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