@jsdev_ninja/core 0.13.34 → 0.13.48
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.js +1 -1
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.es.js +1017 -960
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/entities/Organization.d.ts +6 -0
- package/dist/lib/entities/Organization.d.ts.map +1 -1
- package/dist/lib/entities/Organization.js +1 -0
- package/dist/lib/entities/OrganizationGroup.d.ts +22 -0
- package/dist/lib/entities/OrganizationGroup.d.ts.map +1 -0
- package/dist/lib/entities/OrganizationGroup.js +7 -0
- package/dist/lib/entities/Supplier.d.ts +34 -0
- package/dist/lib/entities/Supplier.d.ts.map +1 -0
- package/dist/lib/entities/Supplier.js +8 -0
- package/dist/lib/entities/SupplierInvoice.d.ts +378 -0
- package/dist/lib/entities/SupplierInvoice.d.ts.map +1 -0
- package/dist/lib/entities/SupplierInvoice.js +40 -0
- package/dist/lib/entities/index.d.ts +3 -0
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +3 -0
- package/dist/lib/firebase-api/index.d.ts +9 -0
- package/dist/lib/firebase-api/index.d.ts.map +1 -1
- package/dist/lib/firebase-api/index.js +3 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +8 -2
package/dist/core.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var $e = (n, e, t) =>
|
|
1
|
+
var ot = Object.defineProperty;
|
|
2
|
+
var ct = (n, e, t) => e in n ? ot(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var $e = (n, e, t) => ct(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var x;
|
|
5
5
|
(function(n) {
|
|
6
6
|
n.assertEqual = (s) => s;
|
|
@@ -11,31 +11,31 @@ var x;
|
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
13
|
n.assertNever = t, n.arrayToEnum = (s) => {
|
|
14
|
-
const
|
|
14
|
+
const i = {};
|
|
15
15
|
for (const o of s)
|
|
16
|
-
|
|
17
|
-
return
|
|
16
|
+
i[o] = o;
|
|
17
|
+
return i;
|
|
18
18
|
}, n.getValidEnumValues = (s) => {
|
|
19
|
-
const
|
|
20
|
-
for (const c of
|
|
19
|
+
const i = n.objectKeys(s).filter((c) => typeof s[s[c]] != "number"), o = {};
|
|
20
|
+
for (const c of i)
|
|
21
21
|
o[c] = s[c];
|
|
22
22
|
return n.objectValues(o);
|
|
23
|
-
}, n.objectValues = (s) => n.objectKeys(s).map(function(
|
|
24
|
-
return s[
|
|
23
|
+
}, n.objectValues = (s) => n.objectKeys(s).map(function(i) {
|
|
24
|
+
return s[i];
|
|
25
25
|
}), n.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
|
|
26
|
-
const
|
|
26
|
+
const i = [];
|
|
27
27
|
for (const o in s)
|
|
28
|
-
Object.prototype.hasOwnProperty.call(s, o) &&
|
|
29
|
-
return
|
|
30
|
-
}, n.find = (s,
|
|
28
|
+
Object.prototype.hasOwnProperty.call(s, o) && i.push(o);
|
|
29
|
+
return i;
|
|
30
|
+
}, n.find = (s, i) => {
|
|
31
31
|
for (const o of s)
|
|
32
|
-
if (
|
|
32
|
+
if (i(o))
|
|
33
33
|
return o;
|
|
34
34
|
}, n.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
|
|
35
|
-
function r(s,
|
|
36
|
-
return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(
|
|
35
|
+
function r(s, i = " | ") {
|
|
36
|
+
return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(i);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues = r, n.jsonStringifyReplacer = (s,
|
|
38
|
+
n.joinValues = r, n.jsonStringifyReplacer = (s, i) => typeof i == "bigint" ? i.toString() : i;
|
|
39
39
|
})(x || (x = {}));
|
|
40
40
|
var De;
|
|
41
41
|
(function(n) {
|
|
@@ -45,7 +45,7 @@ var De;
|
|
|
45
45
|
// second overwrites first
|
|
46
46
|
});
|
|
47
47
|
})(De || (De = {}));
|
|
48
|
-
const
|
|
48
|
+
const p = x.arrayToEnum([
|
|
49
49
|
"string",
|
|
50
50
|
"nan",
|
|
51
51
|
"number",
|
|
@@ -66,28 +66,28 @@ const f = x.arrayToEnum([
|
|
|
66
66
|
"never",
|
|
67
67
|
"map",
|
|
68
68
|
"set"
|
|
69
|
-
]),
|
|
69
|
+
]), R = (n) => {
|
|
70
70
|
switch (typeof n) {
|
|
71
71
|
case "undefined":
|
|
72
|
-
return
|
|
72
|
+
return p.undefined;
|
|
73
73
|
case "string":
|
|
74
|
-
return
|
|
74
|
+
return p.string;
|
|
75
75
|
case "number":
|
|
76
|
-
return isNaN(n) ?
|
|
76
|
+
return isNaN(n) ? p.nan : p.number;
|
|
77
77
|
case "boolean":
|
|
78
|
-
return
|
|
78
|
+
return p.boolean;
|
|
79
79
|
case "function":
|
|
80
|
-
return
|
|
80
|
+
return p.function;
|
|
81
81
|
case "bigint":
|
|
82
|
-
return
|
|
82
|
+
return p.bigint;
|
|
83
83
|
case "symbol":
|
|
84
|
-
return
|
|
84
|
+
return p.symbol;
|
|
85
85
|
case "object":
|
|
86
|
-
return Array.isArray(n) ?
|
|
86
|
+
return Array.isArray(n) ? p.array : n === null ? p.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? p.promise : typeof Map < "u" && n instanceof Map ? p.map : typeof Set < "u" && n instanceof Set ? p.set : typeof Date < "u" && n instanceof Date ? p.date : p.object;
|
|
87
87
|
default:
|
|
88
|
-
return
|
|
88
|
+
return p.unknown;
|
|
89
89
|
}
|
|
90
|
-
},
|
|
90
|
+
}, d = x.arrayToEnum([
|
|
91
91
|
"invalid_type",
|
|
92
92
|
"invalid_literal",
|
|
93
93
|
"custom",
|
|
@@ -104,8 +104,8 @@ const f = x.arrayToEnum([
|
|
|
104
104
|
"invalid_intersection_types",
|
|
105
105
|
"not_multiple_of",
|
|
106
106
|
"not_finite"
|
|
107
|
-
]),
|
|
108
|
-
class
|
|
107
|
+
]), ut = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
108
|
+
class N extends Error {
|
|
109
109
|
get errors() {
|
|
110
110
|
return this.issues;
|
|
111
111
|
}
|
|
@@ -119,10 +119,10 @@ class S extends Error {
|
|
|
119
119
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
120
120
|
}
|
|
121
121
|
format(e) {
|
|
122
|
-
const t = e || function(
|
|
123
|
-
return
|
|
124
|
-
}, r = { _errors: [] }, s = (
|
|
125
|
-
for (const o of
|
|
122
|
+
const t = e || function(i) {
|
|
123
|
+
return i.message;
|
|
124
|
+
}, r = { _errors: [] }, s = (i) => {
|
|
125
|
+
for (const o of i.issues)
|
|
126
126
|
if (o.code === "invalid_union")
|
|
127
127
|
o.unionErrors.map(s);
|
|
128
128
|
else if (o.code === "invalid_return_type")
|
|
@@ -134,15 +134,15 @@ class S extends Error {
|
|
|
134
134
|
else {
|
|
135
135
|
let c = r, l = 0;
|
|
136
136
|
for (; l < o.path.length; ) {
|
|
137
|
-
const
|
|
138
|
-
l === o.path.length - 1 ? (c[
|
|
137
|
+
const u = o.path[l];
|
|
138
|
+
l === o.path.length - 1 ? (c[u] = c[u] || { _errors: [] }, c[u]._errors.push(t(o))) : c[u] = c[u] || { _errors: [] }, c = c[u], l++;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
return s(this), r;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
|
-
if (!(e instanceof
|
|
145
|
+
if (!(e instanceof N))
|
|
146
146
|
throw new Error(`Not a ZodError: ${e}`);
|
|
147
147
|
}
|
|
148
148
|
toString() {
|
|
@@ -164,56 +164,56 @@ class S extends Error {
|
|
|
164
164
|
return this.flatten();
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
N.create = (n) => new N(n);
|
|
168
168
|
const J = (n, e) => {
|
|
169
169
|
let t;
|
|
170
170
|
switch (n.code) {
|
|
171
|
-
case
|
|
172
|
-
n.received ===
|
|
171
|
+
case d.invalid_type:
|
|
172
|
+
n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
173
173
|
break;
|
|
174
|
-
case
|
|
174
|
+
case d.invalid_literal:
|
|
175
175
|
t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
|
|
176
176
|
break;
|
|
177
|
-
case
|
|
177
|
+
case d.unrecognized_keys:
|
|
178
178
|
t = `Unrecognized key(s) in object: ${x.joinValues(n.keys, ", ")}`;
|
|
179
179
|
break;
|
|
180
|
-
case
|
|
180
|
+
case d.invalid_union:
|
|
181
181
|
t = "Invalid input";
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
183
|
+
case d.invalid_union_discriminator:
|
|
184
184
|
t = `Invalid discriminator value. Expected ${x.joinValues(n.options)}`;
|
|
185
185
|
break;
|
|
186
|
-
case
|
|
186
|
+
case d.invalid_enum_value:
|
|
187
187
|
t = `Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;
|
|
188
188
|
break;
|
|
189
|
-
case
|
|
189
|
+
case d.invalid_arguments:
|
|
190
190
|
t = "Invalid function arguments";
|
|
191
191
|
break;
|
|
192
|
-
case
|
|
192
|
+
case d.invalid_return_type:
|
|
193
193
|
t = "Invalid function return type";
|
|
194
194
|
break;
|
|
195
|
-
case
|
|
195
|
+
case d.invalid_date:
|
|
196
196
|
t = "Invalid date";
|
|
197
197
|
break;
|
|
198
|
-
case
|
|
198
|
+
case d.invalid_string:
|
|
199
199
|
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : x.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
200
200
|
break;
|
|
201
|
-
case
|
|
201
|
+
case d.too_small:
|
|
202
202
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
203
203
|
break;
|
|
204
|
-
case
|
|
204
|
+
case d.too_big:
|
|
205
205
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
206
206
|
break;
|
|
207
|
-
case
|
|
207
|
+
case d.custom:
|
|
208
208
|
t = "Invalid input";
|
|
209
209
|
break;
|
|
210
|
-
case
|
|
210
|
+
case d.invalid_intersection_types:
|
|
211
211
|
t = "Intersection results could not be merged";
|
|
212
212
|
break;
|
|
213
|
-
case
|
|
213
|
+
case d.not_multiple_of:
|
|
214
214
|
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
215
215
|
break;
|
|
216
|
-
case
|
|
216
|
+
case d.not_finite:
|
|
217
217
|
t = "Number must be finite";
|
|
218
218
|
break;
|
|
219
219
|
default:
|
|
@@ -229,26 +229,26 @@ function ve() {
|
|
|
229
229
|
return Ue;
|
|
230
230
|
}
|
|
231
231
|
const _e = (n) => {
|
|
232
|
-
const { data: e, path: t, errorMaps: r, issueData: s } = n,
|
|
232
|
+
const { data: e, path: t, errorMaps: r, issueData: s } = n, i = [...t, ...s.path || []], o = {
|
|
233
233
|
...s,
|
|
234
|
-
path:
|
|
234
|
+
path: i
|
|
235
235
|
};
|
|
236
236
|
if (s.message !== void 0)
|
|
237
237
|
return {
|
|
238
238
|
...s,
|
|
239
|
-
path:
|
|
239
|
+
path: i,
|
|
240
240
|
message: s.message
|
|
241
241
|
};
|
|
242
242
|
let c = "";
|
|
243
|
-
const l = r.filter((
|
|
244
|
-
for (const
|
|
245
|
-
c =
|
|
243
|
+
const l = r.filter((u) => !!u).slice().reverse();
|
|
244
|
+
for (const u of l)
|
|
245
|
+
c = u(o, { data: e, defaultError: c }).message;
|
|
246
246
|
return {
|
|
247
247
|
...s,
|
|
248
|
-
path:
|
|
248
|
+
path: i,
|
|
249
249
|
message: c
|
|
250
250
|
};
|
|
251
|
-
},
|
|
251
|
+
}, lt = [];
|
|
252
252
|
function m(n, e) {
|
|
253
253
|
const t = ve(), r = _e({
|
|
254
254
|
issueData: e,
|
|
@@ -289,9 +289,9 @@ class T {
|
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
290
|
const r = [];
|
|
291
291
|
for (const s of t) {
|
|
292
|
-
const
|
|
292
|
+
const i = await s.key, o = await s.value;
|
|
293
293
|
r.push({
|
|
294
|
-
key:
|
|
294
|
+
key: i,
|
|
295
295
|
value: o
|
|
296
296
|
});
|
|
297
297
|
}
|
|
@@ -300,17 +300,17 @@ class T {
|
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
301
|
const r = {};
|
|
302
302
|
for (const s of t) {
|
|
303
|
-
const { key:
|
|
304
|
-
if (
|
|
303
|
+
const { key: i, value: o } = s;
|
|
304
|
+
if (i.status === "aborted" || o.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
|
|
306
|
+
i.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof o.value < "u" || s.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 }),
|
|
313
|
+
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }), Oe = (n) => n.status === "aborted", Pe = (n) => n.status === "dirty", q = (n) => n.status === "valid", 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);
|
|
@@ -342,7 +342,7 @@ const Ve = (n, e) => {
|
|
|
342
342
|
get error() {
|
|
343
343
|
if (this._error)
|
|
344
344
|
return this._error;
|
|
345
|
-
const t = new
|
|
345
|
+
const t = new N(n.common.issues);
|
|
346
346
|
return this._error = t, this._error;
|
|
347
347
|
}
|
|
348
348
|
};
|
|
@@ -354,9 +354,9 @@ function v(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
356
|
return e ? { errorMap: e, description: s } : { errorMap: (o, c) => {
|
|
357
|
-
var l,
|
|
358
|
-
const { message:
|
|
359
|
-
return o.code === "invalid_enum_value" ? { message:
|
|
357
|
+
var l, u;
|
|
358
|
+
const { message: f } = n;
|
|
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
360
|
}, description: s };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
@@ -364,13 +364,13 @@ class _ {
|
|
|
364
364
|
return this._def.description;
|
|
365
365
|
}
|
|
366
366
|
_getType(e) {
|
|
367
|
-
return
|
|
367
|
+
return R(e.data);
|
|
368
368
|
}
|
|
369
369
|
_getOrReturnCtx(e, t) {
|
|
370
370
|
return t || {
|
|
371
371
|
common: e.parent.common,
|
|
372
372
|
data: e.data,
|
|
373
|
-
parsedType:
|
|
373
|
+
parsedType: R(e.data),
|
|
374
374
|
schemaErrorMap: this._def.errorMap,
|
|
375
375
|
path: e.path,
|
|
376
376
|
parent: e.parent
|
|
@@ -382,7 +382,7 @@ class _ {
|
|
|
382
382
|
ctx: {
|
|
383
383
|
common: e.parent.common,
|
|
384
384
|
data: e.data,
|
|
385
|
-
parsedType:
|
|
385
|
+
parsedType: R(e.data),
|
|
386
386
|
schemaErrorMap: this._def.errorMap,
|
|
387
387
|
path: e.path,
|
|
388
388
|
parent: e.parent
|
|
@@ -417,9 +417,9 @@ class _ {
|
|
|
417
417
|
schemaErrorMap: this._def.errorMap,
|
|
418
418
|
parent: null,
|
|
419
419
|
data: e,
|
|
420
|
-
parsedType:
|
|
421
|
-
},
|
|
422
|
-
return Ve(s,
|
|
420
|
+
parsedType: R(e)
|
|
421
|
+
}, i = this._parseSync({ data: e, path: s.path, parent: s });
|
|
422
|
+
return Ve(s, i);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
425
|
var t, r;
|
|
@@ -432,24 +432,24 @@ class _ {
|
|
|
432
432
|
schemaErrorMap: this._def.errorMap,
|
|
433
433
|
parent: null,
|
|
434
434
|
data: e,
|
|
435
|
-
parsedType:
|
|
435
|
+
parsedType: R(e)
|
|
436
436
|
};
|
|
437
437
|
if (!this["~standard"].async)
|
|
438
438
|
try {
|
|
439
|
-
const
|
|
440
|
-
return q(
|
|
441
|
-
value:
|
|
439
|
+
const i = this._parseSync({ data: e, path: [], parent: s });
|
|
440
|
+
return q(i) ? {
|
|
441
|
+
value: i.value
|
|
442
442
|
} : {
|
|
443
443
|
issues: s.common.issues
|
|
444
444
|
};
|
|
445
|
-
} catch (
|
|
446
|
-
!((r = (t =
|
|
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), s.common = {
|
|
447
447
|
issues: [],
|
|
448
448
|
async: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
return this._parseAsync({ data: e, path: [], parent: s }).then((
|
|
452
|
-
value:
|
|
451
|
+
return this._parseAsync({ data: e, path: [], parent: s }).then((i) => q(i) ? {
|
|
452
|
+
value: i.value
|
|
453
453
|
} : {
|
|
454
454
|
issues: s.common.issues
|
|
455
455
|
});
|
|
@@ -471,15 +471,15 @@ class _ {
|
|
|
471
471
|
schemaErrorMap: this._def.errorMap,
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
|
-
parsedType:
|
|
475
|
-
}, s = this._parse({ data: e, path: r.path, parent: r }),
|
|
476
|
-
return Ve(r,
|
|
474
|
+
parsedType: R(e)
|
|
475
|
+
}, s = this._parse({ data: e, path: r.path, parent: r }), i = await (se(s) ? s : Promise.resolve(s));
|
|
476
|
+
return Ve(r, i);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
479
|
const r = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
480
|
-
return this._refinement((s,
|
|
481
|
-
const o = e(s), c = () =>
|
|
482
|
-
code:
|
|
480
|
+
return this._refinement((s, i) => {
|
|
481
|
+
const o = e(s), c = () => i.addIssue({
|
|
482
|
+
code: d.custom,
|
|
483
483
|
...r(s)
|
|
484
484
|
});
|
|
485
485
|
return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
@@ -518,13 +518,13 @@ class _ {
|
|
|
518
518
|
return C.create(this);
|
|
519
519
|
}
|
|
520
520
|
promise() {
|
|
521
|
-
return
|
|
521
|
+
return H.create(this, this._def);
|
|
522
522
|
}
|
|
523
523
|
or(e) {
|
|
524
524
|
return ce.create([this, e], this._def);
|
|
525
525
|
}
|
|
526
526
|
and(e) {
|
|
527
|
-
return
|
|
527
|
+
return ue.create(this, e, this._def);
|
|
528
528
|
}
|
|
529
529
|
transform(e) {
|
|
530
530
|
return new Z({
|
|
@@ -536,7 +536,7 @@ class _ {
|
|
|
536
536
|
}
|
|
537
537
|
default(e) {
|
|
538
538
|
const t = typeof e == "function" ? e : () => e;
|
|
539
|
-
return new
|
|
539
|
+
return new fe({
|
|
540
540
|
...v(this._def),
|
|
541
541
|
innerType: this,
|
|
542
542
|
defaultValue: t,
|
|
@@ -544,7 +544,7 @@ class _ {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
brand() {
|
|
547
|
-
return new
|
|
547
|
+
return new Re({
|
|
548
548
|
typeName: g.ZodBranded,
|
|
549
549
|
type: this,
|
|
550
550
|
...v(this._def)
|
|
@@ -579,14 +579,14 @@ class _ {
|
|
|
579
579
|
return this.safeParse(null).success;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
const
|
|
582
|
+
const mt = /^c[^\s-]{8,}$/i, pt = /^[0-9a-z]+$/, ft = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ht = /^[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, gt = /^[a-z0-9_-]{21}$/i, yt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, vt = /^[-+]?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)?)??$/, _t = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, bt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
583
|
let Ze;
|
|
584
|
-
const
|
|
584
|
+
const xt = /^(?:(?: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])$/, kt = /^(?:(?: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])$/, wt = /^(([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]))$/, Tt = /^(([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])$/, St = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, It = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, qe = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Nt = new RegExp(`^${qe}$`);
|
|
585
585
|
function Be(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 At(n) {
|
|
590
590
|
return new RegExp(`^${Be(n)}$`);
|
|
591
591
|
}
|
|
592
592
|
function We(n) {
|
|
@@ -594,11 +594,11 @@ function We(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 Nt(n, e) {
|
|
598
|
-
return !!((e === "v4" || !e) && bt.test(n) || (e === "v6" || !e) && kt.test(n));
|
|
599
|
-
}
|
|
600
597
|
function Ct(n, e) {
|
|
601
|
-
|
|
598
|
+
return !!((e === "v4" || !e) && xt.test(n) || (e === "v6" || !e) && wt.test(n));
|
|
599
|
+
}
|
|
600
|
+
function Zt(n, e) {
|
|
601
|
+
if (!yt.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
604
|
const [t] = n.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(r));
|
|
@@ -607,173 +607,173 @@ function Ct(n, e) {
|
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return !!((e === "v4" || !e) &&
|
|
610
|
+
function jt(n, e) {
|
|
611
|
+
return !!((e === "v4" || !e) && kt.test(n) || (e === "v6" || !e) && Tt.test(n));
|
|
612
612
|
}
|
|
613
|
-
class
|
|
613
|
+
class A extends _ {
|
|
614
614
|
_parse(e) {
|
|
615
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !==
|
|
616
|
-
const
|
|
617
|
-
return m(
|
|
618
|
-
code:
|
|
619
|
-
expected:
|
|
620
|
-
received:
|
|
615
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
|
|
616
|
+
const i = this._getOrReturnCtx(e);
|
|
617
|
+
return m(i, {
|
|
618
|
+
code: d.invalid_type,
|
|
619
|
+
expected: p.string,
|
|
620
|
+
received: i.parsedType
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
623
|
const r = new T();
|
|
624
624
|
let s;
|
|
625
|
-
for (const
|
|
626
|
-
if (
|
|
627
|
-
e.data.length <
|
|
628
|
-
code:
|
|
629
|
-
minimum:
|
|
625
|
+
for (const i of this._def.checks)
|
|
626
|
+
if (i.kind === "min")
|
|
627
|
+
e.data.length < i.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
628
|
+
code: d.too_small,
|
|
629
|
+
minimum: i.value,
|
|
630
630
|
type: "string",
|
|
631
631
|
inclusive: !0,
|
|
632
632
|
exact: !1,
|
|
633
|
-
message:
|
|
633
|
+
message: i.message
|
|
634
634
|
}), r.dirty());
|
|
635
|
-
else if (
|
|
636
|
-
e.data.length >
|
|
637
|
-
code:
|
|
638
|
-
maximum:
|
|
635
|
+
else if (i.kind === "max")
|
|
636
|
+
e.data.length > i.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
637
|
+
code: d.too_big,
|
|
638
|
+
maximum: i.value,
|
|
639
639
|
type: "string",
|
|
640
640
|
inclusive: !0,
|
|
641
641
|
exact: !1,
|
|
642
|
-
message:
|
|
642
|
+
message: i.message
|
|
643
643
|
}), r.dirty());
|
|
644
|
-
else if (
|
|
645
|
-
const o = e.data.length >
|
|
644
|
+
else if (i.kind === "length") {
|
|
645
|
+
const o = e.data.length > i.value, c = e.data.length < i.value;
|
|
646
646
|
(o || c) && (s = this._getOrReturnCtx(e, s), o ? m(s, {
|
|
647
|
-
code:
|
|
648
|
-
maximum:
|
|
647
|
+
code: d.too_big,
|
|
648
|
+
maximum: i.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
|
-
message:
|
|
652
|
+
message: i.message
|
|
653
653
|
}) : c && m(s, {
|
|
654
|
-
code:
|
|
655
|
-
minimum:
|
|
654
|
+
code: d.too_small,
|
|
655
|
+
minimum: i.value,
|
|
656
656
|
type: "string",
|
|
657
657
|
inclusive: !0,
|
|
658
658
|
exact: !0,
|
|
659
|
-
message:
|
|
659
|
+
message: i.message
|
|
660
660
|
}), r.dirty());
|
|
661
|
-
} else if (
|
|
662
|
-
|
|
661
|
+
} else if (i.kind === "email")
|
|
662
|
+
_t.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
663
663
|
validation: "email",
|
|
664
|
-
code:
|
|
665
|
-
message:
|
|
664
|
+
code: d.invalid_string,
|
|
665
|
+
message: i.message
|
|
666
666
|
}), r.dirty());
|
|
667
|
-
else if (
|
|
668
|
-
Ze || (Ze = new RegExp(
|
|
667
|
+
else if (i.kind === "emoji")
|
|
668
|
+
Ze || (Ze = new RegExp(bt, "u")), Ze.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
669
669
|
validation: "emoji",
|
|
670
|
-
code:
|
|
671
|
-
message:
|
|
670
|
+
code: d.invalid_string,
|
|
671
|
+
message: i.message
|
|
672
672
|
}), r.dirty());
|
|
673
|
-
else if (
|
|
674
|
-
|
|
673
|
+
else if (i.kind === "uuid")
|
|
674
|
+
ht.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
675
675
|
validation: "uuid",
|
|
676
|
-
code:
|
|
677
|
-
message:
|
|
676
|
+
code: d.invalid_string,
|
|
677
|
+
message: i.message
|
|
678
678
|
}), r.dirty());
|
|
679
|
-
else if (
|
|
680
|
-
|
|
679
|
+
else if (i.kind === "nanoid")
|
|
680
|
+
gt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
681
681
|
validation: "nanoid",
|
|
682
|
-
code:
|
|
683
|
-
message:
|
|
682
|
+
code: d.invalid_string,
|
|
683
|
+
message: i.message
|
|
684
684
|
}), r.dirty());
|
|
685
|
-
else if (
|
|
686
|
-
|
|
685
|
+
else if (i.kind === "cuid")
|
|
686
|
+
mt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
687
687
|
validation: "cuid",
|
|
688
|
-
code:
|
|
689
|
-
message:
|
|
688
|
+
code: d.invalid_string,
|
|
689
|
+
message: i.message
|
|
690
690
|
}), r.dirty());
|
|
691
|
-
else if (
|
|
692
|
-
|
|
691
|
+
else if (i.kind === "cuid2")
|
|
692
|
+
pt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
693
693
|
validation: "cuid2",
|
|
694
|
-
code:
|
|
695
|
-
message:
|
|
694
|
+
code: d.invalid_string,
|
|
695
|
+
message: i.message
|
|
696
696
|
}), r.dirty());
|
|
697
|
-
else if (
|
|
697
|
+
else if (i.kind === "ulid")
|
|
698
698
|
ft.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
699
699
|
validation: "ulid",
|
|
700
|
-
code:
|
|
701
|
-
message:
|
|
700
|
+
code: d.invalid_string,
|
|
701
|
+
message: i.message
|
|
702
702
|
}), r.dirty());
|
|
703
|
-
else if (
|
|
703
|
+
else if (i.kind === "url")
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
707
|
s = this._getOrReturnCtx(e, s), m(s, {
|
|
708
708
|
validation: "url",
|
|
709
|
-
code:
|
|
710
|
-
message:
|
|
709
|
+
code: d.invalid_string,
|
|
710
|
+
message: i.message
|
|
711
711
|
}), r.dirty();
|
|
712
712
|
}
|
|
713
|
-
else
|
|
713
|
+
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
714
714
|
validation: "regex",
|
|
715
|
-
code:
|
|
716
|
-
message:
|
|
717
|
-
}), r.dirty())) :
|
|
718
|
-
code:
|
|
719
|
-
validation: { includes:
|
|
720
|
-
message:
|
|
721
|
-
}), r.dirty()) :
|
|
722
|
-
code:
|
|
723
|
-
validation: { startsWith:
|
|
724
|
-
message:
|
|
725
|
-
}), r.dirty()) :
|
|
726
|
-
code:
|
|
727
|
-
validation: { endsWith:
|
|
728
|
-
message:
|
|
729
|
-
}), r.dirty()) :
|
|
730
|
-
code:
|
|
715
|
+
code: d.invalid_string,
|
|
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) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
718
|
+
code: d.invalid_string,
|
|
719
|
+
validation: { includes: i.value, position: i.position },
|
|
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) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
722
|
+
code: d.invalid_string,
|
|
723
|
+
validation: { startsWith: i.value },
|
|
724
|
+
message: i.message
|
|
725
|
+
}), r.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
726
|
+
code: d.invalid_string,
|
|
727
|
+
validation: { endsWith: i.value },
|
|
728
|
+
message: i.message
|
|
729
|
+
}), r.dirty()) : i.kind === "datetime" ? We(i).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
730
|
+
code: d.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
|
-
message:
|
|
733
|
-
}), r.dirty()) :
|
|
734
|
-
code:
|
|
732
|
+
message: i.message
|
|
733
|
+
}), r.dirty()) : i.kind === "date" ? Nt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
734
|
+
code: d.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
|
-
message:
|
|
737
|
-
}), r.dirty()) :
|
|
738
|
-
code:
|
|
736
|
+
message: i.message
|
|
737
|
+
}), r.dirty()) : i.kind === "time" ? At(i).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
738
|
+
code: d.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
|
-
message:
|
|
741
|
-
}), r.dirty()) :
|
|
740
|
+
message: i.message
|
|
741
|
+
}), r.dirty()) : i.kind === "duration" ? vt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
742
742
|
validation: "duration",
|
|
743
|
-
code:
|
|
744
|
-
message:
|
|
745
|
-
}), r.dirty()) :
|
|
743
|
+
code: d.invalid_string,
|
|
744
|
+
message: i.message
|
|
745
|
+
}), r.dirty()) : i.kind === "ip" ? Ct(e.data, i.version) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
746
746
|
validation: "ip",
|
|
747
|
-
code:
|
|
748
|
-
message:
|
|
749
|
-
}), r.dirty()) :
|
|
747
|
+
code: d.invalid_string,
|
|
748
|
+
message: i.message
|
|
749
|
+
}), r.dirty()) : i.kind === "jwt" ? Zt(e.data, i.alg) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
750
750
|
validation: "jwt",
|
|
751
|
-
code:
|
|
752
|
-
message:
|
|
753
|
-
}), r.dirty()) :
|
|
751
|
+
code: d.invalid_string,
|
|
752
|
+
message: i.message
|
|
753
|
+
}), r.dirty()) : i.kind === "cidr" ? jt(e.data, i.version) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
754
754
|
validation: "cidr",
|
|
755
|
-
code:
|
|
756
|
-
message:
|
|
757
|
-
}), r.dirty()) :
|
|
755
|
+
code: d.invalid_string,
|
|
756
|
+
message: i.message
|
|
757
|
+
}), r.dirty()) : i.kind === "base64" ? St.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
758
758
|
validation: "base64",
|
|
759
|
-
code:
|
|
760
|
-
message:
|
|
761
|
-
}), r.dirty()) :
|
|
759
|
+
code: d.invalid_string,
|
|
760
|
+
message: i.message
|
|
761
|
+
}), r.dirty()) : i.kind === "base64url" ? It.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
762
762
|
validation: "base64url",
|
|
763
|
-
code:
|
|
764
|
-
message:
|
|
765
|
-
}), r.dirty()) : x.assertNever(
|
|
763
|
+
code: d.invalid_string,
|
|
764
|
+
message: i.message
|
|
765
|
+
}), r.dirty()) : x.assertNever(i);
|
|
766
766
|
return { status: r.value, value: e.data };
|
|
767
767
|
}
|
|
768
768
|
_regex(e, t, r) {
|
|
769
769
|
return this.refinement((s) => e.test(s), {
|
|
770
770
|
validation: t,
|
|
771
|
-
code:
|
|
771
|
+
code: d.invalid_string,
|
|
772
772
|
...h.errToObj(r)
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
_addCheck(e) {
|
|
776
|
-
return new
|
|
776
|
+
return new A({
|
|
777
777
|
...this._def,
|
|
778
778
|
checks: [...this._def.checks, e]
|
|
779
779
|
});
|
|
@@ -910,19 +910,19 @@ class N extends _ {
|
|
|
910
910
|
return this.min(1, h.errToObj(e));
|
|
911
911
|
}
|
|
912
912
|
trim() {
|
|
913
|
-
return new
|
|
913
|
+
return new A({
|
|
914
914
|
...this._def,
|
|
915
915
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
918
|
toLowerCase() {
|
|
919
|
-
return new
|
|
919
|
+
return new A({
|
|
920
920
|
...this._def,
|
|
921
921
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
922
922
|
});
|
|
923
923
|
}
|
|
924
924
|
toUpperCase() {
|
|
925
|
-
return new
|
|
925
|
+
return new A({
|
|
926
926
|
...this._def,
|
|
927
927
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
928
928
|
});
|
|
@@ -988,62 +988,62 @@ class N extends _ {
|
|
|
988
988
|
return e;
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
|
-
|
|
991
|
+
A.create = (n) => {
|
|
992
992
|
var e;
|
|
993
|
-
return new
|
|
993
|
+
return new A({
|
|
994
994
|
checks: [],
|
|
995
995
|
typeName: g.ZodString,
|
|
996
996
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
|
|
997
997
|
...v(n)
|
|
998
998
|
});
|
|
999
999
|
};
|
|
1000
|
-
function
|
|
1001
|
-
const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r,
|
|
1002
|
-
return
|
|
1000
|
+
function Dt(n, e) {
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r, i = parseInt(n.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
|
|
1002
|
+
return i % o / Math.pow(10, s);
|
|
1003
1003
|
}
|
|
1004
1004
|
class V extends _ {
|
|
1005
1005
|
constructor() {
|
|
1006
1006
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1007
1007
|
}
|
|
1008
1008
|
_parse(e) {
|
|
1009
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !==
|
|
1010
|
-
const
|
|
1011
|
-
return m(
|
|
1012
|
-
code:
|
|
1013
|
-
expected:
|
|
1014
|
-
received:
|
|
1009
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
|
|
1010
|
+
const i = this._getOrReturnCtx(e);
|
|
1011
|
+
return m(i, {
|
|
1012
|
+
code: d.invalid_type,
|
|
1013
|
+
expected: p.number,
|
|
1014
|
+
received: i.parsedType
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
1017
|
let r;
|
|
1018
1018
|
const s = new T();
|
|
1019
|
-
for (const
|
|
1020
|
-
|
|
1021
|
-
code:
|
|
1019
|
+
for (const i of this._def.checks)
|
|
1020
|
+
i.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1021
|
+
code: d.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
|
-
message:
|
|
1025
|
-
}), s.dirty()) :
|
|
1026
|
-
code:
|
|
1027
|
-
minimum:
|
|
1024
|
+
message: i.message
|
|
1025
|
+
}), s.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1026
|
+
code: d.too_small,
|
|
1027
|
+
minimum: i.value,
|
|
1028
1028
|
type: "number",
|
|
1029
|
-
inclusive:
|
|
1029
|
+
inclusive: i.inclusive,
|
|
1030
1030
|
exact: !1,
|
|
1031
|
-
message:
|
|
1032
|
-
}), s.dirty()) :
|
|
1033
|
-
code:
|
|
1034
|
-
maximum:
|
|
1031
|
+
message: i.message
|
|
1032
|
+
}), s.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1033
|
+
code: d.too_big,
|
|
1034
|
+
maximum: i.value,
|
|
1035
1035
|
type: "number",
|
|
1036
|
-
inclusive:
|
|
1036
|
+
inclusive: i.inclusive,
|
|
1037
1037
|
exact: !1,
|
|
1038
|
-
message:
|
|
1039
|
-
}), s.dirty()) :
|
|
1040
|
-
code:
|
|
1041
|
-
multipleOf:
|
|
1042
|
-
message:
|
|
1043
|
-
}), s.dirty()) :
|
|
1044
|
-
code:
|
|
1045
|
-
message:
|
|
1046
|
-
}), s.dirty()) : x.assertNever(
|
|
1038
|
+
message: i.message
|
|
1039
|
+
}), s.dirty()) : i.kind === "multipleOf" ? Dt(e.data, i.value) !== 0 && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1040
|
+
code: d.not_multiple_of,
|
|
1041
|
+
multipleOf: i.value,
|
|
1042
|
+
message: i.message
|
|
1043
|
+
}), s.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1044
|
+
code: d.not_finite,
|
|
1045
|
+
message: i.message
|
|
1046
|
+
}), s.dirty()) : x.assertNever(i);
|
|
1047
1047
|
return { status: s.value, value: e.data };
|
|
1048
1048
|
}
|
|
1049
1049
|
gte(e, t) {
|
|
@@ -1173,7 +1173,7 @@ V.create = (n) => new V({
|
|
|
1173
1173
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1174
1174
|
...v(n)
|
|
1175
1175
|
});
|
|
1176
|
-
class
|
|
1176
|
+
class z extends _ {
|
|
1177
1177
|
constructor() {
|
|
1178
1178
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1179
1179
|
}
|
|
@@ -1184,35 +1184,35 @@ class F extends _ {
|
|
|
1184
1184
|
} catch {
|
|
1185
1185
|
return this._getInvalidInput(e);
|
|
1186
1186
|
}
|
|
1187
|
-
if (this._getType(e) !==
|
|
1187
|
+
if (this._getType(e) !== p.bigint)
|
|
1188
1188
|
return this._getInvalidInput(e);
|
|
1189
1189
|
let r;
|
|
1190
1190
|
const s = new T();
|
|
1191
|
-
for (const
|
|
1192
|
-
|
|
1193
|
-
code:
|
|
1191
|
+
for (const i of this._def.checks)
|
|
1192
|
+
i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1193
|
+
code: d.too_small,
|
|
1194
1194
|
type: "bigint",
|
|
1195
|
-
minimum:
|
|
1196
|
-
inclusive:
|
|
1197
|
-
message:
|
|
1198
|
-
}), s.dirty()) :
|
|
1199
|
-
code:
|
|
1195
|
+
minimum: i.value,
|
|
1196
|
+
inclusive: i.inclusive,
|
|
1197
|
+
message: i.message
|
|
1198
|
+
}), s.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1199
|
+
code: d.too_big,
|
|
1200
1200
|
type: "bigint",
|
|
1201
|
-
maximum:
|
|
1202
|
-
inclusive:
|
|
1203
|
-
message:
|
|
1204
|
-
}), s.dirty()) :
|
|
1205
|
-
code:
|
|
1206
|
-
multipleOf:
|
|
1207
|
-
message:
|
|
1208
|
-
}), s.dirty()) : x.assertNever(
|
|
1201
|
+
maximum: i.value,
|
|
1202
|
+
inclusive: i.inclusive,
|
|
1203
|
+
message: i.message
|
|
1204
|
+
}), s.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), m(r, {
|
|
1205
|
+
code: d.not_multiple_of,
|
|
1206
|
+
multipleOf: i.value,
|
|
1207
|
+
message: i.message
|
|
1208
|
+
}), s.dirty()) : x.assertNever(i);
|
|
1209
1209
|
return { status: s.value, value: e.data };
|
|
1210
1210
|
}
|
|
1211
1211
|
_getInvalidInput(e) {
|
|
1212
1212
|
const t = this._getOrReturnCtx(e);
|
|
1213
1213
|
return m(t, {
|
|
1214
|
-
code:
|
|
1215
|
-
expected:
|
|
1214
|
+
code: d.invalid_type,
|
|
1215
|
+
expected: p.bigint,
|
|
1216
1216
|
received: t.parsedType
|
|
1217
1217
|
}), y;
|
|
1218
1218
|
}
|
|
@@ -1229,7 +1229,7 @@ class F extends _ {
|
|
|
1229
1229
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1230
1230
|
}
|
|
1231
1231
|
setLimit(e, t, r, s) {
|
|
1232
|
-
return new
|
|
1232
|
+
return new z({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
1235
1235
|
...this._def.checks,
|
|
@@ -1243,7 +1243,7 @@ class F extends _ {
|
|
|
1243
1243
|
});
|
|
1244
1244
|
}
|
|
1245
1245
|
_addCheck(e) {
|
|
1246
|
-
return new
|
|
1246
|
+
return new z({
|
|
1247
1247
|
...this._def,
|
|
1248
1248
|
checks: [...this._def.checks, e]
|
|
1249
1249
|
});
|
|
@@ -1300,9 +1300,9 @@ class F extends _ {
|
|
|
1300
1300
|
return e;
|
|
1301
1301
|
}
|
|
1302
1302
|
}
|
|
1303
|
-
|
|
1303
|
+
z.create = (n) => {
|
|
1304
1304
|
var e;
|
|
1305
|
-
return new
|
|
1305
|
+
return new z({
|
|
1306
1306
|
checks: [],
|
|
1307
1307
|
typeName: g.ZodBigInt,
|
|
1308
1308
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
|
|
@@ -1311,15 +1311,15 @@ F.create = (n) => {
|
|
|
1311
1311
|
};
|
|
1312
1312
|
class ae extends _ {
|
|
1313
1313
|
_parse(e) {
|
|
1314
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !==
|
|
1314
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
1315
1315
|
const r = this._getOrReturnCtx(e);
|
|
1316
1316
|
return m(r, {
|
|
1317
|
-
code:
|
|
1318
|
-
expected:
|
|
1317
|
+
code: d.invalid_type,
|
|
1318
|
+
expected: p.boolean,
|
|
1319
1319
|
received: r.parsedType
|
|
1320
1320
|
}), y;
|
|
1321
1321
|
}
|
|
1322
|
-
return
|
|
1322
|
+
return S(e.data);
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
1325
|
ae.create = (n) => new ae({
|
|
@@ -1329,38 +1329,38 @@ ae.create = (n) => new ae({
|
|
|
1329
1329
|
});
|
|
1330
1330
|
class B extends _ {
|
|
1331
1331
|
_parse(e) {
|
|
1332
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !==
|
|
1333
|
-
const
|
|
1334
|
-
return m(
|
|
1335
|
-
code:
|
|
1336
|
-
expected:
|
|
1337
|
-
received:
|
|
1332
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1333
|
+
const i = this._getOrReturnCtx(e);
|
|
1334
|
+
return m(i, {
|
|
1335
|
+
code: d.invalid_type,
|
|
1336
|
+
expected: p.date,
|
|
1337
|
+
received: i.parsedType
|
|
1338
1338
|
}), y;
|
|
1339
1339
|
}
|
|
1340
1340
|
if (isNaN(e.data.getTime())) {
|
|
1341
|
-
const
|
|
1342
|
-
return m(
|
|
1343
|
-
code:
|
|
1341
|
+
const i = this._getOrReturnCtx(e);
|
|
1342
|
+
return m(i, {
|
|
1343
|
+
code: d.invalid_date
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
1346
|
const r = new T();
|
|
1347
1347
|
let s;
|
|
1348
|
-
for (const
|
|
1349
|
-
|
|
1350
|
-
code:
|
|
1351
|
-
message:
|
|
1348
|
+
for (const i of this._def.checks)
|
|
1349
|
+
i.kind === "min" ? e.data.getTime() < i.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
1350
|
+
code: d.too_small,
|
|
1351
|
+
message: i.message,
|
|
1352
1352
|
inclusive: !0,
|
|
1353
1353
|
exact: !1,
|
|
1354
|
-
minimum:
|
|
1354
|
+
minimum: i.value,
|
|
1355
1355
|
type: "date"
|
|
1356
|
-
}), r.dirty()) :
|
|
1357
|
-
code:
|
|
1358
|
-
message:
|
|
1356
|
+
}), r.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
1357
|
+
code: d.too_big,
|
|
1358
|
+
message: i.message,
|
|
1359
1359
|
inclusive: !0,
|
|
1360
1360
|
exact: !1,
|
|
1361
|
-
maximum:
|
|
1361
|
+
maximum: i.value,
|
|
1362
1362
|
type: "date"
|
|
1363
|
-
}), r.dirty()) : x.assertNever(
|
|
1363
|
+
}), r.dirty()) : x.assertNever(i);
|
|
1364
1364
|
return {
|
|
1365
1365
|
status: r.value,
|
|
1366
1366
|
value: new Date(e.data.getTime())
|
|
@@ -1407,15 +1407,15 @@ B.create = (n) => new B({
|
|
|
1407
1407
|
});
|
|
1408
1408
|
class xe extends _ {
|
|
1409
1409
|
_parse(e) {
|
|
1410
|
-
if (this._getType(e) !==
|
|
1410
|
+
if (this._getType(e) !== p.symbol) {
|
|
1411
1411
|
const r = this._getOrReturnCtx(e);
|
|
1412
1412
|
return m(r, {
|
|
1413
|
-
code:
|
|
1414
|
-
expected:
|
|
1413
|
+
code: d.invalid_type,
|
|
1414
|
+
expected: p.symbol,
|
|
1415
1415
|
received: r.parsedType
|
|
1416
1416
|
}), y;
|
|
1417
1417
|
}
|
|
1418
|
-
return
|
|
1418
|
+
return S(e.data);
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
1421
1421
|
xe.create = (n) => new xe({
|
|
@@ -1424,15 +1424,15 @@ xe.create = (n) => new xe({
|
|
|
1424
1424
|
});
|
|
1425
1425
|
class ie extends _ {
|
|
1426
1426
|
_parse(e) {
|
|
1427
|
-
if (this._getType(e) !==
|
|
1427
|
+
if (this._getType(e) !== p.undefined) {
|
|
1428
1428
|
const r = this._getOrReturnCtx(e);
|
|
1429
1429
|
return m(r, {
|
|
1430
|
-
code:
|
|
1431
|
-
expected:
|
|
1430
|
+
code: d.invalid_type,
|
|
1431
|
+
expected: p.undefined,
|
|
1432
1432
|
received: r.parsedType
|
|
1433
1433
|
}), y;
|
|
1434
1434
|
}
|
|
1435
|
-
return
|
|
1435
|
+
return S(e.data);
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
1438
|
ie.create = (n) => new ie({
|
|
@@ -1441,30 +1441,30 @@ ie.create = (n) => new ie({
|
|
|
1441
1441
|
});
|
|
1442
1442
|
class oe extends _ {
|
|
1443
1443
|
_parse(e) {
|
|
1444
|
-
if (this._getType(e) !==
|
|
1444
|
+
if (this._getType(e) !== p.null) {
|
|
1445
1445
|
const r = this._getOrReturnCtx(e);
|
|
1446
1446
|
return m(r, {
|
|
1447
|
-
code:
|
|
1448
|
-
expected:
|
|
1447
|
+
code: d.invalid_type,
|
|
1448
|
+
expected: p.null,
|
|
1449
1449
|
received: r.parsedType
|
|
1450
1450
|
}), y;
|
|
1451
1451
|
}
|
|
1452
|
-
return
|
|
1452
|
+
return S(e.data);
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
1455
|
oe.create = (n) => new oe({
|
|
1456
1456
|
typeName: g.ZodNull,
|
|
1457
1457
|
...v(n)
|
|
1458
1458
|
});
|
|
1459
|
-
class
|
|
1459
|
+
class G extends _ {
|
|
1460
1460
|
constructor() {
|
|
1461
1461
|
super(...arguments), this._any = !0;
|
|
1462
1462
|
}
|
|
1463
1463
|
_parse(e) {
|
|
1464
|
-
return
|
|
1464
|
+
return S(e.data);
|
|
1465
1465
|
}
|
|
1466
1466
|
}
|
|
1467
|
-
|
|
1467
|
+
G.create = (n) => new G({
|
|
1468
1468
|
typeName: g.ZodAny,
|
|
1469
1469
|
...v(n)
|
|
1470
1470
|
});
|
|
@@ -1473,7 +1473,7 @@ class L extends _ {
|
|
|
1473
1473
|
super(...arguments), this._unknown = !0;
|
|
1474
1474
|
}
|
|
1475
1475
|
_parse(e) {
|
|
1476
|
-
return
|
|
1476
|
+
return S(e.data);
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
1479
|
L.create = (n) => new L({
|
|
@@ -1484,8 +1484,8 @@ class $ extends _ {
|
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
const t = this._getOrReturnCtx(e);
|
|
1486
1486
|
return m(t, {
|
|
1487
|
-
code:
|
|
1488
|
-
expected:
|
|
1487
|
+
code: d.invalid_type,
|
|
1488
|
+
expected: p.never,
|
|
1489
1489
|
received: t.parsedType
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
@@ -1496,15 +1496,15 @@ $.create = (n) => new $({
|
|
|
1496
1496
|
});
|
|
1497
1497
|
class ke extends _ {
|
|
1498
1498
|
_parse(e) {
|
|
1499
|
-
if (this._getType(e) !==
|
|
1499
|
+
if (this._getType(e) !== p.undefined) {
|
|
1500
1500
|
const r = this._getOrReturnCtx(e);
|
|
1501
1501
|
return m(r, {
|
|
1502
|
-
code:
|
|
1503
|
-
expected:
|
|
1502
|
+
code: d.invalid_type,
|
|
1503
|
+
expected: p.void,
|
|
1504
1504
|
received: r.parsedType
|
|
1505
1505
|
}), y;
|
|
1506
1506
|
}
|
|
1507
|
-
return
|
|
1507
|
+
return S(e.data);
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
1510
|
ke.create = (n) => new ke({
|
|
@@ -1514,16 +1514,16 @@ ke.create = (n) => new ke({
|
|
|
1514
1514
|
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
1516
|
const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
|
|
1517
|
-
if (t.parsedType !==
|
|
1517
|
+
if (t.parsedType !== p.array)
|
|
1518
1518
|
return m(t, {
|
|
1519
|
-
code:
|
|
1520
|
-
expected:
|
|
1519
|
+
code: d.invalid_type,
|
|
1520
|
+
expected: p.array,
|
|
1521
1521
|
received: t.parsedType
|
|
1522
1522
|
}), y;
|
|
1523
1523
|
if (s.exactLength !== null) {
|
|
1524
1524
|
const o = t.data.length > s.exactLength.value, c = t.data.length < s.exactLength.value;
|
|
1525
1525
|
(o || c) && (m(t, {
|
|
1526
|
-
code: o ?
|
|
1526
|
+
code: o ? d.too_big : d.too_small,
|
|
1527
1527
|
minimum: c ? s.exactLength.value : void 0,
|
|
1528
1528
|
maximum: o ? s.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
@@ -1533,14 +1533,14 @@ class C extends _ {
|
|
|
1533
1533
|
}), r.dirty());
|
|
1534
1534
|
}
|
|
1535
1535
|
if (s.minLength !== null && t.data.length < s.minLength.value && (m(t, {
|
|
1536
|
-
code:
|
|
1536
|
+
code: d.too_small,
|
|
1537
1537
|
minimum: s.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
1541
|
message: s.minLength.message
|
|
1542
1542
|
}), r.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (m(t, {
|
|
1543
|
-
code:
|
|
1543
|
+
code: d.too_big,
|
|
1544
1544
|
maximum: s.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
@@ -1548,8 +1548,8 @@ class C extends _ {
|
|
|
1548
1548
|
message: s.maxLength.message
|
|
1549
1549
|
}), r.dirty()), t.common.async)
|
|
1550
1550
|
return Promise.all([...t.data].map((o, c) => s.type._parseAsync(new O(t, o, t.path, c)))).then((o) => T.mergeArray(r, o));
|
|
1551
|
-
const
|
|
1552
|
-
return T.mergeArray(r,
|
|
1551
|
+
const i = [...t.data].map((o, c) => s.type._parseSync(new O(t, o, t.path, c)));
|
|
1552
|
+
return T.mergeArray(r, i);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
1555
1555
|
return this._def.type;
|
|
@@ -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 D ? D.create(Q(n.unwrap())) : n instanceof U ? U.create(Q(n.unwrap())) : 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() {
|
|
@@ -1611,67 +1611,67 @@ class k extends _ {
|
|
|
1611
1611
|
return this._cached = { shape: e, keys: t };
|
|
1612
1612
|
}
|
|
1613
1613
|
_parse(e) {
|
|
1614
|
-
if (this._getType(e) !==
|
|
1615
|
-
const
|
|
1616
|
-
return m(
|
|
1617
|
-
code:
|
|
1618
|
-
expected:
|
|
1619
|
-
received:
|
|
1614
|
+
if (this._getType(e) !== p.object) {
|
|
1615
|
+
const u = this._getOrReturnCtx(e);
|
|
1616
|
+
return m(u, {
|
|
1617
|
+
code: d.invalid_type,
|
|
1618
|
+
expected: p.object,
|
|
1619
|
+
received: u.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status: r, ctx: s } = this._processInputParams(e), { shape:
|
|
1622
|
+
const { status: r, ctx: s } = this._processInputParams(e), { shape: i, keys: o } = this._getCached(), c = [];
|
|
1623
1623
|
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1624
|
-
for (const
|
|
1625
|
-
o.includes(
|
|
1624
|
+
for (const u in s.data)
|
|
1625
|
+
o.includes(u) || c.push(u);
|
|
1626
1626
|
const l = [];
|
|
1627
|
-
for (const
|
|
1628
|
-
const
|
|
1627
|
+
for (const u of o) {
|
|
1628
|
+
const f = i[u], b = s.data[u];
|
|
1629
1629
|
l.push({
|
|
1630
|
-
key: { status: "valid", value:
|
|
1631
|
-
value:
|
|
1632
|
-
alwaysSet:
|
|
1630
|
+
key: { status: "valid", value: u },
|
|
1631
|
+
value: f._parse(new O(s, b, s.path, u)),
|
|
1632
|
+
alwaysSet: u in s.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
1635
|
if (this._def.catchall instanceof $) {
|
|
1636
|
-
const
|
|
1637
|
-
if (
|
|
1638
|
-
for (const
|
|
1636
|
+
const u = this._def.unknownKeys;
|
|
1637
|
+
if (u === "passthrough")
|
|
1638
|
+
for (const f of c)
|
|
1639
1639
|
l.push({
|
|
1640
|
-
key: { status: "valid", value:
|
|
1641
|
-
value: { status: "valid", value: s.data[
|
|
1640
|
+
key: { status: "valid", value: f },
|
|
1641
|
+
value: { status: "valid", value: s.data[f] }
|
|
1642
1642
|
});
|
|
1643
|
-
else if (
|
|
1643
|
+
else if (u === "strict")
|
|
1644
1644
|
c.length > 0 && (m(s, {
|
|
1645
|
-
code:
|
|
1645
|
+
code: d.unrecognized_keys,
|
|
1646
1646
|
keys: c
|
|
1647
1647
|
}), r.dirty());
|
|
1648
|
-
else if (
|
|
1648
|
+
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1649
1649
|
} else {
|
|
1650
|
-
const
|
|
1651
|
-
for (const
|
|
1652
|
-
const b = s.data[
|
|
1650
|
+
const u = this._def.catchall;
|
|
1651
|
+
for (const f of c) {
|
|
1652
|
+
const b = s.data[f];
|
|
1653
1653
|
l.push({
|
|
1654
|
-
key: { status: "valid", value:
|
|
1655
|
-
value:
|
|
1656
|
-
new O(s, b, s.path,
|
|
1654
|
+
key: { status: "valid", value: f },
|
|
1655
|
+
value: u._parse(
|
|
1656
|
+
new O(s, b, s.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet:
|
|
1659
|
+
alwaysSet: f in s.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
1663
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1664
|
-
const
|
|
1665
|
-
for (const
|
|
1666
|
-
const b = await
|
|
1667
|
-
|
|
1664
|
+
const u = [];
|
|
1665
|
+
for (const f of l) {
|
|
1666
|
+
const b = await f.key, w = await f.value;
|
|
1667
|
+
u.push({
|
|
1668
1668
|
key: b,
|
|
1669
1669
|
value: w,
|
|
1670
|
-
alwaysSet:
|
|
1670
|
+
alwaysSet: f.alwaysSet
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
|
-
return
|
|
1674
|
-
}).then((
|
|
1673
|
+
return u;
|
|
1674
|
+
}).then((u) => T.mergeObjectSync(r, u)) : T.mergeObjectSync(r, l);
|
|
1675
1675
|
}
|
|
1676
1676
|
get shape() {
|
|
1677
1677
|
return this._def.shape();
|
|
@@ -1682,8 +1682,8 @@ class k extends _ {
|
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
1684
|
errorMap: (t, r) => {
|
|
1685
|
-
var s,
|
|
1686
|
-
const l = (o = (
|
|
1685
|
+
var s, i, o, c;
|
|
1686
|
+
const l = (o = (i = (s = this._def).errorMap) === null || i === void 0 ? void 0 : i.call(s, 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
|
} : {
|
|
@@ -1852,10 +1852,10 @@ class k extends _ {
|
|
|
1852
1852
|
if (e && !e[r])
|
|
1853
1853
|
t[r] = this.shape[r];
|
|
1854
1854
|
else {
|
|
1855
|
-
let
|
|
1856
|
-
for (;
|
|
1857
|
-
|
|
1858
|
-
t[r] =
|
|
1855
|
+
let i = this.shape[r];
|
|
1856
|
+
for (; i instanceof D; )
|
|
1857
|
+
i = i._def.innerType;
|
|
1858
|
+
t[r] = i;
|
|
1859
1859
|
}
|
|
1860
1860
|
}), new k({
|
|
1861
1861
|
...this._def,
|
|
@@ -1890,21 +1890,21 @@ k.lazycreate = (n, e) => new k({
|
|
|
1890
1890
|
class ce extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
1892
|
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1893
|
-
function s(
|
|
1894
|
-
for (const c of
|
|
1893
|
+
function s(i) {
|
|
1894
|
+
for (const c of i)
|
|
1895
1895
|
if (c.result.status === "valid")
|
|
1896
1896
|
return c.result;
|
|
1897
|
-
for (const c of
|
|
1897
|
+
for (const c of i)
|
|
1898
1898
|
if (c.result.status === "dirty")
|
|
1899
1899
|
return t.common.issues.push(...c.ctx.common.issues), c.result;
|
|
1900
|
-
const o =
|
|
1900
|
+
const o = i.map((c) => new N(c.ctx.common.issues));
|
|
1901
1901
|
return m(t, {
|
|
1902
|
-
code:
|
|
1902
|
+
code: d.invalid_union,
|
|
1903
1903
|
unionErrors: o
|
|
1904
1904
|
}), y;
|
|
1905
1905
|
}
|
|
1906
1906
|
if (t.common.async)
|
|
1907
|
-
return Promise.all(r.map(async (
|
|
1907
|
+
return Promise.all(r.map(async (i) => {
|
|
1908
1908
|
const o = {
|
|
1909
1909
|
...t,
|
|
1910
1910
|
common: {
|
|
@@ -1914,7 +1914,7 @@ class ce extends _ {
|
|
|
1914
1914
|
parent: null
|
|
1915
1915
|
};
|
|
1916
1916
|
return {
|
|
1917
|
-
result: await
|
|
1917
|
+
result: await i._parseAsync({
|
|
1918
1918
|
data: t.data,
|
|
1919
1919
|
path: t.path,
|
|
1920
1920
|
parent: o
|
|
@@ -1923,30 +1923,30 @@ class ce extends _ {
|
|
|
1923
1923
|
};
|
|
1924
1924
|
})).then(s);
|
|
1925
1925
|
{
|
|
1926
|
-
let
|
|
1926
|
+
let i;
|
|
1927
1927
|
const o = [];
|
|
1928
1928
|
for (const l of r) {
|
|
1929
|
-
const
|
|
1929
|
+
const u = {
|
|
1930
1930
|
...t,
|
|
1931
1931
|
common: {
|
|
1932
1932
|
...t.common,
|
|
1933
1933
|
issues: []
|
|
1934
1934
|
},
|
|
1935
1935
|
parent: null
|
|
1936
|
-
},
|
|
1936
|
+
}, f = l._parseSync({
|
|
1937
1937
|
data: t.data,
|
|
1938
1938
|
path: t.path,
|
|
1939
|
-
parent:
|
|
1939
|
+
parent: u
|
|
1940
1940
|
});
|
|
1941
|
-
if (
|
|
1942
|
-
return
|
|
1943
|
-
|
|
1941
|
+
if (f.status === "valid")
|
|
1942
|
+
return f;
|
|
1943
|
+
f.status === "dirty" && !i && (i = { result: f, ctx: u }), u.common.issues.length && o.push(u.common.issues);
|
|
1944
1944
|
}
|
|
1945
|
-
if (
|
|
1946
|
-
return t.common.issues.push(...
|
|
1947
|
-
const c = o.map((l) => new
|
|
1945
|
+
if (i)
|
|
1946
|
+
return t.common.issues.push(...i.ctx.common.issues), i.result;
|
|
1947
|
+
const c = o.map((l) => new N(l));
|
|
1948
1948
|
return m(t, {
|
|
1949
|
-
code:
|
|
1949
|
+
code: d.invalid_union,
|
|
1950
1950
|
unionErrors: c
|
|
1951
1951
|
}), y;
|
|
1952
1952
|
}
|
|
@@ -1960,27 +1960,27 @@ ce.create = (n, e) => new ce({
|
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const
|
|
1964
|
-
class
|
|
1963
|
+
const E = (n) => n instanceof le ? E(n.schema) : n instanceof Z ? 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 Re || n instanceof ge ? E(n.unwrap()) : n instanceof he ? E(n._def.innerType) : [];
|
|
1964
|
+
class Se extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
1967
|
-
if (t.parsedType !==
|
|
1967
|
+
if (t.parsedType !== p.object)
|
|
1968
1968
|
return m(t, {
|
|
1969
|
-
code:
|
|
1970
|
-
expected:
|
|
1969
|
+
code: d.invalid_type,
|
|
1970
|
+
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const r = this.discriminator, s = t.data[r],
|
|
1974
|
-
return
|
|
1973
|
+
const r = this.discriminator, s = t.data[r], i = this.optionsMap.get(s);
|
|
1974
|
+
return i ? t.common.async ? i._parseAsync({
|
|
1975
1975
|
data: t.data,
|
|
1976
1976
|
path: t.path,
|
|
1977
1977
|
parent: t
|
|
1978
|
-
}) :
|
|
1978
|
+
}) : i._parseSync({
|
|
1979
1979
|
data: t.data,
|
|
1980
1980
|
path: t.path,
|
|
1981
1981
|
parent: t
|
|
1982
1982
|
}) : (m(t, {
|
|
1983
|
-
code:
|
|
1983
|
+
code: d.invalid_union_discriminator,
|
|
1984
1984
|
options: Array.from(this.optionsMap.keys()),
|
|
1985
1985
|
path: [r]
|
|
1986
1986
|
}), y);
|
|
@@ -2004,17 +2004,17 @@ class Ie extends _ {
|
|
|
2004
2004
|
*/
|
|
2005
2005
|
static create(e, t, r) {
|
|
2006
2006
|
const s = /* @__PURE__ */ new Map();
|
|
2007
|
-
for (const
|
|
2008
|
-
const o =
|
|
2007
|
+
for (const i of t) {
|
|
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
2012
|
if (s.has(c))
|
|
2013
2013
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
|
|
2014
|
-
s.set(c,
|
|
2014
|
+
s.set(c, i);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
|
-
return new
|
|
2017
|
+
return new Se({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
@@ -2023,40 +2023,40 @@ class Ie extends _ {
|
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const t =
|
|
2026
|
+
function Ee(n, e) {
|
|
2027
|
+
const t = R(n), r = R(e);
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
|
-
if (t ===
|
|
2031
|
-
const s = x.objectKeys(e),
|
|
2032
|
-
for (const c of
|
|
2033
|
-
const l =
|
|
2030
|
+
if (t === p.object && r === p.object) {
|
|
2031
|
+
const s = x.objectKeys(e), i = x.objectKeys(n).filter((c) => s.indexOf(c) !== -1), o = { ...n, ...e };
|
|
2032
|
+
for (const c of i) {
|
|
2033
|
+
const l = Ee(n[c], e[c]);
|
|
2034
2034
|
if (!l.valid)
|
|
2035
2035
|
return { valid: !1 };
|
|
2036
2036
|
o[c] = l.data;
|
|
2037
2037
|
}
|
|
2038
2038
|
return { valid: !0, data: o };
|
|
2039
|
-
} else if (t ===
|
|
2039
|
+
} else if (t === p.array && r === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
2042
|
const s = [];
|
|
2043
|
-
for (let
|
|
2044
|
-
const o = n[
|
|
2043
|
+
for (let i = 0; i < n.length; i++) {
|
|
2044
|
+
const o = n[i], c = e[i], l = Ee(o, c);
|
|
2045
2045
|
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
2047
|
s.push(l.data);
|
|
2048
2048
|
}
|
|
2049
2049
|
return { valid: !0, data: s };
|
|
2050
|
-
} else return t ===
|
|
2050
|
+
} else return t === p.date && r === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
|
-
class
|
|
2052
|
+
class ue extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx: r } = this._processInputParams(e), s = (
|
|
2055
|
-
if (Oe(
|
|
2054
|
+
const { status: t, ctx: r } = this._processInputParams(e), s = (i, o) => {
|
|
2055
|
+
if (Oe(i) || Oe(o))
|
|
2056
2056
|
return y;
|
|
2057
|
-
const c =
|
|
2058
|
-
return c.valid ? ((
|
|
2059
|
-
code:
|
|
2057
|
+
const c = Ee(i.value, o.value);
|
|
2058
|
+
return c.valid ? ((Pe(i) || Pe(o)) && t.dirty(), { status: t.value, value: c.data }) : (m(r, {
|
|
2059
|
+
code: d.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
2062
2062
|
return r.common.async ? Promise.all([
|
|
@@ -2070,7 +2070,7 @@ class de extends _ {
|
|
|
2070
2070
|
path: r.path,
|
|
2071
2071
|
parent: r
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([
|
|
2073
|
+
]).then(([i, o]) => s(i, o)) : s(this._def.left._parseSync({
|
|
2074
2074
|
data: r.data,
|
|
2075
2075
|
path: r.path,
|
|
2076
2076
|
parent: r
|
|
@@ -2081,63 +2081,63 @@ class de extends _ {
|
|
|
2081
2081
|
}));
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
|
-
|
|
2084
|
+
ue.create = (n, e, t) => new ue({
|
|
2085
2085
|
left: n,
|
|
2086
2086
|
right: e,
|
|
2087
2087
|
typeName: g.ZodIntersection,
|
|
2088
2088
|
...v(t)
|
|
2089
2089
|
});
|
|
2090
|
-
class
|
|
2090
|
+
class P extends _ {
|
|
2091
2091
|
_parse(e) {
|
|
2092
2092
|
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2093
|
-
if (r.parsedType !==
|
|
2093
|
+
if (r.parsedType !== p.array)
|
|
2094
2094
|
return m(r, {
|
|
2095
|
-
code:
|
|
2096
|
-
expected:
|
|
2095
|
+
code: d.invalid_type,
|
|
2096
|
+
expected: p.array,
|
|
2097
2097
|
received: r.parsedType
|
|
2098
2098
|
}), y;
|
|
2099
2099
|
if (r.data.length < this._def.items.length)
|
|
2100
2100
|
return m(r, {
|
|
2101
|
-
code:
|
|
2101
|
+
code: d.too_small,
|
|
2102
2102
|
minimum: this._def.items.length,
|
|
2103
2103
|
inclusive: !0,
|
|
2104
2104
|
exact: !1,
|
|
2105
2105
|
type: "array"
|
|
2106
2106
|
}), y;
|
|
2107
2107
|
!this._def.rest && r.data.length > this._def.items.length && (m(r, {
|
|
2108
|
-
code:
|
|
2108
|
+
code: d.too_big,
|
|
2109
2109
|
maximum: this._def.items.length,
|
|
2110
2110
|
inclusive: !0,
|
|
2111
2111
|
exact: !1,
|
|
2112
2112
|
type: "array"
|
|
2113
2113
|
}), t.dirty());
|
|
2114
|
-
const
|
|
2114
|
+
const i = [...r.data].map((o, c) => {
|
|
2115
2115
|
const l = this._def.items[c] || this._def.rest;
|
|
2116
2116
|
return l ? l._parse(new O(r, o, r.path, c)) : null;
|
|
2117
2117
|
}).filter((o) => !!o);
|
|
2118
|
-
return r.common.async ? Promise.all(
|
|
2118
|
+
return r.common.async ? Promise.all(i).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, i);
|
|
2119
2119
|
}
|
|
2120
2120
|
get items() {
|
|
2121
2121
|
return this._def.items;
|
|
2122
2122
|
}
|
|
2123
2123
|
rest(e) {
|
|
2124
|
-
return new
|
|
2124
|
+
return new P({
|
|
2125
2125
|
...this._def,
|
|
2126
2126
|
rest: e
|
|
2127
2127
|
});
|
|
2128
2128
|
}
|
|
2129
2129
|
}
|
|
2130
|
-
|
|
2130
|
+
P.create = (n, e) => {
|
|
2131
2131
|
if (!Array.isArray(n))
|
|
2132
2132
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2133
|
-
return new
|
|
2133
|
+
return new P({
|
|
2134
2134
|
items: n,
|
|
2135
2135
|
typeName: g.ZodTuple,
|
|
2136
2136
|
rest: null,
|
|
2137
2137
|
...v(e)
|
|
2138
2138
|
});
|
|
2139
2139
|
};
|
|
2140
|
-
class
|
|
2140
|
+
class de extends _ {
|
|
2141
2141
|
get keySchema() {
|
|
2142
2142
|
return this._def.keyType;
|
|
2143
2143
|
}
|
|
@@ -2146,16 +2146,16 @@ class ue extends _ {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
_parse(e) {
|
|
2148
2148
|
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2149
|
-
if (r.parsedType !==
|
|
2149
|
+
if (r.parsedType !== p.object)
|
|
2150
2150
|
return m(r, {
|
|
2151
|
-
code:
|
|
2152
|
-
expected:
|
|
2151
|
+
code: d.invalid_type,
|
|
2152
|
+
expected: p.object,
|
|
2153
2153
|
received: r.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const s = [],
|
|
2155
|
+
const s = [], i = this._def.keyType, o = this._def.valueType;
|
|
2156
2156
|
for (const c in r.data)
|
|
2157
2157
|
s.push({
|
|
2158
|
-
key:
|
|
2158
|
+
key: i._parse(new O(r, c, r.path, c)),
|
|
2159
2159
|
value: o._parse(new O(r, r.data[c], r.path, c)),
|
|
2160
2160
|
alwaysSet: c in r.data
|
|
2161
2161
|
});
|
|
@@ -2165,13 +2165,13 @@ class ue extends _ {
|
|
|
2165
2165
|
return this._def.valueType;
|
|
2166
2166
|
}
|
|
2167
2167
|
static create(e, t, r) {
|
|
2168
|
-
return t instanceof _ ? new
|
|
2168
|
+
return t instanceof _ ? new de({
|
|
2169
2169
|
keyType: e,
|
|
2170
2170
|
valueType: t,
|
|
2171
2171
|
typeName: g.ZodRecord,
|
|
2172
2172
|
...v(r)
|
|
2173
|
-
}) : new
|
|
2174
|
-
keyType:
|
|
2173
|
+
}) : new de({
|
|
2174
|
+
keyType: A.create(),
|
|
2175
2175
|
valueType: e,
|
|
2176
2176
|
typeName: g.ZodRecord,
|
|
2177
2177
|
...v(t)
|
|
@@ -2187,34 +2187,34 @@ class we extends _ {
|
|
|
2187
2187
|
}
|
|
2188
2188
|
_parse(e) {
|
|
2189
2189
|
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2190
|
-
if (r.parsedType !==
|
|
2190
|
+
if (r.parsedType !== p.map)
|
|
2191
2191
|
return m(r, {
|
|
2192
|
-
code:
|
|
2193
|
-
expected:
|
|
2192
|
+
code: d.invalid_type,
|
|
2193
|
+
expected: p.map,
|
|
2194
2194
|
received: r.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const s = this._def.keyType,
|
|
2197
|
-
key: s._parse(new O(r, c, r.path, [
|
|
2198
|
-
value:
|
|
2196
|
+
const s = this._def.keyType, i = this._def.valueType, o = [...r.data.entries()].map(([c, l], u) => ({
|
|
2197
|
+
key: s._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();
|
|
2202
2202
|
return Promise.resolve().then(async () => {
|
|
2203
2203
|
for (const l of o) {
|
|
2204
|
-
const
|
|
2205
|
-
if (
|
|
2204
|
+
const u = await l.key, f = await l.value;
|
|
2205
|
+
if (u.status === "aborted" || f.status === "aborted")
|
|
2206
2206
|
return y;
|
|
2207
|
-
(
|
|
2207
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2208
2208
|
}
|
|
2209
2209
|
return { status: t.value, value: c };
|
|
2210
2210
|
});
|
|
2211
2211
|
} else {
|
|
2212
2212
|
const c = /* @__PURE__ */ new Map();
|
|
2213
2213
|
for (const l of o) {
|
|
2214
|
-
const
|
|
2215
|
-
if (
|
|
2214
|
+
const u = l.key, f = l.value;
|
|
2215
|
+
if (u.status === "aborted" || f.status === "aborted")
|
|
2216
2216
|
return y;
|
|
2217
|
-
(
|
|
2217
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2218
2218
|
}
|
|
2219
2219
|
return { status: t.value, value: c };
|
|
2220
2220
|
}
|
|
@@ -2229,39 +2229,39 @@ we.create = (n, e, t) => new we({
|
|
|
2229
2229
|
class W extends _ {
|
|
2230
2230
|
_parse(e) {
|
|
2231
2231
|
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2232
|
-
if (r.parsedType !==
|
|
2232
|
+
if (r.parsedType !== p.set)
|
|
2233
2233
|
return m(r, {
|
|
2234
|
-
code:
|
|
2235
|
-
expected:
|
|
2234
|
+
code: d.invalid_type,
|
|
2235
|
+
expected: p.set,
|
|
2236
2236
|
received: r.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
2238
|
const s = this._def;
|
|
2239
2239
|
s.minSize !== null && r.data.size < s.minSize.value && (m(r, {
|
|
2240
|
-
code:
|
|
2240
|
+
code: d.too_small,
|
|
2241
2241
|
minimum: s.minSize.value,
|
|
2242
2242
|
type: "set",
|
|
2243
2243
|
inclusive: !0,
|
|
2244
2244
|
exact: !1,
|
|
2245
2245
|
message: s.minSize.message
|
|
2246
2246
|
}), t.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (m(r, {
|
|
2247
|
-
code:
|
|
2247
|
+
code: d.too_big,
|
|
2248
2248
|
maximum: s.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
2252
|
message: s.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
|
-
const
|
|
2254
|
+
const i = this._def.valueType;
|
|
2255
2255
|
function o(l) {
|
|
2256
|
-
const
|
|
2257
|
-
for (const
|
|
2258
|
-
if (
|
|
2256
|
+
const u = /* @__PURE__ */ new Set();
|
|
2257
|
+
for (const f of l) {
|
|
2258
|
+
if (f.status === "aborted")
|
|
2259
2259
|
return y;
|
|
2260
|
-
|
|
2260
|
+
f.status === "dirty" && t.dirty(), u.add(f.value);
|
|
2261
2261
|
}
|
|
2262
|
-
return { status: t.value, value:
|
|
2262
|
+
return { status: t.value, value: u };
|
|
2263
2263
|
}
|
|
2264
|
-
const c = [...r.data.values()].map((l,
|
|
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) {
|
|
@@ -2296,10 +2296,10 @@ class X extends _ {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
_parse(e) {
|
|
2298
2298
|
const { ctx: t } = this._processInputParams(e);
|
|
2299
|
-
if (t.parsedType !==
|
|
2299
|
+
if (t.parsedType !== p.function)
|
|
2300
2300
|
return m(t, {
|
|
2301
|
-
code:
|
|
2302
|
-
expected:
|
|
2301
|
+
code: d.invalid_type,
|
|
2302
|
+
expected: p.function,
|
|
2303
2303
|
received: t.parsedType
|
|
2304
2304
|
}), y;
|
|
2305
2305
|
function r(c, l) {
|
|
@@ -2311,9 +2311,9 @@ class X extends _ {
|
|
|
2311
2311
|
t.schemaErrorMap,
|
|
2312
2312
|
ve(),
|
|
2313
2313
|
J
|
|
2314
|
-
].filter((
|
|
2314
|
+
].filter((u) => !!u),
|
|
2315
2315
|
issueData: {
|
|
2316
|
-
code:
|
|
2316
|
+
code: d.invalid_arguments,
|
|
2317
2317
|
argumentsError: l
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
@@ -2327,33 +2327,33 @@ class X extends _ {
|
|
|
2327
2327
|
t.schemaErrorMap,
|
|
2328
2328
|
ve(),
|
|
2329
2329
|
J
|
|
2330
|
-
].filter((
|
|
2330
|
+
].filter((u) => !!u),
|
|
2331
2331
|
issueData: {
|
|
2332
|
-
code:
|
|
2332
|
+
code: d.invalid_return_type,
|
|
2333
2333
|
returnTypeError: l
|
|
2334
2334
|
}
|
|
2335
2335
|
});
|
|
2336
2336
|
}
|
|
2337
|
-
const
|
|
2338
|
-
if (this._def.returns instanceof
|
|
2337
|
+
const i = { errorMap: t.common.contextualErrorMap }, o = t.data;
|
|
2338
|
+
if (this._def.returns instanceof H) {
|
|
2339
2339
|
const c = this;
|
|
2340
|
-
return
|
|
2341
|
-
const
|
|
2342
|
-
throw
|
|
2343
|
-
}), b = await Reflect.apply(o, this,
|
|
2344
|
-
return await c._def.returns._def.type.parseAsync(b,
|
|
2345
|
-
throw
|
|
2340
|
+
return S(async function(...l) {
|
|
2341
|
+
const u = new N([]), f = await c._def.args.parseAsync(l, i).catch((I) => {
|
|
2342
|
+
throw u.addIssue(r(l, I)), u;
|
|
2343
|
+
}), b = await Reflect.apply(o, this, f);
|
|
2344
|
+
return await c._def.returns._def.type.parseAsync(b, i).catch((I) => {
|
|
2345
|
+
throw u.addIssue(s(b, I)), u;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
2349
2349
|
const c = this;
|
|
2350
|
-
return
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
throw new
|
|
2354
|
-
const
|
|
2350
|
+
return S(function(...l) {
|
|
2351
|
+
const u = c._def.args.safeParse(l, i);
|
|
2352
|
+
if (!u.success)
|
|
2353
|
+
throw new N([r(l, u.error)]);
|
|
2354
|
+
const f = Reflect.apply(o, this, u.data), b = c._def.returns.safeParse(f, i);
|
|
2355
2355
|
if (!b.success)
|
|
2356
|
-
throw new
|
|
2356
|
+
throw new N([s(f, b.error)]);
|
|
2357
2357
|
return b.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
@@ -2367,7 +2367,7 @@ class X extends _ {
|
|
|
2367
2367
|
args(...e) {
|
|
2368
2368
|
return new X({
|
|
2369
2369
|
...this._def,
|
|
2370
|
-
args:
|
|
2370
|
+
args: P.create(e).rest(L.create())
|
|
2371
2371
|
});
|
|
2372
2372
|
}
|
|
2373
2373
|
returns(e) {
|
|
@@ -2384,7 +2384,7 @@ class X extends _ {
|
|
|
2384
2384
|
}
|
|
2385
2385
|
static create(e, t, r) {
|
|
2386
2386
|
return new X({
|
|
2387
|
-
args: e ||
|
|
2387
|
+
args: e || P.create([]).rest(L.create()),
|
|
2388
2388
|
returns: t || L.create(),
|
|
2389
2389
|
typeName: g.ZodFunction,
|
|
2390
2390
|
...v(r)
|
|
@@ -2411,7 +2411,7 @@ class me extends _ {
|
|
|
2411
2411
|
const t = this._getOrReturnCtx(e);
|
|
2412
2412
|
return m(t, {
|
|
2413
2413
|
received: t.data,
|
|
2414
|
-
code:
|
|
2414
|
+
code: d.invalid_literal,
|
|
2415
2415
|
expected: this._def.value
|
|
2416
2416
|
}), y;
|
|
2417
2417
|
}
|
|
@@ -2427,13 +2427,13 @@ me.create = (n, e) => new me({
|
|
|
2427
2427
|
...v(e)
|
|
2428
2428
|
});
|
|
2429
2429
|
function Qe(n, e) {
|
|
2430
|
-
return new
|
|
2430
|
+
return new F({
|
|
2431
2431
|
values: n,
|
|
2432
2432
|
typeName: g.ZodEnum,
|
|
2433
2433
|
...v(e)
|
|
2434
2434
|
});
|
|
2435
2435
|
}
|
|
2436
|
-
class
|
|
2436
|
+
class F extends _ {
|
|
2437
2437
|
constructor() {
|
|
2438
2438
|
super(...arguments), te.set(this, void 0);
|
|
2439
2439
|
}
|
|
@@ -2443,18 +2443,18 @@ class z extends _ {
|
|
|
2443
2443
|
return m(t, {
|
|
2444
2444
|
expected: x.joinValues(r),
|
|
2445
2445
|
received: t.parsedType,
|
|
2446
|
-
code:
|
|
2446
|
+
code: d.invalid_type
|
|
2447
2447
|
}), y;
|
|
2448
2448
|
}
|
|
2449
2449
|
if (be(this, te) || Le(this, te, new Set(this._def.values)), !be(this, te).has(e.data)) {
|
|
2450
2450
|
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2451
2451
|
return m(t, {
|
|
2452
2452
|
received: t.data,
|
|
2453
|
-
code:
|
|
2453
|
+
code: d.invalid_enum_value,
|
|
2454
2454
|
options: r
|
|
2455
2455
|
}), y;
|
|
2456
2456
|
}
|
|
2457
|
-
return
|
|
2457
|
+
return S(e.data);
|
|
2458
2458
|
}
|
|
2459
2459
|
get options() {
|
|
2460
2460
|
return this._def.values;
|
|
@@ -2478,74 +2478,74 @@ class z extends _ {
|
|
|
2478
2478
|
return e;
|
|
2479
2479
|
}
|
|
2480
2480
|
extract(e, t = this._def) {
|
|
2481
|
-
return
|
|
2481
|
+
return F.create(e, {
|
|
2482
2482
|
...this._def,
|
|
2483
2483
|
...t
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
exclude(e, t = this._def) {
|
|
2487
|
-
return
|
|
2487
|
+
return F.create(this.options.filter((r) => !e.includes(r)), {
|
|
2488
2488
|
...this._def,
|
|
2489
2489
|
...t
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
2493
|
te = /* @__PURE__ */ new WeakMap();
|
|
2494
|
-
|
|
2495
|
-
class
|
|
2494
|
+
F.create = Qe;
|
|
2495
|
+
class pe extends _ {
|
|
2496
2496
|
constructor() {
|
|
2497
2497
|
super(...arguments), ne.set(this, void 0);
|
|
2498
2498
|
}
|
|
2499
2499
|
_parse(e) {
|
|
2500
2500
|
const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2501
|
-
if (r.parsedType !==
|
|
2501
|
+
if (r.parsedType !== p.string && r.parsedType !== p.number) {
|
|
2502
2502
|
const s = x.objectValues(t);
|
|
2503
2503
|
return m(r, {
|
|
2504
2504
|
expected: x.joinValues(s),
|
|
2505
2505
|
received: r.parsedType,
|
|
2506
|
-
code:
|
|
2506
|
+
code: d.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
2509
|
if (be(this, ne) || Le(this, ne, new Set(x.getValidEnumValues(this._def.values))), !be(this, ne).has(e.data)) {
|
|
2510
2510
|
const s = x.objectValues(t);
|
|
2511
2511
|
return m(r, {
|
|
2512
2512
|
received: r.data,
|
|
2513
|
-
code:
|
|
2513
|
+
code: d.invalid_enum_value,
|
|
2514
2514
|
options: s
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
|
-
return
|
|
2517
|
+
return S(e.data);
|
|
2518
2518
|
}
|
|
2519
2519
|
get enum() {
|
|
2520
2520
|
return this._def.values;
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
2523
|
ne = /* @__PURE__ */ new WeakMap();
|
|
2524
|
-
|
|
2524
|
+
pe.create = (n, e) => new pe({
|
|
2525
2525
|
values: n,
|
|
2526
2526
|
typeName: g.ZodNativeEnum,
|
|
2527
2527
|
...v(e)
|
|
2528
2528
|
});
|
|
2529
|
-
class
|
|
2529
|
+
class H extends _ {
|
|
2530
2530
|
unwrap() {
|
|
2531
2531
|
return this._def.type;
|
|
2532
2532
|
}
|
|
2533
2533
|
_parse(e) {
|
|
2534
2534
|
const { ctx: t } = this._processInputParams(e);
|
|
2535
|
-
if (t.parsedType !==
|
|
2535
|
+
if (t.parsedType !== p.promise && t.common.async === !1)
|
|
2536
2536
|
return m(t, {
|
|
2537
|
-
code:
|
|
2538
|
-
expected:
|
|
2537
|
+
code: d.invalid_type,
|
|
2538
|
+
expected: p.promise,
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
|
-
const r = t.parsedType ===
|
|
2542
|
-
return
|
|
2541
|
+
const r = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
+
return S(r.then((s) => this._def.type.parseAsync(s, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
2546
2546
|
}
|
|
2547
2547
|
}
|
|
2548
|
-
|
|
2548
|
+
H.create = (n, e) => new H({
|
|
2549
2549
|
type: n,
|
|
2550
2550
|
typeName: g.ZodPromise,
|
|
2551
2551
|
...v(e)
|
|
@@ -2558,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), s = this._def.effect || null,
|
|
2561
|
+
const { status: t, ctx: r } = this._processInputParams(e), s = 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 (
|
|
2570
|
-
const o = s.transform(r.data,
|
|
2569
|
+
if (i.addIssue = i.addIssue.bind(i), s.type === "preprocess") {
|
|
2570
|
+
const o = s.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")
|
|
@@ -2592,7 +2592,7 @@ class Z extends _ {
|
|
|
2592
2592
|
}
|
|
2593
2593
|
if (s.type === "refinement") {
|
|
2594
2594
|
const o = (c) => {
|
|
2595
|
-
const l = s.refinement(c,
|
|
2595
|
+
const l = s.refinement(c, i);
|
|
2596
2596
|
if (r.common.async)
|
|
2597
2597
|
return Promise.resolve(l);
|
|
2598
2598
|
if (l instanceof Promise)
|
|
@@ -2618,12 +2618,12 @@ class Z extends _ {
|
|
|
2618
2618
|
});
|
|
2619
2619
|
if (!q(o))
|
|
2620
2620
|
return o;
|
|
2621
|
-
const c = s.transform(o.value,
|
|
2621
|
+
const c = s.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(s.transform(o.value,
|
|
2626
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => q(o) ? Promise.resolve(s.transform(o.value, i)).then((c) => ({ status: t.value, value: c })) : o);
|
|
2627
2627
|
x.assertNever(s);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
@@ -2641,7 +2641,7 @@ Z.createWithPreprocess = (n, e, t) => new Z({
|
|
|
2641
2641
|
});
|
|
2642
2642
|
class D extends _ {
|
|
2643
2643
|
_parse(e) {
|
|
2644
|
-
return this._getType(e) ===
|
|
2644
|
+
return this._getType(e) === p.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
2645
2645
|
}
|
|
2646
2646
|
unwrap() {
|
|
2647
2647
|
return this._def.innerType;
|
|
@@ -2654,7 +2654,7 @@ D.create = (n, e) => new D({
|
|
|
2654
2654
|
});
|
|
2655
2655
|
class U extends _ {
|
|
2656
2656
|
_parse(e) {
|
|
2657
|
-
return this._getType(e) ===
|
|
2657
|
+
return this._getType(e) === p.null ? S(null) : this._def.innerType._parse(e);
|
|
2658
2658
|
}
|
|
2659
2659
|
unwrap() {
|
|
2660
2660
|
return this._def.innerType;
|
|
@@ -2665,11 +2665,11 @@ U.create = (n, e) => new U({
|
|
|
2665
2665
|
typeName: g.ZodNullable,
|
|
2666
2666
|
...v(e)
|
|
2667
2667
|
});
|
|
2668
|
-
class
|
|
2668
|
+
class fe extends _ {
|
|
2669
2669
|
_parse(e) {
|
|
2670
2670
|
const { ctx: t } = this._processInputParams(e);
|
|
2671
2671
|
let r = t.data;
|
|
2672
|
-
return t.parsedType ===
|
|
2672
|
+
return t.parsedType === p.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2673
2673
|
data: r,
|
|
2674
2674
|
path: t.path,
|
|
2675
2675
|
parent: t
|
|
@@ -2679,7 +2679,7 @@ class pe extends _ {
|
|
|
2679
2679
|
return this._def.innerType;
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
|
|
2682
|
+
fe.create = (n, e) => new fe({
|
|
2683
2683
|
innerType: n,
|
|
2684
2684
|
typeName: g.ZodDefault,
|
|
2685
2685
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
@@ -2700,11 +2700,11 @@ class he extends _ {
|
|
|
2700
2700
|
...r
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return se(s) ? s.then((
|
|
2703
|
+
return se(s) ? s.then((i) => ({
|
|
2704
2704
|
status: "valid",
|
|
2705
|
-
value:
|
|
2705
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2706
2706
|
get error() {
|
|
2707
|
-
return new
|
|
2707
|
+
return new N(r.common.issues);
|
|
2708
2708
|
},
|
|
2709
2709
|
input: r.data
|
|
2710
2710
|
})
|
|
@@ -2712,7 +2712,7 @@ class he extends _ {
|
|
|
2712
2712
|
status: "valid",
|
|
2713
2713
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
|
-
return new
|
|
2715
|
+
return new N(r.common.issues);
|
|
2716
2716
|
},
|
|
2717
2717
|
input: r.data
|
|
2718
2718
|
})
|
|
@@ -2730,11 +2730,11 @@ he.create = (n, e) => new he({
|
|
|
2730
2730
|
});
|
|
2731
2731
|
class Te extends _ {
|
|
2732
2732
|
_parse(e) {
|
|
2733
|
-
if (this._getType(e) !==
|
|
2733
|
+
if (this._getType(e) !== p.nan) {
|
|
2734
2734
|
const r = this._getOrReturnCtx(e);
|
|
2735
2735
|
return m(r, {
|
|
2736
|
-
code:
|
|
2737
|
-
expected:
|
|
2736
|
+
code: d.invalid_type,
|
|
2737
|
+
expected: p.nan,
|
|
2738
2738
|
received: r.parsedType
|
|
2739
2739
|
}), y;
|
|
2740
2740
|
}
|
|
@@ -2745,8 +2745,8 @@ Te.create = (n) => new Te({
|
|
|
2745
2745
|
typeName: g.ZodNaN,
|
|
2746
2746
|
...v(n)
|
|
2747
2747
|
});
|
|
2748
|
-
const
|
|
2749
|
-
class
|
|
2748
|
+
const Ot = Symbol("zod_brand");
|
|
2749
|
+
class Re extends _ {
|
|
2750
2750
|
_parse(e) {
|
|
2751
2751
|
const { ctx: t } = this._processInputParams(e), r = t.data;
|
|
2752
2752
|
return this._def.type._parse({
|
|
@@ -2764,13 +2764,13 @@ class ye extends _ {
|
|
|
2764
2764
|
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2765
2765
|
if (r.common.async)
|
|
2766
2766
|
return (async () => {
|
|
2767
|
-
const
|
|
2767
|
+
const i = await this._def.in._parseAsync({
|
|
2768
2768
|
data: r.data,
|
|
2769
2769
|
path: r.path,
|
|
2770
2770
|
parent: r
|
|
2771
2771
|
});
|
|
2772
|
-
return
|
|
2773
|
-
data:
|
|
2772
|
+
return i.status === "aborted" ? y : i.status === "dirty" ? (t.dirty(), Y(i.value)) : this._def.out._parseAsync({
|
|
2773
|
+
data: i.value,
|
|
2774
2774
|
path: r.path,
|
|
2775
2775
|
parent: r
|
|
2776
2776
|
});
|
|
@@ -2813,29 +2813,29 @@ ge.create = (n, e) => new ge({
|
|
|
2813
2813
|
typeName: g.ZodReadonly,
|
|
2814
2814
|
...v(e)
|
|
2815
2815
|
});
|
|
2816
|
-
function
|
|
2816
|
+
function ze(n, e) {
|
|
2817
2817
|
const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
2820
|
function Ye(n, e = {}, t) {
|
|
2821
|
-
return n ?
|
|
2822
|
-
var
|
|
2821
|
+
return n ? G.create().superRefine((r, s) => {
|
|
2822
|
+
var i, o;
|
|
2823
2823
|
const c = n(r);
|
|
2824
2824
|
if (c instanceof Promise)
|
|
2825
2825
|
return c.then((l) => {
|
|
2826
|
-
var
|
|
2826
|
+
var u, f;
|
|
2827
2827
|
if (!l) {
|
|
2828
|
-
const b =
|
|
2828
|
+
const b = ze(e, r), w = (f = (u = b.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
|
|
2829
2829
|
s.addIssue({ code: "custom", ...b, fatal: w });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
2832
|
if (!c) {
|
|
2833
|
-
const l =
|
|
2834
|
-
s.addIssue({ code: "custom", ...l, fatal:
|
|
2833
|
+
const l = ze(e, r), u = (o = (i = l.fatal) !== null && i !== void 0 ? i : t) !== null && o !== void 0 ? o : !0;
|
|
2834
|
+
s.addIssue({ code: "custom", ...l, fatal: u });
|
|
2835
2835
|
}
|
|
2836
|
-
}) :
|
|
2836
|
+
}) : G.create();
|
|
2837
2837
|
}
|
|
2838
|
-
const
|
|
2838
|
+
const Pt = {
|
|
2839
2839
|
object: k.lazycreate
|
|
2840
2840
|
};
|
|
2841
2841
|
var g;
|
|
@@ -2844,30 +2844,30 @@ var g;
|
|
|
2844
2844
|
})(g || (g = {}));
|
|
2845
2845
|
const Et = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) => Ye((t) => t instanceof n, e), Xe =
|
|
2848
|
-
string: (n) =>
|
|
2847
|
+
}) => Ye((t) => t instanceof n, e), Xe = A.create, Je = V.create, Rt = Te.create, Mt = z.create, Ge = ae.create, $t = B.create, Vt = xe.create, zt = ie.create, Ft = oe.create, Ut = G.create, Lt = L.create, qt = $.create, Bt = ke.create, Wt = C.create, Qt = k.create, Yt = k.strictCreate, Xt = ce.create, Jt = Se.create, Gt = ue.create, Ht = P.create, Kt = de.create, en = we.create, tn = W.create, nn = X.create, rn = le.create, sn = me.create, an = F.create, on = pe.create, cn = H.create, Fe = Z.create, un = D.create, dn = U.create, ln = Z.createWithPreprocess, mn = ye.create, pn = () => Xe().optional(), fn = () => Je().optional(), hn = () => Ge().optional(), gn = {
|
|
2848
|
+
string: (n) => A.create({ ...n, coerce: !0 }),
|
|
2849
2849
|
number: (n) => V.create({ ...n, coerce: !0 }),
|
|
2850
2850
|
boolean: (n) => ae.create({
|
|
2851
2851
|
...n,
|
|
2852
2852
|
coerce: !0
|
|
2853
2853
|
}),
|
|
2854
|
-
bigint: (n) =>
|
|
2854
|
+
bigint: (n) => z.create({ ...n, coerce: !0 }),
|
|
2855
2855
|
date: (n) => B.create({ ...n, coerce: !0 })
|
|
2856
|
-
},
|
|
2857
|
-
var
|
|
2856
|
+
}, yn = y;
|
|
2857
|
+
var a = /* @__PURE__ */ Object.freeze({
|
|
2858
2858
|
__proto__: null,
|
|
2859
2859
|
defaultErrorMap: J,
|
|
2860
2860
|
setErrorMap: dt,
|
|
2861
2861
|
getErrorMap: ve,
|
|
2862
2862
|
makeIssue: _e,
|
|
2863
|
-
EMPTY_PATH:
|
|
2863
|
+
EMPTY_PATH: lt,
|
|
2864
2864
|
addIssueToContext: m,
|
|
2865
2865
|
ParseStatus: T,
|
|
2866
2866
|
INVALID: y,
|
|
2867
2867
|
DIRTY: Y,
|
|
2868
|
-
OK:
|
|
2868
|
+
OK: S,
|
|
2869
2869
|
isAborted: Oe,
|
|
2870
|
-
isDirty:
|
|
2870
|
+
isDirty: Pe,
|
|
2871
2871
|
isValid: q,
|
|
2872
2872
|
isAsync: se,
|
|
2873
2873
|
get util() {
|
|
@@ -2876,340 +2876,341 @@ var i = /* @__PURE__ */ Object.freeze({
|
|
|
2876
2876
|
get objectUtil() {
|
|
2877
2877
|
return De;
|
|
2878
2878
|
},
|
|
2879
|
-
ZodParsedType:
|
|
2880
|
-
getParsedType:
|
|
2879
|
+
ZodParsedType: p,
|
|
2880
|
+
getParsedType: R,
|
|
2881
2881
|
ZodType: _,
|
|
2882
2882
|
datetimeRegex: We,
|
|
2883
|
-
ZodString:
|
|
2883
|
+
ZodString: A,
|
|
2884
2884
|
ZodNumber: V,
|
|
2885
|
-
ZodBigInt:
|
|
2885
|
+
ZodBigInt: z,
|
|
2886
2886
|
ZodBoolean: ae,
|
|
2887
2887
|
ZodDate: B,
|
|
2888
2888
|
ZodSymbol: xe,
|
|
2889
2889
|
ZodUndefined: ie,
|
|
2890
2890
|
ZodNull: oe,
|
|
2891
|
-
ZodAny:
|
|
2891
|
+
ZodAny: G,
|
|
2892
2892
|
ZodUnknown: L,
|
|
2893
2893
|
ZodNever: $,
|
|
2894
2894
|
ZodVoid: ke,
|
|
2895
2895
|
ZodArray: C,
|
|
2896
2896
|
ZodObject: k,
|
|
2897
2897
|
ZodUnion: ce,
|
|
2898
|
-
ZodDiscriminatedUnion:
|
|
2899
|
-
ZodIntersection:
|
|
2900
|
-
ZodTuple:
|
|
2901
|
-
ZodRecord:
|
|
2898
|
+
ZodDiscriminatedUnion: Se,
|
|
2899
|
+
ZodIntersection: ue,
|
|
2900
|
+
ZodTuple: P,
|
|
2901
|
+
ZodRecord: de,
|
|
2902
2902
|
ZodMap: we,
|
|
2903
2903
|
ZodSet: W,
|
|
2904
2904
|
ZodFunction: X,
|
|
2905
2905
|
ZodLazy: le,
|
|
2906
2906
|
ZodLiteral: me,
|
|
2907
|
-
ZodEnum:
|
|
2908
|
-
ZodNativeEnum:
|
|
2909
|
-
ZodPromise:
|
|
2907
|
+
ZodEnum: F,
|
|
2908
|
+
ZodNativeEnum: pe,
|
|
2909
|
+
ZodPromise: H,
|
|
2910
2910
|
ZodEffects: Z,
|
|
2911
2911
|
ZodTransformer: Z,
|
|
2912
2912
|
ZodOptional: D,
|
|
2913
2913
|
ZodNullable: U,
|
|
2914
|
-
ZodDefault:
|
|
2914
|
+
ZodDefault: fe,
|
|
2915
2915
|
ZodCatch: he,
|
|
2916
2916
|
ZodNaN: Te,
|
|
2917
|
-
BRAND:
|
|
2918
|
-
ZodBranded:
|
|
2917
|
+
BRAND: Ot,
|
|
2918
|
+
ZodBranded: Re,
|
|
2919
2919
|
ZodPipeline: ye,
|
|
2920
2920
|
ZodReadonly: ge,
|
|
2921
2921
|
custom: Ye,
|
|
2922
2922
|
Schema: _,
|
|
2923
2923
|
ZodSchema: _,
|
|
2924
|
-
late:
|
|
2924
|
+
late: Pt,
|
|
2925
2925
|
get ZodFirstPartyTypeKind() {
|
|
2926
2926
|
return g;
|
|
2927
2927
|
},
|
|
2928
|
-
coerce:
|
|
2929
|
-
any:
|
|
2930
|
-
array:
|
|
2931
|
-
bigint:
|
|
2932
|
-
boolean:
|
|
2933
|
-
date:
|
|
2934
|
-
discriminatedUnion:
|
|
2935
|
-
effect:
|
|
2936
|
-
enum:
|
|
2937
|
-
function:
|
|
2928
|
+
coerce: gn,
|
|
2929
|
+
any: Ut,
|
|
2930
|
+
array: Wt,
|
|
2931
|
+
bigint: Mt,
|
|
2932
|
+
boolean: Ge,
|
|
2933
|
+
date: $t,
|
|
2934
|
+
discriminatedUnion: Jt,
|
|
2935
|
+
effect: Fe,
|
|
2936
|
+
enum: an,
|
|
2937
|
+
function: nn,
|
|
2938
2938
|
instanceof: Et,
|
|
2939
|
-
intersection:
|
|
2940
|
-
lazy:
|
|
2941
|
-
literal:
|
|
2942
|
-
map:
|
|
2939
|
+
intersection: Gt,
|
|
2940
|
+
lazy: rn,
|
|
2941
|
+
literal: sn,
|
|
2942
|
+
map: en,
|
|
2943
2943
|
nan: Rt,
|
|
2944
|
-
nativeEnum:
|
|
2945
|
-
never:
|
|
2944
|
+
nativeEnum: on,
|
|
2945
|
+
never: qt,
|
|
2946
2946
|
null: Ft,
|
|
2947
2947
|
nullable: dn,
|
|
2948
2948
|
number: Je,
|
|
2949
|
-
object:
|
|
2950
|
-
oboolean:
|
|
2949
|
+
object: Qt,
|
|
2950
|
+
oboolean: hn,
|
|
2951
2951
|
onumber: fn,
|
|
2952
|
-
optional:
|
|
2953
|
-
ostring:
|
|
2954
|
-
pipeline:
|
|
2955
|
-
preprocess:
|
|
2956
|
-
promise:
|
|
2957
|
-
record:
|
|
2958
|
-
set:
|
|
2959
|
-
strictObject:
|
|
2952
|
+
optional: un,
|
|
2953
|
+
ostring: pn,
|
|
2954
|
+
pipeline: mn,
|
|
2955
|
+
preprocess: ln,
|
|
2956
|
+
promise: cn,
|
|
2957
|
+
record: Kt,
|
|
2958
|
+
set: tn,
|
|
2959
|
+
strictObject: Yt,
|
|
2960
2960
|
string: Xe,
|
|
2961
|
-
symbol:
|
|
2962
|
-
transformer:
|
|
2961
|
+
symbol: Vt,
|
|
2962
|
+
transformer: Fe,
|
|
2963
2963
|
tuple: Ht,
|
|
2964
|
-
undefined:
|
|
2965
|
-
union:
|
|
2966
|
-
unknown:
|
|
2967
|
-
void:
|
|
2968
|
-
NEVER:
|
|
2969
|
-
ZodIssueCode:
|
|
2970
|
-
quotelessJson:
|
|
2971
|
-
ZodError:
|
|
2964
|
+
undefined: zt,
|
|
2965
|
+
union: Xt,
|
|
2966
|
+
unknown: Lt,
|
|
2967
|
+
void: Bt,
|
|
2968
|
+
NEVER: yn,
|
|
2969
|
+
ZodIssueCode: d,
|
|
2970
|
+
quotelessJson: ut,
|
|
2971
|
+
ZodError: N
|
|
2972
2972
|
});
|
|
2973
|
-
const
|
|
2974
|
-
country:
|
|
2975
|
-
city:
|
|
2976
|
-
street:
|
|
2977
|
-
streetNumber:
|
|
2978
|
-
floor:
|
|
2979
|
-
apartmentEnterNumber:
|
|
2980
|
-
apartmentNumber:
|
|
2981
|
-
}), M =
|
|
2982
|
-
function
|
|
2973
|
+
const Ie = a.object({
|
|
2974
|
+
country: a.string().optional(),
|
|
2975
|
+
city: a.string().optional(),
|
|
2976
|
+
street: a.string().optional(),
|
|
2977
|
+
streetNumber: a.string().optional(),
|
|
2978
|
+
floor: a.string().optional(),
|
|
2979
|
+
apartmentEnterNumber: a.string().optional(),
|
|
2980
|
+
apartmentNumber: a.string().optional()
|
|
2981
|
+
}), M = a.string().min(1, { message: "שדה חובה" }), Mn = a.string().regex(/^\d+$/, "Must be a numeric string"), $n = a.object({ url: a.string().url(), id: a.string() });
|
|
2982
|
+
function Vn(n) {
|
|
2983
2983
|
return !!(n != null && n.url);
|
|
2984
2984
|
}
|
|
2985
|
-
const re =
|
|
2986
|
-
lang:
|
|
2987
|
-
value:
|
|
2988
|
-
}),
|
|
2989
|
-
id:
|
|
2990
|
-
companyId:
|
|
2991
|
-
storeId:
|
|
2992
|
-
parentId:
|
|
2993
|
-
tag:
|
|
2994
|
-
locales:
|
|
2995
|
-
depth:
|
|
2996
|
-
}), Me =
|
|
2997
|
-
children:
|
|
2998
|
-
}),
|
|
2999
|
-
index:
|
|
3000
|
-
depth:
|
|
3001
|
-
collapsed:
|
|
3002
|
-
children:
|
|
3003
|
-
}), ee =
|
|
3004
|
-
type:
|
|
2985
|
+
const re = a.object({
|
|
2986
|
+
lang: a.enum(["he"]),
|
|
2987
|
+
value: a.string()
|
|
2988
|
+
}), zn = a.array(re), He = a.object({
|
|
2989
|
+
id: a.string().min(1),
|
|
2990
|
+
companyId: a.string().min(1),
|
|
2991
|
+
storeId: a.string().min(1),
|
|
2992
|
+
parentId: a.string().nullish(),
|
|
2993
|
+
tag: a.string().optional(),
|
|
2994
|
+
locales: a.array(re),
|
|
2995
|
+
depth: a.number()
|
|
2996
|
+
}), Me = He.extend({
|
|
2997
|
+
children: a.lazy(() => Me.array())
|
|
2998
|
+
}), Fn = He.extend({
|
|
2999
|
+
index: a.number(),
|
|
3000
|
+
depth: a.number(),
|
|
3001
|
+
collapsed: a.boolean().optional(),
|
|
3002
|
+
children: a.array(Me)
|
|
3003
|
+
}), ee = a.string().min(1), Ke = a.object({
|
|
3004
|
+
type: a.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: a.array(re),
|
|
3011
|
+
description: a.array(re),
|
|
3012
|
+
isPublished: a.boolean(),
|
|
3013
|
+
vat: a.boolean(),
|
|
3014
|
+
priceType: a.object({
|
|
3015
|
+
type: a.enum(["unit", "kg", "gram", "liter", "ml"]),
|
|
3016
|
+
value: a.number()
|
|
3017
3017
|
}),
|
|
3018
|
-
price:
|
|
3019
|
-
purchasePrice:
|
|
3020
|
-
profitPercentage:
|
|
3021
|
-
currency:
|
|
3022
|
-
discount:
|
|
3023
|
-
type:
|
|
3024
|
-
value:
|
|
3018
|
+
price: a.number().positive(),
|
|
3019
|
+
purchasePrice: a.number().optional(),
|
|
3020
|
+
profitPercentage: a.number().optional(),
|
|
3021
|
+
currency: a.literal("ILS"),
|
|
3022
|
+
discount: a.object({
|
|
3023
|
+
type: a.enum(["number", "percent", "none"]),
|
|
3024
|
+
value: a.number()
|
|
3025
3025
|
}),
|
|
3026
|
-
isDiscountable:
|
|
3027
|
-
weight:
|
|
3028
|
-
value:
|
|
3029
|
-
unit:
|
|
3026
|
+
isDiscountable: a.boolean({ description: "included in store discounts" }).optional(),
|
|
3027
|
+
weight: a.object({
|
|
3028
|
+
value: a.number(),
|
|
3029
|
+
unit: a.enum(["kg", "gram", "none"])
|
|
3030
3030
|
}),
|
|
3031
|
-
volume:
|
|
3032
|
-
value:
|
|
3033
|
-
unit:
|
|
3031
|
+
volume: a.object({
|
|
3032
|
+
value: a.number(),
|
|
3033
|
+
unit: a.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:
|
|
3035
|
+
images: a.array(a.object({ url: a.string().url(), id: a.string() })),
|
|
3036
|
+
manufacturer: a.string(),
|
|
3037
|
+
brand: a.string(),
|
|
3038
|
+
importer: a.string(),
|
|
3039
|
+
supplier: a.string(),
|
|
3040
|
+
ingredients: a.array(re),
|
|
3041
|
+
created_at: a.number(),
|
|
3042
|
+
updated_at: a.number(),
|
|
3043
|
+
categoryIds: a.array(a.string().nonempty()),
|
|
3044
3044
|
// @deprecated
|
|
3045
|
-
categoryList:
|
|
3045
|
+
categoryList: a.array(Me).optional(),
|
|
3046
3046
|
// @deprecated
|
|
3047
|
-
categories:
|
|
3048
|
-
lvl0:
|
|
3049
|
-
lvl1:
|
|
3050
|
-
lvl2:
|
|
3051
|
-
lvl3:
|
|
3052
|
-
lvl4:
|
|
3047
|
+
categories: a.object({
|
|
3048
|
+
lvl0: a.array(a.string()),
|
|
3049
|
+
lvl1: a.array(a.string()),
|
|
3050
|
+
lvl2: a.array(a.string()),
|
|
3051
|
+
lvl3: a.array(a.string()),
|
|
3052
|
+
lvl4: a.array(a.string())
|
|
3053
3053
|
}).optional(),
|
|
3054
3054
|
// @deprecated
|
|
3055
|
-
categoryNames:
|
|
3056
|
-
}),
|
|
3057
|
-
image:
|
|
3058
|
-
}), et =
|
|
3055
|
+
categoryNames: a.array(a.string()).optional()
|
|
3056
|
+
}), Un = Ke.extend({
|
|
3057
|
+
image: a.instanceof(File).optional()
|
|
3058
|
+
}), et = a.object({
|
|
3059
3059
|
product: Ke,
|
|
3060
|
-
originalPrice:
|
|
3061
|
-
finalPrice:
|
|
3062
|
-
finalDiscount:
|
|
3063
|
-
amount:
|
|
3064
|
-
}),
|
|
3065
|
-
type:
|
|
3066
|
-
id:
|
|
3067
|
-
companyId:
|
|
3068
|
-
storeId:
|
|
3069
|
-
userId:
|
|
3070
|
-
status:
|
|
3071
|
-
items:
|
|
3072
|
-
}),
|
|
3073
|
-
id:
|
|
3074
|
-
name:
|
|
3075
|
-
websiteDomains:
|
|
3076
|
-
}),
|
|
3077
|
-
type:
|
|
3078
|
-
id:
|
|
3079
|
-
companyId:
|
|
3080
|
-
storeId:
|
|
3081
|
-
userId:
|
|
3082
|
-
productId:
|
|
3083
|
-
}),
|
|
3084
|
-
type:
|
|
3060
|
+
originalPrice: a.number().optional(),
|
|
3061
|
+
finalPrice: a.number().optional(),
|
|
3062
|
+
finalDiscount: a.number().optional(),
|
|
3063
|
+
amount: a.number().positive({ message: "Quantity must be a positive number." })
|
|
3064
|
+
}), Ln = a.object({
|
|
3065
|
+
type: a.literal("Cart"),
|
|
3066
|
+
id: a.string().uuid(),
|
|
3067
|
+
companyId: a.string().uuid(),
|
|
3068
|
+
storeId: a.string().uuid(),
|
|
3069
|
+
userId: a.string().uuid(),
|
|
3070
|
+
status: a.enum(["active", "draft", "completed"]),
|
|
3071
|
+
items: a.array(et)
|
|
3072
|
+
}), qn = a.object({
|
|
3073
|
+
id: a.string(),
|
|
3074
|
+
name: a.string(),
|
|
3075
|
+
websiteDomains: a.array(a.string())
|
|
3076
|
+
}), Bn = a.object({
|
|
3077
|
+
type: a.literal("FavoriteProduct"),
|
|
3078
|
+
id: a.string().uuid(),
|
|
3079
|
+
companyId: a.string().uuid(),
|
|
3080
|
+
storeId: a.string().uuid(),
|
|
3081
|
+
userId: a.string().uuid(),
|
|
3082
|
+
productId: a.string().uuid()
|
|
3083
|
+
}), Ne = a.enum(["external", "j5", "none"]), vn = a.object({
|
|
3084
|
+
type: a.literal("Profile"),
|
|
3085
3085
|
id: M,
|
|
3086
3086
|
companyId: M,
|
|
3087
3087
|
storeId: M,
|
|
3088
3088
|
tenantId: M,
|
|
3089
|
-
clientType:
|
|
3090
|
-
companyName:
|
|
3089
|
+
clientType: a.enum(["user", "company"]),
|
|
3090
|
+
companyName: a.string().optional(),
|
|
3091
3091
|
displayName: M,
|
|
3092
|
-
email:
|
|
3093
|
-
phoneNumber:
|
|
3094
|
-
address:
|
|
3095
|
-
isAnonymous:
|
|
3096
|
-
createdDate:
|
|
3097
|
-
lastActivityDate:
|
|
3098
|
-
paymentType:
|
|
3099
|
-
organizationId:
|
|
3100
|
-
}), tt =
|
|
3101
|
-
_COMMENT:
|
|
3102
|
-
transaction_id:
|
|
3103
|
-
date:
|
|
3104
|
-
currency:
|
|
3105
|
-
rate:
|
|
3106
|
-
vat:
|
|
3107
|
-
vat_price:
|
|
3108
|
-
price_discount:
|
|
3109
|
-
price_discount_in_currency:
|
|
3110
|
-
price_total:
|
|
3111
|
-
price_total_in_currency:
|
|
3112
|
-
}),
|
|
3113
|
-
doc_uuid:
|
|
3114
|
-
pdf_link:
|
|
3115
|
-
pdf_link_copy:
|
|
3116
|
-
doc_number:
|
|
3117
|
-
sent_mails:
|
|
3118
|
-
success:
|
|
3119
|
-
ua_uuid:
|
|
3092
|
+
email: a.string().email(),
|
|
3093
|
+
phoneNumber: a.string().optional(),
|
|
3094
|
+
address: Ie.optional(),
|
|
3095
|
+
isAnonymous: a.boolean(),
|
|
3096
|
+
createdDate: a.number(),
|
|
3097
|
+
lastActivityDate: a.number(),
|
|
3098
|
+
paymentType: Ne,
|
|
3099
|
+
organizationId: a.string().optional().nullable()
|
|
3100
|
+
}), tt = a.object({
|
|
3101
|
+
_COMMENT: a.string().optional(),
|
|
3102
|
+
transaction_id: a.string(),
|
|
3103
|
+
date: a.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
|
|
3104
|
+
currency: a.string().length(3, "Currency must be 3 characters"),
|
|
3105
|
+
rate: a.number().positive(),
|
|
3106
|
+
vat: a.string().regex(/^\d+\.\d{2}$/, "VAT must be in format XX.XX"),
|
|
3107
|
+
vat_price: a.number().positive(),
|
|
3108
|
+
price_discount: a.number(),
|
|
3109
|
+
price_discount_in_currency: a.number(),
|
|
3110
|
+
price_total: a.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
|
|
3111
|
+
price_total_in_currency: a.number().positive()
|
|
3112
|
+
}), _n = a.object({
|
|
3113
|
+
doc_uuid: a.string().uuid("Document UUID must be a valid UUID"),
|
|
3114
|
+
pdf_link: a.string().url("PDF link must be a valid URL"),
|
|
3115
|
+
pdf_link_copy: a.string().url("PDF copy link must be a valid URL"),
|
|
3116
|
+
doc_number: a.string().min(1, "Document number is required"),
|
|
3117
|
+
sent_mails: a.array(a.string().email("Each email must be valid")),
|
|
3118
|
+
success: a.boolean(),
|
|
3119
|
+
ua_uuid: a.string().uuid("UA UUID must be a valid UUID"),
|
|
3120
3120
|
calculatedData: tt,
|
|
3121
|
-
warning:
|
|
3122
|
-
date:
|
|
3123
|
-
}),
|
|
3124
|
-
id:
|
|
3125
|
-
number:
|
|
3126
|
-
date:
|
|
3127
|
-
createdAt:
|
|
3128
|
-
status:
|
|
3129
|
-
companyDetails:
|
|
3130
|
-
name:
|
|
3131
|
-
address:
|
|
3132
|
-
phone:
|
|
3133
|
-
email:
|
|
3121
|
+
warning: a.string().optional(),
|
|
3122
|
+
date: a.number().optional()
|
|
3123
|
+
}), bn = a.object({
|
|
3124
|
+
id: a.string().min(1, "ID is required"),
|
|
3125
|
+
number: a.string().min(1, "Number is required"),
|
|
3126
|
+
date: a.number().min(1, "Date is required"),
|
|
3127
|
+
createdAt: a.number().min(1, "Created at is required"),
|
|
3128
|
+
status: a.enum(["pending", "paid", "cancelled"]),
|
|
3129
|
+
companyDetails: a.object({
|
|
3130
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3131
|
+
address: a.string().min(1, "Address is required").optional(),
|
|
3132
|
+
phone: a.string().min(1, "Phone is required").optional(),
|
|
3133
|
+
email: a.string().email("Email must be valid").optional()
|
|
3134
3134
|
}).optional(),
|
|
3135
|
-
clientDetails:
|
|
3136
|
-
name:
|
|
3137
|
-
address:
|
|
3138
|
-
phone:
|
|
3139
|
-
email:
|
|
3135
|
+
clientDetails: a.object({
|
|
3136
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3137
|
+
address: a.string().min(1, "Address is required").optional(),
|
|
3138
|
+
phone: a.string().min(1, "Phone is required").optional(),
|
|
3139
|
+
email: a.string().email("Email must be valid").optional()
|
|
3140
3140
|
}).optional(),
|
|
3141
|
-
items:
|
|
3142
|
-
|
|
3143
|
-
name:
|
|
3144
|
-
price:
|
|
3145
|
-
quantity:
|
|
3146
|
-
total:
|
|
3141
|
+
items: a.array(
|
|
3142
|
+
a.object({
|
|
3143
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3144
|
+
price: a.number().min(1, "Price is required").optional(),
|
|
3145
|
+
quantity: a.number().min(1, "Quantity is required").optional(),
|
|
3146
|
+
total: a.number().min(1, "Total is required").optional()
|
|
3147
3147
|
})
|
|
3148
3148
|
).optional(),
|
|
3149
|
-
total:
|
|
3150
|
-
vat:
|
|
3151
|
-
link:
|
|
3152
|
-
}), nt =
|
|
3153
|
-
number:
|
|
3154
|
-
name:
|
|
3155
|
-
id:
|
|
3156
|
-
}),
|
|
3157
|
-
id:
|
|
3158
|
-
name:
|
|
3159
|
-
discountPercentage:
|
|
3160
|
-
nameOnInvoice:
|
|
3161
|
-
billingAccounts:
|
|
3162
|
-
paymentType:
|
|
3163
|
-
companyNumber:
|
|
3164
|
-
address:
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3149
|
+
total: a.number().min(1, "Total is required").optional(),
|
|
3150
|
+
vat: a.number().min(1, "VAT is required").optional(),
|
|
3151
|
+
link: a.string().url("Link must be a valid URL").optional()
|
|
3152
|
+
}), nt = a.object({
|
|
3153
|
+
number: a.string(),
|
|
3154
|
+
name: a.string(),
|
|
3155
|
+
id: a.string()
|
|
3156
|
+
}), xn = a.object({
|
|
3157
|
+
id: a.string(),
|
|
3158
|
+
name: a.string(),
|
|
3159
|
+
discountPercentage: a.number().positive().min(0).max(100).optional(),
|
|
3160
|
+
nameOnInvoice: a.string().optional(),
|
|
3161
|
+
billingAccounts: a.array(nt),
|
|
3162
|
+
paymentType: Ne,
|
|
3163
|
+
companyNumber: a.string().optional(),
|
|
3164
|
+
address: Ie.optional(),
|
|
3165
|
+
groupId: a.string().optional()
|
|
3166
|
+
}), Wn = xn.omit({ id: !0 }), kn = a.object({
|
|
3167
|
+
doc_uuid: a.string().uuid("Document UUID must be a valid UUID"),
|
|
3168
|
+
pdf_link: a.string().url("PDF link must be a valid URL"),
|
|
3169
|
+
pdf_link_copy: a.string().url("PDF copy link must be a valid URL"),
|
|
3170
|
+
doc_number: a.string().min(1, "Document number is required"),
|
|
3171
|
+
sent_mails: a.array(a.string().email("Each email must be valid")),
|
|
3172
|
+
success: a.boolean(),
|
|
3173
|
+
ua_uuid: a.string().uuid("UA UUID must be a valid UUID"),
|
|
3173
3174
|
calculatedData: tt,
|
|
3174
|
-
warning:
|
|
3175
|
-
date:
|
|
3176
|
-
}),
|
|
3177
|
-
id:
|
|
3178
|
-
number:
|
|
3179
|
-
date:
|
|
3180
|
-
createdAt:
|
|
3181
|
-
status:
|
|
3182
|
-
companyDetails:
|
|
3183
|
-
name:
|
|
3184
|
-
address:
|
|
3185
|
-
phone:
|
|
3186
|
-
email:
|
|
3175
|
+
warning: a.string().optional(),
|
|
3176
|
+
date: a.number().optional()
|
|
3177
|
+
}), wn = a.object({
|
|
3178
|
+
id: a.string().min(1, "ID is required"),
|
|
3179
|
+
number: a.string().min(1, "Number is required"),
|
|
3180
|
+
date: a.string().min(1, "Date is required"),
|
|
3181
|
+
createdAt: a.number().min(1, "Created at is required"),
|
|
3182
|
+
status: a.enum(["pending", "paid", "cancelled"]),
|
|
3183
|
+
companyDetails: a.object({
|
|
3184
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3185
|
+
address: a.string().min(1, "Address is required").optional(),
|
|
3186
|
+
phone: a.string().min(1, "Phone is required").optional(),
|
|
3187
|
+
email: a.string().email("Email must be valid").optional()
|
|
3187
3188
|
}).optional(),
|
|
3188
|
-
clientDetails:
|
|
3189
|
-
name:
|
|
3190
|
-
address:
|
|
3191
|
-
phone:
|
|
3192
|
-
email:
|
|
3189
|
+
clientDetails: a.object({
|
|
3190
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3191
|
+
address: a.string().min(1, "Address is required").optional(),
|
|
3192
|
+
phone: a.string().min(1, "Phone is required").optional(),
|
|
3193
|
+
email: a.string().email("Email must be valid").optional()
|
|
3193
3194
|
}).optional(),
|
|
3194
|
-
items:
|
|
3195
|
-
|
|
3196
|
-
name:
|
|
3197
|
-
price:
|
|
3198
|
-
quantity:
|
|
3199
|
-
total:
|
|
3195
|
+
items: a.array(
|
|
3196
|
+
a.object({
|
|
3197
|
+
name: a.string().min(1, "Name is required").optional(),
|
|
3198
|
+
price: a.number().min(1, "Price is required").optional(),
|
|
3199
|
+
quantity: a.number().min(1, "Quantity is required").optional(),
|
|
3200
|
+
total: a.number().min(1, "Total is required").optional()
|
|
3200
3201
|
})
|
|
3201
3202
|
).optional(),
|
|
3202
|
-
total:
|
|
3203
|
-
vat:
|
|
3204
|
-
link:
|
|
3205
|
-
}),
|
|
3206
|
-
type:
|
|
3207
|
-
createdBy:
|
|
3203
|
+
total: a.number().min(1, "Total is required").optional(),
|
|
3204
|
+
vat: a.number().min(1, "VAT is required").optional(),
|
|
3205
|
+
link: a.string().url("Link must be a valid URL").optional()
|
|
3206
|
+
}), Qn = a.object({
|
|
3207
|
+
type: a.literal("Order"),
|
|
3208
|
+
createdBy: a.enum(["user", "admin"]).optional(),
|
|
3208
3209
|
id: M,
|
|
3209
3210
|
companyId: M,
|
|
3210
3211
|
storeId: M,
|
|
3211
3212
|
userId: M,
|
|
3212
|
-
status:
|
|
3213
|
+
status: a.enum([
|
|
3213
3214
|
"draft",
|
|
3214
3215
|
// before payment
|
|
3215
3216
|
"pending",
|
|
@@ -3223,85 +3224,85 @@ const re = i.object({
|
|
|
3223
3224
|
"completed",
|
|
3224
3225
|
"refunded"
|
|
3225
3226
|
]),
|
|
3226
|
-
paymentType:
|
|
3227
|
-
paymentStatus:
|
|
3227
|
+
paymentType: Ne.optional(),
|
|
3228
|
+
paymentStatus: a.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
|
|
3228
3229
|
//todo check if hyp support partial refund
|
|
3229
|
-
cart:
|
|
3230
|
-
id:
|
|
3231
|
-
items:
|
|
3232
|
-
cartDiscount:
|
|
3233
|
-
cartTotal:
|
|
3234
|
-
cartVat:
|
|
3235
|
-
deliveryPrice:
|
|
3230
|
+
cart: a.object({
|
|
3231
|
+
id: a.string(),
|
|
3232
|
+
items: a.array(et),
|
|
3233
|
+
cartDiscount: a.number(),
|
|
3234
|
+
cartTotal: a.number(),
|
|
3235
|
+
cartVat: a.number(),
|
|
3236
|
+
deliveryPrice: a.number().optional()
|
|
3236
3237
|
// final delivery price for cart
|
|
3237
3238
|
}),
|
|
3238
|
-
storeOptions:
|
|
3239
|
-
deliveryPrice:
|
|
3240
|
-
freeDeliveryPrice:
|
|
3241
|
-
isVatIncludedInPrice:
|
|
3239
|
+
storeOptions: a.object({
|
|
3240
|
+
deliveryPrice: a.number().optional(),
|
|
3241
|
+
freeDeliveryPrice: a.number().optional(),
|
|
3242
|
+
isVatIncludedInPrice: a.boolean().optional()
|
|
3242
3243
|
}).optional(),
|
|
3243
|
-
originalAmount:
|
|
3244
|
+
originalAmount: a.number().positive().optional(),
|
|
3244
3245
|
// what client pay
|
|
3245
|
-
actualAmount:
|
|
3246
|
+
actualAmount: a.number().positive().optional(),
|
|
3246
3247
|
// what store charge
|
|
3247
|
-
date:
|
|
3248
|
-
deliveryDate:
|
|
3249
|
-
client:
|
|
3250
|
-
address:
|
|
3251
|
-
nameOnInvoice:
|
|
3252
|
-
emailOnInvoice:
|
|
3253
|
-
phoneNumberOnInvoice:
|
|
3254
|
-
clientComment:
|
|
3255
|
-
organizationId:
|
|
3248
|
+
date: a.number(),
|
|
3249
|
+
deliveryDate: a.coerce.number(),
|
|
3250
|
+
client: vn.optional(),
|
|
3251
|
+
address: Ie.optional(),
|
|
3252
|
+
nameOnInvoice: a.string().optional(),
|
|
3253
|
+
emailOnInvoice: a.string().email().optional(),
|
|
3254
|
+
phoneNumberOnInvoice: a.string().optional(),
|
|
3255
|
+
clientComment: a.string().optional(),
|
|
3256
|
+
organizationId: a.string().optional(),
|
|
3256
3257
|
billingAccount: nt.optional(),
|
|
3257
|
-
deliveryNote:
|
|
3258
|
-
invoice:
|
|
3259
|
-
ezInvoice:
|
|
3260
|
-
ezDeliveryNote:
|
|
3261
|
-
}),
|
|
3262
|
-
id:
|
|
3263
|
-
companyId:
|
|
3264
|
-
name:
|
|
3265
|
-
urls:
|
|
3266
|
-
logoUrl:
|
|
3267
|
-
tenantId:
|
|
3258
|
+
deliveryNote: bn.optional(),
|
|
3259
|
+
invoice: wn.optional(),
|
|
3260
|
+
ezInvoice: kn.optional(),
|
|
3261
|
+
ezDeliveryNote: _n.optional()
|
|
3262
|
+
}), Tn = a.enum(["individual", "company"]), Yn = a.object({
|
|
3263
|
+
id: a.string(),
|
|
3264
|
+
companyId: a.string(),
|
|
3265
|
+
name: a.string(),
|
|
3266
|
+
urls: a.array(a.string()),
|
|
3267
|
+
logoUrl: a.string(),
|
|
3268
|
+
tenantId: a.string(),
|
|
3268
3269
|
// firebase auth tenantId
|
|
3269
|
-
paymentType:
|
|
3270
|
-
allowAnonymousClients:
|
|
3271
|
-
isVatIncludedInPrice:
|
|
3272
|
-
clientTypes:
|
|
3273
|
-
minimumOrder:
|
|
3274
|
-
freeDeliveryPrice:
|
|
3275
|
-
deliveryPrice:
|
|
3276
|
-
address:
|
|
3277
|
-
companyNumber:
|
|
3270
|
+
paymentType: Ne,
|
|
3271
|
+
allowAnonymousClients: a.boolean(),
|
|
3272
|
+
isVatIncludedInPrice: a.boolean(),
|
|
3273
|
+
clientTypes: a.array(Tn),
|
|
3274
|
+
minimumOrder: a.number().optional(),
|
|
3275
|
+
freeDeliveryPrice: a.number().optional(),
|
|
3276
|
+
deliveryPrice: a.number().optional(),
|
|
3277
|
+
address: Ie.optional(),
|
|
3278
|
+
companyNumber: a.string().optional()
|
|
3278
3279
|
// חפ של החברה
|
|
3279
|
-
}),
|
|
3280
|
-
minSpend:
|
|
3281
|
-
stackable:
|
|
3282
|
-
}).optional(), In =
|
|
3283
|
-
|
|
3284
|
-
variantType:
|
|
3285
|
-
productsId:
|
|
3280
|
+
}), Sn = a.object({
|
|
3281
|
+
minSpend: a.number().positive().optional(),
|
|
3282
|
+
stackable: a.boolean().default(!1)
|
|
3283
|
+
}).optional(), In = a.discriminatedUnion("variantType", [
|
|
3284
|
+
a.object({
|
|
3285
|
+
variantType: a.literal("bundle"),
|
|
3286
|
+
productsId: a.array(a.string().nonempty()).min(1),
|
|
3286
3287
|
// Which products are included
|
|
3287
|
-
requiredQuantity:
|
|
3288
|
+
requiredQuantity: a.number().positive(),
|
|
3288
3289
|
// How many items needed (e.g., 3)
|
|
3289
|
-
bundlePrice:
|
|
3290
|
+
bundlePrice: a.number().positive()
|
|
3290
3291
|
// Total price for the bundle (e.g., $25)
|
|
3291
3292
|
})
|
|
3292
|
-
]),
|
|
3293
|
-
type:
|
|
3294
|
-
storeId:
|
|
3295
|
-
companyId:
|
|
3296
|
-
id:
|
|
3297
|
-
name:
|
|
3298
|
-
active:
|
|
3299
|
-
startDate:
|
|
3300
|
-
endDate:
|
|
3293
|
+
]), Xn = a.object({
|
|
3294
|
+
type: a.literal("Discount"),
|
|
3295
|
+
storeId: a.string().min(1),
|
|
3296
|
+
companyId: a.string().min(1),
|
|
3297
|
+
id: a.string().min(1),
|
|
3298
|
+
name: a.array(a.object({ lang: a.enum(["he"]), value: a.string().nonempty() })),
|
|
3299
|
+
active: a.boolean(),
|
|
3300
|
+
startDate: a.number(),
|
|
3301
|
+
endDate: a.number(),
|
|
3301
3302
|
variant: In,
|
|
3302
|
-
conditions:
|
|
3303
|
+
conditions: Sn
|
|
3303
3304
|
});
|
|
3304
|
-
class
|
|
3305
|
+
class Nn {
|
|
3305
3306
|
canApply(e, t) {
|
|
3306
3307
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3307
3308
|
const { productsId: r, requiredQuantity: s } = e.variant;
|
|
@@ -3310,20 +3311,20 @@ class An {
|
|
|
3310
3311
|
calculate(e, t) {
|
|
3311
3312
|
if (e.variant.variantType !== "bundle")
|
|
3312
3313
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3313
|
-
const { productsId: r, requiredQuantity: s, bundlePrice:
|
|
3314
|
+
const { productsId: r, requiredQuantity: s, bundlePrice: i } = e.variant, o = t.cart.filter((K) => r.includes(K.product.id)), c = this.getTotalQuantity(t.cart, r), l = Math.floor(c / s);
|
|
3314
3315
|
if (l === 0)
|
|
3315
3316
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3316
|
-
const
|
|
3317
|
-
|
|
3318
|
-
|
|
3317
|
+
const u = this.calculateOriginalPrice(o), f = this.getTotalQuantity(t.cart, r), b = this.calculateDiscountedPrice(
|
|
3318
|
+
u,
|
|
3319
|
+
i,
|
|
3319
3320
|
l,
|
|
3320
3321
|
s,
|
|
3321
|
-
|
|
3322
|
-
), w =
|
|
3322
|
+
f
|
|
3323
|
+
), w = u - b, I = this.distributeDiscount(o, w, u);
|
|
3323
3324
|
return {
|
|
3324
3325
|
applicable: !0,
|
|
3325
3326
|
discountAmount: Number(w.toFixed(2)),
|
|
3326
|
-
affectedItems:
|
|
3327
|
+
affectedItems: I
|
|
3327
3328
|
};
|
|
3328
3329
|
}
|
|
3329
3330
|
isDiscountActive(e) {
|
|
@@ -3336,19 +3337,19 @@ class An {
|
|
|
3336
3337
|
calculateOriginalPrice(e) {
|
|
3337
3338
|
return e.reduce((t, r) => t + r.product.price * r.amount, 0);
|
|
3338
3339
|
}
|
|
3339
|
-
calculateDiscountedPrice(e, t, r, s,
|
|
3340
|
-
const o = t * r, c = r * s,
|
|
3341
|
-
return o +
|
|
3340
|
+
calculateDiscountedPrice(e, t, r, s, i) {
|
|
3341
|
+
const o = t * r, c = r * s, u = Math.max(0, i - c) / i * e;
|
|
3342
|
+
return o + u;
|
|
3342
3343
|
}
|
|
3343
3344
|
distributeDiscount(e, t, r) {
|
|
3344
3345
|
const s = t / r;
|
|
3345
|
-
return e.map((
|
|
3346
|
-
const o =
|
|
3346
|
+
return e.map((i) => {
|
|
3347
|
+
const o = i.product.price * i.amount * s;
|
|
3347
3348
|
return {
|
|
3348
|
-
productId:
|
|
3349
|
-
quantity:
|
|
3350
|
-
originalPrice: Number(
|
|
3351
|
-
discountedPrice: Number((
|
|
3349
|
+
productId: i.product.id,
|
|
3350
|
+
quantity: i.amount,
|
|
3351
|
+
originalPrice: Number(i.product.price.toFixed(2)),
|
|
3352
|
+
discountedPrice: Number((i.product.price - o / i.amount).toFixed(2)),
|
|
3352
3353
|
discountAmount: Number(o.toFixed(2))
|
|
3353
3354
|
};
|
|
3354
3355
|
});
|
|
@@ -3369,25 +3370,25 @@ class rt {
|
|
|
3369
3370
|
}
|
|
3370
3371
|
}
|
|
3371
3372
|
$e(rt, "strategies", /* @__PURE__ */ new Map([
|
|
3372
|
-
["bundle", new
|
|
3373
|
+
["bundle", new Nn()]
|
|
3373
3374
|
]));
|
|
3374
|
-
class
|
|
3375
|
+
class An {
|
|
3375
3376
|
static calculateDiscounts(e, t, r) {
|
|
3376
|
-
var
|
|
3377
|
+
var u, f;
|
|
3377
3378
|
const s = {
|
|
3378
3379
|
cart: e,
|
|
3379
3380
|
user: r,
|
|
3380
3381
|
appliedDiscounts: []
|
|
3381
|
-
},
|
|
3382
|
-
for (const b of
|
|
3382
|
+
}, i = this.filterActiveDiscounts(t), o = [];
|
|
3383
|
+
for (const b of i) {
|
|
3383
3384
|
const w = rt.getStrategy(b);
|
|
3384
|
-
if (!w || !w.canApply(b, s) || !((
|
|
3385
|
-
const
|
|
3386
|
-
|
|
3385
|
+
if (!w || !w.canApply(b, s) || !((u = b.conditions) != null && u.stackable) && o.length > 0) continue;
|
|
3386
|
+
const I = w.calculate(b, s);
|
|
3387
|
+
I.applicable && (o.push({
|
|
3387
3388
|
discountId: b.id,
|
|
3388
|
-
discountName: ((
|
|
3389
|
-
discountAmount: Number(
|
|
3390
|
-
affectedItems:
|
|
3389
|
+
discountName: ((f = b.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3390
|
+
discountAmount: Number(I.discountAmount.toFixed(2)),
|
|
3391
|
+
affectedItems: I.affectedItems
|
|
3391
3392
|
}), s.appliedDiscounts = o);
|
|
3392
3393
|
}
|
|
3393
3394
|
const c = this.calculateFinalPrices(e, o), l = o.reduce(
|
|
@@ -3409,19 +3410,19 @@ class Sn {
|
|
|
3409
3410
|
static calculateFinalPrices(e, t) {
|
|
3410
3411
|
return e.map((r) => {
|
|
3411
3412
|
const s = t.filter(
|
|
3412
|
-
(l) => l.affectedItems.some((
|
|
3413
|
-
),
|
|
3414
|
-
const
|
|
3413
|
+
(l) => l.affectedItems.some((u) => u.productId === r.product.id)
|
|
3414
|
+
), i = s.reduce((l, u) => {
|
|
3415
|
+
const f = u.affectedItems.find(
|
|
3415
3416
|
(b) => b.productId === r.product.id
|
|
3416
3417
|
);
|
|
3417
|
-
return l + ((
|
|
3418
|
-
}, 0), o =
|
|
3418
|
+
return l + ((f == null ? void 0 : f.discountAmount) || 0);
|
|
3419
|
+
}, 0), o = i / r.amount, c = r.product.price - o;
|
|
3419
3420
|
return {
|
|
3420
3421
|
amount: r.amount,
|
|
3421
3422
|
product: r.product,
|
|
3422
3423
|
originalPrice: Number(r.product.price.toFixed(2)),
|
|
3423
3424
|
finalPrice: Number(Math.max(0, c).toFixed(2)),
|
|
3424
|
-
finalDiscount: Number(
|
|
3425
|
+
finalDiscount: Number(i.toFixed(2)),
|
|
3425
3426
|
appliedDiscounts: s.map((l) => l.discountId)
|
|
3426
3427
|
};
|
|
3427
3428
|
});
|
|
@@ -3437,25 +3438,72 @@ class Sn {
|
|
|
3437
3438
|
function st(n) {
|
|
3438
3439
|
return Number(n.toFixed(2));
|
|
3439
3440
|
}
|
|
3440
|
-
function
|
|
3441
|
+
function Jn(n) {
|
|
3441
3442
|
return n.toFixed(2);
|
|
3442
3443
|
}
|
|
3443
|
-
function
|
|
3444
|
+
function Gn(n) {
|
|
3444
3445
|
return Math.max(0, st(n));
|
|
3445
3446
|
}
|
|
3446
|
-
function
|
|
3447
|
+
function Hn(n, e) {
|
|
3447
3448
|
if (n <= 0) return 0;
|
|
3448
3449
|
const t = n - e;
|
|
3449
3450
|
return st(t / n * 100);
|
|
3450
3451
|
}
|
|
3451
|
-
const
|
|
3452
|
+
const Cn = a.object({
|
|
3453
|
+
id: a.string(),
|
|
3454
|
+
name: a.string()
|
|
3455
|
+
}), Kn = Cn.omit({ id: !0 }), at = a.object({
|
|
3456
|
+
type: a.literal("Supplier"),
|
|
3457
|
+
id: a.string(),
|
|
3458
|
+
name: a.string(),
|
|
3459
|
+
code: a.string()
|
|
3460
|
+
// supplier code number
|
|
3461
|
+
}), er = at.omit({ id: !0 }), Zn = a.object({
|
|
3462
|
+
type: a.literal("SupplierInvoice"),
|
|
3463
|
+
id: a.string(),
|
|
3464
|
+
supplier: at,
|
|
3465
|
+
invoiceNumber: a.string(),
|
|
3466
|
+
date: a.number(),
|
|
3467
|
+
rows: a.array(
|
|
3468
|
+
a.object({
|
|
3469
|
+
id: a.string(),
|
|
3470
|
+
rowNumber: a.number(),
|
|
3471
|
+
sku: a.string(),
|
|
3472
|
+
itemName: a.string(),
|
|
3473
|
+
quantity: a.number(),
|
|
3474
|
+
purchasePrice: a.number(),
|
|
3475
|
+
lineDiscount: a.number(),
|
|
3476
|
+
profitPercentage: a.number(),
|
|
3477
|
+
price: a.number(),
|
|
3478
|
+
totalPurchasePrice: a.number(),
|
|
3479
|
+
vat: a.boolean(),
|
|
3480
|
+
originalProduct: a.object({
|
|
3481
|
+
purchasePrice: a.number(),
|
|
3482
|
+
price: a.number(),
|
|
3483
|
+
profitPercentage: a.number()
|
|
3484
|
+
}).optional()
|
|
3485
|
+
})
|
|
3486
|
+
),
|
|
3487
|
+
productsToUpdate: a.array(
|
|
3488
|
+
a.object({
|
|
3489
|
+
sku: a.string(),
|
|
3490
|
+
itemName: a.string(),
|
|
3491
|
+
oldPurchasePrice: a.number(),
|
|
3492
|
+
newPurchasePrice: a.number(),
|
|
3493
|
+
oldPrice: a.number(),
|
|
3494
|
+
newPrice: a.number(),
|
|
3495
|
+
oldProfitPercentage: a.number(),
|
|
3496
|
+
newProfitPercentage: a.number()
|
|
3497
|
+
})
|
|
3498
|
+
)
|
|
3499
|
+
}), tr = Zn.omit({ id: !0 }), je = {
|
|
3452
3500
|
VAT: 18
|
|
3453
3501
|
};
|
|
3454
|
-
function
|
|
3502
|
+
function jn(n) {
|
|
3455
3503
|
var e, t;
|
|
3456
3504
|
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;
|
|
3457
3505
|
}
|
|
3458
|
-
function
|
|
3506
|
+
function Dn(n) {
|
|
3459
3507
|
var e, t;
|
|
3460
3508
|
if (((e = n.discount) == null ? void 0 : e.type) === "percent") {
|
|
3461
3509
|
const r = n.price * n.discount.value / 100;
|
|
@@ -3463,43 +3511,43 @@ function Cn(n) {
|
|
|
3463
3511
|
}
|
|
3464
3512
|
return ((t = n.discount) == null ? void 0 : t.type) === "number" ? n.price - n.discount.value : n.price;
|
|
3465
3513
|
}
|
|
3466
|
-
function
|
|
3514
|
+
function nr({
|
|
3467
3515
|
cart: n,
|
|
3468
3516
|
discounts: e,
|
|
3469
3517
|
deliveryPrice: t = 0,
|
|
3470
3518
|
freeDeliveryPrice: r = 0,
|
|
3471
3519
|
isVatIncludedInPrice: s = !1
|
|
3472
3520
|
}) {
|
|
3473
|
-
const
|
|
3474
|
-
amount:
|
|
3521
|
+
const i = n.map((u) => ({
|
|
3522
|
+
amount: u.amount,
|
|
3475
3523
|
product: {
|
|
3476
|
-
id:
|
|
3477
|
-
price:
|
|
3524
|
+
id: u.product.id,
|
|
3525
|
+
price: u.product.price
|
|
3478
3526
|
}
|
|
3479
|
-
})), o =
|
|
3480
|
-
const b = o.items[
|
|
3527
|
+
})), o = An.calculateDiscounts(i, e), c = n.map((u, f) => {
|
|
3528
|
+
const b = o.items[f];
|
|
3481
3529
|
return {
|
|
3482
|
-
amount:
|
|
3483
|
-
product: { ...
|
|
3484
|
-
originalPrice:
|
|
3485
|
-
finalPrice: b ? b.finalPrice :
|
|
3486
|
-
finalDiscount: b ? b.finalDiscount :
|
|
3530
|
+
amount: u.amount,
|
|
3531
|
+
product: { ...u.product },
|
|
3532
|
+
originalPrice: u.product.price,
|
|
3533
|
+
finalPrice: b ? b.finalPrice : Dn(u.product),
|
|
3534
|
+
finalDiscount: b ? b.finalDiscount : jn(u.product)
|
|
3487
3535
|
};
|
|
3488
3536
|
}), l = c.reduce(
|
|
3489
|
-
(
|
|
3490
|
-
const { product: b, amount: w, finalPrice:
|
|
3537
|
+
(u, f) => {
|
|
3538
|
+
const { product: b, amount: w, finalPrice: I, finalDiscount: K } = f;
|
|
3491
3539
|
let j = 0;
|
|
3492
3540
|
if (b.vat) {
|
|
3493
3541
|
let Ce = 0;
|
|
3494
3542
|
if (s) {
|
|
3495
|
-
const
|
|
3496
|
-
j = Number(
|
|
3543
|
+
const it = I * (je.VAT / (100 + je.VAT));
|
|
3544
|
+
j = Number(it.toFixed(2)), j = j * w, Ce = Number(j.toFixed(2));
|
|
3497
3545
|
} else
|
|
3498
|
-
j =
|
|
3499
|
-
|
|
3546
|
+
j = I * je.VAT / 100, j = j * w, Ce = Number(j.toFixed(2));
|
|
3547
|
+
u.vat = Number((u.vat + Ce).toFixed(2));
|
|
3500
3548
|
}
|
|
3501
|
-
const
|
|
3502
|
-
return
|
|
3549
|
+
const Ae = Number(I.toFixed(2));
|
|
3550
|
+
return u.cost += w * Ae, u.discount += K && w * K, u.finalCost += w * Ae + (s ? 0 : j), u.productsCost += w * Ae + (s ? 0 : j), 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;
|
|
3503
3551
|
},
|
|
3504
3552
|
{
|
|
3505
3553
|
discount: 0,
|
|
@@ -3512,10 +3560,10 @@ function Jn({
|
|
|
3512
3560
|
);
|
|
3513
3561
|
return l.deliveryPrice && l.productsCost >= r ? l.deliveryPrice = 0 : l.finalCost += l.deliveryPrice, console.log("cartDetails", l), { items: c, ...l };
|
|
3514
3562
|
}
|
|
3515
|
-
const
|
|
3563
|
+
const On = {
|
|
3516
3564
|
stores: "STORES",
|
|
3517
3565
|
companies: "COMPANIES"
|
|
3518
|
-
},
|
|
3566
|
+
}, Pn = {
|
|
3519
3567
|
products: "products",
|
|
3520
3568
|
"favorite-products": "favorite-products",
|
|
3521
3569
|
profiles: "profiles",
|
|
@@ -3527,10 +3575,13 @@ const Zn = {
|
|
|
3527
3575
|
settings: "settings",
|
|
3528
3576
|
discounts: "discounts",
|
|
3529
3577
|
organizations: "organizations",
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3578
|
+
organizationGroups: "organization-groups",
|
|
3579
|
+
invoices: "invoices",
|
|
3580
|
+
suppliers: "suppliers",
|
|
3581
|
+
supplierInvoices: "supplier-invoices"
|
|
3582
|
+
}, En = {
|
|
3583
|
+
systemCollections: On,
|
|
3584
|
+
storeCollections: Pn,
|
|
3534
3585
|
// for client and server
|
|
3535
3586
|
getPath: ({
|
|
3536
3587
|
companyId: n,
|
|
@@ -3540,48 +3591,54 @@ const Zn = {
|
|
|
3540
3591
|
}) => `${n}/${e}/${t}${r ? `/${r}` : ""}`,
|
|
3541
3592
|
// for firestore events
|
|
3542
3593
|
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`
|
|
3543
|
-
},
|
|
3544
|
-
firestore:
|
|
3594
|
+
}, rr = {
|
|
3595
|
+
firestore: En
|
|
3545
3596
|
};
|
|
3546
3597
|
export {
|
|
3547
|
-
|
|
3548
|
-
|
|
3598
|
+
Ie as AddressSchema,
|
|
3599
|
+
He as BaseCategorySchema,
|
|
3549
3600
|
nt as BillingAccountSchema,
|
|
3550
|
-
|
|
3601
|
+
Nn as BundleDiscountStrategy,
|
|
3551
3602
|
tt as CalculatedDataSchema,
|
|
3552
3603
|
et as CartItemProductSchema,
|
|
3553
|
-
|
|
3604
|
+
Ln as CartSchema,
|
|
3554
3605
|
Me as CategorySchema,
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3606
|
+
qn as CompanySchema,
|
|
3607
|
+
bn as DeliveryNoteSchema,
|
|
3608
|
+
Sn as DiscountConditionsSchema,
|
|
3609
|
+
An as DiscountEngine,
|
|
3610
|
+
Xn as DiscountSchema,
|
|
3560
3611
|
rt as DiscountStrategyFactory,
|
|
3561
3612
|
In as DiscountVariantSchema,
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3613
|
+
_n as EzDeliveryNoteSchema,
|
|
3614
|
+
Bn as FavoriteProductSchema,
|
|
3615
|
+
$n as FileSchema,
|
|
3616
|
+
rr as FirebaseAPI,
|
|
3566
3617
|
re as LocaleSchema,
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3618
|
+
zn as LocaleValueSchema,
|
|
3619
|
+
Kn as NewOrganizationGroupSchema,
|
|
3620
|
+
Wn as NewOrganizationSchema,
|
|
3621
|
+
Un as NewProductSchema,
|
|
3622
|
+
tr as NewSupplierInvoiceSchema,
|
|
3623
|
+
er as NewSupplierSchema,
|
|
3624
|
+
Qn as OrderSchema,
|
|
3625
|
+
Cn as OrganizationGroupSchema,
|
|
3626
|
+
xn as OrganizationSchema,
|
|
3627
|
+
Ne as PaymentTypeSchema,
|
|
3573
3628
|
Ke as ProductSchema,
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3629
|
+
vn as ProfileSchema,
|
|
3630
|
+
Yn as StoreSchema,
|
|
3631
|
+
Zn as SupplierInvoiceSchema,
|
|
3632
|
+
at as SupplierSchema,
|
|
3633
|
+
Fn as TFlattenCategorySchema,
|
|
3634
|
+
Hn as calculatePercentageDiscount,
|
|
3635
|
+
Tn as clientTypesSchema,
|
|
3636
|
+
Gn as ensureNonNegative,
|
|
3580
3637
|
st as formatCurrency,
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3638
|
+
Jn as formatCurrencyString,
|
|
3639
|
+
nr as getCartCost,
|
|
3640
|
+
Vn as isFile,
|
|
3584
3641
|
M as notEmptyTextSchema,
|
|
3585
|
-
|
|
3642
|
+
Mn as numericTextSchema
|
|
3586
3643
|
};
|
|
3587
3644
|
//# sourceMappingURL=core.es.js.map
|