@spscommerce/asst-api 4.1.1 → 4.2.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 (73) hide show
  1. package/package.json +4 -4
  2. package/dist/CompanyBriefByOrg-57oGCtjK.d.ts +0 -3427
  3. package/dist/CompanyBriefByOrg-LTdsUKm4.d.ts +0 -3427
  4. package/dist/CompanyBriefByOrg-itus4RMD.d.cts +0 -131
  5. package/dist/CompanyBriefByOrg-itus4RMD.d.ts +0 -131
  6. package/dist/chunk-27XV7TS2.js +0 -522
  7. package/dist/chunk-2VJS5KPH.js +0 -5182
  8. package/dist/chunk-2W3LZ4AO.js +0 -513
  9. package/dist/chunk-3XNXQYIB.js +0 -521
  10. package/dist/chunk-4C475UZX.js +0 -5164
  11. package/dist/chunk-5AROSGQB.js +0 -5034
  12. package/dist/chunk-7F5CQRS2.js +0 -567
  13. package/dist/chunk-7OEXJIWW.js +0 -565
  14. package/dist/chunk-A22SEYVL.js +0 -530
  15. package/dist/chunk-AH5MG2WF.js +0 -5040
  16. package/dist/chunk-BDSSH6MN.js +0 -574
  17. package/dist/chunk-BFIQVABZ.js +0 -528
  18. package/dist/chunk-BJTO4CRW.js +0 -558
  19. package/dist/chunk-BLMS4KUD.js +0 -5164
  20. package/dist/chunk-BTNVA4NZ.js +0 -568
  21. package/dist/chunk-CNQTNX3M.js +0 -567
  22. package/dist/chunk-CUVSWUIQ.js +0 -5040
  23. package/dist/chunk-DP2ZMQG5.js +0 -4881
  24. package/dist/chunk-EMBJNPTB.js +0 -5040
  25. package/dist/chunk-EO2UMCWY.js +0 -574
  26. package/dist/chunk-FTB465WY.js +0 -575
  27. package/dist/chunk-G6A4EVAL.js +0 -528
  28. package/dist/chunk-GDARBI5R.js +0 -5185
  29. package/dist/chunk-HY2SRD5L.js +0 -5003
  30. package/dist/chunk-ISQ3LQRI.js +0 -565
  31. package/dist/chunk-KKX3CXHP.js +0 -558
  32. package/dist/chunk-LJVJ4SYE.js +0 -568
  33. package/dist/chunk-LYMA4XGG.js +0 -5181
  34. package/dist/chunk-MLAU3LFL.js +0 -527
  35. package/dist/chunk-MQREZR54.js +0 -5164
  36. package/dist/chunk-N4A4BVKV.js +0 -5163
  37. package/dist/chunk-QVEV57JA.js +0 -5185
  38. package/dist/chunk-SI7CWAHC.js +0 -574
  39. package/dist/chunk-SK6U2JDX.js +0 -566
  40. package/dist/chunk-SQBB5K5J.js +0 -574
  41. package/dist/chunk-TQ2IQDSM.js +0 -568
  42. package/dist/chunk-TTT6PM27.js +0 -558
  43. package/dist/chunk-VFMKDLXO.js +0 -570
  44. package/dist/chunk-VKPQOGVS.js +0 -565
  45. package/dist/chunk-VLLI4AYA.js +0 -520
  46. package/dist/chunk-VNFLJ5FV.js +0 -530
  47. package/dist/chunk-WNCDQJEM.js +0 -5034
  48. package/dist/chunk-XYZVRJF3.js +0 -5162
  49. package/dist/chunk-YJCJB4OT.js +0 -79
  50. package/dist/chunk-YJMQ4PGM.js +0 -559
  51. package/dist/chunk-Z6PXGHNC.js +0 -570
  52. package/dist/chunk-ZQ32XEVW.js +0 -79
  53. package/dist/chunk-ZXXDLGW7.js +0 -513
  54. package/dist/index-B8ovDTs5.d.cts +0 -14
  55. package/dist/index-BFKgtuVI.d.ts +0 -14
  56. package/dist/index-Zz-6wNSh.d.ts +0 -106
  57. package/dist/index-fgr_c5Wj.d.ts +0 -106
  58. package/dist/zod-6gU8y6oS.d.cts +0 -6712
  59. package/dist/zod-B4sIVoVX.d.ts +0 -6712
  60. package/dist/zod-BI81QHVK.d.ts +0 -6715
  61. package/dist/zod-BUCQsGOm.d.ts +0 -6712
  62. package/dist/zod-BdDmL7rg.d.ts +0 -6718
  63. package/dist/zod-Bl_5j5Nx.d.ts +0 -6712
  64. package/dist/zod-Bxu34bbp.d.ts +0 -6718
  65. package/dist/zod-C4kEHhO8.d.cts +0 -6718
  66. package/dist/zod-C5pRCHei.d.ts +0 -6712
  67. package/dist/zod-CIacR1Kf.d.cts +0 -6712
  68. package/dist/zod-DBbdP-KT.d.cts +0 -6718
  69. package/dist/zod-DzhoVlw_.d.cts +0 -6712
  70. package/dist/zod-FdtLO2-F.d.cts +0 -6715
  71. package/dist/zod-NE2xXWlK.d.ts +0 -3416
  72. package/dist/zod-lSiFMzqK.d.cts +0 -6712
  73. package/dist/zod-zxqlYYMG.d.ts +0 -3416
