clivly 0.17.0 → 0.17.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.
- package/README.md +21 -27
- package/{adapter-BpAfha3z.d.mts → adapter-C63F9VZL.d.mts} +1 -1
- package/{adapter-BvSigBPG.d.cts → adapter-OO5g17qF.d.cts} +1 -1
- package/{auth-adapter-CsZE4ugg.d.cts → auth-adapter-COMP0Fud.d.cts} +1 -1
- package/{auth-adapter-Q6CL2VHr.d.mts → auth-adapter-ZlhllVpm.d.mts} +1 -1
- package/auth-better-auth.d.cts +1 -1
- package/auth-better-auth.d.mts +1 -1
- package/auth-clerk.d.cts +1 -1
- package/auth-clerk.d.mts +1 -1
- package/auth-workos.d.cts +1 -1
- package/auth-workos.d.mts +1 -1
- package/core-adapter.d.cts +1 -1
- package/core-adapter.d.mts +1 -1
- package/core-auth-adapter.d.cts +1 -1
- package/core-auth-adapter.d.mts +1 -1
- package/core-drizzle.d.cts +1 -1
- package/core-drizzle.d.mts +1 -1
- package/core-entity-config.cjs +1 -1
- package/core-entity-config.d.cts +1 -1
- package/core-entity-config.d.mts +1 -1
- package/core-entity-config.mjs +1 -1
- package/core-entity-heuristics.cjs +16 -15
- package/core-entity-heuristics.d.cts +3 -3
- package/core-entity-heuristics.d.mts +3 -3
- package/core-entity-heuristics.mjs +1 -1
- package/core-mapping-form.d.cts +1 -1
- package/core-mapping-form.d.mts +1 -1
- package/core-mappings-config.cjs +1 -1
- package/core-mappings-config.d.cts +1 -1
- package/core-mappings-config.d.mts +1 -1
- package/core-mappings-config.mjs +1 -1
- package/core-sync-engine.cjs +1 -1
- package/core-sync-engine.d.cts +1 -1
- package/core-sync-engine.d.mts +1 -1
- package/core-sync-engine.mjs +1 -1
- package/core-types.d.cts +1 -1
- package/core-types.d.mts +1 -1
- package/core-view-compiler.cjs +1 -1
- package/core-view-compiler.d.cts +1 -1
- package/core-view-compiler.d.mts +1 -1
- package/core-view-compiler.mjs +1 -1
- package/core.cjs +7 -7
- package/core.d.cts +9 -9
- package/core.d.mts +9 -9
- package/core.mjs +7 -7
- package/{drizzle-MUNZgh1l.d.cts → drizzle-B9cjBavj.d.cts} +1 -1
- package/{drizzle-UJbPCzPJ.d.mts → drizzle-L5FOGe_-.d.mts} +1 -1
- package/drizzle.cjs +2 -2
- package/drizzle.d.cts +3 -3
- package/drizzle.d.mts +3 -3
- package/drizzle.mjs +2 -2
- package/{entity-config-nWWgJXLw.cjs → entity-config-DiCJ6mhI.cjs} +1 -1
- package/{entity-config-BF7pcXFB.d.cts → entity-config-X-KlnYXX.d.mts} +1 -1
- package/{entity-config-pzamFSKw.d.mts → entity-config-dNclLyBM.d.cts} +1 -1
- package/{entity-config-DQVSprlG.mjs → entity-config-g_oMPXlN.mjs} +1 -1
- package/entity-heuristics-CIParuQe.cjs +655 -0
- package/entity-heuristics-DE5ujoHw.mjs +566 -0
- package/index.cjs +16 -15
- package/index.mjs +4 -3
- package/{internal-DtLZyjf8.mjs → internal-9oDwwbNg.mjs} +1 -1
- package/{internal-CjJy-cy1.cjs → internal-BKYt5j0l.cjs} +1 -1
- package/{internal-Gie7hCpK.d.mts → internal-COALpgov.d.cts} +1 -1
- package/{internal-C-uvosSL.d.cts → internal-D3q4FPcA.d.mts} +1 -1
- package/internal-adapter.d.cts +1 -1
- package/internal-adapter.d.mts +1 -1
- package/internal-auth-adapter.d.cts +1 -1
- package/internal-auth-adapter.d.mts +1 -1
- package/internal-drizzle.d.cts +1 -1
- package/internal-drizzle.d.mts +1 -1
- package/internal-entity-config.cjs +1 -1
- package/internal-entity-config.d.cts +1 -1
- package/internal-entity-config.d.mts +1 -1
- package/internal-entity-config.mjs +1 -1
- package/internal-entity-heuristics.cjs +16 -575
- package/internal-entity-heuristics.d.cts +3 -1
- package/internal-entity-heuristics.d.mts +3 -1
- package/internal-entity-heuristics.mjs +1 -562
- package/internal-mapping-form.d.cts +1 -1
- package/internal-mapping-form.d.mts +1 -1
- package/internal-mappings-config.cjs +1 -1
- package/internal-mappings-config.d.cts +1 -1
- package/internal-mappings-config.d.mts +1 -1
- package/internal-mappings-config.mjs +1 -1
- package/internal-sync-engine.cjs +1 -1
- package/internal-sync-engine.d.cts +1 -1
- package/internal-sync-engine.d.mts +1 -1
- package/internal-sync-engine.mjs +1 -1
- package/internal-types.d.cts +1 -1
- package/internal-types.d.mts +1 -1
- package/internal-view-compiler.cjs +1 -1
- package/internal-view-compiler.d.cts +1 -1
- package/internal-view-compiler.d.mts +1 -1
- package/internal-view-compiler.mjs +1 -1
- package/internal.cjs +7 -7
- package/internal.d.cts +9 -9
- package/internal.d.mts +9 -9
- package/internal.mjs +7 -7
- package/{mapping-form-BymksK7h.d.mts → mapping-form-Bpvgf5b8.d.mts} +1 -1
- package/{mapping-form-Cmf8y-1m.d.cts → mapping-form-CV7y6qox.d.cts} +1 -1
- package/{mappings-config-Dsz6rcJb.d.cts → mappings-config-BBppW9fp.d.cts} +1 -1
- package/{mappings-config-DBG-KnYl.cjs → mappings-config-CNxBrbt9.cjs} +1 -1
- package/{mappings-config-C7FPwrJT.mjs → mappings-config-D_g20PyS.mjs} +1 -1
- package/{mappings-config-ktJhxmHm.d.mts → mappings-config-Dmm0H6p_.d.mts} +1 -1
- package/{namespace-probe-CTkb35Ro.d.cts → namespace-probe-BHk3NcyI.d.cts} +31 -2
- package/{namespace-probe-By8SCnym.d.mts → namespace-probe-Dt_HXcI-.d.mts} +31 -2
- package/package.json +1 -7
- package/{projection-DNi_2dVa.mjs → projection-BkYXvjTr.mjs} +2434 -1147
- package/{projection-B8RtxuEq.cjs → projection-By63gMC-.cjs} +2434 -1147
- package/{projection-sql-BYv40Hen.mjs → projection-sql-C3gZE3GS.mjs} +1 -1
- package/{projection-sql-SuhzhsMe.cjs → projection-sql-CHz7KzNS.cjs} +1 -1
- package/{schemas-DySv963y.d.cts → schemas-BSuo_eZQ.d.cts} +97 -35
- package/{schemas-DySv963y.d.mts → schemas-BSuo_eZQ.d.mts} +97 -35
- package/{sdk-BJ3OkhCq.cjs → sdk-BZSTXPyK.cjs} +161 -27
- package/{sdk-CXrarwvs.mjs → sdk-KzHpSf7F.mjs} +161 -27
- package/sdk.cjs +2 -2
- package/sdk.d.cts +4 -4
- package/sdk.d.mts +4 -4
- package/sdk.mjs +2 -2
- package/{sync-engine-D9ltfqkD.d.cts → sync-engine-C7W0Gkq0.d.cts} +2 -2
- package/{sync-engine-C_SwnFgF.d.mts → sync-engine-C9Q2FkR9.d.mts} +2 -2
- package/{sync-engine-BTUoH82k.mjs → sync-engine-CwdLkmch.mjs} +1 -1
- package/{sync-engine-DBlSP9r2.cjs → sync-engine-Di-vF26b.cjs} +1 -1
- package/{types-BtQCi_qP.d.cts → types-C9_2vW5a.d.mts} +1 -1
- package/{types-CTOl3pAX.d.mts → types-CQ2DgEH7.d.cts} +1 -1
- package/{view-compiler-B8tJ5IGw.mjs → view-compiler-CLTi1VL-.mjs} +2 -2
- package/{view-compiler-Ce_QE3dh.cjs → view-compiler-DaOz5QVl.cjs} +2 -2
- package/{view-compiler-BZgZisTG.d.mts → view-compiler-M23WiVGG.d.mts} +1 -1
- package/{view-compiler-D7GLf1n8.d.cts → view-compiler-cXqt4X-c.d.cts} +1 -1
- package/vite.d.cts +1 -1
- package/vite.d.mts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type _JSONSchema = boolean | JSONSchema;
|
|
2
|
+
type SchemaType = "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
|
|
2
3
|
type JSONSchema = {
|
|
3
4
|
[k: string]: unknown;
|
|
4
5
|
$schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
|
|
@@ -10,7 +11,7 @@ type JSONSchema = {
|
|
|
10
11
|
$vocabulary?: Record<string, boolean>;
|
|
11
12
|
$comment?: string;
|
|
12
13
|
$defs?: Record<string, JSONSchema>;
|
|
13
|
-
type?:
|
|
14
|
+
type?: SchemaType | SchemaType[];
|
|
14
15
|
additionalItems?: _JSONSchema;
|
|
15
16
|
unevaluatedItems?: _JSONSchema;
|
|
16
17
|
prefixItems?: _JSONSchema[];
|
|
@@ -207,6 +208,18 @@ interface JSONSchemaMeta {
|
|
|
207
208
|
}
|
|
208
209
|
interface GlobalMeta extends JSONSchemaMeta {}
|
|
209
210
|
type Processor<T extends $ZodType = $ZodType> = (schema: T, ctx: ToJSONSchemaContext, json: BaseSchema, params: ProcessParams) => void;
|
|
211
|
+
/**
|
|
212
|
+
* Called for each schema that has no JSON Schema equivalent. Return a JSON Schema to use in its
|
|
213
|
+
* place, `"any"` to fall back to the `unrepresentable: "any"` behavior, or `"throw"`/`undefined` to
|
|
214
|
+
* throw the default error. Throwing from the handler propagates, so custom errors work too.
|
|
215
|
+
*/
|
|
216
|
+
type UnrepresentableHandler<T extends $ZodType = $ZodType> = (ctx: {
|
|
217
|
+
zodSchema: T;
|
|
218
|
+
path: (string | number)[];
|
|
219
|
+
/** The error Zod would throw. Distinguishes sites that share a `zodSchema`, e.g. an `undefined`
|
|
220
|
+
* vs a `bigint` member of the same literal. */
|
|
221
|
+
message: string;
|
|
222
|
+
}) => BaseSchema | "throw" | "any" | undefined;
|
|
210
223
|
interface JSONSchemaGeneratorParams {
|
|
211
224
|
processors: Record<string, Processor>;
|
|
212
225
|
/** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
|
|
@@ -220,8 +233,9 @@ interface JSONSchemaGeneratorParams {
|
|
|
220
233
|
target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined;
|
|
221
234
|
/** How to handle unrepresentable types.
|
|
222
235
|
* - `"throw"` — Default. Unrepresentable types throw an error
|
|
223
|
-
* - `"any"` — Unrepresentable types become `{}`
|
|
224
|
-
|
|
236
|
+
* - `"any"` — Unrepresentable types become `{}`
|
|
237
|
+
* - A function — called once per unrepresentable schema; see {@link UnrepresentableHandler}. */
|
|
238
|
+
unrepresentable?: "throw" | "any" | UnrepresentableHandler<$ZodTypes>;
|
|
225
239
|
/** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
|
|
226
240
|
override?: (ctx: {
|
|
227
241
|
zodSchema: $ZodTypes;
|
|
@@ -270,7 +284,7 @@ interface ToJSONSchemaContext {
|
|
|
270
284
|
processors: Record<string, Processor>;
|
|
271
285
|
metadataRegistry: $ZodRegistry<Record<string, any>>;
|
|
272
286
|
target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
|
|
273
|
-
unrepresentable: "throw" | "any";
|
|
287
|
+
unrepresentable: "throw" | "any" | UnrepresentableHandler;
|
|
274
288
|
override: (ctx: {
|
|
275
289
|
zodSchema: $ZodType;
|
|
276
290
|
jsonSchema: BaseSchema;
|
|
@@ -279,8 +293,28 @@ interface ToJSONSchemaContext {
|
|
|
279
293
|
io: "input" | "output";
|
|
280
294
|
counter: number;
|
|
281
295
|
seen: Map<$ZodType, Seen>;
|
|
296
|
+
/** Registry conversions share one `seen` map across every emitted schema. These hold the
|
|
297
|
+
* `external` the whole-map passes below last ran for, so the passes are not repeated once per
|
|
298
|
+
* schema — and still re-run if the map grows or `external` is swapped. `sharedEmitDoneFor`
|
|
299
|
+
* covers both passes in `finalize`: the ref flattening and the `$defs` build.
|
|
300
|
+
*
|
|
301
|
+
* The passes are valid only while nothing they read has changed, so both are cleared in
|
|
302
|
+
* `processSchema()` when the map grows, and in `JSONSchemaGenerator.emit()`, which can also change
|
|
303
|
+
* the `cycles` and `reused` they branch on.
|
|
304
|
+
*
|
|
305
|
+
* One case is deliberately not covered: an `override` callback that writes to
|
|
306
|
+
* `metadataRegistry` mid-conversion. It runs inside `finalize`, so a registry conversion has
|
|
307
|
+
* nowhere left to clear the guards, and later schemas keep the ids the first pass saw. That
|
|
308
|
+
* output was never coherent — before this, whether a shared subschema was inlined or extracted
|
|
309
|
+
* depended on which registry entry happened to be emitted when the callback fired. */
|
|
310
|
+
sharedDefsExtractedFor?: ToJSONSchemaContext["external"];
|
|
311
|
+
sharedEmitDoneFor?: ToJSONSchemaContext["external"];
|
|
282
312
|
cycles: "ref" | "throw";
|
|
283
313
|
reused: "ref" | "inline";
|
|
314
|
+
/** The `allOf` array of each intersection encountered during traversal, innermost first. `finalize` folds every emitted object holding one; see `foldIntersection`. */
|
|
315
|
+
intersections: BaseSchema[][];
|
|
316
|
+
/** Rewrites a processor deferred to `finalize`, where the flatten has resolved every ref and the union branches are in place. */
|
|
317
|
+
deferred: (() => void)[];
|
|
284
318
|
external?: {
|
|
285
319
|
registry: $ZodRegistry<{
|
|
286
320
|
id?: string | undefined;
|
|
@@ -332,9 +366,11 @@ type EmptyToNever<T> = keyof T extends never ? never : T;
|
|
|
332
366
|
declare abstract class Class {
|
|
333
367
|
constructor(..._args: any[]);
|
|
334
368
|
}
|
|
369
|
+
/** A trait's prototype members: a partial view of its own interface, with `this` typed as the instance. */
|
|
370
|
+
type ProtoOf<T> = { [K in keyof T]?: (T[K] extends ((...args: infer A) => infer R) ? (...args: A) => R : T[K]) | undefined; } & ThisType<T>;
|
|
335
371
|
declare const version: {
|
|
336
372
|
readonly major: 4;
|
|
337
|
-
readonly minor:
|
|
373
|
+
readonly minor: 6;
|
|
338
374
|
readonly patch: number;
|
|
339
375
|
};
|
|
340
376
|
interface ParseContext<T extends $ZodIssueBase = never> {
|
|
@@ -350,17 +386,17 @@ interface ParseContextInternal<T extends $ZodIssueBase = never> extends ParseCon
|
|
|
350
386
|
readonly async?: boolean | undefined;
|
|
351
387
|
readonly direction?: "forward" | "backward";
|
|
352
388
|
readonly skipChecks?: boolean;
|
|
389
|
+
/** Set only by `validate`/`validateAsync`. A container may stop before its next child, never inside one, so a map entry and a tuple's fixed items parse whole. */
|
|
390
|
+
readonly abortEarly?: boolean;
|
|
353
391
|
}
|
|
354
392
|
interface ParsePayload<T = unknown> {
|
|
355
393
|
value: T;
|
|
356
394
|
issues: $ZodRawIssue[];
|
|
357
395
|
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
|
358
396
|
aborted?: boolean;
|
|
359
|
-
/** @internal
|
|
360
|
-
*
|
|
361
|
-
|
|
362
|
-
* $ZodTransform invocation. */
|
|
363
|
-
fallback?: boolean | undefined;
|
|
397
|
+
/** @internal Set when the value came from a repeat visit to a node still being
|
|
398
|
+
* parsed. Its checks run on the node itself, against the finished value. */
|
|
399
|
+
memo?: boolean | undefined;
|
|
364
400
|
}
|
|
365
401
|
type CheckFn<T> = (input: ParsePayload<T>) => MaybeAsync<void>;
|
|
366
402
|
interface $ZodTypeDef {
|
|
@@ -385,8 +421,13 @@ interface _$ZodTypeInternals {
|
|
|
385
421
|
/** @internal Indicates that a schema output type should be considered optional inside objects.
|
|
386
422
|
* @default Required
|
|
387
423
|
*/
|
|
388
|
-
/** @internal
|
|
389
|
-
|
|
424
|
+
/** @internal Three rungs, each strictly stronger than the last:
|
|
425
|
+
* undefined — required; the container may not omit this slot
|
|
426
|
+
* "optional" — the container may omit it; nothing is supplied in its place
|
|
427
|
+
* "defaulted" — the container may omit it AND this schema substitutes a value
|
|
428
|
+
* Consumers asking "may the slot be absent?" test `!== undefined`.
|
|
429
|
+
* $ZodOptional asks the stronger question and tests `=== "defaulted"`. */
|
|
430
|
+
optin?: "optional" | "defaulted" | undefined;
|
|
390
431
|
/** @internal */
|
|
391
432
|
optout?: "optional" | undefined;
|
|
392
433
|
/** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
|
|
@@ -448,6 +489,8 @@ interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
|
|
|
448
489
|
patterns: Set<RegExp>;
|
|
449
490
|
format: string;
|
|
450
491
|
contentEncoding: string;
|
|
492
|
+
/** the pattern admits strings its `format` keyword forbids, so `toJSONSchema` must not emit it */
|
|
493
|
+
laxFormat: boolean;
|
|
451
494
|
}>;
|
|
452
495
|
}
|
|
453
496
|
interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {}
|
|
@@ -497,7 +540,12 @@ interface $ZodEmoji extends $ZodType {
|
|
|
497
540
|
_zod: $ZodEmojiInternals;
|
|
498
541
|
}
|
|
499
542
|
declare const $ZodEmoji: $constructor<$ZodEmoji>;
|
|
500
|
-
interface $
|
|
543
|
+
interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
|
544
|
+
length?: number | undefined;
|
|
545
|
+
}
|
|
546
|
+
interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
|
547
|
+
def: $ZodNanoIDDef;
|
|
548
|
+
}
|
|
501
549
|
interface $ZodNanoID extends $ZodType {
|
|
502
550
|
_zod: $ZodNanoIDInternals;
|
|
503
551
|
}
|
|
@@ -812,11 +860,11 @@ type OptionalOutSchema = {
|
|
|
812
860
|
};
|
|
813
861
|
type OptionalInSchema = {
|
|
814
862
|
_zod: {
|
|
815
|
-
optin: "optional";
|
|
863
|
+
optin: "optional" | "defaulted";
|
|
816
864
|
};
|
|
817
865
|
};
|
|
818
|
-
type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> :
|
|
819
|
-
type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> :
|
|
866
|
+
type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : { [k in string]: output<T[keyof T]>; } : keyof (T & Extra) extends never ? Record<string, never> : Prettify<{ -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"]; } & { -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"]; } & Extra>;
|
|
867
|
+
type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : { [k in string]: input<T[keyof T]>; } : keyof (T & Extra) extends never ? Record<string, never> : Prettify<{ -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"]; } & { -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"]; } & Extra>;
|
|
820
868
|
type $ZodObjectConfig = {
|
|
821
869
|
out: Record<string, unknown>;
|
|
822
870
|
in: Record<string, unknown>;
|
|
@@ -882,7 +930,7 @@ interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]
|
|
|
882
930
|
values: T[number]["_zod"]["values"];
|
|
883
931
|
output: $InferUnionOutput<T[number]>;
|
|
884
932
|
input: $InferUnionInput<T[number]>;
|
|
885
|
-
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
|
933
|
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | "defaulted" | undefined : "optional" | "defaulted";
|
|
886
934
|
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
|
887
935
|
}
|
|
888
936
|
interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodType<any, any, $ZodUnionInternals<T>> {
|
|
@@ -913,7 +961,7 @@ interface $ZodTupleDef<T extends TupleItems = readonly $ZodType[], Rest extends
|
|
|
913
961
|
}
|
|
914
962
|
type $InferTupleInputType<T extends TupleItems, Rest extends SomeType | null> = [...TupleInputTypeWithOptionals<T>, ...(Rest extends SomeType ? input<Rest>[] : [])];
|
|
915
963
|
type TupleInputTypeNoOptionals<T extends TupleItems> = { [k in keyof T]: input<T[k]>; };
|
|
916
|
-
type TupleInputTypeWithOptionals<T extends TupleItems> = T extends readonly [...infer Prefix extends SomeType[], infer Tail extends SomeType] ? Tail["_zod"]["optin"] extends "optional" ? [...TupleInputTypeWithOptionals<Prefix>, input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
|
964
|
+
type TupleInputTypeWithOptionals<T extends TupleItems> = T extends readonly [...infer Prefix extends SomeType[], infer Tail extends SomeType] ? Tail["_zod"]["optin"] extends "optional" | "defaulted" ? [...TupleInputTypeWithOptionals<Prefix>, input<Tail>?] : TupleInputTypeNoOptionals<T> : [];
|
|
917
965
|
type $InferTupleOutputType<T extends TupleItems, Rest extends SomeType | null> = [...TupleOutputTypeWithOptionals<T>, ...(Rest extends SomeType ? output<Rest>[] : [])];
|
|
918
966
|
type TupleOutputTypeNoOptionals<T extends TupleItems> = { [k in keyof T]: output<T[k]>; };
|
|
919
967
|
type TupleOutputTypeWithOptionals<T extends TupleItems> = T extends readonly [...infer Prefix extends SomeType[], infer Tail extends SomeType] ? Tail["_zod"]["optout"] extends "optional" ? [...TupleOutputTypeWithOptionals<Prefix>, output<Tail>?] : TupleOutputTypeNoOptionals<T> : [];
|
|
@@ -934,11 +982,14 @@ interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends
|
|
|
934
982
|
valueType: Value;
|
|
935
983
|
/** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
|
|
936
984
|
mode?: "strict" | "loose";
|
|
985
|
+
partial?: boolean;
|
|
937
986
|
}
|
|
938
987
|
type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<output<Key>, output<Value>>> : Record<output<Key>, output<Value>>;
|
|
939
|
-
type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<input<Key> & PropertyKey, input<Value>>> : Record<input<Key> & PropertyKey, input<Value>>;
|
|
940
|
-
interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
988
|
+
type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<input<Key> & PropertyKey, input<Value>>> : [Value] extends [OptionalInSchema] ? Partial<Record<input<Key> & PropertyKey, input<Value>>> : Record<input<Key> & PropertyKey, input<Value>>;
|
|
989
|
+
interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals {
|
|
941
990
|
def: $ZodRecordDef<Key, Value>;
|
|
991
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
992
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
942
993
|
isst: $ZodIssueInvalidType | $ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
943
994
|
optin?: "optional" | undefined;
|
|
944
995
|
optout?: "optional" | undefined;
|
|
@@ -1055,7 +1106,7 @@ interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
|
1055
1106
|
}
|
|
1056
1107
|
interface $ZodOptionalInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<output<T> | undefined, input<T> | undefined> {
|
|
1057
1108
|
def: $ZodOptionalDef<T>;
|
|
1058
|
-
optin: "optional";
|
|
1109
|
+
optin: "optional" | "defaulted";
|
|
1059
1110
|
optout: "optional";
|
|
1060
1111
|
isst: never;
|
|
1061
1112
|
values: T["_zod"]["values"];
|
|
@@ -1099,7 +1150,7 @@ interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
|
1099
1150
|
}
|
|
1100
1151
|
interface $ZodDefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<NoUndefined<output<T>>, input<T> | undefined> {
|
|
1101
1152
|
def: $ZodDefaultDef<T>;
|
|
1102
|
-
optin: "
|
|
1153
|
+
optin: "defaulted";
|
|
1103
1154
|
optout?: "optional" | undefined;
|
|
1104
1155
|
isst: never;
|
|
1105
1156
|
values: T["_zod"]["values"];
|
|
@@ -1114,9 +1165,9 @@ interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
|
|
|
1114
1165
|
/** The default value. May be a getter. */
|
|
1115
1166
|
defaultValue: input<T>;
|
|
1116
1167
|
}
|
|
1117
|
-
interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<
|
|
1168
|
+
interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<output<T>, input<T> | undefined> {
|
|
1118
1169
|
def: $ZodPrefaultDef<T>;
|
|
1119
|
-
optin: "
|
|
1170
|
+
optin: "defaulted";
|
|
1120
1171
|
optout?: "optional" | undefined;
|
|
1121
1172
|
isst: never;
|
|
1122
1173
|
values: T["_zod"]["values"];
|
|
@@ -1386,16 +1437,16 @@ interface $ZodCheckMultipleOf<T extends number | bigint = number | bigint> exten
|
|
|
1386
1437
|
}
|
|
1387
1438
|
declare const $ZodCheckMultipleOf: $constructor<$ZodCheckMultipleOf<number | bigint>>;
|
|
1388
1439
|
type $ZodNumberFormats = "int32" | "uint32" | "float32" | "float64" | "safeint";
|
|
1389
|
-
interface $ZodCheckNumberFormatDef extends $ZodCheckDef {
|
|
1440
|
+
interface $ZodCheckNumberFormatDef<Format extends $ZodNumberFormats = $ZodNumberFormats> extends $ZodCheckDef {
|
|
1390
1441
|
check: "number_format";
|
|
1391
|
-
format:
|
|
1442
|
+
format: Format;
|
|
1392
1443
|
}
|
|
1393
|
-
interface $ZodCheckNumberFormatInternals extends $ZodCheckInternals<number> {
|
|
1394
|
-
def: $ZodCheckNumberFormatDef
|
|
1444
|
+
interface $ZodCheckNumberFormatInternals<Format extends $ZodNumberFormats = $ZodNumberFormats> extends $ZodCheckInternals<number> {
|
|
1445
|
+
def: $ZodCheckNumberFormatDef<Format>;
|
|
1395
1446
|
issc: $ZodIssueInvalidType | $ZodIssueTooBig<"number"> | $ZodIssueTooSmall<"number">;
|
|
1396
1447
|
}
|
|
1397
|
-
interface $ZodCheckNumberFormat extends $ZodCheck<number> {
|
|
1398
|
-
_zod: $ZodCheckNumberFormatInternals
|
|
1448
|
+
interface $ZodCheckNumberFormat<Format extends $ZodNumberFormats = $ZodNumberFormats> extends $ZodCheck<number> {
|
|
1449
|
+
_zod: $ZodCheckNumberFormatInternals<Format>;
|
|
1399
1450
|
}
|
|
1400
1451
|
declare const $ZodCheckNumberFormat: $constructor<$ZodCheckNumberFormat>;
|
|
1401
1452
|
interface $ZodCheckMaxLengthDef extends $ZodCheckDef {
|
|
@@ -1434,7 +1485,7 @@ interface $ZodCheckLengthEquals<T extends HasLength = HasLength> extends $ZodChe
|
|
|
1434
1485
|
_zod: $ZodCheckLengthEqualsInternals<T>;
|
|
1435
1486
|
}
|
|
1436
1487
|
declare const $ZodCheckLengthEquals: $constructor<$ZodCheckLengthEquals>;
|
|
1437
|
-
type $ZodStringFormats = "email" | "url" | "emoji" | "uuid" | "guid" | "nanoid" | "cuid" | "cuid2" | "ulid" | "xid" | "ksuid" | "datetime" | "date" | "time" | "duration" | "ipv4" | "ipv6" | "cidrv4" | "cidrv6" | "base64" | "base64url" | "json_string" | "e164" | "lowercase" | "uppercase" | "regex" | "jwt" | "starts_with" | "ends_with" | "includes";
|
|
1488
|
+
type $ZodStringFormats = "email" | "url" | "emoji" | "uuid" | "guid" | "nanoid" | "cuid" | "cuid2" | "ulid" | "xid" | "ksuid" | "datetime" | "date" | "time" | "duration" | "ipv4" | "ipv6" | "cidrv4" | "cidrv6" | "base64" | "base64url" | "json_string" | "e164" | "credit_card" | "iban" | "lowercase" | "uppercase" | "regex" | "jwt" | "starts_with" | "ends_with" | "includes";
|
|
1438
1489
|
interface $ZodCheckStringFormatDef<Format extends string = string> extends $ZodCheckDef {
|
|
1439
1490
|
check: "string_format";
|
|
1440
1491
|
format: Format;
|
|
@@ -1568,6 +1619,8 @@ interface $ZodIssueInvalidUnionMultipleMatch extends $ZodIssueBase {
|
|
|
1568
1619
|
readonly input?: unknown;
|
|
1569
1620
|
readonly discriminator?: string | undefined;
|
|
1570
1621
|
readonly inclusive: false;
|
|
1622
|
+
/** Indices of the options that matched */
|
|
1623
|
+
readonly matches: number[];
|
|
1571
1624
|
}
|
|
1572
1625
|
type $ZodIssueInvalidUnion = $ZodIssueInvalidUnionNoMatch | $ZodIssueInvalidUnionMultipleMatch;
|
|
1573
1626
|
interface $ZodIssueInvalidKey<Input = unknown> extends $ZodIssueBase {
|
|
@@ -1600,6 +1653,8 @@ type RawIssue$1<T extends $ZodIssueBase> = T extends any ? Flatten<MakePartial<T
|
|
|
1600
1653
|
readonly input: unknown;
|
|
1601
1654
|
/** The schema or check that originated this issue. */
|
|
1602
1655
|
readonly inst?: $ZodType | $ZodCheck;
|
|
1656
|
+
/** The schema that owns the issue. Equal to `inst` when a schema originated the issue, and the schema the check was attached to when a check did. */
|
|
1657
|
+
readonly schema?: $ZodType | undefined;
|
|
1603
1658
|
/** If `true`, Zod will continue executing checks/refinements after this issue. */
|
|
1604
1659
|
readonly continue?: boolean | undefined;
|
|
1605
1660
|
} & Record<string, unknown>> : never;
|
|
@@ -1641,9 +1696,12 @@ interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
|
|
|
1641
1696
|
new (def: D): T;
|
|
1642
1697
|
init(inst: T, def: D): asserts inst is T;
|
|
1643
1698
|
}
|
|
1644
|
-
|
|
1699
|
+
interface $constructorParams {
|
|
1645
1700
|
Parent?: typeof Class;
|
|
1646
|
-
}
|
|
1701
|
+
}
|
|
1702
|
+
declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void,
|
|
1703
|
+
/** This trait's members, installed once on every prototype that composes it. They cannot be declared in the initializer above: that runs per instance, and the prototype is shared. */
|
|
1704
|
+
proto?: ProtoOf<T>, params?: $constructorParams): $constructor<T, D>;
|
|
1647
1705
|
declare const $brand: unique symbol;
|
|
1648
1706
|
type $brand<T extends string | number | symbol = string | number | symbol> = {
|
|
1649
1707
|
[$brand]: { [k in T]: true; };
|
|
@@ -1689,7 +1747,7 @@ type $ZodCheckGUIDParams = CheckStringFormatParams<$ZodGUID, "pattern" | "when">
|
|
|
1689
1747
|
type $ZodCheckUUIDParams = CheckStringFormatParams<$ZodUUID, "pattern" | "when">;
|
|
1690
1748
|
type $ZodCheckURLParams = CheckStringFormatParams<$ZodURL, "when">;
|
|
1691
1749
|
type $ZodCheckEmojiParams = CheckStringFormatParams<$ZodEmoji, "when">;
|
|
1692
|
-
type $ZodCheckNanoIDParams = CheckStringFormatParams<$ZodNanoID, "when">;
|
|
1750
|
+
type $ZodCheckNanoIDParams = CheckStringFormatParams<$ZodNanoID, "when" | "pattern">;
|
|
1693
1751
|
/**
|
|
1694
1752
|
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
1695
1753
|
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
@@ -1794,6 +1852,8 @@ interface ZodType<out Output = unknown, out Input = unknown, out Internals exten
|
|
|
1794
1852
|
parseAsync(data: unknown, params?: ParseContext<$ZodIssue>): Promise<output<this>>;
|
|
1795
1853
|
safeParseAsync(data: unknown, params?: ParseContext<$ZodIssue>): Promise<ZodSafeParseResult<output<this>>>;
|
|
1796
1854
|
spa: (data: unknown, params?: ParseContext<$ZodIssue>) => Promise<ZodSafeParseResult<output<this>>>;
|
|
1855
|
+
validate(data: unknown, params?: ParseContext<$ZodIssue>): data is input<this>;
|
|
1856
|
+
validateAsync(data: unknown, params?: ParseContext<$ZodIssue>): Promise<boolean>;
|
|
1797
1857
|
encode(data: output<this>, params?: ParseContext<$ZodIssue>): input<this>;
|
|
1798
1858
|
decode(data: input<this>, params?: ParseContext<$ZodIssue>): output<this>;
|
|
1799
1859
|
encodeAsync(data: output<this>, params?: ParseContext<$ZodIssue>): Promise<input<this>>;
|
|
@@ -1846,7 +1906,7 @@ interface ZodType<out Output = unknown, out Input = unknown, out Internals exten
|
|
|
1846
1906
|
* ```
|
|
1847
1907
|
*/
|
|
1848
1908
|
isNullable(): boolean;
|
|
1849
|
-
apply<T>(fn: (schema: this) => T): T;
|
|
1909
|
+
apply<T, TArgs extends unknown[] = []>(fn: (schema: this, ...args: TArgs) => T, ...args: TArgs): T;
|
|
1850
1910
|
}
|
|
1851
1911
|
interface _ZodType<out Internals extends $ZodTypeInternals = $ZodTypeInternals> extends ZodType<any, any, Internals> {}
|
|
1852
1912
|
declare const ZodType: $constructor<ZodType>;
|
|
@@ -2005,6 +2065,8 @@ out Shape extends $ZodShape = $ZodLooseShape, out Config extends $ZodObjectConfi
|
|
|
2005
2065
|
omit<M extends Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
|
|
2006
2066
|
partial(): ZodObject<{ -readonly [k in keyof Shape]: ZodOptional<Shape[k]>; }, Config>;
|
|
2007
2067
|
partial<M extends Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<{ -readonly [k in keyof Shape]: k extends keyof M ? ZodOptional<Shape[k]> : Shape[k]; }, Config>;
|
|
2068
|
+
exactPartial(): ZodObject<{ -readonly [k in keyof Shape]: ZodExactOptional<Shape[k]>; }, Config>;
|
|
2069
|
+
exactPartial<M extends Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<{ -readonly [k in keyof Shape]: k extends keyof M ? ZodExactOptional<Shape[k]> : Shape[k]; }, Config>;
|
|
2008
2070
|
required(): ZodObject<{ -readonly [k in keyof Shape]: ZodNonOptional<Shape[k]>; }, Config>;
|
|
2009
2071
|
required<M extends Mask<keyof Shape>>(mask: M & Record<Exclude<keyof M, keyof Shape>, never>): ZodObject<{ -readonly [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k]; }, Config>;
|
|
2010
2072
|
}
|