@temporary-name/zod 1.9.3-alpha.a252b3ff8cb6bf7deaa6d41dc9ac8a8d50edd80e → 1.9.3-alpha.a253b67a3639148c12f13a47295e1922182adecd

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.mjs CHANGED
@@ -1,955 +1,1624 @@
1
- import { custom, ZodFirstPartyTypeKind } from 'zod/v3';
2
- import wcmatch from 'wildcard-match';
3
- import { isObject, guard, toArray } from '@temporary-name/shared';
4
- import { JsonSchemaXNativeType } from '@temporary-name/json-schema';
5
- import { JSONSchemaFormat } from '@temporary-name/server/openapi';
6
- import escapeStringRegexp from 'escape-string-regexp';
1
+ import * as core from 'zod/v4/core';
2
+ import { $ZodError, util, _overwrite, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _gt, _gte, _lt, _lte, _multipleOf } from 'zod/v4/core';
3
+ export { core };
4
+ export { _endsWith as endsWith, _gt as gt, _gte as gte, _includes as includes, _length as length, _lowercase as lowercase, _lt as lt, _lte as lte, _maxLength as maxLength, _maxSize as maxSize, _mime as mime, _minLength as minLength, _minSize as minSize, _multipleOf as multipleOf, _negative as negative, _nonnegative as nonnegative, _nonpositive as nonpositive, _normalize as normalize, _overwrite as overwrite, _positive as positive, _property as property, _regex as regex, _size as size, _startsWith as startsWith, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _trim as trim, _uppercase as uppercase } from 'zod/v4/core';
5
+ import { AsyncLocalStorage } from 'node:async_hooks';
7
6
 
