@jsdev_ninja/core 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/core.cjs.js +1 -1
  2. package/index.html +1 -1
  3. package/lib/entities/Order.ts +0 -2
  4. package/package.json +1 -1
  5. package/dist/core.cjs.js.map +0 -1
  6. package/dist/core.es.js +0 -3046
  7. package/dist/core.es.js.map +0 -1
  8. package/dist/core.umd.js +0 -2
  9. package/dist/core.umd.js.map +0 -1
  10. package/dist/entities/Address.d.ts +0 -28
  11. package/dist/entities/Address.d.ts.map +0 -1
  12. package/dist/entities/Address.js +0 -10
  13. package/dist/entities/Cart.d.ts +0 -715
  14. package/dist/entities/Cart.d.ts.map +0 -1
  15. package/dist/entities/Cart.js +0 -14
  16. package/dist/entities/Category.d.ts +0 -103
  17. package/dist/entities/Category.d.ts.map +0 -1
  18. package/dist/entities/Category.js +0 -20
  19. package/dist/entities/FavoriteProduct.d.ts +0 -25
  20. package/dist/entities/FavoriteProduct.d.ts.map +0 -1
  21. package/dist/entities/FavoriteProduct.js +0 -9
  22. package/dist/entities/Locale.d.ts +0 -12
  23. package/dist/entities/Locale.d.ts.map +0 -1
  24. package/dist/entities/Locale.js +0 -5
  25. package/dist/entities/Order.d.ts +0 -1121
  26. package/dist/entities/Order.d.ts.map +0 -1
  27. package/dist/entities/Order.js +0 -30
  28. package/dist/entities/Payment.d.ts +0 -30
  29. package/dist/entities/Payment.d.ts.map +0 -1
  30. package/dist/entities/Payment.js +0 -12
  31. package/dist/entities/Product.d.ts +0 -1000
  32. package/dist/entities/Product.d.ts.map +0 -1
  33. package/dist/entities/Product.js +0 -64
  34. package/dist/entities/Profile.d.ts +0 -102
  35. package/dist/entities/Profile.d.ts.map +0 -1
  36. package/dist/entities/Profile.js +0 -45
  37. package/dist/entities/Store.d.ts +0 -44
  38. package/dist/entities/Store.d.ts.map +0 -1
  39. package/dist/entities/Store.js +0 -15
  40. package/dist/entities/index.d.ts +0 -7
  41. package/dist/entities/index.d.ts.map +0 -1
  42. package/dist/entities/index.js +0 -6
  43. package/dist/firebase-api/index.d.ts +0 -2
  44. package/dist/firebase-api/index.d.ts.map +0 -1
  45. package/dist/firebase-api/index.js +0 -12
  46. package/dist/index.d.ts +0 -2
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/index.js +0 -1
  49. package/dist/tsconfig.app.tsbuildinfo +0 -1
  50. package/dist/tsconfig.node.tsbuildinfo +0 -1
  51. package/dist/vite.config.d.ts +0 -3
  52. package/dist/vite.config.d.ts.map +0 -1
  53. package/dist/vite.config.js +0 -25
