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