8
- const CUSTOM_JSON_SCHEMA_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA");
9
- const CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA_INPUT");
10
- const CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA_OUTPUT");
11
- function getCustomJsonSchema(def, options) {
12
- if (options.strategy === "input" && CUSTOM_JSON_SCHEMA_INPUT_SYMBOL in def) {
13
- return def[CUSTOM_JSON_SCHEMA_INPUT_SYMBOL];
14
- }
15
- if (options.strategy === "output" && CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL in def) {
16
- return def[CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL];
17
- }
18
- if (CUSTOM_JSON_SCHEMA_SYMBOL in def) {
19
- return def[CUSTOM_JSON_SCHEMA_SYMBOL];
20
- }
21
- return void 0;
22
- }
23
- function customJsonSchema(schema, custom, options = {}) {
24
- const SYMBOL = options.strategy === "input" ? CUSTOM_JSON_SCHEMA_INPUT_SYMBOL : options.strategy === "output" ? CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL : CUSTOM_JSON_SCHEMA_SYMBOL;
25
- const This = schema.constructor;
26
- const newSchema = new This({
27
- ...schema._def,
28
- [SYMBOL]: custom
7
+ const initializer = (inst, issues) => {
8
+ $ZodError.init(inst, issues);
9
+ inst.name = "ZodError";
10
+ Object.defineProperties(inst, {
11
+ format: {
12
+ value: (mapper) => core.formatError(inst, mapper)
13
+ // enumerable: false,
14
+ },
15
+ flatten: {
16
+ value: (mapper) => core.flattenError(inst, mapper)
17
+ // enumerable: false,
18
+ },
19
+ addIssue: {
20
+ value: (issue) => {
21
+ inst.issues.push(issue);
22
+ inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
23
+ }
24
+ // enumerable: false,
25
+ },
26
+ addIssues: {
27
+ value: (issues2) => {
28
+ inst.issues.push(...issues2);
29
+ inst.message = JSON.stringify(inst.issues, core.util.jsonStringifyReplacer, 2);
30
+ }
31
+ // enumerable: false,
32
+ },
33
+ isEmpty: {
34
+ get() {
35
+ return inst.issues.length === 0;
36
+ }
37
+ // enumerable: false,
38
+ }
29
39
  });
30
- return newSchema;
31
- }
40
+ };
41
+ const ZodError = core.$constructor("ZodError", initializer);
42
+ const ZodRealError = core.$constructor("ZodError", initializer, {
43
+ Parent: Error
44
+ });
32
45
 
33
- const CUSTOM_ZOD_DEF_SYMBOL = Symbol("ORPC_CUSTOM_ZOD_DEF");
34
- function setCustomZodDef(def, custom) {
35
- Object.assign(def, { [CUSTOM_ZOD_DEF_SYMBOL]: custom });
36
- }
37
- function getCustomZodDef(def) {
38
- return def[CUSTOM_ZOD_DEF_SYMBOL];
39
- }
40
- function composeParams(defaultMessage, params) {
41
- return (val) => {
42
- const message = defaultMessage(val);
43
- if (!params) {
44
- return {
45
- message
46
- };
47
- }
48
- if (typeof params === "function") {
49
- return {
50
- message,
51
- ...params(val)
52
- };
53
- }
54
- if (typeof params === "object") {
55
- return {
56
- message,
57
- ...params
58
- };
59
- }
60
- return {
61
- message: params
62
- };
63
- };
64
- }
46
+ const parse = /* @__PURE__ */ core._parse(ZodRealError);
47
+ const parseAsync = /* @__PURE__ */ core._parseAsync(ZodRealError);
48
+ const safeParse = /* @__PURE__ */ core._safeParse(ZodRealError);
49
+ const safeParseAsync = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
50
+ const encode = /* @__PURE__ */ core._encode(ZodRealError);
51
+ const decode = /* @__PURE__ */ core._decode(ZodRealError);
52
+ const encodeAsync = /* @__PURE__ */ core._encodeAsync(ZodRealError);
53
+ const decodeAsync = /* @__PURE__ */ core._decodeAsync(ZodRealError);
54
+ const safeEncode = /* @__PURE__ */ core._safeEncode(ZodRealError);
55
+ const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
56
+ const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
57
+ const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
65
58
 
66
- function blob(params) {
67
- const schema = custom(
68
- (val) => val instanceof Blob,
69
- composeParams(
70
- () => "Input is not a blob",
71
- params
72
- )
73
- );
74
- setCustomZodDef(schema._def, { type: "blob" });
75
- return schema;
59
+ const gatingContext = new AsyncLocalStorage();
60
+ function isGateIssueRaw(issue) {
61
+ return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof KrustyGate;
76
62
  }
77
-
78
- function file(params) {
79
- const schema = custom(
80
- (val) => val instanceof File,
81
- composeParams(
82
- () => "Input is not a file",
83
- params
84
- )
85
- );
86
- setCustomZodDef(schema._def, { type: "file" });
87
- return Object.assign(schema, {
88
- type: (mimeType, params2) => {
89
- const isMatch = wcmatch(mimeType);
90
- const refinedSchema = schema.refine(
91
- (val) => isMatch(val.type.split(";")[0]),
92
- composeParams(
93
- (val) => `Expected a file of type ${mimeType} but got a file of type ${val.type || "unknown"}`,
94
- params2
95
- )
96
- );
97
- setCustomZodDef(refinedSchema._def, { type: "file", mimeType });
98
- return refinedSchema;
99
- }
63
+ function isGateIssue(issue) {
64
+ return issue.code === "invalid_type" && issue.expected === "never" && issue.path?.length === 0;
65
+ }
66
+ const KrustyGate = /* @__PURE__ */ core.$constructor(
67
+ "KrustyGate",
68
+ (inst, def) => {
69
+ const coreInit = core.$ZodOptional.init;
70
+ coreInit(inst, def);
71
+ KrustyType.init(inst, def);
72
+ inst._zod.parse = (payload, ctx) => {
73
+ const gateEnabled = gatingContext.getStore()?.(def.gateName);
74
+ if (gateEnabled) {
75
+ return def.innerType._zod.run(payload, ctx);
76
+ } else if (payload.value !== void 0) {
77
+ payload.issues.push({
78
+ expected: "never",
79
+ code: "invalid_type",
80
+ input: payload.value,
81
+ inst
82
+ });
83
+ }
84
+ return payload;
85
+ };
86
+ }
87
+ );
88
+ function gate(innerType, gateName) {
89
+ return new KrustyGate({
90
+ type: "optional",
91
+ innerType,
92
+ gateName
100
93
  });
101
94
  }
102
95
 
103
- function regexp(params) {
104
- const schema = custom(
105
- (val) => val instanceof RegExp,
106
- composeParams(
107
- () => "Input is not a regexp",
108
- params
109
- )
110
- );
111
- setCustomZodDef(schema._def, { type: "regexp" });
112
- return schema;
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);
113
106
  }
114
-
115
- function url(params) {
116
- const schema = custom(
117
- (val) => val instanceof URL,
118
- composeParams(
119
- () => "Input is not a URL",
120
- params
121
- )
122
- );
123
- setCustomZodDef(schema._def, { type: "url" });
124
- return schema;
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);
125
117
  }
126
118
 
127
- class ZodSmartCoercionPlugin {
128
- init(options) {
129
- options.clientInterceptors ??= [];
130
- options.clientInterceptors.unshift((options2) => {
131
- const inputSchema = options2.procedure["~orpc"].inputSchema;
132
- if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || "_zod" in inputSchema) {
133
- return options2.next();
134
- }
135
- const coercedInput = zodCoerceInternal(inputSchema, options2.input);
136
- return options2.next({ ...options2, input: coercedInput });
137
- });
119
+ function handleGating(payload) {
120
+ for (let i = 0; i < payload.issues.length; i++) {
121
+ const issue = payload.issues[i];
122
+ if (issue?.code === "invalid_union") {
123
+ const newErrors = issue.errors.filter((innerIssues) => !innerIssues.some(isGateIssue));
124
+ issue.errors.splice(0, Infinity, ...newErrors);
125
+ }
138
126
  }
127
+ return payload;
139
128
  }
140
- function zodCoerceInternal(schema, value) {
141
- const customZodDef = getCustomZodDef(schema._def);
142
- switch (customZodDef?.type) {
143
- case "regexp": {
144
- if (typeof value === "string") {
145
- return safeToRegExp(value);
129
+ const KrustyUnion = /* @__PURE__ */ core.$constructor(
130
+ "KrustyUnion",
131
+ (inst, def) => {
132
+ const coreInit = core.$ZodUnion.init;
133
+ coreInit(inst, def);
134
+ KrustyType.init(inst, def);
135
+ inst.options = def.options;
136
+ const origParse = inst._zod.parse;
137
+ inst._zod.parse = (payload, ctx) => {
138
+ const res = origParse(payload, ctx);
139
+ if (res instanceof Promise) {
140
+ return res.then((r) => handleGating(r));
141
+ } else {
142
+ return handleGating(res);
146
143
  }
147
- return value;
148
- }
149
- case "url": {
150
- if (typeof value === "string") {
151
- return safeToURL(value);
152
- }
153
- return value;
154
- }
144
+ };
155
145
  }
156
- const typeName = schema._def.typeName;
157
- switch (typeName) {
158
- case ZodFirstPartyTypeKind.ZodNumber: {
159
- if (typeof value === "string") {
160
- return safeToNumber(value);
161
- }
162
- return value;
163
- }
164
- case ZodFirstPartyTypeKind.ZodBigInt: {
165
- if (typeof value === "string") {
166
- return safeToBigInt(value);
167
- }
168
- return value;
169
- }
170
- case ZodFirstPartyTypeKind.ZodBoolean: {
171
- if (typeof value === "string") {
172
- return safeToBoolean(value);
173
- }
174
- return value;
175
- }
176
- case ZodFirstPartyTypeKind.ZodDate: {
177
- if (typeof value === "string") {
178
- return safeToDate(value);
179
- }
180
- return value;
146
+ );
147
+ function union(options, params) {
148
+ return new KrustyUnion({
149
+ type: "union",
150
+ options,
151
+ ...util.normalizeParams(params)
152
+ });
153
+ }
154
+ const KrustyDiscriminatedUnion = /* @__PURE__ */ core.$constructor("KrustyDiscriminatedUnion", (inst, def) => {
155
+ KrustyUnion.init(inst, def);
156
+ const coreInit = core.$ZodDiscriminatedUnion.init;
157
+ coreInit(inst, def);
158
+ });
159
+ function discriminatedUnion(discriminator, options, params) {
160
+ return new KrustyDiscriminatedUnion({
161
+ type: "union",
162
+ options,
163
+ discriminator,
164
+ ...util.normalizeParams(params)
165
+ });
166
+ }
167
+
168
+ function handlePropertyResult(result, final, key, input) {
169
+ if (result.issues.length) {
170
+ final.issues.push(...util.prefixIssues(key, result.issues));
171
+ }
172
+ if (result.value === void 0) {
173
+ if (key in input) {
174
+ final.value[key] = void 0;
181
175
  }
182
- case ZodFirstPartyTypeKind.ZodLiteral: {
183
- const schema_ = schema;
184
- const expectedValue = schema_._def.value;
185
- if (typeof value === "string" && typeof expectedValue !== "string") {
186
- if (typeof expectedValue === "bigint") {
187
- return safeToBigInt(value);
188
- } else if (typeof expectedValue === "number") {
189
- return safeToNumber(value);
190
- } else if (typeof expectedValue === "boolean") {
191
- return safeToBoolean(value);
176
+ } else {
177
+ final.value[key] = result.value;
178
+ }
179
+ }
180
+ const KrustyObject = /* @__PURE__ */ core.$constructor(
181
+ "KrustyObject",
182
+ (inst, def) => {
183
+ const coreInit = core.$ZodObjectJIT.init;
184
+ coreInit(inst, def);
185
+ KrustyType.init(inst, def);
186
+ util.defineLazy(inst, "shape", () => {
187
+ return def.shape;
188
+ });
189
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
190
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
191
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
192
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
193
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
194
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
195
+ inst.extend = (incoming) => {
196
+ return util.extend(inst, incoming);
197
+ };
198
+ inst.safeExtend = (incoming) => {
199
+ return util.safeExtend(inst, incoming);
200
+ };
201
+ inst.merge = (other) => util.merge(inst, other);
202
+ inst.pick = (mask) => util.pick(inst, mask);
203
+ inst.omit = (mask) => util.omit(inst, mask);
204
+ inst.partial = (...args) => util.partial(KrustyOptional, inst, args[0]);
205
+ inst.required = (...args) => util.required(KrustyNonOptional, inst, args[0]);
206
+ function handleGating(input, payload, ctx) {
207
+ const _catchall = def.catchall?._zod;
208
+ const t = _catchall?.def.type;
209
+ let newIssues = null;
210
+ const proms = [];
211
+ const newUnrecognizedKeys = [];
212
+ for (let i = 0; i < payload.issues.length; i++) {
213
+ const issue = payload.issues[i];
214
+ if (!isGateIssueRaw(issue)) {
215
+ continue;
192
216
  }
193
- }
194
- return value;
195
- }
196
- case ZodFirstPartyTypeKind.ZodNativeEnum: {
197
- const schema_ = schema;
198
- if (Object.values(schema_._def.values).includes(value)) {
199
- return value;
200
- }
201
- if (typeof value === "string") {
202
- for (const expectedValue of Object.values(schema_._def.values)) {
203
- if (expectedValue.toString() === value) {
204
- return expectedValue;
217
+ newIssues ??= [...payload.issues];
218
+ newIssues[i] = null;
219
+ const key = issue.path[0];
220
+ if (!_catchall) {
221
+ delete payload.value[key];
222
+ } else if (t === "never") {
223
+ newUnrecognizedKeys.push(key);
224
+ } else {
225
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
226
+ if (r instanceof Promise) {
227
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
228
+ } else {
229
+ handlePropertyResult(r, payload, key, input);
205
230
  }
206
231
  }
207
232
  }
208
- return value;
209
- }
210
- case ZodFirstPartyTypeKind.ZodObject: {
211
- const schema_ = schema;
212
- if (isObject(value)) {
213
- const newObj = {};
214
- const keys = /* @__PURE__ */ new Set([...Object.keys(value), ...Object.keys(schema_.shape)]);
215
- for (const k of keys) {
216
- newObj[k] = zodCoerceInternal(schema_.shape[k] ?? schema_._def.catchall, value[k]);
217
- }
218
- return newObj;
219
- }
220
- return value;
221
- }
222
- case ZodFirstPartyTypeKind.ZodRecord: {
223
- const schema_ = schema;
224
- if (isObject(value)) {
225
- const newObj = {};
226
- for (const [k, v] of Object.entries(value)) {
227
- const key = zodCoerceInternal(schema_._def.keyType, k);
228
- const val = zodCoerceInternal(schema_._def.valueType, v);
229
- newObj[key] = val;
230
- }
231
- return newObj;
232
- }
233
- return value;
234
- }
235
- case ZodFirstPartyTypeKind.ZodArray: {
236
- const schema_ = schema;
237
- if (Array.isArray(value)) {
238
- return value.map((v) => zodCoerceInternal(schema_._def.type, v));
233
+ if (newIssues) {
234
+ payload.issues = newIssues.filter(Boolean);
239
235
  }
240
- return value;
241
- }
242
- case ZodFirstPartyTypeKind.ZodTuple: {
243
- const schema_ = schema;
244
- if (Array.isArray(value)) {
245
- return value.map((v, i) => {
246
- const s = schema_._def.items[i] ?? schema_._def.rest;
247
- return s ? zodCoerceInternal(s, v) : v;
248
- });
249
- }
250
- return value;
251
- }
252
- case ZodFirstPartyTypeKind.ZodSet: {
253
- const schema_ = schema;
254
- if (Array.isArray(value)) {
255
- return new Set(value.map((v) => zodCoerceInternal(schema_._def.valueType, v)));
256
- }
257
- return value;
258
- }
259
- case ZodFirstPartyTypeKind.ZodMap: {
260
- const schema_ = schema;
261
- if (Array.isArray(value) && value.every((i) => Array.isArray(i) && i.length === 2)) {
262
- return new Map(
263
- value.map(([k, v]) => [
264
- zodCoerceInternal(schema_._def.keyType, k),
265
- zodCoerceInternal(schema_._def.valueType, v)
266
- ])
236
+ if (newUnrecognizedKeys.length > 0) {
237
+ const missingKeyIssue = payload.issues.find(
238
+ (issue) => issue.code === "unrecognized_keys" && !issue.path
267
239
  );
268
- }
269
- return value;
270
- }
271
- case ZodFirstPartyTypeKind.ZodUnion:
272
- case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
273
- const schema_ = schema;
274
- if (schema_.safeParse(value).success) {
275
- return value;
276
- }
277
- const results = [];
278
- for (const s of schema_._def.options) {
279
- const newValue = zodCoerceInternal(s, value);
280
- const result = schema_.safeParse(newValue);
281
- if (result.success) {
282
- return newValue;
240
+ if (missingKeyIssue) {
241
+ missingKeyIssue.keys.push(...newUnrecognizedKeys);
242
+ } else {
243
+ payload.issues.push({
244
+ code: "unrecognized_keys",
245
+ keys: newUnrecognizedKeys,
246
+ input,
247
+ inst
248
+ });
283
249
  }
284
- results.push([newValue, result.error.issues.length]);
285
250
  }
286
- if (results.length === 0) {
287
- return value;
251
+ if (proms.length > 0) {
252
+ return Promise.all(proms).then(() => payload);
253
+ } else {
254
+ return payload;
288
255
  }
289
- return results.sort((a, b) => a[1] - b[1])[0][0];
290
- }
291
- case ZodFirstPartyTypeKind.ZodIntersection: {
292
- const schema_ = schema;
293
- return zodCoerceInternal(schema_._def.right, zodCoerceInternal(schema_._def.left, value));
294
- }
295
- case ZodFirstPartyTypeKind.ZodReadonly: {
296
- const schema_ = schema;
297
- return zodCoerceInternal(schema_._def.innerType, value);
298
- }
299
- case ZodFirstPartyTypeKind.ZodPipeline: {
300
- const schema_ = schema;
301
- return zodCoerceInternal(schema_._def.in, value);
302
- }
303
- case ZodFirstPartyTypeKind.ZodEffects: {
304
- const schema_ = schema;
305
- return zodCoerceInternal(schema_._def.schema, value);
306
256
  }
307
- case ZodFirstPartyTypeKind.ZodBranded: {
308
- const schema_ = schema;
309
- return zodCoerceInternal(schema_._def.type, value);
310
- }
311
- case ZodFirstPartyTypeKind.ZodCatch: {
312
- const schema_ = schema;
313
- return zodCoerceInternal(schema_._def.innerType, value);
314
- }
315
- case ZodFirstPartyTypeKind.ZodDefault: {
316
- const schema_ = schema;
317
- return zodCoerceInternal(schema_._def.innerType, value);
318
- }
319
- case ZodFirstPartyTypeKind.ZodNullable: {
320
- if (value === null) {
321
- return null;
257
+ const origParse = inst._zod.parse;
258
+ inst._zod.parse = (payload, ctx) => {
259
+ const input = payload.value;
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
+ }
322
280
  }
323
- const schema_ = schema;
324
- return zodCoerceInternal(schema_._def.innerType, value);
325
- }
326
- case ZodFirstPartyTypeKind.ZodOptional: {
327
- if (value === void 0) {
328
- return void 0;
281
+ if (res instanceof Promise) {
282
+ return res.then((r) => handleGating(input, r, ctx));
283
+ } else {
284
+ return handleGating(input, res, ctx);
329
285
  }
330
- const schema_ = schema;
331
- return zodCoerceInternal(schema_._def.innerType, value);
332
- }
333
- case ZodFirstPartyTypeKind.ZodLazy: {
334
- const schema_ = schema;
335
- if (value !== void 0) {
336
- return zodCoerceInternal(schema_._def.getter(), value);
286
+ };
287
+ }
288
+ );
289
+ function object(shape, params) {
290
+ const def = {
291
+ type: "object",
292
+ shape: shape ?? {},
293
+ ...util.normalizeParams(params)
294
+ };
295
+ return new KrustyObject(def);
296
+ }
297
+ function strictObject(shape, params) {
298
+ return new KrustyObject({
299
+ type: "object",
300
+ shape,
301
+ catchall: never(),
302
+ ...util.normalizeParams(params)
303
+ });
304
+ }
305
+ function looseObject(shape, params) {
306
+ return new KrustyObject({
307
+ type: "object",
308
+ shape,
309
+ catchall: unknown(),
310
+ ...util.normalizeParams(params)
311
+ });
312
+ }
313
+
314
+ const KrustyType = /* @__PURE__ */ core.$constructor(
315
+ "KrustyType",
316
+ (inst, def) => {
317
+ const coreInit = core.$ZodType.init;
318
+ coreInit(inst, def);
319
+ inst.def = def;
320
+ inst.type = def.type;
321
+ Object.defineProperty(inst, "_def", { value: def });
322
+ inst.check = (...checks2) => {
323
+ return inst.clone(
324
+ util.mergeDefs(def, {
325
+ checks: [
326
+ ...def.checks ?? [],
327
+ ...checks2.map(
328
+ (ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
329
+ )
330
+ ]
331
+ })
332
+ );
333
+ };
334
+ inst.clone = (def2, params) => core.clone(inst, def2, params);
335
+ inst.brand = () => inst;
336
+ inst.register = ((reg, meta) => {
337
+ reg.add(inst, meta);
338
+ return inst;
339
+ });
340
+ inst.refine = (check2, params) => inst.check(refine(check2, params));
341
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
342
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
343
+ inst.gate = (gateName) => gate(inst, gateName);
344
+ inst.optional = () => optional(inst);
345
+ inst.nullable = () => nullable(inst);
346
+ inst.nullish = () => optional(nullable(inst));
347
+ inst.nonoptional = (params) => nonoptional(inst, params);
348
+ inst.array = () => array(inst);
349
+ inst.or = (arg) => union([inst, arg]);
350
+ inst.and = (arg) => intersection(inst, arg);
351
+ inst.transform = (tx) => pipe(inst, transform(tx));
352
+ inst.default = (def2) => _default(inst, def2);
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);
337
368
  }
338
- return value;
339
- }
369
+ const cl = inst.clone();
370
+ core.globalRegistry.add(cl, args[0]);
371
+ return cl;
372
+ };
373
+ return inst;
374
+ }
375
+ );
376
+ const _KrustyString = /* @__PURE__ */ core.$constructor(
377
+ "_KrustyString",
378
+ (inst, def) => {
379
+ const coreInit = core.$ZodString.init;
380
+ coreInit(inst, def);
381
+ KrustyType.init(inst, def);
382
+ const bag = inst._zod.bag;
383
+ inst.format = bag.format ?? null;
384
+ inst.minLength = bag.minimum ?? null;
385
+ inst.maxLength = bag.maximum ?? null;
386
+ inst.regex = (...args) => inst.check(_regex(...args));
387
+ inst.includes = (...args) => inst.check(_includes(...args));
388
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
389
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
390
+ inst.min = (...args) => inst.check(_minLength(...args));
391
+ inst.max = (...args) => inst.check(_maxLength(...args));
392
+ inst.length = (...args) => inst.check(_length(...args));
393
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
394
+ inst.lowercase = (params) => inst.check(_lowercase(params));
395
+ inst.uppercase = (params) => inst.check(_uppercase(params));
396
+ inst.trim = () => inst.check(_trim());
397
+ inst.normalize = (...args) => inst.check(_normalize(...args));
398
+ inst.toLowerCase = () => inst.check(_toLowerCase());
399
+ inst.toUpperCase = () => inst.check(_toUpperCase());
340
400
  }
341
- return value;
401
+ );
402
+ const KrustyString = /* @__PURE__ */ core.$constructor(
403
+ "KrustyString",
404
+ (inst, def) => {
405
+ const coreInit = core.$ZodString.init;
406
+ coreInit(inst, def);
407
+ _KrustyString.init(inst, def);
408
+ inst.email = (params) => inst.check(core._email(KrustyEmail, params));
409
+ inst.url = (params) => inst.check(core._url(KrustyURL, params));
410
+ inst.jwt = (params) => inst.check(core._jwt(KrustyJWT, params));
411
+ inst.emoji = (params) => inst.check(core._emoji(KrustyEmoji, params));
412
+ inst.guid = (params) => inst.check(core._guid(KrustyGUID, params));
413
+ inst.uuid = (params) => inst.check(core._uuid(KrustyUUID, params));
414
+ inst.uuidv4 = (params) => inst.check(core._uuidv4(KrustyUUID, params));
415
+ inst.uuidv6 = (params) => inst.check(core._uuidv6(KrustyUUID, params));
416
+ inst.uuidv7 = (params) => inst.check(core._uuidv7(KrustyUUID, params));
417
+ inst.nanoid = (params) => inst.check(core._nanoid(KrustyNanoID, params));
418
+ inst.guid = (params) => inst.check(core._guid(KrustyGUID, params));
419
+ inst.cuid = (params) => inst.check(core._cuid(KrustyCUID, params));
420
+ inst.cuid2 = (params) => inst.check(core._cuid2(KrustyCUID2, params));
421
+ inst.ulid = (params) => inst.check(core._ulid(KrustyULID, params));
422
+ inst.base64 = (params) => inst.check(core._base64(KrustyBase64, params));
423
+ inst.base64url = (params) => inst.check(core._base64url(KrustyBase64URL, params));
424
+ inst.xid = (params) => inst.check(core._xid(KrustyXID, params));
425
+ inst.ksuid = (params) => inst.check(core._ksuid(KrustyKSUID, params));
426
+ inst.ipv4 = (params) => inst.check(core._ipv4(KrustyIPv4, params));
427
+ inst.ipv6 = (params) => inst.check(core._ipv6(KrustyIPv6, params));
428
+ inst.cidrv4 = (params) => inst.check(core._cidrv4(KrustyCIDRv4, params));
429
+ inst.cidrv6 = (params) => inst.check(core._cidrv6(KrustyCIDRv6, params));
430
+ inst.e164 = (params) => inst.check(core._e164(KrustyE164, params));
431
+ }
432
+ );
433
+ function string(params) {
434
+ return core._string(KrustyString, params);
342
435
  }
343
- function safeToBigInt(value) {
344
- return guard(() => BigInt(value)) ?? value;
436
+ const KrustyStringFormat = /* @__PURE__ */ core.$constructor(
437
+ "KrustyStringFormat",
438
+ (inst, def) => {
439
+ const coreInit = core.$ZodStringFormat.init;
440
+ coreInit(inst, def);
441
+ _KrustyString.init(inst, def);
442
+ }
443
+ );
444
+ const KrustyEmail = /* @__PURE__ */ core.$constructor(
445
+ "KrustyEmail",
446
+ (inst, def) => {
447
+ const coreInit = core.$ZodEmail.init;
448
+ coreInit(inst, def);
449
+ KrustyStringFormat.init(inst, def);
450
+ }
451
+ );
452
+ function email(params) {
453
+ return core._email(KrustyEmail, params);
345
454
  }
346
- function safeToNumber(value) {
347
- const num = Number(value);
348
- return Number.isNaN(num) || num.toString() !== value ? value : num;
455
+ const KrustyGUID = /* @__PURE__ */ core.$constructor(
456
+ "KrustyGUID",
457
+ (inst, def) => {
458
+ const coreInit = core.$ZodGUID.init;
459
+ coreInit(inst, def);
460
+ KrustyStringFormat.init(inst, def);
461
+ }
462
+ );
463
+ function guid(params) {
464
+ return core._guid(KrustyGUID, params);
349
465
  }
350
- function safeToBoolean(value) {
351
- const lower = value.toLowerCase();
352
- if (lower === "false" || lower === "off" || lower === "f") {
353
- return false;
466
+ const KrustyUUID = /* @__PURE__ */ core.$constructor(
467
+ "KrustyUUID",
468
+ (inst, def) => {
469
+ const coreInit = core.$ZodUUID.init;
470
+ coreInit(inst, def);
471
+ KrustyStringFormat.init(inst, def);
354
472
  }
355
- if (lower === "true" || lower === "on" || lower === "t") {
356
- return true;
473
+ );
474
+ function uuid(params) {
475
+ return core._uuid(KrustyUUID, params);
476
+ }
477
+ function uuidv4(params) {
478
+ return core._uuidv4(KrustyUUID, params);
479
+ }
480
+ function uuidv6(params) {
481
+ return core._uuidv6(KrustyUUID, params);
482
+ }
483
+ function uuidv7(params) {
484
+ return core._uuidv7(KrustyUUID, params);
485
+ }
486
+ const KrustyURL = /* @__PURE__ */ core.$constructor(
487
+ "KrustyURL",
488
+ (inst, def) => {
489
+ const coreInit = core.$ZodURL.init;
490
+ coreInit(inst, def);
491
+ KrustyStringFormat.init(inst, def);
357
492
  }
358
- return value;
493
+ );
494
+ function url(params) {
495
+ return core._url(KrustyURL, params);
359
496
  }
360
- function safeToRegExp(value) {
361
- if (value.startsWith("/")) {
362
- const match = value.match(/^\/(.*)\/([a-z]*)$/);
363
- if (match) {
364
- const [, pattern, flags] = match;
365
- return new RegExp(pattern, flags);
366
- }
497
+ function httpUrl(params) {
498
+ return core._url(KrustyURL, {
499
+ protocol: /^https?$/,
500
+ hostname: core.regexes.domain,
501
+ ...util.normalizeParams(params)
502
+ });
503
+ }
504
+ const KrustyEmoji = /* @__PURE__ */ core.$constructor(
505
+ "KrustyEmoji",
506
+ (inst, def) => {
507
+ const coreInit = core.$ZodEmoji.init;
508
+ coreInit(inst, def);
509
+ KrustyStringFormat.init(inst, def);
367
510
  }
368
- return value;
511
+ );
512
+ function emoji(params) {
513
+ return core._emoji(KrustyEmoji, params);
369
514
  }
370
- function safeToURL(value) {
371
- return guard(() => new URL(value)) ?? value;
515
+ const KrustyNanoID = /* @__PURE__ */ core.$constructor(
516
+ "KrustyNanoID",
517
+ (inst, def) => {
518
+ const coreInit = core.$ZodNanoID.init;
519
+ coreInit(inst, def);
520
+ KrustyStringFormat.init(inst, def);
521
+ }
522
+ );
523
+ function nanoid(params) {
524
+ return core._nanoid(KrustyNanoID, params);
372
525
  }
373
- function safeToDate(value) {
374
- const date = new Date(value);
375
- if (!Number.isNaN(date.getTime()) && date.toISOString().startsWith(value)) {
376
- return date;
526
+ const KrustyCUID = /* @__PURE__ */ core.$constructor(
527
+ "KrustyCUID",
528
+ (inst, def) => {
529
+ const coreInit = core.$ZodCUID.init;
530
+ coreInit(inst, def);
531
+ KrustyStringFormat.init(inst, def);
377
532
  }
378
- return value;
533
+ );
534
+ function cuid(params) {
535
+ return core._cuid(KrustyCUID, params);
379
536
  }
380
-
381
- class ZodToJsonSchemaConverter {
382
- maxLazyDepth;
383
- maxStructureDepth;
384
- unsupportedJsonSchema;
385
- anyJsonSchema;
386
- constructor(options = {}) {
387
- this.maxLazyDepth = options.maxLazyDepth ?? 3;
388
- this.maxStructureDepth = options.maxStructureDepth ?? 10;
389
- this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
390
- this.anyJsonSchema = options.anyJsonSchema ?? {};
391
- }
392
- condition(schema) {
393
- return schema !== void 0 && schema["~standard"].vendor === "zod" && !("_zod" in schema);
394
- }
395
- convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
396
- const def = schema._def;
397
- if (structureDepth > this.maxStructureDepth) {
398
- return [false, this.anyJsonSchema];
399
- }
400
- if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
401
- const components = toArray(options.components);
402
- for (const component of components) {
403
- if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
404
- return [component.required, { $ref: component.ref }];
405
- }
406
- }
407
- }
408
- if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
409
- const [required, json] = this.convert(
410
- schema,
411
- options,
412
- lazyDepth,
413
- isHandledCustomJSONSchema,
414
- true,
415
- structureDepth
416
- );
417
- return [required, { ...json, description: def.description }];
418
- }
419
- if (!isHandledCustomJSONSchema) {
420
- const customJSONSchema = getCustomJsonSchema(def, options);
421
- if (customJSONSchema) {
422
- const [required, json] = this.convert(
423
- schema,
424
- options,
425
- lazyDepth,
426
- true,
427
- isHandledZodDescription,
428
- structureDepth
429
- );
430
- return [required, { ...json, ...customJSONSchema }];
431
- }
432
- }
433
- const customSchema = this.#handleCustomZodDef(def);
434
- if (customSchema) {
435
- return [true, customSchema];
436
- }
437
- const typeName = this.#getZodTypeName(def);
438
- switch (typeName) {
439
- case ZodFirstPartyTypeKind.ZodString: {
440
- const schema_ = schema;
441
- const json = { type: "string" };
442
- for (const check of schema_._def.checks) {
443
- switch (check.kind) {
444
- case "base64":
445
- json.contentEncoding = "base64";
446
- break;
447
- case "cuid":
448
- json.pattern = "^[0-9A-HJKMNP-TV-Z]{26}$";
449
- break;
450
- case "email":
451
- json.format = JSONSchemaFormat.Email;
452
- break;
453
- case "url":
454
- json.format = JSONSchemaFormat.URI;
455
- break;
456
- case "uuid":
457
- json.format = JSONSchemaFormat.UUID;
458
- break;
459
- case "regex":
460
- json.pattern = check.regex.source;
461
- break;
462
- case "min":
463
- json.minLength = check.value;
464
- break;
465
- case "max":
466
- json.maxLength = check.value;
467
- break;
468
- case "length":
469
- json.minLength = check.value;
470
- json.maxLength = check.value;
471
- break;
472
- case "includes":
473
- json.pattern = escapeStringRegexp(check.value);
474
- break;
475
- case "startsWith":
476
- json.pattern = `^${escapeStringRegexp(check.value)}`;
477
- break;
478
- case "endsWith":
479
- json.pattern = `${escapeStringRegexp(check.value)}$`;
480
- break;
481
- case "emoji":
482
- json.pattern = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
483
- break;
484
- case "nanoid":
485
- json.pattern = "^[a-zA-Z0-9_-]{21}$";
486
- break;
487
- case "cuid2":
488
- json.pattern = "^[0-9a-z]+$";
489
- break;
490
- case "ulid":
491
- json.pattern = "^[0-9A-HJKMNP-TV-Z]{26}$";
492
- break;
493
- case "datetime":
494
- json.format = JSONSchemaFormat.DateTime;
495
- break;
496
- case "date":
497
- json.format = JSONSchemaFormat.Date;
498
- break;
499
- case "time":
500
- json.format = JSONSchemaFormat.Time;
501
- break;
502
- case "duration":
503
- json.format = JSONSchemaFormat.Duration;
504
- break;
505
- case "ip": {
506
- if (check.version === "v4") {
507
- json.format = JSONSchemaFormat.IPv4;
508
- } else if (check.version === "v6") {
509
- json.format = JSONSchemaFormat.IPv6;
510
- } else {
511
- json.anyOf = [{ format: JSONSchemaFormat.IPv4 }, { format: JSONSchemaFormat.IPv6 }];
512
- }
513
- break;
514
- }
515
- case "jwt":
516
- json.pattern = "^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$";
517
- break;
518
- case "base64url":
519
- json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
520
- break;
521
- default: {
522
- check.kind;
523
- }
524
- }
525
- }
526
- return [true, json];
527
- }
528
- case ZodFirstPartyTypeKind.ZodNumber: {
529
- const schema_ = schema;
530
- const json = { type: "number" };
531
- for (const check of schema_._def.checks) {
532
- switch (check.kind) {
533
- case "int":
534
- json.type = "integer";
535
- break;
536
- case "min":
537
- json.minimum = check.value;
538
- break;
539
- case "max":
540
- json.maximum = check.value;
541
- break;
542
- case "multipleOf":
543
- json.multipleOf = check.value;
544
- break;
545
- default: {
546
- check.kind;
547
- }
548
- }
549
- }
550
- return [true, json];
551
- }
552
- case ZodFirstPartyTypeKind.ZodBigInt: {
553
- const json = {
554
- type: "string",
555
- pattern: "^-?[0-9]+$",
556
- "x-native-type": JsonSchemaXNativeType.BigInt
557
- };
558
- return [true, json];
559
- }
560
- case ZodFirstPartyTypeKind.ZodNaN: {
561
- return options.strategy === "input" ? [true, this.unsupportedJsonSchema] : [true, { type: "null" }];
562
- }
563
- case ZodFirstPartyTypeKind.ZodBoolean: {
564
- return [true, { type: "boolean" }];
565
- }
566
- case ZodFirstPartyTypeKind.ZodDate: {
567
- const schema2 = {
568
- type: "string",
569
- format: JSONSchemaFormat.DateTime,
570
- "x-native-type": JsonSchemaXNativeType.Date
571
- };
572
- return [true, schema2];
573
- }
574
- case ZodFirstPartyTypeKind.ZodNull: {
575
- return [true, { type: "null" }];
576
- }
577
- case ZodFirstPartyTypeKind.ZodLiteral: {
578
- const schema_ = schema;
579
- if (schema_._def.value === void 0) {
580
- return [false, this.unsupportedJsonSchema];
581
- }
582
- return [true, { const: schema_._def.value }];
583
- }
584
- case ZodFirstPartyTypeKind.ZodVoid:
585
- case ZodFirstPartyTypeKind.ZodUndefined: {
586
- return [false, this.unsupportedJsonSchema];
587
- }
588
- case ZodFirstPartyTypeKind.ZodUnknown:
589
- case ZodFirstPartyTypeKind.ZodAny: {
590
- return [false, this.anyJsonSchema];
591
- }
592
- case ZodFirstPartyTypeKind.ZodEnum: {
593
- const schema_ = schema;
594
- return [true, { enum: schema_._def.values }];
595
- }
596
- case ZodFirstPartyTypeKind.ZodNativeEnum: {
597
- const schema_ = schema;
598
- return [true, { enum: Object.values(schema_._def.values) }];
599
- }
600
- case ZodFirstPartyTypeKind.ZodArray: {
601
- const schema_ = schema;
602
- const def2 = schema_._def;
603
- const json = { type: "array" };
604
- const [itemRequired, itemJson] = this.convert(
605
- def2.type,
606
- options,
607
- lazyDepth,
608
- false,
609
- false,
610
- structureDepth + 1
611
- );
612
- json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
613
- if (def2.exactLength) {
614
- json.maxItems = def2.exactLength.value;
615
- json.minItems = def2.exactLength.value;
616
- }
617
- if (def2.minLength) {
618
- json.minItems = def2.minLength.value;
619
- }
620
- if (def2.maxLength) {
621
- json.maxItems = def2.maxLength.value;
622
- }
623
- return [true, json];
624
- }
625
- case ZodFirstPartyTypeKind.ZodTuple: {
626
- const schema_ = schema;
627
- const prefixItems = [];
628
- const json = { type: "array" };
629
- for (const item of schema_._def.items) {
630
- const [itemRequired, itemJson] = this.convert(
631
- item,
632
- options,
633
- lazyDepth,
634
- false,
635
- false,
636
- structureDepth + 1
637
- );
638
- prefixItems.push(this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy));
639
- }
640
- if (prefixItems?.length) {
641
- json.prefixItems = prefixItems;
642
- }
643
- if (schema_._def.rest) {
644
- const [itemRequired, itemJson] = this.convert(
645
- schema_._def.rest,
646
- options,
647
- lazyDepth,
648
- false,
649
- false,
650
- structureDepth + 1
651
- );
652
- json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
537
+ const KrustyCUID2 = /* @__PURE__ */ core.$constructor(
538
+ "KrustyCUID2",
539
+ (inst, def) => {
540
+ const coreInit = core.$ZodCUID2.init;
541
+ coreInit(inst, def);
542
+ KrustyStringFormat.init(inst, def);
543
+ }
544
+ );
545
+ function cuid2(params) {
546
+ return core._cuid2(KrustyCUID2, params);
547
+ }
548
+ const KrustyULID = /* @__PURE__ */ core.$constructor(
549
+ "KrustyULID",
550
+ (inst, def) => {
551
+ const coreInit = core.$ZodULID.init;
552
+ coreInit(inst, def);
553
+ KrustyStringFormat.init(inst, def);
554
+ }
555
+ );
556
+ function ulid(params) {
557
+ return core._ulid(KrustyULID, params);
558
+ }
559
+ const KrustyXID = /* @__PURE__ */ core.$constructor(
560
+ "KrustyXID",
561
+ (inst, def) => {
562
+ const coreInit = core.$ZodXID.init;
563
+ coreInit(inst, def);
564
+ KrustyStringFormat.init(inst, def);
565
+ }
566
+ );
567
+ function xid(params) {
568
+ return core._xid(KrustyXID, params);
569
+ }
570
+ const KrustyKSUID = /* @__PURE__ */ core.$constructor(
571
+ "KrustyKSUID",
572
+ (inst, def) => {
573
+ const coreInit = core.$ZodKSUID.init;
574
+ coreInit(inst, def);
575
+ KrustyStringFormat.init(inst, def);
576
+ }
577
+ );
578
+ function ksuid(params) {
579
+ return core._ksuid(KrustyKSUID, params);
580
+ }
581
+ const KrustyIPv4 = /* @__PURE__ */ core.$constructor(
582
+ "KrustyIPv4",
583
+ (inst, def) => {
584
+ const coreInit = core.$ZodIPv4.init;
585
+ coreInit(inst, def);
586
+ KrustyStringFormat.init(inst, def);
587
+ }
588
+ );
589
+ function ipv4(params) {
590
+ return core._ipv4(KrustyIPv4, params);
591
+ }
592
+ const KrustyIPv6 = /* @__PURE__ */ core.$constructor(
593
+ "KrustyIPv6",
594
+ (inst, def) => {
595
+ const coreInit = core.$ZodIPv6.init;
596
+ coreInit(inst, def);
597
+ KrustyStringFormat.init(inst, def);
598
+ }
599
+ );
600
+ function ipv6(params) {
601
+ return core._ipv6(KrustyIPv6, params);
602
+ }
603
+ const KrustyCIDRv4 = /* @__PURE__ */ core.$constructor(
604
+ "KrustyCIDRv4",
605
+ (inst, def) => {
606
+ const coreInit = core.$ZodCIDRv4.init;
607
+ coreInit(inst, def);
608
+ KrustyStringFormat.init(inst, def);
609
+ }
610
+ );
611
+ function cidrv4(params) {
612
+ return core._cidrv4(KrustyCIDRv4, params);
613
+ }
614
+ const KrustyCIDRv6 = /* @__PURE__ */ core.$constructor(
615
+ "KrustyCIDRv6",
616
+ (inst, def) => {
617
+ const coreInit = core.$ZodCIDRv6.init;
618
+ coreInit(inst, def);
619
+ KrustyStringFormat.init(inst, def);
620
+ }
621
+ );
622
+ function cidrv6(params) {
623
+ return core._cidrv6(KrustyCIDRv6, params);
624
+ }
625
+ const KrustyBase64 = /* @__PURE__ */ core.$constructor(
626
+ "KrustyBase64",
627
+ (inst, def) => {
628
+ const coreInit = core.$ZodBase64.init;
629
+ coreInit(inst, def);
630
+ KrustyStringFormat.init(inst, def);
631
+ }
632
+ );
633
+ function base64(params) {
634
+ return core._base64(KrustyBase64, params);
635
+ }
636
+ const KrustyBase64URL = /* @__PURE__ */ core.$constructor(
637
+ "KrustyBase64URL",
638
+ (inst, def) => {
639
+ const coreInit = core.$ZodBase64URL.init;
640
+ coreInit(inst, def);
641
+ KrustyStringFormat.init(inst, def);
642
+ }
643
+ );
644
+ function base64url(params) {
645
+ return core._base64url(KrustyBase64URL, params);
646
+ }
647
+ const KrustyE164 = /* @__PURE__ */ core.$constructor(
648
+ "KrustyE164",
649
+ (inst, def) => {
650
+ const coreInit = core.$ZodE164.init;
651
+ coreInit(inst, def);
652
+ KrustyStringFormat.init(inst, def);
653
+ }
654
+ );
655
+ function e164(params) {
656
+ return core._e164(KrustyE164, params);
657
+ }
658
+ const KrustyJWT = /* @__PURE__ */ core.$constructor(
659
+ "KrustyJWT",
660
+ (inst, def) => {
661
+ const coreInit = core.$ZodJWT.init;
662
+ coreInit(inst, def);
663
+ KrustyStringFormat.init(inst, def);
664
+ }
665
+ );
666
+ function jwt(params) {
667
+ return core._jwt(KrustyJWT, params);
668
+ }
669
+ const KrustyCustomStringFormat = /* @__PURE__ */ core.$constructor("KrustyCustomStringFormat", (inst, def) => {
670
+ const coreInit = core.$ZodCustomStringFormat.init;
671
+ coreInit(inst, def);
672
+ KrustyStringFormat.init(inst, def);
673
+ });
674
+ function stringFormat(format, fnOrRegex, _params = {}) {
675
+ return core._stringFormat(KrustyCustomStringFormat, format, fnOrRegex, _params);
676
+ }
677
+ function hostname(_params) {
678
+ return core._stringFormat(KrustyCustomStringFormat, "hostname", core.regexes.hostname, _params);
679
+ }
680
+ function hex(_params) {
681
+ return core._stringFormat(KrustyCustomStringFormat, "hex", core.regexes.hex, _params);
682
+ }
683
+ function hash(alg, params) {
684
+ const enc = params?.enc ?? "hex";
685
+ const format = `${alg}_${enc}`;
686
+ const regex = core.regexes[format];
687
+ if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
688
+ return core._stringFormat(KrustyCustomStringFormat, format, regex, params);
689
+ }
690
+ const KrustyNumber = /* @__PURE__ */ core.$constructor(
691
+ "KrustyNumber",
692
+ (inst, def) => {
693
+ const coreInit = core.$ZodNumber.init;
694
+ coreInit(inst, def);
695
+ KrustyType.init(inst, def);
696
+ inst.gt = (value, params) => inst.check(_gt(value, params));
697
+ inst.gte = (value, params) => inst.check(_gte(value, params));
698
+ inst.min = (value, params) => inst.check(_gte(value, params));
699
+ inst.lt = (value, params) => inst.check(_lt(value, params));
700
+ inst.lte = (value, params) => inst.check(_lte(value, params));
701
+ inst.max = (value, params) => inst.check(_lte(value, params));
702
+ inst.int = (params) => inst.check(int(params));
703
+ inst.positive = (params) => inst.check(_gt(0, params));
704
+ inst.nonnegative = (params) => inst.check(_gte(0, params));
705
+ inst.negative = (params) => inst.check(_lt(0, params));
706
+ inst.nonpositive = (params) => inst.check(_lte(0, params));
707
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
708
+ inst.step = (value, params) => inst.check(_multipleOf(value, params));
709
+ inst.finite = () => inst;
710
+ const bag = inst._zod.bag;
711
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
712
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
713
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
714
+ inst.isFinite = true;
715
+ inst.format = bag.format ?? null;
716
+ const origParse = inst._zod.parse;
717
+ inst._zod.parse = (payload, ctx) => {
718
+ const { parseType } = ctx;
719
+ if (parseType === "query" && typeof payload.value === "string") {
720
+ const value = Number(payload.value);
721
+ if (!Number.isNaN(value)) {
722
+ payload.value = value;
653
723
  }
654
- return [true, json];
655
724
  }
656
- case ZodFirstPartyTypeKind.ZodObject: {
657
- const schema_ = schema;
658
- const json = { type: "object" };
659
- const properties = {};
660
- const required = [];
661
- for (const [key, value] of Object.entries(schema_.shape)) {
662
- const [itemRequired, itemJson] = this.convert(
663
- value,
664
- options,
665
- lazyDepth,
666
- false,
667
- false,
668
- structureDepth + 1
669
- );
670
- properties[key] = itemJson;
671
- if (itemRequired) {
672
- required.push(key);
673
- }
674
- }
675
- if (Object.keys(properties).length) {
676
- json.properties = properties;
677
- }
678
- if (required.length) {
679
- json.required = required;
680
- }
681
- const catchAllTypeName = this.#getZodTypeName(schema_._def.catchall._def);
682
- if (catchAllTypeName === ZodFirstPartyTypeKind.ZodNever) {
683
- if (schema_._def.unknownKeys === "strict") {
684
- json.additionalProperties = false;
685
- }
725
+ return origParse(payload, ctx);
726
+ };
727
+ }
728
+ );
729
+ function number(params) {
730
+ return core._number(KrustyNumber, params);
731
+ }
732
+ const KrustyNumberFormat = /* @__PURE__ */ core.$constructor(
733
+ "KrustyNumberFormat",
734
+ (inst, def) => {
735
+ const coreInit = core.$ZodNumberFormat.init;
736
+ coreInit(inst, def);
737
+ KrustyNumber.init(inst, def);
738
+ }
739
+ );
740
+ function int(params) {
741
+ return core._int(KrustyNumberFormat, params);
742
+ }
743
+ function float32(params) {
744
+ return core._float32(KrustyNumberFormat, params);
745
+ }
746
+ function float64(params) {
747
+ return core._float64(KrustyNumberFormat, params);
748
+ }
749
+ function int32(params) {
750
+ return core._int32(KrustyNumberFormat, params);
751
+ }
752
+ function uint32(params) {
753
+ return core._uint32(KrustyNumberFormat, params);
754
+ }
755
+ const KrustyBoolean = /* @__PURE__ */ core.$constructor(
756
+ "KrustyBoolean",
757
+ (inst, def) => {
758
+ const coreInit = core.$ZodBoolean.init;
759
+ coreInit(inst, def);
760
+ KrustyType.init(inst, def);
761
+ const origParse = inst._zod.parse;
762
+ inst._zod.parse = (payload, ctx) => {
763
+ const { parseType } = ctx;
764
+ if (parseType === "query") {
765
+ if (payload.value === "true") {
766
+ payload.value = true;
767
+ } else if (payload.value === "false") {
768
+ payload.value = false;
686
769
  } else {
687
- const [_, addJson] = this.convert(
688
- schema_._def.catchall,
689
- options,
690
- lazyDepth,
691
- false,
692
- false,
693
- structureDepth + 1
694
- );
695
- json.additionalProperties = addJson;
696
- }
697
- return [true, json];
698
- }
699
- case ZodFirstPartyTypeKind.ZodRecord: {
700
- const schema_ = schema;
701
- const json = { type: "object" };
702
- const [__, keyJson] = this.convert(
703
- schema_._def.keyType,
704
- options,
705
- lazyDepth,
706
- false,
707
- false,
708
- structureDepth + 1
709
- );
710
- if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
711
- json.propertyNames = keyJson;
770
+ payload.issues.push({
771
+ code: "invalid_type",
772
+ expected: "boolean",
773
+ values: ["true", "false"],
774
+ input: payload.value,
775
+ inst,
776
+ continue: false
777
+ });
778
+ return payload;
712
779
  }
713
- const [_, itemJson] = this.convert(
714
- schema_._def.valueType,
715
- options,
716
- lazyDepth,
717
- false,
718
- false,
719
- structureDepth + 1
720
- );
721
- json.additionalProperties = itemJson;
722
- return [true, json];
723
- }
724
- case ZodFirstPartyTypeKind.ZodSet: {
725
- const schema_ = schema;
726
- const json = {
727
- type: "array",
728
- uniqueItems: true,
729
- "x-native-type": JsonSchemaXNativeType.Set
730
- };
731
- const [itemRequired, itemJson] = this.convert(
732
- schema_._def.valueType,
733
- options,
734
- lazyDepth,
735
- false,
736
- false,
737
- structureDepth + 1
738
- );
739
- json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
740
- return [true, json];
741
- }
742
- case ZodFirstPartyTypeKind.ZodMap: {
743
- const schema_ = schema;
744
- const [keyRequired, keyJson] = this.convert(
745
- schema_._def.keyType,
746
- options,
747
- lazyDepth,
748
- false,
749
- false,
750
- structureDepth + 1
751
- );
752
- const [valueRequired, valueJson] = this.convert(
753
- schema_._def.valueType,
754
- options,
755
- lazyDepth,
756
- false,
757
- false,
758
- structureDepth + 1
759
- );
760
- const json = {
761
- type: "array",
762
- items: {
763
- type: "array",
764
- prefixItems: [
765
- this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
766
- this.#toArrayItemJsonSchema(valueRequired, valueJson, options.strategy)
767
- ],
768
- maxItems: 2,
769
- minItems: 2
770
- },
771
- "x-native-type": JsonSchemaXNativeType.Map
772
- };
773
- return [true, json];
774
780
  }
775
- case ZodFirstPartyTypeKind.ZodUnion:
776
- case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
777
- const schema_ = schema;
778
- const anyOf = [];
779
- let required = true;
780
- for (const item of schema_._def.options) {
781
- const [itemRequired, itemJson] = this.convert(
782
- item,
783
- options,
784
- lazyDepth,
785
- false,
786
- false,
787
- structureDepth
788
- );
789
- if (!itemRequired) {
790
- required = false;
791
- if (itemJson !== this.unsupportedJsonSchema) {
792
- anyOf.push(itemJson);
793
- }
794
- } else {
795
- anyOf.push(itemJson);
796
- }
797
- }
798
- if (anyOf.length === 1) {
799
- return [required, anyOf[0]];
800
- }
801
- return [required, { anyOf }];
781
+ return origParse(payload, ctx);
782
+ };
783
+ }
784
+ );
785
+ function boolean(params) {
786
+ return core._boolean(KrustyBoolean, params);
787
+ }
788
+ const KrustyBigInt = /* @__PURE__ */ core.$constructor(
789
+ "KrustyBigInt",
790
+ (inst, def) => {
791
+ const coreInit = core.$ZodBigInt.init;
792
+ coreInit(inst, def);
793
+ KrustyType.init(inst, def);
794
+ inst.gte = (value, params) => inst.check(_gte(value, params));
795
+ inst.min = (value, params) => inst.check(_gte(value, params));
796
+ inst.gt = (value, params) => inst.check(_gt(value, params));
797
+ inst.gte = (value, params) => inst.check(_gte(value, params));
798
+ inst.min = (value, params) => inst.check(_gte(value, params));
799
+ inst.lt = (value, params) => inst.check(_lt(value, params));
800
+ inst.lte = (value, params) => inst.check(_lte(value, params));
801
+ inst.max = (value, params) => inst.check(_lte(value, params));
802
+ inst.positive = (params) => inst.check(_gt(BigInt(0), params));
803
+ inst.negative = (params) => inst.check(_lt(BigInt(0), params));
804
+ inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
805
+ inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
806
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
807
+ const bag = inst._zod.bag;
808
+ inst.minValue = bag.minimum ?? null;
809
+ inst.maxValue = bag.maximum ?? null;
810
+ inst.format = bag.format ?? null;
811
+ }
812
+ );
813
+ function bigint(params) {
814
+ return core._bigint(KrustyBigInt, params);
815
+ }
816
+ const KrustyBigIntFormat = /* @__PURE__ */ core.$constructor(
817
+ "KrustyBigIntFormat",
818
+ (inst, def) => {
819
+ const coreInit = core.$ZodBigIntFormat.init;
820
+ coreInit(inst, def);
821
+ KrustyBigInt.init(inst, def);
822
+ }
823
+ );
824
+ function int64(params) {
825
+ return core._int64(KrustyBigIntFormat, params);
826
+ }
827
+ function uint64(params) {
828
+ return core._uint64(KrustyBigIntFormat, params);
829
+ }
830
+ const KrustySymbol = /* @__PURE__ */ core.$constructor(
831
+ "KrustySymbol",
832
+ (inst, def) => {
833
+ const coreInit = core.$ZodSymbol.init;
834
+ coreInit(inst, def);
835
+ KrustyType.init(inst, def);
836
+ }
837
+ );
838
+ function symbol(params) {
839
+ return core._symbol(KrustySymbol, params);
840
+ }
841
+ const KrustyUndefined = /* @__PURE__ */ core.$constructor(
842
+ "KrustyUndefined",
843
+ (inst, def) => {
844
+ const coreInit = core.$ZodUndefined.init;
845
+ coreInit(inst, def);
846
+ KrustyType.init(inst, def);
847
+ }
848
+ );
849
+ function _undefined(params) {
850
+ return core._undefined(KrustyUndefined, params);
851
+ }
852
+ const KrustyNull = /* @__PURE__ */ core.$constructor(
853
+ "KrustyNull",
854
+ (inst, def) => {
855
+ const coreInit = core.$ZodNull.init;
856
+ coreInit(inst, def);
857
+ KrustyType.init(inst, def);
858
+ }
859
+ );
860
+ function _null(params) {
861
+ return core._null(KrustyNull, params);
862
+ }
863
+ const KrustyAny = /* @__PURE__ */ core.$constructor(
864
+ "KrustyAny",
865
+ (inst, def) => {
866
+ const coreInit = core.$ZodAny.init;
867
+ coreInit(inst, def);
868
+ KrustyType.init(inst, def);
869
+ }
870
+ );
871
+ function any() {
872
+ return core._any(KrustyAny);
873
+ }
874
+ const KrustyUnknown = /* @__PURE__ */ core.$constructor(
875
+ "KrustyUnknown",
876
+ (inst, def) => {
877
+ const coreInit = core.$ZodUnknown.init;
878
+ coreInit(inst, def);
879
+ KrustyType.init(inst, def);
880
+ }
881
+ );
882
+ function unknown() {
883
+ return core._unknown(KrustyUnknown);
884
+ }
885
+ const KrustyNever = /* @__PURE__ */ core.$constructor(
886
+ "KrustyNever",
887
+ (inst, def) => {
888
+ const coreInit = core.$ZodNever.init;
889
+ coreInit(inst, def);
890
+ KrustyType.init(inst, def);
891
+ }
892
+ );
893
+ function never(params) {
894
+ return core._never(KrustyNever, params);
895
+ }
896
+ const KrustyVoid = /* @__PURE__ */ core.$constructor(
897
+ "KrustyVoid",
898
+ (inst, def) => {
899
+ const coreInit = core.$ZodVoid.init;
900
+ coreInit(inst, def);
901
+ KrustyType.init(inst, def);
902
+ }
903
+ );
904
+ function _void(params) {
905
+ return core._void(KrustyVoid, params);
906
+ }
907
+ const KrustyDate = /* @__PURE__ */ core.$constructor(
908
+ "KrustyDate",
909
+ (inst, def) => {
910
+ const coreInit = core.$ZodDate.init;
911
+ coreInit(inst, def);
912
+ KrustyType.init(inst, def);
913
+ inst.min = (value, params) => inst.check(_gte(value, params));
914
+ inst.max = (value, params) => inst.check(_lte(value, params));
915
+ const c = inst._zod.bag;
916
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
917
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
918
+ }
919
+ );
920
+ function date(params) {
921
+ return codec(date$1(params), core._date(KrustyDate, params), {
922
+ encode: (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`,
923
+ decode: (isoString2) => {
924
+ const [y, m, d] = isoString2.split("-");
925
+ return new Date(Number(y), Number(m) - 1, Number(d));
926
+ }
927
+ });
928
+ }
929
+ function datetime(params) {
930
+ return codec(datetime$1(params), core._date(KrustyDate, params), {
931
+ encode: (date2) => date2.toISOString(),
932
+ decode: (isoString2) => new Date(isoString2)
933
+ });
934
+ }
935
+ const KrustyArray = /* @__PURE__ */ core.$constructor(
936
+ "KrustyArray",
937
+ (inst, def) => {
938
+ const coreInit = core.$ZodArray.init;
939
+ coreInit(inst, def);
940
+ KrustyType.init(inst, def);
941
+ inst.element = def.element;
942
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
943
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
944
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
945
+ inst.length = (len, params) => inst.check(_length(len, params));
946
+ inst.unwrap = () => inst.element;
947
+ }
948
+ );
949
+ function array(element, params) {
950
+ return core._array(KrustyArray, element, params);
951
+ }
952
+ function keyof(schema) {
953
+ const shape = schema._zod.def.shape;
954
+ return _enum(Object.keys(shape));
955
+ }
956
+ const KrustyIntersection = /* @__PURE__ */ core.$constructor(
957
+ "KrustyIntersection",
958
+ (inst, def) => {
959
+ const coreInit = core.$ZodIntersection.init;
960
+ coreInit(inst, def);
961
+ KrustyType.init(inst, def);
962
+ }
963
+ );
964
+ function intersection(left, right) {
965
+ return new KrustyIntersection({
966
+ type: "intersection",
967
+ left,
968
+ right
969
+ });
970
+ }
971
+ const KrustyTuple = /* @__PURE__ */ core.$constructor(
972
+ "KrustyTuple",
973
+ (inst, def) => {
974
+ const coreInit = core.$ZodTuple.init;
975
+ coreInit(inst, def);
976
+ KrustyType.init(inst, def);
977
+ inst.rest = (rest) => inst.clone({
978
+ ...inst._zod.def,
979
+ rest
980
+ });
981
+ }
982
+ );
983
+ function tuple(items, _paramsOrRest, _params) {
984
+ const hasRest = _paramsOrRest instanceof core.$ZodType;
985
+ const params = hasRest ? _params : _paramsOrRest;
986
+ const rest = hasRest ? _paramsOrRest : null;
987
+ return new KrustyTuple({
988
+ type: "tuple",
989
+ items,
990
+ rest,
991
+ ...util.normalizeParams(params)
992
+ });
993
+ }
994
+ const KrustyRecord = /* @__PURE__ */ core.$constructor(
995
+ "KrustyRecord",
996
+ (inst, def) => {
997
+ const coreInit = core.$ZodRecord.init;
998
+ coreInit(inst, def);
999
+ KrustyType.init(inst, def);
1000
+ inst.keyType = def.keyType;
1001
+ inst.valueType = def.valueType;
1002
+ }
1003
+ );
1004
+ function record(keyType, valueType, params) {
1005
+ return new KrustyRecord({
1006
+ type: "record",
1007
+ keyType,
1008
+ valueType,
1009
+ ...util.normalizeParams(params)
1010
+ });
1011
+ }
1012
+ function partialRecord(keyType, valueType, params) {
1013
+ const k = core.clone(keyType);
1014
+ k._zod.values = void 0;
1015
+ return new KrustyRecord({
1016
+ type: "record",
1017
+ keyType: k,
1018
+ valueType,
1019
+ ...util.normalizeParams(params)
1020
+ });
1021
+ }
1022
+ const KrustyMap = /* @__PURE__ */ core.$constructor(
1023
+ "KrustyMap",
1024
+ (inst, def) => {
1025
+ const coreInit = core.$ZodMap.init;
1026
+ coreInit(inst, def);
1027
+ KrustyType.init(inst, def);
1028
+ inst.keyType = def.keyType;
1029
+ inst.valueType = def.valueType;
1030
+ }
1031
+ );
1032
+ function map(keyType, valueType, params) {
1033
+ return new KrustyMap({
1034
+ type: "map",
1035
+ keyType,
1036
+ valueType,
1037
+ ...util.normalizeParams(params)
1038
+ });
1039
+ }
1040
+ const KrustySet = /* @__PURE__ */ core.$constructor(
1041
+ "KrustySet",
1042
+ (inst, def) => {
1043
+ const coreInit = core.$ZodSet.init;
1044
+ coreInit(inst, def);
1045
+ KrustyType.init(inst, def);
1046
+ inst.min = (...args) => inst.check(core._minSize(...args));
1047
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
1048
+ inst.max = (...args) => inst.check(core._maxSize(...args));
1049
+ inst.size = (...args) => inst.check(core._size(...args));
1050
+ }
1051
+ );
1052
+ function set(valueType, params) {
1053
+ return new KrustySet({
1054
+ type: "set",
1055
+ valueType,
1056
+ ...util.normalizeParams(params)
1057
+ });
1058
+ }
1059
+ const KrustyEnum = /* @__PURE__ */ core.$constructor(
1060
+ "KrustyEnum",
1061
+ (inst, def) => {
1062
+ const coreInit = core.$ZodEnum.init;
1063
+ coreInit(inst, def);
1064
+ KrustyType.init(inst, def);
1065
+ inst.enum = def.entries;
1066
+ inst.options = Object.values(def.entries);
1067
+ const keys = new Set(Object.keys(def.entries));
1068
+ inst.extract = (values, params) => {
1069
+ const newEntries = {};
1070
+ for (const value of values) {
1071
+ if (keys.has(value)) {
1072
+ newEntries[value] = def.entries[value];
1073
+ } else throw new Error(`Key ${value} not found in enum`);
802
1074
  }
803
- case ZodFirstPartyTypeKind.ZodIntersection: {
804
- const schema_ = schema;
805
- const allOf = [];
806
- let required = false;
807
- for (const item of [schema_._def.left, schema_._def.right]) {
808
- const [itemRequired, itemJson] = this.convert(
809
- item,
810
- options,
811
- lazyDepth,
812
- false,
813
- false,
814
- structureDepth
815
- );
816
- allOf.push(itemJson);
817
- if (itemRequired) {
818
- required = true;
819
- }
820
- }
821
- return [required, { allOf }];
1075
+ return new KrustyEnum({
1076
+ ...def,
1077
+ checks: [],
1078
+ ...util.normalizeParams(params),
1079
+ entries: newEntries
1080
+ });
1081
+ };
1082
+ inst.exclude = (values, params) => {
1083
+ const newEntries = { ...def.entries };
1084
+ for (const value of values) {
1085
+ if (keys.has(value)) {
1086
+ delete newEntries[value];
1087
+ } else throw new Error(`Key ${value} not found in enum`);
822
1088
  }
823
- case ZodFirstPartyTypeKind.ZodLazy: {
824
- const currentLazyDepth = lazyDepth + 1;
825
- if (currentLazyDepth > this.maxLazyDepth) {
826
- return [false, this.anyJsonSchema];
1089
+ return new KrustyEnum({
1090
+ ...def,
1091
+ checks: [],
1092
+ ...util.normalizeParams(params),
1093
+ entries: newEntries
1094
+ });
1095
+ };
1096
+ }
1097
+ );
1098
+ function _enum(values, params) {
1099
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1100
+ return new KrustyEnum({
1101
+ type: "enum",
1102
+ entries,
1103
+ ...util.normalizeParams(params)
1104
+ });
1105
+ }
1106
+ function nativeEnum(entries, params) {
1107
+ return new KrustyEnum({
1108
+ type: "enum",
1109
+ entries,
1110
+ ...util.normalizeParams(params)
1111
+ });
1112
+ }
1113
+ const KrustyLiteral = /* @__PURE__ */ core.$constructor(
1114
+ "KrustyLiteral",
1115
+ (inst, def) => {
1116
+ const coreInit = core.$ZodLiteral.init;
1117
+ coreInit(inst, def);
1118
+ KrustyType.init(inst, def);
1119
+ inst.values = new Set(def.values);
1120
+ Object.defineProperty(inst, "value", {
1121
+ get() {
1122
+ if (def.values.length > 1) {
1123
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
827
1124
  }
828
- const schema_ = schema;
829
- return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
1125
+ return def.values[0];
830
1126
  }
831
- case ZodFirstPartyTypeKind.ZodOptional: {
832
- const schema_ = schema;
833
- const [_, inner] = this.convert(
834
- schema_._def.innerType,
835
- options,
836
- lazyDepth,
837
- false,
838
- false,
839
- structureDepth
840
- );
841
- return [false, inner];
842
- }
843
- case ZodFirstPartyTypeKind.ZodReadonly: {
844
- const schema_ = schema;
845
- const [required, json] = this.convert(
846
- schema_._def.innerType,
847
- options,
848
- lazyDepth,
849
- false,
850
- false,
851
- structureDepth
852
- );
853
- return [required, { ...json, readOnly: true }];
854
- }
855
- case ZodFirstPartyTypeKind.ZodDefault: {
856
- const schema_ = schema;
857
- const [_, json] = this.convert(
858
- schema_._def.innerType,
859
- options,
860
- lazyDepth,
861
- false,
862
- false,
863
- structureDepth
864
- );
865
- return [false, { default: schema_._def.defaultValue(), ...json }];
1127
+ });
1128
+ }
1129
+ );
1130
+ function literal(value, params) {
1131
+ return new KrustyLiteral({
1132
+ type: "literal",
1133
+ values: Array.isArray(value) ? value : [value],
1134
+ ...util.normalizeParams(params)
1135
+ });
1136
+ }
1137
+ const KrustyFile = /* @__PURE__ */ core.$constructor(
1138
+ "KrustyFile",
1139
+ (inst, def) => {
1140
+ const coreInit = core.$ZodFile.init;
1141
+ coreInit(inst, def);
1142
+ KrustyType.init(inst, def);
1143
+ inst.min = (size, params) => inst.check(core._minSize(size, params));
1144
+ inst.max = (size, params) => inst.check(core._maxSize(size, params));
1145
+ inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
1146
+ }
1147
+ );
1148
+ function file(params) {
1149
+ return core._file(KrustyFile, params);
1150
+ }
1151
+ const KrustyTransform = /* @__PURE__ */ core.$constructor(
1152
+ "KrustyTransform",
1153
+ (inst, def) => {
1154
+ const coreInit = core.$ZodTransform.init;
1155
+ coreInit(inst, def);
1156
+ KrustyType.init(inst, def);
1157
+ inst._zod.parse = (payload, _ctx) => {
1158
+ if (_ctx.direction === "backward") {
1159
+ throw new core.$ZodEncodeError(inst.constructor.name);
866
1160
  }
867
- case ZodFirstPartyTypeKind.ZodEffects: {
868
- const schema_ = schema;
869
- if (schema_._def.effect.type === "transform" && options.strategy === "output") {
870
- return [false, this.anyJsonSchema];
1161
+ payload.addIssue = (issue) => {
1162
+ if (typeof issue === "string") {
1163
+ payload.issues.push(util.issue(issue, payload.value, def));
1164
+ } else {
1165
+ const _issue = issue;
1166
+ if (_issue.fatal) _issue.continue = false;
1167
+ _issue.code ??= "custom";
1168
+ _issue.input ??= payload.value;
1169
+ _issue.inst ??= inst;
1170
+ payload.issues.push(util.issue(_issue));
871
1171
  }
872
- return this.convert(schema_._def.schema, options, lazyDepth, false, false, structureDepth);
873
- }
874
- case ZodFirstPartyTypeKind.ZodCatch: {
875
- const schema_ = schema;
876
- return this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
877
- }
878
- case ZodFirstPartyTypeKind.ZodBranded: {
879
- const schema_ = schema;
880
- return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
881
- }
882
- case ZodFirstPartyTypeKind.ZodPipeline: {
883
- const schema_ = schema;
884
- return this.convert(
885
- options.strategy === "input" ? schema_._def.in : schema_._def.out,
886
- options,
887
- lazyDepth,
888
- false,
889
- false,
890
- structureDepth
891
- );
892
- }
893
- case ZodFirstPartyTypeKind.ZodNullable: {
894
- const schema_ = schema;
895
- const [required, json] = this.convert(
896
- schema_._def.innerType,
897
- options,
898
- lazyDepth,
899
- false,
900
- false,
901
- structureDepth
902
- );
903
- return [required, { anyOf: [json, { type: "null" }] }];
1172
+ };
1173
+ const output = def.transform(payload.value, payload);
1174
+ if (output instanceof Promise) {
1175
+ return output.then((output2) => {
1176
+ payload.value = output2;
1177
+ return payload;
1178
+ });
904
1179
  }
905
- }
906
- return [true, this.unsupportedJsonSchema];
1180
+ payload.value = output;
1181
+ return payload;
1182
+ };
1183
+ }
1184
+ );
1185
+ function transform(fn) {
1186
+ return new KrustyTransform({
1187
+ type: "transform",
1188
+ transform: fn
1189
+ });
1190
+ }
1191
+ const KrustyOptional = /* @__PURE__ */ core.$constructor(
1192
+ "KrustyOptional",
1193
+ (inst, def) => {
1194
+ const coreInit = core.$ZodOptional.init;
1195
+ coreInit(inst, def);
1196
+ KrustyType.init(inst, def);
1197
+ inst.unwrap = () => inst._zod.def.innerType;
1198
+ }
1199
+ );
1200
+ function optional(innerType) {
1201
+ return new KrustyOptional({
1202
+ type: "optional",
1203
+ innerType
1204
+ });
1205
+ }
1206
+ const KrustyNullable = /* @__PURE__ */ core.$constructor(
1207
+ "KrustyNullable",
1208
+ (inst, def) => {
1209
+ const coreInit = core.$ZodNullable.init;
1210
+ coreInit(inst, def);
1211
+ KrustyType.init(inst, def);
1212
+ inst.unwrap = () => inst._zod.def.innerType;
907
1213
  }
908
- #handleCustomZodDef(def) {
909
- const customZodDef = getCustomZodDef(def);
910
- if (!customZodDef) {
911
- return void 0;
1214
+ );
1215
+ function nullable(innerType) {
1216
+ return new KrustyNullable({
1217
+ type: "nullable",
1218
+ innerType
1219
+ });
1220
+ }
1221
+ function nullish(innerType) {
1222
+ return optional(nullable(innerType));
1223
+ }
1224
+ const KrustyDefault = /* @__PURE__ */ core.$constructor(
1225
+ "KrustyDefault",
1226
+ (inst, def) => {
1227
+ const coreInit = core.$ZodDefault.init;
1228
+ coreInit(inst, def);
1229
+ KrustyType.init(inst, def);
1230
+ inst.unwrap = () => inst._zod.def.innerType;
1231
+ inst.removeDefault = inst.unwrap;
1232
+ }
1233
+ );
1234
+ function _default(innerType, defaultValue) {
1235
+ return new KrustyDefault({
1236
+ type: "default",
1237
+ innerType,
1238
+ get defaultValue() {
1239
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
912
1240
  }
913
- switch (customZodDef.type) {
914
- case "blob": {
915
- return { type: "string", contentMediaType: "*/*" };
916
- }
917
- case "file": {
918
- return { type: "string", contentMediaType: customZodDef.mimeType ?? "*/*" };
919
- }
920
- case "regexp": {
921
- return {
922
- type: "string",
923
- pattern: "^\\/(.*)\\/([a-z]*)$",
924
- "x-native-type": JsonSchemaXNativeType.RegExp
925
- };
926
- }
927
- case "url": {
928
- return {
929
- type: "string",
930
- format: JSONSchemaFormat.URI,
931
- "x-native-type": JsonSchemaXNativeType.Url
932
- };
933
- }
1241
+ });
1242
+ }
1243
+ const KrustyPrefault = /* @__PURE__ */ core.$constructor(
1244
+ "KrustyPrefault",
1245
+ (inst, def) => {
1246
+ const coreInit = core.$ZodPrefault.init;
1247
+ coreInit(inst, def);
1248
+ KrustyType.init(inst, def);
1249
+ inst.unwrap = () => inst._zod.def.innerType;
1250
+ }
1251
+ );
1252
+ function prefault(innerType, defaultValue) {
1253
+ return new KrustyPrefault({
1254
+ type: "prefault",
1255
+ innerType,
1256
+ get defaultValue() {
1257
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
934
1258
  }
1259
+ });
1260
+ }
1261
+ const KrustyNonOptional = /* @__PURE__ */ core.$constructor(
1262
+ "KrustyNonOptional",
1263
+ (inst, def) => {
1264
+ const coreInit = core.$ZodNonOptional.init;
1265
+ coreInit(inst, def);
1266
+ KrustyType.init(inst, def);
1267
+ inst.unwrap = () => inst._zod.def.innerType;
935
1268
  }
936
- #getZodTypeName(def) {
937
- return def.typeName;
1269
+ );
1270
+ function nonoptional(innerType, params) {
1271
+ return new KrustyNonOptional({
1272
+ type: "nonoptional",
1273
+ innerType,
1274
+ ...util.normalizeParams(params)
1275
+ });
1276
+ }
1277
+ const KrustySuccess = /* @__PURE__ */ core.$constructor(
1278
+ "KrustySuccess",
1279
+ (inst, def) => {
1280
+ const coreInit = core.$ZodSuccess.init;
1281
+ coreInit(inst, def);
1282
+ KrustyType.init(inst, def);
1283
+ inst.unwrap = () => inst._zod.def.innerType;
938
1284
  }
939
- #toArrayItemJsonSchema(required, schema, strategy) {
940
- if (required) {
941
- return schema;
942
- }
943
- return strategy === "input" ? { anyOf: [schema, this.unsupportedJsonSchema] } : { anyOf: [schema, { type: "null" }] };
1285
+ );
1286
+ function success(innerType) {
1287
+ return new KrustySuccess({
1288
+ type: "success",
1289
+ innerType
1290
+ });
1291
+ }
1292
+ const KrustyCatch = /* @__PURE__ */ core.$constructor(
1293
+ "KrustyCatch",
1294
+ (inst, def) => {
1295
+ const coreInit = core.$ZodCatch.init;
1296
+ coreInit(inst, def);
1297
+ KrustyType.init(inst, def);
1298
+ inst.unwrap = () => inst._zod.def.innerType;
1299
+ inst.removeCatch = inst.unwrap;
944
1300
  }
1301
+ );
1302
+ function _catch(innerType, catchValue) {
1303
+ return new KrustyCatch({
1304
+ type: "catch",
1305
+ innerType,
1306
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
1307
+ });
1308
+ }
1309
+ const KrustyNaN = /* @__PURE__ */ core.$constructor(
1310
+ "KrustyNaN",
1311
+ (inst, def) => {
1312
+ const coreInit = core.$ZodNaN.init;
1313
+ coreInit(inst, def);
1314
+ KrustyType.init(inst, def);
1315
+ }
1316
+ );
1317
+ function nan(params) {
1318
+ return core._nan(KrustyNaN, params);
1319
+ }
1320
+ const KrustyPipe = /* @__PURE__ */ core.$constructor(
1321
+ "KrustyPipe",
1322
+ (inst, def) => {
1323
+ const coreInit = core.$ZodPipe.init;
1324
+ coreInit(inst, def);
1325
+ KrustyType.init(inst, def);
1326
+ inst.in = def.in;
1327
+ inst.out = def.out;
1328
+ }
1329
+ );
1330
+ function pipe(in_, out) {
1331
+ return new KrustyPipe({
1332
+ type: "pipe",
1333
+ in: in_,
1334
+ out
1335
+ // ...util.normalizeParams(params),
1336
+ });
1337
+ }
1338
+ const KrustyCodec = /* @__PURE__ */ core.$constructor(
1339
+ "KrustyCodec",
1340
+ (inst, def) => {
1341
+ KrustyPipe.init(inst, def);
1342
+ const coreInit = core.$ZodCodec.init;
1343
+ coreInit(inst, def);
1344
+ }
1345
+ );
1346
+ function codec(in_, out, params) {
1347
+ return new KrustyCodec({
1348
+ type: "pipe",
1349
+ in: in_,
1350
+ out,
1351
+ transform: params.decode,
1352
+ reverseTransform: params.encode
1353
+ });
1354
+ }
1355
+ const KrustyReadonly = /* @__PURE__ */ core.$constructor(
1356
+ "KrustyReadonly",
1357
+ (inst, def) => {
1358
+ const coreInit = core.$ZodReadonly.init;
1359
+ coreInit(inst, def);
1360
+ KrustyType.init(inst, def);
1361
+ inst.unwrap = () => inst._zod.def.innerType;
1362
+ }
1363
+ );
1364
+ function readonly(innerType) {
1365
+ return new KrustyReadonly({
1366
+ type: "readonly",
1367
+ innerType
1368
+ });
1369
+ }
1370
+ const KrustyTemplateLiteral = /* @__PURE__ */ core.$constructor("KrustyTemplateLiteral", (inst, def) => {
1371
+ const coreInit = core.$ZodTemplateLiteral.init;
1372
+ coreInit(inst, def);
1373
+ KrustyType.init(inst, def);
1374
+ });
1375
+ function templateLiteral(parts, params) {
1376
+ return new KrustyTemplateLiteral({
1377
+ type: "template_literal",
1378
+ parts,
1379
+ ...util.normalizeParams(params)
1380
+ });
1381
+ }
1382
+ const KrustyLazy = /* @__PURE__ */ core.$constructor(
1383
+ "KrustyLazy",
1384
+ (inst, def) => {
1385
+ const coreInit = core.$ZodLazy.init;
1386
+ coreInit(inst, def);
1387
+ KrustyType.init(inst, def);
1388
+ inst.unwrap = () => inst._zod.def.getter();
1389
+ }
1390
+ );
1391
+ function lazy(getter) {
1392
+ return new KrustyLazy({
1393
+ type: "lazy",
1394
+ getter
1395
+ });
1396
+ }
1397
+ const KrustyPromise = /* @__PURE__ */ core.$constructor(
1398
+ "KrustyPromise",
1399
+ (inst, def) => {
1400
+ const coreInit = core.$ZodPromise.init;
1401
+ coreInit(inst, def);
1402
+ KrustyType.init(inst, def);
1403
+ inst.unwrap = () => inst._zod.def.innerType;
1404
+ }
1405
+ );
1406
+ function promise(innerType) {
1407
+ return new KrustyPromise({
1408
+ type: "promise",
1409
+ innerType
1410
+ });
1411
+ }
1412
+ const KrustyFunction = /* @__PURE__ */ core.$constructor(
1413
+ "KrustyFunction",
1414
+ (inst, def) => {
1415
+ const coreInit = core.$ZodFunction.init;
1416
+ coreInit(inst, def);
1417
+ KrustyType.init(inst, def);
1418
+ }
1419
+ );
1420
+ function _function(params) {
1421
+ return new KrustyFunction({
1422
+ type: "function",
1423
+ input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
1424
+ output: params?.output ?? unknown()
1425
+ });
1426
+ }
1427
+ const KrustyCustom = /* @__PURE__ */ core.$constructor(
1428
+ "KrustyCustom",
1429
+ (inst, def) => {
1430
+ const coreInit = core.$ZodCustom.init;
1431
+ coreInit(inst, def);
1432
+ KrustyType.init(inst, def);
1433
+ }
1434
+ );
1435
+ function check(fn) {
1436
+ const ch = new core.$ZodCheck({
1437
+ check: "custom"
1438
+ // ...util.normalizeParams(params),
1439
+ });
1440
+ ch._zod.check = fn;
1441
+ return ch;
1442
+ }
1443
+ function custom(fn, _params) {
1444
+ return core._custom(KrustyCustom, fn ?? (() => true), _params);
1445
+ }
1446
+ function refine(fn, _params = {}) {
1447
+ return core._refine(KrustyCustom, fn, _params);
1448
+ }
1449
+ function superRefine(fn) {
1450
+ return core._superRefine(fn);
1451
+ }
1452
+ function _instanceof(cls, params = {
1453
+ error: `Input not instance of ${cls.name}`
1454
+ }) {
1455
+ const inst = new KrustyCustom({
1456
+ type: "custom",
1457
+ check: "custom",
1458
+ fn: (data) => data instanceof cls,
1459
+ abort: true,
1460
+ ...util.normalizeParams(params)
1461
+ });
1462
+ inst._zod.bag.Class = cls;
1463
+ return inst;
1464
+ }
1465
+ const stringbool = (...args) => core._stringbool(
1466
+ {
1467
+ Codec: KrustyCodec,
1468
+ Boolean: KrustyBoolean,
1469
+ String: KrustyString
1470
+ },
1471
+ ...args
1472
+ );
1473
+ function json(params) {
1474
+ const jsonSchema = lazy(() => {
1475
+ return union([
1476
+ string(params),
1477
+ number(),
1478
+ boolean(),
1479
+ _null(),
1480
+ array(jsonSchema),
1481
+ record(string(), jsonSchema)
1482
+ ]);
1483
+ });
1484
+ return jsonSchema;
945
1485
  }
946
1486
 
947
- const oz = {
948
- file,
949
- blob,
950
- url,
951
- regexp,
952
- openapi: customJsonSchema
953
- };
1487
+ class SchemaClass {
1488
+ string(params) {
1489
+ return string(params);
1490
+ }
1491
+ number(params) {
1492
+ return number(params);
1493
+ }
1494
+ int(params) {
1495
+ return this.number().int(params);
1496
+ }
1497
+ boolean(params) {
1498
+ return boolean(params);
1499
+ }
1500
+ null(params) {
1501
+ return _null(params);
1502
+ }
1503
+ array(element, params) {
1504
+ return array(element, params);
1505
+ }
1506
+ record(keyType, valueType, params) {
1507
+ return record(keyType, valueType, params);
1508
+ }
1509
+ union(options, params) {
1510
+ return union(options, params);
1511
+ }
1512
+ discriminatedUnion(discriminator, options, params) {
1513
+ return discriminatedUnion(discriminator, options, params);
1514
+ }
1515
+ object(shape, params) {
1516
+ return object(shape, params);
1517
+ }
1518
+ date(params) {
1519
+ return date(params);
1520
+ }
1521
+ datetime(params) {
1522
+ return datetime(params);
1523
+ }
1524
+ any() {
1525
+ return any();
1526
+ }
1527
+ unknown() {
1528
+ return unknown();
1529
+ }
1530
+ never(params) {
1531
+ return never(params);
1532
+ }
1533
+ lazy(getter) {
1534
+ return lazy(getter);
1535
+ }
1536
+ json(params) {
1537
+ return json(params);
1538
+ }
1539
+ /**
1540
+ * TODO: def need to expose
1541
+ * file
1542
+ * literal
1543
+ * nativeEnum
1544
+ */
1545
+ /**
1546
+ * TODO: decide how to handle non-serializeable values
1547
+ * TODO: decide what types to expose
1548
+ * function
1549
+ * promise
1550
+ * readonly
1551
+ * nan
1552
+ * success
1553
+ * set
1554
+ * map
1555
+ * partialRecord
1556
+ * tuple
1557
+ * intersection
1558
+ * keyof
1559
+ * symbol
1560
+ * bigint
1561
+ * blob
1562
+ */
1563
+ /**
1564
+ * TODO: decide what non-chained format helpers to expose
1565
+ * -- OBJECT
1566
+ * strictObject
1567
+ * looseObject
1568
+ * -- STRING
1569
+ * url
1570
+ * regexp
1571
+ * email
1572
+ * guid
1573
+ * uuid
1574
+ * uuidv4
1575
+ * uuidv6
1576
+ * uuidv7
1577
+ * url
1578
+ * httpUrl
1579
+ * emoji
1580
+ * nanoid
1581
+ * cuid
1582
+ * cuid2
1583
+ * ulid
1584
+ * xid
1585
+ * ksuid
1586
+ * jwt
1587
+ * hostname
1588
+ * hex
1589
+ * hash
1590
+ * ipv4
1591
+ * ipv6
1592
+ * cidrv4
1593
+ * cidrv6
1594
+ * base64
1595
+ * base64url
1596
+ * e164
1597
+ * -- NUMBER
1598
+ * float32
1599
+ * float64
1600
+ * int32
1601
+ * uint32
1602
+ * int64
1603
+ * uint64
1604
+ */
1605
+ /**
1606
+ * TODO: decide what other helper methods to expose
1607
+ * refine
1608
+ * superRefine
1609
+ * custom
1610
+ * check
1611
+ * codec
1612
+ * pipe
1613
+ * nonoptional
1614
+ * prefault
1615
+ * default
1616
+ * nullish
1617
+ * nullable
1618
+ * optional
1619
+ * transform
1620
+ * stringFormat
1621
+ */
1622
+ }
954
1623
 
955
- export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
1624
+ 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 };