@authhero/cloudflare-adapter 2.27.1 → 2.28.1
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 +41 -33
- package/dist/cloudflare-adapter.d.ts +77 -0
- package/dist/cloudflare-adapter.mjs +790 -663
- package/package.json +3 -3
|
@@ -12,7 +12,7 @@ function yt(t, e) {
|
|
|
12
12
|
var s;
|
|
13
13
|
return ((s = t?._def) === null || s === void 0 ? void 0 : s.typeName) === e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function ie(t, e) {
|
|
16
16
|
const s = t.ZodType.prototype[e];
|
|
17
17
|
t.ZodType.prototype[e] = function(...n) {
|
|
18
18
|
const r = s.apply(this, n);
|
|
@@ -23,31 +23,31 @@ function gt(t) {
|
|
|
23
23
|
if (typeof t.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
25
|
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
|
-
var i, o, c,
|
|
27
|
-
const C = typeof r == "string" ? a : r, S = C ?? {}, { param:
|
|
28
|
-
param: Object.assign(Object.assign({}, (
|
|
29
|
-
} : void 0),
|
|
26
|
+
var i, o, c, d, f, w;
|
|
27
|
+
const C = typeof r == "string" ? a : r, S = C ?? {}, { param: O } = S, F = mt(S, ["param"]), x = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0), D = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), F), !((d = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || d === void 0) && d.param || O ? {
|
|
28
|
+
param: Object.assign(Object.assign({}, (w = (f = this._def.openapi) === null || f === void 0 ? void 0 : f.metadata) === null || w === void 0 ? void 0 : w.param), O)
|
|
29
|
+
} : void 0), $ = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(x).length > 0 ? { _internal: x } : void 0), Object.keys(D).length > 0 ? { metadata: D } : void 0) }));
|
|
30
30
|
if (yt(this, "ZodObject")) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
return
|
|
31
|
+
const k = this.extend;
|
|
32
|
+
$.extend = function(...E) {
|
|
33
|
+
var Z, V, Se, Ce, Te, Ee, Oe;
|
|
34
|
+
const $e = k.apply(this, E);
|
|
35
|
+
return $e._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((V = (Z = this._def.openapi) === null || Z === void 0 ? void 0 : Z._internal) === null || V === void 0) && V.refId ? { refId: (Ce = (Se = this._def.openapi) === null || Se === void 0 ? void 0 : Se._internal) === null || Ce === void 0 ? void 0 : Ce.refId, schema: this } : (Ee = (Te = this._def.openapi) === null || Te === void 0 ? void 0 : Te._internal) === null || Ee === void 0 ? void 0 : Ee.extendedFrom
|
|
38
38
|
},
|
|
39
|
-
metadata: (
|
|
40
|
-
},
|
|
39
|
+
metadata: (Oe = $e._def.openapi) === null || Oe === void 0 ? void 0 : Oe.metadata
|
|
40
|
+
}, $e;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
return
|
|
44
|
-
},
|
|
43
|
+
return $;
|
|
44
|
+
}, ie(t, "optional"), ie(t, "nullable"), ie(t, "default"), ie(t, "transform"), ie(t, "refine");
|
|
45
45
|
const e = t.ZodObject.prototype.deepPartial;
|
|
46
46
|
t.ZodObject.prototype.deepPartial = function() {
|
|
47
47
|
const r = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
48
48
|
return Object.entries(i).forEach(([o, c]) => {
|
|
49
|
-
var
|
|
50
|
-
c._def.openapi = (
|
|
49
|
+
var d, f;
|
|
50
|
+
c._def.openapi = (f = (d = r[o]) === null || d === void 0 ? void 0 : d._def) === null || f === void 0 ? void 0 : f.openapi;
|
|
51
51
|
}), a._def.openapi = void 0, a;
|
|
52
52
|
};
|
|
53
53
|
const s = t.ZodObject.prototype.pick;
|
|
@@ -61,7 +61,7 @@ function gt(t) {
|
|
|
61
61
|
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var te = class extends Error {
|
|
65
65
|
res;
|
|
66
66
|
status;
|
|
67
67
|
/**
|
|
@@ -153,7 +153,7 @@ const h = b.arrayToEnum([
|
|
|
153
153
|
"never",
|
|
154
154
|
"map",
|
|
155
155
|
"set"
|
|
156
|
-
]),
|
|
156
|
+
]), q = (t) => {
|
|
157
157
|
switch (typeof t) {
|
|
158
158
|
case "undefined":
|
|
159
159
|
return h.undefined;
|
|
@@ -174,7 +174,7 @@ const h = b.arrayToEnum([
|
|
|
174
174
|
default:
|
|
175
175
|
return h.unknown;
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, u = b.arrayToEnum([
|
|
178
178
|
"invalid_type",
|
|
179
179
|
"invalid_literal",
|
|
180
180
|
"custom",
|
|
@@ -192,7 +192,7 @@ const h = b.arrayToEnum([
|
|
|
192
192
|
"not_multiple_of",
|
|
193
193
|
"not_finite"
|
|
194
194
|
]);
|
|
195
|
-
class
|
|
195
|
+
class U extends Error {
|
|
196
196
|
get errors() {
|
|
197
197
|
return this.issues;
|
|
198
198
|
}
|
|
@@ -221,15 +221,15 @@ class Z extends Error {
|
|
|
221
221
|
else {
|
|
222
222
|
let o = n, c = 0;
|
|
223
223
|
for (; c < i.path.length; ) {
|
|
224
|
-
const
|
|
225
|
-
c === i.path.length - 1 ? (o[
|
|
224
|
+
const d = i.path[c];
|
|
225
|
+
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(s(i))) : o[d] = o[d] || { _errors: [] }, o = o[d], c++;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
229
|
return r(this), n;
|
|
230
230
|
}
|
|
231
231
|
static assert(e) {
|
|
232
|
-
if (!(e instanceof
|
|
232
|
+
if (!(e instanceof U))
|
|
233
233
|
throw new Error(`Not a ZodError: ${e}`);
|
|
234
234
|
}
|
|
235
235
|
toString() {
|
|
@@ -255,56 +255,56 @@ class Z extends Error {
|
|
|
255
255
|
return this.flatten();
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
const
|
|
258
|
+
U.create = (t) => new U(t);
|
|
259
|
+
const me = (t, e) => {
|
|
260
260
|
let s;
|
|
261
261
|
switch (t.code) {
|
|
262
|
-
case
|
|
262
|
+
case u.invalid_type:
|
|
263
263
|
t.received === h.undefined ? s = "Required" : s = `Expected ${t.expected}, received ${t.received}`;
|
|
264
264
|
break;
|
|
265
|
-
case
|
|
265
|
+
case u.invalid_literal:
|
|
266
266
|
s = `Invalid literal value, expected ${JSON.stringify(t.expected, b.jsonStringifyReplacer)}`;
|
|
267
267
|
break;
|
|
268
|
-
case
|
|
268
|
+
case u.unrecognized_keys:
|
|
269
269
|
s = `Unrecognized key(s) in object: ${b.joinValues(t.keys, ", ")}`;
|
|
270
270
|
break;
|
|
271
|
-
case
|
|
271
|
+
case u.invalid_union:
|
|
272
272
|
s = "Invalid input";
|
|
273
273
|
break;
|
|
274
|
-
case
|
|
274
|
+
case u.invalid_union_discriminator:
|
|
275
275
|
s = `Invalid discriminator value. Expected ${b.joinValues(t.options)}`;
|
|
276
276
|
break;
|
|
277
|
-
case
|
|
277
|
+
case u.invalid_enum_value:
|
|
278
278
|
s = `Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;
|
|
279
279
|
break;
|
|
280
|
-
case
|
|
280
|
+
case u.invalid_arguments:
|
|
281
281
|
s = "Invalid function arguments";
|
|
282
282
|
break;
|
|
283
|
-
case
|
|
283
|
+
case u.invalid_return_type:
|
|
284
284
|
s = "Invalid function return type";
|
|
285
285
|
break;
|
|
286
|
-
case
|
|
286
|
+
case u.invalid_date:
|
|
287
287
|
s = "Invalid date";
|
|
288
288
|
break;
|
|
289
|
-
case
|
|
289
|
+
case u.invalid_string:
|
|
290
290
|
typeof t.validation == "object" ? "includes" in t.validation ? (s = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (s = `${s} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? s = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? s = `Invalid input: must end with "${t.validation.endsWith}"` : b.assertNever(t.validation) : t.validation !== "regex" ? s = `Invalid ${t.validation}` : s = "Invalid";
|
|
291
291
|
break;
|
|
292
|
-
case
|
|
292
|
+
case u.too_small:
|
|
293
293
|
t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? s = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : s = "Invalid input";
|
|
294
294
|
break;
|
|
295
|
-
case
|
|
295
|
+
case u.too_big:
|
|
296
296
|
t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? s = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : s = "Invalid input";
|
|
297
297
|
break;
|
|
298
|
-
case
|
|
298
|
+
case u.custom:
|
|
299
299
|
s = "Invalid input";
|
|
300
300
|
break;
|
|
301
|
-
case
|
|
301
|
+
case u.invalid_intersection_types:
|
|
302
302
|
s = "Intersection results could not be merged";
|
|
303
303
|
break;
|
|
304
|
-
case
|
|
304
|
+
case u.not_multiple_of:
|
|
305
305
|
s = `Number must be a multiple of ${t.multipleOf}`;
|
|
306
306
|
break;
|
|
307
|
-
case
|
|
307
|
+
case u.not_finite:
|
|
308
308
|
s = "Number must be finite";
|
|
309
309
|
break;
|
|
310
310
|
default:
|
|
@@ -312,7 +312,7 @@ const pe = (t, e) => {
|
|
|
312
312
|
}
|
|
313
313
|
return { message: s };
|
|
314
314
|
};
|
|
315
|
-
let _t =
|
|
315
|
+
let _t = me;
|
|
316
316
|
function Xe() {
|
|
317
317
|
return _t;
|
|
318
318
|
}
|
|
@@ -328,9 +328,9 @@ const et = (t) => {
|
|
|
328
328
|
message: r.message
|
|
329
329
|
};
|
|
330
330
|
let o = "";
|
|
331
|
-
const c = n.filter((
|
|
332
|
-
for (const
|
|
333
|
-
o =
|
|
331
|
+
const c = n.filter((d) => !!d).slice().reverse();
|
|
332
|
+
for (const d of c)
|
|
333
|
+
o = d(i, { data: e, defaultError: o }).message;
|
|
334
334
|
return {
|
|
335
335
|
...r,
|
|
336
336
|
path: a,
|
|
@@ -349,13 +349,13 @@ function l(t, e) {
|
|
|
349
349
|
// then schema-bound map if available
|
|
350
350
|
s,
|
|
351
351
|
// then global override map
|
|
352
|
-
s ===
|
|
352
|
+
s === me ? void 0 : me
|
|
353
353
|
// then global default map
|
|
354
354
|
].filter((r) => !!r)
|
|
355
355
|
});
|
|
356
356
|
t.common.issues.push(n);
|
|
357
357
|
}
|
|
358
|
-
class
|
|
358
|
+
class A {
|
|
359
359
|
constructor() {
|
|
360
360
|
this.value = "valid";
|
|
361
361
|
}
|
|
@@ -383,7 +383,7 @@ class T {
|
|
|
383
383
|
value: i
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
|
-
return
|
|
386
|
+
return A.mergeObjectSync(e, n);
|
|
387
387
|
}
|
|
388
388
|
static mergeObjectSync(e, s) {
|
|
389
389
|
const n = {};
|
|
@@ -398,12 +398,12 @@ class T {
|
|
|
398
398
|
}
|
|
399
399
|
const y = Object.freeze({
|
|
400
400
|
status: "aborted"
|
|
401
|
-
}),
|
|
402
|
-
var
|
|
401
|
+
}), ne = (t) => ({ status: "dirty", value: t }), I = (t) => ({ status: "valid", value: t }), Ie = (t) => t.status === "aborted", je = (t) => t.status === "dirty", Y = (t) => t.status === "valid", ce = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
402
|
+
var p;
|
|
403
403
|
(function(t) {
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
|
-
})(
|
|
406
|
-
class
|
|
405
|
+
})(p || (p = {}));
|
|
406
|
+
class B {
|
|
407
407
|
constructor(e, s, n, r) {
|
|
408
408
|
this._cachedPath = [], this.parent = e, this.data = s, this._path = n, this._key = r;
|
|
409
409
|
}
|
|
@@ -412,7 +412,7 @@ class L {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
const Je = (t, e) => {
|
|
415
|
-
if (
|
|
415
|
+
if (Y(e))
|
|
416
416
|
return { success: !0, data: e.value };
|
|
417
417
|
if (!t.common.issues.length)
|
|
418
418
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -421,7 +421,7 @@ const Je = (t, e) => {
|
|
|
421
421
|
get error() {
|
|
422
422
|
if (this._error)
|
|
423
423
|
return this._error;
|
|
424
|
-
const s = new
|
|
424
|
+
const s = new U(t.common.issues);
|
|
425
425
|
return this._error = s, this._error;
|
|
426
426
|
}
|
|
427
427
|
};
|
|
@@ -442,13 +442,13 @@ class v {
|
|
|
442
442
|
return this._def.description;
|
|
443
443
|
}
|
|
444
444
|
_getType(e) {
|
|
445
|
-
return
|
|
445
|
+
return q(e.data);
|
|
446
446
|
}
|
|
447
447
|
_getOrReturnCtx(e, s) {
|
|
448
448
|
return s || {
|
|
449
449
|
common: e.parent.common,
|
|
450
450
|
data: e.data,
|
|
451
|
-
parsedType:
|
|
451
|
+
parsedType: q(e.data),
|
|
452
452
|
schemaErrorMap: this._def.errorMap,
|
|
453
453
|
path: e.path,
|
|
454
454
|
parent: e.parent
|
|
@@ -456,11 +456,11 @@ class v {
|
|
|
456
456
|
}
|
|
457
457
|
_processInputParams(e) {
|
|
458
458
|
return {
|
|
459
|
-
status: new
|
|
459
|
+
status: new A(),
|
|
460
460
|
ctx: {
|
|
461
461
|
common: e.parent.common,
|
|
462
462
|
data: e.data,
|
|
463
|
-
parsedType:
|
|
463
|
+
parsedType: q(e.data),
|
|
464
464
|
schemaErrorMap: this._def.errorMap,
|
|
465
465
|
path: e.path,
|
|
466
466
|
parent: e.parent
|
|
@@ -469,7 +469,7 @@ class v {
|
|
|
469
469
|
}
|
|
470
470
|
_parseSync(e) {
|
|
471
471
|
const s = this._parse(e);
|
|
472
|
-
if (
|
|
472
|
+
if (ce(s))
|
|
473
473
|
throw new Error("Synchronous parse encountered promise.");
|
|
474
474
|
return s;
|
|
475
475
|
}
|
|
@@ -494,7 +494,7 @@ class v {
|
|
|
494
494
|
schemaErrorMap: this._def.errorMap,
|
|
495
495
|
parent: null,
|
|
496
496
|
data: e,
|
|
497
|
-
parsedType:
|
|
497
|
+
parsedType: q(e)
|
|
498
498
|
}, r = this._parseSync({ data: e, path: n.path, parent: n });
|
|
499
499
|
return Je(n, r);
|
|
500
500
|
}
|
|
@@ -508,12 +508,12 @@ class v {
|
|
|
508
508
|
schemaErrorMap: this._def.errorMap,
|
|
509
509
|
parent: null,
|
|
510
510
|
data: e,
|
|
511
|
-
parsedType:
|
|
511
|
+
parsedType: q(e)
|
|
512
512
|
};
|
|
513
513
|
if (!this["~standard"].async)
|
|
514
514
|
try {
|
|
515
515
|
const n = this._parseSync({ data: e, path: [], parent: s });
|
|
516
|
-
return
|
|
516
|
+
return Y(n) ? {
|
|
517
517
|
value: n.value
|
|
518
518
|
} : {
|
|
519
519
|
issues: s.common.issues
|
|
@@ -524,7 +524,7 @@ class v {
|
|
|
524
524
|
async: !0
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
return this._parseAsync({ data: e, path: [], parent: s }).then((n) =>
|
|
527
|
+
return this._parseAsync({ data: e, path: [], parent: s }).then((n) => Y(n) ? {
|
|
528
528
|
value: n.value
|
|
529
529
|
} : {
|
|
530
530
|
issues: s.common.issues
|
|
@@ -547,15 +547,15 @@ class v {
|
|
|
547
547
|
schemaErrorMap: this._def.errorMap,
|
|
548
548
|
parent: null,
|
|
549
549
|
data: e,
|
|
550
|
-
parsedType:
|
|
551
|
-
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (
|
|
550
|
+
parsedType: q(e)
|
|
551
|
+
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (ce(r) ? r : Promise.resolve(r));
|
|
552
552
|
return Je(n, a);
|
|
553
553
|
}
|
|
554
554
|
refine(e, s) {
|
|
555
555
|
const n = (r) => typeof s == "string" || typeof s > "u" ? { message: s } : typeof s == "function" ? s(r) : s;
|
|
556
556
|
return this._refinement((r, a) => {
|
|
557
557
|
const i = e(r), o = () => a.addIssue({
|
|
558
|
-
code:
|
|
558
|
+
code: u.custom,
|
|
559
559
|
...n(r)
|
|
560
560
|
});
|
|
561
561
|
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
@@ -565,7 +565,7 @@ class v {
|
|
|
565
565
|
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof s == "function" ? s(n, r) : s), !1));
|
|
566
566
|
}
|
|
567
567
|
_refinement(e) {
|
|
568
|
-
return new
|
|
568
|
+
return new G({
|
|
569
569
|
schema: this,
|
|
570
570
|
typeName: m.ZodEffects,
|
|
571
571
|
effect: { type: "refinement", refinement: e }
|
|
@@ -582,28 +582,28 @@ class v {
|
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
584
|
optional() {
|
|
585
|
-
return
|
|
585
|
+
return z.create(this, this._def);
|
|
586
586
|
}
|
|
587
587
|
nullable() {
|
|
588
|
-
return
|
|
588
|
+
return ee.create(this, this._def);
|
|
589
589
|
}
|
|
590
590
|
nullish() {
|
|
591
591
|
return this.nullable().optional();
|
|
592
592
|
}
|
|
593
593
|
array() {
|
|
594
|
-
return
|
|
594
|
+
return L.create(this);
|
|
595
595
|
}
|
|
596
596
|
promise() {
|
|
597
|
-
return
|
|
597
|
+
return fe.create(this, this._def);
|
|
598
598
|
}
|
|
599
599
|
or(e) {
|
|
600
|
-
return
|
|
600
|
+
return ue.create([this, e], this._def);
|
|
601
601
|
}
|
|
602
602
|
and(e) {
|
|
603
|
-
return
|
|
603
|
+
return le.create(this, e, this._def);
|
|
604
604
|
}
|
|
605
605
|
transform(e) {
|
|
606
|
-
return new
|
|
606
|
+
return new G({
|
|
607
607
|
..._(this._def),
|
|
608
608
|
schema: this,
|
|
609
609
|
typeName: m.ZodEffects,
|
|
@@ -612,7 +612,7 @@ class v {
|
|
|
612
612
|
}
|
|
613
613
|
default(e) {
|
|
614
614
|
const s = typeof e == "function" ? e : () => e;
|
|
615
|
-
return new
|
|
615
|
+
return new ge({
|
|
616
616
|
..._(this._def),
|
|
617
617
|
innerType: this,
|
|
618
618
|
defaultValue: s,
|
|
@@ -628,7 +628,7 @@ class v {
|
|
|
628
628
|
}
|
|
629
629
|
catch(e) {
|
|
630
630
|
const s = typeof e == "function" ? e : () => e;
|
|
631
|
-
return new
|
|
631
|
+
return new _e({
|
|
632
632
|
..._(this._def),
|
|
633
633
|
innerType: this,
|
|
634
634
|
catchValue: s,
|
|
@@ -643,10 +643,10 @@ class v {
|
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
645
|
pipe(e) {
|
|
646
|
-
return
|
|
646
|
+
return we.create(this, e);
|
|
647
647
|
}
|
|
648
648
|
readonly() {
|
|
649
|
-
return
|
|
649
|
+
return ve.create(this);
|
|
650
650
|
}
|
|
651
651
|
isOptional() {
|
|
652
652
|
return this.safeParse(void 0).success;
|
|
@@ -655,9 +655,9 @@ class v {
|
|
|
655
655
|
return this.safeParse(null).success;
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
|
-
const vt = /^c[^\s-]{8,}$/i, bt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i,
|
|
659
|
-
let
|
|
660
|
-
const 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])$/,
|
|
658
|
+
const vt = /^c[^\s-]{8,}$/i, bt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, wt = /^[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, St = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ct = /^[-+]?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)?)??$/, Tt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Et = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
659
|
+
let Ae;
|
|
660
|
+
const 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])$/, $t = /^(?:(?: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])$/, 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]))$/, Nt = /^(([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])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, It = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, tt = "((\\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])))", jt = new RegExp(`^${tt}$`);
|
|
661
661
|
function st(t) {
|
|
662
662
|
let e = "[0-5]\\d";
|
|
663
663
|
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
@@ -688,25 +688,25 @@ function Lt(t, e) {
|
|
|
688
688
|
return !1;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
|
-
function
|
|
692
|
-
return !!((e === "v4" || !e) &&
|
|
691
|
+
function Mt(t, e) {
|
|
692
|
+
return !!((e === "v4" || !e) && $t.test(t) || (e === "v6" || !e) && Nt.test(t));
|
|
693
693
|
}
|
|
694
|
-
class
|
|
694
|
+
class P extends v {
|
|
695
695
|
_parse(e) {
|
|
696
696
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
697
697
|
const a = this._getOrReturnCtx(e);
|
|
698
698
|
return l(a, {
|
|
699
|
-
code:
|
|
699
|
+
code: u.invalid_type,
|
|
700
700
|
expected: h.string,
|
|
701
701
|
received: a.parsedType
|
|
702
702
|
}), y;
|
|
703
703
|
}
|
|
704
|
-
const n = new
|
|
704
|
+
const n = new A();
|
|
705
705
|
let r;
|
|
706
706
|
for (const a of this._def.checks)
|
|
707
707
|
if (a.kind === "min")
|
|
708
708
|
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
709
|
-
code:
|
|
709
|
+
code: u.too_small,
|
|
710
710
|
minimum: a.value,
|
|
711
711
|
type: "string",
|
|
712
712
|
inclusive: !0,
|
|
@@ -715,7 +715,7 @@ class D extends v {
|
|
|
715
715
|
}), n.dirty());
|
|
716
716
|
else if (a.kind === "max")
|
|
717
717
|
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
718
|
-
code:
|
|
718
|
+
code: u.too_big,
|
|
719
719
|
maximum: a.value,
|
|
720
720
|
type: "string",
|
|
721
721
|
inclusive: !0,
|
|
@@ -725,14 +725,14 @@ class D extends v {
|
|
|
725
725
|
else if (a.kind === "length") {
|
|
726
726
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
727
727
|
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
728
|
-
code:
|
|
728
|
+
code: u.too_big,
|
|
729
729
|
maximum: a.value,
|
|
730
730
|
type: "string",
|
|
731
731
|
inclusive: !0,
|
|
732
732
|
exact: !0,
|
|
733
733
|
message: a.message
|
|
734
734
|
}) : o && l(r, {
|
|
735
|
-
code:
|
|
735
|
+
code: u.too_small,
|
|
736
736
|
minimum: a.value,
|
|
737
737
|
type: "string",
|
|
738
738
|
inclusive: !0,
|
|
@@ -742,43 +742,43 @@ class D extends v {
|
|
|
742
742
|
} else if (a.kind === "email")
|
|
743
743
|
Tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
744
744
|
validation: "email",
|
|
745
|
-
code:
|
|
745
|
+
code: u.invalid_string,
|
|
746
746
|
message: a.message
|
|
747
747
|
}), n.dirty());
|
|
748
748
|
else if (a.kind === "emoji")
|
|
749
|
-
|
|
749
|
+
Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
750
750
|
validation: "emoji",
|
|
751
|
-
code:
|
|
751
|
+
code: u.invalid_string,
|
|
752
752
|
message: a.message
|
|
753
753
|
}), n.dirty());
|
|
754
754
|
else if (a.kind === "uuid")
|
|
755
|
-
|
|
755
|
+
wt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
756
756
|
validation: "uuid",
|
|
757
|
-
code:
|
|
757
|
+
code: u.invalid_string,
|
|
758
758
|
message: a.message
|
|
759
759
|
}), n.dirty());
|
|
760
760
|
else if (a.kind === "nanoid")
|
|
761
|
-
|
|
761
|
+
kt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
762
762
|
validation: "nanoid",
|
|
763
|
-
code:
|
|
763
|
+
code: u.invalid_string,
|
|
764
764
|
message: a.message
|
|
765
765
|
}), n.dirty());
|
|
766
766
|
else if (a.kind === "cuid")
|
|
767
767
|
vt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
768
768
|
validation: "cuid",
|
|
769
|
-
code:
|
|
769
|
+
code: u.invalid_string,
|
|
770
770
|
message: a.message
|
|
771
771
|
}), n.dirty());
|
|
772
772
|
else if (a.kind === "cuid2")
|
|
773
773
|
bt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
774
774
|
validation: "cuid2",
|
|
775
|
-
code:
|
|
775
|
+
code: u.invalid_string,
|
|
776
776
|
message: a.message
|
|
777
777
|
}), n.dirty());
|
|
778
778
|
else if (a.kind === "ulid")
|
|
779
779
|
xt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
780
780
|
validation: "ulid",
|
|
781
|
-
code:
|
|
781
|
+
code: u.invalid_string,
|
|
782
782
|
message: a.message
|
|
783
783
|
}), n.dirty());
|
|
784
784
|
else if (a.kind === "url")
|
|
@@ -787,61 +787,61 @@ class D extends v {
|
|
|
787
787
|
} catch {
|
|
788
788
|
r = this._getOrReturnCtx(e, r), l(r, {
|
|
789
789
|
validation: "url",
|
|
790
|
-
code:
|
|
790
|
+
code: u.invalid_string,
|
|
791
791
|
message: a.message
|
|
792
792
|
}), n.dirty();
|
|
793
793
|
}
|
|
794
794
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
795
795
|
validation: "regex",
|
|
796
|
-
code:
|
|
796
|
+
code: u.invalid_string,
|
|
797
797
|
message: a.message
|
|
798
798
|
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
799
|
-
code:
|
|
799
|
+
code: u.invalid_string,
|
|
800
800
|
validation: { includes: a.value, position: a.position },
|
|
801
801
|
message: a.message
|
|
802
802
|
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
803
|
-
code:
|
|
803
|
+
code: u.invalid_string,
|
|
804
804
|
validation: { startsWith: a.value },
|
|
805
805
|
message: a.message
|
|
806
806
|
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
807
|
-
code:
|
|
807
|
+
code: u.invalid_string,
|
|
808
808
|
validation: { endsWith: a.value },
|
|
809
809
|
message: a.message
|
|
810
810
|
}), n.dirty()) : a.kind === "datetime" ? nt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
811
|
-
code:
|
|
811
|
+
code: u.invalid_string,
|
|
812
812
|
validation: "datetime",
|
|
813
813
|
message: a.message
|
|
814
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
815
|
-
code:
|
|
814
|
+
}), n.dirty()) : a.kind === "date" ? jt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
815
|
+
code: u.invalid_string,
|
|
816
816
|
validation: "date",
|
|
817
817
|
message: a.message
|
|
818
818
|
}), n.dirty()) : a.kind === "time" ? Dt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
819
|
-
code:
|
|
819
|
+
code: u.invalid_string,
|
|
820
820
|
validation: "time",
|
|
821
821
|
message: a.message
|
|
822
822
|
}), n.dirty()) : a.kind === "duration" ? Ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
823
823
|
validation: "duration",
|
|
824
|
-
code:
|
|
824
|
+
code: u.invalid_string,
|
|
825
825
|
message: a.message
|
|
826
826
|
}), n.dirty()) : a.kind === "ip" ? Zt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
827
827
|
validation: "ip",
|
|
828
|
-
code:
|
|
828
|
+
code: u.invalid_string,
|
|
829
829
|
message: a.message
|
|
830
830
|
}), n.dirty()) : a.kind === "jwt" ? Lt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
831
831
|
validation: "jwt",
|
|
832
|
-
code:
|
|
832
|
+
code: u.invalid_string,
|
|
833
833
|
message: a.message
|
|
834
|
-
}), n.dirty()) : a.kind === "cidr" ?
|
|
834
|
+
}), n.dirty()) : a.kind === "cidr" ? Mt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
835
835
|
validation: "cidr",
|
|
836
|
-
code:
|
|
836
|
+
code: u.invalid_string,
|
|
837
837
|
message: a.message
|
|
838
|
-
}), n.dirty()) : a.kind === "base64" ?
|
|
838
|
+
}), n.dirty()) : a.kind === "base64" ? Rt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
839
839
|
validation: "base64",
|
|
840
|
-
code:
|
|
840
|
+
code: u.invalid_string,
|
|
841
841
|
message: a.message
|
|
842
|
-
}), n.dirty()) : a.kind === "base64url" ?
|
|
842
|
+
}), n.dirty()) : a.kind === "base64url" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
843
843
|
validation: "base64url",
|
|
844
|
-
code:
|
|
844
|
+
code: u.invalid_string,
|
|
845
845
|
message: a.message
|
|
846
846
|
}), n.dirty()) : b.assertNever(a);
|
|
847
847
|
return { status: n.value, value: e.data };
|
|
@@ -849,57 +849,57 @@ class D extends v {
|
|
|
849
849
|
_regex(e, s, n) {
|
|
850
850
|
return this.refinement((r) => e.test(r), {
|
|
851
851
|
validation: s,
|
|
852
|
-
code:
|
|
853
|
-
...
|
|
852
|
+
code: u.invalid_string,
|
|
853
|
+
...p.errToObj(n)
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
_addCheck(e) {
|
|
857
|
-
return new
|
|
857
|
+
return new P({
|
|
858
858
|
...this._def,
|
|
859
859
|
checks: [...this._def.checks, e]
|
|
860
860
|
});
|
|
861
861
|
}
|
|
862
862
|
email(e) {
|
|
863
|
-
return this._addCheck({ kind: "email", ...
|
|
863
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
864
864
|
}
|
|
865
865
|
url(e) {
|
|
866
|
-
return this._addCheck({ kind: "url", ...
|
|
866
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
867
867
|
}
|
|
868
868
|
emoji(e) {
|
|
869
|
-
return this._addCheck({ kind: "emoji", ...
|
|
869
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
870
870
|
}
|
|
871
871
|
uuid(e) {
|
|
872
|
-
return this._addCheck({ kind: "uuid", ...
|
|
872
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
873
873
|
}
|
|
874
874
|
nanoid(e) {
|
|
875
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
875
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
876
876
|
}
|
|
877
877
|
cuid(e) {
|
|
878
|
-
return this._addCheck({ kind: "cuid", ...
|
|
878
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
879
879
|
}
|
|
880
880
|
cuid2(e) {
|
|
881
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
881
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
882
882
|
}
|
|
883
883
|
ulid(e) {
|
|
884
|
-
return this._addCheck({ kind: "ulid", ...
|
|
884
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
885
885
|
}
|
|
886
886
|
base64(e) {
|
|
887
|
-
return this._addCheck({ kind: "base64", ...
|
|
887
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
888
888
|
}
|
|
889
889
|
base64url(e) {
|
|
890
890
|
return this._addCheck({
|
|
891
891
|
kind: "base64url",
|
|
892
|
-
...
|
|
892
|
+
...p.errToObj(e)
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
895
|
jwt(e) {
|
|
896
|
-
return this._addCheck({ kind: "jwt", ...
|
|
896
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
897
897
|
}
|
|
898
898
|
ip(e) {
|
|
899
|
-
return this._addCheck({ kind: "ip", ...
|
|
899
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
900
900
|
}
|
|
901
901
|
cidr(e) {
|
|
902
|
-
return this._addCheck({ kind: "cidr", ...
|
|
902
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
903
903
|
}
|
|
904
904
|
datetime(e) {
|
|
905
905
|
return typeof e == "string" ? this._addCheck({
|
|
@@ -913,7 +913,7 @@ class D extends v {
|
|
|
913
913
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
914
914
|
offset: e?.offset ?? !1,
|
|
915
915
|
local: e?.local ?? !1,
|
|
916
|
-
...
|
|
916
|
+
...p.errToObj(e?.message)
|
|
917
917
|
});
|
|
918
918
|
}
|
|
919
919
|
date(e) {
|
|
@@ -927,17 +927,17 @@ class D extends v {
|
|
|
927
927
|
}) : this._addCheck({
|
|
928
928
|
kind: "time",
|
|
929
929
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
930
|
-
...
|
|
930
|
+
...p.errToObj(e?.message)
|
|
931
931
|
});
|
|
932
932
|
}
|
|
933
933
|
duration(e) {
|
|
934
|
-
return this._addCheck({ kind: "duration", ...
|
|
934
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
935
935
|
}
|
|
936
936
|
regex(e, s) {
|
|
937
937
|
return this._addCheck({
|
|
938
938
|
kind: "regex",
|
|
939
939
|
regex: e,
|
|
940
|
-
...
|
|
940
|
+
...p.errToObj(s)
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
943
|
includes(e, s) {
|
|
@@ -945,64 +945,64 @@ class D extends v {
|
|
|
945
945
|
kind: "includes",
|
|
946
946
|
value: e,
|
|
947
947
|
position: s?.position,
|
|
948
|
-
...
|
|
948
|
+
...p.errToObj(s?.message)
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
951
|
startsWith(e, s) {
|
|
952
952
|
return this._addCheck({
|
|
953
953
|
kind: "startsWith",
|
|
954
954
|
value: e,
|
|
955
|
-
...
|
|
955
|
+
...p.errToObj(s)
|
|
956
956
|
});
|
|
957
957
|
}
|
|
958
958
|
endsWith(e, s) {
|
|
959
959
|
return this._addCheck({
|
|
960
960
|
kind: "endsWith",
|
|
961
961
|
value: e,
|
|
962
|
-
...
|
|
962
|
+
...p.errToObj(s)
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
965
|
min(e, s) {
|
|
966
966
|
return this._addCheck({
|
|
967
967
|
kind: "min",
|
|
968
968
|
value: e,
|
|
969
|
-
...
|
|
969
|
+
...p.errToObj(s)
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
972
|
max(e, s) {
|
|
973
973
|
return this._addCheck({
|
|
974
974
|
kind: "max",
|
|
975
975
|
value: e,
|
|
976
|
-
...
|
|
976
|
+
...p.errToObj(s)
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
979
|
length(e, s) {
|
|
980
980
|
return this._addCheck({
|
|
981
981
|
kind: "length",
|
|
982
982
|
value: e,
|
|
983
|
-
...
|
|
983
|
+
...p.errToObj(s)
|
|
984
984
|
});
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
987
987
|
* Equivalent to `.min(1)`
|
|
988
988
|
*/
|
|
989
989
|
nonempty(e) {
|
|
990
|
-
return this.min(1,
|
|
990
|
+
return this.min(1, p.errToObj(e));
|
|
991
991
|
}
|
|
992
992
|
trim() {
|
|
993
|
-
return new
|
|
993
|
+
return new P({
|
|
994
994
|
...this._def,
|
|
995
995
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
998
|
toLowerCase() {
|
|
999
|
-
return new
|
|
999
|
+
return new P({
|
|
1000
1000
|
...this._def,
|
|
1001
1001
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
toUpperCase() {
|
|
1005
|
-
return new
|
|
1005
|
+
return new P({
|
|
1006
1006
|
...this._def,
|
|
1007
1007
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1008
1008
|
});
|
|
@@ -1068,17 +1068,17 @@ class D extends v {
|
|
|
1068
1068
|
return e;
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
|
-
|
|
1071
|
+
P.create = (t) => new P({
|
|
1072
1072
|
checks: [],
|
|
1073
1073
|
typeName: m.ZodString,
|
|
1074
1074
|
coerce: t?.coerce ?? !1,
|
|
1075
1075
|
..._(t)
|
|
1076
1076
|
});
|
|
1077
|
-
function
|
|
1077
|
+
function Pt(t, e) {
|
|
1078
1078
|
const s = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = s > n ? s : n, a = Number.parseInt(t.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
1079
1079
|
return a % i / 10 ** r;
|
|
1080
1080
|
}
|
|
1081
|
-
class
|
|
1081
|
+
class K extends v {
|
|
1082
1082
|
constructor() {
|
|
1083
1083
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1084
1084
|
}
|
|
@@ -1086,57 +1086,57 @@ class G extends v {
|
|
|
1086
1086
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1087
1087
|
const a = this._getOrReturnCtx(e);
|
|
1088
1088
|
return l(a, {
|
|
1089
|
-
code:
|
|
1089
|
+
code: u.invalid_type,
|
|
1090
1090
|
expected: h.number,
|
|
1091
1091
|
received: a.parsedType
|
|
1092
1092
|
}), y;
|
|
1093
1093
|
}
|
|
1094
1094
|
let n;
|
|
1095
|
-
const r = new
|
|
1095
|
+
const r = new A();
|
|
1096
1096
|
for (const a of this._def.checks)
|
|
1097
1097
|
a.kind === "int" ? b.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1098
|
-
code:
|
|
1098
|
+
code: u.invalid_type,
|
|
1099
1099
|
expected: "integer",
|
|
1100
1100
|
received: "float",
|
|
1101
1101
|
message: a.message
|
|
1102
1102
|
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1103
|
-
code:
|
|
1103
|
+
code: u.too_small,
|
|
1104
1104
|
minimum: a.value,
|
|
1105
1105
|
type: "number",
|
|
1106
1106
|
inclusive: a.inclusive,
|
|
1107
1107
|
exact: !1,
|
|
1108
1108
|
message: a.message
|
|
1109
1109
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1110
|
-
code:
|
|
1110
|
+
code: u.too_big,
|
|
1111
1111
|
maximum: a.value,
|
|
1112
1112
|
type: "number",
|
|
1113
1113
|
inclusive: a.inclusive,
|
|
1114
1114
|
exact: !1,
|
|
1115
1115
|
message: a.message
|
|
1116
|
-
}), r.dirty()) : a.kind === "multipleOf" ?
|
|
1117
|
-
code:
|
|
1116
|
+
}), r.dirty()) : a.kind === "multipleOf" ? Pt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1117
|
+
code: u.not_multiple_of,
|
|
1118
1118
|
multipleOf: a.value,
|
|
1119
1119
|
message: a.message
|
|
1120
1120
|
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1121
|
-
code:
|
|
1121
|
+
code: u.not_finite,
|
|
1122
1122
|
message: a.message
|
|
1123
1123
|
}), r.dirty()) : b.assertNever(a);
|
|
1124
1124
|
return { status: r.value, value: e.data };
|
|
1125
1125
|
}
|
|
1126
1126
|
gte(e, s) {
|
|
1127
|
-
return this.setLimit("min", e, !0,
|
|
1127
|
+
return this.setLimit("min", e, !0, p.toString(s));
|
|
1128
1128
|
}
|
|
1129
1129
|
gt(e, s) {
|
|
1130
|
-
return this.setLimit("min", e, !1,
|
|
1130
|
+
return this.setLimit("min", e, !1, p.toString(s));
|
|
1131
1131
|
}
|
|
1132
1132
|
lte(e, s) {
|
|
1133
|
-
return this.setLimit("max", e, !0,
|
|
1133
|
+
return this.setLimit("max", e, !0, p.toString(s));
|
|
1134
1134
|
}
|
|
1135
1135
|
lt(e, s) {
|
|
1136
|
-
return this.setLimit("max", e, !1,
|
|
1136
|
+
return this.setLimit("max", e, !1, p.toString(s));
|
|
1137
1137
|
}
|
|
1138
1138
|
setLimit(e, s, n, r) {
|
|
1139
|
-
return new
|
|
1139
|
+
return new K({
|
|
1140
1140
|
...this._def,
|
|
1141
1141
|
checks: [
|
|
1142
1142
|
...this._def.checks,
|
|
@@ -1144,13 +1144,13 @@ class G extends v {
|
|
|
1144
1144
|
kind: e,
|
|
1145
1145
|
value: s,
|
|
1146
1146
|
inclusive: n,
|
|
1147
|
-
message:
|
|
1147
|
+
message: p.toString(r)
|
|
1148
1148
|
}
|
|
1149
1149
|
]
|
|
1150
1150
|
});
|
|
1151
1151
|
}
|
|
1152
1152
|
_addCheck(e) {
|
|
1153
|
-
return new
|
|
1153
|
+
return new K({
|
|
1154
1154
|
...this._def,
|
|
1155
1155
|
checks: [...this._def.checks, e]
|
|
1156
1156
|
});
|
|
@@ -1158,7 +1158,7 @@ class G extends v {
|
|
|
1158
1158
|
int(e) {
|
|
1159
1159
|
return this._addCheck({
|
|
1160
1160
|
kind: "int",
|
|
1161
|
-
message:
|
|
1161
|
+
message: p.toString(e)
|
|
1162
1162
|
});
|
|
1163
1163
|
}
|
|
1164
1164
|
positive(e) {
|
|
@@ -1166,7 +1166,7 @@ class G extends v {
|
|
|
1166
1166
|
kind: "min",
|
|
1167
1167
|
value: 0,
|
|
1168
1168
|
inclusive: !1,
|
|
1169
|
-
message:
|
|
1169
|
+
message: p.toString(e)
|
|
1170
1170
|
});
|
|
1171
1171
|
}
|
|
1172
1172
|
negative(e) {
|
|
@@ -1174,7 +1174,7 @@ class G extends v {
|
|
|
1174
1174
|
kind: "max",
|
|
1175
1175
|
value: 0,
|
|
1176
1176
|
inclusive: !1,
|
|
1177
|
-
message:
|
|
1177
|
+
message: p.toString(e)
|
|
1178
1178
|
});
|
|
1179
1179
|
}
|
|
1180
1180
|
nonpositive(e) {
|
|
@@ -1182,7 +1182,7 @@ class G extends v {
|
|
|
1182
1182
|
kind: "max",
|
|
1183
1183
|
value: 0,
|
|
1184
1184
|
inclusive: !0,
|
|
1185
|
-
message:
|
|
1185
|
+
message: p.toString(e)
|
|
1186
1186
|
});
|
|
1187
1187
|
}
|
|
1188
1188
|
nonnegative(e) {
|
|
@@ -1190,20 +1190,20 @@ class G extends v {
|
|
|
1190
1190
|
kind: "min",
|
|
1191
1191
|
value: 0,
|
|
1192
1192
|
inclusive: !0,
|
|
1193
|
-
message:
|
|
1193
|
+
message: p.toString(e)
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
1196
1196
|
multipleOf(e, s) {
|
|
1197
1197
|
return this._addCheck({
|
|
1198
1198
|
kind: "multipleOf",
|
|
1199
1199
|
value: e,
|
|
1200
|
-
message:
|
|
1200
|
+
message: p.toString(s)
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
1203
|
finite(e) {
|
|
1204
1204
|
return this._addCheck({
|
|
1205
1205
|
kind: "finite",
|
|
1206
|
-
message:
|
|
1206
|
+
message: p.toString(e)
|
|
1207
1207
|
});
|
|
1208
1208
|
}
|
|
1209
1209
|
safe(e) {
|
|
@@ -1211,12 +1211,12 @@ class G extends v {
|
|
|
1211
1211
|
kind: "min",
|
|
1212
1212
|
inclusive: !0,
|
|
1213
1213
|
value: Number.MIN_SAFE_INTEGER,
|
|
1214
|
-
message:
|
|
1214
|
+
message: p.toString(e)
|
|
1215
1215
|
})._addCheck({
|
|
1216
1216
|
kind: "max",
|
|
1217
1217
|
inclusive: !0,
|
|
1218
1218
|
value: Number.MAX_SAFE_INTEGER,
|
|
1219
|
-
message:
|
|
1219
|
+
message: p.toString(e)
|
|
1220
1220
|
});
|
|
1221
1221
|
}
|
|
1222
1222
|
get minValue() {
|
|
@@ -1244,13 +1244,13 @@ class G extends v {
|
|
|
1244
1244
|
return Number.isFinite(s) && Number.isFinite(e);
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
K.create = (t) => new K({
|
|
1248
1248
|
checks: [],
|
|
1249
1249
|
typeName: m.ZodNumber,
|
|
1250
1250
|
coerce: t?.coerce || !1,
|
|
1251
1251
|
..._(t)
|
|
1252
1252
|
});
|
|
1253
|
-
class
|
|
1253
|
+
class re extends v {
|
|
1254
1254
|
constructor() {
|
|
1255
1255
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1256
1256
|
}
|
|
@@ -1264,22 +1264,22 @@ class se extends v {
|
|
|
1264
1264
|
if (this._getType(e) !== h.bigint)
|
|
1265
1265
|
return this._getInvalidInput(e);
|
|
1266
1266
|
let n;
|
|
1267
|
-
const r = new
|
|
1267
|
+
const r = new A();
|
|
1268
1268
|
for (const a of this._def.checks)
|
|
1269
1269
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1270
|
-
code:
|
|
1270
|
+
code: u.too_small,
|
|
1271
1271
|
type: "bigint",
|
|
1272
1272
|
minimum: a.value,
|
|
1273
1273
|
inclusive: a.inclusive,
|
|
1274
1274
|
message: a.message
|
|
1275
1275
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1276
|
-
code:
|
|
1276
|
+
code: u.too_big,
|
|
1277
1277
|
type: "bigint",
|
|
1278
1278
|
maximum: a.value,
|
|
1279
1279
|
inclusive: a.inclusive,
|
|
1280
1280
|
message: a.message
|
|
1281
1281
|
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1282
|
-
code:
|
|
1282
|
+
code: u.not_multiple_of,
|
|
1283
1283
|
multipleOf: a.value,
|
|
1284
1284
|
message: a.message
|
|
1285
1285
|
}), r.dirty()) : b.assertNever(a);
|
|
@@ -1288,25 +1288,25 @@ class se extends v {
|
|
|
1288
1288
|
_getInvalidInput(e) {
|
|
1289
1289
|
const s = this._getOrReturnCtx(e);
|
|
1290
1290
|
return l(s, {
|
|
1291
|
-
code:
|
|
1291
|
+
code: u.invalid_type,
|
|
1292
1292
|
expected: h.bigint,
|
|
1293
1293
|
received: s.parsedType
|
|
1294
1294
|
}), y;
|
|
1295
1295
|
}
|
|
1296
1296
|
gte(e, s) {
|
|
1297
|
-
return this.setLimit("min", e, !0,
|
|
1297
|
+
return this.setLimit("min", e, !0, p.toString(s));
|
|
1298
1298
|
}
|
|
1299
1299
|
gt(e, s) {
|
|
1300
|
-
return this.setLimit("min", e, !1,
|
|
1300
|
+
return this.setLimit("min", e, !1, p.toString(s));
|
|
1301
1301
|
}
|
|
1302
1302
|
lte(e, s) {
|
|
1303
|
-
return this.setLimit("max", e, !0,
|
|
1303
|
+
return this.setLimit("max", e, !0, p.toString(s));
|
|
1304
1304
|
}
|
|
1305
1305
|
lt(e, s) {
|
|
1306
|
-
return this.setLimit("max", e, !1,
|
|
1306
|
+
return this.setLimit("max", e, !1, p.toString(s));
|
|
1307
1307
|
}
|
|
1308
1308
|
setLimit(e, s, n, r) {
|
|
1309
|
-
return new
|
|
1309
|
+
return new re({
|
|
1310
1310
|
...this._def,
|
|
1311
1311
|
checks: [
|
|
1312
1312
|
...this._def.checks,
|
|
@@ -1314,13 +1314,13 @@ class se extends v {
|
|
|
1314
1314
|
kind: e,
|
|
1315
1315
|
value: s,
|
|
1316
1316
|
inclusive: n,
|
|
1317
|
-
message:
|
|
1317
|
+
message: p.toString(r)
|
|
1318
1318
|
}
|
|
1319
1319
|
]
|
|
1320
1320
|
});
|
|
1321
1321
|
}
|
|
1322
1322
|
_addCheck(e) {
|
|
1323
|
-
return new
|
|
1323
|
+
return new re({
|
|
1324
1324
|
...this._def,
|
|
1325
1325
|
checks: [...this._def.checks, e]
|
|
1326
1326
|
});
|
|
@@ -1330,7 +1330,7 @@ class se extends v {
|
|
|
1330
1330
|
kind: "min",
|
|
1331
1331
|
value: BigInt(0),
|
|
1332
1332
|
inclusive: !1,
|
|
1333
|
-
message:
|
|
1333
|
+
message: p.toString(e)
|
|
1334
1334
|
});
|
|
1335
1335
|
}
|
|
1336
1336
|
negative(e) {
|
|
@@ -1338,7 +1338,7 @@ class se extends v {
|
|
|
1338
1338
|
kind: "max",
|
|
1339
1339
|
value: BigInt(0),
|
|
1340
1340
|
inclusive: !1,
|
|
1341
|
-
message:
|
|
1341
|
+
message: p.toString(e)
|
|
1342
1342
|
});
|
|
1343
1343
|
}
|
|
1344
1344
|
nonpositive(e) {
|
|
@@ -1346,7 +1346,7 @@ class se extends v {
|
|
|
1346
1346
|
kind: "max",
|
|
1347
1347
|
value: BigInt(0),
|
|
1348
1348
|
inclusive: !0,
|
|
1349
|
-
message:
|
|
1349
|
+
message: p.toString(e)
|
|
1350
1350
|
});
|
|
1351
1351
|
}
|
|
1352
1352
|
nonnegative(e) {
|
|
@@ -1354,14 +1354,14 @@ class se extends v {
|
|
|
1354
1354
|
kind: "min",
|
|
1355
1355
|
value: BigInt(0),
|
|
1356
1356
|
inclusive: !0,
|
|
1357
|
-
message:
|
|
1357
|
+
message: p.toString(e)
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
1360
|
multipleOf(e, s) {
|
|
1361
1361
|
return this._addCheck({
|
|
1362
1362
|
kind: "multipleOf",
|
|
1363
1363
|
value: e,
|
|
1364
|
-
message:
|
|
1364
|
+
message: p.toString(s)
|
|
1365
1365
|
});
|
|
1366
1366
|
}
|
|
1367
1367
|
get minValue() {
|
|
@@ -1377,36 +1377,36 @@ class se extends v {
|
|
|
1377
1377
|
return e;
|
|
1378
1378
|
}
|
|
1379
1379
|
}
|
|
1380
|
-
|
|
1380
|
+
re.create = (t) => new re({
|
|
1381
1381
|
checks: [],
|
|
1382
1382
|
typeName: m.ZodBigInt,
|
|
1383
1383
|
coerce: t?.coerce ?? !1,
|
|
1384
1384
|
..._(t)
|
|
1385
1385
|
});
|
|
1386
|
-
class
|
|
1386
|
+
class ye extends v {
|
|
1387
1387
|
_parse(e) {
|
|
1388
1388
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1389
1389
|
const n = this._getOrReturnCtx(e);
|
|
1390
1390
|
return l(n, {
|
|
1391
|
-
code:
|
|
1391
|
+
code: u.invalid_type,
|
|
1392
1392
|
expected: h.boolean,
|
|
1393
1393
|
received: n.parsedType
|
|
1394
1394
|
}), y;
|
|
1395
1395
|
}
|
|
1396
|
-
return
|
|
1396
|
+
return I(e.data);
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
|
|
1399
|
+
ye.create = (t) => new ye({
|
|
1400
1400
|
typeName: m.ZodBoolean,
|
|
1401
1401
|
coerce: t?.coerce || !1,
|
|
1402
1402
|
..._(t)
|
|
1403
1403
|
});
|
|
1404
|
-
class
|
|
1404
|
+
class de extends v {
|
|
1405
1405
|
_parse(e) {
|
|
1406
1406
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1407
1407
|
const a = this._getOrReturnCtx(e);
|
|
1408
1408
|
return l(a, {
|
|
1409
|
-
code:
|
|
1409
|
+
code: u.invalid_type,
|
|
1410
1410
|
expected: h.date,
|
|
1411
1411
|
received: a.parsedType
|
|
1412
1412
|
}), y;
|
|
@@ -1414,21 +1414,21 @@ class ce extends v {
|
|
|
1414
1414
|
if (Number.isNaN(e.data.getTime())) {
|
|
1415
1415
|
const a = this._getOrReturnCtx(e);
|
|
1416
1416
|
return l(a, {
|
|
1417
|
-
code:
|
|
1417
|
+
code: u.invalid_date
|
|
1418
1418
|
}), y;
|
|
1419
1419
|
}
|
|
1420
|
-
const n = new
|
|
1420
|
+
const n = new A();
|
|
1421
1421
|
let r;
|
|
1422
1422
|
for (const a of this._def.checks)
|
|
1423
1423
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1424
|
-
code:
|
|
1424
|
+
code: u.too_small,
|
|
1425
1425
|
message: a.message,
|
|
1426
1426
|
inclusive: !0,
|
|
1427
1427
|
exact: !1,
|
|
1428
1428
|
minimum: a.value,
|
|
1429
1429
|
type: "date"
|
|
1430
1430
|
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1431
|
-
code:
|
|
1431
|
+
code: u.too_big,
|
|
1432
1432
|
message: a.message,
|
|
1433
1433
|
inclusive: !0,
|
|
1434
1434
|
exact: !1,
|
|
@@ -1441,7 +1441,7 @@ class ce extends v {
|
|
|
1441
1441
|
};
|
|
1442
1442
|
}
|
|
1443
1443
|
_addCheck(e) {
|
|
1444
|
-
return new
|
|
1444
|
+
return new de({
|
|
1445
1445
|
...this._def,
|
|
1446
1446
|
checks: [...this._def.checks, e]
|
|
1447
1447
|
});
|
|
@@ -1450,14 +1450,14 @@ class ce extends v {
|
|
|
1450
1450
|
return this._addCheck({
|
|
1451
1451
|
kind: "min",
|
|
1452
1452
|
value: e.getTime(),
|
|
1453
|
-
message:
|
|
1453
|
+
message: p.toString(s)
|
|
1454
1454
|
});
|
|
1455
1455
|
}
|
|
1456
1456
|
max(e, s) {
|
|
1457
1457
|
return this._addCheck({
|
|
1458
1458
|
kind: "max",
|
|
1459
1459
|
value: e.getTime(),
|
|
1460
|
-
message:
|
|
1460
|
+
message: p.toString(s)
|
|
1461
1461
|
});
|
|
1462
1462
|
}
|
|
1463
1463
|
get minDate() {
|
|
@@ -1473,72 +1473,72 @@ class ce extends v {
|
|
|
1473
1473
|
return e != null ? new Date(e) : null;
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
|
-
|
|
1476
|
+
de.create = (t) => new de({
|
|
1477
1477
|
checks: [],
|
|
1478
1478
|
coerce: t?.coerce || !1,
|
|
1479
1479
|
typeName: m.ZodDate,
|
|
1480
1480
|
..._(t)
|
|
1481
1481
|
});
|
|
1482
|
-
class
|
|
1482
|
+
class De extends v {
|
|
1483
1483
|
_parse(e) {
|
|
1484
1484
|
if (this._getType(e) !== h.symbol) {
|
|
1485
1485
|
const n = this._getOrReturnCtx(e);
|
|
1486
1486
|
return l(n, {
|
|
1487
|
-
code:
|
|
1487
|
+
code: u.invalid_type,
|
|
1488
1488
|
expected: h.symbol,
|
|
1489
1489
|
received: n.parsedType
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
1492
|
-
return
|
|
1492
|
+
return I(e.data);
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
|
|
1495
|
+
De.create = (t) => new De({
|
|
1496
1496
|
typeName: m.ZodSymbol,
|
|
1497
1497
|
..._(t)
|
|
1498
1498
|
});
|
|
1499
|
-
class
|
|
1499
|
+
class Ze extends v {
|
|
1500
1500
|
_parse(e) {
|
|
1501
1501
|
if (this._getType(e) !== h.undefined) {
|
|
1502
1502
|
const n = this._getOrReturnCtx(e);
|
|
1503
1503
|
return l(n, {
|
|
1504
|
-
code:
|
|
1504
|
+
code: u.invalid_type,
|
|
1505
1505
|
expected: h.undefined,
|
|
1506
1506
|
received: n.parsedType
|
|
1507
1507
|
}), y;
|
|
1508
1508
|
}
|
|
1509
|
-
return
|
|
1509
|
+
return I(e.data);
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
|
-
|
|
1512
|
+
Ze.create = (t) => new Ze({
|
|
1513
1513
|
typeName: m.ZodUndefined,
|
|
1514
1514
|
..._(t)
|
|
1515
1515
|
});
|
|
1516
|
-
class
|
|
1516
|
+
class Le extends v {
|
|
1517
1517
|
_parse(e) {
|
|
1518
1518
|
if (this._getType(e) !== h.null) {
|
|
1519
1519
|
const n = this._getOrReturnCtx(e);
|
|
1520
1520
|
return l(n, {
|
|
1521
|
-
code:
|
|
1521
|
+
code: u.invalid_type,
|
|
1522
1522
|
expected: h.null,
|
|
1523
1523
|
received: n.parsedType
|
|
1524
1524
|
}), y;
|
|
1525
1525
|
}
|
|
1526
|
-
return
|
|
1526
|
+
return I(e.data);
|
|
1527
1527
|
}
|
|
1528
1528
|
}
|
|
1529
|
-
|
|
1529
|
+
Le.create = (t) => new Le({
|
|
1530
1530
|
typeName: m.ZodNull,
|
|
1531
1531
|
..._(t)
|
|
1532
1532
|
});
|
|
1533
|
-
class
|
|
1533
|
+
class Me extends v {
|
|
1534
1534
|
constructor() {
|
|
1535
1535
|
super(...arguments), this._any = !0;
|
|
1536
1536
|
}
|
|
1537
1537
|
_parse(e) {
|
|
1538
|
-
return
|
|
1538
|
+
return I(e.data);
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
|
-
|
|
1541
|
+
Me.create = (t) => new Me({
|
|
1542
1542
|
typeName: m.ZodAny,
|
|
1543
1543
|
..._(t)
|
|
1544
1544
|
});
|
|
@@ -1547,57 +1547,57 @@ class Pe extends v {
|
|
|
1547
1547
|
super(...arguments), this._unknown = !0;
|
|
1548
1548
|
}
|
|
1549
1549
|
_parse(e) {
|
|
1550
|
-
return
|
|
1550
|
+
return I(e.data);
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
Pe.create = (t) => new Pe({
|
|
1554
1554
|
typeName: m.ZodUnknown,
|
|
1555
1555
|
..._(t)
|
|
1556
1556
|
});
|
|
1557
|
-
class
|
|
1557
|
+
class W extends v {
|
|
1558
1558
|
_parse(e) {
|
|
1559
1559
|
const s = this._getOrReturnCtx(e);
|
|
1560
1560
|
return l(s, {
|
|
1561
|
-
code:
|
|
1561
|
+
code: u.invalid_type,
|
|
1562
1562
|
expected: h.never,
|
|
1563
1563
|
received: s.parsedType
|
|
1564
1564
|
}), y;
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
|
-
|
|
1567
|
+
W.create = (t) => new W({
|
|
1568
1568
|
typeName: m.ZodNever,
|
|
1569
1569
|
..._(t)
|
|
1570
1570
|
});
|
|
1571
|
-
class
|
|
1571
|
+
class Ue extends v {
|
|
1572
1572
|
_parse(e) {
|
|
1573
1573
|
if (this._getType(e) !== h.undefined) {
|
|
1574
1574
|
const n = this._getOrReturnCtx(e);
|
|
1575
1575
|
return l(n, {
|
|
1576
|
-
code:
|
|
1576
|
+
code: u.invalid_type,
|
|
1577
1577
|
expected: h.void,
|
|
1578
1578
|
received: n.parsedType
|
|
1579
1579
|
}), y;
|
|
1580
1580
|
}
|
|
1581
|
-
return
|
|
1581
|
+
return I(e.data);
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
|
-
|
|
1584
|
+
Ue.create = (t) => new Ue({
|
|
1585
1585
|
typeName: m.ZodVoid,
|
|
1586
1586
|
..._(t)
|
|
1587
1587
|
});
|
|
1588
|
-
class
|
|
1588
|
+
class L extends v {
|
|
1589
1589
|
_parse(e) {
|
|
1590
1590
|
const { ctx: s, status: n } = this._processInputParams(e), r = this._def;
|
|
1591
1591
|
if (s.parsedType !== h.array)
|
|
1592
1592
|
return l(s, {
|
|
1593
|
-
code:
|
|
1593
|
+
code: u.invalid_type,
|
|
1594
1594
|
expected: h.array,
|
|
1595
1595
|
received: s.parsedType
|
|
1596
1596
|
}), y;
|
|
1597
1597
|
if (r.exactLength !== null) {
|
|
1598
1598
|
const i = s.data.length > r.exactLength.value, o = s.data.length < r.exactLength.value;
|
|
1599
1599
|
(i || o) && (l(s, {
|
|
1600
|
-
code: i ?
|
|
1600
|
+
code: i ? u.too_big : u.too_small,
|
|
1601
1601
|
minimum: o ? r.exactLength.value : void 0,
|
|
1602
1602
|
maximum: i ? r.exactLength.value : void 0,
|
|
1603
1603
|
type: "array",
|
|
@@ -1607,50 +1607,50 @@ class R extends v {
|
|
|
1607
1607
|
}), n.dirty());
|
|
1608
1608
|
}
|
|
1609
1609
|
if (r.minLength !== null && s.data.length < r.minLength.value && (l(s, {
|
|
1610
|
-
code:
|
|
1610
|
+
code: u.too_small,
|
|
1611
1611
|
minimum: r.minLength.value,
|
|
1612
1612
|
type: "array",
|
|
1613
1613
|
inclusive: !0,
|
|
1614
1614
|
exact: !1,
|
|
1615
1615
|
message: r.minLength.message
|
|
1616
1616
|
}), n.dirty()), r.maxLength !== null && s.data.length > r.maxLength.value && (l(s, {
|
|
1617
|
-
code:
|
|
1617
|
+
code: u.too_big,
|
|
1618
1618
|
maximum: r.maxLength.value,
|
|
1619
1619
|
type: "array",
|
|
1620
1620
|
inclusive: !0,
|
|
1621
1621
|
exact: !1,
|
|
1622
1622
|
message: r.maxLength.message
|
|
1623
1623
|
}), n.dirty()), s.common.async)
|
|
1624
|
-
return Promise.all([...s.data].map((i, o) => r.type._parseAsync(new
|
|
1625
|
-
const a = [...s.data].map((i, o) => r.type._parseSync(new
|
|
1626
|
-
return
|
|
1624
|
+
return Promise.all([...s.data].map((i, o) => r.type._parseAsync(new B(s, i, s.path, o)))).then((i) => A.mergeArray(n, i));
|
|
1625
|
+
const a = [...s.data].map((i, o) => r.type._parseSync(new B(s, i, s.path, o)));
|
|
1626
|
+
return A.mergeArray(n, a);
|
|
1627
1627
|
}
|
|
1628
1628
|
get element() {
|
|
1629
1629
|
return this._def.type;
|
|
1630
1630
|
}
|
|
1631
1631
|
min(e, s) {
|
|
1632
|
-
return new
|
|
1632
|
+
return new L({
|
|
1633
1633
|
...this._def,
|
|
1634
|
-
minLength: { value: e, message:
|
|
1634
|
+
minLength: { value: e, message: p.toString(s) }
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
1637
|
max(e, s) {
|
|
1638
|
-
return new
|
|
1638
|
+
return new L({
|
|
1639
1639
|
...this._def,
|
|
1640
|
-
maxLength: { value: e, message:
|
|
1640
|
+
maxLength: { value: e, message: p.toString(s) }
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
1643
|
length(e, s) {
|
|
1644
|
-
return new
|
|
1644
|
+
return new L({
|
|
1645
1645
|
...this._def,
|
|
1646
|
-
exactLength: { value: e, message:
|
|
1646
|
+
exactLength: { value: e, message: p.toString(s) }
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
1649
|
nonempty(e) {
|
|
1650
1650
|
return this.min(1, e);
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
|
|
1653
|
+
L.create = (t, e) => new L({
|
|
1654
1654
|
type: t,
|
|
1655
1655
|
minLength: null,
|
|
1656
1656
|
maxLength: null,
|
|
@@ -1658,23 +1658,23 @@ R.create = (t, e) => new R({
|
|
|
1658
1658
|
typeName: m.ZodArray,
|
|
1659
1659
|
..._(e)
|
|
1660
1660
|
});
|
|
1661
|
-
function
|
|
1662
|
-
if (t instanceof
|
|
1661
|
+
function se(t) {
|
|
1662
|
+
if (t instanceof T) {
|
|
1663
1663
|
const e = {};
|
|
1664
1664
|
for (const s in t.shape) {
|
|
1665
1665
|
const n = t.shape[s];
|
|
1666
|
-
e[s] =
|
|
1666
|
+
e[s] = z.create(se(n));
|
|
1667
1667
|
}
|
|
1668
|
-
return new
|
|
1668
|
+
return new T({
|
|
1669
1669
|
...t._def,
|
|
1670
1670
|
shape: () => e
|
|
1671
1671
|
});
|
|
1672
|
-
} else return t instanceof
|
|
1672
|
+
} else return t instanceof L ? new L({
|
|
1673
1673
|
...t._def,
|
|
1674
|
-
type:
|
|
1675
|
-
}) : t instanceof
|
|
1674
|
+
type: se(t.element)
|
|
1675
|
+
}) : t instanceof z ? z.create(se(t.unwrap())) : t instanceof ee ? ee.create(se(t.unwrap())) : t instanceof J ? J.create(t.items.map((e) => se(e))) : t;
|
|
1676
1676
|
}
|
|
1677
|
-
class
|
|
1677
|
+
class T extends v {
|
|
1678
1678
|
constructor() {
|
|
1679
1679
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1680
1680
|
}
|
|
@@ -1686,79 +1686,79 @@ class w extends v {
|
|
|
1686
1686
|
}
|
|
1687
1687
|
_parse(e) {
|
|
1688
1688
|
if (this._getType(e) !== h.object) {
|
|
1689
|
-
const
|
|
1690
|
-
return l(
|
|
1691
|
-
code:
|
|
1689
|
+
const d = this._getOrReturnCtx(e);
|
|
1690
|
+
return l(d, {
|
|
1691
|
+
code: u.invalid_type,
|
|
1692
1692
|
expected: h.object,
|
|
1693
|
-
received:
|
|
1693
|
+
received: d.parsedType
|
|
1694
1694
|
}), y;
|
|
1695
1695
|
}
|
|
1696
1696
|
const { status: n, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1697
|
-
if (!(this._def.catchall instanceof
|
|
1698
|
-
for (const
|
|
1699
|
-
i.includes(
|
|
1697
|
+
if (!(this._def.catchall instanceof W && this._def.unknownKeys === "strip"))
|
|
1698
|
+
for (const d in r.data)
|
|
1699
|
+
i.includes(d) || o.push(d);
|
|
1700
1700
|
const c = [];
|
|
1701
|
-
for (const
|
|
1702
|
-
const
|
|
1701
|
+
for (const d of i) {
|
|
1702
|
+
const f = a[d], w = r.data[d];
|
|
1703
1703
|
c.push({
|
|
1704
|
-
key: { status: "valid", value:
|
|
1705
|
-
value:
|
|
1706
|
-
alwaysSet:
|
|
1704
|
+
key: { status: "valid", value: d },
|
|
1705
|
+
value: f._parse(new B(r, w, r.path, d)),
|
|
1706
|
+
alwaysSet: d in r.data
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
1709
|
-
if (this._def.catchall instanceof
|
|
1710
|
-
const
|
|
1711
|
-
if (
|
|
1712
|
-
for (const
|
|
1709
|
+
if (this._def.catchall instanceof W) {
|
|
1710
|
+
const d = this._def.unknownKeys;
|
|
1711
|
+
if (d === "passthrough")
|
|
1712
|
+
for (const f of o)
|
|
1713
1713
|
c.push({
|
|
1714
|
-
key: { status: "valid", value:
|
|
1715
|
-
value: { status: "valid", value: r.data[
|
|
1714
|
+
key: { status: "valid", value: f },
|
|
1715
|
+
value: { status: "valid", value: r.data[f] }
|
|
1716
1716
|
});
|
|
1717
|
-
else if (
|
|
1717
|
+
else if (d === "strict")
|
|
1718
1718
|
o.length > 0 && (l(r, {
|
|
1719
|
-
code:
|
|
1719
|
+
code: u.unrecognized_keys,
|
|
1720
1720
|
keys: o
|
|
1721
1721
|
}), n.dirty());
|
|
1722
|
-
else if (
|
|
1722
|
+
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1723
1723
|
} else {
|
|
1724
|
-
const
|
|
1725
|
-
for (const
|
|
1726
|
-
const
|
|
1724
|
+
const d = this._def.catchall;
|
|
1725
|
+
for (const f of o) {
|
|
1726
|
+
const w = r.data[f];
|
|
1727
1727
|
c.push({
|
|
1728
|
-
key: { status: "valid", value:
|
|
1729
|
-
value:
|
|
1730
|
-
new
|
|
1728
|
+
key: { status: "valid", value: f },
|
|
1729
|
+
value: d._parse(
|
|
1730
|
+
new B(r, w, r.path, f)
|
|
1731
1731
|
//, ctx.child(key), value, getParsedType(value)
|
|
1732
1732
|
),
|
|
1733
|
-
alwaysSet:
|
|
1733
|
+
alwaysSet: f in r.data
|
|
1734
1734
|
});
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
1737
|
return r.common.async ? Promise.resolve().then(async () => {
|
|
1738
|
-
const
|
|
1739
|
-
for (const
|
|
1740
|
-
const
|
|
1741
|
-
|
|
1742
|
-
key:
|
|
1738
|
+
const d = [];
|
|
1739
|
+
for (const f of c) {
|
|
1740
|
+
const w = await f.key, C = await f.value;
|
|
1741
|
+
d.push({
|
|
1742
|
+
key: w,
|
|
1743
1743
|
value: C,
|
|
1744
|
-
alwaysSet:
|
|
1744
|
+
alwaysSet: f.alwaysSet
|
|
1745
1745
|
});
|
|
1746
1746
|
}
|
|
1747
|
-
return
|
|
1748
|
-
}).then((
|
|
1747
|
+
return d;
|
|
1748
|
+
}).then((d) => A.mergeObjectSync(n, d)) : A.mergeObjectSync(n, c);
|
|
1749
1749
|
}
|
|
1750
1750
|
get shape() {
|
|
1751
1751
|
return this._def.shape();
|
|
1752
1752
|
}
|
|
1753
1753
|
strict(e) {
|
|
1754
|
-
return
|
|
1754
|
+
return p.errToObj, new T({
|
|
1755
1755
|
...this._def,
|
|
1756
1756
|
unknownKeys: "strict",
|
|
1757
1757
|
...e !== void 0 ? {
|
|
1758
1758
|
errorMap: (s, n) => {
|
|
1759
1759
|
const r = this._def.errorMap?.(s, n).message ?? n.defaultError;
|
|
1760
1760
|
return s.code === "unrecognized_keys" ? {
|
|
1761
|
-
message:
|
|
1761
|
+
message: p.errToObj(e).message ?? r
|
|
1762
1762
|
} : {
|
|
1763
1763
|
message: r
|
|
1764
1764
|
};
|
|
@@ -1767,13 +1767,13 @@ class w extends v {
|
|
|
1767
1767
|
});
|
|
1768
1768
|
}
|
|
1769
1769
|
strip() {
|
|
1770
|
-
return new
|
|
1770
|
+
return new T({
|
|
1771
1771
|
...this._def,
|
|
1772
1772
|
unknownKeys: "strip"
|
|
1773
1773
|
});
|
|
1774
1774
|
}
|
|
1775
1775
|
passthrough() {
|
|
1776
|
-
return new
|
|
1776
|
+
return new T({
|
|
1777
1777
|
...this._def,
|
|
1778
1778
|
unknownKeys: "passthrough"
|
|
1779
1779
|
});
|
|
@@ -1796,7 +1796,7 @@ class w extends v {
|
|
|
1796
1796
|
// }) as any;
|
|
1797
1797
|
// };
|
|
1798
1798
|
extend(e) {
|
|
1799
|
-
return new
|
|
1799
|
+
return new T({
|
|
1800
1800
|
...this._def,
|
|
1801
1801
|
shape: () => ({
|
|
1802
1802
|
...this._def.shape(),
|
|
@@ -1810,7 +1810,7 @@ class w extends v {
|
|
|
1810
1810
|
* upgrade if you are experiencing issues.
|
|
1811
1811
|
*/
|
|
1812
1812
|
merge(e) {
|
|
1813
|
-
return new
|
|
1813
|
+
return new T({
|
|
1814
1814
|
unknownKeys: e._def.unknownKeys,
|
|
1815
1815
|
catchall: e._def.catchall,
|
|
1816
1816
|
shape: () => ({
|
|
@@ -1880,7 +1880,7 @@ class w extends v {
|
|
|
1880
1880
|
// return merged;
|
|
1881
1881
|
// }
|
|
1882
1882
|
catchall(e) {
|
|
1883
|
-
return new
|
|
1883
|
+
return new T({
|
|
1884
1884
|
...this._def,
|
|
1885
1885
|
catchall: e
|
|
1886
1886
|
});
|
|
@@ -1889,7 +1889,7 @@ class w extends v {
|
|
|
1889
1889
|
const s = {};
|
|
1890
1890
|
for (const n of b.objectKeys(e))
|
|
1891
1891
|
e[n] && this.shape[n] && (s[n] = this.shape[n]);
|
|
1892
|
-
return new
|
|
1892
|
+
return new T({
|
|
1893
1893
|
...this._def,
|
|
1894
1894
|
shape: () => s
|
|
1895
1895
|
});
|
|
@@ -1898,7 +1898,7 @@ class w extends v {
|
|
|
1898
1898
|
const s = {};
|
|
1899
1899
|
for (const n of b.objectKeys(this.shape))
|
|
1900
1900
|
e[n] || (s[n] = this.shape[n]);
|
|
1901
|
-
return new
|
|
1901
|
+
return new T({
|
|
1902
1902
|
...this._def,
|
|
1903
1903
|
shape: () => s
|
|
1904
1904
|
});
|
|
@@ -1907,7 +1907,7 @@ class w extends v {
|
|
|
1907
1907
|
* @deprecated
|
|
1908
1908
|
*/
|
|
1909
1909
|
deepPartial() {
|
|
1910
|
-
return
|
|
1910
|
+
return se(this);
|
|
1911
1911
|
}
|
|
1912
1912
|
partial(e) {
|
|
1913
1913
|
const s = {};
|
|
@@ -1915,7 +1915,7 @@ class w extends v {
|
|
|
1915
1915
|
const r = this.shape[n];
|
|
1916
1916
|
e && !e[n] ? s[n] = r : s[n] = r.optional();
|
|
1917
1917
|
}
|
|
1918
|
-
return new
|
|
1918
|
+
return new T({
|
|
1919
1919
|
...this._def,
|
|
1920
1920
|
shape: () => s
|
|
1921
1921
|
});
|
|
@@ -1927,11 +1927,11 @@ class w extends v {
|
|
|
1927
1927
|
s[n] = this.shape[n];
|
|
1928
1928
|
else {
|
|
1929
1929
|
let a = this.shape[n];
|
|
1930
|
-
for (; a instanceof
|
|
1930
|
+
for (; a instanceof z; )
|
|
1931
1931
|
a = a._def.innerType;
|
|
1932
1932
|
s[n] = a;
|
|
1933
1933
|
}
|
|
1934
|
-
return new
|
|
1934
|
+
return new T({
|
|
1935
1935
|
...this._def,
|
|
1936
1936
|
shape: () => s
|
|
1937
1937
|
});
|
|
@@ -1940,28 +1940,28 @@ class w extends v {
|
|
|
1940
1940
|
return rt(b.objectKeys(this.shape));
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
|
-
|
|
1943
|
+
T.create = (t, e) => new T({
|
|
1944
1944
|
shape: () => t,
|
|
1945
1945
|
unknownKeys: "strip",
|
|
1946
|
-
catchall:
|
|
1946
|
+
catchall: W.create(),
|
|
1947
1947
|
typeName: m.ZodObject,
|
|
1948
1948
|
..._(e)
|
|
1949
1949
|
});
|
|
1950
|
-
|
|
1950
|
+
T.strictCreate = (t, e) => new T({
|
|
1951
1951
|
shape: () => t,
|
|
1952
1952
|
unknownKeys: "strict",
|
|
1953
|
-
catchall:
|
|
1953
|
+
catchall: W.create(),
|
|
1954
1954
|
typeName: m.ZodObject,
|
|
1955
1955
|
..._(e)
|
|
1956
1956
|
});
|
|
1957
|
-
|
|
1957
|
+
T.lazycreate = (t, e) => new T({
|
|
1958
1958
|
shape: t,
|
|
1959
1959
|
unknownKeys: "strip",
|
|
1960
|
-
catchall:
|
|
1960
|
+
catchall: W.create(),
|
|
1961
1961
|
typeName: m.ZodObject,
|
|
1962
1962
|
..._(e)
|
|
1963
1963
|
});
|
|
1964
|
-
class
|
|
1964
|
+
class ue extends v {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: s } = this._processInputParams(e), n = this._def.options;
|
|
1967
1967
|
function r(a) {
|
|
@@ -1971,9 +1971,9 @@ class de extends v {
|
|
|
1971
1971
|
for (const o of a)
|
|
1972
1972
|
if (o.result.status === "dirty")
|
|
1973
1973
|
return s.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1974
|
-
const i = a.map((o) => new
|
|
1974
|
+
const i = a.map((o) => new U(o.ctx.common.issues));
|
|
1975
1975
|
return l(s, {
|
|
1976
|
-
code:
|
|
1976
|
+
code: u.invalid_union,
|
|
1977
1977
|
unionErrors: i
|
|
1978
1978
|
}), y;
|
|
1979
1979
|
}
|
|
@@ -2000,27 +2000,27 @@ class de extends v {
|
|
|
2000
2000
|
let a;
|
|
2001
2001
|
const i = [];
|
|
2002
2002
|
for (const c of n) {
|
|
2003
|
-
const
|
|
2003
|
+
const d = {
|
|
2004
2004
|
...s,
|
|
2005
2005
|
common: {
|
|
2006
2006
|
...s.common,
|
|
2007
2007
|
issues: []
|
|
2008
2008
|
},
|
|
2009
2009
|
parent: null
|
|
2010
|
-
},
|
|
2010
|
+
}, f = c._parseSync({
|
|
2011
2011
|
data: s.data,
|
|
2012
2012
|
path: s.path,
|
|
2013
|
-
parent:
|
|
2013
|
+
parent: d
|
|
2014
2014
|
});
|
|
2015
|
-
if (
|
|
2016
|
-
return
|
|
2017
|
-
|
|
2015
|
+
if (f.status === "valid")
|
|
2016
|
+
return f;
|
|
2017
|
+
f.status === "dirty" && !a && (a = { result: f, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
2018
2018
|
}
|
|
2019
2019
|
if (a)
|
|
2020
2020
|
return s.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2021
|
-
const o = i.map((c) => new
|
|
2021
|
+
const o = i.map((c) => new U(c));
|
|
2022
2022
|
return l(s, {
|
|
2023
|
-
code:
|
|
2023
|
+
code: u.invalid_union,
|
|
2024
2024
|
unionErrors: o
|
|
2025
2025
|
}), y;
|
|
2026
2026
|
}
|
|
@@ -2029,19 +2029,19 @@ class de extends v {
|
|
|
2029
2029
|
return this._def.options;
|
|
2030
2030
|
}
|
|
2031
2031
|
}
|
|
2032
|
-
|
|
2032
|
+
ue.create = (t, e) => new ue({
|
|
2033
2033
|
options: t,
|
|
2034
2034
|
typeName: m.ZodUnion,
|
|
2035
2035
|
..._(e)
|
|
2036
2036
|
});
|
|
2037
|
-
function
|
|
2038
|
-
const s =
|
|
2037
|
+
function Be(t, e) {
|
|
2038
|
+
const s = q(t), n = q(e);
|
|
2039
2039
|
if (t === e)
|
|
2040
2040
|
return { valid: !0, data: t };
|
|
2041
2041
|
if (s === h.object && n === h.object) {
|
|
2042
2042
|
const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2043
2043
|
for (const o of a) {
|
|
2044
|
-
const c =
|
|
2044
|
+
const c = Be(t[o], e[o]);
|
|
2045
2045
|
if (!c.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
2047
|
i[o] = c.data;
|
|
@@ -2052,7 +2052,7 @@ function Ue(t, e) {
|
|
|
2052
2052
|
return { valid: !1 };
|
|
2053
2053
|
const r = [];
|
|
2054
2054
|
for (let a = 0; a < t.length; a++) {
|
|
2055
|
-
const i = t[a], o = e[a], c =
|
|
2055
|
+
const i = t[a], o = e[a], c = Be(i, o);
|
|
2056
2056
|
if (!c.valid)
|
|
2057
2057
|
return { valid: !1 };
|
|
2058
2058
|
r.push(c.data);
|
|
@@ -2060,14 +2060,14 @@ function Ue(t, e) {
|
|
|
2060
2060
|
return { valid: !0, data: r };
|
|
2061
2061
|
} else return s === h.date && n === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2062
2062
|
}
|
|
2063
|
-
class
|
|
2063
|
+
class le extends v {
|
|
2064
2064
|
_parse(e) {
|
|
2065
2065
|
const { status: s, ctx: n } = this._processInputParams(e), r = (a, i) => {
|
|
2066
|
-
if (
|
|
2066
|
+
if (Ie(a) || Ie(i))
|
|
2067
2067
|
return y;
|
|
2068
|
-
const o =
|
|
2068
|
+
const o = Be(a.value, i.value);
|
|
2069
2069
|
return o.valid ? ((je(a) || je(i)) && s.dirty(), { status: s.value, value: o.data }) : (l(n, {
|
|
2070
|
-
code:
|
|
2070
|
+
code: u.invalid_intersection_types
|
|
2071
2071
|
}), y);
|
|
2072
2072
|
};
|
|
2073
2073
|
return n.common.async ? Promise.all([
|
|
@@ -2092,31 +2092,31 @@ class ue extends v {
|
|
|
2092
2092
|
}));
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
|
|
2095
|
+
le.create = (t, e, s) => new le({
|
|
2096
2096
|
left: t,
|
|
2097
2097
|
right: e,
|
|
2098
2098
|
typeName: m.ZodIntersection,
|
|
2099
2099
|
..._(s)
|
|
2100
2100
|
});
|
|
2101
|
-
class
|
|
2101
|
+
class J extends v {
|
|
2102
2102
|
_parse(e) {
|
|
2103
2103
|
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2104
2104
|
if (n.parsedType !== h.array)
|
|
2105
2105
|
return l(n, {
|
|
2106
|
-
code:
|
|
2106
|
+
code: u.invalid_type,
|
|
2107
2107
|
expected: h.array,
|
|
2108
2108
|
received: n.parsedType
|
|
2109
2109
|
}), y;
|
|
2110
2110
|
if (n.data.length < this._def.items.length)
|
|
2111
2111
|
return l(n, {
|
|
2112
|
-
code:
|
|
2112
|
+
code: u.too_small,
|
|
2113
2113
|
minimum: this._def.items.length,
|
|
2114
2114
|
inclusive: !0,
|
|
2115
2115
|
exact: !1,
|
|
2116
2116
|
type: "array"
|
|
2117
2117
|
}), y;
|
|
2118
2118
|
!this._def.rest && n.data.length > this._def.items.length && (l(n, {
|
|
2119
|
-
code:
|
|
2119
|
+
code: u.too_big,
|
|
2120
2120
|
maximum: this._def.items.length,
|
|
2121
2121
|
inclusive: !0,
|
|
2122
2122
|
exact: !1,
|
|
@@ -2124,31 +2124,31 @@ class F extends v {
|
|
|
2124
2124
|
}), s.dirty());
|
|
2125
2125
|
const a = [...n.data].map((i, o) => {
|
|
2126
2126
|
const c = this._def.items[o] || this._def.rest;
|
|
2127
|
-
return c ? c._parse(new
|
|
2127
|
+
return c ? c._parse(new B(n, i, n.path, o)) : null;
|
|
2128
2128
|
}).filter((i) => !!i);
|
|
2129
|
-
return n.common.async ? Promise.all(a).then((i) =>
|
|
2129
|
+
return n.common.async ? Promise.all(a).then((i) => A.mergeArray(s, i)) : A.mergeArray(s, a);
|
|
2130
2130
|
}
|
|
2131
2131
|
get items() {
|
|
2132
2132
|
return this._def.items;
|
|
2133
2133
|
}
|
|
2134
2134
|
rest(e) {
|
|
2135
|
-
return new
|
|
2135
|
+
return new J({
|
|
2136
2136
|
...this._def,
|
|
2137
2137
|
rest: e
|
|
2138
2138
|
});
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
|
-
|
|
2141
|
+
J.create = (t, e) => {
|
|
2142
2142
|
if (!Array.isArray(t))
|
|
2143
2143
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2144
|
-
return new
|
|
2144
|
+
return new J({
|
|
2145
2145
|
items: t,
|
|
2146
2146
|
typeName: m.ZodTuple,
|
|
2147
2147
|
rest: null,
|
|
2148
2148
|
..._(e)
|
|
2149
2149
|
});
|
|
2150
2150
|
};
|
|
2151
|
-
class
|
|
2151
|
+
class he extends v {
|
|
2152
2152
|
get keySchema() {
|
|
2153
2153
|
return this._def.keyType;
|
|
2154
2154
|
}
|
|
@@ -2159,37 +2159,37 @@ class le extends v {
|
|
|
2159
2159
|
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2160
2160
|
if (n.parsedType !== h.object)
|
|
2161
2161
|
return l(n, {
|
|
2162
|
-
code:
|
|
2162
|
+
code: u.invalid_type,
|
|
2163
2163
|
expected: h.object,
|
|
2164
2164
|
received: n.parsedType
|
|
2165
2165
|
}), y;
|
|
2166
2166
|
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2167
2167
|
for (const o in n.data)
|
|
2168
2168
|
r.push({
|
|
2169
|
-
key: a._parse(new
|
|
2170
|
-
value: i._parse(new
|
|
2169
|
+
key: a._parse(new B(n, o, n.path, o)),
|
|
2170
|
+
value: i._parse(new B(n, n.data[o], n.path, o)),
|
|
2171
2171
|
alwaysSet: o in n.data
|
|
2172
2172
|
});
|
|
2173
|
-
return n.common.async ?
|
|
2173
|
+
return n.common.async ? A.mergeObjectAsync(s, r) : A.mergeObjectSync(s, r);
|
|
2174
2174
|
}
|
|
2175
2175
|
get element() {
|
|
2176
2176
|
return this._def.valueType;
|
|
2177
2177
|
}
|
|
2178
2178
|
static create(e, s, n) {
|
|
2179
|
-
return s instanceof v ? new
|
|
2179
|
+
return s instanceof v ? new he({
|
|
2180
2180
|
keyType: e,
|
|
2181
2181
|
valueType: s,
|
|
2182
2182
|
typeName: m.ZodRecord,
|
|
2183
2183
|
..._(n)
|
|
2184
|
-
}) : new
|
|
2185
|
-
keyType:
|
|
2184
|
+
}) : new he({
|
|
2185
|
+
keyType: P.create(),
|
|
2186
2186
|
valueType: e,
|
|
2187
2187
|
typeName: m.ZodRecord,
|
|
2188
2188
|
..._(s)
|
|
2189
2189
|
});
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
-
class
|
|
2192
|
+
class Fe extends v {
|
|
2193
2193
|
get keySchema() {
|
|
2194
2194
|
return this._def.keyType;
|
|
2195
2195
|
}
|
|
@@ -2200,62 +2200,62 @@ class Be extends v {
|
|
|
2200
2200
|
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2201
2201
|
if (n.parsedType !== h.map)
|
|
2202
2202
|
return l(n, {
|
|
2203
|
-
code:
|
|
2203
|
+
code: u.invalid_type,
|
|
2204
2204
|
expected: h.map,
|
|
2205
2205
|
received: n.parsedType
|
|
2206
2206
|
}), y;
|
|
2207
|
-
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, c],
|
|
2208
|
-
key: r._parse(new
|
|
2209
|
-
value: a._parse(new
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, c], d) => ({
|
|
2208
|
+
key: r._parse(new B(n, o, n.path, [d, "key"])),
|
|
2209
|
+
value: a._parse(new B(n, c, n.path, [d, "value"]))
|
|
2210
2210
|
}));
|
|
2211
2211
|
if (n.common.async) {
|
|
2212
2212
|
const o = /* @__PURE__ */ new Map();
|
|
2213
2213
|
return Promise.resolve().then(async () => {
|
|
2214
2214
|
for (const c of i) {
|
|
2215
|
-
const
|
|
2216
|
-
if (
|
|
2215
|
+
const d = await c.key, f = await c.value;
|
|
2216
|
+
if (d.status === "aborted" || f.status === "aborted")
|
|
2217
2217
|
return y;
|
|
2218
|
-
(
|
|
2218
|
+
(d.status === "dirty" || f.status === "dirty") && s.dirty(), o.set(d.value, f.value);
|
|
2219
2219
|
}
|
|
2220
2220
|
return { status: s.value, value: o };
|
|
2221
2221
|
});
|
|
2222
2222
|
} else {
|
|
2223
2223
|
const o = /* @__PURE__ */ new Map();
|
|
2224
2224
|
for (const c of i) {
|
|
2225
|
-
const
|
|
2226
|
-
if (
|
|
2225
|
+
const d = c.key, f = c.value;
|
|
2226
|
+
if (d.status === "aborted" || f.status === "aborted")
|
|
2227
2227
|
return y;
|
|
2228
|
-
(
|
|
2228
|
+
(d.status === "dirty" || f.status === "dirty") && s.dirty(), o.set(d.value, f.value);
|
|
2229
2229
|
}
|
|
2230
2230
|
return { status: s.value, value: o };
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
|
-
|
|
2234
|
+
Fe.create = (t, e, s) => new Fe({
|
|
2235
2235
|
valueType: e,
|
|
2236
2236
|
keyType: t,
|
|
2237
2237
|
typeName: m.ZodMap,
|
|
2238
2238
|
..._(s)
|
|
2239
2239
|
});
|
|
2240
|
-
class
|
|
2240
|
+
class ae extends v {
|
|
2241
2241
|
_parse(e) {
|
|
2242
2242
|
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2243
2243
|
if (n.parsedType !== h.set)
|
|
2244
2244
|
return l(n, {
|
|
2245
|
-
code:
|
|
2245
|
+
code: u.invalid_type,
|
|
2246
2246
|
expected: h.set,
|
|
2247
2247
|
received: n.parsedType
|
|
2248
2248
|
}), y;
|
|
2249
2249
|
const r = this._def;
|
|
2250
2250
|
r.minSize !== null && n.data.size < r.minSize.value && (l(n, {
|
|
2251
|
-
code:
|
|
2251
|
+
code: u.too_small,
|
|
2252
2252
|
minimum: r.minSize.value,
|
|
2253
2253
|
type: "set",
|
|
2254
2254
|
inclusive: !0,
|
|
2255
2255
|
exact: !1,
|
|
2256
2256
|
message: r.minSize.message
|
|
2257
2257
|
}), s.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (l(n, {
|
|
2258
|
-
code:
|
|
2258
|
+
code: u.too_big,
|
|
2259
2259
|
maximum: r.maxSize.value,
|
|
2260
2260
|
type: "set",
|
|
2261
2261
|
inclusive: !0,
|
|
@@ -2264,27 +2264,27 @@ class ne extends v {
|
|
|
2264
2264
|
}), s.dirty());
|
|
2265
2265
|
const a = this._def.valueType;
|
|
2266
2266
|
function i(c) {
|
|
2267
|
-
const
|
|
2268
|
-
for (const
|
|
2269
|
-
if (
|
|
2267
|
+
const d = /* @__PURE__ */ new Set();
|
|
2268
|
+
for (const f of c) {
|
|
2269
|
+
if (f.status === "aborted")
|
|
2270
2270
|
return y;
|
|
2271
|
-
|
|
2271
|
+
f.status === "dirty" && s.dirty(), d.add(f.value);
|
|
2272
2272
|
}
|
|
2273
|
-
return { status: s.value, value:
|
|
2273
|
+
return { status: s.value, value: d };
|
|
2274
2274
|
}
|
|
2275
|
-
const o = [...n.data.values()].map((c,
|
|
2275
|
+
const o = [...n.data.values()].map((c, d) => a._parse(new B(n, c, n.path, d)));
|
|
2276
2276
|
return n.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2277
2277
|
}
|
|
2278
2278
|
min(e, s) {
|
|
2279
|
-
return new
|
|
2279
|
+
return new ae({
|
|
2280
2280
|
...this._def,
|
|
2281
|
-
minSize: { value: e, message:
|
|
2281
|
+
minSize: { value: e, message: p.toString(s) }
|
|
2282
2282
|
});
|
|
2283
2283
|
}
|
|
2284
2284
|
max(e, s) {
|
|
2285
|
-
return new
|
|
2285
|
+
return new ae({
|
|
2286
2286
|
...this._def,
|
|
2287
|
-
maxSize: { value: e, message:
|
|
2287
|
+
maxSize: { value: e, message: p.toString(s) }
|
|
2288
2288
|
});
|
|
2289
2289
|
}
|
|
2290
2290
|
size(e, s) {
|
|
@@ -2294,7 +2294,7 @@ class ne extends v {
|
|
|
2294
2294
|
return this.min(1, e);
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
2297
|
-
|
|
2297
|
+
ae.create = (t, e) => new ae({
|
|
2298
2298
|
valueType: t,
|
|
2299
2299
|
minSize: null,
|
|
2300
2300
|
maxSize: null,
|
|
@@ -2315,13 +2315,13 @@ Ve.create = (t, e) => new Ve({
|
|
|
2315
2315
|
typeName: m.ZodLazy,
|
|
2316
2316
|
..._(e)
|
|
2317
2317
|
});
|
|
2318
|
-
class
|
|
2318
|
+
class qe extends v {
|
|
2319
2319
|
_parse(e) {
|
|
2320
2320
|
if (e.data !== this._def.value) {
|
|
2321
2321
|
const s = this._getOrReturnCtx(e);
|
|
2322
2322
|
return l(s, {
|
|
2323
2323
|
received: s.data,
|
|
2324
|
-
code:
|
|
2324
|
+
code: u.invalid_literal,
|
|
2325
2325
|
expected: this._def.value
|
|
2326
2326
|
}), y;
|
|
2327
2327
|
}
|
|
@@ -2331,37 +2331,37 @@ class Fe extends v {
|
|
|
2331
2331
|
return this._def.value;
|
|
2332
2332
|
}
|
|
2333
2333
|
}
|
|
2334
|
-
|
|
2334
|
+
qe.create = (t, e) => new qe({
|
|
2335
2335
|
value: t,
|
|
2336
2336
|
typeName: m.ZodLiteral,
|
|
2337
2337
|
..._(e)
|
|
2338
2338
|
});
|
|
2339
2339
|
function rt(t, e) {
|
|
2340
|
-
return new
|
|
2340
|
+
return new X({
|
|
2341
2341
|
values: t,
|
|
2342
2342
|
typeName: m.ZodEnum,
|
|
2343
2343
|
..._(e)
|
|
2344
2344
|
});
|
|
2345
2345
|
}
|
|
2346
|
-
class
|
|
2346
|
+
class X extends v {
|
|
2347
2347
|
_parse(e) {
|
|
2348
2348
|
if (typeof e.data != "string") {
|
|
2349
2349
|
const s = this._getOrReturnCtx(e), n = this._def.values;
|
|
2350
2350
|
return l(s, {
|
|
2351
2351
|
expected: b.joinValues(n),
|
|
2352
2352
|
received: s.parsedType,
|
|
2353
|
-
code:
|
|
2353
|
+
code: u.invalid_type
|
|
2354
2354
|
}), y;
|
|
2355
2355
|
}
|
|
2356
2356
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2357
2357
|
const s = this._getOrReturnCtx(e), n = this._def.values;
|
|
2358
2358
|
return l(s, {
|
|
2359
2359
|
received: s.data,
|
|
2360
|
-
code:
|
|
2360
|
+
code: u.invalid_enum_value,
|
|
2361
2361
|
options: n
|
|
2362
2362
|
}), y;
|
|
2363
2363
|
}
|
|
2364
|
-
return
|
|
2364
|
+
return I(e.data);
|
|
2365
2365
|
}
|
|
2366
2366
|
get options() {
|
|
2367
2367
|
return this._def.values;
|
|
@@ -2385,19 +2385,19 @@ class Y extends v {
|
|
|
2385
2385
|
return e;
|
|
2386
2386
|
}
|
|
2387
2387
|
extract(e, s = this._def) {
|
|
2388
|
-
return
|
|
2388
|
+
return X.create(e, {
|
|
2389
2389
|
...this._def,
|
|
2390
2390
|
...s
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
exclude(e, s = this._def) {
|
|
2394
|
-
return
|
|
2394
|
+
return X.create(this.options.filter((n) => !e.includes(n)), {
|
|
2395
2395
|
...this._def,
|
|
2396
2396
|
...s
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
|
|
2400
|
+
X.create = rt;
|
|
2401
2401
|
class ze extends v {
|
|
2402
2402
|
_parse(e) {
|
|
2403
2403
|
const s = b.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
@@ -2406,18 +2406,18 @@ class ze extends v {
|
|
|
2406
2406
|
return l(n, {
|
|
2407
2407
|
expected: b.joinValues(r),
|
|
2408
2408
|
received: n.parsedType,
|
|
2409
|
-
code:
|
|
2409
|
+
code: u.invalid_type
|
|
2410
2410
|
}), y;
|
|
2411
2411
|
}
|
|
2412
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2413
2413
|
const r = b.objectValues(s);
|
|
2414
2414
|
return l(n, {
|
|
2415
2415
|
received: n.data,
|
|
2416
|
-
code:
|
|
2416
|
+
code: u.invalid_enum_value,
|
|
2417
2417
|
options: r
|
|
2418
2418
|
}), y;
|
|
2419
2419
|
}
|
|
2420
|
-
return
|
|
2420
|
+
return I(e.data);
|
|
2421
2421
|
}
|
|
2422
2422
|
get enum() {
|
|
2423
2423
|
return this._def.values;
|
|
@@ -2428,7 +2428,7 @@ ze.create = (t, e) => new ze({
|
|
|
2428
2428
|
typeName: m.ZodNativeEnum,
|
|
2429
2429
|
..._(e)
|
|
2430
2430
|
});
|
|
2431
|
-
class
|
|
2431
|
+
class fe extends v {
|
|
2432
2432
|
unwrap() {
|
|
2433
2433
|
return this._def.type;
|
|
2434
2434
|
}
|
|
@@ -2436,23 +2436,23 @@ class he extends v {
|
|
|
2436
2436
|
const { ctx: s } = this._processInputParams(e);
|
|
2437
2437
|
if (s.parsedType !== h.promise && s.common.async === !1)
|
|
2438
2438
|
return l(s, {
|
|
2439
|
-
code:
|
|
2439
|
+
code: u.invalid_type,
|
|
2440
2440
|
expected: h.promise,
|
|
2441
2441
|
received: s.parsedType
|
|
2442
2442
|
}), y;
|
|
2443
2443
|
const n = s.parsedType === h.promise ? s.data : Promise.resolve(s.data);
|
|
2444
|
-
return
|
|
2444
|
+
return I(n.then((r) => this._def.type.parseAsync(r, {
|
|
2445
2445
|
path: s.path,
|
|
2446
2446
|
errorMap: s.common.contextualErrorMap
|
|
2447
2447
|
})));
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
|
|
2450
|
+
fe.create = (t, e) => new fe({
|
|
2451
2451
|
type: t,
|
|
2452
2452
|
typeName: m.ZodPromise,
|
|
2453
2453
|
..._(e)
|
|
2454
2454
|
});
|
|
2455
|
-
class
|
|
2455
|
+
class G extends v {
|
|
2456
2456
|
innerType() {
|
|
2457
2457
|
return this._def.schema;
|
|
2458
2458
|
}
|
|
@@ -2479,7 +2479,7 @@ class z extends v {
|
|
|
2479
2479
|
path: n.path,
|
|
2480
2480
|
parent: n
|
|
2481
2481
|
});
|
|
2482
|
-
return c.status === "aborted" ? y : c.status === "dirty" || s.value === "dirty" ?
|
|
2482
|
+
return c.status === "aborted" ? y : c.status === "dirty" || s.value === "dirty" ? ne(c.value) : c;
|
|
2483
2483
|
});
|
|
2484
2484
|
{
|
|
2485
2485
|
if (s.value === "aborted")
|
|
@@ -2489,7 +2489,7 @@ class z extends v {
|
|
|
2489
2489
|
path: n.path,
|
|
2490
2490
|
parent: n
|
|
2491
2491
|
});
|
|
2492
|
-
return o.status === "aborted" ? y : o.status === "dirty" || s.value === "dirty" ?
|
|
2492
|
+
return o.status === "aborted" ? y : o.status === "dirty" || s.value === "dirty" ? ne(o.value) : o;
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
2495
|
if (r.type === "refinement") {
|
|
@@ -2518,59 +2518,59 @@ class z extends v {
|
|
|
2518
2518
|
path: n.path,
|
|
2519
2519
|
parent: n
|
|
2520
2520
|
});
|
|
2521
|
-
if (!
|
|
2521
|
+
if (!Y(i))
|
|
2522
2522
|
return y;
|
|
2523
2523
|
const o = r.transform(i.value, a);
|
|
2524
2524
|
if (o instanceof Promise)
|
|
2525
2525
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2526
2526
|
return { status: s.value, value: o };
|
|
2527
2527
|
} else
|
|
2528
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) =>
|
|
2528
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => Y(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2529
2529
|
status: s.value,
|
|
2530
2530
|
value: o
|
|
2531
2531
|
})) : y);
|
|
2532
2532
|
b.assertNever(r);
|
|
2533
2533
|
}
|
|
2534
2534
|
}
|
|
2535
|
-
|
|
2535
|
+
G.create = (t, e, s) => new G({
|
|
2536
2536
|
schema: t,
|
|
2537
2537
|
typeName: m.ZodEffects,
|
|
2538
2538
|
effect: e,
|
|
2539
2539
|
..._(s)
|
|
2540
2540
|
});
|
|
2541
|
-
|
|
2541
|
+
G.createWithPreprocess = (t, e, s) => new G({
|
|
2542
2542
|
schema: e,
|
|
2543
2543
|
effect: { type: "preprocess", transform: t },
|
|
2544
2544
|
typeName: m.ZodEffects,
|
|
2545
2545
|
..._(s)
|
|
2546
2546
|
});
|
|
2547
|
-
class
|
|
2547
|
+
class z extends v {
|
|
2548
2548
|
_parse(e) {
|
|
2549
|
-
return this._getType(e) === h.undefined ?
|
|
2549
|
+
return this._getType(e) === h.undefined ? I(void 0) : this._def.innerType._parse(e);
|
|
2550
2550
|
}
|
|
2551
2551
|
unwrap() {
|
|
2552
2552
|
return this._def.innerType;
|
|
2553
2553
|
}
|
|
2554
2554
|
}
|
|
2555
|
-
|
|
2555
|
+
z.create = (t, e) => new z({
|
|
2556
2556
|
innerType: t,
|
|
2557
2557
|
typeName: m.ZodOptional,
|
|
2558
2558
|
..._(e)
|
|
2559
2559
|
});
|
|
2560
|
-
class
|
|
2560
|
+
class ee extends v {
|
|
2561
2561
|
_parse(e) {
|
|
2562
|
-
return this._getType(e) === h.null ?
|
|
2562
|
+
return this._getType(e) === h.null ? I(null) : this._def.innerType._parse(e);
|
|
2563
2563
|
}
|
|
2564
2564
|
unwrap() {
|
|
2565
2565
|
return this._def.innerType;
|
|
2566
2566
|
}
|
|
2567
2567
|
}
|
|
2568
|
-
|
|
2568
|
+
ee.create = (t, e) => new ee({
|
|
2569
2569
|
innerType: t,
|
|
2570
2570
|
typeName: m.ZodNullable,
|
|
2571
2571
|
..._(e)
|
|
2572
2572
|
});
|
|
2573
|
-
class
|
|
2573
|
+
class ge extends v {
|
|
2574
2574
|
_parse(e) {
|
|
2575
2575
|
const { ctx: s } = this._processInputParams(e);
|
|
2576
2576
|
let n = s.data;
|
|
@@ -2584,13 +2584,13 @@ class ye extends v {
|
|
|
2584
2584
|
return this._def.innerType;
|
|
2585
2585
|
}
|
|
2586
2586
|
}
|
|
2587
|
-
|
|
2587
|
+
ge.create = (t, e) => new ge({
|
|
2588
2588
|
innerType: t,
|
|
2589
2589
|
typeName: m.ZodDefault,
|
|
2590
2590
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2591
2591
|
..._(e)
|
|
2592
2592
|
});
|
|
2593
|
-
class
|
|
2593
|
+
class _e extends v {
|
|
2594
2594
|
_parse(e) {
|
|
2595
2595
|
const { ctx: s } = this._processInputParams(e), n = {
|
|
2596
2596
|
...s,
|
|
@@ -2605,11 +2605,11 @@ class ge extends v {
|
|
|
2605
2605
|
...n
|
|
2606
2606
|
}
|
|
2607
2607
|
});
|
|
2608
|
-
return
|
|
2608
|
+
return ce(r) ? r.then((a) => ({
|
|
2609
2609
|
status: "valid",
|
|
2610
2610
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2611
2611
|
get error() {
|
|
2612
|
-
return new
|
|
2612
|
+
return new U(n.common.issues);
|
|
2613
2613
|
},
|
|
2614
2614
|
input: n.data
|
|
2615
2615
|
})
|
|
@@ -2617,7 +2617,7 @@ class ge extends v {
|
|
|
2617
2617
|
status: "valid",
|
|
2618
2618
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2619
2619
|
get error() {
|
|
2620
|
-
return new
|
|
2620
|
+
return new U(n.common.issues);
|
|
2621
2621
|
},
|
|
2622
2622
|
input: n.data
|
|
2623
2623
|
})
|
|
@@ -2627,18 +2627,18 @@ class ge extends v {
|
|
|
2627
2627
|
return this._def.innerType;
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
|
|
2630
|
+
_e.create = (t, e) => new _e({
|
|
2631
2631
|
innerType: t,
|
|
2632
2632
|
typeName: m.ZodCatch,
|
|
2633
2633
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2634
2634
|
..._(e)
|
|
2635
2635
|
});
|
|
2636
|
-
class
|
|
2636
|
+
class We extends v {
|
|
2637
2637
|
_parse(e) {
|
|
2638
2638
|
if (this._getType(e) !== h.nan) {
|
|
2639
2639
|
const n = this._getOrReturnCtx(e);
|
|
2640
2640
|
return l(n, {
|
|
2641
|
-
code:
|
|
2641
|
+
code: u.invalid_type,
|
|
2642
2642
|
expected: h.nan,
|
|
2643
2643
|
received: n.parsedType
|
|
2644
2644
|
}), y;
|
|
@@ -2646,7 +2646,7 @@ class qe extends v {
|
|
|
2646
2646
|
return { status: "valid", value: e.data };
|
|
2647
2647
|
}
|
|
2648
2648
|
}
|
|
2649
|
-
|
|
2649
|
+
We.create = (t) => new We({
|
|
2650
2650
|
typeName: m.ZodNaN,
|
|
2651
2651
|
..._(t)
|
|
2652
2652
|
});
|
|
@@ -2663,7 +2663,7 @@ class at extends v {
|
|
|
2663
2663
|
return this._def.type;
|
|
2664
2664
|
}
|
|
2665
2665
|
}
|
|
2666
|
-
class
|
|
2666
|
+
class we extends v {
|
|
2667
2667
|
_parse(e) {
|
|
2668
2668
|
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2669
2669
|
if (n.common.async)
|
|
@@ -2673,7 +2673,7 @@ class xe extends v {
|
|
|
2673
2673
|
path: n.path,
|
|
2674
2674
|
parent: n
|
|
2675
2675
|
});
|
|
2676
|
-
return a.status === "aborted" ? y : a.status === "dirty" ? (s.dirty(),
|
|
2676
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (s.dirty(), ne(a.value)) : this._def.out._parseAsync({
|
|
2677
2677
|
data: a.value,
|
|
2678
2678
|
path: n.path,
|
|
2679
2679
|
parent: n
|
|
@@ -2696,23 +2696,23 @@ class xe extends v {
|
|
|
2696
2696
|
}
|
|
2697
2697
|
}
|
|
2698
2698
|
static create(e, s) {
|
|
2699
|
-
return new
|
|
2699
|
+
return new we({
|
|
2700
2700
|
in: e,
|
|
2701
2701
|
out: s,
|
|
2702
2702
|
typeName: m.ZodPipeline
|
|
2703
2703
|
});
|
|
2704
2704
|
}
|
|
2705
2705
|
}
|
|
2706
|
-
class
|
|
2706
|
+
class ve extends v {
|
|
2707
2707
|
_parse(e) {
|
|
2708
|
-
const s = this._def.innerType._parse(e), n = (r) => (
|
|
2709
|
-
return
|
|
2708
|
+
const s = this._def.innerType._parse(e), n = (r) => (Y(r) && (r.value = Object.freeze(r.value)), r);
|
|
2709
|
+
return ce(s) ? s.then((r) => n(r)) : n(s);
|
|
2710
2710
|
}
|
|
2711
2711
|
unwrap() {
|
|
2712
2712
|
return this._def.innerType;
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
|
-
|
|
2715
|
+
ve.create = (t, e) => new ve({
|
|
2716
2716
|
innerType: t,
|
|
2717
2717
|
typeName: m.ZodReadonly,
|
|
2718
2718
|
..._(e)
|
|
@@ -2721,81 +2721,81 @@ var m;
|
|
|
2721
2721
|
(function(t) {
|
|
2722
2722
|
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2723
2723
|
})(m || (m = {}));
|
|
2724
|
-
const g =
|
|
2725
|
-
|
|
2726
|
-
const
|
|
2727
|
-
de.create;
|
|
2724
|
+
const g = P.create, it = K.create, ke = ye.create;
|
|
2725
|
+
W.create;
|
|
2726
|
+
const R = L.create, M = T.create;
|
|
2728
2727
|
ue.create;
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2728
|
+
le.create;
|
|
2729
|
+
J.create;
|
|
2730
|
+
const ot = he.create;
|
|
2731
|
+
X.create;
|
|
2732
|
+
fe.create;
|
|
2733
|
+
z.create;
|
|
2734
|
+
ee.create;
|
|
2735
2735
|
const Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2736
2736
|
__proto__: null,
|
|
2737
|
-
DIRTY:
|
|
2737
|
+
DIRTY: ne,
|
|
2738
2738
|
INVALID: y,
|
|
2739
|
-
OK:
|
|
2740
|
-
ParseStatus:
|
|
2739
|
+
OK: I,
|
|
2740
|
+
ParseStatus: A,
|
|
2741
2741
|
Schema: v,
|
|
2742
|
-
ZodAny:
|
|
2743
|
-
ZodArray:
|
|
2744
|
-
ZodBigInt:
|
|
2745
|
-
ZodBoolean:
|
|
2742
|
+
ZodAny: Me,
|
|
2743
|
+
ZodArray: L,
|
|
2744
|
+
ZodBigInt: re,
|
|
2745
|
+
ZodBoolean: ye,
|
|
2746
2746
|
ZodBranded: at,
|
|
2747
|
-
ZodCatch:
|
|
2748
|
-
ZodDate:
|
|
2749
|
-
ZodDefault:
|
|
2750
|
-
ZodEffects:
|
|
2751
|
-
ZodEnum:
|
|
2752
|
-
ZodError:
|
|
2747
|
+
ZodCatch: _e,
|
|
2748
|
+
ZodDate: de,
|
|
2749
|
+
ZodDefault: ge,
|
|
2750
|
+
ZodEffects: G,
|
|
2751
|
+
ZodEnum: X,
|
|
2752
|
+
ZodError: U,
|
|
2753
2753
|
get ZodFirstPartyTypeKind() {
|
|
2754
2754
|
return m;
|
|
2755
2755
|
},
|
|
2756
|
-
ZodIntersection:
|
|
2757
|
-
ZodIssueCode:
|
|
2756
|
+
ZodIntersection: le,
|
|
2757
|
+
ZodIssueCode: u,
|
|
2758
2758
|
ZodLazy: Ve,
|
|
2759
|
-
ZodLiteral:
|
|
2760
|
-
ZodMap:
|
|
2761
|
-
ZodNaN:
|
|
2759
|
+
ZodLiteral: qe,
|
|
2760
|
+
ZodMap: Fe,
|
|
2761
|
+
ZodNaN: We,
|
|
2762
2762
|
ZodNativeEnum: ze,
|
|
2763
|
-
ZodNever:
|
|
2764
|
-
ZodNull:
|
|
2765
|
-
ZodNullable:
|
|
2766
|
-
ZodNumber:
|
|
2767
|
-
ZodObject:
|
|
2768
|
-
ZodOptional:
|
|
2763
|
+
ZodNever: W,
|
|
2764
|
+
ZodNull: Le,
|
|
2765
|
+
ZodNullable: ee,
|
|
2766
|
+
ZodNumber: K,
|
|
2767
|
+
ZodObject: T,
|
|
2768
|
+
ZodOptional: z,
|
|
2769
2769
|
ZodParsedType: h,
|
|
2770
|
-
ZodPipeline:
|
|
2771
|
-
ZodPromise:
|
|
2772
|
-
ZodReadonly:
|
|
2773
|
-
ZodRecord:
|
|
2770
|
+
ZodPipeline: we,
|
|
2771
|
+
ZodPromise: fe,
|
|
2772
|
+
ZodReadonly: ve,
|
|
2773
|
+
ZodRecord: he,
|
|
2774
2774
|
ZodSchema: v,
|
|
2775
|
-
ZodSet:
|
|
2776
|
-
ZodString:
|
|
2777
|
-
ZodSymbol:
|
|
2778
|
-
ZodTransformer:
|
|
2779
|
-
ZodTuple:
|
|
2775
|
+
ZodSet: ae,
|
|
2776
|
+
ZodString: P,
|
|
2777
|
+
ZodSymbol: De,
|
|
2778
|
+
ZodTransformer: G,
|
|
2779
|
+
ZodTuple: J,
|
|
2780
2780
|
ZodType: v,
|
|
2781
|
-
ZodUndefined:
|
|
2782
|
-
ZodUnion:
|
|
2781
|
+
ZodUndefined: Ze,
|
|
2782
|
+
ZodUnion: ue,
|
|
2783
2783
|
ZodUnknown: Pe,
|
|
2784
|
-
ZodVoid:
|
|
2784
|
+
ZodVoid: Ue,
|
|
2785
2785
|
addIssueToContext: l,
|
|
2786
|
-
array:
|
|
2786
|
+
array: R,
|
|
2787
2787
|
boolean: ke,
|
|
2788
2788
|
datetimeRegex: nt,
|
|
2789
|
-
defaultErrorMap:
|
|
2789
|
+
defaultErrorMap: me,
|
|
2790
2790
|
getErrorMap: Xe,
|
|
2791
|
-
getParsedType:
|
|
2792
|
-
isAborted:
|
|
2793
|
-
isAsync:
|
|
2791
|
+
getParsedType: q,
|
|
2792
|
+
isAborted: Ie,
|
|
2793
|
+
isAsync: ce,
|
|
2794
2794
|
isDirty: je,
|
|
2795
|
-
isValid:
|
|
2795
|
+
isValid: Y,
|
|
2796
2796
|
makeIssue: et,
|
|
2797
2797
|
number: it,
|
|
2798
|
-
object:
|
|
2798
|
+
object: M,
|
|
2799
2799
|
get objectUtil() {
|
|
2800
2800
|
return Re;
|
|
2801
2801
|
},
|
|
@@ -2806,7 +2806,7 @@ const Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
2808
|
gt(Ut);
|
|
2809
|
-
const Bt = (t, e) => e.skipDedupe || e.method !== "GET",
|
|
2809
|
+
const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ft = (t, e) => e.method + "@" + t, Vt = (t) => t.clone(), qt = ({ skip: t = Bt, key: e = Ft, resolver: s = Vt } = {}) => {
|
|
2810
2810
|
const n = /* @__PURE__ */ new Map();
|
|
2811
2811
|
return (r) => (a, i) => {
|
|
2812
2812
|
if (t(a, i))
|
|
@@ -2815,63 +2815,63 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Vt = (t, e) => e.method
|
|
|
2815
2815
|
if (!n.has(o))
|
|
2816
2816
|
n.set(o, []);
|
|
2817
2817
|
else
|
|
2818
|
-
return new Promise((c,
|
|
2819
|
-
n.get(o).push([c,
|
|
2818
|
+
return new Promise((c, d) => {
|
|
2819
|
+
n.get(o).push([c, d]);
|
|
2820
2820
|
});
|
|
2821
2821
|
try {
|
|
2822
|
-
return r(a, i).then((c) => (n.get(o).forEach(([
|
|
2823
|
-
throw n.get(o).forEach(([,
|
|
2822
|
+
return r(a, i).then((c) => (n.get(o).forEach(([d]) => d(s(c))), n.delete(o), c)).catch((c) => {
|
|
2823
|
+
throw n.get(o).forEach(([, d]) => d(c)), n.delete(o), c;
|
|
2824
2824
|
});
|
|
2825
2825
|
} catch (c) {
|
|
2826
2826
|
return n.delete(o), Promise.reject(c);
|
|
2827
2827
|
}
|
|
2828
2828
|
};
|
|
2829
|
-
},
|
|
2830
|
-
let
|
|
2831
|
-
if (o && o(
|
|
2832
|
-
return c(
|
|
2833
|
-
const C = (S,
|
|
2834
|
-
const
|
|
2829
|
+
}, zt = (t, e) => t * e, Wt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Ht = ({ delayTimer: t = 500, delayRamp: e = zt, maxAttempts: s = 10, until: n = Wt, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (d, f) => {
|
|
2830
|
+
let w = 0;
|
|
2831
|
+
if (o && o(d, f))
|
|
2832
|
+
return c(d, f);
|
|
2833
|
+
const C = (S, O) => Promise.resolve(n(S, O)).then((F) => F ? S && i ? S : O ? Promise.reject(O) : S : (w++, !s || w <= s ? new Promise((x) => {
|
|
2834
|
+
const D = e(t, w);
|
|
2835
2835
|
setTimeout(() => {
|
|
2836
2836
|
typeof r == "function" ? Promise.resolve(r({
|
|
2837
2837
|
response: S,
|
|
2838
|
-
error:
|
|
2839
|
-
url:
|
|
2840
|
-
attempt:
|
|
2841
|
-
options:
|
|
2842
|
-
})).then((
|
|
2843
|
-
var
|
|
2844
|
-
x(c((
|
|
2845
|
-
}) : x(c(
|
|
2846
|
-
},
|
|
2838
|
+
error: O,
|
|
2839
|
+
url: d,
|
|
2840
|
+
attempt: w,
|
|
2841
|
+
options: f
|
|
2842
|
+
})).then(($ = {}) => {
|
|
2843
|
+
var k, E;
|
|
2844
|
+
x(c((k = $ && $.url) !== null && k !== void 0 ? k : d, (E = $ && $.options) !== null && E !== void 0 ? E : f));
|
|
2845
|
+
}) : x(c(d, f));
|
|
2846
|
+
}, D);
|
|
2847
2847
|
}).then(C).catch((x) => {
|
|
2848
2848
|
if (!a)
|
|
2849
2849
|
throw x;
|
|
2850
2850
|
return C(null, x);
|
|
2851
|
-
}) : S && i ? S : Promise.reject(
|
|
2852
|
-
return c(
|
|
2851
|
+
}) : S && i ? S : Promise.reject(O || new Error("Number of attempts exceeded."))));
|
|
2852
|
+
return c(d, f).then(C).catch((S) => {
|
|
2853
2853
|
if (!a)
|
|
2854
2854
|
throw S;
|
|
2855
2855
|
return C(null, S);
|
|
2856
2856
|
});
|
|
2857
|
-
},
|
|
2857
|
+
}, be = M({
|
|
2858
2858
|
code: it(),
|
|
2859
2859
|
message: g()
|
|
2860
|
-
}), Jt =
|
|
2860
|
+
}), Jt = M({
|
|
2861
2861
|
message: g()
|
|
2862
|
-
}),
|
|
2863
|
-
emails:
|
|
2862
|
+
}), Gt = M({
|
|
2863
|
+
emails: R(g()).optional(),
|
|
2864
2864
|
http_body: g().optional(),
|
|
2865
2865
|
http_url: g().optional(),
|
|
2866
2866
|
txt_name: g().optional(),
|
|
2867
2867
|
txt_value: g().optional()
|
|
2868
|
-
}),
|
|
2869
|
-
ciphers:
|
|
2868
|
+
}), Qt = M({
|
|
2869
|
+
ciphers: R(g()).optional(),
|
|
2870
2870
|
early_hints: g().optional(),
|
|
2871
2871
|
http2: g().optional(),
|
|
2872
2872
|
min_tls_version: g().optional(),
|
|
2873
2873
|
tls_1_3: g().optional()
|
|
2874
|
-
}), Yt =
|
|
2874
|
+
}), Yt = M({
|
|
2875
2875
|
id: g(),
|
|
2876
2876
|
bundle_method: g().optional(),
|
|
2877
2877
|
certificate_authority: g(),
|
|
@@ -2879,25 +2879,25 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Vt = (t, e) => e.method
|
|
|
2879
2879
|
custom_csr_id: g().optional(),
|
|
2880
2880
|
custom_key: g().optional(),
|
|
2881
2881
|
expires_on: g().optional(),
|
|
2882
|
-
hosts:
|
|
2882
|
+
hosts: R(g()).optional(),
|
|
2883
2883
|
issuer: g().optional(),
|
|
2884
2884
|
method: g(),
|
|
2885
2885
|
serial_number: g().optional(),
|
|
2886
|
-
settings:
|
|
2886
|
+
settings: Qt.optional(),
|
|
2887
2887
|
signature: g().optional(),
|
|
2888
2888
|
type: g(),
|
|
2889
2889
|
uploaded_on: g().optional(),
|
|
2890
|
-
validation_errors:
|
|
2891
|
-
validation_records:
|
|
2890
|
+
validation_errors: R(Jt).optional(),
|
|
2891
|
+
validation_records: R(Gt).optional(),
|
|
2892
2892
|
wildcard: ke()
|
|
2893
|
-
}), Kt =
|
|
2893
|
+
}), Kt = M({
|
|
2894
2894
|
name: g(),
|
|
2895
2895
|
type: g(),
|
|
2896
2896
|
value: g()
|
|
2897
|
-
}), Xt =
|
|
2897
|
+
}), Xt = M({
|
|
2898
2898
|
http_body: g().optional(),
|
|
2899
2899
|
http_url: g().optional()
|
|
2900
|
-
}), ct =
|
|
2900
|
+
}), ct = M({
|
|
2901
2901
|
id: g(),
|
|
2902
2902
|
ssl: Yt,
|
|
2903
2903
|
hostname: g(),
|
|
@@ -2907,35 +2907,35 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Vt = (t, e) => e.method
|
|
|
2907
2907
|
ownership_verification: Kt.optional(),
|
|
2908
2908
|
ownership_verification_http: Xt.optional(),
|
|
2909
2909
|
status: g(),
|
|
2910
|
-
verification_errors:
|
|
2910
|
+
verification_errors: R(g()).optional(),
|
|
2911
2911
|
created_at: g()
|
|
2912
|
-
}),
|
|
2913
|
-
errors:
|
|
2914
|
-
messages:
|
|
2912
|
+
}), oe = M({
|
|
2913
|
+
errors: R(be),
|
|
2914
|
+
messages: R(be),
|
|
2915
2915
|
success: ke(),
|
|
2916
2916
|
result: ct
|
|
2917
2917
|
});
|
|
2918
|
-
|
|
2919
|
-
errors:
|
|
2920
|
-
messages:
|
|
2918
|
+
M({
|
|
2919
|
+
errors: R(be),
|
|
2920
|
+
messages: R(be),
|
|
2921
2921
|
success: ke(),
|
|
2922
|
-
result:
|
|
2922
|
+
result: R(ct)
|
|
2923
2923
|
});
|
|
2924
|
-
function
|
|
2924
|
+
function Q(t) {
|
|
2925
2925
|
return pt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({
|
|
2926
2926
|
"X-Auth-Email": t.authEmail,
|
|
2927
2927
|
"X-Auth-Key": t.authKey,
|
|
2928
2928
|
"Content-Type": "application/json"
|
|
2929
|
-
}).middlewares([Ht(),
|
|
2929
|
+
}).middlewares([Ht(), qt()]);
|
|
2930
2930
|
}
|
|
2931
|
-
function
|
|
2931
|
+
function Ge(t) {
|
|
2932
2932
|
const e = {}, s = {};
|
|
2933
2933
|
if (!t) return { sslOverrides: e, rest: s };
|
|
2934
2934
|
for (const [n, r] of Object.entries(t))
|
|
2935
2935
|
n.startsWith("ssl.") ? e[n.slice(4)] = r : s[n] = r;
|
|
2936
2936
|
return { sslOverrides: e, rest: s };
|
|
2937
2937
|
}
|
|
2938
|
-
function
|
|
2938
|
+
function Ne(t) {
|
|
2939
2939
|
const e = [];
|
|
2940
2940
|
if (t.ssl.validation_records)
|
|
2941
2941
|
for (const n of t.ssl.validation_records)
|
|
@@ -2972,7 +2972,7 @@ function Ae(t) {
|
|
|
2972
2972
|
status: t.status === "active" ? "ready" : "pending",
|
|
2973
2973
|
type: "auth0_managed_certs",
|
|
2974
2974
|
verification: {
|
|
2975
|
-
methods:
|
|
2975
|
+
methods: R(ft).parse(e)
|
|
2976
2976
|
},
|
|
2977
2977
|
domain_metadata: s
|
|
2978
2978
|
};
|
|
@@ -2980,10 +2980,10 @@ function Ae(t) {
|
|
|
2980
2980
|
function es(t) {
|
|
2981
2981
|
return {
|
|
2982
2982
|
create: async (e, s) => {
|
|
2983
|
-
const { sslOverrides: n, rest: r } =
|
|
2983
|
+
const { sslOverrides: n, rest: r } = Ge(
|
|
2984
2984
|
s.domain_metadata
|
|
2985
|
-
), { result: a, errors: i, success: o } =
|
|
2986
|
-
await
|
|
2985
|
+
), { result: a, errors: i, success: o } = oe.parse(
|
|
2986
|
+
await Q(t).post(
|
|
2987
2987
|
{
|
|
2988
2988
|
hostname: s.domain,
|
|
2989
2989
|
ssl: {
|
|
@@ -3000,7 +3000,7 @@ function es(t) {
|
|
|
3000
3000
|
);
|
|
3001
3001
|
if (!o)
|
|
3002
3002
|
throw new Error(JSON.stringify(i));
|
|
3003
|
-
const c =
|
|
3003
|
+
const c = Ne({
|
|
3004
3004
|
...a,
|
|
3005
3005
|
primary: !1,
|
|
3006
3006
|
domain_metadata: r
|
|
@@ -3018,15 +3018,15 @@ function es(t) {
|
|
|
3018
3018
|
s
|
|
3019
3019
|
);
|
|
3020
3020
|
if (!n)
|
|
3021
|
-
throw new
|
|
3022
|
-
const r = await
|
|
3021
|
+
throw new te(404);
|
|
3022
|
+
const r = await Q(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(), { result: a, errors: i, success: o } = oe.parse(r);
|
|
3023
3023
|
if (!o)
|
|
3024
|
-
throw new
|
|
3024
|
+
throw new te(503, {
|
|
3025
3025
|
message: JSON.stringify(i)
|
|
3026
3026
|
});
|
|
3027
3027
|
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3028
|
-
throw new
|
|
3029
|
-
return
|
|
3028
|
+
throw new te(404);
|
|
3029
|
+
return Ne({ ...n, ...a });
|
|
3030
3030
|
},
|
|
3031
3031
|
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3032
3032
|
list: async (e) => {
|
|
@@ -3034,10 +3034,10 @@ function es(t) {
|
|
|
3034
3034
|
return (await Promise.all(
|
|
3035
3035
|
s.map(async (r) => {
|
|
3036
3036
|
try {
|
|
3037
|
-
const a = await
|
|
3037
|
+
const a = await Q(t).get(
|
|
3038
3038
|
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
3039
|
-
).json(), { result: i, success: o } =
|
|
3040
|
-
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null :
|
|
3039
|
+
).json(), { result: i, success: o } = oe.parse(a);
|
|
3040
|
+
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ne({
|
|
3041
3041
|
...r,
|
|
3042
3042
|
...i
|
|
3043
3043
|
});
|
|
@@ -3049,23 +3049,23 @@ function es(t) {
|
|
|
3049
3049
|
},
|
|
3050
3050
|
remove: async (e, s) => {
|
|
3051
3051
|
if (t.enterprise) {
|
|
3052
|
-
const { result: r, success: a } =
|
|
3053
|
-
await
|
|
3052
|
+
const { result: r, success: a } = oe.parse(
|
|
3053
|
+
await Q(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json()
|
|
3054
3054
|
);
|
|
3055
3055
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3056
|
-
throw new
|
|
3056
|
+
throw new te(404);
|
|
3057
3057
|
}
|
|
3058
|
-
const n = await
|
|
3058
|
+
const n = await Q(t).delete(`/custom_hostnames/${encodeURIComponent(s)}`).res();
|
|
3059
3059
|
return n.ok && await t.customDomainAdapter.remove(e, s), n.ok;
|
|
3060
3060
|
},
|
|
3061
3061
|
update: async (e, s, n) => {
|
|
3062
|
-
const { sslOverrides: r } =
|
|
3062
|
+
const { sslOverrides: r } = Ge(
|
|
3063
3063
|
n.domain_metadata
|
|
3064
3064
|
), a = {};
|
|
3065
3065
|
if (Object.keys(r).length > 0) {
|
|
3066
|
-
const i = await
|
|
3066
|
+
const i = await Q(t).get(`/custom_hostnames/${encodeURIComponent(s)}`).json(), { result: o, success: c } = oe.parse(i);
|
|
3067
3067
|
if (!c)
|
|
3068
|
-
throw new
|
|
3068
|
+
throw new te(503, {
|
|
3069
3069
|
message: "Failed to fetch current custom hostname state"
|
|
3070
3070
|
});
|
|
3071
3071
|
a.ssl = {
|
|
@@ -3076,12 +3076,12 @@ function es(t) {
|
|
|
3076
3076
|
};
|
|
3077
3077
|
}
|
|
3078
3078
|
if (Object.keys(a).length > 0) {
|
|
3079
|
-
const i = await
|
|
3079
|
+
const i = await Q(t).patch(
|
|
3080
3080
|
a,
|
|
3081
3081
|
`/custom_hostnames/${encodeURIComponent(s)}`
|
|
3082
3082
|
).res();
|
|
3083
3083
|
if (!i.ok)
|
|
3084
|
-
throw new
|
|
3084
|
+
throw new te(503, {
|
|
3085
3085
|
message: await i.text()
|
|
3086
3086
|
});
|
|
3087
3087
|
}
|
|
@@ -3139,14 +3139,14 @@ class ts {
|
|
|
3139
3139
|
value: s,
|
|
3140
3140
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3141
3141
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3142
|
-
},
|
|
3142
|
+
}, d = this.createRequest(e), f = {
|
|
3143
3143
|
"Content-Type": "application/json"
|
|
3144
3144
|
};
|
|
3145
|
-
i && o > 0 && (
|
|
3146
|
-
const
|
|
3147
|
-
headers:
|
|
3145
|
+
i && o > 0 && (f["Cache-Control"] = `max-age=${o}`);
|
|
3146
|
+
const w = new Response(JSON.stringify(c), {
|
|
3147
|
+
headers: f
|
|
3148
3148
|
});
|
|
3149
|
-
await r.put(
|
|
3149
|
+
await r.put(d, w);
|
|
3150
3150
|
} catch (r) {
|
|
3151
3151
|
console.error(`CloudflareCache: set error for key ${e}:`, r);
|
|
3152
3152
|
}
|
|
@@ -3187,7 +3187,7 @@ let ns = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", dt
|
|
|
3187
3187
|
e += ns[s[t] & 63];
|
|
3188
3188
|
return e;
|
|
3189
3189
|
};
|
|
3190
|
-
async function
|
|
3190
|
+
async function He(t, e) {
|
|
3191
3191
|
const s = t.timeout || 3e4, n = new AbortController(), r = setTimeout(() => n.abort(), s);
|
|
3192
3192
|
try {
|
|
3193
3193
|
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
@@ -3214,10 +3214,10 @@ async function We(t, e) {
|
|
|
3214
3214
|
clearTimeout(r);
|
|
3215
3215
|
}
|
|
3216
3216
|
}
|
|
3217
|
-
function
|
|
3217
|
+
function xe(t) {
|
|
3218
3218
|
return `'${t.replace(/'/g, "''")}'`;
|
|
3219
3219
|
}
|
|
3220
|
-
function
|
|
3220
|
+
function H(t) {
|
|
3221
3221
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3222
3222
|
}
|
|
3223
3223
|
function ut(t) {
|
|
@@ -3336,11 +3336,11 @@ async function as(t, e, s) {
|
|
|
3336
3336
|
function is(t) {
|
|
3337
3337
|
return async (e, s) => {
|
|
3338
3338
|
const n = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3339
|
-
SELECT * FROM ${
|
|
3340
|
-
WHERE tenant_id = ${
|
|
3341
|
-
AND id = ${
|
|
3339
|
+
SELECT * FROM ${H(n)}.${H(r)}
|
|
3340
|
+
WHERE tenant_id = ${xe(e)}
|
|
3341
|
+
AND id = ${xe(s)}
|
|
3342
3342
|
LIMIT 1
|
|
3343
|
-
`, i = await
|
|
3343
|
+
`, i = await He(t, a);
|
|
3344
3344
|
if (i.length === 0)
|
|
3345
3345
|
return null;
|
|
3346
3346
|
const o = i[0];
|
|
@@ -3359,52 +3359,52 @@ function cs(t) {
|
|
|
3359
3359
|
for (const [s, n] of Object.entries(t)) {
|
|
3360
3360
|
const r = s.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3361
3361
|
r && n && e.push(
|
|
3362
|
-
`${
|
|
3362
|
+
`${H(r)} = ${xe(n)}`
|
|
3363
3363
|
);
|
|
3364
3364
|
}
|
|
3365
3365
|
return e;
|
|
3366
3366
|
}
|
|
3367
3367
|
function ds(t) {
|
|
3368
3368
|
return async (e, s = {}) => {
|
|
3369
|
-
const { page: n = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = s, c = t.namespace || "default",
|
|
3370
|
-
`tenant_id = ${
|
|
3369
|
+
const { page: n = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = s, c = t.namespace || "default", d = t.tableName || "logs", f = [
|
|
3370
|
+
`tenant_id = ${xe(e)}`
|
|
3371
3371
|
];
|
|
3372
3372
|
if (o) {
|
|
3373
|
-
const
|
|
3374
|
-
|
|
3373
|
+
const Z = os(o);
|
|
3374
|
+
f.push(...cs(Z));
|
|
3375
3375
|
}
|
|
3376
|
-
const
|
|
3376
|
+
const w = f.join(" AND ");
|
|
3377
3377
|
let C = "ORDER BY date DESC";
|
|
3378
3378
|
if (i && i.sort_by) {
|
|
3379
|
-
const
|
|
3380
|
-
C = `ORDER BY ${
|
|
3379
|
+
const Z = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), V = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3380
|
+
C = `ORDER BY ${H(Z)} ${V}`;
|
|
3381
3381
|
}
|
|
3382
|
-
const S = n * r,
|
|
3383
|
-
SELECT * FROM ${
|
|
3384
|
-
WHERE ${
|
|
3382
|
+
const S = n * r, O = `LIMIT ${r} OFFSET ${S}`, F = `
|
|
3383
|
+
SELECT * FROM ${H(c)}.${H(d)}
|
|
3384
|
+
WHERE ${w}
|
|
3385
3385
|
${C}
|
|
3386
|
-
${
|
|
3387
|
-
`,
|
|
3386
|
+
${O}
|
|
3387
|
+
`, D = (await He(t, F)).map(ut);
|
|
3388
3388
|
if (!a)
|
|
3389
3389
|
return {
|
|
3390
|
-
logs:
|
|
3390
|
+
logs: D,
|
|
3391
3391
|
start: 0,
|
|
3392
3392
|
limit: 0,
|
|
3393
3393
|
length: 0
|
|
3394
3394
|
};
|
|
3395
|
-
const
|
|
3396
|
-
SELECT COUNT(*) as count FROM ${
|
|
3397
|
-
WHERE ${
|
|
3398
|
-
`,
|
|
3395
|
+
const $ = `
|
|
3396
|
+
SELECT COUNT(*) as count FROM ${H(c)}.${H(d)}
|
|
3397
|
+
WHERE ${w}
|
|
3398
|
+
`, E = (await He(t, $))[0]?.count || 0;
|
|
3399
3399
|
return {
|
|
3400
|
-
logs:
|
|
3400
|
+
logs: D,
|
|
3401
3401
|
start: S,
|
|
3402
3402
|
limit: r,
|
|
3403
|
-
length: Number(
|
|
3403
|
+
length: Number(E)
|
|
3404
3404
|
};
|
|
3405
3405
|
};
|
|
3406
3406
|
}
|
|
3407
|
-
function
|
|
3407
|
+
function Us() {
|
|
3408
3408
|
return {
|
|
3409
3409
|
async getDaily() {
|
|
3410
3410
|
throw new Error(
|
|
@@ -3436,7 +3436,7 @@ function us(t) {
|
|
|
3436
3436
|
get: is(t)
|
|
3437
3437
|
};
|
|
3438
3438
|
}
|
|
3439
|
-
async function
|
|
3439
|
+
async function pe(t, e) {
|
|
3440
3440
|
const s = t.timeout || 3e4, n = new AbortController(), r = setTimeout(() => n.abort(), s);
|
|
3441
3441
|
try {
|
|
3442
3442
|
const a = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(a, {
|
|
@@ -3464,10 +3464,10 @@ async function fe(t, e) {
|
|
|
3464
3464
|
clearTimeout(r);
|
|
3465
3465
|
}
|
|
3466
3466
|
}
|
|
3467
|
-
function
|
|
3467
|
+
function N(t) {
|
|
3468
3468
|
return `'${t.replace(/'/g, "''").replace(/\\/g, "\\\\")}'`;
|
|
3469
3469
|
}
|
|
3470
|
-
function
|
|
3470
|
+
function j(t) {
|
|
3471
3471
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3472
3472
|
}
|
|
3473
3473
|
function lt(t) {
|
|
@@ -3579,11 +3579,11 @@ function fs(t) {
|
|
|
3579
3579
|
return async (e, s) => {
|
|
3580
3580
|
const n = t.dataset || "authhero_logs", r = `
|
|
3581
3581
|
SELECT *
|
|
3582
|
-
FROM ${
|
|
3583
|
-
WHERE index1 = ${
|
|
3584
|
-
AND blob1 = ${
|
|
3582
|
+
FROM ${j(n)}
|
|
3583
|
+
WHERE index1 = ${N(e)}
|
|
3584
|
+
AND blob1 = ${N(s)}
|
|
3585
3585
|
LIMIT 1
|
|
3586
|
-
`, a = await
|
|
3586
|
+
`, a = await pe(t, r);
|
|
3587
3587
|
return a.length === 0 || !a[0] ? null : lt(a[0]);
|
|
3588
3588
|
};
|
|
3589
3589
|
}
|
|
@@ -3632,9 +3632,9 @@ function ms(t) {
|
|
|
3632
3632
|
const a = ht(s);
|
|
3633
3633
|
if (a)
|
|
3634
3634
|
if (r.length === 1)
|
|
3635
|
-
e.push(`${a} = ${
|
|
3635
|
+
e.push(`${a} = ${N(r[0])}`);
|
|
3636
3636
|
else {
|
|
3637
|
-
const i = r.map((o) =>
|
|
3637
|
+
const i = r.map((o) => N(o)).join(", ");
|
|
3638
3638
|
e.push(`${a} IN (${i})`);
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
@@ -3648,24 +3648,24 @@ function ys(t) {
|
|
|
3648
3648
|
}
|
|
3649
3649
|
function gs(t) {
|
|
3650
3650
|
return async (e, s = {}) => {
|
|
3651
|
-
const { page: n = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = s, c = t.dataset || "authhero_logs",
|
|
3651
|
+
const { page: n = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = s, c = t.dataset || "authhero_logs", d = [`index1 = ${N(e)}`];
|
|
3652
3652
|
if (o) {
|
|
3653
|
-
const
|
|
3654
|
-
|
|
3653
|
+
const $ = ps(o);
|
|
3654
|
+
d.push(...ms($));
|
|
3655
3655
|
}
|
|
3656
|
-
const
|
|
3657
|
-
let
|
|
3656
|
+
const f = d.join(" AND ");
|
|
3657
|
+
let w = "ORDER BY timestamp DESC";
|
|
3658
3658
|
if (i && i.sort_by) {
|
|
3659
|
-
const
|
|
3660
|
-
|
|
3659
|
+
const $ = ys(i.sort_by), k = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3660
|
+
w = `ORDER BY ${$} ${k}`;
|
|
3661
3661
|
}
|
|
3662
|
-
const C = n * r, S = `LIMIT ${r} OFFSET ${C}`,
|
|
3662
|
+
const C = n * r, S = `LIMIT ${r} OFFSET ${C}`, O = `
|
|
3663
3663
|
SELECT *
|
|
3664
|
-
FROM ${
|
|
3665
|
-
WHERE ${
|
|
3666
|
-
${
|
|
3664
|
+
FROM ${j(c)}
|
|
3665
|
+
WHERE ${f}
|
|
3666
|
+
${w}
|
|
3667
3667
|
${S}
|
|
3668
|
-
`, x = (await
|
|
3668
|
+
`, x = (await pe(t, O)).map(lt);
|
|
3669
3669
|
if (!a)
|
|
3670
3670
|
return {
|
|
3671
3671
|
logs: x,
|
|
@@ -3673,18 +3673,18 @@ function gs(t) {
|
|
|
3673
3673
|
limit: 0,
|
|
3674
3674
|
length: 0
|
|
3675
3675
|
};
|
|
3676
|
-
const
|
|
3676
|
+
const D = `
|
|
3677
3677
|
SELECT count() as count
|
|
3678
|
-
FROM ${
|
|
3679
|
-
WHERE ${
|
|
3678
|
+
FROM ${j(c)}
|
|
3679
|
+
WHERE ${f}
|
|
3680
3680
|
`;
|
|
3681
3681
|
try {
|
|
3682
|
-
const
|
|
3682
|
+
const k = (await pe(t, D))[0]?.count || 0;
|
|
3683
3683
|
return {
|
|
3684
3684
|
logs: x,
|
|
3685
3685
|
start: C,
|
|
3686
3686
|
limit: r,
|
|
3687
|
-
length: Number(
|
|
3687
|
+
length: Number(k)
|
|
3688
3688
|
};
|
|
3689
3689
|
} catch {
|
|
3690
3690
|
return {
|
|
@@ -3696,37 +3696,24 @@ function gs(t) {
|
|
|
3696
3696
|
}
|
|
3697
3697
|
};
|
|
3698
3698
|
}
|
|
3699
|
-
const
|
|
3700
|
-
"s",
|
|
3701
|
-
// SUCCESS_LOGIN
|
|
3702
|
-
"seacft",
|
|
3703
|
-
// SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN
|
|
3704
|
-
"seccft",
|
|
3705
|
-
// SUCCESS_EXCHANGE_CLIENT_CREDENTIALS_FOR_ACCESS_TOKEN
|
|
3706
|
-
"sepft",
|
|
3707
|
-
// SUCCESS_EXCHANGE_PASSWORD_FOR_ACCESS_TOKEN
|
|
3708
|
-
"sertft",
|
|
3709
|
-
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3710
|
-
"ssa"
|
|
3711
|
-
// SUCCESS_SILENT_AUTH
|
|
3712
|
-
], _s = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
3699
|
+
const Qe = ["s"], _s = ["pwd_leak"];
|
|
3713
3700
|
function Ye(t) {
|
|
3714
3701
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3715
3702
|
}
|
|
3716
3703
|
function Ke(t) {
|
|
3717
3704
|
return t.toISOString().split("T")[0];
|
|
3718
3705
|
}
|
|
3719
|
-
function
|
|
3706
|
+
function Bs(t) {
|
|
3720
3707
|
const e = t.dataset || "authhero_logs";
|
|
3721
3708
|
return {
|
|
3722
3709
|
async getDaily(s, n = {}) {
|
|
3723
3710
|
const { from: r, to: a } = n, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3724
3711
|
o.setDate(o.getDate() - 30);
|
|
3725
|
-
const c = r ? Ye(r) : Ke(o),
|
|
3712
|
+
const c = r ? Ye(r) : Ke(o), d = a ? Ye(a) : Ke(i), f = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), w = (/* @__PURE__ */ new Date(`${d}T23:59:59.999Z`)).getTime(), C = Qe.map((x) => N(x)).join(
|
|
3726
3713
|
", "
|
|
3727
3714
|
), S = _s.map(
|
|
3728
|
-
(x) =>
|
|
3729
|
-
).join(", "),
|
|
3715
|
+
(x) => N(x)
|
|
3716
|
+
).join(", "), O = `
|
|
3730
3717
|
SELECT
|
|
3731
3718
|
toDate(toDateTime(double2 / 1000)) AS date,
|
|
3732
3719
|
SUM(CASE WHEN blob3 IN (${C}) THEN 1 ELSE 0 END) AS logins,
|
|
@@ -3735,13 +3722,13 @@ function $s(t) {
|
|
|
3735
3722
|
MIN(double2) AS first_event,
|
|
3736
3723
|
MAX(double2) AS last_event
|
|
3737
3724
|
FROM "${e}"
|
|
3738
|
-
WHERE index1 = ${
|
|
3739
|
-
AND double2 >= ${
|
|
3740
|
-
AND double2 <= ${
|
|
3725
|
+
WHERE index1 = ${N(s)}
|
|
3726
|
+
AND double2 >= ${f}
|
|
3727
|
+
AND double2 <= ${w}
|
|
3741
3728
|
GROUP BY date
|
|
3742
3729
|
ORDER BY date ASC
|
|
3743
3730
|
`;
|
|
3744
|
-
return (await
|
|
3731
|
+
return (await pe(t, O)).map((x) => ({
|
|
3745
3732
|
date: String(x.date),
|
|
3746
3733
|
logins: Number(x.logins) || 0,
|
|
3747
3734
|
signups: Number(x.signups) || 0,
|
|
@@ -3753,22 +3740,159 @@ function $s(t) {
|
|
|
3753
3740
|
async getActiveUsers(s) {
|
|
3754
3741
|
const n = /* @__PURE__ */ new Date();
|
|
3755
3742
|
n.setDate(n.getDate() - 30);
|
|
3756
|
-
const r = n.getTime(), a =
|
|
3743
|
+
const r = n.getTime(), a = Qe.map((d) => N(d)).join(
|
|
3757
3744
|
", "
|
|
3758
3745
|
), i = `
|
|
3759
3746
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3760
3747
|
FROM "${e}"
|
|
3761
|
-
WHERE index1 = ${
|
|
3748
|
+
WHERE index1 = ${N(s)}
|
|
3762
3749
|
AND double2 >= ${r}
|
|
3763
3750
|
AND blob3 IN (${a})
|
|
3764
3751
|
AND blob7 IS NOT NULL
|
|
3765
3752
|
AND blob7 != ''
|
|
3766
|
-
`, c = (await
|
|
3753
|
+
`, c = (await pe(t, i))[0];
|
|
3767
3754
|
return c && c.count !== void 0 && Number(c.count) || 0;
|
|
3768
3755
|
}
|
|
3769
3756
|
};
|
|
3770
3757
|
}
|
|
3771
|
-
|
|
3758
|
+
const vs = {
|
|
3759
|
+
"active-users": ["s", "seacft"],
|
|
3760
|
+
logins: ["s", "f", "fp"],
|
|
3761
|
+
signups: ["ss", "fs"],
|
|
3762
|
+
"refresh-tokens": ["seacft", "fertft"],
|
|
3763
|
+
// No dedicated session-created event yet; track logouts as the lifecycle signal.
|
|
3764
|
+
sessions: ["slo"]
|
|
3765
|
+
}, bs = {
|
|
3766
|
+
connection: "blob9",
|
|
3767
|
+
client_id: "blob11",
|
|
3768
|
+
user_type: "blob16",
|
|
3769
|
+
// strategy_type
|
|
3770
|
+
event: "blob3"
|
|
3771
|
+
}, xs = {
|
|
3772
|
+
connection: "blob9",
|
|
3773
|
+
client_id: "blob11",
|
|
3774
|
+
user_type: "blob16",
|
|
3775
|
+
user_id: "blob7"
|
|
3776
|
+
}, ws = {
|
|
3777
|
+
"active-users": {
|
|
3778
|
+
expr: "uniqExact(blob7)",
|
|
3779
|
+
alias: "active_users",
|
|
3780
|
+
type: "UInt64"
|
|
3781
|
+
},
|
|
3782
|
+
logins: { expr: "count()", alias: "logins", type: "UInt64" },
|
|
3783
|
+
signups: { expr: "count()", alias: "signups", type: "UInt64" },
|
|
3784
|
+
"refresh-tokens": {
|
|
3785
|
+
expr: "count()",
|
|
3786
|
+
alias: "refresh_tokens",
|
|
3787
|
+
type: "UInt64"
|
|
3788
|
+
},
|
|
3789
|
+
sessions: { expr: "count()", alias: "sessions", type: "UInt64" }
|
|
3790
|
+
};
|
|
3791
|
+
function ks(t, e) {
|
|
3792
|
+
const s = `, ${N(e)}`, n = "toDateTime(double2 / 1000)";
|
|
3793
|
+
switch (t) {
|
|
3794
|
+
case "hour":
|
|
3795
|
+
return `toStartOfHour(${n}${s})`;
|
|
3796
|
+
case "week":
|
|
3797
|
+
return `toStartOfWeek(${n}${s})`;
|
|
3798
|
+
case "month":
|
|
3799
|
+
return `toStartOfMonth(${n}${s})`;
|
|
3800
|
+
default:
|
|
3801
|
+
return `toStartOfDay(${n}${s})`;
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
function Ss(t) {
|
|
3805
|
+
return t === "hour" ? "DateTime" : "Date";
|
|
3806
|
+
}
|
|
3807
|
+
function Cs(t, e, s) {
|
|
3808
|
+
const n = new Date(t.from).getTime(), r = new Date(t.to).getTime(), a = s.map((o) => N(o)).join(", "), i = [
|
|
3809
|
+
`index1 = ${N(e)}`,
|
|
3810
|
+
`double2 >= ${n}`,
|
|
3811
|
+
`double2 < ${r}`,
|
|
3812
|
+
`blob3 IN (${a})`
|
|
3813
|
+
];
|
|
3814
|
+
for (const [o, c] of Object.entries(xs)) {
|
|
3815
|
+
const d = t.filters[o];
|
|
3816
|
+
if (d && d.length > 0) {
|
|
3817
|
+
const f = d.map((w) => N(w)).join(", ");
|
|
3818
|
+
i.push(`${c} IN (${f})`);
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
return i.join(" AND ");
|
|
3822
|
+
}
|
|
3823
|
+
function Ts(t, e, s) {
|
|
3824
|
+
if (t.order_by) {
|
|
3825
|
+
const n = t.order_by.startsWith("-"), r = n ? t.order_by.slice(1) : t.order_by;
|
|
3826
|
+
return `${j(r)} ${n ? "DESC" : "ASC"}`;
|
|
3827
|
+
}
|
|
3828
|
+
return e.length > 0 ? e[0] === "time" ? `${j("time")} ASC` : `${j(s)} DESC` : `${j(s)} DESC`;
|
|
3829
|
+
}
|
|
3830
|
+
function Es(t) {
|
|
3831
|
+
const e = t.dataset || "authhero_logs";
|
|
3832
|
+
return {
|
|
3833
|
+
async query(s, n, r) {
|
|
3834
|
+
const a = vs[n], i = ws[n], o = [], c = [];
|
|
3835
|
+
for (const k of r.group_by)
|
|
3836
|
+
if (k === "time") {
|
|
3837
|
+
const E = ks(r.interval, r.tz);
|
|
3838
|
+
o.push(`${E} AS ${j("time")}`), c.push({ name: "time", type: Ss(r.interval) });
|
|
3839
|
+
} else {
|
|
3840
|
+
const E = bs[k];
|
|
3841
|
+
o.push(`${E} AS ${j(k)}`), c.push({ name: k, type: "String" });
|
|
3842
|
+
}
|
|
3843
|
+
c.push({ name: i.alias, type: i.type });
|
|
3844
|
+
const d = [
|
|
3845
|
+
...o,
|
|
3846
|
+
`${i.expr} AS ${j(i.alias)}`
|
|
3847
|
+
], f = r.group_by.length ? `GROUP BY ${r.group_by.map((k) => j(k === "time" ? "time" : k)).join(", ")}` : "", w = r.group_by.map(
|
|
3848
|
+
(k) => k === "time" ? "time" : k
|
|
3849
|
+
), C = Ts(r, w, i.alias), S = `
|
|
3850
|
+
SELECT ${d.join(", ")}
|
|
3851
|
+
FROM ${j(e)}
|
|
3852
|
+
WHERE ${Cs(r, s, a)}
|
|
3853
|
+
${f}
|
|
3854
|
+
ORDER BY ${C}
|
|
3855
|
+
LIMIT ${Math.max(0, r.limit)} OFFSET ${Math.max(0, r.offset)}
|
|
3856
|
+
FORMAT JSON
|
|
3857
|
+
`, O = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, F = t.timeout || 3e4, x = new AbortController(), D = setTimeout(() => x.abort(), F), $ = Date.now();
|
|
3858
|
+
try {
|
|
3859
|
+
const k = await fetch(O, {
|
|
3860
|
+
method: "POST",
|
|
3861
|
+
headers: {
|
|
3862
|
+
"Content-Type": "text/plain",
|
|
3863
|
+
Authorization: `Bearer ${t.apiToken}`
|
|
3864
|
+
},
|
|
3865
|
+
body: S,
|
|
3866
|
+
signal: x.signal
|
|
3867
|
+
});
|
|
3868
|
+
if (!k.ok) {
|
|
3869
|
+
const V = await k.text();
|
|
3870
|
+
throw new Error(
|
|
3871
|
+
`Analytics Engine query failed: ${k.status} ${k.statusText} - ${V}`
|
|
3872
|
+
);
|
|
3873
|
+
}
|
|
3874
|
+
const E = await k.json();
|
|
3875
|
+
if (E.success === !1 && E.errors?.length)
|
|
3876
|
+
throw new Error(
|
|
3877
|
+
`Analytics Engine error: ${E.errors.map((V) => V.message).join(", ")}`
|
|
3878
|
+
);
|
|
3879
|
+
const Z = E.data ?? [];
|
|
3880
|
+
return {
|
|
3881
|
+
meta: E.meta ?? c,
|
|
3882
|
+
data: Z,
|
|
3883
|
+
rows: E.rows ?? Z.length,
|
|
3884
|
+
rows_before_limit_at_least: E.rows_before_limit_at_least ?? Z.length,
|
|
3885
|
+
statistics: {
|
|
3886
|
+
elapsed: (Date.now() - $) / 1e3
|
|
3887
|
+
}
|
|
3888
|
+
};
|
|
3889
|
+
} finally {
|
|
3890
|
+
clearTimeout(D);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
};
|
|
3894
|
+
}
|
|
3895
|
+
function Os(t) {
|
|
3772
3896
|
return t.analyticsEngineBinding || console.warn(
|
|
3773
3897
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3774
3898
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
@@ -3779,7 +3903,7 @@ function vs(t) {
|
|
|
3779
3903
|
get: fs(t)
|
|
3780
3904
|
};
|
|
3781
3905
|
}
|
|
3782
|
-
function
|
|
3906
|
+
function $s() {
|
|
3783
3907
|
return {
|
|
3784
3908
|
async getGeoInfo(t) {
|
|
3785
3909
|
try {
|
|
@@ -3798,7 +3922,7 @@ function bs() {
|
|
|
3798
3922
|
}
|
|
3799
3923
|
};
|
|
3800
3924
|
}
|
|
3801
|
-
class
|
|
3925
|
+
class As {
|
|
3802
3926
|
constructor(e) {
|
|
3803
3927
|
this.bindings = e;
|
|
3804
3928
|
}
|
|
@@ -3818,13 +3942,13 @@ class xs {
|
|
|
3818
3942
|
}
|
|
3819
3943
|
}
|
|
3820
3944
|
}
|
|
3821
|
-
function
|
|
3945
|
+
function Ns(t) {
|
|
3822
3946
|
if (!(!t || !Object.keys(t).some(
|
|
3823
3947
|
(s) => t[s]
|
|
3824
3948
|
)))
|
|
3825
|
-
return new
|
|
3949
|
+
return new As(t);
|
|
3826
3950
|
}
|
|
3827
|
-
function
|
|
3951
|
+
function Rs(t) {
|
|
3828
3952
|
return `// Auto-generated AuthHero code hook worker
|
|
3829
3953
|
|
|
3830
3954
|
const fnNames = {
|
|
@@ -3930,7 +4054,7 @@ export default {
|
|
|
3930
4054
|
};
|
|
3931
4055
|
`;
|
|
3932
4056
|
}
|
|
3933
|
-
class
|
|
4057
|
+
class Is {
|
|
3934
4058
|
config;
|
|
3935
4059
|
constructor(e) {
|
|
3936
4060
|
this.config = e;
|
|
@@ -4005,7 +4129,7 @@ class Ss {
|
|
|
4005
4129
|
* Wraps the code in a worker template and uploads via Cloudflare API.
|
|
4006
4130
|
*/
|
|
4007
4131
|
async deploy(e, s) {
|
|
4008
|
-
const n = `hook-${e}`, r =
|
|
4132
|
+
const n = `hook-${e}`, r = Rs(s), a = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`, i = JSON.stringify({
|
|
4009
4133
|
main_module: "index.js",
|
|
4010
4134
|
compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
|
|
4011
4135
|
}), o = new FormData();
|
|
@@ -4025,9 +4149,9 @@ class Ss {
|
|
|
4025
4149
|
body: o
|
|
4026
4150
|
});
|
|
4027
4151
|
if (!c.ok) {
|
|
4028
|
-
const
|
|
4152
|
+
const d = await c.text();
|
|
4029
4153
|
throw new Error(
|
|
4030
|
-
`Failed to deploy hook worker ${n}: ${c.status} ${
|
|
4154
|
+
`Failed to deploy hook worker ${n}: ${c.status} ${d}`
|
|
4031
4155
|
);
|
|
4032
4156
|
}
|
|
4033
4157
|
}
|
|
@@ -4049,12 +4173,12 @@ class Ss {
|
|
|
4049
4173
|
}
|
|
4050
4174
|
}
|
|
4051
4175
|
}
|
|
4052
|
-
const
|
|
4176
|
+
const Fs = Is, js = {
|
|
4053
4177
|
"post-user-login": "onExecutePostLogin",
|
|
4054
4178
|
"credentials-exchange": "onExecuteCredentialsExchange",
|
|
4055
4179
|
"pre-user-registration": "onExecutePreUserRegistration",
|
|
4056
4180
|
"post-user-registration": "onExecutePostUserRegistration"
|
|
4057
|
-
},
|
|
4181
|
+
}, Ds = {
|
|
4058
4182
|
"post-user-login": {
|
|
4059
4183
|
accessToken: ["setCustomClaim"],
|
|
4060
4184
|
idToken: ["setCustomClaim"],
|
|
@@ -4073,17 +4197,17 @@ const js = Ss, Cs = {
|
|
|
4073
4197
|
},
|
|
4074
4198
|
"post-user-registration": {}
|
|
4075
4199
|
};
|
|
4076
|
-
async function
|
|
4200
|
+
async function Zs(t) {
|
|
4077
4201
|
const e = new TextEncoder().encode(t), s = await crypto.subtle.digest("SHA-256", e), n = new Uint8Array(s);
|
|
4078
4202
|
let r = "";
|
|
4079
4203
|
for (const a of n)
|
|
4080
4204
|
r += a.toString(16).padStart(2, "0");
|
|
4081
4205
|
return r;
|
|
4082
4206
|
}
|
|
4083
|
-
function
|
|
4207
|
+
function Ls(t) {
|
|
4084
4208
|
return `
|
|
4085
|
-
const TRIGGER_FN_NAMES = ${JSON.stringify(
|
|
4086
|
-
const API_SHAPES = ${JSON.stringify(
|
|
4209
|
+
const TRIGGER_FN_NAMES = ${JSON.stringify(js)};
|
|
4210
|
+
const API_SHAPES = ${JSON.stringify(Ds)};
|
|
4087
4211
|
const MAX_LOG_ENTRIES = 50;
|
|
4088
4212
|
const MAX_LOG_LENGTH = 500;
|
|
4089
4213
|
|
|
@@ -4183,7 +4307,7 @@ export default {
|
|
|
4183
4307
|
};
|
|
4184
4308
|
`;
|
|
4185
4309
|
}
|
|
4186
|
-
class
|
|
4310
|
+
class Vs {
|
|
4187
4311
|
loader;
|
|
4188
4312
|
compatibilityDate;
|
|
4189
4313
|
constructor(e) {
|
|
@@ -4192,11 +4316,11 @@ class Is {
|
|
|
4192
4316
|
async execute(e) {
|
|
4193
4317
|
const s = Date.now();
|
|
4194
4318
|
try {
|
|
4195
|
-
const n =
|
|
4319
|
+
const n = Ls(e.code), r = {
|
|
4196
4320
|
compatibilityDate: this.compatibilityDate,
|
|
4197
4321
|
mainModule: "hook.js",
|
|
4198
4322
|
modules: { "hook.js": n }
|
|
4199
|
-
}, a = e.hookCodeId ? `${e.hookCodeId}-${await
|
|
4323
|
+
}, a = e.hookCodeId ? `${e.hookCodeId}-${await Zs(e.code)}` : null;
|
|
4200
4324
|
return await (await (a ? this.loader.get(a, async () => r) : this.loader.load(r)).getEntrypoint().fetch(
|
|
4201
4325
|
new Request("https://hook/execute", {
|
|
4202
4326
|
method: "POST",
|
|
@@ -4217,7 +4341,7 @@ class Is {
|
|
|
4217
4341
|
}
|
|
4218
4342
|
}
|
|
4219
4343
|
}
|
|
4220
|
-
function
|
|
4344
|
+
function qs(t) {
|
|
4221
4345
|
const e = {
|
|
4222
4346
|
customDomains: es(t),
|
|
4223
4347
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
@@ -4230,23 +4354,26 @@ function Ds(t) {
|
|
|
4230
4354
|
}),
|
|
4231
4355
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
4232
4356
|
// passed at request time via getGeoInfo(headers)
|
|
4233
|
-
geo:
|
|
4357
|
+
geo: $s()
|
|
4234
4358
|
};
|
|
4235
|
-
t.r2SqlLogs ? e.logs = us(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs =
|
|
4359
|
+
t.r2SqlLogs ? e.logs = us(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = Os(
|
|
4360
|
+
t.analyticsEngineLogs
|
|
4361
|
+
)), t.analyticsEngineLogs && (e.analytics = Es(
|
|
4236
4362
|
t.analyticsEngineLogs
|
|
4237
4363
|
));
|
|
4238
|
-
const s =
|
|
4364
|
+
const s = Ns(t.rateLimitBindings);
|
|
4239
4365
|
return s && (e.rateLimit = s), e;
|
|
4240
4366
|
}
|
|
4241
4367
|
export {
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4368
|
+
Fs as CloudflareCodeExecutor,
|
|
4369
|
+
Is as DispatchNamespaceCodeExecutor,
|
|
4370
|
+
Vs as WorkerLoaderCodeExecutor,
|
|
4371
|
+
Es as createAnalyticsEngineAnalyticsAdapter,
|
|
4372
|
+
Os as createAnalyticsEngineLogsAdapter,
|
|
4373
|
+
Bs as createAnalyticsEngineStatsAdapter,
|
|
4374
|
+
Ns as createCloudflareRateLimitAdapter,
|
|
4248
4375
|
us as createR2SQLLogsAdapter,
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4376
|
+
Us as createR2SQLStatsAdapter,
|
|
4377
|
+
qs as default,
|
|
4378
|
+
Rs as generateWorkerScript
|
|
4252
4379
|
};
|