chore(api): migrate chat endpoints to OpenAPI#39820
Conversation
|
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 |
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
WalkthroughThis PR refactors API endpoint definitions for chat and direct message routes to use a fluent builder pattern with explicit OpenAPI/AJV schemas. Additional changes include type refinements for message attachments, conditional field inclusion in quote attachments and pin messages, and test updates reflecting validation error naming conventions. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested labels
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 |
eb144a9 to
9425f11
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## chore/apis #39820 +/- ##
==============================================
- Coverage 70.58% 70.56% -0.02%
==============================================
Files 3256 3256
Lines 115791 115792 +1
Branches 21085 21022 -63
==============================================
- Hits 81727 81706 -21
- Misses 31994 32022 +28
+ Partials 2070 2064 -6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
… response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ponse schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…sponse schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…th response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… response schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ponse schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…onse schema Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…to typed endpoints Converts the last 3 addRoute calls in im.ts (each with dm/im aliases) to the typed .get() chain pattern with response schemas. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The typed endpoint pattern returns 'error-invalid-params' instead of 'invalid-params' when query/body validation fails. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
POST endpoints using body validators return 'invalid-params' (not 'error-invalid-params'). Only GET endpoints with query validators use the 'error-' prefix. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…t and prevent null md createQuoteAttachment was propagating null/undefined md from messages. Now only spreads md when truthy. Also author_link was never set in createQuoteAttachment so it must be optional in the type. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…te attachments - Make message_link required in MessageQuoteAttachment (serves as discriminator for AJV oneOf) - Patch MessageAttachmentDefault schema at runtime to add additionalProperties: false, preventing it from matching every attachment type in the oneOf Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Thank your for the update and for working on the mass migration in #39820. I was following the instructions in RocketChat/Rocket.Chat-Open-API#150 To avoid any future conflicts, is there a way I can see which specific endpoints you are currently working on ? That way I can pick different ones and continue contributing without overlapping. |
The pin message attachment includes nested attachments but the type did not declare it, causing AJV validation to reject it with additionalProperties: false. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Pin attachments include encrypted content from e2e messages. Without this field, additionalProperties: false rejects the attachment. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…or attachment translation Eliminated the @ts-expect-error comments in the AutoTranslate module, clarifying the handling of attachment translations. Updated MessageAttachmentDefault type with a TODO comment to verify the validity of the content field usage.
There was a problem hiding this comment.
1 issue found across 9 files
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/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts">
<violation number="1" location="packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts:40">
P2: `content` is typed too broadly as `object`; use a structured encrypted-content shape to preserve type safety.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| attachments?: MessageAttachment[]; | ||
|
|
||
| /** Encrypted content from e2e messages, preserved in pin attachments */ | ||
| content?: object; // TODO: check if MessageAttachmentDefault[content] is a valid type it does not seem to be used anywhere |
There was a problem hiding this comment.
P2: content is typed too broadly as object; use a structured encrypted-content shape to preserve type safety.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core-typings/src/IMessage/MessageAttachment/MessageAttachmentDefault.ts, line 40:
<comment>`content` is typed too broadly as `object`; use a structured encrypted-content shape to preserve type safety.</comment>
<file context>
@@ -32,4 +33,9 @@ export type MessageAttachmentDefault = {
+ attachments?: MessageAttachment[];
+
+ /** Encrypted content from e2e messages, preserved in pin attachments */
+ content?: object; // TODO: check if MessageAttachmentDefault[content] is a valid type it does not seem to be used anywhere
} & MessageAttachmentBase;
</file context>
…ge parameter
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Refactor