-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: InitialData & serverRunning to TS #37929
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
Conversation
|
WalkthroughType updates and startup logic adjustments: Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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). (3)
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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #37929 +/- ##
===========================================
+ Coverage 70.62% 70.65% +0.02%
===========================================
Files 3143 3143
Lines 108688 108694 +6
Branches 19529 19548 +19
===========================================
+ Hits 76763 76796 +33
+ Misses 29923 29904 -19
+ Partials 2002 1994 -8
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
apps/meteor/definition/externals/meteor/meteor.d.tsapps/meteor/server/startup/initialData.tsapps/meteor/server/startup/serverRunning.tspackages/model-typings/src/models/IRoomsModel.tspackages/models/src/models/Rooms.ts
🧰 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/definition/externals/meteor/meteor.d.tspackages/models/src/models/Rooms.tspackages/model-typings/src/models/IRoomsModel.tsapps/meteor/server/startup/initialData.tsapps/meteor/server/startup/serverRunning.ts
🧠 Learnings (5)
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Applied to files:
packages/models/src/models/Rooms.tspackages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.
Applied to files:
packages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.
Applied to files:
packages/model-typings/src/models/IRoomsModel.ts
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.
Applied to files:
apps/meteor/server/startup/initialData.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts
Applied to files:
apps/meteor/server/startup/serverRunning.ts
🧬 Code graph analysis (2)
packages/model-typings/src/models/IRoomsModel.ts (3)
packages/core-typings/src/IRoom.ts (1)
IRoom(20-94)packages/apps-engine/src/definition/rooms/IRoom.ts (1)
IRoom(4-28)packages/apps/src/AppsEngine.ts (1)
IRoom(16-16)
apps/meteor/server/startup/initialData.ts (1)
apps/meteor/app/lib/server/functions/addUserToDefaultChannels.ts (1)
addUserToDefaultChannels(12-47)
⏰ 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). (10)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (3/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (1/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (2/4)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (4/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (1/4)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (4/4)
- GitHub Check: 🔨 Test API (EE) / MongoDB 8.2 coverage (1/1)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (5/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 (2/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (3/4)
🔇 Additional comments (14)
apps/meteor/definition/externals/meteor/meteor.d.ts (1)
11-11: LGTM! Type definition now correctly represents binary data.The return type change from
Promise<EJSON | undefined>toPromise<Uint8Array | undefined>accurately reflects thatgetBinaryAsyncreturns binary asset data. This aligns with the usage ininitialData.tswhere the asset is consumed as a buffer without text encoding.packages/models/src/models/Rooms.ts (1)
2038-2038: Appropriate type broadening to support diverse extraData values.Changing
extraDatafromRecord<string, string>toRecord<string, unknown>allows passing boolean, number, and other property types. This aligns with actual usage in the codebase (e.g.,{ default: true }ininitialData.ts:122) and matches the interface definition update.packages/model-typings/src/models/IRoomsModel.ts (1)
302-302: Interface correctly updated to match implementation.The type change to
Record<string, unknown>maintains consistency with the corresponding implementation inpackages/models/src/models/Rooms.ts.apps/meteor/server/startup/serverRunning.ts (5)
16-16: Good addition of explicit type annotation.The type annotation
ignore: string | undefinedimproves code clarity and type safety.
31-37: Robust version parsing with proper error handling.The added null check and early exit on parse failure prevents downstream errors. Using
parsedSemVer.majoris more reliable than string manipulation for extracting the major version.
40-40: Type annotation accurately reflects runtime behavior.The
string | string[]type correctly models thatmsgstarts as an array before being joined into a string at line 58.
50-56: Optional chaining prevents potential runtime errors.Using
Info.commit?.hashandInfo.commit?.branchsafely handles cases where commit information may be absent, avoidingCannot read property of undefinederrors.
72-79: Verify MongoDB version validation logic change.The
semver.coercefunction correctly normalizes MongoDB version strings (e.g., "7.0.0", "6.0.8") by extracting and coercing the first digit sequence. The dual condition!mongoSemver || semver.satisfies(mongoSemver, '<7.0.0')properly handles both edge cases:
!mongoSemvercatches any coercion failures (malformed version strings)semver.satisfies(mongoSemver, '<7.0.0')validates the version requirementThe logic is equivalent to a direct check but more defensive, protecting against unexpected MongoDB version formats while correctly rejecting anything below 7.0.0.
apps/meteor/server/startup/initialData.ts (6)
1-1: Appropriate imports for typed user creation.Adding
UserStatusandtype IUserenables proper typing throughout the file.
20-28: Well-typed admin user initialization.Using
Partial<IUser>withUserStatusenum values provides proper type safety. Settingstatus: UserStatus.OFFLINEandstatusDefault: UserStatus.ONLINEis semantically clearer than string literals.
136-137: Consistent use of UserStatus enum.Applying
UserStatus.ONLINEfor the rocket.cat bot user maintains consistency with the admin user creation pattern.
145-161: Improved type safety in avatar loading with proper guards.The updated logic correctly handles the new
Uint8Array | undefinedreturn type fromAssets.getBinaryAsync(). Theif (asset)guard ensures all file operations only execute when data is present, and creating the buffer directly fromasset(without utf8 encoding) aligns with binary data handling.
213-228: Precise typing for test admin user.Using
Omit<IUser, 'createdAt' | 'roles' | '_updatedAt'>accurately reflects that these fields are added by the system duringUsers.create().
254-254: Review cast necessity for type compatibility.The cast
adminUser as IUseris required becauseaddUserToDefaultChannelsexpects a fullIUser, butadminUseris typed asOmit<IUser, 'createdAt' | 'roles' | '_updatedAt'>. SinceUsers.create()at line 243 adds these fields to the database but doesn't update the local variable, the cast is necessary.This is acceptable but consider whether
addUserToDefaultChannelscould accept a more flexible type.
https://rocketchat.atlassian.net/browse/CORE-1717
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit
Bug Fixes
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.