@spscommerce/asst-api 0.0.1-beta.9 → 0.1.0

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