@temporary-name/zod 1.9.3-alpha.afd18ec2afa743b08cf1b5c2eb6252ded18a1f43 → 1.9.3-alpha.bb3867758271e7fcf8c191f9693365d655697e7f

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,1625 @@
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.safe = (params) => inst.check(int(params));
704
+ inst.positive = (params) => inst.check(_gt(0, params));
705
+ inst.nonnegative = (params) => inst.check(_gte(0, params));
706
+ inst.negative = (params) => inst.check(_lt(0, params));
707
+ inst.nonpositive = (params) => inst.check(_lte(0, params));
708
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
709
+ inst.step = (value, params) => inst.check(_multipleOf(value, params));
710
+ inst.finite = () => inst;
711
+ const bag = inst._zod.bag;
712
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
713
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
714
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
715
+ inst.isFinite = true;
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;
653
724
  }
654
- return [true, json];
655
725
  }
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
- }
726
+ return origParse(payload, ctx);
727
+ };
728
+ }
729
+ );
730
+ function number(params) {
731
+ return core._number(KrustyNumber, params);
732
+ }
733
+ const KrustyNumberFormat = /* @__PURE__ */ core.$constructor(
734
+ "KrustyNumberFormat",
735
+ (inst, def) => {
736
+ const coreInit = core.$ZodNumberFormat.init;
737
+ coreInit(inst, def);
738
+ KrustyNumber.init(inst, def);
739
+ }
740
+ );
741
+ function int(params) {
742
+ return core._int(KrustyNumberFormat, params);
743
+ }
744
+ function float32(params) {
745
+ return core._float32(KrustyNumberFormat, params);
746
+ }
747
+ function float64(params) {
748
+ return core._float64(KrustyNumberFormat, params);
749
+ }
750
+ function int32(params) {
751
+ return core._int32(KrustyNumberFormat, params);
752
+ }
753
+ function uint32(params) {
754
+ return core._uint32(KrustyNumberFormat, params);
755
+ }
756
+ const KrustyBoolean = /* @__PURE__ */ core.$constructor(
757
+ "KrustyBoolean",
758
+ (inst, def) => {
759
+ const coreInit = core.$ZodBoolean.init;
760
+ coreInit(inst, def);
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;
686
770
  } 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;
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;
712
780
  }
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
781
  }
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 }];
782
+ return origParse(payload, ctx);
783
+ };
784
+ }
785
+ );
786
+ function boolean(params) {
787
+ return core._boolean(KrustyBoolean, params);
788
+ }
789
+ const KrustyBigInt = /* @__PURE__ */ core.$constructor(
790
+ "KrustyBigInt",
791
+ (inst, def) => {
792
+ const coreInit = core.$ZodBigInt.init;
793
+ coreInit(inst, def);
794
+ KrustyType.init(inst, def);
795
+ inst.gte = (value, params) => inst.check(_gte(value, params));
796
+ inst.min = (value, params) => inst.check(_gte(value, params));
797
+ inst.gt = (value, params) => inst.check(_gt(value, params));
798
+ inst.gte = (value, params) => inst.check(_gte(value, params));
799
+ inst.min = (value, params) => inst.check(_gte(value, params));
800
+ inst.lt = (value, params) => inst.check(_lt(value, params));
801
+ inst.lte = (value, params) => inst.check(_lte(value, params));
802
+ inst.max = (value, params) => inst.check(_lte(value, params));
803
+ inst.positive = (params) => inst.check(_gt(BigInt(0), params));
804
+ inst.negative = (params) => inst.check(_lt(BigInt(0), params));
805
+ inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
806
+ inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
807
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
808
+ const bag = inst._zod.bag;
809
+ inst.minValue = bag.minimum ?? null;
810
+ inst.maxValue = bag.maximum ?? null;
811
+ inst.format = bag.format ?? null;
812
+ }
813
+ );
814
+ function bigint(params) {
815
+ return core._bigint(KrustyBigInt, params);
816
+ }
817
+ const KrustyBigIntFormat = /* @__PURE__ */ core.$constructor(
818
+ "KrustyBigIntFormat",
819
+ (inst, def) => {
820
+ const coreInit = core.$ZodBigIntFormat.init;
821
+ coreInit(inst, def);
822
+ KrustyBigInt.init(inst, def);
823
+ }
824
+ );
825
+ function int64(params) {
826
+ return core._int64(KrustyBigIntFormat, params);
827
+ }
828
+ function uint64(params) {
829
+ return core._uint64(KrustyBigIntFormat, params);
830
+ }
831
+ const KrustySymbol = /* @__PURE__ */ core.$constructor(
832
+ "KrustySymbol",
833
+ (inst, def) => {
834
+ const coreInit = core.$ZodSymbol.init;
835
+ coreInit(inst, def);
836
+ KrustyType.init(inst, def);
837
+ }
838
+ );
839
+ function symbol(params) {
840
+ return core._symbol(KrustySymbol, params);
841
+ }
842
+ const KrustyUndefined = /* @__PURE__ */ core.$constructor(
843
+ "KrustyUndefined",
844
+ (inst, def) => {
845
+ const coreInit = core.$ZodUndefined.init;
846
+ coreInit(inst, def);
847
+ KrustyType.init(inst, def);
848
+ }
849
+ );
850
+ function _undefined(params) {
851
+ return core._undefined(KrustyUndefined, params);
852
+ }
853
+ const KrustyNull = /* @__PURE__ */ core.$constructor(
854
+ "KrustyNull",
855
+ (inst, def) => {
856
+ const coreInit = core.$ZodNull.init;
857
+ coreInit(inst, def);
858
+ KrustyType.init(inst, def);
859
+ }
860
+ );
861
+ function _null(params) {
862
+ return core._null(KrustyNull, params);
863
+ }
864
+ const KrustyAny = /* @__PURE__ */ core.$constructor(
865
+ "KrustyAny",
866
+ (inst, def) => {
867
+ const coreInit = core.$ZodAny.init;
868
+ coreInit(inst, def);
869
+ KrustyType.init(inst, def);
870
+ }
871
+ );
872
+ function any() {
873
+ return core._any(KrustyAny);
874
+ }
875
+ const KrustyUnknown = /* @__PURE__ */ core.$constructor(
876
+ "KrustyUnknown",
877
+ (inst, def) => {
878
+ const coreInit = core.$ZodUnknown.init;
879
+ coreInit(inst, def);
880
+ KrustyType.init(inst, def);
881
+ }
882
+ );
883
+ function unknown() {
884
+ return core._unknown(KrustyUnknown);
885
+ }
886
+ const KrustyNever = /* @__PURE__ */ core.$constructor(
887
+ "KrustyNever",
888
+ (inst, def) => {
889
+ const coreInit = core.$ZodNever.init;
890
+ coreInit(inst, def);
891
+ KrustyType.init(inst, def);
892
+ }
893
+ );
894
+ function never(params) {
895
+ return core._never(KrustyNever, params);
896
+ }
897
+ const KrustyVoid = /* @__PURE__ */ core.$constructor(
898
+ "KrustyVoid",
899
+ (inst, def) => {
900
+ const coreInit = core.$ZodVoid.init;
901
+ coreInit(inst, def);
902
+ KrustyType.init(inst, def);
903
+ }
904
+ );
905
+ function _void(params) {
906
+ return core._void(KrustyVoid, params);
907
+ }
908
+ const KrustyDate = /* @__PURE__ */ core.$constructor(
909
+ "KrustyDate",
910
+ (inst, def) => {
911
+ const coreInit = core.$ZodDate.init;
912
+ coreInit(inst, def);
913
+ KrustyType.init(inst, def);
914
+ inst.min = (value, params) => inst.check(_gte(value, params));
915
+ inst.max = (value, params) => inst.check(_lte(value, params));
916
+ const c = inst._zod.bag;
917
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
918
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
919
+ }
920
+ );
921
+ function date(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
+ });
935
+ }
936
+ const KrustyArray = /* @__PURE__ */ core.$constructor(
937
+ "KrustyArray",
938
+ (inst, def) => {
939
+ const coreInit = core.$ZodArray.init;
940
+ coreInit(inst, def);
941
+ KrustyType.init(inst, def);
942
+ inst.element = def.element;
943
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
944
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
945
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
946
+ inst.length = (len, params) => inst.check(_length(len, params));
947
+ inst.unwrap = () => inst.element;
948
+ }
949
+ );
950
+ function array(element, params) {
951
+ return core._array(KrustyArray, element, params);
952
+ }
953
+ function keyof(schema) {
954
+ const shape = schema._zod.def.shape;
955
+ return _enum(Object.keys(shape));
956
+ }
957
+ const KrustyIntersection = /* @__PURE__ */ core.$constructor(
958
+ "KrustyIntersection",
959
+ (inst, def) => {
960
+ const coreInit = core.$ZodIntersection.init;
961
+ coreInit(inst, def);
962
+ KrustyType.init(inst, def);
963
+ }
964
+ );
965
+ function intersection(left, right) {
966
+ return new KrustyIntersection({
967
+ type: "intersection",
968
+ left,
969
+ right
970
+ });
971
+ }
972
+ const KrustyTuple = /* @__PURE__ */ core.$constructor(
973
+ "KrustyTuple",
974
+ (inst, def) => {
975
+ const coreInit = core.$ZodTuple.init;
976
+ coreInit(inst, def);
977
+ KrustyType.init(inst, def);
978
+ inst.rest = (rest) => inst.clone({
979
+ ...inst._zod.def,
980
+ rest
981
+ });
982
+ }
983
+ );
984
+ function tuple(items, _paramsOrRest, _params) {
985
+ const hasRest = _paramsOrRest instanceof core.$ZodType;
986
+ const params = hasRest ? _params : _paramsOrRest;
987
+ const rest = hasRest ? _paramsOrRest : null;
988
+ return new KrustyTuple({
989
+ type: "tuple",
990
+ items,
991
+ rest,
992
+ ...util.normalizeParams(params)
993
+ });
994
+ }
995
+ const KrustyRecord = /* @__PURE__ */ core.$constructor(
996
+ "KrustyRecord",
997
+ (inst, def) => {
998
+ const coreInit = core.$ZodRecord.init;
999
+ coreInit(inst, def);
1000
+ KrustyType.init(inst, def);
1001
+ inst.keyType = def.keyType;
1002
+ inst.valueType = def.valueType;
1003
+ }
1004
+ );
1005
+ function record(keyType, valueType, params) {
1006
+ return new KrustyRecord({
1007
+ type: "record",
1008
+ keyType,
1009
+ valueType,
1010
+ ...util.normalizeParams(params)
1011
+ });
1012
+ }
1013
+ function partialRecord(keyType, valueType, params) {
1014
+ const k = core.clone(keyType);
1015
+ k._zod.values = void 0;
1016
+ return new KrustyRecord({
1017
+ type: "record",
1018
+ keyType: k,
1019
+ valueType,
1020
+ ...util.normalizeParams(params)
1021
+ });
1022
+ }
1023
+ const KrustyMap = /* @__PURE__ */ core.$constructor(
1024
+ "KrustyMap",
1025
+ (inst, def) => {
1026
+ const coreInit = core.$ZodMap.init;
1027
+ coreInit(inst, def);
1028
+ KrustyType.init(inst, def);
1029
+ inst.keyType = def.keyType;
1030
+ inst.valueType = def.valueType;
1031
+ }
1032
+ );
1033
+ function map(keyType, valueType, params) {
1034
+ return new KrustyMap({
1035
+ type: "map",
1036
+ keyType,
1037
+ valueType,
1038
+ ...util.normalizeParams(params)
1039
+ });
1040
+ }
1041
+ const KrustySet = /* @__PURE__ */ core.$constructor(
1042
+ "KrustySet",
1043
+ (inst, def) => {
1044
+ const coreInit = core.$ZodSet.init;
1045
+ coreInit(inst, def);
1046
+ KrustyType.init(inst, def);
1047
+ inst.min = (...args) => inst.check(core._minSize(...args));
1048
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
1049
+ inst.max = (...args) => inst.check(core._maxSize(...args));
1050
+ inst.size = (...args) => inst.check(core._size(...args));
1051
+ }
1052
+ );
1053
+ function set(valueType, params) {
1054
+ return new KrustySet({
1055
+ type: "set",
1056
+ valueType,
1057
+ ...util.normalizeParams(params)
1058
+ });
1059
+ }
1060
+ const KrustyEnum = /* @__PURE__ */ core.$constructor(
1061
+ "KrustyEnum",
1062
+ (inst, def) => {
1063
+ const coreInit = core.$ZodEnum.init;
1064
+ coreInit(inst, def);
1065
+ KrustyType.init(inst, def);
1066
+ inst.enum = def.entries;
1067
+ inst.options = Object.values(def.entries);
1068
+ const keys = new Set(Object.keys(def.entries));
1069
+ inst.extract = (values, params) => {
1070
+ const newEntries = {};
1071
+ for (const value of values) {
1072
+ if (keys.has(value)) {
1073
+ newEntries[value] = def.entries[value];
1074
+ } else throw new Error(`Key ${value} not found in enum`);
802
1075
  }
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 }];
1076
+ return new KrustyEnum({
1077
+ ...def,
1078
+ checks: [],
1079
+ ...util.normalizeParams(params),
1080
+ entries: newEntries
1081
+ });
1082
+ };
1083
+ inst.exclude = (values, params) => {
1084
+ const newEntries = { ...def.entries };
1085
+ for (const value of values) {
1086
+ if (keys.has(value)) {
1087
+ delete newEntries[value];
1088
+ } else throw new Error(`Key ${value} not found in enum`);
822
1089
  }
823
- case ZodFirstPartyTypeKind.ZodLazy: {
824
- const currentLazyDepth = lazyDepth + 1;
825
- if (currentLazyDepth > this.maxLazyDepth) {
826
- return [false, this.anyJsonSchema];
1090
+ return new KrustyEnum({
1091
+ ...def,
1092
+ checks: [],
1093
+ ...util.normalizeParams(params),
1094
+ entries: newEntries
1095
+ });
1096
+ };
1097
+ }
1098
+ );
1099
+ function _enum(values, params) {
1100
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1101
+ return new KrustyEnum({
1102
+ type: "enum",
1103
+ entries,
1104
+ ...util.normalizeParams(params)
1105
+ });
1106
+ }
1107
+ function nativeEnum(entries, params) {
1108
+ return new KrustyEnum({
1109
+ type: "enum",
1110
+ entries,
1111
+ ...util.normalizeParams(params)
1112
+ });
1113
+ }
1114
+ const KrustyLiteral = /* @__PURE__ */ core.$constructor(
1115
+ "KrustyLiteral",
1116
+ (inst, def) => {
1117
+ const coreInit = core.$ZodLiteral.init;
1118
+ coreInit(inst, def);
1119
+ KrustyType.init(inst, def);
1120
+ inst.values = new Set(def.values);
1121
+ Object.defineProperty(inst, "value", {
1122
+ get() {
1123
+ if (def.values.length > 1) {
1124
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
827
1125
  }
828
- const schema_ = schema;
829
- return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
1126
+ return def.values[0];
830
1127
  }
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 }];
1128
+ });
1129
+ }
1130
+ );
1131
+ function literal(value, params) {
1132
+ return new KrustyLiteral({
1133
+ type: "literal",
1134
+ values: Array.isArray(value) ? value : [value],
1135
+ ...util.normalizeParams(params)
1136
+ });
1137
+ }
1138
+ const KrustyFile = /* @__PURE__ */ core.$constructor(
1139
+ "KrustyFile",
1140
+ (inst, def) => {
1141
+ const coreInit = core.$ZodFile.init;
1142
+ coreInit(inst, def);
1143
+ KrustyType.init(inst, def);
1144
+ inst.min = (size, params) => inst.check(core._minSize(size, params));
1145
+ inst.max = (size, params) => inst.check(core._maxSize(size, params));
1146
+ inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
1147
+ }
1148
+ );
1149
+ function file(params) {
1150
+ return core._file(KrustyFile, params);
1151
+ }
1152
+ const KrustyTransform = /* @__PURE__ */ core.$constructor(
1153
+ "KrustyTransform",
1154
+ (inst, def) => {
1155
+ const coreInit = core.$ZodTransform.init;
1156
+ coreInit(inst, def);
1157
+ KrustyType.init(inst, def);
1158
+ inst._zod.parse = (payload, _ctx) => {
1159
+ if (_ctx.direction === "backward") {
1160
+ throw new core.$ZodEncodeError(inst.constructor.name);
866
1161
  }
867
- case ZodFirstPartyTypeKind.ZodEffects: {
868
- const schema_ = schema;
869
- if (schema_._def.effect.type === "transform" && options.strategy === "output") {
870
- return [false, this.anyJsonSchema];
1162
+ payload.addIssue = (issue) => {
1163
+ if (typeof issue === "string") {
1164
+ payload.issues.push(util.issue(issue, payload.value, def));
1165
+ } else {
1166
+ const _issue = issue;
1167
+ if (_issue.fatal) _issue.continue = false;
1168
+ _issue.code ??= "custom";
1169
+ _issue.input ??= payload.value;
1170
+ _issue.inst ??= inst;
1171
+ payload.issues.push(util.issue(_issue));
871
1172
  }
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" }] }];
1173
+ };
1174
+ const output = def.transform(payload.value, payload);
1175
+ if (output instanceof Promise) {
1176
+ return output.then((output2) => {
1177
+ payload.value = output2;
1178
+ return payload;
1179
+ });
904
1180
  }
905
- }
906
- return [true, this.unsupportedJsonSchema];
1181
+ payload.value = output;
1182
+ return payload;
1183
+ };
1184
+ }
1185
+ );
1186
+ function transform(fn) {
1187
+ return new KrustyTransform({
1188
+ type: "transform",
1189
+ transform: fn
1190
+ });
1191
+ }
1192
+ const KrustyOptional = /* @__PURE__ */ core.$constructor(
1193
+ "KrustyOptional",
1194
+ (inst, def) => {
1195
+ const coreInit = core.$ZodOptional.init;
1196
+ coreInit(inst, def);
1197
+ KrustyType.init(inst, def);
1198
+ inst.unwrap = () => inst._zod.def.innerType;
1199
+ }
1200
+ );
1201
+ function optional(innerType) {
1202
+ return new KrustyOptional({
1203
+ type: "optional",
1204
+ innerType
1205
+ });
1206
+ }
1207
+ const KrustyNullable = /* @__PURE__ */ core.$constructor(
1208
+ "KrustyNullable",
1209
+ (inst, def) => {
1210
+ const coreInit = core.$ZodNullable.init;
1211
+ coreInit(inst, def);
1212
+ KrustyType.init(inst, def);
1213
+ inst.unwrap = () => inst._zod.def.innerType;
907
1214
  }
908
- #handleCustomZodDef(def) {
909
- const customZodDef = getCustomZodDef(def);
910
- if (!customZodDef) {
911
- return void 0;
1215
+ );
1216
+ function nullable(innerType) {
1217
+ return new KrustyNullable({
1218
+ type: "nullable",
1219
+ innerType
1220
+ });
1221
+ }
1222
+ function nullish(innerType) {
1223
+ return optional(nullable(innerType));
1224
+ }
1225
+ const KrustyDefault = /* @__PURE__ */ core.$constructor(
1226
+ "KrustyDefault",
1227
+ (inst, def) => {
1228
+ const coreInit = core.$ZodDefault.init;
1229
+ coreInit(inst, def);
1230
+ KrustyType.init(inst, def);
1231
+ inst.unwrap = () => inst._zod.def.innerType;
1232
+ inst.removeDefault = inst.unwrap;
1233
+ }
1234
+ );
1235
+ function _default(innerType, defaultValue) {
1236
+ return new KrustyDefault({
1237
+ type: "default",
1238
+ innerType,
1239
+ get defaultValue() {
1240
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
912
1241
  }
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
- }
1242
+ });
1243
+ }
1244
+ const KrustyPrefault = /* @__PURE__ */ core.$constructor(
1245
+ "KrustyPrefault",
1246
+ (inst, def) => {
1247
+ const coreInit = core.$ZodPrefault.init;
1248
+ coreInit(inst, def);
1249
+ KrustyType.init(inst, def);
1250
+ inst.unwrap = () => inst._zod.def.innerType;
1251
+ }
1252
+ );
1253
+ function prefault(innerType, defaultValue) {
1254
+ return new KrustyPrefault({
1255
+ type: "prefault",
1256
+ innerType,
1257
+ get defaultValue() {
1258
+ return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
934
1259
  }
1260
+ });
1261
+ }
1262
+ const KrustyNonOptional = /* @__PURE__ */ core.$constructor(
1263
+ "KrustyNonOptional",
1264
+ (inst, def) => {
1265
+ const coreInit = core.$ZodNonOptional.init;
1266
+ coreInit(inst, def);
1267
+ KrustyType.init(inst, def);
1268
+ inst.unwrap = () => inst._zod.def.innerType;
935
1269
  }
936
- #getZodTypeName(def) {
937
- return def.typeName;
1270
+ );
1271
+ function nonoptional(innerType, params) {
1272
+ return new KrustyNonOptional({
1273
+ type: "nonoptional",
1274
+ innerType,
1275
+ ...util.normalizeParams(params)
1276
+ });
1277
+ }
1278
+ const KrustySuccess = /* @__PURE__ */ core.$constructor(
1279
+ "KrustySuccess",
1280
+ (inst, def) => {
1281
+ const coreInit = core.$ZodSuccess.init;
1282
+ coreInit(inst, def);
1283
+ KrustyType.init(inst, def);
1284
+ inst.unwrap = () => inst._zod.def.innerType;
938
1285
  }
939
- #toArrayItemJsonSchema(required, schema, strategy) {
940
- if (required) {
941
- return schema;
942
- }
943
- return strategy === "input" ? { anyOf: [schema, this.unsupportedJsonSchema] } : { anyOf: [schema, { type: "null" }] };
1286
+ );
1287
+ function success(innerType) {
1288
+ return new KrustySuccess({
1289
+ type: "success",
1290
+ innerType
1291
+ });
1292
+ }
1293
+ const KrustyCatch = /* @__PURE__ */ core.$constructor(
1294
+ "KrustyCatch",
1295
+ (inst, def) => {
1296
+ const coreInit = core.$ZodCatch.init;
1297
+ coreInit(inst, def);
1298
+ KrustyType.init(inst, def);
1299
+ inst.unwrap = () => inst._zod.def.innerType;
1300
+ inst.removeCatch = inst.unwrap;
944
1301
  }
1302
+ );
1303
+ function _catch(innerType, catchValue) {
1304
+ return new KrustyCatch({
1305
+ type: "catch",
1306
+ innerType,
1307
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
1308
+ });
1309
+ }
1310
+ const KrustyNaN = /* @__PURE__ */ core.$constructor(
1311
+ "KrustyNaN",
1312
+ (inst, def) => {
1313
+ const coreInit = core.$ZodNaN.init;
1314
+ coreInit(inst, def);
1315
+ KrustyType.init(inst, def);
1316
+ }
1317
+ );
1318
+ function nan(params) {
1319
+ return core._nan(KrustyNaN, params);
1320
+ }
1321
+ const KrustyPipe = /* @__PURE__ */ core.$constructor(
1322
+ "KrustyPipe",
1323
+ (inst, def) => {
1324
+ const coreInit = core.$ZodPipe.init;
1325
+ coreInit(inst, def);
1326
+ KrustyType.init(inst, def);
1327
+ inst.in = def.in;
1328
+ inst.out = def.out;
1329
+ }
1330
+ );
1331
+ function pipe(in_, out) {
1332
+ return new KrustyPipe({
1333
+ type: "pipe",
1334
+ in: in_,
1335
+ out
1336
+ // ...util.normalizeParams(params),
1337
+ });
1338
+ }
1339
+ const KrustyCodec = /* @__PURE__ */ core.$constructor(
1340
+ "KrustyCodec",
1341
+ (inst, def) => {
1342
+ KrustyPipe.init(inst, def);
1343
+ const coreInit = core.$ZodCodec.init;
1344
+ coreInit(inst, def);
1345
+ }
1346
+ );
1347
+ function codec(in_, out, params) {
1348
+ return new KrustyCodec({
1349
+ type: "pipe",
1350
+ in: in_,
1351
+ out,
1352
+ transform: params.decode,
1353
+ reverseTransform: params.encode
1354
+ });
1355
+ }
1356
+ const KrustyReadonly = /* @__PURE__ */ core.$constructor(
1357
+ "KrustyReadonly",
1358
+ (inst, def) => {
1359
+ const coreInit = core.$ZodReadonly.init;
1360
+ coreInit(inst, def);
1361
+ KrustyType.init(inst, def);
1362
+ inst.unwrap = () => inst._zod.def.innerType;
1363
+ }
1364
+ );
1365
+ function readonly(innerType) {
1366
+ return new KrustyReadonly({
1367
+ type: "readonly",
1368
+ innerType
1369
+ });
1370
+ }
1371
+ const KrustyTemplateLiteral = /* @__PURE__ */ core.$constructor("KrustyTemplateLiteral", (inst, def) => {
1372
+ const coreInit = core.$ZodTemplateLiteral.init;
1373
+ coreInit(inst, def);
1374
+ KrustyType.init(inst, def);
1375
+ });
1376
+ function templateLiteral(parts, params) {
1377
+ return new KrustyTemplateLiteral({
1378
+ type: "template_literal",
1379
+ parts,
1380
+ ...util.normalizeParams(params)
1381
+ });
1382
+ }
1383
+ const KrustyLazy = /* @__PURE__ */ core.$constructor(
1384
+ "KrustyLazy",
1385
+ (inst, def) => {
1386
+ const coreInit = core.$ZodLazy.init;
1387
+ coreInit(inst, def);
1388
+ KrustyType.init(inst, def);
1389
+ inst.unwrap = () => inst._zod.def.getter();
1390
+ }
1391
+ );
1392
+ function lazy(getter) {
1393
+ return new KrustyLazy({
1394
+ type: "lazy",
1395
+ getter
1396
+ });
1397
+ }
1398
+ const KrustyPromise = /* @__PURE__ */ core.$constructor(
1399
+ "KrustyPromise",
1400
+ (inst, def) => {
1401
+ const coreInit = core.$ZodPromise.init;
1402
+ coreInit(inst, def);
1403
+ KrustyType.init(inst, def);
1404
+ inst.unwrap = () => inst._zod.def.innerType;
1405
+ }
1406
+ );
1407
+ function promise(innerType) {
1408
+ return new KrustyPromise({
1409
+ type: "promise",
1410
+ innerType
1411
+ });
1412
+ }
1413
+ const KrustyFunction = /* @__PURE__ */ core.$constructor(
1414
+ "KrustyFunction",
1415
+ (inst, def) => {
1416
+ const coreInit = core.$ZodFunction.init;
1417
+ coreInit(inst, def);
1418
+ KrustyType.init(inst, def);
1419
+ }
1420
+ );
1421
+ function _function(params) {
1422
+ return new KrustyFunction({
1423
+ type: "function",
1424
+ input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
1425
+ output: params?.output ?? unknown()
1426
+ });
1427
+ }
1428
+ const KrustyCustom = /* @__PURE__ */ core.$constructor(
1429
+ "KrustyCustom",
1430
+ (inst, def) => {
1431
+ const coreInit = core.$ZodCustom.init;
1432
+ coreInit(inst, def);
1433
+ KrustyType.init(inst, def);
1434
+ }
1435
+ );
1436
+ function check(fn) {
1437
+ const ch = new core.$ZodCheck({
1438
+ check: "custom"
1439
+ // ...util.normalizeParams(params),
1440
+ });
1441
+ ch._zod.check = fn;
1442
+ return ch;
1443
+ }
1444
+ function custom(fn, _params) {
1445
+ return core._custom(KrustyCustom, fn ?? (() => true), _params);
1446
+ }
1447
+ function refine(fn, _params = {}) {
1448
+ return core._refine(KrustyCustom, fn, _params);
1449
+ }
1450
+ function superRefine(fn) {
1451
+ return core._superRefine(fn);
1452
+ }
1453
+ function _instanceof(cls, params = {
1454
+ error: `Input not instance of ${cls.name}`
1455
+ }) {
1456
+ const inst = new KrustyCustom({
1457
+ type: "custom",
1458
+ check: "custom",
1459
+ fn: (data) => data instanceof cls,
1460
+ abort: true,
1461
+ ...util.normalizeParams(params)
1462
+ });
1463
+ inst._zod.bag.Class = cls;
1464
+ return inst;
1465
+ }
1466
+ const stringbool = (...args) => core._stringbool(
1467
+ {
1468
+ Codec: KrustyCodec,
1469
+ Boolean: KrustyBoolean,
1470
+ String: KrustyString
1471
+ },
1472
+ ...args
1473
+ );
1474
+ function json(params) {
1475
+ const jsonSchema = lazy(() => {
1476
+ return union([
1477
+ string(params),
1478
+ number(),
1479
+ boolean(),
1480
+ _null(),
1481
+ array(jsonSchema),
1482
+ record(string(), jsonSchema)
1483
+ ]);
1484
+ });
1485
+ return jsonSchema;
945
1486
  }
946
1487
 
947
- const oz = {
948
- file,
949
- blob,
950
- url,
951
- regexp,
952
- openapi: customJsonSchema
953
- };
1488
+ class SchemaClass {
1489
+ string(params) {
1490
+ return string(params);
1491
+ }
1492
+ number(params) {
1493
+ return number(params);
1494
+ }
1495
+ int(params) {
1496
+ return this.number().int(params);
1497
+ }
1498
+ boolean(params) {
1499
+ return boolean(params);
1500
+ }
1501
+ null(params) {
1502
+ return _null(params);
1503
+ }
1504
+ array(element, params) {
1505
+ return array(element, params);
1506
+ }
1507
+ record(keyType, valueType, params) {
1508
+ return record(keyType, valueType, params);
1509
+ }
1510
+ union(options, params) {
1511
+ return union(options, params);
1512
+ }
1513
+ discriminatedUnion(discriminator, options, params) {
1514
+ return discriminatedUnion(discriminator, options, params);
1515
+ }
1516
+ object(shape, params) {
1517
+ return object(shape, params);
1518
+ }
1519
+ date(params) {
1520
+ return date(params);
1521
+ }
1522
+ datetime(params) {
1523
+ return datetime(params);
1524
+ }
1525
+ any() {
1526
+ return any();
1527
+ }
1528
+ unknown() {
1529
+ return unknown();
1530
+ }
1531
+ never(params) {
1532
+ return never(params);
1533
+ }
1534
+ lazy(getter) {
1535
+ return lazy(getter);
1536
+ }
1537
+ json(params) {
1538
+ return json(params);
1539
+ }
1540
+ /**
1541
+ * TODO: def need to expose
1542
+ * file
1543
+ * literal
1544
+ * nativeEnum
1545
+ */
1546
+ /**
1547
+ * TODO: decide how to handle non-serializeable values
1548
+ * TODO: decide what types to expose
1549
+ * function
1550
+ * promise
1551
+ * readonly
1552
+ * nan
1553
+ * success
1554
+ * set
1555
+ * map
1556
+ * partialRecord
1557
+ * tuple
1558
+ * intersection
1559
+ * keyof
1560
+ * symbol
1561
+ * bigint
1562
+ * blob
1563
+ */
1564
+ /**
1565
+ * TODO: decide what non-chained format helpers to expose
1566
+ * -- OBJECT
1567
+ * strictObject
1568
+ * looseObject
1569
+ * -- STRING
1570
+ * url
1571
+ * regexp
1572
+ * email
1573
+ * guid
1574
+ * uuid
1575
+ * uuidv4
1576
+ * uuidv6
1577
+ * uuidv7
1578
+ * url
1579
+ * httpUrl
1580
+ * emoji
1581
+ * nanoid
1582
+ * cuid
1583
+ * cuid2
1584
+ * ulid
1585
+ * xid
1586
+ * ksuid
1587
+ * jwt
1588
+ * hostname
1589
+ * hex
1590
+ * hash
1591
+ * ipv4
1592
+ * ipv6
1593
+ * cidrv4
1594
+ * cidrv6
1595
+ * base64
1596
+ * base64url
1597
+ * e164
1598
+ * -- NUMBER
1599
+ * float32
1600
+ * float64
1601
+ * int32
1602
+ * uint32
1603
+ * int64
1604
+ * uint64
1605
+ */
1606
+ /**
1607
+ * TODO: decide what other helper methods to expose
1608
+ * refine
1609
+ * superRefine
1610
+ * custom
1611
+ * check
1612
+ * codec
1613
+ * pipe
1614
+ * nonoptional
1615
+ * prefault
1616
+ * default
1617
+ * nullish
1618
+ * nullable
1619
+ * optional
1620
+ * transform
1621
+ * stringFormat
1622
+ */
1623
+ }
954
1624
 
955
- export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
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 };