@jsdev_ninja/core 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +1039 -1021
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/utils/getCartCost.test.d.ts +2 -0
- package/dist/lib/utils/getCartCost.test.d.ts.map +1 -0
- package/dist/lib/utils/getCartCost.test.js +236 -0
- package/dist/lib/utils/index.d.ts +20 -1
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +43 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.es.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var dt = (n, e, t) => e in n ?
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var ut = Object.defineProperty;
|
|
2
|
+
var dt = (n, e, t) => e in n ? ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var ze = (n, e, t) => dt(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
var b;
|
|
5
5
|
(function(n) {
|
|
6
|
-
n.assertEqual = (
|
|
7
|
-
function e(
|
|
6
|
+
n.assertEqual = (a) => a;
|
|
7
|
+
function e(a) {
|
|
8
8
|
}
|
|
9
9
|
n.assertIs = e;
|
|
10
|
-
function t(
|
|
10
|
+
function t(a) {
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
|
-
n.assertNever = t, n.arrayToEnum = (
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (a) => {
|
|
14
14
|
const s = {};
|
|
15
|
-
for (const o of
|
|
15
|
+
for (const o of a)
|
|
16
16
|
s[o] = o;
|
|
17
17
|
return s;
|
|
18
|
-
}, n.getValidEnumValues = (
|
|
19
|
-
const s = n.objectKeys(
|
|
18
|
+
}, n.getValidEnumValues = (a) => {
|
|
19
|
+
const s = n.objectKeys(a).filter((c) => typeof a[a[c]] != "number"), o = {};
|
|
20
20
|
for (const c of s)
|
|
21
|
-
o[c] =
|
|
21
|
+
o[c] = a[c];
|
|
22
22
|
return n.objectValues(o);
|
|
23
|
-
}, n.objectValues = (
|
|
24
|
-
return
|
|
25
|
-
}), n.objectKeys = typeof Object.keys == "function" ? (
|
|
23
|
+
}, n.objectValues = (a) => n.objectKeys(a).map(function(s) {
|
|
24
|
+
return a[s];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
26
26
|
const s = [];
|
|
27
|
-
for (const o in
|
|
28
|
-
Object.prototype.hasOwnProperty.call(
|
|
27
|
+
for (const o in a)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(a, o) && s.push(o);
|
|
29
29
|
return s;
|
|
30
|
-
}, n.find = (
|
|
31
|
-
for (const o of
|
|
30
|
+
}, n.find = (a, s) => {
|
|
31
|
+
for (const o of a)
|
|
32
32
|
if (s(o))
|
|
33
33
|
return o;
|
|
34
|
-
}, n.isInteger = typeof Number.isInteger == "function" ? (
|
|
35
|
-
function a
|
|
36
|
-
return
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && isFinite(a) && Math.floor(a) === a;
|
|
35
|
+
function i(a, s = " | ") {
|
|
36
|
+
return a.map((o) => typeof o == "string" ? `'${o}'` : o).join(s);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues =
|
|
39
|
-
})(
|
|
40
|
-
var
|
|
38
|
+
n.joinValues = i, n.jsonStringifyReplacer = (a, s) => typeof s == "bigint" ? s.toString() : s;
|
|
39
|
+
})(b || (b = {}));
|
|
40
|
+
var Ze;
|
|
41
41
|
(function(n) {
|
|
42
42
|
n.mergeShapes = (e, t) => ({
|
|
43
43
|
...e,
|
|
44
44
|
...t
|
|
45
45
|
// second overwrites first
|
|
46
46
|
});
|
|
47
|
-
})(
|
|
48
|
-
const p =
|
|
47
|
+
})(Ze || (Ze = {}));
|
|
48
|
+
const p = b.arrayToEnum([
|
|
49
49
|
"string",
|
|
50
50
|
"nan",
|
|
51
51
|
"number",
|
|
@@ -87,7 +87,7 @@ const p = x.arrayToEnum([
|
|
|
87
87
|
default:
|
|
88
88
|
return p.unknown;
|
|
89
89
|
}
|
|
90
|
-
},
|
|
90
|
+
}, d = b.arrayToEnum([
|
|
91
91
|
"invalid_type",
|
|
92
92
|
"invalid_literal",
|
|
93
93
|
"custom",
|
|
@@ -104,16 +104,16 @@ const p = x.arrayToEnum([
|
|
|
104
104
|
"invalid_intersection_types",
|
|
105
105
|
"not_multiple_of",
|
|
106
106
|
"not_finite"
|
|
107
|
-
]),
|
|
107
|
+
]), lt = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
108
108
|
class A extends Error {
|
|
109
109
|
get errors() {
|
|
110
110
|
return this.issues;
|
|
111
111
|
}
|
|
112
112
|
constructor(e) {
|
|
113
|
-
super(), this.issues = [], this.addIssue = (
|
|
114
|
-
this.issues = [...this.issues,
|
|
115
|
-
}, this.addIssues = (
|
|
116
|
-
this.issues = [...this.issues, ...
|
|
113
|
+
super(), this.issues = [], this.addIssue = (i) => {
|
|
114
|
+
this.issues = [...this.issues, i];
|
|
115
|
+
}, this.addIssues = (i = []) => {
|
|
116
|
+
this.issues = [...this.issues, ...i];
|
|
117
117
|
};
|
|
118
118
|
const t = new.target.prototype;
|
|
119
119
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -121,25 +121,25 @@ class A extends Error {
|
|
|
121
121
|
format(e) {
|
|
122
122
|
const t = e || function(s) {
|
|
123
123
|
return s.message;
|
|
124
|
-
},
|
|
124
|
+
}, i = { _errors: [] }, a = (s) => {
|
|
125
125
|
for (const o of s.issues)
|
|
126
126
|
if (o.code === "invalid_union")
|
|
127
|
-
o.unionErrors.map(
|
|
127
|
+
o.unionErrors.map(a);
|
|
128
128
|
else if (o.code === "invalid_return_type")
|
|
129
|
-
|
|
129
|
+
a(o.returnTypeError);
|
|
130
130
|
else if (o.code === "invalid_arguments")
|
|
131
|
-
|
|
131
|
+
a(o.argumentsError);
|
|
132
132
|
else if (o.path.length === 0)
|
|
133
|
-
|
|
133
|
+
i._errors.push(t(o));
|
|
134
134
|
else {
|
|
135
|
-
let c =
|
|
136
|
-
for (;
|
|
137
|
-
const
|
|
138
|
-
|
|
135
|
+
let c = i, l = 0;
|
|
136
|
+
for (; l < o.path.length; ) {
|
|
137
|
+
const u = o.path[l];
|
|
138
|
+
l === o.path.length - 1 ? (c[u] = c[u] || { _errors: [] }, c[u]._errors.push(t(o))) : c[u] = c[u] || { _errors: [] }, c = c[u], l++;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return a(this), i;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
145
|
if (!(e instanceof A))
|
|
@@ -149,16 +149,16 @@ class A extends Error {
|
|
|
149
149
|
return this.message;
|
|
150
150
|
}
|
|
151
151
|
get message() {
|
|
152
|
-
return JSON.stringify(this.issues,
|
|
152
|
+
return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
|
|
153
153
|
}
|
|
154
154
|
get isEmpty() {
|
|
155
155
|
return this.issues.length === 0;
|
|
156
156
|
}
|
|
157
157
|
flatten(e = (t) => t.message) {
|
|
158
|
-
const t = {},
|
|
159
|
-
for (const
|
|
160
|
-
|
|
161
|
-
return { formErrors:
|
|
158
|
+
const t = {}, i = [];
|
|
159
|
+
for (const a of this.issues)
|
|
160
|
+
a.path.length > 0 ? (t[a.path[0]] = t[a.path[0]] || [], t[a.path[0]].push(e(a))) : i.push(e(a));
|
|
161
|
+
return { formErrors: i, fieldErrors: t };
|
|
162
162
|
}
|
|
163
163
|
get formErrors() {
|
|
164
164
|
return this.flatten();
|
|
@@ -168,89 +168,89 @@ A.create = (n) => new A(n);
|
|
|
168
168
|
const G = (n, e) => {
|
|
169
169
|
let t;
|
|
170
170
|
switch (n.code) {
|
|
171
|
-
case
|
|
171
|
+
case d.invalid_type:
|
|
172
172
|
n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
173
173
|
break;
|
|
174
|
-
case
|
|
175
|
-
t = `Invalid literal value, expected ${JSON.stringify(n.expected,
|
|
174
|
+
case d.invalid_literal:
|
|
175
|
+
t = `Invalid literal value, expected ${JSON.stringify(n.expected, b.jsonStringifyReplacer)}`;
|
|
176
176
|
break;
|
|
177
|
-
case
|
|
178
|
-
t = `Unrecognized key(s) in object: ${
|
|
177
|
+
case d.unrecognized_keys:
|
|
178
|
+
t = `Unrecognized key(s) in object: ${b.joinValues(n.keys, ", ")}`;
|
|
179
179
|
break;
|
|
180
|
-
case
|
|
180
|
+
case d.invalid_union:
|
|
181
181
|
t = "Invalid input";
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
184
|
-
t = `Invalid discriminator value. Expected ${
|
|
183
|
+
case d.invalid_union_discriminator:
|
|
184
|
+
t = `Invalid discriminator value. Expected ${b.joinValues(n.options)}`;
|
|
185
185
|
break;
|
|
186
|
-
case
|
|
187
|
-
t = `Invalid enum value. Expected ${
|
|
186
|
+
case d.invalid_enum_value:
|
|
187
|
+
t = `Invalid enum value. Expected ${b.joinValues(n.options)}, received '${n.received}'`;
|
|
188
188
|
break;
|
|
189
|
-
case
|
|
189
|
+
case d.invalid_arguments:
|
|
190
190
|
t = "Invalid function arguments";
|
|
191
191
|
break;
|
|
192
|
-
case
|
|
192
|
+
case d.invalid_return_type:
|
|
193
193
|
t = "Invalid function return type";
|
|
194
194
|
break;
|
|
195
|
-
case
|
|
195
|
+
case d.invalid_date:
|
|
196
196
|
t = "Invalid date";
|
|
197
197
|
break;
|
|
198
|
-
case
|
|
199
|
-
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` :
|
|
198
|
+
case d.invalid_string:
|
|
199
|
+
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : b.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
200
200
|
break;
|
|
201
|
-
case
|
|
201
|
+
case d.too_small:
|
|
202
202
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
203
203
|
break;
|
|
204
|
-
case
|
|
204
|
+
case d.too_big:
|
|
205
205
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
206
206
|
break;
|
|
207
|
-
case
|
|
207
|
+
case d.custom:
|
|
208
208
|
t = "Invalid input";
|
|
209
209
|
break;
|
|
210
|
-
case
|
|
210
|
+
case d.invalid_intersection_types:
|
|
211
211
|
t = "Intersection results could not be merged";
|
|
212
212
|
break;
|
|
213
|
-
case
|
|
213
|
+
case d.not_multiple_of:
|
|
214
214
|
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
215
215
|
break;
|
|
216
|
-
case
|
|
216
|
+
case d.not_finite:
|
|
217
217
|
t = "Number must be finite";
|
|
218
218
|
break;
|
|
219
219
|
default:
|
|
220
|
-
t = e.defaultError,
|
|
220
|
+
t = e.defaultError, b.assertNever(n);
|
|
221
221
|
}
|
|
222
222
|
return { message: t };
|
|
223
223
|
};
|
|
224
|
-
let
|
|
225
|
-
function
|
|
226
|
-
|
|
224
|
+
let Be = G;
|
|
225
|
+
function mt(n) {
|
|
226
|
+
Be = n;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
228
|
+
function ve() {
|
|
229
|
+
return Be;
|
|
230
230
|
}
|
|
231
|
-
const
|
|
232
|
-
const { data: e, path: t, errorMaps:
|
|
233
|
-
...
|
|
231
|
+
const _e = (n) => {
|
|
232
|
+
const { data: e, path: t, errorMaps: i, issueData: a } = n, s = [...t, ...a.path || []], o = {
|
|
233
|
+
...a,
|
|
234
234
|
path: s
|
|
235
235
|
};
|
|
236
|
-
if (
|
|
236
|
+
if (a.message !== void 0)
|
|
237
237
|
return {
|
|
238
|
-
...
|
|
238
|
+
...a,
|
|
239
239
|
path: s,
|
|
240
|
-
message:
|
|
240
|
+
message: a.message
|
|
241
241
|
};
|
|
242
242
|
let c = "";
|
|
243
|
-
const
|
|
244
|
-
for (const
|
|
245
|
-
c =
|
|
243
|
+
const l = i.filter((u) => !!u).slice().reverse();
|
|
244
|
+
for (const u of l)
|
|
245
|
+
c = u(o, { data: e, defaultError: c }).message;
|
|
246
246
|
return {
|
|
247
|
-
...
|
|
247
|
+
...a,
|
|
248
248
|
path: s,
|
|
249
249
|
message: c
|
|
250
250
|
};
|
|
251
|
-
},
|
|
251
|
+
}, pt = [];
|
|
252
252
|
function m(n, e) {
|
|
253
|
-
const t =
|
|
253
|
+
const t = ve(), i = _e({
|
|
254
254
|
issueData: e,
|
|
255
255
|
data: n.data,
|
|
256
256
|
path: n.path,
|
|
@@ -263,9 +263,9 @@ function m(n, e) {
|
|
|
263
263
|
// then global override map
|
|
264
264
|
t === G ? void 0 : G
|
|
265
265
|
// then global default map
|
|
266
|
-
].filter((
|
|
266
|
+
].filter((a) => !!a)
|
|
267
267
|
});
|
|
268
|
-
n.common.issues.push(
|
|
268
|
+
n.common.issues.push(i);
|
|
269
269
|
}
|
|
270
270
|
class T {
|
|
271
271
|
constructor() {
|
|
@@ -278,44 +278,44 @@ class T {
|
|
|
278
278
|
this.value !== "aborted" && (this.value = "aborted");
|
|
279
279
|
}
|
|
280
280
|
static mergeArray(e, t) {
|
|
281
|
-
const
|
|
282
|
-
for (const
|
|
283
|
-
if (
|
|
281
|
+
const i = [];
|
|
282
|
+
for (const a of t) {
|
|
283
|
+
if (a.status === "aborted")
|
|
284
284
|
return y;
|
|
285
|
-
|
|
285
|
+
a.status === "dirty" && e.dirty(), i.push(a.value);
|
|
286
286
|
}
|
|
287
|
-
return { status: e.value, value:
|
|
287
|
+
return { status: e.value, value: i };
|
|
288
288
|
}
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
292
|
-
const s = await
|
|
293
|
-
|
|
290
|
+
const i = [];
|
|
291
|
+
for (const a of t) {
|
|
292
|
+
const s = await a.key, o = await a.value;
|
|
293
|
+
i.push({
|
|
294
294
|
key: s,
|
|
295
295
|
value: o
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
return T.mergeObjectSync(e,
|
|
298
|
+
return T.mergeObjectSync(e, i);
|
|
299
299
|
}
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
|
-
const
|
|
302
|
-
for (const
|
|
303
|
-
const { key: s, value: o } =
|
|
301
|
+
const i = {};
|
|
302
|
+
for (const a of t) {
|
|
303
|
+
const { key: s, value: o } = a;
|
|
304
304
|
if (s.status === "aborted" || o.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
s.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof o.value < "u" ||
|
|
306
|
+
s.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof o.value < "u" || a.alwaysSet) && (i[s.value] = o.value);
|
|
307
307
|
}
|
|
308
|
-
return { status: e.value, value:
|
|
308
|
+
return { status: e.value, value: i };
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
const y = Object.freeze({
|
|
312
312
|
status: "aborted"
|
|
313
|
-
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }),
|
|
314
|
-
function
|
|
313
|
+
}), Y = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }), Oe = (n) => n.status === "aborted", Pe = (n) => n.status === "dirty", q = (n) => n.status === "valid", re = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
314
|
+
function be(n, e, t, i) {
|
|
315
315
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
316
316
|
return e.get(n);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function We(n, e, t, i, a) {
|
|
319
319
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
320
320
|
return e.set(n, t), t;
|
|
321
321
|
}
|
|
@@ -323,16 +323,16 @@ var h;
|
|
|
323
323
|
(function(n) {
|
|
324
324
|
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
325
325
|
})(h || (h = {}));
|
|
326
|
-
var
|
|
326
|
+
var te, ne;
|
|
327
327
|
class P {
|
|
328
|
-
constructor(e, t,
|
|
329
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
328
|
+
constructor(e, t, i, a) {
|
|
329
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = i, this._key = a;
|
|
330
330
|
}
|
|
331
331
|
get path() {
|
|
332
332
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
const
|
|
335
|
+
const Ve = (n, e) => {
|
|
336
336
|
if (q(e))
|
|
337
337
|
return { success: !0, data: e.value };
|
|
338
338
|
if (!n.common.issues.length)
|
|
@@ -350,14 +350,14 @@ const ze = (n, e) => {
|
|
|
350
350
|
function v(n) {
|
|
351
351
|
if (!n)
|
|
352
352
|
return {};
|
|
353
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
354
|
-
if (e && (t ||
|
|
353
|
+
const { errorMap: e, invalid_type_error: t, required_error: i, description: a } = n;
|
|
354
|
+
if (e && (t || i))
|
|
355
355
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
356
|
-
return e ? { errorMap: e, description:
|
|
357
|
-
var
|
|
356
|
+
return e ? { errorMap: e, description: a } : { errorMap: (o, c) => {
|
|
357
|
+
var l, u;
|
|
358
358
|
const { message: f } = n;
|
|
359
|
-
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (
|
|
360
|
-
}, description:
|
|
359
|
+
return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (l = f ?? i) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (u = f ?? t) !== null && u !== void 0 ? u : c.defaultError };
|
|
360
|
+
}, description: a };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
363
363
|
get description() {
|
|
@@ -391,7 +391,7 @@ class _ {
|
|
|
391
391
|
}
|
|
392
392
|
_parseSync(e) {
|
|
393
393
|
const t = this._parse(e);
|
|
394
|
-
if (
|
|
394
|
+
if (re(t))
|
|
395
395
|
throw new Error("Synchronous parse encountered promise.");
|
|
396
396
|
return t;
|
|
397
397
|
}
|
|
@@ -400,17 +400,17 @@ class _ {
|
|
|
400
400
|
return Promise.resolve(t);
|
|
401
401
|
}
|
|
402
402
|
parse(e, t) {
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
406
|
-
throw
|
|
403
|
+
const i = this.safeParse(e, t);
|
|
404
|
+
if (i.success)
|
|
405
|
+
return i.data;
|
|
406
|
+
throw i.error;
|
|
407
407
|
}
|
|
408
408
|
safeParse(e, t) {
|
|
409
|
-
var
|
|
410
|
-
const
|
|
409
|
+
var i;
|
|
410
|
+
const a = {
|
|
411
411
|
common: {
|
|
412
412
|
issues: [],
|
|
413
|
-
async: (
|
|
413
|
+
async: (i = t == null ? void 0 : t.async) !== null && i !== void 0 ? i : !1,
|
|
414
414
|
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
415
415
|
},
|
|
416
416
|
path: (t == null ? void 0 : t.path) || [],
|
|
@@ -418,12 +418,12 @@ class _ {
|
|
|
418
418
|
parent: null,
|
|
419
419
|
data: e,
|
|
420
420
|
parsedType: R(e)
|
|
421
|
-
}, s = this._parseSync({ data: e, path:
|
|
422
|
-
return
|
|
421
|
+
}, s = this._parseSync({ data: e, path: a.path, parent: a });
|
|
422
|
+
return Ve(a, s);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
|
-
var t,
|
|
426
|
-
const
|
|
425
|
+
var t, i;
|
|
426
|
+
const a = {
|
|
427
427
|
common: {
|
|
428
428
|
issues: [],
|
|
429
429
|
async: !!this["~standard"].async
|
|
@@ -436,32 +436,32 @@ class _ {
|
|
|
436
436
|
};
|
|
437
437
|
if (!this["~standard"].async)
|
|
438
438
|
try {
|
|
439
|
-
const s = this._parseSync({ data: e, path: [], parent:
|
|
439
|
+
const s = this._parseSync({ data: e, path: [], parent: a });
|
|
440
440
|
return q(s) ? {
|
|
441
441
|
value: s.value
|
|
442
442
|
} : {
|
|
443
|
-
issues:
|
|
443
|
+
issues: a.common.issues
|
|
444
444
|
};
|
|
445
445
|
} catch (s) {
|
|
446
|
-
!((
|
|
446
|
+
!((i = (t = s == null ? void 0 : s.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || i === void 0) && i.includes("encountered") && (this["~standard"].async = !0), a.common = {
|
|
447
447
|
issues: [],
|
|
448
448
|
async: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
451
|
+
return this._parseAsync({ data: e, path: [], parent: a }).then((s) => q(s) ? {
|
|
452
452
|
value: s.value
|
|
453
453
|
} : {
|
|
454
|
-
issues:
|
|
454
|
+
issues: a.common.issues
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
async parseAsync(e, t) {
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
461
|
-
throw
|
|
458
|
+
const i = await this.safeParseAsync(e, t);
|
|
459
|
+
if (i.success)
|
|
460
|
+
return i.data;
|
|
461
|
+
throw i.error;
|
|
462
462
|
}
|
|
463
463
|
async safeParseAsync(e, t) {
|
|
464
|
-
const
|
|
464
|
+
const i = {
|
|
465
465
|
common: {
|
|
466
466
|
issues: [],
|
|
467
467
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -472,24 +472,24 @@ class _ {
|
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
474
|
parsedType: R(e)
|
|
475
|
-
},
|
|
476
|
-
return
|
|
475
|
+
}, a = this._parse({ data: e, path: i.path, parent: i }), s = await (re(a) ? a : Promise.resolve(a));
|
|
476
|
+
return Ve(i, s);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
|
-
const
|
|
480
|
-
return this._refinement((
|
|
481
|
-
const o = e(
|
|
482
|
-
code:
|
|
483
|
-
...a
|
|
479
|
+
const i = (a) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(a) : t;
|
|
480
|
+
return this._refinement((a, s) => {
|
|
481
|
+
const o = e(a), c = () => s.addIssue({
|
|
482
|
+
code: d.custom,
|
|
483
|
+
...i(a)
|
|
484
484
|
});
|
|
485
|
-
return typeof Promise < "u" && o instanceof Promise ? o.then((
|
|
485
|
+
return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (c(), !1)) : o ? !0 : (c(), !1);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
refinement(e, t) {
|
|
489
|
-
return this._refinement((
|
|
489
|
+
return this._refinement((i, a) => e(i) ? !0 : (a.addIssue(typeof t == "function" ? t(i, a) : t), !1));
|
|
490
490
|
}
|
|
491
491
|
_refinement(e) {
|
|
492
|
-
return new
|
|
492
|
+
return new j({
|
|
493
493
|
schema: this,
|
|
494
494
|
typeName: g.ZodEffects,
|
|
495
495
|
effect: { type: "refinement", refinement: e }
|
|
@@ -515,19 +515,19 @@ class _ {
|
|
|
515
515
|
return this.nullable().optional();
|
|
516
516
|
}
|
|
517
517
|
array() {
|
|
518
|
-
return
|
|
518
|
+
return C.create(this);
|
|
519
519
|
}
|
|
520
520
|
promise() {
|
|
521
521
|
return H.create(this, this._def);
|
|
522
522
|
}
|
|
523
523
|
or(e) {
|
|
524
|
-
return
|
|
524
|
+
return oe.create([this, e], this._def);
|
|
525
525
|
}
|
|
526
526
|
and(e) {
|
|
527
|
-
return
|
|
527
|
+
return ce.create(this, e, this._def);
|
|
528
528
|
}
|
|
529
529
|
transform(e) {
|
|
530
|
-
return new
|
|
530
|
+
return new j({
|
|
531
531
|
...v(this._def),
|
|
532
532
|
schema: this,
|
|
533
533
|
typeName: g.ZodEffects,
|
|
@@ -536,7 +536,7 @@ class _ {
|
|
|
536
536
|
}
|
|
537
537
|
default(e) {
|
|
538
538
|
const t = typeof e == "function" ? e : () => e;
|
|
539
|
-
return new
|
|
539
|
+
return new pe({
|
|
540
540
|
...v(this._def),
|
|
541
541
|
innerType: this,
|
|
542
542
|
defaultValue: t,
|
|
@@ -544,7 +544,7 @@ class _ {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
brand() {
|
|
547
|
-
return new
|
|
547
|
+
return new Re({
|
|
548
548
|
typeName: g.ZodBranded,
|
|
549
549
|
type: this,
|
|
550
550
|
...v(this._def)
|
|
@@ -552,7 +552,7 @@ class _ {
|
|
|
552
552
|
}
|
|
553
553
|
catch(e) {
|
|
554
554
|
const t = typeof e == "function" ? e : () => e;
|
|
555
|
-
return new
|
|
555
|
+
return new fe({
|
|
556
556
|
...v(this._def),
|
|
557
557
|
innerType: this,
|
|
558
558
|
catchValue: t,
|
|
@@ -567,10 +567,10 @@ class _ {
|
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
pipe(e) {
|
|
570
|
-
return
|
|
570
|
+
return ge.create(this, e);
|
|
571
571
|
}
|
|
572
572
|
readonly() {
|
|
573
|
-
return
|
|
573
|
+
return he.create(this);
|
|
574
574
|
}
|
|
575
575
|
isOptional() {
|
|
576
576
|
return this.safeParse(void 0).success;
|
|
@@ -579,201 +579,201 @@ class _ {
|
|
|
579
579
|
return this.safeParse(null).success;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
const
|
|
583
|
-
let
|
|
584
|
-
const
|
|
585
|
-
function
|
|
582
|
+
const ft = /^c[^\s-]{8,}$/i, ht = /^[0-9a-z]+$/, gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, yt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, vt = /^[a-z0-9_-]{21}$/i, _t = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, bt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, xt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
|
+
let je;
|
|
584
|
+
const wt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Tt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, St = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, It = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, At = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Nt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Qe = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Ct = new RegExp(`^${Qe}$`);
|
|
585
|
+
function Ye(n) {
|
|
586
586
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
587
587
|
return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
return new RegExp(`^${
|
|
589
|
+
function jt(n) {
|
|
590
|
+
return new RegExp(`^${Ye(n)}$`);
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
let e = `${
|
|
592
|
+
function Xe(n) {
|
|
593
|
+
let e = `${Qe}T${Ye(n)}`;
|
|
594
594
|
const t = [];
|
|
595
595
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
596
596
|
}
|
|
597
|
-
function jt(n, e) {
|
|
598
|
-
return !!((e === "v4" || !e) && kt.test(n) || (e === "v6" || !e) && Tt.test(n));
|
|
599
|
-
}
|
|
600
597
|
function Zt(n, e) {
|
|
601
|
-
|
|
598
|
+
return !!((e === "v4" || !e) && wt.test(n) || (e === "v6" || !e) && St.test(n));
|
|
599
|
+
}
|
|
600
|
+
function Ot(n, e) {
|
|
601
|
+
if (!_t.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
|
-
const [t] = n.split("."),
|
|
605
|
-
return !(typeof
|
|
604
|
+
const [t] = n.split("."), i = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), a = JSON.parse(atob(i));
|
|
605
|
+
return !(typeof a != "object" || a === null || !a.typ || !a.alg || e && a.alg !== e);
|
|
606
606
|
} catch {
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return !!((e === "v4" || !e) &&
|
|
610
|
+
function Pt(n, e) {
|
|
611
|
+
return !!((e === "v4" || !e) && Tt.test(n) || (e === "v6" || !e) && It.test(n));
|
|
612
612
|
}
|
|
613
|
-
class
|
|
613
|
+
class N extends _ {
|
|
614
614
|
_parse(e) {
|
|
615
615
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
|
|
616
616
|
const s = this._getOrReturnCtx(e);
|
|
617
617
|
return m(s, {
|
|
618
|
-
code:
|
|
618
|
+
code: d.invalid_type,
|
|
619
619
|
expected: p.string,
|
|
620
620
|
received: s.parsedType
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
let
|
|
623
|
+
const i = new T();
|
|
624
|
+
let a;
|
|
625
625
|
for (const s of this._def.checks)
|
|
626
626
|
if (s.kind === "min")
|
|
627
|
-
e.data.length < s.value && (
|
|
628
|
-
code:
|
|
627
|
+
e.data.length < s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
628
|
+
code: d.too_small,
|
|
629
629
|
minimum: s.value,
|
|
630
630
|
type: "string",
|
|
631
631
|
inclusive: !0,
|
|
632
632
|
exact: !1,
|
|
633
633
|
message: s.message
|
|
634
|
-
}),
|
|
634
|
+
}), i.dirty());
|
|
635
635
|
else if (s.kind === "max")
|
|
636
|
-
e.data.length > s.value && (
|
|
637
|
-
code:
|
|
636
|
+
e.data.length > s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
637
|
+
code: d.too_big,
|
|
638
638
|
maximum: s.value,
|
|
639
639
|
type: "string",
|
|
640
640
|
inclusive: !0,
|
|
641
641
|
exact: !1,
|
|
642
642
|
message: s.message
|
|
643
|
-
}),
|
|
643
|
+
}), i.dirty());
|
|
644
644
|
else if (s.kind === "length") {
|
|
645
645
|
const o = e.data.length > s.value, c = e.data.length < s.value;
|
|
646
|
-
(o || c) && (
|
|
647
|
-
code:
|
|
646
|
+
(o || c) && (a = this._getOrReturnCtx(e, a), o ? m(a, {
|
|
647
|
+
code: d.too_big,
|
|
648
648
|
maximum: s.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
652
|
message: s.message
|
|
653
|
-
}) : c && m(
|
|
654
|
-
code:
|
|
653
|
+
}) : c && m(a, {
|
|
654
|
+
code: d.too_small,
|
|
655
655
|
minimum: s.value,
|
|
656
656
|
type: "string",
|
|
657
657
|
inclusive: !0,
|
|
658
658
|
exact: !0,
|
|
659
659
|
message: s.message
|
|
660
|
-
}),
|
|
660
|
+
}), i.dirty());
|
|
661
661
|
} else if (s.kind === "email")
|
|
662
|
-
|
|
662
|
+
xt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
663
663
|
validation: "email",
|
|
664
|
-
code:
|
|
664
|
+
code: d.invalid_string,
|
|
665
665
|
message: s.message
|
|
666
|
-
}),
|
|
666
|
+
}), i.dirty());
|
|
667
667
|
else if (s.kind === "emoji")
|
|
668
|
-
|
|
668
|
+
je || (je = new RegExp(kt, "u")), je.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
669
669
|
validation: "emoji",
|
|
670
|
-
code:
|
|
670
|
+
code: d.invalid_string,
|
|
671
671
|
message: s.message
|
|
672
|
-
}),
|
|
672
|
+
}), i.dirty());
|
|
673
673
|
else if (s.kind === "uuid")
|
|
674
|
-
|
|
674
|
+
yt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
675
675
|
validation: "uuid",
|
|
676
|
-
code:
|
|
676
|
+
code: d.invalid_string,
|
|
677
677
|
message: s.message
|
|
678
|
-
}),
|
|
678
|
+
}), i.dirty());
|
|
679
679
|
else if (s.kind === "nanoid")
|
|
680
|
-
|
|
680
|
+
vt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
681
681
|
validation: "nanoid",
|
|
682
|
-
code:
|
|
682
|
+
code: d.invalid_string,
|
|
683
683
|
message: s.message
|
|
684
|
-
}),
|
|
684
|
+
}), i.dirty());
|
|
685
685
|
else if (s.kind === "cuid")
|
|
686
|
-
|
|
686
|
+
ft.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
687
687
|
validation: "cuid",
|
|
688
|
-
code:
|
|
688
|
+
code: d.invalid_string,
|
|
689
689
|
message: s.message
|
|
690
|
-
}),
|
|
690
|
+
}), i.dirty());
|
|
691
691
|
else if (s.kind === "cuid2")
|
|
692
|
-
|
|
692
|
+
ht.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
693
693
|
validation: "cuid2",
|
|
694
|
-
code:
|
|
694
|
+
code: d.invalid_string,
|
|
695
695
|
message: s.message
|
|
696
|
-
}),
|
|
696
|
+
}), i.dirty());
|
|
697
697
|
else if (s.kind === "ulid")
|
|
698
|
-
|
|
698
|
+
gt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
699
699
|
validation: "ulid",
|
|
700
|
-
code:
|
|
700
|
+
code: d.invalid_string,
|
|
701
701
|
message: s.message
|
|
702
|
-
}),
|
|
702
|
+
}), i.dirty());
|
|
703
703
|
else if (s.kind === "url")
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
a = this._getOrReturnCtx(e, a), m(a, {
|
|
708
708
|
validation: "url",
|
|
709
|
-
code:
|
|
709
|
+
code: d.invalid_string,
|
|
710
710
|
message: s.message
|
|
711
|
-
}),
|
|
711
|
+
}), i.dirty();
|
|
712
712
|
}
|
|
713
|
-
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (
|
|
713
|
+
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
714
714
|
validation: "regex",
|
|
715
|
-
code:
|
|
715
|
+
code: d.invalid_string,
|
|
716
716
|
message: s.message
|
|
717
|
-
}),
|
|
718
|
-
code:
|
|
717
|
+
}), i.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
718
|
+
code: d.invalid_string,
|
|
719
719
|
validation: { includes: s.value, position: s.position },
|
|
720
720
|
message: s.message
|
|
721
|
-
}),
|
|
722
|
-
code:
|
|
721
|
+
}), i.dirty()) : s.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : s.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : s.kind === "startsWith" ? e.data.startsWith(s.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
722
|
+
code: d.invalid_string,
|
|
723
723
|
validation: { startsWith: s.value },
|
|
724
724
|
message: s.message
|
|
725
|
-
}),
|
|
726
|
-
code:
|
|
725
|
+
}), i.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
726
|
+
code: d.invalid_string,
|
|
727
727
|
validation: { endsWith: s.value },
|
|
728
728
|
message: s.message
|
|
729
|
-
}),
|
|
730
|
-
code:
|
|
729
|
+
}), i.dirty()) : s.kind === "datetime" ? Xe(s).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
730
|
+
code: d.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
732
|
message: s.message
|
|
733
|
-
}),
|
|
734
|
-
code:
|
|
733
|
+
}), i.dirty()) : s.kind === "date" ? Ct.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
734
|
+
code: d.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
736
|
message: s.message
|
|
737
|
-
}),
|
|
738
|
-
code:
|
|
737
|
+
}), i.dirty()) : s.kind === "time" ? jt(s).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
738
|
+
code: d.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
740
|
message: s.message
|
|
741
|
-
}),
|
|
741
|
+
}), i.dirty()) : s.kind === "duration" ? bt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
742
742
|
validation: "duration",
|
|
743
|
-
code:
|
|
743
|
+
code: d.invalid_string,
|
|
744
744
|
message: s.message
|
|
745
|
-
}),
|
|
745
|
+
}), i.dirty()) : s.kind === "ip" ? Zt(e.data, s.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
746
746
|
validation: "ip",
|
|
747
|
-
code:
|
|
747
|
+
code: d.invalid_string,
|
|
748
748
|
message: s.message
|
|
749
|
-
}),
|
|
749
|
+
}), i.dirty()) : s.kind === "jwt" ? Ot(e.data, s.alg) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
750
750
|
validation: "jwt",
|
|
751
|
-
code:
|
|
751
|
+
code: d.invalid_string,
|
|
752
752
|
message: s.message
|
|
753
|
-
}),
|
|
753
|
+
}), i.dirty()) : s.kind === "cidr" ? Pt(e.data, s.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
754
754
|
validation: "cidr",
|
|
755
|
-
code:
|
|
755
|
+
code: d.invalid_string,
|
|
756
756
|
message: s.message
|
|
757
|
-
}),
|
|
757
|
+
}), i.dirty()) : s.kind === "base64" ? At.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
758
758
|
validation: "base64",
|
|
759
|
-
code:
|
|
759
|
+
code: d.invalid_string,
|
|
760
760
|
message: s.message
|
|
761
|
-
}),
|
|
761
|
+
}), i.dirty()) : s.kind === "base64url" ? Nt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
762
762
|
validation: "base64url",
|
|
763
|
-
code:
|
|
763
|
+
code: d.invalid_string,
|
|
764
764
|
message: s.message
|
|
765
|
-
}),
|
|
766
|
-
return { status:
|
|
765
|
+
}), i.dirty()) : b.assertNever(s);
|
|
766
|
+
return { status: i.value, value: e.data };
|
|
767
767
|
}
|
|
768
|
-
_regex(e, t,
|
|
769
|
-
return this.refinement((
|
|
768
|
+
_regex(e, t, i) {
|
|
769
|
+
return this.refinement((a) => e.test(a), {
|
|
770
770
|
validation: t,
|
|
771
|
-
code:
|
|
772
|
-
...h.errToObj(
|
|
771
|
+
code: d.invalid_string,
|
|
772
|
+
...h.errToObj(i)
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
_addCheck(e) {
|
|
776
|
-
return new
|
|
776
|
+
return new N({
|
|
777
777
|
...this._def,
|
|
778
778
|
checks: [...this._def.checks, e]
|
|
779
779
|
});
|
|
@@ -821,7 +821,7 @@ class C extends _ {
|
|
|
821
821
|
return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
|
|
822
822
|
}
|
|
823
823
|
datetime(e) {
|
|
824
|
-
var t,
|
|
824
|
+
var t, i;
|
|
825
825
|
return typeof e == "string" ? this._addCheck({
|
|
826
826
|
kind: "datetime",
|
|
827
827
|
precision: null,
|
|
@@ -832,7 +832,7 @@ class C extends _ {
|
|
|
832
832
|
kind: "datetime",
|
|
833
833
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
834
834
|
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
835
|
-
local: (
|
|
835
|
+
local: (i = e == null ? void 0 : e.local) !== null && i !== void 0 ? i : !1,
|
|
836
836
|
...h.errToObj(e == null ? void 0 : e.message)
|
|
837
837
|
});
|
|
838
838
|
}
|
|
@@ -910,19 +910,19 @@ class C extends _ {
|
|
|
910
910
|
return this.min(1, h.errToObj(e));
|
|
911
911
|
}
|
|
912
912
|
trim() {
|
|
913
|
-
return new
|
|
913
|
+
return new N({
|
|
914
914
|
...this._def,
|
|
915
915
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
918
|
toLowerCase() {
|
|
919
|
-
return new
|
|
919
|
+
return new N({
|
|
920
920
|
...this._def,
|
|
921
921
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
922
922
|
});
|
|
923
923
|
}
|
|
924
924
|
toUpperCase() {
|
|
925
|
-
return new
|
|
925
|
+
return new N({
|
|
926
926
|
...this._def,
|
|
927
927
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
928
928
|
});
|
|
@@ -988,18 +988,18 @@ class C extends _ {
|
|
|
988
988
|
return e;
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
|
-
|
|
991
|
+
N.create = (n) => {
|
|
992
992
|
var e;
|
|
993
|
-
return new
|
|
993
|
+
return new N({
|
|
994
994
|
checks: [],
|
|
995
995
|
typeName: g.ZodString,
|
|
996
996
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
|
|
997
997
|
...v(n)
|
|
998
998
|
});
|
|
999
999
|
};
|
|
1000
|
-
function
|
|
1001
|
-
const t = (n.toString().split(".")[1] || "").length,
|
|
1002
|
-
return s % o / Math.pow(10,
|
|
1000
|
+
function Dt(n, e) {
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, i = (e.toString().split(".")[1] || "").length, a = t > i ? t : i, s = parseInt(n.toFixed(a).replace(".", "")), o = parseInt(e.toFixed(a).replace(".", ""));
|
|
1002
|
+
return s % o / Math.pow(10, a);
|
|
1003
1003
|
}
|
|
1004
1004
|
class z extends _ {
|
|
1005
1005
|
constructor() {
|
|
@@ -1009,42 +1009,42 @@ class z extends _ {
|
|
|
1009
1009
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
|
|
1010
1010
|
const s = this._getOrReturnCtx(e);
|
|
1011
1011
|
return m(s, {
|
|
1012
|
-
code:
|
|
1012
|
+
code: d.invalid_type,
|
|
1013
1013
|
expected: p.number,
|
|
1014
1014
|
received: s.parsedType
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
|
-
let
|
|
1018
|
-
const
|
|
1017
|
+
let i;
|
|
1018
|
+
const a = new T();
|
|
1019
1019
|
for (const s of this._def.checks)
|
|
1020
|
-
s.kind === "int" ?
|
|
1021
|
-
code:
|
|
1020
|
+
s.kind === "int" ? b.isInteger(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1021
|
+
code: d.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
1024
|
message: s.message
|
|
1025
|
-
}),
|
|
1026
|
-
code:
|
|
1025
|
+
}), a.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1026
|
+
code: d.too_small,
|
|
1027
1027
|
minimum: s.value,
|
|
1028
1028
|
type: "number",
|
|
1029
1029
|
inclusive: s.inclusive,
|
|
1030
1030
|
exact: !1,
|
|
1031
1031
|
message: s.message
|
|
1032
|
-
}),
|
|
1033
|
-
code:
|
|
1032
|
+
}), a.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1033
|
+
code: d.too_big,
|
|
1034
1034
|
maximum: s.value,
|
|
1035
1035
|
type: "number",
|
|
1036
1036
|
inclusive: s.inclusive,
|
|
1037
1037
|
exact: !1,
|
|
1038
1038
|
message: s.message
|
|
1039
|
-
}),
|
|
1040
|
-
code:
|
|
1039
|
+
}), a.dirty()) : s.kind === "multipleOf" ? Dt(e.data, s.value) !== 0 && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1040
|
+
code: d.not_multiple_of,
|
|
1041
1041
|
multipleOf: s.value,
|
|
1042
1042
|
message: s.message
|
|
1043
|
-
}),
|
|
1044
|
-
code:
|
|
1043
|
+
}), a.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1044
|
+
code: d.not_finite,
|
|
1045
1045
|
message: s.message
|
|
1046
|
-
}),
|
|
1047
|
-
return { status:
|
|
1046
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1047
|
+
return { status: a.value, value: e.data };
|
|
1048
1048
|
}
|
|
1049
1049
|
gte(e, t) {
|
|
1050
1050
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -1058,7 +1058,7 @@ class z extends _ {
|
|
|
1058
1058
|
lt(e, t) {
|
|
1059
1059
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1060
1060
|
}
|
|
1061
|
-
setLimit(e, t,
|
|
1061
|
+
setLimit(e, t, i, a) {
|
|
1062
1062
|
return new z({
|
|
1063
1063
|
...this._def,
|
|
1064
1064
|
checks: [
|
|
@@ -1066,8 +1066,8 @@ class z extends _ {
|
|
|
1066
1066
|
{
|
|
1067
1067
|
kind: e,
|
|
1068
1068
|
value: t,
|
|
1069
|
-
inclusive:
|
|
1070
|
-
message: h.toString(
|
|
1069
|
+
inclusive: i,
|
|
1070
|
+
message: h.toString(a)
|
|
1071
1071
|
}
|
|
1072
1072
|
]
|
|
1073
1073
|
});
|
|
@@ -1155,14 +1155,14 @@ class z extends _ {
|
|
|
1155
1155
|
return e;
|
|
1156
1156
|
}
|
|
1157
1157
|
get isInt() {
|
|
1158
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" &&
|
|
1158
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
|
|
1159
1159
|
}
|
|
1160
1160
|
get isFinite() {
|
|
1161
1161
|
let e = null, t = null;
|
|
1162
|
-
for (const
|
|
1163
|
-
if (
|
|
1162
|
+
for (const i of this._def.checks) {
|
|
1163
|
+
if (i.kind === "finite" || i.kind === "int" || i.kind === "multipleOf")
|
|
1164
1164
|
return !0;
|
|
1165
|
-
|
|
1165
|
+
i.kind === "min" ? (t === null || i.value > t) && (t = i.value) : i.kind === "max" && (e === null || i.value < e) && (e = i.value);
|
|
1166
1166
|
}
|
|
1167
1167
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1168
1168
|
}
|
|
@@ -1186,32 +1186,32 @@ class V extends _ {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
if (this._getType(e) !== p.bigint)
|
|
1188
1188
|
return this._getInvalidInput(e);
|
|
1189
|
-
let
|
|
1190
|
-
const
|
|
1189
|
+
let i;
|
|
1190
|
+
const a = new T();
|
|
1191
1191
|
for (const s of this._def.checks)
|
|
1192
|
-
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (
|
|
1193
|
-
code:
|
|
1192
|
+
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1193
|
+
code: d.too_small,
|
|
1194
1194
|
type: "bigint",
|
|
1195
1195
|
minimum: s.value,
|
|
1196
1196
|
inclusive: s.inclusive,
|
|
1197
1197
|
message: s.message
|
|
1198
|
-
}),
|
|
1199
|
-
code:
|
|
1198
|
+
}), a.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1199
|
+
code: d.too_big,
|
|
1200
1200
|
type: "bigint",
|
|
1201
1201
|
maximum: s.value,
|
|
1202
1202
|
inclusive: s.inclusive,
|
|
1203
1203
|
message: s.message
|
|
1204
|
-
}),
|
|
1205
|
-
code:
|
|
1204
|
+
}), a.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1205
|
+
code: d.not_multiple_of,
|
|
1206
1206
|
multipleOf: s.value,
|
|
1207
1207
|
message: s.message
|
|
1208
|
-
}),
|
|
1209
|
-
return { status:
|
|
1208
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1209
|
+
return { status: a.value, value: e.data };
|
|
1210
1210
|
}
|
|
1211
1211
|
_getInvalidInput(e) {
|
|
1212
1212
|
const t = this._getOrReturnCtx(e);
|
|
1213
1213
|
return m(t, {
|
|
1214
|
-
code:
|
|
1214
|
+
code: d.invalid_type,
|
|
1215
1215
|
expected: p.bigint,
|
|
1216
1216
|
received: t.parsedType
|
|
1217
1217
|
}), y;
|
|
@@ -1228,7 +1228,7 @@ class V extends _ {
|
|
|
1228
1228
|
lt(e, t) {
|
|
1229
1229
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1230
1230
|
}
|
|
1231
|
-
setLimit(e, t,
|
|
1231
|
+
setLimit(e, t, i, a) {
|
|
1232
1232
|
return new V({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
@@ -1236,8 +1236,8 @@ class V extends _ {
|
|
|
1236
1236
|
{
|
|
1237
1237
|
kind: e,
|
|
1238
1238
|
value: t,
|
|
1239
|
-
inclusive:
|
|
1240
|
-
message: h.toString(
|
|
1239
|
+
inclusive: i,
|
|
1240
|
+
message: h.toString(a)
|
|
1241
1241
|
}
|
|
1242
1242
|
]
|
|
1243
1243
|
});
|
|
@@ -1309,20 +1309,20 @@ V.create = (n) => {
|
|
|
1309
1309
|
...v(n)
|
|
1310
1310
|
});
|
|
1311
1311
|
};
|
|
1312
|
-
class
|
|
1312
|
+
class ie extends _ {
|
|
1313
1313
|
_parse(e) {
|
|
1314
1314
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
1315
|
-
const
|
|
1316
|
-
return m(
|
|
1317
|
-
code:
|
|
1315
|
+
const i = this._getOrReturnCtx(e);
|
|
1316
|
+
return m(i, {
|
|
1317
|
+
code: d.invalid_type,
|
|
1318
1318
|
expected: p.boolean,
|
|
1319
|
-
received:
|
|
1319
|
+
received: i.parsedType
|
|
1320
1320
|
}), y;
|
|
1321
1321
|
}
|
|
1322
1322
|
return S(e.data);
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
|
-
|
|
1325
|
+
ie.create = (n) => new ie({
|
|
1326
1326
|
typeName: g.ZodBoolean,
|
|
1327
1327
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1328
1328
|
...v(n)
|
|
@@ -1332,7 +1332,7 @@ class B extends _ {
|
|
|
1332
1332
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1333
1333
|
const s = this._getOrReturnCtx(e);
|
|
1334
1334
|
return m(s, {
|
|
1335
|
-
code:
|
|
1335
|
+
code: d.invalid_type,
|
|
1336
1336
|
expected: p.date,
|
|
1337
1337
|
received: s.parsedType
|
|
1338
1338
|
}), y;
|
|
@@ -1340,29 +1340,29 @@ class B extends _ {
|
|
|
1340
1340
|
if (isNaN(e.data.getTime())) {
|
|
1341
1341
|
const s = this._getOrReturnCtx(e);
|
|
1342
1342
|
return m(s, {
|
|
1343
|
-
code:
|
|
1343
|
+
code: d.invalid_date
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
let
|
|
1346
|
+
const i = new T();
|
|
1347
|
+
let a;
|
|
1348
1348
|
for (const s of this._def.checks)
|
|
1349
|
-
s.kind === "min" ? e.data.getTime() < s.value && (
|
|
1350
|
-
code:
|
|
1349
|
+
s.kind === "min" ? e.data.getTime() < s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1350
|
+
code: d.too_small,
|
|
1351
1351
|
message: s.message,
|
|
1352
1352
|
inclusive: !0,
|
|
1353
1353
|
exact: !1,
|
|
1354
1354
|
minimum: s.value,
|
|
1355
1355
|
type: "date"
|
|
1356
|
-
}),
|
|
1357
|
-
code:
|
|
1356
|
+
}), i.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1357
|
+
code: d.too_big,
|
|
1358
1358
|
message: s.message,
|
|
1359
1359
|
inclusive: !0,
|
|
1360
1360
|
exact: !1,
|
|
1361
1361
|
maximum: s.value,
|
|
1362
1362
|
type: "date"
|
|
1363
|
-
}),
|
|
1363
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1364
1364
|
return {
|
|
1365
|
-
status:
|
|
1365
|
+
status: i.value,
|
|
1366
1366
|
value: new Date(e.data.getTime())
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
@@ -1405,31 +1405,31 @@ B.create = (n) => new B({
|
|
|
1405
1405
|
typeName: g.ZodDate,
|
|
1406
1406
|
...v(n)
|
|
1407
1407
|
});
|
|
1408
|
-
class
|
|
1408
|
+
class xe extends _ {
|
|
1409
1409
|
_parse(e) {
|
|
1410
1410
|
if (this._getType(e) !== p.symbol) {
|
|
1411
|
-
const
|
|
1412
|
-
return m(
|
|
1413
|
-
code:
|
|
1411
|
+
const i = this._getOrReturnCtx(e);
|
|
1412
|
+
return m(i, {
|
|
1413
|
+
code: d.invalid_type,
|
|
1414
1414
|
expected: p.symbol,
|
|
1415
|
-
received:
|
|
1415
|
+
received: i.parsedType
|
|
1416
1416
|
}), y;
|
|
1417
1417
|
}
|
|
1418
1418
|
return S(e.data);
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
1421
|
-
|
|
1421
|
+
xe.create = (n) => new xe({
|
|
1422
1422
|
typeName: g.ZodSymbol,
|
|
1423
1423
|
...v(n)
|
|
1424
1424
|
});
|
|
1425
1425
|
class ae extends _ {
|
|
1426
1426
|
_parse(e) {
|
|
1427
1427
|
if (this._getType(e) !== p.undefined) {
|
|
1428
|
-
const
|
|
1429
|
-
return m(
|
|
1430
|
-
code:
|
|
1428
|
+
const i = this._getOrReturnCtx(e);
|
|
1429
|
+
return m(i, {
|
|
1430
|
+
code: d.invalid_type,
|
|
1431
1431
|
expected: p.undefined,
|
|
1432
|
-
received:
|
|
1432
|
+
received: i.parsedType
|
|
1433
1433
|
}), y;
|
|
1434
1434
|
}
|
|
1435
1435
|
return S(e.data);
|
|
@@ -1439,20 +1439,20 @@ ae.create = (n) => new ae({
|
|
|
1439
1439
|
typeName: g.ZodUndefined,
|
|
1440
1440
|
...v(n)
|
|
1441
1441
|
});
|
|
1442
|
-
class
|
|
1442
|
+
class se extends _ {
|
|
1443
1443
|
_parse(e) {
|
|
1444
1444
|
if (this._getType(e) !== p.null) {
|
|
1445
|
-
const
|
|
1446
|
-
return m(
|
|
1447
|
-
code:
|
|
1445
|
+
const i = this._getOrReturnCtx(e);
|
|
1446
|
+
return m(i, {
|
|
1447
|
+
code: d.invalid_type,
|
|
1448
1448
|
expected: p.null,
|
|
1449
|
-
received:
|
|
1449
|
+
received: i.parsedType
|
|
1450
1450
|
}), y;
|
|
1451
1451
|
}
|
|
1452
1452
|
return S(e.data);
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
|
|
1455
|
+
se.create = (n) => new se({
|
|
1456
1456
|
typeName: g.ZodNull,
|
|
1457
1457
|
...v(n)
|
|
1458
1458
|
});
|
|
@@ -1484,7 +1484,7 @@ class M extends _ {
|
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
const t = this._getOrReturnCtx(e);
|
|
1486
1486
|
return m(t, {
|
|
1487
|
-
code:
|
|
1487
|
+
code: d.invalid_type,
|
|
1488
1488
|
expected: p.never,
|
|
1489
1489
|
received: t.parsedType
|
|
1490
1490
|
}), y;
|
|
@@ -1494,80 +1494,80 @@ M.create = (n) => new M({
|
|
|
1494
1494
|
typeName: g.ZodNever,
|
|
1495
1495
|
...v(n)
|
|
1496
1496
|
});
|
|
1497
|
-
class
|
|
1497
|
+
class ke extends _ {
|
|
1498
1498
|
_parse(e) {
|
|
1499
1499
|
if (this._getType(e) !== p.undefined) {
|
|
1500
|
-
const
|
|
1501
|
-
return m(
|
|
1502
|
-
code:
|
|
1500
|
+
const i = this._getOrReturnCtx(e);
|
|
1501
|
+
return m(i, {
|
|
1502
|
+
code: d.invalid_type,
|
|
1503
1503
|
expected: p.void,
|
|
1504
|
-
received:
|
|
1504
|
+
received: i.parsedType
|
|
1505
1505
|
}), y;
|
|
1506
1506
|
}
|
|
1507
1507
|
return S(e.data);
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
|
-
|
|
1510
|
+
ke.create = (n) => new ke({
|
|
1511
1511
|
typeName: g.ZodVoid,
|
|
1512
1512
|
...v(n)
|
|
1513
1513
|
});
|
|
1514
|
-
class
|
|
1514
|
+
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
|
-
const { ctx: t, status:
|
|
1516
|
+
const { ctx: t, status: i } = this._processInputParams(e), a = this._def;
|
|
1517
1517
|
if (t.parsedType !== p.array)
|
|
1518
1518
|
return m(t, {
|
|
1519
|
-
code:
|
|
1519
|
+
code: d.invalid_type,
|
|
1520
1520
|
expected: p.array,
|
|
1521
1521
|
received: t.parsedType
|
|
1522
1522
|
}), y;
|
|
1523
|
-
if (
|
|
1524
|
-
const o = t.data.length >
|
|
1523
|
+
if (a.exactLength !== null) {
|
|
1524
|
+
const o = t.data.length > a.exactLength.value, c = t.data.length < a.exactLength.value;
|
|
1525
1525
|
(o || c) && (m(t, {
|
|
1526
|
-
code: o ?
|
|
1527
|
-
minimum: c ?
|
|
1528
|
-
maximum: o ?
|
|
1526
|
+
code: o ? d.too_big : d.too_small,
|
|
1527
|
+
minimum: c ? a.exactLength.value : void 0,
|
|
1528
|
+
maximum: o ? a.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
1530
1530
|
inclusive: !0,
|
|
1531
1531
|
exact: !0,
|
|
1532
|
-
message:
|
|
1533
|
-
}),
|
|
1532
|
+
message: a.exactLength.message
|
|
1533
|
+
}), i.dirty());
|
|
1534
1534
|
}
|
|
1535
|
-
if (
|
|
1536
|
-
code:
|
|
1537
|
-
minimum:
|
|
1535
|
+
if (a.minLength !== null && t.data.length < a.minLength.value && (m(t, {
|
|
1536
|
+
code: d.too_small,
|
|
1537
|
+
minimum: a.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
|
-
message:
|
|
1542
|
-
}),
|
|
1543
|
-
code:
|
|
1544
|
-
maximum:
|
|
1541
|
+
message: a.minLength.message
|
|
1542
|
+
}), i.dirty()), a.maxLength !== null && t.data.length > a.maxLength.value && (m(t, {
|
|
1543
|
+
code: d.too_big,
|
|
1544
|
+
maximum: a.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
1547
1547
|
exact: !1,
|
|
1548
|
-
message:
|
|
1549
|
-
}),
|
|
1550
|
-
return Promise.all([...t.data].map((o, c) =>
|
|
1551
|
-
const s = [...t.data].map((o, c) =>
|
|
1552
|
-
return T.mergeArray(
|
|
1548
|
+
message: a.maxLength.message
|
|
1549
|
+
}), i.dirty()), t.common.async)
|
|
1550
|
+
return Promise.all([...t.data].map((o, c) => a.type._parseAsync(new P(t, o, t.path, c)))).then((o) => T.mergeArray(i, o));
|
|
1551
|
+
const s = [...t.data].map((o, c) => a.type._parseSync(new P(t, o, t.path, c)));
|
|
1552
|
+
return T.mergeArray(i, s);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
1555
1555
|
return this._def.type;
|
|
1556
1556
|
}
|
|
1557
1557
|
min(e, t) {
|
|
1558
|
-
return new
|
|
1558
|
+
return new C({
|
|
1559
1559
|
...this._def,
|
|
1560
1560
|
minLength: { value: e, message: h.toString(t) }
|
|
1561
1561
|
});
|
|
1562
1562
|
}
|
|
1563
1563
|
max(e, t) {
|
|
1564
|
-
return new
|
|
1564
|
+
return new C({
|
|
1565
1565
|
...this._def,
|
|
1566
1566
|
maxLength: { value: e, message: h.toString(t) }
|
|
1567
1567
|
});
|
|
1568
1568
|
}
|
|
1569
1569
|
length(e, t) {
|
|
1570
|
-
return new
|
|
1570
|
+
return new C({
|
|
1571
1571
|
...this._def,
|
|
1572
1572
|
exactLength: { value: e, message: h.toString(t) }
|
|
1573
1573
|
});
|
|
@@ -1576,7 +1576,7 @@ class j extends _ {
|
|
|
1576
1576
|
return this.min(1, e);
|
|
1577
1577
|
}
|
|
1578
1578
|
}
|
|
1579
|
-
|
|
1579
|
+
C.create = (n, e) => new C({
|
|
1580
1580
|
type: n,
|
|
1581
1581
|
minLength: null,
|
|
1582
1582
|
maxLength: null,
|
|
@@ -1588,14 +1588,14 @@ function Q(n) {
|
|
|
1588
1588
|
if (n instanceof k) {
|
|
1589
1589
|
const e = {};
|
|
1590
1590
|
for (const t in n.shape) {
|
|
1591
|
-
const
|
|
1592
|
-
e[t] = O.create(Q(
|
|
1591
|
+
const i = n.shape[t];
|
|
1592
|
+
e[t] = O.create(Q(i));
|
|
1593
1593
|
}
|
|
1594
1594
|
return new k({
|
|
1595
1595
|
...n._def,
|
|
1596
1596
|
shape: () => e
|
|
1597
1597
|
});
|
|
1598
|
-
} else return n instanceof
|
|
1598
|
+
} else return n instanceof C ? new C({
|
|
1599
1599
|
...n._def,
|
|
1600
1600
|
type: Q(n.element)
|
|
1601
1601
|
}) : n instanceof O ? O.create(Q(n.unwrap())) : n instanceof F ? F.create(Q(n.unwrap())) : n instanceof D ? D.create(n.items.map((e) => Q(e))) : n;
|
|
@@ -1607,71 +1607,71 @@ class k extends _ {
|
|
|
1607
1607
|
_getCached() {
|
|
1608
1608
|
if (this._cached !== null)
|
|
1609
1609
|
return this._cached;
|
|
1610
|
-
const e = this._def.shape(), t =
|
|
1610
|
+
const e = this._def.shape(), t = b.objectKeys(e);
|
|
1611
1611
|
return this._cached = { shape: e, keys: t };
|
|
1612
1612
|
}
|
|
1613
1613
|
_parse(e) {
|
|
1614
1614
|
if (this._getType(e) !== p.object) {
|
|
1615
|
-
const
|
|
1616
|
-
return m(
|
|
1617
|
-
code:
|
|
1615
|
+
const u = this._getOrReturnCtx(e);
|
|
1616
|
+
return m(u, {
|
|
1617
|
+
code: d.invalid_type,
|
|
1618
1618
|
expected: p.object,
|
|
1619
|
-
received:
|
|
1619
|
+
received: u.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status:
|
|
1622
|
+
const { status: i, ctx: a } = this._processInputParams(e), { shape: s, keys: o } = this._getCached(), c = [];
|
|
1623
1623
|
if (!(this._def.catchall instanceof M && this._def.unknownKeys === "strip"))
|
|
1624
|
-
for (const
|
|
1625
|
-
o.includes(
|
|
1626
|
-
const
|
|
1627
|
-
for (const
|
|
1628
|
-
const f = s[
|
|
1629
|
-
|
|
1630
|
-
key: { status: "valid", value:
|
|
1631
|
-
value: f._parse(new P(
|
|
1632
|
-
alwaysSet:
|
|
1624
|
+
for (const u in a.data)
|
|
1625
|
+
o.includes(u) || c.push(u);
|
|
1626
|
+
const l = [];
|
|
1627
|
+
for (const u of o) {
|
|
1628
|
+
const f = s[u], x = a.data[u];
|
|
1629
|
+
l.push({
|
|
1630
|
+
key: { status: "valid", value: u },
|
|
1631
|
+
value: f._parse(new P(a, x, a.path, u)),
|
|
1632
|
+
alwaysSet: u in a.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
1635
|
if (this._def.catchall instanceof M) {
|
|
1636
|
-
const
|
|
1637
|
-
if (
|
|
1636
|
+
const u = this._def.unknownKeys;
|
|
1637
|
+
if (u === "passthrough")
|
|
1638
1638
|
for (const f of c)
|
|
1639
|
-
|
|
1639
|
+
l.push({
|
|
1640
1640
|
key: { status: "valid", value: f },
|
|
1641
|
-
value: { status: "valid", value:
|
|
1641
|
+
value: { status: "valid", value: a.data[f] }
|
|
1642
1642
|
});
|
|
1643
|
-
else if (
|
|
1644
|
-
c.length > 0 && (m(
|
|
1645
|
-
code:
|
|
1643
|
+
else if (u === "strict")
|
|
1644
|
+
c.length > 0 && (m(a, {
|
|
1645
|
+
code: d.unrecognized_keys,
|
|
1646
1646
|
keys: c
|
|
1647
|
-
}),
|
|
1648
|
-
else if (
|
|
1647
|
+
}), i.dirty());
|
|
1648
|
+
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1649
1649
|
} else {
|
|
1650
|
-
const
|
|
1650
|
+
const u = this._def.catchall;
|
|
1651
1651
|
for (const f of c) {
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1652
|
+
const x = a.data[f];
|
|
1653
|
+
l.push({
|
|
1654
1654
|
key: { status: "valid", value: f },
|
|
1655
|
-
value:
|
|
1656
|
-
new P(
|
|
1655
|
+
value: u._parse(
|
|
1656
|
+
new P(a, x, a.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet: f in
|
|
1659
|
+
alwaysSet: f in a.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
-
return
|
|
1664
|
-
const
|
|
1665
|
-
for (const f of
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
key:
|
|
1663
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
1664
|
+
const u = [];
|
|
1665
|
+
for (const f of l) {
|
|
1666
|
+
const x = await f.key, w = await f.value;
|
|
1667
|
+
u.push({
|
|
1668
|
+
key: x,
|
|
1669
1669
|
value: w,
|
|
1670
1670
|
alwaysSet: f.alwaysSet
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
|
-
return
|
|
1674
|
-
}).then((
|
|
1673
|
+
return u;
|
|
1674
|
+
}).then((u) => T.mergeObjectSync(i, u)) : T.mergeObjectSync(i, l);
|
|
1675
1675
|
}
|
|
1676
1676
|
get shape() {
|
|
1677
1677
|
return this._def.shape();
|
|
@@ -1681,13 +1681,13 @@ class k extends _ {
|
|
|
1681
1681
|
...this._def,
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
|
-
errorMap: (t,
|
|
1685
|
-
var
|
|
1686
|
-
const
|
|
1684
|
+
errorMap: (t, i) => {
|
|
1685
|
+
var a, s, o, c;
|
|
1686
|
+
const l = (o = (s = (a = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(a, t, i).message) !== null && o !== void 0 ? o : i.defaultError;
|
|
1687
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1688
|
-
message: (c = h.errToObj(e).message) !== null && c !== void 0 ? c :
|
|
1688
|
+
message: (c = h.errToObj(e).message) !== null && c !== void 0 ? c : l
|
|
1689
1689
|
} : {
|
|
1690
|
-
message:
|
|
1690
|
+
message: l
|
|
1691
1691
|
};
|
|
1692
1692
|
}
|
|
1693
1693
|
} : {}
|
|
@@ -1814,8 +1814,8 @@ class k extends _ {
|
|
|
1814
1814
|
}
|
|
1815
1815
|
pick(e) {
|
|
1816
1816
|
const t = {};
|
|
1817
|
-
return
|
|
1818
|
-
e[
|
|
1817
|
+
return b.objectKeys(e).forEach((i) => {
|
|
1818
|
+
e[i] && this.shape[i] && (t[i] = this.shape[i]);
|
|
1819
1819
|
}), new k({
|
|
1820
1820
|
...this._def,
|
|
1821
1821
|
shape: () => t
|
|
@@ -1823,8 +1823,8 @@ class k extends _ {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
omit(e) {
|
|
1825
1825
|
const t = {};
|
|
1826
|
-
return
|
|
1827
|
-
e[
|
|
1826
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1827
|
+
e[i] || (t[i] = this.shape[i]);
|
|
1828
1828
|
}), new k({
|
|
1829
1829
|
...this._def,
|
|
1830
1830
|
shape: () => t
|
|
@@ -1838,9 +1838,9 @@ class k extends _ {
|
|
|
1838
1838
|
}
|
|
1839
1839
|
partial(e) {
|
|
1840
1840
|
const t = {};
|
|
1841
|
-
return
|
|
1842
|
-
const
|
|
1843
|
-
e && !e[
|
|
1841
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1842
|
+
const a = this.shape[i];
|
|
1843
|
+
e && !e[i] ? t[i] = a : t[i] = a.optional();
|
|
1844
1844
|
}), new k({
|
|
1845
1845
|
...this._def,
|
|
1846
1846
|
shape: () => t
|
|
@@ -1848,14 +1848,14 @@ class k extends _ {
|
|
|
1848
1848
|
}
|
|
1849
1849
|
required(e) {
|
|
1850
1850
|
const t = {};
|
|
1851
|
-
return
|
|
1852
|
-
if (e && !e[
|
|
1853
|
-
t[
|
|
1851
|
+
return b.objectKeys(this.shape).forEach((i) => {
|
|
1852
|
+
if (e && !e[i])
|
|
1853
|
+
t[i] = this.shape[i];
|
|
1854
1854
|
else {
|
|
1855
|
-
let s = this.shape[
|
|
1855
|
+
let s = this.shape[i];
|
|
1856
1856
|
for (; s instanceof O; )
|
|
1857
1857
|
s = s._def.innerType;
|
|
1858
|
-
t[
|
|
1858
|
+
t[i] = s;
|
|
1859
1859
|
}
|
|
1860
1860
|
}), new k({
|
|
1861
1861
|
...this._def,
|
|
@@ -1863,7 +1863,7 @@ class k extends _ {
|
|
|
1863
1863
|
});
|
|
1864
1864
|
}
|
|
1865
1865
|
keyof() {
|
|
1866
|
-
return
|
|
1866
|
+
return Ge(b.objectKeys(this.shape));
|
|
1867
1867
|
}
|
|
1868
1868
|
}
|
|
1869
1869
|
k.create = (n, e) => new k({
|
|
@@ -1887,10 +1887,10 @@ k.lazycreate = (n, e) => new k({
|
|
|
1887
1887
|
typeName: g.ZodObject,
|
|
1888
1888
|
...v(e)
|
|
1889
1889
|
});
|
|
1890
|
-
class
|
|
1890
|
+
class oe extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1893
|
-
function
|
|
1892
|
+
const { ctx: t } = this._processInputParams(e), i = this._def.options;
|
|
1893
|
+
function a(s) {
|
|
1894
1894
|
for (const c of s)
|
|
1895
1895
|
if (c.result.status === "valid")
|
|
1896
1896
|
return c.result;
|
|
@@ -1899,12 +1899,12 @@ class se extends _ {
|
|
|
1899
1899
|
return t.common.issues.push(...c.ctx.common.issues), c.result;
|
|
1900
1900
|
const o = s.map((c) => new A(c.ctx.common.issues));
|
|
1901
1901
|
return m(t, {
|
|
1902
|
-
code:
|
|
1902
|
+
code: d.invalid_union,
|
|
1903
1903
|
unionErrors: o
|
|
1904
1904
|
}), y;
|
|
1905
1905
|
}
|
|
1906
1906
|
if (t.common.async)
|
|
1907
|
-
return Promise.all(
|
|
1907
|
+
return Promise.all(i.map(async (s) => {
|
|
1908
1908
|
const o = {
|
|
1909
1909
|
...t,
|
|
1910
1910
|
common: {
|
|
@@ -1921,32 +1921,32 @@ class se extends _ {
|
|
|
1921
1921
|
}),
|
|
1922
1922
|
ctx: o
|
|
1923
1923
|
};
|
|
1924
|
-
})).then(
|
|
1924
|
+
})).then(a);
|
|
1925
1925
|
{
|
|
1926
1926
|
let s;
|
|
1927
1927
|
const o = [];
|
|
1928
|
-
for (const
|
|
1929
|
-
const
|
|
1928
|
+
for (const l of i) {
|
|
1929
|
+
const u = {
|
|
1930
1930
|
...t,
|
|
1931
1931
|
common: {
|
|
1932
1932
|
...t.common,
|
|
1933
1933
|
issues: []
|
|
1934
1934
|
},
|
|
1935
1935
|
parent: null
|
|
1936
|
-
}, f =
|
|
1936
|
+
}, f = l._parseSync({
|
|
1937
1937
|
data: t.data,
|
|
1938
1938
|
path: t.path,
|
|
1939
|
-
parent:
|
|
1939
|
+
parent: u
|
|
1940
1940
|
});
|
|
1941
1941
|
if (f.status === "valid")
|
|
1942
1942
|
return f;
|
|
1943
|
-
f.status === "dirty" && !s && (s = { result: f, ctx:
|
|
1943
|
+
f.status === "dirty" && !s && (s = { result: f, ctx: u }), u.common.issues.length && o.push(u.common.issues);
|
|
1944
1944
|
}
|
|
1945
1945
|
if (s)
|
|
1946
1946
|
return t.common.issues.push(...s.ctx.common.issues), s.result;
|
|
1947
|
-
const c = o.map((
|
|
1947
|
+
const c = o.map((l) => new A(l));
|
|
1948
1948
|
return m(t, {
|
|
1949
|
-
code:
|
|
1949
|
+
code: d.invalid_union,
|
|
1950
1950
|
unionErrors: c
|
|
1951
1951
|
}), y;
|
|
1952
1952
|
}
|
|
@@ -1955,22 +1955,22 @@ class se extends _ {
|
|
|
1955
1955
|
return this._def.options;
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
|
-
|
|
1958
|
+
oe.create = (n, e) => new oe({
|
|
1959
1959
|
options: n,
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const E = (n) => n instanceof de ? E(n.schema) : n instanceof
|
|
1964
|
-
class
|
|
1963
|
+
const E = (n) => n instanceof de ? E(n.schema) : n instanceof j ? E(n.innerType()) : n instanceof le ? [n.value] : n instanceof L ? n.options : n instanceof me ? b.objectValues(n.enum) : n instanceof pe ? E(n._def.innerType) : n instanceof ae ? [void 0] : n instanceof se ? [null] : n instanceof O ? [void 0, ...E(n.unwrap())] : n instanceof F ? [null, ...E(n.unwrap())] : n instanceof Re || n instanceof he ? E(n.unwrap()) : n instanceof fe ? E(n._def.innerType) : [];
|
|
1964
|
+
class Se extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
1967
1967
|
if (t.parsedType !== p.object)
|
|
1968
1968
|
return m(t, {
|
|
1969
|
-
code:
|
|
1969
|
+
code: d.invalid_type,
|
|
1970
1970
|
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const
|
|
1973
|
+
const i = this.discriminator, a = t.data[i], s = this.optionsMap.get(a);
|
|
1974
1974
|
return s ? t.common.async ? s._parseAsync({
|
|
1975
1975
|
data: t.data,
|
|
1976
1976
|
path: t.path,
|
|
@@ -1980,9 +1980,9 @@ class Te extends _ {
|
|
|
1980
1980
|
path: t.path,
|
|
1981
1981
|
parent: t
|
|
1982
1982
|
}) : (m(t, {
|
|
1983
|
-
code:
|
|
1983
|
+
code: d.invalid_union_discriminator,
|
|
1984
1984
|
options: Array.from(this.optionsMap.keys()),
|
|
1985
|
-
path: [
|
|
1985
|
+
path: [i]
|
|
1986
1986
|
}), y);
|
|
1987
1987
|
}
|
|
1988
1988
|
get discriminator() {
|
|
@@ -2002,86 +2002,86 @@ class Te extends _ {
|
|
|
2002
2002
|
* @param types an array of object schemas
|
|
2003
2003
|
* @param params
|
|
2004
2004
|
*/
|
|
2005
|
-
static create(e, t,
|
|
2006
|
-
const
|
|
2005
|
+
static create(e, t, i) {
|
|
2006
|
+
const a = /* @__PURE__ */ new Map();
|
|
2007
2007
|
for (const s of t) {
|
|
2008
2008
|
const o = E(s.shape[e]);
|
|
2009
2009
|
if (!o.length)
|
|
2010
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2011
2011
|
for (const c of o) {
|
|
2012
|
-
if (
|
|
2012
|
+
if (a.has(c))
|
|
2013
2013
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);
|
|
2014
|
-
|
|
2014
|
+
a.set(c, s);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
|
-
return new
|
|
2017
|
+
return new Se({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
2021
|
-
optionsMap:
|
|
2022
|
-
...v(
|
|
2021
|
+
optionsMap: a,
|
|
2022
|
+
...v(i)
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2027
|
-
const t = R(n),
|
|
2026
|
+
function De(n, e) {
|
|
2027
|
+
const t = R(n), i = R(e);
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
|
-
if (t === p.object &&
|
|
2031
|
-
const
|
|
2030
|
+
if (t === p.object && i === p.object) {
|
|
2031
|
+
const a = b.objectKeys(e), s = b.objectKeys(n).filter((c) => a.indexOf(c) !== -1), o = { ...n, ...e };
|
|
2032
2032
|
for (const c of s) {
|
|
2033
|
-
const
|
|
2034
|
-
if (!
|
|
2033
|
+
const l = De(n[c], e[c]);
|
|
2034
|
+
if (!l.valid)
|
|
2035
2035
|
return { valid: !1 };
|
|
2036
|
-
o[c] =
|
|
2036
|
+
o[c] = l.data;
|
|
2037
2037
|
}
|
|
2038
2038
|
return { valid: !0, data: o };
|
|
2039
|
-
} else if (t === p.array &&
|
|
2039
|
+
} else if (t === p.array && i === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
|
-
const
|
|
2042
|
+
const a = [];
|
|
2043
2043
|
for (let s = 0; s < n.length; s++) {
|
|
2044
|
-
const o = n[s], c = e[s],
|
|
2045
|
-
if (!
|
|
2044
|
+
const o = n[s], c = e[s], l = De(o, c);
|
|
2045
|
+
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
|
-
|
|
2047
|
+
a.push(l.data);
|
|
2048
2048
|
}
|
|
2049
|
-
return { valid: !0, data:
|
|
2050
|
-
} else return t === p.date &&
|
|
2049
|
+
return { valid: !0, data: a };
|
|
2050
|
+
} else return t === p.date && i === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
|
-
class
|
|
2052
|
+
class ce extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx:
|
|
2055
|
-
if (
|
|
2054
|
+
const { status: t, ctx: i } = this._processInputParams(e), a = (s, o) => {
|
|
2055
|
+
if (Oe(s) || Oe(o))
|
|
2056
2056
|
return y;
|
|
2057
|
-
const c =
|
|
2058
|
-
return c.valid ? ((
|
|
2059
|
-
code:
|
|
2057
|
+
const c = De(s.value, o.value);
|
|
2058
|
+
return c.valid ? ((Pe(s) || Pe(o)) && t.dirty(), { status: t.value, value: c.data }) : (m(i, {
|
|
2059
|
+
code: d.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
2062
|
-
return
|
|
2062
|
+
return i.common.async ? Promise.all([
|
|
2063
2063
|
this._def.left._parseAsync({
|
|
2064
|
-
data:
|
|
2065
|
-
path:
|
|
2066
|
-
parent:
|
|
2064
|
+
data: i.data,
|
|
2065
|
+
path: i.path,
|
|
2066
|
+
parent: i
|
|
2067
2067
|
}),
|
|
2068
2068
|
this._def.right._parseAsync({
|
|
2069
|
-
data:
|
|
2070
|
-
path:
|
|
2071
|
-
parent:
|
|
2069
|
+
data: i.data,
|
|
2070
|
+
path: i.path,
|
|
2071
|
+
parent: i
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([s, o]) =>
|
|
2074
|
-
data:
|
|
2075
|
-
path:
|
|
2076
|
-
parent:
|
|
2073
|
+
]).then(([s, o]) => a(s, o)) : a(this._def.left._parseSync({
|
|
2074
|
+
data: i.data,
|
|
2075
|
+
path: i.path,
|
|
2076
|
+
parent: i
|
|
2077
2077
|
}), this._def.right._parseSync({
|
|
2078
|
-
data:
|
|
2079
|
-
path:
|
|
2080
|
-
parent:
|
|
2078
|
+
data: i.data,
|
|
2079
|
+
path: i.path,
|
|
2080
|
+
parent: i
|
|
2081
2081
|
}));
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
|
-
|
|
2084
|
+
ce.create = (n, e, t) => new ce({
|
|
2085
2085
|
left: n,
|
|
2086
2086
|
right: e,
|
|
2087
2087
|
typeName: g.ZodIntersection,
|
|
@@ -2089,33 +2089,33 @@ oe.create = (n, e, t) => new oe({
|
|
|
2089
2089
|
});
|
|
2090
2090
|
class D extends _ {
|
|
2091
2091
|
_parse(e) {
|
|
2092
|
-
const { status: t, ctx:
|
|
2093
|
-
if (
|
|
2094
|
-
return m(
|
|
2095
|
-
code:
|
|
2092
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2093
|
+
if (i.parsedType !== p.array)
|
|
2094
|
+
return m(i, {
|
|
2095
|
+
code: d.invalid_type,
|
|
2096
2096
|
expected: p.array,
|
|
2097
|
-
received:
|
|
2097
|
+
received: i.parsedType
|
|
2098
2098
|
}), y;
|
|
2099
|
-
if (
|
|
2100
|
-
return m(
|
|
2101
|
-
code:
|
|
2099
|
+
if (i.data.length < this._def.items.length)
|
|
2100
|
+
return m(i, {
|
|
2101
|
+
code: d.too_small,
|
|
2102
2102
|
minimum: this._def.items.length,
|
|
2103
2103
|
inclusive: !0,
|
|
2104
2104
|
exact: !1,
|
|
2105
2105
|
type: "array"
|
|
2106
2106
|
}), y;
|
|
2107
|
-
!this._def.rest &&
|
|
2108
|
-
code:
|
|
2107
|
+
!this._def.rest && i.data.length > this._def.items.length && (m(i, {
|
|
2108
|
+
code: d.too_big,
|
|
2109
2109
|
maximum: this._def.items.length,
|
|
2110
2110
|
inclusive: !0,
|
|
2111
2111
|
exact: !1,
|
|
2112
2112
|
type: "array"
|
|
2113
2113
|
}), t.dirty());
|
|
2114
|
-
const s = [...
|
|
2115
|
-
const
|
|
2116
|
-
return
|
|
2114
|
+
const s = [...i.data].map((o, c) => {
|
|
2115
|
+
const l = this._def.items[c] || this._def.rest;
|
|
2116
|
+
return l ? l._parse(new P(i, o, i.path, c)) : null;
|
|
2117
2117
|
}).filter((o) => !!o);
|
|
2118
|
-
return
|
|
2118
|
+
return i.common.async ? Promise.all(s).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, s);
|
|
2119
2119
|
}
|
|
2120
2120
|
get items() {
|
|
2121
2121
|
return this._def.items;
|
|
@@ -2137,7 +2137,7 @@ D.create = (n, e) => {
|
|
|
2137
2137
|
...v(e)
|
|
2138
2138
|
});
|
|
2139
2139
|
};
|
|
2140
|
-
class
|
|
2140
|
+
class ue extends _ {
|
|
2141
2141
|
get keySchema() {
|
|
2142
2142
|
return this._def.keyType;
|
|
2143
2143
|
}
|
|
@@ -2145,40 +2145,40 @@ class ce extends _ {
|
|
|
2145
2145
|
return this._def.valueType;
|
|
2146
2146
|
}
|
|
2147
2147
|
_parse(e) {
|
|
2148
|
-
const { status: t, ctx:
|
|
2149
|
-
if (
|
|
2150
|
-
return m(
|
|
2151
|
-
code:
|
|
2148
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2149
|
+
if (i.parsedType !== p.object)
|
|
2150
|
+
return m(i, {
|
|
2151
|
+
code: d.invalid_type,
|
|
2152
2152
|
expected: p.object,
|
|
2153
|
-
received:
|
|
2153
|
+
received: i.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const
|
|
2156
|
-
for (const c in
|
|
2157
|
-
|
|
2158
|
-
key: s._parse(new P(
|
|
2159
|
-
value: o._parse(new P(
|
|
2160
|
-
alwaysSet: c in
|
|
2155
|
+
const a = [], s = this._def.keyType, o = this._def.valueType;
|
|
2156
|
+
for (const c in i.data)
|
|
2157
|
+
a.push({
|
|
2158
|
+
key: s._parse(new P(i, c, i.path, c)),
|
|
2159
|
+
value: o._parse(new P(i, i.data[c], i.path, c)),
|
|
2160
|
+
alwaysSet: c in i.data
|
|
2161
2161
|
});
|
|
2162
|
-
return
|
|
2162
|
+
return i.common.async ? T.mergeObjectAsync(t, a) : T.mergeObjectSync(t, a);
|
|
2163
2163
|
}
|
|
2164
2164
|
get element() {
|
|
2165
2165
|
return this._def.valueType;
|
|
2166
2166
|
}
|
|
2167
|
-
static create(e, t,
|
|
2168
|
-
return t instanceof _ ? new
|
|
2167
|
+
static create(e, t, i) {
|
|
2168
|
+
return t instanceof _ ? new ue({
|
|
2169
2169
|
keyType: e,
|
|
2170
2170
|
valueType: t,
|
|
2171
2171
|
typeName: g.ZodRecord,
|
|
2172
|
-
...v(
|
|
2173
|
-
}) : new
|
|
2174
|
-
keyType:
|
|
2172
|
+
...v(i)
|
|
2173
|
+
}) : new ue({
|
|
2174
|
+
keyType: N.create(),
|
|
2175
2175
|
valueType: e,
|
|
2176
2176
|
typeName: g.ZodRecord,
|
|
2177
2177
|
...v(t)
|
|
2178
2178
|
});
|
|
2179
2179
|
}
|
|
2180
2180
|
}
|
|
2181
|
-
class
|
|
2181
|
+
class we extends _ {
|
|
2182
2182
|
get keySchema() {
|
|
2183
2183
|
return this._def.keyType;
|
|
2184
2184
|
}
|
|
@@ -2186,41 +2186,41 @@ class ke extends _ {
|
|
|
2186
2186
|
return this._def.valueType;
|
|
2187
2187
|
}
|
|
2188
2188
|
_parse(e) {
|
|
2189
|
-
const { status: t, ctx:
|
|
2190
|
-
if (
|
|
2191
|
-
return m(
|
|
2192
|
-
code:
|
|
2189
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2190
|
+
if (i.parsedType !== p.map)
|
|
2191
|
+
return m(i, {
|
|
2192
|
+
code: d.invalid_type,
|
|
2193
2193
|
expected: p.map,
|
|
2194
|
-
received:
|
|
2194
|
+
received: i.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const
|
|
2197
|
-
key:
|
|
2198
|
-
value: s._parse(new P(
|
|
2196
|
+
const a = this._def.keyType, s = this._def.valueType, o = [...i.data.entries()].map(([c, l], u) => ({
|
|
2197
|
+
key: a._parse(new P(i, c, i.path, [u, "key"])),
|
|
2198
|
+
value: s._parse(new P(i, l, i.path, [u, "value"]))
|
|
2199
2199
|
}));
|
|
2200
|
-
if (
|
|
2200
|
+
if (i.common.async) {
|
|
2201
2201
|
const c = /* @__PURE__ */ new Map();
|
|
2202
2202
|
return Promise.resolve().then(async () => {
|
|
2203
|
-
for (const
|
|
2204
|
-
const
|
|
2205
|
-
if (
|
|
2203
|
+
for (const l of o) {
|
|
2204
|
+
const u = await l.key, f = await l.value;
|
|
2205
|
+
if (u.status === "aborted" || f.status === "aborted")
|
|
2206
2206
|
return y;
|
|
2207
|
-
(
|
|
2207
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2208
2208
|
}
|
|
2209
2209
|
return { status: t.value, value: c };
|
|
2210
2210
|
});
|
|
2211
2211
|
} else {
|
|
2212
2212
|
const c = /* @__PURE__ */ new Map();
|
|
2213
|
-
for (const
|
|
2214
|
-
const
|
|
2215
|
-
if (
|
|
2213
|
+
for (const l of o) {
|
|
2214
|
+
const u = l.key, f = l.value;
|
|
2215
|
+
if (u.status === "aborted" || f.status === "aborted")
|
|
2216
2216
|
return y;
|
|
2217
|
-
(
|
|
2217
|
+
(u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
|
|
2218
2218
|
}
|
|
2219
2219
|
return { status: t.value, value: c };
|
|
2220
2220
|
}
|
|
2221
2221
|
}
|
|
2222
2222
|
}
|
|
2223
|
-
|
|
2223
|
+
we.create = (n, e, t) => new we({
|
|
2224
2224
|
valueType: e,
|
|
2225
2225
|
keyType: n,
|
|
2226
2226
|
typeName: g.ZodMap,
|
|
@@ -2228,41 +2228,41 @@ ke.create = (n, e, t) => new ke({
|
|
|
2228
2228
|
});
|
|
2229
2229
|
class W extends _ {
|
|
2230
2230
|
_parse(e) {
|
|
2231
|
-
const { status: t, ctx:
|
|
2232
|
-
if (
|
|
2233
|
-
return m(
|
|
2234
|
-
code:
|
|
2231
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2232
|
+
if (i.parsedType !== p.set)
|
|
2233
|
+
return m(i, {
|
|
2234
|
+
code: d.invalid_type,
|
|
2235
2235
|
expected: p.set,
|
|
2236
|
-
received:
|
|
2236
|
+
received: i.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2240
|
-
code:
|
|
2241
|
-
minimum:
|
|
2238
|
+
const a = this._def;
|
|
2239
|
+
a.minSize !== null && i.data.size < a.minSize.value && (m(i, {
|
|
2240
|
+
code: d.too_small,
|
|
2241
|
+
minimum: a.minSize.value,
|
|
2242
2242
|
type: "set",
|
|
2243
2243
|
inclusive: !0,
|
|
2244
2244
|
exact: !1,
|
|
2245
|
-
message:
|
|
2246
|
-
}), t.dirty()),
|
|
2247
|
-
code:
|
|
2248
|
-
maximum:
|
|
2245
|
+
message: a.minSize.message
|
|
2246
|
+
}), t.dirty()), a.maxSize !== null && i.data.size > a.maxSize.value && (m(i, {
|
|
2247
|
+
code: d.too_big,
|
|
2248
|
+
maximum: a.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
|
-
message:
|
|
2252
|
+
message: a.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
2254
|
const s = this._def.valueType;
|
|
2255
|
-
function o(
|
|
2256
|
-
const
|
|
2257
|
-
for (const f of
|
|
2255
|
+
function o(l) {
|
|
2256
|
+
const u = /* @__PURE__ */ new Set();
|
|
2257
|
+
for (const f of l) {
|
|
2258
2258
|
if (f.status === "aborted")
|
|
2259
2259
|
return y;
|
|
2260
|
-
f.status === "dirty" && t.dirty(),
|
|
2260
|
+
f.status === "dirty" && t.dirty(), u.add(f.value);
|
|
2261
2261
|
}
|
|
2262
|
-
return { status: t.value, value:
|
|
2262
|
+
return { status: t.value, value: u };
|
|
2263
2263
|
}
|
|
2264
|
-
const c = [...
|
|
2265
|
-
return
|
|
2264
|
+
const c = [...i.data.values()].map((l, u) => s._parse(new P(i, l, i.path, u)));
|
|
2265
|
+
return i.common.async ? Promise.all(c).then((l) => o(l)) : o(c);
|
|
2266
2266
|
}
|
|
2267
2267
|
min(e, t) {
|
|
2268
2268
|
return new W({
|
|
@@ -2298,63 +2298,63 @@ class X extends _ {
|
|
|
2298
2298
|
const { ctx: t } = this._processInputParams(e);
|
|
2299
2299
|
if (t.parsedType !== p.function)
|
|
2300
2300
|
return m(t, {
|
|
2301
|
-
code:
|
|
2301
|
+
code: d.invalid_type,
|
|
2302
2302
|
expected: p.function,
|
|
2303
2303
|
received: t.parsedType
|
|
2304
2304
|
}), y;
|
|
2305
|
-
function
|
|
2306
|
-
return
|
|
2305
|
+
function i(c, l) {
|
|
2306
|
+
return _e({
|
|
2307
2307
|
data: c,
|
|
2308
2308
|
path: t.path,
|
|
2309
2309
|
errorMaps: [
|
|
2310
2310
|
t.common.contextualErrorMap,
|
|
2311
2311
|
t.schemaErrorMap,
|
|
2312
|
-
|
|
2312
|
+
ve(),
|
|
2313
2313
|
G
|
|
2314
|
-
].filter((
|
|
2314
|
+
].filter((u) => !!u),
|
|
2315
2315
|
issueData: {
|
|
2316
|
-
code:
|
|
2317
|
-
argumentsError:
|
|
2316
|
+
code: d.invalid_arguments,
|
|
2317
|
+
argumentsError: l
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
2320
2320
|
}
|
|
2321
|
-
function
|
|
2322
|
-
return
|
|
2321
|
+
function a(c, l) {
|
|
2322
|
+
return _e({
|
|
2323
2323
|
data: c,
|
|
2324
2324
|
path: t.path,
|
|
2325
2325
|
errorMaps: [
|
|
2326
2326
|
t.common.contextualErrorMap,
|
|
2327
2327
|
t.schemaErrorMap,
|
|
2328
|
-
|
|
2328
|
+
ve(),
|
|
2329
2329
|
G
|
|
2330
|
-
].filter((
|
|
2330
|
+
].filter((u) => !!u),
|
|
2331
2331
|
issueData: {
|
|
2332
|
-
code:
|
|
2333
|
-
returnTypeError:
|
|
2332
|
+
code: d.invalid_return_type,
|
|
2333
|
+
returnTypeError: l
|
|
2334
2334
|
}
|
|
2335
2335
|
});
|
|
2336
2336
|
}
|
|
2337
2337
|
const s = { errorMap: t.common.contextualErrorMap }, o = t.data;
|
|
2338
2338
|
if (this._def.returns instanceof H) {
|
|
2339
2339
|
const c = this;
|
|
2340
|
-
return S(async function(...
|
|
2341
|
-
const
|
|
2342
|
-
throw
|
|
2343
|
-
}),
|
|
2344
|
-
return await c._def.returns._def.type.parseAsync(
|
|
2345
|
-
throw
|
|
2340
|
+
return S(async function(...l) {
|
|
2341
|
+
const u = new A([]), f = await c._def.args.parseAsync(l, s).catch((I) => {
|
|
2342
|
+
throw u.addIssue(i(l, I)), u;
|
|
2343
|
+
}), x = await Reflect.apply(o, this, f);
|
|
2344
|
+
return await c._def.returns._def.type.parseAsync(x, s).catch((I) => {
|
|
2345
|
+
throw u.addIssue(a(x, I)), u;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
2349
2349
|
const c = this;
|
|
2350
|
-
return S(function(...
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
throw new A([
|
|
2354
|
-
const f = Reflect.apply(o, this,
|
|
2355
|
-
if (!
|
|
2356
|
-
throw new A([
|
|
2357
|
-
return
|
|
2350
|
+
return S(function(...l) {
|
|
2351
|
+
const u = c._def.args.safeParse(l, s);
|
|
2352
|
+
if (!u.success)
|
|
2353
|
+
throw new A([i(l, u.error)]);
|
|
2354
|
+
const f = Reflect.apply(o, this, u.data), x = c._def.returns.safeParse(f, s);
|
|
2355
|
+
if (!x.success)
|
|
2356
|
+
throw new A([a(f, x.error)]);
|
|
2357
|
+
return x.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
2360
2360
|
}
|
|
@@ -2382,12 +2382,12 @@ class X extends _ {
|
|
|
2382
2382
|
strictImplement(e) {
|
|
2383
2383
|
return this.parse(e);
|
|
2384
2384
|
}
|
|
2385
|
-
static create(e, t,
|
|
2385
|
+
static create(e, t, i) {
|
|
2386
2386
|
return new X({
|
|
2387
2387
|
args: e || D.create([]).rest(U.create()),
|
|
2388
2388
|
returns: t || U.create(),
|
|
2389
2389
|
typeName: g.ZodFunction,
|
|
2390
|
-
...v(
|
|
2390
|
+
...v(i)
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
@@ -2405,13 +2405,13 @@ de.create = (n, e) => new de({
|
|
|
2405
2405
|
typeName: g.ZodLazy,
|
|
2406
2406
|
...v(e)
|
|
2407
2407
|
});
|
|
2408
|
-
class
|
|
2408
|
+
class le extends _ {
|
|
2409
2409
|
_parse(e) {
|
|
2410
2410
|
if (e.data !== this._def.value) {
|
|
2411
2411
|
const t = this._getOrReturnCtx(e);
|
|
2412
2412
|
return m(t, {
|
|
2413
2413
|
received: t.data,
|
|
2414
|
-
code:
|
|
2414
|
+
code: d.invalid_literal,
|
|
2415
2415
|
expected: this._def.value
|
|
2416
2416
|
}), y;
|
|
2417
2417
|
}
|
|
@@ -2421,12 +2421,12 @@ class ue extends _ {
|
|
|
2421
2421
|
return this._def.value;
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
|
|
2424
|
+
le.create = (n, e) => new le({
|
|
2425
2425
|
value: n,
|
|
2426
2426
|
typeName: g.ZodLiteral,
|
|
2427
2427
|
...v(e)
|
|
2428
2428
|
});
|
|
2429
|
-
function
|
|
2429
|
+
function Ge(n, e) {
|
|
2430
2430
|
return new L({
|
|
2431
2431
|
values: n,
|
|
2432
2432
|
typeName: g.ZodEnum,
|
|
@@ -2435,23 +2435,23 @@ function Xe(n, e) {
|
|
|
2435
2435
|
}
|
|
2436
2436
|
class L extends _ {
|
|
2437
2437
|
constructor() {
|
|
2438
|
-
super(...arguments),
|
|
2438
|
+
super(...arguments), te.set(this, void 0);
|
|
2439
2439
|
}
|
|
2440
2440
|
_parse(e) {
|
|
2441
2441
|
if (typeof e.data != "string") {
|
|
2442
|
-
const t = this._getOrReturnCtx(e),
|
|
2442
|
+
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2443
2443
|
return m(t, {
|
|
2444
|
-
expected:
|
|
2444
|
+
expected: b.joinValues(i),
|
|
2445
2445
|
received: t.parsedType,
|
|
2446
|
-
code:
|
|
2446
|
+
code: d.invalid_type
|
|
2447
2447
|
}), y;
|
|
2448
2448
|
}
|
|
2449
|
-
if (
|
|
2450
|
-
const t = this._getOrReturnCtx(e),
|
|
2449
|
+
if (be(this, te) || We(this, te, new Set(this._def.values)), !be(this, te).has(e.data)) {
|
|
2450
|
+
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2451
2451
|
return m(t, {
|
|
2452
2452
|
received: t.data,
|
|
2453
|
-
code:
|
|
2454
|
-
options:
|
|
2453
|
+
code: d.invalid_enum_value,
|
|
2454
|
+
options: i
|
|
2455
2455
|
}), y;
|
|
2456
2456
|
}
|
|
2457
2457
|
return S(e.data);
|
|
@@ -2484,34 +2484,34 @@ class L extends _ {
|
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
exclude(e, t = this._def) {
|
|
2487
|
-
return L.create(this.options.filter((
|
|
2487
|
+
return L.create(this.options.filter((i) => !e.includes(i)), {
|
|
2488
2488
|
...this._def,
|
|
2489
2489
|
...t
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
|
-
|
|
2494
|
-
L.create =
|
|
2495
|
-
class
|
|
2493
|
+
te = /* @__PURE__ */ new WeakMap();
|
|
2494
|
+
L.create = Ge;
|
|
2495
|
+
class me extends _ {
|
|
2496
2496
|
constructor() {
|
|
2497
|
-
super(...arguments),
|
|
2497
|
+
super(...arguments), ne.set(this, void 0);
|
|
2498
2498
|
}
|
|
2499
2499
|
_parse(e) {
|
|
2500
|
-
const t =
|
|
2501
|
-
if (
|
|
2502
|
-
const
|
|
2503
|
-
return m(
|
|
2504
|
-
expected:
|
|
2505
|
-
received:
|
|
2506
|
-
code:
|
|
2500
|
+
const t = b.getValidEnumValues(this._def.values), i = this._getOrReturnCtx(e);
|
|
2501
|
+
if (i.parsedType !== p.string && i.parsedType !== p.number) {
|
|
2502
|
+
const a = b.objectValues(t);
|
|
2503
|
+
return m(i, {
|
|
2504
|
+
expected: b.joinValues(a),
|
|
2505
|
+
received: i.parsedType,
|
|
2506
|
+
code: d.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
|
-
if (
|
|
2510
|
-
const
|
|
2511
|
-
return m(
|
|
2512
|
-
received:
|
|
2513
|
-
code:
|
|
2514
|
-
options:
|
|
2509
|
+
if (be(this, ne) || We(this, ne, new Set(b.getValidEnumValues(this._def.values))), !be(this, ne).has(e.data)) {
|
|
2510
|
+
const a = b.objectValues(t);
|
|
2511
|
+
return m(i, {
|
|
2512
|
+
received: i.data,
|
|
2513
|
+
code: d.invalid_enum_value,
|
|
2514
|
+
options: a
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
2517
|
return S(e.data);
|
|
@@ -2520,8 +2520,8 @@ class le extends _ {
|
|
|
2520
2520
|
return this._def.values;
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2523
|
+
ne = /* @__PURE__ */ new WeakMap();
|
|
2524
|
+
me.create = (n, e) => new me({
|
|
2525
2525
|
values: n,
|
|
2526
2526
|
typeName: g.ZodNativeEnum,
|
|
2527
2527
|
...v(e)
|
|
@@ -2534,12 +2534,12 @@ class H extends _ {
|
|
|
2534
2534
|
const { ctx: t } = this._processInputParams(e);
|
|
2535
2535
|
if (t.parsedType !== p.promise && t.common.async === !1)
|
|
2536
2536
|
return m(t, {
|
|
2537
|
-
code:
|
|
2537
|
+
code: d.invalid_type,
|
|
2538
2538
|
expected: p.promise,
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
|
-
const
|
|
2542
|
-
return S(
|
|
2541
|
+
const i = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
+
return S(i.then((a) => this._def.type.parseAsync(a, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
@@ -2550,7 +2550,7 @@ H.create = (n, e) => new H({
|
|
|
2550
2550
|
typeName: g.ZodPromise,
|
|
2551
2551
|
...v(e)
|
|
2552
2552
|
});
|
|
2553
|
-
class
|
|
2553
|
+
class j extends _ {
|
|
2554
2554
|
innerType() {
|
|
2555
2555
|
return this._def.schema;
|
|
2556
2556
|
}
|
|
@@ -2558,82 +2558,82 @@ class Z extends _ {
|
|
|
2558
2558
|
return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2559
2559
|
}
|
|
2560
2560
|
_parse(e) {
|
|
2561
|
-
const { status: t, ctx:
|
|
2561
|
+
const { status: t, ctx: i } = this._processInputParams(e), a = this._def.effect || null, s = {
|
|
2562
2562
|
addIssue: (o) => {
|
|
2563
|
-
m(
|
|
2563
|
+
m(i, o), o.fatal ? t.abort() : t.dirty();
|
|
2564
2564
|
},
|
|
2565
2565
|
get path() {
|
|
2566
|
-
return
|
|
2566
|
+
return i.path;
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
|
-
if (s.addIssue = s.addIssue.bind(s),
|
|
2570
|
-
const o =
|
|
2571
|
-
if (
|
|
2569
|
+
if (s.addIssue = s.addIssue.bind(s), a.type === "preprocess") {
|
|
2570
|
+
const o = a.transform(i.data, s);
|
|
2571
|
+
if (i.common.async)
|
|
2572
2572
|
return Promise.resolve(o).then(async (c) => {
|
|
2573
2573
|
if (t.value === "aborted")
|
|
2574
2574
|
return y;
|
|
2575
|
-
const
|
|
2575
|
+
const l = await this._def.schema._parseAsync({
|
|
2576
2576
|
data: c,
|
|
2577
|
-
path:
|
|
2578
|
-
parent:
|
|
2577
|
+
path: i.path,
|
|
2578
|
+
parent: i
|
|
2579
2579
|
});
|
|
2580
|
-
return
|
|
2580
|
+
return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ? Y(l.value) : l;
|
|
2581
2581
|
});
|
|
2582
2582
|
{
|
|
2583
2583
|
if (t.value === "aborted")
|
|
2584
2584
|
return y;
|
|
2585
2585
|
const c = this._def.schema._parseSync({
|
|
2586
2586
|
data: o,
|
|
2587
|
-
path:
|
|
2588
|
-
parent:
|
|
2587
|
+
path: i.path,
|
|
2588
|
+
parent: i
|
|
2589
2589
|
});
|
|
2590
2590
|
return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? Y(c.value) : c;
|
|
2591
2591
|
}
|
|
2592
2592
|
}
|
|
2593
|
-
if (
|
|
2593
|
+
if (a.type === "refinement") {
|
|
2594
2594
|
const o = (c) => {
|
|
2595
|
-
const
|
|
2596
|
-
if (
|
|
2597
|
-
return Promise.resolve(
|
|
2598
|
-
if (
|
|
2595
|
+
const l = a.refinement(c, s);
|
|
2596
|
+
if (i.common.async)
|
|
2597
|
+
return Promise.resolve(l);
|
|
2598
|
+
if (l instanceof Promise)
|
|
2599
2599
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2600
2600
|
return c;
|
|
2601
2601
|
};
|
|
2602
|
-
if (
|
|
2602
|
+
if (i.common.async === !1) {
|
|
2603
2603
|
const c = this._def.schema._parseSync({
|
|
2604
|
-
data:
|
|
2605
|
-
path:
|
|
2606
|
-
parent:
|
|
2604
|
+
data: i.data,
|
|
2605
|
+
path: i.path,
|
|
2606
|
+
parent: i
|
|
2607
2607
|
});
|
|
2608
2608
|
return c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value), { status: t.value, value: c.value });
|
|
2609
2609
|
} else
|
|
2610
|
-
return this._def.schema._parseAsync({ data:
|
|
2610
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((c) => c.status === "aborted" ? y : (c.status === "dirty" && t.dirty(), o(c.value).then(() => ({ status: t.value, value: c.value }))));
|
|
2611
2611
|
}
|
|
2612
|
-
if (
|
|
2613
|
-
if (
|
|
2612
|
+
if (a.type === "transform")
|
|
2613
|
+
if (i.common.async === !1) {
|
|
2614
2614
|
const o = this._def.schema._parseSync({
|
|
2615
|
-
data:
|
|
2616
|
-
path:
|
|
2617
|
-
parent:
|
|
2615
|
+
data: i.data,
|
|
2616
|
+
path: i.path,
|
|
2617
|
+
parent: i
|
|
2618
2618
|
});
|
|
2619
2619
|
if (!q(o))
|
|
2620
2620
|
return o;
|
|
2621
|
-
const c =
|
|
2621
|
+
const c = a.transform(o.value, s);
|
|
2622
2622
|
if (c instanceof Promise)
|
|
2623
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2624
2624
|
return { status: t.value, value: c };
|
|
2625
2625
|
} else
|
|
2626
|
-
return this._def.schema._parseAsync({ data:
|
|
2627
|
-
|
|
2626
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((o) => q(o) ? Promise.resolve(a.transform(o.value, s)).then((c) => ({ status: t.value, value: c })) : o);
|
|
2627
|
+
b.assertNever(a);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
|
|
2630
|
+
j.create = (n, e, t) => new j({
|
|
2631
2631
|
schema: n,
|
|
2632
2632
|
typeName: g.ZodEffects,
|
|
2633
2633
|
effect: e,
|
|
2634
2634
|
...v(t)
|
|
2635
2635
|
});
|
|
2636
|
-
|
|
2636
|
+
j.createWithPreprocess = (n, e, t) => new j({
|
|
2637
2637
|
schema: e,
|
|
2638
2638
|
effect: { type: "preprocess", transform: n },
|
|
2639
2639
|
typeName: g.ZodEffects,
|
|
@@ -2665,12 +2665,12 @@ F.create = (n, e) => new F({
|
|
|
2665
2665
|
typeName: g.ZodNullable,
|
|
2666
2666
|
...v(e)
|
|
2667
2667
|
});
|
|
2668
|
-
class
|
|
2668
|
+
class pe extends _ {
|
|
2669
2669
|
_parse(e) {
|
|
2670
2670
|
const { ctx: t } = this._processInputParams(e);
|
|
2671
|
-
let
|
|
2672
|
-
return t.parsedType === p.undefined && (
|
|
2673
|
-
data:
|
|
2671
|
+
let i = t.data;
|
|
2672
|
+
return t.parsedType === p.undefined && (i = this._def.defaultValue()), this._def.innerType._parse({
|
|
2673
|
+
data: i,
|
|
2674
2674
|
path: t.path,
|
|
2675
2675
|
parent: t
|
|
2676
2676
|
});
|
|
@@ -2679,42 +2679,42 @@ class me extends _ {
|
|
|
2679
2679
|
return this._def.innerType;
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
|
|
2682
|
+
pe.create = (n, e) => new pe({
|
|
2683
2683
|
innerType: n,
|
|
2684
2684
|
typeName: g.ZodDefault,
|
|
2685
2685
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2686
2686
|
...v(e)
|
|
2687
2687
|
});
|
|
2688
|
-
class
|
|
2688
|
+
class fe extends _ {
|
|
2689
2689
|
_parse(e) {
|
|
2690
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2690
|
+
const { ctx: t } = this._processInputParams(e), i = {
|
|
2691
2691
|
...t,
|
|
2692
2692
|
common: {
|
|
2693
2693
|
...t.common,
|
|
2694
2694
|
issues: []
|
|
2695
2695
|
}
|
|
2696
|
-
},
|
|
2697
|
-
data:
|
|
2698
|
-
path:
|
|
2696
|
+
}, a = this._def.innerType._parse({
|
|
2697
|
+
data: i.data,
|
|
2698
|
+
path: i.path,
|
|
2699
2699
|
parent: {
|
|
2700
|
-
...
|
|
2700
|
+
...i
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return
|
|
2703
|
+
return re(a) ? a.then((s) => ({
|
|
2704
2704
|
status: "valid",
|
|
2705
2705
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2706
2706
|
get error() {
|
|
2707
|
-
return new A(
|
|
2707
|
+
return new A(i.common.issues);
|
|
2708
2708
|
},
|
|
2709
|
-
input:
|
|
2709
|
+
input: i.data
|
|
2710
2710
|
})
|
|
2711
2711
|
})) : {
|
|
2712
2712
|
status: "valid",
|
|
2713
|
-
value:
|
|
2713
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
|
-
return new A(
|
|
2715
|
+
return new A(i.common.issues);
|
|
2716
2716
|
},
|
|
2717
|
-
input:
|
|
2717
|
+
input: i.data
|
|
2718
2718
|
})
|
|
2719
2719
|
};
|
|
2720
2720
|
}
|
|
@@ -2722,35 +2722,35 @@ class pe extends _ {
|
|
|
2722
2722
|
return this._def.innerType;
|
|
2723
2723
|
}
|
|
2724
2724
|
}
|
|
2725
|
-
|
|
2725
|
+
fe.create = (n, e) => new fe({
|
|
2726
2726
|
innerType: n,
|
|
2727
2727
|
typeName: g.ZodCatch,
|
|
2728
2728
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2729
2729
|
...v(e)
|
|
2730
2730
|
});
|
|
2731
|
-
class
|
|
2731
|
+
class Te extends _ {
|
|
2732
2732
|
_parse(e) {
|
|
2733
2733
|
if (this._getType(e) !== p.nan) {
|
|
2734
|
-
const
|
|
2735
|
-
return m(
|
|
2736
|
-
code:
|
|
2734
|
+
const i = this._getOrReturnCtx(e);
|
|
2735
|
+
return m(i, {
|
|
2736
|
+
code: d.invalid_type,
|
|
2737
2737
|
expected: p.nan,
|
|
2738
|
-
received:
|
|
2738
|
+
received: i.parsedType
|
|
2739
2739
|
}), y;
|
|
2740
2740
|
}
|
|
2741
2741
|
return { status: "valid", value: e.data };
|
|
2742
2742
|
}
|
|
2743
2743
|
}
|
|
2744
|
-
|
|
2744
|
+
Te.create = (n) => new Te({
|
|
2745
2745
|
typeName: g.ZodNaN,
|
|
2746
2746
|
...v(n)
|
|
2747
2747
|
});
|
|
2748
|
-
const
|
|
2749
|
-
class
|
|
2748
|
+
const Et = Symbol("zod_brand");
|
|
2749
|
+
class Re extends _ {
|
|
2750
2750
|
_parse(e) {
|
|
2751
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2751
|
+
const { ctx: t } = this._processInputParams(e), i = t.data;
|
|
2752
2752
|
return this._def.type._parse({
|
|
2753
|
-
data:
|
|
2753
|
+
data: i,
|
|
2754
2754
|
path: t.path,
|
|
2755
2755
|
parent: t
|
|
2756
2756
|
});
|
|
@@ -2759,218 +2759,218 @@ class Ee extends _ {
|
|
|
2759
2759
|
return this._def.type;
|
|
2760
2760
|
}
|
|
2761
2761
|
}
|
|
2762
|
-
class
|
|
2762
|
+
class ge extends _ {
|
|
2763
2763
|
_parse(e) {
|
|
2764
|
-
const { status: t, ctx:
|
|
2765
|
-
if (
|
|
2764
|
+
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2765
|
+
if (i.common.async)
|
|
2766
2766
|
return (async () => {
|
|
2767
2767
|
const s = await this._def.in._parseAsync({
|
|
2768
|
-
data:
|
|
2769
|
-
path:
|
|
2770
|
-
parent:
|
|
2768
|
+
data: i.data,
|
|
2769
|
+
path: i.path,
|
|
2770
|
+
parent: i
|
|
2771
2771
|
});
|
|
2772
2772
|
return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), Y(s.value)) : this._def.out._parseAsync({
|
|
2773
2773
|
data: s.value,
|
|
2774
|
-
path:
|
|
2775
|
-
parent:
|
|
2774
|
+
path: i.path,
|
|
2775
|
+
parent: i
|
|
2776
2776
|
});
|
|
2777
2777
|
})();
|
|
2778
2778
|
{
|
|
2779
|
-
const
|
|
2780
|
-
data:
|
|
2781
|
-
path:
|
|
2782
|
-
parent:
|
|
2779
|
+
const a = this._def.in._parseSync({
|
|
2780
|
+
data: i.data,
|
|
2781
|
+
path: i.path,
|
|
2782
|
+
parent: i
|
|
2783
2783
|
});
|
|
2784
|
-
return
|
|
2784
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), {
|
|
2785
2785
|
status: "dirty",
|
|
2786
|
-
value:
|
|
2786
|
+
value: a.value
|
|
2787
2787
|
}) : this._def.out._parseSync({
|
|
2788
|
-
data:
|
|
2789
|
-
path:
|
|
2790
|
-
parent:
|
|
2788
|
+
data: a.value,
|
|
2789
|
+
path: i.path,
|
|
2790
|
+
parent: i
|
|
2791
2791
|
});
|
|
2792
2792
|
}
|
|
2793
2793
|
}
|
|
2794
2794
|
static create(e, t) {
|
|
2795
|
-
return new
|
|
2795
|
+
return new ge({
|
|
2796
2796
|
in: e,
|
|
2797
2797
|
out: t,
|
|
2798
2798
|
typeName: g.ZodPipeline
|
|
2799
2799
|
});
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
|
-
class
|
|
2802
|
+
class he extends _ {
|
|
2803
2803
|
_parse(e) {
|
|
2804
|
-
const t = this._def.innerType._parse(e),
|
|
2805
|
-
return
|
|
2804
|
+
const t = this._def.innerType._parse(e), i = (a) => (q(a) && (a.value = Object.freeze(a.value)), a);
|
|
2805
|
+
return re(t) ? t.then((a) => i(a)) : i(t);
|
|
2806
2806
|
}
|
|
2807
2807
|
unwrap() {
|
|
2808
2808
|
return this._def.innerType;
|
|
2809
2809
|
}
|
|
2810
2810
|
}
|
|
2811
|
-
|
|
2811
|
+
he.create = (n, e) => new he({
|
|
2812
2812
|
innerType: n,
|
|
2813
2813
|
typeName: g.ZodReadonly,
|
|
2814
2814
|
...v(e)
|
|
2815
2815
|
});
|
|
2816
|
-
function
|
|
2816
|
+
function Le(n, e) {
|
|
2817
2817
|
const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return n ? J.create().superRefine((
|
|
2820
|
+
function Je(n, e = {}, t) {
|
|
2821
|
+
return n ? J.create().superRefine((i, a) => {
|
|
2822
2822
|
var s, o;
|
|
2823
|
-
const c = n(
|
|
2823
|
+
const c = n(i);
|
|
2824
2824
|
if (c instanceof Promise)
|
|
2825
|
-
return c.then((
|
|
2826
|
-
var
|
|
2827
|
-
if (!
|
|
2828
|
-
const
|
|
2829
|
-
|
|
2825
|
+
return c.then((l) => {
|
|
2826
|
+
var u, f;
|
|
2827
|
+
if (!l) {
|
|
2828
|
+
const x = Le(e, i), w = (f = (u = x.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
|
|
2829
|
+
a.addIssue({ code: "custom", ...x, fatal: w });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
2832
|
if (!c) {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2833
|
+
const l = Le(e, i), u = (o = (s = l.fatal) !== null && s !== void 0 ? s : t) !== null && o !== void 0 ? o : !0;
|
|
2834
|
+
a.addIssue({ code: "custom", ...l, fatal: u });
|
|
2835
2835
|
}
|
|
2836
2836
|
}) : J.create();
|
|
2837
2837
|
}
|
|
2838
|
-
const
|
|
2838
|
+
const Rt = {
|
|
2839
2839
|
object: k.lazycreate
|
|
2840
2840
|
};
|
|
2841
2841
|
var g;
|
|
2842
2842
|
(function(n) {
|
|
2843
2843
|
n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
|
|
2844
2844
|
})(g || (g = {}));
|
|
2845
|
-
const
|
|
2845
|
+
const $t = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) =>
|
|
2848
|
-
string: (n) =>
|
|
2847
|
+
}) => Je((t) => t instanceof n, e), He = N.create, Ke = z.create, Mt = Te.create, zt = V.create, et = ie.create, Vt = B.create, Lt = xe.create, Ft = ae.create, Ut = se.create, qt = J.create, Bt = U.create, Wt = M.create, Qt = ke.create, Yt = C.create, Xt = k.create, Gt = k.strictCreate, Jt = oe.create, Ht = Se.create, Kt = ce.create, en = D.create, tn = ue.create, nn = we.create, rn = W.create, an = X.create, sn = de.create, on = le.create, cn = L.create, un = me.create, dn = H.create, Fe = j.create, ln = O.create, mn = F.create, pn = j.createWithPreprocess, fn = ge.create, hn = () => He().optional(), gn = () => Ke().optional(), yn = () => et().optional(), vn = {
|
|
2848
|
+
string: (n) => N.create({ ...n, coerce: !0 }),
|
|
2849
2849
|
number: (n) => z.create({ ...n, coerce: !0 }),
|
|
2850
|
-
boolean: (n) =>
|
|
2850
|
+
boolean: (n) => ie.create({
|
|
2851
2851
|
...n,
|
|
2852
2852
|
coerce: !0
|
|
2853
2853
|
}),
|
|
2854
2854
|
bigint: (n) => V.create({ ...n, coerce: !0 }),
|
|
2855
2855
|
date: (n) => B.create({ ...n, coerce: !0 })
|
|
2856
|
-
},
|
|
2856
|
+
}, _n = y;
|
|
2857
2857
|
var r = /* @__PURE__ */ Object.freeze({
|
|
2858
2858
|
__proto__: null,
|
|
2859
2859
|
defaultErrorMap: G,
|
|
2860
|
-
setErrorMap:
|
|
2861
|
-
getErrorMap:
|
|
2862
|
-
makeIssue:
|
|
2863
|
-
EMPTY_PATH:
|
|
2860
|
+
setErrorMap: mt,
|
|
2861
|
+
getErrorMap: ve,
|
|
2862
|
+
makeIssue: _e,
|
|
2863
|
+
EMPTY_PATH: pt,
|
|
2864
2864
|
addIssueToContext: m,
|
|
2865
2865
|
ParseStatus: T,
|
|
2866
2866
|
INVALID: y,
|
|
2867
2867
|
DIRTY: Y,
|
|
2868
2868
|
OK: S,
|
|
2869
|
-
isAborted:
|
|
2870
|
-
isDirty:
|
|
2869
|
+
isAborted: Oe,
|
|
2870
|
+
isDirty: Pe,
|
|
2871
2871
|
isValid: q,
|
|
2872
|
-
isAsync:
|
|
2872
|
+
isAsync: re,
|
|
2873
2873
|
get util() {
|
|
2874
|
-
return
|
|
2874
|
+
return b;
|
|
2875
2875
|
},
|
|
2876
2876
|
get objectUtil() {
|
|
2877
|
-
return
|
|
2877
|
+
return Ze;
|
|
2878
2878
|
},
|
|
2879
2879
|
ZodParsedType: p,
|
|
2880
2880
|
getParsedType: R,
|
|
2881
2881
|
ZodType: _,
|
|
2882
|
-
datetimeRegex:
|
|
2883
|
-
ZodString:
|
|
2882
|
+
datetimeRegex: Xe,
|
|
2883
|
+
ZodString: N,
|
|
2884
2884
|
ZodNumber: z,
|
|
2885
2885
|
ZodBigInt: V,
|
|
2886
|
-
ZodBoolean:
|
|
2886
|
+
ZodBoolean: ie,
|
|
2887
2887
|
ZodDate: B,
|
|
2888
|
-
ZodSymbol:
|
|
2888
|
+
ZodSymbol: xe,
|
|
2889
2889
|
ZodUndefined: ae,
|
|
2890
|
-
ZodNull:
|
|
2890
|
+
ZodNull: se,
|
|
2891
2891
|
ZodAny: J,
|
|
2892
2892
|
ZodUnknown: U,
|
|
2893
2893
|
ZodNever: M,
|
|
2894
|
-
ZodVoid:
|
|
2895
|
-
ZodArray:
|
|
2894
|
+
ZodVoid: ke,
|
|
2895
|
+
ZodArray: C,
|
|
2896
2896
|
ZodObject: k,
|
|
2897
|
-
ZodUnion:
|
|
2898
|
-
ZodDiscriminatedUnion:
|
|
2899
|
-
ZodIntersection:
|
|
2897
|
+
ZodUnion: oe,
|
|
2898
|
+
ZodDiscriminatedUnion: Se,
|
|
2899
|
+
ZodIntersection: ce,
|
|
2900
2900
|
ZodTuple: D,
|
|
2901
|
-
ZodRecord:
|
|
2902
|
-
ZodMap:
|
|
2901
|
+
ZodRecord: ue,
|
|
2902
|
+
ZodMap: we,
|
|
2903
2903
|
ZodSet: W,
|
|
2904
2904
|
ZodFunction: X,
|
|
2905
2905
|
ZodLazy: de,
|
|
2906
|
-
ZodLiteral:
|
|
2906
|
+
ZodLiteral: le,
|
|
2907
2907
|
ZodEnum: L,
|
|
2908
|
-
ZodNativeEnum:
|
|
2908
|
+
ZodNativeEnum: me,
|
|
2909
2909
|
ZodPromise: H,
|
|
2910
|
-
ZodEffects:
|
|
2911
|
-
ZodTransformer:
|
|
2910
|
+
ZodEffects: j,
|
|
2911
|
+
ZodTransformer: j,
|
|
2912
2912
|
ZodOptional: O,
|
|
2913
2913
|
ZodNullable: F,
|
|
2914
|
-
ZodDefault:
|
|
2915
|
-
ZodCatch:
|
|
2916
|
-
ZodNaN:
|
|
2917
|
-
BRAND:
|
|
2918
|
-
ZodBranded:
|
|
2919
|
-
ZodPipeline:
|
|
2920
|
-
ZodReadonly:
|
|
2921
|
-
custom:
|
|
2914
|
+
ZodDefault: pe,
|
|
2915
|
+
ZodCatch: fe,
|
|
2916
|
+
ZodNaN: Te,
|
|
2917
|
+
BRAND: Et,
|
|
2918
|
+
ZodBranded: Re,
|
|
2919
|
+
ZodPipeline: ge,
|
|
2920
|
+
ZodReadonly: he,
|
|
2921
|
+
custom: Je,
|
|
2922
2922
|
Schema: _,
|
|
2923
2923
|
ZodSchema: _,
|
|
2924
|
-
late:
|
|
2924
|
+
late: Rt,
|
|
2925
2925
|
get ZodFirstPartyTypeKind() {
|
|
2926
2926
|
return g;
|
|
2927
2927
|
},
|
|
2928
|
-
coerce:
|
|
2929
|
-
any:
|
|
2930
|
-
array:
|
|
2931
|
-
bigint:
|
|
2932
|
-
boolean:
|
|
2933
|
-
date:
|
|
2934
|
-
discriminatedUnion:
|
|
2935
|
-
effect:
|
|
2936
|
-
enum:
|
|
2937
|
-
function:
|
|
2938
|
-
instanceof:
|
|
2939
|
-
intersection:
|
|
2940
|
-
lazy:
|
|
2941
|
-
literal:
|
|
2942
|
-
map:
|
|
2943
|
-
nan:
|
|
2944
|
-
nativeEnum:
|
|
2945
|
-
never:
|
|
2946
|
-
null:
|
|
2947
|
-
nullable:
|
|
2948
|
-
number:
|
|
2949
|
-
object:
|
|
2950
|
-
oboolean:
|
|
2951
|
-
onumber:
|
|
2952
|
-
optional:
|
|
2953
|
-
ostring:
|
|
2954
|
-
pipeline:
|
|
2955
|
-
preprocess:
|
|
2928
|
+
coerce: vn,
|
|
2929
|
+
any: qt,
|
|
2930
|
+
array: Yt,
|
|
2931
|
+
bigint: zt,
|
|
2932
|
+
boolean: et,
|
|
2933
|
+
date: Vt,
|
|
2934
|
+
discriminatedUnion: Ht,
|
|
2935
|
+
effect: Fe,
|
|
2936
|
+
enum: cn,
|
|
2937
|
+
function: an,
|
|
2938
|
+
instanceof: $t,
|
|
2939
|
+
intersection: Kt,
|
|
2940
|
+
lazy: sn,
|
|
2941
|
+
literal: on,
|
|
2942
|
+
map: nn,
|
|
2943
|
+
nan: Mt,
|
|
2944
|
+
nativeEnum: un,
|
|
2945
|
+
never: Wt,
|
|
2946
|
+
null: Ut,
|
|
2947
|
+
nullable: mn,
|
|
2948
|
+
number: Ke,
|
|
2949
|
+
object: Xt,
|
|
2950
|
+
oboolean: yn,
|
|
2951
|
+
onumber: gn,
|
|
2952
|
+
optional: ln,
|
|
2953
|
+
ostring: hn,
|
|
2954
|
+
pipeline: fn,
|
|
2955
|
+
preprocess: pn,
|
|
2956
2956
|
promise: dn,
|
|
2957
|
-
record:
|
|
2958
|
-
set:
|
|
2959
|
-
strictObject:
|
|
2960
|
-
string:
|
|
2961
|
-
symbol:
|
|
2962
|
-
transformer:
|
|
2963
|
-
tuple:
|
|
2964
|
-
undefined:
|
|
2965
|
-
union:
|
|
2966
|
-
unknown:
|
|
2967
|
-
void:
|
|
2968
|
-
NEVER:
|
|
2969
|
-
ZodIssueCode:
|
|
2970
|
-
quotelessJson:
|
|
2957
|
+
record: tn,
|
|
2958
|
+
set: rn,
|
|
2959
|
+
strictObject: Gt,
|
|
2960
|
+
string: He,
|
|
2961
|
+
symbol: Lt,
|
|
2962
|
+
transformer: Fe,
|
|
2963
|
+
tuple: en,
|
|
2964
|
+
undefined: Ft,
|
|
2965
|
+
union: Jt,
|
|
2966
|
+
unknown: Bt,
|
|
2967
|
+
void: Qt,
|
|
2968
|
+
NEVER: _n,
|
|
2969
|
+
ZodIssueCode: d,
|
|
2970
|
+
quotelessJson: lt,
|
|
2971
2971
|
ZodError: A
|
|
2972
2972
|
});
|
|
2973
|
-
const
|
|
2973
|
+
const Ie = r.object({
|
|
2974
2974
|
country: r.string().optional(),
|
|
2975
2975
|
city: r.string().optional(),
|
|
2976
2976
|
street: r.string().optional(),
|
|
@@ -2979,37 +2979,37 @@ const Se = r.object({
|
|
|
2979
2979
|
apartmentEnterNumber: r.string().optional(),
|
|
2980
2980
|
apartmentNumber: r.string().optional(),
|
|
2981
2981
|
zip: r.string().optional()
|
|
2982
|
-
}), $ = r.string().min(1, { message: "שדה חובה" }),
|
|
2983
|
-
function
|
|
2982
|
+
}), $ = r.string().min(1, { message: "שדה חובה" }), Un = r.string().regex(/^\d+$/, "Must be a numeric string"), qn = r.object({ url: r.string().url(), id: r.string() });
|
|
2983
|
+
function Bn(n) {
|
|
2984
2984
|
return !!(n != null && n.url);
|
|
2985
2985
|
}
|
|
2986
|
-
const
|
|
2986
|
+
const ye = r.object({
|
|
2987
2987
|
lang: r.enum(["he"]),
|
|
2988
2988
|
value: r.string()
|
|
2989
|
-
}),
|
|
2989
|
+
}), tt = r.object({
|
|
2990
2990
|
id: r.string().min(1),
|
|
2991
2991
|
companyId: r.string().min(1),
|
|
2992
2992
|
storeId: r.string().min(1),
|
|
2993
2993
|
parentId: r.string().nullish(),
|
|
2994
2994
|
tag: r.string().optional(),
|
|
2995
|
-
locales: r.array(
|
|
2995
|
+
locales: r.array(ye),
|
|
2996
2996
|
depth: r.number()
|
|
2997
|
-
}),
|
|
2998
|
-
children: r.lazy(() =>
|
|
2999
|
-
}),
|
|
2997
|
+
}), $e = tt.extend({
|
|
2998
|
+
children: r.lazy(() => $e.array())
|
|
2999
|
+
}), Wn = tt.extend({
|
|
3000
3000
|
index: r.number(),
|
|
3001
3001
|
depth: r.number(),
|
|
3002
3002
|
collapsed: r.boolean().optional(),
|
|
3003
|
-
children: r.array(
|
|
3004
|
-
}),
|
|
3003
|
+
children: r.array($e)
|
|
3004
|
+
}), ee = r.string().min(1), Me = r.object({
|
|
3005
3005
|
type: r.literal("Product"),
|
|
3006
|
-
storeId:
|
|
3007
|
-
companyId:
|
|
3008
|
-
id:
|
|
3009
|
-
objectID:
|
|
3010
|
-
sku:
|
|
3011
|
-
name: r.array(
|
|
3012
|
-
description: r.array(
|
|
3006
|
+
storeId: ee,
|
|
3007
|
+
companyId: ee,
|
|
3008
|
+
id: ee,
|
|
3009
|
+
objectID: ee,
|
|
3010
|
+
sku: ee,
|
|
3011
|
+
name: r.array(ye),
|
|
3012
|
+
description: r.array(ye),
|
|
3013
3013
|
isPublished: r.boolean(),
|
|
3014
3014
|
vat: r.boolean(),
|
|
3015
3015
|
priceType: r.object({
|
|
@@ -3038,7 +3038,7 @@ const ge = r.object({
|
|
|
3038
3038
|
brand: r.string(),
|
|
3039
3039
|
importer: r.string(),
|
|
3040
3040
|
supplier: r.string(),
|
|
3041
|
-
ingredients: r.array(
|
|
3041
|
+
ingredients: r.array(ye),
|
|
3042
3042
|
created_at: r.number(),
|
|
3043
3043
|
updated_at: r.number(),
|
|
3044
3044
|
categoryIds: r.array(r.string().nonempty()),
|
|
@@ -3047,7 +3047,7 @@ const ge = r.object({
|
|
|
3047
3047
|
unit: r.enum(["piece", "kg", "gram", "liter", "ml"])
|
|
3048
3048
|
}).optional(),
|
|
3049
3049
|
// @deprecated
|
|
3050
|
-
categoryList: r.array(
|
|
3050
|
+
categoryList: r.array($e).optional(),
|
|
3051
3051
|
// @deprecated
|
|
3052
3052
|
categories: r.object({
|
|
3053
3053
|
lvl0: r.array(r.string()),
|
|
@@ -3058,41 +3058,41 @@ const ge = r.object({
|
|
|
3058
3058
|
}).optional(),
|
|
3059
3059
|
// @deprecated
|
|
3060
3060
|
categoryNames: r.array(r.string()).optional()
|
|
3061
|
-
}),
|
|
3061
|
+
}), Qn = Me.extend({
|
|
3062
3062
|
image: r.instanceof(File).optional()
|
|
3063
|
-
}),
|
|
3064
|
-
product:
|
|
3063
|
+
}), bn = r.enum(["delivered", "missing", "substituted"]), xn = r.object({
|
|
3064
|
+
product: Me,
|
|
3065
3065
|
amount: r.number().positive(),
|
|
3066
3066
|
price: r.number()
|
|
3067
|
-
}),
|
|
3068
|
-
product:
|
|
3067
|
+
}), nt = r.object({
|
|
3068
|
+
product: Me,
|
|
3069
3069
|
originalPrice: r.number().optional(),
|
|
3070
3070
|
finalPrice: r.number().optional(),
|
|
3071
3071
|
finalDiscount: r.number().optional(),
|
|
3072
3072
|
amount: r.number().positive({ message: "Quantity must be a positive number." }),
|
|
3073
3073
|
// Picking / fulfillment — optional so existing items stay valid (treated as "delivered").
|
|
3074
|
-
status:
|
|
3075
|
-
substitutedWith:
|
|
3076
|
-
}),
|
|
3074
|
+
status: bn.optional(),
|
|
3075
|
+
substitutedWith: xn.nullable().optional()
|
|
3076
|
+
}), Yn = r.object({
|
|
3077
3077
|
type: r.literal("Cart"),
|
|
3078
3078
|
id: r.string().uuid(),
|
|
3079
3079
|
companyId: r.string().uuid(),
|
|
3080
3080
|
storeId: r.string().uuid(),
|
|
3081
3081
|
userId: r.string().uuid(),
|
|
3082
3082
|
status: r.enum(["active", "draft", "completed"]),
|
|
3083
|
-
items: r.array(
|
|
3084
|
-
}),
|
|
3083
|
+
items: r.array(nt)
|
|
3084
|
+
}), Xn = r.object({
|
|
3085
3085
|
id: r.string(),
|
|
3086
3086
|
name: r.string(),
|
|
3087
3087
|
websiteDomains: r.array(r.string())
|
|
3088
|
-
}),
|
|
3088
|
+
}), Gn = r.object({
|
|
3089
3089
|
type: r.literal("FavoriteProduct"),
|
|
3090
3090
|
id: r.string().uuid(),
|
|
3091
3091
|
companyId: r.string().uuid(),
|
|
3092
3092
|
storeId: r.string().uuid(),
|
|
3093
3093
|
userId: r.string().uuid(),
|
|
3094
3094
|
productId: r.string().uuid()
|
|
3095
|
-
}),
|
|
3095
|
+
}), Ae = r.enum(["external", "j5", "none"]), kn = r.object({
|
|
3096
3096
|
type: r.literal("Profile"),
|
|
3097
3097
|
id: $,
|
|
3098
3098
|
companyId: $,
|
|
@@ -3104,17 +3104,17 @@ const ge = r.object({
|
|
|
3104
3104
|
displayName: $,
|
|
3105
3105
|
email: r.string().email(),
|
|
3106
3106
|
phoneNumber: r.string().optional(),
|
|
3107
|
-
address:
|
|
3107
|
+
address: Ie.optional(),
|
|
3108
3108
|
isAnonymous: r.boolean(),
|
|
3109
3109
|
createdDate: r.number(),
|
|
3110
3110
|
lastActivityDate: r.number(),
|
|
3111
3111
|
//todo
|
|
3112
|
-
paymentType:
|
|
3112
|
+
paymentType: Ae.optional(),
|
|
3113
3113
|
/** @deprecated Use organizationIds instead */
|
|
3114
3114
|
organizationId: r.string().optional().nullable(),
|
|
3115
3115
|
/** Array of organization IDs this user belongs to */
|
|
3116
3116
|
organizationIds: r.array(r.string()).optional()
|
|
3117
|
-
}),
|
|
3117
|
+
}), rt = r.object({
|
|
3118
3118
|
_COMMENT: r.string().optional(),
|
|
3119
3119
|
transaction_id: r.string(),
|
|
3120
3120
|
date: r.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
|
|
@@ -3126,7 +3126,7 @@ const ge = r.object({
|
|
|
3126
3126
|
price_discount_in_currency: r.number(),
|
|
3127
3127
|
price_total: r.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
|
|
3128
3128
|
price_total_in_currency: r.number().positive()
|
|
3129
|
-
}),
|
|
3129
|
+
}), wn = r.object({
|
|
3130
3130
|
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3131
3131
|
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3132
3132
|
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
@@ -3134,10 +3134,10 @@ const ge = r.object({
|
|
|
3134
3134
|
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3135
3135
|
success: r.boolean(),
|
|
3136
3136
|
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3137
|
-
calculatedData:
|
|
3137
|
+
calculatedData: rt,
|
|
3138
3138
|
warning: r.string().optional(),
|
|
3139
3139
|
date: r.number().optional()
|
|
3140
|
-
}),
|
|
3140
|
+
}), Tn = r.object({
|
|
3141
3141
|
id: r.string().min(1, "ID is required"),
|
|
3142
3142
|
number: r.string().min(1, "Number is required"),
|
|
3143
3143
|
date: r.number().min(1, "Date is required"),
|
|
@@ -3166,47 +3166,47 @@ const ge = r.object({
|
|
|
3166
3166
|
total: r.number().min(1, "Total is required").optional(),
|
|
3167
3167
|
vat: r.number().min(1, "VAT is required").optional(),
|
|
3168
3168
|
link: r.string().url("Link must be a valid URL").optional()
|
|
3169
|
-
}),
|
|
3169
|
+
}), Sn = r.enum([
|
|
3170
3170
|
"credit",
|
|
3171
3171
|
"net15",
|
|
3172
3172
|
"net30",
|
|
3173
3173
|
"net60",
|
|
3174
3174
|
"net90"
|
|
3175
|
-
]),
|
|
3175
|
+
]), it = r.object({
|
|
3176
3176
|
number: r.string(),
|
|
3177
3177
|
name: r.string(),
|
|
3178
3178
|
id: r.string(),
|
|
3179
3179
|
// Optional, admin-managed billing config (see company-edit-like-demo plan, Phase 2)
|
|
3180
|
-
payTerms:
|
|
3180
|
+
payTerms: Sn.optional(),
|
|
3181
3181
|
creditLimit: r.number().optional(),
|
|
3182
3182
|
isPrimary: r.boolean().optional(),
|
|
3183
3183
|
// Optional category restriction — when `restricted`, the account is limited to
|
|
3184
3184
|
// `allowedCategories` (category ids). Order-time enforcement is a separate concern.
|
|
3185
3185
|
restricted: r.boolean().optional(),
|
|
3186
3186
|
allowedCategories: r.array(r.string()).optional()
|
|
3187
|
-
}),
|
|
3187
|
+
}), In = r.object({
|
|
3188
3188
|
id: r.string(),
|
|
3189
3189
|
label: r.string(),
|
|
3190
3190
|
address: r.string().optional(),
|
|
3191
3191
|
phone: r.string().optional(),
|
|
3192
3192
|
isPrimary: r.boolean().optional()
|
|
3193
|
-
}),
|
|
3193
|
+
}), An = r.object({
|
|
3194
3194
|
id: r.string(),
|
|
3195
3195
|
name: r.string(),
|
|
3196
3196
|
discountPercentage: r.number().positive().min(0).max(100).optional(),
|
|
3197
3197
|
nameOnInvoice: r.string().optional(),
|
|
3198
|
-
billingAccounts: r.array(
|
|
3199
|
-
paymentType:
|
|
3198
|
+
billingAccounts: r.array(it),
|
|
3199
|
+
paymentType: Ae,
|
|
3200
3200
|
companyNumber: r.string().optional(),
|
|
3201
|
-
address:
|
|
3201
|
+
address: Ie.optional(),
|
|
3202
3202
|
groupId: r.string().optional(),
|
|
3203
3203
|
// Contact / billing details (admin-managed, optional — see company-edit-like-demo plan)
|
|
3204
3204
|
phone: r.string().optional(),
|
|
3205
3205
|
email: r.string().optional(),
|
|
3206
3206
|
notes: r.string().optional(),
|
|
3207
3207
|
freeShipping: r.boolean().optional(),
|
|
3208
|
-
branches: r.array(
|
|
3209
|
-
}),
|
|
3208
|
+
branches: r.array(In).optional()
|
|
3209
|
+
}), Jn = An.omit({ id: !0 }), Ue = r.object({
|
|
3210
3210
|
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3211
3211
|
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3212
3212
|
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
@@ -3214,10 +3214,10 @@ const ge = r.object({
|
|
|
3214
3214
|
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3215
3215
|
success: r.boolean(),
|
|
3216
3216
|
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3217
|
-
calculatedData:
|
|
3217
|
+
calculatedData: rt,
|
|
3218
3218
|
warning: r.string().optional(),
|
|
3219
3219
|
date: r.number().optional()
|
|
3220
|
-
}),
|
|
3220
|
+
}), Nn = r.object({
|
|
3221
3221
|
id: r.string().min(1, "ID is required"),
|
|
3222
3222
|
number: r.string().min(1, "Number is required"),
|
|
3223
3223
|
date: r.string().min(1, "Date is required"),
|
|
@@ -3246,7 +3246,7 @@ const ge = r.object({
|
|
|
3246
3246
|
total: r.number().min(1, "Total is required").optional(),
|
|
3247
3247
|
vat: r.number().min(1, "VAT is required").optional(),
|
|
3248
3248
|
link: r.string().url("Link must be a valid URL").optional()
|
|
3249
|
-
}),
|
|
3249
|
+
}), Hn = r.object({
|
|
3250
3250
|
type: r.literal("Order"),
|
|
3251
3251
|
createdBy: r.enum(["user", "admin"]).optional(),
|
|
3252
3252
|
id: $,
|
|
@@ -3267,12 +3267,12 @@ const ge = r.object({
|
|
|
3267
3267
|
"completed",
|
|
3268
3268
|
"refunded"
|
|
3269
3269
|
]),
|
|
3270
|
-
paymentType:
|
|
3270
|
+
paymentType: Ae.optional(),
|
|
3271
3271
|
paymentStatus: r.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
|
|
3272
3272
|
//todo check if hyp support partial refund
|
|
3273
3273
|
cart: r.object({
|
|
3274
3274
|
id: r.string(),
|
|
3275
|
-
items: r.array(
|
|
3275
|
+
items: r.array(nt),
|
|
3276
3276
|
cartDiscount: r.number(),
|
|
3277
3277
|
cartTotal: r.number(),
|
|
3278
3278
|
cartVat: r.number(),
|
|
@@ -3294,8 +3294,8 @@ const ge = r.object({
|
|
|
3294
3294
|
// what store charge
|
|
3295
3295
|
date: r.number(),
|
|
3296
3296
|
deliveryDate: r.coerce.number(),
|
|
3297
|
-
client:
|
|
3298
|
-
address:
|
|
3297
|
+
client: kn.optional(),
|
|
3298
|
+
address: Ie.optional(),
|
|
3299
3299
|
nameOnInvoice: r.string().optional(),
|
|
3300
3300
|
emailOnInvoice: r.string().email().optional(),
|
|
3301
3301
|
phoneNumberOnInvoice: r.string().optional(),
|
|
@@ -3315,11 +3315,11 @@ const ge = r.object({
|
|
|
3315
3315
|
// הזמנת רכש
|
|
3316
3316
|
outOfStockPolicy: r.enum(["substitute", "remove"]).optional(),
|
|
3317
3317
|
organizationId: r.string().optional(),
|
|
3318
|
-
billingAccount:
|
|
3319
|
-
deliveryNote:
|
|
3320
|
-
invoice:
|
|
3321
|
-
ezInvoice:
|
|
3322
|
-
ezDeliveryNote:
|
|
3318
|
+
billingAccount: it.optional(),
|
|
3319
|
+
deliveryNote: Tn.optional(),
|
|
3320
|
+
invoice: Nn.optional(),
|
|
3321
|
+
ezInvoice: Ue.optional(),
|
|
3322
|
+
ezDeliveryNote: wn.optional(),
|
|
3323
3323
|
/**
|
|
3324
3324
|
* Set when an admin records a full payment against o.invoice / o.ezInvoice.
|
|
3325
3325
|
* Epoch millis. Absent means no payment has been recorded via the admin payment flow.
|
|
@@ -3331,11 +3331,11 @@ const ge = r.object({
|
|
|
3331
3331
|
* Mirrors EzInvoiceSchema shape (doc_uuid, pdf_link, doc_number, …).
|
|
3332
3332
|
* Present only after a successful recordInvoicePayment call.
|
|
3333
3333
|
*/
|
|
3334
|
-
ezReceipt:
|
|
3334
|
+
ezReceipt: Ue.optional(),
|
|
3335
3335
|
// Audit: who last changed the order + when (epoch millis). Stamped by admin writes.
|
|
3336
3336
|
updatedBy: r.string().optional(),
|
|
3337
3337
|
updatedAt: r.number().optional()
|
|
3338
|
-
}),
|
|
3338
|
+
}), Cn = r.enum(["individual", "company"]), Kn = r.object({
|
|
3339
3339
|
id: r.string(),
|
|
3340
3340
|
companyId: r.string(),
|
|
3341
3341
|
name: r.string(),
|
|
@@ -3343,20 +3343,20 @@ const ge = r.object({
|
|
|
3343
3343
|
logoUrl: r.string(),
|
|
3344
3344
|
tenantId: r.string(),
|
|
3345
3345
|
// firebase auth tenantId
|
|
3346
|
-
paymentType:
|
|
3346
|
+
paymentType: Ae,
|
|
3347
3347
|
allowAnonymousClients: r.boolean(),
|
|
3348
3348
|
isVatIncludedInPrice: r.boolean(),
|
|
3349
|
-
clientTypes: r.array(
|
|
3349
|
+
clientTypes: r.array(Cn),
|
|
3350
3350
|
minimumOrder: r.number().optional(),
|
|
3351
3351
|
freeDeliveryPrice: r.number().optional(),
|
|
3352
3352
|
deliveryPrice: r.number().optional(),
|
|
3353
|
-
address:
|
|
3353
|
+
address: Ie.optional(),
|
|
3354
3354
|
companyNumber: r.string().optional()
|
|
3355
3355
|
// חפ של החברה
|
|
3356
|
-
}),
|
|
3356
|
+
}), jn = r.object({
|
|
3357
3357
|
minSpend: r.number().positive().optional(),
|
|
3358
3358
|
stackable: r.boolean().default(!1)
|
|
3359
|
-
}).optional(),
|
|
3359
|
+
}).optional(), Zn = r.discriminatedUnion("variantType", [
|
|
3360
3360
|
r.object({
|
|
3361
3361
|
variantType: r.literal("bundle"),
|
|
3362
3362
|
productsId: r.array(r.string().nonempty()).min(1),
|
|
@@ -3366,7 +3366,7 @@ const ge = r.object({
|
|
|
3366
3366
|
bundlePrice: r.number().positive()
|
|
3367
3367
|
// Total price for the bundle (e.g., $25)
|
|
3368
3368
|
})
|
|
3369
|
-
]),
|
|
3369
|
+
]), er = r.object({
|
|
3370
3370
|
type: r.literal("Discount"),
|
|
3371
3371
|
storeId: r.string().min(1),
|
|
3372
3372
|
companyId: r.string().min(1),
|
|
@@ -3375,28 +3375,28 @@ const ge = r.object({
|
|
|
3375
3375
|
active: r.boolean(),
|
|
3376
3376
|
startDate: r.number(),
|
|
3377
3377
|
endDate: r.number(),
|
|
3378
|
-
variant:
|
|
3379
|
-
conditions:
|
|
3378
|
+
variant: Zn,
|
|
3379
|
+
conditions: jn
|
|
3380
3380
|
});
|
|
3381
|
-
class
|
|
3381
|
+
class On {
|
|
3382
3382
|
canApply(e, t) {
|
|
3383
3383
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3384
|
-
const { productsId:
|
|
3385
|
-
return this.getTotalQuantity(t.cart,
|
|
3384
|
+
const { productsId: i, requiredQuantity: a } = e.variant;
|
|
3385
|
+
return this.getTotalQuantity(t.cart, i) >= a;
|
|
3386
3386
|
}
|
|
3387
3387
|
calculate(e, t) {
|
|
3388
3388
|
if (e.variant.variantType !== "bundle")
|
|
3389
3389
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3390
|
-
const { productsId:
|
|
3391
|
-
if (
|
|
3390
|
+
const { productsId: i, requiredQuantity: a, bundlePrice: s } = e.variant, o = t.cart.filter((K) => i.includes(K.product.id)), c = this.getTotalQuantity(t.cart, i), l = Math.floor(c / a);
|
|
3391
|
+
if (l === 0)
|
|
3392
3392
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3393
|
-
const
|
|
3394
|
-
|
|
3393
|
+
const u = this.calculateOriginalPrice(o), f = this.getTotalQuantity(t.cart, i), x = this.calculateDiscountedPrice(
|
|
3394
|
+
u,
|
|
3395
3395
|
s,
|
|
3396
|
-
|
|
3397
|
-
|
|
3396
|
+
l,
|
|
3397
|
+
a,
|
|
3398
3398
|
f
|
|
3399
|
-
), w =
|
|
3399
|
+
), w = u - x, I = this.distributeDiscount(o, w, u);
|
|
3400
3400
|
return {
|
|
3401
3401
|
applicable: !0,
|
|
3402
3402
|
discountAmount: Number(w.toFixed(2)),
|
|
@@ -3408,19 +3408,19 @@ class Zn {
|
|
|
3408
3408
|
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3409
3409
|
}
|
|
3410
3410
|
getTotalQuantity(e, t) {
|
|
3411
|
-
return e.filter((
|
|
3411
|
+
return e.filter((i) => t.includes(i.product.id)).reduce((i, a) => i + a.amount, 0);
|
|
3412
3412
|
}
|
|
3413
3413
|
calculateOriginalPrice(e) {
|
|
3414
|
-
return e.reduce((t,
|
|
3414
|
+
return e.reduce((t, i) => t + i.product.price * i.amount, 0);
|
|
3415
3415
|
}
|
|
3416
|
-
calculateDiscountedPrice(e, t,
|
|
3417
|
-
const o = t *
|
|
3418
|
-
return o +
|
|
3416
|
+
calculateDiscountedPrice(e, t, i, a, s) {
|
|
3417
|
+
const o = t * i, c = i * a, u = Math.max(0, s - c) / s * e;
|
|
3418
|
+
return o + u;
|
|
3419
3419
|
}
|
|
3420
|
-
distributeDiscount(e, t,
|
|
3421
|
-
const
|
|
3420
|
+
distributeDiscount(e, t, i) {
|
|
3421
|
+
const a = t / i;
|
|
3422
3422
|
return e.map((s) => {
|
|
3423
|
-
const o = s.product.price * s.amount *
|
|
3423
|
+
const o = s.product.price * s.amount * a;
|
|
3424
3424
|
return {
|
|
3425
3425
|
productId: s.product.id,
|
|
3426
3426
|
quantity: s.amount,
|
|
@@ -3445,61 +3445,61 @@ class at {
|
|
|
3445
3445
|
this.strategies.clear();
|
|
3446
3446
|
}
|
|
3447
3447
|
}
|
|
3448
|
-
|
|
3449
|
-
["bundle", new
|
|
3448
|
+
ze(at, "strategies", /* @__PURE__ */ new Map([
|
|
3449
|
+
["bundle", new On()]
|
|
3450
3450
|
]));
|
|
3451
|
-
class
|
|
3452
|
-
static calculateDiscounts(e, t,
|
|
3453
|
-
var
|
|
3454
|
-
const
|
|
3451
|
+
class tr {
|
|
3452
|
+
static calculateDiscounts(e, t, i) {
|
|
3453
|
+
var u, f;
|
|
3454
|
+
const a = {
|
|
3455
3455
|
cart: e,
|
|
3456
|
-
user:
|
|
3456
|
+
user: i,
|
|
3457
3457
|
appliedDiscounts: []
|
|
3458
3458
|
}, s = this.filterActiveDiscounts(t), o = [];
|
|
3459
|
-
for (const
|
|
3460
|
-
const w = at.getStrategy(
|
|
3461
|
-
if (!w || !w.canApply(
|
|
3462
|
-
const I = w.calculate(
|
|
3459
|
+
for (const x of s) {
|
|
3460
|
+
const w = at.getStrategy(x);
|
|
3461
|
+
if (!w || !w.canApply(x, a) || !((u = x.conditions) != null && u.stackable) && o.length > 0) continue;
|
|
3462
|
+
const I = w.calculate(x, a);
|
|
3463
3463
|
I.applicable && (o.push({
|
|
3464
|
-
discountId:
|
|
3465
|
-
discountName: ((f =
|
|
3464
|
+
discountId: x.id,
|
|
3465
|
+
discountName: ((f = x.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3466
3466
|
discountAmount: Number(I.discountAmount.toFixed(2)),
|
|
3467
3467
|
affectedItems: I.affectedItems
|
|
3468
|
-
}),
|
|
3468
|
+
}), a.appliedDiscounts = o);
|
|
3469
3469
|
}
|
|
3470
|
-
const c = this.calculateFinalPrices(e, o),
|
|
3471
|
-
(
|
|
3470
|
+
const c = this.calculateFinalPrices(e, o), l = o.reduce(
|
|
3471
|
+
(x, w) => x + w.discountAmount,
|
|
3472
3472
|
0
|
|
3473
3473
|
);
|
|
3474
3474
|
return {
|
|
3475
3475
|
items: c,
|
|
3476
|
-
totalDiscount: Number(
|
|
3476
|
+
totalDiscount: Number(l.toFixed(2)),
|
|
3477
3477
|
appliedDiscounts: o
|
|
3478
3478
|
};
|
|
3479
3479
|
}
|
|
3480
3480
|
static filterActiveDiscounts(e) {
|
|
3481
3481
|
const t = Date.now();
|
|
3482
3482
|
return e.filter(
|
|
3483
|
-
(
|
|
3483
|
+
(i) => i.active && i.startDate <= t && i.endDate >= t
|
|
3484
3484
|
);
|
|
3485
3485
|
}
|
|
3486
3486
|
static calculateFinalPrices(e, t) {
|
|
3487
|
-
return e.map((
|
|
3488
|
-
const
|
|
3489
|
-
(
|
|
3490
|
-
), s =
|
|
3491
|
-
const f =
|
|
3492
|
-
(
|
|
3487
|
+
return e.map((i) => {
|
|
3488
|
+
const a = t.filter(
|
|
3489
|
+
(l) => l.affectedItems.some((u) => u.productId === i.product.id)
|
|
3490
|
+
), s = a.reduce((l, u) => {
|
|
3491
|
+
const f = u.affectedItems.find(
|
|
3492
|
+
(x) => x.productId === i.product.id
|
|
3493
3493
|
);
|
|
3494
|
-
return
|
|
3495
|
-
}, 0), o = s /
|
|
3494
|
+
return l + ((f == null ? void 0 : f.discountAmount) || 0);
|
|
3495
|
+
}, 0), o = s / i.amount, c = i.product.price - o;
|
|
3496
3496
|
return {
|
|
3497
|
-
amount:
|
|
3498
|
-
product:
|
|
3499
|
-
originalPrice: Number(
|
|
3497
|
+
amount: i.amount,
|
|
3498
|
+
product: i.product,
|
|
3499
|
+
originalPrice: Number(i.product.price.toFixed(2)),
|
|
3500
3500
|
finalPrice: Number(Math.max(0, c).toFixed(2)),
|
|
3501
3501
|
finalDiscount: Number(s.toFixed(2)),
|
|
3502
|
-
appliedDiscounts:
|
|
3502
|
+
appliedDiscounts: a.map((l) => l.discountId)
|
|
3503
3503
|
};
|
|
3504
3504
|
});
|
|
3505
3505
|
}
|
|
@@ -3511,23 +3511,23 @@ class Kn {
|
|
|
3511
3511
|
return this.filterActiveDiscounts(e);
|
|
3512
3512
|
}
|
|
3513
3513
|
}
|
|
3514
|
-
const
|
|
3514
|
+
const Pn = r.object({
|
|
3515
3515
|
id: r.string(),
|
|
3516
3516
|
name: r.string()
|
|
3517
|
-
}),
|
|
3517
|
+
}), nr = Pn.omit({ id: !0 }), st = r.object({
|
|
3518
3518
|
type: r.literal("Supplier"),
|
|
3519
3519
|
id: r.string(),
|
|
3520
3520
|
name: r.string(),
|
|
3521
3521
|
code: r.string()
|
|
3522
3522
|
// supplier code number
|
|
3523
|
-
}),
|
|
3523
|
+
}), rr = st.omit({ id: !0 }), Dn = r.object({
|
|
3524
3524
|
type: r.literal("SupplierInvoice"),
|
|
3525
3525
|
id: r.string(),
|
|
3526
3526
|
// "draft" = work-in-progress, NOT yet finalized. Product prices are only
|
|
3527
3527
|
// updated once the invoice is finalized ("completed"). Legacy invoices have
|
|
3528
3528
|
// no status and are treated as finalized.
|
|
3529
3529
|
status: r.enum(["draft", "completed"]).optional(),
|
|
3530
|
-
supplier:
|
|
3530
|
+
supplier: st,
|
|
3531
3531
|
invoiceNumber: r.string(),
|
|
3532
3532
|
date: r.number(),
|
|
3533
3533
|
rows: r.array(
|
|
@@ -3565,14 +3565,14 @@ const On = r.object({
|
|
|
3565
3565
|
total: r.number().optional(),
|
|
3566
3566
|
totalBeforeVat: r.number().optional(),
|
|
3567
3567
|
vat: r.number().optional()
|
|
3568
|
-
}),
|
|
3568
|
+
}), ir = Dn.omit({ id: !0 }), En = r.enum(["debt_increase", "debt_reduction"]), ar = r.object({
|
|
3569
3569
|
recordId: r.string().min(1),
|
|
3570
3570
|
organizationId: r.string().min(1),
|
|
3571
3571
|
customerId: r.string(),
|
|
3572
3572
|
// "system" when no acting user
|
|
3573
3573
|
customerName: r.string(),
|
|
3574
3574
|
billingAccountId: r.string().nullable(),
|
|
3575
|
-
type:
|
|
3575
|
+
type: En,
|
|
3576
3576
|
/** Integer agorot, always positive */
|
|
3577
3577
|
amount: r.number().int().positive(),
|
|
3578
3578
|
currency: r.literal("ILS"),
|
|
@@ -3590,7 +3590,7 @@ const On = r.object({
|
|
|
3590
3590
|
yearMonth: r.string(),
|
|
3591
3591
|
companyId: r.string().min(1),
|
|
3592
3592
|
storeId: r.string().min(1)
|
|
3593
|
-
}),
|
|
3593
|
+
}), sr = r.object({
|
|
3594
3594
|
/** = doc id */
|
|
3595
3595
|
organizationId: r.string().min(1),
|
|
3596
3596
|
organizationName: r.string(),
|
|
@@ -3604,7 +3604,7 @@ const On = r.object({
|
|
|
3604
3604
|
updatedAt: r.number().int().positive(),
|
|
3605
3605
|
companyId: r.string().min(1),
|
|
3606
3606
|
storeId: r.string().min(1)
|
|
3607
|
-
}),
|
|
3607
|
+
}), or = r.enum([
|
|
3608
3608
|
"delivery_note",
|
|
3609
3609
|
"payment_received",
|
|
3610
3610
|
"credit_note",
|
|
@@ -3615,7 +3615,7 @@ const On = r.object({
|
|
|
3615
3615
|
// legacy
|
|
3616
3616
|
"order_refunded"
|
|
3617
3617
|
// legacy
|
|
3618
|
-
]),
|
|
3618
|
+
]), cr = r.enum(["check", "bank_transfer", "cash", "credit_card", "other"]), ur = r.object({
|
|
3619
3619
|
/** = deterministic dedup doc id */
|
|
3620
3620
|
id: r.string().min(1),
|
|
3621
3621
|
organizationId: r.string().min(1),
|
|
@@ -3647,7 +3647,7 @@ const On = r.object({
|
|
|
3647
3647
|
createdAt: r.number().int().positive(),
|
|
3648
3648
|
companyId: r.string().min(1),
|
|
3649
3649
|
storeId: r.string().min(1)
|
|
3650
|
-
}),
|
|
3650
|
+
}), dr = r.object({
|
|
3651
3651
|
/** = doc id */
|
|
3652
3652
|
organizationId: r.string().min(1),
|
|
3653
3653
|
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
@@ -3667,51 +3667,68 @@ const On = r.object({
|
|
|
3667
3667
|
updatedAt: r.number().int().positive(),
|
|
3668
3668
|
companyId: r.string().min(1),
|
|
3669
3669
|
storeId: r.string().min(1)
|
|
3670
|
-
}),
|
|
3670
|
+
}), Ee = {
|
|
3671
3671
|
VAT: 18
|
|
3672
3672
|
};
|
|
3673
|
-
function
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3673
|
+
function Rn(n) {
|
|
3674
|
+
return n.reduce((e, t) => {
|
|
3675
|
+
if (t.status === "missing")
|
|
3676
|
+
return e;
|
|
3677
|
+
if (t.status === "substituted" && t.substitutedWith) {
|
|
3678
|
+
const i = t.substitutedWith;
|
|
3679
|
+
return e.push({
|
|
3680
|
+
...t,
|
|
3681
|
+
// Pin price to sub.price and neutralise the substitute product's own
|
|
3682
|
+
// discount so getPriceAfterDiscount returns sub.price with no reduction.
|
|
3683
|
+
product: { ...i.product, price: i.price, discount: { type: "none", value: 0 } },
|
|
3684
|
+
amount: i.amount
|
|
3685
|
+
}), e;
|
|
3686
|
+
}
|
|
3687
|
+
return e.push(t), e;
|
|
3688
|
+
}, []);
|
|
3689
|
+
}
|
|
3690
|
+
function $n(n, e) {
|
|
3691
|
+
var t, i;
|
|
3692
|
+
return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((i = n.discount) == null ? void 0 : i.type) === "number" ? n.discount.value ?? 0 : 0;
|
|
3693
|
+
}
|
|
3694
|
+
function Mn(n, e) {
|
|
3695
|
+
var i, a;
|
|
3696
|
+
const t = e && n.vat ? n.price + n.price * Ee.VAT / 100 : n.price;
|
|
3697
|
+
if (((i = n.discount) == null ? void 0 : i.type) === "percent") {
|
|
3681
3698
|
const s = t * n.discount.value / 100;
|
|
3682
3699
|
return n.price - s;
|
|
3683
3700
|
}
|
|
3684
|
-
return ((
|
|
3701
|
+
return ((a = n.discount) == null ? void 0 : a.type) === "number" ? t - n.discount.value : t;
|
|
3685
3702
|
}
|
|
3686
|
-
function
|
|
3703
|
+
function lr({
|
|
3687
3704
|
cart: n,
|
|
3688
3705
|
discounts: e,
|
|
3689
3706
|
deliveryPrice: t = 0,
|
|
3690
|
-
freeDeliveryPrice:
|
|
3691
|
-
freeShipping:
|
|
3707
|
+
freeDeliveryPrice: i = 0,
|
|
3708
|
+
freeShipping: a = !1,
|
|
3692
3709
|
isVatIncludedInPrice: s = !1
|
|
3693
3710
|
}) {
|
|
3694
|
-
const
|
|
3695
|
-
amount:
|
|
3696
|
-
product: { ...
|
|
3697
|
-
originalPrice:
|
|
3698
|
-
finalPrice:
|
|
3699
|
-
finalDiscount:
|
|
3700
|
-
})),
|
|
3701
|
-
(
|
|
3702
|
-
const { product:
|
|
3703
|
-
let
|
|
3704
|
-
if (
|
|
3705
|
-
let
|
|
3711
|
+
const c = Rn(n).map((u, f) => ({
|
|
3712
|
+
amount: u.amount,
|
|
3713
|
+
product: { ...u.product },
|
|
3714
|
+
originalPrice: u.product.price,
|
|
3715
|
+
finalPrice: Mn(u.product, s),
|
|
3716
|
+
finalDiscount: $n(u.product)
|
|
3717
|
+
})), l = c.reduce(
|
|
3718
|
+
(u, f) => {
|
|
3719
|
+
const { product: x, amount: w, finalPrice: I, finalDiscount: K } = f;
|
|
3720
|
+
let Z = 0;
|
|
3721
|
+
if (x.vat) {
|
|
3722
|
+
let Ce = 0;
|
|
3706
3723
|
if (s) {
|
|
3707
|
-
const
|
|
3708
|
-
|
|
3724
|
+
const ot = Number((I / (1 + Ee.VAT / 100)).toFixed(2)), ct = I - ot;
|
|
3725
|
+
Z = Number(ct.toFixed(2)), Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3709
3726
|
} else
|
|
3710
|
-
|
|
3711
|
-
|
|
3727
|
+
Z = I * Ee.VAT / 100, Z = Z * w, Ce = Number(Z.toFixed(2));
|
|
3728
|
+
u.vat = Number((u.vat + Ce).toFixed(2));
|
|
3712
3729
|
}
|
|
3713
|
-
const
|
|
3714
|
-
return
|
|
3730
|
+
const Ne = Number(I.toFixed(2));
|
|
3731
|
+
return u.cost += w * Ne, u.discount += K && w * K, u.finalCost += w * Ne + (s ? 0 : Z), u.productsCost += w * Ne + (s ? 0 : Z), u.cost = Number(u.cost.toFixed(2)), u.discount = Number(u.discount.toFixed(2)), u.finalCost = Number(u.finalCost.toFixed(2)), u.productsCost = Number(u.productsCost.toFixed(2)), u;
|
|
3715
3732
|
},
|
|
3716
3733
|
{
|
|
3717
3734
|
discount: 0,
|
|
@@ -3722,12 +3739,12 @@ function dr({
|
|
|
3722
3739
|
deliveryPrice: t
|
|
3723
3740
|
}
|
|
3724
3741
|
);
|
|
3725
|
-
return
|
|
3742
|
+
return a || l.deliveryPrice && l.productsCost >= i ? l.deliveryPrice = 0 : l.finalCost += l.deliveryPrice, { items: c, ...l };
|
|
3726
3743
|
}
|
|
3727
|
-
const
|
|
3744
|
+
const zn = {
|
|
3728
3745
|
stores: "STORES",
|
|
3729
3746
|
companies: "COMPANIES"
|
|
3730
|
-
},
|
|
3747
|
+
}, Vn = {
|
|
3731
3748
|
products: "products",
|
|
3732
3749
|
"favorite-products": "favorite-products",
|
|
3733
3750
|
profiles: "profiles",
|
|
@@ -3756,95 +3773,96 @@ const $n = {
|
|
|
3756
3773
|
duplicateChargeAlerts: "duplicateChargeAlerts",
|
|
3757
3774
|
organizationBalance: "organizationBalance",
|
|
3758
3775
|
organizationBalanceRollup: "organizationBalanceRollup"
|
|
3759
|
-
},
|
|
3760
|
-
systemCollections:
|
|
3761
|
-
storeCollections:
|
|
3776
|
+
}, Ln = {
|
|
3777
|
+
systemCollections: zn,
|
|
3778
|
+
storeCollections: Vn,
|
|
3762
3779
|
// for client and server
|
|
3763
3780
|
getPath: ({
|
|
3764
3781
|
companyId: n,
|
|
3765
3782
|
storeId: e,
|
|
3766
3783
|
collectionName: t,
|
|
3767
|
-
id:
|
|
3768
|
-
}) => `${n}/${e}/${t}${
|
|
3784
|
+
id: i
|
|
3785
|
+
}) => `${n}/${e}/${t}${i ? `/${i}` : ""}`,
|
|
3769
3786
|
getSubPath: ({
|
|
3770
3787
|
companyId: n,
|
|
3771
3788
|
storeId: e,
|
|
3772
3789
|
collectionName: t,
|
|
3773
|
-
subCollectionName:
|
|
3774
|
-
id:
|
|
3790
|
+
subCollectionName: i,
|
|
3791
|
+
id: a,
|
|
3775
3792
|
subId: s
|
|
3776
|
-
}) => `${n}/${e}/${t}/${
|
|
3793
|
+
}) => `${n}/${e}/${t}/${a}/${i}${s ? `/${s}` : ""}`,
|
|
3777
3794
|
// for firestore events
|
|
3778
3795
|
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
|
|
3779
3796
|
getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
|
|
3780
|
-
},
|
|
3781
|
-
firestore:
|
|
3782
|
-
},
|
|
3797
|
+
}, mr = {
|
|
3798
|
+
firestore: Ln
|
|
3799
|
+
}, qe = {
|
|
3783
3800
|
round: (n, e = 2) => {
|
|
3784
3801
|
const t = 10 ** e;
|
|
3785
3802
|
return Math.round((n + Number.EPSILON) * t) / t;
|
|
3786
3803
|
}
|
|
3787
|
-
},
|
|
3788
|
-
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e :
|
|
3789
|
-
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 :
|
|
3804
|
+
}, pr = {
|
|
3805
|
+
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : qe.round(e / (1 - n / 100)),
|
|
3806
|
+
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : qe.round((n - e) / n * 100)
|
|
3790
3807
|
};
|
|
3791
3808
|
export {
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
+
Ie as AddressSchema,
|
|
3810
|
+
tt as BaseCategorySchema,
|
|
3811
|
+
it as BillingAccountSchema,
|
|
3812
|
+
In as BranchSchema,
|
|
3813
|
+
ar as BudgetRecordSchema,
|
|
3814
|
+
En as BudgetRecordTypeSchema,
|
|
3815
|
+
or as BudgetTransactionTypeSchema,
|
|
3816
|
+
On as BundleDiscountStrategy,
|
|
3817
|
+
rt as CalculatedDataSchema,
|
|
3818
|
+
nt as CartItemProductSchema,
|
|
3819
|
+
Yn as CartSchema,
|
|
3820
|
+
$e as CategorySchema,
|
|
3821
|
+
Xn as CompanySchema,
|
|
3822
|
+
Tn as DeliveryNoteSchema,
|
|
3823
|
+
jn as DiscountConditionsSchema,
|
|
3824
|
+
tr as DiscountEngine,
|
|
3825
|
+
er as DiscountSchema,
|
|
3809
3826
|
at as DiscountStrategyFactory,
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3827
|
+
Zn as DiscountVariantSchema,
|
|
3828
|
+
wn as EzDeliveryNoteSchema,
|
|
3829
|
+
Ue as EzInvoiceSchema,
|
|
3830
|
+
Gn as FavoriteProductSchema,
|
|
3831
|
+
qn as FileSchema,
|
|
3832
|
+
mr as FirebaseAPI,
|
|
3833
|
+
bn as FulfillmentStatusSchema,
|
|
3834
|
+
Nn as InvoiceSchema,
|
|
3835
|
+
ye as LocaleSchema,
|
|
3836
|
+
nr as NewOrganizationGroupSchema,
|
|
3837
|
+
Jn as NewOrganizationSchema,
|
|
3838
|
+
Qn as NewProductSchema,
|
|
3839
|
+
ir as NewSupplierInvoiceSchema,
|
|
3840
|
+
rr as NewSupplierSchema,
|
|
3841
|
+
Hn as OrderSchema,
|
|
3842
|
+
ur as OrganizationBalanceEntrySchema,
|
|
3843
|
+
dr as OrganizationBalanceRollupSchema,
|
|
3844
|
+
sr as OrganizationBudgetSchema,
|
|
3845
|
+
Pn as OrganizationGroupSchema,
|
|
3846
|
+
An as OrganizationSchema,
|
|
3847
|
+
cr as PaymentMethodSchema,
|
|
3848
|
+
Sn as PaymentTermsSchema,
|
|
3849
|
+
Ae as PaymentTypeSchema,
|
|
3850
|
+
Me as ProductSchema,
|
|
3851
|
+
kn as ProfileSchema,
|
|
3852
|
+
Kn as StoreSchema,
|
|
3853
|
+
xn as SubstitutedWithSchema,
|
|
3854
|
+
Dn as SupplierInvoiceSchema,
|
|
3855
|
+
st as SupplierSchema,
|
|
3856
|
+
Wn as TFlattenCategorySchema,
|
|
3857
|
+
Cn as clientTypesSchema,
|
|
3858
|
+
lr as getCartCost,
|
|
3859
|
+
Rn as getFulfilledCartItems,
|
|
3860
|
+
Bn as isFile,
|
|
3861
|
+
qe as math,
|
|
3844
3862
|
$ as notEmptyTextSchema,
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3863
|
+
Un as numericTextSchema,
|
|
3864
|
+
pr as storeCalculator,
|
|
3865
|
+
Vn as storeCollections,
|
|
3866
|
+
zn as systemCollections
|
|
3849
3867
|
};
|
|
3850
3868
|
//# sourceMappingURL=core.es.js.map
|