diff --git a/CHANGELOG.md b/CHANGELOG.md index 25735d3..bfc533d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,11 @@ package release is useful for users. ## Unreleased -No user-facing changes yet. +- Drizzle ORM v1 note: the Drizzle-Zod integration is built into drizzle-orm + on the v1 line (`drizzle-orm/zod`; zod is an optional peer there) — the + standalone `drizzle-zod` package stays on 0.x. Support policy corrected and + the v1 RC canary now smokes schema derivation + parsing through + `drizzle-orm/zod` (the spec skips on 0.x, where the subpath does not exist). ## 0.4.0 - 2026-07-05 diff --git a/README.md b/README.md index 1ca68d8..3534531 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,12 @@ Drizzle ORM v1 (`1.0.0-rc.x`) is supported for the **core surface** as of `0.4.0 the peer range admits `>=1.0.0-rc.1`, and the CI canary runs the full package suite against `drizzle-orm@rc` — module wiring, DI, repositories, testing helpers, and plain query building on all four drivers, including a real -CLS-adapter transaction. Two optional paths stay gated upstream: +CLS-adapter transaction. One optional path stays gated upstream: `@nestjs-cls/transactional-adapter-drizzle-orm` still peer-pins `drizzle-orm@^0` -(works today with an npm override; tracked in -[Papooch/nestjs-cls#599](https://github.com/Papooch/nestjs-cls/issues/599)), and -`drizzle-zod` has no v1-compatible release. Details and the override recipe: +(works today with an npm override; fix proposed in +[Papooch/nestjs-cls#604](https://github.com/Papooch/nestjs-cls/pull/604)). The +Drizzle-Zod path is already solved on v1 — it moved into drizzle-orm as +`drizzle-orm/zod`, and the canary smokes it. Details and the override recipe: [Drizzle ORM v1 (release candidate)](website/docs/support-policy.md#drizzle-orm-v1-release-candidate). For peer dependency policy and API stability, see diff --git a/docs/support-policy.md b/docs/support-policy.md index 67496a6..94ade60 100644 --- a/docs/support-policy.md +++ b/docs/support-policy.md @@ -36,7 +36,9 @@ regressed compatibility. - `@nestjs-cls/transactional-adapter-drizzle-orm` peer-pins `drizzle-orm@^0`, so installing it next to v1 needs an npm override until [Papooch/nestjs-cls#599](https://github.com/Papooch/nestjs-cls/issues/599) - lands. Our canary runs the adapter's real commit/rollback against the RC and + lands (fix proposed in + [Papooch/nestjs-cls#604](https://github.com/Papooch/nestjs-cls/pull/604)). + Our canary runs the adapter's real commit/rollback against the RC and it works at runtime; the override below is a workaround, not a support claim for the adapter itself: @@ -50,16 +52,20 @@ regressed compatibility. } ``` -- `drizzle-zod` has no v1-compatible release (its stable peer range excludes - prereleases), so the optional Drizzle-Zod validation path stays on the - `0.45.x` line. +**Drizzle-Zod on v1 — already solved upstream:** the integration moved into +drizzle-orm itself as the `drizzle-orm/zod` subpath (zod is an optional peer +of drizzle-orm there; `/valibot`, `/typebox`, and `/arktype` moved the same +way). The standalone `drizzle-zod` package stays on the 0.x line, so migrate +the import — `'drizzle-zod'` → `'drizzle-orm/zod'` — when adopting v1. The RC +canary smokes this path (schema derivation + parsing) on every push; the spec +skips on 0.x, where the subpath does not exist. Two migration notes that live in Drizzle's API, not this package's: v1's Relational Queries v2 changes what the database type generic means (tables record → relations) and removes the positional-client init overloads — use the unified `drizzle({ client })` form, which works on `0.32+` and v1 alike. When -v1 goes GA and the two packages above ship v1 support, this policy drops the -RC caveats; the peer range already covers `1.x`. +v1 goes GA and the CLS adapter ships v1 support, this policy drops the RC +caveats; the peer range already covers `1.x`. ## Public API Tiers diff --git a/packages/drizzle/test/drizzle-zod-v1.spec.ts b/packages/drizzle/test/drizzle-zod-v1.spec.ts new file mode 100644 index 0000000..037a6e9 --- /dev/null +++ b/packages/drizzle/test/drizzle-zod-v1.spec.ts @@ -0,0 +1,52 @@ +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; +import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; + +// drizzle-orm v1 folds the Drizzle-Zod integration into the core package as +// the `drizzle-orm/zod` subpath (zod becomes an optional peer of drizzle-orm); +// the standalone `drizzle-zod` package stays on the 0.x line. This spec backs +// the support-policy claim for that path: it skips on 0.x base lanes (the +// subpath does not exist there) and runs on the v1 RC canary lane. +type ZodProbeSchema = { + safeParse: (value: unknown) => { success: boolean }; +}; +type DrizzleOrmZod = { + createSelectSchema: (table: unknown) => ZodProbeSchema; + createInsertSchema: (table: unknown) => ZodProbeSchema; +}; + +function loadDrizzleOrmZod(): DrizzleOrmZod | undefined { + try { + // Feature detection: a static import would fail module resolution on 0.x. + return require('drizzle-orm/zod') as DrizzleOrmZod; + } catch { + return undefined; + } +} + +const drizzleOrmZod = loadDrizzleOrmZod(); + +const users = sqliteTable('zod_probe_users', { + id: integer('id').primaryKey({ autoIncrement: true }), + name: text('name').notNull(), +}); + +describe('drizzle-orm/zod (v1 built-in Drizzle-Zod)', () => { + it( + 'derives select/insert schemas that validate rows', + { + skip: drizzleOrmZod + ? false + : 'drizzle-orm/zod ships on the v1 line only (runs on the RC canary)', + }, + () => { + assert.ok(drizzleOrmZod); + const select = drizzleOrmZod.createSelectSchema(users); + const insert = drizzleOrmZod.createInsertSchema(users); + + assert.equal(select.safeParse({ id: 1, name: 'Ada' }).success, true); + assert.equal(select.safeParse({ id: 'x', name: 42 }).success, false); + assert.equal(insert.safeParse({ name: 'Grace' }).success, true); + }, + ); +}); diff --git a/website/docs/support-policy.md b/website/docs/support-policy.md index 67496a6..94ade60 100644 --- a/website/docs/support-policy.md +++ b/website/docs/support-policy.md @@ -36,7 +36,9 @@ regressed compatibility. - `@nestjs-cls/transactional-adapter-drizzle-orm` peer-pins `drizzle-orm@^0`, so installing it next to v1 needs an npm override until [Papooch/nestjs-cls#599](https://github.com/Papooch/nestjs-cls/issues/599) - lands. Our canary runs the adapter's real commit/rollback against the RC and + lands (fix proposed in + [Papooch/nestjs-cls#604](https://github.com/Papooch/nestjs-cls/pull/604)). + Our canary runs the adapter's real commit/rollback against the RC and it works at runtime; the override below is a workaround, not a support claim for the adapter itself: @@ -50,16 +52,20 @@ regressed compatibility. } ``` -- `drizzle-zod` has no v1-compatible release (its stable peer range excludes - prereleases), so the optional Drizzle-Zod validation path stays on the - `0.45.x` line. +**Drizzle-Zod on v1 — already solved upstream:** the integration moved into +drizzle-orm itself as the `drizzle-orm/zod` subpath (zod is an optional peer +of drizzle-orm there; `/valibot`, `/typebox`, and `/arktype` moved the same +way). The standalone `drizzle-zod` package stays on the 0.x line, so migrate +the import — `'drizzle-zod'` → `'drizzle-orm/zod'` — when adopting v1. The RC +canary smokes this path (schema derivation + parsing) on every push; the spec +skips on 0.x, where the subpath does not exist. Two migration notes that live in Drizzle's API, not this package's: v1's Relational Queries v2 changes what the database type generic means (tables record → relations) and removes the positional-client init overloads — use the unified `drizzle({ client })` form, which works on `0.32+` and v1 alike. When -v1 goes GA and the two packages above ship v1 support, this policy drops the -RC caveats; the peer range already covers `1.x`. +v1 goes GA and the CLS adapter ships v1 support, this policy drops the RC +caveats; the peer range already covers `1.x`. ## Public API Tiers