-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat(orm): enable JSON filter for typed-json fields; consolidate generation scripts #471
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
WalkthroughThis PR centralizes test schema generation infrastructure by consolidating per-directory Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ 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 Comprehensive Code ReviewI've thoroughly reviewed this PR that enables JSON filtering for typed-json fields and consolidates generation scripts. Here's my complete assessment: Review Tasks:
📋 SummaryThis is a well-structured PR that adds JSON filtering capabilities for typed JSON fields while consolidating scattered generation scripts. The implementation is incremental, maintaining backward compatibility while laying groundwork for future enhancements. 🔍 Detailed Analysis✅ Code Quality & Best PracticesStrengths:
Areas of Excellence:
🧪 Test CoverageComprehensive Testing:
Test Quality:
🛡️ Security ConsiderationsRobust Security:
Security Best Practices:
⚡ Performance ConsiderationsPerformance Optimizations:
Potential Optimizations:
🔧 Script ConsolidationExcellent Refactoring:
Implementation Quality:
🎯 Technical RecommendationsImmediate (Current PR):
Future Enhancements:
Minor Suggestions:
💡 Notable Innovations
🚀 ConclusionThis is a high-quality PR that delivers meaningful functionality while improving codebase maintainability. The implementation is:
The changes successfully enable JSON filtering for typed JSON fields and provide a solid foundation for future enhancements. The script consolidation is a welcome improvement that reduces maintenance overhead. Recommendation: APPROVE - This PR is ready for merge and represents quality software development practices. |
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 PR consolidates test generation scripts across multiple test directories and adds JSON filter support for typed-json fields. The main changes include:
- Consolidates generation scripts: Removes duplicate generation scripts from
tests/runtimes/edge-runtime,tests/runtimes/bun,tests/regression, andtests/e2edirectories and replaces them with a single shared script atscripts/test-generate.ts - Enables JSON filter for typed-json fields: Adds a new test schema and test case demonstrating JSON filtering on typed-json fields
- Removes generator blocks: Cleans up unnecessary Prisma generator blocks from test schemas
Reviewed changes
Copilot reviewed 36 out of 40 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
scripts/test-generate.ts |
New centralized test generation script that can scan for all schemas and handle runtime-specific generation |
tests/runtimes/*/package.json |
Updated to reference the new centralized generation script |
tests/runtimes/*/scripts/generate.ts |
Deleted - replaced by centralized script |
tests/regression/generate.ts |
Deleted - replaced by centralized script |
tests/e2e/scripts/generate.ts |
Deleted - replaced by centralized script |
tests/e2e/orm/schemas/typed-json/* |
New schema and generated files for typed-json field testing |
tests/e2e/orm/client-api/json-filter.test.ts |
Added test demonstrating JSON filtering on typed-json fields |
tests/e2e/orm/schemas/*/schema.zmodel |
Removed unnecessary generator blocks and updated plugin paths |
tests/e2e/github-repos/*/schema.zmodel |
Removed generator blocks from test schemas |
tests/e2e/github-repos/*/*.test.ts |
Removed redundant test files that only verified schema generation |
tests/e2e/github-repos/*/{models,input}.ts |
New generated TypeScript files for GitHub repo test schemas |
tests/regression/test/v2-migrated/*.test.ts |
Removed generator blocks from embedded test schemas |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 (7)
packages/orm/src/client/query-utils.ts (1)
193-195: NewisTypeDefhelper is consistent with existing schema utilitiesImplementation is straightforward and mirrors the existing
getTypeDef/isEnumpatterns; no functional issues. If you ever want to reduce duplication, you could haveisTypeDefdelegate togetTypeDef, but that’s purely optional.tests/e2e/orm/client-api/json-filter.test.ts (1)
4-4: Good coverage for typed-JSON field filteringThe new test that uses
typedJsonSchemaand exercisesequalsandnotfilters on theprofiletyped-JSON field is a solid end-to-end check that the new filter path works as intended and returns the full user record. This aligns well with the goal of validating ORM behavior on realistic schemas. Based on learnings, this fits the e2e testing guidance.If CI log noise becomes an issue, you might consider dropping
debug: truehere once the feature stabilizes.Also applies to: 236-251
tests/runtimes/bun/package.json (1)
8-8: Bun runtime tests now delegate to shared generator with runtime overrideUsing
RUNTIME=bun tsx ../../../scripts/test-generate.tscleanly reuses the centralized generator while signaling the desired runtime viaprocess.env.RUNTIME. This keeps Bun’s behavior aligned with other runtimes without duplicating generation logic.If Windows support becomes a priority, consider wrapping this in a cross-platform env helper (e.g.,
cross-env) to avoidRUNTIME=...shell syntax issues.packages/orm/src/client/crud/dialects/base-dialect.ts (1)
31-32: NarrowisTypeDefusage to typed-JSON fields and update TODORouting TypeDef-backed fields through
buildJsonFilteris the right direction for typed-JSON support, butisTypeDef(this.schema, fieldDef.type)currently matches all typeDefs. If you ever define non-JSON typeDefs (e.g., string/int aliases), their filters will now be treated as JSON equality/not-only filters, which is likely not what you want and differs from previous behavior where such filters were effectively unsupported.Consider tightening this condition to only apply to typeDefs whose underlying scalar is
Json(or whatever constraint defines “typed JSON” in your schema model), e.g. by:
- Inspecting the referenced typeDef’s base type, or
- Introducing a dedicated helper like
isTypedJsonField(schema, fieldDef)and using that here.Also, the
// TODO: type-def field filteringcomment is now outdated or at least too vague—either remove it or clarify what remains (e.g., “TODO: support non-JSON typeDef filters”).Also applies to: 504-507
scripts/test-generate.ts (1)
1-24: Centralized test generator works; consider simplifying async/sync and ergonomicsThe script correctly discovers
schema.zmodelfiles under the providedbaseDir, computes the CLI path relative toscripts/, and invokespackages/cli/dist/index.jswith the requestedRUNTIME. That matches how the updated package.json scripts are calling it.A couple of small cleanups you might consider:
mainandgeneratedon’t actually perform any async work (everything is sync viaglob.syncandexecSync), so they don’t need to beasync, and theawait generate(file)is redundant. Making these functions synchronous will simplify control flow and avoid dangling Promises from the top-levelmain()call.- Optionally, wrapping
execSyncin a try/catch to print a clearer error (e.g., whendist/index.jshasn’t been built yet) could make failures easier to diagnose in CI, but current behavior is functionally correct.For example, you could refactor along these lines:
-async function main() { +function main() { const baseDir = process.argv[2] || '.'; const zmodelFiles = [...glob.sync(path.resolve(baseDir, '**/schema.zmodel'), { ignore: '**/node_modules/**' })]; for (const file of zmodelFiles) { console.log(`Generating TS schema for: ${file}`); - await generate(file); + generate(file); } } -async function generate(schemaPath: string) { +function generate(schemaPath: string) { const cliPath = path.join(_dirname, '../packages/cli/dist/index.js'); const RUNTIME = process.env.RUNTIME ?? 'node'; execSync(`${RUNTIME} ${cliPath} generate --schema ${schemaPath}`, { cwd: path.dirname(schemaPath) }); }packages/orm/src/client/crud/validator/index.ts (2)
381-387: Consider preserving validation error details in the custom schema.Using
z.custom((v) => schema!.safeParse(v).success)loses the detailed validation error messages from the original schema. When validation fails, users will only see a generic error rather than which specific field failed validation.Consider using
z.customwith an error message orsuperRefineto propagate the actual validation errors:- const finalSchema = z.custom((v) => schema!.safeParse(v).success); + const finalSchema = z.custom((v) => { + const result = schema!.safeParse(v); + return result.success; + }, { message: 'Invalid typed JSON object' });Alternatively, if detailed errors are important, consider using
transformorsuperRefineto preserve error details while still returning the original input.
538-545: Placeholder implementation acknowledged with TODO.The
makeTypedJsonFilterSchemacurrently delegates to the generic JSON filter schema, which is a reasonable incremental approach. The TODO comment makes it clear this is intended for future enhancement with direct typed JSON filtering capabilities.Do you want me to open an issue to track the "direct typed JSON filtering" TODO, or help design the typed filter schema when you're ready to implement it?
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (35)
packages/clients/tanstack-query/package.json(1 hunks)packages/clients/tanstack-query/scripts/generate.ts(0 hunks)packages/orm/src/client/crud-types.ts(2 hunks)packages/orm/src/client/crud/dialects/base-dialect.ts(2 hunks)packages/orm/src/client/crud/validator/index.ts(3 hunks)packages/orm/src/client/query-utils.ts(1 hunks)scripts/test-generate.ts(1 hunks)tests/e2e/github-repos/cal.com/cal-com.test.ts(0 hunks)tests/e2e/github-repos/cal.com/models.ts(1 hunks)tests/e2e/github-repos/formbricks/formbricks.test.ts(0 hunks)tests/e2e/github-repos/formbricks/input.ts(1 hunks)tests/e2e/github-repos/formbricks/models.ts(1 hunks)tests/e2e/github-repos/formbricks/schema.zmodel(0 hunks)tests/e2e/github-repos/trigger.dev/input.ts(1 hunks)tests/e2e/github-repos/trigger.dev/models.ts(1 hunks)tests/e2e/github-repos/trigger.dev/trigger-dev.test.ts(0 hunks)tests/e2e/orm/client-api/json-filter.test.ts(2 hunks)tests/e2e/orm/schemas/basic/schema.zmodel(1 hunks)tests/e2e/orm/schemas/petstore/schema.zmodel(1 hunks)tests/e2e/orm/schemas/todo/todo.zmodel(1 hunks)tests/e2e/orm/schemas/typed-json/input.ts(1 hunks)tests/e2e/orm/schemas/typed-json/models.ts(1 hunks)tests/e2e/orm/schemas/typed-json/schema.ts(1 hunks)tests/e2e/orm/schemas/typed-json/schema.zmodel(1 hunks)tests/e2e/package.json(1 hunks)tests/e2e/scripts/generate.ts(0 hunks)tests/regression/generate.ts(0 hunks)tests/regression/package.json(1 hunks)tests/regression/test/v2-migrated/issue-1647.test.ts(0 hunks)tests/regression/test/v2-migrated/issue-756.test.ts(0 hunks)tests/regression/test/v2-migrated/issue-804.test.ts(0 hunks)tests/runtimes/bun/package.json(1 hunks)tests/runtimes/bun/scripts/generate.ts(0 hunks)tests/runtimes/edge-runtime/package.json(1 hunks)tests/runtimes/edge-runtime/scripts/generate.ts(0 hunks)
💤 Files with no reviewable changes (12)
- tests/e2e/github-repos/formbricks/formbricks.test.ts
- tests/e2e/github-repos/formbricks/schema.zmodel
- tests/e2e/scripts/generate.ts
- tests/regression/generate.ts
- tests/e2e/github-repos/cal.com/cal-com.test.ts
- tests/regression/test/v2-migrated/issue-756.test.ts
- tests/e2e/github-repos/trigger.dev/trigger-dev.test.ts
- tests/regression/test/v2-migrated/issue-804.test.ts
- tests/runtimes/bun/scripts/generate.ts
- packages/clients/tanstack-query/scripts/generate.ts
- tests/regression/test/v2-migrated/issue-1647.test.ts
- tests/runtimes/edge-runtime/scripts/generate.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.zmodel
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.zmodel: Always runzenstack generateafter modifying ZModel schemas
ZModel schema files should define database structure and policies that compile to TypeScript viazenstack generate
Files:
tests/e2e/orm/schemas/basic/schema.zmodeltests/e2e/orm/schemas/petstore/schema.zmodeltests/e2e/orm/schemas/todo/todo.zmodeltests/e2e/orm/schemas/typed-json/schema.zmodel
tests/e2e/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
E2E tests should validate real-world schema compatibility with established projects
Files:
tests/e2e/orm/schemas/typed-json/models.tstests/e2e/orm/client-api/json-filter.test.tstests/e2e/github-repos/formbricks/input.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/github-repos/formbricks/models.tstests/e2e/github-repos/trigger.dev/input.tstests/e2e/orm/schemas/typed-json/input.tstests/e2e/github-repos/cal.com/models.tstests/e2e/github-repos/trigger.dev/models.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests
Applied to files:
tests/regression/package.jsonscripts/test-generate.tspackages/clients/tanstack-query/package.jsontests/e2e/orm/client-api/json-filter.test.tstests/runtimes/edge-runtime/package.jsontests/e2e/github-repos/trigger.dev/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects
Applied to files:
tests/regression/package.jsontests/e2e/orm/schemas/basic/schema.zmodeltests/e2e/package.jsonscripts/test-generate.tstests/e2e/orm/schemas/typed-json/models.tstests/e2e/orm/client-api/json-filter.test.tstests/runtimes/edge-runtime/package.jsontests/e2e/github-repos/formbricks/input.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/github-repos/formbricks/models.tspackages/orm/src/client/crud/validator/index.tstests/e2e/github-repos/trigger.dev/input.tstests/e2e/orm/schemas/typed-json/input.tstests/e2e/github-repos/cal.com/models.tstests/e2e/github-repos/trigger.dev/models.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/cli/**/*.test.{ts,tsx} : CLI package tests should focus on action-specific tests for each command
Applied to files:
tests/regression/package.jsontests/e2e/package.jsonscripts/test-generate.tspackages/clients/tanstack-query/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use Turbo for build orchestration and run `pnpm build`, `pnpm watch`, `pnpm lint`, and `pnpm test` for development tasks
Applied to files:
tests/regression/package.jsontests/e2e/package.jsonpackages/clients/tanstack-query/package.jsontests/runtimes/bun/package.jsontests/runtimes/edge-runtime/package.json
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
packages/orm/src/client/query-utils.tspackages/orm/src/client/crud/dialects/base-dialect.tstests/e2e/orm/schemas/typed-json/schema.tspackages/orm/src/client/crud/validator/index.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Applied to files:
tests/e2e/orm/schemas/basic/schema.zmodeltests/e2e/orm/schemas/petstore/schema.zmodeltests/e2e/orm/schemas/todo/todo.zmodelscripts/test-generate.tstests/e2e/orm/schemas/typed-json/models.tstests/e2e/orm/schemas/typed-json/schema.zmodeltests/e2e/github-repos/formbricks/input.tstests/e2e/orm/schemas/typed-json/schema.tstests/e2e/github-repos/formbricks/models.tstests/e2e/github-repos/trigger.dev/input.tstests/e2e/orm/schemas/typed-json/input.tstests/e2e/github-repos/cal.com/models.tstests/e2e/github-repos/trigger.dev/models.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
tests/e2e/orm/schemas/basic/schema.zmodeltests/e2e/orm/schemas/petstore/schema.zmodeltests/e2e/orm/schemas/todo/todo.zmodelpackages/orm/src/client/crud/dialects/base-dialect.tstests/e2e/orm/schemas/typed-json/models.tstests/e2e/github-repos/formbricks/input.tspackages/orm/src/client/crud-types.tstests/e2e/orm/schemas/typed-json/schema.tspackages/orm/src/client/crud/validator/index.tstests/e2e/github-repos/trigger.dev/input.tstests/e2e/orm/schemas/typed-json/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : Always run `zenstack generate` after modifying ZModel schemas
Applied to files:
tests/e2e/orm/schemas/petstore/schema.zmodelscripts/test-generate.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Applied to files:
tests/e2e/orm/schemas/petstore/schema.zmodeltests/e2e/orm/schemas/todo/todo.zmodeltests/e2e/orm/client-api/json-filter.test.tstests/e2e/github-repos/formbricks/input.tspackages/orm/src/client/crud/validator/index.tstests/e2e/github-repos/trigger.dev/input.tstests/e2e/orm/schemas/typed-json/input.ts
📚 Learning: 2025-10-21T16:04:56.292Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/crud/dialects/base-dialect.ts:745-747
Timestamp: 2025-10-21T16:04:56.292Z
Learning: In packages/runtime/src/client/crud/dialects/base-dialect.ts, it's intentional that buildCursorFilter applies default ordering (via makeDefaultOrderBy fallback) while buildOrderBy does not. This ensures cursor-based pagination always has stable ordering for correctness, while regular queries remain unordered unless explicitly specified. This design is to be consistent with Prisma's pagination requirements.
Applied to files:
packages/orm/src/client/crud/dialects/base-dialect.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
packages/orm/src/client/crud/dialects/base-dialect.tstests/e2e/orm/schemas/typed-json/models.tstests/e2e/github-repos/formbricks/input.tspackages/orm/src/client/crud-types.tstests/e2e/orm/schemas/typed-json/schema.tspackages/orm/src/client/crud/validator/index.tstests/e2e/orm/schemas/typed-json/input.ts
🧬 Code graph analysis (8)
packages/orm/src/client/query-utils.ts (1)
packages/schema/src/schema.ts (1)
SchemaDef(11-19)
packages/orm/src/client/crud/dialects/base-dialect.ts (1)
packages/orm/src/client/query-utils.ts (1)
isTypeDef(193-195)
scripts/test-generate.ts (1)
packages/cli/src/utils/exec-utils.ts (1)
execSync(7-16)
tests/e2e/orm/schemas/typed-json/models.ts (3)
tests/e2e/github-repos/cal.com/models.ts (2)
User(17-17)Profile(19-19)tests/e2e/github-repos/formbricks/models.ts (1)
User(313-313)tests/e2e/github-repos/trigger.dev/models.ts (1)
User(10-10)
packages/orm/src/client/crud-types.ts (1)
packages/schema/src/schema.ts (3)
GetModelFieldType(166-170)GetTypeDefs(142-142)ModelFieldIsOptional(232-236)
tests/e2e/orm/schemas/typed-json/schema.ts (3)
packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)packages/schema/src/schema.ts (1)
SchemaDef(11-19)tests/e2e/github-repos/formbricks/schema.ts (1)
schema(3028-3028)
tests/e2e/github-repos/formbricks/models.ts (3)
tests/e2e/github-repos/cal.com/models.ts (10)
Webhook(39-39)Membership(25-25)ApiKey(41-41)Account(44-44)User(17-17)MembershipRole(119-119)MembershipRole(120-120)IdentityProvider(113-113)IdentityProvider(114-114)Role(105-105)tests/e2e/github-repos/trigger.dev/models.ts (4)
DataMigration(24-24)Project(21-21)Organization(17-17)User(10-10)tests/e2e/orm/schemas/typed-json/models.ts (1)
User(10-10)
tests/e2e/orm/schemas/typed-json/input.ts (2)
tests/e2e/github-repos/formbricks/input.ts (20)
UserFindManyArgs(491-491)UserFindUniqueArgs(492-492)UserFindFirstArgs(493-493)UserCreateArgs(494-494)UserCreateManyArgs(495-495)UserCreateManyAndReturnArgs(496-496)UserUpdateArgs(497-497)UserUpdateManyArgs(498-498)UserUpdateManyAndReturnArgs(499-499)UserUpsertArgs(500-500)UserDeleteArgs(501-501)UserDeleteManyArgs(502-502)UserCountArgs(503-503)UserAggregateArgs(504-504)UserGroupByArgs(505-505)UserWhereInput(506-506)UserSelect(507-507)UserInclude(508-508)UserOmit(509-509)UserGetPayload(510-510)tests/e2e/github-repos/cal.com/input.ts (20)
UserFindManyArgs(151-151)UserFindUniqueArgs(152-152)UserFindFirstArgs(153-153)UserCreateArgs(154-154)UserCreateManyArgs(155-155)UserCreateManyAndReturnArgs(156-156)UserUpdateArgs(157-157)UserUpdateManyArgs(158-158)UserUpdateManyAndReturnArgs(159-159)UserUpsertArgs(160-160)UserDeleteArgs(161-161)UserDeleteManyArgs(162-162)UserCountArgs(163-163)UserAggregateArgs(164-164)UserGroupByArgs(165-165)UserWhereInput(166-166)UserSelect(167-167)UserInclude(168-168)UserOmit(169-169)UserGetPayload(170-170)
⏰ 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). (4)
- GitHub Check: Agent
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: claude-review
🔇 Additional comments (18)
tests/e2e/orm/schemas/basic/schema.zmodel (1)
7-7: Policy plugin path alignment looks good—ensure generation was rerunPointing the
policyplugin to../../../../../packages/plugins/policy/plugin.zmodelbrings this schema in line with the shared plugin location. Please just confirmzenstack generate/ the test generation script has been rerun so the generated TS for this schema is up to date. As per coding guidelines, ZModel changes should always be followed by regeneration.packages/orm/src/client/crud-types.ts (1)
308-315: Typed JSON filter wiring for typedef-backed fields looks correct—just double‑check non‑JSON typedef usageRouting
WhereInputthrough:GetModelFieldType<Schema, Model, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter : PrimitiveFilter<...>makes previously unfilterable typedef-typed fields JSON‑filterable, and
TypedJsonFilter = JsonFilterkeeps their semantics aligned with plainJsonfields, which matches the intent of enabling JSON filters for typed‑json.One nuance to validate: this condition will apply to any field whose type name is a typedef, regardless of whether it’s stored as JSON (e.g., via
@json). If you ever have typedef‑typed fields that are not JSON‑backed, they would now accept JSON‑style filters as well; in that case you might want to gate this branch by a field‑level “json” flag instead of relying solely on the type name. Based on learnings, TypeDefs are reused in multiple ways, so it’s worth a quick scan of existing typedef usages to confirm this matches expectations.Also applies to: 465-467
tests/e2e/orm/schemas/todo/todo.zmodel (1)
10-12: Todo schema now uses shared policy plugin—confirm regenerationSwitching to
plugin policywith provider../../../../../packages/plugins/policy/plugin.zmodelaligns this schema with the centralized policy plugin configuration. Please confirm you’ve rerunzenstack generate/ the e2e generation script so all derived TS for this schema reflects the new plugin wiring. As per coding guidelines, ZModel edits should always be followed by regeneration.tests/e2e/orm/schemas/petstore/schema.zmodel (1)
6-8: Petstore schema policy plugin configuration is consistent—ensure outputs are regeneratedUsing the shared
policyplugin at../../../../../packages/plugins/policy/plugin.zmodelbrings this schema in line with the rest of the e2e suite. Please just double‑check thatzenstack generate/ the updated test generation pipeline has been run so the generated client/types for this schema are synchronized. As per coding guidelines, ZModel schemas should always be regenerated after edits.tests/e2e/orm/schemas/typed-json/schema.zmodel (1)
1-30: Typed‑JSON test schema is well‑structured—just confirm generated artifacts are syncedThe
User.profile: Profile @jsonplus nestedProfile/Job/Addresstypedefs andGenderenum give a clean surface for exercising typed‑json filtering, including nested arrays and optionals. No issues spotted in the schema itself; please just confirm you’ve rerun the generation step so the correspondingschema.ts/models.ts/input.tsfiles used by the e2e tests are in sync with this definition. As per coding guidelines, ZModel changes should always be followed byzenstack generate.tests/e2e/github-repos/cal.com/models.ts (1)
1-174: Generated Cal.com model typings look consistentThis file follows the usual generated pattern (ModelResult‑based model aliases plus enum value/union exports) and matches the schema‑driven structure; nothing to change here.
tests/e2e/github-repos/trigger.dev/models.ts (1)
1-172: Generated Trigger.dev model typings look consistentThe ModelResult aliases and enum constant/union exports follow the expected generated pattern and line up with the schema; no issues from a code-review standpoint.
tests/e2e/package.json (1)
8-8: Centralized e2e test generation script wiring looks correct
test:generatenow points to../../scripts/test-generate.ts, which resolves fromtests/e2eto the new shared generator at the repo root and uses the defaultbaseDir='.'to scope generation to this package. No issues from a path or workflow perspective.tests/runtimes/edge-runtime/package.json (1)
8-8: Edge-runtime test generator correctly points to shared scriptThe new
test:generatepath (tsx ../../../scripts/test-generate.ts) correctly resolves fromtests/runtimes/edge-runtimeto the centralized generator and keeps runtime defaulting tonode. This is consistent with the broader consolidation.packages/clients/tanstack-query/package.json (1)
13-13: TanStack Query tests now use centralized generator with scoped baseDir
test:generatenow invokestsx ../../../scripts/test-generate.ts tests, correctly resolving to the root generator and limiting discovery to the localtestsfolder. This keeps the workflow consistent with other packages while avoiding cross-package schema discovery.tests/regression/package.json (1)
7-7: Regression tests correctly migrated to shared generatorThe
generatescript now callstsx ../../scripts/test-generate.ts ./test, which resolves to the root generator and confines schema discovery to thetestsubdirectory of the regression suite. This keeps the existingpnpm generate && tsc && vitest runflow intact while removing the per-suite generator.packages/orm/src/client/crud/validator/index.ts (1)
442-443: LGTM!The new type-def type check is correctly placed in the filter schema construction logic, routing typed JSON fields to the appropriate filter schema while maintaining the existing enum and array field handling.
tests/e2e/orm/schemas/typed-json/schema.ts (1)
1-99: Generated schema file looks correct.The generated schema properly defines the typed JSON test case with a
Usermodel containing aprofilefield of typeProfile(a TypeDef), along with nested type definitions (Address,Job) and theGenderenum. The structure aligns with the PR's objective of enabling JSON filter for typed-json fields. Based on learnings, E2E tests should validate real-world schema compatibility, and this schema provides a good test fixture for the new typed JSON filtering feature.tests/e2e/orm/schemas/typed-json/models.ts (1)
1-15: Generated models file follows established patterns.The type exports correctly differentiate between
$ModelResultfor theUsermodel and$TypeDefResultfor the TypeDef types (Profile,Address,Job). TheGenderenum export pattern (both const and type) matches the established code generation conventions.tests/e2e/github-repos/formbricks/input.ts (1)
1-710: Generated input types file validates Formbricks schema compatibility.This comprehensive generated type file covers all 35 models from the Formbricks schema, providing strongly-typed ORM argument and payload types. The consistent generation pattern (
FindManyArgs,CreateArgs,WhereInput,GetPayload, etc.) for each model enables type-safe ORM operations. Based on learnings, this validates real-world schema compatibility with Formbricks, an established project.tests/e2e/github-repos/trigger.dev/input.ts (1)
1-1030: Generated input types file validates Trigger.dev schema compatibility.This generated type file covers 51 models from the Trigger.dev schema with the same consistent typing pattern. Based on learnings, this validates real-world schema compatibility with Trigger.dev, an established project, ensuring the ORM type generation works correctly for complex, production-grade schemas.
tests/e2e/orm/schemas/typed-json/input.ts (1)
1-30: LGTM! Generated file follows established patterns.The generated type definitions correctly follow the same structure as other input files in the codebase (e.g.,
tests/e2e/github-repos/formbricks/input.tsandtests/e2e/github-repos/cal.com/input.ts). All standard ORM operation types for the User entity are properly exported with correct generic parameterization.tests/e2e/github-repos/formbricks/models.ts (1)
1-468: LGTM! Comprehensive generated model definitions.The generated models correctly follow established patterns from other e2e test schemas (e.g.,
tests/e2e/github-repos/cal.com/models.ts). The file includes:
- 32 properly typed model exports using the
$ModelResultpattern- Comprehensive JSDoc documentation for each entity
- Consistent enum constant and type declarations
- Real-world schema validation for Formbricks compatibility
This aligns with the coding guideline that E2E tests should validate real-world schema compatibility with established projects.
Summary by CodeRabbit
Release Notes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.