@resconet/qp-bridge 0.0.1-alpha.5 → 0.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/index.js +1 -1
- package/index.mjs +813 -761
- package/lib/qp-bridge-types.d.ts +120 -8
- package/lib/qp-bridge.d.ts +14 -1
- package/package.json +3 -2
package/index.mjs
CHANGED
|
@@ -1,47 +1,70 @@
|
|
|
1
|
+
let he;
|
|
2
|
+
const Ye = new Uint8Array(16);
|
|
3
|
+
function Ge() {
|
|
4
|
+
if (!he && (he = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !he))
|
|
5
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6
|
+
return he(Ye);
|
|
7
|
+
}
|
|
8
|
+
const b = [];
|
|
9
|
+
for (let s = 0; s < 256; ++s)
|
|
10
|
+
b.push((s + 256).toString(16).slice(1));
|
|
11
|
+
function He(s, e = 0) {
|
|
12
|
+
return b[s[e + 0]] + b[s[e + 1]] + b[s[e + 2]] + b[s[e + 3]] + "-" + b[s[e + 4]] + b[s[e + 5]] + "-" + b[s[e + 6]] + b[s[e + 7]] + "-" + b[s[e + 8]] + b[s[e + 9]] + "-" + b[s[e + 10]] + b[s[e + 11]] + b[s[e + 12]] + b[s[e + 13]] + b[s[e + 14]] + b[s[e + 15]];
|
|
13
|
+
}
|
|
14
|
+
const Je = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Re = {
|
|
15
|
+
randomUUID: Je
|
|
16
|
+
};
|
|
17
|
+
function Xe(s, e, t) {
|
|
18
|
+
if (Re.randomUUID && !e && !s)
|
|
19
|
+
return Re.randomUUID();
|
|
20
|
+
s = s || {};
|
|
21
|
+
const n = s.random || (s.rng || Ge)();
|
|
22
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, He(n);
|
|
23
|
+
}
|
|
1
24
|
var _;
|
|
2
25
|
(function(s) {
|
|
3
|
-
s.assertEqual = (
|
|
4
|
-
function e(
|
|
26
|
+
s.assertEqual = (r) => r;
|
|
27
|
+
function e(r) {
|
|
5
28
|
}
|
|
6
29
|
s.assertIs = e;
|
|
7
|
-
function t(
|
|
30
|
+
function t(r) {
|
|
8
31
|
throw new Error();
|
|
9
32
|
}
|
|
10
|
-
s.assertNever = t, s.arrayToEnum = (
|
|
33
|
+
s.assertNever = t, s.arrayToEnum = (r) => {
|
|
11
34
|
const a = {};
|
|
12
|
-
for (const i of
|
|
35
|
+
for (const i of r)
|
|
13
36
|
a[i] = i;
|
|
14
37
|
return a;
|
|
15
|
-
}, s.getValidEnumValues = (
|
|
16
|
-
const a = s.objectKeys(
|
|
38
|
+
}, s.getValidEnumValues = (r) => {
|
|
39
|
+
const a = s.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
|
|
17
40
|
for (const o of a)
|
|
18
|
-
i[o] =
|
|
41
|
+
i[o] = r[o];
|
|
19
42
|
return s.objectValues(i);
|
|
20
|
-
}, s.objectValues = (
|
|
21
|
-
return
|
|
22
|
-
}), s.objectKeys = typeof Object.keys == "function" ? (
|
|
43
|
+
}, s.objectValues = (r) => s.objectKeys(r).map(function(a) {
|
|
44
|
+
return r[a];
|
|
45
|
+
}), s.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
|
|
23
46
|
const a = [];
|
|
24
|
-
for (const i in
|
|
25
|
-
Object.prototype.hasOwnProperty.call(
|
|
47
|
+
for (const i in r)
|
|
48
|
+
Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
|
|
26
49
|
return a;
|
|
27
|
-
}, s.find = (
|
|
28
|
-
for (const i of
|
|
50
|
+
}, s.find = (r, a) => {
|
|
51
|
+
for (const i of r)
|
|
29
52
|
if (a(i))
|
|
30
53
|
return i;
|
|
31
|
-
}, s.isInteger = typeof Number.isInteger == "function" ? (
|
|
32
|
-
function r
|
|
33
|
-
return
|
|
54
|
+
}, s.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && isFinite(r) && Math.floor(r) === r;
|
|
55
|
+
function n(r, a = " | ") {
|
|
56
|
+
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
34
57
|
}
|
|
35
|
-
s.joinValues =
|
|
58
|
+
s.joinValues = n, s.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
36
59
|
})(_ || (_ = {}));
|
|
37
|
-
var
|
|
60
|
+
var Te;
|
|
38
61
|
(function(s) {
|
|
39
62
|
s.mergeShapes = (e, t) => ({
|
|
40
63
|
...e,
|
|
41
64
|
...t
|
|
42
65
|
// second overwrites first
|
|
43
66
|
});
|
|
44
|
-
})(
|
|
67
|
+
})(Te || (Te = {}));
|
|
45
68
|
const f = _.arrayToEnum([
|
|
46
69
|
"string",
|
|
47
70
|
"nan",
|
|
@@ -63,7 +86,7 @@ const f = _.arrayToEnum([
|
|
|
63
86
|
"never",
|
|
64
87
|
"map",
|
|
65
88
|
"set"
|
|
66
|
-
]),
|
|
89
|
+
]), M = (s) => {
|
|
67
90
|
switch (typeof s) {
|
|
68
91
|
case "undefined":
|
|
69
92
|
return f.undefined;
|
|
@@ -101,13 +124,13 @@ const f = _.arrayToEnum([
|
|
|
101
124
|
"invalid_intersection_types",
|
|
102
125
|
"not_multiple_of",
|
|
103
126
|
"not_finite"
|
|
104
|
-
]),
|
|
105
|
-
class
|
|
127
|
+
]), Ke = (s) => JSON.stringify(s, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
128
|
+
class S extends Error {
|
|
106
129
|
constructor(e) {
|
|
107
|
-
super(), this.issues = [], this.addIssue = (
|
|
108
|
-
this.issues = [...this.issues,
|
|
109
|
-
}, this.addIssues = (
|
|
110
|
-
this.issues = [...this.issues, ...
|
|
130
|
+
super(), this.issues = [], this.addIssue = (n) => {
|
|
131
|
+
this.issues = [...this.issues, n];
|
|
132
|
+
}, this.addIssues = (n = []) => {
|
|
133
|
+
this.issues = [...this.issues, ...n];
|
|
111
134
|
};
|
|
112
135
|
const t = new.target.prototype;
|
|
113
136
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -118,28 +141,28 @@ class T extends Error {
|
|
|
118
141
|
format(e) {
|
|
119
142
|
const t = e || function(a) {
|
|
120
143
|
return a.message;
|
|
121
|
-
},
|
|
144
|
+
}, n = { _errors: [] }, r = (a) => {
|
|
122
145
|
for (const i of a.issues)
|
|
123
146
|
if (i.code === "invalid_union")
|
|
124
|
-
i.unionErrors.map(
|
|
147
|
+
i.unionErrors.map(r);
|
|
125
148
|
else if (i.code === "invalid_return_type")
|
|
126
|
-
|
|
149
|
+
r(i.returnTypeError);
|
|
127
150
|
else if (i.code === "invalid_arguments")
|
|
128
|
-
|
|
151
|
+
r(i.argumentsError);
|
|
129
152
|
else if (i.path.length === 0)
|
|
130
|
-
|
|
153
|
+
n._errors.push(t(i));
|
|
131
154
|
else {
|
|
132
|
-
let o =
|
|
155
|
+
let o = n, u = 0;
|
|
133
156
|
for (; u < i.path.length; ) {
|
|
134
157
|
const c = i.path[u];
|
|
135
158
|
u === i.path.length - 1 ? (o[c] = o[c] || { _errors: [] }, o[c]._errors.push(t(i))) : o[c] = o[c] || { _errors: [] }, o = o[c], u++;
|
|
136
159
|
}
|
|
137
160
|
}
|
|
138
161
|
};
|
|
139
|
-
return
|
|
162
|
+
return r(this), n;
|
|
140
163
|
}
|
|
141
164
|
static assert(e) {
|
|
142
|
-
if (!(e instanceof
|
|
165
|
+
if (!(e instanceof S))
|
|
143
166
|
throw new Error(`Not a ZodError: ${e}`);
|
|
144
167
|
}
|
|
145
168
|
toString() {
|
|
@@ -152,17 +175,17 @@ class T extends Error {
|
|
|
152
175
|
return this.issues.length === 0;
|
|
153
176
|
}
|
|
154
177
|
flatten(e = (t) => t.message) {
|
|
155
|
-
const t = {},
|
|
156
|
-
for (const
|
|
157
|
-
|
|
158
|
-
return { formErrors:
|
|
178
|
+
const t = {}, n = [];
|
|
179
|
+
for (const r of this.issues)
|
|
180
|
+
r.path.length > 0 ? (t[r.path[0]] = t[r.path[0]] || [], t[r.path[0]].push(e(r))) : n.push(e(r));
|
|
181
|
+
return { formErrors: n, fieldErrors: t };
|
|
159
182
|
}
|
|
160
183
|
get formErrors() {
|
|
161
184
|
return this.flatten();
|
|
162
185
|
}
|
|
163
186
|
}
|
|
164
|
-
|
|
165
|
-
const
|
|
187
|
+
S.create = (s) => new S(s);
|
|
188
|
+
const Y = (s, e) => {
|
|
166
189
|
let t;
|
|
167
190
|
switch (s.code) {
|
|
168
191
|
case d.invalid_type:
|
|
@@ -218,36 +241,36 @@ const W = (s, e) => {
|
|
|
218
241
|
}
|
|
219
242
|
return { message: t };
|
|
220
243
|
};
|
|
221
|
-
let
|
|
222
|
-
function
|
|
223
|
-
|
|
244
|
+
let Ae = Y;
|
|
245
|
+
function Fe(s) {
|
|
246
|
+
Ae = s;
|
|
224
247
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
248
|
+
function pe() {
|
|
249
|
+
return Ae;
|
|
227
250
|
}
|
|
228
|
-
const
|
|
229
|
-
const { data: e, path: t, errorMaps:
|
|
230
|
-
...
|
|
251
|
+
const me = (s) => {
|
|
252
|
+
const { data: e, path: t, errorMaps: n, issueData: r } = s, a = [...t, ...r.path || []], i = {
|
|
253
|
+
...r,
|
|
231
254
|
path: a
|
|
232
255
|
};
|
|
233
|
-
if (
|
|
256
|
+
if (r.message !== void 0)
|
|
234
257
|
return {
|
|
235
|
-
...
|
|
258
|
+
...r,
|
|
236
259
|
path: a,
|
|
237
|
-
message:
|
|
260
|
+
message: r.message
|
|
238
261
|
};
|
|
239
262
|
let o = "";
|
|
240
|
-
const u =
|
|
263
|
+
const u = n.filter((c) => !!c).slice().reverse();
|
|
241
264
|
for (const c of u)
|
|
242
265
|
o = c(i, { data: e, defaultError: o }).message;
|
|
243
266
|
return {
|
|
244
|
-
...
|
|
267
|
+
...r,
|
|
245
268
|
path: a,
|
|
246
269
|
message: o
|
|
247
270
|
};
|
|
248
|
-
},
|
|
271
|
+
}, et = [];
|
|
249
272
|
function l(s, e) {
|
|
250
|
-
const t =
|
|
273
|
+
const t = pe(), n = me({
|
|
251
274
|
issueData: e,
|
|
252
275
|
data: s.data,
|
|
253
276
|
path: s.path,
|
|
@@ -255,13 +278,13 @@ function l(s, e) {
|
|
|
255
278
|
s.common.contextualErrorMap,
|
|
256
279
|
s.schemaErrorMap,
|
|
257
280
|
t,
|
|
258
|
-
t ===
|
|
281
|
+
t === Y ? void 0 : Y
|
|
259
282
|
// then global default map
|
|
260
|
-
].filter((
|
|
283
|
+
].filter((r) => !!r)
|
|
261
284
|
});
|
|
262
|
-
s.common.issues.push(
|
|
285
|
+
s.common.issues.push(n);
|
|
263
286
|
}
|
|
264
|
-
class
|
|
287
|
+
class w {
|
|
265
288
|
constructor() {
|
|
266
289
|
this.value = "valid";
|
|
267
290
|
}
|
|
@@ -272,46 +295,46 @@ class b {
|
|
|
272
295
|
this.value !== "aborted" && (this.value = "aborted");
|
|
273
296
|
}
|
|
274
297
|
static mergeArray(e, t) {
|
|
275
|
-
const
|
|
276
|
-
for (const
|
|
277
|
-
if (
|
|
298
|
+
const n = [];
|
|
299
|
+
for (const r of t) {
|
|
300
|
+
if (r.status === "aborted")
|
|
278
301
|
return m;
|
|
279
|
-
|
|
302
|
+
r.status === "dirty" && e.dirty(), n.push(r.value);
|
|
280
303
|
}
|
|
281
|
-
return { status: e.value, value:
|
|
304
|
+
return { status: e.value, value: n };
|
|
282
305
|
}
|
|
283
306
|
static async mergeObjectAsync(e, t) {
|
|
284
|
-
const
|
|
285
|
-
for (const
|
|
286
|
-
const a = await
|
|
287
|
-
|
|
307
|
+
const n = [];
|
|
308
|
+
for (const r of t) {
|
|
309
|
+
const a = await r.key, i = await r.value;
|
|
310
|
+
n.push({
|
|
288
311
|
key: a,
|
|
289
312
|
value: i
|
|
290
313
|
});
|
|
291
314
|
}
|
|
292
|
-
return
|
|
315
|
+
return w.mergeObjectSync(e, n);
|
|
293
316
|
}
|
|
294
317
|
static mergeObjectSync(e, t) {
|
|
295
|
-
const
|
|
296
|
-
for (const
|
|
297
|
-
const { key: a, value: i } =
|
|
318
|
+
const n = {};
|
|
319
|
+
for (const r of t) {
|
|
320
|
+
const { key: a, value: i } = r;
|
|
298
321
|
if (a.status === "aborted" || i.status === "aborted")
|
|
299
322
|
return m;
|
|
300
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" ||
|
|
323
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (n[a.value] = i.value);
|
|
301
324
|
}
|
|
302
|
-
return { status: e.value, value:
|
|
325
|
+
return { status: e.value, value: n };
|
|
303
326
|
}
|
|
304
327
|
}
|
|
305
328
|
const m = Object.freeze({
|
|
306
329
|
status: "aborted"
|
|
307
|
-
}),
|
|
308
|
-
function
|
|
309
|
-
if (typeof e == "function" ? s !== e || !
|
|
330
|
+
}), W = (s) => ({ status: "dirty", value: s }), T = (s) => ({ status: "valid", value: s }), Se = (s) => s.status === "aborted", Ze = (s) => s.status === "dirty", K = (s) => s.status === "valid", F = (s) => typeof Promise < "u" && s instanceof Promise;
|
|
331
|
+
function ye(s, e, t, n) {
|
|
332
|
+
if (typeof e == "function" ? s !== e || !n : !e.has(s))
|
|
310
333
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
311
334
|
return e.get(s);
|
|
312
335
|
}
|
|
313
|
-
function
|
|
314
|
-
if (typeof e == "function" ? s !== e || !
|
|
336
|
+
function Me(s, e, t, n, r) {
|
|
337
|
+
if (typeof e == "function" ? s !== e || !r : !e.has(s))
|
|
315
338
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
316
339
|
return e.set(s, t), t;
|
|
317
340
|
}
|
|
@@ -319,17 +342,17 @@ var h;
|
|
|
319
342
|
(function(s) {
|
|
320
343
|
s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
321
344
|
})(h || (h = {}));
|
|
322
|
-
var J,
|
|
323
|
-
class
|
|
324
|
-
constructor(e, t,
|
|
325
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
345
|
+
var J, X;
|
|
346
|
+
class R {
|
|
347
|
+
constructor(e, t, n, r) {
|
|
348
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = r;
|
|
326
349
|
}
|
|
327
350
|
get path() {
|
|
328
351
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
329
352
|
}
|
|
330
353
|
}
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
354
|
+
const Ie = (s, e) => {
|
|
355
|
+
if (K(e))
|
|
333
356
|
return { success: !0, data: e.value };
|
|
334
357
|
if (!s.common.issues.length)
|
|
335
358
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -338,7 +361,7 @@ const Ee = (s, e) => {
|
|
|
338
361
|
get error() {
|
|
339
362
|
if (this._error)
|
|
340
363
|
return this._error;
|
|
341
|
-
const t = new
|
|
364
|
+
const t = new S(s.common.issues);
|
|
342
365
|
return this._error = t, this._error;
|
|
343
366
|
}
|
|
344
367
|
};
|
|
@@ -346,14 +369,14 @@ const Ee = (s, e) => {
|
|
|
346
369
|
function g(s) {
|
|
347
370
|
if (!s)
|
|
348
371
|
return {};
|
|
349
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
350
|
-
if (e && (t ||
|
|
372
|
+
const { errorMap: e, invalid_type_error: t, required_error: n, description: r } = s;
|
|
373
|
+
if (e && (t || n))
|
|
351
374
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
352
|
-
return e ? { errorMap: e, description:
|
|
375
|
+
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
353
376
|
var u, c;
|
|
354
377
|
const { message: y } = s;
|
|
355
|
-
return i.code === "invalid_enum_value" ? { message: y ?? o.defaultError } : typeof o.data > "u" ? { message: (u = y ??
|
|
356
|
-
}, description:
|
|
378
|
+
return i.code === "invalid_enum_value" ? { message: y ?? o.defaultError } : typeof o.data > "u" ? { message: (u = y ?? n) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (c = y ?? t) !== null && c !== void 0 ? c : o.defaultError };
|
|
379
|
+
}, description: r };
|
|
357
380
|
}
|
|
358
381
|
class v {
|
|
359
382
|
constructor(e) {
|
|
@@ -363,13 +386,13 @@ class v {
|
|
|
363
386
|
return this._def.description;
|
|
364
387
|
}
|
|
365
388
|
_getType(e) {
|
|
366
|
-
return
|
|
389
|
+
return M(e.data);
|
|
367
390
|
}
|
|
368
391
|
_getOrReturnCtx(e, t) {
|
|
369
392
|
return t || {
|
|
370
393
|
common: e.parent.common,
|
|
371
394
|
data: e.data,
|
|
372
|
-
parsedType:
|
|
395
|
+
parsedType: M(e.data),
|
|
373
396
|
schemaErrorMap: this._def.errorMap,
|
|
374
397
|
path: e.path,
|
|
375
398
|
parent: e.parent
|
|
@@ -377,11 +400,11 @@ class v {
|
|
|
377
400
|
}
|
|
378
401
|
_processInputParams(e) {
|
|
379
402
|
return {
|
|
380
|
-
status: new
|
|
403
|
+
status: new w(),
|
|
381
404
|
ctx: {
|
|
382
405
|
common: e.parent.common,
|
|
383
406
|
data: e.data,
|
|
384
|
-
parsedType:
|
|
407
|
+
parsedType: M(e.data),
|
|
385
408
|
schemaErrorMap: this._def.errorMap,
|
|
386
409
|
path: e.path,
|
|
387
410
|
parent: e.parent
|
|
@@ -390,7 +413,7 @@ class v {
|
|
|
390
413
|
}
|
|
391
414
|
_parseSync(e) {
|
|
392
415
|
const t = this._parse(e);
|
|
393
|
-
if (
|
|
416
|
+
if (F(t))
|
|
394
417
|
throw new Error("Synchronous parse encountered promise.");
|
|
395
418
|
return t;
|
|
396
419
|
}
|
|
@@ -399,35 +422,35 @@ class v {
|
|
|
399
422
|
return Promise.resolve(t);
|
|
400
423
|
}
|
|
401
424
|
parse(e, t) {
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return
|
|
405
|
-
throw
|
|
425
|
+
const n = this.safeParse(e, t);
|
|
426
|
+
if (n.success)
|
|
427
|
+
return n.data;
|
|
428
|
+
throw n.error;
|
|
406
429
|
}
|
|
407
430
|
safeParse(e, t) {
|
|
408
|
-
var
|
|
409
|
-
const
|
|
431
|
+
var n;
|
|
432
|
+
const r = {
|
|
410
433
|
common: {
|
|
411
434
|
issues: [],
|
|
412
|
-
async: (
|
|
435
|
+
async: (n = t == null ? void 0 : t.async) !== null && n !== void 0 ? n : !1,
|
|
413
436
|
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
414
437
|
},
|
|
415
438
|
path: (t == null ? void 0 : t.path) || [],
|
|
416
439
|
schemaErrorMap: this._def.errorMap,
|
|
417
440
|
parent: null,
|
|
418
441
|
data: e,
|
|
419
|
-
parsedType:
|
|
420
|
-
}, a = this._parseSync({ data: e, path:
|
|
421
|
-
return
|
|
442
|
+
parsedType: M(e)
|
|
443
|
+
}, a = this._parseSync({ data: e, path: r.path, parent: r });
|
|
444
|
+
return Ie(r, a);
|
|
422
445
|
}
|
|
423
446
|
async parseAsync(e, t) {
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
426
|
-
return
|
|
427
|
-
throw
|
|
447
|
+
const n = await this.safeParseAsync(e, t);
|
|
448
|
+
if (n.success)
|
|
449
|
+
return n.data;
|
|
450
|
+
throw n.error;
|
|
428
451
|
}
|
|
429
452
|
async safeParseAsync(e, t) {
|
|
430
|
-
const
|
|
453
|
+
const n = {
|
|
431
454
|
common: {
|
|
432
455
|
issues: [],
|
|
433
456
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -437,25 +460,25 @@ class v {
|
|
|
437
460
|
schemaErrorMap: this._def.errorMap,
|
|
438
461
|
parent: null,
|
|
439
462
|
data: e,
|
|
440
|
-
parsedType:
|
|
441
|
-
},
|
|
442
|
-
return
|
|
463
|
+
parsedType: M(e)
|
|
464
|
+
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (F(r) ? r : Promise.resolve(r));
|
|
465
|
+
return Ie(n, a);
|
|
443
466
|
}
|
|
444
467
|
refine(e, t) {
|
|
445
|
-
const
|
|
446
|
-
return this._refinement((
|
|
447
|
-
const i = e(
|
|
468
|
+
const n = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
|
|
469
|
+
return this._refinement((r, a) => {
|
|
470
|
+
const i = e(r), o = () => a.addIssue({
|
|
448
471
|
code: d.custom,
|
|
449
|
-
...r
|
|
472
|
+
...n(r)
|
|
450
473
|
});
|
|
451
474
|
return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
452
475
|
});
|
|
453
476
|
}
|
|
454
477
|
refinement(e, t) {
|
|
455
|
-
return this._refinement((
|
|
478
|
+
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof t == "function" ? t(n, r) : t), !1));
|
|
456
479
|
}
|
|
457
480
|
_refinement(e) {
|
|
458
|
-
return new
|
|
481
|
+
return new N({
|
|
459
482
|
schema: this,
|
|
460
483
|
typeName: p.ZodEffects,
|
|
461
484
|
effect: { type: "refinement", refinement: e }
|
|
@@ -465,28 +488,28 @@ class v {
|
|
|
465
488
|
return this._refinement(e);
|
|
466
489
|
}
|
|
467
490
|
optional() {
|
|
468
|
-
return
|
|
491
|
+
return O.create(this, this._def);
|
|
469
492
|
}
|
|
470
493
|
nullable() {
|
|
471
|
-
return
|
|
494
|
+
return D.create(this, this._def);
|
|
472
495
|
}
|
|
473
496
|
nullish() {
|
|
474
497
|
return this.nullable().optional();
|
|
475
498
|
}
|
|
476
499
|
array() {
|
|
477
|
-
return
|
|
500
|
+
return E.create(this, this._def);
|
|
478
501
|
}
|
|
479
502
|
promise() {
|
|
480
|
-
return
|
|
503
|
+
return H.create(this, this._def);
|
|
481
504
|
}
|
|
482
505
|
or(e) {
|
|
483
|
-
return
|
|
506
|
+
return ne.create([this, e], this._def);
|
|
484
507
|
}
|
|
485
508
|
and(e) {
|
|
486
509
|
return re.create(this, e, this._def);
|
|
487
510
|
}
|
|
488
511
|
transform(e) {
|
|
489
|
-
return new
|
|
512
|
+
return new N({
|
|
490
513
|
...g(this._def),
|
|
491
514
|
schema: this,
|
|
492
515
|
typeName: p.ZodEffects,
|
|
@@ -495,7 +518,7 @@ class v {
|
|
|
495
518
|
}
|
|
496
519
|
default(e) {
|
|
497
520
|
const t = typeof e == "function" ? e : () => e;
|
|
498
|
-
return new
|
|
521
|
+
return new ce({
|
|
499
522
|
...g(this._def),
|
|
500
523
|
innerType: this,
|
|
501
524
|
defaultValue: t,
|
|
@@ -503,7 +526,7 @@ class v {
|
|
|
503
526
|
});
|
|
504
527
|
}
|
|
505
528
|
brand() {
|
|
506
|
-
return new
|
|
529
|
+
return new Ee({
|
|
507
530
|
typeName: p.ZodBranded,
|
|
508
531
|
type: this,
|
|
509
532
|
...g(this._def)
|
|
@@ -511,7 +534,7 @@ class v {
|
|
|
511
534
|
}
|
|
512
535
|
catch(e) {
|
|
513
536
|
const t = typeof e == "function" ? e : () => e;
|
|
514
|
-
return new
|
|
537
|
+
return new ue({
|
|
515
538
|
...g(this._def),
|
|
516
539
|
innerType: this,
|
|
517
540
|
catchValue: t,
|
|
@@ -526,10 +549,10 @@ class v {
|
|
|
526
549
|
});
|
|
527
550
|
}
|
|
528
551
|
pipe(e) {
|
|
529
|
-
return
|
|
552
|
+
return fe.create(this, e);
|
|
530
553
|
}
|
|
531
554
|
readonly() {
|
|
532
|
-
return
|
|
555
|
+
return le.create(this);
|
|
533
556
|
}
|
|
534
557
|
isOptional() {
|
|
535
558
|
return this.safeParse(void 0).success;
|
|
@@ -538,25 +561,25 @@ class v {
|
|
|
538
561
|
return this.safeParse(null).success;
|
|
539
562
|
}
|
|
540
563
|
}
|
|
541
|
-
const
|
|
542
|
-
let
|
|
543
|
-
const
|
|
544
|
-
function
|
|
564
|
+
const tt = /^c[^\s-]{8,}$/i, st = /^[0-9a-z]+$/, nt = /^[0-9A-HJKMNP-TV-Z]{26}$/, rt = /^[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, at = /^[a-z0-9_-]{21}$/i, it = /^[-+]?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)?)??$/, ot = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, dt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
565
|
+
let we;
|
|
566
|
+
const ct = /^(?:(?: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])$/, ut = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, lt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Pe = "((\\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])))", ft = new RegExp(`^${Pe}$`);
|
|
567
|
+
function $e(s) {
|
|
545
568
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
546
569
|
return s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
547
570
|
}
|
|
548
|
-
function
|
|
549
|
-
return new RegExp(`^${
|
|
571
|
+
function ht(s) {
|
|
572
|
+
return new RegExp(`^${$e(s)}$`);
|
|
550
573
|
}
|
|
551
|
-
function
|
|
552
|
-
let e = `${
|
|
574
|
+
function Ve(s) {
|
|
575
|
+
let e = `${Pe}T${$e(s)}`;
|
|
553
576
|
const t = [];
|
|
554
577
|
return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
555
578
|
}
|
|
556
|
-
function
|
|
557
|
-
return !!((e === "v4" || !e) &&
|
|
579
|
+
function pt(s, e) {
|
|
580
|
+
return !!((e === "v4" || !e) && ct.test(s) || (e === "v6" || !e) && ut.test(s));
|
|
558
581
|
}
|
|
559
|
-
class
|
|
582
|
+
class C extends v {
|
|
560
583
|
_parse(e) {
|
|
561
584
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
562
585
|
const a = this._getOrReturnCtx(e);
|
|
@@ -566,149 +589,149 @@ class S extends v {
|
|
|
566
589
|
received: a.parsedType
|
|
567
590
|
}), m;
|
|
568
591
|
}
|
|
569
|
-
const
|
|
570
|
-
let
|
|
592
|
+
const n = new w();
|
|
593
|
+
let r;
|
|
571
594
|
for (const a of this._def.checks)
|
|
572
595
|
if (a.kind === "min")
|
|
573
|
-
e.data.length < a.value && (
|
|
596
|
+
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
574
597
|
code: d.too_small,
|
|
575
598
|
minimum: a.value,
|
|
576
599
|
type: "string",
|
|
577
600
|
inclusive: !0,
|
|
578
601
|
exact: !1,
|
|
579
602
|
message: a.message
|
|
580
|
-
}),
|
|
603
|
+
}), n.dirty());
|
|
581
604
|
else if (a.kind === "max")
|
|
582
|
-
e.data.length > a.value && (
|
|
605
|
+
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
583
606
|
code: d.too_big,
|
|
584
607
|
maximum: a.value,
|
|
585
608
|
type: "string",
|
|
586
609
|
inclusive: !0,
|
|
587
610
|
exact: !1,
|
|
588
611
|
message: a.message
|
|
589
|
-
}),
|
|
612
|
+
}), n.dirty());
|
|
590
613
|
else if (a.kind === "length") {
|
|
591
614
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
592
|
-
(i || o) && (
|
|
615
|
+
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
593
616
|
code: d.too_big,
|
|
594
617
|
maximum: a.value,
|
|
595
618
|
type: "string",
|
|
596
619
|
inclusive: !0,
|
|
597
620
|
exact: !0,
|
|
598
621
|
message: a.message
|
|
599
|
-
}) : o && l(
|
|
622
|
+
}) : o && l(r, {
|
|
600
623
|
code: d.too_small,
|
|
601
624
|
minimum: a.value,
|
|
602
625
|
type: "string",
|
|
603
626
|
inclusive: !0,
|
|
604
627
|
exact: !0,
|
|
605
628
|
message: a.message
|
|
606
|
-
}),
|
|
629
|
+
}), n.dirty());
|
|
607
630
|
} else if (a.kind === "email")
|
|
608
|
-
|
|
631
|
+
ot.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
609
632
|
validation: "email",
|
|
610
633
|
code: d.invalid_string,
|
|
611
634
|
message: a.message
|
|
612
|
-
}),
|
|
635
|
+
}), n.dirty());
|
|
613
636
|
else if (a.kind === "emoji")
|
|
614
|
-
|
|
637
|
+
we || (we = new RegExp(dt, "u")), we.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
615
638
|
validation: "emoji",
|
|
616
639
|
code: d.invalid_string,
|
|
617
640
|
message: a.message
|
|
618
|
-
}),
|
|
641
|
+
}), n.dirty());
|
|
619
642
|
else if (a.kind === "uuid")
|
|
620
|
-
|
|
643
|
+
rt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
621
644
|
validation: "uuid",
|
|
622
645
|
code: d.invalid_string,
|
|
623
646
|
message: a.message
|
|
624
|
-
}),
|
|
647
|
+
}), n.dirty());
|
|
625
648
|
else if (a.kind === "nanoid")
|
|
626
|
-
|
|
649
|
+
at.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
627
650
|
validation: "nanoid",
|
|
628
651
|
code: d.invalid_string,
|
|
629
652
|
message: a.message
|
|
630
|
-
}),
|
|
653
|
+
}), n.dirty());
|
|
631
654
|
else if (a.kind === "cuid")
|
|
632
|
-
|
|
655
|
+
tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
633
656
|
validation: "cuid",
|
|
634
657
|
code: d.invalid_string,
|
|
635
658
|
message: a.message
|
|
636
|
-
}),
|
|
659
|
+
}), n.dirty());
|
|
637
660
|
else if (a.kind === "cuid2")
|
|
638
|
-
|
|
661
|
+
st.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
639
662
|
validation: "cuid2",
|
|
640
663
|
code: d.invalid_string,
|
|
641
664
|
message: a.message
|
|
642
|
-
}),
|
|
665
|
+
}), n.dirty());
|
|
643
666
|
else if (a.kind === "ulid")
|
|
644
|
-
|
|
667
|
+
nt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
645
668
|
validation: "ulid",
|
|
646
669
|
code: d.invalid_string,
|
|
647
670
|
message: a.message
|
|
648
|
-
}),
|
|
671
|
+
}), n.dirty());
|
|
649
672
|
else if (a.kind === "url")
|
|
650
673
|
try {
|
|
651
674
|
new URL(e.data);
|
|
652
675
|
} catch {
|
|
653
|
-
|
|
676
|
+
r = this._getOrReturnCtx(e, r), l(r, {
|
|
654
677
|
validation: "url",
|
|
655
678
|
code: d.invalid_string,
|
|
656
679
|
message: a.message
|
|
657
|
-
}),
|
|
680
|
+
}), n.dirty();
|
|
658
681
|
}
|
|
659
682
|
else
|
|
660
|
-
a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (
|
|
683
|
+
a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
661
684
|
validation: "regex",
|
|
662
685
|
code: d.invalid_string,
|
|
663
686
|
message: a.message
|
|
664
|
-
}),
|
|
687
|
+
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
665
688
|
code: d.invalid_string,
|
|
666
689
|
validation: { includes: a.value, position: a.position },
|
|
667
690
|
message: a.message
|
|
668
|
-
}),
|
|
691
|
+
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
669
692
|
code: d.invalid_string,
|
|
670
693
|
validation: { startsWith: a.value },
|
|
671
694
|
message: a.message
|
|
672
|
-
}),
|
|
695
|
+
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
673
696
|
code: d.invalid_string,
|
|
674
697
|
validation: { endsWith: a.value },
|
|
675
698
|
message: a.message
|
|
676
|
-
}),
|
|
699
|
+
}), n.dirty()) : a.kind === "datetime" ? Ve(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
677
700
|
code: d.invalid_string,
|
|
678
701
|
validation: "datetime",
|
|
679
702
|
message: a.message
|
|
680
|
-
}),
|
|
703
|
+
}), n.dirty()) : a.kind === "date" ? ft.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
681
704
|
code: d.invalid_string,
|
|
682
705
|
validation: "date",
|
|
683
706
|
message: a.message
|
|
684
|
-
}),
|
|
707
|
+
}), n.dirty()) : a.kind === "time" ? ht(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
685
708
|
code: d.invalid_string,
|
|
686
709
|
validation: "time",
|
|
687
710
|
message: a.message
|
|
688
|
-
}),
|
|
711
|
+
}), n.dirty()) : a.kind === "duration" ? it.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
689
712
|
validation: "duration",
|
|
690
713
|
code: d.invalid_string,
|
|
691
714
|
message: a.message
|
|
692
|
-
}),
|
|
715
|
+
}), n.dirty()) : a.kind === "ip" ? pt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
693
716
|
validation: "ip",
|
|
694
717
|
code: d.invalid_string,
|
|
695
718
|
message: a.message
|
|
696
|
-
}),
|
|
719
|
+
}), n.dirty()) : a.kind === "base64" ? lt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
697
720
|
validation: "base64",
|
|
698
721
|
code: d.invalid_string,
|
|
699
722
|
message: a.message
|
|
700
|
-
}),
|
|
701
|
-
return { status:
|
|
723
|
+
}), n.dirty()) : _.assertNever(a);
|
|
724
|
+
return { status: n.value, value: e.data };
|
|
702
725
|
}
|
|
703
|
-
_regex(e, t,
|
|
704
|
-
return this.refinement((
|
|
726
|
+
_regex(e, t, n) {
|
|
727
|
+
return this.refinement((r) => e.test(r), {
|
|
705
728
|
validation: t,
|
|
706
729
|
code: d.invalid_string,
|
|
707
|
-
...h.errToObj(
|
|
730
|
+
...h.errToObj(n)
|
|
708
731
|
});
|
|
709
732
|
}
|
|
710
733
|
_addCheck(e) {
|
|
711
|
-
return new
|
|
734
|
+
return new C({
|
|
712
735
|
...this._def,
|
|
713
736
|
checks: [...this._def.checks, e]
|
|
714
737
|
});
|
|
@@ -744,7 +767,7 @@ class S extends v {
|
|
|
744
767
|
return this._addCheck({ kind: "ip", ...h.errToObj(e) });
|
|
745
768
|
}
|
|
746
769
|
datetime(e) {
|
|
747
|
-
var t,
|
|
770
|
+
var t, n;
|
|
748
771
|
return typeof e == "string" ? this._addCheck({
|
|
749
772
|
kind: "datetime",
|
|
750
773
|
precision: null,
|
|
@@ -755,7 +778,7 @@ class S extends v {
|
|
|
755
778
|
kind: "datetime",
|
|
756
779
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
757
780
|
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
758
|
-
local: (
|
|
781
|
+
local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
|
|
759
782
|
...h.errToObj(e == null ? void 0 : e.message)
|
|
760
783
|
});
|
|
761
784
|
}
|
|
@@ -834,19 +857,19 @@ class S extends v {
|
|
|
834
857
|
return this.min(1, h.errToObj(e));
|
|
835
858
|
}
|
|
836
859
|
trim() {
|
|
837
|
-
return new
|
|
860
|
+
return new C({
|
|
838
861
|
...this._def,
|
|
839
862
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
840
863
|
});
|
|
841
864
|
}
|
|
842
865
|
toLowerCase() {
|
|
843
|
-
return new
|
|
866
|
+
return new C({
|
|
844
867
|
...this._def,
|
|
845
868
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
846
869
|
});
|
|
847
870
|
}
|
|
848
871
|
toUpperCase() {
|
|
849
|
-
return new
|
|
872
|
+
return new C({
|
|
850
873
|
...this._def,
|
|
851
874
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
852
875
|
});
|
|
@@ -906,20 +929,20 @@ class S extends v {
|
|
|
906
929
|
return e;
|
|
907
930
|
}
|
|
908
931
|
}
|
|
909
|
-
|
|
932
|
+
C.create = (s) => {
|
|
910
933
|
var e;
|
|
911
|
-
return new
|
|
934
|
+
return new C({
|
|
912
935
|
checks: [],
|
|
913
936
|
typeName: p.ZodString,
|
|
914
937
|
coerce: (e = s == null ? void 0 : s.coerce) !== null && e !== void 0 ? e : !1,
|
|
915
938
|
...g(s)
|
|
916
939
|
});
|
|
917
940
|
};
|
|
918
|
-
function
|
|
919
|
-
const t = (s.toString().split(".")[1] || "").length,
|
|
920
|
-
return a % i / Math.pow(10,
|
|
941
|
+
function mt(s, e) {
|
|
942
|
+
const t = (s.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = t > n ? t : n, a = parseInt(s.toFixed(r).replace(".", "")), i = parseInt(e.toFixed(r).replace(".", ""));
|
|
943
|
+
return a % i / Math.pow(10, r);
|
|
921
944
|
}
|
|
922
|
-
class
|
|
945
|
+
class P extends v {
|
|
923
946
|
constructor() {
|
|
924
947
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
925
948
|
}
|
|
@@ -932,37 +955,37 @@ class M extends v {
|
|
|
932
955
|
received: a.parsedType
|
|
933
956
|
}), m;
|
|
934
957
|
}
|
|
935
|
-
let
|
|
936
|
-
const
|
|
958
|
+
let n;
|
|
959
|
+
const r = new w();
|
|
937
960
|
for (const a of this._def.checks)
|
|
938
|
-
a.kind === "int" ? _.isInteger(e.data) || (
|
|
961
|
+
a.kind === "int" ? _.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
939
962
|
code: d.invalid_type,
|
|
940
963
|
expected: "integer",
|
|
941
964
|
received: "float",
|
|
942
965
|
message: a.message
|
|
943
|
-
}),
|
|
966
|
+
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
944
967
|
code: d.too_small,
|
|
945
968
|
minimum: a.value,
|
|
946
969
|
type: "number",
|
|
947
970
|
inclusive: a.inclusive,
|
|
948
971
|
exact: !1,
|
|
949
972
|
message: a.message
|
|
950
|
-
}),
|
|
973
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
951
974
|
code: d.too_big,
|
|
952
975
|
maximum: a.value,
|
|
953
976
|
type: "number",
|
|
954
977
|
inclusive: a.inclusive,
|
|
955
978
|
exact: !1,
|
|
956
979
|
message: a.message
|
|
957
|
-
}),
|
|
980
|
+
}), r.dirty()) : a.kind === "multipleOf" ? mt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
958
981
|
code: d.not_multiple_of,
|
|
959
982
|
multipleOf: a.value,
|
|
960
983
|
message: a.message
|
|
961
|
-
}),
|
|
984
|
+
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
962
985
|
code: d.not_finite,
|
|
963
986
|
message: a.message
|
|
964
|
-
}),
|
|
965
|
-
return { status:
|
|
987
|
+
}), r.dirty()) : _.assertNever(a);
|
|
988
|
+
return { status: r.value, value: e.data };
|
|
966
989
|
}
|
|
967
990
|
gte(e, t) {
|
|
968
991
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -976,22 +999,22 @@ class M extends v {
|
|
|
976
999
|
lt(e, t) {
|
|
977
1000
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
978
1001
|
}
|
|
979
|
-
setLimit(e, t,
|
|
980
|
-
return new
|
|
1002
|
+
setLimit(e, t, n, r) {
|
|
1003
|
+
return new P({
|
|
981
1004
|
...this._def,
|
|
982
1005
|
checks: [
|
|
983
1006
|
...this._def.checks,
|
|
984
1007
|
{
|
|
985
1008
|
kind: e,
|
|
986
1009
|
value: t,
|
|
987
|
-
inclusive:
|
|
988
|
-
message: h.toString(
|
|
1010
|
+
inclusive: n,
|
|
1011
|
+
message: h.toString(r)
|
|
989
1012
|
}
|
|
990
1013
|
]
|
|
991
1014
|
});
|
|
992
1015
|
}
|
|
993
1016
|
_addCheck(e) {
|
|
994
|
-
return new
|
|
1017
|
+
return new P({
|
|
995
1018
|
...this._def,
|
|
996
1019
|
checks: [...this._def.checks, e]
|
|
997
1020
|
});
|
|
@@ -1077,21 +1100,21 @@ class M extends v {
|
|
|
1077
1100
|
}
|
|
1078
1101
|
get isFinite() {
|
|
1079
1102
|
let e = null, t = null;
|
|
1080
|
-
for (const
|
|
1081
|
-
if (
|
|
1103
|
+
for (const n of this._def.checks) {
|
|
1104
|
+
if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
|
|
1082
1105
|
return !0;
|
|
1083
|
-
|
|
1106
|
+
n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1084
1107
|
}
|
|
1085
1108
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1086
1109
|
}
|
|
1087
1110
|
}
|
|
1088
|
-
|
|
1111
|
+
P.create = (s) => new P({
|
|
1089
1112
|
checks: [],
|
|
1090
1113
|
typeName: p.ZodNumber,
|
|
1091
1114
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1092
1115
|
...g(s)
|
|
1093
1116
|
});
|
|
1094
|
-
class
|
|
1117
|
+
class $ extends v {
|
|
1095
1118
|
constructor() {
|
|
1096
1119
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1097
1120
|
}
|
|
@@ -1104,27 +1127,27 @@ class P extends v {
|
|
|
1104
1127
|
received: a.parsedType
|
|
1105
1128
|
}), m;
|
|
1106
1129
|
}
|
|
1107
|
-
let
|
|
1108
|
-
const
|
|
1130
|
+
let n;
|
|
1131
|
+
const r = new w();
|
|
1109
1132
|
for (const a of this._def.checks)
|
|
1110
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1133
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1111
1134
|
code: d.too_small,
|
|
1112
1135
|
type: "bigint",
|
|
1113
1136
|
minimum: a.value,
|
|
1114
1137
|
inclusive: a.inclusive,
|
|
1115
1138
|
message: a.message
|
|
1116
|
-
}),
|
|
1139
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1117
1140
|
code: d.too_big,
|
|
1118
1141
|
type: "bigint",
|
|
1119
1142
|
maximum: a.value,
|
|
1120
1143
|
inclusive: a.inclusive,
|
|
1121
1144
|
message: a.message
|
|
1122
|
-
}),
|
|
1145
|
+
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1123
1146
|
code: d.not_multiple_of,
|
|
1124
1147
|
multipleOf: a.value,
|
|
1125
1148
|
message: a.message
|
|
1126
|
-
}),
|
|
1127
|
-
return { status:
|
|
1149
|
+
}), r.dirty()) : _.assertNever(a);
|
|
1150
|
+
return { status: r.value, value: e.data };
|
|
1128
1151
|
}
|
|
1129
1152
|
gte(e, t) {
|
|
1130
1153
|
return this.setLimit("min", e, !0, h.toString(t));
|
|
@@ -1138,22 +1161,22 @@ class P extends v {
|
|
|
1138
1161
|
lt(e, t) {
|
|
1139
1162
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1140
1163
|
}
|
|
1141
|
-
setLimit(e, t,
|
|
1142
|
-
return new
|
|
1164
|
+
setLimit(e, t, n, r) {
|
|
1165
|
+
return new $({
|
|
1143
1166
|
...this._def,
|
|
1144
1167
|
checks: [
|
|
1145
1168
|
...this._def.checks,
|
|
1146
1169
|
{
|
|
1147
1170
|
kind: e,
|
|
1148
1171
|
value: t,
|
|
1149
|
-
inclusive:
|
|
1150
|
-
message: h.toString(
|
|
1172
|
+
inclusive: n,
|
|
1173
|
+
message: h.toString(r)
|
|
1151
1174
|
}
|
|
1152
1175
|
]
|
|
1153
1176
|
});
|
|
1154
1177
|
}
|
|
1155
1178
|
_addCheck(e) {
|
|
1156
|
-
return new
|
|
1179
|
+
return new $({
|
|
1157
1180
|
...this._def,
|
|
1158
1181
|
checks: [...this._def.checks, e]
|
|
1159
1182
|
});
|
|
@@ -1210,34 +1233,34 @@ class P extends v {
|
|
|
1210
1233
|
return e;
|
|
1211
1234
|
}
|
|
1212
1235
|
}
|
|
1213
|
-
|
|
1236
|
+
$.create = (s) => {
|
|
1214
1237
|
var e;
|
|
1215
|
-
return new
|
|
1238
|
+
return new $({
|
|
1216
1239
|
checks: [],
|
|
1217
1240
|
typeName: p.ZodBigInt,
|
|
1218
1241
|
coerce: (e = s == null ? void 0 : s.coerce) !== null && e !== void 0 ? e : !1,
|
|
1219
1242
|
...g(s)
|
|
1220
1243
|
});
|
|
1221
1244
|
};
|
|
1222
|
-
class
|
|
1245
|
+
class ee extends v {
|
|
1223
1246
|
_parse(e) {
|
|
1224
1247
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1225
|
-
const
|
|
1226
|
-
return l(
|
|
1248
|
+
const n = this._getOrReturnCtx(e);
|
|
1249
|
+
return l(n, {
|
|
1227
1250
|
code: d.invalid_type,
|
|
1228
1251
|
expected: f.boolean,
|
|
1229
|
-
received:
|
|
1252
|
+
received: n.parsedType
|
|
1230
1253
|
}), m;
|
|
1231
1254
|
}
|
|
1232
|
-
return
|
|
1255
|
+
return T(e.data);
|
|
1233
1256
|
}
|
|
1234
1257
|
}
|
|
1235
|
-
|
|
1258
|
+
ee.create = (s) => new ee({
|
|
1236
1259
|
typeName: p.ZodBoolean,
|
|
1237
1260
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1238
1261
|
...g(s)
|
|
1239
1262
|
});
|
|
1240
|
-
class
|
|
1263
|
+
class U extends v {
|
|
1241
1264
|
_parse(e) {
|
|
1242
1265
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1243
1266
|
const a = this._getOrReturnCtx(e);
|
|
@@ -1253,31 +1276,31 @@ class D extends v {
|
|
|
1253
1276
|
code: d.invalid_date
|
|
1254
1277
|
}), m;
|
|
1255
1278
|
}
|
|
1256
|
-
const
|
|
1257
|
-
let
|
|
1279
|
+
const n = new w();
|
|
1280
|
+
let r;
|
|
1258
1281
|
for (const a of this._def.checks)
|
|
1259
|
-
a.kind === "min" ? e.data.getTime() < a.value && (
|
|
1282
|
+
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1260
1283
|
code: d.too_small,
|
|
1261
1284
|
message: a.message,
|
|
1262
1285
|
inclusive: !0,
|
|
1263
1286
|
exact: !1,
|
|
1264
1287
|
minimum: a.value,
|
|
1265
1288
|
type: "date"
|
|
1266
|
-
}),
|
|
1289
|
+
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1267
1290
|
code: d.too_big,
|
|
1268
1291
|
message: a.message,
|
|
1269
1292
|
inclusive: !0,
|
|
1270
1293
|
exact: !1,
|
|
1271
1294
|
maximum: a.value,
|
|
1272
1295
|
type: "date"
|
|
1273
|
-
}),
|
|
1296
|
+
}), n.dirty()) : _.assertNever(a);
|
|
1274
1297
|
return {
|
|
1275
|
-
status:
|
|
1298
|
+
status: n.value,
|
|
1276
1299
|
value: new Date(e.data.getTime())
|
|
1277
1300
|
};
|
|
1278
1301
|
}
|
|
1279
1302
|
_addCheck(e) {
|
|
1280
|
-
return new
|
|
1303
|
+
return new U({
|
|
1281
1304
|
...this._def,
|
|
1282
1305
|
checks: [...this._def.checks, e]
|
|
1283
1306
|
});
|
|
@@ -1309,72 +1332,72 @@ class D extends v {
|
|
|
1309
1332
|
return e != null ? new Date(e) : null;
|
|
1310
1333
|
}
|
|
1311
1334
|
}
|
|
1312
|
-
|
|
1335
|
+
U.create = (s) => new U({
|
|
1313
1336
|
checks: [],
|
|
1314
1337
|
coerce: (s == null ? void 0 : s.coerce) || !1,
|
|
1315
1338
|
typeName: p.ZodDate,
|
|
1316
1339
|
...g(s)
|
|
1317
1340
|
});
|
|
1318
|
-
class
|
|
1341
|
+
class ge extends v {
|
|
1319
1342
|
_parse(e) {
|
|
1320
1343
|
if (this._getType(e) !== f.symbol) {
|
|
1321
|
-
const
|
|
1322
|
-
return l(
|
|
1344
|
+
const n = this._getOrReturnCtx(e);
|
|
1345
|
+
return l(n, {
|
|
1323
1346
|
code: d.invalid_type,
|
|
1324
1347
|
expected: f.symbol,
|
|
1325
|
-
received:
|
|
1348
|
+
received: n.parsedType
|
|
1326
1349
|
}), m;
|
|
1327
1350
|
}
|
|
1328
|
-
return
|
|
1351
|
+
return T(e.data);
|
|
1329
1352
|
}
|
|
1330
1353
|
}
|
|
1331
|
-
|
|
1354
|
+
ge.create = (s) => new ge({
|
|
1332
1355
|
typeName: p.ZodSymbol,
|
|
1333
1356
|
...g(s)
|
|
1334
1357
|
});
|
|
1335
|
-
class
|
|
1358
|
+
class te extends v {
|
|
1336
1359
|
_parse(e) {
|
|
1337
1360
|
if (this._getType(e) !== f.undefined) {
|
|
1338
|
-
const
|
|
1339
|
-
return l(
|
|
1361
|
+
const n = this._getOrReturnCtx(e);
|
|
1362
|
+
return l(n, {
|
|
1340
1363
|
code: d.invalid_type,
|
|
1341
1364
|
expected: f.undefined,
|
|
1342
|
-
received:
|
|
1365
|
+
received: n.parsedType
|
|
1343
1366
|
}), m;
|
|
1344
1367
|
}
|
|
1345
|
-
return
|
|
1368
|
+
return T(e.data);
|
|
1346
1369
|
}
|
|
1347
1370
|
}
|
|
1348
|
-
|
|
1371
|
+
te.create = (s) => new te({
|
|
1349
1372
|
typeName: p.ZodUndefined,
|
|
1350
1373
|
...g(s)
|
|
1351
1374
|
});
|
|
1352
|
-
class
|
|
1375
|
+
class se extends v {
|
|
1353
1376
|
_parse(e) {
|
|
1354
1377
|
if (this._getType(e) !== f.null) {
|
|
1355
|
-
const
|
|
1356
|
-
return l(
|
|
1378
|
+
const n = this._getOrReturnCtx(e);
|
|
1379
|
+
return l(n, {
|
|
1357
1380
|
code: d.invalid_type,
|
|
1358
1381
|
expected: f.null,
|
|
1359
|
-
received:
|
|
1382
|
+
received: n.parsedType
|
|
1360
1383
|
}), m;
|
|
1361
1384
|
}
|
|
1362
|
-
return
|
|
1385
|
+
return T(e.data);
|
|
1363
1386
|
}
|
|
1364
1387
|
}
|
|
1365
|
-
|
|
1388
|
+
se.create = (s) => new se({
|
|
1366
1389
|
typeName: p.ZodNull,
|
|
1367
1390
|
...g(s)
|
|
1368
1391
|
});
|
|
1369
|
-
class
|
|
1392
|
+
class G extends v {
|
|
1370
1393
|
constructor() {
|
|
1371
1394
|
super(...arguments), this._any = !0;
|
|
1372
1395
|
}
|
|
1373
1396
|
_parse(e) {
|
|
1374
|
-
return
|
|
1397
|
+
return T(e.data);
|
|
1375
1398
|
}
|
|
1376
1399
|
}
|
|
1377
|
-
|
|
1400
|
+
G.create = (s) => new G({
|
|
1378
1401
|
typeName: p.ZodAny,
|
|
1379
1402
|
...g(s)
|
|
1380
1403
|
});
|
|
@@ -1383,14 +1406,14 @@ class L extends v {
|
|
|
1383
1406
|
super(...arguments), this._unknown = !0;
|
|
1384
1407
|
}
|
|
1385
1408
|
_parse(e) {
|
|
1386
|
-
return
|
|
1409
|
+
return T(e.data);
|
|
1387
1410
|
}
|
|
1388
1411
|
}
|
|
1389
1412
|
L.create = (s) => new L({
|
|
1390
1413
|
typeName: p.ZodUnknown,
|
|
1391
1414
|
...g(s)
|
|
1392
1415
|
});
|
|
1393
|
-
class
|
|
1416
|
+
class A extends v {
|
|
1394
1417
|
_parse(e) {
|
|
1395
1418
|
const t = this._getOrReturnCtx(e);
|
|
1396
1419
|
return l(t, {
|
|
@@ -1400,84 +1423,84 @@ class j extends v {
|
|
|
1400
1423
|
}), m;
|
|
1401
1424
|
}
|
|
1402
1425
|
}
|
|
1403
|
-
|
|
1426
|
+
A.create = (s) => new A({
|
|
1404
1427
|
typeName: p.ZodNever,
|
|
1405
1428
|
...g(s)
|
|
1406
1429
|
});
|
|
1407
|
-
class
|
|
1430
|
+
class ve extends v {
|
|
1408
1431
|
_parse(e) {
|
|
1409
1432
|
if (this._getType(e) !== f.undefined) {
|
|
1410
|
-
const
|
|
1411
|
-
return l(
|
|
1433
|
+
const n = this._getOrReturnCtx(e);
|
|
1434
|
+
return l(n, {
|
|
1412
1435
|
code: d.invalid_type,
|
|
1413
1436
|
expected: f.void,
|
|
1414
|
-
received:
|
|
1437
|
+
received: n.parsedType
|
|
1415
1438
|
}), m;
|
|
1416
1439
|
}
|
|
1417
|
-
return
|
|
1440
|
+
return T(e.data);
|
|
1418
1441
|
}
|
|
1419
1442
|
}
|
|
1420
|
-
|
|
1443
|
+
ve.create = (s) => new ve({
|
|
1421
1444
|
typeName: p.ZodVoid,
|
|
1422
1445
|
...g(s)
|
|
1423
1446
|
});
|
|
1424
|
-
class
|
|
1447
|
+
class E extends v {
|
|
1425
1448
|
_parse(e) {
|
|
1426
|
-
const { ctx: t, status:
|
|
1449
|
+
const { ctx: t, status: n } = this._processInputParams(e), r = this._def;
|
|
1427
1450
|
if (t.parsedType !== f.array)
|
|
1428
1451
|
return l(t, {
|
|
1429
1452
|
code: d.invalid_type,
|
|
1430
1453
|
expected: f.array,
|
|
1431
1454
|
received: t.parsedType
|
|
1432
1455
|
}), m;
|
|
1433
|
-
if (
|
|
1434
|
-
const i = t.data.length >
|
|
1456
|
+
if (r.exactLength !== null) {
|
|
1457
|
+
const i = t.data.length > r.exactLength.value, o = t.data.length < r.exactLength.value;
|
|
1435
1458
|
(i || o) && (l(t, {
|
|
1436
1459
|
code: i ? d.too_big : d.too_small,
|
|
1437
|
-
minimum: o ?
|
|
1438
|
-
maximum: i ?
|
|
1460
|
+
minimum: o ? r.exactLength.value : void 0,
|
|
1461
|
+
maximum: i ? r.exactLength.value : void 0,
|
|
1439
1462
|
type: "array",
|
|
1440
1463
|
inclusive: !0,
|
|
1441
1464
|
exact: !0,
|
|
1442
|
-
message:
|
|
1443
|
-
}),
|
|
1465
|
+
message: r.exactLength.message
|
|
1466
|
+
}), n.dirty());
|
|
1444
1467
|
}
|
|
1445
|
-
if (
|
|
1468
|
+
if (r.minLength !== null && t.data.length < r.minLength.value && (l(t, {
|
|
1446
1469
|
code: d.too_small,
|
|
1447
|
-
minimum:
|
|
1470
|
+
minimum: r.minLength.value,
|
|
1448
1471
|
type: "array",
|
|
1449
1472
|
inclusive: !0,
|
|
1450
1473
|
exact: !1,
|
|
1451
|
-
message:
|
|
1452
|
-
}),
|
|
1474
|
+
message: r.minLength.message
|
|
1475
|
+
}), n.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (l(t, {
|
|
1453
1476
|
code: d.too_big,
|
|
1454
|
-
maximum:
|
|
1477
|
+
maximum: r.maxLength.value,
|
|
1455
1478
|
type: "array",
|
|
1456
1479
|
inclusive: !0,
|
|
1457
1480
|
exact: !1,
|
|
1458
|
-
message:
|
|
1459
|
-
}),
|
|
1460
|
-
return Promise.all([...t.data].map((i, o) =>
|
|
1461
|
-
const a = [...t.data].map((i, o) =>
|
|
1462
|
-
return
|
|
1481
|
+
message: r.maxLength.message
|
|
1482
|
+
}), n.dirty()), t.common.async)
|
|
1483
|
+
return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new R(t, i, t.path, o)))).then((i) => w.mergeArray(n, i));
|
|
1484
|
+
const a = [...t.data].map((i, o) => r.type._parseSync(new R(t, i, t.path, o)));
|
|
1485
|
+
return w.mergeArray(n, a);
|
|
1463
1486
|
}
|
|
1464
1487
|
get element() {
|
|
1465
1488
|
return this._def.type;
|
|
1466
1489
|
}
|
|
1467
1490
|
min(e, t) {
|
|
1468
|
-
return new
|
|
1491
|
+
return new E({
|
|
1469
1492
|
...this._def,
|
|
1470
1493
|
minLength: { value: e, message: h.toString(t) }
|
|
1471
1494
|
});
|
|
1472
1495
|
}
|
|
1473
1496
|
max(e, t) {
|
|
1474
|
-
return new
|
|
1497
|
+
return new E({
|
|
1475
1498
|
...this._def,
|
|
1476
1499
|
maxLength: { value: e, message: h.toString(t) }
|
|
1477
1500
|
});
|
|
1478
1501
|
}
|
|
1479
1502
|
length(e, t) {
|
|
1480
|
-
return new
|
|
1503
|
+
return new E({
|
|
1481
1504
|
...this._def,
|
|
1482
1505
|
exactLength: { value: e, message: h.toString(t) }
|
|
1483
1506
|
});
|
|
@@ -1486,7 +1509,7 @@ class C extends v {
|
|
|
1486
1509
|
return this.min(1, e);
|
|
1487
1510
|
}
|
|
1488
1511
|
}
|
|
1489
|
-
|
|
1512
|
+
E.create = (s, e) => new E({
|
|
1490
1513
|
type: s,
|
|
1491
1514
|
minLength: null,
|
|
1492
1515
|
maxLength: null,
|
|
@@ -1494,22 +1517,22 @@ C.create = (s, e) => new C({
|
|
|
1494
1517
|
typeName: p.ZodArray,
|
|
1495
1518
|
...g(e)
|
|
1496
1519
|
});
|
|
1497
|
-
function
|
|
1520
|
+
function B(s) {
|
|
1498
1521
|
if (s instanceof x) {
|
|
1499
1522
|
const e = {};
|
|
1500
1523
|
for (const t in s.shape) {
|
|
1501
|
-
const
|
|
1502
|
-
e[t] =
|
|
1524
|
+
const n = s.shape[t];
|
|
1525
|
+
e[t] = O.create(B(n));
|
|
1503
1526
|
}
|
|
1504
1527
|
return new x({
|
|
1505
1528
|
...s._def,
|
|
1506
1529
|
shape: () => e
|
|
1507
1530
|
});
|
|
1508
1531
|
} else
|
|
1509
|
-
return s instanceof
|
|
1532
|
+
return s instanceof E ? new E({
|
|
1510
1533
|
...s._def,
|
|
1511
|
-
type:
|
|
1512
|
-
}) : s instanceof
|
|
1534
|
+
type: B(s.element)
|
|
1535
|
+
}) : s instanceof O ? O.create(B(s.unwrap())) : s instanceof D ? D.create(B(s.unwrap())) : s instanceof I ? I.create(s.items.map((e) => B(e))) : s;
|
|
1513
1536
|
}
|
|
1514
1537
|
class x extends v {
|
|
1515
1538
|
constructor() {
|
|
@@ -1530,60 +1553,60 @@ class x extends v {
|
|
|
1530
1553
|
received: c.parsedType
|
|
1531
1554
|
}), m;
|
|
1532
1555
|
}
|
|
1533
|
-
const { status:
|
|
1534
|
-
if (!(this._def.catchall instanceof
|
|
1535
|
-
for (const c in
|
|
1556
|
+
const { status: n, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1557
|
+
if (!(this._def.catchall instanceof A && this._def.unknownKeys === "strip"))
|
|
1558
|
+
for (const c in r.data)
|
|
1536
1559
|
i.includes(c) || o.push(c);
|
|
1537
1560
|
const u = [];
|
|
1538
1561
|
for (const c of i) {
|
|
1539
|
-
const y = a[c], Z =
|
|
1562
|
+
const y = a[c], Z = r.data[c];
|
|
1540
1563
|
u.push({
|
|
1541
1564
|
key: { status: "valid", value: c },
|
|
1542
|
-
value: y._parse(new
|
|
1543
|
-
alwaysSet: c in
|
|
1565
|
+
value: y._parse(new R(r, Z, r.path, c)),
|
|
1566
|
+
alwaysSet: c in r.data
|
|
1544
1567
|
});
|
|
1545
1568
|
}
|
|
1546
|
-
if (this._def.catchall instanceof
|
|
1569
|
+
if (this._def.catchall instanceof A) {
|
|
1547
1570
|
const c = this._def.unknownKeys;
|
|
1548
1571
|
if (c === "passthrough")
|
|
1549
1572
|
for (const y of o)
|
|
1550
1573
|
u.push({
|
|
1551
1574
|
key: { status: "valid", value: y },
|
|
1552
|
-
value: { status: "valid", value:
|
|
1575
|
+
value: { status: "valid", value: r.data[y] }
|
|
1553
1576
|
});
|
|
1554
1577
|
else if (c === "strict")
|
|
1555
|
-
o.length > 0 && (l(
|
|
1578
|
+
o.length > 0 && (l(r, {
|
|
1556
1579
|
code: d.unrecognized_keys,
|
|
1557
1580
|
keys: o
|
|
1558
|
-
}),
|
|
1581
|
+
}), n.dirty());
|
|
1559
1582
|
else if (c !== "strip")
|
|
1560
1583
|
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1561
1584
|
} else {
|
|
1562
1585
|
const c = this._def.catchall;
|
|
1563
1586
|
for (const y of o) {
|
|
1564
|
-
const Z =
|
|
1587
|
+
const Z = r.data[y];
|
|
1565
1588
|
u.push({
|
|
1566
1589
|
key: { status: "valid", value: y },
|
|
1567
1590
|
value: c._parse(
|
|
1568
|
-
new
|
|
1591
|
+
new R(r, Z, r.path, y)
|
|
1569
1592
|
//, ctx.child(key), value, getParsedType(value)
|
|
1570
1593
|
),
|
|
1571
|
-
alwaysSet: y in
|
|
1594
|
+
alwaysSet: y in r.data
|
|
1572
1595
|
});
|
|
1573
1596
|
}
|
|
1574
1597
|
}
|
|
1575
|
-
return
|
|
1598
|
+
return r.common.async ? Promise.resolve().then(async () => {
|
|
1576
1599
|
const c = [];
|
|
1577
1600
|
for (const y of u) {
|
|
1578
|
-
const Z = await y.key,
|
|
1601
|
+
const Z = await y.key, Oe = await y.value;
|
|
1579
1602
|
c.push({
|
|
1580
1603
|
key: Z,
|
|
1581
|
-
value:
|
|
1604
|
+
value: Oe,
|
|
1582
1605
|
alwaysSet: y.alwaysSet
|
|
1583
1606
|
});
|
|
1584
1607
|
}
|
|
1585
1608
|
return c;
|
|
1586
|
-
}).then((c) =>
|
|
1609
|
+
}).then((c) => w.mergeObjectSync(n, c)) : w.mergeObjectSync(n, u);
|
|
1587
1610
|
}
|
|
1588
1611
|
get shape() {
|
|
1589
1612
|
return this._def.shape();
|
|
@@ -1593,9 +1616,9 @@ class x extends v {
|
|
|
1593
1616
|
...this._def,
|
|
1594
1617
|
unknownKeys: "strict",
|
|
1595
1618
|
...e !== void 0 ? {
|
|
1596
|
-
errorMap: (t,
|
|
1597
|
-
var
|
|
1598
|
-
const u = (i = (a = (
|
|
1619
|
+
errorMap: (t, n) => {
|
|
1620
|
+
var r, a, i, o;
|
|
1621
|
+
const u = (i = (a = (r = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(r, t, n).message) !== null && i !== void 0 ? i : n.defaultError;
|
|
1599
1622
|
return t.code === "unrecognized_keys" ? {
|
|
1600
1623
|
message: (o = h.errToObj(e).message) !== null && o !== void 0 ? o : u
|
|
1601
1624
|
} : {
|
|
@@ -1726,8 +1749,8 @@ class x extends v {
|
|
|
1726
1749
|
}
|
|
1727
1750
|
pick(e) {
|
|
1728
1751
|
const t = {};
|
|
1729
|
-
return _.objectKeys(e).forEach((
|
|
1730
|
-
e[
|
|
1752
|
+
return _.objectKeys(e).forEach((n) => {
|
|
1753
|
+
e[n] && this.shape[n] && (t[n] = this.shape[n]);
|
|
1731
1754
|
}), new x({
|
|
1732
1755
|
...this._def,
|
|
1733
1756
|
shape: () => t
|
|
@@ -1735,8 +1758,8 @@ class x extends v {
|
|
|
1735
1758
|
}
|
|
1736
1759
|
omit(e) {
|
|
1737
1760
|
const t = {};
|
|
1738
|
-
return _.objectKeys(this.shape).forEach((
|
|
1739
|
-
e[
|
|
1761
|
+
return _.objectKeys(this.shape).forEach((n) => {
|
|
1762
|
+
e[n] || (t[n] = this.shape[n]);
|
|
1740
1763
|
}), new x({
|
|
1741
1764
|
...this._def,
|
|
1742
1765
|
shape: () => t
|
|
@@ -1746,13 +1769,13 @@ class x extends v {
|
|
|
1746
1769
|
* @deprecated
|
|
1747
1770
|
*/
|
|
1748
1771
|
deepPartial() {
|
|
1749
|
-
return
|
|
1772
|
+
return B(this);
|
|
1750
1773
|
}
|
|
1751
1774
|
partial(e) {
|
|
1752
1775
|
const t = {};
|
|
1753
|
-
return _.objectKeys(this.shape).forEach((
|
|
1754
|
-
const
|
|
1755
|
-
e && !e[
|
|
1776
|
+
return _.objectKeys(this.shape).forEach((n) => {
|
|
1777
|
+
const r = this.shape[n];
|
|
1778
|
+
e && !e[n] ? t[n] = r : t[n] = r.optional();
|
|
1756
1779
|
}), new x({
|
|
1757
1780
|
...this._def,
|
|
1758
1781
|
shape: () => t
|
|
@@ -1760,14 +1783,14 @@ class x extends v {
|
|
|
1760
1783
|
}
|
|
1761
1784
|
required(e) {
|
|
1762
1785
|
const t = {};
|
|
1763
|
-
return _.objectKeys(this.shape).forEach((
|
|
1764
|
-
if (e && !e[
|
|
1765
|
-
t[
|
|
1786
|
+
return _.objectKeys(this.shape).forEach((n) => {
|
|
1787
|
+
if (e && !e[n])
|
|
1788
|
+
t[n] = this.shape[n];
|
|
1766
1789
|
else {
|
|
1767
|
-
let a = this.shape[
|
|
1768
|
-
for (; a instanceof
|
|
1790
|
+
let a = this.shape[n];
|
|
1791
|
+
for (; a instanceof O; )
|
|
1769
1792
|
a = a._def.innerType;
|
|
1770
|
-
t[
|
|
1793
|
+
t[n] = a;
|
|
1771
1794
|
}
|
|
1772
1795
|
}), new x({
|
|
1773
1796
|
...this._def,
|
|
@@ -1775,48 +1798,48 @@ class x extends v {
|
|
|
1775
1798
|
});
|
|
1776
1799
|
}
|
|
1777
1800
|
keyof() {
|
|
1778
|
-
return
|
|
1801
|
+
return De(_.objectKeys(this.shape));
|
|
1779
1802
|
}
|
|
1780
1803
|
}
|
|
1781
1804
|
x.create = (s, e) => new x({
|
|
1782
1805
|
shape: () => s,
|
|
1783
1806
|
unknownKeys: "strip",
|
|
1784
|
-
catchall:
|
|
1807
|
+
catchall: A.create(),
|
|
1785
1808
|
typeName: p.ZodObject,
|
|
1786
1809
|
...g(e)
|
|
1787
1810
|
});
|
|
1788
1811
|
x.strictCreate = (s, e) => new x({
|
|
1789
1812
|
shape: () => s,
|
|
1790
1813
|
unknownKeys: "strict",
|
|
1791
|
-
catchall:
|
|
1814
|
+
catchall: A.create(),
|
|
1792
1815
|
typeName: p.ZodObject,
|
|
1793
1816
|
...g(e)
|
|
1794
1817
|
});
|
|
1795
1818
|
x.lazycreate = (s, e) => new x({
|
|
1796
1819
|
shape: s,
|
|
1797
1820
|
unknownKeys: "strip",
|
|
1798
|
-
catchall:
|
|
1821
|
+
catchall: A.create(),
|
|
1799
1822
|
typeName: p.ZodObject,
|
|
1800
1823
|
...g(e)
|
|
1801
1824
|
});
|
|
1802
|
-
class
|
|
1825
|
+
class ne extends v {
|
|
1803
1826
|
_parse(e) {
|
|
1804
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1805
|
-
function
|
|
1827
|
+
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
1828
|
+
function r(a) {
|
|
1806
1829
|
for (const o of a)
|
|
1807
1830
|
if (o.result.status === "valid")
|
|
1808
1831
|
return o.result;
|
|
1809
1832
|
for (const o of a)
|
|
1810
1833
|
if (o.result.status === "dirty")
|
|
1811
1834
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1812
|
-
const i = a.map((o) => new
|
|
1835
|
+
const i = a.map((o) => new S(o.ctx.common.issues));
|
|
1813
1836
|
return l(t, {
|
|
1814
1837
|
code: d.invalid_union,
|
|
1815
1838
|
unionErrors: i
|
|
1816
1839
|
}), m;
|
|
1817
1840
|
}
|
|
1818
1841
|
if (t.common.async)
|
|
1819
|
-
return Promise.all(
|
|
1842
|
+
return Promise.all(n.map(async (a) => {
|
|
1820
1843
|
const i = {
|
|
1821
1844
|
...t,
|
|
1822
1845
|
common: {
|
|
@@ -1833,11 +1856,11 @@ class se extends v {
|
|
|
1833
1856
|
}),
|
|
1834
1857
|
ctx: i
|
|
1835
1858
|
};
|
|
1836
|
-
})).then(
|
|
1859
|
+
})).then(r);
|
|
1837
1860
|
{
|
|
1838
1861
|
let a;
|
|
1839
1862
|
const i = [];
|
|
1840
|
-
for (const u of
|
|
1863
|
+
for (const u of n) {
|
|
1841
1864
|
const c = {
|
|
1842
1865
|
...t,
|
|
1843
1866
|
common: {
|
|
@@ -1856,7 +1879,7 @@ class se extends v {
|
|
|
1856
1879
|
}
|
|
1857
1880
|
if (a)
|
|
1858
1881
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1859
|
-
const o = i.map((u) => new
|
|
1882
|
+
const o = i.map((u) => new S(u));
|
|
1860
1883
|
return l(t, {
|
|
1861
1884
|
code: d.invalid_union,
|
|
1862
1885
|
unionErrors: o
|
|
@@ -1867,13 +1890,13 @@ class se extends v {
|
|
|
1867
1890
|
return this._def.options;
|
|
1868
1891
|
}
|
|
1869
1892
|
}
|
|
1870
|
-
|
|
1893
|
+
ne.create = (s, e) => new ne({
|
|
1871
1894
|
options: s,
|
|
1872
1895
|
typeName: p.ZodUnion,
|
|
1873
1896
|
...g(e)
|
|
1874
1897
|
});
|
|
1875
|
-
const
|
|
1876
|
-
class
|
|
1898
|
+
const j = (s) => s instanceof ie ? j(s.schema) : s instanceof N ? j(s.innerType()) : s instanceof oe ? [s.value] : s instanceof V ? s.options : s instanceof de ? _.objectValues(s.enum) : s instanceof ce ? j(s._def.innerType) : s instanceof te ? [void 0] : s instanceof se ? [null] : s instanceof O ? [void 0, ...j(s.unwrap())] : s instanceof D ? [null, ...j(s.unwrap())] : s instanceof Ee || s instanceof le ? j(s.unwrap()) : s instanceof ue ? j(s._def.innerType) : [];
|
|
1899
|
+
class ke extends v {
|
|
1877
1900
|
_parse(e) {
|
|
1878
1901
|
const { ctx: t } = this._processInputParams(e);
|
|
1879
1902
|
if (t.parsedType !== f.object)
|
|
@@ -1882,7 +1905,7 @@ class _e extends v {
|
|
|
1882
1905
|
expected: f.object,
|
|
1883
1906
|
received: t.parsedType
|
|
1884
1907
|
}), m;
|
|
1885
|
-
const
|
|
1908
|
+
const n = this.discriminator, r = t.data[n], a = this.optionsMap.get(r);
|
|
1886
1909
|
return a ? t.common.async ? a._parseAsync({
|
|
1887
1910
|
data: t.data,
|
|
1888
1911
|
path: t.path,
|
|
@@ -1894,7 +1917,7 @@ class _e extends v {
|
|
|
1894
1917
|
}) : (l(t, {
|
|
1895
1918
|
code: d.invalid_union_discriminator,
|
|
1896
1919
|
options: Array.from(this.optionsMap.keys()),
|
|
1897
|
-
path: [
|
|
1920
|
+
path: [n]
|
|
1898
1921
|
}), m);
|
|
1899
1922
|
}
|
|
1900
1923
|
get discriminator() {
|
|
@@ -1914,83 +1937,83 @@ class _e extends v {
|
|
|
1914
1937
|
* @param types an array of object schemas
|
|
1915
1938
|
* @param params
|
|
1916
1939
|
*/
|
|
1917
|
-
static create(e, t,
|
|
1918
|
-
const
|
|
1940
|
+
static create(e, t, n) {
|
|
1941
|
+
const r = /* @__PURE__ */ new Map();
|
|
1919
1942
|
for (const a of t) {
|
|
1920
|
-
const i =
|
|
1943
|
+
const i = j(a.shape[e]);
|
|
1921
1944
|
if (!i.length)
|
|
1922
1945
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1923
1946
|
for (const o of i) {
|
|
1924
|
-
if (
|
|
1947
|
+
if (r.has(o))
|
|
1925
1948
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
1926
|
-
|
|
1949
|
+
r.set(o, a);
|
|
1927
1950
|
}
|
|
1928
1951
|
}
|
|
1929
|
-
return new
|
|
1952
|
+
return new ke({
|
|
1930
1953
|
typeName: p.ZodDiscriminatedUnion,
|
|
1931
1954
|
discriminator: e,
|
|
1932
1955
|
options: t,
|
|
1933
|
-
optionsMap:
|
|
1934
|
-
...g(
|
|
1956
|
+
optionsMap: r,
|
|
1957
|
+
...g(n)
|
|
1935
1958
|
});
|
|
1936
1959
|
}
|
|
1937
1960
|
}
|
|
1938
|
-
function
|
|
1939
|
-
const t =
|
|
1961
|
+
function Ce(s, e) {
|
|
1962
|
+
const t = M(s), n = M(e);
|
|
1940
1963
|
if (s === e)
|
|
1941
1964
|
return { valid: !0, data: s };
|
|
1942
|
-
if (t === f.object &&
|
|
1943
|
-
const
|
|
1965
|
+
if (t === f.object && n === f.object) {
|
|
1966
|
+
const r = _.objectKeys(e), a = _.objectKeys(s).filter((o) => r.indexOf(o) !== -1), i = { ...s, ...e };
|
|
1944
1967
|
for (const o of a) {
|
|
1945
|
-
const u =
|
|
1968
|
+
const u = Ce(s[o], e[o]);
|
|
1946
1969
|
if (!u.valid)
|
|
1947
1970
|
return { valid: !1 };
|
|
1948
1971
|
i[o] = u.data;
|
|
1949
1972
|
}
|
|
1950
1973
|
return { valid: !0, data: i };
|
|
1951
|
-
} else if (t === f.array &&
|
|
1974
|
+
} else if (t === f.array && n === f.array) {
|
|
1952
1975
|
if (s.length !== e.length)
|
|
1953
1976
|
return { valid: !1 };
|
|
1954
|
-
const
|
|
1977
|
+
const r = [];
|
|
1955
1978
|
for (let a = 0; a < s.length; a++) {
|
|
1956
|
-
const i = s[a], o = e[a], u =
|
|
1979
|
+
const i = s[a], o = e[a], u = Ce(i, o);
|
|
1957
1980
|
if (!u.valid)
|
|
1958
1981
|
return { valid: !1 };
|
|
1959
|
-
|
|
1982
|
+
r.push(u.data);
|
|
1960
1983
|
}
|
|
1961
|
-
return { valid: !0, data:
|
|
1984
|
+
return { valid: !0, data: r };
|
|
1962
1985
|
} else
|
|
1963
|
-
return t === f.date &&
|
|
1986
|
+
return t === f.date && n === f.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
|
|
1964
1987
|
}
|
|
1965
1988
|
class re extends v {
|
|
1966
1989
|
_parse(e) {
|
|
1967
|
-
const { status: t, ctx:
|
|
1968
|
-
if (
|
|
1990
|
+
const { status: t, ctx: n } = this._processInputParams(e), r = (a, i) => {
|
|
1991
|
+
if (Se(a) || Se(i))
|
|
1969
1992
|
return m;
|
|
1970
|
-
const o =
|
|
1971
|
-
return o.valid ? ((
|
|
1993
|
+
const o = Ce(a.value, i.value);
|
|
1994
|
+
return o.valid ? ((Ze(a) || Ze(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
|
|
1972
1995
|
code: d.invalid_intersection_types
|
|
1973
1996
|
}), m);
|
|
1974
1997
|
};
|
|
1975
|
-
return
|
|
1998
|
+
return n.common.async ? Promise.all([
|
|
1976
1999
|
this._def.left._parseAsync({
|
|
1977
|
-
data:
|
|
1978
|
-
path:
|
|
1979
|
-
parent:
|
|
2000
|
+
data: n.data,
|
|
2001
|
+
path: n.path,
|
|
2002
|
+
parent: n
|
|
1980
2003
|
}),
|
|
1981
2004
|
this._def.right._parseAsync({
|
|
1982
|
-
data:
|
|
1983
|
-
path:
|
|
1984
|
-
parent:
|
|
2005
|
+
data: n.data,
|
|
2006
|
+
path: n.path,
|
|
2007
|
+
parent: n
|
|
1985
2008
|
})
|
|
1986
|
-
]).then(([a, i]) =>
|
|
1987
|
-
data:
|
|
1988
|
-
path:
|
|
1989
|
-
parent:
|
|
2009
|
+
]).then(([a, i]) => r(a, i)) : r(this._def.left._parseSync({
|
|
2010
|
+
data: n.data,
|
|
2011
|
+
path: n.path,
|
|
2012
|
+
parent: n
|
|
1990
2013
|
}), this._def.right._parseSync({
|
|
1991
|
-
data:
|
|
1992
|
-
path:
|
|
1993
|
-
parent:
|
|
2014
|
+
data: n.data,
|
|
2015
|
+
path: n.path,
|
|
2016
|
+
parent: n
|
|
1994
2017
|
}));
|
|
1995
2018
|
}
|
|
1996
2019
|
}
|
|
@@ -2000,57 +2023,57 @@ re.create = (s, e, t) => new re({
|
|
|
2000
2023
|
typeName: p.ZodIntersection,
|
|
2001
2024
|
...g(t)
|
|
2002
2025
|
});
|
|
2003
|
-
class
|
|
2026
|
+
class I extends v {
|
|
2004
2027
|
_parse(e) {
|
|
2005
|
-
const { status: t, ctx:
|
|
2006
|
-
if (
|
|
2007
|
-
return l(
|
|
2028
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2029
|
+
if (n.parsedType !== f.array)
|
|
2030
|
+
return l(n, {
|
|
2008
2031
|
code: d.invalid_type,
|
|
2009
2032
|
expected: f.array,
|
|
2010
|
-
received:
|
|
2033
|
+
received: n.parsedType
|
|
2011
2034
|
}), m;
|
|
2012
|
-
if (
|
|
2013
|
-
return l(
|
|
2035
|
+
if (n.data.length < this._def.items.length)
|
|
2036
|
+
return l(n, {
|
|
2014
2037
|
code: d.too_small,
|
|
2015
2038
|
minimum: this._def.items.length,
|
|
2016
2039
|
inclusive: !0,
|
|
2017
2040
|
exact: !1,
|
|
2018
2041
|
type: "array"
|
|
2019
2042
|
}), m;
|
|
2020
|
-
!this._def.rest &&
|
|
2043
|
+
!this._def.rest && n.data.length > this._def.items.length && (l(n, {
|
|
2021
2044
|
code: d.too_big,
|
|
2022
2045
|
maximum: this._def.items.length,
|
|
2023
2046
|
inclusive: !0,
|
|
2024
2047
|
exact: !1,
|
|
2025
2048
|
type: "array"
|
|
2026
2049
|
}), t.dirty());
|
|
2027
|
-
const a = [...
|
|
2050
|
+
const a = [...n.data].map((i, o) => {
|
|
2028
2051
|
const u = this._def.items[o] || this._def.rest;
|
|
2029
|
-
return u ? u._parse(new
|
|
2052
|
+
return u ? u._parse(new R(n, i, n.path, o)) : null;
|
|
2030
2053
|
}).filter((i) => !!i);
|
|
2031
|
-
return
|
|
2054
|
+
return n.common.async ? Promise.all(a).then((i) => w.mergeArray(t, i)) : w.mergeArray(t, a);
|
|
2032
2055
|
}
|
|
2033
2056
|
get items() {
|
|
2034
2057
|
return this._def.items;
|
|
2035
2058
|
}
|
|
2036
2059
|
rest(e) {
|
|
2037
|
-
return new
|
|
2060
|
+
return new I({
|
|
2038
2061
|
...this._def,
|
|
2039
2062
|
rest: e
|
|
2040
2063
|
});
|
|
2041
2064
|
}
|
|
2042
2065
|
}
|
|
2043
|
-
|
|
2066
|
+
I.create = (s, e) => {
|
|
2044
2067
|
if (!Array.isArray(s))
|
|
2045
2068
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2046
|
-
return new
|
|
2069
|
+
return new I({
|
|
2047
2070
|
items: s,
|
|
2048
2071
|
typeName: p.ZodTuple,
|
|
2049
2072
|
rest: null,
|
|
2050
2073
|
...g(e)
|
|
2051
2074
|
});
|
|
2052
2075
|
};
|
|
2053
|
-
class
|
|
2076
|
+
class ae extends v {
|
|
2054
2077
|
get keySchema() {
|
|
2055
2078
|
return this._def.keyType;
|
|
2056
2079
|
}
|
|
@@ -2058,40 +2081,40 @@ class ne extends v {
|
|
|
2058
2081
|
return this._def.valueType;
|
|
2059
2082
|
}
|
|
2060
2083
|
_parse(e) {
|
|
2061
|
-
const { status: t, ctx:
|
|
2062
|
-
if (
|
|
2063
|
-
return l(
|
|
2084
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2085
|
+
if (n.parsedType !== f.object)
|
|
2086
|
+
return l(n, {
|
|
2064
2087
|
code: d.invalid_type,
|
|
2065
2088
|
expected: f.object,
|
|
2066
|
-
received:
|
|
2089
|
+
received: n.parsedType
|
|
2067
2090
|
}), m;
|
|
2068
|
-
const
|
|
2069
|
-
for (const o in
|
|
2070
|
-
|
|
2071
|
-
key: a._parse(new
|
|
2072
|
-
value: i._parse(new
|
|
2073
|
-
alwaysSet: o in
|
|
2091
|
+
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2092
|
+
for (const o in n.data)
|
|
2093
|
+
r.push({
|
|
2094
|
+
key: a._parse(new R(n, o, n.path, o)),
|
|
2095
|
+
value: i._parse(new R(n, n.data[o], n.path, o)),
|
|
2096
|
+
alwaysSet: o in n.data
|
|
2074
2097
|
});
|
|
2075
|
-
return
|
|
2098
|
+
return n.common.async ? w.mergeObjectAsync(t, r) : w.mergeObjectSync(t, r);
|
|
2076
2099
|
}
|
|
2077
2100
|
get element() {
|
|
2078
2101
|
return this._def.valueType;
|
|
2079
2102
|
}
|
|
2080
|
-
static create(e, t,
|
|
2081
|
-
return t instanceof v ? new
|
|
2103
|
+
static create(e, t, n) {
|
|
2104
|
+
return t instanceof v ? new ae({
|
|
2082
2105
|
keyType: e,
|
|
2083
2106
|
valueType: t,
|
|
2084
2107
|
typeName: p.ZodRecord,
|
|
2085
|
-
...g(
|
|
2086
|
-
}) : new
|
|
2087
|
-
keyType:
|
|
2108
|
+
...g(n)
|
|
2109
|
+
}) : new ae({
|
|
2110
|
+
keyType: C.create(),
|
|
2088
2111
|
valueType: e,
|
|
2089
2112
|
typeName: p.ZodRecord,
|
|
2090
2113
|
...g(t)
|
|
2091
2114
|
});
|
|
2092
2115
|
}
|
|
2093
2116
|
}
|
|
2094
|
-
class
|
|
2117
|
+
class _e extends v {
|
|
2095
2118
|
get keySchema() {
|
|
2096
2119
|
return this._def.keyType;
|
|
2097
2120
|
}
|
|
@@ -2099,18 +2122,18 @@ class ge extends v {
|
|
|
2099
2122
|
return this._def.valueType;
|
|
2100
2123
|
}
|
|
2101
2124
|
_parse(e) {
|
|
2102
|
-
const { status: t, ctx:
|
|
2103
|
-
if (
|
|
2104
|
-
return l(
|
|
2125
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2126
|
+
if (n.parsedType !== f.map)
|
|
2127
|
+
return l(n, {
|
|
2105
2128
|
code: d.invalid_type,
|
|
2106
2129
|
expected: f.map,
|
|
2107
|
-
received:
|
|
2130
|
+
received: n.parsedType
|
|
2108
2131
|
}), m;
|
|
2109
|
-
const
|
|
2110
|
-
key:
|
|
2111
|
-
value: a._parse(new
|
|
2132
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], c) => ({
|
|
2133
|
+
key: r._parse(new R(n, o, n.path, [c, "key"])),
|
|
2134
|
+
value: a._parse(new R(n, u, n.path, [c, "value"]))
|
|
2112
2135
|
}));
|
|
2113
|
-
if (
|
|
2136
|
+
if (n.common.async) {
|
|
2114
2137
|
const o = /* @__PURE__ */ new Map();
|
|
2115
2138
|
return Promise.resolve().then(async () => {
|
|
2116
2139
|
for (const u of i) {
|
|
@@ -2133,7 +2156,7 @@ class ge extends v {
|
|
|
2133
2156
|
}
|
|
2134
2157
|
}
|
|
2135
2158
|
}
|
|
2136
|
-
|
|
2159
|
+
_e.create = (s, e, t) => new _e({
|
|
2137
2160
|
valueType: e,
|
|
2138
2161
|
keyType: s,
|
|
2139
2162
|
typeName: p.ZodMap,
|
|
@@ -2141,28 +2164,28 @@ ge.create = (s, e, t) => new ge({
|
|
|
2141
2164
|
});
|
|
2142
2165
|
class z extends v {
|
|
2143
2166
|
_parse(e) {
|
|
2144
|
-
const { status: t, ctx:
|
|
2145
|
-
if (
|
|
2146
|
-
return l(
|
|
2167
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2168
|
+
if (n.parsedType !== f.set)
|
|
2169
|
+
return l(n, {
|
|
2147
2170
|
code: d.invalid_type,
|
|
2148
2171
|
expected: f.set,
|
|
2149
|
-
received:
|
|
2172
|
+
received: n.parsedType
|
|
2150
2173
|
}), m;
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2174
|
+
const r = this._def;
|
|
2175
|
+
r.minSize !== null && n.data.size < r.minSize.value && (l(n, {
|
|
2153
2176
|
code: d.too_small,
|
|
2154
|
-
minimum:
|
|
2177
|
+
minimum: r.minSize.value,
|
|
2155
2178
|
type: "set",
|
|
2156
2179
|
inclusive: !0,
|
|
2157
2180
|
exact: !1,
|
|
2158
|
-
message:
|
|
2159
|
-
}), t.dirty()),
|
|
2181
|
+
message: r.minSize.message
|
|
2182
|
+
}), t.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (l(n, {
|
|
2160
2183
|
code: d.too_big,
|
|
2161
|
-
maximum:
|
|
2184
|
+
maximum: r.maxSize.value,
|
|
2162
2185
|
type: "set",
|
|
2163
2186
|
inclusive: !0,
|
|
2164
2187
|
exact: !1,
|
|
2165
|
-
message:
|
|
2188
|
+
message: r.maxSize.message
|
|
2166
2189
|
}), t.dirty());
|
|
2167
2190
|
const a = this._def.valueType;
|
|
2168
2191
|
function i(u) {
|
|
@@ -2174,8 +2197,8 @@ class z extends v {
|
|
|
2174
2197
|
}
|
|
2175
2198
|
return { status: t.value, value: c };
|
|
2176
2199
|
}
|
|
2177
|
-
const o = [...
|
|
2178
|
-
return
|
|
2200
|
+
const o = [...n.data.values()].map((u, c) => a._parse(new R(n, u, n.path, c)));
|
|
2201
|
+
return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2179
2202
|
}
|
|
2180
2203
|
min(e, t) {
|
|
2181
2204
|
return new z({
|
|
@@ -2203,7 +2226,7 @@ z.create = (s, e) => new z({
|
|
|
2203
2226
|
typeName: p.ZodSet,
|
|
2204
2227
|
...g(e)
|
|
2205
2228
|
});
|
|
2206
|
-
class
|
|
2229
|
+
class Q extends v {
|
|
2207
2230
|
constructor() {
|
|
2208
2231
|
super(...arguments), this.validate = this.implement;
|
|
2209
2232
|
}
|
|
@@ -2215,15 +2238,15 @@ class q extends v {
|
|
|
2215
2238
|
expected: f.function,
|
|
2216
2239
|
received: t.parsedType
|
|
2217
2240
|
}), m;
|
|
2218
|
-
function
|
|
2219
|
-
return
|
|
2241
|
+
function n(o, u) {
|
|
2242
|
+
return me({
|
|
2220
2243
|
data: o,
|
|
2221
2244
|
path: t.path,
|
|
2222
2245
|
errorMaps: [
|
|
2223
2246
|
t.common.contextualErrorMap,
|
|
2224
2247
|
t.schemaErrorMap,
|
|
2225
|
-
|
|
2226
|
-
|
|
2248
|
+
pe(),
|
|
2249
|
+
Y
|
|
2227
2250
|
].filter((c) => !!c),
|
|
2228
2251
|
issueData: {
|
|
2229
2252
|
code: d.invalid_arguments,
|
|
@@ -2231,15 +2254,15 @@ class q extends v {
|
|
|
2231
2254
|
}
|
|
2232
2255
|
});
|
|
2233
2256
|
}
|
|
2234
|
-
function
|
|
2235
|
-
return
|
|
2257
|
+
function r(o, u) {
|
|
2258
|
+
return me({
|
|
2236
2259
|
data: o,
|
|
2237
2260
|
path: t.path,
|
|
2238
2261
|
errorMaps: [
|
|
2239
2262
|
t.common.contextualErrorMap,
|
|
2240
2263
|
t.schemaErrorMap,
|
|
2241
|
-
|
|
2242
|
-
|
|
2264
|
+
pe(),
|
|
2265
|
+
Y
|
|
2243
2266
|
].filter((c) => !!c),
|
|
2244
2267
|
issueData: {
|
|
2245
2268
|
code: d.invalid_return_type,
|
|
@@ -2248,25 +2271,25 @@ class q extends v {
|
|
|
2248
2271
|
});
|
|
2249
2272
|
}
|
|
2250
2273
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2251
|
-
if (this._def.returns instanceof
|
|
2274
|
+
if (this._def.returns instanceof H) {
|
|
2252
2275
|
const o = this;
|
|
2253
|
-
return
|
|
2254
|
-
const c = new
|
|
2255
|
-
throw c.addIssue(
|
|
2276
|
+
return T(async function(...u) {
|
|
2277
|
+
const c = new S([]), y = await o._def.args.parseAsync(u, a).catch((be) => {
|
|
2278
|
+
throw c.addIssue(n(u, be)), c;
|
|
2256
2279
|
}), Z = await Reflect.apply(i, this, y);
|
|
2257
|
-
return await o._def.returns._def.type.parseAsync(Z, a).catch((
|
|
2258
|
-
throw c.addIssue(
|
|
2280
|
+
return await o._def.returns._def.type.parseAsync(Z, a).catch((be) => {
|
|
2281
|
+
throw c.addIssue(r(Z, be)), c;
|
|
2259
2282
|
});
|
|
2260
2283
|
});
|
|
2261
2284
|
} else {
|
|
2262
2285
|
const o = this;
|
|
2263
|
-
return
|
|
2286
|
+
return T(function(...u) {
|
|
2264
2287
|
const c = o._def.args.safeParse(u, a);
|
|
2265
2288
|
if (!c.success)
|
|
2266
|
-
throw new
|
|
2289
|
+
throw new S([n(u, c.error)]);
|
|
2267
2290
|
const y = Reflect.apply(i, this, c.data), Z = o._def.returns.safeParse(y, a);
|
|
2268
2291
|
if (!Z.success)
|
|
2269
|
-
throw new
|
|
2292
|
+
throw new S([r(y, Z.error)]);
|
|
2270
2293
|
return Z.data;
|
|
2271
2294
|
});
|
|
2272
2295
|
}
|
|
@@ -2278,13 +2301,13 @@ class q extends v {
|
|
|
2278
2301
|
return this._def.returns;
|
|
2279
2302
|
}
|
|
2280
2303
|
args(...e) {
|
|
2281
|
-
return new
|
|
2304
|
+
return new Q({
|
|
2282
2305
|
...this._def,
|
|
2283
|
-
args:
|
|
2306
|
+
args: I.create(e).rest(L.create())
|
|
2284
2307
|
});
|
|
2285
2308
|
}
|
|
2286
2309
|
returns(e) {
|
|
2287
|
-
return new
|
|
2310
|
+
return new Q({
|
|
2288
2311
|
...this._def,
|
|
2289
2312
|
returns: e
|
|
2290
2313
|
});
|
|
@@ -2295,16 +2318,16 @@ class q extends v {
|
|
|
2295
2318
|
strictImplement(e) {
|
|
2296
2319
|
return this.parse(e);
|
|
2297
2320
|
}
|
|
2298
|
-
static create(e, t,
|
|
2299
|
-
return new
|
|
2300
|
-
args: e ||
|
|
2321
|
+
static create(e, t, n) {
|
|
2322
|
+
return new Q({
|
|
2323
|
+
args: e || I.create([]).rest(L.create()),
|
|
2301
2324
|
returns: t || L.create(),
|
|
2302
2325
|
typeName: p.ZodFunction,
|
|
2303
|
-
...g(
|
|
2326
|
+
...g(n)
|
|
2304
2327
|
});
|
|
2305
2328
|
}
|
|
2306
2329
|
}
|
|
2307
|
-
class
|
|
2330
|
+
class ie extends v {
|
|
2308
2331
|
get schema() {
|
|
2309
2332
|
return this._def.getter();
|
|
2310
2333
|
}
|
|
@@ -2313,12 +2336,12 @@ class ae extends v {
|
|
|
2313
2336
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2314
2337
|
}
|
|
2315
2338
|
}
|
|
2316
|
-
|
|
2339
|
+
ie.create = (s, e) => new ie({
|
|
2317
2340
|
getter: s,
|
|
2318
2341
|
typeName: p.ZodLazy,
|
|
2319
2342
|
...g(e)
|
|
2320
2343
|
});
|
|
2321
|
-
class
|
|
2344
|
+
class oe extends v {
|
|
2322
2345
|
_parse(e) {
|
|
2323
2346
|
if (e.data !== this._def.value) {
|
|
2324
2347
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2334,40 +2357,40 @@ class ie extends v {
|
|
|
2334
2357
|
return this._def.value;
|
|
2335
2358
|
}
|
|
2336
2359
|
}
|
|
2337
|
-
|
|
2360
|
+
oe.create = (s, e) => new oe({
|
|
2338
2361
|
value: s,
|
|
2339
2362
|
typeName: p.ZodLiteral,
|
|
2340
2363
|
...g(e)
|
|
2341
2364
|
});
|
|
2342
|
-
function
|
|
2343
|
-
return new
|
|
2365
|
+
function De(s, e) {
|
|
2366
|
+
return new V({
|
|
2344
2367
|
values: s,
|
|
2345
2368
|
typeName: p.ZodEnum,
|
|
2346
2369
|
...g(e)
|
|
2347
2370
|
});
|
|
2348
2371
|
}
|
|
2349
|
-
class
|
|
2372
|
+
class V extends v {
|
|
2350
2373
|
constructor() {
|
|
2351
2374
|
super(...arguments), J.set(this, void 0);
|
|
2352
2375
|
}
|
|
2353
2376
|
_parse(e) {
|
|
2354
2377
|
if (typeof e.data != "string") {
|
|
2355
|
-
const t = this._getOrReturnCtx(e),
|
|
2378
|
+
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2356
2379
|
return l(t, {
|
|
2357
|
-
expected: _.joinValues(
|
|
2380
|
+
expected: _.joinValues(n),
|
|
2358
2381
|
received: t.parsedType,
|
|
2359
2382
|
code: d.invalid_type
|
|
2360
2383
|
}), m;
|
|
2361
2384
|
}
|
|
2362
|
-
if (
|
|
2363
|
-
const t = this._getOrReturnCtx(e),
|
|
2385
|
+
if (ye(this, J) || Me(this, J, new Set(this._def.values)), !ye(this, J).has(e.data)) {
|
|
2386
|
+
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2364
2387
|
return l(t, {
|
|
2365
2388
|
received: t.data,
|
|
2366
2389
|
code: d.invalid_enum_value,
|
|
2367
|
-
options:
|
|
2390
|
+
options: n
|
|
2368
2391
|
}), m;
|
|
2369
2392
|
}
|
|
2370
|
-
return
|
|
2393
|
+
return T(e.data);
|
|
2371
2394
|
}
|
|
2372
2395
|
get options() {
|
|
2373
2396
|
return this._def.values;
|
|
@@ -2391,55 +2414,55 @@ class $ extends v {
|
|
|
2391
2414
|
return e;
|
|
2392
2415
|
}
|
|
2393
2416
|
extract(e, t = this._def) {
|
|
2394
|
-
return
|
|
2417
|
+
return V.create(e, {
|
|
2395
2418
|
...this._def,
|
|
2396
2419
|
...t
|
|
2397
2420
|
});
|
|
2398
2421
|
}
|
|
2399
2422
|
exclude(e, t = this._def) {
|
|
2400
|
-
return
|
|
2423
|
+
return V.create(this.options.filter((n) => !e.includes(n)), {
|
|
2401
2424
|
...this._def,
|
|
2402
2425
|
...t
|
|
2403
2426
|
});
|
|
2404
2427
|
}
|
|
2405
2428
|
}
|
|
2406
2429
|
J = /* @__PURE__ */ new WeakMap();
|
|
2407
|
-
|
|
2408
|
-
class
|
|
2430
|
+
V.create = De;
|
|
2431
|
+
class de extends v {
|
|
2409
2432
|
constructor() {
|
|
2410
|
-
super(...arguments),
|
|
2433
|
+
super(...arguments), X.set(this, void 0);
|
|
2411
2434
|
}
|
|
2412
2435
|
_parse(e) {
|
|
2413
|
-
const t = _.getValidEnumValues(this._def.values),
|
|
2414
|
-
if (
|
|
2415
|
-
const
|
|
2416
|
-
return l(
|
|
2417
|
-
expected: _.joinValues(
|
|
2418
|
-
received:
|
|
2436
|
+
const t = _.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
2437
|
+
if (n.parsedType !== f.string && n.parsedType !== f.number) {
|
|
2438
|
+
const r = _.objectValues(t);
|
|
2439
|
+
return l(n, {
|
|
2440
|
+
expected: _.joinValues(r),
|
|
2441
|
+
received: n.parsedType,
|
|
2419
2442
|
code: d.invalid_type
|
|
2420
2443
|
}), m;
|
|
2421
2444
|
}
|
|
2422
|
-
if (
|
|
2423
|
-
const
|
|
2424
|
-
return l(
|
|
2425
|
-
received:
|
|
2445
|
+
if (ye(this, X) || Me(this, X, new Set(_.getValidEnumValues(this._def.values))), !ye(this, X).has(e.data)) {
|
|
2446
|
+
const r = _.objectValues(t);
|
|
2447
|
+
return l(n, {
|
|
2448
|
+
received: n.data,
|
|
2426
2449
|
code: d.invalid_enum_value,
|
|
2427
|
-
options:
|
|
2450
|
+
options: r
|
|
2428
2451
|
}), m;
|
|
2429
2452
|
}
|
|
2430
|
-
return
|
|
2453
|
+
return T(e.data);
|
|
2431
2454
|
}
|
|
2432
2455
|
get enum() {
|
|
2433
2456
|
return this._def.values;
|
|
2434
2457
|
}
|
|
2435
2458
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2459
|
+
X = /* @__PURE__ */ new WeakMap();
|
|
2460
|
+
de.create = (s, e) => new de({
|
|
2438
2461
|
values: s,
|
|
2439
2462
|
typeName: p.ZodNativeEnum,
|
|
2440
2463
|
...g(e)
|
|
2441
2464
|
});
|
|
2442
|
-
class
|
|
2465
|
+
class H extends v {
|
|
2443
2466
|
unwrap() {
|
|
2444
2467
|
return this._def.type;
|
|
2445
2468
|
}
|
|
@@ -2451,19 +2474,19 @@ class Y extends v {
|
|
|
2451
2474
|
expected: f.promise,
|
|
2452
2475
|
received: t.parsedType
|
|
2453
2476
|
}), m;
|
|
2454
|
-
const
|
|
2455
|
-
return
|
|
2477
|
+
const n = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2478
|
+
return T(n.then((r) => this._def.type.parseAsync(r, {
|
|
2456
2479
|
path: t.path,
|
|
2457
2480
|
errorMap: t.common.contextualErrorMap
|
|
2458
2481
|
})));
|
|
2459
2482
|
}
|
|
2460
2483
|
}
|
|
2461
|
-
|
|
2484
|
+
H.create = (s, e) => new H({
|
|
2462
2485
|
type: s,
|
|
2463
2486
|
typeName: p.ZodPromise,
|
|
2464
2487
|
...g(e)
|
|
2465
2488
|
});
|
|
2466
|
-
class
|
|
2489
|
+
class N extends v {
|
|
2467
2490
|
innerType() {
|
|
2468
2491
|
return this._def.schema;
|
|
2469
2492
|
}
|
|
@@ -2471,119 +2494,119 @@ class E extends v {
|
|
|
2471
2494
|
return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2472
2495
|
}
|
|
2473
2496
|
_parse(e) {
|
|
2474
|
-
const { status: t, ctx:
|
|
2497
|
+
const { status: t, ctx: n } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2475
2498
|
addIssue: (i) => {
|
|
2476
|
-
l(
|
|
2499
|
+
l(n, i), i.fatal ? t.abort() : t.dirty();
|
|
2477
2500
|
},
|
|
2478
2501
|
get path() {
|
|
2479
|
-
return
|
|
2502
|
+
return n.path;
|
|
2480
2503
|
}
|
|
2481
2504
|
};
|
|
2482
|
-
if (a.addIssue = a.addIssue.bind(a),
|
|
2483
|
-
const i =
|
|
2484
|
-
if (
|
|
2505
|
+
if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
|
|
2506
|
+
const i = r.transform(n.data, a);
|
|
2507
|
+
if (n.common.async)
|
|
2485
2508
|
return Promise.resolve(i).then(async (o) => {
|
|
2486
2509
|
if (t.value === "aborted")
|
|
2487
2510
|
return m;
|
|
2488
2511
|
const u = await this._def.schema._parseAsync({
|
|
2489
2512
|
data: o,
|
|
2490
|
-
path:
|
|
2491
|
-
parent:
|
|
2513
|
+
path: n.path,
|
|
2514
|
+
parent: n
|
|
2492
2515
|
});
|
|
2493
|
-
return u.status === "aborted" ? m : u.status === "dirty" || t.value === "dirty" ?
|
|
2516
|
+
return u.status === "aborted" ? m : u.status === "dirty" || t.value === "dirty" ? W(u.value) : u;
|
|
2494
2517
|
});
|
|
2495
2518
|
{
|
|
2496
2519
|
if (t.value === "aborted")
|
|
2497
2520
|
return m;
|
|
2498
2521
|
const o = this._def.schema._parseSync({
|
|
2499
2522
|
data: i,
|
|
2500
|
-
path:
|
|
2501
|
-
parent:
|
|
2523
|
+
path: n.path,
|
|
2524
|
+
parent: n
|
|
2502
2525
|
});
|
|
2503
|
-
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ?
|
|
2526
|
+
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ? W(o.value) : o;
|
|
2504
2527
|
}
|
|
2505
2528
|
}
|
|
2506
|
-
if (
|
|
2529
|
+
if (r.type === "refinement") {
|
|
2507
2530
|
const i = (o) => {
|
|
2508
|
-
const u =
|
|
2509
|
-
if (
|
|
2531
|
+
const u = r.refinement(o, a);
|
|
2532
|
+
if (n.common.async)
|
|
2510
2533
|
return Promise.resolve(u);
|
|
2511
2534
|
if (u instanceof Promise)
|
|
2512
2535
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2513
2536
|
return o;
|
|
2514
2537
|
};
|
|
2515
|
-
if (
|
|
2538
|
+
if (n.common.async === !1) {
|
|
2516
2539
|
const o = this._def.schema._parseSync({
|
|
2517
|
-
data:
|
|
2518
|
-
path:
|
|
2519
|
-
parent:
|
|
2540
|
+
data: n.data,
|
|
2541
|
+
path: n.path,
|
|
2542
|
+
parent: n
|
|
2520
2543
|
});
|
|
2521
2544
|
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2522
2545
|
} else
|
|
2523
|
-
return this._def.schema._parseAsync({ data:
|
|
2546
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2524
2547
|
}
|
|
2525
|
-
if (
|
|
2526
|
-
if (
|
|
2548
|
+
if (r.type === "transform")
|
|
2549
|
+
if (n.common.async === !1) {
|
|
2527
2550
|
const i = this._def.schema._parseSync({
|
|
2528
|
-
data:
|
|
2529
|
-
path:
|
|
2530
|
-
parent:
|
|
2551
|
+
data: n.data,
|
|
2552
|
+
path: n.path,
|
|
2553
|
+
parent: n
|
|
2531
2554
|
});
|
|
2532
|
-
if (!
|
|
2555
|
+
if (!K(i))
|
|
2533
2556
|
return i;
|
|
2534
|
-
const o =
|
|
2557
|
+
const o = r.transform(i.value, a);
|
|
2535
2558
|
if (o instanceof Promise)
|
|
2536
2559
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2537
2560
|
return { status: t.value, value: o };
|
|
2538
2561
|
} else
|
|
2539
|
-
return this._def.schema._parseAsync({ data:
|
|
2540
|
-
_.assertNever(
|
|
2562
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => K(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
2563
|
+
_.assertNever(r);
|
|
2541
2564
|
}
|
|
2542
2565
|
}
|
|
2543
|
-
|
|
2566
|
+
N.create = (s, e, t) => new N({
|
|
2544
2567
|
schema: s,
|
|
2545
2568
|
typeName: p.ZodEffects,
|
|
2546
2569
|
effect: e,
|
|
2547
2570
|
...g(t)
|
|
2548
2571
|
});
|
|
2549
|
-
|
|
2572
|
+
N.createWithPreprocess = (s, e, t) => new N({
|
|
2550
2573
|
schema: e,
|
|
2551
2574
|
effect: { type: "preprocess", transform: s },
|
|
2552
2575
|
typeName: p.ZodEffects,
|
|
2553
2576
|
...g(t)
|
|
2554
2577
|
});
|
|
2555
|
-
class
|
|
2578
|
+
class O extends v {
|
|
2556
2579
|
_parse(e) {
|
|
2557
|
-
return this._getType(e) === f.undefined ?
|
|
2580
|
+
return this._getType(e) === f.undefined ? T(void 0) : this._def.innerType._parse(e);
|
|
2558
2581
|
}
|
|
2559
2582
|
unwrap() {
|
|
2560
2583
|
return this._def.innerType;
|
|
2561
2584
|
}
|
|
2562
2585
|
}
|
|
2563
|
-
|
|
2586
|
+
O.create = (s, e) => new O({
|
|
2564
2587
|
innerType: s,
|
|
2565
2588
|
typeName: p.ZodOptional,
|
|
2566
2589
|
...g(e)
|
|
2567
2590
|
});
|
|
2568
|
-
class
|
|
2591
|
+
class D extends v {
|
|
2569
2592
|
_parse(e) {
|
|
2570
|
-
return this._getType(e) === f.null ?
|
|
2593
|
+
return this._getType(e) === f.null ? T(null) : this._def.innerType._parse(e);
|
|
2571
2594
|
}
|
|
2572
2595
|
unwrap() {
|
|
2573
2596
|
return this._def.innerType;
|
|
2574
2597
|
}
|
|
2575
2598
|
}
|
|
2576
|
-
|
|
2599
|
+
D.create = (s, e) => new D({
|
|
2577
2600
|
innerType: s,
|
|
2578
2601
|
typeName: p.ZodNullable,
|
|
2579
2602
|
...g(e)
|
|
2580
2603
|
});
|
|
2581
|
-
class
|
|
2604
|
+
class ce extends v {
|
|
2582
2605
|
_parse(e) {
|
|
2583
2606
|
const { ctx: t } = this._processInputParams(e);
|
|
2584
|
-
let
|
|
2585
|
-
return t.parsedType === f.undefined && (
|
|
2586
|
-
data:
|
|
2607
|
+
let n = t.data;
|
|
2608
|
+
return t.parsedType === f.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
2609
|
+
data: n,
|
|
2587
2610
|
path: t.path,
|
|
2588
2611
|
parent: t
|
|
2589
2612
|
});
|
|
@@ -2592,42 +2615,42 @@ class de extends v {
|
|
|
2592
2615
|
return this._def.innerType;
|
|
2593
2616
|
}
|
|
2594
2617
|
}
|
|
2595
|
-
|
|
2618
|
+
ce.create = (s, e) => new ce({
|
|
2596
2619
|
innerType: s,
|
|
2597
2620
|
typeName: p.ZodDefault,
|
|
2598
2621
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2599
2622
|
...g(e)
|
|
2600
2623
|
});
|
|
2601
|
-
class
|
|
2624
|
+
class ue extends v {
|
|
2602
2625
|
_parse(e) {
|
|
2603
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2626
|
+
const { ctx: t } = this._processInputParams(e), n = {
|
|
2604
2627
|
...t,
|
|
2605
2628
|
common: {
|
|
2606
2629
|
...t.common,
|
|
2607
2630
|
issues: []
|
|
2608
2631
|
}
|
|
2609
|
-
},
|
|
2610
|
-
data:
|
|
2611
|
-
path:
|
|
2632
|
+
}, r = this._def.innerType._parse({
|
|
2633
|
+
data: n.data,
|
|
2634
|
+
path: n.path,
|
|
2612
2635
|
parent: {
|
|
2613
|
-
...
|
|
2636
|
+
...n
|
|
2614
2637
|
}
|
|
2615
2638
|
});
|
|
2616
|
-
return
|
|
2639
|
+
return F(r) ? r.then((a) => ({
|
|
2617
2640
|
status: "valid",
|
|
2618
2641
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2619
2642
|
get error() {
|
|
2620
|
-
return new
|
|
2643
|
+
return new S(n.common.issues);
|
|
2621
2644
|
},
|
|
2622
|
-
input:
|
|
2645
|
+
input: n.data
|
|
2623
2646
|
})
|
|
2624
2647
|
})) : {
|
|
2625
2648
|
status: "valid",
|
|
2626
|
-
value:
|
|
2649
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2627
2650
|
get error() {
|
|
2628
|
-
return new
|
|
2651
|
+
return new S(n.common.issues);
|
|
2629
2652
|
},
|
|
2630
|
-
input:
|
|
2653
|
+
input: n.data
|
|
2631
2654
|
})
|
|
2632
2655
|
};
|
|
2633
2656
|
}
|
|
@@ -2635,35 +2658,35 @@ class ce extends v {
|
|
|
2635
2658
|
return this._def.innerType;
|
|
2636
2659
|
}
|
|
2637
2660
|
}
|
|
2638
|
-
|
|
2661
|
+
ue.create = (s, e) => new ue({
|
|
2639
2662
|
innerType: s,
|
|
2640
2663
|
typeName: p.ZodCatch,
|
|
2641
2664
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2642
2665
|
...g(e)
|
|
2643
2666
|
});
|
|
2644
|
-
class
|
|
2667
|
+
class xe extends v {
|
|
2645
2668
|
_parse(e) {
|
|
2646
2669
|
if (this._getType(e) !== f.nan) {
|
|
2647
|
-
const
|
|
2648
|
-
return l(
|
|
2670
|
+
const n = this._getOrReturnCtx(e);
|
|
2671
|
+
return l(n, {
|
|
2649
2672
|
code: d.invalid_type,
|
|
2650
2673
|
expected: f.nan,
|
|
2651
|
-
received:
|
|
2674
|
+
received: n.parsedType
|
|
2652
2675
|
}), m;
|
|
2653
2676
|
}
|
|
2654
2677
|
return { status: "valid", value: e.data };
|
|
2655
2678
|
}
|
|
2656
2679
|
}
|
|
2657
|
-
|
|
2680
|
+
xe.create = (s) => new xe({
|
|
2658
2681
|
typeName: p.ZodNaN,
|
|
2659
2682
|
...g(s)
|
|
2660
2683
|
});
|
|
2661
|
-
const
|
|
2662
|
-
class
|
|
2684
|
+
const yt = Symbol("zod_brand");
|
|
2685
|
+
class Ee extends v {
|
|
2663
2686
|
_parse(e) {
|
|
2664
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2687
|
+
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
2665
2688
|
return this._def.type._parse({
|
|
2666
|
-
data:
|
|
2689
|
+
data: n,
|
|
2667
2690
|
path: t.path,
|
|
2668
2691
|
parent: t
|
|
2669
2692
|
});
|
|
@@ -2672,268 +2695,287 @@ class Se extends v {
|
|
|
2672
2695
|
return this._def.type;
|
|
2673
2696
|
}
|
|
2674
2697
|
}
|
|
2675
|
-
class
|
|
2698
|
+
class fe extends v {
|
|
2676
2699
|
_parse(e) {
|
|
2677
|
-
const { status: t, ctx:
|
|
2678
|
-
if (
|
|
2700
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2701
|
+
if (n.common.async)
|
|
2679
2702
|
return (async () => {
|
|
2680
2703
|
const a = await this._def.in._parseAsync({
|
|
2681
|
-
data:
|
|
2682
|
-
path:
|
|
2683
|
-
parent:
|
|
2704
|
+
data: n.data,
|
|
2705
|
+
path: n.path,
|
|
2706
|
+
parent: n
|
|
2684
2707
|
});
|
|
2685
|
-
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(),
|
|
2708
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), W(a.value)) : this._def.out._parseAsync({
|
|
2686
2709
|
data: a.value,
|
|
2687
|
-
path:
|
|
2688
|
-
parent:
|
|
2710
|
+
path: n.path,
|
|
2711
|
+
parent: n
|
|
2689
2712
|
});
|
|
2690
2713
|
})();
|
|
2691
2714
|
{
|
|
2692
|
-
const
|
|
2693
|
-
data:
|
|
2694
|
-
path:
|
|
2695
|
-
parent:
|
|
2715
|
+
const r = this._def.in._parseSync({
|
|
2716
|
+
data: n.data,
|
|
2717
|
+
path: n.path,
|
|
2718
|
+
parent: n
|
|
2696
2719
|
});
|
|
2697
|
-
return
|
|
2720
|
+
return r.status === "aborted" ? m : r.status === "dirty" ? (t.dirty(), {
|
|
2698
2721
|
status: "dirty",
|
|
2699
|
-
value:
|
|
2722
|
+
value: r.value
|
|
2700
2723
|
}) : this._def.out._parseSync({
|
|
2701
|
-
data:
|
|
2702
|
-
path:
|
|
2703
|
-
parent:
|
|
2724
|
+
data: r.value,
|
|
2725
|
+
path: n.path,
|
|
2726
|
+
parent: n
|
|
2704
2727
|
});
|
|
2705
2728
|
}
|
|
2706
2729
|
}
|
|
2707
2730
|
static create(e, t) {
|
|
2708
|
-
return new
|
|
2731
|
+
return new fe({
|
|
2709
2732
|
in: e,
|
|
2710
2733
|
out: t,
|
|
2711
2734
|
typeName: p.ZodPipeline
|
|
2712
2735
|
});
|
|
2713
2736
|
}
|
|
2714
2737
|
}
|
|
2715
|
-
class
|
|
2738
|
+
class le extends v {
|
|
2716
2739
|
_parse(e) {
|
|
2717
|
-
const t = this._def.innerType._parse(e),
|
|
2718
|
-
return
|
|
2740
|
+
const t = this._def.innerType._parse(e), n = (r) => (K(r) && (r.value = Object.freeze(r.value)), r);
|
|
2741
|
+
return F(t) ? t.then((r) => n(r)) : n(t);
|
|
2719
2742
|
}
|
|
2720
2743
|
unwrap() {
|
|
2721
2744
|
return this._def.innerType;
|
|
2722
2745
|
}
|
|
2723
2746
|
}
|
|
2724
|
-
|
|
2747
|
+
le.create = (s, e) => new le({
|
|
2725
2748
|
innerType: s,
|
|
2726
2749
|
typeName: p.ZodReadonly,
|
|
2727
2750
|
...g(e)
|
|
2728
2751
|
});
|
|
2729
|
-
function
|
|
2730
|
-
return s ?
|
|
2752
|
+
function Le(s, e = {}, t) {
|
|
2753
|
+
return s ? G.create().superRefine((n, r) => {
|
|
2731
2754
|
var a, i;
|
|
2732
|
-
if (!s(
|
|
2733
|
-
const o = typeof e == "function" ? e(
|
|
2734
|
-
|
|
2755
|
+
if (!s(n)) {
|
|
2756
|
+
const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, c = typeof o == "string" ? { message: o } : o;
|
|
2757
|
+
r.addIssue({ code: "custom", ...c, fatal: u });
|
|
2735
2758
|
}
|
|
2736
|
-
}) :
|
|
2759
|
+
}) : G.create();
|
|
2737
2760
|
}
|
|
2738
|
-
const
|
|
2761
|
+
const gt = {
|
|
2739
2762
|
object: x.lazycreate
|
|
2740
2763
|
};
|
|
2741
2764
|
var p;
|
|
2742
2765
|
(function(s) {
|
|
2743
2766
|
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
|
|
2744
2767
|
})(p || (p = {}));
|
|
2745
|
-
const
|
|
2768
|
+
const vt = (s, e = {
|
|
2746
2769
|
message: `Input not instance of ${s.name}`
|
|
2747
|
-
}) =>
|
|
2748
|
-
string: (s) =>
|
|
2749
|
-
number: (s) =>
|
|
2750
|
-
boolean: (s) =>
|
|
2770
|
+
}) => Le((t) => t instanceof s, e), Ue = C.create, ze = P.create, _t = xe.create, xt = $.create, qe = ee.create, kt = U.create, bt = ge.create, wt = te.create, Tt = se.create, St = G.create, Zt = L.create, Ct = A.create, Et = ve.create, Nt = E.create, Ot = x.create, Rt = x.strictCreate, It = ne.create, jt = ke.create, At = re.create, Mt = I.create, Pt = ae.create, $t = _e.create, Vt = z.create, Dt = Q.create, Lt = ie.create, Ut = oe.create, zt = V.create, qt = de.create, Bt = H.create, je = N.create, Wt = O.create, Qt = D.create, Yt = N.createWithPreprocess, Gt = fe.create, Ht = () => Ue().optional(), Jt = () => ze().optional(), Xt = () => qe().optional(), Kt = {
|
|
2771
|
+
string: (s) => C.create({ ...s, coerce: !0 }),
|
|
2772
|
+
number: (s) => P.create({ ...s, coerce: !0 }),
|
|
2773
|
+
boolean: (s) => ee.create({
|
|
2751
2774
|
...s,
|
|
2752
2775
|
coerce: !0
|
|
2753
2776
|
}),
|
|
2754
|
-
bigint: (s) =>
|
|
2755
|
-
date: (s) =>
|
|
2756
|
-
},
|
|
2777
|
+
bigint: (s) => $.create({ ...s, coerce: !0 }),
|
|
2778
|
+
date: (s) => U.create({ ...s, coerce: !0 })
|
|
2779
|
+
}, Ft = m;
|
|
2757
2780
|
var k = /* @__PURE__ */ Object.freeze({
|
|
2758
2781
|
__proto__: null,
|
|
2759
|
-
defaultErrorMap:
|
|
2760
|
-
setErrorMap:
|
|
2761
|
-
getErrorMap:
|
|
2762
|
-
makeIssue:
|
|
2763
|
-
EMPTY_PATH:
|
|
2782
|
+
defaultErrorMap: Y,
|
|
2783
|
+
setErrorMap: Fe,
|
|
2784
|
+
getErrorMap: pe,
|
|
2785
|
+
makeIssue: me,
|
|
2786
|
+
EMPTY_PATH: et,
|
|
2764
2787
|
addIssueToContext: l,
|
|
2765
|
-
ParseStatus:
|
|
2788
|
+
ParseStatus: w,
|
|
2766
2789
|
INVALID: m,
|
|
2767
|
-
DIRTY:
|
|
2768
|
-
OK:
|
|
2769
|
-
isAborted:
|
|
2770
|
-
isDirty:
|
|
2771
|
-
isValid:
|
|
2772
|
-
isAsync:
|
|
2790
|
+
DIRTY: W,
|
|
2791
|
+
OK: T,
|
|
2792
|
+
isAborted: Se,
|
|
2793
|
+
isDirty: Ze,
|
|
2794
|
+
isValid: K,
|
|
2795
|
+
isAsync: F,
|
|
2773
2796
|
get util() {
|
|
2774
2797
|
return _;
|
|
2775
2798
|
},
|
|
2776
2799
|
get objectUtil() {
|
|
2777
|
-
return
|
|
2800
|
+
return Te;
|
|
2778
2801
|
},
|
|
2779
2802
|
ZodParsedType: f,
|
|
2780
|
-
getParsedType:
|
|
2803
|
+
getParsedType: M,
|
|
2781
2804
|
ZodType: v,
|
|
2782
|
-
datetimeRegex:
|
|
2783
|
-
ZodString:
|
|
2784
|
-
ZodNumber:
|
|
2785
|
-
ZodBigInt:
|
|
2786
|
-
ZodBoolean:
|
|
2787
|
-
ZodDate:
|
|
2788
|
-
ZodSymbol:
|
|
2789
|
-
ZodUndefined:
|
|
2790
|
-
ZodNull:
|
|
2791
|
-
ZodAny:
|
|
2805
|
+
datetimeRegex: Ve,
|
|
2806
|
+
ZodString: C,
|
|
2807
|
+
ZodNumber: P,
|
|
2808
|
+
ZodBigInt: $,
|
|
2809
|
+
ZodBoolean: ee,
|
|
2810
|
+
ZodDate: U,
|
|
2811
|
+
ZodSymbol: ge,
|
|
2812
|
+
ZodUndefined: te,
|
|
2813
|
+
ZodNull: se,
|
|
2814
|
+
ZodAny: G,
|
|
2792
2815
|
ZodUnknown: L,
|
|
2793
|
-
ZodNever:
|
|
2794
|
-
ZodVoid:
|
|
2795
|
-
ZodArray:
|
|
2816
|
+
ZodNever: A,
|
|
2817
|
+
ZodVoid: ve,
|
|
2818
|
+
ZodArray: E,
|
|
2796
2819
|
ZodObject: x,
|
|
2797
|
-
ZodUnion:
|
|
2798
|
-
ZodDiscriminatedUnion:
|
|
2820
|
+
ZodUnion: ne,
|
|
2821
|
+
ZodDiscriminatedUnion: ke,
|
|
2799
2822
|
ZodIntersection: re,
|
|
2800
|
-
ZodTuple:
|
|
2801
|
-
ZodRecord:
|
|
2802
|
-
ZodMap:
|
|
2823
|
+
ZodTuple: I,
|
|
2824
|
+
ZodRecord: ae,
|
|
2825
|
+
ZodMap: _e,
|
|
2803
2826
|
ZodSet: z,
|
|
2804
|
-
ZodFunction:
|
|
2805
|
-
ZodLazy:
|
|
2806
|
-
ZodLiteral:
|
|
2807
|
-
ZodEnum:
|
|
2808
|
-
ZodNativeEnum:
|
|
2809
|
-
ZodPromise:
|
|
2810
|
-
ZodEffects:
|
|
2811
|
-
ZodTransformer:
|
|
2812
|
-
ZodOptional:
|
|
2813
|
-
ZodNullable:
|
|
2814
|
-
ZodDefault:
|
|
2815
|
-
ZodCatch:
|
|
2816
|
-
ZodNaN:
|
|
2817
|
-
BRAND:
|
|
2818
|
-
ZodBranded:
|
|
2819
|
-
ZodPipeline:
|
|
2820
|
-
ZodReadonly:
|
|
2821
|
-
custom:
|
|
2827
|
+
ZodFunction: Q,
|
|
2828
|
+
ZodLazy: ie,
|
|
2829
|
+
ZodLiteral: oe,
|
|
2830
|
+
ZodEnum: V,
|
|
2831
|
+
ZodNativeEnum: de,
|
|
2832
|
+
ZodPromise: H,
|
|
2833
|
+
ZodEffects: N,
|
|
2834
|
+
ZodTransformer: N,
|
|
2835
|
+
ZodOptional: O,
|
|
2836
|
+
ZodNullable: D,
|
|
2837
|
+
ZodDefault: ce,
|
|
2838
|
+
ZodCatch: ue,
|
|
2839
|
+
ZodNaN: xe,
|
|
2840
|
+
BRAND: yt,
|
|
2841
|
+
ZodBranded: Ee,
|
|
2842
|
+
ZodPipeline: fe,
|
|
2843
|
+
ZodReadonly: le,
|
|
2844
|
+
custom: Le,
|
|
2822
2845
|
Schema: v,
|
|
2823
2846
|
ZodSchema: v,
|
|
2824
|
-
late:
|
|
2847
|
+
late: gt,
|
|
2825
2848
|
get ZodFirstPartyTypeKind() {
|
|
2826
2849
|
return p;
|
|
2827
2850
|
},
|
|
2828
|
-
coerce:
|
|
2829
|
-
any:
|
|
2830
|
-
array:
|
|
2831
|
-
bigint:
|
|
2832
|
-
boolean:
|
|
2833
|
-
date:
|
|
2834
|
-
discriminatedUnion:
|
|
2835
|
-
effect:
|
|
2836
|
-
enum:
|
|
2837
|
-
function:
|
|
2838
|
-
instanceof:
|
|
2839
|
-
intersection:
|
|
2840
|
-
lazy:
|
|
2841
|
-
literal:
|
|
2842
|
-
map:
|
|
2843
|
-
nan:
|
|
2844
|
-
nativeEnum:
|
|
2845
|
-
never:
|
|
2846
|
-
null:
|
|
2847
|
-
nullable:
|
|
2848
|
-
number:
|
|
2849
|
-
object:
|
|
2850
|
-
oboolean:
|
|
2851
|
-
onumber:
|
|
2852
|
-
optional:
|
|
2853
|
-
ostring:
|
|
2854
|
-
pipeline:
|
|
2855
|
-
preprocess:
|
|
2856
|
-
promise:
|
|
2857
|
-
record:
|
|
2858
|
-
set:
|
|
2859
|
-
strictObject:
|
|
2860
|
-
string:
|
|
2861
|
-
symbol:
|
|
2862
|
-
transformer:
|
|
2863
|
-
tuple:
|
|
2864
|
-
undefined:
|
|
2865
|
-
union:
|
|
2866
|
-
unknown:
|
|
2867
|
-
void:
|
|
2868
|
-
NEVER:
|
|
2851
|
+
coerce: Kt,
|
|
2852
|
+
any: St,
|
|
2853
|
+
array: Nt,
|
|
2854
|
+
bigint: xt,
|
|
2855
|
+
boolean: qe,
|
|
2856
|
+
date: kt,
|
|
2857
|
+
discriminatedUnion: jt,
|
|
2858
|
+
effect: je,
|
|
2859
|
+
enum: zt,
|
|
2860
|
+
function: Dt,
|
|
2861
|
+
instanceof: vt,
|
|
2862
|
+
intersection: At,
|
|
2863
|
+
lazy: Lt,
|
|
2864
|
+
literal: Ut,
|
|
2865
|
+
map: $t,
|
|
2866
|
+
nan: _t,
|
|
2867
|
+
nativeEnum: qt,
|
|
2868
|
+
never: Ct,
|
|
2869
|
+
null: Tt,
|
|
2870
|
+
nullable: Qt,
|
|
2871
|
+
number: ze,
|
|
2872
|
+
object: Ot,
|
|
2873
|
+
oboolean: Xt,
|
|
2874
|
+
onumber: Jt,
|
|
2875
|
+
optional: Wt,
|
|
2876
|
+
ostring: Ht,
|
|
2877
|
+
pipeline: Gt,
|
|
2878
|
+
preprocess: Yt,
|
|
2879
|
+
promise: Bt,
|
|
2880
|
+
record: Pt,
|
|
2881
|
+
set: Vt,
|
|
2882
|
+
strictObject: Rt,
|
|
2883
|
+
string: Ue,
|
|
2884
|
+
symbol: bt,
|
|
2885
|
+
transformer: je,
|
|
2886
|
+
tuple: Mt,
|
|
2887
|
+
undefined: wt,
|
|
2888
|
+
union: It,
|
|
2889
|
+
unknown: Zt,
|
|
2890
|
+
void: Et,
|
|
2891
|
+
NEVER: Ft,
|
|
2869
2892
|
ZodIssueCode: d,
|
|
2870
|
-
quotelessJson:
|
|
2871
|
-
ZodError:
|
|
2893
|
+
quotelessJson: Ke,
|
|
2894
|
+
ZodError: S
|
|
2872
2895
|
});
|
|
2873
|
-
const
|
|
2896
|
+
const q = k.object({
|
|
2874
2897
|
type: k.literal("qp-bridge"),
|
|
2875
2898
|
id: k.string().optional()
|
|
2876
|
-
}),
|
|
2899
|
+
}), es = q.extend({
|
|
2877
2900
|
status: k.literal("answerChanged"),
|
|
2878
2901
|
question: k.string(),
|
|
2879
2902
|
answer: k.unknown()
|
|
2880
|
-
}),
|
|
2903
|
+
}), Be = q.extend({
|
|
2881
2904
|
status: k.literal("success")
|
|
2882
|
-
}),
|
|
2905
|
+
}), ts = q.extend({
|
|
2883
2906
|
status: k.literal("error"),
|
|
2884
2907
|
message: k.string()
|
|
2885
|
-
}),
|
|
2908
|
+
}), We = k.object({
|
|
2909
|
+
semanticColor: k.string().optional(),
|
|
2886
2910
|
label: k.string(),
|
|
2887
|
-
|
|
2888
|
-
|
|
2911
|
+
description: k.string(),
|
|
2912
|
+
disabled: k.boolean(),
|
|
2913
|
+
required: k.boolean(),
|
|
2914
|
+
hidden: k.boolean()
|
|
2915
|
+
}), ss = We.partial(), ns = q.extend({
|
|
2889
2916
|
action: k.literal("getQuestion"),
|
|
2890
2917
|
question: k.string()
|
|
2891
|
-
}),
|
|
2892
|
-
question:
|
|
2893
|
-
}),
|
|
2918
|
+
}), rs = Be.extend({
|
|
2919
|
+
question: We
|
|
2920
|
+
}), as = q.extend({
|
|
2921
|
+
action: k.literal("setQuestion"),
|
|
2922
|
+
question: k.string(),
|
|
2923
|
+
questionData: ss
|
|
2924
|
+
}), is = q.extend({
|
|
2894
2925
|
action: k.literal("setAnswer"),
|
|
2895
2926
|
question: k.string(),
|
|
2896
2927
|
answer: k.unknown()
|
|
2897
2928
|
});
|
|
2898
|
-
function
|
|
2899
|
-
return
|
|
2929
|
+
function os(s) {
|
|
2930
|
+
return es.safeParse(s).success;
|
|
2931
|
+
}
|
|
2932
|
+
function ds(s) {
|
|
2933
|
+
return q.safeParse(s).success;
|
|
2900
2934
|
}
|
|
2901
|
-
function
|
|
2902
|
-
return
|
|
2935
|
+
function Qe(s) {
|
|
2936
|
+
return Be.safeParse(s).success;
|
|
2903
2937
|
}
|
|
2904
|
-
function
|
|
2905
|
-
return
|
|
2938
|
+
function cs(s) {
|
|
2939
|
+
return ts.safeParse(s).success;
|
|
2906
2940
|
}
|
|
2907
|
-
function
|
|
2908
|
-
return
|
|
2941
|
+
function ps(s) {
|
|
2942
|
+
return ns.safeParse(s).success;
|
|
2909
2943
|
}
|
|
2910
|
-
function
|
|
2911
|
-
return
|
|
2944
|
+
function us(s) {
|
|
2945
|
+
return rs.safeParse(s).success;
|
|
2912
2946
|
}
|
|
2913
|
-
function
|
|
2914
|
-
return
|
|
2947
|
+
function ms(s) {
|
|
2948
|
+
return is.safeParse(s).success;
|
|
2915
2949
|
}
|
|
2916
|
-
function
|
|
2917
|
-
return
|
|
2950
|
+
function ys(s) {
|
|
2951
|
+
return as.safeParse(s).success;
|
|
2918
2952
|
}
|
|
2919
|
-
async function
|
|
2920
|
-
await
|
|
2953
|
+
async function gs(s, e) {
|
|
2954
|
+
await ls({
|
|
2921
2955
|
type: "qp-bridge",
|
|
2922
2956
|
action: "setAnswer",
|
|
2923
2957
|
question: s,
|
|
2924
2958
|
answer: e
|
|
2925
2959
|
});
|
|
2926
2960
|
}
|
|
2927
|
-
async function
|
|
2928
|
-
return await
|
|
2961
|
+
async function vs(s) {
|
|
2962
|
+
return await fs({
|
|
2929
2963
|
type: "qp-bridge",
|
|
2930
2964
|
action: "getQuestion",
|
|
2931
2965
|
question: s
|
|
2932
2966
|
});
|
|
2933
2967
|
}
|
|
2934
|
-
function
|
|
2968
|
+
async function _s(s, e) {
|
|
2969
|
+
await hs({
|
|
2970
|
+
type: "qp-bridge",
|
|
2971
|
+
action: "setQuestion",
|
|
2972
|
+
question: s,
|
|
2973
|
+
questionData: e
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
function xs(s) {
|
|
2935
2977
|
const e = (t) => {
|
|
2936
|
-
|
|
2978
|
+
os(t.data) && s(t.data.question, t.data.answer);
|
|
2937
2979
|
};
|
|
2938
2980
|
return window.addEventListener("message", e), {
|
|
2939
2981
|
cancelSubscription: () => {
|
|
@@ -2941,43 +2983,53 @@ function os(s) {
|
|
|
2941
2983
|
}
|
|
2942
2984
|
};
|
|
2943
2985
|
}
|
|
2944
|
-
async function
|
|
2945
|
-
return new Promise((t,
|
|
2946
|
-
const
|
|
2947
|
-
if (!
|
|
2986
|
+
async function Ne(s, e) {
|
|
2987
|
+
return new Promise((t, n) => {
|
|
2988
|
+
const r = Xe(), a = (i) => {
|
|
2989
|
+
if (!ds(i.data) || i.data.id !== r)
|
|
2948
2990
|
return;
|
|
2949
2991
|
const u = e(i.data);
|
|
2950
|
-
u !== null ? t(u) :
|
|
2992
|
+
u !== null ? t(u) : cs(i.data) ? n(new Error(i.data.message)) : n(new Error("Unknown message received")), window.removeEventListener("message", a);
|
|
2951
2993
|
};
|
|
2952
|
-
window.addEventListener("message", a), window.parent.postMessage({ ...s, id:
|
|
2994
|
+
window.addEventListener("message", a), window.parent.postMessage({ ...s, id: r }, "*");
|
|
2953
2995
|
});
|
|
2954
2996
|
}
|
|
2955
|
-
async function
|
|
2956
|
-
return
|
|
2957
|
-
if (!
|
|
2997
|
+
async function ls(s) {
|
|
2998
|
+
return Ne(s, (e) => {
|
|
2999
|
+
if (!Qe(e))
|
|
2958
3000
|
return null;
|
|
2959
3001
|
});
|
|
2960
3002
|
}
|
|
2961
|
-
async function
|
|
2962
|
-
return
|
|
3003
|
+
async function fs(s) {
|
|
3004
|
+
return Ne(s, (e) => us(e) ? e.question : null);
|
|
3005
|
+
}
|
|
3006
|
+
async function hs(s) {
|
|
3007
|
+
return Ne(s, (e) => {
|
|
3008
|
+
if (!Qe(e))
|
|
3009
|
+
return null;
|
|
3010
|
+
});
|
|
2963
3011
|
}
|
|
2964
3012
|
export {
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
3013
|
+
vs as getQuestion,
|
|
3014
|
+
ns as getQuestionRequestMessageSchema,
|
|
3015
|
+
rs as getQuestionSuccessResponseMessageSchema,
|
|
3016
|
+
cs as isErrorMessage,
|
|
3017
|
+
ps as isGetQuestionRequestMessage,
|
|
3018
|
+
us as isGetQuestionSuccessResponseMessage,
|
|
3019
|
+
os as isOnAnswerChangeMessage,
|
|
3020
|
+
ds as isQpBridgeMessage,
|
|
3021
|
+
ms as isSetAnswerRequestMessage,
|
|
3022
|
+
ys as isSetQuestionRequestMessage,
|
|
3023
|
+
Qe as isSuccessMessage,
|
|
3024
|
+
xs as onAnswerChange,
|
|
3025
|
+
es as onAnswerChangeMessageSchema,
|
|
3026
|
+
q as qpBridgeMessageSchema,
|
|
3027
|
+
ss as questionOptionalScheme,
|
|
3028
|
+
We as questionSchema,
|
|
3029
|
+
ts as responseErrorMessageSchema,
|
|
3030
|
+
Be as responseSuccessMessageSchema,
|
|
3031
|
+
gs as setAnswer,
|
|
3032
|
+
is as setAnswerRequestMessageSchema,
|
|
3033
|
+
_s as setQuestion,
|
|
3034
|
+
as as setQuestionRequestMessageSchema
|
|
2983
3035
|
};
|