@@ -1,4881 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/external.js
8
- var external_exports = {};
9
- __export(external_exports, {
10
- BRAND: () => BRAND,
11
- DIRTY: () => DIRTY,
12
- EMPTY_PATH: () => EMPTY_PATH,
13
- INVALID: () => INVALID,
14
- NEVER: () => NEVER,
15
- OK: () => OK,
16
- ParseStatus: () => ParseStatus,
17
- Schema: () => ZodType,
18
- ZodAny: () => ZodAny,
19
- ZodArray: () => ZodArray,
20
- ZodBigInt: () => ZodBigInt,
21
- ZodBoolean: () => ZodBoolean,
22
- ZodBranded: () => ZodBranded,
23
- ZodCatch: () => ZodCatch,
24
- ZodDate: () => ZodDate,
25
- ZodDefault: () => ZodDefault,
26
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
27
- ZodEffects: () => ZodEffects,
28
- ZodEnum: () => ZodEnum,
29
- ZodError: () => ZodError,
30
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
31
- ZodFunction: () => ZodFunction,
32
- ZodIntersection: () => ZodIntersection,
33
- ZodIssueCode: () => ZodIssueCode,
34
- ZodLazy: () => ZodLazy,
35
- ZodLiteral: () => ZodLiteral,
36
- ZodMap: () => ZodMap,
37
- ZodNaN: () => ZodNaN,
38
- ZodNativeEnum: () => ZodNativeEnum,
39
- ZodNever: () => ZodNever,
40
- ZodNull: () => ZodNull,
41
- ZodNullable: () => ZodNullable,
42
- ZodNumber: () => ZodNumber,
43
- ZodObject: () => ZodObject,
44
- ZodOptional: () => ZodOptional,
45
- ZodParsedType: () => ZodParsedType,
46
- ZodPipeline: () => ZodPipeline,
47
- ZodPromise: () => ZodPromise,
48
- ZodReadonly: () => ZodReadonly,
49
- ZodRecord: () => ZodRecord,
50
- ZodSchema: () => ZodType,
51
- ZodSet: () => ZodSet,
52
- ZodString: () => ZodString,
53
- ZodSymbol: () => ZodSymbol,
54
- ZodTransformer: () => ZodEffects,
55
- ZodTuple: () => ZodTuple,
56
- ZodType: () => ZodType,
57
- ZodUndefined: () => ZodUndefined,
58
- ZodUnion: () => ZodUnion,
59
- ZodUnknown: () => ZodUnknown,
60
- ZodVoid: () => ZodVoid,
61
- addIssueToContext: () => addIssueToContext,
62
- any: () => anyType,
63
- array: () => arrayType,
64
- bigint: () => bigIntType,
65
- boolean: () => booleanType,
66
- coerce: () => coerce,
67
- custom: () => custom,
68
- date: () => dateType,
69
- datetimeRegex: () => datetimeRegex,
70
- defaultErrorMap: () => en_default,
71
- discriminatedUnion: () => discriminatedUnionType,
72
- effect: () => effectsType,
73
- enum: () => enumType,
74
- function: () => functionType,
75
- getErrorMap: () => getErrorMap,
76
- getParsedType: () => getParsedType,
77
- instanceof: () => instanceOfType,
78
- intersection: () => intersectionType,
79
- isAborted: () => isAborted,
80
- isAsync: () => isAsync,
81
- isDirty: () => isDirty,
82
- isValid: () => isValid,
83
- late: () => late,
84
- lazy: () => lazyType,
85
- literal: () => literalType,
86
- makeIssue: () => makeIssue,
87
- map: () => mapType,
88
- nan: () => nanType,
89
- nativeEnum: () => nativeEnumType,
90
- never: () => neverType,
91
- null: () => nullType,
92
- nullable: () => nullableType,
93
- number: () => numberType,
94
- object: () => objectType,
95
- objectUtil: () => objectUtil,
96
- oboolean: () => oboolean,
97
- onumber: () => onumber,
98
- optional: () => optionalType,
99
- ostring: () => ostring,
100
- pipeline: () => pipelineType,
101
- preprocess: () => preprocessType,
102
- promise: () => promiseType,
103
- quotelessJson: () => quotelessJson,
104
- record: () => recordType,
105
- set: () => setType,
106
- setErrorMap: () => setErrorMap,
107
- strictObject: () => strictObjectType,
108
- string: () => stringType,
109
- symbol: () => symbolType,
110
- transformer: () => effectsType,
111
- tuple: () => tupleType,
112
- undefined: () => undefinedType,
113
- union: () => unionType,
114
- unknown: () => unknownType,
115
- util: () => util,
116
- void: () => voidType
117
- });
118
-
119
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/helpers/util.js
120
- var util;
121
- (function(util2) {
122
- util2.assertEqual = (_) => {
123
- };
124
- function assertIs(_arg) {
125
- }
126
- util2.assertIs = assertIs;
127
- function assertNever(_x) {
128
- throw new Error();
129
- }
130
- util2.assertNever = assertNever;
131
- util2.arrayToEnum = (items) => {
132
- const obj = {};
133
- for (const item of items) {
134
- obj[item] = item;
135
- }
136
- return obj;
137
- };
138
- util2.getValidEnumValues = (obj) => {
139
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
140
- const filtered = {};
141
- for (const k of validKeys) {
142
- filtered[k] = obj[k];
143
- }
144
- return util2.objectValues(filtered);
145
- };
146
- util2.objectValues = (obj) => {
147
- return util2.objectKeys(obj).map(function(e) {
148
- return obj[e];
149
- });
150
- };
151
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
152
- const keys = [];
153
- for (const key in object) {
154
- if (Object.prototype.hasOwnProperty.call(object, key)) {
155
- keys.push(key);
156
- }
157
- }
158
- return keys;
159
- };
160
- util2.find = (arr, checker) => {
161
- for (const item of arr) {
162
- if (checker(item))
163
- return item;
164
- }
165
- return void 0;
166
- };
167
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
168
- function joinValues(array, separator = " | ") {
169
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
170
- }
171
- util2.joinValues = joinValues;
172
- util2.jsonStringifyReplacer = (_, value) => {
173
- if (typeof value === "bigint") {
174
- return value.toString();
175
- }
176
- return value;
177
- };
178
- })(util || (util = {}));
179
- var objectUtil;
180
- (function(objectUtil2) {
181
- objectUtil2.mergeShapes = (first, second) => {
182
- return {
183
- ...first,
184
- ...second
185
- // second overwrites first
186
- };
187
- };
188
- })(objectUtil || (objectUtil = {}));
189
- var ZodParsedType = util.arrayToEnum([
190
- "string",
191
- "nan",
192
- "number",
193
- "integer",
194
- "float",
195
- "boolean",
196
- "date",
197
- "bigint",
198
- "symbol",
199
- "function",
200
- "undefined",
201
- "null",
202
- "array",
203
- "object",
204
- "unknown",
205
- "promise",
206
- "void",
207
- "never",
208
- "map",
209
- "set"
210
- ]);
211
- var getParsedType = (data) => {
212
- const t = typeof data;
213
- switch (t) {
214
- case "undefined":
215
- return ZodParsedType.undefined;
216
- case "string":
217
- return ZodParsedType.string;
218
- case "number":
219
- return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
220
- case "boolean":
221
- return ZodParsedType.boolean;
222
- case "function":
223
- return ZodParsedType.function;
224
- case "bigint":
225
- return ZodParsedType.bigint;
226
- case "symbol":
227
- return ZodParsedType.symbol;
228
- case "object":
229
- if (Array.isArray(data)) {
230
- return ZodParsedType.array;
231
- }
232
- if (data === null) {
233
- return ZodParsedType.null;
234
- }
235
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
236
- return ZodParsedType.promise;
237
- }
238
- if (typeof Map !== "undefined" && data instanceof Map) {
239
- return ZodParsedType.map;
240
- }
241
- if (typeof Set !== "undefined" && data instanceof Set) {
242
- return ZodParsedType.set;
243
- }
244
- if (typeof Date !== "undefined" && data instanceof Date) {
245
- return ZodParsedType.date;
246
- }
247
- return ZodParsedType.object;
248
- default:
249
- return ZodParsedType.unknown;
250
- }
251
- };
252
-
253
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/ZodError.js
254
- var ZodIssueCode = util.arrayToEnum([
255
- "invalid_type",
256
- "invalid_literal",
257
- "custom",
258
- "invalid_union",
259
- "invalid_union_discriminator",
260
- "invalid_enum_value",
261
- "unrecognized_keys",
262
- "invalid_arguments",
263
- "invalid_return_type",
264
- "invalid_date",
265
- "invalid_string",
266
- "too_small",
267
- "too_big",
268
- "invalid_intersection_types",
269
- "not_multiple_of",
270
- "not_finite"
271
- ]);
272
- var quotelessJson = (obj) => {
273
- const json = JSON.stringify(obj, null, 2);
274
- return json.replace(/"([^"]+)":/g, "$1:");
275
- };
276
- var ZodError = class _ZodError extends Error {
277
- get errors() {
278
- return this.issues;
279
- }
280
- constructor(issues) {
281
- super();
282
- this.issues = [];
283
- this.addIssue = (sub) => {
284
- this.issues = [...this.issues, sub];
285
- };
286
- this.addIssues = (subs = []) => {
287
- this.issues = [...this.issues, ...subs];
288
- };
289
- const actualProto = new.target.prototype;
290
- if (Object.setPrototypeOf) {
291
- Object.setPrototypeOf(this, actualProto);
292
- } else {
293
- this.__proto__ = actualProto;
294
- }
295
- this.name = "ZodError";
296
- this.issues = issues;
297
- }
298
- format(_mapper) {
299
- const mapper = _mapper || function(issue) {
300
- return issue.message;
301
- };
302
- const fieldErrors = { _errors: [] };
303
- const processError = (error) => {
304
- for (const issue of error.issues) {
305
- if (issue.code === "invalid_union") {
306
- issue.unionErrors.map(processError);
307
- } else if (issue.code === "invalid_return_type") {
308
- processError(issue.returnTypeError);
309
- } else if (issue.code === "invalid_arguments") {
310
- processError(issue.argumentsError);
311
- } else if (issue.path.length === 0) {
312
- fieldErrors._errors.push(mapper(issue));
313
- } else {
314
- let curr = fieldErrors;
315
- let i = 0;
316
- while (i < issue.path.length) {
317
- const el = issue.path[i];
318
- const terminal = i === issue.path.length - 1;
319
- if (!terminal) {
320
- curr[el] = curr[el] || { _errors: [] };
321
- } else {
322
- curr[el] = curr[el] || { _errors: [] };
323
- curr[el]._errors.push(mapper(issue));
324
- }
325
- curr = curr[el];
326
- i++;
327
- }
328
- }
329
- }
330
- };
331
- processError(this);
332
- return fieldErrors;
333
- }
334
- static assert(value) {
335
- if (!(value instanceof _ZodError)) {
336
- throw new Error(`Not a ZodError: ${value}`);
337
- }
338
- }
339
- toString() {
340
- return this.message;
341
- }
342
- get message() {
343
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
344
- }
345
- get isEmpty() {
346
- return this.issues.length === 0;
347
- }
348
- flatten(mapper = (issue) => issue.message) {
349
- const fieldErrors = {};
350
- const formErrors = [];
351
- for (const sub of this.issues) {
352
- if (sub.path.length > 0) {
353
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
354
- fieldErrors[sub.path[0]].push(mapper(sub));
355
- } else {
356
- formErrors.push(mapper(sub));
357
- }
358
- }
359
- return { formErrors, fieldErrors };
360
- }
361
- get formErrors() {
362
- return this.flatten();
363
- }
364
- };
365
- ZodError.create = (issues) => {
366
- const error = new ZodError(issues);
367
- return error;
368
- };
369
-
370
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/locales/en.js
371
- var errorMap = (issue, _ctx) => {
372
- let message;
373
- switch (issue.code) {
374
- case ZodIssueCode.invalid_type:
375
- if (issue.received === ZodParsedType.undefined) {
376
- message = "Required";
377
- } else {
378
- message = `Expected ${issue.expected}, received ${issue.received}`;
379
- }
380
- break;
381
- case ZodIssueCode.invalid_literal:
382
- message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
383
- break;
384
- case ZodIssueCode.unrecognized_keys:
385
- message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
386
- break;
387
- case ZodIssueCode.invalid_union:
388
- message = `Invalid input`;
389
- break;
390
- case ZodIssueCode.invalid_union_discriminator:
391
- message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
392
- break;
393
- case ZodIssueCode.invalid_enum_value:
394
- message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
395
- break;
396
- case ZodIssueCode.invalid_arguments:
397
- message = `Invalid function arguments`;
398
- break;
399
- case ZodIssueCode.invalid_return_type:
400
- message = `Invalid function return type`;
401
- break;
402
- case ZodIssueCode.invalid_date:
403
- message = `Invalid date`;
404
- break;
405
- case ZodIssueCode.invalid_string:
406
- if (typeof issue.validation === "object") {
407
- if ("includes" in issue.validation) {
408
- message = `Invalid input: must include "${issue.validation.includes}"`;
409
- if (typeof issue.validation.position === "number") {
410
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
411
- }
412
- } else if ("startsWith" in issue.validation) {
413
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
414
- } else if ("endsWith" in issue.validation) {
415
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
416
- } else {
417
- util.assertNever(issue.validation);
418
- }
419
- } else if (issue.validation !== "regex") {
420
- message = `Invalid ${issue.validation}`;
421
- } else {
422
- message = "Invalid";
423
- }
424
- break;
425
- case ZodIssueCode.too_small:
426
- if (issue.type === "array")
427
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
428
- else if (issue.type === "string")
429
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
430
- else if (issue.type === "number")
431
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
432
- else if (issue.type === "date")
433
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
434
- else
435
- message = "Invalid input";
436
- break;
437
- case ZodIssueCode.too_big:
438
- if (issue.type === "array")
439
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
440
- else if (issue.type === "string")
441
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
442
- else if (issue.type === "number")
443
- message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
444
- else if (issue.type === "bigint")
445
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
446
- else if (issue.type === "date")
447
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
448
- else
449
- message = "Invalid input";
450
- break;
451
- case ZodIssueCode.custom:
452
- message = `Invalid input`;
453
- break;
454
- case ZodIssueCode.invalid_intersection_types:
455
- message = `Intersection results could not be merged`;
456
- break;
457
- case ZodIssueCode.not_multiple_of:
458
- message = `Number must be a multiple of ${issue.multipleOf}`;
459
- break;
460
- case ZodIssueCode.not_finite:
461
- message = "Number must be finite";
462
- break;
463
- default:
464
- message = _ctx.defaultError;
465
- util.assertNever(issue);
466
- }
467
- return { message };
468
- };
469
- var en_default = errorMap;
470
-
471
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/errors.js
472
- var overrideErrorMap = en_default;
473
- function setErrorMap(map) {
474
- overrideErrorMap = map;
475
- }
476
- function getErrorMap() {
477
- return overrideErrorMap;
478
- }
479
-
480
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/helpers/parseUtil.js
481
- var makeIssue = (params) => {
482
- const { data, path, errorMaps, issueData } = params;
483
- const fullPath = [...path, ...issueData.path || []];
484
- const fullIssue = {
485
- ...issueData,
486
- path: fullPath
487
- };
488
- if (issueData.message !== void 0) {
489
- return {
490
- ...issueData,
491
- path: fullPath,
492
- message: issueData.message
493
- };
494
- }
495
- let errorMessage = "";
496
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
497
- for (const map of maps) {
498
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
499
- }
500
- return {
501
- ...issueData,
502
- path: fullPath,
503
- message: errorMessage
504
- };
505
- };
506
- var EMPTY_PATH = [];
507
- function addIssueToContext(ctx, issueData) {
508
- const overrideMap = getErrorMap();
509
- const issue = makeIssue({
510
- issueData,
511
- data: ctx.data,
512
- path: ctx.path,
513
- errorMaps: [
514
- ctx.common.contextualErrorMap,
515
- // contextual error map is first priority
516
- ctx.schemaErrorMap,
517
- // then schema-bound map if available
518
- overrideMap,
519
- // then global override map
520
- overrideMap === en_default ? void 0 : en_default
521
- // then global default map
522
- ].filter((x) => !!x)
523
- });
524
- ctx.common.issues.push(issue);
525
- }
526
- var ParseStatus = class _ParseStatus {
527
- constructor() {
528
- this.value = "valid";
529
- }
530
- dirty() {
531
- if (this.value === "valid")
532
- this.value = "dirty";
533
- }
534
- abort() {
535
- if (this.value !== "aborted")
536
- this.value = "aborted";
537
- }
538
- static mergeArray(status, results) {
539
- const arrayValue = [];
540
- for (const s of results) {
541
- if (s.status === "aborted")
542
- return INVALID;
543
- if (s.status === "dirty")
544
- status.dirty();
545
- arrayValue.push(s.value);
546
- }
547
- return { status: status.value, value: arrayValue };
548
- }
549
- static async mergeObjectAsync(status, pairs) {
550
- const syncPairs = [];
551
- for (const pair of pairs) {
552
- const key = await pair.key;
553
- const value = await pair.value;
554
- syncPairs.push({
555
- key,
556
- value
557
- });
558
- }
559
- return _ParseStatus.mergeObjectSync(status, syncPairs);
560
- }
561
- static mergeObjectSync(status, pairs) {
562
- const finalObject = {};
563
- for (const pair of pairs) {
564
- const { key, value } = pair;
565
- if (key.status === "aborted")
566
- return INVALID;
567
- if (value.status === "aborted")
568
- return INVALID;
569
- if (key.status === "dirty")
570
- status.dirty();
571
- if (value.status === "dirty")
572
- status.dirty();
573
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
574
- finalObject[key.value] = value.value;
575
- }
576
- }
577
- return { status: status.value, value: finalObject };
578
- }
579
- };
580
- var INVALID = Object.freeze({
581
- status: "aborted"
582
- });
583
- var DIRTY = (value) => ({ status: "dirty", value });
584
- var OK = (value) => ({ status: "valid", value });
585
- var isAborted = (x) => x.status === "aborted";
586
- var isDirty = (x) => x.status === "dirty";
587
- var isValid = (x) => x.status === "valid";
588
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
589
-
590
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/helpers/errorUtil.js
591
- var errorUtil;
592
- (function(errorUtil2) {
593
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
594
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
595
- })(errorUtil || (errorUtil = {}));
596
-
597
- // ../../node_modules/.pnpm/zod@3.25.67/node_modules/zod/dist/esm/v3/types.js
598
- var ParseInputLazyPath = class {
599
- constructor(parent, value, path, key) {
600
- this._cachedPath = [];
601
- this.parent = parent;
602
- this.data = value;
603
- this._path = path;
604
- this._key = key;
605
- }
606
- get path() {
607
- if (!this._cachedPath.length) {
608
- if (Array.isArray(this._key)) {
609
- this._cachedPath.push(...this._path, ...this._key);
610
- } else {
611
- this._cachedPath.push(...this._path, this._key);
612
- }
613
- }
614
- return this._cachedPath;
615
- }
616
- };
617
- var handleResult = (ctx, result) => {
618
- if (isValid(result)) {
619
- return { success: true, data: result.value };
620
- } else {
621
- if (!ctx.common.issues.length) {
622
- throw new Error("Validation failed but no issues detected.");
623
- }
624
- return {
625
- success: false,
626
- get error() {
627
- if (this._error)
628
- return this._error;
629
- const error = new ZodError(ctx.common.issues);
630
- this._error = error;
631
- return this._error;
632
- }
633
- };
634
- }
635
- };
636
- function processCreateParams(params) {
637
- if (!params)
638
- return {};
639
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
640
- if (errorMap2 && (invalid_type_error || required_error)) {
641
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
642
- }
643
- if (errorMap2)
644
- return { errorMap: errorMap2, description };
645
- const customMap = (iss, ctx) => {
646
- const { message } = params;
647
- if (iss.code === "invalid_enum_value") {
648
- return { message: message ?? ctx.defaultError };
649
- }
650
- if (typeof ctx.data === "undefined") {
651
- return { message: message ?? required_error ?? ctx.defaultError };
652
- }
653
- if (iss.code !== "invalid_type")
654
- return { message: ctx.defaultError };
655
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
656
- };
657
- return { errorMap: customMap, description };
658
- }
659
- var ZodType = class {
660
- get description() {
661
- return this._def.description;
662
- }
663
- _getType(input) {
664
- return getParsedType(input.data);
665
- }
666
- _getOrReturnCtx(input, ctx) {
667
- return ctx || {
668
- common: input.parent.common,
669
- data: input.data,
670
- parsedType: getParsedType(input.data),
671
- schemaErrorMap: this._def.errorMap,
672
- path: input.path,
673
- parent: input.parent
674
- };
675
- }
676
- _processInputParams(input) {
677
- return {
678
- status: new ParseStatus(),
679
- ctx: {
680
- common: input.parent.common,
681
- data: input.data,
682
- parsedType: getParsedType(input.data),
683
- schemaErrorMap: this._def.errorMap,
684
- path: input.path,
685
- parent: input.parent
686
- }
687
- };
688
- }
689
- _parseSync(input) {
690
- const result = this._parse(input);
691
- if (isAsync(result)) {
692
- throw new Error("Synchronous parse encountered promise.");
693
- }
694
- return result;
695
- }
696
- _parseAsync(input) {
697
- const result = this._parse(input);
698
- return Promise.resolve(result);
699
- }
700
- parse(data, params) {
701
- const result = this.safeParse(data, params);
702
- if (result.success)
703
- return result.data;
704
- throw result.error;
705
- }
706
- safeParse(data, params) {
707
- const ctx = {
708
- common: {
709
- issues: [],
710
- async: params?.async ?? false,
711
- contextualErrorMap: params?.errorMap
712
- },
713
- path: params?.path || [],
714
- schemaErrorMap: this._def.errorMap,
715
- parent: null,
716
- data,
717
- parsedType: getParsedType(data)
718
- };
719
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
720
- return handleResult(ctx, result);
721
- }
722
- "~validate"(data) {
723
- const ctx = {
724
- common: {
725
- issues: [],
726
- async: !!this["~standard"].async
727
- },
728
- path: [],
729
- schemaErrorMap: this._def.errorMap,
730
- parent: null,
731
- data,
732
- parsedType: getParsedType(data)
733
- };
734
- if (!this["~standard"].async) {
735
- try {
736
- const result = this._parseSync({ data, path: [], parent: ctx });
737
- return isValid(result) ? {
738
- value: result.value
739
- } : {
740
- issues: ctx.common.issues
741
- };
742
- } catch (err) {
743
- if (err?.message?.toLowerCase()?.includes("encountered")) {
744
- this["~standard"].async = true;
745
- }
746
- ctx.common = {
747
- issues: [],
748
- async: true
749
- };
750
- }
751
- }
752
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
753
- value: result.value
754
- } : {
755
- issues: ctx.common.issues
756
- });
757
- }
758
- async parseAsync(data, params) {
759
- const result = await this.safeParseAsync(data, params);
760
- if (result.success)
761
- return result.data;
762
- throw result.error;
763
- }
764
- async safeParseAsync(data, params) {
765
- const ctx = {
766
- common: {
767
- issues: [],
768
- contextualErrorMap: params?.errorMap,
769
- async: true
770
- },
771
- path: params?.path || [],
772
- schemaErrorMap: this._def.errorMap,
773
- parent: null,
774
- data,
775
- parsedType: getParsedType(data)
776
- };
777
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
778
- const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
779
- return handleResult(ctx, result);
780
- }
781
- refine(check, message) {
782
- const getIssueProperties = (val) => {
783
- if (typeof message === "string" || typeof message === "undefined") {
784
- return { message };
785
- } else if (typeof message === "function") {
786
- return message(val);
787
- } else {
788
- return message;
789
- }
790
- };
791
- return this._refinement((val, ctx) => {
792
- const result = check(val);
793
- const setError = () => ctx.addIssue({
794
- code: ZodIssueCode.custom,
795
- ...getIssueProperties(val)
796
- });
797
- if (typeof Promise !== "undefined" && result instanceof Promise) {
798
- return result.then((data) => {
799
- if (!data) {
800
- setError();
801
- return false;
802
- } else {
803
- return true;
804
- }
805
- });
806
- }
807
- if (!result) {
808
- setError();
809
- return false;
810
- } else {
811
- return true;
812
- }
813
- });
814
- }
815
- refinement(check, refinementData) {
816
- return this._refinement((val, ctx) => {
817
- if (!check(val)) {
818
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
819
- return false;
820
- } else {
821
- return true;
822
- }
823
- });
824
- }
825
- _refinement(refinement) {
826
- return new ZodEffects({
827
- schema: this,
828
- typeName: ZodFirstPartyTypeKind.ZodEffects,
829
- effect: { type: "refinement", refinement }
830
- });
831
- }
832
- superRefine(refinement) {
833
- return this._refinement(refinement);
834
- }
835
- constructor(def) {
836
- this.spa = this.safeParseAsync;
837
- this._def = def;
838
- this.parse = this.parse.bind(this);
839
- this.safeParse = this.safeParse.bind(this);
840
- this.parseAsync = this.parseAsync.bind(this);
841
- this.safeParseAsync = this.safeParseAsync.bind(this);
842
- this.spa = this.spa.bind(this);
843
- this.refine = this.refine.bind(this);
844
- this.refinement = this.refinement.bind(this);
845
- this.superRefine = this.superRefine.bind(this);
846
- this.optional = this.optional.bind(this);
847
- this.nullable = this.nullable.bind(this);
848
- this.nullish = this.nullish.bind(this);
849
- this.array = this.array.bind(this);
850
- this.promise = this.promise.bind(this);
851
- this.or = this.or.bind(this);
852
- this.and = this.and.bind(this);
853
- this.transform = this.transform.bind(this);
854
- this.brand = this.brand.bind(this);
855
- this.default = this.default.bind(this);
856
- this.catch = this.catch.bind(this);
857
- this.describe = this.describe.bind(this);
858
- this.pipe = this.pipe.bind(this);
859
- this.readonly = this.readonly.bind(this);
860
- this.isNullable = this.isNullable.bind(this);
861
- this.isOptional = this.isOptional.bind(this);
862
- this["~standard"] = {
863
- version: 1,
864
- vendor: "zod",
865
- validate: (data) => this["~validate"](data)
866
- };
867
- }
868
- optional() {
869
- return ZodOptional.create(this, this._def);
870
- }
871
- nullable() {
872
- return ZodNullable.create(this, this._def);
873
- }
874
- nullish() {
875
- return this.nullable().optional();
876
- }
877
- array() {
878
- return ZodArray.create(this);
879
- }
880
- promise() {
881
- return ZodPromise.create(this, this._def);
882
- }
883
- or(option) {
884
- return ZodUnion.create([this, option], this._def);
885
- }
886
- and(incoming) {
887
- return ZodIntersection.create(this, incoming, this._def);
888
- }
889
- transform(transform) {
890
- return new ZodEffects({
891
- ...processCreateParams(this._def),
892
- schema: this,
893
- typeName: ZodFirstPartyTypeKind.ZodEffects,
894
- effect: { type: "transform", transform }
895
- });
896
- }
897
- default(def) {
898
- const defaultValueFunc = typeof def === "function" ? def : () => def;
899
- return new ZodDefault({
900
- ...processCreateParams(this._def),
901
- innerType: this,
902
- defaultValue: defaultValueFunc,
903
- typeName: ZodFirstPartyTypeKind.ZodDefault
904
- });
905
- }
906
- brand() {
907
- return new ZodBranded({
908
- typeName: ZodFirstPartyTypeKind.ZodBranded,
909
- type: this,
910
- ...processCreateParams(this._def)
911
- });
912
- }
913
- catch(def) {
914
- const catchValueFunc = typeof def === "function" ? def : () => def;
915
- return new ZodCatch({
916
- ...processCreateParams(this._def),
917
- innerType: this,
918
- catchValue: catchValueFunc,
919
- typeName: ZodFirstPartyTypeKind.ZodCatch
920
- });
921
- }
922
- describe(description) {
923
- const This = this.constructor;
924
- return new This({
925
- ...this._def,
926
- description
927
- });
928
- }
929
- pipe(target) {
930
- return ZodPipeline.create(this, target);
931
- }
932
- readonly() {
933
- return ZodReadonly.create(this);
934
- }
935
- isOptional() {
936
- return this.safeParse(void 0).success;
937
- }
938
- isNullable() {
939
- return this.safeParse(null).success;
940
- }
941
- };
942
- var cuidRegex = /^c[^\s-]{8,}$/i;
943
- var cuid2Regex = /^[0-9a-z]+$/;
944
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
945
- 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;
946
- var nanoidRegex = /^[a-z0-9_-]{21}$/i;
947
- var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
948
- 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)?)??$/;
949
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
950
- var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
951
- var emojiRegex;
952
- 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])$/;
953
- 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])$/;
954
- 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]))$/;
955
- 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])$/;
956
- var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
957
- var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
958
- 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])))`;
959
- var dateRegex = new RegExp(`^${dateRegexSource}$`);
960
- function timeRegexSource(args) {
961
- let secondsRegexSource = `[0-5]\\d`;
962
- if (args.precision) {
963
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
964
- } else if (args.precision == null) {
965
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
966
- }
967
- const secondsQuantifier = args.precision ? "+" : "?";
968
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
969
- }
970
- function timeRegex(args) {
971
- return new RegExp(`^${timeRegexSource(args)}$`);
972
- }
973
- function datetimeRegex(args) {
974
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
975
- const opts = [];
976
- opts.push(args.local ? `Z?` : `Z`);
977
- if (args.offset)
978
- opts.push(`([+-]\\d{2}:?\\d{2})`);
979
- regex = `${regex}(${opts.join("|")})`;
980
- return new RegExp(`^${regex}$`);
981
- }
982
- function isValidIP(ip, version) {
983
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
984
- return true;
985
- }
986
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
987
- return true;
988
- }
989
- return false;
990
- }
991
- function isValidJWT(jwt, alg) {
992
- if (!jwtRegex.test(jwt))
993
- return false;
994
- try {
995
- const [header] = jwt.split(".");
996
- const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
997
- const decoded = JSON.parse(atob(base64));
998
- if (typeof decoded !== "object" || decoded === null)
999
- return false;
1000
- if ("typ" in decoded && decoded?.typ !== "JWT")
1001
- return false;
1002
- if (!decoded.alg)
1003
- return false;
1004
- if (alg && decoded.alg !== alg)
1005
- return false;
1006
- return true;
1007
- } catch {
1008
- return false;
1009
- }
1010
- }
1011
- function isValidCidr(ip, version) {
1012
- if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1013
- return true;
1014
- }
1015
- if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1016
- return true;
1017
- }
1018
- return false;
1019
- }
1020
- var ZodString = class _ZodString extends ZodType {
1021
- _parse(input) {
1022
- if (this._def.coerce) {
1023
- input.data = String(input.data);
1024
- }
1025
- const parsedType = this._getType(input);
1026
- if (parsedType !== ZodParsedType.string) {
1027
- const ctx2 = this._getOrReturnCtx(input);
1028
- addIssueToContext(ctx2, {
1029
- code: ZodIssueCode.invalid_type,
1030
- expected: ZodParsedType.string,
1031
- received: ctx2.parsedType
1032
- });
1033
- return INVALID;
1034
- }
1035
- const status = new ParseStatus();
1036
- let ctx = void 0;
1037
- for (const check of this._def.checks) {
1038
- if (check.kind === "min") {
1039
- if (input.data.length < check.value) {
1040
- ctx = this._getOrReturnCtx(input, ctx);
1041
- addIssueToContext(ctx, {
1042
- code: ZodIssueCode.too_small,
1043
- minimum: check.value,
1044
- type: "string",
1045
- inclusive: true,
1046
- exact: false,
1047
- message: check.message
1048
- });
1049
- status.dirty();
1050
- }
1051
- } else if (check.kind === "max") {
1052
- if (input.data.length > check.value) {
1053
- ctx = this._getOrReturnCtx(input, ctx);
1054
- addIssueToContext(ctx, {
1055
- code: ZodIssueCode.too_big,
1056
- maximum: check.value,
1057
- type: "string",
1058
- inclusive: true,
1059
- exact: false,
1060
- message: check.message
1061
- });
1062
- status.dirty();
1063
- }
1064
- } else if (check.kind === "length") {
1065
- const tooBig = input.data.length > check.value;
1066
- const tooSmall = input.data.length < check.value;
1067
- if (tooBig || tooSmall) {
1068
- ctx = this._getOrReturnCtx(input, ctx);
1069
- if (tooBig) {
1070
- addIssueToContext(ctx, {
1071
- code: ZodIssueCode.too_big,
1072
- maximum: check.value,
1073
- type: "string",
1074
- inclusive: true,
1075
- exact: true,
1076
- message: check.message
1077
- });
1078
- } else if (tooSmall) {
1079
- addIssueToContext(ctx, {
1080
- code: ZodIssueCode.too_small,
1081
- minimum: check.value,
1082
- type: "string",
1083
- inclusive: true,
1084
- exact: true,
1085
- message: check.message
1086
- });
1087
- }
1088
- status.dirty();
1089
- }
1090
- } else if (check.kind === "email") {
1091
- if (!emailRegex.test(input.data)) {
1092
- ctx = this._getOrReturnCtx(input, ctx);
1093
- addIssueToContext(ctx, {
1094
- validation: "email",
1095
- code: ZodIssueCode.invalid_string,
1096
- message: check.message
1097
- });
1098
- status.dirty();
1099
- }
1100
- } else if (check.kind === "emoji") {
1101
- if (!emojiRegex) {
1102
- emojiRegex = new RegExp(_emojiRegex, "u");
1103
- }
1104
- if (!emojiRegex.test(input.data)) {
1105
- ctx = this._getOrReturnCtx(input, ctx);
1106
- addIssueToContext(ctx, {
1107
- validation: "emoji",
1108
- code: ZodIssueCode.invalid_string,
1109
- message: check.message
1110
- });
1111
- status.dirty();
1112
- }
1113
- } else if (check.kind === "uuid") {
1114
- if (!uuidRegex.test(input.data)) {
1115
- ctx = this._getOrReturnCtx(input, ctx);
1116
- addIssueToContext(ctx, {
1117
- validation: "uuid",
1118
- code: ZodIssueCode.invalid_string,
1119
- message: check.message
1120
- });
1121
- status.dirty();
1122
- }
1123
- } else if (check.kind === "nanoid") {
1124
- if (!nanoidRegex.test(input.data)) {
1125
- ctx = this._getOrReturnCtx(input, ctx);
1126
- addIssueToContext(ctx, {
1127
- validation: "nanoid",
1128
- code: ZodIssueCode.invalid_string,
1129
- message: check.message
1130
- });
1131
- status.dirty();
1132
- }
1133
- } else if (check.kind === "cuid") {
1134
- if (!cuidRegex.test(input.data)) {
1135
- ctx = this._getOrReturnCtx(input, ctx);
1136
- addIssueToContext(ctx, {
1137
- validation: "cuid",
1138
- code: ZodIssueCode.invalid_string,
1139
- message: check.message
1140
- });
1141
- status.dirty();
1142
- }
1143
- } else if (check.kind === "cuid2") {
1144
- if (!cuid2Regex.test(input.data)) {
1145
- ctx = this._getOrReturnCtx(input, ctx);
1146
- addIssueToContext(ctx, {
1147
- validation: "cuid2",
1148
- code: ZodIssueCode.invalid_string,
1149
- message: check.message
1150
- });
1151
- status.dirty();
1152
- }
1153
- } else if (check.kind === "ulid") {
1154
- if (!ulidRegex.test(input.data)) {
1155
- ctx = this._getOrReturnCtx(input, ctx);
1156
- addIssueToContext(ctx, {
1157
- validation: "ulid",
1158
- code: ZodIssueCode.invalid_string,
1159
- message: check.message
1160
- });
1161
- status.dirty();
1162
- }
1163
- } else if (check.kind === "url") {
1164
- try {
1165
- new URL(input.data);
1166
- } catch {
1167
- ctx = this._getOrReturnCtx(input, ctx);
1168
- addIssueToContext(ctx, {
1169
- validation: "url",
1170
- code: ZodIssueCode.invalid_string,
1171
- message: check.message
1172
- });
1173
- status.dirty();
1174
- }
1175
- } else if (check.kind === "regex") {
1176
- check.regex.lastIndex = 0;
1177
- const testResult = check.regex.test(input.data);
1178
- if (!testResult) {
1179
- ctx = this._getOrReturnCtx(input, ctx);
1180
- addIssueToContext(ctx, {
1181
- validation: "regex",
1182
- code: ZodIssueCode.invalid_string,
1183
- message: check.message
1184
- });
1185
- status.dirty();
1186
- }
1187
- } else if (check.kind === "trim") {
1188
- input.data = input.data.trim();
1189
- } else if (check.kind === "includes") {
1190
- if (!input.data.includes(check.value, check.position)) {
1191
- ctx = this._getOrReturnCtx(input, ctx);
1192
- addIssueToContext(ctx, {
1193
- code: ZodIssueCode.invalid_string,
1194
- validation: { includes: check.value, position: check.position },
1195
- message: check.message
1196
- });
1197
- status.dirty();
1198
- }
1199
- } else if (check.kind === "toLowerCase") {
1200
- input.data = input.data.toLowerCase();
1201
- } else if (check.kind === "toUpperCase") {
1202
- input.data = input.data.toUpperCase();
1203
- } else if (check.kind === "startsWith") {
1204
- if (!input.data.startsWith(check.value)) {
1205
- ctx = this._getOrReturnCtx(input, ctx);
1206
- addIssueToContext(ctx, {
1207
- code: ZodIssueCode.invalid_string,
1208
- validation: { startsWith: check.value },
1209
- message: check.message
1210
- });
1211
- status.dirty();
1212
- }
1213
- } else if (check.kind === "endsWith") {
1214
- if (!input.data.endsWith(check.value)) {
1215
- ctx = this._getOrReturnCtx(input, ctx);
1216
- addIssueToContext(ctx, {
1217
- code: ZodIssueCode.invalid_string,
1218
- validation: { endsWith: check.value },
1219
- message: check.message
1220
- });
1221
- status.dirty();
1222
- }
1223
- } else if (check.kind === "datetime") {
1224
- const regex = datetimeRegex(check);
1225
- if (!regex.test(input.data)) {
1226
- ctx = this._getOrReturnCtx(input, ctx);
1227
- addIssueToContext(ctx, {
1228
- code: ZodIssueCode.invalid_string,
1229
- validation: "datetime",
1230
- message: check.message
1231
- });
1232
- status.dirty();
1233
- }
1234
- } else if (check.kind === "date") {
1235
- const regex = dateRegex;
1236
- if (!regex.test(input.data)) {
1237
- ctx = this._getOrReturnCtx(input, ctx);
1238
- addIssueToContext(ctx, {
1239
- code: ZodIssueCode.invalid_string,
1240
- validation: "date",
1241
- message: check.message
1242
- });
1243
- status.dirty();
1244
- }
1245
- } else if (check.kind === "time") {
1246
- const regex = timeRegex(check);
1247
- if (!regex.test(input.data)) {
1248
- ctx = this._getOrReturnCtx(input, ctx);
1249
- addIssueToContext(ctx, {
1250
- code: ZodIssueCode.invalid_string,
1251
- validation: "time",
1252
- message: check.message
1253
- });
1254
- status.dirty();
1255
- }
1256
- } else if (check.kind === "duration") {
1257
- if (!durationRegex.test(input.data)) {
1258
- ctx = this._getOrReturnCtx(input, ctx);
1259
- addIssueToContext(ctx, {
1260
- validation: "duration",
1261
- code: ZodIssueCode.invalid_string,
1262
- message: check.message
1263
- });
1264
- status.dirty();
1265
- }
1266
- } else if (check.kind === "ip") {
1267
- if (!isValidIP(input.data, check.version)) {
1268
- ctx = this._getOrReturnCtx(input, ctx);
1269
- addIssueToContext(ctx, {
1270
- validation: "ip",
1271
- code: ZodIssueCode.invalid_string,
1272
- message: check.message
1273
- });
1274
- status.dirty();
1275
- }
1276
- } else if (check.kind === "jwt") {
1277
- if (!isValidJWT(input.data, check.alg)) {
1278
- ctx = this._getOrReturnCtx(input, ctx);
1279
- addIssueToContext(ctx, {
1280
- validation: "jwt",
1281
- code: ZodIssueCode.invalid_string,
1282
- message: check.message
1283
- });
1284
- status.dirty();
1285
- }
1286
- } else if (check.kind === "cidr") {
1287
- if (!isValidCidr(input.data, check.version)) {
1288
- ctx = this._getOrReturnCtx(input, ctx);
1289
- addIssueToContext(ctx, {
1290
- validation: "cidr",
1291
- code: ZodIssueCode.invalid_string,
1292
- message: check.message
1293
- });
1294
- status.dirty();
1295
- }
1296
- } else if (check.kind === "base64") {
1297
- if (!base64Regex.test(input.data)) {
1298
- ctx = this._getOrReturnCtx(input, ctx);
1299
- addIssueToContext(ctx, {
1300
- validation: "base64",
1301
- code: ZodIssueCode.invalid_string,
1302
- message: check.message
1303
- });
1304
- status.dirty();
1305
- }
1306
- } else if (check.kind === "base64url") {
1307
- if (!base64urlRegex.test(input.data)) {
1308
- ctx = this._getOrReturnCtx(input, ctx);
1309
- addIssueToContext(ctx, {
1310
- validation: "base64url",
1311
- code: ZodIssueCode.invalid_string,
1312
- message: check.message
1313
- });
1314
- status.dirty();
1315
- }
1316
- } else {
1317
- util.assertNever(check);
1318
- }
1319
- }
1320
- return { status: status.value, value: input.data };
1321
- }
1322
- _regex(regex, validation, message) {
1323
- return this.refinement((data) => regex.test(data), {
1324
- validation,
1325
- code: ZodIssueCode.invalid_string,
1326
- ...errorUtil.errToObj(message)
1327
- });
1328
- }
1329
- _addCheck(check) {
1330
- return new _ZodString({
1331
- ...this._def,
1332
- checks: [...this._def.checks, check]
1333
- });
1334
- }
1335
- email(message) {
1336
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1337
- }
1338
- url(message) {
1339
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1340
- }
1341
- emoji(message) {
1342
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1343
- }
1344
- uuid(message) {
1345
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1346
- }
1347
- nanoid(message) {
1348
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1349
- }
1350
- cuid(message) {
1351
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1352
- }
1353
- cuid2(message) {
1354
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1355
- }
1356
- ulid(message) {
1357
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1358
- }
1359
- base64(message) {
1360
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1361
- }
1362
- base64url(message) {
1363
- return this._addCheck({
1364
- kind: "base64url",
1365
- ...errorUtil.errToObj(message)
1366
- });
1367
- }
1368
- jwt(options) {
1369
- return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1370
- }
1371
- ip(options) {
1372
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1373
- }
1374
- cidr(options) {
1375
- return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1376
- }
1377
- datetime(options) {
1378
- if (typeof options === "string") {
1379
- return this._addCheck({
1380
- kind: "datetime",
1381
- precision: null,
1382
- offset: false,
1383
- local: false,
1384
- message: options
1385
- });
1386
- }
1387
- return this._addCheck({
1388
- kind: "datetime",
1389
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1390
- offset: options?.offset ?? false,
1391
- local: options?.local ?? false,
1392
- ...errorUtil.errToObj(options?.message)
1393
- });
1394
- }
1395
- date(message) {
1396
- return this._addCheck({ kind: "date", message });
1397
- }
1398
- time(options) {
1399
- if (typeof options === "string") {
1400
- return this._addCheck({
1401
- kind: "time",
1402
- precision: null,
1403
- message: options
1404
- });
1405
- }
1406
- return this._addCheck({
1407
- kind: "time",
1408
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
1409
- ...errorUtil.errToObj(options?.message)
1410
- });
1411
- }
1412
- duration(message) {
1413
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1414
- }
1415
- regex(regex, message) {
1416
- return this._addCheck({
1417
- kind: "regex",
1418
- regex,
1419
- ...errorUtil.errToObj(message)
1420
- });
1421
- }
1422
- includes(value, options) {
1423
- return this._addCheck({
1424
- kind: "includes",
1425
- value,
1426
- position: options?.position,
1427
- ...errorUtil.errToObj(options?.message)
1428
- });
1429
- }
1430
- startsWith(value, message) {
1431
- return this._addCheck({
1432
- kind: "startsWith",
1433
- value,
1434
- ...errorUtil.errToObj(message)
1435
- });
1436
- }
1437
- endsWith(value, message) {
1438
- return this._addCheck({
1439
- kind: "endsWith",
1440
- value,
1441
- ...errorUtil.errToObj(message)
1442
- });
1443
- }
1444
- min(minLength, message) {
1445
- return this._addCheck({
1446
- kind: "min",
1447
- value: minLength,
1448
- ...errorUtil.errToObj(message)
1449
- });
1450
- }
1451
- max(maxLength, message) {
1452
- return this._addCheck({
1453
- kind: "max",
1454
- value: maxLength,
1455
- ...errorUtil.errToObj(message)
1456
- });
1457
- }
1458
- length(len, message) {
1459
- return this._addCheck({
1460
- kind: "length",
1461
- value: len,
1462
- ...errorUtil.errToObj(message)
1463
- });
1464
- }
1465
- /**
1466
- * Equivalent to `.min(1)`
1467
- */
1468
- nonempty(message) {
1469
- return this.min(1, errorUtil.errToObj(message));
1470
- }
1471
- trim() {
1472
- return new _ZodString({
1473
- ...this._def,
1474
- checks: [...this._def.checks, { kind: "trim" }]
1475
- });
1476
- }
1477
- toLowerCase() {
1478
- return new _ZodString({
1479
- ...this._def,
1480
- checks: [...this._def.checks, { kind: "toLowerCase" }]
1481
- });
1482
- }
1483
- toUpperCase() {
1484
- return new _ZodString({
1485
- ...this._def,
1486
- checks: [...this._def.checks, { kind: "toUpperCase" }]
1487
- });
1488
- }
1489
- get isDatetime() {
1490
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
1491
- }
1492
- get isDate() {
1493
- return !!this._def.checks.find((ch) => ch.kind === "date");
1494
- }
1495
- get isTime() {
1496
- return !!this._def.checks.find((ch) => ch.kind === "time");
1497
- }
1498
- get isDuration() {
1499
- return !!this._def.checks.find((ch) => ch.kind === "duration");
1500
- }
1501
- get isEmail() {
1502
- return !!this._def.checks.find((ch) => ch.kind === "email");
1503
- }
1504
- get isURL() {
1505
- return !!this._def.checks.find((ch) => ch.kind === "url");
1506
- }
1507
- get isEmoji() {
1508
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
1509
- }
1510
- get isUUID() {
1511
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
1512
- }
1513
- get isNANOID() {
1514
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1515
- }
1516
- get isCUID() {
1517
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
1518
- }
1519
- get isCUID2() {
1520
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1521
- }
1522
- get isULID() {
1523
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
1524
- }
1525
- get isIP() {
1526
- return !!this._def.checks.find((ch) => ch.kind === "ip");
1527
- }
1528
- get isCIDR() {
1529
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
1530
- }
1531
- get isBase64() {
1532
- return !!this._def.checks.find((ch) => ch.kind === "base64");
1533
- }
1534
- get isBase64url() {
1535
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
1536
- }
1537
- get minLength() {
1538
- let min = null;
1539
- for (const ch of this._def.checks) {
1540
- if (ch.kind === "min") {
1541
- if (min === null || ch.value > min)
1542
- min = ch.value;
1543
- }
1544
- }
1545
- return min;
1546
- }
1547
- get maxLength() {
1548
- let max = null;
1549
- for (const ch of this._def.checks) {
1550
- if (ch.kind === "max") {
1551
- if (max === null || ch.value < max)
1552
- max = ch.value;
1553
- }
1554
- }
1555
- return max;
1556
- }
1557
- };
1558
- ZodString.create = (params) => {
1559
- return new ZodString({
1560
- checks: [],
1561
- typeName: ZodFirstPartyTypeKind.ZodString,
1562
- coerce: params?.coerce ?? false,
1563
- ...processCreateParams(params)
1564
- });
1565
- };
1566
- function floatSafeRemainder(val, step) {
1567
- const valDecCount = (val.toString().split(".")[1] || "").length;
1568
- const stepDecCount = (step.toString().split(".")[1] || "").length;
1569
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1570
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1571
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1572
- return valInt % stepInt / 10 ** decCount;
1573
- }
1574
- var ZodNumber = class _ZodNumber extends ZodType {
1575
- constructor() {
1576
- super(...arguments);
1577
- this.min = this.gte;
1578
- this.max = this.lte;
1579
- this.step = this.multipleOf;
1580
- }
1581
- _parse(input) {
1582
- if (this._def.coerce) {
1583
- input.data = Number(input.data);
1584
- }
1585
- const parsedType = this._getType(input);
1586
- if (parsedType !== ZodParsedType.number) {
1587
- const ctx2 = this._getOrReturnCtx(input);
1588
- addIssueToContext(ctx2, {
1589
- code: ZodIssueCode.invalid_type,
1590
- expected: ZodParsedType.number,
1591
- received: ctx2.parsedType
1592
- });
1593
- return INVALID;
1594
- }
1595
- let ctx = void 0;
1596
- const status = new ParseStatus();
1597
- for (const check of this._def.checks) {
1598
- if (check.kind === "int") {
1599
- if (!util.isInteger(input.data)) {
1600
- ctx = this._getOrReturnCtx(input, ctx);
1601
- addIssueToContext(ctx, {
1602
- code: ZodIssueCode.invalid_type,
1603
- expected: "integer",
1604
- received: "float",
1605
- message: check.message
1606
- });
1607
- status.dirty();
1608
- }
1609
- } else if (check.kind === "min") {
1610
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1611
- if (tooSmall) {
1612
- ctx = this._getOrReturnCtx(input, ctx);
1613
- addIssueToContext(ctx, {
1614
- code: ZodIssueCode.too_small,
1615
- minimum: check.value,
1616
- type: "number",
1617
- inclusive: check.inclusive,
1618
- exact: false,
1619
- message: check.message
1620
- });
1621
- status.dirty();
1622
- }
1623
- } else if (check.kind === "max") {
1624
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1625
- if (tooBig) {
1626
- ctx = this._getOrReturnCtx(input, ctx);
1627
- addIssueToContext(ctx, {
1628
- code: ZodIssueCode.too_big,
1629
- maximum: check.value,
1630
- type: "number",
1631
- inclusive: check.inclusive,
1632
- exact: false,
1633
- message: check.message
1634
- });
1635
- status.dirty();
1636
- }
1637
- } else if (check.kind === "multipleOf") {
1638
- if (floatSafeRemainder(input.data, check.value) !== 0) {
1639
- ctx = this._getOrReturnCtx(input, ctx);
1640
- addIssueToContext(ctx, {
1641
- code: ZodIssueCode.not_multiple_of,
1642
- multipleOf: check.value,
1643
- message: check.message
1644
- });
1645
- status.dirty();
1646
- }
1647
- } else if (check.kind === "finite") {
1648
- if (!Number.isFinite(input.data)) {
1649
- ctx = this._getOrReturnCtx(input, ctx);
1650
- addIssueToContext(ctx, {
1651
- code: ZodIssueCode.not_finite,
1652
- message: check.message
1653
- });
1654
- status.dirty();
1655
- }
1656
- } else {
1657
- util.assertNever(check);
1658
- }
1659
- }
1660
- return { status: status.value, value: input.data };
1661
- }
1662
- gte(value, message) {
1663
- return this.setLimit("min", value, true, errorUtil.toString(message));
1664
- }
1665
- gt(value, message) {
1666
- return this.setLimit("min", value, false, errorUtil.toString(message));
1667
- }
1668
- lte(value, message) {
1669
- return this.setLimit("max", value, true, errorUtil.toString(message));
1670
- }
1671
- lt(value, message) {
1672
- return this.setLimit("max", value, false, errorUtil.toString(message));
1673
- }
1674
- setLimit(kind, value, inclusive, message) {
1675
- return new _ZodNumber({
1676
- ...this._def,
1677
- checks: [
1678
- ...this._def.checks,
1679
- {
1680
- kind,
1681
- value,
1682
- inclusive,
1683
- message: errorUtil.toString(message)
1684
- }
1685
- ]
1686
- });
1687
- }
1688
- _addCheck(check) {
1689
- return new _ZodNumber({
1690
- ...this._def,
1691
- checks: [...this._def.checks, check]
1692
- });
1693
- }
1694
- int(message) {
1695
- return this._addCheck({
1696
- kind: "int",
1697
- message: errorUtil.toString(message)
1698
- });
1699
- }
1700
- positive(message) {
1701
- return this._addCheck({
1702
- kind: "min",
1703
- value: 0,
1704
- inclusive: false,
1705
- message: errorUtil.toString(message)
1706
- });
1707
- }
1708
- negative(message) {
1709
- return this._addCheck({
1710
- kind: "max",
1711
- value: 0,
1712
- inclusive: false,
1713
- message: errorUtil.toString(message)
1714
- });
1715
- }
1716
- nonpositive(message) {
1717
- return this._addCheck({
1718
- kind: "max",
1719
- value: 0,
1720
- inclusive: true,
1721
- message: errorUtil.toString(message)
1722
- });
1723
- }
1724
- nonnegative(message) {
1725
- return this._addCheck({
1726
- kind: "min",
1727
- value: 0,
1728
- inclusive: true,
1729
- message: errorUtil.toString(message)
1730
- });
1731
- }
1732
- multipleOf(value, message) {
1733
- return this._addCheck({
1734
- kind: "multipleOf",
1735
- value,
1736
- message: errorUtil.toString(message)
1737
- });
1738
- }
1739
- finite(message) {
1740
- return this._addCheck({
1741
- kind: "finite",
1742
- message: errorUtil.toString(message)
1743
- });
1744
- }
1745
- safe(message) {
1746
- return this._addCheck({
1747
- kind: "min",
1748
- inclusive: true,
1749
- value: Number.MIN_SAFE_INTEGER,
1750
- message: errorUtil.toString(message)
1751
- })._addCheck({
1752
- kind: "max",
1753
- inclusive: true,
1754
- value: Number.MAX_SAFE_INTEGER,
1755
- message: errorUtil.toString(message)
1756
- });
1757
- }
1758
- get minValue() {
1759
- let min = null;
1760
- for (const ch of this._def.checks) {
1761
- if (ch.kind === "min") {
1762
- if (min === null || ch.value > min)
1763
- min = ch.value;
1764
- }
1765
- }
1766
- return min;
1767
- }
1768
- get maxValue() {
1769
- let max = null;
1770
- for (const ch of this._def.checks) {
1771
- if (ch.kind === "max") {
1772
- if (max === null || ch.value < max)
1773
- max = ch.value;
1774
- }
1775
- }
1776
- return max;
1777
- }
1778
- get isInt() {
1779
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1780
- }
1781
- get isFinite() {
1782
- let max = null;
1783
- let min = null;
1784
- for (const ch of this._def.checks) {
1785
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1786
- return true;
1787
- } else if (ch.kind === "min") {
1788
- if (min === null || ch.value > min)
1789
- min = ch.value;
1790
- } else if (ch.kind === "max") {
1791
- if (max === null || ch.value < max)
1792
- max = ch.value;
1793
- }
1794
- }
1795
- return Number.isFinite(min) && Number.isFinite(max);
1796
- }
1797
- };
1798
- ZodNumber.create = (params) => {
1799
- return new ZodNumber({
1800
- checks: [],
1801
- typeName: ZodFirstPartyTypeKind.ZodNumber,
1802
- coerce: params?.coerce || false,
1803
- ...processCreateParams(params)
1804
- });
1805
- };
1806
- var ZodBigInt = class _ZodBigInt extends ZodType {
1807
- constructor() {
1808
- super(...arguments);
1809
- this.min = this.gte;
1810
- this.max = this.lte;
1811
- }
1812
- _parse(input) {
1813
- if (this._def.coerce) {
1814
- try {
1815
- input.data = BigInt(input.data);
1816
- } catch {
1817
- return this._getInvalidInput(input);
1818
- }
1819
- }
1820
- const parsedType = this._getType(input);
1821
- if (parsedType !== ZodParsedType.bigint) {
1822
- return this._getInvalidInput(input);
1823
- }
1824
- let ctx = void 0;
1825
- const status = new ParseStatus();
1826
- for (const check of this._def.checks) {
1827
- if (check.kind === "min") {
1828
- const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1829
- if (tooSmall) {
1830
- ctx = this._getOrReturnCtx(input, ctx);
1831
- addIssueToContext(ctx, {
1832
- code: ZodIssueCode.too_small,
1833
- type: "bigint",
1834
- minimum: check.value,
1835
- inclusive: check.inclusive,
1836
- message: check.message
1837
- });
1838
- status.dirty();
1839
- }
1840
- } else if (check.kind === "max") {
1841
- const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1842
- if (tooBig) {
1843
- ctx = this._getOrReturnCtx(input, ctx);
1844
- addIssueToContext(ctx, {
1845
- code: ZodIssueCode.too_big,
1846
- type: "bigint",
1847
- maximum: check.value,
1848
- inclusive: check.inclusive,
1849
- message: check.message
1850
- });
1851
- status.dirty();
1852
- }
1853
- } else if (check.kind === "multipleOf") {
1854
- if (input.data % check.value !== BigInt(0)) {
1855
- ctx = this._getOrReturnCtx(input, ctx);
1856
- addIssueToContext(ctx, {
1857
- code: ZodIssueCode.not_multiple_of,
1858
- multipleOf: check.value,
1859
- message: check.message
1860
- });
1861
- status.dirty();
1862
- }
1863
- } else {
1864
- util.assertNever(check);
1865
- }
1866
- }
1867
- return { status: status.value, value: input.data };
1868
- }
1869
- _getInvalidInput(input) {
1870
- const ctx = this._getOrReturnCtx(input);
1871
- addIssueToContext(ctx, {
1872
- code: ZodIssueCode.invalid_type,
1873
- expected: ZodParsedType.bigint,
1874
- received: ctx.parsedType
1875
- });
1876
- return INVALID;
1877
- }
1878
- gte(value, message) {
1879
- return this.setLimit("min", value, true, errorUtil.toString(message));
1880
- }
1881
- gt(value, message) {
1882
- return this.setLimit("min", value, false, errorUtil.toString(message));
1883
- }
1884
- lte(value, message) {
1885
- return this.setLimit("max", value, true, errorUtil.toString(message));
1886
- }
1887
- lt(value, message) {
1888
- return this.setLimit("max", value, false, errorUtil.toString(message));
1889
- }
1890
- setLimit(kind, value, inclusive, message) {
1891
- return new _ZodBigInt({
1892
- ...this._def,
1893
- checks: [
1894
- ...this._def.checks,
1895
- {
1896
- kind,
1897
- value,
1898
- inclusive,
1899
- message: errorUtil.toString(message)
1900
- }
1901
- ]
1902
- });
1903
- }
1904
- _addCheck(check) {
1905
- return new _ZodBigInt({
1906
- ...this._def,
1907
- checks: [...this._def.checks, check]
1908
- });
1909
- }
1910
- positive(message) {
1911
- return this._addCheck({
1912
- kind: "min",
1913
- value: BigInt(0),
1914
- inclusive: false,
1915
- message: errorUtil.toString(message)
1916
- });
1917
- }
1918
- negative(message) {
1919
- return this._addCheck({
1920
- kind: "max",
1921
- value: BigInt(0),
1922
- inclusive: false,
1923
- message: errorUtil.toString(message)
1924
- });
1925
- }
1926
- nonpositive(message) {
1927
- return this._addCheck({
1928
- kind: "max",
1929
- value: BigInt(0),
1930
- inclusive: true,
1931
- message: errorUtil.toString(message)
1932
- });
1933
- }
1934
- nonnegative(message) {
1935
- return this._addCheck({
1936
- kind: "min",
1937
- value: BigInt(0),
1938
- inclusive: true,
1939
- message: errorUtil.toString(message)
1940
- });
1941
- }
1942
- multipleOf(value, message) {
1943
- return this._addCheck({
1944
- kind: "multipleOf",
1945
- value,
1946
- message: errorUtil.toString(message)
1947
- });
1948
- }
1949
- get minValue() {
1950
- let min = null;
1951
- for (const ch of this._def.checks) {
1952
- if (ch.kind === "min") {
1953
- if (min === null || ch.value > min)
1954
- min = ch.value;
1955
- }
1956
- }
1957
- return min;
1958
- }
1959
- get maxValue() {
1960
- let max = null;
1961
- for (const ch of this._def.checks) {
1962
- if (ch.kind === "max") {
1963
- if (max === null || ch.value < max)
1964
- max = ch.value;
1965
- }
1966
- }
1967
- return max;
1968
- }
1969
- };
1970
- ZodBigInt.create = (params) => {
1971
- return new ZodBigInt({
1972
- checks: [],
1973
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
1974
- coerce: params?.coerce ?? false,
1975
- ...processCreateParams(params)
1976
- });
1977
- };
1978
- var ZodBoolean = class extends ZodType {
1979
- _parse(input) {
1980
- if (this._def.coerce) {
1981
- input.data = Boolean(input.data);
1982
- }
1983
- const parsedType = this._getType(input);
1984
- if (parsedType !== ZodParsedType.boolean) {
1985
- const ctx = this._getOrReturnCtx(input);
1986
- addIssueToContext(ctx, {
1987
- code: ZodIssueCode.invalid_type,
1988
- expected: ZodParsedType.boolean,
1989
- received: ctx.parsedType
1990
- });
1991
- return INVALID;
1992
- }
1993
- return OK(input.data);
1994
- }
1995
- };
1996
- ZodBoolean.create = (params) => {
1997
- return new ZodBoolean({
1998
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
1999
- coerce: params?.coerce || false,
2000
- ...processCreateParams(params)
2001
- });
2002
- };
2003
- var ZodDate = class _ZodDate extends ZodType {
2004
- _parse(input) {
2005
- if (this._def.coerce) {
2006
- input.data = new Date(input.data);
2007
- }
2008
- const parsedType = this._getType(input);
2009
- if (parsedType !== ZodParsedType.date) {
2010
- const ctx2 = this._getOrReturnCtx(input);
2011
- addIssueToContext(ctx2, {
2012
- code: ZodIssueCode.invalid_type,
2013
- expected: ZodParsedType.date,
2014
- received: ctx2.parsedType
2015
- });
2016
- return INVALID;
2017
- }
2018
- if (Number.isNaN(input.data.getTime())) {
2019
- const ctx2 = this._getOrReturnCtx(input);
2020
- addIssueToContext(ctx2, {
2021
- code: ZodIssueCode.invalid_date
2022
- });
2023
- return INVALID;
2024
- }
2025
- const status = new ParseStatus();
2026
- let ctx = void 0;
2027
- for (const check of this._def.checks) {
2028
- if (check.kind === "min") {
2029
- if (input.data.getTime() < check.value) {
2030
- ctx = this._getOrReturnCtx(input, ctx);
2031
- addIssueToContext(ctx, {
2032
- code: ZodIssueCode.too_small,
2033
- message: check.message,
2034
- inclusive: true,
2035
- exact: false,
2036
- minimum: check.value,
2037
- type: "date"
2038
- });
2039
- status.dirty();
2040
- }
2041
- } else if (check.kind === "max") {
2042
- if (input.data.getTime() > check.value) {
2043
- ctx = this._getOrReturnCtx(input, ctx);
2044
- addIssueToContext(ctx, {
2045
- code: ZodIssueCode.too_big,
2046
- message: check.message,
2047
- inclusive: true,
2048
- exact: false,
2049
- maximum: check.value,
2050
- type: "date"
2051
- });
2052
- status.dirty();
2053
- }
2054
- } else {
2055
- util.assertNever(check);
2056
- }
2057
- }
2058
- return {
2059
- status: status.value,
2060
- value: new Date(input.data.getTime())
2061
- };
2062
- }
2063
- _addCheck(check) {
2064
- return new _ZodDate({
2065
- ...this._def,
2066
- checks: [...this._def.checks, check]
2067
- });
2068
- }
2069
- min(minDate, message) {
2070
- return this._addCheck({
2071
- kind: "min",
2072
- value: minDate.getTime(),
2073
- message: errorUtil.toString(message)
2074
- });
2075
- }
2076
- max(maxDate, message) {
2077
- return this._addCheck({
2078
- kind: "max",
2079
- value: maxDate.getTime(),
2080
- message: errorUtil.toString(message)
2081
- });
2082
- }
2083
- get minDate() {
2084
- let min = null;
2085
- for (const ch of this._def.checks) {
2086
- if (ch.kind === "min") {
2087
- if (min === null || ch.value > min)
2088
- min = ch.value;
2089
- }
2090
- }
2091
- return min != null ? new Date(min) : null;
2092
- }
2093
- get maxDate() {
2094
- let max = null;
2095
- for (const ch of this._def.checks) {
2096
- if (ch.kind === "max") {
2097
- if (max === null || ch.value < max)
2098
- max = ch.value;
2099
- }
2100
- }
2101
- return max != null ? new Date(max) : null;
2102
- }
2103
- };
2104
- ZodDate.create = (params) => {
2105
- return new ZodDate({
2106
- checks: [],
2107
- coerce: params?.coerce || false,
2108
- typeName: ZodFirstPartyTypeKind.ZodDate,
2109
- ...processCreateParams(params)
2110
- });
2111
- };
2112
- var ZodSymbol = class extends ZodType {
2113
- _parse(input) {
2114
- const parsedType = this._getType(input);
2115
- if (parsedType !== ZodParsedType.symbol) {
2116
- const ctx = this._getOrReturnCtx(input);
2117
- addIssueToContext(ctx, {
2118
- code: ZodIssueCode.invalid_type,
2119
- expected: ZodParsedType.symbol,
2120
- received: ctx.parsedType
2121
- });
2122
- return INVALID;
2123
- }
2124
- return OK(input.data);
2125
- }
2126
- };
2127
- ZodSymbol.create = (params) => {
2128
- return new ZodSymbol({
2129
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
2130
- ...processCreateParams(params)
2131
- });
2132
- };
2133
- var ZodUndefined = class extends ZodType {
2134
- _parse(input) {
2135
- const parsedType = this._getType(input);
2136
- if (parsedType !== ZodParsedType.undefined) {
2137
- const ctx = this._getOrReturnCtx(input);
2138
- addIssueToContext(ctx, {
2139
- code: ZodIssueCode.invalid_type,
2140
- expected: ZodParsedType.undefined,
2141
- received: ctx.parsedType
2142
- });
2143
- return INVALID;
2144
- }
2145
- return OK(input.data);
2146
- }
2147
- };
2148
- ZodUndefined.create = (params) => {
2149
- return new ZodUndefined({
2150
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
2151
- ...processCreateParams(params)
2152
- });
2153
- };
2154
- var ZodNull = class extends ZodType {
2155
- _parse(input) {
2156
- const parsedType = this._getType(input);
2157
- if (parsedType !== ZodParsedType.null) {
2158
- const ctx = this._getOrReturnCtx(input);
2159
- addIssueToContext(ctx, {
2160
- code: ZodIssueCode.invalid_type,
2161
- expected: ZodParsedType.null,
2162
- received: ctx.parsedType
2163
- });
2164
- return INVALID;
2165
- }
2166
- return OK(input.data);
2167
- }
2168
- };
2169
- ZodNull.create = (params) => {
2170
- return new ZodNull({
2171
- typeName: ZodFirstPartyTypeKind.ZodNull,
2172
- ...processCreateParams(params)
2173
- });
2174
- };
2175
- var ZodAny = class extends ZodType {
2176
- constructor() {
2177
- super(...arguments);
2178
- this._any = true;
2179
- }
2180
- _parse(input) {
2181
- return OK(input.data);
2182
- }
2183
- };
2184
- ZodAny.create = (params) => {
2185
- return new ZodAny({
2186
- typeName: ZodFirstPartyTypeKind.ZodAny,
2187
- ...processCreateParams(params)
2188
- });
2189
- };
2190
- var ZodUnknown = class extends ZodType {
2191
- constructor() {
2192
- super(...arguments);
2193
- this._unknown = true;
2194
- }
2195
- _parse(input) {
2196
- return OK(input.data);
2197
- }
2198
- };
2199
- ZodUnknown.create = (params) => {
2200
- return new ZodUnknown({
2201
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
2202
- ...processCreateParams(params)
2203
- });
2204
- };
2205
- var ZodNever = class extends ZodType {
2206
- _parse(input) {
2207
- const ctx = this._getOrReturnCtx(input);
2208
- addIssueToContext(ctx, {
2209
- code: ZodIssueCode.invalid_type,
2210
- expected: ZodParsedType.never,
2211
- received: ctx.parsedType
2212
- });
2213
- return INVALID;
2214
- }
2215
- };
2216
- ZodNever.create = (params) => {
2217
- return new ZodNever({
2218
- typeName: ZodFirstPartyTypeKind.ZodNever,
2219
- ...processCreateParams(params)
2220
- });
2221
- };
2222
- var ZodVoid = class extends ZodType {
2223
- _parse(input) {
2224
- const parsedType = this._getType(input);
2225
- if (parsedType !== ZodParsedType.undefined) {
2226
- const ctx = this._getOrReturnCtx(input);
2227
- addIssueToContext(ctx, {
2228
- code: ZodIssueCode.invalid_type,
2229
- expected: ZodParsedType.void,
2230
- received: ctx.parsedType
2231
- });
2232
- return INVALID;
2233
- }
2234
- return OK(input.data);
2235
- }
2236
- };
2237
- ZodVoid.create = (params) => {
2238
- return new ZodVoid({
2239
- typeName: ZodFirstPartyTypeKind.ZodVoid,
2240
- ...processCreateParams(params)
2241
- });
2242
- };
2243
- var ZodArray = class _ZodArray extends ZodType {
2244
- _parse(input) {
2245
- const { ctx, status } = this._processInputParams(input);
2246
- const def = this._def;
2247
- if (ctx.parsedType !== ZodParsedType.array) {
2248
- addIssueToContext(ctx, {
2249
- code: ZodIssueCode.invalid_type,
2250
- expected: ZodParsedType.array,
2251
- received: ctx.parsedType
2252
- });
2253
- return INVALID;
2254
- }
2255
- if (def.exactLength !== null) {
2256
- const tooBig = ctx.data.length > def.exactLength.value;
2257
- const tooSmall = ctx.data.length < def.exactLength.value;
2258
- if (tooBig || tooSmall) {
2259
- addIssueToContext(ctx, {
2260
- code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2261
- minimum: tooSmall ? def.exactLength.value : void 0,
2262
- maximum: tooBig ? def.exactLength.value : void 0,
2263
- type: "array",
2264
- inclusive: true,
2265
- exact: true,
2266
- message: def.exactLength.message
2267
- });
2268
- status.dirty();
2269
- }
2270
- }
2271
- if (def.minLength !== null) {
2272
- if (ctx.data.length < def.minLength.value) {
2273
- addIssueToContext(ctx, {
2274
- code: ZodIssueCode.too_small,
2275
- minimum: def.minLength.value,
2276
- type: "array",
2277
- inclusive: true,
2278
- exact: false,
2279
- message: def.minLength.message
2280
- });
2281
- status.dirty();
2282
- }
2283
- }
2284
- if (def.maxLength !== null) {
2285
- if (ctx.data.length > def.maxLength.value) {
2286
- addIssueToContext(ctx, {
2287
- code: ZodIssueCode.too_big,
2288
- maximum: def.maxLength.value,
2289
- type: "array",
2290
- inclusive: true,
2291
- exact: false,
2292
- message: def.maxLength.message
2293
- });
2294
- status.dirty();
2295
- }
2296
- }
2297
- if (ctx.common.async) {
2298
- return Promise.all([...ctx.data].map((item, i) => {
2299
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2300
- })).then((result2) => {
2301
- return ParseStatus.mergeArray(status, result2);
2302
- });
2303
- }
2304
- const result = [...ctx.data].map((item, i) => {
2305
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2306
- });
2307
- return ParseStatus.mergeArray(status, result);
2308
- }
2309
- get element() {
2310
- return this._def.type;
2311
- }
2312
- min(minLength, message) {
2313
- return new _ZodArray({
2314
- ...this._def,
2315
- minLength: { value: minLength, message: errorUtil.toString(message) }
2316
- });
2317
- }
2318
- max(maxLength, message) {
2319
- return new _ZodArray({
2320
- ...this._def,
2321
- maxLength: { value: maxLength, message: errorUtil.toString(message) }
2322
- });
2323
- }
2324
- length(len, message) {
2325
- return new _ZodArray({
2326
- ...this._def,
2327
- exactLength: { value: len, message: errorUtil.toString(message) }
2328
- });
2329
- }
2330
- nonempty(message) {
2331
- return this.min(1, message);
2332
- }
2333
- };
2334
- ZodArray.create = (schema, params) => {
2335
- return new ZodArray({
2336
- type: schema,
2337
- minLength: null,
2338
- maxLength: null,
2339
- exactLength: null,
2340
- typeName: ZodFirstPartyTypeKind.ZodArray,
2341
- ...processCreateParams(params)
2342
- });
2343
- };
2344
- function deepPartialify(schema) {
2345
- if (schema instanceof ZodObject) {
2346
- const newShape = {};
2347
- for (const key in schema.shape) {
2348
- const fieldSchema = schema.shape[key];
2349
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2350
- }
2351
- return new ZodObject({
2352
- ...schema._def,
2353
- shape: () => newShape
2354
- });
2355
- } else if (schema instanceof ZodArray) {
2356
- return new ZodArray({
2357
- ...schema._def,
2358
- type: deepPartialify(schema.element)
2359
- });
2360
- } else if (schema instanceof ZodOptional) {
2361
- return ZodOptional.create(deepPartialify(schema.unwrap()));
2362
- } else if (schema instanceof ZodNullable) {
2363
- return ZodNullable.create(deepPartialify(schema.unwrap()));
2364
- } else if (schema instanceof ZodTuple) {
2365
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2366
- } else {
2367
- return schema;
2368
- }
2369
- }
2370
- var ZodObject = class _ZodObject extends ZodType {
2371
- constructor() {
2372
- super(...arguments);
2373
- this._cached = null;
2374
- this.nonstrict = this.passthrough;
2375
- this.augment = this.extend;
2376
- }
2377
- _getCached() {
2378
- if (this._cached !== null)
2379
- return this._cached;
2380
- const shape = this._def.shape();
2381
- const keys = util.objectKeys(shape);
2382
- this._cached = { shape, keys };
2383
- return this._cached;
2384
- }
2385
- _parse(input) {
2386
- const parsedType = this._getType(input);
2387
- if (parsedType !== ZodParsedType.object) {
2388
- const ctx2 = this._getOrReturnCtx(input);
2389
- addIssueToContext(ctx2, {
2390
- code: ZodIssueCode.invalid_type,
2391
- expected: ZodParsedType.object,
2392
- received: ctx2.parsedType
2393
- });
2394
- return INVALID;
2395
- }
2396
- const { status, ctx } = this._processInputParams(input);
2397
- const { shape, keys: shapeKeys } = this._getCached();
2398
- const extraKeys = [];
2399
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2400
- for (const key in ctx.data) {
2401
- if (!shapeKeys.includes(key)) {
2402
- extraKeys.push(key);
2403
- }
2404
- }
2405
- }
2406
- const pairs = [];
2407
- for (const key of shapeKeys) {
2408
- const keyValidator = shape[key];
2409
- const value = ctx.data[key];
2410
- pairs.push({
2411
- key: { status: "valid", value: key },
2412
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2413
- alwaysSet: key in ctx.data
2414
- });
2415
- }
2416
- if (this._def.catchall instanceof ZodNever) {
2417
- const unknownKeys = this._def.unknownKeys;
2418
- if (unknownKeys === "passthrough") {
2419
- for (const key of extraKeys) {
2420
- pairs.push({
2421
- key: { status: "valid", value: key },
2422
- value: { status: "valid", value: ctx.data[key] }
2423
- });
2424
- }
2425
- } else if (unknownKeys === "strict") {
2426
- if (extraKeys.length > 0) {
2427
- addIssueToContext(ctx, {
2428
- code: ZodIssueCode.unrecognized_keys,
2429
- keys: extraKeys
2430
- });
2431
- status.dirty();
2432
- }
2433
- } else if (unknownKeys === "strip") {
2434
- } else {
2435
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2436
- }
2437
- } else {
2438
- const catchall = this._def.catchall;
2439
- for (const key of extraKeys) {
2440
- const value = ctx.data[key];
2441
- pairs.push({
2442
- key: { status: "valid", value: key },
2443
- value: catchall._parse(
2444
- new ParseInputLazyPath(ctx, value, ctx.path, key)
2445
- //, ctx.child(key), value, getParsedType(value)
2446
- ),
2447
- alwaysSet: key in ctx.data
2448
- });
2449
- }
2450
- }
2451
- if (ctx.common.async) {
2452
- return Promise.resolve().then(async () => {
2453
- const syncPairs = [];
2454
- for (const pair of pairs) {
2455
- const key = await pair.key;
2456
- const value = await pair.value;
2457
- syncPairs.push({
2458
- key,
2459
- value,
2460
- alwaysSet: pair.alwaysSet
2461
- });
2462
- }
2463
- return syncPairs;
2464
- }).then((syncPairs) => {
2465
- return ParseStatus.mergeObjectSync(status, syncPairs);
2466
- });
2467
- } else {
2468
- return ParseStatus.mergeObjectSync(status, pairs);
2469
- }
2470
- }
2471
- get shape() {
2472
- return this._def.shape();
2473
- }
2474
- strict(message) {
2475
- errorUtil.errToObj;
2476
- return new _ZodObject({
2477
- ...this._def,
2478
- unknownKeys: "strict",
2479
- ...message !== void 0 ? {
2480
- errorMap: (issue, ctx) => {
2481
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2482
- if (issue.code === "unrecognized_keys")
2483
- return {
2484
- message: errorUtil.errToObj(message).message ?? defaultError
2485
- };
2486
- return {
2487
- message: defaultError
2488
- };
2489
- }
2490
- } : {}
2491
- });
2492
- }
2493
- strip() {
2494
- return new _ZodObject({
2495
- ...this._def,
2496
- unknownKeys: "strip"
2497
- });
2498
- }
2499
- passthrough() {
2500
- return new _ZodObject({
2501
- ...this._def,
2502
- unknownKeys: "passthrough"
2503
- });
2504
- }
2505
- // const AugmentFactory =
2506
- // <Def extends ZodObjectDef>(def: Def) =>
2507
- // <Augmentation extends ZodRawShape>(
2508
- // augmentation: Augmentation
2509
- // ): ZodObject<
2510
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2511
- // Def["unknownKeys"],
2512
- // Def["catchall"]
2513
- // > => {
2514
- // return new ZodObject({
2515
- // ...def,
2516
- // shape: () => ({
2517
- // ...def.shape(),
2518
- // ...augmentation,
2519
- // }),
2520
- // }) as any;
2521
- // };
2522
- extend(augmentation) {
2523
- return new _ZodObject({
2524
- ...this._def,
2525
- shape: () => ({
2526
- ...this._def.shape(),
2527
- ...augmentation
2528
- })
2529
- });
2530
- }
2531
- /**
2532
- * Prior to zod@1.0.12 there was a bug in the
2533
- * inferred type of merged objects. Please
2534
- * upgrade if you are experiencing issues.
2535
- */
2536
- merge(merging) {
2537
- const merged = new _ZodObject({
2538
- unknownKeys: merging._def.unknownKeys,
2539
- catchall: merging._def.catchall,
2540
- shape: () => ({
2541
- ...this._def.shape(),
2542
- ...merging._def.shape()
2543
- }),
2544
- typeName: ZodFirstPartyTypeKind.ZodObject
2545
- });
2546
- return merged;
2547
- }
2548
- // merge<
2549
- // Incoming extends AnyZodObject,
2550
- // Augmentation extends Incoming["shape"],
2551
- // NewOutput extends {
2552
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2553
- // ? Augmentation[k]["_output"]
2554
- // : k extends keyof Output
2555
- // ? Output[k]
2556
- // : never;
2557
- // },
2558
- // NewInput extends {
2559
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2560
- // ? Augmentation[k]["_input"]
2561
- // : k extends keyof Input
2562
- // ? Input[k]
2563
- // : never;
2564
- // }
2565
- // >(
2566
- // merging: Incoming
2567
- // ): ZodObject<
2568
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2569
- // Incoming["_def"]["unknownKeys"],
2570
- // Incoming["_def"]["catchall"],
2571
- // NewOutput,
2572
- // NewInput
2573
- // > {
2574
- // const merged: any = new ZodObject({
2575
- // unknownKeys: merging._def.unknownKeys,
2576
- // catchall: merging._def.catchall,
2577
- // shape: () =>
2578
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2579
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2580
- // }) as any;
2581
- // return merged;
2582
- // }
2583
- setKey(key, schema) {
2584
- return this.augment({ [key]: schema });
2585
- }
2586
- // merge<Incoming extends AnyZodObject>(
2587
- // merging: Incoming
2588
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2589
- // ZodObject<
2590
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2591
- // Incoming["_def"]["unknownKeys"],
2592
- // Incoming["_def"]["catchall"]
2593
- // > {
2594
- // // const mergedShape = objectUtil.mergeShapes(
2595
- // // this._def.shape(),
2596
- // // merging._def.shape()
2597
- // // );
2598
- // const merged: any = new ZodObject({
2599
- // unknownKeys: merging._def.unknownKeys,
2600
- // catchall: merging._def.catchall,
2601
- // shape: () =>
2602
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2603
- // typeName: ZodFirstPartyTypeKind.ZodObject,
2604
- // }) as any;
2605
- // return merged;
2606
- // }
2607
- catchall(index) {
2608
- return new _ZodObject({
2609
- ...this._def,
2610
- catchall: index
2611
- });
2612
- }
2613
- pick(mask) {
2614
- const shape = {};
2615
- for (const key of util.objectKeys(mask)) {
2616
- if (mask[key] && this.shape[key]) {
2617
- shape[key] = this.shape[key];
2618
- }
2619
- }
2620
- return new _ZodObject({
2621
- ...this._def,
2622
- shape: () => shape
2623
- });
2624
- }
2625
- omit(mask) {
2626
- const shape = {};
2627
- for (const key of util.objectKeys(this.shape)) {
2628
- if (!mask[key]) {
2629
- shape[key] = this.shape[key];
2630
- }
2631
- }
2632
- return new _ZodObject({
2633
- ...this._def,
2634
- shape: () => shape
2635
- });
2636
- }
2637
- /**
2638
- * @deprecated
2639
- */
2640
- deepPartial() {
2641
- return deepPartialify(this);
2642
- }
2643
- partial(mask) {
2644
- const newShape = {};
2645
- for (const key of util.objectKeys(this.shape)) {
2646
- const fieldSchema = this.shape[key];
2647
- if (mask && !mask[key]) {
2648
- newShape[key] = fieldSchema;
2649
- } else {
2650
- newShape[key] = fieldSchema.optional();
2651
- }
2652
- }
2653
- return new _ZodObject({
2654
- ...this._def,
2655
- shape: () => newShape
2656
- });
2657
- }
2658
- required(mask) {
2659
- const newShape = {};
2660
- for (const key of util.objectKeys(this.shape)) {
2661
- if (mask && !mask[key]) {
2662
- newShape[key] = this.shape[key];
2663
- } else {
2664
- const fieldSchema = this.shape[key];
2665
- let newField = fieldSchema;
2666
- while (newField instanceof ZodOptional) {
2667
- newField = newField._def.innerType;
2668
- }
2669
- newShape[key] = newField;
2670
- }
2671
- }
2672
- return new _ZodObject({
2673
- ...this._def,
2674
- shape: () => newShape
2675
- });
2676
- }
2677
- keyof() {
2678
- return createZodEnum(util.objectKeys(this.shape));
2679
- }
2680
- };
2681
- ZodObject.create = (shape, params) => {
2682
- return new ZodObject({
2683
- shape: () => shape,
2684
- unknownKeys: "strip",
2685
- catchall: ZodNever.create(),
2686
- typeName: ZodFirstPartyTypeKind.ZodObject,
2687
- ...processCreateParams(params)
2688
- });
2689
- };
2690
- ZodObject.strictCreate = (shape, params) => {
2691
- return new ZodObject({
2692
- shape: () => shape,
2693
- unknownKeys: "strict",
2694
- catchall: ZodNever.create(),
2695
- typeName: ZodFirstPartyTypeKind.ZodObject,
2696
- ...processCreateParams(params)
2697
- });
2698
- };
2699
- ZodObject.lazycreate = (shape, params) => {
2700
- return new ZodObject({
2701
- shape,
2702
- unknownKeys: "strip",
2703
- catchall: ZodNever.create(),
2704
- typeName: ZodFirstPartyTypeKind.ZodObject,
2705
- ...processCreateParams(params)
2706
- });
2707
- };
2708
- var ZodUnion = class extends ZodType {
2709
- _parse(input) {
2710
- const { ctx } = this._processInputParams(input);
2711
- const options = this._def.options;
2712
- function handleResults(results) {
2713
- for (const result of results) {
2714
- if (result.result.status === "valid") {
2715
- return result.result;
2716
- }
2717
- }
2718
- for (const result of results) {
2719
- if (result.result.status === "dirty") {
2720
- ctx.common.issues.push(...result.ctx.common.issues);
2721
- return result.result;
2722
- }
2723
- }
2724
- const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2725
- addIssueToContext(ctx, {
2726
- code: ZodIssueCode.invalid_union,
2727
- unionErrors
2728
- });
2729
- return INVALID;
2730
- }
2731
- if (ctx.common.async) {
2732
- return Promise.all(options.map(async (option) => {
2733
- const childCtx = {
2734
- ...ctx,
2735
- common: {
2736
- ...ctx.common,
2737
- issues: []
2738
- },
2739
- parent: null
2740
- };
2741
- return {
2742
- result: await option._parseAsync({
2743
- data: ctx.data,
2744
- path: ctx.path,
2745
- parent: childCtx
2746
- }),
2747
- ctx: childCtx
2748
- };
2749
- })).then(handleResults);
2750
- } else {
2751
- let dirty = void 0;
2752
- const issues = [];
2753
- for (const option of options) {
2754
- const childCtx = {
2755
- ...ctx,
2756
- common: {
2757
- ...ctx.common,
2758
- issues: []
2759
- },
2760
- parent: null
2761
- };
2762
- const result = option._parseSync({
2763
- data: ctx.data,
2764
- path: ctx.path,
2765
- parent: childCtx
2766
- });
2767
- if (result.status === "valid") {
2768
- return result;
2769
- } else if (result.status === "dirty" && !dirty) {
2770
- dirty = { result, ctx: childCtx };
2771
- }
2772
- if (childCtx.common.issues.length) {
2773
- issues.push(childCtx.common.issues);
2774
- }
2775
- }
2776
- if (dirty) {
2777
- ctx.common.issues.push(...dirty.ctx.common.issues);
2778
- return dirty.result;
2779
- }
2780
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
2781
- addIssueToContext(ctx, {
2782
- code: ZodIssueCode.invalid_union,
2783
- unionErrors
2784
- });
2785
- return INVALID;
2786
- }
2787
- }
2788
- get options() {
2789
- return this._def.options;
2790
- }
2791
- };
2792
- ZodUnion.create = (types, params) => {
2793
- return new ZodUnion({
2794
- options: types,
2795
- typeName: ZodFirstPartyTypeKind.ZodUnion,
2796
- ...processCreateParams(params)
2797
- });
2798
- };
2799
- var getDiscriminator = (type) => {
2800
- if (type instanceof ZodLazy) {
2801
- return getDiscriminator(type.schema);
2802
- } else if (type instanceof ZodEffects) {
2803
- return getDiscriminator(type.innerType());
2804
- } else if (type instanceof ZodLiteral) {
2805
- return [type.value];
2806
- } else if (type instanceof ZodEnum) {
2807
- return type.options;
2808
- } else if (type instanceof ZodNativeEnum) {
2809
- return util.objectValues(type.enum);
2810
- } else if (type instanceof ZodDefault) {
2811
- return getDiscriminator(type._def.innerType);
2812
- } else if (type instanceof ZodUndefined) {
2813
- return [void 0];
2814
- } else if (type instanceof ZodNull) {
2815
- return [null];
2816
- } else if (type instanceof ZodOptional) {
2817
- return [void 0, ...getDiscriminator(type.unwrap())];
2818
- } else if (type instanceof ZodNullable) {
2819
- return [null, ...getDiscriminator(type.unwrap())];
2820
- } else if (type instanceof ZodBranded) {
2821
- return getDiscriminator(type.unwrap());
2822
- } else if (type instanceof ZodReadonly) {
2823
- return getDiscriminator(type.unwrap());
2824
- } else if (type instanceof ZodCatch) {
2825
- return getDiscriminator(type._def.innerType);
2826
- } else {
2827
- return [];
2828
- }
2829
- };
2830
- var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2831
- _parse(input) {
2832
- const { ctx } = this._processInputParams(input);
2833
- if (ctx.parsedType !== ZodParsedType.object) {
2834
- addIssueToContext(ctx, {
2835
- code: ZodIssueCode.invalid_type,
2836
- expected: ZodParsedType.object,
2837
- received: ctx.parsedType
2838
- });
2839
- return INVALID;
2840
- }
2841
- const discriminator = this.discriminator;
2842
- const discriminatorValue = ctx.data[discriminator];
2843
- const option = this.optionsMap.get(discriminatorValue);
2844
- if (!option) {
2845
- addIssueToContext(ctx, {
2846
- code: ZodIssueCode.invalid_union_discriminator,
2847
- options: Array.from(this.optionsMap.keys()),
2848
- path: [discriminator]
2849
- });
2850
- return INVALID;
2851
- }
2852
- if (ctx.common.async) {
2853
- return option._parseAsync({
2854
- data: ctx.data,
2855
- path: ctx.path,
2856
- parent: ctx
2857
- });
2858
- } else {
2859
- return option._parseSync({
2860
- data: ctx.data,
2861
- path: ctx.path,
2862
- parent: ctx
2863
- });
2864
- }
2865
- }
2866
- get discriminator() {
2867
- return this._def.discriminator;
2868
- }
2869
- get options() {
2870
- return this._def.options;
2871
- }
2872
- get optionsMap() {
2873
- return this._def.optionsMap;
2874
- }
2875
- /**
2876
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2877
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2878
- * have a different value for each object in the union.
2879
- * @param discriminator the name of the discriminator property
2880
- * @param types an array of object schemas
2881
- * @param params
2882
- */
2883
- static create(discriminator, options, params) {
2884
- const optionsMap = /* @__PURE__ */ new Map();
2885
- for (const type of options) {
2886
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2887
- if (!discriminatorValues.length) {
2888
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2889
- }
2890
- for (const value of discriminatorValues) {
2891
- if (optionsMap.has(value)) {
2892
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2893
- }
2894
- optionsMap.set(value, type);
2895
- }
2896
- }
2897
- return new _ZodDiscriminatedUnion({
2898
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2899
- discriminator,
2900
- options,
2901
- optionsMap,
2902
- ...processCreateParams(params)
2903
- });
2904
- }
2905
- };
2906
- function mergeValues(a, b) {
2907
- const aType = getParsedType(a);
2908
- const bType = getParsedType(b);
2909
- if (a === b) {
2910
- return { valid: true, data: a };
2911
- } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2912
- const bKeys = util.objectKeys(b);
2913
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2914
- const newObj = { ...a, ...b };
2915
- for (const key of sharedKeys) {
2916
- const sharedValue = mergeValues(a[key], b[key]);
2917
- if (!sharedValue.valid) {
2918
- return { valid: false };
2919
- }
2920
- newObj[key] = sharedValue.data;
2921
- }
2922
- return { valid: true, data: newObj };
2923
- } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2924
- if (a.length !== b.length) {
2925
- return { valid: false };
2926
- }
2927
- const newArray = [];
2928
- for (let index = 0; index < a.length; index++) {
2929
- const itemA = a[index];
2930
- const itemB = b[index];
2931
- const sharedValue = mergeValues(itemA, itemB);
2932
- if (!sharedValue.valid) {
2933
- return { valid: false };
2934
- }
2935
- newArray.push(sharedValue.data);
2936
- }
2937
- return { valid: true, data: newArray };
2938
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2939
- return { valid: true, data: a };
2940
- } else {
2941
- return { valid: false };
2942
- }
2943
- }
2944
- var ZodIntersection = class extends ZodType {
2945
- _parse(input) {
2946
- const { status, ctx } = this._processInputParams(input);
2947
- const handleParsed = (parsedLeft, parsedRight) => {
2948
- if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2949
- return INVALID;
2950
- }
2951
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
2952
- if (!merged.valid) {
2953
- addIssueToContext(ctx, {
2954
- code: ZodIssueCode.invalid_intersection_types
2955
- });
2956
- return INVALID;
2957
- }
2958
- if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2959
- status.dirty();
2960
- }
2961
- return { status: status.value, value: merged.data };
2962
- };
2963
- if (ctx.common.async) {
2964
- return Promise.all([
2965
- this._def.left._parseAsync({
2966
- data: ctx.data,
2967
- path: ctx.path,
2968
- parent: ctx
2969
- }),
2970
- this._def.right._parseAsync({
2971
- data: ctx.data,
2972
- path: ctx.path,
2973
- parent: ctx
2974
- })
2975
- ]).then(([left, right]) => handleParsed(left, right));
2976
- } else {
2977
- return handleParsed(this._def.left._parseSync({
2978
- data: ctx.data,
2979
- path: ctx.path,
2980
- parent: ctx
2981
- }), this._def.right._parseSync({
2982
- data: ctx.data,
2983
- path: ctx.path,
2984
- parent: ctx
2985
- }));
2986
- }
2987
- }
2988
- };
2989
- ZodIntersection.create = (left, right, params) => {
2990
- return new ZodIntersection({
2991
- left,
2992
- right,
2993
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
2994
- ...processCreateParams(params)
2995
- });
2996
- };
2997
- var ZodTuple = class _ZodTuple extends ZodType {
2998
- _parse(input) {
2999
- const { status, ctx } = this._processInputParams(input);
3000
- if (ctx.parsedType !== ZodParsedType.array) {
3001
- addIssueToContext(ctx, {
3002
- code: ZodIssueCode.invalid_type,
3003
- expected: ZodParsedType.array,
3004
- received: ctx.parsedType
3005
- });
3006
- return INVALID;
3007
- }
3008
- if (ctx.data.length < this._def.items.length) {
3009
- addIssueToContext(ctx, {
3010
- code: ZodIssueCode.too_small,
3011
- minimum: this._def.items.length,
3012
- inclusive: true,
3013
- exact: false,
3014
- type: "array"
3015
- });
3016
- return INVALID;
3017
- }
3018
- const rest = this._def.rest;
3019
- if (!rest && ctx.data.length > this._def.items.length) {
3020
- addIssueToContext(ctx, {
3021
- code: ZodIssueCode.too_big,
3022
- maximum: this._def.items.length,
3023
- inclusive: true,
3024
- exact: false,
3025
- type: "array"
3026
- });
3027
- status.dirty();
3028
- }
3029
- const items = [...ctx.data].map((item, itemIndex) => {
3030
- const schema = this._def.items[itemIndex] || this._def.rest;
3031
- if (!schema)
3032
- return null;
3033
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3034
- }).filter((x) => !!x);
3035
- if (ctx.common.async) {
3036
- return Promise.all(items).then((results) => {
3037
- return ParseStatus.mergeArray(status, results);
3038
- });
3039
- } else {
3040
- return ParseStatus.mergeArray(status, items);
3041
- }
3042
- }
3043
- get items() {
3044
- return this._def.items;
3045
- }
3046
- rest(rest) {
3047
- return new _ZodTuple({
3048
- ...this._def,
3049
- rest
3050
- });
3051
- }
3052
- };
3053
- ZodTuple.create = (schemas, params) => {
3054
- if (!Array.isArray(schemas)) {
3055
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3056
- }
3057
- return new ZodTuple({
3058
- items: schemas,
3059
- typeName: ZodFirstPartyTypeKind.ZodTuple,
3060
- rest: null,
3061
- ...processCreateParams(params)
3062
- });
3063
- };
3064
- var ZodRecord = class _ZodRecord extends ZodType {
3065
- get keySchema() {
3066
- return this._def.keyType;
3067
- }
3068
- get valueSchema() {
3069
- return this._def.valueType;
3070
- }
3071
- _parse(input) {
3072
- const { status, ctx } = this._processInputParams(input);
3073
- if (ctx.parsedType !== ZodParsedType.object) {
3074
- addIssueToContext(ctx, {
3075
- code: ZodIssueCode.invalid_type,
3076
- expected: ZodParsedType.object,
3077
- received: ctx.parsedType
3078
- });
3079
- return INVALID;
3080
- }
3081
- const pairs = [];
3082
- const keyType = this._def.keyType;
3083
- const valueType = this._def.valueType;
3084
- for (const key in ctx.data) {
3085
- pairs.push({
3086
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3087
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3088
- alwaysSet: key in ctx.data
3089
- });
3090
- }
3091
- if (ctx.common.async) {
3092
- return ParseStatus.mergeObjectAsync(status, pairs);
3093
- } else {
3094
- return ParseStatus.mergeObjectSync(status, pairs);
3095
- }
3096
- }
3097
- get element() {
3098
- return this._def.valueType;
3099
- }
3100
- static create(first, second, third) {
3101
- if (second instanceof ZodType) {
3102
- return new _ZodRecord({
3103
- keyType: first,
3104
- valueType: second,
3105
- typeName: ZodFirstPartyTypeKind.ZodRecord,
3106
- ...processCreateParams(third)
3107
- });
3108
- }
3109
- return new _ZodRecord({
3110
- keyType: ZodString.create(),
3111
- valueType: first,
3112
- typeName: ZodFirstPartyTypeKind.ZodRecord,
3113
- ...processCreateParams(second)
3114
- });
3115
- }
3116
- };
3117
- var ZodMap = class extends ZodType {
3118
- get keySchema() {
3119
- return this._def.keyType;
3120
- }
3121
- get valueSchema() {
3122
- return this._def.valueType;
3123
- }
3124
- _parse(input) {
3125
- const { status, ctx } = this._processInputParams(input);
3126
- if (ctx.parsedType !== ZodParsedType.map) {
3127
- addIssueToContext(ctx, {
3128
- code: ZodIssueCode.invalid_type,
3129
- expected: ZodParsedType.map,
3130
- received: ctx.parsedType
3131
- });
3132
- return INVALID;
3133
- }
3134
- const keyType = this._def.keyType;
3135
- const valueType = this._def.valueType;
3136
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3137
- return {
3138
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3139
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3140
- };
3141
- });
3142
- if (ctx.common.async) {
3143
- const finalMap = /* @__PURE__ */ new Map();
3144
- return Promise.resolve().then(async () => {
3145
- for (const pair of pairs) {
3146
- const key = await pair.key;
3147
- const value = await pair.value;
3148
- if (key.status === "aborted" || value.status === "aborted") {
3149
- return INVALID;
3150
- }
3151
- if (key.status === "dirty" || value.status === "dirty") {
3152
- status.dirty();
3153
- }
3154
- finalMap.set(key.value, value.value);
3155
- }
3156
- return { status: status.value, value: finalMap };
3157
- });
3158
- } else {
3159
- const finalMap = /* @__PURE__ */ new Map();
3160
- for (const pair of pairs) {
3161
- const key = pair.key;
3162
- const value = pair.value;
3163
- if (key.status === "aborted" || value.status === "aborted") {
3164
- return INVALID;
3165
- }
3166
- if (key.status === "dirty" || value.status === "dirty") {
3167
- status.dirty();
3168
- }
3169
- finalMap.set(key.value, value.value);
3170
- }
3171
- return { status: status.value, value: finalMap };
3172
- }
3173
- }
3174
- };
3175
- ZodMap.create = (keyType, valueType, params) => {
3176
- return new ZodMap({
3177
- valueType,
3178
- keyType,
3179
- typeName: ZodFirstPartyTypeKind.ZodMap,
3180
- ...processCreateParams(params)
3181
- });
3182
- };
3183
- var ZodSet = class _ZodSet extends ZodType {
3184
- _parse(input) {
3185
- const { status, ctx } = this._processInputParams(input);
3186
- if (ctx.parsedType !== ZodParsedType.set) {
3187
- addIssueToContext(ctx, {
3188
- code: ZodIssueCode.invalid_type,
3189
- expected: ZodParsedType.set,
3190
- received: ctx.parsedType
3191
- });
3192
- return INVALID;
3193
- }
3194
- const def = this._def;
3195
- if (def.minSize !== null) {
3196
- if (ctx.data.size < def.minSize.value) {
3197
- addIssueToContext(ctx, {
3198
- code: ZodIssueCode.too_small,
3199
- minimum: def.minSize.value,
3200
- type: "set",
3201
- inclusive: true,
3202
- exact: false,
3203
- message: def.minSize.message
3204
- });
3205
- status.dirty();
3206
- }
3207
- }
3208
- if (def.maxSize !== null) {
3209
- if (ctx.data.size > def.maxSize.value) {
3210
- addIssueToContext(ctx, {
3211
- code: ZodIssueCode.too_big,
3212
- maximum: def.maxSize.value,
3213
- type: "set",
3214
- inclusive: true,
3215
- exact: false,
3216
- message: def.maxSize.message
3217
- });
3218
- status.dirty();
3219
- }
3220
- }
3221
- const valueType = this._def.valueType;
3222
- function finalizeSet(elements2) {
3223
- const parsedSet = /* @__PURE__ */ new Set();
3224
- for (const element of elements2) {
3225
- if (element.status === "aborted")
3226
- return INVALID;
3227
- if (element.status === "dirty")
3228
- status.dirty();
3229
- parsedSet.add(element.value);
3230
- }
3231
- return { status: status.value, value: parsedSet };
3232
- }
3233
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3234
- if (ctx.common.async) {
3235
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3236
- } else {
3237
- return finalizeSet(elements);
3238
- }
3239
- }
3240
- min(minSize, message) {
3241
- return new _ZodSet({
3242
- ...this._def,
3243
- minSize: { value: minSize, message: errorUtil.toString(message) }
3244
- });
3245
- }
3246
- max(maxSize, message) {
3247
- return new _ZodSet({
3248
- ...this._def,
3249
- maxSize: { value: maxSize, message: errorUtil.toString(message) }
3250
- });
3251
- }
3252
- size(size, message) {
3253
- return this.min(size, message).max(size, message);
3254
- }
3255
- nonempty(message) {
3256
- return this.min(1, message);
3257
- }
3258
- };
3259
- ZodSet.create = (valueType, params) => {
3260
- return new ZodSet({
3261
- valueType,
3262
- minSize: null,
3263
- maxSize: null,
3264
- typeName: ZodFirstPartyTypeKind.ZodSet,
3265
- ...processCreateParams(params)
3266
- });
3267
- };
3268
- var ZodFunction = class _ZodFunction extends ZodType {
3269
- constructor() {
3270
- super(...arguments);
3271
- this.validate = this.implement;
3272
- }
3273
- _parse(input) {
3274
- const { ctx } = this._processInputParams(input);
3275
- if (ctx.parsedType !== ZodParsedType.function) {
3276
- addIssueToContext(ctx, {
3277
- code: ZodIssueCode.invalid_type,
3278
- expected: ZodParsedType.function,
3279
- received: ctx.parsedType
3280
- });
3281
- return INVALID;
3282
- }
3283
- function makeArgsIssue(args, error) {
3284
- return makeIssue({
3285
- data: args,
3286
- path: ctx.path,
3287
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3288
- issueData: {
3289
- code: ZodIssueCode.invalid_arguments,
3290
- argumentsError: error
3291
- }
3292
- });
3293
- }
3294
- function makeReturnsIssue(returns, error) {
3295
- return makeIssue({
3296
- data: returns,
3297
- path: ctx.path,
3298
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3299
- issueData: {
3300
- code: ZodIssueCode.invalid_return_type,
3301
- returnTypeError: error
3302
- }
3303
- });
3304
- }
3305
- const params = { errorMap: ctx.common.contextualErrorMap };
3306
- const fn = ctx.data;
3307
- if (this._def.returns instanceof ZodPromise) {
3308
- const me = this;
3309
- return OK(async function(...args) {
3310
- const error = new ZodError([]);
3311
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3312
- error.addIssue(makeArgsIssue(args, e));
3313
- throw error;
3314
- });
3315
- const result = await Reflect.apply(fn, this, parsedArgs);
3316
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3317
- error.addIssue(makeReturnsIssue(result, e));
3318
- throw error;
3319
- });
3320
- return parsedReturns;
3321
- });
3322
- } else {
3323
- const me = this;
3324
- return OK(function(...args) {
3325
- const parsedArgs = me._def.args.safeParse(args, params);
3326
- if (!parsedArgs.success) {
3327
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3328
- }
3329
- const result = Reflect.apply(fn, this, parsedArgs.data);
3330
- const parsedReturns = me._def.returns.safeParse(result, params);
3331
- if (!parsedReturns.success) {
3332
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3333
- }
3334
- return parsedReturns.data;
3335
- });
3336
- }
3337
- }
3338
- parameters() {
3339
- return this._def.args;
3340
- }
3341
- returnType() {
3342
- return this._def.returns;
3343
- }
3344
- args(...items) {
3345
- return new _ZodFunction({
3346
- ...this._def,
3347
- args: ZodTuple.create(items).rest(ZodUnknown.create())
3348
- });
3349
- }
3350
- returns(returnType) {
3351
- return new _ZodFunction({
3352
- ...this._def,
3353
- returns: returnType
3354
- });
3355
- }
3356
- implement(func) {
3357
- const validatedFunc = this.parse(func);
3358
- return validatedFunc;
3359
- }
3360
- strictImplement(func) {
3361
- const validatedFunc = this.parse(func);
3362
- return validatedFunc;
3363
- }
3364
- static create(args, returns, params) {
3365
- return new _ZodFunction({
3366
- args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3367
- returns: returns || ZodUnknown.create(),
3368
- typeName: ZodFirstPartyTypeKind.ZodFunction,
3369
- ...processCreateParams(params)
3370
- });
3371
- }
3372
- };
3373
- var ZodLazy = class extends ZodType {
3374
- get schema() {
3375
- return this._def.getter();
3376
- }
3377
- _parse(input) {
3378
- const { ctx } = this._processInputParams(input);
3379
- const lazySchema = this._def.getter();
3380
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3381
- }
3382
- };
3383
- ZodLazy.create = (getter, params) => {
3384
- return new ZodLazy({
3385
- getter,
3386
- typeName: ZodFirstPartyTypeKind.ZodLazy,
3387
- ...processCreateParams(params)
3388
- });
3389
- };
3390
- var ZodLiteral = class extends ZodType {
3391
- _parse(input) {
3392
- if (input.data !== this._def.value) {
3393
- const ctx = this._getOrReturnCtx(input);
3394
- addIssueToContext(ctx, {
3395
- received: ctx.data,
3396
- code: ZodIssueCode.invalid_literal,
3397
- expected: this._def.value
3398
- });
3399
- return INVALID;
3400
- }
3401
- return { status: "valid", value: input.data };
3402
- }
3403
- get value() {
3404
- return this._def.value;
3405
- }
3406
- };
3407
- ZodLiteral.create = (value, params) => {
3408
- return new ZodLiteral({
3409
- value,
3410
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
3411
- ...processCreateParams(params)
3412
- });
3413
- };
3414
- function createZodEnum(values, params) {
3415
- return new ZodEnum({
3416
- values,
3417
- typeName: ZodFirstPartyTypeKind.ZodEnum,
3418
- ...processCreateParams(params)
3419
- });
3420
- }
3421
- var ZodEnum = class _ZodEnum extends ZodType {
3422
- _parse(input) {
3423
- if (typeof input.data !== "string") {
3424
- const ctx = this._getOrReturnCtx(input);
3425
- const expectedValues = this._def.values;
3426
- addIssueToContext(ctx, {
3427
- expected: util.joinValues(expectedValues),
3428
- received: ctx.parsedType,
3429
- code: ZodIssueCode.invalid_type
3430
- });
3431
- return INVALID;
3432
- }
3433
- if (!this._cache) {
3434
- this._cache = new Set(this._def.values);
3435
- }
3436
- if (!this._cache.has(input.data)) {
3437
- const ctx = this._getOrReturnCtx(input);
3438
- const expectedValues = this._def.values;
3439
- addIssueToContext(ctx, {
3440
- received: ctx.data,
3441
- code: ZodIssueCode.invalid_enum_value,
3442
- options: expectedValues
3443
- });
3444
- return INVALID;
3445
- }
3446
- return OK(input.data);
3447
- }
3448
- get options() {
3449
- return this._def.values;
3450
- }
3451
- get enum() {
3452
- const enumValues = {};
3453
- for (const val of this._def.values) {
3454
- enumValues[val] = val;
3455
- }
3456
- return enumValues;
3457
- }
3458
- get Values() {
3459
- const enumValues = {};
3460
- for (const val of this._def.values) {
3461
- enumValues[val] = val;
3462
- }
3463
- return enumValues;
3464
- }
3465
- get Enum() {
3466
- const enumValues = {};
3467
- for (const val of this._def.values) {
3468
- enumValues[val] = val;
3469
- }
3470
- return enumValues;
3471
- }
3472
- extract(values, newDef = this._def) {
3473
- return _ZodEnum.create(values, {
3474
- ...this._def,
3475
- ...newDef
3476
- });
3477
- }
3478
- exclude(values, newDef = this._def) {
3479
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3480
- ...this._def,
3481
- ...newDef
3482
- });
3483
- }
3484
- };
3485
- ZodEnum.create = createZodEnum;
3486
- var ZodNativeEnum = class extends ZodType {
3487
- _parse(input) {
3488
- const nativeEnumValues = util.getValidEnumValues(this._def.values);
3489
- const ctx = this._getOrReturnCtx(input);
3490
- if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3491
- const expectedValues = util.objectValues(nativeEnumValues);
3492
- addIssueToContext(ctx, {
3493
- expected: util.joinValues(expectedValues),
3494
- received: ctx.parsedType,
3495
- code: ZodIssueCode.invalid_type
3496
- });
3497
- return INVALID;
3498
- }
3499
- if (!this._cache) {
3500
- this._cache = new Set(util.getValidEnumValues(this._def.values));
3501
- }
3502
- if (!this._cache.has(input.data)) {
3503
- const expectedValues = util.objectValues(nativeEnumValues);
3504
- addIssueToContext(ctx, {
3505
- received: ctx.data,
3506
- code: ZodIssueCode.invalid_enum_value,
3507
- options: expectedValues
3508
- });
3509
- return INVALID;
3510
- }
3511
- return OK(input.data);
3512
- }
3513
- get enum() {
3514
- return this._def.values;
3515
- }
3516
- };
3517
- ZodNativeEnum.create = (values, params) => {
3518
- return new ZodNativeEnum({
3519
- values,
3520
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3521
- ...processCreateParams(params)
3522
- });
3523
- };
3524
- var ZodPromise = class extends ZodType {
3525
- unwrap() {
3526
- return this._def.type;
3527
- }
3528
- _parse(input) {
3529
- const { ctx } = this._processInputParams(input);
3530
- if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3531
- addIssueToContext(ctx, {
3532
- code: ZodIssueCode.invalid_type,
3533
- expected: ZodParsedType.promise,
3534
- received: ctx.parsedType
3535
- });
3536
- return INVALID;
3537
- }
3538
- const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3539
- return OK(promisified.then((data) => {
3540
- return this._def.type.parseAsync(data, {
3541
- path: ctx.path,
3542
- errorMap: ctx.common.contextualErrorMap
3543
- });
3544
- }));
3545
- }
3546
- };
3547
- ZodPromise.create = (schema, params) => {
3548
- return new ZodPromise({
3549
- type: schema,
3550
- typeName: ZodFirstPartyTypeKind.ZodPromise,
3551
- ...processCreateParams(params)
3552
- });
3553
- };
3554
- var ZodEffects = class extends ZodType {
3555
- innerType() {
3556
- return this._def.schema;
3557
- }
3558
- sourceType() {
3559
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3560
- }
3561
- _parse(input) {
3562
- const { status, ctx } = this._processInputParams(input);
3563
- const effect = this._def.effect || null;
3564
- const checkCtx = {
3565
- addIssue: (arg) => {
3566
- addIssueToContext(ctx, arg);
3567
- if (arg.fatal) {
3568
- status.abort();
3569
- } else {
3570
- status.dirty();
3571
- }
3572
- },
3573
- get path() {
3574
- return ctx.path;
3575
- }
3576
- };
3577
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3578
- if (effect.type === "preprocess") {
3579
- const processed = effect.transform(ctx.data, checkCtx);
3580
- if (ctx.common.async) {
3581
- return Promise.resolve(processed).then(async (processed2) => {
3582
- if (status.value === "aborted")
3583
- return INVALID;
3584
- const result = await this._def.schema._parseAsync({
3585
- data: processed2,
3586
- path: ctx.path,
3587
- parent: ctx
3588
- });
3589
- if (result.status === "aborted")
3590
- return INVALID;
3591
- if (result.status === "dirty")
3592
- return DIRTY(result.value);
3593
- if (status.value === "dirty")
3594
- return DIRTY(result.value);
3595
- return result;
3596
- });
3597
- } else {
3598
- if (status.value === "aborted")
3599
- return INVALID;
3600
- const result = this._def.schema._parseSync({
3601
- data: processed,
3602
- path: ctx.path,
3603
- parent: ctx
3604
- });
3605
- if (result.status === "aborted")
3606
- return INVALID;
3607
- if (result.status === "dirty")
3608
- return DIRTY(result.value);
3609
- if (status.value === "dirty")
3610
- return DIRTY(result.value);
3611
- return result;
3612
- }
3613
- }
3614
- if (effect.type === "refinement") {
3615
- const executeRefinement = (acc) => {
3616
- const result = effect.refinement(acc, checkCtx);
3617
- if (ctx.common.async) {
3618
- return Promise.resolve(result);
3619
- }
3620
- if (result instanceof Promise) {
3621
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3622
- }
3623
- return acc;
3624
- };
3625
- if (ctx.common.async === false) {
3626
- const inner = this._def.schema._parseSync({
3627
- data: ctx.data,
3628
- path: ctx.path,
3629
- parent: ctx
3630
- });
3631
- if (inner.status === "aborted")
3632
- return INVALID;
3633
- if (inner.status === "dirty")
3634
- status.dirty();
3635
- executeRefinement(inner.value);
3636
- return { status: status.value, value: inner.value };
3637
- } else {
3638
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3639
- if (inner.status === "aborted")
3640
- return INVALID;
3641
- if (inner.status === "dirty")
3642
- status.dirty();
3643
- return executeRefinement(inner.value).then(() => {
3644
- return { status: status.value, value: inner.value };
3645
- });
3646
- });
3647
- }
3648
- }
3649
- if (effect.type === "transform") {
3650
- if (ctx.common.async === false) {
3651
- const base = this._def.schema._parseSync({
3652
- data: ctx.data,
3653
- path: ctx.path,
3654
- parent: ctx
3655
- });
3656
- if (!isValid(base))
3657
- return INVALID;
3658
- const result = effect.transform(base.value, checkCtx);
3659
- if (result instanceof Promise) {
3660
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3661
- }
3662
- return { status: status.value, value: result };
3663
- } else {
3664
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3665
- if (!isValid(base))
3666
- return INVALID;
3667
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3668
- status: status.value,
3669
- value: result
3670
- }));
3671
- });
3672
- }
3673
- }
3674
- util.assertNever(effect);
3675
- }
3676
- };
3677
- ZodEffects.create = (schema, effect, params) => {
3678
- return new ZodEffects({
3679
- schema,
3680
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3681
- effect,
3682
- ...processCreateParams(params)
3683
- });
3684
- };
3685
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3686
- return new ZodEffects({
3687
- schema,
3688
- effect: { type: "preprocess", transform: preprocess },
3689
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3690
- ...processCreateParams(params)
3691
- });
3692
- };
3693
- var ZodOptional = class extends ZodType {
3694
- _parse(input) {
3695
- const parsedType = this._getType(input);
3696
- if (parsedType === ZodParsedType.undefined) {
3697
- return OK(void 0);
3698
- }
3699
- return this._def.innerType._parse(input);
3700
- }
3701
- unwrap() {
3702
- return this._def.innerType;
3703
- }
3704
- };
3705
- ZodOptional.create = (type, params) => {
3706
- return new ZodOptional({
3707
- innerType: type,
3708
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3709
- ...processCreateParams(params)
3710
- });
3711
- };
3712
- var ZodNullable = class extends ZodType {
3713
- _parse(input) {
3714
- const parsedType = this._getType(input);
3715
- if (parsedType === ZodParsedType.null) {
3716
- return OK(null);
3717
- }
3718
- return this._def.innerType._parse(input);
3719
- }
3720
- unwrap() {
3721
- return this._def.innerType;
3722
- }
3723
- };
3724
- ZodNullable.create = (type, params) => {
3725
- return new ZodNullable({
3726
- innerType: type,
3727
- typeName: ZodFirstPartyTypeKind.ZodNullable,
3728
- ...processCreateParams(params)
3729
- });
3730
- };
3731
- var ZodDefault = class extends ZodType {
3732
- _parse(input) {
3733
- const { ctx } = this._processInputParams(input);
3734
- let data = ctx.data;
3735
- if (ctx.parsedType === ZodParsedType.undefined) {
3736
- data = this._def.defaultValue();
3737
- }
3738
- return this._def.innerType._parse({
3739
- data,
3740
- path: ctx.path,
3741
- parent: ctx
3742
- });
3743
- }
3744
- removeDefault() {
3745
- return this._def.innerType;
3746
- }
3747
- };
3748
- ZodDefault.create = (type, params) => {
3749
- return new ZodDefault({
3750
- innerType: type,
3751
- typeName: ZodFirstPartyTypeKind.ZodDefault,
3752
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3753
- ...processCreateParams(params)
3754
- });
3755
- };
3756
- var ZodCatch = class extends ZodType {
3757
- _parse(input) {
3758
- const { ctx } = this._processInputParams(input);
3759
- const newCtx = {
3760
- ...ctx,
3761
- common: {
3762
- ...ctx.common,
3763
- issues: []
3764
- }
3765
- };
3766
- const result = this._def.innerType._parse({
3767
- data: newCtx.data,
3768
- path: newCtx.path,
3769
- parent: {
3770
- ...newCtx
3771
- }
3772
- });
3773
- if (isAsync(result)) {
3774
- return result.then((result2) => {
3775
- return {
3776
- status: "valid",
3777
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
3778
- get error() {
3779
- return new ZodError(newCtx.common.issues);
3780
- },
3781
- input: newCtx.data
3782
- })
3783
- };
3784
- });
3785
- } else {
3786
- return {
3787
- status: "valid",
3788
- value: result.status === "valid" ? result.value : this._def.catchValue({
3789
- get error() {
3790
- return new ZodError(newCtx.common.issues);
3791
- },
3792
- input: newCtx.data
3793
- })
3794
- };
3795
- }
3796
- }
3797
- removeCatch() {
3798
- return this._def.innerType;
3799
- }
3800
- };
3801
- ZodCatch.create = (type, params) => {
3802
- return new ZodCatch({
3803
- innerType: type,
3804
- typeName: ZodFirstPartyTypeKind.ZodCatch,
3805
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3806
- ...processCreateParams(params)
3807
- });
3808
- };
3809
- var ZodNaN = class extends ZodType {
3810
- _parse(input) {
3811
- const parsedType = this._getType(input);
3812
- if (parsedType !== ZodParsedType.nan) {
3813
- const ctx = this._getOrReturnCtx(input);
3814
- addIssueToContext(ctx, {
3815
- code: ZodIssueCode.invalid_type,
3816
- expected: ZodParsedType.nan,
3817
- received: ctx.parsedType
3818
- });
3819
- return INVALID;
3820
- }
3821
- return { status: "valid", value: input.data };
3822
- }
3823
- };
3824
- ZodNaN.create = (params) => {
3825
- return new ZodNaN({
3826
- typeName: ZodFirstPartyTypeKind.ZodNaN,
3827
- ...processCreateParams(params)
3828
- });
3829
- };
3830
- var BRAND = Symbol("zod_brand");
3831
- var ZodBranded = class extends ZodType {
3832
- _parse(input) {
3833
- const { ctx } = this._processInputParams(input);
3834
- const data = ctx.data;
3835
- return this._def.type._parse({
3836
- data,
3837
- path: ctx.path,
3838
- parent: ctx
3839
- });
3840
- }
3841
- unwrap() {
3842
- return this._def.type;
3843
- }
3844
- };
3845
- var ZodPipeline = class _ZodPipeline extends ZodType {
3846
- _parse(input) {
3847
- const { status, ctx } = this._processInputParams(input);
3848
- if (ctx.common.async) {
3849
- const handleAsync = async () => {
3850
- const inResult = await this._def.in._parseAsync({
3851
- data: ctx.data,
3852
- path: ctx.path,
3853
- parent: ctx
3854
- });
3855
- if (inResult.status === "aborted")
3856
- return INVALID;
3857
- if (inResult.status === "dirty") {
3858
- status.dirty();
3859
- return DIRTY(inResult.value);
3860
- } else {
3861
- return this._def.out._parseAsync({
3862
- data: inResult.value,
3863
- path: ctx.path,
3864
- parent: ctx
3865
- });
3866
- }
3867
- };
3868
- return handleAsync();
3869
- } else {
3870
- const inResult = this._def.in._parseSync({
3871
- data: ctx.data,
3872
- path: ctx.path,
3873
- parent: ctx
3874
- });
3875
- if (inResult.status === "aborted")
3876
- return INVALID;
3877
- if (inResult.status === "dirty") {
3878
- status.dirty();
3879
- return {
3880
- status: "dirty",
3881
- value: inResult.value
3882
- };
3883
- } else {
3884
- return this._def.out._parseSync({
3885
- data: inResult.value,
3886
- path: ctx.path,
3887
- parent: ctx
3888
- });
3889
- }
3890
- }
3891
- }
3892
- static create(a, b) {
3893
- return new _ZodPipeline({
3894
- in: a,
3895
- out: b,
3896
- typeName: ZodFirstPartyTypeKind.ZodPipeline
3897
- });
3898
- }
3899
- };
3900
- var ZodReadonly = class extends ZodType {
3901
- _parse(input) {
3902
- const result = this._def.innerType._parse(input);
3903
- const freeze = (data) => {
3904
- if (isValid(data)) {
3905
- data.value = Object.freeze(data.value);
3906
- }
3907
- return data;
3908
- };
3909
- return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3910
- }
3911
- unwrap() {
3912
- return this._def.innerType;
3913
- }
3914
- };
3915
- ZodReadonly.create = (type, params) => {
3916
- return new ZodReadonly({
3917
- innerType: type,
3918
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
3919
- ...processCreateParams(params)
3920
- });
3921
- };
3922
- function cleanParams(params, data) {
3923
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3924
- const p2 = typeof p === "string" ? { message: p } : p;
3925
- return p2;
3926
- }
3927
- function custom(check, _params = {}, fatal) {
3928
- if (check)
3929
- return ZodAny.create().superRefine((data, ctx) => {
3930
- const r = check(data);
3931
- if (r instanceof Promise) {
3932
- return r.then((r2) => {
3933
- if (!r2) {
3934
- const params = cleanParams(_params, data);
3935
- const _fatal = params.fatal ?? fatal ?? true;
3936
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3937
- }
3938
- });
3939
- }
3940
- if (!r) {
3941
- const params = cleanParams(_params, data);
3942
- const _fatal = params.fatal ?? fatal ?? true;
3943
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3944
- }
3945
- return;
3946
- });
3947
- return ZodAny.create();
3948
- }
3949
- var late = {
3950
- object: ZodObject.lazycreate
3951
- };
3952
- var ZodFirstPartyTypeKind;
3953
- (function(ZodFirstPartyTypeKind2) {
3954
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3955
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3956
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3957
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3958
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3959
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3960
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3961
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3962
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3963
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3964
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3965
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3966
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3967
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3968
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3969
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3970
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3971
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3972
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3973
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3974
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3975
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3976
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3977
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3978
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3979
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3980
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3981
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3982
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3983
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3984
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3985
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3986
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3987
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3988
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3989
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3990
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3991
- var instanceOfType = (cls, params = {
3992
- message: `Input not instance of ${cls.name}`
3993
- }) => custom((data) => data instanceof cls, params);
3994
- var stringType = ZodString.create;
3995
- var numberType = ZodNumber.create;
3996
- var nanType = ZodNaN.create;
3997
- var bigIntType = ZodBigInt.create;
3998
- var booleanType = ZodBoolean.create;
3999
- var dateType = ZodDate.create;
4000
- var symbolType = ZodSymbol.create;
4001
- var undefinedType = ZodUndefined.create;
4002
- var nullType = ZodNull.create;
4003
- var anyType = ZodAny.create;
4004
- var unknownType = ZodUnknown.create;
4005
- var neverType = ZodNever.create;
4006
- var voidType = ZodVoid.create;
4007
- var arrayType = ZodArray.create;
4008
- var objectType = ZodObject.create;
4009
- var strictObjectType = ZodObject.strictCreate;
4010
- var unionType = ZodUnion.create;
4011
- var discriminatedUnionType = ZodDiscriminatedUnion.create;
4012
- var intersectionType = ZodIntersection.create;
4013
- var tupleType = ZodTuple.create;
4014
- var recordType = ZodRecord.create;
4015
- var mapType = ZodMap.create;
4016
- var setType = ZodSet.create;
4017
- var functionType = ZodFunction.create;
4018
- var lazyType = ZodLazy.create;
4019
- var literalType = ZodLiteral.create;
4020
- var enumType = ZodEnum.create;
4021
- var nativeEnumType = ZodNativeEnum.create;
4022
- var promiseType = ZodPromise.create;
4023
- var effectsType = ZodEffects.create;
4024
- var optionalType = ZodOptional.create;
4025
- var nullableType = ZodNullable.create;
4026
- var preprocessType = ZodEffects.createWithPreprocess;
4027
- var pipelineType = ZodPipeline.create;
4028
- var ostring = () => stringType().optional();
4029
- var onumber = () => numberType().optional();
4030
- var oboolean = () => booleanType().optional();
4031
- var coerce = {
4032
- string: (arg) => ZodString.create({ ...arg, coerce: true }),
4033
- number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4034
- boolean: (arg) => ZodBoolean.create({
4035
- ...arg,
4036
- coerce: true
4037
- }),
4038
- bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4039
- date: (arg) => ZodDate.create({ ...arg, coerce: true })
4040
- };
4041
- var NEVER = INVALID;
4042
-
4043
- // lib/imports/models/ImportDetail.ts
4044
- var importDetailSchema = external_exports.object({
4045
- completedAt: external_exports.number().nullish(),
4046
- errorCount: external_exports.number(),
4047
- importId: external_exports.number(),
4048
- name: external_exports.string(),
4049
- startedAt: external_exports.string().nullish(),
4050
- status: external_exports.string(),
4051
- uploadedAt: external_exports.string()
4052
- });
4053
-
4054
- // lib/imports/models/Import.ts
4055
- var importSchema = external_exports.object({
4056
- count: external_exports.number(),
4057
- imports: external_exports.array(importDetailSchema)
4058
- });
4059
-
4060
- // lib/imports/models/ImportError.ts
4061
- var importErrorSchema = external_exports.object({
4062
- attribute: external_exports.string().nullish(),
4063
- description: external_exports.string(),
4064
- importErrorId: external_exports.number(),
4065
- row: external_exports.number()
4066
- });
4067
-
4068
- // lib/imports/models/ImportErrors.ts
4069
- var importErrorsSchema = external_exports.object({
4070
- count: external_exports.number(),
4071
- errors: external_exports.array(importErrorSchema),
4072
- hasNext: external_exports.boolean(),
4073
- importId: external_exports.number(),
4074
- totalCount: external_exports.number()
4075
- });
4076
-
4077
- // lib/imports/models/ImportsStatusEnum.ts
4078
- var importStatusEnumSchema = external_exports.enum([
4079
- "QUEUED_FOR_IMPORT",
4080
- "IN_PROGRESS",
4081
- "DOC_FAILED",
4082
- "VALIDATION_FAILED",
4083
- "COMPLETED"
4084
- ]);
4085
-
4086
- // lib/imports/models/ImportsStatus.ts
4087
- var importsStatusSchema = external_exports.object({
4088
- completedAt: external_exports.string().nullish(),
4089
- docInEventId: external_exports.string().nullish(),
4090
- errorCount: external_exports.number().nullish(),
4091
- importId: external_exports.number(),
4092
- invalidItemCount: external_exports.number().nullish(),
4093
- name: external_exports.string().nullish(),
4094
- status: importStatusEnumSchema,
4095
- totalItemCount: external_exports.number().nullish(),
4096
- validItemCount: external_exports.number().nullish()
4097
- });
4098
-
4099
- // lib/imports/models/VendorPartnerAttGroups.ts
4100
- var vendorPartnerAttGroupsSchema = external_exports.object({
4101
- partnerCompanyId: external_exports.number(),
4102
- partnerCompanyName: external_exports.string(),
4103
- partnerAttributeGroups: external_exports.array(external_exports.number())
4104
- });
4105
-
4106
- // lib/imports/models/GenerateImportTemplateParams.ts
4107
- var generateImportTemplateParamsSchema = external_exports.object({
4108
- "multi-sheet": external_exports.boolean(),
4109
- gids: external_exports.string().optional(),
4110
- productTypeIds: external_exports.string().optional(),
4111
- groupTypeId: external_exports.number().optional(),
4112
- includeGuides: external_exports.boolean().optional()
4113
- });
4114
-
4115
- // lib/productTypes/models/AttrProdType.ts
4116
- var attrProdTypeSchema = external_exports.object({
4117
- attrProdTypeId: external_exports.number(),
4118
- productType: external_exports.string(),
4119
- description: external_exports.string(),
4120
- createdDate: external_exports.number(),
4121
- createdBy: external_exports.string(),
4122
- modifiedDate: external_exports.number().optional(),
4123
- modifiedBy: external_exports.string().optional(),
4124
- retailerId: external_exports.number().optional()
4125
- });
4126
-
4127
- // lib/productTypes/models/PagedResults.ts
4128
- function pagedResultsSchema(resultsType) {
4129
- return external_exports.object({
4130
- next: external_exports.string(),
4131
- previous: external_exports.string(),
4132
- count: external_exports.number(),
4133
- results: external_exports.array(resultsType)
4134
- });
4135
- }
4136
-
4137
- // lib/tradingPartners/models/Connection.ts
4138
- var connectionSchema = external_exports.object({
4139
- catalog_id: external_exports.number(),
4140
- catalog_name: external_exports.string().nullable(),
4141
- partner_company_name: external_exports.string(),
4142
- partner_company_id: external_exports.number(),
4143
- partner_org_id: external_exports.string()
4144
- });
4145
-
4146
- // lib/tradingPartners/models/CompanyRelationshipUpsertBody.ts
4147
- var companyRelationshipUpsertBodySchema = external_exports.object({
4148
- supplierId: external_exports.number(),
4149
- retailerId: external_exports.number(),
4150
- catalogId: external_exports.number(),
4151
- active: external_exports.boolean(),
4152
- applicationType: external_exports.array(external_exports.enum(["ASSORTMENT", "ITEM-XREF", "TEST-ORDER-GENERATOR"])).default([])
4153
- });
4154
-
4155
- // lib/tradingPartners/models/ItemPartner.ts
4156
- var itemPartnerSchema = external_exports.object({
4157
- itemPartnerId: external_exports.number(),
4158
- retailerId: external_exports.number(),
4159
- supplierId: external_exports.number(),
4160
- catalogId: external_exports.number(),
4161
- isActive: external_exports.number(),
4162
- createdDate: external_exports.string(),
4163
- modifiedDate: external_exports.string(),
4164
- applications: external_exports.array(external_exports.enum(["ASSORTMENT", "ITEM-XREF"]))
4165
- });
4166
-
4167
- // lib/tradingPartners/models/TradingPartnerAccessByCompanyId.ts
4168
- var tradingPartnerAccessByCompanyIdSchema = external_exports.object({
4169
- companyId: external_exports.number(),
4170
- companyType: external_exports.string(),
4171
- identityOrgId: external_exports.string(),
4172
- companyName: external_exports.string(),
4173
- count: external_exports.number(),
4174
- connections: external_exports.array(connectionSchema)
4175
- });
4176
-
4177
- // lib/categories/models/ItemCategory.ts
4178
- var itemCategorySchema = external_exports.object({
4179
- categoryid: external_exports.number(),
4180
- encodedCategoryId: external_exports.string(),
4181
- companyId: external_exports.number(),
4182
- name: external_exports.string(),
4183
- isActive: external_exports.number(),
4184
- createdDate: external_exports.number().nullish(),
4185
- categorytimestamp: external_exports.number().nullish(),
4186
- typeId: external_exports.number(),
4187
- type: external_exports.string(),
4188
- categorykey: external_exports.string().nullish(),
4189
- description: external_exports.string().nullish(),
4190
- categoryCatalogName: external_exports.string().nullish()
4191
- });
4192
-
4193
- // lib/categories/models/ItemCategoriesSearch.ts
4194
- var itemCategoriesSearchSchema = external_exports.object({
4195
- count: external_exports.number(),
4196
- data: external_exports.array(itemCategorySchema)
4197
- });
4198
-
4199
- // lib/categories/models/ItemHierarchyResponse.ts
4200
- var baseHierarchySchema = external_exports.object({
4201
- id: external_exports.string(),
4202
- name: external_exports.string().nullish(),
4203
- description: external_exports.string().nullish(),
4204
- type: external_exports.string().nullish()
4205
- });
4206
- var hierarchySchema = baseHierarchySchema.extend({
4207
- child: external_exports.lazy(() => hierarchySchema).nullable()
4208
- });
4209
- var itemHierarchyResponseSchema = external_exports.object({
4210
- itemHierarchies: external_exports.array(
4211
- external_exports.object({
4212
- itemId: external_exports.string(),
4213
- hierarchies: external_exports.array(hierarchySchema)
4214
- })
4215
- )
4216
- });
4217
-
4218
- // lib/locale/models/Locale.ts
4219
- var localeSchema = external_exports.object({
4220
- localeCode: external_exports.string(),
4221
- localeDescription: external_exports.string()
4222
- });
4223
-
4224
- // lib/spreadsheetTemplate/models/SpreadsheetTemplateCompany.ts
4225
- var spreadsheetTemplateCompanySchema = external_exports.object({
4226
- companyName: external_exports.string(),
4227
- companyId: external_exports.number(),
4228
- createdAt: external_exports.number()
4229
- });
4230
-
4231
- // lib/spreadsheetTemplate/models/SpreadsheetTemplate.ts
4232
- var spreadsheetTemplateSchema = external_exports.object({
4233
- id: external_exports.number(),
4234
- fileLocation: external_exports.string(),
4235
- name: external_exports.string(),
4236
- templateType: external_exports.string(),
4237
- maxItemsPerDoc: external_exports.number(),
4238
- companies: external_exports.array(spreadsheetTemplateCompanySchema),
4239
- createdBy: external_exports.string().nullish(),
4240
- createdAt: external_exports.number().nullish(),
4241
- modifiedBy: external_exports.string().nullish(),
4242
- modifiedAt: external_exports.number().nullish()
4243
- });
4244
-
4245
- // lib/whoami/models/IdentityServiceDatetimePreferences.ts
4246
- var identityServiceDatetimePreferencesSchema = external_exports.object({
4247
- DATE_TIME: external_exports.string(),
4248
- TIME: external_exports.string(),
4249
- SHORT_DATE: external_exports.string(),
4250
- LONG_DATETIME: external_exports.string(),
4251
- LONG_TIME: external_exports.string(),
4252
- DATE: external_exports.string()
4253
- });
4254
-
4255
- // lib/whoami/models/IdentityServiceOrganizationMetadata.ts
4256
- var identityServiceOrganizationMetadataSchema = external_exports.object({
4257
- namespace: external_exports.string(),
4258
- key: external_exports.string(),
4259
- value: external_exports.string()
4260
- });
4261
-
4262
- // lib/whoami/models/IdentityServiceOrganization.ts
4263
- var identityServiceOrganizationSchema = external_exports.object({
4264
- organization_name: external_exports.string().optional(),
4265
- organization_site: external_exports.string().optional(),
4266
- namespace: external_exports.string().optional(),
4267
- id: external_exports.string(),
4268
- permissions: external_exports.array(external_exports.string()).optional(),
4269
- metadata: identityServiceOrganizationMetadataSchema.optional()
4270
- });
4271
-
4272
- // lib/whoami/models/IdentityServicePreferences.ts
4273
- var identityServicePreferencesSchema = external_exports.object({
4274
- locale: external_exports.string(),
4275
- timezone: external_exports.string(),
4276
- cpUpgrade: external_exports.string().optional(),
4277
- language: external_exports.array(external_exports.string()),
4278
- datetime: identityServiceDatetimePreferencesSchema
4279
- });
4280
-
4281
- // lib/whoami/models/IdentityServiceUser.ts
4282
- var identityServiceUserSchema = external_exports.object({
4283
- id: external_exports.string(),
4284
- email: external_exports.string().optional(),
4285
- first_name: external_exports.string().optional(),
4286
- last_name: external_exports.string().optional(),
4287
- job_title: external_exports.string().optional(),
4288
- externally_managed: external_exports.boolean().optional(),
4289
- city: external_exports.string().optional(),
4290
- name: external_exports.string(),
4291
- state: external_exports.string().optional(),
4292
- country: external_exports.string().optional(),
4293
- user_type: external_exports.string().optional(),
4294
- token_type: external_exports.string().optional(),
4295
- avatar_image_id: external_exports.string().optional(),
4296
- avatar_image_url: external_exports.string().optional(),
4297
- origin_avatar_image_id: external_exports.string().optional(),
4298
- bio: external_exports.string().optional(),
4299
- phone_number: external_exports.string().optional(),
4300
- twitter_handle: external_exports.string().optional(),
4301
- linkedin_url: external_exports.string().optional(),
4302
- description: external_exports.string().optional(),
4303
- preferences: identityServicePreferencesSchema.optional(),
4304
- roles: external_exports.array(external_exports.string()),
4305
- organization: identityServiceOrganizationSchema,
4306
- password: external_exports.string(),
4307
- verified: external_exports.boolean()
4308
- });
4309
-
4310
- // lib/whoami/models/RegisteredService.ts
4311
- var registeredServiceSchema = external_exports.object({
4312
- serviceId: external_exports.number(),
4313
- identityServiceId: external_exports.number(),
4314
- name: external_exports.string(),
4315
- isActive: external_exports.boolean()
4316
- });
4317
-
4318
- // lib/whoami/models/UserAccount.ts
4319
- var userAccountSchema = external_exports.object({
4320
- identityUser: identityServiceUserSchema,
4321
- companyId: external_exports.number(),
4322
- companyName: external_exports.string(),
4323
- name: external_exports.string(),
4324
- assortmentPartnerCompanyId: external_exports.number().nullish(),
4325
- retailer: external_exports.boolean(),
4326
- supplier: external_exports.boolean(),
4327
- registeredService: registeredServiceSchema,
4328
- uniqueAttributes: external_exports.array(external_exports.string()),
4329
- admin: external_exports.boolean(),
4330
- adminToolUser: external_exports.boolean(),
4331
- attributeRegistryAdmin: external_exports.boolean(),
4332
- attributeRegistryDev: external_exports.boolean(),
4333
- attributeRegistryRsx: external_exports.boolean(),
4334
- attributeRegistryUser: external_exports.boolean(),
4335
- attributeRegistryViewer: external_exports.boolean()
4336
- });
4337
-
4338
- // lib/items/v1/models/ItemHeader.ts
4339
- var itemHeaderSchema = external_exports.object({
4340
- status: external_exports.string().optional(),
4341
- catalogName: external_exports.string(),
4342
- productCodeName: external_exports.string(),
4343
- selectionCodeName: external_exports.string(),
4344
- gtin: external_exports.string(),
4345
- upc: external_exports.string(),
4346
- ean: external_exports.string(),
4347
- isbn: external_exports.string(),
4348
- partNumber: external_exports.string(),
4349
- lastUpdatedDateString: external_exports.string(),
4350
- companyId: external_exports.string(),
4351
- itemInfoId: external_exports.string()
4352
- });
4353
-
4354
- // lib/items/v1/models/PhaseEnum.ts
4355
- var phaseEnumSchema = external_exports.enum([
4356
- "CORE",
4357
- "CORE_PLUS",
4358
- "CORE_ADVANCED",
4359
- "ENRICHED",
4360
- "STANDARD_REQUIREMENTS"
4361
- ]);
4362
-
4363
- // lib/items/v1/models/TradingPartnerStage.ts
4364
- var tradingPartnerStageSchema = external_exports.object({
4365
- companyId: external_exports.number(),
4366
- companyName: external_exports.string(),
4367
- stage: external_exports.nullable(phaseEnumSchema),
4368
- isValid: external_exports.boolean()
4369
- });
4370
-
4371
- // lib/items/v1/models/ItemMap.ts
4372
- var itemMapSchema = external_exports.object({
4373
- rn: external_exports.number().optional(),
4374
- iteminfoid: external_exports.string(),
4375
- tradingPartnerStages: external_exports.array(tradingPartnerStageSchema).optional(),
4376
- gtin: external_exports.string().nullish(),
4377
- catalogname: external_exports.string().nullish(),
4378
- isbn: external_exports.string().nullish(),
4379
- lastupdateddatestring: external_exports.string().nullish(),
4380
- upc: external_exports.string().nullish(),
4381
- productcodename: external_exports.string().nullish(),
4382
- ean: external_exports.string().nullish(),
4383
- selectioncodename: external_exports.string().nullish(),
4384
- createddatestring: external_exports.string().nullish(),
4385
- partnumber: external_exports.string().nullish(),
4386
- consumeravailabledatestring: external_exports.string().nullish(),
4387
- status: external_exports.string().nullish(),
4388
- nrfcolorcode: external_exports.array(external_exports.string()).nullish(),
4389
- nrfsizecode: external_exports.array(external_exports.string()).nullish(),
4390
- productcolordescription: external_exports.array(external_exports.string()).nullish(),
4391
- productsizedescription: external_exports.array(external_exports.string()).nullish()
4392
- }).passthrough();
4393
-
4394
- // lib/items/v1/models/ItemTable.ts
4395
- var itemTableSchema = external_exports.object({
4396
- headers: itemHeaderSchema,
4397
- itemMaps: external_exports.array(itemMapSchema)
4398
- });
4399
-
4400
- // lib/items/v1/models/ItemSearchView.ts
4401
- var itemSearchViewSchema = external_exports.object({
4402
- itemTable: itemTableSchema,
4403
- hasNext: external_exports.boolean(),
4404
- count: external_exports.number()
4405
- });
4406
-
4407
- // lib/items/v1/models/AttrDatatypeNameEnum.ts
4408
- var attrDatatypeNameEnumSchema = external_exports.enum([
4409
- "TEXT",
4410
- "SET",
4411
- "INTEGER",
4412
- "FLOAT",
4413
- "BOOLEAN",
4414
- "DATE",
4415
- "KEYVALUE",
4416
- "REFERENCE",
4417
- // Not used anymore
4418
- "STRING",
4419
- "REAL"
4420
- ]);
4421
-
4422
- // lib/items/v1/models/AttributeDetail.ts
4423
- var attributeDetailSchema = external_exports.object({
4424
- type: attrDatatypeNameEnumSchema,
4425
- name: external_exports.string(),
4426
- value: external_exports.string().or(external_exports.number()).or(external_exports.array(external_exports.string())).or(external_exports.array(external_exports.number())).nullable(),
4427
- label: external_exports.string(),
4428
- group: external_exports.string(),
4429
- orderBy: external_exports.number().or(external_exports.string()).nullish()
4430
- });
4431
-
4432
- // lib/items/v1/models/CategoryEnum.ts
4433
- var categoryEnumSchema = external_exports.enum([
4434
- "ALIAS",
4435
- "CATALOG",
4436
- "EXPORT",
4437
- "LEGACY_PRODUCT_TYPE",
4438
- "PRODUCT_CLASSIFICATION",
4439
- "PRODUCT_CODE",
4440
- "SELECTION_CODE",
4441
- "TAG",
4442
- "TAXONOMY_ROOT"
4443
- ]);
4444
-
4445
- // lib/items/v1/models/ComponentDetails.ts
4446
- var componentDetailsSchema = external_exports.object({
4447
- itemInfoId: external_exports.number(),
4448
- description: external_exports.string().nullish(),
4449
- saleable: external_exports.boolean(),
4450
- valid: external_exports.boolean(),
4451
- uniqueCriteria: external_exports.array(
4452
- external_exports.object({
4453
- name: external_exports.string(),
4454
- value: external_exports.string()
4455
- })
4456
- )
4457
- });
4458
-
4459
- // lib/items/v1/models/RepeatableGroup.ts
4460
- var repeatableGroupSchema = external_exports.object({
4461
- repeatableGroupId: external_exports.string(),
4462
- repeatableNumber: external_exports.number()
4463
- });
4464
-
4465
- // lib/items/v1/models/GroupedAttributeList.ts
4466
- var groupedAttributeListSchema = external_exports.object({
4467
- type: external_exports.string(),
4468
- rows: external_exports.array(external_exports.array(attributeDetailSchema)),
4469
- repeatableGroups: external_exports.array(repeatableGroupSchema)
4470
- });
4471
-
4472
- // lib/items/v1/models/GroupedAttributes.ts
4473
- var groupedAttributesSchema = external_exports.object({
4474
- type: external_exports.string(),
4475
- attributes: external_exports.array(attributeDetailSchema),
4476
- attributeGroups: external_exports.array(groupedAttributeListSchema)
4477
- });
4478
-
4479
- // lib/items/v1/models/HierarchyCategory.ts
4480
- var hierarchyCategorySchema = external_exports.object({
4481
- name: external_exports.string(),
4482
- description: external_exports.string().nullish(),
4483
- id: external_exports.number(),
4484
- companyId: external_exports.number().nullish(),
4485
- type: categoryEnumSchema
4486
- });
4487
-
4488
- // lib/items/v1/models/HierarchyDetails.ts
4489
- var hierarchyDetailsSchema = external_exports.object({
4490
- catalogs: external_exports.array(hierarchyCategorySchema),
4491
- selectionCodes: external_exports.array(hierarchyCategorySchema),
4492
- productCodes: external_exports.array(hierarchyCategorySchema)
4493
- });
4494
-
4495
- // lib/items/v1/models/PackComponentItemInfo.ts
4496
- var packComponentItemInfoSchema = external_exports.object({
4497
- companyid: external_exports.number(),
4498
- createddate: external_exports.number(),
4499
- isServiceApi: external_exports.boolean(),
4500
- isactive: external_exports.number(),
4501
- isvalid: external_exports.number(),
4502
- itemType: external_exports.string(),
4503
- iteminfoid: external_exports.number(),
4504
- itemtimestamp: external_exports.number(),
4505
- serviceId: external_exports.number(),
4506
- attributes: external_exports.record(external_exports.string(), external_exports.string().or(external_exports.array(external_exports.string())))
4507
- });
4508
-
4509
- // lib/items/v1/models/ItemPrice.ts
4510
- var itemPriceSchema = external_exports.object({
4511
- amount: external_exports.number(),
4512
- currency: external_exports.string(),
4513
- id: external_exports.number().nullish(),
4514
- priceDivision: external_exports.string().nullish(),
4515
- iteminfoid: external_exports.number().nullish(),
4516
- startdate: external_exports.string().nullish(),
4517
- enddate: external_exports.string().nullish(),
4518
- qualifier: external_exports.string(),
4519
- region: external_exports.string().nullish(),
4520
- regionqualifier: external_exports.string().nullish(),
4521
- regiondescription: external_exports.string().nullish(),
4522
- partnercompanyid: external_exports.string().nullish(),
4523
- itempricetimestamp: external_exports.number().nullish(),
4524
- range_type: external_exports.string().nullish(),
4525
- date_range_type: external_exports.string().nullish(),
4526
- min_range: external_exports.number().nullish(),
4527
- gtin: external_exports.string().nullish(),
4528
- priceConditionDescription: external_exports.string().nullish(),
4529
- priceUnitQuantity: external_exports.number().nullish(),
4530
- priceUnitQuantityUOM: external_exports.string().nullish()
4531
- });
4532
-
4533
- // lib/items/v1/models/PackComponentDetails.ts
4534
- var packComponentDetailsSchema = external_exports.object({
4535
- itemInfo: packComponentItemInfoSchema,
4536
- itemPrices: external_exports.array(itemPriceSchema)
4537
- });
4538
-
4539
- // lib/items/v1/models/GroupedItem.ts
4540
- var groupedItemSchema = external_exports.object({
4541
- iteminfoid: external_exports.number(),
4542
- companyid: external_exports.number(),
4543
- status: external_exports.string(),
4544
- createdDate: external_exports.string(),
4545
- lastUpdatedDate: external_exports.string(),
4546
- identifiers: external_exports.record(external_exports.string(), external_exports.any()),
4547
- hierarchyDetails: hierarchyDetailsSchema,
4548
- groupedAttributes: external_exports.array(groupedAttributesSchema),
4549
- packComponentDetails: external_exports.array(packComponentDetailsSchema),
4550
- childComponentDetails: external_exports.array(componentDetailsSchema),
4551
- parentComponentDetails: external_exports.array(componentDetailsSchema),
4552
- locales: external_exports.array(external_exports.string())
4553
- });
4554
-
4555
- // lib/items/v1/models/ItemDetailView.ts
4556
- var itemDetailViewSchema = external_exports.object({
4557
- item: groupedItemSchema
4558
- });
4559
-
4560
- // lib/items/v1/models/Bulb.ts
4561
- var bulbSchema = external_exports.object({
4562
- iteminfoid: external_exports.number(),
4563
- id: external_exports.number(),
4564
- shape: external_exports.string(),
4565
- position: external_exports.number(),
4566
- quantity: external_exports.number(),
4567
- basetype: external_exports.string(),
4568
- maxwatt: external_exports.number(),
4569
- createdat: external_exports.string(),
4570
- modifiedat: external_exports.string(),
4571
- bulbtype: external_exports.string(),
4572
- bulbincluded: external_exports.string(),
4573
- bulbsize: external_exports.string(),
4574
- replacementbulb: external_exports.string(),
4575
- threewaybulb: external_exports.string()
4576
- });
4577
-
4578
- // lib/items/v1/models/PackComponent.ts
4579
- var packComponentSchema = external_exports.object({
4580
- itemInfoId: external_exports.number().nullish(),
4581
- attributes: external_exports.record(external_exports.string(), external_exports.string().or(external_exports.array(external_exports.string()))),
4582
- prices: external_exports.array(itemPriceSchema)
4583
- });
4584
-
4585
- // lib/items/v1/models/MediaItem.ts
4586
- var mediaItemSchema = external_exports.object({
4587
- id: external_exports.number(),
4588
- iteminfoid: external_exports.number(),
4589
- medianame: external_exports.string(),
4590
- height: external_exports.number().nullish(),
4591
- filename: external_exports.string(),
4592
- mediafilename: external_exports.string().nullish(),
4593
- description: external_exports.string().nullish(),
4594
- filesize: external_exports.number().nullish(),
4595
- format: external_exports.string().nullish(),
4596
- orientation: external_exports.string().nullish(),
4597
- pixeldensity: external_exports.string().nullish(),
4598
- purpose: external_exports.string().nullish(),
4599
- width: external_exports.number().nullish(),
4600
- mediatype: external_exports.string(),
4601
- mediaviewtype: external_exports.string().nullish(),
4602
- compressionquality: external_exports.string().nullish(),
4603
- thumbnailflag: external_exports.string().nullish()
4604
- });
4605
-
4606
- // lib/items/v1/models/ItemDetail.ts
4607
- var itemDetailSchema = external_exports.object({
4608
- attributes: external_exports.record(external_exports.string(), external_exports.any()),
4609
- clusters: external_exports.record(
4610
- external_exports.string(),
4611
- external_exports.array(
4612
- external_exports.object({
4613
- itemInfoAttributes: external_exports.record(
4614
- external_exports.string(),
4615
- external_exports.string().or(external_exports.number()).or(external_exports.boolean())
4616
- )
4617
- })
4618
- )
4619
- ),
4620
- prices: external_exports.array(itemPriceSchema),
4621
- bulbs: external_exports.array(bulbSchema),
4622
- media: external_exports.array(mediaItemSchema),
4623
- packs: external_exports.array(packComponentSchema)
4624
- });
4625
-
4626
- // lib/items/v1/models/SpsItemIdResponse.ts
4627
- var spsItemIdResponseSchema = external_exports.object({
4628
- id: external_exports.string(),
4629
- ref: external_exports.string()
4630
- });
4631
-
4632
- // lib/items/v1/models/ItemOrgStatus.ts
4633
- var itemOrgStatusSchema = external_exports.object({
4634
- org: external_exports.object({
4635
- ref: external_exports.string(),
4636
- id: external_exports.string(),
4637
- name: external_exports.string()
4638
- }),
4639
- lowestInvalidStage: phaseEnumSchema.nullable(),
4640
- validForRelationship: external_exports.boolean()
4641
- });
4642
-
4643
- // lib/items/v1/models/ItemStatus.ts
4644
- var itemStatusSchema = external_exports.object({
4645
- itemId: external_exports.string(),
4646
- itemOrgStatuses: external_exports.array(itemOrgStatusSchema)
4647
- });
4648
-
4649
- // lib/items/v1/models/ItemStatusResponse.ts
4650
- var itemStatusResponseSchema = external_exports.object({
4651
- itemStatuses: external_exports.array(itemStatusSchema)
4652
- });
4653
-
4654
- // lib/errors/v1/models/ItemErrorDetails.ts
4655
- var itemErrorDetailsSchema = external_exports.object({
4656
- errorMessage: external_exports.string(),
4657
- attributeName: external_exports.string().nullable(),
4658
- tradingPartnerNames: external_exports.array(external_exports.string()),
4659
- phases: external_exports.array(phaseEnumSchema),
4660
- attributeDbNames: external_exports.array(external_exports.string()),
4661
- tradingPartnerStages: external_exports.array(tradingPartnerStageSchema),
4662
- repeatableGroupId: external_exports.string().nullish()
4663
- });
4664
-
4665
- // lib/errors/v1/models/ItemErrorDetailsResult.ts
4666
- var itemErrorDetailsResultSchema = external_exports.object({
4667
- itemInfoId: external_exports.number(),
4668
- upc: external_exports.string().nullish(),
4669
- isbn: external_exports.string().nullish(),
4670
- gtin: external_exports.string().nullish(),
4671
- partnumber: external_exports.string().nullish(),
4672
- ean: external_exports.string().nullish(),
4673
- itemName: external_exports.string().nullable(),
4674
- itemErrorDetails: external_exports.array(itemErrorDetailsSchema)
4675
- });
4676
-
4677
- // lib/items/v2/models/Stage.ts
4678
- var stageSchema = external_exports.enum([
4679
- "CORE",
4680
- "CORE_PLUS",
4681
- "CORE_ADVANCED",
4682
- "ENRICHED"
4683
- ]);
4684
-
4685
- // lib/items/v2/models/OrgSummary.ts
4686
- var orgSummarySchema = external_exports.object({
4687
- ref: external_exports.string(),
4688
- id: external_exports.string(),
4689
- name: external_exports.string()
4690
- });
4691
-
4692
- // lib/items/v2/models/ItemOrgStageDetails.ts
4693
- var itemOrgStageDetailsSchema = external_exports.object({
4694
- /**
4695
- * When called as retailer, the vendor, else when vendor, the retailer.
4696
- * */
4697
- orgSummary: orgSummarySchema,
4698
- /**
4699
- * The company id of the retailer or vendor used for matching ItemOrgStageDetails to TradingPartnerStage for ErrorService
4700
- */
4701
- companyId: external_exports.number().nullish(),
4702
- /**
4703
- * "Standard Requirements" (null) UNLESS the retailer of the item is MSIS Enabled
4704
- * OTHERWISE the retailer default Stage UNLESS there's a currently active vendor-specific Stage defined
4705
- * OTHERWISE the trading partnership Stage UNLESS there's a currently active Item Level override defined
4706
- * OTHERWISE the item level override */
4707
- stage: stageSchema.nullish(),
4708
- /**
4709
- * If the item is valid for the active stage. Note that for "Standard Requirements" or
4710
- * "Enriched" this cam come directly from the item_doc table, but anything else requires validation
4711
- */
4712
- isValid: external_exports.boolean(),
4713
- /**
4714
- * Not null if there's an item level policy override for this trading partnership
4715
- */
4716
- itemPolicyId: external_exports.string().nullish(),
4717
- /**
4718
- * Start date for the Item level Stage if applicable
4719
- */
4720
- startDate: external_exports.number().transform((num) => new Date(num * 1e3)).nullish(),
4721
- /**
4722
- * End date for the Item level Stage if applicable
4723
- */
4724
- endDate: external_exports.number().transform((num) => new Date(num * 1e3)).nullish()
4725
- });
4726
-
4727
- // lib/items/v2/models/ItemStatusV2.ts
4728
- var itemStatusV2Schema = external_exports.object({
4729
- itemId: external_exports.string(),
4730
- mostRestrictiveRetailerStage: stageSchema.nullable(),
4731
- itemOrgStageDetails: external_exports.array(itemOrgStageDetailsSchema)
4732
- });
4733
-
4734
- // lib/items/v2/models/ItemStatusV2Response.ts
4735
- var itemStatusV2ResponseSchema = external_exports.object({
4736
- itemStatuses: external_exports.array(itemStatusV2Schema)
4737
- });
4738
-
4739
- // lib/errors/v2/models/TradingPartnerStage.ts
4740
- var tradingPartnerStageV2Schema = external_exports.object({
4741
- companyId: external_exports.number(),
4742
- companyName: external_exports.string(),
4743
- stage: stageSchema.nullish(),
4744
- isValid: external_exports.boolean()
4745
- });
4746
-
4747
- // lib/errors/v2/models/ItemErrorSummary.ts
4748
- var itemErrorSummaryV2Schema = external_exports.object({
4749
- itemInfoId: external_exports.number(),
4750
- upc: external_exports.string().nullish(),
4751
- isbn: external_exports.string().nullish(),
4752
- gtin: external_exports.string().nullish(),
4753
- ean: external_exports.string().nullish(),
4754
- partnumber: external_exports.string().nullish(),
4755
- colorfamily: external_exports.string().nullish(),
4756
- fit: external_exports.string().nullish(),
4757
- productcolordescription: external_exports.string().nullish(),
4758
- distributioncentercode: external_exports.string().nullish(),
4759
- accountnumber: external_exports.string().nullish(),
4760
- erpid: external_exports.string().nullish(),
4761
- totalErrors: external_exports.number(),
4762
- tradingPartners: external_exports.array(external_exports.string()),
4763
- tradingPartnerIds: external_exports.array(external_exports.number()),
4764
- // These are the stages assigned to the TradingPartners, not the stages of the errors
4765
- phases: external_exports.array(external_exports.string()),
4766
- // Same thing for the stage property in here: it's the stage of the Item & TradingPartner, not the stage of the error
4767
- tradingPartnerStages: external_exports.array(tradingPartnerStageV2Schema),
4768
- validatedDate: external_exports.number().pipe(external_exports.coerce.date()).nullish()
4769
- });
4770
-
4771
- // lib/errors/v2/models/ItemErrorSummaryResult.ts
4772
- var itemErrorSummaryResultV2Schema = external_exports.object({
4773
- hasNext: external_exports.boolean(),
4774
- errors: external_exports.array(itemErrorSummaryV2Schema)
4775
- });
4776
-
4777
- // lib/errors/v2/models/ItemErrorDetails.ts
4778
- var itemErrorDetailsV2Schema = external_exports.object({
4779
- errorMessage: external_exports.string(),
4780
- attributeName: external_exports.string().nullable(),
4781
- tradingPartnerNames: external_exports.array(external_exports.string()),
4782
- phases: external_exports.array(stageSchema),
4783
- attributeDbNames: external_exports.array(external_exports.string()),
4784
- tradingPartnerStages: external_exports.array(tradingPartnerStageV2Schema),
4785
- repeatableGroupId: external_exports.string().nullish()
4786
- });
4787
-
4788
- // lib/errors/v2/models/ItemErrorDetailsResult.ts
4789
- var itemErrorDetailsResultV2Schema = external_exports.object({
4790
- itemInfoId: external_exports.number(),
4791
- upc: external_exports.string().nullish(),
4792
- isbn: external_exports.string().nullish(),
4793
- gtin: external_exports.string().nullish(),
4794
- partnumber: external_exports.string().nullish(),
4795
- ean: external_exports.string().nullish(),
4796
- colorfamily: external_exports.string().nullish(),
4797
- fit: external_exports.string().nullish(),
4798
- productcolordescription: external_exports.string().nullish(),
4799
- distributioncentercode: external_exports.string().nullish(),
4800
- accountnumber: external_exports.string().nullish(),
4801
- erpid: external_exports.string().nullish(),
4802
- itemName: external_exports.string().nullish(),
4803
- itemErrorDetails: external_exports.array(itemErrorDetailsV2Schema)
4804
- });
4805
-
4806
- // lib/companies/models/CompanyBriefByOrg.ts
4807
- var companyBriefByOrgSchema = external_exports.object({
4808
- companyId: external_exports.number(),
4809
- name: external_exports.string(),
4810
- orgId: external_exports.string(),
4811
- companyType: external_exports.object({
4812
- type: external_exports.enum(["SUPPLIER", "RETAILER"]),
4813
- display: external_exports.enum(["SUPPLIER", "RETAILER"])
4814
- }),
4815
- dc4Id: external_exports.number()
4816
- });
4817
-
4818
- export {
4819
- external_exports,
4820
- importDetailSchema,
4821
- importSchema,
4822
- importErrorSchema,
4823
- importErrorsSchema,
4824
- importStatusEnumSchema,
4825
- importsStatusSchema,
4826
- vendorPartnerAttGroupsSchema,
4827
- generateImportTemplateParamsSchema,
4828
- attrProdTypeSchema,
4829
- pagedResultsSchema,
4830
- connectionSchema,
4831
- companyRelationshipUpsertBodySchema,
4832
- itemPartnerSchema,
4833
- tradingPartnerAccessByCompanyIdSchema,
4834
- itemCategorySchema,
4835
- itemCategoriesSearchSchema,
4836
- itemHierarchyResponseSchema,
4837
- localeSchema,
4838
- spreadsheetTemplateCompanySchema,
4839
- spreadsheetTemplateSchema,
4840
- identityServiceDatetimePreferencesSchema,
4841
- identityServiceOrganizationMetadataSchema,
4842
- identityServiceOrganizationSchema,
4843
- identityServicePreferencesSchema,
4844
- identityServiceUserSchema,
4845
- registeredServiceSchema,
4846
- userAccountSchema,
4847
- itemHeaderSchema,
4848
- phaseEnumSchema,
4849
- tradingPartnerStageSchema,
4850
- itemMapSchema,
4851
- itemTableSchema,
4852
- itemSearchViewSchema,
4853
- attributeDetailSchema,
4854
- categoryEnumSchema,
4855
- componentDetailsSchema,
4856
- repeatableGroupSchema,
4857
- groupedAttributeListSchema,
4858
- groupedAttributesSchema,
4859
- hierarchyCategorySchema,
4860
- hierarchyDetailsSchema,
4861
- packComponentItemInfoSchema,
4862
- itemPriceSchema,
4863
- packComponentDetailsSchema,
4864
- groupedItemSchema,
4865
- itemDetailViewSchema,
4866
- bulbSchema,
4867
- packComponentSchema,
4868
- mediaItemSchema,
4869
- itemDetailSchema,
4870
- spsItemIdResponseSchema,
4871
- itemStatusResponseSchema,
4872
- itemStatusV2ResponseSchema,
4873
- itemErrorDetailsSchema,
4874
- itemErrorDetailsResultSchema,
4875
- tradingPartnerStageV2Schema,
4876
- itemErrorSummaryV2Schema,
4877
- itemErrorSummaryResultV2Schema,
4878
- itemErrorDetailsV2Schema,
4879
- itemErrorDetailsResultV2Schema,
4880
- companyBriefByOrgSchema
4881
- };