authhero 0.0.1 → 0.1.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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/authhero.js +1004 -822
- package/dist/bun.d.ts +8 -0
- package/dist/bun.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/routes/oauth2/index.d.ts +2 -0
- package/dist/routes/oauth2/index.d.ts.map +1 -0
- package/dist/routes/oauth2/well-known.d.ts +55 -0
- package/dist/routes/oauth2/well-known.d.ts.map +1 -0
- package/dist/types/Bindings.d.ts +1 -0
- package/dist/types/Bindings.d.ts.map +1 -1
- package/dist/types/JWKS.d.ts +131 -0
- package/dist/types/JWKS.d.ts.map +1 -0
- package/dist/types/Variables.d.ts +2 -0
- package/dist/types/Variables.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/bun.ts +16 -0
- package/src/index.ts +25 -4
- package/src/routes/oauth2/index.ts +1 -0
- package/src/routes/oauth2/well-known.ts +179 -0
- package/src/types/Bindings.ts +3 -0
- package/src/types/JWKS.ts +37 -0
- package/src/types/Variables.ts +1 -0
- package/src/types/index.ts +3 -0
package/dist/authhero.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var xr = Object.defineProperty;
|
|
2
|
+
var Lt = (r) => {
|
|
3
3
|
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var p = (r, e, t) =>
|
|
7
|
-
var
|
|
8
|
-
function
|
|
5
|
+
var kr = (r, e, t) => e in r ? xr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
6
|
+
var p = (r, e, t) => kr(r, typeof e != "symbol" ? e + "" : e, t), Vt = (r, e, t) => e.has(r) || Lt("Cannot " + t);
|
|
7
|
+
var f = (r, e, t) => (Vt(r, e, "read from private field"), t ? t.call(r) : e.get(r)), D = (r, e, t) => e.has(r) ? Lt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), j = (r, e, t, n) => (Vt(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
|
8
|
+
function Ae(r, e) {
|
|
9
9
|
var t = {};
|
|
10
10
|
for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
|
|
11
11
|
if (r != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -17,39 +17,39 @@ function x(r, e) {
|
|
|
17
17
|
var t;
|
|
18
18
|
return ((t = r == null ? void 0 : r._def) === null || t === void 0 ? void 0 : t.typeName) === e;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Or(r) {
|
|
21
21
|
return "_def" in r;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function Ie(r, e) {
|
|
24
24
|
const t = r.ZodType.prototype[e];
|
|
25
25
|
r.ZodType.prototype[e] = function(...n) {
|
|
26
26
|
const s = t.apply(this, n);
|
|
27
27
|
return s._def.openapi = this._def.openapi, s;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Tr(r) {
|
|
31
31
|
if (typeof r.ZodType.prototype.openapi < "u")
|
|
32
32
|
return;
|
|
33
33
|
r.ZodType.prototype.openapi = function(s, a) {
|
|
34
|
-
var i, o, c, u, d,
|
|
35
|
-
const
|
|
36
|
-
param: Object.assign(Object.assign({}, (
|
|
37
|
-
} : void 0),
|
|
34
|
+
var i, o, c, u, d, h;
|
|
35
|
+
const T = typeof s == "string" ? a : s, S = T ?? {}, { param: E } = S, b = Ae(S, ["param"]), A = Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i._internal), typeof s == "string" ? { refId: s } : void 0), M = Object.assign(Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o.metadata), b), !((u = (c = this._def.openapi) === null || c === void 0 ? void 0 : c.metadata) === null || u === void 0) && u.param || E ? {
|
|
36
|
+
param: Object.assign(Object.assign({}, (h = (d = this._def.openapi) === null || d === void 0 ? void 0 : d.metadata) === null || h === void 0 ? void 0 : h.param), E)
|
|
37
|
+
} : void 0), K = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys(A).length > 0 ? { _internal: A } : void 0), Object.keys(M).length > 0 ? { metadata: M } : void 0) }));
|
|
38
38
|
if (x(this, "ZodObject")) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
return
|
|
39
|
+
const U = this.extend;
|
|
40
|
+
K.extend = function(...ve) {
|
|
41
|
+
var se, z, Y, ye, le, Ot;
|
|
42
|
+
const Tt = U.apply(this, ve);
|
|
43
|
+
return Tt._def.openapi = {
|
|
44
44
|
_internal: {
|
|
45
|
-
extendedFrom: !((
|
|
45
|
+
extendedFrom: !((z = (se = this._def.openapi) === null || se === void 0 ? void 0 : se._internal) === null || z === void 0) && z.refId ? { refId: (ye = (Y = this._def.openapi) === null || Y === void 0 ? void 0 : Y._internal) === null || ye === void 0 ? void 0 : ye.refId, schema: this } : (le = this._def.openapi) === null || le === void 0 ? void 0 : le._internal.extendedFrom
|
|
46
46
|
},
|
|
47
|
-
metadata: (Ot =
|
|
48
|
-
},
|
|
47
|
+
metadata: (Ot = Tt._def.openapi) === null || Ot === void 0 ? void 0 : Ot.metadata
|
|
48
|
+
}, Tt;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
return
|
|
52
|
-
},
|
|
51
|
+
return K;
|
|
52
|
+
}, Ie(r, "optional"), Ie(r, "nullable"), Ie(r, "default"), Ie(r, "transform"), Ie(r, "refine");
|
|
53
53
|
const e = r.ZodObject.prototype.deepPartial;
|
|
54
54
|
r.ZodObject.prototype.deepPartial = function() {
|
|
55
55
|
const s = this._def.shape(), a = e.apply(this), i = a._def.shape();
|
|
@@ -69,7 +69,7 @@ function wr(r) {
|
|
|
69
69
|
return a._def.openapi = void 0, a;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function lt(r, e) {
|
|
73
73
|
if (r == null || e === null || e === void 0)
|
|
74
74
|
return r === e;
|
|
75
75
|
if (r === e || r.valueOf() === e.valueOf())
|
|
@@ -77,9 +77,9 @@ function dt(r, e) {
|
|
|
77
77
|
if (Array.isArray(r) && (!Array.isArray(e) || r.length !== e.length) || !(r instanceof Object) || !(e instanceof Object))
|
|
78
78
|
return !1;
|
|
79
79
|
const t = Object.keys(r);
|
|
80
|
-
return Object.keys(e).every((n) => t.indexOf(n) !== -1) && t.every((n) =>
|
|
80
|
+
return Object.keys(e).every((n) => t.indexOf(n) !== -1) && t.every((n) => lt(r[n], e[n]));
|
|
81
81
|
}
|
|
82
|
-
class
|
|
82
|
+
class jr {
|
|
83
83
|
constructor() {
|
|
84
84
|
this.buckets = /* @__PURE__ */ new Map();
|
|
85
85
|
}
|
|
@@ -89,11 +89,11 @@ class xr {
|
|
|
89
89
|
this.buckets.set(t, [e]);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
n.some((a) =>
|
|
92
|
+
n.some((a) => lt(a, e)) || n.push(e);
|
|
93
93
|
}
|
|
94
94
|
contains(e) {
|
|
95
95
|
const t = this.hashCodeOf(e), n = this.buckets.get(t);
|
|
96
|
-
return n ? n.some((s) =>
|
|
96
|
+
return n ? n.some((s) => lt(s, e)) : !1;
|
|
97
97
|
}
|
|
98
98
|
values() {
|
|
99
99
|
return [...this.buckets.values()].flat();
|
|
@@ -125,39 +125,39 @@ class xr {
|
|
|
125
125
|
return t;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function $e(r) {
|
|
129
129
|
return r == null;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function Le(r, e) {
|
|
132
132
|
const t = {};
|
|
133
133
|
return Object.entries(r).forEach(([n, s]) => {
|
|
134
134
|
t[n] = e(s);
|
|
135
135
|
}), t;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Rr(r, e) {
|
|
138
138
|
const t = {};
|
|
139
139
|
return Object.entries(r).forEach(([n, s]) => {
|
|
140
140
|
e.some((a) => a === n) || (t[n] = s);
|
|
141
141
|
}), t;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function ke(r, e) {
|
|
144
144
|
const t = {};
|
|
145
145
|
return Object.entries(r).forEach(([n, s]) => {
|
|
146
146
|
e(s, n) || (t[n] = s);
|
|
147
147
|
}), t;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
return r.filter((e) =>
|
|
149
|
+
function Ut(r) {
|
|
150
|
+
return r.filter((e) => !$e(e));
|
|
151
151
|
}
|
|
152
|
-
const
|
|
153
|
-
function
|
|
154
|
-
const e = new
|
|
152
|
+
const Ct = lt;
|
|
153
|
+
function Er(r) {
|
|
154
|
+
const e = new jr();
|
|
155
155
|
return r.forEach((t) => e.put(t)), [...e.values()];
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Xt(r) {
|
|
158
158
|
return typeof r == "string";
|
|
159
159
|
}
|
|
160
|
-
class
|
|
160
|
+
class Sr {
|
|
161
161
|
constructor(e) {
|
|
162
162
|
this.parents = e, this._definitions = [];
|
|
163
163
|
}
|
|
@@ -224,17 +224,17 @@ class Tr {
|
|
|
224
224
|
return t.openapi(e);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
class
|
|
227
|
+
class xt {
|
|
228
228
|
constructor(e) {
|
|
229
229
|
this.message = e;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
class
|
|
232
|
+
class Pe extends xt {
|
|
233
233
|
constructor(e, t) {
|
|
234
234
|
super(e), this.data = t;
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
class
|
|
237
|
+
class ht extends xt {
|
|
238
238
|
constructor(e) {
|
|
239
239
|
super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``), this.data = e;
|
|
240
240
|
}
|
|
@@ -243,15 +243,15 @@ function Ze(r, e) {
|
|
|
243
243
|
try {
|
|
244
244
|
return r();
|
|
245
245
|
} catch (t) {
|
|
246
|
-
throw t instanceof
|
|
246
|
+
throw t instanceof ht ? new ht(Object.assign(Object.assign({}, t.data), e)) : t;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
class
|
|
249
|
+
class Cr extends xt {
|
|
250
250
|
constructor(e) {
|
|
251
251
|
super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."), this.data = e;
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
class
|
|
254
|
+
class C {
|
|
255
255
|
static getMetadata(e) {
|
|
256
256
|
var t;
|
|
257
257
|
const n = this.unwrapChained(e), s = e._def.openapi ? e._def.openapi : n._def.openapi, a = (t = e.description) !== null && t !== void 0 ? t : n.description;
|
|
@@ -280,13 +280,13 @@ class I {
|
|
|
280
280
|
* metadata properties
|
|
281
281
|
*/
|
|
282
282
|
static buildSchemaMetadata(e) {
|
|
283
|
-
return
|
|
283
|
+
return ke(Rr(e, ["param"]), $e);
|
|
284
284
|
}
|
|
285
285
|
static buildParameterMetadata(e) {
|
|
286
|
-
return
|
|
286
|
+
return ke(e, $e);
|
|
287
287
|
}
|
|
288
288
|
static applySchemaMetadata(e, t) {
|
|
289
|
-
return
|
|
289
|
+
return ke(Object.assign(Object.assign({}, e), this.buildSchemaMetadata(t)), $e);
|
|
290
290
|
}
|
|
291
291
|
static getRefId(e) {
|
|
292
292
|
var t;
|
|
@@ -306,19 +306,19 @@ class I {
|
|
|
306
306
|
return x(e, "ZodEffects") ? this.isOptionalSchema(e._def.schema) : e.isOptional();
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
class
|
|
309
|
+
class Ir {
|
|
310
310
|
transform(e, t, n) {
|
|
311
311
|
var s, a;
|
|
312
312
|
const i = e._def.type;
|
|
313
313
|
return Object.assign(Object.assign({}, t("array")), { items: n(i), minItems: (s = e._def.minLength) === null || s === void 0 ? void 0 : s.value, maxItems: (a = e._def.maxLength) === null || a === void 0 ? void 0 : a.value });
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
class
|
|
316
|
+
class Pr {
|
|
317
317
|
transform(e) {
|
|
318
318
|
return Object.assign(Object.assign({}, e("string")), { pattern: "^d+$" });
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
class
|
|
321
|
+
class Zr {
|
|
322
322
|
transform(e, t, n, s, a) {
|
|
323
323
|
const i = [...e.options.values()], o = i.map(s);
|
|
324
324
|
return t ? {
|
|
@@ -329,15 +329,15 @@ class Ir {
|
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
331
|
mapDiscriminator(e, t, n) {
|
|
332
|
-
if (e.some((a) =>
|
|
332
|
+
if (e.some((a) => C.getRefId(a) === void 0))
|
|
333
333
|
return;
|
|
334
334
|
const s = {};
|
|
335
335
|
return e.forEach((a) => {
|
|
336
336
|
var i;
|
|
337
|
-
const o =
|
|
337
|
+
const o = C.getRefId(a), c = (i = a.shape) === null || i === void 0 ? void 0 : i[t];
|
|
338
338
|
if (x(c, "ZodEnum") || x(c, "ZodNativeEnum")) {
|
|
339
|
-
Object.values(c.enum).filter(
|
|
340
|
-
s[
|
|
339
|
+
Object.values(c.enum).filter(Xt).forEach((h) => {
|
|
340
|
+
s[h] = n(o);
|
|
341
341
|
});
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
@@ -351,12 +351,12 @@ class Ir {
|
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
class
|
|
354
|
+
class Ar {
|
|
355
355
|
transform(e, t) {
|
|
356
356
|
return Object.assign(Object.assign({}, t("string")), { enum: e._def.values });
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
class
|
|
359
|
+
class Nr {
|
|
360
360
|
transform(e, t, n, s) {
|
|
361
361
|
const i = {
|
|
362
362
|
allOf: this.flattenIntersectionTypes(e).map(s)
|
|
@@ -372,41 +372,41 @@ class Cr {
|
|
|
372
372
|
return [...t, ...n];
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class Dr {
|
|
376
376
|
transform(e, t) {
|
|
377
377
|
return Object.assign(Object.assign({}, t(typeof e._def.value)), { enum: [e._def.value] });
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function Mr(r) {
|
|
381
381
|
const t = Object.keys(r).filter((a) => typeof r[r[a]] != "number").map((a) => r[a]), n = t.filter((a) => typeof a == "number").length, s = n === 0 ? "string" : n === t.length ? "numeric" : "mixed";
|
|
382
382
|
return { values: t, type: s };
|
|
383
383
|
}
|
|
384
|
-
class
|
|
384
|
+
class $r {
|
|
385
385
|
transform(e, t) {
|
|
386
|
-
const { type: n, values: s } =
|
|
386
|
+
const { type: n, values: s } = Mr(e._def.values);
|
|
387
387
|
if (n === "mixed")
|
|
388
|
-
throw new
|
|
388
|
+
throw new xt("Enum has mixed string and number values, please specify the OpenAPI type manually");
|
|
389
389
|
return Object.assign(Object.assign({}, t(n === "numeric" ? "integer" : "string")), { enum: s });
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
class
|
|
392
|
+
class Lr {
|
|
393
393
|
transform(e, t, n) {
|
|
394
394
|
return Object.assign(Object.assign({}, t(e.isInt ? "integer" : "number")), n(e._def.checks));
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
class
|
|
397
|
+
class Vr {
|
|
398
398
|
transform(e, t, n, s) {
|
|
399
399
|
var a;
|
|
400
|
-
const i = (a =
|
|
400
|
+
const i = (a = C.getInternalMetadata(e)) === null || a === void 0 ? void 0 : a.extendedFrom, o = this.requiredKeysOf(e), c = Le(e._def.shape(), s);
|
|
401
401
|
if (!i)
|
|
402
402
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, n("object")), { properties: c, default: t }), o.length > 0 ? { required: o } : {}), this.generateAdditionalProperties(e, s));
|
|
403
403
|
const u = i.schema;
|
|
404
404
|
s(u);
|
|
405
|
-
const d = this.requiredKeysOf(u),
|
|
405
|
+
const d = this.requiredKeysOf(u), h = Le(u == null ? void 0 : u._def.shape(), s), T = Object.fromEntries(Object.entries(c).filter(([b, A]) => !Ct(h[b], A))), S = o.filter((b) => !d.includes(b)), E = Object.assign(Object.assign(Object.assign(Object.assign({}, n("object")), { default: t, properties: T }), S.length > 0 ? { required: S } : {}), this.generateAdditionalProperties(e, s));
|
|
406
406
|
return {
|
|
407
407
|
allOf: [
|
|
408
408
|
{ $ref: `#/components/schemas/${i.refId}` },
|
|
409
|
-
|
|
409
|
+
E
|
|
410
410
|
]
|
|
411
411
|
};
|
|
412
412
|
}
|
|
@@ -415,20 +415,20 @@ class Dr {
|
|
|
415
415
|
return x(s, "ZodNever") ? n === "strict" ? { additionalProperties: !1 } : {} : { additionalProperties: t(s) };
|
|
416
416
|
}
|
|
417
417
|
requiredKeysOf(e) {
|
|
418
|
-
return Object.entries(e._def.shape()).filter(([t, n]) => !
|
|
418
|
+
return Object.entries(e._def.shape()).filter(([t, n]) => !C.isOptionalSchema(n)).map(([t, n]) => t);
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
class
|
|
421
|
+
class Ur {
|
|
422
422
|
transform(e, t, n) {
|
|
423
423
|
const s = e._def.valueType, a = e._def.keyType, i = n(s);
|
|
424
424
|
if (x(a, "ZodEnum") || x(a, "ZodNativeEnum")) {
|
|
425
|
-
const c = Object.values(a.enum).filter(
|
|
425
|
+
const c = Object.values(a.enum).filter(Xt).reduce((u, d) => Object.assign(Object.assign({}, u), { [d]: i }), {});
|
|
426
426
|
return Object.assign(Object.assign({}, t("object")), { properties: c });
|
|
427
427
|
}
|
|
428
428
|
return Object.assign(Object.assign({}, t("object")), { additionalProperties: i });
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
class
|
|
431
|
+
class Hr {
|
|
432
432
|
transform(e, t) {
|
|
433
433
|
var n, s, a;
|
|
434
434
|
const i = this.getZodStringCheck(e, "regex"), o = (n = this.getZodStringCheck(e, "length")) === null || n === void 0 ? void 0 : n.value, c = Number.isFinite(e.minLength) && (s = e.minLength) !== null && s !== void 0 ? s : void 0, u = Number.isFinite(e.maxLength) && (a = e.maxLength) !== null && a !== void 0 ? a : void 0;
|
|
@@ -458,7 +458,7 @@ class $r {
|
|
|
458
458
|
return e._def.checks.find((n) => n.kind === t);
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
|
-
class
|
|
461
|
+
class qr {
|
|
462
462
|
constructor(e) {
|
|
463
463
|
this.versionSpecifics = e;
|
|
464
464
|
}
|
|
@@ -467,7 +467,7 @@ class Lr {
|
|
|
467
467
|
return Object.assign(Object.assign({}, t("array")), this.versionSpecifics.mapTupleItems(a));
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
class
|
|
470
|
+
class Wr {
|
|
471
471
|
transform(e, t, n) {
|
|
472
472
|
const a = this.flattenUnionTypes(e).map((i) => {
|
|
473
473
|
const o = this.unwrapNullable(i);
|
|
@@ -484,9 +484,9 @@ class Vr {
|
|
|
484
484
|
return x(e, "ZodNullable") ? this.unwrapNullable(e.unwrap()) : e;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class
|
|
487
|
+
class Br {
|
|
488
488
|
constructor(e) {
|
|
489
|
-
this.versionSpecifics = e, this.objectTransformer = new
|
|
489
|
+
this.versionSpecifics = e, this.objectTransformer = new Vr(), this.stringTransformer = new Hr(), this.numberTransformer = new Lr(), this.bigIntTransformer = new Pr(), this.literalTransformer = new Dr(), this.enumTransformer = new Ar(), this.nativeEnumTransformer = new $r(), this.arrayTransformer = new Ir(), this.unionTransformer = new Wr(), this.discriminatedUnionTransformer = new Zr(), this.intersectionTransformer = new Nr(), this.recordTransformer = new Ur(), this.tupleTransformer = new qr(e);
|
|
490
490
|
}
|
|
491
491
|
transform(e, t, n, s, a) {
|
|
492
492
|
if (x(e, "ZodNull"))
|
|
@@ -536,16 +536,16 @@ class Ur {
|
|
|
536
536
|
return this.recordTransformer.transform(e, (i) => this.versionSpecifics.mapNullableType(i, t), n);
|
|
537
537
|
if (x(e, "ZodDate"))
|
|
538
538
|
return this.versionSpecifics.mapNullableType("string", t);
|
|
539
|
-
const a =
|
|
540
|
-
throw new
|
|
539
|
+
const a = C.getRefId(e);
|
|
540
|
+
throw new Cr({
|
|
541
541
|
currentSchema: e._def,
|
|
542
542
|
schemaName: a
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
class
|
|
546
|
+
class zt {
|
|
547
547
|
constructor(e, t) {
|
|
548
|
-
this.definitions = e, this.versionSpecifics = t, this.schemaRefs = {}, this.paramRefs = {}, this.pathRefs = {}, this.rawComponents = [], this.openApiTransformer = new
|
|
548
|
+
this.definitions = e, this.versionSpecifics = t, this.schemaRefs = {}, this.paramRefs = {}, this.pathRefs = {}, this.rawComponents = [], this.openApiTransformer = new Br(t), this.sortDefinitions();
|
|
549
549
|
}
|
|
550
550
|
generateDocumentData() {
|
|
551
551
|
return this.definitions.forEach((e) => this.generateSingle(e)), {
|
|
@@ -603,7 +603,7 @@ class Jt {
|
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
generateParameterDefinition(e) {
|
|
606
|
-
const t =
|
|
606
|
+
const t = C.getRefId(e), n = this.generateParameter(e);
|
|
607
607
|
return t && (this.paramRefs[t] = n), n;
|
|
608
608
|
}
|
|
609
609
|
getParameterRef(e, t) {
|
|
@@ -611,18 +611,18 @@ class Jt {
|
|
|
611
611
|
const c = (n = e == null ? void 0 : e.metadata) === null || n === void 0 ? void 0 : n.param, u = !((s = e == null ? void 0 : e._internal) === null || s === void 0) && s.refId ? this.paramRefs[(a = e._internal) === null || a === void 0 ? void 0 : a.refId] : void 0;
|
|
612
612
|
if (!(!(!((i = e == null ? void 0 : e._internal) === null || i === void 0) && i.refId) || !u)) {
|
|
613
613
|
if (c && u.in !== c.in || t != null && t.in && u.in !== t.in)
|
|
614
|
-
throw new
|
|
614
|
+
throw new Pe(`Conflicting location for parameter ${u.name}`, {
|
|
615
615
|
key: "in",
|
|
616
|
-
values:
|
|
616
|
+
values: Ut([
|
|
617
617
|
u.in,
|
|
618
618
|
t == null ? void 0 : t.in,
|
|
619
619
|
c == null ? void 0 : c.in
|
|
620
620
|
])
|
|
621
621
|
});
|
|
622
622
|
if (c && u.name !== c.name || t != null && t.name && u.name !== (t == null ? void 0 : t.name))
|
|
623
|
-
throw new
|
|
623
|
+
throw new Pe("Conflicting names for parameter", {
|
|
624
624
|
key: "name",
|
|
625
|
-
values:
|
|
625
|
+
values: Ut([
|
|
626
626
|
u.name,
|
|
627
627
|
t == null ? void 0 : t.name,
|
|
628
628
|
c == null ? void 0 : c.name
|
|
@@ -635,27 +635,27 @@ class Jt {
|
|
|
635
635
|
}
|
|
636
636
|
generateInlineParameters(e, t) {
|
|
637
637
|
var n;
|
|
638
|
-
const s =
|
|
638
|
+
const s = C.getMetadata(e), a = (n = s == null ? void 0 : s.metadata) === null || n === void 0 ? void 0 : n.param, i = this.getParameterRef(s, { in: t });
|
|
639
639
|
if (i)
|
|
640
640
|
return [i];
|
|
641
641
|
if (x(e, "ZodObject")) {
|
|
642
642
|
const o = e._def.shape();
|
|
643
643
|
return Object.entries(o).map(([u, d]) => {
|
|
644
|
-
var
|
|
645
|
-
const
|
|
644
|
+
var h, T;
|
|
645
|
+
const S = C.getMetadata(d), E = this.getParameterRef(S, {
|
|
646
646
|
in: t,
|
|
647
647
|
name: u
|
|
648
648
|
});
|
|
649
|
-
if (
|
|
650
|
-
return
|
|
651
|
-
const b = (
|
|
649
|
+
if (E)
|
|
650
|
+
return E;
|
|
651
|
+
const b = (h = S == null ? void 0 : S.metadata) === null || h === void 0 ? void 0 : h.param;
|
|
652
652
|
if (b != null && b.name && b.name !== u)
|
|
653
|
-
throw new
|
|
653
|
+
throw new Pe("Conflicting names for parameter", {
|
|
654
654
|
key: "name",
|
|
655
655
|
values: [u, b.name]
|
|
656
656
|
});
|
|
657
657
|
if (b != null && b.in && b.in !== t)
|
|
658
|
-
throw new
|
|
658
|
+
throw new Pe(`Conflicting location for parameter ${(T = b.name) !== null && T !== void 0 ? T : u}`, {
|
|
659
659
|
key: "in",
|
|
660
660
|
values: [t, b.in]
|
|
661
661
|
});
|
|
@@ -663,7 +663,7 @@ class Jt {
|
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
665
|
if (a != null && a.in && a.in !== t)
|
|
666
|
-
throw new
|
|
666
|
+
throw new Pe(`Conflicting location for parameter ${a.name}`, {
|
|
667
667
|
key: "in",
|
|
668
668
|
values: [t, a.in]
|
|
669
669
|
});
|
|
@@ -673,19 +673,19 @@ class Jt {
|
|
|
673
673
|
}
|
|
674
674
|
generateSimpleParameter(e) {
|
|
675
675
|
var t;
|
|
676
|
-
const n =
|
|
676
|
+
const n = C.getParamMetadata(e), s = (t = n == null ? void 0 : n.metadata) === null || t === void 0 ? void 0 : t.param, a = !C.isOptionalSchema(e) && !e.isNullable(), i = this.generateSchemaWithRef(e);
|
|
677
677
|
return Object.assign({
|
|
678
678
|
schema: i,
|
|
679
679
|
required: a
|
|
680
|
-
}, s ?
|
|
680
|
+
}, s ? C.buildParameterMetadata(s) : {});
|
|
681
681
|
}
|
|
682
682
|
generateParameter(e) {
|
|
683
683
|
var t;
|
|
684
|
-
const n =
|
|
684
|
+
const n = C.getMetadata(e), s = (t = n == null ? void 0 : n.metadata) === null || t === void 0 ? void 0 : t.param, a = s == null ? void 0 : s.name, i = s == null ? void 0 : s.in;
|
|
685
685
|
if (!a)
|
|
686
|
-
throw new
|
|
686
|
+
throw new ht({ missingField: "name" });
|
|
687
687
|
if (!i)
|
|
688
|
-
throw new
|
|
688
|
+
throw new ht({
|
|
689
689
|
missingField: "in",
|
|
690
690
|
paramName: a
|
|
691
691
|
});
|
|
@@ -694,15 +694,15 @@ class Jt {
|
|
|
694
694
|
}
|
|
695
695
|
generateSchemaWithMetadata(e) {
|
|
696
696
|
var t;
|
|
697
|
-
const n =
|
|
698
|
-
return s != null && s.metadata ?
|
|
697
|
+
const n = C.unwrapChained(e), s = C.getMetadata(e), a = C.getDefaultValue(e), i = !((t = s == null ? void 0 : s.metadata) === null || t === void 0) && t.type ? { type: s == null ? void 0 : s.metadata.type } : this.toOpenAPISchema(n, e.isNullable(), a);
|
|
698
|
+
return s != null && s.metadata ? C.applySchemaMetadata(i, s.metadata) : ke(i, $e);
|
|
699
699
|
}
|
|
700
700
|
/**
|
|
701
701
|
* Same as above but applies nullable
|
|
702
702
|
*/
|
|
703
703
|
constructReferencedOpenAPISchema(e) {
|
|
704
704
|
var t;
|
|
705
|
-
const n =
|
|
705
|
+
const n = C.getMetadata(e), s = C.unwrapChained(e), a = C.getDefaultValue(e), i = e.isNullable();
|
|
706
706
|
return !((t = n == null ? void 0 : n.metadata) === null || t === void 0) && t.type ? this.versionSpecifics.mapNullableType(n.metadata.type, i) : this.toOpenAPISchema(s, i, a);
|
|
707
707
|
}
|
|
708
708
|
/**
|
|
@@ -710,17 +710,17 @@ class Jt {
|
|
|
710
710
|
*/
|
|
711
711
|
generateSimpleSchema(e) {
|
|
712
712
|
var t;
|
|
713
|
-
const n =
|
|
713
|
+
const n = C.getMetadata(e), s = C.getRefId(e);
|
|
714
714
|
if (!s || !this.schemaRefs[s])
|
|
715
715
|
return this.generateSchemaWithMetadata(e);
|
|
716
716
|
const a = this.schemaRefs[s], i = {
|
|
717
717
|
$ref: this.generateSchemaRef(s)
|
|
718
|
-
}, o =
|
|
718
|
+
}, o = ke(C.buildSchemaMetadata((t = n == null ? void 0 : n.metadata) !== null && t !== void 0 ? t : {}), (d, h) => d === void 0 || Ct(d, a[h]));
|
|
719
719
|
if (o.type)
|
|
720
720
|
return {
|
|
721
721
|
allOf: [i, o]
|
|
722
722
|
};
|
|
723
|
-
const c =
|
|
723
|
+
const c = ke(this.constructReferencedOpenAPISchema(e), (d, h) => d === void 0 || Ct(d, a[h])), u = C.applySchemaMetadata(c, o);
|
|
724
724
|
return Object.keys(u).length > 0 ? {
|
|
725
725
|
allOf: [i, u]
|
|
726
726
|
} : i;
|
|
@@ -733,7 +733,7 @@ class Jt {
|
|
|
733
733
|
* Should be used for nested objects, arrays, etc.
|
|
734
734
|
*/
|
|
735
735
|
generateSchemaWithRef(e) {
|
|
736
|
-
const t =
|
|
736
|
+
const t = C.getRefId(e), n = this.generateSimpleSchema(e);
|
|
737
737
|
return t && this.schemaRefs[t] === void 0 ? (this.schemaRefs[t] = n, { $ref: this.generateSchemaRef(t) }) : n;
|
|
738
738
|
}
|
|
739
739
|
generateSchemaRef(e) {
|
|
@@ -742,7 +742,7 @@ class Jt {
|
|
|
742
742
|
getRequestBody(e) {
|
|
743
743
|
if (!e)
|
|
744
744
|
return;
|
|
745
|
-
const { content: t } = e, n =
|
|
745
|
+
const { content: t } = e, n = Ae(e, ["content"]), s = this.getBodyContent(t);
|
|
746
746
|
return Object.assign(Object.assign({}, n), { content: s });
|
|
747
747
|
}
|
|
748
748
|
getParameters(e) {
|
|
@@ -750,7 +750,7 @@ class Jt {
|
|
|
750
750
|
return [];
|
|
751
751
|
const { headers: t } = e, n = this.cleanParameter(e.query), s = this.cleanParameter(e.params), a = this.cleanParameter(e.cookies), i = Ze(() => n ? this.generateInlineParameters(n, "query") : [], { location: "query" }), o = Ze(() => s ? this.generateInlineParameters(s, "path") : [], { location: "path" }), c = Ze(() => a ? this.generateInlineParameters(a, "cookie") : [], { location: "cookie" }), u = Ze(() => {
|
|
752
752
|
if (Array.isArray(t))
|
|
753
|
-
return t.flatMap((
|
|
753
|
+
return t.flatMap((h) => this.generateInlineParameters(h, "header"));
|
|
754
754
|
const d = this.cleanParameter(t);
|
|
755
755
|
return d ? this.generateInlineParameters(d, "header") : [];
|
|
756
756
|
}, { location: "header" });
|
|
@@ -766,7 +766,7 @@ class Jt {
|
|
|
766
766
|
return x(e, "ZodEffects") ? this.cleanParameter(e._def.schema) : e;
|
|
767
767
|
}
|
|
768
768
|
generatePath(e) {
|
|
769
|
-
const { method: t, path: n, request: s, responses: a } = e, i =
|
|
769
|
+
const { method: t, path: n, request: s, responses: a } = e, i = Ae(e, ["method", "path", "request", "responses"]), o = Le(a, (h) => this.getResponse(h)), c = Ze(() => this.getParameters(s), { route: `${t} ${n}` }), u = this.getRequestBody(s == null ? void 0 : s.body);
|
|
770
770
|
return {
|
|
771
771
|
[t]: Object.assign(Object.assign(Object.assign(Object.assign({}, i), c.length > 0 ? {
|
|
772
772
|
parameters: [...i.parameters || [], ...c]
|
|
@@ -778,7 +778,7 @@ class Jt {
|
|
|
778
778
|
return this.pathRefs[e.path] = Object.assign(Object.assign({}, this.pathRefs[e.path]), t), t;
|
|
779
779
|
}
|
|
780
780
|
getResponse(e) {
|
|
781
|
-
var { content: t, headers: n } = e, s =
|
|
781
|
+
var { content: t, headers: n } = e, s = Ae(e, ["content", "headers"]);
|
|
782
782
|
const a = t ? { content: this.getBodyContent(t) } : {};
|
|
783
783
|
if (!n)
|
|
784
784
|
return Object.assign(Object.assign({}, s), a);
|
|
@@ -791,13 +791,13 @@ class Jt {
|
|
|
791
791
|
}
|
|
792
792
|
getResponseHeaders(e) {
|
|
793
793
|
const t = e._def.shape();
|
|
794
|
-
return
|
|
794
|
+
return Le(t, (s) => this.generateSimpleParameter(s));
|
|
795
795
|
}
|
|
796
796
|
getBodyContent(e) {
|
|
797
|
-
return
|
|
798
|
-
if (!t || !
|
|
797
|
+
return Le(e, (t) => {
|
|
798
|
+
if (!t || !Or(t.schema))
|
|
799
799
|
return t;
|
|
800
|
-
const { schema: n } = t, s =
|
|
800
|
+
const { schema: n } = t, s = Ae(t, ["schema"]), a = this.generateSchemaWithRef(n);
|
|
801
801
|
return Object.assign({ schema: a }, s);
|
|
802
802
|
});
|
|
803
803
|
}
|
|
@@ -805,7 +805,7 @@ class Jt {
|
|
|
805
805
|
return this.openApiTransformer.transform(e, t, (s) => this.generateSchemaWithRef(s), (s) => this.generateSchemaRef(s), n);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
class
|
|
808
|
+
class Fr {
|
|
809
809
|
get nullType() {
|
|
810
810
|
return { nullable: !0 };
|
|
811
811
|
}
|
|
@@ -816,7 +816,7 @@ class Hr {
|
|
|
816
816
|
return Object.assign(Object.assign({}, e ? { type: e } : void 0), t ? this.nullType : void 0);
|
|
817
817
|
}
|
|
818
818
|
mapTupleItems(e) {
|
|
819
|
-
const t =
|
|
819
|
+
const t = Er(e);
|
|
820
820
|
return {
|
|
821
821
|
items: t.length === 1 ? t[0] : { anyOf: t },
|
|
822
822
|
minItems: e.length,
|
|
@@ -836,10 +836,10 @@ class Hr {
|
|
|
836
836
|
}));
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
class
|
|
839
|
+
class Gr {
|
|
840
840
|
constructor(e) {
|
|
841
|
-
const t = new
|
|
842
|
-
this.generator = new
|
|
841
|
+
const t = new Fr();
|
|
842
|
+
this.generator = new zt(e, t);
|
|
843
843
|
}
|
|
844
844
|
generateDocument(e) {
|
|
845
845
|
const t = this.generator.generateDocumentData();
|
|
@@ -849,7 +849,7 @@ class qr {
|
|
|
849
849
|
return this.generator.generateComponents();
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
class
|
|
852
|
+
class Kr {
|
|
853
853
|
get nullType() {
|
|
854
854
|
return { type: "null" };
|
|
855
855
|
}
|
|
@@ -881,18 +881,18 @@ class Br {
|
|
|
881
881
|
}));
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
|
-
function
|
|
884
|
+
function Yr(r) {
|
|
885
885
|
return "type" in r && r.type === "webhook";
|
|
886
886
|
}
|
|
887
|
-
class
|
|
887
|
+
class Qr {
|
|
888
888
|
constructor(e) {
|
|
889
889
|
this.definitions = e, this.webhookRefs = {};
|
|
890
|
-
const t = new
|
|
891
|
-
this.generator = new
|
|
890
|
+
const t = new Kr();
|
|
891
|
+
this.generator = new zt(this.definitions, t);
|
|
892
892
|
}
|
|
893
893
|
generateDocument(e) {
|
|
894
894
|
const t = this.generator.generateDocumentData();
|
|
895
|
-
return this.definitions.filter(
|
|
895
|
+
return this.definitions.filter(Yr).forEach((n) => this.generateSingleWebhook(n.webhook)), Object.assign(Object.assign(Object.assign({}, e), t), { webhooks: this.webhookRefs });
|
|
896
896
|
}
|
|
897
897
|
generateComponents() {
|
|
898
898
|
return this.generator.generateComponents();
|
|
@@ -902,19 +902,19 @@ class Fr {
|
|
|
902
902
|
return this.webhookRefs[e.path] = Object.assign(Object.assign({}, this.webhookRefs[e.path]), t), t;
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
|
-
var
|
|
905
|
+
var er = (r) => {
|
|
906
906
|
const e = r.split("/");
|
|
907
907
|
return e[0] === "" && e.shift(), e;
|
|
908
|
-
},
|
|
909
|
-
const { groups: e, path: t } =
|
|
910
|
-
return
|
|
911
|
-
},
|
|
908
|
+
}, Jr = (r) => {
|
|
909
|
+
const { groups: e, path: t } = Xr(r), n = er(t);
|
|
910
|
+
return zr(n, e);
|
|
911
|
+
}, Xr = (r) => {
|
|
912
912
|
const e = [];
|
|
913
913
|
return r = r.replace(/\{[^}]+\}/g, (t, n) => {
|
|
914
914
|
const s = `@${n}`;
|
|
915
915
|
return e.push([s, t]), s;
|
|
916
916
|
}), { groups: e, path: r };
|
|
917
|
-
},
|
|
917
|
+
}, zr = (r, e) => {
|
|
918
918
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
919
919
|
const [n] = e[t];
|
|
920
920
|
for (let s = r.length - 1; s >= 0; s--)
|
|
@@ -924,12 +924,12 @@ var Yt = (r) => {
|
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
return r;
|
|
927
|
-
},
|
|
927
|
+
}, ct = {}, Ht = (r) => {
|
|
928
928
|
if (r === "*")
|
|
929
929
|
return "*";
|
|
930
930
|
const e = r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
931
|
-
return e ? (
|
|
932
|
-
},
|
|
931
|
+
return e ? (ct[r] || (e[2] ? ct[r] = [r, e[1], new RegExp("^" + e[2] + "$")] : ct[r] = [r, e[1], !0]), ct[r]) : null;
|
|
932
|
+
}, en = (r) => {
|
|
933
933
|
try {
|
|
934
934
|
return decodeURI(r);
|
|
935
935
|
} catch {
|
|
@@ -941,27 +941,27 @@ var Yt = (r) => {
|
|
|
941
941
|
}
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, tr = (r) => {
|
|
945
945
|
const e = r.url, t = e.indexOf("/", 8);
|
|
946
946
|
let n = t;
|
|
947
947
|
for (; n < e.length; n++) {
|
|
948
948
|
const s = e.charCodeAt(n);
|
|
949
949
|
if (s === 37) {
|
|
950
950
|
const a = e.indexOf("?", n), i = e.slice(t, a === -1 ? void 0 : a);
|
|
951
|
-
return
|
|
951
|
+
return en(i.includes("%25") ? i.replace(/%25/g, "%2525") : i);
|
|
952
952
|
} else if (s === 63)
|
|
953
953
|
break;
|
|
954
954
|
}
|
|
955
955
|
return e.slice(t, n);
|
|
956
|
-
},
|
|
957
|
-
const e =
|
|
956
|
+
}, tn = (r) => {
|
|
957
|
+
const e = tr(r);
|
|
958
958
|
return e.length > 1 && e[e.length - 1] === "/" ? e.slice(0, -1) : e;
|
|
959
|
-
},
|
|
959
|
+
}, he = (...r) => {
|
|
960
960
|
let e = "", t = !1;
|
|
961
961
|
for (let n of r)
|
|
962
962
|
e[e.length - 1] === "/" && (e = e.slice(0, -1), t = !0), n[0] !== "/" && (n = `/${n}`), n === "/" && t ? e = `${e}/` : n !== "/" && (e = `${e}${n}`), n === "/" && e === "" && (e = "/");
|
|
963
963
|
return e;
|
|
964
|
-
},
|
|
964
|
+
}, rr = (r) => {
|
|
965
965
|
if (!r.match(/\:.+\?$/))
|
|
966
966
|
return null;
|
|
967
967
|
const e = r.split("/"), t = [];
|
|
@@ -977,7 +977,7 @@ var Yt = (r) => {
|
|
|
977
977
|
} else
|
|
978
978
|
n += "/" + s;
|
|
979
979
|
}), t.filter((s, a, i) => i.indexOf(s) === a);
|
|
980
|
-
},
|
|
980
|
+
}, jt = (r) => /[%+]/.test(r) ? (r.indexOf("+") !== -1 && (r = r.replace(/\+/g, " ")), /%/.test(r) ? ft(r) : r) : r, nr = (r, e, t) => {
|
|
981
981
|
let n;
|
|
982
982
|
if (!t && e && !/[%+]/.test(e)) {
|
|
983
983
|
let i = r.indexOf(`?${e}`, 8);
|
|
@@ -985,7 +985,7 @@ var Yt = (r) => {
|
|
|
985
985
|
const o = r.charCodeAt(i + e.length + 1);
|
|
986
986
|
if (o === 61) {
|
|
987
987
|
const c = i + e.length + 2, u = r.indexOf("&", c);
|
|
988
|
-
return
|
|
988
|
+
return jt(r.slice(c, u === -1 ? void 0 : u));
|
|
989
989
|
} else if (o == 38 || isNaN(o))
|
|
990
990
|
return "";
|
|
991
991
|
i = r.indexOf(`&${e}`, i + 1);
|
|
@@ -1004,26 +1004,26 @@ var Yt = (r) => {
|
|
|
1004
1004
|
a + 1,
|
|
1005
1005
|
o === -1 ? i === -1 ? void 0 : i : o
|
|
1006
1006
|
);
|
|
1007
|
-
if (n && (c =
|
|
1007
|
+
if (n && (c = jt(c)), a = i, c === "")
|
|
1008
1008
|
continue;
|
|
1009
1009
|
let u;
|
|
1010
|
-
o === -1 ? u = "" : (u = r.slice(o + 1, i === -1 ? void 0 : i), n && (u =
|
|
1010
|
+
o === -1 ? u = "" : (u = r.slice(o + 1, i === -1 ? void 0 : i), n && (u = jt(u))), t ? (s[c] && Array.isArray(s[c]) || (s[c] = []), s[c].push(u)) : s[c] ?? (s[c] = u);
|
|
1011
1011
|
}
|
|
1012
1012
|
return e ? s[e] : s;
|
|
1013
|
-
},
|
|
1013
|
+
}, rn = nr, nn = (r, e) => nr(r, e, !0), ft = decodeURIComponent, sn = /^[\w!#$%&'*.^`|~+-]+$/, an = /^[ !#-:<-[\]-~]*$/, on = (r, e) => r.trim().split(";").reduce((n, s) => {
|
|
1014
1014
|
s = s.trim();
|
|
1015
1015
|
const a = s.indexOf("=");
|
|
1016
1016
|
if (a === -1)
|
|
1017
1017
|
return n;
|
|
1018
1018
|
const i = s.substring(0, a).trim();
|
|
1019
|
-
if (!
|
|
1019
|
+
if (!sn.test(i))
|
|
1020
1020
|
return n;
|
|
1021
1021
|
let o = s.substring(a + 1).trim();
|
|
1022
|
-
return o.startsWith('"') && o.endsWith('"') && (o = o.slice(1, -1)),
|
|
1023
|
-
}, {}),
|
|
1022
|
+
return o.startsWith('"') && o.endsWith('"') && (o = o.slice(1, -1)), an.test(o) && (n[i] = ft(o)), n;
|
|
1023
|
+
}, {}), cn = (r, e, t) => {
|
|
1024
1024
|
const n = r.req.raw.headers.get("Cookie");
|
|
1025
|
-
return n ?
|
|
1026
|
-
},
|
|
1025
|
+
return n ? on(n) : {};
|
|
1026
|
+
}, Rt = class extends Error {
|
|
1027
1027
|
constructor(e = 500, t) {
|
|
1028
1028
|
super(t == null ? void 0 : t.message, { cause: t == null ? void 0 : t.cause });
|
|
1029
1029
|
p(this, "res");
|
|
@@ -1038,24 +1038,24 @@ var Yt = (r) => {
|
|
|
1038
1038
|
status: this.status
|
|
1039
1039
|
});
|
|
1040
1040
|
}
|
|
1041
|
-
},
|
|
1041
|
+
}, un = (r, e) => new Response(r, {
|
|
1042
1042
|
headers: {
|
|
1043
1043
|
"Content-Type": e
|
|
1044
1044
|
}
|
|
1045
|
-
}).formData(),
|
|
1045
|
+
}).formData(), dn = (r, e) => async (t, n) => {
|
|
1046
1046
|
let s = {};
|
|
1047
1047
|
const a = t.req.header("Content-Type");
|
|
1048
1048
|
switch (r) {
|
|
1049
1049
|
case "json":
|
|
1050
1050
|
if (!a || !/^application\/([a-z-\.]+\+)?json/.test(a)) {
|
|
1051
1051
|
const o = `Invalid HTTP header: Content-Type=${a}`;
|
|
1052
|
-
throw new
|
|
1052
|
+
throw new Rt(400, { message: o });
|
|
1053
1053
|
}
|
|
1054
1054
|
try {
|
|
1055
1055
|
s = await t.req.json();
|
|
1056
1056
|
} catch {
|
|
1057
1057
|
const o = "Malformed JSON in request body";
|
|
1058
|
-
throw new
|
|
1058
|
+
throw new Rt(400, { message: o });
|
|
1059
1059
|
}
|
|
1060
1060
|
break;
|
|
1061
1061
|
case "form": {
|
|
@@ -1066,13 +1066,13 @@ var Yt = (r) => {
|
|
|
1066
1066
|
break;
|
|
1067
1067
|
}
|
|
1068
1068
|
try {
|
|
1069
|
-
const o = await t.req.arrayBuffer(), c = await
|
|
1070
|
-
c.forEach((d,
|
|
1071
|
-
|
|
1069
|
+
const o = await t.req.arrayBuffer(), c = await un(o, a), u = {};
|
|
1070
|
+
c.forEach((d, h) => {
|
|
1071
|
+
h.endsWith("[]") ? u[h] === void 0 ? u[h] = [d] : Array.isArray(u[h]) && u[h].push(d) : u[h] = d;
|
|
1072
1072
|
}), s = u, t.req.bodyCache.formData = c;
|
|
1073
1073
|
} catch (o) {
|
|
1074
1074
|
let c = "Malformed FormData request.";
|
|
1075
|
-
throw c += o instanceof Error ? ` ${o.message}` : ` ${String(o)}`, new
|
|
1075
|
+
throw c += o instanceof Error ? ` ${o.message}` : ` ${String(o)}`, new Rt(400, { message: c });
|
|
1076
1076
|
}
|
|
1077
1077
|
break;
|
|
1078
1078
|
}
|
|
@@ -1088,7 +1088,7 @@ var Yt = (r) => {
|
|
|
1088
1088
|
s = t.req.header();
|
|
1089
1089
|
break;
|
|
1090
1090
|
case "cookie":
|
|
1091
|
-
s =
|
|
1091
|
+
s = cn(t);
|
|
1092
1092
|
break;
|
|
1093
1093
|
}
|
|
1094
1094
|
const i = await e(s, t);
|
|
@@ -1096,9 +1096,9 @@ var Yt = (r) => {
|
|
|
1096
1096
|
return i;
|
|
1097
1097
|
t.req.addValidatedData(r, i), await n();
|
|
1098
1098
|
};
|
|
1099
|
-
const
|
|
1099
|
+
const _e = (r, e, t) => (
|
|
1100
1100
|
// @ts-expect-error not typed well
|
|
1101
|
-
|
|
1101
|
+
dn(r, async (n, s) => {
|
|
1102
1102
|
const a = await e.safeParseAsync(n);
|
|
1103
1103
|
if (t) {
|
|
1104
1104
|
const i = await t({ data: n, ...a }, s);
|
|
@@ -1112,35 +1112,35 @@ const ye = (r, e, t) => (
|
|
|
1112
1112
|
return a.success ? a.data : s.json(a, 400);
|
|
1113
1113
|
})
|
|
1114
1114
|
);
|
|
1115
|
-
var
|
|
1116
|
-
const { all: t = !1, dot: n = !1 } = e, a = (r instanceof
|
|
1117
|
-
return a !== null && a.startsWith("multipart/form-data") || a !== null && a.startsWith("application/x-www-form-urlencoded") ?
|
|
1115
|
+
var ln = async (r, e = /* @__PURE__ */ Object.create(null)) => {
|
|
1116
|
+
const { all: t = !1, dot: n = !1 } = e, a = (r instanceof sr ? r.raw.headers : r.headers).get("Content-Type");
|
|
1117
|
+
return a !== null && a.startsWith("multipart/form-data") || a !== null && a.startsWith("application/x-www-form-urlencoded") ? hn(r, { all: t, dot: n }) : {};
|
|
1118
1118
|
};
|
|
1119
|
-
async function
|
|
1119
|
+
async function hn(r, e) {
|
|
1120
1120
|
const t = await r.formData();
|
|
1121
|
-
return t ?
|
|
1121
|
+
return t ? fn(t, e) : {};
|
|
1122
1122
|
}
|
|
1123
|
-
function
|
|
1123
|
+
function fn(r, e) {
|
|
1124
1124
|
const t = /* @__PURE__ */ Object.create(null);
|
|
1125
1125
|
return r.forEach((n, s) => {
|
|
1126
|
-
e.all || s.endsWith("[]") ?
|
|
1126
|
+
e.all || s.endsWith("[]") ? pn(t, s, n) : t[s] = n;
|
|
1127
1127
|
}), e.dot && Object.entries(t).forEach(([n, s]) => {
|
|
1128
|
-
n.includes(".") && (
|
|
1128
|
+
n.includes(".") && (mn(t, n, s), delete t[n]);
|
|
1129
1129
|
}), t;
|
|
1130
1130
|
}
|
|
1131
|
-
var
|
|
1131
|
+
var pn = (r, e, t) => {
|
|
1132
1132
|
r[e] !== void 0 ? Array.isArray(r[e]) ? r[e].push(t) : r[e] = [r[e], t] : r[e] = t;
|
|
1133
|
-
},
|
|
1133
|
+
}, mn = (r, e, t) => {
|
|
1134
1134
|
let n = r;
|
|
1135
1135
|
const s = e.split(".");
|
|
1136
1136
|
s.forEach((a, i) => {
|
|
1137
1137
|
i === s.length - 1 ? n[a] = t : ((!n[a] || typeof n[a] != "object" || Array.isArray(n[a]) || n[a] instanceof File) && (n[a] = /* @__PURE__ */ Object.create(null)), n = n[a]);
|
|
1138
1138
|
});
|
|
1139
|
-
},
|
|
1139
|
+
}, Te, H, Yt, sr = (Yt = class {
|
|
1140
1140
|
constructor(r, e = "/", t = [[]]) {
|
|
1141
1141
|
p(this, "raw");
|
|
1142
|
-
|
|
1143
|
-
|
|
1142
|
+
D(this, Te);
|
|
1143
|
+
D(this, H);
|
|
1144
1144
|
p(this, "routeIndex", 0);
|
|
1145
1145
|
p(this, "path");
|
|
1146
1146
|
p(this, "bodyCache", {});
|
|
@@ -1151,31 +1151,31 @@ var dn = (r, e, t) => {
|
|
|
1151
1151
|
const s = Object.keys(e)[0];
|
|
1152
1152
|
return s ? e[s].then((a) => (s === "json" && (a = JSON.stringify(a)), new Response(a)[r]())) : e[r] = t[r]();
|
|
1153
1153
|
});
|
|
1154
|
-
this.raw = r, this.path = e,
|
|
1154
|
+
this.raw = r, this.path = e, j(this, H, t), j(this, Te, {});
|
|
1155
1155
|
}
|
|
1156
1156
|
param(r) {
|
|
1157
1157
|
return r ? this.getDecodedParam(r) : this.getAllDecodedParams();
|
|
1158
1158
|
}
|
|
1159
1159
|
getDecodedParam(r) {
|
|
1160
|
-
const e =
|
|
1160
|
+
const e = f(this, H)[0][this.routeIndex][1][r], t = this.getParamValue(e);
|
|
1161
1161
|
return t ? /\%/.test(t) ? ft(t) : t : void 0;
|
|
1162
1162
|
}
|
|
1163
1163
|
getAllDecodedParams() {
|
|
1164
|
-
const r = {}, e = Object.keys(
|
|
1164
|
+
const r = {}, e = Object.keys(f(this, H)[0][this.routeIndex][1]);
|
|
1165
1165
|
for (const t of e) {
|
|
1166
|
-
const n = this.getParamValue(
|
|
1166
|
+
const n = this.getParamValue(f(this, H)[0][this.routeIndex][1][t]);
|
|
1167
1167
|
n && typeof n == "string" && (r[t] = /\%/.test(n) ? ft(n) : n);
|
|
1168
1168
|
}
|
|
1169
1169
|
return r;
|
|
1170
1170
|
}
|
|
1171
1171
|
getParamValue(r) {
|
|
1172
|
-
return
|
|
1172
|
+
return f(this, H)[1] ? f(this, H)[1][r] : r;
|
|
1173
1173
|
}
|
|
1174
1174
|
query(r) {
|
|
1175
|
-
return
|
|
1175
|
+
return rn(this.url, r);
|
|
1176
1176
|
}
|
|
1177
1177
|
queries(r) {
|
|
1178
|
-
return
|
|
1178
|
+
return nn(this.url, r);
|
|
1179
1179
|
}
|
|
1180
1180
|
header(r) {
|
|
1181
1181
|
if (r)
|
|
@@ -1187,7 +1187,7 @@ var dn = (r, e, t) => {
|
|
|
1187
1187
|
}
|
|
1188
1188
|
async parseBody(r) {
|
|
1189
1189
|
var e;
|
|
1190
|
-
return (e = this.bodyCache).parsedBody ?? (e.parsedBody = await
|
|
1190
|
+
return (e = this.bodyCache).parsedBody ?? (e.parsedBody = await ln(this, r));
|
|
1191
1191
|
}
|
|
1192
1192
|
json() {
|
|
1193
1193
|
return this.cachedBody("json");
|
|
@@ -1205,10 +1205,10 @@ var dn = (r, e, t) => {
|
|
|
1205
1205
|
return this.cachedBody("formData");
|
|
1206
1206
|
}
|
|
1207
1207
|
addValidatedData(r, e) {
|
|
1208
|
-
|
|
1208
|
+
f(this, Te)[r] = e;
|
|
1209
1209
|
}
|
|
1210
1210
|
valid(r) {
|
|
1211
|
-
return
|
|
1211
|
+
return f(this, Te)[r];
|
|
1212
1212
|
}
|
|
1213
1213
|
get url() {
|
|
1214
1214
|
return this.raw.url;
|
|
@@ -1217,147 +1217,147 @@ var dn = (r, e, t) => {
|
|
|
1217
1217
|
return this.raw.method;
|
|
1218
1218
|
}
|
|
1219
1219
|
get matchedRoutes() {
|
|
1220
|
-
return
|
|
1220
|
+
return f(this, H)[0].map(([[, r]]) => r);
|
|
1221
1221
|
}
|
|
1222
1222
|
get routePath() {
|
|
1223
|
-
return
|
|
1223
|
+
return f(this, H)[0].map(([[, r]]) => r)[this.routeIndex].path;
|
|
1224
1224
|
}
|
|
1225
|
-
},
|
|
1225
|
+
}, Te = new WeakMap(), H = new WeakMap(), Yt), gn = {
|
|
1226
1226
|
Stringify: 1,
|
|
1227
1227
|
BeforeStream: 2,
|
|
1228
1228
|
Stream: 3
|
|
1229
|
-
},
|
|
1229
|
+
}, ar = async (r, e, t, n, s) => {
|
|
1230
1230
|
const a = r.callbacks;
|
|
1231
1231
|
return a != null && a.length ? (s ? s[0] += r : s = [r], Promise.all(a.map((o) => o({ phase: e, buffer: s, context: n }))).then(
|
|
1232
1232
|
(o) => Promise.all(
|
|
1233
|
-
o.filter(Boolean).map((c) =>
|
|
1233
|
+
o.filter(Boolean).map((c) => ar(c, e, !1, n, s))
|
|
1234
1234
|
).then(() => s[0])
|
|
1235
1235
|
)) : Promise.resolve(r);
|
|
1236
|
-
},
|
|
1236
|
+
}, vn = "text/plain; charset=UTF-8", Et = (r, e = {}) => (Object.entries(e).forEach(([t, n]) => r.set(t, n)), r), rt, nt, ie, fe, te, I, Z, q, re, st, je, Re, at, it, Qt, ut = (Qt = class {
|
|
1237
1237
|
constructor(r, e) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1238
|
+
D(this, rt);
|
|
1239
|
+
D(this, nt);
|
|
1240
1240
|
p(this, "env", {});
|
|
1241
|
-
|
|
1241
|
+
D(this, ie);
|
|
1242
1242
|
p(this, "finalized", !1);
|
|
1243
1243
|
p(this, "error");
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
p(this, "render", (...r) => (
|
|
1256
|
-
p(this, "setLayout", (r) =>
|
|
1257
|
-
p(this, "getLayout", () =>
|
|
1244
|
+
D(this, fe, 200);
|
|
1245
|
+
D(this, te);
|
|
1246
|
+
D(this, I);
|
|
1247
|
+
D(this, Z);
|
|
1248
|
+
D(this, q);
|
|
1249
|
+
D(this, re, !0);
|
|
1250
|
+
D(this, st);
|
|
1251
|
+
D(this, je);
|
|
1252
|
+
D(this, Re);
|
|
1253
|
+
D(this, at);
|
|
1254
|
+
D(this, it);
|
|
1255
|
+
p(this, "render", (...r) => (f(this, je) ?? j(this, je, (e) => this.html(e)), f(this, je).call(this, ...r)));
|
|
1256
|
+
p(this, "setLayout", (r) => j(this, st, r));
|
|
1257
|
+
p(this, "getLayout", () => f(this, st));
|
|
1258
1258
|
p(this, "setRenderer", (r) => {
|
|
1259
|
-
|
|
1259
|
+
j(this, je, r);
|
|
1260
1260
|
});
|
|
1261
1261
|
p(this, "header", (r, e, t) => {
|
|
1262
1262
|
if (e === void 0) {
|
|
1263
|
-
|
|
1263
|
+
f(this, I) ? f(this, I).delete(r) : f(this, Z) && delete f(this, Z)[r.toLocaleLowerCase()], this.finalized && this.res.headers.delete(r);
|
|
1264
1264
|
return;
|
|
1265
1265
|
}
|
|
1266
|
-
t != null && t.append ? (
|
|
1266
|
+
t != null && t.append ? (f(this, I) || (j(this, re, !1), j(this, I, new Headers(f(this, Z))), j(this, Z, {})), f(this, I).append(r, e)) : f(this, I) ? f(this, I).set(r, e) : (f(this, Z) ?? j(this, Z, {}), f(this, Z)[r.toLowerCase()] = e), this.finalized && (t != null && t.append ? this.res.headers.append(r, e) : this.res.headers.set(r, e));
|
|
1267
1267
|
});
|
|
1268
1268
|
p(this, "status", (r) => {
|
|
1269
|
-
|
|
1269
|
+
j(this, re, !1), j(this, fe, r);
|
|
1270
1270
|
});
|
|
1271
1271
|
p(this, "set", (r, e) => {
|
|
1272
|
-
|
|
1272
|
+
f(this, ie) ?? j(this, ie, {}), f(this, ie)[r] = e;
|
|
1273
1273
|
});
|
|
1274
|
-
p(this, "get", (r) =>
|
|
1274
|
+
p(this, "get", (r) => f(this, ie) ? f(this, ie)[r] : void 0);
|
|
1275
1275
|
p(this, "newResponse", (r, e, t) => {
|
|
1276
|
-
if (
|
|
1276
|
+
if (f(this, re) && !t && !e && f(this, fe) === 200)
|
|
1277
1277
|
return new Response(r, {
|
|
1278
|
-
headers:
|
|
1278
|
+
headers: f(this, Z)
|
|
1279
1279
|
});
|
|
1280
1280
|
if (e && typeof e != "number") {
|
|
1281
1281
|
const s = new Headers(e.headers);
|
|
1282
|
-
|
|
1282
|
+
f(this, I) && f(this, I).forEach((i, o) => {
|
|
1283
1283
|
o === "set-cookie" ? s.append(o, i) : s.set(o, i);
|
|
1284
1284
|
});
|
|
1285
|
-
const a =
|
|
1285
|
+
const a = Et(s, f(this, Z));
|
|
1286
1286
|
return new Response(r, {
|
|
1287
1287
|
headers: a,
|
|
1288
|
-
status: e.status ??
|
|
1288
|
+
status: e.status ?? f(this, fe)
|
|
1289
1289
|
});
|
|
1290
1290
|
}
|
|
1291
|
-
const n = typeof e == "number" ? e :
|
|
1292
|
-
|
|
1291
|
+
const n = typeof e == "number" ? e : f(this, fe);
|
|
1292
|
+
f(this, Z) ?? j(this, Z, {}), f(this, I) ?? j(this, I, new Headers()), Et(f(this, I), f(this, Z)), f(this, q) && (f(this, q).headers.forEach((s, a) => {
|
|
1293
1293
|
var i, o;
|
|
1294
|
-
a === "set-cookie" ? (i =
|
|
1295
|
-
}),
|
|
1294
|
+
a === "set-cookie" ? (i = f(this, I)) == null || i.append(a, s) : (o = f(this, I)) == null || o.set(a, s);
|
|
1295
|
+
}), Et(f(this, I), f(this, Z))), t ?? (t = {});
|
|
1296
1296
|
for (const [s, a] of Object.entries(t))
|
|
1297
1297
|
if (typeof a == "string")
|
|
1298
|
-
|
|
1298
|
+
f(this, I).set(s, a);
|
|
1299
1299
|
else {
|
|
1300
|
-
|
|
1300
|
+
f(this, I).delete(s);
|
|
1301
1301
|
for (const i of a)
|
|
1302
|
-
|
|
1302
|
+
f(this, I).append(s, i);
|
|
1303
1303
|
}
|
|
1304
1304
|
return new Response(r, {
|
|
1305
1305
|
status: n,
|
|
1306
|
-
headers:
|
|
1306
|
+
headers: f(this, I)
|
|
1307
1307
|
});
|
|
1308
1308
|
});
|
|
1309
1309
|
p(this, "body", (r, e, t) => typeof e == "number" ? this.newResponse(r, e, t) : this.newResponse(r, e));
|
|
1310
1310
|
p(this, "text", (r, e, t) => {
|
|
1311
|
-
if (!
|
|
1312
|
-
if (
|
|
1311
|
+
if (!f(this, Z)) {
|
|
1312
|
+
if (f(this, re) && !t && !e)
|
|
1313
1313
|
return new Response(r);
|
|
1314
|
-
|
|
1314
|
+
j(this, Z, {});
|
|
1315
1315
|
}
|
|
1316
|
-
return
|
|
1316
|
+
return f(this, Z)["content-type"] = vn, typeof e == "number" ? this.newResponse(r, e, t) : this.newResponse(r, e);
|
|
1317
1317
|
});
|
|
1318
1318
|
p(this, "json", (r, e, t) => {
|
|
1319
1319
|
const n = JSON.stringify(r);
|
|
1320
|
-
return
|
|
1320
|
+
return f(this, Z) ?? j(this, Z, {}), f(this, Z)["content-type"] = "application/json; charset=UTF-8", typeof e == "number" ? this.newResponse(n, e, t) : this.newResponse(n, e);
|
|
1321
1321
|
});
|
|
1322
|
-
p(this, "html", (r, e, t) => (
|
|
1323
|
-
p(this, "redirect", (r, e) => (
|
|
1324
|
-
p(this, "notFound", () => (
|
|
1325
|
-
|
|
1322
|
+
p(this, "html", (r, e, t) => (f(this, Z) ?? j(this, Z, {}), f(this, Z)["content-type"] = "text/html; charset=UTF-8", typeof r == "object" && (r instanceof Promise || (r = r.toString()), r instanceof Promise) ? r.then((n) => ar(n, gn.Stringify, !1, {})).then((n) => typeof e == "number" ? this.newResponse(n, e, t) : this.newResponse(n, e)) : typeof e == "number" ? this.newResponse(r, e, t) : this.newResponse(r, e)));
|
|
1323
|
+
p(this, "redirect", (r, e) => (f(this, I) ?? j(this, I, new Headers()), f(this, I).set("Location", r), this.newResponse(null, e ?? 302)));
|
|
1324
|
+
p(this, "notFound", () => (f(this, Re) ?? j(this, Re, () => new Response()), f(this, Re).call(this, this)));
|
|
1325
|
+
j(this, rt, r), e && (j(this, te, e.executionCtx), this.env = e.env, j(this, Re, e.notFoundHandler), j(this, it, e.path), j(this, at, e.matchResult));
|
|
1326
1326
|
}
|
|
1327
1327
|
get req() {
|
|
1328
|
-
return
|
|
1328
|
+
return f(this, nt) ?? j(this, nt, new sr(f(this, rt), f(this, it), f(this, at))), f(this, nt);
|
|
1329
1329
|
}
|
|
1330
1330
|
get event() {
|
|
1331
|
-
if (
|
|
1332
|
-
return
|
|
1331
|
+
if (f(this, te) && "respondWith" in f(this, te))
|
|
1332
|
+
return f(this, te);
|
|
1333
1333
|
throw Error("This context has no FetchEvent");
|
|
1334
1334
|
}
|
|
1335
1335
|
get executionCtx() {
|
|
1336
|
-
if (
|
|
1337
|
-
return
|
|
1336
|
+
if (f(this, te))
|
|
1337
|
+
return f(this, te);
|
|
1338
1338
|
throw Error("This context has no ExecutionContext");
|
|
1339
1339
|
}
|
|
1340
1340
|
get res() {
|
|
1341
|
-
return
|
|
1341
|
+
return j(this, re, !1), f(this, q) || j(this, q, new Response("404 Not Found", { status: 404 }));
|
|
1342
1342
|
}
|
|
1343
1343
|
set res(r) {
|
|
1344
|
-
if (
|
|
1345
|
-
|
|
1346
|
-
for (const [e, t] of
|
|
1344
|
+
if (j(this, re, !1), f(this, q) && r) {
|
|
1345
|
+
f(this, q).headers.delete("content-type");
|
|
1346
|
+
for (const [e, t] of f(this, q).headers.entries())
|
|
1347
1347
|
if (e === "set-cookie") {
|
|
1348
|
-
const n =
|
|
1348
|
+
const n = f(this, q).headers.getSetCookie();
|
|
1349
1349
|
r.headers.delete("set-cookie");
|
|
1350
1350
|
for (const s of n)
|
|
1351
1351
|
r.headers.append("set-cookie", s);
|
|
1352
1352
|
} else
|
|
1353
1353
|
r.headers.set(e, t);
|
|
1354
1354
|
}
|
|
1355
|
-
|
|
1355
|
+
j(this, q, r), this.finalized = !0;
|
|
1356
1356
|
}
|
|
1357
1357
|
get var() {
|
|
1358
|
-
return { ...
|
|
1358
|
+
return { ...f(this, ie) };
|
|
1359
1359
|
}
|
|
1360
|
-
},
|
|
1360
|
+
}, rt = new WeakMap(), nt = new WeakMap(), ie = new WeakMap(), fe = new WeakMap(), te = new WeakMap(), I = new WeakMap(), Z = new WeakMap(), q = new WeakMap(), re = new WeakMap(), st = new WeakMap(), je = new WeakMap(), Re = new WeakMap(), at = new WeakMap(), it = new WeakMap(), Qt), qt = (r, e, t) => (n, s) => {
|
|
1361
1361
|
let a = -1;
|
|
1362
1362
|
return i(0);
|
|
1363
1363
|
async function i(o) {
|
|
@@ -1365,21 +1365,21 @@ var dn = (r, e, t) => {
|
|
|
1365
1365
|
throw new Error("next() called multiple times");
|
|
1366
1366
|
a = o;
|
|
1367
1367
|
let c, u = !1, d;
|
|
1368
|
-
if (r[o] ? (d = r[o][0][0], n instanceof
|
|
1369
|
-
n instanceof
|
|
1368
|
+
if (r[o] ? (d = r[o][0][0], n instanceof ut && (n.req.routeIndex = o)) : d = o === r.length && s || void 0, !d)
|
|
1369
|
+
n instanceof ut && n.finalized === !1 && t && (c = await t(n));
|
|
1370
1370
|
else
|
|
1371
1371
|
try {
|
|
1372
1372
|
c = await d(n, () => i(o + 1));
|
|
1373
|
-
} catch (
|
|
1374
|
-
if (
|
|
1375
|
-
n.error =
|
|
1373
|
+
} catch (h) {
|
|
1374
|
+
if (h instanceof Error && n instanceof ut && e)
|
|
1375
|
+
n.error = h, c = await e(h, n), u = !0;
|
|
1376
1376
|
else
|
|
1377
|
-
throw
|
|
1377
|
+
throw h;
|
|
1378
1378
|
}
|
|
1379
1379
|
return c && (n.finalized === !1 || u) && (n.res = c), n;
|
|
1380
1380
|
}
|
|
1381
|
-
},
|
|
1382
|
-
},
|
|
1381
|
+
}, N = "ALL", yn = "all", _n = ["get", "post", "put", "delete", "options", "patch"], ir = "Can not add a route since the matcher is already built.", or = class extends Error {
|
|
1382
|
+
}, bn = Symbol("composedHandler"), wn = (r) => r.text("404 Not Found", 404), Wt = (r, e) => "getResponse" in r ? r.getResponse() : (console.error(r), e.text("Internal Server Error", 500)), W, Jt, cr = (Jt = class {
|
|
1383
1383
|
constructor(e = {}) {
|
|
1384
1384
|
p(this, "get");
|
|
1385
1385
|
p(this, "post");
|
|
@@ -1393,10 +1393,10 @@ var dn = (r, e, t) => {
|
|
|
1393
1393
|
p(this, "router");
|
|
1394
1394
|
p(this, "getPath");
|
|
1395
1395
|
p(this, "_basePath", "/");
|
|
1396
|
-
|
|
1396
|
+
D(this, W, "/");
|
|
1397
1397
|
p(this, "routes", []);
|
|
1398
|
-
p(this, "notFoundHandler",
|
|
1399
|
-
p(this, "errorHandler",
|
|
1398
|
+
p(this, "notFoundHandler", wn);
|
|
1399
|
+
p(this, "errorHandler", Wt);
|
|
1400
1400
|
p(this, "onError", (e) => (this.errorHandler = e, this));
|
|
1401
1401
|
p(this, "notFound", (e) => (this.notFoundHandler = e, this));
|
|
1402
1402
|
p(this, "fetch", (e, ...t) => this.dispatch(e, t[1], t[0], e.method));
|
|
@@ -1404,7 +1404,7 @@ var dn = (r, e, t) => {
|
|
|
1404
1404
|
if (e instanceof Request)
|
|
1405
1405
|
return t !== void 0 && (e = new Request(e, t)), this.fetch(e, n, s);
|
|
1406
1406
|
e = e.toString();
|
|
1407
|
-
const a = /^https?:\/\//.test(e) ? e : `http://localhost${
|
|
1407
|
+
const a = /^https?:\/\//.test(e) ? e : `http://localhost${he("/", e)}`, i = new Request(a, t);
|
|
1408
1408
|
return this.fetch(i, n, s);
|
|
1409
1409
|
});
|
|
1410
1410
|
p(this, "fire", () => {
|
|
@@ -1412,27 +1412,27 @@ var dn = (r, e, t) => {
|
|
|
1412
1412
|
e.respondWith(this.dispatch(e.request, e, void 0, e.request.method));
|
|
1413
1413
|
});
|
|
1414
1414
|
});
|
|
1415
|
-
[...
|
|
1416
|
-
this[s] = (a, ...i) => (typeof a == "string" ?
|
|
1417
|
-
typeof o != "string" && this.addRoute(s,
|
|
1415
|
+
[..._n, yn].forEach((s) => {
|
|
1416
|
+
this[s] = (a, ...i) => (typeof a == "string" ? j(this, W, a) : this.addRoute(s, f(this, W), a), i.forEach((o) => {
|
|
1417
|
+
typeof o != "string" && this.addRoute(s, f(this, W), o);
|
|
1418
1418
|
}), this);
|
|
1419
1419
|
}), this.on = (s, a, ...i) => {
|
|
1420
1420
|
for (const o of [a].flat()) {
|
|
1421
|
-
|
|
1421
|
+
j(this, W, o);
|
|
1422
1422
|
for (const c of [s].flat())
|
|
1423
1423
|
i.map((u) => {
|
|
1424
|
-
this.addRoute(c.toUpperCase(),
|
|
1424
|
+
this.addRoute(c.toUpperCase(), f(this, W), u);
|
|
1425
1425
|
});
|
|
1426
1426
|
}
|
|
1427
1427
|
return this;
|
|
1428
|
-
}, this.use = (s, ...a) => (typeof s == "string" ?
|
|
1429
|
-
this.addRoute(
|
|
1428
|
+
}, this.use = (s, ...a) => (typeof s == "string" ? j(this, W, s) : (j(this, W, "*"), a.unshift(s)), a.forEach((i) => {
|
|
1429
|
+
this.addRoute(N, f(this, W), i);
|
|
1430
1430
|
}), this);
|
|
1431
1431
|
const n = e.strict ?? !0;
|
|
1432
|
-
delete e.strict, Object.assign(this, e), this.getPath = n ? e.getPath ??
|
|
1432
|
+
delete e.strict, Object.assign(this, e), this.getPath = n ? e.getPath ?? tr : tn;
|
|
1433
1433
|
}
|
|
1434
1434
|
clone() {
|
|
1435
|
-
const e = new
|
|
1435
|
+
const e = new cr({
|
|
1436
1436
|
router: this.router,
|
|
1437
1437
|
getPath: this.getPath
|
|
1438
1438
|
});
|
|
@@ -1442,12 +1442,12 @@ var dn = (r, e, t) => {
|
|
|
1442
1442
|
const n = this.basePath(e);
|
|
1443
1443
|
return t.routes.map((s) => {
|
|
1444
1444
|
let a;
|
|
1445
|
-
t.errorHandler ===
|
|
1445
|
+
t.errorHandler === Wt ? a = s.handler : (a = async (i, o) => (await qt([], t.errorHandler)(i, () => s.handler(i, o))).res, a[bn] = s.handler), n.addRoute(s.method, s.path, a);
|
|
1446
1446
|
}), this;
|
|
1447
1447
|
}
|
|
1448
1448
|
basePath(e) {
|
|
1449
1449
|
const t = this.clone();
|
|
1450
|
-
return t._basePath =
|
|
1450
|
+
return t._basePath = he(this._basePath, e), t;
|
|
1451
1451
|
}
|
|
1452
1452
|
mount(e, t, n) {
|
|
1453
1453
|
let s, a;
|
|
@@ -1464,10 +1464,10 @@ var dn = (r, e, t) => {
|
|
|
1464
1464
|
return [c.env, u];
|
|
1465
1465
|
};
|
|
1466
1466
|
s || (s = (() => {
|
|
1467
|
-
const c =
|
|
1467
|
+
const c = he(this._basePath, e), u = c === "/" ? 0 : c.length;
|
|
1468
1468
|
return (d) => {
|
|
1469
|
-
const
|
|
1470
|
-
return
|
|
1469
|
+
const h = new URL(d.url);
|
|
1470
|
+
return h.pathname = h.pathname.slice(u) || "/", new Request(h, d);
|
|
1471
1471
|
};
|
|
1472
1472
|
})());
|
|
1473
1473
|
const o = async (c, u) => {
|
|
@@ -1476,10 +1476,10 @@ var dn = (r, e, t) => {
|
|
|
1476
1476
|
return d;
|
|
1477
1477
|
await u();
|
|
1478
1478
|
};
|
|
1479
|
-
return this.addRoute(
|
|
1479
|
+
return this.addRoute(N, he(e, "*"), o), this;
|
|
1480
1480
|
}
|
|
1481
1481
|
addRoute(e, t, n) {
|
|
1482
|
-
e = e.toUpperCase(), t =
|
|
1482
|
+
e = e.toUpperCase(), t = he(this._basePath, t);
|
|
1483
1483
|
const s = { path: t, method: e, handler: n };
|
|
1484
1484
|
this.router.add(e, t, [n, s]), this.routes.push(s);
|
|
1485
1485
|
}
|
|
@@ -1494,7 +1494,7 @@ var dn = (r, e, t) => {
|
|
|
1494
1494
|
dispatch(e, t, n, s) {
|
|
1495
1495
|
if (s === "HEAD")
|
|
1496
1496
|
return (async () => new Response(null, await this.dispatch(e, t, n, "GET")))();
|
|
1497
|
-
const a = this.getPath(e, { env: n }), i = this.matchRoute(s, a), o = new
|
|
1497
|
+
const a = this.getPath(e, { env: n }), i = this.matchRoute(s, a), o = new ut(e, {
|
|
1498
1498
|
path: a,
|
|
1499
1499
|
matchResult: i,
|
|
1500
1500
|
env: n,
|
|
@@ -1514,7 +1514,7 @@ var dn = (r, e, t) => {
|
|
|
1514
1514
|
(d) => d || (o.finalized ? o.res : this.notFoundHandler(o))
|
|
1515
1515
|
).catch((d) => this.handleError(d, o)) : u ?? this.notFoundHandler(o);
|
|
1516
1516
|
}
|
|
1517
|
-
const c =
|
|
1517
|
+
const c = qt(i[0], this.errorHandler, this.notFoundHandler);
|
|
1518
1518
|
return (async () => {
|
|
1519
1519
|
try {
|
|
1520
1520
|
const u = await c(o);
|
|
@@ -1528,11 +1528,11 @@ var dn = (r, e, t) => {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
})();
|
|
1530
1530
|
}
|
|
1531
|
-
},
|
|
1532
|
-
function
|
|
1533
|
-
return r.length === 1 ? e.length === 1 ? r < e ? -1 : 1 : -1 : e.length === 1 || r ===
|
|
1531
|
+
}, W = new WeakMap(), Jt), pt = "[^/]+", Ve = ".*", Ue = "(?:|/.*)", Ne = Symbol(), xn = new Set(".\\+*[^]$()");
|
|
1532
|
+
function kn(r, e) {
|
|
1533
|
+
return r.length === 1 ? e.length === 1 ? r < e ? -1 : 1 : -1 : e.length === 1 || r === Ve || r === Ue ? 1 : e === Ve || e === Ue ? -1 : r === pt ? 1 : e === pt ? -1 : r.length === e.length ? r < e ? -1 : 1 : e.length - r.length;
|
|
1534
1534
|
}
|
|
1535
|
-
var
|
|
1535
|
+
var It = class {
|
|
1536
1536
|
constructor() {
|
|
1537
1537
|
p(this, "index");
|
|
1538
1538
|
p(this, "varIndex");
|
|
@@ -1541,51 +1541,51 @@ var Pt = class {
|
|
|
1541
1541
|
insert(e, t, n, s, a) {
|
|
1542
1542
|
if (e.length === 0) {
|
|
1543
1543
|
if (this.index !== void 0)
|
|
1544
|
-
throw
|
|
1544
|
+
throw Ne;
|
|
1545
1545
|
if (a)
|
|
1546
1546
|
return;
|
|
1547
1547
|
this.index = t;
|
|
1548
1548
|
return;
|
|
1549
1549
|
}
|
|
1550
|
-
const [i, ...o] = e, c = i === "*" ? o.length === 0 ? ["", "",
|
|
1550
|
+
const [i, ...o] = e, c = i === "*" ? o.length === 0 ? ["", "", Ve] : ["", "", pt] : i === "/*" ? ["", "", Ue] : i.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
1551
1551
|
let u;
|
|
1552
1552
|
if (c) {
|
|
1553
1553
|
const d = c[1];
|
|
1554
|
-
let
|
|
1555
|
-
if (d && c[2] && (
|
|
1556
|
-
throw
|
|
1557
|
-
if (u = this.children[
|
|
1554
|
+
let h = c[2] || pt;
|
|
1555
|
+
if (d && c[2] && (h = h.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(h)))
|
|
1556
|
+
throw Ne;
|
|
1557
|
+
if (u = this.children[h], !u) {
|
|
1558
1558
|
if (Object.keys(this.children).some(
|
|
1559
|
-
(
|
|
1559
|
+
(T) => T !== Ve && T !== Ue
|
|
1560
1560
|
))
|
|
1561
|
-
throw
|
|
1561
|
+
throw Ne;
|
|
1562
1562
|
if (a)
|
|
1563
1563
|
return;
|
|
1564
|
-
u = this.children[
|
|
1564
|
+
u = this.children[h] = new It(), d !== "" && (u.varIndex = s.varIndex++);
|
|
1565
1565
|
}
|
|
1566
1566
|
!a && d !== "" && n.push([d, u.varIndex]);
|
|
1567
1567
|
} else if (u = this.children[i], !u) {
|
|
1568
1568
|
if (Object.keys(this.children).some(
|
|
1569
|
-
(d) => d.length > 1 && d !==
|
|
1569
|
+
(d) => d.length > 1 && d !== Ve && d !== Ue
|
|
1570
1570
|
))
|
|
1571
|
-
throw
|
|
1571
|
+
throw Ne;
|
|
1572
1572
|
if (a)
|
|
1573
1573
|
return;
|
|
1574
|
-
u = this.children[i] = new
|
|
1574
|
+
u = this.children[i] = new It();
|
|
1575
1575
|
}
|
|
1576
1576
|
u.insert(o, t, n, s, a);
|
|
1577
1577
|
}
|
|
1578
1578
|
buildRegExpStr() {
|
|
1579
|
-
const t = Object.keys(this.children).sort(
|
|
1579
|
+
const t = Object.keys(this.children).sort(kn).map((n) => {
|
|
1580
1580
|
const s = this.children[n];
|
|
1581
|
-
return (typeof s.varIndex == "number" ? `(${n})@${s.varIndex}` :
|
|
1581
|
+
return (typeof s.varIndex == "number" ? `(${n})@${s.varIndex}` : xn.has(n) ? `\\${n}` : n) + s.buildRegExpStr();
|
|
1582
1582
|
});
|
|
1583
1583
|
return typeof this.index == "number" && t.unshift(`#${this.index}`), t.length === 0 ? "" : t.length === 1 ? t[0] : "(?:" + t.join("|") + ")";
|
|
1584
1584
|
}
|
|
1585
|
-
},
|
|
1585
|
+
}, On = class {
|
|
1586
1586
|
constructor() {
|
|
1587
1587
|
p(this, "context", { varIndex: 0 });
|
|
1588
|
-
p(this, "root", new
|
|
1588
|
+
p(this, "root", new It());
|
|
1589
1589
|
}
|
|
1590
1590
|
insert(r, e, t) {
|
|
1591
1591
|
const n = [], s = [];
|
|
@@ -1616,123 +1616,123 @@ var Pt = class {
|
|
|
1616
1616
|
const t = [], n = [];
|
|
1617
1617
|
return r = r.replace(/#(\d+)|@(\d+)|\.\*\$/g, (s, a, i) => typeof a < "u" ? (t[++e] = Number(a), "$()") : (typeof i < "u" && (n[Number(i)] = ++e), "")), [new RegExp(`^${r}`), t, n];
|
|
1618
1618
|
}
|
|
1619
|
-
},
|
|
1620
|
-
function
|
|
1621
|
-
return
|
|
1619
|
+
}, ur = [], Tn = [/^$/, [], /* @__PURE__ */ Object.create(null)], dt = /* @__PURE__ */ Object.create(null);
|
|
1620
|
+
function dr(r) {
|
|
1621
|
+
return dt[r] ?? (dt[r] = new RegExp(
|
|
1622
1622
|
r === "*" ? "" : `^${r.replace(
|
|
1623
1623
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
1624
1624
|
(e, t) => t ? `\\${t}` : "(?:|/.*)"
|
|
1625
1625
|
)}$`
|
|
1626
1626
|
));
|
|
1627
1627
|
}
|
|
1628
|
-
function
|
|
1629
|
-
|
|
1628
|
+
function jn() {
|
|
1629
|
+
dt = /* @__PURE__ */ Object.create(null);
|
|
1630
1630
|
}
|
|
1631
|
-
function
|
|
1631
|
+
function Rn(r) {
|
|
1632
1632
|
var u;
|
|
1633
|
-
const e = new
|
|
1633
|
+
const e = new On(), t = [];
|
|
1634
1634
|
if (r.length === 0)
|
|
1635
|
-
return
|
|
1635
|
+
return Tn;
|
|
1636
1636
|
const n = r.map(
|
|
1637
1637
|
(d) => [!/\*|\/:/.test(d[0]), ...d]
|
|
1638
1638
|
).sort(
|
|
1639
|
-
([d,
|
|
1639
|
+
([d, h], [T, S]) => d ? 1 : T ? -1 : h.length - S.length
|
|
1640
1640
|
), s = /* @__PURE__ */ Object.create(null);
|
|
1641
|
-
for (let d = 0,
|
|
1642
|
-
const [
|
|
1643
|
-
|
|
1644
|
-
let
|
|
1641
|
+
for (let d = 0, h = -1, T = n.length; d < T; d++) {
|
|
1642
|
+
const [S, E, b] = n[d];
|
|
1643
|
+
S ? s[E] = [b.map(([M]) => [M, /* @__PURE__ */ Object.create(null)]), ur] : h++;
|
|
1644
|
+
let A;
|
|
1645
1645
|
try {
|
|
1646
|
-
|
|
1647
|
-
} catch (
|
|
1648
|
-
throw
|
|
1646
|
+
A = e.insert(E, h, S);
|
|
1647
|
+
} catch (M) {
|
|
1648
|
+
throw M === Ne ? new or(E) : M;
|
|
1649
1649
|
}
|
|
1650
|
-
|
|
1651
|
-
const
|
|
1652
|
-
for (
|
|
1653
|
-
const [
|
|
1654
|
-
|
|
1650
|
+
S || (t[h] = b.map(([M, K]) => {
|
|
1651
|
+
const U = /* @__PURE__ */ Object.create(null);
|
|
1652
|
+
for (K -= 1; K >= 0; K--) {
|
|
1653
|
+
const [ve, se] = A[K];
|
|
1654
|
+
U[ve] = se;
|
|
1655
1655
|
}
|
|
1656
|
-
return [
|
|
1656
|
+
return [M, U];
|
|
1657
1657
|
}));
|
|
1658
1658
|
}
|
|
1659
1659
|
const [a, i, o] = e.buildRegExp();
|
|
1660
|
-
for (let d = 0,
|
|
1661
|
-
for (let
|
|
1662
|
-
const
|
|
1663
|
-
if (!
|
|
1660
|
+
for (let d = 0, h = t.length; d < h; d++)
|
|
1661
|
+
for (let T = 0, S = t[d].length; T < S; T++) {
|
|
1662
|
+
const E = (u = t[d][T]) == null ? void 0 : u[1];
|
|
1663
|
+
if (!E)
|
|
1664
1664
|
continue;
|
|
1665
|
-
const b = Object.keys(
|
|
1666
|
-
for (let
|
|
1667
|
-
|
|
1665
|
+
const b = Object.keys(E);
|
|
1666
|
+
for (let A = 0, M = b.length; A < M; A++)
|
|
1667
|
+
E[b[A]] = o[E[b[A]]];
|
|
1668
1668
|
}
|
|
1669
1669
|
const c = [];
|
|
1670
1670
|
for (const d in i)
|
|
1671
1671
|
c[d] = t[i[d]];
|
|
1672
1672
|
return [a, c, s];
|
|
1673
1673
|
}
|
|
1674
|
-
function
|
|
1674
|
+
function be(r, e) {
|
|
1675
1675
|
if (r) {
|
|
1676
1676
|
for (const t of Object.keys(r).sort((n, s) => s.length - n.length))
|
|
1677
|
-
if (
|
|
1677
|
+
if (dr(t).test(e))
|
|
1678
1678
|
return [...r[t]];
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
|
-
var
|
|
1681
|
+
var En = class {
|
|
1682
1682
|
constructor() {
|
|
1683
1683
|
p(this, "name", "RegExpRouter");
|
|
1684
1684
|
p(this, "middleware");
|
|
1685
1685
|
p(this, "routes");
|
|
1686
|
-
this.middleware = { [
|
|
1686
|
+
this.middleware = { [N]: /* @__PURE__ */ Object.create(null) }, this.routes = { [N]: /* @__PURE__ */ Object.create(null) };
|
|
1687
1687
|
}
|
|
1688
1688
|
add(r, e, t) {
|
|
1689
1689
|
var o;
|
|
1690
1690
|
const { middleware: n, routes: s } = this;
|
|
1691
1691
|
if (!n || !s)
|
|
1692
|
-
throw new Error(
|
|
1692
|
+
throw new Error(ir);
|
|
1693
1693
|
n[r] || [n, s].forEach((c) => {
|
|
1694
|
-
c[r] = /* @__PURE__ */ Object.create(null), Object.keys(c[
|
|
1695
|
-
c[r][u] = [...c[
|
|
1694
|
+
c[r] = /* @__PURE__ */ Object.create(null), Object.keys(c[N]).forEach((u) => {
|
|
1695
|
+
c[r][u] = [...c[N][u]];
|
|
1696
1696
|
});
|
|
1697
1697
|
}), e === "/*" && (e = "*");
|
|
1698
1698
|
const a = (e.match(/\/:/g) || []).length;
|
|
1699
1699
|
if (/\*$/.test(e)) {
|
|
1700
|
-
const c =
|
|
1701
|
-
r ===
|
|
1700
|
+
const c = dr(e);
|
|
1701
|
+
r === N ? Object.keys(n).forEach((u) => {
|
|
1702
1702
|
var d;
|
|
1703
|
-
(d = n[u])[e] || (d[e] =
|
|
1704
|
-
}) : (o = n[r])[e] || (o[e] =
|
|
1705
|
-
(r ===
|
|
1703
|
+
(d = n[u])[e] || (d[e] = be(n[u], e) || be(n[N], e) || []);
|
|
1704
|
+
}) : (o = n[r])[e] || (o[e] = be(n[r], e) || be(n[N], e) || []), Object.keys(n).forEach((u) => {
|
|
1705
|
+
(r === N || r === u) && Object.keys(n[u]).forEach((d) => {
|
|
1706
1706
|
c.test(d) && n[u][d].push([t, a]);
|
|
1707
1707
|
});
|
|
1708
1708
|
}), Object.keys(s).forEach((u) => {
|
|
1709
|
-
(r ===
|
|
1709
|
+
(r === N || r === u) && Object.keys(s[u]).forEach(
|
|
1710
1710
|
(d) => c.test(d) && s[u][d].push([t, a])
|
|
1711
1711
|
);
|
|
1712
1712
|
});
|
|
1713
1713
|
return;
|
|
1714
1714
|
}
|
|
1715
|
-
const i =
|
|
1715
|
+
const i = rr(e) || [e];
|
|
1716
1716
|
for (let c = 0, u = i.length; c < u; c++) {
|
|
1717
1717
|
const d = i[c];
|
|
1718
|
-
Object.keys(s).forEach((
|
|
1719
|
-
var
|
|
1720
|
-
(r ===
|
|
1721
|
-
...
|
|
1722
|
-
]), s[
|
|
1718
|
+
Object.keys(s).forEach((h) => {
|
|
1719
|
+
var T;
|
|
1720
|
+
(r === N || r === h) && ((T = s[h])[d] || (T[d] = [
|
|
1721
|
+
...be(n[h], d) || be(n[N], d) || []
|
|
1722
|
+
]), s[h][d].push([t, a - u + c + 1]));
|
|
1723
1723
|
});
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
1726
|
match(r, e) {
|
|
1727
|
-
|
|
1727
|
+
jn();
|
|
1728
1728
|
const t = this.buildAllMatchers();
|
|
1729
1729
|
return this.match = (n, s) => {
|
|
1730
|
-
const a = t[n] || t[
|
|
1730
|
+
const a = t[n] || t[N], i = a[2][s];
|
|
1731
1731
|
if (i)
|
|
1732
1732
|
return i;
|
|
1733
1733
|
const o = s.match(a[0]);
|
|
1734
1734
|
if (!o)
|
|
1735
|
-
return [[],
|
|
1735
|
+
return [[], ur];
|
|
1736
1736
|
const c = o.indexOf("", 1);
|
|
1737
1737
|
return [a[1][c], o];
|
|
1738
1738
|
}, this.match(r, e);
|
|
@@ -1745,15 +1745,15 @@ var kn = class {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
buildMatcher(r) {
|
|
1747
1747
|
const e = [];
|
|
1748
|
-
let t = r ===
|
|
1748
|
+
let t = r === N;
|
|
1749
1749
|
return [this.middleware, this.routes].forEach((n) => {
|
|
1750
1750
|
const s = n[r] ? Object.keys(n[r]).map((a) => [a, n[r][a]]) : [];
|
|
1751
|
-
s.length !== 0 ? (t || (t = !0), e.push(...s)) : r !==
|
|
1752
|
-
...Object.keys(n[
|
|
1751
|
+
s.length !== 0 ? (t || (t = !0), e.push(...s)) : r !== N && e.push(
|
|
1752
|
+
...Object.keys(n[N]).map((a) => [a, n[N][a]])
|
|
1753
1753
|
);
|
|
1754
|
-
}), t ?
|
|
1754
|
+
}), t ? Rn(e) : null;
|
|
1755
1755
|
}
|
|
1756
|
-
},
|
|
1756
|
+
}, Sn = class {
|
|
1757
1757
|
constructor(r) {
|
|
1758
1758
|
p(this, "name", "SmartRouter");
|
|
1759
1759
|
p(this, "routers", []);
|
|
@@ -1762,7 +1762,7 @@ var kn = class {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
add(r, e, t) {
|
|
1764
1764
|
if (!this.routes)
|
|
1765
|
-
throw new Error(
|
|
1765
|
+
throw new Error(ir);
|
|
1766
1766
|
this.routes.push([r, e, t]);
|
|
1767
1767
|
}
|
|
1768
1768
|
match(r, e) {
|
|
@@ -1777,7 +1777,7 @@ var kn = class {
|
|
|
1777
1777
|
o.add(...c);
|
|
1778
1778
|
}), i = o.match(r, e);
|
|
1779
1779
|
} catch (c) {
|
|
1780
|
-
if (c instanceof
|
|
1780
|
+
if (c instanceof or)
|
|
1781
1781
|
continue;
|
|
1782
1782
|
throw c;
|
|
1783
1783
|
}
|
|
@@ -1793,7 +1793,7 @@ var kn = class {
|
|
|
1793
1793
|
throw new Error("No active router has been determined yet.");
|
|
1794
1794
|
return this.routers[0];
|
|
1795
1795
|
}
|
|
1796
|
-
},
|
|
1796
|
+
}, lr = class {
|
|
1797
1797
|
constructor(r, e, t) {
|
|
1798
1798
|
p(this, "methods");
|
|
1799
1799
|
p(this, "children");
|
|
@@ -1810,18 +1810,18 @@ var kn = class {
|
|
|
1810
1810
|
insert(r, e, t) {
|
|
1811
1811
|
this.name = `${r} ${e}`, this.order = ++this.order;
|
|
1812
1812
|
let n = this;
|
|
1813
|
-
const s =
|
|
1813
|
+
const s = Jr(e), a = [];
|
|
1814
1814
|
for (let c = 0, u = s.length; c < u; c++) {
|
|
1815
1815
|
const d = s[c];
|
|
1816
1816
|
if (Object.keys(n.children).includes(d)) {
|
|
1817
1817
|
n = n.children[d];
|
|
1818
|
-
const
|
|
1819
|
-
|
|
1818
|
+
const T = Ht(d);
|
|
1819
|
+
T && a.push(T[1]);
|
|
1820
1820
|
continue;
|
|
1821
1821
|
}
|
|
1822
|
-
n.children[d] = new
|
|
1823
|
-
const
|
|
1824
|
-
|
|
1822
|
+
n.children[d] = new lr();
|
|
1823
|
+
const h = Ht(d);
|
|
1824
|
+
h && (n.patterns.push(h), a.push(h[1])), n = n.children[d];
|
|
1825
1825
|
}
|
|
1826
1826
|
n.methods.length || (n.methods = []);
|
|
1827
1827
|
const i = /* @__PURE__ */ Object.create(null), o = {
|
|
@@ -1835,10 +1835,10 @@ var kn = class {
|
|
|
1835
1835
|
gHSets(r, e, t, n) {
|
|
1836
1836
|
const s = [];
|
|
1837
1837
|
for (let a = 0, i = r.methods.length; a < i; a++) {
|
|
1838
|
-
const o = r.methods[a], c = o[e] || o[
|
|
1838
|
+
const o = r.methods[a], c = o[e] || o[N], u = /* @__PURE__ */ Object.create(null);
|
|
1839
1839
|
c !== void 0 && (c.params = /* @__PURE__ */ Object.create(null), c.possibleKeys.forEach((d) => {
|
|
1840
|
-
const
|
|
1841
|
-
c.params[d] = n[d] && !
|
|
1840
|
+
const h = u[c.name];
|
|
1841
|
+
c.params[d] = n[d] && !h ? n[d] : t[d] ?? n[d], u[c.name] = !0;
|
|
1842
1842
|
}), s.push(c));
|
|
1843
1843
|
}
|
|
1844
1844
|
return s;
|
|
@@ -1847,43 +1847,43 @@ var kn = class {
|
|
|
1847
1847
|
const t = [];
|
|
1848
1848
|
this.params = /* @__PURE__ */ Object.create(null);
|
|
1849
1849
|
let s = [this];
|
|
1850
|
-
const a =
|
|
1850
|
+
const a = er(e);
|
|
1851
1851
|
for (let o = 0, c = a.length; o < c; o++) {
|
|
1852
|
-
const u = a[o], d = o === c - 1,
|
|
1853
|
-
for (let
|
|
1854
|
-
const
|
|
1855
|
-
b && (b.params =
|
|
1856
|
-
...this.gHSets(b.children["*"], r,
|
|
1857
|
-
), t.push(...this.gHSets(b, r,
|
|
1858
|
-
for (let
|
|
1859
|
-
const
|
|
1860
|
-
if (
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1852
|
+
const u = a[o], d = o === c - 1, h = [];
|
|
1853
|
+
for (let T = 0, S = s.length; T < S; T++) {
|
|
1854
|
+
const E = s[T], b = E.children[u];
|
|
1855
|
+
b && (b.params = E.params, d === !0 ? (b.children["*"] && t.push(
|
|
1856
|
+
...this.gHSets(b.children["*"], r, E.params, /* @__PURE__ */ Object.create(null))
|
|
1857
|
+
), t.push(...this.gHSets(b, r, E.params, /* @__PURE__ */ Object.create(null)))) : h.push(b));
|
|
1858
|
+
for (let A = 0, M = E.patterns.length; A < M; A++) {
|
|
1859
|
+
const K = E.patterns[A], U = { ...E.params };
|
|
1860
|
+
if (K === "*") {
|
|
1861
|
+
const le = E.children["*"];
|
|
1862
|
+
le && (t.push(...this.gHSets(le, r, E.params, /* @__PURE__ */ Object.create(null))), h.push(le));
|
|
1863
1863
|
continue;
|
|
1864
1864
|
}
|
|
1865
1865
|
if (u === "")
|
|
1866
1866
|
continue;
|
|
1867
|
-
const [
|
|
1868
|
-
if (
|
|
1869
|
-
|
|
1867
|
+
const [ve, se, z] = K, Y = E.children[ve], ye = a.slice(o).join("/");
|
|
1868
|
+
if (z instanceof RegExp && z.test(ye)) {
|
|
1869
|
+
U[se] = ye, t.push(...this.gHSets(Y, r, E.params, U));
|
|
1870
1870
|
continue;
|
|
1871
1871
|
}
|
|
1872
|
-
(
|
|
1872
|
+
(z === !0 || z instanceof RegExp && z.test(u)) && typeof ve == "string" && (U[se] = u, d === !0 ? (t.push(...this.gHSets(Y, r, U, E.params)), Y.children["*"] && t.push(...this.gHSets(Y.children["*"], r, U, E.params))) : (Y.params = U, h.push(Y)));
|
|
1873
1873
|
}
|
|
1874
1874
|
}
|
|
1875
|
-
s =
|
|
1875
|
+
s = h;
|
|
1876
1876
|
}
|
|
1877
1877
|
return [t.sort((o, c) => o.score - c.score).map(({ handler: o, params: c }) => [o, c])];
|
|
1878
1878
|
}
|
|
1879
|
-
},
|
|
1879
|
+
}, Cn = class {
|
|
1880
1880
|
constructor() {
|
|
1881
1881
|
p(this, "name", "TrieRouter");
|
|
1882
1882
|
p(this, "node");
|
|
1883
|
-
this.node = new
|
|
1883
|
+
this.node = new lr();
|
|
1884
1884
|
}
|
|
1885
1885
|
add(r, e, t) {
|
|
1886
|
-
const n =
|
|
1886
|
+
const n = rr(e);
|
|
1887
1887
|
if (n) {
|
|
1888
1888
|
for (const s of n)
|
|
1889
1889
|
this.node.insert(r, s, t);
|
|
@@ -1894,13 +1894,13 @@ var kn = class {
|
|
|
1894
1894
|
match(r, e) {
|
|
1895
1895
|
return this.node.search(r, e);
|
|
1896
1896
|
}
|
|
1897
|
-
},
|
|
1897
|
+
}, In = class extends cr {
|
|
1898
1898
|
constructor(r = {}) {
|
|
1899
|
-
super(r), this.router = r.router ?? new
|
|
1900
|
-
routers: [new
|
|
1899
|
+
super(r), this.router = r.router ?? new Sn({
|
|
1900
|
+
routers: [new En(), new Cn()]
|
|
1901
1901
|
});
|
|
1902
1902
|
}
|
|
1903
|
-
},
|
|
1903
|
+
}, R;
|
|
1904
1904
|
(function(r) {
|
|
1905
1905
|
r.assertEqual = (s) => s;
|
|
1906
1906
|
function e(s) {
|
|
@@ -1935,16 +1935,16 @@ var kn = class {
|
|
|
1935
1935
|
return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
1936
1936
|
}
|
|
1937
1937
|
r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
1938
|
-
})(
|
|
1939
|
-
var
|
|
1938
|
+
})(R || (R = {}));
|
|
1939
|
+
var Pt;
|
|
1940
1940
|
(function(r) {
|
|
1941
1941
|
r.mergeShapes = (e, t) => ({
|
|
1942
1942
|
...e,
|
|
1943
1943
|
...t
|
|
1944
1944
|
// second overwrites first
|
|
1945
1945
|
});
|
|
1946
|
-
})(
|
|
1947
|
-
const g =
|
|
1946
|
+
})(Pt || (Pt = {}));
|
|
1947
|
+
const g = R.arrayToEnum([
|
|
1948
1948
|
"string",
|
|
1949
1949
|
"nan",
|
|
1950
1950
|
"number",
|
|
@@ -1965,7 +1965,7 @@ const g = j.arrayToEnum([
|
|
|
1965
1965
|
"never",
|
|
1966
1966
|
"map",
|
|
1967
1967
|
"set"
|
|
1968
|
-
]),
|
|
1968
|
+
]), ae = (r) => {
|
|
1969
1969
|
switch (typeof r) {
|
|
1970
1970
|
case "undefined":
|
|
1971
1971
|
return g.undefined;
|
|
@@ -1986,7 +1986,7 @@ const g = j.arrayToEnum([
|
|
|
1986
1986
|
default:
|
|
1987
1987
|
return g.unknown;
|
|
1988
1988
|
}
|
|
1989
|
-
}, l =
|
|
1989
|
+
}, l = R.arrayToEnum([
|
|
1990
1990
|
"invalid_type",
|
|
1991
1991
|
"invalid_literal",
|
|
1992
1992
|
"custom",
|
|
@@ -2003,8 +2003,8 @@ const g = j.arrayToEnum([
|
|
|
2003
2003
|
"invalid_intersection_types",
|
|
2004
2004
|
"not_multiple_of",
|
|
2005
2005
|
"not_finite"
|
|
2006
|
-
]),
|
|
2007
|
-
class
|
|
2006
|
+
]), Pn = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
2007
|
+
class V extends Error {
|
|
2008
2008
|
constructor(e) {
|
|
2009
2009
|
super(), this.issues = [], this.addIssue = (n) => {
|
|
2010
2010
|
this.issues = [...this.issues, n];
|
|
@@ -2041,14 +2041,14 @@ class L extends Error {
|
|
|
2041
2041
|
return s(this), n;
|
|
2042
2042
|
}
|
|
2043
2043
|
static assert(e) {
|
|
2044
|
-
if (!(e instanceof
|
|
2044
|
+
if (!(e instanceof V))
|
|
2045
2045
|
throw new Error(`Not a ZodError: ${e}`);
|
|
2046
2046
|
}
|
|
2047
2047
|
toString() {
|
|
2048
2048
|
return this.message;
|
|
2049
2049
|
}
|
|
2050
2050
|
get message() {
|
|
2051
|
-
return JSON.stringify(this.issues,
|
|
2051
|
+
return JSON.stringify(this.issues, R.jsonStringifyReplacer, 2);
|
|
2052
2052
|
}
|
|
2053
2053
|
get isEmpty() {
|
|
2054
2054
|
return this.issues.length === 0;
|
|
@@ -2063,27 +2063,27 @@ class L extends Error {
|
|
|
2063
2063
|
return this.flatten();
|
|
2064
2064
|
}
|
|
2065
2065
|
}
|
|
2066
|
-
|
|
2067
|
-
const
|
|
2066
|
+
V.create = (r) => new V(r);
|
|
2067
|
+
const Ee = (r, e) => {
|
|
2068
2068
|
let t;
|
|
2069
2069
|
switch (r.code) {
|
|
2070
2070
|
case l.invalid_type:
|
|
2071
2071
|
r.received === g.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
|
|
2072
2072
|
break;
|
|
2073
2073
|
case l.invalid_literal:
|
|
2074
|
-
t = `Invalid literal value, expected ${JSON.stringify(r.expected,
|
|
2074
|
+
t = `Invalid literal value, expected ${JSON.stringify(r.expected, R.jsonStringifyReplacer)}`;
|
|
2075
2075
|
break;
|
|
2076
2076
|
case l.unrecognized_keys:
|
|
2077
|
-
t = `Unrecognized key(s) in object: ${
|
|
2077
|
+
t = `Unrecognized key(s) in object: ${R.joinValues(r.keys, ", ")}`;
|
|
2078
2078
|
break;
|
|
2079
2079
|
case l.invalid_union:
|
|
2080
2080
|
t = "Invalid input";
|
|
2081
2081
|
break;
|
|
2082
2082
|
case l.invalid_union_discriminator:
|
|
2083
|
-
t = `Invalid discriminator value. Expected ${
|
|
2083
|
+
t = `Invalid discriminator value. Expected ${R.joinValues(r.options)}`;
|
|
2084
2084
|
break;
|
|
2085
2085
|
case l.invalid_enum_value:
|
|
2086
|
-
t = `Invalid enum value. Expected ${
|
|
2086
|
+
t = `Invalid enum value. Expected ${R.joinValues(r.options)}, received '${r.received}'`;
|
|
2087
2087
|
break;
|
|
2088
2088
|
case l.invalid_arguments:
|
|
2089
2089
|
t = "Invalid function arguments";
|
|
@@ -2095,7 +2095,7 @@ const Re = (r, e) => {
|
|
|
2095
2095
|
t = "Invalid date";
|
|
2096
2096
|
break;
|
|
2097
2097
|
case l.invalid_string:
|
|
2098
|
-
typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` :
|
|
2098
|
+
typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : R.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
|
|
2099
2099
|
break;
|
|
2100
2100
|
case l.too_small:
|
|
2101
2101
|
r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
|
|
@@ -2116,18 +2116,18 @@ const Re = (r, e) => {
|
|
|
2116
2116
|
t = "Number must be finite";
|
|
2117
2117
|
break;
|
|
2118
2118
|
default:
|
|
2119
|
-
t = e.defaultError,
|
|
2119
|
+
t = e.defaultError, R.assertNever(r);
|
|
2120
2120
|
}
|
|
2121
2121
|
return { message: t };
|
|
2122
2122
|
};
|
|
2123
|
-
let
|
|
2124
|
-
function
|
|
2125
|
-
|
|
2123
|
+
let hr = Ee;
|
|
2124
|
+
function Zn(r) {
|
|
2125
|
+
hr = r;
|
|
2126
2126
|
}
|
|
2127
|
-
function
|
|
2128
|
-
return
|
|
2127
|
+
function mt() {
|
|
2128
|
+
return hr;
|
|
2129
2129
|
}
|
|
2130
|
-
const
|
|
2130
|
+
const gt = (r) => {
|
|
2131
2131
|
const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
|
|
2132
2132
|
...s,
|
|
2133
2133
|
path: a
|
|
@@ -2147,9 +2147,9 @@ const mt = (r) => {
|
|
|
2147
2147
|
path: a,
|
|
2148
2148
|
message: o
|
|
2149
2149
|
};
|
|
2150
|
-
},
|
|
2150
|
+
}, An = [];
|
|
2151
2151
|
function m(r, e) {
|
|
2152
|
-
const t =
|
|
2152
|
+
const t = mt(), n = gt({
|
|
2153
2153
|
issueData: e,
|
|
2154
2154
|
data: r.data,
|
|
2155
2155
|
path: r.path,
|
|
@@ -2157,13 +2157,13 @@ function m(r, e) {
|
|
|
2157
2157
|
r.common.contextualErrorMap,
|
|
2158
2158
|
r.schemaErrorMap,
|
|
2159
2159
|
t,
|
|
2160
|
-
t ===
|
|
2160
|
+
t === Ee ? void 0 : Ee
|
|
2161
2161
|
// then global default map
|
|
2162
2162
|
].filter((s) => !!s)
|
|
2163
2163
|
});
|
|
2164
2164
|
r.common.issues.push(n);
|
|
2165
2165
|
}
|
|
2166
|
-
class
|
|
2166
|
+
class $ {
|
|
2167
2167
|
constructor() {
|
|
2168
2168
|
this.value = "valid";
|
|
2169
2169
|
}
|
|
@@ -2191,7 +2191,7 @@ class M {
|
|
|
2191
2191
|
value: i
|
|
2192
2192
|
});
|
|
2193
2193
|
}
|
|
2194
|
-
return
|
|
2194
|
+
return $.mergeObjectSync(e, n);
|
|
2195
2195
|
}
|
|
2196
2196
|
static mergeObjectSync(e, t) {
|
|
2197
2197
|
const n = {};
|
|
@@ -2206,12 +2206,12 @@ class M {
|
|
|
2206
2206
|
}
|
|
2207
2207
|
const _ = Object.freeze({
|
|
2208
2208
|
status: "aborted"
|
|
2209
|
-
}),
|
|
2210
|
-
function
|
|
2209
|
+
}), xe = (r) => ({ status: "dirty", value: r }), L = (r) => ({ status: "valid", value: r }), Zt = (r) => r.status === "aborted", At = (r) => r.status === "dirty", He = (r) => r.status === "valid", qe = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
2210
|
+
function vt(r, e, t, n) {
|
|
2211
2211
|
if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2212
2212
|
return e.get(r);
|
|
2213
2213
|
}
|
|
2214
|
-
function
|
|
2214
|
+
function fr(r, e, t, n, s) {
|
|
2215
2215
|
if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2216
2216
|
return e.set(r, t), t;
|
|
2217
2217
|
}
|
|
@@ -2219,8 +2219,8 @@ var v;
|
|
|
2219
2219
|
(function(r) {
|
|
2220
2220
|
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
2221
2221
|
})(v || (v = {}));
|
|
2222
|
-
var
|
|
2223
|
-
class
|
|
2222
|
+
var De, Me;
|
|
2223
|
+
class J {
|
|
2224
2224
|
constructor(e, t, n, s) {
|
|
2225
2225
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
|
|
2226
2226
|
}
|
|
@@ -2228,8 +2228,8 @@ class Y {
|
|
|
2228
2228
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
2229
2229
|
}
|
|
2230
2230
|
}
|
|
2231
|
-
const
|
|
2232
|
-
if (
|
|
2231
|
+
const Bt = (r, e) => {
|
|
2232
|
+
if (He(e))
|
|
2233
2233
|
return { success: !0, data: e.value };
|
|
2234
2234
|
if (!r.common.issues.length)
|
|
2235
2235
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -2238,7 +2238,7 @@ const qt = (r, e) => {
|
|
|
2238
2238
|
get error() {
|
|
2239
2239
|
if (this._error)
|
|
2240
2240
|
return this._error;
|
|
2241
|
-
const t = new
|
|
2241
|
+
const t = new V(r.common.issues);
|
|
2242
2242
|
return this._error = t, this._error;
|
|
2243
2243
|
}
|
|
2244
2244
|
};
|
|
@@ -2255,7 +2255,7 @@ function w(r) {
|
|
|
2255
2255
|
return i.code === "invalid_enum_value" ? { message: d ?? o.defaultError } : typeof o.data > "u" ? { message: (c = d ?? n) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = d ?? t) !== null && u !== void 0 ? u : o.defaultError };
|
|
2256
2256
|
}, description: s };
|
|
2257
2257
|
}
|
|
2258
|
-
class
|
|
2258
|
+
class k {
|
|
2259
2259
|
constructor(e) {
|
|
2260
2260
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
|
|
2261
2261
|
}
|
|
@@ -2263,13 +2263,13 @@ class O {
|
|
|
2263
2263
|
return this._def.description;
|
|
2264
2264
|
}
|
|
2265
2265
|
_getType(e) {
|
|
2266
|
-
return
|
|
2266
|
+
return ae(e.data);
|
|
2267
2267
|
}
|
|
2268
2268
|
_getOrReturnCtx(e, t) {
|
|
2269
2269
|
return t || {
|
|
2270
2270
|
common: e.parent.common,
|
|
2271
2271
|
data: e.data,
|
|
2272
|
-
parsedType:
|
|
2272
|
+
parsedType: ae(e.data),
|
|
2273
2273
|
schemaErrorMap: this._def.errorMap,
|
|
2274
2274
|
path: e.path,
|
|
2275
2275
|
parent: e.parent
|
|
@@ -2277,11 +2277,11 @@ class O {
|
|
|
2277
2277
|
}
|
|
2278
2278
|
_processInputParams(e) {
|
|
2279
2279
|
return {
|
|
2280
|
-
status: new
|
|
2280
|
+
status: new $(),
|
|
2281
2281
|
ctx: {
|
|
2282
2282
|
common: e.parent.common,
|
|
2283
2283
|
data: e.data,
|
|
2284
|
-
parsedType:
|
|
2284
|
+
parsedType: ae(e.data),
|
|
2285
2285
|
schemaErrorMap: this._def.errorMap,
|
|
2286
2286
|
path: e.path,
|
|
2287
2287
|
parent: e.parent
|
|
@@ -2290,7 +2290,7 @@ class O {
|
|
|
2290
2290
|
}
|
|
2291
2291
|
_parseSync(e) {
|
|
2292
2292
|
const t = this._parse(e);
|
|
2293
|
-
if (
|
|
2293
|
+
if (qe(t))
|
|
2294
2294
|
throw new Error("Synchronous parse encountered promise.");
|
|
2295
2295
|
return t;
|
|
2296
2296
|
}
|
|
@@ -2316,9 +2316,9 @@ class O {
|
|
|
2316
2316
|
schemaErrorMap: this._def.errorMap,
|
|
2317
2317
|
parent: null,
|
|
2318
2318
|
data: e,
|
|
2319
|
-
parsedType:
|
|
2319
|
+
parsedType: ae(e)
|
|
2320
2320
|
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
2321
|
-
return
|
|
2321
|
+
return Bt(s, a);
|
|
2322
2322
|
}
|
|
2323
2323
|
async parseAsync(e, t) {
|
|
2324
2324
|
const n = await this.safeParseAsync(e, t);
|
|
@@ -2337,9 +2337,9 @@ class O {
|
|
|
2337
2337
|
schemaErrorMap: this._def.errorMap,
|
|
2338
2338
|
parent: null,
|
|
2339
2339
|
data: e,
|
|
2340
|
-
parsedType:
|
|
2341
|
-
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (
|
|
2342
|
-
return
|
|
2340
|
+
parsedType: ae(e)
|
|
2341
|
+
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (qe(s) ? s : Promise.resolve(s));
|
|
2342
|
+
return Bt(n, a);
|
|
2343
2343
|
}
|
|
2344
2344
|
refine(e, t) {
|
|
2345
2345
|
const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
@@ -2355,7 +2355,7 @@ class O {
|
|
|
2355
2355
|
return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
|
|
2356
2356
|
}
|
|
2357
2357
|
_refinement(e) {
|
|
2358
|
-
return new
|
|
2358
|
+
return new G({
|
|
2359
2359
|
schema: this,
|
|
2360
2360
|
typeName: y.ZodEffects,
|
|
2361
2361
|
effect: { type: "refinement", refinement: e }
|
|
@@ -2365,28 +2365,28 @@ class O {
|
|
|
2365
2365
|
return this._refinement(e);
|
|
2366
2366
|
}
|
|
2367
2367
|
optional() {
|
|
2368
|
-
return
|
|
2368
|
+
return Q.create(this, this._def);
|
|
2369
2369
|
}
|
|
2370
2370
|
nullable() {
|
|
2371
|
-
return
|
|
2371
|
+
return de.create(this, this._def);
|
|
2372
2372
|
}
|
|
2373
2373
|
nullish() {
|
|
2374
2374
|
return this.nullable().optional();
|
|
2375
2375
|
}
|
|
2376
2376
|
array() {
|
|
2377
|
-
return
|
|
2377
|
+
return F.create(this, this._def);
|
|
2378
2378
|
}
|
|
2379
2379
|
promise() {
|
|
2380
|
-
return
|
|
2380
|
+
return Ce.create(this, this._def);
|
|
2381
2381
|
}
|
|
2382
2382
|
or(e) {
|
|
2383
|
-
return
|
|
2383
|
+
return Ge.create([this, e], this._def);
|
|
2384
2384
|
}
|
|
2385
2385
|
and(e) {
|
|
2386
|
-
return
|
|
2386
|
+
return Ke.create(this, e, this._def);
|
|
2387
2387
|
}
|
|
2388
2388
|
transform(e) {
|
|
2389
|
-
return new
|
|
2389
|
+
return new G({
|
|
2390
2390
|
...w(this._def),
|
|
2391
2391
|
schema: this,
|
|
2392
2392
|
typeName: y.ZodEffects,
|
|
@@ -2395,7 +2395,7 @@ class O {
|
|
|
2395
2395
|
}
|
|
2396
2396
|
default(e) {
|
|
2397
2397
|
const t = typeof e == "function" ? e : () => e;
|
|
2398
|
-
return new
|
|
2398
|
+
return new ze({
|
|
2399
2399
|
...w(this._def),
|
|
2400
2400
|
innerType: this,
|
|
2401
2401
|
defaultValue: t,
|
|
@@ -2403,7 +2403,7 @@ class O {
|
|
|
2403
2403
|
});
|
|
2404
2404
|
}
|
|
2405
2405
|
brand() {
|
|
2406
|
-
return new
|
|
2406
|
+
return new $t({
|
|
2407
2407
|
typeName: y.ZodBranded,
|
|
2408
2408
|
type: this,
|
|
2409
2409
|
...w(this._def)
|
|
@@ -2411,7 +2411,7 @@ class O {
|
|
|
2411
2411
|
}
|
|
2412
2412
|
catch(e) {
|
|
2413
2413
|
const t = typeof e == "function" ? e : () => e;
|
|
2414
|
-
return new
|
|
2414
|
+
return new et({
|
|
2415
2415
|
...w(this._def),
|
|
2416
2416
|
innerType: this,
|
|
2417
2417
|
catchValue: t,
|
|
@@ -2426,10 +2426,10 @@ class O {
|
|
|
2426
2426
|
});
|
|
2427
2427
|
}
|
|
2428
2428
|
pipe(e) {
|
|
2429
|
-
return
|
|
2429
|
+
return ot.create(this, e);
|
|
2430
2430
|
}
|
|
2431
2431
|
readonly() {
|
|
2432
|
-
return
|
|
2432
|
+
return tt.create(this);
|
|
2433
2433
|
}
|
|
2434
2434
|
isOptional() {
|
|
2435
2435
|
return this.safeParse(void 0).success;
|
|
@@ -2438,25 +2438,25 @@ class O {
|
|
|
2438
2438
|
return this.safeParse(null).success;
|
|
2439
2439
|
}
|
|
2440
2440
|
}
|
|
2441
|
-
const
|
|
2442
|
-
let
|
|
2443
|
-
const
|
|
2444
|
-
function
|
|
2441
|
+
const Nn = /^c[^\s-]{8,}$/i, Dn = /^[0-9a-z]+$/, Mn = /^[0-9A-HJKMNP-TV-Z]{26}$/, $n = /^[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, Ln = /^[a-z0-9_-]{21}$/i, Vn = /^[-+]?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)?)??$/, Un = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Hn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
2442
|
+
let St;
|
|
2443
|
+
const qn = /^(?:(?: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])$/, Wn = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Bn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, pr = "((\\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])))", Fn = new RegExp(`^${pr}$`);
|
|
2444
|
+
function mr(r) {
|
|
2445
2445
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
2446
2446
|
return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
2447
2447
|
}
|
|
2448
|
-
function
|
|
2449
|
-
return new RegExp(`^${
|
|
2448
|
+
function Gn(r) {
|
|
2449
|
+
return new RegExp(`^${mr(r)}$`);
|
|
2450
2450
|
}
|
|
2451
|
-
function
|
|
2452
|
-
let e = `${
|
|
2451
|
+
function gr(r) {
|
|
2452
|
+
let e = `${pr}T${mr(r)}`;
|
|
2453
2453
|
const t = [];
|
|
2454
2454
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2457
|
-
return !!((e === "v4" || !e) &&
|
|
2456
|
+
function Kn(r, e) {
|
|
2457
|
+
return !!((e === "v4" || !e) && qn.test(r) || (e === "v6" || !e) && Wn.test(r));
|
|
2458
2458
|
}
|
|
2459
|
-
class B extends
|
|
2459
|
+
class B extends k {
|
|
2460
2460
|
_parse(e) {
|
|
2461
2461
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== g.string) {
|
|
2462
2462
|
const a = this._getOrReturnCtx(e);
|
|
@@ -2466,7 +2466,7 @@ class B extends O {
|
|
|
2466
2466
|
received: a.parsedType
|
|
2467
2467
|
}), _;
|
|
2468
2468
|
}
|
|
2469
|
-
const n = new
|
|
2469
|
+
const n = new $();
|
|
2470
2470
|
let s;
|
|
2471
2471
|
for (const a of this._def.checks)
|
|
2472
2472
|
if (a.kind === "min")
|
|
@@ -2505,43 +2505,43 @@ class B extends O {
|
|
|
2505
2505
|
message: a.message
|
|
2506
2506
|
}), n.dirty());
|
|
2507
2507
|
} else if (a.kind === "email")
|
|
2508
|
-
|
|
2508
|
+
Un.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2509
2509
|
validation: "email",
|
|
2510
2510
|
code: l.invalid_string,
|
|
2511
2511
|
message: a.message
|
|
2512
2512
|
}), n.dirty());
|
|
2513
2513
|
else if (a.kind === "emoji")
|
|
2514
|
-
|
|
2514
|
+
St || (St = new RegExp(Hn, "u")), St.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2515
2515
|
validation: "emoji",
|
|
2516
2516
|
code: l.invalid_string,
|
|
2517
2517
|
message: a.message
|
|
2518
2518
|
}), n.dirty());
|
|
2519
2519
|
else if (a.kind === "uuid")
|
|
2520
|
-
|
|
2520
|
+
$n.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2521
2521
|
validation: "uuid",
|
|
2522
2522
|
code: l.invalid_string,
|
|
2523
2523
|
message: a.message
|
|
2524
2524
|
}), n.dirty());
|
|
2525
2525
|
else if (a.kind === "nanoid")
|
|
2526
|
-
|
|
2526
|
+
Ln.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2527
2527
|
validation: "nanoid",
|
|
2528
2528
|
code: l.invalid_string,
|
|
2529
2529
|
message: a.message
|
|
2530
2530
|
}), n.dirty());
|
|
2531
2531
|
else if (a.kind === "cuid")
|
|
2532
|
-
|
|
2532
|
+
Nn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2533
2533
|
validation: "cuid",
|
|
2534
2534
|
code: l.invalid_string,
|
|
2535
2535
|
message: a.message
|
|
2536
2536
|
}), n.dirty());
|
|
2537
2537
|
else if (a.kind === "cuid2")
|
|
2538
|
-
|
|
2538
|
+
Dn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2539
2539
|
validation: "cuid2",
|
|
2540
2540
|
code: l.invalid_string,
|
|
2541
2541
|
message: a.message
|
|
2542
2542
|
}), n.dirty());
|
|
2543
2543
|
else if (a.kind === "ulid")
|
|
2544
|
-
|
|
2544
|
+
Mn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2545
2545
|
validation: "ulid",
|
|
2546
2546
|
code: l.invalid_string,
|
|
2547
2547
|
message: a.message
|
|
@@ -2572,31 +2572,31 @@ class B extends O {
|
|
|
2572
2572
|
code: l.invalid_string,
|
|
2573
2573
|
validation: { endsWith: a.value },
|
|
2574
2574
|
message: a.message
|
|
2575
|
-
}), n.dirty()) : a.kind === "datetime" ?
|
|
2575
|
+
}), n.dirty()) : a.kind === "datetime" ? gr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2576
2576
|
code: l.invalid_string,
|
|
2577
2577
|
validation: "datetime",
|
|
2578
2578
|
message: a.message
|
|
2579
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
2579
|
+
}), n.dirty()) : a.kind === "date" ? Fn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2580
2580
|
code: l.invalid_string,
|
|
2581
2581
|
validation: "date",
|
|
2582
2582
|
message: a.message
|
|
2583
|
-
}), n.dirty()) : a.kind === "time" ?
|
|
2583
|
+
}), n.dirty()) : a.kind === "time" ? Gn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2584
2584
|
code: l.invalid_string,
|
|
2585
2585
|
validation: "time",
|
|
2586
2586
|
message: a.message
|
|
2587
|
-
}), n.dirty()) : a.kind === "duration" ?
|
|
2587
|
+
}), n.dirty()) : a.kind === "duration" ? Vn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2588
2588
|
validation: "duration",
|
|
2589
2589
|
code: l.invalid_string,
|
|
2590
2590
|
message: a.message
|
|
2591
|
-
}), n.dirty()) : a.kind === "ip" ?
|
|
2591
|
+
}), n.dirty()) : a.kind === "ip" ? Kn(e.data, a.version) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2592
2592
|
validation: "ip",
|
|
2593
2593
|
code: l.invalid_string,
|
|
2594
2594
|
message: a.message
|
|
2595
|
-
}), n.dirty()) : a.kind === "base64" ?
|
|
2595
|
+
}), n.dirty()) : a.kind === "base64" ? Bn.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
|
|
2596
2596
|
validation: "base64",
|
|
2597
2597
|
code: l.invalid_string,
|
|
2598
2598
|
message: a.message
|
|
2599
|
-
}), n.dirty()) :
|
|
2599
|
+
}), n.dirty()) : R.assertNever(a);
|
|
2600
2600
|
return { status: n.value, value: e.data };
|
|
2601
2601
|
}
|
|
2602
2602
|
_regex(e, t, n) {
|
|
@@ -2814,11 +2814,11 @@ B.create = (r) => {
|
|
|
2814
2814
|
...w(r)
|
|
2815
2815
|
});
|
|
2816
2816
|
};
|
|
2817
|
-
function
|
|
2817
|
+
function Yn(r, e) {
|
|
2818
2818
|
const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
|
|
2819
2819
|
return a % i / Math.pow(10, s);
|
|
2820
2820
|
}
|
|
2821
|
-
class
|
|
2821
|
+
class oe extends k {
|
|
2822
2822
|
constructor() {
|
|
2823
2823
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
2824
2824
|
}
|
|
@@ -2832,9 +2832,9 @@ class ie extends O {
|
|
|
2832
2832
|
}), _;
|
|
2833
2833
|
}
|
|
2834
2834
|
let n;
|
|
2835
|
-
const s = new
|
|
2835
|
+
const s = new $();
|
|
2836
2836
|
for (const a of this._def.checks)
|
|
2837
|
-
a.kind === "int" ?
|
|
2837
|
+
a.kind === "int" ? R.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2838
2838
|
code: l.invalid_type,
|
|
2839
2839
|
expected: "integer",
|
|
2840
2840
|
received: "float",
|
|
@@ -2853,14 +2853,14 @@ class ie extends O {
|
|
|
2853
2853
|
inclusive: a.inclusive,
|
|
2854
2854
|
exact: !1,
|
|
2855
2855
|
message: a.message
|
|
2856
|
-
}), s.dirty()) : a.kind === "multipleOf" ?
|
|
2856
|
+
}), s.dirty()) : a.kind === "multipleOf" ? Yn(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2857
2857
|
code: l.not_multiple_of,
|
|
2858
2858
|
multipleOf: a.value,
|
|
2859
2859
|
message: a.message
|
|
2860
2860
|
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2861
2861
|
code: l.not_finite,
|
|
2862
2862
|
message: a.message
|
|
2863
|
-
}), s.dirty()) :
|
|
2863
|
+
}), s.dirty()) : R.assertNever(a);
|
|
2864
2864
|
return { status: s.value, value: e.data };
|
|
2865
2865
|
}
|
|
2866
2866
|
gte(e, t) {
|
|
@@ -2876,7 +2876,7 @@ class ie extends O {
|
|
|
2876
2876
|
return this.setLimit("max", e, !1, v.toString(t));
|
|
2877
2877
|
}
|
|
2878
2878
|
setLimit(e, t, n, s) {
|
|
2879
|
-
return new
|
|
2879
|
+
return new oe({
|
|
2880
2880
|
...this._def,
|
|
2881
2881
|
checks: [
|
|
2882
2882
|
...this._def.checks,
|
|
@@ -2890,7 +2890,7 @@ class ie extends O {
|
|
|
2890
2890
|
});
|
|
2891
2891
|
}
|
|
2892
2892
|
_addCheck(e) {
|
|
2893
|
-
return new
|
|
2893
|
+
return new oe({
|
|
2894
2894
|
...this._def,
|
|
2895
2895
|
checks: [...this._def.checks, e]
|
|
2896
2896
|
});
|
|
@@ -2972,7 +2972,7 @@ class ie extends O {
|
|
|
2972
2972
|
return e;
|
|
2973
2973
|
}
|
|
2974
2974
|
get isInt() {
|
|
2975
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" &&
|
|
2975
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && R.isInteger(e.value));
|
|
2976
2976
|
}
|
|
2977
2977
|
get isFinite() {
|
|
2978
2978
|
let e = null, t = null;
|
|
@@ -2984,13 +2984,13 @@ class ie extends O {
|
|
|
2984
2984
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
|
-
|
|
2987
|
+
oe.create = (r) => new oe({
|
|
2988
2988
|
checks: [],
|
|
2989
2989
|
typeName: y.ZodNumber,
|
|
2990
2990
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
2991
2991
|
...w(r)
|
|
2992
2992
|
});
|
|
2993
|
-
class
|
|
2993
|
+
class ce extends k {
|
|
2994
2994
|
constructor() {
|
|
2995
2995
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
2996
2996
|
}
|
|
@@ -3004,7 +3004,7 @@ class oe extends O {
|
|
|
3004
3004
|
}), _;
|
|
3005
3005
|
}
|
|
3006
3006
|
let n;
|
|
3007
|
-
const s = new
|
|
3007
|
+
const s = new $();
|
|
3008
3008
|
for (const a of this._def.checks)
|
|
3009
3009
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
3010
3010
|
code: l.too_small,
|
|
@@ -3022,7 +3022,7 @@ class oe extends O {
|
|
|
3022
3022
|
code: l.not_multiple_of,
|
|
3023
3023
|
multipleOf: a.value,
|
|
3024
3024
|
message: a.message
|
|
3025
|
-
}), s.dirty()) :
|
|
3025
|
+
}), s.dirty()) : R.assertNever(a);
|
|
3026
3026
|
return { status: s.value, value: e.data };
|
|
3027
3027
|
}
|
|
3028
3028
|
gte(e, t) {
|
|
@@ -3038,7 +3038,7 @@ class oe extends O {
|
|
|
3038
3038
|
return this.setLimit("max", e, !1, v.toString(t));
|
|
3039
3039
|
}
|
|
3040
3040
|
setLimit(e, t, n, s) {
|
|
3041
|
-
return new
|
|
3041
|
+
return new ce({
|
|
3042
3042
|
...this._def,
|
|
3043
3043
|
checks: [
|
|
3044
3044
|
...this._def.checks,
|
|
@@ -3052,7 +3052,7 @@ class oe extends O {
|
|
|
3052
3052
|
});
|
|
3053
3053
|
}
|
|
3054
3054
|
_addCheck(e) {
|
|
3055
|
-
return new
|
|
3055
|
+
return new ce({
|
|
3056
3056
|
...this._def,
|
|
3057
3057
|
checks: [...this._def.checks, e]
|
|
3058
3058
|
});
|
|
@@ -3109,16 +3109,16 @@ class oe extends O {
|
|
|
3109
3109
|
return e;
|
|
3110
3110
|
}
|
|
3111
3111
|
}
|
|
3112
|
-
|
|
3112
|
+
ce.create = (r) => {
|
|
3113
3113
|
var e;
|
|
3114
|
-
return new
|
|
3114
|
+
return new ce({
|
|
3115
3115
|
checks: [],
|
|
3116
3116
|
typeName: y.ZodBigInt,
|
|
3117
3117
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
3118
3118
|
...w(r)
|
|
3119
3119
|
});
|
|
3120
3120
|
};
|
|
3121
|
-
class
|
|
3121
|
+
class We extends k {
|
|
3122
3122
|
_parse(e) {
|
|
3123
3123
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== g.boolean) {
|
|
3124
3124
|
const n = this._getOrReturnCtx(e);
|
|
@@ -3128,15 +3128,15 @@ class qe extends O {
|
|
|
3128
3128
|
received: n.parsedType
|
|
3129
3129
|
}), _;
|
|
3130
3130
|
}
|
|
3131
|
-
return
|
|
3131
|
+
return L(e.data);
|
|
3132
3132
|
}
|
|
3133
3133
|
}
|
|
3134
|
-
|
|
3134
|
+
We.create = (r) => new We({
|
|
3135
3135
|
typeName: y.ZodBoolean,
|
|
3136
3136
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
3137
3137
|
...w(r)
|
|
3138
3138
|
});
|
|
3139
|
-
class
|
|
3139
|
+
class me extends k {
|
|
3140
3140
|
_parse(e) {
|
|
3141
3141
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== g.date) {
|
|
3142
3142
|
const a = this._getOrReturnCtx(e);
|
|
@@ -3152,7 +3152,7 @@ class pe extends O {
|
|
|
3152
3152
|
code: l.invalid_date
|
|
3153
3153
|
}), _;
|
|
3154
3154
|
}
|
|
3155
|
-
const n = new
|
|
3155
|
+
const n = new $();
|
|
3156
3156
|
let s;
|
|
3157
3157
|
for (const a of this._def.checks)
|
|
3158
3158
|
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), m(s, {
|
|
@@ -3169,14 +3169,14 @@ class pe extends O {
|
|
|
3169
3169
|
exact: !1,
|
|
3170
3170
|
maximum: a.value,
|
|
3171
3171
|
type: "date"
|
|
3172
|
-
}), n.dirty()) :
|
|
3172
|
+
}), n.dirty()) : R.assertNever(a);
|
|
3173
3173
|
return {
|
|
3174
3174
|
status: n.value,
|
|
3175
3175
|
value: new Date(e.data.getTime())
|
|
3176
3176
|
};
|
|
3177
3177
|
}
|
|
3178
3178
|
_addCheck(e) {
|
|
3179
|
-
return new
|
|
3179
|
+
return new me({
|
|
3180
3180
|
...this._def,
|
|
3181
3181
|
checks: [...this._def.checks, e]
|
|
3182
3182
|
});
|
|
@@ -3208,13 +3208,13 @@ class pe extends O {
|
|
|
3208
3208
|
return e != null ? new Date(e) : null;
|
|
3209
3209
|
}
|
|
3210
3210
|
}
|
|
3211
|
-
|
|
3211
|
+
me.create = (r) => new me({
|
|
3212
3212
|
checks: [],
|
|
3213
3213
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
3214
3214
|
typeName: y.ZodDate,
|
|
3215
3215
|
...w(r)
|
|
3216
3216
|
});
|
|
3217
|
-
class
|
|
3217
|
+
class yt extends k {
|
|
3218
3218
|
_parse(e) {
|
|
3219
3219
|
if (this._getType(e) !== g.symbol) {
|
|
3220
3220
|
const n = this._getOrReturnCtx(e);
|
|
@@ -3224,14 +3224,14 @@ class vt extends O {
|
|
|
3224
3224
|
received: n.parsedType
|
|
3225
3225
|
}), _;
|
|
3226
3226
|
}
|
|
3227
|
-
return
|
|
3227
|
+
return L(e.data);
|
|
3228
3228
|
}
|
|
3229
3229
|
}
|
|
3230
|
-
|
|
3230
|
+
yt.create = (r) => new yt({
|
|
3231
3231
|
typeName: y.ZodSymbol,
|
|
3232
3232
|
...w(r)
|
|
3233
3233
|
});
|
|
3234
|
-
class Be extends
|
|
3234
|
+
class Be extends k {
|
|
3235
3235
|
_parse(e) {
|
|
3236
3236
|
if (this._getType(e) !== g.undefined) {
|
|
3237
3237
|
const n = this._getOrReturnCtx(e);
|
|
@@ -3241,14 +3241,14 @@ class Be extends O {
|
|
|
3241
3241
|
received: n.parsedType
|
|
3242
3242
|
}), _;
|
|
3243
3243
|
}
|
|
3244
|
-
return
|
|
3244
|
+
return L(e.data);
|
|
3245
3245
|
}
|
|
3246
3246
|
}
|
|
3247
3247
|
Be.create = (r) => new Be({
|
|
3248
3248
|
typeName: y.ZodUndefined,
|
|
3249
3249
|
...w(r)
|
|
3250
3250
|
});
|
|
3251
|
-
class
|
|
3251
|
+
class Fe extends k {
|
|
3252
3252
|
_parse(e) {
|
|
3253
3253
|
if (this._getType(e) !== g.null) {
|
|
3254
3254
|
const n = this._getOrReturnCtx(e);
|
|
@@ -3258,38 +3258,38 @@ class We extends O {
|
|
|
3258
3258
|
received: n.parsedType
|
|
3259
3259
|
}), _;
|
|
3260
3260
|
}
|
|
3261
|
-
return
|
|
3261
|
+
return L(e.data);
|
|
3262
3262
|
}
|
|
3263
3263
|
}
|
|
3264
|
-
|
|
3264
|
+
Fe.create = (r) => new Fe({
|
|
3265
3265
|
typeName: y.ZodNull,
|
|
3266
3266
|
...w(r)
|
|
3267
3267
|
});
|
|
3268
|
-
class
|
|
3268
|
+
class Se extends k {
|
|
3269
3269
|
constructor() {
|
|
3270
3270
|
super(...arguments), this._any = !0;
|
|
3271
3271
|
}
|
|
3272
3272
|
_parse(e) {
|
|
3273
|
-
return
|
|
3273
|
+
return L(e.data);
|
|
3274
3274
|
}
|
|
3275
3275
|
}
|
|
3276
|
-
|
|
3276
|
+
Se.create = (r) => new Se({
|
|
3277
3277
|
typeName: y.ZodAny,
|
|
3278
3278
|
...w(r)
|
|
3279
3279
|
});
|
|
3280
|
-
class
|
|
3280
|
+
class pe extends k {
|
|
3281
3281
|
constructor() {
|
|
3282
3282
|
super(...arguments), this._unknown = !0;
|
|
3283
3283
|
}
|
|
3284
3284
|
_parse(e) {
|
|
3285
|
-
return
|
|
3285
|
+
return L(e.data);
|
|
3286
3286
|
}
|
|
3287
3287
|
}
|
|
3288
|
-
|
|
3288
|
+
pe.create = (r) => new pe({
|
|
3289
3289
|
typeName: y.ZodUnknown,
|
|
3290
3290
|
...w(r)
|
|
3291
3291
|
});
|
|
3292
|
-
class
|
|
3292
|
+
class ne extends k {
|
|
3293
3293
|
_parse(e) {
|
|
3294
3294
|
const t = this._getOrReturnCtx(e);
|
|
3295
3295
|
return m(t, {
|
|
@@ -3299,11 +3299,11 @@ class re extends O {
|
|
|
3299
3299
|
}), _;
|
|
3300
3300
|
}
|
|
3301
3301
|
}
|
|
3302
|
-
|
|
3302
|
+
ne.create = (r) => new ne({
|
|
3303
3303
|
typeName: y.ZodNever,
|
|
3304
3304
|
...w(r)
|
|
3305
3305
|
});
|
|
3306
|
-
class
|
|
3306
|
+
class _t extends k {
|
|
3307
3307
|
_parse(e) {
|
|
3308
3308
|
if (this._getType(e) !== g.undefined) {
|
|
3309
3309
|
const n = this._getOrReturnCtx(e);
|
|
@@ -3313,14 +3313,14 @@ class yt extends O {
|
|
|
3313
3313
|
received: n.parsedType
|
|
3314
3314
|
}), _;
|
|
3315
3315
|
}
|
|
3316
|
-
return
|
|
3316
|
+
return L(e.data);
|
|
3317
3317
|
}
|
|
3318
3318
|
}
|
|
3319
|
-
|
|
3319
|
+
_t.create = (r) => new _t({
|
|
3320
3320
|
typeName: y.ZodVoid,
|
|
3321
3321
|
...w(r)
|
|
3322
3322
|
});
|
|
3323
|
-
class
|
|
3323
|
+
class F extends k {
|
|
3324
3324
|
_parse(e) {
|
|
3325
3325
|
const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
|
|
3326
3326
|
if (t.parsedType !== g.array)
|
|
@@ -3356,27 +3356,27 @@ class W extends O {
|
|
|
3356
3356
|
exact: !1,
|
|
3357
3357
|
message: s.maxLength.message
|
|
3358
3358
|
}), n.dirty()), t.common.async)
|
|
3359
|
-
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new
|
|
3360
|
-
const a = [...t.data].map((i, o) => s.type._parseSync(new
|
|
3361
|
-
return
|
|
3359
|
+
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new J(t, i, t.path, o)))).then((i) => $.mergeArray(n, i));
|
|
3360
|
+
const a = [...t.data].map((i, o) => s.type._parseSync(new J(t, i, t.path, o)));
|
|
3361
|
+
return $.mergeArray(n, a);
|
|
3362
3362
|
}
|
|
3363
3363
|
get element() {
|
|
3364
3364
|
return this._def.type;
|
|
3365
3365
|
}
|
|
3366
3366
|
min(e, t) {
|
|
3367
|
-
return new
|
|
3367
|
+
return new F({
|
|
3368
3368
|
...this._def,
|
|
3369
3369
|
minLength: { value: e, message: v.toString(t) }
|
|
3370
3370
|
});
|
|
3371
3371
|
}
|
|
3372
3372
|
max(e, t) {
|
|
3373
|
-
return new
|
|
3373
|
+
return new F({
|
|
3374
3374
|
...this._def,
|
|
3375
3375
|
maxLength: { value: e, message: v.toString(t) }
|
|
3376
3376
|
});
|
|
3377
3377
|
}
|
|
3378
3378
|
length(e, t) {
|
|
3379
|
-
return new
|
|
3379
|
+
return new F({
|
|
3380
3380
|
...this._def,
|
|
3381
3381
|
exactLength: { value: e, message: v.toString(t) }
|
|
3382
3382
|
});
|
|
@@ -3385,7 +3385,7 @@ class W extends O {
|
|
|
3385
3385
|
return this.min(1, e);
|
|
3386
3386
|
}
|
|
3387
3387
|
}
|
|
3388
|
-
|
|
3388
|
+
F.create = (r, e) => new F({
|
|
3389
3389
|
type: r,
|
|
3390
3390
|
minLength: null,
|
|
3391
3391
|
maxLength: null,
|
|
@@ -3393,30 +3393,30 @@ W.create = (r, e) => new W({
|
|
|
3393
3393
|
typeName: y.ZodArray,
|
|
3394
3394
|
...w(e)
|
|
3395
3395
|
});
|
|
3396
|
-
function
|
|
3397
|
-
if (r instanceof
|
|
3396
|
+
function we(r) {
|
|
3397
|
+
if (r instanceof P) {
|
|
3398
3398
|
const e = {};
|
|
3399
3399
|
for (const t in r.shape) {
|
|
3400
3400
|
const n = r.shape[t];
|
|
3401
|
-
e[t] =
|
|
3401
|
+
e[t] = Q.create(we(n));
|
|
3402
3402
|
}
|
|
3403
|
-
return new
|
|
3403
|
+
return new P({
|
|
3404
3404
|
...r._def,
|
|
3405
3405
|
shape: () => e
|
|
3406
3406
|
});
|
|
3407
|
-
} else return r instanceof
|
|
3407
|
+
} else return r instanceof F ? new F({
|
|
3408
3408
|
...r._def,
|
|
3409
|
-
type:
|
|
3410
|
-
}) : r instanceof
|
|
3409
|
+
type: we(r.element)
|
|
3410
|
+
}) : r instanceof Q ? Q.create(we(r.unwrap())) : r instanceof de ? de.create(we(r.unwrap())) : r instanceof X ? X.create(r.items.map((e) => we(e))) : r;
|
|
3411
3411
|
}
|
|
3412
|
-
class
|
|
3412
|
+
class P extends k {
|
|
3413
3413
|
constructor() {
|
|
3414
3414
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
3415
3415
|
}
|
|
3416
3416
|
_getCached() {
|
|
3417
3417
|
if (this._cached !== null)
|
|
3418
3418
|
return this._cached;
|
|
3419
|
-
const e = this._def.shape(), t =
|
|
3419
|
+
const e = this._def.shape(), t = R.objectKeys(e);
|
|
3420
3420
|
return this._cached = { shape: e, keys: t };
|
|
3421
3421
|
}
|
|
3422
3422
|
_parse(e) {
|
|
@@ -3429,19 +3429,19 @@ class C extends O {
|
|
|
3429
3429
|
}), _;
|
|
3430
3430
|
}
|
|
3431
3431
|
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
3432
|
-
if (!(this._def.catchall instanceof
|
|
3432
|
+
if (!(this._def.catchall instanceof ne && this._def.unknownKeys === "strip"))
|
|
3433
3433
|
for (const u in s.data)
|
|
3434
3434
|
i.includes(u) || o.push(u);
|
|
3435
3435
|
const c = [];
|
|
3436
3436
|
for (const u of i) {
|
|
3437
|
-
const d = a[u],
|
|
3437
|
+
const d = a[u], h = s.data[u];
|
|
3438
3438
|
c.push({
|
|
3439
3439
|
key: { status: "valid", value: u },
|
|
3440
|
-
value: d._parse(new
|
|
3440
|
+
value: d._parse(new J(s, h, s.path, u)),
|
|
3441
3441
|
alwaysSet: u in s.data
|
|
3442
3442
|
});
|
|
3443
3443
|
}
|
|
3444
|
-
if (this._def.catchall instanceof
|
|
3444
|
+
if (this._def.catchall instanceof ne) {
|
|
3445
3445
|
const u = this._def.unknownKeys;
|
|
3446
3446
|
if (u === "passthrough")
|
|
3447
3447
|
for (const d of o)
|
|
@@ -3458,11 +3458,11 @@ class C extends O {
|
|
|
3458
3458
|
} else {
|
|
3459
3459
|
const u = this._def.catchall;
|
|
3460
3460
|
for (const d of o) {
|
|
3461
|
-
const
|
|
3461
|
+
const h = s.data[d];
|
|
3462
3462
|
c.push({
|
|
3463
3463
|
key: { status: "valid", value: d },
|
|
3464
3464
|
value: u._parse(
|
|
3465
|
-
new
|
|
3465
|
+
new J(s, h, s.path, d)
|
|
3466
3466
|
//, ctx.child(key), value, getParsedType(value)
|
|
3467
3467
|
),
|
|
3468
3468
|
alwaysSet: d in s.data
|
|
@@ -3472,21 +3472,21 @@ class C extends O {
|
|
|
3472
3472
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
3473
3473
|
const u = [];
|
|
3474
3474
|
for (const d of c) {
|
|
3475
|
-
const
|
|
3475
|
+
const h = await d.key, T = await d.value;
|
|
3476
3476
|
u.push({
|
|
3477
|
-
key:
|
|
3478
|
-
value:
|
|
3477
|
+
key: h,
|
|
3478
|
+
value: T,
|
|
3479
3479
|
alwaysSet: d.alwaysSet
|
|
3480
3480
|
});
|
|
3481
3481
|
}
|
|
3482
3482
|
return u;
|
|
3483
|
-
}).then((u) =>
|
|
3483
|
+
}).then((u) => $.mergeObjectSync(n, u)) : $.mergeObjectSync(n, c);
|
|
3484
3484
|
}
|
|
3485
3485
|
get shape() {
|
|
3486
3486
|
return this._def.shape();
|
|
3487
3487
|
}
|
|
3488
3488
|
strict(e) {
|
|
3489
|
-
return v.errToObj, new
|
|
3489
|
+
return v.errToObj, new P({
|
|
3490
3490
|
...this._def,
|
|
3491
3491
|
unknownKeys: "strict",
|
|
3492
3492
|
...e !== void 0 ? {
|
|
@@ -3503,13 +3503,13 @@ class C extends O {
|
|
|
3503
3503
|
});
|
|
3504
3504
|
}
|
|
3505
3505
|
strip() {
|
|
3506
|
-
return new
|
|
3506
|
+
return new P({
|
|
3507
3507
|
...this._def,
|
|
3508
3508
|
unknownKeys: "strip"
|
|
3509
3509
|
});
|
|
3510
3510
|
}
|
|
3511
3511
|
passthrough() {
|
|
3512
|
-
return new
|
|
3512
|
+
return new P({
|
|
3513
3513
|
...this._def,
|
|
3514
3514
|
unknownKeys: "passthrough"
|
|
3515
3515
|
});
|
|
@@ -3532,7 +3532,7 @@ class C extends O {
|
|
|
3532
3532
|
// }) as any;
|
|
3533
3533
|
// };
|
|
3534
3534
|
extend(e) {
|
|
3535
|
-
return new
|
|
3535
|
+
return new P({
|
|
3536
3536
|
...this._def,
|
|
3537
3537
|
shape: () => ({
|
|
3538
3538
|
...this._def.shape(),
|
|
@@ -3546,7 +3546,7 @@ class C extends O {
|
|
|
3546
3546
|
* upgrade if you are experiencing issues.
|
|
3547
3547
|
*/
|
|
3548
3548
|
merge(e) {
|
|
3549
|
-
return new
|
|
3549
|
+
return new P({
|
|
3550
3550
|
unknownKeys: e._def.unknownKeys,
|
|
3551
3551
|
catchall: e._def.catchall,
|
|
3552
3552
|
shape: () => ({
|
|
@@ -3616,25 +3616,25 @@ class C extends O {
|
|
|
3616
3616
|
// return merged;
|
|
3617
3617
|
// }
|
|
3618
3618
|
catchall(e) {
|
|
3619
|
-
return new
|
|
3619
|
+
return new P({
|
|
3620
3620
|
...this._def,
|
|
3621
3621
|
catchall: e
|
|
3622
3622
|
});
|
|
3623
3623
|
}
|
|
3624
3624
|
pick(e) {
|
|
3625
3625
|
const t = {};
|
|
3626
|
-
return
|
|
3626
|
+
return R.objectKeys(e).forEach((n) => {
|
|
3627
3627
|
e[n] && this.shape[n] && (t[n] = this.shape[n]);
|
|
3628
|
-
}), new
|
|
3628
|
+
}), new P({
|
|
3629
3629
|
...this._def,
|
|
3630
3630
|
shape: () => t
|
|
3631
3631
|
});
|
|
3632
3632
|
}
|
|
3633
3633
|
omit(e) {
|
|
3634
3634
|
const t = {};
|
|
3635
|
-
return
|
|
3635
|
+
return R.objectKeys(this.shape).forEach((n) => {
|
|
3636
3636
|
e[n] || (t[n] = this.shape[n]);
|
|
3637
|
-
}), new
|
|
3637
|
+
}), new P({
|
|
3638
3638
|
...this._def,
|
|
3639
3639
|
shape: () => t
|
|
3640
3640
|
});
|
|
@@ -3643,60 +3643,60 @@ class C extends O {
|
|
|
3643
3643
|
* @deprecated
|
|
3644
3644
|
*/
|
|
3645
3645
|
deepPartial() {
|
|
3646
|
-
return
|
|
3646
|
+
return we(this);
|
|
3647
3647
|
}
|
|
3648
3648
|
partial(e) {
|
|
3649
3649
|
const t = {};
|
|
3650
|
-
return
|
|
3650
|
+
return R.objectKeys(this.shape).forEach((n) => {
|
|
3651
3651
|
const s = this.shape[n];
|
|
3652
3652
|
e && !e[n] ? t[n] = s : t[n] = s.optional();
|
|
3653
|
-
}), new
|
|
3653
|
+
}), new P({
|
|
3654
3654
|
...this._def,
|
|
3655
3655
|
shape: () => t
|
|
3656
3656
|
});
|
|
3657
3657
|
}
|
|
3658
3658
|
required(e) {
|
|
3659
3659
|
const t = {};
|
|
3660
|
-
return
|
|
3660
|
+
return R.objectKeys(this.shape).forEach((n) => {
|
|
3661
3661
|
if (e && !e[n])
|
|
3662
3662
|
t[n] = this.shape[n];
|
|
3663
3663
|
else {
|
|
3664
3664
|
let a = this.shape[n];
|
|
3665
|
-
for (; a instanceof
|
|
3665
|
+
for (; a instanceof Q; )
|
|
3666
3666
|
a = a._def.innerType;
|
|
3667
3667
|
t[n] = a;
|
|
3668
3668
|
}
|
|
3669
|
-
}), new
|
|
3669
|
+
}), new P({
|
|
3670
3670
|
...this._def,
|
|
3671
3671
|
shape: () => t
|
|
3672
3672
|
});
|
|
3673
3673
|
}
|
|
3674
3674
|
keyof() {
|
|
3675
|
-
return
|
|
3675
|
+
return vr(R.objectKeys(this.shape));
|
|
3676
3676
|
}
|
|
3677
3677
|
}
|
|
3678
|
-
|
|
3678
|
+
P.create = (r, e) => new P({
|
|
3679
3679
|
shape: () => r,
|
|
3680
3680
|
unknownKeys: "strip",
|
|
3681
|
-
catchall:
|
|
3681
|
+
catchall: ne.create(),
|
|
3682
3682
|
typeName: y.ZodObject,
|
|
3683
3683
|
...w(e)
|
|
3684
3684
|
});
|
|
3685
|
-
|
|
3685
|
+
P.strictCreate = (r, e) => new P({
|
|
3686
3686
|
shape: () => r,
|
|
3687
3687
|
unknownKeys: "strict",
|
|
3688
|
-
catchall:
|
|
3688
|
+
catchall: ne.create(),
|
|
3689
3689
|
typeName: y.ZodObject,
|
|
3690
3690
|
...w(e)
|
|
3691
3691
|
});
|
|
3692
|
-
|
|
3692
|
+
P.lazycreate = (r, e) => new P({
|
|
3693
3693
|
shape: r,
|
|
3694
3694
|
unknownKeys: "strip",
|
|
3695
|
-
catchall:
|
|
3695
|
+
catchall: ne.create(),
|
|
3696
3696
|
typeName: y.ZodObject,
|
|
3697
3697
|
...w(e)
|
|
3698
3698
|
});
|
|
3699
|
-
class
|
|
3699
|
+
class Ge extends k {
|
|
3700
3700
|
_parse(e) {
|
|
3701
3701
|
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
3702
3702
|
function s(a) {
|
|
@@ -3706,7 +3706,7 @@ class Fe extends O {
|
|
|
3706
3706
|
for (const o of a)
|
|
3707
3707
|
if (o.result.status === "dirty")
|
|
3708
3708
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
3709
|
-
const i = a.map((o) => new
|
|
3709
|
+
const i = a.map((o) => new V(o.ctx.common.issues));
|
|
3710
3710
|
return m(t, {
|
|
3711
3711
|
code: l.invalid_union,
|
|
3712
3712
|
unionErrors: i
|
|
@@ -3753,7 +3753,7 @@ class Fe extends O {
|
|
|
3753
3753
|
}
|
|
3754
3754
|
if (a)
|
|
3755
3755
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
3756
|
-
const o = i.map((c) => new
|
|
3756
|
+
const o = i.map((c) => new V(c));
|
|
3757
3757
|
return m(t, {
|
|
3758
3758
|
code: l.invalid_union,
|
|
3759
3759
|
unionErrors: o
|
|
@@ -3764,13 +3764,13 @@ class Fe extends O {
|
|
|
3764
3764
|
return this._def.options;
|
|
3765
3765
|
}
|
|
3766
3766
|
}
|
|
3767
|
-
|
|
3767
|
+
Ge.create = (r, e) => new Ge({
|
|
3768
3768
|
options: r,
|
|
3769
3769
|
typeName: y.ZodUnion,
|
|
3770
3770
|
...w(e)
|
|
3771
3771
|
});
|
|
3772
|
-
const
|
|
3773
|
-
class
|
|
3772
|
+
const ee = (r) => r instanceof Qe ? ee(r.schema) : r instanceof G ? ee(r.innerType()) : r instanceof Je ? [r.value] : r instanceof ue ? r.options : r instanceof Xe ? R.objectValues(r.enum) : r instanceof ze ? ee(r._def.innerType) : r instanceof Be ? [void 0] : r instanceof Fe ? [null] : r instanceof Q ? [void 0, ...ee(r.unwrap())] : r instanceof de ? [null, ...ee(r.unwrap())] : r instanceof $t || r instanceof tt ? ee(r.unwrap()) : r instanceof et ? ee(r._def.innerType) : [];
|
|
3773
|
+
class kt extends k {
|
|
3774
3774
|
_parse(e) {
|
|
3775
3775
|
const { ctx: t } = this._processInputParams(e);
|
|
3776
3776
|
if (t.parsedType !== g.object)
|
|
@@ -3814,7 +3814,7 @@ class xt extends O {
|
|
|
3814
3814
|
static create(e, t, n) {
|
|
3815
3815
|
const s = /* @__PURE__ */ new Map();
|
|
3816
3816
|
for (const a of t) {
|
|
3817
|
-
const i =
|
|
3817
|
+
const i = ee(a.shape[e]);
|
|
3818
3818
|
if (!i.length)
|
|
3819
3819
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
3820
3820
|
for (const o of i) {
|
|
@@ -3823,7 +3823,7 @@ class xt extends O {
|
|
|
3823
3823
|
s.set(o, a);
|
|
3824
3824
|
}
|
|
3825
3825
|
}
|
|
3826
|
-
return new
|
|
3826
|
+
return new kt({
|
|
3827
3827
|
typeName: y.ZodDiscriminatedUnion,
|
|
3828
3828
|
discriminator: e,
|
|
3829
3829
|
options: t,
|
|
@@ -3832,14 +3832,14 @@ class xt extends O {
|
|
|
3832
3832
|
});
|
|
3833
3833
|
}
|
|
3834
3834
|
}
|
|
3835
|
-
function
|
|
3836
|
-
const t =
|
|
3835
|
+
function Nt(r, e) {
|
|
3836
|
+
const t = ae(r), n = ae(e);
|
|
3837
3837
|
if (r === e)
|
|
3838
3838
|
return { valid: !0, data: r };
|
|
3839
3839
|
if (t === g.object && n === g.object) {
|
|
3840
|
-
const s =
|
|
3840
|
+
const s = R.objectKeys(e), a = R.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
|
|
3841
3841
|
for (const o of a) {
|
|
3842
|
-
const c =
|
|
3842
|
+
const c = Nt(r[o], e[o]);
|
|
3843
3843
|
if (!c.valid)
|
|
3844
3844
|
return { valid: !1 };
|
|
3845
3845
|
i[o] = c.data;
|
|
@@ -3850,7 +3850,7 @@ function At(r, e) {
|
|
|
3850
3850
|
return { valid: !1 };
|
|
3851
3851
|
const s = [];
|
|
3852
3852
|
for (let a = 0; a < r.length; a++) {
|
|
3853
|
-
const i = r[a], o = e[a], c =
|
|
3853
|
+
const i = r[a], o = e[a], c = Nt(i, o);
|
|
3854
3854
|
if (!c.valid)
|
|
3855
3855
|
return { valid: !1 };
|
|
3856
3856
|
s.push(c.data);
|
|
@@ -3858,13 +3858,13 @@ function At(r, e) {
|
|
|
3858
3858
|
return { valid: !0, data: s };
|
|
3859
3859
|
} else return t === g.date && n === g.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
3860
3860
|
}
|
|
3861
|
-
class
|
|
3861
|
+
class Ke extends k {
|
|
3862
3862
|
_parse(e) {
|
|
3863
3863
|
const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
|
|
3864
3864
|
if (Zt(a) || Zt(i))
|
|
3865
3865
|
return _;
|
|
3866
|
-
const o =
|
|
3867
|
-
return o.valid ? ((
|
|
3866
|
+
const o = Nt(a.value, i.value);
|
|
3867
|
+
return o.valid ? ((At(a) || At(i)) && t.dirty(), { status: t.value, value: o.data }) : (m(n, {
|
|
3868
3868
|
code: l.invalid_intersection_types
|
|
3869
3869
|
}), _);
|
|
3870
3870
|
};
|
|
@@ -3890,13 +3890,13 @@ class Ge extends O {
|
|
|
3890
3890
|
}));
|
|
3891
3891
|
}
|
|
3892
3892
|
}
|
|
3893
|
-
|
|
3893
|
+
Ke.create = (r, e, t) => new Ke({
|
|
3894
3894
|
left: r,
|
|
3895
3895
|
right: e,
|
|
3896
3896
|
typeName: y.ZodIntersection,
|
|
3897
3897
|
...w(t)
|
|
3898
3898
|
});
|
|
3899
|
-
class X extends
|
|
3899
|
+
class X extends k {
|
|
3900
3900
|
_parse(e) {
|
|
3901
3901
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
3902
3902
|
if (n.parsedType !== g.array)
|
|
@@ -3922,9 +3922,9 @@ class X extends O {
|
|
|
3922
3922
|
}), t.dirty());
|
|
3923
3923
|
const a = [...n.data].map((i, o) => {
|
|
3924
3924
|
const c = this._def.items[o] || this._def.rest;
|
|
3925
|
-
return c ? c._parse(new
|
|
3925
|
+
return c ? c._parse(new J(n, i, n.path, o)) : null;
|
|
3926
3926
|
}).filter((i) => !!i);
|
|
3927
|
-
return n.common.async ? Promise.all(a).then((i) =>
|
|
3927
|
+
return n.common.async ? Promise.all(a).then((i) => $.mergeArray(t, i)) : $.mergeArray(t, a);
|
|
3928
3928
|
}
|
|
3929
3929
|
get items() {
|
|
3930
3930
|
return this._def.items;
|
|
@@ -3946,7 +3946,7 @@ X.create = (r, e) => {
|
|
|
3946
3946
|
...w(e)
|
|
3947
3947
|
});
|
|
3948
3948
|
};
|
|
3949
|
-
class
|
|
3949
|
+
class Ye extends k {
|
|
3950
3950
|
get keySchema() {
|
|
3951
3951
|
return this._def.keyType;
|
|
3952
3952
|
}
|
|
@@ -3964,22 +3964,22 @@ class Ke extends O {
|
|
|
3964
3964
|
const s = [], a = this._def.keyType, i = this._def.valueType;
|
|
3965
3965
|
for (const o in n.data)
|
|
3966
3966
|
s.push({
|
|
3967
|
-
key: a._parse(new
|
|
3968
|
-
value: i._parse(new
|
|
3967
|
+
key: a._parse(new J(n, o, n.path, o)),
|
|
3968
|
+
value: i._parse(new J(n, n.data[o], n.path, o)),
|
|
3969
3969
|
alwaysSet: o in n.data
|
|
3970
3970
|
});
|
|
3971
|
-
return n.common.async ?
|
|
3971
|
+
return n.common.async ? $.mergeObjectAsync(t, s) : $.mergeObjectSync(t, s);
|
|
3972
3972
|
}
|
|
3973
3973
|
get element() {
|
|
3974
3974
|
return this._def.valueType;
|
|
3975
3975
|
}
|
|
3976
3976
|
static create(e, t, n) {
|
|
3977
|
-
return t instanceof
|
|
3977
|
+
return t instanceof k ? new Ye({
|
|
3978
3978
|
keyType: e,
|
|
3979
3979
|
valueType: t,
|
|
3980
3980
|
typeName: y.ZodRecord,
|
|
3981
3981
|
...w(n)
|
|
3982
|
-
}) : new
|
|
3982
|
+
}) : new Ye({
|
|
3983
3983
|
keyType: B.create(),
|
|
3984
3984
|
valueType: e,
|
|
3985
3985
|
typeName: y.ZodRecord,
|
|
@@ -3987,7 +3987,7 @@ class Ke extends O {
|
|
|
3987
3987
|
});
|
|
3988
3988
|
}
|
|
3989
3989
|
}
|
|
3990
|
-
class
|
|
3990
|
+
class bt extends k {
|
|
3991
3991
|
get keySchema() {
|
|
3992
3992
|
return this._def.keyType;
|
|
3993
3993
|
}
|
|
@@ -4003,8 +4003,8 @@ class _t extends O {
|
|
|
4003
4003
|
received: n.parsedType
|
|
4004
4004
|
}), _;
|
|
4005
4005
|
const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, c], u) => ({
|
|
4006
|
-
key: s._parse(new
|
|
4007
|
-
value: a._parse(new
|
|
4006
|
+
key: s._parse(new J(n, o, n.path, [u, "key"])),
|
|
4007
|
+
value: a._parse(new J(n, c, n.path, [u, "value"]))
|
|
4008
4008
|
}));
|
|
4009
4009
|
if (n.common.async) {
|
|
4010
4010
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -4029,13 +4029,13 @@ class _t extends O {
|
|
|
4029
4029
|
}
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
|
-
|
|
4032
|
+
bt.create = (r, e, t) => new bt({
|
|
4033
4033
|
valueType: e,
|
|
4034
4034
|
keyType: r,
|
|
4035
4035
|
typeName: y.ZodMap,
|
|
4036
4036
|
...w(t)
|
|
4037
4037
|
});
|
|
4038
|
-
class
|
|
4038
|
+
class ge extends k {
|
|
4039
4039
|
_parse(e) {
|
|
4040
4040
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
4041
4041
|
if (n.parsedType !== g.set)
|
|
@@ -4070,17 +4070,17 @@ class me extends O {
|
|
|
4070
4070
|
}
|
|
4071
4071
|
return { status: t.value, value: u };
|
|
4072
4072
|
}
|
|
4073
|
-
const o = [...n.data.values()].map((c, u) => a._parse(new
|
|
4073
|
+
const o = [...n.data.values()].map((c, u) => a._parse(new J(n, c, n.path, u)));
|
|
4074
4074
|
return n.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
4075
4075
|
}
|
|
4076
4076
|
min(e, t) {
|
|
4077
|
-
return new
|
|
4077
|
+
return new ge({
|
|
4078
4078
|
...this._def,
|
|
4079
4079
|
minSize: { value: e, message: v.toString(t) }
|
|
4080
4080
|
});
|
|
4081
4081
|
}
|
|
4082
4082
|
max(e, t) {
|
|
4083
|
-
return new
|
|
4083
|
+
return new ge({
|
|
4084
4084
|
...this._def,
|
|
4085
4085
|
maxSize: { value: e, message: v.toString(t) }
|
|
4086
4086
|
});
|
|
@@ -4092,14 +4092,14 @@ class me extends O {
|
|
|
4092
4092
|
return this.min(1, e);
|
|
4093
4093
|
}
|
|
4094
4094
|
}
|
|
4095
|
-
|
|
4095
|
+
ge.create = (r, e) => new ge({
|
|
4096
4096
|
valueType: r,
|
|
4097
4097
|
minSize: null,
|
|
4098
4098
|
maxSize: null,
|
|
4099
4099
|
typeName: y.ZodSet,
|
|
4100
4100
|
...w(e)
|
|
4101
4101
|
});
|
|
4102
|
-
class Oe extends
|
|
4102
|
+
class Oe extends k {
|
|
4103
4103
|
constructor() {
|
|
4104
4104
|
super(...arguments), this.validate = this.implement;
|
|
4105
4105
|
}
|
|
@@ -4112,14 +4112,14 @@ class Oe extends O {
|
|
|
4112
4112
|
received: t.parsedType
|
|
4113
4113
|
}), _;
|
|
4114
4114
|
function n(o, c) {
|
|
4115
|
-
return
|
|
4115
|
+
return gt({
|
|
4116
4116
|
data: o,
|
|
4117
4117
|
path: t.path,
|
|
4118
4118
|
errorMaps: [
|
|
4119
4119
|
t.common.contextualErrorMap,
|
|
4120
4120
|
t.schemaErrorMap,
|
|
4121
|
-
|
|
4122
|
-
|
|
4121
|
+
mt(),
|
|
4122
|
+
Ee
|
|
4123
4123
|
].filter((u) => !!u),
|
|
4124
4124
|
issueData: {
|
|
4125
4125
|
code: l.invalid_arguments,
|
|
@@ -4128,14 +4128,14 @@ class Oe extends O {
|
|
|
4128
4128
|
});
|
|
4129
4129
|
}
|
|
4130
4130
|
function s(o, c) {
|
|
4131
|
-
return
|
|
4131
|
+
return gt({
|
|
4132
4132
|
data: o,
|
|
4133
4133
|
path: t.path,
|
|
4134
4134
|
errorMaps: [
|
|
4135
4135
|
t.common.contextualErrorMap,
|
|
4136
4136
|
t.schemaErrorMap,
|
|
4137
|
-
|
|
4138
|
-
|
|
4137
|
+
mt(),
|
|
4138
|
+
Ee
|
|
4139
4139
|
].filter((u) => !!u),
|
|
4140
4140
|
issueData: {
|
|
4141
4141
|
code: l.invalid_return_type,
|
|
@@ -4144,26 +4144,26 @@ class Oe extends O {
|
|
|
4144
4144
|
});
|
|
4145
4145
|
}
|
|
4146
4146
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
4147
|
-
if (this._def.returns instanceof
|
|
4147
|
+
if (this._def.returns instanceof Ce) {
|
|
4148
4148
|
const o = this;
|
|
4149
|
-
return
|
|
4150
|
-
const u = new
|
|
4151
|
-
throw u.addIssue(n(c,
|
|
4152
|
-
}),
|
|
4153
|
-
return await o._def.returns._def.type.parseAsync(
|
|
4154
|
-
throw u.addIssue(s(
|
|
4149
|
+
return L(async function(...c) {
|
|
4150
|
+
const u = new V([]), d = await o._def.args.parseAsync(c, a).catch((S) => {
|
|
4151
|
+
throw u.addIssue(n(c, S)), u;
|
|
4152
|
+
}), h = await Reflect.apply(i, this, d);
|
|
4153
|
+
return await o._def.returns._def.type.parseAsync(h, a).catch((S) => {
|
|
4154
|
+
throw u.addIssue(s(h, S)), u;
|
|
4155
4155
|
});
|
|
4156
4156
|
});
|
|
4157
4157
|
} else {
|
|
4158
4158
|
const o = this;
|
|
4159
|
-
return
|
|
4159
|
+
return L(function(...c) {
|
|
4160
4160
|
const u = o._def.args.safeParse(c, a);
|
|
4161
4161
|
if (!u.success)
|
|
4162
|
-
throw new
|
|
4163
|
-
const d = Reflect.apply(i, this, u.data),
|
|
4164
|
-
if (!
|
|
4165
|
-
throw new
|
|
4166
|
-
return
|
|
4162
|
+
throw new V([n(c, u.error)]);
|
|
4163
|
+
const d = Reflect.apply(i, this, u.data), h = o._def.returns.safeParse(d, a);
|
|
4164
|
+
if (!h.success)
|
|
4165
|
+
throw new V([s(d, h.error)]);
|
|
4166
|
+
return h.data;
|
|
4167
4167
|
});
|
|
4168
4168
|
}
|
|
4169
4169
|
}
|
|
@@ -4176,7 +4176,7 @@ class Oe extends O {
|
|
|
4176
4176
|
args(...e) {
|
|
4177
4177
|
return new Oe({
|
|
4178
4178
|
...this._def,
|
|
4179
|
-
args: X.create(e).rest(
|
|
4179
|
+
args: X.create(e).rest(pe.create())
|
|
4180
4180
|
});
|
|
4181
4181
|
}
|
|
4182
4182
|
returns(e) {
|
|
@@ -4193,14 +4193,14 @@ class Oe extends O {
|
|
|
4193
4193
|
}
|
|
4194
4194
|
static create(e, t, n) {
|
|
4195
4195
|
return new Oe({
|
|
4196
|
-
args: e || X.create([]).rest(
|
|
4197
|
-
returns: t ||
|
|
4196
|
+
args: e || X.create([]).rest(pe.create()),
|
|
4197
|
+
returns: t || pe.create(),
|
|
4198
4198
|
typeName: y.ZodFunction,
|
|
4199
4199
|
...w(n)
|
|
4200
4200
|
});
|
|
4201
4201
|
}
|
|
4202
4202
|
}
|
|
4203
|
-
class
|
|
4203
|
+
class Qe extends k {
|
|
4204
4204
|
get schema() {
|
|
4205
4205
|
return this._def.getter();
|
|
4206
4206
|
}
|
|
@@ -4209,12 +4209,12 @@ class Je extends O {
|
|
|
4209
4209
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
4210
4210
|
}
|
|
4211
4211
|
}
|
|
4212
|
-
|
|
4212
|
+
Qe.create = (r, e) => new Qe({
|
|
4213
4213
|
getter: r,
|
|
4214
4214
|
typeName: y.ZodLazy,
|
|
4215
4215
|
...w(e)
|
|
4216
4216
|
});
|
|
4217
|
-
class
|
|
4217
|
+
class Je extends k {
|
|
4218
4218
|
_parse(e) {
|
|
4219
4219
|
if (e.data !== this._def.value) {
|
|
4220
4220
|
const t = this._getOrReturnCtx(e);
|
|
@@ -4230,32 +4230,32 @@ class Ye extends O {
|
|
|
4230
4230
|
return this._def.value;
|
|
4231
4231
|
}
|
|
4232
4232
|
}
|
|
4233
|
-
|
|
4233
|
+
Je.create = (r, e) => new Je({
|
|
4234
4234
|
value: r,
|
|
4235
4235
|
typeName: y.ZodLiteral,
|
|
4236
4236
|
...w(e)
|
|
4237
4237
|
});
|
|
4238
|
-
function
|
|
4239
|
-
return new
|
|
4238
|
+
function vr(r, e) {
|
|
4239
|
+
return new ue({
|
|
4240
4240
|
values: r,
|
|
4241
4241
|
typeName: y.ZodEnum,
|
|
4242
4242
|
...w(e)
|
|
4243
4243
|
});
|
|
4244
4244
|
}
|
|
4245
|
-
class
|
|
4245
|
+
class ue extends k {
|
|
4246
4246
|
constructor() {
|
|
4247
|
-
super(...arguments),
|
|
4247
|
+
super(...arguments), De.set(this, void 0);
|
|
4248
4248
|
}
|
|
4249
4249
|
_parse(e) {
|
|
4250
4250
|
if (typeof e.data != "string") {
|
|
4251
4251
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
4252
4252
|
return m(t, {
|
|
4253
|
-
expected:
|
|
4253
|
+
expected: R.joinValues(n),
|
|
4254
4254
|
received: t.parsedType,
|
|
4255
4255
|
code: l.invalid_type
|
|
4256
4256
|
}), _;
|
|
4257
4257
|
}
|
|
4258
|
-
if (
|
|
4258
|
+
if (vt(this, De) || fr(this, De, new Set(this._def.values)), !vt(this, De).has(e.data)) {
|
|
4259
4259
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
4260
4260
|
return m(t, {
|
|
4261
4261
|
received: t.data,
|
|
@@ -4263,7 +4263,7 @@ class ce extends O {
|
|
|
4263
4263
|
options: n
|
|
4264
4264
|
}), _;
|
|
4265
4265
|
}
|
|
4266
|
-
return
|
|
4266
|
+
return L(e.data);
|
|
4267
4267
|
}
|
|
4268
4268
|
get options() {
|
|
4269
4269
|
return this._def.values;
|
|
@@ -4287,55 +4287,55 @@ class ce extends O {
|
|
|
4287
4287
|
return e;
|
|
4288
4288
|
}
|
|
4289
4289
|
extract(e, t = this._def) {
|
|
4290
|
-
return
|
|
4290
|
+
return ue.create(e, {
|
|
4291
4291
|
...this._def,
|
|
4292
4292
|
...t
|
|
4293
4293
|
});
|
|
4294
4294
|
}
|
|
4295
4295
|
exclude(e, t = this._def) {
|
|
4296
|
-
return
|
|
4296
|
+
return ue.create(this.options.filter((n) => !e.includes(n)), {
|
|
4297
4297
|
...this._def,
|
|
4298
4298
|
...t
|
|
4299
4299
|
});
|
|
4300
4300
|
}
|
|
4301
4301
|
}
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
class Xe extends
|
|
4302
|
+
De = /* @__PURE__ */ new WeakMap();
|
|
4303
|
+
ue.create = vr;
|
|
4304
|
+
class Xe extends k {
|
|
4305
4305
|
constructor() {
|
|
4306
|
-
super(...arguments),
|
|
4306
|
+
super(...arguments), Me.set(this, void 0);
|
|
4307
4307
|
}
|
|
4308
4308
|
_parse(e) {
|
|
4309
|
-
const t =
|
|
4309
|
+
const t = R.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
4310
4310
|
if (n.parsedType !== g.string && n.parsedType !== g.number) {
|
|
4311
|
-
const s =
|
|
4311
|
+
const s = R.objectValues(t);
|
|
4312
4312
|
return m(n, {
|
|
4313
|
-
expected:
|
|
4313
|
+
expected: R.joinValues(s),
|
|
4314
4314
|
received: n.parsedType,
|
|
4315
4315
|
code: l.invalid_type
|
|
4316
4316
|
}), _;
|
|
4317
4317
|
}
|
|
4318
|
-
if (
|
|
4319
|
-
const s =
|
|
4318
|
+
if (vt(this, Me) || fr(this, Me, new Set(R.getValidEnumValues(this._def.values))), !vt(this, Me).has(e.data)) {
|
|
4319
|
+
const s = R.objectValues(t);
|
|
4320
4320
|
return m(n, {
|
|
4321
4321
|
received: n.data,
|
|
4322
4322
|
code: l.invalid_enum_value,
|
|
4323
4323
|
options: s
|
|
4324
4324
|
}), _;
|
|
4325
4325
|
}
|
|
4326
|
-
return
|
|
4326
|
+
return L(e.data);
|
|
4327
4327
|
}
|
|
4328
4328
|
get enum() {
|
|
4329
4329
|
return this._def.values;
|
|
4330
4330
|
}
|
|
4331
4331
|
}
|
|
4332
|
-
|
|
4332
|
+
Me = /* @__PURE__ */ new WeakMap();
|
|
4333
4333
|
Xe.create = (r, e) => new Xe({
|
|
4334
4334
|
values: r,
|
|
4335
4335
|
typeName: y.ZodNativeEnum,
|
|
4336
4336
|
...w(e)
|
|
4337
4337
|
});
|
|
4338
|
-
class
|
|
4338
|
+
class Ce extends k {
|
|
4339
4339
|
unwrap() {
|
|
4340
4340
|
return this._def.type;
|
|
4341
4341
|
}
|
|
@@ -4348,18 +4348,18 @@ class Ie extends O {
|
|
|
4348
4348
|
received: t.parsedType
|
|
4349
4349
|
}), _;
|
|
4350
4350
|
const n = t.parsedType === g.promise ? t.data : Promise.resolve(t.data);
|
|
4351
|
-
return
|
|
4351
|
+
return L(n.then((s) => this._def.type.parseAsync(s, {
|
|
4352
4352
|
path: t.path,
|
|
4353
4353
|
errorMap: t.common.contextualErrorMap
|
|
4354
4354
|
})));
|
|
4355
4355
|
}
|
|
4356
4356
|
}
|
|
4357
|
-
|
|
4357
|
+
Ce.create = (r, e) => new Ce({
|
|
4358
4358
|
type: r,
|
|
4359
4359
|
typeName: y.ZodPromise,
|
|
4360
4360
|
...w(e)
|
|
4361
4361
|
});
|
|
4362
|
-
class
|
|
4362
|
+
class G extends k {
|
|
4363
4363
|
innerType() {
|
|
4364
4364
|
return this._def.schema;
|
|
4365
4365
|
}
|
|
@@ -4386,7 +4386,7 @@ class F extends O {
|
|
|
4386
4386
|
path: n.path,
|
|
4387
4387
|
parent: n
|
|
4388
4388
|
});
|
|
4389
|
-
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ?
|
|
4389
|
+
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ? xe(c.value) : c;
|
|
4390
4390
|
});
|
|
4391
4391
|
{
|
|
4392
4392
|
if (t.value === "aborted")
|
|
@@ -4396,7 +4396,7 @@ class F extends O {
|
|
|
4396
4396
|
path: n.path,
|
|
4397
4397
|
parent: n
|
|
4398
4398
|
});
|
|
4399
|
-
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ?
|
|
4399
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? xe(o.value) : o;
|
|
4400
4400
|
}
|
|
4401
4401
|
}
|
|
4402
4402
|
if (s.type === "refinement") {
|
|
@@ -4425,56 +4425,56 @@ class F extends O {
|
|
|
4425
4425
|
path: n.path,
|
|
4426
4426
|
parent: n
|
|
4427
4427
|
});
|
|
4428
|
-
if (!
|
|
4428
|
+
if (!He(i))
|
|
4429
4429
|
return i;
|
|
4430
4430
|
const o = s.transform(i.value, a);
|
|
4431
4431
|
if (o instanceof Promise)
|
|
4432
4432
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4433
4433
|
return { status: t.value, value: o };
|
|
4434
4434
|
} else
|
|
4435
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) =>
|
|
4436
|
-
|
|
4435
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => He(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
4436
|
+
R.assertNever(s);
|
|
4437
4437
|
}
|
|
4438
4438
|
}
|
|
4439
|
-
|
|
4439
|
+
G.create = (r, e, t) => new G({
|
|
4440
4440
|
schema: r,
|
|
4441
4441
|
typeName: y.ZodEffects,
|
|
4442
4442
|
effect: e,
|
|
4443
4443
|
...w(t)
|
|
4444
4444
|
});
|
|
4445
|
-
|
|
4445
|
+
G.createWithPreprocess = (r, e, t) => new G({
|
|
4446
4446
|
schema: e,
|
|
4447
4447
|
effect: { type: "preprocess", transform: r },
|
|
4448
4448
|
typeName: y.ZodEffects,
|
|
4449
4449
|
...w(t)
|
|
4450
4450
|
});
|
|
4451
|
-
class
|
|
4451
|
+
class Q extends k {
|
|
4452
4452
|
_parse(e) {
|
|
4453
|
-
return this._getType(e) === g.undefined ?
|
|
4453
|
+
return this._getType(e) === g.undefined ? L(void 0) : this._def.innerType._parse(e);
|
|
4454
4454
|
}
|
|
4455
4455
|
unwrap() {
|
|
4456
4456
|
return this._def.innerType;
|
|
4457
4457
|
}
|
|
4458
4458
|
}
|
|
4459
|
-
|
|
4459
|
+
Q.create = (r, e) => new Q({
|
|
4460
4460
|
innerType: r,
|
|
4461
4461
|
typeName: y.ZodOptional,
|
|
4462
4462
|
...w(e)
|
|
4463
4463
|
});
|
|
4464
|
-
class
|
|
4464
|
+
class de extends k {
|
|
4465
4465
|
_parse(e) {
|
|
4466
|
-
return this._getType(e) === g.null ?
|
|
4466
|
+
return this._getType(e) === g.null ? L(null) : this._def.innerType._parse(e);
|
|
4467
4467
|
}
|
|
4468
4468
|
unwrap() {
|
|
4469
4469
|
return this._def.innerType;
|
|
4470
4470
|
}
|
|
4471
4471
|
}
|
|
4472
|
-
|
|
4472
|
+
de.create = (r, e) => new de({
|
|
4473
4473
|
innerType: r,
|
|
4474
4474
|
typeName: y.ZodNullable,
|
|
4475
4475
|
...w(e)
|
|
4476
4476
|
});
|
|
4477
|
-
class
|
|
4477
|
+
class ze extends k {
|
|
4478
4478
|
_parse(e) {
|
|
4479
4479
|
const { ctx: t } = this._processInputParams(e);
|
|
4480
4480
|
let n = t.data;
|
|
@@ -4488,13 +4488,13 @@ class Qe extends O {
|
|
|
4488
4488
|
return this._def.innerType;
|
|
4489
4489
|
}
|
|
4490
4490
|
}
|
|
4491
|
-
|
|
4491
|
+
ze.create = (r, e) => new ze({
|
|
4492
4492
|
innerType: r,
|
|
4493
4493
|
typeName: y.ZodDefault,
|
|
4494
4494
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
4495
4495
|
...w(e)
|
|
4496
4496
|
});
|
|
4497
|
-
class
|
|
4497
|
+
class et extends k {
|
|
4498
4498
|
_parse(e) {
|
|
4499
4499
|
const { ctx: t } = this._processInputParams(e), n = {
|
|
4500
4500
|
...t,
|
|
@@ -4509,11 +4509,11 @@ class ze extends O {
|
|
|
4509
4509
|
...n
|
|
4510
4510
|
}
|
|
4511
4511
|
});
|
|
4512
|
-
return
|
|
4512
|
+
return qe(s) ? s.then((a) => ({
|
|
4513
4513
|
status: "valid",
|
|
4514
4514
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
4515
4515
|
get error() {
|
|
4516
|
-
return new
|
|
4516
|
+
return new V(n.common.issues);
|
|
4517
4517
|
},
|
|
4518
4518
|
input: n.data
|
|
4519
4519
|
})
|
|
@@ -4521,7 +4521,7 @@ class ze extends O {
|
|
|
4521
4521
|
status: "valid",
|
|
4522
4522
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
4523
4523
|
get error() {
|
|
4524
|
-
return new
|
|
4524
|
+
return new V(n.common.issues);
|
|
4525
4525
|
},
|
|
4526
4526
|
input: n.data
|
|
4527
4527
|
})
|
|
@@ -4531,13 +4531,13 @@ class ze extends O {
|
|
|
4531
4531
|
return this._def.innerType;
|
|
4532
4532
|
}
|
|
4533
4533
|
}
|
|
4534
|
-
|
|
4534
|
+
et.create = (r, e) => new et({
|
|
4535
4535
|
innerType: r,
|
|
4536
4536
|
typeName: y.ZodCatch,
|
|
4537
4537
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
4538
4538
|
...w(e)
|
|
4539
4539
|
});
|
|
4540
|
-
class
|
|
4540
|
+
class wt extends k {
|
|
4541
4541
|
_parse(e) {
|
|
4542
4542
|
if (this._getType(e) !== g.nan) {
|
|
4543
4543
|
const n = this._getOrReturnCtx(e);
|
|
@@ -4550,12 +4550,12 @@ class bt extends O {
|
|
|
4550
4550
|
return { status: "valid", value: e.data };
|
|
4551
4551
|
}
|
|
4552
4552
|
}
|
|
4553
|
-
|
|
4553
|
+
wt.create = (r) => new wt({
|
|
4554
4554
|
typeName: y.ZodNaN,
|
|
4555
4555
|
...w(r)
|
|
4556
4556
|
});
|
|
4557
|
-
const
|
|
4558
|
-
class
|
|
4557
|
+
const Qn = Symbol("zod_brand");
|
|
4558
|
+
class $t extends k {
|
|
4559
4559
|
_parse(e) {
|
|
4560
4560
|
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
4561
4561
|
return this._def.type._parse({
|
|
@@ -4568,7 +4568,7 @@ class Dt extends O {
|
|
|
4568
4568
|
return this._def.type;
|
|
4569
4569
|
}
|
|
4570
4570
|
}
|
|
4571
|
-
class
|
|
4571
|
+
class ot extends k {
|
|
4572
4572
|
_parse(e) {
|
|
4573
4573
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
4574
4574
|
if (n.common.async)
|
|
@@ -4578,7 +4578,7 @@ class it extends O {
|
|
|
4578
4578
|
path: n.path,
|
|
4579
4579
|
parent: n
|
|
4580
4580
|
});
|
|
4581
|
-
return a.status === "aborted" ? _ : a.status === "dirty" ? (t.dirty(),
|
|
4581
|
+
return a.status === "aborted" ? _ : a.status === "dirty" ? (t.dirty(), xe(a.value)) : this._def.out._parseAsync({
|
|
4582
4582
|
data: a.value,
|
|
4583
4583
|
path: n.path,
|
|
4584
4584
|
parent: n
|
|
@@ -4601,171 +4601,171 @@ class it extends O {
|
|
|
4601
4601
|
}
|
|
4602
4602
|
}
|
|
4603
4603
|
static create(e, t) {
|
|
4604
|
-
return new
|
|
4604
|
+
return new ot({
|
|
4605
4605
|
in: e,
|
|
4606
4606
|
out: t,
|
|
4607
4607
|
typeName: y.ZodPipeline
|
|
4608
4608
|
});
|
|
4609
4609
|
}
|
|
4610
4610
|
}
|
|
4611
|
-
class
|
|
4611
|
+
class tt extends k {
|
|
4612
4612
|
_parse(e) {
|
|
4613
|
-
const t = this._def.innerType._parse(e), n = (s) => (
|
|
4614
|
-
return
|
|
4613
|
+
const t = this._def.innerType._parse(e), n = (s) => (He(s) && (s.value = Object.freeze(s.value)), s);
|
|
4614
|
+
return qe(t) ? t.then((s) => n(s)) : n(t);
|
|
4615
4615
|
}
|
|
4616
4616
|
unwrap() {
|
|
4617
4617
|
return this._def.innerType;
|
|
4618
4618
|
}
|
|
4619
4619
|
}
|
|
4620
|
-
|
|
4620
|
+
tt.create = (r, e) => new tt({
|
|
4621
4621
|
innerType: r,
|
|
4622
4622
|
typeName: y.ZodReadonly,
|
|
4623
4623
|
...w(e)
|
|
4624
4624
|
});
|
|
4625
|
-
function
|
|
4626
|
-
return r ?
|
|
4625
|
+
function yr(r, e = {}, t) {
|
|
4626
|
+
return r ? Se.create().superRefine((n, s) => {
|
|
4627
4627
|
var a, i;
|
|
4628
4628
|
if (!r(n)) {
|
|
4629
4629
|
const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, c = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, u = typeof o == "string" ? { message: o } : o;
|
|
4630
4630
|
s.addIssue({ code: "custom", ...u, fatal: c });
|
|
4631
4631
|
}
|
|
4632
|
-
}) :
|
|
4632
|
+
}) : Se.create();
|
|
4633
4633
|
}
|
|
4634
|
-
const
|
|
4635
|
-
object:
|
|
4634
|
+
const Jn = {
|
|
4635
|
+
object: P.lazycreate
|
|
4636
4636
|
};
|
|
4637
4637
|
var y;
|
|
4638
4638
|
(function(r) {
|
|
4639
4639
|
r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
|
|
4640
4640
|
})(y || (y = {}));
|
|
4641
|
-
const
|
|
4641
|
+
const Xn = (r, e = {
|
|
4642
4642
|
message: `Input not instance of ${r.name}`
|
|
4643
|
-
}) =>
|
|
4643
|
+
}) => yr((t) => t instanceof r, e), _r = B.create, br = oe.create, zn = wt.create, es = ce.create, wr = We.create, ts = me.create, rs = yt.create, ns = Be.create, ss = Fe.create, as = Se.create, is = pe.create, os = ne.create, cs = _t.create, us = F.create, ds = P.create, ls = P.strictCreate, hs = Ge.create, fs = kt.create, ps = Ke.create, ms = X.create, gs = Ye.create, vs = bt.create, ys = ge.create, _s = Oe.create, bs = Qe.create, ws = Je.create, xs = ue.create, ks = Xe.create, Os = Ce.create, Ft = G.create, Ts = Q.create, js = de.create, Rs = G.createWithPreprocess, Es = ot.create, Ss = () => _r().optional(), Cs = () => br().optional(), Is = () => wr().optional(), Ps = {
|
|
4644
4644
|
string: (r) => B.create({ ...r, coerce: !0 }),
|
|
4645
|
-
number: (r) =>
|
|
4646
|
-
boolean: (r) =>
|
|
4645
|
+
number: (r) => oe.create({ ...r, coerce: !0 }),
|
|
4646
|
+
boolean: (r) => We.create({
|
|
4647
4647
|
...r,
|
|
4648
4648
|
coerce: !0
|
|
4649
4649
|
}),
|
|
4650
|
-
bigint: (r) =>
|
|
4651
|
-
date: (r) =>
|
|
4652
|
-
},
|
|
4653
|
-
var
|
|
4650
|
+
bigint: (r) => ce.create({ ...r, coerce: !0 }),
|
|
4651
|
+
date: (r) => me.create({ ...r, coerce: !0 })
|
|
4652
|
+
}, Zs = _;
|
|
4653
|
+
var O = /* @__PURE__ */ Object.freeze({
|
|
4654
4654
|
__proto__: null,
|
|
4655
|
-
defaultErrorMap:
|
|
4656
|
-
setErrorMap:
|
|
4657
|
-
getErrorMap:
|
|
4658
|
-
makeIssue:
|
|
4659
|
-
EMPTY_PATH:
|
|
4655
|
+
defaultErrorMap: Ee,
|
|
4656
|
+
setErrorMap: Zn,
|
|
4657
|
+
getErrorMap: mt,
|
|
4658
|
+
makeIssue: gt,
|
|
4659
|
+
EMPTY_PATH: An,
|
|
4660
4660
|
addIssueToContext: m,
|
|
4661
|
-
ParseStatus:
|
|
4661
|
+
ParseStatus: $,
|
|
4662
4662
|
INVALID: _,
|
|
4663
|
-
DIRTY:
|
|
4664
|
-
OK:
|
|
4663
|
+
DIRTY: xe,
|
|
4664
|
+
OK: L,
|
|
4665
4665
|
isAborted: Zt,
|
|
4666
|
-
isDirty:
|
|
4667
|
-
isValid:
|
|
4668
|
-
isAsync:
|
|
4666
|
+
isDirty: At,
|
|
4667
|
+
isValid: He,
|
|
4668
|
+
isAsync: qe,
|
|
4669
4669
|
get util() {
|
|
4670
|
-
return
|
|
4670
|
+
return R;
|
|
4671
4671
|
},
|
|
4672
4672
|
get objectUtil() {
|
|
4673
|
-
return
|
|
4673
|
+
return Pt;
|
|
4674
4674
|
},
|
|
4675
4675
|
ZodParsedType: g,
|
|
4676
|
-
getParsedType:
|
|
4677
|
-
ZodType:
|
|
4678
|
-
datetimeRegex:
|
|
4676
|
+
getParsedType: ae,
|
|
4677
|
+
ZodType: k,
|
|
4678
|
+
datetimeRegex: gr,
|
|
4679
4679
|
ZodString: B,
|
|
4680
|
-
ZodNumber:
|
|
4681
|
-
ZodBigInt:
|
|
4682
|
-
ZodBoolean:
|
|
4683
|
-
ZodDate:
|
|
4684
|
-
ZodSymbol:
|
|
4680
|
+
ZodNumber: oe,
|
|
4681
|
+
ZodBigInt: ce,
|
|
4682
|
+
ZodBoolean: We,
|
|
4683
|
+
ZodDate: me,
|
|
4684
|
+
ZodSymbol: yt,
|
|
4685
4685
|
ZodUndefined: Be,
|
|
4686
|
-
ZodNull:
|
|
4687
|
-
ZodAny:
|
|
4688
|
-
ZodUnknown:
|
|
4689
|
-
ZodNever:
|
|
4690
|
-
ZodVoid:
|
|
4691
|
-
ZodArray:
|
|
4692
|
-
ZodObject:
|
|
4693
|
-
ZodUnion:
|
|
4694
|
-
ZodDiscriminatedUnion:
|
|
4695
|
-
ZodIntersection:
|
|
4686
|
+
ZodNull: Fe,
|
|
4687
|
+
ZodAny: Se,
|
|
4688
|
+
ZodUnknown: pe,
|
|
4689
|
+
ZodNever: ne,
|
|
4690
|
+
ZodVoid: _t,
|
|
4691
|
+
ZodArray: F,
|
|
4692
|
+
ZodObject: P,
|
|
4693
|
+
ZodUnion: Ge,
|
|
4694
|
+
ZodDiscriminatedUnion: kt,
|
|
4695
|
+
ZodIntersection: Ke,
|
|
4696
4696
|
ZodTuple: X,
|
|
4697
|
-
ZodRecord:
|
|
4698
|
-
ZodMap:
|
|
4699
|
-
ZodSet:
|
|
4697
|
+
ZodRecord: Ye,
|
|
4698
|
+
ZodMap: bt,
|
|
4699
|
+
ZodSet: ge,
|
|
4700
4700
|
ZodFunction: Oe,
|
|
4701
|
-
ZodLazy:
|
|
4702
|
-
ZodLiteral:
|
|
4703
|
-
ZodEnum:
|
|
4701
|
+
ZodLazy: Qe,
|
|
4702
|
+
ZodLiteral: Je,
|
|
4703
|
+
ZodEnum: ue,
|
|
4704
4704
|
ZodNativeEnum: Xe,
|
|
4705
|
-
ZodPromise:
|
|
4706
|
-
ZodEffects:
|
|
4707
|
-
ZodTransformer:
|
|
4708
|
-
ZodOptional:
|
|
4709
|
-
ZodNullable:
|
|
4710
|
-
ZodDefault:
|
|
4711
|
-
ZodCatch:
|
|
4712
|
-
ZodNaN:
|
|
4713
|
-
BRAND:
|
|
4714
|
-
ZodBranded:
|
|
4715
|
-
ZodPipeline:
|
|
4716
|
-
ZodReadonly:
|
|
4717
|
-
custom:
|
|
4718
|
-
Schema:
|
|
4719
|
-
ZodSchema:
|
|
4720
|
-
late:
|
|
4705
|
+
ZodPromise: Ce,
|
|
4706
|
+
ZodEffects: G,
|
|
4707
|
+
ZodTransformer: G,
|
|
4708
|
+
ZodOptional: Q,
|
|
4709
|
+
ZodNullable: de,
|
|
4710
|
+
ZodDefault: ze,
|
|
4711
|
+
ZodCatch: et,
|
|
4712
|
+
ZodNaN: wt,
|
|
4713
|
+
BRAND: Qn,
|
|
4714
|
+
ZodBranded: $t,
|
|
4715
|
+
ZodPipeline: ot,
|
|
4716
|
+
ZodReadonly: tt,
|
|
4717
|
+
custom: yr,
|
|
4718
|
+
Schema: k,
|
|
4719
|
+
ZodSchema: k,
|
|
4720
|
+
late: Jn,
|
|
4721
4721
|
get ZodFirstPartyTypeKind() {
|
|
4722
4722
|
return y;
|
|
4723
4723
|
},
|
|
4724
|
-
coerce:
|
|
4725
|
-
any:
|
|
4726
|
-
array:
|
|
4727
|
-
bigint:
|
|
4728
|
-
boolean:
|
|
4729
|
-
date:
|
|
4730
|
-
discriminatedUnion:
|
|
4731
|
-
effect:
|
|
4732
|
-
enum:
|
|
4733
|
-
function:
|
|
4734
|
-
instanceof:
|
|
4735
|
-
intersection:
|
|
4736
|
-
lazy:
|
|
4737
|
-
literal:
|
|
4738
|
-
map:
|
|
4739
|
-
nan:
|
|
4740
|
-
nativeEnum:
|
|
4741
|
-
never:
|
|
4742
|
-
null:
|
|
4743
|
-
nullable:
|
|
4744
|
-
number:
|
|
4745
|
-
object:
|
|
4746
|
-
oboolean:
|
|
4747
|
-
onumber:
|
|
4748
|
-
optional:
|
|
4749
|
-
ostring:
|
|
4750
|
-
pipeline:
|
|
4751
|
-
preprocess:
|
|
4752
|
-
promise:
|
|
4753
|
-
record:
|
|
4754
|
-
set:
|
|
4755
|
-
strictObject:
|
|
4756
|
-
string:
|
|
4757
|
-
symbol:
|
|
4758
|
-
transformer:
|
|
4759
|
-
tuple:
|
|
4760
|
-
undefined:
|
|
4761
|
-
union:
|
|
4762
|
-
unknown:
|
|
4763
|
-
void:
|
|
4764
|
-
NEVER:
|
|
4724
|
+
coerce: Ps,
|
|
4725
|
+
any: as,
|
|
4726
|
+
array: us,
|
|
4727
|
+
bigint: es,
|
|
4728
|
+
boolean: wr,
|
|
4729
|
+
date: ts,
|
|
4730
|
+
discriminatedUnion: fs,
|
|
4731
|
+
effect: Ft,
|
|
4732
|
+
enum: xs,
|
|
4733
|
+
function: _s,
|
|
4734
|
+
instanceof: Xn,
|
|
4735
|
+
intersection: ps,
|
|
4736
|
+
lazy: bs,
|
|
4737
|
+
literal: ws,
|
|
4738
|
+
map: vs,
|
|
4739
|
+
nan: zn,
|
|
4740
|
+
nativeEnum: ks,
|
|
4741
|
+
never: os,
|
|
4742
|
+
null: ss,
|
|
4743
|
+
nullable: js,
|
|
4744
|
+
number: br,
|
|
4745
|
+
object: ds,
|
|
4746
|
+
oboolean: Is,
|
|
4747
|
+
onumber: Cs,
|
|
4748
|
+
optional: Ts,
|
|
4749
|
+
ostring: Ss,
|
|
4750
|
+
pipeline: Es,
|
|
4751
|
+
preprocess: Rs,
|
|
4752
|
+
promise: Os,
|
|
4753
|
+
record: gs,
|
|
4754
|
+
set: ys,
|
|
4755
|
+
strictObject: ls,
|
|
4756
|
+
string: _r,
|
|
4757
|
+
symbol: rs,
|
|
4758
|
+
transformer: Ft,
|
|
4759
|
+
tuple: ms,
|
|
4760
|
+
undefined: ns,
|
|
4761
|
+
union: hs,
|
|
4762
|
+
unknown: is,
|
|
4763
|
+
void: cs,
|
|
4764
|
+
NEVER: Zs,
|
|
4765
4765
|
ZodIssueCode: l,
|
|
4766
|
-
quotelessJson:
|
|
4767
|
-
ZodError:
|
|
4768
|
-
}),
|
|
4766
|
+
quotelessJson: Pn,
|
|
4767
|
+
ZodError: V
|
|
4768
|
+
}), Dt = class Mt extends In {
|
|
4769
4769
|
constructor(t) {
|
|
4770
4770
|
super(t);
|
|
4771
4771
|
p(this, "openAPIRegistry");
|
|
@@ -4802,39 +4802,39 @@ var Ps = /* @__PURE__ */ Object.freeze({
|
|
|
4802
4802
|
*)
|
|
4803
4803
|
*/
|
|
4804
4804
|
p(this, "openapi", ({ middleware: t, ...n }, s, a = this.defaultHook) => {
|
|
4805
|
-
var u, d,
|
|
4805
|
+
var u, d, h, T, S, E;
|
|
4806
4806
|
this.openAPIRegistry.registerPath(n);
|
|
4807
4807
|
const i = [];
|
|
4808
4808
|
if ((u = n.request) != null && u.query) {
|
|
4809
|
-
const b =
|
|
4809
|
+
const b = _e("query", n.request.query, a);
|
|
4810
4810
|
i.push(b);
|
|
4811
4811
|
}
|
|
4812
4812
|
if ((d = n.request) != null && d.params) {
|
|
4813
|
-
const b =
|
|
4813
|
+
const b = _e("param", n.request.params, a);
|
|
4814
4814
|
i.push(b);
|
|
4815
4815
|
}
|
|
4816
|
-
if ((
|
|
4817
|
-
const b =
|
|
4816
|
+
if ((h = n.request) != null && h.headers) {
|
|
4817
|
+
const b = _e("header", n.request.headers, a);
|
|
4818
4818
|
i.push(b);
|
|
4819
4819
|
}
|
|
4820
|
-
if ((
|
|
4821
|
-
const b =
|
|
4820
|
+
if ((T = n.request) != null && T.cookies) {
|
|
4821
|
+
const b = _e("cookie", n.request.cookies, a);
|
|
4822
4822
|
i.push(b);
|
|
4823
4823
|
}
|
|
4824
|
-
const o = (
|
|
4824
|
+
const o = (E = (S = n.request) == null ? void 0 : S.body) == null ? void 0 : E.content;
|
|
4825
4825
|
if (o)
|
|
4826
4826
|
for (const b of Object.keys(o)) {
|
|
4827
4827
|
if (!o[b])
|
|
4828
4828
|
continue;
|
|
4829
|
-
const
|
|
4830
|
-
if (
|
|
4829
|
+
const A = o[b].schema;
|
|
4830
|
+
if (A instanceof k) {
|
|
4831
4831
|
if (b.startsWith("application/json")) {
|
|
4832
|
-
const
|
|
4833
|
-
i.push(
|
|
4832
|
+
const M = _e("json", A, a);
|
|
4833
|
+
i.push(M);
|
|
4834
4834
|
}
|
|
4835
4835
|
if (b.startsWith("multipart/form-data") || b.startsWith("application/x-www-form-urlencoded")) {
|
|
4836
|
-
const
|
|
4837
|
-
i.push(
|
|
4836
|
+
const M = _e("form", A, a);
|
|
4837
|
+
i.push(M);
|
|
4838
4838
|
}
|
|
4839
4839
|
}
|
|
4840
4840
|
}
|
|
@@ -4847,8 +4847,8 @@ var Ps = /* @__PURE__ */ Object.freeze({
|
|
|
4847
4847
|
s
|
|
4848
4848
|
), this;
|
|
4849
4849
|
});
|
|
4850
|
-
p(this, "getOpenAPIDocument", (t) => new
|
|
4851
|
-
p(this, "getOpenAPI31Document", (t) => new
|
|
4850
|
+
p(this, "getOpenAPIDocument", (t) => new Gr(this.openAPIRegistry.definitions).generateDocument(t));
|
|
4851
|
+
p(this, "getOpenAPI31Document", (t) => new Qr(this.openAPIRegistry.definitions).generateDocument(t));
|
|
4852
4852
|
p(this, "doc", (t, n) => this.get(t, (s) => {
|
|
4853
4853
|
const a = typeof n == "function" ? n(s) : n;
|
|
4854
4854
|
try {
|
|
@@ -4867,23 +4867,23 @@ var Ps = /* @__PURE__ */ Object.freeze({
|
|
|
4867
4867
|
return s.json(i, 500);
|
|
4868
4868
|
}
|
|
4869
4869
|
}));
|
|
4870
|
-
this.openAPIRegistry = new
|
|
4870
|
+
this.openAPIRegistry = new Sr(), this.defaultHook = t == null ? void 0 : t.defaultHook;
|
|
4871
4871
|
}
|
|
4872
4872
|
route(t, n) {
|
|
4873
4873
|
const s = t.replaceAll(/:([^\/]+)/g, "{$1}");
|
|
4874
|
-
return super.route(t, n), n instanceof
|
|
4874
|
+
return super.route(t, n), n instanceof Mt ? (n.openAPIRegistry.definitions.forEach((a) => {
|
|
4875
4875
|
switch (a.type) {
|
|
4876
4876
|
case "component":
|
|
4877
4877
|
return this.openAPIRegistry.registerComponent(a.componentType, a.name, a.component);
|
|
4878
4878
|
case "route":
|
|
4879
4879
|
return this.openAPIRegistry.registerPath({
|
|
4880
4880
|
...a.route,
|
|
4881
|
-
path:
|
|
4881
|
+
path: he(s, a.route.path)
|
|
4882
4882
|
});
|
|
4883
4883
|
case "webhook":
|
|
4884
4884
|
return this.openAPIRegistry.registerWebhook({
|
|
4885
4885
|
...a.webhook,
|
|
4886
|
-
path:
|
|
4886
|
+
path: he(s, a.webhook.path)
|
|
4887
4887
|
});
|
|
4888
4888
|
case "schema":
|
|
4889
4889
|
return this.openAPIRegistry.register(a.schema._def.openapi._internal.refId, a.schema);
|
|
@@ -4900,13 +4900,195 @@ var Ps = /* @__PURE__ */ Object.freeze({
|
|
|
4900
4900
|
}), this) : this;
|
|
4901
4901
|
}
|
|
4902
4902
|
basePath(t) {
|
|
4903
|
-
return new
|
|
4903
|
+
return new Mt({ ...super.basePath(t), defaultHook: this.defaultHook });
|
|
4904
4904
|
}
|
|
4905
|
+
}, Gt = (r) => {
|
|
4906
|
+
const e = {
|
|
4907
|
+
...r,
|
|
4908
|
+
getRoutingPath() {
|
|
4909
|
+
return r.path.replaceAll(/\/{(.+?)}/g, "/:$1");
|
|
4910
|
+
}
|
|
4911
|
+
};
|
|
4912
|
+
return Object.defineProperty(e, "getRoutingPath", { enumerable: !1 });
|
|
4905
4913
|
};
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4914
|
+
Tr(O);
|
|
4915
|
+
const As = O.object({
|
|
4916
|
+
alg: O.string(),
|
|
4917
|
+
e: O.string(),
|
|
4918
|
+
kid: O.string(),
|
|
4919
|
+
kty: O.string(),
|
|
4920
|
+
n: O.string(),
|
|
4921
|
+
use: O.string().optional()
|
|
4922
|
+
}), Ns = O.object({
|
|
4923
|
+
keys: O.array(As)
|
|
4924
|
+
}), Kt = O.object({
|
|
4925
|
+
issuer: O.string(),
|
|
4926
|
+
authorization_endpoint: O.string(),
|
|
4927
|
+
token_endpoint: O.string(),
|
|
4928
|
+
device_authorization_endpoint: O.string(),
|
|
4929
|
+
userinfo_endpoint: O.string(),
|
|
4930
|
+
mfa_challenge_endpoint: O.string(),
|
|
4931
|
+
jwks_uri: O.string(),
|
|
4932
|
+
registration_endpoint: O.string(),
|
|
4933
|
+
revocation_endpoint: O.string(),
|
|
4934
|
+
scopes_supported: O.array(O.string()),
|
|
4935
|
+
response_types_supported: O.array(O.string()),
|
|
4936
|
+
code_challenge_methods_supported: O.array(O.string()),
|
|
4937
|
+
response_modes_supported: O.array(O.string()),
|
|
4938
|
+
subject_types_supported: O.array(O.string()),
|
|
4939
|
+
id_token_signing_alg_values_supported: O.array(O.string()),
|
|
4940
|
+
token_endpoint_auth_methods_supported: O.array(O.string()),
|
|
4941
|
+
claims_supported: O.array(O.string()),
|
|
4942
|
+
request_uri_parameter_supported: O.boolean(),
|
|
4943
|
+
request_parameter_supported: O.boolean(),
|
|
4944
|
+
token_endpoint_auth_signing_alg_values_supported: O.array(O.string())
|
|
4945
|
+
}), Ds = new Dt().openapi(
|
|
4946
|
+
Gt({
|
|
4947
|
+
tags: ["jwks"],
|
|
4948
|
+
method: "get",
|
|
4949
|
+
path: "/jwks.json",
|
|
4950
|
+
request: {},
|
|
4951
|
+
responses: {
|
|
4952
|
+
200: {
|
|
4953
|
+
content: {
|
|
4954
|
+
"application/json": {
|
|
4955
|
+
schema: Ns
|
|
4956
|
+
}
|
|
4957
|
+
},
|
|
4958
|
+
description: "List of tenants"
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
}),
|
|
4962
|
+
async (r) => {
|
|
4963
|
+
const { env: e } = r, t = [
|
|
4964
|
+
{
|
|
4965
|
+
alg: "RS256",
|
|
4966
|
+
e: "AQAB",
|
|
4967
|
+
kid: "hZ42TWGWLdmyKfwGVA6c2",
|
|
4968
|
+
kty: "RSA",
|
|
4969
|
+
n: "nUd-mktFZQNfVwmXufxcVcvJo6Lkb-jDuymtfQunmEhWCctOccWx9e7LX7_9uN15ZnRS7XJInPMRs9KLYdZ0GCnE2HM_QbrEoHpdkCRgyTE-KzmoaEv_AOVGE_Kg0-0ct3r9Z7aJLDVAsxXl1C9y8Gr7ZYkq0c4DyZr9VT8nQiwZQERbfxXdXw-5RLj21S_Lm-LL-AjKvry_TDBLpfUFJV18SVsM07lY_V45TwykNewRdaGLspFIeGdG5j5eByV8ifzBqvzOSptSCsmOTtW-ceWUk0FPD7g_KKzjjbzenoB0TC8mBb_4vWZlHnuGIAs2YoTFglp9uNu7t_OVl3Svo6ZE6alzUnaNfZNeAi78KPHYQ4tDWPjpYNfGynsiD0nojkDSPCIak56jWNYjj614cPEBiv9MVQRiSbBxpiGhMoHlW_QCCPMcXygLAaRs_tUksqoH4QB80krifG2yHPgGDPjXK1_0cYzV80iOcQIeoceqhkSSc6YxzzgDrQcsV2k3bizRQSL83GWkpdHhTZn-Q_JzsW_bDY_f9fjigYbRnoDSgS7038VFIPc92StE41MdgvIQMomcyEE4lYK1uv1Mo6cnXbCZhm8tvddo7VKNorOB4nsiv8DGrWPlzQBca9VN4C1oE2mH-3WLFR7XEkBHWVouOdTWM2S3K9F10YtahkM"
|
|
4970
|
+
}
|
|
4971
|
+
];
|
|
4972
|
+
return r.json(
|
|
4973
|
+
{ keys: t },
|
|
4974
|
+
{
|
|
4975
|
+
headers: {
|
|
4976
|
+
"access-control-allow-origin": "*",
|
|
4977
|
+
"access-control-allow-method": "GET",
|
|
4978
|
+
"cache-control": `public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS * 2}, stale-if-error=86400`
|
|
4979
|
+
}
|
|
4980
|
+
}
|
|
4981
|
+
);
|
|
4982
|
+
}
|
|
4983
|
+
).openapi(
|
|
4984
|
+
Gt({
|
|
4985
|
+
tags: ["well known"],
|
|
4986
|
+
method: "get",
|
|
4987
|
+
path: "/openid-configuration",
|
|
4988
|
+
request: {},
|
|
4989
|
+
responses: {
|
|
4990
|
+
200: {
|
|
4991
|
+
content: {
|
|
4992
|
+
"application/json": {
|
|
4993
|
+
schema: Kt
|
|
4994
|
+
}
|
|
4995
|
+
},
|
|
4996
|
+
description: "List of tenants"
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4999
|
+
}),
|
|
5000
|
+
async (r) => {
|
|
5001
|
+
const { env: e } = r, { ISSUER: t } = e, n = Kt.parse({
|
|
5002
|
+
issuer: t,
|
|
5003
|
+
authorization_endpoint: `${t}authorize`,
|
|
5004
|
+
token_endpoint: `${t}oauth/token`,
|
|
5005
|
+
device_authorization_endpoint: `${t}oauth/device/code`,
|
|
5006
|
+
userinfo_endpoint: `${t}userinfo`,
|
|
5007
|
+
mfa_challenge_endpoint: `${t}mfa/challenge`,
|
|
5008
|
+
jwks_uri: `${t}.well-known/jwks.json`,
|
|
5009
|
+
registration_endpoint: `${t}oidc/register`,
|
|
5010
|
+
revocation_endpoint: `${t}oauth/revoke`,
|
|
5011
|
+
scopes_supported: [
|
|
5012
|
+
"openid",
|
|
5013
|
+
"profile",
|
|
5014
|
+
"offline_access",
|
|
5015
|
+
"name",
|
|
5016
|
+
"given_name",
|
|
5017
|
+
"family_name",
|
|
5018
|
+
"nickname",
|
|
5019
|
+
"email",
|
|
5020
|
+
"email_verified",
|
|
5021
|
+
"picture",
|
|
5022
|
+
"created_at",
|
|
5023
|
+
"identities",
|
|
5024
|
+
"phone",
|
|
5025
|
+
"address"
|
|
5026
|
+
],
|
|
5027
|
+
response_types_supported: [
|
|
5028
|
+
"code",
|
|
5029
|
+
"token",
|
|
5030
|
+
"id_token",
|
|
5031
|
+
"code token",
|
|
5032
|
+
"code id_token",
|
|
5033
|
+
"token id_token",
|
|
5034
|
+
"code token id_token"
|
|
5035
|
+
],
|
|
5036
|
+
code_challenge_methods_supported: ["S256", "plain"],
|
|
5037
|
+
response_modes_supported: ["query", "fragment", "form_post"],
|
|
5038
|
+
subject_types_supported: ["public"],
|
|
5039
|
+
id_token_signing_alg_values_supported: ["HS256", "RS256"],
|
|
5040
|
+
token_endpoint_auth_methods_supported: [
|
|
5041
|
+
"client_secret_basic",
|
|
5042
|
+
"client_secret_post",
|
|
5043
|
+
"private_key_jwt"
|
|
5044
|
+
],
|
|
5045
|
+
claims_supported: [
|
|
5046
|
+
"aud",
|
|
5047
|
+
"auth_time",
|
|
5048
|
+
"created_at",
|
|
5049
|
+
"email",
|
|
5050
|
+
"email_verified",
|
|
5051
|
+
"exp",
|
|
5052
|
+
"family_name",
|
|
5053
|
+
"given_name",
|
|
5054
|
+
"iat",
|
|
5055
|
+
"identities",
|
|
5056
|
+
"iss",
|
|
5057
|
+
"name",
|
|
5058
|
+
"nickname",
|
|
5059
|
+
"phone_number",
|
|
5060
|
+
"picture",
|
|
5061
|
+
"sub"
|
|
5062
|
+
],
|
|
5063
|
+
request_uri_parameter_supported: !1,
|
|
5064
|
+
request_parameter_supported: !1,
|
|
5065
|
+
token_endpoint_auth_signing_alg_values_supported: [
|
|
5066
|
+
"RS256",
|
|
5067
|
+
"RS384",
|
|
5068
|
+
"PS256"
|
|
5069
|
+
]
|
|
5070
|
+
});
|
|
5071
|
+
return r.json(n, {
|
|
5072
|
+
headers: {
|
|
5073
|
+
"access-control-allow-origin": "*",
|
|
5074
|
+
"access-control-allow-method": "GET",
|
|
5075
|
+
"cache-control": `public, max-age=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS}, stale-while-revalidate=${e.JWKS_CACHE_TIMEOUT_IN_SECONDS * 2}, stale-if-error=86400`
|
|
5076
|
+
}
|
|
5077
|
+
});
|
|
5078
|
+
}
|
|
5079
|
+
);
|
|
5080
|
+
function Vs() {
|
|
5081
|
+
const r = new Dt();
|
|
5082
|
+
r.get("/", (t) => t.text("Hello, authhero!"));
|
|
5083
|
+
const e = new Dt().route("/.well-known", Ds);
|
|
5084
|
+
return e.doc("/spec", {
|
|
5085
|
+
openapi: "3.0.0",
|
|
5086
|
+
info: {
|
|
5087
|
+
version: "1.0.0",
|
|
5088
|
+
title: "Oauth endpoints"
|
|
5089
|
+
}
|
|
5090
|
+
}), r.route("/", e), r;
|
|
4909
5091
|
}
|
|
4910
5092
|
export {
|
|
4911
|
-
|
|
5093
|
+
Vs as init
|
|
4912
5094
|
};
|