Skip to content

fix: re-add /v1/push.token types to rest-typings - #41350

Open
Rohit3523 wants to merge 2 commits into
developfrom
fix/rest-typings-push-token
Open

fix: re-add /v1/push.token types to rest-typings#41350
Rohit3523 wants to merge 2 commits into
developfrom
fix/rest-typings-push-token

Conversation

@Rohit3523

@Rohit3523 Rohit3523 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

PR #39011 ("chore: modernize code related to pushToken management") removed the /v1/push.token route from rest-typings, but the server still serves both POST and DELETE for it. This left the published @rocket.chat/rest-typings without those types, forcing downstream consumers (e.g. the mobile app) to patch node_modules to call push.token.

This PR re-adds the route definitions hand-written, matching the server contract and the canonical OpenAPI spec (Rocket.Chat-Open-APInotifications.yaml, /api/v1/push.token):

'/v1/push.token': {
    POST: (payload: PushTokenProps) => { result: IPushToken };
    DELETE: (payload: { token: string }) => { success: boolean };
};

PushTokenProps (existing) matches the server POST body; IPushToken is already exported from @rocket.chat/core-typings.

Issue(s)

Steps to test or reproduce

  • Before: sdk.rest.delete('/v1/push.token', { token: 'abc' }) / post(...) had no typed route in rest-typings (callers cast or patch node_modules).
  • After: ParamsFor<'DELETE', '/v1/push.token'> and the POST variant resolve correctly, removing the need for the downstream node_modules patch.

Further comments

