@authhero/cloudflare-adapter 2.17.19 → 2.17.21
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 +33 -33
- package/dist/cloudflare-adapter.mjs +976 -1200
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { verificationMethodsSchema as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
1
|
+
import { verificationMethodsSchema as ht } from "@authhero/adapter-interfaces";
|
|
2
|
+
import ft from "wretch";
|
|
3
|
+
function pt(t, e) {
|
|
4
4
|
var n = {};
|
|
5
5
|
for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
|
|
6
6
|
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -8,46 +8,46 @@ function xt(t, e) {
|
|
|
8
8
|
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[r]) && (n[s[r]] = t[s[r]]);
|
|
9
9
|
return n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function mt(t, e) {
|
|
12
12
|
var n;
|
|
13
13
|
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function re(t, e) {
|
|
16
16
|
const n = t.ZodType.prototype[e];
|
|
17
17
|
t.ZodType.prototype[e] = function(...s) {
|
|
18
18
|
const r = n.apply(this, s);
|
|
19
19
|
return r._def.openapi = this._def.openapi, r;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function yt(t) {
|
|
23
23
|
if (typeof t.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
25
|
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
|
-
var i, o, c,
|
|
27
|
-
const
|
|
28
|
-
param: Object.assign(Object.assign({}, (
|
|
29
|
-
} : void 0),
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
return
|
|
26
|
+
var i, o, c, u, p, k;
|
|
27
|
+
const T = typeof r == "string" ? a : r, S = T ?? {}, { param: E } = S, q = pt(S, ["param"]), x = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0), L = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), q), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || E ? {
|
|
28
|
+
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(L).length > 0 ? { metadata: L } : void 0) }));
|
|
30
|
+
if (mt(this, "ZodObject")) {
|
|
31
|
+
const I = this.extend;
|
|
32
|
+
O.extend = function(...W) {
|
|
33
|
+
var Q, se, we, Se, Te, Ce, Ee;
|
|
34
|
+
const Oe = I.apply(this, W);
|
|
35
|
+
return Oe._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((se = (Q = this._def.openapi) === null || Q === void 0 ? void 0 : Q._internal) === null || se === void 0) && se.refId ? { refId: (Se = (we = this._def.openapi) === null || we === void 0 ? void 0 : we._internal) === null || Se === void 0 ? void 0 : Se.refId, schema: this } : (Ce = (Te = this._def.openapi) === null || Te === void 0 ? void 0 : Te._internal) === null || Ce === void 0 ? void 0 : Ce.extendedFrom
|
|
38
38
|
},
|
|
39
|
-
metadata: (
|
|
40
|
-
},
|
|
39
|
+
metadata: (Ee = Oe._def.openapi) === null || Ee === void 0 ? void 0 : Ee.metadata
|
|
40
|
+
}, Oe;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
return
|
|
44
|
-
},
|
|
43
|
+
return O;
|
|
44
|
+
}, re(t, "optional"), re(t, "nullable"), re(t, "default"), re(t, "transform"), re(t, "refine");
|
|
45
45
|
const e = t.ZodObject.prototype.deepPartial;
|
|
46
46
|
t.ZodObject.prototype.deepPartial = function() {
|
|
47
47
|
const r = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
48
48
|
return Object.entries(i).forEach(([o, c]) => {
|
|
49
|
-
var
|
|
50
|
-
c._def.openapi = (
|
|
49
|
+
var u, p;
|
|
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
53
|
const n = t.ZodObject.prototype.pick;
|
|
@@ -61,7 +61,7 @@ function wt(t) {
|
|
|
61
61
|
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var ae = class extends Error {
|
|
65
65
|
res;
|
|
66
66
|
status;
|
|
67
67
|
/**
|
|
@@ -124,15 +124,15 @@ var b;
|
|
|
124
124
|
}
|
|
125
125
|
t.joinValues = s, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
126
126
|
})(b || (b = {}));
|
|
127
|
-
var
|
|
127
|
+
var Re;
|
|
128
128
|
(function(t) {
|
|
129
129
|
t.mergeShapes = (e, n) => ({
|
|
130
130
|
...e,
|
|
131
131
|
...n
|
|
132
132
|
// second overwrites first
|
|
133
133
|
});
|
|
134
|
-
})(
|
|
135
|
-
const
|
|
134
|
+
})(Re || (Re = {}));
|
|
135
|
+
const h = b.arrayToEnum([
|
|
136
136
|
"string",
|
|
137
137
|
"nan",
|
|
138
138
|
"number",
|
|
@@ -153,28 +153,28 @@ const f = b.arrayToEnum([
|
|
|
153
153
|
"never",
|
|
154
154
|
"map",
|
|
155
155
|
"set"
|
|
156
|
-
]),
|
|
156
|
+
]), P = (t) => {
|
|
157
157
|
switch (typeof t) {
|
|
158
158
|
case "undefined":
|
|
159
|
-
return
|
|
159
|
+
return h.undefined;
|
|
160
160
|
case "string":
|
|
161
|
-
return
|
|
161
|
+
return h.string;
|
|
162
162
|
case "number":
|
|
163
|
-
return Number.isNaN(t) ?
|
|
163
|
+
return Number.isNaN(t) ? h.nan : h.number;
|
|
164
164
|
case "boolean":
|
|
165
|
-
return
|
|
165
|
+
return h.boolean;
|
|
166
166
|
case "function":
|
|
167
|
-
return
|
|
167
|
+
return h.function;
|
|
168
168
|
case "bigint":
|
|
169
|
-
return
|
|
169
|
+
return h.bigint;
|
|
170
170
|
case "symbol":
|
|
171
|
-
return
|
|
171
|
+
return h.symbol;
|
|
172
172
|
case "object":
|
|
173
|
-
return Array.isArray(t) ?
|
|
173
|
+
return Array.isArray(t) ? h.array : t === null ? h.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? h.promise : typeof Map < "u" && t instanceof Map ? h.map : typeof Set < "u" && t instanceof Set ? h.set : typeof Date < "u" && t instanceof Date ? h.date : h.object;
|
|
174
174
|
default:
|
|
175
|
-
return
|
|
175
|
+
return h.unknown;
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, d = b.arrayToEnum([
|
|
178
178
|
"invalid_type",
|
|
179
179
|
"invalid_literal",
|
|
180
180
|
"custom",
|
|
@@ -191,8 +191,8 @@ const f = b.arrayToEnum([
|
|
|
191
191
|
"invalid_intersection_types",
|
|
192
192
|
"not_multiple_of",
|
|
193
193
|
"not_finite"
|
|
194
|
-
])
|
|
195
|
-
class
|
|
194
|
+
]);
|
|
195
|
+
class Z extends Error {
|
|
196
196
|
get errors() {
|
|
197
197
|
return this.issues;
|
|
198
198
|
}
|
|
@@ -221,15 +221,15 @@ class N extends Error {
|
|
|
221
221
|
else {
|
|
222
222
|
let o = s, c = 0;
|
|
223
223
|
for (; c < i.path.length; ) {
|
|
224
|
-
const
|
|
225
|
-
c === i.path.length - 1 ? (o[
|
|
224
|
+
const u = i.path[c];
|
|
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
229
|
return r(this), s;
|
|
230
230
|
}
|
|
231
231
|
static assert(e) {
|
|
232
|
-
if (!(e instanceof
|
|
232
|
+
if (!(e instanceof Z))
|
|
233
233
|
throw new Error(`Not a ZodError: ${e}`);
|
|
234
234
|
}
|
|
235
235
|
toString() {
|
|
@@ -255,56 +255,56 @@ class N extends Error {
|
|
|
255
255
|
return this.flatten();
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
const
|
|
258
|
+
Z.create = (t) => new Z(t);
|
|
259
|
+
const pe = (t, e) => {
|
|
260
260
|
let n;
|
|
261
261
|
switch (t.code) {
|
|
262
|
-
case
|
|
263
|
-
t.received ===
|
|
262
|
+
case d.invalid_type:
|
|
263
|
+
t.received === h.undefined ? n = "Required" : n = `Expected ${t.expected}, received ${t.received}`;
|
|
264
264
|
break;
|
|
265
|
-
case
|
|
265
|
+
case d.invalid_literal:
|
|
266
266
|
n = `Invalid literal value, expected ${JSON.stringify(t.expected, b.jsonStringifyReplacer)}`;
|
|
267
267
|
break;
|
|
268
|
-
case
|
|
268
|
+
case d.unrecognized_keys:
|
|
269
269
|
n = `Unrecognized key(s) in object: ${b.joinValues(t.keys, ", ")}`;
|
|
270
270
|
break;
|
|
271
|
-
case
|
|
271
|
+
case d.invalid_union:
|
|
272
272
|
n = "Invalid input";
|
|
273
273
|
break;
|
|
274
|
-
case
|
|
274
|
+
case d.invalid_union_discriminator:
|
|
275
275
|
n = `Invalid discriminator value. Expected ${b.joinValues(t.options)}`;
|
|
276
276
|
break;
|
|
277
|
-
case
|
|
277
|
+
case d.invalid_enum_value:
|
|
278
278
|
n = `Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;
|
|
279
279
|
break;
|
|
280
|
-
case
|
|
280
|
+
case d.invalid_arguments:
|
|
281
281
|
n = "Invalid function arguments";
|
|
282
282
|
break;
|
|
283
|
-
case
|
|
283
|
+
case d.invalid_return_type:
|
|
284
284
|
n = "Invalid function return type";
|
|
285
285
|
break;
|
|
286
|
-
case
|
|
286
|
+
case d.invalid_date:
|
|
287
287
|
n = "Invalid date";
|
|
288
288
|
break;
|
|
289
|
-
case
|
|
289
|
+
case d.invalid_string:
|
|
290
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
|
-
case
|
|
292
|
+
case d.too_small:
|
|
293
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
|
-
case
|
|
295
|
+
case d.too_big:
|
|
296
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
|
-
case
|
|
298
|
+
case d.custom:
|
|
299
299
|
n = "Invalid input";
|
|
300
300
|
break;
|
|
301
|
-
case
|
|
301
|
+
case d.invalid_intersection_types:
|
|
302
302
|
n = "Intersection results could not be merged";
|
|
303
303
|
break;
|
|
304
|
-
case
|
|
304
|
+
case d.not_multiple_of:
|
|
305
305
|
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
306
306
|
break;
|
|
307
|
-
case
|
|
307
|
+
case d.not_finite:
|
|
308
308
|
n = "Number must be finite";
|
|
309
309
|
break;
|
|
310
310
|
default:
|
|
@@ -312,14 +312,11 @@ const oe = (t, e) => {
|
|
|
312
312
|
}
|
|
313
313
|
return { message: n };
|
|
314
314
|
};
|
|
315
|
-
let
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
function Ne() {
|
|
320
|
-
return ot;
|
|
315
|
+
let _t = pe;
|
|
316
|
+
function Ge() {
|
|
317
|
+
return _t;
|
|
321
318
|
}
|
|
322
|
-
const
|
|
319
|
+
const Xe = (t) => {
|
|
323
320
|
const { data: e, path: n, errorMaps: s, issueData: r } = t, a = [...n, ...r.path || []], i = {
|
|
324
321
|
...r,
|
|
325
322
|
path: a
|
|
@@ -331,17 +328,17 @@ const Re = (t) => {
|
|
|
331
328
|
message: r.message
|
|
332
329
|
};
|
|
333
330
|
let o = "";
|
|
334
|
-
const c = s.filter((
|
|
335
|
-
for (const
|
|
336
|
-
o =
|
|
331
|
+
const c = s.filter((u) => !!u).slice().reverse();
|
|
332
|
+
for (const u of c)
|
|
333
|
+
o = u(i, { data: e, defaultError: o }).message;
|
|
337
334
|
return {
|
|
338
335
|
...r,
|
|
339
336
|
path: a,
|
|
340
337
|
message: o
|
|
341
338
|
};
|
|
342
|
-
}
|
|
339
|
+
};
|
|
343
340
|
function l(t, e) {
|
|
344
|
-
const n =
|
|
341
|
+
const n = Ge(), s = Xe({
|
|
345
342
|
issueData: e,
|
|
346
343
|
data: t.data,
|
|
347
344
|
path: t.path,
|
|
@@ -352,13 +349,13 @@ function l(t, e) {
|
|
|
352
349
|
// then schema-bound map if available
|
|
353
350
|
n,
|
|
354
351
|
// then global override map
|
|
355
|
-
n ===
|
|
352
|
+
n === pe ? void 0 : pe
|
|
356
353
|
// then global default map
|
|
357
354
|
].filter((r) => !!r)
|
|
358
355
|
});
|
|
359
356
|
t.common.issues.push(s);
|
|
360
357
|
}
|
|
361
|
-
class
|
|
358
|
+
class C {
|
|
362
359
|
constructor() {
|
|
363
360
|
this.value = "valid";
|
|
364
361
|
}
|
|
@@ -372,7 +369,7 @@ class E {
|
|
|
372
369
|
const s = [];
|
|
373
370
|
for (const r of n) {
|
|
374
371
|
if (r.status === "aborted")
|
|
375
|
-
return
|
|
372
|
+
return y;
|
|
376
373
|
r.status === "dirty" && e.dirty(), s.push(r.value);
|
|
377
374
|
}
|
|
378
375
|
return { status: e.value, value: s };
|
|
@@ -386,27 +383,27 @@ class E {
|
|
|
386
383
|
value: i
|
|
387
384
|
});
|
|
388
385
|
}
|
|
389
|
-
return
|
|
386
|
+
return C.mergeObjectSync(e, s);
|
|
390
387
|
}
|
|
391
388
|
static mergeObjectSync(e, n) {
|
|
392
389
|
const s = {};
|
|
393
390
|
for (const r of n) {
|
|
394
391
|
const { key: a, value: i } = r;
|
|
395
392
|
if (a.status === "aborted" || i.status === "aborted")
|
|
396
|
-
return
|
|
393
|
+
return y;
|
|
397
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);
|
|
398
395
|
}
|
|
399
396
|
return { status: e.value, value: s };
|
|
400
397
|
}
|
|
401
398
|
}
|
|
402
|
-
const
|
|
399
|
+
const y = Object.freeze({
|
|
403
400
|
status: "aborted"
|
|
404
|
-
}),
|
|
405
|
-
var
|
|
401
|
+
}), ee = (t) => ({ status: "dirty", value: t }), N = (t) => ({ status: "valid", value: t }), $e = (t) => t.status === "aborted", Ie = (t) => t.status === "dirty", H = (t) => t.status === "valid", ie = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
402
|
+
var f;
|
|
406
403
|
(function(t) {
|
|
407
404
|
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
408
|
-
})(
|
|
409
|
-
class
|
|
405
|
+
})(f || (f = {}));
|
|
406
|
+
class D {
|
|
410
407
|
constructor(e, n, s, r) {
|
|
411
408
|
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key = r;
|
|
412
409
|
}
|
|
@@ -414,8 +411,8 @@ class M {
|
|
|
414
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;
|
|
415
412
|
}
|
|
416
413
|
}
|
|
417
|
-
const
|
|
418
|
-
if (
|
|
414
|
+
const He = (t, e) => {
|
|
415
|
+
if (H(e))
|
|
419
416
|
return { success: !0, data: e.value };
|
|
420
417
|
if (!t.common.issues.length)
|
|
421
418
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -424,12 +421,12 @@ const tt = (t, e) => {
|
|
|
424
421
|
get error() {
|
|
425
422
|
if (this._error)
|
|
426
423
|
return this._error;
|
|
427
|
-
const n = new
|
|
424
|
+
const n = new Z(t.common.issues);
|
|
428
425
|
return this._error = n, this._error;
|
|
429
426
|
}
|
|
430
427
|
};
|
|
431
428
|
};
|
|
432
|
-
function
|
|
429
|
+
function g(t) {
|
|
433
430
|
if (!t)
|
|
434
431
|
return {};
|
|
435
432
|
const { errorMap: e, invalid_type_error: n, required_error: s, description: r } = t;
|
|
@@ -445,13 +442,13 @@ class v {
|
|
|
445
442
|
return this._def.description;
|
|
446
443
|
}
|
|
447
444
|
_getType(e) {
|
|
448
|
-
return
|
|
445
|
+
return P(e.data);
|
|
449
446
|
}
|
|
450
447
|
_getOrReturnCtx(e, n) {
|
|
451
448
|
return n || {
|
|
452
449
|
common: e.parent.common,
|
|
453
450
|
data: e.data,
|
|
454
|
-
parsedType:
|
|
451
|
+
parsedType: P(e.data),
|
|
455
452
|
schemaErrorMap: this._def.errorMap,
|
|
456
453
|
path: e.path,
|
|
457
454
|
parent: e.parent
|
|
@@ -459,11 +456,11 @@ class v {
|
|
|
459
456
|
}
|
|
460
457
|
_processInputParams(e) {
|
|
461
458
|
return {
|
|
462
|
-
status: new
|
|
459
|
+
status: new C(),
|
|
463
460
|
ctx: {
|
|
464
461
|
common: e.parent.common,
|
|
465
462
|
data: e.data,
|
|
466
|
-
parsedType:
|
|
463
|
+
parsedType: P(e.data),
|
|
467
464
|
schemaErrorMap: this._def.errorMap,
|
|
468
465
|
path: e.path,
|
|
469
466
|
parent: e.parent
|
|
@@ -472,7 +469,7 @@ class v {
|
|
|
472
469
|
}
|
|
473
470
|
_parseSync(e) {
|
|
474
471
|
const n = this._parse(e);
|
|
475
|
-
if (
|
|
472
|
+
if (ie(n))
|
|
476
473
|
throw new Error("Synchronous parse encountered promise.");
|
|
477
474
|
return n;
|
|
478
475
|
}
|
|
@@ -497,9 +494,9 @@ class v {
|
|
|
497
494
|
schemaErrorMap: this._def.errorMap,
|
|
498
495
|
parent: null,
|
|
499
496
|
data: e,
|
|
500
|
-
parsedType:
|
|
497
|
+
parsedType: P(e)
|
|
501
498
|
}, r = this._parseSync({ data: e, path: s.path, parent: s });
|
|
502
|
-
return
|
|
499
|
+
return He(s, r);
|
|
503
500
|
}
|
|
504
501
|
"~validate"(e) {
|
|
505
502
|
const n = {
|
|
@@ -511,12 +508,12 @@ class v {
|
|
|
511
508
|
schemaErrorMap: this._def.errorMap,
|
|
512
509
|
parent: null,
|
|
513
510
|
data: e,
|
|
514
|
-
parsedType:
|
|
511
|
+
parsedType: P(e)
|
|
515
512
|
};
|
|
516
513
|
if (!this["~standard"].async)
|
|
517
514
|
try {
|
|
518
515
|
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
519
|
-
return
|
|
516
|
+
return H(s) ? {
|
|
520
517
|
value: s.value
|
|
521
518
|
} : {
|
|
522
519
|
issues: n.common.issues
|
|
@@ -527,7 +524,7 @@ class v {
|
|
|
527
524
|
async: !0
|
|
528
525
|
};
|
|
529
526
|
}
|
|
530
|
-
return this._parseAsync({ data: e, path: [], parent: n }).then((s) =>
|
|
527
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((s) => H(s) ? {
|
|
531
528
|
value: s.value
|
|
532
529
|
} : {
|
|
533
530
|
issues: n.common.issues
|
|
@@ -550,15 +547,15 @@ class v {
|
|
|
550
547
|
schemaErrorMap: this._def.errorMap,
|
|
551
548
|
parent: null,
|
|
552
549
|
data: e,
|
|
553
|
-
parsedType:
|
|
554
|
-
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (
|
|
555
|
-
return
|
|
550
|
+
parsedType: P(e)
|
|
551
|
+
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (ie(r) ? r : Promise.resolve(r));
|
|
552
|
+
return He(s, a);
|
|
556
553
|
}
|
|
557
554
|
refine(e, n) {
|
|
558
555
|
const s = (r) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(r) : n;
|
|
559
556
|
return this._refinement((r, a) => {
|
|
560
557
|
const i = e(r), o = () => a.addIssue({
|
|
561
|
-
code:
|
|
558
|
+
code: d.custom,
|
|
562
559
|
...s(r)
|
|
563
560
|
});
|
|
564
561
|
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
@@ -568,9 +565,9 @@ class v {
|
|
|
568
565
|
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof n == "function" ? n(s, r) : n), !1));
|
|
569
566
|
}
|
|
570
567
|
_refinement(e) {
|
|
571
|
-
return new
|
|
568
|
+
return new U({
|
|
572
569
|
schema: this,
|
|
573
|
-
typeName:
|
|
570
|
+
typeName: m.ZodEffects,
|
|
574
571
|
effect: { type: "refinement", refinement: e }
|
|
575
572
|
});
|
|
576
573
|
}
|
|
@@ -585,57 +582,57 @@ class v {
|
|
|
585
582
|
};
|
|
586
583
|
}
|
|
587
584
|
optional() {
|
|
588
|
-
return
|
|
585
|
+
return V.create(this, this._def);
|
|
589
586
|
}
|
|
590
587
|
nullable() {
|
|
591
|
-
return
|
|
588
|
+
return K.create(this, this._def);
|
|
592
589
|
}
|
|
593
590
|
nullish() {
|
|
594
591
|
return this.nullable().optional();
|
|
595
592
|
}
|
|
596
593
|
array() {
|
|
597
|
-
return
|
|
594
|
+
return R.create(this);
|
|
598
595
|
}
|
|
599
596
|
promise() {
|
|
600
|
-
return
|
|
597
|
+
return le.create(this, this._def);
|
|
601
598
|
}
|
|
602
599
|
or(e) {
|
|
603
|
-
return
|
|
600
|
+
return ce.create([this, e], this._def);
|
|
604
601
|
}
|
|
605
602
|
and(e) {
|
|
606
|
-
return
|
|
603
|
+
return de.create(this, e, this._def);
|
|
607
604
|
}
|
|
608
605
|
transform(e) {
|
|
609
|
-
return new
|
|
610
|
-
...
|
|
606
|
+
return new U({
|
|
607
|
+
...g(this._def),
|
|
611
608
|
schema: this,
|
|
612
|
-
typeName:
|
|
609
|
+
typeName: m.ZodEffects,
|
|
613
610
|
effect: { type: "transform", transform: e }
|
|
614
611
|
});
|
|
615
612
|
}
|
|
616
613
|
default(e) {
|
|
617
614
|
const n = typeof e == "function" ? e : () => e;
|
|
618
|
-
return new
|
|
619
|
-
...
|
|
615
|
+
return new ye({
|
|
616
|
+
...g(this._def),
|
|
620
617
|
innerType: this,
|
|
621
618
|
defaultValue: n,
|
|
622
|
-
typeName:
|
|
619
|
+
typeName: m.ZodDefault
|
|
623
620
|
});
|
|
624
621
|
}
|
|
625
622
|
brand() {
|
|
626
|
-
return new
|
|
627
|
-
typeName:
|
|
623
|
+
return new rt({
|
|
624
|
+
typeName: m.ZodBranded,
|
|
628
625
|
type: this,
|
|
629
|
-
...
|
|
626
|
+
...g(this._def)
|
|
630
627
|
});
|
|
631
628
|
}
|
|
632
629
|
catch(e) {
|
|
633
630
|
const n = typeof e == "function" ? e : () => e;
|
|
634
|
-
return new
|
|
635
|
-
...
|
|
631
|
+
return new _e({
|
|
632
|
+
...g(this._def),
|
|
636
633
|
innerType: this,
|
|
637
634
|
catchValue: n,
|
|
638
|
-
typeName:
|
|
635
|
+
typeName: m.ZodCatch
|
|
639
636
|
});
|
|
640
637
|
}
|
|
641
638
|
describe(e) {
|
|
@@ -646,10 +643,10 @@ class v {
|
|
|
646
643
|
});
|
|
647
644
|
}
|
|
648
645
|
pipe(e) {
|
|
649
|
-
return
|
|
646
|
+
return xe.create(this, e);
|
|
650
647
|
}
|
|
651
648
|
readonly() {
|
|
652
|
-
return
|
|
649
|
+
return ge.create(this);
|
|
653
650
|
}
|
|
654
651
|
isOptional() {
|
|
655
652
|
return this.safeParse(void 0).success;
|
|
@@ -658,28 +655,28 @@ class v {
|
|
|
658
655
|
return this.safeParse(null).success;
|
|
659
656
|
}
|
|
660
657
|
}
|
|
661
|
-
const
|
|
662
|
-
let
|
|
663
|
-
const
|
|
664
|
-
function
|
|
658
|
+
const gt = /^c[^\s-]{8,}$/i, vt = /^[0-9a-z]+$/, bt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, xt = /^[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, kt = /^[a-z0-9_-]{21}$/i, wt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, St = /^[-+]?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, Ct = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
659
|
+
let Ae;
|
|
660
|
+
const Et = /^(?:(?: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])$/, 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])\/(3[0-2]|[12]?[0-9])$/, At = /^(([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]))$/, 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]))\/(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}=))?$/, $t = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, et = "((\\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(`^${et}$`);
|
|
661
|
+
function tt(t) {
|
|
665
662
|
let e = "[0-5]\\d";
|
|
666
663
|
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
667
664
|
const n = t.precision ? "+" : "?";
|
|
668
665
|
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
|
|
669
666
|
}
|
|
670
|
-
function
|
|
671
|
-
return new RegExp(`^${
|
|
667
|
+
function jt(t) {
|
|
668
|
+
return new RegExp(`^${tt(t)}$`);
|
|
672
669
|
}
|
|
673
|
-
function
|
|
674
|
-
let e = `${
|
|
670
|
+
function nt(t) {
|
|
671
|
+
let e = `${et}T${tt(t)}`;
|
|
675
672
|
const n = [];
|
|
676
673
|
return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
|
|
677
674
|
}
|
|
678
|
-
function
|
|
679
|
-
return !!((e === "v4" || !e) &&
|
|
675
|
+
function Zt(t, e) {
|
|
676
|
+
return !!((e === "v4" || !e) && Et.test(t) || (e === "v6" || !e) && At.test(t));
|
|
680
677
|
}
|
|
681
|
-
function
|
|
682
|
-
if (
|
|
678
|
+
function Dt(t, e) {
|
|
679
|
+
if (!wt.test(t))
|
|
683
680
|
return !1;
|
|
684
681
|
try {
|
|
685
682
|
const [n] = t.split(".");
|
|
@@ -691,25 +688,25 @@ function qt(t, e) {
|
|
|
691
688
|
return !1;
|
|
692
689
|
}
|
|
693
690
|
}
|
|
694
|
-
function
|
|
695
|
-
return !!((e === "v4" || !e) &&
|
|
691
|
+
function Lt(t, e) {
|
|
692
|
+
return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && Nt.test(t));
|
|
696
693
|
}
|
|
697
|
-
class
|
|
694
|
+
class j extends v {
|
|
698
695
|
_parse(e) {
|
|
699
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !==
|
|
696
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
700
697
|
const a = this._getOrReturnCtx(e);
|
|
701
698
|
return l(a, {
|
|
702
|
-
code:
|
|
703
|
-
expected:
|
|
699
|
+
code: d.invalid_type,
|
|
700
|
+
expected: h.string,
|
|
704
701
|
received: a.parsedType
|
|
705
|
-
}),
|
|
702
|
+
}), y;
|
|
706
703
|
}
|
|
707
|
-
const s = new
|
|
704
|
+
const s = new C();
|
|
708
705
|
let r;
|
|
709
706
|
for (const a of this._def.checks)
|
|
710
707
|
if (a.kind === "min")
|
|
711
708
|
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
712
|
-
code:
|
|
709
|
+
code: d.too_small,
|
|
713
710
|
minimum: a.value,
|
|
714
711
|
type: "string",
|
|
715
712
|
inclusive: !0,
|
|
@@ -718,7 +715,7 @@ class $ extends v {
|
|
|
718
715
|
}), s.dirty());
|
|
719
716
|
else if (a.kind === "max")
|
|
720
717
|
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
721
|
-
code:
|
|
718
|
+
code: d.too_big,
|
|
722
719
|
maximum: a.value,
|
|
723
720
|
type: "string",
|
|
724
721
|
inclusive: !0,
|
|
@@ -728,14 +725,14 @@ class $ extends v {
|
|
|
728
725
|
else if (a.kind === "length") {
|
|
729
726
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
730
727
|
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
731
|
-
code:
|
|
728
|
+
code: d.too_big,
|
|
732
729
|
maximum: a.value,
|
|
733
730
|
type: "string",
|
|
734
731
|
inclusive: !0,
|
|
735
732
|
exact: !0,
|
|
736
733
|
message: a.message
|
|
737
734
|
}) : o && l(r, {
|
|
738
|
-
code:
|
|
735
|
+
code: d.too_small,
|
|
739
736
|
minimum: a.value,
|
|
740
737
|
type: "string",
|
|
741
738
|
inclusive: !0,
|
|
@@ -743,45 +740,45 @@ class $ extends v {
|
|
|
743
740
|
message: a.message
|
|
744
741
|
}), s.dirty());
|
|
745
742
|
} else if (a.kind === "email")
|
|
746
|
-
|
|
743
|
+
Tt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
747
744
|
validation: "email",
|
|
748
|
-
code:
|
|
745
|
+
code: d.invalid_string,
|
|
749
746
|
message: a.message
|
|
750
747
|
}), s.dirty());
|
|
751
748
|
else if (a.kind === "emoji")
|
|
752
|
-
|
|
749
|
+
Ae || (Ae = new RegExp(Ct, "u")), Ae.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
753
750
|
validation: "emoji",
|
|
754
|
-
code:
|
|
751
|
+
code: d.invalid_string,
|
|
755
752
|
message: a.message
|
|
756
753
|
}), s.dirty());
|
|
757
754
|
else if (a.kind === "uuid")
|
|
758
|
-
|
|
755
|
+
xt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
759
756
|
validation: "uuid",
|
|
760
|
-
code:
|
|
757
|
+
code: d.invalid_string,
|
|
761
758
|
message: a.message
|
|
762
759
|
}), s.dirty());
|
|
763
760
|
else if (a.kind === "nanoid")
|
|
764
|
-
|
|
761
|
+
kt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
765
762
|
validation: "nanoid",
|
|
766
|
-
code:
|
|
763
|
+
code: d.invalid_string,
|
|
767
764
|
message: a.message
|
|
768
765
|
}), s.dirty());
|
|
769
766
|
else if (a.kind === "cuid")
|
|
770
|
-
|
|
767
|
+
gt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
771
768
|
validation: "cuid",
|
|
772
|
-
code:
|
|
769
|
+
code: d.invalid_string,
|
|
773
770
|
message: a.message
|
|
774
771
|
}), s.dirty());
|
|
775
772
|
else if (a.kind === "cuid2")
|
|
776
|
-
|
|
773
|
+
vt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
777
774
|
validation: "cuid2",
|
|
778
|
-
code:
|
|
775
|
+
code: d.invalid_string,
|
|
779
776
|
message: a.message
|
|
780
777
|
}), s.dirty());
|
|
781
778
|
else if (a.kind === "ulid")
|
|
782
|
-
|
|
779
|
+
bt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
783
780
|
validation: "ulid",
|
|
784
|
-
code:
|
|
781
|
+
code: d.invalid_string,
|
|
785
782
|
message: a.message
|
|
786
783
|
}), s.dirty());
|
|
787
784
|
else if (a.kind === "url")
|
|
@@ -790,61 +787,61 @@ class $ extends v {
|
|
|
790
787
|
} catch {
|
|
791
788
|
r = this._getOrReturnCtx(e, r), l(r, {
|
|
792
789
|
validation: "url",
|
|
793
|
-
code:
|
|
790
|
+
code: d.invalid_string,
|
|
794
791
|
message: a.message
|
|
795
792
|
}), s.dirty();
|
|
796
793
|
}
|
|
797
794
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
798
795
|
validation: "regex",
|
|
799
|
-
code:
|
|
796
|
+
code: d.invalid_string,
|
|
800
797
|
message: a.message
|
|
801
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, {
|
|
802
|
-
code:
|
|
799
|
+
code: d.invalid_string,
|
|
803
800
|
validation: { includes: a.value, position: a.position },
|
|
804
801
|
message: a.message
|
|
805
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, {
|
|
806
|
-
code:
|
|
803
|
+
code: d.invalid_string,
|
|
807
804
|
validation: { startsWith: a.value },
|
|
808
805
|
message: a.message
|
|
809
806
|
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
810
|
-
code:
|
|
807
|
+
code: d.invalid_string,
|
|
811
808
|
validation: { endsWith: a.value },
|
|
812
809
|
message: a.message
|
|
813
|
-
}), s.dirty()) : a.kind === "datetime" ?
|
|
814
|
-
code:
|
|
810
|
+
}), s.dirty()) : a.kind === "datetime" ? nt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
811
|
+
code: d.invalid_string,
|
|
815
812
|
validation: "datetime",
|
|
816
813
|
message: a.message
|
|
817
|
-
}), s.dirty()) : a.kind === "date" ?
|
|
818
|
-
code:
|
|
814
|
+
}), s.dirty()) : a.kind === "date" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
815
|
+
code: d.invalid_string,
|
|
819
816
|
validation: "date",
|
|
820
817
|
message: a.message
|
|
821
|
-
}), s.dirty()) : a.kind === "time" ?
|
|
822
|
-
code:
|
|
818
|
+
}), s.dirty()) : a.kind === "time" ? jt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
819
|
+
code: d.invalid_string,
|
|
823
820
|
validation: "time",
|
|
824
821
|
message: a.message
|
|
825
|
-
}), s.dirty()) : a.kind === "duration" ?
|
|
822
|
+
}), s.dirty()) : a.kind === "duration" ? St.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
826
823
|
validation: "duration",
|
|
827
|
-
code:
|
|
824
|
+
code: d.invalid_string,
|
|
828
825
|
message: a.message
|
|
829
|
-
}), s.dirty()) : a.kind === "ip" ?
|
|
826
|
+
}), s.dirty()) : a.kind === "ip" ? Zt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
830
827
|
validation: "ip",
|
|
831
|
-
code:
|
|
828
|
+
code: d.invalid_string,
|
|
832
829
|
message: a.message
|
|
833
|
-
}), s.dirty()) : a.kind === "jwt" ?
|
|
830
|
+
}), s.dirty()) : a.kind === "jwt" ? Dt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
834
831
|
validation: "jwt",
|
|
835
|
-
code:
|
|
832
|
+
code: d.invalid_string,
|
|
836
833
|
message: a.message
|
|
837
|
-
}), s.dirty()) : a.kind === "cidr" ?
|
|
834
|
+
}), s.dirty()) : a.kind === "cidr" ? Lt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
838
835
|
validation: "cidr",
|
|
839
|
-
code:
|
|
836
|
+
code: d.invalid_string,
|
|
840
837
|
message: a.message
|
|
841
|
-
}), s.dirty()) : a.kind === "base64" ?
|
|
838
|
+
}), s.dirty()) : a.kind === "base64" ? Rt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
842
839
|
validation: "base64",
|
|
843
|
-
code:
|
|
840
|
+
code: d.invalid_string,
|
|
844
841
|
message: a.message
|
|
845
|
-
}), s.dirty()) : a.kind === "base64url" ?
|
|
842
|
+
}), s.dirty()) : a.kind === "base64url" ? $t.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
846
843
|
validation: "base64url",
|
|
847
|
-
code:
|
|
844
|
+
code: d.invalid_string,
|
|
848
845
|
message: a.message
|
|
849
846
|
}), s.dirty()) : b.assertNever(a);
|
|
850
847
|
return { status: s.value, value: e.data };
|
|
@@ -852,57 +849,57 @@ class $ extends v {
|
|
|
852
849
|
_regex(e, n, s) {
|
|
853
850
|
return this.refinement((r) => e.test(r), {
|
|
854
851
|
validation: n,
|
|
855
|
-
code:
|
|
856
|
-
...
|
|
852
|
+
code: d.invalid_string,
|
|
853
|
+
...f.errToObj(s)
|
|
857
854
|
});
|
|
858
855
|
}
|
|
859
856
|
_addCheck(e) {
|
|
860
|
-
return new
|
|
857
|
+
return new j({
|
|
861
858
|
...this._def,
|
|
862
859
|
checks: [...this._def.checks, e]
|
|
863
860
|
});
|
|
864
861
|
}
|
|
865
862
|
email(e) {
|
|
866
|
-
return this._addCheck({ kind: "email", ...
|
|
863
|
+
return this._addCheck({ kind: "email", ...f.errToObj(e) });
|
|
867
864
|
}
|
|
868
865
|
url(e) {
|
|
869
|
-
return this._addCheck({ kind: "url", ...
|
|
866
|
+
return this._addCheck({ kind: "url", ...f.errToObj(e) });
|
|
870
867
|
}
|
|
871
868
|
emoji(e) {
|
|
872
|
-
return this._addCheck({ kind: "emoji", ...
|
|
869
|
+
return this._addCheck({ kind: "emoji", ...f.errToObj(e) });
|
|
873
870
|
}
|
|
874
871
|
uuid(e) {
|
|
875
|
-
return this._addCheck({ kind: "uuid", ...
|
|
872
|
+
return this._addCheck({ kind: "uuid", ...f.errToObj(e) });
|
|
876
873
|
}
|
|
877
874
|
nanoid(e) {
|
|
878
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
875
|
+
return this._addCheck({ kind: "nanoid", ...f.errToObj(e) });
|
|
879
876
|
}
|
|
880
877
|
cuid(e) {
|
|
881
|
-
return this._addCheck({ kind: "cuid", ...
|
|
878
|
+
return this._addCheck({ kind: "cuid", ...f.errToObj(e) });
|
|
882
879
|
}
|
|
883
880
|
cuid2(e) {
|
|
884
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
881
|
+
return this._addCheck({ kind: "cuid2", ...f.errToObj(e) });
|
|
885
882
|
}
|
|
886
883
|
ulid(e) {
|
|
887
|
-
return this._addCheck({ kind: "ulid", ...
|
|
884
|
+
return this._addCheck({ kind: "ulid", ...f.errToObj(e) });
|
|
888
885
|
}
|
|
889
886
|
base64(e) {
|
|
890
|
-
return this._addCheck({ kind: "base64", ...
|
|
887
|
+
return this._addCheck({ kind: "base64", ...f.errToObj(e) });
|
|
891
888
|
}
|
|
892
889
|
base64url(e) {
|
|
893
890
|
return this._addCheck({
|
|
894
891
|
kind: "base64url",
|
|
895
|
-
...
|
|
892
|
+
...f.errToObj(e)
|
|
896
893
|
});
|
|
897
894
|
}
|
|
898
895
|
jwt(e) {
|
|
899
|
-
return this._addCheck({ kind: "jwt", ...
|
|
896
|
+
return this._addCheck({ kind: "jwt", ...f.errToObj(e) });
|
|
900
897
|
}
|
|
901
898
|
ip(e) {
|
|
902
|
-
return this._addCheck({ kind: "ip", ...
|
|
899
|
+
return this._addCheck({ kind: "ip", ...f.errToObj(e) });
|
|
903
900
|
}
|
|
904
901
|
cidr(e) {
|
|
905
|
-
return this._addCheck({ kind: "cidr", ...
|
|
902
|
+
return this._addCheck({ kind: "cidr", ...f.errToObj(e) });
|
|
906
903
|
}
|
|
907
904
|
datetime(e) {
|
|
908
905
|
return typeof e == "string" ? this._addCheck({
|
|
@@ -916,7 +913,7 @@ class $ extends v {
|
|
|
916
913
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
917
914
|
offset: e?.offset ?? !1,
|
|
918
915
|
local: e?.local ?? !1,
|
|
919
|
-
...
|
|
916
|
+
...f.errToObj(e?.message)
|
|
920
917
|
});
|
|
921
918
|
}
|
|
922
919
|
date(e) {
|
|
@@ -930,17 +927,17 @@ class $ extends v {
|
|
|
930
927
|
}) : this._addCheck({
|
|
931
928
|
kind: "time",
|
|
932
929
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
933
|
-
...
|
|
930
|
+
...f.errToObj(e?.message)
|
|
934
931
|
});
|
|
935
932
|
}
|
|
936
933
|
duration(e) {
|
|
937
|
-
return this._addCheck({ kind: "duration", ...
|
|
934
|
+
return this._addCheck({ kind: "duration", ...f.errToObj(e) });
|
|
938
935
|
}
|
|
939
936
|
regex(e, n) {
|
|
940
937
|
return this._addCheck({
|
|
941
938
|
kind: "regex",
|
|
942
939
|
regex: e,
|
|
943
|
-
...
|
|
940
|
+
...f.errToObj(n)
|
|
944
941
|
});
|
|
945
942
|
}
|
|
946
943
|
includes(e, n) {
|
|
@@ -948,64 +945,64 @@ class $ extends v {
|
|
|
948
945
|
kind: "includes",
|
|
949
946
|
value: e,
|
|
950
947
|
position: n?.position,
|
|
951
|
-
...
|
|
948
|
+
...f.errToObj(n?.message)
|
|
952
949
|
});
|
|
953
950
|
}
|
|
954
951
|
startsWith(e, n) {
|
|
955
952
|
return this._addCheck({
|
|
956
953
|
kind: "startsWith",
|
|
957
954
|
value: e,
|
|
958
|
-
...
|
|
955
|
+
...f.errToObj(n)
|
|
959
956
|
});
|
|
960
957
|
}
|
|
961
958
|
endsWith(e, n) {
|
|
962
959
|
return this._addCheck({
|
|
963
960
|
kind: "endsWith",
|
|
964
961
|
value: e,
|
|
965
|
-
...
|
|
962
|
+
...f.errToObj(n)
|
|
966
963
|
});
|
|
967
964
|
}
|
|
968
965
|
min(e, n) {
|
|
969
966
|
return this._addCheck({
|
|
970
967
|
kind: "min",
|
|
971
968
|
value: e,
|
|
972
|
-
...
|
|
969
|
+
...f.errToObj(n)
|
|
973
970
|
});
|
|
974
971
|
}
|
|
975
972
|
max(e, n) {
|
|
976
973
|
return this._addCheck({
|
|
977
974
|
kind: "max",
|
|
978
975
|
value: e,
|
|
979
|
-
...
|
|
976
|
+
...f.errToObj(n)
|
|
980
977
|
});
|
|
981
978
|
}
|
|
982
979
|
length(e, n) {
|
|
983
980
|
return this._addCheck({
|
|
984
981
|
kind: "length",
|
|
985
982
|
value: e,
|
|
986
|
-
...
|
|
983
|
+
...f.errToObj(n)
|
|
987
984
|
});
|
|
988
985
|
}
|
|
989
986
|
/**
|
|
990
987
|
* Equivalent to `.min(1)`
|
|
991
988
|
*/
|
|
992
989
|
nonempty(e) {
|
|
993
|
-
return this.min(1,
|
|
990
|
+
return this.min(1, f.errToObj(e));
|
|
994
991
|
}
|
|
995
992
|
trim() {
|
|
996
|
-
return new
|
|
993
|
+
return new j({
|
|
997
994
|
...this._def,
|
|
998
995
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
999
996
|
});
|
|
1000
997
|
}
|
|
1001
998
|
toLowerCase() {
|
|
1002
|
-
return new
|
|
999
|
+
return new j({
|
|
1003
1000
|
...this._def,
|
|
1004
1001
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1005
1002
|
});
|
|
1006
1003
|
}
|
|
1007
1004
|
toUpperCase() {
|
|
1008
|
-
return new
|
|
1005
|
+
return new j({
|
|
1009
1006
|
...this._def,
|
|
1010
1007
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1011
1008
|
});
|
|
@@ -1071,75 +1068,75 @@ class $ extends v {
|
|
|
1071
1068
|
return e;
|
|
1072
1069
|
}
|
|
1073
1070
|
}
|
|
1074
|
-
|
|
1071
|
+
j.create = (t) => new j({
|
|
1075
1072
|
checks: [],
|
|
1076
|
-
typeName:
|
|
1073
|
+
typeName: m.ZodString,
|
|
1077
1074
|
coerce: t?.coerce ?? !1,
|
|
1078
|
-
...
|
|
1075
|
+
...g(t)
|
|
1079
1076
|
});
|
|
1080
|
-
function
|
|
1077
|
+
function Pt(t, e) {
|
|
1081
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(".", ""));
|
|
1082
1079
|
return a % i / 10 ** r;
|
|
1083
1080
|
}
|
|
1084
|
-
class
|
|
1081
|
+
class J extends v {
|
|
1085
1082
|
constructor() {
|
|
1086
1083
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1087
1084
|
}
|
|
1088
1085
|
_parse(e) {
|
|
1089
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !==
|
|
1086
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1090
1087
|
const a = this._getOrReturnCtx(e);
|
|
1091
1088
|
return l(a, {
|
|
1092
|
-
code:
|
|
1093
|
-
expected:
|
|
1089
|
+
code: d.invalid_type,
|
|
1090
|
+
expected: h.number,
|
|
1094
1091
|
received: a.parsedType
|
|
1095
|
-
}),
|
|
1092
|
+
}), y;
|
|
1096
1093
|
}
|
|
1097
1094
|
let s;
|
|
1098
|
-
const r = new
|
|
1095
|
+
const r = new C();
|
|
1099
1096
|
for (const a of this._def.checks)
|
|
1100
1097
|
a.kind === "int" ? b.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1101
|
-
code:
|
|
1098
|
+
code: d.invalid_type,
|
|
1102
1099
|
expected: "integer",
|
|
1103
1100
|
received: "float",
|
|
1104
1101
|
message: a.message
|
|
1105
1102
|
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1106
|
-
code:
|
|
1103
|
+
code: d.too_small,
|
|
1107
1104
|
minimum: a.value,
|
|
1108
1105
|
type: "number",
|
|
1109
1106
|
inclusive: a.inclusive,
|
|
1110
1107
|
exact: !1,
|
|
1111
1108
|
message: a.message
|
|
1112
1109
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1113
|
-
code:
|
|
1110
|
+
code: d.too_big,
|
|
1114
1111
|
maximum: a.value,
|
|
1115
1112
|
type: "number",
|
|
1116
1113
|
inclusive: a.inclusive,
|
|
1117
1114
|
exact: !1,
|
|
1118
1115
|
message: a.message
|
|
1119
|
-
}), r.dirty()) : a.kind === "multipleOf" ?
|
|
1120
|
-
code:
|
|
1116
|
+
}), r.dirty()) : a.kind === "multipleOf" ? Pt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1117
|
+
code: d.not_multiple_of,
|
|
1121
1118
|
multipleOf: a.value,
|
|
1122
1119
|
message: a.message
|
|
1123
1120
|
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1124
|
-
code:
|
|
1121
|
+
code: d.not_finite,
|
|
1125
1122
|
message: a.message
|
|
1126
1123
|
}), r.dirty()) : b.assertNever(a);
|
|
1127
1124
|
return { status: r.value, value: e.data };
|
|
1128
1125
|
}
|
|
1129
1126
|
gte(e, n) {
|
|
1130
|
-
return this.setLimit("min", e, !0,
|
|
1127
|
+
return this.setLimit("min", e, !0, f.toString(n));
|
|
1131
1128
|
}
|
|
1132
1129
|
gt(e, n) {
|
|
1133
|
-
return this.setLimit("min", e, !1,
|
|
1130
|
+
return this.setLimit("min", e, !1, f.toString(n));
|
|
1134
1131
|
}
|
|
1135
1132
|
lte(e, n) {
|
|
1136
|
-
return this.setLimit("max", e, !0,
|
|
1133
|
+
return this.setLimit("max", e, !0, f.toString(n));
|
|
1137
1134
|
}
|
|
1138
1135
|
lt(e, n) {
|
|
1139
|
-
return this.setLimit("max", e, !1,
|
|
1136
|
+
return this.setLimit("max", e, !1, f.toString(n));
|
|
1140
1137
|
}
|
|
1141
1138
|
setLimit(e, n, s, r) {
|
|
1142
|
-
return new
|
|
1139
|
+
return new J({
|
|
1143
1140
|
...this._def,
|
|
1144
1141
|
checks: [
|
|
1145
1142
|
...this._def.checks,
|
|
@@ -1147,13 +1144,13 @@ class W extends v {
|
|
|
1147
1144
|
kind: e,
|
|
1148
1145
|
value: n,
|
|
1149
1146
|
inclusive: s,
|
|
1150
|
-
message:
|
|
1147
|
+
message: f.toString(r)
|
|
1151
1148
|
}
|
|
1152
1149
|
]
|
|
1153
1150
|
});
|
|
1154
1151
|
}
|
|
1155
1152
|
_addCheck(e) {
|
|
1156
|
-
return new
|
|
1153
|
+
return new J({
|
|
1157
1154
|
...this._def,
|
|
1158
1155
|
checks: [...this._def.checks, e]
|
|
1159
1156
|
});
|
|
@@ -1161,7 +1158,7 @@ class W extends v {
|
|
|
1161
1158
|
int(e) {
|
|
1162
1159
|
return this._addCheck({
|
|
1163
1160
|
kind: "int",
|
|
1164
|
-
message:
|
|
1161
|
+
message: f.toString(e)
|
|
1165
1162
|
});
|
|
1166
1163
|
}
|
|
1167
1164
|
positive(e) {
|
|
@@ -1169,7 +1166,7 @@ class W extends v {
|
|
|
1169
1166
|
kind: "min",
|
|
1170
1167
|
value: 0,
|
|
1171
1168
|
inclusive: !1,
|
|
1172
|
-
message:
|
|
1169
|
+
message: f.toString(e)
|
|
1173
1170
|
});
|
|
1174
1171
|
}
|
|
1175
1172
|
negative(e) {
|
|
@@ -1177,7 +1174,7 @@ class W extends v {
|
|
|
1177
1174
|
kind: "max",
|
|
1178
1175
|
value: 0,
|
|
1179
1176
|
inclusive: !1,
|
|
1180
|
-
message:
|
|
1177
|
+
message: f.toString(e)
|
|
1181
1178
|
});
|
|
1182
1179
|
}
|
|
1183
1180
|
nonpositive(e) {
|
|
@@ -1185,7 +1182,7 @@ class W extends v {
|
|
|
1185
1182
|
kind: "max",
|
|
1186
1183
|
value: 0,
|
|
1187
1184
|
inclusive: !0,
|
|
1188
|
-
message:
|
|
1185
|
+
message: f.toString(e)
|
|
1189
1186
|
});
|
|
1190
1187
|
}
|
|
1191
1188
|
nonnegative(e) {
|
|
@@ -1193,20 +1190,20 @@ class W extends v {
|
|
|
1193
1190
|
kind: "min",
|
|
1194
1191
|
value: 0,
|
|
1195
1192
|
inclusive: !0,
|
|
1196
|
-
message:
|
|
1193
|
+
message: f.toString(e)
|
|
1197
1194
|
});
|
|
1198
1195
|
}
|
|
1199
1196
|
multipleOf(e, n) {
|
|
1200
1197
|
return this._addCheck({
|
|
1201
1198
|
kind: "multipleOf",
|
|
1202
1199
|
value: e,
|
|
1203
|
-
message:
|
|
1200
|
+
message: f.toString(n)
|
|
1204
1201
|
});
|
|
1205
1202
|
}
|
|
1206
1203
|
finite(e) {
|
|
1207
1204
|
return this._addCheck({
|
|
1208
1205
|
kind: "finite",
|
|
1209
|
-
message:
|
|
1206
|
+
message: f.toString(e)
|
|
1210
1207
|
});
|
|
1211
1208
|
}
|
|
1212
1209
|
safe(e) {
|
|
@@ -1214,12 +1211,12 @@ class W extends v {
|
|
|
1214
1211
|
kind: "min",
|
|
1215
1212
|
inclusive: !0,
|
|
1216
1213
|
value: Number.MIN_SAFE_INTEGER,
|
|
1217
|
-
message:
|
|
1214
|
+
message: f.toString(e)
|
|
1218
1215
|
})._addCheck({
|
|
1219
1216
|
kind: "max",
|
|
1220
1217
|
inclusive: !0,
|
|
1221
1218
|
value: Number.MAX_SAFE_INTEGER,
|
|
1222
|
-
message:
|
|
1219
|
+
message: f.toString(e)
|
|
1223
1220
|
});
|
|
1224
1221
|
}
|
|
1225
1222
|
get minValue() {
|
|
@@ -1247,13 +1244,13 @@ class W extends v {
|
|
|
1247
1244
|
return Number.isFinite(n) && Number.isFinite(e);
|
|
1248
1245
|
}
|
|
1249
1246
|
}
|
|
1250
|
-
|
|
1247
|
+
J.create = (t) => new J({
|
|
1251
1248
|
checks: [],
|
|
1252
|
-
typeName:
|
|
1249
|
+
typeName: m.ZodNumber,
|
|
1253
1250
|
coerce: t?.coerce || !1,
|
|
1254
|
-
...
|
|
1251
|
+
...g(t)
|
|
1255
1252
|
});
|
|
1256
|
-
class
|
|
1253
|
+
class te extends v {
|
|
1257
1254
|
constructor() {
|
|
1258
1255
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1259
1256
|
}
|
|
@@ -1264,25 +1261,25 @@ class H extends v {
|
|
|
1264
1261
|
} catch {
|
|
1265
1262
|
return this._getInvalidInput(e);
|
|
1266
1263
|
}
|
|
1267
|
-
if (this._getType(e) !==
|
|
1264
|
+
if (this._getType(e) !== h.bigint)
|
|
1268
1265
|
return this._getInvalidInput(e);
|
|
1269
1266
|
let s;
|
|
1270
|
-
const r = new
|
|
1267
|
+
const r = new C();
|
|
1271
1268
|
for (const a of this._def.checks)
|
|
1272
1269
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1273
|
-
code:
|
|
1270
|
+
code: d.too_small,
|
|
1274
1271
|
type: "bigint",
|
|
1275
1272
|
minimum: a.value,
|
|
1276
1273
|
inclusive: a.inclusive,
|
|
1277
1274
|
message: a.message
|
|
1278
1275
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1279
|
-
code:
|
|
1276
|
+
code: d.too_big,
|
|
1280
1277
|
type: "bigint",
|
|
1281
1278
|
maximum: a.value,
|
|
1282
1279
|
inclusive: a.inclusive,
|
|
1283
1280
|
message: a.message
|
|
1284
1281
|
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1285
|
-
code:
|
|
1282
|
+
code: d.not_multiple_of,
|
|
1286
1283
|
multipleOf: a.value,
|
|
1287
1284
|
message: a.message
|
|
1288
1285
|
}), r.dirty()) : b.assertNever(a);
|
|
@@ -1291,25 +1288,25 @@ class H extends v {
|
|
|
1291
1288
|
_getInvalidInput(e) {
|
|
1292
1289
|
const n = this._getOrReturnCtx(e);
|
|
1293
1290
|
return l(n, {
|
|
1294
|
-
code:
|
|
1295
|
-
expected:
|
|
1291
|
+
code: d.invalid_type,
|
|
1292
|
+
expected: h.bigint,
|
|
1296
1293
|
received: n.parsedType
|
|
1297
|
-
}),
|
|
1294
|
+
}), y;
|
|
1298
1295
|
}
|
|
1299
1296
|
gte(e, n) {
|
|
1300
|
-
return this.setLimit("min", e, !0,
|
|
1297
|
+
return this.setLimit("min", e, !0, f.toString(n));
|
|
1301
1298
|
}
|
|
1302
1299
|
gt(e, n) {
|
|
1303
|
-
return this.setLimit("min", e, !1,
|
|
1300
|
+
return this.setLimit("min", e, !1, f.toString(n));
|
|
1304
1301
|
}
|
|
1305
1302
|
lte(e, n) {
|
|
1306
|
-
return this.setLimit("max", e, !0,
|
|
1303
|
+
return this.setLimit("max", e, !0, f.toString(n));
|
|
1307
1304
|
}
|
|
1308
1305
|
lt(e, n) {
|
|
1309
|
-
return this.setLimit("max", e, !1,
|
|
1306
|
+
return this.setLimit("max", e, !1, f.toString(n));
|
|
1310
1307
|
}
|
|
1311
1308
|
setLimit(e, n, s, r) {
|
|
1312
|
-
return new
|
|
1309
|
+
return new te({
|
|
1313
1310
|
...this._def,
|
|
1314
1311
|
checks: [
|
|
1315
1312
|
...this._def.checks,
|
|
@@ -1317,13 +1314,13 @@ class H extends v {
|
|
|
1317
1314
|
kind: e,
|
|
1318
1315
|
value: n,
|
|
1319
1316
|
inclusive: s,
|
|
1320
|
-
message:
|
|
1317
|
+
message: f.toString(r)
|
|
1321
1318
|
}
|
|
1322
1319
|
]
|
|
1323
1320
|
});
|
|
1324
1321
|
}
|
|
1325
1322
|
_addCheck(e) {
|
|
1326
|
-
return new
|
|
1323
|
+
return new te({
|
|
1327
1324
|
...this._def,
|
|
1328
1325
|
checks: [...this._def.checks, e]
|
|
1329
1326
|
});
|
|
@@ -1333,7 +1330,7 @@ class H extends v {
|
|
|
1333
1330
|
kind: "min",
|
|
1334
1331
|
value: BigInt(0),
|
|
1335
1332
|
inclusive: !1,
|
|
1336
|
-
message:
|
|
1333
|
+
message: f.toString(e)
|
|
1337
1334
|
});
|
|
1338
1335
|
}
|
|
1339
1336
|
negative(e) {
|
|
@@ -1341,7 +1338,7 @@ class H extends v {
|
|
|
1341
1338
|
kind: "max",
|
|
1342
1339
|
value: BigInt(0),
|
|
1343
1340
|
inclusive: !1,
|
|
1344
|
-
message:
|
|
1341
|
+
message: f.toString(e)
|
|
1345
1342
|
});
|
|
1346
1343
|
}
|
|
1347
1344
|
nonpositive(e) {
|
|
@@ -1349,7 +1346,7 @@ class H extends v {
|
|
|
1349
1346
|
kind: "max",
|
|
1350
1347
|
value: BigInt(0),
|
|
1351
1348
|
inclusive: !0,
|
|
1352
|
-
message:
|
|
1349
|
+
message: f.toString(e)
|
|
1353
1350
|
});
|
|
1354
1351
|
}
|
|
1355
1352
|
nonnegative(e) {
|
|
@@ -1357,14 +1354,14 @@ class H extends v {
|
|
|
1357
1354
|
kind: "min",
|
|
1358
1355
|
value: BigInt(0),
|
|
1359
1356
|
inclusive: !0,
|
|
1360
|
-
message:
|
|
1357
|
+
message: f.toString(e)
|
|
1361
1358
|
});
|
|
1362
1359
|
}
|
|
1363
1360
|
multipleOf(e, n) {
|
|
1364
1361
|
return this._addCheck({
|
|
1365
1362
|
kind: "multipleOf",
|
|
1366
1363
|
value: e,
|
|
1367
|
-
message:
|
|
1364
|
+
message: f.toString(n)
|
|
1368
1365
|
});
|
|
1369
1366
|
}
|
|
1370
1367
|
get minValue() {
|
|
@@ -1380,58 +1377,58 @@ class H extends v {
|
|
|
1380
1377
|
return e;
|
|
1381
1378
|
}
|
|
1382
1379
|
}
|
|
1383
|
-
|
|
1380
|
+
te.create = (t) => new te({
|
|
1384
1381
|
checks: [],
|
|
1385
|
-
typeName:
|
|
1382
|
+
typeName: m.ZodBigInt,
|
|
1386
1383
|
coerce: t?.coerce ?? !1,
|
|
1387
|
-
...
|
|
1384
|
+
...g(t)
|
|
1388
1385
|
});
|
|
1389
|
-
class
|
|
1386
|
+
class me extends v {
|
|
1390
1387
|
_parse(e) {
|
|
1391
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !==
|
|
1388
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1392
1389
|
const s = this._getOrReturnCtx(e);
|
|
1393
1390
|
return l(s, {
|
|
1394
|
-
code:
|
|
1395
|
-
expected:
|
|
1391
|
+
code: d.invalid_type,
|
|
1392
|
+
expected: h.boolean,
|
|
1396
1393
|
received: s.parsedType
|
|
1397
|
-
}),
|
|
1394
|
+
}), y;
|
|
1398
1395
|
}
|
|
1399
|
-
return
|
|
1396
|
+
return N(e.data);
|
|
1400
1397
|
}
|
|
1401
1398
|
}
|
|
1402
|
-
|
|
1403
|
-
typeName:
|
|
1399
|
+
me.create = (t) => new me({
|
|
1400
|
+
typeName: m.ZodBoolean,
|
|
1404
1401
|
coerce: t?.coerce || !1,
|
|
1405
|
-
...
|
|
1402
|
+
...g(t)
|
|
1406
1403
|
});
|
|
1407
|
-
class
|
|
1404
|
+
class oe extends v {
|
|
1408
1405
|
_parse(e) {
|
|
1409
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !==
|
|
1406
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1410
1407
|
const a = this._getOrReturnCtx(e);
|
|
1411
1408
|
return l(a, {
|
|
1412
|
-
code:
|
|
1413
|
-
expected:
|
|
1409
|
+
code: d.invalid_type,
|
|
1410
|
+
expected: h.date,
|
|
1414
1411
|
received: a.parsedType
|
|
1415
|
-
}),
|
|
1412
|
+
}), y;
|
|
1416
1413
|
}
|
|
1417
1414
|
if (Number.isNaN(e.data.getTime())) {
|
|
1418
1415
|
const a = this._getOrReturnCtx(e);
|
|
1419
1416
|
return l(a, {
|
|
1420
|
-
code:
|
|
1421
|
-
}),
|
|
1417
|
+
code: d.invalid_date
|
|
1418
|
+
}), y;
|
|
1422
1419
|
}
|
|
1423
|
-
const s = new
|
|
1420
|
+
const s = new C();
|
|
1424
1421
|
let r;
|
|
1425
1422
|
for (const a of this._def.checks)
|
|
1426
1423
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1427
|
-
code:
|
|
1424
|
+
code: d.too_small,
|
|
1428
1425
|
message: a.message,
|
|
1429
1426
|
inclusive: !0,
|
|
1430
1427
|
exact: !1,
|
|
1431
1428
|
minimum: a.value,
|
|
1432
1429
|
type: "date"
|
|
1433
1430
|
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1434
|
-
code:
|
|
1431
|
+
code: d.too_big,
|
|
1435
1432
|
message: a.message,
|
|
1436
1433
|
inclusive: !0,
|
|
1437
1434
|
exact: !1,
|
|
@@ -1444,7 +1441,7 @@ class te extends v {
|
|
|
1444
1441
|
};
|
|
1445
1442
|
}
|
|
1446
1443
|
_addCheck(e) {
|
|
1447
|
-
return new
|
|
1444
|
+
return new oe({
|
|
1448
1445
|
...this._def,
|
|
1449
1446
|
checks: [...this._def.checks, e]
|
|
1450
1447
|
});
|
|
@@ -1453,14 +1450,14 @@ class te extends v {
|
|
|
1453
1450
|
return this._addCheck({
|
|
1454
1451
|
kind: "min",
|
|
1455
1452
|
value: e.getTime(),
|
|
1456
|
-
message:
|
|
1453
|
+
message: f.toString(n)
|
|
1457
1454
|
});
|
|
1458
1455
|
}
|
|
1459
1456
|
max(e, n) {
|
|
1460
1457
|
return this._addCheck({
|
|
1461
1458
|
kind: "max",
|
|
1462
1459
|
value: e.getTime(),
|
|
1463
|
-
message:
|
|
1460
|
+
message: f.toString(n)
|
|
1464
1461
|
});
|
|
1465
1462
|
}
|
|
1466
1463
|
get minDate() {
|
|
@@ -1476,131 +1473,131 @@ class te extends v {
|
|
|
1476
1473
|
return e != null ? new Date(e) : null;
|
|
1477
1474
|
}
|
|
1478
1475
|
}
|
|
1479
|
-
|
|
1476
|
+
oe.create = (t) => new oe({
|
|
1480
1477
|
checks: [],
|
|
1481
1478
|
coerce: t?.coerce || !1,
|
|
1482
|
-
typeName:
|
|
1483
|
-
...
|
|
1479
|
+
typeName: m.ZodDate,
|
|
1480
|
+
...g(t)
|
|
1484
1481
|
});
|
|
1485
|
-
class
|
|
1482
|
+
class je extends v {
|
|
1486
1483
|
_parse(e) {
|
|
1487
|
-
if (this._getType(e) !==
|
|
1484
|
+
if (this._getType(e) !== h.symbol) {
|
|
1488
1485
|
const s = this._getOrReturnCtx(e);
|
|
1489
1486
|
return l(s, {
|
|
1490
|
-
code:
|
|
1491
|
-
expected:
|
|
1487
|
+
code: d.invalid_type,
|
|
1488
|
+
expected: h.symbol,
|
|
1492
1489
|
received: s.parsedType
|
|
1493
|
-
}),
|
|
1490
|
+
}), y;
|
|
1494
1491
|
}
|
|
1495
|
-
return
|
|
1492
|
+
return N(e.data);
|
|
1496
1493
|
}
|
|
1497
1494
|
}
|
|
1498
|
-
|
|
1499
|
-
typeName:
|
|
1500
|
-
...
|
|
1495
|
+
je.create = (t) => new je({
|
|
1496
|
+
typeName: m.ZodSymbol,
|
|
1497
|
+
...g(t)
|
|
1501
1498
|
});
|
|
1502
|
-
class
|
|
1499
|
+
class Ze extends v {
|
|
1503
1500
|
_parse(e) {
|
|
1504
|
-
if (this._getType(e) !==
|
|
1501
|
+
if (this._getType(e) !== h.undefined) {
|
|
1505
1502
|
const s = this._getOrReturnCtx(e);
|
|
1506
1503
|
return l(s, {
|
|
1507
|
-
code:
|
|
1508
|
-
expected:
|
|
1504
|
+
code: d.invalid_type,
|
|
1505
|
+
expected: h.undefined,
|
|
1509
1506
|
received: s.parsedType
|
|
1510
|
-
}),
|
|
1507
|
+
}), y;
|
|
1511
1508
|
}
|
|
1512
|
-
return
|
|
1509
|
+
return N(e.data);
|
|
1513
1510
|
}
|
|
1514
1511
|
}
|
|
1515
|
-
|
|
1516
|
-
typeName:
|
|
1517
|
-
...
|
|
1512
|
+
Ze.create = (t) => new Ze({
|
|
1513
|
+
typeName: m.ZodUndefined,
|
|
1514
|
+
...g(t)
|
|
1518
1515
|
});
|
|
1519
|
-
class
|
|
1516
|
+
class De extends v {
|
|
1520
1517
|
_parse(e) {
|
|
1521
|
-
if (this._getType(e) !==
|
|
1518
|
+
if (this._getType(e) !== h.null) {
|
|
1522
1519
|
const s = this._getOrReturnCtx(e);
|
|
1523
1520
|
return l(s, {
|
|
1524
|
-
code:
|
|
1525
|
-
expected:
|
|
1521
|
+
code: d.invalid_type,
|
|
1522
|
+
expected: h.null,
|
|
1526
1523
|
received: s.parsedType
|
|
1527
|
-
}),
|
|
1524
|
+
}), y;
|
|
1528
1525
|
}
|
|
1529
|
-
return
|
|
1526
|
+
return N(e.data);
|
|
1530
1527
|
}
|
|
1531
1528
|
}
|
|
1532
|
-
|
|
1533
|
-
typeName:
|
|
1534
|
-
...
|
|
1529
|
+
De.create = (t) => new De({
|
|
1530
|
+
typeName: m.ZodNull,
|
|
1531
|
+
...g(t)
|
|
1535
1532
|
});
|
|
1536
|
-
class
|
|
1533
|
+
class Le extends v {
|
|
1537
1534
|
constructor() {
|
|
1538
1535
|
super(...arguments), this._any = !0;
|
|
1539
1536
|
}
|
|
1540
1537
|
_parse(e) {
|
|
1541
|
-
return
|
|
1538
|
+
return N(e.data);
|
|
1542
1539
|
}
|
|
1543
1540
|
}
|
|
1544
|
-
|
|
1545
|
-
typeName:
|
|
1546
|
-
...
|
|
1541
|
+
Le.create = (t) => new Le({
|
|
1542
|
+
typeName: m.ZodAny,
|
|
1543
|
+
...g(t)
|
|
1547
1544
|
});
|
|
1548
|
-
class
|
|
1545
|
+
class Pe extends v {
|
|
1549
1546
|
constructor() {
|
|
1550
1547
|
super(...arguments), this._unknown = !0;
|
|
1551
1548
|
}
|
|
1552
1549
|
_parse(e) {
|
|
1553
|
-
return
|
|
1550
|
+
return N(e.data);
|
|
1554
1551
|
}
|
|
1555
1552
|
}
|
|
1556
|
-
|
|
1557
|
-
typeName:
|
|
1558
|
-
...
|
|
1553
|
+
Pe.create = (t) => new Pe({
|
|
1554
|
+
typeName: m.ZodUnknown,
|
|
1555
|
+
...g(t)
|
|
1559
1556
|
});
|
|
1560
|
-
class
|
|
1557
|
+
class z extends v {
|
|
1561
1558
|
_parse(e) {
|
|
1562
1559
|
const n = this._getOrReturnCtx(e);
|
|
1563
1560
|
return l(n, {
|
|
1564
|
-
code:
|
|
1565
|
-
expected:
|
|
1561
|
+
code: d.invalid_type,
|
|
1562
|
+
expected: h.never,
|
|
1566
1563
|
received: n.parsedType
|
|
1567
|
-
}),
|
|
1564
|
+
}), y;
|
|
1568
1565
|
}
|
|
1569
1566
|
}
|
|
1570
|
-
|
|
1571
|
-
typeName:
|
|
1572
|
-
...
|
|
1567
|
+
z.create = (t) => new z({
|
|
1568
|
+
typeName: m.ZodNever,
|
|
1569
|
+
...g(t)
|
|
1573
1570
|
});
|
|
1574
|
-
class
|
|
1571
|
+
class Me extends v {
|
|
1575
1572
|
_parse(e) {
|
|
1576
|
-
if (this._getType(e) !==
|
|
1573
|
+
if (this._getType(e) !== h.undefined) {
|
|
1577
1574
|
const s = this._getOrReturnCtx(e);
|
|
1578
1575
|
return l(s, {
|
|
1579
|
-
code:
|
|
1580
|
-
expected:
|
|
1576
|
+
code: d.invalid_type,
|
|
1577
|
+
expected: h.void,
|
|
1581
1578
|
received: s.parsedType
|
|
1582
|
-
}),
|
|
1579
|
+
}), y;
|
|
1583
1580
|
}
|
|
1584
|
-
return
|
|
1581
|
+
return N(e.data);
|
|
1585
1582
|
}
|
|
1586
1583
|
}
|
|
1587
|
-
|
|
1588
|
-
typeName:
|
|
1589
|
-
...
|
|
1584
|
+
Me.create = (t) => new Me({
|
|
1585
|
+
typeName: m.ZodVoid,
|
|
1586
|
+
...g(t)
|
|
1590
1587
|
});
|
|
1591
|
-
class
|
|
1588
|
+
class R extends v {
|
|
1592
1589
|
_parse(e) {
|
|
1593
1590
|
const { ctx: n, status: s } = this._processInputParams(e), r = this._def;
|
|
1594
|
-
if (n.parsedType !==
|
|
1591
|
+
if (n.parsedType !== h.array)
|
|
1595
1592
|
return l(n, {
|
|
1596
|
-
code:
|
|
1597
|
-
expected:
|
|
1593
|
+
code: d.invalid_type,
|
|
1594
|
+
expected: h.array,
|
|
1598
1595
|
received: n.parsedType
|
|
1599
|
-
}),
|
|
1596
|
+
}), y;
|
|
1600
1597
|
if (r.exactLength !== null) {
|
|
1601
1598
|
const i = n.data.length > r.exactLength.value, o = n.data.length < r.exactLength.value;
|
|
1602
1599
|
(i || o) && (l(n, {
|
|
1603
|
-
code: i ?
|
|
1600
|
+
code: i ? d.too_big : d.too_small,
|
|
1604
1601
|
minimum: o ? r.exactLength.value : void 0,
|
|
1605
1602
|
maximum: i ? r.exactLength.value : void 0,
|
|
1606
1603
|
type: "array",
|
|
@@ -1610,74 +1607,74 @@ class I extends v {
|
|
|
1610
1607
|
}), s.dirty());
|
|
1611
1608
|
}
|
|
1612
1609
|
if (r.minLength !== null && n.data.length < r.minLength.value && (l(n, {
|
|
1613
|
-
code:
|
|
1610
|
+
code: d.too_small,
|
|
1614
1611
|
minimum: r.minLength.value,
|
|
1615
1612
|
type: "array",
|
|
1616
1613
|
inclusive: !0,
|
|
1617
1614
|
exact: !1,
|
|
1618
1615
|
message: r.minLength.message
|
|
1619
1616
|
}), s.dirty()), r.maxLength !== null && n.data.length > r.maxLength.value && (l(n, {
|
|
1620
|
-
code:
|
|
1617
|
+
code: d.too_big,
|
|
1621
1618
|
maximum: r.maxLength.value,
|
|
1622
1619
|
type: "array",
|
|
1623
1620
|
inclusive: !0,
|
|
1624
1621
|
exact: !1,
|
|
1625
1622
|
message: r.maxLength.message
|
|
1626
1623
|
}), s.dirty()), n.common.async)
|
|
1627
|
-
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new
|
|
1628
|
-
const a = [...n.data].map((i, o) => r.type._parseSync(new
|
|
1629
|
-
return
|
|
1624
|
+
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new D(n, i, n.path, o)))).then((i) => C.mergeArray(s, i));
|
|
1625
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new D(n, i, n.path, o)));
|
|
1626
|
+
return C.mergeArray(s, a);
|
|
1630
1627
|
}
|
|
1631
1628
|
get element() {
|
|
1632
1629
|
return this._def.type;
|
|
1633
1630
|
}
|
|
1634
1631
|
min(e, n) {
|
|
1635
|
-
return new
|
|
1632
|
+
return new R({
|
|
1636
1633
|
...this._def,
|
|
1637
|
-
minLength: { value: e, message:
|
|
1634
|
+
minLength: { value: e, message: f.toString(n) }
|
|
1638
1635
|
});
|
|
1639
1636
|
}
|
|
1640
1637
|
max(e, n) {
|
|
1641
|
-
return new
|
|
1638
|
+
return new R({
|
|
1642
1639
|
...this._def,
|
|
1643
|
-
maxLength: { value: e, message:
|
|
1640
|
+
maxLength: { value: e, message: f.toString(n) }
|
|
1644
1641
|
});
|
|
1645
1642
|
}
|
|
1646
1643
|
length(e, n) {
|
|
1647
|
-
return new
|
|
1644
|
+
return new R({
|
|
1648
1645
|
...this._def,
|
|
1649
|
-
exactLength: { value: e, message:
|
|
1646
|
+
exactLength: { value: e, message: f.toString(n) }
|
|
1650
1647
|
});
|
|
1651
1648
|
}
|
|
1652
1649
|
nonempty(e) {
|
|
1653
1650
|
return this.min(1, e);
|
|
1654
1651
|
}
|
|
1655
1652
|
}
|
|
1656
|
-
|
|
1653
|
+
R.create = (t, e) => new R({
|
|
1657
1654
|
type: t,
|
|
1658
1655
|
minLength: null,
|
|
1659
1656
|
maxLength: null,
|
|
1660
1657
|
exactLength: null,
|
|
1661
|
-
typeName:
|
|
1662
|
-
...
|
|
1658
|
+
typeName: m.ZodArray,
|
|
1659
|
+
...g(e)
|
|
1663
1660
|
});
|
|
1664
|
-
function
|
|
1665
|
-
if (t instanceof
|
|
1661
|
+
function X(t) {
|
|
1662
|
+
if (t instanceof w) {
|
|
1666
1663
|
const e = {};
|
|
1667
1664
|
for (const n in t.shape) {
|
|
1668
1665
|
const s = t.shape[n];
|
|
1669
|
-
e[n] =
|
|
1666
|
+
e[n] = V.create(X(s));
|
|
1670
1667
|
}
|
|
1671
|
-
return new
|
|
1668
|
+
return new w({
|
|
1672
1669
|
...t._def,
|
|
1673
1670
|
shape: () => e
|
|
1674
1671
|
});
|
|
1675
|
-
} else return t instanceof
|
|
1672
|
+
} else return t instanceof R ? new R({
|
|
1676
1673
|
...t._def,
|
|
1677
|
-
type:
|
|
1678
|
-
}) : t instanceof
|
|
1674
|
+
type: X(t.element)
|
|
1675
|
+
}) : t instanceof V ? V.create(X(t.unwrap())) : t instanceof K ? K.create(X(t.unwrap())) : t instanceof F ? F.create(t.items.map((e) => X(e))) : t;
|
|
1679
1676
|
}
|
|
1680
|
-
class
|
|
1677
|
+
class w extends v {
|
|
1681
1678
|
constructor() {
|
|
1682
1679
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1683
1680
|
}
|
|
@@ -1688,80 +1685,80 @@ class T extends v {
|
|
|
1688
1685
|
return this._cached = { shape: e, keys: n }, this._cached;
|
|
1689
1686
|
}
|
|
1690
1687
|
_parse(e) {
|
|
1691
|
-
if (this._getType(e) !==
|
|
1692
|
-
const
|
|
1693
|
-
return l(
|
|
1694
|
-
code:
|
|
1695
|
-
expected:
|
|
1696
|
-
received:
|
|
1697
|
-
}),
|
|
1688
|
+
if (this._getType(e) !== h.object) {
|
|
1689
|
+
const u = this._getOrReturnCtx(e);
|
|
1690
|
+
return l(u, {
|
|
1691
|
+
code: d.invalid_type,
|
|
1692
|
+
expected: h.object,
|
|
1693
|
+
received: u.parsedType
|
|
1694
|
+
}), y;
|
|
1698
1695
|
}
|
|
1699
1696
|
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1700
|
-
if (!(this._def.catchall instanceof
|
|
1701
|
-
for (const
|
|
1702
|
-
i.includes(
|
|
1697
|
+
if (!(this._def.catchall instanceof z && this._def.unknownKeys === "strip"))
|
|
1698
|
+
for (const u in r.data)
|
|
1699
|
+
i.includes(u) || o.push(u);
|
|
1703
1700
|
const c = [];
|
|
1704
|
-
for (const
|
|
1705
|
-
const
|
|
1701
|
+
for (const u of i) {
|
|
1702
|
+
const p = a[u], k = r.data[u];
|
|
1706
1703
|
c.push({
|
|
1707
|
-
key: { status: "valid", value:
|
|
1708
|
-
value:
|
|
1709
|
-
alwaysSet:
|
|
1704
|
+
key: { status: "valid", value: u },
|
|
1705
|
+
value: p._parse(new D(r, k, r.path, u)),
|
|
1706
|
+
alwaysSet: u in r.data
|
|
1710
1707
|
});
|
|
1711
1708
|
}
|
|
1712
|
-
if (this._def.catchall instanceof
|
|
1713
|
-
const
|
|
1714
|
-
if (
|
|
1715
|
-
for (const
|
|
1709
|
+
if (this._def.catchall instanceof z) {
|
|
1710
|
+
const u = this._def.unknownKeys;
|
|
1711
|
+
if (u === "passthrough")
|
|
1712
|
+
for (const p of o)
|
|
1716
1713
|
c.push({
|
|
1717
|
-
key: { status: "valid", value:
|
|
1718
|
-
value: { status: "valid", value: r.data[
|
|
1714
|
+
key: { status: "valid", value: p },
|
|
1715
|
+
value: { status: "valid", value: r.data[p] }
|
|
1719
1716
|
});
|
|
1720
|
-
else if (
|
|
1717
|
+
else if (u === "strict")
|
|
1721
1718
|
o.length > 0 && (l(r, {
|
|
1722
|
-
code:
|
|
1719
|
+
code: d.unrecognized_keys,
|
|
1723
1720
|
keys: o
|
|
1724
1721
|
}), s.dirty());
|
|
1725
|
-
else if (
|
|
1722
|
+
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1726
1723
|
} else {
|
|
1727
|
-
const
|
|
1728
|
-
for (const
|
|
1729
|
-
const
|
|
1724
|
+
const u = this._def.catchall;
|
|
1725
|
+
for (const p of o) {
|
|
1726
|
+
const k = r.data[p];
|
|
1730
1727
|
c.push({
|
|
1731
|
-
key: { status: "valid", value:
|
|
1732
|
-
value:
|
|
1733
|
-
new
|
|
1728
|
+
key: { status: "valid", value: p },
|
|
1729
|
+
value: u._parse(
|
|
1730
|
+
new D(r, k, r.path, p)
|
|
1734
1731
|
//, ctx.child(key), value, getParsedType(value)
|
|
1735
1732
|
),
|
|
1736
|
-
alwaysSet:
|
|
1733
|
+
alwaysSet: p in r.data
|
|
1737
1734
|
});
|
|
1738
1735
|
}
|
|
1739
1736
|
}
|
|
1740
1737
|
return r.common.async ? Promise.resolve().then(async () => {
|
|
1741
|
-
const
|
|
1742
|
-
for (const
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
key:
|
|
1746
|
-
value:
|
|
1747
|
-
alwaysSet:
|
|
1738
|
+
const u = [];
|
|
1739
|
+
for (const p of c) {
|
|
1740
|
+
const k = await p.key, T = await p.value;
|
|
1741
|
+
u.push({
|
|
1742
|
+
key: k,
|
|
1743
|
+
value: T,
|
|
1744
|
+
alwaysSet: p.alwaysSet
|
|
1748
1745
|
});
|
|
1749
1746
|
}
|
|
1750
|
-
return
|
|
1751
|
-
}).then((
|
|
1747
|
+
return u;
|
|
1748
|
+
}).then((u) => C.mergeObjectSync(s, u)) : C.mergeObjectSync(s, c);
|
|
1752
1749
|
}
|
|
1753
1750
|
get shape() {
|
|
1754
1751
|
return this._def.shape();
|
|
1755
1752
|
}
|
|
1756
1753
|
strict(e) {
|
|
1757
|
-
return
|
|
1754
|
+
return f.errToObj, new w({
|
|
1758
1755
|
...this._def,
|
|
1759
1756
|
unknownKeys: "strict",
|
|
1760
1757
|
...e !== void 0 ? {
|
|
1761
1758
|
errorMap: (n, s) => {
|
|
1762
1759
|
const r = this._def.errorMap?.(n, s).message ?? s.defaultError;
|
|
1763
1760
|
return n.code === "unrecognized_keys" ? {
|
|
1764
|
-
message:
|
|
1761
|
+
message: f.errToObj(e).message ?? r
|
|
1765
1762
|
} : {
|
|
1766
1763
|
message: r
|
|
1767
1764
|
};
|
|
@@ -1770,13 +1767,13 @@ class T extends v {
|
|
|
1770
1767
|
});
|
|
1771
1768
|
}
|
|
1772
1769
|
strip() {
|
|
1773
|
-
return new
|
|
1770
|
+
return new w({
|
|
1774
1771
|
...this._def,
|
|
1775
1772
|
unknownKeys: "strip"
|
|
1776
1773
|
});
|
|
1777
1774
|
}
|
|
1778
1775
|
passthrough() {
|
|
1779
|
-
return new
|
|
1776
|
+
return new w({
|
|
1780
1777
|
...this._def,
|
|
1781
1778
|
unknownKeys: "passthrough"
|
|
1782
1779
|
});
|
|
@@ -1799,7 +1796,7 @@ class T extends v {
|
|
|
1799
1796
|
// }) as any;
|
|
1800
1797
|
// };
|
|
1801
1798
|
extend(e) {
|
|
1802
|
-
return new
|
|
1799
|
+
return new w({
|
|
1803
1800
|
...this._def,
|
|
1804
1801
|
shape: () => ({
|
|
1805
1802
|
...this._def.shape(),
|
|
@@ -1813,14 +1810,14 @@ class T extends v {
|
|
|
1813
1810
|
* upgrade if you are experiencing issues.
|
|
1814
1811
|
*/
|
|
1815
1812
|
merge(e) {
|
|
1816
|
-
return new
|
|
1813
|
+
return new w({
|
|
1817
1814
|
unknownKeys: e._def.unknownKeys,
|
|
1818
1815
|
catchall: e._def.catchall,
|
|
1819
1816
|
shape: () => ({
|
|
1820
1817
|
...this._def.shape(),
|
|
1821
1818
|
...e._def.shape()
|
|
1822
1819
|
}),
|
|
1823
|
-
typeName:
|
|
1820
|
+
typeName: m.ZodObject
|
|
1824
1821
|
});
|
|
1825
1822
|
}
|
|
1826
1823
|
// merge<
|
|
@@ -1883,7 +1880,7 @@ class T extends v {
|
|
|
1883
1880
|
// return merged;
|
|
1884
1881
|
// }
|
|
1885
1882
|
catchall(e) {
|
|
1886
|
-
return new
|
|
1883
|
+
return new w({
|
|
1887
1884
|
...this._def,
|
|
1888
1885
|
catchall: e
|
|
1889
1886
|
});
|
|
@@ -1892,7 +1889,7 @@ class T extends v {
|
|
|
1892
1889
|
const n = {};
|
|
1893
1890
|
for (const s of b.objectKeys(e))
|
|
1894
1891
|
e[s] && this.shape[s] && (n[s] = this.shape[s]);
|
|
1895
|
-
return new
|
|
1892
|
+
return new w({
|
|
1896
1893
|
...this._def,
|
|
1897
1894
|
shape: () => n
|
|
1898
1895
|
});
|
|
@@ -1901,7 +1898,7 @@ class T extends v {
|
|
|
1901
1898
|
const n = {};
|
|
1902
1899
|
for (const s of b.objectKeys(this.shape))
|
|
1903
1900
|
e[s] || (n[s] = this.shape[s]);
|
|
1904
|
-
return new
|
|
1901
|
+
return new w({
|
|
1905
1902
|
...this._def,
|
|
1906
1903
|
shape: () => n
|
|
1907
1904
|
});
|
|
@@ -1910,7 +1907,7 @@ class T extends v {
|
|
|
1910
1907
|
* @deprecated
|
|
1911
1908
|
*/
|
|
1912
1909
|
deepPartial() {
|
|
1913
|
-
return
|
|
1910
|
+
return X(this);
|
|
1914
1911
|
}
|
|
1915
1912
|
partial(e) {
|
|
1916
1913
|
const n = {};
|
|
@@ -1918,7 +1915,7 @@ class T extends v {
|
|
|
1918
1915
|
const r = this.shape[s];
|
|
1919
1916
|
e && !e[s] ? n[s] = r : n[s] = r.optional();
|
|
1920
1917
|
}
|
|
1921
|
-
return new
|
|
1918
|
+
return new w({
|
|
1922
1919
|
...this._def,
|
|
1923
1920
|
shape: () => n
|
|
1924
1921
|
});
|
|
@@ -1930,41 +1927,41 @@ class T extends v {
|
|
|
1930
1927
|
n[s] = this.shape[s];
|
|
1931
1928
|
else {
|
|
1932
1929
|
let a = this.shape[s];
|
|
1933
|
-
for (; a instanceof
|
|
1930
|
+
for (; a instanceof V; )
|
|
1934
1931
|
a = a._def.innerType;
|
|
1935
1932
|
n[s] = a;
|
|
1936
1933
|
}
|
|
1937
|
-
return new
|
|
1934
|
+
return new w({
|
|
1938
1935
|
...this._def,
|
|
1939
1936
|
shape: () => n
|
|
1940
1937
|
});
|
|
1941
1938
|
}
|
|
1942
1939
|
keyof() {
|
|
1943
|
-
return
|
|
1940
|
+
return st(b.objectKeys(this.shape));
|
|
1944
1941
|
}
|
|
1945
1942
|
}
|
|
1946
|
-
|
|
1943
|
+
w.create = (t, e) => new w({
|
|
1947
1944
|
shape: () => t,
|
|
1948
1945
|
unknownKeys: "strip",
|
|
1949
|
-
catchall:
|
|
1950
|
-
typeName:
|
|
1951
|
-
...
|
|
1946
|
+
catchall: z.create(),
|
|
1947
|
+
typeName: m.ZodObject,
|
|
1948
|
+
...g(e)
|
|
1952
1949
|
});
|
|
1953
|
-
|
|
1950
|
+
w.strictCreate = (t, e) => new w({
|
|
1954
1951
|
shape: () => t,
|
|
1955
1952
|
unknownKeys: "strict",
|
|
1956
|
-
catchall:
|
|
1957
|
-
typeName:
|
|
1958
|
-
...
|
|
1953
|
+
catchall: z.create(),
|
|
1954
|
+
typeName: m.ZodObject,
|
|
1955
|
+
...g(e)
|
|
1959
1956
|
});
|
|
1960
|
-
|
|
1957
|
+
w.lazycreate = (t, e) => new w({
|
|
1961
1958
|
shape: t,
|
|
1962
1959
|
unknownKeys: "strip",
|
|
1963
|
-
catchall:
|
|
1964
|
-
typeName:
|
|
1965
|
-
...
|
|
1960
|
+
catchall: z.create(),
|
|
1961
|
+
typeName: m.ZodObject,
|
|
1962
|
+
...g(e)
|
|
1966
1963
|
});
|
|
1967
|
-
class
|
|
1964
|
+
class ce extends v {
|
|
1968
1965
|
_parse(e) {
|
|
1969
1966
|
const { ctx: n } = this._processInputParams(e), s = this._def.options;
|
|
1970
1967
|
function r(a) {
|
|
@@ -1974,11 +1971,11 @@ class _e extends v {
|
|
|
1974
1971
|
for (const o of a)
|
|
1975
1972
|
if (o.result.status === "dirty")
|
|
1976
1973
|
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1977
|
-
const i = a.map((o) => new
|
|
1974
|
+
const i = a.map((o) => new Z(o.ctx.common.issues));
|
|
1978
1975
|
return l(n, {
|
|
1979
|
-
code:
|
|
1976
|
+
code: d.invalid_union,
|
|
1980
1977
|
unionErrors: i
|
|
1981
|
-
}),
|
|
1978
|
+
}), y;
|
|
1982
1979
|
}
|
|
1983
1980
|
if (n.common.async)
|
|
1984
1981
|
return Promise.all(s.map(async (a) => {
|
|
@@ -2003,138 +2000,75 @@ class _e extends v {
|
|
|
2003
2000
|
let a;
|
|
2004
2001
|
const i = [];
|
|
2005
2002
|
for (const c of s) {
|
|
2006
|
-
const
|
|
2003
|
+
const u = {
|
|
2007
2004
|
...n,
|
|
2008
2005
|
common: {
|
|
2009
2006
|
...n.common,
|
|
2010
2007
|
issues: []
|
|
2011
2008
|
},
|
|
2012
2009
|
parent: null
|
|
2013
|
-
},
|
|
2010
|
+
}, p = c._parseSync({
|
|
2014
2011
|
data: n.data,
|
|
2015
2012
|
path: n.path,
|
|
2016
|
-
parent:
|
|
2013
|
+
parent: u
|
|
2017
2014
|
});
|
|
2018
|
-
if (
|
|
2019
|
-
return
|
|
2020
|
-
|
|
2015
|
+
if (p.status === "valid")
|
|
2016
|
+
return p;
|
|
2017
|
+
p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && i.push(u.common.issues);
|
|
2021
2018
|
}
|
|
2022
2019
|
if (a)
|
|
2023
2020
|
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2024
|
-
const o = i.map((c) => new
|
|
2021
|
+
const o = i.map((c) => new Z(c));
|
|
2025
2022
|
return l(n, {
|
|
2026
|
-
code:
|
|
2023
|
+
code: d.invalid_union,
|
|
2027
2024
|
unionErrors: o
|
|
2028
|
-
}),
|
|
2025
|
+
}), y;
|
|
2029
2026
|
}
|
|
2030
2027
|
}
|
|
2031
2028
|
get options() {
|
|
2032
2029
|
return this._def.options;
|
|
2033
2030
|
}
|
|
2034
2031
|
}
|
|
2035
|
-
|
|
2032
|
+
ce.create = (t, e) => new ce({
|
|
2036
2033
|
options: t,
|
|
2037
|
-
typeName:
|
|
2038
|
-
...
|
|
2034
|
+
typeName: m.ZodUnion,
|
|
2035
|
+
...g(e)
|
|
2039
2036
|
});
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
_parse(e) {
|
|
2043
|
-
const { ctx: n } = this._processInputParams(e);
|
|
2044
|
-
if (n.parsedType !== f.object)
|
|
2045
|
-
return l(n, {
|
|
2046
|
-
code: u.invalid_type,
|
|
2047
|
-
expected: f.object,
|
|
2048
|
-
received: n.parsedType
|
|
2049
|
-
}), m;
|
|
2050
|
-
const s = this.discriminator, r = n.data[s], a = this.optionsMap.get(r);
|
|
2051
|
-
return a ? n.common.async ? a._parseAsync({
|
|
2052
|
-
data: n.data,
|
|
2053
|
-
path: n.path,
|
|
2054
|
-
parent: n
|
|
2055
|
-
}) : a._parseSync({
|
|
2056
|
-
data: n.data,
|
|
2057
|
-
path: n.path,
|
|
2058
|
-
parent: n
|
|
2059
|
-
}) : (l(n, {
|
|
2060
|
-
code: u.invalid_union_discriminator,
|
|
2061
|
-
options: Array.from(this.optionsMap.keys()),
|
|
2062
|
-
path: [s]
|
|
2063
|
-
}), m);
|
|
2064
|
-
}
|
|
2065
|
-
get discriminator() {
|
|
2066
|
-
return this._def.discriminator;
|
|
2067
|
-
}
|
|
2068
|
-
get options() {
|
|
2069
|
-
return this._def.options;
|
|
2070
|
-
}
|
|
2071
|
-
get optionsMap() {
|
|
2072
|
-
return this._def.optionsMap;
|
|
2073
|
-
}
|
|
2074
|
-
/**
|
|
2075
|
-
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
2076
|
-
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
2077
|
-
* have a different value for each object in the union.
|
|
2078
|
-
* @param discriminator the name of the discriminator property
|
|
2079
|
-
* @param types an array of object schemas
|
|
2080
|
-
* @param params
|
|
2081
|
-
*/
|
|
2082
|
-
static create(e, n, s) {
|
|
2083
|
-
const r = /* @__PURE__ */ new Map();
|
|
2084
|
-
for (const a of n) {
|
|
2085
|
-
const i = z(a.shape[e]);
|
|
2086
|
-
if (!i.length)
|
|
2087
|
-
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2088
|
-
for (const o of i) {
|
|
2089
|
-
if (r.has(o))
|
|
2090
|
-
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2091
|
-
r.set(o, a);
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2094
|
-
return new Me({
|
|
2095
|
-
typeName: y.ZodDiscriminatedUnion,
|
|
2096
|
-
discriminator: e,
|
|
2097
|
-
options: n,
|
|
2098
|
-
optionsMap: r,
|
|
2099
|
-
..._(s)
|
|
2100
|
-
});
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
function Ye(t, e) {
|
|
2104
|
-
const n = B(t), s = B(e);
|
|
2037
|
+
function Ve(t, e) {
|
|
2038
|
+
const n = P(t), s = P(e);
|
|
2105
2039
|
if (t === e)
|
|
2106
2040
|
return { valid: !0, data: t };
|
|
2107
|
-
if (n ===
|
|
2041
|
+
if (n === h.object && s === h.object) {
|
|
2108
2042
|
const r = b.objectKeys(e), a = b.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2109
2043
|
for (const o of a) {
|
|
2110
|
-
const c =
|
|
2044
|
+
const c = Ve(t[o], e[o]);
|
|
2111
2045
|
if (!c.valid)
|
|
2112
2046
|
return { valid: !1 };
|
|
2113
2047
|
i[o] = c.data;
|
|
2114
2048
|
}
|
|
2115
2049
|
return { valid: !0, data: i };
|
|
2116
|
-
} else if (n ===
|
|
2050
|
+
} else if (n === h.array && s === h.array) {
|
|
2117
2051
|
if (t.length !== e.length)
|
|
2118
2052
|
return { valid: !1 };
|
|
2119
2053
|
const r = [];
|
|
2120
2054
|
for (let a = 0; a < t.length; a++) {
|
|
2121
|
-
const i = t[a], o = e[a], c =
|
|
2055
|
+
const i = t[a], o = e[a], c = Ve(i, o);
|
|
2122
2056
|
if (!c.valid)
|
|
2123
2057
|
return { valid: !1 };
|
|
2124
2058
|
r.push(c.data);
|
|
2125
2059
|
}
|
|
2126
2060
|
return { valid: !0, data: r };
|
|
2127
|
-
} else return n ===
|
|
2061
|
+
} else return n === h.date && s === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2128
2062
|
}
|
|
2129
|
-
class
|
|
2063
|
+
class de extends v {
|
|
2130
2064
|
_parse(e) {
|
|
2131
2065
|
const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2132
|
-
if (
|
|
2133
|
-
return
|
|
2134
|
-
const o =
|
|
2135
|
-
return o.valid ? ((
|
|
2136
|
-
code:
|
|
2137
|
-
}),
|
|
2066
|
+
if ($e(a) || $e(i))
|
|
2067
|
+
return y;
|
|
2068
|
+
const o = Ve(a.value, i.value);
|
|
2069
|
+
return o.valid ? ((Ie(a) || Ie(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2070
|
+
code: d.invalid_intersection_types
|
|
2071
|
+
}), y);
|
|
2138
2072
|
};
|
|
2139
2073
|
return s.common.async ? Promise.all([
|
|
2140
2074
|
this._def.left._parseAsync({
|
|
@@ -2158,31 +2092,31 @@ class ge extends v {
|
|
|
2158
2092
|
}));
|
|
2159
2093
|
}
|
|
2160
2094
|
}
|
|
2161
|
-
|
|
2095
|
+
de.create = (t, e, n) => new de({
|
|
2162
2096
|
left: t,
|
|
2163
2097
|
right: e,
|
|
2164
|
-
typeName:
|
|
2165
|
-
...
|
|
2098
|
+
typeName: m.ZodIntersection,
|
|
2099
|
+
...g(n)
|
|
2166
2100
|
});
|
|
2167
|
-
class
|
|
2101
|
+
class F extends v {
|
|
2168
2102
|
_parse(e) {
|
|
2169
2103
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2170
|
-
if (s.parsedType !==
|
|
2104
|
+
if (s.parsedType !== h.array)
|
|
2171
2105
|
return l(s, {
|
|
2172
|
-
code:
|
|
2173
|
-
expected:
|
|
2106
|
+
code: d.invalid_type,
|
|
2107
|
+
expected: h.array,
|
|
2174
2108
|
received: s.parsedType
|
|
2175
|
-
}),
|
|
2109
|
+
}), y;
|
|
2176
2110
|
if (s.data.length < this._def.items.length)
|
|
2177
2111
|
return l(s, {
|
|
2178
|
-
code:
|
|
2112
|
+
code: d.too_small,
|
|
2179
2113
|
minimum: this._def.items.length,
|
|
2180
2114
|
inclusive: !0,
|
|
2181
2115
|
exact: !1,
|
|
2182
2116
|
type: "array"
|
|
2183
|
-
}),
|
|
2117
|
+
}), y;
|
|
2184
2118
|
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2185
|
-
code:
|
|
2119
|
+
code: d.too_big,
|
|
2186
2120
|
maximum: this._def.items.length,
|
|
2187
2121
|
inclusive: !0,
|
|
2188
2122
|
exact: !1,
|
|
@@ -2190,31 +2124,31 @@ class P extends v {
|
|
|
2190
2124
|
}), n.dirty());
|
|
2191
2125
|
const a = [...s.data].map((i, o) => {
|
|
2192
2126
|
const c = this._def.items[o] || this._def.rest;
|
|
2193
|
-
return c ? c._parse(new
|
|
2127
|
+
return c ? c._parse(new D(s, i, s.path, o)) : null;
|
|
2194
2128
|
}).filter((i) => !!i);
|
|
2195
|
-
return s.common.async ? Promise.all(a).then((i) =>
|
|
2129
|
+
return s.common.async ? Promise.all(a).then((i) => C.mergeArray(n, i)) : C.mergeArray(n, a);
|
|
2196
2130
|
}
|
|
2197
2131
|
get items() {
|
|
2198
2132
|
return this._def.items;
|
|
2199
2133
|
}
|
|
2200
2134
|
rest(e) {
|
|
2201
|
-
return new
|
|
2135
|
+
return new F({
|
|
2202
2136
|
...this._def,
|
|
2203
2137
|
rest: e
|
|
2204
2138
|
});
|
|
2205
2139
|
}
|
|
2206
2140
|
}
|
|
2207
|
-
|
|
2141
|
+
F.create = (t, e) => {
|
|
2208
2142
|
if (!Array.isArray(t))
|
|
2209
2143
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2210
|
-
return new
|
|
2144
|
+
return new F({
|
|
2211
2145
|
items: t,
|
|
2212
|
-
typeName:
|
|
2146
|
+
typeName: m.ZodTuple,
|
|
2213
2147
|
rest: null,
|
|
2214
|
-
...
|
|
2148
|
+
...g(e)
|
|
2215
2149
|
});
|
|
2216
2150
|
};
|
|
2217
|
-
class
|
|
2151
|
+
class ue extends v {
|
|
2218
2152
|
get keySchema() {
|
|
2219
2153
|
return this._def.keyType;
|
|
2220
2154
|
}
|
|
@@ -2223,39 +2157,39 @@ class ve extends v {
|
|
|
2223
2157
|
}
|
|
2224
2158
|
_parse(e) {
|
|
2225
2159
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2226
|
-
if (s.parsedType !==
|
|
2160
|
+
if (s.parsedType !== h.object)
|
|
2227
2161
|
return l(s, {
|
|
2228
|
-
code:
|
|
2229
|
-
expected:
|
|
2162
|
+
code: d.invalid_type,
|
|
2163
|
+
expected: h.object,
|
|
2230
2164
|
received: s.parsedType
|
|
2231
|
-
}),
|
|
2165
|
+
}), y;
|
|
2232
2166
|
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2233
2167
|
for (const o in s.data)
|
|
2234
2168
|
r.push({
|
|
2235
|
-
key: a._parse(new
|
|
2236
|
-
value: i._parse(new
|
|
2169
|
+
key: a._parse(new D(s, o, s.path, o)),
|
|
2170
|
+
value: i._parse(new D(s, s.data[o], s.path, o)),
|
|
2237
2171
|
alwaysSet: o in s.data
|
|
2238
2172
|
});
|
|
2239
|
-
return s.common.async ?
|
|
2173
|
+
return s.common.async ? C.mergeObjectAsync(n, r) : C.mergeObjectSync(n, r);
|
|
2240
2174
|
}
|
|
2241
2175
|
get element() {
|
|
2242
2176
|
return this._def.valueType;
|
|
2243
2177
|
}
|
|
2244
2178
|
static create(e, n, s) {
|
|
2245
|
-
return n instanceof v ? new
|
|
2179
|
+
return n instanceof v ? new ue({
|
|
2246
2180
|
keyType: e,
|
|
2247
2181
|
valueType: n,
|
|
2248
|
-
typeName:
|
|
2249
|
-
...
|
|
2250
|
-
}) : new
|
|
2251
|
-
keyType:
|
|
2182
|
+
typeName: m.ZodRecord,
|
|
2183
|
+
...g(s)
|
|
2184
|
+
}) : new ue({
|
|
2185
|
+
keyType: j.create(),
|
|
2252
2186
|
valueType: e,
|
|
2253
|
-
typeName:
|
|
2254
|
-
...
|
|
2187
|
+
typeName: m.ZodRecord,
|
|
2188
|
+
...g(n)
|
|
2255
2189
|
});
|
|
2256
2190
|
}
|
|
2257
2191
|
}
|
|
2258
|
-
class
|
|
2192
|
+
class ze extends v {
|
|
2259
2193
|
get keySchema() {
|
|
2260
2194
|
return this._def.keyType;
|
|
2261
2195
|
}
|
|
@@ -2264,64 +2198,64 @@ class je extends v {
|
|
|
2264
2198
|
}
|
|
2265
2199
|
_parse(e) {
|
|
2266
2200
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2267
|
-
if (s.parsedType !==
|
|
2201
|
+
if (s.parsedType !== h.map)
|
|
2268
2202
|
return l(s, {
|
|
2269
|
-
code:
|
|
2270
|
-
expected:
|
|
2203
|
+
code: d.invalid_type,
|
|
2204
|
+
expected: h.map,
|
|
2271
2205
|
received: s.parsedType
|
|
2272
|
-
}),
|
|
2273
|
-
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c],
|
|
2274
|
-
key: r._parse(new
|
|
2275
|
-
value: a._parse(new
|
|
2206
|
+
}), y;
|
|
2207
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2208
|
+
key: r._parse(new D(s, o, s.path, [u, "key"])),
|
|
2209
|
+
value: a._parse(new D(s, c, s.path, [u, "value"]))
|
|
2276
2210
|
}));
|
|
2277
2211
|
if (s.common.async) {
|
|
2278
2212
|
const o = /* @__PURE__ */ new Map();
|
|
2279
2213
|
return Promise.resolve().then(async () => {
|
|
2280
2214
|
for (const c of i) {
|
|
2281
|
-
const
|
|
2282
|
-
if (
|
|
2283
|
-
return
|
|
2284
|
-
(
|
|
2215
|
+
const u = await c.key, p = await c.value;
|
|
2216
|
+
if (u.status === "aborted" || p.status === "aborted")
|
|
2217
|
+
return y;
|
|
2218
|
+
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.value);
|
|
2285
2219
|
}
|
|
2286
2220
|
return { status: n.value, value: o };
|
|
2287
2221
|
});
|
|
2288
2222
|
} else {
|
|
2289
2223
|
const o = /* @__PURE__ */ new Map();
|
|
2290
2224
|
for (const c of i) {
|
|
2291
|
-
const
|
|
2292
|
-
if (
|
|
2293
|
-
return
|
|
2294
|
-
(
|
|
2225
|
+
const u = c.key, p = c.value;
|
|
2226
|
+
if (u.status === "aborted" || p.status === "aborted")
|
|
2227
|
+
return y;
|
|
2228
|
+
(u.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(u.value, p.value);
|
|
2295
2229
|
}
|
|
2296
2230
|
return { status: n.value, value: o };
|
|
2297
2231
|
}
|
|
2298
2232
|
}
|
|
2299
2233
|
}
|
|
2300
|
-
|
|
2234
|
+
ze.create = (t, e, n) => new ze({
|
|
2301
2235
|
valueType: e,
|
|
2302
2236
|
keyType: t,
|
|
2303
|
-
typeName:
|
|
2304
|
-
...
|
|
2237
|
+
typeName: m.ZodMap,
|
|
2238
|
+
...g(n)
|
|
2305
2239
|
});
|
|
2306
2240
|
class ne extends v {
|
|
2307
2241
|
_parse(e) {
|
|
2308
2242
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2309
|
-
if (s.parsedType !==
|
|
2243
|
+
if (s.parsedType !== h.set)
|
|
2310
2244
|
return l(s, {
|
|
2311
|
-
code:
|
|
2312
|
-
expected:
|
|
2245
|
+
code: d.invalid_type,
|
|
2246
|
+
expected: h.set,
|
|
2313
2247
|
received: s.parsedType
|
|
2314
|
-
}),
|
|
2248
|
+
}), y;
|
|
2315
2249
|
const r = this._def;
|
|
2316
2250
|
r.minSize !== null && s.data.size < r.minSize.value && (l(s, {
|
|
2317
|
-
code:
|
|
2251
|
+
code: d.too_small,
|
|
2318
2252
|
minimum: r.minSize.value,
|
|
2319
2253
|
type: "set",
|
|
2320
2254
|
inclusive: !0,
|
|
2321
2255
|
exact: !1,
|
|
2322
2256
|
message: r.minSize.message
|
|
2323
2257
|
}), n.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (l(s, {
|
|
2324
|
-
code:
|
|
2258
|
+
code: d.too_big,
|
|
2325
2259
|
maximum: r.maxSize.value,
|
|
2326
2260
|
type: "set",
|
|
2327
2261
|
inclusive: !0,
|
|
@@ -2330,27 +2264,27 @@ class ne extends v {
|
|
|
2330
2264
|
}), n.dirty());
|
|
2331
2265
|
const a = this._def.valueType;
|
|
2332
2266
|
function i(c) {
|
|
2333
|
-
const
|
|
2334
|
-
for (const
|
|
2335
|
-
if (
|
|
2336
|
-
return
|
|
2337
|
-
|
|
2267
|
+
const u = /* @__PURE__ */ new Set();
|
|
2268
|
+
for (const p of c) {
|
|
2269
|
+
if (p.status === "aborted")
|
|
2270
|
+
return y;
|
|
2271
|
+
p.status === "dirty" && n.dirty(), u.add(p.value);
|
|
2338
2272
|
}
|
|
2339
|
-
return { status: n.value, value:
|
|
2273
|
+
return { status: n.value, value: u };
|
|
2340
2274
|
}
|
|
2341
|
-
const o = [...s.data.values()].map((c,
|
|
2275
|
+
const o = [...s.data.values()].map((c, u) => a._parse(new D(s, c, s.path, u)));
|
|
2342
2276
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2343
2277
|
}
|
|
2344
2278
|
min(e, n) {
|
|
2345
2279
|
return new ne({
|
|
2346
2280
|
...this._def,
|
|
2347
|
-
minSize: { value: e, message:
|
|
2281
|
+
minSize: { value: e, message: f.toString(n) }
|
|
2348
2282
|
});
|
|
2349
2283
|
}
|
|
2350
2284
|
max(e, n) {
|
|
2351
2285
|
return new ne({
|
|
2352
2286
|
...this._def,
|
|
2353
|
-
maxSize: { value: e, message:
|
|
2287
|
+
maxSize: { value: e, message: f.toString(n) }
|
|
2354
2288
|
});
|
|
2355
2289
|
}
|
|
2356
2290
|
size(e, n) {
|
|
@@ -2364,101 +2298,10 @@ ne.create = (t, e) => new ne({
|
|
|
2364
2298
|
valueType: t,
|
|
2365
2299
|
minSize: null,
|
|
2366
2300
|
maxSize: null,
|
|
2367
|
-
typeName:
|
|
2368
|
-
...
|
|
2301
|
+
typeName: m.ZodSet,
|
|
2302
|
+
...g(e)
|
|
2369
2303
|
});
|
|
2370
|
-
class
|
|
2371
|
-
constructor() {
|
|
2372
|
-
super(...arguments), this.validate = this.implement;
|
|
2373
|
-
}
|
|
2374
|
-
_parse(e) {
|
|
2375
|
-
const { ctx: n } = this._processInputParams(e);
|
|
2376
|
-
if (n.parsedType !== f.function)
|
|
2377
|
-
return l(n, {
|
|
2378
|
-
code: u.invalid_type,
|
|
2379
|
-
expected: f.function,
|
|
2380
|
-
received: n.parsedType
|
|
2381
|
-
}), m;
|
|
2382
|
-
function s(o, c) {
|
|
2383
|
-
return Re({
|
|
2384
|
-
data: o,
|
|
2385
|
-
path: n.path,
|
|
2386
|
-
errorMaps: [n.common.contextualErrorMap, n.schemaErrorMap, Ne(), oe].filter((d) => !!d),
|
|
2387
|
-
issueData: {
|
|
2388
|
-
code: u.invalid_arguments,
|
|
2389
|
-
argumentsError: c
|
|
2390
|
-
}
|
|
2391
|
-
});
|
|
2392
|
-
}
|
|
2393
|
-
function r(o, c) {
|
|
2394
|
-
return Re({
|
|
2395
|
-
data: o,
|
|
2396
|
-
path: n.path,
|
|
2397
|
-
errorMaps: [n.common.contextualErrorMap, n.schemaErrorMap, Ne(), oe].filter((d) => !!d),
|
|
2398
|
-
issueData: {
|
|
2399
|
-
code: u.invalid_return_type,
|
|
2400
|
-
returnTypeError: c
|
|
2401
|
-
}
|
|
2402
|
-
});
|
|
2403
|
-
}
|
|
2404
|
-
const a = { errorMap: n.common.contextualErrorMap }, i = n.data;
|
|
2405
|
-
if (this._def.returns instanceof de) {
|
|
2406
|
-
const o = this;
|
|
2407
|
-
return C(async function(...c) {
|
|
2408
|
-
const d = new N([]), h = await o._def.args.parseAsync(c, a).catch((w) => {
|
|
2409
|
-
throw d.addIssue(s(c, w)), d;
|
|
2410
|
-
}), x = await Reflect.apply(i, this, h);
|
|
2411
|
-
return await o._def.returns._def.type.parseAsync(x, a).catch((w) => {
|
|
2412
|
-
throw d.addIssue(r(x, w)), d;
|
|
2413
|
-
});
|
|
2414
|
-
});
|
|
2415
|
-
} else {
|
|
2416
|
-
const o = this;
|
|
2417
|
-
return C(function(...c) {
|
|
2418
|
-
const d = o._def.args.safeParse(c, a);
|
|
2419
|
-
if (!d.success)
|
|
2420
|
-
throw new N([s(c, d.error)]);
|
|
2421
|
-
const h = Reflect.apply(i, this, d.data), x = o._def.returns.safeParse(h, a);
|
|
2422
|
-
if (!x.success)
|
|
2423
|
-
throw new N([r(h, x.error)]);
|
|
2424
|
-
return x.data;
|
|
2425
|
-
});
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
parameters() {
|
|
2429
|
-
return this._def.args;
|
|
2430
|
-
}
|
|
2431
|
-
returnType() {
|
|
2432
|
-
return this._def.returns;
|
|
2433
|
-
}
|
|
2434
|
-
args(...e) {
|
|
2435
|
-
return new ie({
|
|
2436
|
-
...this._def,
|
|
2437
|
-
args: P.create(e).rest(X.create())
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
|
-
returns(e) {
|
|
2441
|
-
return new ie({
|
|
2442
|
-
...this._def,
|
|
2443
|
-
returns: e
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
implement(e) {
|
|
2447
|
-
return this.parse(e);
|
|
2448
|
-
}
|
|
2449
|
-
strictImplement(e) {
|
|
2450
|
-
return this.parse(e);
|
|
2451
|
-
}
|
|
2452
|
-
static create(e, n, s) {
|
|
2453
|
-
return new ie({
|
|
2454
|
-
args: e || P.create([]).rest(X.create()),
|
|
2455
|
-
returns: n || X.create(),
|
|
2456
|
-
typeName: y.ZodFunction,
|
|
2457
|
-
..._(s)
|
|
2458
|
-
});
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
class be extends v {
|
|
2304
|
+
class Be extends v {
|
|
2462
2305
|
get schema() {
|
|
2463
2306
|
return this._def.getter();
|
|
2464
2307
|
}
|
|
@@ -2467,20 +2310,20 @@ class be extends v {
|
|
|
2467
2310
|
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2468
2311
|
}
|
|
2469
2312
|
}
|
|
2470
|
-
|
|
2313
|
+
Be.create = (t, e) => new Be({
|
|
2471
2314
|
getter: t,
|
|
2472
|
-
typeName:
|
|
2473
|
-
...
|
|
2315
|
+
typeName: m.ZodLazy,
|
|
2316
|
+
...g(e)
|
|
2474
2317
|
});
|
|
2475
|
-
class
|
|
2318
|
+
class Fe extends v {
|
|
2476
2319
|
_parse(e) {
|
|
2477
2320
|
if (e.data !== this._def.value) {
|
|
2478
2321
|
const n = this._getOrReturnCtx(e);
|
|
2479
2322
|
return l(n, {
|
|
2480
2323
|
received: n.data,
|
|
2481
|
-
code:
|
|
2324
|
+
code: d.invalid_literal,
|
|
2482
2325
|
expected: this._def.value
|
|
2483
|
-
}),
|
|
2326
|
+
}), y;
|
|
2484
2327
|
}
|
|
2485
2328
|
return { status: "valid", value: e.data };
|
|
2486
2329
|
}
|
|
@@ -2488,37 +2331,37 @@ class xe extends v {
|
|
|
2488
2331
|
return this._def.value;
|
|
2489
2332
|
}
|
|
2490
2333
|
}
|
|
2491
|
-
|
|
2334
|
+
Fe.create = (t, e) => new Fe({
|
|
2492
2335
|
value: t,
|
|
2493
|
-
typeName:
|
|
2494
|
-
...
|
|
2336
|
+
typeName: m.ZodLiteral,
|
|
2337
|
+
...g(e)
|
|
2495
2338
|
});
|
|
2496
|
-
function
|
|
2497
|
-
return new
|
|
2339
|
+
function st(t, e) {
|
|
2340
|
+
return new Y({
|
|
2498
2341
|
values: t,
|
|
2499
|
-
typeName:
|
|
2500
|
-
...
|
|
2342
|
+
typeName: m.ZodEnum,
|
|
2343
|
+
...g(e)
|
|
2501
2344
|
});
|
|
2502
2345
|
}
|
|
2503
|
-
class
|
|
2346
|
+
class Y extends v {
|
|
2504
2347
|
_parse(e) {
|
|
2505
2348
|
if (typeof e.data != "string") {
|
|
2506
2349
|
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2507
2350
|
return l(n, {
|
|
2508
2351
|
expected: b.joinValues(s),
|
|
2509
2352
|
received: n.parsedType,
|
|
2510
|
-
code:
|
|
2511
|
-
}),
|
|
2353
|
+
code: d.invalid_type
|
|
2354
|
+
}), y;
|
|
2512
2355
|
}
|
|
2513
2356
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2514
2357
|
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2515
2358
|
return l(n, {
|
|
2516
2359
|
received: n.data,
|
|
2517
|
-
code:
|
|
2360
|
+
code: d.invalid_enum_value,
|
|
2518
2361
|
options: s
|
|
2519
|
-
}),
|
|
2362
|
+
}), y;
|
|
2520
2363
|
}
|
|
2521
|
-
return
|
|
2364
|
+
return N(e.data);
|
|
2522
2365
|
}
|
|
2523
2366
|
get options() {
|
|
2524
2367
|
return this._def.values;
|
|
@@ -2542,79 +2385,79 @@ class Q extends v {
|
|
|
2542
2385
|
return e;
|
|
2543
2386
|
}
|
|
2544
2387
|
extract(e, n = this._def) {
|
|
2545
|
-
return
|
|
2388
|
+
return Y.create(e, {
|
|
2546
2389
|
...this._def,
|
|
2547
2390
|
...n
|
|
2548
2391
|
});
|
|
2549
2392
|
}
|
|
2550
2393
|
exclude(e, n = this._def) {
|
|
2551
|
-
return
|
|
2394
|
+
return Y.create(this.options.filter((s) => !e.includes(s)), {
|
|
2552
2395
|
...this._def,
|
|
2553
2396
|
...n
|
|
2554
2397
|
});
|
|
2555
2398
|
}
|
|
2556
2399
|
}
|
|
2557
|
-
|
|
2558
|
-
class
|
|
2400
|
+
Y.create = st;
|
|
2401
|
+
class Ue extends v {
|
|
2559
2402
|
_parse(e) {
|
|
2560
2403
|
const n = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2561
|
-
if (s.parsedType !==
|
|
2404
|
+
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
2562
2405
|
const r = b.objectValues(n);
|
|
2563
2406
|
return l(s, {
|
|
2564
2407
|
expected: b.joinValues(r),
|
|
2565
2408
|
received: s.parsedType,
|
|
2566
|
-
code:
|
|
2567
|
-
}),
|
|
2409
|
+
code: d.invalid_type
|
|
2410
|
+
}), y;
|
|
2568
2411
|
}
|
|
2569
2412
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2570
2413
|
const r = b.objectValues(n);
|
|
2571
2414
|
return l(s, {
|
|
2572
2415
|
received: s.data,
|
|
2573
|
-
code:
|
|
2416
|
+
code: d.invalid_enum_value,
|
|
2574
2417
|
options: r
|
|
2575
|
-
}),
|
|
2418
|
+
}), y;
|
|
2576
2419
|
}
|
|
2577
|
-
return
|
|
2420
|
+
return N(e.data);
|
|
2578
2421
|
}
|
|
2579
2422
|
get enum() {
|
|
2580
2423
|
return this._def.values;
|
|
2581
2424
|
}
|
|
2582
2425
|
}
|
|
2583
|
-
|
|
2426
|
+
Ue.create = (t, e) => new Ue({
|
|
2584
2427
|
values: t,
|
|
2585
|
-
typeName:
|
|
2586
|
-
...
|
|
2428
|
+
typeName: m.ZodNativeEnum,
|
|
2429
|
+
...g(e)
|
|
2587
2430
|
});
|
|
2588
|
-
class
|
|
2431
|
+
class le extends v {
|
|
2589
2432
|
unwrap() {
|
|
2590
2433
|
return this._def.type;
|
|
2591
2434
|
}
|
|
2592
2435
|
_parse(e) {
|
|
2593
2436
|
const { ctx: n } = this._processInputParams(e);
|
|
2594
|
-
if (n.parsedType !==
|
|
2437
|
+
if (n.parsedType !== h.promise && n.common.async === !1)
|
|
2595
2438
|
return l(n, {
|
|
2596
|
-
code:
|
|
2597
|
-
expected:
|
|
2439
|
+
code: d.invalid_type,
|
|
2440
|
+
expected: h.promise,
|
|
2598
2441
|
received: n.parsedType
|
|
2599
|
-
}),
|
|
2600
|
-
const s = n.parsedType ===
|
|
2601
|
-
return
|
|
2442
|
+
}), y;
|
|
2443
|
+
const s = n.parsedType === h.promise ? n.data : Promise.resolve(n.data);
|
|
2444
|
+
return N(s.then((r) => this._def.type.parseAsync(r, {
|
|
2602
2445
|
path: n.path,
|
|
2603
2446
|
errorMap: n.common.contextualErrorMap
|
|
2604
2447
|
})));
|
|
2605
2448
|
}
|
|
2606
2449
|
}
|
|
2607
|
-
|
|
2450
|
+
le.create = (t, e) => new le({
|
|
2608
2451
|
type: t,
|
|
2609
|
-
typeName:
|
|
2610
|
-
...
|
|
2452
|
+
typeName: m.ZodPromise,
|
|
2453
|
+
...g(e)
|
|
2611
2454
|
});
|
|
2612
|
-
class
|
|
2455
|
+
class U extends v {
|
|
2613
2456
|
innerType() {
|
|
2614
2457
|
return this._def.schema;
|
|
2615
2458
|
}
|
|
2616
2459
|
sourceType() {
|
|
2617
|
-
return this._def.schema._def.typeName ===
|
|
2460
|
+
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2618
2461
|
}
|
|
2619
2462
|
_parse(e) {
|
|
2620
2463
|
const { status: n, ctx: s } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
@@ -2630,23 +2473,23 @@ class j extends v {
|
|
|
2630
2473
|
if (s.common.async)
|
|
2631
2474
|
return Promise.resolve(i).then(async (o) => {
|
|
2632
2475
|
if (n.value === "aborted")
|
|
2633
|
-
return
|
|
2476
|
+
return y;
|
|
2634
2477
|
const c = await this._def.schema._parseAsync({
|
|
2635
2478
|
data: o,
|
|
2636
2479
|
path: s.path,
|
|
2637
2480
|
parent: s
|
|
2638
2481
|
});
|
|
2639
|
-
return c.status === "aborted" ?
|
|
2482
|
+
return c.status === "aborted" ? y : c.status === "dirty" || n.value === "dirty" ? ee(c.value) : c;
|
|
2640
2483
|
});
|
|
2641
2484
|
{
|
|
2642
2485
|
if (n.value === "aborted")
|
|
2643
|
-
return
|
|
2486
|
+
return y;
|
|
2644
2487
|
const o = this._def.schema._parseSync({
|
|
2645
2488
|
data: i,
|
|
2646
2489
|
path: s.path,
|
|
2647
2490
|
parent: s
|
|
2648
2491
|
});
|
|
2649
|
-
return o.status === "aborted" ?
|
|
2492
|
+
return o.status === "aborted" ? y : o.status === "dirty" || n.value === "dirty" ? ee(o.value) : o;
|
|
2650
2493
|
}
|
|
2651
2494
|
}
|
|
2652
2495
|
if (r.type === "refinement") {
|
|
@@ -2664,9 +2507,9 @@ class j extends v {
|
|
|
2664
2507
|
path: s.path,
|
|
2665
2508
|
parent: s
|
|
2666
2509
|
});
|
|
2667
|
-
return o.status === "aborted" ?
|
|
2510
|
+
return o.status === "aborted" ? y : (o.status === "dirty" && n.dirty(), i(o.value), { status: n.value, value: o.value });
|
|
2668
2511
|
} else
|
|
2669
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ?
|
|
2512
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && n.dirty(), i(o.value).then(() => ({ status: n.value, value: o.value }))));
|
|
2670
2513
|
}
|
|
2671
2514
|
if (r.type === "transform")
|
|
2672
2515
|
if (s.common.async === !1) {
|
|
@@ -2675,63 +2518,63 @@ class j extends v {
|
|
|
2675
2518
|
path: s.path,
|
|
2676
2519
|
parent: s
|
|
2677
2520
|
});
|
|
2678
|
-
if (!
|
|
2679
|
-
return
|
|
2521
|
+
if (!H(i))
|
|
2522
|
+
return y;
|
|
2680
2523
|
const o = r.transform(i.value, a);
|
|
2681
2524
|
if (o instanceof Promise)
|
|
2682
2525
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2683
2526
|
return { status: n.value, value: o };
|
|
2684
2527
|
} else
|
|
2685
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) =>
|
|
2528
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => H(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2686
2529
|
status: n.value,
|
|
2687
2530
|
value: o
|
|
2688
|
-
})) :
|
|
2531
|
+
})) : y);
|
|
2689
2532
|
b.assertNever(r);
|
|
2690
2533
|
}
|
|
2691
2534
|
}
|
|
2692
|
-
|
|
2535
|
+
U.create = (t, e, n) => new U({
|
|
2693
2536
|
schema: t,
|
|
2694
|
-
typeName:
|
|
2537
|
+
typeName: m.ZodEffects,
|
|
2695
2538
|
effect: e,
|
|
2696
|
-
...
|
|
2539
|
+
...g(n)
|
|
2697
2540
|
});
|
|
2698
|
-
|
|
2541
|
+
U.createWithPreprocess = (t, e, n) => new U({
|
|
2699
2542
|
schema: e,
|
|
2700
2543
|
effect: { type: "preprocess", transform: t },
|
|
2701
|
-
typeName:
|
|
2702
|
-
...
|
|
2544
|
+
typeName: m.ZodEffects,
|
|
2545
|
+
...g(n)
|
|
2703
2546
|
});
|
|
2704
|
-
class
|
|
2547
|
+
class V extends v {
|
|
2705
2548
|
_parse(e) {
|
|
2706
|
-
return this._getType(e) ===
|
|
2549
|
+
return this._getType(e) === h.undefined ? N(void 0) : this._def.innerType._parse(e);
|
|
2707
2550
|
}
|
|
2708
2551
|
unwrap() {
|
|
2709
2552
|
return this._def.innerType;
|
|
2710
2553
|
}
|
|
2711
2554
|
}
|
|
2712
|
-
|
|
2555
|
+
V.create = (t, e) => new V({
|
|
2713
2556
|
innerType: t,
|
|
2714
|
-
typeName:
|
|
2715
|
-
...
|
|
2557
|
+
typeName: m.ZodOptional,
|
|
2558
|
+
...g(e)
|
|
2716
2559
|
});
|
|
2717
|
-
class
|
|
2560
|
+
class K extends v {
|
|
2718
2561
|
_parse(e) {
|
|
2719
|
-
return this._getType(e) ===
|
|
2562
|
+
return this._getType(e) === h.null ? N(null) : this._def.innerType._parse(e);
|
|
2720
2563
|
}
|
|
2721
2564
|
unwrap() {
|
|
2722
2565
|
return this._def.innerType;
|
|
2723
2566
|
}
|
|
2724
2567
|
}
|
|
2725
|
-
|
|
2568
|
+
K.create = (t, e) => new K({
|
|
2726
2569
|
innerType: t,
|
|
2727
|
-
typeName:
|
|
2728
|
-
...
|
|
2570
|
+
typeName: m.ZodNullable,
|
|
2571
|
+
...g(e)
|
|
2729
2572
|
});
|
|
2730
|
-
class
|
|
2573
|
+
class ye extends v {
|
|
2731
2574
|
_parse(e) {
|
|
2732
2575
|
const { ctx: n } = this._processInputParams(e);
|
|
2733
2576
|
let s = n.data;
|
|
2734
|
-
return n.parsedType ===
|
|
2577
|
+
return n.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2735
2578
|
data: s,
|
|
2736
2579
|
path: n.path,
|
|
2737
2580
|
parent: n
|
|
@@ -2741,13 +2584,13 @@ class we extends v {
|
|
|
2741
2584
|
return this._def.innerType;
|
|
2742
2585
|
}
|
|
2743
2586
|
}
|
|
2744
|
-
|
|
2587
|
+
ye.create = (t, e) => new ye({
|
|
2745
2588
|
innerType: t,
|
|
2746
|
-
typeName:
|
|
2589
|
+
typeName: m.ZodDefault,
|
|
2747
2590
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2748
|
-
...
|
|
2591
|
+
...g(e)
|
|
2749
2592
|
});
|
|
2750
|
-
class
|
|
2593
|
+
class _e extends v {
|
|
2751
2594
|
_parse(e) {
|
|
2752
2595
|
const { ctx: n } = this._processInputParams(e), s = {
|
|
2753
2596
|
...n,
|
|
@@ -2762,11 +2605,11 @@ class Te extends v {
|
|
|
2762
2605
|
...s
|
|
2763
2606
|
}
|
|
2764
2607
|
});
|
|
2765
|
-
return
|
|
2608
|
+
return ie(r) ? r.then((a) => ({
|
|
2766
2609
|
status: "valid",
|
|
2767
2610
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2768
2611
|
get error() {
|
|
2769
|
-
return new
|
|
2612
|
+
return new Z(s.common.issues);
|
|
2770
2613
|
},
|
|
2771
2614
|
input: s.data
|
|
2772
2615
|
})
|
|
@@ -2774,7 +2617,7 @@ class Te extends v {
|
|
|
2774
2617
|
status: "valid",
|
|
2775
2618
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2776
2619
|
get error() {
|
|
2777
|
-
return new
|
|
2620
|
+
return new Z(s.common.issues);
|
|
2778
2621
|
},
|
|
2779
2622
|
input: s.data
|
|
2780
2623
|
})
|
|
@@ -2784,31 +2627,30 @@ class Te extends v {
|
|
|
2784
2627
|
return this._def.innerType;
|
|
2785
2628
|
}
|
|
2786
2629
|
}
|
|
2787
|
-
|
|
2630
|
+
_e.create = (t, e) => new _e({
|
|
2788
2631
|
innerType: t,
|
|
2789
|
-
typeName:
|
|
2632
|
+
typeName: m.ZodCatch,
|
|
2790
2633
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2791
|
-
...
|
|
2634
|
+
...g(e)
|
|
2792
2635
|
});
|
|
2793
|
-
class
|
|
2636
|
+
class qe extends v {
|
|
2794
2637
|
_parse(e) {
|
|
2795
|
-
if (this._getType(e) !==
|
|
2638
|
+
if (this._getType(e) !== h.nan) {
|
|
2796
2639
|
const s = this._getOrReturnCtx(e);
|
|
2797
2640
|
return l(s, {
|
|
2798
|
-
code:
|
|
2799
|
-
expected:
|
|
2641
|
+
code: d.invalid_type,
|
|
2642
|
+
expected: h.nan,
|
|
2800
2643
|
received: s.parsedType
|
|
2801
|
-
}),
|
|
2644
|
+
}), y;
|
|
2802
2645
|
}
|
|
2803
2646
|
return { status: "valid", value: e.data };
|
|
2804
2647
|
}
|
|
2805
2648
|
}
|
|
2806
|
-
|
|
2807
|
-
typeName:
|
|
2808
|
-
...
|
|
2649
|
+
qe.create = (t) => new qe({
|
|
2650
|
+
typeName: m.ZodNaN,
|
|
2651
|
+
...g(t)
|
|
2809
2652
|
});
|
|
2810
|
-
|
|
2811
|
-
class Xe extends v {
|
|
2653
|
+
class rt extends v {
|
|
2812
2654
|
_parse(e) {
|
|
2813
2655
|
const { ctx: n } = this._processInputParams(e), s = n.data;
|
|
2814
2656
|
return this._def.type._parse({
|
|
@@ -2821,7 +2663,7 @@ class Xe extends v {
|
|
|
2821
2663
|
return this._def.type;
|
|
2822
2664
|
}
|
|
2823
2665
|
}
|
|
2824
|
-
class
|
|
2666
|
+
class xe extends v {
|
|
2825
2667
|
_parse(e) {
|
|
2826
2668
|
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2827
2669
|
if (s.common.async)
|
|
@@ -2831,7 +2673,7 @@ class Ce extends v {
|
|
|
2831
2673
|
path: s.path,
|
|
2832
2674
|
parent: s
|
|
2833
2675
|
});
|
|
2834
|
-
return a.status === "aborted" ?
|
|
2676
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (n.dirty(), ee(a.value)) : this._def.out._parseAsync({
|
|
2835
2677
|
data: a.value,
|
|
2836
2678
|
path: s.path,
|
|
2837
2679
|
parent: s
|
|
@@ -2843,7 +2685,7 @@ class Ce extends v {
|
|
|
2843
2685
|
path: s.path,
|
|
2844
2686
|
parent: s
|
|
2845
2687
|
});
|
|
2846
|
-
return r.status === "aborted" ?
|
|
2688
|
+
return r.status === "aborted" ? y : r.status === "dirty" ? (n.dirty(), {
|
|
2847
2689
|
status: "dirty",
|
|
2848
2690
|
value: r.value
|
|
2849
2691
|
}) : this._def.out._parseSync({
|
|
@@ -2854,183 +2696,117 @@ class Ce extends v {
|
|
|
2854
2696
|
}
|
|
2855
2697
|
}
|
|
2856
2698
|
static create(e, n) {
|
|
2857
|
-
return new
|
|
2699
|
+
return new xe({
|
|
2858
2700
|
in: e,
|
|
2859
2701
|
out: n,
|
|
2860
|
-
typeName:
|
|
2702
|
+
typeName: m.ZodPipeline
|
|
2861
2703
|
});
|
|
2862
2704
|
}
|
|
2863
2705
|
}
|
|
2864
|
-
class
|
|
2706
|
+
class ge extends v {
|
|
2865
2707
|
_parse(e) {
|
|
2866
|
-
const n = this._def.innerType._parse(e), s = (r) => (
|
|
2867
|
-
return
|
|
2708
|
+
const n = this._def.innerType._parse(e), s = (r) => (H(r) && (r.value = Object.freeze(r.value)), r);
|
|
2709
|
+
return ie(n) ? n.then((r) => s(r)) : s(n);
|
|
2868
2710
|
}
|
|
2869
2711
|
unwrap() {
|
|
2870
2712
|
return this._def.innerType;
|
|
2871
2713
|
}
|
|
2872
2714
|
}
|
|
2873
|
-
|
|
2715
|
+
ge.create = (t, e) => new ge({
|
|
2874
2716
|
innerType: t,
|
|
2875
|
-
typeName:
|
|
2876
|
-
...
|
|
2717
|
+
typeName: m.ZodReadonly,
|
|
2718
|
+
...g(e)
|
|
2877
2719
|
});
|
|
2878
|
-
|
|
2879
|
-
const n = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
|
|
2880
|
-
return typeof n == "string" ? { message: n } : n;
|
|
2881
|
-
}
|
|
2882
|
-
function ft(t, e = {}, n) {
|
|
2883
|
-
return t ? ce.create().superRefine((s, r) => {
|
|
2884
|
-
const a = t(s);
|
|
2885
|
-
if (a instanceof Promise)
|
|
2886
|
-
return a.then((i) => {
|
|
2887
|
-
if (!i) {
|
|
2888
|
-
const o = nt(e, s), c = o.fatal ?? n ?? !0;
|
|
2889
|
-
r.addIssue({ code: "custom", ...o, fatal: c });
|
|
2890
|
-
}
|
|
2891
|
-
});
|
|
2892
|
-
if (!a) {
|
|
2893
|
-
const i = nt(e, s), o = i.fatal ?? n ?? !0;
|
|
2894
|
-
r.addIssue({ code: "custom", ...i, fatal: o });
|
|
2895
|
-
}
|
|
2896
|
-
}) : ce.create();
|
|
2897
|
-
}
|
|
2898
|
-
const Jt = {
|
|
2899
|
-
object: T.lazycreate
|
|
2900
|
-
};
|
|
2901
|
-
var y;
|
|
2720
|
+
var m;
|
|
2902
2721
|
(function(t) {
|
|
2903
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";
|
|
2904
|
-
})(
|
|
2905
|
-
const
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2723
|
+
})(m || (m = {}));
|
|
2724
|
+
const _ = j.create, at = J.create, ke = me.create;
|
|
2725
|
+
z.create;
|
|
2726
|
+
const A = R.create, $ = w.create;
|
|
2727
|
+
ce.create;
|
|
2728
|
+
de.create;
|
|
2729
|
+
F.create;
|
|
2730
|
+
const it = ue.create;
|
|
2731
|
+
Y.create;
|
|
2732
|
+
le.create;
|
|
2733
|
+
V.create;
|
|
2734
|
+
K.create;
|
|
2735
|
+
const Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2917
2736
|
__proto__: null,
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
NEVER: An,
|
|
2923
|
-
OK: C,
|
|
2924
|
-
ParseStatus: E,
|
|
2737
|
+
DIRTY: ee,
|
|
2738
|
+
INVALID: y,
|
|
2739
|
+
OK: N,
|
|
2740
|
+
ParseStatus: C,
|
|
2925
2741
|
Schema: v,
|
|
2926
|
-
ZodAny:
|
|
2927
|
-
ZodArray:
|
|
2928
|
-
ZodBigInt:
|
|
2929
|
-
ZodBoolean:
|
|
2930
|
-
ZodBranded:
|
|
2931
|
-
ZodCatch:
|
|
2932
|
-
ZodDate:
|
|
2933
|
-
ZodDefault:
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
ZodError: N,
|
|
2742
|
+
ZodAny: Le,
|
|
2743
|
+
ZodArray: R,
|
|
2744
|
+
ZodBigInt: te,
|
|
2745
|
+
ZodBoolean: me,
|
|
2746
|
+
ZodBranded: rt,
|
|
2747
|
+
ZodCatch: _e,
|
|
2748
|
+
ZodDate: oe,
|
|
2749
|
+
ZodDefault: ye,
|
|
2750
|
+
ZodEffects: U,
|
|
2751
|
+
ZodEnum: Y,
|
|
2752
|
+
ZodError: Z,
|
|
2938
2753
|
get ZodFirstPartyTypeKind() {
|
|
2939
|
-
return
|
|
2754
|
+
return m;
|
|
2940
2755
|
},
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
ZodRecord: ve,
|
|
2756
|
+
ZodIntersection: de,
|
|
2757
|
+
ZodIssueCode: d,
|
|
2758
|
+
ZodLazy: Be,
|
|
2759
|
+
ZodLiteral: Fe,
|
|
2760
|
+
ZodMap: ze,
|
|
2761
|
+
ZodNaN: qe,
|
|
2762
|
+
ZodNativeEnum: Ue,
|
|
2763
|
+
ZodNever: z,
|
|
2764
|
+
ZodNull: De,
|
|
2765
|
+
ZodNullable: K,
|
|
2766
|
+
ZodNumber: J,
|
|
2767
|
+
ZodObject: w,
|
|
2768
|
+
ZodOptional: V,
|
|
2769
|
+
ZodParsedType: h,
|
|
2770
|
+
ZodPipeline: xe,
|
|
2771
|
+
ZodPromise: le,
|
|
2772
|
+
ZodReadonly: ge,
|
|
2773
|
+
ZodRecord: ue,
|
|
2960
2774
|
ZodSchema: v,
|
|
2961
2775
|
ZodSet: ne,
|
|
2962
|
-
ZodString:
|
|
2963
|
-
ZodSymbol:
|
|
2964
|
-
ZodTransformer:
|
|
2965
|
-
ZodTuple:
|
|
2776
|
+
ZodString: j,
|
|
2777
|
+
ZodSymbol: je,
|
|
2778
|
+
ZodTransformer: U,
|
|
2779
|
+
ZodTuple: F,
|
|
2966
2780
|
ZodType: v,
|
|
2967
|
-
ZodUndefined:
|
|
2968
|
-
ZodUnion:
|
|
2969
|
-
ZodUnknown:
|
|
2970
|
-
ZodVoid:
|
|
2781
|
+
ZodUndefined: Ze,
|
|
2782
|
+
ZodUnion: ce,
|
|
2783
|
+
ZodUnknown: Pe,
|
|
2784
|
+
ZodVoid: Me,
|
|
2971
2785
|
addIssueToContext: l,
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
getErrorMap: Ne,
|
|
2986
|
-
getParsedType: B,
|
|
2987
|
-
instanceof: Yt,
|
|
2988
|
-
intersection: ln,
|
|
2989
|
-
isAborted: Qe,
|
|
2990
|
-
isAsync: he,
|
|
2991
|
-
isDirty: Je,
|
|
2992
|
-
isValid: ee,
|
|
2993
|
-
late: Jt,
|
|
2994
|
-
lazy: yn,
|
|
2995
|
-
literal: _n,
|
|
2996
|
-
makeIssue: Re,
|
|
2997
|
-
map: hn,
|
|
2998
|
-
nan: Kt,
|
|
2999
|
-
nativeEnum: vn,
|
|
3000
|
-
never: an,
|
|
3001
|
-
null: nn,
|
|
3002
|
-
nullable: kn,
|
|
3003
|
-
number: et,
|
|
3004
|
-
object: Z,
|
|
2786
|
+
array: A,
|
|
2787
|
+
boolean: ke,
|
|
2788
|
+
datetimeRegex: nt,
|
|
2789
|
+
defaultErrorMap: pe,
|
|
2790
|
+
getErrorMap: Ge,
|
|
2791
|
+
getParsedType: P,
|
|
2792
|
+
isAborted: $e,
|
|
2793
|
+
isAsync: ie,
|
|
2794
|
+
isDirty: Ie,
|
|
2795
|
+
isValid: H,
|
|
2796
|
+
makeIssue: Xe,
|
|
2797
|
+
number: at,
|
|
2798
|
+
object: $,
|
|
3005
2799
|
get objectUtil() {
|
|
3006
|
-
return
|
|
2800
|
+
return Re;
|
|
3007
2801
|
},
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
optional: xn,
|
|
3011
|
-
ostring: Sn,
|
|
3012
|
-
pipeline: Tn,
|
|
3013
|
-
preprocess: wn,
|
|
3014
|
-
promise: bn,
|
|
3015
|
-
quotelessJson: Tt,
|
|
3016
|
-
record: ht,
|
|
3017
|
-
set: pn,
|
|
3018
|
-
setErrorMap: St,
|
|
3019
|
-
strictObject: cn,
|
|
3020
|
-
string: g,
|
|
3021
|
-
symbol: en,
|
|
3022
|
-
transformer: st,
|
|
3023
|
-
tuple: fn,
|
|
3024
|
-
undefined: tn,
|
|
3025
|
-
union: dn,
|
|
3026
|
-
unknown: rn,
|
|
2802
|
+
record: it,
|
|
2803
|
+
string: _,
|
|
3027
2804
|
get util() {
|
|
3028
2805
|
return b;
|
|
3029
|
-
}
|
|
3030
|
-
void: on
|
|
2806
|
+
}
|
|
3031
2807
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3032
|
-
|
|
3033
|
-
const
|
|
2808
|
+
yt(Mt);
|
|
2809
|
+
const Vt = (t, e) => e.skipDedupe || e.method !== "GET", zt = (t, e) => e.method + "@" + t, Bt = (t) => t.clone(), Ft = ({ skip: t = Vt, key: e = zt, resolver: n = Bt } = {}) => {
|
|
3034
2810
|
const s = /* @__PURE__ */ new Map();
|
|
3035
2811
|
return (r) => (a, i) => {
|
|
3036
2812
|
if (t(a, i))
|
|
@@ -3039,120 +2815,120 @@ const Rn = (t, e) => e.skipDedupe || e.method !== "GET", $n = (t, e) => e.method
|
|
|
3039
2815
|
if (!s.has(o))
|
|
3040
2816
|
s.set(o, []);
|
|
3041
2817
|
else
|
|
3042
|
-
return new Promise((c,
|
|
3043
|
-
s.get(o).push([c,
|
|
2818
|
+
return new Promise((c, u) => {
|
|
2819
|
+
s.get(o).push([c, u]);
|
|
3044
2820
|
});
|
|
3045
2821
|
try {
|
|
3046
|
-
return r(a, i).then((c) => (s.get(o).forEach(([
|
|
3047
|
-
throw s.get(o).forEach(([,
|
|
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;
|
|
3048
2824
|
});
|
|
3049
2825
|
} catch (c) {
|
|
3050
2826
|
return s.delete(o), Promise.reject(c);
|
|
3051
2827
|
}
|
|
3052
2828
|
};
|
|
3053
|
-
},
|
|
3054
|
-
let
|
|
3055
|
-
if (o && o(
|
|
3056
|
-
return c(
|
|
3057
|
-
const
|
|
3058
|
-
const
|
|
2829
|
+
}, Ut = (t, e) => t * e, qt = (t) => t && (t.ok || t.status >= 400 && t.status < 500), Wt = ({ delayTimer: t = 500, delayRamp: e = Ut, maxAttempts: n = 10, until: s = qt, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (u, p) => {
|
|
2830
|
+
let k = 0;
|
|
2831
|
+
if (o && o(u, p))
|
|
2832
|
+
return c(u, p);
|
|
2833
|
+
const T = (S, E) => Promise.resolve(s(S, E)).then((q) => q ? S && i ? S : E ? Promise.reject(E) : S : (k++, !n || k <= n ? new Promise((x) => {
|
|
2834
|
+
const L = e(t, k);
|
|
3059
2835
|
setTimeout(() => {
|
|
3060
2836
|
typeof r == "function" ? Promise.resolve(r({
|
|
3061
|
-
response:
|
|
3062
|
-
error:
|
|
3063
|
-
url:
|
|
3064
|
-
attempt:
|
|
3065
|
-
options:
|
|
3066
|
-
})).then((
|
|
3067
|
-
var
|
|
3068
|
-
|
|
3069
|
-
}) :
|
|
3070
|
-
},
|
|
3071
|
-
}).then(
|
|
2837
|
+
response: S,
|
|
2838
|
+
error: E,
|
|
2839
|
+
url: u,
|
|
2840
|
+
attempt: k,
|
|
2841
|
+
options: p
|
|
2842
|
+
})).then((O = {}) => {
|
|
2843
|
+
var I, W;
|
|
2844
|
+
x(c((I = O && O.url) !== null && I !== void 0 ? I : u, (W = O && O.options) !== null && W !== void 0 ? W : p));
|
|
2845
|
+
}) : x(c(u, p));
|
|
2846
|
+
}, L);
|
|
2847
|
+
}).then(T).catch((x) => {
|
|
3072
2848
|
if (!a)
|
|
3073
|
-
throw
|
|
3074
|
-
return
|
|
3075
|
-
}) :
|
|
3076
|
-
return c(
|
|
2849
|
+
throw x;
|
|
2850
|
+
return T(null, x);
|
|
2851
|
+
}) : S && i ? S : Promise.reject(E || new Error("Number of attempts exceeded."))));
|
|
2852
|
+
return c(u, p).then(T).catch((S) => {
|
|
3077
2853
|
if (!a)
|
|
3078
|
-
throw
|
|
3079
|
-
return
|
|
2854
|
+
throw S;
|
|
2855
|
+
return T(null, S);
|
|
3080
2856
|
});
|
|
3081
|
-
},
|
|
3082
|
-
code:
|
|
3083
|
-
message:
|
|
3084
|
-
}),
|
|
3085
|
-
message:
|
|
3086
|
-
}),
|
|
3087
|
-
emails:
|
|
3088
|
-
http_body:
|
|
3089
|
-
http_url:
|
|
3090
|
-
txt_name:
|
|
3091
|
-
txt_value:
|
|
3092
|
-
}),
|
|
3093
|
-
ciphers:
|
|
3094
|
-
early_hints:
|
|
3095
|
-
http2:
|
|
3096
|
-
min_tls_version:
|
|
3097
|
-
tls_1_3:
|
|
3098
|
-
}),
|
|
3099
|
-
id:
|
|
3100
|
-
bundle_method:
|
|
3101
|
-
certificate_authority:
|
|
3102
|
-
custom_certificate:
|
|
3103
|
-
custom_csr_id:
|
|
3104
|
-
custom_key:
|
|
3105
|
-
expires_on:
|
|
3106
|
-
hosts:
|
|
3107
|
-
issuer:
|
|
3108
|
-
method:
|
|
3109
|
-
serial_number:
|
|
3110
|
-
settings:
|
|
3111
|
-
signature:
|
|
3112
|
-
type:
|
|
3113
|
-
uploaded_on:
|
|
3114
|
-
validation_errors:
|
|
3115
|
-
validation_records:
|
|
3116
|
-
wildcard:
|
|
3117
|
-
}),
|
|
3118
|
-
name:
|
|
3119
|
-
type:
|
|
3120
|
-
value:
|
|
3121
|
-
}),
|
|
3122
|
-
http_body:
|
|
3123
|
-
http_url:
|
|
3124
|
-
}),
|
|
3125
|
-
id:
|
|
3126
|
-
ssl:
|
|
3127
|
-
hostname:
|
|
3128
|
-
custom_metadata:
|
|
3129
|
-
custom_origin_server:
|
|
3130
|
-
custom_origin_sni:
|
|
3131
|
-
ownership_verification:
|
|
3132
|
-
ownership_verification_http:
|
|
3133
|
-
status:
|
|
3134
|
-
verification_errors:
|
|
3135
|
-
created_at:
|
|
3136
|
-
}),
|
|
3137
|
-
errors:
|
|
3138
|
-
messages:
|
|
3139
|
-
success:
|
|
3140
|
-
result:
|
|
2857
|
+
}, ve = $({
|
|
2858
|
+
code: at(),
|
|
2859
|
+
message: _()
|
|
2860
|
+
}), Qt = $({
|
|
2861
|
+
message: _()
|
|
2862
|
+
}), Ht = $({
|
|
2863
|
+
emails: A(_()).optional(),
|
|
2864
|
+
http_body: _().optional(),
|
|
2865
|
+
http_url: _().optional(),
|
|
2866
|
+
txt_name: _().optional(),
|
|
2867
|
+
txt_value: _().optional()
|
|
2868
|
+
}), Jt = $({
|
|
2869
|
+
ciphers: A(_()).optional(),
|
|
2870
|
+
early_hints: _().optional(),
|
|
2871
|
+
http2: _().optional(),
|
|
2872
|
+
min_tls_version: _().optional(),
|
|
2873
|
+
tls_1_3: _().optional()
|
|
2874
|
+
}), Yt = $({
|
|
2875
|
+
id: _(),
|
|
2876
|
+
bundle_method: _().optional(),
|
|
2877
|
+
certificate_authority: _(),
|
|
2878
|
+
custom_certificate: _().optional(),
|
|
2879
|
+
custom_csr_id: _().optional(),
|
|
2880
|
+
custom_key: _().optional(),
|
|
2881
|
+
expires_on: _().optional(),
|
|
2882
|
+
hosts: A(_()).optional(),
|
|
2883
|
+
issuer: _().optional(),
|
|
2884
|
+
method: _(),
|
|
2885
|
+
serial_number: _().optional(),
|
|
2886
|
+
settings: Jt.optional(),
|
|
2887
|
+
signature: _().optional(),
|
|
2888
|
+
type: _(),
|
|
2889
|
+
uploaded_on: _().optional(),
|
|
2890
|
+
validation_errors: A(Qt).optional(),
|
|
2891
|
+
validation_records: A(Ht).optional(),
|
|
2892
|
+
wildcard: ke()
|
|
2893
|
+
}), Kt = $({
|
|
2894
|
+
name: _(),
|
|
2895
|
+
type: _(),
|
|
2896
|
+
value: _()
|
|
2897
|
+
}), Gt = $({
|
|
2898
|
+
http_body: _().optional(),
|
|
2899
|
+
http_url: _().optional()
|
|
2900
|
+
}), ot = $({
|
|
2901
|
+
id: _(),
|
|
2902
|
+
ssl: Yt,
|
|
2903
|
+
hostname: _(),
|
|
2904
|
+
custom_metadata: it(_()).optional(),
|
|
2905
|
+
custom_origin_server: _().optional(),
|
|
2906
|
+
custom_origin_sni: _().optional(),
|
|
2907
|
+
ownership_verification: Kt.optional(),
|
|
2908
|
+
ownership_verification_http: Gt.optional(),
|
|
2909
|
+
status: _(),
|
|
2910
|
+
verification_errors: A(_()).optional(),
|
|
2911
|
+
created_at: _()
|
|
2912
|
+
}), fe = $({
|
|
2913
|
+
errors: A(ve),
|
|
2914
|
+
messages: A(ve),
|
|
2915
|
+
success: ke(),
|
|
2916
|
+
result: ot
|
|
3141
2917
|
});
|
|
3142
|
-
|
|
3143
|
-
errors:
|
|
3144
|
-
messages:
|
|
3145
|
-
success:
|
|
3146
|
-
result:
|
|
2918
|
+
$({
|
|
2919
|
+
errors: A(ve),
|
|
2920
|
+
messages: A(ve),
|
|
2921
|
+
success: ke(),
|
|
2922
|
+
result: A(ot)
|
|
3147
2923
|
});
|
|
3148
|
-
function
|
|
3149
|
-
return
|
|
2924
|
+
function G(t) {
|
|
2925
|
+
return ft(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({
|
|
3150
2926
|
"X-Auth-Email": t.authEmail,
|
|
3151
2927
|
"X-Auth-Key": t.authKey,
|
|
3152
2928
|
"Content-Type": "application/json"
|
|
3153
|
-
}).middlewares([
|
|
2929
|
+
}).middlewares([Wt(), Ft()]);
|
|
3154
2930
|
}
|
|
3155
|
-
function
|
|
2931
|
+
function Ne(t) {
|
|
3156
2932
|
const e = [];
|
|
3157
2933
|
if (t.ssl.validation_records)
|
|
3158
2934
|
for (const n of t.ssl.validation_records)
|
|
@@ -3172,15 +2948,15 @@ function We(t) {
|
|
|
3172
2948
|
status: t.status === "active" ? "ready" : "pending",
|
|
3173
2949
|
type: "auth0_managed_certs",
|
|
3174
2950
|
verification: {
|
|
3175
|
-
methods:
|
|
2951
|
+
methods: A(ht).parse(e)
|
|
3176
2952
|
}
|
|
3177
2953
|
};
|
|
3178
2954
|
}
|
|
3179
|
-
function
|
|
2955
|
+
function Xt(t) {
|
|
3180
2956
|
return {
|
|
3181
2957
|
create: async (e, n) => {
|
|
3182
|
-
const { result: s, errors: r, success: a } =
|
|
3183
|
-
await
|
|
2958
|
+
const { result: s, errors: r, success: a } = fe.parse(
|
|
2959
|
+
await G(t).post(
|
|
3184
2960
|
{
|
|
3185
2961
|
hostname: n.domain,
|
|
3186
2962
|
ssl: {
|
|
@@ -3196,7 +2972,7 @@ function Un(t) {
|
|
|
3196
2972
|
);
|
|
3197
2973
|
if (!a)
|
|
3198
2974
|
throw new Error(JSON.stringify(r));
|
|
3199
|
-
const i =
|
|
2975
|
+
const i = Ne({
|
|
3200
2976
|
...s,
|
|
3201
2977
|
primary: !1
|
|
3202
2978
|
});
|
|
@@ -3212,15 +2988,15 @@ function Un(t) {
|
|
|
3212
2988
|
n
|
|
3213
2989
|
);
|
|
3214
2990
|
if (!s)
|
|
3215
|
-
throw new
|
|
3216
|
-
const r = await
|
|
2991
|
+
throw new ae(404);
|
|
2992
|
+
const r = await G(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: a, errors: i, success: o } = fe.parse(r);
|
|
3217
2993
|
if (!o)
|
|
3218
|
-
throw new
|
|
2994
|
+
throw new ae(503, {
|
|
3219
2995
|
message: JSON.stringify(i)
|
|
3220
2996
|
});
|
|
3221
2997
|
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3222
|
-
throw new
|
|
3223
|
-
return
|
|
2998
|
+
throw new ae(404);
|
|
2999
|
+
return Ne({ ...s, ...a });
|
|
3224
3000
|
},
|
|
3225
3001
|
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3226
3002
|
list: async (e) => {
|
|
@@ -3228,10 +3004,10 @@ function Un(t) {
|
|
|
3228
3004
|
return (await Promise.all(
|
|
3229
3005
|
n.map(async (r) => {
|
|
3230
3006
|
try {
|
|
3231
|
-
const a = await
|
|
3007
|
+
const a = await G(t).get(
|
|
3232
3008
|
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
3233
|
-
).json(), { result: i, success: o } =
|
|
3234
|
-
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null :
|
|
3009
|
+
).json(), { result: i, success: o } = fe.parse(a);
|
|
3010
|
+
return !o || t.enterprise && i.custom_metadata?.tenant_id !== e ? null : Ne({
|
|
3235
3011
|
...r,
|
|
3236
3012
|
...i
|
|
3237
3013
|
});
|
|
@@ -3243,22 +3019,22 @@ function Un(t) {
|
|
|
3243
3019
|
},
|
|
3244
3020
|
remove: async (e, n) => {
|
|
3245
3021
|
if (t.enterprise) {
|
|
3246
|
-
const { result: r, success: a } =
|
|
3247
|
-
await
|
|
3022
|
+
const { result: r, success: a } = fe.parse(
|
|
3023
|
+
await G(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3248
3024
|
);
|
|
3249
3025
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3250
|
-
throw new
|
|
3026
|
+
throw new ae(404);
|
|
3251
3027
|
}
|
|
3252
|
-
const s = await
|
|
3028
|
+
const s = await G(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
|
|
3253
3029
|
return s.ok && await t.customDomainAdapter.remove(e, n), s.ok;
|
|
3254
3030
|
},
|
|
3255
3031
|
update: async (e, n, s) => {
|
|
3256
|
-
const r = await
|
|
3032
|
+
const r = await G(t).patch(
|
|
3257
3033
|
s,
|
|
3258
3034
|
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3259
3035
|
).res();
|
|
3260
3036
|
if (!r.ok)
|
|
3261
|
-
throw new
|
|
3037
|
+
throw new ae(503, {
|
|
3262
3038
|
message: await r.text()
|
|
3263
3039
|
});
|
|
3264
3040
|
return t.customDomainAdapter.update(
|
|
@@ -3269,7 +3045,7 @@ function Un(t) {
|
|
|
3269
3045
|
}
|
|
3270
3046
|
};
|
|
3271
3047
|
}
|
|
3272
|
-
class
|
|
3048
|
+
class en {
|
|
3273
3049
|
constructor(e) {
|
|
3274
3050
|
this.config = e;
|
|
3275
3051
|
}
|
|
@@ -3306,14 +3082,14 @@ class qn {
|
|
|
3306
3082
|
value: n,
|
|
3307
3083
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3308
3084
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3309
|
-
},
|
|
3085
|
+
}, u = this.createRequest(e), p = {
|
|
3310
3086
|
"Content-Type": "application/json"
|
|
3311
3087
|
};
|
|
3312
|
-
i && o > 0 && (
|
|
3313
|
-
const
|
|
3314
|
-
headers:
|
|
3088
|
+
i && o > 0 && (p["Cache-Control"] = `max-age=${o}`);
|
|
3089
|
+
const k = new Response(JSON.stringify(c), {
|
|
3090
|
+
headers: p
|
|
3315
3091
|
});
|
|
3316
|
-
await r.put(
|
|
3092
|
+
await r.put(u, k);
|
|
3317
3093
|
} catch (r) {
|
|
3318
3094
|
console.error(`CloudflareCache: set error for key ${e}:`, r);
|
|
3319
3095
|
}
|
|
@@ -3332,7 +3108,7 @@ class qn {
|
|
|
3332
3108
|
);
|
|
3333
3109
|
}
|
|
3334
3110
|
}
|
|
3335
|
-
function
|
|
3111
|
+
function tn(t = {}) {
|
|
3336
3112
|
const e = {
|
|
3337
3113
|
defaultTtlSeconds: 300,
|
|
3338
3114
|
// 5 minutes default
|
|
@@ -3341,16 +3117,16 @@ function Wn(t = {}) {
|
|
|
3341
3117
|
...t
|
|
3342
3118
|
// user config overrides defaults
|
|
3343
3119
|
};
|
|
3344
|
-
return new
|
|
3120
|
+
return new en(e);
|
|
3345
3121
|
}
|
|
3346
|
-
const
|
|
3347
|
-
let
|
|
3122
|
+
const nn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3123
|
+
let ct = (t = 21) => {
|
|
3348
3124
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
3349
3125
|
for (; t--; )
|
|
3350
|
-
e +=
|
|
3126
|
+
e += nn[n[t] & 63];
|
|
3351
3127
|
return e;
|
|
3352
3128
|
};
|
|
3353
|
-
async function
|
|
3129
|
+
async function We(t, e) {
|
|
3354
3130
|
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3355
3131
|
try {
|
|
3356
3132
|
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
@@ -3377,13 +3153,13 @@ async function Ke(t, e) {
|
|
|
3377
3153
|
clearTimeout(r);
|
|
3378
3154
|
}
|
|
3379
3155
|
}
|
|
3380
|
-
function
|
|
3156
|
+
function be(t) {
|
|
3381
3157
|
return `'${t.replace(/'/g, "''")}'`;
|
|
3382
3158
|
}
|
|
3383
|
-
function
|
|
3159
|
+
function B(t) {
|
|
3384
3160
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3385
3161
|
}
|
|
3386
|
-
function
|
|
3162
|
+
function dt(t) {
|
|
3387
3163
|
const e = (n) => {
|
|
3388
3164
|
if (!n)
|
|
3389
3165
|
return "";
|
|
@@ -3425,16 +3201,16 @@ function yt(t) {
|
|
|
3425
3201
|
} : void 0
|
|
3426
3202
|
};
|
|
3427
3203
|
}
|
|
3428
|
-
function
|
|
3204
|
+
function sn(t) {
|
|
3429
3205
|
return async (e, n) => {
|
|
3430
|
-
const s = n.log_id ||
|
|
3206
|
+
const s = n.log_id || ct(), r = {
|
|
3431
3207
|
...n,
|
|
3432
3208
|
log_id: s
|
|
3433
3209
|
};
|
|
3434
|
-
return await
|
|
3210
|
+
return await rn(t, e, r), r;
|
|
3435
3211
|
};
|
|
3436
3212
|
}
|
|
3437
|
-
async function
|
|
3213
|
+
async function rn(t, e, n) {
|
|
3438
3214
|
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3439
3215
|
id: n.log_id,
|
|
3440
3216
|
tenant_id: e,
|
|
@@ -3496,78 +3272,78 @@ async function Jn(t, e, n) {
|
|
|
3496
3272
|
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3497
3273
|
}
|
|
3498
3274
|
}
|
|
3499
|
-
function
|
|
3275
|
+
function an(t) {
|
|
3500
3276
|
return async (e, n) => {
|
|
3501
3277
|
const s = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3502
|
-
SELECT * FROM ${
|
|
3503
|
-
WHERE tenant_id = ${
|
|
3504
|
-
AND id = ${
|
|
3278
|
+
SELECT * FROM ${B(s)}.${B(r)}
|
|
3279
|
+
WHERE tenant_id = ${be(e)}
|
|
3280
|
+
AND id = ${be(n)}
|
|
3505
3281
|
LIMIT 1
|
|
3506
|
-
`, i = await
|
|
3282
|
+
`, i = await We(t, a);
|
|
3507
3283
|
if (i.length === 0)
|
|
3508
3284
|
return null;
|
|
3509
3285
|
const o = i[0];
|
|
3510
|
-
return o ?
|
|
3286
|
+
return o ? dt(o) : null;
|
|
3511
3287
|
};
|
|
3512
3288
|
}
|
|
3513
|
-
function
|
|
3289
|
+
function on(t) {
|
|
3514
3290
|
const e = {};
|
|
3515
3291
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3516
3292
|
const [r, a] = s.split(":");
|
|
3517
3293
|
r && a && (e[r] = a);
|
|
3518
3294
|
}), e;
|
|
3519
3295
|
}
|
|
3520
|
-
function
|
|
3296
|
+
function cn(t) {
|
|
3521
3297
|
const e = [];
|
|
3522
3298
|
for (const [n, s] of Object.entries(t)) {
|
|
3523
3299
|
const r = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3524
3300
|
r && s && e.push(
|
|
3525
|
-
`${
|
|
3301
|
+
`${B(r)} = ${be(s)}`
|
|
3526
3302
|
);
|
|
3527
3303
|
}
|
|
3528
3304
|
return e;
|
|
3529
3305
|
}
|
|
3530
|
-
function
|
|
3306
|
+
function dn(t) {
|
|
3531
3307
|
return async (e, n = {}) => {
|
|
3532
|
-
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.namespace || "default",
|
|
3533
|
-
`tenant_id = ${
|
|
3308
|
+
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 = [
|
|
3309
|
+
`tenant_id = ${be(e)}`
|
|
3534
3310
|
];
|
|
3535
3311
|
if (o) {
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3312
|
+
const Q = on(o);
|
|
3313
|
+
p.push(...cn(Q));
|
|
3538
3314
|
}
|
|
3539
|
-
const
|
|
3540
|
-
let
|
|
3315
|
+
const k = p.join(" AND ");
|
|
3316
|
+
let T = "ORDER BY date DESC";
|
|
3541
3317
|
if (i && i.sort_by) {
|
|
3542
|
-
const
|
|
3543
|
-
|
|
3318
|
+
const Q = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), se = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3319
|
+
T = `ORDER BY ${B(Q)} ${se}`;
|
|
3544
3320
|
}
|
|
3545
|
-
const
|
|
3546
|
-
SELECT * FROM ${
|
|
3547
|
-
WHERE ${
|
|
3548
|
-
${
|
|
3549
|
-
${
|
|
3550
|
-
`,
|
|
3321
|
+
const S = s * r, E = `LIMIT ${r} OFFSET ${S}`, q = `
|
|
3322
|
+
SELECT * FROM ${B(c)}.${B(u)}
|
|
3323
|
+
WHERE ${k}
|
|
3324
|
+
${T}
|
|
3325
|
+
${E}
|
|
3326
|
+
`, L = (await We(t, q)).map(dt);
|
|
3551
3327
|
if (!a)
|
|
3552
3328
|
return {
|
|
3553
|
-
logs:
|
|
3329
|
+
logs: L,
|
|
3554
3330
|
start: 0,
|
|
3555
3331
|
limit: 0,
|
|
3556
3332
|
length: 0
|
|
3557
3333
|
};
|
|
3558
|
-
const
|
|
3559
|
-
SELECT COUNT(*) as count FROM ${
|
|
3560
|
-
WHERE ${
|
|
3561
|
-
`,
|
|
3334
|
+
const O = `
|
|
3335
|
+
SELECT COUNT(*) as count FROM ${B(c)}.${B(u)}
|
|
3336
|
+
WHERE ${k}
|
|
3337
|
+
`, W = (await We(t, O))[0]?.count || 0;
|
|
3562
3338
|
return {
|
|
3563
|
-
logs:
|
|
3564
|
-
start:
|
|
3339
|
+
logs: L,
|
|
3340
|
+
start: S,
|
|
3565
3341
|
limit: r,
|
|
3566
|
-
length: Number(
|
|
3342
|
+
length: Number(W)
|
|
3567
3343
|
};
|
|
3568
3344
|
};
|
|
3569
3345
|
}
|
|
3570
|
-
function
|
|
3346
|
+
function wn() {
|
|
3571
3347
|
return {
|
|
3572
3348
|
async getDaily() {
|
|
3573
3349
|
throw new Error(
|
|
@@ -3581,7 +3357,7 @@ function hs() {
|
|
|
3581
3357
|
}
|
|
3582
3358
|
};
|
|
3583
3359
|
}
|
|
3584
|
-
function
|
|
3360
|
+
function un(t) {
|
|
3585
3361
|
const e = !!t.pipelineEndpoint, n = !!t.pipelineBinding;
|
|
3586
3362
|
if (!e && !n)
|
|
3587
3363
|
throw new Error(
|
|
@@ -3594,12 +3370,12 @@ function es(t) {
|
|
|
3594
3370
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3595
3371
|
);
|
|
3596
3372
|
return {
|
|
3597
|
-
create:
|
|
3598
|
-
list:
|
|
3599
|
-
get:
|
|
3373
|
+
create: sn(t),
|
|
3374
|
+
list: dn(t),
|
|
3375
|
+
get: an(t)
|
|
3600
3376
|
};
|
|
3601
3377
|
}
|
|
3602
|
-
async function
|
|
3378
|
+
async function he(t, e) {
|
|
3603
3379
|
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3604
3380
|
try {
|
|
3605
3381
|
const a = `https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`, i = await fetch(a, {
|
|
@@ -3627,13 +3403,13 @@ async function Ee(t, e) {
|
|
|
3627
3403
|
clearTimeout(r);
|
|
3628
3404
|
}
|
|
3629
3405
|
}
|
|
3630
|
-
function
|
|
3406
|
+
function M(t) {
|
|
3631
3407
|
return `'${t.replace(/'/g, "''").replace(/\\/g, "\\\\")}'`;
|
|
3632
3408
|
}
|
|
3633
|
-
function
|
|
3409
|
+
function Qe(t) {
|
|
3634
3410
|
return `"${t.replace(/"/g, '""')}"`;
|
|
3635
3411
|
}
|
|
3636
|
-
function
|
|
3412
|
+
function ut(t) {
|
|
3637
3413
|
const e = (r) => {
|
|
3638
3414
|
if (r)
|
|
3639
3415
|
try {
|
|
@@ -3666,16 +3442,16 @@ function _t(t) {
|
|
|
3666
3442
|
isMobile: t.double1 === 1
|
|
3667
3443
|
};
|
|
3668
3444
|
}
|
|
3669
|
-
function
|
|
3445
|
+
function ln(t) {
|
|
3670
3446
|
return async (e, n) => {
|
|
3671
|
-
const s = n.log_id ||
|
|
3447
|
+
const s = n.log_id || ct(), r = {
|
|
3672
3448
|
...n,
|
|
3673
3449
|
log_id: s
|
|
3674
3450
|
};
|
|
3675
|
-
return
|
|
3451
|
+
return hn(t, e, r), r;
|
|
3676
3452
|
};
|
|
3677
3453
|
}
|
|
3678
|
-
function
|
|
3454
|
+
function hn(t, e, n) {
|
|
3679
3455
|
if (!t.analyticsEngineBinding) {
|
|
3680
3456
|
console.error("Analytics Engine binding not configured");
|
|
3681
3457
|
return;
|
|
@@ -3738,26 +3514,26 @@ function ns(t, e, n) {
|
|
|
3738
3514
|
console.error("Failed to write log to Analytics Engine:", a);
|
|
3739
3515
|
}
|
|
3740
3516
|
}
|
|
3741
|
-
function
|
|
3517
|
+
function fn(t) {
|
|
3742
3518
|
return async (e, n) => {
|
|
3743
3519
|
const s = t.dataset || "authhero_logs", r = `
|
|
3744
3520
|
SELECT *
|
|
3745
|
-
FROM ${
|
|
3746
|
-
WHERE index1 = ${
|
|
3747
|
-
AND blob1 = ${
|
|
3521
|
+
FROM ${Qe(s)}
|
|
3522
|
+
WHERE index1 = ${M(e)}
|
|
3523
|
+
AND blob1 = ${M(n)}
|
|
3748
3524
|
LIMIT 1
|
|
3749
|
-
`, a = await
|
|
3750
|
-
return a.length === 0 || !a[0] ? null :
|
|
3525
|
+
`, a = await he(t, r);
|
|
3526
|
+
return a.length === 0 || !a[0] ? null : ut(a[0]);
|
|
3751
3527
|
};
|
|
3752
3528
|
}
|
|
3753
|
-
function
|
|
3529
|
+
function pn(t) {
|
|
3754
3530
|
const e = {};
|
|
3755
3531
|
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3756
3532
|
const r = s.indexOf(":"), a = s.substring(0, r), i = s.substring(r + 1);
|
|
3757
3533
|
a && i && (e[a] = i);
|
|
3758
3534
|
}), e;
|
|
3759
3535
|
}
|
|
3760
|
-
function
|
|
3536
|
+
function lt(t) {
|
|
3761
3537
|
return {
|
|
3762
3538
|
log_id: "blob1",
|
|
3763
3539
|
tenant_id: "blob2",
|
|
@@ -3778,71 +3554,71 @@ function gt(t) {
|
|
|
3778
3554
|
hostname: "blob17"
|
|
3779
3555
|
}[t] || null;
|
|
3780
3556
|
}
|
|
3781
|
-
function
|
|
3557
|
+
function mn(t) {
|
|
3782
3558
|
const e = [];
|
|
3783
3559
|
for (const [n, s] of Object.entries(t)) {
|
|
3784
|
-
const r =
|
|
3785
|
-
r && s && e.push(`${r} = ${
|
|
3560
|
+
const r = lt(n);
|
|
3561
|
+
r && s && e.push(`${r} = ${M(s)}`);
|
|
3786
3562
|
}
|
|
3787
3563
|
return e;
|
|
3788
3564
|
}
|
|
3789
|
-
function
|
|
3565
|
+
function yn(t) {
|
|
3790
3566
|
if (t === "date")
|
|
3791
3567
|
return "double2";
|
|
3792
|
-
const e =
|
|
3568
|
+
const e = lt(t);
|
|
3793
3569
|
return e || "timestamp";
|
|
3794
3570
|
}
|
|
3795
|
-
function
|
|
3571
|
+
function _n(t) {
|
|
3796
3572
|
return async (e, n = {}) => {
|
|
3797
|
-
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs",
|
|
3573
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.dataset || "authhero_logs", u = [`index1 = ${M(e)}`];
|
|
3798
3574
|
if (o) {
|
|
3799
|
-
const
|
|
3800
|
-
|
|
3575
|
+
const O = pn(o);
|
|
3576
|
+
u.push(...mn(O));
|
|
3801
3577
|
}
|
|
3802
|
-
const
|
|
3803
|
-
let
|
|
3578
|
+
const p = u.join(" AND ");
|
|
3579
|
+
let k = "ORDER BY timestamp DESC";
|
|
3804
3580
|
if (i && i.sort_by) {
|
|
3805
|
-
const
|
|
3806
|
-
|
|
3581
|
+
const O = yn(i.sort_by), I = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3582
|
+
k = `ORDER BY ${O} ${I}`;
|
|
3807
3583
|
}
|
|
3808
|
-
const
|
|
3584
|
+
const T = s * r, S = `LIMIT ${r} OFFSET ${T}`, E = `
|
|
3809
3585
|
SELECT *
|
|
3810
|
-
FROM ${
|
|
3811
|
-
WHERE ${
|
|
3812
|
-
${
|
|
3813
|
-
${
|
|
3814
|
-
`,
|
|
3586
|
+
FROM ${Qe(c)}
|
|
3587
|
+
WHERE ${p}
|
|
3588
|
+
${k}
|
|
3589
|
+
${S}
|
|
3590
|
+
`, x = (await he(t, E)).map(ut);
|
|
3815
3591
|
if (!a)
|
|
3816
3592
|
return {
|
|
3817
|
-
logs:
|
|
3593
|
+
logs: x,
|
|
3818
3594
|
start: 0,
|
|
3819
3595
|
limit: 0,
|
|
3820
3596
|
length: 0
|
|
3821
3597
|
};
|
|
3822
|
-
const
|
|
3598
|
+
const L = `
|
|
3823
3599
|
SELECT count() as count
|
|
3824
|
-
FROM ${
|
|
3825
|
-
WHERE ${
|
|
3600
|
+
FROM ${Qe(c)}
|
|
3601
|
+
WHERE ${p}
|
|
3826
3602
|
`;
|
|
3827
3603
|
try {
|
|
3828
|
-
const
|
|
3604
|
+
const I = (await he(t, L))[0]?.count || 0;
|
|
3829
3605
|
return {
|
|
3830
|
-
logs:
|
|
3831
|
-
start:
|
|
3606
|
+
logs: x,
|
|
3607
|
+
start: T,
|
|
3832
3608
|
limit: r,
|
|
3833
|
-
length: Number(
|
|
3609
|
+
length: Number(I)
|
|
3834
3610
|
};
|
|
3835
3611
|
} catch {
|
|
3836
3612
|
return {
|
|
3837
|
-
logs:
|
|
3838
|
-
start:
|
|
3613
|
+
logs: x,
|
|
3614
|
+
start: T,
|
|
3839
3615
|
limit: r,
|
|
3840
|
-
length:
|
|
3616
|
+
length: x.length
|
|
3841
3617
|
};
|
|
3842
3618
|
}
|
|
3843
3619
|
};
|
|
3844
3620
|
}
|
|
3845
|
-
const
|
|
3621
|
+
const Je = [
|
|
3846
3622
|
"s",
|
|
3847
3623
|
// SUCCESS_LOGIN
|
|
3848
3624
|
"seacft",
|
|
@@ -3855,77 +3631,77 @@ const rt = [
|
|
|
3855
3631
|
// SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN
|
|
3856
3632
|
"ssa"
|
|
3857
3633
|
// SUCCESS_SILENT_AUTH
|
|
3858
|
-
],
|
|
3634
|
+
], gn = [
|
|
3859
3635
|
"pwd_leak",
|
|
3860
3636
|
"signup_pwd_leak",
|
|
3861
3637
|
"reset_pwd_leak"
|
|
3862
3638
|
];
|
|
3863
|
-
function
|
|
3639
|
+
function Ye(t) {
|
|
3864
3640
|
return `${t.slice(0, 4)}-${t.slice(4, 6)}-${t.slice(6, 8)}`;
|
|
3865
3641
|
}
|
|
3866
|
-
function
|
|
3642
|
+
function Ke(t) {
|
|
3867
3643
|
return t.toISOString().split("T")[0];
|
|
3868
3644
|
}
|
|
3869
|
-
function
|
|
3645
|
+
function Sn(t) {
|
|
3870
3646
|
const e = t.dataset || "authhero_logs";
|
|
3871
3647
|
return {
|
|
3872
3648
|
async getDaily(n, s = {}) {
|
|
3873
3649
|
const { from: r, to: a } = s, i = /* @__PURE__ */ new Date(), o = new Date(i);
|
|
3874
3650
|
o.setDate(o.getDate() - 30);
|
|
3875
|
-
const c = r ?
|
|
3876
|
-
(
|
|
3877
|
-
).join(", "),
|
|
3651
|
+
const c = r ? Ye(r) : Ke(o), u = a ? Ye(a) : Ke(i), p = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), k = (/* @__PURE__ */ new Date(`${u}T23:59:59.999Z`)).getTime(), T = Je.map((x) => M(x)).join(", "), S = gn.map(
|
|
3652
|
+
(x) => M(x)
|
|
3653
|
+
).join(", "), E = `
|
|
3878
3654
|
SELECT
|
|
3879
3655
|
toDate(toDateTime(double2 / 1000)) AS date,
|
|
3880
|
-
SUM(CASE WHEN blob3 IN (${
|
|
3656
|
+
SUM(CASE WHEN blob3 IN (${T}) THEN 1 ELSE 0 END) AS logins,
|
|
3881
3657
|
SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
|
|
3882
|
-
SUM(CASE WHEN blob3 IN (${
|
|
3658
|
+
SUM(CASE WHEN blob3 IN (${S}) THEN 1 ELSE 0 END) AS leaked_passwords,
|
|
3883
3659
|
MIN(double2) AS first_event,
|
|
3884
3660
|
MAX(double2) AS last_event
|
|
3885
3661
|
FROM "${e}"
|
|
3886
|
-
WHERE index1 = ${
|
|
3887
|
-
AND double2 >= ${
|
|
3888
|
-
AND double2 <= ${
|
|
3662
|
+
WHERE index1 = ${M(n)}
|
|
3663
|
+
AND double2 >= ${p}
|
|
3664
|
+
AND double2 <= ${k}
|
|
3889
3665
|
GROUP BY date
|
|
3890
3666
|
ORDER BY date ASC
|
|
3891
3667
|
`;
|
|
3892
|
-
return (await
|
|
3893
|
-
date: String(
|
|
3894
|
-
logins: Number(
|
|
3895
|
-
signups: Number(
|
|
3896
|
-
leaked_passwords: Number(
|
|
3897
|
-
created_at:
|
|
3898
|
-
updated_at:
|
|
3668
|
+
return (await he(t, E)).map((x) => ({
|
|
3669
|
+
date: String(x.date),
|
|
3670
|
+
logins: Number(x.logins) || 0,
|
|
3671
|
+
signups: Number(x.signups) || 0,
|
|
3672
|
+
leaked_passwords: Number(x.leaked_passwords) || 0,
|
|
3673
|
+
created_at: x.first_event ? new Date(Number(x.first_event)).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3674
|
+
updated_at: x.last_event ? new Date(Number(x.last_event)).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
3899
3675
|
}));
|
|
3900
3676
|
},
|
|
3901
3677
|
async getActiveUsers(n) {
|
|
3902
3678
|
const s = /* @__PURE__ */ new Date();
|
|
3903
3679
|
s.setDate(s.getDate() - 30);
|
|
3904
|
-
const r = s.getTime(), a =
|
|
3680
|
+
const r = s.getTime(), a = Je.map((u) => M(u)).join(", "), i = `
|
|
3905
3681
|
SELECT COUNT(DISTINCT blob7) AS count
|
|
3906
3682
|
FROM "${e}"
|
|
3907
|
-
WHERE index1 = ${
|
|
3683
|
+
WHERE index1 = ${M(n)}
|
|
3908
3684
|
AND double2 >= ${r}
|
|
3909
3685
|
AND blob3 IN (${a})
|
|
3910
3686
|
AND blob7 IS NOT NULL
|
|
3911
3687
|
AND blob7 != ''
|
|
3912
|
-
`, c = (await
|
|
3688
|
+
`, c = (await he(t, i))[0];
|
|
3913
3689
|
return c && c.count !== void 0 && Number(c.count) || 0;
|
|
3914
3690
|
}
|
|
3915
3691
|
};
|
|
3916
3692
|
}
|
|
3917
|
-
function
|
|
3693
|
+
function vn(t) {
|
|
3918
3694
|
return t.analyticsEngineBinding || console.warn(
|
|
3919
3695
|
"Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."
|
|
3920
3696
|
), (!t.accountId || !t.apiToken) && console.warn(
|
|
3921
3697
|
"Analytics Engine: accountId and apiToken are required for querying logs via SQL API."
|
|
3922
3698
|
), {
|
|
3923
|
-
create:
|
|
3924
|
-
list:
|
|
3925
|
-
get:
|
|
3699
|
+
create: ln(t),
|
|
3700
|
+
list: _n(t),
|
|
3701
|
+
get: fn(t)
|
|
3926
3702
|
};
|
|
3927
3703
|
}
|
|
3928
|
-
function
|
|
3704
|
+
function bn() {
|
|
3929
3705
|
return {
|
|
3930
3706
|
async getGeoInfo(t) {
|
|
3931
3707
|
try {
|
|
@@ -3944,11 +3720,11 @@ function us() {
|
|
|
3944
3720
|
}
|
|
3945
3721
|
};
|
|
3946
3722
|
}
|
|
3947
|
-
function
|
|
3723
|
+
function Tn(t) {
|
|
3948
3724
|
const e = {
|
|
3949
|
-
customDomains:
|
|
3725
|
+
customDomains: Xt(t),
|
|
3950
3726
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
3951
|
-
cache:
|
|
3727
|
+
cache: tn({
|
|
3952
3728
|
...t.cacheName && { cacheName: t.cacheName },
|
|
3953
3729
|
...t.defaultTtlSeconds !== void 0 && {
|
|
3954
3730
|
defaultTtlSeconds: t.defaultTtlSeconds
|
|
@@ -3957,16 +3733,16 @@ function ms(t) {
|
|
|
3957
3733
|
}),
|
|
3958
3734
|
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
3959
3735
|
// passed at request time via getGeoInfo(headers)
|
|
3960
|
-
geo:
|
|
3736
|
+
geo: bn()
|
|
3961
3737
|
};
|
|
3962
|
-
return t.r2SqlLogs ? e.logs =
|
|
3738
|
+
return t.r2SqlLogs ? e.logs = un(t.r2SqlLogs) : t.analyticsEngineLogs && (e.logs = vn(
|
|
3963
3739
|
t.analyticsEngineLogs
|
|
3964
3740
|
)), e;
|
|
3965
3741
|
}
|
|
3966
3742
|
export {
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3743
|
+
vn as createAnalyticsEngineLogsAdapter,
|
|
3744
|
+
Sn as createAnalyticsEngineStatsAdapter,
|
|
3745
|
+
un as createR2SQLLogsAdapter,
|
|
3746
|
+
wn as createR2SQLStatsAdapter,
|
|
3747
|
+
Tn as default
|
|
3972
3748
|
};
|