@jsdev_ninja/core 0.14.3 → 0.14.5
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 +641 -593
- 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/Chatbot/index.d.ts +96 -0
- package/dist/lib/entities/Chatbot/index.d.ts.map +1 -0
- package/dist/lib/entities/Chatbot/index.js +37 -0
- package/dist/lib/entities/index.d.ts +1 -0
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +1 -0
- package/dist/lib/firebase-api/index.d.ts +27 -0
- package/dist/lib/firebase-api/index.d.ts.map +1 -1
- package/dist/lib/firebase-api/index.js +9 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.es.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
var ut = Object.defineProperty;
|
|
2
2
|
var dt = (n, e, t) => e in n ? ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
-
var
|
|
3
|
+
var $e = (n, e, t) => dt(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var x;
|
|
5
5
|
(function(n) {
|
|
6
|
-
n.assertEqual = (
|
|
7
|
-
function e(
|
|
6
|
+
n.assertEqual = (a) => a;
|
|
7
|
+
function e(a) {
|
|
8
8
|
}
|
|
9
9
|
n.assertIs = e;
|
|
10
|
-
function t(
|
|
10
|
+
function t(a) {
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
|
-
n.assertNever = t, n.arrayToEnum = (
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (a) => {
|
|
14
14
|
const i = {};
|
|
15
|
-
for (const o of
|
|
15
|
+
for (const o of a)
|
|
16
16
|
i[o] = o;
|
|
17
17
|
return i;
|
|
18
|
-
}, n.getValidEnumValues = (
|
|
19
|
-
const i = n.objectKeys(
|
|
18
|
+
}, n.getValidEnumValues = (a) => {
|
|
19
|
+
const i = n.objectKeys(a).filter((c) => typeof a[a[c]] != "number"), o = {};
|
|
20
20
|
for (const c of i)
|
|
21
|
-
o[c] =
|
|
21
|
+
o[c] = a[c];
|
|
22
22
|
return n.objectValues(o);
|
|
23
|
-
}, n.objectValues = (
|
|
24
|
-
return
|
|
25
|
-
}), n.objectKeys = typeof Object.keys == "function" ? (
|
|
23
|
+
}, n.objectValues = (a) => n.objectKeys(a).map(function(i) {
|
|
24
|
+
return a[i];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
26
26
|
const i = [];
|
|
27
|
-
for (const o in
|
|
28
|
-
Object.prototype.hasOwnProperty.call(
|
|
27
|
+
for (const o in a)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(a, o) && i.push(o);
|
|
29
29
|
return i;
|
|
30
|
-
}, n.find = (
|
|
31
|
-
for (const o of
|
|
30
|
+
}, n.find = (a, i) => {
|
|
31
|
+
for (const o of a)
|
|
32
32
|
if (i(o))
|
|
33
33
|
return o;
|
|
34
|
-
}, n.isInteger = typeof Number.isInteger == "function" ? (
|
|
35
|
-
function r(
|
|
36
|
-
return
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && isFinite(a) && Math.floor(a) === a;
|
|
35
|
+
function r(a, i = " | ") {
|
|
36
|
+
return a.map((o) => typeof o == "string" ? `'${o}'` : o).join(i);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues = r, n.jsonStringifyReplacer = (
|
|
38
|
+
n.joinValues = r, n.jsonStringifyReplacer = (a, i) => typeof i == "bigint" ? i.toString() : i;
|
|
39
39
|
})(x || (x = {}));
|
|
40
|
-
var
|
|
40
|
+
var Ze;
|
|
41
41
|
(function(n) {
|
|
42
42
|
n.mergeShapes = (e, t) => ({
|
|
43
43
|
...e,
|
|
44
44
|
...t
|
|
45
45
|
// second overwrites first
|
|
46
46
|
});
|
|
47
|
-
})(
|
|
47
|
+
})(Ze || (Ze = {}));
|
|
48
48
|
const p = x.arrayToEnum([
|
|
49
49
|
"string",
|
|
50
50
|
"nan",
|
|
@@ -121,14 +121,14 @@ class N extends Error {
|
|
|
121
121
|
format(e) {
|
|
122
122
|
const t = e || function(i) {
|
|
123
123
|
return i.message;
|
|
124
|
-
}, r = { _errors: [] },
|
|
124
|
+
}, r = { _errors: [] }, a = (i) => {
|
|
125
125
|
for (const o of i.issues)
|
|
126
126
|
if (o.code === "invalid_union")
|
|
127
|
-
o.unionErrors.map(
|
|
127
|
+
o.unionErrors.map(a);
|
|
128
128
|
else if (o.code === "invalid_return_type")
|
|
129
|
-
|
|
129
|
+
a(o.returnTypeError);
|
|
130
130
|
else if (o.code === "invalid_arguments")
|
|
131
|
-
|
|
131
|
+
a(o.argumentsError);
|
|
132
132
|
else if (o.path.length === 0)
|
|
133
133
|
r._errors.push(t(o));
|
|
134
134
|
else {
|
|
@@ -139,7 +139,7 @@ class N extends Error {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return a(this), r;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
145
|
if (!(e instanceof N))
|
|
@@ -156,8 +156,8 @@ class N extends Error {
|
|
|
156
156
|
}
|
|
157
157
|
flatten(e = (t) => t.message) {
|
|
158
158
|
const t = {}, r = [];
|
|
159
|
-
for (const
|
|
160
|
-
|
|
159
|
+
for (const a of this.issues)
|
|
160
|
+
a.path.length > 0 ? (t[a.path[0]] = t[a.path[0]] || [], t[a.path[0]].push(e(a))) : r.push(e(a));
|
|
161
161
|
return { formErrors: r, fieldErrors: t };
|
|
162
162
|
}
|
|
163
163
|
get formErrors() {
|
|
@@ -229,22 +229,22 @@ function ve() {
|
|
|
229
229
|
return Le;
|
|
230
230
|
}
|
|
231
231
|
const _e = (n) => {
|
|
232
|
-
const { data: e, path: t, errorMaps: r, issueData:
|
|
233
|
-
...
|
|
232
|
+
const { data: e, path: t, errorMaps: r, issueData: a } = n, i = [...t, ...a.path || []], o = {
|
|
233
|
+
...a,
|
|
234
234
|
path: i
|
|
235
235
|
};
|
|
236
|
-
if (
|
|
236
|
+
if (a.message !== void 0)
|
|
237
237
|
return {
|
|
238
|
-
...
|
|
238
|
+
...a,
|
|
239
239
|
path: i,
|
|
240
|
-
message:
|
|
240
|
+
message: a.message
|
|
241
241
|
};
|
|
242
242
|
let c = "";
|
|
243
243
|
const l = r.filter((u) => !!u).slice().reverse();
|
|
244
244
|
for (const u of l)
|
|
245
245
|
c = u(o, { data: e, defaultError: c }).message;
|
|
246
246
|
return {
|
|
247
|
-
...
|
|
247
|
+
...a,
|
|
248
248
|
path: i,
|
|
249
249
|
message: c
|
|
250
250
|
};
|
|
@@ -263,7 +263,7 @@ function m(n, e) {
|
|
|
263
263
|
// then global override map
|
|
264
264
|
t === G ? void 0 : G
|
|
265
265
|
// then global default map
|
|
266
|
-
].filter((
|
|
266
|
+
].filter((a) => !!a)
|
|
267
267
|
});
|
|
268
268
|
n.common.issues.push(r);
|
|
269
269
|
}
|
|
@@ -279,17 +279,17 @@ class T {
|
|
|
279
279
|
}
|
|
280
280
|
static mergeArray(e, t) {
|
|
281
281
|
const r = [];
|
|
282
|
-
for (const
|
|
283
|
-
if (
|
|
282
|
+
for (const a of t) {
|
|
283
|
+
if (a.status === "aborted")
|
|
284
284
|
return y;
|
|
285
|
-
|
|
285
|
+
a.status === "dirty" && e.dirty(), r.push(a.value);
|
|
286
286
|
}
|
|
287
287
|
return { status: e.value, value: r };
|
|
288
288
|
}
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
290
|
const r = [];
|
|
291
|
-
for (const
|
|
292
|
-
const i = await
|
|
291
|
+
for (const a of t) {
|
|
292
|
+
const i = await a.key, o = await a.value;
|
|
293
293
|
r.push({
|
|
294
294
|
key: i,
|
|
295
295
|
value: o
|
|
@@ -299,23 +299,23 @@ class T {
|
|
|
299
299
|
}
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
301
|
const r = {};
|
|
302
|
-
for (const
|
|
303
|
-
const { key: i, value: o } =
|
|
302
|
+
for (const a of t) {
|
|
303
|
+
const { key: i, value: o } = a;
|
|
304
304
|
if (i.status === "aborted" || o.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
i.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof o.value < "u" ||
|
|
306
|
+
i.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof o.value < "u" || a.alwaysSet) && (r[i.value] = o.value);
|
|
307
307
|
}
|
|
308
308
|
return { status: e.value, value: r };
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
const y = Object.freeze({
|
|
312
312
|
status: "aborted"
|
|
313
|
-
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }),
|
|
313
|
+
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }), De = (n) => n.status === "aborted", Oe = (n) => n.status === "dirty", q = (n) => n.status === "valid", se = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
314
314
|
function be(n, e, t, r) {
|
|
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, r,
|
|
318
|
+
function qe(n, e, t, r, a) {
|
|
319
319
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
320
320
|
return e.set(n, t), t;
|
|
321
321
|
}
|
|
@@ -324,15 +324,15 @@ var h;
|
|
|
324
324
|
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
325
325
|
})(h || (h = {}));
|
|
326
326
|
var te, ne;
|
|
327
|
-
class
|
|
328
|
-
constructor(e, t, r,
|
|
329
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key =
|
|
327
|
+
class O {
|
|
328
|
+
constructor(e, t, r, a) {
|
|
329
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = a;
|
|
330
330
|
}
|
|
331
331
|
get path() {
|
|
332
332
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
335
|
+
const Me = (n, e) => {
|
|
336
336
|
if (q(e))
|
|
337
337
|
return { success: !0, data: e.value };
|
|
338
338
|
if (!n.common.issues.length)
|
|
@@ -350,14 +350,14 @@ const $e = (n, e) => {
|
|
|
350
350
|
function v(n) {
|
|
351
351
|
if (!n)
|
|
352
352
|
return {};
|
|
353
|
-
const { errorMap: e, invalid_type_error: t, required_error: r, description:
|
|
353
|
+
const { errorMap: e, invalid_type_error: t, required_error: r, description: a } = n;
|
|
354
354
|
if (e && (t || r))
|
|
355
355
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
356
|
-
return e ? { errorMap: e, description:
|
|
356
|
+
return e ? { errorMap: e, description: a } : { errorMap: (o, c) => {
|
|
357
357
|
var l, u;
|
|
358
358
|
const { message: f } = n;
|
|
359
359
|
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (l = f ?? r) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (u = f ?? t) !== null && u !== void 0 ? u : c.defaultError };
|
|
360
|
-
}, description:
|
|
360
|
+
}, description: a };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
363
363
|
get description() {
|
|
@@ -407,7 +407,7 @@ class _ {
|
|
|
407
407
|
}
|
|
408
408
|
safeParse(e, t) {
|
|
409
409
|
var r;
|
|
410
|
-
const
|
|
410
|
+
const a = {
|
|
411
411
|
common: {
|
|
412
412
|
issues: [],
|
|
413
413
|
async: (r = t == null ? void 0 : t.async) !== null && r !== void 0 ? r : !1,
|
|
@@ -418,12 +418,12 @@ class _ {
|
|
|
418
418
|
parent: null,
|
|
419
419
|
data: e,
|
|
420
420
|
parsedType: R(e)
|
|
421
|
-
}, i = this._parseSync({ data: e, path:
|
|
422
|
-
return
|
|
421
|
+
}, i = this._parseSync({ data: e, path: a.path, parent: a });
|
|
422
|
+
return Me(a, i);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
425
|
var t, r;
|
|
426
|
-
const
|
|
426
|
+
const a = {
|
|
427
427
|
common: {
|
|
428
428
|
issues: [],
|
|
429
429
|
async: !!this["~standard"].async
|
|
@@ -436,22 +436,22 @@ class _ {
|
|
|
436
436
|
};
|
|
437
437
|
if (!this["~standard"].async)
|
|
438
438
|
try {
|
|
439
|
-
const i = this._parseSync({ data: e, path: [], parent:
|
|
439
|
+
const i = this._parseSync({ data: e, path: [], parent: a });
|
|
440
440
|
return q(i) ? {
|
|
441
441
|
value: i.value
|
|
442
442
|
} : {
|
|
443
|
-
issues:
|
|
443
|
+
issues: a.common.issues
|
|
444
444
|
};
|
|
445
445
|
} catch (i) {
|
|
446
|
-
!((r = (t = i == null ? void 0 : i.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || r === void 0) && r.includes("encountered") && (this["~standard"].async = !0),
|
|
446
|
+
!((r = (t = i == null ? void 0 : i.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || r === void 0) && r.includes("encountered") && (this["~standard"].async = !0), a.common = {
|
|
447
447
|
issues: [],
|
|
448
448
|
async: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
451
|
+
return this._parseAsync({ data: e, path: [], parent: a }).then((i) => q(i) ? {
|
|
452
452
|
value: i.value
|
|
453
453
|
} : {
|
|
454
|
-
issues:
|
|
454
|
+
issues: a.common.issues
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
async parseAsync(e, t) {
|
|
@@ -472,24 +472,24 @@ class _ {
|
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
474
|
parsedType: R(e)
|
|
475
|
-
},
|
|
476
|
-
return
|
|
475
|
+
}, a = this._parse({ data: e, path: r.path, parent: r }), i = await (se(a) ? a : Promise.resolve(a));
|
|
476
|
+
return Me(r, i);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
|
-
const r = (
|
|
480
|
-
return this._refinement((
|
|
481
|
-
const o = e(
|
|
479
|
+
const r = (a) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(a) : t;
|
|
480
|
+
return this._refinement((a, i) => {
|
|
481
|
+
const o = e(a), c = () => i.addIssue({
|
|
482
482
|
code: d.custom,
|
|
483
|
-
...r(
|
|
483
|
+
...r(a)
|
|
484
484
|
});
|
|
485
485
|
return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
refinement(e, t) {
|
|
489
|
-
return this._refinement((r,
|
|
489
|
+
return this._refinement((r, a) => e(r) ? !0 : (a.addIssue(typeof t == "function" ? t(r, a) : t), !1));
|
|
490
490
|
}
|
|
491
491
|
_refinement(e) {
|
|
492
|
-
return new
|
|
492
|
+
return new j({
|
|
493
493
|
schema: this,
|
|
494
494
|
typeName: g.ZodEffects,
|
|
495
495
|
effect: { type: "refinement", refinement: e }
|
|
@@ -506,7 +506,7 @@ class _ {
|
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
optional() {
|
|
509
|
-
return
|
|
509
|
+
return D.create(this, this._def);
|
|
510
510
|
}
|
|
511
511
|
nullable() {
|
|
512
512
|
return U.create(this, this._def);
|
|
@@ -527,7 +527,7 @@ class _ {
|
|
|
527
527
|
return ue.create(this, e, this._def);
|
|
528
528
|
}
|
|
529
529
|
transform(e) {
|
|
530
|
-
return new
|
|
530
|
+
return new j({
|
|
531
531
|
...v(this._def),
|
|
532
532
|
schema: this,
|
|
533
533
|
typeName: g.ZodEffects,
|
|
@@ -580,13 +580,13 @@ class _ {
|
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
const ft = /^c[^\s-]{8,}$/i, ht = /^[0-9a-z]+$/, gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, yt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, vt = /^[a-z0-9_-]{21}$/i, _t = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, bt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, xt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
|
-
let
|
|
583
|
+
let je;
|
|
584
584
|
const wt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Tt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, St = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, It = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Nt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, At = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Be = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Ct = new RegExp(`^${Be}$`);
|
|
585
585
|
function We(n) {
|
|
586
586
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
587
587
|
return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function jt(n) {
|
|
590
590
|
return new RegExp(`^${We(n)}$`);
|
|
591
591
|
}
|
|
592
592
|
function Qe(n) {
|
|
@@ -594,20 +594,20 @@ function Qe(n) {
|
|
|
594
594
|
const t = [];
|
|
595
595
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function Zt(n, e) {
|
|
598
598
|
return !!((e === "v4" || !e) && wt.test(n) || (e === "v6" || !e) && St.test(n));
|
|
599
599
|
}
|
|
600
|
-
function
|
|
600
|
+
function Dt(n, e) {
|
|
601
601
|
if (!_t.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
|
-
const [t] = n.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="),
|
|
605
|
-
return !(typeof
|
|
604
|
+
const [t] = n.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), a = JSON.parse(atob(r));
|
|
605
|
+
return !(typeof a != "object" || a === null || !a.typ || !a.alg || e && a.alg !== e);
|
|
606
606
|
} catch {
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Ot(n, e) {
|
|
611
611
|
return !!((e === "v4" || !e) && Tt.test(n) || (e === "v6" || !e) && It.test(n));
|
|
612
612
|
}
|
|
613
613
|
class A extends _ {
|
|
@@ -621,10 +621,10 @@ class A extends _ {
|
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
623
|
const r = new T();
|
|
624
|
-
let
|
|
624
|
+
let a;
|
|
625
625
|
for (const i of this._def.checks)
|
|
626
626
|
if (i.kind === "min")
|
|
627
|
-
e.data.length < i.value && (
|
|
627
|
+
e.data.length < i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
628
628
|
code: d.too_small,
|
|
629
629
|
minimum: i.value,
|
|
630
630
|
type: "string",
|
|
@@ -633,7 +633,7 @@ class A extends _ {
|
|
|
633
633
|
message: i.message
|
|
634
634
|
}), r.dirty());
|
|
635
635
|
else if (i.kind === "max")
|
|
636
|
-
e.data.length > i.value && (
|
|
636
|
+
e.data.length > i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
637
637
|
code: d.too_big,
|
|
638
638
|
maximum: i.value,
|
|
639
639
|
type: "string",
|
|
@@ -643,14 +643,14 @@ class A extends _ {
|
|
|
643
643
|
}), r.dirty());
|
|
644
644
|
else if (i.kind === "length") {
|
|
645
645
|
const o = e.data.length > i.value, c = e.data.length < i.value;
|
|
646
|
-
(o || c) && (
|
|
646
|
+
(o || c) && (a = this._getOrReturnCtx(e, a), o ? m(a, {
|
|
647
647
|
code: d.too_big,
|
|
648
648
|
maximum: i.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
652
|
message: i.message
|
|
653
|
-
}) : c && m(
|
|
653
|
+
}) : c && m(a, {
|
|
654
654
|
code: d.too_small,
|
|
655
655
|
minimum: i.value,
|
|
656
656
|
type: "string",
|
|
@@ -659,43 +659,43 @@ class A extends _ {
|
|
|
659
659
|
message: i.message
|
|
660
660
|
}), r.dirty());
|
|
661
661
|
} else if (i.kind === "email")
|
|
662
|
-
xt.test(e.data) || (
|
|
662
|
+
xt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
663
663
|
validation: "email",
|
|
664
664
|
code: d.invalid_string,
|
|
665
665
|
message: i.message
|
|
666
666
|
}), r.dirty());
|
|
667
667
|
else if (i.kind === "emoji")
|
|
668
|
-
|
|
668
|
+
je || (je = new RegExp(kt, "u")), je.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
669
669
|
validation: "emoji",
|
|
670
670
|
code: d.invalid_string,
|
|
671
671
|
message: i.message
|
|
672
672
|
}), r.dirty());
|
|
673
673
|
else if (i.kind === "uuid")
|
|
674
|
-
yt.test(e.data) || (
|
|
674
|
+
yt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
675
675
|
validation: "uuid",
|
|
676
676
|
code: d.invalid_string,
|
|
677
677
|
message: i.message
|
|
678
678
|
}), r.dirty());
|
|
679
679
|
else if (i.kind === "nanoid")
|
|
680
|
-
vt.test(e.data) || (
|
|
680
|
+
vt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
681
681
|
validation: "nanoid",
|
|
682
682
|
code: d.invalid_string,
|
|
683
683
|
message: i.message
|
|
684
684
|
}), r.dirty());
|
|
685
685
|
else if (i.kind === "cuid")
|
|
686
|
-
ft.test(e.data) || (
|
|
686
|
+
ft.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
687
687
|
validation: "cuid",
|
|
688
688
|
code: d.invalid_string,
|
|
689
689
|
message: i.message
|
|
690
690
|
}), r.dirty());
|
|
691
691
|
else if (i.kind === "cuid2")
|
|
692
|
-
ht.test(e.data) || (
|
|
692
|
+
ht.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
693
693
|
validation: "cuid2",
|
|
694
694
|
code: d.invalid_string,
|
|
695
695
|
message: i.message
|
|
696
696
|
}), r.dirty());
|
|
697
697
|
else if (i.kind === "ulid")
|
|
698
|
-
gt.test(e.data) || (
|
|
698
|
+
gt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
699
699
|
validation: "ulid",
|
|
700
700
|
code: d.invalid_string,
|
|
701
701
|
message: i.message
|
|
@@ -704,61 +704,61 @@ class A extends _ {
|
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
a = this._getOrReturnCtx(e, a), m(a, {
|
|
708
708
|
validation: "url",
|
|
709
709
|
code: d.invalid_string,
|
|
710
710
|
message: i.message
|
|
711
711
|
}), r.dirty();
|
|
712
712
|
}
|
|
713
|
-
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (
|
|
713
|
+
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
714
714
|
validation: "regex",
|
|
715
715
|
code: d.invalid_string,
|
|
716
716
|
message: i.message
|
|
717
|
-
}), r.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (
|
|
717
|
+
}), r.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
718
718
|
code: d.invalid_string,
|
|
719
719
|
validation: { includes: i.value, position: i.position },
|
|
720
720
|
message: i.message
|
|
721
|
-
}), r.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (
|
|
721
|
+
}), r.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
722
722
|
code: d.invalid_string,
|
|
723
723
|
validation: { startsWith: i.value },
|
|
724
724
|
message: i.message
|
|
725
|
-
}), r.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (
|
|
725
|
+
}), r.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
726
726
|
code: d.invalid_string,
|
|
727
727
|
validation: { endsWith: i.value },
|
|
728
728
|
message: i.message
|
|
729
|
-
}), r.dirty()) : i.kind === "datetime" ? Qe(i).test(e.data) || (
|
|
729
|
+
}), r.dirty()) : i.kind === "datetime" ? Qe(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
730
730
|
code: d.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
732
|
message: i.message
|
|
733
|
-
}), r.dirty()) : i.kind === "date" ? Ct.test(e.data) || (
|
|
733
|
+
}), r.dirty()) : i.kind === "date" ? Ct.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
734
734
|
code: d.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
736
|
message: i.message
|
|
737
|
-
}), r.dirty()) : i.kind === "time" ?
|
|
737
|
+
}), r.dirty()) : i.kind === "time" ? jt(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
738
738
|
code: d.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
740
|
message: i.message
|
|
741
|
-
}), r.dirty()) : i.kind === "duration" ? bt.test(e.data) || (
|
|
741
|
+
}), r.dirty()) : i.kind === "duration" ? bt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
742
742
|
validation: "duration",
|
|
743
743
|
code: d.invalid_string,
|
|
744
744
|
message: i.message
|
|
745
|
-
}), r.dirty()) : i.kind === "ip" ?
|
|
745
|
+
}), r.dirty()) : i.kind === "ip" ? Zt(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
746
746
|
validation: "ip",
|
|
747
747
|
code: d.invalid_string,
|
|
748
748
|
message: i.message
|
|
749
|
-
}), r.dirty()) : i.kind === "jwt" ?
|
|
749
|
+
}), r.dirty()) : i.kind === "jwt" ? Dt(e.data, i.alg) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
750
750
|
validation: "jwt",
|
|
751
751
|
code: d.invalid_string,
|
|
752
752
|
message: i.message
|
|
753
|
-
}), r.dirty()) : i.kind === "cidr" ?
|
|
753
|
+
}), r.dirty()) : i.kind === "cidr" ? Ot(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
754
754
|
validation: "cidr",
|
|
755
755
|
code: d.invalid_string,
|
|
756
756
|
message: i.message
|
|
757
|
-
}), r.dirty()) : i.kind === "base64" ? Nt.test(e.data) || (
|
|
757
|
+
}), r.dirty()) : i.kind === "base64" ? Nt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
758
758
|
validation: "base64",
|
|
759
759
|
code: d.invalid_string,
|
|
760
760
|
message: i.message
|
|
761
|
-
}), r.dirty()) : i.kind === "base64url" ? At.test(e.data) || (
|
|
761
|
+
}), r.dirty()) : i.kind === "base64url" ? At.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
762
762
|
validation: "base64url",
|
|
763
763
|
code: d.invalid_string,
|
|
764
764
|
message: i.message
|
|
@@ -766,7 +766,7 @@ class A extends _ {
|
|
|
766
766
|
return { status: r.value, value: e.data };
|
|
767
767
|
}
|
|
768
768
|
_regex(e, t, r) {
|
|
769
|
-
return this.refinement((
|
|
769
|
+
return this.refinement((a) => e.test(a), {
|
|
770
770
|
validation: t,
|
|
771
771
|
code: d.invalid_string,
|
|
772
772
|
...h.errToObj(r)
|
|
@@ -998,8 +998,8 @@ A.create = (n) => {
|
|
|
998
998
|
});
|
|
999
999
|
};
|
|
1000
1000
|
function Pt(n, e) {
|
|
1001
|
-
const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length,
|
|
1002
|
-
return i % o / Math.pow(10,
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, a = t > r ? t : r, i = parseInt(n.toFixed(a).replace(".", "")), o = parseInt(e.toFixed(a).replace(".", ""));
|
|
1002
|
+
return i % o / Math.pow(10, a);
|
|
1003
1003
|
}
|
|
1004
1004
|
class V extends _ {
|
|
1005
1005
|
constructor() {
|
|
@@ -1015,36 +1015,36 @@ class V extends _ {
|
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
1017
|
let r;
|
|
1018
|
-
const
|
|
1018
|
+
const a = new T();
|
|
1019
1019
|
for (const i of this._def.checks)
|
|
1020
1020
|
i.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1021
1021
|
code: d.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
1024
|
message: i.message
|
|
1025
|
-
}),
|
|
1025
|
+
}), a.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1026
1026
|
code: d.too_small,
|
|
1027
1027
|
minimum: i.value,
|
|
1028
1028
|
type: "number",
|
|
1029
1029
|
inclusive: i.inclusive,
|
|
1030
1030
|
exact: !1,
|
|
1031
1031
|
message: i.message
|
|
1032
|
-
}),
|
|
1032
|
+
}), a.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1033
1033
|
code: d.too_big,
|
|
1034
1034
|
maximum: i.value,
|
|
1035
1035
|
type: "number",
|
|
1036
1036
|
inclusive: i.inclusive,
|
|
1037
1037
|
exact: !1,
|
|
1038
1038
|
message: i.message
|
|
1039
|
-
}),
|
|
1039
|
+
}), a.dirty()) : i.kind === "multipleOf" ? Pt(e.data, i.value) !== 0 && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1040
1040
|
code: d.not_multiple_of,
|
|
1041
1041
|
multipleOf: i.value,
|
|
1042
1042
|
message: i.message
|
|
1043
|
-
}),
|
|
1043
|
+
}), a.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1044
1044
|
code: d.not_finite,
|
|
1045
1045
|
message: i.message
|
|
1046
|
-
}),
|
|
1047
|
-
return { status:
|
|
1046
|
+
}), a.dirty()) : x.assertNever(i);
|
|
1047
|
+
return { status: a.value, value: e.data };
|
|
1048
1048
|
}
|
|
1049
1049
|
gte(e, t) {
|
|
1050
1050
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -1058,7 +1058,7 @@ class V extends _ {
|
|
|
1058
1058
|
lt(e, t) {
|
|
1059
1059
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1060
1060
|
}
|
|
1061
|
-
setLimit(e, t, r,
|
|
1061
|
+
setLimit(e, t, r, a) {
|
|
1062
1062
|
return new V({
|
|
1063
1063
|
...this._def,
|
|
1064
1064
|
checks: [
|
|
@@ -1067,7 +1067,7 @@ class V extends _ {
|
|
|
1067
1067
|
kind: e,
|
|
1068
1068
|
value: t,
|
|
1069
1069
|
inclusive: r,
|
|
1070
|
-
message: h.toString(
|
|
1070
|
+
message: h.toString(a)
|
|
1071
1071
|
}
|
|
1072
1072
|
]
|
|
1073
1073
|
});
|
|
@@ -1187,7 +1187,7 @@ class z extends _ {
|
|
|
1187
1187
|
if (this._getType(e) !== p.bigint)
|
|
1188
1188
|
return this._getInvalidInput(e);
|
|
1189
1189
|
let r;
|
|
1190
|
-
const
|
|
1190
|
+
const a = new T();
|
|
1191
1191
|
for (const i of this._def.checks)
|
|
1192
1192
|
i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1193
1193
|
code: d.too_small,
|
|
@@ -1195,18 +1195,18 @@ class z extends _ {
|
|
|
1195
1195
|
minimum: i.value,
|
|
1196
1196
|
inclusive: i.inclusive,
|
|
1197
1197
|
message: i.message
|
|
1198
|
-
}),
|
|
1198
|
+
}), a.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1199
1199
|
code: d.too_big,
|
|
1200
1200
|
type: "bigint",
|
|
1201
1201
|
maximum: i.value,
|
|
1202
1202
|
inclusive: i.inclusive,
|
|
1203
1203
|
message: i.message
|
|
1204
|
-
}),
|
|
1204
|
+
}), a.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1205
1205
|
code: d.not_multiple_of,
|
|
1206
1206
|
multipleOf: i.value,
|
|
1207
1207
|
message: i.message
|
|
1208
|
-
}),
|
|
1209
|
-
return { status:
|
|
1208
|
+
}), a.dirty()) : x.assertNever(i);
|
|
1209
|
+
return { status: a.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, r,
|
|
1231
|
+
setLimit(e, t, r, a) {
|
|
1232
1232
|
return new z({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
@@ -1237,7 +1237,7 @@ class z extends _ {
|
|
|
1237
1237
|
kind: e,
|
|
1238
1238
|
value: t,
|
|
1239
1239
|
inclusive: r,
|
|
1240
|
-
message: h.toString(
|
|
1240
|
+
message: h.toString(a)
|
|
1241
1241
|
}
|
|
1242
1242
|
]
|
|
1243
1243
|
});
|
|
@@ -1344,16 +1344,16 @@ class B extends _ {
|
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
1346
|
const r = new T();
|
|
1347
|
-
let
|
|
1347
|
+
let a;
|
|
1348
1348
|
for (const i of this._def.checks)
|
|
1349
|
-
i.kind === "min" ? e.data.getTime() < i.value && (
|
|
1349
|
+
i.kind === "min" ? e.data.getTime() < i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1350
1350
|
code: d.too_small,
|
|
1351
1351
|
message: i.message,
|
|
1352
1352
|
inclusive: !0,
|
|
1353
1353
|
exact: !1,
|
|
1354
1354
|
minimum: i.value,
|
|
1355
1355
|
type: "date"
|
|
1356
|
-
}), r.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (
|
|
1356
|
+
}), r.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1357
1357
|
code: d.too_big,
|
|
1358
1358
|
message: i.message,
|
|
1359
1359
|
inclusive: !0,
|
|
@@ -1480,7 +1480,7 @@ L.create = (n) => new L({
|
|
|
1480
1480
|
typeName: g.ZodUnknown,
|
|
1481
1481
|
...v(n)
|
|
1482
1482
|
});
|
|
1483
|
-
class
|
|
1483
|
+
class M extends _ {
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
const t = this._getOrReturnCtx(e);
|
|
1486
1486
|
return m(t, {
|
|
@@ -1490,7 +1490,7 @@ class $ extends _ {
|
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
|
-
|
|
1493
|
+
M.create = (n) => new M({
|
|
1494
1494
|
typeName: g.ZodNever,
|
|
1495
1495
|
...v(n)
|
|
1496
1496
|
});
|
|
@@ -1513,42 +1513,42 @@ ke.create = (n) => new ke({
|
|
|
1513
1513
|
});
|
|
1514
1514
|
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
|
-
const { ctx: t, status: r } = this._processInputParams(e),
|
|
1516
|
+
const { ctx: t, status: r } = this._processInputParams(e), a = this._def;
|
|
1517
1517
|
if (t.parsedType !== p.array)
|
|
1518
1518
|
return m(t, {
|
|
1519
1519
|
code: d.invalid_type,
|
|
1520
1520
|
expected: p.array,
|
|
1521
1521
|
received: t.parsedType
|
|
1522
1522
|
}), y;
|
|
1523
|
-
if (
|
|
1524
|
-
const o = t.data.length >
|
|
1523
|
+
if (a.exactLength !== null) {
|
|
1524
|
+
const o = t.data.length > a.exactLength.value, c = t.data.length < a.exactLength.value;
|
|
1525
1525
|
(o || c) && (m(t, {
|
|
1526
1526
|
code: o ? d.too_big : d.too_small,
|
|
1527
|
-
minimum: c ?
|
|
1528
|
-
maximum: o ?
|
|
1527
|
+
minimum: c ? a.exactLength.value : void 0,
|
|
1528
|
+
maximum: o ? a.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
1530
1530
|
inclusive: !0,
|
|
1531
1531
|
exact: !0,
|
|
1532
|
-
message:
|
|
1532
|
+
message: a.exactLength.message
|
|
1533
1533
|
}), r.dirty());
|
|
1534
1534
|
}
|
|
1535
|
-
if (
|
|
1535
|
+
if (a.minLength !== null && t.data.length < a.minLength.value && (m(t, {
|
|
1536
1536
|
code: d.too_small,
|
|
1537
|
-
minimum:
|
|
1537
|
+
minimum: a.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
|
-
message:
|
|
1542
|
-
}), r.dirty()),
|
|
1541
|
+
message: a.minLength.message
|
|
1542
|
+
}), r.dirty()), a.maxLength !== null && t.data.length > a.maxLength.value && (m(t, {
|
|
1543
1543
|
code: d.too_big,
|
|
1544
|
-
maximum:
|
|
1544
|
+
maximum: a.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
1547
1547
|
exact: !1,
|
|
1548
|
-
message:
|
|
1548
|
+
message: a.maxLength.message
|
|
1549
1549
|
}), r.dirty()), t.common.async)
|
|
1550
|
-
return Promise.all([...t.data].map((o, c) =>
|
|
1551
|
-
const i = [...t.data].map((o, c) =>
|
|
1550
|
+
return Promise.all([...t.data].map((o, c) => a.type._parseAsync(new O(t, o, t.path, c)))).then((o) => T.mergeArray(r, o));
|
|
1551
|
+
const i = [...t.data].map((o, c) => a.type._parseSync(new O(t, o, t.path, c)));
|
|
1552
1552
|
return T.mergeArray(r, i);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
@@ -1589,7 +1589,7 @@ function Q(n) {
|
|
|
1589
1589
|
const e = {};
|
|
1590
1590
|
for (const t in n.shape) {
|
|
1591
1591
|
const r = n.shape[t];
|
|
1592
|
-
e[t] =
|
|
1592
|
+
e[t] = D.create(Q(r));
|
|
1593
1593
|
}
|
|
1594
1594
|
return new k({
|
|
1595
1595
|
...n._def,
|
|
@@ -1598,7 +1598,7 @@ function Q(n) {
|
|
|
1598
1598
|
} else return n instanceof C ? new C({
|
|
1599
1599
|
...n._def,
|
|
1600
1600
|
type: Q(n.element)
|
|
1601
|
-
}) : n instanceof
|
|
1601
|
+
}) : n instanceof D ? D.create(Q(n.unwrap())) : n instanceof U ? U.create(Q(n.unwrap())) : n instanceof P ? P.create(n.items.map((e) => Q(e))) : n;
|
|
1602
1602
|
}
|
|
1603
1603
|
class k extends _ {
|
|
1604
1604
|
constructor() {
|
|
@@ -1619,29 +1619,29 @@ class k extends _ {
|
|
|
1619
1619
|
received: u.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status: r, ctx:
|
|
1623
|
-
if (!(this._def.catchall instanceof
|
|
1624
|
-
for (const u in
|
|
1622
|
+
const { status: r, ctx: a } = this._processInputParams(e), { shape: i, keys: o } = this._getCached(), c = [];
|
|
1623
|
+
if (!(this._def.catchall instanceof M && this._def.unknownKeys === "strip"))
|
|
1624
|
+
for (const u in a.data)
|
|
1625
1625
|
o.includes(u) || c.push(u);
|
|
1626
1626
|
const l = [];
|
|
1627
1627
|
for (const u of o) {
|
|
1628
|
-
const f = i[u], b =
|
|
1628
|
+
const f = i[u], b = a.data[u];
|
|
1629
1629
|
l.push({
|
|
1630
1630
|
key: { status: "valid", value: u },
|
|
1631
|
-
value: f._parse(new
|
|
1632
|
-
alwaysSet: u in
|
|
1631
|
+
value: f._parse(new O(a, b, a.path, u)),
|
|
1632
|
+
alwaysSet: u in a.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
|
-
if (this._def.catchall instanceof
|
|
1635
|
+
if (this._def.catchall instanceof M) {
|
|
1636
1636
|
const u = this._def.unknownKeys;
|
|
1637
1637
|
if (u === "passthrough")
|
|
1638
1638
|
for (const f of c)
|
|
1639
1639
|
l.push({
|
|
1640
1640
|
key: { status: "valid", value: f },
|
|
1641
|
-
value: { status: "valid", value:
|
|
1641
|
+
value: { status: "valid", value: a.data[f] }
|
|
1642
1642
|
});
|
|
1643
1643
|
else if (u === "strict")
|
|
1644
|
-
c.length > 0 && (m(
|
|
1644
|
+
c.length > 0 && (m(a, {
|
|
1645
1645
|
code: d.unrecognized_keys,
|
|
1646
1646
|
keys: c
|
|
1647
1647
|
}), r.dirty());
|
|
@@ -1649,18 +1649,18 @@ class k extends _ {
|
|
|
1649
1649
|
} else {
|
|
1650
1650
|
const u = this._def.catchall;
|
|
1651
1651
|
for (const f of c) {
|
|
1652
|
-
const b =
|
|
1652
|
+
const b = a.data[f];
|
|
1653
1653
|
l.push({
|
|
1654
1654
|
key: { status: "valid", value: f },
|
|
1655
1655
|
value: u._parse(
|
|
1656
|
-
new
|
|
1656
|
+
new O(a, b, a.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet: f in
|
|
1659
|
+
alwaysSet: f in a.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
-
return
|
|
1663
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
1664
1664
|
const u = [];
|
|
1665
1665
|
for (const f of l) {
|
|
1666
1666
|
const b = await f.key, w = await f.value;
|
|
@@ -1682,8 +1682,8 @@ class k extends _ {
|
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
1684
|
errorMap: (t, r) => {
|
|
1685
|
-
var
|
|
1686
|
-
const l = (o = (i = (
|
|
1685
|
+
var a, i, o, c;
|
|
1686
|
+
const l = (o = (i = (a = this._def).errorMap) === null || i === void 0 ? void 0 : i.call(a, t, r).message) !== null && o !== void 0 ? o : r.defaultError;
|
|
1687
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1688
1688
|
message: (c = h.errToObj(e).message) !== null && c !== void 0 ? c : l
|
|
1689
1689
|
} : {
|
|
@@ -1839,8 +1839,8 @@ class k extends _ {
|
|
|
1839
1839
|
partial(e) {
|
|
1840
1840
|
const t = {};
|
|
1841
1841
|
return x.objectKeys(this.shape).forEach((r) => {
|
|
1842
|
-
const
|
|
1843
|
-
e && !e[r] ? t[r] =
|
|
1842
|
+
const a = this.shape[r];
|
|
1843
|
+
e && !e[r] ? t[r] = a : t[r] = a.optional();
|
|
1844
1844
|
}), new k({
|
|
1845
1845
|
...this._def,
|
|
1846
1846
|
shape: () => t
|
|
@@ -1853,7 +1853,7 @@ class k extends _ {
|
|
|
1853
1853
|
t[r] = this.shape[r];
|
|
1854
1854
|
else {
|
|
1855
1855
|
let i = this.shape[r];
|
|
1856
|
-
for (; i instanceof
|
|
1856
|
+
for (; i instanceof D; )
|
|
1857
1857
|
i = i._def.innerType;
|
|
1858
1858
|
t[r] = i;
|
|
1859
1859
|
}
|
|
@@ -1869,28 +1869,28 @@ class k extends _ {
|
|
|
1869
1869
|
k.create = (n, e) => new k({
|
|
1870
1870
|
shape: () => n,
|
|
1871
1871
|
unknownKeys: "strip",
|
|
1872
|
-
catchall:
|
|
1872
|
+
catchall: M.create(),
|
|
1873
1873
|
typeName: g.ZodObject,
|
|
1874
1874
|
...v(e)
|
|
1875
1875
|
});
|
|
1876
1876
|
k.strictCreate = (n, e) => new k({
|
|
1877
1877
|
shape: () => n,
|
|
1878
1878
|
unknownKeys: "strict",
|
|
1879
|
-
catchall:
|
|
1879
|
+
catchall: M.create(),
|
|
1880
1880
|
typeName: g.ZodObject,
|
|
1881
1881
|
...v(e)
|
|
1882
1882
|
});
|
|
1883
1883
|
k.lazycreate = (n, e) => new k({
|
|
1884
1884
|
shape: n,
|
|
1885
1885
|
unknownKeys: "strip",
|
|
1886
|
-
catchall:
|
|
1886
|
+
catchall: M.create(),
|
|
1887
1887
|
typeName: g.ZodObject,
|
|
1888
1888
|
...v(e)
|
|
1889
1889
|
});
|
|
1890
1890
|
class ce extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
1892
|
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1893
|
-
function
|
|
1893
|
+
function a(i) {
|
|
1894
1894
|
for (const c of i)
|
|
1895
1895
|
if (c.result.status === "valid")
|
|
1896
1896
|
return c.result;
|
|
@@ -1921,7 +1921,7 @@ class ce extends _ {
|
|
|
1921
1921
|
}),
|
|
1922
1922
|
ctx: o
|
|
1923
1923
|
};
|
|
1924
|
-
})).then(
|
|
1924
|
+
})).then(a);
|
|
1925
1925
|
{
|
|
1926
1926
|
let i;
|
|
1927
1927
|
const o = [];
|
|
@@ -1960,7 +1960,7 @@ ce.create = (n, e) => new ce({
|
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const E = (n) => n instanceof le ? E(n.schema) : n instanceof
|
|
1963
|
+
const E = (n) => n instanceof le ? E(n.schema) : n instanceof j ? E(n.innerType()) : n instanceof me ? [n.value] : n instanceof F ? n.options : n instanceof pe ? x.objectValues(n.enum) : n instanceof fe ? E(n._def.innerType) : n instanceof ie ? [void 0] : n instanceof oe ? [null] : n instanceof D ? [void 0, ...E(n.unwrap())] : n instanceof U ? [null, ...E(n.unwrap())] : n instanceof Ee || n instanceof ge ? E(n.unwrap()) : n instanceof he ? E(n._def.innerType) : [];
|
|
1964
1964
|
class Se extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
@@ -1970,7 +1970,7 @@ class Se extends _ {
|
|
|
1970
1970
|
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const r = this.discriminator,
|
|
1973
|
+
const r = this.discriminator, a = t.data[r], i = this.optionsMap.get(a);
|
|
1974
1974
|
return i ? t.common.async ? i._parseAsync({
|
|
1975
1975
|
data: t.data,
|
|
1976
1976
|
path: t.path,
|
|
@@ -2003,22 +2003,22 @@ class Se extends _ {
|
|
|
2003
2003
|
* @param params
|
|
2004
2004
|
*/
|
|
2005
2005
|
static create(e, t, r) {
|
|
2006
|
-
const
|
|
2006
|
+
const a = /* @__PURE__ */ new Map();
|
|
2007
2007
|
for (const i of t) {
|
|
2008
2008
|
const o = E(i.shape[e]);
|
|
2009
2009
|
if (!o.length)
|
|
2010
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2011
2011
|
for (const c of o) {
|
|
2012
|
-
if (
|
|
2012
|
+
if (a.has(c))
|
|
2013
2013
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
|
|
2014
|
-
|
|
2014
|
+
a.set(c, i);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
2017
|
return new Se({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
2021
|
-
optionsMap:
|
|
2021
|
+
optionsMap: a,
|
|
2022
2022
|
...v(r)
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
@@ -2028,7 +2028,7 @@ function Pe(n, e) {
|
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
2030
|
if (t === p.object && r === p.object) {
|
|
2031
|
-
const
|
|
2031
|
+
const a = x.objectKeys(e), i = x.objectKeys(n).filter((c) => a.indexOf(c) !== -1), o = { ...n, ...e };
|
|
2032
2032
|
for (const c of i) {
|
|
2033
2033
|
const l = Pe(n[c], e[c]);
|
|
2034
2034
|
if (!l.valid)
|
|
@@ -2039,23 +2039,23 @@ function Pe(n, e) {
|
|
|
2039
2039
|
} else if (t === p.array && r === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
|
-
const
|
|
2042
|
+
const a = [];
|
|
2043
2043
|
for (let i = 0; i < n.length; i++) {
|
|
2044
2044
|
const o = n[i], c = e[i], l = Pe(o, c);
|
|
2045
2045
|
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
|
-
|
|
2047
|
+
a.push(l.data);
|
|
2048
2048
|
}
|
|
2049
|
-
return { valid: !0, data:
|
|
2049
|
+
return { valid: !0, data: a };
|
|
2050
2050
|
} else return t === p.date && r === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
2052
|
class ue extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx: r } = this._processInputParams(e),
|
|
2055
|
-
if (
|
|
2054
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = (i, o) => {
|
|
2055
|
+
if (De(i) || De(o))
|
|
2056
2056
|
return y;
|
|
2057
2057
|
const c = Pe(i.value, o.value);
|
|
2058
|
-
return c.valid ? ((
|
|
2058
|
+
return c.valid ? ((Oe(i) || Oe(o)) && t.dirty(), { status: t.value, value: c.data }) : (m(r, {
|
|
2059
2059
|
code: d.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
@@ -2070,7 +2070,7 @@ class ue extends _ {
|
|
|
2070
2070
|
path: r.path,
|
|
2071
2071
|
parent: r
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([i, o]) =>
|
|
2073
|
+
]).then(([i, o]) => a(i, o)) : a(this._def.left._parseSync({
|
|
2074
2074
|
data: r.data,
|
|
2075
2075
|
path: r.path,
|
|
2076
2076
|
parent: r
|
|
@@ -2113,7 +2113,7 @@ class P extends _ {
|
|
|
2113
2113
|
}), t.dirty());
|
|
2114
2114
|
const i = [...r.data].map((o, c) => {
|
|
2115
2115
|
const l = this._def.items[c] || this._def.rest;
|
|
2116
|
-
return l ? l._parse(new
|
|
2116
|
+
return l ? l._parse(new O(r, o, r.path, c)) : null;
|
|
2117
2117
|
}).filter((o) => !!o);
|
|
2118
2118
|
return r.common.async ? Promise.all(i).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, i);
|
|
2119
2119
|
}
|
|
@@ -2152,14 +2152,14 @@ class de extends _ {
|
|
|
2152
2152
|
expected: p.object,
|
|
2153
2153
|
received: r.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const
|
|
2155
|
+
const a = [], i = this._def.keyType, o = this._def.valueType;
|
|
2156
2156
|
for (const c in r.data)
|
|
2157
|
-
|
|
2158
|
-
key: i._parse(new
|
|
2159
|
-
value: o._parse(new
|
|
2157
|
+
a.push({
|
|
2158
|
+
key: i._parse(new O(r, c, r.path, c)),
|
|
2159
|
+
value: o._parse(new O(r, r.data[c], r.path, c)),
|
|
2160
2160
|
alwaysSet: c in r.data
|
|
2161
2161
|
});
|
|
2162
|
-
return r.common.async ? T.mergeObjectAsync(t,
|
|
2162
|
+
return r.common.async ? T.mergeObjectAsync(t, a) : T.mergeObjectSync(t, a);
|
|
2163
2163
|
}
|
|
2164
2164
|
get element() {
|
|
2165
2165
|
return this._def.valueType;
|
|
@@ -2193,9 +2193,9 @@ class we extends _ {
|
|
|
2193
2193
|
expected: p.map,
|
|
2194
2194
|
received: r.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const
|
|
2197
|
-
key:
|
|
2198
|
-
value: i._parse(new
|
|
2196
|
+
const a = this._def.keyType, i = this._def.valueType, o = [...r.data.entries()].map(([c, l], u) => ({
|
|
2197
|
+
key: a._parse(new O(r, c, r.path, [u, "key"])),
|
|
2198
|
+
value: i._parse(new O(r, l, r.path, [u, "value"]))
|
|
2199
2199
|
}));
|
|
2200
2200
|
if (r.common.async) {
|
|
2201
2201
|
const c = /* @__PURE__ */ new Map();
|
|
@@ -2235,21 +2235,21 @@ class W extends _ {
|
|
|
2235
2235
|
expected: p.set,
|
|
2236
2236
|
received: r.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2238
|
+
const a = this._def;
|
|
2239
|
+
a.minSize !== null && r.data.size < a.minSize.value && (m(r, {
|
|
2240
2240
|
code: d.too_small,
|
|
2241
|
-
minimum:
|
|
2241
|
+
minimum: a.minSize.value,
|
|
2242
2242
|
type: "set",
|
|
2243
2243
|
inclusive: !0,
|
|
2244
2244
|
exact: !1,
|
|
2245
|
-
message:
|
|
2246
|
-
}), t.dirty()),
|
|
2245
|
+
message: a.minSize.message
|
|
2246
|
+
}), t.dirty()), a.maxSize !== null && r.data.size > a.maxSize.value && (m(r, {
|
|
2247
2247
|
code: d.too_big,
|
|
2248
|
-
maximum:
|
|
2248
|
+
maximum: a.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
|
-
message:
|
|
2252
|
+
message: a.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
2254
|
const i = this._def.valueType;
|
|
2255
2255
|
function o(l) {
|
|
@@ -2261,7 +2261,7 @@ class W extends _ {
|
|
|
2261
2261
|
}
|
|
2262
2262
|
return { status: t.value, value: u };
|
|
2263
2263
|
}
|
|
2264
|
-
const c = [...r.data.values()].map((l, u) => i._parse(new
|
|
2264
|
+
const c = [...r.data.values()].map((l, u) => i._parse(new O(r, l, r.path, u)));
|
|
2265
2265
|
return r.common.async ? Promise.all(c).then((l) => o(l)) : o(c);
|
|
2266
2266
|
}
|
|
2267
2267
|
min(e, t) {
|
|
@@ -2318,7 +2318,7 @@ class X extends _ {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
2320
2320
|
}
|
|
2321
|
-
function
|
|
2321
|
+
function a(c, l) {
|
|
2322
2322
|
return _e({
|
|
2323
2323
|
data: c,
|
|
2324
2324
|
path: t.path,
|
|
@@ -2342,7 +2342,7 @@ class X extends _ {
|
|
|
2342
2342
|
throw u.addIssue(r(l, I)), u;
|
|
2343
2343
|
}), b = await Reflect.apply(o, this, f);
|
|
2344
2344
|
return await c._def.returns._def.type.parseAsync(b, i).catch((I) => {
|
|
2345
|
-
throw u.addIssue(
|
|
2345
|
+
throw u.addIssue(a(b, I)), u;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
@@ -2353,7 +2353,7 @@ class X extends _ {
|
|
|
2353
2353
|
throw new N([r(l, u.error)]);
|
|
2354
2354
|
const f = Reflect.apply(o, this, u.data), b = c._def.returns.safeParse(f, i);
|
|
2355
2355
|
if (!b.success)
|
|
2356
|
-
throw new N([
|
|
2356
|
+
throw new N([a(f, b.error)]);
|
|
2357
2357
|
return b.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
@@ -2499,19 +2499,19 @@ class pe extends _ {
|
|
|
2499
2499
|
_parse(e) {
|
|
2500
2500
|
const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2501
2501
|
if (r.parsedType !== p.string && r.parsedType !== p.number) {
|
|
2502
|
-
const
|
|
2502
|
+
const a = x.objectValues(t);
|
|
2503
2503
|
return m(r, {
|
|
2504
|
-
expected: x.joinValues(
|
|
2504
|
+
expected: x.joinValues(a),
|
|
2505
2505
|
received: r.parsedType,
|
|
2506
2506
|
code: d.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
2509
|
if (be(this, ne) || qe(this, ne, new Set(x.getValidEnumValues(this._def.values))), !be(this, ne).has(e.data)) {
|
|
2510
|
-
const
|
|
2510
|
+
const a = x.objectValues(t);
|
|
2511
2511
|
return m(r, {
|
|
2512
2512
|
received: r.data,
|
|
2513
2513
|
code: d.invalid_enum_value,
|
|
2514
|
-
options:
|
|
2514
|
+
options: a
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
2517
|
return S(e.data);
|
|
@@ -2539,7 +2539,7 @@ class H extends _ {
|
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
2541
|
const r = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
-
return S(r.then((
|
|
2542
|
+
return S(r.then((a) => this._def.type.parseAsync(a, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
@@ -2550,7 +2550,7 @@ H.create = (n, e) => new H({
|
|
|
2550
2550
|
typeName: g.ZodPromise,
|
|
2551
2551
|
...v(e)
|
|
2552
2552
|
});
|
|
2553
|
-
class
|
|
2553
|
+
class j extends _ {
|
|
2554
2554
|
innerType() {
|
|
2555
2555
|
return this._def.schema;
|
|
2556
2556
|
}
|
|
@@ -2558,7 +2558,7 @@ class Z 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: r } = this._processInputParams(e),
|
|
2561
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = this._def.effect || null, i = {
|
|
2562
2562
|
addIssue: (o) => {
|
|
2563
2563
|
m(r, o), o.fatal ? t.abort() : t.dirty();
|
|
2564
2564
|
},
|
|
@@ -2566,8 +2566,8 @@ class Z extends _ {
|
|
|
2566
2566
|
return r.path;
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
|
-
if (i.addIssue = i.addIssue.bind(i),
|
|
2570
|
-
const o =
|
|
2569
|
+
if (i.addIssue = i.addIssue.bind(i), a.type === "preprocess") {
|
|
2570
|
+
const o = a.transform(r.data, i);
|
|
2571
2571
|
if (r.common.async)
|
|
2572
2572
|
return Promise.resolve(o).then(async (c) => {
|
|
2573
2573
|
if (t.value === "aborted")
|
|
@@ -2590,9 +2590,9 @@ class Z extends _ {
|
|
|
2590
2590
|
return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? Y(c.value) : c;
|
|
2591
2591
|
}
|
|
2592
2592
|
}
|
|
2593
|
-
if (
|
|
2593
|
+
if (a.type === "refinement") {
|
|
2594
2594
|
const o = (c) => {
|
|
2595
|
-
const l =
|
|
2595
|
+
const l = a.refinement(c, i);
|
|
2596
2596
|
if (r.common.async)
|
|
2597
2597
|
return Promise.resolve(l);
|
|
2598
2598
|
if (l instanceof Promise)
|
|
@@ -2609,7 +2609,7 @@ class Z extends _ {
|
|
|
2609
2609
|
} else
|
|
2610
2610
|
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((c) => c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value).then(() => ({ status: t.value, value: c.value }))));
|
|
2611
2611
|
}
|
|
2612
|
-
if (
|
|
2612
|
+
if (a.type === "transform")
|
|
2613
2613
|
if (r.common.async === !1) {
|
|
2614
2614
|
const o = this._def.schema._parseSync({
|
|
2615
2615
|
data: r.data,
|
|
@@ -2618,28 +2618,28 @@ class Z extends _ {
|
|
|
2618
2618
|
});
|
|
2619
2619
|
if (!q(o))
|
|
2620
2620
|
return o;
|
|
2621
|
-
const c =
|
|
2621
|
+
const c = a.transform(o.value, i);
|
|
2622
2622
|
if (c instanceof Promise)
|
|
2623
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2624
2624
|
return { status: t.value, value: c };
|
|
2625
2625
|
} else
|
|
2626
|
-
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => q(o) ? Promise.resolve(
|
|
2627
|
-
x.assertNever(
|
|
2626
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => q(o) ? Promise.resolve(a.transform(o.value, i)).then((c) => ({ status: t.value, value: c })) : o);
|
|
2627
|
+
x.assertNever(a);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
|
|
2630
|
+
j.create = (n, e, t) => new j({
|
|
2631
2631
|
schema: n,
|
|
2632
2632
|
typeName: g.ZodEffects,
|
|
2633
2633
|
effect: e,
|
|
2634
2634
|
...v(t)
|
|
2635
2635
|
});
|
|
2636
|
-
|
|
2636
|
+
j.createWithPreprocess = (n, e, t) => new j({
|
|
2637
2637
|
schema: e,
|
|
2638
2638
|
effect: { type: "preprocess", transform: n },
|
|
2639
2639
|
typeName: g.ZodEffects,
|
|
2640
2640
|
...v(t)
|
|
2641
2641
|
});
|
|
2642
|
-
class
|
|
2642
|
+
class D extends _ {
|
|
2643
2643
|
_parse(e) {
|
|
2644
2644
|
return this._getType(e) === p.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
2645
2645
|
}
|
|
@@ -2647,7 +2647,7 @@ class O extends _ {
|
|
|
2647
2647
|
return this._def.innerType;
|
|
2648
2648
|
}
|
|
2649
2649
|
}
|
|
2650
|
-
|
|
2650
|
+
D.create = (n, e) => new D({
|
|
2651
2651
|
innerType: n,
|
|
2652
2652
|
typeName: g.ZodOptional,
|
|
2653
2653
|
...v(e)
|
|
@@ -2693,14 +2693,14 @@ class he extends _ {
|
|
|
2693
2693
|
...t.common,
|
|
2694
2694
|
issues: []
|
|
2695
2695
|
}
|
|
2696
|
-
},
|
|
2696
|
+
}, a = this._def.innerType._parse({
|
|
2697
2697
|
data: r.data,
|
|
2698
2698
|
path: r.path,
|
|
2699
2699
|
parent: {
|
|
2700
2700
|
...r
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return se(
|
|
2703
|
+
return se(a) ? a.then((i) => ({
|
|
2704
2704
|
status: "valid",
|
|
2705
2705
|
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2706
2706
|
get error() {
|
|
@@ -2710,7 +2710,7 @@ class he extends _ {
|
|
|
2710
2710
|
})
|
|
2711
2711
|
})) : {
|
|
2712
2712
|
status: "valid",
|
|
2713
|
-
value:
|
|
2713
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
2715
|
return new N(r.common.issues);
|
|
2716
2716
|
},
|
|
@@ -2776,16 +2776,16 @@ class ye extends _ {
|
|
|
2776
2776
|
});
|
|
2777
2777
|
})();
|
|
2778
2778
|
{
|
|
2779
|
-
const
|
|
2779
|
+
const a = this._def.in._parseSync({
|
|
2780
2780
|
data: r.data,
|
|
2781
2781
|
path: r.path,
|
|
2782
2782
|
parent: r
|
|
2783
2783
|
});
|
|
2784
|
-
return
|
|
2784
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), {
|
|
2785
2785
|
status: "dirty",
|
|
2786
|
-
value:
|
|
2786
|
+
value: a.value
|
|
2787
2787
|
}) : this._def.out._parseSync({
|
|
2788
|
-
data:
|
|
2788
|
+
data: a.value,
|
|
2789
2789
|
path: r.path,
|
|
2790
2790
|
parent: r
|
|
2791
2791
|
});
|
|
@@ -2801,8 +2801,8 @@ class ye extends _ {
|
|
|
2801
2801
|
}
|
|
2802
2802
|
class ge extends _ {
|
|
2803
2803
|
_parse(e) {
|
|
2804
|
-
const t = this._def.innerType._parse(e), r = (
|
|
2805
|
-
return se(t) ? t.then((
|
|
2804
|
+
const t = this._def.innerType._parse(e), r = (a) => (q(a) && (a.value = Object.freeze(a.value)), a);
|
|
2805
|
+
return se(t) ? t.then((a) => r(a)) : r(t);
|
|
2806
2806
|
}
|
|
2807
2807
|
unwrap() {
|
|
2808
2808
|
return this._def.innerType;
|
|
@@ -2818,7 +2818,7 @@ function Ve(n, e) {
|
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
2820
|
function Xe(n, e = {}, t) {
|
|
2821
|
-
return n ? J.create().superRefine((r,
|
|
2821
|
+
return n ? J.create().superRefine((r, a) => {
|
|
2822
2822
|
var i, o;
|
|
2823
2823
|
const c = n(r);
|
|
2824
2824
|
if (c instanceof Promise)
|
|
@@ -2826,12 +2826,12 @@ function Xe(n, e = {}, t) {
|
|
|
2826
2826
|
var u, f;
|
|
2827
2827
|
if (!l) {
|
|
2828
2828
|
const b = Ve(e, r), w = (f = (u = b.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
|
|
2829
|
-
|
|
2829
|
+
a.addIssue({ code: "custom", ...b, fatal: w });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
2832
|
if (!c) {
|
|
2833
2833
|
const l = Ve(e, r), u = (o = (i = l.fatal) !== null && i !== void 0 ? i : t) !== null && o !== void 0 ? o : !0;
|
|
2834
|
-
|
|
2834
|
+
a.addIssue({ code: "custom", ...l, fatal: u });
|
|
2835
2835
|
}
|
|
2836
2836
|
}) : J.create();
|
|
2837
2837
|
}
|
|
@@ -2842,9 +2842,9 @@ var g;
|
|
|
2842
2842
|
(function(n) {
|
|
2843
2843
|
n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
|
|
2844
2844
|
})(g || (g = {}));
|
|
2845
|
-
const
|
|
2845
|
+
const $t = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) => Xe((t) => t instanceof n, e), Ge = A.create, Je = V.create,
|
|
2847
|
+
}) => Xe((t) => t instanceof n, e), Ge = A.create, Je = V.create, Mt = Te.create, Vt = z.create, He = ae.create, zt = B.create, Ft = xe.create, Ut = ie.create, Lt = oe.create, qt = J.create, Bt = L.create, Wt = M.create, Qt = ke.create, Yt = C.create, Xt = k.create, Gt = k.strictCreate, Jt = ce.create, Ht = Se.create, Kt = ue.create, en = P.create, tn = de.create, nn = we.create, rn = W.create, sn = X.create, an = le.create, on = me.create, cn = F.create, un = pe.create, dn = H.create, ze = j.create, ln = D.create, mn = U.create, pn = j.createWithPreprocess, fn = ye.create, hn = () => Ge().optional(), gn = () => Je().optional(), yn = () => He().optional(), vn = {
|
|
2848
2848
|
string: (n) => A.create({ ...n, coerce: !0 }),
|
|
2849
2849
|
number: (n) => V.create({ ...n, coerce: !0 }),
|
|
2850
2850
|
boolean: (n) => ae.create({
|
|
@@ -2854,7 +2854,7 @@ const Mt = (n, e = {
|
|
|
2854
2854
|
bigint: (n) => z.create({ ...n, coerce: !0 }),
|
|
2855
2855
|
date: (n) => B.create({ ...n, coerce: !0 })
|
|
2856
2856
|
}, _n = y;
|
|
2857
|
-
var
|
|
2857
|
+
var s = /* @__PURE__ */ Object.freeze({
|
|
2858
2858
|
__proto__: null,
|
|
2859
2859
|
defaultErrorMap: G,
|
|
2860
2860
|
setErrorMap: mt,
|
|
@@ -2866,15 +2866,15 @@ var a = /* @__PURE__ */ Object.freeze({
|
|
|
2866
2866
|
INVALID: y,
|
|
2867
2867
|
DIRTY: Y,
|
|
2868
2868
|
OK: S,
|
|
2869
|
-
isAborted:
|
|
2870
|
-
isDirty:
|
|
2869
|
+
isAborted: De,
|
|
2870
|
+
isDirty: Oe,
|
|
2871
2871
|
isValid: q,
|
|
2872
2872
|
isAsync: se,
|
|
2873
2873
|
get util() {
|
|
2874
2874
|
return x;
|
|
2875
2875
|
},
|
|
2876
2876
|
get objectUtil() {
|
|
2877
|
-
return
|
|
2877
|
+
return Ze;
|
|
2878
2878
|
},
|
|
2879
2879
|
ZodParsedType: p,
|
|
2880
2880
|
getParsedType: R,
|
|
@@ -2890,7 +2890,7 @@ var a = /* @__PURE__ */ Object.freeze({
|
|
|
2890
2890
|
ZodNull: oe,
|
|
2891
2891
|
ZodAny: J,
|
|
2892
2892
|
ZodUnknown: L,
|
|
2893
|
-
ZodNever:
|
|
2893
|
+
ZodNever: M,
|
|
2894
2894
|
ZodVoid: ke,
|
|
2895
2895
|
ZodArray: C,
|
|
2896
2896
|
ZodObject: k,
|
|
@@ -2907,9 +2907,9 @@ var a = /* @__PURE__ */ Object.freeze({
|
|
|
2907
2907
|
ZodEnum: F,
|
|
2908
2908
|
ZodNativeEnum: pe,
|
|
2909
2909
|
ZodPromise: H,
|
|
2910
|
-
ZodEffects:
|
|
2911
|
-
ZodTransformer:
|
|
2912
|
-
ZodOptional:
|
|
2910
|
+
ZodEffects: j,
|
|
2911
|
+
ZodTransformer: j,
|
|
2912
|
+
ZodOptional: D,
|
|
2913
2913
|
ZodNullable: U,
|
|
2914
2914
|
ZodDefault: fe,
|
|
2915
2915
|
ZodCatch: he,
|
|
@@ -2935,12 +2935,12 @@ var a = /* @__PURE__ */ Object.freeze({
|
|
|
2935
2935
|
effect: ze,
|
|
2936
2936
|
enum: cn,
|
|
2937
2937
|
function: sn,
|
|
2938
|
-
instanceof:
|
|
2938
|
+
instanceof: $t,
|
|
2939
2939
|
intersection: Kt,
|
|
2940
2940
|
lazy: an,
|
|
2941
2941
|
literal: on,
|
|
2942
2942
|
map: nn,
|
|
2943
|
-
nan:
|
|
2943
|
+
nan: Mt,
|
|
2944
2944
|
nativeEnum: un,
|
|
2945
2945
|
never: Wt,
|
|
2946
2946
|
null: Lt,
|
|
@@ -2970,253 +2970,253 @@ var a = /* @__PURE__ */ Object.freeze({
|
|
|
2970
2970
|
quotelessJson: lt,
|
|
2971
2971
|
ZodError: N
|
|
2972
2972
|
});
|
|
2973
|
-
const Ie =
|
|
2974
|
-
country:
|
|
2975
|
-
city:
|
|
2976
|
-
street:
|
|
2977
|
-
streetNumber:
|
|
2978
|
-
floor:
|
|
2979
|
-
apartmentEnterNumber:
|
|
2980
|
-
apartmentNumber:
|
|
2981
|
-
}),
|
|
2973
|
+
const Ie = s.object({
|
|
2974
|
+
country: s.string().optional(),
|
|
2975
|
+
city: s.string().optional(),
|
|
2976
|
+
street: s.string().optional(),
|
|
2977
|
+
streetNumber: s.string().optional(),
|
|
2978
|
+
floor: s.string().optional(),
|
|
2979
|
+
apartmentEnterNumber: s.string().optional(),
|
|
2980
|
+
apartmentNumber: s.string().optional()
|
|
2981
|
+
}), $ = s.string().min(1, { message: "שדה חובה" }), Vn = s.string().regex(/^\d+$/, "Must be a numeric string"), zn = s.object({ url: s.string().url(), id: s.string() });
|
|
2982
2982
|
function Fn(n) {
|
|
2983
2983
|
return !!(n != null && n.url);
|
|
2984
2984
|
}
|
|
2985
|
-
const re =
|
|
2986
|
-
lang:
|
|
2987
|
-
value:
|
|
2988
|
-
}), Un =
|
|
2989
|
-
id:
|
|
2990
|
-
companyId:
|
|
2991
|
-
storeId:
|
|
2992
|
-
parentId:
|
|
2993
|
-
tag:
|
|
2994
|
-
locales:
|
|
2995
|
-
depth:
|
|
2985
|
+
const re = s.object({
|
|
2986
|
+
lang: s.enum(["he"]),
|
|
2987
|
+
value: s.string()
|
|
2988
|
+
}), Un = s.array(re), Ke = s.object({
|
|
2989
|
+
id: s.string().min(1),
|
|
2990
|
+
companyId: s.string().min(1),
|
|
2991
|
+
storeId: s.string().min(1),
|
|
2992
|
+
parentId: s.string().nullish(),
|
|
2993
|
+
tag: s.string().optional(),
|
|
2994
|
+
locales: s.array(re),
|
|
2995
|
+
depth: s.number()
|
|
2996
2996
|
}), Re = Ke.extend({
|
|
2997
|
-
children:
|
|
2997
|
+
children: s.lazy(() => Re.array())
|
|
2998
2998
|
}), Ln = Ke.extend({
|
|
2999
|
-
index:
|
|
3000
|
-
depth:
|
|
3001
|
-
collapsed:
|
|
3002
|
-
children:
|
|
3003
|
-
}), ee =
|
|
3004
|
-
type:
|
|
2999
|
+
index: s.number(),
|
|
3000
|
+
depth: s.number(),
|
|
3001
|
+
collapsed: s.boolean().optional(),
|
|
3002
|
+
children: s.array(Re)
|
|
3003
|
+
}), ee = s.string().min(1), et = s.object({
|
|
3004
|
+
type: s.literal("Product"),
|
|
3005
3005
|
storeId: ee,
|
|
3006
3006
|
companyId: ee,
|
|
3007
3007
|
id: ee,
|
|
3008
3008
|
objectID: ee,
|
|
3009
3009
|
sku: ee,
|
|
3010
|
-
name:
|
|
3011
|
-
description:
|
|
3012
|
-
isPublished:
|
|
3013
|
-
vat:
|
|
3014
|
-
priceType:
|
|
3015
|
-
type:
|
|
3016
|
-
value:
|
|
3010
|
+
name: s.array(re),
|
|
3011
|
+
description: s.array(re),
|
|
3012
|
+
isPublished: s.boolean(),
|
|
3013
|
+
vat: s.boolean(),
|
|
3014
|
+
priceType: s.object({
|
|
3015
|
+
type: s.enum(["unit", "kg", "gram", "liter", "ml"]),
|
|
3016
|
+
value: s.number()
|
|
3017
3017
|
}),
|
|
3018
|
-
price:
|
|
3019
|
-
purchasePrice:
|
|
3020
|
-
profitPercentage:
|
|
3021
|
-
currency:
|
|
3022
|
-
discount:
|
|
3023
|
-
type:
|
|
3024
|
-
value:
|
|
3018
|
+
price: s.number().positive(),
|
|
3019
|
+
purchasePrice: s.number().optional(),
|
|
3020
|
+
profitPercentage: s.number().optional(),
|
|
3021
|
+
currency: s.literal("ILS"),
|
|
3022
|
+
discount: s.object({
|
|
3023
|
+
type: s.enum(["number", "percent", "none"]),
|
|
3024
|
+
value: s.number()
|
|
3025
3025
|
}),
|
|
3026
|
-
isDiscountable:
|
|
3027
|
-
weight:
|
|
3028
|
-
value:
|
|
3029
|
-
unit:
|
|
3026
|
+
isDiscountable: s.boolean({ description: "included in store discounts" }).optional(),
|
|
3027
|
+
weight: s.object({
|
|
3028
|
+
value: s.number(),
|
|
3029
|
+
unit: s.enum(["kg", "gram", "none"])
|
|
3030
3030
|
}),
|
|
3031
|
-
volume:
|
|
3032
|
-
value:
|
|
3033
|
-
unit:
|
|
3031
|
+
volume: s.object({
|
|
3032
|
+
value: s.number(),
|
|
3033
|
+
unit: s.enum(["liter", "ml", "none"])
|
|
3034
3034
|
}),
|
|
3035
|
-
images:
|
|
3036
|
-
manufacturer:
|
|
3037
|
-
brand:
|
|
3038
|
-
importer:
|
|
3039
|
-
supplier:
|
|
3040
|
-
ingredients:
|
|
3041
|
-
created_at:
|
|
3042
|
-
updated_at:
|
|
3043
|
-
categoryIds:
|
|
3044
|
-
stock:
|
|
3045
|
-
quantity:
|
|
3046
|
-
unit:
|
|
3035
|
+
images: s.array(s.object({ url: s.string().url(), id: s.string() })),
|
|
3036
|
+
manufacturer: s.string(),
|
|
3037
|
+
brand: s.string(),
|
|
3038
|
+
importer: s.string(),
|
|
3039
|
+
supplier: s.string(),
|
|
3040
|
+
ingredients: s.array(re),
|
|
3041
|
+
created_at: s.number(),
|
|
3042
|
+
updated_at: s.number(),
|
|
3043
|
+
categoryIds: s.array(s.string().nonempty()),
|
|
3044
|
+
stock: s.object({
|
|
3045
|
+
quantity: s.number().min(0),
|
|
3046
|
+
unit: s.enum(["piece", "kg", "gram", "liter", "ml"])
|
|
3047
3047
|
}).optional(),
|
|
3048
3048
|
// @deprecated
|
|
3049
|
-
categoryList:
|
|
3049
|
+
categoryList: s.array(Re).optional(),
|
|
3050
3050
|
// @deprecated
|
|
3051
|
-
categories:
|
|
3052
|
-
lvl0:
|
|
3053
|
-
lvl1:
|
|
3054
|
-
lvl2:
|
|
3055
|
-
lvl3:
|
|
3056
|
-
lvl4:
|
|
3051
|
+
categories: s.object({
|
|
3052
|
+
lvl0: s.array(s.string()),
|
|
3053
|
+
lvl1: s.array(s.string()),
|
|
3054
|
+
lvl2: s.array(s.string()),
|
|
3055
|
+
lvl3: s.array(s.string()),
|
|
3056
|
+
lvl4: s.array(s.string())
|
|
3057
3057
|
}).optional(),
|
|
3058
3058
|
// @deprecated
|
|
3059
|
-
categoryNames:
|
|
3059
|
+
categoryNames: s.array(s.string()).optional()
|
|
3060
3060
|
}), qn = et.extend({
|
|
3061
|
-
image:
|
|
3062
|
-
}), tt =
|
|
3061
|
+
image: s.instanceof(File).optional()
|
|
3062
|
+
}), tt = s.object({
|
|
3063
3063
|
product: et,
|
|
3064
|
-
originalPrice:
|
|
3065
|
-
finalPrice:
|
|
3066
|
-
finalDiscount:
|
|
3067
|
-
amount:
|
|
3068
|
-
}), Bn =
|
|
3069
|
-
type:
|
|
3070
|
-
id:
|
|
3071
|
-
companyId:
|
|
3072
|
-
storeId:
|
|
3073
|
-
userId:
|
|
3074
|
-
status:
|
|
3075
|
-
items:
|
|
3076
|
-
}), Wn =
|
|
3077
|
-
id:
|
|
3078
|
-
name:
|
|
3079
|
-
websiteDomains:
|
|
3080
|
-
}), Qn =
|
|
3081
|
-
type:
|
|
3082
|
-
id:
|
|
3083
|
-
companyId:
|
|
3084
|
-
storeId:
|
|
3085
|
-
userId:
|
|
3086
|
-
productId:
|
|
3087
|
-
}), Ne =
|
|
3088
|
-
type:
|
|
3089
|
-
id:
|
|
3090
|
-
companyId:
|
|
3091
|
-
storeId:
|
|
3092
|
-
tenantId:
|
|
3064
|
+
originalPrice: s.number().optional(),
|
|
3065
|
+
finalPrice: s.number().optional(),
|
|
3066
|
+
finalDiscount: s.number().optional(),
|
|
3067
|
+
amount: s.number().positive({ message: "Quantity must be a positive number." })
|
|
3068
|
+
}), Bn = s.object({
|
|
3069
|
+
type: s.literal("Cart"),
|
|
3070
|
+
id: s.string().uuid(),
|
|
3071
|
+
companyId: s.string().uuid(),
|
|
3072
|
+
storeId: s.string().uuid(),
|
|
3073
|
+
userId: s.string().uuid(),
|
|
3074
|
+
status: s.enum(["active", "draft", "completed"]),
|
|
3075
|
+
items: s.array(tt)
|
|
3076
|
+
}), Wn = s.object({
|
|
3077
|
+
id: s.string(),
|
|
3078
|
+
name: s.string(),
|
|
3079
|
+
websiteDomains: s.array(s.string())
|
|
3080
|
+
}), Qn = s.object({
|
|
3081
|
+
type: s.literal("FavoriteProduct"),
|
|
3082
|
+
id: s.string().uuid(),
|
|
3083
|
+
companyId: s.string().uuid(),
|
|
3084
|
+
storeId: s.string().uuid(),
|
|
3085
|
+
userId: s.string().uuid(),
|
|
3086
|
+
productId: s.string().uuid()
|
|
3087
|
+
}), Ne = s.enum(["external", "j5", "none"]), bn = s.object({
|
|
3088
|
+
type: s.literal("Profile"),
|
|
3089
|
+
id: $,
|
|
3090
|
+
companyId: $,
|
|
3091
|
+
storeId: $,
|
|
3092
|
+
tenantId: $,
|
|
3093
3093
|
// @deprecated
|
|
3094
|
-
clientType:
|
|
3095
|
-
companyName:
|
|
3096
|
-
displayName:
|
|
3097
|
-
email:
|
|
3098
|
-
phoneNumber:
|
|
3094
|
+
clientType: s.enum(["user", "company"]),
|
|
3095
|
+
companyName: s.string().optional(),
|
|
3096
|
+
displayName: $,
|
|
3097
|
+
email: s.string().email(),
|
|
3098
|
+
phoneNumber: s.string().optional(),
|
|
3099
3099
|
address: Ie.optional(),
|
|
3100
|
-
isAnonymous:
|
|
3101
|
-
createdDate:
|
|
3102
|
-
lastActivityDate:
|
|
3100
|
+
isAnonymous: s.boolean(),
|
|
3101
|
+
createdDate: s.number(),
|
|
3102
|
+
lastActivityDate: s.number(),
|
|
3103
3103
|
//todo
|
|
3104
3104
|
paymentType: Ne.optional(),
|
|
3105
|
-
organizationId:
|
|
3106
|
-
}), nt =
|
|
3107
|
-
_COMMENT:
|
|
3108
|
-
transaction_id:
|
|
3109
|
-
date:
|
|
3110
|
-
currency:
|
|
3111
|
-
rate:
|
|
3112
|
-
vat:
|
|
3113
|
-
vat_price:
|
|
3114
|
-
price_discount:
|
|
3115
|
-
price_discount_in_currency:
|
|
3116
|
-
price_total:
|
|
3117
|
-
price_total_in_currency:
|
|
3118
|
-
}), xn =
|
|
3119
|
-
doc_uuid:
|
|
3120
|
-
pdf_link:
|
|
3121
|
-
pdf_link_copy:
|
|
3122
|
-
doc_number:
|
|
3123
|
-
sent_mails:
|
|
3124
|
-
success:
|
|
3125
|
-
ua_uuid:
|
|
3105
|
+
organizationId: s.string().optional().nullable()
|
|
3106
|
+
}), nt = s.object({
|
|
3107
|
+
_COMMENT: s.string().optional(),
|
|
3108
|
+
transaction_id: s.string(),
|
|
3109
|
+
date: s.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
|
|
3110
|
+
currency: s.string().length(3, "Currency must be 3 characters"),
|
|
3111
|
+
rate: s.number().positive(),
|
|
3112
|
+
vat: s.string().regex(/^\d+\.\d{2}$/, "VAT must be in format XX.XX"),
|
|
3113
|
+
vat_price: s.number().positive(),
|
|
3114
|
+
price_discount: s.number(),
|
|
3115
|
+
price_discount_in_currency: s.number(),
|
|
3116
|
+
price_total: s.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
|
|
3117
|
+
price_total_in_currency: s.number().positive()
|
|
3118
|
+
}), xn = s.object({
|
|
3119
|
+
doc_uuid: s.string().uuid("Document UUID must be a valid UUID"),
|
|
3120
|
+
pdf_link: s.string().url("PDF link must be a valid URL"),
|
|
3121
|
+
pdf_link_copy: s.string().url("PDF copy link must be a valid URL"),
|
|
3122
|
+
doc_number: s.string().min(1, "Document number is required"),
|
|
3123
|
+
sent_mails: s.array(s.string().email("Each email must be valid")),
|
|
3124
|
+
success: s.boolean(),
|
|
3125
|
+
ua_uuid: s.string().uuid("UA UUID must be a valid UUID"),
|
|
3126
3126
|
calculatedData: nt,
|
|
3127
|
-
warning:
|
|
3128
|
-
date:
|
|
3129
|
-
}), kn =
|
|
3130
|
-
id:
|
|
3131
|
-
number:
|
|
3132
|
-
date:
|
|
3133
|
-
createdAt:
|
|
3134
|
-
status:
|
|
3135
|
-
companyDetails:
|
|
3136
|
-
name:
|
|
3137
|
-
address:
|
|
3138
|
-
phone:
|
|
3139
|
-
email:
|
|
3127
|
+
warning: s.string().optional(),
|
|
3128
|
+
date: s.number().optional()
|
|
3129
|
+
}), kn = s.object({
|
|
3130
|
+
id: s.string().min(1, "ID is required"),
|
|
3131
|
+
number: s.string().min(1, "Number is required"),
|
|
3132
|
+
date: s.number().min(1, "Date is required"),
|
|
3133
|
+
createdAt: s.number().min(1, "Created at is required"),
|
|
3134
|
+
status: s.enum(["pending", "paid", "cancelled"]),
|
|
3135
|
+
companyDetails: s.object({
|
|
3136
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3137
|
+
address: s.string().min(1, "Address is required").optional(),
|
|
3138
|
+
phone: s.string().min(1, "Phone is required").optional(),
|
|
3139
|
+
email: s.string().email("Email must be valid").optional()
|
|
3140
3140
|
}).optional(),
|
|
3141
|
-
clientDetails:
|
|
3142
|
-
name:
|
|
3143
|
-
address:
|
|
3144
|
-
phone:
|
|
3145
|
-
email:
|
|
3141
|
+
clientDetails: s.object({
|
|
3142
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3143
|
+
address: s.string().min(1, "Address is required").optional(),
|
|
3144
|
+
phone: s.string().min(1, "Phone is required").optional(),
|
|
3145
|
+
email: s.string().email("Email must be valid").optional()
|
|
3146
3146
|
}).optional(),
|
|
3147
|
-
items:
|
|
3148
|
-
|
|
3149
|
-
name:
|
|
3150
|
-
price:
|
|
3151
|
-
quantity:
|
|
3152
|
-
total:
|
|
3147
|
+
items: s.array(
|
|
3148
|
+
s.object({
|
|
3149
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3150
|
+
price: s.number().min(1, "Price is required").optional(),
|
|
3151
|
+
quantity: s.number().min(1, "Quantity is required").optional(),
|
|
3152
|
+
total: s.number().min(1, "Total is required").optional()
|
|
3153
3153
|
})
|
|
3154
3154
|
).optional(),
|
|
3155
|
-
total:
|
|
3156
|
-
vat:
|
|
3157
|
-
link:
|
|
3158
|
-
}), rt =
|
|
3159
|
-
number:
|
|
3160
|
-
name:
|
|
3161
|
-
id:
|
|
3162
|
-
}), wn =
|
|
3163
|
-
id:
|
|
3164
|
-
name:
|
|
3165
|
-
discountPercentage:
|
|
3166
|
-
nameOnInvoice:
|
|
3167
|
-
billingAccounts:
|
|
3155
|
+
total: s.number().min(1, "Total is required").optional(),
|
|
3156
|
+
vat: s.number().min(1, "VAT is required").optional(),
|
|
3157
|
+
link: s.string().url("Link must be a valid URL").optional()
|
|
3158
|
+
}), rt = s.object({
|
|
3159
|
+
number: s.string(),
|
|
3160
|
+
name: s.string(),
|
|
3161
|
+
id: s.string()
|
|
3162
|
+
}), wn = s.object({
|
|
3163
|
+
id: s.string(),
|
|
3164
|
+
name: s.string(),
|
|
3165
|
+
discountPercentage: s.number().positive().min(0).max(100).optional(),
|
|
3166
|
+
nameOnInvoice: s.string().optional(),
|
|
3167
|
+
billingAccounts: s.array(rt),
|
|
3168
3168
|
paymentType: Ne,
|
|
3169
|
-
companyNumber:
|
|
3169
|
+
companyNumber: s.string().optional(),
|
|
3170
3170
|
address: Ie.optional(),
|
|
3171
|
-
groupId:
|
|
3172
|
-
}), Yn = wn.omit({ id: !0 }), Tn =
|
|
3173
|
-
doc_uuid:
|
|
3174
|
-
pdf_link:
|
|
3175
|
-
pdf_link_copy:
|
|
3176
|
-
doc_number:
|
|
3177
|
-
sent_mails:
|
|
3178
|
-
success:
|
|
3179
|
-
ua_uuid:
|
|
3171
|
+
groupId: s.string().optional()
|
|
3172
|
+
}), Yn = wn.omit({ id: !0 }), Tn = s.object({
|
|
3173
|
+
doc_uuid: s.string().uuid("Document UUID must be a valid UUID"),
|
|
3174
|
+
pdf_link: s.string().url("PDF link must be a valid URL"),
|
|
3175
|
+
pdf_link_copy: s.string().url("PDF copy link must be a valid URL"),
|
|
3176
|
+
doc_number: s.string().min(1, "Document number is required"),
|
|
3177
|
+
sent_mails: s.array(s.string().email("Each email must be valid")),
|
|
3178
|
+
success: s.boolean(),
|
|
3179
|
+
ua_uuid: s.string().uuid("UA UUID must be a valid UUID"),
|
|
3180
3180
|
calculatedData: nt,
|
|
3181
|
-
warning:
|
|
3182
|
-
date:
|
|
3183
|
-
}), Sn =
|
|
3184
|
-
id:
|
|
3185
|
-
number:
|
|
3186
|
-
date:
|
|
3187
|
-
createdAt:
|
|
3188
|
-
status:
|
|
3189
|
-
companyDetails:
|
|
3190
|
-
name:
|
|
3191
|
-
address:
|
|
3192
|
-
phone:
|
|
3193
|
-
email:
|
|
3181
|
+
warning: s.string().optional(),
|
|
3182
|
+
date: s.number().optional()
|
|
3183
|
+
}), Sn = s.object({
|
|
3184
|
+
id: s.string().min(1, "ID is required"),
|
|
3185
|
+
number: s.string().min(1, "Number is required"),
|
|
3186
|
+
date: s.string().min(1, "Date is required"),
|
|
3187
|
+
createdAt: s.number().min(1, "Created at is required"),
|
|
3188
|
+
status: s.enum(["pending", "paid", "cancelled"]),
|
|
3189
|
+
companyDetails: s.object({
|
|
3190
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3191
|
+
address: s.string().min(1, "Address is required").optional(),
|
|
3192
|
+
phone: s.string().min(1, "Phone is required").optional(),
|
|
3193
|
+
email: s.string().email("Email must be valid").optional()
|
|
3194
3194
|
}).optional(),
|
|
3195
|
-
clientDetails:
|
|
3196
|
-
name:
|
|
3197
|
-
address:
|
|
3198
|
-
phone:
|
|
3199
|
-
email:
|
|
3195
|
+
clientDetails: s.object({
|
|
3196
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3197
|
+
address: s.string().min(1, "Address is required").optional(),
|
|
3198
|
+
phone: s.string().min(1, "Phone is required").optional(),
|
|
3199
|
+
email: s.string().email("Email must be valid").optional()
|
|
3200
3200
|
}).optional(),
|
|
3201
|
-
items:
|
|
3202
|
-
|
|
3203
|
-
name:
|
|
3204
|
-
price:
|
|
3205
|
-
quantity:
|
|
3206
|
-
total:
|
|
3201
|
+
items: s.array(
|
|
3202
|
+
s.object({
|
|
3203
|
+
name: s.string().min(1, "Name is required").optional(),
|
|
3204
|
+
price: s.number().min(1, "Price is required").optional(),
|
|
3205
|
+
quantity: s.number().min(1, "Quantity is required").optional(),
|
|
3206
|
+
total: s.number().min(1, "Total is required").optional()
|
|
3207
3207
|
})
|
|
3208
3208
|
).optional(),
|
|
3209
|
-
total:
|
|
3210
|
-
vat:
|
|
3211
|
-
link:
|
|
3212
|
-
}), Xn =
|
|
3213
|
-
type:
|
|
3214
|
-
createdBy:
|
|
3215
|
-
id:
|
|
3216
|
-
companyId:
|
|
3217
|
-
storeId:
|
|
3218
|
-
userId:
|
|
3219
|
-
status:
|
|
3209
|
+
total: s.number().min(1, "Total is required").optional(),
|
|
3210
|
+
vat: s.number().min(1, "VAT is required").optional(),
|
|
3211
|
+
link: s.string().url("Link must be a valid URL").optional()
|
|
3212
|
+
}), Xn = s.object({
|
|
3213
|
+
type: s.literal("Order"),
|
|
3214
|
+
createdBy: s.enum(["user", "admin"]).optional(),
|
|
3215
|
+
id: $,
|
|
3216
|
+
companyId: $,
|
|
3217
|
+
storeId: $,
|
|
3218
|
+
userId: $,
|
|
3219
|
+
status: s.enum([
|
|
3220
3220
|
"draft",
|
|
3221
3221
|
// before payment
|
|
3222
3222
|
"pending",
|
|
@@ -3231,100 +3231,100 @@ const re = a.object({
|
|
|
3231
3231
|
"refunded"
|
|
3232
3232
|
]),
|
|
3233
3233
|
paymentType: Ne.optional(),
|
|
3234
|
-
paymentStatus:
|
|
3234
|
+
paymentStatus: s.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
|
|
3235
3235
|
//todo check if hyp support partial refund
|
|
3236
|
-
cart:
|
|
3237
|
-
id:
|
|
3238
|
-
items:
|
|
3239
|
-
cartDiscount:
|
|
3240
|
-
cartTotal:
|
|
3241
|
-
cartVat:
|
|
3242
|
-
deliveryPrice:
|
|
3236
|
+
cart: s.object({
|
|
3237
|
+
id: s.string(),
|
|
3238
|
+
items: s.array(tt),
|
|
3239
|
+
cartDiscount: s.number(),
|
|
3240
|
+
cartTotal: s.number(),
|
|
3241
|
+
cartVat: s.number(),
|
|
3242
|
+
deliveryPrice: s.number().optional()
|
|
3243
3243
|
// final delivery price for cart
|
|
3244
3244
|
}),
|
|
3245
|
-
storeOptions:
|
|
3246
|
-
deliveryPrice:
|
|
3247
|
-
freeDeliveryPrice:
|
|
3248
|
-
isVatIncludedInPrice:
|
|
3245
|
+
storeOptions: s.object({
|
|
3246
|
+
deliveryPrice: s.number().optional(),
|
|
3247
|
+
freeDeliveryPrice: s.number().optional(),
|
|
3248
|
+
isVatIncludedInPrice: s.boolean().optional()
|
|
3249
3249
|
}).optional(),
|
|
3250
|
-
originalAmount:
|
|
3250
|
+
originalAmount: s.number().positive().optional(),
|
|
3251
3251
|
// what client pay
|
|
3252
|
-
actualAmount:
|
|
3252
|
+
actualAmount: s.number().positive().optional(),
|
|
3253
3253
|
// what store charge
|
|
3254
|
-
date:
|
|
3255
|
-
deliveryDate:
|
|
3254
|
+
date: s.number(),
|
|
3255
|
+
deliveryDate: s.coerce.number(),
|
|
3256
3256
|
client: bn.optional(),
|
|
3257
3257
|
address: Ie.optional(),
|
|
3258
|
-
nameOnInvoice:
|
|
3259
|
-
emailOnInvoice:
|
|
3260
|
-
phoneNumberOnInvoice:
|
|
3261
|
-
clientComment:
|
|
3262
|
-
organizationId:
|
|
3258
|
+
nameOnInvoice: s.string().optional(),
|
|
3259
|
+
emailOnInvoice: s.string().email().optional(),
|
|
3260
|
+
phoneNumberOnInvoice: s.string().optional(),
|
|
3261
|
+
clientComment: s.string().optional(),
|
|
3262
|
+
organizationId: s.string().optional(),
|
|
3263
3263
|
billingAccount: rt.optional(),
|
|
3264
3264
|
deliveryNote: kn.optional(),
|
|
3265
3265
|
invoice: Sn.optional(),
|
|
3266
3266
|
ezInvoice: Tn.optional(),
|
|
3267
3267
|
ezDeliveryNote: xn.optional()
|
|
3268
|
-
}), In =
|
|
3269
|
-
id:
|
|
3270
|
-
companyId:
|
|
3271
|
-
name:
|
|
3272
|
-
urls:
|
|
3273
|
-
logoUrl:
|
|
3274
|
-
tenantId:
|
|
3268
|
+
}), In = s.enum(["individual", "company"]), Gn = s.object({
|
|
3269
|
+
id: s.string(),
|
|
3270
|
+
companyId: s.string(),
|
|
3271
|
+
name: s.string(),
|
|
3272
|
+
urls: s.array(s.string()),
|
|
3273
|
+
logoUrl: s.string(),
|
|
3274
|
+
tenantId: s.string(),
|
|
3275
3275
|
// firebase auth tenantId
|
|
3276
3276
|
paymentType: Ne,
|
|
3277
|
-
allowAnonymousClients:
|
|
3278
|
-
isVatIncludedInPrice:
|
|
3279
|
-
clientTypes:
|
|
3280
|
-
minimumOrder:
|
|
3281
|
-
freeDeliveryPrice:
|
|
3282
|
-
deliveryPrice:
|
|
3277
|
+
allowAnonymousClients: s.boolean(),
|
|
3278
|
+
isVatIncludedInPrice: s.boolean(),
|
|
3279
|
+
clientTypes: s.array(In),
|
|
3280
|
+
minimumOrder: s.number().optional(),
|
|
3281
|
+
freeDeliveryPrice: s.number().optional(),
|
|
3282
|
+
deliveryPrice: s.number().optional(),
|
|
3283
3283
|
address: Ie.optional(),
|
|
3284
|
-
companyNumber:
|
|
3284
|
+
companyNumber: s.string().optional()
|
|
3285
3285
|
// חפ של החברה
|
|
3286
|
-
}), Nn =
|
|
3287
|
-
minSpend:
|
|
3288
|
-
stackable:
|
|
3289
|
-
}).optional(), An =
|
|
3290
|
-
|
|
3291
|
-
variantType:
|
|
3292
|
-
productsId:
|
|
3286
|
+
}), Nn = s.object({
|
|
3287
|
+
minSpend: s.number().positive().optional(),
|
|
3288
|
+
stackable: s.boolean().default(!1)
|
|
3289
|
+
}).optional(), An = s.discriminatedUnion("variantType", [
|
|
3290
|
+
s.object({
|
|
3291
|
+
variantType: s.literal("bundle"),
|
|
3292
|
+
productsId: s.array(s.string().nonempty()).min(1),
|
|
3293
3293
|
// Which products are included
|
|
3294
|
-
requiredQuantity:
|
|
3294
|
+
requiredQuantity: s.number().positive(),
|
|
3295
3295
|
// How many items needed (e.g., 3)
|
|
3296
|
-
bundlePrice:
|
|
3296
|
+
bundlePrice: s.number().positive()
|
|
3297
3297
|
// Total price for the bundle (e.g., $25)
|
|
3298
3298
|
})
|
|
3299
|
-
]), Jn =
|
|
3300
|
-
type:
|
|
3301
|
-
storeId:
|
|
3302
|
-
companyId:
|
|
3303
|
-
id:
|
|
3304
|
-
name:
|
|
3305
|
-
active:
|
|
3306
|
-
startDate:
|
|
3307
|
-
endDate:
|
|
3299
|
+
]), Jn = s.object({
|
|
3300
|
+
type: s.literal("Discount"),
|
|
3301
|
+
storeId: s.string().min(1),
|
|
3302
|
+
companyId: s.string().min(1),
|
|
3303
|
+
id: s.string().min(1),
|
|
3304
|
+
name: s.array(s.object({ lang: s.enum(["he"]), value: s.string().nonempty() })),
|
|
3305
|
+
active: s.boolean(),
|
|
3306
|
+
startDate: s.number(),
|
|
3307
|
+
endDate: s.number(),
|
|
3308
3308
|
variant: An,
|
|
3309
3309
|
conditions: Nn
|
|
3310
3310
|
});
|
|
3311
3311
|
class Cn {
|
|
3312
3312
|
canApply(e, t) {
|
|
3313
3313
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3314
|
-
const { productsId: r, requiredQuantity:
|
|
3315
|
-
return this.getTotalQuantity(t.cart, r) >=
|
|
3314
|
+
const { productsId: r, requiredQuantity: a } = e.variant;
|
|
3315
|
+
return this.getTotalQuantity(t.cart, r) >= a;
|
|
3316
3316
|
}
|
|
3317
3317
|
calculate(e, t) {
|
|
3318
3318
|
if (e.variant.variantType !== "bundle")
|
|
3319
3319
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3320
|
-
const { productsId: r, requiredQuantity:
|
|
3320
|
+
const { productsId: r, requiredQuantity: a, bundlePrice: i } = e.variant, o = t.cart.filter((K) => r.includes(K.product.id)), c = this.getTotalQuantity(t.cart, r), l = Math.floor(c / a);
|
|
3321
3321
|
if (l === 0)
|
|
3322
3322
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3323
3323
|
const u = this.calculateOriginalPrice(o), f = this.getTotalQuantity(t.cart, r), b = this.calculateDiscountedPrice(
|
|
3324
3324
|
u,
|
|
3325
3325
|
i,
|
|
3326
3326
|
l,
|
|
3327
|
-
|
|
3327
|
+
a,
|
|
3328
3328
|
f
|
|
3329
3329
|
), w = u - b, I = this.distributeDiscount(o, w, u);
|
|
3330
3330
|
return {
|
|
@@ -3338,19 +3338,19 @@ class Cn {
|
|
|
3338
3338
|
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3339
3339
|
}
|
|
3340
3340
|
getTotalQuantity(e, t) {
|
|
3341
|
-
return e.filter((r) => t.includes(r.product.id)).reduce((r,
|
|
3341
|
+
return e.filter((r) => t.includes(r.product.id)).reduce((r, a) => r + a.amount, 0);
|
|
3342
3342
|
}
|
|
3343
3343
|
calculateOriginalPrice(e) {
|
|
3344
3344
|
return e.reduce((t, r) => t + r.product.price * r.amount, 0);
|
|
3345
3345
|
}
|
|
3346
|
-
calculateDiscountedPrice(e, t, r,
|
|
3347
|
-
const o = t * r, c = r *
|
|
3346
|
+
calculateDiscountedPrice(e, t, r, a, i) {
|
|
3347
|
+
const o = t * r, c = r * a, u = Math.max(0, i - c) / i * e;
|
|
3348
3348
|
return o + u;
|
|
3349
3349
|
}
|
|
3350
3350
|
distributeDiscount(e, t, r) {
|
|
3351
|
-
const
|
|
3351
|
+
const a = t / r;
|
|
3352
3352
|
return e.map((i) => {
|
|
3353
|
-
const o = i.product.price * i.amount *
|
|
3353
|
+
const o = i.product.price * i.amount * a;
|
|
3354
3354
|
return {
|
|
3355
3355
|
productId: i.product.id,
|
|
3356
3356
|
quantity: i.amount,
|
|
@@ -3375,27 +3375,27 @@ class st {
|
|
|
3375
3375
|
this.strategies.clear();
|
|
3376
3376
|
}
|
|
3377
3377
|
}
|
|
3378
|
-
|
|
3378
|
+
$e(st, "strategies", /* @__PURE__ */ new Map([
|
|
3379
3379
|
["bundle", new Cn()]
|
|
3380
3380
|
]));
|
|
3381
|
-
class
|
|
3381
|
+
class jn {
|
|
3382
3382
|
static calculateDiscounts(e, t, r) {
|
|
3383
3383
|
var u, f;
|
|
3384
|
-
const
|
|
3384
|
+
const a = {
|
|
3385
3385
|
cart: e,
|
|
3386
3386
|
user: r,
|
|
3387
3387
|
appliedDiscounts: []
|
|
3388
3388
|
}, i = this.filterActiveDiscounts(t), o = [];
|
|
3389
3389
|
for (const b of i) {
|
|
3390
3390
|
const w = st.getStrategy(b);
|
|
3391
|
-
if (!w || !w.canApply(b,
|
|
3392
|
-
const I = w.calculate(b,
|
|
3391
|
+
if (!w || !w.canApply(b, a) || !((u = b.conditions) != null && u.stackable) && o.length > 0) continue;
|
|
3392
|
+
const I = w.calculate(b, a);
|
|
3393
3393
|
I.applicable && (o.push({
|
|
3394
3394
|
discountId: b.id,
|
|
3395
3395
|
discountName: ((f = b.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3396
3396
|
discountAmount: Number(I.discountAmount.toFixed(2)),
|
|
3397
3397
|
affectedItems: I.affectedItems
|
|
3398
|
-
}),
|
|
3398
|
+
}), a.appliedDiscounts = o);
|
|
3399
3399
|
}
|
|
3400
3400
|
const c = this.calculateFinalPrices(e, o), l = o.reduce(
|
|
3401
3401
|
(b, w) => b + w.discountAmount,
|
|
@@ -3415,9 +3415,9 @@ class Zn {
|
|
|
3415
3415
|
}
|
|
3416
3416
|
static calculateFinalPrices(e, t) {
|
|
3417
3417
|
return e.map((r) => {
|
|
3418
|
-
const
|
|
3418
|
+
const a = t.filter(
|
|
3419
3419
|
(l) => l.affectedItems.some((u) => u.productId === r.product.id)
|
|
3420
|
-
), i =
|
|
3420
|
+
), i = a.reduce((l, u) => {
|
|
3421
3421
|
const f = u.affectedItems.find(
|
|
3422
3422
|
(b) => b.productId === r.product.id
|
|
3423
3423
|
);
|
|
@@ -3429,7 +3429,7 @@ class Zn {
|
|
|
3429
3429
|
originalPrice: Number(r.product.price.toFixed(2)),
|
|
3430
3430
|
finalPrice: Number(Math.max(0, c).toFixed(2)),
|
|
3431
3431
|
finalDiscount: Number(i.toFixed(2)),
|
|
3432
|
-
appliedDiscounts:
|
|
3432
|
+
appliedDiscounts: a.map((l) => l.discountId)
|
|
3433
3433
|
};
|
|
3434
3434
|
});
|
|
3435
3435
|
}
|
|
@@ -3455,60 +3455,94 @@ function er(n, e) {
|
|
|
3455
3455
|
const t = n - e;
|
|
3456
3456
|
return at(t / n * 100);
|
|
3457
3457
|
}
|
|
3458
|
-
const
|
|
3459
|
-
id:
|
|
3460
|
-
name:
|
|
3461
|
-
}), tr =
|
|
3462
|
-
type:
|
|
3463
|
-
id:
|
|
3464
|
-
name:
|
|
3465
|
-
code:
|
|
3458
|
+
const Zn = s.object({
|
|
3459
|
+
id: s.string(),
|
|
3460
|
+
name: s.string()
|
|
3461
|
+
}), tr = Zn.omit({ id: !0 }), it = s.object({
|
|
3462
|
+
type: s.literal("Supplier"),
|
|
3463
|
+
id: s.string(),
|
|
3464
|
+
name: s.string(),
|
|
3465
|
+
code: s.string()
|
|
3466
3466
|
// supplier code number
|
|
3467
|
-
}), nr = it.omit({ id: !0 }),
|
|
3468
|
-
type:
|
|
3469
|
-
id:
|
|
3467
|
+
}), nr = it.omit({ id: !0 }), Dn = s.object({
|
|
3468
|
+
type: s.literal("SupplierInvoice"),
|
|
3469
|
+
id: s.string(),
|
|
3470
3470
|
supplier: it,
|
|
3471
|
-
invoiceNumber:
|
|
3472
|
-
date:
|
|
3473
|
-
rows:
|
|
3474
|
-
|
|
3475
|
-
id:
|
|
3476
|
-
rowNumber:
|
|
3477
|
-
sku:
|
|
3478
|
-
itemName:
|
|
3479
|
-
quantity:
|
|
3480
|
-
purchasePrice:
|
|
3481
|
-
lineDiscount:
|
|
3482
|
-
profitPercentage:
|
|
3483
|
-
price:
|
|
3484
|
-
totalPurchasePrice:
|
|
3485
|
-
vat:
|
|
3486
|
-
originalProduct:
|
|
3487
|
-
purchasePrice:
|
|
3488
|
-
price:
|
|
3489
|
-
profitPercentage:
|
|
3471
|
+
invoiceNumber: s.string(),
|
|
3472
|
+
date: s.number(),
|
|
3473
|
+
rows: s.array(
|
|
3474
|
+
s.object({
|
|
3475
|
+
id: s.string(),
|
|
3476
|
+
rowNumber: s.number(),
|
|
3477
|
+
sku: s.string(),
|
|
3478
|
+
itemName: s.string(),
|
|
3479
|
+
quantity: s.number(),
|
|
3480
|
+
purchasePrice: s.number(),
|
|
3481
|
+
lineDiscount: s.number(),
|
|
3482
|
+
profitPercentage: s.number(),
|
|
3483
|
+
price: s.number(),
|
|
3484
|
+
totalPurchasePrice: s.number(),
|
|
3485
|
+
vat: s.boolean(),
|
|
3486
|
+
originalProduct: s.object({
|
|
3487
|
+
purchasePrice: s.number(),
|
|
3488
|
+
price: s.number(),
|
|
3489
|
+
profitPercentage: s.number()
|
|
3490
3490
|
}).optional()
|
|
3491
3491
|
})
|
|
3492
3492
|
),
|
|
3493
|
-
productsToUpdate:
|
|
3494
|
-
|
|
3495
|
-
sku:
|
|
3496
|
-
itemName:
|
|
3497
|
-
oldPurchasePrice:
|
|
3498
|
-
newPurchasePrice:
|
|
3499
|
-
oldPrice:
|
|
3500
|
-
newPrice:
|
|
3501
|
-
oldProfitPercentage:
|
|
3502
|
-
newProfitPercentage:
|
|
3493
|
+
productsToUpdate: s.array(
|
|
3494
|
+
s.object({
|
|
3495
|
+
sku: s.string(),
|
|
3496
|
+
itemName: s.string(),
|
|
3497
|
+
oldPurchasePrice: s.number(),
|
|
3498
|
+
newPurchasePrice: s.number(),
|
|
3499
|
+
oldPrice: s.number(),
|
|
3500
|
+
newPrice: s.number(),
|
|
3501
|
+
oldProfitPercentage: s.number(),
|
|
3502
|
+
newProfitPercentage: s.number()
|
|
3503
3503
|
})
|
|
3504
3504
|
),
|
|
3505
|
-
total:
|
|
3506
|
-
totalBeforeVat:
|
|
3507
|
-
vat:
|
|
3508
|
-
}), rr =
|
|
3505
|
+
total: s.number().optional(),
|
|
3506
|
+
totalBeforeVat: s.number().optional(),
|
|
3507
|
+
vat: s.number().optional()
|
|
3508
|
+
}), rr = Dn.omit({ id: !0 }), sr = s.object({
|
|
3509
|
+
type: s.literal("ChatSession"),
|
|
3510
|
+
id: s.string(),
|
|
3511
|
+
storeId: s.string(),
|
|
3512
|
+
companyId: s.string(),
|
|
3513
|
+
tenantId: s.string(),
|
|
3514
|
+
userId: s.string().nullable(),
|
|
3515
|
+
userType: s.enum(["anonymous", "client", "admin", "superAdmin"]),
|
|
3516
|
+
createdAt: s.number(),
|
|
3517
|
+
updatedAt: s.number(),
|
|
3518
|
+
messageCount: s.number(),
|
|
3519
|
+
status: s.enum(["active", "archived"])
|
|
3520
|
+
}), ar = s.discriminatedUnion("type", [
|
|
3521
|
+
s.object({
|
|
3522
|
+
type: s.literal("message"),
|
|
3523
|
+
id: s.string(),
|
|
3524
|
+
role: s.enum(["user", "assistant", "system"]),
|
|
3525
|
+
content: s.string(),
|
|
3526
|
+
timestamp: s.number()
|
|
3527
|
+
}),
|
|
3528
|
+
s.object({
|
|
3529
|
+
type: s.literal("function_call"),
|
|
3530
|
+
id: s.string(),
|
|
3531
|
+
name: s.string(),
|
|
3532
|
+
arguments: s.record(s.string(), s.any()),
|
|
3533
|
+
timestamp: s.number()
|
|
3534
|
+
}),
|
|
3535
|
+
s.object({
|
|
3536
|
+
type: s.literal("tool_result"),
|
|
3537
|
+
id: s.string(),
|
|
3538
|
+
name: s.string(),
|
|
3539
|
+
result: s.any(),
|
|
3540
|
+
timestamp: s.number()
|
|
3541
|
+
})
|
|
3542
|
+
]), Fe = {
|
|
3509
3543
|
VAT: 18
|
|
3510
3544
|
};
|
|
3511
|
-
function
|
|
3545
|
+
function On(n) {
|
|
3512
3546
|
var e, t;
|
|
3513
3547
|
return ((e = n.discount) == null ? void 0 : e.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((t = n.discount) == null ? void 0 : t.type) === "number" ? n.discount.value ?? 0 : 0;
|
|
3514
3548
|
}
|
|
@@ -3520,12 +3554,12 @@ function Pn(n) {
|
|
|
3520
3554
|
}
|
|
3521
3555
|
return ((t = n.discount) == null ? void 0 : t.type) === "number" ? n.price - n.discount.value : n.price;
|
|
3522
3556
|
}
|
|
3523
|
-
function
|
|
3557
|
+
function ir({
|
|
3524
3558
|
cart: n,
|
|
3525
3559
|
discounts: e,
|
|
3526
3560
|
deliveryPrice: t = 0,
|
|
3527
3561
|
freeDeliveryPrice: r = 0,
|
|
3528
|
-
isVatIncludedInPrice:
|
|
3562
|
+
isVatIncludedInPrice: a = !1
|
|
3529
3563
|
}) {
|
|
3530
3564
|
const i = n.map((u) => ({
|
|
3531
3565
|
amount: u.amount,
|
|
@@ -3533,30 +3567,30 @@ function sr({
|
|
|
3533
3567
|
id: u.product.id,
|
|
3534
3568
|
price: u.product.price
|
|
3535
3569
|
}
|
|
3536
|
-
})), o =
|
|
3570
|
+
})), o = jn.calculateDiscounts(i, e), c = n.map((u, f) => {
|
|
3537
3571
|
const b = o.items[f];
|
|
3538
3572
|
return {
|
|
3539
3573
|
amount: u.amount,
|
|
3540
3574
|
product: { ...u.product },
|
|
3541
3575
|
originalPrice: u.product.price,
|
|
3542
3576
|
finalPrice: b ? b.finalPrice : Pn(u.product),
|
|
3543
|
-
finalDiscount: b ? b.finalDiscount :
|
|
3577
|
+
finalDiscount: b ? b.finalDiscount : On(u.product)
|
|
3544
3578
|
};
|
|
3545
3579
|
}), l = c.reduce(
|
|
3546
3580
|
(u, f) => {
|
|
3547
3581
|
const { product: b, amount: w, finalPrice: I, finalDiscount: K } = f;
|
|
3548
|
-
let
|
|
3582
|
+
let Z = 0;
|
|
3549
3583
|
if (b.vat) {
|
|
3550
3584
|
let Ce = 0;
|
|
3551
|
-
if (
|
|
3585
|
+
if (a) {
|
|
3552
3586
|
const ot = Number((I / (1 + Fe.VAT / 100)).toFixed(2)), ct = I - ot;
|
|
3553
|
-
|
|
3587
|
+
Z = Number(ct.toFixed(2)), Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3554
3588
|
} else
|
|
3555
|
-
|
|
3589
|
+
Z = I * Fe.VAT / 100, Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3556
3590
|
u.vat = Number((u.vat + Ce).toFixed(2));
|
|
3557
3591
|
}
|
|
3558
3592
|
const Ae = Number(I.toFixed(2));
|
|
3559
|
-
return u.cost += w * Ae, u.discount += K && w * K, u.finalCost += w * Ae + (
|
|
3593
|
+
return u.cost += w * Ae, u.discount += K && w * K, u.finalCost += w * Ae + (a ? 0 : Z), u.productsCost += w * Ae + (a ? 0 : Z), u.cost = Number(u.cost.toFixed(2)), u.discount = Number(u.discount.toFixed(2)), u.finalCost = Number(u.finalCost.toFixed(2)), u.productsCost = Number(u.productsCost.toFixed(2)), u;
|
|
3560
3594
|
},
|
|
3561
3595
|
{
|
|
3562
3596
|
discount: 0,
|
|
@@ -3588,8 +3622,11 @@ const En = {
|
|
|
3588
3622
|
// todo remove
|
|
3589
3623
|
invoices: "invoices",
|
|
3590
3624
|
suppliers: "suppliers",
|
|
3591
|
-
supplierInvoices: "supplierInvoices"
|
|
3592
|
-
|
|
3625
|
+
supplierInvoices: "supplierInvoices",
|
|
3626
|
+
chatSessions: "chatSessions",
|
|
3627
|
+
chatSessionMessages: "chatSessionMessages",
|
|
3628
|
+
contactSubmissions: "contactSubmissions"
|
|
3629
|
+
}, $n = {
|
|
3593
3630
|
systemCollections: En,
|
|
3594
3631
|
storeCollections: Rn,
|
|
3595
3632
|
// for client and server
|
|
@@ -3599,16 +3636,25 @@ const En = {
|
|
|
3599
3636
|
collectionName: t,
|
|
3600
3637
|
id: r
|
|
3601
3638
|
}) => `${n}/${e}/${t}${r ? `/${r}` : ""}`,
|
|
3639
|
+
getSubPath: ({
|
|
3640
|
+
companyId: n,
|
|
3641
|
+
storeId: e,
|
|
3642
|
+
collectionName: t,
|
|
3643
|
+
subCollectionName: r,
|
|
3644
|
+
id: a,
|
|
3645
|
+
subId: i
|
|
3646
|
+
}) => `${n}/${e}/${t}/${a}/${r}${i ? `/${i}` : ""}`,
|
|
3602
3647
|
// for firestore events
|
|
3603
|
-
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}
|
|
3604
|
-
|
|
3605
|
-
|
|
3648
|
+
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
|
|
3649
|
+
getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
|
|
3650
|
+
}, or = {
|
|
3651
|
+
firestore: $n
|
|
3606
3652
|
}, Ue = {
|
|
3607
3653
|
round: (n, e = 2) => {
|
|
3608
3654
|
const t = 10 ** e;
|
|
3609
3655
|
return Math.round((n + Number.EPSILON) * t) / t;
|
|
3610
3656
|
}
|
|
3611
|
-
},
|
|
3657
|
+
}, cr = {
|
|
3612
3658
|
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : Ue.round(e / (1 - n / 100)),
|
|
3613
3659
|
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : Ue.round((n - e) / n * 100)
|
|
3614
3660
|
};
|
|
@@ -3621,17 +3667,19 @@ export {
|
|
|
3621
3667
|
tt as CartItemProductSchema,
|
|
3622
3668
|
Bn as CartSchema,
|
|
3623
3669
|
Re as CategorySchema,
|
|
3670
|
+
ar as ChatSessionMessageSchema,
|
|
3671
|
+
sr as ChatSessionSchema,
|
|
3624
3672
|
Wn as CompanySchema,
|
|
3625
3673
|
kn as DeliveryNoteSchema,
|
|
3626
3674
|
Nn as DiscountConditionsSchema,
|
|
3627
|
-
|
|
3675
|
+
jn as DiscountEngine,
|
|
3628
3676
|
Jn as DiscountSchema,
|
|
3629
3677
|
st as DiscountStrategyFactory,
|
|
3630
3678
|
An as DiscountVariantSchema,
|
|
3631
3679
|
xn as EzDeliveryNoteSchema,
|
|
3632
3680
|
Qn as FavoriteProductSchema,
|
|
3633
3681
|
zn as FileSchema,
|
|
3634
|
-
|
|
3682
|
+
or as FirebaseAPI,
|
|
3635
3683
|
re as LocaleSchema,
|
|
3636
3684
|
Un as LocaleValueSchema,
|
|
3637
3685
|
tr as NewOrganizationGroupSchema,
|
|
@@ -3640,13 +3688,13 @@ export {
|
|
|
3640
3688
|
rr as NewSupplierInvoiceSchema,
|
|
3641
3689
|
nr as NewSupplierSchema,
|
|
3642
3690
|
Xn as OrderSchema,
|
|
3643
|
-
|
|
3691
|
+
Zn as OrganizationGroupSchema,
|
|
3644
3692
|
wn as OrganizationSchema,
|
|
3645
3693
|
Ne as PaymentTypeSchema,
|
|
3646
3694
|
et as ProductSchema,
|
|
3647
3695
|
bn as ProfileSchema,
|
|
3648
3696
|
Gn as StoreSchema,
|
|
3649
|
-
|
|
3697
|
+
Dn as SupplierInvoiceSchema,
|
|
3650
3698
|
it as SupplierSchema,
|
|
3651
3699
|
Ln as TFlattenCategorySchema,
|
|
3652
3700
|
er as calculatePercentageDiscount,
|
|
@@ -3654,11 +3702,11 @@ export {
|
|
|
3654
3702
|
Kn as ensureNonNegative,
|
|
3655
3703
|
at as formatCurrency,
|
|
3656
3704
|
Hn as formatCurrencyString,
|
|
3657
|
-
|
|
3705
|
+
ir as getCartCost,
|
|
3658
3706
|
Fn as isFile,
|
|
3659
3707
|
Ue as math,
|
|
3660
|
-
|
|
3708
|
+
$ as notEmptyTextSchema,
|
|
3661
3709
|
Vn as numericTextSchema,
|
|
3662
|
-
|
|
3710
|
+
cr as storeCalculator
|
|
3663
3711
|
};
|
|
3664
3712
|
//# sourceMappingURL=core.es.js.map
|