chore: migrate mailer and mailer.unsubscribe to OpenAPI#39267
chore: migrate mailer and mailer.unsubscribe to OpenAPI#39267amitb0ra wants to merge 2 commits intoRocketChat:developfrom
Conversation
…ation - Migrated mailer and mailer.unsubscribe POST endpoints from addRoute to chainable .post() pattern - Added inline AJV response schemas (200/400/401/403) for OpenAPI 3.0.3 doc generation - Moved type definitions and validators from rest-typings into handler file - Removed packages/rest-typings/src/v1/mailer.ts and mailer/ directory - Updated packages/rest-typings/src/index.ts to remove old imports and re-exports - Uses ExtractRoutesFromAPI + module augmentation for type extraction
|
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 |
🦋 Changeset detectedLatest commit: 9473b97 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 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 |
WalkthroughThis pull request migrates mailer API endpoints from a deprecated Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/meteor/app/api/server/v1/mailer.ts (1)
109-109: Avoid inline lint-disable comments in implementation code.Prefer a config-level override (or shared declaration-file convention) for this augmentation pattern instead of inline suppression comments.
As per coding guidelines: "Avoid code comments in the implementation".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/app/api/server/v1/mailer.ts` at line 109, Remove the inline eslint-disable comment in apps/meteor/app/api/server/v1/mailer.ts and instead handle the augmentation exception at configuration or declaration-file level: either add a targeted override in the shared ESLint config (.eslintrc) to allow `@typescript-eslint/naming-convention` and `@typescript-eslint/no-empty-interface` for declaration/augmentation files, or move the augmentation into a shared .d.ts declaration file (e.g., types/global.d.ts) where you can document and scope the exception without inline suppression; update references to the augmentation so the file no longer contains the inline "eslint-disable-next-line" comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/meteor/app/api/server/v1/mailer.ts`:
- Around line 27-28: The OpenAPI change added nullable: true to the request
schema fields dryrun and query which expands the contract to accept explicit
nulls; revert those schema entries in the mailer.ts request/body definition so
dryrun and query remain optional but not nullable (remove the nullable: true key
for the dryrun and query properties in the schema object), ensuring validation
semantics for dryrun and query are preserved.
---
Nitpick comments:
In `@apps/meteor/app/api/server/v1/mailer.ts`:
- Line 109: Remove the inline eslint-disable comment in
apps/meteor/app/api/server/v1/mailer.ts and instead handle the augmentation
exception at configuration or declaration-file level: either add a targeted
override in the shared ESLint config (.eslintrc) to allow
`@typescript-eslint/naming-convention` and `@typescript-eslint/no-empty-interface`
for declaration/augmentation files, or move the augmentation into a shared .d.ts
declaration file (e.g., types/global.d.ts) where you can document and scope the
exception without inline suppression; update references to the augmentation so
the file no longer contains the inline "eslint-disable-next-line" comment.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.changeset/migrate-mailer-openapi.mdapps/meteor/app/api/server/v1/mailer.tspackages/rest-typings/src/index.tspackages/rest-typings/src/v1/mailer.tspackages/rest-typings/src/v1/mailer/MailerParamsPOST.tspackages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts
💤 Files with no reviewable changes (4)
- packages/rest-typings/src/index.ts
- packages/rest-typings/src/v1/mailer.ts
- packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts
- packages/rest-typings/src/v1/mailer/MailerParamsPOST.ts
📜 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
🧰 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:
apps/meteor/app/api/server/v1/mailer.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
📚 Learning: 2026-02-24T19:09:09.561Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Applied to files:
.changeset/migrate-mailer-openapi.md
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.
Applied to files:
.changeset/migrate-mailer-openapi.mdapps/meteor/app/api/server/v1/mailer.ts
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.
Applied to files:
.changeset/migrate-mailer-openapi.md
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.
Applied to files:
apps/meteor/app/api/server/v1/mailer.ts
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.
Applied to files:
apps/meteor/app/api/server/v1/mailer.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 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:
apps/meteor/app/api/server/v1/mailer.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:
apps/meteor/app/api/server/v1/mailer.ts
🧬 Code graph analysis (1)
apps/meteor/app/api/server/v1/mailer.ts (3)
apps/meteor/app/mail-messages/server/functions/sendMail.ts (1)
sendMail(13-101)apps/meteor/app/api/server/ApiClass.ts (1)
ExtractRoutesFromAPI(74-78)packages/rest-typings/src/index.ts (1)
Endpoints(47-91)
🔇 Additional comments (3)
apps/meteor/app/api/server/v1/mailer.ts (2)
49-104: Route migration preserves the important guards and behavior.Auth requirements,
send-mailpermission, rate limiting, and handler flow are retained while adding explicit response schemas.
106-111: Module augmentation is safe for isolated package compilation.Verification confirms no active legacy SDK typing depends on the migrated mailer endpoints. The module augmentation in
apps/meteorwill not cause typing issues whenpackages/ddp-clientcompiles in isolation, as no legacy SDK methods reference these endpoints..changeset/migrate-mailer-openapi.md (1)
2-3: The review comment is based on an incorrect premise.Mailer types were never exported from
@rocket.chat/rest-typings. The changeset describes a refactoring of endpoint implementation withinapps/meteor(migrating fromaddRouteto the chainable.post()pattern), not a removal of public types from rest-typings. Since the rest-typings public API surface is unchanged, thepatchlevel is appropriate.Likely an incorrect or invalid review comment.
Proposed changes (including videos or screenshots)
Migrate
mailerandmailer.unsubscribeendpoints to the new OpenAPI-compatible chained route definition syntax with AJV body and response validation.Changes
apps/meteor/app/api/server/v1/mailer.tsMailerLocalandMailerUnsubscribeLocaladdRoute()to chained.post()callsExtractRoutesFromAPIanddeclare moduleaugmentationpermissionsRequired: ['send-mail']for mailer endpointrateLimiterOptionsfor mailer.unsubscribe endpointpackages/rest-typings/src/v1/mailer.ts— Deleted (all endpoints migrated)packages/rest-typings/src/v1/mailer/MailerParamsPOST.ts— Deleted (all endpoints migrated)packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts— Deleted (all endpoints migrated)packages/rest-typings/src/index.tsMailerEndpointsimport and entry fromEndpointsinterface.changeset/migrate-mailer-unsubscribe.mdminorbump for@rocket.chat/meteorand@rocket.chat/rest-typingsIssue(s)
Tracking: RocketChat/Rocket.Chat-Open-API#150
Screenshots
mailer

mailer.unsubscribe

Summary by CodeRabbit