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