@authhero/cloudflare-adapter 2.18.16 → 2.19.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 +14 -14
- package/dist/cloudflare-adapter.mjs +725 -687
- package/package.json +3 -3
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { verificationMethodsSchema as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
1
|
+
import { verificationMethodsSchema as ft } from "@authhero/adapter-interfaces";
|
|
2
|
+
import pt from "wretch";
|
|
3
|
+
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 a = 0, s = Object.getOwnPropertySymbols(t); a < s.length; a++)
|
|
8
|
+
e.indexOf(s[a]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[a]) && (n[s[a]] = t[s[a]]);
|
|
9
9
|
return n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function yt(t, e) {
|
|
12
12
|
var n;
|
|
13
13
|
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
14
|
}
|
|
15
15
|
function re(t, e) {
|
|
16
16
|
const n = t.ZodType.prototype[e];
|
|
17
17
|
t.ZodType.prototype[e] = function(...s) {
|
|
18
|
-
const
|
|
19
|
-
return
|
|
18
|
+
const a = n.apply(this, s);
|
|
19
|
+
return a._def.openapi = this._def.openapi, a;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function _t(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(a, r) {
|
|
26
26
|
var i, o, c, u, p, k;
|
|
27
|
-
const T = typeof
|
|
27
|
+
const T = typeof a == "string" ? r : a, 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 a == "string" ? { refId: a } : 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 (
|
|
31
|
-
const
|
|
30
|
+
if (yt(this, "ZodObject")) {
|
|
31
|
+
const j = this.extend;
|
|
32
32
|
O.extend = function(...W) {
|
|
33
|
-
var Q,
|
|
34
|
-
const Oe =
|
|
33
|
+
var Q, ae, we, Se, Te, Ce, Ee;
|
|
34
|
+
const Oe = j.apply(this, W);
|
|
35
35
|
return Oe._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((ae = (Q = this._def.openapi) === null || Q === void 0 ? void 0 : Q._internal) === null || ae === void 0) && ae.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;
|
|
@@ -44,24 +44,24 @@ function yt(t) {
|
|
|
44
44
|
}, re(t, "optional"), re(t, "nullable"), re(t, "default"), re(t, "transform"), re(t, "refine");
|
|
45
45
|
const e = t.ZodObject.prototype.deepPartial;
|
|
46
46
|
t.ZodObject.prototype.deepPartial = function() {
|
|
47
|
-
const
|
|
47
|
+
const a = this._def.shape(), r = e.apply(this), i = r._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 = a[o]) === null || u === void 0 ? void 0 : u._def) === null || p === void 0 ? void 0 : p.openapi;
|
|
51
|
+
}), r._def.openapi = void 0, r;
|
|
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(...a) {
|
|
55
|
+
const r = n.apply(this, a);
|
|
56
|
+
return r._def.openapi = void 0, r;
|
|
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(...a) {
|
|
60
|
+
const r = s.apply(this, a);
|
|
61
|
+
return r._def.openapi = void 0, r;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var X = class extends Error {
|
|
65
65
|
res;
|
|
66
66
|
status;
|
|
67
67
|
/**
|
|
@@ -89,40 +89,40 @@ var ae = class extends Error {
|
|
|
89
89
|
new Set(".\\+*[^]$()");
|
|
90
90
|
var b;
|
|
91
91
|
(function(t) {
|
|
92
|
-
t.assertEqual = (
|
|
92
|
+
t.assertEqual = (a) => {
|
|
93
93
|
};
|
|
94
|
-
function e(
|
|
94
|
+
function e(a) {
|
|
95
95
|
}
|
|
96
96
|
t.assertIs = e;
|
|
97
|
-
function n(
|
|
97
|
+
function n(a) {
|
|
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 = (a) => {
|
|
101
|
+
const r = {};
|
|
102
|
+
for (const i of a)
|
|
103
|
+
r[i] = i;
|
|
104
|
+
return r;
|
|
105
|
+
}, t.getValidEnumValues = (a) => {
|
|
106
|
+
const r = t.objectKeys(a).filter((o) => typeof a[a[o]] != "number"), i = {};
|
|
107
|
+
for (const o of r)
|
|
108
|
+
i[o] = a[o];
|
|
109
109
|
return t.objectValues(i);
|
|
110
|
-
}, t.objectValues = (
|
|
111
|
-
return r
|
|
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 = (a) => t.objectKeys(a).map(function(r) {
|
|
111
|
+
return a[r];
|
|
112
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
113
|
+
const r = [];
|
|
114
|
+
for (const i in a)
|
|
115
|
+
Object.prototype.hasOwnProperty.call(a, i) && r.push(i);
|
|
116
|
+
return r;
|
|
117
|
+
}, t.find = (a, r) => {
|
|
118
|
+
for (const i of a)
|
|
119
|
+
if (r(i))
|
|
120
120
|
return i;
|
|
121
|
-
}, t.isInteger = typeof Number.isInteger == "function" ? (
|
|
122
|
-
function s(
|
|
123
|
-
return
|
|
121
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && Number.isFinite(a) && Math.floor(a) === a;
|
|
122
|
+
function s(a, r = " | ") {
|
|
123
|
+
return a.map((i) => typeof i == "string" ? `'${i}'` : i).join(r);
|
|
124
124
|
}
|
|
125
|
-
t.joinValues = s, t.jsonStringifyReplacer = (
|
|
125
|
+
t.joinValues = s, t.jsonStringifyReplacer = (a, r) => typeof r == "bigint" ? r.toString() : r;
|
|
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(r) {
|
|
210
|
+
return r.message;
|
|
211
|
+
}, s = { _errors: [] }, a = (r) => {
|
|
212
|
+
for (const i of r.issues)
|
|
213
213
|
if (i.code === "invalid_union")
|
|
214
|
-
i.unionErrors.map(
|
|
214
|
+
i.unionErrors.map(a);
|
|
215
215
|
else if (i.code === "invalid_return_type")
|
|
216
|
-
|
|
216
|
+
a(i.returnTypeError);
|
|
217
217
|
else if (i.code === "invalid_arguments")
|
|
218
|
-
|
|
218
|
+
a(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 a(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 a of this.issues)
|
|
247
|
+
if (a.path.length > 0) {
|
|
248
|
+
const r = a.path[0];
|
|
249
|
+
n[r] = n[r] || [], n[r].push(e(a));
|
|
250
250
|
} else
|
|
251
|
-
s.push(e(
|
|
251
|
+
s.push(e(a));
|
|
252
252
|
return { formErrors: s, fieldErrors: n };
|
|
253
253
|
}
|
|
254
254
|
get formErrors() {
|
|
@@ -312,33 +312,33 @@ const pe = (t, e) => {
|
|
|
312
312
|
}
|
|
313
313
|
return { message: n };
|
|
314
314
|
};
|
|
315
|
-
let
|
|
316
|
-
function
|
|
317
|
-
return
|
|
318
|
-
}
|
|
319
|
-
const
|
|
320
|
-
const { data: e, path: n, errorMaps: s, issueData:
|
|
321
|
-
...
|
|
322
|
-
path:
|
|
315
|
+
let gt = pe;
|
|
316
|
+
function Xe() {
|
|
317
|
+
return gt;
|
|
318
|
+
}
|
|
319
|
+
const et = (t) => {
|
|
320
|
+
const { data: e, path: n, errorMaps: s, issueData: a } = t, r = [...n, ...a.path || []], i = {
|
|
321
|
+
...a,
|
|
322
|
+
path: r
|
|
323
323
|
};
|
|
324
|
-
if (
|
|
324
|
+
if (a.message !== void 0)
|
|
325
325
|
return {
|
|
326
|
-
...
|
|
327
|
-
path:
|
|
328
|
-
message:
|
|
326
|
+
...a,
|
|
327
|
+
path: r,
|
|
328
|
+
message: a.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
|
+
...a,
|
|
336
|
+
path: r,
|
|
337
337
|
message: o
|
|
338
338
|
};
|
|
339
339
|
};
|
|
340
340
|
function l(t, e) {
|
|
341
|
-
const n =
|
|
341
|
+
const n = Xe(), s = et({
|
|
342
342
|
issueData: e,
|
|
343
343
|
data: t.data,
|
|
344
344
|
path: t.path,
|
|
@@ -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((a) => !!a)
|
|
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 (
|
|
370
|
+
for (const a of n) {
|
|
371
|
+
if (a.status === "aborted")
|
|
372
372
|
return y;
|
|
373
|
-
|
|
373
|
+
a.status === "dirty" && e.dirty(), s.push(a.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 a of n) {
|
|
380
|
+
const r = await a.key, i = await a.value;
|
|
381
381
|
s.push({
|
|
382
|
-
key:
|
|
382
|
+
key: r,
|
|
383
383
|
value: i
|
|
384
384
|
});
|
|
385
385
|
}
|
|
@@ -387,32 +387,32 @@ class C {
|
|
|
387
387
|
}
|
|
388
388
|
static mergeObjectSync(e, n) {
|
|
389
389
|
const s = {};
|
|
390
|
-
for (const
|
|
391
|
-
const { key:
|
|
392
|
-
if (
|
|
390
|
+
for (const a of n) {
|
|
391
|
+
const { key: r, value: i } = a;
|
|
392
|
+
if (r.status === "aborted" || i.status === "aborted")
|
|
393
393
|
return y;
|
|
394
|
-
|
|
394
|
+
r.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof i.value < "u" || a.alwaysSet) && (s[r.value] = i.value);
|
|
395
395
|
}
|
|
396
396
|
return { status: e.value, value: s };
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
const y = 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;
|
|
403
403
|
(function(t) {
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
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, a) {
|
|
408
|
+
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key = a;
|
|
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;
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
const He = (t, e) => {
|
|
415
|
-
if (
|
|
415
|
+
if (J(e))
|
|
416
416
|
return { success: !0, data: e.value };
|
|
417
417
|
if (!t.common.issues.length)
|
|
418
418
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -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: a } = 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: a } : { 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: a };
|
|
439
439
|
}
|
|
440
440
|
class v {
|
|
441
441
|
get description() {
|
|
@@ -469,7 +469,7 @@ class v {
|
|
|
469
469
|
}
|
|
470
470
|
_parseSync(e) {
|
|
471
471
|
const n = this._parse(e);
|
|
472
|
-
if (
|
|
472
|
+
if (oe(n))
|
|
473
473
|
throw new Error("Synchronous parse encountered promise.");
|
|
474
474
|
return n;
|
|
475
475
|
}
|
|
@@ -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
|
+
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
499
|
+
return He(s, a);
|
|
500
500
|
}
|
|
501
501
|
"~validate"(e) {
|
|
502
502
|
const n = {
|
|
@@ -513,7 +513,7 @@ class v {
|
|
|
513
513
|
if (!this["~standard"].async)
|
|
514
514
|
try {
|
|
515
515
|
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
516
|
-
return
|
|
516
|
+
return J(s) ? {
|
|
517
517
|
value: s.value
|
|
518
518
|
} : {
|
|
519
519
|
issues: n.common.issues
|
|
@@ -524,7 +524,7 @@ class v {
|
|
|
524
524
|
async: !0
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
return this._parseAsync({ data: e, path: [], parent: n }).then((s) =>
|
|
527
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((s) => J(s) ? {
|
|
528
528
|
value: s.value
|
|
529
529
|
} : {
|
|
530
530
|
issues: n.common.issues
|
|
@@ -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
|
+
}, a = this._parse({ data: e, path: s.path, parent: s }), r = await (oe(a) ? a : Promise.resolve(a));
|
|
552
|
+
return He(s, r);
|
|
553
553
|
}
|
|
554
554
|
refine(e, n) {
|
|
555
|
-
const s = (
|
|
556
|
-
return this._refinement((
|
|
557
|
-
const i = e(
|
|
555
|
+
const s = (a) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(a) : n;
|
|
556
|
+
return this._refinement((a, r) => {
|
|
557
|
+
const i = e(a), o = () => r.addIssue({
|
|
558
558
|
code: d.custom,
|
|
559
|
-
...s(
|
|
559
|
+
...s(a)
|
|
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, a) => e(s) ? !0 : (a.addIssue(typeof n == "function" ? n(s, a) : n), !1));
|
|
566
566
|
}
|
|
567
567
|
_refinement(e) {
|
|
568
568
|
return new U({
|
|
@@ -585,7 +585,7 @@ class v {
|
|
|
585
585
|
return V.create(this, this._def);
|
|
586
586
|
}
|
|
587
587
|
nullable() {
|
|
588
|
-
return
|
|
588
|
+
return G.create(this, this._def);
|
|
589
589
|
}
|
|
590
590
|
nullish() {
|
|
591
591
|
return this.nullable().optional();
|
|
@@ -594,13 +594,13 @@ class v {
|
|
|
594
594
|
return R.create(this);
|
|
595
595
|
}
|
|
596
596
|
promise() {
|
|
597
|
-
return
|
|
597
|
+
return he.create(this, this._def);
|
|
598
598
|
}
|
|
599
599
|
or(e) {
|
|
600
|
-
return
|
|
600
|
+
return de.create([this, e], this._def);
|
|
601
601
|
}
|
|
602
602
|
and(e) {
|
|
603
|
-
return
|
|
603
|
+
return ue.create(this, e, this._def);
|
|
604
604
|
}
|
|
605
605
|
transform(e) {
|
|
606
606
|
return new U({
|
|
@@ -655,206 +655,206 @@ class v {
|
|
|
655
655
|
return this.safeParse(null).success;
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
|
-
const
|
|
658
|
+
const vt = /^c[^\s-]{8,}$/i, bt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, wt = /^[a-z0-9_-]{21}$/i, St = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Tt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Ct = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Et = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
659
659
|
let Ae;
|
|
660
|
-
const
|
|
661
|
-
function
|
|
660
|
+
const Ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, At = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Nt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Rt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, $t = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, jt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, tt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", It = new RegExp(`^${tt}$`);
|
|
661
|
+
function nt(t) {
|
|
662
662
|
let e = "[0-5]\\d";
|
|
663
663
|
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
664
664
|
const n = t.precision ? "+" : "?";
|
|
665
665
|
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
668
|
-
return new RegExp(`^${
|
|
667
|
+
function Zt(t) {
|
|
668
|
+
return new RegExp(`^${nt(t)}$`);
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
let e = `${
|
|
670
|
+
function st(t) {
|
|
671
|
+
let e = `${tt}T${nt(t)}`;
|
|
672
672
|
const n = [];
|
|
673
673
|
return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
|
|
674
674
|
}
|
|
675
|
-
function Zt(t, e) {
|
|
676
|
-
return !!((e === "v4" || !e) && Et.test(t) || (e === "v6" || !e) && At.test(t));
|
|
677
|
-
}
|
|
678
675
|
function Dt(t, e) {
|
|
679
|
-
|
|
676
|
+
return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && Nt.test(t));
|
|
677
|
+
}
|
|
678
|
+
function Lt(t, e) {
|
|
679
|
+
if (!St.test(t))
|
|
680
680
|
return !1;
|
|
681
681
|
try {
|
|
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, "="), a = JSON.parse(atob(s));
|
|
686
|
+
return !(typeof a != "object" || a === null || "typ" in a && a?.typ !== "JWT" || !a.alg || e && a.alg !== e);
|
|
687
687
|
} catch {
|
|
688
688
|
return !1;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
|
-
function
|
|
692
|
-
return !!((e === "v4" || !e) &&
|
|
691
|
+
function Pt(t, e) {
|
|
692
|
+
return !!((e === "v4" || !e) && At.test(t) || (e === "v6" || !e) && Rt.test(t));
|
|
693
693
|
}
|
|
694
|
-
class
|
|
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 r = this._getOrReturnCtx(e);
|
|
698
|
+
return l(r, {
|
|
699
699
|
code: d.invalid_type,
|
|
700
700
|
expected: h.string,
|
|
701
|
-
received:
|
|
701
|
+
received: r.parsedType
|
|
702
702
|
}), y;
|
|
703
703
|
}
|
|
704
704
|
const s = new C();
|
|
705
|
-
let
|
|
706
|
-
for (const
|
|
707
|
-
if (
|
|
708
|
-
e.data.length <
|
|
705
|
+
let a;
|
|
706
|
+
for (const r of this._def.checks)
|
|
707
|
+
if (r.kind === "min")
|
|
708
|
+
e.data.length < r.value && (a = this._getOrReturnCtx(e, a), l(a, {
|
|
709
709
|
code: d.too_small,
|
|
710
|
-
minimum:
|
|
710
|
+
minimum: r.value,
|
|
711
711
|
type: "string",
|
|
712
712
|
inclusive: !0,
|
|
713
713
|
exact: !1,
|
|
714
|
-
message:
|
|
714
|
+
message: r.message
|
|
715
715
|
}), s.dirty());
|
|
716
|
-
else if (
|
|
717
|
-
e.data.length >
|
|
716
|
+
else if (r.kind === "max")
|
|
717
|
+
e.data.length > r.value && (a = this._getOrReturnCtx(e, a), l(a, {
|
|
718
718
|
code: d.too_big,
|
|
719
|
-
maximum:
|
|
719
|
+
maximum: r.value,
|
|
720
720
|
type: "string",
|
|
721
721
|
inclusive: !0,
|
|
722
722
|
exact: !1,
|
|
723
|
-
message:
|
|
723
|
+
message: r.message
|
|
724
724
|
}), s.dirty());
|
|
725
|
-
else if (
|
|
726
|
-
const i = e.data.length >
|
|
727
|
-
(i || o) && (
|
|
725
|
+
else if (r.kind === "length") {
|
|
726
|
+
const i = e.data.length > r.value, o = e.data.length < r.value;
|
|
727
|
+
(i || o) && (a = this._getOrReturnCtx(e, a), i ? l(a, {
|
|
728
728
|
code: d.too_big,
|
|
729
|
-
maximum:
|
|
729
|
+
maximum: r.value,
|
|
730
730
|
type: "string",
|
|
731
731
|
inclusive: !0,
|
|
732
732
|
exact: !0,
|
|
733
|
-
message:
|
|
734
|
-
}) : o && l(
|
|
733
|
+
message: r.message
|
|
734
|
+
}) : o && l(a, {
|
|
735
735
|
code: d.too_small,
|
|
736
|
-
minimum:
|
|
736
|
+
minimum: r.value,
|
|
737
737
|
type: "string",
|
|
738
738
|
inclusive: !0,
|
|
739
739
|
exact: !0,
|
|
740
|
-
message:
|
|
740
|
+
message: r.message
|
|
741
741
|
}), s.dirty());
|
|
742
|
-
} else if (
|
|
743
|
-
|
|
742
|
+
} else if (r.kind === "email")
|
|
743
|
+
Ct.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
744
744
|
validation: "email",
|
|
745
745
|
code: d.invalid_string,
|
|
746
|
-
message:
|
|
746
|
+
message: r.message
|
|
747
747
|
}), s.dirty());
|
|
748
|
-
else if (
|
|
749
|
-
Ae || (Ae = new RegExp(
|
|
748
|
+
else if (r.kind === "emoji")
|
|
749
|
+
Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
750
750
|
validation: "emoji",
|
|
751
751
|
code: d.invalid_string,
|
|
752
|
-
message:
|
|
752
|
+
message: r.message
|
|
753
753
|
}), s.dirty());
|
|
754
|
-
else if (
|
|
755
|
-
|
|
754
|
+
else if (r.kind === "uuid")
|
|
755
|
+
kt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
756
756
|
validation: "uuid",
|
|
757
757
|
code: d.invalid_string,
|
|
758
|
-
message:
|
|
758
|
+
message: r.message
|
|
759
759
|
}), s.dirty());
|
|
760
|
-
else if (
|
|
761
|
-
|
|
760
|
+
else if (r.kind === "nanoid")
|
|
761
|
+
wt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
762
762
|
validation: "nanoid",
|
|
763
763
|
code: d.invalid_string,
|
|
764
|
-
message:
|
|
764
|
+
message: r.message
|
|
765
765
|
}), s.dirty());
|
|
766
|
-
else if (
|
|
767
|
-
|
|
766
|
+
else if (r.kind === "cuid")
|
|
767
|
+
vt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
768
768
|
validation: "cuid",
|
|
769
769
|
code: d.invalid_string,
|
|
770
|
-
message:
|
|
770
|
+
message: r.message
|
|
771
771
|
}), s.dirty());
|
|
772
|
-
else if (
|
|
773
|
-
|
|
772
|
+
else if (r.kind === "cuid2")
|
|
773
|
+
bt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
774
774
|
validation: "cuid2",
|
|
775
775
|
code: d.invalid_string,
|
|
776
|
-
message:
|
|
776
|
+
message: r.message
|
|
777
777
|
}), s.dirty());
|
|
778
|
-
else if (
|
|
779
|
-
|
|
778
|
+
else if (r.kind === "ulid")
|
|
779
|
+
xt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
780
780
|
validation: "ulid",
|
|
781
781
|
code: d.invalid_string,
|
|
782
|
-
message:
|
|
782
|
+
message: r.message
|
|
783
783
|
}), s.dirty());
|
|
784
|
-
else if (
|
|
784
|
+
else if (r.kind === "url")
|
|
785
785
|
try {
|
|
786
786
|
new URL(e.data);
|
|
787
787
|
} catch {
|
|
788
|
-
|
|
788
|
+
a = this._getOrReturnCtx(e, a), l(a, {
|
|
789
789
|
validation: "url",
|
|
790
790
|
code: d.invalid_string,
|
|
791
|
-
message:
|
|
791
|
+
message: r.message
|
|
792
792
|
}), s.dirty();
|
|
793
793
|
}
|
|
794
|
-
else
|
|
794
|
+
else r.kind === "regex" ? (r.regex.lastIndex = 0, r.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
795
795
|
validation: "regex",
|
|
796
796
|
code: d.invalid_string,
|
|
797
|
-
message:
|
|
798
|
-
}), s.dirty())) :
|
|
797
|
+
message: r.message
|
|
798
|
+
}), s.dirty())) : r.kind === "trim" ? e.data = e.data.trim() : r.kind === "includes" ? e.data.includes(r.value, r.position) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
799
799
|
code: d.invalid_string,
|
|
800
|
-
validation: { includes:
|
|
801
|
-
message:
|
|
802
|
-
}), s.dirty()) :
|
|
800
|
+
validation: { includes: r.value, position: r.position },
|
|
801
|
+
message: r.message
|
|
802
|
+
}), s.dirty()) : r.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : r.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : r.kind === "startsWith" ? e.data.startsWith(r.value) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
803
803
|
code: d.invalid_string,
|
|
804
|
-
validation: { startsWith:
|
|
805
|
-
message:
|
|
806
|
-
}), s.dirty()) :
|
|
804
|
+
validation: { startsWith: r.value },
|
|
805
|
+
message: r.message
|
|
806
|
+
}), s.dirty()) : r.kind === "endsWith" ? e.data.endsWith(r.value) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
807
807
|
code: d.invalid_string,
|
|
808
|
-
validation: { endsWith:
|
|
809
|
-
message:
|
|
810
|
-
}), s.dirty()) :
|
|
808
|
+
validation: { endsWith: r.value },
|
|
809
|
+
message: r.message
|
|
810
|
+
}), s.dirty()) : r.kind === "datetime" ? st(r).test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
811
811
|
code: d.invalid_string,
|
|
812
812
|
validation: "datetime",
|
|
813
|
-
message:
|
|
814
|
-
}), s.dirty()) :
|
|
813
|
+
message: r.message
|
|
814
|
+
}), s.dirty()) : r.kind === "date" ? It.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
815
815
|
code: d.invalid_string,
|
|
816
816
|
validation: "date",
|
|
817
|
-
message:
|
|
818
|
-
}), s.dirty()) :
|
|
817
|
+
message: r.message
|
|
818
|
+
}), s.dirty()) : r.kind === "time" ? Zt(r).test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
819
819
|
code: d.invalid_string,
|
|
820
820
|
validation: "time",
|
|
821
|
-
message:
|
|
822
|
-
}), s.dirty()) :
|
|
821
|
+
message: r.message
|
|
822
|
+
}), s.dirty()) : r.kind === "duration" ? Tt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
823
823
|
validation: "duration",
|
|
824
824
|
code: d.invalid_string,
|
|
825
|
-
message:
|
|
826
|
-
}), s.dirty()) :
|
|
825
|
+
message: r.message
|
|
826
|
+
}), s.dirty()) : r.kind === "ip" ? Dt(e.data, r.version) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
827
827
|
validation: "ip",
|
|
828
828
|
code: d.invalid_string,
|
|
829
|
-
message:
|
|
830
|
-
}), s.dirty()) :
|
|
829
|
+
message: r.message
|
|
830
|
+
}), s.dirty()) : r.kind === "jwt" ? Lt(e.data, r.alg) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
831
831
|
validation: "jwt",
|
|
832
832
|
code: d.invalid_string,
|
|
833
|
-
message:
|
|
834
|
-
}), s.dirty()) :
|
|
833
|
+
message: r.message
|
|
834
|
+
}), s.dirty()) : r.kind === "cidr" ? Pt(e.data, r.version) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
835
835
|
validation: "cidr",
|
|
836
836
|
code: d.invalid_string,
|
|
837
|
-
message:
|
|
838
|
-
}), s.dirty()) :
|
|
837
|
+
message: r.message
|
|
838
|
+
}), s.dirty()) : r.kind === "base64" ? $t.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
839
839
|
validation: "base64",
|
|
840
840
|
code: d.invalid_string,
|
|
841
|
-
message:
|
|
842
|
-
}), s.dirty()) :
|
|
841
|
+
message: r.message
|
|
842
|
+
}), s.dirty()) : r.kind === "base64url" ? jt.test(e.data) || (a = this._getOrReturnCtx(e, a), l(a, {
|
|
843
843
|
validation: "base64url",
|
|
844
844
|
code: d.invalid_string,
|
|
845
|
-
message:
|
|
846
|
-
}), s.dirty()) : b.assertNever(
|
|
845
|
+
message: r.message
|
|
846
|
+
}), s.dirty()) : b.assertNever(r);
|
|
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((a) => e.test(a), {
|
|
851
851
|
validation: n,
|
|
852
852
|
code: d.invalid_string,
|
|
853
853
|
...f.errToObj(s)
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
_addCheck(e) {
|
|
857
|
-
return new
|
|
857
|
+
return new I({
|
|
858
858
|
...this._def,
|
|
859
859
|
checks: [...this._def.checks, e]
|
|
860
860
|
});
|
|
@@ -990,19 +990,19 @@ class j extends v {
|
|
|
990
990
|
return this.min(1, f.errToObj(e));
|
|
991
991
|
}
|
|
992
992
|
trim() {
|
|
993
|
-
return new
|
|
993
|
+
return new I({
|
|
994
994
|
...this._def,
|
|
995
995
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
998
|
toLowerCase() {
|
|
999
|
-
return new
|
|
999
|
+
return new I({
|
|
1000
1000
|
...this._def,
|
|
1001
1001
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
toUpperCase() {
|
|
1005
|
-
return new
|
|
1005
|
+
return new I({
|
|
1006
1006
|
...this._def,
|
|
1007
1007
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1008
1008
|
});
|
|
@@ -1068,60 +1068,60 @@ class j extends v {
|
|
|
1068
1068
|
return e;
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
|
-
|
|
1071
|
+
I.create = (t) => new I({
|
|
1072
1072
|
checks: [],
|
|
1073
1073
|
typeName: m.ZodString,
|
|
1074
1074
|
coerce: t?.coerce ?? !1,
|
|
1075
1075
|
...g(t)
|
|
1076
1076
|
});
|
|
1077
|
-
function
|
|
1078
|
-
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length,
|
|
1079
|
-
return
|
|
1077
|
+
function Mt(t, e) {
|
|
1078
|
+
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, a = n > s ? n : s, r = Number.parseInt(t.toFixed(a).replace(".", "")), i = Number.parseInt(e.toFixed(a).replace(".", ""));
|
|
1079
|
+
return r % i / 10 ** a;
|
|
1080
1080
|
}
|
|
1081
|
-
class
|
|
1081
|
+
class Y extends v {
|
|
1082
1082
|
constructor() {
|
|
1083
1083
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
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 r = this._getOrReturnCtx(e);
|
|
1088
|
+
return l(r, {
|
|
1089
1089
|
code: d.invalid_type,
|
|
1090
1090
|
expected: h.number,
|
|
1091
|
-
received:
|
|
1091
|
+
received: r.parsedType
|
|
1092
1092
|
}), y;
|
|
1093
1093
|
}
|
|
1094
1094
|
let s;
|
|
1095
|
-
const
|
|
1096
|
-
for (const
|
|
1097
|
-
|
|
1095
|
+
const a = new C();
|
|
1096
|
+
for (const r of this._def.checks)
|
|
1097
|
+
r.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: r.message
|
|
1102
|
+
}), a.dirty()) : r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1103
1103
|
code: d.too_small,
|
|
1104
|
-
minimum:
|
|
1104
|
+
minimum: r.value,
|
|
1105
1105
|
type: "number",
|
|
1106
|
-
inclusive:
|
|
1106
|
+
inclusive: r.inclusive,
|
|
1107
1107
|
exact: !1,
|
|
1108
|
-
message:
|
|
1109
|
-
}),
|
|
1108
|
+
message: r.message
|
|
1109
|
+
}), a.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1110
1110
|
code: d.too_big,
|
|
1111
|
-
maximum:
|
|
1111
|
+
maximum: r.value,
|
|
1112
1112
|
type: "number",
|
|
1113
|
-
inclusive:
|
|
1113
|
+
inclusive: r.inclusive,
|
|
1114
1114
|
exact: !1,
|
|
1115
|
-
message:
|
|
1116
|
-
}),
|
|
1115
|
+
message: r.message
|
|
1116
|
+
}), a.dirty()) : r.kind === "multipleOf" ? Mt(e.data, r.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1117
1117
|
code: d.not_multiple_of,
|
|
1118
|
-
multipleOf:
|
|
1119
|
-
message:
|
|
1120
|
-
}),
|
|
1118
|
+
multipleOf: r.value,
|
|
1119
|
+
message: r.message
|
|
1120
|
+
}), a.dirty()) : r.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: r.message
|
|
1123
|
+
}), a.dirty()) : b.assertNever(r);
|
|
1124
|
+
return { status: a.value, value: e.data };
|
|
1125
1125
|
}
|
|
1126
1126
|
gte(e, n) {
|
|
1127
1127
|
return this.setLimit("min", e, !0, f.toString(n));
|
|
@@ -1135,8 +1135,8 @@ class J 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,
|
|
1139
|
-
return new
|
|
1138
|
+
setLimit(e, n, s, a) {
|
|
1139
|
+
return new Y({
|
|
1140
1140
|
...this._def,
|
|
1141
1141
|
checks: [
|
|
1142
1142
|
...this._def.checks,
|
|
@@ -1144,13 +1144,13 @@ class J extends v {
|
|
|
1144
1144
|
kind: e,
|
|
1145
1145
|
value: n,
|
|
1146
1146
|
inclusive: s,
|
|
1147
|
-
message: f.toString(
|
|
1147
|
+
message: f.toString(a)
|
|
1148
1148
|
}
|
|
1149
1149
|
]
|
|
1150
1150
|
});
|
|
1151
1151
|
}
|
|
1152
1152
|
_addCheck(e) {
|
|
1153
|
-
return new
|
|
1153
|
+
return new Y({
|
|
1154
1154
|
...this._def,
|
|
1155
1155
|
checks: [...this._def.checks, e]
|
|
1156
1156
|
});
|
|
@@ -1244,13 +1244,13 @@ class J extends v {
|
|
|
1244
1244
|
return Number.isFinite(n) && Number.isFinite(e);
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
Y.create = (t) => new Y({
|
|
1248
1248
|
checks: [],
|
|
1249
1249
|
typeName: m.ZodNumber,
|
|
1250
1250
|
coerce: t?.coerce || !1,
|
|
1251
1251
|
...g(t)
|
|
1252
1252
|
});
|
|
1253
|
-
class
|
|
1253
|
+
class ne extends v {
|
|
1254
1254
|
constructor() {
|
|
1255
1255
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1256
1256
|
}
|
|
@@ -1264,26 +1264,26 @@ class te 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 a = new C();
|
|
1268
|
+
for (const r of this._def.checks)
|
|
1269
|
+
r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.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: r.value,
|
|
1273
|
+
inclusive: r.inclusive,
|
|
1274
|
+
message: r.message
|
|
1275
|
+
}), a.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.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: r.value,
|
|
1279
|
+
inclusive: r.inclusive,
|
|
1280
|
+
message: r.message
|
|
1281
|
+
}), a.dirty()) : r.kind === "multipleOf" ? e.data % r.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: r.value,
|
|
1284
|
+
message: r.message
|
|
1285
|
+
}), a.dirty()) : b.assertNever(r);
|
|
1286
|
+
return { status: a.value, value: e.data };
|
|
1287
1287
|
}
|
|
1288
1288
|
_getInvalidInput(e) {
|
|
1289
1289
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1305,8 +1305,8 @@ class te 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,
|
|
1309
|
-
return new
|
|
1308
|
+
setLimit(e, n, s, a) {
|
|
1309
|
+
return new ne({
|
|
1310
1310
|
...this._def,
|
|
1311
1311
|
checks: [
|
|
1312
1312
|
...this._def.checks,
|
|
@@ -1314,13 +1314,13 @@ class te extends v {
|
|
|
1314
1314
|
kind: e,
|
|
1315
1315
|
value: n,
|
|
1316
1316
|
inclusive: s,
|
|
1317
|
-
message: f.toString(
|
|
1317
|
+
message: f.toString(a)
|
|
1318
1318
|
}
|
|
1319
1319
|
]
|
|
1320
1320
|
});
|
|
1321
1321
|
}
|
|
1322
1322
|
_addCheck(e) {
|
|
1323
|
-
return new
|
|
1323
|
+
return new ne({
|
|
1324
1324
|
...this._def,
|
|
1325
1325
|
checks: [...this._def.checks, e]
|
|
1326
1326
|
});
|
|
@@ -1377,7 +1377,7 @@ class te extends v {
|
|
|
1377
1377
|
return e;
|
|
1378
1378
|
}
|
|
1379
1379
|
}
|
|
1380
|
-
|
|
1380
|
+
ne.create = (t) => new ne({
|
|
1381
1381
|
checks: [],
|
|
1382
1382
|
typeName: m.ZodBigInt,
|
|
1383
1383
|
coerce: t?.coerce ?? !1,
|
|
@@ -1401,47 +1401,47 @@ me.create = (t) => new me({
|
|
|
1401
1401
|
coerce: t?.coerce || !1,
|
|
1402
1402
|
...g(t)
|
|
1403
1403
|
});
|
|
1404
|
-
class
|
|
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 r = this._getOrReturnCtx(e);
|
|
1408
|
+
return l(r, {
|
|
1409
1409
|
code: d.invalid_type,
|
|
1410
1410
|
expected: h.date,
|
|
1411
|
-
received:
|
|
1411
|
+
received: r.parsedType
|
|
1412
1412
|
}), y;
|
|
1413
1413
|
}
|
|
1414
1414
|
if (Number.isNaN(e.data.getTime())) {
|
|
1415
|
-
const
|
|
1416
|
-
return l(
|
|
1415
|
+
const r = this._getOrReturnCtx(e);
|
|
1416
|
+
return l(r, {
|
|
1417
1417
|
code: d.invalid_date
|
|
1418
1418
|
}), y;
|
|
1419
1419
|
}
|
|
1420
1420
|
const s = new C();
|
|
1421
|
-
let
|
|
1422
|
-
for (const
|
|
1423
|
-
|
|
1421
|
+
let a;
|
|
1422
|
+
for (const r of this._def.checks)
|
|
1423
|
+
r.kind === "min" ? e.data.getTime() < r.value && (a = this._getOrReturnCtx(e, a), l(a, {
|
|
1424
1424
|
code: d.too_small,
|
|
1425
|
-
message:
|
|
1425
|
+
message: r.message,
|
|
1426
1426
|
inclusive: !0,
|
|
1427
1427
|
exact: !1,
|
|
1428
|
-
minimum:
|
|
1428
|
+
minimum: r.value,
|
|
1429
1429
|
type: "date"
|
|
1430
|
-
}), s.dirty()) :
|
|
1430
|
+
}), s.dirty()) : r.kind === "max" ? e.data.getTime() > r.value && (a = this._getOrReturnCtx(e, a), l(a, {
|
|
1431
1431
|
code: d.too_big,
|
|
1432
|
-
message:
|
|
1432
|
+
message: r.message,
|
|
1433
1433
|
inclusive: !0,
|
|
1434
1434
|
exact: !1,
|
|
1435
|
-
maximum:
|
|
1435
|
+
maximum: r.value,
|
|
1436
1436
|
type: "date"
|
|
1437
|
-
}), s.dirty()) : b.assertNever(
|
|
1437
|
+
}), s.dirty()) : b.assertNever(r);
|
|
1438
1438
|
return {
|
|
1439
1439
|
status: s.value,
|
|
1440
1440
|
value: new Date(e.data.getTime())
|
|
1441
1441
|
};
|
|
1442
1442
|
}
|
|
1443
1443
|
_addCheck(e) {
|
|
1444
|
-
return new
|
|
1444
|
+
return new ce({
|
|
1445
1445
|
...this._def,
|
|
1446
1446
|
checks: [...this._def.checks, e]
|
|
1447
1447
|
});
|
|
@@ -1473,13 +1473,13 @@ class oe extends v {
|
|
|
1473
1473
|
return e != null ? new Date(e) : null;
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
|
-
|
|
1476
|
+
ce.create = (t) => new ce({
|
|
1477
1477
|
checks: [],
|
|
1478
1478
|
coerce: t?.coerce || !1,
|
|
1479
1479
|
typeName: m.ZodDate,
|
|
1480
1480
|
...g(t)
|
|
1481
1481
|
});
|
|
1482
|
-
class
|
|
1482
|
+
class Ie extends v {
|
|
1483
1483
|
_parse(e) {
|
|
1484
1484
|
if (this._getType(e) !== h.symbol) {
|
|
1485
1485
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1492,7 +1492,7 @@ class je extends v {
|
|
|
1492
1492
|
return N(e.data);
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
|
|
1495
|
+
Ie.create = (t) => new Ie({
|
|
1496
1496
|
typeName: m.ZodSymbol,
|
|
1497
1497
|
...g(t)
|
|
1498
1498
|
});
|
|
@@ -1554,7 +1554,7 @@ Pe.create = (t) => new Pe({
|
|
|
1554
1554
|
typeName: m.ZodUnknown,
|
|
1555
1555
|
...g(t)
|
|
1556
1556
|
});
|
|
1557
|
-
class
|
|
1557
|
+
class B extends v {
|
|
1558
1558
|
_parse(e) {
|
|
1559
1559
|
const n = this._getOrReturnCtx(e);
|
|
1560
1560
|
return l(n, {
|
|
@@ -1564,7 +1564,7 @@ class z extends v {
|
|
|
1564
1564
|
}), y;
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
|
-
|
|
1567
|
+
B.create = (t) => new B({
|
|
1568
1568
|
typeName: m.ZodNever,
|
|
1569
1569
|
...g(t)
|
|
1570
1570
|
});
|
|
@@ -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), a = 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
1596
|
}), y;
|
|
1597
|
-
if (
|
|
1598
|
-
const i = n.data.length >
|
|
1597
|
+
if (a.exactLength !== null) {
|
|
1598
|
+
const i = n.data.length > a.exactLength.value, o = n.data.length < a.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 ? a.exactLength.value : void 0,
|
|
1602
|
+
maximum: i ? a.exactLength.value : void 0,
|
|
1603
1603
|
type: "array",
|
|
1604
1604
|
inclusive: !0,
|
|
1605
1605
|
exact: !0,
|
|
1606
|
-
message:
|
|
1606
|
+
message: a.exactLength.message
|
|
1607
1607
|
}), s.dirty());
|
|
1608
1608
|
}
|
|
1609
|
-
if (
|
|
1609
|
+
if (a.minLength !== null && n.data.length < a.minLength.value && (l(n, {
|
|
1610
1610
|
code: d.too_small,
|
|
1611
|
-
minimum:
|
|
1611
|
+
minimum: a.minLength.value,
|
|
1612
1612
|
type: "array",
|
|
1613
1613
|
inclusive: !0,
|
|
1614
1614
|
exact: !1,
|
|
1615
|
-
message:
|
|
1616
|
-
}), s.dirty()),
|
|
1615
|
+
message: a.minLength.message
|
|
1616
|
+
}), s.dirty()), a.maxLength !== null && n.data.length > a.maxLength.value && (l(n, {
|
|
1617
1617
|
code: d.too_big,
|
|
1618
|
-
maximum:
|
|
1618
|
+
maximum: a.maxLength.value,
|
|
1619
1619
|
type: "array",
|
|
1620
1620
|
inclusive: !0,
|
|
1621
1621
|
exact: !1,
|
|
1622
|
-
message:
|
|
1622
|
+
message: a.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) => a.type._parseAsync(new D(n, i, n.path, o)))).then((i) => C.mergeArray(s, i));
|
|
1625
|
+
const r = [...n.data].map((i, o) => a.type._parseSync(new D(n, i, n.path, o)));
|
|
1626
|
+
return C.mergeArray(s, r);
|
|
1627
1627
|
}
|
|
1628
1628
|
get element() {
|
|
1629
1629
|
return this._def.type;
|
|
@@ -1658,12 +1658,12 @@ R.create = (t, e) => new R({
|
|
|
1658
1658
|
typeName: m.ZodArray,
|
|
1659
1659
|
...g(e)
|
|
1660
1660
|
});
|
|
1661
|
-
function
|
|
1661
|
+
function ee(t) {
|
|
1662
1662
|
if (t instanceof w) {
|
|
1663
1663
|
const e = {};
|
|
1664
1664
|
for (const n in t.shape) {
|
|
1665
1665
|
const s = t.shape[n];
|
|
1666
|
-
e[n] = V.create(
|
|
1666
|
+
e[n] = V.create(ee(s));
|
|
1667
1667
|
}
|
|
1668
1668
|
return new w({
|
|
1669
1669
|
...t._def,
|
|
@@ -1671,8 +1671,8 @@ function X(t) {
|
|
|
1671
1671
|
});
|
|
1672
1672
|
} else return t instanceof R ? new R({
|
|
1673
1673
|
...t._def,
|
|
1674
|
-
type:
|
|
1675
|
-
}) : t instanceof V ? V.create(
|
|
1674
|
+
type: ee(t.element)
|
|
1675
|
+
}) : t instanceof V ? V.create(ee(t.unwrap())) : t instanceof G ? G.create(ee(t.unwrap())) : t instanceof F ? F.create(t.items.map((e) => ee(e))) : t;
|
|
1676
1676
|
}
|
|
1677
1677
|
class w extends v {
|
|
1678
1678
|
constructor() {
|
|
@@ -1693,29 +1693,29 @@ class w extends v {
|
|
|
1693
1693
|
received: u.parsedType
|
|
1694
1694
|
}), y;
|
|
1695
1695
|
}
|
|
1696
|
-
const { status: s, ctx:
|
|
1697
|
-
if (!(this._def.catchall instanceof
|
|
1698
|
-
for (const u in
|
|
1696
|
+
const { status: s, ctx: a } = this._processInputParams(e), { shape: r, keys: i } = this._getCached(), o = [];
|
|
1697
|
+
if (!(this._def.catchall instanceof B && this._def.unknownKeys === "strip"))
|
|
1698
|
+
for (const u in a.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 = r[u], k = a.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(a, k, a.path, u)),
|
|
1706
|
+
alwaysSet: u in a.data
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
1709
|
-
if (this._def.catchall instanceof
|
|
1709
|
+
if (this._def.catchall instanceof B) {
|
|
1710
1710
|
const u = this._def.unknownKeys;
|
|
1711
1711
|
if (u === "passthrough")
|
|
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: a.data[p] }
|
|
1716
1716
|
});
|
|
1717
1717
|
else if (u === "strict")
|
|
1718
|
-
o.length > 0 && (l(
|
|
1718
|
+
o.length > 0 && (l(a, {
|
|
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 = a.data[p];
|
|
1727
1727
|
c.push({
|
|
1728
1728
|
key: { status: "valid", value: p },
|
|
1729
1729
|
value: u._parse(
|
|
1730
|
-
new D(
|
|
1730
|
+
new D(a, k, a.path, p)
|
|
1731
1731
|
//, ctx.child(key), value, getParsedType(value)
|
|
1732
1732
|
),
|
|
1733
|
-
alwaysSet: p in
|
|
1733
|
+
alwaysSet: p in a.data
|
|
1734
1734
|
});
|
|
1735
1735
|
}
|
|
1736
1736
|
}
|
|
1737
|
-
return
|
|
1737
|
+
return a.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 a = 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 ?? a
|
|
1762
1762
|
} : {
|
|
1763
|
-
message:
|
|
1763
|
+
message: a
|
|
1764
1764
|
};
|
|
1765
1765
|
}
|
|
1766
1766
|
} : {}
|
|
@@ -1907,13 +1907,13 @@ class w extends v {
|
|
|
1907
1907
|
* @deprecated
|
|
1908
1908
|
*/
|
|
1909
1909
|
deepPartial() {
|
|
1910
|
-
return
|
|
1910
|
+
return ee(this);
|
|
1911
1911
|
}
|
|
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 a = this.shape[s];
|
|
1916
|
+
e && !e[s] ? n[s] = a : n[s] = a.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 r = this.shape[s];
|
|
1930
|
+
for (; r instanceof V; )
|
|
1931
|
+
r = r._def.innerType;
|
|
1932
|
+
n[s] = r;
|
|
1933
1933
|
}
|
|
1934
1934
|
return new w({
|
|
1935
1935
|
...this._def,
|
|
@@ -1937,48 +1937,48 @@ class w extends v {
|
|
|
1937
1937
|
});
|
|
1938
1938
|
}
|
|
1939
1939
|
keyof() {
|
|
1940
|
-
return
|
|
1940
|
+
return at(b.objectKeys(this.shape));
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
1943
|
w.create = (t, e) => new w({
|
|
1944
1944
|
shape: () => t,
|
|
1945
1945
|
unknownKeys: "strip",
|
|
1946
|
-
catchall:
|
|
1946
|
+
catchall: B.create(),
|
|
1947
1947
|
typeName: m.ZodObject,
|
|
1948
1948
|
...g(e)
|
|
1949
1949
|
});
|
|
1950
1950
|
w.strictCreate = (t, e) => new w({
|
|
1951
1951
|
shape: () => t,
|
|
1952
1952
|
unknownKeys: "strict",
|
|
1953
|
-
catchall:
|
|
1953
|
+
catchall: B.create(),
|
|
1954
1954
|
typeName: m.ZodObject,
|
|
1955
1955
|
...g(e)
|
|
1956
1956
|
});
|
|
1957
1957
|
w.lazycreate = (t, e) => new w({
|
|
1958
1958
|
shape: t,
|
|
1959
1959
|
unknownKeys: "strip",
|
|
1960
|
-
catchall:
|
|
1960
|
+
catchall: B.create(),
|
|
1961
1961
|
typeName: m.ZodObject,
|
|
1962
1962
|
...g(e)
|
|
1963
1963
|
});
|
|
1964
|
-
class
|
|
1964
|
+
class de extends v {
|
|
1965
1965
|
_parse(e) {
|
|
1966
1966
|
const { ctx: n } = this._processInputParams(e), s = this._def.options;
|
|
1967
|
-
function r
|
|
1968
|
-
for (const o of
|
|
1967
|
+
function a(r) {
|
|
1968
|
+
for (const o of r)
|
|
1969
1969
|
if (o.result.status === "valid")
|
|
1970
1970
|
return o.result;
|
|
1971
|
-
for (const o of
|
|
1971
|
+
for (const o of r)
|
|
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 = r.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
|
}), y;
|
|
1979
1979
|
}
|
|
1980
1980
|
if (n.common.async)
|
|
1981
|
-
return Promise.all(s.map(async (
|
|
1981
|
+
return Promise.all(s.map(async (r) => {
|
|
1982
1982
|
const i = {
|
|
1983
1983
|
...n,
|
|
1984
1984
|
common: {
|
|
@@ -1988,16 +1988,16 @@ class ce extends v {
|
|
|
1988
1988
|
parent: null
|
|
1989
1989
|
};
|
|
1990
1990
|
return {
|
|
1991
|
-
result: await
|
|
1991
|
+
result: await r._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(a);
|
|
1999
1999
|
{
|
|
2000
|
-
let
|
|
2000
|
+
let r;
|
|
2001
2001
|
const i = [];
|
|
2002
2002
|
for (const c of s) {
|
|
2003
2003
|
const u = {
|
|
@@ -2014,10 +2014,10 @@ class ce extends v {
|
|
|
2014
2014
|
});
|
|
2015
2015
|
if (p.status === "valid")
|
|
2016
2016
|
return p;
|
|
2017
|
-
p.status === "dirty" && !
|
|
2017
|
+
p.status === "dirty" && !r && (r = { 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 (r)
|
|
2020
|
+
return n.common.issues.push(...r.ctx.common.issues), r.result;
|
|
2021
2021
|
const o = i.map((c) => new Z(c));
|
|
2022
2022
|
return l(n, {
|
|
2023
2023
|
code: d.invalid_union,
|
|
@@ -2029,7 +2029,7 @@ class ce extends v {
|
|
|
2029
2029
|
return this._def.options;
|
|
2030
2030
|
}
|
|
2031
2031
|
}
|
|
2032
|
-
|
|
2032
|
+
de.create = (t, e) => new de({
|
|
2033
2033
|
options: t,
|
|
2034
2034
|
typeName: m.ZodUnion,
|
|
2035
2035
|
...g(e)
|
|
@@ -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 a = b.objectKeys(e), r = b.objectKeys(t).filter((o) => a.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2043
|
+
for (const o of r) {
|
|
2044
2044
|
const c = Ve(t[o], e[o]);
|
|
2045
2045
|
if (!c.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
@@ -2050,23 +2050,23 @@ 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 a = [];
|
|
2054
|
+
for (let r = 0; r < t.length; r++) {
|
|
2055
|
+
const i = t[r], o = e[r], c = Ve(i, o);
|
|
2056
2056
|
if (!c.valid)
|
|
2057
2057
|
return { valid: !1 };
|
|
2058
|
-
|
|
2058
|
+
a.push(c.data);
|
|
2059
2059
|
}
|
|
2060
|
-
return { valid: !0, data:
|
|
2060
|
+
return { valid: !0, data: a };
|
|
2061
2061
|
} else return n === h.date && s === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2062
2062
|
}
|
|
2063
|
-
class
|
|
2063
|
+
class ue extends v {
|
|
2064
2064
|
_parse(e) {
|
|
2065
|
-
const { status: n, ctx: s } = this._processInputParams(e),
|
|
2066
|
-
if ($e(
|
|
2065
|
+
const { status: n, ctx: s } = this._processInputParams(e), a = (r, i) => {
|
|
2066
|
+
if ($e(r) || $e(i))
|
|
2067
2067
|
return y;
|
|
2068
|
-
const o = Ve(
|
|
2069
|
-
return o.valid ? ((
|
|
2068
|
+
const o = Ve(r.value, i.value);
|
|
2069
|
+
return o.valid ? ((je(r) || je(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
2070
|
code: d.invalid_intersection_types
|
|
2071
2071
|
}), y);
|
|
2072
2072
|
};
|
|
@@ -2081,7 +2081,7 @@ class de extends v {
|
|
|
2081
2081
|
path: s.path,
|
|
2082
2082
|
parent: s
|
|
2083
2083
|
})
|
|
2084
|
-
]).then(([
|
|
2084
|
+
]).then(([r, i]) => a(r, i)) : a(this._def.left._parseSync({
|
|
2085
2085
|
data: s.data,
|
|
2086
2086
|
path: s.path,
|
|
2087
2087
|
parent: s
|
|
@@ -2092,7 +2092,7 @@ class de extends v {
|
|
|
2092
2092
|
}));
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
|
|
2095
|
+
ue.create = (t, e, n) => new ue({
|
|
2096
2096
|
left: t,
|
|
2097
2097
|
right: e,
|
|
2098
2098
|
typeName: m.ZodIntersection,
|
|
@@ -2122,11 +2122,11 @@ class F extends v {
|
|
|
2122
2122
|
exact: !1,
|
|
2123
2123
|
type: "array"
|
|
2124
2124
|
}), n.dirty());
|
|
2125
|
-
const
|
|
2125
|
+
const r = [...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(r).then((i) => C.mergeArray(n, i)) : C.mergeArray(n, r);
|
|
2130
2130
|
}
|
|
2131
2131
|
get items() {
|
|
2132
2132
|
return this._def.items;
|
|
@@ -2148,7 +2148,7 @@ F.create = (t, e) => {
|
|
|
2148
2148
|
...g(e)
|
|
2149
2149
|
});
|
|
2150
2150
|
};
|
|
2151
|
-
class
|
|
2151
|
+
class le extends v {
|
|
2152
2152
|
get keySchema() {
|
|
2153
2153
|
return this._def.keyType;
|
|
2154
2154
|
}
|
|
@@ -2163,33 +2163,33 @@ class ue extends v {
|
|
|
2163
2163
|
expected: h.object,
|
|
2164
2164
|
received: s.parsedType
|
|
2165
2165
|
}), y;
|
|
2166
|
-
const
|
|
2166
|
+
const a = [], r = this._def.keyType, i = this._def.valueType;
|
|
2167
2167
|
for (const o in s.data)
|
|
2168
|
-
|
|
2169
|
-
key:
|
|
2168
|
+
a.push({
|
|
2169
|
+
key: r._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, a) : C.mergeObjectSync(n, a);
|
|
2174
2174
|
}
|
|
2175
2175
|
get element() {
|
|
2176
2176
|
return this._def.valueType;
|
|
2177
2177
|
}
|
|
2178
2178
|
static create(e, n, s) {
|
|
2179
|
-
return n instanceof v ? new
|
|
2179
|
+
return n instanceof v ? new le({
|
|
2180
2180
|
keyType: e,
|
|
2181
2181
|
valueType: n,
|
|
2182
2182
|
typeName: m.ZodRecord,
|
|
2183
2183
|
...g(s)
|
|
2184
|
-
}) : new
|
|
2185
|
-
keyType:
|
|
2184
|
+
}) : new le({
|
|
2185
|
+
keyType: I.create(),
|
|
2186
2186
|
valueType: e,
|
|
2187
2187
|
typeName: m.ZodRecord,
|
|
2188
2188
|
...g(n)
|
|
2189
2189
|
});
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
-
class
|
|
2192
|
+
class Be extends v {
|
|
2193
2193
|
get keySchema() {
|
|
2194
2194
|
return this._def.keyType;
|
|
2195
2195
|
}
|
|
@@ -2204,9 +2204,9 @@ class ze extends v {
|
|
|
2204
2204
|
expected: h.map,
|
|
2205
2205
|
received: s.parsedType
|
|
2206
2206
|
}), y;
|
|
2207
|
-
const
|
|
2208
|
-
key:
|
|
2209
|
-
value:
|
|
2207
|
+
const a = this._def.keyType, r = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2208
|
+
key: a._parse(new D(s, o, s.path, [u, "key"])),
|
|
2209
|
+
value: r._parse(new D(s, c, s.path, [u, "value"]))
|
|
2210
2210
|
}));
|
|
2211
2211
|
if (s.common.async) {
|
|
2212
2212
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2231,13 +2231,13 @@ class ze extends v {
|
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
|
-
|
|
2234
|
+
Be.create = (t, e, n) => new Be({
|
|
2235
2235
|
valueType: e,
|
|
2236
2236
|
keyType: t,
|
|
2237
2237
|
typeName: m.ZodMap,
|
|
2238
2238
|
...g(n)
|
|
2239
2239
|
});
|
|
2240
|
-
class
|
|
2240
|
+
class se extends v {
|
|
2241
2241
|
_parse(e) {
|
|
2242
2242
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2243
2243
|
if (s.parsedType !== h.set)
|
|
@@ -2246,23 +2246,23 @@ class ne extends v {
|
|
|
2246
2246
|
expected: h.set,
|
|
2247
2247
|
received: s.parsedType
|
|
2248
2248
|
}), y;
|
|
2249
|
-
const
|
|
2250
|
-
|
|
2249
|
+
const a = this._def;
|
|
2250
|
+
a.minSize !== null && s.data.size < a.minSize.value && (l(s, {
|
|
2251
2251
|
code: d.too_small,
|
|
2252
|
-
minimum:
|
|
2252
|
+
minimum: a.minSize.value,
|
|
2253
2253
|
type: "set",
|
|
2254
2254
|
inclusive: !0,
|
|
2255
2255
|
exact: !1,
|
|
2256
|
-
message:
|
|
2257
|
-
}), n.dirty()),
|
|
2256
|
+
message: a.minSize.message
|
|
2257
|
+
}), n.dirty()), a.maxSize !== null && s.data.size > a.maxSize.value && (l(s, {
|
|
2258
2258
|
code: d.too_big,
|
|
2259
|
-
maximum:
|
|
2259
|
+
maximum: a.maxSize.value,
|
|
2260
2260
|
type: "set",
|
|
2261
2261
|
inclusive: !0,
|
|
2262
2262
|
exact: !1,
|
|
2263
|
-
message:
|
|
2263
|
+
message: a.maxSize.message
|
|
2264
2264
|
}), n.dirty());
|
|
2265
|
-
const
|
|
2265
|
+
const r = this._def.valueType;
|
|
2266
2266
|
function i(c) {
|
|
2267
2267
|
const u = /* @__PURE__ */ new Set();
|
|
2268
2268
|
for (const p of c) {
|
|
@@ -2272,17 +2272,17 @@ class ne extends v {
|
|
|
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) => r._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) {
|
|
2279
|
-
return new
|
|
2279
|
+
return new se({
|
|
2280
2280
|
...this._def,
|
|
2281
2281
|
minSize: { value: e, message: f.toString(n) }
|
|
2282
2282
|
});
|
|
2283
2283
|
}
|
|
2284
2284
|
max(e, n) {
|
|
2285
|
-
return new
|
|
2285
|
+
return new se({
|
|
2286
2286
|
...this._def,
|
|
2287
2287
|
maxSize: { value: e, message: f.toString(n) }
|
|
2288
2288
|
});
|
|
@@ -2294,14 +2294,14 @@ class ne extends v {
|
|
|
2294
2294
|
return this.min(1, e);
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
2297
|
-
|
|
2297
|
+
se.create = (t, e) => new se({
|
|
2298
2298
|
valueType: t,
|
|
2299
2299
|
minSize: null,
|
|
2300
2300
|
maxSize: null,
|
|
2301
2301
|
typeName: m.ZodSet,
|
|
2302
2302
|
...g(e)
|
|
2303
2303
|
});
|
|
2304
|
-
class
|
|
2304
|
+
class ze extends v {
|
|
2305
2305
|
get schema() {
|
|
2306
2306
|
return this._def.getter();
|
|
2307
2307
|
}
|
|
@@ -2310,7 +2310,7 @@ class Be extends v {
|
|
|
2310
2310
|
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2311
2311
|
}
|
|
2312
2312
|
}
|
|
2313
|
-
|
|
2313
|
+
ze.create = (t, e) => new ze({
|
|
2314
2314
|
getter: t,
|
|
2315
2315
|
typeName: m.ZodLazy,
|
|
2316
2316
|
...g(e)
|
|
@@ -2336,14 +2336,14 @@ Fe.create = (t, e) => new Fe({
|
|
|
2336
2336
|
typeName: m.ZodLiteral,
|
|
2337
2337
|
...g(e)
|
|
2338
2338
|
});
|
|
2339
|
-
function
|
|
2340
|
-
return new
|
|
2339
|
+
function at(t, e) {
|
|
2340
|
+
return new K({
|
|
2341
2341
|
values: t,
|
|
2342
2342
|
typeName: m.ZodEnum,
|
|
2343
2343
|
...g(e)
|
|
2344
2344
|
});
|
|
2345
2345
|
}
|
|
2346
|
-
class
|
|
2346
|
+
class K extends v {
|
|
2347
2347
|
_parse(e) {
|
|
2348
2348
|
if (typeof e.data != "string") {
|
|
2349
2349
|
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
@@ -2385,36 +2385,36 @@ class Y extends v {
|
|
|
2385
2385
|
return e;
|
|
2386
2386
|
}
|
|
2387
2387
|
extract(e, n = this._def) {
|
|
2388
|
-
return
|
|
2388
|
+
return K.create(e, {
|
|
2389
2389
|
...this._def,
|
|
2390
2390
|
...n
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
2393
|
exclude(e, n = this._def) {
|
|
2394
|
-
return
|
|
2394
|
+
return K.create(this.options.filter((s) => !e.includes(s)), {
|
|
2395
2395
|
...this._def,
|
|
2396
2396
|
...n
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
|
|
2400
|
+
K.create = at;
|
|
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 a = b.objectValues(n);
|
|
2406
2406
|
return l(s, {
|
|
2407
|
-
expected: b.joinValues(
|
|
2407
|
+
expected: b.joinValues(a),
|
|
2408
2408
|
received: s.parsedType,
|
|
2409
2409
|
code: d.invalid_type
|
|
2410
2410
|
}), y;
|
|
2411
2411
|
}
|
|
2412
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2413
|
-
const
|
|
2413
|
+
const a = b.objectValues(n);
|
|
2414
2414
|
return l(s, {
|
|
2415
2415
|
received: s.data,
|
|
2416
2416
|
code: d.invalid_enum_value,
|
|
2417
|
-
options:
|
|
2417
|
+
options: a
|
|
2418
2418
|
}), y;
|
|
2419
2419
|
}
|
|
2420
2420
|
return N(e.data);
|
|
@@ -2428,7 +2428,7 @@ Ue.create = (t, e) => new Ue({
|
|
|
2428
2428
|
typeName: m.ZodNativeEnum,
|
|
2429
2429
|
...g(e)
|
|
2430
2430
|
});
|
|
2431
|
-
class
|
|
2431
|
+
class he extends v {
|
|
2432
2432
|
unwrap() {
|
|
2433
2433
|
return this._def.type;
|
|
2434
2434
|
}
|
|
@@ -2441,13 +2441,13 @@ class le extends v {
|
|
|
2441
2441
|
received: n.parsedType
|
|
2442
2442
|
}), y;
|
|
2443
2443
|
const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2444
|
-
return N(s.then((
|
|
2444
|
+
return N(s.then((a) => this._def.type.parseAsync(a, {
|
|
2445
2445
|
path: n.path,
|
|
2446
2446
|
errorMap: n.common.contextualErrorMap
|
|
2447
2447
|
})));
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
|
|
2450
|
+
he.create = (t, e) => new he({
|
|
2451
2451
|
type: t,
|
|
2452
2452
|
typeName: m.ZodPromise,
|
|
2453
2453
|
...g(e)
|
|
@@ -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), a = this._def.effect || null, r = {
|
|
2464
2464
|
addIssue: (i) => {
|
|
2465
2465
|
l(s, i), i.fatal ? n.abort() : n.dirty();
|
|
2466
2466
|
},
|
|
@@ -2468,8 +2468,8 @@ class U extends v {
|
|
|
2468
2468
|
return s.path;
|
|
2469
2469
|
}
|
|
2470
2470
|
};
|
|
2471
|
-
if (
|
|
2472
|
-
const i =
|
|
2471
|
+
if (r.addIssue = r.addIssue.bind(r), a.type === "preprocess") {
|
|
2472
|
+
const i = a.transform(s.data, r);
|
|
2473
2473
|
if (s.common.async)
|
|
2474
2474
|
return Promise.resolve(i).then(async (o) => {
|
|
2475
2475
|
if (n.value === "aborted")
|
|
@@ -2479,7 +2479,7 @@ class U extends v {
|
|
|
2479
2479
|
path: s.path,
|
|
2480
2480
|
parent: s
|
|
2481
2481
|
});
|
|
2482
|
-
return c.status === "aborted" ? y : c.status === "dirty" || n.value === "dirty" ?
|
|
2482
|
+
return c.status === "aborted" ? y : c.status === "dirty" || n.value === "dirty" ? te(c.value) : c;
|
|
2483
2483
|
});
|
|
2484
2484
|
{
|
|
2485
2485
|
if (n.value === "aborted")
|
|
@@ -2489,12 +2489,12 @@ class U extends v {
|
|
|
2489
2489
|
path: s.path,
|
|
2490
2490
|
parent: s
|
|
2491
2491
|
});
|
|
2492
|
-
return o.status === "aborted" ? y : o.status === "dirty" || n.value === "dirty" ?
|
|
2492
|
+
return o.status === "aborted" ? y : o.status === "dirty" || n.value === "dirty" ? te(o.value) : o;
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
|
-
if (
|
|
2495
|
+
if (a.type === "refinement") {
|
|
2496
2496
|
const i = (o) => {
|
|
2497
|
-
const c =
|
|
2497
|
+
const c = a.refinement(o, r);
|
|
2498
2498
|
if (s.common.async)
|
|
2499
2499
|
return Promise.resolve(c);
|
|
2500
2500
|
if (c instanceof Promise)
|
|
@@ -2511,25 +2511,25 @@ class U extends v {
|
|
|
2511
2511
|
} else
|
|
2512
2512
|
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && n.dirty(), i(o.value).then(() => ({ status: n.value, value: o.value }))));
|
|
2513
2513
|
}
|
|
2514
|
-
if (
|
|
2514
|
+
if (a.type === "transform")
|
|
2515
2515
|
if (s.common.async === !1) {
|
|
2516
2516
|
const i = this._def.schema._parseSync({
|
|
2517
2517
|
data: s.data,
|
|
2518
2518
|
path: s.path,
|
|
2519
2519
|
parent: s
|
|
2520
2520
|
});
|
|
2521
|
-
if (!
|
|
2521
|
+
if (!J(i))
|
|
2522
2522
|
return y;
|
|
2523
|
-
const o =
|
|
2523
|
+
const o = a.transform(i.value, r);
|
|
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) =>
|
|
2528
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => J(i) ? Promise.resolve(a.transform(i.value, r)).then((o) => ({
|
|
2529
2529
|
status: n.value,
|
|
2530
2530
|
value: o
|
|
2531
2531
|
})) : y);
|
|
2532
|
-
b.assertNever(
|
|
2532
|
+
b.assertNever(a);
|
|
2533
2533
|
}
|
|
2534
2534
|
}
|
|
2535
2535
|
U.create = (t, e, n) => new U({
|
|
@@ -2557,7 +2557,7 @@ V.create = (t, e) => new V({
|
|
|
2557
2557
|
typeName: m.ZodOptional,
|
|
2558
2558
|
...g(e)
|
|
2559
2559
|
});
|
|
2560
|
-
class
|
|
2560
|
+
class G extends v {
|
|
2561
2561
|
_parse(e) {
|
|
2562
2562
|
return this._getType(e) === h.null ? N(null) : this._def.innerType._parse(e);
|
|
2563
2563
|
}
|
|
@@ -2565,7 +2565,7 @@ class K extends v {
|
|
|
2565
2565
|
return this._def.innerType;
|
|
2566
2566
|
}
|
|
2567
2567
|
}
|
|
2568
|
-
|
|
2568
|
+
G.create = (t, e) => new G({
|
|
2569
2569
|
innerType: t,
|
|
2570
2570
|
typeName: m.ZodNullable,
|
|
2571
2571
|
...g(e)
|
|
@@ -2598,16 +2598,16 @@ class _e extends v {
|
|
|
2598
2598
|
...n.common,
|
|
2599
2599
|
issues: []
|
|
2600
2600
|
}
|
|
2601
|
-
},
|
|
2601
|
+
}, a = 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
|
|
2608
|
+
return oe(a) ? a.then((r) => ({
|
|
2609
2609
|
status: "valid",
|
|
2610
|
-
value:
|
|
2610
|
+
value: r.status === "valid" ? r.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: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2619
2619
|
get error() {
|
|
2620
2620
|
return new Z(s.common.issues);
|
|
2621
2621
|
},
|
|
@@ -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 r = 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 r.status === "aborted" ? y : r.status === "dirty" ? (n.dirty(), te(r.value)) : this._def.out._parseAsync({
|
|
2677
|
+
data: r.value,
|
|
2678
2678
|
path: s.path,
|
|
2679
2679
|
parent: s
|
|
2680
2680
|
});
|
|
2681
2681
|
})();
|
|
2682
2682
|
{
|
|
2683
|
-
const
|
|
2683
|
+
const a = this._def.in._parseSync({
|
|
2684
2684
|
data: s.data,
|
|
2685
2685
|
path: s.path,
|
|
2686
2686
|
parent: s
|
|
2687
2687
|
});
|
|
2688
|
-
return
|
|
2688
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (n.dirty(), {
|
|
2689
2689
|
status: "dirty",
|
|
2690
|
-
value:
|
|
2690
|
+
value: a.value
|
|
2691
2691
|
}) : this._def.out._parseSync({
|
|
2692
|
-
data:
|
|
2692
|
+
data: a.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
|
|
2708
|
+
const n = this._def.innerType._parse(e), s = (a) => (J(a) && (a.value = Object.freeze(a.value)), a);
|
|
2709
|
+
return oe(n) ? n.then((a) => s(a)) : s(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
unwrap() {
|
|
2712
2712
|
return this._def.innerType;
|
|
@@ -2721,97 +2721,97 @@ 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 _ =
|
|
2725
|
-
|
|
2724
|
+
const _ = I.create, it = Y.create, ke = me.create;
|
|
2725
|
+
B.create;
|
|
2726
2726
|
const A = R.create, $ = w.create;
|
|
2727
|
-
ce.create;
|
|
2728
2727
|
de.create;
|
|
2728
|
+
ue.create;
|
|
2729
2729
|
F.create;
|
|
2730
|
-
const
|
|
2731
|
-
Y.create;
|
|
2732
|
-
le.create;
|
|
2733
|
-
V.create;
|
|
2730
|
+
const ot = le.create;
|
|
2734
2731
|
K.create;
|
|
2735
|
-
|
|
2732
|
+
he.create;
|
|
2733
|
+
V.create;
|
|
2734
|
+
G.create;
|
|
2735
|
+
const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2736
2736
|
__proto__: null,
|
|
2737
|
-
DIRTY:
|
|
2737
|
+
DIRTY: te,
|
|
2738
2738
|
INVALID: y,
|
|
2739
2739
|
OK: N,
|
|
2740
2740
|
ParseStatus: C,
|
|
2741
2741
|
Schema: v,
|
|
2742
2742
|
ZodAny: Le,
|
|
2743
2743
|
ZodArray: R,
|
|
2744
|
-
ZodBigInt:
|
|
2744
|
+
ZodBigInt: ne,
|
|
2745
2745
|
ZodBoolean: me,
|
|
2746
2746
|
ZodBranded: rt,
|
|
2747
2747
|
ZodCatch: _e,
|
|
2748
|
-
ZodDate:
|
|
2748
|
+
ZodDate: ce,
|
|
2749
2749
|
ZodDefault: ye,
|
|
2750
2750
|
ZodEffects: U,
|
|
2751
|
-
ZodEnum:
|
|
2751
|
+
ZodEnum: K,
|
|
2752
2752
|
ZodError: Z,
|
|
2753
2753
|
get ZodFirstPartyTypeKind() {
|
|
2754
2754
|
return m;
|
|
2755
2755
|
},
|
|
2756
|
-
ZodIntersection:
|
|
2756
|
+
ZodIntersection: ue,
|
|
2757
2757
|
ZodIssueCode: d,
|
|
2758
|
-
ZodLazy:
|
|
2758
|
+
ZodLazy: ze,
|
|
2759
2759
|
ZodLiteral: Fe,
|
|
2760
|
-
ZodMap:
|
|
2760
|
+
ZodMap: Be,
|
|
2761
2761
|
ZodNaN: qe,
|
|
2762
2762
|
ZodNativeEnum: Ue,
|
|
2763
|
-
ZodNever:
|
|
2763
|
+
ZodNever: B,
|
|
2764
2764
|
ZodNull: De,
|
|
2765
|
-
ZodNullable:
|
|
2766
|
-
ZodNumber:
|
|
2765
|
+
ZodNullable: G,
|
|
2766
|
+
ZodNumber: Y,
|
|
2767
2767
|
ZodObject: w,
|
|
2768
2768
|
ZodOptional: V,
|
|
2769
2769
|
ZodParsedType: h,
|
|
2770
2770
|
ZodPipeline: xe,
|
|
2771
|
-
ZodPromise:
|
|
2771
|
+
ZodPromise: he,
|
|
2772
2772
|
ZodReadonly: ge,
|
|
2773
|
-
ZodRecord:
|
|
2773
|
+
ZodRecord: le,
|
|
2774
2774
|
ZodSchema: v,
|
|
2775
|
-
ZodSet:
|
|
2776
|
-
ZodString:
|
|
2777
|
-
ZodSymbol:
|
|
2775
|
+
ZodSet: se,
|
|
2776
|
+
ZodString: I,
|
|
2777
|
+
ZodSymbol: Ie,
|
|
2778
2778
|
ZodTransformer: U,
|
|
2779
2779
|
ZodTuple: F,
|
|
2780
2780
|
ZodType: v,
|
|
2781
2781
|
ZodUndefined: Ze,
|
|
2782
|
-
ZodUnion:
|
|
2782
|
+
ZodUnion: de,
|
|
2783
2783
|
ZodUnknown: Pe,
|
|
2784
2784
|
ZodVoid: Me,
|
|
2785
2785
|
addIssueToContext: l,
|
|
2786
2786
|
array: A,
|
|
2787
2787
|
boolean: ke,
|
|
2788
|
-
datetimeRegex:
|
|
2788
|
+
datetimeRegex: st,
|
|
2789
2789
|
defaultErrorMap: pe,
|
|
2790
|
-
getErrorMap:
|
|
2790
|
+
getErrorMap: Xe,
|
|
2791
2791
|
getParsedType: P,
|
|
2792
2792
|
isAborted: $e,
|
|
2793
|
-
isAsync:
|
|
2794
|
-
isDirty:
|
|
2795
|
-
isValid:
|
|
2796
|
-
makeIssue:
|
|
2797
|
-
number:
|
|
2793
|
+
isAsync: oe,
|
|
2794
|
+
isDirty: je,
|
|
2795
|
+
isValid: J,
|
|
2796
|
+
makeIssue: et,
|
|
2797
|
+
number: it,
|
|
2798
2798
|
object: $,
|
|
2799
2799
|
get objectUtil() {
|
|
2800
2800
|
return Re;
|
|
2801
2801
|
},
|
|
2802
|
-
record:
|
|
2802
|
+
record: ot,
|
|
2803
2803
|
string: _,
|
|
2804
2804
|
get util() {
|
|
2805
2805
|
return b;
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
|
-
|
|
2809
|
-
const
|
|
2808
|
+
_t(Vt);
|
|
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 r
|
|
2814
|
-
const o = e(
|
|
2811
|
+
return (a) => (r, i) => {
|
|
2812
|
+
if (t(r, i))
|
|
2813
|
+
return a(r, i);
|
|
2814
|
+
const o = e(r, i);
|
|
2815
2815
|
if (!s.has(o))
|
|
2816
2816
|
s.set(o, []);
|
|
2817
2817
|
else
|
|
@@ -2819,59 +2819,59 @@ const Vt = (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 r
|
|
2822
|
+
return a(r, 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
|
-
},
|
|
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: a = null, retryOnNetworkError: r = !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 a == "function" ? Promise.resolve(a({
|
|
2837
2837
|
response: S,
|
|
2838
2838
|
error: E,
|
|
2839
2839
|
url: u,
|
|
2840
2840
|
attempt: k,
|
|
2841
2841
|
options: p
|
|
2842
2842
|
})).then((O = {}) => {
|
|
2843
|
-
var
|
|
2844
|
-
x(c((
|
|
2843
|
+
var j, W;
|
|
2844
|
+
x(c((j = O && O.url) !== null && j !== void 0 ? j : u, (W = O && O.options) !== null && W !== void 0 ? W : p));
|
|
2845
2845
|
}) : x(c(u, p));
|
|
2846
2846
|
}, L);
|
|
2847
2847
|
}).then(T).catch((x) => {
|
|
2848
|
-
if (!
|
|
2848
|
+
if (!r)
|
|
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 (!r)
|
|
2854
2854
|
throw S;
|
|
2855
2855
|
return T(null, S);
|
|
2856
2856
|
});
|
|
2857
2857
|
}, ve = $({
|
|
2858
|
-
code:
|
|
2859
|
-
message: _()
|
|
2860
|
-
}), Qt = $({
|
|
2858
|
+
code: it(),
|
|
2861
2859
|
message: _()
|
|
2862
2860
|
}), Ht = $({
|
|
2861
|
+
message: _()
|
|
2862
|
+
}), Jt = $({
|
|
2863
2863
|
emails: A(_()).optional(),
|
|
2864
2864
|
http_body: _().optional(),
|
|
2865
2865
|
http_url: _().optional(),
|
|
2866
2866
|
txt_name: _().optional(),
|
|
2867
2867
|
txt_value: _().optional()
|
|
2868
|
-
}),
|
|
2868
|
+
}), Yt = $({
|
|
2869
2869
|
ciphers: A(_()).optional(),
|
|
2870
2870
|
early_hints: _().optional(),
|
|
2871
2871
|
http2: _().optional(),
|
|
2872
2872
|
min_tls_version: _().optional(),
|
|
2873
2873
|
tls_1_3: _().optional()
|
|
2874
|
-
}),
|
|
2874
|
+
}), Kt = $({
|
|
2875
2875
|
id: _(),
|
|
2876
2876
|
bundle_method: _().optional(),
|
|
2877
2877
|
certificate_authority: _(),
|
|
@@ -2883,85 +2883,103 @@ const Vt = (t, e) => e.skipDedupe || e.method !== "GET", zt = (t, e) => e.method
|
|
|
2883
2883
|
issuer: _().optional(),
|
|
2884
2884
|
method: _(),
|
|
2885
2885
|
serial_number: _().optional(),
|
|
2886
|
-
settings:
|
|
2886
|
+
settings: Yt.optional(),
|
|
2887
2887
|
signature: _().optional(),
|
|
2888
2888
|
type: _(),
|
|
2889
2889
|
uploaded_on: _().optional(),
|
|
2890
|
-
validation_errors: A(
|
|
2891
|
-
validation_records: A(
|
|
2890
|
+
validation_errors: A(Ht).optional(),
|
|
2891
|
+
validation_records: A(Jt).optional(),
|
|
2892
2892
|
wildcard: ke()
|
|
2893
|
-
}),
|
|
2893
|
+
}), Gt = $({
|
|
2894
2894
|
name: _(),
|
|
2895
2895
|
type: _(),
|
|
2896
2896
|
value: _()
|
|
2897
|
-
}),
|
|
2897
|
+
}), Xt = $({
|
|
2898
2898
|
http_body: _().optional(),
|
|
2899
2899
|
http_url: _().optional()
|
|
2900
|
-
}),
|
|
2900
|
+
}), ct = $({
|
|
2901
2901
|
id: _(),
|
|
2902
|
-
ssl:
|
|
2902
|
+
ssl: Kt,
|
|
2903
2903
|
hostname: _(),
|
|
2904
|
-
custom_metadata:
|
|
2904
|
+
custom_metadata: ot(_()).optional(),
|
|
2905
2905
|
custom_origin_server: _().optional(),
|
|
2906
2906
|
custom_origin_sni: _().optional(),
|
|
2907
|
-
ownership_verification:
|
|
2908
|
-
ownership_verification_http:
|
|
2907
|
+
ownership_verification: Gt.optional(),
|
|
2908
|
+
ownership_verification_http: Xt.optional(),
|
|
2909
2909
|
status: _(),
|
|
2910
2910
|
verification_errors: A(_()).optional(),
|
|
2911
2911
|
created_at: _()
|
|
2912
|
-
}),
|
|
2912
|
+
}), ie = $({
|
|
2913
2913
|
errors: A(ve),
|
|
2914
2914
|
messages: A(ve),
|
|
2915
2915
|
success: ke(),
|
|
2916
|
-
result:
|
|
2916
|
+
result: ct
|
|
2917
2917
|
});
|
|
2918
2918
|
$({
|
|
2919
2919
|
errors: A(ve),
|
|
2920
2920
|
messages: A(ve),
|
|
2921
2921
|
success: ke(),
|
|
2922
|
-
result: A(
|
|
2922
|
+
result: A(ct)
|
|
2923
2923
|
});
|
|
2924
|
-
function
|
|
2925
|
-
return
|
|
2924
|
+
function H(t) {
|
|
2925
|
+
return pt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({
|
|
2926
2926
|
"X-Auth-Email": t.authEmail,
|
|
2927
2927
|
"X-Auth-Key": t.authKey,
|
|
2928
2928
|
"Content-Type": "application/json"
|
|
2929
|
-
}).middlewares([
|
|
2929
|
+
}).middlewares([Qt(), Ut()]);
|
|
2930
|
+
}
|
|
2931
|
+
function Je(t) {
|
|
2932
|
+
const e = {}, n = {};
|
|
2933
|
+
if (!t) return { sslOverrides: e, rest: n };
|
|
2934
|
+
for (const [s, a] of Object.entries(t))
|
|
2935
|
+
s.startsWith("ssl.") ? e[s.slice(4)] = a : n[s] = a;
|
|
2936
|
+
return { sslOverrides: e, rest: n };
|
|
2930
2937
|
}
|
|
2931
2938
|
function Ne(t) {
|
|
2932
2939
|
const e = [];
|
|
2933
2940
|
if (t.ssl.validation_records)
|
|
2934
|
-
for (const
|
|
2935
|
-
|
|
2941
|
+
for (const s of t.ssl.validation_records)
|
|
2942
|
+
s.txt_name && s.txt_value && e.push({
|
|
2936
2943
|
name: "txt",
|
|
2937
|
-
record:
|
|
2938
|
-
domain:
|
|
2944
|
+
record: s.txt_value,
|
|
2945
|
+
domain: s.txt_name
|
|
2939
2946
|
});
|
|
2940
|
-
|
|
2947
|
+
t.ownership_verification && e.push({
|
|
2941
2948
|
name: "txt",
|
|
2942
2949
|
record: t.ownership_verification.value,
|
|
2943
2950
|
domain: t.ownership_verification.name
|
|
2944
|
-
})
|
|
2951
|
+
});
|
|
2952
|
+
const n = {
|
|
2953
|
+
...t.domain_metadata || {},
|
|
2954
|
+
"ssl.method": t.ssl.method,
|
|
2955
|
+
"ssl.type": t.ssl.type,
|
|
2956
|
+
"ssl.certificate_authority": t.ssl.certificate_authority
|
|
2957
|
+
};
|
|
2958
|
+
return {
|
|
2945
2959
|
custom_domain_id: t.id,
|
|
2946
2960
|
domain: t.hostname,
|
|
2947
2961
|
primary: t.primary,
|
|
2948
2962
|
status: t.status === "active" ? "ready" : "pending",
|
|
2949
2963
|
type: "auth0_managed_certs",
|
|
2950
2964
|
verification: {
|
|
2951
|
-
methods: A(
|
|
2952
|
-
}
|
|
2965
|
+
methods: A(ft).parse(e)
|
|
2966
|
+
},
|
|
2967
|
+
domain_metadata: n
|
|
2953
2968
|
};
|
|
2954
2969
|
}
|
|
2955
|
-
function
|
|
2970
|
+
function en(t) {
|
|
2956
2971
|
return {
|
|
2957
2972
|
create: async (e, n) => {
|
|
2958
|
-
const {
|
|
2959
|
-
|
|
2973
|
+
const { sslOverrides: s, rest: a } = Je(
|
|
2974
|
+
n.domain_metadata
|
|
2975
|
+
), { result: r, errors: i, success: o } = ie.parse(
|
|
2976
|
+
await H(t).post(
|
|
2960
2977
|
{
|
|
2961
2978
|
hostname: n.domain,
|
|
2962
2979
|
ssl: {
|
|
2963
2980
|
method: "txt",
|
|
2964
|
-
type: "dv"
|
|
2981
|
+
type: "dv",
|
|
2982
|
+
...s
|
|
2965
2983
|
},
|
|
2966
2984
|
custom_metadata: t.enterprise ? {
|
|
2967
2985
|
tenant_id: e
|
|
@@ -2970,17 +2988,19 @@ function Xt(t) {
|
|
|
2970
2988
|
"/custom_hostnames"
|
|
2971
2989
|
).json()
|
|
2972
2990
|
);
|
|
2973
|
-
if (!
|
|
2974
|
-
throw new Error(JSON.stringify(
|
|
2975
|
-
const
|
|
2976
|
-
...
|
|
2977
|
-
primary: !1
|
|
2991
|
+
if (!o)
|
|
2992
|
+
throw new Error(JSON.stringify(i));
|
|
2993
|
+
const c = Ne({
|
|
2994
|
+
...r,
|
|
2995
|
+
primary: !1,
|
|
2996
|
+
domain_metadata: a
|
|
2978
2997
|
});
|
|
2979
2998
|
return await t.customDomainAdapter.create(e, {
|
|
2980
|
-
custom_domain_id:
|
|
2981
|
-
domain:
|
|
2982
|
-
type:
|
|
2983
|
-
|
|
2999
|
+
custom_domain_id: c.custom_domain_id,
|
|
3000
|
+
domain: c.domain,
|
|
3001
|
+
type: c.type,
|
|
3002
|
+
domain_metadata: n.domain_metadata
|
|
3003
|
+
}), c;
|
|
2984
3004
|
},
|
|
2985
3005
|
get: async (e, n) => {
|
|
2986
3006
|
const s = await t.customDomainAdapter.get(
|
|
@@ -2988,55 +3008,73 @@ function Xt(t) {
|
|
|
2988
3008
|
n
|
|
2989
3009
|
);
|
|
2990
3010
|
if (!s)
|
|
2991
|
-
throw new
|
|
2992
|
-
const
|
|
3011
|
+
throw new X(404);
|
|
3012
|
+
const a = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: r, errors: i, success: o } = ie.parse(a);
|
|
2993
3013
|
if (!o)
|
|
2994
|
-
throw new
|
|
3014
|
+
throw new X(503, {
|
|
2995
3015
|
message: JSON.stringify(i)
|
|
2996
3016
|
});
|
|
2997
|
-
if (t.enterprise &&
|
|
2998
|
-
throw new
|
|
2999
|
-
return Ne({ ...s, ...
|
|
3017
|
+
if (t.enterprise && r.custom_metadata?.tenant_id !== e)
|
|
3018
|
+
throw new X(404);
|
|
3019
|
+
return Ne({ ...s, ...r });
|
|
3000
3020
|
},
|
|
3001
3021
|
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3002
3022
|
list: async (e) => {
|
|
3003
3023
|
const n = await t.customDomainAdapter.list(e);
|
|
3004
3024
|
return (await Promise.all(
|
|
3005
|
-
n.map(async (
|
|
3025
|
+
n.map(async (a) => {
|
|
3006
3026
|
try {
|
|
3007
|
-
const
|
|
3008
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3009
|
-
).json(), { result: i, success: o } =
|
|
3027
|
+
const r = await H(t).get(
|
|
3028
|
+
`/custom_hostnames/${encodeURIComponent(a.custom_domain_id)}`
|
|
3029
|
+
).json(), { result: i, success: o } = ie.parse(r);
|
|
3010
3030
|
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ne({
|
|
3011
|
-
...
|
|
3031
|
+
...a,
|
|
3012
3032
|
...i
|
|
3013
3033
|
});
|
|
3014
3034
|
} catch {
|
|
3015
3035
|
return null;
|
|
3016
3036
|
}
|
|
3017
3037
|
})
|
|
3018
|
-
)).filter((
|
|
3038
|
+
)).filter((a) => a !== null);
|
|
3019
3039
|
},
|
|
3020
3040
|
remove: async (e, n) => {
|
|
3021
3041
|
if (t.enterprise) {
|
|
3022
|
-
const { result:
|
|
3023
|
-
await
|
|
3042
|
+
const { result: a, success: r } = ie.parse(
|
|
3043
|
+
await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3024
3044
|
);
|
|
3025
|
-
if (!
|
|
3026
|
-
throw new
|
|
3045
|
+
if (!r || a.custom_metadata?.tenant_id !== e)
|
|
3046
|
+
throw new X(404);
|
|
3027
3047
|
}
|
|
3028
|
-
const s = await
|
|
3048
|
+
const s = await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
|
|
3029
3049
|
return s.ok && await t.customDomainAdapter.remove(e, n), s.ok;
|
|
3030
3050
|
},
|
|
3031
3051
|
update: async (e, n, s) => {
|
|
3032
|
-
const
|
|
3033
|
-
s
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3052
|
+
const { sslOverrides: a } = Je(
|
|
3053
|
+
s.domain_metadata
|
|
3054
|
+
), r = {};
|
|
3055
|
+
if (Object.keys(a).length > 0) {
|
|
3056
|
+
const i = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: o, success: c } = ie.parse(i);
|
|
3057
|
+
if (!c)
|
|
3058
|
+
throw new X(503, {
|
|
3059
|
+
message: "Failed to fetch current custom hostname state"
|
|
3060
|
+
});
|
|
3061
|
+
r.ssl = {
|
|
3062
|
+
method: o.ssl.method,
|
|
3063
|
+
type: o.ssl.type,
|
|
3064
|
+
certificate_authority: o.ssl.certificate_authority,
|
|
3065
|
+
...a
|
|
3066
|
+
};
|
|
3067
|
+
}
|
|
3068
|
+
if (Object.keys(r).length > 0) {
|
|
3069
|
+
const i = await H(t).patch(
|
|
3070
|
+
r,
|
|
3071
|
+
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3072
|
+
).res();
|
|
3073
|
+
if (!i.ok)
|
|
3074
|
+
throw new X(503, {
|
|
3075
|
+
message: await i.text()
|
|
3076
|
+
});
|
|
3077
|
+
}
|
|
3040
3078
|
return t.customDomainAdapter.update(
|
|
3041
3079
|
e,
|
|
3042
3080
|
n,
|
|
@@ -3045,7 +3083,7 @@ function Xt(t) {
|
|
|
3045
3083
|
}
|
|
3046
3084
|
};
|
|
3047
3085
|
}
|
|
3048
|
-
class
|
|
3086
|
+
class tn {
|
|
3049
3087
|
constructor(e) {
|
|
3050
3088
|
this.config = e;
|
|
3051
3089
|
}
|
|
@@ -3067,18 +3105,18 @@ class en {
|
|
|
3067
3105
|
}
|
|
3068
3106
|
async get(e) {
|
|
3069
3107
|
try {
|
|
3070
|
-
const n = await this.getCache(), s = this.createRequest(e),
|
|
3071
|
-
if (!
|
|
3108
|
+
const n = await this.getCache(), s = this.createRequest(e), a = await n.match(s);
|
|
3109
|
+
if (!a)
|
|
3072
3110
|
return null;
|
|
3073
|
-
const
|
|
3074
|
-
return
|
|
3111
|
+
const r = await a.json();
|
|
3112
|
+
return r.expiresAt && new Date(r.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : r.value;
|
|
3075
3113
|
} catch (n) {
|
|
3076
3114
|
return console.error(`CloudflareCache: get error for key ${e}:`, n), null;
|
|
3077
3115
|
}
|
|
3078
3116
|
}
|
|
3079
3117
|
async set(e, n, s) {
|
|
3080
3118
|
try {
|
|
3081
|
-
const
|
|
3119
|
+
const a = await this.getCache(), r = s ?? this.config.defaultTtlSeconds, i = r !== void 0, o = i ? Math.max(0, r) : 0, c = {
|
|
3082
3120
|
value: n,
|
|
3083
3121
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3084
3122
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3089,9 +3127,9 @@ class en {
|
|
|
3089
3127
|
const k = new Response(JSON.stringify(c), {
|
|
3090
3128
|
headers: p
|
|
3091
3129
|
});
|
|
3092
|
-
await
|
|
3093
|
-
} catch (
|
|
3094
|
-
console.error(`CloudflareCache: set error for key ${e}:`,
|
|
3130
|
+
await a.put(u, k);
|
|
3131
|
+
} catch (a) {
|
|
3132
|
+
console.error(`CloudflareCache: set error for key ${e}:`, a);
|
|
3095
3133
|
}
|
|
3096
3134
|
}
|
|
3097
3135
|
async delete(e) {
|
|
@@ -3113,7 +3151,7 @@ class en {
|
|
|
3113
3151
|
);
|
|
3114
3152
|
}
|
|
3115
3153
|
}
|
|
3116
|
-
function
|
|
3154
|
+
function nn(t = {}) {
|
|
3117
3155
|
const e = {
|
|
3118
3156
|
defaultTtlSeconds: 300,
|
|
3119
3157
|
// 5 minutes default
|
|
@@ -3122,19 +3160,19 @@ function tn(t = {}) {
|
|
|
3122
3160
|
...t
|
|
3123
3161
|
// user config overrides defaults
|
|
3124
3162
|
};
|
|
3125
|
-
return new
|
|
3163
|
+
return new tn(e);
|
|
3126
3164
|
}
|
|
3127
|
-
const
|
|
3128
|
-
let
|
|
3165
|
+
const sn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3166
|
+
let dt = (t = 21) => {
|
|
3129
3167
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
3130
3168
|
for (; t--; )
|
|
3131
|
-
e +=
|
|
3169
|
+
e += sn[n[t] & 63];
|
|
3132
3170
|
return e;
|
|
3133
3171
|
};
|
|
3134
3172
|
async function We(t, e) {
|
|
3135
|
-
const n = t.timeout || 3e4, s = new AbortController(),
|
|
3173
|
+
const n = t.timeout || 3e4, s = new AbortController(), a = setTimeout(() => s.abort(), n);
|
|
3136
3174
|
try {
|
|
3137
|
-
const
|
|
3175
|
+
const r = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(r, {
|
|
3138
3176
|
method: "POST",
|
|
3139
3177
|
headers: {
|
|
3140
3178
|
"Content-Type": "application/json",
|
|
@@ -3155,16 +3193,16 @@ async function We(t, e) {
|
|
|
3155
3193
|
throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);
|
|
3156
3194
|
return o.data || o.result?.data || [];
|
|
3157
3195
|
} finally {
|
|
3158
|
-
clearTimeout(
|
|
3196
|
+
clearTimeout(a);
|
|
3159
3197
|
}
|
|
3160
3198
|
}
|
|
3161
3199
|
function be(t) {
|
|
3162
3200
|
return `'${t.replace(/'/g, "''")}'`;
|
|
3163
3201
|
}
|
|
3164
|
-
function
|
|
3202
|
+
function z(t) {
|
|
3165
3203
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3166
3204
|
}
|
|
3167
|
-
function
|
|
3205
|
+
function ut(t) {
|
|
3168
3206
|
const e = (n) => {
|
|
3169
3207
|
if (!n)
|
|
3170
3208
|
return "";
|
|
@@ -3206,17 +3244,17 @@ function dt(t) {
|
|
|
3206
3244
|
} : void 0
|
|
3207
3245
|
};
|
|
3208
3246
|
}
|
|
3209
|
-
function
|
|
3247
|
+
function an(t) {
|
|
3210
3248
|
return async (e, n) => {
|
|
3211
|
-
const s = n.log_id ||
|
|
3249
|
+
const s = n.log_id || dt(), a = {
|
|
3212
3250
|
...n,
|
|
3213
3251
|
log_id: s
|
|
3214
3252
|
};
|
|
3215
|
-
return await rn(t, e,
|
|
3253
|
+
return await rn(t, e, a), a;
|
|
3216
3254
|
};
|
|
3217
3255
|
}
|
|
3218
3256
|
async function rn(t, e, n) {
|
|
3219
|
-
const s = (
|
|
3257
|
+
const s = (r) => r ? JSON.stringify(r) : void 0, a = {
|
|
3220
3258
|
id: n.log_id,
|
|
3221
3259
|
tenant_id: e,
|
|
3222
3260
|
type: n.type,
|
|
@@ -3249,16 +3287,16 @@ async function rn(t, e, n) {
|
|
|
3249
3287
|
};
|
|
3250
3288
|
try {
|
|
3251
3289
|
if (t.pipelineBinding)
|
|
3252
|
-
await t.pipelineBinding.send([
|
|
3290
|
+
await t.pipelineBinding.send([a]);
|
|
3253
3291
|
else if (t.pipelineEndpoint) {
|
|
3254
|
-
const
|
|
3292
|
+
const r = t.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), r);
|
|
3255
3293
|
try {
|
|
3256
3294
|
const c = await fetch(t.pipelineEndpoint, {
|
|
3257
3295
|
method: "POST",
|
|
3258
3296
|
headers: {
|
|
3259
3297
|
"Content-Type": "application/json"
|
|
3260
3298
|
},
|
|
3261
|
-
body: JSON.stringify([
|
|
3299
|
+
body: JSON.stringify([a]),
|
|
3262
3300
|
// Pipelines accept array of records
|
|
3263
3301
|
signal: i.signal
|
|
3264
3302
|
});
|
|
@@ -3273,63 +3311,63 @@ async function rn(t, e, n) {
|
|
|
3273
3311
|
throw new Error(
|
|
3274
3312
|
"Either pipelineEndpoint or pipelineBinding must be configured"
|
|
3275
3313
|
);
|
|
3276
|
-
} catch (
|
|
3277
|
-
throw console.error("Failed to send log to Pipeline:",
|
|
3314
|
+
} catch (r) {
|
|
3315
|
+
throw console.error("Failed to send log to Pipeline:", r), r;
|
|
3278
3316
|
}
|
|
3279
3317
|
}
|
|
3280
|
-
function
|
|
3318
|
+
function on(t) {
|
|
3281
3319
|
return async (e, n) => {
|
|
3282
|
-
const s = t.namespace || "default",
|
|
3283
|
-
SELECT * FROM ${
|
|
3320
|
+
const s = t.namespace || "default", a = t.tableName || "logs", r = `
|
|
3321
|
+
SELECT * FROM ${z(s)}.${z(a)}
|
|
3284
3322
|
WHERE tenant_id = ${be(e)}
|
|
3285
3323
|
AND id = ${be(n)}
|
|
3286
3324
|
LIMIT 1
|
|
3287
|
-
`, i = await We(t,
|
|
3325
|
+
`, i = await We(t, r);
|
|
3288
3326
|
if (i.length === 0)
|
|
3289
3327
|
return null;
|
|
3290
3328
|
const o = i[0];
|
|
3291
|
-
return o ?
|
|
3329
|
+
return o ? ut(o) : null;
|
|
3292
3330
|
};
|
|
3293
3331
|
}
|
|
3294
|
-
function
|
|
3332
|
+
function cn(t) {
|
|
3295
3333
|
const e = {};
|
|
3296
3334
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3297
|
-
const [
|
|
3298
|
-
|
|
3335
|
+
const [a, r] = s.split(":");
|
|
3336
|
+
a && r && (e[a] = r);
|
|
3299
3337
|
}), e;
|
|
3300
3338
|
}
|
|
3301
|
-
function
|
|
3339
|
+
function dn(t) {
|
|
3302
3340
|
const e = [];
|
|
3303
3341
|
for (const [n, s] of Object.entries(t)) {
|
|
3304
|
-
const
|
|
3305
|
-
|
|
3306
|
-
`${
|
|
3342
|
+
const a = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3343
|
+
a && s && e.push(
|
|
3344
|
+
`${z(a)} = ${be(s)}`
|
|
3307
3345
|
);
|
|
3308
3346
|
}
|
|
3309
3347
|
return e;
|
|
3310
3348
|
}
|
|
3311
|
-
function
|
|
3349
|
+
function un(t) {
|
|
3312
3350
|
return async (e, n = {}) => {
|
|
3313
|
-
const { page: s = 0, per_page:
|
|
3351
|
+
const { page: s = 0, per_page: a = 50, include_totals: r = !1, sort: i, q: o } = n, c = t.namespace || "default", u = t.tableName || "logs", p = [
|
|
3314
3352
|
`tenant_id = ${be(e)}`
|
|
3315
3353
|
];
|
|
3316
3354
|
if (o) {
|
|
3317
|
-
const Q =
|
|
3318
|
-
p.push(...
|
|
3355
|
+
const Q = cn(o);
|
|
3356
|
+
p.push(...dn(Q));
|
|
3319
3357
|
}
|
|
3320
3358
|
const k = p.join(" AND ");
|
|
3321
3359
|
let T = "ORDER BY date DESC";
|
|
3322
3360
|
if (i && i.sort_by) {
|
|
3323
|
-
const Q = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""),
|
|
3324
|
-
T = `ORDER BY ${
|
|
3361
|
+
const Q = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), ae = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3362
|
+
T = `ORDER BY ${z(Q)} ${ae}`;
|
|
3325
3363
|
}
|
|
3326
|
-
const S = s *
|
|
3327
|
-
SELECT * FROM ${
|
|
3364
|
+
const S = s * a, E = `LIMIT ${a} OFFSET ${S}`, q = `
|
|
3365
|
+
SELECT * FROM ${z(c)}.${z(u)}
|
|
3328
3366
|
WHERE ${k}
|
|
3329
3367
|
${T}
|
|
3330
3368
|
${E}
|
|
3331
|
-
`, L = (await We(t, q)).map(
|
|
3332
|
-
if (!
|
|
3369
|
+
`, L = (await We(t, q)).map(ut);
|
|
3370
|
+
if (!r)
|
|
3333
3371
|
return {
|
|
3334
3372
|
logs: L,
|
|
3335
3373
|
start: 0,
|
|
@@ -3337,18 +3375,18 @@ function dn(t) {
|
|
|
3337
3375
|
length: 0
|
|
3338
3376
|
};
|
|
3339
3377
|
const O = `
|
|
3340
|
-
SELECT COUNT(*) as count FROM ${
|
|
3378
|
+
SELECT COUNT(*) as count FROM ${z(c)}.${z(u)}
|
|
3341
3379
|
WHERE ${k}
|
|
3342
3380
|
`, W = (await We(t, O))[0]?.count || 0;
|
|
3343
3381
|
return {
|
|
3344
3382
|
logs: L,
|
|
3345
3383
|
start: S,
|
|
3346
|
-
limit:
|
|
3384
|
+
limit: a,
|
|
3347
3385
|
length: Number(W)
|
|
3348
3386
|
};
|
|
3349
3387
|
};
|
|
3350
3388
|
}
|
|
3351
|
-
function
|
|
3389
|
+
function Sn() {
|
|
3352
3390
|
return {
|
|
3353
3391
|
async getDaily() {
|
|
3354
3392
|
throw new Error(
|
|
@@ -3362,7 +3400,7 @@ function wn() {
|
|
|
3362
3400
|
}
|
|
3363
3401
|
};
|
|
3364
3402
|
}
|
|
3365
|
-
function
|
|
3403
|
+
function ln(t) {
|
|
3366
3404
|
const e = !!t.pipelineEndpoint, n = !!t.pipelineBinding;
|
|
3367
3405
|
if (!e && !n)
|
|
3368
3406
|
throw new Error(
|
|
@@ -3375,15 +3413,15 @@ function un(t) {
|
|
|
3375
3413
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3376
3414
|
);
|
|
3377
3415
|
return {
|
|
3378
|
-
create:
|
|
3379
|
-
list:
|
|
3380
|
-
get:
|
|
3416
|
+
create: an(t),
|
|
3417
|
+
list: un(t),
|
|
3418
|
+
get: on(t)
|
|
3381
3419
|
};
|
|
3382
3420
|
}
|
|
3383
|
-
async function
|
|
3384
|
-
const n = t.timeout || 3e4, s = new AbortController(),
|
|
3421
|
+
async function fe(t, e) {
|
|
3422
|
+
const n = t.timeout || 3e4, s = new AbortController(), a = setTimeout(() => s.abort(), n);
|
|
3385
3423
|
try {
|
|
3386
|
-
const
|
|
3424
|
+
const r = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(r, {
|
|
3387
3425
|
method: "POST",
|
|
3388
3426
|
headers: {
|
|
3389
3427
|
"Content-Type": "text/plain",
|
|
@@ -3405,7 +3443,7 @@ async function he(t, e) {
|
|
|
3405
3443
|
);
|
|
3406
3444
|
return o.data || [];
|
|
3407
3445
|
} finally {
|
|
3408
|
-
clearTimeout(
|
|
3446
|
+
clearTimeout(a);
|
|
3409
3447
|
}
|
|
3410
3448
|
}
|
|
3411
3449
|
function M(t) {
|
|
@@ -3414,11 +3452,11 @@ function M(t) {
|
|
|
3414
3452
|
function Qe(t) {
|
|
3415
3453
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3416
3454
|
}
|
|
3417
|
-
function
|
|
3418
|
-
const e = (
|
|
3419
|
-
if (
|
|
3455
|
+
function lt(t) {
|
|
3456
|
+
const e = (a) => {
|
|
3457
|
+
if (a)
|
|
3420
3458
|
try {
|
|
3421
|
-
return JSON.parse(
|
|
3459
|
+
return JSON.parse(a);
|
|
3422
3460
|
} catch {
|
|
3423
3461
|
return;
|
|
3424
3462
|
}
|
|
@@ -3447,63 +3485,63 @@ function ut(t) {
|
|
|
3447
3485
|
isMobile: t.double1 === 1
|
|
3448
3486
|
};
|
|
3449
3487
|
}
|
|
3450
|
-
function
|
|
3488
|
+
function hn(t) {
|
|
3451
3489
|
return async (e, n) => {
|
|
3452
|
-
const s = n.log_id ||
|
|
3490
|
+
const s = n.log_id || dt(), a = {
|
|
3453
3491
|
...n,
|
|
3454
3492
|
log_id: s
|
|
3455
3493
|
};
|
|
3456
|
-
return
|
|
3494
|
+
return fn(t, e, a), a;
|
|
3457
3495
|
};
|
|
3458
3496
|
}
|
|
3459
|
-
function
|
|
3497
|
+
function fn(t, e, n) {
|
|
3460
3498
|
if (!t.analyticsEngineBinding) {
|
|
3461
3499
|
console.error("Analytics Engine binding not configured");
|
|
3462
3500
|
return;
|
|
3463
3501
|
}
|
|
3464
|
-
const s = (
|
|
3502
|
+
const s = (r) => r == null ? "" : typeof r == "string" ? r : JSON.stringify(r), a = (r, i = 1024) => r.substring(0, i);
|
|
3465
3503
|
try {
|
|
3466
3504
|
t.analyticsEngineBinding.writeDataPoint({
|
|
3467
3505
|
blobs: [
|
|
3468
|
-
|
|
3506
|
+
a(n.log_id),
|
|
3469
3507
|
// blob1: log_id
|
|
3470
|
-
|
|
3508
|
+
a(e),
|
|
3471
3509
|
// blob2: tenant_id
|
|
3472
|
-
|
|
3510
|
+
a(n.type || ""),
|
|
3473
3511
|
// blob3: type
|
|
3474
|
-
|
|
3512
|
+
a(n.description || ""),
|
|
3475
3513
|
// blob4: description
|
|
3476
|
-
|
|
3514
|
+
a(n.ip || ""),
|
|
3477
3515
|
// blob5: ip
|
|
3478
|
-
|
|
3516
|
+
a(n.user_agent || ""),
|
|
3479
3517
|
// blob6: user_agent
|
|
3480
|
-
|
|
3518
|
+
a(n.user_id || ""),
|
|
3481
3519
|
// blob7: user_id
|
|
3482
|
-
|
|
3520
|
+
a(n.user_name || ""),
|
|
3483
3521
|
// blob8: user_name
|
|
3484
|
-
|
|
3522
|
+
a(n.connection || ""),
|
|
3485
3523
|
// blob9: connection
|
|
3486
|
-
|
|
3524
|
+
a(n.connection_id || ""),
|
|
3487
3525
|
// blob10: connection_id
|
|
3488
|
-
|
|
3526
|
+
a(n.client_id || ""),
|
|
3489
3527
|
// blob11: client_id
|
|
3490
|
-
|
|
3528
|
+
a(n.client_name || ""),
|
|
3491
3529
|
// blob12: client_name
|
|
3492
|
-
|
|
3530
|
+
a(n.audience || ""),
|
|
3493
3531
|
// blob13: audience
|
|
3494
|
-
|
|
3532
|
+
a(n.scope || ""),
|
|
3495
3533
|
// blob14: scope
|
|
3496
|
-
|
|
3534
|
+
a(n.strategy || ""),
|
|
3497
3535
|
// blob15: strategy
|
|
3498
|
-
|
|
3536
|
+
a(n.strategy_type || ""),
|
|
3499
3537
|
// blob16: strategy_type
|
|
3500
|
-
|
|
3538
|
+
a(n.hostname || ""),
|
|
3501
3539
|
// blob17: hostname
|
|
3502
|
-
|
|
3540
|
+
a(s(n.details)),
|
|
3503
3541
|
// blob18: details (JSON)
|
|
3504
|
-
|
|
3542
|
+
a(s(n.auth0_client)),
|
|
3505
3543
|
// blob19: auth0_client (JSON)
|
|
3506
|
-
|
|
3544
|
+
a(s(n.location_info))
|
|
3507
3545
|
// blob20: location_info (JSON)
|
|
3508
3546
|
],
|
|
3509
3547
|
doubles: [
|
|
@@ -3515,30 +3553,30 @@ function hn(t, e, n) {
|
|
|
3515
3553
|
indexes: [e.substring(0, 96)]
|
|
3516
3554
|
// index1: tenant_id
|
|
3517
3555
|
});
|
|
3518
|
-
} catch (
|
|
3519
|
-
console.error("Failed to write log to Analytics Engine:",
|
|
3556
|
+
} catch (r) {
|
|
3557
|
+
console.error("Failed to write log to Analytics Engine:", r);
|
|
3520
3558
|
}
|
|
3521
3559
|
}
|
|
3522
|
-
function
|
|
3560
|
+
function pn(t) {
|
|
3523
3561
|
return async (e, n) => {
|
|
3524
|
-
const s = t.dataset || "authhero_logs",
|
|
3562
|
+
const s = t.dataset || "authhero_logs", a = `
|
|
3525
3563
|
SELECT *
|
|
3526
3564
|
FROM ${Qe(s)}
|
|
3527
3565
|
WHERE index1 = ${M(e)}
|
|
3528
3566
|
AND blob1 = ${M(n)}
|
|
3529
3567
|
LIMIT 1
|
|
3530
|
-
`,
|
|
3531
|
-
return
|
|
3568
|
+
`, r = await fe(t, a);
|
|
3569
|
+
return r.length === 0 || !r[0] ? null : lt(r[0]);
|
|
3532
3570
|
};
|
|
3533
3571
|
}
|
|
3534
|
-
function
|
|
3572
|
+
function mn(t) {
|
|
3535
3573
|
const e = {};
|
|
3536
3574
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3537
|
-
const
|
|
3538
|
-
|
|
3575
|
+
const a = s.indexOf(":"), r = s.substring(0, a), i = s.substring(a + 1);
|
|
3576
|
+
r && i && (e[r] = i);
|
|
3539
3577
|
}), e;
|
|
3540
3578
|
}
|
|
3541
|
-
function
|
|
3579
|
+
function ht(t) {
|
|
3542
3580
|
return {
|
|
3543
3581
|
log_id: "blob1",
|
|
3544
3582
|
tenant_id: "blob2",
|
|
@@ -3559,41 +3597,41 @@ function lt(t) {
|
|
|
3559
3597
|
hostname: "blob17"
|
|
3560
3598
|
}[t] || null;
|
|
3561
3599
|
}
|
|
3562
|
-
function
|
|
3600
|
+
function yn(t) {
|
|
3563
3601
|
const e = [];
|
|
3564
3602
|
for (const [n, s] of Object.entries(t)) {
|
|
3565
|
-
const
|
|
3566
|
-
|
|
3603
|
+
const a = ht(n);
|
|
3604
|
+
a && s && e.push(`${a} = ${M(s)}`);
|
|
3567
3605
|
}
|
|
3568
3606
|
return e;
|
|
3569
3607
|
}
|
|
3570
|
-
function
|
|
3608
|
+
function _n(t) {
|
|
3571
3609
|
if (t === "date")
|
|
3572
3610
|
return "double2";
|
|
3573
|
-
const e =
|
|
3611
|
+
const e = ht(t);
|
|
3574
3612
|
return e || "timestamp";
|
|
3575
3613
|
}
|
|
3576
|
-
function
|
|
3614
|
+
function gn(t) {
|
|
3577
3615
|
return async (e, n = {}) => {
|
|
3578
|
-
const { page: s = 0, per_page:
|
|
3616
|
+
const { page: s = 0, per_page: a = 50, include_totals: r = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs", u = [`index1 = ${M(e)}`];
|
|
3579
3617
|
if (o) {
|
|
3580
|
-
const O =
|
|
3581
|
-
u.push(...
|
|
3618
|
+
const O = mn(o);
|
|
3619
|
+
u.push(...yn(O));
|
|
3582
3620
|
}
|
|
3583
3621
|
const p = u.join(" AND ");
|
|
3584
3622
|
let k = "ORDER BY timestamp DESC";
|
|
3585
3623
|
if (i && i.sort_by) {
|
|
3586
|
-
const O =
|
|
3587
|
-
k = `ORDER BY ${O} ${
|
|
3624
|
+
const O = _n(i.sort_by), j = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3625
|
+
k = `ORDER BY ${O} ${j}`;
|
|
3588
3626
|
}
|
|
3589
|
-
const T = s *
|
|
3627
|
+
const T = s * a, S = `LIMIT ${a} OFFSET ${T}`, E = `
|
|
3590
3628
|
SELECT *
|
|
3591
3629
|
FROM ${Qe(c)}
|
|
3592
3630
|
WHERE ${p}
|
|
3593
3631
|
${k}
|
|
3594
3632
|
${S}
|
|
3595
|
-
`, x = (await
|
|
3596
|
-
if (!
|
|
3633
|
+
`, x = (await fe(t, E)).map(lt);
|
|
3634
|
+
if (!r)
|
|
3597
3635
|
return {
|
|
3598
3636
|
logs: x,
|
|
3599
3637
|
start: 0,
|
|
@@ -3606,24 +3644,24 @@ function _n(t) {
|
|
|
3606
3644
|
WHERE ${p}
|
|
3607
3645
|
`;
|
|
3608
3646
|
try {
|
|
3609
|
-
const
|
|
3647
|
+
const j = (await fe(t, L))[0]?.count || 0;
|
|
3610
3648
|
return {
|
|
3611
3649
|
logs: x,
|
|
3612
3650
|
start: T,
|
|
3613
|
-
limit:
|
|
3614
|
-
length: Number(
|
|
3651
|
+
limit: a,
|
|
3652
|
+
length: Number(j)
|
|
3615
3653
|
};
|
|
3616
3654
|
} catch {
|
|
3617
3655
|
return {
|
|
3618
3656
|
logs: x,
|
|
3619
3657
|
start: T,
|
|
3620
|
-
limit:
|
|
3658
|
+
limit: a,
|
|
3621
3659
|
length: x.length
|
|
3622
3660
|
};
|
|
3623
3661
|
}
|
|
3624
3662
|
};
|
|
3625
3663
|
}
|
|
3626
|
-
const
|
|
3664
|
+
const Ye = [
|
|
3627
3665
|
"s",
|
|
3628
3666
|
// SUCCESS_LOGIN
|
|
3629
3667
|
"seacft",
|
|
@@ -3636,24 +3674,24 @@ const Je = [
|
|
|
3636
3674
|
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3637
3675
|
"ssa"
|
|
3638
3676
|
// SUCCESS_SILENT_AUTH
|
|
3639
|
-
],
|
|
3677
|
+
], vn = [
|
|
3640
3678
|
"pwd_leak",
|
|
3641
3679
|
"signup_pwd_leak",
|
|
3642
3680
|
"reset_pwd_leak"
|
|
3643
3681
|
];
|
|
3644
|
-
function
|
|
3682
|
+
function Ke(t) {
|
|
3645
3683
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3646
3684
|
}
|
|
3647
|
-
function
|
|
3685
|
+
function Ge(t) {
|
|
3648
3686
|
return t.toISOString().split("T")[0];
|
|
3649
3687
|
}
|
|
3650
|
-
function
|
|
3688
|
+
function Tn(t) {
|
|
3651
3689
|
const e = t.dataset || "authhero_logs";
|
|
3652
3690
|
return {
|
|
3653
3691
|
async getDaily(n, s = {}) {
|
|
3654
|
-
const { from:
|
|
3692
|
+
const { from: a, to: r } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3655
3693
|
o.setDate(o.getDate() - 30);
|
|
3656
|
-
const c =
|
|
3694
|
+
const c = a ? Ke(a) : Ge(o), u = r ? Ke(r) : 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(", "), S = vn.map(
|
|
3657
3695
|
(x) => M(x)
|
|
3658
3696
|
).join(", "), E = `
|
|
3659
3697
|
SELECT
|
|
@@ -3670,7 +3708,7 @@ function Sn(t) {
|
|
|
3670
3708
|
GROUP BY date
|
|
3671
3709
|
ORDER BY date ASC
|
|
3672
3710
|
`;
|
|
3673
|
-
return (await
|
|
3711
|
+
return (await fe(t, E)).map((x) => ({
|
|
3674
3712
|
date: String(x.date),
|
|
3675
3713
|
logins: Number(x.logins) || 0,
|
|
3676
3714
|
signups: Number(x.signups) || 0,
|
|
@@ -3682,41 +3720,41 @@ function Sn(t) {
|
|
|
3682
3720
|
async getActiveUsers(n) {
|
|
3683
3721
|
const s = /* @__PURE__ */ new Date();
|
|
3684
3722
|
s.setDate(s.getDate() - 30);
|
|
3685
|
-
const
|
|
3723
|
+
const a = s.getTime(), r = Ye.map((u) => M(u)).join(", "), i = `
|
|
3686
3724
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3687
3725
|
FROM "${e}"
|
|
3688
3726
|
WHERE index1 = ${M(n)}
|
|
3689
|
-
AND double2 >= ${
|
|
3690
|
-
AND blob3 IN (${
|
|
3727
|
+
AND double2 >= ${a}
|
|
3728
|
+
AND blob3 IN (${r})
|
|
3691
3729
|
AND blob7 IS NOT NULL
|
|
3692
3730
|
AND blob7 != ''
|
|
3693
|
-
`, c = (await
|
|
3731
|
+
`, c = (await fe(t, i))[0];
|
|
3694
3732
|
return c && c.count !== void 0 && Number(c.count) || 0;
|
|
3695
3733
|
}
|
|
3696
3734
|
};
|
|
3697
3735
|
}
|
|
3698
|
-
function
|
|
3736
|
+
function bn(t) {
|
|
3699
3737
|
return t.analyticsEngineBinding || console.warn(
|
|
3700
3738
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3701
3739
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
3702
3740
|
"Analytics Engine: accountId and apiToken are required for querying logs via SQL API."
|
|
3703
3741
|
), {
|
|
3704
|
-
create:
|
|
3705
|
-
list:
|
|
3706
|
-
get:
|
|
3742
|
+
create: hn(t),
|
|
3743
|
+
list: gn(t),
|
|
3744
|
+
get: pn(t)
|
|
3707
3745
|
};
|
|
3708
3746
|
}
|
|
3709
|
-
function
|
|
3747
|
+
function xn() {
|
|
3710
3748
|
return {
|
|
3711
3749
|
async getGeoInfo(t) {
|
|
3712
3750
|
try {
|
|
3713
|
-
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"],
|
|
3751
|
+
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"], a = t["cf-iplongitude"], r = t["cf-timezone"], i = t["cf-ipcontinent"];
|
|
3714
3752
|
return e ? {
|
|
3715
3753
|
country_code: e,
|
|
3716
3754
|
city_name: n || "",
|
|
3717
3755
|
latitude: s || "",
|
|
3718
|
-
longitude:
|
|
3719
|
-
time_zone:
|
|
3756
|
+
longitude: a || "",
|
|
3757
|
+
time_zone: r || "",
|
|
3720
3758
|
continent_code: i || ""
|
|
3721
3759
|
} : null;
|
|
3722
3760
|
} catch (e) {
|
|
@@ -3725,11 +3763,11 @@ function bn() {
|
|
|
3725
3763
|
}
|
|
3726
3764
|
};
|
|
3727
3765
|
}
|
|
3728
|
-
function
|
|
3766
|
+
function Cn(t) {
|
|
3729
3767
|
const e = {
|
|
3730
|
-
customDomains:
|
|
3768
|
+
customDomains: en(t),
|
|
3731
3769
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
3732
|
-
cache:
|
|
3770
|
+
cache: nn({
|
|
3733
3771
|
...t.cacheName && { cacheName: t.cacheName },
|
|
3734
3772
|
...t.defaultTtlSeconds !== void 0 && {
|
|
3735
3773
|
defaultTtlSeconds: t.defaultTtlSeconds
|
|
@@ -3738,16 +3776,16 @@ function Tn(t) {
|
|
|
3738
3776
|
}),
|
|
3739
3777
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
3740
3778
|
// passed at request time via getGeoInfo(headers)
|
|
3741
|
-
geo:
|
|
3779
|
+
geo: xn()
|
|
3742
3780
|
};
|
|
3743
|
-
return t.r2SqlLogs ? e.logs =
|
|
3781
|
+
return t.r2SqlLogs ? e.logs = ln(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = bn(
|
|
3744
3782
|
t.analyticsEngineLogs
|
|
3745
3783
|
)), e;
|
|
3746
3784
|
}
|
|
3747
3785
|
export {
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3786
|
+
bn as createAnalyticsEngineLogsAdapter,
|
|
3787
|
+
Tn as createAnalyticsEngineStatsAdapter,
|
|
3788
|
+
ln as createR2SQLLogsAdapter,
|
|
3789
|
+
Sn as createR2SQLStatsAdapter,
|
|
3790
|
+
Cn as default
|
|
3753
3791
|
};
|