zodvex 0.7.4 → 0.7.5-beta.0

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.
package/README.md CHANGED
@@ -170,7 +170,7 @@ zodvex includes an optional CLI that generates typed client code:
170
170
 
171
171
  - **Typed hooks** — `useZodQuery`, `useZodMutation` with automatic codec decode
172
172
  - **Boundary helpers** — `encodeArgs`, `decodeResult` for custom client integrations
173
- - **Action auto-decode** — `ctx.runQuery` / `ctx.runMutation` decode via registry
173
+ - **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
174
 
175
175
  ```bash
176
176
  zodvex generate # one-shot generation
@@ -150,6 +150,7 @@ var ZodvexClient = class {
150
150
  innerClient;
151
151
  url;
152
152
  pendingAuthFetcher;
153
+ pendingAuthOnChange;
153
154
  constructor(registry, options) {
154
155
  this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError });
155
156
  if ("client" in options) {
@@ -167,7 +168,7 @@ var ZodvexClient = class {
167
168
  if (this.innerClient) return this.innerClient;
168
169
  const client = new ConvexClient(this.getUrl());
169
170
  if (this.pendingAuthFetcher) {
170
- client.setAuth(this.pendingAuthFetcher);
171
+ client.setAuth(this.pendingAuthFetcher, this.pendingAuthOnChange);
171
172
  }
172
173
  this.innerClient = client;
173
174
  return client;
@@ -182,26 +183,85 @@ var ZodvexClient = class {
182
183
  );
183
184
  return this.codec.decodeResult(ref, wireResult);
184
185
  }
185
- async mutate(ref, args) {
186
+ async mutate(ref, args, options) {
186
187
  const wireResult = await this.getConvex().mutation(
188
+ ref,
189
+ this.codec.encodeArgs(ref, args),
190
+ options
191
+ );
192
+ return this.codec.decodeResult(ref, wireResult);
193
+ }
194
+ /** Alias for {@link mutate} — matches `ConvexClient.mutation` / `ZodvexReactClient.mutation`. */
195
+ mutation(ref, args, options) {
196
+ return this.mutate(ref, args, options);
197
+ }
198
+ async action(ref, args) {
199
+ const wireResult = await this.getConvex().action(
187
200
  ref,
188
201
  this.codec.encodeArgs(ref, args)
189
202
  );
190
203
  return this.codec.decodeResult(ref, wireResult);
191
204
  }
192
- subscribe(ref, args, callback) {
205
+ subscribe(ref, args, callback, onError) {
193
206
  const wireArgs = this.codec.encodeArgs(ref, args);
194
- return this.getConvex().onUpdate(ref, wireArgs, (wireResult) => {
195
- callback(this.codec.decodeResult(ref, wireResult));
196
- });
207
+ return this.getConvex().onUpdate(
208
+ ref,
209
+ wireArgs,
210
+ (wireResult) => {
211
+ callback(this.codec.decodeResult(ref, wireResult));
212
+ },
213
+ onError
214
+ );
197
215
  }
198
- setAuth(token) {
199
- const fetcher = async () => token;
216
+ /** Alias for {@link subscribe} — matches `ConvexClient.onUpdate`. */
217
+ onUpdate(ref, args, callback, onError) {
218
+ return this.subscribe(ref, args, callback, onError);
219
+ }
220
+ /**
221
+ * Experimental paginated subscription. Encodes args to wire and decodes each
222
+ * page item through the registry, mirroring {@link subscribe}.
223
+ */
224
+ onPaginatedUpdate_experimental(ref, args, options, callback, onError) {
225
+ const wireArgs = this.codec.encodeArgs(ref, args);
226
+ return this.getConvex().onPaginatedUpdate_experimental(
227
+ ref,
228
+ wireArgs,
229
+ options,
230
+ (wireResult) => {
231
+ callback({
232
+ ...wireResult,
233
+ page: wireResult.page.map((item) => this.codec.decodeResult(ref, item))
234
+ });
235
+ },
236
+ onError
237
+ );
238
+ }
239
+ setAuth(tokenOrFetcher, onChange) {
240
+ const fetcher = typeof tokenOrFetcher === "function" ? tokenOrFetcher : async () => tokenOrFetcher;
200
241
  this.pendingAuthFetcher = fetcher;
242
+ this.pendingAuthOnChange = onChange;
201
243
  if (this.innerClient) {
202
- this.innerClient.setAuth(fetcher);
244
+ this.innerClient.setAuth(fetcher, onChange);
203
245
  }
204
246
  }
247
+ /** Returns the current auth token and its decoded claims, if authenticated. */
248
+ getAuth() {
249
+ return this.getConvex().getAuth();
250
+ }
251
+ /** Whether this client has been closed. False before the inner client is created. */
252
+ get closed() {
253
+ return this.innerClient?.closed ?? false;
254
+ }
255
+ /** Whether this client is disabled. False before the inner client is created. */
256
+ get disabled() {
257
+ return this.innerClient?.disabled ?? false;
258
+ }
259
+ connectionState() {
260
+ return this.getConvex().connectionState();
261
+ }
262
+ subscribeToConnectionState(cb) {
263
+ return this.getConvex().subscribeToConnectionState(cb);
264
+ }
205
265
  async close() {
206
266
  await this.getConvex().close();
207
267
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/internal/normalizeCodecPaths.ts","../../src/internal/stripUndefined.ts","../../src/internal/boundaryHelpers.ts","../../src/public/client/zodvexClient.ts"],"names":[],"mappings":";;;;;;AAeA,SAAS,YAAY,MAAA,EAA4B;AAC/C,EAAA,IAAI,OAAA,GAAoB,MAAA;AACxB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,EAAI,CAAA,EAAA,EAAK;AAC3B,IAAA,IACE,OAAA,YAAmB,YAAA,IACnB,OAAA,YAAmB,YAAA,IACnB,mBAAmB,WAAA,EACnB;AACA,MAAA,OAAA,GAAU,OAAA,CAAQ,KAAK,GAAA,CAAI,SAAA;AAC3B,MAAA;AAAA,IACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAOA,SAAS,uBAAA,CAAwB,MAA2B,MAAA,EAAuC;AACjG,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,IAAI,OAAA,GAAoB,MAAA;AAExB,EAAA,KAAA,MAAW,WAAW,IAAA,EAAM;AAC1B,IAAA,OAAA,GAAU,YAAY,OAAO,CAAA;AAG7B,IAAA,IAAI,mBAAmB,SAAA,EAAW;AAChC,MAAA;AAAA,IACF;AAGA,IAAA,IAAI,OAAA,YAAmB,UAAA,IAAc,OAAO,OAAA,KAAY,QAAA,EAAU;AAChE,MAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,IA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ACjC;AACA,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,GAAA,EAAK,UAAU,CAAA;AAAA,EAChD;AAAA,EAEA,SAAA,CACE,GAAA,EACA,IAAA,EACA,QAAA,EACY;AACZ,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,UAAA,CAAW,KAAK,IAAI,CAAA;AAChD,IAAA,OAAO,KAAK,SAAA,EAAU,CAAE,SAAS,GAAA,EAAK,QAAA,EAAU,CAAC,UAAA,KAAsC;AACrF,MAAA,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,GAAA,EAAK,UAAU,CAAC,CAAA;AAAA,IACnD,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,QAAQ,KAAA,EAAsB;AAC5B,IAAA,MAAM,UAAU,YAAY,KAAA;AAC5B,IAAA,IAAA,CAAK,kBAAA,GAAqB,OAAA;AAC1B,IAAA,IAAI,KAAK,WAAA,EAAa;AACpB,MAAA,IAAA,CAAK,WAAA,CAAY,QAAQ,OAAO,CAAA;AAAA,IAClC;AAAA,EACF;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,SAAA,EAAU,CAAE,KAAA,EAAM;AAAA,EAC/B;AACF;AAEO,SAAS,kBAAA,CACd,UACA,OAAA,EACiB;AACjB,EAAA,OAAO,IAAI,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAC3C","file":"index.js","sourcesContent":["import {\n $ZodArray,\n $ZodCodec,\n $ZodDefault,\n $ZodError,\n $ZodNullable,\n $ZodObject,\n $ZodOptional,\n $ZodType,\n encode\n} from './zod-core'\n\n/**\n * Unwraps ZodOptional/ZodNullable/ZodDefault wrappers to get the structural type.\n */\nfunction unwrapOuter(schema: $ZodType): $ZodType {\n let current: $ZodType = schema\n for (let i = 0; i < 10; i++) {\n if (\n current instanceof $ZodOptional ||\n current instanceof $ZodNullable ||\n current instanceof $ZodDefault\n ) {\n current = current._zod.def.innerType\n continue\n }\n break\n }\n return current\n}\n\n/**\n * Walks a path through a schema tree, truncating at codec boundaries.\n * When a codec is encountered, the path is cut — any deeper segments\n * are wire-internal and should not be exposed to consumers.\n */\nfunction truncateAtCodecBoundary(path: (string | number)[], schema: $ZodType): (string | number)[] {\n const result: (string | number)[] = []\n let current: $ZodType = schema\n\n for (const segment of path) {\n current = unwrapOuter(current)\n\n // If we've landed on a codec, everything from here is wire-internal — stop\n if (current instanceof $ZodCodec) {\n break\n }\n\n // Descend into objects\n if (current instanceof $ZodObject && typeof segment === 'string') {\n const fieldSchema = current._zod.def.shape[segment] as $ZodType | undefined\n if (!fieldSchema) {\n // Unknown field — include segment and stop\n result.push(segment)\n break\n }\n\n result.push(segment)\n\n const unwrapped = unwrapOuter(fieldSchema)\n if (unwrapped instanceof $ZodCodec) {\n // Hit a codec boundary — truncate here\n break\n }\n\n current = fieldSchema\n continue\n }\n\n // Descend into arrays\n if (current instanceof $ZodArray && typeof segment === 'number') {\n result.push(segment)\n current = current._zod.def.element\n continue\n }\n\n // For anything else (unions, records, etc.), include segment and continue\n result.push(segment)\n }\n\n return result\n}\n\n/**\n * Normalizes ZodError paths by truncating at codec boundaries.\n *\n * When z.encode() throws a ZodError, the paths reflect the wire schema\n * structure (e.g., [\"email\", \"value\"] for a custom codec).\n * This function strips the wire-internal segments so consumers see\n * clean field-level paths (e.g., [\"email\"]).\n */\nexport function normalizeCodecPaths(error: $ZodError, schema: $ZodType): $ZodError {\n const normalized = error.issues.map(issue => ({\n ...issue,\n path: truncateAtCodecBoundary(issue.path as (string | number)[], schema)\n }))\n return new $ZodError(normalized)\n}\n\n/**\n * Encodes a value through a Zod schema, normalizing codec-internal\n * path segments in any ZodError before re-throwing.\n *\n * Drop-in replacement for `z.encode(schema, value)` at client boundaries.\n */\nexport function safeEncode(schema: $ZodType, value: unknown): unknown {\n try {\n return encode(schema, value)\n } catch (e) {\n if (e instanceof $ZodError) throw normalizeCodecPaths(e as $ZodError, schema)\n throw e\n }\n}\n","/**\n * Recursively strips `undefined` values from objects and arrays.\n * Used by codec encode/decode to clean wire data.\n *\n * Extracted to its own module so client-safe code (boundaryHelpers)\n * can import it without pulling in zod via utils.ts.\n */\nexport function stripUndefined<T>(value: T): T {\n if (value === null || value === undefined) {\n return value\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUndefined) as T\n }\n\n // Only process plain objects (not class instances, Dates, etc.)\n if (typeof value === 'object' && value.constructor === Object) {\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value)) {\n if (val !== undefined) {\n result[key] = stripUndefined(val)\n }\n }\n return result as T\n }\n\n return value\n}\n","import type { FunctionReference } from 'convex/server'\nimport type { $ZodIssue } from 'zod/v4/core'\nimport { safeEncode } from './normalizeCodecPaths'\nimport { stripUndefined } from './stripUndefined'\nimport type { AnyRegistry } from './types'\nimport { $ZodError, safeParse } from './zod-core'\n\n/**\n * Resolves a Convex FunctionReference to its string path.\n *\n * Mirrors `getFunctionName` from `convex/server` but without the server import.\n * Reads the well-known `Symbol.for('functionName')` that Convex attaches to all\n * function references — the same symbol used by Convex's own browser client.\n */\nconst functionNameSymbol = Symbol.for('functionName')\n\nfunction resolveFunctionPath(ref: FunctionReference<any, any, any, any>): string {\n if (typeof ref === 'string') return ref\n const name = (ref as any)[functionNameSymbol]\n if (!name) {\n throw new Error(\n `Expected a Convex function reference (e.g. api.file.func), but received ${JSON.stringify(ref)}`\n )\n }\n return name\n}\n\n/**\n * Options for codec helper behavior.\n */\nexport type BoundaryHelpersOptions = {\n /**\n * How to handle decode failures (schema validation errors on wire data).\n *\n * - `'warn'` (default): log a console.warn and return raw wire data untransformed.\n * - `'throw'`: throw a ZodvexDecodeError (extends z.ZodError). // zod-ok\n */\n onDecodeError?: 'warn' | 'throw'\n}\n\n/**\n * Decode error with function path and wire data context.\n * Extends $ZodError from zod/v4/core for compatibility with both zod and zod/mini.\n * instanceof $ZodError checks work in both variants.\n */\nexport class ZodvexDecodeError extends $ZodError {\n readonly functionPath: string\n readonly wireData: unknown\n\n constructor(functionPath: string, issues: $ZodIssue[], wireData: unknown) {\n super(issues)\n this.functionPath = functionPath\n this.wireData = wireData\n this.name = 'ZodvexDecodeError'\n }\n}\n\n/**\n * Creates shared encode/decode helpers bound to a zodvex registry.\n *\n * These are the core primitives used by all codec boundary implementations:\n * - `encodeArgs`: runtime types -> wire format (e.g., Date -> timestamp number)\n * - `decodeResult`: wire format -> runtime types (e.g., timestamp number -> Date)\n *\n * Both look up the function reference in the registry to find the appropriate\n * Zod schema, then apply the codec transform. Functions not in the registry\n * (or without the relevant schema) pass through unchanged.\n *\n * @param registry - A map of function paths to `{ args?, returns? }` Zod schemas.\n * Typically generated by zodvex codegen into `_zodvex/api.ts`.\n * @param options - Optional configuration for decode error behavior.\n */\nexport function createBoundaryHelpers(registry: AnyRegistry, options?: BoundaryHelpersOptions) {\n const onDecodeError = options?.onDecodeError ?? 'warn'\n const warnedPaths = new Set<string>()\n\n /**\n * Encode args from runtime types to wire format.\n *\n * Uses `safeEncode` (not raw `z.encode`) to normalize codec-internal\n * error paths in ZodErrors, then strips undefined values for Convex\n * serialization compatibility.\n *\n * Passthrough when:\n * - args is null/undefined\n * - function is not in the registry\n * - registry entry has no args schema\n */\n function encodeArgs(ref: FunctionReference<any, any, any, any>, args: any): any {\n if (args == null) return args\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.args) {\n if (entry === undefined && !warnedPaths.has(path)) {\n warnedPaths.add(path)\n console.debug(\n `[zodvex] No registry entry for \"${path}\" — args will not be codec-encoded. ` +\n 'If this function uses zodvex wrappers, run `zodvex generate` to update the registry.'\n )\n }\n return args\n }\n return stripUndefined(safeEncode(entry.args, args))\n }\n\n /**\n * Decode a wire result back to runtime types.\n *\n * Uses `.safeParse()` to decode. On failure:\n * - 'warn' (default): logs warning, returns raw wireResult\n * - 'throw': throws ZodvexDecodeError (extends z.ZodError) // zod-ok\n *\n * Passthrough when:\n * - function is not in the registry\n * - registry entry has no returns schema\n */\n function decodeResult(ref: FunctionReference<any, any, any, any>, wireResult: any): any {\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.returns) return wireResult\n\n const result = safeParse(entry.returns, wireResult)\n if (result.success) return result.data\n\n if (onDecodeError === 'throw') {\n throw new ZodvexDecodeError(path, result.error.issues, wireResult)\n }\n\n // Default: warn and return raw wire data\n const preview = JSON.stringify(wireResult)\n const truncated = preview.length > 200 ? `${preview.slice(0, 200)}...` : preview\n console.warn(\n `[zodvex] Decode failed for ${path}: ${result.error.issues.map((i: $ZodIssue) => `${i.path.join('.')}: ${i.message}`).join(', ')}. Returning raw wire data. Preview: ${truncated}`\n )\n return wireResult\n }\n\n return { encodeArgs, decodeResult }\n}\n\nexport type BoundaryHelpers = ReturnType<typeof createBoundaryHelpers>\n","import type { AuthTokenFetcher } from 'convex/browser'\nimport { ConvexClient } from 'convex/browser'\nimport type { FunctionArgs, FunctionReference, FunctionReturnType } from 'convex/server'\nimport type { BoundaryHelpersOptions } from '../../internal/boundaryHelpers'\nimport { createBoundaryHelpers } from '../../internal/boundaryHelpers'\nimport type { AnyRegistry } from '../../internal/types'\n\nexport type ZodvexClientOptions = (\n | { url: string; token?: string | null }\n | { client: ConvexClient }\n) &\n BoundaryHelpersOptions\n\n/** Wrap a static token string as an AuthTokenFetcher for ConvexClient */\nfunction tokenToFetcher(token: string): AuthTokenFetcher {\n return async () => token\n}\n\nexport class ZodvexClient<R extends AnyRegistry = AnyRegistry> {\n private codec: ReturnType<typeof createBoundaryHelpers>\n private innerClient?: ConvexClient\n private url?: string\n private pendingAuthFetcher?: AuthTokenFetcher\n\n constructor(registry: R, options: ZodvexClientOptions) {\n this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError })\n if ('client' in options) {\n this.innerClient = options.client\n } else {\n this.url = options.url\n if (options.token) this.pendingAuthFetcher = tokenToFetcher(options.token)\n }\n }\n\n private getUrl(): string {\n if (this.url) return this.url\n throw new Error('[zodvex] ZodvexClient is missing a Convex URL.')\n }\n\n private getConvex(): ConvexClient {\n if (this.innerClient) return this.innerClient\n\n const client = new ConvexClient(this.getUrl())\n if (this.pendingAuthFetcher) {\n client.setAuth(this.pendingAuthFetcher)\n }\n this.innerClient = client\n return client\n }\n\n get convex(): ConvexClient {\n return this.getConvex()\n }\n\n async query<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args']\n ): Promise<Q['_returnType']> {\n const wireResult = await this.getConvex().query(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n async mutate<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args']\n ): Promise<M['_returnType']> {\n const wireResult = await this.getConvex().mutation(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<M>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n subscribe<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void\n ): () => void {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onUpdate(ref, wireArgs, (wireResult: FunctionReturnType<Q>) => {\n callback(this.codec.decodeResult(ref, wireResult))\n })\n }\n\n setAuth(token: string | null) {\n const fetcher = async () => token\n this.pendingAuthFetcher = fetcher\n if (this.innerClient) {\n this.innerClient.setAuth(fetcher)\n }\n }\n\n async close() {\n await this.getConvex().close()\n }\n}\n\nexport function createZodvexClient<R extends AnyRegistry>(\n registry: R,\n options: ZodvexClientOptions\n): ZodvexClient<R> {\n return new ZodvexClient(registry, options)\n}\n"]}
1
+ {"version":3,"sources":["../../src/internal/normalizeCodecPaths.ts","../../src/internal/stripUndefined.ts","../../src/internal/boundaryHelpers.ts","../../src/public/client/zodvexClient.ts"],"names":[],"mappings":";;;;;;AAeA,SAAS,YAAY,MAAA,EAA4B;AAC/C,EAAA,IAAI,OAAA,GAAoB,MAAA;AACxB,EAAA,KAAA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A,EASA,OAAA,CACE,gBACA,QAAA,EACM;AACN,IAAA,MAAM,OAAA,GACJ,OAAO,cAAA,KAAmB,UAAA,GAAa,iBAAiB,YAAY,cAAA;AACtE,IAAA,IAAA,CAAK,kBAAA,GAAqB,OAAA;AAC1B,IAAA,IAAA,CAAK,mBAAA,GAAsB,QAAA;AAC3B,IAAA,IAAI,KAAK,WAAA,EAAa;AACpB,MAAA,IAAA,CAAK,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,QAAQ,CAAA;AAAA,IAC5C;AAAA,EACF;AAAA;AAAA,EAGA,OAAA,GAAuE;AACrE,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,OAAA,EAAQ;AAAA,EAClC;AAAA;AAAA,EAGA,IAAI,MAAA,GAAkB;AACpB,IAAA,OAAO,IAAA,CAAK,aAAa,MAAA,IAAU,KAAA;AAAA,EACrC;AAAA;AAAA,EAGA,IAAI,QAAA,GAAoB;AACtB,IAAA,OAAO,IAAA,CAAK,aAAa,QAAA,IAAY,KAAA;AAAA,EACvC;AAAA,EAEA,eAAA,GAAmC;AACjC,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,eAAA,EAAgB;AAAA,EAC1C;AAAA,EAEA,2BAA2B,EAAA,EAAkD;AAC3E,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,0BAAA,CAA2B,EAAE,CAAA;AAAA,EACvD;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,SAAA,EAAU,CAAE,KAAA,EAAM;AAAA,EAC/B;AACF;AAEO,SAAS,kBAAA,CACd,UACA,OAAA,EACiB;AACjB,EAAA,OAAO,IAAI,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAC3C","file":"index.js","sourcesContent":["import {\n $ZodArray,\n $ZodCodec,\n $ZodDefault,\n $ZodError,\n $ZodNullable,\n $ZodObject,\n $ZodOptional,\n $ZodType,\n encode\n} from './zod-core'\n\n/**\n * Unwraps ZodOptional/ZodNullable/ZodDefault wrappers to get the structural type.\n */\nfunction unwrapOuter(schema: $ZodType): $ZodType {\n let current: $ZodType = schema\n for (let i = 0; i < 10; i++) {\n if (\n current instanceof $ZodOptional ||\n current instanceof $ZodNullable ||\n current instanceof $ZodDefault\n ) {\n current = current._zod.def.innerType\n continue\n }\n break\n }\n return current\n}\n\n/**\n * Walks a path through a schema tree, truncating at codec boundaries.\n * When a codec is encountered, the path is cut — any deeper segments\n * are wire-internal and should not be exposed to consumers.\n */\nfunction truncateAtCodecBoundary(path: (string | number)[], schema: $ZodType): (string | number)[] {\n const result: (string | number)[] = []\n let current: $ZodType = schema\n\n for (const segment of path) {\n current = unwrapOuter(current)\n\n // If we've landed on a codec, everything from here is wire-internal — stop\n if (current instanceof $ZodCodec) {\n break\n }\n\n // Descend into objects\n if (current instanceof $ZodObject && typeof segment === 'string') {\n const fieldSchema = current._zod.def.shape[segment] as $ZodType | undefined\n if (!fieldSchema) {\n // Unknown field — include segment and stop\n result.push(segment)\n break\n }\n\n result.push(segment)\n\n const unwrapped = unwrapOuter(fieldSchema)\n if (unwrapped instanceof $ZodCodec) {\n // Hit a codec boundary — truncate here\n break\n }\n\n current = fieldSchema\n continue\n }\n\n // Descend into arrays\n if (current instanceof $ZodArray && typeof segment === 'number') {\n result.push(segment)\n current = current._zod.def.element\n continue\n }\n\n // For anything else (unions, records, etc.), include segment and continue\n result.push(segment)\n }\n\n return result\n}\n\n/**\n * Normalizes ZodError paths by truncating at codec boundaries.\n *\n * When z.encode() throws a ZodError, the paths reflect the wire schema\n * structure (e.g., [\"email\", \"value\"] for a custom codec).\n * This function strips the wire-internal segments so consumers see\n * clean field-level paths (e.g., [\"email\"]).\n */\nexport function normalizeCodecPaths(error: $ZodError, schema: $ZodType): $ZodError {\n const normalized = error.issues.map(issue => ({\n ...issue,\n path: truncateAtCodecBoundary(issue.path as (string | number)[], schema)\n }))\n return new $ZodError(normalized)\n}\n\n/**\n * Encodes a value through a Zod schema, normalizing codec-internal\n * path segments in any ZodError before re-throwing.\n *\n * Drop-in replacement for `z.encode(schema, value)` at client boundaries.\n */\nexport function safeEncode(schema: $ZodType, value: unknown): unknown {\n try {\n return encode(schema, value)\n } catch (e) {\n if (e instanceof $ZodError) throw normalizeCodecPaths(e as $ZodError, schema)\n throw e\n }\n}\n","/**\n * Recursively strips `undefined` values from objects and arrays.\n * Used by codec encode/decode to clean wire data.\n *\n * Extracted to its own module so client-safe code (boundaryHelpers)\n * can import it without pulling in zod via utils.ts.\n */\nexport function stripUndefined<T>(value: T): T {\n if (value === null || value === undefined) {\n return value\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUndefined) as T\n }\n\n // Only process plain objects (not class instances, Dates, etc.)\n if (typeof value === 'object' && value.constructor === Object) {\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value)) {\n if (val !== undefined) {\n result[key] = stripUndefined(val)\n }\n }\n return result as T\n }\n\n return value\n}\n","import type { FunctionReference } from 'convex/server'\nimport type { $ZodIssue } from 'zod/v4/core'\nimport { safeEncode } from './normalizeCodecPaths'\nimport { stripUndefined } from './stripUndefined'\nimport type { AnyRegistry } from './types'\nimport { $ZodError, safeParse } from './zod-core'\n\n/**\n * Resolves a Convex FunctionReference to its string path.\n *\n * Mirrors `getFunctionName` from `convex/server` but without the server import.\n * Reads the well-known `Symbol.for('functionName')` that Convex attaches to all\n * function references — the same symbol used by Convex's own browser client.\n */\nconst functionNameSymbol = Symbol.for('functionName')\n\nfunction resolveFunctionPath(ref: FunctionReference<any, any, any, any>): string {\n if (typeof ref === 'string') return ref\n const name = (ref as any)[functionNameSymbol]\n if (!name) {\n throw new Error(\n `Expected a Convex function reference (e.g. api.file.func), but received ${JSON.stringify(ref)}`\n )\n }\n return name\n}\n\n/**\n * Options for codec helper behavior.\n */\nexport type BoundaryHelpersOptions = {\n /**\n * How to handle decode failures (schema validation errors on wire data).\n *\n * - `'warn'` (default): log a console.warn and return raw wire data untransformed.\n * - `'throw'`: throw a ZodvexDecodeError (extends z.ZodError). // zod-ok\n */\n onDecodeError?: 'warn' | 'throw'\n}\n\n/**\n * Decode error with function path and wire data context.\n * Extends $ZodError from zod/v4/core for compatibility with both zod and zod/mini.\n * instanceof $ZodError checks work in both variants.\n */\nexport class ZodvexDecodeError extends $ZodError {\n readonly functionPath: string\n readonly wireData: unknown\n\n constructor(functionPath: string, issues: $ZodIssue[], wireData: unknown) {\n super(issues)\n this.functionPath = functionPath\n this.wireData = wireData\n this.name = 'ZodvexDecodeError'\n }\n}\n\n/**\n * Creates shared encode/decode helpers bound to a zodvex registry.\n *\n * These are the core primitives used by all codec boundary implementations:\n * - `encodeArgs`: runtime types -> wire format (e.g., Date -> timestamp number)\n * - `decodeResult`: wire format -> runtime types (e.g., timestamp number -> Date)\n *\n * Both look up the function reference in the registry to find the appropriate\n * Zod schema, then apply the codec transform. Functions not in the registry\n * (or without the relevant schema) pass through unchanged.\n *\n * @param registry - A map of function paths to `{ args?, returns? }` Zod schemas.\n * Typically generated by zodvex codegen into `_zodvex/api.ts`.\n * @param options - Optional configuration for decode error behavior.\n */\nexport function createBoundaryHelpers(registry: AnyRegistry, options?: BoundaryHelpersOptions) {\n const onDecodeError = options?.onDecodeError ?? 'warn'\n const warnedPaths = new Set<string>()\n\n /**\n * Encode args from runtime types to wire format.\n *\n * Uses `safeEncode` (not raw `z.encode`) to normalize codec-internal\n * error paths in ZodErrors, then strips undefined values for Convex\n * serialization compatibility.\n *\n * Passthrough when:\n * - args is null/undefined\n * - function is not in the registry\n * - registry entry has no args schema\n */\n function encodeArgs(ref: FunctionReference<any, any, any, any>, args: any): any {\n if (args == null) return args\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.args) {\n if (entry === undefined && !warnedPaths.has(path)) {\n warnedPaths.add(path)\n console.debug(\n `[zodvex] No registry entry for \"${path}\" — args will not be codec-encoded. ` +\n 'If this function uses zodvex wrappers, run `zodvex generate` to update the registry.'\n )\n }\n return args\n }\n return stripUndefined(safeEncode(entry.args, args))\n }\n\n /**\n * Decode a wire result back to runtime types.\n *\n * Uses `.safeParse()` to decode. On failure:\n * - 'warn' (default): logs warning, returns raw wireResult\n * - 'throw': throws ZodvexDecodeError (extends z.ZodError) // zod-ok\n *\n * Passthrough when:\n * - function is not in the registry\n * - registry entry has no returns schema\n */\n function decodeResult(ref: FunctionReference<any, any, any, any>, wireResult: any): any {\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.returns) return wireResult\n\n const result = safeParse(entry.returns, wireResult)\n if (result.success) return result.data\n\n if (onDecodeError === 'throw') {\n throw new ZodvexDecodeError(path, result.error.issues, wireResult)\n }\n\n // Default: warn and return raw wire data\n const preview = JSON.stringify(wireResult)\n const truncated = preview.length > 200 ? `${preview.slice(0, 200)}...` : preview\n console.warn(\n `[zodvex] Decode failed for ${path}: ${result.error.issues.map((i: $ZodIssue) => `${i.path.join('.')}: ${i.message}`).join(', ')}. Returning raw wire data. Preview: ${truncated}`\n )\n return wireResult\n }\n\n return { encodeArgs, decodeResult }\n}\n\nexport type BoundaryHelpers = ReturnType<typeof createBoundaryHelpers>\n","import type { AuthTokenFetcher, ConnectionState, MutationOptions } from 'convex/browser'\nimport { ConvexClient } from 'convex/browser'\nimport type { FunctionArgs, FunctionReference, FunctionReturnType } from 'convex/server'\nimport type { BoundaryHelpersOptions } from '../../internal/boundaryHelpers'\nimport { createBoundaryHelpers } from '../../internal/boundaryHelpers'\nimport type { AnyRegistry } from '../../internal/types'\n\nexport type ZodvexClientOptions = (\n | { url: string; token?: string | null }\n | { client: ConvexClient }\n) &\n BoundaryHelpersOptions\n\n/** Wrap a static token string as an AuthTokenFetcher for ConvexClient */\nfunction tokenToFetcher(token: string): AuthTokenFetcher {\n return async () => token\n}\n\nexport class ZodvexClient<R extends AnyRegistry = AnyRegistry> {\n private codec: ReturnType<typeof createBoundaryHelpers>\n private innerClient?: ConvexClient\n private url?: string\n private pendingAuthFetcher?: AuthTokenFetcher\n private pendingAuthOnChange?: (isAuthenticated: boolean) => void\n\n constructor(registry: R, options: ZodvexClientOptions) {\n this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError })\n if ('client' in options) {\n this.innerClient = options.client\n } else {\n this.url = options.url\n if (options.token) this.pendingAuthFetcher = tokenToFetcher(options.token)\n }\n }\n\n private getUrl(): string {\n if (this.url) return this.url\n throw new Error('[zodvex] ZodvexClient is missing a Convex URL.')\n }\n\n private getConvex(): ConvexClient {\n if (this.innerClient) return this.innerClient\n\n const client = new ConvexClient(this.getUrl())\n if (this.pendingAuthFetcher) {\n client.setAuth(this.pendingAuthFetcher, this.pendingAuthOnChange)\n }\n this.innerClient = client\n return client\n }\n\n get convex(): ConvexClient {\n return this.getConvex()\n }\n\n async query<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args']\n ): Promise<Q['_returnType']> {\n const wireResult = await this.getConvex().query(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n async mutate<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args'],\n options?: MutationOptions\n ): Promise<M['_returnType']> {\n const wireResult = await this.getConvex().mutation(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<M>,\n options\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n /** Alias for {@link mutate} — matches `ConvexClient.mutation` / `ZodvexReactClient.mutation`. */\n mutation<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args'],\n options?: MutationOptions\n ): Promise<M['_returnType']> {\n return this.mutate(ref, args, options)\n }\n\n async action<A extends FunctionReference<'action', any, any, any>>(\n ref: A,\n args: A['_args']\n ): Promise<A['_returnType']> {\n const wireResult = await this.getConvex().action(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<A>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n subscribe<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void,\n onError?: (e: Error) => void\n ): () => void {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onUpdate(\n ref,\n wireArgs,\n (wireResult: FunctionReturnType<Q>) => {\n callback(this.codec.decodeResult(ref, wireResult))\n },\n onError\n )\n }\n\n /** Alias for {@link subscribe} — matches `ConvexClient.onUpdate`. */\n onUpdate<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void,\n onError?: (e: Error) => void\n ): () => void {\n return this.subscribe(ref, args, callback, onError)\n }\n\n /**\n * Experimental paginated subscription. Encodes args to wire and decodes each\n * page item through the registry, mirroring {@link subscribe}.\n */\n onPaginatedUpdate_experimental<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n options: { initialNumItems: number },\n callback: (result: {\n page: Q['_returnType'][]\n isDone: boolean\n continueCursor: string\n [key: string]: unknown\n }) => void,\n onError?: (e: Error) => void\n ): ReturnType<ConvexClient['onPaginatedUpdate_experimental']> {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onPaginatedUpdate_experimental(\n ref,\n wireArgs,\n options,\n (wireResult: any) => {\n callback({\n ...wireResult,\n page: wireResult.page.map((item: any) => this.codec.decodeResult(ref, item))\n })\n },\n onError\n ) as ReturnType<ConvexClient['onPaginatedUpdate_experimental']>\n }\n\n /**\n * Set the auth token. Accepts either a raw token string (convenience) or a\n * Convex `AuthTokenFetcher` plus optional `onChange` callback (parity with\n * `ConvexClient.setAuth`).\n */\n setAuth(token: string | null): void\n setAuth(fetchToken: AuthTokenFetcher, onChange?: (isAuthenticated: boolean) => void): void\n setAuth(\n tokenOrFetcher: string | null | AuthTokenFetcher,\n onChange?: (isAuthenticated: boolean) => void\n ): void {\n const fetcher: AuthTokenFetcher =\n typeof tokenOrFetcher === 'function' ? tokenOrFetcher : async () => tokenOrFetcher\n this.pendingAuthFetcher = fetcher\n this.pendingAuthOnChange = onChange\n if (this.innerClient) {\n this.innerClient.setAuth(fetcher, onChange)\n }\n }\n\n /** Returns the current auth token and its decoded claims, if authenticated. */\n getAuth(): { token: string; decoded: Record<string, any> } | undefined {\n return this.getConvex().getAuth()\n }\n\n /** Whether this client has been closed. False before the inner client is created. */\n get closed(): boolean {\n return this.innerClient?.closed ?? false\n }\n\n /** Whether this client is disabled. False before the inner client is created. */\n get disabled(): boolean {\n return this.innerClient?.disabled ?? false\n }\n\n connectionState(): ConnectionState {\n return this.getConvex().connectionState()\n }\n\n subscribeToConnectionState(cb: (state: ConnectionState) => void): () => void {\n return this.getConvex().subscribeToConnectionState(cb)\n }\n\n async close() {\n await this.getConvex().close()\n }\n}\n\nexport function createZodvexClient<R extends AnyRegistry>(\n registry: R,\n options: ZodvexClientOptions\n): ZodvexClient<R> {\n return new ZodvexClient(registry, options)\n}\n"]}
@@ -1,12 +1,28 @@
1
- import type { GenericActionCtx, GenericDataModel } from 'convex/server';
1
+ import type { GenericActionCtx, GenericDataModel, Scheduler } from 'convex/server';
2
2
  import type { BoundaryHelpersOptions } from './boundaryHelpers';
