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