@jsdev_ninja/core 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +1055 -1032
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/entities/Order.d.ts +5 -0
- package/dist/lib/entities/Order.d.ts.map +1 -1
- package/dist/lib/entities/Order.js +4 -0
- package/dist/lib/utils/getCartCost.test.d.ts +2 -0
- package/dist/lib/utils/getCartCost.test.d.ts.map +1 -0
- package/dist/lib/utils/getCartCost.test.js +236 -0
- package/dist/lib/utils/index.d.ts +26 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +45 -2
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.es.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var ut = Object.defineProperty;
|
|
2
|
+
var dt = (n, e, t) => e in n ? ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var ze = (n, e, t) => dt(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var b;
|
|
5
5
|
(function(n) {
|
|
6
|
-
n.assertEqual = (
|
|
7
|
-
function e(
|
|
6
|
+
n.assertEqual = (a) => a;
|
|
7
|
+
function e(a) {
|
|
8
8
|
}
|
|
9
9
|
n.assertIs = e;
|
|
10
|
-
function t(
|
|
10
|
+
function t(a) {
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
|
-
n.assertNever = t, n.arrayToEnum = (
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (a) => {
|
|
14
14
|
const s = {};
|
|
15
|
-
for (const
|
|
16
|
-
s[
|
|
15
|
+
for (const o of a)
|
|
16
|
+
s[o] = o;
|
|
17
17
|
return s;
|
|
18
|
-
}, n.getValidEnumValues = (
|
|
19
|
-
const s = n.objectKeys(
|
|
20
|
-
for (const
|
|
21
|
-
c
|
|
22
|
-
return n.objectValues(
|
|
23
|
-
}, n.objectValues = (
|
|
24
|
-
return
|
|
25
|
-
}), n.objectKeys = typeof Object.keys == "function" ? (
|
|
18
|
+
}, n.getValidEnumValues = (a) => {
|
|
19
|
+
const s = n.objectKeys(a).filter((c) => typeof a[a[c]] != "number"), o = {};
|
|
20
|
+
for (const c of s)
|
|
21
|
+
o[c] = a[c];
|
|
22
|
+
return n.objectValues(o);
|
|
23
|
+
}, n.objectValues = (a) => n.objectKeys(a).map(function(s) {
|
|
24
|
+
return a[s];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
26
26
|
const s = [];
|
|
27
|
-
for (const
|
|
28
|
-
Object.prototype.hasOwnProperty.call(
|
|
27
|
+
for (const o in a)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(a, o) && s.push(o);
|
|
29
29
|
return s;
|
|
30
|
-
}, n.find = (
|
|
31
|
-
for (const
|
|
32
|
-
if (s(
|
|
33
|
-
return
|
|
34
|
-
}, n.isInteger = typeof Number.isInteger == "function" ? (
|
|
35
|
-
function a
|
|
36
|
-
return
|
|
30
|
+
}, n.find = (a, s) => {
|
|
31
|
+
for (const o of a)
|
|
32
|
+
if (s(o))
|
|
33
|
+
return o;
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && isFinite(a) && Math.floor(a) === a;
|
|
35
|
+
function i(a, s = " | ") {
|
|
36
|
+
return a.map((o) => typeof o == "string" ? `'${o}'` : o).join(s);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues =
|
|
38
|
+
n.joinValues = i, n.jsonStringifyReplacer = (a, s) => typeof s == "bigint" ? s.toString() : s;
|
|
39
39
|
})(b || (b = {}));
|
|
40
|
-
var
|
|
40
|
+
var Ze;
|
|
41
41
|
(function(n) {
|
|
42
42
|
n.mergeShapes = (e, t) => ({
|
|
43
43
|
...e,
|
|
44
44
|
...t
|
|
45
45
|
// second overwrites first
|
|
46
46
|
});
|
|
47
|
-
})(
|
|
47
|
+
})(Ze || (Ze = {}));
|
|
48
48
|
const p = b.arrayToEnum([
|
|
49
49
|
"string",
|
|
50
50
|
"nan",
|
|
@@ -66,7 +66,7 @@ const p = b.arrayToEnum([
|
|
|
66
66
|
"never",
|
|
67
67
|
"map",
|
|
68
68
|
"set"
|
|
69
|
-
]),
|
|
69
|
+
]), R = (n) => {
|
|
70
70
|
switch (typeof n) {
|
|
71
71
|
case "undefined":
|
|
72
72
|
return p.undefined;
|
|
@@ -104,16 +104,16 @@ const p = b.arrayToEnum([
|
|
|
104
104
|
"invalid_intersection_types",
|
|
105
105
|
"not_multiple_of",
|
|
106
106
|
"not_finite"
|
|
107
|
-
]),
|
|
107
|
+
]), lt = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
108
108
|
class A extends Error {
|
|
109
109
|
get errors() {
|
|
110
110
|
return this.issues;
|
|
111
111
|
}
|
|
112
112
|
constructor(e) {
|
|
113
|
-
super(), this.issues = [], this.addIssue = (
|
|
114
|
-
this.issues = [...this.issues,
|
|
115
|
-
}, this.addIssues = (
|
|
116
|
-
this.issues = [...this.issues, ...
|
|
113
|
+
super(), this.issues = [], this.addIssue = (i) => {
|
|
114
|
+
this.issues = [...this.issues, i];
|
|
115
|
+
}, this.addIssues = (i = []) => {
|
|
116
|
+
this.issues = [...this.issues, ...i];
|
|
117
117
|
};
|
|
118
118
|
const t = new.target.prototype;
|
|
119
119
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -121,25 +121,25 @@ class A extends Error {
|
|
|
121
121
|
format(e) {
|
|
122
122
|
const t = e || function(s) {
|
|
123
123
|
return s.message;
|
|
124
|
-
},
|
|
125
|
-
for (const
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
else if (
|
|
129
|
-
|
|
130
|
-
else if (
|
|
131
|
-
|
|
132
|
-
else if (
|
|
133
|
-
|
|
124
|
+
}, i = { _errors: [] }, a = (s) => {
|
|
125
|
+
for (const o of s.issues)
|
|
126
|
+
if (o.code === "invalid_union")
|
|
127
|
+
o.unionErrors.map(a);
|
|
128
|
+
else if (o.code === "invalid_return_type")
|
|
129
|
+
a(o.returnTypeError);
|
|
130
|
+
else if (o.code === "invalid_arguments")
|
|
131
|
+
a(o.argumentsError);
|
|
132
|
+
else if (o.path.length === 0)
|
|
133
|
+
i._errors.push(t(o));
|
|
134
134
|
else {
|
|
135
|
-
let
|
|
136
|
-
for (; l <
|
|
137
|
-
const u =
|
|
138
|
-
l ===
|
|
135
|
+
let c = i, l = 0;
|
|
136
|
+
for (; l < o.path.length; ) {
|
|
137
|
+
const u = o.path[l];
|
|
138
|
+
l === o.path.length - 1 ? (c[u] = c[u] || { _errors: [] }, c[u]._errors.push(t(o))) : c[u] = c[u] || { _errors: [] }, c = c[u], l++;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return a(this), i;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
145
|
if (!(e instanceof A))
|
|
@@ -155,17 +155,17 @@ class A extends Error {
|
|
|
155
155
|
return this.issues.length === 0;
|
|
156
156
|
}
|
|
157
157
|
flatten(e = (t) => t.message) {
|
|
158
|
-
const t = {},
|
|
159
|
-
for (const
|
|
160
|
-
|
|
161
|
-
return { formErrors:
|
|
158
|
+
const t = {}, i = [];
|
|
159
|
+
for (const a of this.issues)
|
|
160
|
+
a.path.length > 0 ? (t[a.path[0]] = t[a.path[0]] || [], t[a.path[0]].push(e(a))) : i.push(e(a));
|
|
161
|
+
return { formErrors: i, fieldErrors: t };
|
|
162
162
|
}
|
|
163
163
|
get formErrors() {
|
|
164
164
|
return this.flatten();
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
A.create = (n) => new A(n);
|
|
168
|
-
const
|
|
168
|
+
const G = (n, e) => {
|
|
169
169
|
let t;
|
|
170
170
|
switch (n.code) {
|
|
171
171
|
case d.invalid_type:
|
|
@@ -221,36 +221,36 @@ const X = (n, e) => {
|
|
|
221
221
|
}
|
|
222
222
|
return { message: t };
|
|
223
223
|
};
|
|
224
|
-
let
|
|
225
|
-
function
|
|
226
|
-
|
|
224
|
+
let Be = G;
|
|
225
|
+
function mt(n) {
|
|
226
|
+
Be = n;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
228
|
+
function ve() {
|
|
229
|
+
return Be;
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
const { data: e, path: t, errorMaps:
|
|
233
|
-
...
|
|
231
|
+
const _e = (n) => {
|
|
232
|
+
const { data: e, path: t, errorMaps: i, issueData: a } = n, s = [...t, ...a.path || []], o = {
|
|
233
|
+
...a,
|
|
234
234
|
path: s
|
|
235
235
|
};
|
|
236
|
-
if (
|
|
236
|
+
if (a.message !== void 0)
|
|
237
237
|
return {
|
|
238
|
-
...
|
|
238
|
+
...a,
|
|
239
239
|
path: s,
|
|
240
|
-
message:
|
|
240
|
+
message: a.message
|
|
241
241
|
};
|
|
242
|
-
let
|
|
243
|
-
const l =
|
|
242
|
+
let c = "";
|
|
243
|
+
const l = i.filter((u) => !!u).slice().reverse();
|
|
244
244
|
for (const u of l)
|
|
245
|
-
|
|
245
|
+
c = u(o, { data: e, defaultError: c }).message;
|
|
246
246
|
return {
|
|
247
|
-
...
|
|
247
|
+
...a,
|
|
248
248
|
path: s,
|
|
249
|
-
message:
|
|
249
|
+
message: c
|
|
250
250
|
};
|
|
251
|
-
},
|
|
251
|
+
}, pt = [];
|
|
252
252
|
function m(n, e) {
|
|
253
|
-
const t =
|
|
253
|
+
const t = ve(), i = _e({
|
|
254
254
|
issueData: e,
|
|
255
255
|
data: n.data,
|
|
256
256
|
path: n.path,
|
|
@@ -261,13 +261,13 @@ function m(n, e) {
|
|
|
261
261
|
// then schema-bound map if available
|
|
262
262
|
t,
|
|
263
263
|
// then global override map
|
|
264
|
-
t ===
|
|
264
|
+
t === G ? void 0 : G
|
|
265
265
|
// then global default map
|
|
266
|
-
].filter((
|
|
266
|
+
].filter((a) => !!a)
|
|
267
267
|
});
|
|
268
|
-
n.common.issues.push(
|
|
268
|
+
n.common.issues.push(i);
|
|
269
269
|
}
|
|
270
|
-
class
|
|
270
|
+
class T {
|
|
271
271
|
constructor() {
|
|
272
272
|
this.value = "valid";
|
|
273
273
|
}
|
|
@@ -278,44 +278,44 @@ class S {
|
|
|
278
278
|
this.value !== "aborted" && (this.value = "aborted");
|
|
279
279
|
}
|
|
280
280
|
static mergeArray(e, t) {
|
|
281
|
-
const
|
|
282
|
-
for (const
|
|
283
|
-
if (
|
|
281
|
+
const i = [];
|
|
282
|
+
for (const a of t) {
|
|
283
|
+
if (a.status === "aborted")
|
|
284
284
|
return y;
|
|
285
|
-
|
|
285
|
+
a.status === "dirty" && e.dirty(), i.push(a.value);
|
|
286
286
|
}
|
|
287
|
-
return { status: e.value, value:
|
|
287
|
+
return { status: e.value, value: i };
|
|
288
288
|
}
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
292
|
-
const s = await
|
|
293
|
-
|
|
290
|
+
const i = [];
|
|
291
|
+
for (const a of t) {
|
|
292
|
+
const s = await a.key, o = await a.value;
|
|
293
|
+
i.push({
|
|
294
294
|
key: s,
|
|
295
|
-
value:
|
|
295
|
+
value: o
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
return
|
|
298
|
+
return T.mergeObjectSync(e, i);
|
|
299
299
|
}
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
|
-
const
|
|
302
|
-
for (const
|
|
303
|
-
const { key: s, value:
|
|
304
|
-
if (s.status === "aborted" ||
|
|
301
|
+
const i = {};
|
|
302
|
+
for (const a of t) {
|
|
303
|
+
const { key: s, value: o } = a;
|
|
304
|
+
if (s.status === "aborted" || o.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
s.status === "dirty" && e.dirty(),
|
|
306
|
+
s.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof o.value < "u" || a.alwaysSet) && (i[s.value] = o.value);
|
|
307
307
|
}
|
|
308
|
-
return { status: e.value, value:
|
|
308
|
+
return { status: e.value, value: i };
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
const y = Object.freeze({
|
|
312
312
|
status: "aborted"
|
|
313
|
-
}),
|
|
314
|
-
function
|
|
313
|
+
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }), Oe = (n) => n.status === "aborted", Pe = (n) => n.status === "dirty", q = (n) => n.status === "valid", re = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
314
|
+
function be(n, e, t, i) {
|
|
315
315
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
316
316
|
return e.get(n);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function We(n, e, t, i, a) {
|
|
319
319
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
320
320
|
return e.set(n, t), t;
|
|
321
321
|
}
|
|
@@ -323,17 +323,17 @@ var h;
|
|
|
323
323
|
(function(n) {
|
|
324
324
|
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
325
325
|
})(h || (h = {}));
|
|
326
|
-
var
|
|
327
|
-
class
|
|
328
|
-
constructor(e, t,
|
|
329
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
326
|
+
var te, ne;
|
|
327
|
+
class P {
|
|
328
|
+
constructor(e, t, i, a) {
|
|
329
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = i, this._key = a;
|
|
330
330
|
}
|
|
331
331
|
get path() {
|
|
332
332
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
335
|
+
const Ve = (n, e) => {
|
|
336
|
+
if (q(e))
|
|
337
337
|
return { success: !0, data: e.value };
|
|
338
338
|
if (!n.common.issues.length)
|
|
339
339
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -350,27 +350,27 @@ const Me = (n, e) => {
|
|
|
350
350
|
function v(n) {
|
|
351
351
|
if (!n)
|
|
352
352
|
return {};
|
|
353
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
354
|
-
if (e && (t ||
|
|
353
|
+
const { errorMap: e, invalid_type_error: t, required_error: i, description: a } = n;
|
|
354
|
+
if (e && (t || i))
|
|
355
355
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
356
|
-
return e ? { errorMap: e, description:
|
|
356
|
+
return e ? { errorMap: e, description: a } : { errorMap: (o, c) => {
|
|
357
357
|
var l, u;
|
|
358
358
|
const { message: f } = n;
|
|
359
|
-
return
|
|
360
|
-
}, description:
|
|
359
|
+
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (l = f ?? i) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (u = f ?? t) !== null && u !== void 0 ? u : c.defaultError };
|
|
360
|
+
}, description: a };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
363
363
|
get description() {
|
|
364
364
|
return this._def.description;
|
|
365
365
|
}
|
|
366
366
|
_getType(e) {
|
|
367
|
-
return
|
|
367
|
+
return R(e.data);
|
|
368
368
|
}
|
|
369
369
|
_getOrReturnCtx(e, t) {
|
|
370
370
|
return t || {
|
|
371
371
|
common: e.parent.common,
|
|
372
372
|
data: e.data,
|
|
373
|
-
parsedType:
|
|
373
|
+
parsedType: R(e.data),
|
|
374
374
|
schemaErrorMap: this._def.errorMap,
|
|
375
375
|
path: e.path,
|
|
376
376
|
parent: e.parent
|
|
@@ -378,11 +378,11 @@ class _ {
|
|
|
378
378
|
}
|
|
379
379
|
_processInputParams(e) {
|
|
380
380
|
return {
|
|
381
|
-
status: new
|
|
381
|
+
status: new T(),
|
|
382
382
|
ctx: {
|
|
383
383
|
common: e.parent.common,
|
|
384
384
|
data: e.data,
|
|
385
|
-
parsedType:
|
|
385
|
+
parsedType: R(e.data),
|
|
386
386
|
schemaErrorMap: this._def.errorMap,
|
|
387
387
|
path: e.path,
|
|
388
388
|
parent: e.parent
|
|
@@ -391,7 +391,7 @@ class _ {
|
|
|
391
391
|
}
|
|
392
392
|
_parseSync(e) {
|
|
393
393
|
const t = this._parse(e);
|
|
394
|
-
if (
|
|
394
|
+
if (re(t))
|
|
395
395
|
throw new Error("Synchronous parse encountered promise.");
|
|
396
396
|
return t;
|
|
397
397
|
}
|
|
@@ -400,30 +400,30 @@ class _ {
|
|
|
400
400
|
return Promise.resolve(t);
|
|
401
401
|
}
|
|
402
402
|
parse(e, t) {
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
406
|
-
throw
|
|
403
|
+
const i = this.safeParse(e, t);
|
|
404
|
+
if (i.success)
|
|
405
|
+
return i.data;
|
|
406
|
+
throw i.error;
|
|
407
407
|
}
|
|
408
408
|
safeParse(e, t) {
|
|
409
|
-
var
|
|
410
|
-
const
|
|
409
|
+
var i;
|
|
410
|
+
const a = {
|
|
411
411
|
common: {
|
|
412
412
|
issues: [],
|
|
413
|
-
async: (
|
|
413
|
+
async: (i = t == null ? void 0 : t.async) !== null && i !== void 0 ? i : !1,
|
|
414
414
|
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
415
415
|
},
|
|
416
416
|
path: (t == null ? void 0 : t.path) || [],
|
|
417
417
|
schemaErrorMap: this._def.errorMap,
|
|
418
418
|
parent: null,
|
|
419
419
|
data: e,
|
|
420
|
-
parsedType:
|
|
421
|
-
}, s = this._parseSync({ data: e, path:
|
|
422
|
-
return
|
|
420
|
+
parsedType: R(e)
|
|
421
|
+
}, s = this._parseSync({ data: e, path: a.path, parent: a });
|
|
422
|
+
return Ve(a, s);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
|
-
var t,
|
|
426
|
-
const
|
|
425
|
+
var t, i;
|
|
426
|
+
const a = {
|
|
427
427
|
common: {
|
|
428
428
|
issues: [],
|
|
429
429
|
async: !!this["~standard"].async
|
|
@@ -432,36 +432,36 @@ class _ {
|
|
|
432
432
|
schemaErrorMap: this._def.errorMap,
|
|
433
433
|
parent: null,
|
|
434
434
|
data: e,
|
|
435
|
-
parsedType:
|
|
435
|
+
parsedType: R(e)
|
|
436
436
|
};
|
|
437
437
|
if (!this["~standard"].async)
|
|
438
438
|
try {
|
|
439
|
-
const s = this._parseSync({ data: e, path: [], parent:
|
|
440
|
-
return
|
|
439
|
+
const s = this._parseSync({ data: e, path: [], parent: a });
|
|
440
|
+
return q(s) ? {
|
|
441
441
|
value: s.value
|
|
442
442
|
} : {
|
|
443
|
-
issues:
|
|
443
|
+
issues: a.common.issues
|
|
444
444
|
};
|
|
445
445
|
} catch (s) {
|
|
446
|
-
!((
|
|
446
|
+
!((i = (t = s == null ? void 0 : s.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || i === void 0) && i.includes("encountered") && (this["~standard"].async = !0), a.common = {
|
|
447
447
|
issues: [],
|
|
448
448
|
async: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
451
|
+
return this._parseAsync({ data: e, path: [], parent: a }).then((s) => q(s) ? {
|
|
452
452
|
value: s.value
|
|
453
453
|
} : {
|
|
454
|
-
issues:
|
|
454
|
+
issues: a.common.issues
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
async parseAsync(e, t) {
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
461
|
-
throw
|
|
458
|
+
const i = await this.safeParseAsync(e, t);
|
|
459
|
+
if (i.success)
|
|
460
|
+
return i.data;
|
|
461
|
+
throw i.error;
|
|
462
462
|
}
|
|
463
463
|
async safeParseAsync(e, t) {
|
|
464
|
-
const
|
|
464
|
+
const i = {
|
|
465
465
|
common: {
|
|
466
466
|
issues: [],
|
|
467
467
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -471,22 +471,22 @@ class _ {
|
|
|
471
471
|
schemaErrorMap: this._def.errorMap,
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
|
-
parsedType:
|
|
475
|
-
},
|
|
476
|
-
return
|
|
474
|
+
parsedType: R(e)
|
|
475
|
+
}, a = this._parse({ data: e, path: i.path, parent: i }), s = await (re(a) ? a : Promise.resolve(a));
|
|
476
|
+
return Ve(i, s);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
|
-
const
|
|
480
|
-
return this._refinement((
|
|
481
|
-
const
|
|
479
|
+
const i = (a) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(a) : t;
|
|
480
|
+
return this._refinement((a, s) => {
|
|
481
|
+
const o = e(a), c = () => s.addIssue({
|
|
482
482
|
code: d.custom,
|
|
483
|
-
...a
|
|
483
|
+
...i(a)
|
|
484
484
|
});
|
|
485
|
-
return typeof Promise < "u" &&
|
|
485
|
+
return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
refinement(e, t) {
|
|
489
|
-
return this._refinement((
|
|
489
|
+
return this._refinement((i, a) => e(i) ? !0 : (a.addIssue(typeof t == "function" ? t(i, a) : t), !1));
|
|
490
490
|
}
|
|
491
491
|
_refinement(e) {
|
|
492
492
|
return new j({
|
|
@@ -506,10 +506,10 @@ class _ {
|
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
optional() {
|
|
509
|
-
return
|
|
509
|
+
return O.create(this, this._def);
|
|
510
510
|
}
|
|
511
511
|
nullable() {
|
|
512
|
-
return
|
|
512
|
+
return F.create(this, this._def);
|
|
513
513
|
}
|
|
514
514
|
nullish() {
|
|
515
515
|
return this.nullable().optional();
|
|
@@ -518,13 +518,13 @@ class _ {
|
|
|
518
518
|
return C.create(this);
|
|
519
519
|
}
|
|
520
520
|
promise() {
|
|
521
|
-
return
|
|
521
|
+
return H.create(this, this._def);
|
|
522
522
|
}
|
|
523
523
|
or(e) {
|
|
524
|
-
return
|
|
524
|
+
return oe.create([this, e], this._def);
|
|
525
525
|
}
|
|
526
526
|
and(e) {
|
|
527
|
-
return
|
|
527
|
+
return ce.create(this, e, this._def);
|
|
528
528
|
}
|
|
529
529
|
transform(e) {
|
|
530
530
|
return new j({
|
|
@@ -536,7 +536,7 @@ class _ {
|
|
|
536
536
|
}
|
|
537
537
|
default(e) {
|
|
538
538
|
const t = typeof e == "function" ? e : () => e;
|
|
539
|
-
return new
|
|
539
|
+
return new pe({
|
|
540
540
|
...v(this._def),
|
|
541
541
|
innerType: this,
|
|
542
542
|
defaultValue: t,
|
|
@@ -544,7 +544,7 @@ class _ {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
brand() {
|
|
547
|
-
return new
|
|
547
|
+
return new Re({
|
|
548
548
|
typeName: g.ZodBranded,
|
|
549
549
|
type: this,
|
|
550
550
|
...v(this._def)
|
|
@@ -552,7 +552,7 @@ class _ {
|
|
|
552
552
|
}
|
|
553
553
|
catch(e) {
|
|
554
554
|
const t = typeof e == "function" ? e : () => e;
|
|
555
|
-
return new
|
|
555
|
+
return new fe({
|
|
556
556
|
...v(this._def),
|
|
557
557
|
innerType: this,
|
|
558
558
|
catchValue: t,
|
|
@@ -567,10 +567,10 @@ class _ {
|
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
pipe(e) {
|
|
570
|
-
return
|
|
570
|
+
return ge.create(this, e);
|
|
571
571
|
}
|
|
572
572
|
readonly() {
|
|
573
|
-
return
|
|
573
|
+
return he.create(this);
|
|
574
574
|
}
|
|
575
575
|
isOptional() {
|
|
576
576
|
return this.safeParse(void 0).success;
|
|
@@ -579,36 +579,36 @@ class _ {
|
|
|
579
579
|
return this.safeParse(null).success;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
const
|
|
583
|
-
let
|
|
584
|
-
const
|
|
585
|
-
function
|
|
582
|
+
const ft = /^c[^\s-]{8,}$/i, ht = /^[0-9a-z]+$/, gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, yt = /^[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, vt = /^[a-z0-9_-]{21}$/i, _t = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, bt = /^[-+]?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)?)??$/, xt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
|
+
let je;
|
|
584
|
+
const wt = /^(?:(?: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])$/, Tt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, St = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, It = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, At = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Nt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Qe = "((\\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])))", Ct = new RegExp(`^${Qe}$`);
|
|
585
|
+
function Ye(n) {
|
|
586
586
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
587
587
|
return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
return new RegExp(`^${
|
|
589
|
+
function jt(n) {
|
|
590
|
+
return new RegExp(`^${Ye(n)}$`);
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
let e = `${
|
|
592
|
+
function Xe(n) {
|
|
593
|
+
let e = `${Qe}T${Ye(n)}`;
|
|
594
594
|
const t = [];
|
|
595
595
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
596
596
|
}
|
|
597
|
-
function
|
|
598
|
-
return !!((e === "v4" || !e) &&
|
|
597
|
+
function Zt(n, e) {
|
|
598
|
+
return !!((e === "v4" || !e) && wt.test(n) || (e === "v6" || !e) && St.test(n));
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
if (!
|
|
600
|
+
function Ot(n, e) {
|
|
601
|
+
if (!_t.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
|
-
const [t] = n.split("."),
|
|
605
|
-
return !(typeof
|
|
604
|
+
const [t] = n.split("."), i = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), a = JSON.parse(atob(i));
|
|
605
|
+
return !(typeof a != "object" || a === null || !a.typ || !a.alg || e && a.alg !== e);
|
|
606
606
|
} catch {
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return !!((e === "v4" || !e) &&
|
|
610
|
+
function Pt(n, e) {
|
|
611
|
+
return !!((e === "v4" || !e) && Tt.test(n) || (e === "v6" || !e) && It.test(n));
|
|
612
612
|
}
|
|
613
613
|
class N extends _ {
|
|
614
614
|
_parse(e) {
|
|
@@ -620,156 +620,156 @@ class N extends _ {
|
|
|
620
620
|
received: s.parsedType
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
let
|
|
623
|
+
const i = new T();
|
|
624
|
+
let a;
|
|
625
625
|
for (const s of this._def.checks)
|
|
626
626
|
if (s.kind === "min")
|
|
627
|
-
e.data.length < s.value && (
|
|
627
|
+
e.data.length < s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
628
628
|
code: d.too_small,
|
|
629
629
|
minimum: s.value,
|
|
630
630
|
type: "string",
|
|
631
631
|
inclusive: !0,
|
|
632
632
|
exact: !1,
|
|
633
633
|
message: s.message
|
|
634
|
-
}),
|
|
634
|
+
}), i.dirty());
|
|
635
635
|
else if (s.kind === "max")
|
|
636
|
-
e.data.length > s.value && (
|
|
636
|
+
e.data.length > s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
637
637
|
code: d.too_big,
|
|
638
638
|
maximum: s.value,
|
|
639
639
|
type: "string",
|
|
640
640
|
inclusive: !0,
|
|
641
641
|
exact: !1,
|
|
642
642
|
message: s.message
|
|
643
|
-
}),
|
|
643
|
+
}), i.dirty());
|
|
644
644
|
else if (s.kind === "length") {
|
|
645
|
-
const
|
|
646
|
-
(
|
|
645
|
+
const o = e.data.length > s.value, c = e.data.length < s.value;
|
|
646
|
+
(o || c) && (a = this._getOrReturnCtx(e, a), o ? m(a, {
|
|
647
647
|
code: d.too_big,
|
|
648
648
|
maximum: s.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
652
|
message: s.message
|
|
653
|
-
}) :
|
|
653
|
+
}) : c && m(a, {
|
|
654
654
|
code: d.too_small,
|
|
655
655
|
minimum: s.value,
|
|
656
656
|
type: "string",
|
|
657
657
|
inclusive: !0,
|
|
658
658
|
exact: !0,
|
|
659
659
|
message: s.message
|
|
660
|
-
}),
|
|
660
|
+
}), i.dirty());
|
|
661
661
|
} else if (s.kind === "email")
|
|
662
|
-
|
|
662
|
+
xt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
663
663
|
validation: "email",
|
|
664
664
|
code: d.invalid_string,
|
|
665
665
|
message: s.message
|
|
666
|
-
}),
|
|
666
|
+
}), i.dirty());
|
|
667
667
|
else if (s.kind === "emoji")
|
|
668
|
-
|
|
668
|
+
je || (je = new RegExp(kt, "u")), je.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
669
669
|
validation: "emoji",
|
|
670
670
|
code: d.invalid_string,
|
|
671
671
|
message: s.message
|
|
672
|
-
}),
|
|
672
|
+
}), i.dirty());
|
|
673
673
|
else if (s.kind === "uuid")
|
|
674
|
-
|
|
674
|
+
yt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
675
675
|
validation: "uuid",
|
|
676
676
|
code: d.invalid_string,
|
|
677
677
|
message: s.message
|
|
678
|
-
}),
|
|
678
|
+
}), i.dirty());
|
|
679
679
|
else if (s.kind === "nanoid")
|
|
680
|
-
|
|
680
|
+
vt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
681
681
|
validation: "nanoid",
|
|
682
682
|
code: d.invalid_string,
|
|
683
683
|
message: s.message
|
|
684
|
-
}),
|
|
684
|
+
}), i.dirty());
|
|
685
685
|
else if (s.kind === "cuid")
|
|
686
|
-
|
|
686
|
+
ft.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
687
687
|
validation: "cuid",
|
|
688
688
|
code: d.invalid_string,
|
|
689
689
|
message: s.message
|
|
690
|
-
}),
|
|
690
|
+
}), i.dirty());
|
|
691
691
|
else if (s.kind === "cuid2")
|
|
692
|
-
|
|
692
|
+
ht.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
693
693
|
validation: "cuid2",
|
|
694
694
|
code: d.invalid_string,
|
|
695
695
|
message: s.message
|
|
696
|
-
}),
|
|
696
|
+
}), i.dirty());
|
|
697
697
|
else if (s.kind === "ulid")
|
|
698
|
-
|
|
698
|
+
gt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
699
699
|
validation: "ulid",
|
|
700
700
|
code: d.invalid_string,
|
|
701
701
|
message: s.message
|
|
702
|
-
}),
|
|
702
|
+
}), i.dirty());
|
|
703
703
|
else if (s.kind === "url")
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
a = this._getOrReturnCtx(e, a), m(a, {
|
|
708
708
|
validation: "url",
|
|
709
709
|
code: d.invalid_string,
|
|
710
710
|
message: s.message
|
|
711
|
-
}),
|
|
711
|
+
}), i.dirty();
|
|
712
712
|
}
|
|
713
|
-
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (
|
|
713
|
+
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
714
714
|
validation: "regex",
|
|
715
715
|
code: d.invalid_string,
|
|
716
716
|
message: s.message
|
|
717
|
-
}),
|
|
717
|
+
}), i.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
718
718
|
code: d.invalid_string,
|
|
719
719
|
validation: { includes: s.value, position: s.position },
|
|
720
720
|
message: s.message
|
|
721
|
-
}),
|
|
721
|
+
}), i.dirty()) : s.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : s.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : s.kind === "startsWith" ? e.data.startsWith(s.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
722
722
|
code: d.invalid_string,
|
|
723
723
|
validation: { startsWith: s.value },
|
|
724
724
|
message: s.message
|
|
725
|
-
}),
|
|
725
|
+
}), i.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
726
726
|
code: d.invalid_string,
|
|
727
727
|
validation: { endsWith: s.value },
|
|
728
728
|
message: s.message
|
|
729
|
-
}),
|
|
729
|
+
}), i.dirty()) : s.kind === "datetime" ? Xe(s).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
730
730
|
code: d.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
732
|
message: s.message
|
|
733
|
-
}),
|
|
733
|
+
}), i.dirty()) : s.kind === "date" ? Ct.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
734
734
|
code: d.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
736
|
message: s.message
|
|
737
|
-
}),
|
|
737
|
+
}), i.dirty()) : s.kind === "time" ? jt(s).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
738
738
|
code: d.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
740
|
message: s.message
|
|
741
|
-
}),
|
|
741
|
+
}), i.dirty()) : s.kind === "duration" ? bt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
742
742
|
validation: "duration",
|
|
743
743
|
code: d.invalid_string,
|
|
744
744
|
message: s.message
|
|
745
|
-
}),
|
|
745
|
+
}), i.dirty()) : s.kind === "ip" ? Zt(e.data, s.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
746
746
|
validation: "ip",
|
|
747
747
|
code: d.invalid_string,
|
|
748
748
|
message: s.message
|
|
749
|
-
}),
|
|
749
|
+
}), i.dirty()) : s.kind === "jwt" ? Ot(e.data, s.alg) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
750
750
|
validation: "jwt",
|
|
751
751
|
code: d.invalid_string,
|
|
752
752
|
message: s.message
|
|
753
|
-
}),
|
|
753
|
+
}), i.dirty()) : s.kind === "cidr" ? Pt(e.data, s.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
754
754
|
validation: "cidr",
|
|
755
755
|
code: d.invalid_string,
|
|
756
756
|
message: s.message
|
|
757
|
-
}),
|
|
757
|
+
}), i.dirty()) : s.kind === "base64" ? At.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
758
758
|
validation: "base64",
|
|
759
759
|
code: d.invalid_string,
|
|
760
760
|
message: s.message
|
|
761
|
-
}),
|
|
761
|
+
}), i.dirty()) : s.kind === "base64url" ? Nt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
762
762
|
validation: "base64url",
|
|
763
763
|
code: d.invalid_string,
|
|
764
764
|
message: s.message
|
|
765
|
-
}),
|
|
766
|
-
return { status:
|
|
765
|
+
}), i.dirty()) : b.assertNever(s);
|
|
766
|
+
return { status: i.value, value: e.data };
|
|
767
767
|
}
|
|
768
|
-
_regex(e, t,
|
|
769
|
-
return this.refinement((
|
|
768
|
+
_regex(e, t, i) {
|
|
769
|
+
return this.refinement((a) => e.test(a), {
|
|
770
770
|
validation: t,
|
|
771
771
|
code: d.invalid_string,
|
|
772
|
-
...h.errToObj(
|
|
772
|
+
...h.errToObj(i)
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
_addCheck(e) {
|
|
@@ -821,7 +821,7 @@ class N extends _ {
|
|
|
821
821
|
return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
|
|
822
822
|
}
|
|
823
823
|
datetime(e) {
|
|
824
|
-
var t,
|
|
824
|
+
var t, i;
|
|
825
825
|
return typeof e == "string" ? this._addCheck({
|
|
826
826
|
kind: "datetime",
|
|
827
827
|
precision: null,
|
|
@@ -832,7 +832,7 @@ class N extends _ {
|
|
|
832
832
|
kind: "datetime",
|
|
833
833
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
834
834
|
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
835
|
-
local: (
|
|
835
|
+
local: (i = e == null ? void 0 : e.local) !== null && i !== void 0 ? i : !1,
|
|
836
836
|
...h.errToObj(e == null ? void 0 : e.message)
|
|
837
837
|
});
|
|
838
838
|
}
|
|
@@ -997,11 +997,11 @@ N.create = (n) => {
|
|
|
997
997
|
...v(n)
|
|
998
998
|
});
|
|
999
999
|
};
|
|
1000
|
-
function
|
|
1001
|
-
const t = (n.toString().split(".")[1] || "").length,
|
|
1002
|
-
return s %
|
|
1000
|
+
function Dt(n, e) {
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, i = (e.toString().split(".")[1] || "").length, a = t > i ? t : i, s = parseInt(n.toFixed(a).replace(".", "")), o = parseInt(e.toFixed(a).replace(".", ""));
|
|
1002
|
+
return s % o / Math.pow(10, a);
|
|
1003
1003
|
}
|
|
1004
|
-
class
|
|
1004
|
+
class z extends _ {
|
|
1005
1005
|
constructor() {
|
|
1006
1006
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1007
1007
|
}
|
|
@@ -1014,37 +1014,37 @@ class M extends _ {
|
|
|
1014
1014
|
received: s.parsedType
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
|
-
let
|
|
1018
|
-
const
|
|
1017
|
+
let i;
|
|
1018
|
+
const a = new T();
|
|
1019
1019
|
for (const s of this._def.checks)
|
|
1020
|
-
s.kind === "int" ? b.isInteger(e.data) || (
|
|
1020
|
+
s.kind === "int" ? b.isInteger(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1021
1021
|
code: d.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
1024
|
message: s.message
|
|
1025
|
-
}),
|
|
1025
|
+
}), a.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1026
1026
|
code: d.too_small,
|
|
1027
1027
|
minimum: s.value,
|
|
1028
1028
|
type: "number",
|
|
1029
1029
|
inclusive: s.inclusive,
|
|
1030
1030
|
exact: !1,
|
|
1031
1031
|
message: s.message
|
|
1032
|
-
}),
|
|
1032
|
+
}), a.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1033
1033
|
code: d.too_big,
|
|
1034
1034
|
maximum: s.value,
|
|
1035
1035
|
type: "number",
|
|
1036
1036
|
inclusive: s.inclusive,
|
|
1037
1037
|
exact: !1,
|
|
1038
1038
|
message: s.message
|
|
1039
|
-
}),
|
|
1039
|
+
}), a.dirty()) : s.kind === "multipleOf" ? Dt(e.data, s.value) !== 0 && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1040
1040
|
code: d.not_multiple_of,
|
|
1041
1041
|
multipleOf: s.value,
|
|
1042
1042
|
message: s.message
|
|
1043
|
-
}),
|
|
1043
|
+
}), a.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1044
1044
|
code: d.not_finite,
|
|
1045
1045
|
message: s.message
|
|
1046
|
-
}),
|
|
1047
|
-
return { status:
|
|
1046
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1047
|
+
return { status: a.value, value: e.data };
|
|
1048
1048
|
}
|
|
1049
1049
|
gte(e, t) {
|
|
1050
1050
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -1058,22 +1058,22 @@ class M extends _ {
|
|
|
1058
1058
|
lt(e, t) {
|
|
1059
1059
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1060
1060
|
}
|
|
1061
|
-
setLimit(e, t,
|
|
1062
|
-
return new
|
|
1061
|
+
setLimit(e, t, i, a) {
|
|
1062
|
+
return new z({
|
|
1063
1063
|
...this._def,
|
|
1064
1064
|
checks: [
|
|
1065
1065
|
...this._def.checks,
|
|
1066
1066
|
{
|
|
1067
1067
|
kind: e,
|
|
1068
1068
|
value: t,
|
|
1069
|
-
inclusive:
|
|
1070
|
-
message: h.toString(
|
|
1069
|
+
inclusive: i,
|
|
1070
|
+
message: h.toString(a)
|
|
1071
1071
|
}
|
|
1072
1072
|
]
|
|
1073
1073
|
});
|
|
1074
1074
|
}
|
|
1075
1075
|
_addCheck(e) {
|
|
1076
|
-
return new
|
|
1076
|
+
return new z({
|
|
1077
1077
|
...this._def,
|
|
1078
1078
|
checks: [...this._def.checks, e]
|
|
1079
1079
|
});
|
|
@@ -1159,21 +1159,21 @@ class M extends _ {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
get isFinite() {
|
|
1161
1161
|
let e = null, t = null;
|
|
1162
|
-
for (const
|
|
1163
|
-
if (
|
|
1162
|
+
for (const i of this._def.checks) {
|
|
1163
|
+
if (i.kind === "finite" || i.kind === "int" || i.kind === "multipleOf")
|
|
1164
1164
|
return !0;
|
|
1165
|
-
|
|
1165
|
+
i.kind === "min" ? (t === null || i.value > t) && (t = i.value) : i.kind === "max" && (e === null || i.value < e) && (e = i.value);
|
|
1166
1166
|
}
|
|
1167
1167
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
|
-
|
|
1170
|
+
z.create = (n) => new z({
|
|
1171
1171
|
checks: [],
|
|
1172
1172
|
typeName: g.ZodNumber,
|
|
1173
1173
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1174
1174
|
...v(n)
|
|
1175
1175
|
});
|
|
1176
|
-
class
|
|
1176
|
+
class V extends _ {
|
|
1177
1177
|
constructor() {
|
|
1178
1178
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1179
1179
|
}
|
|
@@ -1186,27 +1186,27 @@ class z extends _ {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
if (this._getType(e) !== p.bigint)
|
|
1188
1188
|
return this._getInvalidInput(e);
|
|
1189
|
-
let
|
|
1190
|
-
const
|
|
1189
|
+
let i;
|
|
1190
|
+
const a = new T();
|
|
1191
1191
|
for (const s of this._def.checks)
|
|
1192
|
-
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (
|
|
1192
|
+
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1193
1193
|
code: d.too_small,
|
|
1194
1194
|
type: "bigint",
|
|
1195
1195
|
minimum: s.value,
|
|
1196
1196
|
inclusive: s.inclusive,
|
|
1197
1197
|
message: s.message
|
|
1198
|
-
}),
|
|
1198
|
+
}), a.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1199
1199
|
code: d.too_big,
|
|
1200
1200
|
type: "bigint",
|
|
1201
1201
|
maximum: s.value,
|
|
1202
1202
|
inclusive: s.inclusive,
|
|
1203
1203
|
message: s.message
|
|
1204
|
-
}),
|
|
1204
|
+
}), a.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1205
1205
|
code: d.not_multiple_of,
|
|
1206
1206
|
multipleOf: s.value,
|
|
1207
1207
|
message: s.message
|
|
1208
|
-
}),
|
|
1209
|
-
return { status:
|
|
1208
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1209
|
+
return { status: a.value, value: e.data };
|
|
1210
1210
|
}
|
|
1211
1211
|
_getInvalidInput(e) {
|
|
1212
1212
|
const t = this._getOrReturnCtx(e);
|
|
@@ -1228,22 +1228,22 @@ class z extends _ {
|
|
|
1228
1228
|
lt(e, t) {
|
|
1229
1229
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1230
1230
|
}
|
|
1231
|
-
setLimit(e, t,
|
|
1232
|
-
return new
|
|
1231
|
+
setLimit(e, t, i, a) {
|
|
1232
|
+
return new V({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
1235
1235
|
...this._def.checks,
|
|
1236
1236
|
{
|
|
1237
1237
|
kind: e,
|
|
1238
1238
|
value: t,
|
|
1239
|
-
inclusive:
|
|
1240
|
-
message: h.toString(
|
|
1239
|
+
inclusive: i,
|
|
1240
|
+
message: h.toString(a)
|
|
1241
1241
|
}
|
|
1242
1242
|
]
|
|
1243
1243
|
});
|
|
1244
1244
|
}
|
|
1245
1245
|
_addCheck(e) {
|
|
1246
|
-
return new
|
|
1246
|
+
return new V({
|
|
1247
1247
|
...this._def,
|
|
1248
1248
|
checks: [...this._def.checks, e]
|
|
1249
1249
|
});
|
|
@@ -1300,34 +1300,34 @@ class z extends _ {
|
|
|
1300
1300
|
return e;
|
|
1301
1301
|
}
|
|
1302
1302
|
}
|
|
1303
|
-
|
|
1303
|
+
V.create = (n) => {
|
|
1304
1304
|
var e;
|
|
1305
|
-
return new
|
|
1305
|
+
return new V({
|
|
1306
1306
|
checks: [],
|
|
1307
1307
|
typeName: g.ZodBigInt,
|
|
1308
1308
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
|
|
1309
1309
|
...v(n)
|
|
1310
1310
|
});
|
|
1311
1311
|
};
|
|
1312
|
-
class
|
|
1312
|
+
class ie extends _ {
|
|
1313
1313
|
_parse(e) {
|
|
1314
1314
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
1315
|
-
const
|
|
1316
|
-
return m(
|
|
1315
|
+
const i = this._getOrReturnCtx(e);
|
|
1316
|
+
return m(i, {
|
|
1317
1317
|
code: d.invalid_type,
|
|
1318
1318
|
expected: p.boolean,
|
|
1319
|
-
received:
|
|
1319
|
+
received: i.parsedType
|
|
1320
1320
|
}), y;
|
|
1321
1321
|
}
|
|
1322
|
-
return
|
|
1322
|
+
return S(e.data);
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
|
-
|
|
1325
|
+
ie.create = (n) => new ie({
|
|
1326
1326
|
typeName: g.ZodBoolean,
|
|
1327
1327
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1328
1328
|
...v(n)
|
|
1329
1329
|
});
|
|
1330
|
-
class
|
|
1330
|
+
class B extends _ {
|
|
1331
1331
|
_parse(e) {
|
|
1332
1332
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1333
1333
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1343,31 +1343,31 @@ class q extends _ {
|
|
|
1343
1343
|
code: d.invalid_date
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
let
|
|
1346
|
+
const i = new T();
|
|
1347
|
+
let a;
|
|
1348
1348
|
for (const s of this._def.checks)
|
|
1349
|
-
s.kind === "min" ? e.data.getTime() < s.value && (
|
|
1349
|
+
s.kind === "min" ? e.data.getTime() < s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1350
1350
|
code: d.too_small,
|
|
1351
1351
|
message: s.message,
|
|
1352
1352
|
inclusive: !0,
|
|
1353
1353
|
exact: !1,
|
|
1354
1354
|
minimum: s.value,
|
|
1355
1355
|
type: "date"
|
|
1356
|
-
}),
|
|
1356
|
+
}), i.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1357
1357
|
code: d.too_big,
|
|
1358
1358
|
message: s.message,
|
|
1359
1359
|
inclusive: !0,
|
|
1360
1360
|
exact: !1,
|
|
1361
1361
|
maximum: s.value,
|
|
1362
1362
|
type: "date"
|
|
1363
|
-
}),
|
|
1363
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1364
1364
|
return {
|
|
1365
|
-
status:
|
|
1365
|
+
status: i.value,
|
|
1366
1366
|
value: new Date(e.data.getTime())
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
1369
1369
|
_addCheck(e) {
|
|
1370
|
-
return new
|
|
1370
|
+
return new B({
|
|
1371
1371
|
...this._def,
|
|
1372
1372
|
checks: [...this._def.checks, e]
|
|
1373
1373
|
});
|
|
@@ -1399,88 +1399,88 @@ class q extends _ {
|
|
|
1399
1399
|
return e != null ? new Date(e) : null;
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
|
-
|
|
1402
|
+
B.create = (n) => new B({
|
|
1403
1403
|
checks: [],
|
|
1404
1404
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1405
1405
|
typeName: g.ZodDate,
|
|
1406
1406
|
...v(n)
|
|
1407
1407
|
});
|
|
1408
|
-
class
|
|
1408
|
+
class xe extends _ {
|
|
1409
1409
|
_parse(e) {
|
|
1410
1410
|
if (this._getType(e) !== p.symbol) {
|
|
1411
|
-
const
|
|
1412
|
-
return m(
|
|
1411
|
+
const i = this._getOrReturnCtx(e);
|
|
1412
|
+
return m(i, {
|
|
1413
1413
|
code: d.invalid_type,
|
|
1414
1414
|
expected: p.symbol,
|
|
1415
|
-
received:
|
|
1415
|
+
received: i.parsedType
|
|
1416
1416
|
}), y;
|
|
1417
1417
|
}
|
|
1418
|
-
return
|
|
1418
|
+
return S(e.data);
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
1421
|
-
|
|
1421
|
+
xe.create = (n) => new xe({
|
|
1422
1422
|
typeName: g.ZodSymbol,
|
|
1423
1423
|
...v(n)
|
|
1424
1424
|
});
|
|
1425
1425
|
class ae extends _ {
|
|
1426
1426
|
_parse(e) {
|
|
1427
1427
|
if (this._getType(e) !== p.undefined) {
|
|
1428
|
-
const
|
|
1429
|
-
return m(
|
|
1428
|
+
const i = this._getOrReturnCtx(e);
|
|
1429
|
+
return m(i, {
|
|
1430
1430
|
code: d.invalid_type,
|
|
1431
1431
|
expected: p.undefined,
|
|
1432
|
-
received:
|
|
1432
|
+
received: i.parsedType
|
|
1433
1433
|
}), y;
|
|
1434
1434
|
}
|
|
1435
|
-
return
|
|
1435
|
+
return S(e.data);
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
1438
|
ae.create = (n) => new ae({
|
|
1439
1439
|
typeName: g.ZodUndefined,
|
|
1440
1440
|
...v(n)
|
|
1441
1441
|
});
|
|
1442
|
-
class
|
|
1442
|
+
class se extends _ {
|
|
1443
1443
|
_parse(e) {
|
|
1444
1444
|
if (this._getType(e) !== p.null) {
|
|
1445
|
-
const
|
|
1446
|
-
return m(
|
|
1445
|
+
const i = this._getOrReturnCtx(e);
|
|
1446
|
+
return m(i, {
|
|
1447
1447
|
code: d.invalid_type,
|
|
1448
1448
|
expected: p.null,
|
|
1449
|
-
received:
|
|
1449
|
+
received: i.parsedType
|
|
1450
1450
|
}), y;
|
|
1451
1451
|
}
|
|
1452
|
-
return
|
|
1452
|
+
return S(e.data);
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
|
|
1455
|
+
se.create = (n) => new se({
|
|
1456
1456
|
typeName: g.ZodNull,
|
|
1457
1457
|
...v(n)
|
|
1458
1458
|
});
|
|
1459
|
-
class
|
|
1459
|
+
class J extends _ {
|
|
1460
1460
|
constructor() {
|
|
1461
1461
|
super(...arguments), this._any = !0;
|
|
1462
1462
|
}
|
|
1463
1463
|
_parse(e) {
|
|
1464
|
-
return
|
|
1464
|
+
return S(e.data);
|
|
1465
1465
|
}
|
|
1466
1466
|
}
|
|
1467
|
-
|
|
1467
|
+
J.create = (n) => new J({
|
|
1468
1468
|
typeName: g.ZodAny,
|
|
1469
1469
|
...v(n)
|
|
1470
1470
|
});
|
|
1471
|
-
class
|
|
1471
|
+
class U extends _ {
|
|
1472
1472
|
constructor() {
|
|
1473
1473
|
super(...arguments), this._unknown = !0;
|
|
1474
1474
|
}
|
|
1475
1475
|
_parse(e) {
|
|
1476
|
-
return
|
|
1476
|
+
return S(e.data);
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
|
-
|
|
1479
|
+
U.create = (n) => new U({
|
|
1480
1480
|
typeName: g.ZodUnknown,
|
|
1481
1481
|
...v(n)
|
|
1482
1482
|
});
|
|
1483
|
-
class
|
|
1483
|
+
class M extends _ {
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
const t = this._getOrReturnCtx(e);
|
|
1486
1486
|
return m(t, {
|
|
@@ -1490,66 +1490,66 @@ class $ extends _ {
|
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
|
-
|
|
1493
|
+
M.create = (n) => new M({
|
|
1494
1494
|
typeName: g.ZodNever,
|
|
1495
1495
|
...v(n)
|
|
1496
1496
|
});
|
|
1497
|
-
class
|
|
1497
|
+
class ke extends _ {
|
|
1498
1498
|
_parse(e) {
|
|
1499
1499
|
if (this._getType(e) !== p.undefined) {
|
|
1500
|
-
const
|
|
1501
|
-
return m(
|
|
1500
|
+
const i = this._getOrReturnCtx(e);
|
|
1501
|
+
return m(i, {
|
|
1502
1502
|
code: d.invalid_type,
|
|
1503
1503
|
expected: p.void,
|
|
1504
|
-
received:
|
|
1504
|
+
received: i.parsedType
|
|
1505
1505
|
}), y;
|
|
1506
1506
|
}
|
|
1507
|
-
return
|
|
1507
|
+
return S(e.data);
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
|
-
|
|
1510
|
+
ke.create = (n) => new ke({
|
|
1511
1511
|
typeName: g.ZodVoid,
|
|
1512
1512
|
...v(n)
|
|
1513
1513
|
});
|
|
1514
1514
|
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
|
-
const { ctx: t, status:
|
|
1516
|
+
const { ctx: t, status: i } = this._processInputParams(e), a = this._def;
|
|
1517
1517
|
if (t.parsedType !== p.array)
|
|
1518
1518
|
return m(t, {
|
|
1519
1519
|
code: d.invalid_type,
|
|
1520
1520
|
expected: p.array,
|
|
1521
1521
|
received: t.parsedType
|
|
1522
1522
|
}), y;
|
|
1523
|
-
if (
|
|
1524
|
-
const
|
|
1525
|
-
(
|
|
1526
|
-
code:
|
|
1527
|
-
minimum:
|
|
1528
|
-
maximum:
|
|
1523
|
+
if (a.exactLength !== null) {
|
|
1524
|
+
const o = t.data.length > a.exactLength.value, c = t.data.length < a.exactLength.value;
|
|
1525
|
+
(o || c) && (m(t, {
|
|
1526
|
+
code: o ? d.too_big : d.too_small,
|
|
1527
|
+
minimum: c ? a.exactLength.value : void 0,
|
|
1528
|
+
maximum: o ? a.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
1530
1530
|
inclusive: !0,
|
|
1531
1531
|
exact: !0,
|
|
1532
|
-
message:
|
|
1533
|
-
}),
|
|
1532
|
+
message: a.exactLength.message
|
|
1533
|
+
}), i.dirty());
|
|
1534
1534
|
}
|
|
1535
|
-
if (
|
|
1535
|
+
if (a.minLength !== null && t.data.length < a.minLength.value && (m(t, {
|
|
1536
1536
|
code: d.too_small,
|
|
1537
|
-
minimum:
|
|
1537
|
+
minimum: a.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
|
-
message:
|
|
1542
|
-
}),
|
|
1541
|
+
message: a.minLength.message
|
|
1542
|
+
}), i.dirty()), a.maxLength !== null && t.data.length > a.maxLength.value && (m(t, {
|
|
1543
1543
|
code: d.too_big,
|
|
1544
|
-
maximum:
|
|
1544
|
+
maximum: a.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
1547
1547
|
exact: !1,
|
|
1548
|
-
message:
|
|
1549
|
-
}),
|
|
1550
|
-
return Promise.all([...t.data].map((
|
|
1551
|
-
const s = [...t.data].map((
|
|
1552
|
-
return
|
|
1548
|
+
message: a.maxLength.message
|
|
1549
|
+
}), i.dirty()), t.common.async)
|
|
1550
|
+
return Promise.all([...t.data].map((o, c) => a.type._parseAsync(new P(t, o, t.path, c)))).then((o) => T.mergeArray(i, o));
|
|
1551
|
+
const s = [...t.data].map((o, c) => a.type._parseSync(new P(t, o, t.path, c)));
|
|
1552
|
+
return T.mergeArray(i, s);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
1555
1555
|
return this._def.type;
|
|
@@ -1584,12 +1584,12 @@ C.create = (n, e) => new C({
|
|
|
1584
1584
|
typeName: g.ZodArray,
|
|
1585
1585
|
...v(e)
|
|
1586
1586
|
});
|
|
1587
|
-
function
|
|
1587
|
+
function Q(n) {
|
|
1588
1588
|
if (n instanceof k) {
|
|
1589
1589
|
const e = {};
|
|
1590
1590
|
for (const t in n.shape) {
|
|
1591
|
-
const
|
|
1592
|
-
e[t] =
|
|
1591
|
+
const i = n.shape[t];
|
|
1592
|
+
e[t] = O.create(Q(i));
|
|
1593
1593
|
}
|
|
1594
1594
|
return new k({
|
|
1595
1595
|
...n._def,
|
|
@@ -1597,8 +1597,8 @@ function W(n) {
|
|
|
1597
1597
|
});
|
|
1598
1598
|
} else return n instanceof C ? new C({
|
|
1599
1599
|
...n._def,
|
|
1600
|
-
type:
|
|
1601
|
-
}) : n instanceof
|
|
1600
|
+
type: Q(n.element)
|
|
1601
|
+
}) : n instanceof O ? O.create(Q(n.unwrap())) : n instanceof F ? F.create(Q(n.unwrap())) : n instanceof D ? D.create(n.items.map((e) => Q(e))) : n;
|
|
1602
1602
|
}
|
|
1603
1603
|
class k extends _ {
|
|
1604
1604
|
constructor() {
|
|
@@ -1619,59 +1619,59 @@ class k extends _ {
|
|
|
1619
1619
|
received: u.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status:
|
|
1623
|
-
if (!(this._def.catchall instanceof
|
|
1624
|
-
for (const u in
|
|
1625
|
-
|
|
1622
|
+
const { status: i, ctx: a } = this._processInputParams(e), { shape: s, keys: o } = this._getCached(), c = [];
|
|
1623
|
+
if (!(this._def.catchall instanceof M && this._def.unknownKeys === "strip"))
|
|
1624
|
+
for (const u in a.data)
|
|
1625
|
+
o.includes(u) || c.push(u);
|
|
1626
1626
|
const l = [];
|
|
1627
|
-
for (const u of
|
|
1628
|
-
const f = s[u], x =
|
|
1627
|
+
for (const u of o) {
|
|
1628
|
+
const f = s[u], x = a.data[u];
|
|
1629
1629
|
l.push({
|
|
1630
1630
|
key: { status: "valid", value: u },
|
|
1631
|
-
value: f._parse(new
|
|
1632
|
-
alwaysSet: u in
|
|
1631
|
+
value: f._parse(new P(a, x, a.path, u)),
|
|
1632
|
+
alwaysSet: u in a.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
|
-
if (this._def.catchall instanceof
|
|
1635
|
+
if (this._def.catchall instanceof M) {
|
|
1636
1636
|
const u = this._def.unknownKeys;
|
|
1637
1637
|
if (u === "passthrough")
|
|
1638
|
-
for (const f of
|
|
1638
|
+
for (const f of c)
|
|
1639
1639
|
l.push({
|
|
1640
1640
|
key: { status: "valid", value: f },
|
|
1641
|
-
value: { status: "valid", value:
|
|
1641
|
+
value: { status: "valid", value: a.data[f] }
|
|
1642
1642
|
});
|
|
1643
1643
|
else if (u === "strict")
|
|
1644
|
-
|
|
1644
|
+
c.length > 0 && (m(a, {
|
|
1645
1645
|
code: d.unrecognized_keys,
|
|
1646
|
-
keys:
|
|
1647
|
-
}),
|
|
1646
|
+
keys: c
|
|
1647
|
+
}), i.dirty());
|
|
1648
1648
|
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1649
1649
|
} else {
|
|
1650
1650
|
const u = this._def.catchall;
|
|
1651
|
-
for (const f of
|
|
1652
|
-
const x =
|
|
1651
|
+
for (const f of c) {
|
|
1652
|
+
const x = a.data[f];
|
|
1653
1653
|
l.push({
|
|
1654
1654
|
key: { status: "valid", value: f },
|
|
1655
1655
|
value: u._parse(
|
|
1656
|
-
new
|
|
1656
|
+
new P(a, x, a.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet: f in
|
|
1659
|
+
alwaysSet: f in a.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
-
return
|
|
1663
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
1664
1664
|
const u = [];
|
|
1665
1665
|
for (const f of l) {
|
|
1666
|
-
const x = await f.key,
|
|
1666
|
+
const x = await f.key, w = await f.value;
|
|
1667
1667
|
u.push({
|
|
1668
1668
|
key: x,
|
|
1669
|
-
value:
|
|
1669
|
+
value: w,
|
|
1670
1670
|
alwaysSet: f.alwaysSet
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
1673
|
return u;
|
|
1674
|
-
}).then((u) =>
|
|
1674
|
+
}).then((u) => T.mergeObjectSync(i, u)) : T.mergeObjectSync(i, l);
|
|
1675
1675
|
}
|
|
1676
1676
|
get shape() {
|
|
1677
1677
|
return this._def.shape();
|
|
@@ -1681,11 +1681,11 @@ class k extends _ {
|
|
|
1681
1681
|
...this._def,
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
|
-
errorMap: (t,
|
|
1685
|
-
var
|
|
1686
|
-
const l = (
|
|
1684
|
+
errorMap: (t, i) => {
|
|
1685
|
+
var a, s, o, c;
|
|
1686
|
+
const l = (o = (s = (a = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(a, t, i).message) !== null && o !== void 0 ? o : i.defaultError;
|
|
1687
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1688
|
-
message: (
|
|
1688
|
+
message: (c = h.errToObj(e).message) !== null && c !== void 0 ? c : l
|
|
1689
1689
|
} : {
|
|
1690
1690
|
message: l
|
|
1691
1691
|
};
|
|
@@ -1814,8 +1814,8 @@ class k extends _ {
|
|
|
1814
1814
|
}
|
|
1815
1815
|
pick(e) {
|
|
1816
1816
|
const t = {};
|
|
1817
|
-
return b.objectKeys(e).forEach((
|
|
1818
|
-
e[
|
|
1817
|
+
return b.objectKeys(e).forEach((i) => {
|
|
1818
|
+
e[i] && this.shape[i] && (t[i] = this.shape[i]);
|
|
1819
1819
|
}), new k({
|
|
1820
1820
|
...this._def,
|
|
1821
1821
|
shape: () => t
|
|
@@ -1823,8 +1823,8 @@ class k extends _ {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
omit(e) {
|
|
1825
1825
|
const t = {};
|
|
1826
|
-
return b.objectKeys(this.shape).forEach((
|
|
1827
|
-
e[
|
|
1826
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1827
|
+
e[i] || (t[i] = this.shape[i]);
|
|
1828
1828
|
}), new k({
|
|
1829
1829
|
...this._def,
|
|
1830
1830
|
shape: () => t
|
|
@@ -1834,13 +1834,13 @@ class k extends _ {
|
|
|
1834
1834
|
* @deprecated
|
|
1835
1835
|
*/
|
|
1836
1836
|
deepPartial() {
|
|
1837
|
-
return
|
|
1837
|
+
return Q(this);
|
|
1838
1838
|
}
|
|
1839
1839
|
partial(e) {
|
|
1840
1840
|
const t = {};
|
|
1841
|
-
return b.objectKeys(this.shape).forEach((
|
|
1842
|
-
const
|
|
1843
|
-
e && !e[
|
|
1841
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1842
|
+
const a = this.shape[i];
|
|
1843
|
+
e && !e[i] ? t[i] = a : t[i] = a.optional();
|
|
1844
1844
|
}), new k({
|
|
1845
1845
|
...this._def,
|
|
1846
1846
|
shape: () => t
|
|
@@ -1848,14 +1848,14 @@ class k extends _ {
|
|
|
1848
1848
|
}
|
|
1849
1849
|
required(e) {
|
|
1850
1850
|
const t = {};
|
|
1851
|
-
return b.objectKeys(this.shape).forEach((
|
|
1852
|
-
if (e && !e[
|
|
1853
|
-
t[
|
|
1851
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1852
|
+
if (e && !e[i])
|
|
1853
|
+
t[i] = this.shape[i];
|
|
1854
1854
|
else {
|
|
1855
|
-
let s = this.shape[
|
|
1856
|
-
for (; s instanceof
|
|
1855
|
+
let s = this.shape[i];
|
|
1856
|
+
for (; s instanceof O; )
|
|
1857
1857
|
s = s._def.innerType;
|
|
1858
|
-
t[
|
|
1858
|
+
t[i] = s;
|
|
1859
1859
|
}
|
|
1860
1860
|
}), new k({
|
|
1861
1861
|
...this._def,
|
|
@@ -1863,49 +1863,49 @@ class k extends _ {
|
|
|
1863
1863
|
});
|
|
1864
1864
|
}
|
|
1865
1865
|
keyof() {
|
|
1866
|
-
return
|
|
1866
|
+
return Ge(b.objectKeys(this.shape));
|
|
1867
1867
|
}
|
|
1868
1868
|
}
|
|
1869
1869
|
k.create = (n, e) => new k({
|
|
1870
1870
|
shape: () => n,
|
|
1871
1871
|
unknownKeys: "strip",
|
|
1872
|
-
catchall:
|
|
1872
|
+
catchall: M.create(),
|
|
1873
1873
|
typeName: g.ZodObject,
|
|
1874
1874
|
...v(e)
|
|
1875
1875
|
});
|
|
1876
1876
|
k.strictCreate = (n, e) => new k({
|
|
1877
1877
|
shape: () => n,
|
|
1878
1878
|
unknownKeys: "strict",
|
|
1879
|
-
catchall:
|
|
1879
|
+
catchall: M.create(),
|
|
1880
1880
|
typeName: g.ZodObject,
|
|
1881
1881
|
...v(e)
|
|
1882
1882
|
});
|
|
1883
1883
|
k.lazycreate = (n, e) => new k({
|
|
1884
1884
|
shape: n,
|
|
1885
1885
|
unknownKeys: "strip",
|
|
1886
|
-
catchall:
|
|
1886
|
+
catchall: M.create(),
|
|
1887
1887
|
typeName: g.ZodObject,
|
|
1888
1888
|
...v(e)
|
|
1889
1889
|
});
|
|
1890
|
-
class
|
|
1890
|
+
class oe extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1893
|
-
function
|
|
1894
|
-
for (const
|
|
1895
|
-
if (
|
|
1896
|
-
return
|
|
1897
|
-
for (const
|
|
1898
|
-
if (
|
|
1899
|
-
return t.common.issues.push(...
|
|
1900
|
-
const
|
|
1892
|
+
const { ctx: t } = this._processInputParams(e), i = this._def.options;
|
|
1893
|
+
function a(s) {
|
|
1894
|
+
for (const c of s)
|
|
1895
|
+
if (c.result.status === "valid")
|
|
1896
|
+
return c.result;
|
|
1897
|
+
for (const c of s)
|
|
1898
|
+
if (c.result.status === "dirty")
|
|
1899
|
+
return t.common.issues.push(...c.ctx.common.issues), c.result;
|
|
1900
|
+
const o = s.map((c) => new A(c.ctx.common.issues));
|
|
1901
1901
|
return m(t, {
|
|
1902
1902
|
code: d.invalid_union,
|
|
1903
|
-
unionErrors:
|
|
1903
|
+
unionErrors: o
|
|
1904
1904
|
}), y;
|
|
1905
1905
|
}
|
|
1906
1906
|
if (t.common.async)
|
|
1907
|
-
return Promise.all(
|
|
1908
|
-
const
|
|
1907
|
+
return Promise.all(i.map(async (s) => {
|
|
1908
|
+
const o = {
|
|
1909
1909
|
...t,
|
|
1910
1910
|
common: {
|
|
1911
1911
|
...t.common,
|
|
@@ -1917,15 +1917,15 @@ class se extends _ {
|
|
|
1917
1917
|
result: await s._parseAsync({
|
|
1918
1918
|
data: t.data,
|
|
1919
1919
|
path: t.path,
|
|
1920
|
-
parent:
|
|
1920
|
+
parent: o
|
|
1921
1921
|
}),
|
|
1922
|
-
ctx:
|
|
1922
|
+
ctx: o
|
|
1923
1923
|
};
|
|
1924
|
-
})).then(
|
|
1924
|
+
})).then(a);
|
|
1925
1925
|
{
|
|
1926
1926
|
let s;
|
|
1927
|
-
const
|
|
1928
|
-
for (const l of
|
|
1927
|
+
const o = [];
|
|
1928
|
+
for (const l of i) {
|
|
1929
1929
|
const u = {
|
|
1930
1930
|
...t,
|
|
1931
1931
|
common: {
|
|
@@ -1940,14 +1940,14 @@ class se extends _ {
|
|
|
1940
1940
|
});
|
|
1941
1941
|
if (f.status === "valid")
|
|
1942
1942
|
return f;
|
|
1943
|
-
f.status === "dirty" && !s && (s = { result: f, ctx: u }), u.common.issues.length &&
|
|
1943
|
+
f.status === "dirty" && !s && (s = { result: f, ctx: u }), u.common.issues.length && o.push(u.common.issues);
|
|
1944
1944
|
}
|
|
1945
1945
|
if (s)
|
|
1946
1946
|
return t.common.issues.push(...s.ctx.common.issues), s.result;
|
|
1947
|
-
const
|
|
1947
|
+
const c = o.map((l) => new A(l));
|
|
1948
1948
|
return m(t, {
|
|
1949
1949
|
code: d.invalid_union,
|
|
1950
|
-
unionErrors:
|
|
1950
|
+
unionErrors: c
|
|
1951
1951
|
}), y;
|
|
1952
1952
|
}
|
|
1953
1953
|
}
|
|
@@ -1955,13 +1955,13 @@ class se extends _ {
|
|
|
1955
1955
|
return this._def.options;
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
|
-
|
|
1958
|
+
oe.create = (n, e) => new oe({
|
|
1959
1959
|
options: n,
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const
|
|
1964
|
-
class
|
|
1963
|
+
const E = (n) => n instanceof de ? E(n.schema) : n instanceof j ? E(n.innerType()) : n instanceof le ? [n.value] : n instanceof L ? n.options : n instanceof me ? b.objectValues(n.enum) : n instanceof pe ? E(n._def.innerType) : n instanceof ae ? [void 0] : n instanceof se ? [null] : n instanceof O ? [void 0, ...E(n.unwrap())] : n instanceof F ? [null, ...E(n.unwrap())] : n instanceof Re || n instanceof he ? E(n.unwrap()) : n instanceof fe ? E(n._def.innerType) : [];
|
|
1964
|
+
class Se extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
1967
1967
|
if (t.parsedType !== p.object)
|
|
@@ -1970,7 +1970,7 @@ class Te extends _ {
|
|
|
1970
1970
|
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const
|
|
1973
|
+
const i = this.discriminator, a = t.data[i], s = this.optionsMap.get(a);
|
|
1974
1974
|
return s ? t.common.async ? s._parseAsync({
|
|
1975
1975
|
data: t.data,
|
|
1976
1976
|
path: t.path,
|
|
@@ -1982,7 +1982,7 @@ class Te extends _ {
|
|
|
1982
1982
|
}) : (m(t, {
|
|
1983
1983
|
code: d.invalid_union_discriminator,
|
|
1984
1984
|
options: Array.from(this.optionsMap.keys()),
|
|
1985
|
-
path: [
|
|
1985
|
+
path: [i]
|
|
1986
1986
|
}), y);
|
|
1987
1987
|
}
|
|
1988
1988
|
get discriminator() {
|
|
@@ -2002,142 +2002,142 @@ class Te extends _ {
|
|
|
2002
2002
|
* @param types an array of object schemas
|
|
2003
2003
|
* @param params
|
|
2004
2004
|
*/
|
|
2005
|
-
static create(e, t,
|
|
2006
|
-
const
|
|
2005
|
+
static create(e, t, i) {
|
|
2006
|
+
const a = /* @__PURE__ */ new Map();
|
|
2007
2007
|
for (const s of t) {
|
|
2008
|
-
const
|
|
2009
|
-
if (!
|
|
2008
|
+
const o = E(s.shape[e]);
|
|
2009
|
+
if (!o.length)
|
|
2010
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2011
|
-
for (const
|
|
2012
|
-
if (
|
|
2013
|
-
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(
|
|
2014
|
-
|
|
2011
|
+
for (const c of o) {
|
|
2012
|
+
if (a.has(c))
|
|
2013
|
+
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
|
|
2014
|
+
a.set(c, s);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
|
-
return new
|
|
2017
|
+
return new Se({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
2021
|
-
optionsMap:
|
|
2022
|
-
...v(
|
|
2021
|
+
optionsMap: a,
|
|
2022
|
+
...v(i)
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const t =
|
|
2026
|
+
function De(n, e) {
|
|
2027
|
+
const t = R(n), i = R(e);
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
|
-
if (t === p.object &&
|
|
2031
|
-
const
|
|
2032
|
-
for (const
|
|
2033
|
-
const l =
|
|
2030
|
+
if (t === p.object && i === p.object) {
|
|
2031
|
+
const a = b.objectKeys(e), s = b.objectKeys(n).filter((c) => a.indexOf(c) !== -1), o = { ...n, ...e };
|
|
2032
|
+
for (const c of s) {
|
|
2033
|
+
const l = De(n[c], e[c]);
|
|
2034
2034
|
if (!l.valid)
|
|
2035
2035
|
return { valid: !1 };
|
|
2036
|
-
c
|
|
2036
|
+
o[c] = l.data;
|
|
2037
2037
|
}
|
|
2038
|
-
return { valid: !0, data:
|
|
2039
|
-
} else if (t === p.array &&
|
|
2038
|
+
return { valid: !0, data: o };
|
|
2039
|
+
} else if (t === p.array && i === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
|
-
const
|
|
2042
|
+
const a = [];
|
|
2043
2043
|
for (let s = 0; s < n.length; s++) {
|
|
2044
|
-
const
|
|
2044
|
+
const o = n[s], c = e[s], l = De(o, c);
|
|
2045
2045
|
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
|
-
|
|
2047
|
+
a.push(l.data);
|
|
2048
2048
|
}
|
|
2049
|
-
return { valid: !0, data:
|
|
2050
|
-
} else return t === p.date &&
|
|
2049
|
+
return { valid: !0, data: a };
|
|
2050
|
+
} else return t === p.date && i === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
|
-
class
|
|
2052
|
+
class ce extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx:
|
|
2055
|
-
if (
|
|
2054
|
+
const { status: t, ctx: i } = this._processInputParams(e), a = (s, o) => {
|
|
2055
|
+
if (Oe(s) || Oe(o))
|
|
2056
2056
|
return y;
|
|
2057
|
-
const
|
|
2058
|
-
return
|
|
2057
|
+
const c = De(s.value, o.value);
|
|
2058
|
+
return c.valid ? ((Pe(s) || Pe(o)) && t.dirty(), { status: t.value, value: c.data }) : (m(i, {
|
|
2059
2059
|
code: d.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
2062
|
-
return
|
|
2062
|
+
return i.common.async ? Promise.all([
|
|
2063
2063
|
this._def.left._parseAsync({
|
|
2064
|
-
data:
|
|
2065
|
-
path:
|
|
2066
|
-
parent:
|
|
2064
|
+
data: i.data,
|
|
2065
|
+
path: i.path,
|
|
2066
|
+
parent: i
|
|
2067
2067
|
}),
|
|
2068
2068
|
this._def.right._parseAsync({
|
|
2069
|
-
data:
|
|
2070
|
-
path:
|
|
2071
|
-
parent:
|
|
2069
|
+
data: i.data,
|
|
2070
|
+
path: i.path,
|
|
2071
|
+
parent: i
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([s,
|
|
2074
|
-
data:
|
|
2075
|
-
path:
|
|
2076
|
-
parent:
|
|
2073
|
+
]).then(([s, o]) => a(s, o)) : a(this._def.left._parseSync({
|
|
2074
|
+
data: i.data,
|
|
2075
|
+
path: i.path,
|
|
2076
|
+
parent: i
|
|
2077
2077
|
}), this._def.right._parseSync({
|
|
2078
|
-
data:
|
|
2079
|
-
path:
|
|
2080
|
-
parent:
|
|
2078
|
+
data: i.data,
|
|
2079
|
+
path: i.path,
|
|
2080
|
+
parent: i
|
|
2081
2081
|
}));
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
|
-
|
|
2084
|
+
ce.create = (n, e, t) => new ce({
|
|
2085
2085
|
left: n,
|
|
2086
2086
|
right: e,
|
|
2087
2087
|
typeName: g.ZodIntersection,
|
|
2088
2088
|
...v(t)
|
|
2089
2089
|
});
|
|
2090
|
-
class
|
|
2090
|
+
class D extends _ {
|
|
2091
2091
|
_parse(e) {
|
|
2092
|
-
const { status: t, ctx:
|
|
2093
|
-
if (
|
|
2094
|
-
return m(
|
|
2092
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2093
|
+
if (i.parsedType !== p.array)
|
|
2094
|
+
return m(i, {
|
|
2095
2095
|
code: d.invalid_type,
|
|
2096
2096
|
expected: p.array,
|
|
2097
|
-
received:
|
|
2097
|
+
received: i.parsedType
|
|
2098
2098
|
}), y;
|
|
2099
|
-
if (
|
|
2100
|
-
return m(
|
|
2099
|
+
if (i.data.length < this._def.items.length)
|
|
2100
|
+
return m(i, {
|
|
2101
2101
|
code: d.too_small,
|
|
2102
2102
|
minimum: this._def.items.length,
|
|
2103
2103
|
inclusive: !0,
|
|
2104
2104
|
exact: !1,
|
|
2105
2105
|
type: "array"
|
|
2106
2106
|
}), y;
|
|
2107
|
-
!this._def.rest &&
|
|
2107
|
+
!this._def.rest && i.data.length > this._def.items.length && (m(i, {
|
|
2108
2108
|
code: d.too_big,
|
|
2109
2109
|
maximum: this._def.items.length,
|
|
2110
2110
|
inclusive: !0,
|
|
2111
2111
|
exact: !1,
|
|
2112
2112
|
type: "array"
|
|
2113
2113
|
}), t.dirty());
|
|
2114
|
-
const s = [...
|
|
2115
|
-
const l = this._def.items[
|
|
2116
|
-
return l ? l._parse(new
|
|
2117
|
-
}).filter((
|
|
2118
|
-
return
|
|
2114
|
+
const s = [...i.data].map((o, c) => {
|
|
2115
|
+
const l = this._def.items[c] || this._def.rest;
|
|
2116
|
+
return l ? l._parse(new P(i, o, i.path, c)) : null;
|
|
2117
|
+
}).filter((o) => !!o);
|
|
2118
|
+
return i.common.async ? Promise.all(s).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, s);
|
|
2119
2119
|
}
|
|
2120
2120
|
get items() {
|
|
2121
2121
|
return this._def.items;
|
|
2122
2122
|
}
|
|
2123
2123
|
rest(e) {
|
|
2124
|
-
return new
|
|
2124
|
+
return new D({
|
|
2125
2125
|
...this._def,
|
|
2126
2126
|
rest: e
|
|
2127
2127
|
});
|
|
2128
2128
|
}
|
|
2129
2129
|
}
|
|
2130
|
-
|
|
2130
|
+
D.create = (n, e) => {
|
|
2131
2131
|
if (!Array.isArray(n))
|
|
2132
2132
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2133
|
-
return new
|
|
2133
|
+
return new D({
|
|
2134
2134
|
items: n,
|
|
2135
2135
|
typeName: g.ZodTuple,
|
|
2136
2136
|
rest: null,
|
|
2137
2137
|
...v(e)
|
|
2138
2138
|
});
|
|
2139
2139
|
};
|
|
2140
|
-
class
|
|
2140
|
+
class ue extends _ {
|
|
2141
2141
|
get keySchema() {
|
|
2142
2142
|
return this._def.keyType;
|
|
2143
2143
|
}
|
|
@@ -2145,32 +2145,32 @@ class ce extends _ {
|
|
|
2145
2145
|
return this._def.valueType;
|
|
2146
2146
|
}
|
|
2147
2147
|
_parse(e) {
|
|
2148
|
-
const { status: t, ctx:
|
|
2149
|
-
if (
|
|
2150
|
-
return m(
|
|
2148
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2149
|
+
if (i.parsedType !== p.object)
|
|
2150
|
+
return m(i, {
|
|
2151
2151
|
code: d.invalid_type,
|
|
2152
2152
|
expected: p.object,
|
|
2153
|
-
received:
|
|
2153
|
+
received: i.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const
|
|
2156
|
-
for (const
|
|
2157
|
-
|
|
2158
|
-
key: s._parse(new
|
|
2159
|
-
value:
|
|
2160
|
-
alwaysSet:
|
|
2155
|
+
const a = [], s = this._def.keyType, o = this._def.valueType;
|
|
2156
|
+
for (const c in i.data)
|
|
2157
|
+
a.push({
|
|
2158
|
+
key: s._parse(new P(i, c, i.path, c)),
|
|
2159
|
+
value: o._parse(new P(i, i.data[c], i.path, c)),
|
|
2160
|
+
alwaysSet: c in i.data
|
|
2161
2161
|
});
|
|
2162
|
-
return
|
|
2162
|
+
return i.common.async ? T.mergeObjectAsync(t, a) : T.mergeObjectSync(t, a);
|
|
2163
2163
|
}
|
|
2164
2164
|
get element() {
|
|
2165
2165
|
return this._def.valueType;
|
|
2166
2166
|
}
|
|
2167
|
-
static create(e, t,
|
|
2168
|
-
return t instanceof _ ? new
|
|
2167
|
+
static create(e, t, i) {
|
|
2168
|
+
return t instanceof _ ? new ue({
|
|
2169
2169
|
keyType: e,
|
|
2170
2170
|
valueType: t,
|
|
2171
2171
|
typeName: g.ZodRecord,
|
|
2172
|
-
...v(
|
|
2173
|
-
}) : new
|
|
2172
|
+
...v(i)
|
|
2173
|
+
}) : new ue({
|
|
2174
2174
|
keyType: N.create(),
|
|
2175
2175
|
valueType: e,
|
|
2176
2176
|
typeName: g.ZodRecord,
|
|
@@ -2178,7 +2178,7 @@ class ce extends _ {
|
|
|
2178
2178
|
});
|
|
2179
2179
|
}
|
|
2180
2180
|
}
|
|
2181
|
-
class
|
|
2181
|
+
class we extends _ {
|
|
2182
2182
|
get keySchema() {
|
|
2183
2183
|
return this._def.keyType;
|
|
2184
2184
|
}
|
|
@@ -2186,73 +2186,73 @@ class ke extends _ {
|
|
|
2186
2186
|
return this._def.valueType;
|
|
2187
2187
|
}
|
|
2188
2188
|
_parse(e) {
|
|
2189
|
-
const { status: t, ctx:
|
|
2190
|
-
if (
|
|
2191
|
-
return m(
|
|
2189
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2190
|
+
if (i.parsedType !== p.map)
|
|
2191
|
+
return m(i, {
|
|
2192
2192
|
code: d.invalid_type,
|
|
2193
2193
|
expected: p.map,
|
|
2194
|
-
received:
|
|
2194
|
+
received: i.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const
|
|
2197
|
-
key:
|
|
2198
|
-
value: s._parse(new
|
|
2196
|
+
const a = this._def.keyType, s = this._def.valueType, o = [...i.data.entries()].map(([c, l], u) => ({
|
|
2197
|
+
key: a._parse(new P(i, c, i.path, [u, "key"])),
|
|
2198
|
+
value: s._parse(new P(i, l, i.path, [u, "value"]))
|
|
2199
2199
|
}));
|
|
2200
|
-
if (
|
|
2201
|
-
const
|
|
2200
|
+
if (i.common.async) {
|
|
2201
|
+
const c = /* @__PURE__ */ new Map();
|
|
2202
2202
|
return Promise.resolve().then(async () => {
|
|
2203
|
-
for (const l of
|
|
2203
|
+
for (const l of o) {
|
|
2204
2204
|
const u = await l.key, f = await l.value;
|
|
2205
2205
|
if (u.status === "aborted" || f.status === "aborted")
|
|
2206
2206
|
return y;
|
|
2207
|
-
(u.status === "dirty" || f.status === "dirty") && t.dirty(),
|
|
2207
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2208
2208
|
}
|
|
2209
|
-
return { status: t.value, value:
|
|
2209
|
+
return { status: t.value, value: c };
|
|
2210
2210
|
});
|
|
2211
2211
|
} else {
|
|
2212
|
-
const
|
|
2213
|
-
for (const l of
|
|
2212
|
+
const c = /* @__PURE__ */ new Map();
|
|
2213
|
+
for (const l of o) {
|
|
2214
2214
|
const u = l.key, f = l.value;
|
|
2215
2215
|
if (u.status === "aborted" || f.status === "aborted")
|
|
2216
2216
|
return y;
|
|
2217
|
-
(u.status === "dirty" || f.status === "dirty") && t.dirty(),
|
|
2217
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2218
2218
|
}
|
|
2219
|
-
return { status: t.value, value:
|
|
2219
|
+
return { status: t.value, value: c };
|
|
2220
2220
|
}
|
|
2221
2221
|
}
|
|
2222
2222
|
}
|
|
2223
|
-
|
|
2223
|
+
we.create = (n, e, t) => new we({
|
|
2224
2224
|
valueType: e,
|
|
2225
2225
|
keyType: n,
|
|
2226
2226
|
typeName: g.ZodMap,
|
|
2227
2227
|
...v(t)
|
|
2228
2228
|
});
|
|
2229
|
-
class
|
|
2229
|
+
class W extends _ {
|
|
2230
2230
|
_parse(e) {
|
|
2231
|
-
const { status: t, ctx:
|
|
2232
|
-
if (
|
|
2233
|
-
return m(
|
|
2231
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2232
|
+
if (i.parsedType !== p.set)
|
|
2233
|
+
return m(i, {
|
|
2234
2234
|
code: d.invalid_type,
|
|
2235
2235
|
expected: p.set,
|
|
2236
|
-
received:
|
|
2236
|
+
received: i.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2238
|
+
const a = this._def;
|
|
2239
|
+
a.minSize !== null && i.data.size < a.minSize.value && (m(i, {
|
|
2240
2240
|
code: d.too_small,
|
|
2241
|
-
minimum:
|
|
2241
|
+
minimum: a.minSize.value,
|
|
2242
2242
|
type: "set",
|
|
2243
2243
|
inclusive: !0,
|
|
2244
2244
|
exact: !1,
|
|
2245
|
-
message:
|
|
2246
|
-
}), t.dirty()),
|
|
2245
|
+
message: a.minSize.message
|
|
2246
|
+
}), t.dirty()), a.maxSize !== null && i.data.size > a.maxSize.value && (m(i, {
|
|
2247
2247
|
code: d.too_big,
|
|
2248
|
-
maximum:
|
|
2248
|
+
maximum: a.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
|
-
message:
|
|
2252
|
+
message: a.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
2254
|
const s = this._def.valueType;
|
|
2255
|
-
function
|
|
2255
|
+
function o(l) {
|
|
2256
2256
|
const u = /* @__PURE__ */ new Set();
|
|
2257
2257
|
for (const f of l) {
|
|
2258
2258
|
if (f.status === "aborted")
|
|
@@ -2261,17 +2261,17 @@ class B extends _ {
|
|
|
2261
2261
|
}
|
|
2262
2262
|
return { status: t.value, value: u };
|
|
2263
2263
|
}
|
|
2264
|
-
const
|
|
2265
|
-
return
|
|
2264
|
+
const c = [...i.data.values()].map((l, u) => s._parse(new P(i, l, i.path, u)));
|
|
2265
|
+
return i.common.async ? Promise.all(c).then((l) => o(l)) : o(c);
|
|
2266
2266
|
}
|
|
2267
2267
|
min(e, t) {
|
|
2268
|
-
return new
|
|
2268
|
+
return new W({
|
|
2269
2269
|
...this._def,
|
|
2270
2270
|
minSize: { value: e, message: h.toString(t) }
|
|
2271
2271
|
});
|
|
2272
2272
|
}
|
|
2273
2273
|
max(e, t) {
|
|
2274
|
-
return new
|
|
2274
|
+
return new W({
|
|
2275
2275
|
...this._def,
|
|
2276
2276
|
maxSize: { value: e, message: h.toString(t) }
|
|
2277
2277
|
});
|
|
@@ -2283,14 +2283,14 @@ class B extends _ {
|
|
|
2283
2283
|
return this.min(1, e);
|
|
2284
2284
|
}
|
|
2285
2285
|
}
|
|
2286
|
-
|
|
2286
|
+
W.create = (n, e) => new W({
|
|
2287
2287
|
valueType: n,
|
|
2288
2288
|
minSize: null,
|
|
2289
2289
|
maxSize: null,
|
|
2290
2290
|
typeName: g.ZodSet,
|
|
2291
2291
|
...v(e)
|
|
2292
2292
|
});
|
|
2293
|
-
class
|
|
2293
|
+
class X extends _ {
|
|
2294
2294
|
constructor() {
|
|
2295
2295
|
super(...arguments), this.validate = this.implement;
|
|
2296
2296
|
}
|
|
@@ -2302,15 +2302,15 @@ class Y extends _ {
|
|
|
2302
2302
|
expected: p.function,
|
|
2303
2303
|
received: t.parsedType
|
|
2304
2304
|
}), y;
|
|
2305
|
-
function
|
|
2306
|
-
return
|
|
2307
|
-
data:
|
|
2305
|
+
function i(c, l) {
|
|
2306
|
+
return _e({
|
|
2307
|
+
data: c,
|
|
2308
2308
|
path: t.path,
|
|
2309
2309
|
errorMaps: [
|
|
2310
2310
|
t.common.contextualErrorMap,
|
|
2311
2311
|
t.schemaErrorMap,
|
|
2312
|
-
|
|
2313
|
-
|
|
2312
|
+
ve(),
|
|
2313
|
+
G
|
|
2314
2314
|
].filter((u) => !!u),
|
|
2315
2315
|
issueData: {
|
|
2316
2316
|
code: d.invalid_arguments,
|
|
@@ -2318,15 +2318,15 @@ class Y extends _ {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
2320
2320
|
}
|
|
2321
|
-
function
|
|
2322
|
-
return
|
|
2323
|
-
data:
|
|
2321
|
+
function a(c, l) {
|
|
2322
|
+
return _e({
|
|
2323
|
+
data: c,
|
|
2324
2324
|
path: t.path,
|
|
2325
2325
|
errorMaps: [
|
|
2326
2326
|
t.common.contextualErrorMap,
|
|
2327
2327
|
t.schemaErrorMap,
|
|
2328
|
-
|
|
2329
|
-
|
|
2328
|
+
ve(),
|
|
2329
|
+
G
|
|
2330
2330
|
].filter((u) => !!u),
|
|
2331
2331
|
issueData: {
|
|
2332
2332
|
code: d.invalid_return_type,
|
|
@@ -2334,26 +2334,26 @@ class Y extends _ {
|
|
|
2334
2334
|
}
|
|
2335
2335
|
});
|
|
2336
2336
|
}
|
|
2337
|
-
const s = { errorMap: t.common.contextualErrorMap },
|
|
2338
|
-
if (this._def.returns instanceof
|
|
2339
|
-
const
|
|
2340
|
-
return
|
|
2341
|
-
const u = new A([]), f = await
|
|
2342
|
-
throw u.addIssue(
|
|
2343
|
-
}), x = await Reflect.apply(
|
|
2344
|
-
return await
|
|
2345
|
-
throw u.addIssue(
|
|
2337
|
+
const s = { errorMap: t.common.contextualErrorMap }, o = t.data;
|
|
2338
|
+
if (this._def.returns instanceof H) {
|
|
2339
|
+
const c = this;
|
|
2340
|
+
return S(async function(...l) {
|
|
2341
|
+
const u = new A([]), f = await c._def.args.parseAsync(l, s).catch((I) => {
|
|
2342
|
+
throw u.addIssue(i(l, I)), u;
|
|
2343
|
+
}), x = await Reflect.apply(o, this, f);
|
|
2344
|
+
return await c._def.returns._def.type.parseAsync(x, s).catch((I) => {
|
|
2345
|
+
throw u.addIssue(a(x, I)), u;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
2349
|
-
const
|
|
2350
|
-
return
|
|
2351
|
-
const u =
|
|
2349
|
+
const c = this;
|
|
2350
|
+
return S(function(...l) {
|
|
2351
|
+
const u = c._def.args.safeParse(l, s);
|
|
2352
2352
|
if (!u.success)
|
|
2353
|
-
throw new A([
|
|
2354
|
-
const f = Reflect.apply(
|
|
2353
|
+
throw new A([i(l, u.error)]);
|
|
2354
|
+
const f = Reflect.apply(o, this, u.data), x = c._def.returns.safeParse(f, s);
|
|
2355
2355
|
if (!x.success)
|
|
2356
|
-
throw new A([
|
|
2356
|
+
throw new A([a(f, x.error)]);
|
|
2357
2357
|
return x.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
@@ -2365,13 +2365,13 @@ class Y extends _ {
|
|
|
2365
2365
|
return this._def.returns;
|
|
2366
2366
|
}
|
|
2367
2367
|
args(...e) {
|
|
2368
|
-
return new
|
|
2368
|
+
return new X({
|
|
2369
2369
|
...this._def,
|
|
2370
|
-
args:
|
|
2370
|
+
args: D.create(e).rest(U.create())
|
|
2371
2371
|
});
|
|
2372
2372
|
}
|
|
2373
2373
|
returns(e) {
|
|
2374
|
-
return new
|
|
2374
|
+
return new X({
|
|
2375
2375
|
...this._def,
|
|
2376
2376
|
returns: e
|
|
2377
2377
|
});
|
|
@@ -2382,12 +2382,12 @@ class Y extends _ {
|
|
|
2382
2382
|
strictImplement(e) {
|
|
2383
2383
|
return this.parse(e);
|
|
2384
2384
|
}
|
|
2385
|
-
static create(e, t,
|
|
2386
|
-
return new
|
|
2387
|
-
args: e ||
|
|
2388
|
-
returns: t ||
|
|
2385
|
+
static create(e, t, i) {
|
|
2386
|
+
return new X({
|
|
2387
|
+
args: e || D.create([]).rest(U.create()),
|
|
2388
|
+
returns: t || U.create(),
|
|
2389
2389
|
typeName: g.ZodFunction,
|
|
2390
|
-
...v(
|
|
2390
|
+
...v(i)
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
@@ -2405,7 +2405,7 @@ de.create = (n, e) => new de({
|
|
|
2405
2405
|
typeName: g.ZodLazy,
|
|
2406
2406
|
...v(e)
|
|
2407
2407
|
});
|
|
2408
|
-
class
|
|
2408
|
+
class le extends _ {
|
|
2409
2409
|
_parse(e) {
|
|
2410
2410
|
if (e.data !== this._def.value) {
|
|
2411
2411
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2421,40 +2421,40 @@ class ue extends _ {
|
|
|
2421
2421
|
return this._def.value;
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
|
|
2424
|
+
le.create = (n, e) => new le({
|
|
2425
2425
|
value: n,
|
|
2426
2426
|
typeName: g.ZodLiteral,
|
|
2427
2427
|
...v(e)
|
|
2428
2428
|
});
|
|
2429
|
-
function
|
|
2430
|
-
return new
|
|
2429
|
+
function Ge(n, e) {
|
|
2430
|
+
return new L({
|
|
2431
2431
|
values: n,
|
|
2432
2432
|
typeName: g.ZodEnum,
|
|
2433
2433
|
...v(e)
|
|
2434
2434
|
});
|
|
2435
2435
|
}
|
|
2436
|
-
class
|
|
2436
|
+
class L extends _ {
|
|
2437
2437
|
constructor() {
|
|
2438
|
-
super(...arguments),
|
|
2438
|
+
super(...arguments), te.set(this, void 0);
|
|
2439
2439
|
}
|
|
2440
2440
|
_parse(e) {
|
|
2441
2441
|
if (typeof e.data != "string") {
|
|
2442
|
-
const t = this._getOrReturnCtx(e),
|
|
2442
|
+
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2443
2443
|
return m(t, {
|
|
2444
|
-
expected: b.joinValues(
|
|
2444
|
+
expected: b.joinValues(i),
|
|
2445
2445
|
received: t.parsedType,
|
|
2446
2446
|
code: d.invalid_type
|
|
2447
2447
|
}), y;
|
|
2448
2448
|
}
|
|
2449
|
-
if (
|
|
2450
|
-
const t = this._getOrReturnCtx(e),
|
|
2449
|
+
if (be(this, te) || We(this, te, new Set(this._def.values)), !be(this, te).has(e.data)) {
|
|
2450
|
+
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2451
2451
|
return m(t, {
|
|
2452
2452
|
received: t.data,
|
|
2453
2453
|
code: d.invalid_enum_value,
|
|
2454
|
-
options:
|
|
2454
|
+
options: i
|
|
2455
2455
|
}), y;
|
|
2456
2456
|
}
|
|
2457
|
-
return
|
|
2457
|
+
return S(e.data);
|
|
2458
2458
|
}
|
|
2459
2459
|
get options() {
|
|
2460
2460
|
return this._def.values;
|
|
@@ -2478,55 +2478,55 @@ class V extends _ {
|
|
|
2478
2478
|
return e;
|
|
2479
2479
|
}
|
|
2480
2480
|
extract(e, t = this._def) {
|
|
2481
|
-
return
|
|
2481
|
+
return L.create(e, {
|
|
2482
2482
|
...this._def,
|
|
2483
2483
|
...t
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
exclude(e, t = this._def) {
|
|
2487
|
-
return
|
|
2487
|
+
return L.create(this.options.filter((i) => !e.includes(i)), {
|
|
2488
2488
|
...this._def,
|
|
2489
2489
|
...t
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
class
|
|
2493
|
+
te = /* @__PURE__ */ new WeakMap();
|
|
2494
|
+
L.create = Ge;
|
|
2495
|
+
class me extends _ {
|
|
2496
2496
|
constructor() {
|
|
2497
|
-
super(...arguments),
|
|
2497
|
+
super(...arguments), ne.set(this, void 0);
|
|
2498
2498
|
}
|
|
2499
2499
|
_parse(e) {
|
|
2500
|
-
const t = b.getValidEnumValues(this._def.values),
|
|
2501
|
-
if (
|
|
2502
|
-
const
|
|
2503
|
-
return m(
|
|
2504
|
-
expected: b.joinValues(
|
|
2505
|
-
received:
|
|
2500
|
+
const t = b.getValidEnumValues(this._def.values), i = this._getOrReturnCtx(e);
|
|
2501
|
+
if (i.parsedType !== p.string && i.parsedType !== p.number) {
|
|
2502
|
+
const a = b.objectValues(t);
|
|
2503
|
+
return m(i, {
|
|
2504
|
+
expected: b.joinValues(a),
|
|
2505
|
+
received: i.parsedType,
|
|
2506
2506
|
code: d.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
|
-
if (
|
|
2510
|
-
const
|
|
2511
|
-
return m(
|
|
2512
|
-
received:
|
|
2509
|
+
if (be(this, ne) || We(this, ne, new Set(b.getValidEnumValues(this._def.values))), !be(this, ne).has(e.data)) {
|
|
2510
|
+
const a = b.objectValues(t);
|
|
2511
|
+
return m(i, {
|
|
2512
|
+
received: i.data,
|
|
2513
2513
|
code: d.invalid_enum_value,
|
|
2514
|
-
options:
|
|
2514
|
+
options: a
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
|
-
return
|
|
2517
|
+
return S(e.data);
|
|
2518
2518
|
}
|
|
2519
2519
|
get enum() {
|
|
2520
2520
|
return this._def.values;
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2523
|
+
ne = /* @__PURE__ */ new WeakMap();
|
|
2524
|
+
me.create = (n, e) => new me({
|
|
2525
2525
|
values: n,
|
|
2526
2526
|
typeName: g.ZodNativeEnum,
|
|
2527
2527
|
...v(e)
|
|
2528
2528
|
});
|
|
2529
|
-
class
|
|
2529
|
+
class H extends _ {
|
|
2530
2530
|
unwrap() {
|
|
2531
2531
|
return this._def.type;
|
|
2532
2532
|
}
|
|
@@ -2538,14 +2538,14 @@ class J extends _ {
|
|
|
2538
2538
|
expected: p.promise,
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
|
-
const
|
|
2542
|
-
return
|
|
2541
|
+
const i = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
+
return S(i.then((a) => this._def.type.parseAsync(a, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
2546
2546
|
}
|
|
2547
2547
|
}
|
|
2548
|
-
|
|
2548
|
+
H.create = (n, e) => new H({
|
|
2549
2549
|
type: n,
|
|
2550
2550
|
typeName: g.ZodPromise,
|
|
2551
2551
|
...v(e)
|
|
@@ -2558,73 +2558,73 @@ class j extends _ {
|
|
|
2558
2558
|
return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2559
2559
|
}
|
|
2560
2560
|
_parse(e) {
|
|
2561
|
-
const { status: t, ctx:
|
|
2562
|
-
addIssue: (
|
|
2563
|
-
m(
|
|
2561
|
+
const { status: t, ctx: i } = this._processInputParams(e), a = this._def.effect || null, s = {
|
|
2562
|
+
addIssue: (o) => {
|
|
2563
|
+
m(i, o), o.fatal ? t.abort() : t.dirty();
|
|
2564
2564
|
},
|
|
2565
2565
|
get path() {
|
|
2566
|
-
return
|
|
2566
|
+
return i.path;
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
|
-
if (s.addIssue = s.addIssue.bind(s),
|
|
2570
|
-
const
|
|
2571
|
-
if (
|
|
2572
|
-
return Promise.resolve(
|
|
2569
|
+
if (s.addIssue = s.addIssue.bind(s), a.type === "preprocess") {
|
|
2570
|
+
const o = a.transform(i.data, s);
|
|
2571
|
+
if (i.common.async)
|
|
2572
|
+
return Promise.resolve(o).then(async (c) => {
|
|
2573
2573
|
if (t.value === "aborted")
|
|
2574
2574
|
return y;
|
|
2575
2575
|
const l = await this._def.schema._parseAsync({
|
|
2576
|
-
data:
|
|
2577
|
-
path:
|
|
2578
|
-
parent:
|
|
2576
|
+
data: c,
|
|
2577
|
+
path: i.path,
|
|
2578
|
+
parent: i
|
|
2579
2579
|
});
|
|
2580
|
-
return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ?
|
|
2580
|
+
return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ? Y(l.value) : l;
|
|
2581
2581
|
});
|
|
2582
2582
|
{
|
|
2583
2583
|
if (t.value === "aborted")
|
|
2584
2584
|
return y;
|
|
2585
|
-
const
|
|
2586
|
-
data:
|
|
2587
|
-
path:
|
|
2588
|
-
parent:
|
|
2585
|
+
const c = this._def.schema._parseSync({
|
|
2586
|
+
data: o,
|
|
2587
|
+
path: i.path,
|
|
2588
|
+
parent: i
|
|
2589
2589
|
});
|
|
2590
|
-
return
|
|
2590
|
+
return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? Y(c.value) : c;
|
|
2591
2591
|
}
|
|
2592
2592
|
}
|
|
2593
|
-
if (
|
|
2594
|
-
const
|
|
2595
|
-
const l =
|
|
2596
|
-
if (
|
|
2593
|
+
if (a.type === "refinement") {
|
|
2594
|
+
const o = (c) => {
|
|
2595
|
+
const l = a.refinement(c, s);
|
|
2596
|
+
if (i.common.async)
|
|
2597
2597
|
return Promise.resolve(l);
|
|
2598
2598
|
if (l instanceof Promise)
|
|
2599
2599
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2600
|
-
return
|
|
2600
|
+
return c;
|
|
2601
2601
|
};
|
|
2602
|
-
if (
|
|
2603
|
-
const
|
|
2604
|
-
data:
|
|
2605
|
-
path:
|
|
2606
|
-
parent:
|
|
2602
|
+
if (i.common.async === !1) {
|
|
2603
|
+
const c = this._def.schema._parseSync({
|
|
2604
|
+
data: i.data,
|
|
2605
|
+
path: i.path,
|
|
2606
|
+
parent: i
|
|
2607
2607
|
});
|
|
2608
|
-
return
|
|
2608
|
+
return c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value), { status: t.value, value: c.value });
|
|
2609
2609
|
} else
|
|
2610
|
-
return this._def.schema._parseAsync({ data:
|
|
2610
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((c) => c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value).then(() => ({ status: t.value, value: c.value }))));
|
|
2611
2611
|
}
|
|
2612
|
-
if (
|
|
2613
|
-
if (
|
|
2614
|
-
const
|
|
2615
|
-
data:
|
|
2616
|
-
path:
|
|
2617
|
-
parent:
|
|
2612
|
+
if (a.type === "transform")
|
|
2613
|
+
if (i.common.async === !1) {
|
|
2614
|
+
const o = this._def.schema._parseSync({
|
|
2615
|
+
data: i.data,
|
|
2616
|
+
path: i.path,
|
|
2617
|
+
parent: i
|
|
2618
2618
|
});
|
|
2619
|
-
if (!
|
|
2620
|
-
return
|
|
2621
|
-
const
|
|
2622
|
-
if (
|
|
2619
|
+
if (!q(o))
|
|
2620
|
+
return o;
|
|
2621
|
+
const c = a.transform(o.value, s);
|
|
2622
|
+
if (c instanceof Promise)
|
|
2623
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2624
|
-
return { status: t.value, value:
|
|
2624
|
+
return { status: t.value, value: c };
|
|
2625
2625
|
} else
|
|
2626
|
-
return this._def.schema._parseAsync({ data:
|
|
2627
|
-
b.assertNever(
|
|
2626
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((o) => q(o) ? Promise.resolve(a.transform(o.value, s)).then((c) => ({ status: t.value, value: c })) : o);
|
|
2627
|
+
b.assertNever(a);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
2630
|
j.create = (n, e, t) => new j({
|
|
@@ -2639,38 +2639,38 @@ j.createWithPreprocess = (n, e, t) => new j({
|
|
|
2639
2639
|
typeName: g.ZodEffects,
|
|
2640
2640
|
...v(t)
|
|
2641
2641
|
});
|
|
2642
|
-
class
|
|
2642
|
+
class O extends _ {
|
|
2643
2643
|
_parse(e) {
|
|
2644
|
-
return this._getType(e) === p.undefined ?
|
|
2644
|
+
return this._getType(e) === p.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
2645
2645
|
}
|
|
2646
2646
|
unwrap() {
|
|
2647
2647
|
return this._def.innerType;
|
|
2648
2648
|
}
|
|
2649
2649
|
}
|
|
2650
|
-
|
|
2650
|
+
O.create = (n, e) => new O({
|
|
2651
2651
|
innerType: n,
|
|
2652
2652
|
typeName: g.ZodOptional,
|
|
2653
2653
|
...v(e)
|
|
2654
2654
|
});
|
|
2655
|
-
class
|
|
2655
|
+
class F extends _ {
|
|
2656
2656
|
_parse(e) {
|
|
2657
|
-
return this._getType(e) === p.null ?
|
|
2657
|
+
return this._getType(e) === p.null ? S(null) : this._def.innerType._parse(e);
|
|
2658
2658
|
}
|
|
2659
2659
|
unwrap() {
|
|
2660
2660
|
return this._def.innerType;
|
|
2661
2661
|
}
|
|
2662
2662
|
}
|
|
2663
|
-
|
|
2663
|
+
F.create = (n, e) => new F({
|
|
2664
2664
|
innerType: n,
|
|
2665
2665
|
typeName: g.ZodNullable,
|
|
2666
2666
|
...v(e)
|
|
2667
2667
|
});
|
|
2668
|
-
class
|
|
2668
|
+
class pe extends _ {
|
|
2669
2669
|
_parse(e) {
|
|
2670
2670
|
const { ctx: t } = this._processInputParams(e);
|
|
2671
|
-
let
|
|
2672
|
-
return t.parsedType === p.undefined && (
|
|
2673
|
-
data:
|
|
2671
|
+
let i = t.data;
|
|
2672
|
+
return t.parsedType === p.undefined && (i = this._def.defaultValue()), this._def.innerType._parse({
|
|
2673
|
+
data: i,
|
|
2674
2674
|
path: t.path,
|
|
2675
2675
|
parent: t
|
|
2676
2676
|
});
|
|
@@ -2679,42 +2679,42 @@ class me extends _ {
|
|
|
2679
2679
|
return this._def.innerType;
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
|
|
2682
|
+
pe.create = (n, e) => new pe({
|
|
2683
2683
|
innerType: n,
|
|
2684
2684
|
typeName: g.ZodDefault,
|
|
2685
2685
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2686
2686
|
...v(e)
|
|
2687
2687
|
});
|
|
2688
|
-
class
|
|
2688
|
+
class fe extends _ {
|
|
2689
2689
|
_parse(e) {
|
|
2690
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2690
|
+
const { ctx: t } = this._processInputParams(e), i = {
|
|
2691
2691
|
...t,
|
|
2692
2692
|
common: {
|
|
2693
2693
|
...t.common,
|
|
2694
2694
|
issues: []
|
|
2695
2695
|
}
|
|
2696
|
-
},
|
|
2697
|
-
data:
|
|
2698
|
-
path:
|
|
2696
|
+
}, a = this._def.innerType._parse({
|
|
2697
|
+
data: i.data,
|
|
2698
|
+
path: i.path,
|
|
2699
2699
|
parent: {
|
|
2700
|
-
...
|
|
2700
|
+
...i
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return
|
|
2703
|
+
return re(a) ? a.then((s) => ({
|
|
2704
2704
|
status: "valid",
|
|
2705
2705
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2706
2706
|
get error() {
|
|
2707
|
-
return new A(
|
|
2707
|
+
return new A(i.common.issues);
|
|
2708
2708
|
},
|
|
2709
|
-
input:
|
|
2709
|
+
input: i.data
|
|
2710
2710
|
})
|
|
2711
2711
|
})) : {
|
|
2712
2712
|
status: "valid",
|
|
2713
|
-
value:
|
|
2713
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
|
-
return new A(
|
|
2715
|
+
return new A(i.common.issues);
|
|
2716
2716
|
},
|
|
2717
|
-
input:
|
|
2717
|
+
input: i.data
|
|
2718
2718
|
})
|
|
2719
2719
|
};
|
|
2720
2720
|
}
|
|
@@ -2722,35 +2722,35 @@ class pe extends _ {
|
|
|
2722
2722
|
return this._def.innerType;
|
|
2723
2723
|
}
|
|
2724
2724
|
}
|
|
2725
|
-
|
|
2725
|
+
fe.create = (n, e) => new fe({
|
|
2726
2726
|
innerType: n,
|
|
2727
2727
|
typeName: g.ZodCatch,
|
|
2728
2728
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2729
2729
|
...v(e)
|
|
2730
2730
|
});
|
|
2731
|
-
class
|
|
2731
|
+
class Te extends _ {
|
|
2732
2732
|
_parse(e) {
|
|
2733
2733
|
if (this._getType(e) !== p.nan) {
|
|
2734
|
-
const
|
|
2735
|
-
return m(
|
|
2734
|
+
const i = this._getOrReturnCtx(e);
|
|
2735
|
+
return m(i, {
|
|
2736
2736
|
code: d.invalid_type,
|
|
2737
2737
|
expected: p.nan,
|
|
2738
|
-
received:
|
|
2738
|
+
received: i.parsedType
|
|
2739
2739
|
}), y;
|
|
2740
2740
|
}
|
|
2741
2741
|
return { status: "valid", value: e.data };
|
|
2742
2742
|
}
|
|
2743
2743
|
}
|
|
2744
|
-
|
|
2744
|
+
Te.create = (n) => new Te({
|
|
2745
2745
|
typeName: g.ZodNaN,
|
|
2746
2746
|
...v(n)
|
|
2747
2747
|
});
|
|
2748
|
-
const
|
|
2749
|
-
class
|
|
2748
|
+
const Et = Symbol("zod_brand");
|
|
2749
|
+
class Re extends _ {
|
|
2750
2750
|
_parse(e) {
|
|
2751
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2751
|
+
const { ctx: t } = this._processInputParams(e), i = t.data;
|
|
2752
2752
|
return this._def.type._parse({
|
|
2753
|
-
data:
|
|
2753
|
+
data: i,
|
|
2754
2754
|
path: t.path,
|
|
2755
2755
|
parent: t
|
|
2756
2756
|
});
|
|
@@ -2759,218 +2759,218 @@ class De extends _ {
|
|
|
2759
2759
|
return this._def.type;
|
|
2760
2760
|
}
|
|
2761
2761
|
}
|
|
2762
|
-
class
|
|
2762
|
+
class ge extends _ {
|
|
2763
2763
|
_parse(e) {
|
|
2764
|
-
const { status: t, ctx:
|
|
2765
|
-
if (
|
|
2764
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2765
|
+
if (i.common.async)
|
|
2766
2766
|
return (async () => {
|
|
2767
2767
|
const s = await this._def.in._parseAsync({
|
|
2768
|
-
data:
|
|
2769
|
-
path:
|
|
2770
|
-
parent:
|
|
2768
|
+
data: i.data,
|
|
2769
|
+
path: i.path,
|
|
2770
|
+
parent: i
|
|
2771
2771
|
});
|
|
2772
|
-
return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(),
|
|
2772
|
+
return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), Y(s.value)) : this._def.out._parseAsync({
|
|
2773
2773
|
data: s.value,
|
|
2774
|
-
path:
|
|
2775
|
-
parent:
|
|
2774
|
+
path: i.path,
|
|
2775
|
+
parent: i
|
|
2776
2776
|
});
|
|
2777
2777
|
})();
|
|
2778
2778
|
{
|
|
2779
|
-
const
|
|
2780
|
-
data:
|
|
2781
|
-
path:
|
|
2782
|
-
parent:
|
|
2779
|
+
const a = this._def.in._parseSync({
|
|
2780
|
+
data: i.data,
|
|
2781
|
+
path: i.path,
|
|
2782
|
+
parent: i
|
|
2783
2783
|
});
|
|
2784
|
-
return
|
|
2784
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), {
|
|
2785
2785
|
status: "dirty",
|
|
2786
|
-
value:
|
|
2786
|
+
value: a.value
|
|
2787
2787
|
}) : this._def.out._parseSync({
|
|
2788
|
-
data:
|
|
2789
|
-
path:
|
|
2790
|
-
parent:
|
|
2788
|
+
data: a.value,
|
|
2789
|
+
path: i.path,
|
|
2790
|
+
parent: i
|
|
2791
2791
|
});
|
|
2792
2792
|
}
|
|
2793
2793
|
}
|
|
2794
2794
|
static create(e, t) {
|
|
2795
|
-
return new
|
|
2795
|
+
return new ge({
|
|
2796
2796
|
in: e,
|
|
2797
2797
|
out: t,
|
|
2798
2798
|
typeName: g.ZodPipeline
|
|
2799
2799
|
});
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
|
-
class
|
|
2802
|
+
class he extends _ {
|
|
2803
2803
|
_parse(e) {
|
|
2804
|
-
const t = this._def.innerType._parse(e),
|
|
2805
|
-
return
|
|
2804
|
+
const t = this._def.innerType._parse(e), i = (a) => (q(a) && (a.value = Object.freeze(a.value)), a);
|
|
2805
|
+
return re(t) ? t.then((a) => i(a)) : i(t);
|
|
2806
2806
|
}
|
|
2807
2807
|
unwrap() {
|
|
2808
2808
|
return this._def.innerType;
|
|
2809
2809
|
}
|
|
2810
2810
|
}
|
|
2811
|
-
|
|
2811
|
+
he.create = (n, e) => new he({
|
|
2812
2812
|
innerType: n,
|
|
2813
2813
|
typeName: g.ZodReadonly,
|
|
2814
2814
|
...v(e)
|
|
2815
2815
|
});
|
|
2816
|
-
function
|
|
2816
|
+
function Le(n, e) {
|
|
2817
2817
|
const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return n ?
|
|
2822
|
-
var s,
|
|
2823
|
-
const
|
|
2824
|
-
if (
|
|
2825
|
-
return
|
|
2820
|
+
function Je(n, e = {}, t) {
|
|
2821
|
+
return n ? J.create().superRefine((i, a) => {
|
|
2822
|
+
var s, o;
|
|
2823
|
+
const c = n(i);
|
|
2824
|
+
if (c instanceof Promise)
|
|
2825
|
+
return c.then((l) => {
|
|
2826
2826
|
var u, f;
|
|
2827
2827
|
if (!l) {
|
|
2828
|
-
const x =
|
|
2829
|
-
|
|
2828
|
+
const x = Le(e, i), w = (f = (u = x.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
|
|
2829
|
+
a.addIssue({ code: "custom", ...x, fatal: w });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
|
-
if (!
|
|
2833
|
-
const l =
|
|
2834
|
-
|
|
2832
|
+
if (!c) {
|
|
2833
|
+
const l = Le(e, i), u = (o = (s = l.fatal) !== null && s !== void 0 ? s : t) !== null && o !== void 0 ? o : !0;
|
|
2834
|
+
a.addIssue({ code: "custom", ...l, fatal: u });
|
|
2835
2835
|
}
|
|
2836
|
-
}) :
|
|
2836
|
+
}) : J.create();
|
|
2837
2837
|
}
|
|
2838
|
-
const
|
|
2838
|
+
const Rt = {
|
|
2839
2839
|
object: k.lazycreate
|
|
2840
2840
|
};
|
|
2841
2841
|
var g;
|
|
2842
2842
|
(function(n) {
|
|
2843
2843
|
n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
|
|
2844
2844
|
})(g || (g = {}));
|
|
2845
|
-
const
|
|
2845
|
+
const $t = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) =>
|
|
2847
|
+
}) => Je((t) => t instanceof n, e), He = N.create, Ke = z.create, Mt = Te.create, zt = V.create, et = ie.create, Vt = B.create, Lt = xe.create, Ft = ae.create, Ut = se.create, qt = J.create, Bt = U.create, Wt = M.create, Qt = ke.create, Yt = C.create, Xt = k.create, Gt = k.strictCreate, Jt = oe.create, Ht = Se.create, Kt = ce.create, en = D.create, tn = ue.create, nn = we.create, rn = W.create, an = X.create, sn = de.create, on = le.create, cn = L.create, un = me.create, dn = H.create, Fe = j.create, ln = O.create, mn = F.create, pn = j.createWithPreprocess, fn = ge.create, hn = () => He().optional(), gn = () => Ke().optional(), yn = () => et().optional(), vn = {
|
|
2848
2848
|
string: (n) => N.create({ ...n, coerce: !0 }),
|
|
2849
|
-
number: (n) =>
|
|
2850
|
-
boolean: (n) =>
|
|
2849
|
+
number: (n) => z.create({ ...n, coerce: !0 }),
|
|
2850
|
+
boolean: (n) => ie.create({
|
|
2851
2851
|
...n,
|
|
2852
2852
|
coerce: !0
|
|
2853
2853
|
}),
|
|
2854
|
-
bigint: (n) =>
|
|
2855
|
-
date: (n) =>
|
|
2856
|
-
},
|
|
2854
|
+
bigint: (n) => V.create({ ...n, coerce: !0 }),
|
|
2855
|
+
date: (n) => B.create({ ...n, coerce: !0 })
|
|
2856
|
+
}, _n = y;
|
|
2857
2857
|
var r = /* @__PURE__ */ Object.freeze({
|
|
2858
2858
|
__proto__: null,
|
|
2859
|
-
defaultErrorMap:
|
|
2860
|
-
setErrorMap:
|
|
2861
|
-
getErrorMap:
|
|
2862
|
-
makeIssue:
|
|
2863
|
-
EMPTY_PATH:
|
|
2859
|
+
defaultErrorMap: G,
|
|
2860
|
+
setErrorMap: mt,
|
|
2861
|
+
getErrorMap: ve,
|
|
2862
|
+
makeIssue: _e,
|
|
2863
|
+
EMPTY_PATH: pt,
|
|
2864
2864
|
addIssueToContext: m,
|
|
2865
|
-
ParseStatus:
|
|
2865
|
+
ParseStatus: T,
|
|
2866
2866
|
INVALID: y,
|
|
2867
|
-
DIRTY:
|
|
2868
|
-
OK:
|
|
2869
|
-
isAborted:
|
|
2870
|
-
isDirty:
|
|
2871
|
-
isValid:
|
|
2872
|
-
isAsync:
|
|
2867
|
+
DIRTY: Y,
|
|
2868
|
+
OK: S,
|
|
2869
|
+
isAborted: Oe,
|
|
2870
|
+
isDirty: Pe,
|
|
2871
|
+
isValid: q,
|
|
2872
|
+
isAsync: re,
|
|
2873
2873
|
get util() {
|
|
2874
2874
|
return b;
|
|
2875
2875
|
},
|
|
2876
2876
|
get objectUtil() {
|
|
2877
|
-
return
|
|
2877
|
+
return Ze;
|
|
2878
2878
|
},
|
|
2879
2879
|
ZodParsedType: p,
|
|
2880
|
-
getParsedType:
|
|
2880
|
+
getParsedType: R,
|
|
2881
2881
|
ZodType: _,
|
|
2882
|
-
datetimeRegex:
|
|
2882
|
+
datetimeRegex: Xe,
|
|
2883
2883
|
ZodString: N,
|
|
2884
|
-
ZodNumber:
|
|
2885
|
-
ZodBigInt:
|
|
2886
|
-
ZodBoolean:
|
|
2887
|
-
ZodDate:
|
|
2888
|
-
ZodSymbol:
|
|
2884
|
+
ZodNumber: z,
|
|
2885
|
+
ZodBigInt: V,
|
|
2886
|
+
ZodBoolean: ie,
|
|
2887
|
+
ZodDate: B,
|
|
2888
|
+
ZodSymbol: xe,
|
|
2889
2889
|
ZodUndefined: ae,
|
|
2890
|
-
ZodNull:
|
|
2891
|
-
ZodAny:
|
|
2892
|
-
ZodUnknown:
|
|
2893
|
-
ZodNever:
|
|
2894
|
-
ZodVoid:
|
|
2890
|
+
ZodNull: se,
|
|
2891
|
+
ZodAny: J,
|
|
2892
|
+
ZodUnknown: U,
|
|
2893
|
+
ZodNever: M,
|
|
2894
|
+
ZodVoid: ke,
|
|
2895
2895
|
ZodArray: C,
|
|
2896
2896
|
ZodObject: k,
|
|
2897
|
-
ZodUnion:
|
|
2898
|
-
ZodDiscriminatedUnion:
|
|
2899
|
-
ZodIntersection:
|
|
2900
|
-
ZodTuple:
|
|
2901
|
-
ZodRecord:
|
|
2902
|
-
ZodMap:
|
|
2903
|
-
ZodSet:
|
|
2904
|
-
ZodFunction:
|
|
2897
|
+
ZodUnion: oe,
|
|
2898
|
+
ZodDiscriminatedUnion: Se,
|
|
2899
|
+
ZodIntersection: ce,
|
|
2900
|
+
ZodTuple: D,
|
|
2901
|
+
ZodRecord: ue,
|
|
2902
|
+
ZodMap: we,
|
|
2903
|
+
ZodSet: W,
|
|
2904
|
+
ZodFunction: X,
|
|
2905
2905
|
ZodLazy: de,
|
|
2906
|
-
ZodLiteral:
|
|
2907
|
-
ZodEnum:
|
|
2908
|
-
ZodNativeEnum:
|
|
2909
|
-
ZodPromise:
|
|
2906
|
+
ZodLiteral: le,
|
|
2907
|
+
ZodEnum: L,
|
|
2908
|
+
ZodNativeEnum: me,
|
|
2909
|
+
ZodPromise: H,
|
|
2910
2910
|
ZodEffects: j,
|
|
2911
2911
|
ZodTransformer: j,
|
|
2912
|
-
ZodOptional:
|
|
2913
|
-
ZodNullable:
|
|
2914
|
-
ZodDefault:
|
|
2915
|
-
ZodCatch:
|
|
2916
|
-
ZodNaN:
|
|
2917
|
-
BRAND:
|
|
2918
|
-
ZodBranded:
|
|
2919
|
-
ZodPipeline:
|
|
2920
|
-
ZodReadonly:
|
|
2921
|
-
custom:
|
|
2912
|
+
ZodOptional: O,
|
|
2913
|
+
ZodNullable: F,
|
|
2914
|
+
ZodDefault: pe,
|
|
2915
|
+
ZodCatch: fe,
|
|
2916
|
+
ZodNaN: Te,
|
|
2917
|
+
BRAND: Et,
|
|
2918
|
+
ZodBranded: Re,
|
|
2919
|
+
ZodPipeline: ge,
|
|
2920
|
+
ZodReadonly: he,
|
|
2921
|
+
custom: Je,
|
|
2922
2922
|
Schema: _,
|
|
2923
2923
|
ZodSchema: _,
|
|
2924
|
-
late:
|
|
2924
|
+
late: Rt,
|
|
2925
2925
|
get ZodFirstPartyTypeKind() {
|
|
2926
2926
|
return g;
|
|
2927
2927
|
},
|
|
2928
|
-
coerce:
|
|
2929
|
-
any:
|
|
2930
|
-
array:
|
|
2931
|
-
bigint:
|
|
2932
|
-
boolean:
|
|
2933
|
-
date:
|
|
2934
|
-
discriminatedUnion:
|
|
2935
|
-
effect:
|
|
2936
|
-
enum:
|
|
2937
|
-
function:
|
|
2938
|
-
instanceof:
|
|
2939
|
-
intersection:
|
|
2940
|
-
lazy:
|
|
2941
|
-
literal:
|
|
2942
|
-
map:
|
|
2943
|
-
nan:
|
|
2944
|
-
nativeEnum:
|
|
2945
|
-
never:
|
|
2946
|
-
null:
|
|
2947
|
-
nullable:
|
|
2948
|
-
number:
|
|
2949
|
-
object:
|
|
2950
|
-
oboolean:
|
|
2951
|
-
onumber:
|
|
2952
|
-
optional:
|
|
2953
|
-
ostring:
|
|
2954
|
-
pipeline:
|
|
2955
|
-
preprocess:
|
|
2956
|
-
promise:
|
|
2957
|
-
record:
|
|
2958
|
-
set:
|
|
2959
|
-
strictObject:
|
|
2960
|
-
string:
|
|
2961
|
-
symbol:
|
|
2962
|
-
transformer:
|
|
2963
|
-
tuple:
|
|
2964
|
-
undefined:
|
|
2965
|
-
union:
|
|
2966
|
-
unknown:
|
|
2967
|
-
void:
|
|
2968
|
-
NEVER:
|
|
2928
|
+
coerce: vn,
|
|
2929
|
+
any: qt,
|
|
2930
|
+
array: Yt,
|
|
2931
|
+
bigint: zt,
|
|
2932
|
+
boolean: et,
|
|
2933
|
+
date: Vt,
|
|
2934
|
+
discriminatedUnion: Ht,
|
|
2935
|
+
effect: Fe,
|
|
2936
|
+
enum: cn,
|
|
2937
|
+
function: an,
|
|
2938
|
+
instanceof: $t,
|
|
2939
|
+
intersection: Kt,
|
|
2940
|
+
lazy: sn,
|
|
2941
|
+
literal: on,
|
|
2942
|
+
map: nn,
|
|
2943
|
+
nan: Mt,
|
|
2944
|
+
nativeEnum: un,
|
|
2945
|
+
never: Wt,
|
|
2946
|
+
null: Ut,
|
|
2947
|
+
nullable: mn,
|
|
2948
|
+
number: Ke,
|
|
2949
|
+
object: Xt,
|
|
2950
|
+
oboolean: yn,
|
|
2951
|
+
onumber: gn,
|
|
2952
|
+
optional: ln,
|
|
2953
|
+
ostring: hn,
|
|
2954
|
+
pipeline: fn,
|
|
2955
|
+
preprocess: pn,
|
|
2956
|
+
promise: dn,
|
|
2957
|
+
record: tn,
|
|
2958
|
+
set: rn,
|
|
2959
|
+
strictObject: Gt,
|
|
2960
|
+
string: He,
|
|
2961
|
+
symbol: Lt,
|
|
2962
|
+
transformer: Fe,
|
|
2963
|
+
tuple: en,
|
|
2964
|
+
undefined: Ft,
|
|
2965
|
+
union: Jt,
|
|
2966
|
+
unknown: Bt,
|
|
2967
|
+
void: Qt,
|
|
2968
|
+
NEVER: _n,
|
|
2969
2969
|
ZodIssueCode: d,
|
|
2970
|
-
quotelessJson:
|
|
2970
|
+
quotelessJson: lt,
|
|
2971
2971
|
ZodError: A
|
|
2972
2972
|
});
|
|
2973
|
-
const
|
|
2973
|
+
const Ie = r.object({
|
|
2974
2974
|
country: r.string().optional(),
|
|
2975
2975
|
city: r.string().optional(),
|
|
2976
2976
|
street: r.string().optional(),
|
|
@@ -2979,37 +2979,37 @@ const Se = r.object({
|
|
|
2979
2979
|
apartmentEnterNumber: r.string().optional(),
|
|
2980
2980
|
apartmentNumber: r.string().optional(),
|
|
2981
2981
|
zip: r.string().optional()
|
|
2982
|
-
}),
|
|
2983
|
-
function
|
|
2982
|
+
}), $ = r.string().min(1, { message: "שדה חובה" }), Un = r.string().regex(/^\d+$/, "Must be a numeric string"), qn = r.object({ url: r.string().url(), id: r.string() });
|
|
2983
|
+
function Bn(n) {
|
|
2984
2984
|
return !!(n != null && n.url);
|
|
2985
2985
|
}
|
|
2986
|
-
const
|
|
2986
|
+
const ye = r.object({
|
|
2987
2987
|
lang: r.enum(["he"]),
|
|
2988
2988
|
value: r.string()
|
|
2989
|
-
}),
|
|
2989
|
+
}), tt = r.object({
|
|
2990
2990
|
id: r.string().min(1),
|
|
2991
2991
|
companyId: r.string().min(1),
|
|
2992
2992
|
storeId: r.string().min(1),
|
|
2993
2993
|
parentId: r.string().nullish(),
|
|
2994
2994
|
tag: r.string().optional(),
|
|
2995
|
-
locales: r.array(
|
|
2995
|
+
locales: r.array(ye),
|
|
2996
2996
|
depth: r.number()
|
|
2997
|
-
}),
|
|
2998
|
-
children: r.lazy(() =>
|
|
2999
|
-
}),
|
|
2997
|
+
}), $e = tt.extend({
|
|
2998
|
+
children: r.lazy(() => $e.array())
|
|
2999
|
+
}), Wn = tt.extend({
|
|
3000
3000
|
index: r.number(),
|
|
3001
3001
|
depth: r.number(),
|
|
3002
3002
|
collapsed: r.boolean().optional(),
|
|
3003
|
-
children: r.array(
|
|
3004
|
-
}),
|
|
3003
|
+
children: r.array($e)
|
|
3004
|
+
}), ee = r.string().min(1), Me = r.object({
|
|
3005
3005
|
type: r.literal("Product"),
|
|
3006
|
-
storeId:
|
|
3007
|
-
companyId:
|
|
3008
|
-
id:
|
|
3009
|
-
objectID:
|
|
3010
|
-
sku:
|
|
3011
|
-
name: r.array(
|
|
3012
|
-
description: r.array(
|
|
3006
|
+
storeId: ee,
|
|
3007
|
+
companyId: ee,
|
|
3008
|
+
id: ee,
|
|
3009
|
+
objectID: ee,
|
|
3010
|
+
sku: ee,
|
|
3011
|
+
name: r.array(ye),
|
|
3012
|
+
description: r.array(ye),
|
|
3013
3013
|
isPublished: r.boolean(),
|
|
3014
3014
|
vat: r.boolean(),
|
|
3015
3015
|
priceType: r.object({
|
|
@@ -3038,7 +3038,7 @@ const ge = r.object({
|
|
|
3038
3038
|
brand: r.string(),
|
|
3039
3039
|
importer: r.string(),
|
|
3040
3040
|
supplier: r.string(),
|
|
3041
|
-
ingredients: r.array(
|
|
3041
|
+
ingredients: r.array(ye),
|
|
3042
3042
|
created_at: r.number(),
|
|
3043
3043
|
updated_at: r.number(),
|
|
3044
3044
|
categoryIds: r.array(r.string().nonempty()),
|
|
@@ -3047,7 +3047,7 @@ const ge = r.object({
|
|
|
3047
3047
|
unit: r.enum(["piece", "kg", "gram", "liter", "ml"])
|
|
3048
3048
|
}).optional(),
|
|
3049
3049
|
// @deprecated
|
|
3050
|
-
categoryList: r.array(
|
|
3050
|
+
categoryList: r.array($e).optional(),
|
|
3051
3051
|
// @deprecated
|
|
3052
3052
|
categories: r.object({
|
|
3053
3053
|
lvl0: r.array(r.string()),
|
|
@@ -3058,63 +3058,63 @@ const ge = r.object({
|
|
|
3058
3058
|
}).optional(),
|
|
3059
3059
|
// @deprecated
|
|
3060
3060
|
categoryNames: r.array(r.string()).optional()
|
|
3061
|
-
}),
|
|
3061
|
+
}), Qn = Me.extend({
|
|
3062
3062
|
image: r.instanceof(File).optional()
|
|
3063
|
-
}),
|
|
3064
|
-
product:
|
|
3063
|
+
}), bn = r.enum(["delivered", "missing", "substituted"]), xn = r.object({
|
|
3064
|
+
product: Me,
|
|
3065
3065
|
amount: r.number().positive(),
|
|
3066
3066
|
price: r.number()
|
|
3067
|
-
}),
|
|
3068
|
-
product:
|
|
3067
|
+
}), nt = r.object({
|
|
3068
|
+
product: Me,
|
|
3069
3069
|
originalPrice: r.number().optional(),
|
|
3070
3070
|
finalPrice: r.number().optional(),
|
|
3071
3071
|
finalDiscount: r.number().optional(),
|
|
3072
3072
|
amount: r.number().positive({ message: "Quantity must be a positive number." }),
|
|
3073
3073
|
// Picking / fulfillment — optional so existing items stay valid (treated as "delivered").
|
|
3074
|
-
status:
|
|
3075
|
-
substitutedWith:
|
|
3076
|
-
}),
|
|
3074
|
+
status: bn.optional(),
|
|
3075
|
+
substitutedWith: xn.nullable().optional()
|
|
3076
|
+
}), Yn = r.object({
|
|
3077
3077
|
type: r.literal("Cart"),
|
|
3078
3078
|
id: r.string().uuid(),
|
|
3079
3079
|
companyId: r.string().uuid(),
|
|
3080
3080
|
storeId: r.string().uuid(),
|
|
3081
3081
|
userId: r.string().uuid(),
|
|
3082
3082
|
status: r.enum(["active", "draft", "completed"]),
|
|
3083
|
-
items: r.array(
|
|
3084
|
-
}),
|
|
3083
|
+
items: r.array(nt)
|
|
3084
|
+
}), Xn = r.object({
|
|
3085
3085
|
id: r.string(),
|
|
3086
3086
|
name: r.string(),
|
|
3087
3087
|
websiteDomains: r.array(r.string())
|
|
3088
|
-
}),
|
|
3088
|
+
}), Gn = r.object({
|
|
3089
3089
|
type: r.literal("FavoriteProduct"),
|
|
3090
3090
|
id: r.string().uuid(),
|
|
3091
3091
|
companyId: r.string().uuid(),
|
|
3092
3092
|
storeId: r.string().uuid(),
|
|
3093
3093
|
userId: r.string().uuid(),
|
|
3094
3094
|
productId: r.string().uuid()
|
|
3095
|
-
}),
|
|
3095
|
+
}), Ae = r.enum(["external", "j5", "none"]), kn = r.object({
|
|
3096
3096
|
type: r.literal("Profile"),
|
|
3097
|
-
id:
|
|
3098
|
-
companyId:
|
|
3099
|
-
storeId:
|
|
3100
|
-
tenantId:
|
|
3097
|
+
id: $,
|
|
3098
|
+
companyId: $,
|
|
3099
|
+
storeId: $,
|
|
3100
|
+
tenantId: $,
|
|
3101
3101
|
// @deprecated
|
|
3102
3102
|
clientType: r.enum(["user", "company"]),
|
|
3103
3103
|
companyName: r.string().optional(),
|
|
3104
|
-
displayName:
|
|
3104
|
+
displayName: $,
|
|
3105
3105
|
email: r.string().email(),
|
|
3106
3106
|
phoneNumber: r.string().optional(),
|
|
3107
|
-
address:
|
|
3107
|
+
address: Ie.optional(),
|
|
3108
3108
|
isAnonymous: r.boolean(),
|
|
3109
3109
|
createdDate: r.number(),
|
|
3110
3110
|
lastActivityDate: r.number(),
|
|
3111
3111
|
//todo
|
|
3112
|
-
paymentType:
|
|
3112
|
+
paymentType: Ae.optional(),
|
|
3113
3113
|
/** @deprecated Use organizationIds instead */
|
|
3114
3114
|
organizationId: r.string().optional().nullable(),
|
|
3115
3115
|
/** Array of organization IDs this user belongs to */
|
|
3116
3116
|
organizationIds: r.array(r.string()).optional()
|
|
3117
|
-
}),
|
|
3117
|
+
}), rt = r.object({
|
|
3118
3118
|
_COMMENT: r.string().optional(),
|
|
3119
3119
|
transaction_id: r.string(),
|
|
3120
3120
|
date: r.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
|
|
@@ -3126,7 +3126,7 @@ const ge = r.object({
|
|
|
3126
3126
|
price_discount_in_currency: r.number(),
|
|
3127
3127
|
price_total: r.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
|
|
3128
3128
|
price_total_in_currency: r.number().positive()
|
|
3129
|
-
}),
|
|
3129
|
+
}), wn = r.object({
|
|
3130
3130
|
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3131
3131
|
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3132
3132
|
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
@@ -3134,10 +3134,10 @@ const ge = r.object({
|
|
|
3134
3134
|
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3135
3135
|
success: r.boolean(),
|
|
3136
3136
|
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3137
|
-
calculatedData:
|
|
3137
|
+
calculatedData: rt,
|
|
3138
3138
|
warning: r.string().optional(),
|
|
3139
3139
|
date: r.number().optional()
|
|
3140
|
-
}),
|
|
3140
|
+
}), Tn = r.object({
|
|
3141
3141
|
id: r.string().min(1, "ID is required"),
|
|
3142
3142
|
number: r.string().min(1, "Number is required"),
|
|
3143
3143
|
date: r.number().min(1, "Date is required"),
|
|
@@ -3166,47 +3166,47 @@ const ge = r.object({
|
|
|
3166
3166
|
total: r.number().min(1, "Total is required").optional(),
|
|
3167
3167
|
vat: r.number().min(1, "VAT is required").optional(),
|
|
3168
3168
|
link: r.string().url("Link must be a valid URL").optional()
|
|
3169
|
-
}),
|
|
3169
|
+
}), Sn = r.enum([
|
|
3170
3170
|
"credit",
|
|
3171
3171
|
"net15",
|
|
3172
3172
|
"net30",
|
|
3173
3173
|
"net60",
|
|
3174
3174
|
"net90"
|
|
3175
|
-
]),
|
|
3175
|
+
]), it = r.object({
|
|
3176
3176
|
number: r.string(),
|
|
3177
3177
|
name: r.string(),
|
|
3178
3178
|
id: r.string(),
|
|
3179
3179
|
// Optional, admin-managed billing config (see company-edit-like-demo plan, Phase 2)
|
|
3180
|
-
payTerms:
|
|
3180
|
+
payTerms: Sn.optional(),
|
|
3181
3181
|
creditLimit: r.number().optional(),
|
|
3182
3182
|
isPrimary: r.boolean().optional(),
|
|
3183
3183
|
// Optional category restriction — when `restricted`, the account is limited to
|
|
3184
3184
|
// `allowedCategories` (category ids). Order-time enforcement is a separate concern.
|
|
3185
3185
|
restricted: r.boolean().optional(),
|
|
3186
3186
|
allowedCategories: r.array(r.string()).optional()
|
|
3187
|
-
}),
|
|
3187
|
+
}), In = r.object({
|
|
3188
3188
|
id: r.string(),
|
|
3189
3189
|
label: r.string(),
|
|
3190
3190
|
address: r.string().optional(),
|
|
3191
3191
|
phone: r.string().optional(),
|
|
3192
3192
|
isPrimary: r.boolean().optional()
|
|
3193
|
-
}),
|
|
3193
|
+
}), An = r.object({
|
|
3194
3194
|
id: r.string(),
|
|
3195
3195
|
name: r.string(),
|
|
3196
3196
|
discountPercentage: r.number().positive().min(0).max(100).optional(),
|
|
3197
3197
|
nameOnInvoice: r.string().optional(),
|
|
3198
|
-
billingAccounts: r.array(
|
|
3199
|
-
paymentType:
|
|
3198
|
+
billingAccounts: r.array(it),
|
|
3199
|
+
paymentType: Ae,
|
|
3200
3200
|
companyNumber: r.string().optional(),
|
|
3201
|
-
address:
|
|
3201
|
+
address: Ie.optional(),
|
|
3202
3202
|
groupId: r.string().optional(),
|
|
3203
3203
|
// Contact / billing details (admin-managed, optional — see company-edit-like-demo plan)
|
|
3204
3204
|
phone: r.string().optional(),
|
|
3205
3205
|
email: r.string().optional(),
|
|
3206
3206
|
notes: r.string().optional(),
|
|
3207
3207
|
freeShipping: r.boolean().optional(),
|
|
3208
|
-
branches: r.array(
|
|
3209
|
-
}),
|
|
3208
|
+
branches: r.array(In).optional()
|
|
3209
|
+
}), Jn = An.omit({ id: !0 }), Ue = r.object({
|
|
3210
3210
|
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3211
3211
|
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3212
3212
|
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
@@ -3214,10 +3214,10 @@ const ge = r.object({
|
|
|
3214
3214
|
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3215
3215
|
success: r.boolean(),
|
|
3216
3216
|
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3217
|
-
calculatedData:
|
|
3217
|
+
calculatedData: rt,
|
|
3218
3218
|
warning: r.string().optional(),
|
|
3219
3219
|
date: r.number().optional()
|
|
3220
|
-
}),
|
|
3220
|
+
}), Nn = r.object({
|
|
3221
3221
|
id: r.string().min(1, "ID is required"),
|
|
3222
3222
|
number: r.string().min(1, "Number is required"),
|
|
3223
3223
|
date: r.string().min(1, "Date is required"),
|
|
@@ -3246,13 +3246,13 @@ const ge = r.object({
|
|
|
3246
3246
|
total: r.number().min(1, "Total is required").optional(),
|
|
3247
3247
|
vat: r.number().min(1, "VAT is required").optional(),
|
|
3248
3248
|
link: r.string().url("Link must be a valid URL").optional()
|
|
3249
|
-
}),
|
|
3249
|
+
}), Hn = r.object({
|
|
3250
3250
|
type: r.literal("Order"),
|
|
3251
3251
|
createdBy: r.enum(["user", "admin"]).optional(),
|
|
3252
|
-
id:
|
|
3253
|
-
companyId:
|
|
3254
|
-
storeId:
|
|
3255
|
-
userId:
|
|
3252
|
+
id: $,
|
|
3253
|
+
companyId: $,
|
|
3254
|
+
storeId: $,
|
|
3255
|
+
userId: $,
|
|
3256
3256
|
status: r.enum([
|
|
3257
3257
|
"draft",
|
|
3258
3258
|
// before payment
|
|
@@ -3267,12 +3267,12 @@ const ge = r.object({
|
|
|
3267
3267
|
"completed",
|
|
3268
3268
|
"refunded"
|
|
3269
3269
|
]),
|
|
3270
|
-
paymentType:
|
|
3270
|
+
paymentType: Ae.optional(),
|
|
3271
3271
|
paymentStatus: r.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
|
|
3272
3272
|
//todo check if hyp support partial refund
|
|
3273
3273
|
cart: r.object({
|
|
3274
3274
|
id: r.string(),
|
|
3275
|
-
items: r.array(
|
|
3275
|
+
items: r.array(nt),
|
|
3276
3276
|
cartDiscount: r.number(),
|
|
3277
3277
|
cartTotal: r.number(),
|
|
3278
3278
|
cartVat: r.number(),
|
|
@@ -3282,7 +3282,11 @@ const ge = r.object({
|
|
|
3282
3282
|
storeOptions: r.object({
|
|
3283
3283
|
deliveryPrice: r.number().optional(),
|
|
3284
3284
|
freeDeliveryPrice: r.number().optional(),
|
|
3285
|
-
isVatIncludedInPrice: r.boolean().optional()
|
|
3285
|
+
isVatIncludedInPrice: r.boolean().optional(),
|
|
3286
|
+
// True when the ordering organization is exempt from delivery fees
|
|
3287
|
+
// ("פטור מדמי משלוח"). Persisted so any later recompute (admin edit,
|
|
3288
|
+
// invoice generation) keeps the exemption.
|
|
3289
|
+
freeShipping: r.boolean().optional()
|
|
3286
3290
|
}).optional(),
|
|
3287
3291
|
originalAmount: r.number().positive().optional(),
|
|
3288
3292
|
// what client pay
|
|
@@ -3290,8 +3294,8 @@ const ge = r.object({
|
|
|
3290
3294
|
// what store charge
|
|
3291
3295
|
date: r.number(),
|
|
3292
3296
|
deliveryDate: r.coerce.number(),
|
|
3293
|
-
client:
|
|
3294
|
-
address:
|
|
3297
|
+
client: kn.optional(),
|
|
3298
|
+
address: Ie.optional(),
|
|
3295
3299
|
nameOnInvoice: r.string().optional(),
|
|
3296
3300
|
emailOnInvoice: r.string().email().optional(),
|
|
3297
3301
|
phoneNumberOnInvoice: r.string().optional(),
|
|
@@ -3311,11 +3315,11 @@ const ge = r.object({
|
|
|
3311
3315
|
// הזמנת רכש
|
|
3312
3316
|
outOfStockPolicy: r.enum(["substitute", "remove"]).optional(),
|
|
3313
3317
|
organizationId: r.string().optional(),
|
|
3314
|
-
billingAccount:
|
|
3315
|
-
deliveryNote:
|
|
3316
|
-
invoice:
|
|
3317
|
-
ezInvoice:
|
|
3318
|
-
ezDeliveryNote:
|
|
3318
|
+
billingAccount: it.optional(),
|
|
3319
|
+
deliveryNote: Tn.optional(),
|
|
3320
|
+
invoice: Nn.optional(),
|
|
3321
|
+
ezInvoice: Ue.optional(),
|
|
3322
|
+
ezDeliveryNote: wn.optional(),
|
|
3319
3323
|
/**
|
|
3320
3324
|
* Set when an admin records a full payment against o.invoice / o.ezInvoice.
|
|
3321
3325
|
* Epoch millis. Absent means no payment has been recorded via the admin payment flow.
|
|
@@ -3327,11 +3331,11 @@ const ge = r.object({
|
|
|
3327
3331
|
* Mirrors EzInvoiceSchema shape (doc_uuid, pdf_link, doc_number, …).
|
|
3328
3332
|
* Present only after a successful recordInvoicePayment call.
|
|
3329
3333
|
*/
|
|
3330
|
-
ezReceipt:
|
|
3334
|
+
ezReceipt: Ue.optional(),
|
|
3331
3335
|
// Audit: who last changed the order + when (epoch millis). Stamped by admin writes.
|
|
3332
3336
|
updatedBy: r.string().optional(),
|
|
3333
3337
|
updatedAt: r.number().optional()
|
|
3334
|
-
}),
|
|
3338
|
+
}), Cn = r.enum(["individual", "company"]), Kn = r.object({
|
|
3335
3339
|
id: r.string(),
|
|
3336
3340
|
companyId: r.string(),
|
|
3337
3341
|
name: r.string(),
|
|
@@ -3339,20 +3343,20 @@ const ge = r.object({
|
|
|
3339
3343
|
logoUrl: r.string(),
|
|
3340
3344
|
tenantId: r.string(),
|
|
3341
3345
|
// firebase auth tenantId
|
|
3342
|
-
paymentType:
|
|
3346
|
+
paymentType: Ae,
|
|
3343
3347
|
allowAnonymousClients: r.boolean(),
|
|
3344
3348
|
isVatIncludedInPrice: r.boolean(),
|
|
3345
|
-
clientTypes: r.array(
|
|
3349
|
+
clientTypes: r.array(Cn),
|
|
3346
3350
|
minimumOrder: r.number().optional(),
|
|
3347
3351
|
freeDeliveryPrice: r.number().optional(),
|
|
3348
3352
|
deliveryPrice: r.number().optional(),
|
|
3349
|
-
address:
|
|
3353
|
+
address: Ie.optional(),
|
|
3350
3354
|
companyNumber: r.string().optional()
|
|
3351
3355
|
// חפ של החברה
|
|
3352
|
-
}),
|
|
3356
|
+
}), jn = r.object({
|
|
3353
3357
|
minSpend: r.number().positive().optional(),
|
|
3354
3358
|
stackable: r.boolean().default(!1)
|
|
3355
|
-
}).optional(),
|
|
3359
|
+
}).optional(), Zn = r.discriminatedUnion("variantType", [
|
|
3356
3360
|
r.object({
|
|
3357
3361
|
variantType: r.literal("bundle"),
|
|
3358
3362
|
productsId: r.array(r.string().nonempty()).min(1),
|
|
@@ -3362,7 +3366,7 @@ const ge = r.object({
|
|
|
3362
3366
|
bundlePrice: r.number().positive()
|
|
3363
3367
|
// Total price for the bundle (e.g., $25)
|
|
3364
3368
|
})
|
|
3365
|
-
]),
|
|
3369
|
+
]), er = r.object({
|
|
3366
3370
|
type: r.literal("Discount"),
|
|
3367
3371
|
storeId: r.string().min(1),
|
|
3368
3372
|
companyId: r.string().min(1),
|
|
@@ -3371,32 +3375,32 @@ const ge = r.object({
|
|
|
3371
3375
|
active: r.boolean(),
|
|
3372
3376
|
startDate: r.number(),
|
|
3373
3377
|
endDate: r.number(),
|
|
3374
|
-
variant:
|
|
3375
|
-
conditions:
|
|
3378
|
+
variant: Zn,
|
|
3379
|
+
conditions: jn
|
|
3376
3380
|
});
|
|
3377
|
-
class
|
|
3381
|
+
class On {
|
|
3378
3382
|
canApply(e, t) {
|
|
3379
3383
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3380
|
-
const { productsId:
|
|
3381
|
-
return this.getTotalQuantity(t.cart,
|
|
3384
|
+
const { productsId: i, requiredQuantity: a } = e.variant;
|
|
3385
|
+
return this.getTotalQuantity(t.cart, i) >= a;
|
|
3382
3386
|
}
|
|
3383
3387
|
calculate(e, t) {
|
|
3384
3388
|
if (e.variant.variantType !== "bundle")
|
|
3385
3389
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3386
|
-
const { productsId:
|
|
3390
|
+
const { productsId: i, requiredQuantity: a, bundlePrice: s } = e.variant, o = t.cart.filter((K) => i.includes(K.product.id)), c = this.getTotalQuantity(t.cart, i), l = Math.floor(c / a);
|
|
3387
3391
|
if (l === 0)
|
|
3388
3392
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3389
|
-
const u = this.calculateOriginalPrice(
|
|
3393
|
+
const u = this.calculateOriginalPrice(o), f = this.getTotalQuantity(t.cart, i), x = this.calculateDiscountedPrice(
|
|
3390
3394
|
u,
|
|
3391
3395
|
s,
|
|
3392
3396
|
l,
|
|
3393
|
-
|
|
3397
|
+
a,
|
|
3394
3398
|
f
|
|
3395
|
-
),
|
|
3399
|
+
), w = u - x, I = this.distributeDiscount(o, w, u);
|
|
3396
3400
|
return {
|
|
3397
3401
|
applicable: !0,
|
|
3398
|
-
discountAmount: Number(
|
|
3399
|
-
affectedItems:
|
|
3402
|
+
discountAmount: Number(w.toFixed(2)),
|
|
3403
|
+
affectedItems: I
|
|
3400
3404
|
};
|
|
3401
3405
|
}
|
|
3402
3406
|
isDiscountActive(e) {
|
|
@@ -3404,30 +3408,30 @@ class jn {
|
|
|
3404
3408
|
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3405
3409
|
}
|
|
3406
3410
|
getTotalQuantity(e, t) {
|
|
3407
|
-
return e.filter((
|
|
3411
|
+
return e.filter((i) => t.includes(i.product.id)).reduce((i, a) => i + a.amount, 0);
|
|
3408
3412
|
}
|
|
3409
3413
|
calculateOriginalPrice(e) {
|
|
3410
|
-
return e.reduce((t,
|
|
3414
|
+
return e.reduce((t, i) => t + i.product.price * i.amount, 0);
|
|
3411
3415
|
}
|
|
3412
|
-
calculateDiscountedPrice(e, t,
|
|
3413
|
-
const
|
|
3414
|
-
return
|
|
3416
|
+
calculateDiscountedPrice(e, t, i, a, s) {
|
|
3417
|
+
const o = t * i, c = i * a, u = Math.max(0, s - c) / s * e;
|
|
3418
|
+
return o + u;
|
|
3415
3419
|
}
|
|
3416
|
-
distributeDiscount(e, t,
|
|
3417
|
-
const
|
|
3420
|
+
distributeDiscount(e, t, i) {
|
|
3421
|
+
const a = t / i;
|
|
3418
3422
|
return e.map((s) => {
|
|
3419
|
-
const
|
|
3423
|
+
const o = s.product.price * s.amount * a;
|
|
3420
3424
|
return {
|
|
3421
3425
|
productId: s.product.id,
|
|
3422
3426
|
quantity: s.amount,
|
|
3423
3427
|
originalPrice: Number(s.product.price.toFixed(2)),
|
|
3424
|
-
discountedPrice: Number((s.product.price -
|
|
3425
|
-
discountAmount: Number(
|
|
3428
|
+
discountedPrice: Number((s.product.price - o / s.amount).toFixed(2)),
|
|
3429
|
+
discountAmount: Number(o.toFixed(2))
|
|
3426
3430
|
};
|
|
3427
3431
|
});
|
|
3428
3432
|
}
|
|
3429
3433
|
}
|
|
3430
|
-
class
|
|
3434
|
+
class at {
|
|
3431
3435
|
static getStrategy(e) {
|
|
3432
3436
|
return this.strategies.get(e.variant.variantType) || null;
|
|
3433
3437
|
}
|
|
@@ -3441,61 +3445,61 @@ class rt {
|
|
|
3441
3445
|
this.strategies.clear();
|
|
3442
3446
|
}
|
|
3443
3447
|
}
|
|
3444
|
-
|
|
3445
|
-
["bundle", new
|
|
3448
|
+
ze(at, "strategies", /* @__PURE__ */ new Map([
|
|
3449
|
+
["bundle", new On()]
|
|
3446
3450
|
]));
|
|
3447
|
-
class
|
|
3448
|
-
static calculateDiscounts(e, t,
|
|
3451
|
+
class tr {
|
|
3452
|
+
static calculateDiscounts(e, t, i) {
|
|
3449
3453
|
var u, f;
|
|
3450
|
-
const
|
|
3454
|
+
const a = {
|
|
3451
3455
|
cart: e,
|
|
3452
|
-
user:
|
|
3456
|
+
user: i,
|
|
3453
3457
|
appliedDiscounts: []
|
|
3454
|
-
}, s = this.filterActiveDiscounts(t),
|
|
3458
|
+
}, s = this.filterActiveDiscounts(t), o = [];
|
|
3455
3459
|
for (const x of s) {
|
|
3456
|
-
const
|
|
3457
|
-
if (!
|
|
3458
|
-
const
|
|
3459
|
-
|
|
3460
|
+
const w = at.getStrategy(x);
|
|
3461
|
+
if (!w || !w.canApply(x, a) || !((u = x.conditions) != null && u.stackable) && o.length > 0) continue;
|
|
3462
|
+
const I = w.calculate(x, a);
|
|
3463
|
+
I.applicable && (o.push({
|
|
3460
3464
|
discountId: x.id,
|
|
3461
3465
|
discountName: ((f = x.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3462
|
-
discountAmount: Number(
|
|
3463
|
-
affectedItems:
|
|
3464
|
-
}),
|
|
3466
|
+
discountAmount: Number(I.discountAmount.toFixed(2)),
|
|
3467
|
+
affectedItems: I.affectedItems
|
|
3468
|
+
}), a.appliedDiscounts = o);
|
|
3465
3469
|
}
|
|
3466
|
-
const
|
|
3467
|
-
(x,
|
|
3470
|
+
const c = this.calculateFinalPrices(e, o), l = o.reduce(
|
|
3471
|
+
(x, w) => x + w.discountAmount,
|
|
3468
3472
|
0
|
|
3469
3473
|
);
|
|
3470
3474
|
return {
|
|
3471
|
-
items:
|
|
3475
|
+
items: c,
|
|
3472
3476
|
totalDiscount: Number(l.toFixed(2)),
|
|
3473
|
-
appliedDiscounts:
|
|
3477
|
+
appliedDiscounts: o
|
|
3474
3478
|
};
|
|
3475
3479
|
}
|
|
3476
3480
|
static filterActiveDiscounts(e) {
|
|
3477
3481
|
const t = Date.now();
|
|
3478
3482
|
return e.filter(
|
|
3479
|
-
(
|
|
3483
|
+
(i) => i.active && i.startDate <= t && i.endDate >= t
|
|
3480
3484
|
);
|
|
3481
3485
|
}
|
|
3482
3486
|
static calculateFinalPrices(e, t) {
|
|
3483
|
-
return e.map((
|
|
3484
|
-
const
|
|
3485
|
-
(l) => l.affectedItems.some((u) => u.productId ===
|
|
3486
|
-
), s =
|
|
3487
|
+
return e.map((i) => {
|
|
3488
|
+
const a = t.filter(
|
|
3489
|
+
(l) => l.affectedItems.some((u) => u.productId === i.product.id)
|
|
3490
|
+
), s = a.reduce((l, u) => {
|
|
3487
3491
|
const f = u.affectedItems.find(
|
|
3488
|
-
(x) => x.productId ===
|
|
3492
|
+
(x) => x.productId === i.product.id
|
|
3489
3493
|
);
|
|
3490
3494
|
return l + ((f == null ? void 0 : f.discountAmount) || 0);
|
|
3491
|
-
}, 0),
|
|
3495
|
+
}, 0), o = s / i.amount, c = i.product.price - o;
|
|
3492
3496
|
return {
|
|
3493
|
-
amount:
|
|
3494
|
-
product:
|
|
3495
|
-
originalPrice: Number(
|
|
3496
|
-
finalPrice: Number(Math.max(0,
|
|
3497
|
+
amount: i.amount,
|
|
3498
|
+
product: i.product,
|
|
3499
|
+
originalPrice: Number(i.product.price.toFixed(2)),
|
|
3500
|
+
finalPrice: Number(Math.max(0, c).toFixed(2)),
|
|
3497
3501
|
finalDiscount: Number(s.toFixed(2)),
|
|
3498
|
-
appliedDiscounts:
|
|
3502
|
+
appliedDiscounts: a.map((l) => l.discountId)
|
|
3499
3503
|
};
|
|
3500
3504
|
});
|
|
3501
3505
|
}
|
|
@@ -3507,23 +3511,23 @@ class Hn {
|
|
|
3507
3511
|
return this.filterActiveDiscounts(e);
|
|
3508
3512
|
}
|
|
3509
3513
|
}
|
|
3510
|
-
const
|
|
3514
|
+
const Pn = r.object({
|
|
3511
3515
|
id: r.string(),
|
|
3512
3516
|
name: r.string()
|
|
3513
|
-
}),
|
|
3517
|
+
}), nr = Pn.omit({ id: !0 }), st = r.object({
|
|
3514
3518
|
type: r.literal("Supplier"),
|
|
3515
3519
|
id: r.string(),
|
|
3516
3520
|
name: r.string(),
|
|
3517
3521
|
code: r.string()
|
|
3518
3522
|
// supplier code number
|
|
3519
|
-
}),
|
|
3523
|
+
}), rr = st.omit({ id: !0 }), Dn = r.object({
|
|
3520
3524
|
type: r.literal("SupplierInvoice"),
|
|
3521
3525
|
id: r.string(),
|
|
3522
3526
|
// "draft" = work-in-progress, NOT yet finalized. Product prices are only
|
|
3523
3527
|
// updated once the invoice is finalized ("completed"). Legacy invoices have
|
|
3524
3528
|
// no status and are treated as finalized.
|
|
3525
3529
|
status: r.enum(["draft", "completed"]).optional(),
|
|
3526
|
-
supplier:
|
|
3530
|
+
supplier: st,
|
|
3527
3531
|
invoiceNumber: r.string(),
|
|
3528
3532
|
date: r.number(),
|
|
3529
3533
|
rows: r.array(
|
|
@@ -3561,14 +3565,14 @@ const Zn = r.object({
|
|
|
3561
3565
|
total: r.number().optional(),
|
|
3562
3566
|
totalBeforeVat: r.number().optional(),
|
|
3563
3567
|
vat: r.number().optional()
|
|
3564
|
-
}),
|
|
3568
|
+
}), ir = Dn.omit({ id: !0 }), En = r.enum(["debt_increase", "debt_reduction"]), ar = r.object({
|
|
3565
3569
|
recordId: r.string().min(1),
|
|
3566
3570
|
organizationId: r.string().min(1),
|
|
3567
3571
|
customerId: r.string(),
|
|
3568
3572
|
// "system" when no acting user
|
|
3569
3573
|
customerName: r.string(),
|
|
3570
3574
|
billingAccountId: r.string().nullable(),
|
|
3571
|
-
type:
|
|
3575
|
+
type: En,
|
|
3572
3576
|
/** Integer agorot, always positive */
|
|
3573
3577
|
amount: r.number().int().positive(),
|
|
3574
3578
|
currency: r.literal("ILS"),
|
|
@@ -3586,7 +3590,7 @@ const Zn = r.object({
|
|
|
3586
3590
|
yearMonth: r.string(),
|
|
3587
3591
|
companyId: r.string().min(1),
|
|
3588
3592
|
storeId: r.string().min(1)
|
|
3589
|
-
}),
|
|
3593
|
+
}), sr = r.object({
|
|
3590
3594
|
/** = doc id */
|
|
3591
3595
|
organizationId: r.string().min(1),
|
|
3592
3596
|
organizationName: r.string(),
|
|
@@ -3600,7 +3604,7 @@ const Zn = r.object({
|
|
|
3600
3604
|
updatedAt: r.number().int().positive(),
|
|
3601
3605
|
companyId: r.string().min(1),
|
|
3602
3606
|
storeId: r.string().min(1)
|
|
3603
|
-
}),
|
|
3607
|
+
}), or = r.enum([
|
|
3604
3608
|
"delivery_note",
|
|
3605
3609
|
"payment_received",
|
|
3606
3610
|
"credit_note",
|
|
@@ -3611,7 +3615,7 @@ const Zn = r.object({
|
|
|
3611
3615
|
// legacy
|
|
3612
3616
|
"order_refunded"
|
|
3613
3617
|
// legacy
|
|
3614
|
-
]),
|
|
3618
|
+
]), cr = r.enum(["check", "bank_transfer", "cash", "credit_card", "other"]), ur = r.object({
|
|
3615
3619
|
/** = deterministic dedup doc id */
|
|
3616
3620
|
id: r.string().min(1),
|
|
3617
3621
|
organizationId: r.string().min(1),
|
|
@@ -3643,7 +3647,7 @@ const Zn = r.object({
|
|
|
3643
3647
|
createdAt: r.number().int().positive(),
|
|
3644
3648
|
companyId: r.string().min(1),
|
|
3645
3649
|
storeId: r.string().min(1)
|
|
3646
|
-
}),
|
|
3650
|
+
}), dr = r.object({
|
|
3647
3651
|
/** = doc id */
|
|
3648
3652
|
organizationId: r.string().min(1),
|
|
3649
3653
|
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
@@ -3663,50 +3667,68 @@ const Zn = r.object({
|
|
|
3663
3667
|
updatedAt: r.number().int().positive(),
|
|
3664
3668
|
companyId: r.string().min(1),
|
|
3665
3669
|
storeId: r.string().min(1)
|
|
3666
|
-
}),
|
|
3670
|
+
}), Ee = {
|
|
3667
3671
|
VAT: 18
|
|
3668
3672
|
};
|
|
3669
|
-
function
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3673
|
+
function Rn(n) {
|
|
3674
|
+
return n.reduce((e, t) => {
|
|
3675
|
+
if (t.status === "missing")
|
|
3676
|
+
return e;
|
|
3677
|
+
if (t.status === "substituted" && t.substitutedWith) {
|
|
3678
|
+
const i = t.substitutedWith;
|
|
3679
|
+
return e.push({
|
|
3680
|
+
...t,
|
|
3681
|
+
// Pin price to sub.price and neutralise the substitute product's own
|
|
3682
|
+
// discount so getPriceAfterDiscount returns sub.price with no reduction.
|
|
3683
|
+
product: { ...i.product, price: i.price, discount: { type: "none", value: 0 } },
|
|
3684
|
+
amount: i.amount
|
|
3685
|
+
}), e;
|
|
3686
|
+
}
|
|
3687
|
+
return e.push(t), e;
|
|
3688
|
+
}, []);
|
|
3689
|
+
}
|
|
3690
|
+
function $n(n, e) {
|
|
3691
|
+
var t, i;
|
|
3692
|
+
return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((i = n.discount) == null ? void 0 : i.type) === "number" ? n.discount.value ?? 0 : 0;
|
|
3693
|
+
}
|
|
3694
|
+
function Mn(n, e) {
|
|
3695
|
+
var i, a;
|
|
3696
|
+
const t = e && n.vat ? n.price + n.price * Ee.VAT / 100 : n.price;
|
|
3697
|
+
if (((i = n.discount) == null ? void 0 : i.type) === "percent") {
|
|
3677
3698
|
const s = t * n.discount.value / 100;
|
|
3678
3699
|
return n.price - s;
|
|
3679
3700
|
}
|
|
3680
|
-
return ((
|
|
3701
|
+
return ((a = n.discount) == null ? void 0 : a.type) === "number" ? t - n.discount.value : t;
|
|
3681
3702
|
}
|
|
3682
|
-
function
|
|
3703
|
+
function lr({
|
|
3683
3704
|
cart: n,
|
|
3684
3705
|
discounts: e,
|
|
3685
3706
|
deliveryPrice: t = 0,
|
|
3686
|
-
freeDeliveryPrice:
|
|
3687
|
-
|
|
3707
|
+
freeDeliveryPrice: i = 0,
|
|
3708
|
+
freeShipping: a = !1,
|
|
3709
|
+
isVatIncludedInPrice: s = !1
|
|
3688
3710
|
}) {
|
|
3689
|
-
const
|
|
3690
|
-
amount:
|
|
3691
|
-
product: { ...
|
|
3692
|
-
originalPrice:
|
|
3693
|
-
finalPrice:
|
|
3694
|
-
finalDiscount:
|
|
3695
|
-
})),
|
|
3696
|
-
(
|
|
3697
|
-
const { product:
|
|
3698
|
-
let
|
|
3699
|
-
if (
|
|
3700
|
-
let
|
|
3701
|
-
if (
|
|
3702
|
-
const
|
|
3703
|
-
|
|
3711
|
+
const c = Rn(n).map((u, f) => ({
|
|
3712
|
+
amount: u.amount,
|
|
3713
|
+
product: { ...u.product },
|
|
3714
|
+
originalPrice: u.product.price,
|
|
3715
|
+
finalPrice: Mn(u.product, s),
|
|
3716
|
+
finalDiscount: $n(u.product)
|
|
3717
|
+
})), l = c.reduce(
|
|
3718
|
+
(u, f) => {
|
|
3719
|
+
const { product: x, amount: w, finalPrice: I, finalDiscount: K } = f;
|
|
3720
|
+
let Z = 0;
|
|
3721
|
+
if (x.vat) {
|
|
3722
|
+
let Ce = 0;
|
|
3723
|
+
if (s) {
|
|
3724
|
+
const ot = Number((I / (1 + Ee.VAT / 100)).toFixed(2)), ct = I - ot;
|
|
3725
|
+
Z = Number(ct.toFixed(2)), Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3704
3726
|
} else
|
|
3705
|
-
|
|
3706
|
-
|
|
3727
|
+
Z = I * Ee.VAT / 100, Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3728
|
+
u.vat = Number((u.vat + Ce).toFixed(2));
|
|
3707
3729
|
}
|
|
3708
|
-
const
|
|
3709
|
-
return
|
|
3730
|
+
const Ne = Number(I.toFixed(2));
|
|
3731
|
+
return u.cost += w * Ne, u.discount += K && w * K, u.finalCost += w * Ne + (s ? 0 : Z), u.productsCost += w * Ne + (s ? 0 : Z), u.cost = Number(u.cost.toFixed(2)), u.discount = Number(u.discount.toFixed(2)), u.finalCost = Number(u.finalCost.toFixed(2)), u.productsCost = Number(u.productsCost.toFixed(2)), u;
|
|
3710
3732
|
},
|
|
3711
3733
|
{
|
|
3712
3734
|
discount: 0,
|
|
@@ -3717,12 +3739,12 @@ function cr({
|
|
|
3717
3739
|
deliveryPrice: t
|
|
3718
3740
|
}
|
|
3719
3741
|
);
|
|
3720
|
-
return
|
|
3742
|
+
return a || l.deliveryPrice && l.productsCost >= i ? l.deliveryPrice = 0 : l.finalCost += l.deliveryPrice, { items: c, ...l };
|
|
3721
3743
|
}
|
|
3722
|
-
const
|
|
3744
|
+
const zn = {
|
|
3723
3745
|
stores: "STORES",
|
|
3724
3746
|
companies: "COMPANIES"
|
|
3725
|
-
},
|
|
3747
|
+
}, Vn = {
|
|
3726
3748
|
products: "products",
|
|
3727
3749
|
"favorite-products": "favorite-products",
|
|
3728
3750
|
profiles: "profiles",
|
|
@@ -3751,95 +3773,96 @@ const Rn = {
|
|
|
3751
3773
|
duplicateChargeAlerts: "duplicateChargeAlerts",
|
|
3752
3774
|
organizationBalance: "organizationBalance",
|
|
3753
3775
|
organizationBalanceRollup: "organizationBalanceRollup"
|
|
3754
|
-
},
|
|
3755
|
-
systemCollections:
|
|
3756
|
-
storeCollections:
|
|
3776
|
+
}, Ln = {
|
|
3777
|
+
systemCollections: zn,
|
|
3778
|
+
storeCollections: Vn,
|
|
3757
3779
|
// for client and server
|
|
3758
3780
|
getPath: ({
|
|
3759
3781
|
companyId: n,
|
|
3760
3782
|
storeId: e,
|
|
3761
3783
|
collectionName: t,
|
|
3762
|
-
id:
|
|
3763
|
-
}) => `${n}/${e}/${t}${
|
|
3784
|
+
id: i
|
|
3785
|
+
}) => `${n}/${e}/${t}${i ? `/${i}` : ""}`,
|
|
3764
3786
|
getSubPath: ({
|
|
3765
3787
|
companyId: n,
|
|
3766
3788
|
storeId: e,
|
|
3767
3789
|
collectionName: t,
|
|
3768
|
-
subCollectionName:
|
|
3769
|
-
id:
|
|
3790
|
+
subCollectionName: i,
|
|
3791
|
+
id: a,
|
|
3770
3792
|
subId: s
|
|
3771
|
-
}) => `${n}/${e}/${t}/${
|
|
3793
|
+
}) => `${n}/${e}/${t}/${a}/${i}${s ? `/${s}` : ""}`,
|
|
3772
3794
|
// for firestore events
|
|
3773
3795
|
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
|
|
3774
3796
|
getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
|
|
3775
|
-
},
|
|
3776
|
-
firestore:
|
|
3777
|
-
},
|
|
3797
|
+
}, mr = {
|
|
3798
|
+
firestore: Ln
|
|
3799
|
+
}, qe = {
|
|
3778
3800
|
round: (n, e = 2) => {
|
|
3779
3801
|
const t = 10 ** e;
|
|
3780
3802
|
return Math.round((n + Number.EPSILON) * t) / t;
|
|
3781
3803
|
}
|
|
3782
|
-
},
|
|
3783
|
-
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e :
|
|
3784
|
-
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 :
|
|
3804
|
+
}, pr = {
|
|
3805
|
+
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : qe.round(e / (1 - n / 100)),
|
|
3806
|
+
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : qe.round((n - e) / n * 100)
|
|
3785
3807
|
};
|
|
3786
3808
|
export {
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3809
|
+
Ie as AddressSchema,
|
|
3810
|
+
tt as BaseCategorySchema,
|
|
3811
|
+
it as BillingAccountSchema,
|
|
3812
|
+
In as BranchSchema,
|
|
3813
|
+
ar as BudgetRecordSchema,
|
|
3814
|
+
En as BudgetRecordTypeSchema,
|
|
3815
|
+
or as BudgetTransactionTypeSchema,
|
|
3816
|
+
On as BundleDiscountStrategy,
|
|
3817
|
+
rt as CalculatedDataSchema,
|
|
3818
|
+
nt as CartItemProductSchema,
|
|
3819
|
+
Yn as CartSchema,
|
|
3820
|
+
$e as CategorySchema,
|
|
3821
|
+
Xn as CompanySchema,
|
|
3822
|
+
Tn as DeliveryNoteSchema,
|
|
3823
|
+
jn as DiscountConditionsSchema,
|
|
3824
|
+
tr as DiscountEngine,
|
|
3825
|
+
er as DiscountSchema,
|
|
3826
|
+
at as DiscountStrategyFactory,
|
|
3827
|
+
Zn as DiscountVariantSchema,
|
|
3828
|
+
wn as EzDeliveryNoteSchema,
|
|
3829
|
+
Ue as EzInvoiceSchema,
|
|
3830
|
+
Gn as FavoriteProductSchema,
|
|
3831
|
+
qn as FileSchema,
|
|
3832
|
+
mr as FirebaseAPI,
|
|
3833
|
+
bn as FulfillmentStatusSchema,
|
|
3834
|
+
Nn as InvoiceSchema,
|
|
3835
|
+
ye as LocaleSchema,
|
|
3836
|
+
nr as NewOrganizationGroupSchema,
|
|
3837
|
+
Jn as NewOrganizationSchema,
|
|
3838
|
+
Qn as NewProductSchema,
|
|
3839
|
+
ir as NewSupplierInvoiceSchema,
|
|
3840
|
+
rr as NewSupplierSchema,
|
|
3841
|
+
Hn as OrderSchema,
|
|
3842
|
+
ur as OrganizationBalanceEntrySchema,
|
|
3843
|
+
dr as OrganizationBalanceRollupSchema,
|
|
3844
|
+
sr as OrganizationBudgetSchema,
|
|
3845
|
+
Pn as OrganizationGroupSchema,
|
|
3846
|
+
An as OrganizationSchema,
|
|
3847
|
+
cr as PaymentMethodSchema,
|
|
3848
|
+
Sn as PaymentTermsSchema,
|
|
3849
|
+
Ae as PaymentTypeSchema,
|
|
3850
|
+
Me as ProductSchema,
|
|
3851
|
+
kn as ProfileSchema,
|
|
3852
|
+
Kn as StoreSchema,
|
|
3853
|
+
xn as SubstitutedWithSchema,
|
|
3854
|
+
Dn as SupplierInvoiceSchema,
|
|
3855
|
+
st as SupplierSchema,
|
|
3856
|
+
Wn as TFlattenCategorySchema,
|
|
3857
|
+
Cn as clientTypesSchema,
|
|
3858
|
+
lr as getCartCost,
|
|
3859
|
+
Rn as getFulfilledCartItems,
|
|
3860
|
+
Bn as isFile,
|
|
3861
|
+
qe as math,
|
|
3862
|
+
$ as notEmptyTextSchema,
|
|
3863
|
+
Un as numericTextSchema,
|
|
3864
|
+
pr as storeCalculator,
|
|
3865
|
+
Vn as storeCollections,
|
|
3866
|
+
zn as systemCollections
|
|
3844
3867
|
};
|
|
3845
3868
|
//# sourceMappingURL=core.es.js.map
|