fix: re-add /v1/push.token types to rest-typings - #41350
Conversation
🦋 Changeset detectedLatest commit: 76bea4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
WalkthroughRestores ChangesPush token route typings
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
.changeset/fix-rest-typings-push-token.mdpackages/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!
| '/v1/push.token': { | ||
| POST: (payload: PushTokenProps) => { | ||
| result: IPushToken; | ||
| }; | ||
| DELETE: (payload: { token: string }) => { | ||
| success: boolean; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
🗄️ 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.
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.)
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; |
There was a problem hiding this comment.
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>
Proposed changes (including videos or screenshots)
PR #39011 ("chore: modernize code related to pushToken management") removed the
/v1/push.tokenroute fromrest-typings, but the server still serves bothPOSTandDELETEfor it. This left the published@rocket.chat/rest-typingswithout those types, forcing downstream consumers (e.g. the mobile app) to patchnode_modulesto callpush.token.This PR re-adds the route definitions hand-written, matching the server contract and the canonical OpenAPI spec (
Rocket.Chat-Open-API→notifications.yaml,/api/v1/push.token):PushTokenProps(existing) matches the server POST body;IPushTokenis already exported from@rocket.chat/core-typings.Issue(s)
Steps to test or reproduce
sdk.rest.delete('/v1/push.token', { token: 'abc' })/post(...)had no typed route inrest-typings(callers cast or patchnode_modules).ParamsFor<'DELETE', '/v1/push.token'>and thePOSTvariant resolve correctly, removing the need for the downstreamnode_modulespatch.Further comments
Note:
rest-typingsis currently hand-written (compiled viatsc, 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 theRestClient.deletebody fix (#41349) so theDELETEbody is both sent at runtime and typed.Summary by CodeRabbit
Bug Fixes
Chores