3
3
  import type { AnyRegistry } from './types';
4
4
  /**
5
- * Wraps an action context's runQuery/runMutation with automatic
5
+ * Builds ctx overrides that auto-encode codec args at outbound call sites:
6
+ * - `runQuery` / `runMutation`: encode args, decode result.
7
+ * - `scheduler.runAfter` / `scheduler.runAt`: encode args.
8
+ *
9
+ * Only the members present on the given ctx are included, so this serves both
10
+ * action ctx (run* + scheduler) and mutation ctx (scheduler only).
11
+ *
12
+ * @internal Used by initZodvex when the `registry` option is provided.
13
+ */
14
+ export declare function createCodecCallOverrides(registry: AnyRegistry, ctx: {
15
+ runQuery?: unknown;
16
+ runMutation?: unknown;
17
+ scheduler?: Scheduler;
18
+ }, options?: BoundaryHelpersOptions): Record<string, unknown>;
19
+ /**
20
+ * Wraps an action context's runQuery/runMutation and scheduler with automatic
6
21
  * codec transforms via the zodvex registry.
7
22
  *
8
23
  * - Args are encoded (runtime -> wire) before calling the inner function
9
24
  * - Results are decoded (wire -> runtime) before returning to the handler
25
+ * (runQuery/runMutation only — the scheduler returns a scheduled-function id)
10
26
  * - Functions not in the registry pass through unchanged
11
27
  *
12
28
  * @internal Used by initZodvex when registry option is provided.
@@ -1 +1 @@
1
- {"version":3,"file":"actionCtx.d.ts","sourceRoot":"","sources":["../../src/internal/actionCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,SAAS,gBAAgB,EAC/D,QAAQ,EAAE,WAAW,EACrB,GAAG,EAAE,gBAAgB,CAAC,EAAE,CAAC,EACzB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,gBAAgB,CAAC,EAAE,CAAC,CAgBtB"}
1
+ {"version":3,"file":"actionCtx.d.ts","sourceRoot":"","sources":["../../src/internal/actionCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,KAAK,EAAmB,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAyC1C;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,WAAW,EACrB,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,EACzE,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,MAAM,EAAE,O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AmBjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,GAAG,EACf,SAAS,EAAE,qBAAqB,EAChC,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,KAAK,GAAG,OAUpD"}
@@ -150,6 +150,7 @@ var ZodvexClient = class {
150
150
  innerClient;
151
151
  url;
152
152
  pendingAuthFetcher;
153
+ pendingAuthOnChange;
153
154
  constructor(registry, options) {
154
155
  this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError });
155
156
  if ("client" in options) {
@@ -167,7 +168,7 @@ var ZodvexClient = class {
167
168
  if (this.innerClient) return this.innerClient;
168
169
  const client = new ConvexClient(this.getUrl());
169
170
  if (this.pendingAuthFetcher) {
170
- client.setAuth(this.pendingAuthFetcher);
171
+ client.setAuth(this.pendingAuthFetcher, this.pendingAuthOnChange);
171
172
  }
172
173
  this.innerClient = client;
173
174
  return client;
@@ -182,26 +183,85 @@ var ZodvexClient = class {
182
183
  );
183
184
  return this.codec.decodeResult(ref, wireResult);
184
185
  }
185
- async mutate(ref, args) {
186
+ async mutate(ref, args, options) {
186
187
  const wireResult = await this.getConvex().mutation(
188
+ ref,
189
+ this.codec.encodeArgs(ref, args),
190
+ options
191
+ );
192
+ return this.codec.decodeResult(ref, wireResult);
193
+ }
194
+ /** Alias for {@link mutate} — matches `ConvexClient.mutation` / `ZodvexReactClient.mutation`. */
195
+ mutation(ref, args, options) {
196
+ return this.mutate(ref, args, options);
197
+ }
198
+ async action(ref, args) {
199
+ const wireResult = await this.getConvex().action(
187
200
  ref,
188
201
  this.codec.encodeArgs(ref, args)
189
202
  );
190
203
  return this.codec.decodeResult(ref, wireResult);
191
204
  }
