@authhero/cloudflare-adapter 2.24.3 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare-adapter.cjs +19 -19
- package/dist/cloudflare-adapter.mjs +867 -855
- 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
|
}
|
|
@@ -24,9 +24,9 @@ function _t(t) {
|
|
|
24
24
|
return;
|
|
25
25
|
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
26
|
var i, o, c, u, p, k;
|
|
27
|
-
const C = typeof r == "string" ? a : r, S = C ?? {}, { param: E } = S, q = mt(S, ["param"]), x = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0),
|
|
27
|
+
const C = typeof r == "string" ? a : r, S = C ?? {}, { param: E } = S, q = mt(S, ["param"]), x = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0), P = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), q), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || E ? {
|
|
28
28
|
param: Object.assign(Object.assign({}, (k = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || k === void 0 ? void 0 : k.param), E)
|
|
29
|
-
} : void 0), O = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(x).length > 0 ? { _internal: x } : void 0), Object.keys(
|
|
29
|
+
} : void 0), O = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(x).length > 0 ? { _internal: x } : void 0), Object.keys(P).length > 0 ? { metadata: P } : void 0) }));
|
|
30
30
|
if (yt(this, "ZodObject")) {
|
|
31
31
|
const j = this.extend;
|
|
32
32
|
O.extend = function(...W) {
|
|
@@ -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 = {}));
|
|
@@ -153,7 +153,7 @@ const h = b.arrayToEnum([
|
|
|
153
153
|
"never",
|
|
154
154
|
"map",
|
|
155
155
|
"set"
|
|
156
|
-
]),
|
|
156
|
+
]), M = (t) => {
|
|
157
157
|
switch (typeof t) {
|
|
158
158
|
case "undefined":
|
|
159
159
|
return h.undefined;
|
|
@@ -192,23 +192,23 @@ const h = b.arrayToEnum([
|
|
|
192
192
|
"not_multiple_of",
|
|
193
193
|
"not_finite"
|
|
194
194
|
]);
|
|
195
|
-
class
|
|
195
|
+
class D extends Error {
|
|
196
196
|
get errors() {
|
|
197
197
|
return this.issues;
|
|
198
198
|
}
|
|
199
199
|
constructor(e) {
|
|
200
|
-
super(), this.issues = [], this.addIssue = (
|
|
201
|
-
this.issues = [...this.issues,
|
|
202
|
-
}, this.addIssues = (
|
|
203
|
-
this.issues = [...this.issues, ...
|
|
200
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
201
|
+
this.issues = [...this.issues, s];
|
|
202
|
+
}, this.addIssues = (s = []) => {
|
|
203
|
+
this.issues = [...this.issues, ...s];
|
|
204
204
|
};
|
|
205
|
-
const
|
|
206
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this,
|
|
205
|
+
const n = new.target.prototype;
|
|
206
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
207
207
|
}
|
|
208
208
|
format(e) {
|
|
209
|
-
const
|
|
209
|
+
const n = e || function(a) {
|
|
210
210
|
return a.message;
|
|
211
|
-
},
|
|
211
|
+
}, s = { _errors: [] }, r = (a) => {
|
|
212
212
|
for (const i of a.issues)
|
|
213
213
|
if (i.code === "invalid_union")
|
|
214
214
|
i.unionErrors.map(r);
|
|
@@ -217,19 +217,19 @@ class 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
|
-
if (!(e instanceof
|
|
232
|
+
if (!(e instanceof D))
|
|
233
233
|
throw new Error(`Not a ZodError: ${e}`);
|
|
234
234
|
}
|
|
235
235
|
toString() {
|
|
@@ -241,83 +241,83 @@ 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();
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
D.create = (t) => new D(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({
|
|
@@ -403,9 +403,9 @@ var f;
|
|
|
403
403
|
(function(t) {
|
|
404
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
405
405
|
})(f || (f = {}));
|
|
406
|
-
class
|
|
407
|
-
constructor(e,
|
|
408
|
-
this._cachedPath = [], this.parent = e, this.data =
|
|
406
|
+
class L {
|
|
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 D(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 {
|
|
@@ -442,13 +442,13 @@ class v {
|
|
|
442
442
|
return this._def.description;
|
|
443
443
|
}
|
|
444
444
|
_getType(e) {
|
|
445
|
-
return
|
|
445
|
+
return M(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
|
-
parsedType:
|
|
451
|
+
parsedType: M(e.data),
|
|
452
452
|
schemaErrorMap: this._def.errorMap,
|
|
453
453
|
path: e.path,
|
|
454
454
|
parent: e.parent
|
|
@@ -460,7 +460,7 @@ class v {
|
|
|
460
460
|
ctx: {
|
|
461
461
|
common: e.parent.common,
|
|
462
462
|
data: e.data,
|
|
463
|
-
parsedType:
|
|
463
|
+
parsedType: M(e.data),
|
|
464
464
|
schemaErrorMap: this._def.errorMap,
|
|
465
465
|
path: e.path,
|
|
466
466
|
parent: e.parent
|
|
@@ -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
|
-
parsedType:
|
|
498
|
-
}, r = this._parseSync({ data: e, path:
|
|
499
|
-
return He(
|
|
497
|
+
parsedType: M(e)
|
|
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
|
|
@@ -508,61 +508,61 @@ class v {
|
|
|
508
508
|
schemaErrorMap: this._def.errorMap,
|
|
509
509
|
parent: null,
|
|
510
510
|
data: e,
|
|
511
|
-
parsedType:
|
|
511
|
+
parsedType: M(e)
|
|
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
|
-
parsedType:
|
|
551
|
-
}, r = this._parse({ data: e, path:
|
|
552
|
-
return He(
|
|
550
|
+
parsedType: M(e)
|
|
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,11 +578,11 @@ class v {
|
|
|
578
578
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
579
579
|
version: 1,
|
|
580
580
|
vendor: "zod",
|
|
581
|
-
validate: (
|
|
581
|
+
validate: (n) => this["~validate"](n)
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
584
|
optional() {
|
|
585
|
-
return
|
|
585
|
+
return V.create(this, this._def);
|
|
586
586
|
}
|
|
587
587
|
nullable() {
|
|
588
588
|
return G.create(this, this._def);
|
|
@@ -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;
|
|
@@ -691,7 +691,7 @@ function Lt(t, e) {
|
|
|
691
691
|
function Pt(t, e) {
|
|
692
692
|
return !!((e === "v4" || !e) && At.test(t) || (e === "v6" || !e) && $t.test(t));
|
|
693
693
|
}
|
|
694
|
-
class
|
|
694
|
+
class Z extends v {
|
|
695
695
|
_parse(e) {
|
|
696
696
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
697
697
|
const a = this._getOrReturnCtx(e);
|
|
@@ -701,7 +701,7 @@ class 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,72 +789,72 @@ 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) {
|
|
857
|
-
return new
|
|
857
|
+
return new Z({
|
|
858
858
|
...this._def,
|
|
859
859
|
checks: [...this._def.checks, e]
|
|
860
860
|
});
|
|
@@ -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
|
/**
|
|
@@ -990,19 +990,19 @@ class I extends v {
|
|
|
990
990
|
return this.min(1, f.errToObj(e));
|
|
991
991
|
}
|
|
992
992
|
trim() {
|
|
993
|
-
return new
|
|
993
|
+
return new Z({
|
|
994
994
|
...this._def,
|
|
995
995
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
998
|
toLowerCase() {
|
|
999
|
-
return new
|
|
999
|
+
return new Z({
|
|
1000
1000
|
...this._def,
|
|
1001
1001
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
toUpperCase() {
|
|
1005
|
-
return new
|
|
1005
|
+
return new Z({
|
|
1006
1006
|
...this._def,
|
|
1007
1007
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1008
1008
|
});
|
|
@@ -1057,25 +1057,25 @@ 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
|
}
|
|
1071
|
-
|
|
1071
|
+
Z.create = (t) => new Z({
|
|
1072
1072
|
checks: [],
|
|
1073
1073
|
typeName: m.ZodString,
|
|
1074
1074
|
coerce: t?.coerce ?? !1,
|
|
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);
|
|
@@ -1554,28 +1554,28 @@ Pe.create = (t) => new Pe({
|
|
|
1554
1554
|
typeName: m.ZodUnknown,
|
|
1555
1555
|
...g(t)
|
|
1556
1556
|
});
|
|
1557
|
-
class
|
|
1557
|
+
class B extends v {
|
|
1558
1558
|
_parse(e) {
|
|
1559
|
-
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
|
}
|
|
1567
|
-
|
|
1567
|
+
B.create = (t) => new B({
|
|
1568
1568
|
typeName: m.ZodNever,
|
|
1569
1569
|
...g(t)
|
|
1570
1570
|
});
|
|
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 L(n, i, n.path, o)))).then((i) => T.mergeArray(s, i));
|
|
1625
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new L(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] = V.create(ee(s));
|
|
1667
1667
|
}
|
|
1668
1668
|
return new w({
|
|
1669
1669
|
...t._def,
|
|
@@ -1672,7 +1672,7 @@ function ee(t) {
|
|
|
1672
1672
|
} else return t instanceof $ ? new $({
|
|
1673
1673
|
...t._def,
|
|
1674
1674
|
type: ee(t.element)
|
|
1675
|
-
}) : t instanceof
|
|
1675
|
+
}) : t instanceof V ? V.create(ee(t.unwrap())) : t instanceof G ? G.create(ee(t.unwrap())) : t instanceof z ? z.create(t.items.map((e) => ee(e))) : t;
|
|
1676
1676
|
}
|
|
1677
1677
|
class w extends v {
|
|
1678
1678
|
constructor() {
|
|
@@ -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,8 +1693,8 @@ class w extends v {
|
|
|
1693
1693
|
received: u.parsedType
|
|
1694
1694
|
}), y;
|
|
1695
1695
|
}
|
|
1696
|
-
const { status:
|
|
1697
|
-
if (!(this._def.catchall instanceof
|
|
1696
|
+
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1697
|
+
if (!(this._def.catchall instanceof B && this._def.unknownKeys === "strip"))
|
|
1698
1698
|
for (const u in r.data)
|
|
1699
1699
|
i.includes(u) || o.push(u);
|
|
1700
1700
|
const c = [];
|
|
@@ -1702,11 +1702,11 @@ class w extends v {
|
|
|
1702
1702
|
const p = a[u], k = r.data[u];
|
|
1703
1703
|
c.push({
|
|
1704
1704
|
key: { status: "valid", value: u },
|
|
1705
|
-
value: p._parse(new
|
|
1705
|
+
value: p._parse(new L(r, k, r.path, u)),
|
|
1706
1706
|
alwaysSet: u in r.data
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
1709
|
-
if (this._def.catchall instanceof
|
|
1709
|
+
if (this._def.catchall instanceof B) {
|
|
1710
1710
|
const u = this._def.unknownKeys;
|
|
1711
1711
|
if (u === "passthrough")
|
|
1712
1712
|
for (const p of o)
|
|
@@ -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;
|
|
@@ -1727,7 +1727,7 @@ class w extends v {
|
|
|
1727
1727
|
c.push({
|
|
1728
1728
|
key: { status: "valid", value: p },
|
|
1729
1729
|
value: u._parse(
|
|
1730
|
-
new
|
|
1730
|
+
new L(r, k, r.path, p)
|
|
1731
1731
|
//, ctx.child(key), value, getParsedType(value)
|
|
1732
1732
|
),
|
|
1733
1733
|
alwaysSet: p in r.data
|
|
@@ -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[
|
|
1930
|
-
for (; a instanceof
|
|
1929
|
+
let a = this.shape[s];
|
|
1930
|
+
for (; a instanceof V; )
|
|
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() {
|
|
@@ -1943,54 +1943,54 @@ class w extends v {
|
|
|
1943
1943
|
w.create = (t, e) => new w({
|
|
1944
1944
|
shape: () => t,
|
|
1945
1945
|
unknownKeys: "strip",
|
|
1946
|
-
catchall:
|
|
1946
|
+
catchall: B.create(),
|
|
1947
1947
|
typeName: m.ZodObject,
|
|
1948
1948
|
...g(e)
|
|
1949
1949
|
});
|
|
1950
1950
|
w.strictCreate = (t, e) => new w({
|
|
1951
1951
|
shape: () => t,
|
|
1952
1952
|
unknownKeys: "strict",
|
|
1953
|
-
catchall:
|
|
1953
|
+
catchall: B.create(),
|
|
1954
1954
|
typeName: m.ZodObject,
|
|
1955
1955
|
...g(e)
|
|
1956
1956
|
});
|
|
1957
1957
|
w.lazycreate = (t, e) => new w({
|
|
1958
1958
|
shape: t,
|
|
1959
1959
|
unknownKeys: "strip",
|
|
1960
|
-
catchall:
|
|
1960
|
+
catchall: B.create(),
|
|
1961
1961
|
typeName: m.ZodObject,
|
|
1962
1962
|
...g(e)
|
|
1963
1963
|
});
|
|
1964
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
|
|
1974
|
-
const i = a.map((o) => new
|
|
1975
|
-
return l(
|
|
1973
|
+
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1974
|
+
const i = a.map((o) => new D(o.ctx.common.issues));
|
|
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
|
|
2021
|
-
const o = i.map((c) => new
|
|
2022
|
-
return l(
|
|
2020
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2021
|
+
const o = i.map((c) => new D(c));
|
|
2022
|
+
return l(n, {
|
|
2023
2023
|
code: d.invalid_union,
|
|
2024
2024
|
unionErrors: o
|
|
2025
2025
|
}), y;
|
|
@@ -2034,99 +2034,99 @@ de.create = (t, e) => new de({
|
|
|
2034
2034
|
typeName: m.ZodUnion,
|
|
2035
2035
|
...g(e)
|
|
2036
2036
|
});
|
|
2037
|
-
function
|
|
2038
|
-
const
|
|
2037
|
+
function Ve(t, e) {
|
|
2038
|
+
const n = M(t), s = M(e);
|
|
2039
2039
|
if (t === e)
|
|
2040
2040
|
return { valid: !0, data: t };
|
|
2041
|
-
if (
|
|
2041
|
+
if (n === h.object && s === h.object) {
|
|
2042
2042
|
const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2043
2043
|
for (const o of a) {
|
|
2044
|
-
const c =
|
|
2044
|
+
const c = Ve(t[o], e[o]);
|
|
2045
2045
|
if (!c.valid)
|
|
2046
2046
|
return { valid: !1 };
|
|
2047
2047
|
i[o] = c.data;
|
|
2048
2048
|
}
|
|
2049
2049
|
return { valid: !0, data: i };
|
|
2050
|
-
} else if (
|
|
2050
|
+
} else if (n === h.array && s === h.array) {
|
|
2051
2051
|
if (t.length !== e.length)
|
|
2052
2052
|
return { valid: !1 };
|
|
2053
2053
|
const r = [];
|
|
2054
2054
|
for (let a = 0; a < t.length; a++) {
|
|
2055
|
-
const i = t[a], o = e[a], c =
|
|
2055
|
+
const i = t[a], o = e[a], c = Ve(i, o);
|
|
2056
2056
|
if (!c.valid)
|
|
2057
2057
|
return { valid: !1 };
|
|
2058
2058
|
r.push(c.data);
|
|
2059
2059
|
}
|
|
2060
2060
|
return { valid: !0, data: r };
|
|
2061
|
-
} else return
|
|
2061
|
+
} else return n === h.date && s === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2062
2062
|
}
|
|
2063
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
|
-
const o =
|
|
2069
|
-
return o.valid ? ((je(a) || je(i)) &&
|
|
2068
|
+
const o = Ve(a.value, i.value);
|
|
2069
|
+
return o.valid ? ((je(a) || je(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
2070
|
code: d.invalid_intersection_types
|
|
2071
2071
|
}), 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
|
|
2127
|
+
return c ? c._parse(new L(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,40 +2156,40 @@ 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
|
|
2170
|
-
value: i._parse(new
|
|
2171
|
-
alwaysSet: o in
|
|
2169
|
+
key: a._parse(new L(s, o, s.path, o)),
|
|
2170
|
+
value: i._parse(new L(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
|
-
keyType:
|
|
2185
|
+
keyType: Z.create(),
|
|
2186
2186
|
valueType: e,
|
|
2187
2187
|
typeName: m.ZodRecord,
|
|
2188
|
-
...g(
|
|
2188
|
+
...g(n)
|
|
2189
2189
|
});
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
-
class
|
|
2192
|
+
class Be extends v {
|
|
2193
2193
|
get keySchema() {
|
|
2194
2194
|
return this._def.keyType;
|
|
2195
2195
|
}
|
|
@@ -2197,27 +2197,27 @@ class Ue 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
|
|
2209
|
-
value: a._parse(new
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2208
|
+
key: r._parse(new L(s, o, s.path, [u, "key"])),
|
|
2209
|
+
value: a._parse(new L(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,92 +2225,92 @@ class Ue 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
|
-
|
|
2234
|
+
Be.create = (t, e, n) => new Be({
|
|
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 L(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,
|
|
2301
2301
|
typeName: m.ZodSet,
|
|
2302
2302
|
...g(e)
|
|
2303
2303
|
});
|
|
2304
|
-
class
|
|
2304
|
+
class Ue extends v {
|
|
2305
2305
|
get schema() {
|
|
2306
2306
|
return this._def.getter();
|
|
2307
2307
|
}
|
|
2308
2308
|
_parse(e) {
|
|
2309
|
-
const { ctx:
|
|
2310
|
-
return this._def.getter()._parse({ data:
|
|
2309
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2310
|
+
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2311
2311
|
}
|
|
2312
2312
|
}
|
|
2313
|
-
|
|
2313
|
+
Ue.create = (t, e) => new Ue({
|
|
2314
2314
|
getter: t,
|
|
2315
2315
|
typeName: m.ZodLazy,
|
|
2316
2316
|
...g(e)
|
|
@@ -2318,9 +2318,9 @@ Ve.create = (t, e) => new Ve({
|
|
|
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,91 +2460,91 @@ 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
|
-
class
|
|
2547
|
+
class V extends v {
|
|
2548
2548
|
_parse(e) {
|
|
2549
2549
|
return this._getType(e) === h.undefined ? N(void 0) : this._def.innerType._parse(e);
|
|
2550
2550
|
}
|
|
@@ -2552,7 +2552,7 @@ class B extends v {
|
|
|
2552
2552
|
return this._def.innerType;
|
|
2553
2553
|
}
|
|
2554
2554
|
}
|
|
2555
|
-
|
|
2555
|
+
V.create = (t, e) => new V({
|
|
2556
2556
|
innerType: t,
|
|
2557
2557
|
typeName: m.ZodOptional,
|
|
2558
2558
|
...g(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
|
|
2612
|
+
return new D(s.common.issues);
|
|
2613
2613
|
},
|
|
2614
|
-
input:
|
|
2614
|
+
input: s.data
|
|
2615
2615
|
})
|
|
2616
2616
|
})) : {
|
|
2617
2617
|
status: "valid",
|
|
2618
2618
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2619
2619
|
get error() {
|
|
2620
|
-
return new
|
|
2620
|
+
return new D(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;
|
|
@@ -2721,8 +2721,8 @@ var m;
|
|
|
2721
2721
|
(function(t) {
|
|
2722
2722
|
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2723
2723
|
})(m || (m = {}));
|
|
2724
|
-
const _ =
|
|
2725
|
-
|
|
2724
|
+
const _ = Z.create, it = Y.create, ke = me.create;
|
|
2725
|
+
B.create;
|
|
2726
2726
|
const A = $.create, R = w.create;
|
|
2727
2727
|
de.create;
|
|
2728
2728
|
ue.create;
|
|
@@ -2730,9 +2730,9 @@ z.create;
|
|
|
2730
2730
|
const ot = le.create;
|
|
2731
2731
|
K.create;
|
|
2732
2732
|
he.create;
|
|
2733
|
-
|
|
2733
|
+
V.create;
|
|
2734
2734
|
G.create;
|
|
2735
|
-
const
|
|
2735
|
+
const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2736
2736
|
__proto__: null,
|
|
2737
2737
|
DIRTY: te,
|
|
2738
2738
|
INVALID: y,
|
|
@@ -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,
|
|
@@ -2749,31 +2749,31 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2749
2749
|
ZodDefault: ye,
|
|
2750
2750
|
ZodEffects: F,
|
|
2751
2751
|
ZodEnum: K,
|
|
2752
|
-
ZodError:
|
|
2752
|
+
ZodError: D,
|
|
2753
2753
|
get ZodFirstPartyTypeKind() {
|
|
2754
2754
|
return m;
|
|
2755
2755
|
},
|
|
2756
2756
|
ZodIntersection: ue,
|
|
2757
2757
|
ZodIssueCode: d,
|
|
2758
|
-
ZodLazy:
|
|
2758
|
+
ZodLazy: Ue,
|
|
2759
2759
|
ZodLiteral: ze,
|
|
2760
|
-
ZodMap:
|
|
2760
|
+
ZodMap: Be,
|
|
2761
2761
|
ZodNaN: qe,
|
|
2762
2762
|
ZodNativeEnum: Fe,
|
|
2763
|
-
ZodNever:
|
|
2763
|
+
ZodNever: B,
|
|
2764
2764
|
ZodNull: De,
|
|
2765
2765
|
ZodNullable: G,
|
|
2766
2766
|
ZodNumber: Y,
|
|
2767
2767
|
ZodObject: w,
|
|
2768
|
-
ZodOptional:
|
|
2768
|
+
ZodOptional: V,
|
|
2769
2769
|
ZodParsedType: h,
|
|
2770
2770
|
ZodPipeline: xe,
|
|
2771
2771
|
ZodPromise: he,
|
|
2772
2772
|
ZodReadonly: ge,
|
|
2773
2773
|
ZodRecord: le,
|
|
2774
2774
|
ZodSchema: v,
|
|
2775
|
-
ZodSet:
|
|
2776
|
-
ZodString:
|
|
2775
|
+
ZodSet: se,
|
|
2776
|
+
ZodString: Z,
|
|
2777
2777
|
ZodSymbol: Ie,
|
|
2778
2778
|
ZodTransformer: F,
|
|
2779
2779
|
ZodTuple: z,
|
|
@@ -2785,10 +2785,10 @@ 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
|
-
getParsedType:
|
|
2791
|
+
getParsedType: M,
|
|
2792
2792
|
isAborted: Re,
|
|
2793
2793
|
isAsync: oe,
|
|
2794
2794
|
isDirty: je,
|
|
@@ -2805,33 +2805,33 @@ const Bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2805
2805
|
return b;
|
|
2806
2806
|
}
|
|
2807
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2808
|
-
_t(
|
|
2809
|
-
const
|
|
2810
|
-
const
|
|
2808
|
+
_t(Vt);
|
|
2809
|
+
const Bt = (t, e) => e.skipDedupe || e.method !== "GET", Ut = (t, e) => e.method + "@" + t, zt = (t) => t.clone(), Ft = ({ skip: t = Bt, 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(
|
|
2834
|
-
const
|
|
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
|
+
const P = e(t, k);
|
|
2835
2835
|
setTimeout(() => {
|
|
2836
2836
|
typeof r == "function" ? Promise.resolve(r({
|
|
2837
2837
|
response: S,
|
|
@@ -2843,7 +2843,7 @@ const Ut = (t, e) => e.skipDedupe || e.method !== "GET", Vt = (t, e) => e.method
|
|
|
2843
2843
|
var j, W;
|
|
2844
2844
|
x(c((j = O && O.url) !== null && j !== void 0 ? j : u, (W = O && O.options) !== null && W !== void 0 ? W : p));
|
|
2845
2845
|
}) : x(c(u, p));
|
|
2846
|
-
},
|
|
2846
|
+
}, P);
|
|
2847
2847
|
}).then(C).catch((x) => {
|
|
2848
2848
|
if (!a)
|
|
2849
2849
|
throw x;
|
|
@@ -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(
|
|
@@ -3209,17 +3209,17 @@ async function We(t, e) {
|
|
|
3209
3209
|
function be(t) {
|
|
3210
3210
|
return `'${t.replace(/'/g, "''")}'`;
|
|
3211
3211
|
}
|
|
3212
|
-
function
|
|
3212
|
+
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 ${
|
|
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,64 +3339,64 @@ 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
|
-
`${
|
|
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";
|
|
3370
3370
|
if (i && i.sort_by) {
|
|
3371
3371
|
const J = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), re = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3372
|
-
C = `ORDER BY ${
|
|
3372
|
+
C = `ORDER BY ${U(J)} ${re}`;
|
|
3373
3373
|
}
|
|
3374
|
-
const S =
|
|
3375
|
-
SELECT * FROM ${
|
|
3374
|
+
const S = s * r, E = `LIMIT ${r} OFFSET ${S}`, q = `
|
|
3375
|
+
SELECT * FROM ${U(c)}.${U(u)}
|
|
3376
3376
|
WHERE ${k}
|
|
3377
3377
|
${C}
|
|
3378
3378
|
${E}
|
|
3379
|
-
`,
|
|
3379
|
+
`, P = (await We(t, q)).map(ut);
|
|
3380
3380
|
if (!a)
|
|
3381
3381
|
return {
|
|
3382
|
-
logs:
|
|
3382
|
+
logs: P,
|
|
3383
3383
|
start: 0,
|
|
3384
3384
|
limit: 0,
|
|
3385
3385
|
length: 0
|
|
3386
3386
|
};
|
|
3387
3387
|
const O = `
|
|
3388
|
-
SELECT COUNT(*) as count FROM ${
|
|
3388
|
+
SELECT COUNT(*) as count FROM ${U(c)}.${U(u)}
|
|
3389
3389
|
WHERE ${k}
|
|
3390
3390
|
`, W = (await We(t, O))[0]?.count || 0;
|
|
3391
3391
|
return {
|
|
3392
|
-
logs:
|
|
3392
|
+
logs: P,
|
|
3393
3393
|
start: S,
|
|
3394
3394
|
limit: r,
|
|
3395
3395
|
length: Number(W)
|
|
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();
|
|
@@ -3456,7 +3456,7 @@ async function fe(t, e) {
|
|
|
3456
3456
|
clearTimeout(r);
|
|
3457
3457
|
}
|
|
3458
3458
|
}
|
|
3459
|
-
function
|
|
3459
|
+
function I(t) {
|
|
3460
3460
|
return `'${t.replace(/'/g, "''").replace(/\\/g, "\\\\")}'`;
|
|
3461
3461
|
}
|
|
3462
3462
|
function Je(t) {
|
|
@@ -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,24 +3567,26 @@ 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(
|
|
3575
|
-
WHERE index1 = ${
|
|
3576
|
-
AND blob1 = ${
|
|
3574
|
+
FROM ${Je(s)}
|
|
3575
|
+
WHERE index1 = ${I(e)}
|
|
3576
|
+
AND blob1 = ${I(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
|
|
3583
|
-
const e = {};
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
a
|
|
3587
|
-
|
|
3582
|
+
function mn(t) {
|
|
3583
|
+
const e = {}, n = /(\w+):(?:"([^"]*)"|(\S+))/g;
|
|
3584
|
+
let s;
|
|
3585
|
+
for (; (s = n.exec(t)) !== null; ) {
|
|
3586
|
+
const r = s[1], a = s[2] !== void 0 ? s[2] : s[3];
|
|
3587
|
+
!r || a === void 0 || (e[r] || (e[r] = []), e[r].push(a));
|
|
3588
|
+
}
|
|
3589
|
+
return e;
|
|
3588
3590
|
}
|
|
3589
3591
|
function ht(t) {
|
|
3590
3592
|
return {
|
|
@@ -3607,39 +3609,49 @@ function ht(t) {
|
|
|
3607
3609
|
hostname: "blob17"
|
|
3608
3610
|
}[t] || null;
|
|
3609
3611
|
}
|
|
3610
|
-
function
|
|
3612
|
+
function yn(t) {
|
|
3611
3613
|
const e = [];
|
|
3612
|
-
for (const [
|
|
3613
|
-
|
|
3614
|
-
if (
|
|
3615
|
-
|
|
3614
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3615
|
+
const r = s.filter((i) => i !== "");
|
|
3616
|
+
if (r.length === 0) continue;
|
|
3617
|
+
if (n === "success") {
|
|
3618
|
+
const i = [], o = /* @__PURE__ */ new Set();
|
|
3619
|
+
for (const c of r)
|
|
3620
|
+
o.has(c) || (o.add(c), c === "true" ? i.push("blob3 LIKE 's%'") : c === "false" && i.push("blob3 LIKE 'f%'"));
|
|
3621
|
+
i.length > 0 && e.push(`(${i.join(" OR ")})`);
|
|
3616
3622
|
continue;
|
|
3617
3623
|
}
|
|
3618
|
-
const
|
|
3619
|
-
|
|
3624
|
+
const a = ht(n);
|
|
3625
|
+
if (a)
|
|
3626
|
+
if (r.length === 1)
|
|
3627
|
+
e.push(`${a} = ${I(r[0])}`);
|
|
3628
|
+
else {
|
|
3629
|
+
const i = r.map((o) => I(o)).join(", ");
|
|
3630
|
+
e.push(`${a} IN (${i})`);
|
|
3631
|
+
}
|
|
3620
3632
|
}
|
|
3621
3633
|
return e;
|
|
3622
3634
|
}
|
|
3623
|
-
function
|
|
3635
|
+
function _n(t) {
|
|
3624
3636
|
if (t === "date")
|
|
3625
3637
|
return "double2";
|
|
3626
3638
|
const e = ht(t);
|
|
3627
3639
|
return e || "timestamp";
|
|
3628
3640
|
}
|
|
3629
|
-
function
|
|
3630
|
-
return async (e,
|
|
3631
|
-
const { page:
|
|
3641
|
+
function gn(t) {
|
|
3642
|
+
return async (e, n = {}) => {
|
|
3643
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs", u = [`index1 = ${I(e)}`];
|
|
3632
3644
|
if (o) {
|
|
3633
|
-
const O =
|
|
3634
|
-
u.push(...
|
|
3645
|
+
const O = mn(o);
|
|
3646
|
+
u.push(...yn(O));
|
|
3635
3647
|
}
|
|
3636
3648
|
const p = u.join(" AND ");
|
|
3637
3649
|
let k = "ORDER BY timestamp DESC";
|
|
3638
3650
|
if (i && i.sort_by) {
|
|
3639
|
-
const O =
|
|
3651
|
+
const O = _n(i.sort_by), j = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3640
3652
|
k = `ORDER BY ${O} ${j}`;
|
|
3641
3653
|
}
|
|
3642
|
-
const C =
|
|
3654
|
+
const C = s * r, S = `LIMIT ${r} OFFSET ${C}`, E = `
|
|
3643
3655
|
SELECT *
|
|
3644
3656
|
FROM ${Je(c)}
|
|
3645
3657
|
WHERE ${p}
|
|
@@ -3653,13 +3665,13 @@ function _s(t) {
|
|
|
3653
3665
|
limit: 0,
|
|
3654
3666
|
length: 0
|
|
3655
3667
|
};
|
|
3656
|
-
const
|
|
3668
|
+
const P = `
|
|
3657
3669
|
SELECT count() as count
|
|
3658
3670
|
FROM ${Je(c)}
|
|
3659
3671
|
WHERE ${p}
|
|
3660
3672
|
`;
|
|
3661
3673
|
try {
|
|
3662
|
-
const j = (await fe(t,
|
|
3674
|
+
const j = (await fe(t, P))[0]?.count || 0;
|
|
3663
3675
|
return {
|
|
3664
3676
|
logs: x,
|
|
3665
3677
|
start: C,
|
|
@@ -3689,23 +3701,23 @@ const Ye = [
|
|
|
3689
3701
|
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3690
3702
|
"ssa"
|
|
3691
3703
|
// SUCCESS_SILENT_AUTH
|
|
3692
|
-
],
|
|
3704
|
+
], vn = ["pwd_leak", "signup_pwd_leak", "reset_pwd_leak"];
|
|
3693
3705
|
function Ke(t) {
|
|
3694
3706
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3695
3707
|
}
|
|
3696
3708
|
function Ge(t) {
|
|
3697
3709
|
return t.toISOString().split("T")[0];
|
|
3698
3710
|
}
|
|
3699
|
-
function
|
|
3711
|
+
function Tn(t) {
|
|
3700
3712
|
const e = t.dataset || "authhero_logs";
|
|
3701
3713
|
return {
|
|
3702
|
-
async getDaily(
|
|
3703
|
-
const { from: r, to: a } =
|
|
3714
|
+
async getDaily(n, s = {}) {
|
|
3715
|
+
const { from: r, to: a } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3704
3716
|
o.setDate(o.getDate() - 30);
|
|
3705
|
-
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) =>
|
|
3717
|
+
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) => I(x)).join(
|
|
3706
3718
|
", "
|
|
3707
|
-
), S =
|
|
3708
|
-
(x) =>
|
|
3719
|
+
), S = vn.map(
|
|
3720
|
+
(x) => I(x)
|
|
3709
3721
|
).join(", "), E = `
|
|
3710
3722
|
SELECT
|
|
3711
3723
|
toDate(toDateTime(double2 / 1000)) AS date,
|
|
@@ -3715,7 +3727,7 @@ function Cs(t) {
|
|
|
3715
3727
|
MIN(double2) AS first_event,
|
|
3716
3728
|
MAX(double2) AS last_event
|
|
3717
3729
|
FROM "${e}"
|
|
3718
|
-
WHERE index1 = ${
|
|
3730
|
+
WHERE index1 = ${I(n)}
|
|
3719
3731
|
AND double2 >= ${p}
|
|
3720
3732
|
AND double2 <= ${k}
|
|
3721
3733
|
GROUP BY date
|
|
@@ -3730,15 +3742,15 @@ function Cs(t) {
|
|
|
3730
3742
|
updated_at: x.last_event ? new Date(Number(x.last_event)).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
3731
3743
|
}));
|
|
3732
3744
|
},
|
|
3733
|
-
async getActiveUsers(
|
|
3734
|
-
const
|
|
3735
|
-
|
|
3736
|
-
const r =
|
|
3745
|
+
async getActiveUsers(n) {
|
|
3746
|
+
const s = /* @__PURE__ */ new Date();
|
|
3747
|
+
s.setDate(s.getDate() - 30);
|
|
3748
|
+
const r = s.getTime(), a = Ye.map((u) => I(u)).join(
|
|
3737
3749
|
", "
|
|
3738
3750
|
), i = `
|
|
3739
3751
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3740
3752
|
FROM "${e}"
|
|
3741
|
-
WHERE index1 = ${
|
|
3753
|
+
WHERE index1 = ${I(n)}
|
|
3742
3754
|
AND double2 >= ${r}
|
|
3743
3755
|
AND blob3 IN (${a})
|
|
3744
3756
|
AND blob7 IS NOT NULL
|
|
@@ -3748,26 +3760,26 @@ function Cs(t) {
|
|
|
3748
3760
|
}
|
|
3749
3761
|
};
|
|
3750
3762
|
}
|
|
3751
|
-
function
|
|
3763
|
+
function bn(t) {
|
|
3752
3764
|
return t.analyticsEngineBinding || console.warn(
|
|
3753
3765
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3754
3766
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
3755
3767
|
"Analytics Engine: accountId and apiToken are required for querying logs via SQL API."
|
|
3756
3768
|
), {
|
|
3757
|
-
create:
|
|
3758
|
-
list:
|
|
3759
|
-
get:
|
|
3769
|
+
create: hn(t),
|
|
3770
|
+
list: gn(t),
|
|
3771
|
+
get: pn(t)
|
|
3760
3772
|
};
|
|
3761
3773
|
}
|
|
3762
|
-
function
|
|
3774
|
+
function xn() {
|
|
3763
3775
|
return {
|
|
3764
3776
|
async getGeoInfo(t) {
|
|
3765
3777
|
try {
|
|
3766
|
-
const e = t["cf-ipcountry"],
|
|
3778
|
+
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"];
|
|
3767
3779
|
return e ? {
|
|
3768
3780
|
country_code: e,
|
|
3769
|
-
city_name:
|
|
3770
|
-
latitude:
|
|
3781
|
+
city_name: n || "",
|
|
3782
|
+
latitude: s || "",
|
|
3771
3783
|
longitude: r || "",
|
|
3772
3784
|
time_zone: a || "",
|
|
3773
3785
|
continent_code: i || ""
|
|
@@ -3778,7 +3790,7 @@ function bs() {
|
|
|
3778
3790
|
}
|
|
3779
3791
|
};
|
|
3780
3792
|
}
|
|
3781
|
-
function
|
|
3793
|
+
function kn(t) {
|
|
3782
3794
|
return `// Auto-generated AuthHero code hook worker
|
|
3783
3795
|
|
|
3784
3796
|
const fnNames = {
|
|
@@ -3884,21 +3896,21 @@ export default {
|
|
|
3884
3896
|
};
|
|
3885
3897
|
`;
|
|
3886
3898
|
}
|
|
3887
|
-
class
|
|
3899
|
+
class En {
|
|
3888
3900
|
config;
|
|
3889
3901
|
constructor(e) {
|
|
3890
3902
|
this.config = e;
|
|
3891
3903
|
}
|
|
3892
3904
|
async execute(e) {
|
|
3893
|
-
const
|
|
3905
|
+
const n = Date.now();
|
|
3894
3906
|
if (!e.hookCodeId)
|
|
3895
3907
|
return {
|
|
3896
3908
|
success: !1,
|
|
3897
3909
|
error: "CloudflareCodeExecutor requires hookCodeId",
|
|
3898
|
-
durationMs: Date.now() -
|
|
3910
|
+
durationMs: Date.now() - n,
|
|
3899
3911
|
apiCalls: []
|
|
3900
3912
|
};
|
|
3901
|
-
const
|
|
3913
|
+
const s = `hook-${e.hookCodeId}`, r = JSON.stringify({
|
|
3902
3914
|
triggerId: e.triggerId,
|
|
3903
3915
|
event: e.event
|
|
3904
3916
|
});
|
|
@@ -3906,7 +3918,7 @@ class Ts {
|
|
|
3906
3918
|
let a;
|
|
3907
3919
|
if (this.config.dispatcher)
|
|
3908
3920
|
a = await this.config.dispatcher.get(
|
|
3909
|
-
|
|
3921
|
+
s,
|
|
3910
3922
|
{},
|
|
3911
3923
|
{ limits: { cpuMs: e.cpuLimitMs ?? 5e3 } }
|
|
3912
3924
|
).fetch(
|
|
@@ -3917,7 +3929,7 @@ class Ts {
|
|
|
3917
3929
|
})
|
|
3918
3930
|
);
|
|
3919
3931
|
else if (this.config.dispatchUrl)
|
|
3920
|
-
a = await fetch(`${this.config.dispatchUrl}/${
|
|
3932
|
+
a = await fetch(`${this.config.dispatchUrl}/${s}`, {
|
|
3921
3933
|
method: "POST",
|
|
3922
3934
|
headers: {
|
|
3923
3935
|
"Content-Type": "application/json",
|
|
@@ -3929,7 +3941,7 @@ class Ts {
|
|
|
3929
3941
|
return {
|
|
3930
3942
|
success: !1,
|
|
3931
3943
|
error: "No dispatcher binding or dispatchUrl configured",
|
|
3932
|
-
durationMs: Date.now() -
|
|
3944
|
+
durationMs: Date.now() - n,
|
|
3933
3945
|
apiCalls: []
|
|
3934
3946
|
};
|
|
3935
3947
|
if (!a.ok) {
|
|
@@ -3937,19 +3949,19 @@ class Ts {
|
|
|
3937
3949
|
return {
|
|
3938
3950
|
success: !1,
|
|
3939
3951
|
error: `Worker invocation failed (${a.status}): ${o}`,
|
|
3940
|
-
durationMs: Date.now() -
|
|
3952
|
+
durationMs: Date.now() - n,
|
|
3941
3953
|
apiCalls: []
|
|
3942
3954
|
};
|
|
3943
3955
|
}
|
|
3944
3956
|
return {
|
|
3945
3957
|
...await a.json(),
|
|
3946
|
-
durationMs: Date.now() -
|
|
3958
|
+
durationMs: Date.now() - n
|
|
3947
3959
|
};
|
|
3948
3960
|
} catch (a) {
|
|
3949
3961
|
return {
|
|
3950
3962
|
success: !1,
|
|
3951
3963
|
error: a instanceof Error ? a.message : String(a),
|
|
3952
|
-
durationMs: Date.now() -
|
|
3964
|
+
durationMs: Date.now() - n,
|
|
3953
3965
|
apiCalls: []
|
|
3954
3966
|
};
|
|
3955
3967
|
}
|
|
@@ -3958,8 +3970,8 @@ class Ts {
|
|
|
3958
3970
|
* Deploy user code as a worker to the dispatch namespace.
|
|
3959
3971
|
* Wraps the code in a worker template and uploads via Cloudflare API.
|
|
3960
3972
|
*/
|
|
3961
|
-
async deploy(e,
|
|
3962
|
-
const
|
|
3973
|
+
async deploy(e, n) {
|
|
3974
|
+
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({
|
|
3963
3975
|
main_module: "index.js",
|
|
3964
3976
|
compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
|
|
3965
3977
|
}), o = new FormData();
|
|
@@ -3981,7 +3993,7 @@ class Ts {
|
|
|
3981
3993
|
if (!c.ok) {
|
|
3982
3994
|
const u = await c.text();
|
|
3983
3995
|
throw new Error(
|
|
3984
|
-
`Failed to deploy hook worker ${
|
|
3996
|
+
`Failed to deploy hook worker ${s}: ${c.status} ${u}`
|
|
3985
3997
|
);
|
|
3986
3998
|
}
|
|
3987
3999
|
}
|
|
@@ -3989,7 +4001,7 @@ class Ts {
|
|
|
3989
4001
|
* Remove a user worker from the dispatch namespace.
|
|
3990
4002
|
*/
|
|
3991
4003
|
async remove(e) {
|
|
3992
|
-
const
|
|
4004
|
+
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, {
|
|
3993
4005
|
method: "DELETE",
|
|
3994
4006
|
headers: {
|
|
3995
4007
|
Authorization: `Bearer ${this.config.apiToken}`
|
|
@@ -3998,16 +4010,16 @@ class Ts {
|
|
|
3998
4010
|
if (!r.ok && r.status !== 404) {
|
|
3999
4011
|
const a = await r.text();
|
|
4000
4012
|
throw new Error(
|
|
4001
|
-
`Failed to remove hook worker ${
|
|
4013
|
+
`Failed to remove hook worker ${n}: ${r.status} ${a}`
|
|
4002
4014
|
);
|
|
4003
4015
|
}
|
|
4004
4016
|
}
|
|
4005
4017
|
}
|
|
4006
|
-
function
|
|
4018
|
+
function On(t) {
|
|
4007
4019
|
const e = {
|
|
4008
|
-
customDomains:
|
|
4020
|
+
customDomains: en(t),
|
|
4009
4021
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
4010
|
-
cache:
|
|
4022
|
+
cache: nn({
|
|
4011
4023
|
...t.cacheName && { cacheName: t.cacheName },
|
|
4012
4024
|
...t.defaultTtlSeconds !== void 0 && {
|
|
4013
4025
|
defaultTtlSeconds: t.defaultTtlSeconds
|
|
@@ -4016,18 +4028,18 @@ function Es(t) {
|
|
|
4016
4028
|
}),
|
|
4017
4029
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
4018
4030
|
// passed at request time via getGeoInfo(headers)
|
|
4019
|
-
geo:
|
|
4031
|
+
geo: xn()
|
|
4020
4032
|
};
|
|
4021
|
-
return t.r2SqlLogs ? e.logs =
|
|
4033
|
+
return t.r2SqlLogs ? e.logs = ln(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = bn(
|
|
4022
4034
|
t.analyticsEngineLogs
|
|
4023
4035
|
)), e;
|
|
4024
4036
|
}
|
|
4025
4037
|
export {
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4038
|
+
En as CloudflareCodeExecutor,
|
|
4039
|
+
bn as createAnalyticsEngineLogsAdapter,
|
|
4040
|
+
Tn as createAnalyticsEngineStatsAdapter,
|
|
4041
|
+
ln as createR2SQLLogsAdapter,
|
|
4042
|
+
Cn as createR2SQLStatsAdapter,
|
|
4043
|
+
On as default,
|
|
4044
|
+
kn as generateWorkerScript
|
|
4033
4045
|
};
|