zodvex 0.8.0-beta.0 → 0.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +78 -107
  2. package/dist/cli/index.d.ts +1 -1
  3. package/dist/cli/index.js +604 -1364
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/cli/inspect-schema/census.mjs +112 -0
  6. package/dist/cli/inspect-schema/inspect-worker.mjs +24 -0
  7. package/dist/cli/inspect-schema/inspect.mjs +177 -0
  8. package/dist/client/index.js +106 -24
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/codegen/index.js +373 -508
  11. package/dist/codegen/index.js.map +1 -1
  12. package/dist/core/index.js +312 -253
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/index.js +312 -253
  15. package/dist/index.js.map +1 -1
  16. package/dist/internal/actionCtx.d.ts.map +1 -1
  17. package/dist/internal/boundaryHelpers.d.ts +12 -15
  18. package/dist/internal/boundaryHelpers.d.ts.map +1 -1
  19. package/dist/internal/codec.d.ts +4 -0
  20. package/dist/internal/codec.d.ts.map +1 -1
  21. package/dist/internal/customization.d.ts +33 -15
  22. package/dist/internal/customization.d.ts.map +1 -1
  23. package/dist/internal/db.d.ts +174 -29
  24. package/dist/internal/db.d.ts.map +1 -1
  25. package/dist/internal/functions/contracts.d.ts +66 -0
  26. package/dist/internal/functions/contracts.d.ts.map +1 -0
  27. package/dist/internal/{custom.d.ts → functions/customFunctions.d.ts} +32 -30
  28. package/dist/internal/functions/customFunctions.d.ts.map +1 -0
  29. package/dist/internal/{init.d.ts → functions/init.d.ts} +69 -66
  30. package/dist/internal/functions/init.d.ts.map +1 -0
  31. package/dist/internal/ids.d.ts +1 -1
  32. package/dist/internal/ids.d.ts.map +1 -1
  33. package/dist/internal/{builders.d.ts → legacy/builders.d.ts} +2 -2
  34. package/dist/internal/legacy/builders.d.ts.map +1 -0
  35. package/dist/internal/{wrappers.d.ts → legacy/wrappers.d.ts} +2 -2
  36. package/dist/internal/legacy/wrappers.d.ts.map +1 -0
  37. package/dist/internal/model.d.ts +105 -6
  38. package/dist/internal/model.d.ts.map +1 -1
  39. package/dist/internal/modelSchemaBundle.d.ts.map +1 -1
  40. package/dist/internal/paginationCodec.d.ts +8 -0
  41. package/dist/internal/paginationCodec.d.ts.map +1 -0
  42. package/dist/internal/registry.d.ts +7 -2
  43. package/dist/internal/registry.d.ts.map +1 -1
  44. package/dist/internal/schema/id.d.ts +29 -0
  45. package/dist/internal/schema/id.d.ts.map +1 -0
  46. package/dist/internal/schema.d.ts +13 -55
  47. package/dist/internal/schema.d.ts.map +1 -1
  48. package/dist/internal/schemaHelpers.d.ts +1 -1
  49. package/dist/internal/schemaHelpers.d.ts.map +1 -1
  50. package/dist/internal/stream.d.ts +110 -0
  51. package/dist/internal/stream.d.ts.map +1 -0
  52. package/dist/internal/zx.d.ts +2 -28
  53. package/dist/internal/zx.d.ts.map +1 -1
  54. package/dist/internal/zxDateBrand.d.ts +5 -0
  55. package/dist/internal/zxDateBrand.d.ts.map +1 -0
  56. package/dist/labs/index.js +122 -78
  57. package/dist/labs/index.js.map +1 -1
  58. package/dist/legacy/index.d.ts +1 -1
  59. package/dist/legacy/index.d.ts.map +1 -1
  60. package/dist/legacy/index.js +101 -293
  61. package/dist/legacy/index.js.map +1 -1
  62. package/dist/mini/client/index.js +106 -24
  63. package/dist/mini/client/index.js.map +1 -1
  64. package/dist/mini/index.js +312 -253
  65. package/dist/mini/index.js.map +1 -1
  66. package/dist/mini/react/index.js +143 -23
  67. package/dist/mini/react/index.js.map +1 -1
  68. package/dist/mini/server/index.js +1210 -1202
  69. package/dist/mini/server/index.js.map +1 -1
  70. package/dist/public/cli/commands.d.ts.map +1 -1
  71. package/dist/public/cli/index.d.ts +1 -1
  72. package/dist/public/cli/init.d.ts +1 -2
  73. package/dist/public/cli/init.d.ts.map +1 -1
  74. package/dist/public/cli/migrate.d.ts.map +1 -1
  75. package/dist/public/client/index.d.ts +1 -1
  76. package/dist/public/client/index.d.ts.map +1 -1
  77. package/dist/public/client/zodvexClient.d.ts +23 -9
  78. package/dist/public/client/zodvexClient.d.ts.map +1 -1
  79. package/dist/public/codegen/discover.d.ts +0 -44
  80. package/dist/public/codegen/discover.d.ts.map +1 -1
  81. package/dist/public/codegen/discovery-hooks.d.ts +2 -1
  82. package/dist/public/codegen/discovery-hooks.d.ts.map +1 -1
  83. package/dist/public/codegen/extractCodec.d.ts.map +1 -1
  84. package/dist/public/codegen/generate.d.ts +6 -79
  85. package/dist/public/codegen/generate.d.ts.map +1 -1
  86. package/dist/public/codegen/index.d.ts +1 -1
  87. package/dist/public/codegen/index.d.ts.map +1 -1
  88. package/dist/public/codegen/tsconfigPaths.d.ts +41 -0
  89. package/dist/public/codegen/tsconfigPaths.d.ts.map +1 -0
  90. package/dist/public/codegen/zodToSource.d.ts.map +1 -1
  91. package/dist/public/mini/index.d.ts +1 -1
  92. package/dist/public/mini/index.d.ts.map +1 -1
  93. package/dist/public/mini/model.d.ts +53 -3
  94. package/dist/public/mini/model.d.ts.map +1 -1
  95. package/dist/public/model.d.ts +53 -3
  96. package/dist/public/model.d.ts.map +1 -1
  97. package/dist/public/react/hooks.d.ts +28 -2
  98. package/dist/public/react/hooks.d.ts.map +1 -1
  99. package/dist/public/react/index.d.ts +1 -1
  100. package/dist/public/react/index.d.ts.map +1 -1
  101. package/dist/public/react/zodvexReactClient.d.ts.map +1 -1
  102. package/dist/public/server/index.d.ts +7 -6
  103. package/dist/public/server/index.d.ts.map +1 -1
  104. package/dist/react/index.js +143 -23
  105. package/dist/react/index.js.map +1 -1
  106. package/dist/server/index.js +1210 -1202
  107. package/dist/server/index.js.map +1 -1
  108. package/package.json +8 -4
  109. package/src/cli/index.ts +1 -1
  110. package/src/internal/actionCtx.ts +9 -14
  111. package/src/internal/boundaryHelpers.ts +44 -14
  112. package/src/internal/codec.ts +36 -8
  113. package/src/internal/customization.ts +84 -32
  114. package/src/internal/db.ts +819 -63
  115. package/src/internal/functions/contracts.ts +313 -0
  116. package/src/internal/{custom.ts → functions/customFunctions.ts} +173 -151
  117. package/src/internal/{init.ts → functions/init.ts} +202 -187
  118. package/src/internal/ids.ts +11 -4
  119. package/src/internal/{builders.ts → legacy/builders.ts} +38 -65
  120. package/src/internal/{wrappers.ts → legacy/wrappers.ts} +6 -14
  121. package/src/internal/mapping/types.ts +2 -2
  122. package/src/internal/model.ts +312 -76
  123. package/src/internal/modelSchemaBundle.ts +2 -2
  124. package/src/internal/paginationCodec.ts +60 -0
  125. package/src/internal/registry.ts +50 -3
  126. package/src/internal/schema/id.ts +52 -0
  127. package/src/internal/schema.ts +45 -78
  128. package/src/internal/schemaHelpers.ts +3 -3
  129. package/src/internal/stream.ts +242 -0
  130. package/src/internal/types.ts +2 -2
  131. package/src/internal/zx.ts +15 -60
  132. package/src/internal/zxDateBrand.ts +34 -0
  133. package/src/legacy/index.ts +1 -1
  134. package/src/public/cli/commands.ts +59 -180
  135. package/src/public/cli/index.ts +16 -1
  136. package/src/public/cli/init.ts +3 -16
  137. package/src/public/cli/inspect-schema/census.mjs +112 -0
  138. package/src/public/cli/inspect-schema/inspect-worker.mjs +24 -0
  139. package/src/public/cli/inspect-schema/inspect.mjs +177 -0
  140. package/src/public/cli/migrate.ts +0 -120
  141. package/src/public/client/index.ts +1 -1
  142. package/src/public/client/zodvexClient.ts +74 -22
  143. package/src/public/codegen/discover.ts +34 -148
  144. package/src/public/codegen/discovery-hooks.ts +73 -8
  145. package/src/public/codegen/extractCodec.ts +5 -11
  146. package/src/public/codegen/generate.ts +45 -719
  147. package/src/public/codegen/index.ts +0 -1
  148. package/src/public/codegen/tsconfigPaths.ts +224 -0
  149. package/src/public/codegen/zodToSource.ts +17 -10
  150. package/src/public/mini/index.ts +2 -0
  151. package/src/public/mini/model.ts +89 -3
  152. package/src/public/model.ts +89 -3
  153. package/src/public/react/hooks.ts +145 -16
  154. package/src/public/react/index.ts +1 -1
  155. package/src/public/react/zodvexReactClient.ts +6 -2
  156. package/src/public/server/index.ts +51 -35
  157. package/dist/internal/builders.d.ts.map +0 -1
  158. package/dist/internal/custom.d.ts.map +0 -1
  159. package/dist/internal/functionContracts.d.ts +0 -60
  160. package/dist/internal/functionContracts.d.ts.map +0 -1
  161. package/dist/internal/init.d.ts.map +0 -1
  162. package/dist/internal/ruleTypes.d.ts +0 -104
  163. package/dist/internal/ruleTypes.d.ts.map +0 -1
  164. package/dist/internal/rules.d.ts +0 -27
  165. package/dist/internal/rules.d.ts.map +0 -1
  166. package/dist/internal/wrappers.d.ts.map +0 -1
  167. package/src/internal/functionContracts.ts +0 -270
  168. package/src/internal/ruleTypes.ts +0 -120
  169. package/src/internal/rules.ts +0 -779
