@jsdev_ninja/core 0.12.7 → 0.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs.js +1 -1
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.es.js +1001 -853
- 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/entities/Discount/__tests__/engine.test.d.ts +2 -0
- package/dist/entities/Discount/__tests__/engine.test.d.ts.map +1 -0
- package/dist/entities/Discount/__tests__/engine.test.js +298 -0
- package/dist/entities/Discount/__tests__/factory.test.d.ts +2 -0
- package/dist/entities/Discount/__tests__/factory.test.d.ts.map +1 -0
- package/dist/entities/Discount/__tests__/factory.test.js +75 -0
- package/dist/entities/Discount/__tests__/integration.test.d.ts +2 -0
- package/dist/entities/Discount/__tests__/integration.test.d.ts.map +1 -0
- package/dist/entities/Discount/__tests__/integration.test.js +115 -0
- package/dist/entities/Discount/__tests__/simple.test.d.ts +2 -0
- package/dist/entities/Discount/__tests__/simple.test.d.ts.map +1 -0
- package/dist/entities/Discount/__tests__/simple.test.js +186 -0
- package/dist/entities/Discount/__tests__/utils.test.d.ts +2 -0
- package/dist/entities/Discount/__tests__/utils.test.d.ts.map +1 -0
- package/dist/entities/Discount/__tests__/utils.test.js +55 -0
- package/dist/entities/Discount/engine.d.ts +29 -0
- package/dist/entities/Discount/engine.d.ts.map +1 -0
- package/dist/entities/Discount/engine.js +80 -0
- package/dist/entities/Discount/factory.d.ts +10 -0
- package/dist/entities/Discount/factory.d.ts.map +1 -0
- package/dist/entities/Discount/factory.js +18 -0
- package/dist/entities/Discount/index.d.ts +9 -0
- package/dist/entities/Discount/index.d.ts.map +1 -0
- package/dist/entities/Discount/index.js +8 -0
- package/dist/entities/Discount/strategies/BundleStrategy.d.ts +12 -0
- package/dist/entities/Discount/strategies/BundleStrategy.d.ts.map +1 -0
- package/dist/entities/Discount/strategies/BundleStrategy.js +80 -0
- package/dist/entities/Discount/strategies/__tests__/BundleStrategy.test.d.ts +2 -0
- package/dist/entities/Discount/strategies/__tests__/BundleStrategy.test.d.ts.map +1 -0
- package/dist/entities/Discount/strategies/__tests__/BundleStrategy.test.js +265 -0
- package/dist/entities/Discount/strategy.d.ts +6 -0
- package/dist/entities/Discount/strategy.d.ts.map +1 -0
- package/dist/entities/Discount/strategy.js +1 -0
- package/dist/entities/Discount/types.d.ts +148 -0
- package/dist/entities/Discount/types.d.ts.map +1 -0
- package/dist/entities/Discount/types.js +27 -0
- package/dist/entities/Discount/utils.d.ts +29 -0
- package/dist/entities/Discount/utils.d.ts.map +1 -0
- package/dist/entities/Discount/utils.js +39 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +16 -60
- package/lib/entities/Discount/strategies/__tests__/BundleStrategy.test.ts +12 -7
- package/lib/utils/index.ts +19 -80
- package/package.json +1 -1
- package/dist/entities/Discount.d.ts +0 -71
- package/dist/entities/Discount.d.ts.map +0 -1
- package/dist/entities/Discount.js +0 -20
- package/lib/entities/Discount.ts +0 -23
package/dist/core.es.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var tt = Object.defineProperty;
|
|
2
|
+
var rt = (r, e, t) => e in r ? tt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var Re = (r, e, t) => rt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
var x;
|
|
2
5
|
(function(r) {
|
|
3
6
|
r.assertEqual = (s) => s;
|
|
4
7
|
function e(s) {
|
|
@@ -9,40 +12,40 @@ var b;
|
|
|
9
12
|
}
|
|
10
13
|
r.assertNever = t, r.arrayToEnum = (s) => {
|
|
11
14
|
const a = {};
|
|
12
|
-
for (const
|
|
13
|
-
a[
|
|
15
|
+
for (const o of s)
|
|
16
|
+
a[o] = o;
|
|
14
17
|
return a;
|
|
15
18
|
}, r.getValidEnumValues = (s) => {
|
|
16
|
-
const a = r.objectKeys(s).filter((
|
|
17
|
-
for (const
|
|
18
|
-
c
|
|
19
|
-
return r.objectValues(
|
|
19
|
+
const a = r.objectKeys(s).filter((c) => typeof s[s[c]] != "number"), o = {};
|
|
20
|
+
for (const c of a)
|
|
21
|
+
o[c] = s[c];
|
|
22
|
+
return r.objectValues(o);
|
|
20
23
|
}, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
|
|
21
24
|
return s[a];
|
|
22
25
|
}), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
|
|
23
26
|
const a = [];
|
|
24
|
-
for (const
|
|
25
|
-
Object.prototype.hasOwnProperty.call(s,
|
|
27
|
+
for (const o in s)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(s, o) && a.push(o);
|
|
26
29
|
return a;
|
|
27
30
|
}, r.find = (s, a) => {
|
|
28
|
-
for (const
|
|
29
|
-
if (a(
|
|
30
|
-
return
|
|
31
|
+
for (const o of s)
|
|
32
|
+
if (a(o))
|
|
33
|
+
return o;
|
|
31
34
|
}, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
|
|
32
35
|
function n(s, a = " | ") {
|
|
33
|
-
return s.map((
|
|
36
|
+
return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
|
|
34
37
|
}
|
|
35
38
|
r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
36
|
-
})(
|
|
37
|
-
var
|
|
39
|
+
})(x || (x = {}));
|
|
40
|
+
var Ce;
|
|
38
41
|
(function(r) {
|
|
39
42
|
r.mergeShapes = (e, t) => ({
|
|
40
43
|
...e,
|
|
41
44
|
...t
|
|
42
45
|
// second overwrites first
|
|
43
46
|
});
|
|
44
|
-
})(
|
|
45
|
-
const h =
|
|
47
|
+
})(Ce || (Ce = {}));
|
|
48
|
+
const h = x.arrayToEnum([
|
|
46
49
|
"string",
|
|
47
50
|
"nan",
|
|
48
51
|
"number",
|
|
@@ -63,7 +66,7 @@ const h = b.arrayToEnum([
|
|
|
63
66
|
"never",
|
|
64
67
|
"map",
|
|
65
68
|
"set"
|
|
66
|
-
]),
|
|
69
|
+
]), D = (r) => {
|
|
67
70
|
switch (typeof r) {
|
|
68
71
|
case "undefined":
|
|
69
72
|
return h.undefined;
|
|
@@ -84,7 +87,7 @@ const h = b.arrayToEnum([
|
|
|
84
87
|
default:
|
|
85
88
|
return h.unknown;
|
|
86
89
|
}
|
|
87
|
-
},
|
|
90
|
+
}, u = x.arrayToEnum([
|
|
88
91
|
"invalid_type",
|
|
89
92
|
"invalid_literal",
|
|
90
93
|
"custom",
|
|
@@ -101,8 +104,8 @@ const h = b.arrayToEnum([
|
|
|
101
104
|
"invalid_intersection_types",
|
|
102
105
|
"not_multiple_of",
|
|
103
106
|
"not_finite"
|
|
104
|
-
]),
|
|
105
|
-
class
|
|
107
|
+
]), nt = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
108
|
+
class A extends Error {
|
|
106
109
|
get errors() {
|
|
107
110
|
return this.issues;
|
|
108
111
|
}
|
|
@@ -119,34 +122,34 @@ class C extends Error {
|
|
|
119
122
|
const t = e || function(a) {
|
|
120
123
|
return a.message;
|
|
121
124
|
}, n = { _errors: [] }, s = (a) => {
|
|
122
|
-
for (const
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
else if (
|
|
126
|
-
s(
|
|
127
|
-
else if (
|
|
128
|
-
s(
|
|
129
|
-
else if (
|
|
130
|
-
n._errors.push(t(
|
|
125
|
+
for (const o of a.issues)
|
|
126
|
+
if (o.code === "invalid_union")
|
|
127
|
+
o.unionErrors.map(s);
|
|
128
|
+
else if (o.code === "invalid_return_type")
|
|
129
|
+
s(o.returnTypeError);
|
|
130
|
+
else if (o.code === "invalid_arguments")
|
|
131
|
+
s(o.argumentsError);
|
|
132
|
+
else if (o.path.length === 0)
|
|
133
|
+
n._errors.push(t(o));
|
|
131
134
|
else {
|
|
132
|
-
let
|
|
133
|
-
for (;
|
|
134
|
-
const
|
|
135
|
-
|
|
135
|
+
let c = n, 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++;
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
};
|
|
139
142
|
return s(this), n;
|
|
140
143
|
}
|
|
141
144
|
static assert(e) {
|
|
142
|
-
if (!(e instanceof
|
|
145
|
+
if (!(e instanceof A))
|
|
143
146
|
throw new Error(`Not a ZodError: ${e}`);
|
|
144
147
|
}
|
|
145
148
|
toString() {
|
|
146
149
|
return this.message;
|
|
147
150
|
}
|
|
148
151
|
get message() {
|
|
149
|
-
return JSON.stringify(this.issues,
|
|
152
|
+
return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
|
|
150
153
|
}
|
|
151
154
|
get isEmpty() {
|
|
152
155
|
return this.issues.length === 0;
|
|
@@ -161,72 +164,72 @@ class C extends Error {
|
|
|
161
164
|
return this.flatten();
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
|
-
|
|
165
|
-
const
|
|
167
|
+
A.create = (r) => new A(r);
|
|
168
|
+
const H = (r, e) => {
|
|
166
169
|
let t;
|
|
167
170
|
switch (r.code) {
|
|
168
|
-
case
|
|
171
|
+
case u.invalid_type:
|
|
169
172
|
r.received === h.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
|
|
170
173
|
break;
|
|
171
|
-
case
|
|
172
|
-
t = `Invalid literal value, expected ${JSON.stringify(r.expected,
|
|
174
|
+
case u.invalid_literal:
|
|
175
|
+
t = `Invalid literal value, expected ${JSON.stringify(r.expected, x.jsonStringifyReplacer)}`;
|
|
173
176
|
break;
|
|
174
|
-
case
|
|
175
|
-
t = `Unrecognized key(s) in object: ${
|
|
177
|
+
case u.unrecognized_keys:
|
|
178
|
+
t = `Unrecognized key(s) in object: ${x.joinValues(r.keys, ", ")}`;
|
|
176
179
|
break;
|
|
177
|
-
case
|
|
180
|
+
case u.invalid_union:
|
|
178
181
|
t = "Invalid input";
|
|
179
182
|
break;
|
|
180
|
-
case
|
|
181
|
-
t = `Invalid discriminator value. Expected ${
|
|
183
|
+
case u.invalid_union_discriminator:
|
|
184
|
+
t = `Invalid discriminator value. Expected ${x.joinValues(r.options)}`;
|
|
182
185
|
break;
|
|
183
|
-
case
|
|
184
|
-
t = `Invalid enum value. Expected ${
|
|
186
|
+
case u.invalid_enum_value:
|
|
187
|
+
t = `Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;
|
|
185
188
|
break;
|
|
186
|
-
case
|
|
189
|
+
case u.invalid_arguments:
|
|
187
190
|
t = "Invalid function arguments";
|
|
188
191
|
break;
|
|
189
|
-
case
|
|
192
|
+
case u.invalid_return_type:
|
|
190
193
|
t = "Invalid function return type";
|
|
191
194
|
break;
|
|
192
|
-
case
|
|
195
|
+
case u.invalid_date:
|
|
193
196
|
t = "Invalid date";
|
|
194
197
|
break;
|
|
195
|
-
case
|
|
196
|
-
typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` :
|
|
198
|
+
case u.invalid_string:
|
|
199
|
+
typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : x.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
|
|
197
200
|
break;
|
|
198
|
-
case
|
|
201
|
+
case u.too_small:
|
|
199
202
|
r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
|
|
200
203
|
break;
|
|
201
|
-
case
|
|
204
|
+
case u.too_big:
|
|
202
205
|
r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
|
|
203
206
|
break;
|
|
204
|
-
case
|
|
207
|
+
case u.custom:
|
|
205
208
|
t = "Invalid input";
|
|
206
209
|
break;
|
|
207
|
-
case
|
|
210
|
+
case u.invalid_intersection_types:
|
|
208
211
|
t = "Intersection results could not be merged";
|
|
209
212
|
break;
|
|
210
|
-
case
|
|
213
|
+
case u.not_multiple_of:
|
|
211
214
|
t = `Number must be a multiple of ${r.multipleOf}`;
|
|
212
215
|
break;
|
|
213
|
-
case
|
|
216
|
+
case u.not_finite:
|
|
214
217
|
t = "Number must be finite";
|
|
215
218
|
break;
|
|
216
219
|
default:
|
|
217
|
-
t = e.defaultError,
|
|
220
|
+
t = e.defaultError, x.assertNever(r);
|
|
218
221
|
}
|
|
219
222
|
return { message: t };
|
|
220
223
|
};
|
|
221
|
-
let
|
|
222
|
-
function
|
|
223
|
-
|
|
224
|
+
let $e = H;
|
|
225
|
+
function st(r) {
|
|
226
|
+
$e = r;
|
|
224
227
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
228
|
+
function ge() {
|
|
229
|
+
return $e;
|
|
227
230
|
}
|
|
228
|
-
const
|
|
229
|
-
const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []],
|
|
231
|
+
const ve = (r) => {
|
|
232
|
+
const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], o = {
|
|
230
233
|
...s,
|
|
231
234
|
path: a
|
|
232
235
|
};
|
|
@@ -236,18 +239,18 @@ const _e = (r) => {
|
|
|
236
239
|
path: a,
|
|
237
240
|
message: s.message
|
|
238
241
|
};
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
for (const
|
|
242
|
-
|
|
242
|
+
let c = "";
|
|
243
|
+
const d = n.filter((l) => !!l).slice().reverse();
|
|
244
|
+
for (const l of d)
|
|
245
|
+
c = l(o, { data: e, defaultError: c }).message;
|
|
243
246
|
return {
|
|
244
247
|
...s,
|
|
245
248
|
path: a,
|
|
246
|
-
message:
|
|
249
|
+
message: c
|
|
247
250
|
};
|
|
248
|
-
},
|
|
251
|
+
}, at = [];
|
|
249
252
|
function f(r, e) {
|
|
250
|
-
const t =
|
|
253
|
+
const t = ge(), n = ve({
|
|
251
254
|
issueData: e,
|
|
252
255
|
data: r.data,
|
|
253
256
|
path: r.path,
|
|
@@ -258,7 +261,7 @@ function f(r, e) {
|
|
|
258
261
|
// then schema-bound map if available
|
|
259
262
|
t,
|
|
260
263
|
// then global override map
|
|
261
|
-
t ===
|
|
264
|
+
t === H ? void 0 : H
|
|
262
265
|
// then global default map
|
|
263
266
|
].filter((s) => !!s)
|
|
264
267
|
});
|
|
@@ -286,10 +289,10 @@ class T {
|
|
|
286
289
|
static async mergeObjectAsync(e, t) {
|
|
287
290
|
const n = [];
|
|
288
291
|
for (const s of t) {
|
|
289
|
-
const a = await s.key,
|
|
292
|
+
const a = await s.key, o = await s.value;
|
|
290
293
|
n.push({
|
|
291
294
|
key: a,
|
|
292
|
-
value:
|
|
295
|
+
value: o
|
|
293
296
|
});
|
|
294
297
|
}
|
|
295
298
|
return T.mergeObjectSync(e, n);
|
|
@@ -297,30 +300,30 @@ class T {
|
|
|
297
300
|
static mergeObjectSync(e, t) {
|
|
298
301
|
const n = {};
|
|
299
302
|
for (const s of t) {
|
|
300
|
-
const { key: a, value:
|
|
301
|
-
if (a.status === "aborted" ||
|
|
303
|
+
const { key: a, value: o } = s;
|
|
304
|
+
if (a.status === "aborted" || o.status === "aborted")
|
|
302
305
|
return g;
|
|
303
|
-
a.status === "dirty" && e.dirty(),
|
|
306
|
+
a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (n[a.value] = o.value);
|
|
304
307
|
}
|
|
305
308
|
return { status: e.value, value: n };
|
|
306
309
|
}
|
|
307
310
|
}
|
|
308
311
|
const g = Object.freeze({
|
|
309
312
|
status: "aborted"
|
|
310
|
-
}),
|
|
311
|
-
function
|
|
313
|
+
}), J = (r) => ({ status: "dirty", value: r }), I = (r) => ({ status: "valid", value: r }), Ne = (r) => r.status === "aborted", Ze = (r) => r.status === "dirty", B = (r) => r.status === "valid", ne = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
314
|
+
function _e(r, e, t, n) {
|
|
312
315
|
if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
313
316
|
return e.get(r);
|
|
314
317
|
}
|
|
315
|
-
function
|
|
318
|
+
function Ve(r, e, t, n, s) {
|
|
316
319
|
if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
317
320
|
return e.set(r, t), t;
|
|
318
321
|
}
|
|
319
|
-
var
|
|
322
|
+
var p;
|
|
320
323
|
(function(r) {
|
|
321
324
|
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
322
|
-
})(
|
|
323
|
-
var
|
|
325
|
+
})(p || (p = {}));
|
|
326
|
+
var ee, te;
|
|
324
327
|
class E {
|
|
325
328
|
constructor(e, t, n, s) {
|
|
326
329
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
|
|
@@ -329,7 +332,7 @@ class E {
|
|
|
329
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;
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
|
-
const
|
|
335
|
+
const Pe = (r, e) => {
|
|
333
336
|
if (B(e))
|
|
334
337
|
return { success: !0, data: e.value };
|
|
335
338
|
if (!r.common.issues.length)
|
|
@@ -339,7 +342,7 @@ const Me = (r, e) => {
|
|
|
339
342
|
get error() {
|
|
340
343
|
if (this._error)
|
|
341
344
|
return this._error;
|
|
342
|
-
const t = new
|
|
345
|
+
const t = new A(r.common.issues);
|
|
343
346
|
return this._error = t, this._error;
|
|
344
347
|
}
|
|
345
348
|
};
|
|
@@ -350,10 +353,10 @@ function v(r) {
|
|
|
350
353
|
const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
|
|
351
354
|
if (e && (t || n))
|
|
352
355
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
353
|
-
return e ? { errorMap: e, description: s } : { errorMap: (
|
|
354
|
-
var
|
|
355
|
-
const { message:
|
|
356
|
-
return
|
|
356
|
+
return e ? { errorMap: e, description: s } : { errorMap: (o, c) => {
|
|
357
|
+
var d, l;
|
|
358
|
+
const { message: m } = r;
|
|
359
|
+
return o.code === "invalid_enum_value" ? { message: m ?? c.defaultError } : typeof c.data > "u" ? { message: (d = m ?? n) !== null && d !== void 0 ? d : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (l = m ?? t) !== null && l !== void 0 ? l : c.defaultError };
|
|
357
360
|
}, description: s };
|
|
358
361
|
}
|
|
359
362
|
class _ {
|
|
@@ -361,13 +364,13 @@ class _ {
|
|
|
361
364
|
return this._def.description;
|
|
362
365
|
}
|
|
363
366
|
_getType(e) {
|
|
364
|
-
return
|
|
367
|
+
return D(e.data);
|
|
365
368
|
}
|
|
366
369
|
_getOrReturnCtx(e, t) {
|
|
367
370
|
return t || {
|
|
368
371
|
common: e.parent.common,
|
|
369
372
|
data: e.data,
|
|
370
|
-
parsedType:
|
|
373
|
+
parsedType: D(e.data),
|
|
371
374
|
schemaErrorMap: this._def.errorMap,
|
|
372
375
|
path: e.path,
|
|
373
376
|
parent: e.parent
|
|
@@ -379,7 +382,7 @@ class _ {
|
|
|
379
382
|
ctx: {
|
|
380
383
|
common: e.parent.common,
|
|
381
384
|
data: e.data,
|
|
382
|
-
parsedType:
|
|
385
|
+
parsedType: D(e.data),
|
|
383
386
|
schemaErrorMap: this._def.errorMap,
|
|
384
387
|
path: e.path,
|
|
385
388
|
parent: e.parent
|
|
@@ -388,7 +391,7 @@ class _ {
|
|
|
388
391
|
}
|
|
389
392
|
_parseSync(e) {
|
|
390
393
|
const t = this._parse(e);
|
|
391
|
-
if (
|
|
394
|
+
if (ne(t))
|
|
392
395
|
throw new Error("Synchronous parse encountered promise.");
|
|
393
396
|
return t;
|
|
394
397
|
}
|
|
@@ -414,9 +417,9 @@ class _ {
|
|
|
414
417
|
schemaErrorMap: this._def.errorMap,
|
|
415
418
|
parent: null,
|
|
416
419
|
data: e,
|
|
417
|
-
parsedType:
|
|
420
|
+
parsedType: D(e)
|
|
418
421
|
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
419
|
-
return
|
|
422
|
+
return Pe(s, a);
|
|
420
423
|
}
|
|
421
424
|
"~validate"(e) {
|
|
422
425
|
var t, n;
|
|
@@ -429,7 +432,7 @@ class _ {
|
|
|
429
432
|
schemaErrorMap: this._def.errorMap,
|
|
430
433
|
parent: null,
|
|
431
434
|
data: e,
|
|
432
|
-
parsedType:
|
|
435
|
+
parsedType: D(e)
|
|
433
436
|
};
|
|
434
437
|
if (!this["~standard"].async)
|
|
435
438
|
try {
|
|
@@ -468,25 +471,25 @@ class _ {
|
|
|
468
471
|
schemaErrorMap: this._def.errorMap,
|
|
469
472
|
parent: null,
|
|
470
473
|
data: e,
|
|
471
|
-
parsedType:
|
|
472
|
-
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (
|
|
473
|
-
return
|
|
474
|
+
parsedType: D(e)
|
|
475
|
+
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (ne(s) ? s : Promise.resolve(s));
|
|
476
|
+
return Pe(n, a);
|
|
474
477
|
}
|
|
475
478
|
refine(e, t) {
|
|
476
479
|
const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
477
480
|
return this._refinement((s, a) => {
|
|
478
|
-
const
|
|
479
|
-
code:
|
|
481
|
+
const o = e(s), c = () => a.addIssue({
|
|
482
|
+
code: u.custom,
|
|
480
483
|
...n(s)
|
|
481
484
|
});
|
|
482
|
-
return typeof Promise < "u" &&
|
|
485
|
+
return typeof Promise < "u" && o instanceof Promise ? o.then((d) => d ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
483
486
|
});
|
|
484
487
|
}
|
|
485
488
|
refinement(e, t) {
|
|
486
489
|
return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
|
|
487
490
|
}
|
|
488
491
|
_refinement(e) {
|
|
489
|
-
return new
|
|
492
|
+
return new O({
|
|
490
493
|
schema: this,
|
|
491
494
|
typeName: y.ZodEffects,
|
|
492
495
|
effect: { type: "refinement", refinement: e }
|
|
@@ -506,25 +509,25 @@ class _ {
|
|
|
506
509
|
return j.create(this, this._def);
|
|
507
510
|
}
|
|
508
511
|
nullable() {
|
|
509
|
-
return
|
|
512
|
+
return z.create(this, this._def);
|
|
510
513
|
}
|
|
511
514
|
nullish() {
|
|
512
515
|
return this.nullable().optional();
|
|
513
516
|
}
|
|
514
517
|
array() {
|
|
515
|
-
return
|
|
518
|
+
return Z.create(this);
|
|
516
519
|
}
|
|
517
520
|
promise() {
|
|
518
|
-
return
|
|
521
|
+
return X.create(this, this._def);
|
|
519
522
|
}
|
|
520
523
|
or(e) {
|
|
521
|
-
return
|
|
524
|
+
return oe.create([this, e], this._def);
|
|
522
525
|
}
|
|
523
526
|
and(e) {
|
|
524
|
-
return
|
|
527
|
+
return ce.create(this, e, this._def);
|
|
525
528
|
}
|
|
526
529
|
transform(e) {
|
|
527
|
-
return new
|
|
530
|
+
return new O({
|
|
528
531
|
...v(this._def),
|
|
529
532
|
schema: this,
|
|
530
533
|
typeName: y.ZodEffects,
|
|
@@ -533,7 +536,7 @@ class _ {
|
|
|
533
536
|
}
|
|
534
537
|
default(e) {
|
|
535
538
|
const t = typeof e == "function" ? e : () => e;
|
|
536
|
-
return new
|
|
539
|
+
return new he({
|
|
537
540
|
...v(this._def),
|
|
538
541
|
innerType: this,
|
|
539
542
|
defaultValue: t,
|
|
@@ -541,7 +544,7 @@ class _ {
|
|
|
541
544
|
});
|
|
542
545
|
}
|
|
543
546
|
brand() {
|
|
544
|
-
return new
|
|
547
|
+
return new je({
|
|
545
548
|
typeName: y.ZodBranded,
|
|
546
549
|
type: this,
|
|
547
550
|
...v(this._def)
|
|
@@ -564,10 +567,10 @@ class _ {
|
|
|
564
567
|
});
|
|
565
568
|
}
|
|
566
569
|
pipe(e) {
|
|
567
|
-
return
|
|
570
|
+
return ye.create(this, e);
|
|
568
571
|
}
|
|
569
572
|
readonly() {
|
|
570
|
-
return
|
|
573
|
+
return pe.create(this);
|
|
571
574
|
}
|
|
572
575
|
isOptional() {
|
|
573
576
|
return this.safeParse(void 0).success;
|
|
@@ -576,26 +579,26 @@ class _ {
|
|
|
576
579
|
return this.safeParse(null).success;
|
|
577
580
|
}
|
|
578
581
|
}
|
|
579
|
-
const
|
|
580
|
-
let
|
|
581
|
-
const
|
|
582
|
-
function
|
|
582
|
+
const it = /^c[^\s-]{8,}$/i, ot = /^[0-9a-z]+$/, ct = /^[0-9A-HJKMNP-TV-Z]{26}$/i, dt = /^[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, ut = /^[a-z0-9_-]{21}$/i, lt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ft = /^[-+]?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)?)??$/, ht = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, mt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
|
+
let Se;
|
|
584
|
+
const pt = /^(?:(?: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])$/, yt = /^(?:(?: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])$/, gt = /^(([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]))$/, vt = /^(([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])$/, _t = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, bt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Fe = "((\\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])))", xt = new RegExp(`^${Fe}$`);
|
|
585
|
+
function Le(r) {
|
|
583
586
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
584
587
|
return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
585
588
|
}
|
|
586
|
-
function
|
|
587
|
-
return new RegExp(`^${
|
|
589
|
+
function kt(r) {
|
|
590
|
+
return new RegExp(`^${Le(r)}$`);
|
|
588
591
|
}
|
|
589
|
-
function
|
|
590
|
-
let e = `${
|
|
592
|
+
function ze(r) {
|
|
593
|
+
let e = `${Fe}T${Le(r)}`;
|
|
591
594
|
const t = [];
|
|
592
595
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
593
596
|
}
|
|
594
|
-
function
|
|
595
|
-
return !!((e === "v4" || !e) &&
|
|
597
|
+
function wt(r, e) {
|
|
598
|
+
return !!((e === "v4" || !e) && pt.test(r) || (e === "v6" || !e) && gt.test(r));
|
|
596
599
|
}
|
|
597
|
-
function
|
|
598
|
-
if (!
|
|
600
|
+
function Tt(r, e) {
|
|
601
|
+
if (!lt.test(r))
|
|
599
602
|
return !1;
|
|
600
603
|
try {
|
|
601
604
|
const [t] = r.split("."), n = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(n));
|
|
@@ -604,15 +607,15 @@ function Ct(r, e) {
|
|
|
604
607
|
return !1;
|
|
605
608
|
}
|
|
606
609
|
}
|
|
607
|
-
function
|
|
608
|
-
return !!((e === "v4" || !e) &&
|
|
610
|
+
function It(r, e) {
|
|
611
|
+
return !!((e === "v4" || !e) && yt.test(r) || (e === "v6" || !e) && vt.test(r));
|
|
609
612
|
}
|
|
610
|
-
class
|
|
613
|
+
class N extends _ {
|
|
611
614
|
_parse(e) {
|
|
612
615
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
613
616
|
const a = this._getOrReturnCtx(e);
|
|
614
617
|
return f(a, {
|
|
615
|
-
code:
|
|
618
|
+
code: u.invalid_type,
|
|
616
619
|
expected: h.string,
|
|
617
620
|
received: a.parsedType
|
|
618
621
|
}), g;
|
|
@@ -622,7 +625,7 @@ class I extends _ {
|
|
|
622
625
|
for (const a of this._def.checks)
|
|
623
626
|
if (a.kind === "min")
|
|
624
627
|
e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
625
|
-
code:
|
|
628
|
+
code: u.too_small,
|
|
626
629
|
minimum: a.value,
|
|
627
630
|
type: "string",
|
|
628
631
|
inclusive: !0,
|
|
@@ -631,7 +634,7 @@ class I extends _ {
|
|
|
631
634
|
}), n.dirty());
|
|
632
635
|
else if (a.kind === "max")
|
|
633
636
|
e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
634
|
-
code:
|
|
637
|
+
code: u.too_big,
|
|
635
638
|
maximum: a.value,
|
|
636
639
|
type: "string",
|
|
637
640
|
inclusive: !0,
|
|
@@ -639,16 +642,16 @@ class I extends _ {
|
|
|
639
642
|
message: a.message
|
|
640
643
|
}), n.dirty());
|
|
641
644
|
else if (a.kind === "length") {
|
|
642
|
-
const
|
|
643
|
-
(
|
|
644
|
-
code:
|
|
645
|
+
const o = e.data.length > a.value, c = e.data.length < a.value;
|
|
646
|
+
(o || c) && (s = this._getOrReturnCtx(e, s), o ? f(s, {
|
|
647
|
+
code: u.too_big,
|
|
645
648
|
maximum: a.value,
|
|
646
649
|
type: "string",
|
|
647
650
|
inclusive: !0,
|
|
648
651
|
exact: !0,
|
|
649
652
|
message: a.message
|
|
650
|
-
}) :
|
|
651
|
-
code:
|
|
653
|
+
}) : c && f(s, {
|
|
654
|
+
code: u.too_small,
|
|
652
655
|
minimum: a.value,
|
|
653
656
|
type: "string",
|
|
654
657
|
inclusive: !0,
|
|
@@ -656,45 +659,45 @@ class I extends _ {
|
|
|
656
659
|
message: a.message
|
|
657
660
|
}), n.dirty());
|
|
658
661
|
} else if (a.kind === "email")
|
|
659
|
-
|
|
662
|
+
ht.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
660
663
|
validation: "email",
|
|
661
|
-
code:
|
|
664
|
+
code: u.invalid_string,
|
|
662
665
|
message: a.message
|
|
663
666
|
}), n.dirty());
|
|
664
667
|
else if (a.kind === "emoji")
|
|
665
|
-
|
|
668
|
+
Se || (Se = new RegExp(mt, "u")), Se.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
666
669
|
validation: "emoji",
|
|
667
|
-
code:
|
|
670
|
+
code: u.invalid_string,
|
|
668
671
|
message: a.message
|
|
669
672
|
}), n.dirty());
|
|
670
673
|
else if (a.kind === "uuid")
|
|
671
|
-
|
|
674
|
+
dt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
672
675
|
validation: "uuid",
|
|
673
|
-
code:
|
|
676
|
+
code: u.invalid_string,
|
|
674
677
|
message: a.message
|
|
675
678
|
}), n.dirty());
|
|
676
679
|
else if (a.kind === "nanoid")
|
|
677
|
-
|
|
680
|
+
ut.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
678
681
|
validation: "nanoid",
|
|
679
|
-
code:
|
|
682
|
+
code: u.invalid_string,
|
|
680
683
|
message: a.message
|
|
681
684
|
}), n.dirty());
|
|
682
685
|
else if (a.kind === "cuid")
|
|
683
|
-
|
|
686
|
+
it.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
684
687
|
validation: "cuid",
|
|
685
|
-
code:
|
|
688
|
+
code: u.invalid_string,
|
|
686
689
|
message: a.message
|
|
687
690
|
}), n.dirty());
|
|
688
691
|
else if (a.kind === "cuid2")
|
|
689
|
-
|
|
692
|
+
ot.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
690
693
|
validation: "cuid2",
|
|
691
|
-
code:
|
|
694
|
+
code: u.invalid_string,
|
|
692
695
|
message: a.message
|
|
693
696
|
}), n.dirty());
|
|
694
697
|
else if (a.kind === "ulid")
|
|
695
|
-
|
|
698
|
+
ct.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
696
699
|
validation: "ulid",
|
|
697
|
-
code:
|
|
700
|
+
code: u.invalid_string,
|
|
698
701
|
message: a.message
|
|
699
702
|
}), n.dirty());
|
|
700
703
|
else if (a.kind === "url")
|
|
@@ -703,119 +706,119 @@ class I extends _ {
|
|
|
703
706
|
} catch {
|
|
704
707
|
s = this._getOrReturnCtx(e, s), f(s, {
|
|
705
708
|
validation: "url",
|
|
706
|
-
code:
|
|
709
|
+
code: u.invalid_string,
|
|
707
710
|
message: a.message
|
|
708
711
|
}), n.dirty();
|
|
709
712
|
}
|
|
710
713
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
711
714
|
validation: "regex",
|
|
712
|
-
code:
|
|
715
|
+
code: u.invalid_string,
|
|
713
716
|
message: a.message
|
|
714
717
|
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
715
|
-
code:
|
|
718
|
+
code: u.invalid_string,
|
|
716
719
|
validation: { includes: a.value, position: a.position },
|
|
717
720
|
message: a.message
|
|
718
721
|
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
719
|
-
code:
|
|
722
|
+
code: u.invalid_string,
|
|
720
723
|
validation: { startsWith: a.value },
|
|
721
724
|
message: a.message
|
|
722
725
|
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
723
|
-
code:
|
|
726
|
+
code: u.invalid_string,
|
|
724
727
|
validation: { endsWith: a.value },
|
|
725
728
|
message: a.message
|
|
726
|
-
}), n.dirty()) : a.kind === "datetime" ?
|
|
727
|
-
code:
|
|
729
|
+
}), n.dirty()) : a.kind === "datetime" ? ze(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
730
|
+
code: u.invalid_string,
|
|
728
731
|
validation: "datetime",
|
|
729
732
|
message: a.message
|
|
730
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
731
|
-
code:
|
|
733
|
+
}), n.dirty()) : a.kind === "date" ? xt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
734
|
+
code: u.invalid_string,
|
|
732
735
|
validation: "date",
|
|
733
736
|
message: a.message
|
|
734
|
-
}), n.dirty()) : a.kind === "time" ?
|
|
735
|
-
code:
|
|
737
|
+
}), n.dirty()) : a.kind === "time" ? kt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
738
|
+
code: u.invalid_string,
|
|
736
739
|
validation: "time",
|
|
737
740
|
message: a.message
|
|
738
|
-
}), n.dirty()) : a.kind === "duration" ?
|
|
741
|
+
}), n.dirty()) : a.kind === "duration" ? ft.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
739
742
|
validation: "duration",
|
|
740
|
-
code:
|
|
743
|
+
code: u.invalid_string,
|
|
741
744
|
message: a.message
|
|
742
|
-
}), n.dirty()) : a.kind === "ip" ?
|
|
745
|
+
}), n.dirty()) : a.kind === "ip" ? wt(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
743
746
|
validation: "ip",
|
|
744
|
-
code:
|
|
747
|
+
code: u.invalid_string,
|
|
745
748
|
message: a.message
|
|
746
|
-
}), n.dirty()) : a.kind === "jwt" ?
|
|
749
|
+
}), n.dirty()) : a.kind === "jwt" ? Tt(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
747
750
|
validation: "jwt",
|
|
748
|
-
code:
|
|
751
|
+
code: u.invalid_string,
|
|
749
752
|
message: a.message
|
|
750
|
-
}), n.dirty()) : a.kind === "cidr" ?
|
|
753
|
+
}), n.dirty()) : a.kind === "cidr" ? It(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
751
754
|
validation: "cidr",
|
|
752
|
-
code:
|
|
755
|
+
code: u.invalid_string,
|
|
753
756
|
message: a.message
|
|
754
|
-
}), n.dirty()) : a.kind === "base64" ?
|
|
757
|
+
}), n.dirty()) : a.kind === "base64" ? _t.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
755
758
|
validation: "base64",
|
|
756
|
-
code:
|
|
759
|
+
code: u.invalid_string,
|
|
757
760
|
message: a.message
|
|
758
|
-
}), n.dirty()) : a.kind === "base64url" ?
|
|
761
|
+
}), n.dirty()) : a.kind === "base64url" ? bt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
759
762
|
validation: "base64url",
|
|
760
|
-
code:
|
|
763
|
+
code: u.invalid_string,
|
|
761
764
|
message: a.message
|
|
762
|
-
}), n.dirty()) :
|
|
765
|
+
}), n.dirty()) : x.assertNever(a);
|
|
763
766
|
return { status: n.value, value: e.data };
|
|
764
767
|
}
|
|
765
768
|
_regex(e, t, n) {
|
|
766
769
|
return this.refinement((s) => e.test(s), {
|
|
767
770
|
validation: t,
|
|
768
|
-
code:
|
|
769
|
-
...
|
|
771
|
+
code: u.invalid_string,
|
|
772
|
+
...p.errToObj(n)
|
|
770
773
|
});
|
|
771
774
|
}
|
|
772
775
|
_addCheck(e) {
|
|
773
|
-
return new
|
|
776
|
+
return new N({
|
|
774
777
|
...this._def,
|
|
775
778
|
checks: [...this._def.checks, e]
|
|
776
779
|
});
|
|
777
780
|
}
|
|
778
781
|
email(e) {
|
|
779
|
-
return this._addCheck({ kind: "email", ...
|
|
782
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
780
783
|
}
|
|
781
784
|
url(e) {
|
|
782
|
-
return this._addCheck({ kind: "url", ...
|
|
785
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
783
786
|
}
|
|
784
787
|
emoji(e) {
|
|
785
|
-
return this._addCheck({ kind: "emoji", ...
|
|
788
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
786
789
|
}
|
|
787
790
|
uuid(e) {
|
|
788
|
-
return this._addCheck({ kind: "uuid", ...
|
|
791
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
789
792
|
}
|
|
790
793
|
nanoid(e) {
|
|
791
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
794
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
792
795
|
}
|
|
793
796
|
cuid(e) {
|
|
794
|
-
return this._addCheck({ kind: "cuid", ...
|
|
797
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
795
798
|
}
|
|
796
799
|
cuid2(e) {
|
|
797
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
800
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
798
801
|
}
|
|
799
802
|
ulid(e) {
|
|
800
|
-
return this._addCheck({ kind: "ulid", ...
|
|
803
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
801
804
|
}
|
|
802
805
|
base64(e) {
|
|
803
|
-
return this._addCheck({ kind: "base64", ...
|
|
806
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
804
807
|
}
|
|
805
808
|
base64url(e) {
|
|
806
809
|
return this._addCheck({
|
|
807
810
|
kind: "base64url",
|
|
808
|
-
...
|
|
811
|
+
...p.errToObj(e)
|
|
809
812
|
});
|
|
810
813
|
}
|
|
811
814
|
jwt(e) {
|
|
812
|
-
return this._addCheck({ kind: "jwt", ...
|
|
815
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
813
816
|
}
|
|
814
817
|
ip(e) {
|
|
815
|
-
return this._addCheck({ kind: "ip", ...
|
|
818
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
816
819
|
}
|
|
817
820
|
cidr(e) {
|
|
818
|
-
return this._addCheck({ kind: "cidr", ...
|
|
821
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
819
822
|
}
|
|
820
823
|
datetime(e) {
|
|
821
824
|
var t, n;
|
|
@@ -830,7 +833,7 @@ class I extends _ {
|
|
|
830
833
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
831
834
|
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
832
835
|
local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
|
|
833
|
-
...
|
|
836
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
834
837
|
});
|
|
835
838
|
}
|
|
836
839
|
date(e) {
|
|
@@ -844,17 +847,17 @@ class I extends _ {
|
|
|
844
847
|
}) : this._addCheck({
|
|
845
848
|
kind: "time",
|
|
846
849
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
847
|
-
...
|
|
850
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
848
851
|
});
|
|
849
852
|
}
|
|
850
853
|
duration(e) {
|
|
851
|
-
return this._addCheck({ kind: "duration", ...
|
|
854
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
852
855
|
}
|
|
853
856
|
regex(e, t) {
|
|
854
857
|
return this._addCheck({
|
|
855
858
|
kind: "regex",
|
|
856
859
|
regex: e,
|
|
857
|
-
...
|
|
860
|
+
...p.errToObj(t)
|
|
858
861
|
});
|
|
859
862
|
}
|
|
860
863
|
includes(e, t) {
|
|
@@ -862,64 +865,64 @@ class I extends _ {
|
|
|
862
865
|
kind: "includes",
|
|
863
866
|
value: e,
|
|
864
867
|
position: t == null ? void 0 : t.position,
|
|
865
|
-
...
|
|
868
|
+
...p.errToObj(t == null ? void 0 : t.message)
|
|
866
869
|
});
|
|
867
870
|
}
|
|
868
871
|
startsWith(e, t) {
|
|
869
872
|
return this._addCheck({
|
|
870
873
|
kind: "startsWith",
|
|
871
874
|
value: e,
|
|
872
|
-
...
|
|
875
|
+
...p.errToObj(t)
|
|
873
876
|
});
|
|
874
877
|
}
|
|
875
878
|
endsWith(e, t) {
|
|
876
879
|
return this._addCheck({
|
|
877
880
|
kind: "endsWith",
|
|
878
881
|
value: e,
|
|
879
|
-
...
|
|
882
|
+
...p.errToObj(t)
|
|
880
883
|
});
|
|
881
884
|
}
|
|
882
885
|
min(e, t) {
|
|
883
886
|
return this._addCheck({
|
|
884
887
|
kind: "min",
|
|
885
888
|
value: e,
|
|
886
|
-
...
|
|
889
|
+
...p.errToObj(t)
|
|
887
890
|
});
|
|
888
891
|
}
|
|
889
892
|
max(e, t) {
|
|
890
893
|
return this._addCheck({
|
|
891
894
|
kind: "max",
|
|
892
895
|
value: e,
|
|
893
|
-
...
|
|
896
|
+
...p.errToObj(t)
|
|
894
897
|
});
|
|
895
898
|
}
|
|
896
899
|
length(e, t) {
|
|
897
900
|
return this._addCheck({
|
|
898
901
|
kind: "length",
|
|
899
902
|
value: e,
|
|
900
|
-
...
|
|
903
|
+
...p.errToObj(t)
|
|
901
904
|
});
|
|
902
905
|
}
|
|
903
906
|
/**
|
|
904
907
|
* Equivalent to `.min(1)`
|
|
905
908
|
*/
|
|
906
909
|
nonempty(e) {
|
|
907
|
-
return this.min(1,
|
|
910
|
+
return this.min(1, p.errToObj(e));
|
|
908
911
|
}
|
|
909
912
|
trim() {
|
|
910
|
-
return new
|
|
913
|
+
return new N({
|
|
911
914
|
...this._def,
|
|
912
915
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
913
916
|
});
|
|
914
917
|
}
|
|
915
918
|
toLowerCase() {
|
|
916
|
-
return new
|
|
919
|
+
return new N({
|
|
917
920
|
...this._def,
|
|
918
921
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
919
922
|
});
|
|
920
923
|
}
|
|
921
924
|
toUpperCase() {
|
|
922
|
-
return new
|
|
925
|
+
return new N({
|
|
923
926
|
...this._def,
|
|
924
927
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
925
928
|
});
|
|
@@ -985,18 +988,18 @@ class I extends _ {
|
|
|
985
988
|
return e;
|
|
986
989
|
}
|
|
987
990
|
}
|
|
988
|
-
|
|
991
|
+
N.create = (r) => {
|
|
989
992
|
var e;
|
|
990
|
-
return new
|
|
993
|
+
return new N({
|
|
991
994
|
checks: [],
|
|
992
995
|
typeName: y.ZodString,
|
|
993
996
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
994
997
|
...v(r)
|
|
995
998
|
});
|
|
996
999
|
};
|
|
997
|
-
function
|
|
998
|
-
const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")),
|
|
999
|
-
return a %
|
|
1000
|
+
function St(r, e) {
|
|
1001
|
+
const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
|
|
1002
|
+
return a % o / Math.pow(10, s);
|
|
1000
1003
|
}
|
|
1001
1004
|
class V extends _ {
|
|
1002
1005
|
constructor() {
|
|
@@ -1006,7 +1009,7 @@ class V extends _ {
|
|
|
1006
1009
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1007
1010
|
const a = this._getOrReturnCtx(e);
|
|
1008
1011
|
return f(a, {
|
|
1009
|
-
code:
|
|
1012
|
+
code: u.invalid_type,
|
|
1010
1013
|
expected: h.number,
|
|
1011
1014
|
received: a.parsedType
|
|
1012
1015
|
}), g;
|
|
@@ -1014,46 +1017,46 @@ class V extends _ {
|
|
|
1014
1017
|
let n;
|
|
1015
1018
|
const s = new T();
|
|
1016
1019
|
for (const a of this._def.checks)
|
|
1017
|
-
a.kind === "int" ?
|
|
1018
|
-
code:
|
|
1020
|
+
a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1021
|
+
code: u.invalid_type,
|
|
1019
1022
|
expected: "integer",
|
|
1020
1023
|
received: "float",
|
|
1021
1024
|
message: a.message
|
|
1022
1025
|
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1023
|
-
code:
|
|
1026
|
+
code: u.too_small,
|
|
1024
1027
|
minimum: a.value,
|
|
1025
1028
|
type: "number",
|
|
1026
1029
|
inclusive: a.inclusive,
|
|
1027
1030
|
exact: !1,
|
|
1028
1031
|
message: a.message
|
|
1029
1032
|
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1030
|
-
code:
|
|
1033
|
+
code: u.too_big,
|
|
1031
1034
|
maximum: a.value,
|
|
1032
1035
|
type: "number",
|
|
1033
1036
|
inclusive: a.inclusive,
|
|
1034
1037
|
exact: !1,
|
|
1035
1038
|
message: a.message
|
|
1036
|
-
}), s.dirty()) : a.kind === "multipleOf" ?
|
|
1037
|
-
code:
|
|
1039
|
+
}), s.dirty()) : a.kind === "multipleOf" ? St(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1040
|
+
code: u.not_multiple_of,
|
|
1038
1041
|
multipleOf: a.value,
|
|
1039
1042
|
message: a.message
|
|
1040
1043
|
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1041
|
-
code:
|
|
1044
|
+
code: u.not_finite,
|
|
1042
1045
|
message: a.message
|
|
1043
|
-
}), s.dirty()) :
|
|
1046
|
+
}), s.dirty()) : x.assertNever(a);
|
|
1044
1047
|
return { status: s.value, value: e.data };
|
|
1045
1048
|
}
|
|
1046
1049
|
gte(e, t) {
|
|
1047
|
-
return this.setLimit("min", e, !0,
|
|
1050
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1048
1051
|
}
|
|
1049
1052
|
gt(e, t) {
|
|
1050
|
-
return this.setLimit("min", e, !1,
|
|
1053
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1051
1054
|
}
|
|
1052
1055
|
lte(e, t) {
|
|
1053
|
-
return this.setLimit("max", e, !0,
|
|
1056
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1054
1057
|
}
|
|
1055
1058
|
lt(e, t) {
|
|
1056
|
-
return this.setLimit("max", e, !1,
|
|
1059
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1057
1060
|
}
|
|
1058
1061
|
setLimit(e, t, n, s) {
|
|
1059
1062
|
return new V({
|
|
@@ -1064,7 +1067,7 @@ class V extends _ {
|
|
|
1064
1067
|
kind: e,
|
|
1065
1068
|
value: t,
|
|
1066
1069
|
inclusive: n,
|
|
1067
|
-
message:
|
|
1070
|
+
message: p.toString(s)
|
|
1068
1071
|
}
|
|
1069
1072
|
]
|
|
1070
1073
|
});
|
|
@@ -1078,7 +1081,7 @@ class V extends _ {
|
|
|
1078
1081
|
int(e) {
|
|
1079
1082
|
return this._addCheck({
|
|
1080
1083
|
kind: "int",
|
|
1081
|
-
message:
|
|
1084
|
+
message: p.toString(e)
|
|
1082
1085
|
});
|
|
1083
1086
|
}
|
|
1084
1087
|
positive(e) {
|
|
@@ -1086,7 +1089,7 @@ class V extends _ {
|
|
|
1086
1089
|
kind: "min",
|
|
1087
1090
|
value: 0,
|
|
1088
1091
|
inclusive: !1,
|
|
1089
|
-
message:
|
|
1092
|
+
message: p.toString(e)
|
|
1090
1093
|
});
|
|
1091
1094
|
}
|
|
1092
1095
|
negative(e) {
|
|
@@ -1094,7 +1097,7 @@ class V extends _ {
|
|
|
1094
1097
|
kind: "max",
|
|
1095
1098
|
value: 0,
|
|
1096
1099
|
inclusive: !1,
|
|
1097
|
-
message:
|
|
1100
|
+
message: p.toString(e)
|
|
1098
1101
|
});
|
|
1099
1102
|
}
|
|
1100
1103
|
nonpositive(e) {
|
|
@@ -1102,7 +1105,7 @@ class V extends _ {
|
|
|
1102
1105
|
kind: "max",
|
|
1103
1106
|
value: 0,
|
|
1104
1107
|
inclusive: !0,
|
|
1105
|
-
message:
|
|
1108
|
+
message: p.toString(e)
|
|
1106
1109
|
});
|
|
1107
1110
|
}
|
|
1108
1111
|
nonnegative(e) {
|
|
@@ -1110,20 +1113,20 @@ class V extends _ {
|
|
|
1110
1113
|
kind: "min",
|
|
1111
1114
|
value: 0,
|
|
1112
1115
|
inclusive: !0,
|
|
1113
|
-
message:
|
|
1116
|
+
message: p.toString(e)
|
|
1114
1117
|
});
|
|
1115
1118
|
}
|
|
1116
1119
|
multipleOf(e, t) {
|
|
1117
1120
|
return this._addCheck({
|
|
1118
1121
|
kind: "multipleOf",
|
|
1119
1122
|
value: e,
|
|
1120
|
-
message:
|
|
1123
|
+
message: p.toString(t)
|
|
1121
1124
|
});
|
|
1122
1125
|
}
|
|
1123
1126
|
finite(e) {
|
|
1124
1127
|
return this._addCheck({
|
|
1125
1128
|
kind: "finite",
|
|
1126
|
-
message:
|
|
1129
|
+
message: p.toString(e)
|
|
1127
1130
|
});
|
|
1128
1131
|
}
|
|
1129
1132
|
safe(e) {
|
|
@@ -1131,12 +1134,12 @@ class V extends _ {
|
|
|
1131
1134
|
kind: "min",
|
|
1132
1135
|
inclusive: !0,
|
|
1133
1136
|
value: Number.MIN_SAFE_INTEGER,
|
|
1134
|
-
message:
|
|
1137
|
+
message: p.toString(e)
|
|
1135
1138
|
})._addCheck({
|
|
1136
1139
|
kind: "max",
|
|
1137
1140
|
inclusive: !0,
|
|
1138
1141
|
value: Number.MAX_SAFE_INTEGER,
|
|
1139
|
-
message:
|
|
1142
|
+
message: p.toString(e)
|
|
1140
1143
|
});
|
|
1141
1144
|
}
|
|
1142
1145
|
get minValue() {
|
|
@@ -1152,7 +1155,7 @@ class V extends _ {
|
|
|
1152
1155
|
return e;
|
|
1153
1156
|
}
|
|
1154
1157
|
get isInt() {
|
|
1155
|
-
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));
|
|
1156
1159
|
}
|
|
1157
1160
|
get isFinite() {
|
|
1158
1161
|
let e = null, t = null;
|
|
@@ -1170,7 +1173,7 @@ V.create = (r) => new V({
|
|
|
1170
1173
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1171
1174
|
...v(r)
|
|
1172
1175
|
});
|
|
1173
|
-
class
|
|
1176
|
+
class F extends _ {
|
|
1174
1177
|
constructor() {
|
|
1175
1178
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1176
1179
|
}
|
|
@@ -1187,46 +1190,46 @@ class L extends _ {
|
|
|
1187
1190
|
const s = new T();
|
|
1188
1191
|
for (const a of this._def.checks)
|
|
1189
1192
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1190
|
-
code:
|
|
1193
|
+
code: u.too_small,
|
|
1191
1194
|
type: "bigint",
|
|
1192
1195
|
minimum: a.value,
|
|
1193
1196
|
inclusive: a.inclusive,
|
|
1194
1197
|
message: a.message
|
|
1195
1198
|
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1196
|
-
code:
|
|
1199
|
+
code: u.too_big,
|
|
1197
1200
|
type: "bigint",
|
|
1198
1201
|
maximum: a.value,
|
|
1199
1202
|
inclusive: a.inclusive,
|
|
1200
1203
|
message: a.message
|
|
1201
1204
|
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1202
|
-
code:
|
|
1205
|
+
code: u.not_multiple_of,
|
|
1203
1206
|
multipleOf: a.value,
|
|
1204
1207
|
message: a.message
|
|
1205
|
-
}), s.dirty()) :
|
|
1208
|
+
}), s.dirty()) : x.assertNever(a);
|
|
1206
1209
|
return { status: s.value, value: e.data };
|
|
1207
1210
|
}
|
|
1208
1211
|
_getInvalidInput(e) {
|
|
1209
1212
|
const t = this._getOrReturnCtx(e);
|
|
1210
1213
|
return f(t, {
|
|
1211
|
-
code:
|
|
1214
|
+
code: u.invalid_type,
|
|
1212
1215
|
expected: h.bigint,
|
|
1213
1216
|
received: t.parsedType
|
|
1214
1217
|
}), g;
|
|
1215
1218
|
}
|
|
1216
1219
|
gte(e, t) {
|
|
1217
|
-
return this.setLimit("min", e, !0,
|
|
1220
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1218
1221
|
}
|
|
1219
1222
|
gt(e, t) {
|
|
1220
|
-
return this.setLimit("min", e, !1,
|
|
1223
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1221
1224
|
}
|
|
1222
1225
|
lte(e, t) {
|
|
1223
|
-
return this.setLimit("max", e, !0,
|
|
1226
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1224
1227
|
}
|
|
1225
1228
|
lt(e, t) {
|
|
1226
|
-
return this.setLimit("max", e, !1,
|
|
1229
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1227
1230
|
}
|
|
1228
1231
|
setLimit(e, t, n, s) {
|
|
1229
|
-
return new
|
|
1232
|
+
return new F({
|
|
1230
1233
|
...this._def,
|
|
1231
1234
|
checks: [
|
|
1232
1235
|
...this._def.checks,
|
|
@@ -1234,13 +1237,13 @@ class L extends _ {
|
|
|
1234
1237
|
kind: e,
|
|
1235
1238
|
value: t,
|
|
1236
1239
|
inclusive: n,
|
|
1237
|
-
message:
|
|
1240
|
+
message: p.toString(s)
|
|
1238
1241
|
}
|
|
1239
1242
|
]
|
|
1240
1243
|
});
|
|
1241
1244
|
}
|
|
1242
1245
|
_addCheck(e) {
|
|
1243
|
-
return new
|
|
1246
|
+
return new F({
|
|
1244
1247
|
...this._def,
|
|
1245
1248
|
checks: [...this._def.checks, e]
|
|
1246
1249
|
});
|
|
@@ -1250,7 +1253,7 @@ class L extends _ {
|
|
|
1250
1253
|
kind: "min",
|
|
1251
1254
|
value: BigInt(0),
|
|
1252
1255
|
inclusive: !1,
|
|
1253
|
-
message:
|
|
1256
|
+
message: p.toString(e)
|
|
1254
1257
|
});
|
|
1255
1258
|
}
|
|
1256
1259
|
negative(e) {
|
|
@@ -1258,7 +1261,7 @@ class L extends _ {
|
|
|
1258
1261
|
kind: "max",
|
|
1259
1262
|
value: BigInt(0),
|
|
1260
1263
|
inclusive: !1,
|
|
1261
|
-
message:
|
|
1264
|
+
message: p.toString(e)
|
|
1262
1265
|
});
|
|
1263
1266
|
}
|
|
1264
1267
|
nonpositive(e) {
|
|
@@ -1266,7 +1269,7 @@ class L extends _ {
|
|
|
1266
1269
|
kind: "max",
|
|
1267
1270
|
value: BigInt(0),
|
|
1268
1271
|
inclusive: !0,
|
|
1269
|
-
message:
|
|
1272
|
+
message: p.toString(e)
|
|
1270
1273
|
});
|
|
1271
1274
|
}
|
|
1272
1275
|
nonnegative(e) {
|
|
@@ -1274,14 +1277,14 @@ class L extends _ {
|
|
|
1274
1277
|
kind: "min",
|
|
1275
1278
|
value: BigInt(0),
|
|
1276
1279
|
inclusive: !0,
|
|
1277
|
-
message:
|
|
1280
|
+
message: p.toString(e)
|
|
1278
1281
|
});
|
|
1279
1282
|
}
|
|
1280
1283
|
multipleOf(e, t) {
|
|
1281
1284
|
return this._addCheck({
|
|
1282
1285
|
kind: "multipleOf",
|
|
1283
1286
|
value: e,
|
|
1284
|
-
message:
|
|
1287
|
+
message: p.toString(t)
|
|
1285
1288
|
});
|
|
1286
1289
|
}
|
|
1287
1290
|
get minValue() {
|
|
@@ -1297,39 +1300,39 @@ class L extends _ {
|
|
|
1297
1300
|
return e;
|
|
1298
1301
|
}
|
|
1299
1302
|
}
|
|
1300
|
-
|
|
1303
|
+
F.create = (r) => {
|
|
1301
1304
|
var e;
|
|
1302
|
-
return new
|
|
1305
|
+
return new F({
|
|
1303
1306
|
checks: [],
|
|
1304
1307
|
typeName: y.ZodBigInt,
|
|
1305
1308
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
1306
1309
|
...v(r)
|
|
1307
1310
|
});
|
|
1308
1311
|
};
|
|
1309
|
-
class
|
|
1312
|
+
class se extends _ {
|
|
1310
1313
|
_parse(e) {
|
|
1311
1314
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1312
1315
|
const n = this._getOrReturnCtx(e);
|
|
1313
1316
|
return f(n, {
|
|
1314
|
-
code:
|
|
1317
|
+
code: u.invalid_type,
|
|
1315
1318
|
expected: h.boolean,
|
|
1316
1319
|
received: n.parsedType
|
|
1317
1320
|
}), g;
|
|
1318
1321
|
}
|
|
1319
|
-
return
|
|
1322
|
+
return I(e.data);
|
|
1320
1323
|
}
|
|
1321
1324
|
}
|
|
1322
|
-
|
|
1325
|
+
se.create = (r) => new se({
|
|
1323
1326
|
typeName: y.ZodBoolean,
|
|
1324
1327
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1325
1328
|
...v(r)
|
|
1326
1329
|
});
|
|
1327
|
-
class
|
|
1330
|
+
class W extends _ {
|
|
1328
1331
|
_parse(e) {
|
|
1329
1332
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1330
1333
|
const a = this._getOrReturnCtx(e);
|
|
1331
1334
|
return f(a, {
|
|
1332
|
-
code:
|
|
1335
|
+
code: u.invalid_type,
|
|
1333
1336
|
expected: h.date,
|
|
1334
1337
|
received: a.parsedType
|
|
1335
1338
|
}), g;
|
|
@@ -1337,34 +1340,34 @@ class q extends _ {
|
|
|
1337
1340
|
if (isNaN(e.data.getTime())) {
|
|
1338
1341
|
const a = this._getOrReturnCtx(e);
|
|
1339
1342
|
return f(a, {
|
|
1340
|
-
code:
|
|
1343
|
+
code: u.invalid_date
|
|
1341
1344
|
}), g;
|
|
1342
1345
|
}
|
|
1343
1346
|
const n = new T();
|
|
1344
1347
|
let s;
|
|
1345
1348
|
for (const a of this._def.checks)
|
|
1346
1349
|
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1347
|
-
code:
|
|
1350
|
+
code: u.too_small,
|
|
1348
1351
|
message: a.message,
|
|
1349
1352
|
inclusive: !0,
|
|
1350
1353
|
exact: !1,
|
|
1351
1354
|
minimum: a.value,
|
|
1352
1355
|
type: "date"
|
|
1353
1356
|
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1354
|
-
code:
|
|
1357
|
+
code: u.too_big,
|
|
1355
1358
|
message: a.message,
|
|
1356
1359
|
inclusive: !0,
|
|
1357
1360
|
exact: !1,
|
|
1358
1361
|
maximum: a.value,
|
|
1359
1362
|
type: "date"
|
|
1360
|
-
}), n.dirty()) :
|
|
1363
|
+
}), n.dirty()) : x.assertNever(a);
|
|
1361
1364
|
return {
|
|
1362
1365
|
status: n.value,
|
|
1363
1366
|
value: new Date(e.data.getTime())
|
|
1364
1367
|
};
|
|
1365
1368
|
}
|
|
1366
1369
|
_addCheck(e) {
|
|
1367
|
-
return new
|
|
1370
|
+
return new W({
|
|
1368
1371
|
...this._def,
|
|
1369
1372
|
checks: [...this._def.checks, e]
|
|
1370
1373
|
});
|
|
@@ -1373,14 +1376,14 @@ class q extends _ {
|
|
|
1373
1376
|
return this._addCheck({
|
|
1374
1377
|
kind: "min",
|
|
1375
1378
|
value: e.getTime(),
|
|
1376
|
-
message:
|
|
1379
|
+
message: p.toString(t)
|
|
1377
1380
|
});
|
|
1378
1381
|
}
|
|
1379
1382
|
max(e, t) {
|
|
1380
1383
|
return this._addCheck({
|
|
1381
1384
|
kind: "max",
|
|
1382
1385
|
value: e.getTime(),
|
|
1383
|
-
message:
|
|
1386
|
+
message: p.toString(t)
|
|
1384
1387
|
});
|
|
1385
1388
|
}
|
|
1386
1389
|
get minDate() {
|
|
@@ -1396,72 +1399,72 @@ class q extends _ {
|
|
|
1396
1399
|
return e != null ? new Date(e) : null;
|
|
1397
1400
|
}
|
|
1398
1401
|
}
|
|
1399
|
-
|
|
1402
|
+
W.create = (r) => new W({
|
|
1400
1403
|
checks: [],
|
|
1401
1404
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1402
1405
|
typeName: y.ZodDate,
|
|
1403
1406
|
...v(r)
|
|
1404
1407
|
});
|
|
1405
|
-
class
|
|
1408
|
+
class be extends _ {
|
|
1406
1409
|
_parse(e) {
|
|
1407
1410
|
if (this._getType(e) !== h.symbol) {
|
|
1408
1411
|
const n = this._getOrReturnCtx(e);
|
|
1409
1412
|
return f(n, {
|
|
1410
|
-
code:
|
|
1413
|
+
code: u.invalid_type,
|
|
1411
1414
|
expected: h.symbol,
|
|
1412
1415
|
received: n.parsedType
|
|
1413
1416
|
}), g;
|
|
1414
1417
|
}
|
|
1415
|
-
return
|
|
1418
|
+
return I(e.data);
|
|
1416
1419
|
}
|
|
1417
1420
|
}
|
|
1418
|
-
|
|
1421
|
+
be.create = (r) => new be({
|
|
1419
1422
|
typeName: y.ZodSymbol,
|
|
1420
1423
|
...v(r)
|
|
1421
1424
|
});
|
|
1422
|
-
class
|
|
1425
|
+
class ae extends _ {
|
|
1423
1426
|
_parse(e) {
|
|
1424
1427
|
if (this._getType(e) !== h.undefined) {
|
|
1425
1428
|
const n = this._getOrReturnCtx(e);
|
|
1426
1429
|
return f(n, {
|
|
1427
|
-
code:
|
|
1430
|
+
code: u.invalid_type,
|
|
1428
1431
|
expected: h.undefined,
|
|
1429
1432
|
received: n.parsedType
|
|
1430
1433
|
}), g;
|
|
1431
1434
|
}
|
|
1432
|
-
return
|
|
1435
|
+
return I(e.data);
|
|
1433
1436
|
}
|
|
1434
1437
|
}
|
|
1435
|
-
|
|
1438
|
+
ae.create = (r) => new ae({
|
|
1436
1439
|
typeName: y.ZodUndefined,
|
|
1437
1440
|
...v(r)
|
|
1438
1441
|
});
|
|
1439
|
-
class
|
|
1442
|
+
class ie extends _ {
|
|
1440
1443
|
_parse(e) {
|
|
1441
1444
|
if (this._getType(e) !== h.null) {
|
|
1442
1445
|
const n = this._getOrReturnCtx(e);
|
|
1443
1446
|
return f(n, {
|
|
1444
|
-
code:
|
|
1447
|
+
code: u.invalid_type,
|
|
1445
1448
|
expected: h.null,
|
|
1446
1449
|
received: n.parsedType
|
|
1447
1450
|
}), g;
|
|
1448
1451
|
}
|
|
1449
|
-
return
|
|
1452
|
+
return I(e.data);
|
|
1450
1453
|
}
|
|
1451
1454
|
}
|
|
1452
|
-
|
|
1455
|
+
ie.create = (r) => new ie({
|
|
1453
1456
|
typeName: y.ZodNull,
|
|
1454
1457
|
...v(r)
|
|
1455
1458
|
});
|
|
1456
|
-
class
|
|
1459
|
+
class G extends _ {
|
|
1457
1460
|
constructor() {
|
|
1458
1461
|
super(...arguments), this._any = !0;
|
|
1459
1462
|
}
|
|
1460
1463
|
_parse(e) {
|
|
1461
|
-
return
|
|
1464
|
+
return I(e.data);
|
|
1462
1465
|
}
|
|
1463
1466
|
}
|
|
1464
|
-
|
|
1467
|
+
G.create = (r) => new G({
|
|
1465
1468
|
typeName: y.ZodAny,
|
|
1466
1469
|
...v(r)
|
|
1467
1470
|
});
|
|
@@ -1470,59 +1473,59 @@ class U extends _ {
|
|
|
1470
1473
|
super(...arguments), this._unknown = !0;
|
|
1471
1474
|
}
|
|
1472
1475
|
_parse(e) {
|
|
1473
|
-
return
|
|
1476
|
+
return I(e.data);
|
|
1474
1477
|
}
|
|
1475
1478
|
}
|
|
1476
1479
|
U.create = (r) => new U({
|
|
1477
1480
|
typeName: y.ZodUnknown,
|
|
1478
1481
|
...v(r)
|
|
1479
1482
|
});
|
|
1480
|
-
class
|
|
1483
|
+
class $ extends _ {
|
|
1481
1484
|
_parse(e) {
|
|
1482
1485
|
const t = this._getOrReturnCtx(e);
|
|
1483
1486
|
return f(t, {
|
|
1484
|
-
code:
|
|
1487
|
+
code: u.invalid_type,
|
|
1485
1488
|
expected: h.never,
|
|
1486
1489
|
received: t.parsedType
|
|
1487
1490
|
}), g;
|
|
1488
1491
|
}
|
|
1489
1492
|
}
|
|
1490
|
-
|
|
1493
|
+
$.create = (r) => new $({
|
|
1491
1494
|
typeName: y.ZodNever,
|
|
1492
1495
|
...v(r)
|
|
1493
1496
|
});
|
|
1494
|
-
class
|
|
1497
|
+
class xe extends _ {
|
|
1495
1498
|
_parse(e) {
|
|
1496
1499
|
if (this._getType(e) !== h.undefined) {
|
|
1497
1500
|
const n = this._getOrReturnCtx(e);
|
|
1498
1501
|
return f(n, {
|
|
1499
|
-
code:
|
|
1502
|
+
code: u.invalid_type,
|
|
1500
1503
|
expected: h.void,
|
|
1501
1504
|
received: n.parsedType
|
|
1502
1505
|
}), g;
|
|
1503
1506
|
}
|
|
1504
|
-
return
|
|
1507
|
+
return I(e.data);
|
|
1505
1508
|
}
|
|
1506
1509
|
}
|
|
1507
|
-
|
|
1510
|
+
xe.create = (r) => new xe({
|
|
1508
1511
|
typeName: y.ZodVoid,
|
|
1509
1512
|
...v(r)
|
|
1510
1513
|
});
|
|
1511
|
-
class
|
|
1514
|
+
class Z extends _ {
|
|
1512
1515
|
_parse(e) {
|
|
1513
1516
|
const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
|
|
1514
1517
|
if (t.parsedType !== h.array)
|
|
1515
1518
|
return f(t, {
|
|
1516
|
-
code:
|
|
1519
|
+
code: u.invalid_type,
|
|
1517
1520
|
expected: h.array,
|
|
1518
1521
|
received: t.parsedType
|
|
1519
1522
|
}), g;
|
|
1520
1523
|
if (s.exactLength !== null) {
|
|
1521
|
-
const
|
|
1522
|
-
(
|
|
1523
|
-
code:
|
|
1524
|
-
minimum:
|
|
1525
|
-
maximum:
|
|
1524
|
+
const o = t.data.length > s.exactLength.value, c = t.data.length < s.exactLength.value;
|
|
1525
|
+
(o || c) && (f(t, {
|
|
1526
|
+
code: o ? u.too_big : u.too_small,
|
|
1527
|
+
minimum: c ? s.exactLength.value : void 0,
|
|
1528
|
+
maximum: o ? s.exactLength.value : void 0,
|
|
1526
1529
|
type: "array",
|
|
1527
1530
|
inclusive: !0,
|
|
1528
1531
|
exact: !0,
|
|
@@ -1530,50 +1533,50 @@ class A extends _ {
|
|
|
1530
1533
|
}), n.dirty());
|
|
1531
1534
|
}
|
|
1532
1535
|
if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
|
|
1533
|
-
code:
|
|
1536
|
+
code: u.too_small,
|
|
1534
1537
|
minimum: s.minLength.value,
|
|
1535
1538
|
type: "array",
|
|
1536
1539
|
inclusive: !0,
|
|
1537
1540
|
exact: !1,
|
|
1538
1541
|
message: s.minLength.message
|
|
1539
1542
|
}), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
|
|
1540
|
-
code:
|
|
1543
|
+
code: u.too_big,
|
|
1541
1544
|
maximum: s.maxLength.value,
|
|
1542
1545
|
type: "array",
|
|
1543
1546
|
inclusive: !0,
|
|
1544
1547
|
exact: !1,
|
|
1545
1548
|
message: s.maxLength.message
|
|
1546
1549
|
}), n.dirty()), t.common.async)
|
|
1547
|
-
return Promise.all([...t.data].map((
|
|
1548
|
-
const a = [...t.data].map((
|
|
1550
|
+
return Promise.all([...t.data].map((o, c) => s.type._parseAsync(new E(t, o, t.path, c)))).then((o) => T.mergeArray(n, o));
|
|
1551
|
+
const a = [...t.data].map((o, c) => s.type._parseSync(new E(t, o, t.path, c)));
|
|
1549
1552
|
return T.mergeArray(n, a);
|
|
1550
1553
|
}
|
|
1551
1554
|
get element() {
|
|
1552
1555
|
return this._def.type;
|
|
1553
1556
|
}
|
|
1554
1557
|
min(e, t) {
|
|
1555
|
-
return new
|
|
1558
|
+
return new Z({
|
|
1556
1559
|
...this._def,
|
|
1557
|
-
minLength: { value: e, message:
|
|
1560
|
+
minLength: { value: e, message: p.toString(t) }
|
|
1558
1561
|
});
|
|
1559
1562
|
}
|
|
1560
1563
|
max(e, t) {
|
|
1561
|
-
return new
|
|
1564
|
+
return new Z({
|
|
1562
1565
|
...this._def,
|
|
1563
|
-
maxLength: { value: e, message:
|
|
1566
|
+
maxLength: { value: e, message: p.toString(t) }
|
|
1564
1567
|
});
|
|
1565
1568
|
}
|
|
1566
1569
|
length(e, t) {
|
|
1567
|
-
return new
|
|
1570
|
+
return new Z({
|
|
1568
1571
|
...this._def,
|
|
1569
|
-
exactLength: { value: e, message:
|
|
1572
|
+
exactLength: { value: e, message: p.toString(t) }
|
|
1570
1573
|
});
|
|
1571
1574
|
}
|
|
1572
1575
|
nonempty(e) {
|
|
1573
1576
|
return this.min(1, e);
|
|
1574
1577
|
}
|
|
1575
1578
|
}
|
|
1576
|
-
|
|
1579
|
+
Z.create = (r, e) => new Z({
|
|
1577
1580
|
type: r,
|
|
1578
1581
|
minLength: null,
|
|
1579
1582
|
maxLength: null,
|
|
@@ -1581,21 +1584,21 @@ A.create = (r, e) => new A({
|
|
|
1581
1584
|
typeName: y.ZodArray,
|
|
1582
1585
|
...v(e)
|
|
1583
1586
|
});
|
|
1584
|
-
function
|
|
1587
|
+
function Q(r) {
|
|
1585
1588
|
if (r instanceof k) {
|
|
1586
1589
|
const e = {};
|
|
1587
1590
|
for (const t in r.shape) {
|
|
1588
1591
|
const n = r.shape[t];
|
|
1589
|
-
e[t] = j.create(
|
|
1592
|
+
e[t] = j.create(Q(n));
|
|
1590
1593
|
}
|
|
1591
1594
|
return new k({
|
|
1592
1595
|
...r._def,
|
|
1593
1596
|
shape: () => e
|
|
1594
1597
|
});
|
|
1595
|
-
} else return r instanceof
|
|
1598
|
+
} else return r instanceof Z ? new Z({
|
|
1596
1599
|
...r._def,
|
|
1597
|
-
type:
|
|
1598
|
-
}) : r instanceof j ? j.create(
|
|
1600
|
+
type: Q(r.element)
|
|
1601
|
+
}) : r instanceof j ? j.create(Q(r.unwrap())) : r instanceof z ? z.create(Q(r.unwrap())) : r instanceof R ? R.create(r.items.map((e) => Q(e))) : r;
|
|
1599
1602
|
}
|
|
1600
1603
|
class k extends _ {
|
|
1601
1604
|
constructor() {
|
|
@@ -1604,87 +1607,87 @@ class k extends _ {
|
|
|
1604
1607
|
_getCached() {
|
|
1605
1608
|
if (this._cached !== null)
|
|
1606
1609
|
return this._cached;
|
|
1607
|
-
const e = this._def.shape(), t =
|
|
1610
|
+
const e = this._def.shape(), t = x.objectKeys(e);
|
|
1608
1611
|
return this._cached = { shape: e, keys: t };
|
|
1609
1612
|
}
|
|
1610
1613
|
_parse(e) {
|
|
1611
1614
|
if (this._getType(e) !== h.object) {
|
|
1612
|
-
const
|
|
1613
|
-
return f(
|
|
1614
|
-
code:
|
|
1615
|
+
const l = this._getOrReturnCtx(e);
|
|
1616
|
+
return f(l, {
|
|
1617
|
+
code: u.invalid_type,
|
|
1615
1618
|
expected: h.object,
|
|
1616
|
-
received:
|
|
1619
|
+
received: l.parsedType
|
|
1617
1620
|
}), g;
|
|
1618
1621
|
}
|
|
1619
|
-
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys:
|
|
1620
|
-
if (!(this._def.catchall instanceof
|
|
1621
|
-
for (const
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
for (const
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
key: { status: "valid", value:
|
|
1628
|
-
value:
|
|
1629
|
-
alwaysSet:
|
|
1622
|
+
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), c = [];
|
|
1623
|
+
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1624
|
+
for (const l in s.data)
|
|
1625
|
+
o.includes(l) || c.push(l);
|
|
1626
|
+
const d = [];
|
|
1627
|
+
for (const l of o) {
|
|
1628
|
+
const m = a[l], b = s.data[l];
|
|
1629
|
+
d.push({
|
|
1630
|
+
key: { status: "valid", value: l },
|
|
1631
|
+
value: m._parse(new E(s, b, s.path, l)),
|
|
1632
|
+
alwaysSet: l in s.data
|
|
1630
1633
|
});
|
|
1631
1634
|
}
|
|
1632
|
-
if (this._def.catchall instanceof
|
|
1633
|
-
const
|
|
1634
|
-
if (
|
|
1635
|
-
for (const
|
|
1636
|
-
|
|
1637
|
-
key: { status: "valid", value:
|
|
1638
|
-
value: { status: "valid", value: s.data[
|
|
1635
|
+
if (this._def.catchall instanceof $) {
|
|
1636
|
+
const l = this._def.unknownKeys;
|
|
1637
|
+
if (l === "passthrough")
|
|
1638
|
+
for (const m of c)
|
|
1639
|
+
d.push({
|
|
1640
|
+
key: { status: "valid", value: m },
|
|
1641
|
+
value: { status: "valid", value: s.data[m] }
|
|
1639
1642
|
});
|
|
1640
|
-
else if (
|
|
1641
|
-
|
|
1642
|
-
code:
|
|
1643
|
-
keys:
|
|
1643
|
+
else if (l === "strict")
|
|
1644
|
+
c.length > 0 && (f(s, {
|
|
1645
|
+
code: u.unrecognized_keys,
|
|
1646
|
+
keys: c
|
|
1644
1647
|
}), n.dirty());
|
|
1645
|
-
else if (
|
|
1648
|
+
else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1646
1649
|
} else {
|
|
1647
|
-
const
|
|
1648
|
-
for (const
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1651
|
-
key: { status: "valid", value:
|
|
1652
|
-
value:
|
|
1653
|
-
new E(s,
|
|
1650
|
+
const l = this._def.catchall;
|
|
1651
|
+
for (const m of c) {
|
|
1652
|
+
const b = s.data[m];
|
|
1653
|
+
d.push({
|
|
1654
|
+
key: { status: "valid", value: m },
|
|
1655
|
+
value: l._parse(
|
|
1656
|
+
new E(s, b, s.path, m)
|
|
1654
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1655
1658
|
),
|
|
1656
|
-
alwaysSet:
|
|
1659
|
+
alwaysSet: m in s.data
|
|
1657
1660
|
});
|
|
1658
1661
|
}
|
|
1659
1662
|
}
|
|
1660
1663
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1661
|
-
const
|
|
1662
|
-
for (const
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1665
|
-
key:
|
|
1666
|
-
value:
|
|
1667
|
-
alwaysSet:
|
|
1664
|
+
const l = [];
|
|
1665
|
+
for (const m of d) {
|
|
1666
|
+
const b = await m.key, w = await m.value;
|
|
1667
|
+
l.push({
|
|
1668
|
+
key: b,
|
|
1669
|
+
value: w,
|
|
1670
|
+
alwaysSet: m.alwaysSet
|
|
1668
1671
|
});
|
|
1669
1672
|
}
|
|
1670
|
-
return
|
|
1671
|
-
}).then((
|
|
1673
|
+
return l;
|
|
1674
|
+
}).then((l) => T.mergeObjectSync(n, l)) : T.mergeObjectSync(n, d);
|
|
1672
1675
|
}
|
|
1673
1676
|
get shape() {
|
|
1674
1677
|
return this._def.shape();
|
|
1675
1678
|
}
|
|
1676
1679
|
strict(e) {
|
|
1677
|
-
return
|
|
1680
|
+
return p.errToObj, new k({
|
|
1678
1681
|
...this._def,
|
|
1679
1682
|
unknownKeys: "strict",
|
|
1680
1683
|
...e !== void 0 ? {
|
|
1681
1684
|
errorMap: (t, n) => {
|
|
1682
|
-
var s, a,
|
|
1683
|
-
const
|
|
1685
|
+
var s, a, o, c;
|
|
1686
|
+
const d = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && o !== void 0 ? o : n.defaultError;
|
|
1684
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1685
|
-
message: (
|
|
1688
|
+
message: (c = p.errToObj(e).message) !== null && c !== void 0 ? c : d
|
|
1686
1689
|
} : {
|
|
1687
|
-
message:
|
|
1690
|
+
message: d
|
|
1688
1691
|
};
|
|
1689
1692
|
}
|
|
1690
1693
|
} : {}
|
|
@@ -1811,7 +1814,7 @@ class k extends _ {
|
|
|
1811
1814
|
}
|
|
1812
1815
|
pick(e) {
|
|
1813
1816
|
const t = {};
|
|
1814
|
-
return
|
|
1817
|
+
return x.objectKeys(e).forEach((n) => {
|
|
1815
1818
|
e[n] && this.shape[n] && (t[n] = this.shape[n]);
|
|
1816
1819
|
}), new k({
|
|
1817
1820
|
...this._def,
|
|
@@ -1820,7 +1823,7 @@ class k extends _ {
|
|
|
1820
1823
|
}
|
|
1821
1824
|
omit(e) {
|
|
1822
1825
|
const t = {};
|
|
1823
|
-
return
|
|
1826
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1824
1827
|
e[n] || (t[n] = this.shape[n]);
|
|
1825
1828
|
}), new k({
|
|
1826
1829
|
...this._def,
|
|
@@ -1831,11 +1834,11 @@ class k extends _ {
|
|
|
1831
1834
|
* @deprecated
|
|
1832
1835
|
*/
|
|
1833
1836
|
deepPartial() {
|
|
1834
|
-
return
|
|
1837
|
+
return Q(this);
|
|
1835
1838
|
}
|
|
1836
1839
|
partial(e) {
|
|
1837
1840
|
const t = {};
|
|
1838
|
-
return
|
|
1841
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1839
1842
|
const s = this.shape[n];
|
|
1840
1843
|
e && !e[n] ? t[n] = s : t[n] = s.optional();
|
|
1841
1844
|
}), new k({
|
|
@@ -1845,7 +1848,7 @@ class k extends _ {
|
|
|
1845
1848
|
}
|
|
1846
1849
|
required(e) {
|
|
1847
1850
|
const t = {};
|
|
1848
|
-
return
|
|
1851
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1849
1852
|
if (e && !e[n])
|
|
1850
1853
|
t[n] = this.shape[n];
|
|
1851
1854
|
else {
|
|
@@ -1860,49 +1863,49 @@ class k extends _ {
|
|
|
1860
1863
|
});
|
|
1861
1864
|
}
|
|
1862
1865
|
keyof() {
|
|
1863
|
-
return
|
|
1866
|
+
return Ue(x.objectKeys(this.shape));
|
|
1864
1867
|
}
|
|
1865
1868
|
}
|
|
1866
1869
|
k.create = (r, e) => new k({
|
|
1867
1870
|
shape: () => r,
|
|
1868
1871
|
unknownKeys: "strip",
|
|
1869
|
-
catchall:
|
|
1872
|
+
catchall: $.create(),
|
|
1870
1873
|
typeName: y.ZodObject,
|
|
1871
1874
|
...v(e)
|
|
1872
1875
|
});
|
|
1873
1876
|
k.strictCreate = (r, e) => new k({
|
|
1874
1877
|
shape: () => r,
|
|
1875
1878
|
unknownKeys: "strict",
|
|
1876
|
-
catchall:
|
|
1879
|
+
catchall: $.create(),
|
|
1877
1880
|
typeName: y.ZodObject,
|
|
1878
1881
|
...v(e)
|
|
1879
1882
|
});
|
|
1880
1883
|
k.lazycreate = (r, e) => new k({
|
|
1881
1884
|
shape: r,
|
|
1882
1885
|
unknownKeys: "strip",
|
|
1883
|
-
catchall:
|
|
1886
|
+
catchall: $.create(),
|
|
1884
1887
|
typeName: y.ZodObject,
|
|
1885
1888
|
...v(e)
|
|
1886
1889
|
});
|
|
1887
|
-
class
|
|
1890
|
+
class oe extends _ {
|
|
1888
1891
|
_parse(e) {
|
|
1889
1892
|
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
1890
1893
|
function s(a) {
|
|
1891
|
-
for (const
|
|
1892
|
-
if (
|
|
1893
|
-
return
|
|
1894
|
-
for (const
|
|
1895
|
-
if (
|
|
1896
|
-
return t.common.issues.push(...
|
|
1897
|
-
const
|
|
1894
|
+
for (const c of a)
|
|
1895
|
+
if (c.result.status === "valid")
|
|
1896
|
+
return c.result;
|
|
1897
|
+
for (const c of a)
|
|
1898
|
+
if (c.result.status === "dirty")
|
|
1899
|
+
return t.common.issues.push(...c.ctx.common.issues), c.result;
|
|
1900
|
+
const o = a.map((c) => new A(c.ctx.common.issues));
|
|
1898
1901
|
return f(t, {
|
|
1899
|
-
code:
|
|
1900
|
-
unionErrors:
|
|
1902
|
+
code: u.invalid_union,
|
|
1903
|
+
unionErrors: o
|
|
1901
1904
|
}), g;
|
|
1902
1905
|
}
|
|
1903
1906
|
if (t.common.async)
|
|
1904
1907
|
return Promise.all(n.map(async (a) => {
|
|
1905
|
-
const
|
|
1908
|
+
const o = {
|
|
1906
1909
|
...t,
|
|
1907
1910
|
common: {
|
|
1908
1911
|
...t.common,
|
|
@@ -1914,37 +1917,37 @@ class ce extends _ {
|
|
|
1914
1917
|
result: await a._parseAsync({
|
|
1915
1918
|
data: t.data,
|
|
1916
1919
|
path: t.path,
|
|
1917
|
-
parent:
|
|
1920
|
+
parent: o
|
|
1918
1921
|
}),
|
|
1919
|
-
ctx:
|
|
1922
|
+
ctx: o
|
|
1920
1923
|
};
|
|
1921
1924
|
})).then(s);
|
|
1922
1925
|
{
|
|
1923
1926
|
let a;
|
|
1924
|
-
const
|
|
1925
|
-
for (const
|
|
1926
|
-
const
|
|
1927
|
+
const o = [];
|
|
1928
|
+
for (const d of n) {
|
|
1929
|
+
const l = {
|
|
1927
1930
|
...t,
|
|
1928
1931
|
common: {
|
|
1929
1932
|
...t.common,
|
|
1930
1933
|
issues: []
|
|
1931
1934
|
},
|
|
1932
1935
|
parent: null
|
|
1933
|
-
},
|
|
1936
|
+
}, m = d._parseSync({
|
|
1934
1937
|
data: t.data,
|
|
1935
1938
|
path: t.path,
|
|
1936
|
-
parent:
|
|
1939
|
+
parent: l
|
|
1937
1940
|
});
|
|
1938
|
-
if (
|
|
1939
|
-
return
|
|
1940
|
-
|
|
1941
|
+
if (m.status === "valid")
|
|
1942
|
+
return m;
|
|
1943
|
+
m.status === "dirty" && !a && (a = { result: m, ctx: l }), l.common.issues.length && o.push(l.common.issues);
|
|
1941
1944
|
}
|
|
1942
1945
|
if (a)
|
|
1943
1946
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1944
|
-
const
|
|
1947
|
+
const c = o.map((d) => new A(d));
|
|
1945
1948
|
return f(t, {
|
|
1946
|
-
code:
|
|
1947
|
-
unionErrors:
|
|
1949
|
+
code: u.invalid_union,
|
|
1950
|
+
unionErrors: c
|
|
1948
1951
|
}), g;
|
|
1949
1952
|
}
|
|
1950
1953
|
}
|
|
@@ -1952,18 +1955,18 @@ class ce extends _ {
|
|
|
1952
1955
|
return this._def.options;
|
|
1953
1956
|
}
|
|
1954
1957
|
}
|
|
1955
|
-
|
|
1958
|
+
oe.create = (r, e) => new oe({
|
|
1956
1959
|
options: r,
|
|
1957
1960
|
typeName: y.ZodUnion,
|
|
1958
1961
|
...v(e)
|
|
1959
1962
|
});
|
|
1960
|
-
const P = (r) => r instanceof
|
|
1961
|
-
class
|
|
1963
|
+
const P = (r) => r instanceof ue ? P(r.schema) : r instanceof O ? P(r.innerType()) : r instanceof le ? [r.value] : r instanceof L ? r.options : r instanceof fe ? x.objectValues(r.enum) : r instanceof he ? P(r._def.innerType) : r instanceof ae ? [void 0] : r instanceof ie ? [null] : r instanceof j ? [void 0, ...P(r.unwrap())] : r instanceof z ? [null, ...P(r.unwrap())] : r instanceof je || r instanceof pe ? P(r.unwrap()) : r instanceof me ? P(r._def.innerType) : [];
|
|
1964
|
+
class Te extends _ {
|
|
1962
1965
|
_parse(e) {
|
|
1963
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
1964
1967
|
if (t.parsedType !== h.object)
|
|
1965
1968
|
return f(t, {
|
|
1966
|
-
code:
|
|
1969
|
+
code: u.invalid_type,
|
|
1967
1970
|
expected: h.object,
|
|
1968
1971
|
received: t.parsedType
|
|
1969
1972
|
}), g;
|
|
@@ -1977,7 +1980,7 @@ class Se extends _ {
|
|
|
1977
1980
|
path: t.path,
|
|
1978
1981
|
parent: t
|
|
1979
1982
|
}) : (f(t, {
|
|
1980
|
-
code:
|
|
1983
|
+
code: u.invalid_union_discriminator,
|
|
1981
1984
|
options: Array.from(this.optionsMap.keys()),
|
|
1982
1985
|
path: [n]
|
|
1983
1986
|
}), g);
|
|
@@ -2002,16 +2005,16 @@ class Se extends _ {
|
|
|
2002
2005
|
static create(e, t, n) {
|
|
2003
2006
|
const s = /* @__PURE__ */ new Map();
|
|
2004
2007
|
for (const a of t) {
|
|
2005
|
-
const
|
|
2006
|
-
if (!
|
|
2008
|
+
const o = P(a.shape[e]);
|
|
2009
|
+
if (!o.length)
|
|
2007
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2008
|
-
for (const
|
|
2009
|
-
if (s.has(
|
|
2010
|
-
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(
|
|
2011
|
-
s.set(
|
|
2011
|
+
for (const c of o) {
|
|
2012
|
+
if (s.has(c))
|
|
2013
|
+
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
|
|
2014
|
+
s.set(c, a);
|
|
2012
2015
|
}
|
|
2013
2016
|
}
|
|
2014
|
-
return new
|
|
2017
|
+
return new Te({
|
|
2015
2018
|
typeName: y.ZodDiscriminatedUnion,
|
|
2016
2019
|
discriminator: e,
|
|
2017
2020
|
options: t,
|
|
@@ -2020,40 +2023,40 @@ class Se extends _ {
|
|
|
2020
2023
|
});
|
|
2021
2024
|
}
|
|
2022
2025
|
}
|
|
2023
|
-
function
|
|
2024
|
-
const t =
|
|
2026
|
+
function Oe(r, e) {
|
|
2027
|
+
const t = D(r), n = D(e);
|
|
2025
2028
|
if (r === e)
|
|
2026
2029
|
return { valid: !0, data: r };
|
|
2027
2030
|
if (t === h.object && n === h.object) {
|
|
2028
|
-
const s =
|
|
2029
|
-
for (const
|
|
2030
|
-
const
|
|
2031
|
-
if (!
|
|
2031
|
+
const s = x.objectKeys(e), a = x.objectKeys(r).filter((c) => s.indexOf(c) !== -1), o = { ...r, ...e };
|
|
2032
|
+
for (const c of a) {
|
|
2033
|
+
const d = Oe(r[c], e[c]);
|
|
2034
|
+
if (!d.valid)
|
|
2032
2035
|
return { valid: !1 };
|
|
2033
|
-
c
|
|
2036
|
+
o[c] = d.data;
|
|
2034
2037
|
}
|
|
2035
|
-
return { valid: !0, data:
|
|
2038
|
+
return { valid: !0, data: o };
|
|
2036
2039
|
} else if (t === h.array && n === h.array) {
|
|
2037
2040
|
if (r.length !== e.length)
|
|
2038
2041
|
return { valid: !1 };
|
|
2039
2042
|
const s = [];
|
|
2040
2043
|
for (let a = 0; a < r.length; a++) {
|
|
2041
|
-
const
|
|
2042
|
-
if (!
|
|
2044
|
+
const o = r[a], c = e[a], d = Oe(o, c);
|
|
2045
|
+
if (!d.valid)
|
|
2043
2046
|
return { valid: !1 };
|
|
2044
|
-
s.push(
|
|
2047
|
+
s.push(d.data);
|
|
2045
2048
|
}
|
|
2046
2049
|
return { valid: !0, data: s };
|
|
2047
2050
|
} else return t === h.date && n === h.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
2048
2051
|
}
|
|
2049
|
-
class
|
|
2052
|
+
class ce extends _ {
|
|
2050
2053
|
_parse(e) {
|
|
2051
|
-
const { status: t, ctx: n } = this._processInputParams(e), s = (a,
|
|
2052
|
-
if (
|
|
2054
|
+
const { status: t, ctx: n } = this._processInputParams(e), s = (a, o) => {
|
|
2055
|
+
if (Ne(a) || Ne(o))
|
|
2053
2056
|
return g;
|
|
2054
|
-
const
|
|
2055
|
-
return
|
|
2056
|
-
code:
|
|
2057
|
+
const c = Oe(a.value, o.value);
|
|
2058
|
+
return c.valid ? ((Ze(a) || Ze(o)) && t.dirty(), { status: t.value, value: c.data }) : (f(n, {
|
|
2059
|
+
code: u.invalid_intersection_types
|
|
2057
2060
|
}), g);
|
|
2058
2061
|
};
|
|
2059
2062
|
return n.common.async ? Promise.all([
|
|
@@ -2067,7 +2070,7 @@ class de extends _ {
|
|
|
2067
2070
|
path: n.path,
|
|
2068
2071
|
parent: n
|
|
2069
2072
|
})
|
|
2070
|
-
]).then(([a,
|
|
2073
|
+
]).then(([a, o]) => s(a, o)) : s(this._def.left._parseSync({
|
|
2071
2074
|
data: n.data,
|
|
2072
2075
|
path: n.path,
|
|
2073
2076
|
parent: n
|
|
@@ -2078,7 +2081,7 @@ class de extends _ {
|
|
|
2078
2081
|
}));
|
|
2079
2082
|
}
|
|
2080
2083
|
}
|
|
2081
|
-
|
|
2084
|
+
ce.create = (r, e, t) => new ce({
|
|
2082
2085
|
left: r,
|
|
2083
2086
|
right: e,
|
|
2084
2087
|
typeName: y.ZodIntersection,
|
|
@@ -2089,30 +2092,30 @@ class R extends _ {
|
|
|
2089
2092
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2090
2093
|
if (n.parsedType !== h.array)
|
|
2091
2094
|
return f(n, {
|
|
2092
|
-
code:
|
|
2095
|
+
code: u.invalid_type,
|
|
2093
2096
|
expected: h.array,
|
|
2094
2097
|
received: n.parsedType
|
|
2095
2098
|
}), g;
|
|
2096
2099
|
if (n.data.length < this._def.items.length)
|
|
2097
2100
|
return f(n, {
|
|
2098
|
-
code:
|
|
2101
|
+
code: u.too_small,
|
|
2099
2102
|
minimum: this._def.items.length,
|
|
2100
2103
|
inclusive: !0,
|
|
2101
2104
|
exact: !1,
|
|
2102
2105
|
type: "array"
|
|
2103
2106
|
}), g;
|
|
2104
2107
|
!this._def.rest && n.data.length > this._def.items.length && (f(n, {
|
|
2105
|
-
code:
|
|
2108
|
+
code: u.too_big,
|
|
2106
2109
|
maximum: this._def.items.length,
|
|
2107
2110
|
inclusive: !0,
|
|
2108
2111
|
exact: !1,
|
|
2109
2112
|
type: "array"
|
|
2110
2113
|
}), t.dirty());
|
|
2111
|
-
const a = [...n.data].map((
|
|
2112
|
-
const
|
|
2113
|
-
return
|
|
2114
|
-
}).filter((
|
|
2115
|
-
return n.common.async ? Promise.all(a).then((
|
|
2114
|
+
const a = [...n.data].map((o, c) => {
|
|
2115
|
+
const d = this._def.items[c] || this._def.rest;
|
|
2116
|
+
return d ? d._parse(new E(n, o, n.path, c)) : null;
|
|
2117
|
+
}).filter((o) => !!o);
|
|
2118
|
+
return n.common.async ? Promise.all(a).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, a);
|
|
2116
2119
|
}
|
|
2117
2120
|
get items() {
|
|
2118
2121
|
return this._def.items;
|
|
@@ -2134,7 +2137,7 @@ R.create = (r, e) => {
|
|
|
2134
2137
|
...v(e)
|
|
2135
2138
|
});
|
|
2136
2139
|
};
|
|
2137
|
-
class
|
|
2140
|
+
class de extends _ {
|
|
2138
2141
|
get keySchema() {
|
|
2139
2142
|
return this._def.keyType;
|
|
2140
2143
|
}
|
|
@@ -2145,16 +2148,16 @@ class ue extends _ {
|
|
|
2145
2148
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2146
2149
|
if (n.parsedType !== h.object)
|
|
2147
2150
|
return f(n, {
|
|
2148
|
-
code:
|
|
2151
|
+
code: u.invalid_type,
|
|
2149
2152
|
expected: h.object,
|
|
2150
2153
|
received: n.parsedType
|
|
2151
2154
|
}), g;
|
|
2152
|
-
const s = [], a = this._def.keyType,
|
|
2153
|
-
for (const
|
|
2155
|
+
const s = [], a = this._def.keyType, o = this._def.valueType;
|
|
2156
|
+
for (const c in n.data)
|
|
2154
2157
|
s.push({
|
|
2155
|
-
key: a._parse(new E(n,
|
|
2156
|
-
value:
|
|
2157
|
-
alwaysSet:
|
|
2158
|
+
key: a._parse(new E(n, c, n.path, c)),
|
|
2159
|
+
value: o._parse(new E(n, n.data[c], n.path, c)),
|
|
2160
|
+
alwaysSet: c in n.data
|
|
2158
2161
|
});
|
|
2159
2162
|
return n.common.async ? T.mergeObjectAsync(t, s) : T.mergeObjectSync(t, s);
|
|
2160
2163
|
}
|
|
@@ -2162,20 +2165,20 @@ class ue extends _ {
|
|
|
2162
2165
|
return this._def.valueType;
|
|
2163
2166
|
}
|
|
2164
2167
|
static create(e, t, n) {
|
|
2165
|
-
return t instanceof _ ? new
|
|
2168
|
+
return t instanceof _ ? new de({
|
|
2166
2169
|
keyType: e,
|
|
2167
2170
|
valueType: t,
|
|
2168
2171
|
typeName: y.ZodRecord,
|
|
2169
2172
|
...v(n)
|
|
2170
|
-
}) : new
|
|
2171
|
-
keyType:
|
|
2173
|
+
}) : new de({
|
|
2174
|
+
keyType: N.create(),
|
|
2172
2175
|
valueType: e,
|
|
2173
2176
|
typeName: y.ZodRecord,
|
|
2174
2177
|
...v(t)
|
|
2175
2178
|
});
|
|
2176
2179
|
}
|
|
2177
2180
|
}
|
|
2178
|
-
class
|
|
2181
|
+
class ke extends _ {
|
|
2179
2182
|
get keySchema() {
|
|
2180
2183
|
return this._def.keyType;
|
|
2181
2184
|
}
|
|
@@ -2186,62 +2189,62 @@ class we extends _ {
|
|
|
2186
2189
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2187
2190
|
if (n.parsedType !== h.map)
|
|
2188
2191
|
return f(n, {
|
|
2189
|
-
code:
|
|
2192
|
+
code: u.invalid_type,
|
|
2190
2193
|
expected: h.map,
|
|
2191
2194
|
received: n.parsedType
|
|
2192
2195
|
}), g;
|
|
2193
|
-
const s = this._def.keyType, a = this._def.valueType,
|
|
2194
|
-
key: s._parse(new E(n,
|
|
2195
|
-
value: a._parse(new E(n,
|
|
2196
|
+
const s = this._def.keyType, a = this._def.valueType, o = [...n.data.entries()].map(([c, d], l) => ({
|
|
2197
|
+
key: s._parse(new E(n, c, n.path, [l, "key"])),
|
|
2198
|
+
value: a._parse(new E(n, d, n.path, [l, "value"]))
|
|
2196
2199
|
}));
|
|
2197
2200
|
if (n.common.async) {
|
|
2198
|
-
const
|
|
2201
|
+
const c = /* @__PURE__ */ new Map();
|
|
2199
2202
|
return Promise.resolve().then(async () => {
|
|
2200
|
-
for (const
|
|
2201
|
-
const
|
|
2202
|
-
if (
|
|
2203
|
+
for (const d of o) {
|
|
2204
|
+
const l = await d.key, m = await d.value;
|
|
2205
|
+
if (l.status === "aborted" || m.status === "aborted")
|
|
2203
2206
|
return g;
|
|
2204
|
-
(
|
|
2207
|
+
(l.status === "dirty" || m.status === "dirty") && t.dirty(), c.set(l.value, m.value);
|
|
2205
2208
|
}
|
|
2206
|
-
return { status: t.value, value:
|
|
2209
|
+
return { status: t.value, value: c };
|
|
2207
2210
|
});
|
|
2208
2211
|
} else {
|
|
2209
|
-
const
|
|
2210
|
-
for (const
|
|
2211
|
-
const
|
|
2212
|
-
if (
|
|
2212
|
+
const c = /* @__PURE__ */ new Map();
|
|
2213
|
+
for (const d of o) {
|
|
2214
|
+
const l = d.key, m = d.value;
|
|
2215
|
+
if (l.status === "aborted" || m.status === "aborted")
|
|
2213
2216
|
return g;
|
|
2214
|
-
(
|
|
2217
|
+
(l.status === "dirty" || m.status === "dirty") && t.dirty(), c.set(l.value, m.value);
|
|
2215
2218
|
}
|
|
2216
|
-
return { status: t.value, value:
|
|
2219
|
+
return { status: t.value, value: c };
|
|
2217
2220
|
}
|
|
2218
2221
|
}
|
|
2219
2222
|
}
|
|
2220
|
-
|
|
2223
|
+
ke.create = (r, e, t) => new ke({
|
|
2221
2224
|
valueType: e,
|
|
2222
2225
|
keyType: r,
|
|
2223
2226
|
typeName: y.ZodMap,
|
|
2224
2227
|
...v(t)
|
|
2225
2228
|
});
|
|
2226
|
-
class
|
|
2229
|
+
class q extends _ {
|
|
2227
2230
|
_parse(e) {
|
|
2228
2231
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2229
2232
|
if (n.parsedType !== h.set)
|
|
2230
2233
|
return f(n, {
|
|
2231
|
-
code:
|
|
2234
|
+
code: u.invalid_type,
|
|
2232
2235
|
expected: h.set,
|
|
2233
2236
|
received: n.parsedType
|
|
2234
2237
|
}), g;
|
|
2235
2238
|
const s = this._def;
|
|
2236
2239
|
s.minSize !== null && n.data.size < s.minSize.value && (f(n, {
|
|
2237
|
-
code:
|
|
2240
|
+
code: u.too_small,
|
|
2238
2241
|
minimum: s.minSize.value,
|
|
2239
2242
|
type: "set",
|
|
2240
2243
|
inclusive: !0,
|
|
2241
2244
|
exact: !1,
|
|
2242
2245
|
message: s.minSize.message
|
|
2243
2246
|
}), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (f(n, {
|
|
2244
|
-
code:
|
|
2247
|
+
code: u.too_big,
|
|
2245
2248
|
maximum: s.maxSize.value,
|
|
2246
2249
|
type: "set",
|
|
2247
2250
|
inclusive: !0,
|
|
@@ -2249,28 +2252,28 @@ class W extends _ {
|
|
|
2249
2252
|
message: s.maxSize.message
|
|
2250
2253
|
}), t.dirty());
|
|
2251
2254
|
const a = this._def.valueType;
|
|
2252
|
-
function
|
|
2253
|
-
const
|
|
2254
|
-
for (const
|
|
2255
|
-
if (
|
|
2255
|
+
function o(d) {
|
|
2256
|
+
const l = /* @__PURE__ */ new Set();
|
|
2257
|
+
for (const m of d) {
|
|
2258
|
+
if (m.status === "aborted")
|
|
2256
2259
|
return g;
|
|
2257
|
-
|
|
2260
|
+
m.status === "dirty" && t.dirty(), l.add(m.value);
|
|
2258
2261
|
}
|
|
2259
|
-
return { status: t.value, value:
|
|
2262
|
+
return { status: t.value, value: l };
|
|
2260
2263
|
}
|
|
2261
|
-
const
|
|
2262
|
-
return n.common.async ? Promise.all(
|
|
2264
|
+
const c = [...n.data.values()].map((d, l) => a._parse(new E(n, d, n.path, l)));
|
|
2265
|
+
return n.common.async ? Promise.all(c).then((d) => o(d)) : o(c);
|
|
2263
2266
|
}
|
|
2264
2267
|
min(e, t) {
|
|
2265
|
-
return new
|
|
2268
|
+
return new q({
|
|
2266
2269
|
...this._def,
|
|
2267
|
-
minSize: { value: e, message:
|
|
2270
|
+
minSize: { value: e, message: p.toString(t) }
|
|
2268
2271
|
});
|
|
2269
2272
|
}
|
|
2270
2273
|
max(e, t) {
|
|
2271
|
-
return new
|
|
2274
|
+
return new q({
|
|
2272
2275
|
...this._def,
|
|
2273
|
-
maxSize: { value: e, message:
|
|
2276
|
+
maxSize: { value: e, message: p.toString(t) }
|
|
2274
2277
|
});
|
|
2275
2278
|
}
|
|
2276
2279
|
size(e, t) {
|
|
@@ -2280,14 +2283,14 @@ class W extends _ {
|
|
|
2280
2283
|
return this.min(1, e);
|
|
2281
2284
|
}
|
|
2282
2285
|
}
|
|
2283
|
-
|
|
2286
|
+
q.create = (r, e) => new q({
|
|
2284
2287
|
valueType: r,
|
|
2285
2288
|
minSize: null,
|
|
2286
2289
|
maxSize: null,
|
|
2287
2290
|
typeName: y.ZodSet,
|
|
2288
2291
|
...v(e)
|
|
2289
2292
|
});
|
|
2290
|
-
class
|
|
2293
|
+
class Y extends _ {
|
|
2291
2294
|
constructor() {
|
|
2292
2295
|
super(...arguments), this.validate = this.implement;
|
|
2293
2296
|
}
|
|
@@ -2295,63 +2298,63 @@ class Q extends _ {
|
|
|
2295
2298
|
const { ctx: t } = this._processInputParams(e);
|
|
2296
2299
|
if (t.parsedType !== h.function)
|
|
2297
2300
|
return f(t, {
|
|
2298
|
-
code:
|
|
2301
|
+
code: u.invalid_type,
|
|
2299
2302
|
expected: h.function,
|
|
2300
2303
|
received: t.parsedType
|
|
2301
2304
|
}), g;
|
|
2302
|
-
function n(
|
|
2303
|
-
return
|
|
2304
|
-
data:
|
|
2305
|
+
function n(c, d) {
|
|
2306
|
+
return ve({
|
|
2307
|
+
data: c,
|
|
2305
2308
|
path: t.path,
|
|
2306
2309
|
errorMaps: [
|
|
2307
2310
|
t.common.contextualErrorMap,
|
|
2308
2311
|
t.schemaErrorMap,
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
].filter((
|
|
2312
|
+
ge(),
|
|
2313
|
+
H
|
|
2314
|
+
].filter((l) => !!l),
|
|
2312
2315
|
issueData: {
|
|
2313
|
-
code:
|
|
2314
|
-
argumentsError:
|
|
2316
|
+
code: u.invalid_arguments,
|
|
2317
|
+
argumentsError: d
|
|
2315
2318
|
}
|
|
2316
2319
|
});
|
|
2317
2320
|
}
|
|
2318
|
-
function s(
|
|
2319
|
-
return
|
|
2320
|
-
data:
|
|
2321
|
+
function s(c, d) {
|
|
2322
|
+
return ve({
|
|
2323
|
+
data: c,
|
|
2321
2324
|
path: t.path,
|
|
2322
2325
|
errorMaps: [
|
|
2323
2326
|
t.common.contextualErrorMap,
|
|
2324
2327
|
t.schemaErrorMap,
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
].filter((
|
|
2328
|
+
ge(),
|
|
2329
|
+
H
|
|
2330
|
+
].filter((l) => !!l),
|
|
2328
2331
|
issueData: {
|
|
2329
|
-
code:
|
|
2330
|
-
returnTypeError:
|
|
2332
|
+
code: u.invalid_return_type,
|
|
2333
|
+
returnTypeError: d
|
|
2331
2334
|
}
|
|
2332
2335
|
});
|
|
2333
2336
|
}
|
|
2334
|
-
const a = { errorMap: t.common.contextualErrorMap },
|
|
2335
|
-
if (this._def.returns instanceof
|
|
2336
|
-
const
|
|
2337
|
-
return
|
|
2338
|
-
const
|
|
2339
|
-
throw
|
|
2340
|
-
}),
|
|
2341
|
-
return await
|
|
2342
|
-
throw
|
|
2337
|
+
const a = { errorMap: t.common.contextualErrorMap }, o = t.data;
|
|
2338
|
+
if (this._def.returns instanceof X) {
|
|
2339
|
+
const c = this;
|
|
2340
|
+
return I(async function(...d) {
|
|
2341
|
+
const l = new A([]), m = await c._def.args.parseAsync(d, a).catch((S) => {
|
|
2342
|
+
throw l.addIssue(n(d, S)), l;
|
|
2343
|
+
}), b = await Reflect.apply(o, this, m);
|
|
2344
|
+
return await c._def.returns._def.type.parseAsync(b, a).catch((S) => {
|
|
2345
|
+
throw l.addIssue(s(b, S)), l;
|
|
2343
2346
|
});
|
|
2344
2347
|
});
|
|
2345
2348
|
} else {
|
|
2346
|
-
const
|
|
2347
|
-
return
|
|
2348
|
-
const
|
|
2349
|
-
if (!
|
|
2350
|
-
throw new
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
throw new
|
|
2354
|
-
return
|
|
2349
|
+
const c = this;
|
|
2350
|
+
return I(function(...d) {
|
|
2351
|
+
const l = c._def.args.safeParse(d, a);
|
|
2352
|
+
if (!l.success)
|
|
2353
|
+
throw new A([n(d, l.error)]);
|
|
2354
|
+
const m = Reflect.apply(o, this, l.data), b = c._def.returns.safeParse(m, a);
|
|
2355
|
+
if (!b.success)
|
|
2356
|
+
throw new A([s(m, b.error)]);
|
|
2357
|
+
return b.data;
|
|
2355
2358
|
});
|
|
2356
2359
|
}
|
|
2357
2360
|
}
|
|
@@ -2362,13 +2365,13 @@ class Q extends _ {
|
|
|
2362
2365
|
return this._def.returns;
|
|
2363
2366
|
}
|
|
2364
2367
|
args(...e) {
|
|
2365
|
-
return new
|
|
2368
|
+
return new Y({
|
|
2366
2369
|
...this._def,
|
|
2367
2370
|
args: R.create(e).rest(U.create())
|
|
2368
2371
|
});
|
|
2369
2372
|
}
|
|
2370
2373
|
returns(e) {
|
|
2371
|
-
return new
|
|
2374
|
+
return new Y({
|
|
2372
2375
|
...this._def,
|
|
2373
2376
|
returns: e
|
|
2374
2377
|
});
|
|
@@ -2380,7 +2383,7 @@ class Q extends _ {
|
|
|
2380
2383
|
return this.parse(e);
|
|
2381
2384
|
}
|
|
2382
2385
|
static create(e, t, n) {
|
|
2383
|
-
return new
|
|
2386
|
+
return new Y({
|
|
2384
2387
|
args: e || R.create([]).rest(U.create()),
|
|
2385
2388
|
returns: t || U.create(),
|
|
2386
2389
|
typeName: y.ZodFunction,
|
|
@@ -2388,7 +2391,7 @@ class Q extends _ {
|
|
|
2388
2391
|
});
|
|
2389
2392
|
}
|
|
2390
2393
|
}
|
|
2391
|
-
class
|
|
2394
|
+
class ue extends _ {
|
|
2392
2395
|
get schema() {
|
|
2393
2396
|
return this._def.getter();
|
|
2394
2397
|
}
|
|
@@ -2397,18 +2400,18 @@ class le extends _ {
|
|
|
2397
2400
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2398
2401
|
}
|
|
2399
2402
|
}
|
|
2400
|
-
|
|
2403
|
+
ue.create = (r, e) => new ue({
|
|
2401
2404
|
getter: r,
|
|
2402
2405
|
typeName: y.ZodLazy,
|
|
2403
2406
|
...v(e)
|
|
2404
2407
|
});
|
|
2405
|
-
class
|
|
2408
|
+
class le extends _ {
|
|
2406
2409
|
_parse(e) {
|
|
2407
2410
|
if (e.data !== this._def.value) {
|
|
2408
2411
|
const t = this._getOrReturnCtx(e);
|
|
2409
2412
|
return f(t, {
|
|
2410
2413
|
received: t.data,
|
|
2411
|
-
code:
|
|
2414
|
+
code: u.invalid_literal,
|
|
2412
2415
|
expected: this._def.value
|
|
2413
2416
|
}), g;
|
|
2414
2417
|
}
|
|
@@ -2418,40 +2421,40 @@ class fe extends _ {
|
|
|
2418
2421
|
return this._def.value;
|
|
2419
2422
|
}
|
|
2420
2423
|
}
|
|
2421
|
-
|
|
2424
|
+
le.create = (r, e) => new le({
|
|
2422
2425
|
value: r,
|
|
2423
2426
|
typeName: y.ZodLiteral,
|
|
2424
2427
|
...v(e)
|
|
2425
2428
|
});
|
|
2426
|
-
function
|
|
2427
|
-
return new
|
|
2429
|
+
function Ue(r, e) {
|
|
2430
|
+
return new L({
|
|
2428
2431
|
values: r,
|
|
2429
2432
|
typeName: y.ZodEnum,
|
|
2430
2433
|
...v(e)
|
|
2431
2434
|
});
|
|
2432
2435
|
}
|
|
2433
|
-
class
|
|
2436
|
+
class L extends _ {
|
|
2434
2437
|
constructor() {
|
|
2435
|
-
super(...arguments),
|
|
2438
|
+
super(...arguments), ee.set(this, void 0);
|
|
2436
2439
|
}
|
|
2437
2440
|
_parse(e) {
|
|
2438
2441
|
if (typeof e.data != "string") {
|
|
2439
2442
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2440
2443
|
return f(t, {
|
|
2441
|
-
expected:
|
|
2444
|
+
expected: x.joinValues(n),
|
|
2442
2445
|
received: t.parsedType,
|
|
2443
|
-
code:
|
|
2446
|
+
code: u.invalid_type
|
|
2444
2447
|
}), g;
|
|
2445
2448
|
}
|
|
2446
|
-
if (
|
|
2449
|
+
if (_e(this, ee) || Ve(this, ee, new Set(this._def.values)), !_e(this, ee).has(e.data)) {
|
|
2447
2450
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2448
2451
|
return f(t, {
|
|
2449
2452
|
received: t.data,
|
|
2450
|
-
code:
|
|
2453
|
+
code: u.invalid_enum_value,
|
|
2451
2454
|
options: n
|
|
2452
2455
|
}), g;
|
|
2453
2456
|
}
|
|
2454
|
-
return
|
|
2457
|
+
return I(e.data);
|
|
2455
2458
|
}
|
|
2456
2459
|
get options() {
|
|
2457
2460
|
return this._def.values;
|
|
@@ -2475,55 +2478,55 @@ class z extends _ {
|
|
|
2475
2478
|
return e;
|
|
2476
2479
|
}
|
|
2477
2480
|
extract(e, t = this._def) {
|
|
2478
|
-
return
|
|
2481
|
+
return L.create(e, {
|
|
2479
2482
|
...this._def,
|
|
2480
2483
|
...t
|
|
2481
2484
|
});
|
|
2482
2485
|
}
|
|
2483
2486
|
exclude(e, t = this._def) {
|
|
2484
|
-
return
|
|
2487
|
+
return L.create(this.options.filter((n) => !e.includes(n)), {
|
|
2485
2488
|
...this._def,
|
|
2486
2489
|
...t
|
|
2487
2490
|
});
|
|
2488
2491
|
}
|
|
2489
2492
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
class
|
|
2493
|
+
ee = /* @__PURE__ */ new WeakMap();
|
|
2494
|
+
L.create = Ue;
|
|
2495
|
+
class fe extends _ {
|
|
2493
2496
|
constructor() {
|
|
2494
|
-
super(...arguments),
|
|
2497
|
+
super(...arguments), te.set(this, void 0);
|
|
2495
2498
|
}
|
|
2496
2499
|
_parse(e) {
|
|
2497
|
-
const t =
|
|
2500
|
+
const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
2498
2501
|
if (n.parsedType !== h.string && n.parsedType !== h.number) {
|
|
2499
|
-
const s =
|
|
2502
|
+
const s = x.objectValues(t);
|
|
2500
2503
|
return f(n, {
|
|
2501
|
-
expected:
|
|
2504
|
+
expected: x.joinValues(s),
|
|
2502
2505
|
received: n.parsedType,
|
|
2503
|
-
code:
|
|
2506
|
+
code: u.invalid_type
|
|
2504
2507
|
}), g;
|
|
2505
2508
|
}
|
|
2506
|
-
if (
|
|
2507
|
-
const s =
|
|
2509
|
+
if (_e(this, te) || Ve(this, te, new Set(x.getValidEnumValues(this._def.values))), !_e(this, te).has(e.data)) {
|
|
2510
|
+
const s = x.objectValues(t);
|
|
2508
2511
|
return f(n, {
|
|
2509
2512
|
received: n.data,
|
|
2510
|
-
code:
|
|
2513
|
+
code: u.invalid_enum_value,
|
|
2511
2514
|
options: s
|
|
2512
2515
|
}), g;
|
|
2513
2516
|
}
|
|
2514
|
-
return
|
|
2517
|
+
return I(e.data);
|
|
2515
2518
|
}
|
|
2516
2519
|
get enum() {
|
|
2517
2520
|
return this._def.values;
|
|
2518
2521
|
}
|
|
2519
2522
|
}
|
|
2520
|
-
|
|
2521
|
-
|
|
2523
|
+
te = /* @__PURE__ */ new WeakMap();
|
|
2524
|
+
fe.create = (r, e) => new fe({
|
|
2522
2525
|
values: r,
|
|
2523
2526
|
typeName: y.ZodNativeEnum,
|
|
2524
2527
|
...v(e)
|
|
2525
2528
|
});
|
|
2526
|
-
class
|
|
2529
|
+
class X extends _ {
|
|
2527
2530
|
unwrap() {
|
|
2528
2531
|
return this._def.type;
|
|
2529
2532
|
}
|
|
@@ -2531,23 +2534,23 @@ class K extends _ {
|
|
|
2531
2534
|
const { ctx: t } = this._processInputParams(e);
|
|
2532
2535
|
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
2533
2536
|
return f(t, {
|
|
2534
|
-
code:
|
|
2537
|
+
code: u.invalid_type,
|
|
2535
2538
|
expected: h.promise,
|
|
2536
2539
|
received: t.parsedType
|
|
2537
2540
|
}), g;
|
|
2538
2541
|
const n = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
2539
|
-
return
|
|
2542
|
+
return I(n.then((s) => this._def.type.parseAsync(s, {
|
|
2540
2543
|
path: t.path,
|
|
2541
2544
|
errorMap: t.common.contextualErrorMap
|
|
2542
2545
|
})));
|
|
2543
2546
|
}
|
|
2544
2547
|
}
|
|
2545
|
-
|
|
2548
|
+
X.create = (r, e) => new X({
|
|
2546
2549
|
type: r,
|
|
2547
2550
|
typeName: y.ZodPromise,
|
|
2548
2551
|
...v(e)
|
|
2549
2552
|
});
|
|
2550
|
-
class
|
|
2553
|
+
class O extends _ {
|
|
2551
2554
|
innerType() {
|
|
2552
2555
|
return this._def.schema;
|
|
2553
2556
|
}
|
|
@@ -2556,81 +2559,81 @@ class N extends _ {
|
|
|
2556
2559
|
}
|
|
2557
2560
|
_parse(e) {
|
|
2558
2561
|
const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
2559
|
-
addIssue: (
|
|
2560
|
-
f(n,
|
|
2562
|
+
addIssue: (o) => {
|
|
2563
|
+
f(n, o), o.fatal ? t.abort() : t.dirty();
|
|
2561
2564
|
},
|
|
2562
2565
|
get path() {
|
|
2563
2566
|
return n.path;
|
|
2564
2567
|
}
|
|
2565
2568
|
};
|
|
2566
2569
|
if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
|
|
2567
|
-
const
|
|
2570
|
+
const o = s.transform(n.data, a);
|
|
2568
2571
|
if (n.common.async)
|
|
2569
|
-
return Promise.resolve(
|
|
2572
|
+
return Promise.resolve(o).then(async (c) => {
|
|
2570
2573
|
if (t.value === "aborted")
|
|
2571
2574
|
return g;
|
|
2572
|
-
const
|
|
2573
|
-
data:
|
|
2575
|
+
const d = await this._def.schema._parseAsync({
|
|
2576
|
+
data: c,
|
|
2574
2577
|
path: n.path,
|
|
2575
2578
|
parent: n
|
|
2576
2579
|
});
|
|
2577
|
-
return
|
|
2580
|
+
return d.status === "aborted" ? g : d.status === "dirty" || t.value === "dirty" ? J(d.value) : d;
|
|
2578
2581
|
});
|
|
2579
2582
|
{
|
|
2580
2583
|
if (t.value === "aborted")
|
|
2581
2584
|
return g;
|
|
2582
|
-
const
|
|
2583
|
-
data:
|
|
2585
|
+
const c = this._def.schema._parseSync({
|
|
2586
|
+
data: o,
|
|
2584
2587
|
path: n.path,
|
|
2585
2588
|
parent: n
|
|
2586
2589
|
});
|
|
2587
|
-
return
|
|
2590
|
+
return c.status === "aborted" ? g : c.status === "dirty" || t.value === "dirty" ? J(c.value) : c;
|
|
2588
2591
|
}
|
|
2589
2592
|
}
|
|
2590
2593
|
if (s.type === "refinement") {
|
|
2591
|
-
const
|
|
2592
|
-
const
|
|
2594
|
+
const o = (c) => {
|
|
2595
|
+
const d = s.refinement(c, a);
|
|
2593
2596
|
if (n.common.async)
|
|
2594
|
-
return Promise.resolve(
|
|
2595
|
-
if (
|
|
2597
|
+
return Promise.resolve(d);
|
|
2598
|
+
if (d instanceof Promise)
|
|
2596
2599
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2597
|
-
return
|
|
2600
|
+
return c;
|
|
2598
2601
|
};
|
|
2599
2602
|
if (n.common.async === !1) {
|
|
2600
|
-
const
|
|
2603
|
+
const c = this._def.schema._parseSync({
|
|
2601
2604
|
data: n.data,
|
|
2602
2605
|
path: n.path,
|
|
2603
2606
|
parent: n
|
|
2604
2607
|
});
|
|
2605
|
-
return
|
|
2608
|
+
return c.status === "aborted" ? g : (c.status === "dirty" && t.dirty(), o(c.value), { status: t.value, value: c.value });
|
|
2606
2609
|
} else
|
|
2607
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((
|
|
2610
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((c) => c.status === "aborted" ? g : (c.status === "dirty" && t.dirty(), o(c.value).then(() => ({ status: t.value, value: c.value }))));
|
|
2608
2611
|
}
|
|
2609
2612
|
if (s.type === "transform")
|
|
2610
2613
|
if (n.common.async === !1) {
|
|
2611
|
-
const
|
|
2614
|
+
const o = this._def.schema._parseSync({
|
|
2612
2615
|
data: n.data,
|
|
2613
2616
|
path: n.path,
|
|
2614
2617
|
parent: n
|
|
2615
2618
|
});
|
|
2616
|
-
if (!B(
|
|
2617
|
-
return
|
|
2618
|
-
const
|
|
2619
|
-
if (
|
|
2619
|
+
if (!B(o))
|
|
2620
|
+
return o;
|
|
2621
|
+
const c = s.transform(o.value, a);
|
|
2622
|
+
if (c instanceof Promise)
|
|
2620
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2621
|
-
return { status: t.value, value:
|
|
2624
|
+
return { status: t.value, value: c };
|
|
2622
2625
|
} else
|
|
2623
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((
|
|
2624
|
-
|
|
2626
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => B(o) ? Promise.resolve(s.transform(o.value, a)).then((c) => ({ status: t.value, value: c })) : o);
|
|
2627
|
+
x.assertNever(s);
|
|
2625
2628
|
}
|
|
2626
2629
|
}
|
|
2627
|
-
|
|
2630
|
+
O.create = (r, e, t) => new O({
|
|
2628
2631
|
schema: r,
|
|
2629
2632
|
typeName: y.ZodEffects,
|
|
2630
2633
|
effect: e,
|
|
2631
2634
|
...v(t)
|
|
2632
2635
|
});
|
|
2633
|
-
|
|
2636
|
+
O.createWithPreprocess = (r, e, t) => new O({
|
|
2634
2637
|
schema: e,
|
|
2635
2638
|
effect: { type: "preprocess", transform: r },
|
|
2636
2639
|
typeName: y.ZodEffects,
|
|
@@ -2638,7 +2641,7 @@ N.createWithPreprocess = (r, e, t) => new N({
|
|
|
2638
2641
|
});
|
|
2639
2642
|
class j extends _ {
|
|
2640
2643
|
_parse(e) {
|
|
2641
|
-
return this._getType(e) === h.undefined ?
|
|
2644
|
+
return this._getType(e) === h.undefined ? I(void 0) : this._def.innerType._parse(e);
|
|
2642
2645
|
}
|
|
2643
2646
|
unwrap() {
|
|
2644
2647
|
return this._def.innerType;
|
|
@@ -2649,20 +2652,20 @@ j.create = (r, e) => new j({
|
|
|
2649
2652
|
typeName: y.ZodOptional,
|
|
2650
2653
|
...v(e)
|
|
2651
2654
|
});
|
|
2652
|
-
class
|
|
2655
|
+
class z extends _ {
|
|
2653
2656
|
_parse(e) {
|
|
2654
|
-
return this._getType(e) === h.null ?
|
|
2657
|
+
return this._getType(e) === h.null ? I(null) : this._def.innerType._parse(e);
|
|
2655
2658
|
}
|
|
2656
2659
|
unwrap() {
|
|
2657
2660
|
return this._def.innerType;
|
|
2658
2661
|
}
|
|
2659
2662
|
}
|
|
2660
|
-
|
|
2663
|
+
z.create = (r, e) => new z({
|
|
2661
2664
|
innerType: r,
|
|
2662
2665
|
typeName: y.ZodNullable,
|
|
2663
2666
|
...v(e)
|
|
2664
2667
|
});
|
|
2665
|
-
class
|
|
2668
|
+
class he extends _ {
|
|
2666
2669
|
_parse(e) {
|
|
2667
2670
|
const { ctx: t } = this._processInputParams(e);
|
|
2668
2671
|
let n = t.data;
|
|
@@ -2676,7 +2679,7 @@ class pe extends _ {
|
|
|
2676
2679
|
return this._def.innerType;
|
|
2677
2680
|
}
|
|
2678
2681
|
}
|
|
2679
|
-
|
|
2682
|
+
he.create = (r, e) => new he({
|
|
2680
2683
|
innerType: r,
|
|
2681
2684
|
typeName: y.ZodDefault,
|
|
2682
2685
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
@@ -2697,11 +2700,11 @@ class me extends _ {
|
|
|
2697
2700
|
...n
|
|
2698
2701
|
}
|
|
2699
2702
|
});
|
|
2700
|
-
return
|
|
2703
|
+
return ne(s) ? s.then((a) => ({
|
|
2701
2704
|
status: "valid",
|
|
2702
2705
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2703
2706
|
get error() {
|
|
2704
|
-
return new
|
|
2707
|
+
return new A(n.common.issues);
|
|
2705
2708
|
},
|
|
2706
2709
|
input: n.data
|
|
2707
2710
|
})
|
|
@@ -2709,7 +2712,7 @@ class me extends _ {
|
|
|
2709
2712
|
status: "valid",
|
|
2710
2713
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2711
2714
|
get error() {
|
|
2712
|
-
return new
|
|
2715
|
+
return new A(n.common.issues);
|
|
2713
2716
|
},
|
|
2714
2717
|
input: n.data
|
|
2715
2718
|
})
|
|
@@ -2725,12 +2728,12 @@ me.create = (r, e) => new me({
|
|
|
2725
2728
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2726
2729
|
...v(e)
|
|
2727
2730
|
});
|
|
2728
|
-
class
|
|
2731
|
+
class we extends _ {
|
|
2729
2732
|
_parse(e) {
|
|
2730
2733
|
if (this._getType(e) !== h.nan) {
|
|
2731
2734
|
const n = this._getOrReturnCtx(e);
|
|
2732
2735
|
return f(n, {
|
|
2733
|
-
code:
|
|
2736
|
+
code: u.invalid_type,
|
|
2734
2737
|
expected: h.nan,
|
|
2735
2738
|
received: n.parsedType
|
|
2736
2739
|
}), g;
|
|
@@ -2738,12 +2741,12 @@ class Te extends _ {
|
|
|
2738
2741
|
return { status: "valid", value: e.data };
|
|
2739
2742
|
}
|
|
2740
2743
|
}
|
|
2741
|
-
|
|
2744
|
+
we.create = (r) => new we({
|
|
2742
2745
|
typeName: y.ZodNaN,
|
|
2743
2746
|
...v(r)
|
|
2744
2747
|
});
|
|
2745
2748
|
const At = Symbol("zod_brand");
|
|
2746
|
-
class
|
|
2749
|
+
class je extends _ {
|
|
2747
2750
|
_parse(e) {
|
|
2748
2751
|
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
2749
2752
|
return this._def.type._parse({
|
|
@@ -2756,7 +2759,7 @@ class Re extends _ {
|
|
|
2756
2759
|
return this._def.type;
|
|
2757
2760
|
}
|
|
2758
2761
|
}
|
|
2759
|
-
class
|
|
2762
|
+
class ye extends _ {
|
|
2760
2763
|
_parse(e) {
|
|
2761
2764
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2762
2765
|
if (n.common.async)
|
|
@@ -2766,7 +2769,7 @@ class ge extends _ {
|
|
|
2766
2769
|
path: n.path,
|
|
2767
2770
|
parent: n
|
|
2768
2771
|
});
|
|
2769
|
-
return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(),
|
|
2772
|
+
return a.status === "aborted" ? g : a.status === "dirty" ? (t.dirty(), J(a.value)) : this._def.out._parseAsync({
|
|
2770
2773
|
data: a.value,
|
|
2771
2774
|
path: n.path,
|
|
2772
2775
|
parent: n
|
|
@@ -2789,185 +2792,185 @@ class ge extends _ {
|
|
|
2789
2792
|
}
|
|
2790
2793
|
}
|
|
2791
2794
|
static create(e, t) {
|
|
2792
|
-
return new
|
|
2795
|
+
return new ye({
|
|
2793
2796
|
in: e,
|
|
2794
2797
|
out: t,
|
|
2795
2798
|
typeName: y.ZodPipeline
|
|
2796
2799
|
});
|
|
2797
2800
|
}
|
|
2798
2801
|
}
|
|
2799
|
-
class
|
|
2802
|
+
class pe extends _ {
|
|
2800
2803
|
_parse(e) {
|
|
2801
2804
|
const t = this._def.innerType._parse(e), n = (s) => (B(s) && (s.value = Object.freeze(s.value)), s);
|
|
2802
|
-
return
|
|
2805
|
+
return ne(t) ? t.then((s) => n(s)) : n(t);
|
|
2803
2806
|
}
|
|
2804
2807
|
unwrap() {
|
|
2805
2808
|
return this._def.innerType;
|
|
2806
2809
|
}
|
|
2807
2810
|
}
|
|
2808
|
-
|
|
2811
|
+
pe.create = (r, e) => new pe({
|
|
2809
2812
|
innerType: r,
|
|
2810
2813
|
typeName: y.ZodReadonly,
|
|
2811
2814
|
...v(e)
|
|
2812
2815
|
});
|
|
2813
|
-
function
|
|
2816
|
+
function De(r, e) {
|
|
2814
2817
|
const t = typeof r == "function" ? r(e) : typeof r == "string" ? { message: r } : r;
|
|
2815
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2816
2819
|
}
|
|
2817
|
-
function
|
|
2818
|
-
return r ?
|
|
2819
|
-
var a,
|
|
2820
|
-
const
|
|
2821
|
-
if (
|
|
2822
|
-
return
|
|
2823
|
-
var
|
|
2824
|
-
if (!
|
|
2825
|
-
const
|
|
2826
|
-
s.addIssue({ code: "custom", ...
|
|
2820
|
+
function Be(r, e = {}, t) {
|
|
2821
|
+
return r ? G.create().superRefine((n, s) => {
|
|
2822
|
+
var a, o;
|
|
2823
|
+
const c = r(n);
|
|
2824
|
+
if (c instanceof Promise)
|
|
2825
|
+
return c.then((d) => {
|
|
2826
|
+
var l, m;
|
|
2827
|
+
if (!d) {
|
|
2828
|
+
const b = De(e, n), w = (m = (l = b.fatal) !== null && l !== void 0 ? l : t) !== null && m !== void 0 ? m : !0;
|
|
2829
|
+
s.addIssue({ code: "custom", ...b, fatal: w });
|
|
2827
2830
|
}
|
|
2828
2831
|
});
|
|
2829
|
-
if (!
|
|
2830
|
-
const
|
|
2831
|
-
s.addIssue({ code: "custom", ...
|
|
2832
|
+
if (!c) {
|
|
2833
|
+
const d = De(e, n), l = (o = (a = d.fatal) !== null && a !== void 0 ? a : t) !== null && o !== void 0 ? o : !0;
|
|
2834
|
+
s.addIssue({ code: "custom", ...d, fatal: l });
|
|
2832
2835
|
}
|
|
2833
|
-
}) :
|
|
2836
|
+
}) : G.create();
|
|
2834
2837
|
}
|
|
2835
|
-
const
|
|
2838
|
+
const Ct = {
|
|
2836
2839
|
object: k.lazycreate
|
|
2837
2840
|
};
|
|
2838
2841
|
var y;
|
|
2839
2842
|
(function(r) {
|
|
2840
2843
|
r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
|
|
2841
2844
|
})(y || (y = {}));
|
|
2842
|
-
const
|
|
2845
|
+
const Nt = (r, e = {
|
|
2843
2846
|
message: `Input not instance of ${r.name}`
|
|
2844
|
-
}) =>
|
|
2845
|
-
string: (r) =>
|
|
2847
|
+
}) => Be((t) => t instanceof r, e), We = N.create, qe = V.create, Zt = we.create, Ot = F.create, Qe = se.create, jt = W.create, Et = be.create, Rt = ae.create, Pt = ie.create, Dt = G.create, Mt = U.create, $t = $.create, Vt = xe.create, Ft = Z.create, Lt = k.create, zt = k.strictCreate, Ut = oe.create, Bt = Te.create, Wt = ce.create, qt = R.create, Qt = de.create, Jt = ke.create, Yt = q.create, Ht = Y.create, Gt = ue.create, Xt = le.create, Kt = L.create, er = fe.create, tr = X.create, Me = O.create, rr = j.create, nr = z.create, sr = O.createWithPreprocess, ar = ye.create, ir = () => We().optional(), or = () => qe().optional(), cr = () => Qe().optional(), dr = {
|
|
2848
|
+
string: (r) => N.create({ ...r, coerce: !0 }),
|
|
2846
2849
|
number: (r) => V.create({ ...r, coerce: !0 }),
|
|
2847
|
-
boolean: (r) =>
|
|
2850
|
+
boolean: (r) => se.create({
|
|
2848
2851
|
...r,
|
|
2849
2852
|
coerce: !0
|
|
2850
2853
|
}),
|
|
2851
|
-
bigint: (r) =>
|
|
2852
|
-
date: (r) =>
|
|
2853
|
-
},
|
|
2854
|
+
bigint: (r) => F.create({ ...r, coerce: !0 }),
|
|
2855
|
+
date: (r) => W.create({ ...r, coerce: !0 })
|
|
2856
|
+
}, ur = g;
|
|
2854
2857
|
var i = /* @__PURE__ */ Object.freeze({
|
|
2855
2858
|
__proto__: null,
|
|
2856
|
-
defaultErrorMap:
|
|
2857
|
-
setErrorMap:
|
|
2858
|
-
getErrorMap:
|
|
2859
|
-
makeIssue:
|
|
2860
|
-
EMPTY_PATH:
|
|
2859
|
+
defaultErrorMap: H,
|
|
2860
|
+
setErrorMap: st,
|
|
2861
|
+
getErrorMap: ge,
|
|
2862
|
+
makeIssue: ve,
|
|
2863
|
+
EMPTY_PATH: at,
|
|
2861
2864
|
addIssueToContext: f,
|
|
2862
2865
|
ParseStatus: T,
|
|
2863
2866
|
INVALID: g,
|
|
2864
|
-
DIRTY:
|
|
2865
|
-
OK:
|
|
2866
|
-
isAborted:
|
|
2867
|
-
isDirty:
|
|
2867
|
+
DIRTY: J,
|
|
2868
|
+
OK: I,
|
|
2869
|
+
isAborted: Ne,
|
|
2870
|
+
isDirty: Ze,
|
|
2868
2871
|
isValid: B,
|
|
2869
|
-
isAsync:
|
|
2872
|
+
isAsync: ne,
|
|
2870
2873
|
get util() {
|
|
2871
|
-
return
|
|
2874
|
+
return x;
|
|
2872
2875
|
},
|
|
2873
2876
|
get objectUtil() {
|
|
2874
|
-
return
|
|
2877
|
+
return Ce;
|
|
2875
2878
|
},
|
|
2876
2879
|
ZodParsedType: h,
|
|
2877
|
-
getParsedType:
|
|
2880
|
+
getParsedType: D,
|
|
2878
2881
|
ZodType: _,
|
|
2879
|
-
datetimeRegex:
|
|
2880
|
-
ZodString:
|
|
2882
|
+
datetimeRegex: ze,
|
|
2883
|
+
ZodString: N,
|
|
2881
2884
|
ZodNumber: V,
|
|
2882
|
-
ZodBigInt:
|
|
2883
|
-
ZodBoolean:
|
|
2884
|
-
ZodDate:
|
|
2885
|
-
ZodSymbol:
|
|
2886
|
-
ZodUndefined:
|
|
2887
|
-
ZodNull:
|
|
2888
|
-
ZodAny:
|
|
2885
|
+
ZodBigInt: F,
|
|
2886
|
+
ZodBoolean: se,
|
|
2887
|
+
ZodDate: W,
|
|
2888
|
+
ZodSymbol: be,
|
|
2889
|
+
ZodUndefined: ae,
|
|
2890
|
+
ZodNull: ie,
|
|
2891
|
+
ZodAny: G,
|
|
2889
2892
|
ZodUnknown: U,
|
|
2890
|
-
ZodNever:
|
|
2891
|
-
ZodVoid:
|
|
2892
|
-
ZodArray:
|
|
2893
|
+
ZodNever: $,
|
|
2894
|
+
ZodVoid: xe,
|
|
2895
|
+
ZodArray: Z,
|
|
2893
2896
|
ZodObject: k,
|
|
2894
|
-
ZodUnion:
|
|
2895
|
-
ZodDiscriminatedUnion:
|
|
2896
|
-
ZodIntersection:
|
|
2897
|
+
ZodUnion: oe,
|
|
2898
|
+
ZodDiscriminatedUnion: Te,
|
|
2899
|
+
ZodIntersection: ce,
|
|
2897
2900
|
ZodTuple: R,
|
|
2898
|
-
ZodRecord:
|
|
2899
|
-
ZodMap:
|
|
2900
|
-
ZodSet:
|
|
2901
|
-
ZodFunction:
|
|
2902
|
-
ZodLazy:
|
|
2903
|
-
ZodLiteral:
|
|
2904
|
-
ZodEnum:
|
|
2905
|
-
ZodNativeEnum:
|
|
2906
|
-
ZodPromise:
|
|
2907
|
-
ZodEffects:
|
|
2908
|
-
ZodTransformer:
|
|
2901
|
+
ZodRecord: de,
|
|
2902
|
+
ZodMap: ke,
|
|
2903
|
+
ZodSet: q,
|
|
2904
|
+
ZodFunction: Y,
|
|
2905
|
+
ZodLazy: ue,
|
|
2906
|
+
ZodLiteral: le,
|
|
2907
|
+
ZodEnum: L,
|
|
2908
|
+
ZodNativeEnum: fe,
|
|
2909
|
+
ZodPromise: X,
|
|
2910
|
+
ZodEffects: O,
|
|
2911
|
+
ZodTransformer: O,
|
|
2909
2912
|
ZodOptional: j,
|
|
2910
|
-
ZodNullable:
|
|
2911
|
-
ZodDefault:
|
|
2913
|
+
ZodNullable: z,
|
|
2914
|
+
ZodDefault: he,
|
|
2912
2915
|
ZodCatch: me,
|
|
2913
|
-
ZodNaN:
|
|
2916
|
+
ZodNaN: we,
|
|
2914
2917
|
BRAND: At,
|
|
2915
|
-
ZodBranded:
|
|
2916
|
-
ZodPipeline:
|
|
2917
|
-
ZodReadonly:
|
|
2918
|
-
custom:
|
|
2918
|
+
ZodBranded: je,
|
|
2919
|
+
ZodPipeline: ye,
|
|
2920
|
+
ZodReadonly: pe,
|
|
2921
|
+
custom: Be,
|
|
2919
2922
|
Schema: _,
|
|
2920
2923
|
ZodSchema: _,
|
|
2921
|
-
late:
|
|
2924
|
+
late: Ct,
|
|
2922
2925
|
get ZodFirstPartyTypeKind() {
|
|
2923
2926
|
return y;
|
|
2924
2927
|
},
|
|
2925
|
-
coerce:
|
|
2926
|
-
any:
|
|
2928
|
+
coerce: dr,
|
|
2929
|
+
any: Dt,
|
|
2927
2930
|
array: Ft,
|
|
2928
|
-
bigint:
|
|
2929
|
-
boolean:
|
|
2930
|
-
date:
|
|
2931
|
-
discriminatedUnion:
|
|
2932
|
-
effect:
|
|
2933
|
-
enum:
|
|
2934
|
-
function:
|
|
2935
|
-
instanceof:
|
|
2936
|
-
intersection:
|
|
2937
|
-
lazy:
|
|
2938
|
-
literal:
|
|
2939
|
-
map:
|
|
2940
|
-
nan:
|
|
2941
|
-
nativeEnum:
|
|
2942
|
-
never:
|
|
2943
|
-
null:
|
|
2944
|
-
nullable:
|
|
2945
|
-
number:
|
|
2946
|
-
object:
|
|
2947
|
-
oboolean:
|
|
2948
|
-
onumber:
|
|
2949
|
-
optional:
|
|
2950
|
-
ostring:
|
|
2951
|
-
pipeline:
|
|
2952
|
-
preprocess:
|
|
2953
|
-
promise:
|
|
2931
|
+
bigint: Ot,
|
|
2932
|
+
boolean: Qe,
|
|
2933
|
+
date: jt,
|
|
2934
|
+
discriminatedUnion: Bt,
|
|
2935
|
+
effect: Me,
|
|
2936
|
+
enum: Kt,
|
|
2937
|
+
function: Ht,
|
|
2938
|
+
instanceof: Nt,
|
|
2939
|
+
intersection: Wt,
|
|
2940
|
+
lazy: Gt,
|
|
2941
|
+
literal: Xt,
|
|
2942
|
+
map: Jt,
|
|
2943
|
+
nan: Zt,
|
|
2944
|
+
nativeEnum: er,
|
|
2945
|
+
never: $t,
|
|
2946
|
+
null: Pt,
|
|
2947
|
+
nullable: nr,
|
|
2948
|
+
number: qe,
|
|
2949
|
+
object: Lt,
|
|
2950
|
+
oboolean: cr,
|
|
2951
|
+
onumber: or,
|
|
2952
|
+
optional: rr,
|
|
2953
|
+
ostring: ir,
|
|
2954
|
+
pipeline: ar,
|
|
2955
|
+
preprocess: sr,
|
|
2956
|
+
promise: tr,
|
|
2954
2957
|
record: Qt,
|
|
2955
|
-
set:
|
|
2956
|
-
strictObject:
|
|
2957
|
-
string:
|
|
2958
|
-
symbol:
|
|
2959
|
-
transformer:
|
|
2960
|
-
tuple:
|
|
2961
|
-
undefined:
|
|
2962
|
-
union:
|
|
2963
|
-
unknown:
|
|
2964
|
-
void:
|
|
2965
|
-
NEVER:
|
|
2966
|
-
ZodIssueCode:
|
|
2967
|
-
quotelessJson:
|
|
2968
|
-
ZodError:
|
|
2958
|
+
set: Yt,
|
|
2959
|
+
strictObject: zt,
|
|
2960
|
+
string: We,
|
|
2961
|
+
symbol: Et,
|
|
2962
|
+
transformer: Me,
|
|
2963
|
+
tuple: qt,
|
|
2964
|
+
undefined: Rt,
|
|
2965
|
+
union: Ut,
|
|
2966
|
+
unknown: Mt,
|
|
2967
|
+
void: Vt,
|
|
2968
|
+
NEVER: ur,
|
|
2969
|
+
ZodIssueCode: u,
|
|
2970
|
+
quotelessJson: nt,
|
|
2971
|
+
ZodError: A
|
|
2969
2972
|
});
|
|
2970
|
-
const
|
|
2973
|
+
const lr = i.object({
|
|
2971
2974
|
country: i.string(),
|
|
2972
2975
|
city: i.string(),
|
|
2973
2976
|
street: i.string(),
|
|
@@ -2975,37 +2978,37 @@ const hr = i.object({
|
|
|
2975
2978
|
floor: i.string(),
|
|
2976
2979
|
apartmentEnterNumber: i.string(),
|
|
2977
2980
|
apartmentNumber: i.string()
|
|
2978
|
-
}),
|
|
2979
|
-
function
|
|
2981
|
+
}), M = i.string().min(1, { message: "שדה חובה" }), Tr = i.string().regex(/^\d+$/, "Must be a numeric string"), Ir = i.object({ url: i.string().url(), id: i.string() });
|
|
2982
|
+
function Sr(r) {
|
|
2980
2983
|
return !!(r != null && r.url);
|
|
2981
2984
|
}
|
|
2982
|
-
const
|
|
2985
|
+
const re = i.object({
|
|
2983
2986
|
lang: i.enum(["he"]),
|
|
2984
2987
|
value: i.string()
|
|
2985
|
-
}),
|
|
2988
|
+
}), Ar = i.array(re), Je = i.object({
|
|
2986
2989
|
id: i.string().min(1),
|
|
2987
2990
|
companyId: i.string().min(1),
|
|
2988
2991
|
storeId: i.string().min(1),
|
|
2989
2992
|
parentId: i.string().nullish(),
|
|
2990
2993
|
tag: i.string().optional(),
|
|
2991
|
-
locales: i.array(
|
|
2994
|
+
locales: i.array(re),
|
|
2992
2995
|
depth: i.number()
|
|
2993
|
-
}),
|
|
2994
|
-
children: i.lazy(() =>
|
|
2995
|
-
}),
|
|
2996
|
+
}), Ee = Je.extend({
|
|
2997
|
+
children: i.lazy(() => Ee.array())
|
|
2998
|
+
}), Cr = Je.extend({
|
|
2996
2999
|
index: i.number(),
|
|
2997
3000
|
depth: i.number(),
|
|
2998
3001
|
collapsed: i.boolean().optional(),
|
|
2999
|
-
children: i.array(
|
|
3000
|
-
}),
|
|
3002
|
+
children: i.array(Ee)
|
|
3003
|
+
}), K = i.string().min(1), Ye = i.object({
|
|
3001
3004
|
type: i.literal("Product"),
|
|
3002
|
-
storeId:
|
|
3003
|
-
companyId:
|
|
3004
|
-
id:
|
|
3005
|
-
objectID:
|
|
3006
|
-
sku:
|
|
3007
|
-
name: i.array(
|
|
3008
|
-
description: i.array(
|
|
3005
|
+
storeId: K,
|
|
3006
|
+
companyId: K,
|
|
3007
|
+
id: K,
|
|
3008
|
+
objectID: K,
|
|
3009
|
+
sku: K,
|
|
3010
|
+
name: i.array(re),
|
|
3011
|
+
description: i.array(re),
|
|
3009
3012
|
isPublished: i.boolean(),
|
|
3010
3013
|
vat: i.boolean(),
|
|
3011
3014
|
priceType: i.object({
|
|
@@ -3034,12 +3037,12 @@ const H = i.object({
|
|
|
3034
3037
|
brand: i.string(),
|
|
3035
3038
|
importer: i.string(),
|
|
3036
3039
|
supplier: i.string(),
|
|
3037
|
-
ingredients: i.array(
|
|
3040
|
+
ingredients: i.array(re),
|
|
3038
3041
|
created_at: i.number(),
|
|
3039
3042
|
updated_at: i.number(),
|
|
3040
3043
|
categoryIds: i.array(i.string().nonempty()),
|
|
3041
3044
|
// @deprecated
|
|
3042
|
-
categoryList: i.array(
|
|
3045
|
+
categoryList: i.array(Ee),
|
|
3043
3046
|
// @deprecated
|
|
3044
3047
|
categories: i.object({
|
|
3045
3048
|
lvl0: i.array(i.string()),
|
|
@@ -3050,51 +3053,51 @@ const H = i.object({
|
|
|
3050
3053
|
}),
|
|
3051
3054
|
// @deprecated
|
|
3052
3055
|
categoryNames: i.array(i.string())
|
|
3053
|
-
}),
|
|
3056
|
+
}), Nr = Ye.extend({
|
|
3054
3057
|
image: i.instanceof(File).optional()
|
|
3055
|
-
}),
|
|
3056
|
-
product:
|
|
3058
|
+
}), He = i.object({
|
|
3059
|
+
product: Ye,
|
|
3057
3060
|
originalPrice: i.number().optional(),
|
|
3058
3061
|
finalPrice: i.number().optional(),
|
|
3059
3062
|
finalDiscount: i.number().optional(),
|
|
3060
3063
|
amount: i.number().positive({ message: "Quantity must be a positive number." })
|
|
3061
|
-
}),
|
|
3064
|
+
}), Zr = i.object({
|
|
3062
3065
|
type: i.literal("Cart"),
|
|
3063
3066
|
id: i.string().uuid(),
|
|
3064
3067
|
companyId: i.string().uuid(),
|
|
3065
3068
|
storeId: i.string().uuid(),
|
|
3066
3069
|
userId: i.string().uuid(),
|
|
3067
3070
|
status: i.enum(["active", "draft", "completed"]),
|
|
3068
|
-
items: i.array(
|
|
3069
|
-
}),
|
|
3071
|
+
items: i.array(He)
|
|
3072
|
+
}), Or = i.object({
|
|
3070
3073
|
id: i.string(),
|
|
3071
3074
|
name: i.string(),
|
|
3072
3075
|
websiteDomains: i.array(i.string())
|
|
3073
|
-
}),
|
|
3076
|
+
}), jr = i.object({
|
|
3074
3077
|
type: i.literal("FavoriteProduct"),
|
|
3075
3078
|
id: i.string().uuid(),
|
|
3076
3079
|
companyId: i.string().uuid(),
|
|
3077
3080
|
storeId: i.string().uuid(),
|
|
3078
3081
|
userId: i.string().uuid(),
|
|
3079
3082
|
productId: i.string().uuid()
|
|
3080
|
-
}),
|
|
3083
|
+
}), Ge = i.enum(["default", "delayed"]), fr = i.object({
|
|
3081
3084
|
type: i.literal("Profile"),
|
|
3082
|
-
id:
|
|
3083
|
-
companyId:
|
|
3084
|
-
storeId:
|
|
3085
|
-
tenantId:
|
|
3085
|
+
id: M,
|
|
3086
|
+
companyId: M,
|
|
3087
|
+
storeId: M,
|
|
3088
|
+
tenantId: M,
|
|
3086
3089
|
clientType: i.enum(["user", "company"]),
|
|
3087
3090
|
companyName: i.string().optional(),
|
|
3088
|
-
displayName:
|
|
3091
|
+
displayName: M,
|
|
3089
3092
|
email: i.string().email(),
|
|
3090
3093
|
phoneNumber: i.string().optional(),
|
|
3091
|
-
address:
|
|
3094
|
+
address: lr.optional(),
|
|
3092
3095
|
isAnonymous: i.boolean(),
|
|
3093
3096
|
createdDate: i.number(),
|
|
3094
3097
|
lastActivityDate: i.number(),
|
|
3095
|
-
paymentType:
|
|
3098
|
+
paymentType: Ge
|
|
3096
3099
|
});
|
|
3097
|
-
function
|
|
3100
|
+
function Er() {
|
|
3098
3101
|
return {
|
|
3099
3102
|
type: "Profile",
|
|
3100
3103
|
id: "",
|
|
@@ -3117,15 +3120,15 @@ function Ar() {
|
|
|
3117
3120
|
createdDate: 0,
|
|
3118
3121
|
lastActivityDate: 0,
|
|
3119
3122
|
isAnonymous: !0,
|
|
3120
|
-
paymentType:
|
|
3123
|
+
paymentType: Ge.Values.default
|
|
3121
3124
|
};
|
|
3122
3125
|
}
|
|
3123
|
-
const
|
|
3126
|
+
const Rr = i.object({
|
|
3124
3127
|
type: i.literal("Order"),
|
|
3125
|
-
id:
|
|
3126
|
-
companyId:
|
|
3127
|
-
storeId:
|
|
3128
|
-
userId:
|
|
3128
|
+
id: M,
|
|
3129
|
+
companyId: M,
|
|
3130
|
+
storeId: M,
|
|
3131
|
+
userId: M,
|
|
3129
3132
|
status: i.enum([
|
|
3130
3133
|
"draft",
|
|
3131
3134
|
// before payment
|
|
@@ -3144,7 +3147,7 @@ const Nr = i.object({
|
|
|
3144
3147
|
//todo check if hyp support partial refund
|
|
3145
3148
|
cart: i.object({
|
|
3146
3149
|
id: i.string(),
|
|
3147
|
-
items: i.array(
|
|
3150
|
+
items: i.array(He),
|
|
3148
3151
|
cartDiscount: i.number(),
|
|
3149
3152
|
cartTotal: i.number(),
|
|
3150
3153
|
cartVat: i.number()
|
|
@@ -3155,10 +3158,10 @@ const Nr = i.object({
|
|
|
3155
3158
|
// what store charge
|
|
3156
3159
|
date: i.number(),
|
|
3157
3160
|
deliveryDate: i.coerce.number().optional(),
|
|
3158
|
-
client:
|
|
3161
|
+
client: fr.required({}),
|
|
3159
3162
|
nameOnInvoice: i.string().optional(),
|
|
3160
3163
|
clientComment: i.string().optional()
|
|
3161
|
-
}),
|
|
3164
|
+
}), hr = i.enum(["individual", "company"]), Pr = i.object({
|
|
3162
3165
|
id: i.string(),
|
|
3163
3166
|
companyId: i.string(),
|
|
3164
3167
|
name: i.string(),
|
|
@@ -3169,34 +3172,185 @@ const Nr = i.object({
|
|
|
3169
3172
|
paymentType: i.enum(["external", "j5"]),
|
|
3170
3173
|
allowAnonymousClients: i.boolean(),
|
|
3171
3174
|
isVatIncludedInPrice: i.boolean(),
|
|
3172
|
-
clientTypes: i.array(
|
|
3175
|
+
clientTypes: i.array(hr),
|
|
3173
3176
|
minimumOrder: i.number().optional(),
|
|
3174
3177
|
freeDeliveryPrice: i.number().optional(),
|
|
3175
3178
|
deliveryPrice: i.number().optional()
|
|
3176
|
-
}),
|
|
3179
|
+
}), mr = i.object({
|
|
3180
|
+
minSpend: i.number().positive().optional(),
|
|
3181
|
+
stackable: i.boolean().default(!1)
|
|
3182
|
+
}).optional(), pr = i.discriminatedUnion("variantType", [
|
|
3183
|
+
i.object({
|
|
3184
|
+
variantType: i.literal("bundle"),
|
|
3185
|
+
productsId: i.array(i.string()).min(1),
|
|
3186
|
+
// Which products are included
|
|
3187
|
+
requiredQuantity: i.number().positive(),
|
|
3188
|
+
// How many items needed (e.g., 3)
|
|
3189
|
+
bundlePrice: i.number().positive()
|
|
3190
|
+
// Total price for the bundle (e.g., $25)
|
|
3191
|
+
})
|
|
3192
|
+
]), Dr = i.object({
|
|
3177
3193
|
type: i.literal("Discount"),
|
|
3178
|
-
storeId:
|
|
3179
|
-
companyId:
|
|
3180
|
-
id:
|
|
3181
|
-
name: i.array(
|
|
3194
|
+
storeId: i.string().min(1),
|
|
3195
|
+
companyId: i.string().min(1),
|
|
3196
|
+
id: i.string().min(1),
|
|
3197
|
+
name: i.array(i.object({ lang: i.enum(["he"]), value: i.string() })),
|
|
3182
3198
|
active: i.boolean(),
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3199
|
+
startDate: i.number(),
|
|
3200
|
+
endDate: i.number(),
|
|
3201
|
+
variant: pr,
|
|
3202
|
+
conditions: mr
|
|
3203
|
+
});
|
|
3204
|
+
class yr {
|
|
3205
|
+
canApply(e, t) {
|
|
3206
|
+
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3207
|
+
const { productsId: n, requiredQuantity: s } = e.variant;
|
|
3208
|
+
return this.getTotalQuantity(t.cart, n) >= s;
|
|
3209
|
+
}
|
|
3210
|
+
calculate(e, t) {
|
|
3211
|
+
if (e.variant.variantType !== "bundle")
|
|
3212
|
+
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3213
|
+
const { productsId: n, requiredQuantity: s, bundlePrice: a } = e.variant, o = t.cart.filter((C) => n.includes(C.product.id)), c = this.getTotalQuantity(t.cart, n), d = Math.floor(c / s);
|
|
3214
|
+
if (d === 0)
|
|
3215
|
+
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3216
|
+
const l = this.calculateOriginalPrice(o), m = this.getTotalQuantity(t.cart, n), b = this.calculateDiscountedPrice(
|
|
3217
|
+
l,
|
|
3218
|
+
a,
|
|
3219
|
+
d,
|
|
3220
|
+
s,
|
|
3221
|
+
m
|
|
3222
|
+
), w = l - b, S = this.distributeDiscount(o, w, l);
|
|
3223
|
+
return {
|
|
3224
|
+
applicable: !0,
|
|
3225
|
+
discountAmount: Number(w.toFixed(2)),
|
|
3226
|
+
affectedItems: S
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
isDiscountActive(e) {
|
|
3230
|
+
const t = Date.now();
|
|
3231
|
+
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3232
|
+
}
|
|
3233
|
+
getTotalQuantity(e, t) {
|
|
3234
|
+
return e.filter((n) => t.includes(n.product.id)).reduce((n, s) => n + s.amount, 0);
|
|
3235
|
+
}
|
|
3236
|
+
calculateOriginalPrice(e) {
|
|
3237
|
+
return e.reduce((t, n) => t + n.product.price * n.amount, 0);
|
|
3238
|
+
}
|
|
3239
|
+
calculateDiscountedPrice(e, t, n, s, a) {
|
|
3240
|
+
const o = t * n, c = n * s, l = Math.max(0, a - c) / a * e;
|
|
3241
|
+
return o + l;
|
|
3242
|
+
}
|
|
3243
|
+
distributeDiscount(e, t, n) {
|
|
3244
|
+
const s = t / n;
|
|
3245
|
+
return e.map((a) => {
|
|
3246
|
+
const o = a.product.price * a.amount * s;
|
|
3247
|
+
return {
|
|
3248
|
+
productId: a.product.id,
|
|
3249
|
+
quantity: a.amount,
|
|
3250
|
+
originalPrice: Number(a.product.price.toFixed(2)),
|
|
3251
|
+
discountedPrice: Number((a.product.price - o / a.amount).toFixed(2)),
|
|
3252
|
+
discountAmount: Number(o.toFixed(2))
|
|
3253
|
+
};
|
|
3254
|
+
});
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
class Xe {
|
|
3258
|
+
static getStrategy(e) {
|
|
3259
|
+
return this.strategies.get(e.variant.variantType) || null;
|
|
3260
|
+
}
|
|
3261
|
+
static registerStrategy(e, t) {
|
|
3262
|
+
this.strategies.set(e, t);
|
|
3263
|
+
}
|
|
3264
|
+
static getRegisteredTypes() {
|
|
3265
|
+
return Array.from(this.strategies.keys());
|
|
3266
|
+
}
|
|
3267
|
+
static clearStrategies() {
|
|
3268
|
+
this.strategies.clear();
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
Re(Xe, "strategies", /* @__PURE__ */ new Map([
|
|
3272
|
+
["bundle", new yr()]
|
|
3273
|
+
]));
|
|
3274
|
+
class gr {
|
|
3275
|
+
static calculateDiscounts(e, t, n) {
|
|
3276
|
+
var l, m;
|
|
3277
|
+
const s = {
|
|
3278
|
+
cart: e,
|
|
3279
|
+
user: n,
|
|
3280
|
+
appliedDiscounts: []
|
|
3281
|
+
}, a = this.filterActiveDiscounts(t), o = [];
|
|
3282
|
+
for (const b of a) {
|
|
3283
|
+
const w = Xe.getStrategy(b);
|
|
3284
|
+
if (!w || !w.canApply(b, s) || !((l = b.conditions) != null && l.stackable) && o.length > 0) continue;
|
|
3285
|
+
const S = w.calculate(b, s);
|
|
3286
|
+
S.applicable && (o.push({
|
|
3287
|
+
discountId: b.id,
|
|
3288
|
+
discountName: ((m = b.name[0]) == null ? void 0 : m.value) || "Discount",
|
|
3289
|
+
discountAmount: Number(S.discountAmount.toFixed(2)),
|
|
3290
|
+
affectedItems: S.affectedItems
|
|
3291
|
+
}), s.appliedDiscounts = o);
|
|
3292
|
+
}
|
|
3293
|
+
const c = this.calculateFinalPrices(e, o), d = o.reduce((b, w) => b + w.discountAmount, 0);
|
|
3294
|
+
return {
|
|
3295
|
+
items: c,
|
|
3296
|
+
totalDiscount: Number(d.toFixed(2)),
|
|
3297
|
+
appliedDiscounts: o
|
|
3298
|
+
};
|
|
3299
|
+
}
|
|
3300
|
+
static filterActiveDiscounts(e) {
|
|
3301
|
+
const t = Date.now();
|
|
3302
|
+
return e.filter(
|
|
3303
|
+
(n) => n.active && n.startDate <= t && n.endDate >= t
|
|
3304
|
+
);
|
|
3305
|
+
}
|
|
3306
|
+
static calculateFinalPrices(e, t) {
|
|
3307
|
+
return e.map((n) => {
|
|
3308
|
+
const s = t.filter(
|
|
3309
|
+
(d) => d.affectedItems.some((l) => l.productId === n.product.id)
|
|
3310
|
+
), a = s.reduce((d, l) => {
|
|
3311
|
+
const m = l.affectedItems.find((b) => b.productId === n.product.id);
|
|
3312
|
+
return d + ((m == null ? void 0 : m.discountAmount) || 0);
|
|
3313
|
+
}, 0), o = a / n.amount, c = n.product.price - o;
|
|
3314
|
+
return {
|
|
3315
|
+
amount: n.amount,
|
|
3316
|
+
product: n.product,
|
|
3317
|
+
originalPrice: Number(n.product.price.toFixed(2)),
|
|
3318
|
+
finalPrice: Number(Math.max(0, c).toFixed(2)),
|
|
3319
|
+
finalDiscount: Number(a.toFixed(2)),
|
|
3320
|
+
appliedDiscounts: s.map((d) => d.discountId)
|
|
3321
|
+
};
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
static isDiscountActive(e) {
|
|
3325
|
+
const t = Date.now();
|
|
3326
|
+
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3327
|
+
}
|
|
3328
|
+
static getActiveDiscounts(e) {
|
|
3329
|
+
return this.filterActiveDiscounts(e);
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
function Ke(r) {
|
|
3333
|
+
return Number(r.toFixed(2));
|
|
3334
|
+
}
|
|
3335
|
+
function Mr(r) {
|
|
3336
|
+
return r.toFixed(2);
|
|
3337
|
+
}
|
|
3338
|
+
function $r(r) {
|
|
3339
|
+
return Math.max(0, Ke(r));
|
|
3340
|
+
}
|
|
3341
|
+
function Vr(r, e) {
|
|
3342
|
+
if (r <= 0) return 0;
|
|
3343
|
+
const t = r - e;
|
|
3344
|
+
return Ke(t / r * 100);
|
|
3345
|
+
}
|
|
3346
|
+
const Ae = {
|
|
3193
3347
|
VAT: 18
|
|
3194
3348
|
};
|
|
3195
|
-
function
|
|
3349
|
+
function vr(r) {
|
|
3196
3350
|
var e, t;
|
|
3197
3351
|
return ((e = r.discount) == null ? void 0 : e.type) === "percent" ? r.price * (r.discount.value ?? 100) / 100 : ((t = r.discount) == null ? void 0 : t.type) === "number" ? r.discount.value ?? 0 : 0;
|
|
3198
3352
|
}
|
|
3199
|
-
function
|
|
3353
|
+
function _r(r) {
|
|
3200
3354
|
var e, t;
|
|
3201
3355
|
if (((e = r.discount) == null ? void 0 : e.type) === "percent") {
|
|
3202
3356
|
const n = r.price * r.discount.value / 100;
|
|
@@ -3204,55 +3358,40 @@ function Fe(r) {
|
|
|
3204
3358
|
}
|
|
3205
3359
|
return ((t = r.discount) == null ? void 0 : t.type) === "number" ? r.price - r.discount.value : r.price;
|
|
3206
3360
|
}
|
|
3207
|
-
function
|
|
3361
|
+
function Fr({
|
|
3208
3362
|
cart: r,
|
|
3209
3363
|
discounts: e,
|
|
3210
3364
|
store: t
|
|
3211
3365
|
}) {
|
|
3212
|
-
const { isVatIncludedInPrice: n } = t
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
finalPrice: Fe(o.product),
|
|
3218
|
-
finalDiscount: ze(o.product)
|
|
3219
|
-
}));
|
|
3220
|
-
const a = e.filter((o) => o.variant.variantType === "bundle" && ((r == null ? void 0 : r.reduce((u, p) => (o.variant.productsId.includes(p.product.id) && (u += p.amount), u), 0)) ?? 0) >= o.variant.requiredQuantity);
|
|
3221
|
-
console.log("activeDiscounts", a), a.forEach((o) => {
|
|
3222
|
-
var l, u;
|
|
3223
|
-
if (o.variant.variantType === "bundle") {
|
|
3224
|
-
const p = r.filter(
|
|
3225
|
-
(Z) => o.variant.productsId.includes(Z.product.id)
|
|
3226
|
-
), x = (p == null ? void 0 : p.reduce((Z, De) => (o.variant.productsId.includes(De.product.id) && (Z += De.amount), Z), 0)) ?? 0, O = Math.floor(x / o.variant.requiredQuantity), w = Fe((l = p[0]) == null ? void 0 : l.product), ee = ze((u = p[0]) == null ? void 0 : u.product);
|
|
3227
|
-
console.log("price", w, ee);
|
|
3228
|
-
const Ce = Number(
|
|
3229
|
-
(o.variant.discountPrice / o.variant.requiredQuantity).toFixed(2)
|
|
3230
|
-
) * 1;
|
|
3231
|
-
console.log("discountPrice", Ce);
|
|
3232
|
-
const nt = (w * o.variant.requiredQuantity - o.variant.discountPrice) * O, st = x * w - nt, $e = Number((st / x).toFixed(2));
|
|
3233
|
-
s = s.map((Z) => o.variant.productsId.includes(Z.product.id) ? {
|
|
3234
|
-
...Z,
|
|
3235
|
-
finalPrice: $e,
|
|
3236
|
-
originalPrice: Z.product.price,
|
|
3237
|
-
discountPrice: w,
|
|
3238
|
-
finalDiscount: Z.finalDiscount + (Z.product.price - $e)
|
|
3239
|
-
} : Z);
|
|
3366
|
+
const { isVatIncludedInPrice: n } = t, s = r.map((d) => ({
|
|
3367
|
+
amount: d.amount,
|
|
3368
|
+
product: {
|
|
3369
|
+
id: d.product.id,
|
|
3370
|
+
price: d.product.price
|
|
3240
3371
|
}
|
|
3241
|
-
})
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3372
|
+
})), a = gr.calculateDiscounts(s, e), o = r.map((d, l) => {
|
|
3373
|
+
const m = a.items[l];
|
|
3374
|
+
return {
|
|
3375
|
+
amount: d.amount,
|
|
3376
|
+
product: { ...d.product },
|
|
3377
|
+
originalPrice: d.product.price,
|
|
3378
|
+
finalPrice: m ? m.finalPrice : _r(d.product),
|
|
3379
|
+
finalDiscount: m ? m.finalDiscount : vr(d.product)
|
|
3380
|
+
};
|
|
3381
|
+
}), c = o.reduce(
|
|
3382
|
+
(d, l) => {
|
|
3383
|
+
const { product: m, amount: b, finalPrice: w, finalDiscount: S } = l;
|
|
3384
|
+
let C = 0;
|
|
3385
|
+
if (m.vat) {
|
|
3386
|
+
let Ie = 0;
|
|
3248
3387
|
if (n) {
|
|
3249
|
-
const
|
|
3250
|
-
|
|
3388
|
+
const et = w * (Ae.VAT / (100 + Ae.VAT));
|
|
3389
|
+
C = Number(et.toFixed(2)), C = C * b, Ie = Number(C.toFixed(2));
|
|
3251
3390
|
} else
|
|
3252
|
-
|
|
3253
|
-
|
|
3391
|
+
C = w * Ae.VAT / 100, C = C * b, Ie = Number(C.toFixed(2));
|
|
3392
|
+
d.vat = Number((d.vat + Ie).toFixed(2));
|
|
3254
3393
|
}
|
|
3255
|
-
return
|
|
3394
|
+
return d.cost += b * w, d.discount += S && b * S, d.finalCost += b * w + (n ? 0 : C), d.productsCost += b * w + (n ? 0 : C), d;
|
|
3256
3395
|
},
|
|
3257
3396
|
{
|
|
3258
3397
|
discount: 0,
|
|
@@ -3263,12 +3402,12 @@ function Er({
|
|
|
3263
3402
|
deliveryPrice: (t == null ? void 0 : t.deliveryPrice) ?? 0
|
|
3264
3403
|
}
|
|
3265
3404
|
);
|
|
3266
|
-
return c.deliveryPrice && c.productsCost >= (t.freeDeliveryPrice ?? 0) ? c.deliveryPrice = 0 : c.finalCost += c.deliveryPrice, console.log("cartDetails", c), { items:
|
|
3405
|
+
return c.deliveryPrice && c.productsCost >= (t.freeDeliveryPrice ?? 0) ? c.deliveryPrice = 0 : c.finalCost += c.deliveryPrice, console.log("cartDetails", c), { items: o, ...c };
|
|
3267
3406
|
}
|
|
3268
|
-
const
|
|
3407
|
+
const br = {
|
|
3269
3408
|
stores: "STORES",
|
|
3270
3409
|
companies: "COMPANIES"
|
|
3271
|
-
},
|
|
3410
|
+
}, xr = {
|
|
3272
3411
|
products: "products",
|
|
3273
3412
|
profiles: "profiles",
|
|
3274
3413
|
cart: "cart",
|
|
@@ -3279,9 +3418,9 @@ const yr = {
|
|
|
3279
3418
|
payments: "payments",
|
|
3280
3419
|
settings: "settings",
|
|
3281
3420
|
discounts: "discounts"
|
|
3282
|
-
},
|
|
3283
|
-
systemCollections:
|
|
3284
|
-
storeCollections:
|
|
3421
|
+
}, kr = {
|
|
3422
|
+
systemCollections: br,
|
|
3423
|
+
storeCollections: xr,
|
|
3285
3424
|
// for client
|
|
3286
3425
|
getPath: ({
|
|
3287
3426
|
companyId: r,
|
|
@@ -3291,34 +3430,43 @@ const yr = {
|
|
|
3291
3430
|
}) => `${r}/${e}/${t}${n ? `/${n}` : ""}`,
|
|
3292
3431
|
// for backend
|
|
3293
3432
|
getDocPath: (r) => `{companyId}/{storeId}/${r}/{id}`
|
|
3294
|
-
},
|
|
3295
|
-
firestore:
|
|
3433
|
+
}, Lr = {
|
|
3434
|
+
firestore: kr
|
|
3296
3435
|
};
|
|
3297
3436
|
export {
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3437
|
+
lr as AddressSchema,
|
|
3438
|
+
Je as BaseCategorySchema,
|
|
3439
|
+
yr as BundleDiscountStrategy,
|
|
3440
|
+
He as CartItemProductSchema,
|
|
3441
|
+
Zr as CartSchema,
|
|
3442
|
+
Ee as CategorySchema,
|
|
3443
|
+
Or as CompanySchema,
|
|
3444
|
+
mr as DiscountConditionsSchema,
|
|
3445
|
+
gr as DiscountEngine,
|
|
3446
|
+
Dr as DiscountSchema,
|
|
3447
|
+
Xe as DiscountStrategyFactory,
|
|
3448
|
+
pr as DiscountVariantSchema,
|
|
3449
|
+
jr as FavoriteProductSchema,
|
|
3450
|
+
Ir as FileSchema,
|
|
3451
|
+
Lr as FirebaseAPI,
|
|
3452
|
+
re as LocaleSchema,
|
|
3453
|
+
Ar as LocaleValueSchema,
|
|
3454
|
+
Nr as NewProductSchema,
|
|
3455
|
+
Rr as OrderSchema,
|
|
3456
|
+
Ye as ProductSchema,
|
|
3457
|
+
Ge as ProfilePaymentTypeSchema,
|
|
3458
|
+
fr as ProfileSchema,
|
|
3459
|
+
Pr as StoreSchema,
|
|
3460
|
+
Cr as TFlattenCategorySchema,
|
|
3461
|
+
Vr as calculatePercentageDiscount,
|
|
3462
|
+
hr as clientTypesSchema,
|
|
3463
|
+
Er as createEmptyProfile,
|
|
3464
|
+
$r as ensureNonNegative,
|
|
3465
|
+
Ke as formatCurrency,
|
|
3466
|
+
Mr as formatCurrencyString,
|
|
3467
|
+
Fr as getCartCost,
|
|
3468
|
+
Sr as isFile,
|
|
3469
|
+
M as notEmptyTextSchema,
|
|
3470
|
+
Tr as numericTextSchema
|
|
3323
3471
|
};
|
|
3324
3472
|
//# sourceMappingURL=core.es.js.map
|