@authhero/cloudflare-adapter 2.22.4 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/cloudflare-adapter.cjs +15 -19
- package/dist/cloudflare-adapter.mjs +780 -784
- package/package.json +2 -2
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { verificationMethodsSchema as ft } from "@authhero/adapter-interfaces";
|
|
2
2
|
import pt from "wretch";
|
|
3
3
|
function mt(t, e) {
|
|
4
|
-
var
|
|
5
|
-
for (var
|
|
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
11
|
function yt(t, e) {
|
|
12
|
-
var
|
|
13
|
-
return ((
|
|
12
|
+
var n;
|
|
13
|
+
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
14
|
}
|
|
15
15
|
function ae(t, e) {
|
|
16
|
-
const
|
|
17
|
-
t.ZodType.prototype[e] = function(...
|
|
18
|
-
const r =
|
|
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
|
}
|
|
@@ -50,14 +50,14 @@ function _t(t) {
|
|
|
50
50
|
c._def.openapi = (p = (u = r[o]) === null || u === void 0 ? void 0 : u._def) === null || p === void 0 ? void 0 : p.openapi;
|
|
51
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
|
}
|
|
@@ -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,16 +119,16 @@ 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
127
|
var $e;
|
|
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
|
})($e || ($e = {}));
|
|
@@ -197,18 +197,18 @@ class Z extends Error {
|
|
|
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,16 +217,16 @@ class Z 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 u = i.path[c];
|
|
225
|
-
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(
|
|
225
|
+
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(n(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
return r(this),
|
|
229
|
+
return r(this), s;
|
|
230
230
|
}
|
|
231
231
|
static assert(e) {
|
|
232
232
|
if (!(e instanceof Z))
|
|
@@ -241,15 +241,15 @@ class Z 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();
|
|
@@ -257,67 +257,67 @@ class Z extends Error {
|
|
|
257
257
|
}
|
|
258
258
|
Z.create = (t) => new Z(t);
|
|
259
259
|
const pe = (t, e) => {
|
|
260
|
-
let
|
|
260
|
+
let n;
|
|
261
261
|
switch (t.code) {
|
|
262
262
|
case d.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 d.invalid_literal:
|
|
266
|
-
|
|
266
|
+
n = `Invalid literal value, expected ${JSON.stringify(t.expected, b.jsonStringifyReplacer)}`;
|
|
267
267
|
break;
|
|
268
268
|
case d.unrecognized_keys:
|
|
269
|
-
|
|
269
|
+
n = `Unrecognized key(s) in object: ${b.joinValues(t.keys, ", ")}`;
|
|
270
270
|
break;
|
|
271
271
|
case d.invalid_union:
|
|
272
|
-
|
|
272
|
+
n = "Invalid input";
|
|
273
273
|
break;
|
|
274
274
|
case d.invalid_union_discriminator:
|
|
275
|
-
|
|
275
|
+
n = `Invalid discriminator value. Expected ${b.joinValues(t.options)}`;
|
|
276
276
|
break;
|
|
277
277
|
case d.invalid_enum_value:
|
|
278
|
-
|
|
278
|
+
n = `Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;
|
|
279
279
|
break;
|
|
280
280
|
case d.invalid_arguments:
|
|
281
|
-
|
|
281
|
+
n = "Invalid function arguments";
|
|
282
282
|
break;
|
|
283
283
|
case d.invalid_return_type:
|
|
284
|
-
|
|
284
|
+
n = "Invalid function return type";
|
|
285
285
|
break;
|
|
286
286
|
case d.invalid_date:
|
|
287
|
-
|
|
287
|
+
n = "Invalid date";
|
|
288
288
|
break;
|
|
289
289
|
case d.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 d.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 d.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 d.custom:
|
|
299
|
-
|
|
299
|
+
n = "Invalid input";
|
|
300
300
|
break;
|
|
301
301
|
case d.invalid_intersection_types:
|
|
302
|
-
|
|
302
|
+
n = "Intersection results could not be merged";
|
|
303
303
|
break;
|
|
304
304
|
case d.not_multiple_of:
|
|
305
|
-
|
|
305
|
+
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
306
306
|
break;
|
|
307
307
|
case d.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
315
|
let gt = pe;
|
|
316
316
|
function Xe() {
|
|
317
317
|
return gt;
|
|
318
318
|
}
|
|
319
319
|
const et = (t) => {
|
|
320
|
-
const { data: e, path:
|
|
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((u) => !!u).slice().reverse();
|
|
332
332
|
for (const u of c)
|
|
333
333
|
o = u(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 = Xe(), s = et({
|
|
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 === pe ? void 0 : pe
|
|
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 T {
|
|
359
359
|
constructor() {
|
|
@@ -365,35 +365,35 @@ class T {
|
|
|
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 T.mergeObjectSync(e,
|
|
386
|
+
return T.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({
|
|
@@ -404,8 +404,8 @@ var f;
|
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
405
|
})(f || (f = {}));
|
|
406
406
|
class D {
|
|
407
|
-
constructor(e,
|
|
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;
|
|
@@ -421,20 +421,20 @@ const He = (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 Z(t.common.issues);
|
|
425
|
+
return this._error = n, this._error;
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
};
|
|
429
429
|
function g(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 P(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: P(e.data),
|
|
@@ -468,38 +468,38 @@ class v {
|
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
_parseSync(e) {
|
|
471
|
-
const
|
|
472
|
-
if (oe(
|
|
471
|
+
const n = this._parse(e);
|
|
472
|
+
if (oe(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: P(e)
|
|
498
|
-
}, r = this._parseSync({ data: e, path:
|
|
499
|
-
return He(
|
|
498
|
+
}, r = this._parseSync({ data: e, path: s.path, parent: s });
|
|
499
|
+
return He(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,57 +512,57 @@ class v {
|
|
|
512
512
|
};
|
|
513
513
|
if (!this["~standard"].async)
|
|
514
514
|
try {
|
|
515
|
-
const
|
|
516
|
-
return Q(
|
|
517
|
-
value:
|
|
515
|
+
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
516
|
+
return Q(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) => Q(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: P(e)
|
|
551
|
-
}, r = this._parse({ data: e, path:
|
|
552
|
-
return He(
|
|
551
|
+
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (oe(r) ? r : Promise.resolve(r));
|
|
552
|
+
return He(s, a);
|
|
553
553
|
}
|
|
554
|
-
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: d.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
568
|
return new F({
|
|
@@ -578,7 +578,7 @@ 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() {
|
|
@@ -611,11 +611,11 @@ class v {
|
|
|
611
611
|
});
|
|
612
612
|
}
|
|
613
613
|
default(e) {
|
|
614
|
-
const
|
|
614
|
+
const n = typeof e == "function" ? e : () => e;
|
|
615
615
|
return new ye({
|
|
616
616
|
...g(this._def),
|
|
617
617
|
innerType: this,
|
|
618
|
-
defaultValue:
|
|
618
|
+
defaultValue: n,
|
|
619
619
|
typeName: m.ZodDefault
|
|
620
620
|
});
|
|
621
621
|
}
|
|
@@ -627,17 +627,17 @@ class v {
|
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
629
|
catch(e) {
|
|
630
|
-
const
|
|
630
|
+
const n = typeof e == "function" ? e : () => e;
|
|
631
631
|
return new _e({
|
|
632
632
|
...g(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
|
});
|
|
@@ -658,19 +658,19 @@ class v {
|
|
|
658
658
|
const vt = /^c[^\s-]{8,}$/i, bt = /^[0-9a-z]+$/, xt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, wt = /^[a-z0-9_-]{21}$/i, St = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ct = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Tt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Et = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
659
659
|
let Ae;
|
|
660
660
|
const Ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, At = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Nt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, $t = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Rt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, jt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, tt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", It = new RegExp(`^${tt}$`);
|
|
661
|
-
function
|
|
661
|
+
function nt(t) {
|
|
662
662
|
let e = "[0-5]\\d";
|
|
663
663
|
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
664
|
-
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
667
|
function Zt(t) {
|
|
668
|
-
return new RegExp(`^${
|
|
668
|
+
return new RegExp(`^${nt(t)}$`);
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
let e = `${tt}T${
|
|
672
|
-
const
|
|
673
|
-
return
|
|
670
|
+
function st(t) {
|
|
671
|
+
let e = `${tt}T${nt(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
675
|
function Dt(t, e) {
|
|
676
676
|
return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && Nt.test(t));
|
|
@@ -679,10 +679,10 @@ function Lt(t, e) {
|
|
|
679
679
|
if (!St.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;
|
|
@@ -701,7 +701,7 @@ class I extends v {
|
|
|
701
701
|
received: a.parsedType
|
|
702
702
|
}), y;
|
|
703
703
|
}
|
|
704
|
-
const
|
|
704
|
+
const s = new T();
|
|
705
705
|
let r;
|
|
706
706
|
for (const a of this._def.checks)
|
|
707
707
|
if (a.kind === "min")
|
|
@@ -712,7 +712,7 @@ class I 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: d.too_big,
|
|
@@ -721,7 +721,7 @@ class I 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 I 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
|
Tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
744
744
|
validation: "email",
|
|
745
745
|
code: d.invalid_string,
|
|
746
746
|
message: a.message
|
|
747
|
-
}),
|
|
747
|
+
}), s.dirty());
|
|
748
748
|
else if (a.kind === "emoji")
|
|
749
749
|
Ae || (Ae = new RegExp(Et, "u")), Ae.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
750
750
|
validation: "emoji",
|
|
751
751
|
code: d.invalid_string,
|
|
752
752
|
message: a.message
|
|
753
|
-
}),
|
|
753
|
+
}), s.dirty());
|
|
754
754
|
else if (a.kind === "uuid")
|
|
755
755
|
kt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
756
756
|
validation: "uuid",
|
|
757
757
|
code: d.invalid_string,
|
|
758
758
|
message: a.message
|
|
759
|
-
}),
|
|
759
|
+
}), s.dirty());
|
|
760
760
|
else if (a.kind === "nanoid")
|
|
761
761
|
wt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
762
762
|
validation: "nanoid",
|
|
763
763
|
code: d.invalid_string,
|
|
764
764
|
message: a.message
|
|
765
|
-
}),
|
|
765
|
+
}), s.dirty());
|
|
766
766
|
else if (a.kind === "cuid")
|
|
767
767
|
vt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
768
768
|
validation: "cuid",
|
|
769
769
|
code: d.invalid_string,
|
|
770
770
|
message: a.message
|
|
771
|
-
}),
|
|
771
|
+
}), s.dirty());
|
|
772
772
|
else if (a.kind === "cuid2")
|
|
773
773
|
bt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
774
774
|
validation: "cuid2",
|
|
775
775
|
code: d.invalid_string,
|
|
776
776
|
message: a.message
|
|
777
|
-
}),
|
|
777
|
+
}), s.dirty());
|
|
778
778
|
else if (a.kind === "ulid")
|
|
779
779
|
xt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
780
780
|
validation: "ulid",
|
|
781
781
|
code: d.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,68 +789,68 @@ class I extends v {
|
|
|
789
789
|
validation: "url",
|
|
790
790
|
code: d.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: d.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: d.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: d.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: d.invalid_string,
|
|
808
808
|
validation: { endsWith: a.value },
|
|
809
809
|
message: a.message
|
|
810
|
-
}),
|
|
810
|
+
}), s.dirty()) : a.kind === "datetime" ? st(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
811
811
|
code: d.invalid_string,
|
|
812
812
|
validation: "datetime",
|
|
813
813
|
message: a.message
|
|
814
|
-
}),
|
|
814
|
+
}), s.dirty()) : a.kind === "date" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
815
815
|
code: d.invalid_string,
|
|
816
816
|
validation: "date",
|
|
817
817
|
message: a.message
|
|
818
|
-
}),
|
|
818
|
+
}), s.dirty()) : a.kind === "time" ? Zt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
819
819
|
code: d.invalid_string,
|
|
820
820
|
validation: "time",
|
|
821
821
|
message: a.message
|
|
822
|
-
}),
|
|
822
|
+
}), s.dirty()) : a.kind === "duration" ? Ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
823
823
|
validation: "duration",
|
|
824
824
|
code: d.invalid_string,
|
|
825
825
|
message: a.message
|
|
826
|
-
}),
|
|
826
|
+
}), s.dirty()) : a.kind === "ip" ? Dt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
827
827
|
validation: "ip",
|
|
828
828
|
code: d.invalid_string,
|
|
829
829
|
message: a.message
|
|
830
|
-
}),
|
|
830
|
+
}), s.dirty()) : a.kind === "jwt" ? Lt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
831
831
|
validation: "jwt",
|
|
832
832
|
code: d.invalid_string,
|
|
833
833
|
message: a.message
|
|
834
|
-
}),
|
|
834
|
+
}), s.dirty()) : a.kind === "cidr" ? Pt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
835
835
|
validation: "cidr",
|
|
836
836
|
code: d.invalid_string,
|
|
837
837
|
message: a.message
|
|
838
|
-
}),
|
|
838
|
+
}), s.dirty()) : a.kind === "base64" ? Rt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
839
839
|
validation: "base64",
|
|
840
840
|
code: d.invalid_string,
|
|
841
841
|
message: a.message
|
|
842
|
-
}),
|
|
842
|
+
}), s.dirty()) : a.kind === "base64url" ? jt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
843
843
|
validation: "base64url",
|
|
844
844
|
code: d.invalid_string,
|
|
845
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: d.invalid_string,
|
|
853
|
-
...f.errToObj(
|
|
853
|
+
...f.errToObj(s)
|
|
854
854
|
});
|
|
855
855
|
}
|
|
856
856
|
_addCheck(e) {
|
|
@@ -933,54 +933,54 @@ class I extends v {
|
|
|
933
933
|
duration(e) {
|
|
934
934
|
return this._addCheck({ kind: "duration", ...f.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
|
-
...f.errToObj(
|
|
940
|
+
...f.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
|
-
...f.errToObj(
|
|
947
|
+
position: n?.position,
|
|
948
|
+
...f.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
|
-
...f.errToObj(
|
|
955
|
+
...f.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
|
-
...f.errToObj(
|
|
962
|
+
...f.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
|
-
...f.errToObj(
|
|
969
|
+
...f.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
|
-
...f.errToObj(
|
|
976
|
+
...f.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
|
-
...f.errToObj(
|
|
983
|
+
...f.errToObj(n)
|
|
984
984
|
});
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
@@ -1057,14 +1057,14 @@ class I 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
|
}
|
|
@@ -1075,7 +1075,7 @@ I.create = (t) => new I({
|
|
|
1075
1075
|
...g(t)
|
|
1076
1076
|
});
|
|
1077
1077
|
function Mt(t, e) {
|
|
1078
|
-
const
|
|
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
1081
|
class Y extends v {
|
|
@@ -1091,59 +1091,59 @@ class Y extends v {
|
|
|
1091
1091
|
received: a.parsedType
|
|
1092
1092
|
}), y;
|
|
1093
1093
|
}
|
|
1094
|
-
let
|
|
1094
|
+
let s;
|
|
1095
1095
|
const r = new T();
|
|
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: d.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: d.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: d.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" ? Mt(e.data, a.value) !== 0 && (
|
|
1116
|
+
}), r.dirty()) : a.kind === "multipleOf" ? Mt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1117
1117
|
code: d.not_multiple_of,
|
|
1118
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: d.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, f.toString(
|
|
1126
|
+
gte(e, n) {
|
|
1127
|
+
return this.setLimit("min", e, !0, f.toString(n));
|
|
1128
1128
|
}
|
|
1129
|
-
gt(e,
|
|
1130
|
-
return this.setLimit("min", e, !1, f.toString(
|
|
1129
|
+
gt(e, n) {
|
|
1130
|
+
return this.setLimit("min", e, !1, f.toString(n));
|
|
1131
1131
|
}
|
|
1132
|
-
lte(e,
|
|
1133
|
-
return this.setLimit("max", e, !0, f.toString(
|
|
1132
|
+
lte(e, n) {
|
|
1133
|
+
return this.setLimit("max", e, !0, f.toString(n));
|
|
1134
1134
|
}
|
|
1135
|
-
lt(e,
|
|
1136
|
-
return this.setLimit("max", e, !1, f.toString(
|
|
1135
|
+
lt(e, n) {
|
|
1136
|
+
return this.setLimit("max", e, !1, f.toString(n));
|
|
1137
1137
|
}
|
|
1138
|
-
setLimit(e,
|
|
1138
|
+
setLimit(e, n, s, r) {
|
|
1139
1139
|
return new Y({
|
|
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: f.toString(r)
|
|
1148
1148
|
}
|
|
1149
1149
|
]
|
|
@@ -1193,11 +1193,11 @@ class Y extends v {
|
|
|
1193
1193
|
message: f.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: f.toString(
|
|
1200
|
+
message: f.toString(n)
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
1203
|
finite(e) {
|
|
@@ -1221,27 +1221,27 @@ class Y 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
|
Y.create = (t) => new Y({
|
|
@@ -1250,7 +1250,7 @@ Y.create = (t) => new Y({
|
|
|
1250
1250
|
coerce: t?.coerce || !1,
|
|
1251
1251
|
...g(t)
|
|
1252
1252
|
});
|
|
1253
|
-
class
|
|
1253
|
+
class ne extends v {
|
|
1254
1254
|
constructor() {
|
|
1255
1255
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1256
1256
|
}
|
|
@@ -1263,22 +1263,22 @@ class se 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 T();
|
|
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: d.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: d.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: d.not_multiple_of,
|
|
1283
1283
|
multipleOf: a.value,
|
|
1284
1284
|
message: a.message
|
|
@@ -1286,41 +1286,41 @@ class se 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: d.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, f.toString(
|
|
1296
|
+
gte(e, n) {
|
|
1297
|
+
return this.setLimit("min", e, !0, f.toString(n));
|
|
1298
1298
|
}
|
|
1299
|
-
gt(e,
|
|
1300
|
-
return this.setLimit("min", e, !1, f.toString(
|
|
1299
|
+
gt(e, n) {
|
|
1300
|
+
return this.setLimit("min", e, !1, f.toString(n));
|
|
1301
1301
|
}
|
|
1302
|
-
lte(e,
|
|
1303
|
-
return this.setLimit("max", e, !0, f.toString(
|
|
1302
|
+
lte(e, n) {
|
|
1303
|
+
return this.setLimit("max", e, !0, f.toString(n));
|
|
1304
1304
|
}
|
|
1305
|
-
lt(e,
|
|
1306
|
-
return this.setLimit("max", e, !1, f.toString(
|
|
1305
|
+
lt(e, n) {
|
|
1306
|
+
return this.setLimit("max", e, !1, f.toString(n));
|
|
1307
1307
|
}
|
|
1308
|
-
setLimit(e,
|
|
1309
|
-
return new
|
|
1308
|
+
setLimit(e, n, s, r) {
|
|
1309
|
+
return new ne({
|
|
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: f.toString(r)
|
|
1318
1318
|
}
|
|
1319
1319
|
]
|
|
1320
1320
|
});
|
|
1321
1321
|
}
|
|
1322
1322
|
_addCheck(e) {
|
|
1323
|
-
return new
|
|
1323
|
+
return new ne({
|
|
1324
1324
|
...this._def,
|
|
1325
1325
|
checks: [...this._def.checks, e]
|
|
1326
1326
|
});
|
|
@@ -1357,27 +1357,27 @@ class se extends v {
|
|
|
1357
1357
|
message: f.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: f.toString(
|
|
1364
|
+
message: f.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
|
+
ne.create = (t) => new ne({
|
|
1381
1381
|
checks: [],
|
|
1382
1382
|
typeName: m.ZodBigInt,
|
|
1383
1383
|
coerce: t?.coerce ?? !1,
|
|
@@ -1386,11 +1386,11 @@ se.create = (t) => new se({
|
|
|
1386
1386
|
class me 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: d.invalid_type,
|
|
1392
1392
|
expected: h.boolean,
|
|
1393
|
-
received:
|
|
1393
|
+
received: s.parsedType
|
|
1394
1394
|
}), y;
|
|
1395
1395
|
}
|
|
1396
1396
|
return N(e.data);
|
|
@@ -1417,7 +1417,7 @@ class ce extends v {
|
|
|
1417
1417
|
code: d.invalid_date
|
|
1418
1418
|
}), y;
|
|
1419
1419
|
}
|
|
1420
|
-
const
|
|
1420
|
+
const s = new T();
|
|
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,16 +1427,16 @@ class ce 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: d.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
|
}
|
|
@@ -1446,30 +1446,30 @@ class ce extends v {
|
|
|
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: f.toString(
|
|
1453
|
+
message: f.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: f.toString(
|
|
1460
|
+
message: f.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
|
}
|
|
@@ -1482,11 +1482,11 @@ ce.create = (t) => new ce({
|
|
|
1482
1482
|
class Ie 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: d.invalid_type,
|
|
1488
1488
|
expected: h.symbol,
|
|
1489
|
-
received:
|
|
1489
|
+
received: s.parsedType
|
|
1490
1490
|
}), y;
|
|
1491
1491
|
}
|
|
1492
1492
|
return N(e.data);
|
|
@@ -1499,11 +1499,11 @@ Ie.create = (t) => new Ie({
|
|
|
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: d.invalid_type,
|
|
1505
1505
|
expected: h.undefined,
|
|
1506
|
-
received:
|
|
1506
|
+
received: s.parsedType
|
|
1507
1507
|
}), y;
|
|
1508
1508
|
}
|
|
1509
1509
|
return N(e.data);
|
|
@@ -1516,11 +1516,11 @@ Ze.create = (t) => new Ze({
|
|
|
1516
1516
|
class De 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: d.invalid_type,
|
|
1522
1522
|
expected: h.null,
|
|
1523
|
-
received:
|
|
1523
|
+
received: s.parsedType
|
|
1524
1524
|
}), y;
|
|
1525
1525
|
}
|
|
1526
1526
|
return N(e.data);
|
|
@@ -1556,11 +1556,11 @@ Pe.create = (t) => new Pe({
|
|
|
1556
1556
|
});
|
|
1557
1557
|
class V extends v {
|
|
1558
1558
|
_parse(e) {
|
|
1559
|
-
const
|
|
1560
|
-
return l(
|
|
1559
|
+
const n = this._getOrReturnCtx(e);
|
|
1560
|
+
return l(n, {
|
|
1561
1561
|
code: d.invalid_type,
|
|
1562
1562
|
expected: h.never,
|
|
1563
|
-
received:
|
|
1563
|
+
received: n.parsedType
|
|
1564
1564
|
}), y;
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
@@ -1571,11 +1571,11 @@ V.create = (t) => new V({
|
|
|
1571
1571
|
class Me 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: d.invalid_type,
|
|
1577
1577
|
expected: h.void,
|
|
1578
|
-
received:
|
|
1578
|
+
received: s.parsedType
|
|
1579
1579
|
}), y;
|
|
1580
1580
|
}
|
|
1581
1581
|
return N(e.data);
|
|
@@ -1587,16 +1587,16 @@ Me.create = (t) => new Me({
|
|
|
1587
1587
|
});
|
|
1588
1588
|
class $ 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: d.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 ? d.too_big : d.too_small,
|
|
1601
1601
|
minimum: o ? r.exactLength.value : void 0,
|
|
1602
1602
|
maximum: i ? r.exactLength.value : void 0,
|
|
@@ -1604,46 +1604,46 @@ class $ 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: d.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: d.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 T.mergeArray(
|
|
1623
|
+
}), s.dirty()), n.common.async)
|
|
1624
|
+
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new D(n, i, n.path, o)))).then((i) => T.mergeArray(s, i));
|
|
1625
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new D(n, i, n.path, o)));
|
|
1626
|
+
return T.mergeArray(s, a);
|
|
1627
1627
|
}
|
|
1628
1628
|
get element() {
|
|
1629
1629
|
return this._def.type;
|
|
1630
1630
|
}
|
|
1631
|
-
min(e,
|
|
1631
|
+
min(e, n) {
|
|
1632
1632
|
return new $({
|
|
1633
1633
|
...this._def,
|
|
1634
|
-
minLength: { value: e, message: f.toString(
|
|
1634
|
+
minLength: { value: e, message: f.toString(n) }
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
|
-
max(e,
|
|
1637
|
+
max(e, n) {
|
|
1638
1638
|
return new $({
|
|
1639
1639
|
...this._def,
|
|
1640
|
-
maxLength: { value: e, message: f.toString(
|
|
1640
|
+
maxLength: { value: e, message: f.toString(n) }
|
|
1641
1641
|
});
|
|
1642
1642
|
}
|
|
1643
|
-
length(e,
|
|
1643
|
+
length(e, n) {
|
|
1644
1644
|
return new $({
|
|
1645
1645
|
...this._def,
|
|
1646
|
-
exactLength: { value: e, message: f.toString(
|
|
1646
|
+
exactLength: { value: e, message: f.toString(n) }
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
1649
|
nonempty(e) {
|
|
@@ -1661,9 +1661,9 @@ $.create = (t, e) => new $({
|
|
|
1661
1661
|
function ee(t) {
|
|
1662
1662
|
if (t instanceof w) {
|
|
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] = B.create(ee(s));
|
|
1667
1667
|
}
|
|
1668
1668
|
return new w({
|
|
1669
1669
|
...t._def,
|
|
@@ -1681,8 +1681,8 @@ class w extends v {
|
|
|
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 w extends v {
|
|
|
1693
1693
|
received: u.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 V && this._def.unknownKeys === "strip"))
|
|
1698
1698
|
for (const u in r.data)
|
|
1699
1699
|
i.includes(u) || o.push(u);
|
|
@@ -1718,7 +1718,7 @@ class w extends v {
|
|
|
1718
1718
|
o.length > 0 && (l(r, {
|
|
1719
1719
|
code: d.unrecognized_keys,
|
|
1720
1720
|
keys: o
|
|
1721
|
-
}),
|
|
1721
|
+
}), s.dirty());
|
|
1722
1722
|
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1723
1723
|
} else {
|
|
1724
1724
|
const u = this._def.catchall;
|
|
@@ -1745,7 +1745,7 @@ class w extends v {
|
|
|
1745
1745
|
});
|
|
1746
1746
|
}
|
|
1747
1747
|
return u;
|
|
1748
|
-
}).then((u) => T.mergeObjectSync(
|
|
1748
|
+
}).then((u) => T.mergeObjectSync(s, u)) : T.mergeObjectSync(s, c);
|
|
1749
1749
|
}
|
|
1750
1750
|
get shape() {
|
|
1751
1751
|
return this._def.shape();
|
|
@@ -1755,9 +1755,9 @@ class w extends v {
|
|
|
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: f.errToObj(e).message ?? r
|
|
1762
1762
|
} : {
|
|
1763
1763
|
message: r
|
|
@@ -1855,8 +1855,8 @@ class w 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
|
|
@@ -1886,21 +1886,21 @@ class w extends v {
|
|
|
1886
1886
|
});
|
|
1887
1887
|
}
|
|
1888
1888
|
pick(e) {
|
|
1889
|
-
const
|
|
1890
|
-
for (const
|
|
1891
|
-
e[
|
|
1889
|
+
const n = {};
|
|
1890
|
+
for (const s of b.objectKeys(e))
|
|
1891
|
+
e[s] && this.shape[s] && (n[s] = this.shape[s]);
|
|
1892
1892
|
return new w({
|
|
1893
1893
|
...this._def,
|
|
1894
|
-
shape: () =>
|
|
1894
|
+
shape: () => n
|
|
1895
1895
|
});
|
|
1896
1896
|
}
|
|
1897
1897
|
omit(e) {
|
|
1898
|
-
const
|
|
1899
|
-
for (const
|
|
1900
|
-
e[
|
|
1898
|
+
const n = {};
|
|
1899
|
+
for (const s of b.objectKeys(this.shape))
|
|
1900
|
+
e[s] || (n[s] = this.shape[s]);
|
|
1901
1901
|
return new w({
|
|
1902
1902
|
...this._def,
|
|
1903
|
-
shape: () =>
|
|
1903
|
+
shape: () => n
|
|
1904
1904
|
});
|
|
1905
1905
|
}
|
|
1906
1906
|
/**
|
|
@@ -1910,30 +1910,30 @@ class w extends v {
|
|
|
1910
1910
|
return ee(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
1918
|
return new w({
|
|
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 B; )
|
|
1931
1931
|
a = a._def.innerType;
|
|
1932
|
-
s
|
|
1932
|
+
n[s] = a;
|
|
1933
1933
|
}
|
|
1934
1934
|
return new w({
|
|
1935
1935
|
...this._def,
|
|
1936
|
-
shape: () =>
|
|
1936
|
+
shape: () => n
|
|
1937
1937
|
});
|
|
1938
1938
|
}
|
|
1939
1939
|
keyof() {
|
|
@@ -1963,34 +1963,34 @@ w.lazycreate = (t, e) => new w({
|
|
|
1963
1963
|
});
|
|
1964
1964
|
class de 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
|
|
1973
|
+
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1974
1974
|
const i = a.map((o) => new Z(o.ctx.common.issues));
|
|
1975
|
-
return l(
|
|
1975
|
+
return l(n, {
|
|
1976
1976
|
code: d.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 de 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 u = {
|
|
2004
|
-
...
|
|
2004
|
+
...n,
|
|
2005
2005
|
common: {
|
|
2006
|
-
...
|
|
2006
|
+
...n.common,
|
|
2007
2007
|
issues: []
|
|
2008
2008
|
},
|
|
2009
2009
|
parent: null
|
|
2010
2010
|
}, p = c._parseSync({
|
|
2011
|
-
data:
|
|
2012
|
-
path:
|
|
2011
|
+
data: n.data,
|
|
2012
|
+
path: n.path,
|
|
2013
2013
|
parent: u
|
|
2014
2014
|
});
|
|
2015
2015
|
if (p.status === "valid")
|
|
@@ -2017,9 +2017,9 @@ class de extends v {
|
|
|
2017
2017
|
p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && i.push(u.common.issues);
|
|
2018
2018
|
}
|
|
2019
2019
|
if (a)
|
|
2020
|
-
return
|
|
2020
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2021
2021
|
const o = i.map((c) => new Z(c));
|
|
2022
|
-
return l(
|
|
2022
|
+
return l(n, {
|
|
2023
2023
|
code: d.invalid_union,
|
|
2024
2024
|
unionErrors: o
|
|
2025
2025
|
}), y;
|
|
@@ -2035,10 +2035,10 @@ de.create = (t, e) => new de({
|
|
|
2035
2035
|
...g(e)
|
|
2036
2036
|
});
|
|
2037
2037
|
function Be(t, e) {
|
|
2038
|
-
const
|
|
2038
|
+
const n = P(t), s = P(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
2044
|
const c = Be(t[o], e[o]);
|
|
@@ -2047,7 +2047,7 @@ function Be(t, e) {
|
|
|
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 = [];
|
|
@@ -2058,75 +2058,75 @@ function Be(t, e) {
|
|
|
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
2063
|
class ue extends v {
|
|
2064
2064
|
_parse(e) {
|
|
2065
|
-
const { status:
|
|
2065
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2066
2066
|
if (Re(a) || Re(i))
|
|
2067
2067
|
return y;
|
|
2068
2068
|
const o = Be(a.value, i.value);
|
|
2069
|
-
return o.valid ? ((je(a) || je(i)) &&
|
|
2069
|
+
return o.valid ? ((je(a) || je(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
2070
|
code: d.invalid_intersection_types
|
|
2071
2071
|
}), 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
|
-
ue.create = (t, e,
|
|
2095
|
+
ue.create = (t, e, n) => new ue({
|
|
2096
2096
|
left: t,
|
|
2097
2097
|
right: e,
|
|
2098
2098
|
typeName: m.ZodIntersection,
|
|
2099
|
-
...g(
|
|
2099
|
+
...g(n)
|
|
2100
2100
|
});
|
|
2101
2101
|
class z 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: d.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: d.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: d.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 D(
|
|
2127
|
+
return c ? c._parse(new D(s, i, s.path, o)) : null;
|
|
2128
2128
|
}).filter((i) => !!i);
|
|
2129
|
-
return
|
|
2129
|
+
return s.common.async ? Promise.all(a).then((i) => T.mergeArray(n, i)) : T.mergeArray(n, a);
|
|
2130
2130
|
}
|
|
2131
2131
|
get items() {
|
|
2132
2132
|
return this._def.items;
|
|
@@ -2156,36 +2156,36 @@ class le 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: d.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 D(
|
|
2170
|
-
value: i._parse(new D(
|
|
2171
|
-
alwaysSet: o in
|
|
2169
|
+
key: a._parse(new D(s, o, s.path, o)),
|
|
2170
|
+
value: i._parse(new D(s, s.data[o], s.path, o)),
|
|
2171
|
+
alwaysSet: o in s.data
|
|
2172
2172
|
});
|
|
2173
|
-
return
|
|
2173
|
+
return s.common.async ? T.mergeObjectAsync(n, r) : T.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 le({
|
|
2180
2180
|
keyType: e,
|
|
2181
|
-
valueType:
|
|
2181
|
+
valueType: n,
|
|
2182
2182
|
typeName: m.ZodRecord,
|
|
2183
|
-
...g(
|
|
2183
|
+
...g(s)
|
|
2184
2184
|
}) : new le({
|
|
2185
2185
|
keyType: I.create(),
|
|
2186
2186
|
valueType: e,
|
|
2187
2187
|
typeName: m.ZodRecord,
|
|
2188
|
-
...g(
|
|
2188
|
+
...g(n)
|
|
2189
2189
|
});
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
@@ -2197,27 +2197,27 @@ class Ve 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: d.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 D(
|
|
2209
|
-
value: a._parse(new D(
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2208
|
+
key: r._parse(new D(s, o, s.path, [u, "key"])),
|
|
2209
|
+
value: a._parse(new D(s, c, s.path, [u, "value"]))
|
|
2210
2210
|
}));
|
|
2211
|
-
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 u = await c.key, p = await c.value;
|
|
2216
2216
|
if (u.status === "aborted" || p.status === "aborted")
|
|
2217
2217
|
return y;
|
|
2218
|
-
(u.status === "dirty" || p.status === "dirty") &&
|
|
2218
|
+
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.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,76 +2225,76 @@ class Ve extends v {
|
|
|
2225
2225
|
const u = c.key, p = c.value;
|
|
2226
2226
|
if (u.status === "aborted" || p.status === "aborted")
|
|
2227
2227
|
return y;
|
|
2228
|
-
(u.status === "dirty" || p.status === "dirty") &&
|
|
2228
|
+
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.value);
|
|
2229
2229
|
}
|
|
2230
|
-
return { status:
|
|
2230
|
+
return { status: n.value, value: o };
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
|
-
Ve.create = (t, e,
|
|
2234
|
+
Ve.create = (t, e, n) => new Ve({
|
|
2235
2235
|
valueType: e,
|
|
2236
2236
|
keyType: t,
|
|
2237
2237
|
typeName: m.ZodMap,
|
|
2238
|
-
...g(
|
|
2238
|
+
...g(n)
|
|
2239
2239
|
});
|
|
2240
|
-
class
|
|
2240
|
+
class se 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: d.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: d.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: d.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 u = /* @__PURE__ */ new Set();
|
|
2268
2268
|
for (const p of c) {
|
|
2269
2269
|
if (p.status === "aborted")
|
|
2270
2270
|
return y;
|
|
2271
|
-
p.status === "dirty" &&
|
|
2271
|
+
p.status === "dirty" && n.dirty(), u.add(p.value);
|
|
2272
2272
|
}
|
|
2273
|
-
return { status:
|
|
2273
|
+
return { status: n.value, value: u };
|
|
2274
2274
|
}
|
|
2275
|
-
const o = [...
|
|
2276
|
-
return
|
|
2275
|
+
const o = [...s.data.values()].map((c, u) => a._parse(new D(s, c, s.path, u)));
|
|
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 se({
|
|
2280
2280
|
...this._def,
|
|
2281
|
-
minSize: { value: e, message: f.toString(
|
|
2281
|
+
minSize: { value: e, message: f.toString(n) }
|
|
2282
2282
|
});
|
|
2283
2283
|
}
|
|
2284
|
-
max(e,
|
|
2285
|
-
return new
|
|
2284
|
+
max(e, n) {
|
|
2285
|
+
return new se({
|
|
2286
2286
|
...this._def,
|
|
2287
|
-
maxSize: { value: e, message: f.toString(
|
|
2287
|
+
maxSize: { value: e, message: f.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
|
+
se.create = (t, e) => new se({
|
|
2298
2298
|
valueType: t,
|
|
2299
2299
|
minSize: null,
|
|
2300
2300
|
maxSize: null,
|
|
@@ -2306,8 +2306,8 @@ class Ue extends v {
|
|
|
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
|
Ue.create = (t, e) => new Ue({
|
|
@@ -2318,9 +2318,9 @@ Ue.create = (t, e) => new Ue({
|
|
|
2318
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: d.invalid_literal,
|
|
2325
2325
|
expected: this._def.value
|
|
2326
2326
|
}), y;
|
|
@@ -2346,19 +2346,19 @@ function rt(t, e) {
|
|
|
2346
2346
|
class K 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: d.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: d.invalid_enum_value,
|
|
2361
|
-
options:
|
|
2361
|
+
options: s
|
|
2362
2362
|
}), y;
|
|
2363
2363
|
}
|
|
2364
2364
|
return N(e.data);
|
|
@@ -2368,51 +2368,51 @@ class K extends v {
|
|
|
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,
|
|
2387
|
+
extract(e, n = this._def) {
|
|
2388
2388
|
return K.create(e, {
|
|
2389
2389
|
...this._def,
|
|
2390
|
-
...
|
|
2390
|
+
...n
|
|
2391
2391
|
});
|
|
2392
2392
|
}
|
|
2393
|
-
exclude(e,
|
|
2394
|
-
return K.create(this.options.filter((
|
|
2393
|
+
exclude(e, n = this._def) {
|
|
2394
|
+
return K.create(this.options.filter((s) => !e.includes(s)), {
|
|
2395
2395
|
...this._def,
|
|
2396
|
-
...
|
|
2396
|
+
...n
|
|
2397
2397
|
});
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
2400
|
K.create = rt;
|
|
2401
2401
|
class Fe 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: d.invalid_type
|
|
2410
2410
|
}), y;
|
|
2411
2411
|
}
|
|
2412
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2413
|
-
const 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: d.invalid_enum_value,
|
|
2417
2417
|
options: r
|
|
2418
2418
|
}), y;
|
|
@@ -2433,17 +2433,17 @@ class he extends v {
|
|
|
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: d.invalid_type,
|
|
2440
2440
|
expected: h.promise,
|
|
2441
|
-
received:
|
|
2441
|
+
received: n.parsedType
|
|
2442
2442
|
}), y;
|
|
2443
|
-
const
|
|
2444
|
-
return N(
|
|
2445
|
-
path:
|
|
2446
|
-
errorMap:
|
|
2443
|
+
const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2444
|
+
return N(s.then((r) => this._def.type.parseAsync(r, {
|
|
2445
|
+
path: n.path,
|
|
2446
|
+
errorMap: n.common.contextualErrorMap
|
|
2447
2447
|
})));
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
@@ -2460,89 +2460,89 @@ class F 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" ? te(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" ? te(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
2521
|
if (!Q(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) => Q(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
|
-
F.create = (t, e,
|
|
2535
|
+
F.create = (t, e, n) => new F({
|
|
2536
2536
|
schema: t,
|
|
2537
2537
|
typeName: m.ZodEffects,
|
|
2538
2538
|
effect: e,
|
|
2539
|
-
...g(
|
|
2539
|
+
...g(n)
|
|
2540
2540
|
});
|
|
2541
|
-
F.createWithPreprocess = (t, e,
|
|
2541
|
+
F.createWithPreprocess = (t, e, n) => new F({
|
|
2542
2542
|
schema: e,
|
|
2543
2543
|
effect: { type: "preprocess", transform: t },
|
|
2544
2544
|
typeName: m.ZodEffects,
|
|
2545
|
-
...g(
|
|
2545
|
+
...g(n)
|
|
2546
2546
|
});
|
|
2547
2547
|
class B extends v {
|
|
2548
2548
|
_parse(e) {
|
|
@@ -2572,12 +2572,12 @@ G.create = (t, e) => new G({
|
|
|
2572
2572
|
});
|
|
2573
2573
|
class ye 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() {
|
|
@@ -2592,34 +2592,34 @@ ye.create = (t, e) => new ye({
|
|
|
2592
2592
|
});
|
|
2593
2593
|
class _e 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
2608
|
return oe(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 Z(
|
|
2612
|
+
return new Z(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 Z(
|
|
2620
|
+
return new Z(s.common.issues);
|
|
2621
2621
|
},
|
|
2622
|
-
input:
|
|
2622
|
+
input: s.data
|
|
2623
2623
|
})
|
|
2624
2624
|
};
|
|
2625
2625
|
}
|
|
@@ -2636,11 +2636,11 @@ _e.create = (t, e) => new _e({
|
|
|
2636
2636
|
class qe 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: d.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 };
|
|
@@ -2652,11 +2652,11 @@ qe.create = (t) => new qe({
|
|
|
2652
2652
|
});
|
|
2653
2653
|
class at 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() {
|
|
@@ -2665,48 +2665,48 @@ class at extends v {
|
|
|
2665
2665
|
}
|
|
2666
2666
|
class xe 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(), te(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,
|
|
2698
|
+
static create(e, n) {
|
|
2699
2699
|
return new xe({
|
|
2700
2700
|
in: e,
|
|
2701
|
-
out:
|
|
2701
|
+
out: n,
|
|
2702
2702
|
typeName: m.ZodPipeline
|
|
2703
2703
|
});
|
|
2704
2704
|
}
|
|
2705
2705
|
}
|
|
2706
2706
|
class ge extends v {
|
|
2707
2707
|
_parse(e) {
|
|
2708
|
-
const
|
|
2709
|
-
return oe(
|
|
2708
|
+
const n = this._def.innerType._parse(e), s = (r) => (Q(r) && (r.value = Object.freeze(r.value)), r);
|
|
2709
|
+
return oe(n) ? n.then((r) => s(r)) : s(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
unwrap() {
|
|
2712
2712
|
return this._def.innerType;
|
|
@@ -2741,7 +2741,7 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2741
2741
|
Schema: v,
|
|
2742
2742
|
ZodAny: Le,
|
|
2743
2743
|
ZodArray: $,
|
|
2744
|
-
ZodBigInt:
|
|
2744
|
+
ZodBigInt: ne,
|
|
2745
2745
|
ZodBoolean: me,
|
|
2746
2746
|
ZodBranded: at,
|
|
2747
2747
|
ZodCatch: _e,
|
|
@@ -2772,7 +2772,7 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2772
2772
|
ZodReadonly: ge,
|
|
2773
2773
|
ZodRecord: le,
|
|
2774
2774
|
ZodSchema: v,
|
|
2775
|
-
ZodSet:
|
|
2775
|
+
ZodSet: se,
|
|
2776
2776
|
ZodString: I,
|
|
2777
2777
|
ZodSymbol: Ie,
|
|
2778
2778
|
ZodTransformer: F,
|
|
@@ -2785,7 +2785,7 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2785
2785
|
addIssueToContext: l,
|
|
2786
2786
|
array: A,
|
|
2787
2787
|
boolean: ke,
|
|
2788
|
-
datetimeRegex:
|
|
2788
|
+
datetimeRegex: st,
|
|
2789
2789
|
defaultErrorMap: pe,
|
|
2790
2790
|
getErrorMap: Xe,
|
|
2791
2791
|
getParsedType: P,
|
|
@@ -2806,31 +2806,31 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
2808
|
_t(Bt);
|
|
2809
|
-
const Vt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method + "@" + t, zt = (t) => t.clone(), Ft = ({ skip: t = Vt, key: e = Ut, resolver:
|
|
2810
|
-
const
|
|
2809
|
+
const Vt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method + "@" + t, zt = (t) => t.clone(), Ft = ({ skip: t = Vt, key: e = Ut, resolver: n = zt } = {}) => {
|
|
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, u) => {
|
|
2819
|
-
|
|
2819
|
+
s.get(o).push([c, u]);
|
|
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(([u]) => u(n(c))), s.delete(o), c)).catch((c) => {
|
|
2823
|
+
throw s.get(o).forEach(([, u]) => u(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
|
-
}, qt = (t, e) => t * e, Wt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Jt = ({ delayTimer: t = 500, delayRamp: e = qt, maxAttempts:
|
|
2829
|
+
}, qt = (t, e) => t * e, Wt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Jt = ({ delayTimer: t = 500, delayRamp: e = qt, maxAttempts: n = 10, until: s = Wt, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (u, p) => {
|
|
2830
2830
|
let k = 0;
|
|
2831
2831
|
if (o && o(u, p))
|
|
2832
2832
|
return c(u, p);
|
|
2833
|
-
const C = (S, E) => Promise.resolve(
|
|
2833
|
+
const C = (S, E) => Promise.resolve(s(S, E)).then((q) => q ? S && i ? S : E ? Promise.reject(E) : S : (k++, !n || k <= n ? new Promise((x) => {
|
|
2834
2834
|
const L = e(t, k);
|
|
2835
2835
|
setTimeout(() => {
|
|
2836
2836
|
typeof r == "function" ? Promise.resolve(r({
|
|
@@ -2929,20 +2929,20 @@ function H(t) {
|
|
|
2929
2929
|
}).middlewares([Jt(), Ft()]);
|
|
2930
2930
|
}
|
|
2931
2931
|
function Qe(t) {
|
|
2932
|
-
const e = {},
|
|
2933
|
-
if (!t) return { sslOverrides: e, rest:
|
|
2934
|
-
for (const [
|
|
2935
|
-
|
|
2936
|
-
return { sslOverrides: e, rest:
|
|
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
2938
|
function Ne(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,
|
|
@@ -2974,22 +2974,22 @@ function Ne(t) {
|
|
|
2974
2974
|
verification: {
|
|
2975
2975
|
methods: A(ft).parse(e)
|
|
2976
2976
|
},
|
|
2977
|
-
domain_metadata:
|
|
2977
|
+
domain_metadata: n
|
|
2978
2978
|
};
|
|
2979
2979
|
}
|
|
2980
|
-
function
|
|
2980
|
+
function en(t) {
|
|
2981
2981
|
return {
|
|
2982
|
-
create: async (e,
|
|
2983
|
-
const { sslOverrides:
|
|
2984
|
-
|
|
2982
|
+
create: async (e, n) => {
|
|
2983
|
+
const { sslOverrides: s, rest: r } = Qe(
|
|
2984
|
+
n.domain_metadata
|
|
2985
2985
|
), { result: a, errors: i, success: o } = ie.parse(
|
|
2986
2986
|
await H(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
|
|
@@ -3009,30 +3009,30 @@ 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 (!
|
|
3020
|
+
if (!s)
|
|
3021
3021
|
throw new X(404);
|
|
3022
|
-
const r = await H(t).get(`/custom_hostnames/${encodeURIComponent(
|
|
3022
|
+
const r = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: a, errors: i, success: o } = ie.parse(r);
|
|
3023
3023
|
if (!o)
|
|
3024
3024
|
throw new X(503, {
|
|
3025
3025
|
message: JSON.stringify(i)
|
|
3026
3026
|
});
|
|
3027
3027
|
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3028
3028
|
throw new X(404);
|
|
3029
|
-
return Ne({ ...
|
|
3029
|
+
return Ne({ ...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
3037
|
const a = await H(t).get(
|
|
3038
3038
|
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
@@ -3047,23 +3047,23 @@ 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
3052
|
const { result: r, success: a } = ie.parse(
|
|
3053
|
-
await H(t).get(`/custom_hostnames/${encodeURIComponent(
|
|
3053
|
+
await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3054
3054
|
);
|
|
3055
3055
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3056
3056
|
throw new X(404);
|
|
3057
3057
|
}
|
|
3058
|
-
const
|
|
3059
|
-
return
|
|
3058
|
+
const s = await H(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,
|
|
3061
|
+
update: async (e, n, s) => {
|
|
3062
3062
|
const { sslOverrides: r } = Qe(
|
|
3063
|
-
|
|
3063
|
+
s.domain_metadata
|
|
3064
3064
|
), a = {};
|
|
3065
3065
|
if (Object.keys(r).length > 0) {
|
|
3066
|
-
const i = await H(t).get(`/custom_hostnames/${encodeURIComponent(
|
|
3066
|
+
const i = await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: o, success: c } = ie.parse(i);
|
|
3067
3067
|
if (!c)
|
|
3068
3068
|
throw new X(503, {
|
|
3069
3069
|
message: "Failed to fetch current custom hostname state"
|
|
@@ -3078,7 +3078,7 @@ function es(t) {
|
|
|
3078
3078
|
if (Object.keys(a).length > 0) {
|
|
3079
3079
|
const i = await H(t).patch(
|
|
3080
3080
|
a,
|
|
3081
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3081
|
+
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3082
3082
|
).res();
|
|
3083
3083
|
if (!i.ok)
|
|
3084
3084
|
throw new X(503, {
|
|
@@ -3087,13 +3087,13 @@ function es(t) {
|
|
|
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 tn {
|
|
3097
3097
|
constructor(e) {
|
|
3098
3098
|
this.config = e;
|
|
3099
3099
|
}
|
|
@@ -3116,19 +3116,19 @@ 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.json();
|
|
3123
3123
|
return a.expiresAt && new Date(a.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : a.value;
|
|
3124
|
-
} catch (
|
|
3125
|
-
return console.error(`CloudflareCache: get error for key ${e}:`,
|
|
3124
|
+
} catch (n) {
|
|
3125
|
+
return console.error(`CloudflareCache: get error for key ${e}:`, n), null;
|
|
3126
3126
|
}
|
|
3127
3127
|
}
|
|
3128
|
-
async set(e,
|
|
3128
|
+
async set(e, n, s) {
|
|
3129
3129
|
try {
|
|
3130
|
-
const r = await this.getCache(), a =
|
|
3131
|
-
value:
|
|
3130
|
+
const r = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3131
|
+
value: n,
|
|
3132
3132
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3133
3133
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3134
3134
|
}, u = this.createRequest(e), p = {
|
|
@@ -3145,10 +3145,10 @@ class ts {
|
|
|
3145
3145
|
}
|
|
3146
3146
|
async delete(e) {
|
|
3147
3147
|
try {
|
|
3148
|
-
const
|
|
3149
|
-
return await
|
|
3150
|
-
} catch (
|
|
3151
|
-
return console.error(`CloudflareCache: delete error for key ${e}:`,
|
|
3148
|
+
const n = await this.getCache(), s = this.createRequest(e);
|
|
3149
|
+
return await n.delete(s);
|
|
3150
|
+
} catch (n) {
|
|
3151
|
+
return console.error(`CloudflareCache: delete error for key ${e}:`, n), !1;
|
|
3152
3152
|
}
|
|
3153
3153
|
}
|
|
3154
3154
|
async deleteByPrefix(e) {
|
|
@@ -3162,7 +3162,7 @@ class ts {
|
|
|
3162
3162
|
);
|
|
3163
3163
|
}
|
|
3164
3164
|
}
|
|
3165
|
-
function
|
|
3165
|
+
function nn(t = {}) {
|
|
3166
3166
|
const e = {
|
|
3167
3167
|
defaultTtlSeconds: 300,
|
|
3168
3168
|
// 5 minutes default
|
|
@@ -3171,16 +3171,16 @@ function ss(t = {}) {
|
|
|
3171
3171
|
...t
|
|
3172
3172
|
// user config overrides defaults
|
|
3173
3173
|
};
|
|
3174
|
-
return new
|
|
3174
|
+
return new tn(e);
|
|
3175
3175
|
}
|
|
3176
|
-
let
|
|
3177
|
-
let e = "",
|
|
3176
|
+
let sn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", dt = (t = 21) => {
|
|
3177
|
+
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
3178
3178
|
for (; t--; )
|
|
3179
|
-
e +=
|
|
3179
|
+
e += sn[n[t] & 63];
|
|
3180
3180
|
return e;
|
|
3181
3181
|
};
|
|
3182
3182
|
async function We(t, e) {
|
|
3183
|
-
const
|
|
3183
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3184
3184
|
try {
|
|
3185
3185
|
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
3186
3186
|
method: "POST",
|
|
@@ -3192,7 +3192,7 @@ async function We(t, e) {
|
|
|
3192
3192
|
body: JSON.stringify({
|
|
3193
3193
|
query: e
|
|
3194
3194
|
}),
|
|
3195
|
-
signal:
|
|
3195
|
+
signal: s.signal
|
|
3196
3196
|
});
|
|
3197
3197
|
if (!i.ok)
|
|
3198
3198
|
throw new Error(
|
|
@@ -3213,13 +3213,13 @@ function U(t) {
|
|
|
3213
3213
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3214
3214
|
}
|
|
3215
3215
|
function ut(t) {
|
|
3216
|
-
const e = (
|
|
3217
|
-
if (!
|
|
3216
|
+
const e = (n) => {
|
|
3217
|
+
if (!n)
|
|
3218
3218
|
return "";
|
|
3219
3219
|
try {
|
|
3220
|
-
return JSON.parse(
|
|
3220
|
+
return JSON.parse(n);
|
|
3221
3221
|
} catch {
|
|
3222
|
-
return
|
|
3222
|
+
return n;
|
|
3223
3223
|
}
|
|
3224
3224
|
};
|
|
3225
3225
|
return {
|
|
@@ -3254,46 +3254,46 @@ function ut(t) {
|
|
|
3254
3254
|
} : void 0
|
|
3255
3255
|
};
|
|
3256
3256
|
}
|
|
3257
|
-
function
|
|
3258
|
-
return async (e,
|
|
3259
|
-
const
|
|
3260
|
-
...
|
|
3261
|
-
log_id:
|
|
3257
|
+
function rn(t) {
|
|
3258
|
+
return async (e, n) => {
|
|
3259
|
+
const s = n.log_id || dt(), r = {
|
|
3260
|
+
...n,
|
|
3261
|
+
log_id: s
|
|
3262
3262
|
};
|
|
3263
|
-
return await
|
|
3263
|
+
return await an(t, e, r), r;
|
|
3264
3264
|
};
|
|
3265
3265
|
}
|
|
3266
|
-
async function
|
|
3267
|
-
const
|
|
3268
|
-
id:
|
|
3266
|
+
async function an(t, e, n) {
|
|
3267
|
+
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3268
|
+
id: n.log_id,
|
|
3269
3269
|
tenant_id: e,
|
|
3270
|
-
type:
|
|
3271
|
-
date:
|
|
3272
|
-
description:
|
|
3273
|
-
ip:
|
|
3274
|
-
user_agent:
|
|
3275
|
-
details: n
|
|
3276
|
-
isMobile:
|
|
3277
|
-
user_id:
|
|
3278
|
-
user_name:
|
|
3279
|
-
connection:
|
|
3280
|
-
connection_id:
|
|
3281
|
-
client_id:
|
|
3282
|
-
client_name:
|
|
3283
|
-
audience:
|
|
3284
|
-
scope:
|
|
3285
|
-
strategy:
|
|
3286
|
-
strategy_type:
|
|
3287
|
-
hostname:
|
|
3288
|
-
auth0_client: n
|
|
3289
|
-
log_id:
|
|
3270
|
+
type: n.type,
|
|
3271
|
+
date: n.date,
|
|
3272
|
+
description: n.description?.substring(0, 256),
|
|
3273
|
+
ip: n.ip,
|
|
3274
|
+
user_agent: n.user_agent,
|
|
3275
|
+
details: s(n.details)?.substring(0, 8192),
|
|
3276
|
+
isMobile: n.isMobile ? 1 : 0,
|
|
3277
|
+
user_id: n.user_id,
|
|
3278
|
+
user_name: n.user_name,
|
|
3279
|
+
connection: n.connection,
|
|
3280
|
+
connection_id: n.connection_id,
|
|
3281
|
+
client_id: n.client_id,
|
|
3282
|
+
client_name: n.client_name,
|
|
3283
|
+
audience: n.audience,
|
|
3284
|
+
scope: n.scope,
|
|
3285
|
+
strategy: n.strategy,
|
|
3286
|
+
strategy_type: n.strategy_type,
|
|
3287
|
+
hostname: n.hostname,
|
|
3288
|
+
auth0_client: s(n.auth0_client),
|
|
3289
|
+
log_id: n.log_id,
|
|
3290
3290
|
// Geo fields from location_info
|
|
3291
|
-
country_code:
|
|
3292
|
-
city_name:
|
|
3293
|
-
latitude:
|
|
3294
|
-
longitude:
|
|
3295
|
-
time_zone:
|
|
3296
|
-
continent_code:
|
|
3291
|
+
country_code: n.location_info?.country_code,
|
|
3292
|
+
city_name: n.location_info?.city_name,
|
|
3293
|
+
latitude: n.location_info?.latitude,
|
|
3294
|
+
longitude: n.location_info?.longitude,
|
|
3295
|
+
time_zone: n.location_info?.time_zone,
|
|
3296
|
+
continent_code: n.location_info?.continent_code
|
|
3297
3297
|
};
|
|
3298
3298
|
try {
|
|
3299
3299
|
if (t.pipelineBinding)
|
|
@@ -3325,12 +3325,12 @@ async function as(t, e, s) {
|
|
|
3325
3325
|
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3326
3326
|
}
|
|
3327
3327
|
}
|
|
3328
|
-
function
|
|
3329
|
-
return async (e,
|
|
3330
|
-
const
|
|
3331
|
-
SELECT * FROM ${U(
|
|
3328
|
+
function on(t) {
|
|
3329
|
+
return async (e, n) => {
|
|
3330
|
+
const s = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3331
|
+
SELECT * FROM ${U(s)}.${U(r)}
|
|
3332
3332
|
WHERE tenant_id = ${be(e)}
|
|
3333
|
-
AND id = ${be(
|
|
3333
|
+
AND id = ${be(n)}
|
|
3334
3334
|
LIMIT 1
|
|
3335
3335
|
`, i = await We(t, a);
|
|
3336
3336
|
if (i.length === 0)
|
|
@@ -3339,31 +3339,31 @@ function is(t) {
|
|
|
3339
3339
|
return o ? ut(o) : null;
|
|
3340
3340
|
};
|
|
3341
3341
|
}
|
|
3342
|
-
function
|
|
3342
|
+
function cn(t) {
|
|
3343
3343
|
const e = {};
|
|
3344
|
-
return (t.match(/(\w+):(\S+)/g) || []).forEach((
|
|
3345
|
-
const [r, a] =
|
|
3344
|
+
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3345
|
+
const [r, a] = s.split(":");
|
|
3346
3346
|
r && a && (e[r] = a);
|
|
3347
3347
|
}), e;
|
|
3348
3348
|
}
|
|
3349
|
-
function
|
|
3349
|
+
function dn(t) {
|
|
3350
3350
|
const e = [];
|
|
3351
|
-
for (const [
|
|
3352
|
-
const r =
|
|
3353
|
-
r &&
|
|
3354
|
-
`${U(r)} = ${be(
|
|
3351
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3352
|
+
const r = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3353
|
+
r && s && e.push(
|
|
3354
|
+
`${U(r)} = ${be(s)}`
|
|
3355
3355
|
);
|
|
3356
3356
|
}
|
|
3357
3357
|
return e;
|
|
3358
3358
|
}
|
|
3359
|
-
function
|
|
3360
|
-
return async (e,
|
|
3361
|
-
const { page:
|
|
3359
|
+
function un(t) {
|
|
3360
|
+
return async (e, n = {}) => {
|
|
3361
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.namespace || "default", u = t.tableName || "logs", p = [
|
|
3362
3362
|
`tenant_id = ${be(e)}`
|
|
3363
3363
|
];
|
|
3364
3364
|
if (o) {
|
|
3365
|
-
const J =
|
|
3366
|
-
p.push(...
|
|
3365
|
+
const J = cn(o);
|
|
3366
|
+
p.push(...dn(J));
|
|
3367
3367
|
}
|
|
3368
3368
|
const k = p.join(" AND ");
|
|
3369
3369
|
let C = "ORDER BY date DESC";
|
|
@@ -3371,7 +3371,7 @@ function ds(t) {
|
|
|
3371
3371
|
const J = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), re = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3372
3372
|
C = `ORDER BY ${U(J)} ${re}`;
|
|
3373
3373
|
}
|
|
3374
|
-
const S =
|
|
3374
|
+
const S = s * r, E = `LIMIT ${r} OFFSET ${S}`, q = `
|
|
3375
3375
|
SELECT * FROM ${U(c)}.${U(u)}
|
|
3376
3376
|
WHERE ${k}
|
|
3377
3377
|
${C}
|
|
@@ -3396,7 +3396,7 @@ function ds(t) {
|
|
|
3396
3396
|
};
|
|
3397
3397
|
};
|
|
3398
3398
|
}
|
|
3399
|
-
function
|
|
3399
|
+
function Cn() {
|
|
3400
3400
|
return {
|
|
3401
3401
|
async getDaily() {
|
|
3402
3402
|
throw new Error(
|
|
@@ -3410,9 +3410,9 @@ function Ss() {
|
|
|
3410
3410
|
}
|
|
3411
3411
|
};
|
|
3412
3412
|
}
|
|
3413
|
-
function
|
|
3414
|
-
const e = !!t.pipelineEndpoint,
|
|
3415
|
-
if (!e && !
|
|
3413
|
+
function ln(t) {
|
|
3414
|
+
const e = !!t.pipelineEndpoint, n = !!t.pipelineBinding;
|
|
3415
|
+
if (!e && !n)
|
|
3416
3416
|
throw new Error(
|
|
3417
3417
|
'R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"'
|
|
3418
3418
|
);
|
|
@@ -3423,13 +3423,13 @@ function us(t) {
|
|
|
3423
3423
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3424
3424
|
);
|
|
3425
3425
|
return {
|
|
3426
|
-
create:
|
|
3427
|
-
list:
|
|
3428
|
-
get:
|
|
3426
|
+
create: rn(t),
|
|
3427
|
+
list: un(t),
|
|
3428
|
+
get: on(t)
|
|
3429
3429
|
};
|
|
3430
3430
|
}
|
|
3431
3431
|
async function fe(t, e) {
|
|
3432
|
-
const
|
|
3432
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3433
3433
|
try {
|
|
3434
3434
|
const a = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(a, {
|
|
3435
3435
|
method: "POST",
|
|
@@ -3438,7 +3438,7 @@ async function fe(t, e) {
|
|
|
3438
3438
|
Authorization: `Bearer ${t.apiToken}`
|
|
3439
3439
|
},
|
|
3440
3440
|
body: e,
|
|
3441
|
-
signal:
|
|
3441
|
+
signal: s.signal
|
|
3442
3442
|
});
|
|
3443
3443
|
if (!i.ok) {
|
|
3444
3444
|
const c = await i.text();
|
|
@@ -3470,11 +3470,11 @@ function lt(t) {
|
|
|
3470
3470
|
} catch {
|
|
3471
3471
|
return;
|
|
3472
3472
|
}
|
|
3473
|
-
},
|
|
3473
|
+
}, n = t.double2 || t.timestamp, s = n ? new Date(n).toISOString() : "";
|
|
3474
3474
|
return {
|
|
3475
3475
|
log_id: t.blob1,
|
|
3476
3476
|
type: t.blob3,
|
|
3477
|
-
date:
|
|
3477
|
+
date: s,
|
|
3478
3478
|
description: t.blob4,
|
|
3479
3479
|
ip: t.blob5,
|
|
3480
3480
|
user_agent: t.blob6,
|
|
@@ -3495,69 +3495,69 @@ function lt(t) {
|
|
|
3495
3495
|
isMobile: t.double1 === 1
|
|
3496
3496
|
};
|
|
3497
3497
|
}
|
|
3498
|
-
function
|
|
3499
|
-
return async (e,
|
|
3500
|
-
const
|
|
3501
|
-
...
|
|
3502
|
-
log_id:
|
|
3498
|
+
function hn(t) {
|
|
3499
|
+
return async (e, n) => {
|
|
3500
|
+
const s = n.log_id || dt(), r = {
|
|
3501
|
+
...n,
|
|
3502
|
+
log_id: s
|
|
3503
3503
|
};
|
|
3504
|
-
return
|
|
3504
|
+
return fn(t, e, r), r;
|
|
3505
3505
|
};
|
|
3506
3506
|
}
|
|
3507
|
-
function
|
|
3507
|
+
function fn(t, e, n) {
|
|
3508
3508
|
if (!t.analyticsEngineBinding) {
|
|
3509
3509
|
console.error("Analytics Engine binding not configured");
|
|
3510
3510
|
return;
|
|
3511
3511
|
}
|
|
3512
|
-
const
|
|
3512
|
+
const s = (a) => a == null ? "" : typeof a == "string" ? a : JSON.stringify(a), r = (a, i = 1024) => a.substring(0, i);
|
|
3513
3513
|
try {
|
|
3514
3514
|
t.analyticsEngineBinding.writeDataPoint({
|
|
3515
3515
|
blobs: [
|
|
3516
|
-
r(
|
|
3516
|
+
r(n.log_id),
|
|
3517
3517
|
// blob1: log_id
|
|
3518
3518
|
r(e),
|
|
3519
3519
|
// blob2: tenant_id
|
|
3520
|
-
r(
|
|
3520
|
+
r(n.type || ""),
|
|
3521
3521
|
// blob3: type
|
|
3522
|
-
r(
|
|
3522
|
+
r(n.description || ""),
|
|
3523
3523
|
// blob4: description
|
|
3524
|
-
r(
|
|
3524
|
+
r(n.ip || ""),
|
|
3525
3525
|
// blob5: ip
|
|
3526
|
-
r(
|
|
3526
|
+
r(n.user_agent || ""),
|
|
3527
3527
|
// blob6: user_agent
|
|
3528
|
-
r(
|
|
3528
|
+
r(n.user_id || ""),
|
|
3529
3529
|
// blob7: user_id
|
|
3530
|
-
r(
|
|
3530
|
+
r(n.user_name || ""),
|
|
3531
3531
|
// blob8: user_name
|
|
3532
|
-
r(
|
|
3532
|
+
r(n.connection || ""),
|
|
3533
3533
|
// blob9: connection
|
|
3534
|
-
r(
|
|
3534
|
+
r(n.connection_id || ""),
|
|
3535
3535
|
// blob10: connection_id
|
|
3536
|
-
r(
|
|
3536
|
+
r(n.client_id || ""),
|
|
3537
3537
|
// blob11: client_id
|
|
3538
|
-
r(
|
|
3538
|
+
r(n.client_name || ""),
|
|
3539
3539
|
// blob12: client_name
|
|
3540
|
-
r(
|
|
3540
|
+
r(n.audience || ""),
|
|
3541
3541
|
// blob13: audience
|
|
3542
|
-
r(
|
|
3542
|
+
r(n.scope || ""),
|
|
3543
3543
|
// blob14: scope
|
|
3544
|
-
r(
|
|
3544
|
+
r(n.strategy || ""),
|
|
3545
3545
|
// blob15: strategy
|
|
3546
|
-
r(
|
|
3546
|
+
r(n.strategy_type || ""),
|
|
3547
3547
|
// blob16: strategy_type
|
|
3548
|
-
r(
|
|
3548
|
+
r(n.hostname || ""),
|
|
3549
3549
|
// blob17: hostname
|
|
3550
|
-
r(n
|
|
3550
|
+
r(s(n.details)),
|
|
3551
3551
|
// blob18: details (JSON)
|
|
3552
|
-
r(n
|
|
3552
|
+
r(s(n.auth0_client)),
|
|
3553
3553
|
// blob19: auth0_client (JSON)
|
|
3554
|
-
r(n
|
|
3554
|
+
r(s(n.location_info))
|
|
3555
3555
|
// blob20: location_info (JSON)
|
|
3556
3556
|
],
|
|
3557
3557
|
doubles: [
|
|
3558
|
-
|
|
3558
|
+
n.isMobile ? 1 : 0,
|
|
3559
3559
|
// double1: isMobile
|
|
3560
|
-
new Date(
|
|
3560
|
+
new Date(n.date).getTime()
|
|
3561
3561
|
// double2: timestamp for sorting
|
|
3562
3562
|
],
|
|
3563
3563
|
indexes: [e.substring(0, 96)]
|
|
@@ -3567,22 +3567,22 @@ function hs(t, e, s) {
|
|
|
3567
3567
|
console.error("Failed to write log to Analytics Engine:", a);
|
|
3568
3568
|
}
|
|
3569
3569
|
}
|
|
3570
|
-
function
|
|
3571
|
-
return async (e,
|
|
3572
|
-
const
|
|
3570
|
+
function pn(t) {
|
|
3571
|
+
return async (e, n) => {
|
|
3572
|
+
const s = t.dataset || "authhero_logs", r = `
|
|
3573
3573
|
SELECT *
|
|
3574
|
-
FROM ${Je(
|
|
3574
|
+
FROM ${Je(s)}
|
|
3575
3575
|
WHERE index1 = ${M(e)}
|
|
3576
|
-
AND blob1 = ${M(
|
|
3576
|
+
AND blob1 = ${M(n)}
|
|
3577
3577
|
LIMIT 1
|
|
3578
3578
|
`, a = await fe(t, r);
|
|
3579
3579
|
return a.length === 0 || !a[0] ? null : lt(a[0]);
|
|
3580
3580
|
};
|
|
3581
3581
|
}
|
|
3582
|
-
function
|
|
3582
|
+
function mn(t) {
|
|
3583
3583
|
const e = {};
|
|
3584
|
-
return (t.match(/(\w+):(\S+)/g) || []).forEach((
|
|
3585
|
-
const r =
|
|
3584
|
+
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3585
|
+
const r = s.indexOf(":"), a = s.substring(0, r), i = s.substring(r + 1);
|
|
3586
3586
|
a && i && (e[a] = i);
|
|
3587
3587
|
}), e;
|
|
3588
3588
|
}
|
|
@@ -3607,34 +3607,34 @@ function ht(t) {
|
|
|
3607
3607
|
hostname: "blob17"
|
|
3608
3608
|
}[t] || null;
|
|
3609
3609
|
}
|
|
3610
|
-
function
|
|
3610
|
+
function yn(t) {
|
|
3611
3611
|
const e = [];
|
|
3612
|
-
for (const [
|
|
3613
|
-
const r = ht(
|
|
3614
|
-
r &&
|
|
3612
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3613
|
+
const r = ht(n);
|
|
3614
|
+
r && s && e.push(`${r} = ${M(s)}`);
|
|
3615
3615
|
}
|
|
3616
3616
|
return e;
|
|
3617
3617
|
}
|
|
3618
|
-
function
|
|
3618
|
+
function _n(t) {
|
|
3619
3619
|
if (t === "date")
|
|
3620
3620
|
return "double2";
|
|
3621
3621
|
const e = ht(t);
|
|
3622
3622
|
return e || "timestamp";
|
|
3623
3623
|
}
|
|
3624
|
-
function
|
|
3625
|
-
return async (e,
|
|
3626
|
-
const { page:
|
|
3624
|
+
function gn(t) {
|
|
3625
|
+
return async (e, n = {}) => {
|
|
3626
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs", u = [`index1 = ${M(e)}`];
|
|
3627
3627
|
if (o) {
|
|
3628
|
-
const O =
|
|
3629
|
-
u.push(...
|
|
3628
|
+
const O = mn(o);
|
|
3629
|
+
u.push(...yn(O));
|
|
3630
3630
|
}
|
|
3631
3631
|
const p = u.join(" AND ");
|
|
3632
3632
|
let k = "ORDER BY timestamp DESC";
|
|
3633
3633
|
if (i && i.sort_by) {
|
|
3634
|
-
const O =
|
|
3634
|
+
const O = _n(i.sort_by), j = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3635
3635
|
k = `ORDER BY ${O} ${j}`;
|
|
3636
3636
|
}
|
|
3637
|
-
const C =
|
|
3637
|
+
const C = s * r, S = `LIMIT ${r} OFFSET ${C}`, E = `
|
|
3638
3638
|
SELECT *
|
|
3639
3639
|
FROM ${Je(c)}
|
|
3640
3640
|
WHERE ${p}
|
|
@@ -3684,22 +3684,22 @@ const Ye = [
|
|
|
3684
3684
|
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3685
3685
|
"ssa"
|
|
3686
3686
|
// SUCCESS_SILENT_AUTH
|
|
3687
|
-
],
|
|
3687
|
+
], vn = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
3688
3688
|
function Ke(t) {
|
|
3689
3689
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3690
3690
|
}
|
|
3691
3691
|
function Ge(t) {
|
|
3692
3692
|
return t.toISOString().split("T")[0];
|
|
3693
3693
|
}
|
|
3694
|
-
function
|
|
3694
|
+
function Tn(t) {
|
|
3695
3695
|
const e = t.dataset || "authhero_logs";
|
|
3696
3696
|
return {
|
|
3697
|
-
async getDaily(
|
|
3698
|
-
const { from: r, to: a } =
|
|
3697
|
+
async getDaily(n, s = {}) {
|
|
3698
|
+
const { from: r, to: a } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3699
3699
|
o.setDate(o.getDate() - 30);
|
|
3700
3700
|
const c = r ? Ke(r) : Ge(o), u = a ? Ke(a) : Ge(i), p = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), k = (/* @__PURE__ */ new Date(`${u}T23:59:59.999Z`)).getTime(), C = Ye.map((x) => M(x)).join(
|
|
3701
3701
|
", "
|
|
3702
|
-
), S =
|
|
3702
|
+
), S = vn.map(
|
|
3703
3703
|
(x) => M(x)
|
|
3704
3704
|
).join(", "), E = `
|
|
3705
3705
|
SELECT
|
|
@@ -3710,7 +3710,7 @@ function Cs(t) {
|
|
|
3710
3710
|
MIN(double2) AS first_event,
|
|
3711
3711
|
MAX(double2) AS last_event
|
|
3712
3712
|
FROM "${e}"
|
|
3713
|
-
WHERE index1 = ${M(
|
|
3713
|
+
WHERE index1 = ${M(n)}
|
|
3714
3714
|
AND double2 >= ${p}
|
|
3715
3715
|
AND double2 <= ${k}
|
|
3716
3716
|
GROUP BY date
|
|
@@ -3725,15 +3725,15 @@ function Cs(t) {
|
|
|
3725
3725
|
updated_at: x.last_event ? new Date(Number(x.last_event)).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
3726
3726
|
}));
|
|
3727
3727
|
},
|
|
3728
|
-
async getActiveUsers(
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3731
|
-
const r =
|
|
3728
|
+
async getActiveUsers(n) {
|
|
3729
|
+
const s = /* @__PURE__ */ new Date();
|
|
3730
|
+
s.setDate(s.getDate() - 30);
|
|
3731
|
+
const r = s.getTime(), a = Ye.map((u) => M(u)).join(
|
|
3732
3732
|
", "
|
|
3733
3733
|
), i = `
|
|
3734
3734
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3735
3735
|
FROM "${e}"
|
|
3736
|
-
WHERE index1 = ${M(
|
|
3736
|
+
WHERE index1 = ${M(n)}
|
|
3737
3737
|
AND double2 >= ${r}
|
|
3738
3738
|
AND blob3 IN (${a})
|
|
3739
3739
|
AND blob7 IS NOT NULL
|
|
@@ -3743,26 +3743,26 @@ function Cs(t) {
|
|
|
3743
3743
|
}
|
|
3744
3744
|
};
|
|
3745
3745
|
}
|
|
3746
|
-
function
|
|
3746
|
+
function bn(t) {
|
|
3747
3747
|
return t.analyticsEngineBinding || console.warn(
|
|
3748
3748
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3749
3749
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
3750
3750
|
"Analytics Engine: accountId and apiToken are required for querying logs via SQL API."
|
|
3751
3751
|
), {
|
|
3752
|
-
create:
|
|
3753
|
-
list:
|
|
3754
|
-
get:
|
|
3752
|
+
create: hn(t),
|
|
3753
|
+
list: gn(t),
|
|
3754
|
+
get: pn(t)
|
|
3755
3755
|
};
|
|
3756
3756
|
}
|
|
3757
|
-
function
|
|
3757
|
+
function xn() {
|
|
3758
3758
|
return {
|
|
3759
3759
|
async getGeoInfo(t) {
|
|
3760
3760
|
try {
|
|
3761
|
-
const e = t["cf-ipcountry"],
|
|
3761
|
+
const e = t["cf-ipcountry"], n = t["cf-ipcity"], s = t["cf-iplatitude"], r = t["cf-iplongitude"], a = t["cf-timezone"], i = t["cf-ipcontinent"];
|
|
3762
3762
|
return e ? {
|
|
3763
3763
|
country_code: e,
|
|
3764
|
-
city_name:
|
|
3765
|
-
latitude:
|
|
3764
|
+
city_name: n || "",
|
|
3765
|
+
latitude: s || "",
|
|
3766
3766
|
longitude: r || "",
|
|
3767
3767
|
time_zone: a || "",
|
|
3768
3768
|
continent_code: i || ""
|
|
@@ -3773,7 +3773,7 @@ function bs() {
|
|
|
3773
3773
|
}
|
|
3774
3774
|
};
|
|
3775
3775
|
}
|
|
3776
|
-
function
|
|
3776
|
+
function kn(t) {
|
|
3777
3777
|
return `// Auto-generated AuthHero code hook worker
|
|
3778
3778
|
|
|
3779
3779
|
const fnNames = {
|
|
@@ -3784,11 +3784,7 @@ const fnNames = {
|
|
|
3784
3784
|
};
|
|
3785
3785
|
|
|
3786
3786
|
const apiShapes = {
|
|
3787
|
-
"post-user-login": {
|
|
3788
|
-
accessToken: ["setCustomClaim"],
|
|
3789
|
-
idToken: ["setCustomClaim"],
|
|
3790
|
-
access: ["deny"],
|
|
3791
|
-
},
|
|
3787
|
+
"post-user-login": {},
|
|
3792
3788
|
"credentials-exchange": {
|
|
3793
3789
|
accessToken: ["setCustomClaim"],
|
|
3794
3790
|
idToken: ["setCustomClaim"],
|
|
@@ -3877,21 +3873,21 @@ export default {
|
|
|
3877
3873
|
};
|
|
3878
3874
|
`;
|
|
3879
3875
|
}
|
|
3880
|
-
class
|
|
3876
|
+
class En {
|
|
3881
3877
|
config;
|
|
3882
3878
|
constructor(e) {
|
|
3883
3879
|
this.config = e;
|
|
3884
3880
|
}
|
|
3885
3881
|
async execute(e) {
|
|
3886
|
-
const
|
|
3882
|
+
const n = Date.now();
|
|
3887
3883
|
if (!e.hookCodeId)
|
|
3888
3884
|
return {
|
|
3889
3885
|
success: !1,
|
|
3890
3886
|
error: "CloudflareCodeExecutor requires hookCodeId",
|
|
3891
|
-
durationMs: Date.now() -
|
|
3887
|
+
durationMs: Date.now() - n,
|
|
3892
3888
|
apiCalls: []
|
|
3893
3889
|
};
|
|
3894
|
-
const
|
|
3890
|
+
const s = `hook-${e.hookCodeId}`, r = JSON.stringify({
|
|
3895
3891
|
triggerId: e.triggerId,
|
|
3896
3892
|
event: e.event
|
|
3897
3893
|
});
|
|
@@ -3899,7 +3895,7 @@ class Ts {
|
|
|
3899
3895
|
let a;
|
|
3900
3896
|
if (this.config.dispatcher)
|
|
3901
3897
|
a = await this.config.dispatcher.get(
|
|
3902
|
-
|
|
3898
|
+
s,
|
|
3903
3899
|
{},
|
|
3904
3900
|
{ limits: { cpuMs: e.cpuLimitMs ?? 5e3 } }
|
|
3905
3901
|
).fetch(
|
|
@@ -3910,7 +3906,7 @@ class Ts {
|
|
|
3910
3906
|
})
|
|
3911
3907
|
);
|
|
3912
3908
|
else if (this.config.dispatchUrl)
|
|
3913
|
-
a = await fetch(`${this.config.dispatchUrl}/${
|
|
3909
|
+
a = await fetch(`${this.config.dispatchUrl}/${s}`, {
|
|
3914
3910
|
method: "POST",
|
|
3915
3911
|
headers: {
|
|
3916
3912
|
"Content-Type": "application/json",
|
|
@@ -3922,7 +3918,7 @@ class Ts {
|
|
|
3922
3918
|
return {
|
|
3923
3919
|
success: !1,
|
|
3924
3920
|
error: "No dispatcher binding or dispatchUrl configured",
|
|
3925
|
-
durationMs: Date.now() -
|
|
3921
|
+
durationMs: Date.now() - n,
|
|
3926
3922
|
apiCalls: []
|
|
3927
3923
|
};
|
|
3928
3924
|
if (!a.ok) {
|
|
@@ -3930,19 +3926,19 @@ class Ts {
|
|
|
3930
3926
|
return {
|
|
3931
3927
|
success: !1,
|
|
3932
3928
|
error: `Worker invocation failed (${a.status}): ${o}`,
|
|
3933
|
-
durationMs: Date.now() -
|
|
3929
|
+
durationMs: Date.now() - n,
|
|
3934
3930
|
apiCalls: []
|
|
3935
3931
|
};
|
|
3936
3932
|
}
|
|
3937
3933
|
return {
|
|
3938
3934
|
...await a.json(),
|
|
3939
|
-
durationMs: Date.now() -
|
|
3935
|
+
durationMs: Date.now() - n
|
|
3940
3936
|
};
|
|
3941
3937
|
} catch (a) {
|
|
3942
3938
|
return {
|
|
3943
3939
|
success: !1,
|
|
3944
3940
|
error: a instanceof Error ? a.message : String(a),
|
|
3945
|
-
durationMs: Date.now() -
|
|
3941
|
+
durationMs: Date.now() - n,
|
|
3946
3942
|
apiCalls: []
|
|
3947
3943
|
};
|
|
3948
3944
|
}
|
|
@@ -3951,8 +3947,8 @@ class Ts {
|
|
|
3951
3947
|
* Deploy user code as a worker to the dispatch namespace.
|
|
3952
3948
|
* Wraps the code in a worker template and uploads via Cloudflare API.
|
|
3953
3949
|
*/
|
|
3954
|
-
async deploy(e,
|
|
3955
|
-
const
|
|
3950
|
+
async deploy(e, n) {
|
|
3951
|
+
const s = `hook-${e}`, r = kn(n), a = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`, i = JSON.stringify({
|
|
3956
3952
|
main_module: "index.js",
|
|
3957
3953
|
compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
|
|
3958
3954
|
}), o = new FormData();
|
|
@@ -3974,7 +3970,7 @@ class Ts {
|
|
|
3974
3970
|
if (!c.ok) {
|
|
3975
3971
|
const u = await c.text();
|
|
3976
3972
|
throw new Error(
|
|
3977
|
-
`Failed to deploy hook worker ${
|
|
3973
|
+
`Failed to deploy hook worker ${s}: ${c.status} ${u}`
|
|
3978
3974
|
);
|
|
3979
3975
|
}
|
|
3980
3976
|
}
|
|
@@ -3982,7 +3978,7 @@ class Ts {
|
|
|
3982
3978
|
* Remove a user worker from the dispatch namespace.
|
|
3983
3979
|
*/
|
|
3984
3980
|
async remove(e) {
|
|
3985
|
-
const
|
|
3981
|
+
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, {
|
|
3986
3982
|
method: "DELETE",
|
|
3987
3983
|
headers: {
|
|
3988
3984
|
Authorization: `Bearer ${this.config.apiToken}`
|
|
@@ -3991,16 +3987,16 @@ class Ts {
|
|
|
3991
3987
|
if (!r.ok && r.status !== 404) {
|
|
3992
3988
|
const a = await r.text();
|
|
3993
3989
|
throw new Error(
|
|
3994
|
-
`Failed to remove hook worker ${
|
|
3990
|
+
`Failed to remove hook worker ${n}: ${r.status} ${a}`
|
|
3995
3991
|
);
|
|
3996
3992
|
}
|
|
3997
3993
|
}
|
|
3998
3994
|
}
|
|
3999
|
-
function
|
|
3995
|
+
function On(t) {
|
|
4000
3996
|
const e = {
|
|
4001
|
-
customDomains:
|
|
3997
|
+
customDomains: en(t),
|
|
4002
3998
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
4003
|
-
cache:
|
|
3999
|
+
cache: nn({
|
|
4004
4000
|
...t.cacheName && { cacheName: t.cacheName },
|
|
4005
4001
|
...t.defaultTtlSeconds !== void 0 && {
|
|
4006
4002
|
defaultTtlSeconds: t.defaultTtlSeconds
|
|
@@ -4009,18 +4005,18 @@ function Es(t) {
|
|
|
4009
4005
|
}),
|
|
4010
4006
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
4011
4007
|
// passed at request time via getGeoInfo(headers)
|
|
4012
|
-
geo:
|
|
4008
|
+
geo: xn()
|
|
4013
4009
|
};
|
|
4014
|
-
return t.r2SqlLogs ? e.logs =
|
|
4010
|
+
return t.r2SqlLogs ? e.logs = ln(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = bn(
|
|
4015
4011
|
t.analyticsEngineLogs
|
|
4016
4012
|
)), e;
|
|
4017
4013
|
}
|
|
4018
4014
|
export {
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4015
|
+
En as CloudflareCodeExecutor,
|
|
4016
|
+
bn as createAnalyticsEngineLogsAdapter,
|
|
4017
|
+
Tn as createAnalyticsEngineStatsAdapter,
|
|
4018
|
+
ln as createR2SQLLogsAdapter,
|
|
4019
|
+
Cn as createR2SQLStatsAdapter,
|
|
4020
|
+
On as default,
|
|
4021
|
+
kn as generateWorkerScript
|
|
4026
4022
|
};
|