Commit graph

1913 commits

Author SHA1 Message Date
copilot-swe-agent[bot]
5292a9f927 Restore BeforeEntityMutationCallback cast to fix TS2321 excessive stack depth in CI build
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-18 02:26:46 +00:00
copilot-swe-agent[bot]
e077a4d0c3 Remove unnecessary BeforeEntityMutationCallback cast after HasRelations simplification
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-17 21:18:11 +00:00
copilot-swe-agent[bot]
1a5c4373cf Simplify HasRelations using RelationFields extends never form
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-17 21:15:39 +00:00
copilot-swe-agent[bot]
46ea0e2e98 Replace (payload as any).include casts with 'include' in payload narrowing checks
Co-authored-by: jiashengguo <16688722+jiashengguo@users.noreply.github.com>
2026-03-17 07:07:32 +00:00
copilot-swe-agent[bot]
b9d581eab0 Fix build errors caused by SelectIncludeOmit type change
Co-authored-by: jiashengguo <16688722+jiashengguo@users.noreply.github.com>
2026-03-17 06:13:46 +00:00
copilot-swe-agent[bot]
417829388c Fix: Disallow include for models without relation fields (SelectIncludeOmit)
Co-authored-by: jiashengguo <16688722+jiashengguo@users.noreply.github.com>
2026-03-17 05:25:01 +00:00
copilot-swe-agent[bot]
6404c0346c Initial plan 2026-03-17 05:14:08 +00:00
Eugen Istoc
12aeb7bd18
feat(orm): add result plugin extension point (#2442)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 15:33:50 -07:00
Yiming Cao
a6ce140730
perf(orm): batch many-to-many relation manipulation (#2486) 2026-03-15 21:21:24 -07:00
Yiming Cao
0778e493a9
perf(orm): improve post query data processing performance (#2485) 2026-03-14 17:32:33 -07:00
Yiming Cao
49395f7280
perf(orm): avoid unnecessary pre-mutation read and transactions (#2484) 2026-03-14 12:18:11 -07:00
Yiming Cao
7363096e46
fix(orm): diagnostics should return slow queries sorted by duration (#2483) 2026-03-13 12:57:18 -07:00
ymc9
23c86ad344 update test 2026-03-13 10:23:12 -07:00
ymc9
031701b8c5 fix: change $diagnostics to a property 2026-03-13 10:09:01 -07:00
ymc9
e50ced474a fix(orm): diagnostics should return slow queries sorted by duration 2026-03-13 09:40:55 -07:00
Yiming Cao
f85711a8a4
refactor(schema): widen types for attributes, default, and foreignKeyFor (#2482) 2026-03-12 22:51:31 -07:00
Yiming Cao
62dfcd1a85
feat(orm): add $diagnostics() for cache stats and slow query tracking (#2481) 2026-03-12 22:05:24 -07:00
ymc9
c96bdbaf6e address PR comments 2026-03-12 21:35:50 -07:00
ymc9
14b55e32b7 add startedAt field to query info 2026-03-12 21:31:37 -07:00
ymc9
d25c934afe fix test 2026-03-12 20:02:42 -07:00
ymc9
1ba4e54066 refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema
The generated schema previously used `as const` on entire model/enum/typeDef
objects, causing TypeScript to deeply infer literal types for all nested
properties. This is unnecessary for `attributes`, `default`, and `foreignKeyFor`
which are only used at runtime, not in CRUD type computations.

Changes:
- Add type assertions (`as readonly AttributeApplication[]`, `as FieldDefault`,
  `as readonly string[]`) to prevent deep const inference on these properties
- Extract `FieldDefault` type alias from `FieldDef` for cleaner generated code
- Change `FieldHasDefault` to use key existence check (`'default' extends keyof`)
  instead of value type check, enabling the `default` widening
- Conditionally import `AttributeApplication` and `FieldDefault` only when used

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 19:51:43 -07:00
ymc9
de4499ff4c Merge remote-tracking branch 'origin/dev' into feat/diagnostics-property 2026-03-12 19:13:46 -07:00
ymc9
d75f7f3d31 address PR comments 2026-03-12 19:11:57 -07:00
ymc9
eef5fd64cb improve test 2026-03-12 19:09:37 -07:00
ymc9
5a55977316 fix(orm): allow Infinity for slowQueryMaxRecords validation
z.int().nonnegative() rejects Infinity. Use .or(z.literal(Infinity))
to accept both nonnegative integers and Infinity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 19:08:11 -07:00
ymc9
24089deb7c update 2026-03-12 19:01:24 -07:00
ymc9
ae407ac040 feat(orm): add $diagnostics() method for cache stats and slow query tracking
Introduces a new `$diagnostics()` method on ZenStackClient that returns
Zod schema cache statistics and slow query information, helping users
monitor and debug ORM performance.

- Add `diagnostics` option to `ClientOptions` with `slowQueryThresholdMs`
  and `slowQueryMaxRecords` settings
- Track slow queries in `ZenStackQueryExecutor` when diagnostics is enabled
- Share slow query collection across derived clients (via $setAuth,
  $setOptions, $use, transactions, etc.)
- Cap slow query records with an eviction policy that keeps the slowest
  queries (default max: 100)
- Validate diagnostics config with Zod in ClientImpl constructor
- Add `Diagnostics`, `QueryInfo`, and `ZodCacheStats` types
- Add e2e tests covering all diagnostics features

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 17:16:57 -07:00
Yiming Cao
bf6c9a4f5a
refactor(orm): move validateInput logic into InputValidator (#2480)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Yiming Cao <ymc9@users.noreply.github.com>
2026-03-12 16:46:57 -07:00
Yiming Cao
d4fbb38609
fix(orm): add webpack magic comment to suppress bundler warnings for optional dependencies (#2476) 2026-03-11 11:51:25 -07:00
github-actions[bot]
2c32dc329e
[CI] Bump version 3.4.6 (#2477)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-11 11:40:16 -07:00
Yiming Cao
31776a890a
fix(orm): use IS operator for null comparisons in filters (#2475)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:57:21 -07:00
Yiming Cao
d3ab3a60d4
fix(policy): support now() default value in access policy evaluation (#2465) 2026-03-09 08:01:42 -07:00
ymc9
930d9965ac fix(policy): support now() default value in access policy evaluation
- Fill now() default in evalGenerator so createdAt fields are populated
  before policy checks, preventing DefaultInsertValueNode from being
  treated as null during pre-create policy evaluation.
- Fix now() SQL function to produce ISO 8601 format matching each
  dialect's DateTime storage format (SQLite: strftime, MySQL:
  DATE_FORMAT with trimmed microseconds), ensuring correct comparisons
  in policy expressions.
- Add e2e tests for now() in create, read, update, and delete policies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:11:23 -07:00
Yiming Cao
5aaef621b4
chore: address PR comments (#2463) 2026-03-07 16:26:53 -08:00
Pavel Kudinov
20832441c7
fix(policy): handle DefaultInsertValueNode in createManyAndReturn (#2461)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:06:28 -08:00
Yiming Cao
00c53d7fed
fix(sdk): correctly handle mixin fields for delegate model inheritance (#2456) 2026-03-07 10:04:18 -08:00
claude[bot]
956a64ddbe fix(test): correct delegate discriminator enum values to match model names
- Change DataType enum from TEXT/NUMBER to DataText/DataNumber
- Remove explicit dataType field from test as it's auto-set by delegate discriminator
- Fixes MySQL test failure: delegate discriminators must use model names

Co-authored-by: Yiming Cao <ymc9@users.noreply.github.com>
2026-03-07 17:30:46 +00:00
claude[bot]
ffa17203f3 fix(test): add missing dataType field in issue-2351 regression test
The test was failing on MySQL because the dataType enum field was required
but not provided when creating DataText records. MySQL is stricter about
enum validation than SQLite, causing 'Data truncated for column' errors.

Co-authored-by: Yiming Cao <ymc9@users.noreply.github.com>
2026-03-07 17:14:26 +00:00
github-actions[bot]
bd2b111b8e
[CI] Bump version 3.4.5 (#2457)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-06 22:26:46 -08:00
ymc9
4a99088bce fix(sdk): correctly handle mixin fields for delegate model inheritance
Fields inherited via a mixin type on a delegate base model were not
getting their `originModel` set in the generated schema, causing the
ORM to include them in the wrong table's INSERT statement.

Introduces `getOwnedFields` and `getDelegateOriginModel` helpers in
`model-utils.ts` and uses them in both `ts-schema-generator` and
`prisma-schema-generator`, replacing the previous logic that only
checked `field.$container` directly.

Fixes #2351

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 22:25:10 -08:00
Yiming Cao
158996c11e
perf(orm): use EXISTS instead of COUNT subquery for some/none/every relation filters (#2455)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 20:59:52 -08:00
Pavel Kudinov
8208900e09
fix(orm): fallback to compact temp aliases for overlong names (#2425)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-05 22:04:58 -08:00
Yiming Cao
75d77defe1
fix(orm): handle self-referential relations in delegate models during schema push (#2449)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 19:16:58 -08:00
github-actions[bot]
07586f24cf
[CI] Bump version 3.4.4 (#2450)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-04 18:48:24 -08:00
Yiming Cao
3c181f6832
fix(cli): report error when plugin module cannot be resolved (#2447)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 18:14:00 -08:00
Copilot
5bff0253f5
Switch CI from BuildJet to GitHub-hosted runners (#2446)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-04 16:26:45 -08:00
Yiming Cao
0d19325f30
chore: update Claude code review wf (#2444)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-03-04 15:51:57 -08:00
Jiasheng
87a9f7fb3f
fix(proxy): enhance omit configuration to include Unsupported fields (#2441) 2026-03-04 14:54:44 -08:00
Yiming Cao
a49c2da456
fix(cli): add "@zenstackhq/schema" package installation for "zenstack create" and "zen init" (#2437) 2026-03-03 09:43:45 -08:00
github-actions[bot]
518cbb7ddf
[CI] Bump version 3.4.3 (#2436)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-03 09:34:03 -08:00