@cipherstash/stack 0.16.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/README.md +2 -2
  3. package/dist/{chunk-CY5B4LIF.js → chunk-36AA7IBJ.js} +303 -204
  4. package/dist/chunk-36AA7IBJ.js.map +1 -0
  5. package/dist/{chunk-MD6742R6.js → chunk-4AVL4VZD.js} +1 -1
  6. package/dist/chunk-4AVL4VZD.js.map +1 -0
  7. package/dist/{chunk-4RNBI3UH.js → chunk-BNO32ZMV.js} +1 -1
  8. package/dist/chunk-BNO32ZMV.js.map +1 -0
  9. package/dist/{chunk-6FD7OBGM.js → chunk-HQANMV7R.js} +3 -3
  10. package/dist/chunk-HQANMV7R.js.map +1 -0
  11. package/dist/chunk-IADZCZEA.js +23 -0
  12. package/dist/chunk-IADZCZEA.js.map +1 -0
  13. package/dist/chunk-IBSK6P33.js +209 -0
  14. package/dist/chunk-IBSK6P33.js.map +1 -0
  15. package/dist/chunk-JSG2AMDI.js +17 -0
  16. package/dist/chunk-JSG2AMDI.js.map +1 -0
  17. package/dist/chunk-MP3SSDNN.js +4439 -0
  18. package/dist/chunk-MP3SSDNN.js.map +1 -0
  19. package/dist/chunk-OFQ555AX.js +191 -0
  20. package/dist/chunk-OFQ555AX.js.map +1 -0
  21. package/dist/chunk-PZ5AY32C.js +10 -0
  22. package/dist/chunk-PZ5AY32C.js.map +1 -0
  23. package/dist/chunk-U66S7VIF.js +435 -0
  24. package/dist/chunk-U66S7VIF.js.map +1 -0
  25. package/dist/{client-C_7TF8EL.d.cts → client-DSGHBN-g.d.cts} +209 -72
  26. package/dist/{client-BLbA6aFD.d.ts → client-DfCrlHXh.d.ts} +209 -72
  27. package/dist/client.cjs +4103 -43
  28. package/dist/client.cjs.map +1 -1
  29. package/dist/client.d.cts +5 -5
  30. package/dist/client.d.ts +5 -5
  31. package/dist/client.js +3 -1
  32. package/dist/drizzle/index.cjs +4139 -77
  33. package/dist/drizzle/index.cjs.map +1 -1
  34. package/dist/drizzle/index.d.cts +33 -33
  35. package/dist/drizzle/index.d.ts +33 -33
  36. package/dist/drizzle/index.js +39 -33
  37. package/dist/drizzle/index.js.map +1 -1
  38. package/dist/dynamodb/index.cjs +31 -14
  39. package/dist/dynamodb/index.cjs.map +1 -1
  40. package/dist/dynamodb/index.d.cts +12 -12
  41. package/dist/dynamodb/index.d.ts +12 -12
  42. package/dist/dynamodb/index.js +16 -12
  43. package/dist/dynamodb/index.js.map +1 -1
  44. package/dist/encryption/index.cjs +4611 -257
  45. package/dist/encryption/index.cjs.map +1 -1
  46. package/dist/encryption/index.d.cts +3 -3
  47. package/dist/encryption/index.d.ts +3 -3
  48. package/dist/encryption/index.js +35 -7
  49. package/dist/encryption/v3.cjs +7791 -0
  50. package/dist/encryption/v3.cjs.map +1 -0
  51. package/dist/encryption/v3.d.cts +100 -0
  52. package/dist/encryption/v3.d.ts +100 -0
  53. package/dist/encryption/v3.js +161 -0
  54. package/dist/encryption/v3.js.map +1 -0
  55. package/dist/eql/v3/index.cjs +612 -0
  56. package/dist/eql/v3/index.cjs.map +1 -0
  57. package/dist/eql/v3/index.d.cts +71 -0
  58. package/dist/eql/v3/index.d.ts +71 -0
  59. package/dist/eql/v3/index.js +89 -0
  60. package/dist/eql/v3/index.js.map +1 -0
  61. package/dist/errors/index.js +1 -0
  62. package/dist/identity/index.cjs +55 -35
  63. package/dist/identity/index.cjs.map +1 -1
  64. package/dist/identity/index.d.cts +54 -30
  65. package/dist/identity/index.d.ts +54 -30
  66. package/dist/identity/index.js +9 -177
  67. package/dist/identity/index.js.map +1 -1
  68. package/dist/index.cjs +4625 -273
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.d.cts +18 -7
  71. package/dist/index.d.ts +18 -7
  72. package/dist/index.js +20 -5
  73. package/dist/index.js.map +1 -1
  74. package/dist/schema/index.cjs +4108 -44
  75. package/dist/schema/index.cjs.map +1 -1
  76. package/dist/schema/index.d.cts +1 -1
  77. package/dist/schema/index.d.ts +1 -1
  78. package/dist/schema/index.js +3 -1
  79. package/dist/supabase/index.cjs +4500 -75
  80. package/dist/supabase/index.cjs.map +1 -1
  81. package/dist/supabase/index.d.cts +113 -34
  82. package/dist/supabase/index.d.ts +113 -34
  83. package/dist/supabase/index.js +350 -32
  84. package/dist/supabase/index.js.map +1 -1
  85. package/dist/table-CIH7jZ2h.d.ts +603 -0
  86. package/dist/table-DihEAlxG.d.cts +603 -0
  87. package/dist/{types-public-Dv-r6Ik0.d.ts → types-public-CpS5KjwX.d.cts} +209 -36
  88. package/dist/{types-public-Dv-r6Ik0.d.cts → types-public-CpS5KjwX.d.ts} +209 -36
  89. package/dist/types-public.cjs.map +1 -1
  90. package/dist/types-public.d.cts +2 -2
  91. package/dist/types-public.d.ts +2 -2
  92. package/dist/types-public.js +2 -1
  93. package/dist/wasm-inline.d.ts +1269 -0
  94. package/dist/wasm-inline.js +4594 -0
  95. package/dist/wasm-inline.js.map +1 -0
  96. package/package.json +63 -13
  97. package/dist/chunk-4RNBI3UH.js.map +0 -1
  98. package/dist/chunk-6FD7OBGM.js.map +0 -1
  99. package/dist/chunk-CY5B4LIF.js.map +0 -1
  100. package/dist/chunk-JDZ2QUUF.js +0 -381
  101. package/dist/chunk-JDZ2QUUF.js.map +0 -1
  102. package/dist/chunk-MD6742R6.js.map +0 -1
