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