@temporary-name/zod 1.9.3-alpha.4225889dbc4c4adc76cdbabb804a30cd075c9d7a → 1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6
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/dist/index.d.mts +39 -24
- package/dist/index.d.ts +39 -24
- package/dist/index.mjs +112 -52
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -26,6 +26,9 @@ declare const ZodRealError: core.$constructor<ZodError>;
|
|
|
26
26
|
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
|
27
27
|
type IssueData = core.$ZodRawIssue;
|
|
28
28
|
|
|
29
|
+
interface ParseContext extends core.ParseContextInternal<core.$ZodIssue> {
|
|
30
|
+
parseType?: 'query' | 'body' | 'path' | 'header' | 'output';
|
|
31
|
+
}
|
|
29
32
|
type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
|
|
30
33
|
type ZodSafeParseSuccess<T> = {
|
|
31
34
|
success: true;
|
|
@@ -37,24 +40,24 @@ type ZodSafeParseError<T> = {
|
|
|
37
40
|
data?: never;
|
|
38
41
|
error: ZodError<T>;
|
|
39
42
|
};
|
|
40
|
-
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
43
|
+
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
41
44
|
callee?: core.util.AnyFunc;
|
|
42
45
|
Err?: core.$ZodErrorClass;
|
|
43
46
|
}) => core.output<T>;
|
|
44
|
-
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
47
|
+
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
45
48
|
callee?: core.util.AnyFunc;
|
|
46
49
|
Err?: core.$ZodErrorClass;
|
|
47
50
|
}) => Promise<core.output<T>>;
|
|
48
|
-
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
49
|
-
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
50
|
-
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
51
|
-
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
52
|
-
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
53
|
-
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
54
|
-
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
55
|
-
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
56
|
-
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
57
|
-
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
51
|
+
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
52
|
+
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
53
|
+
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => core.input<T>;
|
|
54
|
+
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => core.output<T>;
|
|
55
|
+
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<core.input<T>>;
|
|
56
|
+
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<core.output<T>>;
|
|
57
|
+
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.input<T>>;
|
|
58
|
+
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
59
|
+
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.input<T>>>;
|
|
60
|
+
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
58
61
|
|
|
59
62
|
type IsGateEnabled = (gate: string) => boolean;
|
|
60
63
|
declare const gatingContext: AsyncLocalStorage<IsGateEnabled>;
|
|
@@ -76,6 +79,15 @@ interface KrustyGate<T extends core.SomeType = core.$ZodType, K extends KrustyIn
|
|
|
76
79
|
declare const KrustyGate: core.$constructor<KrustyGate>;
|
|
77
80
|
declare function gate<T extends core.SomeType, K extends KrustyInternals>(innerType: T, gateName: K['gateNames']): KrustyGate<T, K>;
|
|
78
81
|
|
|
82
|
+
interface KrustyISODateTime extends KrustyStringFormat {
|
|
83
|
+
_zod: core.$ZodISODateTimeInternals;
|
|
84
|
+
}
|
|
85
|
+
declare const KrustyISODateTime: core.$constructor<KrustyISODateTime>;
|
|
86
|
+
interface KrustyISODate extends KrustyStringFormat {
|
|
87
|
+
_zod: core.$ZodISODateInternals;
|
|
88
|
+
}
|
|
89
|
+
declare const KrustyISODate: core.$constructor<KrustyISODate>;
|
|
90
|
+
|
|
79
91
|
type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
|
80
92
|
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
|
81
93
|
};
|
|
@@ -164,6 +176,13 @@ interface KrustyType<out Output = unknown, out Input = unknown, out Internals ex
|
|
|
164
176
|
or<T extends core.SomeType>(option: T): KrustyUnion<[this, T], KInternals>;
|
|
165
177
|
and<T extends core.SomeType>(incoming: T): KrustyIntersection<this, T, KInternals>;
|
|
166
178
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): KrustyPipe<this, KrustyTransform<Awaited<NewOut>, core.output<this>>, KInternals>;
|
|
179
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
|
|
180
|
+
describe(description: string): this;
|
|
181
|
+
description?: string;
|
|
182
|
+
/** Returns the metadata associated with this instance in `z.globalRegistry` */
|
|
183
|
+
meta(): core.$replace<core.GlobalMeta, this> | undefined;
|
|
184
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
|
|
185
|
+
meta(data: core.$replace<core.GlobalMeta, this>): this;
|
|
167
186
|
}
|
|
168
187
|
declare const KrustyType: core.$constructor<_KrustyType>;
|
|
169
188
|
interface _KrustyString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>, K extends KrustyInternals = KrustyInternals> extends _KrustyType<T, K> {
|
|
@@ -234,14 +253,6 @@ interface KrustyString<K extends KrustyInternals = KrustyInternals> extends _Kru
|
|
|
234
253
|
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
235
254
|
/** @deprecated Use `z.e164()` instead. */
|
|
236
255
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
237
|
-
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
238
|
-
datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
|
|
239
|
-
/** @deprecated Use `z.iso.date()` instead. */
|
|
240
|
-
date(params?: string | core.$ZodCheckISODateParams): this;
|
|
241
|
-
/** @deprecated Use `z.iso.time()` instead. */
|
|
242
|
-
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
243
|
-
/** @deprecated Use `z.iso.duration()` instead. */
|
|
244
|
-
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
245
256
|
}
|
|
246
257
|
declare const KrustyString: core.$constructor<KrustyString>;
|
|
247
258
|
declare function string<K extends KrustyInternals = KrustyInternals>(params?: string | core.$ZodStringParams): KrustyString<K>;
|
|
@@ -486,7 +497,10 @@ interface _KrustyDate<T extends core.$ZodDateInternals = core.$ZodDateInternals,
|
|
|
486
497
|
interface KrustyDate<K extends KrustyInternals = KrustyInternals> extends _KrustyDate<core.$ZodDateInternals<Date>, K> {
|
|
487
498
|
}
|
|
488
499
|
declare const KrustyDate: core.$constructor<KrustyDate>;
|
|
489
|
-
|
|
500
|
+
type KrustyDateCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODate, KrustyDate, K>;
|
|
501
|
+
declare function date<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
502
|
+
type KrustyDateTimeCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODateTime, KrustyDate, K>;
|
|
503
|
+
declare function datetime<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateTimeParams)): KrustyDateTimeCodec<K>;
|
|
490
504
|
interface KrustyArray<T extends core.SomeType = core.$ZodType, K extends KrustyInternals = KrustyInternals> extends _KrustyType<core.$ZodArrayInternals<T>, K>, core.$ZodArray<T> {
|
|
491
505
|
element: T;
|
|
492
506
|
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
@@ -717,7 +731,8 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
717
731
|
union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): KrustyUnion<T, K>;
|
|
718
732
|
discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): KrustyDiscriminatedUnion<Types, Disc, K>;
|
|
719
733
|
object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): KrustyObject<core.util.Writeable<T>, core.$strip, K>;
|
|
720
|
-
date(params?: string | core.$ZodDateParams):
|
|
734
|
+
date(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
735
|
+
datetime(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateTimeCodec<K>;
|
|
721
736
|
any(): KrustyAny<K>;
|
|
722
737
|
unknown(): KrustyUnknown<K>;
|
|
723
738
|
never(params?: string | core.$ZodNeverParams): KrustyNever<K>;
|
|
@@ -725,5 +740,5 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
725
740
|
json(params?: string | core.$ZodCustomParams): KrustyJSONSchema<K>;
|
|
726
741
|
}
|
|
727
742
|
|
|
728
|
-
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
729
|
-
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
|
743
|
+
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
744
|
+
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyDateCodec, KrustyDateTimeCodec, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, ParseContext, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ declare const ZodRealError: core.$constructor<ZodError>;
|
|
|
26
26
|
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
|
27
27
|
type IssueData = core.$ZodRawIssue;
|
|
28
28
|
|
|
29
|
+
interface ParseContext extends core.ParseContextInternal<core.$ZodIssue> {
|
|
30
|
+
parseType?: 'query' | 'body' | 'path' | 'header' | 'output';
|
|
31
|
+
}
|
|
29
32
|
type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
|
|
30
33
|
type ZodSafeParseSuccess<T> = {
|
|
31
34
|
success: true;
|
|
@@ -37,24 +40,24 @@ type ZodSafeParseError<T> = {
|
|
|
37
40
|
data?: never;
|
|
38
41
|
error: ZodError<T>;
|
|
39
42
|
};
|
|
40
|
-
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
43
|
+
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
41
44
|
callee?: core.util.AnyFunc;
|
|
42
45
|
Err?: core.$ZodErrorClass;
|
|
43
46
|
}) => core.output<T>;
|
|
44
|
-
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
47
|
+
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
45
48
|
callee?: core.util.AnyFunc;
|
|
46
49
|
Err?: core.$ZodErrorClass;
|
|
47
50
|
}) => Promise<core.output<T>>;
|
|
48
|
-
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
49
|
-
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
50
|
-
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
51
|
-
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
52
|
-
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
53
|
-
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
54
|
-
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
55
|
-
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
56
|
-
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
57
|
-
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
51
|
+
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
52
|
+
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
53
|
+
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => core.input<T>;
|
|
54
|
+
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => core.output<T>;
|
|
55
|
+
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<core.input<T>>;
|
|
56
|
+
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<core.output<T>>;
|
|
57
|
+
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.input<T>>;
|
|
58
|
+
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
59
|
+
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.input<T>>>;
|
|
60
|
+
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
58
61
|
|
|
59
62
|
type IsGateEnabled = (gate: string) => boolean;
|
|
60
63
|
declare const gatingContext: AsyncLocalStorage<IsGateEnabled>;
|
|
@@ -76,6 +79,15 @@ interface KrustyGate<T extends core.SomeType = core.$ZodType, K extends KrustyIn
|
|
|
76
79
|
declare const KrustyGate: core.$constructor<KrustyGate>;
|
|
77
80
|
declare function gate<T extends core.SomeType, K extends KrustyInternals>(innerType: T, gateName: K['gateNames']): KrustyGate<T, K>;
|
|
78
81
|
|
|
82
|
+
interface KrustyISODateTime extends KrustyStringFormat {
|
|
83
|
+
_zod: core.$ZodISODateTimeInternals;
|
|
84
|
+
}
|
|
85
|
+
declare const KrustyISODateTime: core.$constructor<KrustyISODateTime>;
|
|
86
|
+
interface KrustyISODate extends KrustyStringFormat {
|
|
87
|
+
_zod: core.$ZodISODateInternals;
|
|
88
|
+
}
|
|
89
|
+
declare const KrustyISODate: core.$constructor<KrustyISODate>;
|
|
90
|
+
|
|
79
91
|
type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
|
80
92
|
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
|
81
93
|
};
|
|
@@ -164,6 +176,13 @@ interface KrustyType<out Output = unknown, out Input = unknown, out Internals ex
|
|
|
164
176
|
or<T extends core.SomeType>(option: T): KrustyUnion<[this, T], KInternals>;
|
|
165
177
|
and<T extends core.SomeType>(incoming: T): KrustyIntersection<this, T, KInternals>;
|
|
166
178
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): KrustyPipe<this, KrustyTransform<Awaited<NewOut>, core.output<this>>, KInternals>;
|
|
179
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
|
|
180
|
+
describe(description: string): this;
|
|
181
|
+
description?: string;
|
|
182
|
+
/** Returns the metadata associated with this instance in `z.globalRegistry` */
|
|
183
|
+
meta(): core.$replace<core.GlobalMeta, this> | undefined;
|
|
184
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
|
|
185
|
+
meta(data: core.$replace<core.GlobalMeta, this>): this;
|
|
167
186
|
}
|
|
168
187
|
declare const KrustyType: core.$constructor<_KrustyType>;
|
|
169
188
|
interface _KrustyString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>, K extends KrustyInternals = KrustyInternals> extends _KrustyType<T, K> {
|
|
@@ -234,14 +253,6 @@ interface KrustyString<K extends KrustyInternals = KrustyInternals> extends _Kru
|
|
|
234
253
|
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
235
254
|
/** @deprecated Use `z.e164()` instead. */
|
|
236
255
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
237
|
-
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
238
|
-
datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
|
|
239
|
-
/** @deprecated Use `z.iso.date()` instead. */
|
|
240
|
-
date(params?: string | core.$ZodCheckISODateParams): this;
|
|
241
|
-
/** @deprecated Use `z.iso.time()` instead. */
|
|
242
|
-
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
243
|
-
/** @deprecated Use `z.iso.duration()` instead. */
|
|
244
|
-
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
245
256
|
}
|
|
246
257
|
declare const KrustyString: core.$constructor<KrustyString>;
|
|
247
258
|
declare function string<K extends KrustyInternals = KrustyInternals>(params?: string | core.$ZodStringParams): KrustyString<K>;
|
|
@@ -486,7 +497,10 @@ interface _KrustyDate<T extends core.$ZodDateInternals = core.$ZodDateInternals,
|
|
|
486
497
|
interface KrustyDate<K extends KrustyInternals = KrustyInternals> extends _KrustyDate<core.$ZodDateInternals<Date>, K> {
|
|
487
498
|
}
|
|
488
499
|
declare const KrustyDate: core.$constructor<KrustyDate>;
|
|
489
|
-
|
|
500
|
+
type KrustyDateCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODate, KrustyDate, K>;
|
|
501
|
+
declare function date<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
502
|
+
type KrustyDateTimeCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODateTime, KrustyDate, K>;
|
|
503
|
+
declare function datetime<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateTimeParams)): KrustyDateTimeCodec<K>;
|
|
490
504
|
interface KrustyArray<T extends core.SomeType = core.$ZodType, K extends KrustyInternals = KrustyInternals> extends _KrustyType<core.$ZodArrayInternals<T>, K>, core.$ZodArray<T> {
|
|
491
505
|
element: T;
|
|
492
506
|
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
@@ -717,7 +731,8 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
717
731
|
union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): KrustyUnion<T, K>;
|
|
718
732
|
discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): KrustyDiscriminatedUnion<Types, Disc, K>;
|
|
719
733
|
object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): KrustyObject<core.util.Writeable<T>, core.$strip, K>;
|
|
720
|
-
date(params?: string | core.$ZodDateParams):
|
|
734
|
+
date(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
735
|
+
datetime(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateTimeCodec<K>;
|
|
721
736
|
any(): KrustyAny<K>;
|
|
722
737
|
unknown(): KrustyUnknown<K>;
|
|
723
738
|
never(params?: string | core.$ZodNeverParams): KrustyNever<K>;
|
|
@@ -725,5 +740,5 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
725
740
|
json(params?: string | core.$ZodCustomParams): KrustyJSONSchema<K>;
|
|
726
741
|
}
|
|
727
742
|
|
|
728
|
-
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
729
|
-
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
|
743
|
+
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
744
|
+
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyDateCodec, KrustyDateTimeCodec, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, ParseContext, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
package/dist/index.mjs
CHANGED
|
@@ -56,51 +56,6 @@ const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
|
|
56
56
|
const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
|
57
57
|
const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
|
58
58
|
|
|
59
|
-
const KrustyISODateTime = /* @__PURE__ */ core.$constructor(
|
|
60
|
-
"KrustyISODateTime",
|
|
61
|
-
(inst, def) => {
|
|
62
|
-
const coreInit = core.$ZodISODateTime.init;
|
|
63
|
-
coreInit(inst, def);
|
|
64
|
-
KrustyStringFormat.init(inst, def);
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
function datetime(params) {
|
|
68
|
-
return core._isoDateTime(KrustyISODateTime, params);
|
|
69
|
-
}
|
|
70
|
-
const KrustyISODate = /* @__PURE__ */ core.$constructor(
|
|
71
|
-
"KrustyISODate",
|
|
72
|
-
(inst, def) => {
|
|
73
|
-
const coreInit = core.$ZodISODate.init;
|
|
74
|
-
coreInit(inst, def);
|
|
75
|
-
KrustyStringFormat.init(inst, def);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
function date$1(params) {
|
|
79
|
-
return core._isoDate(KrustyISODate, params);
|
|
80
|
-
}
|
|
81
|
-
const KrustyISOTime = /* @__PURE__ */ core.$constructor(
|
|
82
|
-
"KrustyISOTime",
|
|
83
|
-
(inst, def) => {
|
|
84
|
-
const coreInit = core.$ZodISOTime.init;
|
|
85
|
-
coreInit(inst, def);
|
|
86
|
-
KrustyStringFormat.init(inst, def);
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
function time(params) {
|
|
90
|
-
return core._isoTime(KrustyISOTime, params);
|
|
91
|
-
}
|
|
92
|
-
const KrustyISODuration = /* @__PURE__ */ core.$constructor(
|
|
93
|
-
"KrustyISODuration",
|
|
94
|
-
(inst, def) => {
|
|
95
|
-
const coreInit = core.$ZodISODuration.init;
|
|
96
|
-
coreInit(inst, def);
|
|
97
|
-
KrustyStringFormat.init(inst, def);
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
function duration(params) {
|
|
101
|
-
return core._isoDuration(KrustyISODuration, params);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
59
|
const gatingContext = new AsyncLocalStorage();
|
|
105
60
|
function isGateIssueRaw(issue) {
|
|
106
61
|
return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof KrustyGate;
|
|
@@ -138,6 +93,29 @@ function gate(innerType, gateName) {
|
|
|
138
93
|
});
|
|
139
94
|
}
|
|
140
95
|
|
|
96
|
+
const KrustyISODateTime = /* @__PURE__ */ core.$constructor(
|
|
97
|
+
"KrustyISODateTime",
|
|
98
|
+
(inst, def) => {
|
|
99
|
+
const coreInit = core.$ZodISODateTime.init;
|
|
100
|
+
coreInit(inst, def);
|
|
101
|
+
KrustyStringFormat.init(inst, def);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
function datetime$1(params) {
|
|
105
|
+
return core._isoDateTime(KrustyISODateTime, params);
|
|
106
|
+
}
|
|
107
|
+
const KrustyISODate = /* @__PURE__ */ core.$constructor(
|
|
108
|
+
"KrustyISODate",
|
|
109
|
+
(inst, def) => {
|
|
110
|
+
const coreInit = core.$ZodISODate.init;
|
|
111
|
+
coreInit(inst, def);
|
|
112
|
+
KrustyStringFormat.init(inst, def);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
function date$1(params) {
|
|
116
|
+
return core._isoDate(KrustyISODate, params);
|
|
117
|
+
}
|
|
118
|
+
|
|
141
119
|
function handleGating(payload) {
|
|
142
120
|
for (let i = 0; i < payload.issues.length; i++) {
|
|
143
121
|
const issue = payload.issues[i];
|
|
@@ -280,6 +258,26 @@ const KrustyObject = /* @__PURE__ */ core.$constructor(
|
|
|
280
258
|
inst._zod.parse = (payload, ctx) => {
|
|
281
259
|
const input = payload.value;
|
|
282
260
|
const res = origParse(payload, ctx);
|
|
261
|
+
if (!def.catchall) {
|
|
262
|
+
const { parseType } = ctx;
|
|
263
|
+
if (parseType && parseType !== "output") {
|
|
264
|
+
const unrecognized = [];
|
|
265
|
+
const keySet = new Set(Object.keys(def.shape));
|
|
266
|
+
for (const key in input) {
|
|
267
|
+
if (!keySet.has(key)) {
|
|
268
|
+
unrecognized.push(key);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (unrecognized.length) {
|
|
272
|
+
payload.issues.push({
|
|
273
|
+
code: "unrecognized_keys",
|
|
274
|
+
keys: unrecognized,
|
|
275
|
+
input,
|
|
276
|
+
inst
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
283
281
|
if (res instanceof Promise) {
|
|
284
282
|
return res.then((r) => handleGating(input, r, ctx));
|
|
285
283
|
} else {
|
|
@@ -353,6 +351,25 @@ const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
|
353
351
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
354
352
|
inst.default = (def2) => _default(inst, def2);
|
|
355
353
|
inst.prefault = (def2) => prefault(inst, def2);
|
|
354
|
+
inst.describe = (description) => {
|
|
355
|
+
const cl = inst.clone();
|
|
356
|
+
core.globalRegistry.add(cl, { description });
|
|
357
|
+
return cl;
|
|
358
|
+
};
|
|
359
|
+
Object.defineProperty(inst, "description", {
|
|
360
|
+
get() {
|
|
361
|
+
return core.globalRegistry.get(inst)?.description;
|
|
362
|
+
},
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
inst.meta = (...args) => {
|
|
366
|
+
if (args.length === 0) {
|
|
367
|
+
return core.globalRegistry.get(inst);
|
|
368
|
+
}
|
|
369
|
+
const cl = inst.clone();
|
|
370
|
+
core.globalRegistry.add(cl, args[0]);
|
|
371
|
+
return cl;
|
|
372
|
+
};
|
|
356
373
|
return inst;
|
|
357
374
|
}
|
|
358
375
|
);
|
|
@@ -411,10 +428,6 @@ const KrustyString = /* @__PURE__ */ core.$constructor(
|
|
|
411
428
|
inst.cidrv4 = (params) => inst.check(core._cidrv4(KrustyCIDRv4, params));
|
|
412
429
|
inst.cidrv6 = (params) => inst.check(core._cidrv6(KrustyCIDRv6, params));
|
|
413
430
|
inst.e164 = (params) => inst.check(core._e164(KrustyE164, params));
|
|
414
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
415
|
-
inst.date = (params) => inst.check(date$1(params));
|
|
416
|
-
inst.time = (params) => inst.check(time(params));
|
|
417
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
418
431
|
}
|
|
419
432
|
);
|
|
420
433
|
function string(params) {
|
|
@@ -701,6 +714,17 @@ const KrustyNumber = /* @__PURE__ */ core.$constructor(
|
|
|
701
714
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
702
715
|
inst.isFinite = true;
|
|
703
716
|
inst.format = bag.format ?? null;
|
|
717
|
+
const origParse = inst._zod.parse;
|
|
718
|
+
inst._zod.parse = (payload, ctx) => {
|
|
719
|
+
const { parseType } = ctx;
|
|
720
|
+
if (parseType === "query" && typeof payload.value === "string") {
|
|
721
|
+
const value = Number(payload.value);
|
|
722
|
+
if (!Number.isNaN(value)) {
|
|
723
|
+
payload.value = value;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return origParse(payload, ctx);
|
|
727
|
+
};
|
|
704
728
|
}
|
|
705
729
|
);
|
|
706
730
|
function number(params) {
|
|
@@ -735,6 +759,28 @@ const KrustyBoolean = /* @__PURE__ */ core.$constructor(
|
|
|
735
759
|
const coreInit = core.$ZodBoolean.init;
|
|
736
760
|
coreInit(inst, def);
|
|
737
761
|
KrustyType.init(inst, def);
|
|
762
|
+
const origParse = inst._zod.parse;
|
|
763
|
+
inst._zod.parse = (payload, ctx) => {
|
|
764
|
+
const { parseType } = ctx;
|
|
765
|
+
if (parseType === "query") {
|
|
766
|
+
if (payload.value === "true") {
|
|
767
|
+
payload.value = true;
|
|
768
|
+
} else if (payload.value === "false") {
|
|
769
|
+
payload.value = false;
|
|
770
|
+
} else {
|
|
771
|
+
payload.issues.push({
|
|
772
|
+
code: "invalid_type",
|
|
773
|
+
expected: "boolean",
|
|
774
|
+
values: ["true", "false"],
|
|
775
|
+
input: payload.value,
|
|
776
|
+
inst,
|
|
777
|
+
continue: false
|
|
778
|
+
});
|
|
779
|
+
return payload;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return origParse(payload, ctx);
|
|
783
|
+
};
|
|
738
784
|
}
|
|
739
785
|
);
|
|
740
786
|
function boolean(params) {
|
|
@@ -873,7 +919,19 @@ const KrustyDate = /* @__PURE__ */ core.$constructor(
|
|
|
873
919
|
}
|
|
874
920
|
);
|
|
875
921
|
function date(params) {
|
|
876
|
-
return core._date(KrustyDate, params)
|
|
922
|
+
return codec(date$1(params), core._date(KrustyDate, params), {
|
|
923
|
+
encode: (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`,
|
|
924
|
+
decode: (isoString2) => {
|
|
925
|
+
const [y, m, d] = isoString2.split("-");
|
|
926
|
+
return new Date(Number(y), Number(m) - 1, Number(d));
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
function datetime(params) {
|
|
931
|
+
return codec(datetime$1(params), core._date(KrustyDate, params), {
|
|
932
|
+
encode: (date2) => date2.toISOString(),
|
|
933
|
+
decode: (isoString2) => new Date(isoString2)
|
|
934
|
+
});
|
|
877
935
|
}
|
|
878
936
|
const KrustyArray = /* @__PURE__ */ core.$constructor(
|
|
879
937
|
"KrustyArray",
|
|
@@ -1458,10 +1516,12 @@ class SchemaClass {
|
|
|
1458
1516
|
object(shape, params) {
|
|
1459
1517
|
return object(shape, params);
|
|
1460
1518
|
}
|
|
1461
|
-
// TODO: make this a codec?
|
|
1462
1519
|
date(params) {
|
|
1463
1520
|
return date(params);
|
|
1464
1521
|
}
|
|
1522
|
+
datetime(params) {
|
|
1523
|
+
return datetime(params);
|
|
1524
|
+
}
|
|
1465
1525
|
any() {
|
|
1466
1526
|
return any();
|
|
1467
1527
|
}
|
|
@@ -1562,4 +1622,4 @@ class SchemaClass {
|
|
|
1562
1622
|
*/
|
|
1563
1623
|
}
|
|
1564
1624
|
|
|
1565
|
-
export { KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
1625
|
+
export { KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/zod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
27
|
-
"@temporary-name/server": "1.9.3-alpha.
|
|
26
|
+
"@temporary-name/contract": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6",
|
|
27
|
+
"@temporary-name/server": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^4.1.11",
|
|
31
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
31
|
+
"@temporary-name/shared": "1.9.3-alpha.47c8371db8c45c361b1db0b785980cc77971e6e6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {},
|
|
34
34
|
"scripts": {
|