package/dist/core.es.js DELETED
@@ -1,3046 +0,0 @@
1
- var x;
2
- (function(r) {
3
- r.assertEqual = (s) => s;
4
- function e(s) {
5
- }
6
- r.assertIs = e;
7
- function t(s) {
8
- throw new Error();
9
- }
10
- r.assertNever = t, r.arrayToEnum = (s) => {
11
- const a = {};
12
- for (const i of s)
13
- a[i] = i;
14
- return a;
15
- }, r.getValidEnumValues = (s) => {
16
- const a = r.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
17
- for (const o of a)
18
- i[o] = s[o];
19
- return r.objectValues(i);
20
- }, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
21
- return s[a];
22
- }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
23
- const a = [];
24
- for (const i in s)
25
- Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
26
- return a;
27
- }, r.find = (s, a) => {
28
- for (const i of s)
29
- if (a(i))
30
- return i;
31
- }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
32
- function n(s, a = " | ") {
33
- return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
34
- }
35
- r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
36
- })(x || (x = {}));
37
- var Te;
38
- (function(r) {
39
- r.mergeShapes = (e, t) => ({
40
- ...e,
41
- ...t
42
- // second overwrites first
43
- });
44
- })(Te || (Te = {}));
45
- const h = x.arrayToEnum([
46
- "string",
47
- "nan",
48
- "number",
49
- "integer",
50
- "float",
51
- "boolean",
52
- "date",
53
- "bigint",
54
- "symbol",
55
- "function",
56
- "undefined",
57
- "null",
58
- "array",
59
- "object",
60
- "unknown",
61
- "promise",
62
- "void",
63
- "never",
64
- "map",
65
- "set"
66
- ]), A = (r) => {
67
- switch (typeof r) {
68
- case "undefined":
69
- return h.undefined;
70
- case "string":
71
- return h.string;
72
- case "number":
73
- return isNaN(r) ? h.nan : h.number;
74
- case "boolean":
75
- return h.boolean;
76
- case "function":
77
- return h.function;
78
- case "bigint":
79
- return h.bigint;
80
- case "symbol":
81
- return h.symbol;
82
- case "object":
83
- return Array.isArray(r) ? h.array : r === null ? h.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? h.promise : typeof Map < "u" && r instanceof Map ? h.map : typeof Set < "u" && r instanceof Set ? h.set : typeof Date < "u" && r instanceof Date ? h.date : h.object;
84
- default:
85
- return h.unknown;
86
- }
87
- }, c = x.arrayToEnum([
88
- "invalid_type",
89
- "invalid_literal",
90
- "custom",
91
- "invalid_union",
92
- "invalid_union_discriminator",
93
- "invalid_enum_value",
94
- "unrecognized_keys",
95
- "invalid_arguments",
96
- "invalid_return_type",
97
- "invalid_date",
98
- "invalid_string",
99
- "too_small",
100
- "too_big",
101
- "invalid_intersection_types",
102
- "not_multiple_of",
103
- "not_finite"
104
- ]), qe = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
105
- class T extends Error {
106
- constructor(e) {
107
- super(), this.issues = [], this.addIssue = (n) => {
108
- this.issues = [...this.issues, n];
109
- }, this.addIssues = (n = []) => {
110
- this.issues = [...this.issues, ...n];
111
- };
112
- const t = new.target.prototype;
113
- Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
114
- }
115
- get errors() {
116
- return this.issues;
117
- }
118
- format(e) {
119
- const t = e || function(a) {
120
- return a.message;
121
- }, n = { _errors: [] }, s = (a) => {
122
- for (const i of a.issues)
123
- if (i.code === "invalid_union")
124
- i.unionErrors.map(s);
125
- else if (i.code === "invalid_return_type")
126
- s(i.returnTypeError);
127
- else if (i.code === "invalid_arguments")
128
- s(i.argumentsError);
129
- else if (i.path.length === 0)
130
- n._errors.push(t(i));
131
- else {
132
- let o = n, f = 0;
133
- for (; f < i.path.length; ) {
134
- const u = i.path[f];
135
- f === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], f++;
136
- }
137
- }
138
- };
139
- return s(this), n;
140
- }
141
- static assert(e) {
142
- if (!(e instanceof T))
143
- throw new Error(`Not a ZodError: ${e}`);
144
- }
145
- toString() {
146
- return this.message;
147
- }
148
- get message() {
149
- return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
150
- }
151
- get isEmpty() {
152
- return this.issues.length === 0;
153
- }
154
- flatten(e = (t) => t.message) {
155
- const t = {}, n = [];
156
- for (const s of this.issues)
157
- s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : n.push(e(s));
158
- return { formErrors: n, fieldErrors: t };
159
- }
160
- get formErrors() {
161
- return this.flatten();
162
- }
163
- }
164
- T.create = (r) => new T(r);
165
- const q = (r, e) => {
166
- let t;
167
- switch (r.code) {
168
- case c.invalid_type:
169
- r.received === h.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
170
- break;
171
- case c.invalid_literal:
172
- t = `Invalid literal value, expected ${JSON.stringify(r.expected, x.jsonStringifyReplacer)}`;
173
- break;
174
- case c.unrecognized_keys:
175
- t = `Unrecognized key(s) in object: ${x.joinValues(r.keys, ", ")}`;
176
- break;
177
- case c.invalid_union:
178
- t = "Invalid input";
179
- break;
180
- case c.invalid_union_discriminator:
181
- t = `Invalid discriminator value. Expected ${x.joinValues(r.options)}`;
182
- break;
183
- case c.invalid_enum_value:
184
- t = `Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;
185
- break;
186
- case c.invalid_arguments:
187
- t = "Invalid function arguments";
188
- break;
189
- case c.invalid_return_type:
190
- t = "Invalid function return type";
191
- break;
192
- case c.invalid_date:
193
- t = "Invalid date";
194
- break;
195
- case c.invalid_string:
196
- typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : x.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
197
- break;
198
- case c.too_small:
199
- r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
200
- break;
201
- case c.too_big:
202
- r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
203
- break;
204
- case c.custom:
205
- t = "Invalid input";
206
- break;
207
- case c.invalid_intersection_types:
208
- t = "Intersection results could not be merged";
209
- break;
210
- case c.not_multiple_of:
211
- t = `Number must be a multiple of ${r.multipleOf}`;
212
- break;
213
- case c.not_finite:
214
- t = "Number must be finite";
215
- break;
216
- default:
217
- t = e.defaultError, x.assertNever(r);
218
- }
219
- return { message: t };
220
- };
221
- let Re = q;
222
- function Ye(r) {
223
- Re = r;
224
- }
225
- function fe() {
226
- return Re;
227
- }
228
- const he = (r) => {
229
- const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
230
- ...s,
231
- path: a
232
- };
233
- if (s.message !== void 0)
234
- return {
235
- ...s,
236
- path: a,
237
- message: s.message
238
- };
239
- let o = "";
240
- const f = n.filter((u) => !!u).slice().reverse();
241
- for (const u of f)
242
- o = u(i, { data: e, defaultError: o }).message;
243
- return {
244
- ...s,
245
- path: a,
246
- message: o
247
- };
248
- }, Je = [];
249
- function l(r, e) {
250
- const t = fe(), n = he({
251
- issueData: e,
252
- data: r.data,
253
- path: r.path,
254
- errorMaps: [
255
- r.common.contextualErrorMap,
256
- r.schemaErrorMap,
257
- t,
258
- t === q ? void 0 : q
259
- // then global default map
260
- ].filter((s) => !!s)
261
- });
262
- r.common.issues.push(n);
263
- }
264
- class k {
265
- constructor() {
266
- this.value = "valid";
267
- }
268
- dirty() {
269
- this.value === "valid" && (this.value = "dirty");
270
- }
271
- abort() {
272
- this.value !== "aborted" && (this.value = "aborted");
273
- }
274
- static mergeArray(e, t) {
275
- const n = [];
276
- for (const s of t) {
277
- if (s.status === "aborted")
278
- return y;
279
- s.status === "dirty" && e.dirty(), n.push(s.value);
280
- }
281
- return { status: e.value, value: n };
282
- }
283
- static async mergeObjectAsync(e, t) {
284
- const n = [];
285
- for (const s of t) {
286
- const a = await s.key, i = await s.value;
287
- n.push({
288
- key: a,
289
- value: i
290
- });
291
- }
292
- return k.mergeObjectSync(e, n);
293
- }
294
- static mergeObjectSync(e, t) {
295
- const n = {};
296
- for (const s of t) {
297
- const { key: a, value: i } = s;
298
- if (a.status === "aborted" || i.status === "aborted")
299
- return y;
300
- a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (n[a.value] = i.value);
301
- }
302
- return { status: e.value, value: n };
303
- }
304
- }
305
- const y = Object.freeze({
306
- status: "aborted"
307
- }), B = (r) => ({ status: "dirty", value: r }), w = (r) => ({ status: "valid", value: r }), Ze = (r) => r.status === "aborted", Se = (r) => r.status === "dirty", Q = (r) => r.status === "valid", X = (r) => typeof Promise < "u" && r instanceof Promise;
308
- function me(r, e, t, n) {
309
- if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
310
- return e.get(r);
311
- }
312
- function Ae(r, e, t, n, s) {
313
- if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
314
- return e.set(r, t), t;
315
- }
316
- var m;
317
- (function(r) {
318
- r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
319
- })(m || (m = {}));
320
- var H, G;
321
- class I {
322
- constructor(e, t, n, s) {
323
- this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
324
- }
325
- get path() {
326
- return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
327
- }
328
- }
329
- const Oe = (r, e) => {
330
- if (Q(e))
331
- return { success: !0, data: e.value };
332
- if (!r.common.issues.length)
333
- throw new Error("Validation failed but no issues detected.");
334
- return {
335
- success: !1,
336
- get error() {
337
- if (this._error)
338
- return this._error;
339
- const t = new T(r.common.issues);
340
- return this._error = t, this._error;
341
- }
342
- };
343
- };
344
- function v(r) {
345
- if (!r)
346
- return {};
347
- const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
348
- if (e && (t || n))
349
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
350
- return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
351
- var f, u;
352
- const { message: g } = r;
353
- return i.code === "invalid_enum_value" ? { message: g ?? o.defaultError } : typeof o.data > "u" ? { message: (f = g ?? n) !== null && f !== void 0 ? f : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = g ?? t) !== null && u !== void 0 ? u : o.defaultError };
354
- }, description: s };
355
- }
356
- class _ {
357
- constructor(e) {
358
- this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
359
- }
360
- get description() {
361
- return this._def.description;
362
- }
363
- _getType(e) {
364
- return A(e.data);
365
- }
366
- _getOrReturnCtx(e, t) {
367
- return t || {
368
- common: e.parent.common,
369
- data: e.data,
370
- parsedType: A(e.data),
371
- schemaErrorMap: this._def.errorMap,
372
- path: e.path,
373
- parent: e.parent
374
- };
375
- }
376
- _processInputParams(e) {
377
- return {
378
- status: new k(),
379
- ctx: {
380
- common: e.parent.common,
381
- data: e.data,
382
- parsedType: A(e.data),
383
- schemaErrorMap: this._def.errorMap,
384
- path: e.path,
385
- parent: e.parent
386
- }
387
- };
388
- }
389
- _parseSync(e) {
390
- const t = this._parse(e);
391
- if (X(t))
392
- throw new Error("Synchronous parse encountered promise.");
393
- return t;
394
- }
395
- _parseAsync(e) {
396
- const t = this._parse(e);
397
- return Promise.resolve(t);
398
- }
399
- parse(e, t) {
400
- const n = this.safeParse(e, t);
401
- if (n.success)
402
- return n.data;
403
- throw n.error;
404
- }
405
- safeParse(e, t) {
406
- var n;
407
- const s = {
408
- common: {
409
- issues: [],
410
- async: (n = t == null ? void 0 : t.async) !== null && n !== void 0 ? n : !1,
411
- contextualErrorMap: t == null ? void 0 : t.errorMap
412
- },
413
- path: (t == null ? void 0 : t.path) || [],
414
- schemaErrorMap: this._def.errorMap,
415
- parent: null,
416
- data: e,
417
- parsedType: A(e)
418
- }, a = this._parseSync({ data: e, path: s.path, parent: s });
419
- return Oe(s, a);
420
- }
421
- async parseAsync(e, t) {
422
- const n = await this.safeParseAsync(e, t);
423
- if (n.success)
424
- return n.data;
425
- throw n.error;
426
- }
427
- async safeParseAsync(e, t) {
428
- const n = {
429
- common: {
430
- issues: [],
431
- contextualErrorMap: t == null ? void 0 : t.errorMap,
432
- async: !0
433
- },
434
- path: (t == null ? void 0 : t.path) || [],
435
- schemaErrorMap: this._def.errorMap,
436
- parent: null,
437
- data: e,
438
- parsedType: A(e)
439
- }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (X(s) ? s : Promise.resolve(s));
440
- return Oe(n, a);
441
- }
442
- refine(e, t) {
443
- const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
444
- return this._refinement((s, a) => {
445
- const i = e(s), o = () => a.addIssue({
446
- code: c.custom,
447
- ...n(s)
448
- });
449
- return typeof Promise < "u" && i instanceof Promise ? i.then((f) => f ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
450
- });
451
- }
452
- refinement(e, t) {
453
- return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
454
- }
455
- _refinement(e) {
456
- return new C({
457
- schema: this,
458
- typeName: p.ZodEffects,
459
- effect: { type: "refinement", refinement: e }
460
- });
461
- }
462
- superRefine(e) {
463
- return this._refinement(e);
464
- }
465
- optional() {
466
- return E.create(this, this._def);
467
- }
468
- nullable() {
469
- return V.create(this, this._def);
470
- }
471
- nullish() {
472
- return this.nullable().optional();
473
- }
474
- array() {
475
- return N.create(this, this._def);
476
- }
477
- promise() {
478
- return J.create(this, this._def);
479
- }
480
- or(e) {
481
- return te.create([this, e], this._def);
482
- }
483
- and(e) {
484
- return re.create(this, e, this._def);
485
- }
486
- transform(e) {
487
- return new C({
488
- ...v(this._def),
489
- schema: this,
490
- typeName: p.ZodEffects,
491
- effect: { type: "transform", transform: e }
492
- });
493
- }
494
- default(e) {
495
- const t = typeof e == "function" ? e : () => e;
496
- return new oe({
497
- ...v(this._def),
498
- innerType: this,
499
- defaultValue: t,
500
- typeName: p.ZodDefault
501
- });
502
- }
503
- brand() {
504
- return new Ce({
505
- typeName: p.ZodBranded,
506
- type: this,
507
- ...v(this._def)
508
- });
509
- }
510
- catch(e) {
511
- const t = typeof e == "function" ? e : () => e;
512
- return new de({
513
- ...v(this._def),
514
- innerType: this,
515
- catchValue: t,
516
- typeName: p.ZodCatch
517
- });
518
- }
519
- describe(e) {
520
- const t = this.constructor;
521
- return new t({
522
- ...this._def,
523
- description: e
524
- });
525
- }
526
- pipe(e) {
527
- return ue.create(this, e);
528
- }
529
- readonly() {
530
- return ce.create(this);
531
- }
532
- isOptional() {
533
- return this.safeParse(void 0).success;
534
- }
535
- isNullable() {
536
- return this.safeParse(null).success;
537
- }
538
- }
539
- const He = /^c[^\s-]{8,}$/i, Ge = /^[0-9a-z]+$/, Qe = /^[0-9A-HJKMNP-TV-Z]{26}$/, Xe = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Ke = /^[a-z0-9_-]{21}$/i, Fe = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, et = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, tt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
540
- let ke;
541
- const rt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, nt = /^(([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})))$/, st = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Pe = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", at = new RegExp(`^${Pe}$`);
542
- function Me(r) {
543
- let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
544
- return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
545
- }
546
- function it(r) {
547
- return new RegExp(`^${Me(r)}$`);
548
- }
549
- function $e(r) {
550
- let e = `${Pe}T${Me(r)}`;
551
- const t = [];
552
- return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
553
- }
554
- function ot(r, e) {
555
- return !!((e === "v4" || !e) && rt.test(r) || (e === "v6" || !e) && nt.test(r));
556
- }
557
- class S extends _ {
558
- _parse(e) {
559
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
560
- const a = this._getOrReturnCtx(e);
561
- return l(a, {
562
- code: c.invalid_type,
563
- expected: h.string,
564
- received: a.parsedType
565
- }), y;
566
- }
567
- const n = new k();
568
- let s;
569
- for (const a of this._def.checks)
570
- if (a.kind === "min")
571
- e.data.length < a.value && (s = this._getOrReturnCtx(e, s), l(s, {
572
- code: c.too_small,
573
- minimum: a.value,
574
- type: "string",
575
- inclusive: !0,
576
- exact: !1,
577
- message: a.message
578
- }), n.dirty());
579
- else if (a.kind === "max")
580
- e.data.length > a.value && (s = this._getOrReturnCtx(e, s), l(s, {
581
- code: c.too_big,
582
- maximum: a.value,
583
- type: "string",
584
- inclusive: !0,
585
- exact: !1,
586
- message: a.message
587
- }), n.dirty());
588
- else if (a.kind === "length") {
589
- const i = e.data.length > a.value, o = e.data.length < a.value;
590
- (i || o) && (s = this._getOrReturnCtx(e, s), i ? l(s, {
591
- code: c.too_big,
592
- maximum: a.value,
593
- type: "string",
594
- inclusive: !0,
595
- exact: !0,
596
- message: a.message
597
- }) : o && l(s, {
598
- code: c.too_small,
599
- minimum: a.value,
600
- type: "string",
601
- inclusive: !0,
602
- exact: !0,
603
- message: a.message
604
- }), n.dirty());
605
- } else if (a.kind === "email")
606
- et.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
607
- validation: "email",
608
- code: c.invalid_string,
609
- message: a.message
610
- }), n.dirty());
611
- else if (a.kind === "emoji")
612
- ke || (ke = new RegExp(tt, "u")), ke.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
613
- validation: "emoji",
614
- code: c.invalid_string,
615
- message: a.message
616
- }), n.dirty());
617
- else if (a.kind === "uuid")
618
- Xe.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
619
- validation: "uuid",
620
- code: c.invalid_string,
621
- message: a.message
622
- }), n.dirty());
623
- else if (a.kind === "nanoid")
624
- Ke.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
625
- validation: "nanoid",
626
- code: c.invalid_string,
627
- message: a.message
628
- }), n.dirty());
629
- else if (a.kind === "cuid")
630
- He.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
631
- validation: "cuid",
632
- code: c.invalid_string,
633
- message: a.message
634
- }), n.dirty());
635
- else if (a.kind === "cuid2")
636
- Ge.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
637
- validation: "cuid2",
638
- code: c.invalid_string,
639
- message: a.message
640
- }), n.dirty());
641
- else if (a.kind === "ulid")
642
- Qe.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
643
- validation: "ulid",
644
- code: c.invalid_string,
645
- message: a.message
646
- }), n.dirty());
647
- else if (a.kind === "url")
648
- try {
649
- new URL(e.data);
650
- } catch {
651
- s = this._getOrReturnCtx(e, s), l(s, {
652
- validation: "url",
653
- code: c.invalid_string,
654
- message: a.message
655
- }), n.dirty();
656
- }
657
- else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
658
- validation: "regex",
659
- code: c.invalid_string,
660
- message: a.message
661
- }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), l(s, {
662
- code: c.invalid_string,
663
- validation: { includes: a.value, position: a.position },
664
- message: a.message
665
- }), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), l(s, {
666
- code: c.invalid_string,
667
- validation: { startsWith: a.value },
668
- message: a.message
669
- }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), l(s, {
670
- code: c.invalid_string,
671
- validation: { endsWith: a.value },
672
- message: a.message
673
- }), n.dirty()) : a.kind === "datetime" ? $e(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
674
- code: c.invalid_string,
675
- validation: "datetime",
676
- message: a.message
677
- }), n.dirty()) : a.kind === "date" ? at.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
678
- code: c.invalid_string,
679
- validation: "date",
680
- message: a.message
681
- }), n.dirty()) : a.kind === "time" ? it(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
682
- code: c.invalid_string,
683
- validation: "time",
684
- message: a.message
685
- }), n.dirty()) : a.kind === "duration" ? Fe.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
686
- validation: "duration",
687
- code: c.invalid_string,
688
- message: a.message
689
- }), n.dirty()) : a.kind === "ip" ? ot(e.data, a.version) || (s = this._getOrReturnCtx(e, s), l(s, {
690
- validation: "ip",
691
- code: c.invalid_string,
692
- message: a.message
693
- }), n.dirty()) : a.kind === "base64" ? st.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
694
- validation: "base64",
695
- code: c.invalid_string,
696
- message: a.message
697
- }), n.dirty()) : x.assertNever(a);
698
- return { status: n.value, value: e.data };
699
- }
700
- _regex(e, t, n) {
701
- return this.refinement((s) => e.test(s), {
702
- validation: t,
703
- code: c.invalid_string,
704
- ...m.errToObj(n)
705
- });
706
- }
707
- _addCheck(e) {
708
- return new S({
709
- ...this._def,
710
- checks: [...this._def.checks, e]
711
- });
712
- }
713
- email(e) {
714
- return this._addCheck({ kind: "email", ...m.errToObj(e) });
715
- }
716
- url(e) {
717
- return this._addCheck({ kind: "url", ...m.errToObj(e) });
718
- }
719
- emoji(e) {
720
- return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
721
- }
722
- uuid(e) {
723
- return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
724
- }
725
- nanoid(e) {
726
- return this._addCheck({ kind: "nanoid", ...m.errToObj(e) });
727
- }
728
- cuid(e) {
729
- return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
730
- }
731
- cuid2(e) {
732
- return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
733
- }
734
- ulid(e) {
735
- return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
736
- }
737
- base64(e) {
738
- return this._addCheck({ kind: "base64", ...m.errToObj(e) });
739
- }
740
- ip(e) {
741
- return this._addCheck({ kind: "ip", ...m.errToObj(e) });
742
- }
743
- datetime(e) {
744
- var t, n;
745
- return typeof e == "string" ? this._addCheck({
746
- kind: "datetime",
747
- precision: null,
748
- offset: !1,
749
- local: !1,
750
- message: e
751
- }) : this._addCheck({
752
- kind: "datetime",
753
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
754
- offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
755
- local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
756
- ...m.errToObj(e == null ? void 0 : e.message)
757
- });
758
- }
759
- date(e) {
760
- return this._addCheck({ kind: "date", message: e });
761
- }
762
- time(e) {
763
- return typeof e == "string" ? this._addCheck({
764
- kind: "time",
765
- precision: null,
766
- message: e
767
- }) : this._addCheck({
768
- kind: "time",
769
- precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
770
- ...m.errToObj(e == null ? void 0 : e.message)
771
- });
772
- }
773
- duration(e) {
774
- return this._addCheck({ kind: "duration", ...m.errToObj(e) });
775
- }
776
- regex(e, t) {
777
- return this._addCheck({
778
- kind: "regex",
779
- regex: e,
780
- ...m.errToObj(t)
781
- });
782
- }
783
- includes(e, t) {
784
- return this._addCheck({
785
- kind: "includes",
786
- value: e,
787
- position: t == null ? void 0 : t.position,
788
- ...m.errToObj(t == null ? void 0 : t.message)
789
- });
790
- }
791
- startsWith(e, t) {
792
- return this._addCheck({
793
- kind: "startsWith",
794
- value: e,
795
- ...m.errToObj(t)
796
- });
797
- }
798
- endsWith(e, t) {
799
- return this._addCheck({
800
- kind: "endsWith",
801
- value: e,
802
- ...m.errToObj(t)
803
- });
804
- }
805
- min(e, t) {
806
- return this._addCheck({
807
- kind: "min",
808
- value: e,
809
- ...m.errToObj(t)
810
- });
811
- }
812
- max(e, t) {
813
- return this._addCheck({
814
- kind: "max",
815
- value: e,
816
- ...m.errToObj(t)
817
- });
818
- }
819
- length(e, t) {
820
- return this._addCheck({
821
- kind: "length",
822
- value: e,
823
- ...m.errToObj(t)
824
- });
825
- }
826
- /**
827
- * @deprecated Use z.string().min(1) instead.
828
- * @see {@link ZodString.min}
829
- */
830
- nonempty(e) {
831
- return this.min(1, m.errToObj(e));
832
- }
833
- trim() {
834
- return new S({
835
- ...this._def,
836
- checks: [...this._def.checks, { kind: "trim" }]
837
- });
838
- }
839
- toLowerCase() {
840
- return new S({
841
- ...this._def,
842
- checks: [...this._def.checks, { kind: "toLowerCase" }]
843
- });
844
- }
845
- toUpperCase() {
846
- return new S({
847
- ...this._def,
848
- checks: [...this._def.checks, { kind: "toUpperCase" }]
849
- });
850
- }
851
- get isDatetime() {
852
- return !!this._def.checks.find((e) => e.kind === "datetime");
853
- }
854
- get isDate() {
855
- return !!this._def.checks.find((e) => e.kind === "date");
856
- }
857
- get isTime() {
858
- return !!this._def.checks.find((e) => e.kind === "time");
859
- }
860
- get isDuration() {
861
- return !!this._def.checks.find((e) => e.kind === "duration");
862
- }
863
- get isEmail() {
864
- return !!this._def.checks.find((e) => e.kind === "email");
865
- }
866
- get isURL() {
867
- return !!this._def.checks.find((e) => e.kind === "url");
868
- }
869
- get isEmoji() {
870
- return !!this._def.checks.find((e) => e.kind === "emoji");
871
- }
872
- get isUUID() {
873
- return !!this._def.checks.find((e) => e.kind === "uuid");
874
- }
875
- get isNANOID() {
876
- return !!this._def.checks.find((e) => e.kind === "nanoid");
877
- }
878
- get isCUID() {
879
- return !!this._def.checks.find((e) => e.kind === "cuid");
880
- }
881
- get isCUID2() {
882
- return !!this._def.checks.find((e) => e.kind === "cuid2");
883
- }
884
- get isULID() {
885
- return !!this._def.checks.find((e) => e.kind === "ulid");
886
- }
887
- get isIP() {
888
- return !!this._def.checks.find((e) => e.kind === "ip");
889
- }
890
- get isBase64() {
891
- return !!this._def.checks.find((e) => e.kind === "base64");
892
- }
893
- get minLength() {
894
- let e = null;
895
- for (const t of this._def.checks)
896
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
897
- return e;
898
- }
899
- get maxLength() {
900
- let e = null;
901
- for (const t of this._def.checks)
902
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
903
- return e;
904
- }
905
- }
906
- S.create = (r) => {
907
- var e;
908
- return new S({
909
- checks: [],
910
- typeName: p.ZodString,
911
- coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
912
- ...v(r)
913
- });
914
- };
915
- function dt(r, e) {
916
- const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
917
- return a % i / Math.pow(10, s);
918
- }
919
- class P extends _ {
920
- constructor() {
921
- super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
922
- }
923
- _parse(e) {
924
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
925
- const a = this._getOrReturnCtx(e);
926
- return l(a, {
927
- code: c.invalid_type,
928
- expected: h.number,
929
- received: a.parsedType
930
- }), y;
931
- }
932
- let n;
933
- const s = new k();
934
- for (const a of this._def.checks)
935
- a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
936
- code: c.invalid_type,
937
- expected: "integer",
938
- received: "float",
939
- message: a.message
940
- }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
941
- code: c.too_small,
942
- minimum: a.value,
943
- type: "number",
944
- inclusive: a.inclusive,
945
- exact: !1,
946
- message: a.message
947
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
948
- code: c.too_big,
949
- maximum: a.value,
950
- type: "number",
951
- inclusive: a.inclusive,
952
- exact: !1,
953
- message: a.message
954
- }), s.dirty()) : a.kind === "multipleOf" ? dt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
955
- code: c.not_multiple_of,
956
- multipleOf: a.value,
957
- message: a.message
958
- }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
959
- code: c.not_finite,
960
- message: a.message
961
- }), s.dirty()) : x.assertNever(a);
962
- return { status: s.value, value: e.data };
963
- }
964
- gte(e, t) {
965
- return this.setLimit("min", e, !0, m.toString(t));
966
- }
967
- gt(e, t) {
968
- return this.setLimit("min", e, !1, m.toString(t));
969
- }
970
- lte(e, t) {
971
- return this.setLimit("max", e, !0, m.toString(t));
972
- }
973
- lt(e, t) {
974
- return this.setLimit("max", e, !1, m.toString(t));
975
- }
976
- setLimit(e, t, n, s) {
977
- return new P({
978
- ...this._def,
979
- checks: [
980
- ...this._def.checks,
981
- {
982
- kind: e,
983
- value: t,
984
- inclusive: n,
985
- message: m.toString(s)
986
- }
987
- ]
988
- });
989
- }
990
- _addCheck(e) {
991
- return new P({
992
- ...this._def,
993
- checks: [...this._def.checks, e]
994
- });
995
- }
996
- int(e) {
997
- return this._addCheck({
998
- kind: "int",
999
- message: m.toString(e)
1000
- });
1001
- }
1002
- positive(e) {
1003
- return this._addCheck({
1004
- kind: "min",
1005
- value: 0,
1006
- inclusive: !1,
1007
- message: m.toString(e)
1008
- });
1009
- }
1010
- negative(e) {
1011
- return this._addCheck({
1012
- kind: "max",
1013
- value: 0,
1014
- inclusive: !1,
1015
- message: m.toString(e)
1016
- });
1017
- }
1018
- nonpositive(e) {
1019
- return this._addCheck({
1020
- kind: "max",
1021
- value: 0,
1022
- inclusive: !0,
1023
- message: m.toString(e)
1024
- });
1025
- }
1026
- nonnegative(e) {
1027
- return this._addCheck({
1028
- kind: "min",
1029
- value: 0,
1030
- inclusive: !0,
1031
- message: m.toString(e)
1032
- });
1033
- }
1034
- multipleOf(e, t) {
1035
- return this._addCheck({
1036
- kind: "multipleOf",
1037
- value: e,
1038
- message: m.toString(t)
1039
- });
1040
- }
1041
- finite(e) {
1042
- return this._addCheck({
1043
- kind: "finite",
1044
- message: m.toString(e)
1045
- });
1046
- }
1047
- safe(e) {
1048
- return this._addCheck({
1049
- kind: "min",
1050
- inclusive: !0,
1051
- value: Number.MIN_SAFE_INTEGER,
1052
- message: m.toString(e)
1053
- })._addCheck({
1054
- kind: "max",
1055
- inclusive: !0,
1056
- value: Number.MAX_SAFE_INTEGER,
1057
- message: m.toString(e)
1058
- });
1059
- }
1060
- get minValue() {
1061
- let e = null;
1062
- for (const t of this._def.checks)
1063
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1064
- return e;
1065
- }
1066
- get maxValue() {
1067
- let e = null;
1068
- for (const t of this._def.checks)
1069
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1070
- return e;
1071
- }
1072
- get isInt() {
1073
- return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1074
- }
1075
- get isFinite() {
1076
- let e = null, t = null;
1077
- for (const n of this._def.checks) {
1078
- if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
1079
- return !0;
1080
- n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
1081
- }
1082
- return Number.isFinite(t) && Number.isFinite(e);
1083
- }
1084
- }
1085
- P.create = (r) => new P({
1086
- checks: [],
1087
- typeName: p.ZodNumber,
1088
- coerce: (r == null ? void 0 : r.coerce) || !1,
1089
- ...v(r)
1090
- });
1091
- class M extends _ {
1092
- constructor() {
1093
- super(...arguments), this.min = this.gte, this.max = this.lte;
1094
- }
1095
- _parse(e) {
1096
- if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== h.bigint) {
1097
- const a = this._getOrReturnCtx(e);
1098
- return l(a, {
1099
- code: c.invalid_type,
1100
- expected: h.bigint,
1101
- received: a.parsedType
1102
- }), y;
1103
- }
1104
- let n;
1105
- const s = new k();
1106
- for (const a of this._def.checks)
1107
- a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1108
- code: c.too_small,
1109
- type: "bigint",
1110
- minimum: a.value,
1111
- inclusive: a.inclusive,
1112
- message: a.message
1113
- }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1114
- code: c.too_big,
1115
- type: "bigint",
1116
- maximum: a.value,
1117
- inclusive: a.inclusive,
1118
- message: a.message
1119
- }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), l(n, {
1120
- code: c.not_multiple_of,
1121
- multipleOf: a.value,
1122
- message: a.message
1123
- }), s.dirty()) : x.assertNever(a);
1124
- return { status: s.value, value: e.data };
1125
- }
1126
- gte(e, t) {
1127
- return this.setLimit("min", e, !0, m.toString(t));
1128
- }
1129
- gt(e, t) {
1130
- return this.setLimit("min", e, !1, m.toString(t));
1131
- }
1132
- lte(e, t) {
1133
- return this.setLimit("max", e, !0, m.toString(t));
1134
- }
1135
- lt(e, t) {
1136
- return this.setLimit("max", e, !1, m.toString(t));
1137
- }
1138
- setLimit(e, t, n, s) {
1139
- return new M({
1140
- ...this._def,
1141
- checks: [
1142
- ...this._def.checks,
1143
- {
1144
- kind: e,
1145
- value: t,
1146
- inclusive: n,
1147
- message: m.toString(s)
1148
- }
1149
- ]
1150
- });
1151
- }
1152
- _addCheck(e) {
1153
- return new M({
1154
- ...this._def,
1155
- checks: [...this._def.checks, e]
1156
- });
1157
- }
1158
- positive(e) {
1159
- return this._addCheck({
1160
- kind: "min",
1161
- value: BigInt(0),
1162
- inclusive: !1,
1163
- message: m.toString(e)
1164
- });
1165
- }
1166
- negative(e) {
1167
- return this._addCheck({
1168
- kind: "max",
1169
- value: BigInt(0),
1170
- inclusive: !1,
1171
- message: m.toString(e)
1172
- });
1173
- }
1174
- nonpositive(e) {
1175
- return this._addCheck({
1176
- kind: "max",
1177
- value: BigInt(0),
1178
- inclusive: !0,
1179
- message: m.toString(e)
1180
- });
1181
- }
1182
- nonnegative(e) {
1183
- return this._addCheck({
1184
- kind: "min",
1185
- value: BigInt(0),
1186
- inclusive: !0,
1187
- message: m.toString(e)
1188
- });
1189
- }
1190
- multipleOf(e, t) {
1191
- return this._addCheck({
1192
- kind: "multipleOf",
1193
- value: e,
1194
- message: m.toString(t)
1195
- });
1196
- }
1197
- get minValue() {
1198
- let e = null;
1199
- for (const t of this._def.checks)
1200
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1201
- return e;
1202
- }
1203
- get maxValue() {
1204
- let e = null;
1205
- for (const t of this._def.checks)
1206
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1207
- return e;
1208
- }
1209
- }
1210
- M.create = (r) => {
1211
- var e;
1212
- return new M({
1213
- checks: [],
1214
- typeName: p.ZodBigInt,
1215
- coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
1216
- ...v(r)
1217
- });
1218
- };
1219
- class K extends _ {
1220
- _parse(e) {
1221
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
1222
- const n = this._getOrReturnCtx(e);
1223
- return l(n, {
1224
- code: c.invalid_type,
1225
- expected: h.boolean,
1226
- received: n.parsedType
1227
- }), y;
1228
- }
1229
- return w(e.data);
1230
- }
1231
- }
1232
- K.create = (r) => new K({
1233
- typeName: p.ZodBoolean,
1234
- coerce: (r == null ? void 0 : r.coerce) || !1,
1235
- ...v(r)
1236
- });
1237
- class L extends _ {
1238
- _parse(e) {
1239
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
1240
- const a = this._getOrReturnCtx(e);
1241
- return l(a, {
1242
- code: c.invalid_type,
1243
- expected: h.date,
1244
- received: a.parsedType
1245
- }), y;
1246
- }
1247
- if (isNaN(e.data.getTime())) {
1248
- const a = this._getOrReturnCtx(e);
1249
- return l(a, {
1250
- code: c.invalid_date
1251
- }), y;
1252
- }
1253
- const n = new k();
1254
- let s;
1255
- for (const a of this._def.checks)
1256
- a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), l(s, {
1257
- code: c.too_small,
1258
- message: a.message,
1259
- inclusive: !0,
1260
- exact: !1,
1261
- minimum: a.value,
1262
- type: "date"
1263
- }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), l(s, {
1264
- code: c.too_big,
1265
- message: a.message,
1266
- inclusive: !0,
1267
- exact: !1,
1268
- maximum: a.value,
1269
- type: "date"
1270
- }), n.dirty()) : x.assertNever(a);
1271
- return {
1272
- status: n.value,
1273
- value: new Date(e.data.getTime())
1274
- };
1275
- }
1276
- _addCheck(e) {
1277
- return new L({
1278
- ...this._def,
1279
- checks: [...this._def.checks, e]
1280
- });
1281
- }
1282
- min(e, t) {
1283
- return this._addCheck({
1284
- kind: "min",
1285
- value: e.getTime(),
1286
- message: m.toString(t)
1287
- });
1288
- }
1289
- max(e, t) {
1290
- return this._addCheck({
1291
- kind: "max",
1292
- value: e.getTime(),
1293
- message: m.toString(t)
1294
- });
1295
- }
1296
- get minDate() {
1297
- let e = null;
1298
- for (const t of this._def.checks)
1299
- t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1300
- return e != null ? new Date(e) : null;
1301
- }
1302
- get maxDate() {
1303
- let e = null;
1304
- for (const t of this._def.checks)
1305
- t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1306
- return e != null ? new Date(e) : null;
1307
- }
1308
- }
1309
- L.create = (r) => new L({
1310
- checks: [],
1311
- coerce: (r == null ? void 0 : r.coerce) || !1,
1312
- typeName: p.ZodDate,
1313
- ...v(r)
1314
- });
1315
- class pe extends _ {
1316
- _parse(e) {
1317
- if (this._getType(e) !== h.symbol) {
1318
- const n = this._getOrReturnCtx(e);
1319
- return l(n, {
1320
- code: c.invalid_type,
1321
- expected: h.symbol,
1322
- received: n.parsedType
1323
- }), y;
1324
- }
1325
- return w(e.data);
1326
- }
1327
- }
1328
- pe.create = (r) => new pe({
1329
- typeName: p.ZodSymbol,
1330
- ...v(r)
1331
- });
1332
- class F extends _ {
1333
- _parse(e) {
1334
- if (this._getType(e) !== h.undefined) {
1335
- const n = this._getOrReturnCtx(e);
1336
- return l(n, {
1337
- code: c.invalid_type,
1338
- expected: h.undefined,
1339
- received: n.parsedType
1340
- }), y;
1341
- }
1342
- return w(e.data);
1343
- }
1344
- }
1345
- F.create = (r) => new F({
1346
- typeName: p.ZodUndefined,
1347
- ...v(r)
1348
- });
1349
- class ee extends _ {
1350
- _parse(e) {
1351
- if (this._getType(e) !== h.null) {
1352
- const n = this._getOrReturnCtx(e);
1353
- return l(n, {
1354
- code: c.invalid_type,
1355
- expected: h.null,
1356
- received: n.parsedType
1357
- }), y;
1358
- }
1359
- return w(e.data);
1360
- }
1361
- }
1362
- ee.create = (r) => new ee({
1363
- typeName: p.ZodNull,
1364
- ...v(r)
1365
- });
1366
- class Y extends _ {
1367
- constructor() {
1368
- super(...arguments), this._any = !0;
1369
- }
1370
- _parse(e) {
1371
- return w(e.data);
1372
- }
1373
- }
1374
- Y.create = (r) => new Y({
1375
- typeName: p.ZodAny,
1376
- ...v(r)
1377
- });
1378
- class D extends _ {
1379
- constructor() {
1380
- super(...arguments), this._unknown = !0;
1381
- }
1382
- _parse(e) {
1383
- return w(e.data);
1384
- }
1385
- }
1386
- D.create = (r) => new D({
1387
- typeName: p.ZodUnknown,
1388
- ...v(r)
1389
- });
1390
- class R extends _ {
1391
- _parse(e) {
1392
- const t = this._getOrReturnCtx(e);
1393
- return l(t, {
1394
- code: c.invalid_type,
1395
- expected: h.never,
1396
- received: t.parsedType
1397
- }), y;
1398
- }
1399
- }
1400
- R.create = (r) => new R({
1401
- typeName: p.ZodNever,
1402
- ...v(r)
1403
- });
1404
- class ye extends _ {
1405
- _parse(e) {
1406
- if (this._getType(e) !== h.undefined) {
1407
- const n = this._getOrReturnCtx(e);
1408
- return l(n, {
1409
- code: c.invalid_type,
1410
- expected: h.void,
1411
- received: n.parsedType
1412
- }), y;
1413
- }
1414
- return w(e.data);
1415
- }
1416
- }
1417
- ye.create = (r) => new ye({
1418
- typeName: p.ZodVoid,
1419
- ...v(r)
1420
- });
1421
- class N extends _ {
1422
- _parse(e) {
1423
- const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
1424
- if (t.parsedType !== h.array)
1425
- return l(t, {
1426
- code: c.invalid_type,
1427
- expected: h.array,
1428
- received: t.parsedType
1429
- }), y;
1430
- if (s.exactLength !== null) {
1431
- const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
1432
- (i || o) && (l(t, {
1433
- code: i ? c.too_big : c.too_small,
1434
- minimum: o ? s.exactLength.value : void 0,
1435
- maximum: i ? s.exactLength.value : void 0,
1436
- type: "array",
1437
- inclusive: !0,
1438
- exact: !0,
1439
- message: s.exactLength.message
1440
- }), n.dirty());
1441
- }
1442
- if (s.minLength !== null && t.data.length < s.minLength.value && (l(t, {
1443
- code: c.too_small,
1444
- minimum: s.minLength.value,
1445
- type: "array",
1446
- inclusive: !0,
1447
- exact: !1,
1448
- message: s.minLength.message
1449
- }), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (l(t, {
1450
- code: c.too_big,
1451
- maximum: s.maxLength.value,
1452
- type: "array",
1453
- inclusive: !0,
1454
- exact: !1,
1455
- message: s.maxLength.message
1456
- }), n.dirty()), t.common.async)
1457
- return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new I(t, i, t.path, o)))).then((i) => k.mergeArray(n, i));
1458
- const a = [...t.data].map((i, o) => s.type._parseSync(new I(t, i, t.path, o)));
1459
- return k.mergeArray(n, a);
1460
- }
1461
- get element() {
1462
- return this._def.type;
1463
- }
1464
- min(e, t) {
1465
- return new N({
1466
- ...this._def,
1467
- minLength: { value: e, message: m.toString(t) }
1468
- });
1469
- }
1470
- max(e, t) {
1471
- return new N({
1472
- ...this._def,
1473
- maxLength: { value: e, message: m.toString(t) }
1474
- });
1475
- }
1476
- length(e, t) {
1477
- return new N({
1478
- ...this._def,
1479
- exactLength: { value: e, message: m.toString(t) }
1480
- });
1481
- }
1482
- nonempty(e) {
1483
- return this.min(1, e);
1484
- }
1485
- }
1486
- N.create = (r, e) => new N({
1487
- type: r,
1488
- minLength: null,
1489
- maxLength: null,
1490
- exactLength: null,
1491
- typeName: p.ZodArray,
1492
- ...v(e)
1493
- });
1494
- function U(r) {
1495
- if (r instanceof b) {
1496
- const e = {};
1497
- for (const t in r.shape) {
1498
- const n = r.shape[t];
1499
- e[t] = E.create(U(n));
1500
- }
1501
- return new b({
1502
- ...r._def,
1503
- shape: () => e
1504
- });
1505
- } else return r instanceof N ? new N({
1506
- ...r._def,
1507
- type: U(r.element)
1508
- }) : r instanceof E ? E.create(U(r.unwrap())) : r instanceof V ? V.create(U(r.unwrap())) : r instanceof O ? O.create(r.items.map((e) => U(e))) : r;
1509
- }
1510
- class b extends _ {
1511
- constructor() {
1512
- super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1513
- }
1514
- _getCached() {
1515
- if (this._cached !== null)
1516
- return this._cached;
1517
- const e = this._def.shape(), t = x.objectKeys(e);
1518
- return this._cached = { shape: e, keys: t };
1519
- }
1520
- _parse(e) {
1521
- if (this._getType(e) !== h.object) {
1522
- const u = this._getOrReturnCtx(e);
1523
- return l(u, {
1524
- code: c.invalid_type,
1525
- expected: h.object,
1526
- received: u.parsedType
1527
- }), y;
1528
- }
1529
- const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1530
- if (!(this._def.catchall instanceof R && this._def.unknownKeys === "strip"))
1531
- for (const u in s.data)
1532
- i.includes(u) || o.push(u);
1533
- const f = [];
1534
- for (const u of i) {
1535
- const g = a[u], Z = s.data[u];
1536
- f.push({
1537
- key: { status: "valid", value: u },
1538
- value: g._parse(new I(s, Z, s.path, u)),
1539
- alwaysSet: u in s.data
1540
- });
1541
- }
1542
- if (this._def.catchall instanceof R) {
1543
- const u = this._def.unknownKeys;
1544
- if (u === "passthrough")
1545
- for (const g of o)
1546
- f.push({
1547
- key: { status: "valid", value: g },
1548
- value: { status: "valid", value: s.data[g] }
1549
- });
1550
- else if (u === "strict")
1551
- o.length > 0 && (l(s, {
1552
- code: c.unrecognized_keys,
1553
- keys: o
1554
- }), n.dirty());
1555
- else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1556
- } else {
1557
- const u = this._def.catchall;
1558
- for (const g of o) {
1559
- const Z = s.data[g];
1560
- f.push({
1561
- key: { status: "valid", value: g },
1562
- value: u._parse(
1563
- new I(s, Z, s.path, g)
1564
- //, ctx.child(key), value, getParsedType(value)
1565
- ),
1566
- alwaysSet: g in s.data
1567
- });
1568
- }
1569
- }
1570
- return s.common.async ? Promise.resolve().then(async () => {
1571
- const u = [];
1572
- for (const g of f) {
1573
- const Z = await g.key, Ie = await g.value;
1574
- u.push({
1575
- key: Z,
1576
- value: Ie,
1577
- alwaysSet: g.alwaysSet
1578
- });
1579
- }
1580
- return u;
1581
- }).then((u) => k.mergeObjectSync(n, u)) : k.mergeObjectSync(n, f);
1582
- }
1583
- get shape() {
1584
- return this._def.shape();
1585
- }
1586
- strict(e) {
1587
- return m.errToObj, new b({
1588
- ...this._def,
1589
- unknownKeys: "strict",
1590
- ...e !== void 0 ? {
1591
- errorMap: (t, n) => {
1592
- var s, a, i, o;
1593
- const f = (i = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && i !== void 0 ? i : n.defaultError;
1594
- return t.code === "unrecognized_keys" ? {
1595
- message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o : f
1596
- } : {
1597
- message: f
1598
- };
1599
- }
1600
- } : {}
1601
- });
1602
- }
1603
- strip() {
1604
- return new b({
1605
- ...this._def,
1606
- unknownKeys: "strip"
1607
- });
1608
- }
1609
- passthrough() {
1610
- return new b({
1611
- ...this._def,
1612
- unknownKeys: "passthrough"
1613
- });
1614
- }
1615
- // const AugmentFactory =
1616
- // <Def extends ZodObjectDef>(def: Def) =>
1617
- // <Augmentation extends ZodRawShape>(
1618
- // augmentation: Augmentation
1619
- // ): ZodObject<
1620
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1621
- // Def["unknownKeys"],
1622
- // Def["catchall"]
1623
- // > => {
1624
- // return new ZodObject({
1625
- // ...def,
1626
- // shape: () => ({
1627
- // ...def.shape(),
1628
- // ...augmentation,
1629
- // }),
1630
- // }) as any;
1631
- // };
1632
- extend(e) {
1633
- return new b({
1634
- ...this._def,
1635
- shape: () => ({
1636
- ...this._def.shape(),
1637
- ...e
1638
- })
1639
- });
1640
- }
1641
- /**
1642
- * Prior to zod@1.0.12 there was a bug in the
1643
- * inferred type of merged objects. Please
1644
- * upgrade if you are experiencing issues.
1645
- */
1646
- merge(e) {
1647
- return new b({
1648
- unknownKeys: e._def.unknownKeys,
1649
- catchall: e._def.catchall,
1650
- shape: () => ({
1651
- ...this._def.shape(),
1652
- ...e._def.shape()
1653
- }),
1654
- typeName: p.ZodObject
1655
- });
1656
- }
1657
- // merge<
1658
- // Incoming extends AnyZodObject,
1659
- // Augmentation extends Incoming["shape"],
1660
- // NewOutput extends {
1661
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1662
- // ? Augmentation[k]["_output"]
1663
- // : k extends keyof Output
1664
- // ? Output[k]
1665
- // : never;
1666
- // },
1667
- // NewInput extends {
1668
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1669
- // ? Augmentation[k]["_input"]
1670
- // : k extends keyof Input
1671
- // ? Input[k]
1672
- // : never;
1673
- // }
1674
- // >(
1675
- // merging: Incoming
1676
- // ): ZodObject<
1677
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1678
- // Incoming["_def"]["unknownKeys"],
1679
- // Incoming["_def"]["catchall"],
1680
- // NewOutput,
1681
- // NewInput
1682
- // > {
1683
- // const merged: any = new ZodObject({
1684
- // unknownKeys: merging._def.unknownKeys,
1685
- // catchall: merging._def.catchall,
1686
- // shape: () =>
1687
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1688
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1689
- // }) as any;
1690
- // return merged;
1691
- // }
1692
- setKey(e, t) {
1693
- return this.augment({ [e]: t });
1694
- }
1695
- // merge<Incoming extends AnyZodObject>(
1696
- // merging: Incoming
1697
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1698
- // ZodObject<
1699
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1700
- // Incoming["_def"]["unknownKeys"],
1701
- // Incoming["_def"]["catchall"]
1702
- // > {
1703
- // // const mergedShape = objectUtil.mergeShapes(
1704
- // // this._def.shape(),
1705
- // // merging._def.shape()
1706
- // // );
1707
- // const merged: any = new ZodObject({
1708
- // unknownKeys: merging._def.unknownKeys,
1709
- // catchall: merging._def.catchall,
1710
- // shape: () =>
1711
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1712
- // typeName: ZodFirstPartyTypeKind.ZodObject,
1713
- // }) as any;
1714
- // return merged;
1715
- // }
1716
- catchall(e) {
1717
- return new b({
1718
- ...this._def,
1719
- catchall: e
1720
- });
1721
- }
1722
- pick(e) {
1723
- const t = {};
1724
- return x.objectKeys(e).forEach((n) => {
1725
- e[n] && this.shape[n] && (t[n] = this.shape[n]);
1726
- }), new b({
1727
- ...this._def,
1728
- shape: () => t
1729
- });
1730
- }
1731
- omit(e) {
1732
- const t = {};
1733
- return x.objectKeys(this.shape).forEach((n) => {
1734
- e[n] || (t[n] = this.shape[n]);
1735
- }), new b({
1736
- ...this._def,
1737
- shape: () => t
1738
- });
1739
- }
1740
- /**
1741
- * @deprecated
1742
- */
1743
- deepPartial() {
1744
- return U(this);
1745
- }
1746
- partial(e) {
1747
- const t = {};
1748
- return x.objectKeys(this.shape).forEach((n) => {
1749
- const s = this.shape[n];
1750
- e && !e[n] ? t[n] = s : t[n] = s.optional();
1751
- }), new b({
1752
- ...this._def,
1753
- shape: () => t
1754
- });
1755
- }
1756
- required(e) {
1757
- const t = {};
1758
- return x.objectKeys(this.shape).forEach((n) => {
1759
- if (e && !e[n])
1760
- t[n] = this.shape[n];
1761
- else {
1762
- let a = this.shape[n];
1763
- for (; a instanceof E; )
1764
- a = a._def.innerType;
1765
- t[n] = a;
1766
- }
1767
- }), new b({
1768
- ...this._def,
1769
- shape: () => t
1770
- });
1771
- }
1772
- keyof() {
1773
- return Ve(x.objectKeys(this.shape));
1774
- }
1775
- }
1776
- b.create = (r, e) => new b({
1777
- shape: () => r,
1778
- unknownKeys: "strip",
1779
- catchall: R.create(),
1780
- typeName: p.ZodObject,
1781
- ...v(e)
1782
- });
1783
- b.strictCreate = (r, e) => new b({
1784
- shape: () => r,
1785
- unknownKeys: "strict",
1786
- catchall: R.create(),
1787
- typeName: p.ZodObject,
1788
- ...v(e)
1789
- });
1790
- b.lazycreate = (r, e) => new b({
1791
- shape: r,
1792
- unknownKeys: "strip",
1793
- catchall: R.create(),
1794
- typeName: p.ZodObject,
1795
- ...v(e)
1796
- });
1797
- class te extends _ {
1798
- _parse(e) {
1799
- const { ctx: t } = this._processInputParams(e), n = this._def.options;
1800
- function s(a) {
1801
- for (const o of a)
1802
- if (o.result.status === "valid")
1803
- return o.result;
1804
- for (const o of a)
1805
- if (o.result.status === "dirty")
1806
- return t.common.issues.push(...o.ctx.common.issues), o.result;
1807
- const i = a.map((o) => new T(o.ctx.common.issues));
1808
- return l(t, {
1809
- code: c.invalid_union,
1810
- unionErrors: i
1811
- }), y;
1812
- }
1813
- if (t.common.async)
1814
- return Promise.all(n.map(async (a) => {
1815
- const i = {
1816
- ...t,
1817
- common: {
1818
- ...t.common,
1819
- issues: []
1820
- },
1821
- parent: null
1822
- };
1823
- return {
1824
- result: await a._parseAsync({
1825
- data: t.data,
1826
- path: t.path,
1827
- parent: i
1828
- }),
1829
- ctx: i
1830
- };
1831
- })).then(s);
1832
- {
1833
- let a;
1834
- const i = [];
1835
- for (const f of n) {
1836
- const u = {
1837
- ...t,
1838
- common: {
1839
- ...t.common,
1840
- issues: []
1841
- },
1842
- parent: null
1843
- }, g = f._parseSync({
1844
- data: t.data,
1845
- path: t.path,
1846
- parent: u
1847
- });
1848
- if (g.status === "valid")
1849
- return g;
1850
- g.status === "dirty" && !a && (a = { result: g, ctx: u }), u.common.issues.length && i.push(u.common.issues);
1851
- }
1852
- if (a)
1853
- return t.common.issues.push(...a.ctx.common.issues), a.result;
1854
- const o = i.map((f) => new T(f));
1855
- return l(t, {
1856
- code: c.invalid_union,
1857
- unionErrors: o
1858
- }), y;
1859
- }
1860
- }
1861
- get options() {
1862
- return this._def.options;
1863
- }
1864
- }
1865
- te.create = (r, e) => new te({
1866
- options: r,
1867
- typeName: p.ZodUnion,
1868
- ...v(e)
1869
- });
1870
- const j = (r) => r instanceof se ? j(r.schema) : r instanceof C ? j(r.innerType()) : r instanceof ae ? [r.value] : r instanceof $ ? r.options : r instanceof ie ? x.objectValues(r.enum) : r instanceof oe ? j(r._def.innerType) : r instanceof F ? [void 0] : r instanceof ee ? [null] : r instanceof E ? [void 0, ...j(r.unwrap())] : r instanceof V ? [null, ...j(r.unwrap())] : r instanceof Ce || r instanceof ce ? j(r.unwrap()) : r instanceof de ? j(r._def.innerType) : [];
1871
- class _e extends _ {
1872
- _parse(e) {
1873
- const { ctx: t } = this._processInputParams(e);
1874
- if (t.parsedType !== h.object)
1875
- return l(t, {
1876
- code: c.invalid_type,
1877
- expected: h.object,
1878
- received: t.parsedType
1879
- }), y;
1880
- const n = this.discriminator, s = t.data[n], a = this.optionsMap.get(s);
1881
- return a ? t.common.async ? a._parseAsync({
1882
- data: t.data,
1883
- path: t.path,
1884
- parent: t
1885
- }) : a._parseSync({
1886
- data: t.data,
1887
- path: t.path,
1888
- parent: t
1889
- }) : (l(t, {
1890
- code: c.invalid_union_discriminator,
1891
- options: Array.from(this.optionsMap.keys()),
1892
- path: [n]
1893
- }), y);
1894
- }
1895
- get discriminator() {
1896
- return this._def.discriminator;
1897
- }
1898
- get options() {
1899
- return this._def.options;
1900
- }
1901
- get optionsMap() {
1902
- return this._def.optionsMap;
1903
- }
1904
- /**
1905
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1906
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
1907
- * have a different value for each object in the union.
1908
- * @param discriminator the name of the discriminator property
1909
- * @param types an array of object schemas
1910
- * @param params
1911
- */
1912
- static create(e, t, n) {
1913
- const s = /* @__PURE__ */ new Map();
1914
- for (const a of t) {
1915
- const i = j(a.shape[e]);
1916
- if (!i.length)
1917
- throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
1918
- for (const o of i) {
1919
- if (s.has(o))
1920
- throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
1921
- s.set(o, a);
1922
- }
1923
- }
1924
- return new _e({
1925
- typeName: p.ZodDiscriminatedUnion,
1926
- discriminator: e,
1927
- options: t,
1928
- optionsMap: s,
1929
- ...v(n)
1930
- });
1931
- }
1932
- }
1933
- function Ne(r, e) {
1934
- const t = A(r), n = A(e);
1935
- if (r === e)
1936
- return { valid: !0, data: r };
1937
- if (t === h.object && n === h.object) {
1938
- const s = x.objectKeys(e), a = x.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
1939
- for (const o of a) {
1940
- const f = Ne(r[o], e[o]);
1941
- if (!f.valid)
1942
- return { valid: !1 };
1943
- i[o] = f.data;
1944
- }
1945
- return { valid: !0, data: i };
1946
- } else if (t === h.array && n === h.array) {
1947
- if (r.length !== e.length)
1948
- return { valid: !1 };
1949
- const s = [];
1950
- for (let a = 0; a < r.length; a++) {
1951
- const i = r[a], o = e[a], f = Ne(i, o);
1952
- if (!f.valid)
1953
- return { valid: !1 };
1954
- s.push(f.data);
1955
- }
1956
- return { valid: !0, data: s };
1957
- } else return t === h.date && n === h.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
1958
- }
1959
- class re extends _ {
1960
- _parse(e) {
1961
- const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
1962
- if (Ze(a) || Ze(i))
1963
- return y;
1964
- const o = Ne(a.value, i.value);
1965
- return o.valid ? ((Se(a) || Se(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
1966
- code: c.invalid_intersection_types
1967
- }), y);
1968
- };
1969
- return n.common.async ? Promise.all([
1970
- this._def.left._parseAsync({
1971
- data: n.data,
1972
- path: n.path,
1973
- parent: n
1974
- }),
1975
- this._def.right._parseAsync({
1976
- data: n.data,
1977
- path: n.path,
1978
- parent: n
1979
- })
1980
- ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
1981
- data: n.data,
1982
- path: n.path,
1983
- parent: n
1984
- }), this._def.right._parseSync({
1985
- data: n.data,
1986
- path: n.path,
1987
- parent: n
1988
- }));
1989
- }
1990
- }
1991
- re.create = (r, e, t) => new re({
1992
- left: r,
1993
- right: e,
1994
- typeName: p.ZodIntersection,
1995
- ...v(t)
1996
- });
1997
- class O extends _ {
1998
- _parse(e) {
1999
- const { status: t, ctx: n } = this._processInputParams(e);
2000
- if (n.parsedType !== h.array)
2001
- return l(n, {
2002
- code: c.invalid_type,
2003
- expected: h.array,
2004
- received: n.parsedType
2005
- }), y;
2006
- if (n.data.length < this._def.items.length)
2007
- return l(n, {
2008
- code: c.too_small,
2009
- minimum: this._def.items.length,
2010
- inclusive: !0,
2011
- exact: !1,
2012
- type: "array"
2013
- }), y;
2014
- !this._def.rest && n.data.length > this._def.items.length && (l(n, {
2015
- code: c.too_big,
2016
- maximum: this._def.items.length,
2017
- inclusive: !0,
2018
- exact: !1,
2019
- type: "array"
2020
- }), t.dirty());
2021
- const a = [...n.data].map((i, o) => {
2022
- const f = this._def.items[o] || this._def.rest;
2023
- return f ? f._parse(new I(n, i, n.path, o)) : null;
2024
- }).filter((i) => !!i);
2025
- return n.common.async ? Promise.all(a).then((i) => k.mergeArray(t, i)) : k.mergeArray(t, a);
2026
- }
2027
- get items() {
2028
- return this._def.items;
2029
- }
2030
- rest(e) {
2031
- return new O({
2032
- ...this._def,
2033
- rest: e
2034
- });
2035
- }
2036
- }
2037
- O.create = (r, e) => {
2038
- if (!Array.isArray(r))
2039
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2040
- return new O({
2041
- items: r,
2042
- typeName: p.ZodTuple,
2043
- rest: null,
2044
- ...v(e)
2045
- });
2046
- };
2047
- class ne extends _ {
2048
- get keySchema() {
2049
- return this._def.keyType;
2050
- }
2051
- get valueSchema() {
2052
- return this._def.valueType;
2053
- }
2054
- _parse(e) {
2055
- const { status: t, ctx: n } = this._processInputParams(e);
2056
- if (n.parsedType !== h.object)
2057
- return l(n, {
2058
- code: c.invalid_type,
2059
- expected: h.object,
2060
- received: n.parsedType
2061
- }), y;
2062
- const s = [], a = this._def.keyType, i = this._def.valueType;
2063
- for (const o in n.data)
2064
- s.push({
2065
- key: a._parse(new I(n, o, n.path, o)),
2066
- value: i._parse(new I(n, n.data[o], n.path, o)),
2067
- alwaysSet: o in n.data
2068
- });
2069
- return n.common.async ? k.mergeObjectAsync(t, s) : k.mergeObjectSync(t, s);
2070
- }
2071
- get element() {
2072
- return this._def.valueType;
2073
- }
2074
- static create(e, t, n) {
2075
- return t instanceof _ ? new ne({
2076
- keyType: e,
2077
- valueType: t,
2078
- typeName: p.ZodRecord,
2079
- ...v(n)
2080
- }) : new ne({
2081
- keyType: S.create(),
2082
- valueType: e,
2083
- typeName: p.ZodRecord,
2084
- ...v(t)
2085
- });
2086
- }
2087
- }
2088
- class ge extends _ {
2089
- get keySchema() {
2090
- return this._def.keyType;
2091
- }
2092
- get valueSchema() {
2093
- return this._def.valueType;
2094
- }
2095
- _parse(e) {
2096
- const { status: t, ctx: n } = this._processInputParams(e);
2097
- if (n.parsedType !== h.map)
2098
- return l(n, {
2099
- code: c.invalid_type,
2100
- expected: h.map,
2101
- received: n.parsedType
2102
- }), y;
2103
- const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, f], u) => ({
2104
- key: s._parse(new I(n, o, n.path, [u, "key"])),
2105
- value: a._parse(new I(n, f, n.path, [u, "value"]))
2106
- }));
2107
- if (n.common.async) {
2108
- const o = /* @__PURE__ */ new Map();
2109
- return Promise.resolve().then(async () => {
2110
- for (const f of i) {
2111
- const u = await f.key, g = await f.value;
2112
- if (u.status === "aborted" || g.status === "aborted")
2113
- return y;
2114
- (u.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(u.value, g.value);
2115
- }
2116
- return { status: t.value, value: o };
2117
- });
2118
- } else {
2119
- const o = /* @__PURE__ */ new Map();
2120
- for (const f of i) {
2121
- const u = f.key, g = f.value;
2122
- if (u.status === "aborted" || g.status === "aborted")
2123
- return y;
2124
- (u.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(u.value, g.value);
2125
- }
2126
- return { status: t.value, value: o };
2127
- }
2128
- }
2129
- }
2130
- ge.create = (r, e, t) => new ge({
2131
- valueType: e,
2132
- keyType: r,
2133
- typeName: p.ZodMap,
2134
- ...v(t)
2135
- });
2136
- class z extends _ {
2137
- _parse(e) {
2138
- const { status: t, ctx: n } = this._processInputParams(e);
2139
- if (n.parsedType !== h.set)
2140
- return l(n, {
2141
- code: c.invalid_type,
2142
- expected: h.set,
2143
- received: n.parsedType
2144
- }), y;
2145
- const s = this._def;
2146
- s.minSize !== null && n.data.size < s.minSize.value && (l(n, {
2147
- code: c.too_small,
2148
- minimum: s.minSize.value,
2149
- type: "set",
2150
- inclusive: !0,
2151
- exact: !1,
2152
- message: s.minSize.message
2153
- }), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (l(n, {
2154
- code: c.too_big,
2155
- maximum: s.maxSize.value,
2156
- type: "set",
2157
- inclusive: !0,
2158
- exact: !1,
2159
- message: s.maxSize.message
2160
- }), t.dirty());
2161
- const a = this._def.valueType;
2162
- function i(f) {
2163
- const u = /* @__PURE__ */ new Set();
2164
- for (const g of f) {
2165
- if (g.status === "aborted")
2166
- return y;
2167
- g.status === "dirty" && t.dirty(), u.add(g.value);
2168
- }
2169
- return { status: t.value, value: u };
2170
- }
2171
- const o = [...n.data.values()].map((f, u) => a._parse(new I(n, f, n.path, u)));
2172
- return n.common.async ? Promise.all(o).then((f) => i(f)) : i(o);
2173
- }
2174
- min(e, t) {
2175
- return new z({
2176
- ...this._def,
2177
- minSize: { value: e, message: m.toString(t) }
2178
- });
2179
- }
2180
- max(e, t) {
2181
- return new z({
2182
- ...this._def,
2183
- maxSize: { value: e, message: m.toString(t) }
2184
- });
2185
- }
2186
- size(e, t) {
2187
- return this.min(e, t).max(e, t);
2188
- }
2189
- nonempty(e) {
2190
- return this.min(1, e);
2191
- }
2192
- }
2193
- z.create = (r, e) => new z({
2194
- valueType: r,
2195
- minSize: null,
2196
- maxSize: null,
2197
- typeName: p.ZodSet,
2198
- ...v(e)
2199
- });
2200
- class W extends _ {
2201
- constructor() {
2202
- super(...arguments), this.validate = this.implement;
2203
- }
2204
- _parse(e) {
2205
- const { ctx: t } = this._processInputParams(e);
2206
- if (t.parsedType !== h.function)
2207
- return l(t, {
2208
- code: c.invalid_type,
2209
- expected: h.function,
2210
- received: t.parsedType
2211
- }), y;
2212
- function n(o, f) {
2213
- return he({
2214
- data: o,
2215
- path: t.path,
2216
- errorMaps: [
2217
- t.common.contextualErrorMap,
2218
- t.schemaErrorMap,
2219
- fe(),
2220
- q
2221
- ].filter((u) => !!u),
2222
- issueData: {
2223
- code: c.invalid_arguments,
2224
- argumentsError: f
2225
- }
2226
- });
2227
- }
2228
- function s(o, f) {
2229
- return he({
2230
- data: o,
2231
- path: t.path,
2232
- errorMaps: [
2233
- t.common.contextualErrorMap,
2234
- t.schemaErrorMap,
2235
- fe(),
2236
- q
2237
- ].filter((u) => !!u),
2238
- issueData: {
2239
- code: c.invalid_return_type,
2240
- returnTypeError: f
2241
- }
2242
- });
2243
- }
2244
- const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2245
- if (this._def.returns instanceof J) {
2246
- const o = this;
2247
- return w(async function(...f) {
2248
- const u = new T([]), g = await o._def.args.parseAsync(f, a).catch((be) => {
2249
- throw u.addIssue(n(f, be)), u;
2250
- }), Z = await Reflect.apply(i, this, g);
2251
- return await o._def.returns._def.type.parseAsync(Z, a).catch((be) => {
2252
- throw u.addIssue(s(Z, be)), u;
2253
- });
2254
- });
2255
- } else {
2256
- const o = this;
2257
- return w(function(...f) {
2258
- const u = o._def.args.safeParse(f, a);
2259
- if (!u.success)
2260
- throw new T([n(f, u.error)]);
2261
- const g = Reflect.apply(i, this, u.data), Z = o._def.returns.safeParse(g, a);
2262
- if (!Z.success)
2263
- throw new T([s(g, Z.error)]);
2264
- return Z.data;
2265
- });
2266
- }
2267
- }
2268
- parameters() {
2269
- return this._def.args;
2270
- }
2271
- returnType() {
2272
- return this._def.returns;
2273
- }
2274
- args(...e) {
2275
- return new W({
2276
- ...this._def,
2277
- args: O.create(e).rest(D.create())
2278
- });
2279
- }
2280
- returns(e) {
2281
- return new W({
2282
- ...this._def,
2283
- returns: e
2284
- });
2285
- }
2286
- implement(e) {
2287
- return this.parse(e);
2288
- }
2289
- strictImplement(e) {
2290
- return this.parse(e);
2291
- }
2292
- static create(e, t, n) {
2293
- return new W({
2294
- args: e || O.create([]).rest(D.create()),
2295
- returns: t || D.create(),
2296
- typeName: p.ZodFunction,
2297
- ...v(n)
2298
- });
2299
- }
2300
- }
2301
- class se extends _ {
2302
- get schema() {
2303
- return this._def.getter();
2304
- }
2305
- _parse(e) {
2306
- const { ctx: t } = this._processInputParams(e);
2307
- return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2308
- }
2309
- }
2310
- se.create = (r, e) => new se({
2311
- getter: r,
2312
- typeName: p.ZodLazy,
2313
- ...v(e)
2314
- });
2315
- class ae extends _ {
2316
- _parse(e) {
2317
- if (e.data !== this._def.value) {
2318
- const t = this._getOrReturnCtx(e);
2319
- return l(t, {
2320
- received: t.data,
2321
- code: c.invalid_literal,
2322
- expected: this._def.value
2323
- }), y;
2324
- }
2325
- return { status: "valid", value: e.data };
2326
- }
2327
- get value() {
2328
- return this._def.value;
2329
- }
2330
- }
2331
- ae.create = (r, e) => new ae({
2332
- value: r,
2333
- typeName: p.ZodLiteral,
2334
- ...v(e)
2335
- });
2336
- function Ve(r, e) {
2337
- return new $({
2338
- values: r,
2339
- typeName: p.ZodEnum,
2340
- ...v(e)
2341
- });
2342
- }
2343
- class $ extends _ {
2344
- constructor() {
2345
- super(...arguments), H.set(this, void 0);
2346
- }
2347
- _parse(e) {
2348
- if (typeof e.data != "string") {
2349
- const t = this._getOrReturnCtx(e), n = this._def.values;
2350
- return l(t, {
2351
- expected: x.joinValues(n),
2352
- received: t.parsedType,
2353
- code: c.invalid_type
2354
- }), y;
2355
- }
2356
- if (me(this, H) || Ae(this, H, new Set(this._def.values)), !me(this, H).has(e.data)) {
2357
- const t = this._getOrReturnCtx(e), n = this._def.values;
2358
- return l(t, {
2359
- received: t.data,
2360
- code: c.invalid_enum_value,
2361
- options: n
2362
- }), y;
2363
- }
2364
- return w(e.data);
2365
- }
2366
- get options() {
2367
- return this._def.values;
2368
- }
2369
- get enum() {
2370
- const e = {};
2371
- for (const t of this._def.values)
2372
- e[t] = t;
2373
- return e;
2374
- }
2375
- get Values() {
2376
- const e = {};
2377
- for (const t of this._def.values)
2378
- e[t] = t;
2379
- return e;
2380
- }
2381
- get Enum() {
2382
- const e = {};
2383
- for (const t of this._def.values)
2384
- e[t] = t;
2385
- return e;
2386
- }
2387
- extract(e, t = this._def) {
2388
- return $.create(e, {
2389
- ...this._def,
2390
- ...t
2391
- });
2392
- }
2393
- exclude(e, t = this._def) {
2394
- return $.create(this.options.filter((n) => !e.includes(n)), {
2395
- ...this._def,
2396
- ...t
2397
- });
2398
- }
2399
- }
2400
- H = /* @__PURE__ */ new WeakMap();
2401
- $.create = Ve;
2402
- class ie extends _ {
2403
- constructor() {
2404
- super(...arguments), G.set(this, void 0);
2405
- }
2406
- _parse(e) {
2407
- const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2408
- if (n.parsedType !== h.string && n.parsedType !== h.number) {
2409
- const s = x.objectValues(t);
2410
- return l(n, {
2411
- expected: x.joinValues(s),
2412
- received: n.parsedType,
2413
- code: c.invalid_type
2414
- }), y;
2415
- }
2416
- if (me(this, G) || Ae(this, G, new Set(x.getValidEnumValues(this._def.values))), !me(this, G).has(e.data)) {
2417
- const s = x.objectValues(t);
2418
- return l(n, {
2419
- received: n.data,
2420
- code: c.invalid_enum_value,
2421
- options: s
2422
- }), y;
2423
- }
2424
- return w(e.data);
2425
- }
2426
- get enum() {
2427
- return this._def.values;
2428
- }
2429
- }
2430
- G = /* @__PURE__ */ new WeakMap();
2431
- ie.create = (r, e) => new ie({
2432
- values: r,
2433
- typeName: p.ZodNativeEnum,
2434
- ...v(e)
2435
- });
2436
- class J extends _ {
2437
- unwrap() {
2438
- return this._def.type;
2439
- }
2440
- _parse(e) {
2441
- const { ctx: t } = this._processInputParams(e);
2442
- if (t.parsedType !== h.promise && t.common.async === !1)
2443
- return l(t, {
2444
- code: c.invalid_type,
2445
- expected: h.promise,
2446
- received: t.parsedType
2447
- }), y;
2448
- const n = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
2449
- return w(n.then((s) => this._def.type.parseAsync(s, {
2450
- path: t.path,
2451
- errorMap: t.common.contextualErrorMap
2452
- })));
2453
- }
2454
- }
2455
- J.create = (r, e) => new J({
2456
- type: r,
2457
- typeName: p.ZodPromise,
2458
- ...v(e)
2459
- });
2460
- class C extends _ {
2461
- innerType() {
2462
- return this._def.schema;
2463
- }
2464
- sourceType() {
2465
- return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2466
- }
2467
- _parse(e) {
2468
- const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
2469
- addIssue: (i) => {
2470
- l(n, i), i.fatal ? t.abort() : t.dirty();
2471
- },
2472
- get path() {
2473
- return n.path;
2474
- }
2475
- };
2476
- if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2477
- const i = s.transform(n.data, a);
2478
- if (n.common.async)
2479
- return Promise.resolve(i).then(async (o) => {
2480
- if (t.value === "aborted")
2481
- return y;
2482
- const f = await this._def.schema._parseAsync({
2483
- data: o,
2484
- path: n.path,
2485
- parent: n
2486
- });
2487
- return f.status === "aborted" ? y : f.status === "dirty" || t.value === "dirty" ? B(f.value) : f;
2488
- });
2489
- {
2490
- if (t.value === "aborted")
2491
- return y;
2492
- const o = this._def.schema._parseSync({
2493
- data: i,
2494
- path: n.path,
2495
- parent: n
2496
- });
2497
- return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? B(o.value) : o;
2498
- }
2499
- }
2500
- if (s.type === "refinement") {
2501
- const i = (o) => {
2502
- const f = s.refinement(o, a);
2503
- if (n.common.async)
2504
- return Promise.resolve(f);
2505
- if (f instanceof Promise)
2506
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2507
- return o;
2508
- };
2509
- if (n.common.async === !1) {
2510
- const o = this._def.schema._parseSync({
2511
- data: n.data,
2512
- path: n.path,
2513
- parent: n
2514
- });
2515
- return o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2516
- } else
2517
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2518
- }
2519
- if (s.type === "transform")
2520
- if (n.common.async === !1) {
2521
- const i = this._def.schema._parseSync({
2522
- data: n.data,
2523
- path: n.path,
2524
- parent: n
2525
- });
2526
- if (!Q(i))
2527
- return i;
2528
- const o = s.transform(i.value, a);
2529
- if (o instanceof Promise)
2530
- throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2531
- return { status: t.value, value: o };
2532
- } else
2533
- return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => Q(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
2534
- x.assertNever(s);
2535
- }
2536
- }
2537
- C.create = (r, e, t) => new C({
2538
- schema: r,
2539
- typeName: p.ZodEffects,
2540
- effect: e,
2541
- ...v(t)
2542
- });
2543
- C.createWithPreprocess = (r, e, t) => new C({
2544
- schema: e,
2545
- effect: { type: "preprocess", transform: r },
2546
- typeName: p.ZodEffects,
2547
- ...v(t)
2548
- });
2549
- class E extends _ {
2550
- _parse(e) {
2551
- return this._getType(e) === h.undefined ? w(void 0) : this._def.innerType._parse(e);
2552
- }
2553
- unwrap() {
2554
- return this._def.innerType;
2555
- }
2556
- }
2557
- E.create = (r, e) => new E({
2558
- innerType: r,
2559
- typeName: p.ZodOptional,
2560
- ...v(e)
2561
- });
2562
- class V extends _ {
2563
- _parse(e) {
2564
- return this._getType(e) === h.null ? w(null) : this._def.innerType._parse(e);
2565
- }
2566
- unwrap() {
2567
- return this._def.innerType;
2568
- }
2569
- }
2570
- V.create = (r, e) => new V({
2571
- innerType: r,
2572
- typeName: p.ZodNullable,
2573
- ...v(e)
2574
- });
2575
- class oe extends _ {
2576
- _parse(e) {
2577
- const { ctx: t } = this._processInputParams(e);
2578
- let n = t.data;
2579
- return t.parsedType === h.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
2580
- data: n,
2581
- path: t.path,
2582
- parent: t
2583
- });
2584
- }
2585
- removeDefault() {
2586
- return this._def.innerType;
2587
- }
2588
- }
2589
- oe.create = (r, e) => new oe({
2590
- innerType: r,
2591
- typeName: p.ZodDefault,
2592
- defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2593
- ...v(e)
2594
- });
2595
- class de extends _ {
2596
- _parse(e) {
2597
- const { ctx: t } = this._processInputParams(e), n = {
2598
- ...t,
2599
- common: {
2600
- ...t.common,
2601
- issues: []
2602
- }
2603
- }, s = this._def.innerType._parse({
2604
- data: n.data,
2605
- path: n.path,
2606
- parent: {
2607
- ...n
2608
- }
2609
- });
2610
- return X(s) ? s.then((a) => ({
2611
- status: "valid",
2612
- value: a.status === "valid" ? a.value : this._def.catchValue({
2613
- get error() {
2614
- return new T(n.common.issues);
2615
- },
2616
- input: n.data
2617
- })
2618
- })) : {
2619
- status: "valid",
2620
- value: s.status === "valid" ? s.value : this._def.catchValue({
2621
- get error() {
2622
- return new T(n.common.issues);
2623
- },
2624
- input: n.data
2625
- })
2626
- };
2627
- }
2628
- removeCatch() {
2629
- return this._def.innerType;
2630
- }
2631
- }
2632
- de.create = (r, e) => new de({
2633
- innerType: r,
2634
- typeName: p.ZodCatch,
2635
- catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2636
- ...v(e)
2637
- });
2638
- class ve extends _ {
2639
- _parse(e) {
2640
- if (this._getType(e) !== h.nan) {
2641
- const n = this._getOrReturnCtx(e);
2642
- return l(n, {
2643
- code: c.invalid_type,
2644
- expected: h.nan,
2645
- received: n.parsedType
2646
- }), y;
2647
- }
2648
- return { status: "valid", value: e.data };
2649
- }
2650
- }
2651
- ve.create = (r) => new ve({
2652
- typeName: p.ZodNaN,
2653
- ...v(r)
2654
- });
2655
- const ct = Symbol("zod_brand");
2656
- class Ce extends _ {
2657
- _parse(e) {
2658
- const { ctx: t } = this._processInputParams(e), n = t.data;
2659
- return this._def.type._parse({
2660
- data: n,
2661
- path: t.path,
2662
- parent: t
2663
- });
2664
- }
2665
- unwrap() {
2666
- return this._def.type;
2667
- }
2668
- }
2669
- class ue extends _ {
2670
- _parse(e) {
2671
- const { status: t, ctx: n } = this._processInputParams(e);
2672
- if (n.common.async)
2673
- return (async () => {
2674
- const a = await this._def.in._parseAsync({
2675
- data: n.data,
2676
- path: n.path,
2677
- parent: n
2678
- });
2679
- return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), B(a.value)) : this._def.out._parseAsync({
2680
- data: a.value,
2681
- path: n.path,
2682
- parent: n
2683
- });
2684
- })();
2685
- {
2686
- const s = this._def.in._parseSync({
2687
- data: n.data,
2688
- path: n.path,
2689
- parent: n
2690
- });
2691
- return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), {
2692
- status: "dirty",
2693
- value: s.value
2694
- }) : this._def.out._parseSync({
2695
- data: s.value,
2696
- path: n.path,
2697
- parent: n
2698
- });
2699
- }
2700
- }
2701
- static create(e, t) {
2702
- return new ue({
2703
- in: e,
2704
- out: t,
2705
- typeName: p.ZodPipeline
2706
- });
2707
- }
2708
- }
2709
- class ce extends _ {
2710
- _parse(e) {
2711
- const t = this._def.innerType._parse(e), n = (s) => (Q(s) && (s.value = Object.freeze(s.value)), s);
2712
- return X(t) ? t.then((s) => n(s)) : n(t);
2713
- }
2714
- unwrap() {
2715
- return this._def.innerType;
2716
- }
2717
- }
2718
- ce.create = (r, e) => new ce({
2719
- innerType: r,
2720
- typeName: p.ZodReadonly,
2721
- ...v(e)
2722
- });
2723
- function De(r, e = {}, t) {
2724
- return r ? Y.create().superRefine((n, s) => {
2725
- var a, i;
2726
- if (!r(n)) {
2727
- const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, f = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, u = typeof o == "string" ? { message: o } : o;
2728
- s.addIssue({ code: "custom", ...u, fatal: f });
2729
- }
2730
- }) : Y.create();
2731
- }
2732
- const ut = {
2733
- object: b.lazycreate
2734
- };
2735
- var p;
2736
- (function(r) {
2737
- r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
2738
- })(p || (p = {}));
2739
- const lt = (r, e = {
2740
- message: `Input not instance of ${r.name}`
2741
- }) => De((t) => t instanceof r, e), Le = S.create, ze = P.create, ft = ve.create, ht = M.create, Ue = K.create, mt = L.create, pt = pe.create, yt = F.create, gt = ee.create, vt = Y.create, _t = D.create, xt = R.create, bt = ye.create, kt = N.create, wt = b.create, Tt = b.strictCreate, Zt = te.create, St = _e.create, Nt = re.create, Ct = O.create, Et = ne.create, It = ge.create, Ot = z.create, jt = W.create, Rt = se.create, At = ae.create, Pt = $.create, Mt = ie.create, $t = J.create, je = C.create, Vt = E.create, Dt = V.create, Lt = C.createWithPreprocess, zt = ue.create, Ut = () => Le().optional(), Bt = () => ze().optional(), Wt = () => Ue().optional(), qt = {
2742
- string: (r) => S.create({ ...r, coerce: !0 }),
2743
- number: (r) => P.create({ ...r, coerce: !0 }),
2744
- boolean: (r) => K.create({
2745
- ...r,
2746
- coerce: !0
2747
- }),
2748
- bigint: (r) => M.create({ ...r, coerce: !0 }),
2749
- date: (r) => L.create({ ...r, coerce: !0 })
2750
- }, Yt = y;
2751
- var d = /* @__PURE__ */ Object.freeze({
2752
- __proto__: null,
2753
- defaultErrorMap: q,
2754
- setErrorMap: Ye,
2755
- getErrorMap: fe,
2756
- makeIssue: he,
2757
- EMPTY_PATH: Je,
2758
- addIssueToContext: l,
2759
- ParseStatus: k,
2760
- INVALID: y,
2761
- DIRTY: B,
2762
- OK: w,
2763
- isAborted: Ze,
2764
- isDirty: Se,
2765
- isValid: Q,
2766
- isAsync: X,
2767
- get util() {
2768
- return x;
2769
- },
2770
- get objectUtil() {
2771
- return Te;
2772
- },
2773
- ZodParsedType: h,
2774
- getParsedType: A,
2775
- ZodType: _,
2776
- datetimeRegex: $e,
2777
- ZodString: S,
2778
- ZodNumber: P,
2779
- ZodBigInt: M,
2780
- ZodBoolean: K,
2781
- ZodDate: L,
2782
- ZodSymbol: pe,
2783
- ZodUndefined: F,
2784
- ZodNull: ee,
2785
- ZodAny: Y,
2786
- ZodUnknown: D,
2787
- ZodNever: R,
2788
- ZodVoid: ye,
2789
- ZodArray: N,
2790
- ZodObject: b,
2791
- ZodUnion: te,
2792
- ZodDiscriminatedUnion: _e,
2793
- ZodIntersection: re,
2794
- ZodTuple: O,
2795
- ZodRecord: ne,
2796
- ZodMap: ge,
2797
- ZodSet: z,
2798
- ZodFunction: W,
2799
- ZodLazy: se,
2800
- ZodLiteral: ae,
2801
- ZodEnum: $,
2802
- ZodNativeEnum: ie,
2803
- ZodPromise: J,
2804
- ZodEffects: C,
2805
- ZodTransformer: C,
2806
- ZodOptional: E,
2807
- ZodNullable: V,
2808
- ZodDefault: oe,
2809
- ZodCatch: de,
2810
- ZodNaN: ve,
2811
- BRAND: ct,
2812
- ZodBranded: Ce,
2813
- ZodPipeline: ue,
2814
- ZodReadonly: ce,
2815
- custom: De,
2816
- Schema: _,
2817
- ZodSchema: _,
2818
- late: ut,
2819
- get ZodFirstPartyTypeKind() {
2820
- return p;
2821
- },
2822
- coerce: qt,
2823
- any: vt,
2824
- array: kt,
2825
- bigint: ht,
2826
- boolean: Ue,
2827
- date: mt,
2828
- discriminatedUnion: St,
2829
- effect: je,
2830
- enum: Pt,
2831
- function: jt,
2832
- instanceof: lt,
2833
- intersection: Nt,
2834
- lazy: Rt,
2835
- literal: At,
2836
- map: It,
2837
- nan: ft,
2838
- nativeEnum: Mt,
2839
- never: xt,
2840
- null: gt,
2841
- nullable: Dt,
2842
- number: ze,
2843
- object: wt,
2844
- oboolean: Wt,
2845
- onumber: Bt,
2846
- optional: Vt,
2847
- ostring: Ut,
2848
- pipeline: zt,
2849
- preprocess: Lt,
2850
- promise: $t,
2851
- record: Et,
2852
- set: Ot,
2853
- strictObject: Tt,
2854
- string: Le,
2855
- symbol: pt,
2856
- transformer: je,
2857
- tuple: Ct,
2858
- undefined: yt,
2859
- union: Zt,
2860
- unknown: _t,
2861
- void: bt,
2862
- NEVER: Yt,
2863
- ZodIssueCode: c,
2864
- quotelessJson: qe,
2865
- ZodError: T
2866
- });
2867
- const Be = d.object({
2868
- country: d.string(),
2869
- city: d.string(),
2870
- street: d.string(),
2871
- streetNumber: d.string(),
2872
- floor: d.string(),
2873
- apartmentEnterNumber: d.string(),
2874
- apartmentNumber: d.string()
2875
- }), Jt = d.object({
2876
- type: d.literal("Profile"),
2877
- id: d.string(),
2878
- companyId: d.string(),
2879
- storeId: d.string(),
2880
- tenantId: d.string(),
2881
- clientType: d.enum(["user", "company"]),
2882
- displayName: d.string().min(1),
2883
- email: d.string().email(),
2884
- phoneNumber: d.object({
2885
- code: d.string(),
2886
- number: d.string()
2887
- }),
2888
- address: Be,
2889
- isAnonymous: d.boolean(),
2890
- createdDate: d.number(),
2891
- lastActivityDate: d.number()
2892
- });
2893
- function Ht() {
2894
- return {
2895
- type: "Profile",
2896
- id: "",
2897
- companyId: "",
2898
- storeId: "",
2899
- tenantId: "",
2900
- clientType: "user",
2901
- displayName: "",
2902
- email: "",
2903
- phoneNumber: { code: "+972", number: "" },
2904
- address: {
2905
- country: "",
2906
- city: "",
2907
- street: "",
2908
- streetNumber: "",
2909
- floor: "",
2910
- apartmentEnterNumber: "",
2911
- apartmentNumber: ""
2912
- },
2913
- createdDate: 0,
2914
- lastActivityDate: 0,
2915
- isAnonymous: !0
2916
- };
2917
- }
2918
- const le = d.object({
2919
- lang: d.string().min(1),
2920
- value: d.string().min(1)
2921
- }), We = d.object({
2922
- id: d.string().min(1),
2923
- companyId: d.string().min(1),
2924
- storeId: d.string().min(1),
2925
- parentId: d.string().nullish(),
2926
- tag: d.string().min(1),
2927
- locales: d.array(le),
2928
- depth: d.number()
2929
- }), Ee = We.extend({
2930
- children: d.lazy(() => Ee.array())
2931
- }), Gt = We.extend({
2932
- index: d.number(),
2933
- depth: d.number(),
2934
- collapsed: d.boolean().optional(),
2935
- children: d.array(Ee)
2936
- }), we = d.string(), xe = d.object({
2937
- type: d.literal("Product"),
2938
- storeId: we,
2939
- companyId: we,
2940
- id: d.string(),
2941
- objectID: d.string(),
2942
- sku: d.string().min(1),
2943
- name: d.array(le),
2944
- description: d.array(le),
2945
- isPublished: d.boolean(),
2946
- vat: d.boolean(),
2947
- priceType: d.object({
2948
- type: d.enum(["unit", "kg", "gram", "liter", "ml"]),
2949
- value: d.number()
2950
- }),
2951
- price: d.number().positive(),
2952
- purchasePrice: d.number().optional(),
2953
- profitPercentage: d.number().optional(),
2954
- currency: d.literal("ILS"),
2955
- discount: d.object({
2956
- type: d.enum(["number", "percent", "none"]),
2957
- value: d.number()
2958
- }),
2959
- weight: d.object({
2960
- value: d.number(),
2961
- unit: d.enum(["kg", "gram", "none"])
2962
- }),
2963
- volume: d.object({
2964
- value: d.number(),
2965
- unit: d.enum(["liter", "ml", "none"])
2966
- }),
2967
- images: d.array(d.object({ url: d.string().url(), id: d.string() })),
2968
- manufacturer: we,
2969
- brand: d.string(),
2970
- importer: d.string(),
2971
- supplier: d.string(),
2972
- ingredients: d.array(le),
2973
- created_at: d.number(),
2974
- updated_at: d.number(),
2975
- categoryList: d.array(Ee),
2976
- // generated
2977
- categories: d.object({
2978
- lvl0: d.array(d.string()),
2979
- lvl1: d.array(d.string()),
2980
- lvl2: d.array(d.string()),
2981
- lvl3: d.array(d.string()),
2982
- lvl4: d.array(d.string())
2983
- }),
2984
- categoryNames: d.array(d.string())
2985
- }), Qt = xe.omit({
2986
- id: !0,
2987
- categories: !0,
2988
- images: !0
2989
- }).extend({
2990
- image: d.instanceof(File).optional()
2991
- }), Xt = xe.extend({
2992
- image: d.instanceof(File).optional()
2993
- }), Kt = d.object({
2994
- type: d.literal("Order"),
2995
- id: d.string(),
2996
- companyId: d.string(),
2997
- storeId: d.string(),
2998
- userId: d.string(),
2999
- status: d.enum(["pending", "processing", "delivered", "canceled", "completed", "refunded"]),
3000
- paymentStatus: d.enum(["pending", "completed", "failed", "refunded"]),
3001
- cart: d.object({
3002
- id: d.string(),
3003
- items: d.array(d.object({ product: xe, amount: d.number() })),
3004
- cartTotal: d.number(),
3005
- cartDiscount: d.number(),
3006
- cartVat: d.number()
3007
- }),
3008
- date: d.number(),
3009
- deliveryDate: d.number().optional(),
3010
- client: Jt,
3011
- address: Be
3012
- }), Ft = d.object({
3013
- type: d.literal("FavoriteProduct"),
3014
- id: d.string().uuid(),
3015
- companyId: d.string().uuid(),
3016
- storeId: d.string().uuid(),
3017
- userId: d.string().uuid(),
3018
- productId: d.string().uuid()
3019
- }), er = d.object({
3020
- type: d.literal("Cart"),
3021
- id: d.string().uuid(),
3022
- companyId: d.string().uuid(),
3023
- storeId: d.string().uuid(),
3024
- userId: d.string().uuid(),
3025
- status: d.enum(["active", "draft", "completed"]),
3026
- items: d.array(
3027
- d.object({
3028
- product: xe,
3029
- amount: d.number().int().positive({ message: "Quantity must be a positive integer." })
3030
- })
3031
- )
3032
- });
3033
- export {
3034
- We as BaseCategorySchema,
3035
- er as CartSchema,
3036
- Ee as CategorySchema,
3037
- Xt as EditProductSchema,
3038
- Ft as FavoriteProductSchema,
3039
- Qt as NewProductSchema,
3040
- Kt as OrderSchema,
3041
- xe as ProductSchema,
3042
- Jt as ProfileSchema,
3043
- Gt as TFlattenCategorySchema,
3044
- Ht as createEmptyProfile
3045
- };
3046
- //# sourceMappingURL=core.es.js.map