Commit graph

220 commits

Author SHA1 Message Date
sanny-io
97d674ecdc
feat: phone validation (#2672) 2026-05-23 21:27:54 -07:00
github-actions[bot]
87644178b3
[CI] Bump version 3.7.1 (#2678)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-05-22 08:31:58 -07:00
Lukas Wolf
7bc2fe57d7
feat(orm): implement delegateMap attribute (#2676) 2026-05-22 08:31:43 -07:00
Yiming Cao
026450bfe7
fix(orm): make orderBy nulls optional (#2670)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:13:11 -07:00
github-actions[bot]
b53e908a5d
[CI] Bump version 3.7.0 (#2656)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-05-07 22:35:13 -07:00
ymc9
1997cf3e98 fix(orm): coalesce NULL → '' in single-field _ftsRelevance ORDER BY
`to_tsvector(NULL)` returns NULL and `ts_rank(NULL, ...)` therefore
returns NULL — under Postgres's default `NULLS FIRST` for `ORDER BY DESC`
this would surface NULL-valued rows ahead of any matching ones, an
asymmetry with the multi-field path where `concat_ws(' ', ...)` already
skips NULLs and yields a 0.0 rank. Coalescing the field to `''` aligns
the two paths.

Adds `subtitle: String? @fullText` to the test fixture and a regression
test that orders a NULL-subtitle row against a matching one — without
the fix, the NULL row ranks first under DESC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 21:07:53 -07:00
ymc9
d0dd954827 feat(orm): add @fullText attribute and Postgres full-text search
Introduces a Prisma-style full-text search capability gated by a new
field-level `@fullText` ZModel attribute. PostgreSQL only — MySQL/SQLite
throw NotSupported. Mirrors the existing `@fuzzy` design.

- Filter operator: `where: { title: { fts: { search, config? } } }`
  emits `to_tsvector(field) @@ to_tsquery(query)` (or with a `::regconfig`
  cast when `config` is provided; otherwise Postgres uses the database's
  `default_text_search_config`).
- OrderBy operator: `_ftsRelevance: { fields, search, config?, sort }`
  emits a single `ts_rank(...)`. Multi-field combines fields with
  `concat_ws(' ', ...)` so AND queries match terms across fields
  (matches Prisma's behavior).
- Type-level gating: the `fts` operator and `_ftsRelevance` orderBy
  appear only on String fields annotated with `@fullText` and only when
  the schema's provider is `postgresql`. Slicing's `'FullText'` filter
  kind controls availability of the runtime operator.
- Cursor pagination is rejected when combined with `_ftsRelevance`
  (parallel to `_fuzzyRelevance`).

Also refactors `buildOrderBy` to dispatch to small per-branch helpers
(`applyScalarOrderBy`, `applyAggregationOrderBy`, `applyRelationOrderBy`,
`applyFuzzyRelevanceOrderBy`, `applyFtsRelevanceOrderBy`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 11:34:30 -07:00
Yiming Cao
8ddbfdebdc
feat(orm): add field-level @fuzzy attribute to gate fuzzy search (#2642)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 12:41:09 -07:00
Yiming Cao
eff4263c47
refactor(tanstack-query, orm): thread plugin generics through transactions (#2645)
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 10:56:06 -07:00
docloulou
679f91fc26
feat(orm): add fuzzy search and relevance ordering (PostgreSQL) (#2573)
Some checks failed
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-05-03 20:11:03 -07:00
Yiming Cao
9cef0272e7
chore: upgrade to TypeScript 6 (#2629) 2026-04-29 20:41:27 -07:00
Yiming Cao
2a10bcae09
fix(orm): export UncheckedCreateInput/CheckedCreateInput and add XOR to UpdateInput (#2627)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-29 14:44:21 -07:00
github-actions[bot]
80c0bd6d68
[CI] Bump version 3.6.4 (#2624)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-27 17:50:05 -07:00
github-actions[bot]
8609d5b3e3
[CI] Bump version 3.6.3 (#2613)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-24 21:21:24 -07:00
github-actions[bot]
fd8db57ef2
[CI] Bump version 3.6.2 (#2604)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-22 10:54:53 -07:00
Yiming Cao
14e1d55544
chore: fix up test case (#2600) 2026-04-21 17:33:06 -07:00
Lukas Kahwe Smith
bfdfce13c0
fix(orm): accept plain date strings in DateTime @db.Date field filters (#2572)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-21 16:46:30 -07:00
github-actions[bot]
a1374c042f
[CI] Bump version 3.6.1 (#2598)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-21 08:52:19 -07:00
Erwan JOLY
3398c87dbb
fix(orm): return @db.Time fields as Date instead of raw string (#2589) (#2590) 2026-04-18 20:17:45 -07:00
Yiming Cao
c858bbd4cf
feat(language): allow relation fields in type declarations for mixin use cases (#2583)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 20:01:12 -07:00
Yiming Cao
dc26257553
feat(server): add OpenAPI spec generation for RPC API (#2574)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 21:35:24 -07:00
github-actions[bot]
3dc922d6a9
[CI] Bump version 3.6.0 (#2571)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-11 19:18:20 -07:00
Yiming Cao
39a0a28c51
fix(orm): enforce at most one key per orderBy array element (#2563) 2026-04-06 19:16:27 -07:00
github-actions[bot]
df9b35ea64
[CI] Bump version 3.5.6 (#2560)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-06 13:14:51 -07:00
github-actions[bot]
0495333ca3
[CI] Bump version 3.5.5 (#2553)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-03 14:13:43 -07:00
Emil Redzik
c6c8ad1906
fix(orm): unify zenstack v3 and prisma behavior on empty branches in OR filter (#2528)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-02 23:44:28 -07:00
motopods
5a60fb227d
fix(orm): type inference for polymorphic models (#2543)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-04-02 22:52:10 -07:00
github-actions[bot]
263074ce78
[CI] Bump version 3.5.4 (#2545)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-04-02 10:23:46 -07:00
github-actions[bot]
80f364a2f0
[CI] Bump version 3.5.3 (#2533)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-30 18:40:07 -07:00
Emil Redzik
9346fe92ce
fix(orm): fixed postgres orderBy in nested queries (includes/selects) (#2518)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-28 21:58:31 -07:00
github-actions[bot]
e79ea0cbad
[CI] Bump version 3.5.2 (#2523) 2026-03-26 08:26:49 -07:00
ymc9
3145ba686b fix(cli): regression of CLI plugin resolution 2026-03-24 19:02:25 -07:00
github-actions[bot]
8b1046b2c7
[CI] Bump version 3.5.0 (#2511)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-23 16:31:36 -07:00
Pavel Kudinov
1adf26c216
fix: preserve transaction state in $use, $unuse, and $unuseAll (#2497)
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
2026-03-20 22:24:04 -07:00
Pavel Kudinov
ece062f02b
fix(policy): allow dangerous raw SQL opt-in (#2502) 2026-03-20 12:58:50 -07:00
Yiming Cao
00768de0cc
fix(orm): use uncapitalized model names in OmitConfig and ComputedFieldsOptions (#2496)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 17:47:03 -07:00
Yiming Cao
397d2ab478
fix(orm): improve result field extension plugin's typing (#2492) 2026-03-18 16:21:06 -07:00
ymc9
d982cc528c remove resultField helper 2026-03-18 11:49:21 -07:00
Yiming Cao
c768af7b7c
fix(orm): exclude Unsupported fields from ORM client (#2468) 2026-03-17 12:36:46 -07: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
49395f7280
perf(orm): avoid unnecessary pre-mutation read and transactions (#2484) 2026-03-14 12:18:11 -07:00
ymc9
23c86ad344 update test 2026-03-13 10:23:12 -07:00
Yiming Cao
f85711a8a4
refactor(schema): widen types for attributes, default, and foreignKeyFor (#2482) 2026-03-12 22:51:31 -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
eef5fd64cb improve test 2026-03-12 19:09:37 -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