-
Notifications
You must be signed in to change notification settings - Fork 13k
feat: Add OpenAPI Support to Statistics API #35692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: Add OpenAPI Support to Statistics API #35692
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 |
🦋 Changeset detectedLatest commit: 2748afa The changes in this PR will be included in the next version bump. 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 |
|
@kody start-review |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
I usually run To resolve this, I reverted the unintended changes and manually fixed only my file using the following command: npx eslint --parser @typescript-eslint/parser --parser-options "project: ['./tsconfig.base.json']" apps/meteor/app/api/server/v1/stats.ts --fixThis ensured that only the intended file was fixed and committed correctly. |
|
@kody start-review |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
@kody start-review |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
@kody start-review |
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
|
@kody start-review |
|
Hi @ggazzo, I've refactored the statistics endpoints to improve:
Could you please review these changes and share your feedback. |
ggazzo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no reason to "over-optimize" the code.
keep the functions and schemas directly in the endpoint declarations.
this way TypeScript can infer things like this, and in this case, since we have several schemas and actions, it is better to understand which one belongs what
I see your point! My thought was to improve maintainability by keeping things modular, but I can inline them if that's the preferred structure. Let me know if you want any adjustments! |
|
@kody start-review |
|
Hey @ggazzo, I’ve made the recent changes you suggested by keeping the functions and schemas inline within the endpoint declarations. I also added types for the query parameters and body, and fixed the schema naming to be uppercase. Let me know if you have any feedback! |
|
@ahmed-n-abdeltwab how is your editor configured? we dont need to run the ci to realize we have typescript errors |
I'm using Vim as my editor. With default configuration |
| statistics.routingAlgorithm = settings.get('Livechat_Routing_Method'); | ||
|
|
||
| // TODO: the onHoldEnabled is duplicated in L205 & L230 | ||
| // is on-hold active |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the onHoldEnabled, routingAlgorithm are duplicated in the stats lib
|
@cardoso, pinging you because I think this PR is ready. |
|
@ahmed-n-abdeltwab seems tests are failing, but could be unrelated, I'll rerun them. |
Thank you so much. By the way, I looked at it before pinging you, and it passed the statistics test, I saw it. |
|
im going to update this pr |
…y the oneOf from typia
| totalFailed: number; | ||
| totalPrivateApps: number; | ||
| totalPrivateAppsEnabled: number; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numbers can behave like booleans—0 is treated as false and values greater than 0 as true. This causes confusion with the oneOf schemas generated by Typia
| type slashCommandsDataType = { command: string }; | ||
| type otrDataType = { rid: string }; | ||
|
|
||
| // TODO this is duplicated from /packages/rest-typings/src/v1/statistics.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
| federatedUsers: number; | ||
| lastLogin: string; | ||
| lastMessageSentAt: Date | undefined; | ||
| lastMessageSentAt?: Date; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both strings and dates are serialized as strings in JSON, Typia's oneOf schema may misinterpret them, leading to validation issues.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 |
Description:
This PR integrates OpenAPI support into the
Rocket.Chat API, migrate ofRocket.Chat APIendpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.Key Changes:
Issue Reference:
Relates to #34983, part of the ongoing OpenAPI integration effort.
Testing:
Endpoints:
Get Last Statistics
Get Statistics List
Statistics Telemetry
Looking forward to your feedback! 🚀
Description
This pull request introduces OpenAPI support to the statistics API in the
ahmed-n-abdeltwab/Rocket.Chatrepository. The changes are made in theapps/meteor/app/api/server/v1/stats.tsfile. The update involves refactoring the statistics API routes to incorporate typed validation using ajv schema definitions. This enhancement aims to improve type safety and request validation while preserving the existing functionality of the API. The changes are proposed from thefeat/OpenAPIbranch to be merged into thedevelopbranch.