chore(api): migrate omnichannel single-route endpoints to typed HTTP methods
Draft
GG
3mo ago+987+987+012345678901234567890123456789-419-419-012345678901234567890123456789
Proposed changes
Continues the API endpoint migration (docs/api-endpoint-migration.md): moves legacy API.v1.addRoute() omnichannel endpoints to the typed API.v1.get/post/put pattern with AJV request/response validation.
Migrated (14 single-route files)
livechat/offline.message,livechat/integrations.settings,livechat/queue,livechat/transfer.history/:rid,livechat/page.visited,livechat/agents/:agentId/departments,livechat/webhook.test,omnichannel/integrations,livechat/appearance(GET + POST),livechat/business-hour,livechat/config- ee:
livechat/business-hours,livechat/inquiry.setSLA,omnichannel/:rid/request-transcript
Pre-existing typed endpoints keep their manual rest-typings entry (moderation pattern); untyped ones (webhook.test, request-transcript) are augmented via ExtractRoutesFromAPI.
Docs
Extended docs/api-endpoint-migration.md:
- New section on migrating endpoints already declared in
Endpoints(keep manual entry, do not re-augment β avoids TS2717). - New "Common Type Errors" section:
SuccessResultinterface-vs-object-literal, optionalthis.user.username/this.requestIp,failure()requiring400, method-scopedpermissionsRequired. - Refreshed reference paths after the backend reorg (#41126).
Notes
- No behavior change β pure refactor/typing; no changeset needed.
upload.tsandsms.tsdeferred (complex payloads;uploadhits the knownIMessageattachmentoneOfvalidation issue). ~223addRoutecalls remain repo-wide.
Testing
tsc --noEmitclean for all migrated files.- eslint + prettier clean.
- Response schemas validate only under
TEST_MODE; no migrated GET-query path asserts the oldinvalid-paramserror format, so no e2e test changes required.
Summary by CodeRabbit
- Improvements
- Standardized multiple Livechat omnichannel endpoints to use explicit AJV-based request/response validation with consistent success and error payloads (including business hours, inquiries/SLA, transcripts, agent departments, appearance, config, integrations, offline messages, page visited, queue metrics, transfers, and webhooks).
- Refined error handling and response shaping for invalid-room/access and webhook/transcript failure scenarios.
- Improved robustness with test-mode cache timing adjustments and safer audit metadata defaults.
- Documentation
- Updated the API Endpoint Migration Guide with new conventions, conflict guidance, troubleshooting, and expanded schema reference coverage.
- Chores
- Expanded the shared AJV schema bundle to include additional Livechat and settings types.