-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat(schema): add option for generating lite schema #357
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a "lite" generation mode and CLI flags (--lite, --lite-only), changes TsSchemaGenerator.generate to accept an options object ({ outDir, lite, liteOnly }), threads lite/liteOnly through generation internals to emit schema.ts and/or schema-lite.ts, and updates callers, tests, and samples to use the new behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 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 |
|
Claude finished @ymc9's task —— View job PR Review: feat(schema): add option for generating lite schema
|
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.
Pull Request Overview
This pull request adds support for generating a "lite" version of TypeScript schemas that excludes attribute metadata, reducing the generated code size for runtime usage. The lite schema contains only the essential runtime information needed for query execution.
- Introduced
--liteand--lite-onlyCLI flags to control schema generation modes - Modified
TsSchemaGeneratorto conditionally generate schema files with or without attributes - Updated generated files to import from
schema-lite.tsinstead ofschema.tswhere appropriate
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sdk/src/ts-schema-generator.ts | Core implementation of lite schema generation logic, including conditional attribute generation |
| packages/cli/src/index.ts | Added --lite and --lite-only command-line options |
| packages/cli/src/actions/generate.ts | Passes lite mode options to the TypeScript plugin |
| packages/cli/src/plugins/typescript.ts | Handles lite mode option from plugin configuration |
| tests/regression/generate.ts | Updated to use new API signature with options object |
| tests/e2e/orm/scripts/generate.ts | Updated to use new API signature with options object |
| packages/testtools/src/schema.ts | Updated to use new API signature with options object |
| packages/clients/tanstack-query/scripts/generate.ts | Updated to use new API signature with liteOnly: true |
| packages/clients/tanstack-query/test/schemas/basic/schema-lite.ts | Generated lite schema with attributes removed |
| samples/next.js/zenstack/schema-lite.ts | Generated lite schema for sample project |
| samples/next.js/package.json | Updated script to use --lite flag |
| packages/clients/tanstack-query/package.json | Updated build script to include test generation and type checking |
| packages/clients/tanstack-query/tsconfig.json | Separated test files to dedicated test config |
| packages/clients/tanstack-query/tsconfig.test.json | New TypeScript config for test files with JSX support |
| packages/clients/tanstack-query/test/react-query.test.tsx | Multiple test improvements and import updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @ymc9's task —— View job Claude Code is reviewing this PR… PR Review: feat(schema): add option for generating lite schemaReview Tasks:
Detailed Analysis✅ Core Schema Generator Implementation (packages/sdk/src/ts-schema-generator.ts)Excellent Design Decisions:
✅ CLI IntegrationWell-designed CLI options:
✅ Test Coverage AnalysisStrong Test Implementation:
🔒 Security AssessmentNo Security Concerns Found:
⚡ Performance ImplicationsPositive Performance Impact:
🐛 Code Quality Issues Found1. Minor: Inconsistent Error Handling 2. Suggestion: Validation 📋 Code Quality AssessmentStrengths:
Areas for Enhancement:
🎯 Key Technical Insights
Overall AssessmentThis is a well-architected feature with solid implementation. The core logic is sound, the testing is comprehensive, and the CLI integration follows established patterns. The lite schema approach provides real value for applications needing lightweight runtime schemas while maintaining full compatibility. Code Quality: ⭐⭐⭐⭐⭐ (5/5) Verdict: Approve ✅ |
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: 0
🧹 Nitpick comments (1)
packages/cli/test/ts-schema-gen.test.ts (1)
424-444: Add explicit assertion forschemaLitebefore using non-null assertion.The test uses
schemaLite!without explicitly checking thatschemaLiteis defined. If the lite schema generation fails silently, the error message will be unclear.Add an explicit assertion before the property checks:
); + expect(schemaLite).toBeDefined(); expect(schemaLite!.models.User.attributes).toBeUndefined(); expect(schemaLite!.models.User.fields.id.attributes).toBeUndefined(); expect(schemaLite!.models.User.fields.email.attributes).toBeUndefined();
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/cli/src/plugins/typescript.ts(1 hunks)packages/cli/test/generate.test.ts(1 hunks)packages/cli/test/ts-schema-gen.test.ts(1 hunks)packages/testtools/src/schema.ts(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
packages/cli/test/generate.test.ts (1)
packages/cli/test/utils.ts (2)
createProject(12-18)runCli(20-23)
packages/cli/test/ts-schema-gen.test.ts (1)
packages/testtools/src/schema.ts (1)
generateTsSchema(35-66)
packages/testtools/src/schema.ts (1)
packages/schema/src/schema.ts (1)
SchemaDef(10-18)
packages/cli/src/plugins/typescript.ts (1)
packages/sdk/src/ts-schema-generator.ts (1)
TsSchemaGenerator(60-1450)
⏰ 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)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: claude-review
🔇 Additional comments (5)
packages/cli/test/generate.test.ts (2)
48-53: LGTM!The test correctly validates that the
--liteflag generates bothschema.tsandschema-lite.tsfiles.
55-60: LGTM!The test correctly validates that the
--lite-onlyflag generates onlyschema-lite.tswhile skipping the regularschema.tsfile.packages/cli/src/plugins/typescript.ts (1)
10-25: LGTM!The implementation correctly extracts both
liteandliteOnlyoptions frompluginOptionsand passes them to theTsSchemaGenerator. This addresses the previous review comment about missingliteOnlysupport.packages/testtools/src/schema.ts (2)
40-40: LGTM!The
withLiteSchemaparameter is correctly added as an optional boolean parameter.
54-54: LGTM!The changes correctly adapt to the new
TsSchemaGeneratorAPI:
- Line 54: Passes options object with
liteflag to the generator- Lines 77-83: Gracefully handles optional
schema-lite.jsloading with try-catch- Line 98: Updates
generateTsSchemaInPlaceto use the options object patternThe return type will be correctly inferred to include the optional
schemaLiteproperty.Also applies to: 77-83, 98-98

Summary by CodeRabbit