@@ -30,9 +30,4073 @@ __export(drizzle_exports, {
30
30
  module.exports = __toCommonJS(drizzle_exports);
31
31
  var import_pg_core = require("drizzle-orm/pg-core");
32
32
 
33
+ // src/drizzle/operators.ts
34
+ var import_drizzle_orm = require("drizzle-orm");
35
+
36
+ // src/types.ts
37
+ var queryTypes = {
38
+ orderAndRange: "orderAndRange",
39
+ freeTextSearch: "freeTextSearch",
40
+ equality: "equality",
41
+ steVecSelector: "steVecSelector",
42
+ steVecTerm: "steVecTerm",
43
+ searchableJson: "searchableJson"
44
+ };
45
+
46
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
47
+ var external_exports = {};
48
+ __export(external_exports, {
49
+ BRAND: () => BRAND,
50
+ DIRTY: () => DIRTY,
51
+ EMPTY_PATH: () => EMPTY_PATH,
52
+ INVALID: () => INVALID,
53
+ NEVER: () => NEVER,
54
+ OK: () => OK,
55
+ ParseStatus: () => ParseStatus,
56
+ Schema: () => ZodType,
57
+ ZodAny: () => ZodAny,
58
+ ZodArray: () => ZodArray,
59
+ ZodBigInt: () => ZodBigInt,
60
+ ZodBoolean: () => ZodBoolean,
61
+ ZodBranded: () => ZodBranded,
62
+ ZodCatch: () => ZodCatch,
63
+ ZodDate: () => ZodDate,
64
+ ZodDefault: () => ZodDefault,
65
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
66
+ ZodEffects: () => ZodEffects,
67
+ ZodEnum: () => ZodEnum,
68
+ ZodError: () => ZodError,
69
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
70
+ ZodFunction: () => ZodFunction,
71
+ ZodIntersection: () => ZodIntersection,
72
+ ZodIssueCode: () => ZodIssueCode,
73
+ ZodLazy: () => ZodLazy,
74
+ ZodLiteral: () => ZodLiteral,
75
+ ZodMap: () => ZodMap,
76
+ ZodNaN: () => ZodNaN,
77
+ ZodNativeEnum: () => ZodNativeEnum,
78
+ ZodNever: () => ZodNever,
79
+ ZodNull: () => ZodNull,
80
+ ZodNullable: () => ZodNullable,
81
+ ZodNumber: () => ZodNumber,
82
+ ZodObject: () => ZodObject,
83
+ ZodOptional: () => ZodOptional,
84
+ ZodParsedType: () => ZodParsedType,
85
+ ZodPipeline: () => ZodPipeline,
86
+ ZodPromise: () => ZodPromise,
87
+ ZodReadonly: () => ZodReadonly,
88
+ ZodRecord: () => ZodRecord,
89
+ ZodSchema: () => ZodType,
90
+ ZodSet: () => ZodSet,
91
+ ZodString: () => ZodString,
92
+ ZodSymbol: () => ZodSymbol,
93
+ ZodTransformer: () => ZodEffects,
94
+ ZodTuple: () => ZodTuple,
95
+ ZodType: () => ZodType,
96
+ ZodUndefined: () => ZodUndefined,
97
+ ZodUnion: () => ZodUnion,
98
+ ZodUnknown: () => ZodUnknown,
99
+ ZodVoid: () => ZodVoid,
100
+ addIssueToContext: () => addIssueToContext,
101
+ any: () => anyType,
102
+ array: () => arrayType,
103
+ bigint: () => bigIntType,
104
+ boolean: () => booleanType,
105
+ coerce: () => coerce,
106
+ custom: () => custom,
107
+ date: () => dateType,
108
+ datetimeRegex: () => datetimeRegex,
109
+ defaultErrorMap: () => en_default,
110
+ discriminatedUnion: () => discriminatedUnionType,
111
+ effect: () => effectsType,
112
+ enum: () => enumType,
113
+ function: () => functionType,
114
+ getErrorMap: () => getErrorMap,
115
+ getParsedType: () => getParsedType,
116
+ instanceof: () => instanceOfType,
117
+ intersection: () => intersectionType,
118
+ isAborted: () => isAborted,
119
+ isAsync: () => isAsync,
120
+ isDirty: () => isDirty,
121
+ isValid: () => isValid,
122
+ late: () => late,
123
+ lazy: () => lazyType,
124
+ literal: () => literalType,
125
+ makeIssue: () => makeIssue,
126
+ map: () => mapType,
127
+ nan: () => nanType,
128
+ nativeEnum: () => nativeEnumType,
129
+ never: () => neverType,
130
+ null: () => nullType,
131
+ nullable: () => nullableType,
132
+ number: () => numberType,
133
+ object: () => objectType,
134
+ objectUtil: () => objectUtil,
135
+ oboolean: () => oboolean,
136
+ onumber: () => onumber,
137
+ optional: () => optionalType,
138
+ ostring: () => ostring,
139
+ pipeline: () => pipelineType,
140
+ preprocess: () => preprocessType,
141
+ promise: () => promiseType,
142
+ quotelessJson: () => quotelessJson,
143
+ record: () => recordType,
144
+ set: () => setType,
145
+ setErrorMap: () => setErrorMap,
146
+ strictObject: () => strictObjectType,
147
+ string: () => stringType,
148
+ symbol: () => symbolType,
149
+ transformer: () => effectsType,
150
+ tuple: () => tupleType,
151
+ undefined: () => undefinedType,
152
+ union: () => unionType,
153
+ unknown: () => unknownType,
154
+ util: () => util,
155
+ void: () => voidType
156
+ });
157
+
158
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
159
+ var util;
160
+ (function(util2) {
161
+ util2.assertEqual = (_) => {
162
+ };
163
+ function assertIs(_arg) {
164
+ }
165
+ util2.assertIs = assertIs;
166
+ function assertNever(_x) {
167
+ throw new Error();
168
+ }
169
+ util2.assertNever = assertNever;
170
+ util2.arrayToEnum = (items) => {
171
+ const obj = {};
172
+ for (const item of items) {
173
+ obj[item] = item;
174
+ }
175
+ return obj;
176
+ };
177
+ util2.getValidEnumValues = (obj) => {
178
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
179
+ const filtered = {};
180
+ for (const k of validKeys) {
181
+ filtered[k] = obj[k];
182
+ }
183
+ return util2.objectValues(filtered);
184
+ };
185
+ util2.objectValues = (obj) => {
186
+ return util2.objectKeys(obj).map(function(e) {
187
+ return obj[e];
188
+ });
189
+ };
190
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
191
+ const keys = [];
192
+ for (const key in object) {
193
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
194
+ keys.push(key);
195
+ }
196
+ }
197
+ return keys;
198
+ };
199
+ util2.find = (arr, checker) => {
200
+ for (const item of arr) {
201
+ if (checker(item))
202
+ return item;
203
+ }
204
+ return void 0;
205
+ };
206
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
207
+ function joinValues(array, separator = " | ") {
208
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
209
+ }
210
+ util2.joinValues = joinValues;
211
+ util2.jsonStringifyReplacer = (_, value) => {
212
+ if (typeof value === "bigint") {
213
+ return value.toString();
214
+ }
215
+ return value;
216
+ };
217
+ })(util || (util = {}));
218
+ var objectUtil;
219
+ (function(objectUtil2) {
220
+ objectUtil2.mergeShapes = (first, second) => {
221
+ return {
222
+ ...first,
223
+ ...second
224
+ // second overwrites first
225
+ };
226
+ };
227
+ })(objectUtil || (objectUtil = {}));
228
+ var ZodParsedType = util.arrayToEnum([
229
+ "string",
230
+ "nan",
231
+ "number",
232
+ "integer",
233
+ "float",
234
+ "boolean",
235
+ "date",
236
+ "bigint",
237
+ "symbol",
238
+ "function",
239
+ "undefined",
240
+ "null",
241
+ "array",
242
+ "object",
243
+ "unknown",
244
+ "promise",
245
+ "void",
246
+ "never",
247
+ "map",
248
+ "set"
249
+ ]);
250
+ var getParsedType = (data) => {
251
+ const t = typeof data;
252
+ switch (t) {
253
+ case "undefined":
254
+ return ZodParsedType.undefined;
255
+ case "string":
256
+ return ZodParsedType.string;
257
+ case "number":
258
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
259
+ case "boolean":
260
+ return ZodParsedType.boolean;
261
+ case "function":
262
+ return ZodParsedType.function;
263
+ case "bigint":
264
+ return ZodParsedType.bigint;
265
+ case "symbol":
266
+ return ZodParsedType.symbol;
267
+ case "object":
268
+ if (Array.isArray(data)) {
269
+ return ZodParsedType.array;
270
+ }
271
+ if (data === null) {
272
+ return ZodParsedType.null;
273
+ }
274
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
275
+ return ZodParsedType.promise;
276
+ }
277
+ if (typeof Map !== "undefined" && data instanceof Map) {
278
+ return ZodParsedType.map;
279
+ }
280
+ if (typeof Set !== "undefined" && data instanceof Set) {
281
+ return ZodParsedType.set;
282
+ }
283
+ if (typeof Date !== "undefined" && data instanceof Date) {
284
+ return ZodParsedType.date;
285
+ }
286
+ return ZodParsedType.object;
287
+ default:
288
+ return ZodParsedType.unknown;
289
+ }
290
+ };
291
+
292
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
293
+ var ZodIssueCode = util.arrayToEnum([
294
+ "invalid_type",
295
+ "invalid_literal",
296
+ "custom",
297
+ "invalid_union",
298
+ "invalid_union_discriminator",
299
+ "invalid_enum_value",
300
+ "unrecognized_keys",
301
+ "invalid_arguments",
302
+ "invalid_return_type",
303
+ "invalid_date",
304
+ "invalid_string",
305
+ "too_small",
306
+ "too_big",
307
+ "invalid_intersection_types",
308
+ "not_multiple_of",
309
+ "not_finite"
310
+ ]);
311
+ var quotelessJson = (obj) => {
312
+ const json = JSON.stringify(obj, null, 2);
313
+ return json.replace(/"([^"]+)":/g, "$1:");
314
+ };
315
+ var ZodError = class _ZodError extends Error {
316
+ get errors() {
317
+ return this.issues;
318
+ }
319
+ constructor(issues) {
320
+ super();
321
+ this.issues = [];
322
+ this.addIssue = (sub) => {
323
+ this.issues = [...this.issues, sub];
324
+ };
325
+ this.addIssues = (subs = []) => {
326
+ this.issues = [...this.issues, ...subs];
327
+ };
328
+ const actualProto = new.target.prototype;
329
+ if (Object.setPrototypeOf) {
330
+ Object.setPrototypeOf(this, actualProto);
331
+ } else {
332
+ this.__proto__ = actualProto;
333
+ }
334
+ this.name = "ZodError";
335
+ this.issues = issues;
336
+ }
337
+ format(_mapper) {
338
+ const mapper = _mapper || function(issue) {
339
+ return issue.message;
340
+ };
341
+ const fieldErrors = { _errors: [] };
342
+ const processError = (error) => {
343
+ for (const issue of error.issues) {
344
+ if (issue.code === "invalid_union") {
345
+ issue.unionErrors.map(processError);
346
+ } else if (issue.code === "invalid_return_type") {
347
+ processError(issue.returnTypeError);
348
+ } else if (issue.code === "invalid_arguments") {
349
+ processError(issue.argumentsError);
350
+ } else if (issue.path.length === 0) {
351
+ fieldErrors._errors.push(mapper(issue));
352
+ } else {
353
+ let curr = fieldErrors;
354
+ let i = 0;
355
+ while (i < issue.path.length) {
356
+ const el = issue.path[i];
357
+ const terminal = i === issue.path.length - 1;
358
+ if (!terminal) {
359
+ curr[el] = curr[el] || { _errors: [] };
360
+ } else {
361
+ curr[el] = curr[el] || { _errors: [] };
362
+ curr[el]._errors.push(mapper(issue));
363
+ }
364
+ curr = curr[el];
365
+ i++;
366
+ }
367
+ }
368
+ }
369
+ };
370
+ processError(this);
371
+ return fieldErrors;
372
+ }
373
+ static assert(value) {
374
+ if (!(value instanceof _ZodError)) {
375
+ throw new Error(`Not a ZodError: ${value}`);
376
+ }
377
+ }
378
+ toString() {
379
+ return this.message;
380
+ }
381
+ get message() {
382
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
383
+ }
384
+ get isEmpty() {
385
+ return this.issues.length === 0;
386
+ }
387
+ flatten(mapper = (issue) => issue.message) {
388
+ const fieldErrors = {};
389
+ const formErrors = [];
390
+ for (const sub of this.issues) {
391
+ if (sub.path.length > 0) {
392
+ const firstEl = sub.path[0];
393
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
394
+ fieldErrors[firstEl].push(mapper(sub));
395
+ } else {
396
+ formErrors.push(mapper(sub));
397
+ }
398
+ }
399
+ return { formErrors, fieldErrors };
400
+ }
401
+ get formErrors() {
402
+ return this.flatten();
403
+ }
404
+ };
405
+ ZodError.create = (issues) => {
406
+ const error = new ZodError(issues);
407
+ return error;
408
+ };
409
+
410
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
411
+ var errorMap = (issue, _ctx) => {
412
+ let message;
413
+ switch (issue.code) {
414
+ case ZodIssueCode.invalid_type:
415
+ if (issue.received === ZodParsedType.undefined) {
416
+ message = "Required";
417
+ } else {
418
+ message = `Expected ${issue.expected}, received ${issue.received}`;
419
+ }
420
+ break;
421
+ case ZodIssueCode.invalid_literal:
422
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
423
+ break;
424
+ case ZodIssueCode.unrecognized_keys:
425
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
426
+ break;
427
+ case ZodIssueCode.invalid_union:
428
+ message = `Invalid input`;
429
+ break;
430
+ case ZodIssueCode.invalid_union_discriminator:
431
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
432
+ break;
433
+ case ZodIssueCode.invalid_enum_value:
434
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
435
+ break;
436
+ case ZodIssueCode.invalid_arguments:
437
+ message = `Invalid function arguments`;
438
+ break;
439
+ case ZodIssueCode.invalid_return_type:
440
+ message = `Invalid function return type`;
441
+ break;
442
+ case ZodIssueCode.invalid_date:
443
+ message = `Invalid date`;
444
+ break;
445
+ case ZodIssueCode.invalid_string:
446
+ if (typeof issue.validation === "object") {
447
+ if ("includes" in issue.validation) {
448
+ message = `Invalid input: must include "${issue.validation.includes}"`;
449
+ if (typeof issue.validation.position === "number") {
450
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
451
+ }
452
+ } else if ("startsWith" in issue.validation) {
453
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
454
+ } else if ("endsWith" in issue.validation) {
455
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
456
+ } else {
457
+ util.assertNever(issue.validation);
458
+ }
459
+ } else if (issue.validation !== "regex") {
460
+ message = `Invalid ${issue.validation}`;
461
+ } else {
462
+ message = "Invalid";
463
+ }
464
+ break;
465
+ case ZodIssueCode.too_small:
466
+ if (issue.type === "array")
467
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
468
+ else if (issue.type === "string")
469
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
470
+ else if (issue.type === "number")
471
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
472
+ else if (issue.type === "bigint")
473
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
474
+ else if (issue.type === "date")
475
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
476
+ else
477
+ message = "Invalid input";
478
+ break;
479
+ case ZodIssueCode.too_big:
480
+ if (issue.type === "array")
481
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
482
+ else if (issue.type === "string")
483
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
484
+ else if (issue.type === "number")
485
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
486
+ else if (issue.type === "bigint")
487
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
488
+ else if (issue.type === "date")
489
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
490
+ else
491
+ message = "Invalid input";
492
+ break;
493
+ case ZodIssueCode.custom:
494
+ message = `Invalid input`;
495
+ break;
496
+ case ZodIssueCode.invalid_intersection_types:
497
+ message = `Intersection results could not be merged`;
498
+ break;
499
+ case ZodIssueCode.not_multiple_of:
500
+ message = `Number must be a multiple of ${issue.multipleOf}`;
501
+ break;
502
+ case ZodIssueCode.not_finite:
503
+ message = "Number must be finite";
504
+ break;
505
+ default:
506
+ message = _ctx.defaultError;
507
+ util.assertNever(issue);
508
+ }
509
+ return { message };
510
+ };
511
+ var en_default = errorMap;
512
+
513
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
514
+ var overrideErrorMap = en_default;
515
+ function setErrorMap(map) {
516
+ overrideErrorMap = map;
517
+ }
518
+ function getErrorMap() {
519
+ return overrideErrorMap;
520
+ }
521
+
522
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
523
+ var makeIssue = (params) => {
524
+ const { data, path, errorMaps, issueData } = params;
525
+ const fullPath = [...path, ...issueData.path || []];
526
+ const fullIssue = {
527
+ ...issueData,
528
+ path: fullPath
529
+ };
530
+ if (issueData.message !== void 0) {
531
+ return {
532
+ ...issueData,
533
+ path: fullPath,
534
+ message: issueData.message
535
+ };
536
+ }
537
+ let errorMessage = "";
538
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
539
+ for (const map of maps) {
540
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
541
+ }
542
+ return {
543
+ ...issueData,
544
+ path: fullPath,
545
+ message: errorMessage
546
+ };
547
+ };
548
+ var EMPTY_PATH = [];
549
+ function addIssueToContext(ctx, issueData) {
550
+ const overrideMap = getErrorMap();
551
+ const issue = makeIssue({
552
+ issueData,
553
+ data: ctx.data,
554
+ path: ctx.path,
555
+ errorMaps: [
556
+ ctx.common.contextualErrorMap,
557
+ // contextual error map is first priority
558
+ ctx.schemaErrorMap,
559
+ // then schema-bound map if available
560
+ overrideMap,
561
+ // then global override map
562
+ overrideMap === en_default ? void 0 : en_default
563
+ // then global default map
564
+ ].filter((x) => !!x)
565
+ });
566
+ ctx.common.issues.push(issue);
567
+ }
568
+ var ParseStatus = class _ParseStatus {
569
+ constructor() {
570
+ this.value = "valid";
571
+ }
572
+ dirty() {
573
+ if (this.value === "valid")
574
+ this.value = "dirty";
575
+ }
576
+ abort() {
577
+ if (this.value !== "aborted")
578
+ this.value = "aborted";
579
+ }
580
+ static mergeArray(status, results) {
581
+ const arrayValue = [];
582
+ for (const s of results) {
583
+ if (s.status === "aborted")
584
+ return INVALID;
585
+ if (s.status === "dirty")
586
+ status.dirty();
587
+ arrayValue.push(s.value);
588
+ }
589
+ return { status: status.value, value: arrayValue };
590
+ }
591
+ static async mergeObjectAsync(status, pairs) {
592
+ const syncPairs = [];
593
+ for (const pair of pairs) {
594
+ const key = await pair.key;
595
+ const value = await pair.value;
596
+ syncPairs.push({
597
+ key,
598
+ value
599
+ });
600
+ }
601
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
602
+ }
603
+ static mergeObjectSync(status, pairs) {
604
+ const finalObject = {};
605
+ for (const pair of pairs) {
606
+ const { key, value } = pair;
607
+ if (key.status === "aborted")
608
+ return INVALID;
609
+ if (value.status === "aborted")
610
+ return INVALID;
611
+ if (key.status === "dirty")
612
+ status.dirty();
613
+ if (value.status === "dirty")
614
+ status.dirty();
615
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
616
+ finalObject[key.value] = value.value;
617
+ }
618
+ }
619
+ return { status: status.value, value: finalObject };
620
+ }
621
+ };
622
+ var INVALID = Object.freeze({
623
+ status: "aborted"
624
+ });
625
+ var DIRTY = (value) => ({ status: "dirty", value });
626
+ var OK = (value) => ({ status: "valid", value });
627
+ var isAborted = (x) => x.status === "aborted";
628
+ var isDirty = (x) => x.status === "dirty";
629
+ var isValid = (x) => x.status === "valid";
630
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
631
+
632
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
633
+ var errorUtil;
634
+ (function(errorUtil2) {
635
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
636
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
637
+ })(errorUtil || (errorUtil = {}));
638
+
639
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
640
+ var ParseInputLazyPath = class {
641
+ constructor(parent, value, path, key) {
642
+ this._cachedPath = [];
643
+ this.parent = parent;
644
+ this.data = value;
645
+ this._path = path;
646
+ this._key = key;
647
+ }
648
+ get path() {
649
+ if (!this._cachedPath.length) {
650
+ if (Array.isArray(this._key)) {
651
+ this._cachedPath.push(...this._path, ...this._key);
652
+ } else {
653
+ this._cachedPath.push(...this._path, this._key);
654
+ }
655
+ }
656
+ return this._cachedPath;
657
+ }
658
+ };
659
+ var handleResult = (ctx, result) => {
660
+ if (isValid(result)) {
661
+ return { success: true, data: result.value };
662
+ } else {
663
+ if (!ctx.common.issues.length) {
664
+ throw new Error("Validation failed but no issues detected.");
665
+ }
666
+ return {
667
+ success: false,
668
+ get error() {
669
+ if (this._error)
670
+ return this._error;
671
+ const error = new ZodError(ctx.common.issues);
672
+ this._error = error;
673
+ return this._error;
674
+ }
675
+ };
676
+ }
677
+ };
678
+ function processCreateParams(params) {
679
+ if (!params)
680
+ return {};
681
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
682
+ if (errorMap2 && (invalid_type_error || required_error)) {
683
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
684
+ }
685
+ if (errorMap2)
686
+ return { errorMap: errorMap2, description };
687
+ const customMap = (iss, ctx) => {
688
+ const { message } = params;
689
+ if (iss.code === "invalid_enum_value") {
690
+ return { message: message ?? ctx.defaultError };
691
+ }
692
+ if (typeof ctx.data === "undefined") {
693
+ return { message: message ?? required_error ?? ctx.defaultError };
694
+ }
695
+ if (iss.code !== "invalid_type")
696
+ return { message: ctx.defaultError };
697
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
698
+ };
699
+ return { errorMap: customMap, description };
700
+ }
701
+ var ZodType = class {
702
+ get description() {
703
+ return this._def.description;
704
+ }
705
+ _getType(input) {
706
+ return getParsedType(input.data);
707
+ }
708
+ _getOrReturnCtx(input, ctx) {
709
+ return ctx || {
710
+ common: input.parent.common,
711
+ data: input.data,
712
+ parsedType: getParsedType(input.data),
713
+ schemaErrorMap: this._def.errorMap,
714
+ path: input.path,
715
+ parent: input.parent
716
+ };
717
+ }
718
+ _processInputParams(input) {
719
+ return {
720
+ status: new ParseStatus(),
721
+ ctx: {
722
+ common: input.parent.common,
723
+ data: input.data,
724
+ parsedType: getParsedType(input.data),
725
+ schemaErrorMap: this._def.errorMap,
726
+ path: input.path,
727
+ parent: input.parent
728
+ }
729
+ };
730
+ }
731
+ _parseSync(input) {
732
+ const result = this._parse(input);
733
+ if (isAsync(result)) {
734
+ throw new Error("Synchronous parse encountered promise.");
735
+ }
736
+ return result;
737
+ }
738
+ _parseAsync(input) {
739
+ const result = this._parse(input);
740
+ return Promise.resolve(result);
741
+ }
742
+ parse(data, params) {
743
+ const result = this.safeParse(data, params);
744
+ if (result.success)
745
+ return result.data;
746
+ throw result.error;
747
+ }
748
+ safeParse(data, params) {
749
+ const ctx = {
750
+ common: {
751
+ issues: [],
752
+ async: params?.async ?? false,
753
+ contextualErrorMap: params?.errorMap
754
+ },
755
+ path: params?.path || [],
756
+ schemaErrorMap: this._def.errorMap,
757
+ parent: null,
758
+ data,
759
+ parsedType: getParsedType(data)
760
+ };
761
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
762
+ return handleResult(ctx, result);
763
+ }
764
+ "~validate"(data) {
765
+ const ctx = {
766
+ common: {
767
+ issues: [],
768
+ async: !!this["~standard"].async
769
+ },
770
+ path: [],
771
+ schemaErrorMap: this._def.errorMap,
772
+ parent: null,
773
+ data,
774
+ parsedType: getParsedType(data)
775
+ };
776
+ if (!this["~standard"].async) {
777
+ try {
778
+ const result = this._parseSync({ data, path: [], parent: ctx });
779
+ return isValid(result) ? {
780
+ value: result.value
781
+ } : {
782
+ issues: ctx.common.issues
783
+ };
784
+ } catch (err) {
785
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
786
+ this["~standard"].async = true;
787
+ }
788
+ ctx.common = {
789
+ issues: [],
790
+ async: true
791
+ };
792
+ }
793
+ }
794
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
795
+ value: result.value
796
+ } : {
797
+ issues: ctx.common.issues
798
+ });
799
+ }
800
+ async parseAsync(data, params) {
801
+ const result = await this.safeParseAsync(data, params);
802
+ if (result.success)
803
+ return result.data;
804
+ throw result.error;
805
+ }
806
+ async safeParseAsync(data, params) {
807
+ const ctx = {
808
+ common: {
809
+ issues: [],
810
+ contextualErrorMap: params?.errorMap,
811
+ async: true
812
+ },
813
+ path: params?.path || [],
814
+ schemaErrorMap: this._def.errorMap,
815
+ parent: null,
816
+ data,
817
+ parsedType: getParsedType(data)
818
+ };
819
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
820
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
821
+ return handleResult(ctx, result);
822
+ }
823
+ refine(check, message) {
824
+ const getIssueProperties = (val) => {
825
+ if (typeof message === "string" || typeof message === "undefined") {
826
+ return { message };
827
+ } else if (typeof message === "function") {
828
+ return message(val);
829
+ } else {
830
+ return message;
831
+ }
832
+ };
833
+ return this._refinement((val, ctx) => {
834
+ const result = check(val);
835
+ const setError = () => ctx.addIssue({
836
+ code: ZodIssueCode.custom,
837
+ ...getIssueProperties(val)
838
+ });
839
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
840
+ return result.then((data) => {
841
+ if (!data) {
842
+ setError();
843
+ return false;
844
+ } else {
845
+ return true;
846
+ }
847
+ });
848
+ }
849
+ if (!result) {
850
+ setError();
851
+ return false;
852
+ } else {
853
+ return true;
854
+ }
855
+ });
856
+ }
857
+ refinement(check, refinementData) {
858
+ return this._refinement((val, ctx) => {
859
+ if (!check(val)) {
860
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
861
+ return false;
862
+ } else {
863
+ return true;
864
+ }
865
+ });
866
+ }
867
+ _refinement(refinement) {
868
+ return new ZodEffects({
869
+ schema: this,
870
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
871
+ effect: { type: "refinement", refinement }
872
+ });
873
+ }
874
+ superRefine(refinement) {
875
+ return this._refinement(refinement);
876
+ }
877
+ constructor(def) {
878
+ this.spa = this.safeParseAsync;
879
+ this._def = def;
880
+ this.parse = this.parse.bind(this);
881
+ this.safeParse = this.safeParse.bind(this);
882
+ this.parseAsync = this.parseAsync.bind(this);
883
+ this.safeParseAsync = this.safeParseAsync.bind(this);
884
+ this.spa = this.spa.bind(this);
885
+ this.refine = this.refine.bind(this);
886
+ this.refinement = this.refinement.bind(this);
887
+ this.superRefine = this.superRefine.bind(this);
888
+ this.optional = this.optional.bind(this);
889
+ this.nullable = this.nullable.bind(this);
890
+ this.nullish = this.nullish.bind(this);
891
+ this.array = this.array.bind(this);
892
+ this.promise = this.promise.bind(this);
893
+ this.or = this.or.bind(this);
894
+ this.and = this.and.bind(this);
895
+ this.transform = this.transform.bind(this);
896
+ this.brand = this.brand.bind(this);
897
+ this.default = this.default.bind(this);
898
+ this.catch = this.catch.bind(this);
899
+ this.describe = this.describe.bind(this);
900
+ this.pipe = this.pipe.bind(this);
901
+ this.readonly = this.readonly.bind(this);
902
+ this.isNullable = this.isNullable.bind(this);
903
+ this.isOptional = this.isOptional.bind(this);
904
+ this["~standard"] = {
905
+ version: 1,
906
+ vendor: "zod",
907
+ validate: (data) => this["~validate"](data)
908
+ };
909
+ }
910
+ optional() {
911
+ return ZodOptional.create(this, this._def);
912
+ }
913
+ nullable() {
914
+ return ZodNullable.create(this, this._def);
915
+ }
916
+ nullish() {
917
+ return this.nullable().optional();
918
+ }
919
+ array() {
920
+ return ZodArray.create(this);
921
+ }
922
+ promise() {
923
+ return ZodPromise.create(this, this._def);
924
+ }
925
+ or(option) {
926
+ return ZodUnion.create([this, option], this._def);
927
+ }
928
+ and(incoming) {
929
+ return ZodIntersection.create(this, incoming, this._def);
930
+ }
931
+ transform(transform) {
932
+ return new ZodEffects({
933
+ ...processCreateParams(this._def),
934
+ schema: this,
935
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
936
+ effect: { type: "transform", transform }
937
+ });
938
+ }
939
+ default(def) {
940
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
941
+ return new ZodDefault({
942
+ ...processCreateParams(this._def),
943
+ innerType: this,
944
+ defaultValue: defaultValueFunc,
945
+ typeName: ZodFirstPartyTypeKind.ZodDefault
946
+ });
947
+ }
948
+ brand() {
949
+ return new ZodBranded({
950
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
951
+ type: this,
952
+ ...processCreateParams(this._def)
953
+ });
954
+ }
955
+ catch(def) {
956
+ const catchValueFunc = typeof def === "function" ? def : () => def;
957
+ return new ZodCatch({
958
+ ...processCreateParams(this._def),
959
+ innerType: this,
960
+ catchValue: catchValueFunc,
961
+ typeName: ZodFirstPartyTypeKind.ZodCatch
962
+ });
963
+ }
964
+ describe(description) {
965
+ const This = this.constructor;
966
+ return new This({
967
+ ...this._def,
968
+ description
969
+ });
970
+ }
971
+ pipe(target) {
972
+ return ZodPipeline.create(this, target);
973
+ }
974
+ readonly() {
975
+ return ZodReadonly.create(this);
976
+ }
977
+ isOptional() {
978
+ return this.safeParse(void 0).success;
979
+ }
980
+ isNullable() {
981
+ return this.safeParse(null).success;
982
+ }
983
+ };
984
+ var cuidRegex = /^c[^\s-]{8,}$/i;
985
+ var cuid2Regex = /^[0-9a-z]+$/;
986
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
987
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
988
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
989
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
990
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
991
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
992
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
993
+ var emojiRegex;
994
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
995
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
996
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
997
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
998
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
999
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1000
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
1001
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1002
+ function timeRegexSource(args) {
1003
+ let secondsRegexSource = `[0-5]\\d`;
1004
+ if (args.precision) {
1005
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1006
+ } else if (args.precision == null) {
1007
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1008
+ }
1009
+ const secondsQuantifier = args.precision ? "+" : "?";
1010
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1011
+ }
1012
+ function timeRegex(args) {
1013
+ return new RegExp(`^${timeRegexSource(args)}$`);
1014
+ }
1015
+ function datetimeRegex(args) {
1016
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1017
+ const opts = [];
1018
+ opts.push(args.local ? `Z?` : `Z`);
1019
+ if (args.offset)
1020
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1021
+ regex = `${regex}(${opts.join("|")})`;
1022
+ return new RegExp(`^${regex}$`);
1023
+ }
1024
+ function isValidIP(ip, version) {
1025
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1026
+ return true;
1027
+ }
1028
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1029
+ return true;
1030
+ }
1031
+ return false;
1032
+ }
1033
+ function isValidJWT(jwt, alg) {
1034
+ if (!jwtRegex.test(jwt))
1035
+ return false;
1036
+ try {
1037
+ const [header] = jwt.split(".");
1038
+ if (!header)
1039
+ return false;
1040
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1041
+ const decoded = JSON.parse(atob(base64));
1042
+ if (typeof decoded !== "object" || decoded === null)
1043
+ return false;
1044
+ if ("typ" in decoded && decoded?.typ !== "JWT")
1045
+ return false;
1046
+ if (!decoded.alg)
1047
+ return false;
1048
+ if (alg && decoded.alg !== alg)
1049
+ return false;
1050
+ return true;
1051
+ } catch {
1052
+ return false;
1053
+ }
1054
+ }
1055
+ function isValidCidr(ip, version) {
1056
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1057
+ return true;
1058
+ }
1059
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1060
+ return true;
1061
+ }
1062
+ return false;
1063
+ }
1064
+ var ZodString = class _ZodString extends ZodType {
1065
+ _parse(input) {
1066
+ if (this._def.coerce) {
1067
+ input.data = String(input.data);
1068
+ }
1069
+ const parsedType = this._getType(input);
1070
+ if (parsedType !== ZodParsedType.string) {
1071
+ const ctx2 = this._getOrReturnCtx(input);
1072
+ addIssueToContext(ctx2, {
1073
+ code: ZodIssueCode.invalid_type,
1074
+ expected: ZodParsedType.string,
1075
+ received: ctx2.parsedType
1076
+ });
1077
+ return INVALID;
1078
+ }
1079
+ const status = new ParseStatus();
1080
+ let ctx = void 0;
1081
+ for (const check of this._def.checks) {
1082
+ if (check.kind === "min") {
1083
+ if (input.data.length < check.value) {
1084
+ ctx = this._getOrReturnCtx(input, ctx);
1085
+ addIssueToContext(ctx, {
1086
+ code: ZodIssueCode.too_small,
1087
+ minimum: check.value,
1088
+ type: "string",
1089
+ inclusive: true,
1090
+ exact: false,
1091
+ message: check.message
1092
+ });
1093
+ status.dirty();
1094
+ }
1095
+ } else if (check.kind === "max") {
1096
+ if (input.data.length > check.value) {
1097
+ ctx = this._getOrReturnCtx(input, ctx);
1098
+ addIssueToContext(ctx, {
1099
+ code: ZodIssueCode.too_big,
1100
+ maximum: check.value,
1101
+ type: "string",
1102
+ inclusive: true,
1103
+ exact: false,
1104
+ message: check.message
1105
+ });
1106
+ status.dirty();
1107
+ }
1108
+ } else if (check.kind === "length") {
1109
+ const tooBig = input.data.length > check.value;
1110
+ const tooSmall = input.data.length < check.value;
1111
+ if (tooBig || tooSmall) {
1112
+ ctx = this._getOrReturnCtx(input, ctx);
1113
+ if (tooBig) {
1114
+ addIssueToContext(ctx, {
1115
+ code: ZodIssueCode.too_big,
1116
+ maximum: check.value,
1117
+ type: "string",
1118
+ inclusive: true,
1119
+ exact: true,
1120
+ message: check.message
1121
+ });
1122
+ } else if (tooSmall) {
1123
+ addIssueToContext(ctx, {
1124
+ code: ZodIssueCode.too_small,
1125
+ minimum: check.value,
1126
+ type: "string",
1127
+ inclusive: true,
1128
+ exact: true,
1129
+ message: check.message
1130
+ });
1131
+ }
1132
+ status.dirty();
1133
+ }
1134
+ } else if (check.kind === "email") {
1135
+ if (!emailRegex.test(input.data)) {
1136
+ ctx = this._getOrReturnCtx(input, ctx);
1137
+ addIssueToContext(ctx, {
1138
+ validation: "email",
1139
+ code: ZodIssueCode.invalid_string,
1140
+ message: check.message
1141
+ });
1142
+ status.dirty();
1143
+ }
1144
+ } else if (check.kind === "emoji") {
1145
+ if (!emojiRegex) {
1146
+ emojiRegex = new RegExp(_emojiRegex, "u");
1147
+ }
1148
+ if (!emojiRegex.test(input.data)) {
1149
+ ctx = this._getOrReturnCtx(input, ctx);
1150
+ addIssueToContext(ctx, {
1151
+ validation: "emoji",
1152
+ code: ZodIssueCode.invalid_string,
1153
+ message: check.message
1154
+ });
1155
+ status.dirty();
1156
+ }
1157
+ } else if (check.kind === "uuid") {
1158
+ if (!uuidRegex.test(input.data)) {
1159
+ ctx = this._getOrReturnCtx(input, ctx);
1160
+ addIssueToContext(ctx, {
1161
+ validation: "uuid",
1162
+ code: ZodIssueCode.invalid_string,
1163
+ message: check.message
1164
+ });
1165
+ status.dirty();
1166
+ }
1167
+ } else if (check.kind === "nanoid") {
1168
+ if (!nanoidRegex.test(input.data)) {
1169
+ ctx = this._getOrReturnCtx(input, ctx);
1170
+ addIssueToContext(ctx, {
1171
+ validation: "nanoid",
1172
+ code: ZodIssueCode.invalid_string,
1173
+ message: check.message
1174
+ });
1175
+ status.dirty();
1176
+ }
1177
+ } else if (check.kind === "cuid") {
1178
+ if (!cuidRegex.test(input.data)) {
1179
+ ctx = this._getOrReturnCtx(input, ctx);
1180
+ addIssueToContext(ctx, {
1181
+ validation: "cuid",
1182
+ code: ZodIssueCode.invalid_string,
1183
+ message: check.message
1184
+ });
1185
+ status.dirty();
1186
+ }
1187
+ } else if (check.kind === "cuid2") {
1188
+ if (!cuid2Regex.test(input.data)) {
1189
+ ctx = this._getOrReturnCtx(input, ctx);
1190
+ addIssueToContext(ctx, {
1191
+ validation: "cuid2",
1192
+ code: ZodIssueCode.invalid_string,
1193
+ message: check.message
1194
+ });
1195
+ status.dirty();
1196
+ }
1197
+ } else if (check.kind === "ulid") {
1198
+ if (!ulidRegex.test(input.data)) {
1199
+ ctx = this._getOrReturnCtx(input, ctx);
1200
+ addIssueToContext(ctx, {
1201
+ validation: "ulid",
1202
+ code: ZodIssueCode.invalid_string,
1203
+ message: check.message
1204
+ });
1205
+ status.dirty();
1206
+ }
1207
+ } else if (check.kind === "url") {
1208
+ try {
1209
+ new URL(input.data);
1210
+ } catch {
1211
+ ctx = this._getOrReturnCtx(input, ctx);
1212
+ addIssueToContext(ctx, {
1213
+ validation: "url",
1214
+ code: ZodIssueCode.invalid_string,
1215
+ message: check.message
1216
+ });
1217
+ status.dirty();
1218
+ }
1219
+ } else if (check.kind === "regex") {
1220
+ check.regex.lastIndex = 0;
1221
+ const testResult = check.regex.test(input.data);
1222
+ if (!testResult) {
1223
+ ctx = this._getOrReturnCtx(input, ctx);
1224
+ addIssueToContext(ctx, {
1225
+ validation: "regex",
1226
+ code: ZodIssueCode.invalid_string,
1227
+ message: check.message
1228
+ });
1229
+ status.dirty();
1230
+ }
1231
+ } else if (check.kind === "trim") {
1232
+ input.data = input.data.trim();
1233
+ } else if (check.kind === "includes") {
1234
+ if (!input.data.includes(check.value, check.position)) {
1235
+ ctx = this._getOrReturnCtx(input, ctx);
1236
+ addIssueToContext(ctx, {
1237
+ code: ZodIssueCode.invalid_string,
1238
+ validation: { includes: check.value, position: check.position },
1239
+ message: check.message
1240
+ });
1241
+ status.dirty();
1242
+ }
1243
+ } else if (check.kind === "toLowerCase") {
1244
+ input.data = input.data.toLowerCase();
1245
+ } else if (check.kind === "toUpperCase") {
1246
+ input.data = input.data.toUpperCase();
1247
+ } else if (check.kind === "startsWith") {
1248
+ if (!input.data.startsWith(check.value)) {
1249
+ ctx = this._getOrReturnCtx(input, ctx);
1250
+ addIssueToContext(ctx, {
1251
+ code: ZodIssueCode.invalid_string,
1252
+ validation: { startsWith: check.value },
1253
+ message: check.message
1254
+ });
1255
+ status.dirty();
1256
+ }
1257
+ } else if (check.kind === "endsWith") {
1258
+ if (!input.data.endsWith(check.value)) {
1259
+ ctx = this._getOrReturnCtx(input, ctx);
1260
+ addIssueToContext(ctx, {
1261
+ code: ZodIssueCode.invalid_string,
1262
+ validation: { endsWith: check.value },
1263
+ message: check.message
1264
+ });
1265
+ status.dirty();
1266
+ }
1267
+ } else if (check.kind === "datetime") {
1268
+ const regex = datetimeRegex(check);
1269
+ if (!regex.test(input.data)) {
1270
+ ctx = this._getOrReturnCtx(input, ctx);
1271
+ addIssueToContext(ctx, {
1272
+ code: ZodIssueCode.invalid_string,
1273
+ validation: "datetime",
1274
+ message: check.message
1275
+ });
1276
+ status.dirty();
1277
+ }
1278
+ } else if (check.kind === "date") {
1279
+ const regex = dateRegex;
1280
+ if (!regex.test(input.data)) {
1281
+ ctx = this._getOrReturnCtx(input, ctx);
1282
+ addIssueToContext(ctx, {
1283
+ code: ZodIssueCode.invalid_string,
1284
+ validation: "date",
1285
+ message: check.message
1286
+ });
1287
+ status.dirty();
1288
+ }
1289
+ } else if (check.kind === "time") {
1290
+ const regex = timeRegex(check);
1291
+ if (!regex.test(input.data)) {
1292
+ ctx = this._getOrReturnCtx(input, ctx);
1293
+ addIssueToContext(ctx, {
1294
+ code: ZodIssueCode.invalid_string,
1295
+ validation: "time",
1296
+ message: check.message
1297
+ });
1298
+ status.dirty();
1299
+ }
1300
+ } else if (check.kind === "duration") {
1301
+ if (!durationRegex.test(input.data)) {
1302
+ ctx = this._getOrReturnCtx(input, ctx);
1303
+ addIssueToContext(ctx, {
1304
+ validation: "duration",
1305
+ code: ZodIssueCode.invalid_string,
1306
+ message: check.message
1307
+ });
1308
+ status.dirty();
1309
+ }
1310
+ } else if (check.kind === "ip") {
1311
+ if (!isValidIP(input.data, check.version)) {
1312
+ ctx = this._getOrReturnCtx(input, ctx);
1313
+ addIssueToContext(ctx, {
1314
+ validation: "ip",
1315
+ code: ZodIssueCode.invalid_string,
1316
+ message: check.message
1317
+ });
1318
+ status.dirty();
1319
+ }
1320
+ } else if (check.kind === "jwt") {
1321
+ if (!isValidJWT(input.data, check.alg)) {
1322
+ ctx = this._getOrReturnCtx(input, ctx);
1323
+ addIssueToContext(ctx, {
1324
+ validation: "jwt",
1325
+ code: ZodIssueCode.invalid_string,
1326
+ message: check.message
1327
+ });
1328
+ status.dirty();
1329
+ }
1330
+ } else if (check.kind === "cidr") {
1331
+ if (!isValidCidr(input.data, check.version)) {
1332
+ ctx = this._getOrReturnCtx(input, ctx);
1333
+ addIssueToContext(ctx, {
1334
+ validation: "cidr",
1335
+ code: ZodIssueCode.invalid_string,
1336
+ message: check.message
1337
+ });
1338
+ status.dirty();
1339
+ }
1340
+ } else if (check.kind === "base64") {
1341
+ if (!base64Regex.test(input.data)) {
1342
+ ctx = this._getOrReturnCtx(input, ctx);
1343
+ addIssueToContext(ctx, {
1344
+ validation: "base64",
1345
+ code: ZodIssueCode.invalid_string,
1346
+ message: check.message
1347
+ });
1348
+ status.dirty();
1349
+ }
1350
+ } else if (check.kind === "base64url") {
1351
+ if (!base64urlRegex.test(input.data)) {
1352
+ ctx = this._getOrReturnCtx(input, ctx);
1353
+ addIssueToContext(ctx, {
1354
+ validation: "base64url",
1355
+ code: ZodIssueCode.invalid_string,
1356
+ message: check.message
1357
+ });
1358
+ status.dirty();
1359
+ }
1360
+ } else {
1361
+ util.assertNever(check);
1362
+ }
1363
+ }
1364
+ return { status: status.value, value: input.data };
1365
+ }
1366
+ _regex(regex, validation, message) {
1367
+ return this.refinement((data) => regex.test(data), {
1368
+ validation,
1369
+ code: ZodIssueCode.invalid_string,
1370
+ ...errorUtil.errToObj(message)
1371
+ });
1372
+ }
1373
+ _addCheck(check) {
1374
+ return new _ZodString({
1375
+ ...this._def,
1376
+ checks: [...this._def.checks, check]
1377
+ });
1378
+ }
1379
+ email(message) {
1380
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1381
+ }
1382
+ url(message) {
1383
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1384
+ }
1385
+ emoji(message) {
1386
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1387
+ }
1388
+ uuid(message) {
1389
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1390
+ }
1391
+ nanoid(message) {
1392
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1393
+ }
1394
+ cuid(message) {
1395
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1396
+ }
1397
+ cuid2(message) {
1398
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1399
+ }
1400
+ ulid(message) {
1401
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1402
+ }
1403
+ base64(message) {
1404
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1405
+ }
1406
+ base64url(message) {
1407
+ return this._addCheck({
1408
+ kind: "base64url",
1409
+ ...errorUtil.errToObj(message)
1410
+ });
1411
+ }
1412
+ jwt(options) {
1413
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1414
+ }
1415
+ ip(options) {
1416
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1417
+ }
1418
+ cidr(options) {
1419
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1420
+ }
1421
+ datetime(options) {
1422
+ if (typeof options === "string") {
1423
+ return this._addCheck({
1424
+ kind: "datetime",
1425
+ precision: null,
1426
+ offset: false,
1427
+ local: false,
1428
+ message: options
1429
+ });
1430
+ }
1431
+ return this._addCheck({
1432
+ kind: "datetime",
1433
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1434
+ offset: options?.offset ?? false,
1435
+ local: options?.local ?? false,
1436
+ ...errorUtil.errToObj(options?.message)
1437
+ });
1438
+ }
1439
+ date(message) {
1440
+ return this._addCheck({ kind: "date", message });
1441
+ }
1442
+ time(options) {
1443
+ if (typeof options === "string") {
1444
+ return this._addCheck({
1445
+ kind: "time",
1446
+ precision: null,
1447
+ message: options
1448
+ });
1449
+ }
1450
+ return this._addCheck({
1451
+ kind: "time",
1452
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1453
+ ...errorUtil.errToObj(options?.message)
1454
+ });
1455
+ }
1456
+ duration(message) {
1457
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1458
+ }
1459
+ regex(regex, message) {
1460
+ return this._addCheck({
1461
+ kind: "regex",
1462
+ regex,
1463
+ ...errorUtil.errToObj(message)
1464
+ });
1465
+ }
1466
+ includes(value, options) {
1467
+ return this._addCheck({
1468
+ kind: "includes",
1469
+ value,
1470
+ position: options?.position,
1471
+ ...errorUtil.errToObj(options?.message)
1472
+ });
1473
+ }
1474
+ startsWith(value, message) {
1475
+ return this._addCheck({
1476
+ kind: "startsWith",
1477
+ value,
1478
+ ...errorUtil.errToObj(message)
1479
+ });
1480
+ }
1481
+ endsWith(value, message) {
1482
+ return this._addCheck({
1483
+ kind: "endsWith",
1484
+ value,
1485
+ ...errorUtil.errToObj(message)
1486
+ });
1487
+ }
1488
+ min(minLength, message) {
1489
+ return this._addCheck({
1490
+ kind: "min",
1491
+ value: minLength,
1492
+ ...errorUtil.errToObj(message)
1493
+ });
1494
+ }
1495
+ max(maxLength, message) {
1496
+ return this._addCheck({
1497
+ kind: "max",
1498
+ value: maxLength,
1499
+ ...errorUtil.errToObj(message)
1500
+ });
1501
+ }
1502
+ length(len, message) {
1503
+ return this._addCheck({
1504
+ kind: "length",
1505
+ value: len,
1506
+ ...errorUtil.errToObj(message)
1507
+ });
1508
+ }
1509
+ /**
1510
+ * Equivalent to `.min(1)`
1511
+ */
1512
+ nonempty(message) {
1513
+ return this.min(1, errorUtil.errToObj(message));
1514
+ }
1515
+ trim() {
1516
+ return new _ZodString({
1517
+ ...this._def,
1518
+ checks: [...this._def.checks, { kind: "trim" }]
1519
+ });
1520
+ }
1521
+ toLowerCase() {
1522
+ return new _ZodString({
1523
+ ...this._def,
1524
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1525
+ });
1526
+ }
1527
+ toUpperCase() {
1528
+ return new _ZodString({
1529
+ ...this._def,
1530
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1531
+ });
1532
+ }
1533
+ get isDatetime() {
1534
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1535
+ }
1536
+ get isDate() {
1537
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1538
+ }
1539
+ get isTime() {
1540
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1541
+ }
1542
+ get isDuration() {
1543
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1544
+ }
1545
+ get isEmail() {
1546
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1547
+ }
1548
+ get isURL() {
1549
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1550
+ }
1551
+ get isEmoji() {
1552
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1553
+ }
1554
+ get isUUID() {
1555
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1556
+ }
1557
+ get isNANOID() {
1558
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1559
+ }
1560
+ get isCUID() {
1561
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1562
+ }
1563
+ get isCUID2() {
1564
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1565
+ }
1566
+ get isULID() {
1567
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1568
+ }
1569
+ get isIP() {
1570
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1571
+ }
1572
+ get isCIDR() {
1573
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1574
+ }
1575
+ get isBase64() {
1576
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1577
+ }
1578
+ get isBase64url() {
1579
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1580
+ }
1581
+ get minLength() {
1582
+ let min = null;
1583
+ for (const ch of this._def.checks) {
1584
+ if (ch.kind === "min") {
1585
+ if (min === null || ch.value > min)
1586
+ min = ch.value;
1587
+ }
1588
+ }
1589
+ return min;
1590
+ }
1591
+ get maxLength() {
1592
+ let max = null;
1593
+ for (const ch of this._def.checks) {
1594
+ if (ch.kind === "max") {
1595
+ if (max === null || ch.value < max)
1596
+ max = ch.value;
1597
+ }
1598
+ }
1599
+ return max;
1600
+ }
1601
+ };
1602
+ ZodString.create = (params) => {
1603
+ return new ZodString({
1604
+ checks: [],
1605
+ typeName: ZodFirstPartyTypeKind.ZodString,
1606
+ coerce: params?.coerce ?? false,
1607
+ ...processCreateParams(params)
1608
+ });
1609
+ };
1610
+ function floatSafeRemainder(val, step) {
1611
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1612
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1613
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1614
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1615
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1616
+ return valInt % stepInt / 10 ** decCount;
1617
+ }
1618
+ var ZodNumber = class _ZodNumber extends ZodType {
1619
+ constructor() {
1620
+ super(...arguments);
1621
+ this.min = this.gte;
1622
+ this.max = this.lte;
1623
+ this.step = this.multipleOf;
1624
+ }
1625
+ _parse(input) {
1626
+ if (this._def.coerce) {
1627
+ input.data = Number(input.data);
1628
+ }
1629
+ const parsedType = this._getType(input);
1630
+ if (parsedType !== ZodParsedType.number) {
1631
+ const ctx2 = this._getOrReturnCtx(input);
1632
+ addIssueToContext(ctx2, {
1633
+ code: ZodIssueCode.invalid_type,
1634
+ expected: ZodParsedType.number,
1635
+ received: ctx2.parsedType
1636
+ });
1637
+ return INVALID;
1638
+ }
1639
+ let ctx = void 0;
1640
+ const status = new ParseStatus();
1641
+ for (const check of this._def.checks) {
1642
+ if (check.kind === "int") {
1643
+ if (!util.isInteger(input.data)) {
1644
+ ctx = this._getOrReturnCtx(input, ctx);
1645
+ addIssueToContext(ctx, {
1646
+ code: ZodIssueCode.invalid_type,
1647
+ expected: "integer",
1648
+ received: "float",
1649
+ message: check.message
1650
+ });
1651
+ status.dirty();
1652
+ }
1653
+ } else if (check.kind === "min") {
1654
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1655
+ if (tooSmall) {
1656
+ ctx = this._getOrReturnCtx(input, ctx);
1657
+ addIssueToContext(ctx, {
1658
+ code: ZodIssueCode.too_small,
1659
+ minimum: check.value,
1660
+ type: "number",
1661
+ inclusive: check.inclusive,
1662
+ exact: false,
1663
+ message: check.message
1664
+ });
1665
+ status.dirty();
1666
+ }
1667
+ } else if (check.kind === "max") {
1668
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1669
+ if (tooBig) {
1670
+ ctx = this._getOrReturnCtx(input, ctx);
1671
+ addIssueToContext(ctx, {
1672
+ code: ZodIssueCode.too_big,
1673
+ maximum: check.value,
1674
+ type: "number",
1675
+ inclusive: check.inclusive,
1676
+ exact: false,
1677
+ message: check.message
1678
+ });
1679
+ status.dirty();
1680
+ }
1681
+ } else if (check.kind === "multipleOf") {
1682
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1683
+ ctx = this._getOrReturnCtx(input, ctx);
1684
+ addIssueToContext(ctx, {
1685
+ code: ZodIssueCode.not_multiple_of,
1686
+ multipleOf: check.value,
1687
+ message: check.message
1688
+ });
1689
+ status.dirty();
1690
+ }
1691
+ } else if (check.kind === "finite") {
1692
+ if (!Number.isFinite(input.data)) {
1693
+ ctx = this._getOrReturnCtx(input, ctx);
1694
+ addIssueToContext(ctx, {
1695
+ code: ZodIssueCode.not_finite,
1696
+ message: check.message
1697
+ });
1698
+ status.dirty();
1699
+ }
1700
+ } else {
1701
+ util.assertNever(check);
1702
+ }
1703
+ }
1704
+ return { status: status.value, value: input.data };
1705
+ }
1706
+ gte(value, message) {
1707
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1708
+ }
1709
+ gt(value, message) {
1710
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1711
+ }
1712
+ lte(value, message) {
1713
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1714
+ }
1715
+ lt(value, message) {
1716
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1717
+ }
1718
+ setLimit(kind, value, inclusive, message) {
1719
+ return new _ZodNumber({
1720
+ ...this._def,
1721
+ checks: [
1722
+ ...this._def.checks,
1723
+ {
1724
+ kind,
1725
+ value,
1726
+ inclusive,
1727
+ message: errorUtil.toString(message)
1728
+ }
1729
+ ]
1730
+ });
1731
+ }
1732
+ _addCheck(check) {
1733
+ return new _ZodNumber({
1734
+ ...this._def,
1735
+ checks: [...this._def.checks, check]
1736
+ });
1737
+ }
1738
+ int(message) {
1739
+ return this._addCheck({
1740
+ kind: "int",
1741
+ message: errorUtil.toString(message)
1742
+ });
1743
+ }
1744
+ positive(message) {
1745
+ return this._addCheck({
1746
+ kind: "min",
1747
+ value: 0,
1748
+ inclusive: false,
1749
+ message: errorUtil.toString(message)
1750
+ });
1751
+ }
1752
+ negative(message) {
1753
+ return this._addCheck({
1754
+ kind: "max",
1755
+ value: 0,
1756
+ inclusive: false,
1757
+ message: errorUtil.toString(message)
1758
+ });
1759
+ }
1760
+ nonpositive(message) {
1761
+ return this._addCheck({
1762
+ kind: "max",
1763
+ value: 0,
1764
+ inclusive: true,
1765
+ message: errorUtil.toString(message)
1766
+ });
1767
+ }
1768
+ nonnegative(message) {
1769
+ return this._addCheck({
1770
+ kind: "min",
1771
+ value: 0,
1772
+ inclusive: true,
1773
+ message: errorUtil.toString(message)
1774
+ });
1775
+ }
1776
+ multipleOf(value, message) {
1777
+ return this._addCheck({
1778
+ kind: "multipleOf",
1779
+ value,
1780
+ message: errorUtil.toString(message)
1781
+ });
1782
+ }
1783
+ finite(message) {
1784
+ return this._addCheck({
1785
+ kind: "finite",
1786
+ message: errorUtil.toString(message)
1787
+ });
1788
+ }
1789
+ safe(message) {
1790
+ return this._addCheck({
1791
+ kind: "min",
1792
+ inclusive: true,
1793
+ value: Number.MIN_SAFE_INTEGER,
1794
+ message: errorUtil.toString(message)
1795
+ })._addCheck({
1796
+ kind: "max",
1797
+ inclusive: true,
1798
+ value: Number.MAX_SAFE_INTEGER,
1799
+ message: errorUtil.toString(message)
1800
+ });
1801
+ }
1802
+ get minValue() {
1803
+ let min = null;
1804
+ for (const ch of this._def.checks) {
1805
+ if (ch.kind === "min") {
1806
+ if (min === null || ch.value > min)
1807
+ min = ch.value;
1808
+ }
1809
+ }
1810
+ return min;
1811
+ }
1812
+ get maxValue() {
1813
+ let max = null;
1814
+ for (const ch of this._def.checks) {
1815
+ if (ch.kind === "max") {
1816
+ if (max === null || ch.value < max)
1817
+ max = ch.value;
1818
+ }
1819
+ }
1820
+ return max;
1821
+ }
1822
+ get isInt() {
1823
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1824
+ }
1825
+ get isFinite() {
1826
+ let max = null;
1827
+ let min = null;
1828
+ for (const ch of this._def.checks) {
1829
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1830
+ return true;
1831
+ } else if (ch.kind === "min") {
1832
+ if (min === null || ch.value > min)
1833
+ min = ch.value;
1834
+ } else if (ch.kind === "max") {
1835
+ if (max === null || ch.value < max)
1836
+ max = ch.value;
1837
+ }
1838
+ }
1839
+ return Number.isFinite(min) && Number.isFinite(max);
1840
+ }
1841
+ };
1842
+ ZodNumber.create = (params) => {
1843
+ return new ZodNumber({
1844
+ checks: [],
1845
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1846
+ coerce: params?.coerce || false,
1847
+ ...processCreateParams(params)
1848
+ });
1849
+ };
1850
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1851
+ constructor() {
1852
+ super(...arguments);
1853
+ this.min = this.gte;
1854
+ this.max = this.lte;
1855
+ }
1856
+ _parse(input) {
1857
+ if (this._def.coerce) {
1858
+ try {
1859
+ input.data = BigInt(input.data);
1860
+ } catch {
1861
+ return this._getInvalidInput(input);
1862
+ }
1863
+ }
1864
+ const parsedType = this._getType(input);
1865
+ if (parsedType !== ZodParsedType.bigint) {
1866
+ return this._getInvalidInput(input);
1867
+ }
1868
+ let ctx = void 0;
1869
+ const status = new ParseStatus();
1870
+ for (const check of this._def.checks) {
1871
+ if (check.kind === "min") {
1872
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1873
+ if (tooSmall) {
1874
+ ctx = this._getOrReturnCtx(input, ctx);
1875
+ addIssueToContext(ctx, {
1876
+ code: ZodIssueCode.too_small,
1877
+ type: "bigint",
1878
+ minimum: check.value,
1879
+ inclusive: check.inclusive,
1880
+ message: check.message
1881
+ });
1882
+ status.dirty();
1883
+ }
1884
+ } else if (check.kind === "max") {
1885
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1886
+ if (tooBig) {
1887
+ ctx = this._getOrReturnCtx(input, ctx);
1888
+ addIssueToContext(ctx, {
1889
+ code: ZodIssueCode.too_big,
1890
+ type: "bigint",
1891
+ maximum: check.value,
1892
+ inclusive: check.inclusive,
1893
+ message: check.message
1894
+ });
1895
+ status.dirty();
1896
+ }
1897
+ } else if (check.kind === "multipleOf") {
1898
+ if (input.data % check.value !== BigInt(0)) {
1899
+ ctx = this._getOrReturnCtx(input, ctx);
1900
+ addIssueToContext(ctx, {
1901
+ code: ZodIssueCode.not_multiple_of,
1902
+ multipleOf: check.value,
1903
+ message: check.message
1904
+ });
1905
+ status.dirty();
1906
+ }
1907
+ } else {
1908
+ util.assertNever(check);
1909
+ }
1910
+ }
1911
+ return { status: status.value, value: input.data };
1912
+ }
1913
+ _getInvalidInput(input) {
1914
+ const ctx = this._getOrReturnCtx(input);
1915
+ addIssueToContext(ctx, {
1916
+ code: ZodIssueCode.invalid_type,
1917
+ expected: ZodParsedType.bigint,
1918
+ received: ctx.parsedType
1919
+ });
1920
+ return INVALID;
1921
+ }
1922
+ gte(value, message) {
1923
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1924
+ }
1925
+ gt(value, message) {
1926
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1927
+ }
1928
+ lte(value, message) {
1929
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1930
+ }
1931
+ lt(value, message) {
1932
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1933
+ }
1934
+ setLimit(kind, value, inclusive, message) {
1935
+ return new _ZodBigInt({
1936
+ ...this._def,
1937
+ checks: [
1938
+ ...this._def.checks,
1939
+ {
1940
+ kind,
1941
+ value,
1942
+ inclusive,
1943
+ message: errorUtil.toString(message)
1944
+ }
1945
+ ]
1946
+ });
1947
+ }
1948
+ _addCheck(check) {
1949
+ return new _ZodBigInt({
1950
+ ...this._def,
1951
+ checks: [...this._def.checks, check]
1952
+ });
1953
+ }
1954
+ positive(message) {
1955
+ return this._addCheck({
1956
+ kind: "min",
1957
+ value: BigInt(0),
1958
+ inclusive: false,
1959
+ message: errorUtil.toString(message)
1960
+ });
1961
+ }
1962
+ negative(message) {
1963
+ return this._addCheck({
1964
+ kind: "max",
1965
+ value: BigInt(0),
1966
+ inclusive: false,
1967
+ message: errorUtil.toString(message)
1968
+ });
1969
+ }
1970
+ nonpositive(message) {
1971
+ return this._addCheck({
1972
+ kind: "max",
1973
+ value: BigInt(0),
1974
+ inclusive: true,
1975
+ message: errorUtil.toString(message)
1976
+ });
1977
+ }
1978
+ nonnegative(message) {
1979
+ return this._addCheck({
1980
+ kind: "min",
1981
+ value: BigInt(0),
1982
+ inclusive: true,
1983
+ message: errorUtil.toString(message)
1984
+ });
1985
+ }
1986
+ multipleOf(value, message) {
1987
+ return this._addCheck({
1988
+ kind: "multipleOf",
1989
+ value,
1990
+ message: errorUtil.toString(message)
1991
+ });
1992
+ }
1993
+ get minValue() {
1994
+ let min = null;
1995
+ for (const ch of this._def.checks) {
1996
+ if (ch.kind === "min") {
1997
+ if (min === null || ch.value > min)
1998
+ min = ch.value;
1999
+ }
2000
+ }
2001
+ return min;
2002
+ }
2003
+ get maxValue() {
2004
+ let max = null;
2005
+ for (const ch of this._def.checks) {
2006
+ if (ch.kind === "max") {
2007
+ if (max === null || ch.value < max)
2008
+ max = ch.value;
2009
+ }
2010
+ }
2011
+ return max;
2012
+ }
2013
+ };
2014
+ ZodBigInt.create = (params) => {
2015
+ return new ZodBigInt({
2016
+ checks: [],
2017
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2018
+ coerce: params?.coerce ?? false,
2019
+ ...processCreateParams(params)
2020
+ });
2021
+ };
2022
+ var ZodBoolean = class extends ZodType {
2023
+ _parse(input) {
2024
+ if (this._def.coerce) {
2025
+ input.data = Boolean(input.data);
2026
+ }
2027
+ const parsedType = this._getType(input);
2028
+ if (parsedType !== ZodParsedType.boolean) {
2029
+ const ctx = this._getOrReturnCtx(input);
2030
+ addIssueToContext(ctx, {
2031
+ code: ZodIssueCode.invalid_type,
2032
+ expected: ZodParsedType.boolean,
2033
+ received: ctx.parsedType
2034
+ });
2035
+ return INVALID;
2036
+ }
2037
+ return OK(input.data);
2038
+ }
2039
+ };
2040
+ ZodBoolean.create = (params) => {
2041
+ return new ZodBoolean({
2042
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2043
+ coerce: params?.coerce || false,
2044
+ ...processCreateParams(params)
2045
+ });
2046
+ };
2047
+ var ZodDate = class _ZodDate extends ZodType {
2048
+ _parse(input) {
2049
+ if (this._def.coerce) {
2050
+ input.data = new Date(input.data);
2051
+ }
2052
+ const parsedType = this._getType(input);
2053
+ if (parsedType !== ZodParsedType.date) {
2054
+ const ctx2 = this._getOrReturnCtx(input);
2055
+ addIssueToContext(ctx2, {
2056
+ code: ZodIssueCode.invalid_type,
2057
+ expected: ZodParsedType.date,
2058
+ received: ctx2.parsedType
2059
+ });
2060
+ return INVALID;
2061
+ }
2062
+ if (Number.isNaN(input.data.getTime())) {
2063
+ const ctx2 = this._getOrReturnCtx(input);
2064
+ addIssueToContext(ctx2, {
2065
+ code: ZodIssueCode.invalid_date
2066
+ });
2067
+ return INVALID;
2068
+ }
2069
+ const status = new ParseStatus();
2070
+ let ctx = void 0;
2071
+ for (const check of this._def.checks) {
2072
+ if (check.kind === "min") {
2073
+ if (input.data.getTime() < check.value) {
2074
+ ctx = this._getOrReturnCtx(input, ctx);
2075
+ addIssueToContext(ctx, {
2076
+ code: ZodIssueCode.too_small,
2077
+ message: check.message,
2078
+ inclusive: true,
2079
+ exact: false,
2080
+ minimum: check.value,
2081
+ type: "date"
2082
+ });
2083
+ status.dirty();
2084
+ }
2085
+ } else if (check.kind === "max") {
2086
+ if (input.data.getTime() > check.value) {
2087
+ ctx = this._getOrReturnCtx(input, ctx);
2088
+ addIssueToContext(ctx, {
2089
+ code: ZodIssueCode.too_big,
2090
+ message: check.message,
2091
+ inclusive: true,
2092
+ exact: false,
2093
+ maximum: check.value,
2094
+ type: "date"
2095
+ });
2096
+ status.dirty();
2097
+ }
2098
+ } else {
2099
+ util.assertNever(check);
2100
+ }
2101
+ }
2102
+ return {
2103
+ status: status.value,
2104
+ value: new Date(input.data.getTime())
2105
+ };
2106
+ }
2107
+ _addCheck(check) {
2108
+ return new _ZodDate({
2109
+ ...this._def,
2110
+ checks: [...this._def.checks, check]
2111
+ });
2112
+ }
2113
+ min(minDate, message) {
2114
+ return this._addCheck({
2115
+ kind: "min",
2116
+ value: minDate.getTime(),
2117
+ message: errorUtil.toString(message)
2118
+ });
2119
+ }
2120
+ max(maxDate, message) {
2121
+ return this._addCheck({
2122
+ kind: "max",
2123
+ value: maxDate.getTime(),
2124
+ message: errorUtil.toString(message)
2125
+ });
2126
+ }
2127
+ get minDate() {
2128
+ let min = null;
2129
+ for (const ch of this._def.checks) {
2130
+ if (ch.kind === "min") {
2131
+ if (min === null || ch.value > min)
2132
+ min = ch.value;
2133
+ }
2134
+ }
2135
+ return min != null ? new Date(min) : null;
2136
+ }
2137
+ get maxDate() {
2138
+ let max = null;
2139
+ for (const ch of this._def.checks) {
2140
+ if (ch.kind === "max") {
2141
+ if (max === null || ch.value < max)
2142
+ max = ch.value;
2143
+ }
2144
+ }
2145
+ return max != null ? new Date(max) : null;
2146
+ }
2147
+ };
2148
+ ZodDate.create = (params) => {
2149
+ return new ZodDate({
2150
+ checks: [],
2151
+ coerce: params?.coerce || false,
2152
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2153
+ ...processCreateParams(params)
2154
+ });
2155
+ };
2156
+ var ZodSymbol = class extends ZodType {
2157
+ _parse(input) {
2158
+ const parsedType = this._getType(input);
2159
+ if (parsedType !== ZodParsedType.symbol) {
2160
+ const ctx = this._getOrReturnCtx(input);
2161
+ addIssueToContext(ctx, {
2162
+ code: ZodIssueCode.invalid_type,
2163
+ expected: ZodParsedType.symbol,
2164
+ received: ctx.parsedType
2165
+ });
2166
+ return INVALID;
2167
+ }
2168
+ return OK(input.data);
2169
+ }
2170
+ };
2171
+ ZodSymbol.create = (params) => {
2172
+ return new ZodSymbol({
2173
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2174
+ ...processCreateParams(params)
2175
+ });
2176
+ };
2177
+ var ZodUndefined = class extends ZodType {
2178
+ _parse(input) {
2179
+ const parsedType = this._getType(input);
2180
+ if (parsedType !== ZodParsedType.undefined) {
2181
+ const ctx = this._getOrReturnCtx(input);
2182
+ addIssueToContext(ctx, {
2183
+ code: ZodIssueCode.invalid_type,
2184
+ expected: ZodParsedType.undefined,
2185
+ received: ctx.parsedType
2186
+ });
2187
+ return INVALID;
2188
+ }
2189
+ return OK(input.data);
2190
+ }
2191
+ };
2192
+ ZodUndefined.create = (params) => {
2193
+ return new ZodUndefined({
2194
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2195
+ ...processCreateParams(params)
2196
+ });
2197
+ };
2198
+ var ZodNull = class extends ZodType {
2199
+ _parse(input) {
2200
+ const parsedType = this._getType(input);
2201
+ if (parsedType !== ZodParsedType.null) {
2202
+ const ctx = this._getOrReturnCtx(input);
2203
+ addIssueToContext(ctx, {
2204
+ code: ZodIssueCode.invalid_type,
2205
+ expected: ZodParsedType.null,
2206
+ received: ctx.parsedType
2207
+ });
2208
+ return INVALID;
2209
+ }
2210
+ return OK(input.data);
2211
+ }
2212
+ };
2213
+ ZodNull.create = (params) => {
2214
+ return new ZodNull({
2215
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2216
+ ...processCreateParams(params)
2217
+ });
2218
+ };
2219
+ var ZodAny = class extends ZodType {
2220
+ constructor() {
2221
+ super(...arguments);
2222
+ this._any = true;
2223
+ }
2224
+ _parse(input) {
2225
+ return OK(input.data);
2226
+ }
2227
+ };
2228
+ ZodAny.create = (params) => {
2229
+ return new ZodAny({
2230
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2231
+ ...processCreateParams(params)
2232
+ });
2233
+ };
2234
+ var ZodUnknown = class extends ZodType {
2235
+ constructor() {
2236
+ super(...arguments);
2237
+ this._unknown = true;
2238
+ }
2239
+ _parse(input) {
2240
+ return OK(input.data);
2241
+ }
2242
+ };
2243
+ ZodUnknown.create = (params) => {
2244
+ return new ZodUnknown({
2245
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2246
+ ...processCreateParams(params)
2247
+ });
2248
+ };
2249
+ var ZodNever = class extends ZodType {
2250
+ _parse(input) {
2251
+ const ctx = this._getOrReturnCtx(input);
2252
+ addIssueToContext(ctx, {
2253
+ code: ZodIssueCode.invalid_type,
2254
+ expected: ZodParsedType.never,
2255
+ received: ctx.parsedType
2256
+ });
2257
+ return INVALID;
2258
+ }
2259
+ };
2260
+ ZodNever.create = (params) => {
2261
+ return new ZodNever({
2262
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2263
+ ...processCreateParams(params)
2264
+ });
2265
+ };
2266
+ var ZodVoid = class extends ZodType {
2267
+ _parse(input) {
2268
+ const parsedType = this._getType(input);
2269
+ if (parsedType !== ZodParsedType.undefined) {
2270
+ const ctx = this._getOrReturnCtx(input);
2271
+ addIssueToContext(ctx, {
2272
+ code: ZodIssueCode.invalid_type,
2273
+ expected: ZodParsedType.void,
2274
+ received: ctx.parsedType
2275
+ });
2276
+ return INVALID;
2277
+ }
2278
+ return OK(input.data);
2279
+ }
2280
+ };
2281
+ ZodVoid.create = (params) => {
2282
+ return new ZodVoid({
2283
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2284
+ ...processCreateParams(params)
2285
+ });
2286
+ };
2287
+ var ZodArray = class _ZodArray extends ZodType {
2288
+ _parse(input) {
2289
+ const { ctx, status } = this._processInputParams(input);
2290
+ const def = this._def;
2291
+ if (ctx.parsedType !== ZodParsedType.array) {
2292
+ addIssueToContext(ctx, {
2293
+ code: ZodIssueCode.invalid_type,
2294
+ expected: ZodParsedType.array,
2295
+ received: ctx.parsedType
2296
+ });
2297
+ return INVALID;
2298
+ }
2299
+ if (def.exactLength !== null) {
2300
+ const tooBig = ctx.data.length > def.exactLength.value;
2301
+ const tooSmall = ctx.data.length < def.exactLength.value;
2302
+ if (tooBig || tooSmall) {
2303
+ addIssueToContext(ctx, {
2304
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2305
+ minimum: tooSmall ? def.exactLength.value : void 0,
2306
+ maximum: tooBig ? def.exactLength.value : void 0,
2307
+ type: "array",
2308
+ inclusive: true,
2309
+ exact: true,
2310
+ message: def.exactLength.message
2311
+ });
2312
+ status.dirty();
2313
+ }
2314
+ }
2315
+ if (def.minLength !== null) {
2316
+ if (ctx.data.length < def.minLength.value) {
2317
+ addIssueToContext(ctx, {
2318
+ code: ZodIssueCode.too_small,
2319
+ minimum: def.minLength.value,
2320
+ type: "array",
2321
+ inclusive: true,
2322
+ exact: false,
2323
+ message: def.minLength.message
2324
+ });
2325
+ status.dirty();
2326
+ }
2327
+ }
2328
+ if (def.maxLength !== null) {
2329
+ if (ctx.data.length > def.maxLength.value) {
2330
+ addIssueToContext(ctx, {
2331
+ code: ZodIssueCode.too_big,
2332
+ maximum: def.maxLength.value,
2333
+ type: "array",
2334
+ inclusive: true,
2335
+ exact: false,
2336
+ message: def.maxLength.message
2337
+ });
2338
+ status.dirty();
2339
+ }
2340
+ }
2341
+ if (ctx.common.async) {
2342
+ return Promise.all([...ctx.data].map((item, i) => {
2343
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2344
+ })).then((result2) => {
2345
+ return ParseStatus.mergeArray(status, result2);
2346
+ });
2347
+ }
2348
+ const result = [...ctx.data].map((item, i) => {
2349
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2350
+ });
2351
+ return ParseStatus.mergeArray(status, result);
2352
+ }
2353
+ get element() {
2354
+ return this._def.type;
2355
+ }
2356
+ min(minLength, message) {
2357
+ return new _ZodArray({
2358
+ ...this._def,
2359
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2360
+ });
2361
+ }
2362
+ max(maxLength, message) {
2363
+ return new _ZodArray({
2364
+ ...this._def,
2365
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2366
+ });
2367
+ }
2368
+ length(len, message) {
2369
+ return new _ZodArray({
2370
+ ...this._def,
2371
+ exactLength: { value: len, message: errorUtil.toString(message) }
2372
+ });
2373
+ }
2374
+ nonempty(message) {
2375
+ return this.min(1, message);
2376
+ }
2377
+ };
2378
+ ZodArray.create = (schema, params) => {
2379
+ return new ZodArray({
2380
+ type: schema,
2381
+ minLength: null,
2382
+ maxLength: null,
2383
+ exactLength: null,
2384
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2385
+ ...processCreateParams(params)
2386
+ });
2387
+ };
2388
+ function deepPartialify(schema) {
2389
+ if (schema instanceof ZodObject) {
2390
+ const newShape = {};
2391
+ for (const key in schema.shape) {
2392
+ const fieldSchema = schema.shape[key];
2393
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2394
+ }
2395
+ return new ZodObject({
2396
+ ...schema._def,
2397
+ shape: () => newShape
2398
+ });
2399
+ } else if (schema instanceof ZodArray) {
2400
+ return new ZodArray({
2401
+ ...schema._def,
2402
+ type: deepPartialify(schema.element)
2403
+ });
2404
+ } else if (schema instanceof ZodOptional) {
2405
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2406
+ } else if (schema instanceof ZodNullable) {
2407
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2408
+ } else if (schema instanceof ZodTuple) {
2409
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2410
+ } else {
2411
+ return schema;
2412
+ }
2413
+ }
2414
+ var ZodObject = class _ZodObject extends ZodType {
2415
+ constructor() {
2416
+ super(...arguments);
2417
+ this._cached = null;
2418
+ this.nonstrict = this.passthrough;
2419
+ this.augment = this.extend;
2420
+ }
2421
+ _getCached() {
2422
+ if (this._cached !== null)
2423
+ return this._cached;
2424
+ const shape = this._def.shape();
2425
+ const keys = util.objectKeys(shape);
2426
+ this._cached = { shape, keys };
2427
+ return this._cached;
2428
+ }
2429
+ _parse(input) {
2430
+ const parsedType = this._getType(input);
2431
+ if (parsedType !== ZodParsedType.object) {
2432
+ const ctx2 = this._getOrReturnCtx(input);
2433
+ addIssueToContext(ctx2, {
2434
+ code: ZodIssueCode.invalid_type,
2435
+ expected: ZodParsedType.object,
2436
+ received: ctx2.parsedType
2437
+ });
2438
+ return INVALID;
2439
+ }
2440
+ const { status, ctx } = this._processInputParams(input);
2441
+ const { shape, keys: shapeKeys } = this._getCached();
2442
+ const extraKeys = [];
2443
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2444
+ for (const key in ctx.data) {
2445
+ if (!shapeKeys.includes(key)) {
2446
+ extraKeys.push(key);
2447
+ }
2448
+ }
2449
+ }
2450
+ const pairs = [];
2451
+ for (const key of shapeKeys) {
2452
+ const keyValidator = shape[key];
2453
+ const value = ctx.data[key];
2454
+ pairs.push({
2455
+ key: { status: "valid", value: key },
2456
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2457
+ alwaysSet: key in ctx.data
2458
+ });
2459
+ }
2460
+ if (this._def.catchall instanceof ZodNever) {
2461
+ const unknownKeys = this._def.unknownKeys;
2462
+ if (unknownKeys === "passthrough") {
2463
+ for (const key of extraKeys) {
2464
+ pairs.push({
2465
+ key: { status: "valid", value: key },
2466
+ value: { status: "valid", value: ctx.data[key] }
2467
+ });
2468
+ }
2469
+ } else if (unknownKeys === "strict") {
2470
+ if (extraKeys.length > 0) {
2471
+ addIssueToContext(ctx, {
2472
+ code: ZodIssueCode.unrecognized_keys,
2473
+ keys: extraKeys
2474
+ });
2475
+ status.dirty();
2476
+ }
2477
+ } else if (unknownKeys === "strip") {
2478
+ } else {
2479
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2480
+ }
2481
+ } else {
2482
+ const catchall = this._def.catchall;
2483
+ for (const key of extraKeys) {
2484
+ const value = ctx.data[key];
2485
+ pairs.push({
2486
+ key: { status: "valid", value: key },
2487
+ value: catchall._parse(
2488
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2489
+ //, ctx.child(key), value, getParsedType(value)
2490
+ ),
2491
+ alwaysSet: key in ctx.data
2492
+ });
2493
+ }
2494
+ }
2495
+ if (ctx.common.async) {
2496
+ return Promise.resolve().then(async () => {
2497
+ const syncPairs = [];
2498
+ for (const pair of pairs) {
2499
+ const key = await pair.key;
2500
+ const value = await pair.value;
2501
+ syncPairs.push({
2502
+ key,
2503
+ value,
2504
+ alwaysSet: pair.alwaysSet
2505
+ });
2506
+ }
2507
+ return syncPairs;
2508
+ }).then((syncPairs) => {
2509
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2510
+ });
2511
+ } else {
2512
+ return ParseStatus.mergeObjectSync(status, pairs);
2513
+ }
2514
+ }
2515
+ get shape() {
2516
+ return this._def.shape();
2517
+ }
2518
+ strict(message) {
2519
+ errorUtil.errToObj;
2520
+ return new _ZodObject({
2521
+ ...this._def,
2522
+ unknownKeys: "strict",
2523
+ ...message !== void 0 ? {
2524
+ errorMap: (issue, ctx) => {
2525
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2526
+ if (issue.code === "unrecognized_keys")
2527
+ return {
2528
+ message: errorUtil.errToObj(message).message ?? defaultError
2529
+ };
2530
+ return {
2531
+ message: defaultError
2532
+ };
2533
+ }
2534
+ } : {}
2535
+ });
2536
+ }
2537
+ strip() {
2538
+ return new _ZodObject({
2539
+ ...this._def,
2540
+ unknownKeys: "strip"
2541
+ });
2542
+ }
2543
+ passthrough() {
2544
+ return new _ZodObject({
2545
+ ...this._def,
2546
+ unknownKeys: "passthrough"
2547
+ });
2548
+ }
2549
+ // const AugmentFactory =
2550
+ // <Def extends ZodObjectDef>(def: Def) =>
2551
+ // <Augmentation extends ZodRawShape>(
2552
+ // augmentation: Augmentation
2553
+ // ): ZodObject<
2554
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2555
+ // Def["unknownKeys"],
2556
+ // Def["catchall"]
2557
+ // > => {
2558
+ // return new ZodObject({
2559
+ // ...def,
2560
+ // shape: () => ({
2561
+ // ...def.shape(),
2562
+ // ...augmentation,
2563
+ // }),
2564
+ // }) as any;
2565
+ // };
2566
+ extend(augmentation) {
2567
+ return new _ZodObject({
2568
+ ...this._def,
2569
+ shape: () => ({
2570
+ ...this._def.shape(),
2571
+ ...augmentation
2572
+ })
2573
+ });
2574
+ }
2575
+ /**
2576
+ * Prior to zod@1.0.12 there was a bug in the
2577
+ * inferred type of merged objects. Please
2578
+ * upgrade if you are experiencing issues.
2579
+ */
2580
+ merge(merging) {
2581
+ const merged = new _ZodObject({
2582
+ unknownKeys: merging._def.unknownKeys,
2583
+ catchall: merging._def.catchall,
2584
+ shape: () => ({
2585
+ ...this._def.shape(),
2586
+ ...merging._def.shape()
2587
+ }),
2588
+ typeName: ZodFirstPartyTypeKind.ZodObject
2589
+ });
2590
+ return merged;
2591
+ }
2592
+ // merge<
2593
+ // Incoming extends AnyZodObject,
2594
+ // Augmentation extends Incoming["shape"],
2595
+ // NewOutput extends {
2596
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2597
+ // ? Augmentation[k]["_output"]
2598
+ // : k extends keyof Output
2599
+ // ? Output[k]
2600
+ // : never;
2601
+ // },
2602
+ // NewInput extends {
2603
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2604
+ // ? Augmentation[k]["_input"]
2605
+ // : k extends keyof Input
2606
+ // ? Input[k]
2607
+ // : never;
2608
+ // }
2609
+ // >(
2610
+ // merging: Incoming
2611
+ // ): ZodObject<
2612
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2613
+ // Incoming["_def"]["unknownKeys"],
2614
+ // Incoming["_def"]["catchall"],
2615
+ // NewOutput,
2616
+ // NewInput
2617
+ // > {
2618
+ // const merged: any = new ZodObject({
2619
+ // unknownKeys: merging._def.unknownKeys,
2620
+ // catchall: merging._def.catchall,
2621
+ // shape: () =>
2622
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2623
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2624
+ // }) as any;
2625
+ // return merged;
2626
+ // }
2627
+ setKey(key, schema) {
2628
+ return this.augment({ [key]: schema });
2629
+ }
2630
+ // merge<Incoming extends AnyZodObject>(
2631
+ // merging: Incoming
2632
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2633
+ // ZodObject<
2634
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2635
+ // Incoming["_def"]["unknownKeys"],
2636
+ // Incoming["_def"]["catchall"]
2637
+ // > {
2638
+ // // const mergedShape = objectUtil.mergeShapes(
2639
+ // // this._def.shape(),
2640
+ // // merging._def.shape()
2641
+ // // );
2642
+ // const merged: any = new ZodObject({
2643
+ // unknownKeys: merging._def.unknownKeys,
2644
+ // catchall: merging._def.catchall,
2645
+ // shape: () =>
2646
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2647
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2648
+ // }) as any;
2649
+ // return merged;
2650
+ // }
2651
+ catchall(index) {
2652
+ return new _ZodObject({
2653
+ ...this._def,
2654
+ catchall: index
2655
+ });
2656
+ }
2657
+ pick(mask) {
2658
+ const shape = {};
2659
+ for (const key of util.objectKeys(mask)) {
2660
+ if (mask[key] && this.shape[key]) {
2661
+ shape[key] = this.shape[key];
2662
+ }
2663
+ }
2664
+ return new _ZodObject({
2665
+ ...this._def,
2666
+ shape: () => shape
2667
+ });
2668
+ }
2669
+ omit(mask) {
2670
+ const shape = {};
2671
+ for (const key of util.objectKeys(this.shape)) {
2672
+ if (!mask[key]) {
2673
+ shape[key] = this.shape[key];
2674
+ }
2675
+ }
2676
+ return new _ZodObject({
2677
+ ...this._def,
2678
+ shape: () => shape
2679
+ });
2680
+ }
2681
+ /**
2682
+ * @deprecated
2683
+ */
2684
+ deepPartial() {
2685
+ return deepPartialify(this);
2686
+ }
2687
+ partial(mask) {
2688
+ const newShape = {};
2689
+ for (const key of util.objectKeys(this.shape)) {
2690
+ const fieldSchema = this.shape[key];
2691
+ if (mask && !mask[key]) {
2692
+ newShape[key] = fieldSchema;
2693
+ } else {
2694
+ newShape[key] = fieldSchema.optional();
2695
+ }
2696
+ }
2697
+ return new _ZodObject({
2698
+ ...this._def,
2699
+ shape: () => newShape
2700
+ });
2701
+ }
2702
+ required(mask) {
2703
+ const newShape = {};
2704
+ for (const key of util.objectKeys(this.shape)) {
2705
+ if (mask && !mask[key]) {
2706
+ newShape[key] = this.shape[key];
2707
+ } else {
2708
+ const fieldSchema = this.shape[key];
2709
+ let newField = fieldSchema;
2710
+ while (newField instanceof ZodOptional) {
2711
+ newField = newField._def.innerType;
2712
+ }
2713
+ newShape[key] = newField;
2714
+ }
2715
+ }
2716
+ return new _ZodObject({
2717
+ ...this._def,
2718
+ shape: () => newShape
2719
+ });
2720
+ }
2721
+ keyof() {
2722
+ return createZodEnum(util.objectKeys(this.shape));
2723
+ }
2724
+ };
2725
+ ZodObject.create = (shape, params) => {
2726
+ return new ZodObject({
2727
+ shape: () => shape,
2728
+ unknownKeys: "strip",
2729
+ catchall: ZodNever.create(),
2730
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2731
+ ...processCreateParams(params)
2732
+ });
2733
+ };
2734
+ ZodObject.strictCreate = (shape, params) => {
2735
+ return new ZodObject({
2736
+ shape: () => shape,
2737
+ unknownKeys: "strict",
2738
+ catchall: ZodNever.create(),
2739
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2740
+ ...processCreateParams(params)
2741
+ });
2742
+ };
2743
+ ZodObject.lazycreate = (shape, params) => {
2744
+ return new ZodObject({
2745
+ shape,
2746
+ unknownKeys: "strip",
2747
+ catchall: ZodNever.create(),
2748
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2749
+ ...processCreateParams(params)
2750
+ });
2751
+ };
2752
+ var ZodUnion = class extends ZodType {
2753
+ _parse(input) {
2754
+ const { ctx } = this._processInputParams(input);
2755
+ const options = this._def.options;
2756
+ function handleResults(results) {
2757
+ for (const result of results) {
2758
+ if (result.result.status === "valid") {
2759
+ return result.result;
2760
+ }
2761
+ }
2762
+ for (const result of results) {
2763
+ if (result.result.status === "dirty") {
2764
+ ctx.common.issues.push(...result.ctx.common.issues);
2765
+ return result.result;
2766
+ }
2767
+ }
2768
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2769
+ addIssueToContext(ctx, {
2770
+ code: ZodIssueCode.invalid_union,
2771
+ unionErrors
2772
+ });
2773
+ return INVALID;
2774
+ }
2775
+ if (ctx.common.async) {
2776
+ return Promise.all(options.map(async (option) => {
2777
+ const childCtx = {
2778
+ ...ctx,
2779
+ common: {
2780
+ ...ctx.common,
2781
+ issues: []
2782
+ },
2783
+ parent: null
2784
+ };
2785
+ return {
2786
+ result: await option._parseAsync({
2787
+ data: ctx.data,
2788
+ path: ctx.path,
2789
+ parent: childCtx
2790
+ }),
2791
+ ctx: childCtx
2792
+ };
2793
+ })).then(handleResults);
2794
+ } else {
2795
+ let dirty = void 0;
2796
+ const issues = [];
2797
+ for (const option of options) {
2798
+ const childCtx = {
2799
+ ...ctx,
2800
+ common: {
2801
+ ...ctx.common,
2802
+ issues: []
2803
+ },
2804
+ parent: null
2805
+ };
2806
+ const result = option._parseSync({
2807
+ data: ctx.data,
2808
+ path: ctx.path,
2809
+ parent: childCtx
2810
+ });
2811
+ if (result.status === "valid") {
2812
+ return result;
2813
+ } else if (result.status === "dirty" && !dirty) {
2814
+ dirty = { result, ctx: childCtx };
2815
+ }
2816
+ if (childCtx.common.issues.length) {
2817
+ issues.push(childCtx.common.issues);
2818
+ }
2819
+ }
2820
+ if (dirty) {
2821
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2822
+ return dirty.result;
2823
+ }
2824
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2825
+ addIssueToContext(ctx, {
2826
+ code: ZodIssueCode.invalid_union,
2827
+ unionErrors
2828
+ });
2829
+ return INVALID;
2830
+ }
2831
+ }
2832
+ get options() {
2833
+ return this._def.options;
2834
+ }
2835
+ };
2836
+ ZodUnion.create = (types, params) => {
2837
+ return new ZodUnion({
2838
+ options: types,
2839
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2840
+ ...processCreateParams(params)
2841
+ });
2842
+ };
2843
+ var getDiscriminator = (type) => {
2844
+ if (type instanceof ZodLazy) {
2845
+ return getDiscriminator(type.schema);
2846
+ } else if (type instanceof ZodEffects) {
2847
+ return getDiscriminator(type.innerType());
2848
+ } else if (type instanceof ZodLiteral) {
2849
+ return [type.value];
2850
+ } else if (type instanceof ZodEnum) {
2851
+ return type.options;
2852
+ } else if (type instanceof ZodNativeEnum) {
2853
+ return util.objectValues(type.enum);
2854
+ } else if (type instanceof ZodDefault) {
2855
+ return getDiscriminator(type._def.innerType);
2856
+ } else if (type instanceof ZodUndefined) {
2857
+ return [void 0];
2858
+ } else if (type instanceof ZodNull) {
2859
+ return [null];
2860
+ } else if (type instanceof ZodOptional) {
2861
+ return [void 0, ...getDiscriminator(type.unwrap())];
2862
+ } else if (type instanceof ZodNullable) {
2863
+ return [null, ...getDiscriminator(type.unwrap())];
2864
+ } else if (type instanceof ZodBranded) {
2865
+ return getDiscriminator(type.unwrap());
2866
+ } else if (type instanceof ZodReadonly) {
2867
+ return getDiscriminator(type.unwrap());
2868
+ } else if (type instanceof ZodCatch) {
2869
+ return getDiscriminator(type._def.innerType);
2870
+ } else {
2871
+ return [];
2872
+ }
2873
+ };
2874
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2875
+ _parse(input) {
2876
+ const { ctx } = this._processInputParams(input);
2877
+ if (ctx.parsedType !== ZodParsedType.object) {
2878
+ addIssueToContext(ctx, {
2879
+ code: ZodIssueCode.invalid_type,
2880
+ expected: ZodParsedType.object,
2881
+ received: ctx.parsedType
2882
+ });
2883
+ return INVALID;
2884
+ }
2885
+ const discriminator = this.discriminator;
2886
+ const discriminatorValue = ctx.data[discriminator];
2887
+ const option = this.optionsMap.get(discriminatorValue);
2888
+ if (!option) {
2889
+ addIssueToContext(ctx, {
2890
+ code: ZodIssueCode.invalid_union_discriminator,
2891
+ options: Array.from(this.optionsMap.keys()),
2892
+ path: [discriminator]
2893
+ });
2894
+ return INVALID;
2895
+ }
2896
+ if (ctx.common.async) {
2897
+ return option._parseAsync({
2898
+ data: ctx.data,
2899
+ path: ctx.path,
2900
+ parent: ctx
2901
+ });
2902
+ } else {
2903
+ return option._parseSync({
2904
+ data: ctx.data,
2905
+ path: ctx.path,
2906
+ parent: ctx
2907
+ });
2908
+ }
2909
+ }
2910
+ get discriminator() {
2911
+ return this._def.discriminator;
2912
+ }
2913
+ get options() {
2914
+ return this._def.options;
2915
+ }
2916
+ get optionsMap() {
2917
+ return this._def.optionsMap;
2918
+ }
2919
+ /**
2920
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2921
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2922
+ * have a different value for each object in the union.
2923
+ * @param discriminator the name of the discriminator property
2924
+ * @param types an array of object schemas
2925
+ * @param params
2926
+ */
2927
+ static create(discriminator, options, params) {
2928
+ const optionsMap = /* @__PURE__ */ new Map();
2929
+ for (const type of options) {
2930
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2931
+ if (!discriminatorValues.length) {
2932
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2933
+ }
2934
+ for (const value of discriminatorValues) {
2935
+ if (optionsMap.has(value)) {
2936
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2937
+ }
2938
+ optionsMap.set(value, type);
2939
+ }
2940
+ }
2941
+ return new _ZodDiscriminatedUnion({
2942
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2943
+ discriminator,
2944
+ options,
2945
+ optionsMap,
2946
+ ...processCreateParams(params)
2947
+ });
2948
+ }
2949
+ };
2950
+ function mergeValues(a, b) {
2951
+ const aType = getParsedType(a);
2952
+ const bType = getParsedType(b);
2953
+ if (a === b) {
2954
+ return { valid: true, data: a };
2955
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2956
+ const bKeys = util.objectKeys(b);
2957
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2958
+ const newObj = { ...a, ...b };
2959
+ for (const key of sharedKeys) {
2960
+ const sharedValue = mergeValues(a[key], b[key]);
2961
+ if (!sharedValue.valid) {
2962
+ return { valid: false };
2963
+ }
2964
+ newObj[key] = sharedValue.data;
2965
+ }
2966
+ return { valid: true, data: newObj };
2967
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2968
+ if (a.length !== b.length) {
2969
+ return { valid: false };
2970
+ }
2971
+ const newArray = [];
2972
+ for (let index = 0; index < a.length; index++) {
2973
+ const itemA = a[index];
2974
+ const itemB = b[index];
2975
+ const sharedValue = mergeValues(itemA, itemB);
2976
+ if (!sharedValue.valid) {
2977
+ return { valid: false };
2978
+ }
2979
+ newArray.push(sharedValue.data);
2980
+ }
2981
+ return { valid: true, data: newArray };
2982
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2983
+ return { valid: true, data: a };
2984
+ } else {
2985
+ return { valid: false };
2986
+ }
2987
+ }
2988
+ var ZodIntersection = class extends ZodType {
2989
+ _parse(input) {
2990
+ const { status, ctx } = this._processInputParams(input);
2991
+ const handleParsed = (parsedLeft, parsedRight) => {
2992
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2993
+ return INVALID;
2994
+ }
2995
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2996
+ if (!merged.valid) {
2997
+ addIssueToContext(ctx, {
2998
+ code: ZodIssueCode.invalid_intersection_types
2999
+ });
3000
+ return INVALID;
3001
+ }
3002
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3003
+ status.dirty();
3004
+ }
3005
+ return { status: status.value, value: merged.data };
3006
+ };
3007
+ if (ctx.common.async) {
3008
+ return Promise.all([
3009
+ this._def.left._parseAsync({
3010
+ data: ctx.data,
3011
+ path: ctx.path,
3012
+ parent: ctx
3013
+ }),
3014
+ this._def.right._parseAsync({
3015
+ data: ctx.data,
3016
+ path: ctx.path,
3017
+ parent: ctx
3018
+ })
3019
+ ]).then(([left, right]) => handleParsed(left, right));
3020
+ } else {
3021
+ return handleParsed(this._def.left._parseSync({
3022
+ data: ctx.data,
3023
+ path: ctx.path,
3024
+ parent: ctx
3025
+ }), this._def.right._parseSync({
3026
+ data: ctx.data,
3027
+ path: ctx.path,
3028
+ parent: ctx
3029
+ }));
3030
+ }
3031
+ }
3032
+ };
3033
+ ZodIntersection.create = (left, right, params) => {
3034
+ return new ZodIntersection({
3035
+ left,
3036
+ right,
3037
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3038
+ ...processCreateParams(params)
3039
+ });
3040
+ };
3041
+ var ZodTuple = class _ZodTuple extends ZodType {
3042
+ _parse(input) {
3043
+ const { status, ctx } = this._processInputParams(input);
3044
+ if (ctx.parsedType !== ZodParsedType.array) {
3045
+ addIssueToContext(ctx, {
3046
+ code: ZodIssueCode.invalid_type,
3047
+ expected: ZodParsedType.array,
3048
+ received: ctx.parsedType
3049
+ });
3050
+ return INVALID;
3051
+ }
3052
+ if (ctx.data.length < this._def.items.length) {
3053
+ addIssueToContext(ctx, {
3054
+ code: ZodIssueCode.too_small,
3055
+ minimum: this._def.items.length,
3056
+ inclusive: true,
3057
+ exact: false,
3058
+ type: "array"
3059
+ });
3060
+ return INVALID;
3061
+ }
3062
+ const rest = this._def.rest;
3063
+ if (!rest && ctx.data.length > this._def.items.length) {
3064
+ addIssueToContext(ctx, {
3065
+ code: ZodIssueCode.too_big,
3066
+ maximum: this._def.items.length,
3067
+ inclusive: true,
3068
+ exact: false,
3069
+ type: "array"
3070
+ });
3071
+ status.dirty();
3072
+ }
3073
+ const items = [...ctx.data].map((item, itemIndex) => {
3074
+ const schema = this._def.items[itemIndex] || this._def.rest;
3075
+ if (!schema)
3076
+ return null;
3077
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3078
+ }).filter((x) => !!x);
3079
+ if (ctx.common.async) {
3080
+ return Promise.all(items).then((results) => {
3081
+ return ParseStatus.mergeArray(status, results);
3082
+ });
3083
+ } else {
3084
+ return ParseStatus.mergeArray(status, items);
3085
+ }
3086
+ }
3087
+ get items() {
3088
+ return this._def.items;
3089
+ }
3090
+ rest(rest) {
3091
+ return new _ZodTuple({
3092
+ ...this._def,
3093
+ rest
3094
+ });
3095
+ }
3096
+ };
3097
+ ZodTuple.create = (schemas, params) => {
3098
+ if (!Array.isArray(schemas)) {
3099
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3100
+ }
3101
+ return new ZodTuple({
3102
+ items: schemas,
3103
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3104
+ rest: null,
3105
+ ...processCreateParams(params)
3106
+ });
3107
+ };
3108
+ var ZodRecord = class _ZodRecord extends ZodType {
3109
+ get keySchema() {
3110
+ return this._def.keyType;
3111
+ }
3112
+ get valueSchema() {
3113
+ return this._def.valueType;
3114
+ }
3115
+ _parse(input) {
3116
+ const { status, ctx } = this._processInputParams(input);
3117
+ if (ctx.parsedType !== ZodParsedType.object) {
3118
+ addIssueToContext(ctx, {
3119
+ code: ZodIssueCode.invalid_type,
3120
+ expected: ZodParsedType.object,
3121
+ received: ctx.parsedType
3122
+ });
3123
+ return INVALID;
3124
+ }
3125
+ const pairs = [];
3126
+ const keyType = this._def.keyType;
3127
+ const valueType = this._def.valueType;
3128
+ for (const key in ctx.data) {
3129
+ pairs.push({
3130
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3131
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3132
+ alwaysSet: key in ctx.data
3133
+ });
3134
+ }
3135
+ if (ctx.common.async) {
3136
+ return ParseStatus.mergeObjectAsync(status, pairs);
3137
+ } else {
3138
+ return ParseStatus.mergeObjectSync(status, pairs);
3139
+ }
3140
+ }
3141
+ get element() {
3142
+ return this._def.valueType;
3143
+ }
3144
+ static create(first, second, third) {
3145
+ if (second instanceof ZodType) {
3146
+ return new _ZodRecord({
3147
+ keyType: first,
3148
+ valueType: second,
3149
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3150
+ ...processCreateParams(third)
3151
+ });
3152
+ }
3153
+ return new _ZodRecord({
3154
+ keyType: ZodString.create(),
3155
+ valueType: first,
3156
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3157
+ ...processCreateParams(second)
3158
+ });
3159
+ }
3160
+ };
3161
+ var ZodMap = class extends ZodType {
3162
+ get keySchema() {
3163
+ return this._def.keyType;
3164
+ }
3165
+ get valueSchema() {
3166
+ return this._def.valueType;
3167
+ }
3168
+ _parse(input) {
3169
+ const { status, ctx } = this._processInputParams(input);
3170
+ if (ctx.parsedType !== ZodParsedType.map) {
3171
+ addIssueToContext(ctx, {
3172
+ code: ZodIssueCode.invalid_type,
3173
+ expected: ZodParsedType.map,
3174
+ received: ctx.parsedType
3175
+ });
3176
+ return INVALID;
3177
+ }
3178
+ const keyType = this._def.keyType;
3179
+ const valueType = this._def.valueType;
3180
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3181
+ return {
3182
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3183
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3184
+ };
3185
+ });
3186
+ if (ctx.common.async) {
3187
+ const finalMap = /* @__PURE__ */ new Map();
3188
+ return Promise.resolve().then(async () => {
3189
+ for (const pair of pairs) {
3190
+ const key = await pair.key;
3191
+ const value = await pair.value;
3192
+ if (key.status === "aborted" || value.status === "aborted") {
3193
+ return INVALID;
3194
+ }
3195
+ if (key.status === "dirty" || value.status === "dirty") {
3196
+ status.dirty();
3197
+ }
3198
+ finalMap.set(key.value, value.value);
3199
+ }
3200
+ return { status: status.value, value: finalMap };
3201
+ });
3202
+ } else {
3203
+ const finalMap = /* @__PURE__ */ new Map();
3204
+ for (const pair of pairs) {
3205
+ const key = pair.key;
3206
+ const value = pair.value;
3207
+ if (key.status === "aborted" || value.status === "aborted") {
3208
+ return INVALID;
3209
+ }
3210
+ if (key.status === "dirty" || value.status === "dirty") {
3211
+ status.dirty();
3212
+ }
3213
+ finalMap.set(key.value, value.value);
3214
+ }
3215
+ return { status: status.value, value: finalMap };
3216
+ }
3217
+ }
3218
+ };
3219
+ ZodMap.create = (keyType, valueType, params) => {
3220
+ return new ZodMap({
3221
+ valueType,
3222
+ keyType,
3223
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3224
+ ...processCreateParams(params)
3225
+ });
3226
+ };
3227
+ var ZodSet = class _ZodSet extends ZodType {
3228
+ _parse(input) {
3229
+ const { status, ctx } = this._processInputParams(input);
3230
+ if (ctx.parsedType !== ZodParsedType.set) {
3231
+ addIssueToContext(ctx, {
3232
+ code: ZodIssueCode.invalid_type,
3233
+ expected: ZodParsedType.set,
3234
+ received: ctx.parsedType
3235
+ });
3236
+ return INVALID;
3237
+ }
3238
+ const def = this._def;
3239
+ if (def.minSize !== null) {
3240
+ if (ctx.data.size < def.minSize.value) {
3241
+ addIssueToContext(ctx, {
3242
+ code: ZodIssueCode.too_small,
3243
+ minimum: def.minSize.value,
3244
+ type: "set",
3245
+ inclusive: true,
3246
+ exact: false,
3247
+ message: def.minSize.message
3248
+ });
3249
+ status.dirty();
3250
+ }
3251
+ }
3252
+ if (def.maxSize !== null) {
3253
+ if (ctx.data.size > def.maxSize.value) {
3254
+ addIssueToContext(ctx, {
3255
+ code: ZodIssueCode.too_big,
3256
+ maximum: def.maxSize.value,
3257
+ type: "set",
3258
+ inclusive: true,
3259
+ exact: false,
3260
+ message: def.maxSize.message
3261
+ });
3262
+ status.dirty();
3263
+ }
3264
+ }
3265
+ const valueType = this._def.valueType;
3266
+ function finalizeSet(elements2) {
3267
+ const parsedSet = /* @__PURE__ */ new Set();
3268
+ for (const element of elements2) {
3269
+ if (element.status === "aborted")
3270
+ return INVALID;
3271
+ if (element.status === "dirty")
3272
+ status.dirty();
3273
+ parsedSet.add(element.value);
3274
+ }
3275
+ return { status: status.value, value: parsedSet };
3276
+ }
3277
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3278
+ if (ctx.common.async) {
3279
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3280
+ } else {
3281
+ return finalizeSet(elements);
3282
+ }
3283
+ }
3284
+ min(minSize, message) {
3285
+ return new _ZodSet({
3286
+ ...this._def,
3287
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3288
+ });
3289
+ }
3290
+ max(maxSize, message) {
3291
+ return new _ZodSet({
3292
+ ...this._def,
3293
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3294
+ });
3295
+ }
3296
+ size(size, message) {
3297
+ return this.min(size, message).max(size, message);
3298
+ }
3299
+ nonempty(message) {
3300
+ return this.min(1, message);
3301
+ }
3302
+ };
3303
+ ZodSet.create = (valueType, params) => {
3304
+ return new ZodSet({
3305
+ valueType,
3306
+ minSize: null,
3307
+ maxSize: null,
3308
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3309
+ ...processCreateParams(params)
3310
+ });
3311
+ };
3312
+ var ZodFunction = class _ZodFunction extends ZodType {
3313
+ constructor() {
3314
+ super(...arguments);
3315
+ this.validate = this.implement;
3316
+ }
3317
+ _parse(input) {
3318
+ const { ctx } = this._processInputParams(input);
3319
+ if (ctx.parsedType !== ZodParsedType.function) {
3320
+ addIssueToContext(ctx, {
3321
+ code: ZodIssueCode.invalid_type,
3322
+ expected: ZodParsedType.function,
3323
+ received: ctx.parsedType
3324
+ });
3325
+ return INVALID;
3326
+ }
3327
+ function makeArgsIssue(args, error) {
3328
+ return makeIssue({
3329
+ data: args,
3330
+ path: ctx.path,
3331
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3332
+ issueData: {
3333
+ code: ZodIssueCode.invalid_arguments,
3334
+ argumentsError: error
3335
+ }
3336
+ });
3337
+ }
3338
+ function makeReturnsIssue(returns, error) {
3339
+ return makeIssue({
3340
+ data: returns,
3341
+ path: ctx.path,
3342
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3343
+ issueData: {
3344
+ code: ZodIssueCode.invalid_return_type,
3345
+ returnTypeError: error
3346
+ }
3347
+ });
3348
+ }
3349
+ const params = { errorMap: ctx.common.contextualErrorMap };
3350
+ const fn = ctx.data;
3351
+ if (this._def.returns instanceof ZodPromise) {
3352
+ const me = this;
3353
+ return OK(async function(...args) {
3354
+ const error = new ZodError([]);
3355
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3356
+ error.addIssue(makeArgsIssue(args, e));
3357
+ throw error;
3358
+ });
3359
+ const result = await Reflect.apply(fn, this, parsedArgs);
3360
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3361
+ error.addIssue(makeReturnsIssue(result, e));
3362
+ throw error;
3363
+ });
3364
+ return parsedReturns;
3365
+ });
3366
+ } else {
3367
+ const me = this;
3368
+ return OK(function(...args) {
3369
+ const parsedArgs = me._def.args.safeParse(args, params);
3370
+ if (!parsedArgs.success) {
3371
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3372
+ }
3373
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3374
+ const parsedReturns = me._def.returns.safeParse(result, params);
3375
+ if (!parsedReturns.success) {
3376
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3377
+ }
3378
+ return parsedReturns.data;
3379
+ });
3380
+ }
3381
+ }
3382
+ parameters() {
3383
+ return this._def.args;
3384
+ }
3385
+ returnType() {
3386
+ return this._def.returns;
3387
+ }
3388
+ args(...items) {
3389
+ return new _ZodFunction({
3390
+ ...this._def,
3391
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3392
+ });
3393
+ }
3394
+ returns(returnType) {
3395
+ return new _ZodFunction({
3396
+ ...this._def,
3397
+ returns: returnType
3398
+ });
3399
+ }
3400
+ implement(func) {
3401
+ const validatedFunc = this.parse(func);
3402
+ return validatedFunc;
3403
+ }
3404
+ strictImplement(func) {
3405
+ const validatedFunc = this.parse(func);
3406
+ return validatedFunc;
3407
+ }
3408
+ static create(args, returns, params) {
3409
+ return new _ZodFunction({
3410
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3411
+ returns: returns || ZodUnknown.create(),
3412
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3413
+ ...processCreateParams(params)
3414
+ });
3415
+ }
3416
+ };
3417
+ var ZodLazy = class extends ZodType {
3418
+ get schema() {
3419
+ return this._def.getter();
3420
+ }
3421
+ _parse(input) {
3422
+ const { ctx } = this._processInputParams(input);
3423
+ const lazySchema = this._def.getter();
3424
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3425
+ }
3426
+ };
3427
+ ZodLazy.create = (getter, params) => {
3428
+ return new ZodLazy({
3429
+ getter,
3430
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3431
+ ...processCreateParams(params)
3432
+ });
3433
+ };
3434
+ var ZodLiteral = class extends ZodType {
3435
+ _parse(input) {
3436
+ if (input.data !== this._def.value) {
3437
+ const ctx = this._getOrReturnCtx(input);
3438
+ addIssueToContext(ctx, {
3439
+ received: ctx.data,
3440
+ code: ZodIssueCode.invalid_literal,
3441
+ expected: this._def.value
3442
+ });
3443
+ return INVALID;
3444
+ }
3445
+ return { status: "valid", value: input.data };
3446
+ }
3447
+ get value() {
3448
+ return this._def.value;
3449
+ }
3450
+ };
3451
+ ZodLiteral.create = (value, params) => {
3452
+ return new ZodLiteral({
3453
+ value,
3454
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3455
+ ...processCreateParams(params)
3456
+ });
3457
+ };
3458
+ function createZodEnum(values, params) {
3459
+ return new ZodEnum({
3460
+ values,
3461
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3462
+ ...processCreateParams(params)
3463
+ });
3464
+ }
3465
+ var ZodEnum = class _ZodEnum extends ZodType {
3466
+ _parse(input) {
3467
+ if (typeof input.data !== "string") {
3468
+ const ctx = this._getOrReturnCtx(input);
3469
+ const expectedValues = this._def.values;
3470
+ addIssueToContext(ctx, {
3471
+ expected: util.joinValues(expectedValues),
3472
+ received: ctx.parsedType,
3473
+ code: ZodIssueCode.invalid_type
3474
+ });
3475
+ return INVALID;
3476
+ }
3477
+ if (!this._cache) {
3478
+ this._cache = new Set(this._def.values);
3479
+ }
3480
+ if (!this._cache.has(input.data)) {
3481
+ const ctx = this._getOrReturnCtx(input);
3482
+ const expectedValues = this._def.values;
3483
+ addIssueToContext(ctx, {
3484
+ received: ctx.data,
3485
+ code: ZodIssueCode.invalid_enum_value,
3486
+ options: expectedValues
3487
+ });
3488
+ return INVALID;
3489
+ }
3490
+ return OK(input.data);
3491
+ }
3492
+ get options() {
3493
+ return this._def.values;
3494
+ }
3495
+ get enum() {
3496
+ const enumValues = {};
3497
+ for (const val of this._def.values) {
3498
+ enumValues[val] = val;
3499
+ }
3500
+ return enumValues;
3501
+ }
3502
+ get Values() {
3503
+ const enumValues = {};
3504
+ for (const val of this._def.values) {
3505
+ enumValues[val] = val;
3506
+ }
3507
+ return enumValues;
3508
+ }
3509
+ get Enum() {
3510
+ const enumValues = {};
3511
+ for (const val of this._def.values) {
3512
+ enumValues[val] = val;
3513
+ }
3514
+ return enumValues;
3515
+ }
3516
+ extract(values, newDef = this._def) {
3517
+ return _ZodEnum.create(values, {
3518
+ ...this._def,
3519
+ ...newDef
3520
+ });
3521
+ }
3522
+ exclude(values, newDef = this._def) {
3523
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3524
+ ...this._def,
3525
+ ...newDef
3526
+ });
3527
+ }
3528
+ };
3529
+ ZodEnum.create = createZodEnum;
3530
+ var ZodNativeEnum = class extends ZodType {
3531
+ _parse(input) {
3532
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3533
+ const ctx = this._getOrReturnCtx(input);
3534
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3535
+ const expectedValues = util.objectValues(nativeEnumValues);
3536
+ addIssueToContext(ctx, {
3537
+ expected: util.joinValues(expectedValues),
3538
+ received: ctx.parsedType,
3539
+ code: ZodIssueCode.invalid_type
3540
+ });
3541
+ return INVALID;
3542
+ }
3543
+ if (!this._cache) {
3544
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
3545
+ }
3546
+ if (!this._cache.has(input.data)) {
3547
+ const expectedValues = util.objectValues(nativeEnumValues);
3548
+ addIssueToContext(ctx, {
3549
+ received: ctx.data,
3550
+ code: ZodIssueCode.invalid_enum_value,
3551
+ options: expectedValues
3552
+ });
3553
+ return INVALID;
3554
+ }
3555
+ return OK(input.data);
3556
+ }
3557
+ get enum() {
3558
+ return this._def.values;
3559
+ }
3560
+ };
3561
+ ZodNativeEnum.create = (values, params) => {
3562
+ return new ZodNativeEnum({
3563
+ values,
3564
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3565
+ ...processCreateParams(params)
3566
+ });
3567
+ };
3568
+ var ZodPromise = class extends ZodType {
3569
+ unwrap() {
3570
+ return this._def.type;
3571
+ }
3572
+ _parse(input) {
3573
+ const { ctx } = this._processInputParams(input);
3574
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3575
+ addIssueToContext(ctx, {
3576
+ code: ZodIssueCode.invalid_type,
3577
+ expected: ZodParsedType.promise,
3578
+ received: ctx.parsedType
3579
+ });
3580
+ return INVALID;
3581
+ }
3582
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3583
+ return OK(promisified.then((data) => {
3584
+ return this._def.type.parseAsync(data, {
3585
+ path: ctx.path,
3586
+ errorMap: ctx.common.contextualErrorMap
3587
+ });
3588
+ }));
3589
+ }
3590
+ };
3591
+ ZodPromise.create = (schema, params) => {
3592
+ return new ZodPromise({
3593
+ type: schema,
3594
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3595
+ ...processCreateParams(params)
3596
+ });
3597
+ };
3598
+ var ZodEffects = class extends ZodType {
3599
+ innerType() {
3600
+ return this._def.schema;
3601
+ }
3602
+ sourceType() {
3603
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3604
+ }
3605
+ _parse(input) {
3606
+ const { status, ctx } = this._processInputParams(input);
3607
+ const effect = this._def.effect || null;
3608
+ const checkCtx = {
3609
+ addIssue: (arg) => {
3610
+ addIssueToContext(ctx, arg);
3611
+ if (arg.fatal) {
3612
+ status.abort();
3613
+ } else {
3614
+ status.dirty();
3615
+ }
3616
+ },
3617
+ get path() {
3618
+ return ctx.path;
3619
+ }
3620
+ };
3621
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3622
+ if (effect.type === "preprocess") {
3623
+ const processed = effect.transform(ctx.data, checkCtx);
3624
+ if (ctx.common.async) {
3625
+ return Promise.resolve(processed).then(async (processed2) => {
3626
+ if (status.value === "aborted")
3627
+ return INVALID;
3628
+ const result = await this._def.schema._parseAsync({
3629
+ data: processed2,
3630
+ path: ctx.path,
3631
+ parent: ctx
3632
+ });
3633
+ if (result.status === "aborted")
3634
+ return INVALID;
3635
+ if (result.status === "dirty")
3636
+ return DIRTY(result.value);
3637
+ if (status.value === "dirty")
3638
+ return DIRTY(result.value);
3639
+ return result;
3640
+ });
3641
+ } else {
3642
+ if (status.value === "aborted")
3643
+ return INVALID;
3644
+ const result = this._def.schema._parseSync({
3645
+ data: processed,
3646
+ path: ctx.path,
3647
+ parent: ctx
3648
+ });
3649
+ if (result.status === "aborted")
3650
+ return INVALID;
3651
+ if (result.status === "dirty")
3652
+ return DIRTY(result.value);
3653
+ if (status.value === "dirty")
3654
+ return DIRTY(result.value);
3655
+ return result;
3656
+ }
3657
+ }
3658
+ if (effect.type === "refinement") {
3659
+ const executeRefinement = (acc) => {
3660
+ const result = effect.refinement(acc, checkCtx);
3661
+ if (ctx.common.async) {
3662
+ return Promise.resolve(result);
3663
+ }
3664
+ if (result instanceof Promise) {
3665
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3666
+ }
3667
+ return acc;
3668
+ };
3669
+ if (ctx.common.async === false) {
3670
+ const inner = this._def.schema._parseSync({
3671
+ data: ctx.data,
3672
+ path: ctx.path,
3673
+ parent: ctx
3674
+ });
3675
+ if (inner.status === "aborted")
3676
+ return INVALID;
3677
+ if (inner.status === "dirty")
3678
+ status.dirty();
3679
+ executeRefinement(inner.value);
3680
+ return { status: status.value, value: inner.value };
3681
+ } else {
3682
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3683
+ if (inner.status === "aborted")
3684
+ return INVALID;
3685
+ if (inner.status === "dirty")
3686
+ status.dirty();
3687
+ return executeRefinement(inner.value).then(() => {
3688
+ return { status: status.value, value: inner.value };
3689
+ });
3690
+ });
3691
+ }
3692
+ }
3693
+ if (effect.type === "transform") {
3694
+ if (ctx.common.async === false) {
3695
+ const base = this._def.schema._parseSync({
3696
+ data: ctx.data,
3697
+ path: ctx.path,
3698
+ parent: ctx
3699
+ });
3700
+ if (!isValid(base))
3701
+ return INVALID;
3702
+ const result = effect.transform(base.value, checkCtx);
3703
+ if (result instanceof Promise) {
3704
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3705
+ }
3706
+ return { status: status.value, value: result };
3707
+ } else {
3708
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3709
+ if (!isValid(base))
3710
+ return INVALID;
3711
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3712
+ status: status.value,
3713
+ value: result
3714
+ }));
3715
+ });
3716
+ }
3717
+ }
3718
+ util.assertNever(effect);
3719
+ }
3720
+ };
3721
+ ZodEffects.create = (schema, effect, params) => {
3722
+ return new ZodEffects({
3723
+ schema,
3724
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3725
+ effect,
3726
+ ...processCreateParams(params)
3727
+ });
3728
+ };
3729
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3730
+ return new ZodEffects({
3731
+ schema,
3732
+ effect: { type: "preprocess", transform: preprocess },
3733
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3734
+ ...processCreateParams(params)
3735
+ });
3736
+ };
3737
+ var ZodOptional = class extends ZodType {
3738
+ _parse(input) {
3739
+ const parsedType = this._getType(input);
3740
+ if (parsedType === ZodParsedType.undefined) {
3741
+ return OK(void 0);
3742
+ }
3743
+ return this._def.innerType._parse(input);
3744
+ }
3745
+ unwrap() {
3746
+ return this._def.innerType;
3747
+ }
3748
+ };
3749
+ ZodOptional.create = (type, params) => {
3750
+ return new ZodOptional({
3751
+ innerType: type,
3752
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3753
+ ...processCreateParams(params)
3754
+ });
3755
+ };
3756
+ var ZodNullable = class extends ZodType {
3757
+ _parse(input) {
3758
+ const parsedType = this._getType(input);
3759
+ if (parsedType === ZodParsedType.null) {
3760
+ return OK(null);
3761
+ }
3762
+ return this._def.innerType._parse(input);
3763
+ }
3764
+ unwrap() {
3765
+ return this._def.innerType;
3766
+ }
3767
+ };
3768
+ ZodNullable.create = (type, params) => {
3769
+ return new ZodNullable({
3770
+ innerType: type,
3771
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3772
+ ...processCreateParams(params)
3773
+ });
3774
+ };
3775
+ var ZodDefault = class extends ZodType {
3776
+ _parse(input) {
3777
+ const { ctx } = this._processInputParams(input);
3778
+ let data = ctx.data;
3779
+ if (ctx.parsedType === ZodParsedType.undefined) {
3780
+ data = this._def.defaultValue();
3781
+ }
3782
+ return this._def.innerType._parse({
3783
+ data,
3784
+ path: ctx.path,
3785
+ parent: ctx
3786
+ });
3787
+ }
3788
+ removeDefault() {
3789
+ return this._def.innerType;
3790
+ }
3791
+ };
3792
+ ZodDefault.create = (type, params) => {
3793
+ return new ZodDefault({
3794
+ innerType: type,
3795
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3796
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3797
+ ...processCreateParams(params)
3798
+ });
3799
+ };
3800
+ var ZodCatch = class extends ZodType {
3801
+ _parse(input) {
3802
+ const { ctx } = this._processInputParams(input);
3803
+ const newCtx = {
3804
+ ...ctx,
3805
+ common: {
3806
+ ...ctx.common,
3807
+ issues: []
3808
+ }
3809
+ };
3810
+ const result = this._def.innerType._parse({
3811
+ data: newCtx.data,
3812
+ path: newCtx.path,
3813
+ parent: {
3814
+ ...newCtx
3815
+ }
3816
+ });
3817
+ if (isAsync(result)) {
3818
+ return result.then((result2) => {
3819
+ return {
3820
+ status: "valid",
3821
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3822
+ get error() {
3823
+ return new ZodError(newCtx.common.issues);
3824
+ },
3825
+ input: newCtx.data
3826
+ })
3827
+ };
3828
+ });
3829
+ } else {
3830
+ return {
3831
+ status: "valid",
3832
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3833
+ get error() {
3834
+ return new ZodError(newCtx.common.issues);
3835
+ },
3836
+ input: newCtx.data
3837
+ })
3838
+ };
3839
+ }
3840
+ }
3841
+ removeCatch() {
3842
+ return this._def.innerType;
3843
+ }
3844
+ };
3845
+ ZodCatch.create = (type, params) => {
3846
+ return new ZodCatch({
3847
+ innerType: type,
3848
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3849
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3850
+ ...processCreateParams(params)
3851
+ });
3852
+ };
3853
+ var ZodNaN = class extends ZodType {
3854
+ _parse(input) {
3855
+ const parsedType = this._getType(input);
3856
+ if (parsedType !== ZodParsedType.nan) {
3857
+ const ctx = this._getOrReturnCtx(input);
3858
+ addIssueToContext(ctx, {
3859
+ code: ZodIssueCode.invalid_type,
3860
+ expected: ZodParsedType.nan,
3861
+ received: ctx.parsedType
3862
+ });
3863
+ return INVALID;
3864
+ }
3865
+ return { status: "valid", value: input.data };
3866
+ }
3867
+ };
3868
+ ZodNaN.create = (params) => {
3869
+ return new ZodNaN({
3870
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3871
+ ...processCreateParams(params)
3872
+ });
3873
+ };
3874
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
3875
+ var ZodBranded = class extends ZodType {
3876
+ _parse(input) {
3877
+ const { ctx } = this._processInputParams(input);
3878
+ const data = ctx.data;
3879
+ return this._def.type._parse({
3880
+ data,
3881
+ path: ctx.path,
3882
+ parent: ctx
3883
+ });
3884
+ }
3885
+ unwrap() {
3886
+ return this._def.type;
3887
+ }
3888
+ };
3889
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3890
+ _parse(input) {
3891
+ const { status, ctx } = this._processInputParams(input);
3892
+ if (ctx.common.async) {
3893
+ const handleAsync = async () => {
3894
+ const inResult = await this._def.in._parseAsync({
3895
+ data: ctx.data,
3896
+ path: ctx.path,
3897
+ parent: ctx
3898
+ });
3899
+ if (inResult.status === "aborted")
3900
+ return INVALID;
3901
+ if (inResult.status === "dirty") {
3902
+ status.dirty();
3903
+ return DIRTY(inResult.value);
3904
+ } else {
3905
+ return this._def.out._parseAsync({
3906
+ data: inResult.value,
3907
+ path: ctx.path,
3908
+ parent: ctx
3909
+ });
3910
+ }
3911
+ };
3912
+ return handleAsync();
3913
+ } else {
3914
+ const inResult = this._def.in._parseSync({
3915
+ data: ctx.data,
3916
+ path: ctx.path,
3917
+ parent: ctx
3918
+ });
3919
+ if (inResult.status === "aborted")
3920
+ return INVALID;
3921
+ if (inResult.status === "dirty") {
3922
+ status.dirty();
3923
+ return {
3924
+ status: "dirty",
3925
+ value: inResult.value
3926
+ };
3927
+ } else {
3928
+ return this._def.out._parseSync({
3929
+ data: inResult.value,
3930
+ path: ctx.path,
3931
+ parent: ctx
3932
+ });
3933
+ }
3934
+ }
3935
+ }
3936
+ static create(a, b) {
3937
+ return new _ZodPipeline({
3938
+ in: a,
3939
+ out: b,
3940
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3941
+ });
3942
+ }
3943
+ };
3944
+ var ZodReadonly = class extends ZodType {
3945
+ _parse(input) {
3946
+ const result = this._def.innerType._parse(input);
3947
+ const freeze = (data) => {
3948
+ if (isValid(data)) {
3949
+ data.value = Object.freeze(data.value);
3950
+ }
3951
+ return data;
3952
+ };
3953
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3954
+ }
3955
+ unwrap() {
3956
+ return this._def.innerType;
3957
+ }
3958
+ };
3959
+ ZodReadonly.create = (type, params) => {
3960
+ return new ZodReadonly({
3961
+ innerType: type,
3962
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3963
+ ...processCreateParams(params)
3964
+ });
3965
+ };
3966
+ function cleanParams(params, data) {
3967
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3968
+ const p2 = typeof p === "string" ? { message: p } : p;
3969
+ return p2;
3970
+ }
3971
+ function custom(check, _params = {}, fatal) {
3972
+ if (check)
3973
+ return ZodAny.create().superRefine((data, ctx) => {
3974
+ const r = check(data);
3975
+ if (r instanceof Promise) {
3976
+ return r.then((r2) => {
3977
+ if (!r2) {
3978
+ const params = cleanParams(_params, data);
3979
+ const _fatal = params.fatal ?? fatal ?? true;
3980
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3981
+ }
3982
+ });
3983
+ }
3984
+ if (!r) {
3985
+ const params = cleanParams(_params, data);
3986
+ const _fatal = params.fatal ?? fatal ?? true;
3987
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3988
+ }
3989
+ return;
3990
+ });
3991
+ return ZodAny.create();
3992
+ }
3993
+ var late = {
3994
+ object: ZodObject.lazycreate
3995
+ };
3996
+ var ZodFirstPartyTypeKind;
3997
+ (function(ZodFirstPartyTypeKind2) {
3998
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3999
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4000
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4001
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4002
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4003
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4004
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4005
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4006
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4007
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4008
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4009
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4010
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4011
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4012
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4013
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4014
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4015
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4016
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4017
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4018
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4019
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4020
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4021
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4022
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4023
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4024
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4025
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4026
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4027
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4028
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4029
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4030
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4031
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4032
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4033
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4034
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4035
+ var instanceOfType = (cls, params = {
4036
+ message: `Input not instance of ${cls.name}`
4037
+ }) => custom((data) => data instanceof cls, params);
4038
+ var stringType = ZodString.create;
4039
+ var numberType = ZodNumber.create;
4040
+ var nanType = ZodNaN.create;
4041
+ var bigIntType = ZodBigInt.create;
4042
+ var booleanType = ZodBoolean.create;
4043
+ var dateType = ZodDate.create;
4044
+ var symbolType = ZodSymbol.create;
4045
+ var undefinedType = ZodUndefined.create;
4046
+ var nullType = ZodNull.create;
4047
+ var anyType = ZodAny.create;
4048
+ var unknownType = ZodUnknown.create;
4049
+ var neverType = ZodNever.create;
4050
+ var voidType = ZodVoid.create;
4051
+ var arrayType = ZodArray.create;
4052
+ var objectType = ZodObject.create;
4053
+ var strictObjectType = ZodObject.strictCreate;
4054
+ var unionType = ZodUnion.create;
4055
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4056
+ var intersectionType = ZodIntersection.create;
4057
+ var tupleType = ZodTuple.create;
4058
+ var recordType = ZodRecord.create;
4059
+ var mapType = ZodMap.create;
4060
+ var setType = ZodSet.create;
4061
+ var functionType = ZodFunction.create;
4062
+ var lazyType = ZodLazy.create;
4063
+ var literalType = ZodLiteral.create;
4064
+ var enumType = ZodEnum.create;
4065
+ var nativeEnumType = ZodNativeEnum.create;
4066
+ var promiseType = ZodPromise.create;
4067
+ var effectsType = ZodEffects.create;
4068
+ var optionalType = ZodOptional.create;
4069
+ var nullableType = ZodNullable.create;
4070
+ var preprocessType = ZodEffects.createWithPreprocess;
4071
+ var pipelineType = ZodPipeline.create;
4072
+ var ostring = () => stringType().optional();
4073
+ var onumber = () => numberType().optional();
4074
+ var oboolean = () => booleanType().optional();
4075
+ var coerce = {
4076
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4077
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4078
+ boolean: ((arg) => ZodBoolean.create({
4079
+ ...arg,
4080
+ coerce: true
4081
+ })),
4082
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4083
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4084
+ };
4085
+ var NEVER = INVALID;
4086
+
4087
+ // src/schema/match-defaults.ts
4088
+ function defaultMatchOpts() {
4089
+ return {
4090
+ tokenizer: { kind: "ngram", token_length: 3 },
4091
+ token_filters: [{ kind: "downcase" }],
4092
+ k: 6,
4093
+ m: 2048,
4094
+ include_original: true
4095
+ };
4096
+ }
4097
+
33
4098
  // src/schema/index.ts
34
- var import_zod = require("zod");
35
- var eqlCastAsEnum = import_zod.z.enum([
4099
+ var eqlCastAsEnum = external_exports.enum([
36
4100
  "text",
37
4101
  "int",
38
4102
  "small_int",
@@ -41,59 +4105,69 @@ var eqlCastAsEnum = import_zod.z.enum([
41
4105
  "double",
42
4106
  "boolean",
43
4107
  "date",
4108
+ "timestamp",
44
4109
  "jsonb"
45
4110
  ]).default("text");
46
- var castAsEnum = import_zod.z.enum(["bigint", "boolean", "date", "number", "string", "json", "text"]).default("text");
47
- var tokenFilterSchema = import_zod.z.object({
48
- kind: import_zod.z.literal("downcase")
4111
+ var castAsEnum = external_exports.enum([
4112
+ "bigint",
4113
+ "boolean",
4114
+ "date",
4115
+ "timestamp",
4116
+ "number",
4117
+ "string",
4118
+ "json",
4119
+ "text"
4120
+ ]).default("text");
4121
+ var tokenFilterSchema = external_exports.object({
4122
+ kind: external_exports.literal("downcase")
49
4123
  });
50
- var tokenizerSchema = import_zod.z.union([
51
- import_zod.z.object({
52
- kind: import_zod.z.literal("standard")
4124
+ var tokenizerSchema = external_exports.union([
4125
+ external_exports.object({
4126
+ kind: external_exports.literal("standard")
53
4127
  }),
54
- import_zod.z.object({
55
- kind: import_zod.z.literal("ngram"),
56
- token_length: import_zod.z.number()
4128
+ external_exports.object({
4129
+ kind: external_exports.literal("ngram"),
4130
+ token_length: external_exports.number()
57
4131
  })
58
4132
  ]).default({ kind: "ngram", token_length: 3 }).optional();
59
- var oreIndexOptsSchema = import_zod.z.object({});
60
- var uniqueIndexOptsSchema = import_zod.z.object({
61
- token_filters: import_zod.z.array(tokenFilterSchema).default([]).optional()
4133
+ var oreIndexOptsSchema = external_exports.object({});
4134
+ var uniqueIndexOptsSchema = external_exports.object({
4135
+ token_filters: external_exports.array(tokenFilterSchema).default([]).optional()
62
4136
  });
63
- var matchIndexOptsSchema = import_zod.z.object({
4137
+ var matchIndexOptsSchema = external_exports.object({
64
4138
  tokenizer: tokenizerSchema,
65
- token_filters: import_zod.z.array(tokenFilterSchema).default([]).optional(),
66
- k: import_zod.z.number().default(6).optional(),
67
- m: import_zod.z.number().default(2048).optional(),
68
- include_original: import_zod.z.boolean().default(false).optional()
4139
+ token_filters: external_exports.array(tokenFilterSchema).default([]).optional(),
4140
+ k: external_exports.number().default(6).optional(),
4141
+ m: external_exports.number().default(2048).optional(),
4142
+ include_original: external_exports.boolean().default(false).optional()
69
4143
  });
70
- var arrayIndexModeSchema = import_zod.z.union([
71
- import_zod.z.literal("all"),
72
- import_zod.z.literal("none"),
73
- import_zod.z.object({
74
- item: import_zod.z.boolean().optional(),
75
- wildcard: import_zod.z.boolean().optional(),
76
- position: import_zod.z.boolean().optional()
4144
+ var arrayIndexModeSchema = external_exports.union([
4145
+ external_exports.literal("all"),
4146
+ external_exports.literal("none"),
4147
+ external_exports.object({
4148
+ item: external_exports.boolean().optional(),
4149
+ wildcard: external_exports.boolean().optional(),
4150
+ position: external_exports.boolean().optional()
77
4151
  })
78
4152
  ]);
79
- var steVecIndexOptsSchema = import_zod.z.object({
80
- prefix: import_zod.z.string(),
4153
+ var steVecIndexOptsSchema = external_exports.object({
4154
+ prefix: external_exports.string(),
81
4155
  array_index_mode: arrayIndexModeSchema.optional()
82
4156
  });
83
- var indexesSchema = import_zod.z.object({
4157
+ var indexesSchema = external_exports.object({
84
4158
  ore: oreIndexOptsSchema.optional(),
85
4159
  unique: uniqueIndexOptsSchema.optional(),
86
4160
  match: matchIndexOptsSchema.optional(),
87
4161
  ste_vec: steVecIndexOptsSchema.optional()
88
4162
  }).default({});
89
- var columnSchema = import_zod.z.object({
4163
+ var columnSchema = external_exports.object({
90
4164
  cast_as: castAsEnum,
91
4165
  indexes: indexesSchema
92
4166
  }).default({});
93
- var tableSchema = import_zod.z.record(columnSchema).default({});
94
- var tablesSchema = import_zod.z.record(tableSchema).default({});
95
- var encryptConfigSchema = import_zod.z.object({
96
- v: import_zod.z.number(),
4167
+ var tableSchema = external_exports.record(columnSchema).default({});
4168
+ var tablesSchema = external_exports.record(tableSchema).default({});
4169
+ var encryptConfigSchema = external_exports.object({
4170
+ v: external_exports.number(),
97
4171
  tables: tablesSchema
98
4172
  });
99
4173
  var EncryptedField = class {
@@ -238,16 +4312,13 @@ var EncryptedColumn = class {
238
4312
  * ```
239
4313
  */
240
4314
  freeTextSearch(opts) {
4315
+ const defaults = defaultMatchOpts();
241
4316
  this.indexesValue.match = {
242
- tokenizer: opts?.tokenizer ?? { kind: "ngram", token_length: 3 },
243
- token_filters: opts?.token_filters ?? [
244
- {
245
- kind: "downcase"
246
- }
247
- ],
248
- k: opts?.k ?? 6,
249
- m: opts?.m ?? 2048,
250
- include_original: opts?.include_original ?? true
4317
+ tokenizer: opts?.tokenizer ?? defaults.tokenizer,
4318
+ token_filters: opts?.token_filters ?? defaults.token_filters,
4319
+ k: opts?.k ?? defaults.k,
4320
+ m: opts?.m ?? defaults.m,
4321
+ include_original: opts?.include_original ?? defaults.include_original
251
4322
  };
252
4323
  return this;
253
4324
  }
@@ -293,6 +4364,8 @@ var EncryptedTable = class {
293
4364
  this.tableName = tableName;
294
4365
  this.columnBuilders = columnBuilders;
295
4366
  }
4367
+ tableName;
4368
+ columnBuilders;
296
4369
  /**
297
4370
  * Compile this table schema into a `TableDefinition` used internally by the encryption client.
298
4371
  *
@@ -367,7 +4440,7 @@ function encryptedColumn(columnName) {
367
4440
 
368
4441
  // src/drizzle/schema-extraction.ts
369
4442
  function extractEncryptionSchema(table) {
370
- const tableName = table[Symbol.for("drizzle:Name")];
4443
+ const tableName = table[/* @__PURE__ */ Symbol.for("drizzle:Name")];
371
4444
  if (!tableName) {
372
4445
  throw new Error(
373
4446
  "Unable to extract table name from Drizzle table. Ensure you are using a table created with pgTable()."
@@ -421,24 +4494,12 @@ function extractEncryptionSchema(table) {
421
4494
  return encryptedTable(tableName, columns);
422
4495
  }
423
4496
 
424
- // src/types.ts
425
- var queryTypes = {
426
- orderAndRange: "orderAndRange",
427
- freeTextSearch: "freeTextSearch",
428
- equality: "equality",
429
- steVecSelector: "steVecSelector",
430
- steVecTerm: "steVecTerm",
431
- searchableJson: "searchableJson"
432
- };
433
-
434
4497
  // src/drizzle/operators.ts
435
- var import_drizzle_orm = require("drizzle-orm");
436
- var import_drizzle_orm2 = require("drizzle-orm");
437
4498
  function isSQLWrapper(value) {
438
4499
  return typeof value === "object" && value !== null && "sql" in value && typeof value.sql !== "undefined";
439
4500
  }
440
4501
  function isPgTable(value) {
441
- return typeof value === "object" && value !== null && Symbol.for("drizzle:Name") in value;
4502
+ return typeof value === "object" && value !== null && /* @__PURE__ */ Symbol.for("drizzle:Name") in value;
442
4503
  }
443
4504
  var EncryptionOperatorError = class extends Error {
444
4505
  constructor(message, context) {
@@ -446,6 +4507,7 @@ var EncryptionOperatorError = class extends Error {
446
4507
  this.context = context;
447
4508
  this.name = "EncryptionOperatorError";
448
4509
  }
4510
+ context;
449
4511
  };
450
4512
  var EncryptionConfigError = class extends EncryptionOperatorError {
451
4513
  constructor(message, context) {
@@ -458,7 +4520,7 @@ function getDrizzleTableName(drizzleTable) {
458
4520
  return void 0;
459
4521
  }
460
4522
  const tableWithSymbol = drizzleTable;
461
- return tableWithSymbol[Symbol.for("drizzle:Name")];
4523
+ return tableWithSymbol[/* @__PURE__ */ Symbol.for("drizzle:Name")];
462
4524
  }
463
4525
  function getDrizzleTableFromColumn(drizzleColumn) {
464
4526
  const column = drizzleColumn;
@@ -784,7 +4846,7 @@ function createComparisonOperator(operator, left, right, columnInfo, encryptionC
784
4846
  }
785
4847
  );
786
4848
  }
787
- return import_drizzle_orm2.sql`eql_v2.${import_drizzle_orm2.sql.raw(operator)}(${left}, ${(0, import_drizzle_orm2.bindIfParam)(encrypted, left)})`;
4849
+ return import_drizzle_orm.sql`eql_v2.${import_drizzle_orm.sql.raw(operator)}(${left}, ${(0, import_drizzle_orm.bindIfParam)(encrypted, left)})`;
788
4850
  };
789
4851
  return createLazyOperator(
790
4852
  operator,
@@ -853,8 +4915,8 @@ function createRangeOperator(operator, left, min, max, columnInfo, encryptionCli
853
4915
  }
854
4916
  );
855
4917
  }
856
- const rangeCondition = import_drizzle_orm2.sql`eql_v2.gte(${left}, ${(0, import_drizzle_orm2.bindIfParam)(encryptedMin, left)}) AND eql_v2.lte(${left}, ${(0, import_drizzle_orm2.bindIfParam)(encryptedMax, left)})`;
857
- return operator === "between" ? rangeCondition : import_drizzle_orm2.sql`NOT (${rangeCondition})`;
4918
+ const rangeCondition = import_drizzle_orm.sql`eql_v2.gte(${left}, ${(0, import_drizzle_orm.bindIfParam)(encryptedMin, left)}) AND eql_v2.lte(${left}, ${(0, import_drizzle_orm.bindIfParam)(encryptedMax, left)})`;
4919
+ return operator === "between" ? rangeCondition : import_drizzle_orm.sql`NOT (${rangeCondition})`;
858
4920
  };
859
4921
  return createLazyOperator(
860
4922
  operator,
@@ -895,8 +4957,8 @@ function createTextSearchOperator(operator, left, right, columnInfo, encryptionC
895
4957
  }
896
4958
  );
897
4959
  }
898
- const sqlFn = import_drizzle_orm2.sql`eql_v2.${import_drizzle_orm2.sql.raw(operator === "notIlike" ? "ilike" : operator)}(${left}, ${(0, import_drizzle_orm2.bindIfParam)(encrypted, left)})`;
899
- return operator === "notIlike" ? import_drizzle_orm2.sql`NOT (${sqlFn})` : sqlFn;
4960
+ const sqlFn = import_drizzle_orm.sql`eql_v2.${import_drizzle_orm.sql.raw(operator === "notIlike" ? "ilike" : operator)}(${left}, ${(0, import_drizzle_orm.bindIfParam)(encrypted, left)})`;
4961
+ return operator === "notIlike" ? import_drizzle_orm.sql`NOT (${sqlFn})` : sqlFn;
900
4962
  };
901
4963
  return createLazyOperator(
902
4964
  operator,
@@ -917,7 +4979,7 @@ function createTextSearchOperator(operator, left, right, columnInfo, encryptionC
917
4979
  }
918
4980
  function createJsonbOperator(operator, left, right, columnInfo, encryptionClient, defaultTable, tableCache) {
919
4981
  const { config } = columnInfo;
920
- const encryptedSelector = (value) => import_drizzle_orm2.sql`${(0, import_drizzle_orm2.bindIfParam)(value, left)}::eql_v2_encrypted`;
4982
+ const encryptedSelector = (value) => import_drizzle_orm.sql`${(0, import_drizzle_orm.bindIfParam)(value, left)}::eql_v2_encrypted`;
921
4983
  if (!config?.searchableJson) {
922
4984
  throw new EncryptionOperatorError(
923
4985
  `The ${operator} operator requires searchableJson to be enabled on the column configuration.`,
@@ -941,11 +5003,11 @@ function createJsonbOperator(operator, left, right, columnInfo, encryptionClient
941
5003
  }
942
5004
  switch (operator) {
943
5005
  case "jsonbPathQueryFirst":
944
- return import_drizzle_orm2.sql`eql_v2.jsonb_path_query_first(${left}, ${encryptedSelector(encrypted)})`;
5006
+ return import_drizzle_orm.sql`eql_v2.jsonb_path_query_first(${left}, ${encryptedSelector(encrypted)})`;
945
5007
  case "jsonbGet":
946
- return import_drizzle_orm2.sql`${left} -> ${encryptedSelector(encrypted)}`;
5008
+ return import_drizzle_orm.sql`${left} -> ${encryptedSelector(encrypted)}`;
947
5009
  case "jsonbPathExists":
948
- return import_drizzle_orm2.sql`eql_v2.jsonb_path_exists(${left}, ${encryptedSelector(encrypted)})`;
5010
+ return import_drizzle_orm.sql`eql_v2.jsonb_path_exists(${left}, ${encryptedSelector(encrypted)})`;
949
5011
  }
950
5012
  };
951
5013
  return createLazyOperator(
@@ -1156,10 +5218,10 @@ function createEncryptionOperators(encryptionClient) {
1156
5218
  );
1157
5219
  const conditions = encryptedValues.filter((encrypted) => encrypted !== void 0).map((encrypted) => (0, import_drizzle_orm.eq)(left, encrypted));
1158
5220
  if (conditions.length === 0) {
1159
- return import_drizzle_orm2.sql`false`;
5221
+ return import_drizzle_orm.sql`false`;
1160
5222
  }
1161
5223
  const combined = (0, import_drizzle_orm.or)(...conditions);
1162
- return combined ?? import_drizzle_orm2.sql`false`;
5224
+ return combined ?? import_drizzle_orm.sql`false`;
1163
5225
  };
1164
5226
  const encryptedNotInArray = async (left, right) => {
1165
5227
  if (isSQLWrapper(right)) {
@@ -1184,22 +5246,22 @@ function createEncryptionOperators(encryptionClient) {
1184
5246
  );
1185
5247
  const conditions = encryptedValues.filter((encrypted) => encrypted !== void 0).map((encrypted) => (0, import_drizzle_orm.ne)(left, encrypted));
1186
5248
  if (conditions.length === 0) {
1187
- return import_drizzle_orm2.sql`true`;
5249
+ return import_drizzle_orm.sql`true`;
1188
5250
  }
1189
5251
  const combined = (0, import_drizzle_orm.and)(...conditions);
1190
- return combined ?? import_drizzle_orm2.sql`true`;
5252
+ return combined ?? import_drizzle_orm.sql`true`;
1191
5253
  };
1192
5254
  const encryptedAsc = (column) => {
1193
5255
  const columnInfo = getColumnInfo(column, defaultTable, tableCache);
1194
5256
  if (columnInfo.config?.orderAndRange) {
1195
- return (0, import_drizzle_orm.asc)(import_drizzle_orm2.sql`eql_v2.order_by(${column})`);
5257
+ return (0, import_drizzle_orm.asc)(import_drizzle_orm.sql`eql_v2.order_by(${column})`);
1196
5258
  }
1197
5259
  return (0, import_drizzle_orm.asc)(column);
1198
5260
  };
1199
5261
  const encryptedDesc = (column) => {
1200
5262
  const columnInfo = getColumnInfo(column, defaultTable, tableCache);
1201
5263
  if (columnInfo.config?.orderAndRange) {
1202
- return (0, import_drizzle_orm.desc)(import_drizzle_orm2.sql`eql_v2.order_by(${column})`);
5264
+ return (0, import_drizzle_orm.desc)(import_drizzle_orm.sql`eql_v2.order_by(${column})`);
1203
5265
  }
1204
5266
  return (0, import_drizzle_orm.desc)(column);
1205
5267
  };
@@ -1228,7 +5290,7 @@ function createEncryptionOperators(encryptionClient) {
1228
5290
  ...regularConditions,
1229
5291
  ...await Promise.all(regularPromises)
1230
5292
  ];
1231
- return (0, import_drizzle_orm.and)(...allConditions2) ?? import_drizzle_orm2.sql`true`;
5293
+ return (0, import_drizzle_orm.and)(...allConditions2) ?? import_drizzle_orm.sql`true`;
1232
5294
  }
1233
5295
  const valuesToEncrypt = [];
1234
5296
  for (let i = 0; i < lazyOperators.length; i++) {
@@ -1321,7 +5383,7 @@ function createEncryptionOperators(encryptionClient) {
1321
5383
  ...sqlConditions,
1322
5384
  ...regularPromisesResults
1323
5385
  ];
1324
- return (0, import_drizzle_orm.and)(...allConditions) ?? import_drizzle_orm2.sql`true`;
5386
+ return (0, import_drizzle_orm.and)(...allConditions) ?? import_drizzle_orm.sql`true`;
1325
5387
  };
1326
5388
  const encryptedOr = async (...conditions) => {
1327
5389
  const lazyOperators = [];
@@ -1348,7 +5410,7 @@ function createEncryptionOperators(encryptionClient) {
1348
5410
  ...regularConditions,
1349
5411
  ...await Promise.all(regularPromises)
1350
5412
  ];
1351
- return (0, import_drizzle_orm.or)(...allConditions2) ?? import_drizzle_orm2.sql`false`;
5413
+ return (0, import_drizzle_orm.or)(...allConditions2) ?? import_drizzle_orm.sql`false`;
1352
5414
  }
1353
5415
  const valuesToEncrypt = [];
1354
5416
  for (let i = 0; i < lazyOperators.length; i++) {
@@ -1441,7 +5503,7 @@ function createEncryptionOperators(encryptionClient) {
1441
5503
  ...sqlConditions,
1442
5504
  ...regularPromisesResults
1443
5505
  ];
1444
- return (0, import_drizzle_orm.or)(...allConditions) ?? import_drizzle_orm2.sql`false`;
5506
+ return (0, import_drizzle_orm.or)(...allConditions) ?? import_drizzle_orm.sql`false`;
1445
5507
  };
1446
5508
  return {
1447
5509
  // Comparison operators