@spscommerce/asst-api 4.2.2 → 4.2.3

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