@jsdev_ninja/core 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +555 -547
- 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/Organization.d.ts +86 -0
- package/dist/lib/entities/Organization.d.ts.map +1 -1
- package/dist/lib/entities/Organization.js +9 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.es.js
CHANGED
|
@@ -3,39 +3,39 @@ var ct = (n, e, t) => e in n ? ot(n, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var $e = (n, e, t) => ct(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var b;
|
|
5
5
|
(function(n) {
|
|
6
|
-
n.assertEqual = (
|
|
7
|
-
function e(
|
|
6
|
+
n.assertEqual = (i) => i;
|
|
7
|
+
function e(i) {
|
|
8
8
|
}
|
|
9
9
|
n.assertIs = e;
|
|
10
|
-
function t(
|
|
10
|
+
function t(i) {
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
|
-
n.assertNever = t, n.arrayToEnum = (
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (i) => {
|
|
14
14
|
const s = {};
|
|
15
|
-
for (const c of
|
|
15
|
+
for (const c of i)
|
|
16
16
|
s[c] = c;
|
|
17
17
|
return s;
|
|
18
|
-
}, n.getValidEnumValues = (
|
|
19
|
-
const s = n.objectKeys(
|
|
18
|
+
}, n.getValidEnumValues = (i) => {
|
|
19
|
+
const s = n.objectKeys(i).filter((o) => typeof i[i[o]] != "number"), c = {};
|
|
20
20
|
for (const o of s)
|
|
21
|
-
c[o] =
|
|
21
|
+
c[o] = i[o];
|
|
22
22
|
return n.objectValues(c);
|
|
23
|
-
}, n.objectValues = (
|
|
24
|
-
return
|
|
25
|
-
}), n.objectKeys = typeof Object.keys == "function" ? (
|
|
23
|
+
}, n.objectValues = (i) => n.objectKeys(i).map(function(s) {
|
|
24
|
+
return i[s];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (i) => Object.keys(i) : (i) => {
|
|
26
26
|
const s = [];
|
|
27
|
-
for (const c in
|
|
28
|
-
Object.prototype.hasOwnProperty.call(
|
|
27
|
+
for (const c in i)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(i, c) && s.push(c);
|
|
29
29
|
return s;
|
|
30
|
-
}, n.find = (
|
|
31
|
-
for (const c of
|
|
30
|
+
}, n.find = (i, s) => {
|
|
31
|
+
for (const c of i)
|
|
32
32
|
if (s(c))
|
|
33
33
|
return c;
|
|
34
|
-
}, n.isInteger = typeof Number.isInteger == "function" ? (
|
|
35
|
-
function i
|
|
36
|
-
return
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (i) => Number.isInteger(i) : (i) => typeof i == "number" && isFinite(i) && Math.floor(i) === i;
|
|
35
|
+
function a(i, s = " | ") {
|
|
36
|
+
return i.map((c) => typeof c == "string" ? `'${c}'` : c).join(s);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues =
|
|
38
|
+
n.joinValues = a, n.jsonStringifyReplacer = (i, s) => typeof s == "bigint" ? s.toString() : s;
|
|
39
39
|
})(b || (b = {}));
|
|
40
40
|
var Ce;
|
|
41
41
|
(function(n) {
|
|
@@ -110,10 +110,10 @@ class A extends Error {
|
|
|
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 = (a) => {
|
|
114
|
+
this.issues = [...this.issues, a];
|
|
115
|
+
}, this.addIssues = (a = []) => {
|
|
116
|
+
this.issues = [...this.issues, ...a];
|
|
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
|
-
},
|
|
124
|
+
}, a = { _errors: [] }, i = (s) => {
|
|
125
125
|
for (const c of s.issues)
|
|
126
126
|
if (c.code === "invalid_union")
|
|
127
|
-
c.unionErrors.map(
|
|
127
|
+
c.unionErrors.map(i);
|
|
128
128
|
else if (c.code === "invalid_return_type")
|
|
129
|
-
|
|
129
|
+
i(c.returnTypeError);
|
|
130
130
|
else if (c.code === "invalid_arguments")
|
|
131
|
-
|
|
131
|
+
i(c.argumentsError);
|
|
132
132
|
else if (c.path.length === 0)
|
|
133
|
-
|
|
133
|
+
a._errors.push(t(c));
|
|
134
134
|
else {
|
|
135
|
-
let o =
|
|
135
|
+
let o = a, l = 0;
|
|
136
136
|
for (; l < c.path.length; ) {
|
|
137
137
|
const u = c.path[l];
|
|
138
138
|
l === c.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(c))) : o[u] = o[u] || { _errors: [] }, o = o[u], l++;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return i(this), a;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
145
|
if (!(e instanceof A))
|
|
@@ -155,10 +155,10 @@ 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 = {}, a = [];
|
|
159
|
+
for (const i of this.issues)
|
|
160
|
+
i.path.length > 0 ? (t[i.path[0]] = t[i.path[0]] || [], t[i.path[0]].push(e(i))) : a.push(e(i));
|
|
161
|
+
return { formErrors: a, fieldErrors: t };
|
|
162
162
|
}
|
|
163
163
|
get formErrors() {
|
|
164
164
|
return this.flatten();
|
|
@@ -229,28 +229,28 @@ function ye() {
|
|
|
229
229
|
return Ue;
|
|
230
230
|
}
|
|
231
231
|
const ve = (n) => {
|
|
232
|
-
const { data: e, path: t, errorMaps:
|
|
233
|
-
...
|
|
232
|
+
const { data: e, path: t, errorMaps: a, issueData: i } = n, s = [...t, ...i.path || []], c = {
|
|
233
|
+
...i,
|
|
234
234
|
path: s
|
|
235
235
|
};
|
|
236
|
-
if (
|
|
236
|
+
if (i.message !== void 0)
|
|
237
237
|
return {
|
|
238
|
-
...
|
|
238
|
+
...i,
|
|
239
239
|
path: s,
|
|
240
|
-
message:
|
|
240
|
+
message: i.message
|
|
241
241
|
};
|
|
242
242
|
let o = "";
|
|
243
|
-
const l =
|
|
243
|
+
const l = a.filter((u) => !!u).slice().reverse();
|
|
244
244
|
for (const u of l)
|
|
245
245
|
o = u(c, { data: e, defaultError: o }).message;
|
|
246
246
|
return {
|
|
247
|
-
...
|
|
247
|
+
...i,
|
|
248
248
|
path: s,
|
|
249
249
|
message: o
|
|
250
250
|
};
|
|
251
251
|
}, lt = [];
|
|
252
252
|
function m(n, e) {
|
|
253
|
-
const t = ye(),
|
|
253
|
+
const t = ye(), a = ve({
|
|
254
254
|
issueData: e,
|
|
255
255
|
data: n.data,
|
|
256
256
|
path: n.path,
|
|
@@ -263,9 +263,9 @@ function m(n, e) {
|
|
|
263
263
|
// then global override map
|
|
264
264
|
t === X ? void 0 : X
|
|
265
265
|
// then global default map
|
|
266
|
-
].filter((
|
|
266
|
+
].filter((i) => !!i)
|
|
267
267
|
});
|
|
268
|
-
n.common.issues.push(
|
|
268
|
+
n.common.issues.push(a);
|
|
269
269
|
}
|
|
270
270
|
class S {
|
|
271
271
|
constructor() {
|
|
@@ -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 a = [];
|
|
282
|
+
for (const i of t) {
|
|
283
|
+
if (i.status === "aborted")
|
|
284
284
|
return y;
|
|
285
|
-
|
|
285
|
+
i.status === "dirty" && e.dirty(), a.push(i.value);
|
|
286
286
|
}
|
|
287
|
-
return { status: e.value, value:
|
|
287
|
+
return { status: e.value, value: a };
|
|
288
288
|
}
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
292
|
-
const s = await
|
|
293
|
-
|
|
290
|
+
const a = [];
|
|
291
|
+
for (const i of t) {
|
|
292
|
+
const s = await i.key, c = await i.value;
|
|
293
|
+
a.push({
|
|
294
294
|
key: s,
|
|
295
295
|
value: c
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
return S.mergeObjectSync(e,
|
|
298
|
+
return S.mergeObjectSync(e, a);
|
|
299
299
|
}
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
|
-
const
|
|
302
|
-
for (const
|
|
303
|
-
const { key: s, value: c } =
|
|
301
|
+
const a = {};
|
|
302
|
+
for (const i of t) {
|
|
303
|
+
const { key: s, value: c } = i;
|
|
304
304
|
if (s.status === "aborted" || c.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
s.status === "dirty" && e.dirty(), c.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof c.value < "u" ||
|
|
306
|
+
s.status === "dirty" && e.dirty(), c.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof c.value < "u" || i.alwaysSet) && (a[s.value] = c.value);
|
|
307
307
|
}
|
|
308
|
-
return { status: e.value, value:
|
|
308
|
+
return { status: e.value, value: a };
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
const y = Object.freeze({
|
|
312
312
|
status: "aborted"
|
|
313
313
|
}), Q = (n) => ({ status: "dirty", value: n }), I = (n) => ({ status: "valid", value: n }), je = (n) => n.status === "aborted", Ze = (n) => n.status === "dirty", U = (n) => n.status === "valid", ne = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
314
|
-
function _e(n, e, t,
|
|
314
|
+
function _e(n, e, t, a) {
|
|
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 qe(n, e, t,
|
|
318
|
+
function qe(n, e, t, a, i) {
|
|
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
|
}
|
|
@@ -325,8 +325,8 @@ var h;
|
|
|
325
325
|
})(h || (h = {}));
|
|
326
326
|
var ee, te;
|
|
327
327
|
class O {
|
|
328
|
-
constructor(e, t,
|
|
329
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
328
|
+
constructor(e, t, a, i) {
|
|
329
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = a, this._key = i;
|
|
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;
|
|
@@ -350,14 +350,14 @@ 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: a, description: i } = n;
|
|
354
|
+
if (e && (t || a))
|
|
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: i } : { errorMap: (c, o) => {
|
|
357
357
|
var l, u;
|
|
358
358
|
const { message: f } = n;
|
|
359
|
-
return c.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: (l = f ??
|
|
360
|
-
}, description:
|
|
359
|
+
return c.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: (l = f ?? a) !== null && l !== void 0 ? l : o.defaultError } : c.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = f ?? t) !== null && u !== void 0 ? u : o.defaultError };
|
|
360
|
+
}, description: i };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
363
363
|
get description() {
|
|
@@ -400,17 +400,17 @@ class _ {
|
|
|
400
400
|
return Promise.resolve(t);
|
|
401
401
|
}
|
|
402
402
|
parse(e, t) {
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
406
|
-
throw
|
|
403
|
+
const a = this.safeParse(e, t);
|
|
404
|
+
if (a.success)
|
|
405
|
+
return a.data;
|
|
406
|
+
throw a.error;
|
|
407
407
|
}
|
|
408
408
|
safeParse(e, t) {
|
|
409
|
-
var
|
|
410
|
-
const
|
|
409
|
+
var a;
|
|
410
|
+
const i = {
|
|
411
411
|
common: {
|
|
412
412
|
issues: [],
|
|
413
|
-
async: (
|
|
413
|
+
async: (a = t == null ? void 0 : t.async) !== null && a !== void 0 ? a : !1,
|
|
414
414
|
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
415
415
|
},
|
|
416
416
|
path: (t == null ? void 0 : t.path) || [],
|
|
@@ -418,12 +418,12 @@ class _ {
|
|
|
418
418
|
parent: null,
|
|
419
419
|
data: e,
|
|
420
420
|
parsedType: E(e)
|
|
421
|
-
}, s = this._parseSync({ data: e, path:
|
|
422
|
-
return Me(
|
|
421
|
+
}, s = this._parseSync({ data: e, path: i.path, parent: i });
|
|
422
|
+
return Me(i, s);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
|
-
var t,
|
|
426
|
-
const
|
|
425
|
+
var t, a;
|
|
426
|
+
const i = {
|
|
427
427
|
common: {
|
|
428
428
|
issues: [],
|
|
429
429
|
async: !!this["~standard"].async
|
|
@@ -436,32 +436,32 @@ class _ {
|
|
|
436
436
|
};
|
|
437
437
|
if (!this["~standard"].async)
|
|
438
438
|
try {
|
|
439
|
-
const s = this._parseSync({ data: e, path: [], parent:
|
|
439
|
+
const s = this._parseSync({ data: e, path: [], parent: i });
|
|
440
440
|
return U(s) ? {
|
|
441
441
|
value: s.value
|
|
442
442
|
} : {
|
|
443
|
-
issues:
|
|
443
|
+
issues: i.common.issues
|
|
444
444
|
};
|
|
445
445
|
} catch (s) {
|
|
446
|
-
!((
|
|
446
|
+
!((a = (t = s == null ? void 0 : s.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || a === void 0) && a.includes("encountered") && (this["~standard"].async = !0), i.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: i }).then((s) => U(s) ? {
|
|
452
452
|
value: s.value
|
|
453
453
|
} : {
|
|
454
|
-
issues:
|
|
454
|
+
issues: i.common.issues
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
async parseAsync(e, t) {
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
461
|
-
throw
|
|
458
|
+
const a = await this.safeParseAsync(e, t);
|
|
459
|
+
if (a.success)
|
|
460
|
+
return a.data;
|
|
461
|
+
throw a.error;
|
|
462
462
|
}
|
|
463
463
|
async safeParseAsync(e, t) {
|
|
464
|
-
const
|
|
464
|
+
const a = {
|
|
465
465
|
common: {
|
|
466
466
|
issues: [],
|
|
467
467
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -472,21 +472,21 @@ class _ {
|
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
474
|
parsedType: E(e)
|
|
475
|
-
},
|
|
476
|
-
return Me(
|
|
475
|
+
}, i = this._parse({ data: e, path: a.path, parent: a }), s = await (ne(i) ? i : Promise.resolve(i));
|
|
476
|
+
return Me(a, s);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
|
-
const
|
|
480
|
-
return this._refinement((
|
|
481
|
-
const c = e(
|
|
479
|
+
const a = (i) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(i) : t;
|
|
480
|
+
return this._refinement((i, s) => {
|
|
481
|
+
const c = e(i), o = () => s.addIssue({
|
|
482
482
|
code: d.custom,
|
|
483
|
-
...i
|
|
483
|
+
...a(i)
|
|
484
484
|
});
|
|
485
485
|
return typeof Promise < "u" && c instanceof Promise ? c.then((l) => l ? !0 : (o(), !1)) : c ? !0 : (o(), !1);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
refinement(e, t) {
|
|
489
|
-
return this._refinement((
|
|
489
|
+
return this._refinement((a, i) => e(a) ? !0 : (i.addIssue(typeof t == "function" ? t(a, i) : t), !1));
|
|
490
490
|
}
|
|
491
491
|
_refinement(e) {
|
|
492
492
|
return new j({
|
|
@@ -601,8 +601,8 @@ function jt(n, e) {
|
|
|
601
601
|
if (!yt.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
|
-
const [t] = n.split("."),
|
|
605
|
-
return !(typeof
|
|
604
|
+
const [t] = n.split("."), a = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), i = JSON.parse(atob(a));
|
|
605
|
+
return !(typeof i != "object" || i === null || !i.typ || !i.alg || e && i.alg !== e);
|
|
606
606
|
} catch {
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
@@ -620,156 +620,156 @@ class N extends _ {
|
|
|
620
620
|
received: s.parsedType
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
let
|
|
623
|
+
const a = new S();
|
|
624
|
+
let i;
|
|
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 && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
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
|
+
}), a.dirty());
|
|
635
635
|
else if (s.kind === "max")
|
|
636
|
-
e.data.length > s.value && (
|
|
636
|
+
e.data.length > s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
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
|
+
}), a.dirty());
|
|
644
644
|
else if (s.kind === "length") {
|
|
645
645
|
const c = e.data.length > s.value, o = e.data.length < s.value;
|
|
646
|
-
(c || o) && (
|
|
646
|
+
(c || o) && (i = this._getOrReturnCtx(e, i), c ? m(i, {
|
|
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
|
-
}) : o && m(
|
|
653
|
+
}) : o && m(i, {
|
|
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
|
+
}), a.dirty());
|
|
661
661
|
} else if (s.kind === "email")
|
|
662
|
-
_t.test(e.data) || (
|
|
662
|
+
_t.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
663
663
|
validation: "email",
|
|
664
664
|
code: d.invalid_string,
|
|
665
665
|
message: s.message
|
|
666
|
-
}),
|
|
666
|
+
}), a.dirty());
|
|
667
667
|
else if (s.kind === "emoji")
|
|
668
|
-
Ne || (Ne = new RegExp(bt, "u")), Ne.test(e.data) || (
|
|
668
|
+
Ne || (Ne = new RegExp(bt, "u")), Ne.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
669
669
|
validation: "emoji",
|
|
670
670
|
code: d.invalid_string,
|
|
671
671
|
message: s.message
|
|
672
|
-
}),
|
|
672
|
+
}), a.dirty());
|
|
673
673
|
else if (s.kind === "uuid")
|
|
674
|
-
ht.test(e.data) || (
|
|
674
|
+
ht.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
675
675
|
validation: "uuid",
|
|
676
676
|
code: d.invalid_string,
|
|
677
677
|
message: s.message
|
|
678
|
-
}),
|
|
678
|
+
}), a.dirty());
|
|
679
679
|
else if (s.kind === "nanoid")
|
|
680
|
-
gt.test(e.data) || (
|
|
680
|
+
gt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
681
681
|
validation: "nanoid",
|
|
682
682
|
code: d.invalid_string,
|
|
683
683
|
message: s.message
|
|
684
|
-
}),
|
|
684
|
+
}), a.dirty());
|
|
685
685
|
else if (s.kind === "cuid")
|
|
686
|
-
mt.test(e.data) || (
|
|
686
|
+
mt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
687
687
|
validation: "cuid",
|
|
688
688
|
code: d.invalid_string,
|
|
689
689
|
message: s.message
|
|
690
|
-
}),
|
|
690
|
+
}), a.dirty());
|
|
691
691
|
else if (s.kind === "cuid2")
|
|
692
|
-
pt.test(e.data) || (
|
|
692
|
+
pt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
693
693
|
validation: "cuid2",
|
|
694
694
|
code: d.invalid_string,
|
|
695
695
|
message: s.message
|
|
696
|
-
}),
|
|
696
|
+
}), a.dirty());
|
|
697
697
|
else if (s.kind === "ulid")
|
|
698
|
-
ft.test(e.data) || (
|
|
698
|
+
ft.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
699
699
|
validation: "ulid",
|
|
700
700
|
code: d.invalid_string,
|
|
701
701
|
message: s.message
|
|
702
|
-
}),
|
|
702
|
+
}), a.dirty());
|
|
703
703
|
else if (s.kind === "url")
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
i = this._getOrReturnCtx(e, i), m(i, {
|
|
708
708
|
validation: "url",
|
|
709
709
|
code: d.invalid_string,
|
|
710
710
|
message: s.message
|
|
711
|
-
}),
|
|
711
|
+
}), a.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) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
714
714
|
validation: "regex",
|
|
715
715
|
code: d.invalid_string,
|
|
716
716
|
message: s.message
|
|
717
|
-
}),
|
|
717
|
+
}), a.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
718
718
|
code: d.invalid_string,
|
|
719
719
|
validation: { includes: s.value, position: s.position },
|
|
720
720
|
message: s.message
|
|
721
|
-
}),
|
|
721
|
+
}), a.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) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
722
722
|
code: d.invalid_string,
|
|
723
723
|
validation: { startsWith: s.value },
|
|
724
724
|
message: s.message
|
|
725
|
-
}),
|
|
725
|
+
}), a.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
726
726
|
code: d.invalid_string,
|
|
727
727
|
validation: { endsWith: s.value },
|
|
728
728
|
message: s.message
|
|
729
|
-
}),
|
|
729
|
+
}), a.dirty()) : s.kind === "datetime" ? Qe(s).test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
730
730
|
code: d.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
732
|
message: s.message
|
|
733
|
-
}),
|
|
733
|
+
}), a.dirty()) : s.kind === "date" ? At.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
734
734
|
code: d.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
736
|
message: s.message
|
|
737
|
-
}),
|
|
737
|
+
}), a.dirty()) : s.kind === "time" ? Nt(s).test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
738
738
|
code: d.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
740
|
message: s.message
|
|
741
|
-
}),
|
|
741
|
+
}), a.dirty()) : s.kind === "duration" ? vt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
742
742
|
validation: "duration",
|
|
743
743
|
code: d.invalid_string,
|
|
744
744
|
message: s.message
|
|
745
|
-
}),
|
|
745
|
+
}), a.dirty()) : s.kind === "ip" ? Ct(e.data, s.version) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
746
746
|
validation: "ip",
|
|
747
747
|
code: d.invalid_string,
|
|
748
748
|
message: s.message
|
|
749
|
-
}),
|
|
749
|
+
}), a.dirty()) : s.kind === "jwt" ? jt(e.data, s.alg) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
750
750
|
validation: "jwt",
|
|
751
751
|
code: d.invalid_string,
|
|
752
752
|
message: s.message
|
|
753
|
-
}),
|
|
753
|
+
}), a.dirty()) : s.kind === "cidr" ? Zt(e.data, s.version) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
754
754
|
validation: "cidr",
|
|
755
755
|
code: d.invalid_string,
|
|
756
756
|
message: s.message
|
|
757
|
-
}),
|
|
757
|
+
}), a.dirty()) : s.kind === "base64" ? St.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
758
758
|
validation: "base64",
|
|
759
759
|
code: d.invalid_string,
|
|
760
760
|
message: s.message
|
|
761
|
-
}),
|
|
761
|
+
}), a.dirty()) : s.kind === "base64url" ? It.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
762
762
|
validation: "base64url",
|
|
763
763
|
code: d.invalid_string,
|
|
764
764
|
message: s.message
|
|
765
|
-
}),
|
|
766
|
-
return { status:
|
|
765
|
+
}), a.dirty()) : b.assertNever(s);
|
|
766
|
+
return { status: a.value, value: e.data };
|
|
767
767
|
}
|
|
768
|
-
_regex(e, t,
|
|
769
|
-
return this.refinement((
|
|
768
|
+
_regex(e, t, a) {
|
|
769
|
+
return this.refinement((i) => e.test(i), {
|
|
770
770
|
validation: t,
|
|
771
771
|
code: d.invalid_string,
|
|
772
|
-
...h.errToObj(
|
|
772
|
+
...h.errToObj(a)
|
|
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, a;
|
|
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: (a = e == null ? void 0 : e.local) !== null && a !== void 0 ? a : !1,
|
|
836
836
|
...h.errToObj(e == null ? void 0 : e.message)
|
|
837
837
|
});
|
|
838
838
|
}
|
|
@@ -998,8 +998,8 @@ N.create = (n) => {
|
|
|
998
998
|
});
|
|
999
999
|
};
|
|
1000
1000
|
function Ot(n, e) {
|
|
1001
|
-
const t = (n.toString().split(".")[1] || "").length,
|
|
1002
|
-
return s % c / Math.pow(10,
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, a = (e.toString().split(".")[1] || "").length, i = t > a ? t : a, s = parseInt(n.toFixed(i).replace(".", "")), c = parseInt(e.toFixed(i).replace(".", ""));
|
|
1002
|
+
return s % c / Math.pow(10, i);
|
|
1003
1003
|
}
|
|
1004
1004
|
class M extends _ {
|
|
1005
1005
|
constructor() {
|
|
@@ -1014,37 +1014,37 @@ class M extends _ {
|
|
|
1014
1014
|
received: s.parsedType
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
|
-
let
|
|
1018
|
-
const
|
|
1017
|
+
let a;
|
|
1018
|
+
const i = new S();
|
|
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) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1021
1021
|
code: d.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
1024
|
message: s.message
|
|
1025
|
-
}),
|
|
1025
|
+
}), i.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
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
|
+
}), i.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
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
|
+
}), i.dirty()) : s.kind === "multipleOf" ? Ot(e.data, s.value) !== 0 && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1040
1040
|
code: d.not_multiple_of,
|
|
1041
1041
|
multipleOf: s.value,
|
|
1042
1042
|
message: s.message
|
|
1043
|
-
}),
|
|
1043
|
+
}), i.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1044
1044
|
code: d.not_finite,
|
|
1045
1045
|
message: s.message
|
|
1046
|
-
}),
|
|
1047
|
-
return { status:
|
|
1046
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1047
|
+
return { status: i.value, value: e.data };
|
|
1048
1048
|
}
|
|
1049
1049
|
gte(e, t) {
|
|
1050
1050
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -1058,7 +1058,7 @@ 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,
|
|
1061
|
+
setLimit(e, t, a, i) {
|
|
1062
1062
|
return new M({
|
|
1063
1063
|
...this._def,
|
|
1064
1064
|
checks: [
|
|
@@ -1066,8 +1066,8 @@ class M extends _ {
|
|
|
1066
1066
|
{
|
|
1067
1067
|
kind: e,
|
|
1068
1068
|
value: t,
|
|
1069
|
-
inclusive:
|
|
1070
|
-
message: h.toString(
|
|
1069
|
+
inclusive: a,
|
|
1070
|
+
message: h.toString(i)
|
|
1071
1071
|
}
|
|
1072
1072
|
]
|
|
1073
1073
|
});
|
|
@@ -1159,10 +1159,10 @@ class M extends _ {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
get isFinite() {
|
|
1161
1161
|
let e = null, t = null;
|
|
1162
|
-
for (const
|
|
1163
|
-
if (
|
|
1162
|
+
for (const a of this._def.checks) {
|
|
1163
|
+
if (a.kind === "finite" || a.kind === "int" || a.kind === "multipleOf")
|
|
1164
1164
|
return !0;
|
|
1165
|
-
|
|
1165
|
+
a.kind === "min" ? (t === null || a.value > t) && (t = a.value) : a.kind === "max" && (e === null || a.value < e) && (e = a.value);
|
|
1166
1166
|
}
|
|
1167
1167
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1168
1168
|
}
|
|
@@ -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 a;
|
|
1190
|
+
const i = new S();
|
|
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) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
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
|
+
}), i.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
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
|
+
}), i.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1205
1205
|
code: d.not_multiple_of,
|
|
1206
1206
|
multipleOf: s.value,
|
|
1207
1207
|
message: s.message
|
|
1208
|
-
}),
|
|
1209
|
-
return { status:
|
|
1208
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1209
|
+
return { status: i.value, value: e.data };
|
|
1210
1210
|
}
|
|
1211
1211
|
_getInvalidInput(e) {
|
|
1212
1212
|
const t = this._getOrReturnCtx(e);
|
|
@@ -1228,7 +1228,7 @@ 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,
|
|
1231
|
+
setLimit(e, t, a, i) {
|
|
1232
1232
|
return new z({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
@@ -1236,8 +1236,8 @@ class z extends _ {
|
|
|
1236
1236
|
{
|
|
1237
1237
|
kind: e,
|
|
1238
1238
|
value: t,
|
|
1239
|
-
inclusive:
|
|
1240
|
-
message: h.toString(
|
|
1239
|
+
inclusive: a,
|
|
1240
|
+
message: h.toString(i)
|
|
1241
1241
|
}
|
|
1242
1242
|
]
|
|
1243
1243
|
});
|
|
@@ -1312,11 +1312,11 @@ z.create = (n) => {
|
|
|
1312
1312
|
class re 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 a = this._getOrReturnCtx(e);
|
|
1316
|
+
return m(a, {
|
|
1317
1317
|
code: d.invalid_type,
|
|
1318
1318
|
expected: p.boolean,
|
|
1319
|
-
received:
|
|
1319
|
+
received: a.parsedType
|
|
1320
1320
|
}), y;
|
|
1321
1321
|
}
|
|
1322
1322
|
return I(e.data);
|
|
@@ -1343,26 +1343,26 @@ class q extends _ {
|
|
|
1343
1343
|
code: d.invalid_date
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
let
|
|
1346
|
+
const a = new S();
|
|
1347
|
+
let i;
|
|
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 && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
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
|
+
}), a.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
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
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1364
1364
|
return {
|
|
1365
|
-
status:
|
|
1365
|
+
status: a.value,
|
|
1366
1366
|
value: new Date(e.data.getTime())
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
@@ -1408,11 +1408,11 @@ q.create = (n) => new q({
|
|
|
1408
1408
|
class be extends _ {
|
|
1409
1409
|
_parse(e) {
|
|
1410
1410
|
if (this._getType(e) !== p.symbol) {
|
|
1411
|
-
const
|
|
1412
|
-
return m(
|
|
1411
|
+
const a = this._getOrReturnCtx(e);
|
|
1412
|
+
return m(a, {
|
|
1413
1413
|
code: d.invalid_type,
|
|
1414
1414
|
expected: p.symbol,
|
|
1415
|
-
received:
|
|
1415
|
+
received: a.parsedType
|
|
1416
1416
|
}), y;
|
|
1417
1417
|
}
|
|
1418
1418
|
return I(e.data);
|
|
@@ -1422,37 +1422,37 @@ be.create = (n) => new be({
|
|
|
1422
1422
|
typeName: g.ZodSymbol,
|
|
1423
1423
|
...v(n)
|
|
1424
1424
|
});
|
|
1425
|
-
class
|
|
1425
|
+
class ae extends _ {
|
|
1426
1426
|
_parse(e) {
|
|
1427
1427
|
if (this._getType(e) !== p.undefined) {
|
|
1428
|
-
const
|
|
1429
|
-
return m(
|
|
1428
|
+
const a = this._getOrReturnCtx(e);
|
|
1429
|
+
return m(a, {
|
|
1430
1430
|
code: d.invalid_type,
|
|
1431
1431
|
expected: p.undefined,
|
|
1432
|
-
received:
|
|
1432
|
+
received: a.parsedType
|
|
1433
1433
|
}), y;
|
|
1434
1434
|
}
|
|
1435
1435
|
return I(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 ie extends _ {
|
|
1443
1443
|
_parse(e) {
|
|
1444
1444
|
if (this._getType(e) !== p.null) {
|
|
1445
|
-
const
|
|
1446
|
-
return m(
|
|
1445
|
+
const a = this._getOrReturnCtx(e);
|
|
1446
|
+
return m(a, {
|
|
1447
1447
|
code: d.invalid_type,
|
|
1448
1448
|
expected: p.null,
|
|
1449
|
-
received:
|
|
1449
|
+
received: a.parsedType
|
|
1450
1450
|
}), y;
|
|
1451
1451
|
}
|
|
1452
1452
|
return I(e.data);
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
|
|
1455
|
+
ie.create = (n) => new ie({
|
|
1456
1456
|
typeName: g.ZodNull,
|
|
1457
1457
|
...v(n)
|
|
1458
1458
|
});
|
|
@@ -1497,11 +1497,11 @@ $.create = (n) => new $({
|
|
|
1497
1497
|
class xe extends _ {
|
|
1498
1498
|
_parse(e) {
|
|
1499
1499
|
if (this._getType(e) !== p.undefined) {
|
|
1500
|
-
const
|
|
1501
|
-
return m(
|
|
1500
|
+
const a = this._getOrReturnCtx(e);
|
|
1501
|
+
return m(a, {
|
|
1502
1502
|
code: d.invalid_type,
|
|
1503
1503
|
expected: p.void,
|
|
1504
|
-
received:
|
|
1504
|
+
received: a.parsedType
|
|
1505
1505
|
}), y;
|
|
1506
1506
|
}
|
|
1507
1507
|
return I(e.data);
|
|
@@ -1513,43 +1513,43 @@ xe.create = (n) => new xe({
|
|
|
1513
1513
|
});
|
|
1514
1514
|
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
|
-
const { ctx: t, status:
|
|
1516
|
+
const { ctx: t, status: a } = this._processInputParams(e), i = 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 c = t.data.length >
|
|
1523
|
+
if (i.exactLength !== null) {
|
|
1524
|
+
const c = t.data.length > i.exactLength.value, o = t.data.length < i.exactLength.value;
|
|
1525
1525
|
(c || o) && (m(t, {
|
|
1526
1526
|
code: c ? d.too_big : d.too_small,
|
|
1527
|
-
minimum: o ?
|
|
1528
|
-
maximum: c ?
|
|
1527
|
+
minimum: o ? i.exactLength.value : void 0,
|
|
1528
|
+
maximum: c ? i.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
1530
1530
|
inclusive: !0,
|
|
1531
1531
|
exact: !0,
|
|
1532
|
-
message:
|
|
1533
|
-
}),
|
|
1532
|
+
message: i.exactLength.message
|
|
1533
|
+
}), a.dirty());
|
|
1534
1534
|
}
|
|
1535
|
-
if (
|
|
1535
|
+
if (i.minLength !== null && t.data.length < i.minLength.value && (m(t, {
|
|
1536
1536
|
code: d.too_small,
|
|
1537
|
-
minimum:
|
|
1537
|
+
minimum: i.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
|
-
message:
|
|
1542
|
-
}),
|
|
1541
|
+
message: i.minLength.message
|
|
1542
|
+
}), a.dirty()), i.maxLength !== null && t.data.length > i.maxLength.value && (m(t, {
|
|
1543
1543
|
code: d.too_big,
|
|
1544
|
-
maximum:
|
|
1544
|
+
maximum: i.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
1547
1547
|
exact: !1,
|
|
1548
|
-
message:
|
|
1549
|
-
}),
|
|
1550
|
-
return Promise.all([...t.data].map((c, o) =>
|
|
1551
|
-
const s = [...t.data].map((c, o) =>
|
|
1552
|
-
return S.mergeArray(
|
|
1548
|
+
message: i.maxLength.message
|
|
1549
|
+
}), a.dirty()), t.common.async)
|
|
1550
|
+
return Promise.all([...t.data].map((c, o) => i.type._parseAsync(new O(t, c, t.path, o)))).then((c) => S.mergeArray(a, c));
|
|
1551
|
+
const s = [...t.data].map((c, o) => i.type._parseSync(new O(t, c, t.path, o)));
|
|
1552
|
+
return S.mergeArray(a, s);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
1555
1555
|
return this._def.type;
|
|
@@ -1588,8 +1588,8 @@ function W(n) {
|
|
|
1588
1588
|
if (n instanceof k) {
|
|
1589
1589
|
const e = {};
|
|
1590
1590
|
for (const t in n.shape) {
|
|
1591
|
-
const
|
|
1592
|
-
e[t] = Z.create(W(
|
|
1591
|
+
const a = n.shape[t];
|
|
1592
|
+
e[t] = Z.create(W(a));
|
|
1593
1593
|
}
|
|
1594
1594
|
return new k({
|
|
1595
1595
|
...n._def,
|
|
@@ -1619,17 +1619,17 @@ class k extends _ {
|
|
|
1619
1619
|
received: u.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status:
|
|
1622
|
+
const { status: a, ctx: i } = this._processInputParams(e), { shape: s, keys: c } = this._getCached(), o = [];
|
|
1623
1623
|
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1624
|
-
for (const u in
|
|
1624
|
+
for (const u in i.data)
|
|
1625
1625
|
c.includes(u) || o.push(u);
|
|
1626
1626
|
const l = [];
|
|
1627
1627
|
for (const u of c) {
|
|
1628
|
-
const f = s[u], x =
|
|
1628
|
+
const f = s[u], x = i.data[u];
|
|
1629
1629
|
l.push({
|
|
1630
1630
|
key: { status: "valid", value: u },
|
|
1631
|
-
value: f._parse(new O(
|
|
1632
|
-
alwaysSet: u in
|
|
1631
|
+
value: f._parse(new O(i, x, i.path, u)),
|
|
1632
|
+
alwaysSet: u in i.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
1635
|
if (this._def.catchall instanceof $) {
|
|
@@ -1638,29 +1638,29 @@ class k extends _ {
|
|
|
1638
1638
|
for (const f of o)
|
|
1639
1639
|
l.push({
|
|
1640
1640
|
key: { status: "valid", value: f },
|
|
1641
|
-
value: { status: "valid", value:
|
|
1641
|
+
value: { status: "valid", value: i.data[f] }
|
|
1642
1642
|
});
|
|
1643
1643
|
else if (u === "strict")
|
|
1644
|
-
o.length > 0 && (m(
|
|
1644
|
+
o.length > 0 && (m(i, {
|
|
1645
1645
|
code: d.unrecognized_keys,
|
|
1646
1646
|
keys: o
|
|
1647
|
-
}),
|
|
1647
|
+
}), a.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
1651
|
for (const f of o) {
|
|
1652
|
-
const x =
|
|
1652
|
+
const x = i.data[f];
|
|
1653
1653
|
l.push({
|
|
1654
1654
|
key: { status: "valid", value: f },
|
|
1655
1655
|
value: u._parse(
|
|
1656
|
-
new O(
|
|
1656
|
+
new O(i, x, i.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet: f in
|
|
1659
|
+
alwaysSet: f in i.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
-
return
|
|
1663
|
+
return i.common.async ? Promise.resolve().then(async () => {
|
|
1664
1664
|
const u = [];
|
|
1665
1665
|
for (const f of l) {
|
|
1666
1666
|
const x = await f.key, T = await f.value;
|
|
@@ -1671,7 +1671,7 @@ class k extends _ {
|
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
1673
|
return u;
|
|
1674
|
-
}).then((u) => S.mergeObjectSync(
|
|
1674
|
+
}).then((u) => S.mergeObjectSync(a, u)) : S.mergeObjectSync(a, l);
|
|
1675
1675
|
}
|
|
1676
1676
|
get shape() {
|
|
1677
1677
|
return this._def.shape();
|
|
@@ -1681,9 +1681,9 @@ class k extends _ {
|
|
|
1681
1681
|
...this._def,
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
|
-
errorMap: (t,
|
|
1685
|
-
var
|
|
1686
|
-
const l = (c = (s = (
|
|
1684
|
+
errorMap: (t, a) => {
|
|
1685
|
+
var i, s, c, o;
|
|
1686
|
+
const l = (c = (s = (i = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(i, t, a).message) !== null && c !== void 0 ? c : a.defaultError;
|
|
1687
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1688
1688
|
message: (o = h.errToObj(e).message) !== null && o !== void 0 ? o : l
|
|
1689
1689
|
} : {
|
|
@@ -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((a) => {
|
|
1818
|
+
e[a] && this.shape[a] && (t[a] = this.shape[a]);
|
|
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((a) => {
|
|
1827
|
+
e[a] || (t[a] = this.shape[a]);
|
|
1828
1828
|
}), new k({
|
|
1829
1829
|
...this._def,
|
|
1830
1830
|
shape: () => t
|
|
@@ -1838,9 +1838,9 @@ class k extends _ {
|
|
|
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((a) => {
|
|
1842
|
+
const i = this.shape[a];
|
|
1843
|
+
e && !e[a] ? t[a] = i : t[a] = i.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((a) => {
|
|
1852
|
+
if (e && !e[a])
|
|
1853
|
+
t[a] = this.shape[a];
|
|
1854
1854
|
else {
|
|
1855
|
-
let s = this.shape[
|
|
1855
|
+
let s = this.shape[a];
|
|
1856
1856
|
for (; s instanceof Z; )
|
|
1857
1857
|
s = s._def.innerType;
|
|
1858
|
-
t[
|
|
1858
|
+
t[a] = s;
|
|
1859
1859
|
}
|
|
1860
1860
|
}), new k({
|
|
1861
1861
|
...this._def,
|
|
@@ -1889,8 +1889,8 @@ k.lazycreate = (n, e) => new k({
|
|
|
1889
1889
|
});
|
|
1890
1890
|
class se extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1893
|
-
function
|
|
1892
|
+
const { ctx: t } = this._processInputParams(e), a = this._def.options;
|
|
1893
|
+
function i(s) {
|
|
1894
1894
|
for (const o of s)
|
|
1895
1895
|
if (o.result.status === "valid")
|
|
1896
1896
|
return o.result;
|
|
@@ -1904,7 +1904,7 @@ class se extends _ {
|
|
|
1904
1904
|
}), y;
|
|
1905
1905
|
}
|
|
1906
1906
|
if (t.common.async)
|
|
1907
|
-
return Promise.all(
|
|
1907
|
+
return Promise.all(a.map(async (s) => {
|
|
1908
1908
|
const c = {
|
|
1909
1909
|
...t,
|
|
1910
1910
|
common: {
|
|
@@ -1921,11 +1921,11 @@ class se extends _ {
|
|
|
1921
1921
|
}),
|
|
1922
1922
|
ctx: c
|
|
1923
1923
|
};
|
|
1924
|
-
})).then(
|
|
1924
|
+
})).then(i);
|
|
1925
1925
|
{
|
|
1926
1926
|
let s;
|
|
1927
1927
|
const c = [];
|
|
1928
|
-
for (const l of
|
|
1928
|
+
for (const l of a) {
|
|
1929
1929
|
const u = {
|
|
1930
1930
|
...t,
|
|
1931
1931
|
common: {
|
|
@@ -1960,7 +1960,7 @@ se.create = (n, e) => new se({
|
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const D = (n) => n instanceof de ? D(n.schema) : n instanceof j ? D(n.innerType()) : n instanceof ue ? [n.value] : n instanceof V ? n.options : n instanceof le ? b.objectValues(n.enum) : n instanceof me ? D(n._def.innerType) : n instanceof
|
|
1963
|
+
const D = (n) => n instanceof de ? D(n.schema) : n instanceof j ? D(n.innerType()) : n instanceof ue ? [n.value] : n instanceof V ? n.options : n instanceof le ? b.objectValues(n.enum) : n instanceof me ? D(n._def.innerType) : n instanceof ae ? [void 0] : n instanceof ie ? [null] : n instanceof Z ? [void 0, ...D(n.unwrap())] : n instanceof L ? [null, ...D(n.unwrap())] : n instanceof De || n instanceof fe ? D(n.unwrap()) : n instanceof pe ? D(n._def.innerType) : [];
|
|
1964
1964
|
class Te extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
@@ -1970,7 +1970,7 @@ class Te extends _ {
|
|
|
1970
1970
|
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const
|
|
1973
|
+
const a = this.discriminator, i = t.data[a], s = this.optionsMap.get(i);
|
|
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: [a]
|
|
1986
1986
|
}), y);
|
|
1987
1987
|
}
|
|
1988
1988
|
get discriminator() {
|
|
@@ -2002,33 +2002,33 @@ 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, a) {
|
|
2006
|
+
const i = /* @__PURE__ */ new Map();
|
|
2007
2007
|
for (const s of t) {
|
|
2008
2008
|
const c = D(s.shape[e]);
|
|
2009
2009
|
if (!c.length)
|
|
2010
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2011
2011
|
for (const o of c) {
|
|
2012
|
-
if (
|
|
2012
|
+
if (i.has(o))
|
|
2013
2013
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2014
|
-
|
|
2014
|
+
i.set(o, s);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
2017
|
return new Te({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
2021
|
-
optionsMap:
|
|
2022
|
-
...v(
|
|
2021
|
+
optionsMap: i,
|
|
2022
|
+
...v(a)
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
2026
|
function Oe(n, e) {
|
|
2027
|
-
const t = E(n),
|
|
2027
|
+
const t = E(n), a = E(e);
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
|
-
if (t === p.object &&
|
|
2031
|
-
const
|
|
2030
|
+
if (t === p.object && a === p.object) {
|
|
2031
|
+
const i = b.objectKeys(e), s = b.objectKeys(n).filter((o) => i.indexOf(o) !== -1), c = { ...n, ...e };
|
|
2032
2032
|
for (const o of s) {
|
|
2033
2033
|
const l = Oe(n[o], e[o]);
|
|
2034
2034
|
if (!l.valid)
|
|
@@ -2036,48 +2036,48 @@ function Oe(n, e) {
|
|
|
2036
2036
|
c[o] = l.data;
|
|
2037
2037
|
}
|
|
2038
2038
|
return { valid: !0, data: c };
|
|
2039
|
-
} else if (t === p.array &&
|
|
2039
|
+
} else if (t === p.array && a === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
|
-
const
|
|
2042
|
+
const i = [];
|
|
2043
2043
|
for (let s = 0; s < n.length; s++) {
|
|
2044
2044
|
const c = n[s], o = e[s], l = Oe(c, o);
|
|
2045
2045
|
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
|
-
|
|
2047
|
+
i.push(l.data);
|
|
2048
2048
|
}
|
|
2049
|
-
return { valid: !0, data:
|
|
2050
|
-
} else return t === p.date &&
|
|
2049
|
+
return { valid: !0, data: i };
|
|
2050
|
+
} else return t === p.date && a === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
2052
|
class oe extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx:
|
|
2054
|
+
const { status: t, ctx: a } = this._processInputParams(e), i = (s, c) => {
|
|
2055
2055
|
if (je(s) || je(c))
|
|
2056
2056
|
return y;
|
|
2057
2057
|
const o = Oe(s.value, c.value);
|
|
2058
|
-
return o.valid ? ((Ze(s) || Ze(c)) && t.dirty(), { status: t.value, value: o.data }) : (m(
|
|
2058
|
+
return o.valid ? ((Ze(s) || Ze(c)) && t.dirty(), { status: t.value, value: o.data }) : (m(a, {
|
|
2059
2059
|
code: d.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
2062
|
-
return
|
|
2062
|
+
return a.common.async ? Promise.all([
|
|
2063
2063
|
this._def.left._parseAsync({
|
|
2064
|
-
data:
|
|
2065
|
-
path:
|
|
2066
|
-
parent:
|
|
2064
|
+
data: a.data,
|
|
2065
|
+
path: a.path,
|
|
2066
|
+
parent: a
|
|
2067
2067
|
}),
|
|
2068
2068
|
this._def.right._parseAsync({
|
|
2069
|
-
data:
|
|
2070
|
-
path:
|
|
2071
|
-
parent:
|
|
2069
|
+
data: a.data,
|
|
2070
|
+
path: a.path,
|
|
2071
|
+
parent: a
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([s, c]) =>
|
|
2074
|
-
data:
|
|
2075
|
-
path:
|
|
2076
|
-
parent:
|
|
2073
|
+
]).then(([s, c]) => i(s, c)) : i(this._def.left._parseSync({
|
|
2074
|
+
data: a.data,
|
|
2075
|
+
path: a.path,
|
|
2076
|
+
parent: a
|
|
2077
2077
|
}), this._def.right._parseSync({
|
|
2078
|
-
data:
|
|
2079
|
-
path:
|
|
2080
|
-
parent:
|
|
2078
|
+
data: a.data,
|
|
2079
|
+
path: a.path,
|
|
2080
|
+
parent: a
|
|
2081
2081
|
}));
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
@@ -2089,33 +2089,33 @@ oe.create = (n, e, t) => new oe({
|
|
|
2089
2089
|
});
|
|
2090
2090
|
class P extends _ {
|
|
2091
2091
|
_parse(e) {
|
|
2092
|
-
const { status: t, ctx:
|
|
2093
|
-
if (
|
|
2094
|
-
return m(
|
|
2092
|
+
const { status: t, ctx: a } = this._processInputParams(e);
|
|
2093
|
+
if (a.parsedType !== p.array)
|
|
2094
|
+
return m(a, {
|
|
2095
2095
|
code: d.invalid_type,
|
|
2096
2096
|
expected: p.array,
|
|
2097
|
-
received:
|
|
2097
|
+
received: a.parsedType
|
|
2098
2098
|
}), y;
|
|
2099
|
-
if (
|
|
2100
|
-
return m(
|
|
2099
|
+
if (a.data.length < this._def.items.length)
|
|
2100
|
+
return m(a, {
|
|
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 && a.data.length > this._def.items.length && (m(a, {
|
|
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 = [...
|
|
2114
|
+
const s = [...a.data].map((c, o) => {
|
|
2115
2115
|
const l = this._def.items[o] || this._def.rest;
|
|
2116
|
-
return l ? l._parse(new O(
|
|
2116
|
+
return l ? l._parse(new O(a, c, a.path, o)) : null;
|
|
2117
2117
|
}).filter((c) => !!c);
|
|
2118
|
-
return
|
|
2118
|
+
return a.common.async ? Promise.all(s).then((c) => S.mergeArray(t, c)) : S.mergeArray(t, s);
|
|
2119
2119
|
}
|
|
2120
2120
|
get items() {
|
|
2121
2121
|
return this._def.items;
|
|
@@ -2145,31 +2145,31 @@ 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: a } = this._processInputParams(e);
|
|
2149
|
+
if (a.parsedType !== p.object)
|
|
2150
|
+
return m(a, {
|
|
2151
2151
|
code: d.invalid_type,
|
|
2152
2152
|
expected: p.object,
|
|
2153
|
-
received:
|
|
2153
|
+
received: a.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const
|
|
2156
|
-
for (const o in
|
|
2157
|
-
|
|
2158
|
-
key: s._parse(new O(
|
|
2159
|
-
value: c._parse(new O(
|
|
2160
|
-
alwaysSet: o in
|
|
2155
|
+
const i = [], s = this._def.keyType, c = this._def.valueType;
|
|
2156
|
+
for (const o in a.data)
|
|
2157
|
+
i.push({
|
|
2158
|
+
key: s._parse(new O(a, o, a.path, o)),
|
|
2159
|
+
value: c._parse(new O(a, a.data[o], a.path, o)),
|
|
2160
|
+
alwaysSet: o in a.data
|
|
2161
2161
|
});
|
|
2162
|
-
return
|
|
2162
|
+
return a.common.async ? S.mergeObjectAsync(t, i) : S.mergeObjectSync(t, i);
|
|
2163
2163
|
}
|
|
2164
2164
|
get element() {
|
|
2165
2165
|
return this._def.valueType;
|
|
2166
2166
|
}
|
|
2167
|
-
static create(e, t,
|
|
2167
|
+
static create(e, t, a) {
|
|
2168
2168
|
return t instanceof _ ? new ce({
|
|
2169
2169
|
keyType: e,
|
|
2170
2170
|
valueType: t,
|
|
2171
2171
|
typeName: g.ZodRecord,
|
|
2172
|
-
...v(
|
|
2172
|
+
...v(a)
|
|
2173
2173
|
}) : new ce({
|
|
2174
2174
|
keyType: N.create(),
|
|
2175
2175
|
valueType: e,
|
|
@@ -2186,18 +2186,18 @@ 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: a } = this._processInputParams(e);
|
|
2190
|
+
if (a.parsedType !== p.map)
|
|
2191
|
+
return m(a, {
|
|
2192
2192
|
code: d.invalid_type,
|
|
2193
2193
|
expected: p.map,
|
|
2194
|
-
received:
|
|
2194
|
+
received: a.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const
|
|
2197
|
-
key:
|
|
2198
|
-
value: s._parse(new O(
|
|
2196
|
+
const i = this._def.keyType, s = this._def.valueType, c = [...a.data.entries()].map(([o, l], u) => ({
|
|
2197
|
+
key: i._parse(new O(a, o, a.path, [u, "key"])),
|
|
2198
|
+
value: s._parse(new O(a, l, a.path, [u, "value"]))
|
|
2199
2199
|
}));
|
|
2200
|
-
if (
|
|
2200
|
+
if (a.common.async) {
|
|
2201
2201
|
const o = /* @__PURE__ */ new Map();
|
|
2202
2202
|
return Promise.resolve().then(async () => {
|
|
2203
2203
|
for (const l of c) {
|
|
@@ -2228,28 +2228,28 @@ ke.create = (n, e, t) => new ke({
|
|
|
2228
2228
|
});
|
|
2229
2229
|
class B extends _ {
|
|
2230
2230
|
_parse(e) {
|
|
2231
|
-
const { status: t, ctx:
|
|
2232
|
-
if (
|
|
2233
|
-
return m(
|
|
2231
|
+
const { status: t, ctx: a } = this._processInputParams(e);
|
|
2232
|
+
if (a.parsedType !== p.set)
|
|
2233
|
+
return m(a, {
|
|
2234
2234
|
code: d.invalid_type,
|
|
2235
2235
|
expected: p.set,
|
|
2236
|
-
received:
|
|
2236
|
+
received: a.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2238
|
+
const i = this._def;
|
|
2239
|
+
i.minSize !== null && a.data.size < i.minSize.value && (m(a, {
|
|
2240
2240
|
code: d.too_small,
|
|
2241
|
-
minimum:
|
|
2241
|
+
minimum: i.minSize.value,
|
|
2242
2242
|
type: "set",
|
|
2243
2243
|
inclusive: !0,
|
|
2244
2244
|
exact: !1,
|
|
2245
|
-
message:
|
|
2246
|
-
}), t.dirty()),
|
|
2245
|
+
message: i.minSize.message
|
|
2246
|
+
}), t.dirty()), i.maxSize !== null && a.data.size > i.maxSize.value && (m(a, {
|
|
2247
2247
|
code: d.too_big,
|
|
2248
|
-
maximum:
|
|
2248
|
+
maximum: i.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
|
-
message:
|
|
2252
|
+
message: i.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
2254
|
const s = this._def.valueType;
|
|
2255
2255
|
function c(l) {
|
|
@@ -2261,8 +2261,8 @@ class B extends _ {
|
|
|
2261
2261
|
}
|
|
2262
2262
|
return { status: t.value, value: u };
|
|
2263
2263
|
}
|
|
2264
|
-
const o = [...
|
|
2265
|
-
return
|
|
2264
|
+
const o = [...a.data.values()].map((l, u) => s._parse(new O(a, l, a.path, u)));
|
|
2265
|
+
return a.common.async ? Promise.all(o).then((l) => c(l)) : c(o);
|
|
2266
2266
|
}
|
|
2267
2267
|
min(e, t) {
|
|
2268
2268
|
return new B({
|
|
@@ -2302,7 +2302,7 @@ class Y extends _ {
|
|
|
2302
2302
|
expected: p.function,
|
|
2303
2303
|
received: t.parsedType
|
|
2304
2304
|
}), y;
|
|
2305
|
-
function
|
|
2305
|
+
function a(o, l) {
|
|
2306
2306
|
return ve({
|
|
2307
2307
|
data: o,
|
|
2308
2308
|
path: t.path,
|
|
@@ -2318,7 +2318,7 @@ class Y extends _ {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
2320
2320
|
}
|
|
2321
|
-
function
|
|
2321
|
+
function i(o, l) {
|
|
2322
2322
|
return ve({
|
|
2323
2323
|
data: o,
|
|
2324
2324
|
path: t.path,
|
|
@@ -2339,10 +2339,10 @@ class Y extends _ {
|
|
|
2339
2339
|
const o = this;
|
|
2340
2340
|
return I(async function(...l) {
|
|
2341
2341
|
const u = new A([]), f = await o._def.args.parseAsync(l, s).catch((w) => {
|
|
2342
|
-
throw u.addIssue(
|
|
2342
|
+
throw u.addIssue(a(l, w)), u;
|
|
2343
2343
|
}), x = await Reflect.apply(c, this, f);
|
|
2344
2344
|
return await o._def.returns._def.type.parseAsync(x, s).catch((w) => {
|
|
2345
|
-
throw u.addIssue(
|
|
2345
|
+
throw u.addIssue(i(x, w)), u;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
@@ -2350,10 +2350,10 @@ class Y extends _ {
|
|
|
2350
2350
|
return I(function(...l) {
|
|
2351
2351
|
const u = o._def.args.safeParse(l, s);
|
|
2352
2352
|
if (!u.success)
|
|
2353
|
-
throw new A([
|
|
2353
|
+
throw new A([a(l, u.error)]);
|
|
2354
2354
|
const f = Reflect.apply(c, this, u.data), x = o._def.returns.safeParse(f, s);
|
|
2355
2355
|
if (!x.success)
|
|
2356
|
-
throw new A([
|
|
2356
|
+
throw new A([i(f, x.error)]);
|
|
2357
2357
|
return x.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
@@ -2382,12 +2382,12 @@ class Y extends _ {
|
|
|
2382
2382
|
strictImplement(e) {
|
|
2383
2383
|
return this.parse(e);
|
|
2384
2384
|
}
|
|
2385
|
-
static create(e, t,
|
|
2385
|
+
static create(e, t, a) {
|
|
2386
2386
|
return new Y({
|
|
2387
2387
|
args: e || P.create([]).rest(F.create()),
|
|
2388
2388
|
returns: t || F.create(),
|
|
2389
2389
|
typeName: g.ZodFunction,
|
|
2390
|
-
...v(
|
|
2390
|
+
...v(a)
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
@@ -2439,19 +2439,19 @@ class V extends _ {
|
|
|
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), a = this._def.values;
|
|
2443
2443
|
return m(t, {
|
|
2444
|
-
expected: b.joinValues(
|
|
2444
|
+
expected: b.joinValues(a),
|
|
2445
2445
|
received: t.parsedType,
|
|
2446
2446
|
code: d.invalid_type
|
|
2447
2447
|
}), y;
|
|
2448
2448
|
}
|
|
2449
2449
|
if (_e(this, ee) || qe(this, ee, new Set(this._def.values)), !_e(this, ee).has(e.data)) {
|
|
2450
|
-
const t = this._getOrReturnCtx(e),
|
|
2450
|
+
const t = this._getOrReturnCtx(e), a = this._def.values;
|
|
2451
2451
|
return m(t, {
|
|
2452
2452
|
received: t.data,
|
|
2453
2453
|
code: d.invalid_enum_value,
|
|
2454
|
-
options:
|
|
2454
|
+
options: a
|
|
2455
2455
|
}), y;
|
|
2456
2456
|
}
|
|
2457
2457
|
return I(e.data);
|
|
@@ -2484,7 +2484,7 @@ class V extends _ {
|
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
exclude(e, t = this._def) {
|
|
2487
|
-
return V.create(this.options.filter((
|
|
2487
|
+
return V.create(this.options.filter((a) => !e.includes(a)), {
|
|
2488
2488
|
...this._def,
|
|
2489
2489
|
...t
|
|
2490
2490
|
});
|
|
@@ -2497,21 +2497,21 @@ class le extends _ {
|
|
|
2497
2497
|
super(...arguments), te.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), a = this._getOrReturnCtx(e);
|
|
2501
|
+
if (a.parsedType !== p.string && a.parsedType !== p.number) {
|
|
2502
|
+
const i = b.objectValues(t);
|
|
2503
|
+
return m(a, {
|
|
2504
|
+
expected: b.joinValues(i),
|
|
2505
|
+
received: a.parsedType,
|
|
2506
2506
|
code: d.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
2509
|
if (_e(this, te) || qe(this, te, new Set(b.getValidEnumValues(this._def.values))), !_e(this, te).has(e.data)) {
|
|
2510
|
-
const
|
|
2511
|
-
return m(
|
|
2512
|
-
received:
|
|
2510
|
+
const i = b.objectValues(t);
|
|
2511
|
+
return m(a, {
|
|
2512
|
+
received: a.data,
|
|
2513
2513
|
code: d.invalid_enum_value,
|
|
2514
|
-
options:
|
|
2514
|
+
options: i
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
2517
|
return I(e.data);
|
|
@@ -2538,8 +2538,8 @@ class J extends _ {
|
|
|
2538
2538
|
expected: p.promise,
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
|
-
const
|
|
2542
|
-
return I(
|
|
2541
|
+
const a = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
+
return I(a.then((i) => this._def.type.parseAsync(i, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
@@ -2558,24 +2558,24 @@ 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:
|
|
2561
|
+
const { status: t, ctx: a } = this._processInputParams(e), i = this._def.effect || null, s = {
|
|
2562
2562
|
addIssue: (c) => {
|
|
2563
|
-
m(
|
|
2563
|
+
m(a, c), c.fatal ? t.abort() : t.dirty();
|
|
2564
2564
|
},
|
|
2565
2565
|
get path() {
|
|
2566
|
-
return
|
|
2566
|
+
return a.path;
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
|
-
if (s.addIssue = s.addIssue.bind(s),
|
|
2570
|
-
const c =
|
|
2571
|
-
if (
|
|
2569
|
+
if (s.addIssue = s.addIssue.bind(s), i.type === "preprocess") {
|
|
2570
|
+
const c = i.transform(a.data, s);
|
|
2571
|
+
if (a.common.async)
|
|
2572
2572
|
return Promise.resolve(c).then(async (o) => {
|
|
2573
2573
|
if (t.value === "aborted")
|
|
2574
2574
|
return y;
|
|
2575
2575
|
const l = await this._def.schema._parseAsync({
|
|
2576
2576
|
data: o,
|
|
2577
|
-
path:
|
|
2578
|
-
parent:
|
|
2577
|
+
path: a.path,
|
|
2578
|
+
parent: a
|
|
2579
2579
|
});
|
|
2580
2580
|
return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ? Q(l.value) : l;
|
|
2581
2581
|
});
|
|
@@ -2584,47 +2584,47 @@ class j extends _ {
|
|
|
2584
2584
|
return y;
|
|
2585
2585
|
const o = this._def.schema._parseSync({
|
|
2586
2586
|
data: c,
|
|
2587
|
-
path:
|
|
2588
|
-
parent:
|
|
2587
|
+
path: a.path,
|
|
2588
|
+
parent: a
|
|
2589
2589
|
});
|
|
2590
2590
|
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? Q(o.value) : o;
|
|
2591
2591
|
}
|
|
2592
2592
|
}
|
|
2593
|
-
if (
|
|
2593
|
+
if (i.type === "refinement") {
|
|
2594
2594
|
const c = (o) => {
|
|
2595
|
-
const l =
|
|
2596
|
-
if (
|
|
2595
|
+
const l = i.refinement(o, s);
|
|
2596
|
+
if (a.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
2600
|
return o;
|
|
2601
2601
|
};
|
|
2602
|
-
if (
|
|
2602
|
+
if (a.common.async === !1) {
|
|
2603
2603
|
const o = this._def.schema._parseSync({
|
|
2604
|
-
data:
|
|
2605
|
-
path:
|
|
2606
|
-
parent:
|
|
2604
|
+
data: a.data,
|
|
2605
|
+
path: a.path,
|
|
2606
|
+
parent: a
|
|
2607
2607
|
});
|
|
2608
2608
|
return o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), c(o.value), { status: t.value, value: o.value });
|
|
2609
2609
|
} else
|
|
2610
|
-
return this._def.schema._parseAsync({ data:
|
|
2610
|
+
return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), c(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2611
2611
|
}
|
|
2612
|
-
if (
|
|
2613
|
-
if (
|
|
2612
|
+
if (i.type === "transform")
|
|
2613
|
+
if (a.common.async === !1) {
|
|
2614
2614
|
const c = this._def.schema._parseSync({
|
|
2615
|
-
data:
|
|
2616
|
-
path:
|
|
2617
|
-
parent:
|
|
2615
|
+
data: a.data,
|
|
2616
|
+
path: a.path,
|
|
2617
|
+
parent: a
|
|
2618
2618
|
});
|
|
2619
2619
|
if (!U(c))
|
|
2620
2620
|
return c;
|
|
2621
|
-
const o =
|
|
2621
|
+
const o = i.transform(c.value, s);
|
|
2622
2622
|
if (o instanceof Promise)
|
|
2623
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2624
2624
|
return { status: t.value, value: o };
|
|
2625
2625
|
} else
|
|
2626
|
-
return this._def.schema._parseAsync({ data:
|
|
2627
|
-
b.assertNever(
|
|
2626
|
+
return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((c) => U(c) ? Promise.resolve(i.transform(c.value, s)).then((o) => ({ status: t.value, value: o })) : c);
|
|
2627
|
+
b.assertNever(i);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
2630
|
j.create = (n, e, t) => new j({
|
|
@@ -2668,9 +2668,9 @@ L.create = (n, e) => new L({
|
|
|
2668
2668
|
class me 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 a = t.data;
|
|
2672
|
+
return t.parsedType === p.undefined && (a = this._def.defaultValue()), this._def.innerType._parse({
|
|
2673
|
+
data: a,
|
|
2674
2674
|
path: t.path,
|
|
2675
2675
|
parent: t
|
|
2676
2676
|
});
|
|
@@ -2687,34 +2687,34 @@ me.create = (n, e) => new me({
|
|
|
2687
2687
|
});
|
|
2688
2688
|
class pe extends _ {
|
|
2689
2689
|
_parse(e) {
|
|
2690
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2690
|
+
const { ctx: t } = this._processInputParams(e), a = {
|
|
2691
2691
|
...t,
|
|
2692
2692
|
common: {
|
|
2693
2693
|
...t.common,
|
|
2694
2694
|
issues: []
|
|
2695
2695
|
}
|
|
2696
|
-
},
|
|
2697
|
-
data:
|
|
2698
|
-
path:
|
|
2696
|
+
}, i = this._def.innerType._parse({
|
|
2697
|
+
data: a.data,
|
|
2698
|
+
path: a.path,
|
|
2699
2699
|
parent: {
|
|
2700
|
-
...
|
|
2700
|
+
...a
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return ne(
|
|
2703
|
+
return ne(i) ? i.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(a.common.issues);
|
|
2708
2708
|
},
|
|
2709
|
-
input:
|
|
2709
|
+
input: a.data
|
|
2710
2710
|
})
|
|
2711
2711
|
})) : {
|
|
2712
2712
|
status: "valid",
|
|
2713
|
-
value:
|
|
2713
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
|
-
return new A(
|
|
2715
|
+
return new A(a.common.issues);
|
|
2716
2716
|
},
|
|
2717
|
-
input:
|
|
2717
|
+
input: a.data
|
|
2718
2718
|
})
|
|
2719
2719
|
};
|
|
2720
2720
|
}
|
|
@@ -2731,11 +2731,11 @@ pe.create = (n, e) => new pe({
|
|
|
2731
2731
|
class we extends _ {
|
|
2732
2732
|
_parse(e) {
|
|
2733
2733
|
if (this._getType(e) !== p.nan) {
|
|
2734
|
-
const
|
|
2735
|
-
return m(
|
|
2734
|
+
const a = this._getOrReturnCtx(e);
|
|
2735
|
+
return m(a, {
|
|
2736
2736
|
code: d.invalid_type,
|
|
2737
2737
|
expected: p.nan,
|
|
2738
|
-
received:
|
|
2738
|
+
received: a.parsedType
|
|
2739
2739
|
}), y;
|
|
2740
2740
|
}
|
|
2741
2741
|
return { status: "valid", value: e.data };
|
|
@@ -2748,9 +2748,9 @@ we.create = (n) => new we({
|
|
|
2748
2748
|
const Pt = Symbol("zod_brand");
|
|
2749
2749
|
class De extends _ {
|
|
2750
2750
|
_parse(e) {
|
|
2751
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2751
|
+
const { ctx: t } = this._processInputParams(e), a = t.data;
|
|
2752
2752
|
return this._def.type._parse({
|
|
2753
|
-
data:
|
|
2753
|
+
data: a,
|
|
2754
2754
|
path: t.path,
|
|
2755
2755
|
parent: t
|
|
2756
2756
|
});
|
|
@@ -2761,33 +2761,33 @@ class De extends _ {
|
|
|
2761
2761
|
}
|
|
2762
2762
|
class he extends _ {
|
|
2763
2763
|
_parse(e) {
|
|
2764
|
-
const { status: t, ctx:
|
|
2765
|
-
if (
|
|
2764
|
+
const { status: t, ctx: a } = this._processInputParams(e);
|
|
2765
|
+
if (a.common.async)
|
|
2766
2766
|
return (async () => {
|
|
2767
2767
|
const s = await this._def.in._parseAsync({
|
|
2768
|
-
data:
|
|
2769
|
-
path:
|
|
2770
|
-
parent:
|
|
2768
|
+
data: a.data,
|
|
2769
|
+
path: a.path,
|
|
2770
|
+
parent: a
|
|
2771
2771
|
});
|
|
2772
2772
|
return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), Q(s.value)) : this._def.out._parseAsync({
|
|
2773
2773
|
data: s.value,
|
|
2774
|
-
path:
|
|
2775
|
-
parent:
|
|
2774
|
+
path: a.path,
|
|
2775
|
+
parent: a
|
|
2776
2776
|
});
|
|
2777
2777
|
})();
|
|
2778
2778
|
{
|
|
2779
|
-
const
|
|
2780
|
-
data:
|
|
2781
|
-
path:
|
|
2782
|
-
parent:
|
|
2779
|
+
const i = this._def.in._parseSync({
|
|
2780
|
+
data: a.data,
|
|
2781
|
+
path: a.path,
|
|
2782
|
+
parent: a
|
|
2783
2783
|
});
|
|
2784
|
-
return
|
|
2784
|
+
return i.status === "aborted" ? y : i.status === "dirty" ? (t.dirty(), {
|
|
2785
2785
|
status: "dirty",
|
|
2786
|
-
value:
|
|
2786
|
+
value: i.value
|
|
2787
2787
|
}) : this._def.out._parseSync({
|
|
2788
|
-
data:
|
|
2789
|
-
path:
|
|
2790
|
-
parent:
|
|
2788
|
+
data: i.value,
|
|
2789
|
+
path: a.path,
|
|
2790
|
+
parent: a
|
|
2791
2791
|
});
|
|
2792
2792
|
}
|
|
2793
2793
|
}
|
|
@@ -2801,8 +2801,8 @@ class he extends _ {
|
|
|
2801
2801
|
}
|
|
2802
2802
|
class fe extends _ {
|
|
2803
2803
|
_parse(e) {
|
|
2804
|
-
const t = this._def.innerType._parse(e),
|
|
2805
|
-
return ne(t) ? t.then((
|
|
2804
|
+
const t = this._def.innerType._parse(e), a = (i) => (U(i) && (i.value = Object.freeze(i.value)), i);
|
|
2805
|
+
return ne(t) ? t.then((i) => a(i)) : a(t);
|
|
2806
2806
|
}
|
|
2807
2807
|
unwrap() {
|
|
2808
2808
|
return this._def.innerType;
|
|
@@ -2818,20 +2818,20 @@ function ze(n, e) {
|
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
2820
|
function Xe(n, e = {}, t) {
|
|
2821
|
-
return n ? G.create().superRefine((
|
|
2821
|
+
return n ? G.create().superRefine((a, i) => {
|
|
2822
2822
|
var s, c;
|
|
2823
|
-
const o = n(
|
|
2823
|
+
const o = n(a);
|
|
2824
2824
|
if (o instanceof Promise)
|
|
2825
2825
|
return o.then((l) => {
|
|
2826
2826
|
var u, f;
|
|
2827
2827
|
if (!l) {
|
|
2828
|
-
const x = ze(e,
|
|
2829
|
-
|
|
2828
|
+
const x = ze(e, a), T = (f = (u = x.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
|
|
2829
|
+
i.addIssue({ code: "custom", ...x, fatal: T });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
2832
|
if (!o) {
|
|
2833
|
-
const l = ze(e,
|
|
2834
|
-
|
|
2833
|
+
const l = ze(e, a), u = (c = (s = l.fatal) !== null && s !== void 0 ? s : t) !== null && c !== void 0 ? c : !0;
|
|
2834
|
+
i.addIssue({ code: "custom", ...l, fatal: u });
|
|
2835
2835
|
}
|
|
2836
2836
|
}) : G.create();
|
|
2837
2837
|
}
|
|
@@ -2844,7 +2844,7 @@ var g;
|
|
|
2844
2844
|
})(g || (g = {}));
|
|
2845
2845
|
const Et = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) => Xe((t) => t instanceof n, e), Ge = N.create, Je = M.create, Rt = we.create, $t = z.create, He = re.create, Mt = q.create, zt = be.create, Vt =
|
|
2847
|
+
}) => Xe((t) => t instanceof n, e), Ge = N.create, Je = M.create, Rt = we.create, $t = z.create, He = re.create, Mt = q.create, zt = be.create, Vt = ae.create, Lt = ie.create, Ft = G.create, Ut = F.create, qt = $.create, Bt = xe.create, Wt = C.create, Qt = k.create, Yt = k.strictCreate, Xt = se.create, Gt = Te.create, Jt = oe.create, Ht = P.create, Kt = ce.create, en = ke.create, tn = B.create, nn = Y.create, rn = de.create, an = ue.create, sn = V.create, on = le.create, cn = J.create, Ve = j.create, dn = Z.create, un = L.create, ln = j.createWithPreprocess, mn = he.create, pn = () => Ge().optional(), fn = () => Je().optional(), hn = () => He().optional(), gn = {
|
|
2848
2848
|
string: (n) => N.create({ ...n, coerce: !0 }),
|
|
2849
2849
|
number: (n) => M.create({ ...n, coerce: !0 }),
|
|
2850
2850
|
boolean: (n) => re.create({
|
|
@@ -2886,8 +2886,8 @@ var r = /* @__PURE__ */ Object.freeze({
|
|
|
2886
2886
|
ZodBoolean: re,
|
|
2887
2887
|
ZodDate: q,
|
|
2888
2888
|
ZodSymbol: be,
|
|
2889
|
-
ZodUndefined:
|
|
2890
|
-
ZodNull:
|
|
2889
|
+
ZodUndefined: ae,
|
|
2890
|
+
ZodNull: ie,
|
|
2891
2891
|
ZodAny: G,
|
|
2892
2892
|
ZodUnknown: F,
|
|
2893
2893
|
ZodNever: $,
|
|
@@ -2979,8 +2979,8 @@ const Se = r.object({
|
|
|
2979
2979
|
apartmentEnterNumber: r.string().optional(),
|
|
2980
2980
|
apartmentNumber: r.string().optional(),
|
|
2981
2981
|
zip: r.string().optional()
|
|
2982
|
-
}), R = r.string().min(1, { message: "שדה חובה" }),
|
|
2983
|
-
function
|
|
2982
|
+
}), R = r.string().min(1, { message: "שדה חובה" }), Vn = r.string().regex(/^\d+$/, "Must be a numeric string"), Ln = r.object({ url: r.string().url(), id: r.string() });
|
|
2983
|
+
function Fn(n) {
|
|
2984
2984
|
return !!(n != null && n.url);
|
|
2985
2985
|
}
|
|
2986
2986
|
const ge = r.object({
|
|
@@ -2996,7 +2996,7 @@ const ge = r.object({
|
|
|
2996
2996
|
depth: r.number()
|
|
2997
2997
|
}), Ee = Ke.extend({
|
|
2998
2998
|
children: r.lazy(() => Ee.array())
|
|
2999
|
-
}),
|
|
2999
|
+
}), Un = Ke.extend({
|
|
3000
3000
|
index: r.number(),
|
|
3001
3001
|
depth: r.number(),
|
|
3002
3002
|
collapsed: r.boolean().optional(),
|
|
@@ -3058,7 +3058,7 @@ const ge = r.object({
|
|
|
3058
3058
|
}).optional(),
|
|
3059
3059
|
// @deprecated
|
|
3060
3060
|
categoryNames: r.array(r.string()).optional()
|
|
3061
|
-
}),
|
|
3061
|
+
}), qn = Re.extend({
|
|
3062
3062
|
image: r.instanceof(File).optional()
|
|
3063
3063
|
}), vn = r.enum(["delivered", "missing", "substituted"]), _n = r.object({
|
|
3064
3064
|
product: Re,
|
|
@@ -3073,7 +3073,7 @@ const ge = r.object({
|
|
|
3073
3073
|
// Picking / fulfillment — optional so existing items stay valid (treated as "delivered").
|
|
3074
3074
|
status: vn.optional(),
|
|
3075
3075
|
substitutedWith: _n.nullable().optional()
|
|
3076
|
-
}),
|
|
3076
|
+
}), Bn = r.object({
|
|
3077
3077
|
type: r.literal("Cart"),
|
|
3078
3078
|
id: r.string().uuid(),
|
|
3079
3079
|
companyId: r.string().uuid(),
|
|
@@ -3081,11 +3081,11 @@ const ge = r.object({
|
|
|
3081
3081
|
userId: r.string().uuid(),
|
|
3082
3082
|
status: r.enum(["active", "draft", "completed"]),
|
|
3083
3083
|
items: r.array(et)
|
|
3084
|
-
}),
|
|
3084
|
+
}), Wn = r.object({
|
|
3085
3085
|
id: r.string(),
|
|
3086
3086
|
name: r.string(),
|
|
3087
3087
|
websiteDomains: r.array(r.string())
|
|
3088
|
-
}),
|
|
3088
|
+
}), Qn = r.object({
|
|
3089
3089
|
type: r.literal("FavoriteProduct"),
|
|
3090
3090
|
id: r.string().uuid(),
|
|
3091
3091
|
companyId: r.string().uuid(),
|
|
@@ -3185,6 +3185,12 @@ const ge = r.object({
|
|
|
3185
3185
|
restricted: r.boolean().optional(),
|
|
3186
3186
|
allowedCategories: r.array(r.string()).optional()
|
|
3187
3187
|
}), Tn = r.object({
|
|
3188
|
+
id: r.string(),
|
|
3189
|
+
label: r.string(),
|
|
3190
|
+
address: r.string().optional(),
|
|
3191
|
+
phone: r.string().optional(),
|
|
3192
|
+
isPrimary: r.boolean().optional()
|
|
3193
|
+
}), Sn = r.object({
|
|
3188
3194
|
id: r.string(),
|
|
3189
3195
|
name: r.string(),
|
|
3190
3196
|
discountPercentage: r.number().positive().min(0).max(100).optional(),
|
|
@@ -3198,8 +3204,9 @@ const ge = r.object({
|
|
|
3198
3204
|
phone: r.string().optional(),
|
|
3199
3205
|
email: r.string().optional(),
|
|
3200
3206
|
notes: r.string().optional(),
|
|
3201
|
-
freeShipping: r.boolean().optional()
|
|
3202
|
-
|
|
3207
|
+
freeShipping: r.boolean().optional(),
|
|
3208
|
+
branches: r.array(Tn).optional()
|
|
3209
|
+
}), Yn = Sn.omit({ id: !0 }), Le = r.object({
|
|
3203
3210
|
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3204
3211
|
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3205
3212
|
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
@@ -3210,7 +3217,7 @@ const ge = r.object({
|
|
|
3210
3217
|
calculatedData: tt,
|
|
3211
3218
|
warning: r.string().optional(),
|
|
3212
3219
|
date: r.number().optional()
|
|
3213
|
-
}),
|
|
3220
|
+
}), In = r.object({
|
|
3214
3221
|
id: r.string().min(1, "ID is required"),
|
|
3215
3222
|
number: r.string().min(1, "Number is required"),
|
|
3216
3223
|
date: r.string().min(1, "Date is required"),
|
|
@@ -3239,7 +3246,7 @@ const ge = r.object({
|
|
|
3239
3246
|
total: r.number().min(1, "Total is required").optional(),
|
|
3240
3247
|
vat: r.number().min(1, "VAT is required").optional(),
|
|
3241
3248
|
link: r.string().url("Link must be a valid URL").optional()
|
|
3242
|
-
}),
|
|
3249
|
+
}), Xn = r.object({
|
|
3243
3250
|
type: r.literal("Order"),
|
|
3244
3251
|
createdBy: r.enum(["user", "admin"]).optional(),
|
|
3245
3252
|
id: R,
|
|
@@ -3306,7 +3313,7 @@ const ge = r.object({
|
|
|
3306
3313
|
organizationId: r.string().optional(),
|
|
3307
3314
|
billingAccount: nt.optional(),
|
|
3308
3315
|
deliveryNote: kn.optional(),
|
|
3309
|
-
invoice:
|
|
3316
|
+
invoice: In.optional(),
|
|
3310
3317
|
ezInvoice: Le.optional(),
|
|
3311
3318
|
ezDeliveryNote: xn.optional(),
|
|
3312
3319
|
/**
|
|
@@ -3324,7 +3331,7 @@ const ge = r.object({
|
|
|
3324
3331
|
// Audit: who last changed the order + when (epoch millis). Stamped by admin writes.
|
|
3325
3332
|
updatedBy: r.string().optional(),
|
|
3326
3333
|
updatedAt: r.number().optional()
|
|
3327
|
-
}),
|
|
3334
|
+
}), An = r.enum(["individual", "company"]), Gn = r.object({
|
|
3328
3335
|
id: r.string(),
|
|
3329
3336
|
companyId: r.string(),
|
|
3330
3337
|
name: r.string(),
|
|
@@ -3335,17 +3342,17 @@ const ge = r.object({
|
|
|
3335
3342
|
paymentType: Ie,
|
|
3336
3343
|
allowAnonymousClients: r.boolean(),
|
|
3337
3344
|
isVatIncludedInPrice: r.boolean(),
|
|
3338
|
-
clientTypes: r.array(
|
|
3345
|
+
clientTypes: r.array(An),
|
|
3339
3346
|
minimumOrder: r.number().optional(),
|
|
3340
3347
|
freeDeliveryPrice: r.number().optional(),
|
|
3341
3348
|
deliveryPrice: r.number().optional(),
|
|
3342
3349
|
address: Se.optional(),
|
|
3343
3350
|
companyNumber: r.string().optional()
|
|
3344
3351
|
// חפ של החברה
|
|
3345
|
-
}),
|
|
3352
|
+
}), Nn = r.object({
|
|
3346
3353
|
minSpend: r.number().positive().optional(),
|
|
3347
3354
|
stackable: r.boolean().default(!1)
|
|
3348
|
-
}).optional(),
|
|
3355
|
+
}).optional(), Cn = r.discriminatedUnion("variantType", [
|
|
3349
3356
|
r.object({
|
|
3350
3357
|
variantType: r.literal("bundle"),
|
|
3351
3358
|
productsId: r.array(r.string().nonempty()).min(1),
|
|
@@ -3355,7 +3362,7 @@ const ge = r.object({
|
|
|
3355
3362
|
bundlePrice: r.number().positive()
|
|
3356
3363
|
// Total price for the bundle (e.g., $25)
|
|
3357
3364
|
})
|
|
3358
|
-
]),
|
|
3365
|
+
]), Jn = r.object({
|
|
3359
3366
|
type: r.literal("Discount"),
|
|
3360
3367
|
storeId: r.string().min(1),
|
|
3361
3368
|
companyId: r.string().min(1),
|
|
@@ -3364,26 +3371,26 @@ const ge = r.object({
|
|
|
3364
3371
|
active: r.boolean(),
|
|
3365
3372
|
startDate: r.number(),
|
|
3366
3373
|
endDate: r.number(),
|
|
3367
|
-
variant:
|
|
3368
|
-
conditions:
|
|
3374
|
+
variant: Cn,
|
|
3375
|
+
conditions: Nn
|
|
3369
3376
|
});
|
|
3370
|
-
class
|
|
3377
|
+
class jn {
|
|
3371
3378
|
canApply(e, t) {
|
|
3372
3379
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3373
|
-
const { productsId:
|
|
3374
|
-
return this.getTotalQuantity(t.cart,
|
|
3380
|
+
const { productsId: a, requiredQuantity: i } = e.variant;
|
|
3381
|
+
return this.getTotalQuantity(t.cart, a) >= i;
|
|
3375
3382
|
}
|
|
3376
3383
|
calculate(e, t) {
|
|
3377
3384
|
if (e.variant.variantType !== "bundle")
|
|
3378
3385
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3379
|
-
const { productsId:
|
|
3386
|
+
const { productsId: a, requiredQuantity: i, bundlePrice: s } = e.variant, c = t.cart.filter((H) => a.includes(H.product.id)), o = this.getTotalQuantity(t.cart, a), l = Math.floor(o / i);
|
|
3380
3387
|
if (l === 0)
|
|
3381
3388
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3382
|
-
const u = this.calculateOriginalPrice(c), f = this.getTotalQuantity(t.cart,
|
|
3389
|
+
const u = this.calculateOriginalPrice(c), f = this.getTotalQuantity(t.cart, a), x = this.calculateDiscountedPrice(
|
|
3383
3390
|
u,
|
|
3384
3391
|
s,
|
|
3385
3392
|
l,
|
|
3386
|
-
|
|
3393
|
+
i,
|
|
3387
3394
|
f
|
|
3388
3395
|
), T = u - x, w = this.distributeDiscount(c, T, u);
|
|
3389
3396
|
return {
|
|
@@ -3397,19 +3404,19 @@ class Cn {
|
|
|
3397
3404
|
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3398
3405
|
}
|
|
3399
3406
|
getTotalQuantity(e, t) {
|
|
3400
|
-
return e.filter((
|
|
3407
|
+
return e.filter((a) => t.includes(a.product.id)).reduce((a, i) => a + i.amount, 0);
|
|
3401
3408
|
}
|
|
3402
3409
|
calculateOriginalPrice(e) {
|
|
3403
|
-
return e.reduce((t,
|
|
3410
|
+
return e.reduce((t, a) => t + a.product.price * a.amount, 0);
|
|
3404
3411
|
}
|
|
3405
|
-
calculateDiscountedPrice(e, t,
|
|
3406
|
-
const c = t *
|
|
3412
|
+
calculateDiscountedPrice(e, t, a, i, s) {
|
|
3413
|
+
const c = t * a, o = a * i, u = Math.max(0, s - o) / s * e;
|
|
3407
3414
|
return c + u;
|
|
3408
3415
|
}
|
|
3409
|
-
distributeDiscount(e, t,
|
|
3410
|
-
const
|
|
3416
|
+
distributeDiscount(e, t, a) {
|
|
3417
|
+
const i = t / a;
|
|
3411
3418
|
return e.map((s) => {
|
|
3412
|
-
const c = s.product.price * s.amount *
|
|
3419
|
+
const c = s.product.price * s.amount * i;
|
|
3413
3420
|
return {
|
|
3414
3421
|
productId: s.product.id,
|
|
3415
3422
|
quantity: s.amount,
|
|
@@ -3435,26 +3442,26 @@ class rt {
|
|
|
3435
3442
|
}
|
|
3436
3443
|
}
|
|
3437
3444
|
$e(rt, "strategies", /* @__PURE__ */ new Map([
|
|
3438
|
-
["bundle", new
|
|
3445
|
+
["bundle", new jn()]
|
|
3439
3446
|
]));
|
|
3440
|
-
class
|
|
3441
|
-
static calculateDiscounts(e, t,
|
|
3447
|
+
class Hn {
|
|
3448
|
+
static calculateDiscounts(e, t, a) {
|
|
3442
3449
|
var u, f;
|
|
3443
|
-
const
|
|
3450
|
+
const i = {
|
|
3444
3451
|
cart: e,
|
|
3445
|
-
user:
|
|
3452
|
+
user: a,
|
|
3446
3453
|
appliedDiscounts: []
|
|
3447
3454
|
}, s = this.filterActiveDiscounts(t), c = [];
|
|
3448
3455
|
for (const x of s) {
|
|
3449
3456
|
const T = rt.getStrategy(x);
|
|
3450
|
-
if (!T || !T.canApply(x,
|
|
3451
|
-
const w = T.calculate(x,
|
|
3457
|
+
if (!T || !T.canApply(x, i) || !((u = x.conditions) != null && u.stackable) && c.length > 0) continue;
|
|
3458
|
+
const w = T.calculate(x, i);
|
|
3452
3459
|
w.applicable && (c.push({
|
|
3453
3460
|
discountId: x.id,
|
|
3454
3461
|
discountName: ((f = x.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3455
3462
|
discountAmount: Number(w.discountAmount.toFixed(2)),
|
|
3456
3463
|
affectedItems: w.affectedItems
|
|
3457
|
-
}),
|
|
3464
|
+
}), i.appliedDiscounts = c);
|
|
3458
3465
|
}
|
|
3459
3466
|
const o = this.calculateFinalPrices(e, c), l = c.reduce(
|
|
3460
3467
|
(x, T) => x + T.discountAmount,
|
|
@@ -3469,26 +3476,26 @@ class Jn {
|
|
|
3469
3476
|
static filterActiveDiscounts(e) {
|
|
3470
3477
|
const t = Date.now();
|
|
3471
3478
|
return e.filter(
|
|
3472
|
-
(
|
|
3479
|
+
(a) => a.active && a.startDate <= t && a.endDate >= t
|
|
3473
3480
|
);
|
|
3474
3481
|
}
|
|
3475
3482
|
static calculateFinalPrices(e, t) {
|
|
3476
|
-
return e.map((
|
|
3477
|
-
const
|
|
3478
|
-
(l) => l.affectedItems.some((u) => u.productId ===
|
|
3479
|
-
), s =
|
|
3483
|
+
return e.map((a) => {
|
|
3484
|
+
const i = t.filter(
|
|
3485
|
+
(l) => l.affectedItems.some((u) => u.productId === a.product.id)
|
|
3486
|
+
), s = i.reduce((l, u) => {
|
|
3480
3487
|
const f = u.affectedItems.find(
|
|
3481
|
-
(x) => x.productId ===
|
|
3488
|
+
(x) => x.productId === a.product.id
|
|
3482
3489
|
);
|
|
3483
3490
|
return l + ((f == null ? void 0 : f.discountAmount) || 0);
|
|
3484
|
-
}, 0), c = s /
|
|
3491
|
+
}, 0), c = s / a.amount, o = a.product.price - c;
|
|
3485
3492
|
return {
|
|
3486
|
-
amount:
|
|
3487
|
-
product:
|
|
3488
|
-
originalPrice: Number(
|
|
3493
|
+
amount: a.amount,
|
|
3494
|
+
product: a.product,
|
|
3495
|
+
originalPrice: Number(a.product.price.toFixed(2)),
|
|
3489
3496
|
finalPrice: Number(Math.max(0, o).toFixed(2)),
|
|
3490
3497
|
finalDiscount: Number(s.toFixed(2)),
|
|
3491
|
-
appliedDiscounts:
|
|
3498
|
+
appliedDiscounts: i.map((l) => l.discountId)
|
|
3492
3499
|
};
|
|
3493
3500
|
});
|
|
3494
3501
|
}
|
|
@@ -3500,23 +3507,23 @@ class Jn {
|
|
|
3500
3507
|
return this.filterActiveDiscounts(e);
|
|
3501
3508
|
}
|
|
3502
3509
|
}
|
|
3503
|
-
const
|
|
3510
|
+
const Zn = r.object({
|
|
3504
3511
|
id: r.string(),
|
|
3505
3512
|
name: r.string()
|
|
3506
|
-
}),
|
|
3513
|
+
}), Kn = Zn.omit({ id: !0 }), at = r.object({
|
|
3507
3514
|
type: r.literal("Supplier"),
|
|
3508
3515
|
id: r.string(),
|
|
3509
3516
|
name: r.string(),
|
|
3510
3517
|
code: r.string()
|
|
3511
3518
|
// supplier code number
|
|
3512
|
-
}),
|
|
3519
|
+
}), er = at.omit({ id: !0 }), On = r.object({
|
|
3513
3520
|
type: r.literal("SupplierInvoice"),
|
|
3514
3521
|
id: r.string(),
|
|
3515
3522
|
// "draft" = work-in-progress, NOT yet finalized. Product prices are only
|
|
3516
3523
|
// updated once the invoice is finalized ("completed"). Legacy invoices have
|
|
3517
3524
|
// no status and are treated as finalized.
|
|
3518
3525
|
status: r.enum(["draft", "completed"]).optional(),
|
|
3519
|
-
supplier:
|
|
3526
|
+
supplier: at,
|
|
3520
3527
|
invoiceNumber: r.string(),
|
|
3521
3528
|
date: r.number(),
|
|
3522
3529
|
rows: r.array(
|
|
@@ -3554,14 +3561,14 @@ const jn = r.object({
|
|
|
3554
3561
|
total: r.number().optional(),
|
|
3555
3562
|
totalBeforeVat: r.number().optional(),
|
|
3556
3563
|
vat: r.number().optional()
|
|
3557
|
-
}),
|
|
3564
|
+
}), tr = On.omit({ id: !0 }), Pn = r.enum(["debt_increase", "debt_reduction"]), nr = r.object({
|
|
3558
3565
|
recordId: r.string().min(1),
|
|
3559
3566
|
organizationId: r.string().min(1),
|
|
3560
3567
|
customerId: r.string(),
|
|
3561
3568
|
// "system" when no acting user
|
|
3562
3569
|
customerName: r.string(),
|
|
3563
3570
|
billingAccountId: r.string().nullable(),
|
|
3564
|
-
type:
|
|
3571
|
+
type: Pn,
|
|
3565
3572
|
/** Integer agorot, always positive */
|
|
3566
3573
|
amount: r.number().int().positive(),
|
|
3567
3574
|
currency: r.literal("ILS"),
|
|
@@ -3579,7 +3586,7 @@ const jn = r.object({
|
|
|
3579
3586
|
yearMonth: r.string(),
|
|
3580
3587
|
companyId: r.string().min(1),
|
|
3581
3588
|
storeId: r.string().min(1)
|
|
3582
|
-
}),
|
|
3589
|
+
}), rr = r.object({
|
|
3583
3590
|
/** = doc id */
|
|
3584
3591
|
organizationId: r.string().min(1),
|
|
3585
3592
|
organizationName: r.string(),
|
|
@@ -3593,7 +3600,7 @@ const jn = r.object({
|
|
|
3593
3600
|
updatedAt: r.number().int().positive(),
|
|
3594
3601
|
companyId: r.string().min(1),
|
|
3595
3602
|
storeId: r.string().min(1)
|
|
3596
|
-
}),
|
|
3603
|
+
}), ar = r.enum([
|
|
3597
3604
|
"delivery_note",
|
|
3598
3605
|
"payment_received",
|
|
3599
3606
|
"credit_note",
|
|
@@ -3604,7 +3611,7 @@ const jn = r.object({
|
|
|
3604
3611
|
// legacy
|
|
3605
3612
|
"order_refunded"
|
|
3606
3613
|
// legacy
|
|
3607
|
-
]), ir = r.enum(["check", "bank_transfer", "cash", "credit_card", "other"]),
|
|
3614
|
+
]), ir = r.enum(["check", "bank_transfer", "cash", "credit_card", "other"]), sr = r.object({
|
|
3608
3615
|
/** = deterministic dedup doc id */
|
|
3609
3616
|
id: r.string().min(1),
|
|
3610
3617
|
organizationId: r.string().min(1),
|
|
@@ -3636,7 +3643,7 @@ const jn = r.object({
|
|
|
3636
3643
|
createdAt: r.number().int().positive(),
|
|
3637
3644
|
companyId: r.string().min(1),
|
|
3638
3645
|
storeId: r.string().min(1)
|
|
3639
|
-
}),
|
|
3646
|
+
}), or = r.object({
|
|
3640
3647
|
/** = doc id */
|
|
3641
3648
|
organizationId: r.string().min(1),
|
|
3642
3649
|
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
@@ -3659,47 +3666,47 @@ const jn = r.object({
|
|
|
3659
3666
|
}), Pe = {
|
|
3660
3667
|
VAT: 18
|
|
3661
3668
|
};
|
|
3662
|
-
function Pn(n, e) {
|
|
3663
|
-
var t, i;
|
|
3664
|
-
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;
|
|
3665
|
-
}
|
|
3666
3669
|
function Dn(n, e) {
|
|
3667
|
-
var
|
|
3670
|
+
var t, a;
|
|
3671
|
+
return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((a = n.discount) == null ? void 0 : a.type) === "number" ? n.discount.value ?? 0 : 0;
|
|
3672
|
+
}
|
|
3673
|
+
function En(n, e) {
|
|
3674
|
+
var a, i;
|
|
3668
3675
|
const t = e && n.vat ? n.price + n.price * Pe.VAT / 100 : n.price;
|
|
3669
|
-
if (((
|
|
3676
|
+
if (((a = n.discount) == null ? void 0 : a.type) === "percent") {
|
|
3670
3677
|
const s = t * n.discount.value / 100;
|
|
3671
3678
|
return n.price - s;
|
|
3672
3679
|
}
|
|
3673
|
-
return ((
|
|
3680
|
+
return ((i = n.discount) == null ? void 0 : i.type) === "number" ? t - n.discount.value : t;
|
|
3674
3681
|
}
|
|
3675
|
-
function
|
|
3682
|
+
function cr({
|
|
3676
3683
|
cart: n,
|
|
3677
3684
|
discounts: e,
|
|
3678
3685
|
deliveryPrice: t = 0,
|
|
3679
|
-
freeDeliveryPrice:
|
|
3680
|
-
isVatIncludedInPrice:
|
|
3686
|
+
freeDeliveryPrice: a = 0,
|
|
3687
|
+
isVatIncludedInPrice: i = !1
|
|
3681
3688
|
}) {
|
|
3682
3689
|
const s = n.map((o, l) => ({
|
|
3683
3690
|
amount: o.amount,
|
|
3684
3691
|
product: { ...o.product },
|
|
3685
3692
|
originalPrice: o.product.price,
|
|
3686
|
-
finalPrice:
|
|
3687
|
-
finalDiscount:
|
|
3693
|
+
finalPrice: En(o.product, i),
|
|
3694
|
+
finalDiscount: Dn(o.product)
|
|
3688
3695
|
})), c = s.reduce(
|
|
3689
3696
|
(o, l) => {
|
|
3690
3697
|
const { product: u, amount: f, finalPrice: x, finalDiscount: T } = l;
|
|
3691
3698
|
let w = 0;
|
|
3692
3699
|
if (u.vat) {
|
|
3693
3700
|
let Ae = 0;
|
|
3694
|
-
if (
|
|
3695
|
-
const
|
|
3701
|
+
if (i) {
|
|
3702
|
+
const it = Number((x / (1 + Pe.VAT / 100)).toFixed(2)), st = x - it;
|
|
3696
3703
|
w = Number(st.toFixed(2)), w = w * f, Ae = Number(w.toFixed(2));
|
|
3697
3704
|
} else
|
|
3698
3705
|
w = x * Pe.VAT / 100, w = w * f, Ae = Number(w.toFixed(2));
|
|
3699
3706
|
o.vat = Number((o.vat + Ae).toFixed(2));
|
|
3700
3707
|
}
|
|
3701
3708
|
const H = Number(x.toFixed(2));
|
|
3702
|
-
return o.cost += f * H, o.discount += T && f * T, o.finalCost += f * H + (
|
|
3709
|
+
return o.cost += f * H, o.discount += T && f * T, o.finalCost += f * H + (i ? 0 : w), o.productsCost += f * H + (i ? 0 : w), o.cost = Number(o.cost.toFixed(2)), o.discount = Number(o.discount.toFixed(2)), o.finalCost = Number(o.finalCost.toFixed(2)), o.productsCost = Number(o.productsCost.toFixed(2)), o;
|
|
3703
3710
|
},
|
|
3704
3711
|
{
|
|
3705
3712
|
discount: 0,
|
|
@@ -3710,12 +3717,12 @@ function or({
|
|
|
3710
3717
|
deliveryPrice: t
|
|
3711
3718
|
}
|
|
3712
3719
|
);
|
|
3713
|
-
return c.deliveryPrice && c.productsCost >=
|
|
3720
|
+
return c.deliveryPrice && c.productsCost >= a ? c.deliveryPrice = 0 : c.finalCost += c.deliveryPrice, { items: s, ...c };
|
|
3714
3721
|
}
|
|
3715
|
-
const
|
|
3722
|
+
const Rn = {
|
|
3716
3723
|
stores: "STORES",
|
|
3717
3724
|
companies: "COMPANIES"
|
|
3718
|
-
},
|
|
3725
|
+
}, $n = {
|
|
3719
3726
|
products: "products",
|
|
3720
3727
|
"favorite-products": "favorite-products",
|
|
3721
3728
|
profiles: "profiles",
|
|
@@ -3744,35 +3751,35 @@ const En = {
|
|
|
3744
3751
|
duplicateChargeAlerts: "duplicateChargeAlerts",
|
|
3745
3752
|
organizationBalance: "organizationBalance",
|
|
3746
3753
|
organizationBalanceRollup: "organizationBalanceRollup"
|
|
3747
|
-
},
|
|
3748
|
-
systemCollections:
|
|
3749
|
-
storeCollections:
|
|
3754
|
+
}, Mn = {
|
|
3755
|
+
systemCollections: Rn,
|
|
3756
|
+
storeCollections: $n,
|
|
3750
3757
|
// for client and server
|
|
3751
3758
|
getPath: ({
|
|
3752
3759
|
companyId: n,
|
|
3753
3760
|
storeId: e,
|
|
3754
3761
|
collectionName: t,
|
|
3755
|
-
id:
|
|
3756
|
-
}) => `${n}/${e}/${t}${
|
|
3762
|
+
id: a
|
|
3763
|
+
}) => `${n}/${e}/${t}${a ? `/${a}` : ""}`,
|
|
3757
3764
|
getSubPath: ({
|
|
3758
3765
|
companyId: n,
|
|
3759
3766
|
storeId: e,
|
|
3760
3767
|
collectionName: t,
|
|
3761
|
-
subCollectionName:
|
|
3762
|
-
id:
|
|
3768
|
+
subCollectionName: a,
|
|
3769
|
+
id: i,
|
|
3763
3770
|
subId: s
|
|
3764
|
-
}) => `${n}/${e}/${t}/${
|
|
3771
|
+
}) => `${n}/${e}/${t}/${i}/${a}${s ? `/${s}` : ""}`,
|
|
3765
3772
|
// for firestore events
|
|
3766
3773
|
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
|
|
3767
3774
|
getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
|
|
3768
|
-
},
|
|
3769
|
-
firestore:
|
|
3775
|
+
}, dr = {
|
|
3776
|
+
firestore: Mn
|
|
3770
3777
|
}, Fe = {
|
|
3771
3778
|
round: (n, e = 2) => {
|
|
3772
3779
|
const t = 10 ** e;
|
|
3773
3780
|
return Math.round((n + Number.EPSILON) * t) / t;
|
|
3774
3781
|
}
|
|
3775
|
-
},
|
|
3782
|
+
}, ur = {
|
|
3776
3783
|
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : Fe.round(e / (1 - n / 100)),
|
|
3777
3784
|
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : Fe.round((n - e) / n * 100)
|
|
3778
3785
|
};
|
|
@@ -3780,58 +3787,59 @@ export {
|
|
|
3780
3787
|
Se as AddressSchema,
|
|
3781
3788
|
Ke as BaseCategorySchema,
|
|
3782
3789
|
nt as BillingAccountSchema,
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3790
|
+
Tn as BranchSchema,
|
|
3791
|
+
nr as BudgetRecordSchema,
|
|
3792
|
+
Pn as BudgetRecordTypeSchema,
|
|
3793
|
+
ar as BudgetTransactionTypeSchema,
|
|
3794
|
+
jn as BundleDiscountStrategy,
|
|
3787
3795
|
tt as CalculatedDataSchema,
|
|
3788
3796
|
et as CartItemProductSchema,
|
|
3789
|
-
|
|
3797
|
+
Bn as CartSchema,
|
|
3790
3798
|
Ee as CategorySchema,
|
|
3791
|
-
|
|
3799
|
+
Wn as CompanySchema,
|
|
3792
3800
|
kn as DeliveryNoteSchema,
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3801
|
+
Nn as DiscountConditionsSchema,
|
|
3802
|
+
Hn as DiscountEngine,
|
|
3803
|
+
Jn as DiscountSchema,
|
|
3796
3804
|
rt as DiscountStrategyFactory,
|
|
3797
|
-
|
|
3805
|
+
Cn as DiscountVariantSchema,
|
|
3798
3806
|
xn as EzDeliveryNoteSchema,
|
|
3799
3807
|
Le as EzInvoiceSchema,
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3808
|
+
Qn as FavoriteProductSchema,
|
|
3809
|
+
Ln as FileSchema,
|
|
3810
|
+
dr as FirebaseAPI,
|
|
3803
3811
|
vn as FulfillmentStatusSchema,
|
|
3804
|
-
|
|
3812
|
+
In as InvoiceSchema,
|
|
3805
3813
|
ge as LocaleSchema,
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3814
|
+
Kn as NewOrganizationGroupSchema,
|
|
3815
|
+
Yn as NewOrganizationSchema,
|
|
3816
|
+
qn as NewProductSchema,
|
|
3817
|
+
tr as NewSupplierInvoiceSchema,
|
|
3818
|
+
er as NewSupplierSchema,
|
|
3819
|
+
Xn as OrderSchema,
|
|
3820
|
+
sr as OrganizationBalanceEntrySchema,
|
|
3821
|
+
or as OrganizationBalanceRollupSchema,
|
|
3822
|
+
rr as OrganizationBudgetSchema,
|
|
3823
|
+
Zn as OrganizationGroupSchema,
|
|
3824
|
+
Sn as OrganizationSchema,
|
|
3817
3825
|
ir as PaymentMethodSchema,
|
|
3818
3826
|
wn as PaymentTermsSchema,
|
|
3819
3827
|
Ie as PaymentTypeSchema,
|
|
3820
3828
|
Re as ProductSchema,
|
|
3821
3829
|
bn as ProfileSchema,
|
|
3822
|
-
|
|
3830
|
+
Gn as StoreSchema,
|
|
3823
3831
|
_n as SubstitutedWithSchema,
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3832
|
+
On as SupplierInvoiceSchema,
|
|
3833
|
+
at as SupplierSchema,
|
|
3834
|
+
Un as TFlattenCategorySchema,
|
|
3835
|
+
An as clientTypesSchema,
|
|
3836
|
+
cr as getCartCost,
|
|
3837
|
+
Fn as isFile,
|
|
3830
3838
|
Fe as math,
|
|
3831
3839
|
R as notEmptyTextSchema,
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3840
|
+
Vn as numericTextSchema,
|
|
3841
|
+
ur as storeCalculator,
|
|
3842
|
+
$n as storeCollections,
|
|
3843
|
+
Rn as systemCollections
|
|
3836
3844
|
};
|
|
3837
3845
|
//# sourceMappingURL=core.es.js.map
|