@authhero/cloudflare-adapter 1.25.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare-adapter.cjs +1 -1
- package/dist/cloudflare-adapter.d.ts +38 -0
- package/dist/cloudflare-adapter.mjs +835 -765
- package/package.json +4 -4
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var ct = Object.defineProperty;
|
|
2
|
+
var dt = (r, e, t) => e in r ? ct(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var ke = (r, e, t) => dt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { verificationMethodsSchema as ut } from "@authhero/adapter-interfaces";
|
|
5
5
|
import lt from "wretch";
|
|
6
6
|
function ft(r, e) {
|
|
7
7
|
var t = {};
|
|
8
|
-
for (var
|
|
8
|
+
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
|
|
9
9
|
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
10
|
-
for (var
|
|
11
|
-
e.indexOf(n
|
|
10
|
+
for (var n = 0, s = Object.getOwnPropertySymbols(r); n < s.length; n++)
|
|
11
|
+
e.indexOf(s[n]) < 0 && Object.prototype.propertyIsEnumerable.call(r, s[n]) && (t[s[n]] = r[s[n]]);
|
|
12
12
|
return t;
|
|
13
13
|
}
|
|
14
14
|
function ht(r, e) {
|
|
15
15
|
var t;
|
|
16
16
|
return ((t = r == null ? void 0 : r._def) === null || t === void 0 ? void 0 : t.typeName) === e;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function ne(r, e) {
|
|
19
19
|
const t = r.ZodType.prototype[e];
|
|
20
|
-
r.ZodType.prototype[e] = function(...
|
|
21
|
-
const
|
|
22
|
-
return
|
|
20
|
+
r.ZodType.prototype[e] = function(...s) {
|
|
21
|
+
const n = t.apply(this, s);
|
|
22
|
+
return n._def.openapi = this._def.openapi, n;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function pt(r) {
|
|
26
26
|
if (typeof r.ZodType.prototype.openapi < "u")
|
|
27
27
|
return;
|
|
28
|
-
r.ZodType.prototype.openapi = function(
|
|
29
|
-
var i, o,
|
|
30
|
-
const
|
|
31
|
-
param: Object.assign(Object.assign({}, (b = (
|
|
28
|
+
r.ZodType.prototype.openapi = function(n, a) {
|
|
29
|
+
var i, o, c, d, h, b;
|
|
30
|
+
const Z = typeof n == "string" ? a : n, w = Z ?? {}, { param: M } = w, Re = ft(w, ["param"]), D = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof n == "string" ? { refId: n } : void 0), be = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), Re), !((d = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || d === void 0) && d.param || M ? {
|
|
31
|
+
param: Object.assign(Object.assign({}, (b = (h = this._def.openapi) === null || h === void 0 ? void 0 : h.metadata) === null || b === void 0 ? void 0 : b.param), M)
|
|
32
32
|
} : void 0), B = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(D).length > 0 ? { _internal: D } : void 0), Object.keys(be).length > 0 ? { metadata: be } : void 0) }));
|
|
33
33
|
if (ht(this, "ZodObject")) {
|
|
34
34
|
const re = this.extend;
|
|
35
|
-
B.extend = function(...
|
|
36
|
-
var
|
|
37
|
-
const
|
|
38
|
-
return
|
|
35
|
+
B.extend = function(...se) {
|
|
36
|
+
var Ne, Ie, $e, Pe, Me, De;
|
|
37
|
+
const Ve = re.apply(this, se);
|
|
38
|
+
return Ve._def.openapi = {
|
|
39
39
|
_internal: {
|
|
40
|
-
extendedFrom: !((
|
|
40
|
+
extendedFrom: !((Ie = (Ne = this._def.openapi) === null || Ne === void 0 ? void 0 : Ne._internal) === null || Ie === void 0) && Ie.refId ? { refId: (Pe = ($e = this._def.openapi) === null || $e === void 0 ? void 0 : $e._internal) === null || Pe === void 0 ? void 0 : Pe.refId, schema: this } : (Me = this._def.openapi) === null || Me === void 0 ? void 0 : Me._internal.extendedFrom
|
|
41
41
|
},
|
|
42
|
-
metadata: (
|
|
43
|
-
},
|
|
42
|
+
metadata: (De = Ve._def.openapi) === null || De === void 0 ? void 0 : De.metadata
|
|
43
|
+
}, Ve;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
return B;
|
|
47
|
-
},
|
|
47
|
+
}, ne(r, "optional"), ne(r, "nullable"), ne(r, "default"), ne(r, "transform"), ne(r, "refine");
|
|
48
48
|
const e = r.ZodObject.prototype.deepPartial;
|
|
49
49
|
r.ZodObject.prototype.deepPartial = function() {
|
|
50
|
-
const
|
|
51
|
-
return Object.entries(i).forEach(([o,
|
|
52
|
-
var
|
|
53
|
-
|
|
50
|
+
const n = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
51
|
+
return Object.entries(i).forEach(([o, c]) => {
|
|
52
|
+
var d, h;
|
|
53
|
+
c._def.openapi = (h = (d = n[o]) === null || d === void 0 ? void 0 : d._def) === null || h === void 0 ? void 0 : h.openapi;
|
|
54
54
|
}), a._def.openapi = void 0, a;
|
|
55
55
|
};
|
|
56
56
|
const t = r.ZodObject.prototype.pick;
|
|
57
|
-
r.ZodObject.prototype.pick = function(...
|
|
58
|
-
const a = t.apply(this,
|
|
57
|
+
r.ZodObject.prototype.pick = function(...n) {
|
|
58
|
+
const a = t.apply(this, n);
|
|
59
59
|
return a._def.openapi = void 0, a;
|
|
60
60
|
};
|
|
61
|
-
const
|
|
62
|
-
r.ZodObject.prototype.omit = function(...
|
|
63
|
-
const a =
|
|
61
|
+
const s = r.ZodObject.prototype.omit;
|
|
62
|
+
r.ZodObject.prototype.omit = function(...n) {
|
|
63
|
+
const a = s.apply(this, n);
|
|
64
64
|
return a._def.openapi = void 0, a;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
var H = class extends Error {
|
|
68
68
|
constructor(e = 500, t) {
|
|
69
69
|
super(t == null ? void 0 : t.message, { cause: t == null ? void 0 : t.cause });
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
ke(this, "res");
|
|
71
|
+
ke(this, "status");
|
|
72
72
|
this.res = t == null ? void 0 : t.res, this.status = e;
|
|
73
73
|
}
|
|
74
74
|
getResponse() {
|
|
@@ -83,39 +83,39 @@ var H = class extends Error {
|
|
|
83
83
|
new Set(".\\+*[^]$()");
|
|
84
84
|
var x;
|
|
85
85
|
(function(r) {
|
|
86
|
-
r.assertEqual = (
|
|
87
|
-
function e(
|
|
86
|
+
r.assertEqual = (n) => n;
|
|
87
|
+
function e(n) {
|
|
88
88
|
}
|
|
89
89
|
r.assertIs = e;
|
|
90
|
-
function t(
|
|
90
|
+
function t(n) {
|
|
91
91
|
throw new Error();
|
|
92
92
|
}
|
|
93
|
-
r.assertNever = t, r.arrayToEnum = (
|
|
93
|
+
r.assertNever = t, r.arrayToEnum = (n) => {
|
|
94
94
|
const a = {};
|
|
95
|
-
for (const i of
|
|
95
|
+
for (const i of n)
|
|
96
96
|
a[i] = i;
|
|
97
97
|
return a;
|
|
98
|
-
}, r.getValidEnumValues = (
|
|
99
|
-
const a = r.objectKeys(
|
|
98
|
+
}, r.getValidEnumValues = (n) => {
|
|
99
|
+
const a = r.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
100
100
|
for (const o of a)
|
|
101
|
-
i[o] =
|
|
101
|
+
i[o] = n[o];
|
|
102
102
|
return r.objectValues(i);
|
|
103
|
-
}, r.objectValues = (
|
|
104
|
-
return
|
|
105
|
-
}), r.objectKeys = typeof Object.keys == "function" ? (
|
|
103
|
+
}, r.objectValues = (n) => r.objectKeys(n).map(function(a) {
|
|
104
|
+
return n[a];
|
|
105
|
+
}), r.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
106
106
|
const a = [];
|
|
107
|
-
for (const i in
|
|
108
|
-
Object.prototype.hasOwnProperty.call(
|
|
107
|
+
for (const i in n)
|
|
108
|
+
Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
|
|
109
109
|
return a;
|
|
110
|
-
}, r.find = (
|
|
111
|
-
for (const i of
|
|
110
|
+
}, r.find = (n, a) => {
|
|
111
|
+
for (const i of n)
|
|
112
112
|
if (a(i))
|
|
113
113
|
return i;
|
|
114
|
-
}, r.isInteger = typeof Number.isInteger == "function" ? (
|
|
115
|
-
function n
|
|
116
|
-
return
|
|
114
|
+
}, r.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
115
|
+
function s(n, a = " | ") {
|
|
116
|
+
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
117
117
|
}
|
|
118
|
-
r.joinValues =
|
|
118
|
+
r.joinValues = s, r.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
119
119
|
})(x || (x = {}));
|
|
120
120
|
var Be;
|
|
121
121
|
(function(r) {
|
|
@@ -185,15 +185,15 @@ const f = x.arrayToEnum([
|
|
|
185
185
|
"not_multiple_of",
|
|
186
186
|
"not_finite"
|
|
187
187
|
]), mt = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
188
|
-
class
|
|
188
|
+
class C extends Error {
|
|
189
189
|
get errors() {
|
|
190
190
|
return this.issues;
|
|
191
191
|
}
|
|
192
192
|
constructor(e) {
|
|
193
|
-
super(), this.issues = [], this.addIssue = (
|
|
194
|
-
this.issues = [...this.issues,
|
|
195
|
-
}, this.addIssues = (
|
|
196
|
-
this.issues = [...this.issues, ...
|
|
193
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
194
|
+
this.issues = [...this.issues, s];
|
|
195
|
+
}, this.addIssues = (s = []) => {
|
|
196
|
+
this.issues = [...this.issues, ...s];
|
|
197
197
|
};
|
|
198
198
|
const t = new.target.prototype;
|
|
199
199
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -201,28 +201,28 @@ class S extends Error {
|
|
|
201
201
|
format(e) {
|
|
202
202
|
const t = e || function(a) {
|
|
203
203
|
return a.message;
|
|
204
|
-
},
|
|
204
|
+
}, s = { _errors: [] }, n = (a) => {
|
|
205
205
|
for (const i of a.issues)
|
|
206
206
|
if (i.code === "invalid_union")
|
|
207
|
-
i.unionErrors.map(
|
|
207
|
+
i.unionErrors.map(n);
|
|
208
208
|
else if (i.code === "invalid_return_type")
|
|
209
|
-
|
|
209
|
+
n(i.returnTypeError);
|
|
210
210
|
else if (i.code === "invalid_arguments")
|
|
211
|
-
|
|
211
|
+
n(i.argumentsError);
|
|
212
212
|
else if (i.path.length === 0)
|
|
213
|
-
|
|
213
|
+
s._errors.push(t(i));
|
|
214
214
|
else {
|
|
215
|
-
let o =
|
|
216
|
-
for (;
|
|
217
|
-
const
|
|
218
|
-
|
|
215
|
+
let o = s, c = 0;
|
|
216
|
+
for (; c < i.path.length; ) {
|
|
217
|
+
const d = i.path[c];
|
|
218
|
+
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(t(i))) : o[d] = o[d] || { _errors: [] }, o = o[d], c++;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
|
-
return
|
|
222
|
+
return n(this), s;
|
|
223
223
|
}
|
|
224
224
|
static assert(e) {
|
|
225
|
-
if (!(e instanceof
|
|
225
|
+
if (!(e instanceof C))
|
|
226
226
|
throw new Error(`Not a ZodError: ${e}`);
|
|
227
227
|
}
|
|
228
228
|
toString() {
|
|
@@ -235,16 +235,16 @@ class S extends Error {
|
|
|
235
235
|
return this.issues.length === 0;
|
|
236
236
|
}
|
|
237
237
|
flatten(e = (t) => t.message) {
|
|
238
|
-
const t = {},
|
|
239
|
-
for (const
|
|
240
|
-
|
|
241
|
-
return { formErrors:
|
|
238
|
+
const t = {}, s = [];
|
|
239
|
+
for (const n of this.issues)
|
|
240
|
+
n.path.length > 0 ? (t[n.path[0]] = t[n.path[0]] || [], t[n.path[0]].push(e(n))) : s.push(e(n));
|
|
241
|
+
return { formErrors: s, fieldErrors: t };
|
|
242
242
|
}
|
|
243
243
|
get formErrors() {
|
|
244
244
|
return this.flatten();
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
C.create = (r) => new C(r);
|
|
248
248
|
const Q = (r, e) => {
|
|
249
249
|
let t;
|
|
250
250
|
switch (r.code) {
|
|
@@ -301,36 +301,36 @@ const Q = (r, e) => {
|
|
|
301
301
|
}
|
|
302
302
|
return { message: t };
|
|
303
303
|
};
|
|
304
|
-
let
|
|
304
|
+
let Ke = Q;
|
|
305
305
|
function _t(r) {
|
|
306
|
-
|
|
306
|
+
Ke = r;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
309
|
-
return
|
|
308
|
+
function we() {
|
|
309
|
+
return Ke;
|
|
310
310
|
}
|
|
311
|
-
const
|
|
312
|
-
const { data: e, path: t, errorMaps:
|
|
313
|
-
...
|
|
311
|
+
const Te = (r) => {
|
|
312
|
+
const { data: e, path: t, errorMaps: s, issueData: n } = r, a = [...t, ...n.path || []], i = {
|
|
313
|
+
...n,
|
|
314
314
|
path: a
|
|
315
315
|
};
|
|
316
|
-
if (
|
|
316
|
+
if (n.message !== void 0)
|
|
317
317
|
return {
|
|
318
|
-
...
|
|
318
|
+
...n,
|
|
319
319
|
path: a,
|
|
320
|
-
message:
|
|
320
|
+
message: n.message
|
|
321
321
|
};
|
|
322
322
|
let o = "";
|
|
323
|
-
const
|
|
324
|
-
for (const
|
|
325
|
-
o =
|
|
323
|
+
const c = s.filter((d) => !!d).slice().reverse();
|
|
324
|
+
for (const d of c)
|
|
325
|
+
o = d(i, { data: e, defaultError: o }).message;
|
|
326
326
|
return {
|
|
327
|
-
...
|
|
327
|
+
...n,
|
|
328
328
|
path: a,
|
|
329
329
|
message: o
|
|
330
330
|
};
|
|
331
331
|
}, yt = [];
|
|
332
332
|
function l(r, e) {
|
|
333
|
-
const t =
|
|
333
|
+
const t = we(), s = Te({
|
|
334
334
|
issueData: e,
|
|
335
335
|
data: r.data,
|
|
336
336
|
path: r.path,
|
|
@@ -343,9 +343,9 @@ function l(r, e) {
|
|
|
343
343
|
// then global override map
|
|
344
344
|
t === Q ? void 0 : Q
|
|
345
345
|
// then global default map
|
|
346
|
-
].filter((
|
|
346
|
+
].filter((n) => !!n)
|
|
347
347
|
});
|
|
348
|
-
r.common.issues.push(
|
|
348
|
+
r.common.issues.push(s);
|
|
349
349
|
}
|
|
350
350
|
class T {
|
|
351
351
|
constructor() {
|
|
@@ -358,45 +358,45 @@ class T {
|
|
|
358
358
|
this.value !== "aborted" && (this.value = "aborted");
|
|
359
359
|
}
|
|
360
360
|
static mergeArray(e, t) {
|
|
361
|
-
const
|
|
362
|
-
for (const
|
|
363
|
-
if (
|
|
361
|
+
const s = [];
|
|
362
|
+
for (const n of t) {
|
|
363
|
+
if (n.status === "aborted")
|
|
364
364
|
return y;
|
|
365
|
-
|
|
365
|
+
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
366
366
|
}
|
|
367
|
-
return { status: e.value, value:
|
|
367
|
+
return { status: e.value, value: s };
|
|
368
368
|
}
|
|
369
369
|
static async mergeObjectAsync(e, t) {
|
|
370
|
-
const
|
|
371
|
-
for (const
|
|
372
|
-
const a = await
|
|
373
|
-
|
|
370
|
+
const s = [];
|
|
371
|
+
for (const n of t) {
|
|
372
|
+
const a = await n.key, i = await n.value;
|
|
373
|
+
s.push({
|
|
374
374
|
key: a,
|
|
375
375
|
value: i
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
|
-
return T.mergeObjectSync(e,
|
|
378
|
+
return T.mergeObjectSync(e, s);
|
|
379
379
|
}
|
|
380
380
|
static mergeObjectSync(e, t) {
|
|
381
|
-
const
|
|
382
|
-
for (const
|
|
383
|
-
const { key: a, value: i } =
|
|
381
|
+
const s = {};
|
|
382
|
+
for (const n of t) {
|
|
383
|
+
const { key: a, value: i } = n;
|
|
384
384
|
if (a.status === "aborted" || i.status === "aborted")
|
|
385
385
|
return y;
|
|
386
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" ||
|
|
386
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[a.value] = i.value);
|
|
387
387
|
}
|
|
388
|
-
return { status: e.value, value:
|
|
388
|
+
return { status: e.value, value: s };
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
const y = Object.freeze({
|
|
392
392
|
status: "aborted"
|
|
393
|
-
}),
|
|
394
|
-
function
|
|
395
|
-
if (typeof e == "function" ? r !== e || !
|
|
393
|
+
}), K = (r) => ({ status: "dirty", value: r }), S = (r) => ({ status: "valid", value: r }), Fe = (r) => r.status === "aborted", qe = (r) => r.status === "dirty", q = (r) => r.status === "valid", oe = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
394
|
+
function Se(r, e, t, s) {
|
|
395
|
+
if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
396
396
|
return e.get(r);
|
|
397
397
|
}
|
|
398
|
-
function
|
|
399
|
-
if (typeof e == "function" ? r !== e || !
|
|
398
|
+
function Xe(r, e, t, s, n) {
|
|
399
|
+
if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
400
400
|
return e.set(r, t), t;
|
|
401
401
|
}
|
|
402
402
|
var m;
|
|
@@ -405,15 +405,15 @@ var m;
|
|
|
405
405
|
})(m || (m = {}));
|
|
406
406
|
var ae, ie;
|
|
407
407
|
class R {
|
|
408
|
-
constructor(e, t,
|
|
409
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
408
|
+
constructor(e, t, s, n) {
|
|
409
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
410
410
|
}
|
|
411
411
|
get path() {
|
|
412
412
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
const He = (r, e) => {
|
|
416
|
-
if (
|
|
416
|
+
if (q(e))
|
|
417
417
|
return { success: !0, data: e.value };
|
|
418
418
|
if (!r.common.issues.length)
|
|
419
419
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -422,7 +422,7 @@ const He = (r, e) => {
|
|
|
422
422
|
get error() {
|
|
423
423
|
if (this._error)
|
|
424
424
|
return this._error;
|
|
425
|
-
const t = new
|
|
425
|
+
const t = new C(r.common.issues);
|
|
426
426
|
return this._error = t, this._error;
|
|
427
427
|
}
|
|
428
428
|
};
|
|
@@ -430,14 +430,14 @@ const He = (r, e) => {
|
|
|
430
430
|
function v(r) {
|
|
431
431
|
if (!r)
|
|
432
432
|
return {};
|
|
433
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
434
|
-
if (e && (t ||
|
|
433
|
+
const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = r;
|
|
434
|
+
if (e && (t || s))
|
|
435
435
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
436
|
-
return e ? { errorMap: e, description:
|
|
437
|
-
var
|
|
438
|
-
const { message:
|
|
439
|
-
return i.code === "invalid_enum_value" ? { message:
|
|
440
|
-
}, description:
|
|
436
|
+
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
437
|
+
var c, d;
|
|
438
|
+
const { message: h } = r;
|
|
439
|
+
return i.code === "invalid_enum_value" ? { message: h ?? o.defaultError } : typeof o.data > "u" ? { message: (c = h ?? s) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (d = h ?? t) !== null && d !== void 0 ? d : o.defaultError };
|
|
440
|
+
}, description: n };
|
|
441
441
|
}
|
|
442
442
|
class g {
|
|
443
443
|
get description() {
|
|
@@ -480,17 +480,17 @@ class g {
|
|
|
480
480
|
return Promise.resolve(t);
|
|
481
481
|
}
|
|
482
482
|
parse(e, t) {
|
|
483
|
-
const
|
|
484
|
-
if (
|
|
485
|
-
return
|
|
486
|
-
throw
|
|
483
|
+
const s = this.safeParse(e, t);
|
|
484
|
+
if (s.success)
|
|
485
|
+
return s.data;
|
|
486
|
+
throw s.error;
|
|
487
487
|
}
|
|
488
488
|
safeParse(e, t) {
|
|
489
|
-
var
|
|
490
|
-
const
|
|
489
|
+
var s;
|
|
490
|
+
const n = {
|
|
491
491
|
common: {
|
|
492
492
|
issues: [],
|
|
493
|
-
async: (
|
|
493
|
+
async: (s = t == null ? void 0 : t.async) !== null && s !== void 0 ? s : !1,
|
|
494
494
|
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
495
495
|
},
|
|
496
496
|
path: (t == null ? void 0 : t.path) || [],
|
|
@@ -498,12 +498,12 @@ class g {
|
|
|
498
498
|
parent: null,
|
|
499
499
|
data: e,
|
|
500
500
|
parsedType: $(e)
|
|
501
|
-
}, a = this._parseSync({ data: e, path:
|
|
502
|
-
return He(
|
|
501
|
+
}, a = this._parseSync({ data: e, path: n.path, parent: n });
|
|
502
|
+
return He(n, a);
|
|
503
503
|
}
|
|
504
504
|
"~validate"(e) {
|
|
505
|
-
var t,
|
|
506
|
-
const
|
|
505
|
+
var t, s;
|
|
506
|
+
const n = {
|
|
507
507
|
common: {
|
|
508
508
|
issues: [],
|
|
509
509
|
async: !!this["~standard"].async
|
|
@@ -516,32 +516,32 @@ class g {
|
|
|
516
516
|
};
|
|
517
517
|
if (!this["~standard"].async)
|
|
518
518
|
try {
|
|
519
|
-
const a = this._parseSync({ data: e, path: [], parent:
|
|
520
|
-
return
|
|
519
|
+
const a = this._parseSync({ data: e, path: [], parent: n });
|
|
520
|
+
return q(a) ? {
|
|
521
521
|
value: a.value
|
|
522
522
|
} : {
|
|
523
|
-
issues:
|
|
523
|
+
issues: n.common.issues
|
|
524
524
|
};
|
|
525
525
|
} catch (a) {
|
|
526
|
-
!((
|
|
526
|
+
!((s = (t = a == null ? void 0 : a.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || s === void 0) && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
527
527
|
issues: [],
|
|
528
528
|
async: !0
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
531
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((a) => q(a) ? {
|
|
532
532
|
value: a.value
|
|
533
533
|
} : {
|
|
534
|
-
issues:
|
|
534
|
+
issues: n.common.issues
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
async parseAsync(e, t) {
|
|
538
|
-
const
|
|
539
|
-
if (
|
|
540
|
-
return
|
|
541
|
-
throw
|
|
538
|
+
const s = await this.safeParseAsync(e, t);
|
|
539
|
+
if (s.success)
|
|
540
|
+
return s.data;
|
|
541
|
+
throw s.error;
|
|
542
542
|
}
|
|
543
543
|
async safeParseAsync(e, t) {
|
|
544
|
-
const
|
|
544
|
+
const s = {
|
|
545
545
|
common: {
|
|
546
546
|
issues: [],
|
|
547
547
|
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
@@ -552,21 +552,21 @@ class g {
|
|
|
552
552
|
parent: null,
|
|
553
553
|
data: e,
|
|
554
554
|
parsedType: $(e)
|
|
555
|
-
},
|
|
556
|
-
return He(
|
|
555
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), a = await (oe(n) ? n : Promise.resolve(n));
|
|
556
|
+
return He(s, a);
|
|
557
557
|
}
|
|
558
558
|
refine(e, t) {
|
|
559
|
-
const
|
|
560
|
-
return this._refinement((
|
|
561
|
-
const i = e(
|
|
559
|
+
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
560
|
+
return this._refinement((n, a) => {
|
|
561
|
+
const i = e(n), o = () => a.addIssue({
|
|
562
562
|
code: u.custom,
|
|
563
|
-
...n
|
|
563
|
+
...s(n)
|
|
564
564
|
});
|
|
565
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((
|
|
565
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
566
566
|
});
|
|
567
567
|
}
|
|
568
568
|
refinement(e, t) {
|
|
569
|
-
return this._refinement((
|
|
569
|
+
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
|
|
570
570
|
}
|
|
571
571
|
_refinement(e) {
|
|
572
572
|
return new A({
|
|
@@ -595,7 +595,7 @@ class g {
|
|
|
595
595
|
return this.nullable().optional();
|
|
596
596
|
}
|
|
597
597
|
array() {
|
|
598
|
-
return
|
|
598
|
+
return j.create(this);
|
|
599
599
|
}
|
|
600
600
|
promise() {
|
|
601
601
|
return te.create(this, this._def);
|
|
@@ -659,9 +659,9 @@ class g {
|
|
|
659
659
|
return this.safeParse(null).success;
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
-
const vt = /^c[^\s-]{8,}$/i, gt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, bt = /^[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, kt = /^[a-z0-9_-]{21}$/i, wt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Tt = /^[-+]?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)?)??$/,
|
|
662
|
+
const vt = /^c[^\s-]{8,}$/i, gt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, bt = /^[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, kt = /^[a-z0-9_-]{21}$/i, wt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Tt = /^[-+]?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)?)??$/, St = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Zt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
663
663
|
let Le;
|
|
664
|
-
const
|
|
664
|
+
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])$/, Ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, jt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, At = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Et = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Rt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Qe = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Nt = new RegExp(`^${Qe}$`);
|
|
665
665
|
function et(r) {
|
|
666
666
|
let e = "[0-5]\\d";
|
|
667
667
|
r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
@@ -677,22 +677,22 @@ function tt(r) {
|
|
|
677
677
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
678
678
|
}
|
|
679
679
|
function $t(r, e) {
|
|
680
|
-
return !!((e === "v4" || !e) &&
|
|
680
|
+
return !!((e === "v4" || !e) && Ct.test(r) || (e === "v6" || !e) && jt.test(r));
|
|
681
681
|
}
|
|
682
|
-
function
|
|
682
|
+
function Pt(r, e) {
|
|
683
683
|
if (!wt.test(r))
|
|
684
684
|
return !1;
|
|
685
685
|
try {
|
|
686
|
-
const [t] = r.split("."),
|
|
687
|
-
return !(typeof
|
|
686
|
+
const [t] = r.split("."), s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
687
|
+
return !(typeof n != "object" || n === null || !n.typ || !n.alg || e && n.alg !== e);
|
|
688
688
|
} catch {
|
|
689
689
|
return !1;
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
return !!((e === "v4" || !e) &&
|
|
692
|
+
function Mt(r, e) {
|
|
693
|
+
return !!((e === "v4" || !e) && Ot.test(r) || (e === "v6" || !e) && At.test(r));
|
|
694
694
|
}
|
|
695
|
-
class
|
|
695
|
+
class O extends g {
|
|
696
696
|
_parse(e) {
|
|
697
697
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
698
698
|
const a = this._getOrReturnCtx(e);
|
|
@@ -702,160 +702,160 @@ class j extends g {
|
|
|
702
702
|
received: a.parsedType
|
|
703
703
|
}), y;
|
|
704
704
|
}
|
|
705
|
-
const
|
|
706
|
-
let
|
|
705
|
+
const s = new T();
|
|
706
|
+
let n;
|
|
707
707
|
for (const a of this._def.checks)
|
|
708
708
|
if (a.kind === "min")
|
|
709
|
-
e.data.length < a.value && (
|
|
709
|
+
e.data.length < a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
710
710
|
code: u.too_small,
|
|
711
711
|
minimum: a.value,
|
|
712
712
|
type: "string",
|
|
713
713
|
inclusive: !0,
|
|
714
714
|
exact: !1,
|
|
715
715
|
message: a.message
|
|
716
|
-
}),
|
|
716
|
+
}), s.dirty());
|
|
717
717
|
else if (a.kind === "max")
|
|
718
|
-
e.data.length > a.value && (
|
|
718
|
+
e.data.length > a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
719
719
|
code: u.too_big,
|
|
720
720
|
maximum: a.value,
|
|
721
721
|
type: "string",
|
|
722
722
|
inclusive: !0,
|
|
723
723
|
exact: !1,
|
|
724
724
|
message: a.message
|
|
725
|
-
}),
|
|
725
|
+
}), s.dirty());
|
|
726
726
|
else if (a.kind === "length") {
|
|
727
727
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
728
|
-
(i || o) && (
|
|
728
|
+
(i || o) && (n = this._getOrReturnCtx(e, n), i ? l(n, {
|
|
729
729
|
code: u.too_big,
|
|
730
730
|
maximum: a.value,
|
|
731
731
|
type: "string",
|
|
732
732
|
inclusive: !0,
|
|
733
733
|
exact: !0,
|
|
734
734
|
message: a.message
|
|
735
|
-
}) : o && l(
|
|
735
|
+
}) : o && l(n, {
|
|
736
736
|
code: u.too_small,
|
|
737
737
|
minimum: a.value,
|
|
738
738
|
type: "string",
|
|
739
739
|
inclusive: !0,
|
|
740
740
|
exact: !0,
|
|
741
741
|
message: a.message
|
|
742
|
-
}),
|
|
742
|
+
}), s.dirty());
|
|
743
743
|
} else if (a.kind === "email")
|
|
744
|
-
|
|
744
|
+
St.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
745
745
|
validation: "email",
|
|
746
746
|
code: u.invalid_string,
|
|
747
747
|
message: a.message
|
|
748
|
-
}),
|
|
748
|
+
}), s.dirty());
|
|
749
749
|
else if (a.kind === "emoji")
|
|
750
|
-
Le || (Le = new RegExp(
|
|
750
|
+
Le || (Le = new RegExp(Zt, "u")), Le.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
751
751
|
validation: "emoji",
|
|
752
752
|
code: u.invalid_string,
|
|
753
753
|
message: a.message
|
|
754
|
-
}),
|
|
754
|
+
}), s.dirty());
|
|
755
755
|
else if (a.kind === "uuid")
|
|
756
|
-
bt.test(e.data) || (
|
|
756
|
+
bt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
757
757
|
validation: "uuid",
|
|
758
758
|
code: u.invalid_string,
|
|
759
759
|
message: a.message
|
|
760
|
-
}),
|
|
760
|
+
}), s.dirty());
|
|
761
761
|
else if (a.kind === "nanoid")
|
|
762
|
-
kt.test(e.data) || (
|
|
762
|
+
kt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
763
763
|
validation: "nanoid",
|
|
764
764
|
code: u.invalid_string,
|
|
765
765
|
message: a.message
|
|
766
|
-
}),
|
|
766
|
+
}), s.dirty());
|
|
767
767
|
else if (a.kind === "cuid")
|
|
768
|
-
vt.test(e.data) || (
|
|
768
|
+
vt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
769
769
|
validation: "cuid",
|
|
770
770
|
code: u.invalid_string,
|
|
771
771
|
message: a.message
|
|
772
|
-
}),
|
|
772
|
+
}), s.dirty());
|
|
773
773
|
else if (a.kind === "cuid2")
|
|
774
|
-
gt.test(e.data) || (
|
|
774
|
+
gt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
775
775
|
validation: "cuid2",
|
|
776
776
|
code: u.invalid_string,
|
|
777
777
|
message: a.message
|
|
778
|
-
}),
|
|
778
|
+
}), s.dirty());
|
|
779
779
|
else if (a.kind === "ulid")
|
|
780
|
-
xt.test(e.data) || (
|
|
780
|
+
xt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
781
781
|
validation: "ulid",
|
|
782
782
|
code: u.invalid_string,
|
|
783
783
|
message: a.message
|
|
784
|
-
}),
|
|
784
|
+
}), s.dirty());
|
|
785
785
|
else if (a.kind === "url")
|
|
786
786
|
try {
|
|
787
787
|
new URL(e.data);
|
|
788
788
|
} catch {
|
|
789
|
-
|
|
789
|
+
n = this._getOrReturnCtx(e, n), l(n, {
|
|
790
790
|
validation: "url",
|
|
791
791
|
code: u.invalid_string,
|
|
792
792
|
message: a.message
|
|
793
|
-
}),
|
|
793
|
+
}), s.dirty();
|
|
794
794
|
}
|
|
795
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (
|
|
795
|
+
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
796
796
|
validation: "regex",
|
|
797
797
|
code: u.invalid_string,
|
|
798
798
|
message: a.message
|
|
799
|
-
}),
|
|
799
|
+
}), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
800
800
|
code: u.invalid_string,
|
|
801
801
|
validation: { includes: a.value, position: a.position },
|
|
802
802
|
message: a.message
|
|
803
|
-
}),
|
|
803
|
+
}), s.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) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
804
804
|
code: u.invalid_string,
|
|
805
805
|
validation: { startsWith: a.value },
|
|
806
806
|
message: a.message
|
|
807
|
-
}),
|
|
807
|
+
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
808
808
|
code: u.invalid_string,
|
|
809
809
|
validation: { endsWith: a.value },
|
|
810
810
|
message: a.message
|
|
811
|
-
}),
|
|
811
|
+
}), s.dirty()) : a.kind === "datetime" ? tt(a).test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
812
812
|
code: u.invalid_string,
|
|
813
813
|
validation: "datetime",
|
|
814
814
|
message: a.message
|
|
815
|
-
}),
|
|
815
|
+
}), s.dirty()) : a.kind === "date" ? Nt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
816
816
|
code: u.invalid_string,
|
|
817
817
|
validation: "date",
|
|
818
818
|
message: a.message
|
|
819
|
-
}),
|
|
819
|
+
}), s.dirty()) : a.kind === "time" ? It(a).test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
820
820
|
code: u.invalid_string,
|
|
821
821
|
validation: "time",
|
|
822
822
|
message: a.message
|
|
823
|
-
}),
|
|
823
|
+
}), s.dirty()) : a.kind === "duration" ? Tt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
824
824
|
validation: "duration",
|
|
825
825
|
code: u.invalid_string,
|
|
826
826
|
message: a.message
|
|
827
|
-
}),
|
|
827
|
+
}), s.dirty()) : a.kind === "ip" ? $t(e.data, a.version) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
828
828
|
validation: "ip",
|
|
829
829
|
code: u.invalid_string,
|
|
830
830
|
message: a.message
|
|
831
|
-
}),
|
|
831
|
+
}), s.dirty()) : a.kind === "jwt" ? Pt(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
832
832
|
validation: "jwt",
|
|
833
833
|
code: u.invalid_string,
|
|
834
834
|
message: a.message
|
|
835
|
-
}),
|
|
835
|
+
}), s.dirty()) : a.kind === "cidr" ? Mt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
836
836
|
validation: "cidr",
|
|
837
837
|
code: u.invalid_string,
|
|
838
838
|
message: a.message
|
|
839
|
-
}),
|
|
839
|
+
}), s.dirty()) : a.kind === "base64" ? Et.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
840
840
|
validation: "base64",
|
|
841
841
|
code: u.invalid_string,
|
|
842
842
|
message: a.message
|
|
843
|
-
}),
|
|
843
|
+
}), s.dirty()) : a.kind === "base64url" ? Rt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
844
844
|
validation: "base64url",
|
|
845
845
|
code: u.invalid_string,
|
|
846
846
|
message: a.message
|
|
847
|
-
}),
|
|
848
|
-
return { status:
|
|
847
|
+
}), s.dirty()) : x.assertNever(a);
|
|
848
|
+
return { status: s.value, value: e.data };
|
|
849
849
|
}
|
|
850
|
-
_regex(e, t,
|
|
851
|
-
return this.refinement((
|
|
850
|
+
_regex(e, t, s) {
|
|
851
|
+
return this.refinement((n) => e.test(n), {
|
|
852
852
|
validation: t,
|
|
853
853
|
code: u.invalid_string,
|
|
854
|
-
...m.errToObj(
|
|
854
|
+
...m.errToObj(s)
|
|
855
855
|
});
|
|
856
856
|
}
|
|
857
857
|
_addCheck(e) {
|
|
858
|
-
return new
|
|
858
|
+
return new O({
|
|
859
859
|
...this._def,
|
|
860
860
|
checks: [...this._def.checks, e]
|
|
861
861
|
});
|
|
@@ -903,7 +903,7 @@ class j extends g {
|
|
|
903
903
|
return this._addCheck({ kind: "cidr", ...m.errToObj(e) });
|
|
904
904
|
}
|
|
905
905
|
datetime(e) {
|
|
906
|
-
var t,
|
|
906
|
+
var t, s;
|
|
907
907
|
return typeof e == "string" ? this._addCheck({
|
|
908
908
|
kind: "datetime",
|
|
909
909
|
precision: null,
|
|
@@ -914,7 +914,7 @@ class j extends g {
|
|
|
914
914
|
kind: "datetime",
|
|
915
915
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
916
916
|
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
917
|
-
local: (
|
|
917
|
+
local: (s = e == null ? void 0 : e.local) !== null && s !== void 0 ? s : !1,
|
|
918
918
|
...m.errToObj(e == null ? void 0 : e.message)
|
|
919
919
|
});
|
|
920
920
|
}
|
|
@@ -992,19 +992,19 @@ class j extends g {
|
|
|
992
992
|
return this.min(1, m.errToObj(e));
|
|
993
993
|
}
|
|
994
994
|
trim() {
|
|
995
|
-
return new
|
|
995
|
+
return new O({
|
|
996
996
|
...this._def,
|
|
997
997
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
998
998
|
});
|
|
999
999
|
}
|
|
1000
1000
|
toLowerCase() {
|
|
1001
|
-
return new
|
|
1001
|
+
return new O({
|
|
1002
1002
|
...this._def,
|
|
1003
1003
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1004
1004
|
});
|
|
1005
1005
|
}
|
|
1006
1006
|
toUpperCase() {
|
|
1007
|
-
return new
|
|
1007
|
+
return new O({
|
|
1008
1008
|
...this._def,
|
|
1009
1009
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1010
1010
|
});
|
|
@@ -1070,9 +1070,9 @@ class j extends g {
|
|
|
1070
1070
|
return e;
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
|
-
|
|
1073
|
+
O.create = (r) => {
|
|
1074
1074
|
var e;
|
|
1075
|
-
return new
|
|
1075
|
+
return new O({
|
|
1076
1076
|
checks: [],
|
|
1077
1077
|
typeName: _.ZodString,
|
|
1078
1078
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
@@ -1080,8 +1080,8 @@ j.create = (r) => {
|
|
|
1080
1080
|
});
|
|
1081
1081
|
};
|
|
1082
1082
|
function Dt(r, e) {
|
|
1083
|
-
const t = (r.toString().split(".")[1] || "").length,
|
|
1084
|
-
return a % i / Math.pow(10,
|
|
1083
|
+
const t = (r.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, a = parseInt(r.toFixed(n).replace(".", "")), i = parseInt(e.toFixed(n).replace(".", ""));
|
|
1084
|
+
return a % i / Math.pow(10, n);
|
|
1085
1085
|
}
|
|
1086
1086
|
class V extends g {
|
|
1087
1087
|
constructor() {
|
|
@@ -1096,37 +1096,37 @@ class V extends g {
|
|
|
1096
1096
|
received: a.parsedType
|
|
1097
1097
|
}), y;
|
|
1098
1098
|
}
|
|
1099
|
-
let
|
|
1100
|
-
const
|
|
1099
|
+
let s;
|
|
1100
|
+
const n = new T();
|
|
1101
1101
|
for (const a of this._def.checks)
|
|
1102
|
-
a.kind === "int" ? x.isInteger(e.data) || (
|
|
1102
|
+
a.kind === "int" ? x.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1103
1103
|
code: u.invalid_type,
|
|
1104
1104
|
expected: "integer",
|
|
1105
1105
|
received: "float",
|
|
1106
1106
|
message: a.message
|
|
1107
|
-
}),
|
|
1107
|
+
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1108
1108
|
code: u.too_small,
|
|
1109
1109
|
minimum: a.value,
|
|
1110
1110
|
type: "number",
|
|
1111
1111
|
inclusive: a.inclusive,
|
|
1112
1112
|
exact: !1,
|
|
1113
1113
|
message: a.message
|
|
1114
|
-
}),
|
|
1114
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1115
1115
|
code: u.too_big,
|
|
1116
1116
|
maximum: a.value,
|
|
1117
1117
|
type: "number",
|
|
1118
1118
|
inclusive: a.inclusive,
|
|
1119
1119
|
exact: !1,
|
|
1120
1120
|
message: a.message
|
|
1121
|
-
}),
|
|
1121
|
+
}), n.dirty()) : a.kind === "multipleOf" ? Dt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1122
1122
|
code: u.not_multiple_of,
|
|
1123
1123
|
multipleOf: a.value,
|
|
1124
1124
|
message: a.message
|
|
1125
|
-
}),
|
|
1125
|
+
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1126
1126
|
code: u.not_finite,
|
|
1127
1127
|
message: a.message
|
|
1128
|
-
}),
|
|
1129
|
-
return { status:
|
|
1128
|
+
}), n.dirty()) : x.assertNever(a);
|
|
1129
|
+
return { status: n.value, value: e.data };
|
|
1130
1130
|
}
|
|
1131
1131
|
gte(e, t) {
|
|
1132
1132
|
return this.setLimit("min", e, !0, m.toString(t));
|
|
@@ -1140,7 +1140,7 @@ class V extends g {
|
|
|
1140
1140
|
lt(e, t) {
|
|
1141
1141
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1142
1142
|
}
|
|
1143
|
-
setLimit(e, t,
|
|
1143
|
+
setLimit(e, t, s, n) {
|
|
1144
1144
|
return new V({
|
|
1145
1145
|
...this._def,
|
|
1146
1146
|
checks: [
|
|
@@ -1148,8 +1148,8 @@ class V extends g {
|
|
|
1148
1148
|
{
|
|
1149
1149
|
kind: e,
|
|
1150
1150
|
value: t,
|
|
1151
|
-
inclusive:
|
|
1152
|
-
message: m.toString(
|
|
1151
|
+
inclusive: s,
|
|
1152
|
+
message: m.toString(n)
|
|
1153
1153
|
}
|
|
1154
1154
|
]
|
|
1155
1155
|
});
|
|
@@ -1241,10 +1241,10 @@ class V extends g {
|
|
|
1241
1241
|
}
|
|
1242
1242
|
get isFinite() {
|
|
1243
1243
|
let e = null, t = null;
|
|
1244
|
-
for (const
|
|
1245
|
-
if (
|
|
1244
|
+
for (const s of this._def.checks) {
|
|
1245
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1246
1246
|
return !0;
|
|
1247
|
-
|
|
1247
|
+
s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1248
1248
|
}
|
|
1249
1249
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1250
1250
|
}
|
|
@@ -1268,27 +1268,27 @@ class L extends g {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
if (this._getType(e) !== f.bigint)
|
|
1270
1270
|
return this._getInvalidInput(e);
|
|
1271
|
-
let
|
|
1272
|
-
const
|
|
1271
|
+
let s;
|
|
1272
|
+
const n = new T();
|
|
1273
1273
|
for (const a of this._def.checks)
|
|
1274
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1274
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1275
1275
|
code: u.too_small,
|
|
1276
1276
|
type: "bigint",
|
|
1277
1277
|
minimum: a.value,
|
|
1278
1278
|
inclusive: a.inclusive,
|
|
1279
1279
|
message: a.message
|
|
1280
|
-
}),
|
|
1280
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1281
1281
|
code: u.too_big,
|
|
1282
1282
|
type: "bigint",
|
|
1283
1283
|
maximum: a.value,
|
|
1284
1284
|
inclusive: a.inclusive,
|
|
1285
1285
|
message: a.message
|
|
1286
|
-
}),
|
|
1286
|
+
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1287
1287
|
code: u.not_multiple_of,
|
|
1288
1288
|
multipleOf: a.value,
|
|
1289
1289
|
message: a.message
|
|
1290
|
-
}),
|
|
1291
|
-
return { status:
|
|
1290
|
+
}), n.dirty()) : x.assertNever(a);
|
|
1291
|
+
return { status: n.value, value: e.data };
|
|
1292
1292
|
}
|
|
1293
1293
|
_getInvalidInput(e) {
|
|
1294
1294
|
const t = this._getOrReturnCtx(e);
|
|
@@ -1310,7 +1310,7 @@ class L extends g {
|
|
|
1310
1310
|
lt(e, t) {
|
|
1311
1311
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1312
1312
|
}
|
|
1313
|
-
setLimit(e, t,
|
|
1313
|
+
setLimit(e, t, s, n) {
|
|
1314
1314
|
return new L({
|
|
1315
1315
|
...this._def,
|
|
1316
1316
|
checks: [
|
|
@@ -1318,8 +1318,8 @@ class L extends g {
|
|
|
1318
1318
|
{
|
|
1319
1319
|
kind: e,
|
|
1320
1320
|
value: t,
|
|
1321
|
-
inclusive:
|
|
1322
|
-
message: m.toString(
|
|
1321
|
+
inclusive: s,
|
|
1322
|
+
message: m.toString(n)
|
|
1323
1323
|
}
|
|
1324
1324
|
]
|
|
1325
1325
|
});
|
|
@@ -1391,25 +1391,25 @@ L.create = (r) => {
|
|
|
1391
1391
|
...v(r)
|
|
1392
1392
|
});
|
|
1393
1393
|
};
|
|
1394
|
-
class
|
|
1394
|
+
class ce extends g {
|
|
1395
1395
|
_parse(e) {
|
|
1396
1396
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1397
|
-
const
|
|
1398
|
-
return l(
|
|
1397
|
+
const s = this._getOrReturnCtx(e);
|
|
1398
|
+
return l(s, {
|
|
1399
1399
|
code: u.invalid_type,
|
|
1400
1400
|
expected: f.boolean,
|
|
1401
|
-
received:
|
|
1401
|
+
received: s.parsedType
|
|
1402
1402
|
}), y;
|
|
1403
1403
|
}
|
|
1404
|
-
return
|
|
1404
|
+
return S(e.data);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
|
-
|
|
1407
|
+
ce.create = (r) => new ce({
|
|
1408
1408
|
typeName: _.ZodBoolean,
|
|
1409
1409
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1410
1410
|
...v(r)
|
|
1411
1411
|
});
|
|
1412
|
-
class
|
|
1412
|
+
class W extends g {
|
|
1413
1413
|
_parse(e) {
|
|
1414
1414
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1415
1415
|
const a = this._getOrReturnCtx(e);
|
|
@@ -1425,31 +1425,31 @@ class q extends g {
|
|
|
1425
1425
|
code: u.invalid_date
|
|
1426
1426
|
}), y;
|
|
1427
1427
|
}
|
|
1428
|
-
const
|
|
1429
|
-
let
|
|
1428
|
+
const s = new T();
|
|
1429
|
+
let n;
|
|
1430
1430
|
for (const a of this._def.checks)
|
|
1431
|
-
a.kind === "min" ? e.data.getTime() < a.value && (
|
|
1431
|
+
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1432
1432
|
code: u.too_small,
|
|
1433
1433
|
message: a.message,
|
|
1434
1434
|
inclusive: !0,
|
|
1435
1435
|
exact: !1,
|
|
1436
1436
|
minimum: a.value,
|
|
1437
1437
|
type: "date"
|
|
1438
|
-
}),
|
|
1438
|
+
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1439
1439
|
code: u.too_big,
|
|
1440
1440
|
message: a.message,
|
|
1441
1441
|
inclusive: !0,
|
|
1442
1442
|
exact: !1,
|
|
1443
1443
|
maximum: a.value,
|
|
1444
1444
|
type: "date"
|
|
1445
|
-
}),
|
|
1445
|
+
}), s.dirty()) : x.assertNever(a);
|
|
1446
1446
|
return {
|
|
1447
|
-
status:
|
|
1447
|
+
status: s.value,
|
|
1448
1448
|
value: new Date(e.data.getTime())
|
|
1449
1449
|
};
|
|
1450
1450
|
}
|
|
1451
1451
|
_addCheck(e) {
|
|
1452
|
-
return new
|
|
1452
|
+
return new W({
|
|
1453
1453
|
...this._def,
|
|
1454
1454
|
checks: [...this._def.checks, e]
|
|
1455
1455
|
});
|
|
@@ -1481,7 +1481,7 @@ class q extends g {
|
|
|
1481
1481
|
return e != null ? new Date(e) : null;
|
|
1482
1482
|
}
|
|
1483
1483
|
}
|
|
1484
|
-
|
|
1484
|
+
W.create = (r) => new W({
|
|
1485
1485
|
checks: [],
|
|
1486
1486
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1487
1487
|
typeName: _.ZodDate,
|
|
@@ -1490,48 +1490,48 @@ q.create = (r) => new q({
|
|
|
1490
1490
|
class Ze extends g {
|
|
1491
1491
|
_parse(e) {
|
|
1492
1492
|
if (this._getType(e) !== f.symbol) {
|
|
1493
|
-
const
|
|
1494
|
-
return l(
|
|
1493
|
+
const s = this._getOrReturnCtx(e);
|
|
1494
|
+
return l(s, {
|
|
1495
1495
|
code: u.invalid_type,
|
|
1496
1496
|
expected: f.symbol,
|
|
1497
|
-
received:
|
|
1497
|
+
received: s.parsedType
|
|
1498
1498
|
}), y;
|
|
1499
1499
|
}
|
|
1500
|
-
return
|
|
1500
|
+
return S(e.data);
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
1503
|
Ze.create = (r) => new Ze({
|
|
1504
1504
|
typeName: _.ZodSymbol,
|
|
1505
1505
|
...v(r)
|
|
1506
1506
|
});
|
|
1507
|
-
class
|
|
1507
|
+
class de extends g {
|
|
1508
1508
|
_parse(e) {
|
|
1509
1509
|
if (this._getType(e) !== f.undefined) {
|
|
1510
|
-
const
|
|
1511
|
-
return l(
|
|
1510
|
+
const s = this._getOrReturnCtx(e);
|
|
1511
|
+
return l(s, {
|
|
1512
1512
|
code: u.invalid_type,
|
|
1513
1513
|
expected: f.undefined,
|
|
1514
|
-
received:
|
|
1514
|
+
received: s.parsedType
|
|
1515
1515
|
}), y;
|
|
1516
1516
|
}
|
|
1517
|
-
return
|
|
1517
|
+
return S(e.data);
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
|
-
|
|
1520
|
+
de.create = (r) => new de({
|
|
1521
1521
|
typeName: _.ZodUndefined,
|
|
1522
1522
|
...v(r)
|
|
1523
1523
|
});
|
|
1524
1524
|
class ue extends g {
|
|
1525
1525
|
_parse(e) {
|
|
1526
1526
|
if (this._getType(e) !== f.null) {
|
|
1527
|
-
const
|
|
1528
|
-
return l(
|
|
1527
|
+
const s = this._getOrReturnCtx(e);
|
|
1528
|
+
return l(s, {
|
|
1529
1529
|
code: u.invalid_type,
|
|
1530
1530
|
expected: f.null,
|
|
1531
|
-
received:
|
|
1531
|
+
received: s.parsedType
|
|
1532
1532
|
}), y;
|
|
1533
1533
|
}
|
|
1534
|
-
return
|
|
1534
|
+
return S(e.data);
|
|
1535
1535
|
}
|
|
1536
1536
|
}
|
|
1537
1537
|
ue.create = (r) => new ue({
|
|
@@ -1543,7 +1543,7 @@ class ee extends g {
|
|
|
1543
1543
|
super(...arguments), this._any = !0;
|
|
1544
1544
|
}
|
|
1545
1545
|
_parse(e) {
|
|
1546
|
-
return
|
|
1546
|
+
return S(e.data);
|
|
1547
1547
|
}
|
|
1548
1548
|
}
|
|
1549
1549
|
ee.create = (r) => new ee({
|
|
@@ -1555,14 +1555,14 @@ class F extends g {
|
|
|
1555
1555
|
super(...arguments), this._unknown = !0;
|
|
1556
1556
|
}
|
|
1557
1557
|
_parse(e) {
|
|
1558
|
-
return
|
|
1558
|
+
return S(e.data);
|
|
1559
1559
|
}
|
|
1560
1560
|
}
|
|
1561
1561
|
F.create = (r) => new F({
|
|
1562
1562
|
typeName: _.ZodUnknown,
|
|
1563
1563
|
...v(r)
|
|
1564
1564
|
});
|
|
1565
|
-
class
|
|
1565
|
+
class P extends g {
|
|
1566
1566
|
_parse(e) {
|
|
1567
1567
|
const t = this._getOrReturnCtx(e);
|
|
1568
1568
|
return l(t, {
|
|
@@ -1572,84 +1572,84 @@ class M extends g {
|
|
|
1572
1572
|
}), y;
|
|
1573
1573
|
}
|
|
1574
1574
|
}
|
|
1575
|
-
|
|
1575
|
+
P.create = (r) => new P({
|
|
1576
1576
|
typeName: _.ZodNever,
|
|
1577
1577
|
...v(r)
|
|
1578
1578
|
});
|
|
1579
|
-
class
|
|
1579
|
+
class Ce extends g {
|
|
1580
1580
|
_parse(e) {
|
|
1581
1581
|
if (this._getType(e) !== f.undefined) {
|
|
1582
|
-
const
|
|
1583
|
-
return l(
|
|
1582
|
+
const s = this._getOrReturnCtx(e);
|
|
1583
|
+
return l(s, {
|
|
1584
1584
|
code: u.invalid_type,
|
|
1585
1585
|
expected: f.void,
|
|
1586
|
-
received:
|
|
1586
|
+
received: s.parsedType
|
|
1587
1587
|
}), y;
|
|
1588
1588
|
}
|
|
1589
|
-
return
|
|
1589
|
+
return S(e.data);
|
|
1590
1590
|
}
|
|
1591
1591
|
}
|
|
1592
|
-
|
|
1592
|
+
Ce.create = (r) => new Ce({
|
|
1593
1593
|
typeName: _.ZodVoid,
|
|
1594
1594
|
...v(r)
|
|
1595
1595
|
});
|
|
1596
|
-
class
|
|
1596
|
+
class j extends g {
|
|
1597
1597
|
_parse(e) {
|
|
1598
|
-
const { ctx: t, status:
|
|
1598
|
+
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
1599
1599
|
if (t.parsedType !== f.array)
|
|
1600
1600
|
return l(t, {
|
|
1601
1601
|
code: u.invalid_type,
|
|
1602
1602
|
expected: f.array,
|
|
1603
1603
|
received: t.parsedType
|
|
1604
1604
|
}), y;
|
|
1605
|
-
if (
|
|
1606
|
-
const i = t.data.length >
|
|
1605
|
+
if (n.exactLength !== null) {
|
|
1606
|
+
const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
1607
1607
|
(i || o) && (l(t, {
|
|
1608
1608
|
code: i ? u.too_big : u.too_small,
|
|
1609
|
-
minimum: o ?
|
|
1610
|
-
maximum: i ?
|
|
1609
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
1610
|
+
maximum: i ? n.exactLength.value : void 0,
|
|
1611
1611
|
type: "array",
|
|
1612
1612
|
inclusive: !0,
|
|
1613
1613
|
exact: !0,
|
|
1614
|
-
message:
|
|
1615
|
-
}),
|
|
1614
|
+
message: n.exactLength.message
|
|
1615
|
+
}), s.dirty());
|
|
1616
1616
|
}
|
|
1617
|
-
if (
|
|
1617
|
+
if (n.minLength !== null && t.data.length < n.minLength.value && (l(t, {
|
|
1618
1618
|
code: u.too_small,
|
|
1619
|
-
minimum:
|
|
1619
|
+
minimum: n.minLength.value,
|
|
1620
1620
|
type: "array",
|
|
1621
1621
|
inclusive: !0,
|
|
1622
1622
|
exact: !1,
|
|
1623
|
-
message:
|
|
1624
|
-
}),
|
|
1623
|
+
message: n.minLength.message
|
|
1624
|
+
}), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (l(t, {
|
|
1625
1625
|
code: u.too_big,
|
|
1626
|
-
maximum:
|
|
1626
|
+
maximum: n.maxLength.value,
|
|
1627
1627
|
type: "array",
|
|
1628
1628
|
inclusive: !0,
|
|
1629
1629
|
exact: !1,
|
|
1630
|
-
message:
|
|
1631
|
-
}),
|
|
1632
|
-
return Promise.all([...t.data].map((i, o) =>
|
|
1633
|
-
const a = [...t.data].map((i, o) =>
|
|
1634
|
-
return T.mergeArray(
|
|
1630
|
+
message: n.maxLength.message
|
|
1631
|
+
}), s.dirty()), t.common.async)
|
|
1632
|
+
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new R(t, i, t.path, o)))).then((i) => T.mergeArray(s, i));
|
|
1633
|
+
const a = [...t.data].map((i, o) => n.type._parseSync(new R(t, i, t.path, o)));
|
|
1634
|
+
return T.mergeArray(s, a);
|
|
1635
1635
|
}
|
|
1636
1636
|
get element() {
|
|
1637
1637
|
return this._def.type;
|
|
1638
1638
|
}
|
|
1639
1639
|
min(e, t) {
|
|
1640
|
-
return new
|
|
1640
|
+
return new j({
|
|
1641
1641
|
...this._def,
|
|
1642
1642
|
minLength: { value: e, message: m.toString(t) }
|
|
1643
1643
|
});
|
|
1644
1644
|
}
|
|
1645
1645
|
max(e, t) {
|
|
1646
|
-
return new
|
|
1646
|
+
return new j({
|
|
1647
1647
|
...this._def,
|
|
1648
1648
|
maxLength: { value: e, message: m.toString(t) }
|
|
1649
1649
|
});
|
|
1650
1650
|
}
|
|
1651
1651
|
length(e, t) {
|
|
1652
|
-
return new
|
|
1652
|
+
return new j({
|
|
1653
1653
|
...this._def,
|
|
1654
1654
|
exactLength: { value: e, message: m.toString(t) }
|
|
1655
1655
|
});
|
|
@@ -1658,7 +1658,7 @@ class C extends g {
|
|
|
1658
1658
|
return this.min(1, e);
|
|
1659
1659
|
}
|
|
1660
1660
|
}
|
|
1661
|
-
|
|
1661
|
+
j.create = (r, e) => new j({
|
|
1662
1662
|
type: r,
|
|
1663
1663
|
minLength: null,
|
|
1664
1664
|
maxLength: null,
|
|
@@ -1670,14 +1670,14 @@ function G(r) {
|
|
|
1670
1670
|
if (r instanceof k) {
|
|
1671
1671
|
const e = {};
|
|
1672
1672
|
for (const t in r.shape) {
|
|
1673
|
-
const
|
|
1674
|
-
e[t] = E.create(G(
|
|
1673
|
+
const s = r.shape[t];
|
|
1674
|
+
e[t] = E.create(G(s));
|
|
1675
1675
|
}
|
|
1676
1676
|
return new k({
|
|
1677
1677
|
...r._def,
|
|
1678
1678
|
shape: () => e
|
|
1679
1679
|
});
|
|
1680
|
-
} else return r instanceof
|
|
1680
|
+
} else return r instanceof j ? new j({
|
|
1681
1681
|
...r._def,
|
|
1682
1682
|
type: G(r.element)
|
|
1683
1683
|
}) : r instanceof E ? E.create(G(r.unwrap())) : r instanceof U ? U.create(G(r.unwrap())) : r instanceof N ? N.create(r.items.map((e) => G(e))) : r;
|
|
@@ -1694,66 +1694,66 @@ class k extends g {
|
|
|
1694
1694
|
}
|
|
1695
1695
|
_parse(e) {
|
|
1696
1696
|
if (this._getType(e) !== f.object) {
|
|
1697
|
-
const
|
|
1698
|
-
return l(
|
|
1697
|
+
const d = this._getOrReturnCtx(e);
|
|
1698
|
+
return l(d, {
|
|
1699
1699
|
code: u.invalid_type,
|
|
1700
1700
|
expected: f.object,
|
|
1701
|
-
received:
|
|
1701
|
+
received: d.parsedType
|
|
1702
1702
|
}), y;
|
|
1703
1703
|
}
|
|
1704
|
-
const { status:
|
|
1705
|
-
if (!(this._def.catchall instanceof
|
|
1706
|
-
for (const
|
|
1707
|
-
i.includes(
|
|
1708
|
-
const
|
|
1709
|
-
for (const
|
|
1710
|
-
const
|
|
1711
|
-
|
|
1712
|
-
key: { status: "valid", value:
|
|
1713
|
-
value:
|
|
1714
|
-
alwaysSet:
|
|
1704
|
+
const { status: s, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1705
|
+
if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
|
|
1706
|
+
for (const d in n.data)
|
|
1707
|
+
i.includes(d) || o.push(d);
|
|
1708
|
+
const c = [];
|
|
1709
|
+
for (const d of i) {
|
|
1710
|
+
const h = a[d], b = n.data[d];
|
|
1711
|
+
c.push({
|
|
1712
|
+
key: { status: "valid", value: d },
|
|
1713
|
+
value: h._parse(new R(n, b, n.path, d)),
|
|
1714
|
+
alwaysSet: d in n.data
|
|
1715
1715
|
});
|
|
1716
1716
|
}
|
|
1717
|
-
if (this._def.catchall instanceof
|
|
1718
|
-
const
|
|
1719
|
-
if (
|
|
1720
|
-
for (const
|
|
1721
|
-
|
|
1722
|
-
key: { status: "valid", value:
|
|
1723
|
-
value: { status: "valid", value:
|
|
1717
|
+
if (this._def.catchall instanceof P) {
|
|
1718
|
+
const d = this._def.unknownKeys;
|
|
1719
|
+
if (d === "passthrough")
|
|
1720
|
+
for (const h of o)
|
|
1721
|
+
c.push({
|
|
1722
|
+
key: { status: "valid", value: h },
|
|
1723
|
+
value: { status: "valid", value: n.data[h] }
|
|
1724
1724
|
});
|
|
1725
|
-
else if (
|
|
1726
|
-
o.length > 0 && (l(
|
|
1725
|
+
else if (d === "strict")
|
|
1726
|
+
o.length > 0 && (l(n, {
|
|
1727
1727
|
code: u.unrecognized_keys,
|
|
1728
1728
|
keys: o
|
|
1729
|
-
}),
|
|
1730
|
-
else if (
|
|
1729
|
+
}), s.dirty());
|
|
1730
|
+
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1731
1731
|
} else {
|
|
1732
|
-
const
|
|
1733
|
-
for (const
|
|
1734
|
-
const b =
|
|
1735
|
-
|
|
1736
|
-
key: { status: "valid", value:
|
|
1737
|
-
value:
|
|
1738
|
-
new R(
|
|
1732
|
+
const d = this._def.catchall;
|
|
1733
|
+
for (const h of o) {
|
|
1734
|
+
const b = n.data[h];
|
|
1735
|
+
c.push({
|
|
1736
|
+
key: { status: "valid", value: h },
|
|
1737
|
+
value: d._parse(
|
|
1738
|
+
new R(n, b, n.path, h)
|
|
1739
1739
|
//, ctx.child(key), value, getParsedType(value)
|
|
1740
1740
|
),
|
|
1741
|
-
alwaysSet:
|
|
1741
|
+
alwaysSet: h in n.data
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
1744
|
}
|
|
1745
|
-
return
|
|
1746
|
-
const
|
|
1747
|
-
for (const
|
|
1748
|
-
const b = await
|
|
1749
|
-
|
|
1745
|
+
return n.common.async ? Promise.resolve().then(async () => {
|
|
1746
|
+
const d = [];
|
|
1747
|
+
for (const h of c) {
|
|
1748
|
+
const b = await h.key, Z = await h.value;
|
|
1749
|
+
d.push({
|
|
1750
1750
|
key: b,
|
|
1751
|
-
value:
|
|
1752
|
-
alwaysSet:
|
|
1751
|
+
value: Z,
|
|
1752
|
+
alwaysSet: h.alwaysSet
|
|
1753
1753
|
});
|
|
1754
1754
|
}
|
|
1755
|
-
return
|
|
1756
|
-
}).then((
|
|
1755
|
+
return d;
|
|
1756
|
+
}).then((d) => T.mergeObjectSync(s, d)) : T.mergeObjectSync(s, c);
|
|
1757
1757
|
}
|
|
1758
1758
|
get shape() {
|
|
1759
1759
|
return this._def.shape();
|
|
@@ -1763,13 +1763,13 @@ class k extends g {
|
|
|
1763
1763
|
...this._def,
|
|
1764
1764
|
unknownKeys: "strict",
|
|
1765
1765
|
...e !== void 0 ? {
|
|
1766
|
-
errorMap: (t,
|
|
1767
|
-
var
|
|
1768
|
-
const
|
|
1766
|
+
errorMap: (t, s) => {
|
|
1767
|
+
var n, a, i, o;
|
|
1768
|
+
const c = (i = (a = (n = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(n, t, s).message) !== null && i !== void 0 ? i : s.defaultError;
|
|
1769
1769
|
return t.code === "unrecognized_keys" ? {
|
|
1770
|
-
message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o :
|
|
1770
|
+
message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o : c
|
|
1771
1771
|
} : {
|
|
1772
|
-
message:
|
|
1772
|
+
message: c
|
|
1773
1773
|
};
|
|
1774
1774
|
}
|
|
1775
1775
|
} : {}
|
|
@@ -1896,8 +1896,8 @@ class k extends g {
|
|
|
1896
1896
|
}
|
|
1897
1897
|
pick(e) {
|
|
1898
1898
|
const t = {};
|
|
1899
|
-
return x.objectKeys(e).forEach((
|
|
1900
|
-
e[
|
|
1899
|
+
return x.objectKeys(e).forEach((s) => {
|
|
1900
|
+
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1901
1901
|
}), new k({
|
|
1902
1902
|
...this._def,
|
|
1903
1903
|
shape: () => t
|
|
@@ -1905,8 +1905,8 @@ class k extends g {
|
|
|
1905
1905
|
}
|
|
1906
1906
|
omit(e) {
|
|
1907
1907
|
const t = {};
|
|
1908
|
-
return x.objectKeys(this.shape).forEach((
|
|
1909
|
-
e[
|
|
1908
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1909
|
+
e[s] || (t[s] = this.shape[s]);
|
|
1910
1910
|
}), new k({
|
|
1911
1911
|
...this._def,
|
|
1912
1912
|
shape: () => t
|
|
@@ -1920,9 +1920,9 @@ class k extends g {
|
|
|
1920
1920
|
}
|
|
1921
1921
|
partial(e) {
|
|
1922
1922
|
const t = {};
|
|
1923
|
-
return x.objectKeys(this.shape).forEach((
|
|
1924
|
-
const
|
|
1925
|
-
e && !e[
|
|
1923
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1924
|
+
const n = this.shape[s];
|
|
1925
|
+
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
1926
1926
|
}), new k({
|
|
1927
1927
|
...this._def,
|
|
1928
1928
|
shape: () => t
|
|
@@ -1930,14 +1930,14 @@ class k extends g {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
required(e) {
|
|
1932
1932
|
const t = {};
|
|
1933
|
-
return x.objectKeys(this.shape).forEach((
|
|
1934
|
-
if (e && !e[
|
|
1935
|
-
t[
|
|
1933
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1934
|
+
if (e && !e[s])
|
|
1935
|
+
t[s] = this.shape[s];
|
|
1936
1936
|
else {
|
|
1937
|
-
let a = this.shape[
|
|
1937
|
+
let a = this.shape[s];
|
|
1938
1938
|
for (; a instanceof E; )
|
|
1939
1939
|
a = a._def.innerType;
|
|
1940
|
-
t[
|
|
1940
|
+
t[s] = a;
|
|
1941
1941
|
}
|
|
1942
1942
|
}), new k({
|
|
1943
1943
|
...this._def,
|
|
@@ -1951,42 +1951,42 @@ class k extends g {
|
|
|
1951
1951
|
k.create = (r, e) => new k({
|
|
1952
1952
|
shape: () => r,
|
|
1953
1953
|
unknownKeys: "strip",
|
|
1954
|
-
catchall:
|
|
1954
|
+
catchall: P.create(),
|
|
1955
1955
|
typeName: _.ZodObject,
|
|
1956
1956
|
...v(e)
|
|
1957
1957
|
});
|
|
1958
1958
|
k.strictCreate = (r, e) => new k({
|
|
1959
1959
|
shape: () => r,
|
|
1960
1960
|
unknownKeys: "strict",
|
|
1961
|
-
catchall:
|
|
1961
|
+
catchall: P.create(),
|
|
1962
1962
|
typeName: _.ZodObject,
|
|
1963
1963
|
...v(e)
|
|
1964
1964
|
});
|
|
1965
1965
|
k.lazycreate = (r, e) => new k({
|
|
1966
1966
|
shape: r,
|
|
1967
1967
|
unknownKeys: "strip",
|
|
1968
|
-
catchall:
|
|
1968
|
+
catchall: P.create(),
|
|
1969
1969
|
typeName: _.ZodObject,
|
|
1970
1970
|
...v(e)
|
|
1971
1971
|
});
|
|
1972
1972
|
class le extends g {
|
|
1973
1973
|
_parse(e) {
|
|
1974
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1975
|
-
function
|
|
1974
|
+
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1975
|
+
function n(a) {
|
|
1976
1976
|
for (const o of a)
|
|
1977
1977
|
if (o.result.status === "valid")
|
|
1978
1978
|
return o.result;
|
|
1979
1979
|
for (const o of a)
|
|
1980
1980
|
if (o.result.status === "dirty")
|
|
1981
1981
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1982
|
-
const i = a.map((o) => new
|
|
1982
|
+
const i = a.map((o) => new C(o.ctx.common.issues));
|
|
1983
1983
|
return l(t, {
|
|
1984
1984
|
code: u.invalid_union,
|
|
1985
1985
|
unionErrors: i
|
|
1986
1986
|
}), y;
|
|
1987
1987
|
}
|
|
1988
1988
|
if (t.common.async)
|
|
1989
|
-
return Promise.all(
|
|
1989
|
+
return Promise.all(s.map(async (a) => {
|
|
1990
1990
|
const i = {
|
|
1991
1991
|
...t,
|
|
1992
1992
|
common: {
|
|
@@ -2003,30 +2003,30 @@ class le extends g {
|
|
|
2003
2003
|
}),
|
|
2004
2004
|
ctx: i
|
|
2005
2005
|
};
|
|
2006
|
-
})).then(
|
|
2006
|
+
})).then(n);
|
|
2007
2007
|
{
|
|
2008
2008
|
let a;
|
|
2009
2009
|
const i = [];
|
|
2010
|
-
for (const
|
|
2011
|
-
const
|
|
2010
|
+
for (const c of s) {
|
|
2011
|
+
const d = {
|
|
2012
2012
|
...t,
|
|
2013
2013
|
common: {
|
|
2014
2014
|
...t.common,
|
|
2015
2015
|
issues: []
|
|
2016
2016
|
},
|
|
2017
2017
|
parent: null
|
|
2018
|
-
},
|
|
2018
|
+
}, h = c._parseSync({
|
|
2019
2019
|
data: t.data,
|
|
2020
2020
|
path: t.path,
|
|
2021
|
-
parent:
|
|
2021
|
+
parent: d
|
|
2022
2022
|
});
|
|
2023
|
-
if (
|
|
2024
|
-
return
|
|
2025
|
-
|
|
2023
|
+
if (h.status === "valid")
|
|
2024
|
+
return h;
|
|
2025
|
+
h.status === "dirty" && !a && (a = { result: h, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
2026
2026
|
}
|
|
2027
2027
|
if (a)
|
|
2028
2028
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2029
|
-
const o = i.map((
|
|
2029
|
+
const o = i.map((c) => new C(c));
|
|
2030
2030
|
return l(t, {
|
|
2031
2031
|
code: u.invalid_union,
|
|
2032
2032
|
unionErrors: o
|
|
@@ -2042,8 +2042,8 @@ le.create = (r, e) => new le({
|
|
|
2042
2042
|
typeName: _.ZodUnion,
|
|
2043
2043
|
...v(e)
|
|
2044
2044
|
});
|
|
2045
|
-
const I = (r) => r instanceof pe ? I(r.schema) : r instanceof A ? I(r.innerType()) : r instanceof me ? [r.value] : r instanceof z ? r.options : r instanceof _e ? x.objectValues(r.enum) : r instanceof ye ? I(r._def.innerType) : r instanceof
|
|
2046
|
-
class
|
|
2045
|
+
const I = (r) => r instanceof pe ? I(r.schema) : r instanceof A ? I(r.innerType()) : r instanceof me ? [r.value] : r instanceof z ? r.options : r instanceof _e ? x.objectValues(r.enum) : r instanceof ye ? I(r._def.innerType) : r instanceof de ? [void 0] : r instanceof ue ? [null] : r instanceof E ? [void 0, ...I(r.unwrap())] : r instanceof U ? [null, ...I(r.unwrap())] : r instanceof Je || r instanceof ge ? I(r.unwrap()) : r instanceof ve ? I(r._def.innerType) : [];
|
|
2046
|
+
class Ee extends g {
|
|
2047
2047
|
_parse(e) {
|
|
2048
2048
|
const { ctx: t } = this._processInputParams(e);
|
|
2049
2049
|
if (t.parsedType !== f.object)
|
|
@@ -2052,7 +2052,7 @@ class Ae extends g {
|
|
|
2052
2052
|
expected: f.object,
|
|
2053
2053
|
received: t.parsedType
|
|
2054
2054
|
}), y;
|
|
2055
|
-
const
|
|
2055
|
+
const s = this.discriminator, n = t.data[s], a = this.optionsMap.get(n);
|
|
2056
2056
|
return a ? t.common.async ? a._parseAsync({
|
|
2057
2057
|
data: t.data,
|
|
2058
2058
|
path: t.path,
|
|
@@ -2064,7 +2064,7 @@ class Ae extends g {
|
|
|
2064
2064
|
}) : (l(t, {
|
|
2065
2065
|
code: u.invalid_union_discriminator,
|
|
2066
2066
|
options: Array.from(this.optionsMap.keys()),
|
|
2067
|
-
path: [
|
|
2067
|
+
path: [s]
|
|
2068
2068
|
}), y);
|
|
2069
2069
|
}
|
|
2070
2070
|
get discriminator() {
|
|
@@ -2084,82 +2084,82 @@ class Ae extends g {
|
|
|
2084
2084
|
* @param types an array of object schemas
|
|
2085
2085
|
* @param params
|
|
2086
2086
|
*/
|
|
2087
|
-
static create(e, t,
|
|
2088
|
-
const
|
|
2087
|
+
static create(e, t, s) {
|
|
2088
|
+
const n = /* @__PURE__ */ new Map();
|
|
2089
2089
|
for (const a of t) {
|
|
2090
2090
|
const i = I(a.shape[e]);
|
|
2091
2091
|
if (!i.length)
|
|
2092
2092
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2093
2093
|
for (const o of i) {
|
|
2094
|
-
if (
|
|
2094
|
+
if (n.has(o))
|
|
2095
2095
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2096
|
-
|
|
2096
|
+
n.set(o, a);
|
|
2097
2097
|
}
|
|
2098
2098
|
}
|
|
2099
|
-
return new
|
|
2099
|
+
return new Ee({
|
|
2100
2100
|
typeName: _.ZodDiscriminatedUnion,
|
|
2101
2101
|
discriminator: e,
|
|
2102
2102
|
options: t,
|
|
2103
|
-
optionsMap:
|
|
2104
|
-
...v(
|
|
2103
|
+
optionsMap: n,
|
|
2104
|
+
...v(s)
|
|
2105
2105
|
});
|
|
2106
2106
|
}
|
|
2107
2107
|
}
|
|
2108
|
-
function
|
|
2109
|
-
const t = $(r),
|
|
2108
|
+
function We(r, e) {
|
|
2109
|
+
const t = $(r), s = $(e);
|
|
2110
2110
|
if (r === e)
|
|
2111
2111
|
return { valid: !0, data: r };
|
|
2112
|
-
if (t === f.object &&
|
|
2113
|
-
const
|
|
2112
|
+
if (t === f.object && s === f.object) {
|
|
2113
|
+
const n = x.objectKeys(e), a = x.objectKeys(r).filter((o) => n.indexOf(o) !== -1), i = { ...r, ...e };
|
|
2114
2114
|
for (const o of a) {
|
|
2115
|
-
const
|
|
2116
|
-
if (!
|
|
2115
|
+
const c = We(r[o], e[o]);
|
|
2116
|
+
if (!c.valid)
|
|
2117
2117
|
return { valid: !1 };
|
|
2118
|
-
i[o] =
|
|
2118
|
+
i[o] = c.data;
|
|
2119
2119
|
}
|
|
2120
2120
|
return { valid: !0, data: i };
|
|
2121
|
-
} else if (t === f.array &&
|
|
2121
|
+
} else if (t === f.array && s === f.array) {
|
|
2122
2122
|
if (r.length !== e.length)
|
|
2123
2123
|
return { valid: !1 };
|
|
2124
|
-
const
|
|
2124
|
+
const n = [];
|
|
2125
2125
|
for (let a = 0; a < r.length; a++) {
|
|
2126
|
-
const i = r[a], o = e[a],
|
|
2127
|
-
if (!
|
|
2126
|
+
const i = r[a], o = e[a], c = We(i, o);
|
|
2127
|
+
if (!c.valid)
|
|
2128
2128
|
return { valid: !1 };
|
|
2129
|
-
|
|
2129
|
+
n.push(c.data);
|
|
2130
2130
|
}
|
|
2131
|
-
return { valid: !0, data:
|
|
2132
|
-
} else return t === f.date &&
|
|
2131
|
+
return { valid: !0, data: n };
|
|
2132
|
+
} else return t === f.date && s === f.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
2133
2133
|
}
|
|
2134
2134
|
class fe extends g {
|
|
2135
2135
|
_parse(e) {
|
|
2136
|
-
const { status: t, ctx:
|
|
2136
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = (a, i) => {
|
|
2137
2137
|
if (Fe(a) || Fe(i))
|
|
2138
2138
|
return y;
|
|
2139
|
-
const o =
|
|
2140
|
-
return o.valid ? ((
|
|
2139
|
+
const o = We(a.value, i.value);
|
|
2140
|
+
return o.valid ? ((qe(a) || qe(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(s, {
|
|
2141
2141
|
code: u.invalid_intersection_types
|
|
2142
2142
|
}), y);
|
|
2143
2143
|
};
|
|
2144
|
-
return
|
|
2144
|
+
return s.common.async ? Promise.all([
|
|
2145
2145
|
this._def.left._parseAsync({
|
|
2146
|
-
data:
|
|
2147
|
-
path:
|
|
2148
|
-
parent:
|
|
2146
|
+
data: s.data,
|
|
2147
|
+
path: s.path,
|
|
2148
|
+
parent: s
|
|
2149
2149
|
}),
|
|
2150
2150
|
this._def.right._parseAsync({
|
|
2151
|
-
data:
|
|
2152
|
-
path:
|
|
2153
|
-
parent:
|
|
2151
|
+
data: s.data,
|
|
2152
|
+
path: s.path,
|
|
2153
|
+
parent: s
|
|
2154
2154
|
})
|
|
2155
|
-
]).then(([a, i]) =>
|
|
2156
|
-
data:
|
|
2157
|
-
path:
|
|
2158
|
-
parent:
|
|
2155
|
+
]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
|
|
2156
|
+
data: s.data,
|
|
2157
|
+
path: s.path,
|
|
2158
|
+
parent: s
|
|
2159
2159
|
}), this._def.right._parseSync({
|
|
2160
|
-
data:
|
|
2161
|
-
path:
|
|
2162
|
-
parent:
|
|
2160
|
+
data: s.data,
|
|
2161
|
+
path: s.path,
|
|
2162
|
+
parent: s
|
|
2163
2163
|
}));
|
|
2164
2164
|
}
|
|
2165
2165
|
}
|
|
@@ -2171,33 +2171,33 @@ fe.create = (r, e, t) => new fe({
|
|
|
2171
2171
|
});
|
|
2172
2172
|
class N extends g {
|
|
2173
2173
|
_parse(e) {
|
|
2174
|
-
const { status: t, ctx:
|
|
2175
|
-
if (
|
|
2176
|
-
return l(
|
|
2174
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2175
|
+
if (s.parsedType !== f.array)
|
|
2176
|
+
return l(s, {
|
|
2177
2177
|
code: u.invalid_type,
|
|
2178
2178
|
expected: f.array,
|
|
2179
|
-
received:
|
|
2179
|
+
received: s.parsedType
|
|
2180
2180
|
}), y;
|
|
2181
|
-
if (
|
|
2182
|
-
return l(
|
|
2181
|
+
if (s.data.length < this._def.items.length)
|
|
2182
|
+
return l(s, {
|
|
2183
2183
|
code: u.too_small,
|
|
2184
2184
|
minimum: this._def.items.length,
|
|
2185
2185
|
inclusive: !0,
|
|
2186
2186
|
exact: !1,
|
|
2187
2187
|
type: "array"
|
|
2188
2188
|
}), y;
|
|
2189
|
-
!this._def.rest &&
|
|
2189
|
+
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2190
2190
|
code: u.too_big,
|
|
2191
2191
|
maximum: this._def.items.length,
|
|
2192
2192
|
inclusive: !0,
|
|
2193
2193
|
exact: !1,
|
|
2194
2194
|
type: "array"
|
|
2195
2195
|
}), t.dirty());
|
|
2196
|
-
const a = [...
|
|
2197
|
-
const
|
|
2198
|
-
return
|
|
2196
|
+
const a = [...s.data].map((i, o) => {
|
|
2197
|
+
const c = this._def.items[o] || this._def.rest;
|
|
2198
|
+
return c ? c._parse(new R(s, i, s.path, o)) : null;
|
|
2199
2199
|
}).filter((i) => !!i);
|
|
2200
|
-
return
|
|
2200
|
+
return s.common.async ? Promise.all(a).then((i) => T.mergeArray(t, i)) : T.mergeArray(t, a);
|
|
2201
2201
|
}
|
|
2202
2202
|
get items() {
|
|
2203
2203
|
return this._def.items;
|
|
@@ -2227,40 +2227,40 @@ class he extends g {
|
|
|
2227
2227
|
return this._def.valueType;
|
|
2228
2228
|
}
|
|
2229
2229
|
_parse(e) {
|
|
2230
|
-
const { status: t, ctx:
|
|
2231
|
-
if (
|
|
2232
|
-
return l(
|
|
2230
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2231
|
+
if (s.parsedType !== f.object)
|
|
2232
|
+
return l(s, {
|
|
2233
2233
|
code: u.invalid_type,
|
|
2234
2234
|
expected: f.object,
|
|
2235
|
-
received:
|
|
2235
|
+
received: s.parsedType
|
|
2236
2236
|
}), y;
|
|
2237
|
-
const
|
|
2238
|
-
for (const o in
|
|
2239
|
-
|
|
2240
|
-
key: a._parse(new R(
|
|
2241
|
-
value: i._parse(new R(
|
|
2242
|
-
alwaysSet: o in
|
|
2237
|
+
const n = [], a = this._def.keyType, i = this._def.valueType;
|
|
2238
|
+
for (const o in s.data)
|
|
2239
|
+
n.push({
|
|
2240
|
+
key: a._parse(new R(s, o, s.path, o)),
|
|
2241
|
+
value: i._parse(new R(s, s.data[o], s.path, o)),
|
|
2242
|
+
alwaysSet: o in s.data
|
|
2243
2243
|
});
|
|
2244
|
-
return
|
|
2244
|
+
return s.common.async ? T.mergeObjectAsync(t, n) : T.mergeObjectSync(t, n);
|
|
2245
2245
|
}
|
|
2246
2246
|
get element() {
|
|
2247
2247
|
return this._def.valueType;
|
|
2248
2248
|
}
|
|
2249
|
-
static create(e, t,
|
|
2249
|
+
static create(e, t, s) {
|
|
2250
2250
|
return t instanceof g ? new he({
|
|
2251
2251
|
keyType: e,
|
|
2252
2252
|
valueType: t,
|
|
2253
2253
|
typeName: _.ZodRecord,
|
|
2254
|
-
...v(
|
|
2254
|
+
...v(s)
|
|
2255
2255
|
}) : new he({
|
|
2256
|
-
keyType:
|
|
2256
|
+
keyType: O.create(),
|
|
2257
2257
|
valueType: e,
|
|
2258
2258
|
typeName: _.ZodRecord,
|
|
2259
2259
|
...v(t)
|
|
2260
2260
|
});
|
|
2261
2261
|
}
|
|
2262
2262
|
}
|
|
2263
|
-
class
|
|
2263
|
+
class Oe extends g {
|
|
2264
2264
|
get keySchema() {
|
|
2265
2265
|
return this._def.keyType;
|
|
2266
2266
|
}
|
|
@@ -2268,41 +2268,41 @@ class Se extends g {
|
|
|
2268
2268
|
return this._def.valueType;
|
|
2269
2269
|
}
|
|
2270
2270
|
_parse(e) {
|
|
2271
|
-
const { status: t, ctx:
|
|
2272
|
-
if (
|
|
2273
|
-
return l(
|
|
2271
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2272
|
+
if (s.parsedType !== f.map)
|
|
2273
|
+
return l(s, {
|
|
2274
2274
|
code: u.invalid_type,
|
|
2275
2275
|
expected: f.map,
|
|
2276
|
-
received:
|
|
2276
|
+
received: s.parsedType
|
|
2277
2277
|
}), y;
|
|
2278
|
-
const
|
|
2279
|
-
key:
|
|
2280
|
-
value: a._parse(new R(
|
|
2278
|
+
const n = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], d) => ({
|
|
2279
|
+
key: n._parse(new R(s, o, s.path, [d, "key"])),
|
|
2280
|
+
value: a._parse(new R(s, c, s.path, [d, "value"]))
|
|
2281
2281
|
}));
|
|
2282
|
-
if (
|
|
2282
|
+
if (s.common.async) {
|
|
2283
2283
|
const o = /* @__PURE__ */ new Map();
|
|
2284
2284
|
return Promise.resolve().then(async () => {
|
|
2285
|
-
for (const
|
|
2286
|
-
const
|
|
2287
|
-
if (
|
|
2285
|
+
for (const c of i) {
|
|
2286
|
+
const d = await c.key, h = await c.value;
|
|
2287
|
+
if (d.status === "aborted" || h.status === "aborted")
|
|
2288
2288
|
return y;
|
|
2289
|
-
(
|
|
2289
|
+
(d.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(d.value, h.value);
|
|
2290
2290
|
}
|
|
2291
2291
|
return { status: t.value, value: o };
|
|
2292
2292
|
});
|
|
2293
2293
|
} else {
|
|
2294
2294
|
const o = /* @__PURE__ */ new Map();
|
|
2295
|
-
for (const
|
|
2296
|
-
const
|
|
2297
|
-
if (
|
|
2295
|
+
for (const c of i) {
|
|
2296
|
+
const d = c.key, h = c.value;
|
|
2297
|
+
if (d.status === "aborted" || h.status === "aborted")
|
|
2298
2298
|
return y;
|
|
2299
|
-
(
|
|
2299
|
+
(d.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(d.value, h.value);
|
|
2300
2300
|
}
|
|
2301
2301
|
return { status: t.value, value: o };
|
|
2302
2302
|
}
|
|
2303
2303
|
}
|
|
2304
2304
|
}
|
|
2305
|
-
|
|
2305
|
+
Oe.create = (r, e, t) => new Oe({
|
|
2306
2306
|
valueType: e,
|
|
2307
2307
|
keyType: r,
|
|
2308
2308
|
typeName: _.ZodMap,
|
|
@@ -2310,41 +2310,41 @@ Se.create = (r, e, t) => new Se({
|
|
|
2310
2310
|
});
|
|
2311
2311
|
class J extends g {
|
|
2312
2312
|
_parse(e) {
|
|
2313
|
-
const { status: t, ctx:
|
|
2314
|
-
if (
|
|
2315
|
-
return l(
|
|
2313
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2314
|
+
if (s.parsedType !== f.set)
|
|
2315
|
+
return l(s, {
|
|
2316
2316
|
code: u.invalid_type,
|
|
2317
2317
|
expected: f.set,
|
|
2318
|
-
received:
|
|
2318
|
+
received: s.parsedType
|
|
2319
2319
|
}), y;
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2320
|
+
const n = this._def;
|
|
2321
|
+
n.minSize !== null && s.data.size < n.minSize.value && (l(s, {
|
|
2322
2322
|
code: u.too_small,
|
|
2323
|
-
minimum:
|
|
2323
|
+
minimum: n.minSize.value,
|
|
2324
2324
|
type: "set",
|
|
2325
2325
|
inclusive: !0,
|
|
2326
2326
|
exact: !1,
|
|
2327
|
-
message:
|
|
2328
|
-
}), t.dirty()),
|
|
2327
|
+
message: n.minSize.message
|
|
2328
|
+
}), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (l(s, {
|
|
2329
2329
|
code: u.too_big,
|
|
2330
|
-
maximum:
|
|
2330
|
+
maximum: n.maxSize.value,
|
|
2331
2331
|
type: "set",
|
|
2332
2332
|
inclusive: !0,
|
|
2333
2333
|
exact: !1,
|
|
2334
|
-
message:
|
|
2334
|
+
message: n.maxSize.message
|
|
2335
2335
|
}), t.dirty());
|
|
2336
2336
|
const a = this._def.valueType;
|
|
2337
|
-
function i(
|
|
2338
|
-
const
|
|
2339
|
-
for (const
|
|
2340
|
-
if (
|
|
2337
|
+
function i(c) {
|
|
2338
|
+
const d = /* @__PURE__ */ new Set();
|
|
2339
|
+
for (const h of c) {
|
|
2340
|
+
if (h.status === "aborted")
|
|
2341
2341
|
return y;
|
|
2342
|
-
|
|
2342
|
+
h.status === "dirty" && t.dirty(), d.add(h.value);
|
|
2343
2343
|
}
|
|
2344
|
-
return { status: t.value, value:
|
|
2344
|
+
return { status: t.value, value: d };
|
|
2345
2345
|
}
|
|
2346
|
-
const o = [...
|
|
2347
|
-
return
|
|
2346
|
+
const o = [...s.data.values()].map((c, d) => a._parse(new R(s, c, s.path, d)));
|
|
2347
|
+
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2348
2348
|
}
|
|
2349
2349
|
min(e, t) {
|
|
2350
2350
|
return new J({
|
|
@@ -2372,7 +2372,7 @@ J.create = (r, e) => new J({
|
|
|
2372
2372
|
typeName: _.ZodSet,
|
|
2373
2373
|
...v(e)
|
|
2374
2374
|
});
|
|
2375
|
-
class
|
|
2375
|
+
class X extends g {
|
|
2376
2376
|
constructor() {
|
|
2377
2377
|
super(...arguments), this.validate = this.implement;
|
|
2378
2378
|
}
|
|
@@ -2384,58 +2384,58 @@ class K extends g {
|
|
|
2384
2384
|
expected: f.function,
|
|
2385
2385
|
received: t.parsedType
|
|
2386
2386
|
}), y;
|
|
2387
|
-
function
|
|
2388
|
-
return
|
|
2387
|
+
function s(o, c) {
|
|
2388
|
+
return Te({
|
|
2389
2389
|
data: o,
|
|
2390
2390
|
path: t.path,
|
|
2391
2391
|
errorMaps: [
|
|
2392
2392
|
t.common.contextualErrorMap,
|
|
2393
2393
|
t.schemaErrorMap,
|
|
2394
|
-
|
|
2394
|
+
we(),
|
|
2395
2395
|
Q
|
|
2396
|
-
].filter((
|
|
2396
|
+
].filter((d) => !!d),
|
|
2397
2397
|
issueData: {
|
|
2398
2398
|
code: u.invalid_arguments,
|
|
2399
|
-
argumentsError:
|
|
2399
|
+
argumentsError: c
|
|
2400
2400
|
}
|
|
2401
2401
|
});
|
|
2402
2402
|
}
|
|
2403
|
-
function
|
|
2404
|
-
return
|
|
2403
|
+
function n(o, c) {
|
|
2404
|
+
return Te({
|
|
2405
2405
|
data: o,
|
|
2406
2406
|
path: t.path,
|
|
2407
2407
|
errorMaps: [
|
|
2408
2408
|
t.common.contextualErrorMap,
|
|
2409
2409
|
t.schemaErrorMap,
|
|
2410
|
-
|
|
2410
|
+
we(),
|
|
2411
2411
|
Q
|
|
2412
|
-
].filter((
|
|
2412
|
+
].filter((d) => !!d),
|
|
2413
2413
|
issueData: {
|
|
2414
2414
|
code: u.invalid_return_type,
|
|
2415
|
-
returnTypeError:
|
|
2415
|
+
returnTypeError: c
|
|
2416
2416
|
}
|
|
2417
2417
|
});
|
|
2418
2418
|
}
|
|
2419
2419
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2420
2420
|
if (this._def.returns instanceof te) {
|
|
2421
2421
|
const o = this;
|
|
2422
|
-
return
|
|
2423
|
-
const
|
|
2424
|
-
throw
|
|
2425
|
-
}), b = await Reflect.apply(i, this,
|
|
2422
|
+
return S(async function(...c) {
|
|
2423
|
+
const d = new C([]), h = await o._def.args.parseAsync(c, a).catch((w) => {
|
|
2424
|
+
throw d.addIssue(s(c, w)), d;
|
|
2425
|
+
}), b = await Reflect.apply(i, this, h);
|
|
2426
2426
|
return await o._def.returns._def.type.parseAsync(b, a).catch((w) => {
|
|
2427
|
-
throw
|
|
2427
|
+
throw d.addIssue(n(b, w)), d;
|
|
2428
2428
|
});
|
|
2429
2429
|
});
|
|
2430
2430
|
} else {
|
|
2431
2431
|
const o = this;
|
|
2432
|
-
return
|
|
2433
|
-
const
|
|
2434
|
-
if (!
|
|
2435
|
-
throw new
|
|
2436
|
-
const
|
|
2432
|
+
return S(function(...c) {
|
|
2433
|
+
const d = o._def.args.safeParse(c, a);
|
|
2434
|
+
if (!d.success)
|
|
2435
|
+
throw new C([s(c, d.error)]);
|
|
2436
|
+
const h = Reflect.apply(i, this, d.data), b = o._def.returns.safeParse(h, a);
|
|
2437
2437
|
if (!b.success)
|
|
2438
|
-
throw new
|
|
2438
|
+
throw new C([n(h, b.error)]);
|
|
2439
2439
|
return b.data;
|
|
2440
2440
|
});
|
|
2441
2441
|
}
|
|
@@ -2447,13 +2447,13 @@ class K extends g {
|
|
|
2447
2447
|
return this._def.returns;
|
|
2448
2448
|
}
|
|
2449
2449
|
args(...e) {
|
|
2450
|
-
return new
|
|
2450
|
+
return new X({
|
|
2451
2451
|
...this._def,
|
|
2452
2452
|
args: N.create(e).rest(F.create())
|
|
2453
2453
|
});
|
|
2454
2454
|
}
|
|
2455
2455
|
returns(e) {
|
|
2456
|
-
return new
|
|
2456
|
+
return new X({
|
|
2457
2457
|
...this._def,
|
|
2458
2458
|
returns: e
|
|
2459
2459
|
});
|
|
@@ -2464,12 +2464,12 @@ class K extends g {
|
|
|
2464
2464
|
strictImplement(e) {
|
|
2465
2465
|
return this.parse(e);
|
|
2466
2466
|
}
|
|
2467
|
-
static create(e, t,
|
|
2468
|
-
return new
|
|
2467
|
+
static create(e, t, s) {
|
|
2468
|
+
return new X({
|
|
2469
2469
|
args: e || N.create([]).rest(F.create()),
|
|
2470
2470
|
returns: t || F.create(),
|
|
2471
2471
|
typeName: _.ZodFunction,
|
|
2472
|
-
...v(
|
|
2472
|
+
...v(s)
|
|
2473
2473
|
});
|
|
2474
2474
|
}
|
|
2475
2475
|
}
|
|
@@ -2521,22 +2521,22 @@ class z extends g {
|
|
|
2521
2521
|
}
|
|
2522
2522
|
_parse(e) {
|
|
2523
2523
|
if (typeof e.data != "string") {
|
|
2524
|
-
const t = this._getOrReturnCtx(e),
|
|
2524
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2525
2525
|
return l(t, {
|
|
2526
|
-
expected: x.joinValues(
|
|
2526
|
+
expected: x.joinValues(s),
|
|
2527
2527
|
received: t.parsedType,
|
|
2528
2528
|
code: u.invalid_type
|
|
2529
2529
|
}), y;
|
|
2530
2530
|
}
|
|
2531
|
-
if (
|
|
2532
|
-
const t = this._getOrReturnCtx(e),
|
|
2531
|
+
if (Se(this, ae) || Xe(this, ae, new Set(this._def.values)), !Se(this, ae).has(e.data)) {
|
|
2532
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2533
2533
|
return l(t, {
|
|
2534
2534
|
received: t.data,
|
|
2535
2535
|
code: u.invalid_enum_value,
|
|
2536
|
-
options:
|
|
2536
|
+
options: s
|
|
2537
2537
|
}), y;
|
|
2538
2538
|
}
|
|
2539
|
-
return
|
|
2539
|
+
return S(e.data);
|
|
2540
2540
|
}
|
|
2541
2541
|
get options() {
|
|
2542
2542
|
return this._def.values;
|
|
@@ -2566,7 +2566,7 @@ class z extends g {
|
|
|
2566
2566
|
});
|
|
2567
2567
|
}
|
|
2568
2568
|
exclude(e, t = this._def) {
|
|
2569
|
-
return z.create(this.options.filter((
|
|
2569
|
+
return z.create(this.options.filter((s) => !e.includes(s)), {
|
|
2570
2570
|
...this._def,
|
|
2571
2571
|
...t
|
|
2572
2572
|
});
|
|
@@ -2579,24 +2579,24 @@ class _e extends g {
|
|
|
2579
2579
|
super(...arguments), ie.set(this, void 0);
|
|
2580
2580
|
}
|
|
2581
2581
|
_parse(e) {
|
|
2582
|
-
const t = x.getValidEnumValues(this._def.values),
|
|
2583
|
-
if (
|
|
2584
|
-
const
|
|
2585
|
-
return l(
|
|
2586
|
-
expected: x.joinValues(
|
|
2587
|
-
received:
|
|
2582
|
+
const t = x.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2583
|
+
if (s.parsedType !== f.string && s.parsedType !== f.number) {
|
|
2584
|
+
const n = x.objectValues(t);
|
|
2585
|
+
return l(s, {
|
|
2586
|
+
expected: x.joinValues(n),
|
|
2587
|
+
received: s.parsedType,
|
|
2588
2588
|
code: u.invalid_type
|
|
2589
2589
|
}), y;
|
|
2590
2590
|
}
|
|
2591
|
-
if (
|
|
2592
|
-
const
|
|
2593
|
-
return l(
|
|
2594
|
-
received:
|
|
2591
|
+
if (Se(this, ie) || Xe(this, ie, new Set(x.getValidEnumValues(this._def.values))), !Se(this, ie).has(e.data)) {
|
|
2592
|
+
const n = x.objectValues(t);
|
|
2593
|
+
return l(s, {
|
|
2594
|
+
received: s.data,
|
|
2595
2595
|
code: u.invalid_enum_value,
|
|
2596
|
-
options:
|
|
2596
|
+
options: n
|
|
2597
2597
|
}), y;
|
|
2598
2598
|
}
|
|
2599
|
-
return
|
|
2599
|
+
return S(e.data);
|
|
2600
2600
|
}
|
|
2601
2601
|
get enum() {
|
|
2602
2602
|
return this._def.values;
|
|
@@ -2620,8 +2620,8 @@ class te extends g {
|
|
|
2620
2620
|
expected: f.promise,
|
|
2621
2621
|
received: t.parsedType
|
|
2622
2622
|
}), y;
|
|
2623
|
-
const
|
|
2624
|
-
return
|
|
2623
|
+
const s = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2624
|
+
return S(s.then((n) => this._def.type.parseAsync(n, {
|
|
2625
2625
|
path: t.path,
|
|
2626
2626
|
errorMap: t.common.contextualErrorMap
|
|
2627
2627
|
})));
|
|
@@ -2640,73 +2640,73 @@ class A extends g {
|
|
|
2640
2640
|
return this._def.schema._def.typeName === _.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2641
2641
|
}
|
|
2642
2642
|
_parse(e) {
|
|
2643
|
-
const { status: t, ctx:
|
|
2643
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
|
|
2644
2644
|
addIssue: (i) => {
|
|
2645
|
-
l(
|
|
2645
|
+
l(s, i), i.fatal ? t.abort() : t.dirty();
|
|
2646
2646
|
},
|
|
2647
2647
|
get path() {
|
|
2648
|
-
return
|
|
2648
|
+
return s.path;
|
|
2649
2649
|
}
|
|
2650
2650
|
};
|
|
2651
|
-
if (a.addIssue = a.addIssue.bind(a),
|
|
2652
|
-
const i =
|
|
2653
|
-
if (
|
|
2651
|
+
if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
|
|
2652
|
+
const i = n.transform(s.data, a);
|
|
2653
|
+
if (s.common.async)
|
|
2654
2654
|
return Promise.resolve(i).then(async (o) => {
|
|
2655
2655
|
if (t.value === "aborted")
|
|
2656
2656
|
return y;
|
|
2657
|
-
const
|
|
2657
|
+
const c = await this._def.schema._parseAsync({
|
|
2658
2658
|
data: o,
|
|
2659
|
-
path:
|
|
2660
|
-
parent:
|
|
2659
|
+
path: s.path,
|
|
2660
|
+
parent: s
|
|
2661
2661
|
});
|
|
2662
|
-
return
|
|
2662
|
+
return c.status === "aborted" ? y : c.status === "dirty" || t.value === "dirty" ? K(c.value) : c;
|
|
2663
2663
|
});
|
|
2664
2664
|
{
|
|
2665
2665
|
if (t.value === "aborted")
|
|
2666
2666
|
return y;
|
|
2667
2667
|
const o = this._def.schema._parseSync({
|
|
2668
2668
|
data: i,
|
|
2669
|
-
path:
|
|
2670
|
-
parent:
|
|
2669
|
+
path: s.path,
|
|
2670
|
+
parent: s
|
|
2671
2671
|
});
|
|
2672
|
-
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ?
|
|
2672
|
+
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? K(o.value) : o;
|
|
2673
2673
|
}
|
|
2674
2674
|
}
|
|
2675
|
-
if (
|
|
2675
|
+
if (n.type === "refinement") {
|
|
2676
2676
|
const i = (o) => {
|
|
2677
|
-
const
|
|
2678
|
-
if (
|
|
2679
|
-
return Promise.resolve(
|
|
2680
|
-
if (
|
|
2677
|
+
const c = n.refinement(o, a);
|
|
2678
|
+
if (s.common.async)
|
|
2679
|
+
return Promise.resolve(c);
|
|
2680
|
+
if (c instanceof Promise)
|
|
2681
2681
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2682
2682
|
return o;
|
|
2683
2683
|
};
|
|
2684
|
-
if (
|
|
2684
|
+
if (s.common.async === !1) {
|
|
2685
2685
|
const o = this._def.schema._parseSync({
|
|
2686
|
-
data:
|
|
2687
|
-
path:
|
|
2688
|
-
parent:
|
|
2686
|
+
data: s.data,
|
|
2687
|
+
path: s.path,
|
|
2688
|
+
parent: s
|
|
2689
2689
|
});
|
|
2690
2690
|
return o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2691
2691
|
} else
|
|
2692
|
-
return this._def.schema._parseAsync({ data:
|
|
2692
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2693
2693
|
}
|
|
2694
|
-
if (
|
|
2695
|
-
if (
|
|
2694
|
+
if (n.type === "transform")
|
|
2695
|
+
if (s.common.async === !1) {
|
|
2696
2696
|
const i = this._def.schema._parseSync({
|
|
2697
|
-
data:
|
|
2698
|
-
path:
|
|
2699
|
-
parent:
|
|
2697
|
+
data: s.data,
|
|
2698
|
+
path: s.path,
|
|
2699
|
+
parent: s
|
|
2700
2700
|
});
|
|
2701
|
-
if (!
|
|
2701
|
+
if (!q(i))
|
|
2702
2702
|
return i;
|
|
2703
|
-
const o =
|
|
2703
|
+
const o = n.transform(i.value, a);
|
|
2704
2704
|
if (o instanceof Promise)
|
|
2705
2705
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2706
2706
|
return { status: t.value, value: o };
|
|
2707
2707
|
} else
|
|
2708
|
-
return this._def.schema._parseAsync({ data:
|
|
2709
|
-
x.assertNever(
|
|
2708
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => q(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
2709
|
+
x.assertNever(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
}
|
|
2712
2712
|
A.create = (r, e, t) => new A({
|
|
@@ -2723,7 +2723,7 @@ A.createWithPreprocess = (r, e, t) => new A({
|
|
|
2723
2723
|
});
|
|
2724
2724
|
class E extends g {
|
|
2725
2725
|
_parse(e) {
|
|
2726
|
-
return this._getType(e) === f.undefined ?
|
|
2726
|
+
return this._getType(e) === f.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
2727
2727
|
}
|
|
2728
2728
|
unwrap() {
|
|
2729
2729
|
return this._def.innerType;
|
|
@@ -2736,7 +2736,7 @@ E.create = (r, e) => new E({
|
|
|
2736
2736
|
});
|
|
2737
2737
|
class U extends g {
|
|
2738
2738
|
_parse(e) {
|
|
2739
|
-
return this._getType(e) === f.null ?
|
|
2739
|
+
return this._getType(e) === f.null ? S(null) : this._def.innerType._parse(e);
|
|
2740
2740
|
}
|
|
2741
2741
|
unwrap() {
|
|
2742
2742
|
return this._def.innerType;
|
|
@@ -2750,9 +2750,9 @@ U.create = (r, e) => new U({
|
|
|
2750
2750
|
class ye extends g {
|
|
2751
2751
|
_parse(e) {
|
|
2752
2752
|
const { ctx: t } = this._processInputParams(e);
|
|
2753
|
-
let
|
|
2754
|
-
return t.parsedType === f.undefined && (
|
|
2755
|
-
data:
|
|
2753
|
+
let s = t.data;
|
|
2754
|
+
return t.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2755
|
+
data: s,
|
|
2756
2756
|
path: t.path,
|
|
2757
2757
|
parent: t
|
|
2758
2758
|
});
|
|
@@ -2769,34 +2769,34 @@ ye.create = (r, e) => new ye({
|
|
|
2769
2769
|
});
|
|
2770
2770
|
class ve extends g {
|
|
2771
2771
|
_parse(e) {
|
|
2772
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2772
|
+
const { ctx: t } = this._processInputParams(e), s = {
|
|
2773
2773
|
...t,
|
|
2774
2774
|
common: {
|
|
2775
2775
|
...t.common,
|
|
2776
2776
|
issues: []
|
|
2777
2777
|
}
|
|
2778
|
-
},
|
|
2779
|
-
data:
|
|
2780
|
-
path:
|
|
2778
|
+
}, n = this._def.innerType._parse({
|
|
2779
|
+
data: s.data,
|
|
2780
|
+
path: s.path,
|
|
2781
2781
|
parent: {
|
|
2782
|
-
...
|
|
2782
|
+
...s
|
|
2783
2783
|
}
|
|
2784
2784
|
});
|
|
2785
|
-
return oe(
|
|
2785
|
+
return oe(n) ? n.then((a) => ({
|
|
2786
2786
|
status: "valid",
|
|
2787
2787
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2788
2788
|
get error() {
|
|
2789
|
-
return new
|
|
2789
|
+
return new C(s.common.issues);
|
|
2790
2790
|
},
|
|
2791
|
-
input:
|
|
2791
|
+
input: s.data
|
|
2792
2792
|
})
|
|
2793
2793
|
})) : {
|
|
2794
2794
|
status: "valid",
|
|
2795
|
-
value:
|
|
2795
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2796
2796
|
get error() {
|
|
2797
|
-
return new
|
|
2797
|
+
return new C(s.common.issues);
|
|
2798
2798
|
},
|
|
2799
|
-
input:
|
|
2799
|
+
input: s.data
|
|
2800
2800
|
})
|
|
2801
2801
|
};
|
|
2802
2802
|
}
|
|
@@ -2813,11 +2813,11 @@ ve.create = (r, e) => new ve({
|
|
|
2813
2813
|
class je extends g {
|
|
2814
2814
|
_parse(e) {
|
|
2815
2815
|
if (this._getType(e) !== f.nan) {
|
|
2816
|
-
const
|
|
2817
|
-
return l(
|
|
2816
|
+
const s = this._getOrReturnCtx(e);
|
|
2817
|
+
return l(s, {
|
|
2818
2818
|
code: u.invalid_type,
|
|
2819
2819
|
expected: f.nan,
|
|
2820
|
-
received:
|
|
2820
|
+
received: s.parsedType
|
|
2821
2821
|
}), y;
|
|
2822
2822
|
}
|
|
2823
2823
|
return { status: "valid", value: e.data };
|
|
@@ -2830,9 +2830,9 @@ je.create = (r) => new je({
|
|
|
2830
2830
|
const Vt = Symbol("zod_brand");
|
|
2831
2831
|
class Je extends g {
|
|
2832
2832
|
_parse(e) {
|
|
2833
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2833
|
+
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
2834
2834
|
return this._def.type._parse({
|
|
2835
|
-
data:
|
|
2835
|
+
data: s,
|
|
2836
2836
|
path: t.path,
|
|
2837
2837
|
parent: t
|
|
2838
2838
|
});
|
|
@@ -2843,33 +2843,33 @@ class Je extends g {
|
|
|
2843
2843
|
}
|
|
2844
2844
|
class xe extends g {
|
|
2845
2845
|
_parse(e) {
|
|
2846
|
-
const { status: t, ctx:
|
|
2847
|
-
if (
|
|
2846
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2847
|
+
if (s.common.async)
|
|
2848
2848
|
return (async () => {
|
|
2849
2849
|
const a = await this._def.in._parseAsync({
|
|
2850
|
-
data:
|
|
2851
|
-
path:
|
|
2852
|
-
parent:
|
|
2850
|
+
data: s.data,
|
|
2851
|
+
path: s.path,
|
|
2852
|
+
parent: s
|
|
2853
2853
|
});
|
|
2854
|
-
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(),
|
|
2854
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), K(a.value)) : this._def.out._parseAsync({
|
|
2855
2855
|
data: a.value,
|
|
2856
|
-
path:
|
|
2857
|
-
parent:
|
|
2856
|
+
path: s.path,
|
|
2857
|
+
parent: s
|
|
2858
2858
|
});
|
|
2859
2859
|
})();
|
|
2860
2860
|
{
|
|
2861
|
-
const
|
|
2862
|
-
data:
|
|
2863
|
-
path:
|
|
2864
|
-
parent:
|
|
2861
|
+
const n = this._def.in._parseSync({
|
|
2862
|
+
data: s.data,
|
|
2863
|
+
path: s.path,
|
|
2864
|
+
parent: s
|
|
2865
2865
|
});
|
|
2866
|
-
return
|
|
2866
|
+
return n.status === "aborted" ? y : n.status === "dirty" ? (t.dirty(), {
|
|
2867
2867
|
status: "dirty",
|
|
2868
|
-
value:
|
|
2868
|
+
value: n.value
|
|
2869
2869
|
}) : this._def.out._parseSync({
|
|
2870
|
-
data:
|
|
2871
|
-
path:
|
|
2872
|
-
parent:
|
|
2870
|
+
data: n.value,
|
|
2871
|
+
path: s.path,
|
|
2872
|
+
parent: s
|
|
2873
2873
|
});
|
|
2874
2874
|
}
|
|
2875
2875
|
}
|
|
@@ -2883,8 +2883,8 @@ class xe extends g {
|
|
|
2883
2883
|
}
|
|
2884
2884
|
class ge extends g {
|
|
2885
2885
|
_parse(e) {
|
|
2886
|
-
const t = this._def.innerType._parse(e),
|
|
2887
|
-
return oe(t) ? t.then((
|
|
2886
|
+
const t = this._def.innerType._parse(e), s = (n) => (q(n) && (n.value = Object.freeze(n.value)), n);
|
|
2887
|
+
return oe(t) ? t.then((n) => s(n)) : s(t);
|
|
2888
2888
|
}
|
|
2889
2889
|
unwrap() {
|
|
2890
2890
|
return this._def.innerType;
|
|
@@ -2899,21 +2899,21 @@ function Ye(r, e) {
|
|
|
2899
2899
|
const t = typeof r == "function" ? r(e) : typeof r == "string" ? { message: r } : r;
|
|
2900
2900
|
return typeof t == "string" ? { message: t } : t;
|
|
2901
2901
|
}
|
|
2902
|
-
function
|
|
2903
|
-
return r ? ee.create().superRefine((
|
|
2902
|
+
function st(r, e = {}, t) {
|
|
2903
|
+
return r ? ee.create().superRefine((s, n) => {
|
|
2904
2904
|
var a, i;
|
|
2905
|
-
const o = r(
|
|
2905
|
+
const o = r(s);
|
|
2906
2906
|
if (o instanceof Promise)
|
|
2907
|
-
return o.then((
|
|
2908
|
-
var
|
|
2909
|
-
if (!
|
|
2910
|
-
const b = Ye(e,
|
|
2911
|
-
|
|
2907
|
+
return o.then((c) => {
|
|
2908
|
+
var d, h;
|
|
2909
|
+
if (!c) {
|
|
2910
|
+
const b = Ye(e, s), Z = (h = (d = b.fatal) !== null && d !== void 0 ? d : t) !== null && h !== void 0 ? h : !0;
|
|
2911
|
+
n.addIssue({ code: "custom", ...b, fatal: Z });
|
|
2912
2912
|
}
|
|
2913
2913
|
});
|
|
2914
2914
|
if (!o) {
|
|
2915
|
-
const
|
|
2916
|
-
|
|
2915
|
+
const c = Ye(e, s), d = (i = (a = c.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0;
|
|
2916
|
+
n.addIssue({ code: "custom", ...c, fatal: d });
|
|
2917
2917
|
}
|
|
2918
2918
|
}) : ee.create();
|
|
2919
2919
|
}
|
|
@@ -2926,31 +2926,31 @@ var _;
|
|
|
2926
2926
|
})(_ || (_ = {}));
|
|
2927
2927
|
const zt = (r, e = {
|
|
2928
2928
|
message: `Input not instance of ${r.name}`
|
|
2929
|
-
}) =>
|
|
2930
|
-
string: (r) =>
|
|
2929
|
+
}) => st((t) => t instanceof r, e), nt = O.create, at = V.create, Ut = je.create, Bt = L.create, it = ce.create, Ft = W.create, qt = Ze.create, Wt = de.create, Jt = ue.create, Ht = ee.create, Yt = F.create, Gt = P.create, Kt = Ce.create, Xt = j.create, Qt = k.create, er = k.strictCreate, tr = le.create, rr = Ee.create, sr = fe.create, nr = N.create, ar = he.create, ir = Oe.create, or = J.create, cr = X.create, dr = pe.create, ur = me.create, lr = z.create, fr = _e.create, hr = te.create, Ge = A.create, pr = E.create, mr = U.create, _r = A.createWithPreprocess, yr = xe.create, vr = () => nt().optional(), gr = () => at().optional(), xr = () => it().optional(), br = {
|
|
2930
|
+
string: (r) => O.create({ ...r, coerce: !0 }),
|
|
2931
2931
|
number: (r) => V.create({ ...r, coerce: !0 }),
|
|
2932
|
-
boolean: (r) =>
|
|
2932
|
+
boolean: (r) => ce.create({
|
|
2933
2933
|
...r,
|
|
2934
2934
|
coerce: !0
|
|
2935
2935
|
}),
|
|
2936
2936
|
bigint: (r) => L.create({ ...r, coerce: !0 }),
|
|
2937
|
-
date: (r) =>
|
|
2937
|
+
date: (r) => W.create({ ...r, coerce: !0 })
|
|
2938
2938
|
}, kr = y;
|
|
2939
|
-
var
|
|
2939
|
+
var p = /* @__PURE__ */ Object.freeze({
|
|
2940
2940
|
__proto__: null,
|
|
2941
2941
|
defaultErrorMap: Q,
|
|
2942
2942
|
setErrorMap: _t,
|
|
2943
|
-
getErrorMap:
|
|
2944
|
-
makeIssue:
|
|
2943
|
+
getErrorMap: we,
|
|
2944
|
+
makeIssue: Te,
|
|
2945
2945
|
EMPTY_PATH: yt,
|
|
2946
2946
|
addIssueToContext: l,
|
|
2947
2947
|
ParseStatus: T,
|
|
2948
2948
|
INVALID: y,
|
|
2949
|
-
DIRTY:
|
|
2950
|
-
OK:
|
|
2949
|
+
DIRTY: K,
|
|
2950
|
+
OK: S,
|
|
2951
2951
|
isAborted: Fe,
|
|
2952
|
-
isDirty:
|
|
2953
|
-
isValid:
|
|
2952
|
+
isDirty: qe,
|
|
2953
|
+
isValid: q,
|
|
2954
2954
|
isAsync: oe,
|
|
2955
2955
|
get util() {
|
|
2956
2956
|
return x;
|
|
@@ -2962,28 +2962,28 @@ var h = /* @__PURE__ */ Object.freeze({
|
|
|
2962
2962
|
getParsedType: $,
|
|
2963
2963
|
ZodType: g,
|
|
2964
2964
|
datetimeRegex: tt,
|
|
2965
|
-
ZodString:
|
|
2965
|
+
ZodString: O,
|
|
2966
2966
|
ZodNumber: V,
|
|
2967
2967
|
ZodBigInt: L,
|
|
2968
|
-
ZodBoolean:
|
|
2969
|
-
ZodDate:
|
|
2968
|
+
ZodBoolean: ce,
|
|
2969
|
+
ZodDate: W,
|
|
2970
2970
|
ZodSymbol: Ze,
|
|
2971
|
-
ZodUndefined:
|
|
2971
|
+
ZodUndefined: de,
|
|
2972
2972
|
ZodNull: ue,
|
|
2973
2973
|
ZodAny: ee,
|
|
2974
2974
|
ZodUnknown: F,
|
|
2975
|
-
ZodNever:
|
|
2976
|
-
ZodVoid:
|
|
2977
|
-
ZodArray:
|
|
2975
|
+
ZodNever: P,
|
|
2976
|
+
ZodVoid: Ce,
|
|
2977
|
+
ZodArray: j,
|
|
2978
2978
|
ZodObject: k,
|
|
2979
2979
|
ZodUnion: le,
|
|
2980
|
-
ZodDiscriminatedUnion:
|
|
2980
|
+
ZodDiscriminatedUnion: Ee,
|
|
2981
2981
|
ZodIntersection: fe,
|
|
2982
2982
|
ZodTuple: N,
|
|
2983
2983
|
ZodRecord: he,
|
|
2984
|
-
ZodMap:
|
|
2984
|
+
ZodMap: Oe,
|
|
2985
2985
|
ZodSet: J,
|
|
2986
|
-
ZodFunction:
|
|
2986
|
+
ZodFunction: X,
|
|
2987
2987
|
ZodLazy: pe,
|
|
2988
2988
|
ZodLiteral: me,
|
|
2989
2989
|
ZodEnum: z,
|
|
@@ -3000,7 +3000,7 @@ var h = /* @__PURE__ */ Object.freeze({
|
|
|
3000
3000
|
ZodBranded: Je,
|
|
3001
3001
|
ZodPipeline: xe,
|
|
3002
3002
|
ZodReadonly: ge,
|
|
3003
|
-
custom:
|
|
3003
|
+
custom: st,
|
|
3004
3004
|
Schema: g,
|
|
3005
3005
|
ZodSchema: g,
|
|
3006
3006
|
late: Lt,
|
|
@@ -3009,17 +3009,17 @@ var h = /* @__PURE__ */ Object.freeze({
|
|
|
3009
3009
|
},
|
|
3010
3010
|
coerce: br,
|
|
3011
3011
|
any: Ht,
|
|
3012
|
-
array:
|
|
3012
|
+
array: Xt,
|
|
3013
3013
|
bigint: Bt,
|
|
3014
3014
|
boolean: it,
|
|
3015
3015
|
date: Ft,
|
|
3016
3016
|
discriminatedUnion: rr,
|
|
3017
3017
|
effect: Ge,
|
|
3018
3018
|
enum: lr,
|
|
3019
|
-
function:
|
|
3019
|
+
function: cr,
|
|
3020
3020
|
instanceof: zt,
|
|
3021
|
-
intersection:
|
|
3022
|
-
lazy:
|
|
3021
|
+
intersection: sr,
|
|
3022
|
+
lazy: dr,
|
|
3023
3023
|
literal: ur,
|
|
3024
3024
|
map: ir,
|
|
3025
3025
|
nan: Ut,
|
|
@@ -3039,139 +3039,139 @@ var h = /* @__PURE__ */ Object.freeze({
|
|
|
3039
3039
|
record: ar,
|
|
3040
3040
|
set: or,
|
|
3041
3041
|
strictObject: er,
|
|
3042
|
-
string:
|
|
3043
|
-
symbol:
|
|
3042
|
+
string: nt,
|
|
3043
|
+
symbol: qt,
|
|
3044
3044
|
transformer: Ge,
|
|
3045
|
-
tuple:
|
|
3046
|
-
undefined:
|
|
3045
|
+
tuple: nr,
|
|
3046
|
+
undefined: Wt,
|
|
3047
3047
|
union: tr,
|
|
3048
3048
|
unknown: Yt,
|
|
3049
|
-
void:
|
|
3049
|
+
void: Kt,
|
|
3050
3050
|
NEVER: kr,
|
|
3051
3051
|
ZodIssueCode: u,
|
|
3052
3052
|
quotelessJson: mt,
|
|
3053
|
-
ZodError:
|
|
3053
|
+
ZodError: C
|
|
3054
3054
|
});
|
|
3055
|
-
pt(
|
|
3056
|
-
const wr = (r, e) => e.skipDedupe || e.method !== "GET", Tr = (r, e) => e.method + "@" + r,
|
|
3057
|
-
const
|
|
3058
|
-
return (
|
|
3055
|
+
pt(p);
|
|
3056
|
+
const wr = (r, e) => e.skipDedupe || e.method !== "GET", Tr = (r, e) => e.method + "@" + r, Sr = (r) => r.clone(), Zr = ({ skip: r = wr, key: e = Tr, resolver: t = Sr } = {}) => {
|
|
3057
|
+
const s = /* @__PURE__ */ new Map();
|
|
3058
|
+
return (n) => (a, i) => {
|
|
3059
3059
|
if (r(a, i))
|
|
3060
|
-
return
|
|
3060
|
+
return n(a, i);
|
|
3061
3061
|
const o = e(a, i);
|
|
3062
|
-
if (!
|
|
3063
|
-
|
|
3062
|
+
if (!s.has(o))
|
|
3063
|
+
s.set(o, []);
|
|
3064
3064
|
else
|
|
3065
|
-
return new Promise((
|
|
3066
|
-
|
|
3065
|
+
return new Promise((c, d) => {
|
|
3066
|
+
s.get(o).push([c, d]);
|
|
3067
3067
|
});
|
|
3068
3068
|
try {
|
|
3069
|
-
return
|
|
3070
|
-
throw
|
|
3069
|
+
return n(a, i).then((c) => (s.get(o).forEach(([d]) => d(t(c))), s.delete(o), c)).catch((c) => {
|
|
3070
|
+
throw s.get(o).forEach(([, d]) => d(c)), s.delete(o), c;
|
|
3071
3071
|
});
|
|
3072
|
-
} catch (
|
|
3073
|
-
return
|
|
3072
|
+
} catch (c) {
|
|
3073
|
+
return s.delete(o), Promise.reject(c);
|
|
3074
3074
|
}
|
|
3075
3075
|
};
|
|
3076
|
-
},
|
|
3076
|
+
}, Cr = (r, e) => r * e, Or = (r) => r && r.ok, jr = ({ delayTimer: r = 500, delayRamp: e = Cr, maxAttempts: t = 10, until: s = Or, onRetry: n = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (d, h) => {
|
|
3077
3077
|
let b = 0;
|
|
3078
|
-
if (o && o(
|
|
3079
|
-
return d
|
|
3080
|
-
const
|
|
3078
|
+
if (o && o(d, h))
|
|
3079
|
+
return c(d, h);
|
|
3080
|
+
const Z = (w, M) => Promise.resolve(s(w, M)).then((Re) => Re ? w && i ? w : M ? Promise.reject(M) : w : (b++, !t || b <= t ? new Promise((D) => {
|
|
3081
3081
|
const be = e(r, b);
|
|
3082
3082
|
setTimeout(() => {
|
|
3083
|
-
typeof
|
|
3083
|
+
typeof n == "function" ? Promise.resolve(n({
|
|
3084
3084
|
response: w,
|
|
3085
|
-
error:
|
|
3086
|
-
url:
|
|
3087
|
-
options:
|
|
3085
|
+
error: M,
|
|
3086
|
+
url: d,
|
|
3087
|
+
options: h
|
|
3088
3088
|
})).then((B = {}) => {
|
|
3089
|
-
var re,
|
|
3090
|
-
D(
|
|
3091
|
-
}) : D(d
|
|
3089
|
+
var re, se;
|
|
3090
|
+
D(c((re = B && B.url) !== null && re !== void 0 ? re : d, (se = B && B.options) !== null && se !== void 0 ? se : h));
|
|
3091
|
+
}) : D(c(d, h));
|
|
3092
3092
|
}, be);
|
|
3093
|
-
}).then(
|
|
3093
|
+
}).then(Z).catch((D) => {
|
|
3094
3094
|
if (!a)
|
|
3095
3095
|
throw D;
|
|
3096
|
-
return
|
|
3097
|
-
}) : w && i ? w : Promise.reject(
|
|
3098
|
-
return d
|
|
3096
|
+
return Z(null, D);
|
|
3097
|
+
}) : w && i ? w : Promise.reject(M || new Error("Number of attempts exceeded."))));
|
|
3098
|
+
return c(d, h).then(Z).catch((w) => {
|
|
3099
3099
|
if (!a)
|
|
3100
3100
|
throw w;
|
|
3101
|
-
return
|
|
3101
|
+
return Z(null, w);
|
|
3102
3102
|
});
|
|
3103
|
-
},
|
|
3104
|
-
code:
|
|
3105
|
-
message:
|
|
3106
|
-
}), Ar =
|
|
3107
|
-
message:
|
|
3108
|
-
}), Er =
|
|
3109
|
-
emails:
|
|
3110
|
-
http_body:
|
|
3111
|
-
http_url:
|
|
3112
|
-
txt_name:
|
|
3113
|
-
txt_value:
|
|
3114
|
-
}), Rr =
|
|
3115
|
-
ciphers:
|
|
3116
|
-
early_hints:
|
|
3117
|
-
http2:
|
|
3118
|
-
min_tls_version:
|
|
3119
|
-
tls_1_3:
|
|
3120
|
-
}), Nr =
|
|
3121
|
-
id:
|
|
3122
|
-
bundle_method:
|
|
3123
|
-
certificate_authority:
|
|
3124
|
-
custom_certificate:
|
|
3125
|
-
custom_csr_id:
|
|
3126
|
-
custom_key:
|
|
3127
|
-
expires_on:
|
|
3128
|
-
hosts:
|
|
3129
|
-
issuer:
|
|
3130
|
-
method:
|
|
3131
|
-
serial_number:
|
|
3103
|
+
}, Ae = p.object({
|
|
3104
|
+
code: p.number(),
|
|
3105
|
+
message: p.string()
|
|
3106
|
+
}), Ar = p.object({
|
|
3107
|
+
message: p.string()
|
|
3108
|
+
}), Er = p.object({
|
|
3109
|
+
emails: p.array(p.string()).optional(),
|
|
3110
|
+
http_body: p.string().optional(),
|
|
3111
|
+
http_url: p.string().optional(),
|
|
3112
|
+
txt_name: p.string().optional(),
|
|
3113
|
+
txt_value: p.string().optional()
|
|
3114
|
+
}), Rr = p.object({
|
|
3115
|
+
ciphers: p.array(p.string()).optional(),
|
|
3116
|
+
early_hints: p.string().optional(),
|
|
3117
|
+
http2: p.string().optional(),
|
|
3118
|
+
min_tls_version: p.string().optional(),
|
|
3119
|
+
tls_1_3: p.string().optional()
|
|
3120
|
+
}), Nr = p.object({
|
|
3121
|
+
id: p.string(),
|
|
3122
|
+
bundle_method: p.string().optional(),
|
|
3123
|
+
certificate_authority: p.string(),
|
|
3124
|
+
custom_certificate: p.string().optional(),
|
|
3125
|
+
custom_csr_id: p.string().optional(),
|
|
3126
|
+
custom_key: p.string().optional(),
|
|
3127
|
+
expires_on: p.string().optional(),
|
|
3128
|
+
hosts: p.array(p.string()).optional(),
|
|
3129
|
+
issuer: p.string().optional(),
|
|
3130
|
+
method: p.string(),
|
|
3131
|
+
serial_number: p.string().optional(),
|
|
3132
3132
|
settings: Rr.optional(),
|
|
3133
|
-
signature:
|
|
3134
|
-
type:
|
|
3135
|
-
uploaded_on:
|
|
3136
|
-
validation_errors:
|
|
3137
|
-
validation_records:
|
|
3138
|
-
wildcard:
|
|
3139
|
-
}), Ir =
|
|
3140
|
-
name:
|
|
3141
|
-
type:
|
|
3142
|
-
value:
|
|
3143
|
-
}), $r =
|
|
3144
|
-
http_body:
|
|
3145
|
-
http_url:
|
|
3146
|
-
}), ot =
|
|
3147
|
-
id:
|
|
3133
|
+
signature: p.string().optional(),
|
|
3134
|
+
type: p.string(),
|
|
3135
|
+
uploaded_on: p.string().optional(),
|
|
3136
|
+
validation_errors: p.array(Ar).optional(),
|
|
3137
|
+
validation_records: p.array(Er).optional(),
|
|
3138
|
+
wildcard: p.boolean()
|
|
3139
|
+
}), Ir = p.object({
|
|
3140
|
+
name: p.string(),
|
|
3141
|
+
type: p.string(),
|
|
3142
|
+
value: p.string()
|
|
3143
|
+
}), $r = p.object({
|
|
3144
|
+
http_body: p.string().optional(),
|
|
3145
|
+
http_url: p.string().optional()
|
|
3146
|
+
}), ot = p.object({
|
|
3147
|
+
id: p.string(),
|
|
3148
3148
|
ssl: Nr,
|
|
3149
|
-
hostname:
|
|
3150
|
-
custom_metadata:
|
|
3151
|
-
custom_origin_server:
|
|
3152
|
-
custom_origin_sni:
|
|
3149
|
+
hostname: p.string(),
|
|
3150
|
+
custom_metadata: p.record(p.string()).optional(),
|
|
3151
|
+
custom_origin_server: p.string().optional(),
|
|
3152
|
+
custom_origin_sni: p.string().optional(),
|
|
3153
3153
|
ownership_verification: Ir.optional(),
|
|
3154
3154
|
ownership_verification_http: $r.optional(),
|
|
3155
|
-
status:
|
|
3156
|
-
verification_errors:
|
|
3157
|
-
created_at:
|
|
3158
|
-
}), ze =
|
|
3159
|
-
errors:
|
|
3160
|
-
messages:
|
|
3161
|
-
success:
|
|
3155
|
+
status: p.string(),
|
|
3156
|
+
verification_errors: p.array(p.string()).optional(),
|
|
3157
|
+
created_at: p.string()
|
|
3158
|
+
}), ze = p.object({
|
|
3159
|
+
errors: p.array(Ae),
|
|
3160
|
+
messages: p.array(Ae),
|
|
3161
|
+
success: p.boolean(),
|
|
3162
3162
|
result: ot
|
|
3163
|
-
}),
|
|
3164
|
-
errors:
|
|
3165
|
-
messages:
|
|
3166
|
-
success:
|
|
3167
|
-
result:
|
|
3163
|
+
}), Pr = p.object({
|
|
3164
|
+
errors: p.array(Ae),
|
|
3165
|
+
messages: p.array(Ae),
|
|
3166
|
+
success: p.boolean(),
|
|
3167
|
+
result: p.array(ot)
|
|
3168
3168
|
});
|
|
3169
3169
|
function Y(r) {
|
|
3170
3170
|
return lt(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({
|
|
3171
3171
|
"X-Auth-Email": r.authEmail,
|
|
3172
3172
|
"X-Auth-Key": r.authKey,
|
|
3173
3173
|
"Content-Type": "application/json"
|
|
3174
|
-
}).middlewares([
|
|
3174
|
+
}).middlewares([jr(), Zr()]);
|
|
3175
3175
|
}
|
|
3176
3176
|
function Ue(r) {
|
|
3177
3177
|
const e = [];
|
|
@@ -3193,14 +3193,14 @@ function Ue(r) {
|
|
|
3193
3193
|
status: r.status === "active" ? "ready" : "pending",
|
|
3194
3194
|
type: "auth0_managed_certs",
|
|
3195
3195
|
verification: {
|
|
3196
|
-
methods:
|
|
3196
|
+
methods: p.array(ut).parse(e)
|
|
3197
3197
|
}
|
|
3198
3198
|
};
|
|
3199
3199
|
}
|
|
3200
|
-
function
|
|
3200
|
+
function Mr(r) {
|
|
3201
3201
|
return {
|
|
3202
3202
|
create: async (e, t) => {
|
|
3203
|
-
const { result:
|
|
3203
|
+
const { result: s, errors: n, success: a } = ze.parse(
|
|
3204
3204
|
await Y(r).post(
|
|
3205
3205
|
{
|
|
3206
3206
|
hostname: t.domain,
|
|
@@ -3216,9 +3216,9 @@ function Pr(r) {
|
|
|
3216
3216
|
).json()
|
|
3217
3217
|
);
|
|
3218
3218
|
if (!a)
|
|
3219
|
-
throw new Error(JSON.stringify(
|
|
3219
|
+
throw new Error(JSON.stringify(n));
|
|
3220
3220
|
const i = Ue({
|
|
3221
|
-
...
|
|
3221
|
+
...s,
|
|
3222
3222
|
primary: !1
|
|
3223
3223
|
});
|
|
3224
3224
|
return await r.customDomainAdapter.create(e, {
|
|
@@ -3228,77 +3228,147 @@ function Pr(r) {
|
|
|
3228
3228
|
}), i;
|
|
3229
3229
|
},
|
|
3230
3230
|
get: async (e, t) => {
|
|
3231
|
-
var
|
|
3232
|
-
const
|
|
3231
|
+
var c;
|
|
3232
|
+
const s = await r.customDomainAdapter.get(
|
|
3233
3233
|
e,
|
|
3234
3234
|
t
|
|
3235
3235
|
);
|
|
3236
|
-
if (!
|
|
3236
|
+
if (!s)
|
|
3237
3237
|
throw new H(404);
|
|
3238
|
-
const
|
|
3238
|
+
const n = await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(), { result: a, errors: i, success: o } = ze.parse(n);
|
|
3239
3239
|
if (!o)
|
|
3240
3240
|
throw new H(503, {
|
|
3241
3241
|
message: JSON.stringify(i)
|
|
3242
3242
|
});
|
|
3243
|
-
if (r.enterprise && ((
|
|
3243
|
+
if (r.enterprise && ((c = a.custom_metadata) == null ? void 0 : c.tenant_id) !== e)
|
|
3244
3244
|
throw new H(404);
|
|
3245
|
-
return Ue({ ...
|
|
3245
|
+
return Ue({ ...s, ...a });
|
|
3246
3246
|
},
|
|
3247
3247
|
getByDomain: async (e) => r.customDomainAdapter.getByDomain(e),
|
|
3248
3248
|
list: async (e) => {
|
|
3249
|
-
const t = await r.customDomainAdapter.list(e),
|
|
3249
|
+
const t = await r.customDomainAdapter.list(e), s = await Y(r).get("/custom_hostnames").json(), { result: n, errors: a, success: i } = Pr.parse(s);
|
|
3250
3250
|
if (!i)
|
|
3251
3251
|
throw new H(503, {
|
|
3252
3252
|
message: JSON.stringify(a)
|
|
3253
3253
|
});
|
|
3254
|
-
return
|
|
3255
|
-
(o) => t.find((
|
|
3254
|
+
return n.filter(
|
|
3255
|
+
(o) => t.find((c) => c.custom_domain_id === o.id)
|
|
3256
3256
|
).filter(
|
|
3257
3257
|
(o) => {
|
|
3258
|
-
var
|
|
3259
|
-
return !(r.enterprise && ((
|
|
3258
|
+
var c;
|
|
3259
|
+
return !(r.enterprise && ((c = o.custom_metadata) == null ? void 0 : c.tenant_id) !== e);
|
|
3260
3260
|
}
|
|
3261
3261
|
).map(
|
|
3262
3262
|
(o) => Ue({
|
|
3263
|
-
...t.find((
|
|
3263
|
+
...t.find((c) => c.custom_domain_id === o.id),
|
|
3264
3264
|
...o
|
|
3265
3265
|
})
|
|
3266
3266
|
);
|
|
3267
3267
|
},
|
|
3268
3268
|
remove: async (e, t) => {
|
|
3269
|
-
var
|
|
3269
|
+
var n;
|
|
3270
3270
|
if (r.enterprise) {
|
|
3271
3271
|
const { result: a, success: i } = ze.parse(
|
|
3272
3272
|
await Y(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json()
|
|
3273
3273
|
);
|
|
3274
|
-
if (!i || ((
|
|
3274
|
+
if (!i || ((n = a.custom_metadata) == null ? void 0 : n.tenant_id) !== e)
|
|
3275
3275
|
throw new H(404);
|
|
3276
3276
|
}
|
|
3277
|
-
const
|
|
3278
|
-
return
|
|
3277
|
+
const s = await Y(r).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();
|
|
3278
|
+
return s.ok && await r.customDomainAdapter.remove(e, t), s.ok;
|
|
3279
3279
|
},
|
|
3280
|
-
update: async (e, t,
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3280
|
+
update: async (e, t, s) => {
|
|
3281
|
+
const n = await Y(r).patch(
|
|
3282
|
+
s,
|
|
3283
3283
|
`/custom_hostnames/${encodeURIComponent(t)}`
|
|
3284
3284
|
).res();
|
|
3285
|
-
if (!
|
|
3285
|
+
if (!n.ok)
|
|
3286
3286
|
throw new H(503, {
|
|
3287
|
-
message: await
|
|
3287
|
+
message: await n.text()
|
|
3288
3288
|
});
|
|
3289
3289
|
return r.customDomainAdapter.update(
|
|
3290
3290
|
e,
|
|
3291
3291
|
t,
|
|
3292
|
-
|
|
3292
|
+
s
|
|
3293
3293
|
);
|
|
3294
3294
|
}
|
|
3295
3295
|
};
|
|
3296
3296
|
}
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3297
|
+
class Dr {
|
|
3298
|
+
constructor(e) {
|
|
3299
|
+
ke(this, "cache", null);
|
|
3300
|
+
this.config = e;
|
|
3301
|
+
}
|
|
3302
|
+
async getCache() {
|
|
3303
|
+
if (this.cache)
|
|
3304
|
+
return this.cache;
|
|
3305
|
+
if (typeof caches > "u")
|
|
3306
|
+
throw new Error(
|
|
3307
|
+
"caches API is not available - CloudflareCache should only be used in Cloudflare Workers"
|
|
3308
|
+
);
|
|
3309
|
+
return this.config.cacheName ? this.cache = await caches.open(this.config.cacheName) : this.cache = caches.default, this.cache;
|
|
3310
|
+
}
|
|
3311
|
+
getKey(e) {
|
|
3312
|
+
return this.config.keyPrefix ? `${this.config.keyPrefix}:${e}` : e;
|
|
3313
|
+
}
|
|
3314
|
+
createRequest(e) {
|
|
3315
|
+
return new Request(`https://cache.internal/${this.getKey(e)}`);
|
|
3316
|
+
}
|
|
3317
|
+
async get(e) {
|
|
3318
|
+
try {
|
|
3319
|
+
const t = await this.getCache(), s = this.createRequest(e), n = await t.match(s);
|
|
3320
|
+
if (!n)
|
|
3321
|
+
return null;
|
|
3322
|
+
const a = await n.json();
|
|
3323
|
+
return a.expiresAt && new Date(a.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : a.value;
|
|
3324
|
+
} catch (t) {
|
|
3325
|
+
return console.warn(`Cache get error for key ${e}:`, t), null;
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
async set(e, t, s) {
|
|
3329
|
+
try {
|
|
3330
|
+
const n = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3331
|
+
value: t,
|
|
3332
|
+
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3333
|
+
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3334
|
+
}, d = this.createRequest(e), h = new Response(JSON.stringify(c), {
|
|
3335
|
+
headers: {
|
|
3336
|
+
"Content-Type": "application/json",
|
|
3337
|
+
...i && o > 0 && { "Cache-Control": `max-age=${o}` }
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
await n.put(d, h);
|
|
3341
|
+
} catch (n) {
|
|
3342
|
+
console.warn(`Cache set error for key ${e}:`, n);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
async delete(e) {
|
|
3346
|
+
try {
|
|
3347
|
+
const t = await this.getCache(), s = this.createRequest(e);
|
|
3348
|
+
return await t.delete(s);
|
|
3349
|
+
} catch (t) {
|
|
3350
|
+
return console.warn(`Cache delete error for key ${e}:`, t), !1;
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
async clear() {
|
|
3354
|
+
console.warn(
|
|
3355
|
+
"CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries"
|
|
3356
|
+
);
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
function Vr(r) {
|
|
3360
|
+
return new Dr(r);
|
|
3361
|
+
}
|
|
3362
|
+
function Br(r) {
|
|
3363
|
+
const e = {
|
|
3364
|
+
customDomains: Mr(r)
|
|
3300
3365
|
};
|
|
3366
|
+
return (r.cacheName || r.defaultTtlSeconds || r.keyPrefix) && (e.cache = Vr({
|
|
3367
|
+
cacheName: r.cacheName,
|
|
3368
|
+
defaultTtlSeconds: r.defaultTtlSeconds,
|
|
3369
|
+
keyPrefix: r.keyPrefix
|
|
3370
|
+
})), e;
|
|
3301
3371
|
}
|
|
3302
3372
|
export {
|
|
3303
|
-
|
|
3373
|
+
Br as default
|
|
3304
3374
|
};
|