package/README.md CHANGED
@@ -2,43 +2,33 @@
2
2
 
3
3
  #### [Zod](https://zod.dev/) + [Convex](https://www.convex.dev/)
4
4
 
5
- Type-safe Convex functions with Zod v4 schemas. Codecs in the schema — `zx.date()`, custom transformations — plus typed IDs, all wired up through `initZodvex`.
6
-
7
- > Built on top of [convex-helpers](https://github.com/get-convex/convex-helpers)
8
-
9
- ## Table of Contents
10
-
11
- - [Why zodvex?](#why-zodvex)
12
- - [Installation](#installation)
13
- - [Quick Start](#quick-start)
14
- - [Import Paths](#import-paths)
15
- - [Features](#features)
16
- - [Codec-Aware Database](#codec-aware-database)
17
- - [Codegen & Client-Side Schema Sharing](#codegen--client-side-schema-sharing)
18
- - [Using zodvex Without Codecs](#using-zodvex-without-codecs)
19
- - [Supported Types](#supported-types)
20
- - [Upgrading?](#upgrading)
21
- - [API Reference](#api-reference)
22
- - [Roadmap](#roadmap)
23
- - [License](#license)
5
+ Use Zod v4 as your schema language for Convex — define your data once and use it end to end, with automatic function validation and a codec-aware database.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/zodvex)](https://www.npmjs.com/package/zodvex)
8
+ [![CI](https://github.com/panzacoder/zodvex/actions/workflows/ci.yml/badge.svg)](https://github.com/panzacoder/zodvex/actions/workflows/ci.yml)
9
+ [![license](https://img.shields.io/npm/l/zodvex)](./LICENSE)
24
10
 
25
11
  ## Why zodvex?
26
12
 
27
- - **Codec-aware database** — `zx.date()`, `zx.codec()` encode/decode automatically at `ctx.db` boundaries
28
- - **Correct optional/nullable semantics** — preserves Convex's distinction (`.optional()` → `v.optional(T)`, `.nullable()` → `v.union(T, v.null())`)
29
- - **Client-safe models** — `defineZodModel` is importable in React
30
- - **End-to-end type safety** — same schema from database to frontend forms
13
+ **Your Zod schemas are the source of truth** — tables, function arguments, and return types defined once, used database to frontend. Two things make that real:
14
+
15
+ - **Functions execute your Zod schemas.** Wrappers parse declared arguments before the handler and encode declared returns. Zod refinements and codec logic run alongside Convex’s structural checks. Parsing and encoding have different transform/default behavior; current wrappers use synchronous Zod operations.
16
+
17
+ - **Modeled database reads run full Zod validation.** The wrapped `ctx.db` parses modeled documents on reads and encodes insert/replace values through the model schema. Codecs live in the schema itself, so handlers can work with `Date` objects while Convex stores plain values.
31
18
 
32
- | Feature | zodvex | convex-helpers/zod4 |
33
- |---------|--------|---------------------|
34
- | Codec-aware DB | `initZodvex` wraps `ctx.db` automatically | Manual |
35
- | Date handling | `zx.date()` — automatic Date ↔ timestamp | Manual `z.codec()` |
36
- | Typed IDs | `zx.id('table')` with type branding | Manual |
37
- | Custom codecs | `zx.codec()` with auto-detection | Not provided |
38
- | Client-safe models | `defineZodModel` (importable in React) | Not provided |
39
- | Codegen | Optional typed hooks, boundary helpers | Not provided |
19
+ What you gain over Convex out of the box:
40
20
 
41
- Both are valid choices — zodvex trades some explicitness for significantly better ergonomics.
21
+ | | Convex | with zodvex |
22
+ |---|---|---|
23
+ | Type safety | end-to-end inference | same — driven by your Zod schemas |
24
+ | Runtime validation | structural checks | Zod parsing/encoding for declared function schemas and modeled data |
25
+ | End-to-end validation | per-function validators | shared Zod definitions across configured client, function, and database paths |
26
+ | Client calls | `useQuery(api.fn)` infers types | registry args encoded and results parsed, with a configurable decode-error policy |
27
+ | Dates & custom types | `number` timestamps | `Date` objects and custom codecs (`zx.date()`, `zx.codec()`) |
28
+ | Rows on read | as stored | modeled documents parsed & decoded through your schema |
29
+ | Row-level rules & audit | build your own | `.withRules()` / `.audit()` on `ctx.db` |
30
+
31
+ All of it wired once with `initZodvex` — see [Features](#features).
42
32
 
43
33
  ## Installation
44
34
 
@@ -72,7 +62,9 @@ export const EventModel = defineZodModel('events', {
72
62
 
73
63
  > `defineZodModel` is client-safe — you can import it in React.
74
64
 
75
- ### Step 2. Build your schema
65
+ ### Step 2. Wire it up
66
+
67
+ Two one-time files: build your Convex schema from your models, and create your function builders.
76
68
 
77
69
  ```ts
78
70
  // convex/schema.ts
@@ -84,8 +76,6 @@ export default defineZodSchema({
84
76
  })
85
77
  ```
86
78
 
87
- ### Step 3. Set up builders
88
-
89
79
  ```ts
90
80
  // convex/functions.ts
91
81
  import { initZodvex } from 'zodvex/server'
@@ -101,9 +91,9 @@ export const { zq, zm, za, ziq, zim, zia } = initZodvex(schema, {
101
91
  })
102
92
  ```
103
93
 
104
- `initZodvex` returns builders for all six Convex function types. By default, `zq` and `zm` (and internal variants) wrap `ctx.db` with automatic codec encode/decode.
94
+ `initZodvex` returns builders for all six Convex function types, with `ctx.db` wrapped for automatic codec encode/decode. You write these two files once and rarely touch them again.
105
95
 
106
- ### Step 4. Write functions — Date conversion Just Works
96
+ ### Step 3. Write functions
107
97
 
108
98
  ```ts
109
99
  // convex/events.ts
@@ -114,7 +104,7 @@ import { EventModel } from './models'
114
104
 
115
105
  export const list = zq({
116
106
  args: {},
117
- returns: EventModel.schema.docArray,
107
+ returns: zx.docArray(EventModel),
118
108
  handler: async (ctx) => {
119
109
  // Dates come back as Date objects, not numbers
120
110
  return await ctx.db.query('events').collect()
@@ -136,42 +126,75 @@ export const create = zm({
136
126
  })
137
127
  ```
138
128
 
139
- > `zx.id('events')` is a typed Convex ID validator — it provides type branding for `GenericId<'events'>` but is NOT a codec (no wire transformation happens). `zx.date()` and `zx.codec()` ARE codecs.
129
+ > `zx.id('events')` is a typed ID validator — branding only, no wire transform. `zx.date()` and `zx.codec()` are codecs. Details in [Features](#features).
140
130
 
141
131
  See the full [quickstart example](./examples/quickstart/) for a runnable project.
142
132
 
143
133
  ## Import Paths
144
134
 
145
- Four entry points:
135
+ Four primary entry points:
146
136
 
147
137
  - **`zodvex`** — Client-safe full-Zod surface. Use in React components and shared code.
148
138
  - **`zodvex/server`** — Server-only. Use in Convex functions and schema definitions.
149
139
  - **`zodvex/mini`** — Client-safe zod/mini surface.
150
140
  - **`zodvex/mini/server`** — Server-only zod/mini surface.
151
- - **`zodvex/legacy`** — Deprecated runtime APIs kept only for migration.
152
141
 
153
- > `zodvex/core` remains as a deprecated compatibility alias for `zodvex`.
142
+ Focused entrypoints — `zodvex/react`, `zodvex/client`, `zodvex/codegen` (and their `zodvex/mini` variants) — back the codegen workflow and are mostly consumed by generated code; see [Codegen](#codegen--client-side-schema-sharing).
143
+
144
+ Two deprecated paths remain for migration only:
145
+
146
+ - **`zodvex/legacy`** — Deprecated runtime APIs kept only for migration.
147
+ - **`zodvex/core`** — Deprecated compatibility alias for `zodvex`.
154
148
 
155
149
  ## Features
156
150
 
157
151
  ### Codec-Aware Database
158
152
 
159
- `initZodvex` wraps `ctx.db` so reads decode automatically and writes encode automatically.
153
+ `initZodvex` wraps `ctx.db` so modeled reads decode automatically and insert/replace values encode automatically. Codecs are opt-in per field — schemas without them get the same validation, typed IDs, and correct optional/nullable mapping through the exact same setup.
160
154
 
161
155
  - **`zx.date()`** — Date ↔ timestamp codec. Stored as `v.float64()`, used as `Date` in handlers.
162
156
  - **`zx.codec(wire, runtime, transforms)`** — Custom codecs for complex transformations (encryption, serialization, etc.).
163
- - **`zx.id('table')`** — Typed Convex ID validator with `GenericId<T>` branding. This is NOT a codec — no wire transformation happens.
157
+ - **`zx.id('table')`** — Typed Convex ID validator with `GenericId<T>` branding — no wire transform (not a codec).
158
+
159
+ Object patches encode supplied fields without validating the merged document or retaining outer object refinements; union patches use full encoding. Unmodeled tables and system access pass through. `unwrap()` or `wrapDb: false` bypass wrapping. See the [boundary contract](./docs/decisions/2026-09-07-boundary-contract.md).
164
160
 
165
161
  Guides: [Custom Codecs](./docs/guide/custom-codecs.md), [Date Handling](./docs/guide/date-handling.md)
166
162
 
163
+ ### Row-Level Rules & Audit
164
+
165
+ The same wrapped `ctx.db` carries per-row rules and audit hooks. Modeled reads and supplied write values use decoded runtime types:
166
+
167
+ - **`.withRules(ruleCtx, rules)`** — gate and transform reads and writes per table (`read`, `insert`, `patch`, `replace`, `delete`), with an optional deny-by-default policy.
168
+ - **`.audit({ afterRead, afterWrite })`** — observe completed inner reads and writes. Composition order determines what audit sees; an audit layer outside `.withRules()` observes the rules-processed results.
169
+
170
+ Guide: [Rules & Audit](./docs/guide/rules-and-audit.md)
171
+
172
+ ### Composable with Triggers
173
+
174
+ The codec wrapper can delegate to an underlying db you supply, so `ctx.db`-wrapping libraries like `convex-helpers/server/triggers` compose instead of colliding — codec on top, triggers underneath, real db at the bottom:
175
+
176
+ ```ts
177
+ const triggers = new Triggers<DataModel>()
178
+ export const { zq, zm, zim /* ... */ } = initZodvex(schema, server, {
179
+ underlyingDb: { mutation: (ctx) => triggers.wrapDB(ctx).db },
180
+ })
181
+ ```
182
+
183
+ Triggers fire inside zodvex mutations and observe native wire-format writes — which unlocks the aggregate component's table-trigger mode, model-bound cascades, and similar reactive patterns. `ctx.db.unwrap()` is the matching escape hatch for direct access to the underlying db.
184
+
185
+ Guide: [Builders — Composing with triggers](./docs/guide/builders.md#composing-with-convex-helpers-triggers-underlyingdb)
186
+
167
187
  ### Codegen & Client-Side Schema Sharing
168
188
 
169
189
  zodvex includes an optional CLI that generates typed client code:
170
190
 
171
- - **Typed hooks** — `useZodQuery`, `useZodMutation` with automatic codec decode
191
+ - **Typed hooks** — `useZodQuery`, `useZodMutation`, generated into `convex/_zodvex/client` — import them from there; args are encoded and results decoded automatically
192
+ Invalid query arguments throw during render and can be handled by a React error boundary. Pass `'skip'` explicitly while required inputs are unavailable; encoding failures no longer silently look like a loading query.
172
193
  - **Boundary helpers** — `encodeArgs`, `decodeResult` for custom client integrations
173
194
  - **Cross-function auto-codec** — `ctx.runQuery` / `ctx.runMutation` encode args + decode results, and `ctx.scheduler.runAfter` / `ctx.scheduler.runAt` encode args, via the registry. Pass natural decoded values; zodvex encodes them to wire at the call site.
174
195
 
196
+ Registry-backed clients and outbound helpers warn and return raw wire data when result parsing fails by default; use `onDecodeError: 'throw'` to reject failed result parses. Missing registry schemas pass through unchanged.
197
+
175
198
  ```bash
176
199
  zodvex generate # one-shot generation
177
200
  zodvex dev # watch mode
@@ -183,20 +206,6 @@ zodvex dev # watch mode
183
206
 
184
207
  Guides: [Codegen](./docs/guide/codegen.md) | Example: [examples/task-manager/](./examples/task-manager/)
185
208
 
186
- ### Using zodvex Without Codecs
187
-
188
- `zodTable` and `zQueryBuilder` still work without `initZodvex`:
189
-
190
- ```ts
191
- import { zodTable, zQueryBuilder } from 'zodvex/legacy'
192
- import { query } from './_generated/server'
193
-
194
- const Users = zodTable('users', { name: z.string() })
195
- const zq = zQueryBuilder(query)
196
- ```
197
-
198
- At this level, zodvex is roughly equivalent to convex-helpers. This is a valid stepping-stone, but the API is deprecated. When you're ready for codecs, see the [Quick Start](#quick-start) above.
199
-
200
209
  ## Supported Types
201
210
 
202
211
  | Zod Type | Convex Validator |
@@ -217,52 +226,13 @@ At this level, zodvex is roughly equivalent to convex-helpers. This is a valid s
217
226
 
218
227
  > **Note:** Native `z.date()` is **not supported** — use `zx.date()` instead. See [Date Handling](./docs/guide/date-handling.md) for details.
219
228
 
220
- **Zod v4 Enum Type Note:**
221
-
222
- ¹ Enum types in Zod v4 produce a slightly different TypeScript signature than manually created unions:
223
-
224
- ```typescript
225
- // Manual union (precise tuple type)
226
- const manual = v.union(v.literal('a'), v.literal('b'))
227
- // Type: VUnion<"a" | "b", [VLiteral<"a", "required">, VLiteral<"b", "required">], "required", never>
228
-
229
- // From Zod enum (array type)
230
- const fromZod = zodToConvex(z.enum(['a', 'b']))
231
- // Type: VUnion<"a" | "b", Array<VLiteral<"a" | "b", "required">>, "required", never>
232
- ```
229
+ ¹ Enum unions carry a cosmetically different TypeScript signature than hand-written `v.union(v.literal(...))` calls — identical values, runtime validation, and type safety. Details: [Mapping Helpers](./docs/guide/mapping-helpers.md#zod-v4-enum-type-note).
233
230
 
234
- **This difference is purely cosmetic with no functional impact:**
235
-
236
- - Value types are identical (`"a" | "b"`)
237
- - Runtime validation is identical
238
- - Type safety for function arguments/returns is preserved
239
- - Convex uses `T[number]` which works identically for both array and tuple types
240
-
241
- This limitation exists because Zod v4 changed enum types from tuple-based to Record-based ([`ToEnum<T>`](https://github.com/colinhacks/zod/blob/v4/src/v4/core/util.ts#L83-L85)). TypeScript cannot convert a Record type to a specific tuple without knowing the keys at compile time. See [Zod v4 changelog](https://zod.dev/v4/changelog) and [enum evolution discussion](https://github.com/colinhacks/zod/discussions/2125) for more details.
242
-
243
- **zx namespace types:**
244
-
245
- ```ts
246
- import { zx } from 'zodvex'
247
-
248
- // Convex IDs — typed validator, NOT a codec
249
- zx.id('tableName') // → v.id('tableName')
250
- zx.id('tableName').optional() // → v.optional(v.id('tableName'))
251
-
252
- // Dates — codec (Date ↔ timestamp)
253
- zx.date() // → v.float64() (timestamp)
254
- zx.date().optional() // → v.optional(v.float64())
255
- zx.date().nullable() // → v.union(v.float64(), v.null())
256
-
257
- // Custom codecs
258
- zx.codec(wireSchema, runtimeSchema, { encode, decode })
259
- ```
231
+ For zodvex's own types — `zx.id()`, `zx.date()`, `zx.codec()` — and exactly how they map to Convex validators, see [The zx Namespace](./docs/guide/zx-namespace.md).
260
232
 
261
233
  ## Upgrading?
262
234
 
263
- > **Upgrading from a previous version?** Read the [migration guide](./docs/migration/v0.6.md) for what changed and why. Key takeaway: the CLI/codegen is optional — the Quick Start path above needs no codegen.
264
-
265
- Automated renames are available:
235
+ Read the [migration guide](./MIGRATION.md) for what changed in each release and why. Automated renames are available:
266
236
 
267
237
  ```bash
268
238
  npx zodvex migrate ./convex # apply renames
@@ -273,7 +243,8 @@ npx zodvex migrate ./convex --dry-run # preview changes
273
243
 
274
244
  - [The zx Namespace](./docs/guide/zx-namespace.md) — `zx.id()`, `zx.date()`, `zx.codec()`
275
245
  - [Builders](./docs/guide/builders.md) — `initZodvex` and legacy builders
276
- - [Custom Context](./docs/guide/custom-context.md) — `.withContext()`, `onSuccess`
246
+ - [Custom Context](./docs/guide/custom-context.md) — `.withContext()`, `defineContext`, `onSuccess`
247
+ - [Rules & Audit](./docs/guide/rules-and-audit.md) — `.withRules()`, `.audit()` on `ctx.db`
277
248
  - [Custom Codecs](./docs/guide/custom-codecs.md) — `zx.codec()`, `decodeDoc`/`encodeDoc`
278
249
  - [Date Handling](./docs/guide/date-handling.md) — `zx.date()` deep dive
279
250
  - [Form Validation](./docs/guide/form-validation.md) — react-hook-form integration
@@ -281,16 +252,16 @@ npx zodvex migrate ./convex --dry-run # preview changes
281
252
  - [Mapping Helpers](./docs/guide/mapping-helpers.md) — `zodToConvex`, `zodToConvexFields`
282
253
  - [Return Type Helpers](./docs/guide/return-type-helpers.md) — `returnsAs`
283
254
  - [Large Schemas](./docs/guide/large-schemas.md) — `pickShape`, `safePick`
255
+ - [Staged Indexes](./docs/guide/staged-indexes.md) — `{ staged: true }` on `index`, `searchIndex`, `vectorIndex`
284
256
  - [Polymorphic Tables](./docs/guide/polymorphic-tables.md) — Union/discriminated union tables
257
+ - [Streams](./docs/guide/streams.md) — `zodvexStream`, `zodvexMergedStream` for fan-out pagination
285
258
  - [AI SDK Compatibility](./docs/guide/ai-sdk.md) — Vercel AI SDK integration
286
259
  - [Codegen](./docs/guide/codegen.md) — CLI, registry, typed hooks
260
+ - [Schema Diagnostics](./docs/guide/schema-diagnostics.md) — local aggregate reports for support
287
261
 
288
262
  ## Roadmap
289
263
 
290
- - Migration tooling: vanilla Convex → zodvex (for new adopters with existing Convex projects)
291
- - Migration tooling: pre-0.5 → current zodvex
292
- - Additional example projects (e.g., full-stack with React, codegen showcase)
293
- - Per-feature READMEs in examples/task-manager/
264
+ See the [roadmap](./docs/roadmap.md) for where zodvex is heading — deploy-scale performance, ecosystem interop, and the model/namespace evolution.
294
265
 
295
266
  ## License
296
267
 
@@ -298,4 +269,4 @@ MIT
298
269
 
299
270
  ---
300
271
 
301
- Built with ❤️ on top of [convex-helpers](https://github.com/get-convex/convex-helpers)
272
+ Built with ❤️ for the [Convex](https://www.convex.dev/) ecosystem. Thanks to [convex-helpers](https://github.com/get-convex/convex-helpers) for the early foundations.
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env node
2
2
  export * from '../public/cli';
3
3
  import '../public/cli';
4
4
  //# sourceMappingURL=index.d.ts.map