@authhero/cloudflare-adapter 2.9.0 → 2.11.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 +56 -15
- package/dist/cloudflare-adapter.cjs +8 -8
- package/dist/cloudflare-adapter.d.ts +4 -3
- package/dist/cloudflare-adapter.mjs +798 -782
- package/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
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 le(
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const r =
|
|
3
|
+
function ht(t, e) {
|
|
4
|
+
var n = {};
|
|
5
|
+
for (var s in t) Object.prototype.hasOwnProperty.call(t, s) && e.indexOf(s) < 0 && (n[s] = t[s]);
|
|
6
|
+
if (t != null && typeof Object.getOwnPropertySymbols == "function")
|
|
7
|
+
for (var r = 0, s = Object.getOwnPropertySymbols(t); r < s.length; r++)
|
|
8
|
+
e.indexOf(s[r]) < 0 && Object.prototype.propertyIsEnumerable.call(t, s[r]) && (n[s[r]] = t[s[r]]);
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
function pt(t, e) {
|
|
12
|
+
var n;
|
|
13
|
+
return ((n = t?._def) === null || n === void 0 ? void 0 : n.typeName) === e;
|
|
14
|
+
}
|
|
15
|
+
function le(t, e) {
|
|
16
|
+
const n = t.ZodType.prototype[e];
|
|
17
|
+
t.ZodType.prototype[e] = function(...s) {
|
|
18
|
+
const r = n.apply(this, s);
|
|
19
19
|
return r._def.openapi = this._def.openapi, r;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function mt(
|
|
23
|
-
if (typeof
|
|
22
|
+
function mt(t) {
|
|
23
|
+
if (typeof t.ZodType.prototype.openapi < "u")
|
|
24
24
|
return;
|
|
25
|
-
|
|
25
|
+
t.ZodType.prototype.openapi = function(r, a) {
|
|
26
26
|
var i, o, c, d, p, b;
|
|
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),
|
|
27
|
+
const C = typeof r == "string" ? a : r, w = C ?? {}, { param: j } = w, de = 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), W = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), de), !((d = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || d === void 0) && d.param || j ? {
|
|
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), j)
|
|
29
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(W).length > 0 ? { metadata: W } : void 0) }));
|
|
30
30
|
if (pt(this, "ZodObject")) {
|
|
31
31
|
const ee = this.extend;
|
|
@@ -41,22 +41,22 @@ function mt(n) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
return D;
|
|
44
|
-
}, le(
|
|
45
|
-
const e =
|
|
46
|
-
|
|
44
|
+
}, le(t, "optional"), le(t, "nullable"), le(t, "default"), le(t, "transform"), le(t, "refine");
|
|
45
|
+
const e = t.ZodObject.prototype.deepPartial;
|
|
46
|
+
t.ZodObject.prototype.deepPartial = function() {
|
|
47
47
|
const r = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
48
48
|
return Object.entries(i).forEach(([o, c]) => {
|
|
49
49
|
var d, p;
|
|
50
50
|
c._def.openapi = (p = (d = r[o]) === null || d === void 0 ? void 0 : d._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 n = t.ZodObject.prototype.pick;
|
|
54
|
+
t.ZodObject.prototype.pick = function(...r) {
|
|
55
|
+
const a = n.apply(this, r);
|
|
56
56
|
return a._def.openapi = void 0, a;
|
|
57
57
|
};
|
|
58
|
-
const s =
|
|
59
|
-
|
|
58
|
+
const s = t.ZodObject.prototype.omit;
|
|
59
|
+
t.ZodObject.prototype.omit = function(...r) {
|
|
60
60
|
const a = s.apply(this, r);
|
|
61
61
|
return a._def.openapi = void 0, a;
|
|
62
62
|
};
|
|
@@ -64,8 +64,8 @@ function mt(n) {
|
|
|
64
64
|
var te = 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(t = 500, e) {
|
|
68
|
+
super(e?.message, { cause: e?.cause }), this.res = e?.res, this.status = t;
|
|
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(t) {
|
|
82
|
+
t.assertEqual = (r) => {
|
|
83
83
|
};
|
|
84
84
|
function e(r) {
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
function
|
|
86
|
+
t.assertIs = e;
|
|
87
|
+
function n(r) {
|
|
88
88
|
throw new Error();
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
t.assertNever = n, t.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
|
+
}, t.getValidEnumValues = (r) => {
|
|
96
|
+
const a = t.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 t.objectValues(i);
|
|
100
|
+
}, t.objectValues = (r) => t.objectKeys(r).map(function(a) {
|
|
101
101
|
return r[a];
|
|
102
|
-
}),
|
|
102
|
+
}), t.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
|
+
}, t.find = (r, a) => {
|
|
108
108
|
for (const i of r)
|
|
109
109
|
if (a(i))
|
|
110
110
|
return i;
|
|
111
|
-
},
|
|
111
|
+
}, t.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
|
+
t.joinValues = s, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
116
116
|
})(x || (x = {}));
|
|
117
117
|
var qe;
|
|
118
|
-
(function(
|
|
119
|
-
|
|
118
|
+
(function(t) {
|
|
119
|
+
t.mergeShapes = (e, n) => ({
|
|
120
120
|
...e,
|
|
121
|
-
...
|
|
121
|
+
...n
|
|
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 = (t) => {
|
|
147
|
+
switch (typeof t) {
|
|
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(t) ? f.nan : f.number;
|
|
154
154
|
case "boolean":
|
|
155
155
|
return f.boolean;
|
|
156
156
|
case "function":
|
|
@@ -160,7 +160,7 @@ 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(t) ? f.array : t === null ? f.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? f.promise : typeof Map < "u" && t instanceof Map ? f.map : typeof Set < "u" && t instanceof Set ? f.set : typeof Date < "u" && t instanceof Date ? f.date : f.object;
|
|
164
164
|
default:
|
|
165
165
|
return f.unknown;
|
|
166
166
|
}
|
|
@@ -181,7 +181,7 @@ const f = x.arrayToEnum([
|
|
|
181
181
|
"invalid_intersection_types",
|
|
182
182
|
"not_multiple_of",
|
|
183
183
|
"not_finite"
|
|
184
|
-
]), yt = (
|
|
184
|
+
]), yt = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
185
185
|
class A extends Error {
|
|
186
186
|
get errors() {
|
|
187
187
|
return this.issues;
|
|
@@ -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 n = new.target.prototype;
|
|
196
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
197
197
|
}
|
|
198
198
|
format(e) {
|
|
199
|
-
const
|
|
199
|
+
const n = e || function(a) {
|
|
200
200
|
return a.message;
|
|
201
201
|
}, s = { _errors: [] }, r = (a) => {
|
|
202
202
|
for (const i of a.issues)
|
|
@@ -207,12 +207,12 @@ 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(n(i));
|
|
211
211
|
else {
|
|
212
212
|
let o = s, c = 0;
|
|
213
213
|
for (; c < i.path.length; ) {
|
|
214
214
|
const d = i.path[c];
|
|
215
|
-
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(
|
|
215
|
+
c === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(n(i))) : o[d] = o[d] || { _errors: [] }, o = o[d], c++;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
};
|
|
@@ -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 = (n) => n.message) {
|
|
235
|
+
const n = {}, 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
|
+
n[a] = n[a] || [], n[a].push(e(r));
|
|
240
240
|
} else
|
|
241
241
|
s.push(e(r));
|
|
242
|
-
return { formErrors: s, fieldErrors:
|
|
242
|
+
return { formErrors: s, fieldErrors: n };
|
|
243
243
|
}
|
|
244
244
|
get formErrors() {
|
|
245
245
|
return this.flatten();
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
A.create = (
|
|
249
|
-
const ie = (
|
|
250
|
-
let
|
|
251
|
-
switch (
|
|
248
|
+
A.create = (t) => new A(t);
|
|
249
|
+
const ie = (t, e) => {
|
|
250
|
+
let n;
|
|
251
|
+
switch (t.code) {
|
|
252
252
|
case u.invalid_type:
|
|
253
|
-
|
|
253
|
+
t.received === f.undefined ? n = "Required" : n = `Expected ${t.expected}, received ${t.received}`;
|
|
254
254
|
break;
|
|
255
255
|
case u.invalid_literal:
|
|
256
|
-
|
|
256
|
+
n = `Invalid literal value, expected ${JSON.stringify(t.expected, x.jsonStringifyReplacer)}`;
|
|
257
257
|
break;
|
|
258
258
|
case u.unrecognized_keys:
|
|
259
|
-
|
|
259
|
+
n = `Unrecognized key(s) in object: ${x.joinValues(t.keys, ", ")}`;
|
|
260
260
|
break;
|
|
261
261
|
case u.invalid_union:
|
|
262
|
-
|
|
262
|
+
n = "Invalid input";
|
|
263
263
|
break;
|
|
264
264
|
case u.invalid_union_discriminator:
|
|
265
|
-
|
|
265
|
+
n = `Invalid discriminator value. Expected ${x.joinValues(t.options)}`;
|
|
266
266
|
break;
|
|
267
267
|
case u.invalid_enum_value:
|
|
268
|
-
|
|
268
|
+
n = `Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;
|
|
269
269
|
break;
|
|
270
270
|
case u.invalid_arguments:
|
|
271
|
-
|
|
271
|
+
n = "Invalid function arguments";
|
|
272
272
|
break;
|
|
273
273
|
case u.invalid_return_type:
|
|
274
|
-
|
|
274
|
+
n = "Invalid function return type";
|
|
275
275
|
break;
|
|
276
276
|
case u.invalid_date:
|
|
277
|
-
|
|
277
|
+
n = "Invalid date";
|
|
278
278
|
break;
|
|
279
279
|
case u.invalid_string:
|
|
280
|
-
typeof
|
|
280
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (n = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? n = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? n = `Invalid input: must end with "${t.validation.endsWith}"` : x.assertNever(t.validation) : t.validation !== "regex" ? n = `Invalid ${t.validation}` : n = "Invalid";
|
|
281
281
|
break;
|
|
282
282
|
case u.too_small:
|
|
283
|
-
|
|
283
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : n = "Invalid input";
|
|
284
284
|
break;
|
|
285
285
|
case u.too_big:
|
|
286
|
-
|
|
286
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? n = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : n = "Invalid input";
|
|
287
287
|
break;
|
|
288
288
|
case u.custom:
|
|
289
|
-
|
|
289
|
+
n = "Invalid input";
|
|
290
290
|
break;
|
|
291
291
|
case u.invalid_intersection_types:
|
|
292
|
-
|
|
292
|
+
n = "Intersection results could not be merged";
|
|
293
293
|
break;
|
|
294
294
|
case u.not_multiple_of:
|
|
295
|
-
|
|
295
|
+
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
296
296
|
break;
|
|
297
297
|
case u.not_finite:
|
|
298
|
-
|
|
298
|
+
n = "Number must be finite";
|
|
299
299
|
break;
|
|
300
300
|
default:
|
|
301
|
-
|
|
301
|
+
n = e.defaultError, x.assertNever(t);
|
|
302
302
|
}
|
|
303
|
-
return { message:
|
|
303
|
+
return { message: n };
|
|
304
304
|
};
|
|
305
305
|
let nt = ie;
|
|
306
|
-
function _t(
|
|
307
|
-
nt =
|
|
306
|
+
function _t(t) {
|
|
307
|
+
nt = t;
|
|
308
308
|
}
|
|
309
309
|
function Ae() {
|
|
310
310
|
return nt;
|
|
311
311
|
}
|
|
312
|
-
const Oe = (
|
|
313
|
-
const { data: e, path:
|
|
312
|
+
const Oe = (t) => {
|
|
313
|
+
const { data: e, path: n, errorMaps: s, issueData: r } = t, a = [...n, ...r.path || []], i = {
|
|
314
314
|
...r,
|
|
315
315
|
path: a
|
|
316
316
|
};
|
|
@@ -330,23 +330,23 @@ const Oe = (n) => {
|
|
|
330
330
|
message: o
|
|
331
331
|
};
|
|
332
332
|
}, gt = [];
|
|
333
|
-
function l(
|
|
334
|
-
const
|
|
333
|
+
function l(t, e) {
|
|
334
|
+
const n = Ae(), s = Oe({
|
|
335
335
|
issueData: e,
|
|
336
|
-
data:
|
|
337
|
-
path:
|
|
336
|
+
data: t.data,
|
|
337
|
+
path: t.path,
|
|
338
338
|
errorMaps: [
|
|
339
|
-
|
|
339
|
+
t.common.contextualErrorMap,
|
|
340
340
|
// contextual error map is first priority
|
|
341
|
-
|
|
341
|
+
t.schemaErrorMap,
|
|
342
342
|
// then schema-bound map if available
|
|
343
|
-
|
|
343
|
+
n,
|
|
344
344
|
// then global override map
|
|
345
|
-
|
|
345
|
+
n === ie ? void 0 : ie
|
|
346
346
|
// then global default map
|
|
347
347
|
].filter((r) => !!r)
|
|
348
348
|
});
|
|
349
|
-
|
|
349
|
+
t.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, n) {
|
|
362
362
|
const s = [];
|
|
363
|
-
for (const r of
|
|
363
|
+
for (const r of n) {
|
|
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, n) {
|
|
371
371
|
const s = [];
|
|
372
|
-
for (const r of
|
|
372
|
+
for (const r of n) {
|
|
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, n) {
|
|
382
382
|
const s = {};
|
|
383
|
-
for (const r of
|
|
383
|
+
for (const r of n) {
|
|
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
|
-
}), re = (
|
|
394
|
+
}), re = (t) => ({ status: "dirty", value: t }), S = (t) => ({ status: "valid", value: t }), He = (t) => t.status === "aborted", We = (t) => t.status === "dirty", Q = (t) => t.status === "valid", fe = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
395
395
|
var h;
|
|
396
|
-
(function(
|
|
397
|
-
|
|
396
|
+
(function(t) {
|
|
397
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.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, n, s, r) {
|
|
401
|
+
this._cachedPath = [], this.parent = e, this.data = n, 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 Ye = (
|
|
407
|
+
const Ye = (t, e) => {
|
|
408
408
|
if (Q(e))
|
|
409
409
|
return { success: !0, data: e.value };
|
|
410
|
-
if (!
|
|
410
|
+
if (!t.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 n = new A(t.common.issues);
|
|
418
|
+
return this._error = n, this._error;
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
};
|
|
422
|
-
function _(
|
|
423
|
-
if (!
|
|
422
|
+
function _(t) {
|
|
423
|
+
if (!t)
|
|
424
424
|
return {};
|
|
425
|
-
const { errorMap: e, invalid_type_error:
|
|
426
|
-
if (e && (
|
|
425
|
+
const { errorMap: e, invalid_type_error: n, required_error: s, description: r } = t;
|
|
426
|
+
if (e && (n || 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 } = t;
|
|
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 ?? n ?? 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, n) {
|
|
441
|
+
return n || {
|
|
442
442
|
common: e.parent.common,
|
|
443
443
|
data: e.data,
|
|
444
444
|
parsedType: V(e.data),
|
|
@@ -461,29 +461,29 @@ class v {
|
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
463
|
_parseSync(e) {
|
|
464
|
-
const
|
|
465
|
-
if (fe(
|
|
464
|
+
const n = this._parse(e);
|
|
465
|
+
if (fe(n))
|
|
466
466
|
throw new Error("Synchronous parse encountered promise.");
|
|
467
|
-
return
|
|
467
|
+
return n;
|
|
468
468
|
}
|
|
469
469
|
_parseAsync(e) {
|
|
470
|
-
const
|
|
471
|
-
return Promise.resolve(
|
|
470
|
+
const n = this._parse(e);
|
|
471
|
+
return Promise.resolve(n);
|
|
472
472
|
}
|
|
473
|
-
parse(e,
|
|
474
|
-
const s = this.safeParse(e,
|
|
473
|
+
parse(e, n) {
|
|
474
|
+
const s = this.safeParse(e, n);
|
|
475
475
|
if (s.success)
|
|
476
476
|
return s.data;
|
|
477
477
|
throw s.error;
|
|
478
478
|
}
|
|
479
|
-
safeParse(e,
|
|
479
|
+
safeParse(e, n) {
|
|
480
480
|
const s = {
|
|
481
481
|
common: {
|
|
482
482
|
issues: [],
|
|
483
|
-
async:
|
|
484
|
-
contextualErrorMap:
|
|
483
|
+
async: n?.async ?? !1,
|
|
484
|
+
contextualErrorMap: n?.errorMap
|
|
485
485
|
},
|
|
486
|
-
path:
|
|
486
|
+
path: n?.path || [],
|
|
487
487
|
schemaErrorMap: this._def.errorMap,
|
|
488
488
|
parent: null,
|
|
489
489
|
data: e,
|
|
@@ -492,7 +492,7 @@ class v {
|
|
|
492
492
|
return Ye(s, r);
|
|
493
493
|
}
|
|
494
494
|
"~validate"(e) {
|
|
495
|
-
const
|
|
495
|
+
const n = {
|
|
496
496
|
common: {
|
|
497
497
|
issues: [],
|
|
498
498
|
async: !!this["~standard"].async
|
|
@@ -505,38 +505,38 @@ class v {
|
|
|
505
505
|
};
|
|
506
506
|
if (!this["~standard"].async)
|
|
507
507
|
try {
|
|
508
|
-
const s = this._parseSync({ data: e, path: [], parent:
|
|
508
|
+
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
509
509
|
return Q(s) ? {
|
|
510
510
|
value: s.value
|
|
511
511
|
} : {
|
|
512
|
-
issues:
|
|
512
|
+
issues: n.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), n.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: n }).then((s) => Q(s) ? {
|
|
521
521
|
value: s.value
|
|
522
522
|
} : {
|
|
523
|
-
issues:
|
|
523
|
+
issues: n.common.issues
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
|
-
async parseAsync(e,
|
|
527
|
-
const s = await this.safeParseAsync(e,
|
|
526
|
+
async parseAsync(e, n) {
|
|
527
|
+
const s = await this.safeParseAsync(e, n);
|
|
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, n) {
|
|
533
533
|
const s = {
|
|
534
534
|
common: {
|
|
535
535
|
issues: [],
|
|
536
|
-
contextualErrorMap:
|
|
536
|
+
contextualErrorMap: n?.errorMap,
|
|
537
537
|
async: !0
|
|
538
538
|
},
|
|
539
|
-
path:
|
|
539
|
+
path: n?.path || [],
|
|
540
540
|
schemaErrorMap: this._def.errorMap,
|
|
541
541
|
parent: null,
|
|
542
542
|
data: e,
|
|
@@ -544,8 +544,8 @@ class v {
|
|
|
544
544
|
}, r = this._parse({ data: e, path: s.path, parent: s }), a = await (fe(r) ? r : Promise.resolve(r));
|
|
545
545
|
return Ye(s, a);
|
|
546
546
|
}
|
|
547
|
-
refine(e,
|
|
548
|
-
const s = (r) => typeof
|
|
547
|
+
refine(e, n) {
|
|
548
|
+
const s = (r) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(r) : n;
|
|
549
549
|
return this._refinement((r, a) => {
|
|
550
550
|
const i = e(r), o = () => a.addIssue({
|
|
551
551
|
code: u.custom,
|
|
@@ -554,8 +554,8 @@ class v {
|
|
|
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, n) {
|
|
558
|
+
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof n == "function" ? n(s, r) : n), !1));
|
|
559
559
|
}
|
|
560
560
|
_refinement(e) {
|
|
561
561
|
return new R({
|
|
@@ -571,7 +571,7 @@ 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: (n) => this["~validate"](n)
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
577
|
optional() {
|
|
@@ -584,7 +584,7 @@ class v {
|
|
|
584
584
|
return this.nullable().optional();
|
|
585
585
|
}
|
|
586
586
|
array() {
|
|
587
|
-
return
|
|
587
|
+
return N.create(this);
|
|
588
588
|
}
|
|
589
589
|
promise() {
|
|
590
590
|
return ce.create(this, this._def);
|
|
@@ -604,11 +604,11 @@ class v {
|
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
606
|
default(e) {
|
|
607
|
-
const
|
|
607
|
+
const n = typeof e == "function" ? e : () => e;
|
|
608
608
|
return new ke({
|
|
609
609
|
..._(this._def),
|
|
610
610
|
innerType: this,
|
|
611
|
-
defaultValue:
|
|
611
|
+
defaultValue: n,
|
|
612
612
|
typeName: y.ZodDefault
|
|
613
613
|
});
|
|
614
614
|
}
|
|
@@ -620,17 +620,17 @@ class v {
|
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
catch(e) {
|
|
623
|
-
const
|
|
623
|
+
const n = typeof e == "function" ? e : () => e;
|
|
624
624
|
return new we({
|
|
625
625
|
..._(this._def),
|
|
626
626
|
innerType: this,
|
|
627
|
-
catchValue:
|
|
627
|
+
catchValue: n,
|
|
628
628
|
typeName: y.ZodCatch
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
631
|
describe(e) {
|
|
632
|
-
const
|
|
633
|
-
return new
|
|
632
|
+
const n = this.constructor;
|
|
633
|
+
return new n({
|
|
634
634
|
...this._def,
|
|
635
635
|
description: e
|
|
636
636
|
});
|
|
@@ -649,42 +649,42 @@ class v {
|
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
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, At = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
652
|
-
let
|
|
653
|
-
const Ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
654
|
-
function rt(
|
|
652
|
+
let ze;
|
|
653
|
+
const Ot = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Et = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Nt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Rt = /^(([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])$/, It = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, jt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, 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])))", Zt = new RegExp(`^${st}$`);
|
|
654
|
+
function rt(t) {
|
|
655
655
|
let e = "[0-5]\\d";
|
|
656
|
-
|
|
657
|
-
const
|
|
658
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${
|
|
656
|
+
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
657
|
+
const n = t.precision ? "+" : "?";
|
|
658
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
|
|
659
659
|
}
|
|
660
|
-
function $t(
|
|
661
|
-
return new RegExp(`^${rt(
|
|
660
|
+
function $t(t) {
|
|
661
|
+
return new RegExp(`^${rt(t)}$`);
|
|
662
662
|
}
|
|
663
|
-
function at(
|
|
664
|
-
let e = `${st}T${rt(
|
|
665
|
-
const
|
|
666
|
-
return
|
|
663
|
+
function at(t) {
|
|
664
|
+
let e = `${st}T${rt(t)}`;
|
|
665
|
+
const n = [];
|
|
666
|
+
return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
|
|
667
667
|
}
|
|
668
|
-
function Pt(
|
|
669
|
-
return !!((e === "v4" || !e) && Ot.test(
|
|
668
|
+
function Pt(t, e) {
|
|
669
|
+
return !!((e === "v4" || !e) && Ot.test(t) || (e === "v6" || !e) && Nt.test(t));
|
|
670
670
|
}
|
|
671
|
-
function Mt(
|
|
672
|
-
if (!Tt.test(
|
|
671
|
+
function Mt(t, e) {
|
|
672
|
+
if (!Tt.test(t))
|
|
673
673
|
return !1;
|
|
674
674
|
try {
|
|
675
|
-
const [
|
|
676
|
-
if (!
|
|
675
|
+
const [n] = t.split(".");
|
|
676
|
+
if (!n)
|
|
677
677
|
return !1;
|
|
678
|
-
const s =
|
|
678
|
+
const s = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.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(t, e) {
|
|
685
|
+
return !!((e === "v4" || !e) && Et.test(t) || (e === "v6" || !e) && Rt.test(t));
|
|
686
686
|
}
|
|
687
|
-
class
|
|
687
|
+
class E 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);
|
|
@@ -739,7 +739,7 @@ class N extends v {
|
|
|
739
739
|
message: a.message
|
|
740
740
|
}), s.dirty());
|
|
741
741
|
else if (a.kind === "emoji")
|
|
742
|
-
|
|
742
|
+
ze || (ze = new RegExp(At, "u")), ze.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
743
743
|
validation: "emoji",
|
|
744
744
|
code: u.invalid_string,
|
|
745
745
|
message: a.message
|
|
@@ -828,26 +828,26 @@ class N extends v {
|
|
|
828
828
|
validation: "cidr",
|
|
829
829
|
code: u.invalid_string,
|
|
830
830
|
message: a.message
|
|
831
|
-
}), s.dirty()) : a.kind === "base64" ?
|
|
831
|
+
}), s.dirty()) : a.kind === "base64" ? It.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
832
832
|
validation: "base64",
|
|
833
833
|
code: u.invalid_string,
|
|
834
834
|
message: a.message
|
|
835
|
-
}), s.dirty()) : a.kind === "base64url" ?
|
|
835
|
+
}), s.dirty()) : a.kind === "base64url" ? jt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
836
836
|
validation: "base64url",
|
|
837
837
|
code: u.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, n, s) {
|
|
843
843
|
return this.refinement((r) => e.test(r), {
|
|
844
|
-
validation:
|
|
844
|
+
validation: n,
|
|
845
845
|
code: u.invalid_string,
|
|
846
846
|
...h.errToObj(s)
|
|
847
847
|
});
|
|
848
848
|
}
|
|
849
849
|
_addCheck(e) {
|
|
850
|
-
return new
|
|
850
|
+
return new E({
|
|
851
851
|
...this._def,
|
|
852
852
|
checks: [...this._def.checks, e]
|
|
853
853
|
});
|
|
@@ -926,54 +926,54 @@ class N extends v {
|
|
|
926
926
|
duration(e) {
|
|
927
927
|
return this._addCheck({ kind: "duration", ...h.errToObj(e) });
|
|
928
928
|
}
|
|
929
|
-
regex(e,
|
|
929
|
+
regex(e, n) {
|
|
930
930
|
return this._addCheck({
|
|
931
931
|
kind: "regex",
|
|
932
932
|
regex: e,
|
|
933
|
-
...h.errToObj(
|
|
933
|
+
...h.errToObj(n)
|
|
934
934
|
});
|
|
935
935
|
}
|
|
936
|
-
includes(e,
|
|
936
|
+
includes(e, n) {
|
|
937
937
|
return this._addCheck({
|
|
938
938
|
kind: "includes",
|
|
939
939
|
value: e,
|
|
940
|
-
position:
|
|
941
|
-
...h.errToObj(
|
|
940
|
+
position: n?.position,
|
|
941
|
+
...h.errToObj(n?.message)
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
|
-
startsWith(e,
|
|
944
|
+
startsWith(e, n) {
|
|
945
945
|
return this._addCheck({
|
|
946
946
|
kind: "startsWith",
|
|
947
947
|
value: e,
|
|
948
|
-
...h.errToObj(
|
|
948
|
+
...h.errToObj(n)
|
|
949
949
|
});
|
|
950
950
|
}
|
|
951
|
-
endsWith(e,
|
|
951
|
+
endsWith(e, n) {
|
|
952
952
|
return this._addCheck({
|
|
953
953
|
kind: "endsWith",
|
|
954
954
|
value: e,
|
|
955
|
-
...h.errToObj(
|
|
955
|
+
...h.errToObj(n)
|
|
956
956
|
});
|
|
957
957
|
}
|
|
958
|
-
min(e,
|
|
958
|
+
min(e, n) {
|
|
959
959
|
return this._addCheck({
|
|
960
960
|
kind: "min",
|
|
961
961
|
value: e,
|
|
962
|
-
...h.errToObj(
|
|
962
|
+
...h.errToObj(n)
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
max(e,
|
|
965
|
+
max(e, n) {
|
|
966
966
|
return this._addCheck({
|
|
967
967
|
kind: "max",
|
|
968
968
|
value: e,
|
|
969
|
-
...h.errToObj(
|
|
969
|
+
...h.errToObj(n)
|
|
970
970
|
});
|
|
971
971
|
}
|
|
972
|
-
length(e,
|
|
972
|
+
length(e, n) {
|
|
973
973
|
return this._addCheck({
|
|
974
974
|
kind: "length",
|
|
975
975
|
value: e,
|
|
976
|
-
...h.errToObj(
|
|
976
|
+
...h.errToObj(n)
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
979
|
/**
|
|
@@ -983,19 +983,19 @@ class N extends v {
|
|
|
983
983
|
return this.min(1, h.errToObj(e));
|
|
984
984
|
}
|
|
985
985
|
trim() {
|
|
986
|
-
return new
|
|
986
|
+
return new E({
|
|
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 E({
|
|
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 E({
|
|
999
999
|
...this._def,
|
|
1000
1000
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1001
1001
|
});
|
|
@@ -1050,28 +1050,28 @@ class N extends v {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
get minLength() {
|
|
1052
1052
|
let e = null;
|
|
1053
|
-
for (const
|
|
1054
|
-
|
|
1053
|
+
for (const n of this._def.checks)
|
|
1054
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1055
1055
|
return e;
|
|
1056
1056
|
}
|
|
1057
1057
|
get maxLength() {
|
|
1058
1058
|
let e = null;
|
|
1059
|
-
for (const
|
|
1060
|
-
|
|
1059
|
+
for (const n of this._def.checks)
|
|
1060
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1061
1061
|
return e;
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
|
|
1064
|
+
E.create = (t) => new E({
|
|
1065
1065
|
checks: [],
|
|
1066
1066
|
typeName: y.ZodString,
|
|
1067
|
-
coerce:
|
|
1068
|
-
..._(
|
|
1067
|
+
coerce: t?.coerce ?? !1,
|
|
1068
|
+
..._(t)
|
|
1069
1069
|
});
|
|
1070
|
-
function Lt(
|
|
1071
|
-
const
|
|
1070
|
+
function Lt(t, e) {
|
|
1071
|
+
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = n > s ? n : s, a = Number.parseInt(t.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
1072
1072
|
return a % i / 10 ** r;
|
|
1073
1073
|
}
|
|
1074
|
-
class
|
|
1074
|
+
class B extends v {
|
|
1075
1075
|
constructor() {
|
|
1076
1076
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1077
1077
|
}
|
|
@@ -1116,26 +1116,26 @@ class z extends v {
|
|
|
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, n) {
|
|
1120
|
+
return this.setLimit("min", e, !0, h.toString(n));
|
|
1121
1121
|
}
|
|
1122
|
-
gt(e,
|
|
1123
|
-
return this.setLimit("min", e, !1, h.toString(
|
|
1122
|
+
gt(e, n) {
|
|
1123
|
+
return this.setLimit("min", e, !1, h.toString(n));
|
|
1124
1124
|
}
|
|
1125
|
-
lte(e,
|
|
1126
|
-
return this.setLimit("max", e, !0, h.toString(
|
|
1125
|
+
lte(e, n) {
|
|
1126
|
+
return this.setLimit("max", e, !0, h.toString(n));
|
|
1127
1127
|
}
|
|
1128
|
-
lt(e,
|
|
1129
|
-
return this.setLimit("max", e, !1, h.toString(
|
|
1128
|
+
lt(e, n) {
|
|
1129
|
+
return this.setLimit("max", e, !1, h.toString(n));
|
|
1130
1130
|
}
|
|
1131
|
-
setLimit(e,
|
|
1132
|
-
return new
|
|
1131
|
+
setLimit(e, n, s, r) {
|
|
1132
|
+
return new B({
|
|
1133
1133
|
...this._def,
|
|
1134
1134
|
checks: [
|
|
1135
1135
|
...this._def.checks,
|
|
1136
1136
|
{
|
|
1137
1137
|
kind: e,
|
|
1138
|
-
value:
|
|
1138
|
+
value: n,
|
|
1139
1139
|
inclusive: s,
|
|
1140
1140
|
message: h.toString(r)
|
|
1141
1141
|
}
|
|
@@ -1143,7 +1143,7 @@ class z extends v {
|
|
|
1143
1143
|
});
|
|
1144
1144
|
}
|
|
1145
1145
|
_addCheck(e) {
|
|
1146
|
-
return new
|
|
1146
|
+
return new B({
|
|
1147
1147
|
...this._def,
|
|
1148
1148
|
checks: [...this._def.checks, e]
|
|
1149
1149
|
});
|
|
@@ -1186,11 +1186,11 @@ class z extends v {
|
|
|
1186
1186
|
message: h.toString(e)
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
|
-
multipleOf(e,
|
|
1189
|
+
multipleOf(e, n) {
|
|
1190
1190
|
return this._addCheck({
|
|
1191
1191
|
kind: "multipleOf",
|
|
1192
1192
|
value: e,
|
|
1193
|
-
message: h.toString(
|
|
1193
|
+
message: h.toString(n)
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
1196
1196
|
finite(e) {
|
|
@@ -1214,34 +1214,34 @@ class z extends v {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
get minValue() {
|
|
1216
1216
|
let e = null;
|
|
1217
|
-
for (const
|
|
1218
|
-
|
|
1217
|
+
for (const n of this._def.checks)
|
|
1218
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1219
1219
|
return e;
|
|
1220
1220
|
}
|
|
1221
1221
|
get maxValue() {
|
|
1222
1222
|
let e = null;
|
|
1223
|
-
for (const
|
|
1224
|
-
|
|
1223
|
+
for (const n of this._def.checks)
|
|
1224
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.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, n = 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" ? (n === null || s.value > n) && (n = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1236
1236
|
}
|
|
1237
|
-
return Number.isFinite(
|
|
1237
|
+
return Number.isFinite(n) && Number.isFinite(e);
|
|
1238
1238
|
}
|
|
1239
1239
|
}
|
|
1240
|
-
|
|
1240
|
+
B.create = (t) => new B({
|
|
1241
1241
|
checks: [],
|
|
1242
1242
|
typeName: y.ZodNumber,
|
|
1243
|
-
coerce:
|
|
1244
|
-
..._(
|
|
1243
|
+
coerce: t?.coerce || !1,
|
|
1244
|
+
..._(t)
|
|
1245
1245
|
});
|
|
1246
1246
|
class F extends v {
|
|
1247
1247
|
constructor() {
|
|
@@ -1279,33 +1279,33 @@ class F extends v {
|
|
|
1279
1279
|
return { status: r.value, value: e.data };
|
|
1280
1280
|
}
|
|
1281
1281
|
_getInvalidInput(e) {
|
|
1282
|
-
const
|
|
1283
|
-
return l(
|
|
1282
|
+
const n = this._getOrReturnCtx(e);
|
|
1283
|
+
return l(n, {
|
|
1284
1284
|
code: u.invalid_type,
|
|
1285
1285
|
expected: f.bigint,
|
|
1286
|
-
received:
|
|
1286
|
+
received: n.parsedType
|
|
1287
1287
|
}), m;
|
|
1288
1288
|
}
|
|
1289
|
-
gte(e,
|
|
1290
|
-
return this.setLimit("min", e, !0, h.toString(
|
|
1289
|
+
gte(e, n) {
|
|
1290
|
+
return this.setLimit("min", e, !0, h.toString(n));
|
|
1291
1291
|
}
|
|
1292
|
-
gt(e,
|
|
1293
|
-
return this.setLimit("min", e, !1, h.toString(
|
|
1292
|
+
gt(e, n) {
|
|
1293
|
+
return this.setLimit("min", e, !1, h.toString(n));
|
|
1294
1294
|
}
|
|
1295
|
-
lte(e,
|
|
1296
|
-
return this.setLimit("max", e, !0, h.toString(
|
|
1295
|
+
lte(e, n) {
|
|
1296
|
+
return this.setLimit("max", e, !0, h.toString(n));
|
|
1297
1297
|
}
|
|
1298
|
-
lt(e,
|
|
1299
|
-
return this.setLimit("max", e, !1, h.toString(
|
|
1298
|
+
lt(e, n) {
|
|
1299
|
+
return this.setLimit("max", e, !1, h.toString(n));
|
|
1300
1300
|
}
|
|
1301
|
-
setLimit(e,
|
|
1301
|
+
setLimit(e, n, 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: n,
|
|
1309
1309
|
inclusive: s,
|
|
1310
1310
|
message: h.toString(r)
|
|
1311
1311
|
}
|
|
@@ -1350,31 +1350,31 @@ class F extends v {
|
|
|
1350
1350
|
message: h.toString(e)
|
|
1351
1351
|
});
|
|
1352
1352
|
}
|
|
1353
|
-
multipleOf(e,
|
|
1353
|
+
multipleOf(e, n) {
|
|
1354
1354
|
return this._addCheck({
|
|
1355
1355
|
kind: "multipleOf",
|
|
1356
1356
|
value: e,
|
|
1357
|
-
message: h.toString(
|
|
1357
|
+
message: h.toString(n)
|
|
1358
1358
|
});
|
|
1359
1359
|
}
|
|
1360
1360
|
get minValue() {
|
|
1361
1361
|
let e = null;
|
|
1362
|
-
for (const
|
|
1363
|
-
|
|
1362
|
+
for (const n of this._def.checks)
|
|
1363
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
1364
1364
|
return e;
|
|
1365
1365
|
}
|
|
1366
1366
|
get maxValue() {
|
|
1367
1367
|
let e = null;
|
|
1368
|
-
for (const
|
|
1369
|
-
|
|
1368
|
+
for (const n of this._def.checks)
|
|
1369
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1370
1370
|
return e;
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
|
-
F.create = (
|
|
1373
|
+
F.create = (t) => new F({
|
|
1374
1374
|
checks: [],
|
|
1375
1375
|
typeName: y.ZodBigInt,
|
|
1376
|
-
coerce:
|
|
1377
|
-
..._(
|
|
1376
|
+
coerce: t?.coerce ?? !1,
|
|
1377
|
+
..._(t)
|
|
1378
1378
|
});
|
|
1379
1379
|
class he extends v {
|
|
1380
1380
|
_parse(e) {
|
|
@@ -1389,10 +1389,10 @@ class he extends v {
|
|
|
1389
1389
|
return S(e.data);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
|
-
he.create = (
|
|
1392
|
+
he.create = (t) => new he({
|
|
1393
1393
|
typeName: y.ZodBoolean,
|
|
1394
|
-
coerce:
|
|
1395
|
-
..._(
|
|
1394
|
+
coerce: t?.coerce || !1,
|
|
1395
|
+
..._(t)
|
|
1396
1396
|
});
|
|
1397
1397
|
class Y extends v {
|
|
1398
1398
|
_parse(e) {
|
|
@@ -1439,40 +1439,40 @@ class Y extends v {
|
|
|
1439
1439
|
checks: [...this._def.checks, e]
|
|
1440
1440
|
});
|
|
1441
1441
|
}
|
|
1442
|
-
min(e,
|
|
1442
|
+
min(e, n) {
|
|
1443
1443
|
return this._addCheck({
|
|
1444
1444
|
kind: "min",
|
|
1445
1445
|
value: e.getTime(),
|
|
1446
|
-
message: h.toString(
|
|
1446
|
+
message: h.toString(n)
|
|
1447
1447
|
});
|
|
1448
1448
|
}
|
|
1449
|
-
max(e,
|
|
1449
|
+
max(e, n) {
|
|
1450
1450
|
return this._addCheck({
|
|
1451
1451
|
kind: "max",
|
|
1452
1452
|
value: e.getTime(),
|
|
1453
|
-
message: h.toString(
|
|
1453
|
+
message: h.toString(n)
|
|
1454
1454
|
});
|
|
1455
1455
|
}
|
|
1456
1456
|
get minDate() {
|
|
1457
1457
|
let e = null;
|
|
1458
|
-
for (const
|
|
1459
|
-
|
|
1458
|
+
for (const n of this._def.checks)
|
|
1459
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.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 n of this._def.checks)
|
|
1465
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1466
1466
|
return e != null ? new Date(e) : null;
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
|
-
Y.create = (
|
|
1469
|
+
Y.create = (t) => new Y({
|
|
1470
1470
|
checks: [],
|
|
1471
|
-
coerce:
|
|
1471
|
+
coerce: t?.coerce || !1,
|
|
1472
1472
|
typeName: y.ZodDate,
|
|
1473
|
-
..._(
|
|
1473
|
+
..._(t)
|
|
1474
1474
|
});
|
|
1475
|
-
class
|
|
1475
|
+
class Ee extends v {
|
|
1476
1476
|
_parse(e) {
|
|
1477
1477
|
if (this._getType(e) !== f.symbol) {
|
|
1478
1478
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1485,9 +1485,9 @@ class Ne extends v {
|
|
|
1485
1485
|
return S(e.data);
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
|
-
|
|
1488
|
+
Ee.create = (t) => new Ee({
|
|
1489
1489
|
typeName: y.ZodSymbol,
|
|
1490
|
-
..._(
|
|
1490
|
+
..._(t)
|
|
1491
1491
|
});
|
|
1492
1492
|
class pe extends v {
|
|
1493
1493
|
_parse(e) {
|
|
@@ -1502,9 +1502,9 @@ class pe extends v {
|
|
|
1502
1502
|
return S(e.data);
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
|
-
pe.create = (
|
|
1505
|
+
pe.create = (t) => new pe({
|
|
1506
1506
|
typeName: y.ZodUndefined,
|
|
1507
|
-
..._(
|
|
1507
|
+
..._(t)
|
|
1508
1508
|
});
|
|
1509
1509
|
class me extends v {
|
|
1510
1510
|
_parse(e) {
|
|
@@ -1519,9 +1519,9 @@ class me extends v {
|
|
|
1519
1519
|
return S(e.data);
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
|
-
me.create = (
|
|
1522
|
+
me.create = (t) => new me({
|
|
1523
1523
|
typeName: y.ZodNull,
|
|
1524
|
-
..._(
|
|
1524
|
+
..._(t)
|
|
1525
1525
|
});
|
|
1526
1526
|
class oe extends v {
|
|
1527
1527
|
constructor() {
|
|
@@ -1531,9 +1531,9 @@ class oe extends v {
|
|
|
1531
1531
|
return S(e.data);
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
1534
|
-
oe.create = (
|
|
1534
|
+
oe.create = (t) => new oe({
|
|
1535
1535
|
typeName: y.ZodAny,
|
|
1536
|
-
..._(
|
|
1536
|
+
..._(t)
|
|
1537
1537
|
});
|
|
1538
1538
|
class K extends v {
|
|
1539
1539
|
constructor() {
|
|
@@ -1543,25 +1543,25 @@ class K extends v {
|
|
|
1543
1543
|
return S(e.data);
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
|
-
K.create = (
|
|
1546
|
+
K.create = (t) => new K({
|
|
1547
1547
|
typeName: y.ZodUnknown,
|
|
1548
|
-
..._(
|
|
1548
|
+
..._(t)
|
|
1549
1549
|
});
|
|
1550
1550
|
class U extends v {
|
|
1551
1551
|
_parse(e) {
|
|
1552
|
-
const
|
|
1553
|
-
return l(
|
|
1552
|
+
const n = this._getOrReturnCtx(e);
|
|
1553
|
+
return l(n, {
|
|
1554
1554
|
code: u.invalid_type,
|
|
1555
1555
|
expected: f.never,
|
|
1556
|
-
received:
|
|
1556
|
+
received: n.parsedType
|
|
1557
1557
|
}), m;
|
|
1558
1558
|
}
|
|
1559
1559
|
}
|
|
1560
|
-
U.create = (
|
|
1560
|
+
U.create = (t) => new U({
|
|
1561
1561
|
typeName: y.ZodNever,
|
|
1562
|
-
..._(
|
|
1562
|
+
..._(t)
|
|
1563
1563
|
});
|
|
1564
|
-
class
|
|
1564
|
+
class Ne extends v {
|
|
1565
1565
|
_parse(e) {
|
|
1566
1566
|
if (this._getType(e) !== f.undefined) {
|
|
1567
1567
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1574,22 +1574,22 @@ class Ee extends v {
|
|
|
1574
1574
|
return S(e.data);
|
|
1575
1575
|
}
|
|
1576
1576
|
}
|
|
1577
|
-
|
|
1577
|
+
Ne.create = (t) => new Ne({
|
|
1578
1578
|
typeName: y.ZodVoid,
|
|
1579
|
-
..._(
|
|
1579
|
+
..._(t)
|
|
1580
1580
|
});
|
|
1581
|
-
class
|
|
1581
|
+
class N extends v {
|
|
1582
1582
|
_parse(e) {
|
|
1583
|
-
const { ctx:
|
|
1584
|
-
if (
|
|
1585
|
-
return l(
|
|
1583
|
+
const { ctx: n, status: s } = this._processInputParams(e), r = this._def;
|
|
1584
|
+
if (n.parsedType !== f.array)
|
|
1585
|
+
return l(n, {
|
|
1586
1586
|
code: u.invalid_type,
|
|
1587
1587
|
expected: f.array,
|
|
1588
|
-
received:
|
|
1588
|
+
received: n.parsedType
|
|
1589
1589
|
}), m;
|
|
1590
1590
|
if (r.exactLength !== null) {
|
|
1591
|
-
const i =
|
|
1592
|
-
(i || o) && (l(
|
|
1591
|
+
const i = n.data.length > r.exactLength.value, o = n.data.length < r.exactLength.value;
|
|
1592
|
+
(i || o) && (l(n, {
|
|
1593
1593
|
code: i ? u.too_big : u.too_small,
|
|
1594
1594
|
minimum: o ? r.exactLength.value : void 0,
|
|
1595
1595
|
maximum: i ? r.exactLength.value : void 0,
|
|
@@ -1599,73 +1599,73 @@ class E extends v {
|
|
|
1599
1599
|
message: r.exactLength.message
|
|
1600
1600
|
}), s.dirty());
|
|
1601
1601
|
}
|
|
1602
|
-
if (r.minLength !== null &&
|
|
1602
|
+
if (r.minLength !== null && n.data.length < r.minLength.value && (l(n, {
|
|
1603
1603
|
code: u.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 &&
|
|
1609
|
+
}), s.dirty()), r.maxLength !== null && n.data.length > r.maxLength.value && (l(n, {
|
|
1610
1610
|
code: u.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()), n.common.async)
|
|
1617
|
+
return Promise.all([...n.data].map((i, o) => r.type._parseAsync(new $(n, i, n.path, o)))).then((i) => T.mergeArray(s, i));
|
|
1618
|
+
const a = [...n.data].map((i, o) => r.type._parseSync(new $(n, i, n.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, n) {
|
|
1625
|
+
return new N({
|
|
1626
1626
|
...this._def,
|
|
1627
|
-
minLength: { value: e, message: h.toString(
|
|
1627
|
+
minLength: { value: e, message: h.toString(n) }
|
|
1628
1628
|
});
|
|
1629
1629
|
}
|
|
1630
|
-
max(e,
|
|
1631
|
-
return new
|
|
1630
|
+
max(e, n) {
|
|
1631
|
+
return new N({
|
|
1632
1632
|
...this._def,
|
|
1633
|
-
maxLength: { value: e, message: h.toString(
|
|
1633
|
+
maxLength: { value: e, message: h.toString(n) }
|
|
1634
1634
|
});
|
|
1635
1635
|
}
|
|
1636
|
-
length(e,
|
|
1637
|
-
return new
|
|
1636
|
+
length(e, n) {
|
|
1637
|
+
return new N({
|
|
1638
1638
|
...this._def,
|
|
1639
|
-
exactLength: { value: e, message: h.toString(
|
|
1639
|
+
exactLength: { value: e, message: h.toString(n) }
|
|
1640
1640
|
});
|
|
1641
1641
|
}
|
|
1642
1642
|
nonempty(e) {
|
|
1643
1643
|
return this.min(1, e);
|
|
1644
1644
|
}
|
|
1645
1645
|
}
|
|
1646
|
-
|
|
1647
|
-
type:
|
|
1646
|
+
N.create = (t, e) => new N({
|
|
1647
|
+
type: t,
|
|
1648
1648
|
minLength: null,
|
|
1649
1649
|
maxLength: null,
|
|
1650
1650
|
exactLength: null,
|
|
1651
1651
|
typeName: y.ZodArray,
|
|
1652
1652
|
..._(e)
|
|
1653
1653
|
});
|
|
1654
|
-
function se(
|
|
1655
|
-
if (
|
|
1654
|
+
function se(t) {
|
|
1655
|
+
if (t instanceof k) {
|
|
1656
1656
|
const e = {};
|
|
1657
|
-
for (const
|
|
1658
|
-
const s =
|
|
1659
|
-
e[
|
|
1657
|
+
for (const n in t.shape) {
|
|
1658
|
+
const s = t.shape[n];
|
|
1659
|
+
e[n] = Z.create(se(s));
|
|
1660
1660
|
}
|
|
1661
1661
|
return new k({
|
|
1662
|
-
...
|
|
1662
|
+
...t._def,
|
|
1663
1663
|
shape: () => e
|
|
1664
1664
|
});
|
|
1665
|
-
} else return
|
|
1666
|
-
...
|
|
1667
|
-
type: se(
|
|
1668
|
-
}) :
|
|
1665
|
+
} else return t instanceof N ? new N({
|
|
1666
|
+
...t._def,
|
|
1667
|
+
type: se(t.element)
|
|
1668
|
+
}) : t instanceof Z ? Z.create(se(t.unwrap())) : t instanceof H ? H.create(se(t.unwrap())) : t instanceof P ? P.create(t.items.map((e) => se(e))) : t;
|
|
1669
1669
|
}
|
|
1670
1670
|
class k extends v {
|
|
1671
1671
|
constructor() {
|
|
@@ -1674,8 +1674,8 @@ 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(), n = x.objectKeys(e);
|
|
1678
|
+
return this._cached = { shape: e, keys: n }, this._cached;
|
|
1679
1679
|
}
|
|
1680
1680
|
_parse(e) {
|
|
1681
1681
|
if (this._getType(e) !== f.object) {
|
|
@@ -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: (n, s) => {
|
|
1752
|
+
const r = this._def.errorMap?.(n, s).message ?? s.defaultError;
|
|
1753
|
+
return n.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, n) {
|
|
1852
|
+
return this.augment({ [e]: n });
|
|
1853
1853
|
}
|
|
1854
1854
|
// merge<Incoming extends AnyZodObject>(
|
|
1855
1855
|
// merging: Incoming
|
|
@@ -1879,21 +1879,21 @@ class k extends v {
|
|
|
1879
1879
|
});
|
|
1880
1880
|
}
|
|
1881
1881
|
pick(e) {
|
|
1882
|
-
const
|
|
1882
|
+
const n = {};
|
|
1883
1883
|
for (const s of x.objectKeys(e))
|
|
1884
|
-
e[s] && this.shape[s] && (
|
|
1884
|
+
e[s] && this.shape[s] && (n[s] = this.shape[s]);
|
|
1885
1885
|
return new k({
|
|
1886
1886
|
...this._def,
|
|
1887
|
-
shape: () =>
|
|
1887
|
+
shape: () => n
|
|
1888
1888
|
});
|
|
1889
1889
|
}
|
|
1890
1890
|
omit(e) {
|
|
1891
|
-
const
|
|
1891
|
+
const n = {};
|
|
1892
1892
|
for (const s of x.objectKeys(this.shape))
|
|
1893
|
-
e[s] || (
|
|
1893
|
+
e[s] || (n[s] = this.shape[s]);
|
|
1894
1894
|
return new k({
|
|
1895
1895
|
...this._def,
|
|
1896
|
-
shape: () =>
|
|
1896
|
+
shape: () => n
|
|
1897
1897
|
});
|
|
1898
1898
|
}
|
|
1899
1899
|
/**
|
|
@@ -1903,52 +1903,52 @@ class k extends v {
|
|
|
1903
1903
|
return se(this);
|
|
1904
1904
|
}
|
|
1905
1905
|
partial(e) {
|
|
1906
|
-
const
|
|
1906
|
+
const n = {};
|
|
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] ? n[s] = r : n[s] = r.optional();
|
|
1910
1910
|
}
|
|
1911
1911
|
return new k({
|
|
1912
1912
|
...this._def,
|
|
1913
|
-
shape: () =>
|
|
1913
|
+
shape: () => n
|
|
1914
1914
|
});
|
|
1915
1915
|
}
|
|
1916
1916
|
required(e) {
|
|
1917
|
-
const
|
|
1917
|
+
const n = {};
|
|
1918
1918
|
for (const s of x.objectKeys(this.shape))
|
|
1919
1919
|
if (e && !e[s])
|
|
1920
|
-
|
|
1920
|
+
n[s] = this.shape[s];
|
|
1921
1921
|
else {
|
|
1922
1922
|
let a = this.shape[s];
|
|
1923
1923
|
for (; a instanceof Z; )
|
|
1924
1924
|
a = a._def.innerType;
|
|
1925
|
-
|
|
1925
|
+
n[s] = a;
|
|
1926
1926
|
}
|
|
1927
1927
|
return new k({
|
|
1928
1928
|
...this._def,
|
|
1929
|
-
shape: () =>
|
|
1929
|
+
shape: () => n
|
|
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 = (t, e) => new k({
|
|
1937
|
+
shape: () => t,
|
|
1938
1938
|
unknownKeys: "strip",
|
|
1939
1939
|
catchall: U.create(),
|
|
1940
1940
|
typeName: y.ZodObject,
|
|
1941
1941
|
..._(e)
|
|
1942
1942
|
});
|
|
1943
|
-
k.strictCreate = (
|
|
1944
|
-
shape: () =>
|
|
1943
|
+
k.strictCreate = (t, e) => new k({
|
|
1944
|
+
shape: () => t,
|
|
1945
1945
|
unknownKeys: "strict",
|
|
1946
1946
|
catchall: U.create(),
|
|
1947
1947
|
typeName: y.ZodObject,
|
|
1948
1948
|
..._(e)
|
|
1949
1949
|
});
|
|
1950
|
-
k.lazycreate = (
|
|
1951
|
-
shape:
|
|
1950
|
+
k.lazycreate = (t, e) => new k({
|
|
1951
|
+
shape: t,
|
|
1952
1952
|
unknownKeys: "strip",
|
|
1953
1953
|
catchall: U.create(),
|
|
1954
1954
|
typeName: y.ZodObject,
|
|
@@ -1956,34 +1956,34 @@ k.lazycreate = (n, e) => new k({
|
|
|
1956
1956
|
});
|
|
1957
1957
|
class ye extends v {
|
|
1958
1958
|
_parse(e) {
|
|
1959
|
-
const { ctx:
|
|
1959
|
+
const { ctx: n } = 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
|
|
1966
|
+
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1967
1967
|
const i = a.map((o) => new A(o.ctx.common.issues));
|
|
1968
|
-
return l(
|
|
1968
|
+
return l(n, {
|
|
1969
1969
|
code: u.invalid_union,
|
|
1970
1970
|
unionErrors: i
|
|
1971
1971
|
}), m;
|
|
1972
1972
|
}
|
|
1973
|
-
if (
|
|
1973
|
+
if (n.common.async)
|
|
1974
1974
|
return Promise.all(s.map(async (a) => {
|
|
1975
1975
|
const i = {
|
|
1976
|
-
...
|
|
1976
|
+
...n,
|
|
1977
1977
|
common: {
|
|
1978
|
-
...
|
|
1978
|
+
...n.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: n.data,
|
|
1986
|
+
path: n.path,
|
|
1987
1987
|
parent: i
|
|
1988
1988
|
}),
|
|
1989
1989
|
ctx: i
|
|
@@ -1994,15 +1994,15 @@ class ye extends v {
|
|
|
1994
1994
|
const i = [];
|
|
1995
1995
|
for (const c of s) {
|
|
1996
1996
|
const d = {
|
|
1997
|
-
...
|
|
1997
|
+
...n,
|
|
1998
1998
|
common: {
|
|
1999
|
-
...
|
|
1999
|
+
...n.common,
|
|
2000
2000
|
issues: []
|
|
2001
2001
|
},
|
|
2002
2002
|
parent: null
|
|
2003
2003
|
}, p = c._parseSync({
|
|
2004
|
-
data:
|
|
2005
|
-
path:
|
|
2004
|
+
data: n.data,
|
|
2005
|
+
path: n.path,
|
|
2006
2006
|
parent: d
|
|
2007
2007
|
});
|
|
2008
2008
|
if (p.status === "valid")
|
|
@@ -2010,9 +2010,9 @@ class ye extends v {
|
|
|
2010
2010
|
p.status === "dirty" && !a && (a = { result: p, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
2011
2011
|
}
|
|
2012
2012
|
if (a)
|
|
2013
|
-
return
|
|
2013
|
+
return n.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2014
2014
|
const o = i.map((c) => new A(c));
|
|
2015
|
-
return l(
|
|
2015
|
+
return l(n, {
|
|
2016
2016
|
code: u.invalid_union,
|
|
2017
2017
|
unionErrors: o
|
|
2018
2018
|
}), m;
|
|
@@ -2022,31 +2022,31 @@ class ye extends v {
|
|
|
2022
2022
|
return this._def.options;
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
2025
|
-
ye.create = (
|
|
2026
|
-
options:
|
|
2025
|
+
ye.create = (t, e) => new ye({
|
|
2026
|
+
options: t,
|
|
2027
2027
|
typeName: y.ZodUnion,
|
|
2028
2028
|
..._(e)
|
|
2029
2029
|
});
|
|
2030
|
-
const L = (
|
|
2030
|
+
const L = (t) => t instanceof ve ? L(t.schema) : t instanceof R ? L(t.innerType()) : t instanceof xe ? [t.value] : t instanceof q ? t.options : t instanceof be ? x.objectValues(t.enum) : t instanceof ke ? L(t._def.innerType) : t instanceof pe ? [void 0] : t instanceof me ? [null] : t instanceof Z ? [void 0, ...L(t.unwrap())] : t instanceof H ? [null, ...L(t.unwrap())] : t instanceof Ke || t instanceof Te ? L(t.unwrap()) : t instanceof we ? L(t._def.innerType) : [];
|
|
2031
2031
|
class $e extends v {
|
|
2032
2032
|
_parse(e) {
|
|
2033
|
-
const { ctx:
|
|
2034
|
-
if (
|
|
2035
|
-
return l(
|
|
2033
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2034
|
+
if (n.parsedType !== f.object)
|
|
2035
|
+
return l(n, {
|
|
2036
2036
|
code: u.invalid_type,
|
|
2037
2037
|
expected: f.object,
|
|
2038
|
-
received:
|
|
2038
|
+
received: n.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 = n.data[s], a = this.optionsMap.get(r);
|
|
2041
|
+
return a ? n.common.async ? a._parseAsync({
|
|
2042
|
+
data: n.data,
|
|
2043
|
+
path: n.path,
|
|
2044
|
+
parent: n
|
|
2045
2045
|
}) : a._parseSync({
|
|
2046
|
-
data:
|
|
2047
|
-
path:
|
|
2048
|
-
parent:
|
|
2049
|
-
}) : (l(
|
|
2046
|
+
data: n.data,
|
|
2047
|
+
path: n.path,
|
|
2048
|
+
parent: n
|
|
2049
|
+
}) : (l(n, {
|
|
2050
2050
|
code: u.invalid_union_discriminator,
|
|
2051
2051
|
options: Array.from(this.optionsMap.keys()),
|
|
2052
2052
|
path: [s]
|
|
@@ -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, n, s) {
|
|
2073
2073
|
const r = /* @__PURE__ */ new Map();
|
|
2074
|
-
for (const a of
|
|
2074
|
+
for (const a of n) {
|
|
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`);
|
|
@@ -2084,45 +2084,45 @@ class $e extends v {
|
|
|
2084
2084
|
return new $e({
|
|
2085
2085
|
typeName: y.ZodDiscriminatedUnion,
|
|
2086
2086
|
discriminator: e,
|
|
2087
|
-
options:
|
|
2087
|
+
options: n,
|
|
2088
2088
|
optionsMap: r,
|
|
2089
2089
|
..._(s)
|
|
2090
2090
|
});
|
|
2091
2091
|
}
|
|
2092
2092
|
}
|
|
2093
|
-
function Ge(
|
|
2094
|
-
const
|
|
2095
|
-
if (
|
|
2096
|
-
return { valid: !0, data:
|
|
2097
|
-
if (
|
|
2098
|
-
const r = x.objectKeys(e), a = x.objectKeys(
|
|
2093
|
+
function Ge(t, e) {
|
|
2094
|
+
const n = V(t), s = V(e);
|
|
2095
|
+
if (t === e)
|
|
2096
|
+
return { valid: !0, data: t };
|
|
2097
|
+
if (n === f.object && s === f.object) {
|
|
2098
|
+
const r = x.objectKeys(e), a = x.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2099
2099
|
for (const o of a) {
|
|
2100
|
-
const c = Ge(
|
|
2100
|
+
const c = Ge(t[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 (n === f.array && s === f.array) {
|
|
2107
|
+
if (t.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 < t.length; a++) {
|
|
2111
|
+
const i = t[a], o = e[a], c = Ge(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 n === f.date && s === f.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2118
2118
|
}
|
|
2119
2119
|
class _e extends v {
|
|
2120
2120
|
_parse(e) {
|
|
2121
|
-
const { status:
|
|
2121
|
+
const { status: n, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2122
2122
|
if (He(a) || He(i))
|
|
2123
2123
|
return m;
|
|
2124
2124
|
const o = Ge(a.value, i.value);
|
|
2125
|
-
return o.valid ? ((We(a) || We(i)) &&
|
|
2125
|
+
return o.valid ? ((We(a) || We(i)) && n.dirty(), { status: n.value, value: o.data }) : (l(s, {
|
|
2126
2126
|
code: u.invalid_intersection_types
|
|
2127
2127
|
}), m);
|
|
2128
2128
|
};
|
|
@@ -2148,15 +2148,15 @@ class _e extends v {
|
|
|
2148
2148
|
}));
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
|
-
_e.create = (
|
|
2152
|
-
left:
|
|
2151
|
+
_e.create = (t, e, n) => new _e({
|
|
2152
|
+
left: t,
|
|
2153
2153
|
right: e,
|
|
2154
2154
|
typeName: y.ZodIntersection,
|
|
2155
|
-
..._(
|
|
2155
|
+
..._(n)
|
|
2156
2156
|
});
|
|
2157
2157
|
class P extends v {
|
|
2158
2158
|
_parse(e) {
|
|
2159
|
-
const { status:
|
|
2159
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2160
2160
|
if (s.parsedType !== f.array)
|
|
2161
2161
|
return l(s, {
|
|
2162
2162
|
code: u.invalid_type,
|
|
@@ -2177,12 +2177,12 @@ class P extends v {
|
|
|
2177
2177
|
inclusive: !0,
|
|
2178
2178
|
exact: !1,
|
|
2179
2179
|
type: "array"
|
|
2180
|
-
}),
|
|
2180
|
+
}), n.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(n, i)) : T.mergeArray(n, 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 = (t, e) => {
|
|
2198
|
+
if (!Array.isArray(t))
|
|
2199
2199
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2200
2200
|
return new P({
|
|
2201
|
-
items:
|
|
2201
|
+
items: t,
|
|
2202
2202
|
typeName: y.ZodTuple,
|
|
2203
2203
|
rest: null,
|
|
2204
2204
|
..._(e)
|
|
@@ -2212,7 +2212,7 @@ class ge extends v {
|
|
|
2212
2212
|
return this._def.valueType;
|
|
2213
2213
|
}
|
|
2214
2214
|
_parse(e) {
|
|
2215
|
-
const { status:
|
|
2215
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2216
2216
|
if (s.parsedType !== f.object)
|
|
2217
2217
|
return l(s, {
|
|
2218
2218
|
code: u.invalid_type,
|
|
@@ -2226,22 +2226,22 @@ 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(n, r) : T.mergeObjectSync(n, 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, n, s) {
|
|
2235
|
+
return n instanceof v ? new ge({
|
|
2236
2236
|
keyType: e,
|
|
2237
|
-
valueType:
|
|
2237
|
+
valueType: n,
|
|
2238
2238
|
typeName: y.ZodRecord,
|
|
2239
2239
|
..._(s)
|
|
2240
2240
|
}) : new ge({
|
|
2241
|
-
keyType:
|
|
2241
|
+
keyType: E.create(),
|
|
2242
2242
|
valueType: e,
|
|
2243
2243
|
typeName: y.ZodRecord,
|
|
2244
|
-
..._(
|
|
2244
|
+
..._(n)
|
|
2245
2245
|
});
|
|
2246
2246
|
}
|
|
2247
2247
|
}
|
|
@@ -2253,7 +2253,7 @@ class Re extends v {
|
|
|
2253
2253
|
return this._def.valueType;
|
|
2254
2254
|
}
|
|
2255
2255
|
_parse(e) {
|
|
2256
|
-
const { status:
|
|
2256
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2257
2257
|
if (s.parsedType !== f.map)
|
|
2258
2258
|
return l(s, {
|
|
2259
2259
|
code: u.invalid_type,
|
|
@@ -2271,9 +2271,9 @@ class Re extends v {
|
|
|
2271
2271
|
const d = await c.key, p = await c.value;
|
|
2272
2272
|
if (d.status === "aborted" || p.status === "aborted")
|
|
2273
2273
|
return m;
|
|
2274
|
-
(d.status === "dirty" || p.status === "dirty") &&
|
|
2274
|
+
(d.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(d.value, p.value);
|
|
2275
2275
|
}
|
|
2276
|
-
return { status:
|
|
2276
|
+
return { status: n.value, value: o };
|
|
2277
2277
|
});
|
|
2278
2278
|
} else {
|
|
2279
2279
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2281,21 +2281,21 @@ class Re extends v {
|
|
|
2281
2281
|
const d = c.key, p = c.value;
|
|
2282
2282
|
if (d.status === "aborted" || p.status === "aborted")
|
|
2283
2283
|
return m;
|
|
2284
|
-
(d.status === "dirty" || p.status === "dirty") &&
|
|
2284
|
+
(d.status === "dirty" || p.status === "dirty") && n.dirty(), o.set(d.value, p.value);
|
|
2285
2285
|
}
|
|
2286
|
-
return { status:
|
|
2286
|
+
return { status: n.value, value: o };
|
|
2287
2287
|
}
|
|
2288
2288
|
}
|
|
2289
2289
|
}
|
|
2290
|
-
Re.create = (
|
|
2290
|
+
Re.create = (t, e, n) => new Re({
|
|
2291
2291
|
valueType: e,
|
|
2292
|
-
keyType:
|
|
2292
|
+
keyType: t,
|
|
2293
2293
|
typeName: y.ZodMap,
|
|
2294
|
-
..._(
|
|
2294
|
+
..._(n)
|
|
2295
2295
|
});
|
|
2296
2296
|
class X extends v {
|
|
2297
2297
|
_parse(e) {
|
|
2298
|
-
const { status:
|
|
2298
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
2299
2299
|
if (s.parsedType !== f.set)
|
|
2300
2300
|
return l(s, {
|
|
2301
2301
|
code: u.invalid_type,
|
|
@@ -2310,48 +2310,48 @@ class X extends v {
|
|
|
2310
2310
|
inclusive: !0,
|
|
2311
2311
|
exact: !1,
|
|
2312
2312
|
message: r.minSize.message
|
|
2313
|
-
}),
|
|
2313
|
+
}), n.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (l(s, {
|
|
2314
2314
|
code: u.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
|
+
}), n.dirty());
|
|
2321
2321
|
const a = this._def.valueType;
|
|
2322
2322
|
function i(c) {
|
|
2323
2323
|
const d = /* @__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" && n.dirty(), d.add(p.value);
|
|
2328
2328
|
}
|
|
2329
|
-
return { status:
|
|
2329
|
+
return { status: n.value, value: d };
|
|
2330
2330
|
}
|
|
2331
2331
|
const o = [...s.data.values()].map((c, d) => a._parse(new $(s, c, s.path, d)));
|
|
2332
2332
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2333
2333
|
}
|
|
2334
|
-
min(e,
|
|
2334
|
+
min(e, n) {
|
|
2335
2335
|
return new X({
|
|
2336
2336
|
...this._def,
|
|
2337
|
-
minSize: { value: e, message: h.toString(
|
|
2337
|
+
minSize: { value: e, message: h.toString(n) }
|
|
2338
2338
|
});
|
|
2339
2339
|
}
|
|
2340
|
-
max(e,
|
|
2340
|
+
max(e, n) {
|
|
2341
2341
|
return new X({
|
|
2342
2342
|
...this._def,
|
|
2343
|
-
maxSize: { value: e, message: h.toString(
|
|
2343
|
+
maxSize: { value: e, message: h.toString(n) }
|
|
2344
2344
|
});
|
|
2345
2345
|
}
|
|
2346
|
-
size(e,
|
|
2347
|
-
return this.min(e,
|
|
2346
|
+
size(e, n) {
|
|
2347
|
+
return this.min(e, n).max(e, n);
|
|
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 = (t, e) => new X({
|
|
2354
|
+
valueType: t,
|
|
2355
2355
|
minSize: null,
|
|
2356
2356
|
maxSize: null,
|
|
2357
2357
|
typeName: y.ZodSet,
|
|
@@ -2362,18 +2362,18 @@ class ae extends v {
|
|
|
2362
2362
|
super(...arguments), this.validate = this.implement;
|
|
2363
2363
|
}
|
|
2364
2364
|
_parse(e) {
|
|
2365
|
-
const { ctx:
|
|
2366
|
-
if (
|
|
2367
|
-
return l(
|
|
2365
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2366
|
+
if (n.parsedType !== f.function)
|
|
2367
|
+
return l(n, {
|
|
2368
2368
|
code: u.invalid_type,
|
|
2369
2369
|
expected: f.function,
|
|
2370
|
-
received:
|
|
2370
|
+
received: n.parsedType
|
|
2371
2371
|
}), m;
|
|
2372
2372
|
function s(o, c) {
|
|
2373
2373
|
return Oe({
|
|
2374
2374
|
data: o,
|
|
2375
|
-
path:
|
|
2376
|
-
errorMaps: [
|
|
2375
|
+
path: n.path,
|
|
2376
|
+
errorMaps: [n.common.contextualErrorMap, n.schemaErrorMap, Ae(), ie].filter((d) => !!d),
|
|
2377
2377
|
issueData: {
|
|
2378
2378
|
code: u.invalid_arguments,
|
|
2379
2379
|
argumentsError: c
|
|
@@ -2383,15 +2383,15 @@ class ae extends v {
|
|
|
2383
2383
|
function r(o, c) {
|
|
2384
2384
|
return Oe({
|
|
2385
2385
|
data: o,
|
|
2386
|
-
path:
|
|
2387
|
-
errorMaps: [
|
|
2386
|
+
path: n.path,
|
|
2387
|
+
errorMaps: [n.common.contextualErrorMap, n.schemaErrorMap, Ae(), ie].filter((d) => !!d),
|
|
2388
2388
|
issueData: {
|
|
2389
2389
|
code: u.invalid_return_type,
|
|
2390
2390
|
returnTypeError: c
|
|
2391
2391
|
}
|
|
2392
2392
|
});
|
|
2393
2393
|
}
|
|
2394
|
-
const a = { errorMap:
|
|
2394
|
+
const a = { errorMap: n.common.contextualErrorMap }, i = n.data;
|
|
2395
2395
|
if (this._def.returns instanceof ce) {
|
|
2396
2396
|
const o = this;
|
|
2397
2397
|
return S(async function(...c) {
|
|
@@ -2439,10 +2439,10 @@ class ae extends v {
|
|
|
2439
2439
|
strictImplement(e) {
|
|
2440
2440
|
return this.parse(e);
|
|
2441
2441
|
}
|
|
2442
|
-
static create(e,
|
|
2442
|
+
static create(e, n, s) {
|
|
2443
2443
|
return new ae({
|
|
2444
2444
|
args: e || P.create([]).rest(K.create()),
|
|
2445
|
-
returns:
|
|
2445
|
+
returns: n || K.create(),
|
|
2446
2446
|
typeName: y.ZodFunction,
|
|
2447
2447
|
..._(s)
|
|
2448
2448
|
});
|
|
@@ -2453,21 +2453,21 @@ 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: n } = this._processInputParams(e);
|
|
2457
|
+
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
|
-
ve.create = (
|
|
2461
|
-
getter:
|
|
2460
|
+
ve.create = (t, e) => new ve({
|
|
2461
|
+
getter: t,
|
|
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:
|
|
2468
|
+
const n = this._getOrReturnCtx(e);
|
|
2469
|
+
return l(n, {
|
|
2470
|
+
received: n.data,
|
|
2471
2471
|
code: u.invalid_literal,
|
|
2472
2472
|
expected: this._def.value
|
|
2473
2473
|
}), m;
|
|
@@ -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 = (t, e) => new xe({
|
|
2482
|
+
value: t,
|
|
2483
2483
|
typeName: y.ZodLiteral,
|
|
2484
2484
|
..._(e)
|
|
2485
2485
|
});
|
|
2486
|
-
function it(
|
|
2486
|
+
function it(t, e) {
|
|
2487
2487
|
return new q({
|
|
2488
|
-
values:
|
|
2488
|
+
values: t,
|
|
2489
2489
|
typeName: y.ZodEnum,
|
|
2490
2490
|
..._(e)
|
|
2491
2491
|
});
|
|
@@ -2493,17 +2493,17 @@ function it(n, 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 n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2497
|
+
return l(n, {
|
|
2498
2498
|
expected: x.joinValues(s),
|
|
2499
|
-
received:
|
|
2499
|
+
received: n.parsedType,
|
|
2500
2500
|
code: u.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:
|
|
2504
|
+
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
2505
|
+
return l(n, {
|
|
2506
|
+
received: n.data,
|
|
2507
2507
|
code: u.invalid_enum_value,
|
|
2508
2508
|
options: s
|
|
2509
2509
|
}), m;
|
|
@@ -2515,41 +2515,41 @@ class q extends v {
|
|
|
2515
2515
|
}
|
|
2516
2516
|
get enum() {
|
|
2517
2517
|
const e = {};
|
|
2518
|
-
for (const
|
|
2519
|
-
e[
|
|
2518
|
+
for (const n of this._def.values)
|
|
2519
|
+
e[n] = n;
|
|
2520
2520
|
return e;
|
|
2521
2521
|
}
|
|
2522
2522
|
get Values() {
|
|
2523
2523
|
const e = {};
|
|
2524
|
-
for (const
|
|
2525
|
-
e[
|
|
2524
|
+
for (const n of this._def.values)
|
|
2525
|
+
e[n] = n;
|
|
2526
2526
|
return e;
|
|
2527
2527
|
}
|
|
2528
2528
|
get Enum() {
|
|
2529
2529
|
const e = {};
|
|
2530
|
-
for (const
|
|
2531
|
-
e[
|
|
2530
|
+
for (const n of this._def.values)
|
|
2531
|
+
e[n] = n;
|
|
2532
2532
|
return e;
|
|
2533
2533
|
}
|
|
2534
|
-
extract(e,
|
|
2534
|
+
extract(e, n = this._def) {
|
|
2535
2535
|
return q.create(e, {
|
|
2536
2536
|
...this._def,
|
|
2537
|
-
...
|
|
2537
|
+
...n
|
|
2538
2538
|
});
|
|
2539
2539
|
}
|
|
2540
|
-
exclude(e,
|
|
2540
|
+
exclude(e, n = this._def) {
|
|
2541
2541
|
return q.create(this.options.filter((s) => !e.includes(s)), {
|
|
2542
2542
|
...this._def,
|
|
2543
|
-
...
|
|
2543
|
+
...n
|
|
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 n = 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(n);
|
|
2553
2553
|
return l(s, {
|
|
2554
2554
|
expected: x.joinValues(r),
|
|
2555
2555
|
received: s.parsedType,
|
|
@@ -2557,7 +2557,7 @@ class be extends v {
|
|
|
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(n);
|
|
2561
2561
|
return l(s, {
|
|
2562
2562
|
received: s.data,
|
|
2563
2563
|
code: u.invalid_enum_value,
|
|
@@ -2570,8 +2570,8 @@ class be extends v {
|
|
|
2570
2570
|
return this._def.values;
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
2573
|
-
be.create = (
|
|
2574
|
-
values:
|
|
2573
|
+
be.create = (t, e) => new be({
|
|
2574
|
+
values: t,
|
|
2575
2575
|
typeName: y.ZodNativeEnum,
|
|
2576
2576
|
..._(e)
|
|
2577
2577
|
});
|
|
@@ -2580,22 +2580,22 @@ class ce extends v {
|
|
|
2580
2580
|
return this._def.type;
|
|
2581
2581
|
}
|
|
2582
2582
|
_parse(e) {
|
|
2583
|
-
const { ctx:
|
|
2584
|
-
if (
|
|
2585
|
-
return l(
|
|
2583
|
+
const { ctx: n } = this._processInputParams(e);
|
|
2584
|
+
if (n.parsedType !== f.promise && n.common.async === !1)
|
|
2585
|
+
return l(n, {
|
|
2586
2586
|
code: u.invalid_type,
|
|
2587
2587
|
expected: f.promise,
|
|
2588
|
-
received:
|
|
2588
|
+
received: n.parsedType
|
|
2589
2589
|
}), m;
|
|
2590
|
-
const s =
|
|
2590
|
+
const s = n.parsedType === f.promise ? n.data : Promise.resolve(n.data);
|
|
2591
2591
|
return S(s.then((r) => this._def.type.parseAsync(r, {
|
|
2592
|
-
path:
|
|
2593
|
-
errorMap:
|
|
2592
|
+
path: n.path,
|
|
2593
|
+
errorMap: n.common.contextualErrorMap
|
|
2594
2594
|
})));
|
|
2595
2595
|
}
|
|
2596
2596
|
}
|
|
2597
|
-
ce.create = (
|
|
2598
|
-
type:
|
|
2597
|
+
ce.create = (t, e) => new ce({
|
|
2598
|
+
type: t,
|
|
2599
2599
|
typeName: y.ZodPromise,
|
|
2600
2600
|
..._(e)
|
|
2601
2601
|
});
|
|
@@ -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: n, 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 ? n.abort() : n.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 (n.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" || n.value === "dirty" ? re(c.value) : c;
|
|
2630
2630
|
});
|
|
2631
2631
|
{
|
|
2632
|
-
if (
|
|
2632
|
+
if (n.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" || n.value === "dirty" ? re(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" && n.dirty(), i(o.value), { status: n.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" && n.dirty(), i(o.value).then(() => ({ status: n.value, value: o.value }))));
|
|
2660
2660
|
}
|
|
2661
2661
|
if (r.type === "transform")
|
|
2662
2662
|
if (s.common.async === !1) {
|
|
@@ -2670,26 +2670,26 @@ class R extends v {
|
|
|
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: n.value, value: o };
|
|
2674
2674
|
} else
|
|
2675
2675
|
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => Q(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2676
|
-
status:
|
|
2676
|
+
status: n.value,
|
|
2677
2677
|
value: o
|
|
2678
2678
|
})) : m);
|
|
2679
2679
|
x.assertNever(r);
|
|
2680
2680
|
}
|
|
2681
2681
|
}
|
|
2682
|
-
R.create = (
|
|
2683
|
-
schema:
|
|
2682
|
+
R.create = (t, e, n) => new R({
|
|
2683
|
+
schema: t,
|
|
2684
2684
|
typeName: y.ZodEffects,
|
|
2685
2685
|
effect: e,
|
|
2686
|
-
..._(
|
|
2686
|
+
..._(n)
|
|
2687
2687
|
});
|
|
2688
|
-
R.createWithPreprocess = (
|
|
2688
|
+
R.createWithPreprocess = (t, e, n) => new R({
|
|
2689
2689
|
schema: e,
|
|
2690
|
-
effect: { type: "preprocess", transform:
|
|
2690
|
+
effect: { type: "preprocess", transform: t },
|
|
2691
2691
|
typeName: y.ZodEffects,
|
|
2692
|
-
..._(
|
|
2692
|
+
..._(n)
|
|
2693
2693
|
});
|
|
2694
2694
|
class Z extends v {
|
|
2695
2695
|
_parse(e) {
|
|
@@ -2699,8 +2699,8 @@ class Z extends v {
|
|
|
2699
2699
|
return this._def.innerType;
|
|
2700
2700
|
}
|
|
2701
2701
|
}
|
|
2702
|
-
Z.create = (
|
|
2703
|
-
innerType:
|
|
2702
|
+
Z.create = (t, e) => new Z({
|
|
2703
|
+
innerType: t,
|
|
2704
2704
|
typeName: y.ZodOptional,
|
|
2705
2705
|
..._(e)
|
|
2706
2706
|
});
|
|
@@ -2712,37 +2712,37 @@ class H extends v {
|
|
|
2712
2712
|
return this._def.innerType;
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
|
-
H.create = (
|
|
2716
|
-
innerType:
|
|
2715
|
+
H.create = (t, e) => new H({
|
|
2716
|
+
innerType: t,
|
|
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: n } = this._processInputParams(e);
|
|
2723
|
+
let s = n.data;
|
|
2724
|
+
return n.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2725
2725
|
data: s,
|
|
2726
|
-
path:
|
|
2727
|
-
parent:
|
|
2726
|
+
path: n.path,
|
|
2727
|
+
parent: n
|
|
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 = (t, e) => new ke({
|
|
2735
|
+
innerType: t,
|
|
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: n } = this._processInputParams(e), s = {
|
|
2743
|
+
...n,
|
|
2744
2744
|
common: {
|
|
2745
|
-
...
|
|
2745
|
+
...n.common,
|
|
2746
2746
|
issues: []
|
|
2747
2747
|
}
|
|
2748
2748
|
}, r = this._def.innerType._parse({
|
|
@@ -2774,13 +2774,13 @@ class we extends v {
|
|
|
2774
2774
|
return this._def.innerType;
|
|
2775
2775
|
}
|
|
2776
2776
|
}
|
|
2777
|
-
we.create = (
|
|
2778
|
-
innerType:
|
|
2777
|
+
we.create = (t, e) => new we({
|
|
2778
|
+
innerType: t,
|
|
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 Ie extends v {
|
|
2784
2784
|
_parse(e) {
|
|
2785
2785
|
if (this._getType(e) !== f.nan) {
|
|
2786
2786
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2793,18 +2793,18 @@ class je extends v {
|
|
|
2793
2793
|
return { status: "valid", value: e.data };
|
|
2794
2794
|
}
|
|
2795
2795
|
}
|
|
2796
|
-
|
|
2796
|
+
Ie.create = (t) => new Ie({
|
|
2797
2797
|
typeName: y.ZodNaN,
|
|
2798
|
-
..._(
|
|
2798
|
+
..._(t)
|
|
2799
2799
|
});
|
|
2800
2800
|
const Vt = Symbol("zod_brand");
|
|
2801
2801
|
class Ke extends v {
|
|
2802
2802
|
_parse(e) {
|
|
2803
|
-
const { ctx:
|
|
2803
|
+
const { ctx: n } = this._processInputParams(e), s = n.data;
|
|
2804
2804
|
return this._def.type._parse({
|
|
2805
2805
|
data: s,
|
|
2806
|
-
path:
|
|
2807
|
-
parent:
|
|
2806
|
+
path: n.path,
|
|
2807
|
+
parent: n
|
|
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: n, 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" ? (n.dirty(), re(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" ? (n.dirty(), {
|
|
2837
2837
|
status: "dirty",
|
|
2838
2838
|
value: r.value
|
|
2839
2839
|
}) : this._def.out._parseSync({
|
|
@@ -2843,44 +2843,44 @@ class Se extends v {
|
|
|
2843
2843
|
});
|
|
2844
2844
|
}
|
|
2845
2845
|
}
|
|
2846
|
-
static create(e,
|
|
2846
|
+
static create(e, n) {
|
|
2847
2847
|
return new Se({
|
|
2848
2848
|
in: e,
|
|
2849
|
-
out:
|
|
2849
|
+
out: n,
|
|
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 n = this._def.innerType._parse(e), s = (r) => (Q(r) && (r.value = Object.freeze(r.value)), r);
|
|
2857
|
+
return fe(n) ? n.then((r) => s(r)) : s(n);
|
|
2858
2858
|
}
|
|
2859
2859
|
unwrap() {
|
|
2860
2860
|
return this._def.innerType;
|
|
2861
2861
|
}
|
|
2862
2862
|
}
|
|
2863
|
-
Te.create = (
|
|
2864
|
-
innerType:
|
|
2863
|
+
Te.create = (t, e) => new Te({
|
|
2864
|
+
innerType: t,
|
|
2865
2865
|
typeName: y.ZodReadonly,
|
|
2866
2866
|
..._(e)
|
|
2867
2867
|
});
|
|
2868
|
-
function Xe(
|
|
2869
|
-
const
|
|
2870
|
-
return typeof
|
|
2868
|
+
function Xe(t, e) {
|
|
2869
|
+
const n = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
|
|
2870
|
+
return typeof n == "string" ? { message: n } : n;
|
|
2871
2871
|
}
|
|
2872
|
-
function ot(
|
|
2873
|
-
return
|
|
2874
|
-
const a =
|
|
2872
|
+
function ot(t, e = {}, n) {
|
|
2873
|
+
return t ? oe.create().superRefine((s, r) => {
|
|
2874
|
+
const a = t(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 ?? n ?? !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 ?? n ?? !0;
|
|
2884
2884
|
r.addIssue({ code: "custom", ...i, fatal: o });
|
|
2885
2885
|
}
|
|
2886
2886
|
}) : oe.create();
|
|
@@ -2889,20 +2889,20 @@ const Ut = {
|
|
|
2889
2889
|
object: k.lazycreate
|
|
2890
2890
|
};
|
|
2891
2891
|
var y;
|
|
2892
|
-
(function(
|
|
2893
|
-
|
|
2892
|
+
(function(t) {
|
|
2893
|
+
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2894
2894
|
})(y || (y = {}));
|
|
2895
|
-
const
|
|
2896
|
-
message: `Input not instance of ${
|
|
2897
|
-
}) => ot((
|
|
2898
|
-
string: ((
|
|
2899
|
-
number: ((
|
|
2900
|
-
boolean: ((
|
|
2901
|
-
...
|
|
2895
|
+
const zt = (t, e = {
|
|
2896
|
+
message: `Input not instance of ${t.name}`
|
|
2897
|
+
}) => ot((n) => n instanceof t, e), g = E.create, Qe = B.create, Bt = Ie.create, Ft = F.create, Ce = he.create, qt = Y.create, Ht = Ee.create, Wt = pe.create, Gt = me.create, Jt = oe.create, Kt = K.create, Qt = U.create, Yt = Ne.create, O = N.create, I = k.create, Xt = k.strictCreate, en = ye.create, tn = $e.create, nn = _e.create, sn = P.create, ct = ge.create, rn = Re.create, an = X.create, on = ae.create, cn = ve.create, dn = xe.create, un = q.create, ln = be.create, fn = ce.create, et = R.create, hn = Z.create, pn = H.create, mn = R.createWithPreprocess, yn = Se.create, _n = () => g().optional(), gn = () => Qe().optional(), vn = () => Ce().optional(), xn = {
|
|
2898
|
+
string: ((t) => E.create({ ...t, coerce: !0 })),
|
|
2899
|
+
number: ((t) => B.create({ ...t, coerce: !0 })),
|
|
2900
|
+
boolean: ((t) => he.create({
|
|
2901
|
+
...t,
|
|
2902
2902
|
coerce: !0
|
|
2903
2903
|
})),
|
|
2904
|
-
bigint: ((
|
|
2905
|
-
date: ((
|
|
2904
|
+
bigint: ((t) => F.create({ ...t, coerce: !0 })),
|
|
2905
|
+
date: ((t) => Y.create({ ...t, coerce: !0 }))
|
|
2906
2906
|
}, bn = m, kn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2907
2907
|
__proto__: null,
|
|
2908
2908
|
BRAND: Vt,
|
|
@@ -2914,7 +2914,7 @@ const Bt = (n, e = {
|
|
|
2914
2914
|
ParseStatus: T,
|
|
2915
2915
|
Schema: v,
|
|
2916
2916
|
ZodAny: oe,
|
|
2917
|
-
ZodArray:
|
|
2917
|
+
ZodArray: N,
|
|
2918
2918
|
ZodBigInt: F,
|
|
2919
2919
|
ZodBoolean: he,
|
|
2920
2920
|
ZodBranded: Ke,
|
|
@@ -2934,12 +2934,12 @@ const Bt = (n, e = {
|
|
|
2934
2934
|
ZodLazy: ve,
|
|
2935
2935
|
ZodLiteral: xe,
|
|
2936
2936
|
ZodMap: Re,
|
|
2937
|
-
ZodNaN:
|
|
2937
|
+
ZodNaN: Ie,
|
|
2938
2938
|
ZodNativeEnum: be,
|
|
2939
2939
|
ZodNever: U,
|
|
2940
2940
|
ZodNull: me,
|
|
2941
2941
|
ZodNullable: H,
|
|
2942
|
-
ZodNumber:
|
|
2942
|
+
ZodNumber: B,
|
|
2943
2943
|
ZodObject: k,
|
|
2944
2944
|
ZodOptional: Z,
|
|
2945
2945
|
ZodParsedType: f,
|
|
@@ -2949,15 +2949,15 @@ const Bt = (n, e = {
|
|
|
2949
2949
|
ZodRecord: ge,
|
|
2950
2950
|
ZodSchema: v,
|
|
2951
2951
|
ZodSet: X,
|
|
2952
|
-
ZodString:
|
|
2953
|
-
ZodSymbol:
|
|
2952
|
+
ZodString: E,
|
|
2953
|
+
ZodSymbol: Ee,
|
|
2954
2954
|
ZodTransformer: R,
|
|
2955
2955
|
ZodTuple: P,
|
|
2956
2956
|
ZodType: v,
|
|
2957
2957
|
ZodUndefined: pe,
|
|
2958
2958
|
ZodUnion: ye,
|
|
2959
2959
|
ZodUnknown: K,
|
|
2960
|
-
ZodVoid:
|
|
2960
|
+
ZodVoid: Ne,
|
|
2961
2961
|
addIssueToContext: l,
|
|
2962
2962
|
any: Jt,
|
|
2963
2963
|
array: O,
|
|
@@ -2974,7 +2974,7 @@ const Bt = (n, e = {
|
|
|
2974
2974
|
function: on,
|
|
2975
2975
|
getErrorMap: Ae,
|
|
2976
2976
|
getParsedType: V,
|
|
2977
|
-
instanceof:
|
|
2977
|
+
instanceof: zt,
|
|
2978
2978
|
intersection: nn,
|
|
2979
2979
|
isAborted: He,
|
|
2980
2980
|
isAsync: fe,
|
|
@@ -2985,13 +2985,13 @@ const Bt = (n, e = {
|
|
|
2985
2985
|
literal: dn,
|
|
2986
2986
|
makeIssue: Oe,
|
|
2987
2987
|
map: rn,
|
|
2988
|
-
nan:
|
|
2988
|
+
nan: Bt,
|
|
2989
2989
|
nativeEnum: ln,
|
|
2990
2990
|
never: Qt,
|
|
2991
2991
|
null: Gt,
|
|
2992
2992
|
nullable: pn,
|
|
2993
2993
|
number: Qe,
|
|
2994
|
-
object:
|
|
2994
|
+
object: I,
|
|
2995
2995
|
get objectUtil() {
|
|
2996
2996
|
return qe;
|
|
2997
2997
|
},
|
|
@@ -3020,10 +3020,10 @@ const Bt = (n, e = {
|
|
|
3020
3020
|
void: Yt
|
|
3021
3021
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3022
3022
|
mt(kn);
|
|
3023
|
-
const wn = (
|
|
3023
|
+
const wn = (t, e) => e.skipDedupe || e.method !== "GET", Tn = (t, e) => e.method + "@" + t, Sn = (t) => t.clone(), Cn = ({ skip: t = wn, key: e = Tn, resolver: n = Sn } = {}) => {
|
|
3024
3024
|
const s = /* @__PURE__ */ new Map();
|
|
3025
3025
|
return (r) => (a, i) => {
|
|
3026
|
-
if (
|
|
3026
|
+
if (t(a, i))
|
|
3027
3027
|
return r(a, i);
|
|
3028
3028
|
const o = e(a, i);
|
|
3029
3029
|
if (!s.has(o))
|
|
@@ -3033,23 +3033,23 @@ const wn = (n, e) => e.skipDedupe || e.method !== "GET", Tn = (n, e) => e.method
|
|
|
3033
3033
|
s.get(o).push([c, d]);
|
|
3034
3034
|
});
|
|
3035
3035
|
try {
|
|
3036
|
-
return r(a, i).then((c) => (s.get(o).forEach(([d]) => d(
|
|
3036
|
+
return r(a, i).then((c) => (s.get(o).forEach(([d]) => d(n(c))), s.delete(o), c)).catch((c) => {
|
|
3037
3037
|
throw s.get(o).forEach(([, d]) => d(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
|
-
}, An = (
|
|
3043
|
+
}, An = (t, e) => t * e, On = (t) => t && (t.ok || t.status >= 400 && t.status < 500), En = ({ delayTimer: t = 500, delayRamp: e = An, maxAttempts: n = 10, until: s = On, onRetry: r = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (d, p) => {
|
|
3044
3044
|
let b = 0;
|
|
3045
3045
|
if (o && o(d, p))
|
|
3046
3046
|
return c(d, p);
|
|
3047
|
-
const C = (w,
|
|
3048
|
-
const W = e(
|
|
3047
|
+
const C = (w, j) => Promise.resolve(s(w, j)).then((de) => de ? w && i ? w : j ? Promise.reject(j) : w : (b++, !n || b <= n ? new Promise((M) => {
|
|
3048
|
+
const W = e(t, b);
|
|
3049
3049
|
setTimeout(() => {
|
|
3050
3050
|
typeof r == "function" ? Promise.resolve(r({
|
|
3051
3051
|
response: w,
|
|
3052
|
-
error:
|
|
3052
|
+
error: j,
|
|
3053
3053
|
url: d,
|
|
3054
3054
|
attempt: b,
|
|
3055
3055
|
options: p
|
|
@@ -3062,30 +3062,30 @@ const wn = (n, e) => e.skipDedupe || e.method !== "GET", Tn = (n, e) => e.method
|
|
|
3062
3062
|
if (!a)
|
|
3063
3063
|
throw M;
|
|
3064
3064
|
return C(null, M);
|
|
3065
|
-
}) : w && i ? w : Promise.reject(
|
|
3065
|
+
}) : w && i ? w : Promise.reject(j || new Error("Number of attempts exceeded."))));
|
|
3066
3066
|
return c(d, p).then(C).catch((w) => {
|
|
3067
3067
|
if (!a)
|
|
3068
3068
|
throw w;
|
|
3069
3069
|
return C(null, w);
|
|
3070
3070
|
});
|
|
3071
|
-
},
|
|
3071
|
+
}, je = I({
|
|
3072
3072
|
code: Qe(),
|
|
3073
3073
|
message: g()
|
|
3074
|
-
}),
|
|
3074
|
+
}), Nn = I({
|
|
3075
3075
|
message: g()
|
|
3076
|
-
}), Rn =
|
|
3076
|
+
}), Rn = I({
|
|
3077
3077
|
emails: O(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
|
-
}),
|
|
3082
|
+
}), In = I({
|
|
3083
3083
|
ciphers: O(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
|
+
}), jn = I({
|
|
3089
3089
|
id: g(),
|
|
3090
3090
|
bundle_method: g().optional(),
|
|
3091
3091
|
certificate_authority: g(),
|
|
@@ -3097,23 +3097,23 @@ const wn = (n, e) => e.skipDedupe || e.method !== "GET", Tn = (n, e) => e.method
|
|
|
3097
3097
|
issuer: g().optional(),
|
|
3098
3098
|
method: g(),
|
|
3099
3099
|
serial_number: g().optional(),
|
|
3100
|
-
settings:
|
|
3100
|
+
settings: In.optional(),
|
|
3101
3101
|
signature: g().optional(),
|
|
3102
3102
|
type: g(),
|
|
3103
3103
|
uploaded_on: g().optional(),
|
|
3104
|
-
validation_errors: O(
|
|
3104
|
+
validation_errors: O(Nn).optional(),
|
|
3105
3105
|
validation_records: O(Rn).optional(),
|
|
3106
3106
|
wildcard: Ce()
|
|
3107
|
-
}), Zn =
|
|
3107
|
+
}), Zn = I({
|
|
3108
3108
|
name: g(),
|
|
3109
3109
|
type: g(),
|
|
3110
3110
|
value: g()
|
|
3111
|
-
}), $n =
|
|
3111
|
+
}), $n = I({
|
|
3112
3112
|
http_body: g().optional(),
|
|
3113
3113
|
http_url: g().optional()
|
|
3114
|
-
}), dt =
|
|
3114
|
+
}), dt = I({
|
|
3115
3115
|
id: g(),
|
|
3116
|
-
ssl:
|
|
3116
|
+
ssl: jn,
|
|
3117
3117
|
hostname: g(),
|
|
3118
3118
|
custom_metadata: ct(g()).optional(),
|
|
3119
3119
|
custom_origin_server: g().optional(),
|
|
@@ -3123,60 +3123,60 @@ const wn = (n, e) => e.skipDedupe || e.method !== "GET", Tn = (n, e) => e.method
|
|
|
3123
3123
|
status: g(),
|
|
3124
3124
|
verification_errors: O(g()).optional(),
|
|
3125
3125
|
created_at: g()
|
|
3126
|
-
}),
|
|
3127
|
-
errors: O(
|
|
3128
|
-
messages: O(
|
|
3126
|
+
}), Be = I({
|
|
3127
|
+
errors: O(je),
|
|
3128
|
+
messages: O(je),
|
|
3129
3129
|
success: Ce(),
|
|
3130
3130
|
result: dt
|
|
3131
|
-
}), Pn =
|
|
3132
|
-
errors: O(
|
|
3133
|
-
messages: O(
|
|
3131
|
+
}), Pn = I({
|
|
3132
|
+
errors: O(je),
|
|
3133
|
+
messages: O(je),
|
|
3134
3134
|
success: Ce(),
|
|
3135
3135
|
result: O(dt)
|
|
3136
3136
|
});
|
|
3137
|
-
function ne(
|
|
3138
|
-
return ft(`https://api.cloudflare.com/client/v4/zones/${
|
|
3139
|
-
"X-Auth-Email":
|
|
3140
|
-
"X-Auth-Key":
|
|
3137
|
+
function ne(t) {
|
|
3138
|
+
return ft(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({
|
|
3139
|
+
"X-Auth-Email": t.authEmail,
|
|
3140
|
+
"X-Auth-Key": t.authKey,
|
|
3141
3141
|
"Content-Type": "application/json"
|
|
3142
|
-
}).middlewares([
|
|
3142
|
+
}).middlewares([En(), Cn()]);
|
|
3143
3143
|
}
|
|
3144
|
-
function Fe(
|
|
3144
|
+
function Fe(t) {
|
|
3145
3145
|
const e = [];
|
|
3146
|
-
if (
|
|
3147
|
-
for (const
|
|
3148
|
-
|
|
3146
|
+
if (t.ssl.validation_records)
|
|
3147
|
+
for (const n of t.ssl.validation_records)
|
|
3148
|
+
n.txt_name && n.txt_value && e.push({
|
|
3149
3149
|
name: "txt",
|
|
3150
|
-
record:
|
|
3151
|
-
domain:
|
|
3150
|
+
record: n.txt_value,
|
|
3151
|
+
domain: n.txt_name
|
|
3152
3152
|
});
|
|
3153
|
-
return
|
|
3153
|
+
return t.ownership_verification && e.push({
|
|
3154
3154
|
name: "txt",
|
|
3155
|
-
record:
|
|
3156
|
-
domain:
|
|
3155
|
+
record: t.ownership_verification.value,
|
|
3156
|
+
domain: t.ownership_verification.name
|
|
3157
3157
|
}), {
|
|
3158
|
-
custom_domain_id:
|
|
3159
|
-
domain:
|
|
3160
|
-
primary:
|
|
3161
|
-
status:
|
|
3158
|
+
custom_domain_id: t.id,
|
|
3159
|
+
domain: t.hostname,
|
|
3160
|
+
primary: t.primary,
|
|
3161
|
+
status: t.status === "active" ? "ready" : "pending",
|
|
3162
3162
|
type: "auth0_managed_certs",
|
|
3163
3163
|
verification: {
|
|
3164
3164
|
methods: O(lt).parse(e)
|
|
3165
3165
|
}
|
|
3166
3166
|
};
|
|
3167
3167
|
}
|
|
3168
|
-
function Mn(
|
|
3168
|
+
function Mn(t) {
|
|
3169
3169
|
return {
|
|
3170
|
-
create: async (e,
|
|
3171
|
-
const { result: s, errors: r, success: a } =
|
|
3172
|
-
await ne(
|
|
3170
|
+
create: async (e, n) => {
|
|
3171
|
+
const { result: s, errors: r, success: a } = Be.parse(
|
|
3172
|
+
await ne(t).post(
|
|
3173
3173
|
{
|
|
3174
|
-
hostname:
|
|
3174
|
+
hostname: n.domain,
|
|
3175
3175
|
ssl: {
|
|
3176
3176
|
method: "txt",
|
|
3177
3177
|
type: "dv"
|
|
3178
3178
|
},
|
|
3179
|
-
custom_metadata:
|
|
3179
|
+
custom_metadata: t.enterprise ? {
|
|
3180
3180
|
tenant_id: e
|
|
3181
3181
|
} : void 0
|
|
3182
3182
|
},
|
|
@@ -3189,69 +3189,69 @@ function Mn(n) {
|
|
|
3189
3189
|
...s,
|
|
3190
3190
|
primary: !1
|
|
3191
3191
|
});
|
|
3192
|
-
return await
|
|
3192
|
+
return await t.customDomainAdapter.create(e, {
|
|
3193
3193
|
custom_domain_id: i.custom_domain_id,
|
|
3194
3194
|
domain: i.domain,
|
|
3195
3195
|
type: i.type
|
|
3196
3196
|
}), i;
|
|
3197
3197
|
},
|
|
3198
|
-
get: async (e,
|
|
3199
|
-
const s = await
|
|
3198
|
+
get: async (e, n) => {
|
|
3199
|
+
const s = await t.customDomainAdapter.get(
|
|
3200
3200
|
e,
|
|
3201
|
-
|
|
3201
|
+
n
|
|
3202
3202
|
);
|
|
3203
3203
|
if (!s)
|
|
3204
3204
|
throw new te(404);
|
|
3205
|
-
const r = await ne(
|
|
3205
|
+
const r = await ne(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: a, errors: i, success: o } = Be.parse(r);
|
|
3206
3206
|
if (!o)
|
|
3207
3207
|
throw new te(503, {
|
|
3208
3208
|
message: JSON.stringify(i)
|
|
3209
3209
|
});
|
|
3210
|
-
if (
|
|
3210
|
+
if (t.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3211
3211
|
throw new te(404);
|
|
3212
3212
|
return Fe({ ...s, ...a });
|
|
3213
3213
|
},
|
|
3214
|
-
getByDomain: async (e) =>
|
|
3214
|
+
getByDomain: async (e) => t.customDomainAdapter.getByDomain(e),
|
|
3215
3215
|
list: async (e) => {
|
|
3216
|
-
const
|
|
3216
|
+
const n = await t.customDomainAdapter.list(e), s = await ne(t).get("/custom_hostnames").json(), { result: r, errors: a, success: i } = Pn.parse(s);
|
|
3217
3217
|
if (!i)
|
|
3218
3218
|
throw new te(503, {
|
|
3219
3219
|
message: JSON.stringify(a)
|
|
3220
3220
|
});
|
|
3221
3221
|
return r.filter(
|
|
3222
|
-
(o) =>
|
|
3222
|
+
(o) => n.find((c) => c.custom_domain_id === o.id)
|
|
3223
3223
|
).filter(
|
|
3224
|
-
(o) => !(
|
|
3224
|
+
(o) => !(t.enterprise && o.custom_metadata?.tenant_id !== e)
|
|
3225
3225
|
).map(
|
|
3226
3226
|
(o) => Fe({
|
|
3227
|
-
...
|
|
3227
|
+
...n.find((c) => c.custom_domain_id === o.id),
|
|
3228
3228
|
...o
|
|
3229
3229
|
})
|
|
3230
3230
|
);
|
|
3231
3231
|
},
|
|
3232
|
-
remove: async (e,
|
|
3233
|
-
if (
|
|
3234
|
-
const { result: r, success: a } =
|
|
3235
|
-
await ne(
|
|
3232
|
+
remove: async (e, n) => {
|
|
3233
|
+
if (t.enterprise) {
|
|
3234
|
+
const { result: r, success: a } = Be.parse(
|
|
3235
|
+
await ne(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json()
|
|
3236
3236
|
);
|
|
3237
3237
|
if (!a || r.custom_metadata?.tenant_id !== e)
|
|
3238
3238
|
throw new te(404);
|
|
3239
3239
|
}
|
|
3240
|
-
const s = await ne(
|
|
3241
|
-
return s.ok && await
|
|
3240
|
+
const s = await ne(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
|
|
3241
|
+
return s.ok && await t.customDomainAdapter.remove(e, n), s.ok;
|
|
3242
3242
|
},
|
|
3243
|
-
update: async (e,
|
|
3244
|
-
const r = await ne(
|
|
3243
|
+
update: async (e, n, s) => {
|
|
3244
|
+
const r = await ne(t).patch(
|
|
3245
3245
|
s,
|
|
3246
|
-
`/custom_hostnames/${encodeURIComponent(
|
|
3246
|
+
`/custom_hostnames/${encodeURIComponent(n)}`
|
|
3247
3247
|
).res();
|
|
3248
3248
|
if (!r.ok)
|
|
3249
3249
|
throw new te(503, {
|
|
3250
3250
|
message: await r.text()
|
|
3251
3251
|
});
|
|
3252
|
-
return
|
|
3252
|
+
return t.customDomainAdapter.update(
|
|
3253
3253
|
e,
|
|
3254
|
-
|
|
3254
|
+
n,
|
|
3255
3255
|
s
|
|
3256
3256
|
);
|
|
3257
3257
|
}
|
|
@@ -3279,19 +3279,19 @@ class Dn {
|
|
|
3279
3279
|
}
|
|
3280
3280
|
async get(e) {
|
|
3281
3281
|
try {
|
|
3282
|
-
const
|
|
3282
|
+
const n = await this.getCache(), s = this.createRequest(e), r = await n.match(s);
|
|
3283
3283
|
if (!r)
|
|
3284
3284
|
return null;
|
|
3285
3285
|
const a = await r.json();
|
|
3286
3286
|
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}:`,
|
|
3287
|
+
} catch (n) {
|
|
3288
|
+
return console.error(`CloudflareCache: get error for key ${e}:`, n), null;
|
|
3289
3289
|
}
|
|
3290
3290
|
}
|
|
3291
|
-
async set(e,
|
|
3291
|
+
async set(e, n, s) {
|
|
3292
3292
|
try {
|
|
3293
3293
|
const r = await this.getCache(), a = s ?? this.config.defaultTtlSeconds, i = a !== void 0, o = i ? Math.max(0, a) : 0, c = {
|
|
3294
|
-
value:
|
|
3294
|
+
value: n,
|
|
3295
3295
|
expiresAt: i ? new Date(Date.now() + (o > 0 ? o * 1e3 : -1)).toISOString() : void 0,
|
|
3296
3296
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3297
3297
|
}, d = this.createRequest(e), p = {
|
|
@@ -3308,10 +3308,10 @@ class Dn {
|
|
|
3308
3308
|
}
|
|
3309
3309
|
async delete(e) {
|
|
3310
3310
|
try {
|
|
3311
|
-
const
|
|
3312
|
-
return await
|
|
3313
|
-
} catch (
|
|
3314
|
-
return console.error(`CloudflareCache: delete error for key ${e}:`,
|
|
3311
|
+
const n = await this.getCache(), s = this.createRequest(e);
|
|
3312
|
+
return await n.delete(s);
|
|
3313
|
+
} catch (n) {
|
|
3314
|
+
return console.error(`CloudflareCache: delete error for key ${e}:`, n), !1;
|
|
3315
3315
|
}
|
|
3316
3316
|
}
|
|
3317
3317
|
async clear() {
|
|
@@ -3320,32 +3320,32 @@ class Dn {
|
|
|
3320
3320
|
);
|
|
3321
3321
|
}
|
|
3322
3322
|
}
|
|
3323
|
-
function Ln(
|
|
3323
|
+
function Ln(t = {}) {
|
|
3324
3324
|
const e = {
|
|
3325
3325
|
defaultTtlSeconds: 300,
|
|
3326
3326
|
// 5 minutes default
|
|
3327
3327
|
keyPrefix: "authhero",
|
|
3328
3328
|
// default prefix
|
|
3329
|
-
...
|
|
3329
|
+
...t
|
|
3330
3330
|
// user config overrides defaults
|
|
3331
3331
|
};
|
|
3332
3332
|
return new Dn(e);
|
|
3333
3333
|
}
|
|
3334
3334
|
const Vn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3335
|
-
let Un = (
|
|
3336
|
-
let e = "",
|
|
3337
|
-
for (;
|
|
3338
|
-
e += Vn[t
|
|
3335
|
+
let Un = (t = 21) => {
|
|
3336
|
+
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
3337
|
+
for (; t--; )
|
|
3338
|
+
e += Vn[n[t] & 63];
|
|
3339
3339
|
return e;
|
|
3340
3340
|
};
|
|
3341
|
-
async function Je(
|
|
3342
|
-
const
|
|
3341
|
+
async function Je(t, e) {
|
|
3342
|
+
const n = t.timeout || 3e4, s = new AbortController(), r = setTimeout(() => s.abort(), n);
|
|
3343
3343
|
try {
|
|
3344
|
-
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${
|
|
3344
|
+
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`, i = await fetch(a, {
|
|
3345
3345
|
method: "POST",
|
|
3346
3346
|
headers: {
|
|
3347
3347
|
"Content-Type": "application/json",
|
|
3348
|
-
Authorization: `Bearer ${
|
|
3348
|
+
Authorization: `Bearer ${t.authToken}`
|
|
3349
3349
|
},
|
|
3350
3350
|
// Request body should be shaped as { "query": "..." }
|
|
3351
3351
|
body: JSON.stringify({
|
|
@@ -3365,30 +3365,82 @@ async function Je(n, e) {
|
|
|
3365
3365
|
clearTimeout(r);
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
|
-
function Ze(
|
|
3369
|
-
return `'${
|
|
3368
|
+
function Ze(t) {
|
|
3369
|
+
return `'${t.replace(/'/g, "''")}'`;
|
|
3370
3370
|
}
|
|
3371
|
-
function
|
|
3372
|
-
return `"${
|
|
3371
|
+
function z(t) {
|
|
3372
|
+
return `"${t.replace(/"/g, '""')}"`;
|
|
3373
3373
|
}
|
|
3374
|
-
function ut(
|
|
3375
|
-
const e = (
|
|
3376
|
-
if (!
|
|
3374
|
+
function ut(t) {
|
|
3375
|
+
const e = (n) => {
|
|
3376
|
+
if (!n)
|
|
3377
3377
|
return "";
|
|
3378
3378
|
try {
|
|
3379
|
-
return JSON.parse(
|
|
3379
|
+
return JSON.parse(n);
|
|
3380
3380
|
} catch {
|
|
3381
|
-
return
|
|
3381
|
+
return n;
|
|
3382
3382
|
}
|
|
3383
3383
|
};
|
|
3384
3384
|
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,
|
|
3385
3437
|
type: n.type,
|
|
3386
3438
|
date: n.date,
|
|
3387
|
-
description: n.description,
|
|
3439
|
+
description: n.description?.substring(0, 256),
|
|
3388
3440
|
ip: n.ip,
|
|
3389
3441
|
user_agent: n.user_agent,
|
|
3390
|
-
details:
|
|
3391
|
-
isMobile:
|
|
3442
|
+
details: s(n.details)?.substring(0, 8192),
|
|
3443
|
+
isMobile: n.isMobile ? 1 : 0,
|
|
3392
3444
|
user_id: n.user_id,
|
|
3393
3445
|
user_name: n.user_name,
|
|
3394
3446
|
connection: n.connection,
|
|
@@ -3400,122 +3452,86 @@ function ut(n) {
|
|
|
3400
3452
|
strategy: n.strategy,
|
|
3401
3453
|
strategy_type: n.strategy_type,
|
|
3402
3454
|
hostname: n.hostname,
|
|
3403
|
-
auth0_client:
|
|
3404
|
-
log_id: n.
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
}
|
|
3415
|
-
const s = t.log_id || Un(), r = {
|
|
3416
|
-
...t,
|
|
3417
|
-
log_id: s
|
|
3418
|
-
};
|
|
3419
|
-
return await tt(n, e, r), console.log("Log sent to Pipeline with ID:", s), r;
|
|
3455
|
+
auth0_client: s(n.auth0_client),
|
|
3456
|
+
log_id: n.log_id,
|
|
3457
|
+
// Geo fields from location_info
|
|
3458
|
+
country_code: n.location_info?.country_code,
|
|
3459
|
+
country_code3: n.location_info?.country_code3,
|
|
3460
|
+
country_name: n.location_info?.country_name,
|
|
3461
|
+
city_name: n.location_info?.city_name,
|
|
3462
|
+
latitude: n.location_info?.latitude,
|
|
3463
|
+
longitude: n.location_info?.longitude,
|
|
3464
|
+
time_zone: n.location_info?.time_zone,
|
|
3465
|
+
continent_code: n.location_info?.continent_code
|
|
3420
3466
|
};
|
|
3421
|
-
}
|
|
3422
|
-
async function tt(n, e, t) {
|
|
3423
|
-
const s = (c) => c ? JSON.stringify(c) : void 0, r = {
|
|
3424
|
-
id: t.log_id,
|
|
3425
|
-
tenant_id: e,
|
|
3426
|
-
type: t.type,
|
|
3427
|
-
date: t.date,
|
|
3428
|
-
description: t.description?.substring(0, 256),
|
|
3429
|
-
ip: t.ip,
|
|
3430
|
-
user_agent: t.user_agent,
|
|
3431
|
-
details: s(t.details)?.substring(0, 8192),
|
|
3432
|
-
isMobile: t.isMobile ? 1 : 0,
|
|
3433
|
-
user_id: t.user_id,
|
|
3434
|
-
user_name: t.user_name,
|
|
3435
|
-
connection: t.connection,
|
|
3436
|
-
connection_id: t.connection_id,
|
|
3437
|
-
client_id: t.client_id,
|
|
3438
|
-
client_name: t.client_name,
|
|
3439
|
-
audience: t.audience,
|
|
3440
|
-
scope: t.scope,
|
|
3441
|
-
strategy: t.strategy,
|
|
3442
|
-
strategy_type: t.strategy_type,
|
|
3443
|
-
hostname: t.hostname,
|
|
3444
|
-
auth0_client: s(t.auth0_client),
|
|
3445
|
-
log_id: t.log_id
|
|
3446
|
-
}, a = n.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), a);
|
|
3447
3467
|
try {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
}
|
|
3469
|
-
else
|
|
3468
|
+
if (t.pipelineBinding)
|
|
3469
|
+
await t.pipelineBinding.send(r);
|
|
3470
|
+
else if (t.pipelineEndpoint) {
|
|
3471
|
+
const a = t.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), a);
|
|
3472
|
+
try {
|
|
3473
|
+
const c = await fetch(t.pipelineEndpoint, {
|
|
3474
|
+
method: "POST",
|
|
3475
|
+
headers: {
|
|
3476
|
+
"Content-Type": "application/json"
|
|
3477
|
+
},
|
|
3478
|
+
body: JSON.stringify([r]),
|
|
3479
|
+
// Pipelines accept array of records
|
|
3480
|
+
signal: i.signal
|
|
3481
|
+
});
|
|
3482
|
+
if (!c.ok)
|
|
3483
|
+
throw new Error(
|
|
3484
|
+
`Pipeline ingestion failed: ${c.status} ${c.statusText}`
|
|
3485
|
+
);
|
|
3486
|
+
} finally {
|
|
3487
|
+
clearTimeout(o);
|
|
3488
|
+
}
|
|
3489
|
+
} else
|
|
3470
3490
|
throw new Error(
|
|
3471
3491
|
"Either pipelineEndpoint or pipelineBinding must be configured"
|
|
3472
3492
|
);
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
`Pipeline ingestion failed: ${c.status} ${c.statusText}`
|
|
3476
|
-
);
|
|
3477
|
-
} finally {
|
|
3478
|
-
clearTimeout(o);
|
|
3493
|
+
} catch (a) {
|
|
3494
|
+
throw console.error("Failed to send log to Pipeline:", a), a;
|
|
3479
3495
|
}
|
|
3480
3496
|
}
|
|
3481
|
-
function
|
|
3482
|
-
return async (e,
|
|
3483
|
-
if (
|
|
3484
|
-
return
|
|
3485
|
-
const s =
|
|
3486
|
-
SELECT * FROM ${
|
|
3497
|
+
function Bn(t) {
|
|
3498
|
+
return async (e, n) => {
|
|
3499
|
+
if (t.baseAdapter)
|
|
3500
|
+
return t.baseAdapter.get(e, n);
|
|
3501
|
+
const s = t.namespace || "default", r = t.tableName || "logs", a = `
|
|
3502
|
+
SELECT * FROM ${z(s)}.${z(r)}
|
|
3487
3503
|
WHERE tenant_id = ${Ze(e)}
|
|
3488
|
-
AND id = ${Ze(
|
|
3504
|
+
AND id = ${Ze(n)}
|
|
3489
3505
|
LIMIT 1
|
|
3490
|
-
`, i = await Je(
|
|
3506
|
+
`, i = await Je(t, a);
|
|
3491
3507
|
if (i.length === 0)
|
|
3492
3508
|
return null;
|
|
3493
3509
|
const o = i[0];
|
|
3494
3510
|
return o ? ut(o) : null;
|
|
3495
3511
|
};
|
|
3496
3512
|
}
|
|
3497
|
-
function Fn(
|
|
3513
|
+
function Fn(t) {
|
|
3498
3514
|
const e = {};
|
|
3499
|
-
return (
|
|
3515
|
+
return (t.match(/(\w+):(\S+)/g) || []).forEach((s) => {
|
|
3500
3516
|
const [r, a] = s.split(":");
|
|
3501
3517
|
r && a && (e[r] = a);
|
|
3502
3518
|
}), e;
|
|
3503
3519
|
}
|
|
3504
|
-
function qn(
|
|
3520
|
+
function qn(t) {
|
|
3505
3521
|
const e = [];
|
|
3506
|
-
for (const [
|
|
3507
|
-
const r =
|
|
3522
|
+
for (const [n, s] of Object.entries(t)) {
|
|
3523
|
+
const r = n.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3508
3524
|
r && s && e.push(
|
|
3509
|
-
`${
|
|
3525
|
+
`${z(r)} = ${Ze(s)}`
|
|
3510
3526
|
);
|
|
3511
3527
|
}
|
|
3512
3528
|
return e;
|
|
3513
3529
|
}
|
|
3514
|
-
function Hn(
|
|
3515
|
-
return async (e,
|
|
3516
|
-
if (
|
|
3517
|
-
return
|
|
3518
|
-
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } =
|
|
3530
|
+
function Hn(t) {
|
|
3531
|
+
return async (e, n = {}) => {
|
|
3532
|
+
if (t.baseAdapter)
|
|
3533
|
+
return t.baseAdapter.list(e, n);
|
|
3534
|
+
const { page: s = 0, per_page: r = 50, include_totals: a = !1, sort: i, q: o } = n, c = t.namespace || "default", d = t.tableName || "logs", p = [
|
|
3519
3535
|
`tenant_id = ${Ze(e)}`
|
|
3520
3536
|
];
|
|
3521
3537
|
if (o) {
|
|
@@ -3526,14 +3542,14 @@ function Hn(n) {
|
|
|
3526
3542
|
let C = "ORDER BY date DESC";
|
|
3527
3543
|
if (i && i.sort_by) {
|
|
3528
3544
|
const J = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), ue = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3529
|
-
C = `ORDER BY ${
|
|
3545
|
+
C = `ORDER BY ${z(J)} ${ue}`;
|
|
3530
3546
|
}
|
|
3531
|
-
const w = s * r,
|
|
3532
|
-
SELECT * FROM ${
|
|
3547
|
+
const w = s * r, j = `LIMIT ${r} OFFSET ${w}`, de = `
|
|
3548
|
+
SELECT * FROM ${z(c)}.${z(d)}
|
|
3533
3549
|
WHERE ${b}
|
|
3534
3550
|
${C}
|
|
3535
|
-
${
|
|
3536
|
-
`, W = (await Je(
|
|
3551
|
+
${j}
|
|
3552
|
+
`, W = (await Je(t, de)).map(ut);
|
|
3537
3553
|
if (!a)
|
|
3538
3554
|
return {
|
|
3539
3555
|
logs: W,
|
|
@@ -3542,9 +3558,9 @@ function Hn(n) {
|
|
|
3542
3558
|
length: 0
|
|
3543
3559
|
};
|
|
3544
3560
|
const D = `
|
|
3545
|
-
SELECT COUNT(*) as count FROM ${
|
|
3561
|
+
SELECT COUNT(*) as count FROM ${z(c)}.${z(d)}
|
|
3546
3562
|
WHERE ${b}
|
|
3547
|
-
`, G = (await Je(
|
|
3563
|
+
`, G = (await Je(t, D))[0]?.count || 0;
|
|
3548
3564
|
return {
|
|
3549
3565
|
logs: W,
|
|
3550
3566
|
start: w,
|
|
@@ -3553,36 +3569,36 @@ function Hn(n) {
|
|
|
3553
3569
|
};
|
|
3554
3570
|
};
|
|
3555
3571
|
}
|
|
3556
|
-
function Wn(
|
|
3557
|
-
const e = !!
|
|
3558
|
-
if (!e && !
|
|
3572
|
+
function Wn(t) {
|
|
3573
|
+
const e = !!t.baseAdapter, n = !!t.pipelineEndpoint, s = !!t.pipelineBinding;
|
|
3574
|
+
if (!e && !n && !s)
|
|
3559
3575
|
throw new Error(
|
|
3560
3576
|
'R2 SQL logs adapter requires one of: "baseAdapter", "pipelineEndpoint", or "pipelineBinding"'
|
|
3561
3577
|
);
|
|
3562
3578
|
if (!e) {
|
|
3563
|
-
if (!
|
|
3579
|
+
if (!t.authToken)
|
|
3564
3580
|
throw new Error('R2 SQL logs adapter requires "authToken" configuration');
|
|
3565
|
-
if (!
|
|
3581
|
+
if (!t.warehouseName)
|
|
3566
3582
|
throw new Error(
|
|
3567
3583
|
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3568
3584
|
);
|
|
3569
3585
|
}
|
|
3570
3586
|
return {
|
|
3571
|
-
create:
|
|
3572
|
-
list: Hn(
|
|
3573
|
-
get:
|
|
3587
|
+
create: zn(t),
|
|
3588
|
+
list: Hn(t),
|
|
3589
|
+
get: Bn(t)
|
|
3574
3590
|
};
|
|
3575
3591
|
}
|
|
3576
|
-
function Gn(
|
|
3592
|
+
function Gn(t) {
|
|
3577
3593
|
return {
|
|
3578
3594
|
async getGeoInfo() {
|
|
3579
3595
|
try {
|
|
3580
|
-
const e =
|
|
3581
|
-
if (!
|
|
3596
|
+
const e = t.getHeaders(), n = e["cf-ipcountry"], s = e["cf-ipcity"], r = e["cf-iplatitude"], a = e["cf-iplongitude"], i = e["cf-timezone"], o = e["cf-ipcontinent"];
|
|
3597
|
+
if (!n)
|
|
3582
3598
|
return null;
|
|
3583
|
-
const c = Jn(
|
|
3599
|
+
const c = Jn(n), d = Kn(n);
|
|
3584
3600
|
return {
|
|
3585
|
-
country_code:
|
|
3601
|
+
country_code: n,
|
|
3586
3602
|
country_code3: c,
|
|
3587
3603
|
country_name: d,
|
|
3588
3604
|
city_name: s || "",
|
|
@@ -3597,7 +3613,7 @@ function Gn(n) {
|
|
|
3597
3613
|
}
|
|
3598
3614
|
};
|
|
3599
3615
|
}
|
|
3600
|
-
function Jn(
|
|
3616
|
+
function Jn(t) {
|
|
3601
3617
|
return {
|
|
3602
3618
|
// North America
|
|
3603
3619
|
US: "USA",
|
|
@@ -3656,9 +3672,9 @@ function Jn(n) {
|
|
|
3656
3672
|
IL: "ISR",
|
|
3657
3673
|
TR: "TUR",
|
|
3658
3674
|
IR: "IRN"
|
|
3659
|
-
}[
|
|
3675
|
+
}[t] || (t.length === 2 ? t + t.charAt(1) : t);
|
|
3660
3676
|
}
|
|
3661
|
-
function Kn(
|
|
3677
|
+
function Kn(t) {
|
|
3662
3678
|
return {
|
|
3663
3679
|
// North America
|
|
3664
3680
|
US: "United States",
|
|
@@ -3717,22 +3733,22 @@ function Kn(n) {
|
|
|
3717
3733
|
IL: "Israel",
|
|
3718
3734
|
TR: "Turkey",
|
|
3719
3735
|
IR: "Iran"
|
|
3720
|
-
}[
|
|
3736
|
+
}[t] || t;
|
|
3721
3737
|
}
|
|
3722
|
-
function Xn(
|
|
3738
|
+
function Xn(t) {
|
|
3723
3739
|
const e = {
|
|
3724
|
-
customDomains: Mn(
|
|
3740
|
+
customDomains: Mn(t),
|
|
3725
3741
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
3726
3742
|
cache: Ln({
|
|
3727
|
-
...
|
|
3728
|
-
...
|
|
3729
|
-
defaultTtlSeconds:
|
|
3743
|
+
...t.cacheName && { cacheName: t.cacheName },
|
|
3744
|
+
...t.defaultTtlSeconds !== void 0 && {
|
|
3745
|
+
defaultTtlSeconds: t.defaultTtlSeconds
|
|
3730
3746
|
},
|
|
3731
|
-
...
|
|
3747
|
+
...t.keyPrefix && { keyPrefix: t.keyPrefix }
|
|
3732
3748
|
})
|
|
3733
3749
|
};
|
|
3734
|
-
return
|
|
3735
|
-
getHeaders:
|
|
3750
|
+
return t.r2SqlLogs && (e.logs = Wn(t.r2SqlLogs)), t.getHeaders && (e.geo = Gn({
|
|
3751
|
+
getHeaders: t.getHeaders
|
|
3736
3752
|
})), e;
|
|
3737
3753
|
}
|
|
3738
3754
|
export {
|