Skip to content

refactor: migrate livechat/agent.info and livechat/agent.next to OpenAPI chained pattern#39819

Open
NAME-ASHWANIYADAV wants to merge 3 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:migrate/livechat-agent-info-next
Open

refactor: migrate livechat/agent.info and livechat/agent.next to OpenAPI chained pattern#39819
NAME-ASHWANIYADAV wants to merge 3 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:migrate/livechat-agent-info-next

Conversation

@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV commented Mar 23, 2026

PR Description

Migrates the following two legacy addRoute endpoints to the modern OpenAPI chained .get() pattern with AJV runtime validation:

  • GET livechat/agent.info/:rid/:token
  • GET livechat/agent.next/:token

Tracking PR: RocketChat/Rocket.Chat-Open-API#150

Changes Made

apps/meteor/app/livechat/server/api/v1/agent.ts

  • Converted livechat/agent.info/:rid/:token from API.v1.addRoute()API.v1.get() with response validation (200, 400)
  • Converted livechat/agent.next/:token from API.v1.addRoute()API.v1.get() with query (isGETAgentNextToken) and response validation (200, 400)
  • Added module augmentation using ExtractRoutesFromAPI for both new endpoints
  • Merged all module augmentations into a single declare module block

packages/rest-typings/src/v1/omnichannel.ts

  • Added GETAgentInfoSuccessResponse AJV validator (agent required, additionalProperties: false)
  • Added GETAgentNextSuccessResponse AJV validator (agent optional for void return case, additionalProperties: false)
  • Used { type: 'object' } for agent field to avoid $ref / Typia unrolling issues in the livechat/ directory
  • Kept manual typings intact in OmnichannelEndpoints since both endpoints are consumed by @rocket.chat/ddp-client SDK

Verification

Swagger UI

GET /api/v1/livechat/agent.info/:rid/:token

Screenshot 2026-03-23 221820 **`GET /api/v1/livechat/agent.next/:token`** Screenshot 2026-03-23 221851 ### Test Results (`yarn testapi:livechat`)
181 passing (45s)
81 pending
1 failing

1) LIVECHAT - appearance
     POST livechat/appearance
       should update a boolean setting and keep it as boolean:
       AssertionError: expected true to be false
Screenshot 2026-03-22 164319

Note: The single failing test is in POST livechat/appearance (02-appearance.ts) — a pre-existing issue on develop branch, completely unrelated to this migration. All agent.info and agent.next tests in 01-agents.ts pass successfully. ✅

Checklist

  • Chained .get() used
  • { type: 'object' } used for complex types (avoids $ref issues in livechat/)
  • Type inferred via ExtractRoutesFromAPI
  • Manual typings kept in rest-typings (SDK requires it — ddp-client)
  • Server boots without MissingRefError
  • ESLint passes
  • Swagger UI renders correctly
  • yarn testapi:livechat — all relevant tests pass

Summary by CodeRabbit

  • Refactor
    • LiveChat agent info and next-agent REST endpoints migrated to a newer GET-style pattern with improved request/response validation and explicit typed response schemas.
  • Chore
    • Release metadata added to mark related packages for a minor version bump.

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV requested review from a team as code owners March 23, 2026 17:03
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 23, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 23, 2026

🦋 Changeset detected

Latest commit: bfe3fe9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/rest-typings Minor
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-client Major
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-voip Major
@rocket.chat/core-typings Minor
@rocket.chat/apps Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc0aebd9-9a35-4497-9683-423b18b74eea

📥 Commits

Reviewing files that changed from the base of the PR and between 731de22 and bfe3fe9.

📒 Files selected for processing (2)
  • apps/meteor/app/livechat/server/api/v1/agent.ts
  • packages/rest-typings/src/v1/omnichannel.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/app/livechat/server/api/v1/agent.ts
  • packages/rest-typings/src/v1/omnichannel.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer

Walkthrough

Refactored two Livechat REST API endpoints (livechat/agent.info/:rid/:token and livechat/agent.next/:token) from legacy API.v1.addRoute syntax to a typed chained .get() pattern with explicit response schemas and AJV validation; updated TypeScript endpoint type exports and module augmentation accordingly; added changeset marking two packages for a minor bump.

Changes

Cohort / File(s) Summary
Changeset Documentation
\.changeset/refactor-livechat-agent-info-next-chained-pattern.md
Added changeset marking @rocket.chat/meteor and @rocket.chat/rest-typings for a minor version bump describing the migration to the chained .get() route pattern.
Livechat API Endpoints & typings augmentation
apps/meteor/app/livechat/server/api/v1/agent.ts
Rewrote livechat/agent.info/:rid/:token and livechat/agent.next/:token from API.v1.addRoute(..., { async get() { ... } }) to typed API.v1.get(...) endpoint constants using action() handlers. Added route-level AJV response schemas and explicit response mappings for HTTP 200 and 400. Moved livechat/agent.next/:token request validation into the endpoint query field. Updated declare module '@rocket.chat/rest-typings' augmentation to extend new route-derived endpoint types (LivechatAgentInfoEndpoints, LivechatAgentNextEndpoints) and exported those new type aliases. Internal control flow (department resolution, RoutingManager.getNextAgent, findAgent, success responses) preserved.
Rest typings (Omnichannel)
packages/rest-typings/src/v1/omnichannel.ts
Removed the prior OmnichannelEndpoints entries for '/v1/livechat/agent.info/:rid/:token' and '/v1/livechat/agent.next/:token' (these route typings are now produced from the route-derived endpoint types). Minor formatting/whitespace adjustments to several union type lines; no semantic changes to those unions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main refactoring work: migrating two legacy REST API endpoints to the OpenAPI chained pattern with specific endpoint names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor Author

@ggazzo @cardoso Hi! Could you please review this PR at your convenience? It migrates livechat/agent.info/:rid/:token and livechat/agent.next/:token to the OpenAPI chained pattern as part of the ongoing migration effort tracked in RocketChat/Rocket.Chat-Open-API#150. Thank you!

Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed some missing steps. Why was the JSON schema moved to rest-typings rather than staying in the route file? Also, you still need to remove the endpoint definitions

@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor Author

Hey @ahmed-n-abdeltwab, thanks for the reviewing !
Missed two things — the response schemas needed to be defined inline in the route file (I had them in rest-typings instead), and the manual endpoint definitions in OmnichannelEndpoints needed to go. Both sorted now. Let me know if you spot anything else 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants