@jsdev_ninja/core 0.15.3 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.es.js +1323 -1253
- package/dist/core.es.js.map +1 -1
- package/dist/core.umd.js +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/lib/entities/Invoice.d.ts +1 -0
- package/dist/lib/entities/Invoice.d.ts.map +1 -1
- package/dist/lib/entities/Order.d.ts +155 -0
- package/dist/lib/entities/Order.d.ts.map +1 -1
- package/dist/lib/entities/Order.js +12 -0
- package/dist/lib/entities/OrganizationBalance.d.ts +138 -0
- package/dist/lib/entities/OrganizationBalance.d.ts.map +1 -0
- package/dist/lib/entities/OrganizationBalance.js +65 -0
- package/dist/lib/entities/index.d.ts +2 -0
- package/dist/lib/entities/index.d.ts.map +1 -1
- package/dist/lib/entities/index.js +2 -0
- package/dist/lib/firebase-api/index.d.ts +6 -0
- package/dist/lib/firebase-api/index.d.ts.map +1 -1
- package/dist/lib/firebase-api/index.js +2 -0
- package/dist/lib/index.js +1 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/core.es.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var $e = (n, e, t) =>
|
|
1
|
+
var ot = Object.defineProperty;
|
|
2
|
+
var ct = (n, e, t) => e in n ? ot(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var $e = (n, e, t) => ct(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
var b;
|
|
5
5
|
(function(n) {
|
|
6
|
-
n.assertEqual = (
|
|
7
|
-
function e(
|
|
6
|
+
n.assertEqual = (i) => i;
|
|
7
|
+
function e(i) {
|
|
8
8
|
}
|
|
9
9
|
n.assertIs = e;
|
|
10
|
-
function t(
|
|
10
|
+
function t(i) {
|
|
11
11
|
throw new Error();
|
|
12
12
|
}
|
|
13
|
-
n.assertNever = t, n.arrayToEnum = (
|
|
14
|
-
const
|
|
15
|
-
for (const c of
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
}, n.getValidEnumValues = (
|
|
19
|
-
const
|
|
20
|
-
for (const o of
|
|
21
|
-
c[o] =
|
|
13
|
+
n.assertNever = t, n.arrayToEnum = (i) => {
|
|
14
|
+
const s = {};
|
|
15
|
+
for (const c of i)
|
|
16
|
+
s[c] = c;
|
|
17
|
+
return s;
|
|
18
|
+
}, n.getValidEnumValues = (i) => {
|
|
19
|
+
const s = n.objectKeys(i).filter((o) => typeof i[i[o]] != "number"), c = {};
|
|
20
|
+
for (const o of s)
|
|
21
|
+
c[o] = i[o];
|
|
22
22
|
return n.objectValues(c);
|
|
23
|
-
}, n.objectValues = (
|
|
24
|
-
return
|
|
25
|
-
}), n.objectKeys = typeof Object.keys == "function" ? (
|
|
26
|
-
const
|
|
27
|
-
for (const c in
|
|
28
|
-
Object.prototype.hasOwnProperty.call(
|
|
29
|
-
return
|
|
30
|
-
}, n.find = (
|
|
31
|
-
for (const c of
|
|
32
|
-
if (
|
|
23
|
+
}, n.objectValues = (i) => n.objectKeys(i).map(function(s) {
|
|
24
|
+
return i[s];
|
|
25
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (i) => Object.keys(i) : (i) => {
|
|
26
|
+
const s = [];
|
|
27
|
+
for (const c in i)
|
|
28
|
+
Object.prototype.hasOwnProperty.call(i, c) && s.push(c);
|
|
29
|
+
return s;
|
|
30
|
+
}, n.find = (i, s) => {
|
|
31
|
+
for (const c of i)
|
|
32
|
+
if (s(c))
|
|
33
33
|
return c;
|
|
34
|
-
}, n.isInteger = typeof Number.isInteger == "function" ? (
|
|
35
|
-
function
|
|
36
|
-
return
|
|
34
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (i) => Number.isInteger(i) : (i) => typeof i == "number" && isFinite(i) && Math.floor(i) === i;
|
|
35
|
+
function a(i, s = " | ") {
|
|
36
|
+
return i.map((c) => typeof c == "string" ? `'${c}'` : c).join(s);
|
|
37
37
|
}
|
|
38
|
-
n.joinValues =
|
|
38
|
+
n.joinValues = a, n.jsonStringifyReplacer = (i, s) => typeof s == "bigint" ? s.toString() : s;
|
|
39
39
|
})(b || (b = {}));
|
|
40
40
|
var Ce;
|
|
41
41
|
(function(n) {
|
|
@@ -87,7 +87,7 @@ const p = b.arrayToEnum([
|
|
|
87
87
|
default:
|
|
88
88
|
return p.unknown;
|
|
89
89
|
}
|
|
90
|
-
},
|
|
90
|
+
}, u = b.arrayToEnum([
|
|
91
91
|
"invalid_type",
|
|
92
92
|
"invalid_literal",
|
|
93
93
|
"custom",
|
|
@@ -104,45 +104,45 @@ const p = b.arrayToEnum([
|
|
|
104
104
|
"invalid_intersection_types",
|
|
105
105
|
"not_multiple_of",
|
|
106
106
|
"not_finite"
|
|
107
|
-
]),
|
|
108
|
-
class
|
|
107
|
+
]), ut = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
108
|
+
class 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 = (a) => {
|
|
114
|
+
this.issues = [...this.issues, a];
|
|
115
|
+
}, this.addIssues = (a = []) => {
|
|
116
|
+
this.issues = [...this.issues, ...a];
|
|
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;
|
|
120
120
|
}
|
|
121
121
|
format(e) {
|
|
122
|
-
const t = e || function(
|
|
123
|
-
return
|
|
124
|
-
},
|
|
125
|
-
for (const c of
|
|
122
|
+
const t = e || function(s) {
|
|
123
|
+
return s.message;
|
|
124
|
+
}, a = { _errors: [] }, i = (s) => {
|
|
125
|
+
for (const c of s.issues)
|
|
126
126
|
if (c.code === "invalid_union")
|
|
127
|
-
c.unionErrors.map(
|
|
127
|
+
c.unionErrors.map(i);
|
|
128
128
|
else if (c.code === "invalid_return_type")
|
|
129
|
-
|
|
129
|
+
i(c.returnTypeError);
|
|
130
130
|
else if (c.code === "invalid_arguments")
|
|
131
|
-
|
|
131
|
+
i(c.argumentsError);
|
|
132
132
|
else if (c.path.length === 0)
|
|
133
|
-
|
|
133
|
+
a._errors.push(t(c));
|
|
134
134
|
else {
|
|
135
|
-
let o =
|
|
135
|
+
let o = a, l = 0;
|
|
136
136
|
for (; l < c.path.length; ) {
|
|
137
|
-
const
|
|
138
|
-
l === c.path.length - 1 ? (o[
|
|
137
|
+
const d = c.path[l];
|
|
138
|
+
l === c.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(t(c))) : o[d] = o[d] || { _errors: [] }, o = o[d], l++;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
return
|
|
142
|
+
return i(this), a;
|
|
143
143
|
}
|
|
144
144
|
static assert(e) {
|
|
145
|
-
if (!(e instanceof
|
|
145
|
+
if (!(e instanceof A))
|
|
146
146
|
throw new Error(`Not a ZodError: ${e}`);
|
|
147
147
|
}
|
|
148
148
|
toString() {
|
|
@@ -155,65 +155,65 @@ class N extends Error {
|
|
|
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 = {}, a = [];
|
|
159
|
+
for (const i of this.issues)
|
|
160
|
+
i.path.length > 0 ? (t[i.path[0]] = t[i.path[0]] || [], t[i.path[0]].push(e(i))) : a.push(e(i));
|
|
161
|
+
return { formErrors: a, fieldErrors: t };
|
|
162
162
|
}
|
|
163
163
|
get formErrors() {
|
|
164
164
|
return this.flatten();
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
A.create = (n) => new A(n);
|
|
168
168
|
const X = (n, e) => {
|
|
169
169
|
let t;
|
|
170
170
|
switch (n.code) {
|
|
171
|
-
case
|
|
171
|
+
case u.invalid_type:
|
|
172
172
|
n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
173
173
|
break;
|
|
174
|
-
case
|
|
174
|
+
case u.invalid_literal:
|
|
175
175
|
t = `Invalid literal value, expected ${JSON.stringify(n.expected, b.jsonStringifyReplacer)}`;
|
|
176
176
|
break;
|
|
177
|
-
case
|
|
177
|
+
case u.unrecognized_keys:
|
|
178
178
|
t = `Unrecognized key(s) in object: ${b.joinValues(n.keys, ", ")}`;
|
|
179
179
|
break;
|
|
180
|
-
case
|
|
180
|
+
case u.invalid_union:
|
|
181
181
|
t = "Invalid input";
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
183
|
+
case u.invalid_union_discriminator:
|
|
184
184
|
t = `Invalid discriminator value. Expected ${b.joinValues(n.options)}`;
|
|
185
185
|
break;
|
|
186
|
-
case
|
|
186
|
+
case u.invalid_enum_value:
|
|
187
187
|
t = `Invalid enum value. Expected ${b.joinValues(n.options)}, received '${n.received}'`;
|
|
188
188
|
break;
|
|
189
|
-
case
|
|
189
|
+
case u.invalid_arguments:
|
|
190
190
|
t = "Invalid function arguments";
|
|
191
191
|
break;
|
|
192
|
-
case
|
|
192
|
+
case u.invalid_return_type:
|
|
193
193
|
t = "Invalid function return type";
|
|
194
194
|
break;
|
|
195
|
-
case
|
|
195
|
+
case u.invalid_date:
|
|
196
196
|
t = "Invalid date";
|
|
197
197
|
break;
|
|
198
|
-
case
|
|
198
|
+
case u.invalid_string:
|
|
199
199
|
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : b.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
200
200
|
break;
|
|
201
|
-
case
|
|
201
|
+
case u.too_small:
|
|
202
202
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
203
203
|
break;
|
|
204
|
-
case
|
|
204
|
+
case u.too_big:
|
|
205
205
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
206
206
|
break;
|
|
207
|
-
case
|
|
207
|
+
case u.custom:
|
|
208
208
|
t = "Invalid input";
|
|
209
209
|
break;
|
|
210
|
-
case
|
|
210
|
+
case u.invalid_intersection_types:
|
|
211
211
|
t = "Intersection results could not be merged";
|
|
212
212
|
break;
|
|
213
|
-
case
|
|
213
|
+
case u.not_multiple_of:
|
|
214
214
|
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
215
215
|
break;
|
|
216
|
-
case
|
|
216
|
+
case u.not_finite:
|
|
217
217
|
t = "Number must be finite";
|
|
218
218
|
break;
|
|
219
219
|
default:
|
|
@@ -221,36 +221,36 @@ const X = (n, e) => {
|
|
|
221
221
|
}
|
|
222
222
|
return { message: t };
|
|
223
223
|
};
|
|
224
|
-
let
|
|
224
|
+
let Ue = X;
|
|
225
225
|
function dt(n) {
|
|
226
|
-
|
|
226
|
+
Ue = n;
|
|
227
227
|
}
|
|
228
228
|
function ye() {
|
|
229
|
-
return
|
|
229
|
+
return Ue;
|
|
230
230
|
}
|
|
231
231
|
const ve = (n) => {
|
|
232
|
-
const { data: e, path: t, errorMaps:
|
|
233
|
-
...
|
|
234
|
-
path:
|
|
232
|
+
const { data: e, path: t, errorMaps: a, issueData: i } = n, s = [...t, ...i.path || []], c = {
|
|
233
|
+
...i,
|
|
234
|
+
path: s
|
|
235
235
|
};
|
|
236
|
-
if (
|
|
236
|
+
if (i.message !== void 0)
|
|
237
237
|
return {
|
|
238
|
-
...
|
|
239
|
-
path:
|
|
240
|
-
message:
|
|
238
|
+
...i,
|
|
239
|
+
path: s,
|
|
240
|
+
message: i.message
|
|
241
241
|
};
|
|
242
242
|
let o = "";
|
|
243
|
-
const l =
|
|
244
|
-
for (const
|
|
245
|
-
o =
|
|
243
|
+
const l = a.filter((d) => !!d).slice().reverse();
|
|
244
|
+
for (const d of l)
|
|
245
|
+
o = d(c, { data: e, defaultError: o }).message;
|
|
246
246
|
return {
|
|
247
|
-
...
|
|
248
|
-
path:
|
|
247
|
+
...i,
|
|
248
|
+
path: s,
|
|
249
249
|
message: o
|
|
250
250
|
};
|
|
251
|
-
},
|
|
251
|
+
}, lt = [];
|
|
252
252
|
function m(n, e) {
|
|
253
|
-
const t = ye(),
|
|
253
|
+
const t = ye(), a = ve({
|
|
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 === X ? void 0 : X
|
|
265
265
|
// then global default map
|
|
266
|
-
].filter((
|
|
266
|
+
].filter((i) => !!i)
|
|
267
267
|
});
|
|
268
|
-
n.common.issues.push(
|
|
268
|
+
n.common.issues.push(a);
|
|
269
269
|
}
|
|
270
270
|
class S {
|
|
271
271
|
constructor() {
|
|
@@ -278,44 +278,44 @@ class S {
|
|
|
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 a = [];
|
|
282
|
+
for (const i of t) {
|
|
283
|
+
if (i.status === "aborted")
|
|
284
284
|
return y;
|
|
285
|
-
|
|
285
|
+
i.status === "dirty" && e.dirty(), a.push(i.value);
|
|
286
286
|
}
|
|
287
|
-
return { status: e.value, value:
|
|
287
|
+
return { status: e.value, value: a };
|
|
288
288
|
}
|
|
289
289
|
static async mergeObjectAsync(e, t) {
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
key:
|
|
290
|
+
const a = [];
|
|
291
|
+
for (const i of t) {
|
|
292
|
+
const s = await i.key, c = await i.value;
|
|
293
|
+
a.push({
|
|
294
|
+
key: s,
|
|
295
295
|
value: c
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
|
-
return S.mergeObjectSync(e,
|
|
298
|
+
return S.mergeObjectSync(e, a);
|
|
299
299
|
}
|
|
300
300
|
static mergeObjectSync(e, t) {
|
|
301
|
-
const
|
|
302
|
-
for (const
|
|
303
|
-
const { key:
|
|
304
|
-
if (
|
|
301
|
+
const a = {};
|
|
302
|
+
for (const i of t) {
|
|
303
|
+
const { key: s, value: c } = i;
|
|
304
|
+
if (s.status === "aborted" || c.status === "aborted")
|
|
305
305
|
return y;
|
|
306
|
-
|
|
306
|
+
s.status === "dirty" && e.dirty(), c.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof c.value < "u" || i.alwaysSet) && (a[s.value] = c.value);
|
|
307
307
|
}
|
|
308
|
-
return { status: e.value, value:
|
|
308
|
+
return { status: e.value, value: a };
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
const y = Object.freeze({
|
|
312
312
|
status: "aborted"
|
|
313
313
|
}), Q = (n) => ({ status: "dirty", value: n }), I = (n) => ({ status: "valid", value: n }), je = (n) => n.status === "aborted", Ze = (n) => n.status === "dirty", U = (n) => n.status === "valid", ne = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
314
|
-
function _e(n, e, t,
|
|
314
|
+
function _e(n, e, t, a) {
|
|
315
315
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
316
316
|
return e.get(n);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function qe(n, e, t, a, i) {
|
|
319
319
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
320
320
|
return e.set(n, t), t;
|
|
321
321
|
}
|
|
@@ -325,8 +325,8 @@ var h;
|
|
|
325
325
|
})(h || (h = {}));
|
|
326
326
|
var ee, te;
|
|
327
327
|
class O {
|
|
328
|
-
constructor(e, t,
|
|
329
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
328
|
+
constructor(e, t, a, i) {
|
|
329
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = a, this._key = i;
|
|
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;
|
|
@@ -342,7 +342,7 @@ const Me = (n, e) => {
|
|
|
342
342
|
get error() {
|
|
343
343
|
if (this._error)
|
|
344
344
|
return this._error;
|
|
345
|
-
const t = new
|
|
345
|
+
const t = new A(n.common.issues);
|
|
346
346
|
return this._error = t, this._error;
|
|
347
347
|
}
|
|
348
348
|
};
|
|
@@ -350,14 +350,14 @@ const Me = (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: a, description: i } = n;
|
|
354
|
+
if (e && (t || a))
|
|
355
355
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
356
|
-
return e ? { errorMap: e, description:
|
|
357
|
-
var l,
|
|
356
|
+
return e ? { errorMap: e, description: i } : { errorMap: (c, o) => {
|
|
357
|
+
var l, d;
|
|
358
358
|
const { message: f } = n;
|
|
359
|
-
return c.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: (l = f ??
|
|
360
|
-
}, description:
|
|
359
|
+
return c.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: (l = f ?? a) !== null && l !== void 0 ? l : o.defaultError } : c.code !== "invalid_type" ? { message: o.defaultError } : { message: (d = f ?? t) !== null && d !== void 0 ? d : o.defaultError };
|
|
360
|
+
}, description: i };
|
|
361
361
|
}
|
|
362
362
|
class _ {
|
|
363
363
|
get description() {
|
|
@@ -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 a = this.safeParse(e, t);
|
|
404
|
+
if (a.success)
|
|
405
|
+
return a.data;
|
|
406
|
+
throw a.error;
|
|
407
407
|
}
|
|
408
408
|
safeParse(e, t) {
|
|
409
|
-
var
|
|
410
|
-
const
|
|
409
|
+
var a;
|
|
410
|
+
const i = {
|
|
411
411
|
common: {
|
|
412
412
|
issues: [],
|
|
413
|
-
async: (
|
|
413
|
+
async: (a = t == null ? void 0 : t.async) !== null && a !== void 0 ? a : !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: E(e)
|
|
421
|
-
},
|
|
422
|
-
return Me(
|
|
421
|
+
}, s = this._parseSync({ data: e, path: i.path, parent: i });
|
|
422
|
+
return Me(i, s);
|
|
423
423
|
}
|
|
424
424
|
"~validate"(e) {
|
|
425
|
-
var t,
|
|
426
|
-
const
|
|
425
|
+
var t, a;
|
|
426
|
+
const i = {
|
|
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
|
|
440
|
-
return U(
|
|
441
|
-
value:
|
|
439
|
+
const s = this._parseSync({ data: e, path: [], parent: i });
|
|
440
|
+
return U(s) ? {
|
|
441
|
+
value: s.value
|
|
442
442
|
} : {
|
|
443
|
-
issues:
|
|
443
|
+
issues: i.common.issues
|
|
444
444
|
};
|
|
445
|
-
} catch (
|
|
446
|
-
!((
|
|
445
|
+
} catch (s) {
|
|
446
|
+
!((a = (t = s == null ? void 0 : s.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || a === void 0) && a.includes("encountered") && (this["~standard"].async = !0), i.common = {
|
|
447
447
|
issues: [],
|
|
448
448
|
async: !0
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
452
|
-
value:
|
|
451
|
+
return this._parseAsync({ data: e, path: [], parent: i }).then((s) => U(s) ? {
|
|
452
|
+
value: s.value
|
|
453
453
|
} : {
|
|
454
|
-
issues:
|
|
454
|
+
issues: i.common.issues
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
async parseAsync(e, t) {
|
|
458
|
-
const
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
461
|
-
throw
|
|
458
|
+
const a = await this.safeParseAsync(e, t);
|
|
459
|
+
if (a.success)
|
|
460
|
+
return a.data;
|
|
461
|
+
throw a.error;
|
|
462
462
|
}
|
|
463
463
|
async safeParseAsync(e, t) {
|
|
464
|
-
const
|
|
464
|
+
const a = {
|
|
465
465
|
common: {
|
|
466
466
|
issues: [],
|
|
467
467
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -472,21 +472,21 @@ class _ {
|
|
|
472
472
|
parent: null,
|
|
473
473
|
data: e,
|
|
474
474
|
parsedType: E(e)
|
|
475
|
-
},
|
|
476
|
-
return Me(
|
|
475
|
+
}, i = this._parse({ data: e, path: a.path, parent: a }), s = await (ne(i) ? i : Promise.resolve(i));
|
|
476
|
+
return Me(a, s);
|
|
477
477
|
}
|
|
478
478
|
refine(e, t) {
|
|
479
|
-
const
|
|
480
|
-
return this._refinement((
|
|
481
|
-
const c = e(
|
|
482
|
-
code:
|
|
483
|
-
...
|
|
479
|
+
const a = (i) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(i) : t;
|
|
480
|
+
return this._refinement((i, s) => {
|
|
481
|
+
const c = e(i), o = () => s.addIssue({
|
|
482
|
+
code: u.custom,
|
|
483
|
+
...a(i)
|
|
484
484
|
});
|
|
485
485
|
return typeof Promise < "u" && c instanceof Promise ? c.then((l) => l ? !0 : (o(), !1)) : c ? !0 : (o(), !1);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
refinement(e, t) {
|
|
489
|
-
return this._refinement((
|
|
489
|
+
return this._refinement((a, i) => e(a) ? !0 : (i.addIssue(typeof t == "function" ? t(a, i) : t), !1));
|
|
490
490
|
}
|
|
491
491
|
_refinement(e) {
|
|
492
492
|
return new j({
|
|
@@ -521,7 +521,7 @@ class _ {
|
|
|
521
521
|
return J.create(this, this._def);
|
|
522
522
|
}
|
|
523
523
|
or(e) {
|
|
524
|
-
return
|
|
524
|
+
return se.create([this, e], this._def);
|
|
525
525
|
}
|
|
526
526
|
and(e) {
|
|
527
527
|
return oe.create(this, e, this._def);
|
|
@@ -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 mt = /^c[^\s-]{8,}$/i, pt = /^[0-9a-z]+$/, ft = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ht = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, gt = /^[a-z0-9_-]{21}$/i, yt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, vt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, _t = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, bt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
583
|
+
let Ne;
|
|
584
|
+
const xt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, kt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, wt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Tt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, St = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, It = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Be = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", At = new RegExp(`^${Be}$`);
|
|
585
|
+
function We(n) {
|
|
586
586
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
587
587
|
return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
588
588
|
}
|
|
589
589
|
function Nt(n) {
|
|
590
|
-
return new RegExp(`^${
|
|
590
|
+
return new RegExp(`^${We(n)}$`);
|
|
591
591
|
}
|
|
592
|
-
function
|
|
593
|
-
let e = `${
|
|
592
|
+
function Qe(n) {
|
|
593
|
+
let e = `${Be}T${We(n)}`;
|
|
594
594
|
const t = [];
|
|
595
595
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
596
596
|
}
|
|
597
|
-
function At(n, e) {
|
|
598
|
-
return !!((e === "v4" || !e) && bt.test(n) || (e === "v6" || !e) && kt.test(n));
|
|
599
|
-
}
|
|
600
597
|
function Ct(n, e) {
|
|
601
|
-
|
|
598
|
+
return !!((e === "v4" || !e) && xt.test(n) || (e === "v6" || !e) && wt.test(n));
|
|
599
|
+
}
|
|
600
|
+
function jt(n, e) {
|
|
601
|
+
if (!yt.test(n))
|
|
602
602
|
return !1;
|
|
603
603
|
try {
|
|
604
|
-
const [t] = n.split("."),
|
|
605
|
-
return !(typeof
|
|
604
|
+
const [t] = n.split("."), a = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), i = JSON.parse(atob(a));
|
|
605
|
+
return !(typeof i != "object" || i === null || !i.typ || !i.alg || e && i.alg !== e);
|
|
606
606
|
} catch {
|
|
607
607
|
return !1;
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return !!((e === "v4" || !e) &&
|
|
610
|
+
function Zt(n, e) {
|
|
611
|
+
return !!((e === "v4" || !e) && kt.test(n) || (e === "v6" || !e) && Tt.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
|
-
const
|
|
617
|
-
return m(
|
|
618
|
-
code:
|
|
616
|
+
const s = this._getOrReturnCtx(e);
|
|
617
|
+
return m(s, {
|
|
618
|
+
code: u.invalid_type,
|
|
619
619
|
expected: p.string,
|
|
620
|
-
received:
|
|
620
|
+
received: s.parsedType
|
|
621
621
|
}), y;
|
|
622
622
|
}
|
|
623
|
-
const
|
|
624
|
-
let
|
|
625
|
-
for (const
|
|
626
|
-
if (
|
|
627
|
-
e.data.length <
|
|
628
|
-
code:
|
|
629
|
-
minimum:
|
|
623
|
+
const a = new S();
|
|
624
|
+
let i;
|
|
625
|
+
for (const s of this._def.checks)
|
|
626
|
+
if (s.kind === "min")
|
|
627
|
+
e.data.length < s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
628
|
+
code: u.too_small,
|
|
629
|
+
minimum: s.value,
|
|
630
630
|
type: "string",
|
|
631
631
|
inclusive: !0,
|
|
632
632
|
exact: !1,
|
|
633
|
-
message:
|
|
634
|
-
}),
|
|
635
|
-
else if (
|
|
636
|
-
e.data.length >
|
|
637
|
-
code:
|
|
638
|
-
maximum:
|
|
633
|
+
message: s.message
|
|
634
|
+
}), a.dirty());
|
|
635
|
+
else if (s.kind === "max")
|
|
636
|
+
e.data.length > s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
637
|
+
code: u.too_big,
|
|
638
|
+
maximum: s.value,
|
|
639
639
|
type: "string",
|
|
640
640
|
inclusive: !0,
|
|
641
641
|
exact: !1,
|
|
642
|
-
message:
|
|
643
|
-
}),
|
|
644
|
-
else if (
|
|
645
|
-
const c = e.data.length >
|
|
646
|
-
(c || o) && (
|
|
647
|
-
code:
|
|
648
|
-
maximum:
|
|
642
|
+
message: s.message
|
|
643
|
+
}), a.dirty());
|
|
644
|
+
else if (s.kind === "length") {
|
|
645
|
+
const c = e.data.length > s.value, o = e.data.length < s.value;
|
|
646
|
+
(c || o) && (i = this._getOrReturnCtx(e, i), c ? m(i, {
|
|
647
|
+
code: u.too_big,
|
|
648
|
+
maximum: s.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
|
-
message:
|
|
653
|
-
}) : o && m(
|
|
654
|
-
code:
|
|
655
|
-
minimum:
|
|
652
|
+
message: s.message
|
|
653
|
+
}) : o && m(i, {
|
|
654
|
+
code: u.too_small,
|
|
655
|
+
minimum: s.value,
|
|
656
656
|
type: "string",
|
|
657
657
|
inclusive: !0,
|
|
658
658
|
exact: !0,
|
|
659
|
-
message:
|
|
660
|
-
}),
|
|
661
|
-
} else if (
|
|
662
|
-
|
|
659
|
+
message: s.message
|
|
660
|
+
}), a.dirty());
|
|
661
|
+
} else if (s.kind === "email")
|
|
662
|
+
_t.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
663
663
|
validation: "email",
|
|
664
|
-
code:
|
|
665
|
-
message:
|
|
666
|
-
}),
|
|
667
|
-
else if (
|
|
668
|
-
|
|
664
|
+
code: u.invalid_string,
|
|
665
|
+
message: s.message
|
|
666
|
+
}), a.dirty());
|
|
667
|
+
else if (s.kind === "emoji")
|
|
668
|
+
Ne || (Ne = new RegExp(bt, "u")), Ne.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
669
669
|
validation: "emoji",
|
|
670
|
-
code:
|
|
671
|
-
message:
|
|
672
|
-
}),
|
|
673
|
-
else if (
|
|
674
|
-
|
|
670
|
+
code: u.invalid_string,
|
|
671
|
+
message: s.message
|
|
672
|
+
}), a.dirty());
|
|
673
|
+
else if (s.kind === "uuid")
|
|
674
|
+
ht.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
675
675
|
validation: "uuid",
|
|
676
|
-
code:
|
|
677
|
-
message:
|
|
678
|
-
}),
|
|
679
|
-
else if (
|
|
680
|
-
|
|
676
|
+
code: u.invalid_string,
|
|
677
|
+
message: s.message
|
|
678
|
+
}), a.dirty());
|
|
679
|
+
else if (s.kind === "nanoid")
|
|
680
|
+
gt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
681
681
|
validation: "nanoid",
|
|
682
|
-
code:
|
|
683
|
-
message:
|
|
684
|
-
}),
|
|
685
|
-
else if (
|
|
686
|
-
|
|
682
|
+
code: u.invalid_string,
|
|
683
|
+
message: s.message
|
|
684
|
+
}), a.dirty());
|
|
685
|
+
else if (s.kind === "cuid")
|
|
686
|
+
mt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
687
687
|
validation: "cuid",
|
|
688
|
-
code:
|
|
689
|
-
message:
|
|
690
|
-
}),
|
|
691
|
-
else if (
|
|
692
|
-
|
|
688
|
+
code: u.invalid_string,
|
|
689
|
+
message: s.message
|
|
690
|
+
}), a.dirty());
|
|
691
|
+
else if (s.kind === "cuid2")
|
|
692
|
+
pt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
693
693
|
validation: "cuid2",
|
|
694
|
-
code:
|
|
695
|
-
message:
|
|
696
|
-
}),
|
|
697
|
-
else if (
|
|
698
|
-
|
|
694
|
+
code: u.invalid_string,
|
|
695
|
+
message: s.message
|
|
696
|
+
}), a.dirty());
|
|
697
|
+
else if (s.kind === "ulid")
|
|
698
|
+
ft.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
699
699
|
validation: "ulid",
|
|
700
|
-
code:
|
|
701
|
-
message:
|
|
702
|
-
}),
|
|
703
|
-
else if (
|
|
700
|
+
code: u.invalid_string,
|
|
701
|
+
message: s.message
|
|
702
|
+
}), a.dirty());
|
|
703
|
+
else if (s.kind === "url")
|
|
704
704
|
try {
|
|
705
705
|
new URL(e.data);
|
|
706
706
|
} catch {
|
|
707
|
-
|
|
707
|
+
i = this._getOrReturnCtx(e, i), m(i, {
|
|
708
708
|
validation: "url",
|
|
709
|
-
code:
|
|
710
|
-
message:
|
|
711
|
-
}),
|
|
709
|
+
code: u.invalid_string,
|
|
710
|
+
message: s.message
|
|
711
|
+
}), a.dirty();
|
|
712
712
|
}
|
|
713
|
-
else
|
|
713
|
+
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
714
714
|
validation: "regex",
|
|
715
|
-
code:
|
|
716
|
-
message:
|
|
717
|
-
}),
|
|
718
|
-
code:
|
|
719
|
-
validation: { includes:
|
|
720
|
-
message:
|
|
721
|
-
}),
|
|
722
|
-
code:
|
|
723
|
-
validation: { startsWith:
|
|
724
|
-
message:
|
|
725
|
-
}),
|
|
726
|
-
code:
|
|
727
|
-
validation: { endsWith:
|
|
728
|
-
message:
|
|
729
|
-
}),
|
|
730
|
-
code:
|
|
715
|
+
code: u.invalid_string,
|
|
716
|
+
message: s.message
|
|
717
|
+
}), a.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
718
|
+
code: u.invalid_string,
|
|
719
|
+
validation: { includes: s.value, position: s.position },
|
|
720
|
+
message: s.message
|
|
721
|
+
}), a.dirty()) : s.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : s.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : s.kind === "startsWith" ? e.data.startsWith(s.value) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
722
|
+
code: u.invalid_string,
|
|
723
|
+
validation: { startsWith: s.value },
|
|
724
|
+
message: s.message
|
|
725
|
+
}), a.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
726
|
+
code: u.invalid_string,
|
|
727
|
+
validation: { endsWith: s.value },
|
|
728
|
+
message: s.message
|
|
729
|
+
}), a.dirty()) : s.kind === "datetime" ? Qe(s).test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
730
|
+
code: u.invalid_string,
|
|
731
731
|
validation: "datetime",
|
|
732
|
-
message:
|
|
733
|
-
}),
|
|
734
|
-
code:
|
|
732
|
+
message: s.message
|
|
733
|
+
}), a.dirty()) : s.kind === "date" ? At.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
734
|
+
code: u.invalid_string,
|
|
735
735
|
validation: "date",
|
|
736
|
-
message:
|
|
737
|
-
}),
|
|
738
|
-
code:
|
|
736
|
+
message: s.message
|
|
737
|
+
}), a.dirty()) : s.kind === "time" ? Nt(s).test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
738
|
+
code: u.invalid_string,
|
|
739
739
|
validation: "time",
|
|
740
|
-
message:
|
|
741
|
-
}),
|
|
740
|
+
message: s.message
|
|
741
|
+
}), a.dirty()) : s.kind === "duration" ? vt.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
742
742
|
validation: "duration",
|
|
743
|
-
code:
|
|
744
|
-
message:
|
|
745
|
-
}),
|
|
743
|
+
code: u.invalid_string,
|
|
744
|
+
message: s.message
|
|
745
|
+
}), a.dirty()) : s.kind === "ip" ? Ct(e.data, s.version) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
746
746
|
validation: "ip",
|
|
747
|
-
code:
|
|
748
|
-
message:
|
|
749
|
-
}),
|
|
747
|
+
code: u.invalid_string,
|
|
748
|
+
message: s.message
|
|
749
|
+
}), a.dirty()) : s.kind === "jwt" ? jt(e.data, s.alg) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
750
750
|
validation: "jwt",
|
|
751
|
-
code:
|
|
752
|
-
message:
|
|
753
|
-
}),
|
|
751
|
+
code: u.invalid_string,
|
|
752
|
+
message: s.message
|
|
753
|
+
}), a.dirty()) : s.kind === "cidr" ? Zt(e.data, s.version) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
754
754
|
validation: "cidr",
|
|
755
|
-
code:
|
|
756
|
-
message:
|
|
757
|
-
}),
|
|
755
|
+
code: u.invalid_string,
|
|
756
|
+
message: s.message
|
|
757
|
+
}), a.dirty()) : s.kind === "base64" ? St.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
758
758
|
validation: "base64",
|
|
759
|
-
code:
|
|
760
|
-
message:
|
|
761
|
-
}),
|
|
759
|
+
code: u.invalid_string,
|
|
760
|
+
message: s.message
|
|
761
|
+
}), a.dirty()) : s.kind === "base64url" ? It.test(e.data) || (i = this._getOrReturnCtx(e, i), m(i, {
|
|
762
762
|
validation: "base64url",
|
|
763
|
-
code:
|
|
764
|
-
message:
|
|
765
|
-
}),
|
|
766
|
-
return { status:
|
|
763
|
+
code: u.invalid_string,
|
|
764
|
+
message: s.message
|
|
765
|
+
}), a.dirty()) : b.assertNever(s);
|
|
766
|
+
return { status: a.value, value: e.data };
|
|
767
767
|
}
|
|
768
|
-
_regex(e, t,
|
|
769
|
-
return this.refinement((
|
|
768
|
+
_regex(e, t, a) {
|
|
769
|
+
return this.refinement((i) => e.test(i), {
|
|
770
770
|
validation: t,
|
|
771
|
-
code:
|
|
772
|
-
...h.errToObj(
|
|
771
|
+
code: u.invalid_string,
|
|
772
|
+
...h.errToObj(a)
|
|
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 A extends _ {
|
|
|
821
821
|
return this._addCheck({ kind: "cidr", ...h.errToObj(e) });
|
|
822
822
|
}
|
|
823
823
|
datetime(e) {
|
|
824
|
-
var t,
|
|
824
|
+
var t, a;
|
|
825
825
|
return typeof e == "string" ? this._addCheck({
|
|
826
826
|
kind: "datetime",
|
|
827
827
|
precision: null,
|
|
@@ -832,7 +832,7 @@ class A 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: (a = e == null ? void 0 : e.local) !== null && a !== void 0 ? a : !1,
|
|
836
836
|
...h.errToObj(e == null ? void 0 : e.message)
|
|
837
837
|
});
|
|
838
838
|
}
|
|
@@ -910,19 +910,19 @@ class A 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 A 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
|
|
1000
|
+
function Ot(n, e) {
|
|
1001
|
+
const t = (n.toString().split(".")[1] || "").length, a = (e.toString().split(".")[1] || "").length, i = t > a ? t : a, s = parseInt(n.toFixed(i).replace(".", "")), c = parseInt(e.toFixed(i).replace(".", ""));
|
|
1002
|
+
return s % c / Math.pow(10, i);
|
|
1003
1003
|
}
|
|
1004
1004
|
class M extends _ {
|
|
1005
1005
|
constructor() {
|
|
@@ -1007,44 +1007,44 @@ class M extends _ {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
_parse(e) {
|
|
1009
1009
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
|
|
1010
|
-
const
|
|
1011
|
-
return m(
|
|
1012
|
-
code:
|
|
1010
|
+
const s = this._getOrReturnCtx(e);
|
|
1011
|
+
return m(s, {
|
|
1012
|
+
code: u.invalid_type,
|
|
1013
1013
|
expected: p.number,
|
|
1014
|
-
received:
|
|
1014
|
+
received: s.parsedType
|
|
1015
1015
|
}), y;
|
|
1016
1016
|
}
|
|
1017
|
-
let
|
|
1018
|
-
const
|
|
1019
|
-
for (const
|
|
1020
|
-
|
|
1021
|
-
code:
|
|
1017
|
+
let a;
|
|
1018
|
+
const i = new S();
|
|
1019
|
+
for (const s of this._def.checks)
|
|
1020
|
+
s.kind === "int" ? b.isInteger(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1021
|
+
code: u.invalid_type,
|
|
1022
1022
|
expected: "integer",
|
|
1023
1023
|
received: "float",
|
|
1024
|
-
message:
|
|
1025
|
-
}),
|
|
1026
|
-
code:
|
|
1027
|
-
minimum:
|
|
1024
|
+
message: s.message
|
|
1025
|
+
}), i.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1026
|
+
code: u.too_small,
|
|
1027
|
+
minimum: s.value,
|
|
1028
1028
|
type: "number",
|
|
1029
|
-
inclusive:
|
|
1029
|
+
inclusive: s.inclusive,
|
|
1030
1030
|
exact: !1,
|
|
1031
|
-
message:
|
|
1032
|
-
}),
|
|
1033
|
-
code:
|
|
1034
|
-
maximum:
|
|
1031
|
+
message: s.message
|
|
1032
|
+
}), i.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1033
|
+
code: u.too_big,
|
|
1034
|
+
maximum: s.value,
|
|
1035
1035
|
type: "number",
|
|
1036
|
-
inclusive:
|
|
1036
|
+
inclusive: s.inclusive,
|
|
1037
1037
|
exact: !1,
|
|
1038
|
-
message:
|
|
1039
|
-
}),
|
|
1040
|
-
code:
|
|
1041
|
-
multipleOf:
|
|
1042
|
-
message:
|
|
1043
|
-
}),
|
|
1044
|
-
code:
|
|
1045
|
-
message:
|
|
1046
|
-
}),
|
|
1047
|
-
return { status:
|
|
1038
|
+
message: s.message
|
|
1039
|
+
}), i.dirty()) : s.kind === "multipleOf" ? Ot(e.data, s.value) !== 0 && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1040
|
+
code: u.not_multiple_of,
|
|
1041
|
+
multipleOf: s.value,
|
|
1042
|
+
message: s.message
|
|
1043
|
+
}), i.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1044
|
+
code: u.not_finite,
|
|
1045
|
+
message: s.message
|
|
1046
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1047
|
+
return { status: i.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 M 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, a, i) {
|
|
1062
1062
|
return new M({
|
|
1063
1063
|
...this._def,
|
|
1064
1064
|
checks: [
|
|
@@ -1066,8 +1066,8 @@ class M extends _ {
|
|
|
1066
1066
|
{
|
|
1067
1067
|
kind: e,
|
|
1068
1068
|
value: t,
|
|
1069
|
-
inclusive:
|
|
1070
|
-
message: h.toString(
|
|
1069
|
+
inclusive: a,
|
|
1070
|
+
message: h.toString(i)
|
|
1071
1071
|
}
|
|
1072
1072
|
]
|
|
1073
1073
|
});
|
|
@@ -1159,10 +1159,10 @@ class M extends _ {
|
|
|
1159
1159
|
}
|
|
1160
1160
|
get isFinite() {
|
|
1161
1161
|
let e = null, t = null;
|
|
1162
|
-
for (const
|
|
1163
|
-
if (
|
|
1162
|
+
for (const a of this._def.checks) {
|
|
1163
|
+
if (a.kind === "finite" || a.kind === "int" || a.kind === "multipleOf")
|
|
1164
1164
|
return !0;
|
|
1165
|
-
|
|
1165
|
+
a.kind === "min" ? (t === null || a.value > t) && (t = a.value) : a.kind === "max" && (e === null || a.value < e) && (e = a.value);
|
|
1166
1166
|
}
|
|
1167
1167
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1168
1168
|
}
|
|
@@ -1173,7 +1173,7 @@ M.create = (n) => new M({
|
|
|
1173
1173
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1174
1174
|
...v(n)
|
|
1175
1175
|
});
|
|
1176
|
-
class
|
|
1176
|
+
class z extends _ {
|
|
1177
1177
|
constructor() {
|
|
1178
1178
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1179
1179
|
}
|
|
@@ -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
|
|
1191
|
-
for (const
|
|
1192
|
-
|
|
1193
|
-
code:
|
|
1189
|
+
let a;
|
|
1190
|
+
const i = new S();
|
|
1191
|
+
for (const s of this._def.checks)
|
|
1192
|
+
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1193
|
+
code: u.too_small,
|
|
1194
1194
|
type: "bigint",
|
|
1195
|
-
minimum:
|
|
1196
|
-
inclusive:
|
|
1197
|
-
message:
|
|
1198
|
-
}),
|
|
1199
|
-
code:
|
|
1195
|
+
minimum: s.value,
|
|
1196
|
+
inclusive: s.inclusive,
|
|
1197
|
+
message: s.message
|
|
1198
|
+
}), i.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1199
|
+
code: u.too_big,
|
|
1200
1200
|
type: "bigint",
|
|
1201
|
-
maximum:
|
|
1202
|
-
inclusive:
|
|
1203
|
-
message:
|
|
1204
|
-
}),
|
|
1205
|
-
code:
|
|
1206
|
-
multipleOf:
|
|
1207
|
-
message:
|
|
1208
|
-
}),
|
|
1209
|
-
return { status:
|
|
1201
|
+
maximum: s.value,
|
|
1202
|
+
inclusive: s.inclusive,
|
|
1203
|
+
message: s.message
|
|
1204
|
+
}), i.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
1205
|
+
code: u.not_multiple_of,
|
|
1206
|
+
multipleOf: s.value,
|
|
1207
|
+
message: s.message
|
|
1208
|
+
}), i.dirty()) : b.assertNever(s);
|
|
1209
|
+
return { status: i.value, value: e.data };
|
|
1210
1210
|
}
|
|
1211
1211
|
_getInvalidInput(e) {
|
|
1212
1212
|
const t = this._getOrReturnCtx(e);
|
|
1213
1213
|
return m(t, {
|
|
1214
|
-
code:
|
|
1214
|
+
code: u.invalid_type,
|
|
1215
1215
|
expected: p.bigint,
|
|
1216
1216
|
received: t.parsedType
|
|
1217
1217
|
}), y;
|
|
@@ -1228,22 +1228,22 @@ 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,
|
|
1232
|
-
return new
|
|
1231
|
+
setLimit(e, t, a, i) {
|
|
1232
|
+
return new z({
|
|
1233
1233
|
...this._def,
|
|
1234
1234
|
checks: [
|
|
1235
1235
|
...this._def.checks,
|
|
1236
1236
|
{
|
|
1237
1237
|
kind: e,
|
|
1238
1238
|
value: t,
|
|
1239
|
-
inclusive:
|
|
1240
|
-
message: h.toString(
|
|
1239
|
+
inclusive: a,
|
|
1240
|
+
message: h.toString(i)
|
|
1241
1241
|
}
|
|
1242
1242
|
]
|
|
1243
1243
|
});
|
|
1244
1244
|
}
|
|
1245
1245
|
_addCheck(e) {
|
|
1246
|
-
return new
|
|
1246
|
+
return new z({
|
|
1247
1247
|
...this._def,
|
|
1248
1248
|
checks: [...this._def.checks, e]
|
|
1249
1249
|
});
|
|
@@ -1300,9 +1300,9 @@ class V extends _ {
|
|
|
1300
1300
|
return e;
|
|
1301
1301
|
}
|
|
1302
1302
|
}
|
|
1303
|
-
|
|
1303
|
+
z.create = (n) => {
|
|
1304
1304
|
var e;
|
|
1305
|
-
return new
|
|
1305
|
+
return new z({
|
|
1306
1306
|
checks: [],
|
|
1307
1307
|
typeName: g.ZodBigInt,
|
|
1308
1308
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1,
|
|
@@ -1312,11 +1312,11 @@ V.create = (n) => {
|
|
|
1312
1312
|
class re 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 a = this._getOrReturnCtx(e);
|
|
1316
|
+
return m(a, {
|
|
1317
|
+
code: u.invalid_type,
|
|
1318
1318
|
expected: p.boolean,
|
|
1319
|
-
received:
|
|
1319
|
+
received: a.parsedType
|
|
1320
1320
|
}), y;
|
|
1321
1321
|
}
|
|
1322
1322
|
return I(e.data);
|
|
@@ -1330,39 +1330,39 @@ re.create = (n) => new re({
|
|
|
1330
1330
|
class q extends _ {
|
|
1331
1331
|
_parse(e) {
|
|
1332
1332
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1333
|
-
const
|
|
1334
|
-
return m(
|
|
1335
|
-
code:
|
|
1333
|
+
const s = this._getOrReturnCtx(e);
|
|
1334
|
+
return m(s, {
|
|
1335
|
+
code: u.invalid_type,
|
|
1336
1336
|
expected: p.date,
|
|
1337
|
-
received:
|
|
1337
|
+
received: s.parsedType
|
|
1338
1338
|
}), y;
|
|
1339
1339
|
}
|
|
1340
1340
|
if (isNaN(e.data.getTime())) {
|
|
1341
|
-
const
|
|
1342
|
-
return m(
|
|
1343
|
-
code:
|
|
1341
|
+
const s = this._getOrReturnCtx(e);
|
|
1342
|
+
return m(s, {
|
|
1343
|
+
code: u.invalid_date
|
|
1344
1344
|
}), y;
|
|
1345
1345
|
}
|
|
1346
|
-
const
|
|
1347
|
-
let
|
|
1348
|
-
for (const
|
|
1349
|
-
|
|
1350
|
-
code:
|
|
1351
|
-
message:
|
|
1346
|
+
const a = new S();
|
|
1347
|
+
let i;
|
|
1348
|
+
for (const s of this._def.checks)
|
|
1349
|
+
s.kind === "min" ? e.data.getTime() < s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1350
|
+
code: u.too_small,
|
|
1351
|
+
message: s.message,
|
|
1352
1352
|
inclusive: !0,
|
|
1353
1353
|
exact: !1,
|
|
1354
|
-
minimum:
|
|
1354
|
+
minimum: s.value,
|
|
1355
1355
|
type: "date"
|
|
1356
|
-
}),
|
|
1357
|
-
code:
|
|
1358
|
-
message:
|
|
1356
|
+
}), a.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (i = this._getOrReturnCtx(e, i), m(i, {
|
|
1357
|
+
code: u.too_big,
|
|
1358
|
+
message: s.message,
|
|
1359
1359
|
inclusive: !0,
|
|
1360
1360
|
exact: !1,
|
|
1361
|
-
maximum:
|
|
1361
|
+
maximum: s.value,
|
|
1362
1362
|
type: "date"
|
|
1363
|
-
}),
|
|
1363
|
+
}), a.dirty()) : b.assertNever(s);
|
|
1364
1364
|
return {
|
|
1365
|
-
status:
|
|
1365
|
+
status: a.value,
|
|
1366
1366
|
value: new Date(e.data.getTime())
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
@@ -1408,11 +1408,11 @@ q.create = (n) => new q({
|
|
|
1408
1408
|
class be extends _ {
|
|
1409
1409
|
_parse(e) {
|
|
1410
1410
|
if (this._getType(e) !== p.symbol) {
|
|
1411
|
-
const
|
|
1412
|
-
return m(
|
|
1413
|
-
code:
|
|
1411
|
+
const a = this._getOrReturnCtx(e);
|
|
1412
|
+
return m(a, {
|
|
1413
|
+
code: u.invalid_type,
|
|
1414
1414
|
expected: p.symbol,
|
|
1415
|
-
received:
|
|
1415
|
+
received: a.parsedType
|
|
1416
1416
|
}), y;
|
|
1417
1417
|
}
|
|
1418
1418
|
return I(e.data);
|
|
@@ -1422,37 +1422,37 @@ be.create = (n) => new be({
|
|
|
1422
1422
|
typeName: g.ZodSymbol,
|
|
1423
1423
|
...v(n)
|
|
1424
1424
|
});
|
|
1425
|
-
class
|
|
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 a = this._getOrReturnCtx(e);
|
|
1429
|
+
return m(a, {
|
|
1430
|
+
code: u.invalid_type,
|
|
1431
1431
|
expected: p.undefined,
|
|
1432
|
-
received:
|
|
1432
|
+
received: a.parsedType
|
|
1433
1433
|
}), y;
|
|
1434
1434
|
}
|
|
1435
1435
|
return I(e.data);
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
|
-
|
|
1438
|
+
ae.create = (n) => new ae({
|
|
1439
1439
|
typeName: g.ZodUndefined,
|
|
1440
1440
|
...v(n)
|
|
1441
1441
|
});
|
|
1442
|
-
class
|
|
1442
|
+
class ie extends _ {
|
|
1443
1443
|
_parse(e) {
|
|
1444
1444
|
if (this._getType(e) !== p.null) {
|
|
1445
|
-
const
|
|
1446
|
-
return m(
|
|
1447
|
-
code:
|
|
1445
|
+
const a = this._getOrReturnCtx(e);
|
|
1446
|
+
return m(a, {
|
|
1447
|
+
code: u.invalid_type,
|
|
1448
1448
|
expected: p.null,
|
|
1449
|
-
received:
|
|
1449
|
+
received: a.parsedType
|
|
1450
1450
|
}), y;
|
|
1451
1451
|
}
|
|
1452
1452
|
return I(e.data);
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
|
|
1455
|
+
ie.create = (n) => new ie({
|
|
1456
1456
|
typeName: g.ZodNull,
|
|
1457
1457
|
...v(n)
|
|
1458
1458
|
});
|
|
@@ -1484,7 +1484,7 @@ class $ extends _ {
|
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
const t = this._getOrReturnCtx(e);
|
|
1486
1486
|
return m(t, {
|
|
1487
|
-
code:
|
|
1487
|
+
code: u.invalid_type,
|
|
1488
1488
|
expected: p.never,
|
|
1489
1489
|
received: t.parsedType
|
|
1490
1490
|
}), y;
|
|
@@ -1497,11 +1497,11 @@ $.create = (n) => new $({
|
|
|
1497
1497
|
class xe extends _ {
|
|
1498
1498
|
_parse(e) {
|
|
1499
1499
|
if (this._getType(e) !== p.undefined) {
|
|
1500
|
-
const
|
|
1501
|
-
return m(
|
|
1502
|
-
code:
|
|
1500
|
+
const a = this._getOrReturnCtx(e);
|
|
1501
|
+
return m(a, {
|
|
1502
|
+
code: u.invalid_type,
|
|
1503
1503
|
expected: p.void,
|
|
1504
|
-
received:
|
|
1504
|
+
received: a.parsedType
|
|
1505
1505
|
}), y;
|
|
1506
1506
|
}
|
|
1507
1507
|
return I(e.data);
|
|
@@ -1513,43 +1513,43 @@ xe.create = (n) => new xe({
|
|
|
1513
1513
|
});
|
|
1514
1514
|
class C extends _ {
|
|
1515
1515
|
_parse(e) {
|
|
1516
|
-
const { ctx: t, status:
|
|
1516
|
+
const { ctx: t, status: a } = this._processInputParams(e), i = this._def;
|
|
1517
1517
|
if (t.parsedType !== p.array)
|
|
1518
1518
|
return m(t, {
|
|
1519
|
-
code:
|
|
1519
|
+
code: u.invalid_type,
|
|
1520
1520
|
expected: p.array,
|
|
1521
1521
|
received: t.parsedType
|
|
1522
1522
|
}), y;
|
|
1523
|
-
if (
|
|
1524
|
-
const c = t.data.length >
|
|
1523
|
+
if (i.exactLength !== null) {
|
|
1524
|
+
const c = t.data.length > i.exactLength.value, o = t.data.length < i.exactLength.value;
|
|
1525
1525
|
(c || o) && (m(t, {
|
|
1526
|
-
code: c ?
|
|
1527
|
-
minimum: o ?
|
|
1528
|
-
maximum: c ?
|
|
1526
|
+
code: c ? u.too_big : u.too_small,
|
|
1527
|
+
minimum: o ? i.exactLength.value : void 0,
|
|
1528
|
+
maximum: c ? i.exactLength.value : void 0,
|
|
1529
1529
|
type: "array",
|
|
1530
1530
|
inclusive: !0,
|
|
1531
1531
|
exact: !0,
|
|
1532
|
-
message:
|
|
1533
|
-
}),
|
|
1532
|
+
message: i.exactLength.message
|
|
1533
|
+
}), a.dirty());
|
|
1534
1534
|
}
|
|
1535
|
-
if (
|
|
1536
|
-
code:
|
|
1537
|
-
minimum:
|
|
1535
|
+
if (i.minLength !== null && t.data.length < i.minLength.value && (m(t, {
|
|
1536
|
+
code: u.too_small,
|
|
1537
|
+
minimum: i.minLength.value,
|
|
1538
1538
|
type: "array",
|
|
1539
1539
|
inclusive: !0,
|
|
1540
1540
|
exact: !1,
|
|
1541
|
-
message:
|
|
1542
|
-
}),
|
|
1543
|
-
code:
|
|
1544
|
-
maximum:
|
|
1541
|
+
message: i.minLength.message
|
|
1542
|
+
}), a.dirty()), i.maxLength !== null && t.data.length > i.maxLength.value && (m(t, {
|
|
1543
|
+
code: u.too_big,
|
|
1544
|
+
maximum: i.maxLength.value,
|
|
1545
1545
|
type: "array",
|
|
1546
1546
|
inclusive: !0,
|
|
1547
1547
|
exact: !1,
|
|
1548
|
-
message:
|
|
1549
|
-
}),
|
|
1550
|
-
return Promise.all([...t.data].map((c, o) =>
|
|
1551
|
-
const
|
|
1552
|
-
return S.mergeArray(
|
|
1548
|
+
message: i.maxLength.message
|
|
1549
|
+
}), a.dirty()), t.common.async)
|
|
1550
|
+
return Promise.all([...t.data].map((c, o) => i.type._parseAsync(new O(t, c, t.path, o)))).then((c) => S.mergeArray(a, c));
|
|
1551
|
+
const s = [...t.data].map((c, o) => i.type._parseSync(new O(t, c, t.path, o)));
|
|
1552
|
+
return S.mergeArray(a, s);
|
|
1553
1553
|
}
|
|
1554
1554
|
get element() {
|
|
1555
1555
|
return this._def.type;
|
|
@@ -1588,8 +1588,8 @@ function W(n) {
|
|
|
1588
1588
|
if (n instanceof k) {
|
|
1589
1589
|
const e = {};
|
|
1590
1590
|
for (const t in n.shape) {
|
|
1591
|
-
const
|
|
1592
|
-
e[t] = Z.create(W(
|
|
1591
|
+
const a = n.shape[t];
|
|
1592
|
+
e[t] = Z.create(W(a));
|
|
1593
1593
|
}
|
|
1594
1594
|
return new k({
|
|
1595
1595
|
...n._def,
|
|
@@ -1612,66 +1612,66 @@ class k extends _ {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
_parse(e) {
|
|
1614
1614
|
if (this._getType(e) !== p.object) {
|
|
1615
|
-
const
|
|
1616
|
-
return m(
|
|
1617
|
-
code:
|
|
1615
|
+
const d = this._getOrReturnCtx(e);
|
|
1616
|
+
return m(d, {
|
|
1617
|
+
code: u.invalid_type,
|
|
1618
1618
|
expected: p.object,
|
|
1619
|
-
received:
|
|
1619
|
+
received: d.parsedType
|
|
1620
1620
|
}), y;
|
|
1621
1621
|
}
|
|
1622
|
-
const { status:
|
|
1622
|
+
const { status: a, ctx: i } = this._processInputParams(e), { shape: s, keys: c } = this._getCached(), o = [];
|
|
1623
1623
|
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1624
|
-
for (const
|
|
1625
|
-
c.includes(
|
|
1624
|
+
for (const d in i.data)
|
|
1625
|
+
c.includes(d) || o.push(d);
|
|
1626
1626
|
const l = [];
|
|
1627
|
-
for (const
|
|
1628
|
-
const f =
|
|
1627
|
+
for (const d of c) {
|
|
1628
|
+
const f = s[d], x = i.data[d];
|
|
1629
1629
|
l.push({
|
|
1630
|
-
key: { status: "valid", value:
|
|
1631
|
-
value: f._parse(new O(
|
|
1632
|
-
alwaysSet:
|
|
1630
|
+
key: { status: "valid", value: d },
|
|
1631
|
+
value: f._parse(new O(i, x, i.path, d)),
|
|
1632
|
+
alwaysSet: d in i.data
|
|
1633
1633
|
});
|
|
1634
1634
|
}
|
|
1635
1635
|
if (this._def.catchall instanceof $) {
|
|
1636
|
-
const
|
|
1637
|
-
if (
|
|
1636
|
+
const d = this._def.unknownKeys;
|
|
1637
|
+
if (d === "passthrough")
|
|
1638
1638
|
for (const f of o)
|
|
1639
1639
|
l.push({
|
|
1640
1640
|
key: { status: "valid", value: f },
|
|
1641
|
-
value: { status: "valid", value:
|
|
1641
|
+
value: { status: "valid", value: i.data[f] }
|
|
1642
1642
|
});
|
|
1643
|
-
else if (
|
|
1644
|
-
o.length > 0 && (m(
|
|
1645
|
-
code:
|
|
1643
|
+
else if (d === "strict")
|
|
1644
|
+
o.length > 0 && (m(i, {
|
|
1645
|
+
code: u.unrecognized_keys,
|
|
1646
1646
|
keys: o
|
|
1647
|
-
}),
|
|
1648
|
-
else if (
|
|
1647
|
+
}), a.dirty());
|
|
1648
|
+
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1649
1649
|
} else {
|
|
1650
|
-
const
|
|
1650
|
+
const d = this._def.catchall;
|
|
1651
1651
|
for (const f of o) {
|
|
1652
|
-
const x =
|
|
1652
|
+
const x = i.data[f];
|
|
1653
1653
|
l.push({
|
|
1654
1654
|
key: { status: "valid", value: f },
|
|
1655
|
-
value:
|
|
1656
|
-
new O(
|
|
1655
|
+
value: d._parse(
|
|
1656
|
+
new O(i, x, i.path, f)
|
|
1657
1657
|
//, ctx.child(key), value, getParsedType(value)
|
|
1658
1658
|
),
|
|
1659
|
-
alwaysSet: f in
|
|
1659
|
+
alwaysSet: f in i.data
|
|
1660
1660
|
});
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
-
return
|
|
1664
|
-
const
|
|
1663
|
+
return i.common.async ? Promise.resolve().then(async () => {
|
|
1664
|
+
const d = [];
|
|
1665
1665
|
for (const f of l) {
|
|
1666
1666
|
const x = await f.key, T = await f.value;
|
|
1667
|
-
|
|
1667
|
+
d.push({
|
|
1668
1668
|
key: x,
|
|
1669
1669
|
value: T,
|
|
1670
1670
|
alwaysSet: f.alwaysSet
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
|
-
return
|
|
1674
|
-
}).then((
|
|
1673
|
+
return d;
|
|
1674
|
+
}).then((d) => S.mergeObjectSync(a, d)) : S.mergeObjectSync(a, l);
|
|
1675
1675
|
}
|
|
1676
1676
|
get shape() {
|
|
1677
1677
|
return this._def.shape();
|
|
@@ -1681,9 +1681,9 @@ class k extends _ {
|
|
|
1681
1681
|
...this._def,
|
|
1682
1682
|
unknownKeys: "strict",
|
|
1683
1683
|
...e !== void 0 ? {
|
|
1684
|
-
errorMap: (t,
|
|
1685
|
-
var
|
|
1686
|
-
const l = (c = (
|
|
1684
|
+
errorMap: (t, a) => {
|
|
1685
|
+
var i, s, c, o;
|
|
1686
|
+
const l = (c = (s = (i = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(i, t, a).message) !== null && c !== void 0 ? c : a.defaultError;
|
|
1687
1687
|
return t.code === "unrecognized_keys" ? {
|
|
1688
1688
|
message: (o = h.errToObj(e).message) !== null && o !== void 0 ? o : l
|
|
1689
1689
|
} : {
|
|
@@ -1814,8 +1814,8 @@ class k extends _ {
|
|
|
1814
1814
|
}
|
|
1815
1815
|
pick(e) {
|
|
1816
1816
|
const t = {};
|
|
1817
|
-
return b.objectKeys(e).forEach((
|
|
1818
|
-
e[
|
|
1817
|
+
return b.objectKeys(e).forEach((a) => {
|
|
1818
|
+
e[a] && this.shape[a] && (t[a] = this.shape[a]);
|
|
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 b.objectKeys(this.shape).forEach((
|
|
1827
|
-
e[
|
|
1826
|
+
return b.objectKeys(this.shape).forEach((a) => {
|
|
1827
|
+
e[a] || (t[a] = this.shape[a]);
|
|
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 b.objectKeys(this.shape).forEach((
|
|
1842
|
-
const
|
|
1843
|
-
e && !e[
|
|
1841
|
+
return b.objectKeys(this.shape).forEach((a) => {
|
|
1842
|
+
const i = this.shape[a];
|
|
1843
|
+
e && !e[a] ? t[a] = i : t[a] = i.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 b.objectKeys(this.shape).forEach((
|
|
1852
|
-
if (e && !e[
|
|
1853
|
-
t[
|
|
1851
|
+
return b.objectKeys(this.shape).forEach((a) => {
|
|
1852
|
+
if (e && !e[a])
|
|
1853
|
+
t[a] = this.shape[a];
|
|
1854
1854
|
else {
|
|
1855
|
-
let
|
|
1856
|
-
for (;
|
|
1857
|
-
|
|
1858
|
-
t[
|
|
1855
|
+
let s = this.shape[a];
|
|
1856
|
+
for (; s instanceof Z; )
|
|
1857
|
+
s = s._def.innerType;
|
|
1858
|
+
t[a] = 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 Ye(b.objectKeys(this.shape));
|
|
1867
1867
|
}
|
|
1868
1868
|
}
|
|
1869
1869
|
k.create = (n, e) => new k({
|
|
@@ -1887,24 +1887,24 @@ k.lazycreate = (n, e) => new k({
|
|
|
1887
1887
|
typeName: g.ZodObject,
|
|
1888
1888
|
...v(e)
|
|
1889
1889
|
});
|
|
1890
|
-
class
|
|
1890
|
+
class se extends _ {
|
|
1891
1891
|
_parse(e) {
|
|
1892
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1893
|
-
function
|
|
1894
|
-
for (const o of
|
|
1892
|
+
const { ctx: t } = this._processInputParams(e), a = this._def.options;
|
|
1893
|
+
function i(s) {
|
|
1894
|
+
for (const o of s)
|
|
1895
1895
|
if (o.result.status === "valid")
|
|
1896
1896
|
return o.result;
|
|
1897
|
-
for (const o of
|
|
1897
|
+
for (const o of s)
|
|
1898
1898
|
if (o.result.status === "dirty")
|
|
1899
1899
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1900
|
-
const c =
|
|
1900
|
+
const c = s.map((o) => new A(o.ctx.common.issues));
|
|
1901
1901
|
return m(t, {
|
|
1902
|
-
code:
|
|
1902
|
+
code: u.invalid_union,
|
|
1903
1903
|
unionErrors: c
|
|
1904
1904
|
}), y;
|
|
1905
1905
|
}
|
|
1906
1906
|
if (t.common.async)
|
|
1907
|
-
return Promise.all(
|
|
1907
|
+
return Promise.all(a.map(async (s) => {
|
|
1908
1908
|
const c = {
|
|
1909
1909
|
...t,
|
|
1910
1910
|
common: {
|
|
@@ -1914,19 +1914,19 @@ class ie extends _ {
|
|
|
1914
1914
|
parent: null
|
|
1915
1915
|
};
|
|
1916
1916
|
return {
|
|
1917
|
-
result: await
|
|
1917
|
+
result: await s._parseAsync({
|
|
1918
1918
|
data: t.data,
|
|
1919
1919
|
path: t.path,
|
|
1920
1920
|
parent: c
|
|
1921
1921
|
}),
|
|
1922
1922
|
ctx: c
|
|
1923
1923
|
};
|
|
1924
|
-
})).then(
|
|
1924
|
+
})).then(i);
|
|
1925
1925
|
{
|
|
1926
|
-
let
|
|
1926
|
+
let s;
|
|
1927
1927
|
const c = [];
|
|
1928
|
-
for (const l of
|
|
1929
|
-
const
|
|
1928
|
+
for (const l of a) {
|
|
1929
|
+
const d = {
|
|
1930
1930
|
...t,
|
|
1931
1931
|
common: {
|
|
1932
1932
|
...t.common,
|
|
@@ -1936,17 +1936,17 @@ class ie extends _ {
|
|
|
1936
1936
|
}, f = l._parseSync({
|
|
1937
1937
|
data: t.data,
|
|
1938
1938
|
path: t.path,
|
|
1939
|
-
parent:
|
|
1939
|
+
parent: d
|
|
1940
1940
|
});
|
|
1941
1941
|
if (f.status === "valid")
|
|
1942
1942
|
return f;
|
|
1943
|
-
f.status === "dirty" && !
|
|
1943
|
+
f.status === "dirty" && !s && (s = { result: f, ctx: d }), d.common.issues.length && c.push(d.common.issues);
|
|
1944
1944
|
}
|
|
1945
|
-
if (
|
|
1946
|
-
return t.common.issues.push(...
|
|
1947
|
-
const o = c.map((l) => new
|
|
1945
|
+
if (s)
|
|
1946
|
+
return t.common.issues.push(...s.ctx.common.issues), s.result;
|
|
1947
|
+
const o = c.map((l) => new A(l));
|
|
1948
1948
|
return m(t, {
|
|
1949
|
-
code:
|
|
1949
|
+
code: u.invalid_union,
|
|
1950
1950
|
unionErrors: o
|
|
1951
1951
|
}), y;
|
|
1952
1952
|
}
|
|
@@ -1955,34 +1955,34 @@ class ie extends _ {
|
|
|
1955
1955
|
return this._def.options;
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
|
-
|
|
1958
|
+
se.create = (n, e) => new se({
|
|
1959
1959
|
options: n,
|
|
1960
1960
|
typeName: g.ZodUnion,
|
|
1961
1961
|
...v(e)
|
|
1962
1962
|
});
|
|
1963
|
-
const P = (n) => n instanceof
|
|
1963
|
+
const P = (n) => n instanceof ue ? P(n.schema) : n instanceof j ? P(n.innerType()) : n instanceof de ? [n.value] : n instanceof V ? n.options : n instanceof le ? b.objectValues(n.enum) : n instanceof me ? P(n._def.innerType) : n instanceof ae ? [void 0] : n instanceof ie ? [null] : n instanceof Z ? [void 0, ...P(n.unwrap())] : n instanceof L ? [null, ...P(n.unwrap())] : n instanceof Pe || n instanceof fe ? P(n.unwrap()) : n instanceof pe ? P(n._def.innerType) : [];
|
|
1964
1964
|
class Te extends _ {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: t } = this._processInputParams(e);
|
|
1967
1967
|
if (t.parsedType !== p.object)
|
|
1968
1968
|
return m(t, {
|
|
1969
|
-
code:
|
|
1969
|
+
code: u.invalid_type,
|
|
1970
1970
|
expected: p.object,
|
|
1971
1971
|
received: t.parsedType
|
|
1972
1972
|
}), y;
|
|
1973
|
-
const
|
|
1974
|
-
return
|
|
1973
|
+
const a = this.discriminator, i = t.data[a], s = this.optionsMap.get(i);
|
|
1974
|
+
return s ? t.common.async ? s._parseAsync({
|
|
1975
1975
|
data: t.data,
|
|
1976
1976
|
path: t.path,
|
|
1977
1977
|
parent: t
|
|
1978
|
-
}) :
|
|
1978
|
+
}) : s._parseSync({
|
|
1979
1979
|
data: t.data,
|
|
1980
1980
|
path: t.path,
|
|
1981
1981
|
parent: t
|
|
1982
1982
|
}) : (m(t, {
|
|
1983
|
-
code:
|
|
1983
|
+
code: u.invalid_union_discriminator,
|
|
1984
1984
|
options: Array.from(this.optionsMap.keys()),
|
|
1985
|
-
path: [
|
|
1985
|
+
path: [a]
|
|
1986
1986
|
}), y);
|
|
1987
1987
|
}
|
|
1988
1988
|
get discriminator() {
|
|
@@ -2002,82 +2002,82 @@ 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
|
|
2007
|
-
for (const
|
|
2008
|
-
const c = P(
|
|
2005
|
+
static create(e, t, a) {
|
|
2006
|
+
const i = /* @__PURE__ */ new Map();
|
|
2007
|
+
for (const s of t) {
|
|
2008
|
+
const c = P(s.shape[e]);
|
|
2009
2009
|
if (!c.length)
|
|
2010
2010
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2011
2011
|
for (const o of c) {
|
|
2012
|
-
if (
|
|
2012
|
+
if (i.has(o))
|
|
2013
2013
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2014
|
-
|
|
2014
|
+
i.set(o, s);
|
|
2015
2015
|
}
|
|
2016
2016
|
}
|
|
2017
2017
|
return new Te({
|
|
2018
2018
|
typeName: g.ZodDiscriminatedUnion,
|
|
2019
2019
|
discriminator: e,
|
|
2020
2020
|
options: t,
|
|
2021
|
-
optionsMap:
|
|
2022
|
-
...v(
|
|
2021
|
+
optionsMap: i,
|
|
2022
|
+
...v(a)
|
|
2023
2023
|
});
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
2026
|
function Oe(n, e) {
|
|
2027
|
-
const t = E(n),
|
|
2027
|
+
const t = E(n), a = E(e);
|
|
2028
2028
|
if (n === e)
|
|
2029
2029
|
return { valid: !0, data: n };
|
|
2030
|
-
if (t === p.object &&
|
|
2031
|
-
const
|
|
2032
|
-
for (const o of
|
|
2030
|
+
if (t === p.object && a === p.object) {
|
|
2031
|
+
const i = b.objectKeys(e), s = b.objectKeys(n).filter((o) => i.indexOf(o) !== -1), c = { ...n, ...e };
|
|
2032
|
+
for (const o of s) {
|
|
2033
2033
|
const l = Oe(n[o], e[o]);
|
|
2034
2034
|
if (!l.valid)
|
|
2035
2035
|
return { valid: !1 };
|
|
2036
2036
|
c[o] = l.data;
|
|
2037
2037
|
}
|
|
2038
2038
|
return { valid: !0, data: c };
|
|
2039
|
-
} else if (t === p.array &&
|
|
2039
|
+
} else if (t === p.array && a === p.array) {
|
|
2040
2040
|
if (n.length !== e.length)
|
|
2041
2041
|
return { valid: !1 };
|
|
2042
|
-
const
|
|
2043
|
-
for (let
|
|
2044
|
-
const c = n[
|
|
2042
|
+
const i = [];
|
|
2043
|
+
for (let s = 0; s < n.length; s++) {
|
|
2044
|
+
const c = n[s], o = e[s], l = Oe(c, o);
|
|
2045
2045
|
if (!l.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
|
-
|
|
2047
|
+
i.push(l.data);
|
|
2048
2048
|
}
|
|
2049
|
-
return { valid: !0, data:
|
|
2050
|
-
} else return t === p.date &&
|
|
2049
|
+
return { valid: !0, data: i };
|
|
2050
|
+
} else return t === p.date && a === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2051
2051
|
}
|
|
2052
2052
|
class oe extends _ {
|
|
2053
2053
|
_parse(e) {
|
|
2054
|
-
const { status: t, ctx:
|
|
2055
|
-
if (je(
|
|
2054
|
+
const { status: t, ctx: a } = this._processInputParams(e), i = (s, c) => {
|
|
2055
|
+
if (je(s) || je(c))
|
|
2056
2056
|
return y;
|
|
2057
|
-
const o = Oe(
|
|
2058
|
-
return o.valid ? ((Ze(
|
|
2059
|
-
code:
|
|
2057
|
+
const o = Oe(s.value, c.value);
|
|
2058
|
+
return o.valid ? ((Ze(s) || Ze(c)) && t.dirty(), { status: t.value, value: o.data }) : (m(a, {
|
|
2059
|
+
code: u.invalid_intersection_types
|
|
2060
2060
|
}), y);
|
|
2061
2061
|
};
|
|
2062
|
-
return
|
|
2062
|
+
return a.common.async ? Promise.all([
|
|
2063
2063
|
this._def.left._parseAsync({
|
|
2064
|
-
data:
|
|
2065
|
-
path:
|
|
2066
|
-
parent:
|
|
2064
|
+
data: a.data,
|
|
2065
|
+
path: a.path,
|
|
2066
|
+
parent: a
|
|
2067
2067
|
}),
|
|
2068
2068
|
this._def.right._parseAsync({
|
|
2069
|
-
data:
|
|
2070
|
-
path:
|
|
2071
|
-
parent:
|
|
2069
|
+
data: a.data,
|
|
2070
|
+
path: a.path,
|
|
2071
|
+
parent: a
|
|
2072
2072
|
})
|
|
2073
|
-
]).then(([
|
|
2074
|
-
data:
|
|
2075
|
-
path:
|
|
2076
|
-
parent:
|
|
2073
|
+
]).then(([s, c]) => i(s, c)) : i(this._def.left._parseSync({
|
|
2074
|
+
data: a.data,
|
|
2075
|
+
path: a.path,
|
|
2076
|
+
parent: a
|
|
2077
2077
|
}), this._def.right._parseSync({
|
|
2078
|
-
data:
|
|
2079
|
-
path:
|
|
2080
|
-
parent:
|
|
2078
|
+
data: a.data,
|
|
2079
|
+
path: a.path,
|
|
2080
|
+
parent: a
|
|
2081
2081
|
}));
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
@@ -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: a } = this._processInputParams(e);
|
|
2093
|
+
if (a.parsedType !== p.array)
|
|
2094
|
+
return m(a, {
|
|
2095
|
+
code: u.invalid_type,
|
|
2096
2096
|
expected: p.array,
|
|
2097
|
-
received:
|
|
2097
|
+
received: a.parsedType
|
|
2098
2098
|
}), y;
|
|
2099
|
-
if (
|
|
2100
|
-
return m(
|
|
2101
|
-
code:
|
|
2099
|
+
if (a.data.length < this._def.items.length)
|
|
2100
|
+
return m(a, {
|
|
2101
|
+
code: u.too_small,
|
|
2102
2102
|
minimum: this._def.items.length,
|
|
2103
2103
|
inclusive: !0,
|
|
2104
2104
|
exact: !1,
|
|
2105
2105
|
type: "array"
|
|
2106
2106
|
}), y;
|
|
2107
|
-
!this._def.rest &&
|
|
2108
|
-
code:
|
|
2107
|
+
!this._def.rest && a.data.length > this._def.items.length && (m(a, {
|
|
2108
|
+
code: u.too_big,
|
|
2109
2109
|
maximum: this._def.items.length,
|
|
2110
2110
|
inclusive: !0,
|
|
2111
2111
|
exact: !1,
|
|
2112
2112
|
type: "array"
|
|
2113
2113
|
}), t.dirty());
|
|
2114
|
-
const
|
|
2114
|
+
const s = [...a.data].map((c, o) => {
|
|
2115
2115
|
const l = this._def.items[o] || this._def.rest;
|
|
2116
|
-
return l ? l._parse(new O(
|
|
2116
|
+
return l ? l._parse(new O(a, c, a.path, o)) : null;
|
|
2117
2117
|
}).filter((c) => !!c);
|
|
2118
|
-
return
|
|
2118
|
+
return a.common.async ? Promise.all(s).then((c) => S.mergeArray(t, c)) : S.mergeArray(t, s);
|
|
2119
2119
|
}
|
|
2120
2120
|
get items() {
|
|
2121
2121
|
return this._def.items;
|
|
@@ -2145,33 +2145,33 @@ 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: a } = this._processInputParams(e);
|
|
2149
|
+
if (a.parsedType !== p.object)
|
|
2150
|
+
return m(a, {
|
|
2151
|
+
code: u.invalid_type,
|
|
2152
2152
|
expected: p.object,
|
|
2153
|
-
received:
|
|
2153
|
+
received: a.parsedType
|
|
2154
2154
|
}), y;
|
|
2155
|
-
const
|
|
2156
|
-
for (const o in
|
|
2157
|
-
|
|
2158
|
-
key:
|
|
2159
|
-
value: c._parse(new O(
|
|
2160
|
-
alwaysSet: o in
|
|
2155
|
+
const i = [], s = this._def.keyType, c = this._def.valueType;
|
|
2156
|
+
for (const o in a.data)
|
|
2157
|
+
i.push({
|
|
2158
|
+
key: s._parse(new O(a, o, a.path, o)),
|
|
2159
|
+
value: c._parse(new O(a, a.data[o], a.path, o)),
|
|
2160
|
+
alwaysSet: o in a.data
|
|
2161
2161
|
});
|
|
2162
|
-
return
|
|
2162
|
+
return a.common.async ? S.mergeObjectAsync(t, i) : S.mergeObjectSync(t, i);
|
|
2163
2163
|
}
|
|
2164
2164
|
get element() {
|
|
2165
2165
|
return this._def.valueType;
|
|
2166
2166
|
}
|
|
2167
|
-
static create(e, t,
|
|
2167
|
+
static create(e, t, a) {
|
|
2168
2168
|
return t instanceof _ ? new ce({
|
|
2169
2169
|
keyType: e,
|
|
2170
2170
|
valueType: t,
|
|
2171
2171
|
typeName: g.ZodRecord,
|
|
2172
|
-
...v(
|
|
2172
|
+
...v(a)
|
|
2173
2173
|
}) : new ce({
|
|
2174
|
-
keyType:
|
|
2174
|
+
keyType: N.create(),
|
|
2175
2175
|
valueType: e,
|
|
2176
2176
|
typeName: g.ZodRecord,
|
|
2177
2177
|
...v(t)
|
|
@@ -2186,35 +2186,35 @@ 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: a } = this._processInputParams(e);
|
|
2190
|
+
if (a.parsedType !== p.map)
|
|
2191
|
+
return m(a, {
|
|
2192
|
+
code: u.invalid_type,
|
|
2193
2193
|
expected: p.map,
|
|
2194
|
-
received:
|
|
2194
|
+
received: a.parsedType
|
|
2195
2195
|
}), y;
|
|
2196
|
-
const
|
|
2197
|
-
key:
|
|
2198
|
-
value:
|
|
2196
|
+
const i = this._def.keyType, s = this._def.valueType, c = [...a.data.entries()].map(([o, l], d) => ({
|
|
2197
|
+
key: i._parse(new O(a, o, a.path, [d, "key"])),
|
|
2198
|
+
value: s._parse(new O(a, l, a.path, [d, "value"]))
|
|
2199
2199
|
}));
|
|
2200
|
-
if (
|
|
2200
|
+
if (a.common.async) {
|
|
2201
2201
|
const o = /* @__PURE__ */ new Map();
|
|
2202
2202
|
return Promise.resolve().then(async () => {
|
|
2203
2203
|
for (const l of c) {
|
|
2204
|
-
const
|
|
2205
|
-
if (
|
|
2204
|
+
const d = await l.key, f = await l.value;
|
|
2205
|
+
if (d.status === "aborted" || f.status === "aborted")
|
|
2206
2206
|
return y;
|
|
2207
|
-
(
|
|
2207
|
+
(d.status === "dirty" || f.status === "dirty") && t.dirty(), o.set(d.value, f.value);
|
|
2208
2208
|
}
|
|
2209
2209
|
return { status: t.value, value: o };
|
|
2210
2210
|
});
|
|
2211
2211
|
} else {
|
|
2212
2212
|
const o = /* @__PURE__ */ new Map();
|
|
2213
2213
|
for (const l of c) {
|
|
2214
|
-
const
|
|
2215
|
-
if (
|
|
2214
|
+
const d = l.key, f = l.value;
|
|
2215
|
+
if (d.status === "aborted" || f.status === "aborted")
|
|
2216
2216
|
return y;
|
|
2217
|
-
(
|
|
2217
|
+
(d.status === "dirty" || f.status === "dirty") && t.dirty(), o.set(d.value, f.value);
|
|
2218
2218
|
}
|
|
2219
2219
|
return { status: t.value, value: o };
|
|
2220
2220
|
}
|
|
@@ -2228,41 +2228,41 @@ ke.create = (n, e, t) => new ke({
|
|
|
2228
2228
|
});
|
|
2229
2229
|
class B extends _ {
|
|
2230
2230
|
_parse(e) {
|
|
2231
|
-
const { status: t, ctx:
|
|
2232
|
-
if (
|
|
2233
|
-
return m(
|
|
2234
|
-
code:
|
|
2231
|
+
const { status: t, ctx: a } = this._processInputParams(e);
|
|
2232
|
+
if (a.parsedType !== p.set)
|
|
2233
|
+
return m(a, {
|
|
2234
|
+
code: u.invalid_type,
|
|
2235
2235
|
expected: p.set,
|
|
2236
|
-
received:
|
|
2236
|
+
received: a.parsedType
|
|
2237
2237
|
}), y;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2240
|
-
code:
|
|
2241
|
-
minimum:
|
|
2238
|
+
const i = this._def;
|
|
2239
|
+
i.minSize !== null && a.data.size < i.minSize.value && (m(a, {
|
|
2240
|
+
code: u.too_small,
|
|
2241
|
+
minimum: i.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: i.minSize.message
|
|
2246
|
+
}), t.dirty()), i.maxSize !== null && a.data.size > i.maxSize.value && (m(a, {
|
|
2247
|
+
code: u.too_big,
|
|
2248
|
+
maximum: i.maxSize.value,
|
|
2249
2249
|
type: "set",
|
|
2250
2250
|
inclusive: !0,
|
|
2251
2251
|
exact: !1,
|
|
2252
|
-
message:
|
|
2252
|
+
message: i.maxSize.message
|
|
2253
2253
|
}), t.dirty());
|
|
2254
|
-
const
|
|
2254
|
+
const s = this._def.valueType;
|
|
2255
2255
|
function c(l) {
|
|
2256
|
-
const
|
|
2256
|
+
const d = /* @__PURE__ */ new Set();
|
|
2257
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(), d.add(f.value);
|
|
2261
2261
|
}
|
|
2262
|
-
return { status: t.value, value:
|
|
2262
|
+
return { status: t.value, value: d };
|
|
2263
2263
|
}
|
|
2264
|
-
const o = [...
|
|
2265
|
-
return
|
|
2264
|
+
const o = [...a.data.values()].map((l, d) => s._parse(new O(a, l, a.path, d)));
|
|
2265
|
+
return a.common.async ? Promise.all(o).then((l) => c(l)) : c(o);
|
|
2266
2266
|
}
|
|
2267
2267
|
min(e, t) {
|
|
2268
2268
|
return new B({
|
|
@@ -2298,11 +2298,11 @@ class Y extends _ {
|
|
|
2298
2298
|
const { ctx: t } = this._processInputParams(e);
|
|
2299
2299
|
if (t.parsedType !== p.function)
|
|
2300
2300
|
return m(t, {
|
|
2301
|
-
code:
|
|
2301
|
+
code: u.invalid_type,
|
|
2302
2302
|
expected: p.function,
|
|
2303
2303
|
received: t.parsedType
|
|
2304
2304
|
}), y;
|
|
2305
|
-
function
|
|
2305
|
+
function a(o, l) {
|
|
2306
2306
|
return ve({
|
|
2307
2307
|
data: o,
|
|
2308
2308
|
path: t.path,
|
|
@@ -2311,14 +2311,14 @@ class Y extends _ {
|
|
|
2311
2311
|
t.schemaErrorMap,
|
|
2312
2312
|
ye(),
|
|
2313
2313
|
X
|
|
2314
|
-
].filter((
|
|
2314
|
+
].filter((d) => !!d),
|
|
2315
2315
|
issueData: {
|
|
2316
|
-
code:
|
|
2316
|
+
code: u.invalid_arguments,
|
|
2317
2317
|
argumentsError: l
|
|
2318
2318
|
}
|
|
2319
2319
|
});
|
|
2320
2320
|
}
|
|
2321
|
-
function
|
|
2321
|
+
function i(o, l) {
|
|
2322
2322
|
return ve({
|
|
2323
2323
|
data: o,
|
|
2324
2324
|
path: t.path,
|
|
@@ -2327,33 +2327,33 @@ class Y extends _ {
|
|
|
2327
2327
|
t.schemaErrorMap,
|
|
2328
2328
|
ye(),
|
|
2329
2329
|
X
|
|
2330
|
-
].filter((
|
|
2330
|
+
].filter((d) => !!d),
|
|
2331
2331
|
issueData: {
|
|
2332
|
-
code:
|
|
2332
|
+
code: u.invalid_return_type,
|
|
2333
2333
|
returnTypeError: l
|
|
2334
2334
|
}
|
|
2335
2335
|
});
|
|
2336
2336
|
}
|
|
2337
|
-
const
|
|
2337
|
+
const s = { errorMap: t.common.contextualErrorMap }, c = t.data;
|
|
2338
2338
|
if (this._def.returns instanceof J) {
|
|
2339
2339
|
const o = this;
|
|
2340
2340
|
return I(async function(...l) {
|
|
2341
|
-
const
|
|
2342
|
-
throw
|
|
2341
|
+
const d = new A([]), f = await o._def.args.parseAsync(l, s).catch((w) => {
|
|
2342
|
+
throw d.addIssue(a(l, w)), d;
|
|
2343
2343
|
}), x = await Reflect.apply(c, this, f);
|
|
2344
|
-
return await o._def.returns._def.type.parseAsync(x,
|
|
2345
|
-
throw
|
|
2344
|
+
return await o._def.returns._def.type.parseAsync(x, s).catch((w) => {
|
|
2345
|
+
throw d.addIssue(i(x, w)), d;
|
|
2346
2346
|
});
|
|
2347
2347
|
});
|
|
2348
2348
|
} else {
|
|
2349
2349
|
const o = this;
|
|
2350
2350
|
return I(function(...l) {
|
|
2351
|
-
const
|
|
2352
|
-
if (!
|
|
2353
|
-
throw new
|
|
2354
|
-
const f = Reflect.apply(c, this,
|
|
2351
|
+
const d = o._def.args.safeParse(l, s);
|
|
2352
|
+
if (!d.success)
|
|
2353
|
+
throw new A([a(l, d.error)]);
|
|
2354
|
+
const f = Reflect.apply(c, this, d.data), x = o._def.returns.safeParse(f, s);
|
|
2355
2355
|
if (!x.success)
|
|
2356
|
-
throw new
|
|
2356
|
+
throw new A([i(f, x.error)]);
|
|
2357
2357
|
return x.data;
|
|
2358
2358
|
});
|
|
2359
2359
|
}
|
|
@@ -2382,16 +2382,16 @@ class Y extends _ {
|
|
|
2382
2382
|
strictImplement(e) {
|
|
2383
2383
|
return this.parse(e);
|
|
2384
2384
|
}
|
|
2385
|
-
static create(e, t,
|
|
2385
|
+
static create(e, t, a) {
|
|
2386
2386
|
return new Y({
|
|
2387
2387
|
args: e || D.create([]).rest(F.create()),
|
|
2388
2388
|
returns: t || F.create(),
|
|
2389
2389
|
typeName: g.ZodFunction,
|
|
2390
|
-
...v(
|
|
2390
|
+
...v(a)
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
2394
|
-
class
|
|
2394
|
+
class ue extends _ {
|
|
2395
2395
|
get schema() {
|
|
2396
2396
|
return this._def.getter();
|
|
2397
2397
|
}
|
|
@@ -2400,18 +2400,18 @@ class de extends _ {
|
|
|
2400
2400
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2401
2401
|
}
|
|
2402
2402
|
}
|
|
2403
|
-
|
|
2403
|
+
ue.create = (n, e) => new ue({
|
|
2404
2404
|
getter: n,
|
|
2405
2405
|
typeName: g.ZodLazy,
|
|
2406
2406
|
...v(e)
|
|
2407
2407
|
});
|
|
2408
|
-
class
|
|
2408
|
+
class de 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: u.invalid_literal,
|
|
2415
2415
|
expected: this._def.value
|
|
2416
2416
|
}), y;
|
|
2417
2417
|
}
|
|
@@ -2421,37 +2421,37 @@ class ue extends _ {
|
|
|
2421
2421
|
return this._def.value;
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
|
|
2424
|
+
de.create = (n, e) => new de({
|
|
2425
2425
|
value: n,
|
|
2426
2426
|
typeName: g.ZodLiteral,
|
|
2427
2427
|
...v(e)
|
|
2428
2428
|
});
|
|
2429
|
-
function
|
|
2430
|
-
return new
|
|
2429
|
+
function Ye(n, e) {
|
|
2430
|
+
return new V({
|
|
2431
2431
|
values: n,
|
|
2432
2432
|
typeName: g.ZodEnum,
|
|
2433
2433
|
...v(e)
|
|
2434
2434
|
});
|
|
2435
2435
|
}
|
|
2436
|
-
class
|
|
2436
|
+
class V extends _ {
|
|
2437
2437
|
constructor() {
|
|
2438
2438
|
super(...arguments), ee.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), a = this._def.values;
|
|
2443
2443
|
return m(t, {
|
|
2444
|
-
expected: b.joinValues(
|
|
2444
|
+
expected: b.joinValues(a),
|
|
2445
2445
|
received: t.parsedType,
|
|
2446
|
-
code:
|
|
2446
|
+
code: u.invalid_type
|
|
2447
2447
|
}), y;
|
|
2448
2448
|
}
|
|
2449
|
-
if (_e(this, ee) ||
|
|
2450
|
-
const t = this._getOrReturnCtx(e),
|
|
2449
|
+
if (_e(this, ee) || qe(this, ee, new Set(this._def.values)), !_e(this, ee).has(e.data)) {
|
|
2450
|
+
const t = this._getOrReturnCtx(e), a = this._def.values;
|
|
2451
2451
|
return m(t, {
|
|
2452
2452
|
received: t.data,
|
|
2453
|
-
code:
|
|
2454
|
-
options:
|
|
2453
|
+
code: u.invalid_enum_value,
|
|
2454
|
+
options: a
|
|
2455
2455
|
}), y;
|
|
2456
2456
|
}
|
|
2457
2457
|
return I(e.data);
|
|
@@ -2478,40 +2478,40 @@ class z extends _ {
|
|
|
2478
2478
|
return e;
|
|
2479
2479
|
}
|
|
2480
2480
|
extract(e, t = this._def) {
|
|
2481
|
-
return
|
|
2481
|
+
return V.create(e, {
|
|
2482
2482
|
...this._def,
|
|
2483
2483
|
...t
|
|
2484
2484
|
});
|
|
2485
2485
|
}
|
|
2486
2486
|
exclude(e, t = this._def) {
|
|
2487
|
-
return
|
|
2487
|
+
return V.create(this.options.filter((a) => !e.includes(a)), {
|
|
2488
2488
|
...this._def,
|
|
2489
2489
|
...t
|
|
2490
2490
|
});
|
|
2491
2491
|
}
|
|
2492
2492
|
}
|
|
2493
2493
|
ee = /* @__PURE__ */ new WeakMap();
|
|
2494
|
-
|
|
2494
|
+
V.create = Ye;
|
|
2495
2495
|
class le extends _ {
|
|
2496
2496
|
constructor() {
|
|
2497
2497
|
super(...arguments), te.set(this, void 0);
|
|
2498
2498
|
}
|
|
2499
2499
|
_parse(e) {
|
|
2500
|
-
const t = b.getValidEnumValues(this._def.values),
|
|
2501
|
-
if (
|
|
2502
|
-
const
|
|
2503
|
-
return m(
|
|
2504
|
-
expected: b.joinValues(
|
|
2505
|
-
received:
|
|
2506
|
-
code:
|
|
2500
|
+
const t = b.getValidEnumValues(this._def.values), a = this._getOrReturnCtx(e);
|
|
2501
|
+
if (a.parsedType !== p.string && a.parsedType !== p.number) {
|
|
2502
|
+
const i = b.objectValues(t);
|
|
2503
|
+
return m(a, {
|
|
2504
|
+
expected: b.joinValues(i),
|
|
2505
|
+
received: a.parsedType,
|
|
2506
|
+
code: u.invalid_type
|
|
2507
2507
|
}), y;
|
|
2508
2508
|
}
|
|
2509
|
-
if (_e(this, te) ||
|
|
2510
|
-
const
|
|
2511
|
-
return m(
|
|
2512
|
-
received:
|
|
2513
|
-
code:
|
|
2514
|
-
options:
|
|
2509
|
+
if (_e(this, te) || qe(this, te, new Set(b.getValidEnumValues(this._def.values))), !_e(this, te).has(e.data)) {
|
|
2510
|
+
const i = b.objectValues(t);
|
|
2511
|
+
return m(a, {
|
|
2512
|
+
received: a.data,
|
|
2513
|
+
code: u.invalid_enum_value,
|
|
2514
|
+
options: i
|
|
2515
2515
|
}), y;
|
|
2516
2516
|
}
|
|
2517
2517
|
return I(e.data);
|
|
@@ -2534,12 +2534,12 @@ class J extends _ {
|
|
|
2534
2534
|
const { ctx: t } = this._processInputParams(e);
|
|
2535
2535
|
if (t.parsedType !== p.promise && t.common.async === !1)
|
|
2536
2536
|
return m(t, {
|
|
2537
|
-
code:
|
|
2537
|
+
code: u.invalid_type,
|
|
2538
2538
|
expected: p.promise,
|
|
2539
2539
|
received: t.parsedType
|
|
2540
2540
|
}), y;
|
|
2541
|
-
const
|
|
2542
|
-
return I(
|
|
2541
|
+
const a = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2542
|
+
return I(a.then((i) => this._def.type.parseAsync(i, {
|
|
2543
2543
|
path: t.path,
|
|
2544
2544
|
errorMap: t.common.contextualErrorMap
|
|
2545
2545
|
})));
|
|
@@ -2558,24 +2558,24 @@ class j 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: a } = this._processInputParams(e), i = this._def.effect || null, s = {
|
|
2562
2562
|
addIssue: (c) => {
|
|
2563
|
-
m(
|
|
2563
|
+
m(a, c), c.fatal ? t.abort() : t.dirty();
|
|
2564
2564
|
},
|
|
2565
2565
|
get path() {
|
|
2566
|
-
return
|
|
2566
|
+
return a.path;
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
|
-
if (
|
|
2570
|
-
const c =
|
|
2571
|
-
if (
|
|
2569
|
+
if (s.addIssue = s.addIssue.bind(s), i.type === "preprocess") {
|
|
2570
|
+
const c = i.transform(a.data, s);
|
|
2571
|
+
if (a.common.async)
|
|
2572
2572
|
return Promise.resolve(c).then(async (o) => {
|
|
2573
2573
|
if (t.value === "aborted")
|
|
2574
2574
|
return y;
|
|
2575
2575
|
const l = await this._def.schema._parseAsync({
|
|
2576
2576
|
data: o,
|
|
2577
|
-
path:
|
|
2578
|
-
parent:
|
|
2577
|
+
path: a.path,
|
|
2578
|
+
parent: a
|
|
2579
2579
|
});
|
|
2580
2580
|
return l.status === "aborted" ? y : l.status === "dirty" || t.value === "dirty" ? Q(l.value) : l;
|
|
2581
2581
|
});
|
|
@@ -2584,47 +2584,47 @@ class j extends _ {
|
|
|
2584
2584
|
return y;
|
|
2585
2585
|
const o = this._def.schema._parseSync({
|
|
2586
2586
|
data: c,
|
|
2587
|
-
path:
|
|
2588
|
-
parent:
|
|
2587
|
+
path: a.path,
|
|
2588
|
+
parent: a
|
|
2589
2589
|
});
|
|
2590
2590
|
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? Q(o.value) : o;
|
|
2591
2591
|
}
|
|
2592
2592
|
}
|
|
2593
|
-
if (
|
|
2593
|
+
if (i.type === "refinement") {
|
|
2594
2594
|
const c = (o) => {
|
|
2595
|
-
const l =
|
|
2596
|
-
if (
|
|
2595
|
+
const l = i.refinement(o, s);
|
|
2596
|
+
if (a.common.async)
|
|
2597
2597
|
return Promise.resolve(l);
|
|
2598
2598
|
if (l instanceof Promise)
|
|
2599
2599
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2600
2600
|
return o;
|
|
2601
2601
|
};
|
|
2602
|
-
if (
|
|
2602
|
+
if (a.common.async === !1) {
|
|
2603
2603
|
const o = this._def.schema._parseSync({
|
|
2604
|
-
data:
|
|
2605
|
-
path:
|
|
2606
|
-
parent:
|
|
2604
|
+
data: a.data,
|
|
2605
|
+
path: a.path,
|
|
2606
|
+
parent: a
|
|
2607
2607
|
});
|
|
2608
2608
|
return o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), c(o.value), { status: t.value, value: o.value });
|
|
2609
2609
|
} else
|
|
2610
|
-
return this._def.schema._parseAsync({ data:
|
|
2610
|
+
return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), c(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2611
2611
|
}
|
|
2612
|
-
if (
|
|
2613
|
-
if (
|
|
2612
|
+
if (i.type === "transform")
|
|
2613
|
+
if (a.common.async === !1) {
|
|
2614
2614
|
const c = this._def.schema._parseSync({
|
|
2615
|
-
data:
|
|
2616
|
-
path:
|
|
2617
|
-
parent:
|
|
2615
|
+
data: a.data,
|
|
2616
|
+
path: a.path,
|
|
2617
|
+
parent: a
|
|
2618
2618
|
});
|
|
2619
2619
|
if (!U(c))
|
|
2620
2620
|
return c;
|
|
2621
|
-
const o =
|
|
2621
|
+
const o = i.transform(c.value, s);
|
|
2622
2622
|
if (o instanceof Promise)
|
|
2623
2623
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2624
2624
|
return { status: t.value, value: o };
|
|
2625
2625
|
} else
|
|
2626
|
-
return this._def.schema._parseAsync({ data:
|
|
2627
|
-
b.assertNever(
|
|
2626
|
+
return this._def.schema._parseAsync({ data: a.data, path: a.path, parent: a }).then((c) => U(c) ? Promise.resolve(i.transform(c.value, s)).then((o) => ({ status: t.value, value: o })) : c);
|
|
2627
|
+
b.assertNever(i);
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
2630
|
j.create = (n, e, t) => new j({
|
|
@@ -2668,9 +2668,9 @@ L.create = (n, e) => new L({
|
|
|
2668
2668
|
class me 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 a = t.data;
|
|
2672
|
+
return t.parsedType === p.undefined && (a = this._def.defaultValue()), this._def.innerType._parse({
|
|
2673
|
+
data: a,
|
|
2674
2674
|
path: t.path,
|
|
2675
2675
|
parent: t
|
|
2676
2676
|
});
|
|
@@ -2687,34 +2687,34 @@ me.create = (n, e) => new me({
|
|
|
2687
2687
|
});
|
|
2688
2688
|
class pe extends _ {
|
|
2689
2689
|
_parse(e) {
|
|
2690
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2690
|
+
const { ctx: t } = this._processInputParams(e), a = {
|
|
2691
2691
|
...t,
|
|
2692
2692
|
common: {
|
|
2693
2693
|
...t.common,
|
|
2694
2694
|
issues: []
|
|
2695
2695
|
}
|
|
2696
|
-
},
|
|
2697
|
-
data:
|
|
2698
|
-
path:
|
|
2696
|
+
}, i = this._def.innerType._parse({
|
|
2697
|
+
data: a.data,
|
|
2698
|
+
path: a.path,
|
|
2699
2699
|
parent: {
|
|
2700
|
-
...
|
|
2700
|
+
...a
|
|
2701
2701
|
}
|
|
2702
2702
|
});
|
|
2703
|
-
return ne(
|
|
2703
|
+
return ne(i) ? i.then((s) => ({
|
|
2704
2704
|
status: "valid",
|
|
2705
|
-
value:
|
|
2705
|
+
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2706
2706
|
get error() {
|
|
2707
|
-
return new
|
|
2707
|
+
return new A(a.common.issues);
|
|
2708
2708
|
},
|
|
2709
|
-
input:
|
|
2709
|
+
input: a.data
|
|
2710
2710
|
})
|
|
2711
2711
|
})) : {
|
|
2712
2712
|
status: "valid",
|
|
2713
|
-
value:
|
|
2713
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2714
2714
|
get error() {
|
|
2715
|
-
return new
|
|
2715
|
+
return new A(a.common.issues);
|
|
2716
2716
|
},
|
|
2717
|
-
input:
|
|
2717
|
+
input: a.data
|
|
2718
2718
|
})
|
|
2719
2719
|
};
|
|
2720
2720
|
}
|
|
@@ -2731,11 +2731,11 @@ pe.create = (n, e) => new pe({
|
|
|
2731
2731
|
class we extends _ {
|
|
2732
2732
|
_parse(e) {
|
|
2733
2733
|
if (this._getType(e) !== p.nan) {
|
|
2734
|
-
const
|
|
2735
|
-
return m(
|
|
2736
|
-
code:
|
|
2734
|
+
const a = this._getOrReturnCtx(e);
|
|
2735
|
+
return m(a, {
|
|
2736
|
+
code: u.invalid_type,
|
|
2737
2737
|
expected: p.nan,
|
|
2738
|
-
received:
|
|
2738
|
+
received: a.parsedType
|
|
2739
2739
|
}), y;
|
|
2740
2740
|
}
|
|
2741
2741
|
return { status: "valid", value: e.data };
|
|
@@ -2745,12 +2745,12 @@ we.create = (n) => new we({
|
|
|
2745
2745
|
typeName: g.ZodNaN,
|
|
2746
2746
|
...v(n)
|
|
2747
2747
|
});
|
|
2748
|
-
const
|
|
2748
|
+
const Dt = Symbol("zod_brand");
|
|
2749
2749
|
class Pe extends _ {
|
|
2750
2750
|
_parse(e) {
|
|
2751
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2751
|
+
const { ctx: t } = this._processInputParams(e), a = t.data;
|
|
2752
2752
|
return this._def.type._parse({
|
|
2753
|
-
data:
|
|
2753
|
+
data: a,
|
|
2754
2754
|
path: t.path,
|
|
2755
2755
|
parent: t
|
|
2756
2756
|
});
|
|
@@ -2761,33 +2761,33 @@ class Pe extends _ {
|
|
|
2761
2761
|
}
|
|
2762
2762
|
class he extends _ {
|
|
2763
2763
|
_parse(e) {
|
|
2764
|
-
const { status: t, ctx:
|
|
2765
|
-
if (
|
|
2764
|
+
const { status: t, ctx: a } = this._processInputParams(e);
|
|
2765
|
+
if (a.common.async)
|
|
2766
2766
|
return (async () => {
|
|
2767
|
-
const
|
|
2768
|
-
data:
|
|
2769
|
-
path:
|
|
2770
|
-
parent:
|
|
2767
|
+
const s = await this._def.in._parseAsync({
|
|
2768
|
+
data: a.data,
|
|
2769
|
+
path: a.path,
|
|
2770
|
+
parent: a
|
|
2771
2771
|
});
|
|
2772
|
-
return
|
|
2773
|
-
data:
|
|
2774
|
-
path:
|
|
2775
|
-
parent:
|
|
2772
|
+
return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), Q(s.value)) : this._def.out._parseAsync({
|
|
2773
|
+
data: s.value,
|
|
2774
|
+
path: a.path,
|
|
2775
|
+
parent: a
|
|
2776
2776
|
});
|
|
2777
2777
|
})();
|
|
2778
2778
|
{
|
|
2779
|
-
const
|
|
2780
|
-
data:
|
|
2781
|
-
path:
|
|
2782
|
-
parent:
|
|
2779
|
+
const i = this._def.in._parseSync({
|
|
2780
|
+
data: a.data,
|
|
2781
|
+
path: a.path,
|
|
2782
|
+
parent: a
|
|
2783
2783
|
});
|
|
2784
|
-
return
|
|
2784
|
+
return i.status === "aborted" ? y : i.status === "dirty" ? (t.dirty(), {
|
|
2785
2785
|
status: "dirty",
|
|
2786
|
-
value:
|
|
2786
|
+
value: i.value
|
|
2787
2787
|
}) : this._def.out._parseSync({
|
|
2788
|
-
data:
|
|
2789
|
-
path:
|
|
2790
|
-
parent:
|
|
2788
|
+
data: i.value,
|
|
2789
|
+
path: a.path,
|
|
2790
|
+
parent: a
|
|
2791
2791
|
});
|
|
2792
2792
|
}
|
|
2793
2793
|
}
|
|
@@ -2801,8 +2801,8 @@ class he extends _ {
|
|
|
2801
2801
|
}
|
|
2802
2802
|
class fe extends _ {
|
|
2803
2803
|
_parse(e) {
|
|
2804
|
-
const t = this._def.innerType._parse(e),
|
|
2805
|
-
return ne(t) ? t.then((
|
|
2804
|
+
const t = this._def.innerType._parse(e), a = (i) => (U(i) && (i.value = Object.freeze(i.value)), i);
|
|
2805
|
+
return ne(t) ? t.then((i) => a(i)) : a(t);
|
|
2806
2806
|
}
|
|
2807
2807
|
unwrap() {
|
|
2808
2808
|
return this._def.innerType;
|
|
@@ -2813,54 +2813,54 @@ fe.create = (n, e) => new fe({
|
|
|
2813
2813
|
typeName: g.ZodReadonly,
|
|
2814
2814
|
...v(e)
|
|
2815
2815
|
});
|
|
2816
|
-
function
|
|
2816
|
+
function ze(n, e) {
|
|
2817
2817
|
const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
|
|
2818
2818
|
return typeof t == "string" ? { message: t } : t;
|
|
2819
2819
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return n ? G.create().superRefine((
|
|
2822
|
-
var
|
|
2823
|
-
const o = n(
|
|
2820
|
+
function Xe(n, e = {}, t) {
|
|
2821
|
+
return n ? G.create().superRefine((a, i) => {
|
|
2822
|
+
var s, c;
|
|
2823
|
+
const o = n(a);
|
|
2824
2824
|
if (o instanceof Promise)
|
|
2825
2825
|
return o.then((l) => {
|
|
2826
|
-
var
|
|
2826
|
+
var d, f;
|
|
2827
2827
|
if (!l) {
|
|
2828
|
-
const x =
|
|
2829
|
-
|
|
2828
|
+
const x = ze(e, a), T = (f = (d = x.fatal) !== null && d !== void 0 ? d : t) !== null && f !== void 0 ? f : !0;
|
|
2829
|
+
i.addIssue({ code: "custom", ...x, fatal: T });
|
|
2830
2830
|
}
|
|
2831
2831
|
});
|
|
2832
2832
|
if (!o) {
|
|
2833
|
-
const l =
|
|
2834
|
-
|
|
2833
|
+
const l = ze(e, a), d = (c = (s = l.fatal) !== null && s !== void 0 ? s : t) !== null && c !== void 0 ? c : !0;
|
|
2834
|
+
i.addIssue({ code: "custom", ...l, fatal: d });
|
|
2835
2835
|
}
|
|
2836
2836
|
}) : G.create();
|
|
2837
2837
|
}
|
|
2838
|
-
const
|
|
2838
|
+
const Pt = {
|
|
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 Et = (n, e = {
|
|
2846
2846
|
message: `Input not instance of ${n.name}`
|
|
2847
|
-
}) =>
|
|
2848
|
-
string: (n) =>
|
|
2847
|
+
}) => Xe((t) => t instanceof n, e), Ge = N.create, Je = M.create, Rt = we.create, $t = z.create, He = re.create, Mt = q.create, zt = be.create, Vt = ae.create, Lt = ie.create, Ft = G.create, Ut = F.create, qt = $.create, Bt = xe.create, Wt = C.create, Qt = k.create, Yt = k.strictCreate, Xt = se.create, Gt = Te.create, Jt = oe.create, Ht = D.create, Kt = ce.create, en = ke.create, tn = B.create, nn = Y.create, rn = ue.create, an = de.create, sn = V.create, on = le.create, cn = J.create, Ve = j.create, un = Z.create, dn = L.create, ln = j.createWithPreprocess, mn = he.create, pn = () => Ge().optional(), fn = () => Je().optional(), hn = () => He().optional(), gn = {
|
|
2848
|
+
string: (n) => N.create({ ...n, coerce: !0 }),
|
|
2849
2849
|
number: (n) => M.create({ ...n, coerce: !0 }),
|
|
2850
2850
|
boolean: (n) => re.create({
|
|
2851
2851
|
...n,
|
|
2852
2852
|
coerce: !0
|
|
2853
2853
|
}),
|
|
2854
|
-
bigint: (n) =>
|
|
2854
|
+
bigint: (n) => z.create({ ...n, coerce: !0 }),
|
|
2855
2855
|
date: (n) => q.create({ ...n, coerce: !0 })
|
|
2856
|
-
},
|
|
2857
|
-
var
|
|
2856
|
+
}, yn = y;
|
|
2857
|
+
var r = /* @__PURE__ */ Object.freeze({
|
|
2858
2858
|
__proto__: null,
|
|
2859
2859
|
defaultErrorMap: X,
|
|
2860
2860
|
setErrorMap: dt,
|
|
2861
2861
|
getErrorMap: ye,
|
|
2862
2862
|
makeIssue: ve,
|
|
2863
|
-
EMPTY_PATH:
|
|
2863
|
+
EMPTY_PATH: lt,
|
|
2864
2864
|
addIssueToContext: m,
|
|
2865
2865
|
ParseStatus: S,
|
|
2866
2866
|
INVALID: y,
|
|
@@ -2879,22 +2879,22 @@ var s = /* @__PURE__ */ Object.freeze({
|
|
|
2879
2879
|
ZodParsedType: p,
|
|
2880
2880
|
getParsedType: E,
|
|
2881
2881
|
ZodType: _,
|
|
2882
|
-
datetimeRegex:
|
|
2883
|
-
ZodString:
|
|
2882
|
+
datetimeRegex: Qe,
|
|
2883
|
+
ZodString: N,
|
|
2884
2884
|
ZodNumber: M,
|
|
2885
|
-
ZodBigInt:
|
|
2885
|
+
ZodBigInt: z,
|
|
2886
2886
|
ZodBoolean: re,
|
|
2887
2887
|
ZodDate: q,
|
|
2888
2888
|
ZodSymbol: be,
|
|
2889
|
-
ZodUndefined:
|
|
2890
|
-
ZodNull:
|
|
2889
|
+
ZodUndefined: ae,
|
|
2890
|
+
ZodNull: ie,
|
|
2891
2891
|
ZodAny: G,
|
|
2892
2892
|
ZodUnknown: F,
|
|
2893
2893
|
ZodNever: $,
|
|
2894
2894
|
ZodVoid: xe,
|
|
2895
2895
|
ZodArray: C,
|
|
2896
2896
|
ZodObject: k,
|
|
2897
|
-
ZodUnion:
|
|
2897
|
+
ZodUnion: se,
|
|
2898
2898
|
ZodDiscriminatedUnion: Te,
|
|
2899
2899
|
ZodIntersection: oe,
|
|
2900
2900
|
ZodTuple: D,
|
|
@@ -2902,9 +2902,9 @@ var s = /* @__PURE__ */ Object.freeze({
|
|
|
2902
2902
|
ZodMap: ke,
|
|
2903
2903
|
ZodSet: B,
|
|
2904
2904
|
ZodFunction: Y,
|
|
2905
|
-
ZodLazy:
|
|
2906
|
-
ZodLiteral:
|
|
2907
|
-
ZodEnum:
|
|
2905
|
+
ZodLazy: ue,
|
|
2906
|
+
ZodLiteral: de,
|
|
2907
|
+
ZodEnum: V,
|
|
2908
2908
|
ZodNativeEnum: le,
|
|
2909
2909
|
ZodPromise: J,
|
|
2910
2910
|
ZodEffects: j,
|
|
@@ -2914,319 +2914,319 @@ var s = /* @__PURE__ */ Object.freeze({
|
|
|
2914
2914
|
ZodDefault: me,
|
|
2915
2915
|
ZodCatch: pe,
|
|
2916
2916
|
ZodNaN: we,
|
|
2917
|
-
BRAND:
|
|
2917
|
+
BRAND: Dt,
|
|
2918
2918
|
ZodBranded: Pe,
|
|
2919
2919
|
ZodPipeline: he,
|
|
2920
2920
|
ZodReadonly: fe,
|
|
2921
|
-
custom:
|
|
2921
|
+
custom: Xe,
|
|
2922
2922
|
Schema: _,
|
|
2923
2923
|
ZodSchema: _,
|
|
2924
|
-
late:
|
|
2924
|
+
late: Pt,
|
|
2925
2925
|
get ZodFirstPartyTypeKind() {
|
|
2926
2926
|
return g;
|
|
2927
2927
|
},
|
|
2928
|
-
coerce:
|
|
2929
|
-
any:
|
|
2930
|
-
array:
|
|
2931
|
-
bigint:
|
|
2932
|
-
boolean:
|
|
2933
|
-
date:
|
|
2934
|
-
discriminatedUnion:
|
|
2935
|
-
effect:
|
|
2928
|
+
coerce: gn,
|
|
2929
|
+
any: Ft,
|
|
2930
|
+
array: Wt,
|
|
2931
|
+
bigint: $t,
|
|
2932
|
+
boolean: He,
|
|
2933
|
+
date: Mt,
|
|
2934
|
+
discriminatedUnion: Gt,
|
|
2935
|
+
effect: Ve,
|
|
2936
2936
|
enum: sn,
|
|
2937
|
-
function:
|
|
2938
|
-
instanceof:
|
|
2939
|
-
intersection:
|
|
2940
|
-
lazy:
|
|
2941
|
-
literal:
|
|
2942
|
-
map:
|
|
2943
|
-
nan:
|
|
2944
|
-
nativeEnum:
|
|
2945
|
-
never:
|
|
2946
|
-
null:
|
|
2937
|
+
function: nn,
|
|
2938
|
+
instanceof: Et,
|
|
2939
|
+
intersection: Jt,
|
|
2940
|
+
lazy: rn,
|
|
2941
|
+
literal: an,
|
|
2942
|
+
map: en,
|
|
2943
|
+
nan: Rt,
|
|
2944
|
+
nativeEnum: on,
|
|
2945
|
+
never: qt,
|
|
2946
|
+
null: Lt,
|
|
2947
2947
|
nullable: dn,
|
|
2948
|
-
number:
|
|
2949
|
-
object:
|
|
2950
|
-
oboolean:
|
|
2951
|
-
onumber:
|
|
2952
|
-
optional:
|
|
2953
|
-
ostring:
|
|
2954
|
-
pipeline:
|
|
2955
|
-
preprocess:
|
|
2956
|
-
promise:
|
|
2957
|
-
record:
|
|
2958
|
-
set:
|
|
2959
|
-
strictObject:
|
|
2960
|
-
string:
|
|
2961
|
-
symbol:
|
|
2962
|
-
transformer:
|
|
2963
|
-
tuple:
|
|
2948
|
+
number: Je,
|
|
2949
|
+
object: Qt,
|
|
2950
|
+
oboolean: hn,
|
|
2951
|
+
onumber: fn,
|
|
2952
|
+
optional: un,
|
|
2953
|
+
ostring: pn,
|
|
2954
|
+
pipeline: mn,
|
|
2955
|
+
preprocess: ln,
|
|
2956
|
+
promise: cn,
|
|
2957
|
+
record: Kt,
|
|
2958
|
+
set: tn,
|
|
2959
|
+
strictObject: Yt,
|
|
2960
|
+
string: Ge,
|
|
2961
|
+
symbol: zt,
|
|
2962
|
+
transformer: Ve,
|
|
2963
|
+
tuple: Ht,
|
|
2964
2964
|
undefined: Vt,
|
|
2965
|
-
union:
|
|
2966
|
-
unknown:
|
|
2967
|
-
void:
|
|
2968
|
-
NEVER:
|
|
2969
|
-
ZodIssueCode:
|
|
2970
|
-
quotelessJson:
|
|
2971
|
-
ZodError:
|
|
2965
|
+
union: Xt,
|
|
2966
|
+
unknown: Ut,
|
|
2967
|
+
void: Bt,
|
|
2968
|
+
NEVER: yn,
|
|
2969
|
+
ZodIssueCode: u,
|
|
2970
|
+
quotelessJson: ut,
|
|
2971
|
+
ZodError: A
|
|
2972
2972
|
});
|
|
2973
|
-
const Se =
|
|
2974
|
-
country:
|
|
2975
|
-
city:
|
|
2976
|
-
street:
|
|
2977
|
-
streetNumber:
|
|
2978
|
-
floor:
|
|
2979
|
-
apartmentEnterNumber:
|
|
2980
|
-
apartmentNumber:
|
|
2981
|
-
}), R =
|
|
2982
|
-
function
|
|
2973
|
+
const Se = r.object({
|
|
2974
|
+
country: r.string().optional(),
|
|
2975
|
+
city: r.string().optional(),
|
|
2976
|
+
street: r.string().optional(),
|
|
2977
|
+
streetNumber: r.string().optional(),
|
|
2978
|
+
floor: r.string().optional(),
|
|
2979
|
+
apartmentEnterNumber: r.string().optional(),
|
|
2980
|
+
apartmentNumber: r.string().optional()
|
|
2981
|
+
}), R = r.string().min(1, { message: "שדה חובה" }), Mn = r.string().regex(/^\d+$/, "Must be a numeric string"), zn = r.object({ url: r.string().url(), id: r.string() });
|
|
2982
|
+
function Vn(n) {
|
|
2983
2983
|
return !!(n != null && n.url);
|
|
2984
2984
|
}
|
|
2985
|
-
const ge =
|
|
2986
|
-
lang:
|
|
2987
|
-
value:
|
|
2988
|
-
}),
|
|
2989
|
-
id:
|
|
2990
|
-
companyId:
|
|
2991
|
-
storeId:
|
|
2992
|
-
parentId:
|
|
2993
|
-
tag:
|
|
2994
|
-
locales:
|
|
2995
|
-
depth:
|
|
2996
|
-
}), Ee =
|
|
2997
|
-
children:
|
|
2998
|
-
}), Ln =
|
|
2999
|
-
index:
|
|
3000
|
-
depth:
|
|
3001
|
-
collapsed:
|
|
3002
|
-
children:
|
|
3003
|
-
}), K =
|
|
3004
|
-
type:
|
|
2985
|
+
const ge = r.object({
|
|
2986
|
+
lang: r.enum(["he"]),
|
|
2987
|
+
value: r.string()
|
|
2988
|
+
}), Ke = r.object({
|
|
2989
|
+
id: r.string().min(1),
|
|
2990
|
+
companyId: r.string().min(1),
|
|
2991
|
+
storeId: r.string().min(1),
|
|
2992
|
+
parentId: r.string().nullish(),
|
|
2993
|
+
tag: r.string().optional(),
|
|
2994
|
+
locales: r.array(ge),
|
|
2995
|
+
depth: r.number()
|
|
2996
|
+
}), Ee = Ke.extend({
|
|
2997
|
+
children: r.lazy(() => Ee.array())
|
|
2998
|
+
}), Ln = Ke.extend({
|
|
2999
|
+
index: r.number(),
|
|
3000
|
+
depth: r.number(),
|
|
3001
|
+
collapsed: r.boolean().optional(),
|
|
3002
|
+
children: r.array(Ee)
|
|
3003
|
+
}), K = r.string().min(1), Re = r.object({
|
|
3004
|
+
type: r.literal("Product"),
|
|
3005
3005
|
storeId: K,
|
|
3006
3006
|
companyId: K,
|
|
3007
3007
|
id: K,
|
|
3008
3008
|
objectID: K,
|
|
3009
3009
|
sku: K,
|
|
3010
|
-
name:
|
|
3011
|
-
description:
|
|
3012
|
-
isPublished:
|
|
3013
|
-
vat:
|
|
3014
|
-
priceType:
|
|
3015
|
-
type:
|
|
3016
|
-
value:
|
|
3010
|
+
name: r.array(ge),
|
|
3011
|
+
description: r.array(ge),
|
|
3012
|
+
isPublished: r.boolean(),
|
|
3013
|
+
vat: r.boolean(),
|
|
3014
|
+
priceType: r.object({
|
|
3015
|
+
type: r.enum(["unit", "kg", "gram", "liter", "ml"]),
|
|
3016
|
+
value: r.number()
|
|
3017
3017
|
}),
|
|
3018
|
-
price:
|
|
3019
|
-
purchasePrice:
|
|
3020
|
-
profitPercentage:
|
|
3021
|
-
currency:
|
|
3022
|
-
discount:
|
|
3023
|
-
type:
|
|
3024
|
-
value:
|
|
3018
|
+
price: r.number().positive(),
|
|
3019
|
+
purchasePrice: r.number().optional(),
|
|
3020
|
+
profitPercentage: r.number().optional(),
|
|
3021
|
+
currency: r.literal("ILS"),
|
|
3022
|
+
discount: r.object({
|
|
3023
|
+
type: r.enum(["number", "percent", "none"]),
|
|
3024
|
+
value: r.number()
|
|
3025
3025
|
}),
|
|
3026
|
-
isDiscountable:
|
|
3027
|
-
weight:
|
|
3028
|
-
value:
|
|
3029
|
-
unit:
|
|
3026
|
+
isDiscountable: r.boolean({ description: "included in store discounts" }).optional(),
|
|
3027
|
+
weight: r.object({
|
|
3028
|
+
value: r.number(),
|
|
3029
|
+
unit: r.enum(["kg", "gram", "none"])
|
|
3030
3030
|
}),
|
|
3031
|
-
volume:
|
|
3032
|
-
value:
|
|
3033
|
-
unit:
|
|
3031
|
+
volume: r.object({
|
|
3032
|
+
value: r.number(),
|
|
3033
|
+
unit: r.enum(["liter", "ml", "none"])
|
|
3034
3034
|
}),
|
|
3035
|
-
images:
|
|
3036
|
-
manufacturer:
|
|
3037
|
-
brand:
|
|
3038
|
-
importer:
|
|
3039
|
-
supplier:
|
|
3040
|
-
ingredients:
|
|
3041
|
-
created_at:
|
|
3042
|
-
updated_at:
|
|
3043
|
-
categoryIds:
|
|
3044
|
-
stock:
|
|
3045
|
-
quantity:
|
|
3046
|
-
unit:
|
|
3035
|
+
images: r.array(r.object({ url: r.string().url(), id: r.string() })),
|
|
3036
|
+
manufacturer: r.string(),
|
|
3037
|
+
brand: r.string(),
|
|
3038
|
+
importer: r.string(),
|
|
3039
|
+
supplier: r.string(),
|
|
3040
|
+
ingredients: r.array(ge),
|
|
3041
|
+
created_at: r.number(),
|
|
3042
|
+
updated_at: r.number(),
|
|
3043
|
+
categoryIds: r.array(r.string().nonempty()),
|
|
3044
|
+
stock: r.object({
|
|
3045
|
+
quantity: r.number().min(0),
|
|
3046
|
+
unit: r.enum(["piece", "kg", "gram", "liter", "ml"])
|
|
3047
3047
|
}).optional(),
|
|
3048
3048
|
// @deprecated
|
|
3049
|
-
categoryList:
|
|
3049
|
+
categoryList: r.array(Ee).optional(),
|
|
3050
3050
|
// @deprecated
|
|
3051
|
-
categories:
|
|
3052
|
-
lvl0:
|
|
3053
|
-
lvl1:
|
|
3054
|
-
lvl2:
|
|
3055
|
-
lvl3:
|
|
3056
|
-
lvl4:
|
|
3051
|
+
categories: r.object({
|
|
3052
|
+
lvl0: r.array(r.string()),
|
|
3053
|
+
lvl1: r.array(r.string()),
|
|
3054
|
+
lvl2: r.array(r.string()),
|
|
3055
|
+
lvl3: r.array(r.string()),
|
|
3056
|
+
lvl4: r.array(r.string())
|
|
3057
3057
|
}).optional(),
|
|
3058
3058
|
// @deprecated
|
|
3059
|
-
categoryNames:
|
|
3059
|
+
categoryNames: r.array(r.string()).optional()
|
|
3060
3060
|
}), Fn = Re.extend({
|
|
3061
|
-
image:
|
|
3062
|
-
}),
|
|
3061
|
+
image: r.instanceof(File).optional()
|
|
3062
|
+
}), vn = r.enum(["delivered", "missing", "substituted"]), _n = r.object({
|
|
3063
3063
|
product: Re,
|
|
3064
|
-
amount:
|
|
3065
|
-
price:
|
|
3066
|
-
}),
|
|
3064
|
+
amount: r.number().positive(),
|
|
3065
|
+
price: r.number()
|
|
3066
|
+
}), et = r.object({
|
|
3067
3067
|
product: Re,
|
|
3068
|
-
originalPrice:
|
|
3069
|
-
finalPrice:
|
|
3070
|
-
finalDiscount:
|
|
3071
|
-
amount:
|
|
3068
|
+
originalPrice: r.number().optional(),
|
|
3069
|
+
finalPrice: r.number().optional(),
|
|
3070
|
+
finalDiscount: r.number().optional(),
|
|
3071
|
+
amount: r.number().positive({ message: "Quantity must be a positive number." }),
|
|
3072
3072
|
// Picking / fulfillment — optional so existing items stay valid (treated as "delivered").
|
|
3073
|
-
status:
|
|
3074
|
-
substitutedWith:
|
|
3075
|
-
}), Un =
|
|
3076
|
-
type:
|
|
3077
|
-
id:
|
|
3078
|
-
companyId:
|
|
3079
|
-
storeId:
|
|
3080
|
-
userId:
|
|
3081
|
-
status:
|
|
3082
|
-
items:
|
|
3083
|
-
}), qn =
|
|
3084
|
-
id:
|
|
3085
|
-
name:
|
|
3086
|
-
websiteDomains:
|
|
3087
|
-
}), Bn =
|
|
3088
|
-
type:
|
|
3089
|
-
id:
|
|
3090
|
-
companyId:
|
|
3091
|
-
storeId:
|
|
3092
|
-
userId:
|
|
3093
|
-
productId:
|
|
3094
|
-
}), Ie =
|
|
3095
|
-
type:
|
|
3073
|
+
status: vn.optional(),
|
|
3074
|
+
substitutedWith: _n.nullable().optional()
|
|
3075
|
+
}), Un = r.object({
|
|
3076
|
+
type: r.literal("Cart"),
|
|
3077
|
+
id: r.string().uuid(),
|
|
3078
|
+
companyId: r.string().uuid(),
|
|
3079
|
+
storeId: r.string().uuid(),
|
|
3080
|
+
userId: r.string().uuid(),
|
|
3081
|
+
status: r.enum(["active", "draft", "completed"]),
|
|
3082
|
+
items: r.array(et)
|
|
3083
|
+
}), qn = r.object({
|
|
3084
|
+
id: r.string(),
|
|
3085
|
+
name: r.string(),
|
|
3086
|
+
websiteDomains: r.array(r.string())
|
|
3087
|
+
}), Bn = r.object({
|
|
3088
|
+
type: r.literal("FavoriteProduct"),
|
|
3089
|
+
id: r.string().uuid(),
|
|
3090
|
+
companyId: r.string().uuid(),
|
|
3091
|
+
storeId: r.string().uuid(),
|
|
3092
|
+
userId: r.string().uuid(),
|
|
3093
|
+
productId: r.string().uuid()
|
|
3094
|
+
}), Ie = r.enum(["external", "j5", "none"]), bn = r.object({
|
|
3095
|
+
type: r.literal("Profile"),
|
|
3096
3096
|
id: R,
|
|
3097
3097
|
companyId: R,
|
|
3098
3098
|
storeId: R,
|
|
3099
3099
|
tenantId: R,
|
|
3100
3100
|
// @deprecated
|
|
3101
|
-
clientType:
|
|
3102
|
-
companyName:
|
|
3101
|
+
clientType: r.enum(["user", "company"]),
|
|
3102
|
+
companyName: r.string().optional(),
|
|
3103
3103
|
displayName: R,
|
|
3104
|
-
email:
|
|
3105
|
-
phoneNumber:
|
|
3104
|
+
email: r.string().email(),
|
|
3105
|
+
phoneNumber: r.string().optional(),
|
|
3106
3106
|
address: Se.optional(),
|
|
3107
|
-
isAnonymous:
|
|
3108
|
-
createdDate:
|
|
3109
|
-
lastActivityDate:
|
|
3107
|
+
isAnonymous: r.boolean(),
|
|
3108
|
+
createdDate: r.number(),
|
|
3109
|
+
lastActivityDate: r.number(),
|
|
3110
3110
|
//todo
|
|
3111
3111
|
paymentType: Ie.optional(),
|
|
3112
3112
|
/** @deprecated Use organizationIds instead */
|
|
3113
|
-
organizationId:
|
|
3113
|
+
organizationId: r.string().optional().nullable(),
|
|
3114
3114
|
/** Array of organization IDs this user belongs to */
|
|
3115
|
-
organizationIds:
|
|
3116
|
-
}),
|
|
3117
|
-
_COMMENT:
|
|
3118
|
-
transaction_id:
|
|
3119
|
-
date:
|
|
3120
|
-
currency:
|
|
3121
|
-
rate:
|
|
3122
|
-
vat:
|
|
3123
|
-
vat_price:
|
|
3124
|
-
price_discount:
|
|
3125
|
-
price_discount_in_currency:
|
|
3126
|
-
price_total:
|
|
3127
|
-
price_total_in_currency:
|
|
3128
|
-
}),
|
|
3129
|
-
doc_uuid:
|
|
3130
|
-
pdf_link:
|
|
3131
|
-
pdf_link_copy:
|
|
3132
|
-
doc_number:
|
|
3133
|
-
sent_mails:
|
|
3134
|
-
success:
|
|
3135
|
-
ua_uuid:
|
|
3136
|
-
calculatedData:
|
|
3137
|
-
warning:
|
|
3138
|
-
date:
|
|
3139
|
-
}),
|
|
3140
|
-
id:
|
|
3141
|
-
number:
|
|
3142
|
-
date:
|
|
3143
|
-
createdAt:
|
|
3144
|
-
status:
|
|
3145
|
-
companyDetails:
|
|
3146
|
-
name:
|
|
3147
|
-
address:
|
|
3148
|
-
phone:
|
|
3149
|
-
email:
|
|
3115
|
+
organizationIds: r.array(r.string()).optional()
|
|
3116
|
+
}), tt = r.object({
|
|
3117
|
+
_COMMENT: r.string().optional(),
|
|
3118
|
+
transaction_id: r.string(),
|
|
3119
|
+
date: r.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format"),
|
|
3120
|
+
currency: r.string().length(3, "Currency must be 3 characters"),
|
|
3121
|
+
rate: r.number().positive(),
|
|
3122
|
+
vat: r.string().regex(/^\d+\.\d{2}$/, "VAT must be in format XX.XX"),
|
|
3123
|
+
vat_price: r.number().positive(),
|
|
3124
|
+
price_discount: r.number(),
|
|
3125
|
+
price_discount_in_currency: r.number(),
|
|
3126
|
+
price_total: r.string().regex(/^\d+\.\d{2}$/, "Price total must be in format XX.XX"),
|
|
3127
|
+
price_total_in_currency: r.number().positive()
|
|
3128
|
+
}), xn = r.object({
|
|
3129
|
+
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3130
|
+
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3131
|
+
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
3132
|
+
doc_number: r.string().min(1, "Document number is required"),
|
|
3133
|
+
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3134
|
+
success: r.boolean(),
|
|
3135
|
+
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3136
|
+
calculatedData: tt,
|
|
3137
|
+
warning: r.string().optional(),
|
|
3138
|
+
date: r.number().optional()
|
|
3139
|
+
}), kn = r.object({
|
|
3140
|
+
id: r.string().min(1, "ID is required"),
|
|
3141
|
+
number: r.string().min(1, "Number is required"),
|
|
3142
|
+
date: r.number().min(1, "Date is required"),
|
|
3143
|
+
createdAt: r.number().min(1, "Created at is required"),
|
|
3144
|
+
status: r.enum(["pending", "paid", "cancelled"]),
|
|
3145
|
+
companyDetails: r.object({
|
|
3146
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3147
|
+
address: r.string().min(1, "Address is required").optional(),
|
|
3148
|
+
phone: r.string().min(1, "Phone is required").optional(),
|
|
3149
|
+
email: r.string().email("Email must be valid").optional()
|
|
3150
3150
|
}).optional(),
|
|
3151
|
-
clientDetails:
|
|
3152
|
-
name:
|
|
3153
|
-
address:
|
|
3154
|
-
phone:
|
|
3155
|
-
email:
|
|
3151
|
+
clientDetails: r.object({
|
|
3152
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3153
|
+
address: r.string().min(1, "Address is required").optional(),
|
|
3154
|
+
phone: r.string().min(1, "Phone is required").optional(),
|
|
3155
|
+
email: r.string().email("Email must be valid").optional()
|
|
3156
3156
|
}).optional(),
|
|
3157
|
-
items:
|
|
3158
|
-
|
|
3159
|
-
name:
|
|
3160
|
-
price:
|
|
3161
|
-
quantity:
|
|
3162
|
-
total:
|
|
3157
|
+
items: r.array(
|
|
3158
|
+
r.object({
|
|
3159
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3160
|
+
price: r.number().min(1, "Price is required").optional(),
|
|
3161
|
+
quantity: r.number().min(1, "Quantity is required").optional(),
|
|
3162
|
+
total: r.number().min(1, "Total is required").optional()
|
|
3163
3163
|
})
|
|
3164
3164
|
).optional(),
|
|
3165
|
-
total:
|
|
3166
|
-
vat:
|
|
3167
|
-
link:
|
|
3168
|
-
}),
|
|
3169
|
-
number:
|
|
3170
|
-
name:
|
|
3171
|
-
id:
|
|
3172
|
-
}),
|
|
3173
|
-
id:
|
|
3174
|
-
name:
|
|
3175
|
-
discountPercentage:
|
|
3176
|
-
nameOnInvoice:
|
|
3177
|
-
billingAccounts:
|
|
3165
|
+
total: r.number().min(1, "Total is required").optional(),
|
|
3166
|
+
vat: r.number().min(1, "VAT is required").optional(),
|
|
3167
|
+
link: r.string().url("Link must be a valid URL").optional()
|
|
3168
|
+
}), nt = r.object({
|
|
3169
|
+
number: r.string(),
|
|
3170
|
+
name: r.string(),
|
|
3171
|
+
id: r.string()
|
|
3172
|
+
}), wn = r.object({
|
|
3173
|
+
id: r.string(),
|
|
3174
|
+
name: r.string(),
|
|
3175
|
+
discountPercentage: r.number().positive().min(0).max(100).optional(),
|
|
3176
|
+
nameOnInvoice: r.string().optional(),
|
|
3177
|
+
billingAccounts: r.array(nt),
|
|
3178
3178
|
paymentType: Ie,
|
|
3179
|
-
companyNumber:
|
|
3179
|
+
companyNumber: r.string().optional(),
|
|
3180
3180
|
address: Se.optional(),
|
|
3181
|
-
groupId:
|
|
3182
|
-
}), Wn =
|
|
3183
|
-
doc_uuid:
|
|
3184
|
-
pdf_link:
|
|
3185
|
-
pdf_link_copy:
|
|
3186
|
-
doc_number:
|
|
3187
|
-
sent_mails:
|
|
3188
|
-
success:
|
|
3189
|
-
ua_uuid:
|
|
3190
|
-
calculatedData:
|
|
3191
|
-
warning:
|
|
3192
|
-
date:
|
|
3193
|
-
}), Tn =
|
|
3194
|
-
id:
|
|
3195
|
-
number:
|
|
3196
|
-
date:
|
|
3197
|
-
createdAt:
|
|
3198
|
-
status:
|
|
3199
|
-
companyDetails:
|
|
3200
|
-
name:
|
|
3201
|
-
address:
|
|
3202
|
-
phone:
|
|
3203
|
-
email:
|
|
3181
|
+
groupId: r.string().optional()
|
|
3182
|
+
}), Wn = wn.omit({ id: !0 }), Le = r.object({
|
|
3183
|
+
doc_uuid: r.string().uuid("Document UUID must be a valid UUID"),
|
|
3184
|
+
pdf_link: r.string().url("PDF link must be a valid URL"),
|
|
3185
|
+
pdf_link_copy: r.string().url("PDF copy link must be a valid URL"),
|
|
3186
|
+
doc_number: r.string().min(1, "Document number is required"),
|
|
3187
|
+
sent_mails: r.array(r.string().email("Each email must be valid")),
|
|
3188
|
+
success: r.boolean(),
|
|
3189
|
+
ua_uuid: r.string().uuid("UA UUID must be a valid UUID"),
|
|
3190
|
+
calculatedData: tt,
|
|
3191
|
+
warning: r.string().optional(),
|
|
3192
|
+
date: r.number().optional()
|
|
3193
|
+
}), Tn = r.object({
|
|
3194
|
+
id: r.string().min(1, "ID is required"),
|
|
3195
|
+
number: r.string().min(1, "Number is required"),
|
|
3196
|
+
date: r.string().min(1, "Date is required"),
|
|
3197
|
+
createdAt: r.number().min(1, "Created at is required"),
|
|
3198
|
+
status: r.enum(["pending", "paid", "cancelled"]),
|
|
3199
|
+
companyDetails: r.object({
|
|
3200
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3201
|
+
address: r.string().min(1, "Address is required").optional(),
|
|
3202
|
+
phone: r.string().min(1, "Phone is required").optional(),
|
|
3203
|
+
email: r.string().email("Email must be valid").optional()
|
|
3204
3204
|
}).optional(),
|
|
3205
|
-
clientDetails:
|
|
3206
|
-
name:
|
|
3207
|
-
address:
|
|
3208
|
-
phone:
|
|
3209
|
-
email:
|
|
3205
|
+
clientDetails: r.object({
|
|
3206
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3207
|
+
address: r.string().min(1, "Address is required").optional(),
|
|
3208
|
+
phone: r.string().min(1, "Phone is required").optional(),
|
|
3209
|
+
email: r.string().email("Email must be valid").optional()
|
|
3210
3210
|
}).optional(),
|
|
3211
|
-
items:
|
|
3212
|
-
|
|
3213
|
-
name:
|
|
3214
|
-
price:
|
|
3215
|
-
quantity:
|
|
3216
|
-
total:
|
|
3211
|
+
items: r.array(
|
|
3212
|
+
r.object({
|
|
3213
|
+
name: r.string().min(1, "Name is required").optional(),
|
|
3214
|
+
price: r.number().min(1, "Price is required").optional(),
|
|
3215
|
+
quantity: r.number().min(1, "Quantity is required").optional(),
|
|
3216
|
+
total: r.number().min(1, "Total is required").optional()
|
|
3217
3217
|
})
|
|
3218
3218
|
).optional(),
|
|
3219
|
-
total:
|
|
3220
|
-
vat:
|
|
3221
|
-
link:
|
|
3222
|
-
}), Qn =
|
|
3223
|
-
type:
|
|
3224
|
-
createdBy:
|
|
3219
|
+
total: r.number().min(1, "Total is required").optional(),
|
|
3220
|
+
vat: r.number().min(1, "VAT is required").optional(),
|
|
3221
|
+
link: r.string().url("Link must be a valid URL").optional()
|
|
3222
|
+
}), Qn = r.object({
|
|
3223
|
+
type: r.literal("Order"),
|
|
3224
|
+
createdBy: r.enum(["user", "admin"]).optional(),
|
|
3225
3225
|
id: R,
|
|
3226
3226
|
companyId: R,
|
|
3227
3227
|
storeId: R,
|
|
3228
3228
|
userId: R,
|
|
3229
|
-
status:
|
|
3229
|
+
status: r.enum([
|
|
3230
3230
|
"draft",
|
|
3231
3231
|
// before payment
|
|
3232
3232
|
"pending",
|
|
@@ -3241,119 +3241,131 @@ const ge = s.object({
|
|
|
3241
3241
|
"refunded"
|
|
3242
3242
|
]),
|
|
3243
3243
|
paymentType: Ie.optional(),
|
|
3244
|
-
paymentStatus:
|
|
3244
|
+
paymentStatus: r.enum(["pending", "pending_j5", "external", "completed", "failed", "refunded"]),
|
|
3245
3245
|
//todo check if hyp support partial refund
|
|
3246
|
-
cart:
|
|
3247
|
-
id:
|
|
3248
|
-
items:
|
|
3249
|
-
cartDiscount:
|
|
3250
|
-
cartTotal:
|
|
3251
|
-
cartVat:
|
|
3252
|
-
deliveryPrice:
|
|
3246
|
+
cart: r.object({
|
|
3247
|
+
id: r.string(),
|
|
3248
|
+
items: r.array(et),
|
|
3249
|
+
cartDiscount: r.number(),
|
|
3250
|
+
cartTotal: r.number(),
|
|
3251
|
+
cartVat: r.number(),
|
|
3252
|
+
deliveryPrice: r.number().optional()
|
|
3253
3253
|
// final delivery price for cart
|
|
3254
3254
|
}),
|
|
3255
|
-
storeOptions:
|
|
3256
|
-
deliveryPrice:
|
|
3257
|
-
freeDeliveryPrice:
|
|
3258
|
-
isVatIncludedInPrice:
|
|
3255
|
+
storeOptions: r.object({
|
|
3256
|
+
deliveryPrice: r.number().optional(),
|
|
3257
|
+
freeDeliveryPrice: r.number().optional(),
|
|
3258
|
+
isVatIncludedInPrice: r.boolean().optional()
|
|
3259
3259
|
}).optional(),
|
|
3260
|
-
originalAmount:
|
|
3260
|
+
originalAmount: r.number().positive().optional(),
|
|
3261
3261
|
// what client pay
|
|
3262
|
-
actualAmount:
|
|
3262
|
+
actualAmount: r.number().positive().optional(),
|
|
3263
3263
|
// what store charge
|
|
3264
|
-
date:
|
|
3265
|
-
deliveryDate:
|
|
3266
|
-
client:
|
|
3264
|
+
date: r.number(),
|
|
3265
|
+
deliveryDate: r.coerce.number(),
|
|
3266
|
+
client: bn.optional(),
|
|
3267
3267
|
address: Se.optional(),
|
|
3268
|
-
nameOnInvoice:
|
|
3269
|
-
emailOnInvoice:
|
|
3270
|
-
phoneNumberOnInvoice:
|
|
3271
|
-
clientComment:
|
|
3268
|
+
nameOnInvoice: r.string().optional(),
|
|
3269
|
+
emailOnInvoice: r.string().email().optional(),
|
|
3270
|
+
phoneNumberOnInvoice: r.string().optional(),
|
|
3271
|
+
clientComment: r.string().optional(),
|
|
3272
3272
|
// --- B2B buyer details (optional, additive — back-compat) ---
|
|
3273
|
-
companyName:
|
|
3274
|
-
companyNumber:
|
|
3273
|
+
companyName: r.string().optional(),
|
|
3274
|
+
companyNumber: r.string().optional(),
|
|
3275
3275
|
// ח.פ / עוסק מורשה (aligns with Organization.companyNumber)
|
|
3276
|
-
contact:
|
|
3277
|
-
fullName:
|
|
3278
|
-
role:
|
|
3276
|
+
contact: r.object({
|
|
3277
|
+
fullName: r.string().optional(),
|
|
3278
|
+
role: r.string().optional(),
|
|
3279
3279
|
// תפקיד
|
|
3280
|
-
phone:
|
|
3281
|
-
email:
|
|
3280
|
+
phone: r.string().optional(),
|
|
3281
|
+
email: r.string().optional()
|
|
3282
3282
|
}).optional(),
|
|
3283
|
-
poNumber:
|
|
3283
|
+
poNumber: r.string().optional(),
|
|
3284
3284
|
// הזמנת רכש
|
|
3285
|
-
outOfStockPolicy:
|
|
3286
|
-
organizationId:
|
|
3287
|
-
billingAccount:
|
|
3288
|
-
deliveryNote:
|
|
3285
|
+
outOfStockPolicy: r.enum(["substitute", "remove"]).optional(),
|
|
3286
|
+
organizationId: r.string().optional(),
|
|
3287
|
+
billingAccount: nt.optional(),
|
|
3288
|
+
deliveryNote: kn.optional(),
|
|
3289
3289
|
invoice: Tn.optional(),
|
|
3290
|
-
ezInvoice:
|
|
3291
|
-
ezDeliveryNote:
|
|
3290
|
+
ezInvoice: Le.optional(),
|
|
3291
|
+
ezDeliveryNote: xn.optional(),
|
|
3292
|
+
/**
|
|
3293
|
+
* Set when an admin records a full payment against o.invoice / o.ezInvoice.
|
|
3294
|
+
* Epoch millis. Absent means no payment has been recorded via the admin payment flow.
|
|
3295
|
+
* A row is "open" iff: invoice exists AND invoicePaidAt is unset AND ezReceipt is unset.
|
|
3296
|
+
*/
|
|
3297
|
+
invoicePaidAt: r.number().int().positive().optional(),
|
|
3298
|
+
/**
|
|
3299
|
+
* EZcount receipt stored after recording payment.
|
|
3300
|
+
* Mirrors EzInvoiceSchema shape (doc_uuid, pdf_link, doc_number, …).
|
|
3301
|
+
* Present only after a successful recordInvoicePayment call.
|
|
3302
|
+
*/
|
|
3303
|
+
ezReceipt: Le.optional(),
|
|
3292
3304
|
// Audit: who last changed the order + when (epoch millis). Stamped by admin writes.
|
|
3293
|
-
updatedBy:
|
|
3294
|
-
updatedAt:
|
|
3295
|
-
}), Sn =
|
|
3296
|
-
id:
|
|
3297
|
-
companyId:
|
|
3298
|
-
name:
|
|
3299
|
-
urls:
|
|
3300
|
-
logoUrl:
|
|
3301
|
-
tenantId:
|
|
3305
|
+
updatedBy: r.string().optional(),
|
|
3306
|
+
updatedAt: r.number().optional()
|
|
3307
|
+
}), Sn = r.enum(["individual", "company"]), Yn = r.object({
|
|
3308
|
+
id: r.string(),
|
|
3309
|
+
companyId: r.string(),
|
|
3310
|
+
name: r.string(),
|
|
3311
|
+
urls: r.array(r.string()),
|
|
3312
|
+
logoUrl: r.string(),
|
|
3313
|
+
tenantId: r.string(),
|
|
3302
3314
|
// firebase auth tenantId
|
|
3303
3315
|
paymentType: Ie,
|
|
3304
|
-
allowAnonymousClients:
|
|
3305
|
-
isVatIncludedInPrice:
|
|
3306
|
-
clientTypes:
|
|
3307
|
-
minimumOrder:
|
|
3308
|
-
freeDeliveryPrice:
|
|
3309
|
-
deliveryPrice:
|
|
3316
|
+
allowAnonymousClients: r.boolean(),
|
|
3317
|
+
isVatIncludedInPrice: r.boolean(),
|
|
3318
|
+
clientTypes: r.array(Sn),
|
|
3319
|
+
minimumOrder: r.number().optional(),
|
|
3320
|
+
freeDeliveryPrice: r.number().optional(),
|
|
3321
|
+
deliveryPrice: r.number().optional(),
|
|
3310
3322
|
address: Se.optional(),
|
|
3311
|
-
companyNumber:
|
|
3323
|
+
companyNumber: r.string().optional()
|
|
3312
3324
|
// חפ של החברה
|
|
3313
|
-
}), In =
|
|
3314
|
-
minSpend:
|
|
3315
|
-
stackable:
|
|
3316
|
-
}).optional(),
|
|
3317
|
-
|
|
3318
|
-
variantType:
|
|
3319
|
-
productsId:
|
|
3325
|
+
}), In = r.object({
|
|
3326
|
+
minSpend: r.number().positive().optional(),
|
|
3327
|
+
stackable: r.boolean().default(!1)
|
|
3328
|
+
}).optional(), An = r.discriminatedUnion("variantType", [
|
|
3329
|
+
r.object({
|
|
3330
|
+
variantType: r.literal("bundle"),
|
|
3331
|
+
productsId: r.array(r.string().nonempty()).min(1),
|
|
3320
3332
|
// Which products are included
|
|
3321
|
-
requiredQuantity:
|
|
3333
|
+
requiredQuantity: r.number().positive(),
|
|
3322
3334
|
// How many items needed (e.g., 3)
|
|
3323
|
-
bundlePrice:
|
|
3335
|
+
bundlePrice: r.number().positive()
|
|
3324
3336
|
// Total price for the bundle (e.g., $25)
|
|
3325
3337
|
})
|
|
3326
|
-
]), Xn =
|
|
3327
|
-
type:
|
|
3328
|
-
storeId:
|
|
3329
|
-
companyId:
|
|
3330
|
-
id:
|
|
3331
|
-
name:
|
|
3332
|
-
active:
|
|
3333
|
-
startDate:
|
|
3334
|
-
endDate:
|
|
3335
|
-
variant:
|
|
3338
|
+
]), Xn = r.object({
|
|
3339
|
+
type: r.literal("Discount"),
|
|
3340
|
+
storeId: r.string().min(1),
|
|
3341
|
+
companyId: r.string().min(1),
|
|
3342
|
+
id: r.string().min(1),
|
|
3343
|
+
name: r.array(r.object({ lang: r.enum(["he"]), value: r.string().nonempty() })),
|
|
3344
|
+
active: r.boolean(),
|
|
3345
|
+
startDate: r.number(),
|
|
3346
|
+
endDate: r.number(),
|
|
3347
|
+
variant: An,
|
|
3336
3348
|
conditions: In
|
|
3337
3349
|
});
|
|
3338
|
-
class
|
|
3350
|
+
class Nn {
|
|
3339
3351
|
canApply(e, t) {
|
|
3340
3352
|
if (e.variant.variantType !== "bundle" || !this.isDiscountActive(e)) return !1;
|
|
3341
|
-
const { productsId:
|
|
3342
|
-
return this.getTotalQuantity(t.cart,
|
|
3353
|
+
const { productsId: a, requiredQuantity: i } = e.variant;
|
|
3354
|
+
return this.getTotalQuantity(t.cart, a) >= i;
|
|
3343
3355
|
}
|
|
3344
3356
|
calculate(e, t) {
|
|
3345
3357
|
if (e.variant.variantType !== "bundle")
|
|
3346
3358
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3347
|
-
const { productsId:
|
|
3359
|
+
const { productsId: a, requiredQuantity: i, bundlePrice: s } = e.variant, c = t.cart.filter((H) => a.includes(H.product.id)), o = this.getTotalQuantity(t.cart, a), l = Math.floor(o / i);
|
|
3348
3360
|
if (l === 0)
|
|
3349
3361
|
return { applicable: !1, discountAmount: 0, affectedItems: [] };
|
|
3350
|
-
const
|
|
3351
|
-
|
|
3352
|
-
|
|
3362
|
+
const d = this.calculateOriginalPrice(c), f = this.getTotalQuantity(t.cart, a), x = this.calculateDiscountedPrice(
|
|
3363
|
+
d,
|
|
3364
|
+
s,
|
|
3353
3365
|
l,
|
|
3354
|
-
|
|
3366
|
+
i,
|
|
3355
3367
|
f
|
|
3356
|
-
), T =
|
|
3368
|
+
), T = d - x, w = this.distributeDiscount(c, T, d);
|
|
3357
3369
|
return {
|
|
3358
3370
|
applicable: !0,
|
|
3359
3371
|
discountAmount: Number(T.toFixed(2)),
|
|
@@ -3365,30 +3377,30 @@ class An {
|
|
|
3365
3377
|
return e.active && e.startDate <= t && e.endDate >= t;
|
|
3366
3378
|
}
|
|
3367
3379
|
getTotalQuantity(e, t) {
|
|
3368
|
-
return e.filter((
|
|
3380
|
+
return e.filter((a) => t.includes(a.product.id)).reduce((a, i) => a + i.amount, 0);
|
|
3369
3381
|
}
|
|
3370
3382
|
calculateOriginalPrice(e) {
|
|
3371
|
-
return e.reduce((t,
|
|
3383
|
+
return e.reduce((t, a) => t + a.product.price * a.amount, 0);
|
|
3372
3384
|
}
|
|
3373
|
-
calculateDiscountedPrice(e, t,
|
|
3374
|
-
const c = t *
|
|
3375
|
-
return c +
|
|
3385
|
+
calculateDiscountedPrice(e, t, a, i, s) {
|
|
3386
|
+
const c = t * a, o = a * i, d = Math.max(0, s - o) / s * e;
|
|
3387
|
+
return c + d;
|
|
3376
3388
|
}
|
|
3377
|
-
distributeDiscount(e, t,
|
|
3378
|
-
const
|
|
3379
|
-
return e.map((
|
|
3380
|
-
const c =
|
|
3389
|
+
distributeDiscount(e, t, a) {
|
|
3390
|
+
const i = t / a;
|
|
3391
|
+
return e.map((s) => {
|
|
3392
|
+
const c = s.product.price * s.amount * i;
|
|
3381
3393
|
return {
|
|
3382
|
-
productId:
|
|
3383
|
-
quantity:
|
|
3384
|
-
originalPrice: Number(
|
|
3385
|
-
discountedPrice: Number((
|
|
3394
|
+
productId: s.product.id,
|
|
3395
|
+
quantity: s.amount,
|
|
3396
|
+
originalPrice: Number(s.product.price.toFixed(2)),
|
|
3397
|
+
discountedPrice: Number((s.product.price - c / s.amount).toFixed(2)),
|
|
3386
3398
|
discountAmount: Number(c.toFixed(2))
|
|
3387
3399
|
};
|
|
3388
3400
|
});
|
|
3389
3401
|
}
|
|
3390
3402
|
}
|
|
3391
|
-
class
|
|
3403
|
+
class rt {
|
|
3392
3404
|
static getStrategy(e) {
|
|
3393
3405
|
return this.strategies.get(e.variant.variantType) || null;
|
|
3394
3406
|
}
|
|
@@ -3402,27 +3414,27 @@ class nt {
|
|
|
3402
3414
|
this.strategies.clear();
|
|
3403
3415
|
}
|
|
3404
3416
|
}
|
|
3405
|
-
$e(
|
|
3406
|
-
["bundle", new
|
|
3417
|
+
$e(rt, "strategies", /* @__PURE__ */ new Map([
|
|
3418
|
+
["bundle", new Nn()]
|
|
3407
3419
|
]));
|
|
3408
3420
|
class Gn {
|
|
3409
|
-
static calculateDiscounts(e, t,
|
|
3410
|
-
var
|
|
3411
|
-
const
|
|
3421
|
+
static calculateDiscounts(e, t, a) {
|
|
3422
|
+
var d, f;
|
|
3423
|
+
const i = {
|
|
3412
3424
|
cart: e,
|
|
3413
|
-
user:
|
|
3425
|
+
user: a,
|
|
3414
3426
|
appliedDiscounts: []
|
|
3415
|
-
},
|
|
3416
|
-
for (const x of
|
|
3417
|
-
const T =
|
|
3418
|
-
if (!T || !T.canApply(x,
|
|
3419
|
-
const w = T.calculate(x,
|
|
3427
|
+
}, s = this.filterActiveDiscounts(t), c = [];
|
|
3428
|
+
for (const x of s) {
|
|
3429
|
+
const T = rt.getStrategy(x);
|
|
3430
|
+
if (!T || !T.canApply(x, i) || !((d = x.conditions) != null && d.stackable) && c.length > 0) continue;
|
|
3431
|
+
const w = T.calculate(x, i);
|
|
3420
3432
|
w.applicable && (c.push({
|
|
3421
3433
|
discountId: x.id,
|
|
3422
3434
|
discountName: ((f = x.name[0]) == null ? void 0 : f.value) || "Discount",
|
|
3423
3435
|
discountAmount: Number(w.discountAmount.toFixed(2)),
|
|
3424
3436
|
affectedItems: w.affectedItems
|
|
3425
|
-
}),
|
|
3437
|
+
}), i.appliedDiscounts = c);
|
|
3426
3438
|
}
|
|
3427
3439
|
const o = this.calculateFinalPrices(e, c), l = c.reduce(
|
|
3428
3440
|
(x, T) => x + T.discountAmount,
|
|
@@ -3437,26 +3449,26 @@ class Gn {
|
|
|
3437
3449
|
static filterActiveDiscounts(e) {
|
|
3438
3450
|
const t = Date.now();
|
|
3439
3451
|
return e.filter(
|
|
3440
|
-
(
|
|
3452
|
+
(a) => a.active && a.startDate <= t && a.endDate >= t
|
|
3441
3453
|
);
|
|
3442
3454
|
}
|
|
3443
3455
|
static calculateFinalPrices(e, t) {
|
|
3444
|
-
return e.map((
|
|
3445
|
-
const
|
|
3446
|
-
(l) => l.affectedItems.some((
|
|
3447
|
-
),
|
|
3448
|
-
const f =
|
|
3449
|
-
(x) => x.productId ===
|
|
3456
|
+
return e.map((a) => {
|
|
3457
|
+
const i = t.filter(
|
|
3458
|
+
(l) => l.affectedItems.some((d) => d.productId === a.product.id)
|
|
3459
|
+
), s = i.reduce((l, d) => {
|
|
3460
|
+
const f = d.affectedItems.find(
|
|
3461
|
+
(x) => x.productId === a.product.id
|
|
3450
3462
|
);
|
|
3451
3463
|
return l + ((f == null ? void 0 : f.discountAmount) || 0);
|
|
3452
|
-
}, 0), c =
|
|
3464
|
+
}, 0), c = s / a.amount, o = a.product.price - c;
|
|
3453
3465
|
return {
|
|
3454
|
-
amount:
|
|
3455
|
-
product:
|
|
3456
|
-
originalPrice: Number(
|
|
3466
|
+
amount: a.amount,
|
|
3467
|
+
product: a.product,
|
|
3468
|
+
originalPrice: Number(a.product.price.toFixed(2)),
|
|
3457
3469
|
finalPrice: Number(Math.max(0, o).toFixed(2)),
|
|
3458
|
-
finalDiscount: Number(
|
|
3459
|
-
appliedDiscounts:
|
|
3470
|
+
finalDiscount: Number(s.toFixed(2)),
|
|
3471
|
+
appliedDiscounts: i.map((l) => l.discountId)
|
|
3460
3472
|
};
|
|
3461
3473
|
});
|
|
3462
3474
|
}
|
|
@@ -3468,100 +3480,100 @@ class Gn {
|
|
|
3468
3480
|
return this.filterActiveDiscounts(e);
|
|
3469
3481
|
}
|
|
3470
3482
|
}
|
|
3471
|
-
const Cn =
|
|
3472
|
-
id:
|
|
3473
|
-
name:
|
|
3474
|
-
}), Jn = Cn.omit({ id: !0 }),
|
|
3475
|
-
type:
|
|
3476
|
-
id:
|
|
3477
|
-
name:
|
|
3478
|
-
code:
|
|
3483
|
+
const Cn = r.object({
|
|
3484
|
+
id: r.string(),
|
|
3485
|
+
name: r.string()
|
|
3486
|
+
}), Jn = Cn.omit({ id: !0 }), at = r.object({
|
|
3487
|
+
type: r.literal("Supplier"),
|
|
3488
|
+
id: r.string(),
|
|
3489
|
+
name: r.string(),
|
|
3490
|
+
code: r.string()
|
|
3479
3491
|
// supplier code number
|
|
3480
|
-
}), Hn =
|
|
3481
|
-
type:
|
|
3482
|
-
id:
|
|
3492
|
+
}), Hn = at.omit({ id: !0 }), jn = r.object({
|
|
3493
|
+
type: r.literal("SupplierInvoice"),
|
|
3494
|
+
id: r.string(),
|
|
3483
3495
|
// "draft" = work-in-progress, NOT yet finalized. Product prices are only
|
|
3484
3496
|
// updated once the invoice is finalized ("completed"). Legacy invoices have
|
|
3485
3497
|
// no status and are treated as finalized.
|
|
3486
|
-
status:
|
|
3487
|
-
supplier:
|
|
3488
|
-
invoiceNumber:
|
|
3489
|
-
date:
|
|
3490
|
-
rows:
|
|
3491
|
-
|
|
3492
|
-
id:
|
|
3493
|
-
rowNumber:
|
|
3494
|
-
sku:
|
|
3495
|
-
itemName:
|
|
3496
|
-
quantity:
|
|
3497
|
-
purchasePrice:
|
|
3498
|
-
lineDiscount:
|
|
3499
|
-
profitPercentage:
|
|
3500
|
-
price:
|
|
3501
|
-
totalPurchasePrice:
|
|
3502
|
-
vat:
|
|
3503
|
-
originalProduct:
|
|
3504
|
-
purchasePrice:
|
|
3505
|
-
price:
|
|
3506
|
-
profitPercentage:
|
|
3498
|
+
status: r.enum(["draft", "completed"]).optional(),
|
|
3499
|
+
supplier: at,
|
|
3500
|
+
invoiceNumber: r.string(),
|
|
3501
|
+
date: r.number(),
|
|
3502
|
+
rows: r.array(
|
|
3503
|
+
r.object({
|
|
3504
|
+
id: r.string(),
|
|
3505
|
+
rowNumber: r.number(),
|
|
3506
|
+
sku: r.string(),
|
|
3507
|
+
itemName: r.string(),
|
|
3508
|
+
quantity: r.number(),
|
|
3509
|
+
purchasePrice: r.number(),
|
|
3510
|
+
lineDiscount: r.number(),
|
|
3511
|
+
profitPercentage: r.number(),
|
|
3512
|
+
price: r.number(),
|
|
3513
|
+
totalPurchasePrice: r.number(),
|
|
3514
|
+
vat: r.boolean(),
|
|
3515
|
+
originalProduct: r.object({
|
|
3516
|
+
purchasePrice: r.number(),
|
|
3517
|
+
price: r.number(),
|
|
3518
|
+
profitPercentage: r.number()
|
|
3507
3519
|
}).optional()
|
|
3508
3520
|
})
|
|
3509
3521
|
),
|
|
3510
|
-
productsToUpdate:
|
|
3511
|
-
|
|
3512
|
-
sku:
|
|
3513
|
-
itemName:
|
|
3514
|
-
oldPurchasePrice:
|
|
3515
|
-
newPurchasePrice:
|
|
3516
|
-
oldPrice:
|
|
3517
|
-
newPrice:
|
|
3518
|
-
oldProfitPercentage:
|
|
3519
|
-
newProfitPercentage:
|
|
3522
|
+
productsToUpdate: r.array(
|
|
3523
|
+
r.object({
|
|
3524
|
+
sku: r.string(),
|
|
3525
|
+
itemName: r.string(),
|
|
3526
|
+
oldPurchasePrice: r.number(),
|
|
3527
|
+
newPurchasePrice: r.number(),
|
|
3528
|
+
oldPrice: r.number(),
|
|
3529
|
+
newPrice: r.number(),
|
|
3530
|
+
oldProfitPercentage: r.number(),
|
|
3531
|
+
newProfitPercentage: r.number()
|
|
3520
3532
|
})
|
|
3521
3533
|
),
|
|
3522
|
-
total:
|
|
3523
|
-
totalBeforeVat:
|
|
3524
|
-
vat:
|
|
3525
|
-
}), Kn = jn.omit({ id: !0 }), Zn =
|
|
3526
|
-
recordId:
|
|
3527
|
-
organizationId:
|
|
3528
|
-
customerId:
|
|
3534
|
+
total: r.number().optional(),
|
|
3535
|
+
totalBeforeVat: r.number().optional(),
|
|
3536
|
+
vat: r.number().optional()
|
|
3537
|
+
}), Kn = jn.omit({ id: !0 }), Zn = r.enum(["debt_increase", "debt_reduction"]), er = r.object({
|
|
3538
|
+
recordId: r.string().min(1),
|
|
3539
|
+
organizationId: r.string().min(1),
|
|
3540
|
+
customerId: r.string(),
|
|
3529
3541
|
// "system" when no acting user
|
|
3530
|
-
customerName:
|
|
3531
|
-
billingAccountId:
|
|
3542
|
+
customerName: r.string(),
|
|
3543
|
+
billingAccountId: r.string().nullable(),
|
|
3532
3544
|
type: Zn,
|
|
3533
3545
|
/** Integer agorot, always positive */
|
|
3534
|
-
amount:
|
|
3535
|
-
currency:
|
|
3546
|
+
amount: r.number().int().positive(),
|
|
3547
|
+
currency: r.literal("ILS"),
|
|
3536
3548
|
/** orderId (debt_increase) | ledger transactionId (debt_reduction) */
|
|
3537
|
-
relatedId:
|
|
3538
|
-
source:
|
|
3549
|
+
relatedId: r.string().min(1),
|
|
3550
|
+
source: r.enum(["order", "ledger", "manual"]),
|
|
3539
3551
|
/** event that caused this — trace + idempotency key; null for manual */
|
|
3540
|
-
causedByEventId:
|
|
3552
|
+
causedByEventId: r.string().nullable(),
|
|
3541
3553
|
/** epoch millis */
|
|
3542
|
-
createdAt:
|
|
3554
|
+
createdAt: r.number().int().positive(),
|
|
3543
3555
|
/** Asia/Jerusalem date parts */
|
|
3544
|
-
year:
|
|
3545
|
-
month:
|
|
3556
|
+
year: r.number().int(),
|
|
3557
|
+
month: r.number().int().min(1).max(12),
|
|
3546
3558
|
/** "2026-05" */
|
|
3547
|
-
yearMonth:
|
|
3548
|
-
companyId:
|
|
3549
|
-
storeId:
|
|
3550
|
-
}), tr =
|
|
3559
|
+
yearMonth: r.string(),
|
|
3560
|
+
companyId: r.string().min(1),
|
|
3561
|
+
storeId: r.string().min(1)
|
|
3562
|
+
}), tr = r.object({
|
|
3551
3563
|
/** = doc id */
|
|
3552
|
-
organizationId:
|
|
3553
|
-
organizationName:
|
|
3564
|
+
organizationId: r.string().min(1),
|
|
3565
|
+
organizationName: r.string(),
|
|
3554
3566
|
/** integer agorot — current outstanding debt */
|
|
3555
|
-
totalCurrentDebt:
|
|
3567
|
+
totalCurrentDebt: r.number().int(),
|
|
3556
3568
|
/** lifetime sums (agorot) */
|
|
3557
|
-
totalDebits:
|
|
3558
|
-
totalCredits:
|
|
3559
|
-
currency:
|
|
3569
|
+
totalDebits: r.number().int(),
|
|
3570
|
+
totalCredits: r.number().int(),
|
|
3571
|
+
currency: r.literal("ILS"),
|
|
3560
3572
|
/** epoch millis */
|
|
3561
|
-
updatedAt:
|
|
3562
|
-
companyId:
|
|
3563
|
-
storeId:
|
|
3564
|
-
}), nr =
|
|
3573
|
+
updatedAt: r.number().int().positive(),
|
|
3574
|
+
companyId: r.string().min(1),
|
|
3575
|
+
storeId: r.string().min(1)
|
|
3576
|
+
}), nr = r.enum([
|
|
3565
3577
|
"delivery_note",
|
|
3566
3578
|
"payment_received",
|
|
3567
3579
|
"credit_note",
|
|
@@ -3572,50 +3584,102 @@ const Cn = s.object({
|
|
|
3572
3584
|
// legacy
|
|
3573
3585
|
"order_refunded"
|
|
3574
3586
|
// legacy
|
|
3575
|
-
]), rr =
|
|
3587
|
+
]), rr = r.enum(["check", "bank_transfer", "cash", "credit_card", "other"]), ar = r.object({
|
|
3588
|
+
/** = deterministic dedup doc id */
|
|
3589
|
+
id: r.string().min(1),
|
|
3590
|
+
organizationId: r.string().min(1),
|
|
3591
|
+
/** "+" increases owed (accrual), "-" decreases owed (settlement/adjustment) */
|
|
3592
|
+
sign: r.enum(["+", "-"]),
|
|
3593
|
+
kind: r.enum(["accrual", "settlement", "adjustment"]),
|
|
3594
|
+
/** Integer agorot, always positive; sign carries direction */
|
|
3595
|
+
amount: r.number().int().positive(),
|
|
3596
|
+
currency: r.literal("ILS"),
|
|
3597
|
+
source: r.enum(["delivery_note", "ledger_payment", "manual", "order_reversal"]),
|
|
3598
|
+
/** Present for document-sourced accruals */
|
|
3599
|
+
document: r.object({
|
|
3600
|
+
type: r.enum(["delivery_note", "invoice"]),
|
|
3601
|
+
id: r.string().min(1),
|
|
3602
|
+
number: r.string().optional()
|
|
3603
|
+
}).optional(),
|
|
3604
|
+
/** Order id (accrual), ledger txId (settlement), or manual ref */
|
|
3605
|
+
reference: r.object({
|
|
3606
|
+
type: r.enum(["order", "transaction", "manual"]),
|
|
3607
|
+
id: r.string().min(1)
|
|
3608
|
+
}).optional(),
|
|
3609
|
+
/** Optional sub-grouping within an org */
|
|
3610
|
+
billingAccountId: r.string().nullable().optional(),
|
|
3611
|
+
/** Deterministic dedup key; doc id is derived from this */
|
|
3612
|
+
dedupKey: r.string().min(1),
|
|
3613
|
+
/** Event id when source is event-driven */
|
|
3614
|
+
causedByEventId: r.string().optional(),
|
|
3615
|
+
/** Epoch millis — used for date-range queries */
|
|
3616
|
+
createdAt: r.number().int().positive(),
|
|
3617
|
+
companyId: r.string().min(1),
|
|
3618
|
+
storeId: r.string().min(1)
|
|
3619
|
+
}), ir = r.object({
|
|
3620
|
+
/** = doc id */
|
|
3621
|
+
organizationId: r.string().min(1),
|
|
3622
|
+
/** Σ(+) − Σ(−), clamped ≥ 0; integer agorot. Non-zero only when totalAccrued > totalSettled. */
|
|
3623
|
+
owed: r.number().int(),
|
|
3624
|
+
/**
|
|
3625
|
+
* Overpayment credit: max(0, totalSettled − totalAccrued); integer agorot, ≥ 0.
|
|
3626
|
+
* Non-zero only when org has paid MORE than it has accrued.
|
|
3627
|
+
* Visibility only — not client-spendable. At most one of {owed, credit} is non-zero.
|
|
3628
|
+
*/
|
|
3629
|
+
credit: r.number().int(),
|
|
3630
|
+
/** Lifetime Σ(+); integer agorot */
|
|
3631
|
+
totalAccrued: r.number().int(),
|
|
3632
|
+
/** Lifetime Σ(−); integer agorot */
|
|
3633
|
+
totalSettled: r.number().int(),
|
|
3634
|
+
currency: r.literal("ILS"),
|
|
3635
|
+
/** Epoch millis */
|
|
3636
|
+
updatedAt: r.number().int().positive(),
|
|
3637
|
+
companyId: r.string().min(1),
|
|
3638
|
+
storeId: r.string().min(1)
|
|
3639
|
+
}), De = {
|
|
3576
3640
|
VAT: 18
|
|
3577
3641
|
};
|
|
3578
3642
|
function On(n, e) {
|
|
3579
|
-
var t,
|
|
3580
|
-
return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((
|
|
3643
|
+
var t, a;
|
|
3644
|
+
return ((t = n.discount) == null ? void 0 : t.type) === "percent" ? n.price * (n.discount.value ?? 100) / 100 : ((a = n.discount) == null ? void 0 : a.type) === "number" ? n.discount.value ?? 0 : 0;
|
|
3581
3645
|
}
|
|
3582
3646
|
function Dn(n, e) {
|
|
3583
|
-
var
|
|
3647
|
+
var a, i;
|
|
3584
3648
|
const t = e && n.vat ? n.price + n.price * De.VAT / 100 : n.price;
|
|
3585
|
-
if (((
|
|
3586
|
-
const
|
|
3587
|
-
return n.price -
|
|
3649
|
+
if (((a = n.discount) == null ? void 0 : a.type) === "percent") {
|
|
3650
|
+
const s = t * n.discount.value / 100;
|
|
3651
|
+
return n.price - s;
|
|
3588
3652
|
}
|
|
3589
|
-
return ((
|
|
3653
|
+
return ((i = n.discount) == null ? void 0 : i.type) === "number" ? t - n.discount.value : t;
|
|
3590
3654
|
}
|
|
3591
3655
|
function sr({
|
|
3592
3656
|
cart: n,
|
|
3593
3657
|
discounts: e,
|
|
3594
3658
|
deliveryPrice: t = 0,
|
|
3595
|
-
freeDeliveryPrice:
|
|
3596
|
-
isVatIncludedInPrice:
|
|
3659
|
+
freeDeliveryPrice: a = 0,
|
|
3660
|
+
isVatIncludedInPrice: i = !1
|
|
3597
3661
|
}) {
|
|
3598
|
-
const
|
|
3662
|
+
const s = n.map((o, l) => ({
|
|
3599
3663
|
amount: o.amount,
|
|
3600
3664
|
product: { ...o.product },
|
|
3601
3665
|
originalPrice: o.product.price,
|
|
3602
|
-
finalPrice: Dn(o.product,
|
|
3666
|
+
finalPrice: Dn(o.product, i),
|
|
3603
3667
|
finalDiscount: On(o.product)
|
|
3604
|
-
})), c =
|
|
3668
|
+
})), c = s.reduce(
|
|
3605
3669
|
(o, l) => {
|
|
3606
|
-
const { product:
|
|
3670
|
+
const { product: d, amount: f, finalPrice: x, finalDiscount: T } = l;
|
|
3607
3671
|
let w = 0;
|
|
3608
|
-
if (
|
|
3609
|
-
let
|
|
3610
|
-
if (
|
|
3611
|
-
const
|
|
3612
|
-
w = Number(
|
|
3672
|
+
if (d.vat) {
|
|
3673
|
+
let Ae = 0;
|
|
3674
|
+
if (i) {
|
|
3675
|
+
const it = Number((x / (1 + De.VAT / 100)).toFixed(2)), st = x - it;
|
|
3676
|
+
w = Number(st.toFixed(2)), w = w * f, Ae = Number(w.toFixed(2));
|
|
3613
3677
|
} else
|
|
3614
|
-
w = x * De.VAT / 100, w = w * f,
|
|
3615
|
-
o.vat = Number((o.vat +
|
|
3678
|
+
w = x * De.VAT / 100, w = w * f, Ae = Number(w.toFixed(2));
|
|
3679
|
+
o.vat = Number((o.vat + Ae).toFixed(2));
|
|
3616
3680
|
}
|
|
3617
3681
|
const H = Number(x.toFixed(2));
|
|
3618
|
-
return o.cost += f * H, o.discount += T && f * T, o.finalCost += f * H + (
|
|
3682
|
+
return o.cost += f * H, o.discount += T && f * T, o.finalCost += f * H + (i ? 0 : w), o.productsCost += f * H + (i ? 0 : w), o.cost = Number(o.cost.toFixed(2)), o.discount = Number(o.discount.toFixed(2)), o.finalCost = Number(o.finalCost.toFixed(2)), o.productsCost = Number(o.productsCost.toFixed(2)), o;
|
|
3619
3683
|
},
|
|
3620
3684
|
{
|
|
3621
3685
|
discount: 0,
|
|
@@ -3626,7 +3690,7 @@ function sr({
|
|
|
3626
3690
|
deliveryPrice: t
|
|
3627
3691
|
}
|
|
3628
3692
|
);
|
|
3629
|
-
return c.deliveryPrice && c.productsCost >=
|
|
3693
|
+
return c.deliveryPrice && c.productsCost >= a ? c.deliveryPrice = 0 : c.finalCost += c.deliveryPrice, { items: s, ...c };
|
|
3630
3694
|
}
|
|
3631
3695
|
const Pn = {
|
|
3632
3696
|
stores: "STORES",
|
|
@@ -3657,7 +3721,9 @@ const Pn = {
|
|
|
3657
3721
|
organizationBudgets: "organizationBudgets",
|
|
3658
3722
|
transactions: "transactions",
|
|
3659
3723
|
paymentLinks: "paymentLinks",
|
|
3660
|
-
duplicateChargeAlerts: "duplicateChargeAlerts"
|
|
3724
|
+
duplicateChargeAlerts: "duplicateChargeAlerts",
|
|
3725
|
+
organizationBalance: "organizationBalance",
|
|
3726
|
+
organizationBalanceRollup: "organizationBalanceRollup"
|
|
3661
3727
|
}, Rn = {
|
|
3662
3728
|
systemCollections: Pn,
|
|
3663
3729
|
storeCollections: En,
|
|
@@ -3666,54 +3732,56 @@ const Pn = {
|
|
|
3666
3732
|
companyId: n,
|
|
3667
3733
|
storeId: e,
|
|
3668
3734
|
collectionName: t,
|
|
3669
|
-
id:
|
|
3670
|
-
}) => `${n}/${e}/${t}${
|
|
3735
|
+
id: a
|
|
3736
|
+
}) => `${n}/${e}/${t}${a ? `/${a}` : ""}`,
|
|
3671
3737
|
getSubPath: ({
|
|
3672
3738
|
companyId: n,
|
|
3673
3739
|
storeId: e,
|
|
3674
3740
|
collectionName: t,
|
|
3675
|
-
subCollectionName:
|
|
3676
|
-
id:
|
|
3677
|
-
subId:
|
|
3678
|
-
}) => `${n}/${e}/${t}/${
|
|
3741
|
+
subCollectionName: a,
|
|
3742
|
+
id: i,
|
|
3743
|
+
subId: s
|
|
3744
|
+
}) => `${n}/${e}/${t}/${i}/${a}${s ? `/${s}` : ""}`,
|
|
3679
3745
|
// for firestore events
|
|
3680
3746
|
getDocPath: (n) => `{companyId}/{storeId}/${n}/{id}`,
|
|
3681
3747
|
getSubDocPath: (n, e, t) => `{companyId}/{storeId}/${n}/${e}/${t}/{id}`
|
|
3682
|
-
},
|
|
3748
|
+
}, or = {
|
|
3683
3749
|
firestore: Rn
|
|
3684
|
-
},
|
|
3750
|
+
}, Fe = {
|
|
3685
3751
|
round: (n, e = 2) => {
|
|
3686
3752
|
const t = 10 ** e;
|
|
3687
3753
|
return Math.round((n + Number.EPSILON) * t) / t;
|
|
3688
3754
|
}
|
|
3689
|
-
},
|
|
3690
|
-
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e :
|
|
3691
|
-
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 :
|
|
3755
|
+
}, cr = {
|
|
3756
|
+
calcSalePriceFromMargin: (n, e) => n <= 0 || e <= 0 || n >= 100 ? e : Fe.round(e / (1 - n / 100)),
|
|
3757
|
+
calcMarginFromSalePrice: (n, e) => n <= 0 || e <= 0 ? 0 : Fe.round((n - e) / n * 100)
|
|
3692
3758
|
};
|
|
3693
3759
|
export {
|
|
3694
3760
|
Se as AddressSchema,
|
|
3695
|
-
|
|
3696
|
-
|
|
3761
|
+
Ke as BaseCategorySchema,
|
|
3762
|
+
nt as BillingAccountSchema,
|
|
3697
3763
|
er as BudgetRecordSchema,
|
|
3698
3764
|
Zn as BudgetRecordTypeSchema,
|
|
3699
3765
|
nr as BudgetTransactionTypeSchema,
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3766
|
+
Nn as BundleDiscountStrategy,
|
|
3767
|
+
tt as CalculatedDataSchema,
|
|
3768
|
+
et as CartItemProductSchema,
|
|
3703
3769
|
Un as CartSchema,
|
|
3704
3770
|
Ee as CategorySchema,
|
|
3705
3771
|
qn as CompanySchema,
|
|
3706
|
-
|
|
3772
|
+
kn as DeliveryNoteSchema,
|
|
3707
3773
|
In as DiscountConditionsSchema,
|
|
3708
3774
|
Gn as DiscountEngine,
|
|
3709
3775
|
Xn as DiscountSchema,
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3776
|
+
rt as DiscountStrategyFactory,
|
|
3777
|
+
An as DiscountVariantSchema,
|
|
3778
|
+
xn as EzDeliveryNoteSchema,
|
|
3779
|
+
Le as EzInvoiceSchema,
|
|
3713
3780
|
Bn as FavoriteProductSchema,
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3781
|
+
zn as FileSchema,
|
|
3782
|
+
or as FirebaseAPI,
|
|
3783
|
+
vn as FulfillmentStatusSchema,
|
|
3784
|
+
Tn as InvoiceSchema,
|
|
3717
3785
|
ge as LocaleSchema,
|
|
3718
3786
|
Jn as NewOrganizationGroupSchema,
|
|
3719
3787
|
Wn as NewOrganizationSchema,
|
|
@@ -3721,25 +3789,27 @@ export {
|
|
|
3721
3789
|
Kn as NewSupplierInvoiceSchema,
|
|
3722
3790
|
Hn as NewSupplierSchema,
|
|
3723
3791
|
Qn as OrderSchema,
|
|
3792
|
+
ar as OrganizationBalanceEntrySchema,
|
|
3793
|
+
ir as OrganizationBalanceRollupSchema,
|
|
3724
3794
|
tr as OrganizationBudgetSchema,
|
|
3725
3795
|
Cn as OrganizationGroupSchema,
|
|
3726
|
-
|
|
3796
|
+
wn as OrganizationSchema,
|
|
3727
3797
|
rr as PaymentMethodSchema,
|
|
3728
3798
|
Ie as PaymentTypeSchema,
|
|
3729
3799
|
Re as ProductSchema,
|
|
3730
|
-
|
|
3800
|
+
bn as ProfileSchema,
|
|
3731
3801
|
Yn as StoreSchema,
|
|
3732
|
-
|
|
3802
|
+
_n as SubstitutedWithSchema,
|
|
3733
3803
|
jn as SupplierInvoiceSchema,
|
|
3734
|
-
|
|
3804
|
+
at as SupplierSchema,
|
|
3735
3805
|
Ln as TFlattenCategorySchema,
|
|
3736
3806
|
Sn as clientTypesSchema,
|
|
3737
3807
|
sr as getCartCost,
|
|
3738
|
-
|
|
3739
|
-
|
|
3808
|
+
Vn as isFile,
|
|
3809
|
+
Fe as math,
|
|
3740
3810
|
R as notEmptyTextSchema,
|
|
3741
3811
|
Mn as numericTextSchema,
|
|
3742
|
-
|
|
3812
|
+
cr as storeCalculator,
|
|
3743
3813
|
En as storeCollections,
|
|
3744
3814
|
Pn as systemCollections
|
|
3745
3815
|
};
|