@authhero/cloudflare-adapter 2.7.6 → 2.8.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 +422 -2
- package/dist/cloudflare-adapter.cjs +14 -1
- package/dist/cloudflare-adapter.d.ts +282 -2
- package/dist/cloudflare-adapter.mjs +1111 -878
- 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(s, e) {
|
|
7
4
|
var t = {};
|
|
8
|
-
for (var
|
|
9
|
-
if (
|
|
10
|
-
for (var n = 0,
|
|
11
|
-
e.indexOf(
|
|
5
|
+
for (var r in s) Object.prototype.hasOwnProperty.call(s, r) && e.indexOf(r) < 0 && (t[r] = s[r]);
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
7
|
+
for (var n = 0, r = Object.getOwnPropertySymbols(s); n < r.length; n++)
|
|
8
|
+
e.indexOf(r[n]) < 0 && Object.prototype.propertyIsEnumerable.call(s, r[n]) && (t[r[n]] = s[r[n]]);
|
|
12
9
|
return t;
|
|
13
10
|
}
|
|
14
|
-
function
|
|
11
|
+
function pt(s, e) {
|
|
15
12
|
var t;
|
|
16
|
-
return ((t =
|
|
13
|
+
return ((t = s?._def) === null || t === void 0 ? void 0 : t.typeName) === e;
|
|
17
14
|
}
|
|
18
|
-
function
|
|
19
|
-
const t =
|
|
20
|
-
|
|
21
|
-
const n = t.apply(this,
|
|
15
|
+
function le(s, e) {
|
|
16
|
+
const t = s.ZodType.prototype[e];
|
|
17
|
+
s.ZodType.prototype[e] = function(...r) {
|
|
18
|
+
const n = t.apply(this, r);
|
|
22
19
|
return n._def.openapi = this._def.openapi, n;
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
function
|
|
26
|
-
if (typeof
|
|
22
|
+
function mt(s) {
|
|
23
|
+
if (typeof s.ZodType.prototype.openapi < "u")
|
|
27
24
|
return;
|
|
28
|
-
|
|
25
|
+
s.ZodType.prototype.openapi = function(n, a) {
|
|
29
26
|
var i, o, c, u, p, b;
|
|
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
|
|
27
|
+
const C = typeof n == "string" ? a : n, w = C ?? {}, { param: Z } = w, de = ht(w, ["param"]), M = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof n == "string" ? { refId: n } : void 0), J = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), de), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || Z ? {
|
|
28
|
+
param: Object.assign(Object.assign({}, (b = (p = this._def.openapi) === null || p === void 0 ? void 0 : p.metadata) === null || b === void 0 ? void 0 : b.param), Z)
|
|
29
|
+
} : void 0), D = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(M).length > 0 ? { _internal: M } : void 0), Object.keys(J).length > 0 ? { metadata: J } : void 0) }));
|
|
30
|
+
if (pt(this, "ZodObject")) {
|
|
31
|
+
const ee = this.extend;
|
|
32
|
+
D.extend = function(...Q) {
|
|
33
|
+
var H, ue, Pe, Me, De, Le, Ve;
|
|
34
|
+
const ze = ee.apply(this, Q);
|
|
35
|
+
return ze._def.openapi = {
|
|
39
36
|
_internal: {
|
|
40
|
-
extendedFrom: !((
|
|
37
|
+
extendedFrom: !((ue = (H = this._def.openapi) === null || H === void 0 ? void 0 : H._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 = ze._def.openapi) === null || Ve === void 0 ? void 0 : Ve.metadata
|
|
40
|
+
}, ze;
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
return
|
|
47
|
-
},
|
|
48
|
-
const e =
|
|
49
|
-
|
|
43
|
+
return D;
|
|
44
|
+
}, le(s, "optional"), le(s, "nullable"), le(s, "default"), le(s, "transform"), le(s, "refine");
|
|
45
|
+
const e = s.ZodObject.prototype.deepPartial;
|
|
46
|
+
s.ZodObject.prototype.deepPartial = function() {
|
|
50
47
|
const n = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
51
48
|
return Object.entries(i).forEach(([o, c]) => {
|
|
52
49
|
var u, p;
|
|
53
50
|
c._def.openapi = (p = (u = n[o]) === null || u === void 0 ? void 0 : u._def) === null || p === void 0 ? void 0 : p.openapi;
|
|
54
51
|
}), a._def.openapi = void 0, a;
|
|
55
52
|
};
|
|
56
|
-
const t =
|
|
57
|
-
|
|
53
|
+
const t = s.ZodObject.prototype.pick;
|
|
54
|
+
s.ZodObject.prototype.pick = function(...n) {
|
|
58
55
|
const a = t.apply(this, n);
|
|
59
56
|
return a._def.openapi = void 0, a;
|
|
60
57
|
};
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const a =
|
|
58
|
+
const r = s.ZodObject.prototype.omit;
|
|
59
|
+
s.ZodObject.prototype.omit = function(...n) {
|
|
60
|
+
const a = r.apply(this, n);
|
|
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(s = 500, e) {
|
|
68
|
+
super(e?.message, { cause: e?.cause }), this.res = e?.res, this.status = s;
|
|
73
69
|
}
|
|
74
70
|
getResponse() {
|
|
75
71
|
return this.res ? new Response(this.res.body, {
|
|
@@ -82,45 +78,45 @@ var G = class extends Error {
|
|
|
82
78
|
};
|
|
83
79
|
new Set(".\\+*[^]$()");
|
|
84
80
|
var x;
|
|
85
|
-
(function(
|
|
86
|
-
|
|
81
|
+
(function(s) {
|
|
82
|
+
s.assertEqual = (n) => {
|
|
87
83
|
};
|
|
88
84
|
function e(n) {
|
|
89
85
|
}
|
|
90
|
-
|
|
86
|
+
s.assertIs = e;
|
|
91
87
|
function t(n) {
|
|
92
88
|
throw new Error();
|
|
93
89
|
}
|
|
94
|
-
|
|
90
|
+
s.assertNever = t, s.arrayToEnum = (n) => {
|
|
95
91
|
const a = {};
|
|
96
92
|
for (const i of n)
|
|
97
93
|
a[i] = i;
|
|
98
94
|
return a;
|
|
99
|
-
},
|
|
100
|
-
const a =
|
|
95
|
+
}, s.getValidEnumValues = (n) => {
|
|
96
|
+
const a = s.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
101
97
|
for (const o of a)
|
|
102
98
|
i[o] = n[o];
|
|
103
|
-
return
|
|
104
|
-
},
|
|
99
|
+
return s.objectValues(i);
|
|
100
|
+
}, s.objectValues = (n) => s.objectKeys(n).map(function(a) {
|
|
105
101
|
return n[a];
|
|
106
|
-
}),
|
|
102
|
+
}), s.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
107
103
|
const a = [];
|
|
108
104
|
for (const i in n)
|
|
109
105
|
Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
|
|
110
106
|
return a;
|
|
111
|
-
},
|
|
107
|
+
}, s.find = (n, a) => {
|
|
112
108
|
for (const i of n)
|
|
113
109
|
if (a(i))
|
|
114
110
|
return i;
|
|
115
|
-
},
|
|
116
|
-
function
|
|
111
|
+
}, s.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
112
|
+
function r(n, a = " | ") {
|
|
117
113
|
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
118
114
|
}
|
|
119
|
-
|
|
115
|
+
s.joinValues = r, s.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
120
116
|
})(x || (x = {}));
|
|
121
117
|
var Fe;
|
|
122
|
-
(function(
|
|
123
|
-
|
|
118
|
+
(function(s) {
|
|
119
|
+
s.mergeShapes = (e, t) => ({
|
|
124
120
|
...e,
|
|
125
121
|
...t
|
|
126
122
|
// second overwrites first
|
|
@@ -147,14 +143,14 @@ const f = x.arrayToEnum([
|
|
|
147
143
|
"never",
|
|
148
144
|
"map",
|
|
149
145
|
"set"
|
|
150
|
-
]),
|
|
151
|
-
switch (typeof
|
|
146
|
+
]), V = (s) => {
|
|
147
|
+
switch (typeof s) {
|
|
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(s) ? f.nan : f.number;
|
|
158
154
|
case "boolean":
|
|
159
155
|
return f.boolean;
|
|
160
156
|
case "function":
|
|
@@ -164,7 +160,7 @@ 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(s) ? f.array : s === null ? f.null : s.then && typeof s.then == "function" && s.catch && typeof s.catch == "function" ? f.promise : typeof Map < "u" && s instanceof Map ? f.map : typeof Set < "u" && s instanceof Set ? f.set : typeof Date < "u" && s instanceof Date ? f.date : f.object;
|
|
168
164
|
default:
|
|
169
165
|
return f.unknown;
|
|
170
166
|
}
|
|
@@ -185,16 +181,16 @@ const f = x.arrayToEnum([
|
|
|
185
181
|
"invalid_intersection_types",
|
|
186
182
|
"not_multiple_of",
|
|
187
183
|
"not_finite"
|
|
188
|
-
]),
|
|
189
|
-
class
|
|
184
|
+
]), yt = (s) => JSON.stringify(s, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
185
|
+
class O extends Error {
|
|
190
186
|
get errors() {
|
|
191
187
|
return this.issues;
|
|
192
188
|
}
|
|
193
189
|
constructor(e) {
|
|
194
|
-
super(), this.issues = [], this.addIssue = (
|
|
195
|
-
this.issues = [...this.issues,
|
|
196
|
-
}, this.addIssues = (
|
|
197
|
-
this.issues = [...this.issues, ...
|
|
190
|
+
super(), this.issues = [], this.addIssue = (r) => {
|
|
191
|
+
this.issues = [...this.issues, r];
|
|
192
|
+
}, this.addIssues = (r = []) => {
|
|
193
|
+
this.issues = [...this.issues, ...r];
|
|
198
194
|
};
|
|
199
195
|
const t = new.target.prototype;
|
|
200
196
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -202,7 +198,7 @@ class S extends Error {
|
|
|
202
198
|
format(e) {
|
|
203
199
|
const t = e || function(a) {
|
|
204
200
|
return a.message;
|
|
205
|
-
},
|
|
201
|
+
}, r = { _errors: [] }, n = (a) => {
|
|
206
202
|
for (const i of a.issues)
|
|
207
203
|
if (i.code === "invalid_union")
|
|
208
204
|
i.unionErrors.map(n);
|
|
@@ -211,19 +207,19 @@ class S extends Error {
|
|
|
211
207
|
else if (i.code === "invalid_arguments")
|
|
212
208
|
n(i.argumentsError);
|
|
213
209
|
else if (i.path.length === 0)
|
|
214
|
-
|
|
210
|
+
r._errors.push(t(i));
|
|
215
211
|
else {
|
|
216
|
-
let o =
|
|
212
|
+
let o = r, c = 0;
|
|
217
213
|
for (; c < i.path.length; ) {
|
|
218
214
|
const u = i.path[c];
|
|
219
215
|
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
|
|
220
216
|
}
|
|
221
217
|
}
|
|
222
218
|
};
|
|
223
|
-
return n(this),
|
|
219
|
+
return n(this), r;
|
|
224
220
|
}
|
|
225
221
|
static assert(e) {
|
|
226
|
-
if (!(e instanceof
|
|
222
|
+
if (!(e instanceof O))
|
|
227
223
|
throw new Error(`Not a ZodError: ${e}`);
|
|
228
224
|
}
|
|
229
225
|
toString() {
|
|
@@ -236,40 +232,40 @@ class S extends Error {
|
|
|
236
232
|
return this.issues.length === 0;
|
|
237
233
|
}
|
|
238
234
|
flatten(e = (t) => t.message) {
|
|
239
|
-
const t = {},
|
|
235
|
+
const t = {}, r = [];
|
|
240
236
|
for (const n of this.issues)
|
|
241
237
|
if (n.path.length > 0) {
|
|
242
238
|
const a = n.path[0];
|
|
243
239
|
t[a] = t[a] || [], t[a].push(e(n));
|
|
244
240
|
} else
|
|
245
|
-
|
|
246
|
-
return { formErrors:
|
|
241
|
+
r.push(e(n));
|
|
242
|
+
return { formErrors: r, fieldErrors: t };
|
|
247
243
|
}
|
|
248
244
|
get formErrors() {
|
|
249
245
|
return this.flatten();
|
|
250
246
|
}
|
|
251
247
|
}
|
|
252
|
-
|
|
253
|
-
const
|
|
248
|
+
O.create = (s) => new O(s);
|
|
249
|
+
const ie = (s, e) => {
|
|
254
250
|
let t;
|
|
255
|
-
switch (
|
|
251
|
+
switch (s.code) {
|
|
256
252
|
case d.invalid_type:
|
|
257
|
-
|
|
253
|
+
s.received === f.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
|
|
258
254
|
break;
|
|
259
255
|
case d.invalid_literal:
|
|
260
|
-
t = `Invalid literal value, expected ${JSON.stringify(
|
|
256
|
+
t = `Invalid literal value, expected ${JSON.stringify(s.expected, x.jsonStringifyReplacer)}`;
|
|
261
257
|
break;
|
|
262
258
|
case d.unrecognized_keys:
|
|
263
|
-
t = `Unrecognized key(s) in object: ${x.joinValues(
|
|
259
|
+
t = `Unrecognized key(s) in object: ${x.joinValues(s.keys, ", ")}`;
|
|
264
260
|
break;
|
|
265
261
|
case d.invalid_union:
|
|
266
262
|
t = "Invalid input";
|
|
267
263
|
break;
|
|
268
264
|
case d.invalid_union_discriminator:
|
|
269
|
-
t = `Invalid discriminator value. Expected ${x.joinValues(
|
|
265
|
+
t = `Invalid discriminator value. Expected ${x.joinValues(s.options)}`;
|
|
270
266
|
break;
|
|
271
267
|
case d.invalid_enum_value:
|
|
272
|
-
t = `Invalid enum value. Expected ${x.joinValues(
|
|
268
|
+
t = `Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;
|
|
273
269
|
break;
|
|
274
270
|
case d.invalid_arguments:
|
|
275
271
|
t = "Invalid function arguments";
|
|
@@ -281,13 +277,13 @@ const te = (r, e) => {
|
|
|
281
277
|
t = "Invalid date";
|
|
282
278
|
break;
|
|
283
279
|
case d.invalid_string:
|
|
284
|
-
typeof
|
|
280
|
+
typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : x.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
|
|
285
281
|
break;
|
|
286
282
|
case d.too_small:
|
|
287
|
-
|
|
283
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "bigint" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
|
|
288
284
|
break;
|
|
289
285
|
case d.too_big:
|
|
290
|
-
|
|
286
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
|
|
291
287
|
break;
|
|
292
288
|
case d.custom:
|
|
293
289
|
t = "Invalid input";
|
|
@@ -296,25 +292,25 @@ const te = (r, e) => {
|
|
|
296
292
|
t = "Intersection results could not be merged";
|
|
297
293
|
break;
|
|
298
294
|
case d.not_multiple_of:
|
|
299
|
-
t = `Number must be a multiple of ${
|
|
295
|
+
t = `Number must be a multiple of ${s.multipleOf}`;
|
|
300
296
|
break;
|
|
301
297
|
case d.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(s);
|
|
306
302
|
}
|
|
307
303
|
return { message: t };
|
|
308
304
|
};
|
|
309
|
-
let
|
|
310
|
-
function
|
|
311
|
-
|
|
305
|
+
let st = ie;
|
|
306
|
+
function _t(s) {
|
|
307
|
+
st = s;
|
|
312
308
|
}
|
|
313
|
-
function
|
|
314
|
-
return
|
|
309
|
+
function Oe() {
|
|
310
|
+
return st;
|
|
315
311
|
}
|
|
316
|
-
const
|
|
317
|
-
const { data: e, path: t, errorMaps:
|
|
312
|
+
const Ae = (s) => {
|
|
313
|
+
const { data: e, path: t, errorMaps: r, issueData: n } = s, a = [...t, ...n.path || []], i = {
|
|
318
314
|
...n,
|
|
319
315
|
path: a
|
|
320
316
|
};
|
|
@@ -325,7 +321,7 @@ const Ce = (r) => {
|
|
|
325
321
|
message: n.message
|
|
326
322
|
};
|
|
327
323
|
let o = "";
|
|
328
|
-
const c =
|
|
324
|
+
const c = r.filter((u) => !!u).slice().reverse();
|
|
329
325
|
for (const u of c)
|
|
330
326
|
o = u(i, { data: e, defaultError: o }).message;
|
|
331
327
|
return {
|
|
@@ -333,24 +329,24 @@ const Ce = (r) => {
|
|
|
333
329
|
path: a,
|
|
334
330
|
message: o
|
|
335
331
|
};
|
|
336
|
-
},
|
|
337
|
-
function l(
|
|
338
|
-
const t =
|
|
332
|
+
}, gt = [];
|
|
333
|
+
function l(s, e) {
|
|
334
|
+
const t = Oe(), r = Ae({
|
|
339
335
|
issueData: e,
|
|
340
|
-
data:
|
|
341
|
-
path:
|
|
336
|
+
data: s.data,
|
|
337
|
+
path: s.path,
|
|
342
338
|
errorMaps: [
|
|
343
|
-
|
|
339
|
+
s.common.contextualErrorMap,
|
|
344
340
|
// contextual error map is first priority
|
|
345
|
-
|
|
341
|
+
s.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
347
|
].filter((n) => !!n)
|
|
352
348
|
});
|
|
353
|
-
|
|
349
|
+
s.common.issues.push(r);
|
|
354
350
|
}
|
|
355
351
|
class T {
|
|
356
352
|
constructor() {
|
|
@@ -363,75 +359,75 @@ class T {
|
|
|
363
359
|
this.value !== "aborted" && (this.value = "aborted");
|
|
364
360
|
}
|
|
365
361
|
static mergeArray(e, t) {
|
|
366
|
-
const
|
|
362
|
+
const r = [];
|
|
367
363
|
for (const n of t) {
|
|
368
364
|
if (n.status === "aborted")
|
|
369
365
|
return m;
|
|
370
|
-
n.status === "dirty" && e.dirty(),
|
|
366
|
+
n.status === "dirty" && e.dirty(), r.push(n.value);
|
|
371
367
|
}
|
|
372
|
-
return { status: e.value, value:
|
|
368
|
+
return { status: e.value, value: r };
|
|
373
369
|
}
|
|
374
370
|
static async mergeObjectAsync(e, t) {
|
|
375
|
-
const
|
|
371
|
+
const r = [];
|
|
376
372
|
for (const n of t) {
|
|
377
373
|
const a = await n.key, i = await n.value;
|
|
378
|
-
|
|
374
|
+
r.push({
|
|
379
375
|
key: a,
|
|
380
376
|
value: i
|
|
381
377
|
});
|
|
382
378
|
}
|
|
383
|
-
return T.mergeObjectSync(e,
|
|
379
|
+
return T.mergeObjectSync(e, r);
|
|
384
380
|
}
|
|
385
381
|
static mergeObjectSync(e, t) {
|
|
386
|
-
const
|
|
382
|
+
const r = {};
|
|
387
383
|
for (const n of t) {
|
|
388
384
|
const { key: a, value: i } = n;
|
|
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" || n.alwaysSet) && (
|
|
387
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (r[a.value] = i.value);
|
|
392
388
|
}
|
|
393
|
-
return { status: e.value, value:
|
|
389
|
+
return { status: e.value, value: r };
|
|
394
390
|
}
|
|
395
391
|
}
|
|
396
392
|
const m = Object.freeze({
|
|
397
393
|
status: "aborted"
|
|
398
|
-
}),
|
|
394
|
+
}), ne = (s) => ({ status: "dirty", value: s }), S = (s) => ({ status: "valid", value: s }), We = (s) => s.status === "aborted", Je = (s) => s.status === "dirty", K = (s) => s.status === "valid", fe = (s) => typeof Promise < "u" && s instanceof Promise;
|
|
399
395
|
var h;
|
|
400
|
-
(function(
|
|
401
|
-
|
|
396
|
+
(function(s) {
|
|
397
|
+
s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
402
398
|
})(h || (h = {}));
|
|
403
|
-
class
|
|
404
|
-
constructor(e, t,
|
|
405
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
399
|
+
class $ {
|
|
400
|
+
constructor(e, t, r, n) {
|
|
401
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = n;
|
|
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 Ge = (
|
|
412
|
-
if (
|
|
407
|
+
const Ge = (s, e) => {
|
|
408
|
+
if (K(e))
|
|
413
409
|
return { success: !0, data: e.value };
|
|
414
|
-
if (!
|
|
410
|
+
if (!s.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 O(s.common.issues);
|
|
422
418
|
return this._error = t, this._error;
|
|
423
419
|
}
|
|
424
420
|
};
|
|
425
421
|
};
|
|
426
|
-
function _(
|
|
427
|
-
if (!
|
|
422
|
+
function _(s) {
|
|
423
|
+
if (!s)
|
|
428
424
|
return {};
|
|
429
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
430
|
-
if (e && (t ||
|
|
425
|
+
const { errorMap: e, invalid_type_error: t, required_error: r, description: n } = s;
|
|
426
|
+
if (e && (t || r))
|
|
431
427
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
432
428
|
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
433
|
-
const { message: c } =
|
|
434
|
-
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ??
|
|
429
|
+
const { message: c } = s;
|
|
430
|
+
return i.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? r ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? t ?? o.defaultError };
|
|
435
431
|
}, description: n };
|
|
436
432
|
}
|
|
437
433
|
class v {
|
|
@@ -439,13 +435,13 @@ class v {
|
|
|
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
|
}
|
|
@@ -475,28 +471,27 @@ class v {
|
|
|
475
471
|
return Promise.resolve(t);
|
|
476
472
|
}
|
|
477
473
|
parse(e, t) {
|
|
478
|
-
const
|
|
479
|
-
if (
|
|
480
|
-
return
|
|
481
|
-
throw
|
|
474
|
+
const r = this.safeParse(e, t);
|
|
475
|
+
if (r.success)
|
|
476
|
+
return r.data;
|
|
477
|
+
throw r.error;
|
|
482
478
|
}
|
|
483
479
|
safeParse(e, t) {
|
|
484
|
-
const
|
|
480
|
+
const r = {
|
|
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
|
-
}, n = this._parseSync({ data: e, path:
|
|
496
|
-
return Ge(
|
|
490
|
+
parsedType: V(e)
|
|
491
|
+
}, n = this._parseSync({ data: e, path: r.path, parent: r });
|
|
492
|
+
return Ge(r, n);
|
|
497
493
|
}
|
|
498
494
|
"~validate"(e) {
|
|
499
|
-
var s, n;
|
|
500
495
|
const t = {
|
|
501
496
|
common: {
|
|
502
497
|
issues: [],
|
|
@@ -506,61 +501,61 @@ 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 r = this._parseSync({ data: e, path: [], parent: t });
|
|
509
|
+
return K(r) ? {
|
|
510
|
+
value: r.value
|
|
516
511
|
} : {
|
|
517
512
|
issues: t.common.issues
|
|
518
513
|
};
|
|
519
|
-
} catch (
|
|
520
|
-
|
|
514
|
+
} catch (r) {
|
|
515
|
+
r?.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((r) => K(r) ? {
|
|
521
|
+
value: r.value
|
|
527
522
|
} : {
|
|
528
523
|
issues: t.common.issues
|
|
529
524
|
});
|
|
530
525
|
}
|
|
531
526
|
async parseAsync(e, t) {
|
|
532
|
-
const
|
|
533
|
-
if (
|
|
534
|
-
return
|
|
535
|
-
throw
|
|
527
|
+
const r = await this.safeParseAsync(e, t);
|
|
528
|
+
if (r.success)
|
|
529
|
+
return r.data;
|
|
530
|
+
throw r.error;
|
|
536
531
|
}
|
|
537
532
|
async safeParseAsync(e, t) {
|
|
538
|
-
const
|
|
533
|
+
const r = {
|
|
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
|
-
}, n = this._parse({ data: e, path:
|
|
550
|
-
return Ge(
|
|
543
|
+
parsedType: V(e)
|
|
544
|
+
}, n = this._parse({ data: e, path: r.path, parent: r }), a = await (fe(n) ? n : Promise.resolve(n));
|
|
545
|
+
return Ge(r, a);
|
|
551
546
|
}
|
|
552
547
|
refine(e, t) {
|
|
553
|
-
const
|
|
548
|
+
const r = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
554
549
|
return this._refinement((n, a) => {
|
|
555
550
|
const i = e(n), o = () => a.addIssue({
|
|
556
551
|
code: d.custom,
|
|
557
|
-
...
|
|
552
|
+
...r(n)
|
|
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((
|
|
558
|
+
return this._refinement((r, n) => e(r) ? !0 : (n.addIssue(typeof t == "function" ? t(r, n) : t), !1));
|
|
564
559
|
}
|
|
565
560
|
_refinement(e) {
|
|
566
561
|
return new N({
|
|
@@ -580,25 +575,25 @@ class v {
|
|
|
580
575
|
};
|
|
581
576
|
}
|
|
582
577
|
optional() {
|
|
583
|
-
return
|
|
578
|
+
return I.create(this, this._def);
|
|
584
579
|
}
|
|
585
580
|
nullable() {
|
|
586
|
-
return
|
|
581
|
+
return W.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
599
|
return new N({
|
|
@@ -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 Ye({
|
|
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,43 +648,43 @@ 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, Ot = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
652
|
+
let Be;
|
|
653
|
+
const At = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Rt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Et = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Nt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, jt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Zt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, rt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", It = new RegExp(`^${rt}$`);
|
|
654
|
+
function nt(s) {
|
|
660
655
|
let e = "[0-5]\\d";
|
|
661
|
-
|
|
662
|
-
const t =
|
|
656
|
+
s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
657
|
+
const t = s.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(s) {
|
|
661
|
+
return new RegExp(`^${nt(s)}$`);
|
|
667
662
|
}
|
|
668
|
-
function
|
|
669
|
-
let e = `${
|
|
663
|
+
function at(s) {
|
|
664
|
+
let e = `${rt}T${nt(s)}`;
|
|
670
665
|
const t = [];
|
|
671
|
-
return t.push(
|
|
666
|
+
return t.push(s.local ? "Z?" : "Z"), s.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(s, e) {
|
|
669
|
+
return !!((e === "v4" || !e) && At.test(s) || (e === "v6" || !e) && Et.test(s));
|
|
675
670
|
}
|
|
676
|
-
function
|
|
677
|
-
if (!
|
|
671
|
+
function Mt(s, e) {
|
|
672
|
+
if (!Tt.test(s))
|
|
678
673
|
return !1;
|
|
679
674
|
try {
|
|
680
|
-
const [t] =
|
|
675
|
+
const [t] = s.split(".");
|
|
681
676
|
if (!t)
|
|
682
677
|
return !1;
|
|
683
|
-
const
|
|
684
|
-
return !(typeof n != "object" || n === null || "typ" in n &&
|
|
678
|
+
const r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(r));
|
|
679
|
+
return !(typeof n != "object" || n === null || "typ" in n && n?.typ !== "JWT" || !n.alg || e && n.alg !== e);
|
|
685
680
|
} catch {
|
|
686
681
|
return !1;
|
|
687
682
|
}
|
|
688
683
|
}
|
|
689
|
-
function
|
|
690
|
-
return !!((e === "v4" || !e) &&
|
|
684
|
+
function Dt(s, e) {
|
|
685
|
+
return !!((e === "v4" || !e) && Rt.test(s) || (e === "v6" || !e) && Nt.test(s));
|
|
691
686
|
}
|
|
692
|
-
class
|
|
687
|
+
class R 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);
|
|
@@ -699,7 +694,7 @@ class j extends v {
|
|
|
699
694
|
received: a.parsedType
|
|
700
695
|
}), m;
|
|
701
696
|
}
|
|
702
|
-
const
|
|
697
|
+
const r = new T();
|
|
703
698
|
let n;
|
|
704
699
|
for (const a of this._def.checks)
|
|
705
700
|
if (a.kind === "min")
|
|
@@ -710,7 +705,7 @@ class j extends v {
|
|
|
710
705
|
inclusive: !0,
|
|
711
706
|
exact: !1,
|
|
712
707
|
message: a.message
|
|
713
|
-
}),
|
|
708
|
+
}), r.dirty());
|
|
714
709
|
else if (a.kind === "max")
|
|
715
710
|
e.data.length > a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
716
711
|
code: d.too_big,
|
|
@@ -719,7 +714,7 @@ class j extends v {
|
|
|
719
714
|
inclusive: !0,
|
|
720
715
|
exact: !1,
|
|
721
716
|
message: a.message
|
|
722
|
-
}),
|
|
717
|
+
}), r.dirty());
|
|
723
718
|
else if (a.kind === "length") {
|
|
724
719
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
725
720
|
(i || o) && (n = this._getOrReturnCtx(e, n), i ? l(n, {
|
|
@@ -736,49 +731,49 @@ class j extends v {
|
|
|
736
731
|
inclusive: !0,
|
|
737
732
|
exact: !0,
|
|
738
733
|
message: a.message
|
|
739
|
-
}),
|
|
734
|
+
}), r.dirty());
|
|
740
735
|
} else if (a.kind === "email")
|
|
741
|
-
|
|
736
|
+
Ct.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
742
737
|
validation: "email",
|
|
743
738
|
code: d.invalid_string,
|
|
744
739
|
message: a.message
|
|
745
|
-
}),
|
|
740
|
+
}), r.dirty());
|
|
746
741
|
else if (a.kind === "emoji")
|
|
747
|
-
|
|
742
|
+
Be || (Be = new RegExp(Ot, "u")), Be.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
748
743
|
validation: "emoji",
|
|
749
744
|
code: d.invalid_string,
|
|
750
745
|
message: a.message
|
|
751
|
-
}),
|
|
746
|
+
}), r.dirty());
|
|
752
747
|
else if (a.kind === "uuid")
|
|
753
|
-
|
|
748
|
+
kt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
754
749
|
validation: "uuid",
|
|
755
750
|
code: d.invalid_string,
|
|
756
751
|
message: a.message
|
|
757
|
-
}),
|
|
752
|
+
}), r.dirty());
|
|
758
753
|
else if (a.kind === "nanoid")
|
|
759
|
-
|
|
754
|
+
wt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
760
755
|
validation: "nanoid",
|
|
761
756
|
code: d.invalid_string,
|
|
762
757
|
message: a.message
|
|
763
|
-
}),
|
|
758
|
+
}), r.dirty());
|
|
764
759
|
else if (a.kind === "cuid")
|
|
765
|
-
|
|
760
|
+
vt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
766
761
|
validation: "cuid",
|
|
767
762
|
code: d.invalid_string,
|
|
768
763
|
message: a.message
|
|
769
|
-
}),
|
|
764
|
+
}), r.dirty());
|
|
770
765
|
else if (a.kind === "cuid2")
|
|
771
|
-
|
|
766
|
+
xt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
772
767
|
validation: "cuid2",
|
|
773
768
|
code: d.invalid_string,
|
|
774
769
|
message: a.message
|
|
775
|
-
}),
|
|
770
|
+
}), r.dirty());
|
|
776
771
|
else if (a.kind === "ulid")
|
|
777
|
-
|
|
772
|
+
bt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
778
773
|
validation: "ulid",
|
|
779
774
|
code: d.invalid_string,
|
|
780
775
|
message: a.message
|
|
781
|
-
}),
|
|
776
|
+
}), r.dirty());
|
|
782
777
|
else if (a.kind === "url")
|
|
783
778
|
try {
|
|
784
779
|
new URL(e.data);
|
|
@@ -787,72 +782,72 @@ class j extends v {
|
|
|
787
782
|
validation: "url",
|
|
788
783
|
code: d.invalid_string,
|
|
789
784
|
message: a.message
|
|
790
|
-
}),
|
|
785
|
+
}), r.dirty();
|
|
791
786
|
}
|
|
792
787
|
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
793
788
|
validation: "regex",
|
|
794
789
|
code: d.invalid_string,
|
|
795
790
|
message: a.message
|
|
796
|
-
}),
|
|
791
|
+
}), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
797
792
|
code: d.invalid_string,
|
|
798
793
|
validation: { includes: a.value, position: a.position },
|
|
799
794
|
message: a.message
|
|
800
|
-
}),
|
|
795
|
+
}), r.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) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
801
796
|
code: d.invalid_string,
|
|
802
797
|
validation: { startsWith: a.value },
|
|
803
798
|
message: a.message
|
|
804
|
-
}),
|
|
799
|
+
}), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
805
800
|
code: d.invalid_string,
|
|
806
801
|
validation: { endsWith: a.value },
|
|
807
802
|
message: a.message
|
|
808
|
-
}),
|
|
803
|
+
}), r.dirty()) : a.kind === "datetime" ? at(a).test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
809
804
|
code: d.invalid_string,
|
|
810
805
|
validation: "datetime",
|
|
811
806
|
message: a.message
|
|
812
|
-
}),
|
|
807
|
+
}), r.dirty()) : a.kind === "date" ? It.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
813
808
|
code: d.invalid_string,
|
|
814
809
|
validation: "date",
|
|
815
810
|
message: a.message
|
|
816
|
-
}),
|
|
811
|
+
}), r.dirty()) : a.kind === "time" ? $t(a).test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
817
812
|
code: d.invalid_string,
|
|
818
813
|
validation: "time",
|
|
819
814
|
message: a.message
|
|
820
|
-
}),
|
|
815
|
+
}), r.dirty()) : a.kind === "duration" ? St.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
821
816
|
validation: "duration",
|
|
822
817
|
code: d.invalid_string,
|
|
823
818
|
message: a.message
|
|
824
|
-
}),
|
|
819
|
+
}), r.dirty()) : a.kind === "ip" ? Pt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
825
820
|
validation: "ip",
|
|
826
821
|
code: d.invalid_string,
|
|
827
822
|
message: a.message
|
|
828
|
-
}),
|
|
823
|
+
}), r.dirty()) : a.kind === "jwt" ? Mt(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
829
824
|
validation: "jwt",
|
|
830
825
|
code: d.invalid_string,
|
|
831
826
|
message: a.message
|
|
832
|
-
}),
|
|
827
|
+
}), r.dirty()) : a.kind === "cidr" ? Dt(e.data, a.version) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
833
828
|
validation: "cidr",
|
|
834
829
|
code: d.invalid_string,
|
|
835
830
|
message: a.message
|
|
836
|
-
}),
|
|
831
|
+
}), r.dirty()) : a.kind === "base64" ? jt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
837
832
|
validation: "base64",
|
|
838
833
|
code: d.invalid_string,
|
|
839
834
|
message: a.message
|
|
840
|
-
}),
|
|
835
|
+
}), r.dirty()) : a.kind === "base64url" ? Zt.test(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
841
836
|
validation: "base64url",
|
|
842
837
|
code: d.invalid_string,
|
|
843
838
|
message: a.message
|
|
844
|
-
}),
|
|
845
|
-
return { status:
|
|
839
|
+
}), r.dirty()) : x.assertNever(a);
|
|
840
|
+
return { status: r.value, value: e.data };
|
|
846
841
|
}
|
|
847
|
-
_regex(e, t,
|
|
842
|
+
_regex(e, t, r) {
|
|
848
843
|
return this.refinement((n) => e.test(n), {
|
|
849
844
|
validation: t,
|
|
850
845
|
code: d.invalid_string,
|
|
851
|
-
...h.errToObj(
|
|
846
|
+
...h.errToObj(r)
|
|
852
847
|
});
|
|
853
848
|
}
|
|
854
849
|
_addCheck(e) {
|
|
855
|
-
return new
|
|
850
|
+
return new R({
|
|
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 R({
|
|
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 R({
|
|
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 R({
|
|
1004
999
|
...this._def,
|
|
1005
1000
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1006
1001
|
});
|
|
@@ -1066,17 +1061,17 @@ class j extends v {
|
|
|
1066
1061
|
return e;
|
|
1067
1062
|
}
|
|
1068
1063
|
}
|
|
1069
|
-
|
|
1064
|
+
R.create = (s) => new R({
|
|
1070
1065
|
checks: [],
|
|
1071
1066
|
typeName: y.ZodString,
|
|
1072
|
-
coerce:
|
|
1073
|
-
..._(
|
|
1067
|
+
coerce: s?.coerce ?? !1,
|
|
1068
|
+
..._(s)
|
|
1074
1069
|
});
|
|
1075
|
-
function
|
|
1076
|
-
const t = (
|
|
1070
|
+
function Lt(s, e) {
|
|
1071
|
+
const t = (s.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, n = t > r ? t : r, a = Number.parseInt(s.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
1077
1072
|
return a % i / 10 ** n;
|
|
1078
1073
|
}
|
|
1079
|
-
class
|
|
1074
|
+
class U extends v {
|
|
1080
1075
|
constructor() {
|
|
1081
1076
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1082
1077
|
}
|
|
@@ -1089,33 +1084,33 @@ class z extends v {
|
|
|
1089
1084
|
received: a.parsedType
|
|
1090
1085
|
}), m;
|
|
1091
1086
|
}
|
|
1092
|
-
let
|
|
1087
|
+
let r;
|
|
1093
1088
|
const n = new T();
|
|
1094
1089
|
for (const a of this._def.checks)
|
|
1095
|
-
a.kind === "int" ? x.isInteger(e.data) || (
|
|
1090
|
+
a.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1096
1091
|
code: d.invalid_type,
|
|
1097
1092
|
expected: "integer",
|
|
1098
1093
|
received: "float",
|
|
1099
1094
|
message: a.message
|
|
1100
|
-
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1095
|
+
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1101
1096
|
code: d.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
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (
|
|
1102
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1108
1103
|
code: d.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
|
-
}), n.dirty()) : a.kind === "multipleOf" ?
|
|
1109
|
+
}), n.dirty()) : a.kind === "multipleOf" ? Lt(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1115
1110
|
code: d.not_multiple_of,
|
|
1116
1111
|
multipleOf: a.value,
|
|
1117
1112
|
message: a.message
|
|
1118
|
-
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (
|
|
1113
|
+
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1119
1114
|
code: d.not_finite,
|
|
1120
1115
|
message: a.message
|
|
1121
1116
|
}), n.dirty()) : x.assertNever(a);
|
|
@@ -1133,22 +1128,22 @@ 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,
|
|
1137
|
-
return new
|
|
1131
|
+
setLimit(e, t, r, n) {
|
|
1132
|
+
return new U({
|
|
1138
1133
|
...this._def,
|
|
1139
1134
|
checks: [
|
|
1140
1135
|
...this._def.checks,
|
|
1141
1136
|
{
|
|
1142
1137
|
kind: e,
|
|
1143
1138
|
value: t,
|
|
1144
|
-
inclusive:
|
|
1139
|
+
inclusive: r,
|
|
1145
1140
|
message: h.toString(n)
|
|
1146
1141
|
}
|
|
1147
1142
|
]
|
|
1148
1143
|
});
|
|
1149
1144
|
}
|
|
1150
1145
|
_addCheck(e) {
|
|
1151
|
-
return new
|
|
1146
|
+
return new U({
|
|
1152
1147
|
...this._def,
|
|
1153
1148
|
checks: [...this._def.checks, e]
|
|
1154
1149
|
});
|
|
@@ -1234,21 +1229,21 @@ class z extends v {
|
|
|
1234
1229
|
}
|
|
1235
1230
|
get isFinite() {
|
|
1236
1231
|
let e = null, t = null;
|
|
1237
|
-
for (const
|
|
1238
|
-
if (
|
|
1232
|
+
for (const r of this._def.checks) {
|
|
1233
|
+
if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
|
|
1239
1234
|
return !0;
|
|
1240
|
-
|
|
1235
|
+
r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1241
1236
|
}
|
|
1242
1237
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1243
1238
|
}
|
|
1244
1239
|
}
|
|
1245
|
-
|
|
1240
|
+
U.create = (s) => new U({
|
|
1246
1241
|
checks: [],
|
|
1247
1242
|
typeName: y.ZodNumber,
|
|
1248
|
-
coerce:
|
|
1249
|
-
..._(
|
|
1243
|
+
coerce: s?.coerce || !1,
|
|
1244
|
+
..._(s)
|
|
1250
1245
|
});
|
|
1251
|
-
class
|
|
1246
|
+
class q extends v {
|
|
1252
1247
|
constructor() {
|
|
1253
1248
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1254
1249
|
}
|
|
@@ -1261,22 +1256,22 @@ class U extends v {
|
|
|
1261
1256
|
}
|
|
1262
1257
|
if (this._getType(e) !== f.bigint)
|
|
1263
1258
|
return this._getInvalidInput(e);
|
|
1264
|
-
let
|
|
1259
|
+
let r;
|
|
1265
1260
|
const n = new T();
|
|
1266
1261
|
for (const a of this._def.checks)
|
|
1267
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1262
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1268
1263
|
code: d.too_small,
|
|
1269
1264
|
type: "bigint",
|
|
1270
1265
|
minimum: a.value,
|
|
1271
1266
|
inclusive: a.inclusive,
|
|
1272
1267
|
message: a.message
|
|
1273
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (
|
|
1268
|
+
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1274
1269
|
code: d.too_big,
|
|
1275
1270
|
type: "bigint",
|
|
1276
1271
|
maximum: a.value,
|
|
1277
1272
|
inclusive: a.inclusive,
|
|
1278
1273
|
message: a.message
|
|
1279
|
-
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (
|
|
1274
|
+
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1280
1275
|
code: d.not_multiple_of,
|
|
1281
1276
|
multipleOf: a.value,
|
|
1282
1277
|
message: a.message
|
|
@@ -1303,22 +1298,22 @@ 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,
|
|
1307
|
-
return new
|
|
1301
|
+
setLimit(e, t, r, n) {
|
|
1302
|
+
return new q({
|
|
1308
1303
|
...this._def,
|
|
1309
1304
|
checks: [
|
|
1310
1305
|
...this._def.checks,
|
|
1311
1306
|
{
|
|
1312
1307
|
kind: e,
|
|
1313
1308
|
value: t,
|
|
1314
|
-
inclusive:
|
|
1309
|
+
inclusive: r,
|
|
1315
1310
|
message: h.toString(n)
|
|
1316
1311
|
}
|
|
1317
1312
|
]
|
|
1318
1313
|
});
|
|
1319
1314
|
}
|
|
1320
1315
|
_addCheck(e) {
|
|
1321
|
-
return new
|
|
1316
|
+
return new q({
|
|
1322
1317
|
...this._def,
|
|
1323
1318
|
checks: [...this._def.checks, e]
|
|
1324
1319
|
});
|
|
@@ -1375,31 +1370,31 @@ class U extends v {
|
|
|
1375
1370
|
return e;
|
|
1376
1371
|
}
|
|
1377
1372
|
}
|
|
1378
|
-
|
|
1373
|
+
q.create = (s) => new q({
|
|
1379
1374
|
checks: [],
|
|
1380
1375
|
typeName: y.ZodBigInt,
|
|
1381
|
-
coerce:
|
|
1382
|
-
..._(
|
|
1376
|
+
coerce: s?.coerce ?? !1,
|
|
1377
|
+
..._(s)
|
|
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
|
-
const
|
|
1388
|
-
return l(
|
|
1382
|
+
const r = this._getOrReturnCtx(e);
|
|
1383
|
+
return l(r, {
|
|
1389
1384
|
code: d.invalid_type,
|
|
1390
1385
|
expected: f.boolean,
|
|
1391
|
-
received:
|
|
1386
|
+
received: r.parsedType
|
|
1392
1387
|
}), m;
|
|
1393
1388
|
}
|
|
1394
|
-
return
|
|
1389
|
+
return S(e.data);
|
|
1395
1390
|
}
|
|
1396
1391
|
}
|
|
1397
|
-
|
|
1392
|
+
he.create = (s) => new he({
|
|
1398
1393
|
typeName: y.ZodBoolean,
|
|
1399
|
-
coerce:
|
|
1400
|
-
..._(
|
|
1394
|
+
coerce: s?.coerce || !1,
|
|
1395
|
+
..._(s)
|
|
1401
1396
|
});
|
|
1402
|
-
class
|
|
1397
|
+
class G 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);
|
|
@@ -1415,7 +1410,7 @@ class H extends v {
|
|
|
1415
1410
|
code: d.invalid_date
|
|
1416
1411
|
}), m;
|
|
1417
1412
|
}
|
|
1418
|
-
const
|
|
1413
|
+
const r = new T();
|
|
1419
1414
|
let n;
|
|
1420
1415
|
for (const a of this._def.checks)
|
|
1421
1416
|
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
@@ -1425,21 +1420,21 @@ class H extends v {
|
|
|
1425
1420
|
exact: !1,
|
|
1426
1421
|
minimum: a.value,
|
|
1427
1422
|
type: "date"
|
|
1428
|
-
}),
|
|
1423
|
+
}), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1429
1424
|
code: d.too_big,
|
|
1430
1425
|
message: a.message,
|
|
1431
1426
|
inclusive: !0,
|
|
1432
1427
|
exact: !1,
|
|
1433
1428
|
maximum: a.value,
|
|
1434
1429
|
type: "date"
|
|
1435
|
-
}),
|
|
1430
|
+
}), r.dirty()) : x.assertNever(a);
|
|
1436
1431
|
return {
|
|
1437
|
-
status:
|
|
1432
|
+
status: r.value,
|
|
1438
1433
|
value: new Date(e.data.getTime())
|
|
1439
1434
|
};
|
|
1440
1435
|
}
|
|
1441
1436
|
_addCheck(e) {
|
|
1442
|
-
return new
|
|
1437
|
+
return new G({
|
|
1443
1438
|
...this._def,
|
|
1444
1439
|
checks: [...this._def.checks, e]
|
|
1445
1440
|
});
|
|
@@ -1471,88 +1466,88 @@ class H extends v {
|
|
|
1471
1466
|
return e != null ? new Date(e) : null;
|
|
1472
1467
|
}
|
|
1473
1468
|
}
|
|
1474
|
-
|
|
1469
|
+
G.create = (s) => new G({
|
|
1475
1470
|
checks: [],
|
|
1476
|
-
coerce:
|
|
1471
|
+
coerce: s?.coerce || !1,
|
|
1477
1472
|
typeName: y.ZodDate,
|
|
1478
|
-
..._(
|
|
1473
|
+
..._(s)
|
|
1479
1474
|
});
|
|
1480
|
-
class
|
|
1475
|
+
class Re extends v {
|
|
1481
1476
|
_parse(e) {
|
|
1482
1477
|
if (this._getType(e) !== f.symbol) {
|
|
1483
|
-
const
|
|
1484
|
-
return l(
|
|
1478
|
+
const r = this._getOrReturnCtx(e);
|
|
1479
|
+
return l(r, {
|
|
1485
1480
|
code: d.invalid_type,
|
|
1486
1481
|
expected: f.symbol,
|
|
1487
|
-
received:
|
|
1482
|
+
received: r.parsedType
|
|
1488
1483
|
}), m;
|
|
1489
1484
|
}
|
|
1490
|
-
return
|
|
1485
|
+
return S(e.data);
|
|
1491
1486
|
}
|
|
1492
1487
|
}
|
|
1493
|
-
|
|
1488
|
+
Re.create = (s) => new Re({
|
|
1494
1489
|
typeName: y.ZodSymbol,
|
|
1495
|
-
..._(
|
|
1490
|
+
..._(s)
|
|
1496
1491
|
});
|
|
1497
|
-
class
|
|
1492
|
+
class pe extends v {
|
|
1498
1493
|
_parse(e) {
|
|
1499
1494
|
if (this._getType(e) !== f.undefined) {
|
|
1500
|
-
const
|
|
1501
|
-
return l(
|
|
1495
|
+
const r = this._getOrReturnCtx(e);
|
|
1496
|
+
return l(r, {
|
|
1502
1497
|
code: d.invalid_type,
|
|
1503
1498
|
expected: f.undefined,
|
|
1504
|
-
received:
|
|
1499
|
+
received: r.parsedType
|
|
1505
1500
|
}), m;
|
|
1506
1501
|
}
|
|
1507
|
-
return
|
|
1502
|
+
return S(e.data);
|
|
1508
1503
|
}
|
|
1509
1504
|
}
|
|
1510
|
-
|
|
1505
|
+
pe.create = (s) => new pe({
|
|
1511
1506
|
typeName: y.ZodUndefined,
|
|
1512
|
-
..._(
|
|
1507
|
+
..._(s)
|
|
1513
1508
|
});
|
|
1514
|
-
class
|
|
1509
|
+
class me extends v {
|
|
1515
1510
|
_parse(e) {
|
|
1516
1511
|
if (this._getType(e) !== f.null) {
|
|
1517
|
-
const
|
|
1518
|
-
return l(
|
|
1512
|
+
const r = this._getOrReturnCtx(e);
|
|
1513
|
+
return l(r, {
|
|
1519
1514
|
code: d.invalid_type,
|
|
1520
1515
|
expected: f.null,
|
|
1521
|
-
received:
|
|
1516
|
+
received: r.parsedType
|
|
1522
1517
|
}), m;
|
|
1523
1518
|
}
|
|
1524
|
-
return
|
|
1519
|
+
return S(e.data);
|
|
1525
1520
|
}
|
|
1526
1521
|
}
|
|
1527
|
-
|
|
1522
|
+
me.create = (s) => new me({
|
|
1528
1523
|
typeName: y.ZodNull,
|
|
1529
|
-
..._(
|
|
1524
|
+
..._(s)
|
|
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 = (s) => new oe({
|
|
1540
1535
|
typeName: y.ZodAny,
|
|
1541
|
-
..._(
|
|
1536
|
+
..._(s)
|
|
1542
1537
|
});
|
|
1543
|
-
class
|
|
1538
|
+
class Y 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
|
+
Y.create = (s) => new Y({
|
|
1552
1547
|
typeName: y.ZodUnknown,
|
|
1553
|
-
..._(
|
|
1548
|
+
..._(s)
|
|
1554
1549
|
});
|
|
1555
|
-
class
|
|
1550
|
+
class z extends v {
|
|
1556
1551
|
_parse(e) {
|
|
1557
1552
|
const t = this._getOrReturnCtx(e);
|
|
1558
1553
|
return l(t, {
|
|
@@ -1562,30 +1557,30 @@ class D extends v {
|
|
|
1562
1557
|
}), m;
|
|
1563
1558
|
}
|
|
1564
1559
|
}
|
|
1565
|
-
|
|
1560
|
+
z.create = (s) => new z({
|
|
1566
1561
|
typeName: y.ZodNever,
|
|
1567
|
-
..._(
|
|
1562
|
+
..._(s)
|
|
1568
1563
|
});
|
|
1569
|
-
class
|
|
1564
|
+
class Ee extends v {
|
|
1570
1565
|
_parse(e) {
|
|
1571
1566
|
if (this._getType(e) !== f.undefined) {
|
|
1572
|
-
const
|
|
1573
|
-
return l(
|
|
1567
|
+
const r = this._getOrReturnCtx(e);
|
|
1568
|
+
return l(r, {
|
|
1574
1569
|
code: d.invalid_type,
|
|
1575
1570
|
expected: f.void,
|
|
1576
|
-
received:
|
|
1571
|
+
received: r.parsedType
|
|
1577
1572
|
}), m;
|
|
1578
1573
|
}
|
|
1579
|
-
return
|
|
1574
|
+
return S(e.data);
|
|
1580
1575
|
}
|
|
1581
1576
|
}
|
|
1582
|
-
|
|
1577
|
+
Ee.create = (s) => new Ee({
|
|
1583
1578
|
typeName: y.ZodVoid,
|
|
1584
|
-
..._(
|
|
1579
|
+
..._(s)
|
|
1585
1580
|
});
|
|
1586
|
-
class
|
|
1581
|
+
class E extends v {
|
|
1587
1582
|
_parse(e) {
|
|
1588
|
-
const { ctx: t, status:
|
|
1583
|
+
const { ctx: t, status: r } = this._processInputParams(e), n = this._def;
|
|
1589
1584
|
if (t.parsedType !== f.array)
|
|
1590
1585
|
return l(t, {
|
|
1591
1586
|
code: d.invalid_type,
|
|
@@ -1602,7 +1597,7 @@ class R extends v {
|
|
|
1602
1597
|
inclusive: !0,
|
|
1603
1598
|
exact: !0,
|
|
1604
1599
|
message: n.exactLength.message
|
|
1605
|
-
}),
|
|
1600
|
+
}), r.dirty());
|
|
1606
1601
|
}
|
|
1607
1602
|
if (n.minLength !== null && t.data.length < n.minLength.value && (l(t, {
|
|
1608
1603
|
code: d.too_small,
|
|
@@ -1611,35 +1606,35 @@ class R extends v {
|
|
|
1611
1606
|
inclusive: !0,
|
|
1612
1607
|
exact: !1,
|
|
1613
1608
|
message: n.minLength.message
|
|
1614
|
-
}),
|
|
1609
|
+
}), r.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (l(t, {
|
|
1615
1610
|
code: d.too_big,
|
|
1616
1611
|
maximum: n.maxLength.value,
|
|
1617
1612
|
type: "array",
|
|
1618
1613
|
inclusive: !0,
|
|
1619
1614
|
exact: !1,
|
|
1620
1615
|
message: n.maxLength.message
|
|
1621
|
-
}),
|
|
1622
|
-
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new
|
|
1623
|
-
const a = [...t.data].map((i, o) => n.type._parseSync(new
|
|
1624
|
-
return T.mergeArray(
|
|
1616
|
+
}), r.dirty()), t.common.async)
|
|
1617
|
+
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new $(t, i, t.path, o)))).then((i) => T.mergeArray(r, i));
|
|
1618
|
+
const a = [...t.data].map((i, o) => n.type._parseSync(new $(t, i, t.path, o)));
|
|
1619
|
+
return T.mergeArray(r, 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 = (s, e) => new E({
|
|
1647
|
+
type: s,
|
|
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 re(s) {
|
|
1655
|
+
if (s instanceof k) {
|
|
1661
1656
|
const e = {};
|
|
1662
|
-
for (const t in
|
|
1663
|
-
const
|
|
1664
|
-
e[t] =
|
|
1657
|
+
for (const t in s.shape) {
|
|
1658
|
+
const r = s.shape[t];
|
|
1659
|
+
e[t] = I.create(re(r));
|
|
1665
1660
|
}
|
|
1666
1661
|
return new k({
|
|
1667
|
-
...
|
|
1662
|
+
...s._def,
|
|
1668
1663
|
shape: () => e
|
|
1669
1664
|
});
|
|
1670
|
-
} else return
|
|
1671
|
-
...
|
|
1672
|
-
type:
|
|
1673
|
-
}) :
|
|
1665
|
+
} else return s instanceof E ? new E({
|
|
1666
|
+
...s._def,
|
|
1667
|
+
type: re(s.element)
|
|
1668
|
+
}) : s instanceof I ? I.create(re(s.unwrap())) : s instanceof W ? W.create(re(s.unwrap())) : s instanceof P ? P.create(s.items.map((e) => re(e))) : s;
|
|
1674
1669
|
}
|
|
1675
1670
|
class k extends v {
|
|
1676
1671
|
constructor() {
|
|
@@ -1691,8 +1686,8 @@ class k extends v {
|
|
|
1691
1686
|
received: u.parsedType
|
|
1692
1687
|
}), m;
|
|
1693
1688
|
}
|
|
1694
|
-
const { status:
|
|
1695
|
-
if (!(this._def.catchall instanceof
|
|
1689
|
+
const { status: r, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1690
|
+
if (!(this._def.catchall instanceof z && this._def.unknownKeys === "strip"))
|
|
1696
1691
|
for (const u in n.data)
|
|
1697
1692
|
i.includes(u) || o.push(u);
|
|
1698
1693
|
const c = [];
|
|
@@ -1700,11 +1695,11 @@ class k extends v {
|
|
|
1700
1695
|
const p = a[u], b = n.data[u];
|
|
1701
1696
|
c.push({
|
|
1702
1697
|
key: { status: "valid", value: u },
|
|
1703
|
-
value: p._parse(new
|
|
1698
|
+
value: p._parse(new $(n, b, n.path, u)),
|
|
1704
1699
|
alwaysSet: u in n.data
|
|
1705
1700
|
});
|
|
1706
1701
|
}
|
|
1707
|
-
if (this._def.catchall instanceof
|
|
1702
|
+
if (this._def.catchall instanceof z) {
|
|
1708
1703
|
const u = this._def.unknownKeys;
|
|
1709
1704
|
if (u === "passthrough")
|
|
1710
1705
|
for (const p of o)
|
|
@@ -1716,7 +1711,7 @@ class k extends v {
|
|
|
1716
1711
|
o.length > 0 && (l(n, {
|
|
1717
1712
|
code: d.unrecognized_keys,
|
|
1718
1713
|
keys: o
|
|
1719
|
-
}),
|
|
1714
|
+
}), r.dirty());
|
|
1720
1715
|
else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1721
1716
|
} else {
|
|
1722
1717
|
const u = this._def.catchall;
|
|
@@ -1725,7 +1720,7 @@ class k extends v {
|
|
|
1725
1720
|
c.push({
|
|
1726
1721
|
key: { status: "valid", value: p },
|
|
1727
1722
|
value: u._parse(
|
|
1728
|
-
new
|
|
1723
|
+
new $(n, b, n.path, p)
|
|
1729
1724
|
//, ctx.child(key), value, getParsedType(value)
|
|
1730
1725
|
),
|
|
1731
1726
|
alwaysSet: p in n.data
|
|
@@ -1735,15 +1730,15 @@ class k extends v {
|
|
|
1735
1730
|
return n.common.async ? Promise.resolve().then(async () => {
|
|
1736
1731
|
const u = [];
|
|
1737
1732
|
for (const p of c) {
|
|
1738
|
-
const b = await p.key,
|
|
1733
|
+
const b = await p.key, C = await p.value;
|
|
1739
1734
|
u.push({
|
|
1740
1735
|
key: b,
|
|
1741
|
-
value:
|
|
1736
|
+
value: C,
|
|
1742
1737
|
alwaysSet: p.alwaysSet
|
|
1743
1738
|
});
|
|
1744
1739
|
}
|
|
1745
1740
|
return u;
|
|
1746
|
-
}).then((u) => T.mergeObjectSync(
|
|
1741
|
+
}).then((u) => T.mergeObjectSync(r, u)) : T.mergeObjectSync(r, c);
|
|
1747
1742
|
}
|
|
1748
1743
|
get shape() {
|
|
1749
1744
|
return this._def.shape();
|
|
@@ -1753,9 +1748,8 @@ class k extends v {
|
|
|
1753
1748
|
...this._def,
|
|
1754
1749
|
unknownKeys: "strict",
|
|
1755
1750
|
...e !== void 0 ? {
|
|
1756
|
-
errorMap: (t,
|
|
1757
|
-
|
|
1758
|
-
const n = ((i = (a = this._def).errorMap) == null ? void 0 : i.call(a, t, s).message) ?? s.defaultError;
|
|
1751
|
+
errorMap: (t, r) => {
|
|
1752
|
+
const n = this._def.errorMap?.(t, r).message ?? r.defaultError;
|
|
1759
1753
|
return t.code === "unrecognized_keys" ? {
|
|
1760
1754
|
message: h.errToObj(e).message ?? n
|
|
1761
1755
|
} : {
|
|
@@ -1886,8 +1880,8 @@ class k extends v {
|
|
|
1886
1880
|
}
|
|
1887
1881
|
pick(e) {
|
|
1888
1882
|
const t = {};
|
|
1889
|
-
for (const
|
|
1890
|
-
e[
|
|
1883
|
+
for (const r of x.objectKeys(e))
|
|
1884
|
+
e[r] && this.shape[r] && (t[r] = this.shape[r]);
|
|
1891
1885
|
return new k({
|
|
1892
1886
|
...this._def,
|
|
1893
1887
|
shape: () => t
|
|
@@ -1895,8 +1889,8 @@ class k extends v {
|
|
|
1895
1889
|
}
|
|
1896
1890
|
omit(e) {
|
|
1897
1891
|
const t = {};
|
|
1898
|
-
for (const
|
|
1899
|
-
e[
|
|
1892
|
+
for (const r of x.objectKeys(this.shape))
|
|
1893
|
+
e[r] || (t[r] = this.shape[r]);
|
|
1900
1894
|
return new k({
|
|
1901
1895
|
...this._def,
|
|
1902
1896
|
shape: () => t
|
|
@@ -1906,13 +1900,13 @@ class k extends v {
|
|
|
1906
1900
|
* @deprecated
|
|
1907
1901
|
*/
|
|
1908
1902
|
deepPartial() {
|
|
1909
|
-
return
|
|
1903
|
+
return re(this);
|
|
1910
1904
|
}
|
|
1911
1905
|
partial(e) {
|
|
1912
1906
|
const t = {};
|
|
1913
|
-
for (const
|
|
1914
|
-
const n = this.shape[
|
|
1915
|
-
e && !e[
|
|
1907
|
+
for (const r of x.objectKeys(this.shape)) {
|
|
1908
|
+
const n = this.shape[r];
|
|
1909
|
+
e && !e[r] ? t[r] = n : t[r] = n.optional();
|
|
1916
1910
|
}
|
|
1917
1911
|
return new k({
|
|
1918
1912
|
...this._def,
|
|
@@ -1921,14 +1915,14 @@ class k extends v {
|
|
|
1921
1915
|
}
|
|
1922
1916
|
required(e) {
|
|
1923
1917
|
const t = {};
|
|
1924
|
-
for (const
|
|
1925
|
-
if (e && !e[
|
|
1926
|
-
t[
|
|
1918
|
+
for (const r of x.objectKeys(this.shape))
|
|
1919
|
+
if (e && !e[r])
|
|
1920
|
+
t[r] = this.shape[r];
|
|
1927
1921
|
else {
|
|
1928
|
-
let a = this.shape[
|
|
1929
|
-
for (; a instanceof
|
|
1922
|
+
let a = this.shape[r];
|
|
1923
|
+
for (; a instanceof I; )
|
|
1930
1924
|
a = a._def.innerType;
|
|
1931
|
-
t[
|
|
1925
|
+
t[r] = a;
|
|
1932
1926
|
}
|
|
1933
1927
|
return new k({
|
|
1934
1928
|
...this._def,
|
|
@@ -1936,33 +1930,33 @@ 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 = (s, e) => new k({
|
|
1937
|
+
shape: () => s,
|
|
1944
1938
|
unknownKeys: "strip",
|
|
1945
|
-
catchall:
|
|
1939
|
+
catchall: z.create(),
|
|
1946
1940
|
typeName: y.ZodObject,
|
|
1947
1941
|
..._(e)
|
|
1948
1942
|
});
|
|
1949
|
-
k.strictCreate = (
|
|
1950
|
-
shape: () =>
|
|
1943
|
+
k.strictCreate = (s, e) => new k({
|
|
1944
|
+
shape: () => s,
|
|
1951
1945
|
unknownKeys: "strict",
|
|
1952
|
-
catchall:
|
|
1946
|
+
catchall: z.create(),
|
|
1953
1947
|
typeName: y.ZodObject,
|
|
1954
1948
|
..._(e)
|
|
1955
1949
|
});
|
|
1956
|
-
k.lazycreate = (
|
|
1957
|
-
shape:
|
|
1950
|
+
k.lazycreate = (s, e) => new k({
|
|
1951
|
+
shape: s,
|
|
1958
1952
|
unknownKeys: "strip",
|
|
1959
|
-
catchall:
|
|
1953
|
+
catchall: z.create(),
|
|
1960
1954
|
typeName: y.ZodObject,
|
|
1961
1955
|
..._(e)
|
|
1962
1956
|
});
|
|
1963
|
-
class
|
|
1957
|
+
class ye extends v {
|
|
1964
1958
|
_parse(e) {
|
|
1965
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1959
|
+
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1966
1960
|
function n(a) {
|
|
1967
1961
|
for (const o of a)
|
|
1968
1962
|
if (o.result.status === "valid")
|
|
@@ -1970,14 +1964,14 @@ class le extends v {
|
|
|
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 O(o.ctx.common.issues));
|
|
1974
1968
|
return l(t, {
|
|
1975
1969
|
code: d.invalid_union,
|
|
1976
1970
|
unionErrors: i
|
|
1977
1971
|
}), m;
|
|
1978
1972
|
}
|
|
1979
1973
|
if (t.common.async)
|
|
1980
|
-
return Promise.all(
|
|
1974
|
+
return Promise.all(r.map(async (a) => {
|
|
1981
1975
|
const i = {
|
|
1982
1976
|
...t,
|
|
1983
1977
|
common: {
|
|
@@ -1998,7 +1992,7 @@ class le extends v {
|
|
|
1998
1992
|
{
|
|
1999
1993
|
let a;
|
|
2000
1994
|
const i = [];
|
|
2001
|
-
for (const c of
|
|
1995
|
+
for (const c of r) {
|
|
2002
1996
|
const u = {
|
|
2003
1997
|
...t,
|
|
2004
1998
|
common: {
|
|
@@ -2017,7 +2011,7 @@ class le extends v {
|
|
|
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 O(c));
|
|
2021
2015
|
return l(t, {
|
|
2022
2016
|
code: d.invalid_union,
|
|
2023
2017
|
unionErrors: o
|
|
@@ -2028,13 +2022,13 @@ class le extends v {
|
|
|
2028
2022
|
return this._def.options;
|
|
2029
2023
|
}
|
|
2030
2024
|
}
|
|
2031
|
-
|
|
2032
|
-
options:
|
|
2025
|
+
ye.create = (s, e) => new ye({
|
|
2026
|
+
options: s,
|
|
2033
2027
|
typeName: y.ZodUnion,
|
|
2034
2028
|
..._(e)
|
|
2035
2029
|
});
|
|
2036
|
-
const
|
|
2037
|
-
class
|
|
2030
|
+
const L = (s) => s instanceof ve ? L(s.schema) : s instanceof N ? L(s.innerType()) : s instanceof xe ? [s.value] : s instanceof F ? s.options : s instanceof be ? x.objectValues(s.enum) : s instanceof ke ? L(s._def.innerType) : s instanceof pe ? [void 0] : s instanceof me ? [null] : s instanceof I ? [void 0, ...L(s.unwrap())] : s instanceof W ? [null, ...L(s.unwrap())] : s instanceof Ye || s instanceof Te ? L(s.unwrap()) : s instanceof we ? L(s._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)
|
|
@@ -2043,7 +2037,7 @@ class Ne extends v {
|
|
|
2043
2037
|
expected: f.object,
|
|
2044
2038
|
received: t.parsedType
|
|
2045
2039
|
}), m;
|
|
2046
|
-
const
|
|
2040
|
+
const r = this.discriminator, n = t.data[r], a = this.optionsMap.get(n);
|
|
2047
2041
|
return a ? t.common.async ? a._parseAsync({
|
|
2048
2042
|
data: t.data,
|
|
2049
2043
|
path: t.path,
|
|
@@ -2055,7 +2049,7 @@ class Ne extends v {
|
|
|
2055
2049
|
}) : (l(t, {
|
|
2056
2050
|
code: d.invalid_union_discriminator,
|
|
2057
2051
|
options: Array.from(this.optionsMap.keys()),
|
|
2058
|
-
path: [
|
|
2052
|
+
path: [r]
|
|
2059
2053
|
}), m);
|
|
2060
2054
|
}
|
|
2061
2055
|
get discriminator() {
|
|
@@ -2075,10 +2069,10 @@ class Ne extends v {
|
|
|
2075
2069
|
* @param types an array of object schemas
|
|
2076
2070
|
* @param params
|
|
2077
2071
|
*/
|
|
2078
|
-
static create(e, t,
|
|
2072
|
+
static create(e, t, r) {
|
|
2079
2073
|
const n = /* @__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) {
|
|
@@ -2087,130 +2081,130 @@ class Ne extends v {
|
|
|
2087
2081
|
n.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
2088
|
optionsMap: n,
|
|
2095
|
-
..._(
|
|
2089
|
+
..._(r)
|
|
2096
2090
|
});
|
|
2097
2091
|
}
|
|
2098
2092
|
}
|
|
2099
|
-
function
|
|
2100
|
-
const t =
|
|
2101
|
-
if (
|
|
2102
|
-
return { valid: !0, data:
|
|
2103
|
-
if (t === f.object &&
|
|
2104
|
-
const n = x.objectKeys(e), a = x.objectKeys(
|
|
2093
|
+
function Qe(s, e) {
|
|
2094
|
+
const t = V(s), r = V(e);
|
|
2095
|
+
if (s === e)
|
|
2096
|
+
return { valid: !0, data: s };
|
|
2097
|
+
if (t === f.object && r === f.object) {
|
|
2098
|
+
const n = x.objectKeys(e), a = x.objectKeys(s).filter((o) => n.indexOf(o) !== -1), i = { ...s, ...e };
|
|
2105
2099
|
for (const o of a) {
|
|
2106
|
-
const c =
|
|
2100
|
+
const c = Qe(s[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
|
-
} else if (t === f.array &&
|
|
2113
|
-
if (
|
|
2106
|
+
} else if (t === f.array && r === f.array) {
|
|
2107
|
+
if (s.length !== e.length)
|
|
2114
2108
|
return { valid: !1 };
|
|
2115
2109
|
const n = [];
|
|
2116
|
-
for (let a = 0; a <
|
|
2117
|
-
const i =
|
|
2110
|
+
for (let a = 0; a < s.length; a++) {
|
|
2111
|
+
const i = s[a], o = e[a], c = Qe(i, o);
|
|
2118
2112
|
if (!c.valid)
|
|
2119
2113
|
return { valid: !1 };
|
|
2120
2114
|
n.push(c.data);
|
|
2121
2115
|
}
|
|
2122
2116
|
return { valid: !0, data: n };
|
|
2123
|
-
} else return t === f.date &&
|
|
2117
|
+
} else return t === f.date && r === f.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
|
|
2124
2118
|
}
|
|
2125
|
-
class
|
|
2119
|
+
class _e extends v {
|
|
2126
2120
|
_parse(e) {
|
|
2127
|
-
const { status: t, ctx:
|
|
2128
|
-
if (
|
|
2121
|
+
const { status: t, ctx: r } = this._processInputParams(e), n = (a, i) => {
|
|
2122
|
+
if (We(a) || We(i))
|
|
2129
2123
|
return m;
|
|
2130
|
-
const o =
|
|
2131
|
-
return o.valid ? ((
|
|
2124
|
+
const o = Qe(a.value, i.value);
|
|
2125
|
+
return o.valid ? ((Je(a) || Je(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(r, {
|
|
2132
2126
|
code: d.invalid_intersection_types
|
|
2133
2127
|
}), m);
|
|
2134
2128
|
};
|
|
2135
|
-
return
|
|
2129
|
+
return r.common.async ? Promise.all([
|
|
2136
2130
|
this._def.left._parseAsync({
|
|
2137
|
-
data:
|
|
2138
|
-
path:
|
|
2139
|
-
parent:
|
|
2131
|
+
data: r.data,
|
|
2132
|
+
path: r.path,
|
|
2133
|
+
parent: r
|
|
2140
2134
|
}),
|
|
2141
2135
|
this._def.right._parseAsync({
|
|
2142
|
-
data:
|
|
2143
|
-
path:
|
|
2144
|
-
parent:
|
|
2136
|
+
data: r.data,
|
|
2137
|
+
path: r.path,
|
|
2138
|
+
parent: r
|
|
2145
2139
|
})
|
|
2146
2140
|
]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
|
|
2147
|
-
data:
|
|
2148
|
-
path:
|
|
2149
|
-
parent:
|
|
2141
|
+
data: r.data,
|
|
2142
|
+
path: r.path,
|
|
2143
|
+
parent: r
|
|
2150
2144
|
}), this._def.right._parseSync({
|
|
2151
|
-
data:
|
|
2152
|
-
path:
|
|
2153
|
-
parent:
|
|
2145
|
+
data: r.data,
|
|
2146
|
+
path: r.path,
|
|
2147
|
+
parent: r
|
|
2154
2148
|
}));
|
|
2155
2149
|
}
|
|
2156
2150
|
}
|
|
2157
|
-
|
|
2158
|
-
left:
|
|
2151
|
+
_e.create = (s, e, t) => new _e({
|
|
2152
|
+
left: s,
|
|
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
|
-
const { status: t, ctx:
|
|
2166
|
-
if (
|
|
2167
|
-
return l(
|
|
2159
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2160
|
+
if (r.parsedType !== f.array)
|
|
2161
|
+
return l(r, {
|
|
2168
2162
|
code: d.invalid_type,
|
|
2169
2163
|
expected: f.array,
|
|
2170
|
-
received:
|
|
2164
|
+
received: r.parsedType
|
|
2171
2165
|
}), m;
|
|
2172
|
-
if (
|
|
2173
|
-
return l(
|
|
2166
|
+
if (r.data.length < this._def.items.length)
|
|
2167
|
+
return l(r, {
|
|
2174
2168
|
code: d.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
|
-
!this._def.rest &&
|
|
2174
|
+
!this._def.rest && r.data.length > this._def.items.length && (l(r, {
|
|
2181
2175
|
code: d.too_big,
|
|
2182
2176
|
maximum: this._def.items.length,
|
|
2183
2177
|
inclusive: !0,
|
|
2184
2178
|
exact: !1,
|
|
2185
2179
|
type: "array"
|
|
2186
2180
|
}), t.dirty());
|
|
2187
|
-
const a = [...
|
|
2181
|
+
const a = [...r.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 $(r, i, r.path, o)) : null;
|
|
2190
2184
|
}).filter((i) => !!i);
|
|
2191
|
-
return
|
|
2185
|
+
return r.common.async ? Promise.all(a).then((i) => T.mergeArray(t, i)) : T.mergeArray(t, a);
|
|
2192
2186
|
}
|
|
2193
2187
|
get items() {
|
|
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 = (s, e) => {
|
|
2198
|
+
if (!Array.isArray(s))
|
|
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: s,
|
|
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
|
}
|
|
@@ -2218,40 +2212,40 @@ class he extends v {
|
|
|
2218
2212
|
return this._def.valueType;
|
|
2219
2213
|
}
|
|
2220
2214
|
_parse(e) {
|
|
2221
|
-
const { status: t, ctx:
|
|
2222
|
-
if (
|
|
2223
|
-
return l(
|
|
2215
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2216
|
+
if (r.parsedType !== f.object)
|
|
2217
|
+
return l(r, {
|
|
2224
2218
|
code: d.invalid_type,
|
|
2225
2219
|
expected: f.object,
|
|
2226
|
-
received:
|
|
2220
|
+
received: r.parsedType
|
|
2227
2221
|
}), m;
|
|
2228
2222
|
const n = [], a = this._def.keyType, i = this._def.valueType;
|
|
2229
|
-
for (const o in
|
|
2223
|
+
for (const o in r.data)
|
|
2230
2224
|
n.push({
|
|
2231
|
-
key: a._parse(new
|
|
2232
|
-
value: i._parse(new
|
|
2233
|
-
alwaysSet: o in
|
|
2225
|
+
key: a._parse(new $(r, o, r.path, o)),
|
|
2226
|
+
value: i._parse(new $(r, r.data[o], r.path, o)),
|
|
2227
|
+
alwaysSet: o in r.data
|
|
2234
2228
|
});
|
|
2235
|
-
return
|
|
2229
|
+
return r.common.async ? T.mergeObjectAsync(t, n) : T.mergeObjectSync(t, n);
|
|
2236
2230
|
}
|
|
2237
2231
|
get element() {
|
|
2238
2232
|
return this._def.valueType;
|
|
2239
2233
|
}
|
|
2240
|
-
static create(e, t,
|
|
2241
|
-
return t instanceof v ? new
|
|
2234
|
+
static create(e, t, r) {
|
|
2235
|
+
return t instanceof v ? new ge({
|
|
2242
2236
|
keyType: e,
|
|
2243
2237
|
valueType: t,
|
|
2244
2238
|
typeName: y.ZodRecord,
|
|
2245
|
-
..._(
|
|
2246
|
-
}) : new
|
|
2247
|
-
keyType:
|
|
2239
|
+
..._(r)
|
|
2240
|
+
}) : new ge({
|
|
2241
|
+
keyType: R.create(),
|
|
2248
2242
|
valueType: e,
|
|
2249
2243
|
typeName: y.ZodRecord,
|
|
2250
2244
|
..._(t)
|
|
2251
2245
|
});
|
|
2252
2246
|
}
|
|
2253
2247
|
}
|
|
2254
|
-
class
|
|
2248
|
+
class Ne extends v {
|
|
2255
2249
|
get keySchema() {
|
|
2256
2250
|
return this._def.keyType;
|
|
2257
2251
|
}
|
|
@@ -2259,18 +2253,18 @@ class Ae extends v {
|
|
|
2259
2253
|
return this._def.valueType;
|
|
2260
2254
|
}
|
|
2261
2255
|
_parse(e) {
|
|
2262
|
-
const { status: t, ctx:
|
|
2263
|
-
if (
|
|
2264
|
-
return l(
|
|
2256
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2257
|
+
if (r.parsedType !== f.map)
|
|
2258
|
+
return l(r, {
|
|
2265
2259
|
code: d.invalid_type,
|
|
2266
2260
|
expected: f.map,
|
|
2267
|
-
received:
|
|
2261
|
+
received: r.parsedType
|
|
2268
2262
|
}), m;
|
|
2269
|
-
const n = this._def.keyType, a = this._def.valueType, i = [...
|
|
2270
|
-
key: n._parse(new
|
|
2271
|
-
value: a._parse(new
|
|
2263
|
+
const n = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, c], u) => ({
|
|
2264
|
+
key: n._parse(new $(r, o, r.path, [u, "key"])),
|
|
2265
|
+
value: a._parse(new $(r, c, r.path, [u, "value"]))
|
|
2272
2266
|
}));
|
|
2273
|
-
if (
|
|
2267
|
+
if (r.common.async) {
|
|
2274
2268
|
const o = /* @__PURE__ */ new Map();
|
|
2275
2269
|
return Promise.resolve().then(async () => {
|
|
2276
2270
|
for (const c of i) {
|
|
@@ -2293,30 +2287,30 @@ class Ae extends v {
|
|
|
2293
2287
|
}
|
|
2294
2288
|
}
|
|
2295
2289
|
}
|
|
2296
|
-
|
|
2290
|
+
Ne.create = (s, e, t) => new Ne({
|
|
2297
2291
|
valueType: e,
|
|
2298
|
-
keyType:
|
|
2292
|
+
keyType: s,
|
|
2299
2293
|
typeName: y.ZodMap,
|
|
2300
2294
|
..._(t)
|
|
2301
2295
|
});
|
|
2302
|
-
class
|
|
2296
|
+
class X extends v {
|
|
2303
2297
|
_parse(e) {
|
|
2304
|
-
const { status: t, ctx:
|
|
2305
|
-
if (
|
|
2306
|
-
return l(
|
|
2298
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2299
|
+
if (r.parsedType !== f.set)
|
|
2300
|
+
return l(r, {
|
|
2307
2301
|
code: d.invalid_type,
|
|
2308
2302
|
expected: f.set,
|
|
2309
|
-
received:
|
|
2303
|
+
received: r.parsedType
|
|
2310
2304
|
}), m;
|
|
2311
2305
|
const n = this._def;
|
|
2312
|
-
n.minSize !== null &&
|
|
2306
|
+
n.minSize !== null && r.data.size < n.minSize.value && (l(r, {
|
|
2313
2307
|
code: d.too_small,
|
|
2314
2308
|
minimum: n.minSize.value,
|
|
2315
2309
|
type: "set",
|
|
2316
2310
|
inclusive: !0,
|
|
2317
2311
|
exact: !1,
|
|
2318
2312
|
message: n.minSize.message
|
|
2319
|
-
}), t.dirty()), n.maxSize !== null &&
|
|
2313
|
+
}), t.dirty()), n.maxSize !== null && r.data.size > n.maxSize.value && (l(r, {
|
|
2320
2314
|
code: d.too_big,
|
|
2321
2315
|
maximum: n.maxSize.value,
|
|
2322
2316
|
type: "set",
|
|
@@ -2334,17 +2328,17 @@ class Y extends v {
|
|
|
2334
2328
|
}
|
|
2335
2329
|
return { status: t.value, value: u };
|
|
2336
2330
|
}
|
|
2337
|
-
const o = [...
|
|
2338
|
-
return
|
|
2331
|
+
const o = [...r.data.values()].map((c, u) => a._parse(new $(r, c, r.path, u)));
|
|
2332
|
+
return r.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 = (s, e) => new X({
|
|
2354
|
+
valueType: s,
|
|
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
|
}
|
|
@@ -2375,11 +2369,11 @@ class ee extends v {
|
|
|
2375
2369
|
expected: f.function,
|
|
2376
2370
|
received: t.parsedType
|
|
2377
2371
|
}), m;
|
|
2378
|
-
function
|
|
2379
|
-
return
|
|
2372
|
+
function r(o, c) {
|
|
2373
|
+
return Ae({
|
|
2380
2374
|
data: o,
|
|
2381
2375
|
path: t.path,
|
|
2382
|
-
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap,
|
|
2376
|
+
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, Oe(), ie].filter((u) => !!u),
|
|
2383
2377
|
issueData: {
|
|
2384
2378
|
code: d.invalid_arguments,
|
|
2385
2379
|
argumentsError: c
|
|
@@ -2387,10 +2381,10 @@ class ee extends v {
|
|
|
2387
2381
|
});
|
|
2388
2382
|
}
|
|
2389
2383
|
function n(o, c) {
|
|
2390
|
-
return
|
|
2384
|
+
return Ae({
|
|
2391
2385
|
data: o,
|
|
2392
2386
|
path: t.path,
|
|
2393
|
-
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap,
|
|
2387
|
+
errorMaps: [t.common.contextualErrorMap, t.schemaErrorMap, Oe(), ie].filter((u) => !!u),
|
|
2394
2388
|
issueData: {
|
|
2395
2389
|
code: d.invalid_return_type,
|
|
2396
2390
|
returnTypeError: c
|
|
@@ -2398,11 +2392,11 @@ class ee extends v {
|
|
|
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 u = new
|
|
2405
|
-
throw u.addIssue(
|
|
2397
|
+
return S(async function(...c) {
|
|
2398
|
+
const u = new O([]), p = await o._def.args.parseAsync(c, a).catch((w) => {
|
|
2399
|
+
throw u.addIssue(r(c, w)), u;
|
|
2406
2400
|
}), b = await Reflect.apply(i, this, p);
|
|
2407
2401
|
return await o._def.returns._def.type.parseAsync(b, a).catch((w) => {
|
|
2408
2402
|
throw u.addIssue(n(b, w)), u;
|
|
@@ -2410,13 +2404,13 @@ class ee extends v {
|
|
|
2410
2404
|
});
|
|
2411
2405
|
} else {
|
|
2412
2406
|
const o = this;
|
|
2413
|
-
return
|
|
2407
|
+
return S(function(...c) {
|
|
2414
2408
|
const u = o._def.args.safeParse(c, a);
|
|
2415
2409
|
if (!u.success)
|
|
2416
|
-
throw new
|
|
2410
|
+
throw new O([r(c, u.error)]);
|
|
2417
2411
|
const p = Reflect.apply(i, this, u.data), b = o._def.returns.safeParse(p, a);
|
|
2418
2412
|
if (!b.success)
|
|
2419
|
-
throw new
|
|
2413
|
+
throw new O([n(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(Y.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
|
});
|
|
@@ -2445,16 +2439,16 @@ class ee extends v {
|
|
|
2445
2439
|
strictImplement(e) {
|
|
2446
2440
|
return this.parse(e);
|
|
2447
2441
|
}
|
|
2448
|
-
static create(e, t,
|
|
2449
|
-
return new
|
|
2450
|
-
args: e ||
|
|
2451
|
-
returns: t ||
|
|
2442
|
+
static create(e, t, r) {
|
|
2443
|
+
return new ae({
|
|
2444
|
+
args: e || P.create([]).rest(Y.create()),
|
|
2445
|
+
returns: t || Y.create(),
|
|
2452
2446
|
typeName: y.ZodFunction,
|
|
2453
|
-
..._(
|
|
2447
|
+
..._(r)
|
|
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,12 +2457,12 @@ 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 = (s, e) => new ve({
|
|
2461
|
+
getter: s,
|
|
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);
|
|
@@ -2484,37 +2478,37 @@ class me extends v {
|
|
|
2484
2478
|
return this._def.value;
|
|
2485
2479
|
}
|
|
2486
2480
|
}
|
|
2487
|
-
|
|
2488
|
-
value:
|
|
2481
|
+
xe.create = (s, e) => new xe({
|
|
2482
|
+
value: s,
|
|
2489
2483
|
typeName: y.ZodLiteral,
|
|
2490
2484
|
..._(e)
|
|
2491
2485
|
});
|
|
2492
|
-
function
|
|
2493
|
-
return new
|
|
2494
|
-
values:
|
|
2486
|
+
function it(s, e) {
|
|
2487
|
+
return new F({
|
|
2488
|
+
values: s,
|
|
2495
2489
|
typeName: y.ZodEnum,
|
|
2496
2490
|
..._(e)
|
|
2497
2491
|
});
|
|
2498
2492
|
}
|
|
2499
|
-
class
|
|
2493
|
+
class F extends v {
|
|
2500
2494
|
_parse(e) {
|
|
2501
2495
|
if (typeof e.data != "string") {
|
|
2502
|
-
const t = this._getOrReturnCtx(e),
|
|
2496
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2503
2497
|
return l(t, {
|
|
2504
|
-
expected: x.joinValues(
|
|
2498
|
+
expected: x.joinValues(r),
|
|
2505
2499
|
received: t.parsedType,
|
|
2506
2500
|
code: d.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
|
-
const t = this._getOrReturnCtx(e),
|
|
2504
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2511
2505
|
return l(t, {
|
|
2512
2506
|
received: t.data,
|
|
2513
2507
|
code: d.invalid_enum_value,
|
|
2514
|
-
options:
|
|
2508
|
+
options: r
|
|
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 F.create(e, {
|
|
2542
2536
|
...this._def,
|
|
2543
2537
|
...t
|
|
2544
2538
|
});
|
|
2545
2539
|
}
|
|
2546
2540
|
exclude(e, t = this._def) {
|
|
2547
|
-
return
|
|
2541
|
+
return F.create(this.options.filter((r) => !e.includes(r)), {
|
|
2548
2542
|
...this._def,
|
|
2549
2543
|
...t
|
|
2550
2544
|
});
|
|
2551
2545
|
}
|
|
2552
2546
|
}
|
|
2553
|
-
|
|
2554
|
-
class
|
|
2547
|
+
F.create = it;
|
|
2548
|
+
class be extends v {
|
|
2555
2549
|
_parse(e) {
|
|
2556
|
-
const t = x.getValidEnumValues(this._def.values),
|
|
2557
|
-
if (
|
|
2550
|
+
const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2551
|
+
if (r.parsedType !== f.string && r.parsedType !== f.number) {
|
|
2558
2552
|
const n = x.objectValues(t);
|
|
2559
|
-
return l(
|
|
2553
|
+
return l(r, {
|
|
2560
2554
|
expected: x.joinValues(n),
|
|
2561
|
-
received:
|
|
2555
|
+
received: r.parsedType,
|
|
2562
2556
|
code: d.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
2560
|
const n = x.objectValues(t);
|
|
2567
|
-
return l(
|
|
2568
|
-
received:
|
|
2561
|
+
return l(r, {
|
|
2562
|
+
received: r.data,
|
|
2569
2563
|
code: d.invalid_enum_value,
|
|
2570
2564
|
options: n
|
|
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 = (s, e) => new be({
|
|
2574
|
+
values: s,
|
|
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
|
}
|
|
@@ -2593,15 +2587,15 @@ class se extends v {
|
|
|
2593
2587
|
expected: f.promise,
|
|
2594
2588
|
received: t.parsedType
|
|
2595
2589
|
}), m;
|
|
2596
|
-
const
|
|
2597
|
-
return
|
|
2590
|
+
const r = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2591
|
+
return S(r.then((n) => this._def.type.parseAsync(n, {
|
|
2598
2592
|
path: t.path,
|
|
2599
2593
|
errorMap: t.common.contextualErrorMap
|
|
2600
2594
|
})));
|
|
2601
2595
|
}
|
|
2602
2596
|
}
|
|
2603
|
-
|
|
2604
|
-
type:
|
|
2597
|
+
ce.create = (s, e) => new ce({
|
|
2598
|
+
type: s,
|
|
2605
2599
|
typeName: y.ZodPromise,
|
|
2606
2600
|
..._(e)
|
|
2607
2601
|
});
|
|
@@ -2613,122 +2607,122 @@ 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:
|
|
2610
|
+
const { status: t, ctx: r } = this._processInputParams(e), n = this._def.effect || null, a = {
|
|
2617
2611
|
addIssue: (i) => {
|
|
2618
|
-
l(
|
|
2612
|
+
l(r, i), i.fatal ? t.abort() : t.dirty();
|
|
2619
2613
|
},
|
|
2620
2614
|
get path() {
|
|
2621
|
-
return
|
|
2615
|
+
return r.path;
|
|
2622
2616
|
}
|
|
2623
2617
|
};
|
|
2624
2618
|
if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
|
|
2625
|
-
const i = n.transform(
|
|
2626
|
-
if (
|
|
2619
|
+
const i = n.transform(r.data, a);
|
|
2620
|
+
if (r.common.async)
|
|
2627
2621
|
return Promise.resolve(i).then(async (o) => {
|
|
2628
2622
|
if (t.value === "aborted")
|
|
2629
2623
|
return m;
|
|
2630
2624
|
const c = await this._def.schema._parseAsync({
|
|
2631
2625
|
data: o,
|
|
2632
|
-
path:
|
|
2633
|
-
parent:
|
|
2626
|
+
path: r.path,
|
|
2627
|
+
parent: r
|
|
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" ? ne(c.value) : c;
|
|
2636
2630
|
});
|
|
2637
2631
|
{
|
|
2638
2632
|
if (t.value === "aborted")
|
|
2639
2633
|
return m;
|
|
2640
2634
|
const o = this._def.schema._parseSync({
|
|
2641
2635
|
data: i,
|
|
2642
|
-
path:
|
|
2643
|
-
parent:
|
|
2636
|
+
path: r.path,
|
|
2637
|
+
parent: r
|
|
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" ? ne(o.value) : o;
|
|
2646
2640
|
}
|
|
2647
2641
|
}
|
|
2648
2642
|
if (n.type === "refinement") {
|
|
2649
2643
|
const i = (o) => {
|
|
2650
2644
|
const c = n.refinement(o, a);
|
|
2651
|
-
if (
|
|
2645
|
+
if (r.common.async)
|
|
2652
2646
|
return Promise.resolve(c);
|
|
2653
2647
|
if (c instanceof Promise)
|
|
2654
2648
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2655
2649
|
return o;
|
|
2656
2650
|
};
|
|
2657
|
-
if (
|
|
2651
|
+
if (r.common.async === !1) {
|
|
2658
2652
|
const o = this._def.schema._parseSync({
|
|
2659
|
-
data:
|
|
2660
|
-
path:
|
|
2661
|
-
parent:
|
|
2653
|
+
data: r.data,
|
|
2654
|
+
path: r.path,
|
|
2655
|
+
parent: r
|
|
2662
2656
|
});
|
|
2663
2657
|
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2664
2658
|
} else
|
|
2665
|
-
return this._def.schema._parseAsync({ data:
|
|
2659
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2666
2660
|
}
|
|
2667
2661
|
if (n.type === "transform")
|
|
2668
|
-
if (
|
|
2662
|
+
if (r.common.async === !1) {
|
|
2669
2663
|
const i = this._def.schema._parseSync({
|
|
2670
|
-
data:
|
|
2671
|
-
path:
|
|
2672
|
-
parent:
|
|
2664
|
+
data: r.data,
|
|
2665
|
+
path: r.path,
|
|
2666
|
+
parent: r
|
|
2673
2667
|
});
|
|
2674
|
-
if (!
|
|
2668
|
+
if (!K(i))
|
|
2675
2669
|
return m;
|
|
2676
2670
|
const o = n.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:
|
|
2675
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => K(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({
|
|
2682
2676
|
status: t.value,
|
|
2683
2677
|
value: o
|
|
2684
2678
|
})) : m);
|
|
2685
2679
|
x.assertNever(n);
|
|
2686
2680
|
}
|
|
2687
2681
|
}
|
|
2688
|
-
N.create = (
|
|
2689
|
-
schema:
|
|
2682
|
+
N.create = (s, e, t) => new N({
|
|
2683
|
+
schema: s,
|
|
2690
2684
|
typeName: y.ZodEffects,
|
|
2691
2685
|
effect: e,
|
|
2692
2686
|
..._(t)
|
|
2693
2687
|
});
|
|
2694
|
-
N.createWithPreprocess = (
|
|
2688
|
+
N.createWithPreprocess = (s, e, t) => new N({
|
|
2695
2689
|
schema: e,
|
|
2696
|
-
effect: { type: "preprocess", transform:
|
|
2690
|
+
effect: { type: "preprocess", transform: s },
|
|
2697
2691
|
typeName: y.ZodEffects,
|
|
2698
2692
|
..._(t)
|
|
2699
2693
|
});
|
|
2700
|
-
class
|
|
2694
|
+
class I 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
|
+
I.create = (s, e) => new I({
|
|
2703
|
+
innerType: s,
|
|
2710
2704
|
typeName: y.ZodOptional,
|
|
2711
2705
|
..._(e)
|
|
2712
2706
|
});
|
|
2713
|
-
class
|
|
2707
|
+
class W 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
|
+
W.create = (s, e) => new W({
|
|
2716
|
+
innerType: s,
|
|
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
|
-
let
|
|
2730
|
-
return t.parsedType === f.undefined && (
|
|
2731
|
-
data:
|
|
2723
|
+
let r = t.data;
|
|
2724
|
+
return t.parsedType === f.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2725
|
+
data: r,
|
|
2732
2726
|
path: t.path,
|
|
2733
2727
|
parent: t
|
|
2734
2728
|
});
|
|
@@ -2737,42 +2731,42 @@ class _e extends v {
|
|
|
2737
2731
|
return this._def.innerType;
|
|
2738
2732
|
}
|
|
2739
2733
|
}
|
|
2740
|
-
|
|
2741
|
-
innerType:
|
|
2734
|
+
ke.create = (s, e) => new ke({
|
|
2735
|
+
innerType: s,
|
|
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
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2742
|
+
const { ctx: t } = this._processInputParams(e), r = {
|
|
2749
2743
|
...t,
|
|
2750
2744
|
common: {
|
|
2751
2745
|
...t.common,
|
|
2752
2746
|
issues: []
|
|
2753
2747
|
}
|
|
2754
2748
|
}, n = this._def.innerType._parse({
|
|
2755
|
-
data:
|
|
2756
|
-
path:
|
|
2749
|
+
data: r.data,
|
|
2750
|
+
path: r.path,
|
|
2757
2751
|
parent: {
|
|
2758
|
-
...
|
|
2752
|
+
...r
|
|
2759
2753
|
}
|
|
2760
2754
|
});
|
|
2761
|
-
return
|
|
2755
|
+
return fe(n) ? n.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 O(r.common.issues);
|
|
2766
2760
|
},
|
|
2767
|
-
input:
|
|
2761
|
+
input: r.data
|
|
2768
2762
|
})
|
|
2769
2763
|
})) : {
|
|
2770
2764
|
status: "valid",
|
|
2771
2765
|
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2772
2766
|
get error() {
|
|
2773
|
-
return new
|
|
2767
|
+
return new O(r.common.issues);
|
|
2774
2768
|
},
|
|
2775
|
-
input:
|
|
2769
|
+
input: r.data
|
|
2776
2770
|
})
|
|
2777
2771
|
};
|
|
2778
2772
|
}
|
|
@@ -2780,8 +2774,8 @@ class ge extends v {
|
|
|
2780
2774
|
return this._def.innerType;
|
|
2781
2775
|
}
|
|
2782
2776
|
}
|
|
2783
|
-
|
|
2784
|
-
innerType:
|
|
2777
|
+
we.create = (s, e) => new we({
|
|
2778
|
+
innerType: s,
|
|
2785
2779
|
typeName: y.ZodCatch,
|
|
2786
2780
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2787
2781
|
..._(e)
|
|
@@ -2789,26 +2783,26 @@ ge.create = (r, e) => new ge({
|
|
|
2789
2783
|
class je extends v {
|
|
2790
2784
|
_parse(e) {
|
|
2791
2785
|
if (this._getType(e) !== f.nan) {
|
|
2792
|
-
const
|
|
2793
|
-
return l(
|
|
2786
|
+
const r = this._getOrReturnCtx(e);
|
|
2787
|
+
return l(r, {
|
|
2794
2788
|
code: d.invalid_type,
|
|
2795
2789
|
expected: f.nan,
|
|
2796
|
-
received:
|
|
2790
|
+
received: r.parsedType
|
|
2797
2791
|
}), m;
|
|
2798
2792
|
}
|
|
2799
2793
|
return { status: "valid", value: e.data };
|
|
2800
2794
|
}
|
|
2801
2795
|
}
|
|
2802
|
-
je.create = (
|
|
2796
|
+
je.create = (s) => new je({
|
|
2803
2797
|
typeName: y.ZodNaN,
|
|
2804
|
-
..._(
|
|
2798
|
+
..._(s)
|
|
2805
2799
|
});
|
|
2806
|
-
const
|
|
2807
|
-
class
|
|
2800
|
+
const Vt = Symbol("zod_brand");
|
|
2801
|
+
class Ye extends v {
|
|
2808
2802
|
_parse(e) {
|
|
2809
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2803
|
+
const { ctx: t } = this._processInputParams(e), r = t.data;
|
|
2810
2804
|
return this._def.type._parse({
|
|
2811
|
-
data:
|
|
2805
|
+
data: r,
|
|
2812
2806
|
path: t.path,
|
|
2813
2807
|
parent: t
|
|
2814
2808
|
});
|
|
@@ -2817,280 +2811,281 @@ 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
|
-
const { status: t, ctx:
|
|
2823
|
-
if (
|
|
2816
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2817
|
+
if (r.common.async)
|
|
2824
2818
|
return (async () => {
|
|
2825
2819
|
const a = await this._def.in._parseAsync({
|
|
2826
|
-
data:
|
|
2827
|
-
path:
|
|
2828
|
-
parent:
|
|
2820
|
+
data: r.data,
|
|
2821
|
+
path: r.path,
|
|
2822
|
+
parent: r
|
|
2829
2823
|
});
|
|
2830
|
-
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(),
|
|
2824
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), ne(a.value)) : this._def.out._parseAsync({
|
|
2831
2825
|
data: a.value,
|
|
2832
|
-
path:
|
|
2833
|
-
parent:
|
|
2826
|
+
path: r.path,
|
|
2827
|
+
parent: r
|
|
2834
2828
|
});
|
|
2835
2829
|
})();
|
|
2836
2830
|
{
|
|
2837
2831
|
const n = this._def.in._parseSync({
|
|
2838
|
-
data:
|
|
2839
|
-
path:
|
|
2840
|
-
parent:
|
|
2832
|
+
data: r.data,
|
|
2833
|
+
path: r.path,
|
|
2834
|
+
parent: r
|
|
2841
2835
|
});
|
|
2842
2836
|
return n.status === "aborted" ? m : n.status === "dirty" ? (t.dirty(), {
|
|
2843
2837
|
status: "dirty",
|
|
2844
2838
|
value: n.value
|
|
2845
2839
|
}) : this._def.out._parseSync({
|
|
2846
2840
|
data: n.value,
|
|
2847
|
-
path:
|
|
2848
|
-
parent:
|
|
2841
|
+
path: r.path,
|
|
2842
|
+
parent: r
|
|
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),
|
|
2863
|
-
return
|
|
2856
|
+
const t = this._def.innerType._parse(e), r = (n) => (K(n) && (n.value = Object.freeze(n.value)), n);
|
|
2857
|
+
return fe(t) ? t.then((n) => r(n)) : r(t);
|
|
2864
2858
|
}
|
|
2865
2859
|
unwrap() {
|
|
2866
2860
|
return this._def.innerType;
|
|
2867
2861
|
}
|
|
2868
2862
|
}
|
|
2869
|
-
|
|
2870
|
-
innerType:
|
|
2863
|
+
Te.create = (s, e) => new Te({
|
|
2864
|
+
innerType: s,
|
|
2871
2865
|
typeName: y.ZodReadonly,
|
|
2872
2866
|
..._(e)
|
|
2873
2867
|
});
|
|
2874
|
-
function
|
|
2875
|
-
const t = typeof
|
|
2868
|
+
function Xe(s, e) {
|
|
2869
|
+
const t = typeof s == "function" ? s(e) : typeof s == "string" ? { message: s } : s;
|
|
2876
2870
|
return typeof t == "string" ? { message: t } : t;
|
|
2877
2871
|
}
|
|
2878
|
-
function
|
|
2879
|
-
return
|
|
2880
|
-
const a = r
|
|
2872
|
+
function ot(s, e = {}, t) {
|
|
2873
|
+
return s ? oe.create().superRefine((r, n) => {
|
|
2874
|
+
const a = s(r);
|
|
2881
2875
|
if (a instanceof Promise)
|
|
2882
2876
|
return a.then((i) => {
|
|
2883
2877
|
if (!i) {
|
|
2884
|
-
const o =
|
|
2878
|
+
const o = Xe(e, r), c = o.fatal ?? t ?? !0;
|
|
2885
2879
|
n.addIssue({ code: "custom", ...o, fatal: c });
|
|
2886
2880
|
}
|
|
2887
2881
|
});
|
|
2888
2882
|
if (!a) {
|
|
2889
|
-
const i =
|
|
2883
|
+
const i = Xe(e, r), o = i.fatal ?? t ?? !0;
|
|
2890
2884
|
n.addIssue({ code: "custom", ...i, fatal: o });
|
|
2891
2885
|
}
|
|
2892
|
-
}) :
|
|
2886
|
+
}) : oe.create();
|
|
2893
2887
|
}
|
|
2894
|
-
const
|
|
2888
|
+
const zt = {
|
|
2895
2889
|
object: k.lazycreate
|
|
2896
2890
|
};
|
|
2897
2891
|
var y;
|
|
2898
|
-
(function(
|
|
2899
|
-
|
|
2892
|
+
(function(s) {
|
|
2893
|
+
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.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 = (s, e = {
|
|
2896
|
+
message: `Input not instance of ${s.name}`
|
|
2897
|
+
}) => ot((t) => t instanceof s, e), g = R.create, Ke = U.create, Ut = je.create, qt = q.create, Ce = he.create, Ft = G.create, Wt = Re.create, Jt = pe.create, Qt = me.create, Ht = oe.create, Yt = Y.create, Kt = z.create, Gt = Ee.create, A = E.create, j = k.create, Xt = k.strictCreate, es = ye.create, ts = $e.create, ss = _e.create, rs = P.create, ct = ge.create, ns = Ne.create, as = X.create, is = ae.create, os = ve.create, cs = xe.create, ds = F.create, us = be.create, ls = ce.create, et = N.create, fs = I.create, hs = W.create, ps = N.createWithPreprocess, ms = Se.create, ys = () => g().optional(), _s = () => Ke().optional(), gs = () => Ce().optional(), vs = {
|
|
2898
|
+
string: ((s) => R.create({ ...s, coerce: !0 })),
|
|
2899
|
+
number: ((s) => U.create({ ...s, coerce: !0 })),
|
|
2900
|
+
boolean: ((s) => he.create({
|
|
2901
|
+
...s,
|
|
2908
2902
|
coerce: !0
|
|
2909
|
-
}),
|
|
2910
|
-
bigint: (
|
|
2911
|
-
date: (
|
|
2912
|
-
},
|
|
2903
|
+
})),
|
|
2904
|
+
bigint: ((s) => q.create({ ...s, coerce: !0 })),
|
|
2905
|
+
date: ((s) => G.create({ ...s, coerce: !0 }))
|
|
2906
|
+
}, xs = m, bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2913
2907
|
__proto__: null,
|
|
2914
|
-
BRAND:
|
|
2915
|
-
DIRTY:
|
|
2916
|
-
EMPTY_PATH:
|
|
2908
|
+
BRAND: Vt,
|
|
2909
|
+
DIRTY: ne,
|
|
2910
|
+
EMPTY_PATH: gt,
|
|
2917
2911
|
INVALID: m,
|
|
2918
|
-
NEVER:
|
|
2919
|
-
OK:
|
|
2912
|
+
NEVER: xs,
|
|
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:
|
|
2916
|
+
ZodAny: oe,
|
|
2917
|
+
ZodArray: E,
|
|
2918
|
+
ZodBigInt: q,
|
|
2919
|
+
ZodBoolean: he,
|
|
2920
|
+
ZodBranded: Ye,
|
|
2921
|
+
ZodCatch: we,
|
|
2922
|
+
ZodDate: G,
|
|
2923
|
+
ZodDefault: ke,
|
|
2924
|
+
ZodDiscriminatedUnion: $e,
|
|
2931
2925
|
ZodEffects: N,
|
|
2932
|
-
ZodEnum:
|
|
2933
|
-
ZodError:
|
|
2926
|
+
ZodEnum: F,
|
|
2927
|
+
ZodError: O,
|
|
2934
2928
|
get ZodFirstPartyTypeKind() {
|
|
2935
2929
|
return y;
|
|
2936
2930
|
},
|
|
2937
|
-
ZodFunction:
|
|
2938
|
-
ZodIntersection:
|
|
2931
|
+
ZodFunction: ae,
|
|
2932
|
+
ZodIntersection: _e,
|
|
2939
2933
|
ZodIssueCode: d,
|
|
2940
|
-
ZodLazy:
|
|
2941
|
-
ZodLiteral:
|
|
2942
|
-
ZodMap:
|
|
2934
|
+
ZodLazy: ve,
|
|
2935
|
+
ZodLiteral: xe,
|
|
2936
|
+
ZodMap: Ne,
|
|
2943
2937
|
ZodNaN: je,
|
|
2944
|
-
ZodNativeEnum:
|
|
2945
|
-
ZodNever:
|
|
2946
|
-
ZodNull:
|
|
2947
|
-
ZodNullable:
|
|
2948
|
-
ZodNumber:
|
|
2938
|
+
ZodNativeEnum: be,
|
|
2939
|
+
ZodNever: z,
|
|
2940
|
+
ZodNull: me,
|
|
2941
|
+
ZodNullable: W,
|
|
2942
|
+
ZodNumber: U,
|
|
2949
2943
|
ZodObject: k,
|
|
2950
|
-
ZodOptional:
|
|
2944
|
+
ZodOptional: I,
|
|
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:
|
|
2951
|
+
ZodSet: X,
|
|
2952
|
+
ZodString: R,
|
|
2953
|
+
ZodSymbol: Re,
|
|
2960
2954
|
ZodTransformer: N,
|
|
2961
|
-
ZodTuple:
|
|
2955
|
+
ZodTuple: P,
|
|
2962
2956
|
ZodType: v,
|
|
2963
|
-
ZodUndefined:
|
|
2964
|
-
ZodUnion:
|
|
2965
|
-
ZodUnknown:
|
|
2966
|
-
ZodVoid:
|
|
2957
|
+
ZodUndefined: pe,
|
|
2958
|
+
ZodUnion: ye,
|
|
2959
|
+
ZodUnknown: Y,
|
|
2960
|
+
ZodVoid: Ee,
|
|
2967
2961
|
addIssueToContext: l,
|
|
2968
|
-
any:
|
|
2969
|
-
array:
|
|
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:
|
|
2987
|
-
isDirty:
|
|
2988
|
-
isValid:
|
|
2989
|
-
late:
|
|
2990
|
-
lazy:
|
|
2991
|
-
literal:
|
|
2992
|
-
makeIssue:
|
|
2993
|
-
map:
|
|
2994
|
-
nan:
|
|
2995
|
-
nativeEnum:
|
|
2996
|
-
never:
|
|
2997
|
-
null:
|
|
2998
|
-
nullable:
|
|
2999
|
-
number:
|
|
3000
|
-
object:
|
|
2962
|
+
any: Ht,
|
|
2963
|
+
array: A,
|
|
2964
|
+
bigint: qt,
|
|
2965
|
+
boolean: Ce,
|
|
2966
|
+
coerce: vs,
|
|
2967
|
+
custom: ot,
|
|
2968
|
+
date: Ft,
|
|
2969
|
+
datetimeRegex: at,
|
|
2970
|
+
defaultErrorMap: ie,
|
|
2971
|
+
discriminatedUnion: ts,
|
|
2972
|
+
effect: et,
|
|
2973
|
+
enum: ds,
|
|
2974
|
+
function: is,
|
|
2975
|
+
getErrorMap: Oe,
|
|
2976
|
+
getParsedType: V,
|
|
2977
|
+
instanceof: Bt,
|
|
2978
|
+
intersection: ss,
|
|
2979
|
+
isAborted: We,
|
|
2980
|
+
isAsync: fe,
|
|
2981
|
+
isDirty: Je,
|
|
2982
|
+
isValid: K,
|
|
2983
|
+
late: zt,
|
|
2984
|
+
lazy: os,
|
|
2985
|
+
literal: cs,
|
|
2986
|
+
makeIssue: Ae,
|
|
2987
|
+
map: ns,
|
|
2988
|
+
nan: Ut,
|
|
2989
|
+
nativeEnum: us,
|
|
2990
|
+
never: Kt,
|
|
2991
|
+
null: Qt,
|
|
2992
|
+
nullable: hs,
|
|
2993
|
+
number: Ke,
|
|
2994
|
+
object: j,
|
|
3001
2995
|
get objectUtil() {
|
|
3002
2996
|
return Fe;
|
|
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: gs,
|
|
2999
|
+
onumber: _s,
|
|
3000
|
+
optional: fs,
|
|
3001
|
+
ostring: ys,
|
|
3002
|
+
pipeline: ms,
|
|
3003
|
+
preprocess: ps,
|
|
3004
|
+
promise: ls,
|
|
3005
|
+
quotelessJson: yt,
|
|
3006
|
+
record: ct,
|
|
3007
|
+
set: as,
|
|
3008
|
+
setErrorMap: _t,
|
|
3009
|
+
strictObject: Xt,
|
|
3016
3010
|
string: g,
|
|
3017
|
-
symbol:
|
|
3018
|
-
transformer:
|
|
3019
|
-
tuple:
|
|
3020
|
-
undefined:
|
|
3021
|
-
union:
|
|
3022
|
-
unknown:
|
|
3011
|
+
symbol: Wt,
|
|
3012
|
+
transformer: et,
|
|
3013
|
+
tuple: rs,
|
|
3014
|
+
undefined: Jt,
|
|
3015
|
+
union: es,
|
|
3016
|
+
unknown: Yt,
|
|
3023
3017
|
get util() {
|
|
3024
3018
|
return x;
|
|
3025
3019
|
},
|
|
3026
3020
|
void: Gt
|
|
3027
3021
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3028
|
-
|
|
3029
|
-
const
|
|
3030
|
-
const
|
|
3022
|
+
mt(bs);
|
|
3023
|
+
const ks = (s, e) => e.skipDedupe || e.method !== "GET", ws = (s, e) => e.method + "@" + s, Ts = (s) => s.clone(), Ss = ({ skip: s = ks, key: e = ws, resolver: t = Ts } = {}) => {
|
|
3024
|
+
const r = /* @__PURE__ */ new Map();
|
|
3031
3025
|
return (n) => (a, i) => {
|
|
3032
|
-
if (
|
|
3026
|
+
if (s(a, i))
|
|
3033
3027
|
return n(a, i);
|
|
3034
3028
|
const o = e(a, i);
|
|
3035
|
-
if (!
|
|
3036
|
-
|
|
3029
|
+
if (!r.has(o))
|
|
3030
|
+
r.set(o, []);
|
|
3037
3031
|
else
|
|
3038
3032
|
return new Promise((c, u) => {
|
|
3039
|
-
|
|
3033
|
+
r.get(o).push([c, u]);
|
|
3040
3034
|
});
|
|
3041
3035
|
try {
|
|
3042
|
-
return n(a, i).then((c) => (
|
|
3043
|
-
throw
|
|
3036
|
+
return n(a, i).then((c) => (r.get(o).forEach(([u]) => u(t(c))), r.delete(o), c)).catch((c) => {
|
|
3037
|
+
throw r.get(o).forEach(([, u]) => u(c)), r.delete(o), c;
|
|
3044
3038
|
});
|
|
3045
3039
|
} catch (c) {
|
|
3046
|
-
return
|
|
3040
|
+
return r.delete(o), Promise.reject(c);
|
|
3047
3041
|
}
|
|
3048
3042
|
};
|
|
3049
|
-
},
|
|
3043
|
+
}, Cs = (s, e) => s * e, Os = (s) => s && (s.ok || s.status >= 400 && s.status < 500), As = ({ delayTimer: s = 500, delayRamp: e = Cs, maxAttempts: t = 10, until: r = Os, onRetry: n = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: i = !1, skip: o } = {}) => (c) => (u, p) => {
|
|
3050
3044
|
let b = 0;
|
|
3051
3045
|
if (o && o(u, p))
|
|
3052
3046
|
return c(u, p);
|
|
3053
|
-
const
|
|
3054
|
-
const
|
|
3047
|
+
const C = (w, Z) => Promise.resolve(r(w, Z)).then((de) => de ? w && i ? w : Z ? Promise.reject(Z) : w : (b++, !t || b <= t ? new Promise((M) => {
|
|
3048
|
+
const J = e(s, b);
|
|
3055
3049
|
setTimeout(() => {
|
|
3056
3050
|
typeof n == "function" ? Promise.resolve(n({
|
|
3057
3051
|
response: w,
|
|
3058
|
-
error:
|
|
3052
|
+
error: Z,
|
|
3059
3053
|
url: u,
|
|
3054
|
+
attempt: b,
|
|
3060
3055
|
options: p
|
|
3061
|
-
})).then((
|
|
3062
|
-
var
|
|
3063
|
-
|
|
3064
|
-
}) :
|
|
3065
|
-
},
|
|
3066
|
-
}).then(
|
|
3056
|
+
})).then((D = {}) => {
|
|
3057
|
+
var ee, Q;
|
|
3058
|
+
M(c((ee = D && D.url) !== null && ee !== void 0 ? ee : u, (Q = D && D.options) !== null && Q !== void 0 ? Q : p));
|
|
3059
|
+
}) : M(c(u, p));
|
|
3060
|
+
}, J);
|
|
3061
|
+
}).then(C).catch((M) => {
|
|
3067
3062
|
if (!a)
|
|
3068
|
-
throw
|
|
3069
|
-
return
|
|
3070
|
-
}) : w && i ? w : Promise.reject(
|
|
3071
|
-
return c(u, p).then(
|
|
3063
|
+
throw M;
|
|
3064
|
+
return C(null, M);
|
|
3065
|
+
}) : w && i ? w : Promise.reject(Z || new Error("Number of attempts exceeded."))));
|
|
3066
|
+
return c(u, 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
|
+
}, Ze = j({
|
|
3072
|
+
code: Ke(),
|
|
3078
3073
|
message: g()
|
|
3079
|
-
}),
|
|
3074
|
+
}), Rs = j({
|
|
3080
3075
|
message: g()
|
|
3081
|
-
}),
|
|
3082
|
-
emails:
|
|
3076
|
+
}), Es = j({
|
|
3077
|
+
emails: A(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
|
-
}),
|
|
3088
|
-
ciphers:
|
|
3082
|
+
}), Ns = j({
|
|
3083
|
+
ciphers: A(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
|
+
}), js = j({
|
|
3094
3089
|
id: g(),
|
|
3095
3090
|
bundle_method: g().optional(),
|
|
3096
3091
|
certificate_authority: g(),
|
|
@@ -3098,90 +3093,90 @@ const xr = (r, e) => e.skipDedupe || e.method !== "GET", kr = (r, e) => e.method
|
|
|
3098
3093
|
custom_csr_id: g().optional(),
|
|
3099
3094
|
custom_key: g().optional(),
|
|
3100
3095
|
expires_on: g().optional(),
|
|
3101
|
-
hosts:
|
|
3096
|
+
hosts: A(g()).optional(),
|
|
3102
3097
|
issuer: g().optional(),
|
|
3103
3098
|
method: g(),
|
|
3104
3099
|
serial_number: g().optional(),
|
|
3105
|
-
settings:
|
|
3100
|
+
settings: Ns.optional(),
|
|
3106
3101
|
signature: g().optional(),
|
|
3107
3102
|
type: g(),
|
|
3108
3103
|
uploaded_on: g().optional(),
|
|
3109
|
-
validation_errors:
|
|
3110
|
-
validation_records:
|
|
3111
|
-
wildcard:
|
|
3112
|
-
}),
|
|
3104
|
+
validation_errors: A(Rs).optional(),
|
|
3105
|
+
validation_records: A(Es).optional(),
|
|
3106
|
+
wildcard: Ce()
|
|
3107
|
+
}), Zs = j({
|
|
3113
3108
|
name: g(),
|
|
3114
3109
|
type: g(),
|
|
3115
3110
|
value: g()
|
|
3116
|
-
}),
|
|
3111
|
+
}), Is = 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: js,
|
|
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: Zs.optional(),
|
|
3122
|
+
ownership_verification_http: Is.optional(),
|
|
3128
3123
|
status: g(),
|
|
3129
|
-
verification_errors:
|
|
3124
|
+
verification_errors: A(g()).optional(),
|
|
3130
3125
|
created_at: g()
|
|
3131
|
-
}), Ue =
|
|
3132
|
-
errors:
|
|
3133
|
-
messages:
|
|
3134
|
-
success:
|
|
3135
|
-
result:
|
|
3136
|
-
}),
|
|
3137
|
-
errors:
|
|
3138
|
-
messages:
|
|
3139
|
-
success:
|
|
3140
|
-
result:
|
|
3126
|
+
}), Ue = j({
|
|
3127
|
+
errors: A(Ze),
|
|
3128
|
+
messages: A(Ze),
|
|
3129
|
+
success: Ce(),
|
|
3130
|
+
result: dt
|
|
3131
|
+
}), $s = j({
|
|
3132
|
+
errors: A(Ze),
|
|
3133
|
+
messages: A(Ze),
|
|
3134
|
+
success: Ce(),
|
|
3135
|
+
result: A(dt)
|
|
3141
3136
|
});
|
|
3142
|
-
function
|
|
3143
|
-
return
|
|
3144
|
-
"X-Auth-Email":
|
|
3145
|
-
"X-Auth-Key":
|
|
3137
|
+
function se(s) {
|
|
3138
|
+
return ft(`https://api.cloudflare.com/client/v4/zones/${s.zoneId}`).headers({
|
|
3139
|
+
"X-Auth-Email": s.authEmail,
|
|
3140
|
+
"X-Auth-Key": s.authKey,
|
|
3146
3141
|
"Content-Type": "application/json"
|
|
3147
|
-
}).middlewares([
|
|
3142
|
+
}).middlewares([As(), Ss()]);
|
|
3148
3143
|
}
|
|
3149
|
-
function
|
|
3144
|
+
function qe(s) {
|
|
3150
3145
|
const e = [];
|
|
3151
|
-
if (
|
|
3152
|
-
for (const t of
|
|
3146
|
+
if (s.ssl.validation_records)
|
|
3147
|
+
for (const t of s.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 s.ownership_verification && e.push({
|
|
3159
3154
|
name: "txt",
|
|
3160
|
-
record:
|
|
3161
|
-
domain:
|
|
3155
|
+
record: s.ownership_verification.value,
|
|
3156
|
+
domain: s.ownership_verification.name
|
|
3162
3157
|
}), {
|
|
3163
|
-
custom_domain_id:
|
|
3164
|
-
domain:
|
|
3165
|
-
primary:
|
|
3166
|
-
status:
|
|
3158
|
+
custom_domain_id: s.id,
|
|
3159
|
+
domain: s.hostname,
|
|
3160
|
+
primary: s.primary,
|
|
3161
|
+
status: s.status === "active" ? "ready" : "pending",
|
|
3167
3162
|
type: "auth0_managed_certs",
|
|
3168
3163
|
verification: {
|
|
3169
|
-
methods:
|
|
3164
|
+
methods: A(lt).parse(e)
|
|
3170
3165
|
}
|
|
3171
3166
|
};
|
|
3172
3167
|
}
|
|
3173
|
-
function
|
|
3168
|
+
function Ps(s) {
|
|
3174
3169
|
return {
|
|
3175
3170
|
create: async (e, t) => {
|
|
3176
|
-
const { result:
|
|
3177
|
-
await
|
|
3171
|
+
const { result: r, errors: n, success: a } = Ue.parse(
|
|
3172
|
+
await se(s).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: s.enterprise ? {
|
|
3185
3180
|
tenant_id: e
|
|
3186
3181
|
} : void 0
|
|
3187
3182
|
},
|
|
@@ -3190,88 +3185,83 @@ function Ir(r) {
|
|
|
3190
3185
|
);
|
|
3191
3186
|
if (!a)
|
|
3192
3187
|
throw new Error(JSON.stringify(n));
|
|
3193
|
-
const i =
|
|
3194
|
-
...
|
|
3188
|
+
const i = qe({
|
|
3189
|
+
...r,
|
|
3195
3190
|
primary: !1
|
|
3196
3191
|
});
|
|
3197
|
-
return await
|
|
3192
|
+
return await s.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 r = await s.customDomainAdapter.get(
|
|
3206
3200
|
e,
|
|
3207
3201
|
t
|
|
3208
3202
|
);
|
|
3209
|
-
if (!
|
|
3210
|
-
throw new
|
|
3211
|
-
const n = await
|
|
3203
|
+
if (!r)
|
|
3204
|
+
throw new te(404);
|
|
3205
|
+
const n = await se(s).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(), { result: a, errors: i, success: o } = Ue.parse(n);
|
|
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 (s.enterprise && a.custom_metadata?.tenant_id !== e)
|
|
3211
|
+
throw new te(404);
|
|
3212
|
+
return qe({ ...r, ...a });
|
|
3219
3213
|
},
|
|
3220
|
-
getByDomain: async (e) =>
|
|
3214
|
+
getByDomain: async (e) => s.customDomainAdapter.getByDomain(e),
|
|
3221
3215
|
list: async (e) => {
|
|
3222
|
-
const t = await
|
|
3216
|
+
const t = await s.customDomainAdapter.list(e), r = await se(s).get("/custom_hostnames").json(), { result: n, errors: a, success: i } = $s.parse(r);
|
|
3223
3217
|
if (!i)
|
|
3224
|
-
throw new
|
|
3218
|
+
throw new te(503, {
|
|
3225
3219
|
message: JSON.stringify(a)
|
|
3226
3220
|
});
|
|
3227
3221
|
return n.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) => !(s.enterprise && o.custom_metadata?.tenant_id !== e)
|
|
3234
3225
|
).map(
|
|
3235
|
-
(o) =>
|
|
3226
|
+
(o) => qe({
|
|
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 (s.enterprise) {
|
|
3234
|
+
const { result: n, success: a } = Ue.parse(
|
|
3235
|
+
await se(s).get(`/custom_hostnames/${encodeURIComponent(t)}`).json()
|
|
3246
3236
|
);
|
|
3247
|
-
if (!
|
|
3248
|
-
throw new
|
|
3237
|
+
if (!a || n.custom_metadata?.tenant_id !== e)
|
|
3238
|
+
throw new te(404);
|
|
3249
3239
|
}
|
|
3250
|
-
const
|
|
3251
|
-
return
|
|
3240
|
+
const r = await se(s).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();
|
|
3241
|
+
return r.ok && await s.customDomainAdapter.remove(e, t), r.ok;
|
|
3252
3242
|
},
|
|
3253
|
-
update: async (e, t,
|
|
3254
|
-
const n = await
|
|
3255
|
-
|
|
3243
|
+
update: async (e, t, r) => {
|
|
3244
|
+
const n = await se(s).patch(
|
|
3245
|
+
r,
|
|
3256
3246
|
`/custom_hostnames/${encodeURIComponent(t)}`
|
|
3257
3247
|
).res();
|
|
3258
3248
|
if (!n.ok)
|
|
3259
|
-
throw new
|
|
3249
|
+
throw new te(503, {
|
|
3260
3250
|
message: await n.text()
|
|
3261
3251
|
});
|
|
3262
|
-
return
|
|
3252
|
+
return s.customDomainAdapter.update(
|
|
3263
3253
|
e,
|
|
3264
3254
|
t,
|
|
3265
|
-
|
|
3255
|
+
r
|
|
3266
3256
|
);
|
|
3267
3257
|
}
|
|
3268
3258
|
};
|
|
3269
3259
|
}
|
|
3270
|
-
class
|
|
3260
|
+
class Ms {
|
|
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,7 +3279,7 @@ class $r {
|
|
|
3289
3279
|
}
|
|
3290
3280
|
async get(e) {
|
|
3291
3281
|
try {
|
|
3292
|
-
const t = await this.getCache(),
|
|
3282
|
+
const t = await this.getCache(), r = this.createRequest(e), n = await t.match(r);
|
|
3293
3283
|
if (!n)
|
|
3294
3284
|
return null;
|
|
3295
3285
|
const a = await n.json();
|
|
@@ -3298,9 +3288,9 @@ class $r {
|
|
|
3298
3288
|
return console.error(`CloudflareCache: get error for key ${e}:`, t), null;
|
|
3299
3289
|
}
|
|
3300
3290
|
}
|
|
3301
|
-
async set(e, t,
|
|
3291
|
+
async set(e, t, r) {
|
|
3302
3292
|
try {
|
|
3303
|
-
const n = await this.getCache(), a =
|
|
3293
|
+
const n = await this.getCache(), a = r ?? 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()
|
|
@@ -3318,8 +3308,8 @@ class $r {
|
|
|
3318
3308
|
}
|
|
3319
3309
|
async delete(e) {
|
|
3320
3310
|
try {
|
|
3321
|
-
const t = await this.getCache(),
|
|
3322
|
-
return await t.delete(
|
|
3311
|
+
const t = await this.getCache(), r = this.createRequest(e);
|
|
3312
|
+
return await t.delete(r);
|
|
3323
3313
|
} catch (t) {
|
|
3324
3314
|
return console.error(`CloudflareCache: delete error for key ${e}:`, t), !1;
|
|
3325
3315
|
}
|
|
@@ -3330,30 +3320,273 @@ class $r {
|
|
|
3330
3320
|
);
|
|
3331
3321
|
}
|
|
3332
3322
|
}
|
|
3333
|
-
function
|
|
3323
|
+
function Ds(s = {}) {
|
|
3334
3324
|
const e = {
|
|
3335
3325
|
defaultTtlSeconds: 300,
|
|
3336
3326
|
// 5 minutes default
|
|
3337
3327
|
keyPrefix: "authhero",
|
|
3338
3328
|
// default prefix
|
|
3339
|
-
...
|
|
3329
|
+
...s
|
|
3340
3330
|
// user config overrides defaults
|
|
3341
3331
|
};
|
|
3342
|
-
return new
|
|
3332
|
+
return new Ms(e);
|
|
3333
|
+
}
|
|
3334
|
+
const Ls = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3335
|
+
let Vs = (s = 21) => {
|
|
3336
|
+
let e = "", t = crypto.getRandomValues(new Uint8Array(s |= 0));
|
|
3337
|
+
for (; s--; )
|
|
3338
|
+
e += Ls[t[s] & 63];
|
|
3339
|
+
return e;
|
|
3340
|
+
};
|
|
3341
|
+
async function He(s, e) {
|
|
3342
|
+
const t = s.timeout || 3e4, r = new AbortController(), n = setTimeout(() => r.abort(), t);
|
|
3343
|
+
try {
|
|
3344
|
+
const a = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${s.accountId}/r2-sql/query/${s.warehouseName}`, i = await fetch(a, {
|
|
3345
|
+
method: "POST",
|
|
3346
|
+
headers: {
|
|
3347
|
+
"Content-Type": "application/json",
|
|
3348
|
+
Authorization: `Bearer ${s.authToken}`
|
|
3349
|
+
},
|
|
3350
|
+
// Request body should be shaped as { "query": "..." }
|
|
3351
|
+
body: JSON.stringify({
|
|
3352
|
+
query: e
|
|
3353
|
+
}),
|
|
3354
|
+
signal: r.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(n);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
function Ie(s) {
|
|
3369
|
+
return `'${s.replace(/'/g, "''")}'`;
|
|
3343
3370
|
}
|
|
3344
|
-
function
|
|
3371
|
+
function B(s) {
|
|
3372
|
+
return `"${s.replace(/"/g, '""')}"`;
|
|
3373
|
+
}
|
|
3374
|
+
function ut(s) {
|
|
3375
|
+
const e = (t) => {
|
|
3376
|
+
if (!t)
|
|
3377
|
+
return "";
|
|
3378
|
+
try {
|
|
3379
|
+
return JSON.parse(t);
|
|
3380
|
+
} catch {
|
|
3381
|
+
return t;
|
|
3382
|
+
}
|
|
3383
|
+
};
|
|
3345
3384
|
return {
|
|
3346
|
-
|
|
3385
|
+
type: s.type,
|
|
3386
|
+
date: s.date,
|
|
3387
|
+
description: s.description,
|
|
3388
|
+
ip: s.ip,
|
|
3389
|
+
user_agent: s.user_agent,
|
|
3390
|
+
details: e(s.details),
|
|
3391
|
+
isMobile: !!s.isMobile,
|
|
3392
|
+
user_id: s.user_id,
|
|
3393
|
+
user_name: s.user_name,
|
|
3394
|
+
connection: s.connection,
|
|
3395
|
+
connection_id: s.connection_id,
|
|
3396
|
+
client_id: s.client_id,
|
|
3397
|
+
client_name: s.client_name,
|
|
3398
|
+
audience: s.audience,
|
|
3399
|
+
scope: s.scope ? s.scope.split(",") : void 0,
|
|
3400
|
+
strategy: s.strategy,
|
|
3401
|
+
strategy_type: s.strategy_type,
|
|
3402
|
+
hostname: s.hostname,
|
|
3403
|
+
auth0_client: e(s.auth0_client),
|
|
3404
|
+
log_id: s.id
|
|
3405
|
+
};
|
|
3406
|
+
}
|
|
3407
|
+
function zs(s) {
|
|
3408
|
+
return async (e, t) => {
|
|
3409
|
+
if (console.log("createLog called with config:", s), s.baseAdapter) {
|
|
3410
|
+
const a = await s.baseAdapter.create(e, t);
|
|
3411
|
+
return (s.pipelineEndpoint || s.pipelineBinding) && tt(s, e, a).catch((i) => {
|
|
3412
|
+
console.error("Failed to send log to Pipeline:", i);
|
|
3413
|
+
}), a;
|
|
3414
|
+
}
|
|
3415
|
+
const r = t.log_id || Vs(), n = {
|
|
3416
|
+
...t,
|
|
3417
|
+
log_id: r
|
|
3418
|
+
};
|
|
3419
|
+
return await tt(s, e, n), console.log("Log sent to Pipeline with ID:", r), n;
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
async function tt(s, e, t) {
|
|
3423
|
+
const r = (c) => c ? JSON.stringify(c) : void 0, n = {
|
|
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: r(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?.join(","),
|
|
3441
|
+
strategy: t.strategy,
|
|
3442
|
+
strategy_type: t.strategy_type,
|
|
3443
|
+
hostname: t.hostname,
|
|
3444
|
+
auth0_client: r(t.auth0_client),
|
|
3445
|
+
log_id: t.log_id
|
|
3446
|
+
}, a = s.timeout || 3e4, i = new AbortController(), o = setTimeout(() => i.abort(), a);
|
|
3447
|
+
try {
|
|
3448
|
+
let c;
|
|
3449
|
+
if (s.pipelineBinding)
|
|
3450
|
+
c = await s.pipelineBinding.fetch("https://pipeline", {
|
|
3451
|
+
method: "POST",
|
|
3452
|
+
headers: {
|
|
3453
|
+
"Content-Type": "application/json"
|
|
3454
|
+
},
|
|
3455
|
+
body: JSON.stringify([n]),
|
|
3456
|
+
// Pipelines accept array of records
|
|
3457
|
+
signal: i.signal
|
|
3458
|
+
});
|
|
3459
|
+
else if (s.pipelineEndpoint)
|
|
3460
|
+
c = await fetch(s.pipelineEndpoint, {
|
|
3461
|
+
method: "POST",
|
|
3462
|
+
headers: {
|
|
3463
|
+
"Content-Type": "application/json"
|
|
3464
|
+
},
|
|
3465
|
+
body: JSON.stringify([n]),
|
|
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 Bs(s) {
|
|
3482
|
+
return async (e, t) => {
|
|
3483
|
+
if (s.baseAdapter)
|
|
3484
|
+
return s.baseAdapter.get(e, t);
|
|
3485
|
+
const r = s.namespace || "default", n = s.tableName || "logs", a = `
|
|
3486
|
+
SELECT * FROM ${B(r)}.${B(n)}
|
|
3487
|
+
WHERE tenant_id = ${Ie(e)}
|
|
3488
|
+
AND id = ${Ie(t)}
|
|
3489
|
+
LIMIT 1
|
|
3490
|
+
`, i = await He(s, a);
|
|
3491
|
+
if (i.length === 0)
|
|
3492
|
+
return null;
|
|
3493
|
+
const o = i[0];
|
|
3494
|
+
return o ? ut(o) : null;
|
|
3495
|
+
};
|
|
3496
|
+
}
|
|
3497
|
+
function Us(s) {
|
|
3498
|
+
const e = {};
|
|
3499
|
+
return (s.match(/(\w+):(\S+)/g) || []).forEach((r) => {
|
|
3500
|
+
const [n, a] = r.split(":");
|
|
3501
|
+
n && a && (e[n] = a);
|
|
3502
|
+
}), e;
|
|
3503
|
+
}
|
|
3504
|
+
function qs(s) {
|
|
3505
|
+
const e = [];
|
|
3506
|
+
for (const [t, r] of Object.entries(s)) {
|
|
3507
|
+
const n = t.replace(/[^a-zA-Z0-9_]/g, "");
|
|
3508
|
+
n && r && e.push(
|
|
3509
|
+
`${B(n)} = ${Ie(r)}`
|
|
3510
|
+
);
|
|
3511
|
+
}
|
|
3512
|
+
return e;
|
|
3513
|
+
}
|
|
3514
|
+
function Fs(s) {
|
|
3515
|
+
return async (e, t = {}) => {
|
|
3516
|
+
if (s.baseAdapter)
|
|
3517
|
+
return s.baseAdapter.list(e, t);
|
|
3518
|
+
const { page: r = 0, per_page: n = 50, include_totals: a = !1, sort: i, q: o } = t, c = s.namespace || "default", u = s.tableName || "logs", p = [
|
|
3519
|
+
`tenant_id = ${Ie(e)}`
|
|
3520
|
+
];
|
|
3521
|
+
if (o) {
|
|
3522
|
+
const H = Us(o);
|
|
3523
|
+
p.push(...qs(H));
|
|
3524
|
+
}
|
|
3525
|
+
const b = p.join(" AND ");
|
|
3526
|
+
let C = "ORDER BY date DESC";
|
|
3527
|
+
if (i && i.sort_by) {
|
|
3528
|
+
const H = i.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), ue = i.sort_order === "asc" ? "ASC" : "DESC";
|
|
3529
|
+
C = `ORDER BY ${B(H)} ${ue}`;
|
|
3530
|
+
}
|
|
3531
|
+
const w = r * n, Z = `LIMIT ${n} OFFSET ${w}`, de = `
|
|
3532
|
+
SELECT * FROM ${B(c)}.${B(u)}
|
|
3533
|
+
WHERE ${b}
|
|
3534
|
+
${C}
|
|
3535
|
+
${Z}
|
|
3536
|
+
`, J = (await He(s, de)).map(ut);
|
|
3537
|
+
if (!a)
|
|
3538
|
+
return {
|
|
3539
|
+
logs: J,
|
|
3540
|
+
start: 0,
|
|
3541
|
+
limit: 0,
|
|
3542
|
+
length: 0
|
|
3543
|
+
};
|
|
3544
|
+
const D = `
|
|
3545
|
+
SELECT COUNT(*) as count FROM ${B(c)}.${B(u)}
|
|
3546
|
+
WHERE ${b}
|
|
3547
|
+
`, Q = (await He(s, D))[0]?.count || 0;
|
|
3548
|
+
return {
|
|
3549
|
+
logs: J,
|
|
3550
|
+
start: w,
|
|
3551
|
+
limit: n,
|
|
3552
|
+
length: Number(Q)
|
|
3553
|
+
};
|
|
3554
|
+
};
|
|
3555
|
+
}
|
|
3556
|
+
function Ws(s) {
|
|
3557
|
+
const e = !!s.baseAdapter, t = !!s.pipelineEndpoint, r = !!s.pipelineBinding;
|
|
3558
|
+
if (!e && !t && !r)
|
|
3559
|
+
throw new Error(
|
|
3560
|
+
'R2 SQL logs adapter requires one of: "baseAdapter", "pipelineEndpoint", or "pipelineBinding"'
|
|
3561
|
+
);
|
|
3562
|
+
if (!e) {
|
|
3563
|
+
if (!s.authToken)
|
|
3564
|
+
throw new Error('R2 SQL logs adapter requires "authToken" configuration');
|
|
3565
|
+
if (!s.warehouseName)
|
|
3566
|
+
throw new Error(
|
|
3567
|
+
'R2 SQL logs adapter requires "warehouseName" configuration'
|
|
3568
|
+
);
|
|
3569
|
+
}
|
|
3570
|
+
return {
|
|
3571
|
+
create: zs(s),
|
|
3572
|
+
list: Fs(s),
|
|
3573
|
+
get: Bs(s)
|
|
3574
|
+
};
|
|
3575
|
+
}
|
|
3576
|
+
function Hs(s) {
|
|
3577
|
+
const e = {
|
|
3578
|
+
customDomains: Ps(s),
|
|
3347
3579
|
// Always create a cache adapter (let createCloudflareCache apply defaults)
|
|
3348
|
-
cache:
|
|
3349
|
-
...
|
|
3350
|
-
...
|
|
3351
|
-
defaultTtlSeconds:
|
|
3580
|
+
cache: Ds({
|
|
3581
|
+
...s.cacheName && { cacheName: s.cacheName },
|
|
3582
|
+
...s.defaultTtlSeconds !== void 0 && {
|
|
3583
|
+
defaultTtlSeconds: s.defaultTtlSeconds
|
|
3352
3584
|
},
|
|
3353
|
-
...
|
|
3585
|
+
...s.keyPrefix && { keyPrefix: s.keyPrefix }
|
|
3354
3586
|
})
|
|
3355
3587
|
};
|
|
3588
|
+
return s.r2SqlLogs && (e.logs = Ws(s.r2SqlLogs)), e;
|
|
3356
3589
|
}
|
|
3357
3590
|
export {
|
|
3358
|
-
|
|
3591
|
+
Hs as default
|
|
3359
3592
|
};
|