Note: rest-typings is currently hand-written (compiled via tsc, no OpenAPI generator). The OpenAPI repo already declares this endpoint; this hand-written entry is the practical source of truth until that generation pipeline lands. Pair with the RestClient.delete body fix (#41349) so the DELETE body is both sent at runtime and typed.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Restored client-side type definitions for push token registration and removal.
    • Improved compatibility with the existing push token management endpoints.
  • Chores

    • Published a patch update for the REST API typings package.

@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 76bea4d

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/rest-typings Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings 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

@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Restores /v1/push.token POST and DELETE endpoint typings in @rocket.chat/rest-typings, including IPushToken responses, token deletion payloads, and a patch changeset.

Changes

Push token route typings

Layer / File(s) Summary
Push token route contract
packages/rest-typings/src/v1/push.ts, .changeset/fix-rest-typings-push-token.md
PushEndpoints now defines POST and DELETE contracts for /v1/push.token, and the package receives a patch changeset.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: ggazzo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: restoring /v1/push.token typings in rest-typings.

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.

@dionisio-bot

dionisio-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.37%. Comparing base (012dd32) to head (76bea4d).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41350      +/-   ##
===========================================
- Coverage    68.38%   68.37%   -0.02%     
===========================================
  Files         3970     3970              
  Lines       154935   154935              
  Branches     27807    27810       +3     
===========================================
- Hits        105960   105936      -24     
- Misses       44232    44258      +26     
+ Partials      4743     4741       -2     
Flag Coverage Δ
e2e 59.17% <ø> (-0.09%) ⬇️
e2e-api 44.05% <ø> (+<0.01%) ⬆️
unit 70.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Rohit3523
Rohit3523 marked this pull request as ready for review July 15, 2026 17:47
@Rohit3523
Rohit3523 requested review from a team as code owners July 15, 2026 17:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/rest-typings/src/v1/push.ts`:
- Around line 68-75: Update the '/v1/push.token' endpoint types to use a request
DTO that includes optional voipToken, and replace IPushToken in the POST
response with a response DTO matching the server’s sanitized projection,
including omission of required authToken and nullable userId. Preserve the
existing DELETE contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 629c4a9d-c86d-4923-b3f3-f167e526c97c

📥 Commits

Reviewing files that changed from the base of the PR and between 012dd32 and 76bea4d.

📒 Files selected for processing (2)
  • .changeset/fix-rest-typings-push-token.md
  • packages/rest-typings/src/v1/push.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/rest-typings/src/v1/push.ts
🧠 Learnings (5)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/fix-rest-typings-push-token.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/rest-typings/src/v1/push.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/rest-typings/src/v1/push.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/rest-typings/src/v1/push.ts
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.

Applied to files:

  • packages/rest-typings/src/v1/push.ts
🔇 Additional comments (2)
packages/rest-typings/src/v1/push.ts (1)

1-1: LGTM!

.changeset/fix-rest-typings-push-token.md (1)

1-5: LGTM!

Comment on lines +68 to +75
'/v1/push.token': {
POST: (payload: PushTokenProps) => {
result: IPushToken;
};
DELETE: (payload: { token: string }) => {
success: boolean;
};
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align the endpoint types with the server contract.

PushTokenProps omits the optional voipToken field that the server reads and forwards, preventing typed clients from using the supported VoIP flow. Also, result: IPushToken overstates the POST response: the server returns a sanitized projection that omits required IPushToken.authToken, and its schema allows nullable userId. Use request and response DTOs matching the actual wire contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/rest-typings/src/v1/push.ts` around lines 68 - 75, Update the
'/v1/push.token' endpoint types to use a request DTO that includes optional
voipToken, and replace IPushToken in the POST response with a response DTO
matching the server’s sanitized projection, including omission of required
authToken and nullable userId. Preserve the existing DELETE contract.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/rest-typings/src/v1/push.ts">

<violation number="1" location="packages/rest-typings/src/v1/push.ts:69">
P2: The new POST typing rejects the server-supported optional `voipToken` field, so SDK consumers cannot type-safely register VoIP push tokens. The payload type should include the same optional field as `PushTokenPOST` in the server implementation.

(Based on your team's feedback about keeping API typings aligned with runtime endpoints.) [FEEDBACK_USED]</violation>

<violation number="2" location="packages/rest-typings/src/v1/push.ts:70">
P2: The POST response type `IPushToken` may not accurately reflect the actual server response. If the server returns a sanitized projection (e.g., omitting `authToken` or allowing nullable `userId`), using the full `IPushToken` interface here would give consumers false confidence about the shape of the response at runtime. Consider defining a narrower response DTO (e.g., `Pick<IPushToken, ...>` or `Omit<IPushToken, 'authToken'>`) that matches the actual wire contract, or verify that the server does indeed return the complete `IPushToken` shape.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

};
};
'/v1/push.token': {
POST: (payload: PushTokenProps) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The new POST typing rejects the server-supported optional voipToken field, so SDK consumers cannot type-safely register VoIP push tokens. The payload type should include the same optional field as PushTokenPOST in the server implementation.

(Based on your team's feedback about keeping API typings aligned with runtime endpoints.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/rest-typings/src/v1/push.ts, line 69:

<comment>The new POST typing rejects the server-supported optional `voipToken` field, so SDK consumers cannot type-safely register VoIP push tokens. The payload type should include the same optional field as `PushTokenPOST` in the server implementation.

(Based on your team's feedback about keeping API typings aligned with runtime endpoints.) </comment>

<file context>
@@ -65,4 +65,12 @@ export type PushEndpoints = {
 		};
 	};
+	'/v1/push.token': {
+		POST: (payload: PushTokenProps) => {
+			result: IPushToken;
+		};
</file context>

};
'/v1/push.token': {
POST: (payload: PushTokenProps) => {
result: IPushToken;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The POST response type IPushToken may not accurately reflect the actual server response. If the server returns a sanitized projection (e.g., omitting authToken or allowing nullable userId), using the full IPushToken interface here would give consumers false confidence about the shape of the response at runtime. Consider defining a narrower response DTO (e.g., Pick<IPushToken, ...> or Omit<IPushToken, 'authToken'>) that matches the actual wire contract, or verify that the server does indeed return the complete IPushToken shape.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/rest-typings/src/v1/push.ts, line 70:

<comment>The POST response type `IPushToken` may not accurately reflect the actual server response. If the server returns a sanitized projection (e.g., omitting `authToken` or allowing nullable `userId`), using the full `IPushToken` interface here would give consumers false confidence about the shape of the response at runtime. Consider defining a narrower response DTO (e.g., `Pick<IPushToken, ...>` or `Omit<IPushToken, 'authToken'>`) that matches the actual wire contract, or verify that the server does indeed return the complete `IPushToken` shape.</comment>

<file context>
@@ -65,4 +65,12 @@ export type PushEndpoints = {
 	};
+	'/v1/push.token': {
+		POST: (payload: PushTokenProps) => {
+			result: IPushToken;
+		};
+		DELETE: (payload: { token: string }) => {
</file context>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants