@visactor/vseed 0.0.17 → 0.0.18
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/dist/builder/builder/builder.d.ts +3 -67
- package/dist/builder/builder/builder.d.ts.map +1 -1
- package/dist/dataReshape/dataReshapeFor1D1M.d.ts.map +1 -1
- package/dist/dataReshape/dataReshapeFor2D1M.d.ts.map +1 -1
- package/dist/index.cjs +246 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +135 -129
- package/dist/index.js.map +1 -1
- package/dist/pipeline/spec/pipes/vchart/annotation/annotationHorizontalLine.d.ts.map +1 -1
- package/dist/pipeline/spec/pipes/vchart/annotation/annotationVerticalLine.d.ts.map +1 -1
- package/dist/pipeline/spec/pipes/vchart/init/pie.d.ts.map +1 -1
- package/dist/types/advancedVSeed.d.ts +2 -18
- package/dist/types/advancedVSeed.d.ts.map +1 -1
- package/dist/types/chartType/area/area.d.ts +414 -14
- package/dist/types/chartType/area/area.d.ts.map +1 -1
- package/dist/types/chartType/areaPercent/areaPercent.d.ts +414 -14
- package/dist/types/chartType/areaPercent/areaPercent.d.ts.map +1 -1
- package/dist/types/chartType/bar/bar.d.ts +414 -14
- package/dist/types/chartType/bar/bar.d.ts.map +1 -1
- package/dist/types/chartType/barParallel/barParallel.d.ts +414 -14
- package/dist/types/chartType/barParallel/barParallel.d.ts.map +1 -1
- package/dist/types/chartType/barPercent/barPercent.d.ts +414 -14
- package/dist/types/chartType/barPercent/barPercent.d.ts.map +1 -1
- package/dist/types/chartType/column/column.d.ts +414 -14
- package/dist/types/chartType/column/column.d.ts.map +1 -1
- package/dist/types/chartType/columnParallel/columnParallel.d.ts +414 -14
- package/dist/types/chartType/columnParallel/columnParallel.d.ts.map +1 -1
- package/dist/types/chartType/columnPercent/columnPercent.d.ts +414 -14
- package/dist/types/chartType/columnPercent/columnPercent.d.ts.map +1 -1
- package/dist/types/chartType/donut/donut.d.ts +2 -2
- package/dist/types/chartType/funnel/funnel.d.ts +2 -2
- package/dist/types/chartType/line/line.d.ts +414 -14
- package/dist/types/chartType/line/line.d.ts.map +1 -1
- package/dist/types/chartType/pie/pie.d.ts +2 -2
- package/dist/types/chartType/rose/rose.d.ts +2 -2
- package/dist/types/chartType/roseParallel/roseParallel.d.ts +2 -2
- package/dist/types/chartType/scatter/scatter.d.ts +414 -14
- package/dist/types/chartType/scatter/scatter.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/properties/annotation/annotation.d.ts +0 -8
- package/dist/types/properties/annotation/annotation.d.ts.map +1 -1
- package/dist/types/properties/annotation/annotationHorizontalLine.d.ts +0 -2
- package/dist/types/properties/annotation/annotationHorizontalLine.d.ts.map +1 -1
- package/dist/types/properties/annotation/annotationVerticalLine.d.ts +0 -2
- package/dist/types/properties/annotation/annotationVerticalLine.d.ts.map +1 -1
- package/dist/types/properties/config/axis.d.ts +1 -1
- package/dist/types/properties/dimensions/dimensions.d.ts +4 -4
- package/dist/types/properties/theme/customTheme.d.ts +0 -16
- package/dist/types/properties/theme/customTheme.d.ts.map +1 -1
- package/dist/types/vseed.d.ts +5898 -1898
- package/dist/types/vseed.d.ts.map +1 -1
- package/dist/umd/999.js +3574 -0
- package/dist/umd/999.js.map +1 -0
- package/dist/umd/index.js +6164 -9537
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/999.js
ADDED
@@ -0,0 +1,3574 @@
|
|
1
|
+
"use strict";
|
2
|
+
(globalThis["webpackChunkVSeed"] = globalThis["webpackChunkVSeed"] || []).push([
|
3
|
+
[
|
4
|
+
"999"
|
5
|
+
],
|
6
|
+
{
|
7
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-2T7K3PFL.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
9
|
+
a: ()=>i
|
10
|
+
});
|
11
|
+
var _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js");
|
12
|
+
function i(...e) {
|
13
|
+
return (0, _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__.a)(o, e);
|
14
|
+
}
|
15
|
+
function o(e, s) {
|
16
|
+
let r = {};
|
17
|
+
for (let n of s)n in e && (r[n] = e[n]);
|
18
|
+
return r;
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-6GTAPB47.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
22
|
+
__webpack_require__.d(__webpack_exports__, {
|
23
|
+
a: ()=>e
|
24
|
+
});
|
25
|
+
function e(r) {
|
26
|
+
return "number" == typeof r && !Number.isNaN(r);
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-BCBB46UE.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
31
|
+
a: ()=>d
|
32
|
+
});
|
33
|
+
var _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js");
|
34
|
+
function d(...n) {
|
35
|
+
return (0, _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__.a)(u, n);
|
36
|
+
}
|
37
|
+
function u(n, o = [], t = []) {
|
38
|
+
if ("function" == typeof n) return n;
|
39
|
+
if ("object" != typeof n || null === n) return structuredClone(n);
|
40
|
+
let r = Object.getPrototypeOf(n);
|
41
|
+
if (!Array.isArray(n) && null !== r && r !== Object.prototype) return structuredClone(n);
|
42
|
+
let e = o.indexOf(n);
|
43
|
+
return -1 !== e ? t[e] : (o.push(n), Array.isArray(n) ? p(n, o, t) : i(n, o, t));
|
44
|
+
}
|
45
|
+
function i(n, o, t) {
|
46
|
+
let r = {};
|
47
|
+
t.push(r);
|
48
|
+
for (let [e, c] of Object.entries(n))r[e] = u(c, o, t);
|
49
|
+
return r;
|
50
|
+
}
|
51
|
+
function p(n, o, t) {
|
52
|
+
let r = [];
|
53
|
+
t.push(r);
|
54
|
+
for (let [e, c] of n.entries())r[e] = u(c, o, t);
|
55
|
+
return r;
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-BO3LQZNF.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
59
|
+
__webpack_require__.d(__webpack_exports__, {
|
60
|
+
a: ()=>o
|
61
|
+
});
|
62
|
+
function o(r) {
|
63
|
+
return Array.isArray(r);
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-HVPVHFDT.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
67
|
+
__webpack_require__.d(__webpack_exports__, {
|
68
|
+
a: ()=>i
|
69
|
+
});
|
70
|
+
var _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js");
|
71
|
+
function i(...e) {
|
72
|
+
return (0, _chunk_WIMGWYZL_js__WEBPACK_IMPORTED_MODULE_0__.a)(p, e);
|
73
|
+
}
|
74
|
+
var p = (e, d)=>{
|
75
|
+
let r = Object.create(null);
|
76
|
+
for(let n = 0; n < e.length; n++){
|
77
|
+
let t = e[n], y = d(t, n, e);
|
78
|
+
if (void 0 !== y) {
|
79
|
+
let o = r[y];
|
80
|
+
void 0 === o ? r[y] = [
|
81
|
+
t
|
82
|
+
] : o.push(t);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
return Object.setPrototypeOf(r, Object.prototype), r;
|
86
|
+
};
|
87
|
+
},
|
88
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-JK3VNB42.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
89
|
+
__webpack_require__.d(__webpack_exports__, {
|
90
|
+
a: ()=>n
|
91
|
+
});
|
92
|
+
function n(e) {
|
93
|
+
return null == e;
|
94
|
+
}
|
95
|
+
},
|
96
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-KI5X74E2.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
97
|
+
__webpack_require__.d(__webpack_exports__, {
|
98
|
+
a: ()=>y
|
99
|
+
});
|
100
|
+
var chunk_WIMGWYZL = __webpack_require__("../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js");
|
101
|
+
function i(...e) {
|
102
|
+
return (0, chunk_WIMGWYZL.a)(n, e);
|
103
|
+
}
|
104
|
+
var n = (e, r)=>e.length >= r;
|
105
|
+
function y(...t) {
|
106
|
+
return (0, chunk_WIMGWYZL.a)(f, t);
|
107
|
+
}
|
108
|
+
function f(t, e) {
|
109
|
+
if (!i(e, 1)) return {
|
110
|
+
...t
|
111
|
+
};
|
112
|
+
if (!i(e, 2)) {
|
113
|
+
let { [e[0]]: r, ...m } = t;
|
114
|
+
return m;
|
115
|
+
}
|
116
|
+
let o = {
|
117
|
+
...t
|
118
|
+
};
|
119
|
+
for (let r of e)delete o[r];
|
120
|
+
return o;
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-PDQFB3TV.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
124
|
+
__webpack_require__.d(__webpack_exports__, {
|
125
|
+
a: ()=>D
|
126
|
+
});
|
127
|
+
function chunk_BZNENX2T_r(o) {
|
128
|
+
if ("object" != typeof o || null === o) return !1;
|
129
|
+
let e = Object.getPrototypeOf(o);
|
130
|
+
return null === e || e === Object.prototype;
|
131
|
+
}
|
132
|
+
var chunk_WIMGWYZL = __webpack_require__("../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js");
|
133
|
+
function D(...e) {
|
134
|
+
return (0, chunk_WIMGWYZL.a)(s, e);
|
135
|
+
}
|
136
|
+
function s(e, t) {
|
137
|
+
let r = {
|
138
|
+
...e,
|
139
|
+
...t
|
140
|
+
};
|
141
|
+
for(let n in t){
|
142
|
+
if (!(n in e)) continue;
|
143
|
+
let { [n]: i } = e;
|
144
|
+
if (!chunk_BZNENX2T_r(i)) continue;
|
145
|
+
let { [n]: c } = t;
|
146
|
+
chunk_BZNENX2T_r(c) && (r[n] = s(i, c));
|
147
|
+
}
|
148
|
+
return r;
|
149
|
+
}
|
150
|
+
},
|
151
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-QJLMYOTX.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
152
|
+
__webpack_require__.d(__webpack_exports__, {
|
153
|
+
a: ()=>chunk_QJLMYOTX_i
|
154
|
+
});
|
155
|
+
var chunk_ANXBDSUI_s = {
|
156
|
+
done: !1,
|
157
|
+
hasNext: !1
|
158
|
+
};
|
159
|
+
function C(t, ...o) {
|
160
|
+
let n = t, u = o.map((e)=>"lazy" in e ? y(e) : void 0), p = 0;
|
161
|
+
for(; p < o.length;){
|
162
|
+
if (void 0 === u[p] || !B(n)) {
|
163
|
+
let i = o[p];
|
164
|
+
n = i(n), p += 1;
|
165
|
+
continue;
|
166
|
+
}
|
167
|
+
let r = [];
|
168
|
+
for(let i = p; i < o.length; i++){
|
169
|
+
let l = u[i];
|
170
|
+
if (void 0 === l || (r.push(l), l.isSingle)) break;
|
171
|
+
}
|
172
|
+
let a = [];
|
173
|
+
for (let i of n)if (f(i, a, r)) break;
|
174
|
+
let { isSingle: s } = r.at(-1);
|
175
|
+
n = s ? a[0] : a, p += r.length;
|
176
|
+
}
|
177
|
+
return n;
|
178
|
+
}
|
179
|
+
function f(t, o, n) {
|
180
|
+
if (0 === n.length) return o.push(t), !1;
|
181
|
+
let u = t, p = chunk_ANXBDSUI_s, e = !1;
|
182
|
+
for (let [r, a] of n.entries()){
|
183
|
+
let { index: s, items: i } = a;
|
184
|
+
if (i.push(u), p = a(u, s, i), a.index += 1, p.hasNext) {
|
185
|
+
if (p.hasMany ?? !1) {
|
186
|
+
for (let l of p.next)if (f(l, o, n.slice(r + 1))) return !0;
|
187
|
+
return e;
|
188
|
+
}
|
189
|
+
u = p.next;
|
190
|
+
}
|
191
|
+
if (!p.hasNext) break;
|
192
|
+
p.done && (e = !0);
|
193
|
+
}
|
194
|
+
return p.hasNext && o.push(u), e;
|
195
|
+
}
|
196
|
+
function y(t) {
|
197
|
+
let { lazy: o, lazyArgs: n } = t, u = o(...n);
|
198
|
+
return Object.assign(u, {
|
199
|
+
isSingle: o.single ?? !1,
|
200
|
+
index: 0,
|
201
|
+
items: []
|
202
|
+
});
|
203
|
+
}
|
204
|
+
function B(t) {
|
205
|
+
return "string" == typeof t || "object" == typeof t && null !== t && Symbol.iterator in t;
|
206
|
+
}
|
207
|
+
function chunk_LFJW7BOT_y(t, i) {
|
208
|
+
let a = i.length - t.length;
|
209
|
+
if (1 === a) {
|
210
|
+
let [n, ...r] = i;
|
211
|
+
return C(n, {
|
212
|
+
lazy: t,
|
213
|
+
lazyArgs: r
|
214
|
+
});
|
215
|
+
}
|
216
|
+
if (0 === a) {
|
217
|
+
let n = {
|
218
|
+
lazy: t,
|
219
|
+
lazyArgs: i
|
220
|
+
};
|
221
|
+
return Object.assign((e)=>C(e, n), n);
|
222
|
+
}
|
223
|
+
throw new Error("Wrong number of arguments");
|
224
|
+
}
|
225
|
+
function chunk_QJLMYOTX_i(...e) {
|
226
|
+
return chunk_LFJW7BOT_y(chunk_QJLMYOTX_a, e);
|
227
|
+
}
|
228
|
+
function chunk_QJLMYOTX_a() {
|
229
|
+
let e = new Set;
|
230
|
+
return (t)=>e.has(t) ? chunk_ANXBDSUI_s : (e.add(t), {
|
231
|
+
done: !1,
|
232
|
+
hasNext: !0,
|
233
|
+
next: t
|
234
|
+
});
|
235
|
+
}
|
236
|
+
},
|
237
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-SFZGYJFI.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
238
|
+
__webpack_require__.d(__webpack_exports__, {
|
239
|
+
a: ()=>t
|
240
|
+
});
|
241
|
+
function t(r) {
|
242
|
+
return "string" == typeof r;
|
243
|
+
}
|
244
|
+
},
|
245
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-VCYTMP4D.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
246
|
+
__webpack_require__.d(__webpack_exports__, {
|
247
|
+
a: ()=>n
|
248
|
+
});
|
249
|
+
function n(e) {
|
250
|
+
return void 0 === e ? !0 : "string" == typeof e || Array.isArray(e) ? 0 === e.length : 0 === Object.keys(e).length;
|
251
|
+
}
|
252
|
+
},
|
253
|
+
"../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
254
|
+
__webpack_require__.d(__webpack_exports__, {
|
255
|
+
a: ()=>chunk_WIMGWYZL_u
|
256
|
+
});
|
257
|
+
function u(o, n, a) {
|
258
|
+
let t = (r)=>o(r, ...n);
|
259
|
+
return void 0 === a ? t : Object.assign(t, {
|
260
|
+
lazy: a,
|
261
|
+
lazyArgs: n
|
262
|
+
});
|
263
|
+
}
|
264
|
+
function chunk_WIMGWYZL_u(r, n, o) {
|
265
|
+
let a = r.length - n.length;
|
266
|
+
if (0 === a) return r(...n);
|
267
|
+
if (1 === a) return u(r, n, o);
|
268
|
+
throw new Error("Wrong number of arguments");
|
269
|
+
}
|
270
|
+
},
|
271
|
+
"../../node_modules/.pnpm/zod@4.0.14/node_modules/zod/v4/classic/schemas.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
272
|
+
__webpack_require__.d(__webpack_exports__, {
|
273
|
+
EB: ()=>ZodStringFormat,
|
274
|
+
k5: ()=>schemas_enum,
|
275
|
+
gM: ()=>discriminatedUnion,
|
276
|
+
bz: ()=>any,
|
277
|
+
g1: ()=>record,
|
278
|
+
zM: ()=>schemas_boolean,
|
279
|
+
ai: ()=>schemas_number,
|
280
|
+
Vx: ()=>schemas_undefined,
|
281
|
+
Ik: ()=>schemas_object,
|
282
|
+
YO: ()=>schemas_array,
|
283
|
+
Yj: ()=>schemas_string,
|
284
|
+
eu: ()=>literal,
|
285
|
+
KC: ()=>union
|
286
|
+
});
|
287
|
+
Object.freeze({
|
288
|
+
status: "aborted"
|
289
|
+
});
|
290
|
+
function $constructor(name, initializer, params) {
|
291
|
+
function init(inst, def) {
|
292
|
+
var _a;
|
293
|
+
Object.defineProperty(inst, "_zod", {
|
294
|
+
value: inst._zod ?? {},
|
295
|
+
enumerable: false
|
296
|
+
});
|
297
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set());
|
298
|
+
inst._zod.traits.add(name);
|
299
|
+
initializer(inst, def);
|
300
|
+
for(const k in _.prototype)if (!(k in inst)) Object.defineProperty(inst, k, {
|
301
|
+
value: _.prototype[k].bind(inst)
|
302
|
+
});
|
303
|
+
inst._zod.constr = _;
|
304
|
+
inst._zod.def = def;
|
305
|
+
}
|
306
|
+
const Parent = params?.Parent ?? Object;
|
307
|
+
class Definition extends Parent {
|
308
|
+
}
|
309
|
+
Object.defineProperty(Definition, "name", {
|
310
|
+
value: name
|
311
|
+
});
|
312
|
+
function _(def) {
|
313
|
+
var _a;
|
314
|
+
const inst = params?.Parent ? new Definition() : this;
|
315
|
+
init(inst, def);
|
316
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
317
|
+
for (const fn of inst._zod.deferred)fn();
|
318
|
+
return inst;
|
319
|
+
}
|
320
|
+
Object.defineProperty(_, "init", {
|
321
|
+
value: init
|
322
|
+
});
|
323
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
324
|
+
value: (inst)=>{
|
325
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
326
|
+
return inst?._zod?.traits?.has(name);
|
327
|
+
}
|
328
|
+
});
|
329
|
+
Object.defineProperty(_, "name", {
|
330
|
+
value: name
|
331
|
+
});
|
332
|
+
return _;
|
333
|
+
}
|
334
|
+
Symbol("zod_brand");
|
335
|
+
class $ZodAsyncError extends Error {
|
336
|
+
constructor(){
|
337
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
338
|
+
}
|
339
|
+
}
|
340
|
+
const globalConfig = {};
|
341
|
+
function core_config(newConfig) {
|
342
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
343
|
+
return globalConfig;
|
344
|
+
}
|
345
|
+
const cuid = /^[cC][^\s-]{8,}$/;
|
346
|
+
const cuid2 = /^[0-9a-z]+$/;
|
347
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
348
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
349
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
350
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
351
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
352
|
+
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
353
|
+
const uuid = (version)=>{
|
354
|
+
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
|
355
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
356
|
+
};
|
357
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
358
|
+
const _emoji = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
359
|
+
function emoji() {
|
360
|
+
return new RegExp(_emoji, "u");
|
361
|
+
}
|
362
|
+
const ipv4 = /^(?:(?: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])$/;
|
363
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
|
364
|
+
const cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
365
|
+
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
366
|
+
const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
367
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
368
|
+
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
369
|
+
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
370
|
+
const dateSource = "(?:(?:\\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])))";
|
371
|
+
const date = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
|
372
|
+
function timeSource(args) {
|
373
|
+
const hhmm = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
374
|
+
const regex = "number" == typeof args.precision ? -1 === args.precision ? `${hhmm}` : 0 === args.precision ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
375
|
+
return regex;
|
376
|
+
}
|
377
|
+
function regexes_time(args) {
|
378
|
+
return new RegExp(`^${timeSource(args)}$`);
|
379
|
+
}
|
380
|
+
function datetime(args) {
|
381
|
+
const time = timeSource({
|
382
|
+
precision: args.precision
|
383
|
+
});
|
384
|
+
const opts = [
|
385
|
+
"Z"
|
386
|
+
];
|
387
|
+
if (args.local) opts.push("");
|
388
|
+
if (args.offset) opts.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
389
|
+
const timeRegex = `${time}(?:${opts.join("|")})`;
|
390
|
+
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
391
|
+
}
|
392
|
+
const string = (params)=>{
|
393
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : "[\\s\\S]*";
|
394
|
+
return new RegExp(`^${regex}$`);
|
395
|
+
};
|
396
|
+
const integer = /^\d+$/;
|
397
|
+
const number = /^-?\d+(?:\.\d+)?/i;
|
398
|
+
const regexes_boolean = /true|false/i;
|
399
|
+
const _undefined = /undefined/i;
|
400
|
+
const lowercase = /^[^A-Z]*$/;
|
401
|
+
const uppercase = /^[^a-z]*$/;
|
402
|
+
function getEnumValues(entries) {
|
403
|
+
const numericValues = Object.values(entries).filter((v)=>"number" == typeof v);
|
404
|
+
const values = Object.entries(entries).filter(([k, _])=>-1 === numericValues.indexOf(+k)).map(([_, v])=>v);
|
405
|
+
return values;
|
406
|
+
}
|
407
|
+
function jsonStringifyReplacer(_, value) {
|
408
|
+
if ("bigint" == typeof value) return value.toString();
|
409
|
+
return value;
|
410
|
+
}
|
411
|
+
function cached(getter) {
|
412
|
+
const set = false;
|
413
|
+
return {
|
414
|
+
get value () {
|
415
|
+
if (!set) {
|
416
|
+
const value = getter();
|
417
|
+
Object.defineProperty(this, "value", {
|
418
|
+
value
|
419
|
+
});
|
420
|
+
return value;
|
421
|
+
}
|
422
|
+
throw new Error("cached value already set");
|
423
|
+
}
|
424
|
+
};
|
425
|
+
}
|
426
|
+
function nullish(input) {
|
427
|
+
return null == input;
|
428
|
+
}
|
429
|
+
function cleanRegex(source) {
|
430
|
+
const start = source.startsWith("^") ? 1 : 0;
|
431
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
432
|
+
return source.slice(start, end);
|
433
|
+
}
|
434
|
+
function floatSafeRemainder(val, step) {
|
435
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
436
|
+
const stepString = step.toString();
|
437
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
438
|
+
if (0 === stepDecCount && /\d?e-\d?/.test(stepString)) {
|
439
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
440
|
+
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
441
|
+
}
|
442
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
443
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
444
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
445
|
+
return valInt % stepInt / 10 ** decCount;
|
446
|
+
}
|
447
|
+
const EVALUATING = Symbol("evaluating");
|
448
|
+
function defineLazy(object, key, getter) {
|
449
|
+
let value;
|
450
|
+
Object.defineProperty(object, key, {
|
451
|
+
get () {
|
452
|
+
if (value === EVALUATING) return;
|
453
|
+
if (void 0 === value) {
|
454
|
+
value = EVALUATING;
|
455
|
+
value = getter();
|
456
|
+
}
|
457
|
+
return value;
|
458
|
+
},
|
459
|
+
set (v) {
|
460
|
+
Object.defineProperty(object, key, {
|
461
|
+
value: v
|
462
|
+
});
|
463
|
+
},
|
464
|
+
configurable: true
|
465
|
+
});
|
466
|
+
}
|
467
|
+
function assignProp(target, prop, value) {
|
468
|
+
Object.defineProperty(target, prop, {
|
469
|
+
value,
|
470
|
+
writable: true,
|
471
|
+
enumerable: true,
|
472
|
+
configurable: true
|
473
|
+
});
|
474
|
+
}
|
475
|
+
function mergeDefs(...defs) {
|
476
|
+
const mergedDescriptors = {};
|
477
|
+
for (const def of defs){
|
478
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
479
|
+
Object.assign(mergedDescriptors, descriptors);
|
480
|
+
}
|
481
|
+
return Object.defineProperties({}, mergedDescriptors);
|
482
|
+
}
|
483
|
+
function esc(str) {
|
484
|
+
return JSON.stringify(str);
|
485
|
+
}
|
486
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args)=>{};
|
487
|
+
function util_isObject(data) {
|
488
|
+
return "object" == typeof data && null !== data && !Array.isArray(data);
|
489
|
+
}
|
490
|
+
const util_allowsEval = cached(()=>{
|
491
|
+
if ("undefined" != typeof navigator && navigator?.userAgent?.includes("Cloudflare")) return false;
|
492
|
+
try {
|
493
|
+
const F = Function;
|
494
|
+
new F("");
|
495
|
+
return true;
|
496
|
+
} catch (_) {
|
497
|
+
return false;
|
498
|
+
}
|
499
|
+
});
|
500
|
+
function isPlainObject(o) {
|
501
|
+
if (false === util_isObject(o)) return false;
|
502
|
+
const ctor = o.constructor;
|
503
|
+
if (void 0 === ctor) return true;
|
504
|
+
const prot = ctor.prototype;
|
505
|
+
if (false === util_isObject(prot)) return false;
|
506
|
+
if (false === Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf")) return false;
|
507
|
+
return true;
|
508
|
+
}
|
509
|
+
const propertyKeyTypes = new Set([
|
510
|
+
"string",
|
511
|
+
"number",
|
512
|
+
"symbol"
|
513
|
+
]);
|
514
|
+
new Set([
|
515
|
+
"string",
|
516
|
+
"number",
|
517
|
+
"bigint",
|
518
|
+
"boolean",
|
519
|
+
"symbol",
|
520
|
+
"undefined"
|
521
|
+
]);
|
522
|
+
function escapeRegex(str) {
|
523
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
524
|
+
}
|
525
|
+
function clone(inst, def, params) {
|
526
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
527
|
+
if (!def || params?.parent) cl._zod.parent = inst;
|
528
|
+
return cl;
|
529
|
+
}
|
530
|
+
function normalizeParams(_params) {
|
531
|
+
const params = _params;
|
532
|
+
if (!params) return {};
|
533
|
+
if ("string" == typeof params) return {
|
534
|
+
error: ()=>params
|
535
|
+
};
|
536
|
+
if (params?.message !== void 0) {
|
537
|
+
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
538
|
+
params.error = params.message;
|
539
|
+
}
|
540
|
+
delete params.message;
|
541
|
+
if ("string" == typeof params.error) return {
|
542
|
+
...params,
|
543
|
+
error: ()=>params.error
|
544
|
+
};
|
545
|
+
return params;
|
546
|
+
}
|
547
|
+
function optionalKeys(shape) {
|
548
|
+
return Object.keys(shape).filter((k)=>"optional" === shape[k]._zod.optin && "optional" === shape[k]._zod.optout);
|
549
|
+
}
|
550
|
+
const NUMBER_FORMAT_RANGES = {
|
551
|
+
safeint: [
|
552
|
+
Number.MIN_SAFE_INTEGER,
|
553
|
+
Number.MAX_SAFE_INTEGER
|
554
|
+
],
|
555
|
+
int32: [
|
556
|
+
-2147483648,
|
557
|
+
2147483647
|
558
|
+
],
|
559
|
+
uint32: [
|
560
|
+
0,
|
561
|
+
4294967295
|
562
|
+
],
|
563
|
+
float32: [
|
564
|
+
-3.4028234663852886e+38,
|
565
|
+
3.4028234663852886e38
|
566
|
+
],
|
567
|
+
float64: [
|
568
|
+
-Number.MAX_VALUE,
|
569
|
+
Number.MAX_VALUE
|
570
|
+
]
|
571
|
+
};
|
572
|
+
function pick(schema, mask) {
|
573
|
+
const currDef = schema._zod.def;
|
574
|
+
const def = mergeDefs(schema._zod.def, {
|
575
|
+
get shape () {
|
576
|
+
const newShape = {};
|
577
|
+
for(const key in mask){
|
578
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
579
|
+
if (mask[key]) newShape[key] = currDef.shape[key];
|
580
|
+
}
|
581
|
+
assignProp(this, "shape", newShape);
|
582
|
+
return newShape;
|
583
|
+
},
|
584
|
+
checks: []
|
585
|
+
});
|
586
|
+
return clone(schema, def);
|
587
|
+
}
|
588
|
+
function omit(schema, mask) {
|
589
|
+
const currDef = schema._zod.def;
|
590
|
+
const def = mergeDefs(schema._zod.def, {
|
591
|
+
get shape () {
|
592
|
+
const newShape = {
|
593
|
+
...schema._zod.def.shape
|
594
|
+
};
|
595
|
+
for(const key in mask){
|
596
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
597
|
+
if (mask[key]) delete newShape[key];
|
598
|
+
}
|
599
|
+
assignProp(this, "shape", newShape);
|
600
|
+
return newShape;
|
601
|
+
},
|
602
|
+
checks: []
|
603
|
+
});
|
604
|
+
return clone(schema, def);
|
605
|
+
}
|
606
|
+
function extend(schema, shape) {
|
607
|
+
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
608
|
+
const def = mergeDefs(schema._zod.def, {
|
609
|
+
get shape () {
|
610
|
+
const _shape = {
|
611
|
+
...schema._zod.def.shape,
|
612
|
+
...shape
|
613
|
+
};
|
614
|
+
assignProp(this, "shape", _shape);
|
615
|
+
return _shape;
|
616
|
+
},
|
617
|
+
checks: []
|
618
|
+
});
|
619
|
+
return clone(schema, def);
|
620
|
+
}
|
621
|
+
function merge(a, b) {
|
622
|
+
const def = mergeDefs(a._zod.def, {
|
623
|
+
get shape () {
|
624
|
+
const _shape = {
|
625
|
+
...a._zod.def.shape,
|
626
|
+
...b._zod.def.shape
|
627
|
+
};
|
628
|
+
assignProp(this, "shape", _shape);
|
629
|
+
return _shape;
|
630
|
+
},
|
631
|
+
get catchall () {
|
632
|
+
return b._zod.def.catchall;
|
633
|
+
},
|
634
|
+
checks: []
|
635
|
+
});
|
636
|
+
return clone(a, def);
|
637
|
+
}
|
638
|
+
function partial(Class, schema, mask) {
|
639
|
+
const def = mergeDefs(schema._zod.def, {
|
640
|
+
get shape () {
|
641
|
+
const oldShape = schema._zod.def.shape;
|
642
|
+
const shape = {
|
643
|
+
...oldShape
|
644
|
+
};
|
645
|
+
if (mask) for(const key in mask){
|
646
|
+
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
647
|
+
if (mask[key]) shape[key] = Class ? new Class({
|
648
|
+
type: "optional",
|
649
|
+
innerType: oldShape[key]
|
650
|
+
}) : oldShape[key];
|
651
|
+
}
|
652
|
+
else for(const key in oldShape)shape[key] = Class ? new Class({
|
653
|
+
type: "optional",
|
654
|
+
innerType: oldShape[key]
|
655
|
+
}) : oldShape[key];
|
656
|
+
assignProp(this, "shape", shape);
|
657
|
+
return shape;
|
658
|
+
},
|
659
|
+
checks: []
|
660
|
+
});
|
661
|
+
return clone(schema, def);
|
662
|
+
}
|
663
|
+
function required(Class, schema, mask) {
|
664
|
+
const def = mergeDefs(schema._zod.def, {
|
665
|
+
get shape () {
|
666
|
+
const oldShape = schema._zod.def.shape;
|
667
|
+
const shape = {
|
668
|
+
...oldShape
|
669
|
+
};
|
670
|
+
if (mask) for(const key in mask){
|
671
|
+
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
672
|
+
if (mask[key]) shape[key] = new Class({
|
673
|
+
type: "nonoptional",
|
674
|
+
innerType: oldShape[key]
|
675
|
+
});
|
676
|
+
}
|
677
|
+
else for(const key in oldShape)shape[key] = new Class({
|
678
|
+
type: "nonoptional",
|
679
|
+
innerType: oldShape[key]
|
680
|
+
});
|
681
|
+
assignProp(this, "shape", shape);
|
682
|
+
return shape;
|
683
|
+
},
|
684
|
+
checks: []
|
685
|
+
});
|
686
|
+
return clone(schema, def);
|
687
|
+
}
|
688
|
+
function aborted(x, startIndex = 0) {
|
689
|
+
for(let i = startIndex; i < x.issues.length; i++)if (x.issues[i]?.continue !== true) return true;
|
690
|
+
return false;
|
691
|
+
}
|
692
|
+
function prefixIssues(path, issues) {
|
693
|
+
return issues.map((iss)=>{
|
694
|
+
var _a;
|
695
|
+
(_a = iss).path ?? (_a.path = []);
|
696
|
+
iss.path.unshift(path);
|
697
|
+
return iss;
|
698
|
+
});
|
699
|
+
}
|
700
|
+
function unwrapMessage(message) {
|
701
|
+
return "string" == typeof message ? message : message?.message;
|
702
|
+
}
|
703
|
+
function finalizeIssue(iss, ctx, config) {
|
704
|
+
const full = {
|
705
|
+
...iss,
|
706
|
+
path: iss.path ?? []
|
707
|
+
};
|
708
|
+
if (!iss.message) {
|
709
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
710
|
+
full.message = message;
|
711
|
+
}
|
712
|
+
delete full.inst;
|
713
|
+
delete full.continue;
|
714
|
+
if (!ctx?.reportInput) delete full.input;
|
715
|
+
return full;
|
716
|
+
}
|
717
|
+
function getLengthableOrigin(input) {
|
718
|
+
if (Array.isArray(input)) return "array";
|
719
|
+
if ("string" == typeof input) return "string";
|
720
|
+
return "unknown";
|
721
|
+
}
|
722
|
+
function util_issue(...args) {
|
723
|
+
const [iss, input, inst] = args;
|
724
|
+
if ("string" == typeof iss) return {
|
725
|
+
message: iss,
|
726
|
+
code: "custom",
|
727
|
+
input,
|
728
|
+
inst
|
729
|
+
};
|
730
|
+
return {
|
731
|
+
...iss
|
732
|
+
};
|
733
|
+
}
|
734
|
+
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def)=>{
|
735
|
+
var _a;
|
736
|
+
inst._zod ?? (inst._zod = {});
|
737
|
+
inst._zod.def = def;
|
738
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
739
|
+
});
|
740
|
+
const numericOriginMap = {
|
741
|
+
number: "number",
|
742
|
+
bigint: "bigint",
|
743
|
+
object: "date"
|
744
|
+
};
|
745
|
+
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def)=>{
|
746
|
+
$ZodCheck.init(inst, def);
|
747
|
+
const origin = numericOriginMap[typeof def.value];
|
748
|
+
inst._zod.onattach.push((inst)=>{
|
749
|
+
const bag = inst._zod.bag;
|
750
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? 1 / 0;
|
751
|
+
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
752
|
+
else bag.exclusiveMaximum = def.value;
|
753
|
+
});
|
754
|
+
inst._zod.check = (payload)=>{
|
755
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
756
|
+
payload.issues.push({
|
757
|
+
origin,
|
758
|
+
code: "too_big",
|
759
|
+
maximum: def.value,
|
760
|
+
input: payload.value,
|
761
|
+
inclusive: def.inclusive,
|
762
|
+
inst,
|
763
|
+
continue: !def.abort
|
764
|
+
});
|
765
|
+
};
|
766
|
+
});
|
767
|
+
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def)=>{
|
768
|
+
$ZodCheck.init(inst, def);
|
769
|
+
const origin = numericOriginMap[typeof def.value];
|
770
|
+
inst._zod.onattach.push((inst)=>{
|
771
|
+
const bag = inst._zod.bag;
|
772
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? -1 / 0;
|
773
|
+
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
774
|
+
else bag.exclusiveMinimum = def.value;
|
775
|
+
});
|
776
|
+
inst._zod.check = (payload)=>{
|
777
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
778
|
+
payload.issues.push({
|
779
|
+
origin,
|
780
|
+
code: "too_small",
|
781
|
+
minimum: def.value,
|
782
|
+
input: payload.value,
|
783
|
+
inclusive: def.inclusive,
|
784
|
+
inst,
|
785
|
+
continue: !def.abort
|
786
|
+
});
|
787
|
+
};
|
788
|
+
});
|
789
|
+
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def)=>{
|
790
|
+
$ZodCheck.init(inst, def);
|
791
|
+
inst._zod.onattach.push((inst)=>{
|
792
|
+
var _a;
|
793
|
+
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
794
|
+
});
|
795
|
+
inst._zod.check = (payload)=>{
|
796
|
+
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
797
|
+
const isMultiple = "bigint" == typeof payload.value ? payload.value % def.value === BigInt(0) : 0 === floatSafeRemainder(payload.value, def.value);
|
798
|
+
if (isMultiple) return;
|
799
|
+
payload.issues.push({
|
800
|
+
origin: typeof payload.value,
|
801
|
+
code: "not_multiple_of",
|
802
|
+
divisor: def.value,
|
803
|
+
input: payload.value,
|
804
|
+
inst,
|
805
|
+
continue: !def.abort
|
806
|
+
});
|
807
|
+
};
|
808
|
+
});
|
809
|
+
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def)=>{
|
810
|
+
$ZodCheck.init(inst, def);
|
811
|
+
def.format = def.format || "float64";
|
812
|
+
const isInt = def.format?.includes("int");
|
813
|
+
const origin = isInt ? "int" : "number";
|
814
|
+
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
815
|
+
inst._zod.onattach.push((inst)=>{
|
816
|
+
const bag = inst._zod.bag;
|
817
|
+
bag.format = def.format;
|
818
|
+
bag.minimum = minimum;
|
819
|
+
bag.maximum = maximum;
|
820
|
+
if (isInt) bag.pattern = integer;
|
821
|
+
});
|
822
|
+
inst._zod.check = (payload)=>{
|
823
|
+
const input = payload.value;
|
824
|
+
if (isInt) {
|
825
|
+
if (!Number.isInteger(input)) return void payload.issues.push({
|
826
|
+
expected: origin,
|
827
|
+
format: def.format,
|
828
|
+
code: "invalid_type",
|
829
|
+
continue: false,
|
830
|
+
input,
|
831
|
+
inst
|
832
|
+
});
|
833
|
+
if (!Number.isSafeInteger(input)) {
|
834
|
+
if (input > 0) payload.issues.push({
|
835
|
+
input,
|
836
|
+
code: "too_big",
|
837
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
838
|
+
note: "Integers must be within the safe integer range.",
|
839
|
+
inst,
|
840
|
+
origin,
|
841
|
+
continue: !def.abort
|
842
|
+
});
|
843
|
+
else payload.issues.push({
|
844
|
+
input,
|
845
|
+
code: "too_small",
|
846
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
847
|
+
note: "Integers must be within the safe integer range.",
|
848
|
+
inst,
|
849
|
+
origin,
|
850
|
+
continue: !def.abort
|
851
|
+
});
|
852
|
+
return;
|
853
|
+
}
|
854
|
+
}
|
855
|
+
if (input < minimum) payload.issues.push({
|
856
|
+
origin: "number",
|
857
|
+
input,
|
858
|
+
code: "too_small",
|
859
|
+
minimum,
|
860
|
+
inclusive: true,
|
861
|
+
inst,
|
862
|
+
continue: !def.abort
|
863
|
+
});
|
864
|
+
if (input > maximum) payload.issues.push({
|
865
|
+
origin: "number",
|
866
|
+
input,
|
867
|
+
code: "too_big",
|
868
|
+
maximum,
|
869
|
+
inst
|
870
|
+
});
|
871
|
+
};
|
872
|
+
});
|
873
|
+
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def)=>{
|
874
|
+
var _a;
|
875
|
+
$ZodCheck.init(inst, def);
|
876
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
877
|
+
const val = payload.value;
|
878
|
+
return !nullish(val) && void 0 !== val.length;
|
879
|
+
});
|
880
|
+
inst._zod.onattach.push((inst)=>{
|
881
|
+
const curr = inst._zod.bag.maximum ?? 1 / 0;
|
882
|
+
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
883
|
+
});
|
884
|
+
inst._zod.check = (payload)=>{
|
885
|
+
const input = payload.value;
|
886
|
+
const length = input.length;
|
887
|
+
if (length <= def.maximum) return;
|
888
|
+
const origin = getLengthableOrigin(input);
|
889
|
+
payload.issues.push({
|
890
|
+
origin,
|
891
|
+
code: "too_big",
|
892
|
+
maximum: def.maximum,
|
893
|
+
inclusive: true,
|
894
|
+
input,
|
895
|
+
inst,
|
896
|
+
continue: !def.abort
|
897
|
+
});
|
898
|
+
};
|
899
|
+
});
|
900
|
+
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def)=>{
|
901
|
+
var _a;
|
902
|
+
$ZodCheck.init(inst, def);
|
903
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
904
|
+
const val = payload.value;
|
905
|
+
return !nullish(val) && void 0 !== val.length;
|
906
|
+
});
|
907
|
+
inst._zod.onattach.push((inst)=>{
|
908
|
+
const curr = inst._zod.bag.minimum ?? -1 / 0;
|
909
|
+
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
910
|
+
});
|
911
|
+
inst._zod.check = (payload)=>{
|
912
|
+
const input = payload.value;
|
913
|
+
const length = input.length;
|
914
|
+
if (length >= def.minimum) return;
|
915
|
+
const origin = getLengthableOrigin(input);
|
916
|
+
payload.issues.push({
|
917
|
+
origin,
|
918
|
+
code: "too_small",
|
919
|
+
minimum: def.minimum,
|
920
|
+
inclusive: true,
|
921
|
+
input,
|
922
|
+
inst,
|
923
|
+
continue: !def.abort
|
924
|
+
});
|
925
|
+
};
|
926
|
+
});
|
927
|
+
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def)=>{
|
928
|
+
var _a;
|
929
|
+
$ZodCheck.init(inst, def);
|
930
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload)=>{
|
931
|
+
const val = payload.value;
|
932
|
+
return !nullish(val) && void 0 !== val.length;
|
933
|
+
});
|
934
|
+
inst._zod.onattach.push((inst)=>{
|
935
|
+
const bag = inst._zod.bag;
|
936
|
+
bag.minimum = def.length;
|
937
|
+
bag.maximum = def.length;
|
938
|
+
bag.length = def.length;
|
939
|
+
});
|
940
|
+
inst._zod.check = (payload)=>{
|
941
|
+
const input = payload.value;
|
942
|
+
const length = input.length;
|
943
|
+
if (length === def.length) return;
|
944
|
+
const origin = getLengthableOrigin(input);
|
945
|
+
const tooBig = length > def.length;
|
946
|
+
payload.issues.push({
|
947
|
+
origin,
|
948
|
+
...tooBig ? {
|
949
|
+
code: "too_big",
|
950
|
+
maximum: def.length
|
951
|
+
} : {
|
952
|
+
code: "too_small",
|
953
|
+
minimum: def.length
|
954
|
+
},
|
955
|
+
inclusive: true,
|
956
|
+
exact: true,
|
957
|
+
input: payload.value,
|
958
|
+
inst,
|
959
|
+
continue: !def.abort
|
960
|
+
});
|
961
|
+
};
|
962
|
+
});
|
963
|
+
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def)=>{
|
964
|
+
var _a, _b;
|
965
|
+
$ZodCheck.init(inst, def);
|
966
|
+
inst._zod.onattach.push((inst)=>{
|
967
|
+
const bag = inst._zod.bag;
|
968
|
+
bag.format = def.format;
|
969
|
+
if (def.pattern) {
|
970
|
+
bag.patterns ?? (bag.patterns = new Set());
|
971
|
+
bag.patterns.add(def.pattern);
|
972
|
+
}
|
973
|
+
});
|
974
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload)=>{
|
975
|
+
def.pattern.lastIndex = 0;
|
976
|
+
if (def.pattern.test(payload.value)) return;
|
977
|
+
payload.issues.push({
|
978
|
+
origin: "string",
|
979
|
+
code: "invalid_format",
|
980
|
+
format: def.format,
|
981
|
+
input: payload.value,
|
982
|
+
...def.pattern ? {
|
983
|
+
pattern: def.pattern.toString()
|
984
|
+
} : {},
|
985
|
+
inst,
|
986
|
+
continue: !def.abort
|
987
|
+
});
|
988
|
+
});
|
989
|
+
else (_b = inst._zod).check ?? (_b.check = ()=>{});
|
990
|
+
});
|
991
|
+
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def)=>{
|
992
|
+
$ZodCheckStringFormat.init(inst, def);
|
993
|
+
inst._zod.check = (payload)=>{
|
994
|
+
def.pattern.lastIndex = 0;
|
995
|
+
if (def.pattern.test(payload.value)) return;
|
996
|
+
payload.issues.push({
|
997
|
+
origin: "string",
|
998
|
+
code: "invalid_format",
|
999
|
+
format: "regex",
|
1000
|
+
input: payload.value,
|
1001
|
+
pattern: def.pattern.toString(),
|
1002
|
+
inst,
|
1003
|
+
continue: !def.abort
|
1004
|
+
});
|
1005
|
+
};
|
1006
|
+
});
|
1007
|
+
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def)=>{
|
1008
|
+
def.pattern ?? (def.pattern = lowercase);
|
1009
|
+
$ZodCheckStringFormat.init(inst, def);
|
1010
|
+
});
|
1011
|
+
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def)=>{
|
1012
|
+
def.pattern ?? (def.pattern = uppercase);
|
1013
|
+
$ZodCheckStringFormat.init(inst, def);
|
1014
|
+
});
|
1015
|
+
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def)=>{
|
1016
|
+
$ZodCheck.init(inst, def);
|
1017
|
+
const escapedRegex = escapeRegex(def.includes);
|
1018
|
+
const pattern = new RegExp("number" == typeof def.position ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
1019
|
+
def.pattern = pattern;
|
1020
|
+
inst._zod.onattach.push((inst)=>{
|
1021
|
+
const bag = inst._zod.bag;
|
1022
|
+
bag.patterns ?? (bag.patterns = new Set());
|
1023
|
+
bag.patterns.add(pattern);
|
1024
|
+
});
|
1025
|
+
inst._zod.check = (payload)=>{
|
1026
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
1027
|
+
payload.issues.push({
|
1028
|
+
origin: "string",
|
1029
|
+
code: "invalid_format",
|
1030
|
+
format: "includes",
|
1031
|
+
includes: def.includes,
|
1032
|
+
input: payload.value,
|
1033
|
+
inst,
|
1034
|
+
continue: !def.abort
|
1035
|
+
});
|
1036
|
+
};
|
1037
|
+
});
|
1038
|
+
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def)=>{
|
1039
|
+
$ZodCheck.init(inst, def);
|
1040
|
+
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
1041
|
+
def.pattern ?? (def.pattern = pattern);
|
1042
|
+
inst._zod.onattach.push((inst)=>{
|
1043
|
+
const bag = inst._zod.bag;
|
1044
|
+
bag.patterns ?? (bag.patterns = new Set());
|
1045
|
+
bag.patterns.add(pattern);
|
1046
|
+
});
|
1047
|
+
inst._zod.check = (payload)=>{
|
1048
|
+
if (payload.value.startsWith(def.prefix)) return;
|
1049
|
+
payload.issues.push({
|
1050
|
+
origin: "string",
|
1051
|
+
code: "invalid_format",
|
1052
|
+
format: "starts_with",
|
1053
|
+
prefix: def.prefix,
|
1054
|
+
input: payload.value,
|
1055
|
+
inst,
|
1056
|
+
continue: !def.abort
|
1057
|
+
});
|
1058
|
+
};
|
1059
|
+
});
|
1060
|
+
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def)=>{
|
1061
|
+
$ZodCheck.init(inst, def);
|
1062
|
+
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
1063
|
+
def.pattern ?? (def.pattern = pattern);
|
1064
|
+
inst._zod.onattach.push((inst)=>{
|
1065
|
+
const bag = inst._zod.bag;
|
1066
|
+
bag.patterns ?? (bag.patterns = new Set());
|
1067
|
+
bag.patterns.add(pattern);
|
1068
|
+
});
|
1069
|
+
inst._zod.check = (payload)=>{
|
1070
|
+
if (payload.value.endsWith(def.suffix)) return;
|
1071
|
+
payload.issues.push({
|
1072
|
+
origin: "string",
|
1073
|
+
code: "invalid_format",
|
1074
|
+
format: "ends_with",
|
1075
|
+
suffix: def.suffix,
|
1076
|
+
input: payload.value,
|
1077
|
+
inst,
|
1078
|
+
continue: !def.abort
|
1079
|
+
});
|
1080
|
+
};
|
1081
|
+
});
|
1082
|
+
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def)=>{
|
1083
|
+
$ZodCheck.init(inst, def);
|
1084
|
+
inst._zod.check = (payload)=>{
|
1085
|
+
payload.value = def.tx(payload.value);
|
1086
|
+
};
|
1087
|
+
});
|
1088
|
+
class Doc {
|
1089
|
+
constructor(args = []){
|
1090
|
+
this.content = [];
|
1091
|
+
this.indent = 0;
|
1092
|
+
if (this) this.args = args;
|
1093
|
+
}
|
1094
|
+
indented(fn) {
|
1095
|
+
this.indent += 1;
|
1096
|
+
fn(this);
|
1097
|
+
this.indent -= 1;
|
1098
|
+
}
|
1099
|
+
write(arg) {
|
1100
|
+
if ("function" == typeof arg) {
|
1101
|
+
arg(this, {
|
1102
|
+
execution: "sync"
|
1103
|
+
});
|
1104
|
+
arg(this, {
|
1105
|
+
execution: "async"
|
1106
|
+
});
|
1107
|
+
return;
|
1108
|
+
}
|
1109
|
+
const content = arg;
|
1110
|
+
const lines = content.split("\n").filter((x)=>x);
|
1111
|
+
const minIndent = Math.min(...lines.map((x)=>x.length - x.trimStart().length));
|
1112
|
+
const dedented = lines.map((x)=>x.slice(minIndent)).map((x)=>" ".repeat(2 * this.indent) + x);
|
1113
|
+
for (const line of dedented)this.content.push(line);
|
1114
|
+
}
|
1115
|
+
compile() {
|
1116
|
+
const F = Function;
|
1117
|
+
const args = this?.args;
|
1118
|
+
const content = this?.content ?? [
|
1119
|
+
""
|
1120
|
+
];
|
1121
|
+
const lines = [
|
1122
|
+
...content.map((x)=>` ${x}`)
|
1123
|
+
];
|
1124
|
+
return new F(...args, lines.join("\n"));
|
1125
|
+
}
|
1126
|
+
}
|
1127
|
+
const errors_initializer = (inst, def)=>{
|
1128
|
+
inst.name = "$ZodError";
|
1129
|
+
Object.defineProperty(inst, "_zod", {
|
1130
|
+
value: inst._zod,
|
1131
|
+
enumerable: false
|
1132
|
+
});
|
1133
|
+
Object.defineProperty(inst, "issues", {
|
1134
|
+
value: def,
|
1135
|
+
enumerable: false
|
1136
|
+
});
|
1137
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
1138
|
+
Object.defineProperty(inst, "toString", {
|
1139
|
+
value: ()=>inst.message,
|
1140
|
+
enumerable: false
|
1141
|
+
});
|
1142
|
+
};
|
1143
|
+
const $ZodError = $constructor("$ZodError", errors_initializer);
|
1144
|
+
const $ZodRealError = $constructor("$ZodError", errors_initializer, {
|
1145
|
+
Parent: Error
|
1146
|
+
});
|
1147
|
+
function flattenError(error, mapper = (issue)=>issue.message) {
|
1148
|
+
const fieldErrors = {};
|
1149
|
+
const formErrors = [];
|
1150
|
+
for (const sub of error.issues)if (sub.path.length > 0) {
|
1151
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
1152
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
1153
|
+
} else formErrors.push(mapper(sub));
|
1154
|
+
return {
|
1155
|
+
formErrors,
|
1156
|
+
fieldErrors
|
1157
|
+
};
|
1158
|
+
}
|
1159
|
+
function formatError(error, _mapper) {
|
1160
|
+
const mapper = _mapper || function(issue) {
|
1161
|
+
return issue.message;
|
1162
|
+
};
|
1163
|
+
const fieldErrors = {
|
1164
|
+
_errors: []
|
1165
|
+
};
|
1166
|
+
const processError = (error)=>{
|
1167
|
+
for (const issue of error.issues)if ("invalid_union" === issue.code && issue.errors.length) issue.errors.map((issues)=>processError({
|
1168
|
+
issues
|
1169
|
+
}));
|
1170
|
+
else if ("invalid_key" === issue.code) processError({
|
1171
|
+
issues: issue.issues
|
1172
|
+
});
|
1173
|
+
else if ("invalid_element" === issue.code) processError({
|
1174
|
+
issues: issue.issues
|
1175
|
+
});
|
1176
|
+
else if (0 === issue.path.length) fieldErrors._errors.push(mapper(issue));
|
1177
|
+
else {
|
1178
|
+
let curr = fieldErrors;
|
1179
|
+
let i = 0;
|
1180
|
+
while(i < issue.path.length){
|
1181
|
+
const el = issue.path[i];
|
1182
|
+
const terminal = i === issue.path.length - 1;
|
1183
|
+
if (terminal) {
|
1184
|
+
curr[el] = curr[el] || {
|
1185
|
+
_errors: []
|
1186
|
+
};
|
1187
|
+
curr[el]._errors.push(mapper(issue));
|
1188
|
+
} else curr[el] = curr[el] || {
|
1189
|
+
_errors: []
|
1190
|
+
};
|
1191
|
+
curr = curr[el];
|
1192
|
+
i++;
|
1193
|
+
}
|
1194
|
+
}
|
1195
|
+
};
|
1196
|
+
processError(error);
|
1197
|
+
return fieldErrors;
|
1198
|
+
}
|
1199
|
+
const _parse = (_Err)=>(schema, value, _ctx, _params)=>{
|
1200
|
+
const ctx = _ctx ? Object.assign(_ctx, {
|
1201
|
+
async: false
|
1202
|
+
}) : {
|
1203
|
+
async: false
|
1204
|
+
};
|
1205
|
+
const result = schema._zod.run({
|
1206
|
+
value,
|
1207
|
+
issues: []
|
1208
|
+
}, ctx);
|
1209
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
1210
|
+
if (result.issues.length) {
|
1211
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
1212
|
+
captureStackTrace(e, _params?.callee);
|
1213
|
+
throw e;
|
1214
|
+
}
|
1215
|
+
return result.value;
|
1216
|
+
};
|
1217
|
+
const _parseAsync = (_Err)=>async (schema, value, _ctx, params)=>{
|
1218
|
+
const ctx = _ctx ? Object.assign(_ctx, {
|
1219
|
+
async: true
|
1220
|
+
}) : {
|
1221
|
+
async: true
|
1222
|
+
};
|
1223
|
+
let result = schema._zod.run({
|
1224
|
+
value,
|
1225
|
+
issues: []
|
1226
|
+
}, ctx);
|
1227
|
+
if (result instanceof Promise) result = await result;
|
1228
|
+
if (result.issues.length) {
|
1229
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())));
|
1230
|
+
captureStackTrace(e, params?.callee);
|
1231
|
+
throw e;
|
1232
|
+
}
|
1233
|
+
return result.value;
|
1234
|
+
};
|
1235
|
+
const _safeParse = (_Err)=>(schema, value, _ctx)=>{
|
1236
|
+
const ctx = _ctx ? {
|
1237
|
+
..._ctx,
|
1238
|
+
async: false
|
1239
|
+
} : {
|
1240
|
+
async: false
|
1241
|
+
};
|
1242
|
+
const result = schema._zod.run({
|
1243
|
+
value,
|
1244
|
+
issues: []
|
1245
|
+
}, ctx);
|
1246
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
1247
|
+
return result.issues.length ? {
|
1248
|
+
success: false,
|
1249
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
1250
|
+
} : {
|
1251
|
+
success: true,
|
1252
|
+
data: result.value
|
1253
|
+
};
|
1254
|
+
};
|
1255
|
+
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
|
1256
|
+
const _safeParseAsync = (_Err)=>async (schema, value, _ctx)=>{
|
1257
|
+
const ctx = _ctx ? Object.assign(_ctx, {
|
1258
|
+
async: true
|
1259
|
+
}) : {
|
1260
|
+
async: true
|
1261
|
+
};
|
1262
|
+
let result = schema._zod.run({
|
1263
|
+
value,
|
1264
|
+
issues: []
|
1265
|
+
}, ctx);
|
1266
|
+
if (result instanceof Promise) result = await result;
|
1267
|
+
return result.issues.length ? {
|
1268
|
+
success: false,
|
1269
|
+
error: new _Err(result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
1270
|
+
} : {
|
1271
|
+
success: true,
|
1272
|
+
data: result.value
|
1273
|
+
};
|
1274
|
+
};
|
1275
|
+
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
|
1276
|
+
const versions_version = {
|
1277
|
+
major: 4,
|
1278
|
+
minor: 0,
|
1279
|
+
patch: 14
|
1280
|
+
};
|
1281
|
+
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def)=>{
|
1282
|
+
var _a;
|
1283
|
+
inst ?? (inst = {});
|
1284
|
+
inst._zod.def = def;
|
1285
|
+
inst._zod.bag = inst._zod.bag || {};
|
1286
|
+
inst._zod.version = versions_version;
|
1287
|
+
const checks = [
|
1288
|
+
...inst._zod.def.checks ?? []
|
1289
|
+
];
|
1290
|
+
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
1291
|
+
for (const ch of checks)for (const fn of ch._zod.onattach)fn(inst);
|
1292
|
+
if (0 === checks.length) {
|
1293
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
1294
|
+
inst._zod.deferred?.push(()=>{
|
1295
|
+
inst._zod.run = inst._zod.parse;
|
1296
|
+
});
|
1297
|
+
} else {
|
1298
|
+
const runChecks = (payload, checks, ctx)=>{
|
1299
|
+
let isAborted = aborted(payload);
|
1300
|
+
let asyncResult;
|
1301
|
+
for (const ch of checks){
|
1302
|
+
if (ch._zod.def.when) {
|
1303
|
+
const shouldRun = ch._zod.def.when(payload);
|
1304
|
+
if (!shouldRun) continue;
|
1305
|
+
} else if (isAborted) continue;
|
1306
|
+
const currLen = payload.issues.length;
|
1307
|
+
const _ = ch._zod.check(payload);
|
1308
|
+
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
1309
|
+
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async ()=>{
|
1310
|
+
await _;
|
1311
|
+
const nextLen = payload.issues.length;
|
1312
|
+
if (nextLen === currLen) return;
|
1313
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
1314
|
+
});
|
1315
|
+
else {
|
1316
|
+
const nextLen = payload.issues.length;
|
1317
|
+
if (nextLen === currLen) continue;
|
1318
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
1319
|
+
}
|
1320
|
+
}
|
1321
|
+
if (asyncResult) return asyncResult.then(()=>payload);
|
1322
|
+
return payload;
|
1323
|
+
};
|
1324
|
+
inst._zod.run = (payload, ctx)=>{
|
1325
|
+
const result = inst._zod.parse(payload, ctx);
|
1326
|
+
if (result instanceof Promise) {
|
1327
|
+
if (false === ctx.async) throw new $ZodAsyncError();
|
1328
|
+
return result.then((result)=>runChecks(result, checks, ctx));
|
1329
|
+
}
|
1330
|
+
return runChecks(result, checks, ctx);
|
1331
|
+
};
|
1332
|
+
}
|
1333
|
+
inst["~standard"] = {
|
1334
|
+
validate: (value)=>{
|
1335
|
+
try {
|
1336
|
+
const r = safeParse(inst, value);
|
1337
|
+
return r.success ? {
|
1338
|
+
value: r.data
|
1339
|
+
} : {
|
1340
|
+
issues: r.error?.issues
|
1341
|
+
};
|
1342
|
+
} catch (_) {
|
1343
|
+
return safeParseAsync(inst, value).then((r)=>r.success ? {
|
1344
|
+
value: r.data
|
1345
|
+
} : {
|
1346
|
+
issues: r.error?.issues
|
1347
|
+
});
|
1348
|
+
}
|
1349
|
+
},
|
1350
|
+
vendor: "zod",
|
1351
|
+
version: 1
|
1352
|
+
};
|
1353
|
+
});
|
1354
|
+
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def)=>{
|
1355
|
+
$ZodType.init(inst, def);
|
1356
|
+
inst._zod.pattern = [
|
1357
|
+
...inst?._zod.bag?.patterns ?? []
|
1358
|
+
].pop() ?? string(inst._zod.bag);
|
1359
|
+
inst._zod.parse = (payload, _)=>{
|
1360
|
+
if (def.coerce) try {
|
1361
|
+
payload.value = String(payload.value);
|
1362
|
+
} catch (_) {}
|
1363
|
+
if ("string" == typeof payload.value) return payload;
|
1364
|
+
payload.issues.push({
|
1365
|
+
expected: "string",
|
1366
|
+
code: "invalid_type",
|
1367
|
+
input: payload.value,
|
1368
|
+
inst
|
1369
|
+
});
|
1370
|
+
return payload;
|
1371
|
+
};
|
1372
|
+
});
|
1373
|
+
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def)=>{
|
1374
|
+
$ZodCheckStringFormat.init(inst, def);
|
1375
|
+
$ZodString.init(inst, def);
|
1376
|
+
});
|
1377
|
+
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def)=>{
|
1378
|
+
def.pattern ?? (def.pattern = guid);
|
1379
|
+
$ZodStringFormat.init(inst, def);
|
1380
|
+
});
|
1381
|
+
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def)=>{
|
1382
|
+
if (def.version) {
|
1383
|
+
const versionMap = {
|
1384
|
+
v1: 1,
|
1385
|
+
v2: 2,
|
1386
|
+
v3: 3,
|
1387
|
+
v4: 4,
|
1388
|
+
v5: 5,
|
1389
|
+
v6: 6,
|
1390
|
+
v7: 7,
|
1391
|
+
v8: 8
|
1392
|
+
};
|
1393
|
+
const v = versionMap[def.version];
|
1394
|
+
if (void 0 === v) throw new Error(`Invalid UUID version: "${def.version}"`);
|
1395
|
+
def.pattern ?? (def.pattern = uuid(v));
|
1396
|
+
} else def.pattern ?? (def.pattern = uuid());
|
1397
|
+
$ZodStringFormat.init(inst, def);
|
1398
|
+
});
|
1399
|
+
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def)=>{
|
1400
|
+
def.pattern ?? (def.pattern = email);
|
1401
|
+
$ZodStringFormat.init(inst, def);
|
1402
|
+
});
|
1403
|
+
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def)=>{
|
1404
|
+
$ZodStringFormat.init(inst, def);
|
1405
|
+
inst._zod.check = (payload)=>{
|
1406
|
+
try {
|
1407
|
+
const trimmed = payload.value.trim();
|
1408
|
+
const url = new URL(trimmed);
|
1409
|
+
if (def.hostname) {
|
1410
|
+
def.hostname.lastIndex = 0;
|
1411
|
+
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
1412
|
+
code: "invalid_format",
|
1413
|
+
format: "url",
|
1414
|
+
note: "Invalid hostname",
|
1415
|
+
pattern: hostname.source,
|
1416
|
+
input: payload.value,
|
1417
|
+
inst,
|
1418
|
+
continue: !def.abort
|
1419
|
+
});
|
1420
|
+
}
|
1421
|
+
if (def.protocol) {
|
1422
|
+
def.protocol.lastIndex = 0;
|
1423
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
1424
|
+
code: "invalid_format",
|
1425
|
+
format: "url",
|
1426
|
+
note: "Invalid protocol",
|
1427
|
+
pattern: def.protocol.source,
|
1428
|
+
input: payload.value,
|
1429
|
+
inst,
|
1430
|
+
continue: !def.abort
|
1431
|
+
});
|
1432
|
+
}
|
1433
|
+
if (def.normalize) payload.value = url.href;
|
1434
|
+
else payload.value = trimmed;
|
1435
|
+
return;
|
1436
|
+
} catch (_) {
|
1437
|
+
payload.issues.push({
|
1438
|
+
code: "invalid_format",
|
1439
|
+
format: "url",
|
1440
|
+
input: payload.value,
|
1441
|
+
inst,
|
1442
|
+
continue: !def.abort
|
1443
|
+
});
|
1444
|
+
}
|
1445
|
+
};
|
1446
|
+
});
|
1447
|
+
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def)=>{
|
1448
|
+
def.pattern ?? (def.pattern = emoji());
|
1449
|
+
$ZodStringFormat.init(inst, def);
|
1450
|
+
});
|
1451
|
+
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def)=>{
|
1452
|
+
def.pattern ?? (def.pattern = nanoid);
|
1453
|
+
$ZodStringFormat.init(inst, def);
|
1454
|
+
});
|
1455
|
+
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def)=>{
|
1456
|
+
def.pattern ?? (def.pattern = cuid);
|
1457
|
+
$ZodStringFormat.init(inst, def);
|
1458
|
+
});
|
1459
|
+
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def)=>{
|
1460
|
+
def.pattern ?? (def.pattern = cuid2);
|
1461
|
+
$ZodStringFormat.init(inst, def);
|
1462
|
+
});
|
1463
|
+
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def)=>{
|
1464
|
+
def.pattern ?? (def.pattern = ulid);
|
1465
|
+
$ZodStringFormat.init(inst, def);
|
1466
|
+
});
|
1467
|
+
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def)=>{
|
1468
|
+
def.pattern ?? (def.pattern = xid);
|
1469
|
+
$ZodStringFormat.init(inst, def);
|
1470
|
+
});
|
1471
|
+
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def)=>{
|
1472
|
+
def.pattern ?? (def.pattern = ksuid);
|
1473
|
+
$ZodStringFormat.init(inst, def);
|
1474
|
+
});
|
1475
|
+
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def)=>{
|
1476
|
+
def.pattern ?? (def.pattern = datetime(def));
|
1477
|
+
$ZodStringFormat.init(inst, def);
|
1478
|
+
});
|
1479
|
+
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def)=>{
|
1480
|
+
def.pattern ?? (def.pattern = date);
|
1481
|
+
$ZodStringFormat.init(inst, def);
|
1482
|
+
});
|
1483
|
+
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def)=>{
|
1484
|
+
def.pattern ?? (def.pattern = regexes_time(def));
|
1485
|
+
$ZodStringFormat.init(inst, def);
|
1486
|
+
});
|
1487
|
+
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def)=>{
|
1488
|
+
def.pattern ?? (def.pattern = duration);
|
1489
|
+
$ZodStringFormat.init(inst, def);
|
1490
|
+
});
|
1491
|
+
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def)=>{
|
1492
|
+
def.pattern ?? (def.pattern = ipv4);
|
1493
|
+
$ZodStringFormat.init(inst, def);
|
1494
|
+
inst._zod.onattach.push((inst)=>{
|
1495
|
+
const bag = inst._zod.bag;
|
1496
|
+
bag.format = "ipv4";
|
1497
|
+
});
|
1498
|
+
});
|
1499
|
+
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def)=>{
|
1500
|
+
def.pattern ?? (def.pattern = ipv6);
|
1501
|
+
$ZodStringFormat.init(inst, def);
|
1502
|
+
inst._zod.onattach.push((inst)=>{
|
1503
|
+
const bag = inst._zod.bag;
|
1504
|
+
bag.format = "ipv6";
|
1505
|
+
});
|
1506
|
+
inst._zod.check = (payload)=>{
|
1507
|
+
try {
|
1508
|
+
new URL(`http://[${payload.value}]`);
|
1509
|
+
} catch {
|
1510
|
+
payload.issues.push({
|
1511
|
+
code: "invalid_format",
|
1512
|
+
format: "ipv6",
|
1513
|
+
input: payload.value,
|
1514
|
+
inst,
|
1515
|
+
continue: !def.abort
|
1516
|
+
});
|
1517
|
+
}
|
1518
|
+
};
|
1519
|
+
});
|
1520
|
+
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def)=>{
|
1521
|
+
def.pattern ?? (def.pattern = cidrv4);
|
1522
|
+
$ZodStringFormat.init(inst, def);
|
1523
|
+
});
|
1524
|
+
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def)=>{
|
1525
|
+
def.pattern ?? (def.pattern = cidrv6);
|
1526
|
+
$ZodStringFormat.init(inst, def);
|
1527
|
+
inst._zod.check = (payload)=>{
|
1528
|
+
const [address, prefix] = payload.value.split("/");
|
1529
|
+
try {
|
1530
|
+
if (!prefix) throw new Error();
|
1531
|
+
const prefixNum = Number(prefix);
|
1532
|
+
if (`${prefixNum}` !== prefix) throw new Error();
|
1533
|
+
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
1534
|
+
new URL(`http://[${address}]`);
|
1535
|
+
} catch {
|
1536
|
+
payload.issues.push({
|
1537
|
+
code: "invalid_format",
|
1538
|
+
format: "cidrv6",
|
1539
|
+
input: payload.value,
|
1540
|
+
inst,
|
1541
|
+
continue: !def.abort
|
1542
|
+
});
|
1543
|
+
}
|
1544
|
+
};
|
1545
|
+
});
|
1546
|
+
function isValidBase64(data) {
|
1547
|
+
if ("" === data) return true;
|
1548
|
+
if (data.length % 4 !== 0) return false;
|
1549
|
+
try {
|
1550
|
+
atob(data);
|
1551
|
+
return true;
|
1552
|
+
} catch {
|
1553
|
+
return false;
|
1554
|
+
}
|
1555
|
+
}
|
1556
|
+
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def)=>{
|
1557
|
+
def.pattern ?? (def.pattern = regexes_base64);
|
1558
|
+
$ZodStringFormat.init(inst, def);
|
1559
|
+
inst._zod.onattach.push((inst)=>{
|
1560
|
+
inst._zod.bag.contentEncoding = "base64";
|
1561
|
+
});
|
1562
|
+
inst._zod.check = (payload)=>{
|
1563
|
+
if (isValidBase64(payload.value)) return;
|
1564
|
+
payload.issues.push({
|
1565
|
+
code: "invalid_format",
|
1566
|
+
format: "base64",
|
1567
|
+
input: payload.value,
|
1568
|
+
inst,
|
1569
|
+
continue: !def.abort
|
1570
|
+
});
|
1571
|
+
};
|
1572
|
+
});
|
1573
|
+
function isValidBase64URL(data) {
|
1574
|
+
if (!base64url.test(data)) return false;
|
1575
|
+
const base64 = data.replace(/[-_]/g, (c)=>"-" === c ? "+" : "/");
|
1576
|
+
const padded = base64.padEnd(4 * Math.ceil(base64.length / 4), "=");
|
1577
|
+
return isValidBase64(padded);
|
1578
|
+
}
|
1579
|
+
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def)=>{
|
1580
|
+
def.pattern ?? (def.pattern = base64url);
|
1581
|
+
$ZodStringFormat.init(inst, def);
|
1582
|
+
inst._zod.onattach.push((inst)=>{
|
1583
|
+
inst._zod.bag.contentEncoding = "base64url";
|
1584
|
+
});
|
1585
|
+
inst._zod.check = (payload)=>{
|
1586
|
+
if (isValidBase64URL(payload.value)) return;
|
1587
|
+
payload.issues.push({
|
1588
|
+
code: "invalid_format",
|
1589
|
+
format: "base64url",
|
1590
|
+
input: payload.value,
|
1591
|
+
inst,
|
1592
|
+
continue: !def.abort
|
1593
|
+
});
|
1594
|
+
};
|
1595
|
+
});
|
1596
|
+
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def)=>{
|
1597
|
+
def.pattern ?? (def.pattern = e164);
|
1598
|
+
$ZodStringFormat.init(inst, def);
|
1599
|
+
});
|
1600
|
+
function isValidJWT(token, algorithm = null) {
|
1601
|
+
try {
|
1602
|
+
const tokensParts = token.split(".");
|
1603
|
+
if (3 !== tokensParts.length) return false;
|
1604
|
+
const [header] = tokensParts;
|
1605
|
+
if (!header) return false;
|
1606
|
+
const parsedHeader = JSON.parse(atob(header));
|
1607
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
1608
|
+
if (!parsedHeader.alg) return false;
|
1609
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
1610
|
+
return true;
|
1611
|
+
} catch {
|
1612
|
+
return false;
|
1613
|
+
}
|
1614
|
+
}
|
1615
|
+
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def)=>{
|
1616
|
+
$ZodStringFormat.init(inst, def);
|
1617
|
+
inst._zod.check = (payload)=>{
|
1618
|
+
if (isValidJWT(payload.value, def.alg)) return;
|
1619
|
+
payload.issues.push({
|
1620
|
+
code: "invalid_format",
|
1621
|
+
format: "jwt",
|
1622
|
+
input: payload.value,
|
1623
|
+
inst,
|
1624
|
+
continue: !def.abort
|
1625
|
+
});
|
1626
|
+
};
|
1627
|
+
});
|
1628
|
+
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def)=>{
|
1629
|
+
$ZodType.init(inst, def);
|
1630
|
+
inst._zod.pattern = inst._zod.bag.pattern ?? number;
|
1631
|
+
inst._zod.parse = (payload, _ctx)=>{
|
1632
|
+
if (def.coerce) try {
|
1633
|
+
payload.value = Number(payload.value);
|
1634
|
+
} catch (_) {}
|
1635
|
+
const input = payload.value;
|
1636
|
+
if ("number" == typeof input && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
1637
|
+
const received = "number" == typeof input ? Number.isNaN(input) ? "NaN" : Number.isFinite(input) ? void 0 : "Infinity" : void 0;
|
1638
|
+
payload.issues.push({
|
1639
|
+
expected: "number",
|
1640
|
+
code: "invalid_type",
|
1641
|
+
input,
|
1642
|
+
inst,
|
1643
|
+
...received ? {
|
1644
|
+
received
|
1645
|
+
} : {}
|
1646
|
+
});
|
1647
|
+
return payload;
|
1648
|
+
};
|
1649
|
+
});
|
1650
|
+
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def)=>{
|
1651
|
+
$ZodCheckNumberFormat.init(inst, def);
|
1652
|
+
$ZodNumber.init(inst, def);
|
1653
|
+
});
|
1654
|
+
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def)=>{
|
1655
|
+
$ZodType.init(inst, def);
|
1656
|
+
inst._zod.pattern = regexes_boolean;
|
1657
|
+
inst._zod.parse = (payload, _ctx)=>{
|
1658
|
+
if (def.coerce) try {
|
1659
|
+
payload.value = Boolean(payload.value);
|
1660
|
+
} catch (_) {}
|
1661
|
+
const input = payload.value;
|
1662
|
+
if ("boolean" == typeof input) return payload;
|
1663
|
+
payload.issues.push({
|
1664
|
+
expected: "boolean",
|
1665
|
+
code: "invalid_type",
|
1666
|
+
input,
|
1667
|
+
inst
|
1668
|
+
});
|
1669
|
+
return payload;
|
1670
|
+
};
|
1671
|
+
});
|
1672
|
+
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (inst, def)=>{
|
1673
|
+
$ZodType.init(inst, def);
|
1674
|
+
inst._zod.pattern = _undefined;
|
1675
|
+
inst._zod.values = new Set([
|
1676
|
+
void 0
|
1677
|
+
]);
|
1678
|
+
inst._zod.optin = "optional";
|
1679
|
+
inst._zod.optout = "optional";
|
1680
|
+
inst._zod.parse = (payload, _ctx)=>{
|
1681
|
+
const input = payload.value;
|
1682
|
+
if (void 0 === input) return payload;
|
1683
|
+
payload.issues.push({
|
1684
|
+
expected: "undefined",
|
1685
|
+
code: "invalid_type",
|
1686
|
+
input,
|
1687
|
+
inst
|
1688
|
+
});
|
1689
|
+
return payload;
|
1690
|
+
};
|
1691
|
+
});
|
1692
|
+
const $ZodAny = /*@__PURE__*/ $constructor("$ZodAny", (inst, def)=>{
|
1693
|
+
$ZodType.init(inst, def);
|
1694
|
+
inst._zod.parse = (payload)=>payload;
|
1695
|
+
});
|
1696
|
+
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def)=>{
|
1697
|
+
$ZodType.init(inst, def);
|
1698
|
+
inst._zod.parse = (payload)=>payload;
|
1699
|
+
});
|
1700
|
+
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def)=>{
|
1701
|
+
$ZodType.init(inst, def);
|
1702
|
+
inst._zod.parse = (payload, _ctx)=>{
|
1703
|
+
payload.issues.push({
|
1704
|
+
expected: "never",
|
1705
|
+
code: "invalid_type",
|
1706
|
+
input: payload.value,
|
1707
|
+
inst
|
1708
|
+
});
|
1709
|
+
return payload;
|
1710
|
+
};
|
1711
|
+
});
|
1712
|
+
function handleArrayResult(result, final, index) {
|
1713
|
+
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
1714
|
+
final.value[index] = result.value;
|
1715
|
+
}
|
1716
|
+
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def)=>{
|
1717
|
+
$ZodType.init(inst, def);
|
1718
|
+
inst._zod.parse = (payload, ctx)=>{
|
1719
|
+
const input = payload.value;
|
1720
|
+
if (!Array.isArray(input)) {
|
1721
|
+
payload.issues.push({
|
1722
|
+
expected: "array",
|
1723
|
+
code: "invalid_type",
|
1724
|
+
input,
|
1725
|
+
inst
|
1726
|
+
});
|
1727
|
+
return payload;
|
1728
|
+
}
|
1729
|
+
payload.value = Array(input.length);
|
1730
|
+
const proms = [];
|
1731
|
+
for(let i = 0; i < input.length; i++){
|
1732
|
+
const item = input[i];
|
1733
|
+
const result = def.element._zod.run({
|
1734
|
+
value: item,
|
1735
|
+
issues: []
|
1736
|
+
}, ctx);
|
1737
|
+
if (result instanceof Promise) proms.push(result.then((result)=>handleArrayResult(result, payload, i)));
|
1738
|
+
else handleArrayResult(result, payload, i);
|
1739
|
+
}
|
1740
|
+
if (proms.length) return Promise.all(proms).then(()=>payload);
|
1741
|
+
return payload;
|
1742
|
+
};
|
1743
|
+
});
|
1744
|
+
function handlePropertyResult(result, final, key, input) {
|
1745
|
+
if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
|
1746
|
+
if (void 0 === result.value) {
|
1747
|
+
if (key in input) final.value[key] = void 0;
|
1748
|
+
} else final.value[key] = result.value;
|
1749
|
+
}
|
1750
|
+
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def)=>{
|
1751
|
+
$ZodType.init(inst, def);
|
1752
|
+
const _normalized = cached(()=>{
|
1753
|
+
const keys = Object.keys(def.shape);
|
1754
|
+
for (const k of keys)if (!(def.shape[k] instanceof $ZodType)) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
1755
|
+
const okeys = optionalKeys(def.shape);
|
1756
|
+
return {
|
1757
|
+
shape: def.shape,
|
1758
|
+
keys,
|
1759
|
+
keySet: new Set(keys),
|
1760
|
+
numKeys: keys.length,
|
1761
|
+
optionalKeys: new Set(okeys)
|
1762
|
+
};
|
1763
|
+
});
|
1764
|
+
defineLazy(inst._zod, "propValues", ()=>{
|
1765
|
+
const shape = def.shape;
|
1766
|
+
const propValues = {};
|
1767
|
+
for(const key in shape){
|
1768
|
+
const field = shape[key]._zod;
|
1769
|
+
if (field.values) {
|
1770
|
+
propValues[key] ?? (propValues[key] = new Set());
|
1771
|
+
for (const v of field.values)propValues[key].add(v);
|
1772
|
+
}
|
1773
|
+
}
|
1774
|
+
return propValues;
|
1775
|
+
});
|
1776
|
+
const generateFastpass = (shape)=>{
|
1777
|
+
const doc = new Doc([
|
1778
|
+
"shape",
|
1779
|
+
"payload",
|
1780
|
+
"ctx"
|
1781
|
+
]);
|
1782
|
+
const normalized = _normalized.value;
|
1783
|
+
const parseStr = (key)=>{
|
1784
|
+
const k = esc(key);
|
1785
|
+
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
1786
|
+
};
|
1787
|
+
doc.write("const input = payload.value;");
|
1788
|
+
const ids = Object.create(null);
|
1789
|
+
let counter = 0;
|
1790
|
+
for (const key of normalized.keys)ids[key] = `key_${counter++}`;
|
1791
|
+
doc.write("const newResult = {}");
|
1792
|
+
for (const key of normalized.keys){
|
1793
|
+
const id = ids[key];
|
1794
|
+
const k = esc(key);
|
1795
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
1796
|
+
doc.write(`
|
1797
|
+
if (${id}.issues.length) {
|
1798
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
1799
|
+
...iss,
|
1800
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
1801
|
+
})));
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
if (${id}.value === undefined) {
|
1805
|
+
if (${k} in input) {
|
1806
|
+
newResult[${k}] = undefined;
|
1807
|
+
}
|
1808
|
+
} else {
|
1809
|
+
newResult[${k}] = ${id}.value;
|
1810
|
+
}
|
1811
|
+
`);
|
1812
|
+
}
|
1813
|
+
doc.write("payload.value = newResult;");
|
1814
|
+
doc.write("return payload;");
|
1815
|
+
const fn = doc.compile();
|
1816
|
+
return (payload, ctx)=>fn(shape, payload, ctx);
|
1817
|
+
};
|
1818
|
+
let fastpass;
|
1819
|
+
const isObject = util_isObject;
|
1820
|
+
const jit = !globalConfig.jitless;
|
1821
|
+
const allowsEval = util_allowsEval;
|
1822
|
+
const fastEnabled = jit && allowsEval.value;
|
1823
|
+
const catchall = def.catchall;
|
1824
|
+
let value;
|
1825
|
+
inst._zod.parse = (payload, ctx)=>{
|
1826
|
+
value ?? (value = _normalized.value);
|
1827
|
+
const input = payload.value;
|
1828
|
+
if (!isObject(input)) {
|
1829
|
+
payload.issues.push({
|
1830
|
+
expected: "object",
|
1831
|
+
code: "invalid_type",
|
1832
|
+
input,
|
1833
|
+
inst
|
1834
|
+
});
|
1835
|
+
return payload;
|
1836
|
+
}
|
1837
|
+
const proms = [];
|
1838
|
+
if (jit && fastEnabled && ctx?.async === false && true !== ctx.jitless) {
|
1839
|
+
if (!fastpass) fastpass = generateFastpass(def.shape);
|
1840
|
+
payload = fastpass(payload, ctx);
|
1841
|
+
} else {
|
1842
|
+
payload.value = {};
|
1843
|
+
const shape = value.shape;
|
1844
|
+
for (const key of value.keys){
|
1845
|
+
const el = shape[key];
|
1846
|
+
const r = el._zod.run({
|
1847
|
+
value: input[key],
|
1848
|
+
issues: []
|
1849
|
+
}, ctx);
|
1850
|
+
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input)));
|
1851
|
+
else handlePropertyResult(r, payload, key, input);
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
if (!catchall) return proms.length ? Promise.all(proms).then(()=>payload) : payload;
|
1855
|
+
const unrecognized = [];
|
1856
|
+
const keySet = value.keySet;
|
1857
|
+
const _catchall = catchall._zod;
|
1858
|
+
const t = _catchall.def.type;
|
1859
|
+
for (const key of Object.keys(input)){
|
1860
|
+
if (keySet.has(key)) continue;
|
1861
|
+
if ("never" === t) {
|
1862
|
+
unrecognized.push(key);
|
1863
|
+
continue;
|
1864
|
+
}
|
1865
|
+
const r = _catchall.run({
|
1866
|
+
value: input[key],
|
1867
|
+
issues: []
|
1868
|
+
}, ctx);
|
1869
|
+
if (r instanceof Promise) proms.push(r.then((r)=>handlePropertyResult(r, payload, key, input)));
|
1870
|
+
else handlePropertyResult(r, payload, key, input);
|
1871
|
+
}
|
1872
|
+
if (unrecognized.length) payload.issues.push({
|
1873
|
+
code: "unrecognized_keys",
|
1874
|
+
keys: unrecognized,
|
1875
|
+
input,
|
1876
|
+
inst
|
1877
|
+
});
|
1878
|
+
if (!proms.length) return payload;
|
1879
|
+
return Promise.all(proms).then(()=>payload);
|
1880
|
+
};
|
1881
|
+
});
|
1882
|
+
function handleUnionResults(results, final, inst, ctx) {
|
1883
|
+
for (const result of results)if (0 === result.issues.length) {
|
1884
|
+
final.value = result.value;
|
1885
|
+
return final;
|
1886
|
+
}
|
1887
|
+
const nonaborted = results.filter((r)=>!aborted(r));
|
1888
|
+
if (1 === nonaborted.length) {
|
1889
|
+
final.value = nonaborted[0].value;
|
1890
|
+
return nonaborted[0];
|
1891
|
+
}
|
1892
|
+
final.issues.push({
|
1893
|
+
code: "invalid_union",
|
1894
|
+
input: final.value,
|
1895
|
+
inst,
|
1896
|
+
errors: results.map((result)=>result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())))
|
1897
|
+
});
|
1898
|
+
return final;
|
1899
|
+
}
|
1900
|
+
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def)=>{
|
1901
|
+
$ZodType.init(inst, def);
|
1902
|
+
defineLazy(inst._zod, "optin", ()=>def.options.some((o)=>"optional" === o._zod.optin) ? "optional" : void 0);
|
1903
|
+
defineLazy(inst._zod, "optout", ()=>def.options.some((o)=>"optional" === o._zod.optout) ? "optional" : void 0);
|
1904
|
+
defineLazy(inst._zod, "values", ()=>{
|
1905
|
+
if (def.options.every((o)=>o._zod.values)) return new Set(def.options.flatMap((option)=>Array.from(option._zod.values)));
|
1906
|
+
});
|
1907
|
+
defineLazy(inst._zod, "pattern", ()=>{
|
1908
|
+
if (def.options.every((o)=>o._zod.pattern)) {
|
1909
|
+
const patterns = def.options.map((o)=>o._zod.pattern);
|
1910
|
+
return new RegExp(`^(${patterns.map((p)=>cleanRegex(p.source)).join("|")})$`);
|
1911
|
+
}
|
1912
|
+
});
|
1913
|
+
const single = 1 === def.options.length;
|
1914
|
+
const first = def.options[0]._zod.run;
|
1915
|
+
inst._zod.parse = (payload, ctx)=>{
|
1916
|
+
if (single) return first(payload, ctx);
|
1917
|
+
let async = false;
|
1918
|
+
const results = [];
|
1919
|
+
for (const option of def.options){
|
1920
|
+
const result = option._zod.run({
|
1921
|
+
value: payload.value,
|
1922
|
+
issues: []
|
1923
|
+
}, ctx);
|
1924
|
+
if (result instanceof Promise) {
|
1925
|
+
results.push(result);
|
1926
|
+
async = true;
|
1927
|
+
} else {
|
1928
|
+
if (0 === result.issues.length) return result;
|
1929
|
+
results.push(result);
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
1933
|
+
return Promise.all(results).then((results)=>handleUnionResults(results, payload, inst, ctx));
|
1934
|
+
};
|
1935
|
+
});
|
1936
|
+
const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def)=>{
|
1937
|
+
$ZodUnion.init(inst, def);
|
1938
|
+
const _super = inst._zod.parse;
|
1939
|
+
defineLazy(inst._zod, "propValues", ()=>{
|
1940
|
+
const propValues = {};
|
1941
|
+
for (const option of def.options){
|
1942
|
+
const pv = option._zod.propValues;
|
1943
|
+
if (!pv || 0 === Object.keys(pv).length) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
1944
|
+
for (const [k, v] of Object.entries(pv)){
|
1945
|
+
if (!propValues[k]) propValues[k] = new Set();
|
1946
|
+
for (const val of v)propValues[k].add(val);
|
1947
|
+
}
|
1948
|
+
}
|
1949
|
+
return propValues;
|
1950
|
+
});
|
1951
|
+
const disc = cached(()=>{
|
1952
|
+
const opts = def.options;
|
1953
|
+
const map = new Map();
|
1954
|
+
for (const o of opts){
|
1955
|
+
const values = o._zod.propValues?.[def.discriminator];
|
1956
|
+
if (!values || 0 === values.size) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
1957
|
+
for (const v of values){
|
1958
|
+
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
1959
|
+
map.set(v, o);
|
1960
|
+
}
|
1961
|
+
}
|
1962
|
+
return map;
|
1963
|
+
});
|
1964
|
+
inst._zod.parse = (payload, ctx)=>{
|
1965
|
+
const input = payload.value;
|
1966
|
+
if (!util_isObject(input)) {
|
1967
|
+
payload.issues.push({
|
1968
|
+
code: "invalid_type",
|
1969
|
+
expected: "object",
|
1970
|
+
input,
|
1971
|
+
inst
|
1972
|
+
});
|
1973
|
+
return payload;
|
1974
|
+
}
|
1975
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
1976
|
+
if (opt) return opt._zod.run(payload, ctx);
|
1977
|
+
if (def.unionFallback) return _super(payload, ctx);
|
1978
|
+
payload.issues.push({
|
1979
|
+
code: "invalid_union",
|
1980
|
+
errors: [],
|
1981
|
+
note: "No matching discriminator",
|
1982
|
+
discriminator: def.discriminator,
|
1983
|
+
input,
|
1984
|
+
path: [
|
1985
|
+
def.discriminator
|
1986
|
+
],
|
1987
|
+
inst
|
1988
|
+
});
|
1989
|
+
return payload;
|
1990
|
+
};
|
1991
|
+
});
|
1992
|
+
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def)=>{
|
1993
|
+
$ZodType.init(inst, def);
|
1994
|
+
inst._zod.parse = (payload, ctx)=>{
|
1995
|
+
const input = payload.value;
|
1996
|
+
const left = def.left._zod.run({
|
1997
|
+
value: input,
|
1998
|
+
issues: []
|
1999
|
+
}, ctx);
|
2000
|
+
const right = def.right._zod.run({
|
2001
|
+
value: input,
|
2002
|
+
issues: []
|
2003
|
+
}, ctx);
|
2004
|
+
const async = left instanceof Promise || right instanceof Promise;
|
2005
|
+
if (async) return Promise.all([
|
2006
|
+
left,
|
2007
|
+
right
|
2008
|
+
]).then(([left, right])=>handleIntersectionResults(payload, left, right));
|
2009
|
+
return handleIntersectionResults(payload, left, right);
|
2010
|
+
};
|
2011
|
+
});
|
2012
|
+
function mergeValues(a, b) {
|
2013
|
+
if (a === b) return {
|
2014
|
+
valid: true,
|
2015
|
+
data: a
|
2016
|
+
};
|
2017
|
+
if (a instanceof Date && b instanceof Date && +a === +b) return {
|
2018
|
+
valid: true,
|
2019
|
+
data: a
|
2020
|
+
};
|
2021
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
2022
|
+
const bKeys = Object.keys(b);
|
2023
|
+
const sharedKeys = Object.keys(a).filter((key)=>-1 !== bKeys.indexOf(key));
|
2024
|
+
const newObj = {
|
2025
|
+
...a,
|
2026
|
+
...b
|
2027
|
+
};
|
2028
|
+
for (const key of sharedKeys){
|
2029
|
+
const sharedValue = mergeValues(a[key], b[key]);
|
2030
|
+
if (!sharedValue.valid) return {
|
2031
|
+
valid: false,
|
2032
|
+
mergeErrorPath: [
|
2033
|
+
key,
|
2034
|
+
...sharedValue.mergeErrorPath
|
2035
|
+
]
|
2036
|
+
};
|
2037
|
+
newObj[key] = sharedValue.data;
|
2038
|
+
}
|
2039
|
+
return {
|
2040
|
+
valid: true,
|
2041
|
+
data: newObj
|
2042
|
+
};
|
2043
|
+
}
|
2044
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
2045
|
+
if (a.length !== b.length) return {
|
2046
|
+
valid: false,
|
2047
|
+
mergeErrorPath: []
|
2048
|
+
};
|
2049
|
+
const newArray = [];
|
2050
|
+
for(let index = 0; index < a.length; index++){
|
2051
|
+
const itemA = a[index];
|
2052
|
+
const itemB = b[index];
|
2053
|
+
const sharedValue = mergeValues(itemA, itemB);
|
2054
|
+
if (!sharedValue.valid) return {
|
2055
|
+
valid: false,
|
2056
|
+
mergeErrorPath: [
|
2057
|
+
index,
|
2058
|
+
...sharedValue.mergeErrorPath
|
2059
|
+
]
|
2060
|
+
};
|
2061
|
+
newArray.push(sharedValue.data);
|
2062
|
+
}
|
2063
|
+
return {
|
2064
|
+
valid: true,
|
2065
|
+
data: newArray
|
2066
|
+
};
|
2067
|
+
}
|
2068
|
+
return {
|
2069
|
+
valid: false,
|
2070
|
+
mergeErrorPath: []
|
2071
|
+
};
|
2072
|
+
}
|
2073
|
+
function handleIntersectionResults(result, left, right) {
|
2074
|
+
if (left.issues.length) result.issues.push(...left.issues);
|
2075
|
+
if (right.issues.length) result.issues.push(...right.issues);
|
2076
|
+
if (aborted(result)) return result;
|
2077
|
+
const merged = mergeValues(left.value, right.value);
|
2078
|
+
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
2079
|
+
result.value = merged.data;
|
2080
|
+
return result;
|
2081
|
+
}
|
2082
|
+
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def)=>{
|
2083
|
+
$ZodType.init(inst, def);
|
2084
|
+
inst._zod.parse = (payload, ctx)=>{
|
2085
|
+
const input = payload.value;
|
2086
|
+
if (!isPlainObject(input)) {
|
2087
|
+
payload.issues.push({
|
2088
|
+
expected: "record",
|
2089
|
+
code: "invalid_type",
|
2090
|
+
input,
|
2091
|
+
inst
|
2092
|
+
});
|
2093
|
+
return payload;
|
2094
|
+
}
|
2095
|
+
const proms = [];
|
2096
|
+
if (def.keyType._zod.values) {
|
2097
|
+
const values = def.keyType._zod.values;
|
2098
|
+
payload.value = {};
|
2099
|
+
for (const key of values)if ("string" == typeof key || "number" == typeof key || "symbol" == typeof key) {
|
2100
|
+
const result = def.valueType._zod.run({
|
2101
|
+
value: input[key],
|
2102
|
+
issues: []
|
2103
|
+
}, ctx);
|
2104
|
+
if (result instanceof Promise) proms.push(result.then((result)=>{
|
2105
|
+
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
2106
|
+
payload.value[key] = result.value;
|
2107
|
+
}));
|
2108
|
+
else {
|
2109
|
+
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
2110
|
+
payload.value[key] = result.value;
|
2111
|
+
}
|
2112
|
+
}
|
2113
|
+
let unrecognized;
|
2114
|
+
for(const key in input)if (!values.has(key)) {
|
2115
|
+
unrecognized = unrecognized ?? [];
|
2116
|
+
unrecognized.push(key);
|
2117
|
+
}
|
2118
|
+
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
2119
|
+
code: "unrecognized_keys",
|
2120
|
+
input,
|
2121
|
+
inst,
|
2122
|
+
keys: unrecognized
|
2123
|
+
});
|
2124
|
+
} else {
|
2125
|
+
payload.value = {};
|
2126
|
+
for (const key of Reflect.ownKeys(input)){
|
2127
|
+
if ("__proto__" === key) continue;
|
2128
|
+
const keyResult = def.keyType._zod.run({
|
2129
|
+
value: key,
|
2130
|
+
issues: []
|
2131
|
+
}, ctx);
|
2132
|
+
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
2133
|
+
if (keyResult.issues.length) {
|
2134
|
+
payload.issues.push({
|
2135
|
+
code: "invalid_key",
|
2136
|
+
origin: "record",
|
2137
|
+
issues: keyResult.issues.map((iss)=>finalizeIssue(iss, ctx, core_config())),
|
2138
|
+
input: key,
|
2139
|
+
path: [
|
2140
|
+
key
|
2141
|
+
],
|
2142
|
+
inst
|
2143
|
+
});
|
2144
|
+
payload.value[keyResult.value] = keyResult.value;
|
2145
|
+
continue;
|
2146
|
+
}
|
2147
|
+
const result = def.valueType._zod.run({
|
2148
|
+
value: input[key],
|
2149
|
+
issues: []
|
2150
|
+
}, ctx);
|
2151
|
+
if (result instanceof Promise) proms.push(result.then((result)=>{
|
2152
|
+
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
2153
|
+
payload.value[keyResult.value] = result.value;
|
2154
|
+
}));
|
2155
|
+
else {
|
2156
|
+
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
2157
|
+
payload.value[keyResult.value] = result.value;
|
2158
|
+
}
|
2159
|
+
}
|
2160
|
+
}
|
2161
|
+
if (proms.length) return Promise.all(proms).then(()=>payload);
|
2162
|
+
return payload;
|
2163
|
+
};
|
2164
|
+
});
|
2165
|
+
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def)=>{
|
2166
|
+
$ZodType.init(inst, def);
|
2167
|
+
const values = getEnumValues(def.entries);
|
2168
|
+
const valuesSet = new Set(values);
|
2169
|
+
inst._zod.values = valuesSet;
|
2170
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k)=>propertyKeyTypes.has(typeof k)).map((o)=>"string" == typeof o ? escapeRegex(o) : o.toString()).join("|")})$`);
|
2171
|
+
inst._zod.parse = (payload, _ctx)=>{
|
2172
|
+
const input = payload.value;
|
2173
|
+
if (valuesSet.has(input)) return payload;
|
2174
|
+
payload.issues.push({
|
2175
|
+
code: "invalid_value",
|
2176
|
+
values,
|
2177
|
+
input,
|
2178
|
+
inst
|
2179
|
+
});
|
2180
|
+
return payload;
|
2181
|
+
};
|
2182
|
+
});
|
2183
|
+
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def)=>{
|
2184
|
+
$ZodType.init(inst, def);
|
2185
|
+
if (0 === def.values.length) throw new Error("Cannot create literal schema with no valid values");
|
2186
|
+
inst._zod.values = new Set(def.values);
|
2187
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o)=>"string" == typeof o ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
2188
|
+
inst._zod.parse = (payload, _ctx)=>{
|
2189
|
+
const input = payload.value;
|
2190
|
+
if (inst._zod.values.has(input)) return payload;
|
2191
|
+
payload.issues.push({
|
2192
|
+
code: "invalid_value",
|
2193
|
+
values: def.values,
|
2194
|
+
input,
|
2195
|
+
inst
|
2196
|
+
});
|
2197
|
+
return payload;
|
2198
|
+
};
|
2199
|
+
});
|
2200
|
+
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def)=>{
|
2201
|
+
$ZodType.init(inst, def);
|
2202
|
+
inst._zod.parse = (payload, _ctx)=>{
|
2203
|
+
const _out = def.transform(payload.value, payload);
|
2204
|
+
if (_ctx.async) {
|
2205
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
2206
|
+
return output.then((output)=>{
|
2207
|
+
payload.value = output;
|
2208
|
+
return payload;
|
2209
|
+
});
|
2210
|
+
}
|
2211
|
+
if (_out instanceof Promise) throw new $ZodAsyncError();
|
2212
|
+
payload.value = _out;
|
2213
|
+
return payload;
|
2214
|
+
};
|
2215
|
+
});
|
2216
|
+
function handleOptionalResult(result, input) {
|
2217
|
+
if (result.issues.length && void 0 === input) return {
|
2218
|
+
issues: [],
|
2219
|
+
value: void 0
|
2220
|
+
};
|
2221
|
+
return result;
|
2222
|
+
}
|
2223
|
+
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def)=>{
|
2224
|
+
$ZodType.init(inst, def);
|
2225
|
+
inst._zod.optin = "optional";
|
2226
|
+
inst._zod.optout = "optional";
|
2227
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values ? new Set([
|
2228
|
+
...def.innerType._zod.values,
|
2229
|
+
void 0
|
2230
|
+
]) : void 0);
|
2231
|
+
defineLazy(inst._zod, "pattern", ()=>{
|
2232
|
+
const pattern = def.innerType._zod.pattern;
|
2233
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
2234
|
+
});
|
2235
|
+
inst._zod.parse = (payload, ctx)=>{
|
2236
|
+
if ("optional" === def.innerType._zod.optin) {
|
2237
|
+
const result = def.innerType._zod.run(payload, ctx);
|
2238
|
+
if (result instanceof Promise) return result.then((r)=>handleOptionalResult(r, payload.value));
|
2239
|
+
return handleOptionalResult(result, payload.value);
|
2240
|
+
}
|
2241
|
+
if (void 0 === payload.value) return payload;
|
2242
|
+
return def.innerType._zod.run(payload, ctx);
|
2243
|
+
};
|
2244
|
+
});
|
2245
|
+
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def)=>{
|
2246
|
+
$ZodType.init(inst, def);
|
2247
|
+
defineLazy(inst._zod, "optin", ()=>def.innerType._zod.optin);
|
2248
|
+
defineLazy(inst._zod, "optout", ()=>def.innerType._zod.optout);
|
2249
|
+
defineLazy(inst._zod, "pattern", ()=>{
|
2250
|
+
const pattern = def.innerType._zod.pattern;
|
2251
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
2252
|
+
});
|
2253
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values ? new Set([
|
2254
|
+
...def.innerType._zod.values,
|
2255
|
+
null
|
2256
|
+
]) : void 0);
|
2257
|
+
inst._zod.parse = (payload, ctx)=>{
|
2258
|
+
if (null === payload.value) return payload;
|
2259
|
+
return def.innerType._zod.run(payload, ctx);
|
2260
|
+
};
|
2261
|
+
});
|
2262
|
+
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def)=>{
|
2263
|
+
$ZodType.init(inst, def);
|
2264
|
+
inst._zod.optin = "optional";
|
2265
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values);
|
2266
|
+
inst._zod.parse = (payload, ctx)=>{
|
2267
|
+
if (void 0 === payload.value) {
|
2268
|
+
payload.value = def.defaultValue;
|
2269
|
+
return payload;
|
2270
|
+
}
|
2271
|
+
const result = def.innerType._zod.run(payload, ctx);
|
2272
|
+
if (result instanceof Promise) return result.then((result)=>handleDefaultResult(result, def));
|
2273
|
+
return handleDefaultResult(result, def);
|
2274
|
+
};
|
2275
|
+
});
|
2276
|
+
function handleDefaultResult(payload, def) {
|
2277
|
+
if (void 0 === payload.value) payload.value = def.defaultValue;
|
2278
|
+
return payload;
|
2279
|
+
}
|
2280
|
+
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def)=>{
|
2281
|
+
$ZodType.init(inst, def);
|
2282
|
+
inst._zod.optin = "optional";
|
2283
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values);
|
2284
|
+
inst._zod.parse = (payload, ctx)=>{
|
2285
|
+
if (void 0 === payload.value) payload.value = def.defaultValue;
|
2286
|
+
return def.innerType._zod.run(payload, ctx);
|
2287
|
+
};
|
2288
|
+
});
|
2289
|
+
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def)=>{
|
2290
|
+
$ZodType.init(inst, def);
|
2291
|
+
defineLazy(inst._zod, "values", ()=>{
|
2292
|
+
const v = def.innerType._zod.values;
|
2293
|
+
return v ? new Set([
|
2294
|
+
...v
|
2295
|
+
].filter((x)=>void 0 !== x)) : void 0;
|
2296
|
+
});
|
2297
|
+
inst._zod.parse = (payload, ctx)=>{
|
2298
|
+
const result = def.innerType._zod.run(payload, ctx);
|
2299
|
+
if (result instanceof Promise) return result.then((result)=>handleNonOptionalResult(result, inst));
|
2300
|
+
return handleNonOptionalResult(result, inst);
|
2301
|
+
};
|
2302
|
+
});
|
2303
|
+
function handleNonOptionalResult(payload, inst) {
|
2304
|
+
if (!payload.issues.length && void 0 === payload.value) payload.issues.push({
|
2305
|
+
code: "invalid_type",
|
2306
|
+
expected: "nonoptional",
|
2307
|
+
input: payload.value,
|
2308
|
+
inst
|
2309
|
+
});
|
2310
|
+
return payload;
|
2311
|
+
}
|
2312
|
+
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def)=>{
|
2313
|
+
$ZodType.init(inst, def);
|
2314
|
+
defineLazy(inst._zod, "optin", ()=>def.innerType._zod.optin);
|
2315
|
+
defineLazy(inst._zod, "optout", ()=>def.innerType._zod.optout);
|
2316
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values);
|
2317
|
+
inst._zod.parse = (payload, ctx)=>{
|
2318
|
+
const result = def.innerType._zod.run(payload, ctx);
|
2319
|
+
if (result instanceof Promise) return result.then((result)=>{
|
2320
|
+
payload.value = result.value;
|
2321
|
+
if (result.issues.length) {
|
2322
|
+
payload.value = def.catchValue({
|
2323
|
+
...payload,
|
2324
|
+
error: {
|
2325
|
+
issues: result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config()))
|
2326
|
+
},
|
2327
|
+
input: payload.value
|
2328
|
+
});
|
2329
|
+
payload.issues = [];
|
2330
|
+
}
|
2331
|
+
return payload;
|
2332
|
+
});
|
2333
|
+
payload.value = result.value;
|
2334
|
+
if (result.issues.length) {
|
2335
|
+
payload.value = def.catchValue({
|
2336
|
+
...payload,
|
2337
|
+
error: {
|
2338
|
+
issues: result.issues.map((iss)=>finalizeIssue(iss, ctx, core_config()))
|
2339
|
+
},
|
2340
|
+
input: payload.value
|
2341
|
+
});
|
2342
|
+
payload.issues = [];
|
2343
|
+
}
|
2344
|
+
return payload;
|
2345
|
+
};
|
2346
|
+
});
|
2347
|
+
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def)=>{
|
2348
|
+
$ZodType.init(inst, def);
|
2349
|
+
defineLazy(inst._zod, "values", ()=>def.in._zod.values);
|
2350
|
+
defineLazy(inst._zod, "optin", ()=>def.in._zod.optin);
|
2351
|
+
defineLazy(inst._zod, "optout", ()=>def.out._zod.optout);
|
2352
|
+
defineLazy(inst._zod, "propValues", ()=>def.in._zod.propValues);
|
2353
|
+
inst._zod.parse = (payload, ctx)=>{
|
2354
|
+
const left = def.in._zod.run(payload, ctx);
|
2355
|
+
if (left instanceof Promise) return left.then((left)=>handlePipeResult(left, def, ctx));
|
2356
|
+
return handlePipeResult(left, def, ctx);
|
2357
|
+
};
|
2358
|
+
});
|
2359
|
+
function handlePipeResult(left, def, ctx) {
|
2360
|
+
if (left.issues.length) return left;
|
2361
|
+
return def.out._zod.run({
|
2362
|
+
value: left.value,
|
2363
|
+
issues: left.issues
|
2364
|
+
}, ctx);
|
2365
|
+
}
|
2366
|
+
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def)=>{
|
2367
|
+
$ZodType.init(inst, def);
|
2368
|
+
defineLazy(inst._zod, "propValues", ()=>def.innerType._zod.propValues);
|
2369
|
+
defineLazy(inst._zod, "values", ()=>def.innerType._zod.values);
|
2370
|
+
defineLazy(inst._zod, "optin", ()=>def.innerType._zod.optin);
|
2371
|
+
defineLazy(inst._zod, "optout", ()=>def.innerType._zod.optout);
|
2372
|
+
inst._zod.parse = (payload, ctx)=>{
|
2373
|
+
const result = def.innerType._zod.run(payload, ctx);
|
2374
|
+
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
2375
|
+
return handleReadonlyResult(result);
|
2376
|
+
};
|
2377
|
+
});
|
2378
|
+
function handleReadonlyResult(payload) {
|
2379
|
+
payload.value = Object.freeze(payload.value);
|
2380
|
+
return payload;
|
2381
|
+
}
|
2382
|
+
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def)=>{
|
2383
|
+
$ZodCheck.init(inst, def);
|
2384
|
+
$ZodType.init(inst, def);
|
2385
|
+
inst._zod.parse = (payload, _)=>payload;
|
2386
|
+
inst._zod.check = (payload)=>{
|
2387
|
+
const input = payload.value;
|
2388
|
+
const r = def.fn(input);
|
2389
|
+
if (r instanceof Promise) return r.then((r)=>handleRefineResult(r, payload, input, inst));
|
2390
|
+
handleRefineResult(r, payload, input, inst);
|
2391
|
+
};
|
2392
|
+
});
|
2393
|
+
function handleRefineResult(result, payload, input, inst) {
|
2394
|
+
if (!result) {
|
2395
|
+
const _iss = {
|
2396
|
+
code: "custom",
|
2397
|
+
input,
|
2398
|
+
inst,
|
2399
|
+
path: [
|
2400
|
+
...inst._zod.def.path ?? []
|
2401
|
+
],
|
2402
|
+
continue: !inst._zod.def.abort
|
2403
|
+
};
|
2404
|
+
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
2405
|
+
payload.issues.push(util_issue(_iss));
|
2406
|
+
}
|
2407
|
+
}
|
2408
|
+
Symbol("ZodOutput");
|
2409
|
+
Symbol("ZodInput");
|
2410
|
+
class $ZodRegistry {
|
2411
|
+
constructor(){
|
2412
|
+
this._map = new Map();
|
2413
|
+
this._idmap = new Map();
|
2414
|
+
}
|
2415
|
+
add(schema, ..._meta) {
|
2416
|
+
const meta = _meta[0];
|
2417
|
+
this._map.set(schema, meta);
|
2418
|
+
if (meta && "object" == typeof meta && "id" in meta) {
|
2419
|
+
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
2420
|
+
this._idmap.set(meta.id, schema);
|
2421
|
+
}
|
2422
|
+
return this;
|
2423
|
+
}
|
2424
|
+
clear() {
|
2425
|
+
this._map = new Map();
|
2426
|
+
this._idmap = new Map();
|
2427
|
+
return this;
|
2428
|
+
}
|
2429
|
+
remove(schema) {
|
2430
|
+
const meta = this._map.get(schema);
|
2431
|
+
if (meta && "object" == typeof meta && "id" in meta) this._idmap.delete(meta.id);
|
2432
|
+
this._map.delete(schema);
|
2433
|
+
return this;
|
2434
|
+
}
|
2435
|
+
get(schema) {
|
2436
|
+
const p = schema._zod.parent;
|
2437
|
+
if (p) {
|
2438
|
+
const pm = {
|
2439
|
+
...this.get(p) ?? {}
|
2440
|
+
};
|
2441
|
+
delete pm.id;
|
2442
|
+
const f = {
|
2443
|
+
...pm,
|
2444
|
+
...this._map.get(schema)
|
2445
|
+
};
|
2446
|
+
return Object.keys(f).length ? f : void 0;
|
2447
|
+
}
|
2448
|
+
return this._map.get(schema);
|
2449
|
+
}
|
2450
|
+
has(schema) {
|
2451
|
+
return this._map.has(schema);
|
2452
|
+
}
|
2453
|
+
}
|
2454
|
+
function registry() {
|
2455
|
+
return new $ZodRegistry();
|
2456
|
+
}
|
2457
|
+
const globalRegistry = /*@__PURE__*/ registry();
|
2458
|
+
function _string(Class, params) {
|
2459
|
+
return new Class({
|
2460
|
+
type: "string",
|
2461
|
+
...normalizeParams(params)
|
2462
|
+
});
|
2463
|
+
}
|
2464
|
+
function _email(Class, params) {
|
2465
|
+
return new Class({
|
2466
|
+
type: "string",
|
2467
|
+
format: "email",
|
2468
|
+
check: "string_format",
|
2469
|
+
abort: false,
|
2470
|
+
...normalizeParams(params)
|
2471
|
+
});
|
2472
|
+
}
|
2473
|
+
function _guid(Class, params) {
|
2474
|
+
return new Class({
|
2475
|
+
type: "string",
|
2476
|
+
format: "guid",
|
2477
|
+
check: "string_format",
|
2478
|
+
abort: false,
|
2479
|
+
...normalizeParams(params)
|
2480
|
+
});
|
2481
|
+
}
|
2482
|
+
function _uuid(Class, params) {
|
2483
|
+
return new Class({
|
2484
|
+
type: "string",
|
2485
|
+
format: "uuid",
|
2486
|
+
check: "string_format",
|
2487
|
+
abort: false,
|
2488
|
+
...normalizeParams(params)
|
2489
|
+
});
|
2490
|
+
}
|
2491
|
+
function _uuidv4(Class, params) {
|
2492
|
+
return new Class({
|
2493
|
+
type: "string",
|
2494
|
+
format: "uuid",
|
2495
|
+
check: "string_format",
|
2496
|
+
abort: false,
|
2497
|
+
version: "v4",
|
2498
|
+
...normalizeParams(params)
|
2499
|
+
});
|
2500
|
+
}
|
2501
|
+
function _uuidv6(Class, params) {
|
2502
|
+
return new Class({
|
2503
|
+
type: "string",
|
2504
|
+
format: "uuid",
|
2505
|
+
check: "string_format",
|
2506
|
+
abort: false,
|
2507
|
+
version: "v6",
|
2508
|
+
...normalizeParams(params)
|
2509
|
+
});
|
2510
|
+
}
|
2511
|
+
function _uuidv7(Class, params) {
|
2512
|
+
return new Class({
|
2513
|
+
type: "string",
|
2514
|
+
format: "uuid",
|
2515
|
+
check: "string_format",
|
2516
|
+
abort: false,
|
2517
|
+
version: "v7",
|
2518
|
+
...normalizeParams(params)
|
2519
|
+
});
|
2520
|
+
}
|
2521
|
+
function _url(Class, params) {
|
2522
|
+
return new Class({
|
2523
|
+
type: "string",
|
2524
|
+
format: "url",
|
2525
|
+
check: "string_format",
|
2526
|
+
abort: false,
|
2527
|
+
...normalizeParams(params)
|
2528
|
+
});
|
2529
|
+
}
|
2530
|
+
function api_emoji(Class, params) {
|
2531
|
+
return new Class({
|
2532
|
+
type: "string",
|
2533
|
+
format: "emoji",
|
2534
|
+
check: "string_format",
|
2535
|
+
abort: false,
|
2536
|
+
...normalizeParams(params)
|
2537
|
+
});
|
2538
|
+
}
|
2539
|
+
function _nanoid(Class, params) {
|
2540
|
+
return new Class({
|
2541
|
+
type: "string",
|
2542
|
+
format: "nanoid",
|
2543
|
+
check: "string_format",
|
2544
|
+
abort: false,
|
2545
|
+
...normalizeParams(params)
|
2546
|
+
});
|
2547
|
+
}
|
2548
|
+
function _cuid(Class, params) {
|
2549
|
+
return new Class({
|
2550
|
+
type: "string",
|
2551
|
+
format: "cuid",
|
2552
|
+
check: "string_format",
|
2553
|
+
abort: false,
|
2554
|
+
...normalizeParams(params)
|
2555
|
+
});
|
2556
|
+
}
|
2557
|
+
function _cuid2(Class, params) {
|
2558
|
+
return new Class({
|
2559
|
+
type: "string",
|
2560
|
+
format: "cuid2",
|
2561
|
+
check: "string_format",
|
2562
|
+
abort: false,
|
2563
|
+
...normalizeParams(params)
|
2564
|
+
});
|
2565
|
+
}
|
2566
|
+
function _ulid(Class, params) {
|
2567
|
+
return new Class({
|
2568
|
+
type: "string",
|
2569
|
+
format: "ulid",
|
2570
|
+
check: "string_format",
|
2571
|
+
abort: false,
|
2572
|
+
...normalizeParams(params)
|
2573
|
+
});
|
2574
|
+
}
|
2575
|
+
function _xid(Class, params) {
|
2576
|
+
return new Class({
|
2577
|
+
type: "string",
|
2578
|
+
format: "xid",
|
2579
|
+
check: "string_format",
|
2580
|
+
abort: false,
|
2581
|
+
...normalizeParams(params)
|
2582
|
+
});
|
2583
|
+
}
|
2584
|
+
function _ksuid(Class, params) {
|
2585
|
+
return new Class({
|
2586
|
+
type: "string",
|
2587
|
+
format: "ksuid",
|
2588
|
+
check: "string_format",
|
2589
|
+
abort: false,
|
2590
|
+
...normalizeParams(params)
|
2591
|
+
});
|
2592
|
+
}
|
2593
|
+
function _ipv4(Class, params) {
|
2594
|
+
return new Class({
|
2595
|
+
type: "string",
|
2596
|
+
format: "ipv4",
|
2597
|
+
check: "string_format",
|
2598
|
+
abort: false,
|
2599
|
+
...normalizeParams(params)
|
2600
|
+
});
|
2601
|
+
}
|
2602
|
+
function _ipv6(Class, params) {
|
2603
|
+
return new Class({
|
2604
|
+
type: "string",
|
2605
|
+
format: "ipv6",
|
2606
|
+
check: "string_format",
|
2607
|
+
abort: false,
|
2608
|
+
...normalizeParams(params)
|
2609
|
+
});
|
2610
|
+
}
|
2611
|
+
function _cidrv4(Class, params) {
|
2612
|
+
return new Class({
|
2613
|
+
type: "string",
|
2614
|
+
format: "cidrv4",
|
2615
|
+
check: "string_format",
|
2616
|
+
abort: false,
|
2617
|
+
...normalizeParams(params)
|
2618
|
+
});
|
2619
|
+
}
|
2620
|
+
function _cidrv6(Class, params) {
|
2621
|
+
return new Class({
|
2622
|
+
type: "string",
|
2623
|
+
format: "cidrv6",
|
2624
|
+
check: "string_format",
|
2625
|
+
abort: false,
|
2626
|
+
...normalizeParams(params)
|
2627
|
+
});
|
2628
|
+
}
|
2629
|
+
function _base64(Class, params) {
|
2630
|
+
return new Class({
|
2631
|
+
type: "string",
|
2632
|
+
format: "base64",
|
2633
|
+
check: "string_format",
|
2634
|
+
abort: false,
|
2635
|
+
...normalizeParams(params)
|
2636
|
+
});
|
2637
|
+
}
|
2638
|
+
function _base64url(Class, params) {
|
2639
|
+
return new Class({
|
2640
|
+
type: "string",
|
2641
|
+
format: "base64url",
|
2642
|
+
check: "string_format",
|
2643
|
+
abort: false,
|
2644
|
+
...normalizeParams(params)
|
2645
|
+
});
|
2646
|
+
}
|
2647
|
+
function _e164(Class, params) {
|
2648
|
+
return new Class({
|
2649
|
+
type: "string",
|
2650
|
+
format: "e164",
|
2651
|
+
check: "string_format",
|
2652
|
+
abort: false,
|
2653
|
+
...normalizeParams(params)
|
2654
|
+
});
|
2655
|
+
}
|
2656
|
+
function _jwt(Class, params) {
|
2657
|
+
return new Class({
|
2658
|
+
type: "string",
|
2659
|
+
format: "jwt",
|
2660
|
+
check: "string_format",
|
2661
|
+
abort: false,
|
2662
|
+
...normalizeParams(params)
|
2663
|
+
});
|
2664
|
+
}
|
2665
|
+
function _isoDateTime(Class, params) {
|
2666
|
+
return new Class({
|
2667
|
+
type: "string",
|
2668
|
+
format: "datetime",
|
2669
|
+
check: "string_format",
|
2670
|
+
offset: false,
|
2671
|
+
local: false,
|
2672
|
+
precision: null,
|
2673
|
+
...normalizeParams(params)
|
2674
|
+
});
|
2675
|
+
}
|
2676
|
+
function _isoDate(Class, params) {
|
2677
|
+
return new Class({
|
2678
|
+
type: "string",
|
2679
|
+
format: "date",
|
2680
|
+
check: "string_format",
|
2681
|
+
...normalizeParams(params)
|
2682
|
+
});
|
2683
|
+
}
|
2684
|
+
function _isoTime(Class, params) {
|
2685
|
+
return new Class({
|
2686
|
+
type: "string",
|
2687
|
+
format: "time",
|
2688
|
+
check: "string_format",
|
2689
|
+
precision: null,
|
2690
|
+
...normalizeParams(params)
|
2691
|
+
});
|
2692
|
+
}
|
2693
|
+
function _isoDuration(Class, params) {
|
2694
|
+
return new Class({
|
2695
|
+
type: "string",
|
2696
|
+
format: "duration",
|
2697
|
+
check: "string_format",
|
2698
|
+
...normalizeParams(params)
|
2699
|
+
});
|
2700
|
+
}
|
2701
|
+
function _number(Class, params) {
|
2702
|
+
return new Class({
|
2703
|
+
type: "number",
|
2704
|
+
checks: [],
|
2705
|
+
...normalizeParams(params)
|
2706
|
+
});
|
2707
|
+
}
|
2708
|
+
function _int(Class, params) {
|
2709
|
+
return new Class({
|
2710
|
+
type: "number",
|
2711
|
+
check: "number_format",
|
2712
|
+
abort: false,
|
2713
|
+
format: "safeint",
|
2714
|
+
...normalizeParams(params)
|
2715
|
+
});
|
2716
|
+
}
|
2717
|
+
function _boolean(Class, params) {
|
2718
|
+
return new Class({
|
2719
|
+
type: "boolean",
|
2720
|
+
...normalizeParams(params)
|
2721
|
+
});
|
2722
|
+
}
|
2723
|
+
function api_undefined(Class, params) {
|
2724
|
+
return new Class({
|
2725
|
+
type: "undefined",
|
2726
|
+
...normalizeParams(params)
|
2727
|
+
});
|
2728
|
+
}
|
2729
|
+
function _any(Class) {
|
2730
|
+
return new Class({
|
2731
|
+
type: "any"
|
2732
|
+
});
|
2733
|
+
}
|
2734
|
+
function _unknown(Class) {
|
2735
|
+
return new Class({
|
2736
|
+
type: "unknown"
|
2737
|
+
});
|
2738
|
+
}
|
2739
|
+
function _never(Class, params) {
|
2740
|
+
return new Class({
|
2741
|
+
type: "never",
|
2742
|
+
...normalizeParams(params)
|
2743
|
+
});
|
2744
|
+
}
|
2745
|
+
function _lt(value, params) {
|
2746
|
+
return new $ZodCheckLessThan({
|
2747
|
+
check: "less_than",
|
2748
|
+
...normalizeParams(params),
|
2749
|
+
value,
|
2750
|
+
inclusive: false
|
2751
|
+
});
|
2752
|
+
}
|
2753
|
+
function _lte(value, params) {
|
2754
|
+
return new $ZodCheckLessThan({
|
2755
|
+
check: "less_than",
|
2756
|
+
...normalizeParams(params),
|
2757
|
+
value,
|
2758
|
+
inclusive: true
|
2759
|
+
});
|
2760
|
+
}
|
2761
|
+
function _gt(value, params) {
|
2762
|
+
return new $ZodCheckGreaterThan({
|
2763
|
+
check: "greater_than",
|
2764
|
+
...normalizeParams(params),
|
2765
|
+
value,
|
2766
|
+
inclusive: false
|
2767
|
+
});
|
2768
|
+
}
|
2769
|
+
function _gte(value, params) {
|
2770
|
+
return new $ZodCheckGreaterThan({
|
2771
|
+
check: "greater_than",
|
2772
|
+
...normalizeParams(params),
|
2773
|
+
value,
|
2774
|
+
inclusive: true
|
2775
|
+
});
|
2776
|
+
}
|
2777
|
+
function _multipleOf(value, params) {
|
2778
|
+
return new $ZodCheckMultipleOf({
|
2779
|
+
check: "multiple_of",
|
2780
|
+
...normalizeParams(params),
|
2781
|
+
value
|
2782
|
+
});
|
2783
|
+
}
|
2784
|
+
function _maxLength(maximum, params) {
|
2785
|
+
const ch = new $ZodCheckMaxLength({
|
2786
|
+
check: "max_length",
|
2787
|
+
...normalizeParams(params),
|
2788
|
+
maximum
|
2789
|
+
});
|
2790
|
+
return ch;
|
2791
|
+
}
|
2792
|
+
function _minLength(minimum, params) {
|
2793
|
+
return new $ZodCheckMinLength({
|
2794
|
+
check: "min_length",
|
2795
|
+
...normalizeParams(params),
|
2796
|
+
minimum
|
2797
|
+
});
|
2798
|
+
}
|
2799
|
+
function _length(length, params) {
|
2800
|
+
return new $ZodCheckLengthEquals({
|
2801
|
+
check: "length_equals",
|
2802
|
+
...normalizeParams(params),
|
2803
|
+
length
|
2804
|
+
});
|
2805
|
+
}
|
2806
|
+
function _regex(pattern, params) {
|
2807
|
+
return new $ZodCheckRegex({
|
2808
|
+
check: "string_format",
|
2809
|
+
format: "regex",
|
2810
|
+
...normalizeParams(params),
|
2811
|
+
pattern
|
2812
|
+
});
|
2813
|
+
}
|
2814
|
+
function _lowercase(params) {
|
2815
|
+
return new $ZodCheckLowerCase({
|
2816
|
+
check: "string_format",
|
2817
|
+
format: "lowercase",
|
2818
|
+
...normalizeParams(params)
|
2819
|
+
});
|
2820
|
+
}
|
2821
|
+
function _uppercase(params) {
|
2822
|
+
return new $ZodCheckUpperCase({
|
2823
|
+
check: "string_format",
|
2824
|
+
format: "uppercase",
|
2825
|
+
...normalizeParams(params)
|
2826
|
+
});
|
2827
|
+
}
|
2828
|
+
function _includes(includes, params) {
|
2829
|
+
return new $ZodCheckIncludes({
|
2830
|
+
check: "string_format",
|
2831
|
+
format: "includes",
|
2832
|
+
...normalizeParams(params),
|
2833
|
+
includes
|
2834
|
+
});
|
2835
|
+
}
|
2836
|
+
function _startsWith(prefix, params) {
|
2837
|
+
return new $ZodCheckStartsWith({
|
2838
|
+
check: "string_format",
|
2839
|
+
format: "starts_with",
|
2840
|
+
...normalizeParams(params),
|
2841
|
+
prefix
|
2842
|
+
});
|
2843
|
+
}
|
2844
|
+
function _endsWith(suffix, params) {
|
2845
|
+
return new $ZodCheckEndsWith({
|
2846
|
+
check: "string_format",
|
2847
|
+
format: "ends_with",
|
2848
|
+
...normalizeParams(params),
|
2849
|
+
suffix
|
2850
|
+
});
|
2851
|
+
}
|
2852
|
+
function _overwrite(tx) {
|
2853
|
+
return new $ZodCheckOverwrite({
|
2854
|
+
check: "overwrite",
|
2855
|
+
tx
|
2856
|
+
});
|
2857
|
+
}
|
2858
|
+
function _normalize(form) {
|
2859
|
+
return _overwrite((input)=>input.normalize(form));
|
2860
|
+
}
|
2861
|
+
function _trim() {
|
2862
|
+
return _overwrite((input)=>input.trim());
|
2863
|
+
}
|
2864
|
+
function _toLowerCase() {
|
2865
|
+
return _overwrite((input)=>input.toLowerCase());
|
2866
|
+
}
|
2867
|
+
function _toUpperCase() {
|
2868
|
+
return _overwrite((input)=>input.toUpperCase());
|
2869
|
+
}
|
2870
|
+
function _array(Class, element, params) {
|
2871
|
+
return new Class({
|
2872
|
+
type: "array",
|
2873
|
+
element,
|
2874
|
+
...normalizeParams(params)
|
2875
|
+
});
|
2876
|
+
}
|
2877
|
+
function _refine(Class, fn, _params) {
|
2878
|
+
const schema = new Class({
|
2879
|
+
type: "custom",
|
2880
|
+
check: "custom",
|
2881
|
+
fn: fn,
|
2882
|
+
...normalizeParams(_params)
|
2883
|
+
});
|
2884
|
+
return schema;
|
2885
|
+
}
|
2886
|
+
function _superRefine(fn) {
|
2887
|
+
const ch = _check((payload)=>{
|
2888
|
+
payload.addIssue = (issue)=>{
|
2889
|
+
if ("string" == typeof issue) payload.issues.push(util_issue(issue, payload.value, ch._zod.def));
|
2890
|
+
else {
|
2891
|
+
const _issue = issue;
|
2892
|
+
if (_issue.fatal) _issue.continue = false;
|
2893
|
+
_issue.code ?? (_issue.code = "custom");
|
2894
|
+
_issue.input ?? (_issue.input = payload.value);
|
2895
|
+
_issue.inst ?? (_issue.inst = ch);
|
2896
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
2897
|
+
payload.issues.push(util_issue(_issue));
|
2898
|
+
}
|
2899
|
+
};
|
2900
|
+
return fn(payload.value, payload);
|
2901
|
+
});
|
2902
|
+
return ch;
|
2903
|
+
}
|
2904
|
+
function _check(fn, params) {
|
2905
|
+
const ch = new $ZodCheck({
|
2906
|
+
check: "custom",
|
2907
|
+
...normalizeParams(params)
|
2908
|
+
});
|
2909
|
+
ch._zod.check = fn;
|
2910
|
+
return ch;
|
2911
|
+
}
|
2912
|
+
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def)=>{
|
2913
|
+
$ZodISODateTime.init(inst, def);
|
2914
|
+
ZodStringFormat.init(inst, def);
|
2915
|
+
});
|
2916
|
+
function iso_datetime(params) {
|
2917
|
+
return _isoDateTime(ZodISODateTime, params);
|
2918
|
+
}
|
2919
|
+
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def)=>{
|
2920
|
+
$ZodISODate.init(inst, def);
|
2921
|
+
ZodStringFormat.init(inst, def);
|
2922
|
+
});
|
2923
|
+
function iso_date(params) {
|
2924
|
+
return _isoDate(ZodISODate, params);
|
2925
|
+
}
|
2926
|
+
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def)=>{
|
2927
|
+
$ZodISOTime.init(inst, def);
|
2928
|
+
ZodStringFormat.init(inst, def);
|
2929
|
+
});
|
2930
|
+
function iso_time(params) {
|
2931
|
+
return _isoTime(ZodISOTime, params);
|
2932
|
+
}
|
2933
|
+
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def)=>{
|
2934
|
+
$ZodISODuration.init(inst, def);
|
2935
|
+
ZodStringFormat.init(inst, def);
|
2936
|
+
});
|
2937
|
+
function iso_duration(params) {
|
2938
|
+
return _isoDuration(ZodISODuration, params);
|
2939
|
+
}
|
2940
|
+
const classic_errors_initializer = (inst, issues)=>{
|
2941
|
+
$ZodError.init(inst, issues);
|
2942
|
+
inst.name = "ZodError";
|
2943
|
+
Object.defineProperties(inst, {
|
2944
|
+
format: {
|
2945
|
+
value: (mapper)=>formatError(inst, mapper)
|
2946
|
+
},
|
2947
|
+
flatten: {
|
2948
|
+
value: (mapper)=>flattenError(inst, mapper)
|
2949
|
+
},
|
2950
|
+
addIssue: {
|
2951
|
+
value: (issue)=>{
|
2952
|
+
inst.issues.push(issue);
|
2953
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
2954
|
+
}
|
2955
|
+
},
|
2956
|
+
addIssues: {
|
2957
|
+
value: (issues)=>{
|
2958
|
+
inst.issues.push(...issues);
|
2959
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
2960
|
+
}
|
2961
|
+
},
|
2962
|
+
isEmpty: {
|
2963
|
+
get () {
|
2964
|
+
return 0 === inst.issues.length;
|
2965
|
+
}
|
2966
|
+
}
|
2967
|
+
});
|
2968
|
+
};
|
2969
|
+
$constructor("ZodError", classic_errors_initializer);
|
2970
|
+
const ZodRealError = $constructor("ZodError", classic_errors_initializer, {
|
2971
|
+
Parent: Error
|
2972
|
+
});
|
2973
|
+
const parse_parse = /* @__PURE__ */ _parse(ZodRealError);
|
2974
|
+
const parse_parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
2975
|
+
const parse_safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
2976
|
+
const parse_safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
2977
|
+
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def)=>{
|
2978
|
+
$ZodType.init(inst, def);
|
2979
|
+
inst.def = def;
|
2980
|
+
Object.defineProperty(inst, "_def", {
|
2981
|
+
value: def
|
2982
|
+
});
|
2983
|
+
inst.check = (...checks)=>inst.clone({
|
2984
|
+
...def,
|
2985
|
+
checks: [
|
2986
|
+
...def.checks ?? [],
|
2987
|
+
...checks.map((ch)=>"function" == typeof ch ? {
|
2988
|
+
_zod: {
|
2989
|
+
check: ch,
|
2990
|
+
def: {
|
2991
|
+
check: "custom"
|
2992
|
+
},
|
2993
|
+
onattach: []
|
2994
|
+
}
|
2995
|
+
} : ch)
|
2996
|
+
]
|
2997
|
+
});
|
2998
|
+
inst.clone = (def, params)=>clone(inst, def, params);
|
2999
|
+
inst.brand = ()=>inst;
|
3000
|
+
inst.register = (reg, meta)=>{
|
3001
|
+
reg.add(inst, meta);
|
3002
|
+
return inst;
|
3003
|
+
};
|
3004
|
+
inst.parse = (data, params)=>parse_parse(inst, data, params, {
|
3005
|
+
callee: inst.parse
|
3006
|
+
});
|
3007
|
+
inst.safeParse = (data, params)=>parse_safeParse(inst, data, params);
|
3008
|
+
inst.parseAsync = async (data, params)=>parse_parseAsync(inst, data, params, {
|
3009
|
+
callee: inst.parseAsync
|
3010
|
+
});
|
3011
|
+
inst.safeParseAsync = async (data, params)=>parse_safeParseAsync(inst, data, params);
|
3012
|
+
inst.spa = inst.safeParseAsync;
|
3013
|
+
inst.refine = (check, params)=>inst.check(refine(check, params));
|
3014
|
+
inst.superRefine = (refinement)=>inst.check(superRefine(refinement));
|
3015
|
+
inst.overwrite = (fn)=>inst.check(_overwrite(fn));
|
3016
|
+
inst.optional = ()=>optional(inst);
|
3017
|
+
inst.nullable = ()=>nullable(inst);
|
3018
|
+
inst.nullish = ()=>optional(nullable(inst));
|
3019
|
+
inst.nonoptional = (params)=>nonoptional(inst, params);
|
3020
|
+
inst.array = ()=>schemas_array(inst);
|
3021
|
+
inst.or = (arg)=>union([
|
3022
|
+
inst,
|
3023
|
+
arg
|
3024
|
+
]);
|
3025
|
+
inst.and = (arg)=>intersection(inst, arg);
|
3026
|
+
inst.transform = (tx)=>pipe(inst, transform(tx));
|
3027
|
+
inst.default = (def)=>schemas_default(inst, def);
|
3028
|
+
inst.prefault = (def)=>prefault(inst, def);
|
3029
|
+
inst.catch = (params)=>schemas_catch(inst, params);
|
3030
|
+
inst.pipe = (target)=>pipe(inst, target);
|
3031
|
+
inst.readonly = ()=>readonly(inst);
|
3032
|
+
inst.describe = (description)=>{
|
3033
|
+
const cl = inst.clone();
|
3034
|
+
globalRegistry.add(cl, {
|
3035
|
+
description
|
3036
|
+
});
|
3037
|
+
return cl;
|
3038
|
+
};
|
3039
|
+
Object.defineProperty(inst, "description", {
|
3040
|
+
get () {
|
3041
|
+
return globalRegistry.get(inst)?.description;
|
3042
|
+
},
|
3043
|
+
configurable: true
|
3044
|
+
});
|
3045
|
+
inst.meta = (...args)=>{
|
3046
|
+
if (0 === args.length) return globalRegistry.get(inst);
|
3047
|
+
const cl = inst.clone();
|
3048
|
+
globalRegistry.add(cl, args[0]);
|
3049
|
+
return cl;
|
3050
|
+
};
|
3051
|
+
inst.isOptional = ()=>inst.safeParse(void 0).success;
|
3052
|
+
inst.isNullable = ()=>inst.safeParse(null).success;
|
3053
|
+
return inst;
|
3054
|
+
});
|
3055
|
+
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def)=>{
|
3056
|
+
$ZodString.init(inst, def);
|
3057
|
+
ZodType.init(inst, def);
|
3058
|
+
const bag = inst._zod.bag;
|
3059
|
+
inst.format = bag.format ?? null;
|
3060
|
+
inst.minLength = bag.minimum ?? null;
|
3061
|
+
inst.maxLength = bag.maximum ?? null;
|
3062
|
+
inst.regex = (...args)=>inst.check(_regex(...args));
|
3063
|
+
inst.includes = (...args)=>inst.check(_includes(...args));
|
3064
|
+
inst.startsWith = (...args)=>inst.check(_startsWith(...args));
|
3065
|
+
inst.endsWith = (...args)=>inst.check(_endsWith(...args));
|
3066
|
+
inst.min = (...args)=>inst.check(_minLength(...args));
|
3067
|
+
inst.max = (...args)=>inst.check(_maxLength(...args));
|
3068
|
+
inst.length = (...args)=>inst.check(_length(...args));
|
3069
|
+
inst.nonempty = (...args)=>inst.check(_minLength(1, ...args));
|
3070
|
+
inst.lowercase = (params)=>inst.check(_lowercase(params));
|
3071
|
+
inst.uppercase = (params)=>inst.check(_uppercase(params));
|
3072
|
+
inst.trim = ()=>inst.check(_trim());
|
3073
|
+
inst.normalize = (...args)=>inst.check(_normalize(...args));
|
3074
|
+
inst.toLowerCase = ()=>inst.check(_toLowerCase());
|
3075
|
+
inst.toUpperCase = ()=>inst.check(_toUpperCase());
|
3076
|
+
});
|
3077
|
+
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def)=>{
|
3078
|
+
$ZodString.init(inst, def);
|
3079
|
+
_ZodString.init(inst, def);
|
3080
|
+
inst.email = (params)=>inst.check(_email(ZodEmail, params));
|
3081
|
+
inst.url = (params)=>inst.check(_url(ZodURL, params));
|
3082
|
+
inst.jwt = (params)=>inst.check(_jwt(ZodJWT, params));
|
3083
|
+
inst.emoji = (params)=>inst.check(api_emoji(ZodEmoji, params));
|
3084
|
+
inst.guid = (params)=>inst.check(_guid(ZodGUID, params));
|
3085
|
+
inst.uuid = (params)=>inst.check(_uuid(ZodUUID, params));
|
3086
|
+
inst.uuidv4 = (params)=>inst.check(_uuidv4(ZodUUID, params));
|
3087
|
+
inst.uuidv6 = (params)=>inst.check(_uuidv6(ZodUUID, params));
|
3088
|
+
inst.uuidv7 = (params)=>inst.check(_uuidv7(ZodUUID, params));
|
3089
|
+
inst.nanoid = (params)=>inst.check(_nanoid(ZodNanoID, params));
|
3090
|
+
inst.guid = (params)=>inst.check(_guid(ZodGUID, params));
|
3091
|
+
inst.cuid = (params)=>inst.check(_cuid(ZodCUID, params));
|
3092
|
+
inst.cuid2 = (params)=>inst.check(_cuid2(ZodCUID2, params));
|
3093
|
+
inst.ulid = (params)=>inst.check(_ulid(ZodULID, params));
|
3094
|
+
inst.base64 = (params)=>inst.check(_base64(ZodBase64, params));
|
3095
|
+
inst.base64url = (params)=>inst.check(_base64url(ZodBase64URL, params));
|
3096
|
+
inst.xid = (params)=>inst.check(_xid(ZodXID, params));
|
3097
|
+
inst.ksuid = (params)=>inst.check(_ksuid(ZodKSUID, params));
|
3098
|
+
inst.ipv4 = (params)=>inst.check(_ipv4(ZodIPv4, params));
|
3099
|
+
inst.ipv6 = (params)=>inst.check(_ipv6(ZodIPv6, params));
|
3100
|
+
inst.cidrv4 = (params)=>inst.check(_cidrv4(ZodCIDRv4, params));
|
3101
|
+
inst.cidrv6 = (params)=>inst.check(_cidrv6(ZodCIDRv6, params));
|
3102
|
+
inst.e164 = (params)=>inst.check(_e164(ZodE164, params));
|
3103
|
+
inst.datetime = (params)=>inst.check(iso_datetime(params));
|
3104
|
+
inst.date = (params)=>inst.check(iso_date(params));
|
3105
|
+
inst.time = (params)=>inst.check(iso_time(params));
|
3106
|
+
inst.duration = (params)=>inst.check(iso_duration(params));
|
3107
|
+
});
|
3108
|
+
function schemas_string(params) {
|
3109
|
+
return _string(ZodString, params);
|
3110
|
+
}
|
3111
|
+
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def)=>{
|
3112
|
+
$ZodStringFormat.init(inst, def);
|
3113
|
+
_ZodString.init(inst, def);
|
3114
|
+
});
|
3115
|
+
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def)=>{
|
3116
|
+
$ZodEmail.init(inst, def);
|
3117
|
+
ZodStringFormat.init(inst, def);
|
3118
|
+
});
|
3119
|
+
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def)=>{
|
3120
|
+
$ZodGUID.init(inst, def);
|
3121
|
+
ZodStringFormat.init(inst, def);
|
3122
|
+
});
|
3123
|
+
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def)=>{
|
3124
|
+
$ZodUUID.init(inst, def);
|
3125
|
+
ZodStringFormat.init(inst, def);
|
3126
|
+
});
|
3127
|
+
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def)=>{
|
3128
|
+
$ZodURL.init(inst, def);
|
3129
|
+
ZodStringFormat.init(inst, def);
|
3130
|
+
});
|
3131
|
+
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def)=>{
|
3132
|
+
$ZodEmoji.init(inst, def);
|
3133
|
+
ZodStringFormat.init(inst, def);
|
3134
|
+
});
|
3135
|
+
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def)=>{
|
3136
|
+
$ZodNanoID.init(inst, def);
|
3137
|
+
ZodStringFormat.init(inst, def);
|
3138
|
+
});
|
3139
|
+
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def)=>{
|
3140
|
+
$ZodCUID.init(inst, def);
|
3141
|
+
ZodStringFormat.init(inst, def);
|
3142
|
+
});
|
3143
|
+
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def)=>{
|
3144
|
+
$ZodCUID2.init(inst, def);
|
3145
|
+
ZodStringFormat.init(inst, def);
|
3146
|
+
});
|
3147
|
+
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def)=>{
|
3148
|
+
$ZodULID.init(inst, def);
|
3149
|
+
ZodStringFormat.init(inst, def);
|
3150
|
+
});
|
3151
|
+
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def)=>{
|
3152
|
+
$ZodXID.init(inst, def);
|
3153
|
+
ZodStringFormat.init(inst, def);
|
3154
|
+
});
|
3155
|
+
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def)=>{
|
3156
|
+
$ZodKSUID.init(inst, def);
|
3157
|
+
ZodStringFormat.init(inst, def);
|
3158
|
+
});
|
3159
|
+
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def)=>{
|
3160
|
+
$ZodIPv4.init(inst, def);
|
3161
|
+
ZodStringFormat.init(inst, def);
|
3162
|
+
});
|
3163
|
+
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def)=>{
|
3164
|
+
$ZodIPv6.init(inst, def);
|
3165
|
+
ZodStringFormat.init(inst, def);
|
3166
|
+
});
|
3167
|
+
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def)=>{
|
3168
|
+
$ZodCIDRv4.init(inst, def);
|
3169
|
+
ZodStringFormat.init(inst, def);
|
3170
|
+
});
|
3171
|
+
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def)=>{
|
3172
|
+
$ZodCIDRv6.init(inst, def);
|
3173
|
+
ZodStringFormat.init(inst, def);
|
3174
|
+
});
|
3175
|
+
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def)=>{
|
3176
|
+
$ZodBase64.init(inst, def);
|
3177
|
+
ZodStringFormat.init(inst, def);
|
3178
|
+
});
|
3179
|
+
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def)=>{
|
3180
|
+
$ZodBase64URL.init(inst, def);
|
3181
|
+
ZodStringFormat.init(inst, def);
|
3182
|
+
});
|
3183
|
+
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def)=>{
|
3184
|
+
$ZodE164.init(inst, def);
|
3185
|
+
ZodStringFormat.init(inst, def);
|
3186
|
+
});
|
3187
|
+
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def)=>{
|
3188
|
+
$ZodJWT.init(inst, def);
|
3189
|
+
ZodStringFormat.init(inst, def);
|
3190
|
+
});
|
3191
|
+
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def)=>{
|
3192
|
+
$ZodNumber.init(inst, def);
|
3193
|
+
ZodType.init(inst, def);
|
3194
|
+
inst.gt = (value, params)=>inst.check(_gt(value, params));
|
3195
|
+
inst.gte = (value, params)=>inst.check(_gte(value, params));
|
3196
|
+
inst.min = (value, params)=>inst.check(_gte(value, params));
|
3197
|
+
inst.lt = (value, params)=>inst.check(_lt(value, params));
|
3198
|
+
inst.lte = (value, params)=>inst.check(_lte(value, params));
|
3199
|
+
inst.max = (value, params)=>inst.check(_lte(value, params));
|
3200
|
+
inst.int = (params)=>inst.check(schemas_int(params));
|
3201
|
+
inst.safe = (params)=>inst.check(schemas_int(params));
|
3202
|
+
inst.positive = (params)=>inst.check(_gt(0, params));
|
3203
|
+
inst.nonnegative = (params)=>inst.check(_gte(0, params));
|
3204
|
+
inst.negative = (params)=>inst.check(_lt(0, params));
|
3205
|
+
inst.nonpositive = (params)=>inst.check(_lte(0, params));
|
3206
|
+
inst.multipleOf = (value, params)=>inst.check(_multipleOf(value, params));
|
3207
|
+
inst.step = (value, params)=>inst.check(_multipleOf(value, params));
|
3208
|
+
inst.finite = ()=>inst;
|
3209
|
+
const bag = inst._zod.bag;
|
3210
|
+
inst.minValue = Math.max(bag.minimum ?? -1 / 0, bag.exclusiveMinimum ?? -1 / 0) ?? null;
|
3211
|
+
inst.maxValue = Math.min(bag.maximum ?? 1 / 0, bag.exclusiveMaximum ?? 1 / 0) ?? null;
|
3212
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
3213
|
+
inst.isFinite = true;
|
3214
|
+
inst.format = bag.format ?? null;
|
3215
|
+
});
|
3216
|
+
function schemas_number(params) {
|
3217
|
+
return _number(ZodNumber, params);
|
3218
|
+
}
|
3219
|
+
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def)=>{
|
3220
|
+
$ZodNumberFormat.init(inst, def);
|
3221
|
+
ZodNumber.init(inst, def);
|
3222
|
+
});
|
3223
|
+
function schemas_int(params) {
|
3224
|
+
return _int(ZodNumberFormat, params);
|
3225
|
+
}
|
3226
|
+
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def)=>{
|
3227
|
+
$ZodBoolean.init(inst, def);
|
3228
|
+
ZodType.init(inst, def);
|
3229
|
+
});
|
3230
|
+
function schemas_boolean(params) {
|
3231
|
+
return _boolean(ZodBoolean, params);
|
3232
|
+
}
|
3233
|
+
const ZodUndefined = /*@__PURE__*/ $constructor("ZodUndefined", (inst, def)=>{
|
3234
|
+
$ZodUndefined.init(inst, def);
|
3235
|
+
ZodType.init(inst, def);
|
3236
|
+
});
|
3237
|
+
function schemas_undefined(params) {
|
3238
|
+
return api_undefined(ZodUndefined, params);
|
3239
|
+
}
|
3240
|
+
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def)=>{
|
3241
|
+
$ZodAny.init(inst, def);
|
3242
|
+
ZodType.init(inst, def);
|
3243
|
+
});
|
3244
|
+
function any() {
|
3245
|
+
return _any(ZodAny);
|
3246
|
+
}
|
3247
|
+
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def)=>{
|
3248
|
+
$ZodUnknown.init(inst, def);
|
3249
|
+
ZodType.init(inst, def);
|
3250
|
+
});
|
3251
|
+
function unknown() {
|
3252
|
+
return _unknown(ZodUnknown);
|
3253
|
+
}
|
3254
|
+
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def)=>{
|
3255
|
+
$ZodNever.init(inst, def);
|
3256
|
+
ZodType.init(inst, def);
|
3257
|
+
});
|
3258
|
+
function never(params) {
|
3259
|
+
return _never(ZodNever, params);
|
3260
|
+
}
|
3261
|
+
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def)=>{
|
3262
|
+
$ZodArray.init(inst, def);
|
3263
|
+
ZodType.init(inst, def);
|
3264
|
+
inst.element = def.element;
|
3265
|
+
inst.min = (minLength, params)=>inst.check(_minLength(minLength, params));
|
3266
|
+
inst.nonempty = (params)=>inst.check(_minLength(1, params));
|
3267
|
+
inst.max = (maxLength, params)=>inst.check(_maxLength(maxLength, params));
|
3268
|
+
inst.length = (len, params)=>inst.check(_length(len, params));
|
3269
|
+
inst.unwrap = ()=>inst.element;
|
3270
|
+
});
|
3271
|
+
function schemas_array(element, params) {
|
3272
|
+
return _array(ZodArray, element, params);
|
3273
|
+
}
|
3274
|
+
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def)=>{
|
3275
|
+
$ZodObject.init(inst, def);
|
3276
|
+
ZodType.init(inst, def);
|
3277
|
+
defineLazy(inst, "shape", ()=>def.shape);
|
3278
|
+
inst.keyof = ()=>schemas_enum(Object.keys(inst._zod.def.shape));
|
3279
|
+
inst.catchall = (catchall)=>inst.clone({
|
3280
|
+
...inst._zod.def,
|
3281
|
+
catchall: catchall
|
3282
|
+
});
|
3283
|
+
inst.passthrough = ()=>inst.clone({
|
3284
|
+
...inst._zod.def,
|
3285
|
+
catchall: unknown()
|
3286
|
+
});
|
3287
|
+
inst.loose = ()=>inst.clone({
|
3288
|
+
...inst._zod.def,
|
3289
|
+
catchall: unknown()
|
3290
|
+
});
|
3291
|
+
inst.strict = ()=>inst.clone({
|
3292
|
+
...inst._zod.def,
|
3293
|
+
catchall: never()
|
3294
|
+
});
|
3295
|
+
inst.strip = ()=>inst.clone({
|
3296
|
+
...inst._zod.def,
|
3297
|
+
catchall: void 0
|
3298
|
+
});
|
3299
|
+
inst.extend = (incoming)=>extend(inst, incoming);
|
3300
|
+
inst.merge = (other)=>merge(inst, other);
|
3301
|
+
inst.pick = (mask)=>pick(inst, mask);
|
3302
|
+
inst.omit = (mask)=>omit(inst, mask);
|
3303
|
+
inst.partial = (...args)=>partial(ZodOptional, inst, args[0]);
|
3304
|
+
inst.required = (...args)=>required(ZodNonOptional, inst, args[0]);
|
3305
|
+
});
|
3306
|
+
function schemas_object(shape, params) {
|
3307
|
+
const def = {
|
3308
|
+
type: "object",
|
3309
|
+
get shape () {
|
3310
|
+
assignProp(this, "shape", {
|
3311
|
+
...shape
|
3312
|
+
});
|
3313
|
+
return this.shape;
|
3314
|
+
},
|
3315
|
+
...normalizeParams(params)
|
3316
|
+
};
|
3317
|
+
return new ZodObject(def);
|
3318
|
+
}
|
3319
|
+
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def)=>{
|
3320
|
+
$ZodUnion.init(inst, def);
|
3321
|
+
ZodType.init(inst, def);
|
3322
|
+
inst.options = def.options;
|
3323
|
+
});
|
3324
|
+
function union(options, params) {
|
3325
|
+
return new ZodUnion({
|
3326
|
+
type: "union",
|
3327
|
+
options: options,
|
3328
|
+
...normalizeParams(params)
|
3329
|
+
});
|
3330
|
+
}
|
3331
|
+
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def)=>{
|
3332
|
+
ZodUnion.init(inst, def);
|
3333
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
3334
|
+
});
|
3335
|
+
function discriminatedUnion(discriminator, options, params) {
|
3336
|
+
return new ZodDiscriminatedUnion({
|
3337
|
+
type: "union",
|
3338
|
+
options,
|
3339
|
+
discriminator,
|
3340
|
+
...normalizeParams(params)
|
3341
|
+
});
|
3342
|
+
}
|
3343
|
+
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def)=>{
|
3344
|
+
$ZodIntersection.init(inst, def);
|
3345
|
+
ZodType.init(inst, def);
|
3346
|
+
});
|
3347
|
+
function intersection(left, right) {
|
3348
|
+
return new ZodIntersection({
|
3349
|
+
type: "intersection",
|
3350
|
+
left: left,
|
3351
|
+
right: right
|
3352
|
+
});
|
3353
|
+
}
|
3354
|
+
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def)=>{
|
3355
|
+
$ZodRecord.init(inst, def);
|
3356
|
+
ZodType.init(inst, def);
|
3357
|
+
inst.keyType = def.keyType;
|
3358
|
+
inst.valueType = def.valueType;
|
3359
|
+
});
|
3360
|
+
function record(keyType, valueType, params) {
|
3361
|
+
return new ZodRecord({
|
3362
|
+
type: "record",
|
3363
|
+
keyType,
|
3364
|
+
valueType: valueType,
|
3365
|
+
...normalizeParams(params)
|
3366
|
+
});
|
3367
|
+
}
|
3368
|
+
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def)=>{
|
3369
|
+
$ZodEnum.init(inst, def);
|
3370
|
+
ZodType.init(inst, def);
|
3371
|
+
inst.enum = def.entries;
|
3372
|
+
inst.options = Object.values(def.entries);
|
3373
|
+
const keys = new Set(Object.keys(def.entries));
|
3374
|
+
inst.extract = (values, params)=>{
|
3375
|
+
const newEntries = {};
|
3376
|
+
for (const value of values)if (keys.has(value)) newEntries[value] = def.entries[value];
|
3377
|
+
else throw new Error(`Key ${value} not found in enum`);
|
3378
|
+
return new ZodEnum({
|
3379
|
+
...def,
|
3380
|
+
checks: [],
|
3381
|
+
...normalizeParams(params),
|
3382
|
+
entries: newEntries
|
3383
|
+
});
|
3384
|
+
};
|
3385
|
+
inst.exclude = (values, params)=>{
|
3386
|
+
const newEntries = {
|
3387
|
+
...def.entries
|
3388
|
+
};
|
3389
|
+
for (const value of values)if (keys.has(value)) delete newEntries[value];
|
3390
|
+
else throw new Error(`Key ${value} not found in enum`);
|
3391
|
+
return new ZodEnum({
|
3392
|
+
...def,
|
3393
|
+
checks: [],
|
3394
|
+
...normalizeParams(params),
|
3395
|
+
entries: newEntries
|
3396
|
+
});
|
3397
|
+
};
|
3398
|
+
});
|
3399
|
+
function schemas_enum(values, params) {
|
3400
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v)=>[
|
3401
|
+
v,
|
3402
|
+
v
|
3403
|
+
])) : values;
|
3404
|
+
return new ZodEnum({
|
3405
|
+
type: "enum",
|
3406
|
+
entries,
|
3407
|
+
...normalizeParams(params)
|
3408
|
+
});
|
3409
|
+
}
|
3410
|
+
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def)=>{
|
3411
|
+
$ZodLiteral.init(inst, def);
|
3412
|
+
ZodType.init(inst, def);
|
3413
|
+
inst.values = new Set(def.values);
|
3414
|
+
Object.defineProperty(inst, "value", {
|
3415
|
+
get () {
|
3416
|
+
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
3417
|
+
return def.values[0];
|
3418
|
+
}
|
3419
|
+
});
|
3420
|
+
});
|
3421
|
+
function literal(value, params) {
|
3422
|
+
return new ZodLiteral({
|
3423
|
+
type: "literal",
|
3424
|
+
values: Array.isArray(value) ? value : [
|
3425
|
+
value
|
3426
|
+
],
|
3427
|
+
...normalizeParams(params)
|
3428
|
+
});
|
3429
|
+
}
|
3430
|
+
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def)=>{
|
3431
|
+
$ZodTransform.init(inst, def);
|
3432
|
+
ZodType.init(inst, def);
|
3433
|
+
inst._zod.parse = (payload, _ctx)=>{
|
3434
|
+
payload.addIssue = (issue)=>{
|
3435
|
+
if ("string" == typeof issue) payload.issues.push(util_issue(issue, payload.value, def));
|
3436
|
+
else {
|
3437
|
+
const _issue = issue;
|
3438
|
+
if (_issue.fatal) _issue.continue = false;
|
3439
|
+
_issue.code ?? (_issue.code = "custom");
|
3440
|
+
_issue.input ?? (_issue.input = payload.value);
|
3441
|
+
_issue.inst ?? (_issue.inst = inst);
|
3442
|
+
payload.issues.push(util_issue(_issue));
|
3443
|
+
}
|
3444
|
+
};
|
3445
|
+
const output = def.transform(payload.value, payload);
|
3446
|
+
if (output instanceof Promise) return output.then((output)=>{
|
3447
|
+
payload.value = output;
|
3448
|
+
return payload;
|
3449
|
+
});
|
3450
|
+
payload.value = output;
|
3451
|
+
return payload;
|
3452
|
+
};
|
3453
|
+
});
|
3454
|
+
function transform(fn) {
|
3455
|
+
return new ZodTransform({
|
3456
|
+
type: "transform",
|
3457
|
+
transform: fn
|
3458
|
+
});
|
3459
|
+
}
|
3460
|
+
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def)=>{
|
3461
|
+
$ZodOptional.init(inst, def);
|
3462
|
+
ZodType.init(inst, def);
|
3463
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3464
|
+
});
|
3465
|
+
function optional(innerType) {
|
3466
|
+
return new ZodOptional({
|
3467
|
+
type: "optional",
|
3468
|
+
innerType: innerType
|
3469
|
+
});
|
3470
|
+
}
|
3471
|
+
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def)=>{
|
3472
|
+
$ZodNullable.init(inst, def);
|
3473
|
+
ZodType.init(inst, def);
|
3474
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3475
|
+
});
|
3476
|
+
function nullable(innerType) {
|
3477
|
+
return new ZodNullable({
|
3478
|
+
type: "nullable",
|
3479
|
+
innerType: innerType
|
3480
|
+
});
|
3481
|
+
}
|
3482
|
+
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def)=>{
|
3483
|
+
$ZodDefault.init(inst, def);
|
3484
|
+
ZodType.init(inst, def);
|
3485
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3486
|
+
inst.removeDefault = inst.unwrap;
|
3487
|
+
});
|
3488
|
+
function schemas_default(innerType, defaultValue) {
|
3489
|
+
return new ZodDefault({
|
3490
|
+
type: "default",
|
3491
|
+
innerType: innerType,
|
3492
|
+
get defaultValue () {
|
3493
|
+
return "function" == typeof defaultValue ? defaultValue() : defaultValue;
|
3494
|
+
}
|
3495
|
+
});
|
3496
|
+
}
|
3497
|
+
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def)=>{
|
3498
|
+
$ZodPrefault.init(inst, def);
|
3499
|
+
ZodType.init(inst, def);
|
3500
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3501
|
+
});
|
3502
|
+
function prefault(innerType, defaultValue) {
|
3503
|
+
return new ZodPrefault({
|
3504
|
+
type: "prefault",
|
3505
|
+
innerType: innerType,
|
3506
|
+
get defaultValue () {
|
3507
|
+
return "function" == typeof defaultValue ? defaultValue() : defaultValue;
|
3508
|
+
}
|
3509
|
+
});
|
3510
|
+
}
|
3511
|
+
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def)=>{
|
3512
|
+
$ZodNonOptional.init(inst, def);
|
3513
|
+
ZodType.init(inst, def);
|
3514
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3515
|
+
});
|
3516
|
+
function nonoptional(innerType, params) {
|
3517
|
+
return new ZodNonOptional({
|
3518
|
+
type: "nonoptional",
|
3519
|
+
innerType: innerType,
|
3520
|
+
...normalizeParams(params)
|
3521
|
+
});
|
3522
|
+
}
|
3523
|
+
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def)=>{
|
3524
|
+
$ZodCatch.init(inst, def);
|
3525
|
+
ZodType.init(inst, def);
|
3526
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3527
|
+
inst.removeCatch = inst.unwrap;
|
3528
|
+
});
|
3529
|
+
function schemas_catch(innerType, catchValue) {
|
3530
|
+
return new ZodCatch({
|
3531
|
+
type: "catch",
|
3532
|
+
innerType: innerType,
|
3533
|
+
catchValue: "function" == typeof catchValue ? catchValue : ()=>catchValue
|
3534
|
+
});
|
3535
|
+
}
|
3536
|
+
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def)=>{
|
3537
|
+
$ZodPipe.init(inst, def);
|
3538
|
+
ZodType.init(inst, def);
|
3539
|
+
inst.in = def.in;
|
3540
|
+
inst.out = def.out;
|
3541
|
+
});
|
3542
|
+
function pipe(in_, out) {
|
3543
|
+
return new ZodPipe({
|
3544
|
+
type: "pipe",
|
3545
|
+
in: in_,
|
3546
|
+
out: out
|
3547
|
+
});
|
3548
|
+
}
|
3549
|
+
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def)=>{
|
3550
|
+
$ZodReadonly.init(inst, def);
|
3551
|
+
ZodType.init(inst, def);
|
3552
|
+
inst.unwrap = ()=>inst._zod.def.innerType;
|
3553
|
+
});
|
3554
|
+
function readonly(innerType) {
|
3555
|
+
return new ZodReadonly({
|
3556
|
+
type: "readonly",
|
3557
|
+
innerType: innerType
|
3558
|
+
});
|
3559
|
+
}
|
3560
|
+
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def)=>{
|
3561
|
+
$ZodCustom.init(inst, def);
|
3562
|
+
ZodType.init(inst, def);
|
3563
|
+
});
|
3564
|
+
function refine(fn, _params = {}) {
|
3565
|
+
return _refine(ZodCustom, fn, _params);
|
3566
|
+
}
|
3567
|
+
function superRefine(fn) {
|
3568
|
+
return _superRefine(fn);
|
3569
|
+
}
|
3570
|
+
}
|
3571
|
+
}
|
3572
|
+
]);
|
3573
|
+
|
3574
|
+
//# sourceMappingURL=999.js.map
|