Schema sync api#353
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a ChangesSchema synchronization
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant pushCommand
participant ProjectAPI
participant ProjectDatabase
Developer->>pushCommand: Run ub push
pushCommand->>ProjectAPI: PUT /projects/:projectId/sync-schema
ProjectAPI->>ProjectDatabase: Atomically replace collections
ProjectDatabase-->>ProjectAPI: Updated project
ProjectAPI-->>pushCommand: Synced collection names
pushCommand-->>Developer: Print synchronization summary
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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: 2
🧹 Nitpick comments (1)
apps/dashboard-api/src/controllers/syncSchema.controller.js (1)
15-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract shared helpers instead of mirroring from
project.controller.js.The comment explicitly states these helpers are "mirrored from project.controller.js." Duplicating
normalizeFieldKey,normalizeFieldType,isRequiredField,toPlainObject,sanitizeSchemaFields,getDefaultRlsForCollection, andvalidateUsersSchemaacross two controllers risks divergent behavior — a bug fix in one location won't propagate to the other. Extract these into a shared module (e.g.,packages/common/src/utils/schema.helpers.js) and import from both controllers.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/dashboard-api/src/controllers/syncSchema.controller.js` at line 15, Extract normalizeFieldKey, normalizeFieldType, isRequiredField, toPlainObject, sanitizeSchemaFields, getDefaultRlsForCollection, and validateUsersSchema from both controllers into a shared schema helpers module, then update syncSchema.controller.js and project.controller.js to import and use those shared implementations instead of maintaining duplicated helpers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/dashboard-api/src/controllers/syncSchema.controller.js`:
- Line 179: Update the users collection check in the relevant schema-sync logic
to compare entry.name case-insensitively using entry.name.toLowerCase() ===
"users", matching getDefaultRlsForCollection and ensuring validation applies to
names such as "Users".
In `@sdks/urbackend-cli/src/commands/push/index.ts`:
- Around line 76-78: Update the catch-all branch in the push command’s error
handling to include the caught error details in the logger.error call instead of
logging only the generic connection message. Preserve the existing
APIError-specific handling and exit-code behavior, while adding clear context
and the original error for unexpected failures.
---
Nitpick comments:
In `@apps/dashboard-api/src/controllers/syncSchema.controller.js`:
- Line 15: Extract normalizeFieldKey, normalizeFieldType, isRequiredField,
toPlainObject, sanitizeSchemaFields, getDefaultRlsForCollection, and
validateUsersSchema from both controllers into a shared schema helpers module,
then update syncSchema.controller.js and project.controller.js to import and use
those shared implementations instead of maintaining duplicated helpers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a0d5d6d4-aca4-46f4-9141-d0130b1cc60f
📒 Files selected for processing (8)
apps/dashboard-api/src/app.jsapps/dashboard-api/src/controllers/syncSchema.controller.jsapps/dashboard-api/src/routes/projects.jspackages/common/src/index.jspackages/common/src/utils/input.validation.jssdks/urbackend-cli/src/commands/push/index.tssdks/urbackend-cli/src/index.tssdks/urbackend-cli/src/services/project.service.ts
|
@yash-pouranik |
🚀 Pull Request Description
I had created the backend infrastructure and CLI tooling for a declarative
Schema as Codeworkflow. It allows developers to define and update their MongoDB schemas locally in their repository &atomically synchronize them to the remote urBackend project usingub push.🛠️ Type of Change
🧪 Testing & Validation
Backend Verification:
npm testin thebackend/directory and all tests passed.Frontend Verification:
npm run lintin thefrontend/directory.✅ Checklist
Summary by CodeRabbit
pushcommand to sync local schemas with a linked remote project.PUT /projects/:projectId/sync-schemato sync collections (with schema validation and plan-based limits).