@authhero/cloudflare-adapter 2.11.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -41
- package/dist/cloudflare-adapter.cjs +10 -10
- package/dist/cloudflare-adapter.d.ts +3 -28
- package/dist/cloudflare-adapter.mjs +1062 -1190
- package/package.json +3 -3
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
import { verificationMethodsSchema as lt } from "@authhero/adapter-interfaces";
|
|
2
2
|
import ft from "wretch";
|
|
3
|
-
function ht(
|
|
4
|
-
var
|
|
5
|
-
for (var s in
|
|
6
|
-
if (
|
|
7
|
-
for (var r = 0, s = Object.getOwnPropertySymbols(
|
|
8
|
-
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
function pt(
|
|
12
|
-
var
|
|
13
|
-
return ((
|
|
14
|
-
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const r =
|
|
3
|
+
function ht(n, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && e.indexOf(s) < 0 && (t[s] = n[s]);
|
|
6
|
+
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
7
|
+
for (var r = 0, s = Object.getOwnPropertySymbols(n); r < s.length; r++)
|
|
8
|
+
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, s[r]) && (t[s[r]] = n[s[r]]);
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
function pt(n, e) {
|
|
12
|
+
var t;
|
|
13
|
+
return ((t = n?._def) === null || t === void 0 ? void 0 : t.typeName) === e;
|
|
14
|
+
}
|
|
15
|
+
function ue(n, e) {
|
|
16
|
+
const t = n.ZodType.prototype[e];
|
|
17
|
+
n.ZodType.prototype[e] = function(...s) {
|
|
18
|
+
const r = t.apply(this, s);
|
|
19
19
|
return r._def.openapi = this._def.openapi, r;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function mt(
|
|
23
|
-
if (typeof
|
|
22
|
+
function mt(n) {
|
|
23
|
+
if (typeof n.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
|
-
|
|
26
|
-
var i, o, c,
|
|
27
|
-
const C = typeof r == "string" ? a : r, w = C ?? {}, { param:
|
|
28
|
-
param: Object.assign(Object.assign({}, (b = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || b === void 0 ? void 0 : b.param),
|
|
29
|
-
} : void 0), D = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(M).length > 0 ? { _internal: M } : void 0), Object.keys(
|
|
25
|
+
n.ZodType.prototype.openapi = function(r, a) {
|
|
26
|
+
var i, o, c, u, p, b;
|
|
27
|
+
const C = typeof r == "string" ? a : r, w = C ?? {}, { param: Z } = w, ce = ht(w, ["param"]), M = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof r == "string" ? { refId: r } : void 0), J = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), ce), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || Z ? {
|
|
28
|
+
param: Object.assign(Object.assign({}, (b = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || b === void 0 ? void 0 : b.param), Z)
|
|
29
|
+
} : void 0), D = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(M).length > 0 ? { _internal: M } : void 0), Object.keys(J).length > 0 ? { metadata: J } : void 0) }));
|
|
30
30
|
if (pt(this, "ZodObject")) {
|
|
31
31
|
const ee = this.extend;
|
|
32
|
-
D.extend = function(...
|
|
33
|
-
var
|
|
34
|
-
const
|
|
35
|
-
return
|
|
32
|
+
D.extend = function(...Q) {
|
|
33
|
+
var H, de, Me, De, Le, Ve, ze;
|
|
34
|
+
const Be = ee.apply(this, Q);
|
|
35
|
+
return Be._def.openapi = {
|
|
36
36
|
_internal: {
|
|
37
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((de = (H = this._def.openapi) === null || H === void 0 ? void 0 : H._internal) === null || de === void 0) && de.refId ? { refId: (De = (Me = this._def.openapi) === null || Me === void 0 ? void 0 : Me._internal) === null || De === void 0 ? void 0 : De.refId, schema: this } : (Ve = (Le = this._def.openapi) === null || Le === void 0 ? void 0 : Le._internal) === null || Ve === void 0 ? void 0 : Ve.extendedFrom
|
|
38
38
|
},
|
|
39
|
-
metadata: (
|
|
40
|
-
},
|
|
39
|
+
metadata: (ze = Be._def.openapi) === null || ze === void 0 ? void 0 : ze.metadata
|
|
40
|
+
}, Be;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
return D;
|
|
44
|
-
},
|
|
45
|
-
const e =
|
|
46
|
-
|
|
44
|
+
}, ue(n, "optional"), ue(n, "nullable"), ue(n, "default"), ue(n, "transform"), ue(n, "refine");
|
|
45
|
+
const e = n.ZodObject.prototype.deepPartial;
|
|
46
|
+
n.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 = (p = (
|
|
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
|
-
const
|
|
54
|
-
|
|
55
|
-
const a =
|
|
53
|
+
const t = n.ZodObject.prototype.pick;
|
|
54
|
+
n.ZodObject.prototype.pick = function(...r) {
|
|
55
|
+
const a = t.apply(this, r);
|
|
56
56
|
return a._def.openapi = void 0, a;
|
|
57
57
|
};
|
|
58
|
-
const s =
|
|
59
|
-
|
|
58
|
+
const s = n.ZodObject.prototype.omit;
|
|
59
|
+
n.ZodObject.prototype.omit = function(...r) {
|
|
60
60
|
const a = s.apply(this, r);
|
|
61
61
|
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var le = class extends Error {
|
|
65
65
|
res;
|
|
66
66
|
status;
|
|
67
|
-
constructor(
|
|
68
|
-
super(e?.message, { cause: e?.cause }), this.res = e?.res, this.status =
|
|
67
|
+
constructor(n = 500, e) {
|
|
68
|
+
super(e?.message, { cause: e?.cause }), this.res = e?.res, this.status = n;
|
|
69
69
|
}
|
|
70
70
|
getResponse() {
|
|
71
71
|
return this.res ? new Response(this.res.body, {
|
|
@@ -78,47 +78,47 @@ var te = class extends Error {
|
|
|
78
78
|
};
|
|
79
79
|
new Set(".\\+*[^]$()");
|
|
80
80
|
var x;
|
|
81
|
-
(function(
|
|
82
|
-
|
|
81
|
+
(function(n) {
|
|
82
|
+
n.assertEqual = (r) => {
|
|
83
83
|
};
|
|
84
84
|
function e(r) {
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
function
|
|
86
|
+
n.assertIs = e;
|
|
87
|
+
function t(r) {
|
|
88
88
|
throw new Error();
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
n.assertNever = t, n.arrayToEnum = (r) => {
|
|
91
91
|
const a = {};
|
|
92
92
|
for (const i of r)
|
|
93
93
|
a[i] = i;
|
|
94
94
|
return a;
|
|
95
|
-
},
|
|
96
|
-
const a =
|
|
95
|
+
}, n.getValidEnumValues = (r) => {
|
|
96
|
+
const a = n.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
|
|
97
97
|
for (const o of a)
|
|
98
98
|
i[o] = r[o];
|
|
99
|
-
return
|
|
100
|
-
},
|
|
99
|
+
return n.objectValues(i);
|
|
100
|
+
}, n.objectValues = (r) => n.objectKeys(r).map(function(a) {
|
|
101
101
|
return r[a];
|
|
102
|
-
}),
|
|
102
|
+
}), n.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
|
|
103
103
|
const a = [];
|
|
104
104
|
for (const i in r)
|
|
105
105
|
Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
|
|
106
106
|
return a;
|
|
107
|
-
},
|
|
107
|
+
}, n.find = (r, a) => {
|
|
108
108
|
for (const i of r)
|
|
109
109
|
if (a(i))
|
|
110
110
|
return i;
|
|
111
|
-
},
|
|
111
|
+
}, n.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
|
|
112
112
|
function s(r, a = " | ") {
|
|
113
113
|
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
n.joinValues = s, n.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
116
116
|
})(x || (x = {}));
|
|
117
117
|
var qe;
|
|
118
|
-
(function(
|
|
119
|
-
|
|
118
|
+
(function(n) {
|
|
119
|
+
n.mergeShapes = (e, t) => ({
|
|
120
120
|
...e,
|
|
121
|
-
...
|
|
121
|
+
...t
|
|
122
122
|
// second overwrites first
|
|
123
123
|
});
|
|
124
124
|
})(qe || (qe = {}));
|
|
@@ -143,14 +143,14 @@ const f = x.arrayToEnum([
|
|
|
143
143
|
"never",
|
|
144
144
|
"map",
|
|
145
145
|
"set"
|
|
146
|
-
]), V = (
|
|
147
|
-
switch (typeof
|
|
146
|
+
]), V = (n) => {
|
|
147
|
+
switch (typeof n) {
|
|
148
148
|
case "undefined":
|
|
149
149
|
return f.undefined;
|
|
150
150
|
case "string":
|
|
151
151
|
return f.string;
|
|
152
152
|
case "number":
|
|
153
|
-
return Number.isNaN(
|
|
153
|
+
return Number.isNaN(n) ? f.nan : f.number;
|
|
154
154
|
case "boolean":
|
|
155
155
|
return f.boolean;
|
|
156
156
|
case "function":
|
|
@@ -160,11 +160,11 @@ const f = x.arrayToEnum([
|
|
|
160
160
|
case "symbol":
|
|
161
161
|
return f.symbol;
|
|
162
162
|
case "object":
|
|
163
|
-
return Array.isArray(
|
|
163
|
+
return Array.isArray(n) ? f.array : n === null ? f.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? f.promise : typeof Map < "u" && n instanceof Map ? f.map : typeof Set < "u" && n instanceof Set ? f.set : typeof Date < "u" && n instanceof Date ? f.date : f.object;
|
|
164
164
|
default:
|
|
165
165
|
return f.unknown;
|
|
166
166
|
}
|
|
167
|
-
},
|
|
167
|
+
}, d = x.arrayToEnum([
|
|
168
168
|
"invalid_type",
|
|
169
169
|
"invalid_literal",
|
|
170
170
|
"custom",
|
|
@@ -181,8 +181,8 @@ const f = x.arrayToEnum([
|
|
|
181
181
|
"invalid_intersection_types",
|
|
182
182
|
"not_multiple_of",
|
|
183
183
|
"not_finite"
|
|
184
|
-
]), yt = (
|
|
185
|
-
class
|
|
184
|
+
]), yt = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
185
|
+
class O extends Error {
|
|
186
186
|
get errors() {
|
|
187
187
|
return this.issues;
|
|
188
188
|
}
|
|
@@ -192,11 +192,11 @@ class A extends Error {
|
|
|
192
192
|
}, this.addIssues = (s = []) => {
|
|
193
193
|
this.issues = [...this.issues, ...s];
|
|
194
194
|
};
|
|
195
|
-
const
|
|
196
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this,
|
|
195
|
+
const t = new.target.prototype;
|
|
196
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
197
197
|
}
|
|
198
198
|
format(e) {
|
|
199
|
-
const
|
|
199
|
+
const t = e || function(a) {
|
|
200
200
|
return a.message;
|
|
201
201
|
}, s = { _errors: [] }, r = (a) => {
|
|
202
202
|
for (const i of a.issues)
|
|
@@ -207,19 +207,19 @@ class A extends Error {
|
|
|
207
207
|
else if (i.code === "invalid_arguments")
|
|
208
208
|
r(i.argumentsError);
|
|
209
209
|
else if (i.path.length === 0)
|
|
210
|
-
s._errors.push(
|
|
210
|
+
s._errors.push(t(i));
|
|
211
211
|
else {
|
|
212
212
|
let o = s, c = 0;
|
|
213
213
|
for (; c < i.path.length; ) {
|
|
214
|
-
const
|
|
215
|
-
c === i.path.length - 1 ? (o[
|
|
214
|
+
const u = i.path[c];
|
|
215
|
+
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
return r(this), s;
|
|
220
220
|
}
|
|
221
221
|
static assert(e) {
|
|
222
|
-
if (!(e instanceof
|
|
222
|
+
if (!(e instanceof O))
|
|
223
223
|
throw new Error(`Not a ZodError: ${e}`);
|
|
224
224
|
}
|
|
225
225
|
toString() {
|
|
@@ -231,86 +231,86 @@ class A extends Error {
|
|
|
231
231
|
get isEmpty() {
|
|
232
232
|
return this.issues.length === 0;
|
|
233
233
|
}
|
|
234
|
-
flatten(e = (
|
|
235
|
-
const
|
|
234
|
+
flatten(e = (t) => t.message) {
|
|
235
|
+
const t = {}, s = [];
|
|
236
236
|
for (const r of this.issues)
|
|
237
237
|
if (r.path.length > 0) {
|
|
238
238
|
const a = r.path[0];
|
|
239
|
-
|
|
239
|
+
t[a] = t[a] || [], t[a].push(e(r));
|
|
240
240
|
} else
|
|
241
241
|
s.push(e(r));
|
|
242
|
-
return { formErrors: s, fieldErrors:
|
|
242
|
+
return { formErrors: s, fieldErrors: t };
|
|
243
243
|
}
|
|
244
244
|
get formErrors() {
|
|
245
245
|
return this.flatten();
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
let
|
|
251
|
-
switch (
|
|
252
|
-
case
|
|
253
|
-
|
|
248
|
+
O.create = (n) => new O(n);
|
|
249
|
+
const ae = (n, e) => {
|
|
250
|
+
let t;
|
|
251
|
+
switch (n.code) {
|
|
252
|
+
case d.invalid_type:
|
|
253
|
+
n.received === f.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
254
254
|
break;
|
|
255
|
-
case
|
|
256
|
-
|
|
255
|
+
case d.invalid_literal:
|
|
256
|
+
t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
|
|
257
257
|
break;
|
|
258
|
-
case
|
|
259
|
-
|
|
258
|
+
case d.unrecognized_keys:
|
|
259
|
+
t = `Unrecognized key(s) in object: ${x.joinValues(n.keys, ", ")}`;
|
|
260
260
|
break;
|
|
261
|
-
case
|
|
262
|
-
|
|
261
|
+
case d.invalid_union:
|
|
262
|
+
t = "Invalid input";
|
|
263
263
|
break;
|
|
264
|
-
case
|
|
265
|
-
|
|
264
|
+
case d.invalid_union_discriminator:
|
|
265
|
+
t = `Invalid discriminator value. Expected ${x.joinValues(n.options)}`;
|
|
266
266
|
break;
|
|
267
|
-
case
|
|
268
|
-
|
|
267
|
+
case d.invalid_enum_value:
|
|
268
|
+
t = `Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;
|
|
269
269
|
break;
|
|
270
|
-
case
|
|
271
|
-
|
|
270
|
+
case d.invalid_arguments:
|
|
271
|
+
t = "Invalid function arguments";
|
|
272
272
|
break;
|
|
273
|
-
case
|
|
274
|
-
|
|
273
|
+
case d.invalid_return_type:
|
|
274
|
+
t = "Invalid function return type";
|
|
275
275
|
break;
|
|
276
|
-
case
|
|
277
|
-
|
|
276
|
+
case d.invalid_date:
|
|
277
|
+
t = "Invalid date";
|
|
278
278
|
break;
|
|
279
|
-
case
|
|
280
|
-
typeof
|
|
279
|
+
case d.invalid_string:
|
|
280
|
+
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : x.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
281
281
|
break;
|
|
282
|
-
case
|
|
283
|
-
|
|
282
|
+
case d.too_small:
|
|
283
|
+
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "bigint" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
284
284
|
break;
|
|
285
|
-
case
|
|
286
|
-
|
|
285
|
+
case d.too_big:
|
|
286
|
+
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
287
287
|
break;
|
|
288
|
-
case
|
|
289
|
-
|
|
288
|
+
case d.custom:
|
|
289
|
+
t = "Invalid input";
|
|
290
290
|
break;
|
|
291
|
-
case
|
|
292
|
-
|
|
291
|
+
case d.invalid_intersection_types:
|
|
292
|
+
t = "Intersection results could not be merged";
|
|
293
293
|
break;
|
|
294
|
-
case
|
|
295
|
-
|
|
294
|
+
case d.not_multiple_of:
|
|
295
|
+
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
296
296
|
break;
|
|
297
|
-
case
|
|
298
|
-
|
|
297
|
+
case d.not_finite:
|
|
298
|
+
t = "Number must be finite";
|
|
299
299
|
break;
|
|
300
300
|
default:
|
|
301
|
-
|
|
301
|
+
t = e.defaultError, x.assertNever(n);
|
|
302
302
|
}
|
|
303
|
-
return { message:
|
|
303
|
+
return { message: t };
|
|
304
304
|
};
|
|
305
|
-
let nt =
|
|
306
|
-
function _t(
|
|
307
|
-
nt =
|
|
305
|
+
let nt = ae;
|
|
306
|
+
function _t(n) {
|
|
307
|
+
nt = n;
|
|
308
308
|
}
|
|
309
309
|
function Ae() {
|
|
310
310
|
return nt;
|
|
311
311
|
}
|
|
312
|
-
const
|
|
313
|
-
const { data: e, path:
|
|
312
|
+
const Re = (n) => {
|
|
313
|
+
const { data: e, path: t, errorMaps: s, issueData: r } = n, a = [...t, ...r.path || []], i = {
|
|
314
314
|
...r,
|
|
315
315
|
path: a
|
|
316
316
|
};
|
|
@@ -321,32 +321,32 @@ const Oe = (t) => {
|
|
|
321
321
|
message: r.message
|
|
322
322
|
};
|
|
323
323
|
let o = "";
|
|
324
|
-
const c = s.filter((
|
|
325
|
-
for (const
|
|
326
|
-
o =
|
|
324
|
+
const c = s.filter((u) => !!u).slice().reverse();
|
|
325
|
+
for (const u of c)
|
|
326
|
+
o = u(i, { data: e, defaultError: o }).message;
|
|
327
327
|
return {
|
|
328
328
|
...r,
|
|
329
329
|
path: a,
|
|
330
330
|
message: o
|
|
331
331
|
};
|
|
332
332
|
}, gt = [];
|
|
333
|
-
function l(
|
|
334
|
-
const
|
|
333
|
+
function l(n, e) {
|
|
334
|
+
const t = Ae(), s = Re({
|
|
335
335
|
issueData: e,
|
|
336
|
-
data:
|
|
337
|
-
path:
|
|
336
|
+
data: n.data,
|
|
337
|
+
path: n.path,
|
|
338
338
|
errorMaps: [
|
|
339
|
-
|
|
339
|
+
n.common.contextualErrorMap,
|
|
340
340
|
// contextual error map is first priority
|
|
341
|
-
|
|
341
|
+
n.schemaErrorMap,
|
|
342
342
|
// then schema-bound map if available
|
|
343
|
-
|
|
343
|
+
t,
|
|
344
344
|
// then global override map
|
|
345
|
-
|
|
345
|
+
t === ae ? void 0 : ae
|
|
346
346
|
// then global default map
|
|
347
347
|
].filter((r) => !!r)
|
|
348
348
|
});
|
|
349
|
-
|
|
349
|
+
n.common.issues.push(s);
|
|
350
350
|
}
|
|
351
351
|
class T {
|
|
352
352
|
constructor() {
|
|
@@ -358,18 +358,18 @@ class T {
|
|
|
358
358
|
abort() {
|
|
359
359
|
this.value !== "aborted" && (this.value = "aborted");
|
|
360
360
|
}
|
|
361
|
-
static mergeArray(e,
|
|
361
|
+
static mergeArray(e, t) {
|
|
362
362
|
const s = [];
|
|
363
|
-
for (const r of
|
|
363
|
+
for (const r of t) {
|
|
364
364
|
if (r.status === "aborted")
|
|
365
365
|
return m;
|
|
366
366
|
r.status === "dirty" && e.dirty(), s.push(r.value);
|
|
367
367
|
}
|
|
368
368
|
return { status: e.value, value: s };
|
|
369
369
|
}
|
|
370
|
-
static async mergeObjectAsync(e,
|
|
370
|
+
static async mergeObjectAsync(e, t) {
|
|
371
371
|
const s = [];
|
|
372
|
-
for (const r of
|
|
372
|
+
for (const r of t) {
|
|
373
373
|
const a = await r.key, i = await r.value;
|
|
374
374
|
s.push({
|
|
375
375
|
key: a,
|
|
@@ -378,9 +378,9 @@ class T {
|
|
|
378
378
|
}
|
|
379
379
|
return T.mergeObjectSync(e, s);
|
|
380
380
|
}
|
|
381
|
-
static mergeObjectSync(e,
|
|
381
|
+
static mergeObjectSync(e, t) {
|
|
382
382
|
const s = {};
|
|
383
|
-
for (const r of
|
|
383
|
+
for (const r of t) {
|
|
384
384
|
const { key: a, value: i } = r;
|
|
385
385
|
if (a.status === "aborted" || i.status === "aborted")
|
|
386
386
|
return m;
|
|
@@ -391,43 +391,43 @@ class T {
|
|
|
391
391
|
}
|
|
392
392
|
const m = Object.freeze({
|
|
393
393
|
status: "aborted"
|
|
394
|
-
}),
|
|
394
|
+
}), se = (n) => ({ status: "dirty", value: n }), S = (n) => ({ status: "valid", value: n }), We = (n) => n.status === "aborted", Je = (n) => n.status === "dirty", G = (n) => n.status === "valid", fe = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
395
395
|
var h;
|
|
396
|
-
(function(
|
|
397
|
-
|
|
396
|
+
(function(n) {
|
|
397
|
+
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
398
398
|
})(h || (h = {}));
|
|
399
399
|
class $ {
|
|
400
|
-
constructor(e,
|
|
401
|
-
this._cachedPath = [], this.parent = e, this.data =
|
|
400
|
+
constructor(e, t, s, r) {
|
|
401
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = r;
|
|
402
402
|
}
|
|
403
403
|
get path() {
|
|
404
404
|
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
407
|
+
const Ke = (n, e) => {
|
|
408
|
+
if (G(e))
|
|
409
409
|
return { success: !0, data: e.value };
|
|
410
|
-
if (!
|
|
410
|
+
if (!n.common.issues.length)
|
|
411
411
|
throw new Error("Validation failed but no issues detected.");
|
|
412
412
|
return {
|
|
413
413
|
success: !1,
|
|
414
414
|
get error() {
|
|
415
415
|
if (this._error)
|
|
416
416
|
return this._error;
|
|
417
|
-
const
|
|
418
|
-
return this._error =
|
|
417
|
+
const t = new O(n.common.issues);
|
|
418
|
+
return this._error = t, this._error;
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
|
-
function _(
|
|
423
|
-
if (!
|
|
422
|
+
function _(n) {
|
|
423
|
+
if (!n)
|
|
424
424
|
return {};
|
|
425
|
-
const { errorMap: e, invalid_type_error:
|
|
426
|
-
if (e && (
|
|
425
|
+
const { errorMap: e, invalid_type_error: t, required_error: s, description: r } = n;
|
|
426
|
+
if (e && (t || s))
|
|
427
427
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
428
428
|
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
429
|
-
const { message: c } =
|
|
430
|
-
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ??
|
|
429
|
+
const { message: c } = n;
|
|
430
|
+
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? t ?? o.defaultError };
|
|
431
431
|
}, description: r };
|
|
432
432
|
}
|
|
433
433
|
class v {
|
|
@@ -437,8 +437,8 @@ class v {
|
|
|
437
437
|
_getType(e) {
|
|
438
438
|
return V(e.data);
|
|
439
439
|
}
|
|
440
|
-
_getOrReturnCtx(e,
|
|
441
|
-
return
|
|
440
|
+
_getOrReturnCtx(e, t) {
|
|
441
|
+
return t || {
|
|
442
442
|
common: e.parent.common,
|
|
443
443
|
data: e.data,
|
|
444
444
|
parsedType: V(e.data),
|
|
@@ -461,38 +461,38 @@ class v {
|
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
463
|
_parseSync(e) {
|
|
464
|
-
const
|
|
465
|
-
if (fe(
|
|
464
|
+
const t = this._parse(e);
|
|
465
|
+
if (fe(t))
|
|
466
466
|
throw new Error("Synchronous parse encountered promise.");
|
|
467
|
-
return
|
|
467
|
+
return t;
|
|
468
468
|
}
|
|
469
469
|
_parseAsync(e) {
|
|
470
|
-
const
|
|
471
|
-
return Promise.resolve(
|
|
470
|
+
const t = this._parse(e);
|
|
471
|
+
return Promise.resolve(t);
|
|
472
472
|
}
|
|
473
|
-
parse(e,
|
|
474
|
-
const s = this.safeParse(e,
|
|
473
|
+
parse(e, t) {
|
|
474
|
+
const s = this.safeParse(e, t);
|
|
475
475
|
if (s.success)
|
|
476
476
|
return s.data;
|
|
477
477
|
throw s.error;
|
|
478
478
|
}
|
|
479
|
-
safeParse(e,
|
|
479
|
+
safeParse(e, t) {
|
|
480
480
|
const s = {
|
|
481
481
|
common: {
|
|
482
482
|
issues: [],
|
|
483
|
-
async:
|
|
484
|
-
contextualErrorMap:
|
|
483
|
+
async: t?.async ?? !1,
|
|
484
|
+
contextualErrorMap: t?.errorMap
|
|
485
485
|
},
|
|
486
|
-
path:
|
|
486
|
+
path: t?.path || [],
|
|
487
487
|
schemaErrorMap: this._def.errorMap,
|
|
488
488
|
parent: null,
|
|
489
489
|
data: e,
|
|
490
490
|
parsedType: V(e)
|
|
491
491
|
}, r = this._parseSync({ data: e, path: s.path, parent: s });
|
|
492
|
-
return
|
|
492
|
+
return Ke(s, r);
|
|
493
493
|
}
|
|
494
494
|
"~validate"(e) {
|
|
495
|
-
const
|
|
495
|
+
const t = {
|
|
496
496
|
common: {
|
|
497
497
|
issues: [],
|
|
498
498
|
async: !!this["~standard"].async
|
|
@@ -505,60 +505,60 @@ class v {
|
|
|
505
505
|
};
|
|
506
506
|
if (!this["~standard"].async)
|
|
507
507
|
try {
|
|
508
|
-
const s = this._parseSync({ data: e, path: [], parent:
|
|
509
|
-
return
|
|
508
|
+
const s = this._parseSync({ data: e, path: [], parent: t });
|
|
509
|
+
return G(s) ? {
|
|
510
510
|
value: s.value
|
|
511
511
|
} : {
|
|
512
|
-
issues:
|
|
512
|
+
issues: t.common.issues
|
|
513
513
|
};
|
|
514
514
|
} catch (s) {
|
|
515
|
-
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0),
|
|
515
|
+
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
516
516
|
issues: [],
|
|
517
517
|
async: !0
|
|
518
518
|
};
|
|
519
519
|
}
|
|
520
|
-
return this._parseAsync({ data: e, path: [], parent:
|
|
520
|
+
return this._parseAsync({ data: e, path: [], parent: t }).then((s) => G(s) ? {
|
|
521
521
|
value: s.value
|
|
522
522
|
} : {
|
|
523
|
-
issues:
|
|
523
|
+
issues: t.common.issues
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
async parseAsync(e,
|
|
527
|
-
const s = await this.safeParseAsync(e,
|
|
526
|
+
async parseAsync(e, t) {
|
|
527
|
+
const s = await this.safeParseAsync(e, t);
|
|
528
528
|
if (s.success)
|
|
529
529
|
return s.data;
|
|
530
530
|
throw s.error;
|
|
531
531
|
}
|
|
532
|
-
async safeParseAsync(e,
|
|
532
|
+
async safeParseAsync(e, t) {
|
|
533
533
|
const s = {
|
|
534
534
|
common: {
|
|
535
535
|
issues: [],
|
|
536
|
-
contextualErrorMap:
|
|
536
|
+
contextualErrorMap: t?.errorMap,
|
|
537
537
|
async: !0
|
|
538
538
|
},
|
|
539
|
-
path:
|
|
539
|
+
path: t?.path || [],
|
|
540
540
|
schemaErrorMap: this._def.errorMap,
|
|
541
541
|
parent: null,
|
|
542
542
|
data: e,
|
|
543
543
|
parsedType: V(e)
|
|
544
544
|
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (fe(r) ? r : Promise.resolve(r));
|
|
545
|
-
return
|
|
545
|
+
return Ke(s, a);
|
|
546
546
|
}
|
|
547
|
-
refine(e,
|
|
548
|
-
const s = (r) => typeof
|
|
547
|
+
refine(e, t) {
|
|
548
|
+
const s = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
|
|
549
549
|
return this._refinement((r, a) => {
|
|
550
550
|
const i = e(r), o = () => a.addIssue({
|
|
551
|
-
code:
|
|
551
|
+
code: d.custom,
|
|
552
552
|
...s(r)
|
|
553
553
|
});
|
|
554
554
|
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
|
-
refinement(e,
|
|
558
|
-
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof
|
|
557
|
+
refinement(e, t) {
|
|
558
|
+
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof t == "function" ? t(s, r) : t), !1));
|
|
559
559
|
}
|
|
560
560
|
_refinement(e) {
|
|
561
|
-
return new
|
|
561
|
+
return new N({
|
|
562
562
|
schema: this,
|
|
563
563
|
typeName: y.ZodEffects,
|
|
564
564
|
effect: { type: "refinement", refinement: e }
|
|
@@ -571,23 +571,23 @@ class v {
|
|
|
571
571
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
572
572
|
version: 1,
|
|
573
573
|
vendor: "zod",
|
|
574
|
-
validate: (
|
|
574
|
+
validate: (t) => this["~validate"](t)
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
577
|
optional() {
|
|
578
|
-
return
|
|
578
|
+
return I.create(this, this._def);
|
|
579
579
|
}
|
|
580
580
|
nullable() {
|
|
581
|
-
return
|
|
581
|
+
return W.create(this, this._def);
|
|
582
582
|
}
|
|
583
583
|
nullish() {
|
|
584
584
|
return this.nullable().optional();
|
|
585
585
|
}
|
|
586
586
|
array() {
|
|
587
|
-
return
|
|
587
|
+
return E.create(this);
|
|
588
588
|
}
|
|
589
589
|
promise() {
|
|
590
|
-
return
|
|
590
|
+
return oe.create(this, this._def);
|
|
591
591
|
}
|
|
592
592
|
or(e) {
|
|
593
593
|
return ye.create([this, e], this._def);
|
|
@@ -596,7 +596,7 @@ class v {
|
|
|
596
596
|
return _e.create(this, e, this._def);
|
|
597
597
|
}
|
|
598
598
|
transform(e) {
|
|
599
|
-
return new
|
|
599
|
+
return new N({
|
|
600
600
|
..._(this._def),
|
|
601
601
|
schema: this,
|
|
602
602
|
typeName: y.ZodEffects,
|
|
@@ -604,33 +604,33 @@ class v {
|
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
606
|
default(e) {
|
|
607
|
-
const
|
|
607
|
+
const t = typeof e == "function" ? e : () => e;
|
|
608
608
|
return new ke({
|
|
609
609
|
..._(this._def),
|
|
610
610
|
innerType: this,
|
|
611
|
-
defaultValue:
|
|
611
|
+
defaultValue: t,
|
|
612
612
|
typeName: y.ZodDefault
|
|
613
613
|
});
|
|
614
614
|
}
|
|
615
615
|
brand() {
|
|
616
|
-
return new
|
|
616
|
+
return new Ye({
|
|
617
617
|
typeName: y.ZodBranded,
|
|
618
618
|
type: this,
|
|
619
619
|
..._(this._def)
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
catch(e) {
|
|
623
|
-
const
|
|
623
|
+
const t = typeof e == "function" ? e : () => e;
|
|
624
624
|
return new we({
|
|
625
625
|
..._(this._def),
|
|
626
626
|
innerType: this,
|
|
627
|
-
catchValue:
|
|
627
|
+
catchValue: t,
|
|
628
628
|
typeName: y.ZodCatch
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
631
|
describe(e) {
|
|
632
|
-
const
|
|
633
|
-
return new
|
|
632
|
+
const t = this.constructor;
|
|
633
|
+
return new t({
|
|
634
634
|
...this._def,
|
|
635
635
|
description: e
|
|
636
636
|
});
|
|
@@ -648,48 +648,48 @@ class v {
|
|
|
648
648
|
return this.safeParse(null).success;
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
const vt = /^c[^\s-]{8,}$/i, xt = /^[0-9a-z]+$/, bt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, wt = /^[a-z0-9_-]{21}$/i, Tt = /^[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)?)??$/, Ct = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,
|
|
652
|
-
let
|
|
653
|
-
const
|
|
654
|
-
function rt(
|
|
651
|
+
const vt = /^c[^\s-]{8,}$/i, xt = /^[0-9a-z]+$/, bt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, wt = /^[a-z0-9_-]{21}$/i, Tt = /^[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)?)??$/, Ct = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ot = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
652
|
+
let Ue;
|
|
653
|
+
const At = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Rt = /^(?:(?: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])$/, Et = /^(([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])$/, jt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Zt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, st = "((\\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(`^${st}$`);
|
|
654
|
+
function rt(n) {
|
|
655
655
|
let e = "[0-5]\\d";
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${
|
|
656
|
+
n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
657
|
+
const t = n.precision ? "+" : "?";
|
|
658
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
659
659
|
}
|
|
660
|
-
function $t(
|
|
661
|
-
return new RegExp(`^${rt(
|
|
660
|
+
function $t(n) {
|
|
661
|
+
return new RegExp(`^${rt(n)}$`);
|
|
662
662
|
}
|
|
663
|
-
function at(
|
|
664
|
-
let e = `${st}T${rt(
|
|
665
|
-
const
|
|
666
|
-
return
|
|
663
|
+
function at(n) {
|
|
664
|
+
let e = `${st}T${rt(n)}`;
|
|
665
|
+
const t = [];
|
|
666
|
+
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
667
667
|
}
|
|
668
|
-
function Pt(
|
|
669
|
-
return !!((e === "v4" || !e) &&
|
|
668
|
+
function Pt(n, e) {
|
|
669
|
+
return !!((e === "v4" || !e) && At.test(n) || (e === "v6" || !e) && Et.test(n));
|
|
670
670
|
}
|
|
671
|
-
function Mt(
|
|
672
|
-
if (!Tt.test(
|
|
671
|
+
function Mt(n, e) {
|
|
672
|
+
if (!Tt.test(n))
|
|
673
673
|
return !1;
|
|
674
674
|
try {
|
|
675
|
-
const [
|
|
676
|
-
if (!
|
|
675
|
+
const [t] = n.split(".");
|
|
676
|
+
if (!t)
|
|
677
677
|
return !1;
|
|
678
|
-
const s =
|
|
678
|
+
const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), r = JSON.parse(atob(s));
|
|
679
679
|
return !(typeof r != "object" || r === null || "typ" in r && r?.typ !== "JWT" || !r.alg || e && r.alg !== e);
|
|
680
680
|
} catch {
|
|
681
681
|
return !1;
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
|
-
function Dt(
|
|
685
|
-
return !!((e === "v4" || !e) &&
|
|
684
|
+
function Dt(n, e) {
|
|
685
|
+
return !!((e === "v4" || !e) && Rt.test(n) || (e === "v6" || !e) && Nt.test(n));
|
|
686
686
|
}
|
|
687
|
-
class
|
|
687
|
+
class R extends v {
|
|
688
688
|
_parse(e) {
|
|
689
689
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
690
690
|
const a = this._getOrReturnCtx(e);
|
|
691
691
|
return l(a, {
|
|
692
|
-
code:
|
|
692
|
+
code: d.invalid_type,
|
|
693
693
|
expected: f.string,
|
|
694
694
|
received: a.parsedType
|
|
695
695
|
}), m;
|
|
@@ -699,7 +699,7 @@ class E extends v {
|
|
|
699
699
|
for (const a of this._def.checks)
|
|
700
700
|
if (a.kind === "min")
|
|
701
701
|
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
702
|
-
code:
|
|
702
|
+
code: d.too_small,
|
|
703
703
|
minimum: a.value,
|
|
704
704
|
type: "string",
|
|
705
705
|
inclusive: !0,
|
|
@@ -708,7 +708,7 @@ class E extends v {
|
|
|
708
708
|
}), s.dirty());
|
|
709
709
|
else if (a.kind === "max")
|
|
710
710
|
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
711
|
-
code:
|
|
711
|
+
code: d.too_big,
|
|
712
712
|
maximum: a.value,
|
|
713
713
|
type: "string",
|
|
714
714
|
inclusive: !0,
|
|
@@ -718,14 +718,14 @@ class E extends v {
|
|
|
718
718
|
else if (a.kind === "length") {
|
|
719
719
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
720
720
|
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
721
|
-
code:
|
|
721
|
+
code: d.too_big,
|
|
722
722
|
maximum: a.value,
|
|
723
723
|
type: "string",
|
|
724
724
|
inclusive: !0,
|
|
725
725
|
exact: !0,
|
|
726
726
|
message: a.message
|
|
727
727
|
}) : o && l(r, {
|
|
728
|
-
code:
|
|
728
|
+
code: d.too_small,
|
|
729
729
|
minimum: a.value,
|
|
730
730
|
type: "string",
|
|
731
731
|
inclusive: !0,
|
|
@@ -735,43 +735,43 @@ class E extends v {
|
|
|
735
735
|
} else if (a.kind === "email")
|
|
736
736
|
Ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
737
737
|
validation: "email",
|
|
738
|
-
code:
|
|
738
|
+
code: d.invalid_string,
|
|
739
739
|
message: a.message
|
|
740
740
|
}), s.dirty());
|
|
741
741
|
else if (a.kind === "emoji")
|
|
742
|
-
|
|
742
|
+
Ue || (Ue = new RegExp(Ot, "u")), Ue.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
743
743
|
validation: "emoji",
|
|
744
|
-
code:
|
|
744
|
+
code: d.invalid_string,
|
|
745
745
|
message: a.message
|
|
746
746
|
}), s.dirty());
|
|
747
747
|
else if (a.kind === "uuid")
|
|
748
748
|
kt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
749
749
|
validation: "uuid",
|
|
750
|
-
code:
|
|
750
|
+
code: d.invalid_string,
|
|
751
751
|
message: a.message
|
|
752
752
|
}), s.dirty());
|
|
753
753
|
else if (a.kind === "nanoid")
|
|
754
754
|
wt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
755
755
|
validation: "nanoid",
|
|
756
|
-
code:
|
|
756
|
+
code: d.invalid_string,
|
|
757
757
|
message: a.message
|
|
758
758
|
}), s.dirty());
|
|
759
759
|
else if (a.kind === "cuid")
|
|
760
760
|
vt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
761
761
|
validation: "cuid",
|
|
762
|
-
code:
|
|
762
|
+
code: d.invalid_string,
|
|
763
763
|
message: a.message
|
|
764
764
|
}), s.dirty());
|
|
765
765
|
else if (a.kind === "cuid2")
|
|
766
766
|
xt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
767
767
|
validation: "cuid2",
|
|
768
|
-
code:
|
|
768
|
+
code: d.invalid_string,
|
|
769
769
|
message: a.message
|
|
770
770
|
}), s.dirty());
|
|
771
771
|
else if (a.kind === "ulid")
|
|
772
772
|
bt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
773
773
|
validation: "ulid",
|
|
774
|
-
code:
|
|
774
|
+
code: d.invalid_string,
|
|
775
775
|
message: a.message
|
|
776
776
|
}), s.dirty());
|
|
777
777
|
else if (a.kind === "url")
|
|
@@ -780,74 +780,74 @@ class E extends v {
|
|
|
780
780
|
} catch {
|
|
781
781
|
r = this._getOrReturnCtx(e, r), l(r, {
|
|
782
782
|
validation: "url",
|
|
783
|
-
code:
|
|
783
|
+
code: d.invalid_string,
|
|
784
784
|
message: a.message
|
|
785
785
|
}), s.dirty();
|
|
786
786
|
}
|
|
787
787
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
788
788
|
validation: "regex",
|
|
789
|
-
code:
|
|
789
|
+
code: d.invalid_string,
|
|
790
790
|
message: a.message
|
|
791
791
|
}), 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, {
|
|
792
|
-
code:
|
|
792
|
+
code: d.invalid_string,
|
|
793
793
|
validation: { includes: a.value, position: a.position },
|
|
794
794
|
message: a.message
|
|
795
795
|
}), 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, {
|
|
796
|
-
code:
|
|
796
|
+
code: d.invalid_string,
|
|
797
797
|
validation: { startsWith: a.value },
|
|
798
798
|
message: a.message
|
|
799
799
|
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
800
|
-
code:
|
|
800
|
+
code: d.invalid_string,
|
|
801
801
|
validation: { endsWith: a.value },
|
|
802
802
|
message: a.message
|
|
803
803
|
}), s.dirty()) : a.kind === "datetime" ? at(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
804
|
-
code:
|
|
804
|
+
code: d.invalid_string,
|
|
805
805
|
validation: "datetime",
|
|
806
806
|
message: a.message
|
|
807
|
-
}), s.dirty()) : a.kind === "date" ?
|
|
808
|
-
code:
|
|
807
|
+
}), s.dirty()) : a.kind === "date" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
808
|
+
code: d.invalid_string,
|
|
809
809
|
validation: "date",
|
|
810
810
|
message: a.message
|
|
811
811
|
}), s.dirty()) : a.kind === "time" ? $t(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
812
|
-
code:
|
|
812
|
+
code: d.invalid_string,
|
|
813
813
|
validation: "time",
|
|
814
814
|
message: a.message
|
|
815
815
|
}), s.dirty()) : a.kind === "duration" ? St.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
816
816
|
validation: "duration",
|
|
817
|
-
code:
|
|
817
|
+
code: d.invalid_string,
|
|
818
818
|
message: a.message
|
|
819
819
|
}), s.dirty()) : a.kind === "ip" ? Pt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
820
820
|
validation: "ip",
|
|
821
|
-
code:
|
|
821
|
+
code: d.invalid_string,
|
|
822
822
|
message: a.message
|
|
823
823
|
}), s.dirty()) : a.kind === "jwt" ? Mt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
824
824
|
validation: "jwt",
|
|
825
|
-
code:
|
|
825
|
+
code: d.invalid_string,
|
|
826
826
|
message: a.message
|
|
827
827
|
}), s.dirty()) : a.kind === "cidr" ? Dt(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
828
828
|
validation: "cidr",
|
|
829
|
-
code:
|
|
829
|
+
code: d.invalid_string,
|
|
830
830
|
message: a.message
|
|
831
|
-
}), s.dirty()) : a.kind === "base64" ?
|
|
831
|
+
}), s.dirty()) : a.kind === "base64" ? jt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
832
832
|
validation: "base64",
|
|
833
|
-
code:
|
|
833
|
+
code: d.invalid_string,
|
|
834
834
|
message: a.message
|
|
835
|
-
}), s.dirty()) : a.kind === "base64url" ?
|
|
835
|
+
}), s.dirty()) : a.kind === "base64url" ? Zt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
836
836
|
validation: "base64url",
|
|
837
|
-
code:
|
|
837
|
+
code: d.invalid_string,
|
|
838
838
|
message: a.message
|
|
839
839
|
}), s.dirty()) : x.assertNever(a);
|
|
840
840
|
return { status: s.value, value: e.data };
|
|
841
841
|
}
|
|
842
|
-
_regex(e,
|
|
842
|
+
_regex(e, t, s) {
|
|
843
843
|
return this.refinement((r) => e.test(r), {
|
|
844
|
-
validation:
|
|
845
|
-
code:
|
|
844
|
+
validation: t,
|
|
845
|
+
code: d.invalid_string,
|
|
846
846
|
...h.errToObj(s)
|
|
847
847
|
});
|
|
848
848
|
}
|
|
849
849
|
_addCheck(e) {
|
|
850
|
-
return new
|
|
850
|
+
return new R({
|
|
851
851
|
...this._def,
|
|
852
852
|
checks: [...this._def.checks, e]
|
|
853
853
|
});
|
|
@@ -926,54 +926,54 @@ class E extends v {
|
|
|
926
926
|
duration(e) {
|
|
927
927
|
return this._addCheck({ kind: "duration", ...h.errToObj(e) });
|
|
928
928
|
}
|
|
929
|
-
regex(e,
|
|
929
|
+
regex(e, t) {
|
|
930
930
|
return this._addCheck({
|
|
931
931
|
kind: "regex",
|
|
932
932
|
regex: e,
|
|
933
|
-
...h.errToObj(
|
|
933
|
+
...h.errToObj(t)
|
|
934
934
|
});
|
|
935
935
|
}
|
|
936
|
-
includes(e,
|
|
936
|
+
includes(e, t) {
|
|
937
937
|
return this._addCheck({
|
|
938
938
|
kind: "includes",
|
|
939
939
|
value: e,
|
|
940
|
-
position:
|
|
941
|
-
...h.errToObj(
|
|
940
|
+
position: t?.position,
|
|
941
|
+
...h.errToObj(t?.message)
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
|
-
startsWith(e,
|
|
944
|
+
startsWith(e, t) {
|
|
945
945
|
return this._addCheck({
|
|
946
946
|
kind: "startsWith",
|
|
947
947
|
value: e,
|
|
948
|
-
...h.errToObj(
|
|
948
|
+
...h.errToObj(t)
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
|
-
endsWith(e,
|
|
951
|
+
endsWith(e, t) {
|
|
952
952
|
return this._addCheck({
|
|
953
953
|
kind: "endsWith",
|
|
954
954
|
value: e,
|
|
955
|
-
...h.errToObj(
|
|
955
|
+
...h.errToObj(t)
|
|
956
956
|
});
|
|
957
957
|
}
|
|
958
|
-
min(e,
|
|
958
|
+
min(e, t) {
|
|
959
959
|
return this._addCheck({
|
|
960
960
|
kind: "min",
|
|
961
961
|
value: e,
|
|
962
|
-
...h.errToObj(
|
|
962
|
+
...h.errToObj(t)
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
max(e,
|
|
965
|
+
max(e, t) {
|
|
966
966
|
return this._addCheck({
|
|
967
967
|
kind: "max",
|
|
968
968
|
value: e,
|
|
969
|
-
...h.errToObj(
|
|
969
|
+
...h.errToObj(t)
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
|
-
length(e,
|
|
972
|
+
length(e, t) {
|
|
973
973
|
return this._addCheck({
|
|
974
974
|
kind: "length",
|
|
975
975
|
value: e,
|
|
976
|
-
...h.errToObj(
|
|
976
|
+
...h.errToObj(t)
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
979
|
/**
|
|
@@ -983,19 +983,19 @@ class E extends v {
|
|
|
983
983
|
return this.min(1, h.errToObj(e));
|
|
984
984
|
}
|
|
985
985
|
trim() {
|
|
986
|
-
return new
|
|
986
|
+
return new R({
|
|
987
987
|
...this._def,
|
|
988
988
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
989
989
|
});
|
|
990
990
|
}
|
|
991
991
|
toLowerCase() {
|
|
992
|
-
return new
|
|
992
|
+
return new R({
|
|
993
993
|
...this._def,
|
|
994
994
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
995
995
|
});
|
|
996
996
|
}
|
|
997
997
|
toUpperCase() {
|
|
998
|
-
return new
|
|
998
|
+
return new R({
|
|
999
999
|
...this._def,
|
|
1000
1000
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1001
1001
|
});
|
|
@@ -1050,28 +1050,28 @@ class E extends v {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
get minLength() {
|
|
1052
1052
|
let e = null;
|
|
1053
|
-
for (const
|
|
1054
|
-
|
|
1053
|
+
for (const t of this._def.checks)
|
|
1054
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1055
1055
|
return e;
|
|
1056
1056
|
}
|
|
1057
1057
|
get maxLength() {
|
|
1058
1058
|
let e = null;
|
|
1059
|
-
for (const
|
|
1060
|
-
|
|
1059
|
+
for (const t of this._def.checks)
|
|
1060
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1061
1061
|
return e;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1064
|
+
R.create = (n) => new R({
|
|
1065
1065
|
checks: [],
|
|
1066
1066
|
typeName: y.ZodString,
|
|
1067
|
-
coerce:
|
|
1068
|
-
..._(
|
|
1067
|
+
coerce: n?.coerce ?? !1,
|
|
1068
|
+
..._(n)
|
|
1069
1069
|
});
|
|
1070
|
-
function Lt(
|
|
1071
|
-
const
|
|
1070
|
+
function Lt(n, e) {
|
|
1071
|
+
const t = (n.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = t > s ? t : s, a = Number.parseInt(n.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
1072
1072
|
return a % i / 10 ** r;
|
|
1073
1073
|
}
|
|
1074
|
-
class
|
|
1074
|
+
class U extends v {
|
|
1075
1075
|
constructor() {
|
|
1076
1076
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1077
1077
|
}
|
|
@@ -1079,7 +1079,7 @@ class B extends v {
|
|
|
1079
1079
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
|
|
1080
1080
|
const a = this._getOrReturnCtx(e);
|
|
1081
1081
|
return l(a, {
|
|
1082
|
-
code:
|
|
1082
|
+
code: d.invalid_type,
|
|
1083
1083
|
expected: f.number,
|
|
1084
1084
|
received: a.parsedType
|
|
1085
1085
|
}), m;
|
|
@@ -1088,54 +1088,54 @@ class B extends v {
|
|
|
1088
1088
|
const r = new T();
|
|
1089
1089
|
for (const a of this._def.checks)
|
|
1090
1090
|
a.kind === "int" ? x.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1091
|
-
code:
|
|
1091
|
+
code: d.invalid_type,
|
|
1092
1092
|
expected: "integer",
|
|
1093
1093
|
received: "float",
|
|
1094
1094
|
message: a.message
|
|
1095
1095
|
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1096
|
-
code:
|
|
1096
|
+
code: d.too_small,
|
|
1097
1097
|
minimum: a.value,
|
|
1098
1098
|
type: "number",
|
|
1099
1099
|
inclusive: a.inclusive,
|
|
1100
1100
|
exact: !1,
|
|
1101
1101
|
message: a.message
|
|
1102
1102
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1103
|
-
code:
|
|
1103
|
+
code: d.too_big,
|
|
1104
1104
|
maximum: a.value,
|
|
1105
1105
|
type: "number",
|
|
1106
1106
|
inclusive: a.inclusive,
|
|
1107
1107
|
exact: !1,
|
|
1108
1108
|
message: a.message
|
|
1109
1109
|
}), r.dirty()) : a.kind === "multipleOf" ? Lt(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1110
|
-
code:
|
|
1110
|
+
code: d.not_multiple_of,
|
|
1111
1111
|
multipleOf: a.value,
|
|
1112
1112
|
message: a.message
|
|
1113
1113
|
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1114
|
-
code:
|
|
1114
|
+
code: d.not_finite,
|
|
1115
1115
|
message: a.message
|
|
1116
1116
|
}), r.dirty()) : x.assertNever(a);
|
|
1117
1117
|
return { status: r.value, value: e.data };
|
|
1118
1118
|
}
|
|
1119
|
-
gte(e,
|
|
1120
|
-
return this.setLimit("min", e, !0, h.toString(
|
|
1119
|
+
gte(e, t) {
|
|
1120
|
+
return this.setLimit("min", e, !0, h.toString(t));
|
|
1121
1121
|
}
|
|
1122
|
-
gt(e,
|
|
1123
|
-
return this.setLimit("min", e, !1, h.toString(
|
|
1122
|
+
gt(e, t) {
|
|
1123
|
+
return this.setLimit("min", e, !1, h.toString(t));
|
|
1124
1124
|
}
|
|
1125
|
-
lte(e,
|
|
1126
|
-
return this.setLimit("max", e, !0, h.toString(
|
|
1125
|
+
lte(e, t) {
|
|
1126
|
+
return this.setLimit("max", e, !0, h.toString(t));
|
|
1127
1127
|
}
|
|
1128
|
-
lt(e,
|
|
1129
|
-
return this.setLimit("max", e, !1, h.toString(
|
|
1128
|
+
lt(e, t) {
|
|
1129
|
+
return this.setLimit("max", e, !1, h.toString(t));
|
|
1130
1130
|
}
|
|
1131
|
-
setLimit(e,
|
|
1132
|
-
return new
|
|
1131
|
+
setLimit(e, t, s, r) {
|
|
1132
|
+
return new U({
|
|
1133
1133
|
...this._def,
|
|
1134
1134
|
checks: [
|
|
1135
1135
|
...this._def.checks,
|
|
1136
1136
|
{
|
|
1137
1137
|
kind: e,
|
|
1138
|
-
value:
|
|
1138
|
+
value: t,
|
|
1139
1139
|
inclusive: s,
|
|
1140
1140
|
message: h.toString(r)
|
|
1141
1141
|
}
|
|
@@ -1143,7 +1143,7 @@ class B extends v {
|
|
|
1143
1143
|
});
|
|
1144
1144
|
}
|
|
1145
1145
|
_addCheck(e) {
|
|
1146
|
-
return new
|
|
1146
|
+
return new U({
|
|
1147
1147
|
...this._def,
|
|
1148
1148
|
checks: [...this._def.checks, e]
|
|
1149
1149
|
});
|
|
@@ -1186,11 +1186,11 @@ class B extends v {
|
|
|
1186
1186
|
message: h.toString(e)
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
|
-
multipleOf(e,
|
|
1189
|
+
multipleOf(e, t) {
|
|
1190
1190
|
return this._addCheck({
|
|
1191
1191
|
kind: "multipleOf",
|
|
1192
1192
|
value: e,
|
|
1193
|
-
message: h.toString(
|
|
1193
|
+
message: h.toString(t)
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
1196
1196
|
finite(e) {
|
|
@@ -1214,34 +1214,34 @@ class B extends v {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
get minValue() {
|
|
1216
1216
|
let e = null;
|
|
1217
|
-
for (const
|
|
1218
|
-
|
|
1217
|
+
for (const t of this._def.checks)
|
|
1218
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1219
1219
|
return e;
|
|
1220
1220
|
}
|
|
1221
1221
|
get maxValue() {
|
|
1222
1222
|
let e = null;
|
|
1223
|
-
for (const
|
|
1224
|
-
|
|
1223
|
+
for (const t of this._def.checks)
|
|
1224
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1225
1225
|
return e;
|
|
1226
1226
|
}
|
|
1227
1227
|
get isInt() {
|
|
1228
1228
|
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
|
|
1229
1229
|
}
|
|
1230
1230
|
get isFinite() {
|
|
1231
|
-
let e = null,
|
|
1231
|
+
let e = null, t = null;
|
|
1232
1232
|
for (const s of this._def.checks) {
|
|
1233
1233
|
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1234
1234
|
return !0;
|
|
1235
|
-
s.kind === "min" ? (
|
|
1235
|
+
s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1236
1236
|
}
|
|
1237
|
-
return Number.isFinite(
|
|
1237
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1238
1238
|
}
|
|
1239
1239
|
}
|
|
1240
|
-
|
|
1240
|
+
U.create = (n) => new U({
|
|
1241
1241
|
checks: [],
|
|
1242
1242
|
typeName: y.ZodNumber,
|
|
1243
|
-
coerce:
|
|
1244
|
-
..._(
|
|
1243
|
+
coerce: n?.coerce || !1,
|
|
1244
|
+
..._(n)
|
|
1245
1245
|
});
|
|
1246
1246
|
class F extends v {
|
|
1247
1247
|
constructor() {
|
|
@@ -1260,52 +1260,52 @@ class F extends v {
|
|
|
1260
1260
|
const r = new T();
|
|
1261
1261
|
for (const a of this._def.checks)
|
|
1262
1262
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1263
|
-
code:
|
|
1263
|
+
code: d.too_small,
|
|
1264
1264
|
type: "bigint",
|
|
1265
1265
|
minimum: a.value,
|
|
1266
1266
|
inclusive: a.inclusive,
|
|
1267
1267
|
message: a.message
|
|
1268
1268
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1269
|
-
code:
|
|
1269
|
+
code: d.too_big,
|
|
1270
1270
|
type: "bigint",
|
|
1271
1271
|
maximum: a.value,
|
|
1272
1272
|
inclusive: a.inclusive,
|
|
1273
1273
|
message: a.message
|
|
1274
1274
|
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1275
|
-
code:
|
|
1275
|
+
code: d.not_multiple_of,
|
|
1276
1276
|
multipleOf: a.value,
|
|
1277
1277
|
message: a.message
|
|
1278
1278
|
}), r.dirty()) : x.assertNever(a);
|
|
1279
1279
|
return { status: r.value, value: e.data };
|
|
1280
1280
|
}
|
|
1281
1281
|
_getInvalidInput(e) {
|
|
1282
|
-
const
|
|
1283
|
-
return l(
|
|
1284
|
-
code:
|
|
1282
|
+
const t = this._getOrReturnCtx(e);
|
|
1283
|
+
return l(t, {
|
|
1284
|
+
code: d.invalid_type,
|
|
1285
1285
|
expected: f.bigint,
|
|
1286
|
-
received:
|
|
1286
|
+
received: t.parsedType
|
|
1287
1287
|
}), m;
|
|
1288
1288
|
}
|
|
1289
|
-
gte(e,
|
|
1290
|
-
return this.setLimit("min", e, !0, h.toString(
|
|
1289
|
+
gte(e, t) {
|
|
1290
|
+
return this.setLimit("min", e, !0, h.toString(t));
|
|
1291
1291
|
}
|
|
1292
|
-
gt(e,
|
|
1293
|
-
return this.setLimit("min", e, !1, h.toString(
|
|
1292
|
+
gt(e, t) {
|
|
1293
|
+
return this.setLimit("min", e, !1, h.toString(t));
|
|
1294
1294
|
}
|
|
1295
|
-
lte(e,
|
|
1296
|
-
return this.setLimit("max", e, !0, h.toString(
|
|
1295
|
+
lte(e, t) {
|
|
1296
|
+
return this.setLimit("max", e, !0, h.toString(t));
|
|
1297
1297
|
}
|
|
1298
|
-
lt(e,
|
|
1299
|
-
return this.setLimit("max", e, !1, h.toString(
|
|
1298
|
+
lt(e, t) {
|
|
1299
|
+
return this.setLimit("max", e, !1, h.toString(t));
|
|
1300
1300
|
}
|
|
1301
|
-
setLimit(e,
|
|
1301
|
+
setLimit(e, t, s, r) {
|
|
1302
1302
|
return new F({
|
|
1303
1303
|
...this._def,
|
|
1304
1304
|
checks: [
|
|
1305
1305
|
...this._def.checks,
|
|
1306
1306
|
{
|
|
1307
1307
|
kind: e,
|
|
1308
|
-
value:
|
|
1308
|
+
value: t,
|
|
1309
1309
|
inclusive: s,
|
|
1310
1310
|
message: h.toString(r)
|
|
1311
1311
|
}
|
|
@@ -1350,38 +1350,38 @@ class F extends v {
|
|
|
1350
1350
|
message: h.toString(e)
|
|
1351
1351
|
});
|
|
1352
1352
|
}
|
|
1353
|
-
multipleOf(e,
|
|
1353
|
+
multipleOf(e, t) {
|
|
1354
1354
|
return this._addCheck({
|
|
1355
1355
|
kind: "multipleOf",
|
|
1356
1356
|
value: e,
|
|
1357
|
-
message: h.toString(
|
|
1357
|
+
message: h.toString(t)
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
1360
|
get minValue() {
|
|
1361
1361
|
let e = null;
|
|
1362
|
-
for (const
|
|
1363
|
-
|
|
1362
|
+
for (const t of this._def.checks)
|
|
1363
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1364
1364
|
return e;
|
|
1365
1365
|
}
|
|
1366
1366
|
get maxValue() {
|
|
1367
1367
|
let e = null;
|
|
1368
|
-
for (const
|
|
1369
|
-
|
|
1368
|
+
for (const t of this._def.checks)
|
|
1369
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1370
1370
|
return e;
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
|
-
F.create = (
|
|
1373
|
+
F.create = (n) => new F({
|
|
1374
1374
|
checks: [],
|
|
1375
1375
|
typeName: y.ZodBigInt,
|
|
1376
|
-
coerce:
|
|
1377
|
-
..._(
|
|
1376
|
+
coerce: n?.coerce ?? !1,
|
|
1377
|
+
..._(n)
|
|
1378
1378
|
});
|
|
1379
1379
|
class he extends v {
|
|
1380
1380
|
_parse(e) {
|
|
1381
1381
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1382
1382
|
const s = this._getOrReturnCtx(e);
|
|
1383
1383
|
return l(s, {
|
|
1384
|
-
code:
|
|
1384
|
+
code: d.invalid_type,
|
|
1385
1385
|
expected: f.boolean,
|
|
1386
1386
|
received: s.parsedType
|
|
1387
1387
|
}), m;
|
|
@@ -1389,17 +1389,17 @@ class he extends v {
|
|
|
1389
1389
|
return S(e.data);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
he.create = (
|
|
1392
|
+
he.create = (n) => new he({
|
|
1393
1393
|
typeName: y.ZodBoolean,
|
|
1394
|
-
coerce:
|
|
1395
|
-
..._(
|
|
1394
|
+
coerce: n?.coerce || !1,
|
|
1395
|
+
..._(n)
|
|
1396
1396
|
});
|
|
1397
|
-
class
|
|
1397
|
+
class K extends v {
|
|
1398
1398
|
_parse(e) {
|
|
1399
1399
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1400
1400
|
const a = this._getOrReturnCtx(e);
|
|
1401
1401
|
return l(a, {
|
|
1402
|
-
code:
|
|
1402
|
+
code: d.invalid_type,
|
|
1403
1403
|
expected: f.date,
|
|
1404
1404
|
received: a.parsedType
|
|
1405
1405
|
}), m;
|
|
@@ -1407,21 +1407,21 @@ class Y extends v {
|
|
|
1407
1407
|
if (Number.isNaN(e.data.getTime())) {
|
|
1408
1408
|
const a = this._getOrReturnCtx(e);
|
|
1409
1409
|
return l(a, {
|
|
1410
|
-
code:
|
|
1410
|
+
code: d.invalid_date
|
|
1411
1411
|
}), m;
|
|
1412
1412
|
}
|
|
1413
1413
|
const s = new T();
|
|
1414
1414
|
let r;
|
|
1415
1415
|
for (const a of this._def.checks)
|
|
1416
1416
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1417
|
-
code:
|
|
1417
|
+
code: d.too_small,
|
|
1418
1418
|
message: a.message,
|
|
1419
1419
|
inclusive: !0,
|
|
1420
1420
|
exact: !1,
|
|
1421
1421
|
minimum: a.value,
|
|
1422
1422
|
type: "date"
|
|
1423
1423
|
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1424
|
-
code:
|
|
1424
|
+
code: d.too_big,
|
|
1425
1425
|
message: a.message,
|
|
1426
1426
|
inclusive: !0,
|
|
1427
1427
|
exact: !1,
|
|
@@ -1434,50 +1434,50 @@ class Y extends v {
|
|
|
1434
1434
|
};
|
|
1435
1435
|
}
|
|
1436
1436
|
_addCheck(e) {
|
|
1437
|
-
return new
|
|
1437
|
+
return new K({
|
|
1438
1438
|
...this._def,
|
|
1439
1439
|
checks: [...this._def.checks, e]
|
|
1440
1440
|
});
|
|
1441
1441
|
}
|
|
1442
|
-
min(e,
|
|
1442
|
+
min(e, t) {
|
|
1443
1443
|
return this._addCheck({
|
|
1444
1444
|
kind: "min",
|
|
1445
1445
|
value: e.getTime(),
|
|
1446
|
-
message: h.toString(
|
|
1446
|
+
message: h.toString(t)
|
|
1447
1447
|
});
|
|
1448
1448
|
}
|
|
1449
|
-
max(e,
|
|
1449
|
+
max(e, t) {
|
|
1450
1450
|
return this._addCheck({
|
|
1451
1451
|
kind: "max",
|
|
1452
1452
|
value: e.getTime(),
|
|
1453
|
-
message: h.toString(
|
|
1453
|
+
message: h.toString(t)
|
|
1454
1454
|
});
|
|
1455
1455
|
}
|
|
1456
1456
|
get minDate() {
|
|
1457
1457
|
let e = null;
|
|
1458
|
-
for (const
|
|
1459
|
-
|
|
1458
|
+
for (const t of this._def.checks)
|
|
1459
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1460
1460
|
return e != null ? new Date(e) : null;
|
|
1461
1461
|
}
|
|
1462
1462
|
get maxDate() {
|
|
1463
1463
|
let e = null;
|
|
1464
|
-
for (const
|
|
1465
|
-
|
|
1464
|
+
for (const t of this._def.checks)
|
|
1465
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1466
1466
|
return e != null ? new Date(e) : null;
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
-
|
|
1469
|
+
K.create = (n) => new K({
|
|
1470
1470
|
checks: [],
|
|
1471
|
-
coerce:
|
|
1471
|
+
coerce: n?.coerce || !1,
|
|
1472
1472
|
typeName: y.ZodDate,
|
|
1473
|
-
..._(
|
|
1473
|
+
..._(n)
|
|
1474
1474
|
});
|
|
1475
1475
|
class Ee extends v {
|
|
1476
1476
|
_parse(e) {
|
|
1477
1477
|
if (this._getType(e) !== f.symbol) {
|
|
1478
1478
|
const s = this._getOrReturnCtx(e);
|
|
1479
1479
|
return l(s, {
|
|
1480
|
-
code:
|
|
1480
|
+
code: d.invalid_type,
|
|
1481
1481
|
expected: f.symbol,
|
|
1482
1482
|
received: s.parsedType
|
|
1483
1483
|
}), m;
|
|
@@ -1485,16 +1485,16 @@ class Ee extends v {
|
|
|
1485
1485
|
return S(e.data);
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
|
-
Ee.create = (
|
|
1488
|
+
Ee.create = (n) => new Ee({
|
|
1489
1489
|
typeName: y.ZodSymbol,
|
|
1490
|
-
..._(
|
|
1490
|
+
..._(n)
|
|
1491
1491
|
});
|
|
1492
1492
|
class pe extends v {
|
|
1493
1493
|
_parse(e) {
|
|
1494
1494
|
if (this._getType(e) !== f.undefined) {
|
|
1495
1495
|
const s = this._getOrReturnCtx(e);
|
|
1496
1496
|
return l(s, {
|
|
1497
|
-
code:
|
|
1497
|
+
code: d.invalid_type,
|
|
1498
1498
|
expected: f.undefined,
|
|
1499
1499
|
received: s.parsedType
|
|
1500
1500
|
}), m;
|
|
@@ -1502,16 +1502,16 @@ class pe extends v {
|
|
|
1502
1502
|
return S(e.data);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
pe.create = (
|
|
1505
|
+
pe.create = (n) => new pe({
|
|
1506
1506
|
typeName: y.ZodUndefined,
|
|
1507
|
-
..._(
|
|
1507
|
+
..._(n)
|
|
1508
1508
|
});
|
|
1509
1509
|
class me extends v {
|
|
1510
1510
|
_parse(e) {
|
|
1511
1511
|
if (this._getType(e) !== f.null) {
|
|
1512
1512
|
const s = this._getOrReturnCtx(e);
|
|
1513
1513
|
return l(s, {
|
|
1514
|
-
code:
|
|
1514
|
+
code: d.invalid_type,
|
|
1515
1515
|
expected: f.null,
|
|
1516
1516
|
received: s.parsedType
|
|
1517
1517
|
}), m;
|
|
@@ -1519,11 +1519,11 @@ class me extends v {
|
|
|
1519
1519
|
return S(e.data);
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
|
-
me.create = (
|
|
1522
|
+
me.create = (n) => new me({
|
|
1523
1523
|
typeName: y.ZodNull,
|
|
1524
|
-
..._(
|
|
1524
|
+
..._(n)
|
|
1525
1525
|
});
|
|
1526
|
-
class
|
|
1526
|
+
class ie extends v {
|
|
1527
1527
|
constructor() {
|
|
1528
1528
|
super(...arguments), this._any = !0;
|
|
1529
1529
|
}
|
|
@@ -1531,11 +1531,11 @@ class oe extends v {
|
|
|
1531
1531
|
return S(e.data);
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
1534
|
-
|
|
1534
|
+
ie.create = (n) => new ie({
|
|
1535
1535
|
typeName: y.ZodAny,
|
|
1536
|
-
..._(
|
|
1536
|
+
..._(n)
|
|
1537
1537
|
});
|
|
1538
|
-
class
|
|
1538
|
+
class Y extends v {
|
|
1539
1539
|
constructor() {
|
|
1540
1540
|
super(...arguments), this._unknown = !0;
|
|
1541
1541
|
}
|
|
@@ -1543,30 +1543,30 @@ class K extends v {
|
|
|
1543
1543
|
return S(e.data);
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
|
-
|
|
1546
|
+
Y.create = (n) => new Y({
|
|
1547
1547
|
typeName: y.ZodUnknown,
|
|
1548
|
-
..._(
|
|
1548
|
+
..._(n)
|
|
1549
1549
|
});
|
|
1550
|
-
class
|
|
1550
|
+
class z extends v {
|
|
1551
1551
|
_parse(e) {
|
|
1552
|
-
const
|
|
1553
|
-
return l(
|
|
1554
|
-
code:
|
|
1552
|
+
const t = this._getOrReturnCtx(e);
|
|
1553
|
+
return l(t, {
|
|
1554
|
+
code: d.invalid_type,
|
|
1555
1555
|
expected: f.never,
|
|
1556
|
-
received:
|
|
1556
|
+
received: t.parsedType
|
|
1557
1557
|
}), m;
|
|
1558
1558
|
}
|
|
1559
1559
|
}
|
|
1560
|
-
|
|
1560
|
+
z.create = (n) => new z({
|
|
1561
1561
|
typeName: y.ZodNever,
|
|
1562
|
-
..._(
|
|
1562
|
+
..._(n)
|
|
1563
1563
|
});
|
|
1564
1564
|
class Ne extends v {
|
|
1565
1565
|
_parse(e) {
|
|
1566
1566
|
if (this._getType(e) !== f.undefined) {
|
|
1567
1567
|
const s = this._getOrReturnCtx(e);
|
|
1568
1568
|
return l(s, {
|
|
1569
|
-
code:
|
|
1569
|
+
code: d.invalid_type,
|
|
1570
1570
|
expected: f.void,
|
|
1571
1571
|
received: s.parsedType
|
|
1572
1572
|
}), m;
|
|
@@ -1574,23 +1574,23 @@ class Ne extends v {
|
|
|
1574
1574
|
return S(e.data);
|
|
1575
1575
|
}
|
|
1576
1576
|
}
|
|
1577
|
-
Ne.create = (
|
|
1577
|
+
Ne.create = (n) => new Ne({
|
|
1578
1578
|
typeName: y.ZodVoid,
|
|
1579
|
-
..._(
|
|
1579
|
+
..._(n)
|
|
1580
1580
|
});
|
|
1581
|
-
class
|
|
1581
|
+
class E extends v {
|
|
1582
1582
|
_parse(e) {
|
|
1583
|
-
const { ctx:
|
|
1584
|
-
if (
|
|
1585
|
-
return l(
|
|
1586
|
-
code:
|
|
1583
|
+
const { ctx: t, status: s } = this._processInputParams(e), r = this._def;
|
|
1584
|
+
if (t.parsedType !== f.array)
|
|
1585
|
+
return l(t, {
|
|
1586
|
+
code: d.invalid_type,
|
|
1587
1587
|
expected: f.array,
|
|
1588
|
-
received:
|
|
1588
|
+
received: t.parsedType
|
|
1589
1589
|
}), m;
|
|
1590
1590
|
if (r.exactLength !== null) {
|
|
1591
|
-
const i =
|
|
1592
|
-
(i || o) && (l(
|
|
1593
|
-
code: i ?
|
|
1591
|
+
const i = t.data.length > r.exactLength.value, o = t.data.length < r.exactLength.value;
|
|
1592
|
+
(i || o) && (l(t, {
|
|
1593
|
+
code: i ? d.too_big : d.too_small,
|
|
1594
1594
|
minimum: o ? r.exactLength.value : void 0,
|
|
1595
1595
|
maximum: i ? r.exactLength.value : void 0,
|
|
1596
1596
|
type: "array",
|
|
@@ -1599,73 +1599,73 @@ class N extends v {
|
|
|
1599
1599
|
message: r.exactLength.message
|
|
1600
1600
|
}), s.dirty());
|
|
1601
1601
|
}
|
|
1602
|
-
if (r.minLength !== null &&
|
|
1603
|
-
code:
|
|
1602
|
+
if (r.minLength !== null && t.data.length < r.minLength.value && (l(t, {
|
|
1603
|
+
code: d.too_small,
|
|
1604
1604
|
minimum: r.minLength.value,
|
|
1605
1605
|
type: "array",
|
|
1606
1606
|
inclusive: !0,
|
|
1607
1607
|
exact: !1,
|
|
1608
1608
|
message: r.minLength.message
|
|
1609
|
-
}), s.dirty()), r.maxLength !== null &&
|
|
1610
|
-
code:
|
|
1609
|
+
}), s.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (l(t, {
|
|
1610
|
+
code: d.too_big,
|
|
1611
1611
|
maximum: r.maxLength.value,
|
|
1612
1612
|
type: "array",
|
|
1613
1613
|
inclusive: !0,
|
|
1614
1614
|
exact: !1,
|
|
1615
1615
|
message: r.maxLength.message
|
|
1616
|
-
}), s.dirty()),
|
|
1617
|
-
return Promise.all([...
|
|
1618
|
-
const a = [...
|
|
1616
|
+
}), s.dirty()), t.common.async)
|
|
1617
|
+
return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new $(t, i, t.path, o)))).then((i) => T.mergeArray(s, i));
|
|
1618
|
+
const a = [...t.data].map((i, o) => r.type._parseSync(new $(t, i, t.path, o)));
|
|
1619
1619
|
return T.mergeArray(s, a);
|
|
1620
1620
|
}
|
|
1621
1621
|
get element() {
|
|
1622
1622
|
return this._def.type;
|
|
1623
1623
|
}
|
|
1624
|
-
min(e,
|
|
1625
|
-
return new
|
|
1624
|
+
min(e, t) {
|
|
1625
|
+
return new E({
|
|
1626
1626
|
...this._def,
|
|
1627
|
-
minLength: { value: e, message: h.toString(
|
|
1627
|
+
minLength: { value: e, message: h.toString(t) }
|
|
1628
1628
|
});
|
|
1629
1629
|
}
|
|
1630
|
-
max(e,
|
|
1631
|
-
return new
|
|
1630
|
+
max(e, t) {
|
|
1631
|
+
return new E({
|
|
1632
1632
|
...this._def,
|
|
1633
|
-
maxLength: { value: e, message: h.toString(
|
|
1633
|
+
maxLength: { value: e, message: h.toString(t) }
|
|
1634
1634
|
});
|
|
1635
1635
|
}
|
|
1636
|
-
length(e,
|
|
1637
|
-
return new
|
|
1636
|
+
length(e, t) {
|
|
1637
|
+
return new E({
|
|
1638
1638
|
...this._def,
|
|
1639
|
-
exactLength: { value: e, message: h.toString(
|
|
1639
|
+
exactLength: { value: e, message: h.toString(t) }
|
|
1640
1640
|
});
|
|
1641
1641
|
}
|
|
1642
1642
|
nonempty(e) {
|
|
1643
1643
|
return this.min(1, e);
|
|
1644
1644
|
}
|
|
1645
1645
|
}
|
|
1646
|
-
|
|
1647
|
-
type:
|
|
1646
|
+
E.create = (n, e) => new E({
|
|
1647
|
+
type: n,
|
|
1648
1648
|
minLength: null,
|
|
1649
1649
|
maxLength: null,
|
|
1650
1650
|
exactLength: null,
|
|
1651
1651
|
typeName: y.ZodArray,
|
|
1652
1652
|
..._(e)
|
|
1653
1653
|
});
|
|
1654
|
-
function
|
|
1655
|
-
if (
|
|
1654
|
+
function ne(n) {
|
|
1655
|
+
if (n instanceof k) {
|
|
1656
1656
|
const e = {};
|
|
1657
|
-
for (const
|
|
1658
|
-
const s =
|
|
1659
|
-
e[
|
|
1657
|
+
for (const t in n.shape) {
|
|
1658
|
+
const s = n.shape[t];
|
|
1659
|
+
e[t] = I.create(ne(s));
|
|
1660
1660
|
}
|
|
1661
1661
|
return new k({
|
|
1662
|
-
...
|
|
1662
|
+
...n._def,
|
|
1663
1663
|
shape: () => e
|
|
1664
1664
|
});
|
|
1665
|
-
} else return
|
|
1666
|
-
...
|
|
1667
|
-
type:
|
|
1668
|
-
}) :
|
|
1665
|
+
} else return n instanceof E ? new E({
|
|
1666
|
+
...n._def,
|
|
1667
|
+
type: ne(n.element)
|
|
1668
|
+
}) : n instanceof I ? I.create(ne(n.unwrap())) : n instanceof W ? W.create(ne(n.unwrap())) : n instanceof P ? P.create(n.items.map((e) => ne(e))) : n;
|
|
1669
1669
|
}
|
|
1670
1670
|
class k extends v {
|
|
1671
1671
|
constructor() {
|
|
@@ -1674,52 +1674,52 @@ class k extends v {
|
|
|
1674
1674
|
_getCached() {
|
|
1675
1675
|
if (this._cached !== null)
|
|
1676
1676
|
return this._cached;
|
|
1677
|
-
const e = this._def.shape(),
|
|
1678
|
-
return this._cached = { shape: e, keys:
|
|
1677
|
+
const e = this._def.shape(), t = x.objectKeys(e);
|
|
1678
|
+
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1679
1679
|
}
|
|
1680
1680
|
_parse(e) {
|
|
1681
1681
|
if (this._getType(e) !== f.object) {
|
|
1682
|
-
const
|
|
1683
|
-
return l(
|
|
1684
|
-
code:
|
|
1682
|
+
const u = this._getOrReturnCtx(e);
|
|
1683
|
+
return l(u, {
|
|
1684
|
+
code: d.invalid_type,
|
|
1685
1685
|
expected: f.object,
|
|
1686
|
-
received:
|
|
1686
|
+
received: u.parsedType
|
|
1687
1687
|
}), m;
|
|
1688
1688
|
}
|
|
1689
1689
|
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1690
|
-
if (!(this._def.catchall instanceof
|
|
1691
|
-
for (const
|
|
1692
|
-
i.includes(
|
|
1690
|
+
if (!(this._def.catchall instanceof z && this._def.unknownKeys === "strip"))
|
|
1691
|
+
for (const u in r.data)
|
|
1692
|
+
i.includes(u) || o.push(u);
|
|
1693
1693
|
const c = [];
|
|
1694
|
-
for (const
|
|
1695
|
-
const p = a[
|
|
1694
|
+
for (const u of i) {
|
|
1695
|
+
const p = a[u], b = r.data[u];
|
|
1696
1696
|
c.push({
|
|
1697
|
-
key: { status: "valid", value:
|
|
1698
|
-
value: p._parse(new $(r, b, r.path,
|
|
1699
|
-
alwaysSet:
|
|
1697
|
+
key: { status: "valid", value: u },
|
|
1698
|
+
value: p._parse(new $(r, b, r.path, u)),
|
|
1699
|
+
alwaysSet: u in r.data
|
|
1700
1700
|
});
|
|
1701
1701
|
}
|
|
1702
|
-
if (this._def.catchall instanceof
|
|
1703
|
-
const
|
|
1704
|
-
if (
|
|
1702
|
+
if (this._def.catchall instanceof z) {
|
|
1703
|
+
const u = this._def.unknownKeys;
|
|
1704
|
+
if (u === "passthrough")
|
|
1705
1705
|
for (const p of o)
|
|
1706
1706
|
c.push({
|
|
1707
1707
|
key: { status: "valid", value: p },
|
|
1708
1708
|
value: { status: "valid", value: r.data[p] }
|
|
1709
1709
|
});
|
|
1710
|
-
else if (
|
|
1710
|
+
else if (u === "strict")
|
|
1711
1711
|
o.length > 0 && (l(r, {
|
|
1712
|
-
code:
|
|
1712
|
+
code: d.unrecognized_keys,
|
|
1713
1713
|
keys: o
|
|
1714
1714
|
}), s.dirty());
|
|
1715
|
-
else if (
|
|
1715
|
+
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1716
1716
|
} else {
|
|
1717
|
-
const
|
|
1717
|
+
const u = this._def.catchall;
|
|
1718
1718
|
for (const p of o) {
|
|
1719
1719
|
const b = r.data[p];
|
|
1720
1720
|
c.push({
|
|
1721
1721
|
key: { status: "valid", value: p },
|
|
1722
|
-
value:
|
|
1722
|
+
value: u._parse(
|
|
1723
1723
|
new $(r, b, r.path, p)
|
|
1724
1724
|
//, ctx.child(key), value, getParsedType(value)
|
|
1725
1725
|
),
|
|
@@ -1728,17 +1728,17 @@ class k extends v {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
}
|
|
1730
1730
|
return r.common.async ? Promise.resolve().then(async () => {
|
|
1731
|
-
const
|
|
1731
|
+
const u = [];
|
|
1732
1732
|
for (const p of c) {
|
|
1733
1733
|
const b = await p.key, C = await p.value;
|
|
1734
|
-
|
|
1734
|
+
u.push({
|
|
1735
1735
|
key: b,
|
|
1736
1736
|
value: C,
|
|
1737
1737
|
alwaysSet: p.alwaysSet
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
1740
|
-
return
|
|
1741
|
-
}).then((
|
|
1740
|
+
return u;
|
|
1741
|
+
}).then((u) => T.mergeObjectSync(s, u)) : T.mergeObjectSync(s, c);
|
|
1742
1742
|
}
|
|
1743
1743
|
get shape() {
|
|
1744
1744
|
return this._def.shape();
|
|
@@ -1748,9 +1748,9 @@ class k extends v {
|
|
|
1748
1748
|
...this._def,
|
|
1749
1749
|
unknownKeys: "strict",
|
|
1750
1750
|
...e !== void 0 ? {
|
|
1751
|
-
errorMap: (
|
|
1752
|
-
const r = this._def.errorMap?.(
|
|
1753
|
-
return
|
|
1751
|
+
errorMap: (t, s) => {
|
|
1752
|
+
const r = this._def.errorMap?.(t, s).message ?? s.defaultError;
|
|
1753
|
+
return t.code === "unrecognized_keys" ? {
|
|
1754
1754
|
message: h.errToObj(e).message ?? r
|
|
1755
1755
|
} : {
|
|
1756
1756
|
message: r
|
|
@@ -1848,8 +1848,8 @@ class k extends v {
|
|
|
1848
1848
|
// }) as any;
|
|
1849
1849
|
// return merged;
|
|
1850
1850
|
// }
|
|
1851
|
-
setKey(e,
|
|
1852
|
-
return this.augment({ [e]:
|
|
1851
|
+
setKey(e, t) {
|
|
1852
|
+
return this.augment({ [e]: t });
|
|
1853
1853
|
}
|
|
1854
1854
|
// merge<Incoming extends AnyZodObject>(
|
|
1855
1855
|
// merging: Incoming
|
|
@@ -1879,111 +1879,111 @@ class k extends v {
|
|
|
1879
1879
|
});
|
|
1880
1880
|
}
|
|
1881
1881
|
pick(e) {
|
|
1882
|
-
const
|
|
1882
|
+
const t = {};
|
|
1883
1883
|
for (const s of x.objectKeys(e))
|
|
1884
|
-
e[s] && this.shape[s] && (
|
|
1884
|
+
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1885
1885
|
return new k({
|
|
1886
1886
|
...this._def,
|
|
1887
|
-
shape: () =>
|
|
1887
|
+
shape: () => t
|
|
1888
1888
|
});
|
|
1889
1889
|
}
|
|
1890
1890
|
omit(e) {
|
|
1891
|
-
const
|
|
1891
|
+
const t = {};
|
|
1892
1892
|
for (const s of x.objectKeys(this.shape))
|
|
1893
|
-
e[s] || (
|
|
1893
|
+
e[s] || (t[s] = this.shape[s]);
|
|
1894
1894
|
return new k({
|
|
1895
1895
|
...this._def,
|
|
1896
|
-
shape: () =>
|
|
1896
|
+
shape: () => t
|
|
1897
1897
|
});
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
1900
1900
|
* @deprecated
|
|
1901
1901
|
*/
|
|
1902
1902
|
deepPartial() {
|
|
1903
|
-
return
|
|
1903
|
+
return ne(this);
|
|
1904
1904
|
}
|
|
1905
1905
|
partial(e) {
|
|
1906
|
-
const
|
|
1906
|
+
const t = {};
|
|
1907
1907
|
for (const s of x.objectKeys(this.shape)) {
|
|
1908
1908
|
const r = this.shape[s];
|
|
1909
|
-
e && !e[s] ?
|
|
1909
|
+
e && !e[s] ? t[s] = r : t[s] = r.optional();
|
|
1910
1910
|
}
|
|
1911
1911
|
return new k({
|
|
1912
1912
|
...this._def,
|
|
1913
|
-
shape: () =>
|
|
1913
|
+
shape: () => t
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
1916
|
required(e) {
|
|
1917
|
-
const
|
|
1917
|
+
const t = {};
|
|
1918
1918
|
for (const s of x.objectKeys(this.shape))
|
|
1919
1919
|
if (e && !e[s])
|
|
1920
|
-
|
|
1920
|
+
t[s] = this.shape[s];
|
|
1921
1921
|
else {
|
|
1922
1922
|
let a = this.shape[s];
|
|
1923
|
-
for (; a instanceof
|
|
1923
|
+
for (; a instanceof I; )
|
|
1924
1924
|
a = a._def.innerType;
|
|
1925
|
-
|
|
1925
|
+
t[s] = a;
|
|
1926
1926
|
}
|
|
1927
1927
|
return new k({
|
|
1928
1928
|
...this._def,
|
|
1929
|
-
shape: () =>
|
|
1929
|
+
shape: () => t
|
|
1930
1930
|
});
|
|
1931
1931
|
}
|
|
1932
1932
|
keyof() {
|
|
1933
1933
|
return it(x.objectKeys(this.shape));
|
|
1934
1934
|
}
|
|
1935
1935
|
}
|
|
1936
|
-
k.create = (
|
|
1937
|
-
shape: () =>
|
|
1936
|
+
k.create = (n, e) => new k({
|
|
1937
|
+
shape: () => n,
|
|
1938
1938
|
unknownKeys: "strip",
|
|
1939
|
-
catchall:
|
|
1939
|
+
catchall: z.create(),
|
|
1940
1940
|
typeName: y.ZodObject,
|
|
1941
1941
|
..._(e)
|
|
1942
1942
|
});
|
|
1943
|
-
k.strictCreate = (
|
|
1944
|
-
shape: () =>
|
|
1943
|
+
k.strictCreate = (n, e) => new k({
|
|
1944
|
+
shape: () => n,
|
|
1945
1945
|
unknownKeys: "strict",
|
|
1946
|
-
catchall:
|
|
1946
|
+
catchall: z.create(),
|
|
1947
1947
|
typeName: y.ZodObject,
|
|
1948
1948
|
..._(e)
|
|
1949
1949
|
});
|
|
1950
|
-
k.lazycreate = (
|
|
1951
|
-
shape:
|
|
1950
|
+
k.lazycreate = (n, e) => new k({
|
|
1951
|
+
shape: n,
|
|
1952
1952
|
unknownKeys: "strip",
|
|
1953
|
-
catchall:
|
|
1953
|
+
catchall: z.create(),
|
|
1954
1954
|
typeName: y.ZodObject,
|
|
1955
1955
|
..._(e)
|
|
1956
1956
|
});
|
|
1957
1957
|
class ye extends v {
|
|
1958
1958
|
_parse(e) {
|
|
1959
|
-
const { ctx:
|
|
1959
|
+
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1960
1960
|
function r(a) {
|
|
1961
1961
|
for (const o of a)
|
|
1962
1962
|
if (o.result.status === "valid")
|
|
1963
1963
|
return o.result;
|
|
1964
1964
|
for (const o of a)
|
|
1965
1965
|
if (o.result.status === "dirty")
|
|
1966
|
-
return
|
|
1967
|
-
const i = a.map((o) => new
|
|
1968
|
-
return l(
|
|
1969
|
-
code:
|
|
1966
|
+
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1967
|
+
const i = a.map((o) => new O(o.ctx.common.issues));
|
|
1968
|
+
return l(t, {
|
|
1969
|
+
code: d.invalid_union,
|
|
1970
1970
|
unionErrors: i
|
|
1971
1971
|
}), m;
|
|
1972
1972
|
}
|
|
1973
|
-
if (
|
|
1973
|
+
if (t.common.async)
|
|
1974
1974
|
return Promise.all(s.map(async (a) => {
|
|
1975
1975
|
const i = {
|
|
1976
|
-
...
|
|
1976
|
+
...t,
|
|
1977
1977
|
common: {
|
|
1978
|
-
...
|
|
1978
|
+
...t.common,
|
|
1979
1979
|
issues: []
|
|
1980
1980
|
},
|
|
1981
1981
|
parent: null
|
|
1982
1982
|
};
|
|
1983
1983
|
return {
|
|
1984
1984
|
result: await a._parseAsync({
|
|
1985
|
-
data:
|
|
1986
|
-
path:
|
|
1985
|
+
data: t.data,
|
|
1986
|
+
path: t.path,
|
|
1987
1987
|
parent: i
|
|
1988
1988
|
}),
|
|
1989
1989
|
ctx: i
|
|
@@ -1993,27 +1993,27 @@ class ye extends v {
|
|
|
1993
1993
|
let a;
|
|
1994
1994
|
const i = [];
|
|
1995
1995
|
for (const c of s) {
|
|
1996
|
-
const
|
|
1997
|
-
...
|
|
1996
|
+
const u = {
|
|
1997
|
+
...t,
|
|
1998
1998
|
common: {
|
|
1999
|
-
...
|
|
1999
|
+
...t.common,
|
|
2000
2000
|
issues: []
|
|
2001
2001
|
},
|
|
2002
2002
|
parent: null
|
|
2003
2003
|
}, p = c._parseSync({
|
|
2004
|
-
data:
|
|
2005
|
-
path:
|
|
2006
|
-
parent:
|
|
2004
|
+
data: t.data,
|
|
2005
|
+
path: t.path,
|
|
2006
|
+
parent: u
|
|
2007
2007
|
});
|
|
2008
2008
|
if (p.status === "valid")
|
|
2009
2009
|
return p;
|
|
2010
|
-
p.status === "dirty" && !a && (a = { result: p, ctx:
|
|
2010
|
+
p.status === "dirty" && !a && (a = { result: p, ctx: u }), u.common.issues.length && i.push(u.common.issues);
|
|
2011
2011
|
}
|
|
2012
2012
|
if (a)
|
|
2013
|
-
return
|
|
2014
|
-
const o = i.map((c) => new
|
|
2015
|
-
return l(
|
|
2016
|
-
code:
|
|
2013
|
+
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2014
|
+
const o = i.map((c) => new O(c));
|
|
2015
|
+
return l(t, {
|
|
2016
|
+
code: d.invalid_union,
|
|
2017
2017
|
unionErrors: o
|
|
2018
2018
|
}), m;
|
|
2019
2019
|
}
|
|
@@ -2022,32 +2022,32 @@ class ye extends v {
|
|
|
2022
2022
|
return this._def.options;
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
2025
|
-
ye.create = (
|
|
2026
|
-
options:
|
|
2025
|
+
ye.create = (n, e) => new ye({
|
|
2026
|
+
options: n,
|
|
2027
2027
|
typeName: y.ZodUnion,
|
|
2028
2028
|
..._(e)
|
|
2029
2029
|
});
|
|
2030
|
-
const L = (
|
|
2031
|
-
class
|
|
2030
|
+
const L = (n) => n instanceof ve ? L(n.schema) : n instanceof N ? L(n.innerType()) : n instanceof xe ? [n.value] : n instanceof q ? n.options : n instanceof be ? x.objectValues(n.enum) : n instanceof ke ? L(n._def.innerType) : n instanceof pe ? [void 0] : n instanceof me ? [null] : n instanceof I ? [void 0, ...L(n.unwrap())] : n instanceof W ? [null, ...L(n.unwrap())] : n instanceof Ye || n instanceof Te ? L(n.unwrap()) : n instanceof we ? L(n._def.innerType) : [];
|
|
2031
|
+
class Pe extends v {
|
|
2032
2032
|
_parse(e) {
|
|
2033
|
-
const { ctx:
|
|
2034
|
-
if (
|
|
2035
|
-
return l(
|
|
2036
|
-
code:
|
|
2033
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2034
|
+
if (t.parsedType !== f.object)
|
|
2035
|
+
return l(t, {
|
|
2036
|
+
code: d.invalid_type,
|
|
2037
2037
|
expected: f.object,
|
|
2038
|
-
received:
|
|
2038
|
+
received: t.parsedType
|
|
2039
2039
|
}), m;
|
|
2040
|
-
const s = this.discriminator, r =
|
|
2041
|
-
return a ?
|
|
2042
|
-
data:
|
|
2043
|
-
path:
|
|
2044
|
-
parent:
|
|
2040
|
+
const s = this.discriminator, r = t.data[s], a = this.optionsMap.get(r);
|
|
2041
|
+
return a ? t.common.async ? a._parseAsync({
|
|
2042
|
+
data: t.data,
|
|
2043
|
+
path: t.path,
|
|
2044
|
+
parent: t
|
|
2045
2045
|
}) : a._parseSync({
|
|
2046
|
-
data:
|
|
2047
|
-
path:
|
|
2048
|
-
parent:
|
|
2049
|
-
}) : (l(
|
|
2050
|
-
code:
|
|
2046
|
+
data: t.data,
|
|
2047
|
+
path: t.path,
|
|
2048
|
+
parent: t
|
|
2049
|
+
}) : (l(t, {
|
|
2050
|
+
code: d.invalid_union_discriminator,
|
|
2051
2051
|
options: Array.from(this.optionsMap.keys()),
|
|
2052
2052
|
path: [s]
|
|
2053
2053
|
}), m);
|
|
@@ -2069,9 +2069,9 @@ class $e extends v {
|
|
|
2069
2069
|
* @param types an array of object schemas
|
|
2070
2070
|
* @param params
|
|
2071
2071
|
*/
|
|
2072
|
-
static create(e,
|
|
2072
|
+
static create(e, t, s) {
|
|
2073
2073
|
const r = /* @__PURE__ */ new Map();
|
|
2074
|
-
for (const a of
|
|
2074
|
+
for (const a of t) {
|
|
2075
2075
|
const i = L(a.shape[e]);
|
|
2076
2076
|
if (!i.length)
|
|
2077
2077
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
@@ -2081,49 +2081,49 @@ class $e extends v {
|
|
|
2081
2081
|
r.set(o, a);
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
|
-
return new
|
|
2084
|
+
return new Pe({
|
|
2085
2085
|
typeName: y.ZodDiscriminatedUnion,
|
|
2086
2086
|
discriminator: e,
|
|
2087
|
-
options:
|
|
2087
|
+
options: t,
|
|
2088
2088
|
optionsMap: r,
|
|
2089
2089
|
..._(s)
|
|
2090
2090
|
});
|
|
2091
2091
|
}
|
|
2092
2092
|
}
|
|
2093
|
-
function
|
|
2094
|
-
const
|
|
2095
|
-
if (
|
|
2096
|
-
return { valid: !0, data:
|
|
2097
|
-
if (
|
|
2098
|
-
const r = x.objectKeys(e), a = x.objectKeys(
|
|
2093
|
+
function Qe(n, e) {
|
|
2094
|
+
const t = V(n), s = V(e);
|
|
2095
|
+
if (n === e)
|
|
2096
|
+
return { valid: !0, data: n };
|
|
2097
|
+
if (t === f.object && s === f.object) {
|
|
2098
|
+
const r = x.objectKeys(e), a = x.objectKeys(n).filter((o) => r.indexOf(o) !== -1), i = { ...n, ...e };
|
|
2099
2099
|
for (const o of a) {
|
|
2100
|
-
const c =
|
|
2100
|
+
const c = Qe(n[o], e[o]);
|
|
2101
2101
|
if (!c.valid)
|
|
2102
2102
|
return { valid: !1 };
|
|
2103
2103
|
i[o] = c.data;
|
|
2104
2104
|
}
|
|
2105
2105
|
return { valid: !0, data: i };
|
|
2106
|
-
} else if (
|
|
2107
|
-
if (
|
|
2106
|
+
} else if (t === f.array && s === f.array) {
|
|
2107
|
+
if (n.length !== e.length)
|
|
2108
2108
|
return { valid: !1 };
|
|
2109
2109
|
const r = [];
|
|
2110
|
-
for (let a = 0; a <
|
|
2111
|
-
const i =
|
|
2110
|
+
for (let a = 0; a < n.length; a++) {
|
|
2111
|
+
const i = n[a], o = e[a], c = Qe(i, o);
|
|
2112
2112
|
if (!c.valid)
|
|
2113
2113
|
return { valid: !1 };
|
|
2114
2114
|
r.push(c.data);
|
|
2115
2115
|
}
|
|
2116
2116
|
return { valid: !0, data: r };
|
|
2117
|
-
} else return
|
|
2117
|
+
} else return t === f.date && s === f.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2118
2118
|
}
|
|
2119
2119
|
class _e extends v {
|
|
2120
2120
|
_parse(e) {
|
|
2121
|
-
const { status:
|
|
2122
|
-
if (
|
|
2121
|
+
const { status: t, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2122
|
+
if (We(a) || We(i))
|
|
2123
2123
|
return m;
|
|
2124
|
-
const o =
|
|
2125
|
-
return o.valid ? ((
|
|
2126
|
-
code:
|
|
2124
|
+
const o = Qe(a.value, i.value);
|
|
2125
|
+
return o.valid ? ((Je(a) || Je(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(s, {
|
|
2126
|
+
code: d.invalid_intersection_types
|
|
2127
2127
|
}), m);
|
|
2128
2128
|
};
|
|
2129
2129
|
return s.common.async ? Promise.all([
|
|
@@ -2148,41 +2148,41 @@ class _e extends v {
|
|
|
2148
2148
|
}));
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
|
-
_e.create = (
|
|
2152
|
-
left:
|
|
2151
|
+
_e.create = (n, e, t) => new _e({
|
|
2152
|
+
left: n,
|
|
2153
2153
|
right: e,
|
|
2154
2154
|
typeName: y.ZodIntersection,
|
|
2155
|
-
..._(
|
|
2155
|
+
..._(t)
|
|
2156
2156
|
});
|
|
2157
2157
|
class P extends v {
|
|
2158
2158
|
_parse(e) {
|
|
2159
|
-
const { status:
|
|
2159
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2160
2160
|
if (s.parsedType !== f.array)
|
|
2161
2161
|
return l(s, {
|
|
2162
|
-
code:
|
|
2162
|
+
code: d.invalid_type,
|
|
2163
2163
|
expected: f.array,
|
|
2164
2164
|
received: s.parsedType
|
|
2165
2165
|
}), m;
|
|
2166
2166
|
if (s.data.length < this._def.items.length)
|
|
2167
2167
|
return l(s, {
|
|
2168
|
-
code:
|
|
2168
|
+
code: d.too_small,
|
|
2169
2169
|
minimum: this._def.items.length,
|
|
2170
2170
|
inclusive: !0,
|
|
2171
2171
|
exact: !1,
|
|
2172
2172
|
type: "array"
|
|
2173
2173
|
}), m;
|
|
2174
2174
|
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2175
|
-
code:
|
|
2175
|
+
code: d.too_big,
|
|
2176
2176
|
maximum: this._def.items.length,
|
|
2177
2177
|
inclusive: !0,
|
|
2178
2178
|
exact: !1,
|
|
2179
2179
|
type: "array"
|
|
2180
|
-
}),
|
|
2180
|
+
}), t.dirty());
|
|
2181
2181
|
const a = [...s.data].map((i, o) => {
|
|
2182
2182
|
const c = this._def.items[o] || this._def.rest;
|
|
2183
2183
|
return c ? c._parse(new $(s, i, s.path, o)) : null;
|
|
2184
2184
|
}).filter((i) => !!i);
|
|
2185
|
-
return s.common.async ? Promise.all(a).then((i) => T.mergeArray(
|
|
2185
|
+
return s.common.async ? Promise.all(a).then((i) => T.mergeArray(t, i)) : T.mergeArray(t, a);
|
|
2186
2186
|
}
|
|
2187
2187
|
get items() {
|
|
2188
2188
|
return this._def.items;
|
|
@@ -2194,11 +2194,11 @@ class P extends v {
|
|
|
2194
2194
|
});
|
|
2195
2195
|
}
|
|
2196
2196
|
}
|
|
2197
|
-
P.create = (
|
|
2198
|
-
if (!Array.isArray(
|
|
2197
|
+
P.create = (n, e) => {
|
|
2198
|
+
if (!Array.isArray(n))
|
|
2199
2199
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2200
2200
|
return new P({
|
|
2201
|
-
items:
|
|
2201
|
+
items: n,
|
|
2202
2202
|
typeName: y.ZodTuple,
|
|
2203
2203
|
rest: null,
|
|
2204
2204
|
..._(e)
|
|
@@ -2212,10 +2212,10 @@ class ge extends v {
|
|
|
2212
2212
|
return this._def.valueType;
|
|
2213
2213
|
}
|
|
2214
2214
|
_parse(e) {
|
|
2215
|
-
const { status:
|
|
2215
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2216
2216
|
if (s.parsedType !== f.object)
|
|
2217
2217
|
return l(s, {
|
|
2218
|
-
code:
|
|
2218
|
+
code: d.invalid_type,
|
|
2219
2219
|
expected: f.object,
|
|
2220
2220
|
received: s.parsedType
|
|
2221
2221
|
}), m;
|
|
@@ -2226,26 +2226,26 @@ class ge extends v {
|
|
|
2226
2226
|
value: i._parse(new $(s, s.data[o], s.path, o)),
|
|
2227
2227
|
alwaysSet: o in s.data
|
|
2228
2228
|
});
|
|
2229
|
-
return s.common.async ? T.mergeObjectAsync(
|
|
2229
|
+
return s.common.async ? T.mergeObjectAsync(t, r) : T.mergeObjectSync(t, r);
|
|
2230
2230
|
}
|
|
2231
2231
|
get element() {
|
|
2232
2232
|
return this._def.valueType;
|
|
2233
2233
|
}
|
|
2234
|
-
static create(e,
|
|
2235
|
-
return
|
|
2234
|
+
static create(e, t, s) {
|
|
2235
|
+
return t instanceof v ? new ge({
|
|
2236
2236
|
keyType: e,
|
|
2237
|
-
valueType:
|
|
2237
|
+
valueType: t,
|
|
2238
2238
|
typeName: y.ZodRecord,
|
|
2239
2239
|
..._(s)
|
|
2240
2240
|
}) : new ge({
|
|
2241
|
-
keyType:
|
|
2241
|
+
keyType: R.create(),
|
|
2242
2242
|
valueType: e,
|
|
2243
2243
|
typeName: y.ZodRecord,
|
|
2244
|
-
..._(
|
|
2244
|
+
..._(t)
|
|
2245
2245
|
});
|
|
2246
2246
|
}
|
|
2247
2247
|
}
|
|
2248
|
-
class
|
|
2248
|
+
class je extends v {
|
|
2249
2249
|
get keySchema() {
|
|
2250
2250
|
return this._def.keyType;
|
|
2251
2251
|
}
|
|
@@ -2253,164 +2253,164 @@ class Re extends v {
|
|
|
2253
2253
|
return this._def.valueType;
|
|
2254
2254
|
}
|
|
2255
2255
|
_parse(e) {
|
|
2256
|
-
const { status:
|
|
2256
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2257
2257
|
if (s.parsedType !== f.map)
|
|
2258
2258
|
return l(s, {
|
|
2259
|
-
code:
|
|
2259
|
+
code: d.invalid_type,
|
|
2260
2260
|
expected: f.map,
|
|
2261
2261
|
received: s.parsedType
|
|
2262
2262
|
}), m;
|
|
2263
|
-
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c],
|
|
2264
|
-
key: r._parse(new $(s, o, s.path, [
|
|
2265
|
-
value: a._parse(new $(s, c, s.path, [
|
|
2263
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], u) => ({
|
|
2264
|
+
key: r._parse(new $(s, o, s.path, [u, "key"])),
|
|
2265
|
+
value: a._parse(new $(s, c, s.path, [u, "value"]))
|
|
2266
2266
|
}));
|
|
2267
2267
|
if (s.common.async) {
|
|
2268
2268
|
const o = /* @__PURE__ */ new Map();
|
|
2269
2269
|
return Promise.resolve().then(async () => {
|
|
2270
2270
|
for (const c of i) {
|
|
2271
|
-
const
|
|
2272
|
-
if (
|
|
2271
|
+
const u = await c.key, p = await c.value;
|
|
2272
|
+
if (u.status === "aborted" || p.status === "aborted")
|
|
2273
2273
|
return m;
|
|
2274
|
-
(
|
|
2274
|
+
(u.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(u.value, p.value);
|
|
2275
2275
|
}
|
|
2276
|
-
return { status:
|
|
2276
|
+
return { status: t.value, value: o };
|
|
2277
2277
|
});
|
|
2278
2278
|
} else {
|
|
2279
2279
|
const o = /* @__PURE__ */ new Map();
|
|
2280
2280
|
for (const c of i) {
|
|
2281
|
-
const
|
|
2282
|
-
if (
|
|
2281
|
+
const u = c.key, p = c.value;
|
|
2282
|
+
if (u.status === "aborted" || p.status === "aborted")
|
|
2283
2283
|
return m;
|
|
2284
|
-
(
|
|
2284
|
+
(u.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(u.value, p.value);
|
|
2285
2285
|
}
|
|
2286
|
-
return { status:
|
|
2286
|
+
return { status: t.value, value: o };
|
|
2287
2287
|
}
|
|
2288
2288
|
}
|
|
2289
2289
|
}
|
|
2290
|
-
|
|
2290
|
+
je.create = (n, e, t) => new je({
|
|
2291
2291
|
valueType: e,
|
|
2292
|
-
keyType:
|
|
2292
|
+
keyType: n,
|
|
2293
2293
|
typeName: y.ZodMap,
|
|
2294
|
-
..._(
|
|
2294
|
+
..._(t)
|
|
2295
2295
|
});
|
|
2296
2296
|
class X extends v {
|
|
2297
2297
|
_parse(e) {
|
|
2298
|
-
const { status:
|
|
2298
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2299
2299
|
if (s.parsedType !== f.set)
|
|
2300
2300
|
return l(s, {
|
|
2301
|
-
code:
|
|
2301
|
+
code: d.invalid_type,
|
|
2302
2302
|
expected: f.set,
|
|
2303
2303
|
received: s.parsedType
|
|
2304
2304
|
}), m;
|
|
2305
2305
|
const r = this._def;
|
|
2306
2306
|
r.minSize !== null && s.data.size < r.minSize.value && (l(s, {
|
|
2307
|
-
code:
|
|
2307
|
+
code: d.too_small,
|
|
2308
2308
|
minimum: r.minSize.value,
|
|
2309
2309
|
type: "set",
|
|
2310
2310
|
inclusive: !0,
|
|
2311
2311
|
exact: !1,
|
|
2312
2312
|
message: r.minSize.message
|
|
2313
|
-
}),
|
|
2314
|
-
code:
|
|
2313
|
+
}), t.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (l(s, {
|
|
2314
|
+
code: d.too_big,
|
|
2315
2315
|
maximum: r.maxSize.value,
|
|
2316
2316
|
type: "set",
|
|
2317
2317
|
inclusive: !0,
|
|
2318
2318
|
exact: !1,
|
|
2319
2319
|
message: r.maxSize.message
|
|
2320
|
-
}),
|
|
2320
|
+
}), t.dirty());
|
|
2321
2321
|
const a = this._def.valueType;
|
|
2322
2322
|
function i(c) {
|
|
2323
|
-
const
|
|
2323
|
+
const u = /* @__PURE__ */ new Set();
|
|
2324
2324
|
for (const p of c) {
|
|
2325
2325
|
if (p.status === "aborted")
|
|
2326
2326
|
return m;
|
|
2327
|
-
p.status === "dirty" &&
|
|
2327
|
+
p.status === "dirty" && t.dirty(), u.add(p.value);
|
|
2328
2328
|
}
|
|
2329
|
-
return { status:
|
|
2329
|
+
return { status: t.value, value: u };
|
|
2330
2330
|
}
|
|
2331
|
-
const o = [...s.data.values()].map((c,
|
|
2331
|
+
const o = [...s.data.values()].map((c, u) => a._parse(new $(s, c, s.path, u)));
|
|
2332
2332
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2333
2333
|
}
|
|
2334
|
-
min(e,
|
|
2334
|
+
min(e, t) {
|
|
2335
2335
|
return new X({
|
|
2336
2336
|
...this._def,
|
|
2337
|
-
minSize: { value: e, message: h.toString(
|
|
2337
|
+
minSize: { value: e, message: h.toString(t) }
|
|
2338
2338
|
});
|
|
2339
2339
|
}
|
|
2340
|
-
max(e,
|
|
2340
|
+
max(e, t) {
|
|
2341
2341
|
return new X({
|
|
2342
2342
|
...this._def,
|
|
2343
|
-
maxSize: { value: e, message: h.toString(
|
|
2343
|
+
maxSize: { value: e, message: h.toString(t) }
|
|
2344
2344
|
});
|
|
2345
2345
|
}
|
|
2346
|
-
size(e,
|
|
2347
|
-
return this.min(e,
|
|
2346
|
+
size(e, t) {
|
|
2347
|
+
return this.min(e, t).max(e, t);
|
|
2348
2348
|
}
|
|
2349
2349
|
nonempty(e) {
|
|
2350
2350
|
return this.min(1, e);
|
|
2351
2351
|
}
|
|
2352
2352
|
}
|
|
2353
|
-
X.create = (
|
|
2354
|
-
valueType:
|
|
2353
|
+
X.create = (n, e) => new X({
|
|
2354
|
+
valueType: n,
|
|
2355
2355
|
minSize: null,
|
|
2356
2356
|
maxSize: null,
|
|
2357
2357
|
typeName: y.ZodSet,
|
|
2358
2358
|
..._(e)
|
|
2359
2359
|
});
|
|
2360
|
-
class
|
|
2360
|
+
class re extends v {
|
|
2361
2361
|
constructor() {
|
|
2362
2362
|
super(...arguments), this.validate = this.implement;
|
|
2363
2363
|
}
|
|
2364
2364
|
_parse(e) {
|
|
2365
|
-
const { ctx:
|
|
2366
|
-
if (
|
|
2367
|
-
return l(
|
|
2368
|
-
code:
|
|
2365
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2366
|
+
if (t.parsedType !== f.function)
|
|
2367
|
+
return l(t, {
|
|
2368
|
+
code: d.invalid_type,
|
|
2369
2369
|
expected: f.function,
|
|
2370
|
-
received:
|
|
2370
|
+
received: t.parsedType
|
|
2371
2371
|
}), m;
|
|
2372
2372
|
function s(o, c) {
|
|
2373
|
-
return
|
|
2373
|
+
return Re({
|
|
2374
2374
|
data: o,
|
|
2375
|
-
path:
|
|
2376
|
-
errorMaps: [
|
|
2375
|
+
path: t.path,
|
|
2376
|
+
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, Ae(), ae].filter((u) => !!u),
|
|
2377
2377
|
issueData: {
|
|
2378
|
-
code:
|
|
2378
|
+
code: d.invalid_arguments,
|
|
2379
2379
|
argumentsError: c
|
|
2380
2380
|
}
|
|
2381
2381
|
});
|
|
2382
2382
|
}
|
|
2383
2383
|
function r(o, c) {
|
|
2384
|
-
return
|
|
2384
|
+
return Re({
|
|
2385
2385
|
data: o,
|
|
2386
|
-
path:
|
|
2387
|
-
errorMaps: [
|
|
2386
|
+
path: t.path,
|
|
2387
|
+
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, Ae(), ae].filter((u) => !!u),
|
|
2388
2388
|
issueData: {
|
|
2389
|
-
code:
|
|
2389
|
+
code: d.invalid_return_type,
|
|
2390
2390
|
returnTypeError: c
|
|
2391
2391
|
}
|
|
2392
2392
|
});
|
|
2393
2393
|
}
|
|
2394
|
-
const a = { errorMap:
|
|
2395
|
-
if (this._def.returns instanceof
|
|
2394
|
+
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2395
|
+
if (this._def.returns instanceof oe) {
|
|
2396
2396
|
const o = this;
|
|
2397
2397
|
return S(async function(...c) {
|
|
2398
|
-
const
|
|
2399
|
-
throw
|
|
2398
|
+
const u = new O([]), p = await o._def.args.parseAsync(c, a).catch((w) => {
|
|
2399
|
+
throw u.addIssue(s(c, w)), u;
|
|
2400
2400
|
}), b = await Reflect.apply(i, this, p);
|
|
2401
2401
|
return await o._def.returns._def.type.parseAsync(b, a).catch((w) => {
|
|
2402
|
-
throw
|
|
2402
|
+
throw u.addIssue(r(b, w)), u;
|
|
2403
2403
|
});
|
|
2404
2404
|
});
|
|
2405
2405
|
} else {
|
|
2406
2406
|
const o = this;
|
|
2407
2407
|
return S(function(...c) {
|
|
2408
|
-
const
|
|
2409
|
-
if (!
|
|
2410
|
-
throw new
|
|
2411
|
-
const p = Reflect.apply(i, this,
|
|
2408
|
+
const u = o._def.args.safeParse(c, a);
|
|
2409
|
+
if (!u.success)
|
|
2410
|
+
throw new O([s(c, u.error)]);
|
|
2411
|
+
const p = Reflect.apply(i, this, u.data), b = o._def.returns.safeParse(p, a);
|
|
2412
2412
|
if (!b.success)
|
|
2413
|
-
throw new
|
|
2413
|
+
throw new O([r(p, b.error)]);
|
|
2414
2414
|
return b.data;
|
|
2415
2415
|
});
|
|
2416
2416
|
}
|
|
@@ -2422,13 +2422,13 @@ class ae extends v {
|
|
|
2422
2422
|
return this._def.returns;
|
|
2423
2423
|
}
|
|
2424
2424
|
args(...e) {
|
|
2425
|
-
return new
|
|
2425
|
+
return new re({
|
|
2426
2426
|
...this._def,
|
|
2427
|
-
args: P.create(e).rest(
|
|
2427
|
+
args: P.create(e).rest(Y.create())
|
|
2428
2428
|
});
|
|
2429
2429
|
}
|
|
2430
2430
|
returns(e) {
|
|
2431
|
-
return new
|
|
2431
|
+
return new re({
|
|
2432
2432
|
...this._def,
|
|
2433
2433
|
returns: e
|
|
2434
2434
|
});
|
|
@@ -2439,10 +2439,10 @@ class ae extends v {
|
|
|
2439
2439
|
strictImplement(e) {
|
|
2440
2440
|
return this.parse(e);
|
|
2441
2441
|
}
|
|
2442
|
-
static create(e,
|
|
2443
|
-
return new
|
|
2444
|
-
args: e || P.create([]).rest(
|
|
2445
|
-
returns:
|
|
2442
|
+
static create(e, t, s) {
|
|
2443
|
+
return new re({
|
|
2444
|
+
args: e || P.create([]).rest(Y.create()),
|
|
2445
|
+
returns: t || Y.create(),
|
|
2446
2446
|
typeName: y.ZodFunction,
|
|
2447
2447
|
..._(s)
|
|
2448
2448
|
});
|
|
@@ -2453,22 +2453,22 @@ class ve extends v {
|
|
|
2453
2453
|
return this._def.getter();
|
|
2454
2454
|
}
|
|
2455
2455
|
_parse(e) {
|
|
2456
|
-
const { ctx:
|
|
2457
|
-
return this._def.getter()._parse({ data:
|
|
2456
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2457
|
+
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
-
ve.create = (
|
|
2461
|
-
getter:
|
|
2460
|
+
ve.create = (n, e) => new ve({
|
|
2461
|
+
getter: n,
|
|
2462
2462
|
typeName: y.ZodLazy,
|
|
2463
2463
|
..._(e)
|
|
2464
2464
|
});
|
|
2465
2465
|
class xe extends v {
|
|
2466
2466
|
_parse(e) {
|
|
2467
2467
|
if (e.data !== this._def.value) {
|
|
2468
|
-
const
|
|
2469
|
-
return l(
|
|
2470
|
-
received:
|
|
2471
|
-
code:
|
|
2468
|
+
const t = this._getOrReturnCtx(e);
|
|
2469
|
+
return l(t, {
|
|
2470
|
+
received: t.data,
|
|
2471
|
+
code: d.invalid_literal,
|
|
2472
2472
|
expected: this._def.value
|
|
2473
2473
|
}), m;
|
|
2474
2474
|
}
|
|
@@ -2478,14 +2478,14 @@ class xe extends v {
|
|
|
2478
2478
|
return this._def.value;
|
|
2479
2479
|
}
|
|
2480
2480
|
}
|
|
2481
|
-
xe.create = (
|
|
2482
|
-
value:
|
|
2481
|
+
xe.create = (n, e) => new xe({
|
|
2482
|
+
value: n,
|
|
2483
2483
|
typeName: y.ZodLiteral,
|
|
2484
2484
|
..._(e)
|
|
2485
2485
|
});
|
|
2486
|
-
function it(
|
|
2486
|
+
function it(n, e) {
|
|
2487
2487
|
return new q({
|
|
2488
|
-
values:
|
|
2488
|
+
values: n,
|
|
2489
2489
|
typeName: y.ZodEnum,
|
|
2490
2490
|
..._(e)
|
|
2491
2491
|
});
|
|
@@ -2493,18 +2493,18 @@ function it(t, e) {
|
|
|
2493
2493
|
class q extends v {
|
|
2494
2494
|
_parse(e) {
|
|
2495
2495
|
if (typeof e.data != "string") {
|
|
2496
|
-
const
|
|
2497
|
-
return l(
|
|
2496
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2497
|
+
return l(t, {
|
|
2498
2498
|
expected: x.joinValues(s),
|
|
2499
|
-
received:
|
|
2500
|
-
code:
|
|
2499
|
+
received: t.parsedType,
|
|
2500
|
+
code: d.invalid_type
|
|
2501
2501
|
}), m;
|
|
2502
2502
|
}
|
|
2503
2503
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2504
|
-
const
|
|
2505
|
-
return l(
|
|
2506
|
-
received:
|
|
2507
|
-
code:
|
|
2504
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2505
|
+
return l(t, {
|
|
2506
|
+
received: t.data,
|
|
2507
|
+
code: d.invalid_enum_value,
|
|
2508
2508
|
options: s
|
|
2509
2509
|
}), m;
|
|
2510
2510
|
}
|
|
@@ -2515,52 +2515,52 @@ class q extends v {
|
|
|
2515
2515
|
}
|
|
2516
2516
|
get enum() {
|
|
2517
2517
|
const e = {};
|
|
2518
|
-
for (const
|
|
2519
|
-
e[
|
|
2518
|
+
for (const t of this._def.values)
|
|
2519
|
+
e[t] = t;
|
|
2520
2520
|
return e;
|
|
2521
2521
|
}
|
|
2522
2522
|
get Values() {
|
|
2523
2523
|
const e = {};
|
|
2524
|
-
for (const
|
|
2525
|
-
e[
|
|
2524
|
+
for (const t of this._def.values)
|
|
2525
|
+
e[t] = t;
|
|
2526
2526
|
return e;
|
|
2527
2527
|
}
|
|
2528
2528
|
get Enum() {
|
|
2529
2529
|
const e = {};
|
|
2530
|
-
for (const
|
|
2531
|
-
e[
|
|
2530
|
+
for (const t of this._def.values)
|
|
2531
|
+
e[t] = t;
|
|
2532
2532
|
return e;
|
|
2533
2533
|
}
|
|
2534
|
-
extract(e,
|
|
2534
|
+
extract(e, t = this._def) {
|
|
2535
2535
|
return q.create(e, {
|
|
2536
2536
|
...this._def,
|
|
2537
|
-
...
|
|
2537
|
+
...t
|
|
2538
2538
|
});
|
|
2539
2539
|
}
|
|
2540
|
-
exclude(e,
|
|
2540
|
+
exclude(e, t = this._def) {
|
|
2541
2541
|
return q.create(this.options.filter((s) => !e.includes(s)), {
|
|
2542
2542
|
...this._def,
|
|
2543
|
-
...
|
|
2543
|
+
...t
|
|
2544
2544
|
});
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
2547
2547
|
q.create = it;
|
|
2548
2548
|
class be extends v {
|
|
2549
2549
|
_parse(e) {
|
|
2550
|
-
const
|
|
2550
|
+
const t = x.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2551
2551
|
if (s.parsedType !== f.string && s.parsedType !== f.number) {
|
|
2552
|
-
const r = x.objectValues(
|
|
2552
|
+
const r = x.objectValues(t);
|
|
2553
2553
|
return l(s, {
|
|
2554
2554
|
expected: x.joinValues(r),
|
|
2555
2555
|
received: s.parsedType,
|
|
2556
|
-
code:
|
|
2556
|
+
code: d.invalid_type
|
|
2557
2557
|
}), m;
|
|
2558
2558
|
}
|
|
2559
2559
|
if (this._cache || (this._cache = new Set(x.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2560
|
-
const r = x.objectValues(
|
|
2560
|
+
const r = x.objectValues(t);
|
|
2561
2561
|
return l(s, {
|
|
2562
2562
|
received: s.data,
|
|
2563
|
-
code:
|
|
2563
|
+
code: d.invalid_enum_value,
|
|
2564
2564
|
options: r
|
|
2565
2565
|
}), m;
|
|
2566
2566
|
}
|
|
@@ -2570,36 +2570,36 @@ class be extends v {
|
|
|
2570
2570
|
return this._def.values;
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
2573
|
-
be.create = (
|
|
2574
|
-
values:
|
|
2573
|
+
be.create = (n, e) => new be({
|
|
2574
|
+
values: n,
|
|
2575
2575
|
typeName: y.ZodNativeEnum,
|
|
2576
2576
|
..._(e)
|
|
2577
2577
|
});
|
|
2578
|
-
class
|
|
2578
|
+
class oe extends v {
|
|
2579
2579
|
unwrap() {
|
|
2580
2580
|
return this._def.type;
|
|
2581
2581
|
}
|
|
2582
2582
|
_parse(e) {
|
|
2583
|
-
const { ctx:
|
|
2584
|
-
if (
|
|
2585
|
-
return l(
|
|
2586
|
-
code:
|
|
2583
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2584
|
+
if (t.parsedType !== f.promise && t.common.async === !1)
|
|
2585
|
+
return l(t, {
|
|
2586
|
+
code: d.invalid_type,
|
|
2587
2587
|
expected: f.promise,
|
|
2588
|
-
received:
|
|
2588
|
+
received: t.parsedType
|
|
2589
2589
|
}), m;
|
|
2590
|
-
const s =
|
|
2590
|
+
const s = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2591
2591
|
return S(s.then((r) => this._def.type.parseAsync(r, {
|
|
2592
|
-
path:
|
|
2593
|
-
errorMap:
|
|
2592
|
+
path: t.path,
|
|
2593
|
+
errorMap: t.common.contextualErrorMap
|
|
2594
2594
|
})));
|
|
2595
2595
|
}
|
|
2596
2596
|
}
|
|
2597
|
-
|
|
2598
|
-
type:
|
|
2597
|
+
oe.create = (n, e) => new oe({
|
|
2598
|
+
type: n,
|
|
2599
2599
|
typeName: y.ZodPromise,
|
|
2600
2600
|
..._(e)
|
|
2601
2601
|
});
|
|
2602
|
-
class
|
|
2602
|
+
class N extends v {
|
|
2603
2603
|
innerType() {
|
|
2604
2604
|
return this._def.schema;
|
|
2605
2605
|
}
|
|
@@ -2607,9 +2607,9 @@ class R extends v {
|
|
|
2607
2607
|
return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2608
2608
|
}
|
|
2609
2609
|
_parse(e) {
|
|
2610
|
-
const { status:
|
|
2610
|
+
const { status: t, ctx: s } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2611
2611
|
addIssue: (i) => {
|
|
2612
|
-
l(s, i), i.fatal ?
|
|
2612
|
+
l(s, i), i.fatal ? t.abort() : t.dirty();
|
|
2613
2613
|
},
|
|
2614
2614
|
get path() {
|
|
2615
2615
|
return s.path;
|
|
@@ -2619,24 +2619,24 @@ class R extends v {
|
|
|
2619
2619
|
const i = r.transform(s.data, a);
|
|
2620
2620
|
if (s.common.async)
|
|
2621
2621
|
return Promise.resolve(i).then(async (o) => {
|
|
2622
|
-
if (
|
|
2622
|
+
if (t.value === "aborted")
|
|
2623
2623
|
return m;
|
|
2624
2624
|
const c = await this._def.schema._parseAsync({
|
|
2625
2625
|
data: o,
|
|
2626
2626
|
path: s.path,
|
|
2627
2627
|
parent: s
|
|
2628
2628
|
});
|
|
2629
|
-
return c.status === "aborted" ? m : c.status === "dirty" ||
|
|
2629
|
+
return c.status === "aborted" ? m : c.status === "dirty" || t.value === "dirty" ? se(c.value) : c;
|
|
2630
2630
|
});
|
|
2631
2631
|
{
|
|
2632
|
-
if (
|
|
2632
|
+
if (t.value === "aborted")
|
|
2633
2633
|
return m;
|
|
2634
2634
|
const o = this._def.schema._parseSync({
|
|
2635
2635
|
data: i,
|
|
2636
2636
|
path: s.path,
|
|
2637
2637
|
parent: s
|
|
2638
2638
|
});
|
|
2639
|
-
return o.status === "aborted" ? m : o.status === "dirty" ||
|
|
2639
|
+
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ? se(o.value) : o;
|
|
2640
2640
|
}
|
|
2641
2641
|
}
|
|
2642
2642
|
if (r.type === "refinement") {
|
|
@@ -2654,9 +2654,9 @@ class R extends v {
|
|
|
2654
2654
|
path: s.path,
|
|
2655
2655
|
parent: s
|
|
2656
2656
|
});
|
|
2657
|
-
return o.status === "aborted" ? m : (o.status === "dirty" &&
|
|
2657
|
+
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2658
2658
|
} else
|
|
2659
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" &&
|
|
2659
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2660
2660
|
}
|
|
2661
2661
|
if (r.type === "transform")
|
|
2662
2662
|
if (s.common.async === !1) {
|
|
@@ -2665,33 +2665,33 @@ class R extends v {
|
|
|
2665
2665
|
path: s.path,
|
|
2666
2666
|
parent: s
|
|
2667
2667
|
});
|
|
2668
|
-
if (!
|
|
2668
|
+
if (!G(i))
|
|
2669
2669
|
return m;
|
|
2670
2670
|
const o = r.transform(i.value, a);
|
|
2671
2671
|
if (o instanceof Promise)
|
|
2672
2672
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2673
|
-
return { status:
|
|
2673
|
+
return { status: t.value, value: o };
|
|
2674
2674
|
} else
|
|
2675
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) =>
|
|
2676
|
-
status:
|
|
2675
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => G(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2676
|
+
status: t.value,
|
|
2677
2677
|
value: o
|
|
2678
2678
|
})) : m);
|
|
2679
2679
|
x.assertNever(r);
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
|
|
2683
|
-
schema:
|
|
2682
|
+
N.create = (n, e, t) => new N({
|
|
2683
|
+
schema: n,
|
|
2684
2684
|
typeName: y.ZodEffects,
|
|
2685
2685
|
effect: e,
|
|
2686
|
-
..._(
|
|
2686
|
+
..._(t)
|
|
2687
2687
|
});
|
|
2688
|
-
|
|
2688
|
+
N.createWithPreprocess = (n, e, t) => new N({
|
|
2689
2689
|
schema: e,
|
|
2690
|
-
effect: { type: "preprocess", transform:
|
|
2690
|
+
effect: { type: "preprocess", transform: n },
|
|
2691
2691
|
typeName: y.ZodEffects,
|
|
2692
|
-
..._(
|
|
2692
|
+
..._(t)
|
|
2693
2693
|
});
|
|
2694
|
-
class
|
|
2694
|
+
class I extends v {
|
|
2695
2695
|
_parse(e) {
|
|
2696
2696
|
return this._getType(e) === f.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
2697
2697
|
}
|
|
@@ -2699,12 +2699,12 @@ class Z extends v {
|
|
|
2699
2699
|
return this._def.innerType;
|
|
2700
2700
|
}
|
|
2701
2701
|
}
|
|
2702
|
-
|
|
2703
|
-
innerType:
|
|
2702
|
+
I.create = (n, e) => new I({
|
|
2703
|
+
innerType: n,
|
|
2704
2704
|
typeName: y.ZodOptional,
|
|
2705
2705
|
..._(e)
|
|
2706
2706
|
});
|
|
2707
|
-
class
|
|
2707
|
+
class W extends v {
|
|
2708
2708
|
_parse(e) {
|
|
2709
2709
|
return this._getType(e) === f.null ? S(null) : this._def.innerType._parse(e);
|
|
2710
2710
|
}
|
|
@@ -2712,37 +2712,37 @@ class H extends v {
|
|
|
2712
2712
|
return this._def.innerType;
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
|
-
|
|
2716
|
-
innerType:
|
|
2715
|
+
W.create = (n, e) => new W({
|
|
2716
|
+
innerType: n,
|
|
2717
2717
|
typeName: y.ZodNullable,
|
|
2718
2718
|
..._(e)
|
|
2719
2719
|
});
|
|
2720
2720
|
class ke extends v {
|
|
2721
2721
|
_parse(e) {
|
|
2722
|
-
const { ctx:
|
|
2723
|
-
let s =
|
|
2724
|
-
return
|
|
2722
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2723
|
+
let s = t.data;
|
|
2724
|
+
return t.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2725
2725
|
data: s,
|
|
2726
|
-
path:
|
|
2727
|
-
parent:
|
|
2726
|
+
path: t.path,
|
|
2727
|
+
parent: t
|
|
2728
2728
|
});
|
|
2729
2729
|
}
|
|
2730
2730
|
removeDefault() {
|
|
2731
2731
|
return this._def.innerType;
|
|
2732
2732
|
}
|
|
2733
2733
|
}
|
|
2734
|
-
ke.create = (
|
|
2735
|
-
innerType:
|
|
2734
|
+
ke.create = (n, e) => new ke({
|
|
2735
|
+
innerType: n,
|
|
2736
2736
|
typeName: y.ZodDefault,
|
|
2737
2737
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2738
2738
|
..._(e)
|
|
2739
2739
|
});
|
|
2740
2740
|
class we extends v {
|
|
2741
2741
|
_parse(e) {
|
|
2742
|
-
const { ctx:
|
|
2743
|
-
...
|
|
2742
|
+
const { ctx: t } = this._processInputParams(e), s = {
|
|
2743
|
+
...t,
|
|
2744
2744
|
common: {
|
|
2745
|
-
...
|
|
2745
|
+
...t.common,
|
|
2746
2746
|
issues: []
|
|
2747
2747
|
}
|
|
2748
2748
|
}, r = this._def.innerType._parse({
|
|
@@ -2756,7 +2756,7 @@ class we extends v {
|
|
|
2756
2756
|
status: "valid",
|
|
2757
2757
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2758
2758
|
get error() {
|
|
2759
|
-
return new
|
|
2759
|
+
return new O(s.common.issues);
|
|
2760
2760
|
},
|
|
2761
2761
|
input: s.data
|
|
2762
2762
|
})
|
|
@@ -2764,7 +2764,7 @@ class we extends v {
|
|
|
2764
2764
|
status: "valid",
|
|
2765
2765
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2766
2766
|
get error() {
|
|
2767
|
-
return new
|
|
2767
|
+
return new O(s.common.issues);
|
|
2768
2768
|
},
|
|
2769
2769
|
input: s.data
|
|
2770
2770
|
})
|
|
@@ -2774,18 +2774,18 @@ class we extends v {
|
|
|
2774
2774
|
return this._def.innerType;
|
|
2775
2775
|
}
|
|
2776
2776
|
}
|
|
2777
|
-
we.create = (
|
|
2778
|
-
innerType:
|
|
2777
|
+
we.create = (n, e) => new we({
|
|
2778
|
+
innerType: n,
|
|
2779
2779
|
typeName: y.ZodCatch,
|
|
2780
2780
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2781
2781
|
..._(e)
|
|
2782
2782
|
});
|
|
2783
|
-
class
|
|
2783
|
+
class Ze extends v {
|
|
2784
2784
|
_parse(e) {
|
|
2785
2785
|
if (this._getType(e) !== f.nan) {
|
|
2786
2786
|
const s = this._getOrReturnCtx(e);
|
|
2787
2787
|
return l(s, {
|
|
2788
|
-
code:
|
|
2788
|
+
code: d.invalid_type,
|
|
2789
2789
|
expected: f.nan,
|
|
2790
2790
|
received: s.parsedType
|
|
2791
2791
|
}), m;
|
|
@@ -2793,18 +2793,18 @@ class Ie extends v {
|
|
|
2793
2793
|
return { status: "valid", value: e.data };
|
|
2794
2794
|
}
|
|
2795
2795
|
}
|
|
2796
|
-
|
|
2796
|
+
Ze.create = (n) => new Ze({
|
|
2797
2797
|
typeName: y.ZodNaN,
|
|
2798
|
-
..._(
|
|
2798
|
+
..._(n)
|
|
2799
2799
|
});
|
|
2800
2800
|
const Vt = Symbol("zod_brand");
|
|
2801
|
-
class
|
|
2801
|
+
class Ye extends v {
|
|
2802
2802
|
_parse(e) {
|
|
2803
|
-
const { ctx:
|
|
2803
|
+
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
2804
2804
|
return this._def.type._parse({
|
|
2805
2805
|
data: s,
|
|
2806
|
-
path:
|
|
2807
|
-
parent:
|
|
2806
|
+
path: t.path,
|
|
2807
|
+
parent: t
|
|
2808
2808
|
});
|
|
2809
2809
|
}
|
|
2810
2810
|
unwrap() {
|
|
@@ -2813,7 +2813,7 @@ class Ke extends v {
|
|
|
2813
2813
|
}
|
|
2814
2814
|
class Se extends v {
|
|
2815
2815
|
_parse(e) {
|
|
2816
|
-
const { status:
|
|
2816
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2817
2817
|
if (s.common.async)
|
|
2818
2818
|
return (async () => {
|
|
2819
2819
|
const a = await this._def.in._parseAsync({
|
|
@@ -2821,7 +2821,7 @@ class Se extends v {
|
|
|
2821
2821
|
path: s.path,
|
|
2822
2822
|
parent: s
|
|
2823
2823
|
});
|
|
2824
|
-
return a.status === "aborted" ? m : a.status === "dirty" ? (
|
|
2824
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), se(a.value)) : this._def.out._parseAsync({
|
|
2825
2825
|
data: a.value,
|
|
2826
2826
|
path: s.path,
|
|
2827
2827
|
parent: s
|
|
@@ -2833,7 +2833,7 @@ class Se extends v {
|
|
|
2833
2833
|
path: s.path,
|
|
2834
2834
|
parent: s
|
|
2835
2835
|
});
|
|
2836
|
-
return r.status === "aborted" ? m : r.status === "dirty" ? (
|
|
2836
|
+
return r.status === "aborted" ? m : r.status === "dirty" ? (t.dirty(), {
|
|
2837
2837
|
status: "dirty",
|
|
2838
2838
|
value: r.value
|
|
2839
2839
|
}) : this._def.out._parseSync({
|
|
@@ -2843,155 +2843,155 @@ class Se extends v {
|
|
|
2843
2843
|
});
|
|
2844
2844
|
}
|
|
2845
2845
|
}
|
|
2846
|
-
static create(e,
|
|
2846
|
+
static create(e, t) {
|
|
2847
2847
|
return new Se({
|
|
2848
2848
|
in: e,
|
|
2849
|
-
out:
|
|
2849
|
+
out: t,
|
|
2850
2850
|
typeName: y.ZodPipeline
|
|
2851
2851
|
});
|
|
2852
2852
|
}
|
|
2853
2853
|
}
|
|
2854
2854
|
class Te extends v {
|
|
2855
2855
|
_parse(e) {
|
|
2856
|
-
const
|
|
2857
|
-
return fe(
|
|
2856
|
+
const t = this._def.innerType._parse(e), s = (r) => (G(r) && (r.value = Object.freeze(r.value)), r);
|
|
2857
|
+
return fe(t) ? t.then((r) => s(r)) : s(t);
|
|
2858
2858
|
}
|
|
2859
2859
|
unwrap() {
|
|
2860
2860
|
return this._def.innerType;
|
|
2861
2861
|
}
|
|
2862
2862
|
}
|
|
2863
|
-
Te.create = (
|
|
2864
|
-
innerType:
|
|
2863
|
+
Te.create = (n, e) => new Te({
|
|
2864
|
+
innerType: n,
|
|
2865
2865
|
typeName: y.ZodReadonly,
|
|
2866
2866
|
..._(e)
|
|
2867
2867
|
});
|
|
2868
|
-
function Xe(
|
|
2869
|
-
const
|
|
2870
|
-
return typeof
|
|
2868
|
+
function Xe(n, e) {
|
|
2869
|
+
const t = typeof n == "function" ? n(e) : typeof n == "string" ? { message: n } : n;
|
|
2870
|
+
return typeof t == "string" ? { message: t } : t;
|
|
2871
2871
|
}
|
|
2872
|
-
function ot(
|
|
2873
|
-
return
|
|
2874
|
-
const a =
|
|
2872
|
+
function ot(n, e = {}, t) {
|
|
2873
|
+
return n ? ie.create().superRefine((s, r) => {
|
|
2874
|
+
const a = n(s);
|
|
2875
2875
|
if (a instanceof Promise)
|
|
2876
2876
|
return a.then((i) => {
|
|
2877
2877
|
if (!i) {
|
|
2878
|
-
const o = Xe(e, s), c = o.fatal ??
|
|
2878
|
+
const o = Xe(e, s), c = o.fatal ?? t ?? !0;
|
|
2879
2879
|
r.addIssue({ code: "custom", ...o, fatal: c });
|
|
2880
2880
|
}
|
|
2881
2881
|
});
|
|
2882
2882
|
if (!a) {
|
|
2883
|
-
const i = Xe(e, s), o = i.fatal ??
|
|
2883
|
+
const i = Xe(e, s), o = i.fatal ?? t ?? !0;
|
|
2884
2884
|
r.addIssue({ code: "custom", ...i, fatal: o });
|
|
2885
2885
|
}
|
|
2886
|
-
}) :
|
|
2886
|
+
}) : ie.create();
|
|
2887
2887
|
}
|
|
2888
|
-
const
|
|
2888
|
+
const zt = {
|
|
2889
2889
|
object: k.lazycreate
|
|
2890
2890
|
};
|
|
2891
2891
|
var y;
|
|
2892
|
-
(function(
|
|
2893
|
-
|
|
2892
|
+
(function(n) {
|
|
2893
|
+
n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
|
|
2894
2894
|
})(y || (y = {}));
|
|
2895
|
-
const
|
|
2896
|
-
message: `Input not instance of ${
|
|
2897
|
-
}) => ot((
|
|
2898
|
-
string: ((
|
|
2899
|
-
number: ((
|
|
2900
|
-
boolean: ((
|
|
2901
|
-
...
|
|
2895
|
+
const Bt = (n, e = {
|
|
2896
|
+
message: `Input not instance of ${n.name}`
|
|
2897
|
+
}) => ot((t) => t instanceof n, e), g = R.create, Ge = U.create, Ut = Ze.create, Ft = F.create, Ce = he.create, qt = K.create, Wt = Ee.create, Jt = pe.create, Qt = me.create, Ht = ie.create, Yt = Y.create, Gt = z.create, Kt = Ne.create, A = E.create, j = k.create, Xt = k.strictCreate, en = ye.create, tn = Pe.create, nn = _e.create, sn = P.create, ct = ge.create, rn = je.create, an = X.create, on = re.create, cn = ve.create, dn = xe.create, un = q.create, ln = be.create, fn = oe.create, et = N.create, hn = I.create, pn = W.create, mn = N.createWithPreprocess, yn = Se.create, _n = () => g().optional(), gn = () => Ge().optional(), vn = () => Ce().optional(), xn = {
|
|
2898
|
+
string: ((n) => R.create({ ...n, coerce: !0 })),
|
|
2899
|
+
number: ((n) => U.create({ ...n, coerce: !0 })),
|
|
2900
|
+
boolean: ((n) => he.create({
|
|
2901
|
+
...n,
|
|
2902
2902
|
coerce: !0
|
|
2903
2903
|
})),
|
|
2904
|
-
bigint: ((
|
|
2905
|
-
date: ((
|
|
2904
|
+
bigint: ((n) => F.create({ ...n, coerce: !0 })),
|
|
2905
|
+
date: ((n) => K.create({ ...n, coerce: !0 }))
|
|
2906
2906
|
}, bn = m, kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2907
2907
|
__proto__: null,
|
|
2908
2908
|
BRAND: Vt,
|
|
2909
|
-
DIRTY:
|
|
2909
|
+
DIRTY: se,
|
|
2910
2910
|
EMPTY_PATH: gt,
|
|
2911
2911
|
INVALID: m,
|
|
2912
2912
|
NEVER: bn,
|
|
2913
2913
|
OK: S,
|
|
2914
2914
|
ParseStatus: T,
|
|
2915
2915
|
Schema: v,
|
|
2916
|
-
ZodAny:
|
|
2917
|
-
ZodArray:
|
|
2916
|
+
ZodAny: ie,
|
|
2917
|
+
ZodArray: E,
|
|
2918
2918
|
ZodBigInt: F,
|
|
2919
2919
|
ZodBoolean: he,
|
|
2920
|
-
ZodBranded:
|
|
2920
|
+
ZodBranded: Ye,
|
|
2921
2921
|
ZodCatch: we,
|
|
2922
|
-
ZodDate:
|
|
2922
|
+
ZodDate: K,
|
|
2923
2923
|
ZodDefault: ke,
|
|
2924
|
-
ZodDiscriminatedUnion:
|
|
2925
|
-
ZodEffects:
|
|
2924
|
+
ZodDiscriminatedUnion: Pe,
|
|
2925
|
+
ZodEffects: N,
|
|
2926
2926
|
ZodEnum: q,
|
|
2927
|
-
ZodError:
|
|
2927
|
+
ZodError: O,
|
|
2928
2928
|
get ZodFirstPartyTypeKind() {
|
|
2929
2929
|
return y;
|
|
2930
2930
|
},
|
|
2931
|
-
ZodFunction:
|
|
2931
|
+
ZodFunction: re,
|
|
2932
2932
|
ZodIntersection: _e,
|
|
2933
|
-
ZodIssueCode:
|
|
2933
|
+
ZodIssueCode: d,
|
|
2934
2934
|
ZodLazy: ve,
|
|
2935
2935
|
ZodLiteral: xe,
|
|
2936
|
-
ZodMap:
|
|
2937
|
-
ZodNaN:
|
|
2936
|
+
ZodMap: je,
|
|
2937
|
+
ZodNaN: Ze,
|
|
2938
2938
|
ZodNativeEnum: be,
|
|
2939
|
-
ZodNever:
|
|
2939
|
+
ZodNever: z,
|
|
2940
2940
|
ZodNull: me,
|
|
2941
|
-
ZodNullable:
|
|
2942
|
-
ZodNumber:
|
|
2941
|
+
ZodNullable: W,
|
|
2942
|
+
ZodNumber: U,
|
|
2943
2943
|
ZodObject: k,
|
|
2944
|
-
ZodOptional:
|
|
2944
|
+
ZodOptional: I,
|
|
2945
2945
|
ZodParsedType: f,
|
|
2946
2946
|
ZodPipeline: Se,
|
|
2947
|
-
ZodPromise:
|
|
2947
|
+
ZodPromise: oe,
|
|
2948
2948
|
ZodReadonly: Te,
|
|
2949
2949
|
ZodRecord: ge,
|
|
2950
2950
|
ZodSchema: v,
|
|
2951
2951
|
ZodSet: X,
|
|
2952
|
-
ZodString:
|
|
2952
|
+
ZodString: R,
|
|
2953
2953
|
ZodSymbol: Ee,
|
|
2954
|
-
ZodTransformer:
|
|
2954
|
+
ZodTransformer: N,
|
|
2955
2955
|
ZodTuple: P,
|
|
2956
2956
|
ZodType: v,
|
|
2957
2957
|
ZodUndefined: pe,
|
|
2958
2958
|
ZodUnion: ye,
|
|
2959
|
-
ZodUnknown:
|
|
2959
|
+
ZodUnknown: Y,
|
|
2960
2960
|
ZodVoid: Ne,
|
|
2961
2961
|
addIssueToContext: l,
|
|
2962
|
-
any:
|
|
2963
|
-
array:
|
|
2962
|
+
any: Ht,
|
|
2963
|
+
array: A,
|
|
2964
2964
|
bigint: Ft,
|
|
2965
2965
|
boolean: Ce,
|
|
2966
2966
|
coerce: xn,
|
|
2967
2967
|
custom: ot,
|
|
2968
2968
|
date: qt,
|
|
2969
2969
|
datetimeRegex: at,
|
|
2970
|
-
defaultErrorMap:
|
|
2970
|
+
defaultErrorMap: ae,
|
|
2971
2971
|
discriminatedUnion: tn,
|
|
2972
2972
|
effect: et,
|
|
2973
2973
|
enum: un,
|
|
2974
2974
|
function: on,
|
|
2975
2975
|
getErrorMap: Ae,
|
|
2976
2976
|
getParsedType: V,
|
|
2977
|
-
instanceof:
|
|
2977
|
+
instanceof: Bt,
|
|
2978
2978
|
intersection: nn,
|
|
2979
|
-
isAborted:
|
|
2979
|
+
isAborted: We,
|
|
2980
2980
|
isAsync: fe,
|
|
2981
|
-
isDirty:
|
|
2982
|
-
isValid:
|
|
2983
|
-
late:
|
|
2981
|
+
isDirty: Je,
|
|
2982
|
+
isValid: G,
|
|
2983
|
+
late: zt,
|
|
2984
2984
|
lazy: cn,
|
|
2985
2985
|
literal: dn,
|
|
2986
|
-
makeIssue:
|
|
2986
|
+
makeIssue: Re,
|
|
2987
2987
|
map: rn,
|
|
2988
|
-
nan:
|
|
2988
|
+
nan: Ut,
|
|
2989
2989
|
nativeEnum: ln,
|
|
2990
|
-
never:
|
|
2991
|
-
null:
|
|
2990
|
+
never: Gt,
|
|
2991
|
+
null: Qt,
|
|
2992
2992
|
nullable: pn,
|
|
2993
|
-
number:
|
|
2994
|
-
object:
|
|
2993
|
+
number: Ge,
|
|
2994
|
+
object: j,
|
|
2995
2995
|
get objectUtil() {
|
|
2996
2996
|
return qe;
|
|
2997
2997
|
},
|
|
@@ -3008,84 +3008,84 @@ const zt = (t, e = {
|
|
|
3008
3008
|
setErrorMap: _t,
|
|
3009
3009
|
strictObject: Xt,
|
|
3010
3010
|
string: g,
|
|
3011
|
-
symbol:
|
|
3011
|
+
symbol: Wt,
|
|
3012
3012
|
transformer: et,
|
|
3013
3013
|
tuple: sn,
|
|
3014
|
-
undefined:
|
|
3014
|
+
undefined: Jt,
|
|
3015
3015
|
union: en,
|
|
3016
|
-
unknown:
|
|
3016
|
+
unknown: Yt,
|
|
3017
3017
|
get util() {
|
|
3018
3018
|
return x;
|
|
3019
3019
|
},
|
|
3020
|
-
void:
|
|
3020
|
+
void: Kt
|
|
3021
3021
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3022
3022
|
mt(kn);
|
|
3023
|
-
const wn = (
|
|
3023
|
+
const wn = (n, e) => e.skipDedupe || e.method !== "GET", Tn = (n, e) => e.method + "@" + n, Sn = (n) => n.clone(), Cn = ({ skip: n = wn, key: e = Tn, resolver: t = Sn } = {}) => {
|
|
3024
3024
|
const s = /* @__PURE__ */ new Map();
|
|
3025
3025
|
return (r) => (a, i) => {
|
|
3026
|
-
if (
|
|
3026
|
+
if (n(a, i))
|
|
3027
3027
|
return r(a, i);
|
|
3028
3028
|
const o = e(a, i);
|
|
3029
3029
|
if (!s.has(o))
|
|
3030
3030
|
s.set(o, []);
|
|
3031
3031
|
else
|
|
3032
|
-
return new Promise((c,
|
|
3033
|
-
s.get(o).push([c,
|
|
3032
|
+
return new Promise((c, u) => {
|
|
3033
|
+
s.get(o).push([c, u]);
|
|
3034
3034
|
});
|
|
3035
3035
|
try {
|
|
3036
|
-
return r(a, i).then((c) => (s.get(o).forEach(([
|
|
3037
|
-
throw s.get(o).forEach(([,
|
|
3036
|
+
return r(a, i).then((c) => (s.get(o).forEach(([u]) => u(t(c))), s.delete(o), c)).catch((c) => {
|
|
3037
|
+
throw s.get(o).forEach(([, u]) => u(c)), s.delete(o), c;
|
|
3038
3038
|
});
|
|
3039
3039
|
} catch (c) {
|
|
3040
3040
|
return s.delete(o), Promise.reject(c);
|
|
3041
3041
|
}
|
|
3042
3042
|
};
|
|
3043
|
-
},
|
|
3043
|
+
}, On = (n, e) => n * e, An = (n) => n && (n.ok || n.status >= 400 && n.status < 500), Rn = ({ delayTimer: n = 500, delayRamp: e = On, maxAttempts: t = 10, until: s = An, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (u, p) => {
|
|
3044
3044
|
let b = 0;
|
|
3045
|
-
if (o && o(
|
|
3046
|
-
return c(
|
|
3047
|
-
const C = (w,
|
|
3048
|
-
const
|
|
3045
|
+
if (o && o(u, p))
|
|
3046
|
+
return c(u, p);
|
|
3047
|
+
const C = (w, Z) => Promise.resolve(s(w, Z)).then((ce) => ce ? w && i ? w : Z ? Promise.reject(Z) : w : (b++, !t || b <= t ? new Promise((M) => {
|
|
3048
|
+
const J = e(n, b);
|
|
3049
3049
|
setTimeout(() => {
|
|
3050
3050
|
typeof r == "function" ? Promise.resolve(r({
|
|
3051
3051
|
response: w,
|
|
3052
|
-
error:
|
|
3053
|
-
url:
|
|
3052
|
+
error: Z,
|
|
3053
|
+
url: u,
|
|
3054
3054
|
attempt: b,
|
|
3055
3055
|
options: p
|
|
3056
3056
|
})).then((D = {}) => {
|
|
3057
|
-
var ee,
|
|
3058
|
-
M(c((ee = D && D.url) !== null && ee !== void 0 ? ee :
|
|
3059
|
-
}) : M(c(
|
|
3060
|
-
},
|
|
3057
|
+
var ee, Q;
|
|
3058
|
+
M(c((ee = D && D.url) !== null && ee !== void 0 ? ee : u, (Q = D && D.options) !== null && Q !== void 0 ? Q : p));
|
|
3059
|
+
}) : M(c(u, p));
|
|
3060
|
+
}, J);
|
|
3061
3061
|
}).then(C).catch((M) => {
|
|
3062
3062
|
if (!a)
|
|
3063
3063
|
throw M;
|
|
3064
3064
|
return C(null, M);
|
|
3065
|
-
}) : w && i ? w : Promise.reject(
|
|
3066
|
-
return c(
|
|
3065
|
+
}) : w && i ? w : Promise.reject(Z || new Error("Number of attempts exceeded."))));
|
|
3066
|
+
return c(u, p).then(C).catch((w) => {
|
|
3067
3067
|
if (!a)
|
|
3068
3068
|
throw w;
|
|
3069
3069
|
return C(null, w);
|
|
3070
3070
|
});
|
|
3071
|
-
},
|
|
3072
|
-
code:
|
|
3071
|
+
}, Ie = j({
|
|
3072
|
+
code: Ge(),
|
|
3073
3073
|
message: g()
|
|
3074
|
-
}),
|
|
3074
|
+
}), En = j({
|
|
3075
3075
|
message: g()
|
|
3076
|
-
}),
|
|
3077
|
-
emails:
|
|
3076
|
+
}), Nn = j({
|
|
3077
|
+
emails: A(g()).optional(),
|
|
3078
3078
|
http_body: g().optional(),
|
|
3079
3079
|
http_url: g().optional(),
|
|
3080
3080
|
txt_name: g().optional(),
|
|
3081
3081
|
txt_value: g().optional()
|
|
3082
|
-
}),
|
|
3083
|
-
ciphers:
|
|
3082
|
+
}), jn = j({
|
|
3083
|
+
ciphers: A(g()).optional(),
|
|
3084
3084
|
early_hints: g().optional(),
|
|
3085
3085
|
http2: g().optional(),
|
|
3086
3086
|
min_tls_version: g().optional(),
|
|
3087
3087
|
tls_1_3: g().optional()
|
|
3088
|
-
}),
|
|
3088
|
+
}), Zn = j({
|
|
3089
3089
|
id: g(),
|
|
3090
3090
|
bundle_method: g().optional(),
|
|
3091
3091
|
certificate_authority: g(),
|
|
@@ -3093,90 +3093,91 @@ const wn = (t, e) => e.skipDedupe || e.method !== "GET", Tn = (t, e) => e.method
|
|
|
3093
3093
|
custom_csr_id: g().optional(),
|
|
3094
3094
|
custom_key: g().optional(),
|
|
3095
3095
|
expires_on: g().optional(),
|
|
3096
|
-
hosts:
|
|
3096
|
+
hosts: A(g()).optional(),
|
|
3097
3097
|
issuer: g().optional(),
|
|
3098
3098
|
method: g(),
|
|
3099
3099
|
serial_number: g().optional(),
|
|
3100
|
-
settings:
|
|
3100
|
+
settings: jn.optional(),
|
|
3101
3101
|
signature: g().optional(),
|
|
3102
3102
|
type: g(),
|
|
3103
3103
|
uploaded_on: g().optional(),
|
|
3104
|
-
validation_errors:
|
|
3105
|
-
validation_records:
|
|
3104
|
+
validation_errors: A(En).optional(),
|
|
3105
|
+
validation_records: A(Nn).optional(),
|
|
3106
3106
|
wildcard: Ce()
|
|
3107
|
-
}),
|
|
3107
|
+
}), In = j({
|
|
3108
3108
|
name: g(),
|
|
3109
3109
|
type: g(),
|
|
3110
3110
|
value: g()
|
|
3111
|
-
}), $n =
|
|
3111
|
+
}), $n = j({
|
|
3112
3112
|
http_body: g().optional(),
|
|
3113
3113
|
http_url: g().optional()
|
|
3114
|
-
}), dt =
|
|
3114
|
+
}), dt = j({
|
|
3115
3115
|
id: g(),
|
|
3116
|
-
ssl:
|
|
3116
|
+
ssl: Zn,
|
|
3117
3117
|
hostname: g(),
|
|
3118
3118
|
custom_metadata: ct(g()).optional(),
|
|
3119
3119
|
custom_origin_server: g().optional(),
|
|
3120
3120
|
custom_origin_sni: g().optional(),
|
|
3121
|
-
ownership_verification:
|
|
3121
|
+
ownership_verification: In.optional(),
|
|
3122
3122
|
ownership_verification_http: $n.optional(),
|
|
3123
3123
|
status: g(),
|
|
3124
|
-
verification_errors:
|
|
3124
|
+
verification_errors: A(g()).optional(),
|
|
3125
3125
|
created_at: g()
|
|
3126
|
-
}),
|
|
3127
|
-
errors:
|
|
3128
|
-
messages:
|
|
3126
|
+
}), Oe = j({
|
|
3127
|
+
errors: A(Ie),
|
|
3128
|
+
messages: A(Ie),
|
|
3129
3129
|
success: Ce(),
|
|
3130
3130
|
result: dt
|
|
3131
|
-
})
|
|
3132
|
-
|
|
3133
|
-
|
|
3131
|
+
});
|
|
3132
|
+
j({
|
|
3133
|
+
errors: A(Ie),
|
|
3134
|
+
messages: A(Ie),
|
|
3134
3135
|
success: Ce(),
|
|
3135
|
-
result:
|
|
3136
|
+
result: A(dt)
|
|
3136
3137
|
});
|
|
3137
|
-
function
|
|
3138
|
-
return ft(`https://api.cloudflare.com/client/v4/zones/${
|
|
3139
|
-
"X-Auth-Email":
|
|
3140
|
-
"X-Auth-Key":
|
|
3138
|
+
function te(n) {
|
|
3139
|
+
return ft(`https://api.cloudflare.com/client/v4/zones/${n.zoneId}`).headers({
|
|
3140
|
+
"X-Auth-Email": n.authEmail,
|
|
3141
|
+
"X-Auth-Key": n.authKey,
|
|
3141
3142
|
"Content-Type": "application/json"
|
|
3142
|
-
}).middlewares([
|
|
3143
|
+
}).middlewares([Rn(), Cn()]);
|
|
3143
3144
|
}
|
|
3144
|
-
function Fe(
|
|
3145
|
+
function Fe(n) {
|
|
3145
3146
|
const e = [];
|
|
3146
|
-
if (
|
|
3147
|
-
for (const
|
|
3148
|
-
|
|
3147
|
+
if (n.ssl.validation_records)
|
|
3148
|
+
for (const t of n.ssl.validation_records)
|
|
3149
|
+
t.txt_name && t.txt_value && e.push({
|
|
3149
3150
|
name: "txt",
|
|
3150
|
-
record:
|
|
3151
|
-
domain:
|
|
3151
|
+
record: t.txt_value,
|
|
3152
|
+
domain: t.txt_name
|
|
3152
3153
|
});
|
|
3153
|
-
return
|
|
3154
|
+
return n.ownership_verification && e.push({
|
|
3154
3155
|
name: "txt",
|
|
3155
|
-
record:
|
|
3156
|
-
domain:
|
|
3156
|
+
record: n.ownership_verification.value,
|
|
3157
|
+
domain: n.ownership_verification.name
|
|
3157
3158
|
}), {
|
|
3158
|
-
custom_domain_id:
|
|
3159
|
-
domain:
|
|
3160
|
-
primary:
|
|
3161
|
-
status:
|
|
3159
|
+
custom_domain_id: n.id,
|
|
3160
|
+
domain: n.hostname,
|
|
3161
|
+
primary: n.primary,
|
|
3162
|
+
status: n.status === "active" ? "ready" : "pending",
|
|
3162
3163
|
type: "auth0_managed_certs",
|
|
3163
3164
|
verification: {
|
|
3164
|
-
methods:
|
|
3165
|
+
methods: A(lt).parse(e)
|
|
3165
3166
|
}
|
|
3166
3167
|
};
|
|
3167
3168
|
}
|
|
3168
|
-
function
|
|
3169
|
+
function Pn(n) {
|
|
3169
3170
|
return {
|
|
3170
|
-
create: async (e,
|
|
3171
|
-
const { result: s, errors: r, success: a } =
|
|
3172
|
-
await
|
|
3171
|
+
create: async (e, t) => {
|
|
3172
|
+
const { result: s, errors: r, success: a } = Oe.parse(
|
|
3173
|
+
await te(n).post(
|
|
3173
3174
|
{
|
|
3174
|
-
hostname:
|
|
3175
|
+
hostname: t.domain,
|
|
3175
3176
|
ssl: {
|
|
3176
3177
|
method: "txt",
|
|
3177
3178
|
type: "dv"
|
|
3178
3179
|
},
|
|
3179
|
-
custom_metadata:
|
|
3180
|
+
custom_metadata: n.enterprise ? {
|
|
3180
3181
|
tenant_id: e
|
|
3181
3182
|
} : void 0
|
|
3182
3183
|
},
|
|
@@ -3189,75 +3190,76 @@ function Mn(t) {
|
|
|
3189
3190
|
...s,
|
|
3190
3191
|
primary: !1
|
|
3191
3192
|
});
|
|
3192
|
-
return await
|
|
3193
|
+
return await n.customDomainAdapter.create(e, {
|
|
3193
3194
|
custom_domain_id: i.custom_domain_id,
|
|
3194
3195
|
domain: i.domain,
|
|
3195
3196
|
type: i.type
|
|
3196
3197
|
}), i;
|
|
3197
3198
|
},
|
|
3198
|
-
get: async (e,
|
|
3199
|
-
const s = await
|
|
3199
|
+
get: async (e, t) => {
|
|
3200
|
+
const s = await n.customDomainAdapter.get(
|
|
3200
3201
|
e,
|
|
3201
|
-
|
|
3202
|
+
t
|
|
3202
3203
|
);
|
|
3203
3204
|
if (!s)
|
|
3204
|
-
throw new
|
|
3205
|
-
const r = await
|
|
3205
|
+
throw new le(404);
|
|
3206
|
+
const r = await te(n).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(), { result: a, errors: i, success: o } = Oe.parse(r);
|
|
3206
3207
|
if (!o)
|
|
3207
|
-
throw new
|
|
3208
|
+
throw new le(503, {
|
|
3208
3209
|
message: JSON.stringify(i)
|
|
3209
3210
|
});
|
|
3210
|
-
if (
|
|
3211
|
-
throw new
|
|
3211
|
+
if (n.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3212
|
+
throw new le(404);
|
|
3212
3213
|
return Fe({ ...s, ...a });
|
|
3213
3214
|
},
|
|
3214
|
-
getByDomain: async (e) =>
|
|
3215
|
+
getByDomain: async (e) => n.customDomainAdapter.getByDomain(e),
|
|
3215
3216
|
list: async (e) => {
|
|
3216
|
-
const
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3217
|
+
const t = await n.customDomainAdapter.list(e);
|
|
3218
|
+
return (await Promise.all(
|
|
3219
|
+
t.map(async (r) => {
|
|
3220
|
+
try {
|
|
3221
|
+
const a = await te(n).get(
|
|
3222
|
+
`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`
|
|
3223
|
+
).json(), { result: i, success: o } = Oe.parse(a);
|
|
3224
|
+
return !o || n.enterprise && i.custom_metadata?.tenant_id !== e ? null : Fe({
|
|
3225
|
+
...r,
|
|
3226
|
+
...i
|
|
3227
|
+
});
|
|
3228
|
+
} catch {
|
|
3229
|
+
return null;
|
|
3230
|
+
}
|
|
3229
3231
|
})
|
|
3230
|
-
);
|
|
3232
|
+
)).filter((r) => r !== null);
|
|
3231
3233
|
},
|
|
3232
|
-
remove: async (e,
|
|
3233
|
-
if (
|
|
3234
|
-
const { result: r, success: a } =
|
|
3235
|
-
await
|
|
3234
|
+
remove: async (e, t) => {
|
|
3235
|
+
if (n.enterprise) {
|
|
3236
|
+
const { result: r, success: a } = Oe.parse(
|
|
3237
|
+
await te(n).get(`/custom_hostnames/${encodeURIComponent(t)}`).json()
|
|
3236
3238
|
);
|
|
3237
3239
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3238
|
-
throw new
|
|
3240
|
+
throw new le(404);
|
|
3239
3241
|
}
|
|
3240
|
-
const s = await
|
|
3241
|
-
return s.ok && await
|
|
3242
|
+
const s = await te(n).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();
|
|
3243
|
+
return s.ok && await n.customDomainAdapter.remove(e, t), s.ok;
|
|
3242
3244
|
},
|
|
3243
|
-
update: async (e,
|
|
3244
|
-
const r = await
|
|
3245
|
+
update: async (e, t, s) => {
|
|
3246
|
+
const r = await te(n).patch(
|
|
3245
3247
|
s,
|
|
3246
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3248
|
+
`/custom_hostnames/${encodeURIComponent(t)}`
|
|
3247
3249
|
).res();
|
|
3248
3250
|
if (!r.ok)
|
|
3249
|
-
throw new
|
|
3251
|
+
throw new le(503, {
|
|
3250
3252
|
message: await r.text()
|
|
3251
3253
|
});
|
|
3252
|
-
return
|
|
3254
|
+
return n.customDomainAdapter.update(
|
|
3253
3255
|
e,
|
|
3254
|
-
|
|
3256
|
+
t,
|
|
3255
3257
|
s
|
|
3256
3258
|
);
|
|
3257
3259
|
}
|
|
3258
3260
|
};
|
|
3259
3261
|
}
|
|
3260
|
-
class
|
|
3262
|
+
class Mn {
|
|
3261
3263
|
constructor(e) {
|
|
3262
3264
|
this.config = e;
|
|
3263
3265
|
}
|
|
@@ -3279,39 +3281,39 @@ class Dn {
|
|
|
3279
3281
|
}
|
|
3280
3282
|
async get(e) {
|
|
3281
3283
|
try {
|
|
3282
|
-
const
|
|
3284
|
+
const t = await this.getCache(), s = this.createRequest(e), r = await t.match(s);
|
|
3283
3285
|
if (!r)
|
|
3284
3286
|
return null;
|
|
3285
3287
|
const a = await r.json();
|
|
3286
3288
|
return a.expiresAt && new Date(a.expiresAt) < /* @__PURE__ */ new Date() ? (await this.delete(e), null) : a.value;
|
|
3287
|
-
} catch (
|
|
3288
|
-
return console.error(`CloudflareCache: get error for key ${e}:`,
|
|
3289
|
+
} catch (t) {
|
|
3290
|
+
return console.error(`CloudflareCache: get error for key ${e}:`, t), null;
|
|
3289
3291
|
}
|
|
3290
3292
|
}
|
|
3291
|
-
async set(e,
|
|
3293
|
+
async set(e, t, s) {
|
|
3292
3294
|
try {
|
|
3293
3295
|
const r = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3294
|
-
value:
|
|
3296
|
+
value: t,
|
|
3295
3297
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3296
3298
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3297
|
-
},
|
|
3299
|
+
}, u = this.createRequest(e), p = {
|
|
3298
3300
|
"Content-Type": "application/json"
|
|
3299
3301
|
};
|
|
3300
3302
|
i && o > 0 && (p["Cache-Control"] = `max-age=${o}`);
|
|
3301
3303
|
const b = new Response(JSON.stringify(c), {
|
|
3302
3304
|
headers: p
|
|
3303
3305
|
});
|
|
3304
|
-
await r.put(
|
|
3306
|
+
await r.put(u, b);
|
|
3305
3307
|
} catch (r) {
|
|
3306
3308
|
console.error(`CloudflareCache: set error for key ${e}:`, r);
|
|
3307
3309
|
}
|
|
3308
3310
|
}
|
|
3309
3311
|
async delete(e) {
|
|
3310
3312
|
try {
|
|
3311
|
-
const
|
|
3312
|
-
return await
|
|
3313
|
-
} catch (
|
|
3314
|
-
return console.error(`CloudflareCache: delete error for key ${e}:`,
|
|
3313
|
+
const t = await this.getCache(), s = this.createRequest(e);
|
|
3314
|
+
return await t.delete(s);
|
|
3315
|
+
} catch (t) {
|
|
3316
|
+
return console.error(`CloudflareCache: delete error for key ${e}:`, t), !1;
|
|
3315
3317
|
}
|
|
3316
3318
|
}
|
|
3317
3319
|
async clear() {
|
|
@@ -3320,32 +3322,32 @@ class Dn {
|
|
|
3320
3322
|
);
|
|
3321
3323
|
}
|
|
3322
3324
|
}
|
|
3323
|
-
function
|
|
3325
|
+
function Dn(n = {}) {
|
|
3324
3326
|
const e = {
|
|
3325
3327
|
defaultTtlSeconds: 300,
|
|
3326
3328
|
// 5 minutes default
|
|
3327
3329
|
keyPrefix: "authhero",
|
|
3328
3330
|
// default prefix
|
|
3329
|
-
...
|
|
3331
|
+
...n
|
|
3330
3332
|
// user config overrides defaults
|
|
3331
3333
|
};
|
|
3332
|
-
return new
|
|
3334
|
+
return new Mn(e);
|
|
3333
3335
|
}
|
|
3334
|
-
const
|
|
3335
|
-
let
|
|
3336
|
-
let e = "",
|
|
3337
|
-
for (;
|
|
3338
|
-
e +=
|
|
3336
|
+
const Ln = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3337
|
+
let Vn = (n = 21) => {
|
|
3338
|
+
let e = "", t = crypto.getRandomValues(new Uint8Array(n |= 0));
|
|
3339
|
+
for (; n--; )
|
|
3340
|
+
e += Ln[t[n] & 63];
|
|
3339
3341
|
return e;
|
|
3340
3342
|
};
|
|
3341
|
-
async function
|
|
3342
|
-
const
|
|
3343
|
+
async function He(n, e) {
|
|
3344
|
+
const t = n.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), t);
|
|
3343
3345
|
try {
|
|
3344
|
-
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${
|
|
3346
|
+
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${n.accountId}/r2-sql/query/${n.warehouseName}`, i = await fetch(a, {
|
|
3345
3347
|
method: "POST",
|
|
3346
3348
|
headers: {
|
|
3347
3349
|
"Content-Type": "application/json",
|
|
3348
|
-
Authorization: `Bearer ${
|
|
3350
|
+
Authorization: `Bearer ${n.authToken}`
|
|
3349
3351
|
},
|
|
3350
3352
|
// Request body should be shaped as { "query": "..." }
|
|
3351
3353
|
body: JSON.stringify({
|
|
@@ -3365,82 +3367,30 @@ async function Je(t, e) {
|
|
|
3365
3367
|
clearTimeout(r);
|
|
3366
3368
|
}
|
|
3367
3369
|
}
|
|
3368
|
-
function
|
|
3369
|
-
return `'${
|
|
3370
|
+
function $e(n) {
|
|
3371
|
+
return `'${n.replace(/'/g, "''")}'`;
|
|
3370
3372
|
}
|
|
3371
|
-
function
|
|
3372
|
-
return `"${
|
|
3373
|
+
function B(n) {
|
|
3374
|
+
return `"${n.replace(/"/g, '""')}"`;
|
|
3373
3375
|
}
|
|
3374
|
-
function ut(
|
|
3375
|
-
const e = (
|
|
3376
|
-
if (!
|
|
3376
|
+
function ut(n) {
|
|
3377
|
+
const e = (t) => {
|
|
3378
|
+
if (!t)
|
|
3377
3379
|
return "";
|
|
3378
3380
|
try {
|
|
3379
|
-
return JSON.parse(
|
|
3381
|
+
return JSON.parse(t);
|
|
3380
3382
|
} catch {
|
|
3381
|
-
return
|
|
3383
|
+
return t;
|
|
3382
3384
|
}
|
|
3383
3385
|
};
|
|
3384
3386
|
return {
|
|
3385
|
-
type: t.type,
|
|
3386
|
-
date: t.date,
|
|
3387
|
-
description: t.description,
|
|
3388
|
-
ip: t.ip,
|
|
3389
|
-
user_agent: t.user_agent,
|
|
3390
|
-
details: e(t.details),
|
|
3391
|
-
isMobile: !!t.isMobile,
|
|
3392
|
-
user_id: t.user_id,
|
|
3393
|
-
user_name: t.user_name,
|
|
3394
|
-
connection: t.connection,
|
|
3395
|
-
connection_id: t.connection_id,
|
|
3396
|
-
client_id: t.client_id,
|
|
3397
|
-
client_name: t.client_name,
|
|
3398
|
-
audience: t.audience,
|
|
3399
|
-
scope: t.scope,
|
|
3400
|
-
strategy: t.strategy,
|
|
3401
|
-
strategy_type: t.strategy_type,
|
|
3402
|
-
hostname: t.hostname,
|
|
3403
|
-
auth0_client: e(t.auth0_client),
|
|
3404
|
-
log_id: t.id,
|
|
3405
|
-
// Include location_info if any geo fields are present
|
|
3406
|
-
location_info: t.country_code || t.country_code3 || t.country_name || t.city_name || t.latitude || t.longitude || t.time_zone || t.continent_code ? {
|
|
3407
|
-
country_code: t.country_code || "",
|
|
3408
|
-
country_code3: t.country_code3 || "",
|
|
3409
|
-
country_name: t.country_name || "",
|
|
3410
|
-
city_name: t.city_name || "",
|
|
3411
|
-
latitude: t.latitude || "",
|
|
3412
|
-
longitude: t.longitude || "",
|
|
3413
|
-
time_zone: t.time_zone || "",
|
|
3414
|
-
continent_code: t.continent_code || ""
|
|
3415
|
-
} : void 0
|
|
3416
|
-
};
|
|
3417
|
-
}
|
|
3418
|
-
function zn(t) {
|
|
3419
|
-
return async (e, n) => {
|
|
3420
|
-
if (console.log("createLog called with config:", t), t.baseAdapter) {
|
|
3421
|
-
const a = await t.baseAdapter.create(e, n);
|
|
3422
|
-
return (t.pipelineEndpoint || t.pipelineBinding) && tt(t, e, a).catch((i) => {
|
|
3423
|
-
console.error("Failed to send log to Pipeline:", i);
|
|
3424
|
-
}), a;
|
|
3425
|
-
}
|
|
3426
|
-
const s = n.log_id || Un(), r = {
|
|
3427
|
-
...n,
|
|
3428
|
-
log_id: s
|
|
3429
|
-
};
|
|
3430
|
-
return await tt(t, e, r), console.log("Log sent to Pipeline with ID:", s), r;
|
|
3431
|
-
};
|
|
3432
|
-
}
|
|
3433
|
-
async function tt(t, e, n) {
|
|
3434
|
-
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3435
|
-
id: n.log_id,
|
|
3436
|
-
tenant_id: e,
|
|
3437
3387
|
type: n.type,
|
|
3438
3388
|
date: n.date,
|
|
3439
|
-
description: n.description
|
|
3389
|
+
description: n.description,
|
|
3440
3390
|
ip: n.ip,
|
|
3441
3391
|
user_agent: n.user_agent,
|
|
3442
|
-
details:
|
|
3443
|
-
isMobile: n.isMobile
|
|
3392
|
+
details: e(n.details),
|
|
3393
|
+
isMobile: !!n.isMobile,
|
|
3444
3394
|
user_id: n.user_id,
|
|
3445
3395
|
user_name: n.user_name,
|
|
3446
3396
|
connection: n.connection,
|
|
@@ -3452,25 +3402,73 @@ async function tt(t, e, n) {
|
|
|
3452
3402
|
strategy: n.strategy,
|
|
3453
3403
|
strategy_type: n.strategy_type,
|
|
3454
3404
|
hostname: n.hostname,
|
|
3455
|
-
auth0_client:
|
|
3456
|
-
log_id: n.
|
|
3405
|
+
auth0_client: e(n.auth0_client),
|
|
3406
|
+
log_id: n.id,
|
|
3407
|
+
// Include location_info if any geo fields are present
|
|
3408
|
+
location_info: n.country_code || n.city_name || n.latitude || n.longitude || n.time_zone || n.continent_code ? {
|
|
3409
|
+
country_code: n.country_code || "",
|
|
3410
|
+
city_name: n.city_name || "",
|
|
3411
|
+
latitude: n.latitude || "",
|
|
3412
|
+
longitude: n.longitude || "",
|
|
3413
|
+
time_zone: n.time_zone || "",
|
|
3414
|
+
continent_code: n.continent_code || ""
|
|
3415
|
+
} : void 0
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
function zn(n) {
|
|
3419
|
+
return async (e, t) => {
|
|
3420
|
+
if (console.log("createLog called with config:", n), n.baseAdapter) {
|
|
3421
|
+
const a = await n.baseAdapter.create(e, t);
|
|
3422
|
+
return (n.pipelineEndpoint || n.pipelineBinding) && tt(n, e, a).catch((i) => {
|
|
3423
|
+
console.error("Failed to send log to Pipeline:", i);
|
|
3424
|
+
}), a;
|
|
3425
|
+
}
|
|
3426
|
+
const s = t.log_id || Vn(), r = {
|
|
3427
|
+
...t,
|
|
3428
|
+
log_id: s
|
|
3429
|
+
};
|
|
3430
|
+
return await tt(n, e, r), console.log("Log sent to Pipeline with ID:", s), r;
|
|
3431
|
+
};
|
|
3432
|
+
}
|
|
3433
|
+
async function tt(n, e, t) {
|
|
3434
|
+
const s = (a) => a ? JSON.stringify(a) : void 0, r = {
|
|
3435
|
+
id: t.log_id,
|
|
3436
|
+
tenant_id: e,
|
|
3437
|
+
type: t.type,
|
|
3438
|
+
date: t.date,
|
|
3439
|
+
description: t.description?.substring(0, 256),
|
|
3440
|
+
ip: t.ip,
|
|
3441
|
+
user_agent: t.user_agent,
|
|
3442
|
+
details: s(t.details)?.substring(0, 8192),
|
|
3443
|
+
isMobile: t.isMobile ? 1 : 0,
|
|
3444
|
+
user_id: t.user_id,
|
|
3445
|
+
user_name: t.user_name,
|
|
3446
|
+
connection: t.connection,
|
|
3447
|
+
connection_id: t.connection_id,
|
|
3448
|
+
client_id: t.client_id,
|
|
3449
|
+
client_name: t.client_name,
|
|
3450
|
+
audience: t.audience,
|
|
3451
|
+
scope: t.scope,
|
|
3452
|
+
strategy: t.strategy,
|
|
3453
|
+
strategy_type: t.strategy_type,
|
|
3454
|
+
hostname: t.hostname,
|
|
3455
|
+
auth0_client: s(t.auth0_client),
|
|
3456
|
+
log_id: t.log_id,
|
|
3457
3457
|
// Geo fields from location_info
|
|
3458
|
-
country_code:
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
time_zone: n.location_info?.time_zone,
|
|
3465
|
-
continent_code: n.location_info?.continent_code
|
|
3458
|
+
country_code: t.location_info?.country_code,
|
|
3459
|
+
city_name: t.location_info?.city_name,
|
|
3460
|
+
latitude: t.location_info?.latitude,
|
|
3461
|
+
longitude: t.location_info?.longitude,
|
|
3462
|
+
time_zone: t.location_info?.time_zone,
|
|
3463
|
+
continent_code: t.location_info?.continent_code
|
|
3466
3464
|
};
|
|
3467
3465
|
try {
|
|
3468
|
-
if (
|
|
3469
|
-
await
|
|
3470
|
-
else if (
|
|
3471
|
-
const a =
|
|
3466
|
+
if (n.pipelineBinding)
|
|
3467
|
+
await n.pipelineBinding.send(r);
|
|
3468
|
+
else if (n.pipelineEndpoint) {
|
|
3469
|
+
const a = n.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), a);
|
|
3472
3470
|
try {
|
|
3473
|
-
const c = await fetch(
|
|
3471
|
+
const c = await fetch(n.pipelineEndpoint, {
|
|
3474
3472
|
method: "POST",
|
|
3475
3473
|
headers: {
|
|
3476
3474
|
"Content-Type": "application/json"
|
|
@@ -3494,263 +3492,137 @@ async function tt(t, e, n) {
|
|
|
3494
3492
|
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3495
3493
|
}
|
|
3496
3494
|
}
|
|
3497
|
-
function Bn(
|
|
3498
|
-
return async (e,
|
|
3499
|
-
if (
|
|
3500
|
-
return
|
|
3501
|
-
const s =
|
|
3502
|
-
SELECT * FROM ${
|
|
3503
|
-
WHERE tenant_id = ${
|
|
3504
|
-
AND id = ${
|
|
3495
|
+
function Bn(n) {
|
|
3496
|
+
return async (e, t) => {
|
|
3497
|
+
if (n.baseAdapter)
|
|
3498
|
+
return n.baseAdapter.get(e, t);
|
|
3499
|
+
const s = n.namespace || "default", r = n.tableName || "logs", a = `
|
|
3500
|
+
SELECT * FROM ${B(s)}.${B(r)}
|
|
3501
|
+
WHERE tenant_id = ${$e(e)}
|
|
3502
|
+
AND id = ${$e(t)}
|
|
3505
3503
|
LIMIT 1
|
|
3506
|
-
`, i = await
|
|
3504
|
+
`, i = await He(n, a);
|
|
3507
3505
|
if (i.length === 0)
|
|
3508
3506
|
return null;
|
|
3509
3507
|
const o = i[0];
|
|
3510
3508
|
return o ? ut(o) : null;
|
|
3511
3509
|
};
|
|
3512
3510
|
}
|
|
3513
|
-
function
|
|
3511
|
+
function Un(n) {
|
|
3514
3512
|
const e = {};
|
|
3515
|
-
return (
|
|
3513
|
+
return (n.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3516
3514
|
const [r, a] = s.split(":");
|
|
3517
3515
|
r && a && (e[r] = a);
|
|
3518
3516
|
}), e;
|
|
3519
3517
|
}
|
|
3520
|
-
function
|
|
3518
|
+
function Fn(n) {
|
|
3521
3519
|
const e = [];
|
|
3522
|
-
for (const [
|
|
3523
|
-
const r =
|
|
3520
|
+
for (const [t, s] of Object.entries(n)) {
|
|
3521
|
+
const r = t.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3524
3522
|
r && s && e.push(
|
|
3525
|
-
`${
|
|
3523
|
+
`${B(r)} = ${$e(s)}`
|
|
3526
3524
|
);
|
|
3527
3525
|
}
|
|
3528
3526
|
return e;
|
|
3529
3527
|
}
|
|
3530
|
-
function
|
|
3531
|
-
return async (e,
|
|
3532
|
-
if (
|
|
3533
|
-
return
|
|
3534
|
-
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } =
|
|
3535
|
-
`tenant_id = ${
|
|
3528
|
+
function qn(n) {
|
|
3529
|
+
return async (e, t = {}) => {
|
|
3530
|
+
if (n.baseAdapter)
|
|
3531
|
+
return n.baseAdapter.list(e, t);
|
|
3532
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = t, c = n.namespace || "default", u = n.tableName || "logs", p = [
|
|
3533
|
+
`tenant_id = ${$e(e)}`
|
|
3536
3534
|
];
|
|
3537
3535
|
if (o) {
|
|
3538
|
-
const
|
|
3539
|
-
p.push(...
|
|
3536
|
+
const H = Un(o);
|
|
3537
|
+
p.push(...Fn(H));
|
|
3540
3538
|
}
|
|
3541
3539
|
const b = p.join(" AND ");
|
|
3542
3540
|
let C = "ORDER BY date DESC";
|
|
3543
3541
|
if (i && i.sort_by) {
|
|
3544
|
-
const
|
|
3545
|
-
C = `ORDER BY ${
|
|
3542
|
+
const H = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), de = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3543
|
+
C = `ORDER BY ${B(H)} ${de}`;
|
|
3546
3544
|
}
|
|
3547
|
-
const w = s * r,
|
|
3548
|
-
SELECT * FROM ${
|
|
3545
|
+
const w = s * r, Z = `LIMIT ${r} OFFSET ${w}`, ce = `
|
|
3546
|
+
SELECT * FROM ${B(c)}.${B(u)}
|
|
3549
3547
|
WHERE ${b}
|
|
3550
3548
|
${C}
|
|
3551
|
-
${
|
|
3552
|
-
`,
|
|
3549
|
+
${Z}
|
|
3550
|
+
`, J = (await He(n, ce)).map(ut);
|
|
3553
3551
|
if (!a)
|
|
3554
3552
|
return {
|
|
3555
|
-
logs:
|
|
3553
|
+
logs: J,
|
|
3556
3554
|
start: 0,
|
|
3557
3555
|
limit: 0,
|
|
3558
3556
|
length: 0
|
|
3559
3557
|
};
|
|
3560
3558
|
const D = `
|
|
3561
|
-
SELECT COUNT(*) as count FROM ${
|
|
3559
|
+
SELECT COUNT(*) as count FROM ${B(c)}.${B(u)}
|
|
3562
3560
|
WHERE ${b}
|
|
3563
|
-
`,
|
|
3561
|
+
`, Q = (await He(n, D))[0]?.count || 0;
|
|
3564
3562
|
return {
|
|
3565
|
-
logs:
|
|
3563
|
+
logs: J,
|
|
3566
3564
|
start: w,
|
|
3567
3565
|
limit: r,
|
|
3568
|
-
length: Number(
|
|
3566
|
+
length: Number(Q)
|
|
3569
3567
|
};
|
|
3570
3568
|
};
|
|
3571
3569
|
}
|
|
3572
|
-
function Wn(
|
|
3573
|
-
const e = !!
|
|
3574
|
-
if (!e && !
|
|
3570
|
+
function Wn(n) {
|
|
3571
|
+
const e = !!n.baseAdapter, t = !!n.pipelineEndpoint, s = !!n.pipelineBinding;
|
|
3572
|
+
if (!e && !t && !s)
|
|
3575
3573
|
throw new Error(
|
|
3576
3574
|
'R2 SQL logs adapter requires one of: "baseAdapter", "pipelineEndpoint", or "pipelineBinding"'
|
|
3577
3575
|
);
|
|
3578
3576
|
if (!e) {
|
|
3579
|
-
if (!
|
|
3577
|
+
if (!n.authToken)
|
|
3580
3578
|
throw new Error('R2 SQL logs adapter requires "authToken" configuration');
|
|
3581
|
-
if (!
|
|
3579
|
+
if (!n.warehouseName)
|
|
3582
3580
|
throw new Error(
|
|
3583
3581
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3584
3582
|
);
|
|
3585
3583
|
}
|
|
3586
3584
|
return {
|
|
3587
|
-
create: zn(
|
|
3588
|
-
list:
|
|
3589
|
-
get: Bn(
|
|
3585
|
+
create: zn(n),
|
|
3586
|
+
list: qn(n),
|
|
3587
|
+
get: Bn(n)
|
|
3590
3588
|
};
|
|
3591
3589
|
}
|
|
3592
|
-
function
|
|
3590
|
+
function Jn() {
|
|
3593
3591
|
return {
|
|
3594
|
-
async getGeoInfo() {
|
|
3592
|
+
async getGeoInfo(n) {
|
|
3595
3593
|
try {
|
|
3596
|
-
const e =
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
latitude: r || "",
|
|
3606
|
-
longitude: a || "",
|
|
3607
|
-
time_zone: i || "",
|
|
3608
|
-
continent_code: o || ""
|
|
3609
|
-
};
|
|
3594
|
+
const e = n["cf-ipcountry"], t = n["cf-ipcity"], s = n["cf-iplatitude"], r = n["cf-iplongitude"], a = n["cf-timezone"], i = n["cf-ipcontinent"];
|
|
3595
|
+
return e ? {
|
|
3596
|
+
country_code: e,
|
|
3597
|
+
city_name: t || "",
|
|
3598
|
+
latitude: s || "",
|
|
3599
|
+
longitude: r || "",
|
|
3600
|
+
time_zone: a || "",
|
|
3601
|
+
continent_code: i || ""
|
|
3602
|
+
} : null;
|
|
3610
3603
|
} catch (e) {
|
|
3611
3604
|
return console.warn("Failed to get geo info from Cloudflare headers:", e), null;
|
|
3612
3605
|
}
|
|
3613
3606
|
}
|
|
3614
3607
|
};
|
|
3615
3608
|
}
|
|
3616
|
-
function
|
|
3617
|
-
return {
|
|
3618
|
-
// North America
|
|
3619
|
-
US: "USA",
|
|
3620
|
-
CA: "CAN",
|
|
3621
|
-
MX: "MEX",
|
|
3622
|
-
// Europe
|
|
3623
|
-
GB: "GBR",
|
|
3624
|
-
DE: "DEU",
|
|
3625
|
-
FR: "FRA",
|
|
3626
|
-
IT: "ITA",
|
|
3627
|
-
ES: "ESP",
|
|
3628
|
-
NL: "NLD",
|
|
3629
|
-
BE: "BEL",
|
|
3630
|
-
CH: "CHE",
|
|
3631
|
-
AT: "AUT",
|
|
3632
|
-
SE: "SWE",
|
|
3633
|
-
NO: "NOR",
|
|
3634
|
-
DK: "DNK",
|
|
3635
|
-
FI: "FIN",
|
|
3636
|
-
PL: "POL",
|
|
3637
|
-
RU: "RUS",
|
|
3638
|
-
UA: "UKR",
|
|
3639
|
-
// Asia
|
|
3640
|
-
JP: "JPN",
|
|
3641
|
-
CN: "CHN",
|
|
3642
|
-
IN: "IND",
|
|
3643
|
-
KR: "KOR",
|
|
3644
|
-
SG: "SGP",
|
|
3645
|
-
HK: "HKG",
|
|
3646
|
-
TW: "TWN",
|
|
3647
|
-
TH: "THA",
|
|
3648
|
-
MY: "MYS",
|
|
3649
|
-
ID: "IDN",
|
|
3650
|
-
PH: "PHL",
|
|
3651
|
-
VN: "VNM",
|
|
3652
|
-
// Oceania
|
|
3653
|
-
AU: "AUS",
|
|
3654
|
-
NZ: "NZL",
|
|
3655
|
-
// South America
|
|
3656
|
-
BR: "BRA",
|
|
3657
|
-
AR: "ARG",
|
|
3658
|
-
CL: "CHL",
|
|
3659
|
-
CO: "COL",
|
|
3660
|
-
PE: "PER",
|
|
3661
|
-
VE: "VEN",
|
|
3662
|
-
// Africa
|
|
3663
|
-
ZA: "ZAF",
|
|
3664
|
-
EG: "EGY",
|
|
3665
|
-
NG: "NGA",
|
|
3666
|
-
KE: "KEN",
|
|
3667
|
-
MA: "MAR",
|
|
3668
|
-
GH: "GHA",
|
|
3669
|
-
// Middle East
|
|
3670
|
-
AE: "ARE",
|
|
3671
|
-
SA: "SAU",
|
|
3672
|
-
IL: "ISR",
|
|
3673
|
-
TR: "TUR",
|
|
3674
|
-
IR: "IRN"
|
|
3675
|
-
}[t] || (t.length === 2 ? t + t.charAt(1) : t);
|
|
3676
|
-
}
|
|
3677
|
-
function Kn(t) {
|
|
3678
|
-
return {
|
|
3679
|
-
// North America
|
|
3680
|
-
US: "United States",
|
|
3681
|
-
CA: "Canada",
|
|
3682
|
-
MX: "Mexico",
|
|
3683
|
-
// Europe
|
|
3684
|
-
GB: "United Kingdom",
|
|
3685
|
-
DE: "Germany",
|
|
3686
|
-
FR: "France",
|
|
3687
|
-
IT: "Italy",
|
|
3688
|
-
ES: "Spain",
|
|
3689
|
-
NL: "Netherlands",
|
|
3690
|
-
BE: "Belgium",
|
|
3691
|
-
CH: "Switzerland",
|
|
3692
|
-
AT: "Austria",
|
|
3693
|
-
SE: "Sweden",
|
|
3694
|
-
NO: "Norway",
|
|
3695
|
-
DK: "Denmark",
|
|
3696
|
-
FI: "Finland",
|
|
3697
|
-
PL: "Poland",
|
|
3698
|
-
RU: "Russia",
|
|
3699
|
-
UA: "Ukraine",
|
|
3700
|
-
// Asia
|
|
3701
|
-
JP: "Japan",
|
|
3702
|
-
CN: "China",
|
|
3703
|
-
IN: "India",
|
|
3704
|
-
KR: "South Korea",
|
|
3705
|
-
SG: "Singapore",
|
|
3706
|
-
HK: "Hong Kong",
|
|
3707
|
-
TW: "Taiwan",
|
|
3708
|
-
TH: "Thailand",
|
|
3709
|
-
MY: "Malaysia",
|
|
3710
|
-
ID: "Indonesia",
|
|
3711
|
-
PH: "Philippines",
|
|
3712
|
-
VN: "Vietnam",
|
|
3713
|
-
// Oceania
|
|
3714
|
-
AU: "Australia",
|
|
3715
|
-
NZ: "New Zealand",
|
|
3716
|
-
// South America
|
|
3717
|
-
BR: "Brazil",
|
|
3718
|
-
AR: "Argentina",
|
|
3719
|
-
CL: "Chile",
|
|
3720
|
-
CO: "Colombia",
|
|
3721
|
-
PE: "Peru",
|
|
3722
|
-
VE: "Venezuela",
|
|
3723
|
-
// Africa
|
|
3724
|
-
ZA: "South Africa",
|
|
3725
|
-
EG: "Egypt",
|
|
3726
|
-
NG: "Nigeria",
|
|
3727
|
-
KE: "Kenya",
|
|
3728
|
-
MA: "Morocco",
|
|
3729
|
-
GH: "Ghana",
|
|
3730
|
-
// Middle East
|
|
3731
|
-
AE: "United Arab Emirates",
|
|
3732
|
-
SA: "Saudi Arabia",
|
|
3733
|
-
IL: "Israel",
|
|
3734
|
-
TR: "Turkey",
|
|
3735
|
-
IR: "Iran"
|
|
3736
|
-
}[t] || t;
|
|
3737
|
-
}
|
|
3738
|
-
function Xn(t) {
|
|
3609
|
+
function Yn(n) {
|
|
3739
3610
|
const e = {
|
|
3740
|
-
customDomains:
|
|
3611
|
+
customDomains: Pn(n),
|
|
3741
3612
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
3742
|
-
cache:
|
|
3743
|
-
...
|
|
3744
|
-
...
|
|
3745
|
-
defaultTtlSeconds:
|
|
3613
|
+
cache: Dn({
|
|
3614
|
+
...n.cacheName && { cacheName: n.cacheName },
|
|
3615
|
+
...n.defaultTtlSeconds !== void 0 && {
|
|
3616
|
+
defaultTtlSeconds: n.defaultTtlSeconds
|
|
3746
3617
|
},
|
|
3747
|
-
...
|
|
3748
|
-
})
|
|
3618
|
+
...n.keyPrefix && { keyPrefix: n.keyPrefix }
|
|
3619
|
+
}),
|
|
3620
|
+
// Always create the geo adapter - it extracts location from Cloudflare headers
|
|
3621
|
+
// passed at request time via getGeoInfo(headers)
|
|
3622
|
+
geo: Jn()
|
|
3749
3623
|
};
|
|
3750
|
-
return
|
|
3751
|
-
getHeaders: t.getHeaders
|
|
3752
|
-
})), e;
|
|
3624
|
+
return n.r2SqlLogs && (e.logs = Wn(n.r2SqlLogs)), e;
|
|
3753
3625
|
}
|
|
3754
3626
|
export {
|
|
3755
|
-
|
|
3627
|
+
Yn as default
|
|
3756
3628
|
};
|