refactor(api): migrate statistics endpoints to chained API pattern#39158
refactor(api): migrate statistics endpoints to chained API pattern#39158smirk-dev wants to merge 1 commit intoRocketChat:developfrom
Conversation
Migrates all 3 statistics API endpoints from the legacy API.v1.addRoute() pattern to the new chained API.v1.get()/API.v1.post() pattern: - GET statistics: with query validation (isStatisticsProps) and IStats response schema - GET statistics.list: with query validation (isStatisticsListProps) and paginated response schema - POST statistics.telemetry: with body validation (TelemetryPayload) and empty success response schema Changes: - apps/meteor/app/api/server/v1/stats.ts: Full endpoint migration with OpenAPI-compatible AJV response schemas, query/body validators, and declare module augmentation for type-safe route registration - packages/rest-typings/src/index.ts: Removed StatisticsEndpoints from Endpoints interface (now provided via module augmentation), added barrel re-export for statistics validators - Added 401/403 error response validators to all endpoints This is part of the ongoing REST API migration effort toward full OpenAPI spec compliance.
|
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: dcd5143 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
📜 Recent 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)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (7)📓 Common learnings📚 Learning: 2026-02-24T19:09:09.561ZApplied to files:
📚 Learning: 2026-02-25T20:10:16.987ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-24T19:09:01.522ZApplied to files:
📚 Learning: 2026-02-23T17:53:06.802ZApplied to files:
🔇 Additional comments (7)
WalkthroughRefactors statistics API endpoints (statistics, statistics.list, statistics.telemetry) from legacy API.v1.addRoute to chained API.v1.get()/post() pattern, with OpenAPI-compatible AJV validation schemas, request/response validation, and type-safe module augmentation for Endpoints. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #39158 +/- ##
===========================================
- Coverage 70.70% 70.69% -0.01%
===========================================
Files 3195 3195
Lines 113095 113095
Branches 20487 20514 +27
===========================================
- Hits 79963 79957 -6
- Misses 31084 31086 +2
- Partials 2048 2052 +4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@ggazzo any further changes required sir, i see you have added the pr to a milestone, but it seems there has been no action taken on the pr yet |
Summary
Migrates all 3 statistics API endpoints from the legacy
API.v1.addRoute()pattern to the new chainedAPI.v1.get()/API.v1.post()pattern with OpenAPI-compatible AJV response schemas, query/body validation, anddeclare moduleaugmentation for type-safe route registration.This continues the ongoing REST API Migration effort toward full OpenAPI spec compliance — cc @diegolmello @guijin.
Endpoints Migrated
1.
GET /v1/statisticsisStatisticsPropsvalidator from rest-typingsIStatsobject withadditionalProperties: true(stats are large dynamic objects)2.
GET /v1/statistics.listisStatisticsListPropsvalidator (paginated request with fields, count, offset, sort, query)statistics[],count,offset,total3.
POST /v1/statistics.telemetryisTelemetryPayloadAJV validator requiringparams[]array witheventNamestring{ success: true })Architecture Changes
API.v1.addRoute("statistics", ...)const statisticsEndpoints = API.v1.get("statistics", ...)query:andbody:response: { 200, 401, 403 }StatisticsEndpointsinEndpointsuniondeclare moduleaugmentation +ExtractRoutesFromAPIChanged Files
apps/meteor/app/api/server/v1/stats.tspackages/rest-typings/src/index.tsStatisticsEndpointsfromEndpointsinterface, addedexport * from "./v1/statistics"barrel export.changeset/refactor-statistics-api-chained-pattern.mdValidation
isStatisticsProps,isStatisticsListProps) reused — no behavioral changesSummary by CodeRabbit