@authhero/cloudflare-adapter 2.19.3 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare-adapter.cjs +4 -4
- package/dist/cloudflare-adapter.d.ts +104 -42
- package/dist/cloudflare-adapter.mjs +574 -564
- package/package.json +3 -3
|
@@ -4,61 +4,61 @@ function mt(t, e) {
|
|
|
4
4
|
var n = {};
|
|
5
5
|
for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
|
|
6
6
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
7
|
-
for (var
|
|
8
|
-
e.indexOf(s[
|
|
7
|
+
for (var r = 0, s = Object.getOwnPropertySymbols(t); r < s.length; r++)
|
|
8
|
+
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[r]) && (n[s[r]] = t[s[r]]);
|
|
9
9
|
return n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function _t(t, e) {
|
|
12
12
|
var n;
|
|
13
13
|
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function ae(t, e) {
|
|
16
16
|
const n = t.ZodType.prototype[e];
|
|
17
17
|
t.ZodType.prototype[e] = function(...s) {
|
|
18
|
-
const
|
|
19
|
-
return
|
|
18
|
+
const r = n.apply(this, s);
|
|
19
|
+
return r._def.openapi = this._def.openapi, r;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function yt(t) {
|
|
23
23
|
if (typeof t.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
|
-
t.ZodType.prototype.openapi = function(
|
|
25
|
+
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
26
|
var i, o, c, u, p, k;
|
|
27
|
-
const T = typeof
|
|
27
|
+
const T = typeof r == "string" ? a : r, S = T ?? {}, { param: E } = S, q = 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), L = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), q), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || E ? {
|
|
28
28
|
param: Object.assign(Object.assign({}, (k = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || k === void 0 ? void 0 : k.param), E)
|
|
29
29
|
} : void 0), O = 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(L).length > 0 ? { metadata: L } : void 0) }));
|
|
30
|
-
if (
|
|
30
|
+
if (_t(this, "ZodObject")) {
|
|
31
31
|
const j = this.extend;
|
|
32
32
|
O.extend = function(...W) {
|
|
33
|
-
var Q,
|
|
33
|
+
var Q, re, we, Se, Te, Ce, Ee;
|
|
34
34
|
const Oe = j.apply(this, W);
|
|
35
35
|
return Oe._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((re = (Q = this._def.openapi) === null || Q === void 0 ? void 0 : Q._internal) === null || re === void 0) && re.refId ? { refId: (Se = (we = this._def.openapi) === null || we === void 0 ? void 0 : we._internal) === null || Se === void 0 ? void 0 : Se.refId, schema: this } : (Ce = (Te = this._def.openapi) === null || Te === void 0 ? void 0 : Te._internal) === null || Ce === void 0 ? void 0 : Ce.extendedFrom
|
|
38
38
|
},
|
|
39
39
|
metadata: (Ee = Oe._def.openapi) === null || Ee === void 0 ? void 0 : Ee.metadata
|
|
40
40
|
}, Oe;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
return O;
|
|
44
|
-
},
|
|
44
|
+
}, ae(t, "optional"), ae(t, "nullable"), ae(t, "default"), ae(t, "transform"), ae(t, "refine");
|
|
45
45
|
const e = t.ZodObject.prototype.deepPartial;
|
|
46
46
|
t.ZodObject.prototype.deepPartial = function() {
|
|
47
|
-
const
|
|
47
|
+
const r = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
48
48
|
return Object.entries(i).forEach(([o, c]) => {
|
|
49
49
|
var u, p;
|
|
50
|
-
c._def.openapi = (p = (u =
|
|
51
|
-
}),
|
|
50
|
+
c._def.openapi = (p = (u = r[o]) === null || u === void 0 ? void 0 : u._def) === null || p === void 0 ? void 0 : p.openapi;
|
|
51
|
+
}), a._def.openapi = void 0, a;
|
|
52
52
|
};
|
|
53
53
|
const n = t.ZodObject.prototype.pick;
|
|
54
|
-
t.ZodObject.prototype.pick = function(...
|
|
55
|
-
const
|
|
56
|
-
return
|
|
54
|
+
t.ZodObject.prototype.pick = function(...r) {
|
|
55
|
+
const a = n.apply(this, r);
|
|
56
|
+
return a._def.openapi = void 0, a;
|
|
57
57
|
};
|
|
58
58
|
const s = t.ZodObject.prototype.omit;
|
|
59
|
-
t.ZodObject.prototype.omit = function(...
|
|
60
|
-
const
|
|
61
|
-
return
|
|
59
|
+
t.ZodObject.prototype.omit = function(...r) {
|
|
60
|
+
const a = s.apply(this, r);
|
|
61
|
+
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
var X = class extends Error {
|
|
@@ -89,40 +89,40 @@ var X = class extends Error {
|
|
|
89
89
|
new Set(".\\+*[^]$()");
|
|
90
90
|
var b;
|
|
91
91
|
(function(t) {
|
|
92
|
-
t.assertEqual = (
|
|
92
|
+
t.assertEqual = (r) => {
|
|
93
93
|
};
|
|
94
|
-
function e(
|
|
94
|
+
function e(r) {
|
|
95
95
|
}
|
|
96
96
|
t.assertIs = e;
|
|
97
|
-
function n(
|
|
97
|
+
function n(r) {
|
|
98
98
|
throw new Error();
|
|
99
99
|
}
|
|
100
|
-
t.assertNever = n, t.arrayToEnum = (
|
|
101
|
-
const
|
|
102
|
-
for (const i of
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
}, t.getValidEnumValues = (
|
|
106
|
-
const
|
|
107
|
-
for (const o of
|
|
108
|
-
i[o] =
|
|
100
|
+
t.assertNever = n, t.arrayToEnum = (r) => {
|
|
101
|
+
const a = {};
|
|
102
|
+
for (const i of r)
|
|
103
|
+
a[i] = i;
|
|
104
|
+
return a;
|
|
105
|
+
}, t.getValidEnumValues = (r) => {
|
|
106
|
+
const a = t.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
|
|
107
|
+
for (const o of a)
|
|
108
|
+
i[o] = r[o];
|
|
109
109
|
return t.objectValues(i);
|
|
110
|
-
}, t.objectValues = (
|
|
111
|
-
return a
|
|
112
|
-
}), t.objectKeys = typeof Object.keys == "function" ? (
|
|
113
|
-
const
|
|
114
|
-
for (const i in
|
|
115
|
-
Object.prototype.hasOwnProperty.call(
|
|
116
|
-
return
|
|
117
|
-
}, t.find = (
|
|
118
|
-
for (const i of
|
|
119
|
-
if (
|
|
110
|
+
}, t.objectValues = (r) => t.objectKeys(r).map(function(a) {
|
|
111
|
+
return r[a];
|
|
112
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
|
|
113
|
+
const a = [];
|
|
114
|
+
for (const i in r)
|
|
115
|
+
Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
|
|
116
|
+
return a;
|
|
117
|
+
}, t.find = (r, a) => {
|
|
118
|
+
for (const i of r)
|
|
119
|
+
if (a(i))
|
|
120
120
|
return i;
|
|
121
|
-
}, t.isInteger = typeof Number.isInteger == "function" ? (
|
|
122
|
-
function s(
|
|
123
|
-
return
|
|
121
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
|
|
122
|
+
function s(r, a = " | ") {
|
|
123
|
+
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
124
124
|
}
|
|
125
|
-
t.joinValues = s, t.jsonStringifyReplacer = (
|
|
125
|
+
t.joinValues = s, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
126
126
|
})(b || (b = {}));
|
|
127
127
|
var Re;
|
|
128
128
|
(function(t) {
|
|
@@ -206,16 +206,16 @@ class Z extends Error {
|
|
|
206
206
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
207
207
|
}
|
|
208
208
|
format(e) {
|
|
209
|
-
const n = e || function(
|
|
210
|
-
return
|
|
211
|
-
}, s = { _errors: [] },
|
|
212
|
-
for (const i of
|
|
209
|
+
const n = e || function(a) {
|
|
210
|
+
return a.message;
|
|
211
|
+
}, s = { _errors: [] }, r = (a) => {
|
|
212
|
+
for (const i of a.issues)
|
|
213
213
|
if (i.code === "invalid_union")
|
|
214
|
-
i.unionErrors.map(
|
|
214
|
+
i.unionErrors.map(r);
|
|
215
215
|
else if (i.code === "invalid_return_type")
|
|
216
|
-
|
|
216
|
+
r(i.returnTypeError);
|
|
217
217
|
else if (i.code === "invalid_arguments")
|
|
218
|
-
|
|
218
|
+
r(i.argumentsError);
|
|
219
219
|
else if (i.path.length === 0)
|
|
220
220
|
s._errors.push(n(i));
|
|
221
221
|
else {
|
|
@@ -226,7 +226,7 @@ class Z extends Error {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
return
|
|
229
|
+
return r(this), s;
|
|
230
230
|
}
|
|
231
231
|
static assert(e) {
|
|
232
232
|
if (!(e instanceof Z))
|
|
@@ -243,12 +243,12 @@ class Z extends Error {
|
|
|
243
243
|
}
|
|
244
244
|
flatten(e = (n) => n.message) {
|
|
245
245
|
const n = {}, s = [];
|
|
246
|
-
for (const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
n[
|
|
246
|
+
for (const r of this.issues)
|
|
247
|
+
if (r.path.length > 0) {
|
|
248
|
+
const a = r.path[0];
|
|
249
|
+
n[a] = n[a] || [], n[a].push(e(r));
|
|
250
250
|
} else
|
|
251
|
-
s.push(e(
|
|
251
|
+
s.push(e(r));
|
|
252
252
|
return { formErrors: s, fieldErrors: n };
|
|
253
253
|
}
|
|
254
254
|
get formErrors() {
|
|
@@ -317,23 +317,23 @@ function Xe() {
|
|
|
317
317
|
return gt;
|
|
318
318
|
}
|
|
319
319
|
const et = (t) => {
|
|
320
|
-
const { data: e, path: n, errorMaps: s, issueData:
|
|
321
|
-
...
|
|
322
|
-
path:
|
|
320
|
+
const { data: e, path: n, errorMaps: s, issueData: r } = t, a = [...n, ...r.path || []], i = {
|
|
321
|
+
...r,
|
|
322
|
+
path: a
|
|
323
323
|
};
|
|
324
|
-
if (
|
|
324
|
+
if (r.message !== void 0)
|
|
325
325
|
return {
|
|
326
|
-
...
|
|
327
|
-
path:
|
|
328
|
-
message:
|
|
326
|
+
...r,
|
|
327
|
+
path: a,
|
|
328
|
+
message: r.message
|
|
329
329
|
};
|
|
330
330
|
let o = "";
|
|
331
331
|
const c = s.filter((u) => !!u).slice().reverse();
|
|
332
332
|
for (const u of c)
|
|
333
333
|
o = u(i, { data: e, defaultError: o }).message;
|
|
334
334
|
return {
|
|
335
|
-
...
|
|
336
|
-
path:
|
|
335
|
+
...r,
|
|
336
|
+
path: a,
|
|
337
337
|
message: o
|
|
338
338
|
};
|
|
339
339
|
};
|
|
@@ -351,7 +351,7 @@ function l(t, e) {
|
|
|
351
351
|
// then global override map
|
|
352
352
|
n === pe ? void 0 : pe
|
|
353
353
|
// then global default map
|
|
354
|
-
].filter((
|
|
354
|
+
].filter((r) => !!r)
|
|
355
355
|
});
|
|
356
356
|
t.common.issues.push(s);
|
|
357
357
|
}
|
|
@@ -367,19 +367,19 @@ class C {
|
|
|
367
367
|
}
|
|
368
368
|
static mergeArray(e, n) {
|
|
369
369
|
const s = [];
|
|
370
|
-
for (const
|
|
371
|
-
if (
|
|
372
|
-
return
|
|
373
|
-
|
|
370
|
+
for (const r of n) {
|
|
371
|
+
if (r.status === "aborted")
|
|
372
|
+
return _;
|
|
373
|
+
r.status === "dirty" && e.dirty(), s.push(r.value);
|
|
374
374
|
}
|
|
375
375
|
return { status: e.value, value: s };
|
|
376
376
|
}
|
|
377
377
|
static async mergeObjectAsync(e, n) {
|
|
378
378
|
const s = [];
|
|
379
|
-
for (const
|
|
380
|
-
const
|
|
379
|
+
for (const r of n) {
|
|
380
|
+
const a = await r.key, i = await r.value;
|
|
381
381
|
s.push({
|
|
382
|
-
key:
|
|
382
|
+
key: a,
|
|
383
383
|
value: i
|
|
384
384
|
});
|
|
385
385
|
}
|
|
@@ -387,16 +387,16 @@ class C {
|
|
|
387
387
|
}
|
|
388
388
|
static mergeObjectSync(e, n) {
|
|
389
389
|
const s = {};
|
|
390
|
-
for (const
|
|
391
|
-
const { key:
|
|
392
|
-
if (
|
|
393
|
-
return
|
|
394
|
-
|
|
390
|
+
for (const r of n) {
|
|
391
|
+
const { key: a, value: i } = r;
|
|
392
|
+
if (a.status === "aborted" || i.status === "aborted")
|
|
393
|
+
return _;
|
|
394
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (s[a.value] = i.value);
|
|
395
395
|
}
|
|
396
396
|
return { status: e.value, value: s };
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
const
|
|
399
|
+
const _ = Object.freeze({
|
|
400
400
|
status: "aborted"
|
|
401
401
|
}), te = (t) => ({ status: "dirty", value: t }), N = (t) => ({ status: "valid", value: t }), $e = (t) => t.status === "aborted", je = (t) => t.status === "dirty", J = (t) => t.status === "valid", oe = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
402
402
|
var f;
|
|
@@ -404,8 +404,8 @@ var f;
|
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
405
|
})(f || (f = {}));
|
|
406
406
|
class D {
|
|
407
|
-
constructor(e, n, s,
|
|
408
|
-
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key =
|
|
407
|
+
constructor(e, n, s, r) {
|
|
408
|
+
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key = r;
|
|
409
409
|
}
|
|
410
410
|
get path() {
|
|
411
411
|
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
@@ -429,13 +429,13 @@ const He = (t, e) => {
|
|
|
429
429
|
function g(t) {
|
|
430
430
|
if (!t)
|
|
431
431
|
return {};
|
|
432
|
-
const { errorMap: e, invalid_type_error: n, required_error: s, description:
|
|
432
|
+
const { errorMap: e, invalid_type_error: n, required_error: s, description: r } = t;
|
|
433
433
|
if (e && (n || s))
|
|
434
434
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
435
|
-
return e ? { errorMap: e, description:
|
|
435
|
+
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
436
436
|
const { message: c } = t;
|
|
437
437
|
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? n ?? o.defaultError };
|
|
438
|
-
}, description:
|
|
438
|
+
}, description: r };
|
|
439
439
|
}
|
|
440
440
|
class v {
|
|
441
441
|
get description() {
|
|
@@ -495,8 +495,8 @@ class v {
|
|
|
495
495
|
parent: null,
|
|
496
496
|
data: e,
|
|
497
497
|
parsedType: P(e)
|
|
498
|
-
},
|
|
499
|
-
return He(s,
|
|
498
|
+
}, r = this._parseSync({ data: e, path: s.path, parent: s });
|
|
499
|
+
return He(s, r);
|
|
500
500
|
}
|
|
501
501
|
"~validate"(e) {
|
|
502
502
|
const n = {
|
|
@@ -548,21 +548,21 @@ class v {
|
|
|
548
548
|
parent: null,
|
|
549
549
|
data: e,
|
|
550
550
|
parsedType: P(e)
|
|
551
|
-
},
|
|
552
|
-
return He(s,
|
|
551
|
+
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (oe(r) ? r : Promise.resolve(r));
|
|
552
|
+
return He(s, a);
|
|
553
553
|
}
|
|
554
554
|
refine(e, n) {
|
|
555
|
-
const s = (
|
|
556
|
-
return this._refinement((
|
|
557
|
-
const i = e(
|
|
555
|
+
const s = (r) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(r) : n;
|
|
556
|
+
return this._refinement((r, a) => {
|
|
557
|
+
const i = e(r), o = () => a.addIssue({
|
|
558
558
|
code: d.custom,
|
|
559
|
-
...s(
|
|
559
|
+
...s(r)
|
|
560
560
|
});
|
|
561
561
|
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
564
|
refinement(e, n) {
|
|
565
|
-
return this._refinement((s,
|
|
565
|
+
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof n == "function" ? n(s, r) : n), !1));
|
|
566
566
|
}
|
|
567
567
|
_refinement(e) {
|
|
568
568
|
return new U({
|
|
@@ -612,7 +612,7 @@ class v {
|
|
|
612
612
|
}
|
|
613
613
|
default(e) {
|
|
614
614
|
const n = typeof e == "function" ? e : () => e;
|
|
615
|
-
return new
|
|
615
|
+
return new _e({
|
|
616
616
|
...g(this._def),
|
|
617
617
|
innerType: this,
|
|
618
618
|
defaultValue: n,
|
|
@@ -620,7 +620,7 @@ class v {
|
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
brand() {
|
|
623
|
-
return new
|
|
623
|
+
return new at({
|
|
624
624
|
typeName: m.ZodBranded,
|
|
625
625
|
type: this,
|
|
626
626
|
...g(this._def)
|
|
@@ -628,7 +628,7 @@ class v {
|
|
|
628
628
|
}
|
|
629
629
|
catch(e) {
|
|
630
630
|
const n = typeof e == "function" ? e : () => e;
|
|
631
|
-
return new
|
|
631
|
+
return new ye({
|
|
632
632
|
...g(this._def),
|
|
633
633
|
innerType: this,
|
|
634
634
|
catchValue: n,
|
|
@@ -682,8 +682,8 @@ function Lt(t, e) {
|
|
|
682
682
|
const [n] = t.split(".");
|
|
683
683
|
if (!n)
|
|
684
684
|
return !1;
|
|
685
|
-
const s = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.length % 4) % 4, "="),
|
|
686
|
-
return !(typeof
|
|
685
|
+
const s = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.length % 4) % 4, "="), r = JSON.parse(atob(s));
|
|
686
|
+
return !(typeof r != "object" || r === null || "typ" in r && r?.typ !== "JWT" || !r.alg || e && r.alg !== e);
|
|
687
687
|
} catch {
|
|
688
688
|
return !1;
|
|
689
689
|
}
|
|
@@ -694,160 +694,160 @@ function Pt(t, e) {
|
|
|
694
694
|
class I extends v {
|
|
695
695
|
_parse(e) {
|
|
696
696
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
697
|
-
const
|
|
698
|
-
return l(
|
|
697
|
+
const a = this._getOrReturnCtx(e);
|
|
698
|
+
return l(a, {
|
|
699
699
|
code: d.invalid_type,
|
|
700
700
|
expected: h.string,
|
|
701
|
-
received:
|
|
702
|
-
}),
|
|
701
|
+
received: a.parsedType
|
|
702
|
+
}), _;
|
|
703
703
|
}
|
|
704
704
|
const s = new C();
|
|
705
|
-
let
|
|
706
|
-
for (const
|
|
707
|
-
if (
|
|
708
|
-
e.data.length <
|
|
705
|
+
let r;
|
|
706
|
+
for (const a of this._def.checks)
|
|
707
|
+
if (a.kind === "min")
|
|
708
|
+
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
709
709
|
code: d.too_small,
|
|
710
|
-
minimum:
|
|
710
|
+
minimum: a.value,
|
|
711
711
|
type: "string",
|
|
712
712
|
inclusive: !0,
|
|
713
713
|
exact: !1,
|
|
714
|
-
message:
|
|
714
|
+
message: a.message
|
|
715
715
|
}), s.dirty());
|
|
716
|
-
else if (
|
|
717
|
-
e.data.length >
|
|
716
|
+
else if (a.kind === "max")
|
|
717
|
+
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
718
718
|
code: d.too_big,
|
|
719
|
-
maximum:
|
|
719
|
+
maximum: a.value,
|
|
720
720
|
type: "string",
|
|
721
721
|
inclusive: !0,
|
|
722
722
|
exact: !1,
|
|
723
|
-
message:
|
|
723
|
+
message: a.message
|
|
724
724
|
}), s.dirty());
|
|
725
|
-
else if (
|
|
726
|
-
const i = e.data.length >
|
|
727
|
-
(i || o) && (
|
|
725
|
+
else if (a.kind === "length") {
|
|
726
|
+
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
727
|
+
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
728
728
|
code: d.too_big,
|
|
729
|
-
maximum:
|
|
729
|
+
maximum: a.value,
|
|
730
730
|
type: "string",
|
|
731
731
|
inclusive: !0,
|
|
732
732
|
exact: !0,
|
|
733
|
-
message:
|
|
734
|
-
}) : o && l(
|
|
733
|
+
message: a.message
|
|
734
|
+
}) : o && l(r, {
|
|
735
735
|
code: d.too_small,
|
|
736
|
-
minimum:
|
|
736
|
+
minimum: a.value,
|
|
737
737
|
type: "string",
|
|
738
738
|
inclusive: !0,
|
|
739
739
|
exact: !0,
|
|
740
|
-
message:
|
|
740
|
+
message: a.message
|
|
741
741
|
}), s.dirty());
|
|
742
|
-
} else if (
|
|
743
|
-
Ct.test(e.data) || (
|
|
742
|
+
} else if (a.kind === "email")
|
|
743
|
+
Ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
744
744
|
validation: "email",
|
|
745
745
|
code: d.invalid_string,
|
|
746
|
-
message:
|
|
746
|
+
message: a.message
|
|
747
747
|
}), s.dirty());
|
|
748
|
-
else if (
|
|
749
|
-
Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (
|
|
748
|
+
else if (a.kind === "emoji")
|
|
749
|
+
Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
750
750
|
validation: "emoji",
|
|
751
751
|
code: d.invalid_string,
|
|
752
|
-
message:
|
|
752
|
+
message: a.message
|
|
753
753
|
}), s.dirty());
|
|
754
|
-
else if (
|
|
755
|
-
kt.test(e.data) || (
|
|
754
|
+
else if (a.kind === "uuid")
|
|
755
|
+
kt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
756
756
|
validation: "uuid",
|
|
757
757
|
code: d.invalid_string,
|
|
758
|
-
message:
|
|
758
|
+
message: a.message
|
|
759
759
|
}), s.dirty());
|
|
760
|
-
else if (
|
|
761
|
-
wt.test(e.data) || (
|
|
760
|
+
else if (a.kind === "nanoid")
|
|
761
|
+
wt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
762
762
|
validation: "nanoid",
|
|
763
763
|
code: d.invalid_string,
|
|
764
|
-
message:
|
|
764
|
+
message: a.message
|
|
765
765
|
}), s.dirty());
|
|
766
|
-
else if (
|
|
767
|
-
vt.test(e.data) || (
|
|
766
|
+
else if (a.kind === "cuid")
|
|
767
|
+
vt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
768
768
|
validation: "cuid",
|
|
769
769
|
code: d.invalid_string,
|
|
770
|
-
message:
|
|
770
|
+
message: a.message
|
|
771
771
|
}), s.dirty());
|
|
772
|
-
else if (
|
|
773
|
-
bt.test(e.data) || (
|
|
772
|
+
else if (a.kind === "cuid2")
|
|
773
|
+
bt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
774
774
|
validation: "cuid2",
|
|
775
775
|
code: d.invalid_string,
|
|
776
|
-
message:
|
|
776
|
+
message: a.message
|
|
777
777
|
}), s.dirty());
|
|
778
|
-
else if (
|
|
779
|
-
xt.test(e.data) || (
|
|
778
|
+
else if (a.kind === "ulid")
|
|
779
|
+
xt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
780
780
|
validation: "ulid",
|
|
781
781
|
code: d.invalid_string,
|
|
782
|
-
message:
|
|
782
|
+
message: a.message
|
|
783
783
|
}), s.dirty());
|
|
784
|
-
else if (
|
|
784
|
+
else if (a.kind === "url")
|
|
785
785
|
try {
|
|
786
786
|
new URL(e.data);
|
|
787
787
|
} catch {
|
|
788
|
-
|
|
788
|
+
r = this._getOrReturnCtx(e, r), l(r, {
|
|
789
789
|
validation: "url",
|
|
790
790
|
code: d.invalid_string,
|
|
791
|
-
message:
|
|
791
|
+
message: a.message
|
|
792
792
|
}), s.dirty();
|
|
793
793
|
}
|
|
794
|
-
else
|
|
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
796
|
code: d.invalid_string,
|
|
797
|
-
message:
|
|
798
|
-
}), s.dirty())) :
|
|
797
|
+
message: a.message
|
|
798
|
+
}), s.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
799
|
code: d.invalid_string,
|
|
800
|
-
validation: { includes:
|
|
801
|
-
message:
|
|
802
|
-
}), s.dirty()) :
|
|
800
|
+
validation: { includes: a.value, position: a.position },
|
|
801
|
+
message: a.message
|
|
802
|
+
}), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
803
803
|
code: d.invalid_string,
|
|
804
|
-
validation: { startsWith:
|
|
805
|
-
message:
|
|
806
|
-
}), s.dirty()) :
|
|
804
|
+
validation: { startsWith: a.value },
|
|
805
|
+
message: a.message
|
|
806
|
+
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
807
807
|
code: d.invalid_string,
|
|
808
|
-
validation: { endsWith:
|
|
809
|
-
message:
|
|
810
|
-
}), s.dirty()) :
|
|
808
|
+
validation: { endsWith: a.value },
|
|
809
|
+
message: a.message
|
|
810
|
+
}), s.dirty()) : a.kind === "datetime" ? st(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
811
811
|
code: d.invalid_string,
|
|
812
812
|
validation: "datetime",
|
|
813
|
-
message:
|
|
814
|
-
}), s.dirty()) :
|
|
813
|
+
message: a.message
|
|
814
|
+
}), s.dirty()) : a.kind === "date" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
815
815
|
code: d.invalid_string,
|
|
816
816
|
validation: "date",
|
|
817
|
-
message:
|
|
818
|
-
}), s.dirty()) :
|
|
817
|
+
message: a.message
|
|
818
|
+
}), s.dirty()) : a.kind === "time" ? Zt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
819
819
|
code: d.invalid_string,
|
|
820
820
|
validation: "time",
|
|
821
|
-
message:
|
|
822
|
-
}), s.dirty()) :
|
|
821
|
+
message: a.message
|
|
822
|
+
}), s.dirty()) : a.kind === "duration" ? Tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
823
823
|
validation: "duration",
|
|
824
824
|
code: d.invalid_string,
|
|
825
|
-
message:
|
|
826
|
-
}), s.dirty()) :
|
|
825
|
+
message: a.message
|
|
826
|
+
}), s.dirty()) : a.kind === "ip" ? Dt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
827
827
|
validation: "ip",
|
|
828
828
|
code: d.invalid_string,
|
|
829
|
-
message:
|
|
830
|
-
}), s.dirty()) :
|
|
829
|
+
message: a.message
|
|
830
|
+
}), s.dirty()) : a.kind === "jwt" ? Lt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
831
831
|
validation: "jwt",
|
|
832
832
|
code: d.invalid_string,
|
|
833
|
-
message:
|
|
834
|
-
}), s.dirty()) :
|
|
833
|
+
message: a.message
|
|
834
|
+
}), s.dirty()) : a.kind === "cidr" ? Pt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
835
835
|
validation: "cidr",
|
|
836
836
|
code: d.invalid_string,
|
|
837
|
-
message:
|
|
838
|
-
}), s.dirty()) :
|
|
837
|
+
message: a.message
|
|
838
|
+
}), s.dirty()) : a.kind === "base64" ? $t.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
839
839
|
validation: "base64",
|
|
840
840
|
code: d.invalid_string,
|
|
841
|
-
message:
|
|
842
|
-
}), s.dirty()) :
|
|
841
|
+
message: a.message
|
|
842
|
+
}), s.dirty()) : a.kind === "base64url" ? jt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
843
843
|
validation: "base64url",
|
|
844
844
|
code: d.invalid_string,
|
|
845
|
-
message:
|
|
846
|
-
}), s.dirty()) : b.assertNever(
|
|
845
|
+
message: a.message
|
|
846
|
+
}), s.dirty()) : b.assertNever(a);
|
|
847
847
|
return { status: s.value, value: e.data };
|
|
848
848
|
}
|
|
849
849
|
_regex(e, n, s) {
|
|
850
|
-
return this.refinement((
|
|
850
|
+
return this.refinement((r) => e.test(r), {
|
|
851
851
|
validation: n,
|
|
852
852
|
code: d.invalid_string,
|
|
853
853
|
...f.errToObj(s)
|
|
@@ -1075,8 +1075,8 @@ I.create = (t) => new I({
|
|
|
1075
1075
|
...g(t)
|
|
1076
1076
|
});
|
|
1077
1077
|
function Mt(t, e) {
|
|
1078
|
-
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length,
|
|
1079
|
-
return
|
|
1078
|
+
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = n > s ? n : s, a = Number.parseInt(t.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
1079
|
+
return a % i / 10 ** r;
|
|
1080
1080
|
}
|
|
1081
1081
|
class Y extends v {
|
|
1082
1082
|
constructor() {
|
|
@@ -1084,44 +1084,44 @@ class Y extends v {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
_parse(e) {
|
|
1086
1086
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1087
|
-
const
|
|
1088
|
-
return l(
|
|
1087
|
+
const a = this._getOrReturnCtx(e);
|
|
1088
|
+
return l(a, {
|
|
1089
1089
|
code: d.invalid_type,
|
|
1090
1090
|
expected: h.number,
|
|
1091
|
-
received:
|
|
1092
|
-
}),
|
|
1091
|
+
received: a.parsedType
|
|
1092
|
+
}), _;
|
|
1093
1093
|
}
|
|
1094
1094
|
let s;
|
|
1095
|
-
const
|
|
1096
|
-
for (const
|
|
1097
|
-
|
|
1095
|
+
const r = new C();
|
|
1096
|
+
for (const a of this._def.checks)
|
|
1097
|
+
a.kind === "int" ? b.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1098
1098
|
code: d.invalid_type,
|
|
1099
1099
|
expected: "integer",
|
|
1100
1100
|
received: "float",
|
|
1101
|
-
message:
|
|
1102
|
-
}),
|
|
1101
|
+
message: a.message
|
|
1102
|
+
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1103
1103
|
code: d.too_small,
|
|
1104
|
-
minimum:
|
|
1104
|
+
minimum: a.value,
|
|
1105
1105
|
type: "number",
|
|
1106
|
-
inclusive:
|
|
1106
|
+
inclusive: a.inclusive,
|
|
1107
1107
|
exact: !1,
|
|
1108
|
-
message:
|
|
1109
|
-
}),
|
|
1108
|
+
message: a.message
|
|
1109
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1110
1110
|
code: d.too_big,
|
|
1111
|
-
maximum:
|
|
1111
|
+
maximum: a.value,
|
|
1112
1112
|
type: "number",
|
|
1113
|
-
inclusive:
|
|
1113
|
+
inclusive: a.inclusive,
|
|
1114
1114
|
exact: !1,
|
|
1115
|
-
message:
|
|
1116
|
-
}),
|
|
1115
|
+
message: a.message
|
|
1116
|
+
}), r.dirty()) : a.kind === "multipleOf" ? Mt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1117
1117
|
code: d.not_multiple_of,
|
|
1118
|
-
multipleOf:
|
|
1119
|
-
message:
|
|
1120
|
-
}),
|
|
1118
|
+
multipleOf: a.value,
|
|
1119
|
+
message: a.message
|
|
1120
|
+
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1121
1121
|
code: d.not_finite,
|
|
1122
|
-
message:
|
|
1123
|
-
}),
|
|
1124
|
-
return { status:
|
|
1122
|
+
message: a.message
|
|
1123
|
+
}), r.dirty()) : b.assertNever(a);
|
|
1124
|
+
return { status: r.value, value: e.data };
|
|
1125
1125
|
}
|
|
1126
1126
|
gte(e, n) {
|
|
1127
1127
|
return this.setLimit("min", e, !0, f.toString(n));
|
|
@@ -1135,7 +1135,7 @@ class Y extends v {
|
|
|
1135
1135
|
lt(e, n) {
|
|
1136
1136
|
return this.setLimit("max", e, !1, f.toString(n));
|
|
1137
1137
|
}
|
|
1138
|
-
setLimit(e, n, s,
|
|
1138
|
+
setLimit(e, n, s, r) {
|
|
1139
1139
|
return new Y({
|
|
1140
1140
|
...this._def,
|
|
1141
1141
|
checks: [
|
|
@@ -1144,7 +1144,7 @@ class Y extends v {
|
|
|
1144
1144
|
kind: e,
|
|
1145
1145
|
value: n,
|
|
1146
1146
|
inclusive: s,
|
|
1147
|
-
message: f.toString(
|
|
1147
|
+
message: f.toString(r)
|
|
1148
1148
|
}
|
|
1149
1149
|
]
|
|
1150
1150
|
});
|
|
@@ -1264,26 +1264,26 @@ class ne extends v {
|
|
|
1264
1264
|
if (this._getType(e) !== h.bigint)
|
|
1265
1265
|
return this._getInvalidInput(e);
|
|
1266
1266
|
let s;
|
|
1267
|
-
const
|
|
1268
|
-
for (const
|
|
1269
|
-
|
|
1267
|
+
const r = new C();
|
|
1268
|
+
for (const a of this._def.checks)
|
|
1269
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1270
1270
|
code: d.too_small,
|
|
1271
1271
|
type: "bigint",
|
|
1272
|
-
minimum:
|
|
1273
|
-
inclusive:
|
|
1274
|
-
message:
|
|
1275
|
-
}),
|
|
1272
|
+
minimum: a.value,
|
|
1273
|
+
inclusive: a.inclusive,
|
|
1274
|
+
message: a.message
|
|
1275
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1276
1276
|
code: d.too_big,
|
|
1277
1277
|
type: "bigint",
|
|
1278
|
-
maximum:
|
|
1279
|
-
inclusive:
|
|
1280
|
-
message:
|
|
1281
|
-
}),
|
|
1278
|
+
maximum: a.value,
|
|
1279
|
+
inclusive: a.inclusive,
|
|
1280
|
+
message: a.message
|
|
1281
|
+
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1282
1282
|
code: d.not_multiple_of,
|
|
1283
|
-
multipleOf:
|
|
1284
|
-
message:
|
|
1285
|
-
}),
|
|
1286
|
-
return { status:
|
|
1283
|
+
multipleOf: a.value,
|
|
1284
|
+
message: a.message
|
|
1285
|
+
}), r.dirty()) : b.assertNever(a);
|
|
1286
|
+
return { status: r.value, value: e.data };
|
|
1287
1287
|
}
|
|
1288
1288
|
_getInvalidInput(e) {
|
|
1289
1289
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1291,7 +1291,7 @@ class ne extends v {
|
|
|
1291
1291
|
code: d.invalid_type,
|
|
1292
1292
|
expected: h.bigint,
|
|
1293
1293
|
received: n.parsedType
|
|
1294
|
-
}),
|
|
1294
|
+
}), _;
|
|
1295
1295
|
}
|
|
1296
1296
|
gte(e, n) {
|
|
1297
1297
|
return this.setLimit("min", e, !0, f.toString(n));
|
|
@@ -1305,7 +1305,7 @@ class ne extends v {
|
|
|
1305
1305
|
lt(e, n) {
|
|
1306
1306
|
return this.setLimit("max", e, !1, f.toString(n));
|
|
1307
1307
|
}
|
|
1308
|
-
setLimit(e, n, s,
|
|
1308
|
+
setLimit(e, n, s, r) {
|
|
1309
1309
|
return new ne({
|
|
1310
1310
|
...this._def,
|
|
1311
1311
|
checks: [
|
|
@@ -1314,7 +1314,7 @@ class ne extends v {
|
|
|
1314
1314
|
kind: e,
|
|
1315
1315
|
value: n,
|
|
1316
1316
|
inclusive: s,
|
|
1317
|
-
message: f.toString(
|
|
1317
|
+
message: f.toString(r)
|
|
1318
1318
|
}
|
|
1319
1319
|
]
|
|
1320
1320
|
});
|
|
@@ -1391,7 +1391,7 @@ class me extends v {
|
|
|
1391
1391
|
code: d.invalid_type,
|
|
1392
1392
|
expected: h.boolean,
|
|
1393
1393
|
received: s.parsedType
|
|
1394
|
-
}),
|
|
1394
|
+
}), _;
|
|
1395
1395
|
}
|
|
1396
1396
|
return N(e.data);
|
|
1397
1397
|
}
|
|
@@ -1404,37 +1404,37 @@ me.create = (t) => new me({
|
|
|
1404
1404
|
class ce extends v {
|
|
1405
1405
|
_parse(e) {
|
|
1406
1406
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1407
|
-
const
|
|
1408
|
-
return l(
|
|
1407
|
+
const a = this._getOrReturnCtx(e);
|
|
1408
|
+
return l(a, {
|
|
1409
1409
|
code: d.invalid_type,
|
|
1410
1410
|
expected: h.date,
|
|
1411
|
-
received:
|
|
1412
|
-
}),
|
|
1411
|
+
received: a.parsedType
|
|
1412
|
+
}), _;
|
|
1413
1413
|
}
|
|
1414
1414
|
if (Number.isNaN(e.data.getTime())) {
|
|
1415
|
-
const
|
|
1416
|
-
return l(
|
|
1415
|
+
const a = this._getOrReturnCtx(e);
|
|
1416
|
+
return l(a, {
|
|
1417
1417
|
code: d.invalid_date
|
|
1418
|
-
}),
|
|
1418
|
+
}), _;
|
|
1419
1419
|
}
|
|
1420
1420
|
const s = new C();
|
|
1421
|
-
let
|
|
1422
|
-
for (const
|
|
1423
|
-
|
|
1421
|
+
let r;
|
|
1422
|
+
for (const a of this._def.checks)
|
|
1423
|
+
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1424
1424
|
code: d.too_small,
|
|
1425
|
-
message:
|
|
1425
|
+
message: a.message,
|
|
1426
1426
|
inclusive: !0,
|
|
1427
1427
|
exact: !1,
|
|
1428
|
-
minimum:
|
|
1428
|
+
minimum: a.value,
|
|
1429
1429
|
type: "date"
|
|
1430
|
-
}), s.dirty()) :
|
|
1430
|
+
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1431
1431
|
code: d.too_big,
|
|
1432
|
-
message:
|
|
1432
|
+
message: a.message,
|
|
1433
1433
|
inclusive: !0,
|
|
1434
1434
|
exact: !1,
|
|
1435
|
-
maximum:
|
|
1435
|
+
maximum: a.value,
|
|
1436
1436
|
type: "date"
|
|
1437
|
-
}), s.dirty()) : b.assertNever(
|
|
1437
|
+
}), s.dirty()) : b.assertNever(a);
|
|
1438
1438
|
return {
|
|
1439
1439
|
status: s.value,
|
|
1440
1440
|
value: new Date(e.data.getTime())
|
|
@@ -1487,7 +1487,7 @@ class Ie extends v {
|
|
|
1487
1487
|
code: d.invalid_type,
|
|
1488
1488
|
expected: h.symbol,
|
|
1489
1489
|
received: s.parsedType
|
|
1490
|
-
}),
|
|
1490
|
+
}), _;
|
|
1491
1491
|
}
|
|
1492
1492
|
return N(e.data);
|
|
1493
1493
|
}
|
|
@@ -1504,7 +1504,7 @@ class Ze extends v {
|
|
|
1504
1504
|
code: d.invalid_type,
|
|
1505
1505
|
expected: h.undefined,
|
|
1506
1506
|
received: s.parsedType
|
|
1507
|
-
}),
|
|
1507
|
+
}), _;
|
|
1508
1508
|
}
|
|
1509
1509
|
return N(e.data);
|
|
1510
1510
|
}
|
|
@@ -1521,7 +1521,7 @@ class De extends v {
|
|
|
1521
1521
|
code: d.invalid_type,
|
|
1522
1522
|
expected: h.null,
|
|
1523
1523
|
received: s.parsedType
|
|
1524
|
-
}),
|
|
1524
|
+
}), _;
|
|
1525
1525
|
}
|
|
1526
1526
|
return N(e.data);
|
|
1527
1527
|
}
|
|
@@ -1561,7 +1561,7 @@ class B extends v {
|
|
|
1561
1561
|
code: d.invalid_type,
|
|
1562
1562
|
expected: h.never,
|
|
1563
1563
|
received: n.parsedType
|
|
1564
|
-
}),
|
|
1564
|
+
}), _;
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
1567
|
B.create = (t) => new B({
|
|
@@ -1576,7 +1576,7 @@ class Me extends v {
|
|
|
1576
1576
|
code: d.invalid_type,
|
|
1577
1577
|
expected: h.void,
|
|
1578
1578
|
received: s.parsedType
|
|
1579
|
-
}),
|
|
1579
|
+
}), _;
|
|
1580
1580
|
}
|
|
1581
1581
|
return N(e.data);
|
|
1582
1582
|
}
|
|
@@ -1587,43 +1587,43 @@ Me.create = (t) => new Me({
|
|
|
1587
1587
|
});
|
|
1588
1588
|
class R extends v {
|
|
1589
1589
|
_parse(e) {
|
|
1590
|
-
const { ctx: n, status: s } = this._processInputParams(e),
|
|
1590
|
+
const { ctx: n, status: s } = this._processInputParams(e), r = this._def;
|
|
1591
1591
|
if (n.parsedType !== h.array)
|
|
1592
1592
|
return l(n, {
|
|
1593
1593
|
code: d.invalid_type,
|
|
1594
1594
|
expected: h.array,
|
|
1595
1595
|
received: n.parsedType
|
|
1596
|
-
}),
|
|
1597
|
-
if (
|
|
1598
|
-
const i = n.data.length >
|
|
1596
|
+
}), _;
|
|
1597
|
+
if (r.exactLength !== null) {
|
|
1598
|
+
const i = n.data.length > r.exactLength.value, o = n.data.length < r.exactLength.value;
|
|
1599
1599
|
(i || o) && (l(n, {
|
|
1600
1600
|
code: i ? d.too_big : d.too_small,
|
|
1601
|
-
minimum: o ?
|
|
1602
|
-
maximum: i ?
|
|
1601
|
+
minimum: o ? r.exactLength.value : void 0,
|
|
1602
|
+
maximum: i ? r.exactLength.value : void 0,
|
|
1603
1603
|
type: "array",
|
|
1604
1604
|
inclusive: !0,
|
|
1605
1605
|
exact: !0,
|
|
1606
|
-
message:
|
|
1606
|
+
message: r.exactLength.message
|
|
1607
1607
|
}), s.dirty());
|
|
1608
1608
|
}
|
|
1609
|
-
if (
|
|
1609
|
+
if (r.minLength !== null && n.data.length < r.minLength.value && (l(n, {
|
|
1610
1610
|
code: d.too_small,
|
|
1611
|
-
minimum:
|
|
1611
|
+
minimum: r.minLength.value,
|
|
1612
1612
|
type: "array",
|
|
1613
1613
|
inclusive: !0,
|
|
1614
1614
|
exact: !1,
|
|
1615
|
-
message:
|
|
1616
|
-
}), s.dirty()),
|
|
1615
|
+
message: r.minLength.message
|
|
1616
|
+
}), s.dirty()), r.maxLength !== null && n.data.length > r.maxLength.value && (l(n, {
|
|
1617
1617
|
code: d.too_big,
|
|
1618
|
-
maximum:
|
|
1618
|
+
maximum: r.maxLength.value,
|
|
1619
1619
|
type: "array",
|
|
1620
1620
|
inclusive: !0,
|
|
1621
1621
|
exact: !1,
|
|
1622
|
-
message:
|
|
1622
|
+
message: r.maxLength.message
|
|
1623
1623
|
}), s.dirty()), n.common.async)
|
|
1624
|
-
return Promise.all([...n.data].map((i, o) =>
|
|
1625
|
-
const
|
|
1626
|
-
return C.mergeArray(s,
|
|
1624
|
+
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new D(n, i, n.path, o)))).then((i) => C.mergeArray(s, i));
|
|
1625
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new D(n, i, n.path, o)));
|
|
1626
|
+
return C.mergeArray(s, a);
|
|
1627
1627
|
}
|
|
1628
1628
|
get element() {
|
|
1629
1629
|
return this._def.type;
|
|
@@ -1691,19 +1691,19 @@ class w extends v {
|
|
|
1691
1691
|
code: d.invalid_type,
|
|
1692
1692
|
expected: h.object,
|
|
1693
1693
|
received: u.parsedType
|
|
1694
|
-
}),
|
|
1694
|
+
}), _;
|
|
1695
1695
|
}
|
|
1696
|
-
const { status: s, ctx:
|
|
1696
|
+
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1697
1697
|
if (!(this._def.catchall instanceof B && this._def.unknownKeys === "strip"))
|
|
1698
|
-
for (const u in
|
|
1698
|
+
for (const u in r.data)
|
|
1699
1699
|
i.includes(u) || o.push(u);
|
|
1700
1700
|
const c = [];
|
|
1701
1701
|
for (const u of i) {
|
|
1702
|
-
const p =
|
|
1702
|
+
const p = a[u], k = r.data[u];
|
|
1703
1703
|
c.push({
|
|
1704
1704
|
key: { status: "valid", value: u },
|
|
1705
|
-
value: p._parse(new D(
|
|
1706
|
-
alwaysSet: u in
|
|
1705
|
+
value: p._parse(new D(r, k, r.path, u)),
|
|
1706
|
+
alwaysSet: u in r.data
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
1709
1709
|
if (this._def.catchall instanceof B) {
|
|
@@ -1712,10 +1712,10 @@ class w extends v {
|
|
|
1712
1712
|
for (const p of o)
|
|
1713
1713
|
c.push({
|
|
1714
1714
|
key: { status: "valid", value: p },
|
|
1715
|
-
value: { status: "valid", value:
|
|
1715
|
+
value: { status: "valid", value: r.data[p] }
|
|
1716
1716
|
});
|
|
1717
1717
|
else if (u === "strict")
|
|
1718
|
-
o.length > 0 && (l(
|
|
1718
|
+
o.length > 0 && (l(r, {
|
|
1719
1719
|
code: d.unrecognized_keys,
|
|
1720
1720
|
keys: o
|
|
1721
1721
|
}), s.dirty());
|
|
@@ -1723,18 +1723,18 @@ class w extends v {
|
|
|
1723
1723
|
} else {
|
|
1724
1724
|
const u = this._def.catchall;
|
|
1725
1725
|
for (const p of o) {
|
|
1726
|
-
const k =
|
|
1726
|
+
const k = r.data[p];
|
|
1727
1727
|
c.push({
|
|
1728
1728
|
key: { status: "valid", value: p },
|
|
1729
1729
|
value: u._parse(
|
|
1730
|
-
new D(
|
|
1730
|
+
new D(r, k, r.path, p)
|
|
1731
1731
|
//, ctx.child(key), value, getParsedType(value)
|
|
1732
1732
|
),
|
|
1733
|
-
alwaysSet: p in
|
|
1733
|
+
alwaysSet: p in r.data
|
|
1734
1734
|
});
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
|
-
return
|
|
1737
|
+
return r.common.async ? Promise.resolve().then(async () => {
|
|
1738
1738
|
const u = [];
|
|
1739
1739
|
for (const p of c) {
|
|
1740
1740
|
const k = await p.key, T = await p.value;
|
|
@@ -1756,11 +1756,11 @@ class w extends v {
|
|
|
1756
1756
|
unknownKeys: "strict",
|
|
1757
1757
|
...e !== void 0 ? {
|
|
1758
1758
|
errorMap: (n, s) => {
|
|
1759
|
-
const
|
|
1759
|
+
const r = this._def.errorMap?.(n, s).message ?? s.defaultError;
|
|
1760
1760
|
return n.code === "unrecognized_keys" ? {
|
|
1761
|
-
message: f.errToObj(e).message ??
|
|
1761
|
+
message: f.errToObj(e).message ?? r
|
|
1762
1762
|
} : {
|
|
1763
|
-
message:
|
|
1763
|
+
message: r
|
|
1764
1764
|
};
|
|
1765
1765
|
}
|
|
1766
1766
|
} : {}
|
|
@@ -1912,8 +1912,8 @@ class w extends v {
|
|
|
1912
1912
|
partial(e) {
|
|
1913
1913
|
const n = {};
|
|
1914
1914
|
for (const s of b.objectKeys(this.shape)) {
|
|
1915
|
-
const
|
|
1916
|
-
e && !e[s] ? n[s] =
|
|
1915
|
+
const r = this.shape[s];
|
|
1916
|
+
e && !e[s] ? n[s] = r : n[s] = r.optional();
|
|
1917
1917
|
}
|
|
1918
1918
|
return new w({
|
|
1919
1919
|
...this._def,
|
|
@@ -1926,10 +1926,10 @@ class w extends v {
|
|
|
1926
1926
|
if (e && !e[s])
|
|
1927
1927
|
n[s] = this.shape[s];
|
|
1928
1928
|
else {
|
|
1929
|
-
let
|
|
1930
|
-
for (;
|
|
1931
|
-
|
|
1932
|
-
n[s] =
|
|
1929
|
+
let a = this.shape[s];
|
|
1930
|
+
for (; a instanceof V; )
|
|
1931
|
+
a = a._def.innerType;
|
|
1932
|
+
n[s] = a;
|
|
1933
1933
|
}
|
|
1934
1934
|
return new w({
|
|
1935
1935
|
...this._def,
|
|
@@ -1937,7 +1937,7 @@ class w extends v {
|
|
|
1937
1937
|
});
|
|
1938
1938
|
}
|
|
1939
1939
|
keyof() {
|
|
1940
|
-
return
|
|
1940
|
+
return rt(b.objectKeys(this.shape));
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
1943
|
w.create = (t, e) => new w({
|
|
@@ -1964,21 +1964,21 @@ w.lazycreate = (t, e) => new w({
|
|
|
1964
1964
|
class de extends v {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: n } = this._processInputParams(e), s = this._def.options;
|
|
1967
|
-
function a
|
|
1968
|
-
for (const o of
|
|
1967
|
+
function r(a) {
|
|
1968
|
+
for (const o of a)
|
|
1969
1969
|
if (o.result.status === "valid")
|
|
1970
1970
|
return o.result;
|
|
1971
|
-
for (const o of
|
|
1971
|
+
for (const o of a)
|
|
1972
1972
|
if (o.result.status === "dirty")
|
|
1973
1973
|
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1974
|
-
const i =
|
|
1974
|
+
const i = a.map((o) => new Z(o.ctx.common.issues));
|
|
1975
1975
|
return l(n, {
|
|
1976
1976
|
code: d.invalid_union,
|
|
1977
1977
|
unionErrors: i
|
|
1978
|
-
}),
|
|
1978
|
+
}), _;
|
|
1979
1979
|
}
|
|
1980
1980
|
if (n.common.async)
|
|
1981
|
-
return Promise.all(s.map(async (
|
|
1981
|
+
return Promise.all(s.map(async (a) => {
|
|
1982
1982
|
const i = {
|
|
1983
1983
|
...n,
|
|
1984
1984
|
common: {
|
|
@@ -1988,16 +1988,16 @@ class de extends v {
|
|
|
1988
1988
|
parent: null
|
|
1989
1989
|
};
|
|
1990
1990
|
return {
|
|
1991
|
-
result: await
|
|
1991
|
+
result: await a._parseAsync({
|
|
1992
1992
|
data: n.data,
|
|
1993
1993
|
path: n.path,
|
|
1994
1994
|
parent: i
|
|
1995
1995
|
}),
|
|
1996
1996
|
ctx: i
|
|
1997
1997
|
};
|
|
1998
|
-
})).then(
|
|
1998
|
+
})).then(r);
|
|
1999
1999
|
{
|
|
2000
|
-
let
|
|
2000
|
+
let a;
|
|
2001
2001
|
const i = [];
|
|
2002
2002
|
for (const c of s) {
|
|
2003
2003
|
const u = {
|
|
@@ -2014,15 +2014,15 @@ class de extends v {
|
|
|
2014
2014
|
});
|
|
2015
2015
|
if (p.status === "valid")
|
|
2016
2016
|
return p;
|
|
2017
|
-
p.status === "dirty" && !
|
|
2017
|
+
p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && i.push(u.common.issues);
|
|
2018
2018
|
}
|
|
2019
|
-
if (
|
|
2020
|
-
return n.common.issues.push(...
|
|
2019
|
+
if (a)
|
|
2020
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2021
2021
|
const o = i.map((c) => new Z(c));
|
|
2022
2022
|
return l(n, {
|
|
2023
2023
|
code: d.invalid_union,
|
|
2024
2024
|
unionErrors: o
|
|
2025
|
-
}),
|
|
2025
|
+
}), _;
|
|
2026
2026
|
}
|
|
2027
2027
|
}
|
|
2028
2028
|
get options() {
|
|
@@ -2039,8 +2039,8 @@ function Ve(t, e) {
|
|
|
2039
2039
|
if (t === e)
|
|
2040
2040
|
return { valid: !0, data: t };
|
|
2041
2041
|
if (n === h.object && s === h.object) {
|
|
2042
|
-
const
|
|
2043
|
-
for (const o of
|
|
2042
|
+
const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2043
|
+
for (const o of a) {
|
|
2044
2044
|
const c = Ve(t[o], e[o]);
|
|
2045
2045
|
if (!c.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
@@ -2050,25 +2050,25 @@ function Ve(t, e) {
|
|
|
2050
2050
|
} else if (n === h.array && s === h.array) {
|
|
2051
2051
|
if (t.length !== e.length)
|
|
2052
2052
|
return { valid: !1 };
|
|
2053
|
-
const
|
|
2054
|
-
for (let
|
|
2055
|
-
const i = t[
|
|
2053
|
+
const r = [];
|
|
2054
|
+
for (let a = 0; a < t.length; a++) {
|
|
2055
|
+
const i = t[a], o = e[a], c = Ve(i, o);
|
|
2056
2056
|
if (!c.valid)
|
|
2057
2057
|
return { valid: !1 };
|
|
2058
|
-
|
|
2058
|
+
r.push(c.data);
|
|
2059
2059
|
}
|
|
2060
|
-
return { valid: !0, data:
|
|
2060
|
+
return { valid: !0, data: r };
|
|
2061
2061
|
} else return n === h.date && s === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2062
2062
|
}
|
|
2063
2063
|
class ue extends v {
|
|
2064
2064
|
_parse(e) {
|
|
2065
|
-
const { status: n, ctx: s } = this._processInputParams(e),
|
|
2066
|
-
if ($e(
|
|
2067
|
-
return
|
|
2068
|
-
const o = Ve(
|
|
2069
|
-
return o.valid ? ((je(
|
|
2065
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2066
|
+
if ($e(a) || $e(i))
|
|
2067
|
+
return _;
|
|
2068
|
+
const o = Ve(a.value, i.value);
|
|
2069
|
+
return o.valid ? ((je(a) || je(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
2070
|
code: d.invalid_intersection_types
|
|
2071
|
-
}),
|
|
2071
|
+
}), _);
|
|
2072
2072
|
};
|
|
2073
2073
|
return s.common.async ? Promise.all([
|
|
2074
2074
|
this._def.left._parseAsync({
|
|
@@ -2081,7 +2081,7 @@ class ue extends v {
|
|
|
2081
2081
|
path: s.path,
|
|
2082
2082
|
parent: s
|
|
2083
2083
|
})
|
|
2084
|
-
]).then(([
|
|
2084
|
+
]).then(([a, i]) => r(a, i)) : r(this._def.left._parseSync({
|
|
2085
2085
|
data: s.data,
|
|
2086
2086
|
path: s.path,
|
|
2087
2087
|
parent: s
|
|
@@ -2106,7 +2106,7 @@ class F extends v {
|
|
|
2106
2106
|
code: d.invalid_type,
|
|
2107
2107
|
expected: h.array,
|
|
2108
2108
|
received: s.parsedType
|
|
2109
|
-
}),
|
|
2109
|
+
}), _;
|
|
2110
2110
|
if (s.data.length < this._def.items.length)
|
|
2111
2111
|
return l(s, {
|
|
2112
2112
|
code: d.too_small,
|
|
@@ -2114,7 +2114,7 @@ class F extends v {
|
|
|
2114
2114
|
inclusive: !0,
|
|
2115
2115
|
exact: !1,
|
|
2116
2116
|
type: "array"
|
|
2117
|
-
}),
|
|
2117
|
+
}), _;
|
|
2118
2118
|
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2119
2119
|
code: d.too_big,
|
|
2120
2120
|
maximum: this._def.items.length,
|
|
@@ -2122,11 +2122,11 @@ class F extends v {
|
|
|
2122
2122
|
exact: !1,
|
|
2123
2123
|
type: "array"
|
|
2124
2124
|
}), n.dirty());
|
|
2125
|
-
const
|
|
2125
|
+
const a = [...s.data].map((i, o) => {
|
|
2126
2126
|
const c = this._def.items[o] || this._def.rest;
|
|
2127
2127
|
return c ? c._parse(new D(s, i, s.path, o)) : null;
|
|
2128
2128
|
}).filter((i) => !!i);
|
|
2129
|
-
return s.common.async ? Promise.all(
|
|
2129
|
+
return s.common.async ? Promise.all(a).then((i) => C.mergeArray(n, i)) : C.mergeArray(n, a);
|
|
2130
2130
|
}
|
|
2131
2131
|
get items() {
|
|
2132
2132
|
return this._def.items;
|
|
@@ -2162,15 +2162,15 @@ class le extends v {
|
|
|
2162
2162
|
code: d.invalid_type,
|
|
2163
2163
|
expected: h.object,
|
|
2164
2164
|
received: s.parsedType
|
|
2165
|
-
}),
|
|
2166
|
-
const
|
|
2165
|
+
}), _;
|
|
2166
|
+
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2167
2167
|
for (const o in s.data)
|
|
2168
|
-
|
|
2169
|
-
key:
|
|
2168
|
+
r.push({
|
|
2169
|
+
key: a._parse(new D(s, o, s.path, o)),
|
|
2170
2170
|
value: i._parse(new D(s, s.data[o], s.path, o)),
|
|
2171
2171
|
alwaysSet: o in s.data
|
|
2172
2172
|
});
|
|
2173
|
-
return s.common.async ? C.mergeObjectAsync(n,
|
|
2173
|
+
return s.common.async ? C.mergeObjectAsync(n, r) : C.mergeObjectSync(n, r);
|
|
2174
2174
|
}
|
|
2175
2175
|
get element() {
|
|
2176
2176
|
return this._def.valueType;
|
|
@@ -2203,10 +2203,10 @@ class Be extends v {
|
|
|
2203
2203
|
code: d.invalid_type,
|
|
2204
2204
|
expected: h.map,
|
|
2205
2205
|
received: s.parsedType
|
|
2206
|
-
}),
|
|
2207
|
-
const
|
|
2208
|
-
key:
|
|
2209
|
-
value:
|
|
2206
|
+
}), _;
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2208
|
+
key: r._parse(new D(s, o, s.path, [u, "key"])),
|
|
2209
|
+
value: a._parse(new D(s, c, s.path, [u, "value"]))
|
|
2210
2210
|
}));
|
|
2211
2211
|
if (s.common.async) {
|
|
2212
2212
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2214,7 +2214,7 @@ class Be extends v {
|
|
|
2214
2214
|
for (const c of i) {
|
|
2215
2215
|
const u = await c.key, p = await c.value;
|
|
2216
2216
|
if (u.status === "aborted" || p.status === "aborted")
|
|
2217
|
-
return
|
|
2217
|
+
return _;
|
|
2218
2218
|
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.value);
|
|
2219
2219
|
}
|
|
2220
2220
|
return { status: n.value, value: o };
|
|
@@ -2224,7 +2224,7 @@ class Be extends v {
|
|
|
2224
2224
|
for (const c of i) {
|
|
2225
2225
|
const u = c.key, p = c.value;
|
|
2226
2226
|
if (u.status === "aborted" || p.status === "aborted")
|
|
2227
|
-
return
|
|
2227
|
+
return _;
|
|
2228
2228
|
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.value);
|
|
2229
2229
|
}
|
|
2230
2230
|
return { status: n.value, value: o };
|
|
@@ -2245,34 +2245,34 @@ class se extends v {
|
|
|
2245
2245
|
code: d.invalid_type,
|
|
2246
2246
|
expected: h.set,
|
|
2247
2247
|
received: s.parsedType
|
|
2248
|
-
}),
|
|
2249
|
-
const
|
|
2250
|
-
|
|
2248
|
+
}), _;
|
|
2249
|
+
const r = this._def;
|
|
2250
|
+
r.minSize !== null && s.data.size < r.minSize.value && (l(s, {
|
|
2251
2251
|
code: d.too_small,
|
|
2252
|
-
minimum:
|
|
2252
|
+
minimum: r.minSize.value,
|
|
2253
2253
|
type: "set",
|
|
2254
2254
|
inclusive: !0,
|
|
2255
2255
|
exact: !1,
|
|
2256
|
-
message:
|
|
2257
|
-
}), n.dirty()),
|
|
2256
|
+
message: r.minSize.message
|
|
2257
|
+
}), n.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (l(s, {
|
|
2258
2258
|
code: d.too_big,
|
|
2259
|
-
maximum:
|
|
2259
|
+
maximum: r.maxSize.value,
|
|
2260
2260
|
type: "set",
|
|
2261
2261
|
inclusive: !0,
|
|
2262
2262
|
exact: !1,
|
|
2263
|
-
message:
|
|
2263
|
+
message: r.maxSize.message
|
|
2264
2264
|
}), n.dirty());
|
|
2265
|
-
const
|
|
2265
|
+
const a = this._def.valueType;
|
|
2266
2266
|
function i(c) {
|
|
2267
2267
|
const u = /* @__PURE__ */ new Set();
|
|
2268
2268
|
for (const p of c) {
|
|
2269
2269
|
if (p.status === "aborted")
|
|
2270
|
-
return
|
|
2270
|
+
return _;
|
|
2271
2271
|
p.status === "dirty" && n.dirty(), u.add(p.value);
|
|
2272
2272
|
}
|
|
2273
2273
|
return { status: n.value, value: u };
|
|
2274
2274
|
}
|
|
2275
|
-
const o = [...s.data.values()].map((c, u) =>
|
|
2275
|
+
const o = [...s.data.values()].map((c, u) => a._parse(new D(s, c, s.path, u)));
|
|
2276
2276
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2277
2277
|
}
|
|
2278
2278
|
min(e, n) {
|
|
@@ -2323,7 +2323,7 @@ class Fe extends v {
|
|
|
2323
2323
|
received: n.data,
|
|
2324
2324
|
code: d.invalid_literal,
|
|
2325
2325
|
expected: this._def.value
|
|
2326
|
-
}),
|
|
2326
|
+
}), _;
|
|
2327
2327
|
}
|
|
2328
2328
|
return { status: "valid", value: e.data };
|
|
2329
2329
|
}
|
|
@@ -2336,7 +2336,7 @@ Fe.create = (t, e) => new Fe({
|
|
|
2336
2336
|
typeName: m.ZodLiteral,
|
|
2337
2337
|
...g(e)
|
|
2338
2338
|
});
|
|
2339
|
-
function
|
|
2339
|
+
function rt(t, e) {
|
|
2340
2340
|
return new K({
|
|
2341
2341
|
values: t,
|
|
2342
2342
|
typeName: m.ZodEnum,
|
|
@@ -2351,7 +2351,7 @@ class K extends v {
|
|
|
2351
2351
|
expected: b.joinValues(s),
|
|
2352
2352
|
received: n.parsedType,
|
|
2353
2353
|
code: d.invalid_type
|
|
2354
|
-
}),
|
|
2354
|
+
}), _;
|
|
2355
2355
|
}
|
|
2356
2356
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2357
2357
|
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
@@ -2359,7 +2359,7 @@ class K extends v {
|
|
|
2359
2359
|
received: n.data,
|
|
2360
2360
|
code: d.invalid_enum_value,
|
|
2361
2361
|
options: s
|
|
2362
|
-
}),
|
|
2362
|
+
}), _;
|
|
2363
2363
|
}
|
|
2364
2364
|
return N(e.data);
|
|
2365
2365
|
}
|
|
@@ -2397,25 +2397,25 @@ class K extends v {
|
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
K.create =
|
|
2400
|
+
K.create = rt;
|
|
2401
2401
|
class Ue extends v {
|
|
2402
2402
|
_parse(e) {
|
|
2403
2403
|
const n = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2404
2404
|
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
2405
|
-
const
|
|
2405
|
+
const r = b.objectValues(n);
|
|
2406
2406
|
return l(s, {
|
|
2407
|
-
expected: b.joinValues(
|
|
2407
|
+
expected: b.joinValues(r),
|
|
2408
2408
|
received: s.parsedType,
|
|
2409
2409
|
code: d.invalid_type
|
|
2410
|
-
}),
|
|
2410
|
+
}), _;
|
|
2411
2411
|
}
|
|
2412
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2413
|
-
const
|
|
2413
|
+
const r = b.objectValues(n);
|
|
2414
2414
|
return l(s, {
|
|
2415
2415
|
received: s.data,
|
|
2416
2416
|
code: d.invalid_enum_value,
|
|
2417
|
-
options:
|
|
2418
|
-
}),
|
|
2417
|
+
options: r
|
|
2418
|
+
}), _;
|
|
2419
2419
|
}
|
|
2420
2420
|
return N(e.data);
|
|
2421
2421
|
}
|
|
@@ -2439,9 +2439,9 @@ class he extends v {
|
|
|
2439
2439
|
code: d.invalid_type,
|
|
2440
2440
|
expected: h.promise,
|
|
2441
2441
|
received: n.parsedType
|
|
2442
|
-
}),
|
|
2442
|
+
}), _;
|
|
2443
2443
|
const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2444
|
-
return N(s.then((
|
|
2444
|
+
return N(s.then((r) => this._def.type.parseAsync(r, {
|
|
2445
2445
|
path: n.path,
|
|
2446
2446
|
errorMap: n.common.contextualErrorMap
|
|
2447
2447
|
})));
|
|
@@ -2460,7 +2460,7 @@ class U extends v {
|
|
|
2460
2460
|
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2461
2461
|
}
|
|
2462
2462
|
_parse(e) {
|
|
2463
|
-
const { status: n, ctx: s } = this._processInputParams(e),
|
|
2463
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2464
2464
|
addIssue: (i) => {
|
|
2465
2465
|
l(s, i), i.fatal ? n.abort() : n.dirty();
|
|
2466
2466
|
},
|
|
@@ -2468,33 +2468,33 @@ class U extends v {
|
|
|
2468
2468
|
return s.path;
|
|
2469
2469
|
}
|
|
2470
2470
|
};
|
|
2471
|
-
if (
|
|
2472
|
-
const i =
|
|
2471
|
+
if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
|
|
2472
|
+
const i = r.transform(s.data, a);
|
|
2473
2473
|
if (s.common.async)
|
|
2474
2474
|
return Promise.resolve(i).then(async (o) => {
|
|
2475
2475
|
if (n.value === "aborted")
|
|
2476
|
-
return
|
|
2476
|
+
return _;
|
|
2477
2477
|
const c = await this._def.schema._parseAsync({
|
|
2478
2478
|
data: o,
|
|
2479
2479
|
path: s.path,
|
|
2480
2480
|
parent: s
|
|
2481
2481
|
});
|
|
2482
|
-
return c.status === "aborted" ?
|
|
2482
|
+
return c.status === "aborted" ? _ : c.status === "dirty" || n.value === "dirty" ? te(c.value) : c;
|
|
2483
2483
|
});
|
|
2484
2484
|
{
|
|
2485
2485
|
if (n.value === "aborted")
|
|
2486
|
-
return
|
|
2486
|
+
return _;
|
|
2487
2487
|
const o = this._def.schema._parseSync({
|
|
2488
2488
|
data: i,
|
|
2489
2489
|
path: s.path,
|
|
2490
2490
|
parent: s
|
|
2491
2491
|
});
|
|
2492
|
-
return o.status === "aborted" ?
|
|
2492
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || n.value === "dirty" ? te(o.value) : o;
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
|
-
if (
|
|
2495
|
+
if (r.type === "refinement") {
|
|
2496
2496
|
const i = (o) => {
|
|
2497
|
-
const c =
|
|
2497
|
+
const c = r.refinement(o, a);
|
|
2498
2498
|
if (s.common.async)
|
|
2499
2499
|
return Promise.resolve(c);
|
|
2500
2500
|
if (c instanceof Promise)
|
|
@@ -2507,11 +2507,11 @@ class U extends v {
|
|
|
2507
2507
|
path: s.path,
|
|
2508
2508
|
parent: s
|
|
2509
2509
|
});
|
|
2510
|
-
return o.status === "aborted" ?
|
|
2510
|
+
return o.status === "aborted" ? _ : (o.status === "dirty" && n.dirty(), i(o.value), { status: n.value, value: o.value });
|
|
2511
2511
|
} else
|
|
2512
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ?
|
|
2512
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && n.dirty(), i(o.value).then(() => ({ status: n.value, value: o.value }))));
|
|
2513
2513
|
}
|
|
2514
|
-
if (
|
|
2514
|
+
if (r.type === "transform")
|
|
2515
2515
|
if (s.common.async === !1) {
|
|
2516
2516
|
const i = this._def.schema._parseSync({
|
|
2517
2517
|
data: s.data,
|
|
@@ -2519,17 +2519,17 @@ class U extends v {
|
|
|
2519
2519
|
parent: s
|
|
2520
2520
|
});
|
|
2521
2521
|
if (!J(i))
|
|
2522
|
-
return
|
|
2523
|
-
const o =
|
|
2522
|
+
return _;
|
|
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: n.value, value: o };
|
|
2527
2527
|
} else
|
|
2528
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => J(i) ? Promise.resolve(
|
|
2528
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => J(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2529
2529
|
status: n.value,
|
|
2530
2530
|
value: o
|
|
2531
|
-
})) :
|
|
2532
|
-
b.assertNever(
|
|
2531
|
+
})) : _);
|
|
2532
|
+
b.assertNever(r);
|
|
2533
2533
|
}
|
|
2534
2534
|
}
|
|
2535
2535
|
U.create = (t, e, n) => new U({
|
|
@@ -2570,7 +2570,7 @@ G.create = (t, e) => new G({
|
|
|
2570
2570
|
typeName: m.ZodNullable,
|
|
2571
2571
|
...g(e)
|
|
2572
2572
|
});
|
|
2573
|
-
class
|
|
2573
|
+
class _e extends v {
|
|
2574
2574
|
_parse(e) {
|
|
2575
2575
|
const { ctx: n } = this._processInputParams(e);
|
|
2576
2576
|
let s = n.data;
|
|
@@ -2584,13 +2584,13 @@ class ye extends v {
|
|
|
2584
2584
|
return this._def.innerType;
|
|
2585
2585
|
}
|
|
2586
2586
|
}
|
|
2587
|
-
|
|
2587
|
+
_e.create = (t, e) => new _e({
|
|
2588
2588
|
innerType: t,
|
|
2589
2589
|
typeName: m.ZodDefault,
|
|
2590
2590
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2591
2591
|
...g(e)
|
|
2592
2592
|
});
|
|
2593
|
-
class
|
|
2593
|
+
class ye extends v {
|
|
2594
2594
|
_parse(e) {
|
|
2595
2595
|
const { ctx: n } = this._processInputParams(e), s = {
|
|
2596
2596
|
...n,
|
|
@@ -2598,16 +2598,16 @@ class _e extends v {
|
|
|
2598
2598
|
...n.common,
|
|
2599
2599
|
issues: []
|
|
2600
2600
|
}
|
|
2601
|
-
},
|
|
2601
|
+
}, r = this._def.innerType._parse({
|
|
2602
2602
|
data: s.data,
|
|
2603
2603
|
path: s.path,
|
|
2604
2604
|
parent: {
|
|
2605
2605
|
...s
|
|
2606
2606
|
}
|
|
2607
2607
|
});
|
|
2608
|
-
return oe(
|
|
2608
|
+
return oe(r) ? r.then((a) => ({
|
|
2609
2609
|
status: "valid",
|
|
2610
|
-
value:
|
|
2610
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2611
2611
|
get error() {
|
|
2612
2612
|
return new Z(s.common.issues);
|
|
2613
2613
|
},
|
|
@@ -2615,7 +2615,7 @@ class _e extends v {
|
|
|
2615
2615
|
})
|
|
2616
2616
|
})) : {
|
|
2617
2617
|
status: "valid",
|
|
2618
|
-
value:
|
|
2618
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2619
2619
|
get error() {
|
|
2620
2620
|
return new Z(s.common.issues);
|
|
2621
2621
|
},
|
|
@@ -2627,7 +2627,7 @@ class _e extends v {
|
|
|
2627
2627
|
return this._def.innerType;
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
|
|
2630
|
+
ye.create = (t, e) => new ye({
|
|
2631
2631
|
innerType: t,
|
|
2632
2632
|
typeName: m.ZodCatch,
|
|
2633
2633
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
@@ -2641,7 +2641,7 @@ class qe extends v {
|
|
|
2641
2641
|
code: d.invalid_type,
|
|
2642
2642
|
expected: h.nan,
|
|
2643
2643
|
received: s.parsedType
|
|
2644
|
-
}),
|
|
2644
|
+
}), _;
|
|
2645
2645
|
}
|
|
2646
2646
|
return { status: "valid", value: e.data };
|
|
2647
2647
|
}
|
|
@@ -2650,7 +2650,7 @@ qe.create = (t) => new qe({
|
|
|
2650
2650
|
typeName: m.ZodNaN,
|
|
2651
2651
|
...g(t)
|
|
2652
2652
|
});
|
|
2653
|
-
class
|
|
2653
|
+
class at extends v {
|
|
2654
2654
|
_parse(e) {
|
|
2655
2655
|
const { ctx: n } = this._processInputParams(e), s = n.data;
|
|
2656
2656
|
return this._def.type._parse({
|
|
@@ -2668,28 +2668,28 @@ class xe extends v {
|
|
|
2668
2668
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2669
2669
|
if (s.common.async)
|
|
2670
2670
|
return (async () => {
|
|
2671
|
-
const
|
|
2671
|
+
const a = await this._def.in._parseAsync({
|
|
2672
2672
|
data: s.data,
|
|
2673
2673
|
path: s.path,
|
|
2674
2674
|
parent: s
|
|
2675
2675
|
});
|
|
2676
|
-
return
|
|
2677
|
-
data:
|
|
2676
|
+
return a.status === "aborted" ? _ : a.status === "dirty" ? (n.dirty(), te(a.value)) : this._def.out._parseAsync({
|
|
2677
|
+
data: a.value,
|
|
2678
2678
|
path: s.path,
|
|
2679
2679
|
parent: s
|
|
2680
2680
|
});
|
|
2681
2681
|
})();
|
|
2682
2682
|
{
|
|
2683
|
-
const
|
|
2683
|
+
const r = this._def.in._parseSync({
|
|
2684
2684
|
data: s.data,
|
|
2685
2685
|
path: s.path,
|
|
2686
2686
|
parent: s
|
|
2687
2687
|
});
|
|
2688
|
-
return
|
|
2688
|
+
return r.status === "aborted" ? _ : r.status === "dirty" ? (n.dirty(), {
|
|
2689
2689
|
status: "dirty",
|
|
2690
|
-
value:
|
|
2690
|
+
value: r.value
|
|
2691
2691
|
}) : this._def.out._parseSync({
|
|
2692
|
-
data:
|
|
2692
|
+
data: r.value,
|
|
2693
2693
|
path: s.path,
|
|
2694
2694
|
parent: s
|
|
2695
2695
|
});
|
|
@@ -2705,8 +2705,8 @@ class xe extends v {
|
|
|
2705
2705
|
}
|
|
2706
2706
|
class ge extends v {
|
|
2707
2707
|
_parse(e) {
|
|
2708
|
-
const n = this._def.innerType._parse(e), s = (
|
|
2709
|
-
return oe(n) ? n.then((
|
|
2708
|
+
const n = this._def.innerType._parse(e), s = (r) => (J(r) && (r.value = Object.freeze(r.value)), r);
|
|
2709
|
+
return oe(n) ? n.then((r) => s(r)) : s(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
unwrap() {
|
|
2712
2712
|
return this._def.innerType;
|
|
@@ -2721,7 +2721,7 @@ 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
|
|
2724
|
+
const y = I.create, it = Y.create, ke = me.create;
|
|
2725
2725
|
B.create;
|
|
2726
2726
|
const A = R.create, $ = w.create;
|
|
2727
2727
|
de.create;
|
|
@@ -2735,7 +2735,7 @@ G.create;
|
|
|
2735
2735
|
const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2736
2736
|
__proto__: null,
|
|
2737
2737
|
DIRTY: te,
|
|
2738
|
-
INVALID:
|
|
2738
|
+
INVALID: _,
|
|
2739
2739
|
OK: N,
|
|
2740
2740
|
ParseStatus: C,
|
|
2741
2741
|
Schema: v,
|
|
@@ -2743,10 +2743,10 @@ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2743
2743
|
ZodArray: R,
|
|
2744
2744
|
ZodBigInt: ne,
|
|
2745
2745
|
ZodBoolean: me,
|
|
2746
|
-
ZodBranded:
|
|
2747
|
-
ZodCatch:
|
|
2746
|
+
ZodBranded: at,
|
|
2747
|
+
ZodCatch: ye,
|
|
2748
2748
|
ZodDate: ce,
|
|
2749
|
-
ZodDefault:
|
|
2749
|
+
ZodDefault: _e,
|
|
2750
2750
|
ZodEffects: U,
|
|
2751
2751
|
ZodEnum: K,
|
|
2752
2752
|
ZodError: Z,
|
|
@@ -2800,18 +2800,18 @@ const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2800
2800
|
return Re;
|
|
2801
2801
|
},
|
|
2802
2802
|
record: ot,
|
|
2803
|
-
string:
|
|
2803
|
+
string: y,
|
|
2804
2804
|
get util() {
|
|
2805
2805
|
return b;
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
|
-
|
|
2808
|
+
yt(Vt);
|
|
2809
2809
|
const Bt = (t, e) => e.skipDedupe || e.method !== "GET", zt = (t, e) => e.method + "@" + t, Ft = (t) => t.clone(), Ut = ({ skip: t = Bt, key: e = zt, resolver: n = Ft } = {}) => {
|
|
2810
2810
|
const s = /* @__PURE__ */ new Map();
|
|
2811
|
-
return (
|
|
2812
|
-
if (t(
|
|
2813
|
-
return a
|
|
2814
|
-
const o = e(
|
|
2811
|
+
return (r) => (a, i) => {
|
|
2812
|
+
if (t(a, i))
|
|
2813
|
+
return r(a, i);
|
|
2814
|
+
const o = e(a, i);
|
|
2815
2815
|
if (!s.has(o))
|
|
2816
2816
|
s.set(o, []);
|
|
2817
2817
|
else
|
|
@@ -2819,21 +2819,21 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", zt = (t, e) => e.method
|
|
|
2819
2819
|
s.get(o).push([c, u]);
|
|
2820
2820
|
});
|
|
2821
2821
|
try {
|
|
2822
|
-
return a
|
|
2822
|
+
return r(a, i).then((c) => (s.get(o).forEach(([u]) => u(n(c))), s.delete(o), c)).catch((c) => {
|
|
2823
2823
|
throw s.get(o).forEach(([, u]) => u(c)), s.delete(o), c;
|
|
2824
2824
|
});
|
|
2825
2825
|
} catch (c) {
|
|
2826
2826
|
return s.delete(o), Promise.reject(c);
|
|
2827
2827
|
}
|
|
2828
2828
|
};
|
|
2829
|
-
}, qt = (t, e) => t * e, Wt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Qt = ({ delayTimer: t = 500, delayRamp: e = qt, maxAttempts: n = 10, until: s = Wt, onRetry:
|
|
2829
|
+
}, qt = (t, e) => t * e, Wt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Qt = ({ delayTimer: t = 500, delayRamp: e = qt, maxAttempts: n = 10, until: s = Wt, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (u, p) => {
|
|
2830
2830
|
let k = 0;
|
|
2831
2831
|
if (o && o(u, p))
|
|
2832
2832
|
return c(u, p);
|
|
2833
2833
|
const T = (S, E) => Promise.resolve(s(S, E)).then((q) => q ? S && i ? S : E ? Promise.reject(E) : S : (k++, !n || k <= n ? new Promise((x) => {
|
|
2834
2834
|
const L = e(t, k);
|
|
2835
2835
|
setTimeout(() => {
|
|
2836
|
-
typeof
|
|
2836
|
+
typeof r == "function" ? Promise.resolve(r({
|
|
2837
2837
|
response: S,
|
|
2838
2838
|
error: E,
|
|
2839
2839
|
url: u,
|
|
@@ -2845,70 +2845,70 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", zt = (t, e) => e.method
|
|
|
2845
2845
|
}) : x(c(u, p));
|
|
2846
2846
|
}, L);
|
|
2847
2847
|
}).then(T).catch((x) => {
|
|
2848
|
-
if (!
|
|
2848
|
+
if (!a)
|
|
2849
2849
|
throw x;
|
|
2850
2850
|
return T(null, x);
|
|
2851
2851
|
}) : S && i ? S : Promise.reject(E || new Error("Number of attempts exceeded."))));
|
|
2852
2852
|
return c(u, p).then(T).catch((S) => {
|
|
2853
|
-
if (!
|
|
2853
|
+
if (!a)
|
|
2854
2854
|
throw S;
|
|
2855
2855
|
return T(null, S);
|
|
2856
2856
|
});
|
|
2857
2857
|
}, ve = $({
|
|
2858
2858
|
code: it(),
|
|
2859
|
-
message:
|
|
2859
|
+
message: y()
|
|
2860
2860
|
}), Ht = $({
|
|
2861
|
-
message:
|
|
2861
|
+
message: y()
|
|
2862
2862
|
}), Jt = $({
|
|
2863
|
-
emails: A(
|
|
2864
|
-
http_body:
|
|
2865
|
-
http_url:
|
|
2866
|
-
txt_name:
|
|
2867
|
-
txt_value:
|
|
2863
|
+
emails: A(y()).optional(),
|
|
2864
|
+
http_body: y().optional(),
|
|
2865
|
+
http_url: y().optional(),
|
|
2866
|
+
txt_name: y().optional(),
|
|
2867
|
+
txt_value: y().optional()
|
|
2868
2868
|
}), Yt = $({
|
|
2869
|
-
ciphers: A(
|
|
2870
|
-
early_hints:
|
|
2871
|
-
http2:
|
|
2872
|
-
min_tls_version:
|
|
2873
|
-
tls_1_3:
|
|
2869
|
+
ciphers: A(y()).optional(),
|
|
2870
|
+
early_hints: y().optional(),
|
|
2871
|
+
http2: y().optional(),
|
|
2872
|
+
min_tls_version: y().optional(),
|
|
2873
|
+
tls_1_3: y().optional()
|
|
2874
2874
|
}), Kt = $({
|
|
2875
|
-
id:
|
|
2876
|
-
bundle_method:
|
|
2877
|
-
certificate_authority:
|
|
2878
|
-
custom_certificate:
|
|
2879
|
-
custom_csr_id:
|
|
2880
|
-
custom_key:
|
|
2881
|
-
expires_on:
|
|
2882
|
-
hosts: A(
|
|
2883
|
-
issuer:
|
|
2884
|
-
method:
|
|
2885
|
-
serial_number:
|
|
2875
|
+
id: y(),
|
|
2876
|
+
bundle_method: y().optional(),
|
|
2877
|
+
certificate_authority: y(),
|
|
2878
|
+
custom_certificate: y().optional(),
|
|
2879
|
+
custom_csr_id: y().optional(),
|
|
2880
|
+
custom_key: y().optional(),
|
|
2881
|
+
expires_on: y().optional(),
|
|
2882
|
+
hosts: A(y()).optional(),
|
|
2883
|
+
issuer: y().optional(),
|
|
2884
|
+
method: y(),
|
|
2885
|
+
serial_number: y().optional(),
|
|
2886
2886
|
settings: Yt.optional(),
|
|
2887
|
-
signature:
|
|
2888
|
-
type:
|
|
2889
|
-
uploaded_on:
|
|
2887
|
+
signature: y().optional(),
|
|
2888
|
+
type: y(),
|
|
2889
|
+
uploaded_on: y().optional(),
|
|
2890
2890
|
validation_errors: A(Ht).optional(),
|
|
2891
2891
|
validation_records: A(Jt).optional(),
|
|
2892
2892
|
wildcard: ke()
|
|
2893
2893
|
}), Gt = $({
|
|
2894
|
-
name:
|
|
2895
|
-
type:
|
|
2896
|
-
value:
|
|
2894
|
+
name: y(),
|
|
2895
|
+
type: y(),
|
|
2896
|
+
value: y()
|
|
2897
2897
|
}), Xt = $({
|
|
2898
|
-
http_body:
|
|
2899
|
-
http_url:
|
|
2898
|
+
http_body: y().optional(),
|
|
2899
|
+
http_url: y().optional()
|
|
2900
2900
|
}), ct = $({
|
|
2901
|
-
id:
|
|
2901
|
+
id: y(),
|
|
2902
2902
|
ssl: Kt,
|
|
2903
|
-
hostname:
|
|
2904
|
-
custom_metadata: ot(
|
|
2905
|
-
custom_origin_server:
|
|
2906
|
-
custom_origin_sni:
|
|
2903
|
+
hostname: y(),
|
|
2904
|
+
custom_metadata: ot(y()).optional(),
|
|
2905
|
+
custom_origin_server: y().optional(),
|
|
2906
|
+
custom_origin_sni: y().optional(),
|
|
2907
2907
|
ownership_verification: Gt.optional(),
|
|
2908
2908
|
ownership_verification_http: Xt.optional(),
|
|
2909
|
-
status:
|
|
2910
|
-
verification_errors: A(
|
|
2911
|
-
created_at:
|
|
2909
|
+
status: y(),
|
|
2910
|
+
verification_errors: A(y()).optional(),
|
|
2911
|
+
created_at: y()
|
|
2912
2912
|
}), ie = $({
|
|
2913
2913
|
errors: A(ve),
|
|
2914
2914
|
messages: A(ve),
|
|
@@ -2931,8 +2931,8 @@ function H(t) {
|
|
|
2931
2931
|
function Je(t) {
|
|
2932
2932
|
const e = {}, n = {};
|
|
2933
2933
|
if (!t) return { sslOverrides: e, rest: n };
|
|
2934
|
-
for (const [s,
|
|
2935
|
-
s.startsWith("ssl.") ? e[s.slice(4)] =
|
|
2934
|
+
for (const [s, r] of Object.entries(t))
|
|
2935
|
+
s.startsWith("ssl.") ? e[s.slice(4)] = r : n[s] = r;
|
|
2936
2936
|
return { sslOverrides: e, rest: n };
|
|
2937
2937
|
}
|
|
2938
2938
|
function Ne(t) {
|
|
@@ -2944,11 +2944,21 @@ function Ne(t) {
|
|
|
2944
2944
|
record: s.txt_value,
|
|
2945
2945
|
domain: s.txt_name
|
|
2946
2946
|
});
|
|
2947
|
-
t.ownership_verification && e.push({
|
|
2947
|
+
if (t.ownership_verification && e.push({
|
|
2948
2948
|
name: "txt",
|
|
2949
2949
|
record: t.ownership_verification.value,
|
|
2950
2950
|
domain: t.ownership_verification.name
|
|
2951
|
-
})
|
|
2951
|
+
}), t.ownership_verification_http?.http_body && t.ownership_verification_http?.http_url && e.push({
|
|
2952
|
+
name: "http",
|
|
2953
|
+
http_body: t.ownership_verification_http.http_body,
|
|
2954
|
+
http_url: t.ownership_verification_http.http_url
|
|
2955
|
+
}), t.ssl.validation_records)
|
|
2956
|
+
for (const s of t.ssl.validation_records)
|
|
2957
|
+
s.http_body && s.http_url && e.push({
|
|
2958
|
+
name: "http",
|
|
2959
|
+
http_body: s.http_body,
|
|
2960
|
+
http_url: s.http_url
|
|
2961
|
+
});
|
|
2952
2962
|
const n = {
|
|
2953
2963
|
...t.domain_metadata || {},
|
|
2954
2964
|
"ssl.method": t.ssl.method,
|
|
@@ -2970,9 +2980,9 @@ function Ne(t) {
|
|
|
2970
2980
|
function en(t) {
|
|
2971
2981
|
return {
|
|
2972
2982
|
create: async (e, n) => {
|
|
2973
|
-
const { sslOverrides: s, rest:
|
|
2983
|
+
const { sslOverrides: s, rest: r } = Je(
|
|
2974
2984
|
n.domain_metadata
|
|
2975
|
-
), { result:
|
|
2985
|
+
), { result: a, errors: i, success: o } = ie.parse(
|
|
2976
2986
|
await H(t).post(
|
|
2977
2987
|
{
|
|
2978
2988
|
hostname: n.domain,
|
|
@@ -2991,9 +3001,9 @@ function en(t) {
|
|
|
2991
3001
|
if (!o)
|
|
2992
3002
|
throw new Error(JSON.stringify(i));
|
|
2993
3003
|
const c = Ne({
|
|
2994
|
-
...
|
|
3004
|
+
...a,
|
|
2995
3005
|
primary: !1,
|
|
2996
|
-
domain_metadata:
|
|
3006
|
+
domain_metadata: r
|
|
2997
3007
|
});
|
|
2998
3008
|
return await t.customDomainAdapter.create(e, {
|
|
2999
3009
|
custom_domain_id: c.custom_domain_id,
|
|
@@ -3009,65 +3019,65 @@ function en(t) {
|
|
|
3009
3019
|
);
|
|
3010
3020
|
if (!s)
|
|
3011
3021
|
throw new X(404);
|
|
3012
|
-
const
|
|
3022
|
+
const r = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: a, errors: i, success: o } = ie.parse(r);
|
|
3013
3023
|
if (!o)
|
|
3014
3024
|
throw new X(503, {
|
|
3015
3025
|
message: JSON.stringify(i)
|
|
3016
3026
|
});
|
|
3017
|
-
if (t.enterprise &&
|
|
3027
|
+
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3018
3028
|
throw new X(404);
|
|
3019
|
-
return Ne({ ...s, ...
|
|
3029
|
+
return Ne({ ...s, ...a });
|
|
3020
3030
|
},
|
|
3021
3031
|
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3022
3032
|
list: async (e) => {
|
|
3023
3033
|
const n = await t.customDomainAdapter.list(e);
|
|
3024
3034
|
return (await Promise.all(
|
|
3025
|
-
n.map(async (
|
|
3035
|
+
n.map(async (r) => {
|
|
3026
3036
|
try {
|
|
3027
|
-
const
|
|
3028
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3029
|
-
).json(), { result: i, success: o } = ie.parse(
|
|
3037
|
+
const a = await H(t).get(
|
|
3038
|
+
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
3039
|
+
).json(), { result: i, success: o } = ie.parse(a);
|
|
3030
3040
|
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ne({
|
|
3031
|
-
...
|
|
3041
|
+
...r,
|
|
3032
3042
|
...i
|
|
3033
3043
|
});
|
|
3034
3044
|
} catch {
|
|
3035
3045
|
return null;
|
|
3036
3046
|
}
|
|
3037
3047
|
})
|
|
3038
|
-
)).filter((
|
|
3048
|
+
)).filter((r) => r !== null);
|
|
3039
3049
|
},
|
|
3040
3050
|
remove: async (e, n) => {
|
|
3041
3051
|
if (t.enterprise) {
|
|
3042
|
-
const { result:
|
|
3052
|
+
const { result: r, success: a } = ie.parse(
|
|
3043
3053
|
await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3044
3054
|
);
|
|
3045
|
-
if (!
|
|
3055
|
+
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3046
3056
|
throw new X(404);
|
|
3047
3057
|
}
|
|
3048
3058
|
const s = await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
|
|
3049
3059
|
return s.ok && await t.customDomainAdapter.remove(e, n), s.ok;
|
|
3050
3060
|
},
|
|
3051
3061
|
update: async (e, n, s) => {
|
|
3052
|
-
const { sslOverrides:
|
|
3062
|
+
const { sslOverrides: r } = Je(
|
|
3053
3063
|
s.domain_metadata
|
|
3054
|
-
),
|
|
3055
|
-
if (Object.keys(
|
|
3064
|
+
), a = {};
|
|
3065
|
+
if (Object.keys(r).length > 0) {
|
|
3056
3066
|
const i = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: o, success: c } = ie.parse(i);
|
|
3057
3067
|
if (!c)
|
|
3058
3068
|
throw new X(503, {
|
|
3059
3069
|
message: "Failed to fetch current custom hostname state"
|
|
3060
3070
|
});
|
|
3061
|
-
|
|
3071
|
+
a.ssl = {
|
|
3062
3072
|
method: o.ssl.method,
|
|
3063
3073
|
type: o.ssl.type,
|
|
3064
3074
|
certificate_authority: o.ssl.certificate_authority,
|
|
3065
|
-
...
|
|
3075
|
+
...r
|
|
3066
3076
|
};
|
|
3067
3077
|
}
|
|
3068
|
-
if (Object.keys(
|
|
3078
|
+
if (Object.keys(a).length > 0) {
|
|
3069
3079
|
const i = await H(t).patch(
|
|
3070
|
-
|
|
3080
|
+
a,
|
|
3071
3081
|
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3072
3082
|
).res();
|
|
3073
3083
|
if (!i.ok)
|
|
@@ -3105,18 +3115,18 @@ class tn {
|
|
|
3105
3115
|
}
|
|
3106
3116
|
async get(e) {
|
|
3107
3117
|
try {
|
|
3108
|
-
const n = await this.getCache(), s = this.createRequest(e),
|
|
3109
|
-
if (!
|
|
3118
|
+
const n = await this.getCache(), s = this.createRequest(e), r = await n.match(s);
|
|
3119
|
+
if (!r)
|
|
3110
3120
|
return null;
|
|
3111
|
-
const
|
|
3112
|
-
return
|
|
3121
|
+
const a = await r.json();
|
|
3122
|
+
return a.expiresAt && new Date(a.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : a.value;
|
|
3113
3123
|
} catch (n) {
|
|
3114
3124
|
return console.error(`CloudflareCache: get error for key ${e}:`, n), null;
|
|
3115
3125
|
}
|
|
3116
3126
|
}
|
|
3117
3127
|
async set(e, n, s) {
|
|
3118
3128
|
try {
|
|
3119
|
-
const
|
|
3129
|
+
const r = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3120
3130
|
value: n,
|
|
3121
3131
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3122
3132
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3127,9 +3137,9 @@ class tn {
|
|
|
3127
3137
|
const k = new Response(JSON.stringify(c), {
|
|
3128
3138
|
headers: p
|
|
3129
3139
|
});
|
|
3130
|
-
await
|
|
3131
|
-
} catch (
|
|
3132
|
-
console.error(`CloudflareCache: set error for key ${e}:`,
|
|
3140
|
+
await r.put(u, k);
|
|
3141
|
+
} catch (r) {
|
|
3142
|
+
console.error(`CloudflareCache: set error for key ${e}:`, r);
|
|
3133
3143
|
}
|
|
3134
3144
|
}
|
|
3135
3145
|
async delete(e) {
|
|
@@ -3170,9 +3180,9 @@ let dt = (t = 21) => {
|
|
|
3170
3180
|
return e;
|
|
3171
3181
|
};
|
|
3172
3182
|
async function We(t, e) {
|
|
3173
|
-
const n = t.timeout || 3e4, s = new AbortController(),
|
|
3183
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3174
3184
|
try {
|
|
3175
|
-
const
|
|
3185
|
+
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
3176
3186
|
method: "POST",
|
|
3177
3187
|
headers: {
|
|
3178
3188
|
"Content-Type": "application/json",
|
|
@@ -3193,7 +3203,7 @@ async function We(t, e) {
|
|
|
3193
3203
|
throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);
|
|
3194
3204
|
return o.data || o.result?.data || [];
|
|
3195
3205
|
} finally {
|
|
3196
|
-
clearTimeout(
|
|
3206
|
+
clearTimeout(r);
|
|
3197
3207
|
}
|
|
3198
3208
|
}
|
|
3199
3209
|
function be(t) {
|
|
@@ -3244,17 +3254,17 @@ function ut(t) {
|
|
|
3244
3254
|
} : void 0
|
|
3245
3255
|
};
|
|
3246
3256
|
}
|
|
3247
|
-
function
|
|
3257
|
+
function rn(t) {
|
|
3248
3258
|
return async (e, n) => {
|
|
3249
|
-
const s = n.log_id || dt(),
|
|
3259
|
+
const s = n.log_id || dt(), r = {
|
|
3250
3260
|
...n,
|
|
3251
3261
|
log_id: s
|
|
3252
3262
|
};
|
|
3253
|
-
return await
|
|
3263
|
+
return await an(t, e, r), r;
|
|
3254
3264
|
};
|
|
3255
3265
|
}
|
|
3256
|
-
async function
|
|
3257
|
-
const s = (
|
|
3266
|
+
async function an(t, e, n) {
|
|
3267
|
+
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3258
3268
|
id: n.log_id,
|
|
3259
3269
|
tenant_id: e,
|
|
3260
3270
|
type: n.type,
|
|
@@ -3287,16 +3297,16 @@ async function rn(t, e, n) {
|
|
|
3287
3297
|
};
|
|
3288
3298
|
try {
|
|
3289
3299
|
if (t.pipelineBinding)
|
|
3290
|
-
await t.pipelineBinding.send([
|
|
3300
|
+
await t.pipelineBinding.send([r]);
|
|
3291
3301
|
else if (t.pipelineEndpoint) {
|
|
3292
|
-
const
|
|
3302
|
+
const a = t.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), a);
|
|
3293
3303
|
try {
|
|
3294
3304
|
const c = await fetch(t.pipelineEndpoint, {
|
|
3295
3305
|
method: "POST",
|
|
3296
3306
|
headers: {
|
|
3297
3307
|
"Content-Type": "application/json"
|
|
3298
3308
|
},
|
|
3299
|
-
body: JSON.stringify([
|
|
3309
|
+
body: JSON.stringify([r]),
|
|
3300
3310
|
// Pipelines accept array of records
|
|
3301
3311
|
signal: i.signal
|
|
3302
3312
|
});
|
|
@@ -3311,18 +3321,18 @@ async function rn(t, e, n) {
|
|
|
3311
3321
|
throw new Error(
|
|
3312
3322
|
"Either pipelineEndpoint or pipelineBinding must be configured"
|
|
3313
3323
|
);
|
|
3314
|
-
} catch (
|
|
3315
|
-
throw console.error("Failed to send log to Pipeline:",
|
|
3324
|
+
} catch (a) {
|
|
3325
|
+
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3316
3326
|
}
|
|
3317
3327
|
}
|
|
3318
3328
|
function on(t) {
|
|
3319
3329
|
return async (e, n) => {
|
|
3320
|
-
const s = t.namespace || "default",
|
|
3321
|
-
SELECT * FROM ${z(s)}.${z(
|
|
3330
|
+
const s = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3331
|
+
SELECT * FROM ${z(s)}.${z(r)}
|
|
3322
3332
|
WHERE tenant_id = ${be(e)}
|
|
3323
3333
|
AND id = ${be(n)}
|
|
3324
3334
|
LIMIT 1
|
|
3325
|
-
`, i = await We(t,
|
|
3335
|
+
`, i = await We(t, a);
|
|
3326
3336
|
if (i.length === 0)
|
|
3327
3337
|
return null;
|
|
3328
3338
|
const o = i[0];
|
|
@@ -3332,23 +3342,23 @@ function on(t) {
|
|
|
3332
3342
|
function cn(t) {
|
|
3333
3343
|
const e = {};
|
|
3334
3344
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3335
|
-
const [
|
|
3336
|
-
|
|
3345
|
+
const [r, a] = s.split(":");
|
|
3346
|
+
r && a && (e[r] = a);
|
|
3337
3347
|
}), e;
|
|
3338
3348
|
}
|
|
3339
3349
|
function dn(t) {
|
|
3340
3350
|
const e = [];
|
|
3341
3351
|
for (const [n, s] of Object.entries(t)) {
|
|
3342
|
-
const
|
|
3343
|
-
|
|
3344
|
-
`${z(
|
|
3352
|
+
const r = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3353
|
+
r && s && e.push(
|
|
3354
|
+
`${z(r)} = ${be(s)}`
|
|
3345
3355
|
);
|
|
3346
3356
|
}
|
|
3347
3357
|
return e;
|
|
3348
3358
|
}
|
|
3349
3359
|
function un(t) {
|
|
3350
3360
|
return async (e, n = {}) => {
|
|
3351
|
-
const { page: s = 0, per_page:
|
|
3361
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.namespace || "default", u = t.tableName || "logs", p = [
|
|
3352
3362
|
`tenant_id = ${be(e)}`
|
|
3353
3363
|
];
|
|
3354
3364
|
if (o) {
|
|
@@ -3358,16 +3368,16 @@ function un(t) {
|
|
|
3358
3368
|
const k = p.join(" AND ");
|
|
3359
3369
|
let T = "ORDER BY date DESC";
|
|
3360
3370
|
if (i && i.sort_by) {
|
|
3361
|
-
const Q = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""),
|
|
3362
|
-
T = `ORDER BY ${z(Q)} ${
|
|
3371
|
+
const Q = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), re = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3372
|
+
T = `ORDER BY ${z(Q)} ${re}`;
|
|
3363
3373
|
}
|
|
3364
|
-
const S = s *
|
|
3374
|
+
const S = s * r, E = `LIMIT ${r} OFFSET ${S}`, q = `
|
|
3365
3375
|
SELECT * FROM ${z(c)}.${z(u)}
|
|
3366
3376
|
WHERE ${k}
|
|
3367
3377
|
${T}
|
|
3368
3378
|
${E}
|
|
3369
3379
|
`, L = (await We(t, q)).map(ut);
|
|
3370
|
-
if (!
|
|
3380
|
+
if (!a)
|
|
3371
3381
|
return {
|
|
3372
3382
|
logs: L,
|
|
3373
3383
|
start: 0,
|
|
@@ -3381,7 +3391,7 @@ function un(t) {
|
|
|
3381
3391
|
return {
|
|
3382
3392
|
logs: L,
|
|
3383
3393
|
start: S,
|
|
3384
|
-
limit:
|
|
3394
|
+
limit: r,
|
|
3385
3395
|
length: Number(W)
|
|
3386
3396
|
};
|
|
3387
3397
|
};
|
|
@@ -3413,15 +3423,15 @@ function ln(t) {
|
|
|
3413
3423
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3414
3424
|
);
|
|
3415
3425
|
return {
|
|
3416
|
-
create:
|
|
3426
|
+
create: rn(t),
|
|
3417
3427
|
list: un(t),
|
|
3418
3428
|
get: on(t)
|
|
3419
3429
|
};
|
|
3420
3430
|
}
|
|
3421
3431
|
async function fe(t, e) {
|
|
3422
|
-
const n = t.timeout || 3e4, s = new AbortController(),
|
|
3432
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3423
3433
|
try {
|
|
3424
|
-
const
|
|
3434
|
+
const a = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(a, {
|
|
3425
3435
|
method: "POST",
|
|
3426
3436
|
headers: {
|
|
3427
3437
|
"Content-Type": "text/plain",
|
|
@@ -3443,7 +3453,7 @@ async function fe(t, e) {
|
|
|
3443
3453
|
);
|
|
3444
3454
|
return o.data || [];
|
|
3445
3455
|
} finally {
|
|
3446
|
-
clearTimeout(
|
|
3456
|
+
clearTimeout(r);
|
|
3447
3457
|
}
|
|
3448
3458
|
}
|
|
3449
3459
|
function M(t) {
|
|
@@ -3453,10 +3463,10 @@ function Qe(t) {
|
|
|
3453
3463
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3454
3464
|
}
|
|
3455
3465
|
function lt(t) {
|
|
3456
|
-
const e = (
|
|
3457
|
-
if (
|
|
3466
|
+
const e = (r) => {
|
|
3467
|
+
if (r)
|
|
3458
3468
|
try {
|
|
3459
|
-
return JSON.parse(
|
|
3469
|
+
return JSON.parse(r);
|
|
3460
3470
|
} catch {
|
|
3461
3471
|
return;
|
|
3462
3472
|
}
|
|
@@ -3487,11 +3497,11 @@ function lt(t) {
|
|
|
3487
3497
|
}
|
|
3488
3498
|
function hn(t) {
|
|
3489
3499
|
return async (e, n) => {
|
|
3490
|
-
const s = n.log_id || dt(),
|
|
3500
|
+
const s = n.log_id || dt(), r = {
|
|
3491
3501
|
...n,
|
|
3492
3502
|
log_id: s
|
|
3493
3503
|
};
|
|
3494
|
-
return fn(t, e,
|
|
3504
|
+
return fn(t, e, r), r;
|
|
3495
3505
|
};
|
|
3496
3506
|
}
|
|
3497
3507
|
function fn(t, e, n) {
|
|
@@ -3499,49 +3509,49 @@ function fn(t, e, n) {
|
|
|
3499
3509
|
console.error("Analytics Engine binding not configured");
|
|
3500
3510
|
return;
|
|
3501
3511
|
}
|
|
3502
|
-
const s = (
|
|
3512
|
+
const s = (a) => a == null ? "" : typeof a == "string" ? a : JSON.stringify(a), r = (a, i = 1024) => a.substring(0, i);
|
|
3503
3513
|
try {
|
|
3504
3514
|
t.analyticsEngineBinding.writeDataPoint({
|
|
3505
3515
|
blobs: [
|
|
3506
|
-
|
|
3516
|
+
r(n.log_id),
|
|
3507
3517
|
// blob1: log_id
|
|
3508
|
-
|
|
3518
|
+
r(e),
|
|
3509
3519
|
// blob2: tenant_id
|
|
3510
|
-
|
|
3520
|
+
r(n.type || ""),
|
|
3511
3521
|
// blob3: type
|
|
3512
|
-
|
|
3522
|
+
r(n.description || ""),
|
|
3513
3523
|
// blob4: description
|
|
3514
|
-
|
|
3524
|
+
r(n.ip || ""),
|
|
3515
3525
|
// blob5: ip
|
|
3516
|
-
|
|
3526
|
+
r(n.user_agent || ""),
|
|
3517
3527
|
// blob6: user_agent
|
|
3518
|
-
|
|
3528
|
+
r(n.user_id || ""),
|
|
3519
3529
|
// blob7: user_id
|
|
3520
|
-
|
|
3530
|
+
r(n.user_name || ""),
|
|
3521
3531
|
// blob8: user_name
|
|
3522
|
-
|
|
3532
|
+
r(n.connection || ""),
|
|
3523
3533
|
// blob9: connection
|
|
3524
|
-
|
|
3534
|
+
r(n.connection_id || ""),
|
|
3525
3535
|
// blob10: connection_id
|
|
3526
|
-
|
|
3536
|
+
r(n.client_id || ""),
|
|
3527
3537
|
// blob11: client_id
|
|
3528
|
-
|
|
3538
|
+
r(n.client_name || ""),
|
|
3529
3539
|
// blob12: client_name
|
|
3530
|
-
|
|
3540
|
+
r(n.audience || ""),
|
|
3531
3541
|
// blob13: audience
|
|
3532
|
-
|
|
3542
|
+
r(n.scope || ""),
|
|
3533
3543
|
// blob14: scope
|
|
3534
|
-
|
|
3544
|
+
r(n.strategy || ""),
|
|
3535
3545
|
// blob15: strategy
|
|
3536
|
-
|
|
3546
|
+
r(n.strategy_type || ""),
|
|
3537
3547
|
// blob16: strategy_type
|
|
3538
|
-
|
|
3548
|
+
r(n.hostname || ""),
|
|
3539
3549
|
// blob17: hostname
|
|
3540
|
-
|
|
3550
|
+
r(s(n.details)),
|
|
3541
3551
|
// blob18: details (JSON)
|
|
3542
|
-
|
|
3552
|
+
r(s(n.auth0_client)),
|
|
3543
3553
|
// blob19: auth0_client (JSON)
|
|
3544
|
-
|
|
3554
|
+
r(s(n.location_info))
|
|
3545
3555
|
// blob20: location_info (JSON)
|
|
3546
3556
|
],
|
|
3547
3557
|
doubles: [
|
|
@@ -3553,27 +3563,27 @@ function fn(t, e, n) {
|
|
|
3553
3563
|
indexes: [e.substring(0, 96)]
|
|
3554
3564
|
// index1: tenant_id
|
|
3555
3565
|
});
|
|
3556
|
-
} catch (
|
|
3557
|
-
console.error("Failed to write log to Analytics Engine:",
|
|
3566
|
+
} catch (a) {
|
|
3567
|
+
console.error("Failed to write log to Analytics Engine:", a);
|
|
3558
3568
|
}
|
|
3559
3569
|
}
|
|
3560
3570
|
function pn(t) {
|
|
3561
3571
|
return async (e, n) => {
|
|
3562
|
-
const s = t.dataset || "authhero_logs",
|
|
3572
|
+
const s = t.dataset || "authhero_logs", r = `
|
|
3563
3573
|
SELECT *
|
|
3564
3574
|
FROM ${Qe(s)}
|
|
3565
3575
|
WHERE index1 = ${M(e)}
|
|
3566
3576
|
AND blob1 = ${M(n)}
|
|
3567
3577
|
LIMIT 1
|
|
3568
|
-
`,
|
|
3569
|
-
return
|
|
3578
|
+
`, a = await fe(t, r);
|
|
3579
|
+
return a.length === 0 || !a[0] ? null : lt(a[0]);
|
|
3570
3580
|
};
|
|
3571
3581
|
}
|
|
3572
3582
|
function mn(t) {
|
|
3573
3583
|
const e = {};
|
|
3574
3584
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3575
|
-
const
|
|
3576
|
-
|
|
3585
|
+
const r = s.indexOf(":"), a = s.substring(0, r), i = s.substring(r + 1);
|
|
3586
|
+
a && i && (e[a] = i);
|
|
3577
3587
|
}), e;
|
|
3578
3588
|
}
|
|
3579
3589
|
function ht(t) {
|
|
@@ -3597,15 +3607,15 @@ function ht(t) {
|
|
|
3597
3607
|
hostname: "blob17"
|
|
3598
3608
|
}[t] || null;
|
|
3599
3609
|
}
|
|
3600
|
-
function
|
|
3610
|
+
function _n(t) {
|
|
3601
3611
|
const e = [];
|
|
3602
3612
|
for (const [n, s] of Object.entries(t)) {
|
|
3603
|
-
const
|
|
3604
|
-
|
|
3613
|
+
const r = ht(n);
|
|
3614
|
+
r && s && e.push(`${r} = ${M(s)}`);
|
|
3605
3615
|
}
|
|
3606
3616
|
return e;
|
|
3607
3617
|
}
|
|
3608
|
-
function
|
|
3618
|
+
function yn(t) {
|
|
3609
3619
|
if (t === "date")
|
|
3610
3620
|
return "double2";
|
|
3611
3621
|
const e = ht(t);
|
|
@@ -3613,25 +3623,25 @@ function _n(t) {
|
|
|
3613
3623
|
}
|
|
3614
3624
|
function gn(t) {
|
|
3615
3625
|
return async (e, n = {}) => {
|
|
3616
|
-
const { page: s = 0, per_page:
|
|
3626
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs", u = [`index1 = ${M(e)}`];
|
|
3617
3627
|
if (o) {
|
|
3618
3628
|
const O = mn(o);
|
|
3619
|
-
u.push(...
|
|
3629
|
+
u.push(..._n(O));
|
|
3620
3630
|
}
|
|
3621
3631
|
const p = u.join(" AND ");
|
|
3622
3632
|
let k = "ORDER BY timestamp DESC";
|
|
3623
3633
|
if (i && i.sort_by) {
|
|
3624
|
-
const O =
|
|
3634
|
+
const O = yn(i.sort_by), j = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3625
3635
|
k = `ORDER BY ${O} ${j}`;
|
|
3626
3636
|
}
|
|
3627
|
-
const T = s *
|
|
3637
|
+
const T = s * r, S = `LIMIT ${r} OFFSET ${T}`, E = `
|
|
3628
3638
|
SELECT *
|
|
3629
3639
|
FROM ${Qe(c)}
|
|
3630
3640
|
WHERE ${p}
|
|
3631
3641
|
${k}
|
|
3632
3642
|
${S}
|
|
3633
3643
|
`, x = (await fe(t, E)).map(lt);
|
|
3634
|
-
if (!
|
|
3644
|
+
if (!a)
|
|
3635
3645
|
return {
|
|
3636
3646
|
logs: x,
|
|
3637
3647
|
start: 0,
|
|
@@ -3648,14 +3658,14 @@ function gn(t) {
|
|
|
3648
3658
|
return {
|
|
3649
3659
|
logs: x,
|
|
3650
3660
|
start: T,
|
|
3651
|
-
limit:
|
|
3661
|
+
limit: r,
|
|
3652
3662
|
length: Number(j)
|
|
3653
3663
|
};
|
|
3654
3664
|
} catch {
|
|
3655
3665
|
return {
|
|
3656
3666
|
logs: x,
|
|
3657
3667
|
start: T,
|
|
3658
|
-
limit:
|
|
3668
|
+
limit: r,
|
|
3659
3669
|
length: x.length
|
|
3660
3670
|
};
|
|
3661
3671
|
}
|
|
@@ -3674,11 +3684,7 @@ const Ye = [
|
|
|
3674
3684
|
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3675
3685
|
"ssa"
|
|
3676
3686
|
// SUCCESS_SILENT_AUTH
|
|
3677
|
-
], vn = [
|
|
3678
|
-
"pwd_leak",
|
|
3679
|
-
"signup_pwd_leak",
|
|
3680
|
-
"reset_pwd_leak"
|
|
3681
|
-
];
|
|
3687
|
+
], vn = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
3682
3688
|
function Ke(t) {
|
|
3683
3689
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3684
3690
|
}
|
|
@@ -3689,9 +3695,11 @@ function Tn(t) {
|
|
|
3689
3695
|
const e = t.dataset || "authhero_logs";
|
|
3690
3696
|
return {
|
|
3691
3697
|
async getDaily(n, s = {}) {
|
|
3692
|
-
const { from:
|
|
3698
|
+
const { from: r, to: a } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3693
3699
|
o.setDate(o.getDate() - 30);
|
|
3694
|
-
const c =
|
|
3700
|
+
const c = r ? Ke(r) : Ge(o), u = a ? Ke(a) : Ge(i), p = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), k = (/* @__PURE__ */ new Date(`${u}T23:59:59.999Z`)).getTime(), T = Ye.map((x) => M(x)).join(
|
|
3701
|
+
", "
|
|
3702
|
+
), S = vn.map(
|
|
3695
3703
|
(x) => M(x)
|
|
3696
3704
|
).join(", "), E = `
|
|
3697
3705
|
SELECT
|
|
@@ -3720,12 +3728,14 @@ function Tn(t) {
|
|
|
3720
3728
|
async getActiveUsers(n) {
|
|
3721
3729
|
const s = /* @__PURE__ */ new Date();
|
|
3722
3730
|
s.setDate(s.getDate() - 30);
|
|
3723
|
-
const
|
|
3731
|
+
const r = s.getTime(), a = Ye.map((u) => M(u)).join(
|
|
3732
|
+
", "
|
|
3733
|
+
), i = `
|
|
3724
3734
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3725
3735
|
FROM "${e}"
|
|
3726
3736
|
WHERE index1 = ${M(n)}
|
|
3727
|
-
AND double2 >= ${
|
|
3728
|
-
AND blob3 IN (${
|
|
3737
|
+
AND double2 >= ${r}
|
|
3738
|
+
AND blob3 IN (${a})
|
|
3729
3739
|
AND blob7 IS NOT NULL
|
|
3730
3740
|
AND blob7 != ''
|
|
3731
3741
|
`, c = (await fe(t, i))[0];
|
|
@@ -3748,13 +3758,13 @@ function xn() {
|
|
|
3748
3758
|
return {
|
|
3749
3759
|
async getGeoInfo(t) {
|
|
3750
3760
|
try {
|
|
3751
|
-
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"],
|
|
3761
|
+
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"], r = t["cf-iplongitude"], a = t["cf-timezone"], i = t["cf-ipcontinent"];
|
|
3752
3762
|
return e ? {
|
|
3753
3763
|
country_code: e,
|
|
3754
3764
|
city_name: n || "",
|
|
3755
3765
|
latitude: s || "",
|
|
3756
|
-
longitude:
|
|
3757
|
-
time_zone:
|
|
3766
|
+
longitude: r || "",
|
|
3767
|
+
time_zone: a || "",
|
|
3758
3768
|
continent_code: i || ""
|
|
3759
3769
|
} : null;
|
|
3760
3770
|
} catch (e) {
|