vite-plugin-norg 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/plugin/generators/html.d.ts +2 -0
- package/dist/plugin/generators/react.d.ts +2 -0
- package/dist/plugin/generators/svelte.d.ts +2 -0
- package/dist/plugin/index.d.ts +32 -0
- package/dist/plugin/index.js +2801 -0
- package/dist/plugin/plugin.d.ts +15 -0
- package/dist/plugin/wasm.d.ts +19 -0
- package/dist/vite_plugin_norg_parser-CNE0aFue.js +183 -0
- package/package.json +71 -0
|
@@ -0,0 +1,2801 @@
|
|
|
1
|
+
import { createFilter as be } from "vite";
|
|
2
|
+
let rt;
|
|
3
|
+
let __tla = (async () => {
|
|
4
|
+
var v;
|
|
5
|
+
(function(s) {
|
|
6
|
+
s.assertEqual = (a) => {
|
|
7
|
+
};
|
|
8
|
+
function e(a) {
|
|
9
|
+
}
|
|
10
|
+
s.assertIs = e;
|
|
11
|
+
function t(a) {
|
|
12
|
+
throw new Error();
|
|
13
|
+
}
|
|
14
|
+
s.assertNever = t, s.arrayToEnum = (a) => {
|
|
15
|
+
const n = {};
|
|
16
|
+
for (const i of a) n[i] = i;
|
|
17
|
+
return n;
|
|
18
|
+
}, s.getValidEnumValues = (a) => {
|
|
19
|
+
const n = s.objectKeys(a).filter((o) => typeof a[a[o]] != "number"), i = {};
|
|
20
|
+
for (const o of n) i[o] = a[o];
|
|
21
|
+
return s.objectValues(i);
|
|
22
|
+
}, s.objectValues = (a) => s.objectKeys(a).map(function(n) {
|
|
23
|
+
return a[n];
|
|
24
|
+
}), s.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
25
|
+
const n = [];
|
|
26
|
+
for (const i in a) Object.prototype.hasOwnProperty.call(a, i) && n.push(i);
|
|
27
|
+
return n;
|
|
28
|
+
}, s.find = (a, n) => {
|
|
29
|
+
for (const i of a) if (n(i)) return i;
|
|
30
|
+
}, s.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && Number.isFinite(a) && Math.floor(a) === a;
|
|
31
|
+
function r(a, n = " | ") {
|
|
32
|
+
return a.map((i) => typeof i == "string" ? `'${i}'` : i).join(n);
|
|
33
|
+
}
|
|
34
|
+
s.joinValues = r, s.jsonStringifyReplacer = (a, n) => typeof n == "bigint" ? n.toString() : n;
|
|
35
|
+
})(v || (v = {}));
|
|
36
|
+
var se;
|
|
37
|
+
(function(s) {
|
|
38
|
+
s.mergeShapes = (e, t) => ({
|
|
39
|
+
...e,
|
|
40
|
+
...t
|
|
41
|
+
});
|
|
42
|
+
})(se || (se = {}));
|
|
43
|
+
const f = v.arrayToEnum([
|
|
44
|
+
"string",
|
|
45
|
+
"nan",
|
|
46
|
+
"number",
|
|
47
|
+
"integer",
|
|
48
|
+
"float",
|
|
49
|
+
"boolean",
|
|
50
|
+
"date",
|
|
51
|
+
"bigint",
|
|
52
|
+
"symbol",
|
|
53
|
+
"function",
|
|
54
|
+
"undefined",
|
|
55
|
+
"null",
|
|
56
|
+
"array",
|
|
57
|
+
"object",
|
|
58
|
+
"unknown",
|
|
59
|
+
"promise",
|
|
60
|
+
"void",
|
|
61
|
+
"never",
|
|
62
|
+
"map",
|
|
63
|
+
"set"
|
|
64
|
+
]), T = (s) => {
|
|
65
|
+
switch (typeof s) {
|
|
66
|
+
case "undefined":
|
|
67
|
+
return f.undefined;
|
|
68
|
+
case "string":
|
|
69
|
+
return f.string;
|
|
70
|
+
case "number":
|
|
71
|
+
return Number.isNaN(s) ? f.nan : f.number;
|
|
72
|
+
case "boolean":
|
|
73
|
+
return f.boolean;
|
|
74
|
+
case "function":
|
|
75
|
+
return f.function;
|
|
76
|
+
case "bigint":
|
|
77
|
+
return f.bigint;
|
|
78
|
+
case "symbol":
|
|
79
|
+
return f.symbol;
|
|
80
|
+
case "object":
|
|
81
|
+
return Array.isArray(s) ? f.array : s === null ? f.null : s.then && typeof s.then == "function" && s.catch && typeof s.catch == "function" ? f.promise : typeof Map < "u" && s instanceof Map ? f.map : typeof Set < "u" && s instanceof Set ? f.set : typeof Date < "u" && s instanceof Date ? f.date : f.object;
|
|
82
|
+
default:
|
|
83
|
+
return f.unknown;
|
|
84
|
+
}
|
|
85
|
+
}, d = v.arrayToEnum([
|
|
86
|
+
"invalid_type",
|
|
87
|
+
"invalid_literal",
|
|
88
|
+
"custom",
|
|
89
|
+
"invalid_union",
|
|
90
|
+
"invalid_union_discriminator",
|
|
91
|
+
"invalid_enum_value",
|
|
92
|
+
"unrecognized_keys",
|
|
93
|
+
"invalid_arguments",
|
|
94
|
+
"invalid_return_type",
|
|
95
|
+
"invalid_date",
|
|
96
|
+
"invalid_string",
|
|
97
|
+
"too_small",
|
|
98
|
+
"too_big",
|
|
99
|
+
"invalid_intersection_types",
|
|
100
|
+
"not_multiple_of",
|
|
101
|
+
"not_finite"
|
|
102
|
+
]);
|
|
103
|
+
class O extends Error {
|
|
104
|
+
get errors() {
|
|
105
|
+
return this.issues;
|
|
106
|
+
}
|
|
107
|
+
constructor(e) {
|
|
108
|
+
super(), this.issues = [], this.addIssue = (r) => {
|
|
109
|
+
this.issues = [
|
|
110
|
+
...this.issues,
|
|
111
|
+
r
|
|
112
|
+
];
|
|
113
|
+
}, this.addIssues = (r = []) => {
|
|
114
|
+
this.issues = [
|
|
115
|
+
...this.issues,
|
|
116
|
+
...r
|
|
117
|
+
];
|
|
118
|
+
};
|
|
119
|
+
const t = new.target.prototype;
|
|
120
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
121
|
+
}
|
|
122
|
+
format(e) {
|
|
123
|
+
const t = e || function(n) {
|
|
124
|
+
return n.message;
|
|
125
|
+
}, r = {
|
|
126
|
+
_errors: []
|
|
127
|
+
}, a = (n) => {
|
|
128
|
+
for (const i of n.issues) if (i.code === "invalid_union") i.unionErrors.map(a);
|
|
129
|
+
else if (i.code === "invalid_return_type") a(i.returnTypeError);
|
|
130
|
+
else if (i.code === "invalid_arguments") a(i.argumentsError);
|
|
131
|
+
else if (i.path.length === 0) r._errors.push(t(i));
|
|
132
|
+
else {
|
|
133
|
+
let o = r, u = 0;
|
|
134
|
+
for (; u < i.path.length; ) {
|
|
135
|
+
const l = i.path[u];
|
|
136
|
+
u === i.path.length - 1 ? (o[l] = o[l] || {
|
|
137
|
+
_errors: []
|
|
138
|
+
}, o[l]._errors.push(t(i))) : o[l] = o[l] || {
|
|
139
|
+
_errors: []
|
|
140
|
+
}, o = o[l], u++;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return a(this), r;
|
|
145
|
+
}
|
|
146
|
+
static assert(e) {
|
|
147
|
+
if (!(e instanceof O)) throw new Error(`Not a ZodError: ${e}`);
|
|
148
|
+
}
|
|
149
|
+
toString() {
|
|
150
|
+
return this.message;
|
|
151
|
+
}
|
|
152
|
+
get message() {
|
|
153
|
+
return JSON.stringify(this.issues, v.jsonStringifyReplacer, 2);
|
|
154
|
+
}
|
|
155
|
+
get isEmpty() {
|
|
156
|
+
return this.issues.length === 0;
|
|
157
|
+
}
|
|
158
|
+
flatten(e = (t) => t.message) {
|
|
159
|
+
const t = {}, r = [];
|
|
160
|
+
for (const a of this.issues) a.path.length > 0 ? (t[a.path[0]] = t[a.path[0]] || [], t[a.path[0]].push(e(a))) : r.push(e(a));
|
|
161
|
+
return {
|
|
162
|
+
formErrors: r,
|
|
163
|
+
fieldErrors: t
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
get formErrors() {
|
|
167
|
+
return this.flatten();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
O.create = (s) => new O(s);
|
|
171
|
+
const Y = (s, e) => {
|
|
172
|
+
let t;
|
|
173
|
+
switch (s.code) {
|
|
174
|
+
case d.invalid_type:
|
|
175
|
+
s.received === f.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
|
|
176
|
+
break;
|
|
177
|
+
case d.invalid_literal:
|
|
178
|
+
t = `Invalid literal value, expected ${JSON.stringify(s.expected, v.jsonStringifyReplacer)}`;
|
|
179
|
+
break;
|
|
180
|
+
case d.unrecognized_keys:
|
|
181
|
+
t = `Unrecognized key(s) in object: ${v.joinValues(s.keys, ", ")}`;
|
|
182
|
+
break;
|
|
183
|
+
case d.invalid_union:
|
|
184
|
+
t = "Invalid input";
|
|
185
|
+
break;
|
|
186
|
+
case d.invalid_union_discriminator:
|
|
187
|
+
t = `Invalid discriminator value. Expected ${v.joinValues(s.options)}`;
|
|
188
|
+
break;
|
|
189
|
+
case d.invalid_enum_value:
|
|
190
|
+
t = `Invalid enum value. Expected ${v.joinValues(s.options)}, received '${s.received}'`;
|
|
191
|
+
break;
|
|
192
|
+
case d.invalid_arguments:
|
|
193
|
+
t = "Invalid function arguments";
|
|
194
|
+
break;
|
|
195
|
+
case d.invalid_return_type:
|
|
196
|
+
t = "Invalid function return type";
|
|
197
|
+
break;
|
|
198
|
+
case d.invalid_date:
|
|
199
|
+
t = "Invalid date";
|
|
200
|
+
break;
|
|
201
|
+
case d.invalid_string:
|
|
202
|
+
typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : v.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
|
|
203
|
+
break;
|
|
204
|
+
case d.too_small:
|
|
205
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
|
|
206
|
+
break;
|
|
207
|
+
case d.too_big:
|
|
208
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
|
|
209
|
+
break;
|
|
210
|
+
case d.custom:
|
|
211
|
+
t = "Invalid input";
|
|
212
|
+
break;
|
|
213
|
+
case d.invalid_intersection_types:
|
|
214
|
+
t = "Intersection results could not be merged";
|
|
215
|
+
break;
|
|
216
|
+
case d.not_multiple_of:
|
|
217
|
+
t = `Number must be a multiple of ${s.multipleOf}`;
|
|
218
|
+
break;
|
|
219
|
+
case d.not_finite:
|
|
220
|
+
t = "Number must be finite";
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
t = e.defaultError, v.assertNever(s);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
message: t
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
let we = Y;
|
|
230
|
+
function Ce() {
|
|
231
|
+
return we;
|
|
232
|
+
}
|
|
233
|
+
const Oe = (s) => {
|
|
234
|
+
const { data: e, path: t, errorMaps: r, issueData: a } = s, n = [
|
|
235
|
+
...t,
|
|
236
|
+
...a.path || []
|
|
237
|
+
], i = {
|
|
238
|
+
...a,
|
|
239
|
+
path: n
|
|
240
|
+
};
|
|
241
|
+
if (a.message !== void 0) return {
|
|
242
|
+
...a,
|
|
243
|
+
path: n,
|
|
244
|
+
message: a.message
|
|
245
|
+
};
|
|
246
|
+
let o = "";
|
|
247
|
+
const u = r.filter((l) => !!l).slice().reverse();
|
|
248
|
+
for (const l of u) o = l(i, {
|
|
249
|
+
data: e,
|
|
250
|
+
defaultError: o
|
|
251
|
+
}).message;
|
|
252
|
+
return {
|
|
253
|
+
...a,
|
|
254
|
+
path: n,
|
|
255
|
+
message: o
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
function c(s, e) {
|
|
259
|
+
const t = Ce(), r = Oe({
|
|
260
|
+
issueData: e,
|
|
261
|
+
data: s.data,
|
|
262
|
+
path: s.path,
|
|
263
|
+
errorMaps: [
|
|
264
|
+
s.common.contextualErrorMap,
|
|
265
|
+
s.schemaErrorMap,
|
|
266
|
+
t,
|
|
267
|
+
t === Y ? void 0 : Y
|
|
268
|
+
].filter((a) => !!a)
|
|
269
|
+
});
|
|
270
|
+
s.common.issues.push(r);
|
|
271
|
+
}
|
|
272
|
+
class k {
|
|
273
|
+
constructor() {
|
|
274
|
+
this.value = "valid";
|
|
275
|
+
}
|
|
276
|
+
dirty() {
|
|
277
|
+
this.value === "valid" && (this.value = "dirty");
|
|
278
|
+
}
|
|
279
|
+
abort() {
|
|
280
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
281
|
+
}
|
|
282
|
+
static mergeArray(e, t) {
|
|
283
|
+
const r = [];
|
|
284
|
+
for (const a of t) {
|
|
285
|
+
if (a.status === "aborted") return m;
|
|
286
|
+
a.status === "dirty" && e.dirty(), r.push(a.value);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
status: e.value,
|
|
290
|
+
value: r
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
static async mergeObjectAsync(e, t) {
|
|
294
|
+
const r = [];
|
|
295
|
+
for (const a of t) {
|
|
296
|
+
const n = await a.key, i = await a.value;
|
|
297
|
+
r.push({
|
|
298
|
+
key: n,
|
|
299
|
+
value: i
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
return k.mergeObjectSync(e, r);
|
|
303
|
+
}
|
|
304
|
+
static mergeObjectSync(e, t) {
|
|
305
|
+
const r = {};
|
|
306
|
+
for (const a of t) {
|
|
307
|
+
const { key: n, value: i } = a;
|
|
308
|
+
if (n.status === "aborted" || i.status === "aborted") return m;
|
|
309
|
+
n.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), n.value !== "__proto__" && (typeof i.value < "u" || a.alwaysSet) && (r[n.value] = i.value);
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
status: e.value,
|
|
313
|
+
value: r
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const m = Object.freeze({
|
|
318
|
+
status: "aborted"
|
|
319
|
+
}), M = (s) => ({
|
|
320
|
+
status: "dirty",
|
|
321
|
+
value: s
|
|
322
|
+
}), b = (s) => ({
|
|
323
|
+
status: "valid",
|
|
324
|
+
value: s
|
|
325
|
+
}), re = (s) => s.status === "aborted", ae = (s) => s.status === "dirty", I = (s) => s.status === "valid", U = (s) => typeof Promise < "u" && s instanceof Promise;
|
|
326
|
+
var h;
|
|
327
|
+
(function(s) {
|
|
328
|
+
s.errToObj = (e) => typeof e == "string" ? {
|
|
329
|
+
message: e
|
|
330
|
+
} : e || {}, s.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
331
|
+
})(h || (h = {}));
|
|
332
|
+
class N {
|
|
333
|
+
constructor(e, t, r, a) {
|
|
334
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = a;
|
|
335
|
+
}
|
|
336
|
+
get path() {
|
|
337
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const ne = (s, e) => {
|
|
341
|
+
if (I(e)) return {
|
|
342
|
+
success: true,
|
|
343
|
+
data: e.value
|
|
344
|
+
};
|
|
345
|
+
if (!s.common.issues.length) throw new Error("Validation failed but no issues detected.");
|
|
346
|
+
return {
|
|
347
|
+
success: false,
|
|
348
|
+
get error() {
|
|
349
|
+
if (this._error) return this._error;
|
|
350
|
+
const t = new O(s.common.issues);
|
|
351
|
+
return this._error = t, this._error;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
function _(s) {
|
|
356
|
+
if (!s) return {};
|
|
357
|
+
const { errorMap: e, invalid_type_error: t, required_error: r, description: a } = s;
|
|
358
|
+
if (e && (t || r)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
359
|
+
return e ? {
|
|
360
|
+
errorMap: e,
|
|
361
|
+
description: a
|
|
362
|
+
} : {
|
|
363
|
+
errorMap: (i, o) => {
|
|
364
|
+
const { message: u } = s;
|
|
365
|
+
return i.code === "invalid_enum_value" ? {
|
|
366
|
+
message: u ?? o.defaultError
|
|
367
|
+
} : typeof o.data > "u" ? {
|
|
368
|
+
message: u ?? r ?? o.defaultError
|
|
369
|
+
} : i.code !== "invalid_type" ? {
|
|
370
|
+
message: o.defaultError
|
|
371
|
+
} : {
|
|
372
|
+
message: u ?? t ?? o.defaultError
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
description: a
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
class y {
|
|
379
|
+
get description() {
|
|
380
|
+
return this._def.description;
|
|
381
|
+
}
|
|
382
|
+
_getType(e) {
|
|
383
|
+
return T(e.data);
|
|
384
|
+
}
|
|
385
|
+
_getOrReturnCtx(e, t) {
|
|
386
|
+
return t || {
|
|
387
|
+
common: e.parent.common,
|
|
388
|
+
data: e.data,
|
|
389
|
+
parsedType: T(e.data),
|
|
390
|
+
schemaErrorMap: this._def.errorMap,
|
|
391
|
+
path: e.path,
|
|
392
|
+
parent: e.parent
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
_processInputParams(e) {
|
|
396
|
+
return {
|
|
397
|
+
status: new k(),
|
|
398
|
+
ctx: {
|
|
399
|
+
common: e.parent.common,
|
|
400
|
+
data: e.data,
|
|
401
|
+
parsedType: T(e.data),
|
|
402
|
+
schemaErrorMap: this._def.errorMap,
|
|
403
|
+
path: e.path,
|
|
404
|
+
parent: e.parent
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
_parseSync(e) {
|
|
409
|
+
const t = this._parse(e);
|
|
410
|
+
if (U(t)) throw new Error("Synchronous parse encountered promise.");
|
|
411
|
+
return t;
|
|
412
|
+
}
|
|
413
|
+
_parseAsync(e) {
|
|
414
|
+
const t = this._parse(e);
|
|
415
|
+
return Promise.resolve(t);
|
|
416
|
+
}
|
|
417
|
+
parse(e, t) {
|
|
418
|
+
const r = this.safeParse(e, t);
|
|
419
|
+
if (r.success) return r.data;
|
|
420
|
+
throw r.error;
|
|
421
|
+
}
|
|
422
|
+
safeParse(e, t) {
|
|
423
|
+
const r = {
|
|
424
|
+
common: {
|
|
425
|
+
issues: [],
|
|
426
|
+
async: (t == null ? void 0 : t.async) ?? false,
|
|
427
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
428
|
+
},
|
|
429
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
430
|
+
schemaErrorMap: this._def.errorMap,
|
|
431
|
+
parent: null,
|
|
432
|
+
data: e,
|
|
433
|
+
parsedType: T(e)
|
|
434
|
+
}, a = this._parseSync({
|
|
435
|
+
data: e,
|
|
436
|
+
path: r.path,
|
|
437
|
+
parent: r
|
|
438
|
+
});
|
|
439
|
+
return ne(r, a);
|
|
440
|
+
}
|
|
441
|
+
"~validate"(e) {
|
|
442
|
+
var _a, _b;
|
|
443
|
+
const t = {
|
|
444
|
+
common: {
|
|
445
|
+
issues: [],
|
|
446
|
+
async: !!this["~standard"].async
|
|
447
|
+
},
|
|
448
|
+
path: [],
|
|
449
|
+
schemaErrorMap: this._def.errorMap,
|
|
450
|
+
parent: null,
|
|
451
|
+
data: e,
|
|
452
|
+
parsedType: T(e)
|
|
453
|
+
};
|
|
454
|
+
if (!this["~standard"].async) try {
|
|
455
|
+
const r = this._parseSync({
|
|
456
|
+
data: e,
|
|
457
|
+
path: [],
|
|
458
|
+
parent: t
|
|
459
|
+
});
|
|
460
|
+
return I(r) ? {
|
|
461
|
+
value: r.value
|
|
462
|
+
} : {
|
|
463
|
+
issues: t.common.issues
|
|
464
|
+
};
|
|
465
|
+
} catch (r) {
|
|
466
|
+
((_b = (_a = r == null ? void 0 : r.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) && (this["~standard"].async = true), t.common = {
|
|
467
|
+
issues: [],
|
|
468
|
+
async: true
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return this._parseAsync({
|
|
472
|
+
data: e,
|
|
473
|
+
path: [],
|
|
474
|
+
parent: t
|
|
475
|
+
}).then((r) => I(r) ? {
|
|
476
|
+
value: r.value
|
|
477
|
+
} : {
|
|
478
|
+
issues: t.common.issues
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
async parseAsync(e, t) {
|
|
482
|
+
const r = await this.safeParseAsync(e, t);
|
|
483
|
+
if (r.success) return r.data;
|
|
484
|
+
throw r.error;
|
|
485
|
+
}
|
|
486
|
+
async safeParseAsync(e, t) {
|
|
487
|
+
const r = {
|
|
488
|
+
common: {
|
|
489
|
+
issues: [],
|
|
490
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
491
|
+
async: true
|
|
492
|
+
},
|
|
493
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
494
|
+
schemaErrorMap: this._def.errorMap,
|
|
495
|
+
parent: null,
|
|
496
|
+
data: e,
|
|
497
|
+
parsedType: T(e)
|
|
498
|
+
}, a = this._parse({
|
|
499
|
+
data: e,
|
|
500
|
+
path: r.path,
|
|
501
|
+
parent: r
|
|
502
|
+
}), n = await (U(a) ? a : Promise.resolve(a));
|
|
503
|
+
return ne(r, n);
|
|
504
|
+
}
|
|
505
|
+
refine(e, t) {
|
|
506
|
+
const r = (a) => typeof t == "string" || typeof t > "u" ? {
|
|
507
|
+
message: t
|
|
508
|
+
} : typeof t == "function" ? t(a) : t;
|
|
509
|
+
return this._refinement((a, n) => {
|
|
510
|
+
const i = e(a), o = () => n.addIssue({
|
|
511
|
+
code: d.custom,
|
|
512
|
+
...r(a)
|
|
513
|
+
});
|
|
514
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? true : (o(), false)) : i ? true : (o(), false);
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
refinement(e, t) {
|
|
518
|
+
return this._refinement((r, a) => e(r) ? true : (a.addIssue(typeof t == "function" ? t(r, a) : t), false));
|
|
519
|
+
}
|
|
520
|
+
_refinement(e) {
|
|
521
|
+
return new $({
|
|
522
|
+
schema: this,
|
|
523
|
+
typeName: p.ZodEffects,
|
|
524
|
+
effect: {
|
|
525
|
+
type: "refinement",
|
|
526
|
+
refinement: e
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
superRefine(e) {
|
|
531
|
+
return this._refinement(e);
|
|
532
|
+
}
|
|
533
|
+
constructor(e) {
|
|
534
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
535
|
+
version: 1,
|
|
536
|
+
vendor: "zod",
|
|
537
|
+
validate: (t) => this["~validate"](t)
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
optional() {
|
|
541
|
+
return S.create(this, this._def);
|
|
542
|
+
}
|
|
543
|
+
nullable() {
|
|
544
|
+
return V.create(this, this._def);
|
|
545
|
+
}
|
|
546
|
+
nullish() {
|
|
547
|
+
return this.nullable().optional();
|
|
548
|
+
}
|
|
549
|
+
array() {
|
|
550
|
+
return w.create(this);
|
|
551
|
+
}
|
|
552
|
+
promise() {
|
|
553
|
+
return J.create(this, this._def);
|
|
554
|
+
}
|
|
555
|
+
or(e) {
|
|
556
|
+
return F.create([
|
|
557
|
+
this,
|
|
558
|
+
e
|
|
559
|
+
], this._def);
|
|
560
|
+
}
|
|
561
|
+
and(e) {
|
|
562
|
+
return W.create(this, e, this._def);
|
|
563
|
+
}
|
|
564
|
+
transform(e) {
|
|
565
|
+
return new $({
|
|
566
|
+
..._(this._def),
|
|
567
|
+
schema: this,
|
|
568
|
+
typeName: p.ZodEffects,
|
|
569
|
+
effect: {
|
|
570
|
+
type: "transform",
|
|
571
|
+
transform: e
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
default(e) {
|
|
576
|
+
const t = typeof e == "function" ? e : () => e;
|
|
577
|
+
return new X({
|
|
578
|
+
..._(this._def),
|
|
579
|
+
innerType: this,
|
|
580
|
+
defaultValue: t,
|
|
581
|
+
typeName: p.ZodDefault
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
brand() {
|
|
585
|
+
return new He({
|
|
586
|
+
typeName: p.ZodBranded,
|
|
587
|
+
type: this,
|
|
588
|
+
..._(this._def)
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
catch(e) {
|
|
592
|
+
const t = typeof e == "function" ? e : () => e;
|
|
593
|
+
return new K({
|
|
594
|
+
..._(this._def),
|
|
595
|
+
innerType: this,
|
|
596
|
+
catchValue: t,
|
|
597
|
+
typeName: p.ZodCatch
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
describe(e) {
|
|
601
|
+
const t = this.constructor;
|
|
602
|
+
return new t({
|
|
603
|
+
...this._def,
|
|
604
|
+
description: e
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
pipe(e) {
|
|
608
|
+
return te.create(this, e);
|
|
609
|
+
}
|
|
610
|
+
readonly() {
|
|
611
|
+
return ee.create(this);
|
|
612
|
+
}
|
|
613
|
+
isOptional() {
|
|
614
|
+
return this.safeParse(void 0).success;
|
|
615
|
+
}
|
|
616
|
+
isNullable() {
|
|
617
|
+
return this.safeParse(null).success;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const Te = /^c[^\s-]{8,}$/i, Se = /^[0-9a-z]+$/, Ne = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Ae = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Ze = /^[a-z0-9_-]{21}$/i, Re = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, je = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Ie = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ee = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
621
|
+
let H;
|
|
622
|
+
const $e = /^(?:(?: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])$/, Ve = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Me = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Pe = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Le = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, ze = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, ve = "((\\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])))", De = new RegExp(`^${ve}$`);
|
|
623
|
+
function xe(s) {
|
|
624
|
+
let e = "[0-5]\\d";
|
|
625
|
+
s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
626
|
+
const t = s.precision ? "+" : "?";
|
|
627
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
628
|
+
}
|
|
629
|
+
function Ue(s) {
|
|
630
|
+
return new RegExp(`^${xe(s)}$`);
|
|
631
|
+
}
|
|
632
|
+
function Be(s) {
|
|
633
|
+
let e = `${ve}T${xe(s)}`;
|
|
634
|
+
const t = [];
|
|
635
|
+
return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
636
|
+
}
|
|
637
|
+
function Fe(s, e) {
|
|
638
|
+
return !!((e === "v4" || !e) && $e.test(s) || (e === "v6" || !e) && Me.test(s));
|
|
639
|
+
}
|
|
640
|
+
function We(s, e) {
|
|
641
|
+
if (!Re.test(s)) return false;
|
|
642
|
+
try {
|
|
643
|
+
const [t] = s.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), a = JSON.parse(atob(r));
|
|
644
|
+
return !(typeof a != "object" || a === null || "typ" in a && (a == null ? void 0 : a.typ) !== "JWT" || !a.alg || e && a.alg !== e);
|
|
645
|
+
} catch {
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
function Je(s, e) {
|
|
650
|
+
return !!((e === "v4" || !e) && Ve.test(s) || (e === "v6" || !e) && Pe.test(s));
|
|
651
|
+
}
|
|
652
|
+
class Z extends y {
|
|
653
|
+
_parse(e) {
|
|
654
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
655
|
+
const n = this._getOrReturnCtx(e);
|
|
656
|
+
return c(n, {
|
|
657
|
+
code: d.invalid_type,
|
|
658
|
+
expected: f.string,
|
|
659
|
+
received: n.parsedType
|
|
660
|
+
}), m;
|
|
661
|
+
}
|
|
662
|
+
const r = new k();
|
|
663
|
+
let a;
|
|
664
|
+
for (const n of this._def.checks) if (n.kind === "min") e.data.length < n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
665
|
+
code: d.too_small,
|
|
666
|
+
minimum: n.value,
|
|
667
|
+
type: "string",
|
|
668
|
+
inclusive: true,
|
|
669
|
+
exact: false,
|
|
670
|
+
message: n.message
|
|
671
|
+
}), r.dirty());
|
|
672
|
+
else if (n.kind === "max") e.data.length > n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
673
|
+
code: d.too_big,
|
|
674
|
+
maximum: n.value,
|
|
675
|
+
type: "string",
|
|
676
|
+
inclusive: true,
|
|
677
|
+
exact: false,
|
|
678
|
+
message: n.message
|
|
679
|
+
}), r.dirty());
|
|
680
|
+
else if (n.kind === "length") {
|
|
681
|
+
const i = e.data.length > n.value, o = e.data.length < n.value;
|
|
682
|
+
(i || o) && (a = this._getOrReturnCtx(e, a), i ? c(a, {
|
|
683
|
+
code: d.too_big,
|
|
684
|
+
maximum: n.value,
|
|
685
|
+
type: "string",
|
|
686
|
+
inclusive: true,
|
|
687
|
+
exact: true,
|
|
688
|
+
message: n.message
|
|
689
|
+
}) : o && c(a, {
|
|
690
|
+
code: d.too_small,
|
|
691
|
+
minimum: n.value,
|
|
692
|
+
type: "string",
|
|
693
|
+
inclusive: true,
|
|
694
|
+
exact: true,
|
|
695
|
+
message: n.message
|
|
696
|
+
}), r.dirty());
|
|
697
|
+
} else if (n.kind === "email") Ie.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
698
|
+
validation: "email",
|
|
699
|
+
code: d.invalid_string,
|
|
700
|
+
message: n.message
|
|
701
|
+
}), r.dirty());
|
|
702
|
+
else if (n.kind === "emoji") H || (H = new RegExp(Ee, "u")), H.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
703
|
+
validation: "emoji",
|
|
704
|
+
code: d.invalid_string,
|
|
705
|
+
message: n.message
|
|
706
|
+
}), r.dirty());
|
|
707
|
+
else if (n.kind === "uuid") Ae.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
708
|
+
validation: "uuid",
|
|
709
|
+
code: d.invalid_string,
|
|
710
|
+
message: n.message
|
|
711
|
+
}), r.dirty());
|
|
712
|
+
else if (n.kind === "nanoid") Ze.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
713
|
+
validation: "nanoid",
|
|
714
|
+
code: d.invalid_string,
|
|
715
|
+
message: n.message
|
|
716
|
+
}), r.dirty());
|
|
717
|
+
else if (n.kind === "cuid") Te.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
718
|
+
validation: "cuid",
|
|
719
|
+
code: d.invalid_string,
|
|
720
|
+
message: n.message
|
|
721
|
+
}), r.dirty());
|
|
722
|
+
else if (n.kind === "cuid2") Se.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
723
|
+
validation: "cuid2",
|
|
724
|
+
code: d.invalid_string,
|
|
725
|
+
message: n.message
|
|
726
|
+
}), r.dirty());
|
|
727
|
+
else if (n.kind === "ulid") Ne.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
728
|
+
validation: "ulid",
|
|
729
|
+
code: d.invalid_string,
|
|
730
|
+
message: n.message
|
|
731
|
+
}), r.dirty());
|
|
732
|
+
else if (n.kind === "url") try {
|
|
733
|
+
new URL(e.data);
|
|
734
|
+
} catch {
|
|
735
|
+
a = this._getOrReturnCtx(e, a), c(a, {
|
|
736
|
+
validation: "url",
|
|
737
|
+
code: d.invalid_string,
|
|
738
|
+
message: n.message
|
|
739
|
+
}), r.dirty();
|
|
740
|
+
}
|
|
741
|
+
else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
742
|
+
validation: "regex",
|
|
743
|
+
code: d.invalid_string,
|
|
744
|
+
message: n.message
|
|
745
|
+
}), r.dirty())) : n.kind === "trim" ? e.data = e.data.trim() : n.kind === "includes" ? e.data.includes(n.value, n.position) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
746
|
+
code: d.invalid_string,
|
|
747
|
+
validation: {
|
|
748
|
+
includes: n.value,
|
|
749
|
+
position: n.position
|
|
750
|
+
},
|
|
751
|
+
message: n.message
|
|
752
|
+
}), r.dirty()) : n.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : n.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : n.kind === "startsWith" ? e.data.startsWith(n.value) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
753
|
+
code: d.invalid_string,
|
|
754
|
+
validation: {
|
|
755
|
+
startsWith: n.value
|
|
756
|
+
},
|
|
757
|
+
message: n.message
|
|
758
|
+
}), r.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
759
|
+
code: d.invalid_string,
|
|
760
|
+
validation: {
|
|
761
|
+
endsWith: n.value
|
|
762
|
+
},
|
|
763
|
+
message: n.message
|
|
764
|
+
}), r.dirty()) : n.kind === "datetime" ? Be(n).test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
765
|
+
code: d.invalid_string,
|
|
766
|
+
validation: "datetime",
|
|
767
|
+
message: n.message
|
|
768
|
+
}), r.dirty()) : n.kind === "date" ? De.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
769
|
+
code: d.invalid_string,
|
|
770
|
+
validation: "date",
|
|
771
|
+
message: n.message
|
|
772
|
+
}), r.dirty()) : n.kind === "time" ? Ue(n).test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
773
|
+
code: d.invalid_string,
|
|
774
|
+
validation: "time",
|
|
775
|
+
message: n.message
|
|
776
|
+
}), r.dirty()) : n.kind === "duration" ? je.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
777
|
+
validation: "duration",
|
|
778
|
+
code: d.invalid_string,
|
|
779
|
+
message: n.message
|
|
780
|
+
}), r.dirty()) : n.kind === "ip" ? Fe(e.data, n.version) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
781
|
+
validation: "ip",
|
|
782
|
+
code: d.invalid_string,
|
|
783
|
+
message: n.message
|
|
784
|
+
}), r.dirty()) : n.kind === "jwt" ? We(e.data, n.alg) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
785
|
+
validation: "jwt",
|
|
786
|
+
code: d.invalid_string,
|
|
787
|
+
message: n.message
|
|
788
|
+
}), r.dirty()) : n.kind === "cidr" ? Je(e.data, n.version) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
789
|
+
validation: "cidr",
|
|
790
|
+
code: d.invalid_string,
|
|
791
|
+
message: n.message
|
|
792
|
+
}), r.dirty()) : n.kind === "base64" ? Le.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
793
|
+
validation: "base64",
|
|
794
|
+
code: d.invalid_string,
|
|
795
|
+
message: n.message
|
|
796
|
+
}), r.dirty()) : n.kind === "base64url" ? ze.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
797
|
+
validation: "base64url",
|
|
798
|
+
code: d.invalid_string,
|
|
799
|
+
message: n.message
|
|
800
|
+
}), r.dirty()) : v.assertNever(n);
|
|
801
|
+
return {
|
|
802
|
+
status: r.value,
|
|
803
|
+
value: e.data
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
_regex(e, t, r) {
|
|
807
|
+
return this.refinement((a) => e.test(a), {
|
|
808
|
+
validation: t,
|
|
809
|
+
code: d.invalid_string,
|
|
810
|
+
...h.errToObj(r)
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
_addCheck(e) {
|
|
814
|
+
return new Z({
|
|
815
|
+
...this._def,
|
|
816
|
+
checks: [
|
|
817
|
+
...this._def.checks,
|
|
818
|
+
e
|
|
819
|
+
]
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
email(e) {
|
|
823
|
+
return this._addCheck({
|
|
824
|
+
kind: "email",
|
|
825
|
+
...h.errToObj(e)
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
url(e) {
|
|
829
|
+
return this._addCheck({
|
|
830
|
+
kind: "url",
|
|
831
|
+
...h.errToObj(e)
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
emoji(e) {
|
|
835
|
+
return this._addCheck({
|
|
836
|
+
kind: "emoji",
|
|
837
|
+
...h.errToObj(e)
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
uuid(e) {
|
|
841
|
+
return this._addCheck({
|
|
842
|
+
kind: "uuid",
|
|
843
|
+
...h.errToObj(e)
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
nanoid(e) {
|
|
847
|
+
return this._addCheck({
|
|
848
|
+
kind: "nanoid",
|
|
849
|
+
...h.errToObj(e)
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
cuid(e) {
|
|
853
|
+
return this._addCheck({
|
|
854
|
+
kind: "cuid",
|
|
855
|
+
...h.errToObj(e)
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
cuid2(e) {
|
|
859
|
+
return this._addCheck({
|
|
860
|
+
kind: "cuid2",
|
|
861
|
+
...h.errToObj(e)
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
ulid(e) {
|
|
865
|
+
return this._addCheck({
|
|
866
|
+
kind: "ulid",
|
|
867
|
+
...h.errToObj(e)
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
base64(e) {
|
|
871
|
+
return this._addCheck({
|
|
872
|
+
kind: "base64",
|
|
873
|
+
...h.errToObj(e)
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
base64url(e) {
|
|
877
|
+
return this._addCheck({
|
|
878
|
+
kind: "base64url",
|
|
879
|
+
...h.errToObj(e)
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
jwt(e) {
|
|
883
|
+
return this._addCheck({
|
|
884
|
+
kind: "jwt",
|
|
885
|
+
...h.errToObj(e)
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
ip(e) {
|
|
889
|
+
return this._addCheck({
|
|
890
|
+
kind: "ip",
|
|
891
|
+
...h.errToObj(e)
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
cidr(e) {
|
|
895
|
+
return this._addCheck({
|
|
896
|
+
kind: "cidr",
|
|
897
|
+
...h.errToObj(e)
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
datetime(e) {
|
|
901
|
+
return typeof e == "string" ? this._addCheck({
|
|
902
|
+
kind: "datetime",
|
|
903
|
+
precision: null,
|
|
904
|
+
offset: false,
|
|
905
|
+
local: false,
|
|
906
|
+
message: e
|
|
907
|
+
}) : this._addCheck({
|
|
908
|
+
kind: "datetime",
|
|
909
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
910
|
+
offset: (e == null ? void 0 : e.offset) ?? false,
|
|
911
|
+
local: (e == null ? void 0 : e.local) ?? false,
|
|
912
|
+
...h.errToObj(e == null ? void 0 : e.message)
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
date(e) {
|
|
916
|
+
return this._addCheck({
|
|
917
|
+
kind: "date",
|
|
918
|
+
message: e
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
time(e) {
|
|
922
|
+
return typeof e == "string" ? this._addCheck({
|
|
923
|
+
kind: "time",
|
|
924
|
+
precision: null,
|
|
925
|
+
message: e
|
|
926
|
+
}) : this._addCheck({
|
|
927
|
+
kind: "time",
|
|
928
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
929
|
+
...h.errToObj(e == null ? void 0 : e.message)
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
duration(e) {
|
|
933
|
+
return this._addCheck({
|
|
934
|
+
kind: "duration",
|
|
935
|
+
...h.errToObj(e)
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
regex(e, t) {
|
|
939
|
+
return this._addCheck({
|
|
940
|
+
kind: "regex",
|
|
941
|
+
regex: e,
|
|
942
|
+
...h.errToObj(t)
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
includes(e, t) {
|
|
946
|
+
return this._addCheck({
|
|
947
|
+
kind: "includes",
|
|
948
|
+
value: e,
|
|
949
|
+
position: t == null ? void 0 : t.position,
|
|
950
|
+
...h.errToObj(t == null ? void 0 : t.message)
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
startsWith(e, t) {
|
|
954
|
+
return this._addCheck({
|
|
955
|
+
kind: "startsWith",
|
|
956
|
+
value: e,
|
|
957
|
+
...h.errToObj(t)
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
endsWith(e, t) {
|
|
961
|
+
return this._addCheck({
|
|
962
|
+
kind: "endsWith",
|
|
963
|
+
value: e,
|
|
964
|
+
...h.errToObj(t)
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
min(e, t) {
|
|
968
|
+
return this._addCheck({
|
|
969
|
+
kind: "min",
|
|
970
|
+
value: e,
|
|
971
|
+
...h.errToObj(t)
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
max(e, t) {
|
|
975
|
+
return this._addCheck({
|
|
976
|
+
kind: "max",
|
|
977
|
+
value: e,
|
|
978
|
+
...h.errToObj(t)
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
length(e, t) {
|
|
982
|
+
return this._addCheck({
|
|
983
|
+
kind: "length",
|
|
984
|
+
value: e,
|
|
985
|
+
...h.errToObj(t)
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
nonempty(e) {
|
|
989
|
+
return this.min(1, h.errToObj(e));
|
|
990
|
+
}
|
|
991
|
+
trim() {
|
|
992
|
+
return new Z({
|
|
993
|
+
...this._def,
|
|
994
|
+
checks: [
|
|
995
|
+
...this._def.checks,
|
|
996
|
+
{
|
|
997
|
+
kind: "trim"
|
|
998
|
+
}
|
|
999
|
+
]
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
toLowerCase() {
|
|
1003
|
+
return new Z({
|
|
1004
|
+
...this._def,
|
|
1005
|
+
checks: [
|
|
1006
|
+
...this._def.checks,
|
|
1007
|
+
{
|
|
1008
|
+
kind: "toLowerCase"
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
toUpperCase() {
|
|
1014
|
+
return new Z({
|
|
1015
|
+
...this._def,
|
|
1016
|
+
checks: [
|
|
1017
|
+
...this._def.checks,
|
|
1018
|
+
{
|
|
1019
|
+
kind: "toUpperCase"
|
|
1020
|
+
}
|
|
1021
|
+
]
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
get isDatetime() {
|
|
1025
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1026
|
+
}
|
|
1027
|
+
get isDate() {
|
|
1028
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1029
|
+
}
|
|
1030
|
+
get isTime() {
|
|
1031
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1032
|
+
}
|
|
1033
|
+
get isDuration() {
|
|
1034
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1035
|
+
}
|
|
1036
|
+
get isEmail() {
|
|
1037
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1038
|
+
}
|
|
1039
|
+
get isURL() {
|
|
1040
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1041
|
+
}
|
|
1042
|
+
get isEmoji() {
|
|
1043
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1044
|
+
}
|
|
1045
|
+
get isUUID() {
|
|
1046
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1047
|
+
}
|
|
1048
|
+
get isNANOID() {
|
|
1049
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1050
|
+
}
|
|
1051
|
+
get isCUID() {
|
|
1052
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1053
|
+
}
|
|
1054
|
+
get isCUID2() {
|
|
1055
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1056
|
+
}
|
|
1057
|
+
get isULID() {
|
|
1058
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1059
|
+
}
|
|
1060
|
+
get isIP() {
|
|
1061
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1062
|
+
}
|
|
1063
|
+
get isCIDR() {
|
|
1064
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1065
|
+
}
|
|
1066
|
+
get isBase64() {
|
|
1067
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1068
|
+
}
|
|
1069
|
+
get isBase64url() {
|
|
1070
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1071
|
+
}
|
|
1072
|
+
get minLength() {
|
|
1073
|
+
let e = null;
|
|
1074
|
+
for (const t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1075
|
+
return e;
|
|
1076
|
+
}
|
|
1077
|
+
get maxLength() {
|
|
1078
|
+
let e = null;
|
|
1079
|
+
for (const t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1080
|
+
return e;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
Z.create = (s) => new Z({
|
|
1084
|
+
checks: [],
|
|
1085
|
+
typeName: p.ZodString,
|
|
1086
|
+
coerce: (s == null ? void 0 : s.coerce) ?? false,
|
|
1087
|
+
..._(s)
|
|
1088
|
+
});
|
|
1089
|
+
function qe(s, e) {
|
|
1090
|
+
const t = (s.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, a = t > r ? t : r, n = Number.parseInt(s.toFixed(a).replace(".", "")), i = Number.parseInt(e.toFixed(a).replace(".", ""));
|
|
1091
|
+
return n % i / 10 ** a;
|
|
1092
|
+
}
|
|
1093
|
+
class P extends y {
|
|
1094
|
+
constructor() {
|
|
1095
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1096
|
+
}
|
|
1097
|
+
_parse(e) {
|
|
1098
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
|
|
1099
|
+
const n = this._getOrReturnCtx(e);
|
|
1100
|
+
return c(n, {
|
|
1101
|
+
code: d.invalid_type,
|
|
1102
|
+
expected: f.number,
|
|
1103
|
+
received: n.parsedType
|
|
1104
|
+
}), m;
|
|
1105
|
+
}
|
|
1106
|
+
let r;
|
|
1107
|
+
const a = new k();
|
|
1108
|
+
for (const n of this._def.checks) n.kind === "int" ? v.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1109
|
+
code: d.invalid_type,
|
|
1110
|
+
expected: "integer",
|
|
1111
|
+
received: "float",
|
|
1112
|
+
message: n.message
|
|
1113
|
+
}), a.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1114
|
+
code: d.too_small,
|
|
1115
|
+
minimum: n.value,
|
|
1116
|
+
type: "number",
|
|
1117
|
+
inclusive: n.inclusive,
|
|
1118
|
+
exact: false,
|
|
1119
|
+
message: n.message
|
|
1120
|
+
}), a.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1121
|
+
code: d.too_big,
|
|
1122
|
+
maximum: n.value,
|
|
1123
|
+
type: "number",
|
|
1124
|
+
inclusive: n.inclusive,
|
|
1125
|
+
exact: false,
|
|
1126
|
+
message: n.message
|
|
1127
|
+
}), a.dirty()) : n.kind === "multipleOf" ? qe(e.data, n.value) !== 0 && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1128
|
+
code: d.not_multiple_of,
|
|
1129
|
+
multipleOf: n.value,
|
|
1130
|
+
message: n.message
|
|
1131
|
+
}), a.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1132
|
+
code: d.not_finite,
|
|
1133
|
+
message: n.message
|
|
1134
|
+
}), a.dirty()) : v.assertNever(n);
|
|
1135
|
+
return {
|
|
1136
|
+
status: a.value,
|
|
1137
|
+
value: e.data
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
gte(e, t) {
|
|
1141
|
+
return this.setLimit("min", e, true, h.toString(t));
|
|
1142
|
+
}
|
|
1143
|
+
gt(e, t) {
|
|
1144
|
+
return this.setLimit("min", e, false, h.toString(t));
|
|
1145
|
+
}
|
|
1146
|
+
lte(e, t) {
|
|
1147
|
+
return this.setLimit("max", e, true, h.toString(t));
|
|
1148
|
+
}
|
|
1149
|
+
lt(e, t) {
|
|
1150
|
+
return this.setLimit("max", e, false, h.toString(t));
|
|
1151
|
+
}
|
|
1152
|
+
setLimit(e, t, r, a) {
|
|
1153
|
+
return new P({
|
|
1154
|
+
...this._def,
|
|
1155
|
+
checks: [
|
|
1156
|
+
...this._def.checks,
|
|
1157
|
+
{
|
|
1158
|
+
kind: e,
|
|
1159
|
+
value: t,
|
|
1160
|
+
inclusive: r,
|
|
1161
|
+
message: h.toString(a)
|
|
1162
|
+
}
|
|
1163
|
+
]
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
_addCheck(e) {
|
|
1167
|
+
return new P({
|
|
1168
|
+
...this._def,
|
|
1169
|
+
checks: [
|
|
1170
|
+
...this._def.checks,
|
|
1171
|
+
e
|
|
1172
|
+
]
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
int(e) {
|
|
1176
|
+
return this._addCheck({
|
|
1177
|
+
kind: "int",
|
|
1178
|
+
message: h.toString(e)
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
positive(e) {
|
|
1182
|
+
return this._addCheck({
|
|
1183
|
+
kind: "min",
|
|
1184
|
+
value: 0,
|
|
1185
|
+
inclusive: false,
|
|
1186
|
+
message: h.toString(e)
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
negative(e) {
|
|
1190
|
+
return this._addCheck({
|
|
1191
|
+
kind: "max",
|
|
1192
|
+
value: 0,
|
|
1193
|
+
inclusive: false,
|
|
1194
|
+
message: h.toString(e)
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
nonpositive(e) {
|
|
1198
|
+
return this._addCheck({
|
|
1199
|
+
kind: "max",
|
|
1200
|
+
value: 0,
|
|
1201
|
+
inclusive: true,
|
|
1202
|
+
message: h.toString(e)
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
nonnegative(e) {
|
|
1206
|
+
return this._addCheck({
|
|
1207
|
+
kind: "min",
|
|
1208
|
+
value: 0,
|
|
1209
|
+
inclusive: true,
|
|
1210
|
+
message: h.toString(e)
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
multipleOf(e, t) {
|
|
1214
|
+
return this._addCheck({
|
|
1215
|
+
kind: "multipleOf",
|
|
1216
|
+
value: e,
|
|
1217
|
+
message: h.toString(t)
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
finite(e) {
|
|
1221
|
+
return this._addCheck({
|
|
1222
|
+
kind: "finite",
|
|
1223
|
+
message: h.toString(e)
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
safe(e) {
|
|
1227
|
+
return this._addCheck({
|
|
1228
|
+
kind: "min",
|
|
1229
|
+
inclusive: true,
|
|
1230
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1231
|
+
message: h.toString(e)
|
|
1232
|
+
})._addCheck({
|
|
1233
|
+
kind: "max",
|
|
1234
|
+
inclusive: true,
|
|
1235
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1236
|
+
message: h.toString(e)
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
get minValue() {
|
|
1240
|
+
let e = null;
|
|
1241
|
+
for (const t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1242
|
+
return e;
|
|
1243
|
+
}
|
|
1244
|
+
get maxValue() {
|
|
1245
|
+
let e = null;
|
|
1246
|
+
for (const t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1247
|
+
return e;
|
|
1248
|
+
}
|
|
1249
|
+
get isInt() {
|
|
1250
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && v.isInteger(e.value));
|
|
1251
|
+
}
|
|
1252
|
+
get isFinite() {
|
|
1253
|
+
let e = null, t = null;
|
|
1254
|
+
for (const r of this._def.checks) {
|
|
1255
|
+
if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf") return true;
|
|
1256
|
+
r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1257
|
+
}
|
|
1258
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
P.create = (s) => new P({
|
|
1262
|
+
checks: [],
|
|
1263
|
+
typeName: p.ZodNumber,
|
|
1264
|
+
coerce: (s == null ? void 0 : s.coerce) || false,
|
|
1265
|
+
..._(s)
|
|
1266
|
+
});
|
|
1267
|
+
class L extends y {
|
|
1268
|
+
constructor() {
|
|
1269
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1270
|
+
}
|
|
1271
|
+
_parse(e) {
|
|
1272
|
+
if (this._def.coerce) try {
|
|
1273
|
+
e.data = BigInt(e.data);
|
|
1274
|
+
} catch {
|
|
1275
|
+
return this._getInvalidInput(e);
|
|
1276
|
+
}
|
|
1277
|
+
if (this._getType(e) !== f.bigint) return this._getInvalidInput(e);
|
|
1278
|
+
let r;
|
|
1279
|
+
const a = new k();
|
|
1280
|
+
for (const n of this._def.checks) n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1281
|
+
code: d.too_small,
|
|
1282
|
+
type: "bigint",
|
|
1283
|
+
minimum: n.value,
|
|
1284
|
+
inclusive: n.inclusive,
|
|
1285
|
+
message: n.message
|
|
1286
|
+
}), a.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1287
|
+
code: d.too_big,
|
|
1288
|
+
type: "bigint",
|
|
1289
|
+
maximum: n.value,
|
|
1290
|
+
inclusive: n.inclusive,
|
|
1291
|
+
message: n.message
|
|
1292
|
+
}), a.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1293
|
+
code: d.not_multiple_of,
|
|
1294
|
+
multipleOf: n.value,
|
|
1295
|
+
message: n.message
|
|
1296
|
+
}), a.dirty()) : v.assertNever(n);
|
|
1297
|
+
return {
|
|
1298
|
+
status: a.value,
|
|
1299
|
+
value: e.data
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
_getInvalidInput(e) {
|
|
1303
|
+
const t = this._getOrReturnCtx(e);
|
|
1304
|
+
return c(t, {
|
|
1305
|
+
code: d.invalid_type,
|
|
1306
|
+
expected: f.bigint,
|
|
1307
|
+
received: t.parsedType
|
|
1308
|
+
}), m;
|
|
1309
|
+
}
|
|
1310
|
+
gte(e, t) {
|
|
1311
|
+
return this.setLimit("min", e, true, h.toString(t));
|
|
1312
|
+
}
|
|
1313
|
+
gt(e, t) {
|
|
1314
|
+
return this.setLimit("min", e, false, h.toString(t));
|
|
1315
|
+
}
|
|
1316
|
+
lte(e, t) {
|
|
1317
|
+
return this.setLimit("max", e, true, h.toString(t));
|
|
1318
|
+
}
|
|
1319
|
+
lt(e, t) {
|
|
1320
|
+
return this.setLimit("max", e, false, h.toString(t));
|
|
1321
|
+
}
|
|
1322
|
+
setLimit(e, t, r, a) {
|
|
1323
|
+
return new L({
|
|
1324
|
+
...this._def,
|
|
1325
|
+
checks: [
|
|
1326
|
+
...this._def.checks,
|
|
1327
|
+
{
|
|
1328
|
+
kind: e,
|
|
1329
|
+
value: t,
|
|
1330
|
+
inclusive: r,
|
|
1331
|
+
message: h.toString(a)
|
|
1332
|
+
}
|
|
1333
|
+
]
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
_addCheck(e) {
|
|
1337
|
+
return new L({
|
|
1338
|
+
...this._def,
|
|
1339
|
+
checks: [
|
|
1340
|
+
...this._def.checks,
|
|
1341
|
+
e
|
|
1342
|
+
]
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
positive(e) {
|
|
1346
|
+
return this._addCheck({
|
|
1347
|
+
kind: "min",
|
|
1348
|
+
value: BigInt(0),
|
|
1349
|
+
inclusive: false,
|
|
1350
|
+
message: h.toString(e)
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
negative(e) {
|
|
1354
|
+
return this._addCheck({
|
|
1355
|
+
kind: "max",
|
|
1356
|
+
value: BigInt(0),
|
|
1357
|
+
inclusive: false,
|
|
1358
|
+
message: h.toString(e)
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
nonpositive(e) {
|
|
1362
|
+
return this._addCheck({
|
|
1363
|
+
kind: "max",
|
|
1364
|
+
value: BigInt(0),
|
|
1365
|
+
inclusive: true,
|
|
1366
|
+
message: h.toString(e)
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
nonnegative(e) {
|
|
1370
|
+
return this._addCheck({
|
|
1371
|
+
kind: "min",
|
|
1372
|
+
value: BigInt(0),
|
|
1373
|
+
inclusive: true,
|
|
1374
|
+
message: h.toString(e)
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
multipleOf(e, t) {
|
|
1378
|
+
return this._addCheck({
|
|
1379
|
+
kind: "multipleOf",
|
|
1380
|
+
value: e,
|
|
1381
|
+
message: h.toString(t)
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
get minValue() {
|
|
1385
|
+
let e = null;
|
|
1386
|
+
for (const t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1387
|
+
return e;
|
|
1388
|
+
}
|
|
1389
|
+
get maxValue() {
|
|
1390
|
+
let e = null;
|
|
1391
|
+
for (const t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1392
|
+
return e;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
L.create = (s) => new L({
|
|
1396
|
+
checks: [],
|
|
1397
|
+
typeName: p.ZodBigInt,
|
|
1398
|
+
coerce: (s == null ? void 0 : s.coerce) ?? false,
|
|
1399
|
+
..._(s)
|
|
1400
|
+
});
|
|
1401
|
+
class ie extends y {
|
|
1402
|
+
_parse(e) {
|
|
1403
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1404
|
+
const r = this._getOrReturnCtx(e);
|
|
1405
|
+
return c(r, {
|
|
1406
|
+
code: d.invalid_type,
|
|
1407
|
+
expected: f.boolean,
|
|
1408
|
+
received: r.parsedType
|
|
1409
|
+
}), m;
|
|
1410
|
+
}
|
|
1411
|
+
return b(e.data);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
ie.create = (s) => new ie({
|
|
1415
|
+
typeName: p.ZodBoolean,
|
|
1416
|
+
coerce: (s == null ? void 0 : s.coerce) || false,
|
|
1417
|
+
..._(s)
|
|
1418
|
+
});
|
|
1419
|
+
class B extends y {
|
|
1420
|
+
_parse(e) {
|
|
1421
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1422
|
+
const n = this._getOrReturnCtx(e);
|
|
1423
|
+
return c(n, {
|
|
1424
|
+
code: d.invalid_type,
|
|
1425
|
+
expected: f.date,
|
|
1426
|
+
received: n.parsedType
|
|
1427
|
+
}), m;
|
|
1428
|
+
}
|
|
1429
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
1430
|
+
const n = this._getOrReturnCtx(e);
|
|
1431
|
+
return c(n, {
|
|
1432
|
+
code: d.invalid_date
|
|
1433
|
+
}), m;
|
|
1434
|
+
}
|
|
1435
|
+
const r = new k();
|
|
1436
|
+
let a;
|
|
1437
|
+
for (const n of this._def.checks) n.kind === "min" ? e.data.getTime() < n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
1438
|
+
code: d.too_small,
|
|
1439
|
+
message: n.message,
|
|
1440
|
+
inclusive: true,
|
|
1441
|
+
exact: false,
|
|
1442
|
+
minimum: n.value,
|
|
1443
|
+
type: "date"
|
|
1444
|
+
}), r.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
1445
|
+
code: d.too_big,
|
|
1446
|
+
message: n.message,
|
|
1447
|
+
inclusive: true,
|
|
1448
|
+
exact: false,
|
|
1449
|
+
maximum: n.value,
|
|
1450
|
+
type: "date"
|
|
1451
|
+
}), r.dirty()) : v.assertNever(n);
|
|
1452
|
+
return {
|
|
1453
|
+
status: r.value,
|
|
1454
|
+
value: new Date(e.data.getTime())
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
_addCheck(e) {
|
|
1458
|
+
return new B({
|
|
1459
|
+
...this._def,
|
|
1460
|
+
checks: [
|
|
1461
|
+
...this._def.checks,
|
|
1462
|
+
e
|
|
1463
|
+
]
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
min(e, t) {
|
|
1467
|
+
return this._addCheck({
|
|
1468
|
+
kind: "min",
|
|
1469
|
+
value: e.getTime(),
|
|
1470
|
+
message: h.toString(t)
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
max(e, t) {
|
|
1474
|
+
return this._addCheck({
|
|
1475
|
+
kind: "max",
|
|
1476
|
+
value: e.getTime(),
|
|
1477
|
+
message: h.toString(t)
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
get minDate() {
|
|
1481
|
+
let e = null;
|
|
1482
|
+
for (const t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1483
|
+
return e != null ? new Date(e) : null;
|
|
1484
|
+
}
|
|
1485
|
+
get maxDate() {
|
|
1486
|
+
let e = null;
|
|
1487
|
+
for (const t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1488
|
+
return e != null ? new Date(e) : null;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
B.create = (s) => new B({
|
|
1492
|
+
checks: [],
|
|
1493
|
+
coerce: (s == null ? void 0 : s.coerce) || false,
|
|
1494
|
+
typeName: p.ZodDate,
|
|
1495
|
+
..._(s)
|
|
1496
|
+
});
|
|
1497
|
+
class oe extends y {
|
|
1498
|
+
_parse(e) {
|
|
1499
|
+
if (this._getType(e) !== f.symbol) {
|
|
1500
|
+
const r = this._getOrReturnCtx(e);
|
|
1501
|
+
return c(r, {
|
|
1502
|
+
code: d.invalid_type,
|
|
1503
|
+
expected: f.symbol,
|
|
1504
|
+
received: r.parsedType
|
|
1505
|
+
}), m;
|
|
1506
|
+
}
|
|
1507
|
+
return b(e.data);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
oe.create = (s) => new oe({
|
|
1511
|
+
typeName: p.ZodSymbol,
|
|
1512
|
+
..._(s)
|
|
1513
|
+
});
|
|
1514
|
+
class de extends y {
|
|
1515
|
+
_parse(e) {
|
|
1516
|
+
if (this._getType(e) !== f.undefined) {
|
|
1517
|
+
const r = this._getOrReturnCtx(e);
|
|
1518
|
+
return c(r, {
|
|
1519
|
+
code: d.invalid_type,
|
|
1520
|
+
expected: f.undefined,
|
|
1521
|
+
received: r.parsedType
|
|
1522
|
+
}), m;
|
|
1523
|
+
}
|
|
1524
|
+
return b(e.data);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
de.create = (s) => new de({
|
|
1528
|
+
typeName: p.ZodUndefined,
|
|
1529
|
+
..._(s)
|
|
1530
|
+
});
|
|
1531
|
+
class ce extends y {
|
|
1532
|
+
_parse(e) {
|
|
1533
|
+
if (this._getType(e) !== f.null) {
|
|
1534
|
+
const r = this._getOrReturnCtx(e);
|
|
1535
|
+
return c(r, {
|
|
1536
|
+
code: d.invalid_type,
|
|
1537
|
+
expected: f.null,
|
|
1538
|
+
received: r.parsedType
|
|
1539
|
+
}), m;
|
|
1540
|
+
}
|
|
1541
|
+
return b(e.data);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
ce.create = (s) => new ce({
|
|
1545
|
+
typeName: p.ZodNull,
|
|
1546
|
+
..._(s)
|
|
1547
|
+
});
|
|
1548
|
+
class G extends y {
|
|
1549
|
+
constructor() {
|
|
1550
|
+
super(...arguments), this._any = true;
|
|
1551
|
+
}
|
|
1552
|
+
_parse(e) {
|
|
1553
|
+
return b(e.data);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
G.create = (s) => new G({
|
|
1557
|
+
typeName: p.ZodAny,
|
|
1558
|
+
..._(s)
|
|
1559
|
+
});
|
|
1560
|
+
class ue extends y {
|
|
1561
|
+
constructor() {
|
|
1562
|
+
super(...arguments), this._unknown = true;
|
|
1563
|
+
}
|
|
1564
|
+
_parse(e) {
|
|
1565
|
+
return b(e.data);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
ue.create = (s) => new ue({
|
|
1569
|
+
typeName: p.ZodUnknown,
|
|
1570
|
+
..._(s)
|
|
1571
|
+
});
|
|
1572
|
+
class A extends y {
|
|
1573
|
+
_parse(e) {
|
|
1574
|
+
const t = this._getOrReturnCtx(e);
|
|
1575
|
+
return c(t, {
|
|
1576
|
+
code: d.invalid_type,
|
|
1577
|
+
expected: f.never,
|
|
1578
|
+
received: t.parsedType
|
|
1579
|
+
}), m;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
A.create = (s) => new A({
|
|
1583
|
+
typeName: p.ZodNever,
|
|
1584
|
+
..._(s)
|
|
1585
|
+
});
|
|
1586
|
+
class le extends y {
|
|
1587
|
+
_parse(e) {
|
|
1588
|
+
if (this._getType(e) !== f.undefined) {
|
|
1589
|
+
const r = this._getOrReturnCtx(e);
|
|
1590
|
+
return c(r, {
|
|
1591
|
+
code: d.invalid_type,
|
|
1592
|
+
expected: f.void,
|
|
1593
|
+
received: r.parsedType
|
|
1594
|
+
}), m;
|
|
1595
|
+
}
|
|
1596
|
+
return b(e.data);
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
le.create = (s) => new le({
|
|
1600
|
+
typeName: p.ZodVoid,
|
|
1601
|
+
..._(s)
|
|
1602
|
+
});
|
|
1603
|
+
class w extends y {
|
|
1604
|
+
_parse(e) {
|
|
1605
|
+
const { ctx: t, status: r } = this._processInputParams(e), a = this._def;
|
|
1606
|
+
if (t.parsedType !== f.array) return c(t, {
|
|
1607
|
+
code: d.invalid_type,
|
|
1608
|
+
expected: f.array,
|
|
1609
|
+
received: t.parsedType
|
|
1610
|
+
}), m;
|
|
1611
|
+
if (a.exactLength !== null) {
|
|
1612
|
+
const i = t.data.length > a.exactLength.value, o = t.data.length < a.exactLength.value;
|
|
1613
|
+
(i || o) && (c(t, {
|
|
1614
|
+
code: i ? d.too_big : d.too_small,
|
|
1615
|
+
minimum: o ? a.exactLength.value : void 0,
|
|
1616
|
+
maximum: i ? a.exactLength.value : void 0,
|
|
1617
|
+
type: "array",
|
|
1618
|
+
inclusive: true,
|
|
1619
|
+
exact: true,
|
|
1620
|
+
message: a.exactLength.message
|
|
1621
|
+
}), r.dirty());
|
|
1622
|
+
}
|
|
1623
|
+
if (a.minLength !== null && t.data.length < a.minLength.value && (c(t, {
|
|
1624
|
+
code: d.too_small,
|
|
1625
|
+
minimum: a.minLength.value,
|
|
1626
|
+
type: "array",
|
|
1627
|
+
inclusive: true,
|
|
1628
|
+
exact: false,
|
|
1629
|
+
message: a.minLength.message
|
|
1630
|
+
}), r.dirty()), a.maxLength !== null && t.data.length > a.maxLength.value && (c(t, {
|
|
1631
|
+
code: d.too_big,
|
|
1632
|
+
maximum: a.maxLength.value,
|
|
1633
|
+
type: "array",
|
|
1634
|
+
inclusive: true,
|
|
1635
|
+
exact: false,
|
|
1636
|
+
message: a.maxLength.message
|
|
1637
|
+
}), r.dirty()), t.common.async) return Promise.all([
|
|
1638
|
+
...t.data
|
|
1639
|
+
].map((i, o) => a.type._parseAsync(new N(t, i, t.path, o)))).then((i) => k.mergeArray(r, i));
|
|
1640
|
+
const n = [
|
|
1641
|
+
...t.data
|
|
1642
|
+
].map((i, o) => a.type._parseSync(new N(t, i, t.path, o)));
|
|
1643
|
+
return k.mergeArray(r, n);
|
|
1644
|
+
}
|
|
1645
|
+
get element() {
|
|
1646
|
+
return this._def.type;
|
|
1647
|
+
}
|
|
1648
|
+
min(e, t) {
|
|
1649
|
+
return new w({
|
|
1650
|
+
...this._def,
|
|
1651
|
+
minLength: {
|
|
1652
|
+
value: e,
|
|
1653
|
+
message: h.toString(t)
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
max(e, t) {
|
|
1658
|
+
return new w({
|
|
1659
|
+
...this._def,
|
|
1660
|
+
maxLength: {
|
|
1661
|
+
value: e,
|
|
1662
|
+
message: h.toString(t)
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
length(e, t) {
|
|
1667
|
+
return new w({
|
|
1668
|
+
...this._def,
|
|
1669
|
+
exactLength: {
|
|
1670
|
+
value: e,
|
|
1671
|
+
message: h.toString(t)
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
nonempty(e) {
|
|
1676
|
+
return this.min(1, e);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
w.create = (s, e) => new w({
|
|
1680
|
+
type: s,
|
|
1681
|
+
minLength: null,
|
|
1682
|
+
maxLength: null,
|
|
1683
|
+
exactLength: null,
|
|
1684
|
+
typeName: p.ZodArray,
|
|
1685
|
+
..._(e)
|
|
1686
|
+
});
|
|
1687
|
+
function j(s) {
|
|
1688
|
+
if (s instanceof x) {
|
|
1689
|
+
const e = {};
|
|
1690
|
+
for (const t in s.shape) {
|
|
1691
|
+
const r = s.shape[t];
|
|
1692
|
+
e[t] = S.create(j(r));
|
|
1693
|
+
}
|
|
1694
|
+
return new x({
|
|
1695
|
+
...s._def,
|
|
1696
|
+
shape: () => e
|
|
1697
|
+
});
|
|
1698
|
+
} else return s instanceof w ? new w({
|
|
1699
|
+
...s._def,
|
|
1700
|
+
type: j(s.element)
|
|
1701
|
+
}) : s instanceof S ? S.create(j(s.unwrap())) : s instanceof V ? V.create(j(s.unwrap())) : s instanceof R ? R.create(s.items.map((e) => j(e))) : s;
|
|
1702
|
+
}
|
|
1703
|
+
class x extends y {
|
|
1704
|
+
constructor() {
|
|
1705
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1706
|
+
}
|
|
1707
|
+
_getCached() {
|
|
1708
|
+
if (this._cached !== null) return this._cached;
|
|
1709
|
+
const e = this._def.shape(), t = v.objectKeys(e);
|
|
1710
|
+
return this._cached = {
|
|
1711
|
+
shape: e,
|
|
1712
|
+
keys: t
|
|
1713
|
+
}, this._cached;
|
|
1714
|
+
}
|
|
1715
|
+
_parse(e) {
|
|
1716
|
+
if (this._getType(e) !== f.object) {
|
|
1717
|
+
const l = this._getOrReturnCtx(e);
|
|
1718
|
+
return c(l, {
|
|
1719
|
+
code: d.invalid_type,
|
|
1720
|
+
expected: f.object,
|
|
1721
|
+
received: l.parsedType
|
|
1722
|
+
}), m;
|
|
1723
|
+
}
|
|
1724
|
+
const { status: r, ctx: a } = this._processInputParams(e), { shape: n, keys: i } = this._getCached(), o = [];
|
|
1725
|
+
if (!(this._def.catchall instanceof A && this._def.unknownKeys === "strip")) for (const l in a.data) i.includes(l) || o.push(l);
|
|
1726
|
+
const u = [];
|
|
1727
|
+
for (const l of i) {
|
|
1728
|
+
const g = n[l], C = a.data[l];
|
|
1729
|
+
u.push({
|
|
1730
|
+
key: {
|
|
1731
|
+
status: "valid",
|
|
1732
|
+
value: l
|
|
1733
|
+
},
|
|
1734
|
+
value: g._parse(new N(a, C, a.path, l)),
|
|
1735
|
+
alwaysSet: l in a.data
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
if (this._def.catchall instanceof A) {
|
|
1739
|
+
const l = this._def.unknownKeys;
|
|
1740
|
+
if (l === "passthrough") for (const g of o) u.push({
|
|
1741
|
+
key: {
|
|
1742
|
+
status: "valid",
|
|
1743
|
+
value: g
|
|
1744
|
+
},
|
|
1745
|
+
value: {
|
|
1746
|
+
status: "valid",
|
|
1747
|
+
value: a.data[g]
|
|
1748
|
+
}
|
|
1749
|
+
});
|
|
1750
|
+
else if (l === "strict") o.length > 0 && (c(a, {
|
|
1751
|
+
code: d.unrecognized_keys,
|
|
1752
|
+
keys: o
|
|
1753
|
+
}), r.dirty());
|
|
1754
|
+
else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1755
|
+
} else {
|
|
1756
|
+
const l = this._def.catchall;
|
|
1757
|
+
for (const g of o) {
|
|
1758
|
+
const C = a.data[g];
|
|
1759
|
+
u.push({
|
|
1760
|
+
key: {
|
|
1761
|
+
status: "valid",
|
|
1762
|
+
value: g
|
|
1763
|
+
},
|
|
1764
|
+
value: l._parse(new N(a, C, a.path, g)),
|
|
1765
|
+
alwaysSet: g in a.data
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
1770
|
+
const l = [];
|
|
1771
|
+
for (const g of u) {
|
|
1772
|
+
const C = await g.key, q = await g.value;
|
|
1773
|
+
l.push({
|
|
1774
|
+
key: C,
|
|
1775
|
+
value: q,
|
|
1776
|
+
alwaysSet: g.alwaysSet
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
return l;
|
|
1780
|
+
}).then((l) => k.mergeObjectSync(r, l)) : k.mergeObjectSync(r, u);
|
|
1781
|
+
}
|
|
1782
|
+
get shape() {
|
|
1783
|
+
return this._def.shape();
|
|
1784
|
+
}
|
|
1785
|
+
strict(e) {
|
|
1786
|
+
return h.errToObj, new x({
|
|
1787
|
+
...this._def,
|
|
1788
|
+
unknownKeys: "strict",
|
|
1789
|
+
...e !== void 0 ? {
|
|
1790
|
+
errorMap: (t, r) => {
|
|
1791
|
+
var _a, _b;
|
|
1792
|
+
const a = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, t, r).message) ?? r.defaultError;
|
|
1793
|
+
return t.code === "unrecognized_keys" ? {
|
|
1794
|
+
message: h.errToObj(e).message ?? a
|
|
1795
|
+
} : {
|
|
1796
|
+
message: a
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
} : {}
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
strip() {
|
|
1803
|
+
return new x({
|
|
1804
|
+
...this._def,
|
|
1805
|
+
unknownKeys: "strip"
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
passthrough() {
|
|
1809
|
+
return new x({
|
|
1810
|
+
...this._def,
|
|
1811
|
+
unknownKeys: "passthrough"
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
extend(e) {
|
|
1815
|
+
return new x({
|
|
1816
|
+
...this._def,
|
|
1817
|
+
shape: () => ({
|
|
1818
|
+
...this._def.shape(),
|
|
1819
|
+
...e
|
|
1820
|
+
})
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
merge(e) {
|
|
1824
|
+
return new x({
|
|
1825
|
+
unknownKeys: e._def.unknownKeys,
|
|
1826
|
+
catchall: e._def.catchall,
|
|
1827
|
+
shape: () => ({
|
|
1828
|
+
...this._def.shape(),
|
|
1829
|
+
...e._def.shape()
|
|
1830
|
+
}),
|
|
1831
|
+
typeName: p.ZodObject
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
setKey(e, t) {
|
|
1835
|
+
return this.augment({
|
|
1836
|
+
[e]: t
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
catchall(e) {
|
|
1840
|
+
return new x({
|
|
1841
|
+
...this._def,
|
|
1842
|
+
catchall: e
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
pick(e) {
|
|
1846
|
+
const t = {};
|
|
1847
|
+
for (const r of v.objectKeys(e)) e[r] && this.shape[r] && (t[r] = this.shape[r]);
|
|
1848
|
+
return new x({
|
|
1849
|
+
...this._def,
|
|
1850
|
+
shape: () => t
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
omit(e) {
|
|
1854
|
+
const t = {};
|
|
1855
|
+
for (const r of v.objectKeys(this.shape)) e[r] || (t[r] = this.shape[r]);
|
|
1856
|
+
return new x({
|
|
1857
|
+
...this._def,
|
|
1858
|
+
shape: () => t
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
deepPartial() {
|
|
1862
|
+
return j(this);
|
|
1863
|
+
}
|
|
1864
|
+
partial(e) {
|
|
1865
|
+
const t = {};
|
|
1866
|
+
for (const r of v.objectKeys(this.shape)) {
|
|
1867
|
+
const a = this.shape[r];
|
|
1868
|
+
e && !e[r] ? t[r] = a : t[r] = a.optional();
|
|
1869
|
+
}
|
|
1870
|
+
return new x({
|
|
1871
|
+
...this._def,
|
|
1872
|
+
shape: () => t
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
required(e) {
|
|
1876
|
+
const t = {};
|
|
1877
|
+
for (const r of v.objectKeys(this.shape)) if (e && !e[r]) t[r] = this.shape[r];
|
|
1878
|
+
else {
|
|
1879
|
+
let n = this.shape[r];
|
|
1880
|
+
for (; n instanceof S; ) n = n._def.innerType;
|
|
1881
|
+
t[r] = n;
|
|
1882
|
+
}
|
|
1883
|
+
return new x({
|
|
1884
|
+
...this._def,
|
|
1885
|
+
shape: () => t
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
keyof() {
|
|
1889
|
+
return ke(v.objectKeys(this.shape));
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
x.create = (s, e) => new x({
|
|
1893
|
+
shape: () => s,
|
|
1894
|
+
unknownKeys: "strip",
|
|
1895
|
+
catchall: A.create(),
|
|
1896
|
+
typeName: p.ZodObject,
|
|
1897
|
+
..._(e)
|
|
1898
|
+
});
|
|
1899
|
+
x.strictCreate = (s, e) => new x({
|
|
1900
|
+
shape: () => s,
|
|
1901
|
+
unknownKeys: "strict",
|
|
1902
|
+
catchall: A.create(),
|
|
1903
|
+
typeName: p.ZodObject,
|
|
1904
|
+
..._(e)
|
|
1905
|
+
});
|
|
1906
|
+
x.lazycreate = (s, e) => new x({
|
|
1907
|
+
shape: s,
|
|
1908
|
+
unknownKeys: "strip",
|
|
1909
|
+
catchall: A.create(),
|
|
1910
|
+
typeName: p.ZodObject,
|
|
1911
|
+
..._(e)
|
|
1912
|
+
});
|
|
1913
|
+
class F extends y {
|
|
1914
|
+
_parse(e) {
|
|
1915
|
+
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1916
|
+
function a(n) {
|
|
1917
|
+
for (const o of n) if (o.result.status === "valid") return o.result;
|
|
1918
|
+
for (const o of n) if (o.result.status === "dirty") return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1919
|
+
const i = n.map((o) => new O(o.ctx.common.issues));
|
|
1920
|
+
return c(t, {
|
|
1921
|
+
code: d.invalid_union,
|
|
1922
|
+
unionErrors: i
|
|
1923
|
+
}), m;
|
|
1924
|
+
}
|
|
1925
|
+
if (t.common.async) return Promise.all(r.map(async (n) => {
|
|
1926
|
+
const i = {
|
|
1927
|
+
...t,
|
|
1928
|
+
common: {
|
|
1929
|
+
...t.common,
|
|
1930
|
+
issues: []
|
|
1931
|
+
},
|
|
1932
|
+
parent: null
|
|
1933
|
+
};
|
|
1934
|
+
return {
|
|
1935
|
+
result: await n._parseAsync({
|
|
1936
|
+
data: t.data,
|
|
1937
|
+
path: t.path,
|
|
1938
|
+
parent: i
|
|
1939
|
+
}),
|
|
1940
|
+
ctx: i
|
|
1941
|
+
};
|
|
1942
|
+
})).then(a);
|
|
1943
|
+
{
|
|
1944
|
+
let n;
|
|
1945
|
+
const i = [];
|
|
1946
|
+
for (const u of r) {
|
|
1947
|
+
const l = {
|
|
1948
|
+
...t,
|
|
1949
|
+
common: {
|
|
1950
|
+
...t.common,
|
|
1951
|
+
issues: []
|
|
1952
|
+
},
|
|
1953
|
+
parent: null
|
|
1954
|
+
}, g = u._parseSync({
|
|
1955
|
+
data: t.data,
|
|
1956
|
+
path: t.path,
|
|
1957
|
+
parent: l
|
|
1958
|
+
});
|
|
1959
|
+
if (g.status === "valid") return g;
|
|
1960
|
+
g.status === "dirty" && !n && (n = {
|
|
1961
|
+
result: g,
|
|
1962
|
+
ctx: l
|
|
1963
|
+
}), l.common.issues.length && i.push(l.common.issues);
|
|
1964
|
+
}
|
|
1965
|
+
if (n) return t.common.issues.push(...n.ctx.common.issues), n.result;
|
|
1966
|
+
const o = i.map((u) => new O(u));
|
|
1967
|
+
return c(t, {
|
|
1968
|
+
code: d.invalid_union,
|
|
1969
|
+
unionErrors: o
|
|
1970
|
+
}), m;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
get options() {
|
|
1974
|
+
return this._def.options;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
F.create = (s, e) => new F({
|
|
1978
|
+
options: s,
|
|
1979
|
+
typeName: p.ZodUnion,
|
|
1980
|
+
..._(e)
|
|
1981
|
+
});
|
|
1982
|
+
function Q(s, e) {
|
|
1983
|
+
const t = T(s), r = T(e);
|
|
1984
|
+
if (s === e) return {
|
|
1985
|
+
valid: true,
|
|
1986
|
+
data: s
|
|
1987
|
+
};
|
|
1988
|
+
if (t === f.object && r === f.object) {
|
|
1989
|
+
const a = v.objectKeys(e), n = v.objectKeys(s).filter((o) => a.indexOf(o) !== -1), i = {
|
|
1990
|
+
...s,
|
|
1991
|
+
...e
|
|
1992
|
+
};
|
|
1993
|
+
for (const o of n) {
|
|
1994
|
+
const u = Q(s[o], e[o]);
|
|
1995
|
+
if (!u.valid) return {
|
|
1996
|
+
valid: false
|
|
1997
|
+
};
|
|
1998
|
+
i[o] = u.data;
|
|
1999
|
+
}
|
|
2000
|
+
return {
|
|
2001
|
+
valid: true,
|
|
2002
|
+
data: i
|
|
2003
|
+
};
|
|
2004
|
+
} else if (t === f.array && r === f.array) {
|
|
2005
|
+
if (s.length !== e.length) return {
|
|
2006
|
+
valid: false
|
|
2007
|
+
};
|
|
2008
|
+
const a = [];
|
|
2009
|
+
for (let n = 0; n < s.length; n++) {
|
|
2010
|
+
const i = s[n], o = e[n], u = Q(i, o);
|
|
2011
|
+
if (!u.valid) return {
|
|
2012
|
+
valid: false
|
|
2013
|
+
};
|
|
2014
|
+
a.push(u.data);
|
|
2015
|
+
}
|
|
2016
|
+
return {
|
|
2017
|
+
valid: true,
|
|
2018
|
+
data: a
|
|
2019
|
+
};
|
|
2020
|
+
} else return t === f.date && r === f.date && +s == +e ? {
|
|
2021
|
+
valid: true,
|
|
2022
|
+
data: s
|
|
2023
|
+
} : {
|
|
2024
|
+
valid: false
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
class W extends y {
|
|
2028
|
+
_parse(e) {
|
|
2029
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = (n, i) => {
|
|
2030
|
+
if (re(n) || re(i)) return m;
|
|
2031
|
+
const o = Q(n.value, i.value);
|
|
2032
|
+
return o.valid ? ((ae(n) || ae(i)) && t.dirty(), {
|
|
2033
|
+
status: t.value,
|
|
2034
|
+
value: o.data
|
|
2035
|
+
}) : (c(r, {
|
|
2036
|
+
code: d.invalid_intersection_types
|
|
2037
|
+
}), m);
|
|
2038
|
+
};
|
|
2039
|
+
return r.common.async ? Promise.all([
|
|
2040
|
+
this._def.left._parseAsync({
|
|
2041
|
+
data: r.data,
|
|
2042
|
+
path: r.path,
|
|
2043
|
+
parent: r
|
|
2044
|
+
}),
|
|
2045
|
+
this._def.right._parseAsync({
|
|
2046
|
+
data: r.data,
|
|
2047
|
+
path: r.path,
|
|
2048
|
+
parent: r
|
|
2049
|
+
})
|
|
2050
|
+
]).then(([n, i]) => a(n, i)) : a(this._def.left._parseSync({
|
|
2051
|
+
data: r.data,
|
|
2052
|
+
path: r.path,
|
|
2053
|
+
parent: r
|
|
2054
|
+
}), this._def.right._parseSync({
|
|
2055
|
+
data: r.data,
|
|
2056
|
+
path: r.path,
|
|
2057
|
+
parent: r
|
|
2058
|
+
}));
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
W.create = (s, e, t) => new W({
|
|
2062
|
+
left: s,
|
|
2063
|
+
right: e,
|
|
2064
|
+
typeName: p.ZodIntersection,
|
|
2065
|
+
..._(t)
|
|
2066
|
+
});
|
|
2067
|
+
class R extends y {
|
|
2068
|
+
_parse(e) {
|
|
2069
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2070
|
+
if (r.parsedType !== f.array) return c(r, {
|
|
2071
|
+
code: d.invalid_type,
|
|
2072
|
+
expected: f.array,
|
|
2073
|
+
received: r.parsedType
|
|
2074
|
+
}), m;
|
|
2075
|
+
if (r.data.length < this._def.items.length) return c(r, {
|
|
2076
|
+
code: d.too_small,
|
|
2077
|
+
minimum: this._def.items.length,
|
|
2078
|
+
inclusive: true,
|
|
2079
|
+
exact: false,
|
|
2080
|
+
type: "array"
|
|
2081
|
+
}), m;
|
|
2082
|
+
!this._def.rest && r.data.length > this._def.items.length && (c(r, {
|
|
2083
|
+
code: d.too_big,
|
|
2084
|
+
maximum: this._def.items.length,
|
|
2085
|
+
inclusive: true,
|
|
2086
|
+
exact: false,
|
|
2087
|
+
type: "array"
|
|
2088
|
+
}), t.dirty());
|
|
2089
|
+
const n = [
|
|
2090
|
+
...r.data
|
|
2091
|
+
].map((i, o) => {
|
|
2092
|
+
const u = this._def.items[o] || this._def.rest;
|
|
2093
|
+
return u ? u._parse(new N(r, i, r.path, o)) : null;
|
|
2094
|
+
}).filter((i) => !!i);
|
|
2095
|
+
return r.common.async ? Promise.all(n).then((i) => k.mergeArray(t, i)) : k.mergeArray(t, n);
|
|
2096
|
+
}
|
|
2097
|
+
get items() {
|
|
2098
|
+
return this._def.items;
|
|
2099
|
+
}
|
|
2100
|
+
rest(e) {
|
|
2101
|
+
return new R({
|
|
2102
|
+
...this._def,
|
|
2103
|
+
rest: e
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
R.create = (s, e) => {
|
|
2108
|
+
if (!Array.isArray(s)) throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2109
|
+
return new R({
|
|
2110
|
+
items: s,
|
|
2111
|
+
typeName: p.ZodTuple,
|
|
2112
|
+
rest: null,
|
|
2113
|
+
..._(e)
|
|
2114
|
+
});
|
|
2115
|
+
};
|
|
2116
|
+
class fe extends y {
|
|
2117
|
+
get keySchema() {
|
|
2118
|
+
return this._def.keyType;
|
|
2119
|
+
}
|
|
2120
|
+
get valueSchema() {
|
|
2121
|
+
return this._def.valueType;
|
|
2122
|
+
}
|
|
2123
|
+
_parse(e) {
|
|
2124
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2125
|
+
if (r.parsedType !== f.map) return c(r, {
|
|
2126
|
+
code: d.invalid_type,
|
|
2127
|
+
expected: f.map,
|
|
2128
|
+
received: r.parsedType
|
|
2129
|
+
}), m;
|
|
2130
|
+
const a = this._def.keyType, n = this._def.valueType, i = [
|
|
2131
|
+
...r.data.entries()
|
|
2132
|
+
].map(([o, u], l) => ({
|
|
2133
|
+
key: a._parse(new N(r, o, r.path, [
|
|
2134
|
+
l,
|
|
2135
|
+
"key"
|
|
2136
|
+
])),
|
|
2137
|
+
value: n._parse(new N(r, u, r.path, [
|
|
2138
|
+
l,
|
|
2139
|
+
"value"
|
|
2140
|
+
]))
|
|
2141
|
+
}));
|
|
2142
|
+
if (r.common.async) {
|
|
2143
|
+
const o = /* @__PURE__ */ new Map();
|
|
2144
|
+
return Promise.resolve().then(async () => {
|
|
2145
|
+
for (const u of i) {
|
|
2146
|
+
const l = await u.key, g = await u.value;
|
|
2147
|
+
if (l.status === "aborted" || g.status === "aborted") return m;
|
|
2148
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2149
|
+
}
|
|
2150
|
+
return {
|
|
2151
|
+
status: t.value,
|
|
2152
|
+
value: o
|
|
2153
|
+
};
|
|
2154
|
+
});
|
|
2155
|
+
} else {
|
|
2156
|
+
const o = /* @__PURE__ */ new Map();
|
|
2157
|
+
for (const u of i) {
|
|
2158
|
+
const l = u.key, g = u.value;
|
|
2159
|
+
if (l.status === "aborted" || g.status === "aborted") return m;
|
|
2160
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2161
|
+
}
|
|
2162
|
+
return {
|
|
2163
|
+
status: t.value,
|
|
2164
|
+
value: o
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
fe.create = (s, e, t) => new fe({
|
|
2170
|
+
valueType: e,
|
|
2171
|
+
keyType: s,
|
|
2172
|
+
typeName: p.ZodMap,
|
|
2173
|
+
..._(t)
|
|
2174
|
+
});
|
|
2175
|
+
class z extends y {
|
|
2176
|
+
_parse(e) {
|
|
2177
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2178
|
+
if (r.parsedType !== f.set) return c(r, {
|
|
2179
|
+
code: d.invalid_type,
|
|
2180
|
+
expected: f.set,
|
|
2181
|
+
received: r.parsedType
|
|
2182
|
+
}), m;
|
|
2183
|
+
const a = this._def;
|
|
2184
|
+
a.minSize !== null && r.data.size < a.minSize.value && (c(r, {
|
|
2185
|
+
code: d.too_small,
|
|
2186
|
+
minimum: a.minSize.value,
|
|
2187
|
+
type: "set",
|
|
2188
|
+
inclusive: true,
|
|
2189
|
+
exact: false,
|
|
2190
|
+
message: a.minSize.message
|
|
2191
|
+
}), t.dirty()), a.maxSize !== null && r.data.size > a.maxSize.value && (c(r, {
|
|
2192
|
+
code: d.too_big,
|
|
2193
|
+
maximum: a.maxSize.value,
|
|
2194
|
+
type: "set",
|
|
2195
|
+
inclusive: true,
|
|
2196
|
+
exact: false,
|
|
2197
|
+
message: a.maxSize.message
|
|
2198
|
+
}), t.dirty());
|
|
2199
|
+
const n = this._def.valueType;
|
|
2200
|
+
function i(u) {
|
|
2201
|
+
const l = /* @__PURE__ */ new Set();
|
|
2202
|
+
for (const g of u) {
|
|
2203
|
+
if (g.status === "aborted") return m;
|
|
2204
|
+
g.status === "dirty" && t.dirty(), l.add(g.value);
|
|
2205
|
+
}
|
|
2206
|
+
return {
|
|
2207
|
+
status: t.value,
|
|
2208
|
+
value: l
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
const o = [
|
|
2212
|
+
...r.data.values()
|
|
2213
|
+
].map((u, l) => n._parse(new N(r, u, r.path, l)));
|
|
2214
|
+
return r.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2215
|
+
}
|
|
2216
|
+
min(e, t) {
|
|
2217
|
+
return new z({
|
|
2218
|
+
...this._def,
|
|
2219
|
+
minSize: {
|
|
2220
|
+
value: e,
|
|
2221
|
+
message: h.toString(t)
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
max(e, t) {
|
|
2226
|
+
return new z({
|
|
2227
|
+
...this._def,
|
|
2228
|
+
maxSize: {
|
|
2229
|
+
value: e,
|
|
2230
|
+
message: h.toString(t)
|
|
2231
|
+
}
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
size(e, t) {
|
|
2235
|
+
return this.min(e, t).max(e, t);
|
|
2236
|
+
}
|
|
2237
|
+
nonempty(e) {
|
|
2238
|
+
return this.min(1, e);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
z.create = (s, e) => new z({
|
|
2242
|
+
valueType: s,
|
|
2243
|
+
minSize: null,
|
|
2244
|
+
maxSize: null,
|
|
2245
|
+
typeName: p.ZodSet,
|
|
2246
|
+
..._(e)
|
|
2247
|
+
});
|
|
2248
|
+
class he extends y {
|
|
2249
|
+
get schema() {
|
|
2250
|
+
return this._def.getter();
|
|
2251
|
+
}
|
|
2252
|
+
_parse(e) {
|
|
2253
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2254
|
+
return this._def.getter()._parse({
|
|
2255
|
+
data: t.data,
|
|
2256
|
+
path: t.path,
|
|
2257
|
+
parent: t
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
he.create = (s, e) => new he({
|
|
2262
|
+
getter: s,
|
|
2263
|
+
typeName: p.ZodLazy,
|
|
2264
|
+
..._(e)
|
|
2265
|
+
});
|
|
2266
|
+
class me extends y {
|
|
2267
|
+
_parse(e) {
|
|
2268
|
+
if (e.data !== this._def.value) {
|
|
2269
|
+
const t = this._getOrReturnCtx(e);
|
|
2270
|
+
return c(t, {
|
|
2271
|
+
received: t.data,
|
|
2272
|
+
code: d.invalid_literal,
|
|
2273
|
+
expected: this._def.value
|
|
2274
|
+
}), m;
|
|
2275
|
+
}
|
|
2276
|
+
return {
|
|
2277
|
+
status: "valid",
|
|
2278
|
+
value: e.data
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
get value() {
|
|
2282
|
+
return this._def.value;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
me.create = (s, e) => new me({
|
|
2286
|
+
value: s,
|
|
2287
|
+
typeName: p.ZodLiteral,
|
|
2288
|
+
..._(e)
|
|
2289
|
+
});
|
|
2290
|
+
function ke(s, e) {
|
|
2291
|
+
return new E({
|
|
2292
|
+
values: s,
|
|
2293
|
+
typeName: p.ZodEnum,
|
|
2294
|
+
..._(e)
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
class E extends y {
|
|
2298
|
+
_parse(e) {
|
|
2299
|
+
if (typeof e.data != "string") {
|
|
2300
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2301
|
+
return c(t, {
|
|
2302
|
+
expected: v.joinValues(r),
|
|
2303
|
+
received: t.parsedType,
|
|
2304
|
+
code: d.invalid_type
|
|
2305
|
+
}), m;
|
|
2306
|
+
}
|
|
2307
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2308
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2309
|
+
return c(t, {
|
|
2310
|
+
received: t.data,
|
|
2311
|
+
code: d.invalid_enum_value,
|
|
2312
|
+
options: r
|
|
2313
|
+
}), m;
|
|
2314
|
+
}
|
|
2315
|
+
return b(e.data);
|
|
2316
|
+
}
|
|
2317
|
+
get options() {
|
|
2318
|
+
return this._def.values;
|
|
2319
|
+
}
|
|
2320
|
+
get enum() {
|
|
2321
|
+
const e = {};
|
|
2322
|
+
for (const t of this._def.values) e[t] = t;
|
|
2323
|
+
return e;
|
|
2324
|
+
}
|
|
2325
|
+
get Values() {
|
|
2326
|
+
const e = {};
|
|
2327
|
+
for (const t of this._def.values) e[t] = t;
|
|
2328
|
+
return e;
|
|
2329
|
+
}
|
|
2330
|
+
get Enum() {
|
|
2331
|
+
const e = {};
|
|
2332
|
+
for (const t of this._def.values) e[t] = t;
|
|
2333
|
+
return e;
|
|
2334
|
+
}
|
|
2335
|
+
extract(e, t = this._def) {
|
|
2336
|
+
return E.create(e, {
|
|
2337
|
+
...this._def,
|
|
2338
|
+
...t
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
exclude(e, t = this._def) {
|
|
2342
|
+
return E.create(this.options.filter((r) => !e.includes(r)), {
|
|
2343
|
+
...this._def,
|
|
2344
|
+
...t
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
E.create = ke;
|
|
2349
|
+
class pe extends y {
|
|
2350
|
+
_parse(e) {
|
|
2351
|
+
const t = v.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2352
|
+
if (r.parsedType !== f.string && r.parsedType !== f.number) {
|
|
2353
|
+
const a = v.objectValues(t);
|
|
2354
|
+
return c(r, {
|
|
2355
|
+
expected: v.joinValues(a),
|
|
2356
|
+
received: r.parsedType,
|
|
2357
|
+
code: d.invalid_type
|
|
2358
|
+
}), m;
|
|
2359
|
+
}
|
|
2360
|
+
if (this._cache || (this._cache = new Set(v.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2361
|
+
const a = v.objectValues(t);
|
|
2362
|
+
return c(r, {
|
|
2363
|
+
received: r.data,
|
|
2364
|
+
code: d.invalid_enum_value,
|
|
2365
|
+
options: a
|
|
2366
|
+
}), m;
|
|
2367
|
+
}
|
|
2368
|
+
return b(e.data);
|
|
2369
|
+
}
|
|
2370
|
+
get enum() {
|
|
2371
|
+
return this._def.values;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
pe.create = (s, e) => new pe({
|
|
2375
|
+
values: s,
|
|
2376
|
+
typeName: p.ZodNativeEnum,
|
|
2377
|
+
..._(e)
|
|
2378
|
+
});
|
|
2379
|
+
class J extends y {
|
|
2380
|
+
unwrap() {
|
|
2381
|
+
return this._def.type;
|
|
2382
|
+
}
|
|
2383
|
+
_parse(e) {
|
|
2384
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2385
|
+
if (t.parsedType !== f.promise && t.common.async === false) return c(t, {
|
|
2386
|
+
code: d.invalid_type,
|
|
2387
|
+
expected: f.promise,
|
|
2388
|
+
received: t.parsedType
|
|
2389
|
+
}), m;
|
|
2390
|
+
const r = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2391
|
+
return b(r.then((a) => this._def.type.parseAsync(a, {
|
|
2392
|
+
path: t.path,
|
|
2393
|
+
errorMap: t.common.contextualErrorMap
|
|
2394
|
+
})));
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
J.create = (s, e) => new J({
|
|
2398
|
+
type: s,
|
|
2399
|
+
typeName: p.ZodPromise,
|
|
2400
|
+
..._(e)
|
|
2401
|
+
});
|
|
2402
|
+
class $ extends y {
|
|
2403
|
+
innerType() {
|
|
2404
|
+
return this._def.schema;
|
|
2405
|
+
}
|
|
2406
|
+
sourceType() {
|
|
2407
|
+
return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2408
|
+
}
|
|
2409
|
+
_parse(e) {
|
|
2410
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = this._def.effect || null, n = {
|
|
2411
|
+
addIssue: (i) => {
|
|
2412
|
+
c(r, i), i.fatal ? t.abort() : t.dirty();
|
|
2413
|
+
},
|
|
2414
|
+
get path() {
|
|
2415
|
+
return r.path;
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
if (n.addIssue = n.addIssue.bind(n), a.type === "preprocess") {
|
|
2419
|
+
const i = a.transform(r.data, n);
|
|
2420
|
+
if (r.common.async) return Promise.resolve(i).then(async (o) => {
|
|
2421
|
+
if (t.value === "aborted") return m;
|
|
2422
|
+
const u = await this._def.schema._parseAsync({
|
|
2423
|
+
data: o,
|
|
2424
|
+
path: r.path,
|
|
2425
|
+
parent: r
|
|
2426
|
+
});
|
|
2427
|
+
return u.status === "aborted" ? m : u.status === "dirty" || t.value === "dirty" ? M(u.value) : u;
|
|
2428
|
+
});
|
|
2429
|
+
{
|
|
2430
|
+
if (t.value === "aborted") return m;
|
|
2431
|
+
const o = this._def.schema._parseSync({
|
|
2432
|
+
data: i,
|
|
2433
|
+
path: r.path,
|
|
2434
|
+
parent: r
|
|
2435
|
+
});
|
|
2436
|
+
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ? M(o.value) : o;
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (a.type === "refinement") {
|
|
2440
|
+
const i = (o) => {
|
|
2441
|
+
const u = a.refinement(o, n);
|
|
2442
|
+
if (r.common.async) return Promise.resolve(u);
|
|
2443
|
+
if (u instanceof Promise) throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2444
|
+
return o;
|
|
2445
|
+
};
|
|
2446
|
+
if (r.common.async === false) {
|
|
2447
|
+
const o = this._def.schema._parseSync({
|
|
2448
|
+
data: r.data,
|
|
2449
|
+
path: r.path,
|
|
2450
|
+
parent: r
|
|
2451
|
+
});
|
|
2452
|
+
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), {
|
|
2453
|
+
status: t.value,
|
|
2454
|
+
value: o.value
|
|
2455
|
+
});
|
|
2456
|
+
} else return this._def.schema._parseAsync({
|
|
2457
|
+
data: r.data,
|
|
2458
|
+
path: r.path,
|
|
2459
|
+
parent: r
|
|
2460
|
+
}).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({
|
|
2461
|
+
status: t.value,
|
|
2462
|
+
value: o.value
|
|
2463
|
+
}))));
|
|
2464
|
+
}
|
|
2465
|
+
if (a.type === "transform") if (r.common.async === false) {
|
|
2466
|
+
const i = this._def.schema._parseSync({
|
|
2467
|
+
data: r.data,
|
|
2468
|
+
path: r.path,
|
|
2469
|
+
parent: r
|
|
2470
|
+
});
|
|
2471
|
+
if (!I(i)) return m;
|
|
2472
|
+
const o = a.transform(i.value, n);
|
|
2473
|
+
if (o instanceof Promise) throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2474
|
+
return {
|
|
2475
|
+
status: t.value,
|
|
2476
|
+
value: o
|
|
2477
|
+
};
|
|
2478
|
+
} else return this._def.schema._parseAsync({
|
|
2479
|
+
data: r.data,
|
|
2480
|
+
path: r.path,
|
|
2481
|
+
parent: r
|
|
2482
|
+
}).then((i) => I(i) ? Promise.resolve(a.transform(i.value, n)).then((o) => ({
|
|
2483
|
+
status: t.value,
|
|
2484
|
+
value: o
|
|
2485
|
+
})) : m);
|
|
2486
|
+
v.assertNever(a);
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
$.create = (s, e, t) => new $({
|
|
2490
|
+
schema: s,
|
|
2491
|
+
typeName: p.ZodEffects,
|
|
2492
|
+
effect: e,
|
|
2493
|
+
..._(t)
|
|
2494
|
+
});
|
|
2495
|
+
$.createWithPreprocess = (s, e, t) => new $({
|
|
2496
|
+
schema: e,
|
|
2497
|
+
effect: {
|
|
2498
|
+
type: "preprocess",
|
|
2499
|
+
transform: s
|
|
2500
|
+
},
|
|
2501
|
+
typeName: p.ZodEffects,
|
|
2502
|
+
..._(t)
|
|
2503
|
+
});
|
|
2504
|
+
class S extends y {
|
|
2505
|
+
_parse(e) {
|
|
2506
|
+
return this._getType(e) === f.undefined ? b(void 0) : this._def.innerType._parse(e);
|
|
2507
|
+
}
|
|
2508
|
+
unwrap() {
|
|
2509
|
+
return this._def.innerType;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
S.create = (s, e) => new S({
|
|
2513
|
+
innerType: s,
|
|
2514
|
+
typeName: p.ZodOptional,
|
|
2515
|
+
..._(e)
|
|
2516
|
+
});
|
|
2517
|
+
class V extends y {
|
|
2518
|
+
_parse(e) {
|
|
2519
|
+
return this._getType(e) === f.null ? b(null) : this._def.innerType._parse(e);
|
|
2520
|
+
}
|
|
2521
|
+
unwrap() {
|
|
2522
|
+
return this._def.innerType;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
V.create = (s, e) => new V({
|
|
2526
|
+
innerType: s,
|
|
2527
|
+
typeName: p.ZodNullable,
|
|
2528
|
+
..._(e)
|
|
2529
|
+
});
|
|
2530
|
+
class X extends y {
|
|
2531
|
+
_parse(e) {
|
|
2532
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2533
|
+
let r = t.data;
|
|
2534
|
+
return t.parsedType === f.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2535
|
+
data: r,
|
|
2536
|
+
path: t.path,
|
|
2537
|
+
parent: t
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
removeDefault() {
|
|
2541
|
+
return this._def.innerType;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
X.create = (s, e) => new X({
|
|
2545
|
+
innerType: s,
|
|
2546
|
+
typeName: p.ZodDefault,
|
|
2547
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2548
|
+
..._(e)
|
|
2549
|
+
});
|
|
2550
|
+
class K extends y {
|
|
2551
|
+
_parse(e) {
|
|
2552
|
+
const { ctx: t } = this._processInputParams(e), r = {
|
|
2553
|
+
...t,
|
|
2554
|
+
common: {
|
|
2555
|
+
...t.common,
|
|
2556
|
+
issues: []
|
|
2557
|
+
}
|
|
2558
|
+
}, a = this._def.innerType._parse({
|
|
2559
|
+
data: r.data,
|
|
2560
|
+
path: r.path,
|
|
2561
|
+
parent: {
|
|
2562
|
+
...r
|
|
2563
|
+
}
|
|
2564
|
+
});
|
|
2565
|
+
return U(a) ? a.then((n) => ({
|
|
2566
|
+
status: "valid",
|
|
2567
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2568
|
+
get error() {
|
|
2569
|
+
return new O(r.common.issues);
|
|
2570
|
+
},
|
|
2571
|
+
input: r.data
|
|
2572
|
+
})
|
|
2573
|
+
})) : {
|
|
2574
|
+
status: "valid",
|
|
2575
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2576
|
+
get error() {
|
|
2577
|
+
return new O(r.common.issues);
|
|
2578
|
+
},
|
|
2579
|
+
input: r.data
|
|
2580
|
+
})
|
|
2581
|
+
};
|
|
2582
|
+
}
|
|
2583
|
+
removeCatch() {
|
|
2584
|
+
return this._def.innerType;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
K.create = (s, e) => new K({
|
|
2588
|
+
innerType: s,
|
|
2589
|
+
typeName: p.ZodCatch,
|
|
2590
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2591
|
+
..._(e)
|
|
2592
|
+
});
|
|
2593
|
+
class ge extends y {
|
|
2594
|
+
_parse(e) {
|
|
2595
|
+
if (this._getType(e) !== f.nan) {
|
|
2596
|
+
const r = this._getOrReturnCtx(e);
|
|
2597
|
+
return c(r, {
|
|
2598
|
+
code: d.invalid_type,
|
|
2599
|
+
expected: f.nan,
|
|
2600
|
+
received: r.parsedType
|
|
2601
|
+
}), m;
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
status: "valid",
|
|
2605
|
+
value: e.data
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
ge.create = (s) => new ge({
|
|
2610
|
+
typeName: p.ZodNaN,
|
|
2611
|
+
..._(s)
|
|
2612
|
+
});
|
|
2613
|
+
class He extends y {
|
|
2614
|
+
_parse(e) {
|
|
2615
|
+
const { ctx: t } = this._processInputParams(e), r = t.data;
|
|
2616
|
+
return this._def.type._parse({
|
|
2617
|
+
data: r,
|
|
2618
|
+
path: t.path,
|
|
2619
|
+
parent: t
|
|
2620
|
+
});
|
|
2621
|
+
}
|
|
2622
|
+
unwrap() {
|
|
2623
|
+
return this._def.type;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
class te extends y {
|
|
2627
|
+
_parse(e) {
|
|
2628
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2629
|
+
if (r.common.async) return (async () => {
|
|
2630
|
+
const n = await this._def.in._parseAsync({
|
|
2631
|
+
data: r.data,
|
|
2632
|
+
path: r.path,
|
|
2633
|
+
parent: r
|
|
2634
|
+
});
|
|
2635
|
+
return n.status === "aborted" ? m : n.status === "dirty" ? (t.dirty(), M(n.value)) : this._def.out._parseAsync({
|
|
2636
|
+
data: n.value,
|
|
2637
|
+
path: r.path,
|
|
2638
|
+
parent: r
|
|
2639
|
+
});
|
|
2640
|
+
})();
|
|
2641
|
+
{
|
|
2642
|
+
const a = this._def.in._parseSync({
|
|
2643
|
+
data: r.data,
|
|
2644
|
+
path: r.path,
|
|
2645
|
+
parent: r
|
|
2646
|
+
});
|
|
2647
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), {
|
|
2648
|
+
status: "dirty",
|
|
2649
|
+
value: a.value
|
|
2650
|
+
}) : this._def.out._parseSync({
|
|
2651
|
+
data: a.value,
|
|
2652
|
+
path: r.path,
|
|
2653
|
+
parent: r
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
static create(e, t) {
|
|
2658
|
+
return new te({
|
|
2659
|
+
in: e,
|
|
2660
|
+
out: t,
|
|
2661
|
+
typeName: p.ZodPipeline
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
class ee extends y {
|
|
2666
|
+
_parse(e) {
|
|
2667
|
+
const t = this._def.innerType._parse(e), r = (a) => (I(a) && (a.value = Object.freeze(a.value)), a);
|
|
2668
|
+
return U(t) ? t.then((a) => r(a)) : r(t);
|
|
2669
|
+
}
|
|
2670
|
+
unwrap() {
|
|
2671
|
+
return this._def.innerType;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
ee.create = (s, e) => new ee({
|
|
2675
|
+
innerType: s,
|
|
2676
|
+
typeName: p.ZodReadonly,
|
|
2677
|
+
..._(e)
|
|
2678
|
+
});
|
|
2679
|
+
var p;
|
|
2680
|
+
(function(s) {
|
|
2681
|
+
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
|
|
2682
|
+
})(p || (p = {}));
|
|
2683
|
+
const _e = G.create;
|
|
2684
|
+
A.create;
|
|
2685
|
+
w.create;
|
|
2686
|
+
const Ye = x.create;
|
|
2687
|
+
F.create;
|
|
2688
|
+
W.create;
|
|
2689
|
+
R.create;
|
|
2690
|
+
const Ge = E.create;
|
|
2691
|
+
J.create;
|
|
2692
|
+
S.create;
|
|
2693
|
+
V.create;
|
|
2694
|
+
let D = null;
|
|
2695
|
+
async function Qe() {
|
|
2696
|
+
if (D) return D;
|
|
2697
|
+
try {
|
|
2698
|
+
const s = await import("../vite_plugin_norg_parser-CNE0aFue.js");
|
|
2699
|
+
return await s.default(), D = s.parse_norg, D;
|
|
2700
|
+
} catch (s) {
|
|
2701
|
+
throw new Error(`Failed to load norg parser: ${s}`);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
const Xe = ({ html: s, metadata: e }) => {
|
|
2705
|
+
const t = JSON.stringify(e ?? {}), r = JSON.stringify(s);
|
|
2706
|
+
return [
|
|
2707
|
+
`export const metadata = ${t};`,
|
|
2708
|
+
`export const html = ${r};`,
|
|
2709
|
+
"export default { metadata, html };"
|
|
2710
|
+
].join(`
|
|
2711
|
+
`);
|
|
2712
|
+
};
|
|
2713
|
+
function Ke({ html: s, metadata: e }) {
|
|
2714
|
+
const t = JSON.stringify(e ?? {});
|
|
2715
|
+
return [
|
|
2716
|
+
"<script>",
|
|
2717
|
+
` const htmlContent = ${JSON.stringify(s)};`,
|
|
2718
|
+
"<\/script>",
|
|
2719
|
+
'<script context="module">',
|
|
2720
|
+
` export const metadata = ${t};`,
|
|
2721
|
+
"<\/script>",
|
|
2722
|
+
"{@html htmlContent}"
|
|
2723
|
+
].join(`
|
|
2724
|
+
`);
|
|
2725
|
+
}
|
|
2726
|
+
function et({ html: s, metadata: e }) {
|
|
2727
|
+
const t = JSON.stringify(e ?? {}), r = JSON.stringify(s);
|
|
2728
|
+
return [
|
|
2729
|
+
'import React from "react";',
|
|
2730
|
+
`export const metadata = ${t};`,
|
|
2731
|
+
`const htmlContent = ${r};`,
|
|
2732
|
+
'export const Component = () => React.createElement("div", { dangerouslySetInnerHTML: { __html: htmlContent } });',
|
|
2733
|
+
"export default Component;"
|
|
2734
|
+
].join(`
|
|
2735
|
+
`);
|
|
2736
|
+
}
|
|
2737
|
+
const tt = Ye({
|
|
2738
|
+
mode: Ge([
|
|
2739
|
+
"html",
|
|
2740
|
+
"svelte",
|
|
2741
|
+
"react"
|
|
2742
|
+
]),
|
|
2743
|
+
include: _e().optional(),
|
|
2744
|
+
exclude: _e().optional()
|
|
2745
|
+
}), ye = {
|
|
2746
|
+
html: Xe,
|
|
2747
|
+
svelte: Ke,
|
|
2748
|
+
react: et
|
|
2749
|
+
};
|
|
2750
|
+
rt = function(s) {
|
|
2751
|
+
const e = tt.parse(s), { include: t, exclude: r, mode: a } = e, n = be(t, r);
|
|
2752
|
+
let i = null;
|
|
2753
|
+
const o = async () => {
|
|
2754
|
+
if (!i) try {
|
|
2755
|
+
i = await Qe();
|
|
2756
|
+
} catch (u) {
|
|
2757
|
+
throw new Error(`Failed to load norg parser: ${u}`);
|
|
2758
|
+
}
|
|
2759
|
+
return i;
|
|
2760
|
+
};
|
|
2761
|
+
return {
|
|
2762
|
+
name: "vite-plugin-norg",
|
|
2763
|
+
enforce: "pre",
|
|
2764
|
+
async resolveId(u, l) {
|
|
2765
|
+
if (!u.endsWith(".norg")) return null;
|
|
2766
|
+
const g = await this.resolve(u, l, {
|
|
2767
|
+
skipSelf: true
|
|
2768
|
+
});
|
|
2769
|
+
return g ? g.id : null;
|
|
2770
|
+
},
|
|
2771
|
+
async load(u) {
|
|
2772
|
+
if (n(u)) try {
|
|
2773
|
+
const { readFile: l } = await import("node:fs/promises").then(async (m2) => {
|
|
2774
|
+
await m2.__tla;
|
|
2775
|
+
return m2;
|
|
2776
|
+
}), g = await o(), C = await l(u, "utf-8"), q = g(C);
|
|
2777
|
+
return ye[a](q);
|
|
2778
|
+
} catch (l) {
|
|
2779
|
+
this.error(new Error(`Failed to parse norg file ${u}: ${l}`));
|
|
2780
|
+
}
|
|
2781
|
+
},
|
|
2782
|
+
async handleHotUpdate(u) {
|
|
2783
|
+
if (!n(u.file) || !u.file.endsWith(".norg")) return;
|
|
2784
|
+
const l = u.read;
|
|
2785
|
+
u.read = async function() {
|
|
2786
|
+
try {
|
|
2787
|
+
const g = await l(), C = await o();
|
|
2788
|
+
return ye[a](C(g));
|
|
2789
|
+
} catch (g) {
|
|
2790
|
+
throw new Error(`Failed to parse norg file ${u.file}: ${g}`);
|
|
2791
|
+
}
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
};
|
|
2796
|
+
})();
|
|
2797
|
+
export {
|
|
2798
|
+
__tla,
|
|
2799
|
+
rt as default,
|
|
2800
|
+
rt as norgPlugin
|
|
2801
|
+
};
|