@authhero/cloudflare-adapter 2.29.1 → 2.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare-adapter.cjs +42 -36
- package/dist/cloudflare-adapter.d.ts +325 -4
- package/dist/cloudflare-adapter.mjs +1277 -1176
- package/package.json +3 -3
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { verificationMethodsSchema as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
var
|
|
5
|
-
for (var
|
|
1
|
+
import { verificationMethodsSchema as gt, actionExecutionStatusSchema as _t } from "@authhero/adapter-interfaces";
|
|
2
|
+
import vt from "wretch";
|
|
3
|
+
function bt(t, e) {
|
|
4
|
+
var n = {};
|
|
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 r = 0,
|
|
8
|
-
e.indexOf(
|
|
9
|
-
return
|
|
7
|
+
for (var r = 0, s = Object.getOwnPropertySymbols(t); r < s.length; r++)
|
|
8
|
+
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[r]) && (n[s[r]] = t[s[r]]);
|
|
9
|
+
return n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
return ((
|
|
11
|
+
function xt(t, e) {
|
|
12
|
+
var n;
|
|
13
|
+
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
t.ZodType.prototype[e] = function(...
|
|
18
|
-
const r =
|
|
15
|
+
function ce(t, e) {
|
|
16
|
+
const n = t.ZodType.prototype[e];
|
|
17
|
+
t.ZodType.prototype[e] = function(...s) {
|
|
18
|
+
const r = n.apply(this, s);
|
|
19
19
|
return r._def.openapi = this._def.openapi, r;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function wt(t) {
|
|
23
23
|
if (typeof t.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
25
|
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
26
|
var i, o, c, d, f, x;
|
|
27
|
-
const
|
|
27
|
+
const T = typeof r == "string" ? a : r, E = T ?? {}, { param: O } = E, M = bt(E, ["param"]), w = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0), P = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), M), !((d = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || d === void 0) && d.param || O ? {
|
|
28
28
|
param: Object.assign(Object.assign({}, (x = (f = this._def.openapi) === null || f === void 0 ? void 0 : f.metadata) === null || x === void 0 ? void 0 : x.param), O)
|
|
29
29
|
} : void 0), A = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(w).length > 0 ? { _internal: w } : void 0), Object.keys(P).length > 0 ? { metadata: P } : void 0) }));
|
|
30
|
-
if (
|
|
30
|
+
if (xt(this, "ZodObject")) {
|
|
31
31
|
const k = this.extend;
|
|
32
32
|
A.extend = function(...S) {
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
var R, V, Ee, Ce, Te, Oe, Ae;
|
|
34
|
+
const Ne = k.apply(this, S);
|
|
35
|
+
return Ne._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((V = (
|
|
37
|
+
extendedFrom: !((V = (R = this._def.openapi) === null || R === void 0 ? void 0 : R._internal) === null || V === void 0) && V.refId ? { refId: (Ce = (Ee = this._def.openapi) === null || Ee === void 0 ? void 0 : Ee._internal) === null || Ce === void 0 ? void 0 : Ce.refId, schema: this } : (Oe = (Te = this._def.openapi) === null || Te === void 0 ? void 0 : Te._internal) === null || Oe === void 0 ? void 0 : Oe.extendedFrom
|
|
38
38
|
},
|
|
39
|
-
metadata: (
|
|
40
|
-
},
|
|
39
|
+
metadata: (Ae = Ne._def.openapi) === null || Ae === void 0 ? void 0 : Ae.metadata
|
|
40
|
+
}, Ne;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
return A;
|
|
44
|
-
},
|
|
44
|
+
}, ce(t, "optional"), ce(t, "nullable"), ce(t, "default"), ce(t, "transform"), ce(t, "refine");
|
|
45
45
|
const e = t.ZodObject.prototype.deepPartial;
|
|
46
46
|
t.ZodObject.prototype.deepPartial = function() {
|
|
47
47
|
const r = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
@@ -50,18 +50,18 @@ function gt(t) {
|
|
|
50
50
|
c._def.openapi = (f = (d = r[o]) === null || d === void 0 ? void 0 : d._def) === null || f === void 0 ? void 0 : f.openapi;
|
|
51
51
|
}), a._def.openapi = void 0, a;
|
|
52
52
|
};
|
|
53
|
-
const
|
|
53
|
+
const n = t.ZodObject.prototype.pick;
|
|
54
54
|
t.ZodObject.prototype.pick = function(...r) {
|
|
55
|
-
const a =
|
|
55
|
+
const a = n.apply(this, r);
|
|
56
56
|
return a._def.openapi = void 0, a;
|
|
57
57
|
};
|
|
58
|
-
const
|
|
58
|
+
const s = t.ZodObject.prototype.omit;
|
|
59
59
|
t.ZodObject.prototype.omit = function(...r) {
|
|
60
|
-
const a =
|
|
60
|
+
const a = s.apply(this, r);
|
|
61
61
|
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var ne = class extends Error {
|
|
65
65
|
res;
|
|
66
66
|
status;
|
|
67
67
|
/**
|
|
@@ -94,10 +94,10 @@ var b;
|
|
|
94
94
|
function e(r) {
|
|
95
95
|
}
|
|
96
96
|
t.assertIs = e;
|
|
97
|
-
function
|
|
97
|
+
function n(r) {
|
|
98
98
|
throw new Error();
|
|
99
99
|
}
|
|
100
|
-
t.assertNever =
|
|
100
|
+
t.assertNever = n, t.arrayToEnum = (r) => {
|
|
101
101
|
const a = {};
|
|
102
102
|
for (const i of r)
|
|
103
103
|
a[i] = i;
|
|
@@ -119,19 +119,19 @@ var b;
|
|
|
119
119
|
if (a(i))
|
|
120
120
|
return i;
|
|
121
121
|
}, t.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
|
|
122
|
-
function
|
|
122
|
+
function s(r, a = " | ") {
|
|
123
123
|
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
124
124
|
}
|
|
125
|
-
t.joinValues =
|
|
125
|
+
t.joinValues = s, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
126
126
|
})(b || (b = {}));
|
|
127
|
-
var
|
|
127
|
+
var Ie;
|
|
128
128
|
(function(t) {
|
|
129
|
-
t.mergeShapes = (e,
|
|
129
|
+
t.mergeShapes = (e, n) => ({
|
|
130
130
|
...e,
|
|
131
|
-
...
|
|
131
|
+
...n
|
|
132
132
|
// second overwrites first
|
|
133
133
|
});
|
|
134
|
-
})(
|
|
134
|
+
})(Ie || (Ie = {}));
|
|
135
135
|
const h = b.arrayToEnum([
|
|
136
136
|
"string",
|
|
137
137
|
"nan",
|
|
@@ -192,23 +192,23 @@ const h = b.arrayToEnum([
|
|
|
192
192
|
"not_multiple_of",
|
|
193
193
|
"not_finite"
|
|
194
194
|
]);
|
|
195
|
-
class
|
|
195
|
+
class U extends Error {
|
|
196
196
|
get errors() {
|
|
197
197
|
return this.issues;
|
|
198
198
|
}
|
|
199
199
|
constructor(e) {
|
|
200
|
-
super(), this.issues = [], this.addIssue = (
|
|
201
|
-
this.issues = [...this.issues,
|
|
202
|
-
}, this.addIssues = (
|
|
203
|
-
this.issues = [...this.issues, ...
|
|
200
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
201
|
+
this.issues = [...this.issues, s];
|
|
202
|
+
}, this.addIssues = (s = []) => {
|
|
203
|
+
this.issues = [...this.issues, ...s];
|
|
204
204
|
};
|
|
205
|
-
const
|
|
206
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this,
|
|
205
|
+
const n = new.target.prototype;
|
|
206
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
207
207
|
}
|
|
208
208
|
format(e) {
|
|
209
|
-
const
|
|
209
|
+
const n = e || function(a) {
|
|
210
210
|
return a.message;
|
|
211
|
-
},
|
|
211
|
+
}, s = { _errors: [] }, r = (a) => {
|
|
212
212
|
for (const i of a.issues)
|
|
213
213
|
if (i.code === "invalid_union")
|
|
214
214
|
i.unionErrors.map(r);
|
|
@@ -217,19 +217,19 @@ class B extends Error {
|
|
|
217
217
|
else if (i.code === "invalid_arguments")
|
|
218
218
|
r(i.argumentsError);
|
|
219
219
|
else if (i.path.length === 0)
|
|
220
|
-
|
|
220
|
+
s._errors.push(n(i));
|
|
221
221
|
else {
|
|
222
|
-
let o =
|
|
222
|
+
let o = s, c = 0;
|
|
223
223
|
for (; c < i.path.length; ) {
|
|
224
224
|
const d = i.path[c];
|
|
225
|
-
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(
|
|
225
|
+
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(n(i))) : o[d] = o[d] || { _errors: [] }, o = o[d], c++;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
return r(this),
|
|
229
|
+
return r(this), s;
|
|
230
230
|
}
|
|
231
231
|
static assert(e) {
|
|
232
|
-
if (!(e instanceof
|
|
232
|
+
if (!(e instanceof U))
|
|
233
233
|
throw new Error(`Not a ZodError: ${e}`);
|
|
234
234
|
}
|
|
235
235
|
toString() {
|
|
@@ -241,83 +241,83 @@ class B extends Error {
|
|
|
241
241
|
get isEmpty() {
|
|
242
242
|
return this.issues.length === 0;
|
|
243
243
|
}
|
|
244
|
-
flatten(e = (
|
|
245
|
-
const
|
|
244
|
+
flatten(e = (n) => n.message) {
|
|
245
|
+
const n = {}, s = [];
|
|
246
246
|
for (const r of this.issues)
|
|
247
247
|
if (r.path.length > 0) {
|
|
248
248
|
const a = r.path[0];
|
|
249
|
-
|
|
249
|
+
n[a] = n[a] || [], n[a].push(e(r));
|
|
250
250
|
} else
|
|
251
|
-
|
|
252
|
-
return { formErrors:
|
|
251
|
+
s.push(e(r));
|
|
252
|
+
return { formErrors: s, fieldErrors: n };
|
|
253
253
|
}
|
|
254
254
|
get formErrors() {
|
|
255
255
|
return this.flatten();
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
let
|
|
258
|
+
U.create = (t) => new U(t);
|
|
259
|
+
const ye = (t, e) => {
|
|
260
|
+
let n;
|
|
261
261
|
switch (t.code) {
|
|
262
262
|
case u.invalid_type:
|
|
263
|
-
t.received === h.undefined ?
|
|
263
|
+
t.received === h.undefined ? n = "Required" : n = `Expected ${t.expected}, received ${t.received}`;
|
|
264
264
|
break;
|
|
265
265
|
case u.invalid_literal:
|
|
266
|
-
|
|
266
|
+
n = `Invalid literal value, expected ${JSON.stringify(t.expected, b.jsonStringifyReplacer)}`;
|
|
267
267
|
break;
|
|
268
268
|
case u.unrecognized_keys:
|
|
269
|
-
|
|
269
|
+
n = `Unrecognized key(s) in object: ${b.joinValues(t.keys, ", ")}`;
|
|
270
270
|
break;
|
|
271
271
|
case u.invalid_union:
|
|
272
|
-
|
|
272
|
+
n = "Invalid input";
|
|
273
273
|
break;
|
|
274
274
|
case u.invalid_union_discriminator:
|
|
275
|
-
|
|
275
|
+
n = `Invalid discriminator value. Expected ${b.joinValues(t.options)}`;
|
|
276
276
|
break;
|
|
277
277
|
case u.invalid_enum_value:
|
|
278
|
-
|
|
278
|
+
n = `Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;
|
|
279
279
|
break;
|
|
280
280
|
case u.invalid_arguments:
|
|
281
|
-
|
|
281
|
+
n = "Invalid function arguments";
|
|
282
282
|
break;
|
|
283
283
|
case u.invalid_return_type:
|
|
284
|
-
|
|
284
|
+
n = "Invalid function return type";
|
|
285
285
|
break;
|
|
286
286
|
case u.invalid_date:
|
|
287
|
-
|
|
287
|
+
n = "Invalid date";
|
|
288
288
|
break;
|
|
289
289
|
case u.invalid_string:
|
|
290
|
-
typeof t.validation == "object" ? "includes" in t.validation ? (
|
|
290
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (n = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? n = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? n = `Invalid input: must end with "${t.validation.endsWith}"` : b.assertNever(t.validation) : t.validation !== "regex" ? n = `Invalid ${t.validation}` : n = "Invalid";
|
|
291
291
|
break;
|
|
292
292
|
case u.too_small:
|
|
293
|
-
t.type === "array" ?
|
|
293
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : n = "Invalid input";
|
|
294
294
|
break;
|
|
295
295
|
case u.too_big:
|
|
296
|
-
t.type === "array" ?
|
|
296
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? n = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : n = "Invalid input";
|
|
297
297
|
break;
|
|
298
298
|
case u.custom:
|
|
299
|
-
|
|
299
|
+
n = "Invalid input";
|
|
300
300
|
break;
|
|
301
301
|
case u.invalid_intersection_types:
|
|
302
|
-
|
|
302
|
+
n = "Intersection results could not be merged";
|
|
303
303
|
break;
|
|
304
304
|
case u.not_multiple_of:
|
|
305
|
-
|
|
305
|
+
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
306
306
|
break;
|
|
307
307
|
case u.not_finite:
|
|
308
|
-
|
|
308
|
+
n = "Number must be finite";
|
|
309
309
|
break;
|
|
310
310
|
default:
|
|
311
|
-
|
|
311
|
+
n = e.defaultError, b.assertNever(t);
|
|
312
312
|
}
|
|
313
|
-
return { message:
|
|
313
|
+
return { message: n };
|
|
314
314
|
};
|
|
315
|
-
let
|
|
316
|
-
function
|
|
317
|
-
return
|
|
315
|
+
let kt = ye;
|
|
316
|
+
function st() {
|
|
317
|
+
return kt;
|
|
318
318
|
}
|
|
319
|
-
const
|
|
320
|
-
const { data: e, path:
|
|
319
|
+
const rt = (t) => {
|
|
320
|
+
const { data: e, path: n, errorMaps: s, issueData: r } = t, a = [...n, ...r.path || []], i = {
|
|
321
321
|
...r,
|
|
322
322
|
path: a
|
|
323
323
|
};
|
|
@@ -328,7 +328,7 @@ const et = (t) => {
|
|
|
328
328
|
message: r.message
|
|
329
329
|
};
|
|
330
330
|
let o = "";
|
|
331
|
-
const c =
|
|
331
|
+
const c = s.filter((d) => !!d).slice().reverse();
|
|
332
332
|
for (const d of c)
|
|
333
333
|
o = d(i, { data: e, defaultError: o }).message;
|
|
334
334
|
return {
|
|
@@ -338,7 +338,7 @@ const et = (t) => {
|
|
|
338
338
|
};
|
|
339
339
|
};
|
|
340
340
|
function l(t, e) {
|
|
341
|
-
const
|
|
341
|
+
const n = st(), s = rt({
|
|
342
342
|
issueData: e,
|
|
343
343
|
data: t.data,
|
|
344
344
|
path: t.path,
|
|
@@ -347,13 +347,13 @@ function l(t, e) {
|
|
|
347
347
|
// contextual error map is first priority
|
|
348
348
|
t.schemaErrorMap,
|
|
349
349
|
// then schema-bound map if available
|
|
350
|
-
|
|
350
|
+
n,
|
|
351
351
|
// then global override map
|
|
352
|
-
|
|
352
|
+
n === ye ? void 0 : ye
|
|
353
353
|
// then global default map
|
|
354
354
|
].filter((r) => !!r)
|
|
355
355
|
});
|
|
356
|
-
t.common.issues.push(
|
|
356
|
+
t.common.issues.push(s);
|
|
357
357
|
}
|
|
358
358
|
class $ {
|
|
359
359
|
constructor() {
|
|
@@ -365,54 +365,54 @@ class $ {
|
|
|
365
365
|
abort() {
|
|
366
366
|
this.value !== "aborted" && (this.value = "aborted");
|
|
367
367
|
}
|
|
368
|
-
static mergeArray(e,
|
|
369
|
-
const
|
|
370
|
-
for (const r of
|
|
368
|
+
static mergeArray(e, n) {
|
|
369
|
+
const s = [];
|
|
370
|
+
for (const r of n) {
|
|
371
371
|
if (r.status === "aborted")
|
|
372
372
|
return y;
|
|
373
|
-
r.status === "dirty" && e.dirty(),
|
|
373
|
+
r.status === "dirty" && e.dirty(), s.push(r.value);
|
|
374
374
|
}
|
|
375
|
-
return { status: e.value, value:
|
|
375
|
+
return { status: e.value, value: s };
|
|
376
376
|
}
|
|
377
|
-
static async mergeObjectAsync(e,
|
|
378
|
-
const
|
|
379
|
-
for (const r of
|
|
377
|
+
static async mergeObjectAsync(e, n) {
|
|
378
|
+
const s = [];
|
|
379
|
+
for (const r of n) {
|
|
380
380
|
const a = await r.key, i = await r.value;
|
|
381
|
-
|
|
381
|
+
s.push({
|
|
382
382
|
key: a,
|
|
383
383
|
value: i
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
|
-
return $.mergeObjectSync(e,
|
|
386
|
+
return $.mergeObjectSync(e, s);
|
|
387
387
|
}
|
|
388
|
-
static mergeObjectSync(e,
|
|
389
|
-
const
|
|
390
|
-
for (const r of
|
|
388
|
+
static mergeObjectSync(e, n) {
|
|
389
|
+
const s = {};
|
|
390
|
+
for (const r of n) {
|
|
391
391
|
const { key: a, value: i } = r;
|
|
392
392
|
if (a.status === "aborted" || i.status === "aborted")
|
|
393
393
|
return y;
|
|
394
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (
|
|
394
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (s[a.value] = i.value);
|
|
395
395
|
}
|
|
396
|
-
return { status: e.value, value:
|
|
396
|
+
return { status: e.value, value: s };
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
const y = Object.freeze({
|
|
400
400
|
status: "aborted"
|
|
401
|
-
}),
|
|
401
|
+
}), re = (t) => ({ status: "dirty", value: t }), D = (t) => ({ status: "valid", value: t }), je = (t) => t.status === "aborted", De = (t) => t.status === "dirty", K = (t) => t.status === "valid", ue = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
402
402
|
var p;
|
|
403
403
|
(function(t) {
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
405
|
})(p || (p = {}));
|
|
406
406
|
class F {
|
|
407
|
-
constructor(e,
|
|
408
|
-
this._cachedPath = [], this.parent = e, this.data =
|
|
407
|
+
constructor(e, n, s, r) {
|
|
408
|
+
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key = r;
|
|
409
409
|
}
|
|
410
410
|
get path() {
|
|
411
411
|
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
414
|
+
const Qe = (t, e) => {
|
|
415
|
+
if (K(e))
|
|
416
416
|
return { success: !0, data: e.value };
|
|
417
417
|
if (!t.common.issues.length)
|
|
418
418
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -421,20 +421,20 @@ const Je = (t, e) => {
|
|
|
421
421
|
get error() {
|
|
422
422
|
if (this._error)
|
|
423
423
|
return this._error;
|
|
424
|
-
const
|
|
425
|
-
return this._error =
|
|
424
|
+
const n = new U(t.common.issues);
|
|
425
|
+
return this._error = n, this._error;
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
};
|
|
429
429
|
function _(t) {
|
|
430
430
|
if (!t)
|
|
431
431
|
return {};
|
|
432
|
-
const { errorMap: e, invalid_type_error:
|
|
433
|
-
if (e && (
|
|
432
|
+
const { errorMap: e, invalid_type_error: n, required_error: s, description: r } = t;
|
|
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
435
|
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
436
436
|
const { message: c } = t;
|
|
437
|
-
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ??
|
|
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
438
|
}, description: r };
|
|
439
439
|
}
|
|
440
440
|
class v {
|
|
@@ -444,8 +444,8 @@ class v {
|
|
|
444
444
|
_getType(e) {
|
|
445
445
|
return q(e.data);
|
|
446
446
|
}
|
|
447
|
-
_getOrReturnCtx(e,
|
|
448
|
-
return
|
|
447
|
+
_getOrReturnCtx(e, n) {
|
|
448
|
+
return n || {
|
|
449
449
|
common: e.parent.common,
|
|
450
450
|
data: e.data,
|
|
451
451
|
parsedType: q(e.data),
|
|
@@ -468,38 +468,38 @@ class v {
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
_parseSync(e) {
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
471
|
+
const n = this._parse(e);
|
|
472
|
+
if (ue(n))
|
|
473
473
|
throw new Error("Synchronous parse encountered promise.");
|
|
474
|
-
return
|
|
474
|
+
return n;
|
|
475
475
|
}
|
|
476
476
|
_parseAsync(e) {
|
|
477
|
-
const
|
|
478
|
-
return Promise.resolve(
|
|
477
|
+
const n = this._parse(e);
|
|
478
|
+
return Promise.resolve(n);
|
|
479
479
|
}
|
|
480
|
-
parse(e,
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
return
|
|
484
|
-
throw
|
|
480
|
+
parse(e, n) {
|
|
481
|
+
const s = this.safeParse(e, n);
|
|
482
|
+
if (s.success)
|
|
483
|
+
return s.data;
|
|
484
|
+
throw s.error;
|
|
485
485
|
}
|
|
486
|
-
safeParse(e,
|
|
487
|
-
const
|
|
486
|
+
safeParse(e, n) {
|
|
487
|
+
const s = {
|
|
488
488
|
common: {
|
|
489
489
|
issues: [],
|
|
490
|
-
async:
|
|
491
|
-
contextualErrorMap:
|
|
490
|
+
async: n?.async ?? !1,
|
|
491
|
+
contextualErrorMap: n?.errorMap
|
|
492
492
|
},
|
|
493
|
-
path:
|
|
493
|
+
path: n?.path || [],
|
|
494
494
|
schemaErrorMap: this._def.errorMap,
|
|
495
495
|
parent: null,
|
|
496
496
|
data: e,
|
|
497
497
|
parsedType: q(e)
|
|
498
|
-
}, r = this._parseSync({ data: e, path:
|
|
499
|
-
return
|
|
498
|
+
}, r = this._parseSync({ data: e, path: s.path, parent: s });
|
|
499
|
+
return Qe(s, r);
|
|
500
500
|
}
|
|
501
501
|
"~validate"(e) {
|
|
502
|
-
const
|
|
502
|
+
const n = {
|
|
503
503
|
common: {
|
|
504
504
|
issues: [],
|
|
505
505
|
async: !!this["~standard"].async
|
|
@@ -512,60 +512,60 @@ class v {
|
|
|
512
512
|
};
|
|
513
513
|
if (!this["~standard"].async)
|
|
514
514
|
try {
|
|
515
|
-
const
|
|
516
|
-
return
|
|
517
|
-
value:
|
|
515
|
+
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
516
|
+
return K(s) ? {
|
|
517
|
+
value: s.value
|
|
518
518
|
} : {
|
|
519
|
-
issues:
|
|
519
|
+
issues: n.common.issues
|
|
520
520
|
};
|
|
521
|
-
} catch (
|
|
522
|
-
|
|
521
|
+
} catch (s) {
|
|
522
|
+
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
523
523
|
issues: [],
|
|
524
524
|
async: !0
|
|
525
525
|
};
|
|
526
526
|
}
|
|
527
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
528
|
-
value:
|
|
527
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((s) => K(s) ? {
|
|
528
|
+
value: s.value
|
|
529
529
|
} : {
|
|
530
|
-
issues:
|
|
530
|
+
issues: n.common.issues
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
|
-
async parseAsync(e,
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
return
|
|
537
|
-
throw
|
|
533
|
+
async parseAsync(e, n) {
|
|
534
|
+
const s = await this.safeParseAsync(e, n);
|
|
535
|
+
if (s.success)
|
|
536
|
+
return s.data;
|
|
537
|
+
throw s.error;
|
|
538
538
|
}
|
|
539
|
-
async safeParseAsync(e,
|
|
540
|
-
const
|
|
539
|
+
async safeParseAsync(e, n) {
|
|
540
|
+
const s = {
|
|
541
541
|
common: {
|
|
542
542
|
issues: [],
|
|
543
|
-
contextualErrorMap:
|
|
543
|
+
contextualErrorMap: n?.errorMap,
|
|
544
544
|
async: !0
|
|
545
545
|
},
|
|
546
|
-
path:
|
|
546
|
+
path: n?.path || [],
|
|
547
547
|
schemaErrorMap: this._def.errorMap,
|
|
548
548
|
parent: null,
|
|
549
549
|
data: e,
|
|
550
550
|
parsedType: q(e)
|
|
551
|
-
}, r = this._parse({ data: e, path:
|
|
552
|
-
return
|
|
551
|
+
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (ue(r) ? r : Promise.resolve(r));
|
|
552
|
+
return Qe(s, a);
|
|
553
553
|
}
|
|
554
|
-
refine(e,
|
|
555
|
-
const
|
|
554
|
+
refine(e, n) {
|
|
555
|
+
const s = (r) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(r) : n;
|
|
556
556
|
return this._refinement((r, a) => {
|
|
557
557
|
const i = e(r), o = () => a.addIssue({
|
|
558
558
|
code: u.custom,
|
|
559
|
-
...
|
|
559
|
+
...s(r)
|
|
560
560
|
});
|
|
561
561
|
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
|
-
refinement(e,
|
|
565
|
-
return this._refinement((
|
|
564
|
+
refinement(e, n) {
|
|
565
|
+
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof n == "function" ? n(s, r) : n), !1));
|
|
566
566
|
}
|
|
567
567
|
_refinement(e) {
|
|
568
|
-
return new
|
|
568
|
+
return new Q({
|
|
569
569
|
schema: this,
|
|
570
570
|
typeName: m.ZodEffects,
|
|
571
571
|
effect: { type: "refinement", refinement: e }
|
|
@@ -578,32 +578,32 @@ class v {
|
|
|
578
578
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
579
579
|
version: 1,
|
|
580
580
|
vendor: "zod",
|
|
581
|
-
validate: (
|
|
581
|
+
validate: (n) => this["~validate"](n)
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
584
|
optional() {
|
|
585
585
|
return z.create(this, this._def);
|
|
586
586
|
}
|
|
587
587
|
nullable() {
|
|
588
|
-
return
|
|
588
|
+
return te.create(this, this._def);
|
|
589
589
|
}
|
|
590
590
|
nullish() {
|
|
591
591
|
return this.nullable().optional();
|
|
592
592
|
}
|
|
593
593
|
array() {
|
|
594
|
-
return
|
|
594
|
+
return L.create(this);
|
|
595
595
|
}
|
|
596
596
|
promise() {
|
|
597
|
-
return
|
|
597
|
+
return me.create(this, this._def);
|
|
598
598
|
}
|
|
599
599
|
or(e) {
|
|
600
|
-
return
|
|
600
|
+
return he.create([this, e], this._def);
|
|
601
601
|
}
|
|
602
602
|
and(e) {
|
|
603
|
-
return
|
|
603
|
+
return fe.create(this, e, this._def);
|
|
604
604
|
}
|
|
605
605
|
transform(e) {
|
|
606
|
-
return new
|
|
606
|
+
return new Q({
|
|
607
607
|
..._(this._def),
|
|
608
608
|
schema: this,
|
|
609
609
|
typeName: m.ZodEffects,
|
|
@@ -611,42 +611,42 @@ class v {
|
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
613
|
default(e) {
|
|
614
|
-
const
|
|
615
|
-
return new
|
|
614
|
+
const n = typeof e == "function" ? e : () => e;
|
|
615
|
+
return new _e({
|
|
616
616
|
..._(this._def),
|
|
617
617
|
innerType: this,
|
|
618
|
-
defaultValue:
|
|
618
|
+
defaultValue: n,
|
|
619
619
|
typeName: m.ZodDefault
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
brand() {
|
|
623
|
-
return new
|
|
623
|
+
return new dt({
|
|
624
624
|
typeName: m.ZodBranded,
|
|
625
625
|
type: this,
|
|
626
626
|
..._(this._def)
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
629
|
catch(e) {
|
|
630
|
-
const
|
|
631
|
-
return new
|
|
630
|
+
const n = typeof e == "function" ? e : () => e;
|
|
631
|
+
return new ve({
|
|
632
632
|
..._(this._def),
|
|
633
633
|
innerType: this,
|
|
634
|
-
catchValue:
|
|
634
|
+
catchValue: n,
|
|
635
635
|
typeName: m.ZodCatch
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
describe(e) {
|
|
639
|
-
const
|
|
640
|
-
return new
|
|
639
|
+
const n = this.constructor;
|
|
640
|
+
return new n({
|
|
641
641
|
...this._def,
|
|
642
642
|
description: e
|
|
643
643
|
});
|
|
644
644
|
}
|
|
645
645
|
pipe(e) {
|
|
646
|
-
return
|
|
646
|
+
return ke.create(this, e);
|
|
647
647
|
}
|
|
648
648
|
readonly() {
|
|
649
|
-
return
|
|
649
|
+
return be.create(this);
|
|
650
650
|
}
|
|
651
651
|
isOptional() {
|
|
652
652
|
return this.safeParse(void 0).success;
|
|
@@ -655,43 +655,43 @@ class v {
|
|
|
655
655
|
return this.safeParse(null).success;
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
|
-
const
|
|
658
|
+
const St = /^c[^\s-]{8,}$/i, Et = /^[0-9a-z]+$/, Ct = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Tt = /^[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, Ot = /^[a-z0-9_-]{21}$/i, At = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Nt = /^[-+]?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)?)??$/, $t = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Rt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
659
659
|
let $e;
|
|
660
|
-
const
|
|
661
|
-
function
|
|
660
|
+
const It = /^(?:(?: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])$/, jt = /^(?:(?: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])$/, Dt = /^(([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]))$/, Lt = /^(([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])$/, Zt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Mt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, at = "((\\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])))", Pt = new RegExp(`^${at}$`);
|
|
661
|
+
function it(t) {
|
|
662
662
|
let e = "[0-5]\\d";
|
|
663
663
|
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
664
|
-
const
|
|
665
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${
|
|
664
|
+
const n = t.precision ? "+" : "?";
|
|
665
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
668
|
-
return new RegExp(`^${
|
|
667
|
+
function Bt(t) {
|
|
668
|
+
return new RegExp(`^${it(t)}$`);
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
let e = `${
|
|
672
|
-
const
|
|
673
|
-
return
|
|
670
|
+
function ot(t) {
|
|
671
|
+
let e = `${at}T${it(t)}`;
|
|
672
|
+
const n = [];
|
|
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
|
|
676
|
-
return !!((e === "v4" || !e) &&
|
|
675
|
+
function Ut(t, e) {
|
|
676
|
+
return !!((e === "v4" || !e) && It.test(t) || (e === "v6" || !e) && Dt.test(t));
|
|
677
677
|
}
|
|
678
|
-
function
|
|
679
|
-
if (!
|
|
678
|
+
function Ft(t, e) {
|
|
679
|
+
if (!At.test(t))
|
|
680
680
|
return !1;
|
|
681
681
|
try {
|
|
682
|
-
const [
|
|
683
|
-
if (!
|
|
682
|
+
const [n] = t.split(".");
|
|
683
|
+
if (!n)
|
|
684
684
|
return !1;
|
|
685
|
-
const
|
|
685
|
+
const s = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.length % 4) % 4, "="), r = JSON.parse(atob(s));
|
|
686
686
|
return !(typeof r != "object" || r === null || "typ" in r && r?.typ !== "JWT" || !r.alg || e && r.alg !== e);
|
|
687
687
|
} catch {
|
|
688
688
|
return !1;
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
|
-
function
|
|
692
|
-
return !!((e === "v4" || !e) &&
|
|
691
|
+
function Vt(t, e) {
|
|
692
|
+
return !!((e === "v4" || !e) && jt.test(t) || (e === "v6" || !e) && Lt.test(t));
|
|
693
693
|
}
|
|
694
|
-
class
|
|
694
|
+
class B extends v {
|
|
695
695
|
_parse(e) {
|
|
696
696
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
697
697
|
const a = this._getOrReturnCtx(e);
|
|
@@ -701,7 +701,7 @@ class U extends v {
|
|
|
701
701
|
received: a.parsedType
|
|
702
702
|
}), y;
|
|
703
703
|
}
|
|
704
|
-
const
|
|
704
|
+
const s = new $();
|
|
705
705
|
let r;
|
|
706
706
|
for (const a of this._def.checks)
|
|
707
707
|
if (a.kind === "min")
|
|
@@ -712,7 +712,7 @@ class U extends v {
|
|
|
712
712
|
inclusive: !0,
|
|
713
713
|
exact: !1,
|
|
714
714
|
message: a.message
|
|
715
|
-
}),
|
|
715
|
+
}), s.dirty());
|
|
716
716
|
else if (a.kind === "max")
|
|
717
717
|
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
718
718
|
code: u.too_big,
|
|
@@ -721,7 +721,7 @@ class U extends v {
|
|
|
721
721
|
inclusive: !0,
|
|
722
722
|
exact: !1,
|
|
723
723
|
message: a.message
|
|
724
|
-
}),
|
|
724
|
+
}), s.dirty());
|
|
725
725
|
else if (a.kind === "length") {
|
|
726
726
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
727
727
|
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
@@ -738,49 +738,49 @@ class U extends v {
|
|
|
738
738
|
inclusive: !0,
|
|
739
739
|
exact: !0,
|
|
740
740
|
message: a.message
|
|
741
|
-
}),
|
|
741
|
+
}), s.dirty());
|
|
742
742
|
} else if (a.kind === "email")
|
|
743
|
-
|
|
743
|
+
$t.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
744
744
|
validation: "email",
|
|
745
745
|
code: u.invalid_string,
|
|
746
746
|
message: a.message
|
|
747
|
-
}),
|
|
747
|
+
}), s.dirty());
|
|
748
748
|
else if (a.kind === "emoji")
|
|
749
|
-
$e || ($e = new RegExp(
|
|
749
|
+
$e || ($e = new RegExp(Rt, "u")), $e.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
750
750
|
validation: "emoji",
|
|
751
751
|
code: u.invalid_string,
|
|
752
752
|
message: a.message
|
|
753
|
-
}),
|
|
753
|
+
}), s.dirty());
|
|
754
754
|
else if (a.kind === "uuid")
|
|
755
|
-
|
|
755
|
+
Tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
756
756
|
validation: "uuid",
|
|
757
757
|
code: u.invalid_string,
|
|
758
758
|
message: a.message
|
|
759
|
-
}),
|
|
759
|
+
}), s.dirty());
|
|
760
760
|
else if (a.kind === "nanoid")
|
|
761
|
-
|
|
761
|
+
Ot.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
762
762
|
validation: "nanoid",
|
|
763
763
|
code: u.invalid_string,
|
|
764
764
|
message: a.message
|
|
765
|
-
}),
|
|
765
|
+
}), s.dirty());
|
|
766
766
|
else if (a.kind === "cuid")
|
|
767
|
-
|
|
767
|
+
St.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
768
768
|
validation: "cuid",
|
|
769
769
|
code: u.invalid_string,
|
|
770
770
|
message: a.message
|
|
771
|
-
}),
|
|
771
|
+
}), s.dirty());
|
|
772
772
|
else if (a.kind === "cuid2")
|
|
773
|
-
|
|
773
|
+
Et.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
774
774
|
validation: "cuid2",
|
|
775
775
|
code: u.invalid_string,
|
|
776
776
|
message: a.message
|
|
777
|
-
}),
|
|
777
|
+
}), s.dirty());
|
|
778
778
|
else if (a.kind === "ulid")
|
|
779
|
-
|
|
779
|
+
Ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
780
780
|
validation: "ulid",
|
|
781
781
|
code: u.invalid_string,
|
|
782
782
|
message: a.message
|
|
783
|
-
}),
|
|
783
|
+
}), s.dirty());
|
|
784
784
|
else if (a.kind === "url")
|
|
785
785
|
try {
|
|
786
786
|
new URL(e.data);
|
|
@@ -789,72 +789,72 @@ class U extends v {
|
|
|
789
789
|
validation: "url",
|
|
790
790
|
code: u.invalid_string,
|
|
791
791
|
message: a.message
|
|
792
|
-
}),
|
|
792
|
+
}), s.dirty();
|
|
793
793
|
}
|
|
794
794
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
795
795
|
validation: "regex",
|
|
796
796
|
code: u.invalid_string,
|
|
797
797
|
message: a.message
|
|
798
|
-
}),
|
|
798
|
+
}), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
799
799
|
code: u.invalid_string,
|
|
800
800
|
validation: { includes: a.value, position: a.position },
|
|
801
801
|
message: a.message
|
|
802
|
-
}),
|
|
802
|
+
}), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
803
803
|
code: u.invalid_string,
|
|
804
804
|
validation: { startsWith: a.value },
|
|
805
805
|
message: a.message
|
|
806
|
-
}),
|
|
806
|
+
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
807
807
|
code: u.invalid_string,
|
|
808
808
|
validation: { endsWith: a.value },
|
|
809
809
|
message: a.message
|
|
810
|
-
}),
|
|
810
|
+
}), s.dirty()) : a.kind === "datetime" ? ot(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
811
811
|
code: u.invalid_string,
|
|
812
812
|
validation: "datetime",
|
|
813
813
|
message: a.message
|
|
814
|
-
}),
|
|
814
|
+
}), s.dirty()) : a.kind === "date" ? Pt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
815
815
|
code: u.invalid_string,
|
|
816
816
|
validation: "date",
|
|
817
817
|
message: a.message
|
|
818
|
-
}),
|
|
818
|
+
}), s.dirty()) : a.kind === "time" ? Bt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
819
819
|
code: u.invalid_string,
|
|
820
820
|
validation: "time",
|
|
821
821
|
message: a.message
|
|
822
|
-
}),
|
|
822
|
+
}), s.dirty()) : a.kind === "duration" ? Nt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
823
823
|
validation: "duration",
|
|
824
824
|
code: u.invalid_string,
|
|
825
825
|
message: a.message
|
|
826
|
-
}),
|
|
826
|
+
}), s.dirty()) : a.kind === "ip" ? Ut(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
827
827
|
validation: "ip",
|
|
828
828
|
code: u.invalid_string,
|
|
829
829
|
message: a.message
|
|
830
|
-
}),
|
|
830
|
+
}), s.dirty()) : a.kind === "jwt" ? Ft(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
831
831
|
validation: "jwt",
|
|
832
832
|
code: u.invalid_string,
|
|
833
833
|
message: a.message
|
|
834
|
-
}),
|
|
834
|
+
}), s.dirty()) : a.kind === "cidr" ? Vt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
835
835
|
validation: "cidr",
|
|
836
836
|
code: u.invalid_string,
|
|
837
837
|
message: a.message
|
|
838
|
-
}),
|
|
838
|
+
}), s.dirty()) : a.kind === "base64" ? Zt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
839
839
|
validation: "base64",
|
|
840
840
|
code: u.invalid_string,
|
|
841
841
|
message: a.message
|
|
842
|
-
}),
|
|
842
|
+
}), s.dirty()) : a.kind === "base64url" ? Mt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
843
843
|
validation: "base64url",
|
|
844
844
|
code: u.invalid_string,
|
|
845
845
|
message: a.message
|
|
846
|
-
}),
|
|
847
|
-
return { status:
|
|
846
|
+
}), s.dirty()) : b.assertNever(a);
|
|
847
|
+
return { status: s.value, value: e.data };
|
|
848
848
|
}
|
|
849
|
-
_regex(e,
|
|
849
|
+
_regex(e, n, s) {
|
|
850
850
|
return this.refinement((r) => e.test(r), {
|
|
851
|
-
validation:
|
|
851
|
+
validation: n,
|
|
852
852
|
code: u.invalid_string,
|
|
853
|
-
...p.errToObj(
|
|
853
|
+
...p.errToObj(s)
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
_addCheck(e) {
|
|
857
|
-
return new
|
|
857
|
+
return new B({
|
|
858
858
|
...this._def,
|
|
859
859
|
checks: [...this._def.checks, e]
|
|
860
860
|
});
|
|
@@ -933,54 +933,54 @@ class U extends v {
|
|
|
933
933
|
duration(e) {
|
|
934
934
|
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
935
935
|
}
|
|
936
|
-
regex(e,
|
|
936
|
+
regex(e, n) {
|
|
937
937
|
return this._addCheck({
|
|
938
938
|
kind: "regex",
|
|
939
939
|
regex: e,
|
|
940
|
-
...p.errToObj(
|
|
940
|
+
...p.errToObj(n)
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
|
-
includes(e,
|
|
943
|
+
includes(e, n) {
|
|
944
944
|
return this._addCheck({
|
|
945
945
|
kind: "includes",
|
|
946
946
|
value: e,
|
|
947
|
-
position:
|
|
948
|
-
...p.errToObj(
|
|
947
|
+
position: n?.position,
|
|
948
|
+
...p.errToObj(n?.message)
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
|
-
startsWith(e,
|
|
951
|
+
startsWith(e, n) {
|
|
952
952
|
return this._addCheck({
|
|
953
953
|
kind: "startsWith",
|
|
954
954
|
value: e,
|
|
955
|
-
...p.errToObj(
|
|
955
|
+
...p.errToObj(n)
|
|
956
956
|
});
|
|
957
957
|
}
|
|
958
|
-
endsWith(e,
|
|
958
|
+
endsWith(e, n) {
|
|
959
959
|
return this._addCheck({
|
|
960
960
|
kind: "endsWith",
|
|
961
961
|
value: e,
|
|
962
|
-
...p.errToObj(
|
|
962
|
+
...p.errToObj(n)
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
min(e,
|
|
965
|
+
min(e, n) {
|
|
966
966
|
return this._addCheck({
|
|
967
967
|
kind: "min",
|
|
968
968
|
value: e,
|
|
969
|
-
...p.errToObj(
|
|
969
|
+
...p.errToObj(n)
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
|
-
max(e,
|
|
972
|
+
max(e, n) {
|
|
973
973
|
return this._addCheck({
|
|
974
974
|
kind: "max",
|
|
975
975
|
value: e,
|
|
976
|
-
...p.errToObj(
|
|
976
|
+
...p.errToObj(n)
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
|
-
length(e,
|
|
979
|
+
length(e, n) {
|
|
980
980
|
return this._addCheck({
|
|
981
981
|
kind: "length",
|
|
982
982
|
value: e,
|
|
983
|
-
...p.errToObj(
|
|
983
|
+
...p.errToObj(n)
|
|
984
984
|
});
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
@@ -990,19 +990,19 @@ class U extends v {
|
|
|
990
990
|
return this.min(1, p.errToObj(e));
|
|
991
991
|
}
|
|
992
992
|
trim() {
|
|
993
|
-
return new
|
|
993
|
+
return new B({
|
|
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 B({
|
|
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 B({
|
|
1006
1006
|
...this._def,
|
|
1007
1007
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1008
1008
|
});
|
|
@@ -1057,28 +1057,28 @@ class U extends v {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
get minLength() {
|
|
1059
1059
|
let e = null;
|
|
1060
|
-
for (const
|
|
1061
|
-
|
|
1060
|
+
for (const n of this._def.checks)
|
|
1061
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1062
1062
|
return e;
|
|
1063
1063
|
}
|
|
1064
1064
|
get maxLength() {
|
|
1065
1065
|
let e = null;
|
|
1066
|
-
for (const
|
|
1067
|
-
|
|
1066
|
+
for (const n of this._def.checks)
|
|
1067
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1068
1068
|
return e;
|
|
1069
1069
|
}
|
|
1070
1070
|
}
|
|
1071
|
-
|
|
1071
|
+
B.create = (t) => new B({
|
|
1072
1072
|
checks: [],
|
|
1073
1073
|
typeName: m.ZodString,
|
|
1074
1074
|
coerce: t?.coerce ?? !1,
|
|
1075
1075
|
..._(t)
|
|
1076
1076
|
});
|
|
1077
|
-
function
|
|
1078
|
-
const
|
|
1077
|
+
function qt(t, e) {
|
|
1078
|
+
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = n > s ? n : s, a = Number.parseInt(t.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
1079
1079
|
return a % i / 10 ** r;
|
|
1080
1080
|
}
|
|
1081
|
-
class
|
|
1081
|
+
class X extends v {
|
|
1082
1082
|
constructor() {
|
|
1083
1083
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1084
1084
|
}
|
|
@@ -1091,66 +1091,66 @@ class K extends v {
|
|
|
1091
1091
|
received: a.parsedType
|
|
1092
1092
|
}), y;
|
|
1093
1093
|
}
|
|
1094
|
-
let
|
|
1094
|
+
let s;
|
|
1095
1095
|
const r = new $();
|
|
1096
1096
|
for (const a of this._def.checks)
|
|
1097
|
-
a.kind === "int" ? b.isInteger(e.data) || (
|
|
1097
|
+
a.kind === "int" ? b.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1098
1098
|
code: u.invalid_type,
|
|
1099
1099
|
expected: "integer",
|
|
1100
1100
|
received: "float",
|
|
1101
1101
|
message: a.message
|
|
1102
|
-
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1102
|
+
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1103
1103
|
code: u.too_small,
|
|
1104
1104
|
minimum: a.value,
|
|
1105
1105
|
type: "number",
|
|
1106
1106
|
inclusive: a.inclusive,
|
|
1107
1107
|
exact: !1,
|
|
1108
1108
|
message: a.message
|
|
1109
|
-
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (
|
|
1109
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1110
1110
|
code: u.too_big,
|
|
1111
1111
|
maximum: a.value,
|
|
1112
1112
|
type: "number",
|
|
1113
1113
|
inclusive: a.inclusive,
|
|
1114
1114
|
exact: !1,
|
|
1115
1115
|
message: a.message
|
|
1116
|
-
}), r.dirty()) : a.kind === "multipleOf" ?
|
|
1116
|
+
}), r.dirty()) : a.kind === "multipleOf" ? qt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1117
1117
|
code: u.not_multiple_of,
|
|
1118
1118
|
multipleOf: a.value,
|
|
1119
1119
|
message: a.message
|
|
1120
|
-
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (
|
|
1120
|
+
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1121
1121
|
code: u.not_finite,
|
|
1122
1122
|
message: a.message
|
|
1123
1123
|
}), r.dirty()) : b.assertNever(a);
|
|
1124
1124
|
return { status: r.value, value: e.data };
|
|
1125
1125
|
}
|
|
1126
|
-
gte(e,
|
|
1127
|
-
return this.setLimit("min", e, !0, p.toString(
|
|
1126
|
+
gte(e, n) {
|
|
1127
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
1128
1128
|
}
|
|
1129
|
-
gt(e,
|
|
1130
|
-
return this.setLimit("min", e, !1, p.toString(
|
|
1129
|
+
gt(e, n) {
|
|
1130
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
1131
1131
|
}
|
|
1132
|
-
lte(e,
|
|
1133
|
-
return this.setLimit("max", e, !0, p.toString(
|
|
1132
|
+
lte(e, n) {
|
|
1133
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
1134
1134
|
}
|
|
1135
|
-
lt(e,
|
|
1136
|
-
return this.setLimit("max", e, !1, p.toString(
|
|
1135
|
+
lt(e, n) {
|
|
1136
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
1137
1137
|
}
|
|
1138
|
-
setLimit(e,
|
|
1139
|
-
return new
|
|
1138
|
+
setLimit(e, n, s, r) {
|
|
1139
|
+
return new X({
|
|
1140
1140
|
...this._def,
|
|
1141
1141
|
checks: [
|
|
1142
1142
|
...this._def.checks,
|
|
1143
1143
|
{
|
|
1144
1144
|
kind: e,
|
|
1145
|
-
value:
|
|
1146
|
-
inclusive:
|
|
1145
|
+
value: n,
|
|
1146
|
+
inclusive: s,
|
|
1147
1147
|
message: p.toString(r)
|
|
1148
1148
|
}
|
|
1149
1149
|
]
|
|
1150
1150
|
});
|
|
1151
1151
|
}
|
|
1152
1152
|
_addCheck(e) {
|
|
1153
|
-
return new
|
|
1153
|
+
return new X({
|
|
1154
1154
|
...this._def,
|
|
1155
1155
|
checks: [...this._def.checks, e]
|
|
1156
1156
|
});
|
|
@@ -1193,11 +1193,11 @@ class K extends v {
|
|
|
1193
1193
|
message: p.toString(e)
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
1196
|
-
multipleOf(e,
|
|
1196
|
+
multipleOf(e, n) {
|
|
1197
1197
|
return this._addCheck({
|
|
1198
1198
|
kind: "multipleOf",
|
|
1199
1199
|
value: e,
|
|
1200
|
-
message: p.toString(
|
|
1200
|
+
message: p.toString(n)
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
1203
|
finite(e) {
|
|
@@ -1221,36 +1221,36 @@ class K extends v {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
get minValue() {
|
|
1223
1223
|
let e = null;
|
|
1224
|
-
for (const
|
|
1225
|
-
|
|
1224
|
+
for (const n of this._def.checks)
|
|
1225
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1226
1226
|
return e;
|
|
1227
1227
|
}
|
|
1228
1228
|
get maxValue() {
|
|
1229
1229
|
let e = null;
|
|
1230
|
-
for (const
|
|
1231
|
-
|
|
1230
|
+
for (const n of this._def.checks)
|
|
1231
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1232
1232
|
return e;
|
|
1233
1233
|
}
|
|
1234
1234
|
get isInt() {
|
|
1235
1235
|
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
|
|
1236
1236
|
}
|
|
1237
1237
|
get isFinite() {
|
|
1238
|
-
let e = null,
|
|
1239
|
-
for (const
|
|
1240
|
-
if (
|
|
1238
|
+
let e = null, n = null;
|
|
1239
|
+
for (const s of this._def.checks) {
|
|
1240
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1241
1241
|
return !0;
|
|
1242
|
-
|
|
1242
|
+
s.kind === "min" ? (n === null || s.value > n) && (n = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1243
1243
|
}
|
|
1244
|
-
return Number.isFinite(
|
|
1244
|
+
return Number.isFinite(n) && Number.isFinite(e);
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
X.create = (t) => new X({
|
|
1248
1248
|
checks: [],
|
|
1249
1249
|
typeName: m.ZodNumber,
|
|
1250
1250
|
coerce: t?.coerce || !1,
|
|
1251
1251
|
..._(t)
|
|
1252
1252
|
});
|
|
1253
|
-
class
|
|
1253
|
+
class ae extends v {
|
|
1254
1254
|
constructor() {
|
|
1255
1255
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1256
1256
|
}
|
|
@@ -1263,22 +1263,22 @@ class re extends v {
|
|
|
1263
1263
|
}
|
|
1264
1264
|
if (this._getType(e) !== h.bigint)
|
|
1265
1265
|
return this._getInvalidInput(e);
|
|
1266
|
-
let
|
|
1266
|
+
let s;
|
|
1267
1267
|
const r = new $();
|
|
1268
1268
|
for (const a of this._def.checks)
|
|
1269
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1269
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1270
1270
|
code: u.too_small,
|
|
1271
1271
|
type: "bigint",
|
|
1272
1272
|
minimum: a.value,
|
|
1273
1273
|
inclusive: a.inclusive,
|
|
1274
1274
|
message: a.message
|
|
1275
|
-
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (
|
|
1275
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1276
1276
|
code: u.too_big,
|
|
1277
1277
|
type: "bigint",
|
|
1278
1278
|
maximum: a.value,
|
|
1279
1279
|
inclusive: a.inclusive,
|
|
1280
1280
|
message: a.message
|
|
1281
|
-
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (
|
|
1281
|
+
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1282
1282
|
code: u.not_multiple_of,
|
|
1283
1283
|
multipleOf: a.value,
|
|
1284
1284
|
message: a.message
|
|
@@ -1286,41 +1286,41 @@ class re extends v {
|
|
|
1286
1286
|
return { status: r.value, value: e.data };
|
|
1287
1287
|
}
|
|
1288
1288
|
_getInvalidInput(e) {
|
|
1289
|
-
const
|
|
1290
|
-
return l(
|
|
1289
|
+
const n = this._getOrReturnCtx(e);
|
|
1290
|
+
return l(n, {
|
|
1291
1291
|
code: u.invalid_type,
|
|
1292
1292
|
expected: h.bigint,
|
|
1293
|
-
received:
|
|
1293
|
+
received: n.parsedType
|
|
1294
1294
|
}), y;
|
|
1295
1295
|
}
|
|
1296
|
-
gte(e,
|
|
1297
|
-
return this.setLimit("min", e, !0, p.toString(
|
|
1296
|
+
gte(e, n) {
|
|
1297
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
1298
1298
|
}
|
|
1299
|
-
gt(e,
|
|
1300
|
-
return this.setLimit("min", e, !1, p.toString(
|
|
1299
|
+
gt(e, n) {
|
|
1300
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
1301
1301
|
}
|
|
1302
|
-
lte(e,
|
|
1303
|
-
return this.setLimit("max", e, !0, p.toString(
|
|
1302
|
+
lte(e, n) {
|
|
1303
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
1304
1304
|
}
|
|
1305
|
-
lt(e,
|
|
1306
|
-
return this.setLimit("max", e, !1, p.toString(
|
|
1305
|
+
lt(e, n) {
|
|
1306
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
1307
1307
|
}
|
|
1308
|
-
setLimit(e,
|
|
1309
|
-
return new
|
|
1308
|
+
setLimit(e, n, s, r) {
|
|
1309
|
+
return new ae({
|
|
1310
1310
|
...this._def,
|
|
1311
1311
|
checks: [
|
|
1312
1312
|
...this._def.checks,
|
|
1313
1313
|
{
|
|
1314
1314
|
kind: e,
|
|
1315
|
-
value:
|
|
1316
|
-
inclusive:
|
|
1315
|
+
value: n,
|
|
1316
|
+
inclusive: s,
|
|
1317
1317
|
message: p.toString(r)
|
|
1318
1318
|
}
|
|
1319
1319
|
]
|
|
1320
1320
|
});
|
|
1321
1321
|
}
|
|
1322
1322
|
_addCheck(e) {
|
|
1323
|
-
return new
|
|
1323
|
+
return new ae({
|
|
1324
1324
|
...this._def,
|
|
1325
1325
|
checks: [...this._def.checks, e]
|
|
1326
1326
|
});
|
|
@@ -1357,51 +1357,51 @@ class re extends v {
|
|
|
1357
1357
|
message: p.toString(e)
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
|
-
multipleOf(e,
|
|
1360
|
+
multipleOf(e, n) {
|
|
1361
1361
|
return this._addCheck({
|
|
1362
1362
|
kind: "multipleOf",
|
|
1363
1363
|
value: e,
|
|
1364
|
-
message: p.toString(
|
|
1364
|
+
message: p.toString(n)
|
|
1365
1365
|
});
|
|
1366
1366
|
}
|
|
1367
1367
|
get minValue() {
|
|
1368
1368
|
let e = null;
|
|
1369
|
-
for (const
|
|
1370
|
-
|
|
1369
|
+
for (const n of this._def.checks)
|
|
1370
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1371
1371
|
return e;
|
|
1372
1372
|
}
|
|
1373
1373
|
get maxValue() {
|
|
1374
1374
|
let e = null;
|
|
1375
|
-
for (const
|
|
1376
|
-
|
|
1375
|
+
for (const n of this._def.checks)
|
|
1376
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1377
1377
|
return e;
|
|
1378
1378
|
}
|
|
1379
1379
|
}
|
|
1380
|
-
|
|
1380
|
+
ae.create = (t) => new ae({
|
|
1381
1381
|
checks: [],
|
|
1382
1382
|
typeName: m.ZodBigInt,
|
|
1383
1383
|
coerce: t?.coerce ?? !1,
|
|
1384
1384
|
..._(t)
|
|
1385
1385
|
});
|
|
1386
|
-
class
|
|
1386
|
+
class ge extends v {
|
|
1387
1387
|
_parse(e) {
|
|
1388
1388
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1389
|
-
const
|
|
1390
|
-
return l(
|
|
1389
|
+
const s = this._getOrReturnCtx(e);
|
|
1390
|
+
return l(s, {
|
|
1391
1391
|
code: u.invalid_type,
|
|
1392
1392
|
expected: h.boolean,
|
|
1393
|
-
received:
|
|
1393
|
+
received: s.parsedType
|
|
1394
1394
|
}), y;
|
|
1395
1395
|
}
|
|
1396
|
-
return
|
|
1396
|
+
return D(e.data);
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
|
|
1399
|
+
ge.create = (t) => new ge({
|
|
1400
1400
|
typeName: m.ZodBoolean,
|
|
1401
1401
|
coerce: t?.coerce || !1,
|
|
1402
1402
|
..._(t)
|
|
1403
1403
|
});
|
|
1404
|
-
class
|
|
1404
|
+
class le extends v {
|
|
1405
1405
|
_parse(e) {
|
|
1406
1406
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1407
1407
|
const a = this._getOrReturnCtx(e);
|
|
@@ -1417,7 +1417,7 @@ class de extends v {
|
|
|
1417
1417
|
code: u.invalid_date
|
|
1418
1418
|
}), y;
|
|
1419
1419
|
}
|
|
1420
|
-
const
|
|
1420
|
+
const s = new $();
|
|
1421
1421
|
let r;
|
|
1422
1422
|
for (const a of this._def.checks)
|
|
1423
1423
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
@@ -1427,140 +1427,140 @@ class de extends v {
|
|
|
1427
1427
|
exact: !1,
|
|
1428
1428
|
minimum: a.value,
|
|
1429
1429
|
type: "date"
|
|
1430
|
-
}),
|
|
1430
|
+
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1431
1431
|
code: u.too_big,
|
|
1432
1432
|
message: a.message,
|
|
1433
1433
|
inclusive: !0,
|
|
1434
1434
|
exact: !1,
|
|
1435
1435
|
maximum: a.value,
|
|
1436
1436
|
type: "date"
|
|
1437
|
-
}),
|
|
1437
|
+
}), s.dirty()) : b.assertNever(a);
|
|
1438
1438
|
return {
|
|
1439
|
-
status:
|
|
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 le({
|
|
1445
1445
|
...this._def,
|
|
1446
1446
|
checks: [...this._def.checks, e]
|
|
1447
1447
|
});
|
|
1448
1448
|
}
|
|
1449
|
-
min(e,
|
|
1449
|
+
min(e, n) {
|
|
1450
1450
|
return this._addCheck({
|
|
1451
1451
|
kind: "min",
|
|
1452
1452
|
value: e.getTime(),
|
|
1453
|
-
message: p.toString(
|
|
1453
|
+
message: p.toString(n)
|
|
1454
1454
|
});
|
|
1455
1455
|
}
|
|
1456
|
-
max(e,
|
|
1456
|
+
max(e, n) {
|
|
1457
1457
|
return this._addCheck({
|
|
1458
1458
|
kind: "max",
|
|
1459
1459
|
value: e.getTime(),
|
|
1460
|
-
message: p.toString(
|
|
1460
|
+
message: p.toString(n)
|
|
1461
1461
|
});
|
|
1462
1462
|
}
|
|
1463
1463
|
get minDate() {
|
|
1464
1464
|
let e = null;
|
|
1465
|
-
for (const
|
|
1466
|
-
|
|
1465
|
+
for (const n of this._def.checks)
|
|
1466
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1467
1467
|
return e != null ? new Date(e) : null;
|
|
1468
1468
|
}
|
|
1469
1469
|
get maxDate() {
|
|
1470
1470
|
let e = null;
|
|
1471
|
-
for (const
|
|
1472
|
-
|
|
1471
|
+
for (const n of this._def.checks)
|
|
1472
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1473
1473
|
return e != null ? new Date(e) : null;
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
|
-
|
|
1476
|
+
le.create = (t) => new le({
|
|
1477
1477
|
checks: [],
|
|
1478
1478
|
coerce: t?.coerce || !1,
|
|
1479
1479
|
typeName: m.ZodDate,
|
|
1480
1480
|
..._(t)
|
|
1481
1481
|
});
|
|
1482
|
-
class
|
|
1482
|
+
class Le extends v {
|
|
1483
1483
|
_parse(e) {
|
|
1484
1484
|
if (this._getType(e) !== h.symbol) {
|
|
1485
|
-
const
|
|
1486
|
-
return l(
|
|
1485
|
+
const s = this._getOrReturnCtx(e);
|
|
1486
|
+
return l(s, {
|
|
1487
1487
|
code: u.invalid_type,
|
|
1488
1488
|
expected: h.symbol,
|
|
1489
|
-
received:
|
|
1489
|
+
received: s.parsedType
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
1492
|
-
return
|
|
1492
|
+
return D(e.data);
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
|
|
1495
|
+
Le.create = (t) => new Le({
|
|
1496
1496
|
typeName: m.ZodSymbol,
|
|
1497
1497
|
..._(t)
|
|
1498
1498
|
});
|
|
1499
1499
|
class Ze extends v {
|
|
1500
1500
|
_parse(e) {
|
|
1501
1501
|
if (this._getType(e) !== h.undefined) {
|
|
1502
|
-
const
|
|
1503
|
-
return l(
|
|
1502
|
+
const s = this._getOrReturnCtx(e);
|
|
1503
|
+
return l(s, {
|
|
1504
1504
|
code: u.invalid_type,
|
|
1505
1505
|
expected: h.undefined,
|
|
1506
|
-
received:
|
|
1506
|
+
received: s.parsedType
|
|
1507
1507
|
}), y;
|
|
1508
1508
|
}
|
|
1509
|
-
return
|
|
1509
|
+
return D(e.data);
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
1512
|
Ze.create = (t) => new Ze({
|
|
1513
1513
|
typeName: m.ZodUndefined,
|
|
1514
1514
|
..._(t)
|
|
1515
1515
|
});
|
|
1516
|
-
class
|
|
1516
|
+
class Me extends v {
|
|
1517
1517
|
_parse(e) {
|
|
1518
1518
|
if (this._getType(e) !== h.null) {
|
|
1519
|
-
const
|
|
1520
|
-
return l(
|
|
1519
|
+
const s = this._getOrReturnCtx(e);
|
|
1520
|
+
return l(s, {
|
|
1521
1521
|
code: u.invalid_type,
|
|
1522
1522
|
expected: h.null,
|
|
1523
|
-
received:
|
|
1523
|
+
received: s.parsedType
|
|
1524
1524
|
}), y;
|
|
1525
1525
|
}
|
|
1526
|
-
return
|
|
1526
|
+
return D(e.data);
|
|
1527
1527
|
}
|
|
1528
1528
|
}
|
|
1529
|
-
|
|
1529
|
+
Me.create = (t) => new Me({
|
|
1530
1530
|
typeName: m.ZodNull,
|
|
1531
1531
|
..._(t)
|
|
1532
1532
|
});
|
|
1533
|
-
class
|
|
1533
|
+
class Pe extends v {
|
|
1534
1534
|
constructor() {
|
|
1535
1535
|
super(...arguments), this._any = !0;
|
|
1536
1536
|
}
|
|
1537
1537
|
_parse(e) {
|
|
1538
|
-
return
|
|
1538
|
+
return D(e.data);
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
|
-
|
|
1541
|
+
Pe.create = (t) => new Pe({
|
|
1542
1542
|
typeName: m.ZodAny,
|
|
1543
1543
|
..._(t)
|
|
1544
1544
|
});
|
|
1545
|
-
class
|
|
1545
|
+
class Be extends v {
|
|
1546
1546
|
constructor() {
|
|
1547
1547
|
super(...arguments), this._unknown = !0;
|
|
1548
1548
|
}
|
|
1549
1549
|
_parse(e) {
|
|
1550
|
-
return
|
|
1550
|
+
return D(e.data);
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
|
-
|
|
1553
|
+
Be.create = (t) => new Be({
|
|
1554
1554
|
typeName: m.ZodUnknown,
|
|
1555
1555
|
..._(t)
|
|
1556
1556
|
});
|
|
1557
1557
|
class W extends v {
|
|
1558
1558
|
_parse(e) {
|
|
1559
|
-
const
|
|
1560
|
-
return l(
|
|
1559
|
+
const n = this._getOrReturnCtx(e);
|
|
1560
|
+
return l(n, {
|
|
1561
1561
|
code: u.invalid_type,
|
|
1562
1562
|
expected: h.never,
|
|
1563
|
-
received:
|
|
1563
|
+
received: n.parsedType
|
|
1564
1564
|
}), y;
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
@@ -1571,32 +1571,32 @@ W.create = (t) => new W({
|
|
|
1571
1571
|
class Ue extends v {
|
|
1572
1572
|
_parse(e) {
|
|
1573
1573
|
if (this._getType(e) !== h.undefined) {
|
|
1574
|
-
const
|
|
1575
|
-
return l(
|
|
1574
|
+
const s = this._getOrReturnCtx(e);
|
|
1575
|
+
return l(s, {
|
|
1576
1576
|
code: u.invalid_type,
|
|
1577
1577
|
expected: h.void,
|
|
1578
|
-
received:
|
|
1578
|
+
received: s.parsedType
|
|
1579
1579
|
}), y;
|
|
1580
1580
|
}
|
|
1581
|
-
return
|
|
1581
|
+
return D(e.data);
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
1584
|
Ue.create = (t) => new Ue({
|
|
1585
1585
|
typeName: m.ZodVoid,
|
|
1586
1586
|
..._(t)
|
|
1587
1587
|
});
|
|
1588
|
-
class
|
|
1588
|
+
class L extends v {
|
|
1589
1589
|
_parse(e) {
|
|
1590
|
-
const { ctx:
|
|
1591
|
-
if (
|
|
1592
|
-
return l(
|
|
1590
|
+
const { ctx: n, status: s } = this._processInputParams(e), r = this._def;
|
|
1591
|
+
if (n.parsedType !== h.array)
|
|
1592
|
+
return l(n, {
|
|
1593
1593
|
code: u.invalid_type,
|
|
1594
1594
|
expected: h.array,
|
|
1595
|
-
received:
|
|
1595
|
+
received: n.parsedType
|
|
1596
1596
|
}), y;
|
|
1597
1597
|
if (r.exactLength !== null) {
|
|
1598
|
-
const i =
|
|
1599
|
-
(i || o) && (l(
|
|
1598
|
+
const i = n.data.length > r.exactLength.value, o = n.data.length < r.exactLength.value;
|
|
1599
|
+
(i || o) && (l(n, {
|
|
1600
1600
|
code: i ? u.too_big : u.too_small,
|
|
1601
1601
|
minimum: o ? r.exactLength.value : void 0,
|
|
1602
1602
|
maximum: i ? r.exactLength.value : void 0,
|
|
@@ -1604,53 +1604,53 @@ class Z extends v {
|
|
|
1604
1604
|
inclusive: !0,
|
|
1605
1605
|
exact: !0,
|
|
1606
1606
|
message: r.exactLength.message
|
|
1607
|
-
}),
|
|
1607
|
+
}), s.dirty());
|
|
1608
1608
|
}
|
|
1609
|
-
if (r.minLength !== null &&
|
|
1609
|
+
if (r.minLength !== null && n.data.length < r.minLength.value && (l(n, {
|
|
1610
1610
|
code: u.too_small,
|
|
1611
1611
|
minimum: r.minLength.value,
|
|
1612
1612
|
type: "array",
|
|
1613
1613
|
inclusive: !0,
|
|
1614
1614
|
exact: !1,
|
|
1615
1615
|
message: r.minLength.message
|
|
1616
|
-
}),
|
|
1616
|
+
}), s.dirty()), r.maxLength !== null && n.data.length > r.maxLength.value && (l(n, {
|
|
1617
1617
|
code: u.too_big,
|
|
1618
1618
|
maximum: r.maxLength.value,
|
|
1619
1619
|
type: "array",
|
|
1620
1620
|
inclusive: !0,
|
|
1621
1621
|
exact: !1,
|
|
1622
1622
|
message: r.maxLength.message
|
|
1623
|
-
}),
|
|
1624
|
-
return Promise.all([...
|
|
1625
|
-
const a = [...
|
|
1626
|
-
return $.mergeArray(
|
|
1623
|
+
}), s.dirty()), n.common.async)
|
|
1624
|
+
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new F(n, i, n.path, o)))).then((i) => $.mergeArray(s, i));
|
|
1625
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new F(n, i, n.path, o)));
|
|
1626
|
+
return $.mergeArray(s, a);
|
|
1627
1627
|
}
|
|
1628
1628
|
get element() {
|
|
1629
1629
|
return this._def.type;
|
|
1630
1630
|
}
|
|
1631
|
-
min(e,
|
|
1632
|
-
return new
|
|
1631
|
+
min(e, n) {
|
|
1632
|
+
return new L({
|
|
1633
1633
|
...this._def,
|
|
1634
|
-
minLength: { value: e, message: p.toString(
|
|
1634
|
+
minLength: { value: e, message: p.toString(n) }
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
|
-
max(e,
|
|
1638
|
-
return new
|
|
1637
|
+
max(e, n) {
|
|
1638
|
+
return new L({
|
|
1639
1639
|
...this._def,
|
|
1640
|
-
maxLength: { value: e, message: p.toString(
|
|
1640
|
+
maxLength: { value: e, message: p.toString(n) }
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
|
-
length(e,
|
|
1644
|
-
return new
|
|
1643
|
+
length(e, n) {
|
|
1644
|
+
return new L({
|
|
1645
1645
|
...this._def,
|
|
1646
|
-
exactLength: { value: e, message: p.toString(
|
|
1646
|
+
exactLength: { value: e, message: p.toString(n) }
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
1649
|
nonempty(e) {
|
|
1650
1650
|
return this.min(1, e);
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
|
-
|
|
1653
|
+
L.create = (t, e) => new L({
|
|
1654
1654
|
type: t,
|
|
1655
1655
|
minLength: null,
|
|
1656
1656
|
maxLength: null,
|
|
@@ -1659,30 +1659,30 @@ Z.create = (t, e) => new Z({
|
|
|
1659
1659
|
..._(e)
|
|
1660
1660
|
});
|
|
1661
1661
|
function se(t) {
|
|
1662
|
-
if (t instanceof
|
|
1662
|
+
if (t instanceof C) {
|
|
1663
1663
|
const e = {};
|
|
1664
|
-
for (const
|
|
1665
|
-
const
|
|
1666
|
-
e[
|
|
1664
|
+
for (const n in t.shape) {
|
|
1665
|
+
const s = t.shape[n];
|
|
1666
|
+
e[n] = z.create(se(s));
|
|
1667
1667
|
}
|
|
1668
|
-
return new
|
|
1668
|
+
return new C({
|
|
1669
1669
|
...t._def,
|
|
1670
1670
|
shape: () => e
|
|
1671
1671
|
});
|
|
1672
|
-
} else return t instanceof
|
|
1672
|
+
} else return t instanceof L ? new L({
|
|
1673
1673
|
...t._def,
|
|
1674
1674
|
type: se(t.element)
|
|
1675
|
-
}) : t instanceof z ? z.create(se(t.unwrap())) : t instanceof
|
|
1675
|
+
}) : t instanceof z ? z.create(se(t.unwrap())) : t instanceof te ? te.create(se(t.unwrap())) : t instanceof H ? H.create(t.items.map((e) => se(e))) : t;
|
|
1676
1676
|
}
|
|
1677
|
-
class
|
|
1677
|
+
class C extends v {
|
|
1678
1678
|
constructor() {
|
|
1679
1679
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1680
1680
|
}
|
|
1681
1681
|
_getCached() {
|
|
1682
1682
|
if (this._cached !== null)
|
|
1683
1683
|
return this._cached;
|
|
1684
|
-
const e = this._def.shape(),
|
|
1685
|
-
return this._cached = { shape: e, keys:
|
|
1684
|
+
const e = this._def.shape(), n = b.objectKeys(e);
|
|
1685
|
+
return this._cached = { shape: e, keys: n }, this._cached;
|
|
1686
1686
|
}
|
|
1687
1687
|
_parse(e) {
|
|
1688
1688
|
if (this._getType(e) !== h.object) {
|
|
@@ -1693,7 +1693,7 @@ class T extends v {
|
|
|
1693
1693
|
received: d.parsedType
|
|
1694
1694
|
}), y;
|
|
1695
1695
|
}
|
|
1696
|
-
const { status:
|
|
1696
|
+
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1697
1697
|
if (!(this._def.catchall instanceof W && this._def.unknownKeys === "strip"))
|
|
1698
1698
|
for (const d in r.data)
|
|
1699
1699
|
i.includes(d) || o.push(d);
|
|
@@ -1718,7 +1718,7 @@ class T extends v {
|
|
|
1718
1718
|
o.length > 0 && (l(r, {
|
|
1719
1719
|
code: u.unrecognized_keys,
|
|
1720
1720
|
keys: o
|
|
1721
|
-
}),
|
|
1721
|
+
}), s.dirty());
|
|
1722
1722
|
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1723
1723
|
} else {
|
|
1724
1724
|
const d = this._def.catchall;
|
|
@@ -1737,27 +1737,27 @@ class T extends v {
|
|
|
1737
1737
|
return r.common.async ? Promise.resolve().then(async () => {
|
|
1738
1738
|
const d = [];
|
|
1739
1739
|
for (const f of c) {
|
|
1740
|
-
const x = await f.key,
|
|
1740
|
+
const x = await f.key, T = await f.value;
|
|
1741
1741
|
d.push({
|
|
1742
1742
|
key: x,
|
|
1743
|
-
value:
|
|
1743
|
+
value: T,
|
|
1744
1744
|
alwaysSet: f.alwaysSet
|
|
1745
1745
|
});
|
|
1746
1746
|
}
|
|
1747
1747
|
return d;
|
|
1748
|
-
}).then((d) => $.mergeObjectSync(
|
|
1748
|
+
}).then((d) => $.mergeObjectSync(s, d)) : $.mergeObjectSync(s, c);
|
|
1749
1749
|
}
|
|
1750
1750
|
get shape() {
|
|
1751
1751
|
return this._def.shape();
|
|
1752
1752
|
}
|
|
1753
1753
|
strict(e) {
|
|
1754
|
-
return p.errToObj, new
|
|
1754
|
+
return p.errToObj, new C({
|
|
1755
1755
|
...this._def,
|
|
1756
1756
|
unknownKeys: "strict",
|
|
1757
1757
|
...e !== void 0 ? {
|
|
1758
|
-
errorMap: (
|
|
1759
|
-
const r = this._def.errorMap?.(
|
|
1760
|
-
return
|
|
1758
|
+
errorMap: (n, s) => {
|
|
1759
|
+
const r = this._def.errorMap?.(n, s).message ?? s.defaultError;
|
|
1760
|
+
return n.code === "unrecognized_keys" ? {
|
|
1761
1761
|
message: p.errToObj(e).message ?? r
|
|
1762
1762
|
} : {
|
|
1763
1763
|
message: r
|
|
@@ -1767,13 +1767,13 @@ class T extends v {
|
|
|
1767
1767
|
});
|
|
1768
1768
|
}
|
|
1769
1769
|
strip() {
|
|
1770
|
-
return new
|
|
1770
|
+
return new C({
|
|
1771
1771
|
...this._def,
|
|
1772
1772
|
unknownKeys: "strip"
|
|
1773
1773
|
});
|
|
1774
1774
|
}
|
|
1775
1775
|
passthrough() {
|
|
1776
|
-
return new
|
|
1776
|
+
return new C({
|
|
1777
1777
|
...this._def,
|
|
1778
1778
|
unknownKeys: "passthrough"
|
|
1779
1779
|
});
|
|
@@ -1796,7 +1796,7 @@ class T extends v {
|
|
|
1796
1796
|
// }) as any;
|
|
1797
1797
|
// };
|
|
1798
1798
|
extend(e) {
|
|
1799
|
-
return new
|
|
1799
|
+
return new C({
|
|
1800
1800
|
...this._def,
|
|
1801
1801
|
shape: () => ({
|
|
1802
1802
|
...this._def.shape(),
|
|
@@ -1810,7 +1810,7 @@ class T extends v {
|
|
|
1810
1810
|
* upgrade if you are experiencing issues.
|
|
1811
1811
|
*/
|
|
1812
1812
|
merge(e) {
|
|
1813
|
-
return new
|
|
1813
|
+
return new C({
|
|
1814
1814
|
unknownKeys: e._def.unknownKeys,
|
|
1815
1815
|
catchall: e._def.catchall,
|
|
1816
1816
|
shape: () => ({
|
|
@@ -1855,8 +1855,8 @@ class T extends v {
|
|
|
1855
1855
|
// }) as any;
|
|
1856
1856
|
// return merged;
|
|
1857
1857
|
// }
|
|
1858
|
-
setKey(e,
|
|
1859
|
-
return this.augment({ [e]:
|
|
1858
|
+
setKey(e, n) {
|
|
1859
|
+
return this.augment({ [e]: n });
|
|
1860
1860
|
}
|
|
1861
1861
|
// merge<Incoming extends AnyZodObject>(
|
|
1862
1862
|
// merging: Incoming
|
|
@@ -1880,27 +1880,27 @@ class T extends v {
|
|
|
1880
1880
|
// return merged;
|
|
1881
1881
|
// }
|
|
1882
1882
|
catchall(e) {
|
|
1883
|
-
return new
|
|
1883
|
+
return new C({
|
|
1884
1884
|
...this._def,
|
|
1885
1885
|
catchall: e
|
|
1886
1886
|
});
|
|
1887
1887
|
}
|
|
1888
1888
|
pick(e) {
|
|
1889
|
-
const
|
|
1890
|
-
for (const
|
|
1891
|
-
e[
|
|
1892
|
-
return new
|
|
1889
|
+
const n = {};
|
|
1890
|
+
for (const s of b.objectKeys(e))
|
|
1891
|
+
e[s] && this.shape[s] && (n[s] = this.shape[s]);
|
|
1892
|
+
return new C({
|
|
1893
1893
|
...this._def,
|
|
1894
|
-
shape: () =>
|
|
1894
|
+
shape: () => n
|
|
1895
1895
|
});
|
|
1896
1896
|
}
|
|
1897
1897
|
omit(e) {
|
|
1898
|
-
const
|
|
1899
|
-
for (const
|
|
1900
|
-
e[
|
|
1901
|
-
return new
|
|
1898
|
+
const n = {};
|
|
1899
|
+
for (const s of b.objectKeys(this.shape))
|
|
1900
|
+
e[s] || (n[s] = this.shape[s]);
|
|
1901
|
+
return new C({
|
|
1902
1902
|
...this._def,
|
|
1903
|
-
shape: () =>
|
|
1903
|
+
shape: () => n
|
|
1904
1904
|
});
|
|
1905
1905
|
}
|
|
1906
1906
|
/**
|
|
@@ -1910,87 +1910,87 @@ class T extends v {
|
|
|
1910
1910
|
return se(this);
|
|
1911
1911
|
}
|
|
1912
1912
|
partial(e) {
|
|
1913
|
-
const
|
|
1914
|
-
for (const
|
|
1915
|
-
const r = this.shape[
|
|
1916
|
-
e && !e[
|
|
1913
|
+
const n = {};
|
|
1914
|
+
for (const s of b.objectKeys(this.shape)) {
|
|
1915
|
+
const r = this.shape[s];
|
|
1916
|
+
e && !e[s] ? n[s] = r : n[s] = r.optional();
|
|
1917
1917
|
}
|
|
1918
|
-
return new
|
|
1918
|
+
return new C({
|
|
1919
1919
|
...this._def,
|
|
1920
|
-
shape: () =>
|
|
1920
|
+
shape: () => n
|
|
1921
1921
|
});
|
|
1922
1922
|
}
|
|
1923
1923
|
required(e) {
|
|
1924
|
-
const
|
|
1925
|
-
for (const
|
|
1926
|
-
if (e && !e[
|
|
1927
|
-
s
|
|
1924
|
+
const n = {};
|
|
1925
|
+
for (const s of b.objectKeys(this.shape))
|
|
1926
|
+
if (e && !e[s])
|
|
1927
|
+
n[s] = this.shape[s];
|
|
1928
1928
|
else {
|
|
1929
|
-
let a = this.shape[
|
|
1929
|
+
let a = this.shape[s];
|
|
1930
1930
|
for (; a instanceof z; )
|
|
1931
1931
|
a = a._def.innerType;
|
|
1932
|
-
s
|
|
1932
|
+
n[s] = a;
|
|
1933
1933
|
}
|
|
1934
|
-
return new
|
|
1934
|
+
return new C({
|
|
1935
1935
|
...this._def,
|
|
1936
|
-
shape: () =>
|
|
1936
|
+
shape: () => n
|
|
1937
1937
|
});
|
|
1938
1938
|
}
|
|
1939
1939
|
keyof() {
|
|
1940
|
-
return
|
|
1940
|
+
return ct(b.objectKeys(this.shape));
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
|
-
|
|
1943
|
+
C.create = (t, e) => new C({
|
|
1944
1944
|
shape: () => t,
|
|
1945
1945
|
unknownKeys: "strip",
|
|
1946
1946
|
catchall: W.create(),
|
|
1947
1947
|
typeName: m.ZodObject,
|
|
1948
1948
|
..._(e)
|
|
1949
1949
|
});
|
|
1950
|
-
|
|
1950
|
+
C.strictCreate = (t, e) => new C({
|
|
1951
1951
|
shape: () => t,
|
|
1952
1952
|
unknownKeys: "strict",
|
|
1953
1953
|
catchall: W.create(),
|
|
1954
1954
|
typeName: m.ZodObject,
|
|
1955
1955
|
..._(e)
|
|
1956
1956
|
});
|
|
1957
|
-
|
|
1957
|
+
C.lazycreate = (t, e) => new C({
|
|
1958
1958
|
shape: t,
|
|
1959
1959
|
unknownKeys: "strip",
|
|
1960
1960
|
catchall: W.create(),
|
|
1961
1961
|
typeName: m.ZodObject,
|
|
1962
1962
|
..._(e)
|
|
1963
1963
|
});
|
|
1964
|
-
class
|
|
1964
|
+
class he extends v {
|
|
1965
1965
|
_parse(e) {
|
|
1966
|
-
const { ctx:
|
|
1966
|
+
const { ctx: n } = this._processInputParams(e), s = this._def.options;
|
|
1967
1967
|
function r(a) {
|
|
1968
1968
|
for (const o of a)
|
|
1969
1969
|
if (o.result.status === "valid")
|
|
1970
1970
|
return o.result;
|
|
1971
1971
|
for (const o of a)
|
|
1972
1972
|
if (o.result.status === "dirty")
|
|
1973
|
-
return
|
|
1974
|
-
const i = a.map((o) => new
|
|
1975
|
-
return l(
|
|
1973
|
+
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1974
|
+
const i = a.map((o) => new U(o.ctx.common.issues));
|
|
1975
|
+
return l(n, {
|
|
1976
1976
|
code: u.invalid_union,
|
|
1977
1977
|
unionErrors: i
|
|
1978
1978
|
}), y;
|
|
1979
1979
|
}
|
|
1980
|
-
if (
|
|
1981
|
-
return Promise.all(
|
|
1980
|
+
if (n.common.async)
|
|
1981
|
+
return Promise.all(s.map(async (a) => {
|
|
1982
1982
|
const i = {
|
|
1983
|
-
...
|
|
1983
|
+
...n,
|
|
1984
1984
|
common: {
|
|
1985
|
-
...
|
|
1985
|
+
...n.common,
|
|
1986
1986
|
issues: []
|
|
1987
1987
|
},
|
|
1988
1988
|
parent: null
|
|
1989
1989
|
};
|
|
1990
1990
|
return {
|
|
1991
1991
|
result: await a._parseAsync({
|
|
1992
|
-
data:
|
|
1993
|
-
path:
|
|
1992
|
+
data: n.data,
|
|
1993
|
+
path: n.path,
|
|
1994
1994
|
parent: i
|
|
1995
1995
|
}),
|
|
1996
1996
|
ctx: i
|
|
@@ -1999,17 +1999,17 @@ class ue extends v {
|
|
|
1999
1999
|
{
|
|
2000
2000
|
let a;
|
|
2001
2001
|
const i = [];
|
|
2002
|
-
for (const c of
|
|
2002
|
+
for (const c of s) {
|
|
2003
2003
|
const d = {
|
|
2004
|
-
...
|
|
2004
|
+
...n,
|
|
2005
2005
|
common: {
|
|
2006
|
-
...
|
|
2006
|
+
...n.common,
|
|
2007
2007
|
issues: []
|
|
2008
2008
|
},
|
|
2009
2009
|
parent: null
|
|
2010
2010
|
}, f = c._parseSync({
|
|
2011
|
-
data:
|
|
2012
|
-
path:
|
|
2011
|
+
data: n.data,
|
|
2012
|
+
path: n.path,
|
|
2013
2013
|
parent: d
|
|
2014
2014
|
});
|
|
2015
2015
|
if (f.status === "valid")
|
|
@@ -2017,9 +2017,9 @@ class ue extends v {
|
|
|
2017
2017
|
f.status === "dirty" && !a && (a = { result: f, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
2018
2018
|
}
|
|
2019
2019
|
if (a)
|
|
2020
|
-
return
|
|
2021
|
-
const o = i.map((c) => new
|
|
2022
|
-
return l(
|
|
2020
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2021
|
+
const o = i.map((c) => new U(c));
|
|
2022
|
+
return l(n, {
|
|
2023
2023
|
code: u.invalid_union,
|
|
2024
2024
|
unionErrors: o
|
|
2025
2025
|
}), y;
|
|
@@ -2029,126 +2029,126 @@ class ue extends v {
|
|
|
2029
2029
|
return this._def.options;
|
|
2030
2030
|
}
|
|
2031
2031
|
}
|
|
2032
|
-
|
|
2032
|
+
he.create = (t, e) => new he({
|
|
2033
2033
|
options: t,
|
|
2034
2034
|
typeName: m.ZodUnion,
|
|
2035
2035
|
..._(e)
|
|
2036
2036
|
});
|
|
2037
|
-
function
|
|
2038
|
-
const
|
|
2037
|
+
function Fe(t, e) {
|
|
2038
|
+
const n = q(t), s = q(e);
|
|
2039
2039
|
if (t === e)
|
|
2040
2040
|
return { valid: !0, data: t };
|
|
2041
|
-
if (
|
|
2041
|
+
if (n === h.object && s === h.object) {
|
|
2042
2042
|
const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2043
2043
|
for (const o of a) {
|
|
2044
|
-
const c =
|
|
2044
|
+
const c = Fe(t[o], e[o]);
|
|
2045
2045
|
if (!c.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
2047
|
i[o] = c.data;
|
|
2048
2048
|
}
|
|
2049
2049
|
return { valid: !0, data: i };
|
|
2050
|
-
} else if (
|
|
2050
|
+
} else if (n === h.array && s === h.array) {
|
|
2051
2051
|
if (t.length !== e.length)
|
|
2052
2052
|
return { valid: !1 };
|
|
2053
2053
|
const r = [];
|
|
2054
2054
|
for (let a = 0; a < t.length; a++) {
|
|
2055
|
-
const i = t[a], o = e[a], c =
|
|
2055
|
+
const i = t[a], o = e[a], c = Fe(i, o);
|
|
2056
2056
|
if (!c.valid)
|
|
2057
2057
|
return { valid: !1 };
|
|
2058
2058
|
r.push(c.data);
|
|
2059
2059
|
}
|
|
2060
2060
|
return { valid: !0, data: r };
|
|
2061
|
-
} else return
|
|
2061
|
+
} else return n === h.date && s === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2062
2062
|
}
|
|
2063
|
-
class
|
|
2063
|
+
class fe extends v {
|
|
2064
2064
|
_parse(e) {
|
|
2065
|
-
const { status:
|
|
2066
|
-
if (
|
|
2065
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2066
|
+
if (je(a) || je(i))
|
|
2067
2067
|
return y;
|
|
2068
|
-
const o =
|
|
2069
|
-
return o.valid ? ((
|
|
2068
|
+
const o = Fe(a.value, i.value);
|
|
2069
|
+
return o.valid ? ((De(a) || De(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
2070
|
code: u.invalid_intersection_types
|
|
2071
2071
|
}), y);
|
|
2072
2072
|
};
|
|
2073
|
-
return
|
|
2073
|
+
return s.common.async ? Promise.all([
|
|
2074
2074
|
this._def.left._parseAsync({
|
|
2075
|
-
data:
|
|
2076
|
-
path:
|
|
2077
|
-
parent:
|
|
2075
|
+
data: s.data,
|
|
2076
|
+
path: s.path,
|
|
2077
|
+
parent: s
|
|
2078
2078
|
}),
|
|
2079
2079
|
this._def.right._parseAsync({
|
|
2080
|
-
data:
|
|
2081
|
-
path:
|
|
2082
|
-
parent:
|
|
2080
|
+
data: s.data,
|
|
2081
|
+
path: s.path,
|
|
2082
|
+
parent: s
|
|
2083
2083
|
})
|
|
2084
2084
|
]).then(([a, i]) => r(a, i)) : r(this._def.left._parseSync({
|
|
2085
|
-
data:
|
|
2086
|
-
path:
|
|
2087
|
-
parent:
|
|
2085
|
+
data: s.data,
|
|
2086
|
+
path: s.path,
|
|
2087
|
+
parent: s
|
|
2088
2088
|
}), this._def.right._parseSync({
|
|
2089
|
-
data:
|
|
2090
|
-
path:
|
|
2091
|
-
parent:
|
|
2089
|
+
data: s.data,
|
|
2090
|
+
path: s.path,
|
|
2091
|
+
parent: s
|
|
2092
2092
|
}));
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
|
|
2095
|
+
fe.create = (t, e, n) => new fe({
|
|
2096
2096
|
left: t,
|
|
2097
2097
|
right: e,
|
|
2098
2098
|
typeName: m.ZodIntersection,
|
|
2099
|
-
..._(
|
|
2099
|
+
..._(n)
|
|
2100
2100
|
});
|
|
2101
|
-
class
|
|
2101
|
+
class H extends v {
|
|
2102
2102
|
_parse(e) {
|
|
2103
|
-
const { status:
|
|
2104
|
-
if (
|
|
2105
|
-
return l(
|
|
2103
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2104
|
+
if (s.parsedType !== h.array)
|
|
2105
|
+
return l(s, {
|
|
2106
2106
|
code: u.invalid_type,
|
|
2107
2107
|
expected: h.array,
|
|
2108
|
-
received:
|
|
2108
|
+
received: s.parsedType
|
|
2109
2109
|
}), y;
|
|
2110
|
-
if (
|
|
2111
|
-
return l(
|
|
2110
|
+
if (s.data.length < this._def.items.length)
|
|
2111
|
+
return l(s, {
|
|
2112
2112
|
code: u.too_small,
|
|
2113
2113
|
minimum: this._def.items.length,
|
|
2114
2114
|
inclusive: !0,
|
|
2115
2115
|
exact: !1,
|
|
2116
2116
|
type: "array"
|
|
2117
2117
|
}), y;
|
|
2118
|
-
!this._def.rest &&
|
|
2118
|
+
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2119
2119
|
code: u.too_big,
|
|
2120
2120
|
maximum: this._def.items.length,
|
|
2121
2121
|
inclusive: !0,
|
|
2122
2122
|
exact: !1,
|
|
2123
2123
|
type: "array"
|
|
2124
|
-
}),
|
|
2125
|
-
const a = [...
|
|
2124
|
+
}), n.dirty());
|
|
2125
|
+
const a = [...s.data].map((i, o) => {
|
|
2126
2126
|
const c = this._def.items[o] || this._def.rest;
|
|
2127
|
-
return c ? c._parse(new F(
|
|
2127
|
+
return c ? c._parse(new F(s, i, s.path, o)) : null;
|
|
2128
2128
|
}).filter((i) => !!i);
|
|
2129
|
-
return
|
|
2129
|
+
return s.common.async ? Promise.all(a).then((i) => $.mergeArray(n, i)) : $.mergeArray(n, a);
|
|
2130
2130
|
}
|
|
2131
2131
|
get items() {
|
|
2132
2132
|
return this._def.items;
|
|
2133
2133
|
}
|
|
2134
2134
|
rest(e) {
|
|
2135
|
-
return new
|
|
2135
|
+
return new H({
|
|
2136
2136
|
...this._def,
|
|
2137
2137
|
rest: e
|
|
2138
2138
|
});
|
|
2139
2139
|
}
|
|
2140
2140
|
}
|
|
2141
|
-
|
|
2141
|
+
H.create = (t, e) => {
|
|
2142
2142
|
if (!Array.isArray(t))
|
|
2143
2143
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2144
|
-
return new
|
|
2144
|
+
return new H({
|
|
2145
2145
|
items: t,
|
|
2146
2146
|
typeName: m.ZodTuple,
|
|
2147
2147
|
rest: null,
|
|
2148
2148
|
..._(e)
|
|
2149
2149
|
});
|
|
2150
2150
|
};
|
|
2151
|
-
class
|
|
2151
|
+
class pe extends v {
|
|
2152
2152
|
get keySchema() {
|
|
2153
2153
|
return this._def.keyType;
|
|
2154
2154
|
}
|
|
@@ -2156,40 +2156,40 @@ class he extends v {
|
|
|
2156
2156
|
return this._def.valueType;
|
|
2157
2157
|
}
|
|
2158
2158
|
_parse(e) {
|
|
2159
|
-
const { status:
|
|
2160
|
-
if (
|
|
2161
|
-
return l(
|
|
2159
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2160
|
+
if (s.parsedType !== h.object)
|
|
2161
|
+
return l(s, {
|
|
2162
2162
|
code: u.invalid_type,
|
|
2163
2163
|
expected: h.object,
|
|
2164
|
-
received:
|
|
2164
|
+
received: s.parsedType
|
|
2165
2165
|
}), y;
|
|
2166
2166
|
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2167
|
-
for (const o in
|
|
2167
|
+
for (const o in s.data)
|
|
2168
2168
|
r.push({
|
|
2169
|
-
key: a._parse(new F(
|
|
2170
|
-
value: i._parse(new F(
|
|
2171
|
-
alwaysSet: o in
|
|
2169
|
+
key: a._parse(new F(s, o, s.path, o)),
|
|
2170
|
+
value: i._parse(new F(s, s.data[o], s.path, o)),
|
|
2171
|
+
alwaysSet: o in s.data
|
|
2172
2172
|
});
|
|
2173
|
-
return
|
|
2173
|
+
return s.common.async ? $.mergeObjectAsync(n, r) : $.mergeObjectSync(n, r);
|
|
2174
2174
|
}
|
|
2175
2175
|
get element() {
|
|
2176
2176
|
return this._def.valueType;
|
|
2177
2177
|
}
|
|
2178
|
-
static create(e,
|
|
2179
|
-
return
|
|
2178
|
+
static create(e, n, s) {
|
|
2179
|
+
return n instanceof v ? new pe({
|
|
2180
2180
|
keyType: e,
|
|
2181
|
-
valueType:
|
|
2181
|
+
valueType: n,
|
|
2182
2182
|
typeName: m.ZodRecord,
|
|
2183
|
-
..._(
|
|
2184
|
-
}) : new
|
|
2185
|
-
keyType:
|
|
2183
|
+
..._(s)
|
|
2184
|
+
}) : new pe({
|
|
2185
|
+
keyType: B.create(),
|
|
2186
2186
|
valueType: e,
|
|
2187
2187
|
typeName: m.ZodRecord,
|
|
2188
|
-
..._(
|
|
2188
|
+
..._(n)
|
|
2189
2189
|
});
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
-
class
|
|
2192
|
+
class Ve extends v {
|
|
2193
2193
|
get keySchema() {
|
|
2194
2194
|
return this._def.keyType;
|
|
2195
2195
|
}
|
|
@@ -2197,27 +2197,27 @@ class Fe extends v {
|
|
|
2197
2197
|
return this._def.valueType;
|
|
2198
2198
|
}
|
|
2199
2199
|
_parse(e) {
|
|
2200
|
-
const { status:
|
|
2201
|
-
if (
|
|
2202
|
-
return l(
|
|
2200
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2201
|
+
if (s.parsedType !== h.map)
|
|
2202
|
+
return l(s, {
|
|
2203
2203
|
code: u.invalid_type,
|
|
2204
2204
|
expected: h.map,
|
|
2205
|
-
received:
|
|
2205
|
+
received: s.parsedType
|
|
2206
2206
|
}), y;
|
|
2207
|
-
const r = this._def.keyType, a = this._def.valueType, i = [...
|
|
2208
|
-
key: r._parse(new F(
|
|
2209
|
-
value: a._parse(new F(
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], d) => ({
|
|
2208
|
+
key: r._parse(new F(s, o, s.path, [d, "key"])),
|
|
2209
|
+
value: a._parse(new F(s, c, s.path, [d, "value"]))
|
|
2210
2210
|
}));
|
|
2211
|
-
if (
|
|
2211
|
+
if (s.common.async) {
|
|
2212
2212
|
const o = /* @__PURE__ */ new Map();
|
|
2213
2213
|
return Promise.resolve().then(async () => {
|
|
2214
2214
|
for (const c of i) {
|
|
2215
2215
|
const d = await c.key, f = await c.value;
|
|
2216
2216
|
if (d.status === "aborted" || f.status === "aborted")
|
|
2217
2217
|
return y;
|
|
2218
|
-
(d.status === "dirty" || f.status === "dirty") &&
|
|
2218
|
+
(d.status === "dirty" || f.status === "dirty") && n.dirty(), o.set(d.value, f.value);
|
|
2219
2219
|
}
|
|
2220
|
-
return { status:
|
|
2220
|
+
return { status: n.value, value: o };
|
|
2221
2221
|
});
|
|
2222
2222
|
} else {
|
|
2223
2223
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2225,102 +2225,102 @@ class Fe extends v {
|
|
|
2225
2225
|
const d = c.key, f = c.value;
|
|
2226
2226
|
if (d.status === "aborted" || f.status === "aborted")
|
|
2227
2227
|
return y;
|
|
2228
|
-
(d.status === "dirty" || f.status === "dirty") &&
|
|
2228
|
+
(d.status === "dirty" || f.status === "dirty") && n.dirty(), o.set(d.value, f.value);
|
|
2229
2229
|
}
|
|
2230
|
-
return { status:
|
|
2230
|
+
return { status: n.value, value: o };
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
|
-
|
|
2234
|
+
Ve.create = (t, e, n) => new Ve({
|
|
2235
2235
|
valueType: e,
|
|
2236
2236
|
keyType: t,
|
|
2237
2237
|
typeName: m.ZodMap,
|
|
2238
|
-
..._(
|
|
2238
|
+
..._(n)
|
|
2239
2239
|
});
|
|
2240
|
-
class
|
|
2240
|
+
class ie extends v {
|
|
2241
2241
|
_parse(e) {
|
|
2242
|
-
const { status:
|
|
2243
|
-
if (
|
|
2244
|
-
return l(
|
|
2242
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2243
|
+
if (s.parsedType !== h.set)
|
|
2244
|
+
return l(s, {
|
|
2245
2245
|
code: u.invalid_type,
|
|
2246
2246
|
expected: h.set,
|
|
2247
|
-
received:
|
|
2247
|
+
received: s.parsedType
|
|
2248
2248
|
}), y;
|
|
2249
2249
|
const r = this._def;
|
|
2250
|
-
r.minSize !== null &&
|
|
2250
|
+
r.minSize !== null && s.data.size < r.minSize.value && (l(s, {
|
|
2251
2251
|
code: u.too_small,
|
|
2252
2252
|
minimum: r.minSize.value,
|
|
2253
2253
|
type: "set",
|
|
2254
2254
|
inclusive: !0,
|
|
2255
2255
|
exact: !1,
|
|
2256
2256
|
message: r.minSize.message
|
|
2257
|
-
}),
|
|
2257
|
+
}), n.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (l(s, {
|
|
2258
2258
|
code: u.too_big,
|
|
2259
2259
|
maximum: r.maxSize.value,
|
|
2260
2260
|
type: "set",
|
|
2261
2261
|
inclusive: !0,
|
|
2262
2262
|
exact: !1,
|
|
2263
2263
|
message: r.maxSize.message
|
|
2264
|
-
}),
|
|
2264
|
+
}), n.dirty());
|
|
2265
2265
|
const a = this._def.valueType;
|
|
2266
2266
|
function i(c) {
|
|
2267
2267
|
const d = /* @__PURE__ */ new Set();
|
|
2268
2268
|
for (const f of c) {
|
|
2269
2269
|
if (f.status === "aborted")
|
|
2270
2270
|
return y;
|
|
2271
|
-
f.status === "dirty" &&
|
|
2271
|
+
f.status === "dirty" && n.dirty(), d.add(f.value);
|
|
2272
2272
|
}
|
|
2273
|
-
return { status:
|
|
2273
|
+
return { status: n.value, value: d };
|
|
2274
2274
|
}
|
|
2275
|
-
const o = [...
|
|
2276
|
-
return
|
|
2275
|
+
const o = [...s.data.values()].map((c, d) => a._parse(new F(s, c, s.path, d)));
|
|
2276
|
+
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2277
2277
|
}
|
|
2278
|
-
min(e,
|
|
2279
|
-
return new
|
|
2278
|
+
min(e, n) {
|
|
2279
|
+
return new ie({
|
|
2280
2280
|
...this._def,
|
|
2281
|
-
minSize: { value: e, message: p.toString(
|
|
2281
|
+
minSize: { value: e, message: p.toString(n) }
|
|
2282
2282
|
});
|
|
2283
2283
|
}
|
|
2284
|
-
max(e,
|
|
2285
|
-
return new
|
|
2284
|
+
max(e, n) {
|
|
2285
|
+
return new ie({
|
|
2286
2286
|
...this._def,
|
|
2287
|
-
maxSize: { value: e, message: p.toString(
|
|
2287
|
+
maxSize: { value: e, message: p.toString(n) }
|
|
2288
2288
|
});
|
|
2289
2289
|
}
|
|
2290
|
-
size(e,
|
|
2291
|
-
return this.min(e,
|
|
2290
|
+
size(e, n) {
|
|
2291
|
+
return this.min(e, n).max(e, n);
|
|
2292
2292
|
}
|
|
2293
2293
|
nonempty(e) {
|
|
2294
2294
|
return this.min(1, e);
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
2297
|
-
|
|
2297
|
+
ie.create = (t, e) => new ie({
|
|
2298
2298
|
valueType: t,
|
|
2299
2299
|
minSize: null,
|
|
2300
2300
|
maxSize: null,
|
|
2301
2301
|
typeName: m.ZodSet,
|
|
2302
2302
|
..._(e)
|
|
2303
2303
|
});
|
|
2304
|
-
class
|
|
2304
|
+
class qe extends v {
|
|
2305
2305
|
get schema() {
|
|
2306
2306
|
return this._def.getter();
|
|
2307
2307
|
}
|
|
2308
2308
|
_parse(e) {
|
|
2309
|
-
const { ctx:
|
|
2310
|
-
return this._def.getter()._parse({ data:
|
|
2309
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2310
|
+
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2311
2311
|
}
|
|
2312
2312
|
}
|
|
2313
|
-
|
|
2313
|
+
qe.create = (t, e) => new qe({
|
|
2314
2314
|
getter: t,
|
|
2315
2315
|
typeName: m.ZodLazy,
|
|
2316
2316
|
..._(e)
|
|
2317
2317
|
});
|
|
2318
|
-
class
|
|
2318
|
+
class ze extends v {
|
|
2319
2319
|
_parse(e) {
|
|
2320
2320
|
if (e.data !== this._def.value) {
|
|
2321
|
-
const
|
|
2322
|
-
return l(
|
|
2323
|
-
received:
|
|
2321
|
+
const n = this._getOrReturnCtx(e);
|
|
2322
|
+
return l(n, {
|
|
2323
|
+
received: n.data,
|
|
2324
2324
|
code: u.invalid_literal,
|
|
2325
2325
|
expected: this._def.value
|
|
2326
2326
|
}), y;
|
|
@@ -2331,128 +2331,128 @@ class qe extends v {
|
|
|
2331
2331
|
return this._def.value;
|
|
2332
2332
|
}
|
|
2333
2333
|
}
|
|
2334
|
-
|
|
2334
|
+
ze.create = (t, e) => new ze({
|
|
2335
2335
|
value: t,
|
|
2336
2336
|
typeName: m.ZodLiteral,
|
|
2337
2337
|
..._(e)
|
|
2338
2338
|
});
|
|
2339
|
-
function
|
|
2340
|
-
return new
|
|
2339
|
+
function ct(t, e) {
|
|
2340
|
+
return new ee({
|
|
2341
2341
|
values: t,
|
|
2342
2342
|
typeName: m.ZodEnum,
|
|
2343
2343
|
..._(e)
|
|
2344
2344
|
});
|
|
2345
2345
|
}
|
|
2346
|
-
class
|
|
2346
|
+
class ee extends v {
|
|
2347
2347
|
_parse(e) {
|
|
2348
2348
|
if (typeof e.data != "string") {
|
|
2349
|
-
const
|
|
2350
|
-
return l(
|
|
2351
|
-
expected: b.joinValues(
|
|
2352
|
-
received:
|
|
2349
|
+
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2350
|
+
return l(n, {
|
|
2351
|
+
expected: b.joinValues(s),
|
|
2352
|
+
received: n.parsedType,
|
|
2353
2353
|
code: u.invalid_type
|
|
2354
2354
|
}), y;
|
|
2355
2355
|
}
|
|
2356
2356
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2357
|
-
const
|
|
2358
|
-
return l(
|
|
2359
|
-
received:
|
|
2357
|
+
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2358
|
+
return l(n, {
|
|
2359
|
+
received: n.data,
|
|
2360
2360
|
code: u.invalid_enum_value,
|
|
2361
|
-
options:
|
|
2361
|
+
options: s
|
|
2362
2362
|
}), y;
|
|
2363
2363
|
}
|
|
2364
|
-
return
|
|
2364
|
+
return D(e.data);
|
|
2365
2365
|
}
|
|
2366
2366
|
get options() {
|
|
2367
2367
|
return this._def.values;
|
|
2368
2368
|
}
|
|
2369
2369
|
get enum() {
|
|
2370
2370
|
const e = {};
|
|
2371
|
-
for (const
|
|
2372
|
-
e[
|
|
2371
|
+
for (const n of this._def.values)
|
|
2372
|
+
e[n] = n;
|
|
2373
2373
|
return e;
|
|
2374
2374
|
}
|
|
2375
2375
|
get Values() {
|
|
2376
2376
|
const e = {};
|
|
2377
|
-
for (const
|
|
2378
|
-
e[
|
|
2377
|
+
for (const n of this._def.values)
|
|
2378
|
+
e[n] = n;
|
|
2379
2379
|
return e;
|
|
2380
2380
|
}
|
|
2381
2381
|
get Enum() {
|
|
2382
2382
|
const e = {};
|
|
2383
|
-
for (const
|
|
2384
|
-
e[
|
|
2383
|
+
for (const n of this._def.values)
|
|
2384
|
+
e[n] = n;
|
|
2385
2385
|
return e;
|
|
2386
2386
|
}
|
|
2387
|
-
extract(e,
|
|
2388
|
-
return
|
|
2387
|
+
extract(e, n = this._def) {
|
|
2388
|
+
return ee.create(e, {
|
|
2389
2389
|
...this._def,
|
|
2390
|
-
...
|
|
2390
|
+
...n
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
|
-
exclude(e,
|
|
2394
|
-
return
|
|
2393
|
+
exclude(e, n = this._def) {
|
|
2394
|
+
return ee.create(this.options.filter((s) => !e.includes(s)), {
|
|
2395
2395
|
...this._def,
|
|
2396
|
-
...
|
|
2396
|
+
...n
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
|
|
2401
|
-
class
|
|
2400
|
+
ee.create = ct;
|
|
2401
|
+
class We extends v {
|
|
2402
2402
|
_parse(e) {
|
|
2403
|
-
const
|
|
2404
|
-
if (
|
|
2405
|
-
const r = b.objectValues(
|
|
2406
|
-
return l(
|
|
2403
|
+
const n = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2404
|
+
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
2405
|
+
const r = b.objectValues(n);
|
|
2406
|
+
return l(s, {
|
|
2407
2407
|
expected: b.joinValues(r),
|
|
2408
|
-
received:
|
|
2408
|
+
received: s.parsedType,
|
|
2409
2409
|
code: u.invalid_type
|
|
2410
2410
|
}), y;
|
|
2411
2411
|
}
|
|
2412
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2413
|
-
const r = b.objectValues(
|
|
2414
|
-
return l(
|
|
2415
|
-
received:
|
|
2413
|
+
const r = b.objectValues(n);
|
|
2414
|
+
return l(s, {
|
|
2415
|
+
received: s.data,
|
|
2416
2416
|
code: u.invalid_enum_value,
|
|
2417
2417
|
options: r
|
|
2418
2418
|
}), y;
|
|
2419
2419
|
}
|
|
2420
|
-
return
|
|
2420
|
+
return D(e.data);
|
|
2421
2421
|
}
|
|
2422
2422
|
get enum() {
|
|
2423
2423
|
return this._def.values;
|
|
2424
2424
|
}
|
|
2425
2425
|
}
|
|
2426
|
-
|
|
2426
|
+
We.create = (t, e) => new We({
|
|
2427
2427
|
values: t,
|
|
2428
2428
|
typeName: m.ZodNativeEnum,
|
|
2429
2429
|
..._(e)
|
|
2430
2430
|
});
|
|
2431
|
-
class
|
|
2431
|
+
class me extends v {
|
|
2432
2432
|
unwrap() {
|
|
2433
2433
|
return this._def.type;
|
|
2434
2434
|
}
|
|
2435
2435
|
_parse(e) {
|
|
2436
|
-
const { ctx:
|
|
2437
|
-
if (
|
|
2438
|
-
return l(
|
|
2436
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2437
|
+
if (n.parsedType !== h.promise && n.common.async === !1)
|
|
2438
|
+
return l(n, {
|
|
2439
2439
|
code: u.invalid_type,
|
|
2440
2440
|
expected: h.promise,
|
|
2441
|
-
received:
|
|
2441
|
+
received: n.parsedType
|
|
2442
2442
|
}), y;
|
|
2443
|
-
const
|
|
2444
|
-
return
|
|
2445
|
-
path:
|
|
2446
|
-
errorMap:
|
|
2443
|
+
const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2444
|
+
return D(s.then((r) => this._def.type.parseAsync(r, {
|
|
2445
|
+
path: n.path,
|
|
2446
|
+
errorMap: n.common.contextualErrorMap
|
|
2447
2447
|
})));
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
|
|
2450
|
+
me.create = (t, e) => new me({
|
|
2451
2451
|
type: t,
|
|
2452
2452
|
typeName: m.ZodPromise,
|
|
2453
2453
|
..._(e)
|
|
2454
2454
|
});
|
|
2455
|
-
class
|
|
2455
|
+
class Q extends v {
|
|
2456
2456
|
innerType() {
|
|
2457
2457
|
return this._def.schema;
|
|
2458
2458
|
}
|
|
@@ -2460,93 +2460,93 @@ class G 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:
|
|
2463
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2464
2464
|
addIssue: (i) => {
|
|
2465
|
-
l(
|
|
2465
|
+
l(s, i), i.fatal ? n.abort() : n.dirty();
|
|
2466
2466
|
},
|
|
2467
2467
|
get path() {
|
|
2468
|
-
return
|
|
2468
|
+
return s.path;
|
|
2469
2469
|
}
|
|
2470
2470
|
};
|
|
2471
2471
|
if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
|
|
2472
|
-
const i = r.transform(
|
|
2473
|
-
if (
|
|
2472
|
+
const i = r.transform(s.data, a);
|
|
2473
|
+
if (s.common.async)
|
|
2474
2474
|
return Promise.resolve(i).then(async (o) => {
|
|
2475
|
-
if (
|
|
2475
|
+
if (n.value === "aborted")
|
|
2476
2476
|
return y;
|
|
2477
2477
|
const c = await this._def.schema._parseAsync({
|
|
2478
2478
|
data: o,
|
|
2479
|
-
path:
|
|
2480
|
-
parent:
|
|
2479
|
+
path: s.path,
|
|
2480
|
+
parent: s
|
|
2481
2481
|
});
|
|
2482
|
-
return c.status === "aborted" ? y : c.status === "dirty" ||
|
|
2482
|
+
return c.status === "aborted" ? y : c.status === "dirty" || n.value === "dirty" ? re(c.value) : c;
|
|
2483
2483
|
});
|
|
2484
2484
|
{
|
|
2485
|
-
if (
|
|
2485
|
+
if (n.value === "aborted")
|
|
2486
2486
|
return y;
|
|
2487
2487
|
const o = this._def.schema._parseSync({
|
|
2488
2488
|
data: i,
|
|
2489
|
-
path:
|
|
2490
|
-
parent:
|
|
2489
|
+
path: s.path,
|
|
2490
|
+
parent: s
|
|
2491
2491
|
});
|
|
2492
|
-
return o.status === "aborted" ? y : o.status === "dirty" ||
|
|
2492
|
+
return o.status === "aborted" ? y : o.status === "dirty" || n.value === "dirty" ? re(o.value) : o;
|
|
2493
2493
|
}
|
|
2494
2494
|
}
|
|
2495
2495
|
if (r.type === "refinement") {
|
|
2496
2496
|
const i = (o) => {
|
|
2497
2497
|
const c = r.refinement(o, a);
|
|
2498
|
-
if (
|
|
2498
|
+
if (s.common.async)
|
|
2499
2499
|
return Promise.resolve(c);
|
|
2500
2500
|
if (c instanceof Promise)
|
|
2501
2501
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2502
2502
|
return o;
|
|
2503
2503
|
};
|
|
2504
|
-
if (
|
|
2504
|
+
if (s.common.async === !1) {
|
|
2505
2505
|
const o = this._def.schema._parseSync({
|
|
2506
|
-
data:
|
|
2507
|
-
path:
|
|
2508
|
-
parent:
|
|
2506
|
+
data: s.data,
|
|
2507
|
+
path: s.path,
|
|
2508
|
+
parent: s
|
|
2509
2509
|
});
|
|
2510
|
-
return o.status === "aborted" ? y : (o.status === "dirty" &&
|
|
2510
|
+
return o.status === "aborted" ? y : (o.status === "dirty" && n.dirty(), i(o.value), { status: n.value, value: o.value });
|
|
2511
2511
|
} else
|
|
2512
|
-
return this._def.schema._parseAsync({ data:
|
|
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
2514
|
if (r.type === "transform")
|
|
2515
|
-
if (
|
|
2515
|
+
if (s.common.async === !1) {
|
|
2516
2516
|
const i = this._def.schema._parseSync({
|
|
2517
|
-
data:
|
|
2518
|
-
path:
|
|
2519
|
-
parent:
|
|
2517
|
+
data: s.data,
|
|
2518
|
+
path: s.path,
|
|
2519
|
+
parent: s
|
|
2520
2520
|
});
|
|
2521
|
-
if (!
|
|
2521
|
+
if (!K(i))
|
|
2522
2522
|
return y;
|
|
2523
2523
|
const o = r.transform(i.value, a);
|
|
2524
2524
|
if (o instanceof Promise)
|
|
2525
2525
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2526
|
-
return { status:
|
|
2526
|
+
return { status: n.value, value: o };
|
|
2527
2527
|
} else
|
|
2528
|
-
return this._def.schema._parseAsync({ data:
|
|
2529
|
-
status:
|
|
2528
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => K(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2529
|
+
status: n.value,
|
|
2530
2530
|
value: o
|
|
2531
2531
|
})) : y);
|
|
2532
2532
|
b.assertNever(r);
|
|
2533
2533
|
}
|
|
2534
2534
|
}
|
|
2535
|
-
|
|
2535
|
+
Q.create = (t, e, n) => new Q({
|
|
2536
2536
|
schema: t,
|
|
2537
2537
|
typeName: m.ZodEffects,
|
|
2538
2538
|
effect: e,
|
|
2539
|
-
..._(
|
|
2539
|
+
..._(n)
|
|
2540
2540
|
});
|
|
2541
|
-
|
|
2541
|
+
Q.createWithPreprocess = (t, e, n) => new Q({
|
|
2542
2542
|
schema: e,
|
|
2543
2543
|
effect: { type: "preprocess", transform: t },
|
|
2544
2544
|
typeName: m.ZodEffects,
|
|
2545
|
-
..._(
|
|
2545
|
+
..._(n)
|
|
2546
2546
|
});
|
|
2547
2547
|
class z extends v {
|
|
2548
2548
|
_parse(e) {
|
|
2549
|
-
return this._getType(e) === h.undefined ?
|
|
2549
|
+
return this._getType(e) === h.undefined ? D(void 0) : this._def.innerType._parse(e);
|
|
2550
2550
|
}
|
|
2551
2551
|
unwrap() {
|
|
2552
2552
|
return this._def.innerType;
|
|
@@ -2557,69 +2557,69 @@ z.create = (t, e) => new z({
|
|
|
2557
2557
|
typeName: m.ZodOptional,
|
|
2558
2558
|
..._(e)
|
|
2559
2559
|
});
|
|
2560
|
-
class
|
|
2560
|
+
class te extends v {
|
|
2561
2561
|
_parse(e) {
|
|
2562
|
-
return this._getType(e) === h.null ?
|
|
2562
|
+
return this._getType(e) === h.null ? D(null) : this._def.innerType._parse(e);
|
|
2563
2563
|
}
|
|
2564
2564
|
unwrap() {
|
|
2565
2565
|
return this._def.innerType;
|
|
2566
2566
|
}
|
|
2567
2567
|
}
|
|
2568
|
-
|
|
2568
|
+
te.create = (t, e) => new te({
|
|
2569
2569
|
innerType: t,
|
|
2570
2570
|
typeName: m.ZodNullable,
|
|
2571
2571
|
..._(e)
|
|
2572
2572
|
});
|
|
2573
|
-
class
|
|
2573
|
+
class _e extends v {
|
|
2574
2574
|
_parse(e) {
|
|
2575
|
-
const { ctx:
|
|
2576
|
-
let
|
|
2577
|
-
return
|
|
2578
|
-
data:
|
|
2579
|
-
path:
|
|
2580
|
-
parent:
|
|
2575
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2576
|
+
let s = n.data;
|
|
2577
|
+
return n.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2578
|
+
data: s,
|
|
2579
|
+
path: n.path,
|
|
2580
|
+
parent: n
|
|
2581
2581
|
});
|
|
2582
2582
|
}
|
|
2583
2583
|
removeDefault() {
|
|
2584
2584
|
return this._def.innerType;
|
|
2585
2585
|
}
|
|
2586
2586
|
}
|
|
2587
|
-
|
|
2587
|
+
_e.create = (t, e) => new _e({
|
|
2588
2588
|
innerType: t,
|
|
2589
2589
|
typeName: m.ZodDefault,
|
|
2590
2590
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2591
2591
|
..._(e)
|
|
2592
2592
|
});
|
|
2593
|
-
class
|
|
2593
|
+
class ve extends v {
|
|
2594
2594
|
_parse(e) {
|
|
2595
|
-
const { ctx:
|
|
2596
|
-
...
|
|
2595
|
+
const { ctx: n } = this._processInputParams(e), s = {
|
|
2596
|
+
...n,
|
|
2597
2597
|
common: {
|
|
2598
|
-
...
|
|
2598
|
+
...n.common,
|
|
2599
2599
|
issues: []
|
|
2600
2600
|
}
|
|
2601
2601
|
}, r = this._def.innerType._parse({
|
|
2602
|
-
data:
|
|
2603
|
-
path:
|
|
2602
|
+
data: s.data,
|
|
2603
|
+
path: s.path,
|
|
2604
2604
|
parent: {
|
|
2605
|
-
...
|
|
2605
|
+
...s
|
|
2606
2606
|
}
|
|
2607
2607
|
});
|
|
2608
|
-
return
|
|
2608
|
+
return ue(r) ? r.then((a) => ({
|
|
2609
2609
|
status: "valid",
|
|
2610
2610
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2611
2611
|
get error() {
|
|
2612
|
-
return new
|
|
2612
|
+
return new U(s.common.issues);
|
|
2613
2613
|
},
|
|
2614
|
-
input:
|
|
2614
|
+
input: s.data
|
|
2615
2615
|
})
|
|
2616
2616
|
})) : {
|
|
2617
2617
|
status: "valid",
|
|
2618
2618
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2619
2619
|
get error() {
|
|
2620
|
-
return new
|
|
2620
|
+
return new U(s.common.issues);
|
|
2621
2621
|
},
|
|
2622
|
-
input:
|
|
2622
|
+
input: s.data
|
|
2623
2623
|
})
|
|
2624
2624
|
};
|
|
2625
2625
|
}
|
|
@@ -2627,92 +2627,92 @@ class _e extends v {
|
|
|
2627
2627
|
return this._def.innerType;
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
|
|
2630
|
+
ve.create = (t, e) => new ve({
|
|
2631
2631
|
innerType: t,
|
|
2632
2632
|
typeName: m.ZodCatch,
|
|
2633
2633
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2634
2634
|
..._(e)
|
|
2635
2635
|
});
|
|
2636
|
-
class
|
|
2636
|
+
class Je extends v {
|
|
2637
2637
|
_parse(e) {
|
|
2638
2638
|
if (this._getType(e) !== h.nan) {
|
|
2639
|
-
const
|
|
2640
|
-
return l(
|
|
2639
|
+
const s = this._getOrReturnCtx(e);
|
|
2640
|
+
return l(s, {
|
|
2641
2641
|
code: u.invalid_type,
|
|
2642
2642
|
expected: h.nan,
|
|
2643
|
-
received:
|
|
2643
|
+
received: s.parsedType
|
|
2644
2644
|
}), y;
|
|
2645
2645
|
}
|
|
2646
2646
|
return { status: "valid", value: e.data };
|
|
2647
2647
|
}
|
|
2648
2648
|
}
|
|
2649
|
-
|
|
2649
|
+
Je.create = (t) => new Je({
|
|
2650
2650
|
typeName: m.ZodNaN,
|
|
2651
2651
|
..._(t)
|
|
2652
2652
|
});
|
|
2653
|
-
class
|
|
2653
|
+
class dt extends v {
|
|
2654
2654
|
_parse(e) {
|
|
2655
|
-
const { ctx:
|
|
2655
|
+
const { ctx: n } = this._processInputParams(e), s = n.data;
|
|
2656
2656
|
return this._def.type._parse({
|
|
2657
|
-
data:
|
|
2658
|
-
path:
|
|
2659
|
-
parent:
|
|
2657
|
+
data: s,
|
|
2658
|
+
path: n.path,
|
|
2659
|
+
parent: n
|
|
2660
2660
|
});
|
|
2661
2661
|
}
|
|
2662
2662
|
unwrap() {
|
|
2663
2663
|
return this._def.type;
|
|
2664
2664
|
}
|
|
2665
2665
|
}
|
|
2666
|
-
class
|
|
2666
|
+
class ke extends v {
|
|
2667
2667
|
_parse(e) {
|
|
2668
|
-
const { status:
|
|
2669
|
-
if (
|
|
2668
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2669
|
+
if (s.common.async)
|
|
2670
2670
|
return (async () => {
|
|
2671
2671
|
const a = await this._def.in._parseAsync({
|
|
2672
|
-
data:
|
|
2673
|
-
path:
|
|
2674
|
-
parent:
|
|
2672
|
+
data: s.data,
|
|
2673
|
+
path: s.path,
|
|
2674
|
+
parent: s
|
|
2675
2675
|
});
|
|
2676
|
-
return a.status === "aborted" ? y : a.status === "dirty" ? (
|
|
2676
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (n.dirty(), re(a.value)) : this._def.out._parseAsync({
|
|
2677
2677
|
data: a.value,
|
|
2678
|
-
path:
|
|
2679
|
-
parent:
|
|
2678
|
+
path: s.path,
|
|
2679
|
+
parent: s
|
|
2680
2680
|
});
|
|
2681
2681
|
})();
|
|
2682
2682
|
{
|
|
2683
2683
|
const r = this._def.in._parseSync({
|
|
2684
|
-
data:
|
|
2685
|
-
path:
|
|
2686
|
-
parent:
|
|
2684
|
+
data: s.data,
|
|
2685
|
+
path: s.path,
|
|
2686
|
+
parent: s
|
|
2687
2687
|
});
|
|
2688
|
-
return r.status === "aborted" ? y : r.status === "dirty" ? (
|
|
2688
|
+
return r.status === "aborted" ? y : r.status === "dirty" ? (n.dirty(), {
|
|
2689
2689
|
status: "dirty",
|
|
2690
2690
|
value: r.value
|
|
2691
2691
|
}) : this._def.out._parseSync({
|
|
2692
2692
|
data: r.value,
|
|
2693
|
-
path:
|
|
2694
|
-
parent:
|
|
2693
|
+
path: s.path,
|
|
2694
|
+
parent: s
|
|
2695
2695
|
});
|
|
2696
2696
|
}
|
|
2697
2697
|
}
|
|
2698
|
-
static create(e,
|
|
2699
|
-
return new
|
|
2698
|
+
static create(e, n) {
|
|
2699
|
+
return new ke({
|
|
2700
2700
|
in: e,
|
|
2701
|
-
out:
|
|
2701
|
+
out: n,
|
|
2702
2702
|
typeName: m.ZodPipeline
|
|
2703
2703
|
});
|
|
2704
2704
|
}
|
|
2705
2705
|
}
|
|
2706
|
-
class
|
|
2706
|
+
class be extends v {
|
|
2707
2707
|
_parse(e) {
|
|
2708
|
-
const
|
|
2709
|
-
return
|
|
2708
|
+
const n = this._def.innerType._parse(e), s = (r) => (K(r) && (r.value = Object.freeze(r.value)), r);
|
|
2709
|
+
return ue(n) ? n.then((r) => s(r)) : s(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
unwrap() {
|
|
2712
2712
|
return this._def.innerType;
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
|
-
|
|
2715
|
+
be.create = (t, e) => new be({
|
|
2716
2716
|
innerType: t,
|
|
2717
2717
|
typeName: m.ZodReadonly,
|
|
2718
2718
|
..._(e)
|
|
@@ -2721,120 +2721,120 @@ var m;
|
|
|
2721
2721
|
(function(t) {
|
|
2722
2722
|
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2723
2723
|
})(m || (m = {}));
|
|
2724
|
-
const g =
|
|
2724
|
+
const g = B.create, ut = X.create, Se = ge.create;
|
|
2725
2725
|
W.create;
|
|
2726
|
-
const
|
|
2727
|
-
|
|
2728
|
-
le.create;
|
|
2729
|
-
J.create;
|
|
2730
|
-
const ot = he.create;
|
|
2731
|
-
X.create;
|
|
2726
|
+
const j = L.create, Z = C.create;
|
|
2727
|
+
he.create;
|
|
2732
2728
|
fe.create;
|
|
2733
|
-
|
|
2729
|
+
H.create;
|
|
2730
|
+
const lt = pe.create;
|
|
2734
2731
|
ee.create;
|
|
2735
|
-
|
|
2732
|
+
me.create;
|
|
2733
|
+
z.create;
|
|
2734
|
+
te.create;
|
|
2735
|
+
const zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2736
2736
|
__proto__: null,
|
|
2737
|
-
DIRTY:
|
|
2737
|
+
DIRTY: re,
|
|
2738
2738
|
INVALID: y,
|
|
2739
|
-
OK:
|
|
2739
|
+
OK: D,
|
|
2740
2740
|
ParseStatus: $,
|
|
2741
2741
|
Schema: v,
|
|
2742
|
-
ZodAny:
|
|
2743
|
-
ZodArray:
|
|
2744
|
-
ZodBigInt:
|
|
2745
|
-
ZodBoolean:
|
|
2746
|
-
ZodBranded:
|
|
2747
|
-
ZodCatch:
|
|
2748
|
-
ZodDate:
|
|
2749
|
-
ZodDefault:
|
|
2750
|
-
ZodEffects:
|
|
2751
|
-
ZodEnum:
|
|
2752
|
-
ZodError:
|
|
2742
|
+
ZodAny: Pe,
|
|
2743
|
+
ZodArray: L,
|
|
2744
|
+
ZodBigInt: ae,
|
|
2745
|
+
ZodBoolean: ge,
|
|
2746
|
+
ZodBranded: dt,
|
|
2747
|
+
ZodCatch: ve,
|
|
2748
|
+
ZodDate: le,
|
|
2749
|
+
ZodDefault: _e,
|
|
2750
|
+
ZodEffects: Q,
|
|
2751
|
+
ZodEnum: ee,
|
|
2752
|
+
ZodError: U,
|
|
2753
2753
|
get ZodFirstPartyTypeKind() {
|
|
2754
2754
|
return m;
|
|
2755
2755
|
},
|
|
2756
|
-
ZodIntersection:
|
|
2756
|
+
ZodIntersection: fe,
|
|
2757
2757
|
ZodIssueCode: u,
|
|
2758
|
-
ZodLazy:
|
|
2759
|
-
ZodLiteral:
|
|
2760
|
-
ZodMap:
|
|
2761
|
-
ZodNaN:
|
|
2762
|
-
ZodNativeEnum:
|
|
2758
|
+
ZodLazy: qe,
|
|
2759
|
+
ZodLiteral: ze,
|
|
2760
|
+
ZodMap: Ve,
|
|
2761
|
+
ZodNaN: Je,
|
|
2762
|
+
ZodNativeEnum: We,
|
|
2763
2763
|
ZodNever: W,
|
|
2764
|
-
ZodNull:
|
|
2765
|
-
ZodNullable:
|
|
2766
|
-
ZodNumber:
|
|
2767
|
-
ZodObject:
|
|
2764
|
+
ZodNull: Me,
|
|
2765
|
+
ZodNullable: te,
|
|
2766
|
+
ZodNumber: X,
|
|
2767
|
+
ZodObject: C,
|
|
2768
2768
|
ZodOptional: z,
|
|
2769
2769
|
ZodParsedType: h,
|
|
2770
|
-
ZodPipeline:
|
|
2771
|
-
ZodPromise:
|
|
2772
|
-
ZodReadonly:
|
|
2773
|
-
ZodRecord:
|
|
2770
|
+
ZodPipeline: ke,
|
|
2771
|
+
ZodPromise: me,
|
|
2772
|
+
ZodReadonly: be,
|
|
2773
|
+
ZodRecord: pe,
|
|
2774
2774
|
ZodSchema: v,
|
|
2775
|
-
ZodSet:
|
|
2776
|
-
ZodString:
|
|
2777
|
-
ZodSymbol:
|
|
2778
|
-
ZodTransformer:
|
|
2779
|
-
ZodTuple:
|
|
2775
|
+
ZodSet: ie,
|
|
2776
|
+
ZodString: B,
|
|
2777
|
+
ZodSymbol: Le,
|
|
2778
|
+
ZodTransformer: Q,
|
|
2779
|
+
ZodTuple: H,
|
|
2780
2780
|
ZodType: v,
|
|
2781
2781
|
ZodUndefined: Ze,
|
|
2782
|
-
ZodUnion:
|
|
2783
|
-
ZodUnknown:
|
|
2782
|
+
ZodUnion: he,
|
|
2783
|
+
ZodUnknown: Be,
|
|
2784
2784
|
ZodVoid: Ue,
|
|
2785
2785
|
addIssueToContext: l,
|
|
2786
|
-
array:
|
|
2787
|
-
boolean:
|
|
2788
|
-
datetimeRegex:
|
|
2789
|
-
defaultErrorMap:
|
|
2790
|
-
getErrorMap:
|
|
2786
|
+
array: j,
|
|
2787
|
+
boolean: Se,
|
|
2788
|
+
datetimeRegex: ot,
|
|
2789
|
+
defaultErrorMap: ye,
|
|
2790
|
+
getErrorMap: st,
|
|
2791
2791
|
getParsedType: q,
|
|
2792
|
-
isAborted:
|
|
2793
|
-
isAsync:
|
|
2794
|
-
isDirty:
|
|
2795
|
-
isValid:
|
|
2796
|
-
makeIssue:
|
|
2797
|
-
number:
|
|
2798
|
-
object:
|
|
2792
|
+
isAborted: je,
|
|
2793
|
+
isAsync: ue,
|
|
2794
|
+
isDirty: De,
|
|
2795
|
+
isValid: K,
|
|
2796
|
+
makeIssue: rt,
|
|
2797
|
+
number: ut,
|
|
2798
|
+
object: Z,
|
|
2799
2799
|
get objectUtil() {
|
|
2800
|
-
return
|
|
2800
|
+
return Ie;
|
|
2801
2801
|
},
|
|
2802
|
-
record:
|
|
2802
|
+
record: lt,
|
|
2803
2803
|
string: g,
|
|
2804
2804
|
get util() {
|
|
2805
2805
|
return b;
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
|
-
|
|
2809
|
-
const
|
|
2810
|
-
const
|
|
2808
|
+
wt(zt);
|
|
2809
|
+
const Wt = (t, e) => e.skipDedupe || e.method !== "GET", Jt = (t, e) => e.method + "@" + t, Ht = (t) => t.clone(), Qt = ({ skip: t = Wt, key: e = Jt, resolver: n = Ht } = {}) => {
|
|
2810
|
+
const s = /* @__PURE__ */ new Map();
|
|
2811
2811
|
return (r) => (a, i) => {
|
|
2812
2812
|
if (t(a, i))
|
|
2813
2813
|
return r(a, i);
|
|
2814
2814
|
const o = e(a, i);
|
|
2815
|
-
if (!
|
|
2816
|
-
|
|
2815
|
+
if (!s.has(o))
|
|
2816
|
+
s.set(o, []);
|
|
2817
2817
|
else
|
|
2818
2818
|
return new Promise((c, d) => {
|
|
2819
|
-
|
|
2819
|
+
s.get(o).push([c, d]);
|
|
2820
2820
|
});
|
|
2821
2821
|
try {
|
|
2822
|
-
return r(a, i).then((c) => (
|
|
2823
|
-
throw
|
|
2822
|
+
return r(a, i).then((c) => (s.get(o).forEach(([d]) => d(n(c))), s.delete(o), c)).catch((c) => {
|
|
2823
|
+
throw s.get(o).forEach(([, d]) => d(c)), s.delete(o), c;
|
|
2824
2824
|
});
|
|
2825
2825
|
} catch (c) {
|
|
2826
|
-
return
|
|
2826
|
+
return s.delete(o), Promise.reject(c);
|
|
2827
2827
|
}
|
|
2828
2828
|
};
|
|
2829
|
-
},
|
|
2829
|
+
}, Yt = (t, e) => t * e, Gt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Kt = ({ delayTimer: t = 500, delayRamp: e = Yt, maxAttempts: n = 10, until: s = Gt, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (d, f) => {
|
|
2830
2830
|
let x = 0;
|
|
2831
2831
|
if (o && o(d, f))
|
|
2832
2832
|
return c(d, f);
|
|
2833
|
-
const
|
|
2833
|
+
const T = (E, O) => Promise.resolve(s(E, O)).then((M) => M ? E && i ? E : O ? Promise.reject(O) : E : (x++, !n || x <= n ? new Promise((w) => {
|
|
2834
2834
|
const P = e(t, x);
|
|
2835
2835
|
setTimeout(() => {
|
|
2836
2836
|
typeof r == "function" ? Promise.resolve(r({
|
|
2837
|
-
response:
|
|
2837
|
+
response: E,
|
|
2838
2838
|
error: O,
|
|
2839
2839
|
url: d,
|
|
2840
2840
|
attempt: x,
|
|
@@ -2844,34 +2844,34 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ft = (t, e) => e.method
|
|
|
2844
2844
|
w(c((k = A && A.url) !== null && k !== void 0 ? k : d, (S = A && A.options) !== null && S !== void 0 ? S : f));
|
|
2845
2845
|
}) : w(c(d, f));
|
|
2846
2846
|
}, P);
|
|
2847
|
-
}).then(
|
|
2847
|
+
}).then(T).catch((w) => {
|
|
2848
2848
|
if (!a)
|
|
2849
2849
|
throw w;
|
|
2850
|
-
return
|
|
2851
|
-
}) :
|
|
2852
|
-
return c(d, f).then(
|
|
2850
|
+
return T(null, w);
|
|
2851
|
+
}) : E && i ? E : Promise.reject(O || new Error("Number of attempts exceeded."))));
|
|
2852
|
+
return c(d, f).then(T).catch((E) => {
|
|
2853
2853
|
if (!a)
|
|
2854
|
-
throw
|
|
2855
|
-
return
|
|
2854
|
+
throw E;
|
|
2855
|
+
return T(null, E);
|
|
2856
2856
|
});
|
|
2857
|
-
},
|
|
2858
|
-
code:
|
|
2857
|
+
}, xe = Z({
|
|
2858
|
+
code: ut(),
|
|
2859
2859
|
message: g()
|
|
2860
|
-
}),
|
|
2860
|
+
}), Xt = Z({
|
|
2861
2861
|
message: g()
|
|
2862
|
-
}),
|
|
2863
|
-
emails:
|
|
2862
|
+
}), en = Z({
|
|
2863
|
+
emails: j(g()).optional(),
|
|
2864
2864
|
http_body: g().optional(),
|
|
2865
2865
|
http_url: g().optional(),
|
|
2866
2866
|
txt_name: g().optional(),
|
|
2867
2867
|
txt_value: g().optional()
|
|
2868
|
-
}),
|
|
2869
|
-
ciphers:
|
|
2868
|
+
}), tn = Z({
|
|
2869
|
+
ciphers: j(g()).optional(),
|
|
2870
2870
|
early_hints: g().optional(),
|
|
2871
2871
|
http2: g().optional(),
|
|
2872
2872
|
min_tls_version: g().optional(),
|
|
2873
2873
|
tls_1_3: g().optional()
|
|
2874
|
-
}),
|
|
2874
|
+
}), nn = Z({
|
|
2875
2875
|
id: g(),
|
|
2876
2876
|
bundle_method: g().optional(),
|
|
2877
2877
|
certificate_authority: g(),
|
|
@@ -2879,70 +2879,70 @@ const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ft = (t, e) => e.method
|
|
|
2879
2879
|
custom_csr_id: g().optional(),
|
|
2880
2880
|
custom_key: g().optional(),
|
|
2881
2881
|
expires_on: g().optional(),
|
|
2882
|
-
hosts:
|
|
2882
|
+
hosts: j(g()).optional(),
|
|
2883
2883
|
issuer: g().optional(),
|
|
2884
2884
|
method: g(),
|
|
2885
2885
|
serial_number: g().optional(),
|
|
2886
|
-
settings:
|
|
2886
|
+
settings: tn.optional(),
|
|
2887
2887
|
signature: g().optional(),
|
|
2888
2888
|
type: g(),
|
|
2889
2889
|
uploaded_on: g().optional(),
|
|
2890
|
-
validation_errors:
|
|
2891
|
-
validation_records:
|
|
2892
|
-
wildcard:
|
|
2893
|
-
}),
|
|
2890
|
+
validation_errors: j(Xt).optional(),
|
|
2891
|
+
validation_records: j(en).optional(),
|
|
2892
|
+
wildcard: Se()
|
|
2893
|
+
}), sn = Z({
|
|
2894
2894
|
name: g(),
|
|
2895
2895
|
type: g(),
|
|
2896
2896
|
value: g()
|
|
2897
|
-
}),
|
|
2897
|
+
}), rn = Z({
|
|
2898
2898
|
http_body: g().optional(),
|
|
2899
2899
|
http_url: g().optional()
|
|
2900
|
-
}),
|
|
2900
|
+
}), ht = Z({
|
|
2901
2901
|
id: g(),
|
|
2902
|
-
ssl:
|
|
2902
|
+
ssl: nn,
|
|
2903
2903
|
hostname: g(),
|
|
2904
|
-
custom_metadata:
|
|
2904
|
+
custom_metadata: lt(g()).optional(),
|
|
2905
2905
|
custom_origin_server: g().optional(),
|
|
2906
2906
|
custom_origin_sni: g().optional(),
|
|
2907
|
-
ownership_verification:
|
|
2908
|
-
ownership_verification_http:
|
|
2907
|
+
ownership_verification: sn.optional(),
|
|
2908
|
+
ownership_verification_http: rn.optional(),
|
|
2909
2909
|
status: g(),
|
|
2910
|
-
verification_errors:
|
|
2910
|
+
verification_errors: j(g()).optional(),
|
|
2911
2911
|
created_at: g()
|
|
2912
|
-
}),
|
|
2913
|
-
errors:
|
|
2914
|
-
messages:
|
|
2915
|
-
success:
|
|
2916
|
-
result:
|
|
2912
|
+
}), de = Z({
|
|
2913
|
+
errors: j(xe),
|
|
2914
|
+
messages: j(xe),
|
|
2915
|
+
success: Se(),
|
|
2916
|
+
result: ht
|
|
2917
2917
|
});
|
|
2918
|
-
|
|
2919
|
-
errors:
|
|
2920
|
-
messages:
|
|
2921
|
-
success:
|
|
2922
|
-
result:
|
|
2918
|
+
Z({
|
|
2919
|
+
errors: j(xe),
|
|
2920
|
+
messages: j(xe),
|
|
2921
|
+
success: Se(),
|
|
2922
|
+
result: j(ht)
|
|
2923
2923
|
});
|
|
2924
|
-
function
|
|
2925
|
-
return
|
|
2924
|
+
function Y(t) {
|
|
2925
|
+
return vt(`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([Kt(), Qt()]);
|
|
2930
2930
|
}
|
|
2931
|
-
function
|
|
2932
|
-
const e = {},
|
|
2933
|
-
if (!t) return { sslOverrides: e, rest:
|
|
2934
|
-
for (const [
|
|
2935
|
-
|
|
2936
|
-
return { sslOverrides: e, rest:
|
|
2931
|
+
function Ye(t) {
|
|
2932
|
+
const e = {}, n = {};
|
|
2933
|
+
if (!t) return { sslOverrides: e, rest: n };
|
|
2934
|
+
for (const [s, r] of Object.entries(t))
|
|
2935
|
+
s.startsWith("ssl.") ? e[s.slice(4)] = r : n[s] = r;
|
|
2936
|
+
return { sslOverrides: e, rest: n };
|
|
2937
2937
|
}
|
|
2938
|
-
function
|
|
2938
|
+
function Re(t) {
|
|
2939
2939
|
const e = [];
|
|
2940
2940
|
if (t.ssl.validation_records)
|
|
2941
|
-
for (const
|
|
2942
|
-
|
|
2941
|
+
for (const s of t.ssl.validation_records)
|
|
2942
|
+
s.txt_name && s.txt_value && e.push({
|
|
2943
2943
|
name: "txt",
|
|
2944
|
-
record:
|
|
2945
|
-
domain:
|
|
2944
|
+
record: s.txt_value,
|
|
2945
|
+
domain: s.txt_name
|
|
2946
2946
|
});
|
|
2947
2947
|
if (t.ownership_verification && e.push({
|
|
2948
2948
|
name: "txt",
|
|
@@ -2953,13 +2953,13 @@ function Ne(t) {
|
|
|
2953
2953
|
http_body: t.ownership_verification_http.http_body,
|
|
2954
2954
|
http_url: t.ownership_verification_http.http_url
|
|
2955
2955
|
}), t.ssl.validation_records)
|
|
2956
|
-
for (const
|
|
2957
|
-
|
|
2956
|
+
for (const s of t.ssl.validation_records)
|
|
2957
|
+
s.http_body && s.http_url && e.push({
|
|
2958
2958
|
name: "http",
|
|
2959
|
-
http_body:
|
|
2960
|
-
http_url:
|
|
2959
|
+
http_body: s.http_body,
|
|
2960
|
+
http_url: s.http_url
|
|
2961
2961
|
});
|
|
2962
|
-
const
|
|
2962
|
+
const n = {
|
|
2963
2963
|
...t.domain_metadata || {},
|
|
2964
2964
|
"ssl.method": t.ssl.method,
|
|
2965
2965
|
"ssl.type": t.ssl.type,
|
|
@@ -2972,24 +2972,24 @@ function Ne(t) {
|
|
|
2972
2972
|
status: t.status === "active" ? "ready" : "pending",
|
|
2973
2973
|
type: "auth0_managed_certs",
|
|
2974
2974
|
verification: {
|
|
2975
|
-
methods:
|
|
2975
|
+
methods: j(gt).parse(e)
|
|
2976
2976
|
},
|
|
2977
|
-
domain_metadata:
|
|
2977
|
+
domain_metadata: n
|
|
2978
2978
|
};
|
|
2979
2979
|
}
|
|
2980
|
-
function
|
|
2980
|
+
function an(t) {
|
|
2981
2981
|
return {
|
|
2982
|
-
create: async (e,
|
|
2983
|
-
const { sslOverrides:
|
|
2984
|
-
|
|
2985
|
-
), { result: a, errors: i, success: o } =
|
|
2986
|
-
await
|
|
2982
|
+
create: async (e, n) => {
|
|
2983
|
+
const { sslOverrides: s, rest: r } = Ye(
|
|
2984
|
+
n.domain_metadata
|
|
2985
|
+
), { result: a, errors: i, success: o } = de.parse(
|
|
2986
|
+
await Y(t).post(
|
|
2987
2987
|
{
|
|
2988
|
-
hostname:
|
|
2988
|
+
hostname: n.domain,
|
|
2989
2989
|
ssl: {
|
|
2990
2990
|
method: "txt",
|
|
2991
2991
|
type: "dv",
|
|
2992
|
-
...
|
|
2992
|
+
...s
|
|
2993
2993
|
},
|
|
2994
2994
|
custom_metadata: t.enterprise ? {
|
|
2995
2995
|
tenant_id: e
|
|
@@ -3000,7 +3000,7 @@ function es(t) {
|
|
|
3000
3000
|
);
|
|
3001
3001
|
if (!o)
|
|
3002
3002
|
throw new Error(JSON.stringify(i));
|
|
3003
|
-
const c =
|
|
3003
|
+
const c = Re({
|
|
3004
3004
|
...a,
|
|
3005
3005
|
primary: !1,
|
|
3006
3006
|
domain_metadata: r
|
|
@@ -3009,35 +3009,35 @@ function es(t) {
|
|
|
3009
3009
|
custom_domain_id: c.custom_domain_id,
|
|
3010
3010
|
domain: c.domain,
|
|
3011
3011
|
type: c.type,
|
|
3012
|
-
domain_metadata:
|
|
3012
|
+
domain_metadata: n.domain_metadata
|
|
3013
3013
|
}), c;
|
|
3014
3014
|
},
|
|
3015
|
-
get: async (e,
|
|
3016
|
-
const
|
|
3015
|
+
get: async (e, n) => {
|
|
3016
|
+
const s = await t.customDomainAdapter.get(
|
|
3017
3017
|
e,
|
|
3018
|
-
|
|
3018
|
+
n
|
|
3019
3019
|
);
|
|
3020
|
-
if (!
|
|
3021
|
-
throw new
|
|
3022
|
-
const r = await
|
|
3020
|
+
if (!s)
|
|
3021
|
+
throw new ne(404);
|
|
3022
|
+
const r = await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: a, errors: i, success: o } = de.parse(r);
|
|
3023
3023
|
if (!o)
|
|
3024
|
-
throw new
|
|
3024
|
+
throw new ne(503, {
|
|
3025
3025
|
message: JSON.stringify(i)
|
|
3026
3026
|
});
|
|
3027
3027
|
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3028
|
-
throw new
|
|
3029
|
-
return
|
|
3028
|
+
throw new ne(404);
|
|
3029
|
+
return Re({ ...s, ...a });
|
|
3030
3030
|
},
|
|
3031
3031
|
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3032
3032
|
list: async (e) => {
|
|
3033
|
-
const
|
|
3033
|
+
const n = await t.customDomainAdapter.list(e);
|
|
3034
3034
|
return (await Promise.all(
|
|
3035
|
-
|
|
3035
|
+
n.map(async (r) => {
|
|
3036
3036
|
try {
|
|
3037
|
-
const a = await
|
|
3037
|
+
const a = await Y(t).get(
|
|
3038
3038
|
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
3039
|
-
).json(), { result: i, success: o } =
|
|
3040
|
-
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null :
|
|
3039
|
+
).json(), { result: i, success: o } = de.parse(a);
|
|
3040
|
+
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Re({
|
|
3041
3041
|
...r,
|
|
3042
3042
|
...i
|
|
3043
3043
|
});
|
|
@@ -3047,25 +3047,25 @@ function es(t) {
|
|
|
3047
3047
|
})
|
|
3048
3048
|
)).filter((r) => r !== null);
|
|
3049
3049
|
},
|
|
3050
|
-
remove: async (e,
|
|
3050
|
+
remove: async (e, n) => {
|
|
3051
3051
|
if (t.enterprise) {
|
|
3052
|
-
const { result: r, success: a } =
|
|
3053
|
-
await
|
|
3052
|
+
const { result: r, success: a } = de.parse(
|
|
3053
|
+
await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3054
3054
|
);
|
|
3055
3055
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3056
|
-
throw new
|
|
3056
|
+
throw new ne(404);
|
|
3057
3057
|
}
|
|
3058
|
-
const
|
|
3059
|
-
return
|
|
3058
|
+
const s = await Y(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
|
|
3059
|
+
return s.ok && await t.customDomainAdapter.remove(e, n), s.ok;
|
|
3060
3060
|
},
|
|
3061
|
-
update: async (e,
|
|
3062
|
-
const { sslOverrides: r } =
|
|
3063
|
-
|
|
3061
|
+
update: async (e, n, s) => {
|
|
3062
|
+
const { sslOverrides: r } = Ye(
|
|
3063
|
+
s.domain_metadata
|
|
3064
3064
|
), a = {};
|
|
3065
3065
|
if (Object.keys(r).length > 0) {
|
|
3066
|
-
const i = await
|
|
3066
|
+
const i = await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: o, success: c } = de.parse(i);
|
|
3067
3067
|
if (!c)
|
|
3068
|
-
throw new
|
|
3068
|
+
throw new ne(503, {
|
|
3069
3069
|
message: "Failed to fetch current custom hostname state"
|
|
3070
3070
|
});
|
|
3071
3071
|
a.ssl = {
|
|
@@ -3076,24 +3076,24 @@ function es(t) {
|
|
|
3076
3076
|
};
|
|
3077
3077
|
}
|
|
3078
3078
|
if (Object.keys(a).length > 0) {
|
|
3079
|
-
const i = await
|
|
3079
|
+
const i = await Y(t).patch(
|
|
3080
3080
|
a,
|
|
3081
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3081
|
+
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3082
3082
|
).res();
|
|
3083
3083
|
if (!i.ok)
|
|
3084
|
-
throw new
|
|
3084
|
+
throw new ne(503, {
|
|
3085
3085
|
message: await i.text()
|
|
3086
3086
|
});
|
|
3087
3087
|
}
|
|
3088
3088
|
return t.customDomainAdapter.update(
|
|
3089
3089
|
e,
|
|
3090
|
-
|
|
3091
|
-
|
|
3090
|
+
n,
|
|
3091
|
+
s
|
|
3092
3092
|
);
|
|
3093
3093
|
}
|
|
3094
3094
|
};
|
|
3095
3095
|
}
|
|
3096
|
-
class
|
|
3096
|
+
class on {
|
|
3097
3097
|
constructor(e) {
|
|
3098
3098
|
this.config = e;
|
|
3099
3099
|
}
|
|
@@ -3116,7 +3116,7 @@ class ts {
|
|
|
3116
3116
|
}
|
|
3117
3117
|
async get(e) {
|
|
3118
3118
|
try {
|
|
3119
|
-
const
|
|
3119
|
+
const n = await this.getCache(), s = this.createRequest(e), r = await n.match(s);
|
|
3120
3120
|
if (!r)
|
|
3121
3121
|
return null;
|
|
3122
3122
|
const a = await r.text();
|
|
@@ -3129,14 +3129,14 @@ class ts {
|
|
|
3129
3129
|
return await this.delete(e), null;
|
|
3130
3130
|
}
|
|
3131
3131
|
return i.expiresAt && new Date(i.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : i.value;
|
|
3132
|
-
} catch (
|
|
3133
|
-
return console.error(`CloudflareCache: get error for key ${e}:`,
|
|
3132
|
+
} catch (n) {
|
|
3133
|
+
return console.error(`CloudflareCache: get error for key ${e}:`, n), null;
|
|
3134
3134
|
}
|
|
3135
3135
|
}
|
|
3136
|
-
async set(e,
|
|
3136
|
+
async set(e, n, s) {
|
|
3137
3137
|
try {
|
|
3138
|
-
const r = await this.getCache(), a =
|
|
3139
|
-
value:
|
|
3138
|
+
const r = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3139
|
+
value: n,
|
|
3140
3140
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3141
3141
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3142
3142
|
}, d = this.createRequest(e), f = {
|
|
@@ -3153,10 +3153,10 @@ class ts {
|
|
|
3153
3153
|
}
|
|
3154
3154
|
async delete(e) {
|
|
3155
3155
|
try {
|
|
3156
|
-
const
|
|
3157
|
-
return await
|
|
3158
|
-
} catch (
|
|
3159
|
-
return console.error(`CloudflareCache: delete error for key ${e}:`,
|
|
3156
|
+
const n = await this.getCache(), s = this.createRequest(e);
|
|
3157
|
+
return await n.delete(s);
|
|
3158
|
+
} catch (n) {
|
|
3159
|
+
return console.error(`CloudflareCache: delete error for key ${e}:`, n), !1;
|
|
3160
3160
|
}
|
|
3161
3161
|
}
|
|
3162
3162
|
async deleteByPrefix(e) {
|
|
@@ -3170,7 +3170,7 @@ class ts {
|
|
|
3170
3170
|
);
|
|
3171
3171
|
}
|
|
3172
3172
|
}
|
|
3173
|
-
function
|
|
3173
|
+
function cn(t = {}) {
|
|
3174
3174
|
const e = {
|
|
3175
3175
|
defaultTtlSeconds: 300,
|
|
3176
3176
|
// 5 minutes default
|
|
@@ -3179,16 +3179,16 @@ function ss(t = {}) {
|
|
|
3179
3179
|
...t
|
|
3180
3180
|
// user config overrides defaults
|
|
3181
3181
|
};
|
|
3182
|
-
return new
|
|
3182
|
+
return new on(e);
|
|
3183
3183
|
}
|
|
3184
|
-
let
|
|
3185
|
-
let e = "",
|
|
3184
|
+
let dn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", ft = (t = 21) => {
|
|
3185
|
+
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
3186
3186
|
for (; t--; )
|
|
3187
|
-
e +=
|
|
3187
|
+
e += dn[n[t] & 63];
|
|
3188
3188
|
return e;
|
|
3189
3189
|
};
|
|
3190
3190
|
async function He(t, e) {
|
|
3191
|
-
const
|
|
3191
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3192
3192
|
try {
|
|
3193
3193
|
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
3194
3194
|
method: "POST",
|
|
@@ -3200,7 +3200,7 @@ async function He(t, e) {
|
|
|
3200
3200
|
body: JSON.stringify({
|
|
3201
3201
|
query: e
|
|
3202
3202
|
}),
|
|
3203
|
-
signal:
|
|
3203
|
+
signal: s.signal
|
|
3204
3204
|
});
|
|
3205
3205
|
if (!i.ok)
|
|
3206
3206
|
throw new Error(
|
|
@@ -3214,20 +3214,20 @@ async function He(t, e) {
|
|
|
3214
3214
|
clearTimeout(r);
|
|
3215
3215
|
}
|
|
3216
3216
|
}
|
|
3217
|
-
function
|
|
3217
|
+
function we(t) {
|
|
3218
3218
|
return `'${t.replace(/'/g, "''")}'`;
|
|
3219
3219
|
}
|
|
3220
|
-
function
|
|
3220
|
+
function J(t) {
|
|
3221
3221
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3222
3222
|
}
|
|
3223
|
-
function
|
|
3224
|
-
const e = (
|
|
3225
|
-
if (!
|
|
3223
|
+
function pt(t) {
|
|
3224
|
+
const e = (n) => {
|
|
3225
|
+
if (!n)
|
|
3226
3226
|
return "";
|
|
3227
3227
|
try {
|
|
3228
|
-
return JSON.parse(
|
|
3228
|
+
return JSON.parse(n);
|
|
3229
3229
|
} catch {
|
|
3230
|
-
return
|
|
3230
|
+
return n;
|
|
3231
3231
|
}
|
|
3232
3232
|
};
|
|
3233
3233
|
return {
|
|
@@ -3262,46 +3262,46 @@ function ut(t) {
|
|
|
3262
3262
|
} : void 0
|
|
3263
3263
|
};
|
|
3264
3264
|
}
|
|
3265
|
-
function
|
|
3266
|
-
return async (e,
|
|
3267
|
-
const
|
|
3268
|
-
...
|
|
3269
|
-
log_id:
|
|
3265
|
+
function un(t) {
|
|
3266
|
+
return async (e, n) => {
|
|
3267
|
+
const s = n.log_id || ft(), r = {
|
|
3268
|
+
...n,
|
|
3269
|
+
log_id: s
|
|
3270
3270
|
};
|
|
3271
|
-
return await
|
|
3271
|
+
return await ln(t, e, r), r;
|
|
3272
3272
|
};
|
|
3273
3273
|
}
|
|
3274
|
-
async function
|
|
3275
|
-
const
|
|
3276
|
-
id:
|
|
3274
|
+
async function ln(t, e, n) {
|
|
3275
|
+
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3276
|
+
id: n.log_id,
|
|
3277
3277
|
tenant_id: e,
|
|
3278
|
-
type:
|
|
3279
|
-
date:
|
|
3280
|
-
description:
|
|
3281
|
-
ip:
|
|
3282
|
-
user_agent:
|
|
3283
|
-
details: n
|
|
3284
|
-
isMobile:
|
|
3285
|
-
user_id:
|
|
3286
|
-
user_name:
|
|
3287
|
-
connection:
|
|
3288
|
-
connection_id:
|
|
3289
|
-
client_id:
|
|
3290
|
-
client_name:
|
|
3291
|
-
audience:
|
|
3292
|
-
scope:
|
|
3293
|
-
strategy:
|
|
3294
|
-
strategy_type:
|
|
3295
|
-
hostname:
|
|
3296
|
-
auth0_client: n
|
|
3297
|
-
log_id:
|
|
3278
|
+
type: n.type,
|
|
3279
|
+
date: n.date,
|
|
3280
|
+
description: n.description?.substring(0, 256),
|
|
3281
|
+
ip: n.ip,
|
|
3282
|
+
user_agent: n.user_agent,
|
|
3283
|
+
details: s(n.details)?.substring(0, 8192),
|
|
3284
|
+
isMobile: n.isMobile ? 1 : 0,
|
|
3285
|
+
user_id: n.user_id,
|
|
3286
|
+
user_name: n.user_name,
|
|
3287
|
+
connection: n.connection,
|
|
3288
|
+
connection_id: n.connection_id,
|
|
3289
|
+
client_id: n.client_id,
|
|
3290
|
+
client_name: n.client_name,
|
|
3291
|
+
audience: n.audience,
|
|
3292
|
+
scope: n.scope,
|
|
3293
|
+
strategy: n.strategy,
|
|
3294
|
+
strategy_type: n.strategy_type,
|
|
3295
|
+
hostname: n.hostname,
|
|
3296
|
+
auth0_client: s(n.auth0_client),
|
|
3297
|
+
log_id: n.log_id,
|
|
3298
3298
|
// Geo fields from location_info
|
|
3299
|
-
country_code:
|
|
3300
|
-
city_name:
|
|
3301
|
-
latitude:
|
|
3302
|
-
longitude:
|
|
3303
|
-
time_zone:
|
|
3304
|
-
continent_code:
|
|
3299
|
+
country_code: n.location_info?.country_code,
|
|
3300
|
+
city_name: n.location_info?.city_name,
|
|
3301
|
+
latitude: n.location_info?.latitude,
|
|
3302
|
+
longitude: n.location_info?.longitude,
|
|
3303
|
+
time_zone: n.location_info?.time_zone,
|
|
3304
|
+
continent_code: n.location_info?.continent_code
|
|
3305
3305
|
};
|
|
3306
3306
|
try {
|
|
3307
3307
|
if (t.pipelineBinding)
|
|
@@ -3333,58 +3333,58 @@ async function as(t, e, s) {
|
|
|
3333
3333
|
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3334
3334
|
}
|
|
3335
3335
|
}
|
|
3336
|
-
function
|
|
3337
|
-
return async (e,
|
|
3338
|
-
const
|
|
3339
|
-
SELECT * FROM ${
|
|
3340
|
-
WHERE tenant_id = ${
|
|
3341
|
-
AND id = ${
|
|
3336
|
+
function hn(t) {
|
|
3337
|
+
return async (e, n) => {
|
|
3338
|
+
const s = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3339
|
+
SELECT * FROM ${J(s)}.${J(r)}
|
|
3340
|
+
WHERE tenant_id = ${we(e)}
|
|
3341
|
+
AND id = ${we(n)}
|
|
3342
3342
|
LIMIT 1
|
|
3343
3343
|
`, i = await He(t, a);
|
|
3344
3344
|
if (i.length === 0)
|
|
3345
3345
|
return null;
|
|
3346
3346
|
const o = i[0];
|
|
3347
|
-
return o ?
|
|
3347
|
+
return o ? pt(o) : null;
|
|
3348
3348
|
};
|
|
3349
3349
|
}
|
|
3350
|
-
function
|
|
3350
|
+
function fn(t) {
|
|
3351
3351
|
const e = {};
|
|
3352
|
-
return (t.match(/(\w+):(\S+)/g) || []).forEach((
|
|
3353
|
-
const [r, a] =
|
|
3352
|
+
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3353
|
+
const [r, a] = s.split(":");
|
|
3354
3354
|
r && a && (e[r] = a);
|
|
3355
3355
|
}), e;
|
|
3356
3356
|
}
|
|
3357
|
-
function
|
|
3357
|
+
function pn(t) {
|
|
3358
3358
|
const e = [];
|
|
3359
|
-
for (const [
|
|
3360
|
-
const r =
|
|
3361
|
-
r &&
|
|
3362
|
-
`${
|
|
3359
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3360
|
+
const r = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3361
|
+
r && s && e.push(
|
|
3362
|
+
`${J(r)} = ${we(s)}`
|
|
3363
3363
|
);
|
|
3364
3364
|
}
|
|
3365
3365
|
return e;
|
|
3366
3366
|
}
|
|
3367
|
-
function
|
|
3368
|
-
return async (e,
|
|
3369
|
-
const { page:
|
|
3370
|
-
`tenant_id = ${
|
|
3367
|
+
function mn(t) {
|
|
3368
|
+
return async (e, n = {}) => {
|
|
3369
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.namespace || "default", d = t.tableName || "logs", f = [
|
|
3370
|
+
`tenant_id = ${we(e)}`
|
|
3371
3371
|
];
|
|
3372
3372
|
if (o) {
|
|
3373
|
-
const
|
|
3374
|
-
f.push(...
|
|
3373
|
+
const R = fn(o);
|
|
3374
|
+
f.push(...pn(R));
|
|
3375
3375
|
}
|
|
3376
3376
|
const x = f.join(" AND ");
|
|
3377
|
-
let
|
|
3377
|
+
let T = "ORDER BY date DESC";
|
|
3378
3378
|
if (i && i.sort_by) {
|
|
3379
|
-
const
|
|
3380
|
-
|
|
3379
|
+
const R = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), V = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3380
|
+
T = `ORDER BY ${J(R)} ${V}`;
|
|
3381
3381
|
}
|
|
3382
|
-
const
|
|
3383
|
-
SELECT * FROM ${
|
|
3382
|
+
const E = s * r, O = `LIMIT ${r} OFFSET ${E}`, M = `
|
|
3383
|
+
SELECT * FROM ${J(c)}.${J(d)}
|
|
3384
3384
|
WHERE ${x}
|
|
3385
|
-
${
|
|
3385
|
+
${T}
|
|
3386
3386
|
${O}
|
|
3387
|
-
`, P = (await He(t, M)).map(
|
|
3387
|
+
`, P = (await He(t, M)).map(pt);
|
|
3388
3388
|
if (!a)
|
|
3389
3389
|
return {
|
|
3390
3390
|
logs: P,
|
|
@@ -3393,18 +3393,18 @@ function ds(t) {
|
|
|
3393
3393
|
length: 0
|
|
3394
3394
|
};
|
|
3395
3395
|
const A = `
|
|
3396
|
-
SELECT COUNT(*) as count FROM ${
|
|
3396
|
+
SELECT COUNT(*) as count FROM ${J(c)}.${J(d)}
|
|
3397
3397
|
WHERE ${x}
|
|
3398
3398
|
`, S = (await He(t, A))[0]?.count || 0;
|
|
3399
3399
|
return {
|
|
3400
3400
|
logs: P,
|
|
3401
|
-
start:
|
|
3401
|
+
start: E,
|
|
3402
3402
|
limit: r,
|
|
3403
3403
|
length: Number(S)
|
|
3404
3404
|
};
|
|
3405
3405
|
};
|
|
3406
3406
|
}
|
|
3407
|
-
function
|
|
3407
|
+
function es() {
|
|
3408
3408
|
return {
|
|
3409
3409
|
async getDaily() {
|
|
3410
3410
|
throw new Error(
|
|
@@ -3418,9 +3418,9 @@ function Us() {
|
|
|
3418
3418
|
}
|
|
3419
3419
|
};
|
|
3420
3420
|
}
|
|
3421
|
-
function
|
|
3422
|
-
const e = !!t.pipelineEndpoint,
|
|
3423
|
-
if (!e && !
|
|
3421
|
+
function yn(t) {
|
|
3422
|
+
const e = !!t.pipelineEndpoint, n = !!t.pipelineBinding;
|
|
3423
|
+
if (!e && !n)
|
|
3424
3424
|
throw new Error(
|
|
3425
3425
|
'R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"'
|
|
3426
3426
|
);
|
|
@@ -3431,13 +3431,13 @@ function us(t) {
|
|
|
3431
3431
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3432
3432
|
);
|
|
3433
3433
|
return {
|
|
3434
|
-
create:
|
|
3435
|
-
list:
|
|
3436
|
-
get:
|
|
3434
|
+
create: un(t),
|
|
3435
|
+
list: mn(t),
|
|
3436
|
+
get: hn(t)
|
|
3437
3437
|
};
|
|
3438
3438
|
}
|
|
3439
|
-
async function
|
|
3440
|
-
const
|
|
3439
|
+
async function oe(t, e) {
|
|
3440
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3441
3441
|
try {
|
|
3442
3442
|
const a = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(a, {
|
|
3443
3443
|
method: "POST",
|
|
@@ -3446,7 +3446,7 @@ async function pe(t, e) {
|
|
|
3446
3446
|
Authorization: `Bearer ${t.apiToken}`
|
|
3447
3447
|
},
|
|
3448
3448
|
body: e,
|
|
3449
|
-
signal:
|
|
3449
|
+
signal: s.signal
|
|
3450
3450
|
});
|
|
3451
3451
|
if (!i.ok) {
|
|
3452
3452
|
const c = await i.text();
|
|
@@ -3464,13 +3464,13 @@ async function pe(t, e) {
|
|
|
3464
3464
|
clearTimeout(r);
|
|
3465
3465
|
}
|
|
3466
3466
|
}
|
|
3467
|
-
function
|
|
3467
|
+
function N(t) {
|
|
3468
3468
|
return `'${t.replace(/'/g, "''").replace(/\\/g, "\\\\")}'`;
|
|
3469
3469
|
}
|
|
3470
|
-
function
|
|
3470
|
+
function I(t) {
|
|
3471
3471
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3472
3472
|
}
|
|
3473
|
-
function
|
|
3473
|
+
function mt(t) {
|
|
3474
3474
|
const e = (r) => {
|
|
3475
3475
|
if (r)
|
|
3476
3476
|
try {
|
|
@@ -3478,11 +3478,11 @@ function lt(t) {
|
|
|
3478
3478
|
} catch {
|
|
3479
3479
|
return;
|
|
3480
3480
|
}
|
|
3481
|
-
},
|
|
3481
|
+
}, n = t.double2 || t.timestamp, s = n ? new Date(n).toISOString() : "";
|
|
3482
3482
|
return {
|
|
3483
3483
|
log_id: t.blob1,
|
|
3484
3484
|
type: t.blob3,
|
|
3485
|
-
date:
|
|
3485
|
+
date: s,
|
|
3486
3486
|
description: t.blob4,
|
|
3487
3487
|
ip: t.blob5,
|
|
3488
3488
|
user_agent: t.blob6,
|
|
@@ -3503,69 +3503,69 @@ function lt(t) {
|
|
|
3503
3503
|
isMobile: t.double1 === 1
|
|
3504
3504
|
};
|
|
3505
3505
|
}
|
|
3506
|
-
function
|
|
3507
|
-
return async (e,
|
|
3508
|
-
const
|
|
3509
|
-
...
|
|
3510
|
-
log_id:
|
|
3506
|
+
function gn(t) {
|
|
3507
|
+
return async (e, n) => {
|
|
3508
|
+
const s = n.log_id || ft(), r = {
|
|
3509
|
+
...n,
|
|
3510
|
+
log_id: s
|
|
3511
3511
|
};
|
|
3512
|
-
return
|
|
3512
|
+
return _n(t, e, r), r;
|
|
3513
3513
|
};
|
|
3514
3514
|
}
|
|
3515
|
-
function
|
|
3515
|
+
function _n(t, e, n) {
|
|
3516
3516
|
if (!t.analyticsEngineBinding) {
|
|
3517
3517
|
console.error("Analytics Engine binding not configured");
|
|
3518
3518
|
return;
|
|
3519
3519
|
}
|
|
3520
|
-
const
|
|
3520
|
+
const s = (a) => a == null ? "" : typeof a == "string" ? a : JSON.stringify(a), r = (a, i = 1024) => a.substring(0, i);
|
|
3521
3521
|
try {
|
|
3522
3522
|
t.analyticsEngineBinding.writeDataPoint({
|
|
3523
3523
|
blobs: [
|
|
3524
|
-
r(
|
|
3524
|
+
r(n.log_id),
|
|
3525
3525
|
// blob1: log_id
|
|
3526
3526
|
r(e),
|
|
3527
3527
|
// blob2: tenant_id
|
|
3528
|
-
r(
|
|
3528
|
+
r(n.type || ""),
|
|
3529
3529
|
// blob3: type
|
|
3530
|
-
r(
|
|
3530
|
+
r(n.description || ""),
|
|
3531
3531
|
// blob4: description
|
|
3532
|
-
r(
|
|
3532
|
+
r(n.ip || ""),
|
|
3533
3533
|
// blob5: ip
|
|
3534
|
-
r(
|
|
3534
|
+
r(n.user_agent || ""),
|
|
3535
3535
|
// blob6: user_agent
|
|
3536
|
-
r(
|
|
3536
|
+
r(n.user_id || ""),
|
|
3537
3537
|
// blob7: user_id
|
|
3538
|
-
r(
|
|
3538
|
+
r(n.user_name || ""),
|
|
3539
3539
|
// blob8: user_name
|
|
3540
|
-
r(
|
|
3540
|
+
r(n.connection || ""),
|
|
3541
3541
|
// blob9: connection
|
|
3542
|
-
r(
|
|
3542
|
+
r(n.connection_id || ""),
|
|
3543
3543
|
// blob10: connection_id
|
|
3544
|
-
r(
|
|
3544
|
+
r(n.client_id || ""),
|
|
3545
3545
|
// blob11: client_id
|
|
3546
|
-
r(
|
|
3546
|
+
r(n.client_name || ""),
|
|
3547
3547
|
// blob12: client_name
|
|
3548
|
-
r(
|
|
3548
|
+
r(n.audience || ""),
|
|
3549
3549
|
// blob13: audience
|
|
3550
|
-
r(
|
|
3550
|
+
r(n.scope || ""),
|
|
3551
3551
|
// blob14: scope
|
|
3552
|
-
r(
|
|
3552
|
+
r(n.strategy || ""),
|
|
3553
3553
|
// blob15: strategy
|
|
3554
|
-
r(
|
|
3554
|
+
r(n.strategy_type || ""),
|
|
3555
3555
|
// blob16: strategy_type
|
|
3556
|
-
r(
|
|
3556
|
+
r(n.hostname || ""),
|
|
3557
3557
|
// blob17: hostname
|
|
3558
|
-
r(n
|
|
3558
|
+
r(s(n.details)),
|
|
3559
3559
|
// blob18: details (JSON)
|
|
3560
|
-
r(n
|
|
3560
|
+
r(s(n.auth0_client)),
|
|
3561
3561
|
// blob19: auth0_client (JSON)
|
|
3562
|
-
r(n
|
|
3562
|
+
r(s(n.location_info))
|
|
3563
3563
|
// blob20: location_info (JSON)
|
|
3564
3564
|
],
|
|
3565
3565
|
doubles: [
|
|
3566
|
-
|
|
3566
|
+
n.isMobile ? 1 : 0,
|
|
3567
3567
|
// double1: isMobile
|
|
3568
|
-
new Date(
|
|
3568
|
+
new Date(n.date).getTime()
|
|
3569
3569
|
// double2: timestamp for sorting
|
|
3570
3570
|
],
|
|
3571
3571
|
indexes: [e.substring(0, 96)]
|
|
@@ -3575,28 +3575,28 @@ function hs(t, e, s) {
|
|
|
3575
3575
|
console.error("Failed to write log to Analytics Engine:", a);
|
|
3576
3576
|
}
|
|
3577
3577
|
}
|
|
3578
|
-
function
|
|
3579
|
-
return async (e,
|
|
3580
|
-
const
|
|
3578
|
+
function vn(t) {
|
|
3579
|
+
return async (e, n) => {
|
|
3580
|
+
const s = t.dataset || "authhero_logs", r = `
|
|
3581
3581
|
SELECT *
|
|
3582
|
-
FROM ${
|
|
3583
|
-
WHERE index1 = ${
|
|
3584
|
-
AND blob1 = ${
|
|
3582
|
+
FROM ${I(s)}
|
|
3583
|
+
WHERE index1 = ${N(e)}
|
|
3584
|
+
AND blob1 = ${N(n)}
|
|
3585
3585
|
LIMIT 1
|
|
3586
|
-
`, a = await
|
|
3587
|
-
return a.length === 0 || !a[0] ? null :
|
|
3586
|
+
`, a = await oe(t, r);
|
|
3587
|
+
return a.length === 0 || !a[0] ? null : mt(a[0]);
|
|
3588
3588
|
};
|
|
3589
3589
|
}
|
|
3590
|
-
function
|
|
3591
|
-
const e = {},
|
|
3592
|
-
let
|
|
3593
|
-
for (; (
|
|
3594
|
-
const r =
|
|
3590
|
+
function bn(t) {
|
|
3591
|
+
const e = {}, n = /(\w+):(?:"([^"]*)"|(\S+))/g;
|
|
3592
|
+
let s;
|
|
3593
|
+
for (; (s = n.exec(t)) !== null; ) {
|
|
3594
|
+
const r = s[1], a = s[2] !== void 0 ? s[2] : s[3];
|
|
3595
3595
|
!r || a === void 0 || (e[r] || (e[r] = []), e[r].push(a));
|
|
3596
3596
|
}
|
|
3597
3597
|
return e;
|
|
3598
3598
|
}
|
|
3599
|
-
function
|
|
3599
|
+
function yt(t) {
|
|
3600
3600
|
return {
|
|
3601
3601
|
log_id: "blob1",
|
|
3602
3602
|
tenant_id: "blob2",
|
|
@@ -3617,64 +3617,64 @@ function ht(t) {
|
|
|
3617
3617
|
hostname: "blob17"
|
|
3618
3618
|
}[t] || null;
|
|
3619
3619
|
}
|
|
3620
|
-
function
|
|
3620
|
+
function xn(t) {
|
|
3621
3621
|
const e = [];
|
|
3622
|
-
for (const [
|
|
3623
|
-
const r =
|
|
3622
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3623
|
+
const r = s.filter((i) => i !== "");
|
|
3624
3624
|
if (r.length === 0) continue;
|
|
3625
|
-
if (
|
|
3625
|
+
if (n === "success") {
|
|
3626
3626
|
const i = [], o = /* @__PURE__ */ new Set();
|
|
3627
3627
|
for (const c of r)
|
|
3628
3628
|
o.has(c) || (o.add(c), c === "true" ? i.push("blob3 LIKE 's%'") : c === "false" && i.push("blob3 LIKE 'f%'"));
|
|
3629
3629
|
i.length > 0 && e.push(`(${i.join(" OR ")})`);
|
|
3630
3630
|
continue;
|
|
3631
3631
|
}
|
|
3632
|
-
const a =
|
|
3632
|
+
const a = yt(n);
|
|
3633
3633
|
if (a)
|
|
3634
3634
|
if (r.length === 1)
|
|
3635
|
-
e.push(`${a} = ${
|
|
3635
|
+
e.push(`${a} = ${N(r[0])}`);
|
|
3636
3636
|
else {
|
|
3637
|
-
const i = r.map((o) =>
|
|
3637
|
+
const i = r.map((o) => N(o)).join(", ");
|
|
3638
3638
|
e.push(`${a} IN (${i})`);
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
3641
3641
|
return e;
|
|
3642
3642
|
}
|
|
3643
|
-
function
|
|
3643
|
+
function wn(t) {
|
|
3644
3644
|
if (t === "date")
|
|
3645
3645
|
return "double2";
|
|
3646
|
-
const e =
|
|
3646
|
+
const e = yt(t);
|
|
3647
3647
|
return e || "timestamp";
|
|
3648
3648
|
}
|
|
3649
|
-
function
|
|
3650
|
-
return async (e,
|
|
3649
|
+
function kn(t) {
|
|
3650
|
+
return async (e, n = {}) => {
|
|
3651
3651
|
const {
|
|
3652
|
-
page:
|
|
3652
|
+
page: s = 0,
|
|
3653
3653
|
per_page: r = 50,
|
|
3654
3654
|
include_totals: a = !1,
|
|
3655
3655
|
sort: i,
|
|
3656
3656
|
q: o,
|
|
3657
3657
|
from_date: c,
|
|
3658
3658
|
to_date: d
|
|
3659
|
-
} =
|
|
3659
|
+
} = n, f = t.dataset || "authhero_logs", x = [`index1 = ${N(e)}`];
|
|
3660
3660
|
if (o) {
|
|
3661
|
-
const S =
|
|
3662
|
-
x.push(...
|
|
3661
|
+
const S = bn(o);
|
|
3662
|
+
x.push(...xn(S));
|
|
3663
3663
|
}
|
|
3664
3664
|
typeof c == "number" && Number.isFinite(c) && x.push(`double2 >= ${Math.floor(c) * 1e3}`), typeof d == "number" && Number.isFinite(d) && x.push(`double2 <= ${Math.floor(d) * 1e3}`);
|
|
3665
|
-
const
|
|
3666
|
-
let
|
|
3665
|
+
const T = x.join(" AND ");
|
|
3666
|
+
let E = "ORDER BY timestamp DESC";
|
|
3667
3667
|
if (i && i.sort_by) {
|
|
3668
|
-
const S =
|
|
3669
|
-
|
|
3668
|
+
const S = wn(i.sort_by), R = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3669
|
+
E = `ORDER BY ${S} ${R}`;
|
|
3670
3670
|
}
|
|
3671
|
-
const O =
|
|
3671
|
+
const O = s * r, M = `LIMIT ${r} OFFSET ${O}`, w = `
|
|
3672
3672
|
SELECT *
|
|
3673
|
-
FROM ${
|
|
3674
|
-
WHERE ${
|
|
3675
|
-
${
|
|
3673
|
+
FROM ${I(f)}
|
|
3674
|
+
WHERE ${T}
|
|
3675
|
+
${E}
|
|
3676
3676
|
${M}
|
|
3677
|
-
`, A = (await
|
|
3677
|
+
`, A = (await oe(t, w)).map(mt);
|
|
3678
3678
|
if (!a)
|
|
3679
3679
|
return {
|
|
3680
3680
|
logs: A,
|
|
@@ -3684,16 +3684,16 @@ function gs(t) {
|
|
|
3684
3684
|
};
|
|
3685
3685
|
const k = `
|
|
3686
3686
|
SELECT count() as count
|
|
3687
|
-
FROM ${
|
|
3688
|
-
WHERE ${
|
|
3687
|
+
FROM ${I(f)}
|
|
3688
|
+
WHERE ${T}
|
|
3689
3689
|
`;
|
|
3690
3690
|
try {
|
|
3691
|
-
const
|
|
3691
|
+
const R = (await oe(t, k))[0]?.count || 0;
|
|
3692
3692
|
return {
|
|
3693
3693
|
logs: A,
|
|
3694
3694
|
start: O,
|
|
3695
3695
|
limit: r,
|
|
3696
|
-
length: Number(
|
|
3696
|
+
length: Number(R)
|
|
3697
3697
|
};
|
|
3698
3698
|
} catch {
|
|
3699
3699
|
return {
|
|
@@ -3705,39 +3705,39 @@ function gs(t) {
|
|
|
3705
3705
|
}
|
|
3706
3706
|
};
|
|
3707
3707
|
}
|
|
3708
|
-
const
|
|
3709
|
-
function
|
|
3708
|
+
const Ge = ["s"], Sn = ["pwd_leak"];
|
|
3709
|
+
function Ke(t) {
|
|
3710
3710
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3711
3711
|
}
|
|
3712
|
-
function
|
|
3712
|
+
function Xe(t) {
|
|
3713
3713
|
return t.toISOString().split("T")[0];
|
|
3714
3714
|
}
|
|
3715
|
-
function
|
|
3715
|
+
function ts(t) {
|
|
3716
3716
|
const e = t.dataset || "authhero_logs";
|
|
3717
3717
|
return {
|
|
3718
|
-
async getDaily(
|
|
3719
|
-
const { from: r, to: a } =
|
|
3718
|
+
async getDaily(n, s = {}) {
|
|
3719
|
+
const { from: r, to: a } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3720
3720
|
o.setDate(o.getDate() - 30);
|
|
3721
|
-
const c = r ?
|
|
3721
|
+
const c = r ? Ke(r) : Xe(o), d = a ? Ke(a) : Xe(i), f = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), x = (/* @__PURE__ */ new Date(`${d}T23:59:59.999Z`)).getTime(), T = Ge.map((w) => N(w)).join(
|
|
3722
3722
|
", "
|
|
3723
|
-
),
|
|
3724
|
-
(w) =>
|
|
3723
|
+
), E = Sn.map(
|
|
3724
|
+
(w) => N(w)
|
|
3725
3725
|
).join(", "), O = `
|
|
3726
3726
|
SELECT
|
|
3727
3727
|
toDate(toDateTime(double2 / 1000)) AS date,
|
|
3728
|
-
SUM(CASE WHEN blob3 IN (${
|
|
3728
|
+
SUM(CASE WHEN blob3 IN (${T}) THEN 1 ELSE 0 END) AS logins,
|
|
3729
3729
|
SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
|
|
3730
|
-
SUM(CASE WHEN blob3 IN (${
|
|
3730
|
+
SUM(CASE WHEN blob3 IN (${E}) THEN 1 ELSE 0 END) AS leaked_passwords,
|
|
3731
3731
|
MIN(double2) AS first_event,
|
|
3732
3732
|
MAX(double2) AS last_event
|
|
3733
3733
|
FROM "${e}"
|
|
3734
|
-
WHERE index1 = ${
|
|
3734
|
+
WHERE index1 = ${N(n)}
|
|
3735
3735
|
AND double2 >= ${f}
|
|
3736
3736
|
AND double2 <= ${x}
|
|
3737
3737
|
GROUP BY date
|
|
3738
3738
|
ORDER BY date ASC
|
|
3739
3739
|
`;
|
|
3740
|
-
return (await
|
|
3740
|
+
return (await oe(t, O)).map((w) => ({
|
|
3741
3741
|
date: String(w.date),
|
|
3742
3742
|
logins: Number(w.logins) || 0,
|
|
3743
3743
|
signups: Number(w.signups) || 0,
|
|
@@ -3746,43 +3746,43 @@ function Bs(t) {
|
|
|
3746
3746
|
updated_at: w.last_event ? new Date(Number(w.last_event)).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
3747
3747
|
}));
|
|
3748
3748
|
},
|
|
3749
|
-
async getActiveUsers(
|
|
3750
|
-
const
|
|
3751
|
-
|
|
3752
|
-
const r =
|
|
3749
|
+
async getActiveUsers(n) {
|
|
3750
|
+
const s = /* @__PURE__ */ new Date();
|
|
3751
|
+
s.setDate(s.getDate() - 30);
|
|
3752
|
+
const r = s.getTime(), a = Ge.map((d) => N(d)).join(
|
|
3753
3753
|
", "
|
|
3754
3754
|
), i = `
|
|
3755
3755
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3756
3756
|
FROM "${e}"
|
|
3757
|
-
WHERE index1 = ${
|
|
3757
|
+
WHERE index1 = ${N(n)}
|
|
3758
3758
|
AND double2 >= ${r}
|
|
3759
3759
|
AND blob3 IN (${a})
|
|
3760
3760
|
AND blob7 IS NOT NULL
|
|
3761
3761
|
AND blob7 != ''
|
|
3762
|
-
`, c = (await
|
|
3762
|
+
`, c = (await oe(t, i))[0];
|
|
3763
3763
|
return c && c.count !== void 0 && Number(c.count) || 0;
|
|
3764
3764
|
}
|
|
3765
3765
|
};
|
|
3766
3766
|
}
|
|
3767
|
-
const
|
|
3767
|
+
const En = {
|
|
3768
3768
|
"active-users": ["s", "seacft"],
|
|
3769
3769
|
logins: ["s", "f", "fp"],
|
|
3770
3770
|
signups: ["ss", "fs"],
|
|
3771
3771
|
"refresh-tokens": ["seacft", "fertft"],
|
|
3772
3772
|
// No dedicated session-created event yet; track logouts as the lifecycle signal.
|
|
3773
3773
|
sessions: ["slo"]
|
|
3774
|
-
},
|
|
3774
|
+
}, Cn = {
|
|
3775
3775
|
connection: "blob9",
|
|
3776
3776
|
client_id: "blob11",
|
|
3777
3777
|
user_type: "blob16",
|
|
3778
3778
|
// strategy_type
|
|
3779
3779
|
event: "blob3"
|
|
3780
|
-
},
|
|
3780
|
+
}, Tn = {
|
|
3781
3781
|
connection: "blob9",
|
|
3782
3782
|
client_id: "blob11",
|
|
3783
3783
|
user_type: "blob16",
|
|
3784
3784
|
user_id: "blob7"
|
|
3785
|
-
},
|
|
3785
|
+
}, On = {
|
|
3786
3786
|
"active-users": {
|
|
3787
3787
|
// CF Analytics Engine SQL doesn't support uniq/uniqExact; COUNT(DISTINCT) is.
|
|
3788
3788
|
expr: "count(DISTINCT blob7)",
|
|
@@ -3798,70 +3798,70 @@ const vs = {
|
|
|
3798
3798
|
},
|
|
3799
3799
|
sessions: { expr: "count()", alias: "sessions", type: "UInt64" }
|
|
3800
3800
|
};
|
|
3801
|
-
function
|
|
3802
|
-
const
|
|
3801
|
+
function An(t, e) {
|
|
3802
|
+
const n = `toDateTime(intDiv(double2, 1000), ${N(e)})`;
|
|
3803
3803
|
switch (t) {
|
|
3804
3804
|
case "hour":
|
|
3805
|
-
return `toStartOfHour(${
|
|
3805
|
+
return `toStartOfHour(${n})`;
|
|
3806
3806
|
case "week":
|
|
3807
|
-
return `toStartOfWeek(${
|
|
3807
|
+
return `toStartOfWeek(${n})`;
|
|
3808
3808
|
case "month":
|
|
3809
|
-
return `toStartOfMonth(${
|
|
3809
|
+
return `toStartOfMonth(${n})`;
|
|
3810
3810
|
default:
|
|
3811
|
-
return `toStartOfDay(${
|
|
3811
|
+
return `toStartOfDay(${n})`;
|
|
3812
3812
|
}
|
|
3813
3813
|
}
|
|
3814
|
-
function
|
|
3814
|
+
function Nn(t) {
|
|
3815
3815
|
return t === "hour" ? "DateTime" : "Date";
|
|
3816
3816
|
}
|
|
3817
|
-
function
|
|
3818
|
-
const
|
|
3819
|
-
`index1 = ${
|
|
3820
|
-
`double2 >= ${
|
|
3817
|
+
function $n(t, e, n) {
|
|
3818
|
+
const s = new Date(t.from).getTime(), r = new Date(t.to).getTime(), a = n.map((o) => N(o)).join(", "), i = [
|
|
3819
|
+
`index1 = ${N(e)}`,
|
|
3820
|
+
`double2 >= ${s}`,
|
|
3821
3821
|
`double2 < ${r}`,
|
|
3822
3822
|
`blob3 IN (${a})`
|
|
3823
3823
|
];
|
|
3824
|
-
for (const [o, c] of Object.entries(
|
|
3824
|
+
for (const [o, c] of Object.entries(Tn)) {
|
|
3825
3825
|
const d = t.filters[o];
|
|
3826
3826
|
if (d && d.length > 0) {
|
|
3827
|
-
const f = d.map((x) =>
|
|
3827
|
+
const f = d.map((x) => N(x)).join(", ");
|
|
3828
3828
|
i.push(`${c} IN (${f})`);
|
|
3829
3829
|
}
|
|
3830
3830
|
}
|
|
3831
3831
|
return i.join(" AND ");
|
|
3832
3832
|
}
|
|
3833
|
-
function
|
|
3833
|
+
function Rn(t, e, n) {
|
|
3834
3834
|
if (t.order_by) {
|
|
3835
|
-
const
|
|
3836
|
-
return `${
|
|
3835
|
+
const s = t.order_by.startsWith("-"), r = s ? t.order_by.slice(1) : t.order_by;
|
|
3836
|
+
return `${I(r)} ${s ? "DESC" : "ASC"}`;
|
|
3837
3837
|
}
|
|
3838
|
-
return e.length > 0 ? e[0] === "time" ? `${
|
|
3838
|
+
return e.length > 0 ? e[0] === "time" ? `${I("time")} ASC` : `${I(n)} DESC` : `${I(n)} DESC`;
|
|
3839
3839
|
}
|
|
3840
|
-
function
|
|
3840
|
+
function In(t) {
|
|
3841
3841
|
const e = t.dataset || "authhero_logs";
|
|
3842
3842
|
return {
|
|
3843
|
-
async query(
|
|
3844
|
-
const a =
|
|
3843
|
+
async query(n, s, r) {
|
|
3844
|
+
const a = En[s], i = On[s], o = [], c = [];
|
|
3845
3845
|
for (const k of r.group_by)
|
|
3846
3846
|
if (k === "time") {
|
|
3847
|
-
const S =
|
|
3848
|
-
o.push(`${S} AS ${
|
|
3847
|
+
const S = An(r.interval, r.tz);
|
|
3848
|
+
o.push(`${S} AS ${I("time")}`), c.push({ name: "time", type: Nn(r.interval) });
|
|
3849
3849
|
} else {
|
|
3850
|
-
const S =
|
|
3851
|
-
o.push(`${S} AS ${
|
|
3850
|
+
const S = Cn[k];
|
|
3851
|
+
o.push(`${S} AS ${I(k)}`), c.push({ name: k, type: "String" });
|
|
3852
3852
|
}
|
|
3853
3853
|
c.push({ name: i.alias, type: i.type });
|
|
3854
3854
|
const d = [
|
|
3855
3855
|
...o,
|
|
3856
|
-
`${i.expr} AS ${
|
|
3857
|
-
], f = r.group_by.length ? `GROUP BY ${r.group_by.map((k) =>
|
|
3856
|
+
`${i.expr} AS ${I(i.alias)}`
|
|
3857
|
+
], f = r.group_by.length ? `GROUP BY ${r.group_by.map((k) => I(k === "time" ? "time" : k)).join(", ")}` : "", x = r.group_by.map(
|
|
3858
3858
|
(k) => k === "time" ? "time" : k
|
|
3859
|
-
),
|
|
3859
|
+
), T = Rn(r, x, i.alias), E = `
|
|
3860
3860
|
SELECT ${d.join(", ")}
|
|
3861
|
-
FROM ${
|
|
3862
|
-
WHERE ${
|
|
3861
|
+
FROM ${I(e)}
|
|
3862
|
+
WHERE ${$n(r, n, a)}
|
|
3863
3863
|
${f}
|
|
3864
|
-
ORDER BY ${
|
|
3864
|
+
ORDER BY ${T}
|
|
3865
3865
|
LIMIT ${Math.max(0, r.limit)} OFFSET ${Math.max(0, r.offset)}
|
|
3866
3866
|
FORMAT JSON
|
|
3867
3867
|
`, O = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, M = t.timeout || 3e4, w = new AbortController(), P = setTimeout(() => w.abort(), M), A = Date.now();
|
|
@@ -3872,7 +3872,7 @@ function Es(t) {
|
|
|
3872
3872
|
"Content-Type": "text/plain",
|
|
3873
3873
|
Authorization: `Bearer ${t.apiToken}`
|
|
3874
3874
|
},
|
|
3875
|
-
body:
|
|
3875
|
+
body: E,
|
|
3876
3876
|
signal: w.signal
|
|
3877
3877
|
});
|
|
3878
3878
|
if (!k.ok) {
|
|
@@ -3886,12 +3886,12 @@ function Es(t) {
|
|
|
3886
3886
|
throw new Error(
|
|
3887
3887
|
`Analytics Engine error: ${S.errors.map((V) => V.message).join(", ")}`
|
|
3888
3888
|
);
|
|
3889
|
-
const
|
|
3889
|
+
const R = S.data ?? [];
|
|
3890
3890
|
return {
|
|
3891
3891
|
meta: S.meta ?? c,
|
|
3892
|
-
data:
|
|
3893
|
-
rows: S.rows ??
|
|
3894
|
-
rows_before_limit_at_least: S.rows_before_limit_at_least ??
|
|
3892
|
+
data: R,
|
|
3893
|
+
rows: S.rows ?? R.length,
|
|
3894
|
+
rows_before_limit_at_least: S.rows_before_limit_at_least ?? R.length,
|
|
3895
3895
|
statistics: {
|
|
3896
3896
|
elapsed: (Date.now() - A) / 1e3
|
|
3897
3897
|
}
|
|
@@ -3902,26 +3902,124 @@ function Es(t) {
|
|
|
3902
3902
|
}
|
|
3903
3903
|
};
|
|
3904
3904
|
}
|
|
3905
|
-
function
|
|
3905
|
+
function jn(t) {
|
|
3906
3906
|
return t.analyticsEngineBinding || console.warn(
|
|
3907
3907
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3908
3908
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
3909
3909
|
"Analytics Engine: accountId and apiToken are required for querying logs via SQL API."
|
|
3910
3910
|
), {
|
|
3911
|
-
create:
|
|
3912
|
-
list:
|
|
3913
|
-
get:
|
|
3911
|
+
create: gn(t),
|
|
3912
|
+
list: kn(t),
|
|
3913
|
+
get: vn(t)
|
|
3914
3914
|
};
|
|
3915
3915
|
}
|
|
3916
|
-
|
|
3916
|
+
const Dn = "authhero_action_executions", Ln = 1024, et = "[truncated]";
|
|
3917
|
+
function tt(t) {
|
|
3918
|
+
if (!(typeof t != "string" || t.length === 0))
|
|
3919
|
+
try {
|
|
3920
|
+
return JSON.parse(t);
|
|
3921
|
+
} catch {
|
|
3922
|
+
return;
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
function Zn(t) {
|
|
3926
|
+
const e = _t.safeParse(t);
|
|
3927
|
+
return e.success ? e.data : "unspecified";
|
|
3928
|
+
}
|
|
3929
|
+
function G(t, e = Ln) {
|
|
3930
|
+
return t.length <= e ? t : `${t.substring(0, e - et.length)}${et}`;
|
|
3931
|
+
}
|
|
3932
|
+
function nt(t) {
|
|
3933
|
+
return t == null ? "" : JSON.stringify(t);
|
|
3934
|
+
}
|
|
3935
|
+
function Mn(t) {
|
|
3936
|
+
const e = typeof t.blob6 == "string" && t.blob6.length > 0 ? t.blob6 : typeof t.double1 == "number" ? new Date(t.double1).toISOString() : "", n = typeof t.blob7 == "string" && t.blob7.length > 0 ? t.blob7 : e;
|
|
3937
|
+
return {
|
|
3938
|
+
id: typeof t.blob1 == "string" ? t.blob1 : "",
|
|
3939
|
+
tenant_id: typeof t.index1 == "string" ? t.index1 : "",
|
|
3940
|
+
trigger_id: typeof t.blob2 == "string" ? t.blob2 : "",
|
|
3941
|
+
status: Zn(t.blob3),
|
|
3942
|
+
results: tt(t.blob4) ?? [],
|
|
3943
|
+
logs: tt(t.blob5),
|
|
3944
|
+
created_at: e,
|
|
3945
|
+
updated_at: n
|
|
3946
|
+
};
|
|
3947
|
+
}
|
|
3948
|
+
function Pn(t) {
|
|
3949
|
+
return async (e, n) => {
|
|
3950
|
+
const s = Date.now(), r = new Date(s).toISOString(), a = {
|
|
3951
|
+
id: n.id,
|
|
3952
|
+
tenant_id: e,
|
|
3953
|
+
trigger_id: n.trigger_id,
|
|
3954
|
+
status: n.status,
|
|
3955
|
+
results: n.results,
|
|
3956
|
+
logs: n.logs,
|
|
3957
|
+
created_at: r,
|
|
3958
|
+
updated_at: r
|
|
3959
|
+
};
|
|
3960
|
+
return Bn(t, e, a, s), a;
|
|
3961
|
+
};
|
|
3962
|
+
}
|
|
3963
|
+
function Bn(t, e, n, s) {
|
|
3964
|
+
if (!t.analyticsEngineBinding) {
|
|
3965
|
+
console.error(
|
|
3966
|
+
"Analytics Engine action_executions binding not configured; skipping write"
|
|
3967
|
+
);
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3970
|
+
try {
|
|
3971
|
+
t.analyticsEngineBinding.writeDataPoint({
|
|
3972
|
+
blobs: [
|
|
3973
|
+
G(n.id),
|
|
3974
|
+
G(n.trigger_id),
|
|
3975
|
+
G(n.status),
|
|
3976
|
+
G(nt(n.results)),
|
|
3977
|
+
G(nt(n.logs)),
|
|
3978
|
+
G(n.created_at),
|
|
3979
|
+
G(n.updated_at)
|
|
3980
|
+
],
|
|
3981
|
+
doubles: [s],
|
|
3982
|
+
// AE caps index values at 96 bytes.
|
|
3983
|
+
indexes: [e.substring(0, 96)]
|
|
3984
|
+
});
|
|
3985
|
+
} catch (r) {
|
|
3986
|
+
console.error(
|
|
3987
|
+
"Failed to write action_execution to Analytics Engine:",
|
|
3988
|
+
r
|
|
3989
|
+
);
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
function Un(t) {
|
|
3993
|
+
return async (e, n) => {
|
|
3994
|
+
const s = t.dataset || Dn, r = `
|
|
3995
|
+
SELECT *
|
|
3996
|
+
FROM ${I(s)}
|
|
3997
|
+
WHERE index1 = ${N(e)}
|
|
3998
|
+
AND blob1 = ${N(n)}
|
|
3999
|
+
LIMIT 1
|
|
4000
|
+
`, a = await oe(t, r);
|
|
4001
|
+
return a.length === 0 || !a[0] ? null : Mn(a[0]);
|
|
4002
|
+
};
|
|
4003
|
+
}
|
|
4004
|
+
function Fn(t) {
|
|
4005
|
+
return t.analyticsEngineBinding || console.warn(
|
|
4006
|
+
"Analytics Engine: No action_executions binding configured. Executions will not be written."
|
|
4007
|
+
), (!t.accountId || !t.apiToken) && console.warn(
|
|
4008
|
+
"Analytics Engine: accountId and apiToken are required to read action_executions via the SQL API."
|
|
4009
|
+
), {
|
|
4010
|
+
create: Pn(t),
|
|
4011
|
+
get: Un(t)
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
function Vn() {
|
|
3917
4015
|
return {
|
|
3918
4016
|
async getGeoInfo(t) {
|
|
3919
4017
|
try {
|
|
3920
|
-
const e = t["cf-ipcountry"],
|
|
4018
|
+
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"], r = t["cf-iplongitude"], a = t["cf-timezone"], i = t["cf-ipcontinent"];
|
|
3921
4019
|
return e ? {
|
|
3922
4020
|
country_code: e,
|
|
3923
|
-
city_name:
|
|
3924
|
-
latitude:
|
|
4021
|
+
city_name: n || "",
|
|
4022
|
+
latitude: s || "",
|
|
3925
4023
|
longitude: r || "",
|
|
3926
4024
|
time_zone: a || "",
|
|
3927
4025
|
continent_code: i || ""
|
|
@@ -3932,17 +4030,17 @@ function As() {
|
|
|
3932
4030
|
}
|
|
3933
4031
|
};
|
|
3934
4032
|
}
|
|
3935
|
-
class
|
|
4033
|
+
class qn {
|
|
3936
4034
|
constructor(e) {
|
|
3937
4035
|
this.bindings = e;
|
|
3938
4036
|
}
|
|
3939
4037
|
bindings;
|
|
3940
|
-
async consume(e,
|
|
3941
|
-
const
|
|
3942
|
-
if (!
|
|
4038
|
+
async consume(e, n) {
|
|
4039
|
+
const s = this.bindings[e];
|
|
4040
|
+
if (!s)
|
|
3943
4041
|
return { allowed: !0 };
|
|
3944
4042
|
try {
|
|
3945
|
-
const { success: r } = await
|
|
4043
|
+
const { success: r } = await s.limit({ key: n });
|
|
3946
4044
|
return { allowed: r };
|
|
3947
4045
|
} catch (r) {
|
|
3948
4046
|
return console.error(
|
|
@@ -3952,13 +4050,13 @@ class $s {
|
|
|
3952
4050
|
}
|
|
3953
4051
|
}
|
|
3954
4052
|
}
|
|
3955
|
-
function
|
|
4053
|
+
function zn(t) {
|
|
3956
4054
|
if (!(!t || !Object.keys(t).some(
|
|
3957
|
-
(
|
|
4055
|
+
(n) => t[n]
|
|
3958
4056
|
)))
|
|
3959
|
-
return new
|
|
4057
|
+
return new qn(t);
|
|
3960
4058
|
}
|
|
3961
|
-
function
|
|
4059
|
+
function Wn(t) {
|
|
3962
4060
|
return `// Auto-generated AuthHero code hook worker
|
|
3963
4061
|
|
|
3964
4062
|
const fnNames = {
|
|
@@ -4064,21 +4162,21 @@ export default {
|
|
|
4064
4162
|
};
|
|
4065
4163
|
`;
|
|
4066
4164
|
}
|
|
4067
|
-
class
|
|
4165
|
+
class Jn {
|
|
4068
4166
|
config;
|
|
4069
4167
|
constructor(e) {
|
|
4070
4168
|
this.config = e;
|
|
4071
4169
|
}
|
|
4072
4170
|
async execute(e) {
|
|
4073
|
-
const
|
|
4171
|
+
const n = Date.now();
|
|
4074
4172
|
if (!e.hookCodeId)
|
|
4075
4173
|
return {
|
|
4076
4174
|
success: !1,
|
|
4077
4175
|
error: "DispatchNamespaceCodeExecutor requires hookCodeId",
|
|
4078
|
-
durationMs: Date.now() -
|
|
4176
|
+
durationMs: Date.now() - n,
|
|
4079
4177
|
apiCalls: []
|
|
4080
4178
|
};
|
|
4081
|
-
const
|
|
4179
|
+
const s = `hook-${e.hookCodeId}`, r = JSON.stringify({
|
|
4082
4180
|
triggerId: e.triggerId,
|
|
4083
4181
|
event: e.event
|
|
4084
4182
|
});
|
|
@@ -4086,7 +4184,7 @@ class Is {
|
|
|
4086
4184
|
let a;
|
|
4087
4185
|
if (this.config.dispatcher)
|
|
4088
4186
|
a = await this.config.dispatcher.get(
|
|
4089
|
-
|
|
4187
|
+
s,
|
|
4090
4188
|
{},
|
|
4091
4189
|
{ limits: { cpuMs: e.cpuLimitMs ?? 5e3 } }
|
|
4092
4190
|
).fetch(
|
|
@@ -4097,7 +4195,7 @@ class Is {
|
|
|
4097
4195
|
})
|
|
4098
4196
|
);
|
|
4099
4197
|
else if (this.config.dispatchUrl)
|
|
4100
|
-
a = await fetch(`${this.config.dispatchUrl}/${
|
|
4198
|
+
a = await fetch(`${this.config.dispatchUrl}/${s}`, {
|
|
4101
4199
|
method: "POST",
|
|
4102
4200
|
headers: {
|
|
4103
4201
|
"Content-Type": "application/json",
|
|
@@ -4109,7 +4207,7 @@ class Is {
|
|
|
4109
4207
|
return {
|
|
4110
4208
|
success: !1,
|
|
4111
4209
|
error: "No dispatcher binding or dispatchUrl configured",
|
|
4112
|
-
durationMs: Date.now() -
|
|
4210
|
+
durationMs: Date.now() - n,
|
|
4113
4211
|
apiCalls: []
|
|
4114
4212
|
};
|
|
4115
4213
|
if (!a.ok) {
|
|
@@ -4117,19 +4215,19 @@ class Is {
|
|
|
4117
4215
|
return {
|
|
4118
4216
|
success: !1,
|
|
4119
4217
|
error: `Worker invocation failed (${a.status}): ${o}`,
|
|
4120
|
-
durationMs: Date.now() -
|
|
4218
|
+
durationMs: Date.now() - n,
|
|
4121
4219
|
apiCalls: []
|
|
4122
4220
|
};
|
|
4123
4221
|
}
|
|
4124
4222
|
return {
|
|
4125
4223
|
...await a.json(),
|
|
4126
|
-
durationMs: Date.now() -
|
|
4224
|
+
durationMs: Date.now() - n
|
|
4127
4225
|
};
|
|
4128
4226
|
} catch (a) {
|
|
4129
4227
|
return {
|
|
4130
4228
|
success: !1,
|
|
4131
4229
|
error: a instanceof Error ? a.message : String(a),
|
|
4132
|
-
durationMs: Date.now() -
|
|
4230
|
+
durationMs: Date.now() - n,
|
|
4133
4231
|
apiCalls: []
|
|
4134
4232
|
};
|
|
4135
4233
|
}
|
|
@@ -4138,8 +4236,8 @@ class Is {
|
|
|
4138
4236
|
* Deploy user code as a worker to the dispatch namespace.
|
|
4139
4237
|
* Wraps the code in a worker template and uploads via Cloudflare API.
|
|
4140
4238
|
*/
|
|
4141
|
-
async deploy(e,
|
|
4142
|
-
const
|
|
4239
|
+
async deploy(e, n) {
|
|
4240
|
+
const s = `hook-${e}`, r = Wn(n), a = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`, i = JSON.stringify({
|
|
4143
4241
|
main_module: "index.js",
|
|
4144
4242
|
compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
|
|
4145
4243
|
}), o = new FormData();
|
|
@@ -4161,7 +4259,7 @@ class Is {
|
|
|
4161
4259
|
if (!c.ok) {
|
|
4162
4260
|
const d = await c.text();
|
|
4163
4261
|
throw new Error(
|
|
4164
|
-
`Failed to deploy hook worker ${
|
|
4262
|
+
`Failed to deploy hook worker ${s}: ${c.status} ${d}`
|
|
4165
4263
|
);
|
|
4166
4264
|
}
|
|
4167
4265
|
}
|
|
@@ -4169,7 +4267,7 @@ class Is {
|
|
|
4169
4267
|
* Remove a user worker from the dispatch namespace.
|
|
4170
4268
|
*/
|
|
4171
4269
|
async remove(e) {
|
|
4172
|
-
const
|
|
4270
|
+
const n = `hook-${e}`, s = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`, r = await fetch(s, {
|
|
4173
4271
|
method: "DELETE",
|
|
4174
4272
|
headers: {
|
|
4175
4273
|
Authorization: `Bearer ${this.config.apiToken}`
|
|
@@ -4178,17 +4276,17 @@ class Is {
|
|
|
4178
4276
|
if (!r.ok && r.status !== 404) {
|
|
4179
4277
|
const a = await r.text();
|
|
4180
4278
|
throw new Error(
|
|
4181
|
-
`Failed to remove hook worker ${
|
|
4279
|
+
`Failed to remove hook worker ${n}: ${r.status} ${a}`
|
|
4182
4280
|
);
|
|
4183
4281
|
}
|
|
4184
4282
|
}
|
|
4185
4283
|
}
|
|
4186
|
-
const
|
|
4284
|
+
const ns = Jn, Hn = {
|
|
4187
4285
|
"post-user-login": "onExecutePostLogin",
|
|
4188
4286
|
"credentials-exchange": "onExecuteCredentialsExchange",
|
|
4189
4287
|
"pre-user-registration": "onExecutePreUserRegistration",
|
|
4190
4288
|
"post-user-registration": "onExecutePostUserRegistration"
|
|
4191
|
-
},
|
|
4289
|
+
}, Qn = {
|
|
4192
4290
|
"post-user-login": {
|
|
4193
4291
|
accessToken: ["setCustomClaim"],
|
|
4194
4292
|
idToken: ["setCustomClaim"],
|
|
@@ -4207,17 +4305,17 @@ const Fs = Is, js = {
|
|
|
4207
4305
|
},
|
|
4208
4306
|
"post-user-registration": {}
|
|
4209
4307
|
};
|
|
4210
|
-
async function
|
|
4211
|
-
const e = new TextEncoder().encode(t),
|
|
4308
|
+
async function Yn(t) {
|
|
4309
|
+
const e = new TextEncoder().encode(t), n = await crypto.subtle.digest("SHA-256", e), s = new Uint8Array(n);
|
|
4212
4310
|
let r = "";
|
|
4213
|
-
for (const a of
|
|
4311
|
+
for (const a of s)
|
|
4214
4312
|
r += a.toString(16).padStart(2, "0");
|
|
4215
4313
|
return r;
|
|
4216
4314
|
}
|
|
4217
|
-
function
|
|
4315
|
+
function Gn(t) {
|
|
4218
4316
|
return `
|
|
4219
|
-
const TRIGGER_FN_NAMES = ${JSON.stringify(
|
|
4220
|
-
const API_SHAPES = ${JSON.stringify(
|
|
4317
|
+
const TRIGGER_FN_NAMES = ${JSON.stringify(Hn)};
|
|
4318
|
+
const API_SHAPES = ${JSON.stringify(Qn)};
|
|
4221
4319
|
const MAX_LOG_ENTRIES = 50;
|
|
4222
4320
|
const MAX_LOG_LENGTH = 500;
|
|
4223
4321
|
|
|
@@ -4317,20 +4415,20 @@ export default {
|
|
|
4317
4415
|
};
|
|
4318
4416
|
`;
|
|
4319
4417
|
}
|
|
4320
|
-
class
|
|
4418
|
+
class ss {
|
|
4321
4419
|
loader;
|
|
4322
4420
|
compatibilityDate;
|
|
4323
4421
|
constructor(e) {
|
|
4324
4422
|
this.loader = e.loader, this.compatibilityDate = e.compatibilityDate || "2025-01-01";
|
|
4325
4423
|
}
|
|
4326
4424
|
async execute(e) {
|
|
4327
|
-
const
|
|
4425
|
+
const n = Date.now();
|
|
4328
4426
|
try {
|
|
4329
|
-
const
|
|
4427
|
+
const s = Gn(e.code), r = {
|
|
4330
4428
|
compatibilityDate: this.compatibilityDate,
|
|
4331
4429
|
mainModule: "hook.js",
|
|
4332
|
-
modules: { "hook.js":
|
|
4333
|
-
}, a = e.hookCodeId ? `${e.hookCodeId}-${await
|
|
4430
|
+
modules: { "hook.js": s }
|
|
4431
|
+
}, a = e.hookCodeId ? `${e.hookCodeId}-${await Yn(e.code)}` : null;
|
|
4334
4432
|
return await (await (a ? this.loader.get(a, async () => r) : this.loader.load(r)).getEntrypoint().fetch(
|
|
4335
4433
|
new Request("https://hook/execute", {
|
|
4336
4434
|
method: "POST",
|
|
@@ -4341,21 +4439,21 @@ class Vs {
|
|
|
4341
4439
|
})
|
|
4342
4440
|
})
|
|
4343
4441
|
)).json();
|
|
4344
|
-
} catch (
|
|
4442
|
+
} catch (s) {
|
|
4345
4443
|
return {
|
|
4346
4444
|
success: !1,
|
|
4347
|
-
error:
|
|
4348
|
-
durationMs: Date.now() -
|
|
4445
|
+
error: s instanceof Error ? s.message : String(s),
|
|
4446
|
+
durationMs: Date.now() - n,
|
|
4349
4447
|
apiCalls: []
|
|
4350
4448
|
};
|
|
4351
4449
|
}
|
|
4352
4450
|
}
|
|
4353
4451
|
}
|
|
4354
|
-
function
|
|
4452
|
+
function rs(t) {
|
|
4355
4453
|
const e = {
|
|
4356
|
-
customDomains:
|
|
4454
|
+
customDomains: an(t),
|
|
4357
4455
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
4358
|
-
cache:
|
|
4456
|
+
cache: cn({
|
|
4359
4457
|
...t.cacheName && { cacheName: t.cacheName },
|
|
4360
4458
|
...t.defaultTtlSeconds !== void 0 && {
|
|
4361
4459
|
defaultTtlSeconds: t.defaultTtlSeconds
|
|
@@ -4364,26 +4462,29 @@ function qs(t) {
|
|
|
4364
4462
|
}),
|
|
4365
4463
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
4366
4464
|
// passed at request time via getGeoInfo(headers)
|
|
4367
|
-
geo:
|
|
4465
|
+
geo: Vn()
|
|
4368
4466
|
};
|
|
4369
|
-
t.r2SqlLogs ? e.logs =
|
|
4467
|
+
t.r2SqlLogs ? e.logs = yn(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = jn(
|
|
4370
4468
|
t.analyticsEngineLogs
|
|
4371
|
-
)), t.analyticsEngineLogs && (e.analytics =
|
|
4469
|
+
)), t.analyticsEngineLogs && (e.analytics = In(
|
|
4372
4470
|
t.analyticsEngineLogs
|
|
4471
|
+
)), t.analyticsEngineActionExecutions && (e.actionExecutions = Fn(
|
|
4472
|
+
t.analyticsEngineActionExecutions
|
|
4373
4473
|
));
|
|
4374
|
-
const
|
|
4375
|
-
return
|
|
4474
|
+
const n = zn(t.rateLimitBindings);
|
|
4475
|
+
return n && (e.rateLimit = n), e;
|
|
4376
4476
|
}
|
|
4377
4477
|
export {
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4478
|
+
ns as CloudflareCodeExecutor,
|
|
4479
|
+
Jn as DispatchNamespaceCodeExecutor,
|
|
4480
|
+
ss as WorkerLoaderCodeExecutor,
|
|
4481
|
+
Fn as createAnalyticsEngineActionExecutionsAdapter,
|
|
4482
|
+
In as createAnalyticsEngineAnalyticsAdapter,
|
|
4483
|
+
jn as createAnalyticsEngineLogsAdapter,
|
|
4484
|
+
ts as createAnalyticsEngineStatsAdapter,
|
|
4485
|
+
zn as createCloudflareRateLimitAdapter,
|
|
4486
|
+
yn as createR2SQLLogsAdapter,
|
|
4487
|
+
es as createR2SQLStatsAdapter,
|
|
4488
|
+
rs as default,
|
|
4489
|
+
Wn as generateWorkerScript
|
|
4389
4490
|
};
|