Skip to content

chore: migrate livechat/tags and livechat/tags/:tagId to OpenAPI chained API pattern#39802

Open
NAME-ASHWANIYADAV wants to merge 2 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:feat/migrate-livechat-tags
Open

chore: migrate livechat/tags and livechat/tags/:tagId to OpenAPI chained API pattern#39802
NAME-ASHWANIYADAV wants to merge 2 commits intoRocketChat:developfrom
NAME-ASHWANIYADAV:feat/migrate-livechat-tags

Conversation

@NAME-ASHWANIYADAV
Copy link
Copy Markdown
Contributor

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

Tracking Issue

Part of RocketChat/Rocket.Chat-Open-API#150

Endpoints migrated:

  • livechat/tags (GET)
  • livechat/tags/:tagId (GET)

Changes

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

  • Fixed text to optional in LivechatTagsListProps type & LivechatTagsListSchema — the existing schema marked text as required, but the actual endpoint and 8+ integration tests treat it as optional. Without this fix, enabling AJV query validation would break all tests that don't pass text.
  • Added response validators:
    • GETLivechatTagsSuccessResponse — paginated response with {tags, count, offset, total, success} and additionalProperties: false
    • GETLivechatTagByIdSuccessResponse — single tag response with {_id, name, description, numDepartments, departments, success} and additionalProperties: false
  • Deleted manual typings for /v1/livechat/tags and /v1/livechat/tags/:tagId from OmnichannelEndpoints (types are now inferred via ExtractRoutesFromAPI)

apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts

  • Converted both legacy API.v1.addRoute() endpoints to chained .get() calls
  • Merged them into the existing livechatTagsEndpoints chain alongside already-migrated tags.save and tags.delete
  • Added query: isLivechatTagsListProps for input validation on the list endpoint
  • Added response validators (200, 401, 403, 404) on both endpoints
  • Business logic is completely unchanged

Endpoint chain structure (after migration):

const livechatTagsEndpoints = API.v1
  .get('livechat/tags', ...)         // ← migrated in this PR
  .get('livechat/tags/:tagId', ...)  // ← migrated in this PR
  .post('livechat/tags.save', ...)   // already migrated
  .post('livechat/tags.delete', ...) // already migrated

SDK Check

  • livechat/tags is NOT consumed by @rocket.chat/ddp-client — safe to delete manual typings

Verification

✅ Build

yarn build — 67/67 packages compiled successfully, 0 errors.

✅ Swagger UI

GET /livechat/tags — 200 OK:

image **`GET /livechat/tags/:tagId` — 404 (expected):** Swagger UI does not render the `:tagId` path parameter input field, so it sends the literal string `:tagId` instead of an actual tag ID — resulting in a `404 "Tag not found"`. This is a Swagger UI rendering limitation, not a code issue. The endpoint works correctly when called with a valid tag ID (verified via `POST /livechat/tags.save` → using the returned `_id`).

WhatsApp Image 2026-03-22 at 4 41 58 PM

✅ Integration Tests

yarn testapi:livechat181 passing, 81 pending (EE), 1 pre-existing failure (unrelated 02-appearance.ts test).

0 failures from this PR's changes.

WhatsApp Image 2026-03-22 at 4 43 27 PM

Checklist

  • Chained .get() used
  • AJV query validation added (isLivechatTagsListProps)
  • Response validators added with additionalProperties: false
  • Types inferred via ExtractRoutesFromAPI
  • Manual typings deleted from rest-typings
  • Server boots without MissingRefError
  • Swagger UI schemas render correctly (200, 401, 403, 404)
  • yarn testapi:livechat passes

Summary by CodeRabbit

  • Refactor

    • Restructured Livechat tags API endpoint registration and handler naming.
    • Added explicit response mappings for 200/401/403/404 status codes.
  • Improvements

    • Made the tag search text parameter optional to allow unfiltered tag retrieval.
    • Added typed success response schemas and stronger response validation.
  • Chores

    • Included a changeset entry marking a minor release for the related packages.

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV requested review from a team as code owners March 22, 2026 11:20
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 22, 2026

🦋 Changeset detected

Latest commit: e790d4d

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

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 22, 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 22, 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: 06aee53d-7b7f-45e6-9868-10825ba37c74

📥 Commits

Reviewing files that changed from the base of the PR and between 9a937c7 and e790d4d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • .changeset/migrate-livechat-tags-openapi.md
  • apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/migrate-livechat-tags-openapi.md
  • apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts

Walkthrough

Refactors Livechat tags server routes to a chained API registration with explicit query and response schemas; updates REST typings to make the text query optional, add AJV-validated success response types, and remove the old route typings; adds a changeset documenting the migration.

Changes

Cohort / File(s) Summary
API Route Refactoring
apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts
Consolidated separate API.v1.addRoute handlers into a chained API.v1.get(...).get(...).post(...).post(...) definition. Added explicit query declaration and response maps for GET routes, renamed get handlers to action, and imported additional types including isLivechatTagsListProps and validateNotFoundErrorResponse.
REST typings & validators
packages/rest-typings/src/v1/omnichannel.ts
Made text optional in LivechatTagsListProps and adjusted schema (nullable: true, removed from required). Removed the two /v1/livechat/tags* route entries from OmnichannelEndpoints. Added AJV-compiled response validators: GETLivechatTagsSuccessResponse and GETLivechatTagByIdSuccessResponse.
Release notes / Changeset
.changeset/migrate-livechat-tags-openapi.md
Added a changeset documenting the migration to the new chained API style and typed response schemas for a minor release.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 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 accurately and clearly summarizes the main change: migrating two legacy endpoints to the OpenAPI chained API pattern, which is the primary focus of all file modifications.
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.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

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

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.

2 participants