192
- subscribe(ref, args, callback) {
205
+ subscribe(ref, args, callback, onError) {
193
206
  const wireArgs = this.codec.encodeArgs(ref, args);
194
- return this.getConvex().onUpdate(ref, wireArgs, (wireResult) => {
195
- callback(this.codec.decodeResult(ref, wireResult));
196
- });
207
+ return this.getConvex().onUpdate(
208
+ ref,
209
+ wireArgs,
210
+ (wireResult) => {
211
+ callback(this.codec.decodeResult(ref, wireResult));
212
+ },
213
+ onError
214
+ );
197
215
  }
198
- setAuth(token) {
199
- const fetcher = async () => token;
216
+ /** Alias for {@link subscribe} — matches `ConvexClient.onUpdate`. */
217
+ onUpdate(ref, args, callback, onError) {
218
+ return this.subscribe(ref, args, callback, onError);
219
+ }
220
+ /**
221
+ * Experimental paginated subscription. Encodes args to wire and decodes each
222
+ * page item through the registry, mirroring {@link subscribe}.
223
+ */
224
+ onPaginatedUpdate_experimental(ref, args, options, callback, onError) {
225
+ const wireArgs = this.codec.encodeArgs(ref, args);
226
+ return this.getConvex().onPaginatedUpdate_experimental(
227
+ ref,
228
+ wireArgs,
229
+ options,
230
+ (wireResult) => {
231
+ callback({
232
+ ...wireResult,
233
+ page: wireResult.page.map((item) => this.codec.decodeResult(ref, item))
234
+ });
235
+ },
236
+ onError
237
+ );
238
+ }
239
+ setAuth(tokenOrFetcher, onChange) {
240
+ const fetcher = typeof tokenOrFetcher === "function" ? tokenOrFetcher : async () => tokenOrFetcher;
200
241
  this.pendingAuthFetcher = fetcher;
242
+ this.pendingAuthOnChange = onChange;
201
243
  if (this.innerClient) {
202
- this.innerClient.setAuth(fetcher);
244
+ this.innerClient.setAuth(fetcher, onChange);
203
245
  }
204
246
  }
247
+ /** Returns the current auth token and its decoded claims, if authenticated. */
248
+ getAuth() {
249
+ return this.getConvex().getAuth();
250
+ }
251
+ /** Whether this client has been closed. False before the inner client is created. */
252
+ get closed() {
253
+ return this.innerClient?.closed ?? false;
254
+ }
255
+ /** Whether this client is disabled. False before the inner client is created. */
256
+ get disabled() {
257
+ return this.innerClient?.disabled ?? false;
258
+ }
259
+ connectionState() {
260
+ return this.getConvex().connectionState();
261
+ }
262
+ subscribeToConnectionState(cb) {
263
+ return this.getConvex().subscribeToConnectionState(cb);
264
+ }
205
265
  async close() {
206
266
  await this.getConvex().close();
207
267
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/internal/normalizeCodecPaths.ts","../../../src/internal/stripUndefined.ts","../../../src/internal/boundaryHelpers.ts","../../../src/public/client/zodvexClient.ts"],"names":[],"mappings":";;;;;;AAeA,SAAS,YAAY,MAAA,EAA4B;AAC/C,EAAA,IAAI,OAAA,GAAoB,MAAA;AACxB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,EAAI,CAAA,EAAA,EAAK;AAC3B,IAAA,IACE,OAAA,YAAmB,YAAA,IACnB,OAAA,YAAmB,YAAA,IACnB,mBAAmB,WAAA,EACnB;AACA,MAAA,OAAA,GAAU,OAAA,CAAQ,KAAK,GAAA,CAAI,SAAA;AAC3B,MAAA;AAAA,IACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAOA,SAAS,uBAAA,CAAwB,MAA2B,MAAA,EAAuC;AACjG,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,IAAI,OAAA,GAAoB,MAAA;AAExB,EAAA,KAAA,MAAW,WAAW,IAAA,EAAM;AAC1B,IAAA,OAAA,GAAU,YAAY,OAAO,CAAA;AAG7B,IAAA,IAAI,mBAAmB,SAAA,EAAW;AAChC,MAAA;AAAA,IACF;AAGA,IAAA,IAAI,OAAA,YAAmB,UAAA,IAAc,OAAO,OAAA,KAAY,QAAA,EAAU;AAChE,MAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,OAAO,CAAA;AAClD,MAAA,IAAI,CAAC,WAAA,EAAa;AAEhB,QAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AACnB,QAAA;AAAA,MACF;AAEA,MAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AAEnB,MAAA,MAAM,SAAA,GAAY,YAAY,WAAW,CAAA;AACzC,MAAA,IAAI,qBAAqB,SAAA,EAAW;AAElC,QAAA;AAAA,MACF;AAEA,MAAA,OAAA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UAAA,KAAsC;AACrF,MAAA,QAAA,CAAS,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,GAAA,EAAK,UAAU,CAAC,CAAA;AAAA,IACnD,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,QAAQ,KAAA,EAAsB;AAC5B,IAAA,MAAM,UAAU,YAAY,KAAA;AAC5B,IAAA,IAAA,CAAK,kBAAA,GAAqB,OAAA;AAC1B,IAAA,IAAI,KAAK,WAAA,EAAa;AACpB,MAAA,IAAA,CAAK,WAAA,CAAY,QAAQ,OAAO,CAAA;AAAA,IAClC;AAAA,EACF;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,SAAA,EAAU,CAAE,KAAA,EAAM;AAAA,EAC/B;AACF;AAEO,SAAS,kBAAA,CACd,UACA,OAAA,EACiB;AACjB,EAAA,OAAO,IAAI,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAC3C","file":"index.js","sourcesContent":["import {\n $ZodArray,\n $ZodCodec,\n $ZodDefault,\n $ZodError,\n $ZodNullable,\n $ZodObject,\n $ZodOptional,\n $ZodType,\n encode\n} from './zod-core'\n\n/**\n * Unwraps ZodOptional/ZodNullable/ZodDefault wrappers to get the structural type.\n */\nfunction unwrapOuter(schema: $ZodType): $ZodType {\n let current: $ZodType = schema\n for (let i = 0; i < 10; i++) {\n if (\n current instanceof $ZodOptional ||\n current instanceof $ZodNullable ||\n current instanceof $ZodDefault\n ) {\n current = current._zod.def.innerType\n continue\n }\n break\n }\n return current\n}\n\n/**\n * Walks a path through a schema tree, truncating at codec boundaries.\n * When a codec is encountered, the path is cut — any deeper segments\n * are wire-internal and should not be exposed to consumers.\n */\nfunction truncateAtCodecBoundary(path: (string | number)[], schema: $ZodType): (string | number)[] {\n const result: (string | number)[] = []\n let current: $ZodType = schema\n\n for (const segment of path) {\n current = unwrapOuter(current)\n\n // If we've landed on a codec, everything from here is wire-internal — stop\n if (current instanceof $ZodCodec) {\n break\n }\n\n // Descend into objects\n if (current instanceof $ZodObject && typeof segment === 'string') {\n const fieldSchema = current._zod.def.shape[segment] as $ZodType | undefined\n if (!fieldSchema) {\n // Unknown field — include segment and stop\n result.push(segment)\n break\n }\n\n result.push(segment)\n\n const unwrapped = unwrapOuter(fieldSchema)\n if (unwrapped instanceof $ZodCodec) {\n // Hit a codec boundary — truncate here\n break\n }\n\n current = fieldSchema\n continue\n }\n\n // Descend into arrays\n if (current instanceof $ZodArray && typeof segment === 'number') {\n result.push(segment)\n current = current._zod.def.element\n continue\n }\n\n // For anything else (unions, records, etc.), include segment and continue\n result.push(segment)\n }\n\n return result\n}\n\n/**\n * Normalizes ZodError paths by truncating at codec boundaries.\n *\n * When z.encode() throws a ZodError, the paths reflect the wire schema\n * structure (e.g., [\"email\", \"value\"] for a custom codec).\n * This function strips the wire-internal segments so consumers see\n * clean field-level paths (e.g., [\"email\"]).\n */\nexport function normalizeCodecPaths(error: $ZodError, schema: $ZodType): $ZodError {\n const normalized = error.issues.map(issue => ({\n ...issue,\n path: truncateAtCodecBoundary(issue.path as (string | number)[], schema)\n }))\n return new $ZodError(normalized)\n}\n\n/**\n * Encodes a value through a Zod schema, normalizing codec-internal\n * path segments in any ZodError before re-throwing.\n *\n * Drop-in replacement for `z.encode(schema, value)` at client boundaries.\n */\nexport function safeEncode(schema: $ZodType, value: unknown): unknown {\n try {\n return encode(schema, value)\n } catch (e) {\n if (e instanceof $ZodError) throw normalizeCodecPaths(e as $ZodError, schema)\n throw e\n }\n}\n","/**\n * Recursively strips `undefined` values from objects and arrays.\n * Used by codec encode/decode to clean wire data.\n *\n * Extracted to its own module so client-safe code (boundaryHelpers)\n * can import it without pulling in zod via utils.ts.\n */\nexport function stripUndefined<T>(value: T): T {\n if (value === null || value === undefined) {\n return value\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUndefined) as T\n }\n\n // Only process plain objects (not class instances, Dates, etc.)\n if (typeof value === 'object' && value.constructor === Object) {\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value)) {\n if (val !== undefined) {\n result[key] = stripUndefined(val)\n }\n }\n return result as T\n }\n\n return value\n}\n","import type { FunctionReference } from 'convex/server'\nimport type { $ZodIssue } from 'zod/v4/core'\nimport { safeEncode } from './normalizeCodecPaths'\nimport { stripUndefined } from './stripUndefined'\nimport type { AnyRegistry } from './types'\nimport { $ZodError, safeParse } from './zod-core'\n\n/**\n * Resolves a Convex FunctionReference to its string path.\n *\n * Mirrors `getFunctionName` from `convex/server` but without the server import.\n * Reads the well-known `Symbol.for('functionName')` that Convex attaches to all\n * function references — the same symbol used by Convex's own browser client.\n */\nconst functionNameSymbol = Symbol.for('functionName')\n\nfunction resolveFunctionPath(ref: FunctionReference<any, any, any, any>): string {\n if (typeof ref === 'string') return ref\n const name = (ref as any)[functionNameSymbol]\n if (!name) {\n throw new Error(\n `Expected a Convex function reference (e.g. api.file.func), but received ${JSON.stringify(ref)}`\n )\n }\n return name\n}\n\n/**\n * Options for codec helper behavior.\n */\nexport type BoundaryHelpersOptions = {\n /**\n * How to handle decode failures (schema validation errors on wire data).\n *\n * - `'warn'` (default): log a console.warn and return raw wire data untransformed.\n * - `'throw'`: throw a ZodvexDecodeError (extends z.ZodError). // zod-ok\n */\n onDecodeError?: 'warn' | 'throw'\n}\n\n/**\n * Decode error with function path and wire data context.\n * Extends $ZodError from zod/v4/core for compatibility with both zod and zod/mini.\n * instanceof $ZodError checks work in both variants.\n */\nexport class ZodvexDecodeError extends $ZodError {\n readonly functionPath: string\n readonly wireData: unknown\n\n constructor(functionPath: string, issues: $ZodIssue[], wireData: unknown) {\n super(issues)\n this.functionPath = functionPath\n this.wireData = wireData\n this.name = 'ZodvexDecodeError'\n }\n}\n\n/**\n * Creates shared encode/decode helpers bound to a zodvex registry.\n *\n * These are the core primitives used by all codec boundary implementations:\n * - `encodeArgs`: runtime types -> wire format (e.g., Date -> timestamp number)\n * - `decodeResult`: wire format -> runtime types (e.g., timestamp number -> Date)\n *\n * Both look up the function reference in the registry to find the appropriate\n * Zod schema, then apply the codec transform. Functions not in the registry\n * (or without the relevant schema) pass through unchanged.\n *\n * @param registry - A map of function paths to `{ args?, returns? }` Zod schemas.\n * Typically generated by zodvex codegen into `_zodvex/api.ts`.\n * @param options - Optional configuration for decode error behavior.\n */\nexport function createBoundaryHelpers(registry: AnyRegistry, options?: BoundaryHelpersOptions) {\n const onDecodeError = options?.onDecodeError ?? 'warn'\n const warnedPaths = new Set<string>()\n\n /**\n * Encode args from runtime types to wire format.\n *\n * Uses `safeEncode` (not raw `z.encode`) to normalize codec-internal\n * error paths in ZodErrors, then strips undefined values for Convex\n * serialization compatibility.\n *\n * Passthrough when:\n * - args is null/undefined\n * - function is not in the registry\n * - registry entry has no args schema\n */\n function encodeArgs(ref: FunctionReference<any, any, any, any>, args: any): any {\n if (args == null) return args\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.args) {\n if (entry === undefined && !warnedPaths.has(path)) {\n warnedPaths.add(path)\n console.debug(\n `[zodvex] No registry entry for \"${path}\" — args will not be codec-encoded. ` +\n 'If this function uses zodvex wrappers, run `zodvex generate` to update the registry.'\n )\n }\n return args\n }\n return stripUndefined(safeEncode(entry.args, args))\n }\n\n /**\n * Decode a wire result back to runtime types.\n *\n * Uses `.safeParse()` to decode. On failure:\n * - 'warn' (default): logs warning, returns raw wireResult\n * - 'throw': throws ZodvexDecodeError (extends z.ZodError) // zod-ok\n *\n * Passthrough when:\n * - function is not in the registry\n * - registry entry has no returns schema\n */\n function decodeResult(ref: FunctionReference<any, any, any, any>, wireResult: any): any {\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.returns) return wireResult\n\n const result = safeParse(entry.returns, wireResult)\n if (result.success) return result.data\n\n if (onDecodeError === 'throw') {\n throw new ZodvexDecodeError(path, result.error.issues, wireResult)\n }\n\n // Default: warn and return raw wire data\n const preview = JSON.stringify(wireResult)\n const truncated = preview.length > 200 ? `${preview.slice(0, 200)}...` : preview\n console.warn(\n `[zodvex] Decode failed for ${path}: ${result.error.issues.map((i: $ZodIssue) => `${i.path.join('.')}: ${i.message}`).join(', ')}. Returning raw wire data. Preview: ${truncated}`\n )\n return wireResult\n }\n\n return { encodeArgs, decodeResult }\n}\n\nexport type BoundaryHelpers = ReturnType<typeof createBoundaryHelpers>\n","import type { AuthTokenFetcher } from 'convex/browser'\nimport { ConvexClient } from 'convex/browser'\nimport type { FunctionArgs, FunctionReference, FunctionReturnType } from 'convex/server'\nimport type { BoundaryHelpersOptions } from '../../internal/boundaryHelpers'\nimport { createBoundaryHelpers } from '../../internal/boundaryHelpers'\nimport type { AnyRegistry } from '../../internal/types'\n\nexport type ZodvexClientOptions = (\n | { url: string; token?: string | null }\n | { client: ConvexClient }\n) &\n BoundaryHelpersOptions\n\n/** Wrap a static token string as an AuthTokenFetcher for ConvexClient */\nfunction tokenToFetcher(token: string): AuthTokenFetcher {\n return async () => token\n}\n\nexport class ZodvexClient<R extends AnyRegistry = AnyRegistry> {\n private codec: ReturnType<typeof createBoundaryHelpers>\n private innerClient?: ConvexClient\n private url?: string\n private pendingAuthFetcher?: AuthTokenFetcher\n\n constructor(registry: R, options: ZodvexClientOptions) {\n this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError })\n if ('client' in options) {\n this.innerClient = options.client\n } else {\n this.url = options.url\n if (options.token) this.pendingAuthFetcher = tokenToFetcher(options.token)\n }\n }\n\n private getUrl(): string {\n if (this.url) return this.url\n throw new Error('[zodvex] ZodvexClient is missing a Convex URL.')\n }\n\n private getConvex(): ConvexClient {\n if (this.innerClient) return this.innerClient\n\n const client = new ConvexClient(this.getUrl())\n if (this.pendingAuthFetcher) {\n client.setAuth(this.pendingAuthFetcher)\n }\n this.innerClient = client\n return client\n }\n\n get convex(): ConvexClient {\n return this.getConvex()\n }\n\n async query<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args']\n ): Promise<Q['_returnType']> {\n const wireResult = await this.getConvex().query(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n async mutate<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args']\n ): Promise<M['_returnType']> {\n const wireResult = await this.getConvex().mutation(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<M>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n subscribe<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void\n ): () => void {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onUpdate(ref, wireArgs, (wireResult: FunctionReturnType<Q>) => {\n callback(this.codec.decodeResult(ref, wireResult))\n })\n }\n\n setAuth(token: string | null) {\n const fetcher = async () => token\n this.pendingAuthFetcher = fetcher\n if (this.innerClient) {\n this.innerClient.setAuth(fetcher)\n }\n }\n\n async close() {\n await this.getConvex().close()\n }\n}\n\nexport function createZodvexClient<R extends AnyRegistry>(\n registry: R,\n options: ZodvexClientOptions\n): ZodvexClient<R> {\n return new ZodvexClient(registry, options)\n}\n"]}
1
+ {"version":3,"sources":["../../../src/internal/normalizeCodecPaths.ts","../../../src/internal/stripUndefined.ts","../../../src/internal/boundaryHelpers.ts","../../../src/public/client/zodvexClient.ts"],"names":[],"mappings":";;;;;;AAeA,SAAS,YAAY,MAAA,EAA4B;AAC/C,EAAA,IAAI,OAAA,GAAoB,MAAA;AACxB,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,EAAA,EAAI,CAAA,EAAA,EAAK;AAC3B,IAAA,IACE,OAAA,YAAmB,YAAA,IACnB,OAAA,YAAmB,YAAA,IACnB,mBAAmB,WAAA,EACnB;AACA,MAAA,OAAA,GAAU,OAAA,CAAQ,KAAK,GAAA,CAAI,SAAA;AAC3B,MAAA;AAAA,IACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAOA,SAAS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AQ,CAAA;AAAA,IAC5C;AAAA,EACF;AAAA;AAAA,EAGA,OAAA,GAAuE;AACrE,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,OAAA,EAAQ;AAAA,EAClC;AAAA;AAAA,EAGA,IAAI,MAAA,GAAkB;AACpB,IAAA,OAAO,IAAA,CAAK,aAAa,MAAA,IAAU,KAAA;AAAA,EACrC;AAAA;AAAA,EAGA,IAAI,QAAA,GAAoB;AACtB,IAAA,OAAO,IAAA,CAAK,aAAa,QAAA,IAAY,KAAA;AAAA,EACvC;AAAA,EAEA,eAAA,GAAmC;AACjC,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,eAAA,EAAgB;AAAA,EAC1C;AAAA,EAEA,2BAA2B,EAAA,EAAkD;AAC3E,IAAA,OAAO,IAAA,CAAK,SAAA,EAAU,CAAE,0BAAA,CAA2B,EAAE,CAAA;AAAA,EACvD;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,SAAA,EAAU,CAAE,KAAA,EAAM;AAAA,EAC/B;AACF;AAEO,SAAS,kBAAA,CACd,UACA,OAAA,EACiB;AACjB,EAAA,OAAO,IAAI,YAAA,CAAa,QAAA,EAAU,OAAO,CAAA;AAC3C","file":"index.js","sourcesContent":["import {\n $ZodArray,\n $ZodCodec,\n $ZodDefault,\n $ZodError,\n $ZodNullable,\n $ZodObject,\n $ZodOptional,\n $ZodType,\n encode\n} from './zod-core'\n\n/**\n * Unwraps ZodOptional/ZodNullable/ZodDefault wrappers to get the structural type.\n */\nfunction unwrapOuter(schema: $ZodType): $ZodType {\n let current: $ZodType = schema\n for (let i = 0; i < 10; i++) {\n if (\n current instanceof $ZodOptional ||\n current instanceof $ZodNullable ||\n current instanceof $ZodDefault\n ) {\n current = current._zod.def.innerType\n continue\n }\n break\n }\n return current\n}\n\n/**\n * Walks a path through a schema tree, truncating at codec boundaries.\n * When a codec is encountered, the path is cut — any deeper segments\n * are wire-internal and should not be exposed to consumers.\n */\nfunction truncateAtCodecBoundary(path: (string | number)[], schema: $ZodType): (string | number)[] {\n const result: (string | number)[] = []\n let current: $ZodType = schema\n\n for (const segment of path) {\n current = unwrapOuter(current)\n\n // If we've landed on a codec, everything from here is wire-internal — stop\n if (current instanceof $ZodCodec) {\n break\n }\n\n // Descend into objects\n if (current instanceof $ZodObject && typeof segment === 'string') {\n const fieldSchema = current._zod.def.shape[segment] as $ZodType | undefined\n if (!fieldSchema) {\n // Unknown field — include segment and stop\n result.push(segment)\n break\n }\n\n result.push(segment)\n\n const unwrapped = unwrapOuter(fieldSchema)\n if (unwrapped instanceof $ZodCodec) {\n // Hit a codec boundary — truncate here\n break\n }\n\n current = fieldSchema\n continue\n }\n\n // Descend into arrays\n if (current instanceof $ZodArray && typeof segment === 'number') {\n result.push(segment)\n current = current._zod.def.element\n continue\n }\n\n // For anything else (unions, records, etc.), include segment and continue\n result.push(segment)\n }\n\n return result\n}\n\n/**\n * Normalizes ZodError paths by truncating at codec boundaries.\n *\n * When z.encode() throws a ZodError, the paths reflect the wire schema\n * structure (e.g., [\"email\", \"value\"] for a custom codec).\n * This function strips the wire-internal segments so consumers see\n * clean field-level paths (e.g., [\"email\"]).\n */\nexport function normalizeCodecPaths(error: $ZodError, schema: $ZodType): $ZodError {\n const normalized = error.issues.map(issue => ({\n ...issue,\n path: truncateAtCodecBoundary(issue.path as (string | number)[], schema)\n }))\n return new $ZodError(normalized)\n}\n\n/**\n * Encodes a value through a Zod schema, normalizing codec-internal\n * path segments in any ZodError before re-throwing.\n *\n * Drop-in replacement for `z.encode(schema, value)` at client boundaries.\n */\nexport function safeEncode(schema: $ZodType, value: unknown): unknown {\n try {\n return encode(schema, value)\n } catch (e) {\n if (e instanceof $ZodError) throw normalizeCodecPaths(e as $ZodError, schema)\n throw e\n }\n}\n","/**\n * Recursively strips `undefined` values from objects and arrays.\n * Used by codec encode/decode to clean wire data.\n *\n * Extracted to its own module so client-safe code (boundaryHelpers)\n * can import it without pulling in zod via utils.ts.\n */\nexport function stripUndefined<T>(value: T): T {\n if (value === null || value === undefined) {\n return value\n }\n\n if (Array.isArray(value)) {\n return value.map(stripUndefined) as T\n }\n\n // Only process plain objects (not class instances, Dates, etc.)\n if (typeof value === 'object' && value.constructor === Object) {\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value)) {\n if (val !== undefined) {\n result[key] = stripUndefined(val)\n }\n }\n return result as T\n }\n\n return value\n}\n","import type { FunctionReference } from 'convex/server'\nimport type { $ZodIssue } from 'zod/v4/core'\nimport { safeEncode } from './normalizeCodecPaths'\nimport { stripUndefined } from './stripUndefined'\nimport type { AnyRegistry } from './types'\nimport { $ZodError, safeParse } from './zod-core'\n\n/**\n * Resolves a Convex FunctionReference to its string path.\n *\n * Mirrors `getFunctionName` from `convex/server` but without the server import.\n * Reads the well-known `Symbol.for('functionName')` that Convex attaches to all\n * function references — the same symbol used by Convex's own browser client.\n */\nconst functionNameSymbol = Symbol.for('functionName')\n\nfunction resolveFunctionPath(ref: FunctionReference<any, any, any, any>): string {\n if (typeof ref === 'string') return ref\n const name = (ref as any)[functionNameSymbol]\n if (!name) {\n throw new Error(\n `Expected a Convex function reference (e.g. api.file.func), but received ${JSON.stringify(ref)}`\n )\n }\n return name\n}\n\n/**\n * Options for codec helper behavior.\n */\nexport type BoundaryHelpersOptions = {\n /**\n * How to handle decode failures (schema validation errors on wire data).\n *\n * - `'warn'` (default): log a console.warn and return raw wire data untransformed.\n * - `'throw'`: throw a ZodvexDecodeError (extends z.ZodError). // zod-ok\n */\n onDecodeError?: 'warn' | 'throw'\n}\n\n/**\n * Decode error with function path and wire data context.\n * Extends $ZodError from zod/v4/core for compatibility with both zod and zod/mini.\n * instanceof $ZodError checks work in both variants.\n */\nexport class ZodvexDecodeError extends $ZodError {\n readonly functionPath: string\n readonly wireData: unknown\n\n constructor(functionPath: string, issues: $ZodIssue[], wireData: unknown) {\n super(issues)\n this.functionPath = functionPath\n this.wireData = wireData\n this.name = 'ZodvexDecodeError'\n }\n}\n\n/**\n * Creates shared encode/decode helpers bound to a zodvex registry.\n *\n * These are the core primitives used by all codec boundary implementations:\n * - `encodeArgs`: runtime types -> wire format (e.g., Date -> timestamp number)\n * - `decodeResult`: wire format -> runtime types (e.g., timestamp number -> Date)\n *\n * Both look up the function reference in the registry to find the appropriate\n * Zod schema, then apply the codec transform. Functions not in the registry\n * (or without the relevant schema) pass through unchanged.\n *\n * @param registry - A map of function paths to `{ args?, returns? }` Zod schemas.\n * Typically generated by zodvex codegen into `_zodvex/api.ts`.\n * @param options - Optional configuration for decode error behavior.\n */\nexport function createBoundaryHelpers(registry: AnyRegistry, options?: BoundaryHelpersOptions) {\n const onDecodeError = options?.onDecodeError ?? 'warn'\n const warnedPaths = new Set<string>()\n\n /**\n * Encode args from runtime types to wire format.\n *\n * Uses `safeEncode` (not raw `z.encode`) to normalize codec-internal\n * error paths in ZodErrors, then strips undefined values for Convex\n * serialization compatibility.\n *\n * Passthrough when:\n * - args is null/undefined\n * - function is not in the registry\n * - registry entry has no args schema\n */\n function encodeArgs(ref: FunctionReference<any, any, any, any>, args: any): any {\n if (args == null) return args\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.args) {\n if (entry === undefined && !warnedPaths.has(path)) {\n warnedPaths.add(path)\n console.debug(\n `[zodvex] No registry entry for \"${path}\" — args will not be codec-encoded. ` +\n 'If this function uses zodvex wrappers, run `zodvex generate` to update the registry.'\n )\n }\n return args\n }\n return stripUndefined(safeEncode(entry.args, args))\n }\n\n /**\n * Decode a wire result back to runtime types.\n *\n * Uses `.safeParse()` to decode. On failure:\n * - 'warn' (default): logs warning, returns raw wireResult\n * - 'throw': throws ZodvexDecodeError (extends z.ZodError) // zod-ok\n *\n * Passthrough when:\n * - function is not in the registry\n * - registry entry has no returns schema\n */\n function decodeResult(ref: FunctionReference<any, any, any, any>, wireResult: any): any {\n const path = resolveFunctionPath(ref)\n const entry = registry[path]\n if (!entry?.returns) return wireResult\n\n const result = safeParse(entry.returns, wireResult)\n if (result.success) return result.data\n\n if (onDecodeError === 'throw') {\n throw new ZodvexDecodeError(path, result.error.issues, wireResult)\n }\n\n // Default: warn and return raw wire data\n const preview = JSON.stringify(wireResult)\n const truncated = preview.length > 200 ? `${preview.slice(0, 200)}...` : preview\n console.warn(\n `[zodvex] Decode failed for ${path}: ${result.error.issues.map((i: $ZodIssue) => `${i.path.join('.')}: ${i.message}`).join(', ')}. Returning raw wire data. Preview: ${truncated}`\n )\n return wireResult\n }\n\n return { encodeArgs, decodeResult }\n}\n\nexport type BoundaryHelpers = ReturnType<typeof createBoundaryHelpers>\n","import type { AuthTokenFetcher, ConnectionState, MutationOptions } from 'convex/browser'\nimport { ConvexClient } from 'convex/browser'\nimport type { FunctionArgs, FunctionReference, FunctionReturnType } from 'convex/server'\nimport type { BoundaryHelpersOptions } from '../../internal/boundaryHelpers'\nimport { createBoundaryHelpers } from '../../internal/boundaryHelpers'\nimport type { AnyRegistry } from '../../internal/types'\n\nexport type ZodvexClientOptions = (\n | { url: string; token?: string | null }\n | { client: ConvexClient }\n) &\n BoundaryHelpersOptions\n\n/** Wrap a static token string as an AuthTokenFetcher for ConvexClient */\nfunction tokenToFetcher(token: string): AuthTokenFetcher {\n return async () => token\n}\n\nexport class ZodvexClient<R extends AnyRegistry = AnyRegistry> {\n private codec: ReturnType<typeof createBoundaryHelpers>\n private innerClient?: ConvexClient\n private url?: string\n private pendingAuthFetcher?: AuthTokenFetcher\n private pendingAuthOnChange?: (isAuthenticated: boolean) => void\n\n constructor(registry: R, options: ZodvexClientOptions) {\n this.codec = createBoundaryHelpers(registry, { onDecodeError: options.onDecodeError })\n if ('client' in options) {\n this.innerClient = options.client\n } else {\n this.url = options.url\n if (options.token) this.pendingAuthFetcher = tokenToFetcher(options.token)\n }\n }\n\n private getUrl(): string {\n if (this.url) return this.url\n throw new Error('[zodvex] ZodvexClient is missing a Convex URL.')\n }\n\n private getConvex(): ConvexClient {\n if (this.innerClient) return this.innerClient\n\n const client = new ConvexClient(this.getUrl())\n if (this.pendingAuthFetcher) {\n client.setAuth(this.pendingAuthFetcher, this.pendingAuthOnChange)\n }\n this.innerClient = client\n return client\n }\n\n get convex(): ConvexClient {\n return this.getConvex()\n }\n\n async query<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args']\n ): Promise<Q['_returnType']> {\n const wireResult = await this.getConvex().query(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n async mutate<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args'],\n options?: MutationOptions\n ): Promise<M['_returnType']> {\n const wireResult = await this.getConvex().mutation(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<M>,\n options\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n /** Alias for {@link mutate} — matches `ConvexClient.mutation` / `ZodvexReactClient.mutation`. */\n mutation<M extends FunctionReference<'mutation', any, any, any>>(\n ref: M,\n args: M['_args'],\n options?: MutationOptions\n ): Promise<M['_returnType']> {\n return this.mutate(ref, args, options)\n }\n\n async action<A extends FunctionReference<'action', any, any, any>>(\n ref: A,\n args: A['_args']\n ): Promise<A['_returnType']> {\n const wireResult = await this.getConvex().action(\n ref,\n this.codec.encodeArgs(ref, args) as FunctionArgs<A>\n )\n return this.codec.decodeResult(ref, wireResult)\n }\n\n subscribe<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void,\n onError?: (e: Error) => void\n ): () => void {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onUpdate(\n ref,\n wireArgs,\n (wireResult: FunctionReturnType<Q>) => {\n callback(this.codec.decodeResult(ref, wireResult))\n },\n onError\n )\n }\n\n /** Alias for {@link subscribe} — matches `ConvexClient.onUpdate`. */\n onUpdate<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n callback: (result: Q['_returnType']) => void,\n onError?: (e: Error) => void\n ): () => void {\n return this.subscribe(ref, args, callback, onError)\n }\n\n /**\n * Experimental paginated subscription. Encodes args to wire and decodes each\n * page item through the registry, mirroring {@link subscribe}.\n */\n onPaginatedUpdate_experimental<Q extends FunctionReference<'query', any, any, any>>(\n ref: Q,\n args: Q['_args'],\n options: { initialNumItems: number },\n callback: (result: {\n page: Q['_returnType'][]\n isDone: boolean\n continueCursor: string\n [key: string]: unknown\n }) => void,\n onError?: (e: Error) => void\n ): ReturnType<ConvexClient['onPaginatedUpdate_experimental']> {\n const wireArgs = this.codec.encodeArgs(ref, args) as FunctionArgs<Q>\n return this.getConvex().onPaginatedUpdate_experimental(\n ref,\n wireArgs,\n options,\n (wireResult: any) => {\n callback({\n ...wireResult,\n page: wireResult.page.map((item: any) => this.codec.decodeResult(ref, item))\n })\n },\n onError\n ) as ReturnType<ConvexClient['onPaginatedUpdate_experimental']>\n }\n\n /**\n * Set the auth token. Accepts either a raw token string (convenience) or a\n * Convex `AuthTokenFetcher` plus optional `onChange` callback (parity with\n * `ConvexClient.setAuth`).\n */\n setAuth(token: string | null): void\n setAuth(fetchToken: AuthTokenFetcher, onChange?: (isAuthenticated: boolean) => void): void\n setAuth(\n tokenOrFetcher: string | null | AuthTokenFetcher,\n onChange?: (isAuthenticated: boolean) => void\n ): void {\n const fetcher: AuthTokenFetcher =\n typeof tokenOrFetcher === 'function' ? tokenOrFetcher : async () => tokenOrFetcher\n this.pendingAuthFetcher = fetcher\n this.pendingAuthOnChange = onChange\n if (this.innerClient) {\n this.innerClient.setAuth(fetcher, onChange)\n }\n }\n\n /** Returns the current auth token and its decoded claims, if authenticated. */\n getAuth(): { token: string; decoded: Record<string, any> } | undefined {\n return this.getConvex().getAuth()\n }\n\n /** Whether this client has been closed. False before the inner client is created. */\n get closed(): boolean {\n return this.innerClient?.closed ?? false\n }\n\n /** Whether this client is disabled. False before the inner client is created. */\n get disabled(): boolean {\n return this.innerClient?.disabled ?? false\n }\n\n connectionState(): ConnectionState {\n return this.getConvex().connectionState()\n }\n\n subscribeToConnectionState(cb: (state: ConnectionState) => void): () => void {\n return this.getConvex().subscribeToConnectionState(cb)\n }\n\n async close() {\n await this.getConvex().close()\n }\n}\n\nexport function createZodvexClient<R extends AnyRegistry>(\n registry: R,\n options: ZodvexClientOptions\n): ZodvexClient<R> {\n return new ZodvexClient(registry, options)\n}\n"]}
@@ -228,6 +228,14 @@ var ZodvexReactClient = class {
228
228
  );
229
229
  return this.codec.decodeResult(ref, wireResult);
230
230
  }
231
+ /**
232
+ * Indicates likely future interest in a query subscription. Encodes args to
233
+ * wire before delegating, mirroring {@link watchQuery}.
234
+ */
235
+ prewarmQuery(queryOptions) {
236
+ const wireArgs = this.codec.encodeArgs(queryOptions.query, queryOptions.args);
237
+ this.getConvex().prewarmQuery({ ...queryOptions, args: wireArgs });
238
+ }
231
239
  watchQuery(ref, args, options) {
232
240
  const wireArgs = this.codec.encodeArgs(ref, args);
233
241
  const innerWatch = this.getConvex().watchQuery(ref, wireArgs, options);
@@ -264,6 +272,9 @@ var ZodvexReactClient = class {
264
272
  get url() {
265
273
  return this.getUrl();
266
274
  }
275
+ get logger() {
276
+ return this.getConvex().logger;
277
+ }
267
278
  connectionState() {
268
279
  return this.getConvex().connectionState();
269
280
  }