@rpcbase/server 0.639.0 → 0.640.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/dist/accountDeletion.d.ts.map +1 -1
- package/dist/applyRouteLoaders.d.ts.map +1 -1
- package/dist/{email-6gJ8ibKp.js → email-CXD08Xm7.js} +368 -281
- package/dist/email-CXD08Xm7.js.map +1 -0
- package/dist/fileReferences-Dcv9PTqD.js.map +1 -1
- package/dist/{handler-Dy_L6_-U.js → handler-Bwmvm0pQ.js} +5 -4
- package/dist/handler-Bwmvm0pQ.js.map +1 -0
- package/dist/{handler-DOLNpMkW.js → handler-CMEIng_C.js} +2 -2
- package/dist/handler-CMEIng_C.js.map +1 -0
- package/dist/{handler-DlRmqucR.js → handler-Cb8opBxn.js} +2 -2
- package/dist/handler-Cb8opBxn.js.map +1 -0
- package/dist/{handler-BkGfOJ1l.js → handler-F-JQoj8x.js} +5 -4
- package/dist/handler-F-JQoj8x.js.map +1 -0
- package/dist/index.js +4341 -2307
- package/dist/index.js.map +1 -1
- package/dist/initServer.d.ts.map +1 -1
- package/dist/node-C1tH2rT4.js.map +1 -1
- package/dist/notifications.js +2 -2
- package/dist/queryWindow-RHVy3D0L.js.map +1 -1
- package/dist/rts/index.js +1 -1
- package/dist/rts/index.js.map +1 -1
- package/dist/{schemas-LLeSMkcz.js → schemas-BzNluG2q.js} +2393 -1137
- package/dist/schemas-BzNluG2q.js.map +1 -0
- package/dist/shared-B1VLaHsk.js.map +1 -1
- package/dist/uploads/api/file-uploads/fileReferences.d.ts +3 -2
- package/dist/uploads/api/file-uploads/fileReferences.d.ts.map +1 -1
- package/dist/uploads/api/file-uploads/imageVariantsPostProcessor.d.ts.map +1 -1
- package/dist/uploads/api/file-uploads/shared.d.ts +2 -2
- package/dist/uploads/api/file-uploads/shared.d.ts.map +1 -1
- package/dist/uploads/api/files/handlers/deleteFile.d.ts.map +1 -1
- package/dist/uploads/api/files/handlers/getFile.d.ts.map +1 -1
- package/dist/uploads/worker.js +3 -2
- package/dist/uploads/worker.js.map +1 -1
- package/dist/uploads.js +2 -2
- package/package.json +24 -14
- package/dist/email-6gJ8ibKp.js.map +0 -1
- package/dist/handler-BkGfOJ1l.js.map +0 -1
- package/dist/handler-DOLNpMkW.js.map +0 -1
- package/dist/handler-DlRmqucR.js.map +0 -1
- package/dist/handler-Dy_L6_-U.js.map +0 -1
- package/dist/schemas-LLeSMkcz.js.map +0 -1
|
@@ -1,79 +1,31 @@
|
|
|
1
|
-
//#region ../../node_modules/zod/v4/core/core.js
|
|
2
|
-
var _a$1;
|
|
3
|
-
function $constructor(name, initializer, params) {
|
|
4
|
-
function init(inst, def) {
|
|
5
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
6
|
-
value: {
|
|
7
|
-
def,
|
|
8
|
-
constr: _,
|
|
9
|
-
traits: /* @__PURE__ */ new Set()
|
|
10
|
-
},
|
|
11
|
-
enumerable: false
|
|
12
|
-
});
|
|
13
|
-
if (inst._zod.traits.has(name)) return;
|
|
14
|
-
inst._zod.traits.add(name);
|
|
15
|
-
initializer(inst, def);
|
|
16
|
-
const proto = _.prototype;
|
|
17
|
-
const keys = Object.keys(proto);
|
|
18
|
-
for (let i = 0; i < keys.length; i++) {
|
|
19
|
-
const k = keys[i];
|
|
20
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const Parent = params?.Parent ?? Object;
|
|
24
|
-
class Definition extends Parent {}
|
|
25
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
26
|
-
function _(def) {
|
|
27
|
-
var _a;
|
|
28
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
29
|
-
init(inst, def);
|
|
30
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
31
|
-
for (const fn of inst._zod.deferred) fn();
|
|
32
|
-
return inst;
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(_, "init", { value: init });
|
|
35
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
36
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
37
|
-
return inst?._zod?.traits?.has(name);
|
|
38
|
-
} });
|
|
39
|
-
Object.defineProperty(_, "name", { value: name });
|
|
40
|
-
return _;
|
|
41
|
-
}
|
|
42
|
-
var $ZodAsyncError = class extends Error {
|
|
43
|
-
constructor() {
|
|
44
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var $ZodEncodeError = class extends Error {
|
|
48
|
-
constructor(name) {
|
|
49
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
50
|
-
this.name = "ZodEncodeError";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
54
|
-
var globalConfig = globalThis.__zod_globalConfig;
|
|
55
|
-
function config(newConfig) {
|
|
56
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
57
|
-
return globalConfig;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
1
|
//#region ../../node_modules/zod/v4/core/util.js
|
|
61
2
|
function getEnumValues(entries) {
|
|
62
3
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
63
4
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
64
5
|
}
|
|
6
|
+
function joinValues(array, separator = "|") {
|
|
7
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
8
|
+
}
|
|
65
9
|
function jsonStringifyReplacer(_, value) {
|
|
66
10
|
if (typeof value === "bigint") return value.toString();
|
|
67
11
|
return value;
|
|
68
12
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
13
|
+
var Cached = class {
|
|
14
|
+
constructor(getter) {
|
|
15
|
+
this._getter = getter;
|
|
16
|
+
this._value = void 0;
|
|
17
|
+
}
|
|
18
|
+
get value() {
|
|
19
|
+
const getter = this._getter;
|
|
20
|
+
if (getter !== void 0) {
|
|
21
|
+
this._value = getter();
|
|
22
|
+
this._getter = void 0;
|
|
75
23
|
}
|
|
76
|
-
|
|
24
|
+
return this._value;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function cached(getter) {
|
|
28
|
+
return new Cached(getter);
|
|
77
29
|
}
|
|
78
30
|
function nullish(input) {
|
|
79
31
|
return input === null || input === void 0;
|
|
@@ -86,28 +38,10 @@ function cleanRegex(source) {
|
|
|
86
38
|
function floatSafeRemainder(val, step) {
|
|
87
39
|
const ratio = val / step;
|
|
88
40
|
const roundedRatio = Math.round(ratio);
|
|
89
|
-
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
41
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
90
42
|
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
91
43
|
return ratio - roundedRatio;
|
|
92
44
|
}
|
|
93
|
-
var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
94
|
-
function defineLazy(object, key, getter) {
|
|
95
|
-
let value = void 0;
|
|
96
|
-
Object.defineProperty(object, key, {
|
|
97
|
-
get() {
|
|
98
|
-
if (value === EVALUATING) return;
|
|
99
|
-
if (value === void 0) {
|
|
100
|
-
value = EVALUATING;
|
|
101
|
-
value = getter();
|
|
102
|
-
}
|
|
103
|
-
return value;
|
|
104
|
-
},
|
|
105
|
-
set(v) {
|
|
106
|
-
Object.defineProperty(object, key, { value: v });
|
|
107
|
-
},
|
|
108
|
-
configurable: true
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
45
|
function assignProp(target, prop, value) {
|
|
112
46
|
Object.defineProperty(target, prop, {
|
|
113
47
|
value,
|
|
@@ -116,6 +50,58 @@ function assignProp(target, prop, value) {
|
|
|
116
50
|
configurable: true
|
|
117
51
|
});
|
|
118
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
55
|
+
*
|
|
56
|
+
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
|
|
57
|
+
*/
|
|
58
|
+
function rawShape(def) {
|
|
59
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
60
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
61
|
+
}
|
|
62
|
+
function sourceShape(schema) {
|
|
63
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
64
|
+
}
|
|
65
|
+
function deferProp(target, key, getter) {
|
|
66
|
+
Object.defineProperty(target, key, {
|
|
67
|
+
get() {
|
|
68
|
+
const value = getter();
|
|
69
|
+
assignProp(this, key, value);
|
|
70
|
+
return value;
|
|
71
|
+
},
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function putProp(target, key, value) {
|
|
77
|
+
if (key in target) assignProp(target, key, value);
|
|
78
|
+
else target[key] = value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
82
|
+
*
|
|
83
|
+
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
|
|
84
|
+
*/
|
|
85
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
86
|
+
const raw = sourceShape(source);
|
|
87
|
+
for (const key of keys) {
|
|
88
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
89
|
+
if (!desc.enumerable) continue;
|
|
90
|
+
if (desc.get) deferProp(target, key, () => {
|
|
91
|
+
const value = source._zod.def.shape[key];
|
|
92
|
+
return wrap ? wrap(value, key) : value;
|
|
93
|
+
});
|
|
94
|
+
else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function mirrorProps(target, source) {
|
|
98
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
99
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
100
|
+
if (!desc.enumerable) continue;
|
|
101
|
+
if (desc.get) deferProp(target, key, () => source[key]);
|
|
102
|
+
else putProp(target, key, desc.value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
119
105
|
function mergeDefs(...defs) {
|
|
120
106
|
const mergedDescriptors = {};
|
|
121
107
|
for (const def of defs) {
|
|
@@ -189,51 +175,56 @@ function normalizeParams(_params) {
|
|
|
189
175
|
};
|
|
190
176
|
return params;
|
|
191
177
|
}
|
|
178
|
+
function stringifyPrimitive(value) {
|
|
179
|
+
if (typeof value === "bigint") return value.toString() + "n";
|
|
180
|
+
if (typeof value === "string") return `"${value}"`;
|
|
181
|
+
return `${value}`;
|
|
182
|
+
}
|
|
192
183
|
function optionalKeys(shape) {
|
|
193
184
|
return Object.keys(shape).filter((k) => {
|
|
194
|
-
return shape[k]._zod.optin
|
|
185
|
+
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
|
|
195
186
|
});
|
|
196
187
|
}
|
|
197
|
-
var NUMBER_FORMAT_RANGES = {
|
|
188
|
+
var NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
|
|
198
189
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
199
190
|
int32: [-2147483648, 2147483647],
|
|
200
191
|
uint32: [0, 4294967295],
|
|
201
192
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
202
193
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
194
|
+
}))();
|
|
195
|
+
var BIGINT_FORMAT_RANGES = {
|
|
196
|
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
197
|
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
|
|
203
198
|
};
|
|
204
199
|
function pick(schema, mask) {
|
|
205
200
|
const currDef = schema._zod.def;
|
|
206
201
|
const checks = currDef.checks;
|
|
207
202
|
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
213
|
-
if (!mask[key]) continue;
|
|
214
|
-
newShape[key] = currDef.shape[key];
|
|
215
|
-
}
|
|
216
|
-
assignProp(this, "shape", newShape);
|
|
217
|
-
return newShape;
|
|
218
|
-
},
|
|
203
|
+
const newShape = {};
|
|
204
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
205
|
+
return clone(schema, mergeDefs(currDef, {
|
|
206
|
+
shape: newShape,
|
|
219
207
|
checks: []
|
|
220
208
|
}));
|
|
221
209
|
}
|
|
210
|
+
function maskedKeys(schema, mask) {
|
|
211
|
+
const raw = sourceShape(schema);
|
|
212
|
+
const keys = [];
|
|
213
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
214
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
215
|
+
if (mask[key]) keys.push(key);
|
|
216
|
+
}
|
|
217
|
+
return keys;
|
|
218
|
+
}
|
|
222
219
|
function omit(schema, mask) {
|
|
223
220
|
const currDef = schema._zod.def;
|
|
224
221
|
const checks = currDef.checks;
|
|
225
222
|
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (!mask[key]) continue;
|
|
232
|
-
delete newShape[key];
|
|
233
|
-
}
|
|
234
|
-
assignProp(this, "shape", newShape);
|
|
235
|
-
return newShape;
|
|
236
|
-
},
|
|
223
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
224
|
+
const newShape = {};
|
|
225
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
226
|
+
return clone(schema, mergeDefs(currDef, {
|
|
227
|
+
shape: newShape,
|
|
237
228
|
checks: []
|
|
238
229
|
}));
|
|
239
230
|
}
|
|
@@ -241,90 +232,57 @@ function extend(schema, shape) {
|
|
|
241
232
|
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
242
233
|
const checks = schema._zod.def.checks;
|
|
243
234
|
if (checks && checks.length > 0) {
|
|
244
|
-
const existingShape = schema
|
|
245
|
-
for (const key
|
|
235
|
+
const existingShape = sourceShape(schema);
|
|
236
|
+
for (const key of Reflect.ownKeys(shape)) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
246
237
|
}
|
|
247
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
} }));
|
|
238
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
239
|
+
}
|
|
240
|
+
function extended(schema, shape) {
|
|
241
|
+
const newShape = {};
|
|
242
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
243
|
+
mirrorProps(newShape, shape);
|
|
244
|
+
return newShape;
|
|
255
245
|
}
|
|
256
246
|
function safeExtend(schema, shape) {
|
|
257
247
|
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
258
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
259
|
-
const _shape = {
|
|
260
|
-
...schema._zod.def.shape,
|
|
261
|
-
...shape
|
|
262
|
-
};
|
|
263
|
-
assignProp(this, "shape", _shape);
|
|
264
|
-
return _shape;
|
|
265
|
-
} }));
|
|
248
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
266
249
|
}
|
|
267
250
|
function merge(a, b) {
|
|
251
|
+
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
268
252
|
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
253
|
+
const newShape = {};
|
|
254
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
255
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
269
256
|
return clone(a, mergeDefs(a._zod.def, {
|
|
270
|
-
|
|
271
|
-
const _shape = {
|
|
272
|
-
...a._zod.def.shape,
|
|
273
|
-
...b._zod.def.shape
|
|
274
|
-
};
|
|
275
|
-
assignProp(this, "shape", _shape);
|
|
276
|
-
return _shape;
|
|
277
|
-
},
|
|
257
|
+
shape: newShape,
|
|
278
258
|
get catchall() {
|
|
279
259
|
return b._zod.def.catchall;
|
|
280
260
|
},
|
|
281
261
|
checks: b._zod.def.checks ?? []
|
|
282
262
|
}));
|
|
283
263
|
}
|
|
284
|
-
function partial(Class, schema, mask) {
|
|
264
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
285
265
|
const checks = schema._zod.def.checks;
|
|
286
|
-
if (checks && checks.length > 0) throw new Error(
|
|
266
|
+
if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
267
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
268
|
+
const newShape = {};
|
|
269
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
|
|
270
|
+
type: "optional",
|
|
271
|
+
innerType: value
|
|
272
|
+
})));
|
|
287
273
|
return clone(schema, mergeDefs(schema._zod.def, {
|
|
288
|
-
|
|
289
|
-
const oldShape = schema._zod.def.shape;
|
|
290
|
-
const shape = { ...oldShape };
|
|
291
|
-
if (mask) for (const key in mask) {
|
|
292
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
293
|
-
if (!mask[key]) continue;
|
|
294
|
-
shape[key] = Class ? new Class({
|
|
295
|
-
type: "optional",
|
|
296
|
-
innerType: oldShape[key]
|
|
297
|
-
}) : oldShape[key];
|
|
298
|
-
}
|
|
299
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
300
|
-
type: "optional",
|
|
301
|
-
innerType: oldShape[key]
|
|
302
|
-
}) : oldShape[key];
|
|
303
|
-
assignProp(this, "shape", shape);
|
|
304
|
-
return shape;
|
|
305
|
-
},
|
|
274
|
+
shape: newShape,
|
|
306
275
|
checks: []
|
|
307
276
|
}));
|
|
308
277
|
}
|
|
309
278
|
function required(Class, schema, mask) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
type: "nonoptional",
|
|
318
|
-
innerType: oldShape[key]
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
322
|
-
type: "nonoptional",
|
|
323
|
-
innerType: oldShape[key]
|
|
324
|
-
});
|
|
325
|
-
assignProp(this, "shape", shape);
|
|
326
|
-
return shape;
|
|
327
|
-
} }));
|
|
279
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
280
|
+
const newShape = {};
|
|
281
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
|
|
282
|
+
type: "nonoptional",
|
|
283
|
+
innerType: value
|
|
284
|
+
}));
|
|
285
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
328
286
|
}
|
|
329
287
|
function aborted(x, startIndex = 0) {
|
|
330
288
|
if (x.aborted === true) return true;
|
|
@@ -347,19 +305,58 @@ function prefixIssues(path, issues) {
|
|
|
347
305
|
function unwrapMessage(message) {
|
|
348
306
|
return typeof message === "string" ? message : message?.message;
|
|
349
307
|
}
|
|
308
|
+
function attachSchema(issues, start, inst) {
|
|
309
|
+
var _a;
|
|
310
|
+
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
|
|
311
|
+
}
|
|
350
312
|
function finalizeIssue(iss, ctx, config) {
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
313
|
+
var _a;
|
|
314
|
+
const traits = iss.inst?._zod?.traits;
|
|
315
|
+
if (traits?.has("$ZodType")) {
|
|
316
|
+
if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
|
|
317
|
+
else iss.schema = iss.inst;
|
|
318
|
+
}
|
|
319
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
320
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
|
|
321
|
+
const full = {};
|
|
322
|
+
for (const k of Object.keys(iss)) {
|
|
323
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
|
|
324
|
+
full[k] = iss[k];
|
|
325
|
+
}
|
|
326
|
+
full.path ?? (full.path = []);
|
|
327
|
+
full.message = message;
|
|
328
|
+
if (ctx?.reportInput) full.input = iss.input;
|
|
329
|
+
return full;
|
|
330
|
+
}
|
|
331
|
+
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
332
|
+
function codePointLength(str) {
|
|
333
|
+
const units = str.length;
|
|
334
|
+
if (!highSurrogate.test(str)) return units;
|
|
335
|
+
let count = units;
|
|
336
|
+
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
337
|
+
count--;
|
|
338
|
+
i++;
|
|
339
|
+
}
|
|
340
|
+
return count;
|
|
357
341
|
}
|
|
358
342
|
function getLengthableOrigin(input) {
|
|
359
343
|
if (Array.isArray(input)) return "array";
|
|
360
344
|
if (typeof input === "string") return "string";
|
|
361
345
|
return "unknown";
|
|
362
346
|
}
|
|
347
|
+
function parsedType(data) {
|
|
348
|
+
const t = typeof data;
|
|
349
|
+
switch (t) {
|
|
350
|
+
case "number": return Number.isNaN(data) ? "nan" : "number";
|
|
351
|
+
case "object": {
|
|
352
|
+
if (data === null) return "null";
|
|
353
|
+
if (Array.isArray(data)) return "array";
|
|
354
|
+
const obj = data;
|
|
355
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return t;
|
|
359
|
+
}
|
|
363
360
|
function issue(...args) {
|
|
364
361
|
const [iss, input, inst] = args;
|
|
365
362
|
if (typeof iss === "string") return {
|
|
@@ -370,33 +367,339 @@ function issue(...args) {
|
|
|
370
367
|
};
|
|
371
368
|
return { ...iss };
|
|
372
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
|
|
372
|
+
*
|
|
373
|
+
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
|
|
374
|
+
*/
|
|
375
|
+
function members(proto, table) {
|
|
376
|
+
for (const key in table) {
|
|
377
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
378
|
+
if (desc.get) Object.defineProperty(proto, key, {
|
|
379
|
+
...desc,
|
|
380
|
+
enumerable: false
|
|
381
|
+
});
|
|
382
|
+
else defineBound(proto, key, desc.value);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
386
|
+
function own(inst, key, value, enumerable = true) {
|
|
387
|
+
Object.defineProperty(inst, key, {
|
|
388
|
+
configurable: true,
|
|
389
|
+
writable: true,
|
|
390
|
+
enumerable,
|
|
391
|
+
value
|
|
392
|
+
});
|
|
393
|
+
return value;
|
|
394
|
+
}
|
|
395
|
+
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
|
|
396
|
+
function hide(inst, key, value) {
|
|
397
|
+
return own(inst, key, value, false);
|
|
398
|
+
}
|
|
399
|
+
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
|
|
400
|
+
function derived(computes, table) {
|
|
401
|
+
for (const key in computes) {
|
|
402
|
+
const compute = computes[key];
|
|
403
|
+
Object.defineProperty(table, key, {
|
|
404
|
+
configurable: true,
|
|
405
|
+
enumerable: true,
|
|
406
|
+
get() {
|
|
407
|
+
return own(this, key, compute(this));
|
|
408
|
+
},
|
|
409
|
+
set(value) {
|
|
410
|
+
own(this, key, value);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
return table;
|
|
415
|
+
}
|
|
416
|
+
function defineBound(proto, key, fn) {
|
|
417
|
+
Object.defineProperty(proto, key, {
|
|
418
|
+
configurable: true,
|
|
419
|
+
get() {
|
|
420
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
421
|
+
},
|
|
422
|
+
set(value) {
|
|
423
|
+
own(this, key, value);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
|
|
428
|
+
function claim(inst, sentinel) {
|
|
429
|
+
const proto = Object.getPrototypeOf(inst);
|
|
430
|
+
return sentinel in proto ? void 0 : proto;
|
|
431
|
+
}
|
|
432
|
+
var installing;
|
|
433
|
+
var broke = false;
|
|
434
|
+
var breaker = {
|
|
435
|
+
configurable: true,
|
|
436
|
+
get() {
|
|
437
|
+
broke = true;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
|
|
442
|
+
* constructor, computed from the internals object itself and cached there on
|
|
443
|
+
* first read. One accessor per constructor rather than one per instance.
|
|
444
|
+
*/
|
|
445
|
+
function defineLazyInternal(inst, key, compute) {
|
|
446
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
447
|
+
if (key in proto && installing !== inst._zod) {
|
|
448
|
+
installing = void 0;
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
installing = inst._zod;
|
|
452
|
+
Object.defineProperty(proto, key, {
|
|
453
|
+
configurable: true,
|
|
454
|
+
get() {
|
|
455
|
+
Object.defineProperty(this, key, breaker);
|
|
456
|
+
const outer = broke;
|
|
457
|
+
broke = false;
|
|
458
|
+
try {
|
|
459
|
+
const value = compute(this);
|
|
460
|
+
if (broke) delete this[key];
|
|
461
|
+
else Object.defineProperty(this, key, {
|
|
462
|
+
configurable: true,
|
|
463
|
+
writable: true,
|
|
464
|
+
value
|
|
465
|
+
});
|
|
466
|
+
broke = broke || outer;
|
|
467
|
+
return value;
|
|
468
|
+
} catch (err) {
|
|
469
|
+
delete this[key];
|
|
470
|
+
broke = broke || outer;
|
|
471
|
+
throw err;
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
set(value) {
|
|
475
|
+
Object.defineProperty(this, key, {
|
|
476
|
+
configurable: true,
|
|
477
|
+
writable: true,
|
|
478
|
+
value
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
|
|
485
|
+
* data property. One accessor per constructor rather than one per instance, because an own accessor
|
|
486
|
+
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
|
|
487
|
+
*/
|
|
488
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
489
|
+
const proto = claim(inst, key);
|
|
490
|
+
if (!proto) return;
|
|
491
|
+
Object.defineProperty(proto, key, {
|
|
492
|
+
configurable: true,
|
|
493
|
+
get() {
|
|
494
|
+
const desc = {
|
|
495
|
+
configurable: true,
|
|
496
|
+
writable: true,
|
|
497
|
+
enumerable,
|
|
498
|
+
value: void 0
|
|
499
|
+
};
|
|
500
|
+
Object.defineProperty(this, key, desc);
|
|
501
|
+
desc.value = make(this);
|
|
502
|
+
Object.defineProperty(this, key, desc);
|
|
503
|
+
return desc.value;
|
|
504
|
+
},
|
|
505
|
+
set(value) {
|
|
506
|
+
Object.defineProperty(this, key, {
|
|
507
|
+
configurable: true,
|
|
508
|
+
writable: true,
|
|
509
|
+
enumerable,
|
|
510
|
+
value
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
|
|
516
|
+
var CONSTANT_CATCH = "~constantCatch";
|
|
517
|
+
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
|
|
518
|
+
function constantCatch(value) {
|
|
519
|
+
const fn = () => value;
|
|
520
|
+
fn[CONSTANT_CATCH] = true;
|
|
521
|
+
return fn;
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region ../../node_modules/zod/v4/core/core.js
|
|
525
|
+
var _a$1;
|
|
526
|
+
var _zodDesc = {
|
|
527
|
+
value: void 0,
|
|
528
|
+
enumerable: false
|
|
529
|
+
};
|
|
530
|
+
var _E = "captureStackTrace" in Error ? Error : null;
|
|
531
|
+
function newError(Definition) {
|
|
532
|
+
const E = _E;
|
|
533
|
+
if (E) {
|
|
534
|
+
const saved = E.stackTraceLimit;
|
|
535
|
+
if (typeof saved === "number") {
|
|
536
|
+
try {
|
|
537
|
+
E.stackTraceLimit = 0;
|
|
538
|
+
} catch {
|
|
539
|
+
_E = null;
|
|
540
|
+
return new Definition();
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
return new Definition();
|
|
544
|
+
} finally {
|
|
545
|
+
E.stackTraceLimit = saved;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return new Definition();
|
|
550
|
+
}
|
|
551
|
+
function $constructor(name, initializer, proto, params) {
|
|
552
|
+
const zodProto = {};
|
|
553
|
+
function Internals(def) {
|
|
554
|
+
this.def = def;
|
|
555
|
+
this.constr = _;
|
|
556
|
+
this.traits = /* @__PURE__ */ new Set();
|
|
557
|
+
}
|
|
558
|
+
Internals.prototype = zodProto;
|
|
559
|
+
const protoMembers = proto;
|
|
560
|
+
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
561
|
+
function init(inst, def) {
|
|
562
|
+
if (!inst._zod) {
|
|
563
|
+
_zodDesc.value = new Internals(def);
|
|
564
|
+
try {
|
|
565
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
566
|
+
} finally {
|
|
567
|
+
_zodDesc.value = void 0;
|
|
568
|
+
}
|
|
569
|
+
} else if (inst._zod.traits.has(name)) return;
|
|
570
|
+
inst._zod.traits.add(name);
|
|
571
|
+
initializer(inst, def);
|
|
572
|
+
if (initialized) {
|
|
573
|
+
const own = Object.getPrototypeOf(inst);
|
|
574
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
575
|
+
let up = own;
|
|
576
|
+
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
577
|
+
const target = up ?? own;
|
|
578
|
+
if (!initialized.has(target)) {
|
|
579
|
+
initialized.add(target);
|
|
580
|
+
members(target, protoMembers);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const proto = _.prototype;
|
|
584
|
+
for (const k in proto) {
|
|
585
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
586
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
const Parent = params?.Parent ?? Object;
|
|
590
|
+
class Definition extends Parent {}
|
|
591
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
592
|
+
function _(def) {
|
|
593
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
594
|
+
init(inst, def);
|
|
595
|
+
const deferred = inst._zod.deferred;
|
|
596
|
+
if (deferred) {
|
|
597
|
+
for (const fn of deferred) fn();
|
|
598
|
+
inst._zod.deferred = void 0;
|
|
599
|
+
}
|
|
600
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
601
|
+
if (pp) pp(inst);
|
|
602
|
+
return inst;
|
|
603
|
+
}
|
|
604
|
+
Object.defineProperty(_, "init", { value: init });
|
|
605
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
606
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
607
|
+
return inst?._zod?.traits?.has(name);
|
|
608
|
+
} });
|
|
609
|
+
Object.defineProperty(_, "name", { value: name });
|
|
610
|
+
return _;
|
|
611
|
+
}
|
|
612
|
+
var $ZodAsyncError = class extends Error {
|
|
613
|
+
constructor() {
|
|
614
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
var $ZodEncodeError = class extends Error {
|
|
618
|
+
constructor(name) {
|
|
619
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
620
|
+
this.name = "ZodEncodeError";
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
624
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
625
|
+
function config(newConfig) {
|
|
626
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
627
|
+
return globalConfig;
|
|
628
|
+
}
|
|
373
629
|
//#endregion
|
|
374
630
|
//#region ../../node_modules/zod/v4/core/errors.js
|
|
631
|
+
function _getMessage() {
|
|
632
|
+
const internals = this._zod;
|
|
633
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
634
|
+
return internals.message;
|
|
635
|
+
}
|
|
636
|
+
function _setMessage(value) {
|
|
637
|
+
this._zod.message = value;
|
|
638
|
+
}
|
|
639
|
+
var _messageDesc = {
|
|
640
|
+
get: _getMessage,
|
|
641
|
+
set: _setMessage,
|
|
642
|
+
enumerable: true,
|
|
643
|
+
configurable: true
|
|
644
|
+
};
|
|
645
|
+
var _issuesDesc = {
|
|
646
|
+
value: void 0,
|
|
647
|
+
enumerable: false
|
|
648
|
+
};
|
|
649
|
+
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
375
650
|
var initializer$1 = (inst, def) => {
|
|
376
651
|
inst.name = "$ZodError";
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
Object.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
652
|
+
_issuesDesc.value = def;
|
|
653
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
654
|
+
_issuesDesc.value = void 0;
|
|
655
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
656
|
+
const proto = Object.getPrototypeOf(inst);
|
|
657
|
+
if (!_installedToString.has(proto)) {
|
|
658
|
+
_installedToString.add(proto);
|
|
659
|
+
Object.defineProperty(proto, "toString", {
|
|
660
|
+
configurable: true,
|
|
661
|
+
enumerable: false,
|
|
662
|
+
get() {
|
|
663
|
+
const value = () => this.message;
|
|
664
|
+
Object.defineProperty(this, "toString", {
|
|
665
|
+
value,
|
|
666
|
+
configurable: true,
|
|
667
|
+
writable: true
|
|
668
|
+
});
|
|
669
|
+
return value;
|
|
670
|
+
},
|
|
671
|
+
set(value) {
|
|
672
|
+
Object.defineProperty(this, "toString", {
|
|
673
|
+
value,
|
|
674
|
+
configurable: true,
|
|
675
|
+
writable: true
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
390
680
|
};
|
|
391
681
|
var $ZodError = $constructor("$ZodError", initializer$1);
|
|
392
|
-
|
|
682
|
+
$constructor("$ZodError", initializer$1, void 0, { Parent: Error });
|
|
683
|
+
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
684
|
+
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
685
|
+
* "__proto__" would hit the setter instead of creating a key. */
|
|
686
|
+
function node(obj, key, make) {
|
|
687
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
688
|
+
if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
689
|
+
value: make(),
|
|
690
|
+
writable: true,
|
|
691
|
+
enumerable: true,
|
|
692
|
+
configurable: true
|
|
693
|
+
});
|
|
694
|
+
else obj[key] = make();
|
|
695
|
+
}
|
|
696
|
+
return obj[key];
|
|
697
|
+
}
|
|
393
698
|
function flattenError(error, mapper = (issue) => issue.message) {
|
|
394
699
|
const fieldErrors = {};
|
|
395
700
|
const formErrors = [];
|
|
396
|
-
for (const sub of error.issues) if (sub.path.length > 0)
|
|
397
|
-
|
|
398
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
399
|
-
} else formErrors.push(mapper(sub));
|
|
701
|
+
for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
702
|
+
else formErrors.push(mapper(sub));
|
|
400
703
|
return {
|
|
401
704
|
formErrors,
|
|
402
705
|
fieldErrors
|
|
@@ -416,12 +719,21 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
416
719
|
let i = 0;
|
|
417
720
|
while (i < fullpath.length) {
|
|
418
721
|
const el = fullpath[i];
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
722
|
+
const terminal = i === fullpath.length - 1;
|
|
723
|
+
if (el === "_errors") {
|
|
724
|
+
if (terminal) curr._errors.push(mapper(issue));
|
|
725
|
+
i++;
|
|
726
|
+
continue;
|
|
423
727
|
}
|
|
424
|
-
curr
|
|
728
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
|
|
729
|
+
value: { _errors: [] },
|
|
730
|
+
enumerable: true,
|
|
731
|
+
writable: true,
|
|
732
|
+
configurable: true
|
|
733
|
+
});
|
|
734
|
+
const node = curr[el];
|
|
735
|
+
if (terminal) node._errors.push(mapper(issue));
|
|
736
|
+
curr = node;
|
|
425
737
|
i++;
|
|
426
738
|
}
|
|
427
739
|
}
|
|
@@ -432,7 +744,53 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
432
744
|
}
|
|
433
745
|
//#endregion
|
|
434
746
|
//#region ../../node_modules/zod/v4/core/parse.js
|
|
435
|
-
|
|
747
|
+
function finalizeParams(callee, params) {
|
|
748
|
+
return {
|
|
749
|
+
callee: params?.callee ?? callee,
|
|
750
|
+
Err: params?.Err
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
var _parse = (_Err) => {
|
|
754
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
755
|
+
const ctx = _ctx ? {
|
|
756
|
+
..._ctx,
|
|
757
|
+
async: false
|
|
758
|
+
} : { async: false };
|
|
759
|
+
const result = schema._zod.run({
|
|
760
|
+
value,
|
|
761
|
+
issues: []
|
|
762
|
+
}, ctx);
|
|
763
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
764
|
+
if (result.issues.length) {
|
|
765
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
766
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
767
|
+
throw e;
|
|
768
|
+
}
|
|
769
|
+
return result.value;
|
|
770
|
+
};
|
|
771
|
+
return fn;
|
|
772
|
+
};
|
|
773
|
+
var _parseAsync = (_Err) => {
|
|
774
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
775
|
+
const ctx = _ctx ? {
|
|
776
|
+
..._ctx,
|
|
777
|
+
async: true
|
|
778
|
+
} : { async: true };
|
|
779
|
+
let result = schema._zod.run({
|
|
780
|
+
value,
|
|
781
|
+
issues: []
|
|
782
|
+
}, ctx);
|
|
783
|
+
if (result instanceof Promise) result = await result;
|
|
784
|
+
if (result.issues.length) {
|
|
785
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
786
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
787
|
+
throw e;
|
|
788
|
+
}
|
|
789
|
+
return result.value;
|
|
790
|
+
};
|
|
791
|
+
return fn;
|
|
792
|
+
};
|
|
793
|
+
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
436
794
|
const ctx = _ctx ? {
|
|
437
795
|
..._ctx,
|
|
438
796
|
async: false
|
|
@@ -442,14 +800,31 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
442
800
|
issues: []
|
|
443
801
|
}, ctx);
|
|
444
802
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}
|
|
450
|
-
return result.value;
|
|
803
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
804
|
+
success: true,
|
|
805
|
+
data: result.value
|
|
806
|
+
};
|
|
451
807
|
};
|
|
452
|
-
|
|
808
|
+
function failure(Err, issues, ctx) {
|
|
809
|
+
let error;
|
|
810
|
+
return {
|
|
811
|
+
success: false,
|
|
812
|
+
get error() {
|
|
813
|
+
if (!error) {
|
|
814
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
815
|
+
issues = void 0;
|
|
816
|
+
ctx = void 0;
|
|
817
|
+
}
|
|
818
|
+
return error;
|
|
819
|
+
},
|
|
820
|
+
set error(e) {
|
|
821
|
+
error = e;
|
|
822
|
+
issues = void 0;
|
|
823
|
+
ctx = void 0;
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
453
828
|
const ctx = _ctx ? {
|
|
454
829
|
..._ctx,
|
|
455
830
|
async: true
|
|
@@ -459,70 +834,96 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
459
834
|
issues: []
|
|
460
835
|
}, ctx);
|
|
461
836
|
if (result instanceof Promise) result = await result;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
return result.value;
|
|
837
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
838
|
+
success: true,
|
|
839
|
+
data: result.value
|
|
840
|
+
};
|
|
468
841
|
};
|
|
469
|
-
var
|
|
842
|
+
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
843
|
+
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
844
|
+
var validate = ((schema, value, _ctx) => {
|
|
845
|
+
const validator = schema._zod.bag.validator;
|
|
846
|
+
if (validator !== void 0) {
|
|
847
|
+
if (validator(value) !== COMPILE_INVALID) return true;
|
|
848
|
+
if (validator.definite === true && _ctx === void 0) return false;
|
|
849
|
+
}
|
|
850
|
+
return validateFallback(schema, value, _ctx);
|
|
851
|
+
});
|
|
852
|
+
function validateFallback(schema, value, _ctx) {
|
|
470
853
|
const ctx = _ctx ? {
|
|
471
854
|
..._ctx,
|
|
472
|
-
async: false
|
|
473
|
-
|
|
474
|
-
|
|
855
|
+
async: false,
|
|
856
|
+
abortEarly: true
|
|
857
|
+
} : {
|
|
858
|
+
async: false,
|
|
859
|
+
abortEarly: true
|
|
860
|
+
};
|
|
861
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
862
|
+
let result;
|
|
863
|
+
if (fallbackRun) {
|
|
864
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
865
|
+
result = fallbackRun({
|
|
866
|
+
value,
|
|
867
|
+
issues: []
|
|
868
|
+
}, ctx);
|
|
869
|
+
} else result = schema._zod.run({
|
|
475
870
|
value,
|
|
476
871
|
issues: []
|
|
477
872
|
}, ctx);
|
|
478
873
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
479
|
-
return result.issues.length
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
} : {
|
|
483
|
-
success: true,
|
|
484
|
-
data: result.value
|
|
485
|
-
};
|
|
486
|
-
};
|
|
487
|
-
var safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
|
|
488
|
-
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
874
|
+
return result.issues.length === 0;
|
|
875
|
+
}
|
|
876
|
+
var validateAsync$1 = async (schema, value, _ctx) => {
|
|
489
877
|
const ctx = _ctx ? {
|
|
490
878
|
..._ctx,
|
|
491
|
-
async: true
|
|
492
|
-
|
|
879
|
+
async: true,
|
|
880
|
+
abortEarly: true
|
|
881
|
+
} : {
|
|
882
|
+
async: true,
|
|
883
|
+
abortEarly: true
|
|
884
|
+
};
|
|
493
885
|
let result = schema._zod.run({
|
|
494
886
|
value,
|
|
495
887
|
issues: []
|
|
496
888
|
}, ctx);
|
|
497
889
|
if (result instanceof Promise) result = await result;
|
|
498
|
-
return result.issues.length
|
|
499
|
-
success: false,
|
|
500
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
501
|
-
} : {
|
|
502
|
-
success: true,
|
|
503
|
-
data: result.value
|
|
504
|
-
};
|
|
890
|
+
return result.issues.length === 0;
|
|
505
891
|
};
|
|
506
|
-
var
|
|
507
|
-
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
892
|
+
var _encode = (_Err) => {
|
|
893
|
+
const parse = _parse(_Err);
|
|
894
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
895
|
+
const ctx = _ctx ? {
|
|
896
|
+
..._ctx,
|
|
897
|
+
direction: "backward"
|
|
898
|
+
} : { direction: "backward" };
|
|
899
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
900
|
+
};
|
|
901
|
+
return fn;
|
|
513
902
|
};
|
|
514
|
-
var _decode = (_Err) =>
|
|
515
|
-
|
|
903
|
+
var _decode = (_Err) => {
|
|
904
|
+
const parse = _parse(_Err);
|
|
905
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
906
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
907
|
+
};
|
|
908
|
+
return fn;
|
|
516
909
|
};
|
|
517
|
-
var _encodeAsync = (_Err) =>
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
910
|
+
var _encodeAsync = (_Err) => {
|
|
911
|
+
const parseAsync = _parseAsync(_Err);
|
|
912
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
913
|
+
const ctx = _ctx ? {
|
|
914
|
+
..._ctx,
|
|
915
|
+
direction: "backward"
|
|
916
|
+
} : { direction: "backward" };
|
|
917
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
918
|
+
};
|
|
919
|
+
return fn;
|
|
523
920
|
};
|
|
524
|
-
var _decodeAsync = (_Err) =>
|
|
525
|
-
|
|
921
|
+
var _decodeAsync = (_Err) => {
|
|
922
|
+
const parseAsync = _parseAsync(_Err);
|
|
923
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
924
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
925
|
+
};
|
|
926
|
+
return fn;
|
|
526
927
|
};
|
|
527
928
|
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
528
929
|
const ctx = _ctx ? {
|
|
@@ -553,12 +954,15 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
553
954
|
*/
|
|
554
955
|
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
555
956
|
var cuid2 = /^[0-9a-z]+$/;
|
|
556
|
-
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{
|
|
957
|
+
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
557
958
|
var xid = /^[0-9a-vA-V]{20}$/;
|
|
558
959
|
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
559
960
|
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
961
|
+
function nanoidOfLength(length) {
|
|
962
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
963
|
+
}
|
|
560
964
|
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
561
|
-
var duration
|
|
965
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
562
966
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
563
967
|
var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
564
968
|
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
@@ -569,40 +973,45 @@ var uuid = (version) => {
|
|
|
569
973
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
570
974
|
};
|
|
571
975
|
/** Practical email validation */
|
|
572
|
-
var email = /^(
|
|
573
|
-
var _emoji$1 = `^(\\p{Extended_Pictographic}
|
|
976
|
+
var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
977
|
+
var _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
574
978
|
function emoji() {
|
|
575
979
|
return new RegExp(_emoji$1, "u");
|
|
576
980
|
}
|
|
577
981
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
578
982
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))$/;
|
|
579
983
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
580
|
-
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
984
|
+
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
581
985
|
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
582
|
-
var base64url = /^[A-Za-z0-9_-]
|
|
986
|
+
var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
583
987
|
var httpProtocol = /^https?$/;
|
|
584
988
|
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
585
989
|
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
586
|
-
|
|
990
|
+
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
991
|
+
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
992
|
+
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
|
|
993
|
+
function anchor(source) {
|
|
994
|
+
return new RegExp(`^${source}$`);
|
|
995
|
+
}
|
|
996
|
+
var date = /*@__PURE__*/ anchor(dateSource);
|
|
587
997
|
function timeSource(args) {
|
|
588
998
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
589
|
-
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
999
|
+
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
590
1000
|
}
|
|
591
|
-
function time
|
|
1001
|
+
function time(args) {
|
|
592
1002
|
return new RegExp(`^${timeSource(args)}$`);
|
|
593
1003
|
}
|
|
594
|
-
function datetime
|
|
595
|
-
const time = timeSource({ precision: args.precision });
|
|
1004
|
+
function datetime(args) {
|
|
596
1005
|
const opts = ["Z"];
|
|
597
|
-
if (args.local) opts.push("");
|
|
598
1006
|
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
599
|
-
const
|
|
1007
|
+
const qualified = `${timeSource({
|
|
1008
|
+
precision: args.precision,
|
|
1009
|
+
seconds: true
|
|
1010
|
+
})}(?:${opts.join("|")})`;
|
|
1011
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
600
1012
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
601
1013
|
}
|
|
602
|
-
var
|
|
603
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
604
|
-
return new RegExp(`^${regex}$`);
|
|
605
|
-
};
|
|
1014
|
+
var anyString = /^[\s\S]{0,}$/;
|
|
606
1015
|
var integer = /^-?\d+$/;
|
|
607
1016
|
var number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
608
1017
|
var boolean$1 = /^(?:true|false)$/i;
|
|
@@ -616,6 +1025,11 @@ var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
|
616
1025
|
inst._zod.def = def;
|
|
617
1026
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
618
1027
|
});
|
|
1028
|
+
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
|
|
1029
|
+
var _whenHasLength = (payload) => {
|
|
1030
|
+
const val = payload.value;
|
|
1031
|
+
return !nullish(val) && val.length !== void 0;
|
|
1032
|
+
};
|
|
619
1033
|
var numericOriginMap = {
|
|
620
1034
|
number: "number",
|
|
621
1035
|
bigint: "bigint",
|
|
@@ -624,18 +1038,10 @@ var numericOriginMap = {
|
|
|
624
1038
|
var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
625
1039
|
$ZodCheck.init(inst, def);
|
|
626
1040
|
const origin = numericOriginMap[typeof def.value];
|
|
627
|
-
inst._zod.onattach.push((inst) => {
|
|
628
|
-
const bag = inst._zod.bag;
|
|
629
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
630
|
-
if (def.value < curr) {
|
|
631
|
-
if (def.inclusive) bag.maximum = def.value;
|
|
632
|
-
else bag.exclusiveMaximum = def.value;
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
1041
|
inst._zod.check = (payload) => {
|
|
636
1042
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
637
1043
|
payload.issues.push({
|
|
638
|
-
origin,
|
|
1044
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
639
1045
|
code: "too_big",
|
|
640
1046
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
641
1047
|
input: payload.value,
|
|
@@ -648,18 +1054,10 @@ var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, d
|
|
|
648
1054
|
var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
649
1055
|
$ZodCheck.init(inst, def);
|
|
650
1056
|
const origin = numericOriginMap[typeof def.value];
|
|
651
|
-
inst._zod.onattach.push((inst) => {
|
|
652
|
-
const bag = inst._zod.bag;
|
|
653
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
654
|
-
if (def.value > curr) {
|
|
655
|
-
if (def.inclusive) bag.minimum = def.value;
|
|
656
|
-
else bag.exclusiveMinimum = def.value;
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
1057
|
inst._zod.check = (payload) => {
|
|
660
1058
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
661
1059
|
payload.issues.push({
|
|
662
|
-
origin,
|
|
1060
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
663
1061
|
code: "too_small",
|
|
664
1062
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
665
1063
|
input: payload.value,
|
|
@@ -671,13 +1069,9 @@ var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (i
|
|
|
671
1069
|
});
|
|
672
1070
|
var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
673
1071
|
$ZodCheck.init(inst, def);
|
|
674
|
-
inst._zod.onattach.push((inst) => {
|
|
675
|
-
var _a;
|
|
676
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
677
|
-
});
|
|
678
1072
|
inst._zod.check = (payload) => {
|
|
679
1073
|
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
680
|
-
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
1074
|
+
if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
681
1075
|
payload.issues.push({
|
|
682
1076
|
origin: typeof payload.value,
|
|
683
1077
|
code: "not_multiple_of",
|
|
@@ -694,13 +1088,6 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
|
|
|
694
1088
|
const isInt = def.format?.includes("int");
|
|
695
1089
|
const origin = isInt ? "int" : "number";
|
|
696
1090
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
697
|
-
inst._zod.onattach.push((inst) => {
|
|
698
|
-
const bag = inst._zod.bag;
|
|
699
|
-
bag.format = def.format;
|
|
700
|
-
bag.minimum = minimum;
|
|
701
|
-
bag.maximum = maximum;
|
|
702
|
-
if (isInt) bag.pattern = integer;
|
|
703
|
-
});
|
|
704
1091
|
inst._zod.check = (payload) => {
|
|
705
1092
|
const input = payload.value;
|
|
706
1093
|
if (isInt) {
|
|
@@ -762,17 +1149,11 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
|
|
|
762
1149
|
var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
763
1150
|
var _a;
|
|
764
1151
|
$ZodCheck.init(inst, def);
|
|
765
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
766
|
-
const val = payload.value;
|
|
767
|
-
return !nullish(val) && val.length !== void 0;
|
|
768
|
-
});
|
|
769
|
-
inst._zod.onattach.push((inst) => {
|
|
770
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
771
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
772
|
-
});
|
|
1152
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
773
1153
|
inst._zod.check = (payload) => {
|
|
774
1154
|
const input = payload.value;
|
|
775
|
-
|
|
1155
|
+
const units = input.length;
|
|
1156
|
+
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
776
1157
|
const origin = getLengthableOrigin(input);
|
|
777
1158
|
payload.issues.push({
|
|
778
1159
|
origin,
|
|
@@ -788,17 +1169,11 @@ var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst,
|
|
|
788
1169
|
var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
789
1170
|
var _a;
|
|
790
1171
|
$ZodCheck.init(inst, def);
|
|
791
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
792
|
-
const val = payload.value;
|
|
793
|
-
return !nullish(val) && val.length !== void 0;
|
|
794
|
-
});
|
|
795
|
-
inst._zod.onattach.push((inst) => {
|
|
796
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
797
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
798
|
-
});
|
|
1172
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
799
1173
|
inst._zod.check = (payload) => {
|
|
800
1174
|
const input = payload.value;
|
|
801
|
-
|
|
1175
|
+
const units = input.length;
|
|
1176
|
+
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
802
1177
|
const origin = getLengthableOrigin(input);
|
|
803
1178
|
payload.issues.push({
|
|
804
1179
|
origin,
|
|
@@ -814,19 +1189,11 @@ var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst,
|
|
|
814
1189
|
var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
815
1190
|
var _a;
|
|
816
1191
|
$ZodCheck.init(inst, def);
|
|
817
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
818
|
-
const val = payload.value;
|
|
819
|
-
return !nullish(val) && val.length !== void 0;
|
|
820
|
-
});
|
|
821
|
-
inst._zod.onattach.push((inst) => {
|
|
822
|
-
const bag = inst._zod.bag;
|
|
823
|
-
bag.minimum = def.length;
|
|
824
|
-
bag.maximum = def.length;
|
|
825
|
-
bag.length = def.length;
|
|
826
|
-
});
|
|
1192
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
827
1193
|
inst._zod.check = (payload) => {
|
|
828
1194
|
const input = payload.value;
|
|
829
|
-
const
|
|
1195
|
+
const units = input.length;
|
|
1196
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
830
1197
|
if (length === def.length) return;
|
|
831
1198
|
const origin = getLengthableOrigin(input);
|
|
832
1199
|
const tooBig = length > def.length;
|
|
@@ -850,14 +1217,6 @@ var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals",
|
|
|
850
1217
|
var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
851
1218
|
var _a, _b;
|
|
852
1219
|
$ZodCheck.init(inst, def);
|
|
853
|
-
inst._zod.onattach.push((inst) => {
|
|
854
|
-
const bag = inst._zod.bag;
|
|
855
|
-
bag.format = def.format;
|
|
856
|
-
if (def.pattern) {
|
|
857
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
858
|
-
bag.patterns.add(def.pattern);
|
|
859
|
-
}
|
|
860
|
-
});
|
|
861
1220
|
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
862
1221
|
def.pattern.lastIndex = 0;
|
|
863
1222
|
if (def.pattern.test(payload.value)) return;
|
|
@@ -900,13 +1259,7 @@ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst,
|
|
|
900
1259
|
var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
901
1260
|
$ZodCheck.init(inst, def);
|
|
902
1261
|
const escapedRegex = escapeRegex(def.includes);
|
|
903
|
-
|
|
904
|
-
def.pattern = pattern;
|
|
905
|
-
inst._zod.onattach.push((inst) => {
|
|
906
|
-
const bag = inst._zod.bag;
|
|
907
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
908
|
-
bag.patterns.add(pattern);
|
|
909
|
-
});
|
|
1262
|
+
def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
910
1263
|
inst._zod.check = (payload) => {
|
|
911
1264
|
if (payload.value.includes(def.includes, def.position)) return;
|
|
912
1265
|
payload.issues.push({
|
|
@@ -924,11 +1277,6 @@ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (ins
|
|
|
924
1277
|
$ZodCheck.init(inst, def);
|
|
925
1278
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
926
1279
|
def.pattern ?? (def.pattern = pattern);
|
|
927
|
-
inst._zod.onattach.push((inst) => {
|
|
928
|
-
const bag = inst._zod.bag;
|
|
929
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
930
|
-
bag.patterns.add(pattern);
|
|
931
|
-
});
|
|
932
1280
|
inst._zod.check = (payload) => {
|
|
933
1281
|
if (payload.value.startsWith(def.prefix)) return;
|
|
934
1282
|
payload.issues.push({
|
|
@@ -946,11 +1294,6 @@ var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, d
|
|
|
946
1294
|
$ZodCheck.init(inst, def);
|
|
947
1295
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
948
1296
|
def.pattern ?? (def.pattern = pattern);
|
|
949
|
-
inst._zod.onattach.push((inst) => {
|
|
950
|
-
const bag = inst._zod.bag;
|
|
951
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
952
|
-
bag.patterns.add(pattern);
|
|
953
|
-
});
|
|
954
1297
|
inst._zod.check = (payload) => {
|
|
955
1298
|
if (payload.value.endsWith(def.suffix)) return;
|
|
956
1299
|
payload.issues.push({
|
|
@@ -973,15 +1316,19 @@ var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst,
|
|
|
973
1316
|
//#endregion
|
|
974
1317
|
//#region ../../node_modules/zod/v4/core/doc.js
|
|
975
1318
|
var Doc = class {
|
|
976
|
-
constructor(args = []) {
|
|
1319
|
+
constructor(args = [], closed = {}) {
|
|
977
1320
|
this.content = [];
|
|
978
1321
|
this.indent = 0;
|
|
979
|
-
|
|
1322
|
+
this.args = args;
|
|
1323
|
+
this.closed = closed;
|
|
980
1324
|
}
|
|
981
1325
|
indented(fn) {
|
|
982
1326
|
this.indent += 1;
|
|
983
|
-
|
|
984
|
-
|
|
1327
|
+
try {
|
|
1328
|
+
fn(this);
|
|
1329
|
+
} finally {
|
|
1330
|
+
this.indent -= 1;
|
|
1331
|
+
}
|
|
985
1332
|
}
|
|
986
1333
|
write(arg) {
|
|
987
1334
|
if (typeof arg === "function") {
|
|
@@ -996,17 +1343,16 @@ var Doc = class {
|
|
|
996
1343
|
}
|
|
997
1344
|
compile() {
|
|
998
1345
|
const F = Function;
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
return new F(...args, lines.join("\n"));
|
|
1346
|
+
const content = this?.content ?? [``];
|
|
1347
|
+
return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
|
|
1002
1348
|
}
|
|
1003
1349
|
};
|
|
1004
1350
|
//#endregion
|
|
1005
1351
|
//#region ../../node_modules/zod/v4/core/versions.js
|
|
1006
1352
|
var version = {
|
|
1007
1353
|
major: 4,
|
|
1008
|
-
minor:
|
|
1009
|
-
patch:
|
|
1354
|
+
minor: 6,
|
|
1355
|
+
patch: 5
|
|
1010
1356
|
};
|
|
1011
1357
|
//#endregion
|
|
1012
1358
|
//#region ../../node_modules/zod/v4/core/schemas.js
|
|
@@ -1016,8 +1362,8 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1016
1362
|
inst._zod.def = def;
|
|
1017
1363
|
inst._zod.bag = inst._zod.bag || {};
|
|
1018
1364
|
inst._zod.version = version;
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1365
|
+
const defChecks = inst._zod.def.checks;
|
|
1366
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1021
1367
|
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1022
1368
|
if (checks.length === 0) {
|
|
1023
1369
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
@@ -1026,6 +1372,7 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1026
1372
|
});
|
|
1027
1373
|
} else {
|
|
1028
1374
|
const runChecks = (payload, checks, ctx) => {
|
|
1375
|
+
if (payload.memo) return payload;
|
|
1029
1376
|
let isAborted = aborted(payload);
|
|
1030
1377
|
let asyncResult;
|
|
1031
1378
|
for (const ch of checks) {
|
|
@@ -1039,10 +1386,12 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1039
1386
|
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1040
1387
|
await _;
|
|
1041
1388
|
if (payload.issues.length === currLen) return;
|
|
1389
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1042
1390
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1043
1391
|
});
|
|
1044
1392
|
else {
|
|
1045
1393
|
if (payload.issues.length === currLen) continue;
|
|
1394
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1046
1395
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1047
1396
|
}
|
|
1048
1397
|
}
|
|
@@ -1086,22 +1435,43 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1086
1435
|
return runChecks(result, checks, ctx);
|
|
1087
1436
|
};
|
|
1088
1437
|
}
|
|
1089
|
-
|
|
1438
|
+
}, {
|
|
1439
|
+
get "~standard"() {
|
|
1440
|
+
return hide(this, "~standard", standardProps(this));
|
|
1441
|
+
},
|
|
1442
|
+
set "~standard"(value) {
|
|
1443
|
+
own(this, "~standard", value);
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
1447
|
+
var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1448
|
+
async function validateAsync(inst, value) {
|
|
1449
|
+
const ctx = { async: true };
|
|
1450
|
+
return toStandardResult(await inst._zod.run({
|
|
1451
|
+
value,
|
|
1452
|
+
issues: []
|
|
1453
|
+
}, ctx), ctx);
|
|
1454
|
+
}
|
|
1455
|
+
function standardProps(inst) {
|
|
1456
|
+
return {
|
|
1090
1457
|
validate: (value) => {
|
|
1458
|
+
const ctx = { async: false };
|
|
1091
1459
|
try {
|
|
1092
|
-
const r =
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1460
|
+
const r = inst._zod.run({
|
|
1461
|
+
value,
|
|
1462
|
+
issues: []
|
|
1463
|
+
}, ctx);
|
|
1464
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
1465
|
+
} catch (_) {}
|
|
1466
|
+
return validateAsync(inst, value);
|
|
1097
1467
|
},
|
|
1098
1468
|
vendor: "zod",
|
|
1099
1469
|
version: 1
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1102
1472
|
var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
1103
1473
|
$ZodType.init(inst, def);
|
|
1104
|
-
inst._zod.pattern =
|
|
1474
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1105
1475
|
inst._zod.parse = (payload, _) => {
|
|
1106
1476
|
if (def.coerce) try {
|
|
1107
1477
|
payload.value = String(payload.value);
|
|
@@ -1145,51 +1515,95 @@ var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1145
1515
|
def.pattern ?? (def.pattern = email);
|
|
1146
1516
|
$ZodStringFormat.init(inst, def);
|
|
1147
1517
|
});
|
|
1518
|
+
function canParseURL(input) {
|
|
1519
|
+
try {
|
|
1520
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
1521
|
+
new URL(input);
|
|
1522
|
+
return true;
|
|
1523
|
+
} catch {
|
|
1524
|
+
return false;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
function validateURL(trimmed, def) {
|
|
1528
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
|
|
1529
|
+
return parseURLObject(trimmed, def);
|
|
1530
|
+
}
|
|
1531
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
1532
|
+
function parseURLObject(trimmed, def) {
|
|
1533
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
|
|
1534
|
+
try {
|
|
1535
|
+
if (typeof URL !== "undefined") {
|
|
1536
|
+
const URLStatic = URL;
|
|
1537
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
|
|
1538
|
+
}
|
|
1539
|
+
return new URL(trimmed);
|
|
1540
|
+
} catch {
|
|
1541
|
+
return 2;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
var asciiTabOrNewline = /[\t\n\r]/g;
|
|
1545
|
+
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
1546
|
+
function stripTabAndNewline(value) {
|
|
1547
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1548
|
+
}
|
|
1549
|
+
function urlHostnameOk(url, hostname) {
|
|
1550
|
+
hostname.lastIndex = 0;
|
|
1551
|
+
return hostname.test(url.hostname);
|
|
1552
|
+
}
|
|
1553
|
+
function urlProtocolOk(url, protocol) {
|
|
1554
|
+
protocol.lastIndex = 0;
|
|
1555
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1556
|
+
}
|
|
1148
1557
|
var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
1149
1558
|
$ZodStringFormat.init(inst, def);
|
|
1150
1559
|
inst._zod.check = (payload) => {
|
|
1151
1560
|
try {
|
|
1152
1561
|
const trimmed = payload.value.trim();
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
code: "invalid_format",
|
|
1157
|
-
format: "url",
|
|
1158
|
-
note: "Invalid URL format",
|
|
1159
|
-
input: payload.value,
|
|
1160
|
-
inst,
|
|
1161
|
-
continue: !def.abort
|
|
1162
|
-
});
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
const url = new URL(trimmed);
|
|
1167
|
-
if (def.hostname) {
|
|
1168
|
-
def.hostname.lastIndex = 0;
|
|
1169
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1562
|
+
const url = validateURL(trimmed, def);
|
|
1563
|
+
if (url === 1) {
|
|
1564
|
+
payload.issues.push({
|
|
1170
1565
|
code: "invalid_format",
|
|
1171
1566
|
format: "url",
|
|
1172
|
-
note: "Invalid
|
|
1173
|
-
pattern: def.hostname.source,
|
|
1567
|
+
note: "Invalid URL format",
|
|
1174
1568
|
input: payload.value,
|
|
1175
1569
|
inst,
|
|
1176
1570
|
continue: !def.abort
|
|
1177
1571
|
});
|
|
1572
|
+
return;
|
|
1178
1573
|
}
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1181
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1574
|
+
if (url === 2) {
|
|
1575
|
+
payload.issues.push({
|
|
1182
1576
|
code: "invalid_format",
|
|
1183
1577
|
format: "url",
|
|
1184
|
-
note: "Invalid protocol",
|
|
1185
|
-
pattern: def.protocol.source,
|
|
1186
1578
|
input: payload.value,
|
|
1187
1579
|
inst,
|
|
1188
1580
|
continue: !def.abort
|
|
1189
1581
|
});
|
|
1582
|
+
return;
|
|
1583
|
+
}
|
|
1584
|
+
if (url === true) {
|
|
1585
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1586
|
+
return;
|
|
1190
1587
|
}
|
|
1191
|
-
if (def.
|
|
1192
|
-
|
|
1588
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
|
|
1589
|
+
code: "invalid_format",
|
|
1590
|
+
format: "url",
|
|
1591
|
+
note: "Invalid hostname",
|
|
1592
|
+
pattern: def.hostname.source,
|
|
1593
|
+
input: payload.value,
|
|
1594
|
+
inst,
|
|
1595
|
+
continue: !def.abort
|
|
1596
|
+
});
|
|
1597
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
|
|
1598
|
+
code: "invalid_format",
|
|
1599
|
+
format: "url",
|
|
1600
|
+
note: "Invalid protocol",
|
|
1601
|
+
pattern: def.protocol.source,
|
|
1602
|
+
input: payload.value,
|
|
1603
|
+
inst,
|
|
1604
|
+
continue: !def.abort
|
|
1605
|
+
});
|
|
1606
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1193
1607
|
return;
|
|
1194
1608
|
} catch (_) {
|
|
1195
1609
|
payload.issues.push({
|
|
@@ -1207,7 +1621,8 @@ var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
|
|
|
1207
1621
|
$ZodStringFormat.init(inst, def);
|
|
1208
1622
|
});
|
|
1209
1623
|
var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
1210
|
-
def.
|
|
1624
|
+
if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1625
|
+
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
1211
1626
|
$ZodStringFormat.init(inst, def);
|
|
1212
1627
|
});
|
|
1213
1628
|
/**
|
|
@@ -1236,70 +1651,69 @@ var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
1236
1651
|
$ZodStringFormat.init(inst, def);
|
|
1237
1652
|
});
|
|
1238
1653
|
var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1239
|
-
def.pattern ?? (def.pattern = datetime
|
|
1654
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1240
1655
|
$ZodStringFormat.init(inst, def);
|
|
1241
1656
|
});
|
|
1242
1657
|
var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
1243
|
-
def.pattern ?? (def.pattern = date
|
|
1658
|
+
def.pattern ?? (def.pattern = date);
|
|
1244
1659
|
$ZodStringFormat.init(inst, def);
|
|
1245
1660
|
});
|
|
1246
1661
|
var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
1247
|
-
def.pattern ?? (def.pattern = time
|
|
1662
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1248
1663
|
$ZodStringFormat.init(inst, def);
|
|
1249
1664
|
});
|
|
1250
1665
|
var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
1251
|
-
def.pattern ?? (def.pattern = duration
|
|
1666
|
+
def.pattern ?? (def.pattern = duration);
|
|
1252
1667
|
$ZodStringFormat.init(inst, def);
|
|
1253
1668
|
});
|
|
1254
1669
|
var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
1255
1670
|
def.pattern ?? (def.pattern = ipv4);
|
|
1256
1671
|
$ZodStringFormat.init(inst, def);
|
|
1257
|
-
inst._zod.bag.format = `ipv4`;
|
|
1258
1672
|
});
|
|
1673
|
+
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
1674
|
+
var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1675
|
+
function isValidIPv6(value) {
|
|
1676
|
+
if (!ipv6Alphabet.test(value)) return false;
|
|
1677
|
+
return canParseURL(`http://[${value}]`);
|
|
1678
|
+
}
|
|
1259
1679
|
var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
1260
1680
|
def.pattern ?? (def.pattern = ipv6);
|
|
1261
1681
|
$ZodStringFormat.init(inst, def);
|
|
1262
|
-
inst._zod.bag.format = `ipv6`;
|
|
1263
1682
|
inst._zod.check = (payload) => {
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
payload.
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
inst,
|
|
1272
|
-
continue: !def.abort
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1683
|
+
if (!isValidIPv6(payload.value)) payload.issues.push({
|
|
1684
|
+
code: "invalid_format",
|
|
1685
|
+
format: "ipv6",
|
|
1686
|
+
input: payload.value,
|
|
1687
|
+
inst,
|
|
1688
|
+
continue: !def.abort
|
|
1689
|
+
});
|
|
1275
1690
|
};
|
|
1276
1691
|
});
|
|
1277
1692
|
var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1278
1693
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1279
1694
|
$ZodStringFormat.init(inst, def);
|
|
1280
1695
|
});
|
|
1696
|
+
function isValidCIDRv6(value) {
|
|
1697
|
+
const parts = value.split("/");
|
|
1698
|
+
if (parts.length !== 2) return false;
|
|
1699
|
+
const [address, prefix] = parts;
|
|
1700
|
+
if (!prefix) return false;
|
|
1701
|
+
const prefixNum = Number(prefix);
|
|
1702
|
+
if (`${prefixNum}` !== prefix) return false;
|
|
1703
|
+
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
1704
|
+
return isValidIPv6(address);
|
|
1705
|
+
}
|
|
1281
1706
|
var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1282
1707
|
def.pattern ?? (def.pattern = cidrv6);
|
|
1283
1708
|
$ZodStringFormat.init(inst, def);
|
|
1284
1709
|
inst._zod.check = (payload) => {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1293
|
-
new URL(`http://[${address}]`);
|
|
1294
|
-
} catch {
|
|
1295
|
-
payload.issues.push({
|
|
1296
|
-
code: "invalid_format",
|
|
1297
|
-
format: "cidrv6",
|
|
1298
|
-
input: payload.value,
|
|
1299
|
-
inst,
|
|
1300
|
-
continue: !def.abort
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1710
|
+
if (!isValidCIDRv6(payload.value)) payload.issues.push({
|
|
1711
|
+
code: "invalid_format",
|
|
1712
|
+
format: "cidrv6",
|
|
1713
|
+
input: payload.value,
|
|
1714
|
+
inst,
|
|
1715
|
+
continue: !def.abort
|
|
1716
|
+
});
|
|
1303
1717
|
};
|
|
1304
1718
|
});
|
|
1305
1719
|
function isValidBase64(data) {
|
|
@@ -1313,10 +1727,10 @@ function isValidBase64(data) {
|
|
|
1313
1727
|
return false;
|
|
1314
1728
|
}
|
|
1315
1729
|
}
|
|
1730
|
+
var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1316
1731
|
var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
1317
|
-
def.pattern ?? (def.pattern =
|
|
1732
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1318
1733
|
$ZodStringFormat.init(inst, def);
|
|
1319
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1320
1734
|
inst._zod.check = (payload) => {
|
|
1321
1735
|
if (isValidBase64(payload.value)) return;
|
|
1322
1736
|
payload.issues.push({
|
|
@@ -1328,15 +1742,15 @@ var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1328
1742
|
});
|
|
1329
1743
|
};
|
|
1330
1744
|
});
|
|
1745
|
+
var base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1331
1746
|
function isValidBase64URL(data) {
|
|
1332
|
-
if (!
|
|
1747
|
+
if (!base64urlCharset.test(data)) return false;
|
|
1333
1748
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1334
1749
|
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
1335
1750
|
}
|
|
1336
1751
|
var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1337
|
-
def.pattern ?? (def.pattern =
|
|
1752
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1338
1753
|
$ZodStringFormat.init(inst, def);
|
|
1339
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1340
1754
|
inst._zod.check = (payload) => {
|
|
1341
1755
|
if (isValidBase64URL(payload.value)) return;
|
|
1342
1756
|
payload.issues.push({
|
|
@@ -1382,14 +1796,14 @@ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1382
1796
|
});
|
|
1383
1797
|
var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
1384
1798
|
$ZodType.init(inst, def);
|
|
1385
|
-
inst._zod.pattern =
|
|
1799
|
+
inst._zod.pattern = number$1;
|
|
1386
1800
|
inst._zod.parse = (payload, _ctx) => {
|
|
1387
1801
|
if (def.coerce) try {
|
|
1388
1802
|
payload.value = Number(payload.value);
|
|
1389
1803
|
} catch (_) {}
|
|
1390
1804
|
const input = payload.value;
|
|
1391
1805
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1392
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ?
|
|
1806
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
|
|
1393
1807
|
payload.issues.push({
|
|
1394
1808
|
expected: "number",
|
|
1395
1809
|
code: "invalid_type",
|
|
@@ -1444,6 +1858,8 @@ function handleArrayResult(result, final, index) {
|
|
|
1444
1858
|
}
|
|
1445
1859
|
var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
1446
1860
|
$ZodType.init(inst, def);
|
|
1861
|
+
const memo = globalConfig.memoizer;
|
|
1862
|
+
memo?.attach(inst);
|
|
1447
1863
|
inst._zod.parse = (payload, ctx) => {
|
|
1448
1864
|
const input = payload.value;
|
|
1449
1865
|
if (!Array.isArray(input)) {
|
|
@@ -1455,8 +1871,9 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1455
1871
|
});
|
|
1456
1872
|
return payload;
|
|
1457
1873
|
}
|
|
1458
|
-
payload.value = Array(input.length);
|
|
1874
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1459
1875
|
const proms = [];
|
|
1876
|
+
const abortEarly = ctx?.abortEarly;
|
|
1460
1877
|
for (let i = 0; i < input.length; i++) {
|
|
1461
1878
|
const item = input[i];
|
|
1462
1879
|
const result = def.element._zod.run({
|
|
@@ -1464,19 +1881,24 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1464
1881
|
issues: []
|
|
1465
1882
|
}, ctx);
|
|
1466
1883
|
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1467
|
-
else
|
|
1884
|
+
else {
|
|
1885
|
+
handleArrayResult(result, payload, i);
|
|
1886
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
|
|
1887
|
+
}
|
|
1468
1888
|
}
|
|
1469
1889
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1470
1890
|
return payload;
|
|
1471
1891
|
};
|
|
1472
1892
|
});
|
|
1473
|
-
function handlePropertyResult(result, final, key, input,
|
|
1893
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1474
1894
|
const isPresent = key in input;
|
|
1895
|
+
const isOptionalOut = optout === "optional";
|
|
1896
|
+
if (!isPresent && isOptionalOut && optin === "optional") return;
|
|
1475
1897
|
if (result.issues.length) {
|
|
1476
|
-
if (
|
|
1898
|
+
if (optin !== void 0 && isOptionalOut && !isPresent) return;
|
|
1477
1899
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1478
1900
|
}
|
|
1479
|
-
if (!isPresent &&
|
|
1901
|
+
if (!isPresent && optin === void 0) {
|
|
1480
1902
|
if (!result.issues.length) final.issues.push({
|
|
1481
1903
|
code: "invalid_type",
|
|
1482
1904
|
expected: "nonoptional",
|
|
@@ -1486,31 +1908,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
1486
1908
|
return;
|
|
1487
1909
|
}
|
|
1488
1910
|
if (result.value === void 0) {
|
|
1489
|
-
if (isPresent) final.value[key] = void 0;
|
|
1911
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
|
|
1490
1912
|
} else final.value[key] = result.value;
|
|
1491
1913
|
}
|
|
1914
|
+
var NO_SYMBOL_KEYS = [];
|
|
1492
1915
|
function normalizeDef(def) {
|
|
1493
1916
|
const keys = Object.keys(def.shape);
|
|
1494
|
-
|
|
1917
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
1918
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
1919
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
1920
|
+
for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
1495
1921
|
const okeys = optionalKeys(def.shape);
|
|
1496
1922
|
return {
|
|
1497
1923
|
...def,
|
|
1498
|
-
|
|
1924
|
+
allKeys,
|
|
1925
|
+
symbolKeys,
|
|
1499
1926
|
keySet: new Set(keys),
|
|
1500
1927
|
numKeys: keys.length,
|
|
1501
1928
|
optionalKeys: new Set(okeys)
|
|
1502
1929
|
};
|
|
1503
1930
|
}
|
|
1504
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1931
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1505
1932
|
const unrecognized = [];
|
|
1506
1933
|
const keySet = def.keySet;
|
|
1507
1934
|
const _catchall = def.catchall._zod;
|
|
1508
1935
|
const t = _catchall.def.type;
|
|
1509
|
-
const
|
|
1510
|
-
const
|
|
1936
|
+
const optin = _catchall.optin;
|
|
1937
|
+
const optout = _catchall.optout;
|
|
1938
|
+
let seen = 0;
|
|
1511
1939
|
for (const key in input) {
|
|
1512
|
-
if (
|
|
1940
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1941
|
+
if (aborted(payload, seen)) break;
|
|
1942
|
+
seen = payload.issues.length;
|
|
1943
|
+
}
|
|
1513
1944
|
if (keySet.has(key)) continue;
|
|
1945
|
+
if (key === "__proto__") {
|
|
1946
|
+
if (t === "never") unrecognized.push(key);
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1514
1949
|
if (t === "never") {
|
|
1515
1950
|
unrecognized.push(key);
|
|
1516
1951
|
continue;
|
|
@@ -1519,14 +1954,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1519
1954
|
value: input[key],
|
|
1520
1955
|
issues: []
|
|
1521
1956
|
}, ctx);
|
|
1522
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1523
|
-
else handlePropertyResult(r, payload, key, input,
|
|
1957
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1958
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1524
1959
|
}
|
|
1525
1960
|
if (unrecognized.length) payload.issues.push({
|
|
1526
1961
|
code: "unrecognized_keys",
|
|
1527
1962
|
keys: unrecognized,
|
|
1528
1963
|
input,
|
|
1529
|
-
inst
|
|
1964
|
+
inst,
|
|
1965
|
+
continue: true
|
|
1530
1966
|
});
|
|
1531
1967
|
if (!proms.length) return payload;
|
|
1532
1968
|
return Promise.all(proms).then(() => {
|
|
@@ -1535,34 +1971,41 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1535
1971
|
}
|
|
1536
1972
|
var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
1537
1973
|
$ZodType.init(inst, def);
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1974
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1975
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
1976
|
+
if (sh) {
|
|
1977
|
+
const get = () => {
|
|
1541
1978
|
const newSh = { ...sh };
|
|
1542
1979
|
Object.defineProperty(def, "shape", { value: newSh });
|
|
1980
|
+
get.raw = newSh;
|
|
1543
1981
|
return newSh;
|
|
1544
|
-
}
|
|
1982
|
+
};
|
|
1983
|
+
get.raw = sh;
|
|
1984
|
+
Object.defineProperty(def, "shape", { get });
|
|
1545
1985
|
}
|
|
1546
1986
|
const _normalized = cached(() => normalizeDef(def));
|
|
1547
|
-
|
|
1548
|
-
const shape = def.shape;
|
|
1987
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
1988
|
+
const shape = zod.def.shape;
|
|
1549
1989
|
const propValues = {};
|
|
1550
1990
|
for (const key in shape) {
|
|
1551
1991
|
const field = shape[key]._zod;
|
|
1552
1992
|
if (field.values) {
|
|
1553
|
-
propValues
|
|
1993
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
|
|
1554
1994
|
for (const v of field.values) propValues[key].add(v);
|
|
1995
|
+
if (field.optin !== void 0) propValues[key].add(void 0);
|
|
1555
1996
|
}
|
|
1556
1997
|
}
|
|
1557
1998
|
return propValues;
|
|
1558
1999
|
});
|
|
1559
|
-
const isObject$
|
|
2000
|
+
const isObject$2 = isObject;
|
|
1560
2001
|
const catchall = def.catchall;
|
|
1561
2002
|
let value;
|
|
2003
|
+
const memo = globalConfig.memoizer;
|
|
2004
|
+
memo?.attach(inst);
|
|
1562
2005
|
inst._zod.parse = (payload, ctx) => {
|
|
1563
2006
|
value ?? (value = _normalized.value);
|
|
1564
2007
|
const input = payload.value;
|
|
1565
|
-
if (!isObject$
|
|
2008
|
+
if (!isObject$2(input)) {
|
|
1566
2009
|
payload.issues.push({
|
|
1567
2010
|
expected: "object",
|
|
1568
2011
|
code: "invalid_type",
|
|
@@ -1571,77 +2014,90 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1571
2014
|
});
|
|
1572
2015
|
return payload;
|
|
1573
2016
|
}
|
|
1574
|
-
payload.value = {};
|
|
2017
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1575
2018
|
const proms = [];
|
|
1576
2019
|
const shape = value.shape;
|
|
1577
|
-
|
|
2020
|
+
const abortEarly = ctx?.abortEarly;
|
|
2021
|
+
let seen = payload.issues.length;
|
|
2022
|
+
for (const key of value.allKeys) {
|
|
2023
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2024
|
+
if (aborted(payload, seen)) break;
|
|
2025
|
+
seen = payload.issues.length;
|
|
2026
|
+
}
|
|
2027
|
+
if (key === "__proto__") continue;
|
|
1578
2028
|
const el = shape[key];
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
2029
|
+
const optin = el._zod.optin;
|
|
2030
|
+
const optout = el._zod.optout;
|
|
1581
2031
|
const r = el._zod.run({
|
|
1582
2032
|
value: input[key],
|
|
1583
2033
|
issues: []
|
|
1584
2034
|
}, ctx);
|
|
1585
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1586
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2035
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2036
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1587
2037
|
}
|
|
1588
2038
|
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1589
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2039
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1590
2040
|
};
|
|
1591
2041
|
});
|
|
1592
2042
|
var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1593
2043
|
$ZodObject.init(inst, def);
|
|
1594
2044
|
const superParse = inst._zod.parse;
|
|
1595
2045
|
const _normalized = cached(() => normalizeDef(def));
|
|
2046
|
+
const memo = globalConfig.memoizer;
|
|
1596
2047
|
const generateFastpass = (shape) => {
|
|
1597
|
-
const doc = new Doc([
|
|
1598
|
-
"shape",
|
|
1599
|
-
"payload",
|
|
1600
|
-
"ctx"
|
|
1601
|
-
]);
|
|
1602
2048
|
const normalized = _normalized.value;
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
2049
|
+
const syms = normalized.symbolKeys;
|
|
2050
|
+
const doc = new Doc(["payload", "ctx"], {
|
|
2051
|
+
shape,
|
|
2052
|
+
inst,
|
|
2053
|
+
memo,
|
|
2054
|
+
syms
|
|
2055
|
+
});
|
|
2056
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2057
|
+
const prefixStr = (id, k) => `
|
|
2058
|
+
let ${id}_ab = false;
|
|
2059
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2060
|
+
const iss = ${id}.issues[i];
|
|
2061
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2062
|
+
payload.issues.push(iss);
|
|
2063
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2064
|
+
}
|
|
2065
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2066
|
+
payload.value = newResult;
|
|
2067
|
+
return payload;
|
|
2068
|
+
}`;
|
|
1607
2069
|
doc.write(`const input = payload.value;`);
|
|
1608
2070
|
const ids = Object.create(null);
|
|
1609
2071
|
let counter = 0;
|
|
1610
|
-
for (const key of normalized.
|
|
1611
|
-
doc.write(`const newResult = {};`);
|
|
1612
|
-
for (const key of normalized.
|
|
2072
|
+
for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
|
|
2073
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2074
|
+
for (const key of normalized.allKeys) {
|
|
2075
|
+
if (key === "__proto__") continue;
|
|
1613
2076
|
const id = ids[key];
|
|
1614
|
-
const k = esc(key);
|
|
2077
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2078
|
+
const isPresent = `${k} in input`;
|
|
1615
2079
|
const schema = shape[key];
|
|
1616
|
-
const
|
|
2080
|
+
const optin = schema?._zod?.optin;
|
|
2081
|
+
const isOptionalIn = optin !== void 0;
|
|
1617
2082
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1618
|
-
doc.write(`const ${id} = ${parseStr(
|
|
1619
|
-
if (isOptionalIn && isOptionalOut)
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
})));
|
|
2083
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
2084
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2085
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
2086
|
+
doc.write(`
|
|
2087
|
+
const ${id}_present = ${isPresent};
|
|
2088
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2089
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1626
2090
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
if (${k} in input) {
|
|
1631
|
-
newResult[${k}] = undefined;
|
|
2091
|
+
|
|
2092
|
+
if (${assign}) {
|
|
2093
|
+
newResult[${k}] = ${id}.value;
|
|
1632
2094
|
}
|
|
1633
|
-
} else {
|
|
1634
|
-
newResult[${k}] = ${id}.value;
|
|
1635
2095
|
}
|
|
1636
|
-
|
|
2096
|
+
|
|
1637
2097
|
`);
|
|
1638
|
-
else if (!isOptionalIn) doc.write(`
|
|
1639
|
-
const ${id}_present = ${
|
|
1640
|
-
if (${id}.issues.length) {
|
|
1641
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1642
|
-
...iss,
|
|
1643
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1644
|
-
})));
|
|
2098
|
+
} else if (!isOptionalIn) doc.write(`
|
|
2099
|
+
const ${id}_present = ${isPresent};
|
|
2100
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1645
2101
|
}
|
|
1646
2102
|
if (!${id}_present && !${id}.issues.length) {
|
|
1647
2103
|
payload.issues.push({
|
|
@@ -1650,42 +2106,36 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
1650
2106
|
input: undefined,
|
|
1651
2107
|
path: [${k}]
|
|
1652
2108
|
});
|
|
2109
|
+
if (ctx && ctx.abortEarly) {
|
|
2110
|
+
payload.value = newResult;
|
|
2111
|
+
return payload;
|
|
2112
|
+
}
|
|
1653
2113
|
}
|
|
1654
2114
|
|
|
1655
2115
|
if (${id}_present) {
|
|
1656
|
-
|
|
1657
|
-
newResult[${k}] = undefined;
|
|
1658
|
-
} else {
|
|
1659
|
-
newResult[${k}] = ${id}.value;
|
|
1660
|
-
}
|
|
2116
|
+
newResult[${k}] = ${id}.value;
|
|
1661
2117
|
}
|
|
1662
2118
|
|
|
1663
2119
|
`);
|
|
1664
|
-
else
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
...iss,
|
|
1668
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1669
|
-
})));
|
|
2120
|
+
else {
|
|
2121
|
+
doc.write(`
|
|
2122
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1670
2123
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
}
|
|
1676
|
-
} else {
|
|
2124
|
+
`);
|
|
2125
|
+
if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2126
|
+
else doc.write(`
|
|
2127
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1677
2128
|
newResult[${k}] = ${id}.value;
|
|
1678
2129
|
}
|
|
1679
|
-
|
|
1680
2130
|
`);
|
|
2131
|
+
}
|
|
1681
2132
|
}
|
|
1682
2133
|
doc.write(`payload.value = newResult;`);
|
|
1683
2134
|
doc.write(`return payload;`);
|
|
1684
|
-
|
|
1685
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2135
|
+
return doc.compile();
|
|
1686
2136
|
};
|
|
1687
2137
|
let fastpass;
|
|
1688
|
-
const isObject$
|
|
2138
|
+
const isObject$1 = isObject;
|
|
1689
2139
|
const jit = !globalConfig.jitless;
|
|
1690
2140
|
const fastEnabled = jit && allowsEval.value;
|
|
1691
2141
|
const catchall = def.catchall;
|
|
@@ -1693,7 +2143,7 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
1693
2143
|
inst._zod.parse = (payload, ctx) => {
|
|
1694
2144
|
value ?? (value = _normalized.value);
|
|
1695
2145
|
const input = payload.value;
|
|
1696
|
-
if (!isObject$
|
|
2146
|
+
if (!isObject$1(input)) {
|
|
1697
2147
|
payload.issues.push({
|
|
1698
2148
|
expected: "object",
|
|
1699
2149
|
code: "invalid_type",
|
|
@@ -1706,7 +2156,7 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
1706
2156
|
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1707
2157
|
payload = fastpass(payload, ctx);
|
|
1708
2158
|
if (!catchall) return payload;
|
|
1709
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2159
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
1710
2160
|
}
|
|
1711
2161
|
return superParse(payload, ctx);
|
|
1712
2162
|
};
|
|
@@ -1731,14 +2181,14 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1731
2181
|
}
|
|
1732
2182
|
var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
1733
2183
|
$ZodType.init(inst, def);
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2184
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== void 0) ? "optional" : void 0);
|
|
2185
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2186
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2187
|
+
if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1738
2188
|
});
|
|
1739
|
-
|
|
1740
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1741
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2189
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2190
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2191
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
1742
2192
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1743
2193
|
}
|
|
1744
2194
|
});
|
|
@@ -1800,7 +2250,9 @@ function mergeValues(a, b) {
|
|
|
1800
2250
|
...a,
|
|
1801
2251
|
...b
|
|
1802
2252
|
};
|
|
2253
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
1803
2254
|
for (const key of sharedKeys) {
|
|
2255
|
+
if (key === "__proto__") continue;
|
|
1804
2256
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1805
2257
|
if (!sharedValue.valid) return {
|
|
1806
2258
|
valid: false,
|
|
@@ -1842,31 +2294,46 @@ function mergeValues(a, b) {
|
|
|
1842
2294
|
function handleIntersectionResults(result, left, right) {
|
|
1843
2295
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1844
2296
|
let unrecIssue;
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
2297
|
+
const keyIssues = /* @__PURE__ */ new Map();
|
|
2298
|
+
const collect = (iss, side) => {
|
|
2299
|
+
let keys;
|
|
2300
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2301
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2302
|
+
keys = iss.keys;
|
|
2303
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2304
|
+
const k = String(iss.path[0]);
|
|
2305
|
+
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
2306
|
+
keys = [k];
|
|
2307
|
+
} else return false;
|
|
2308
|
+
for (const k of keys) {
|
|
1848
2309
|
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1849
|
-
unrecKeys.get(k)
|
|
2310
|
+
unrecKeys.get(k)[side] = true;
|
|
1850
2311
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
}
|
|
1856
|
-
else result.issues.push(iss);
|
|
2312
|
+
return true;
|
|
2313
|
+
};
|
|
2314
|
+
for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
|
|
2315
|
+
for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
|
|
1857
2316
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1858
|
-
if (bothKeys.length
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
2317
|
+
if (bothKeys.length) {
|
|
2318
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2319
|
+
if (aggregated.length) result.issues.push({
|
|
2320
|
+
...unrecIssue,
|
|
2321
|
+
keys: aggregated
|
|
2322
|
+
});
|
|
2323
|
+
for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
|
|
2324
|
+
}
|
|
1863
2325
|
const merged = mergeValues(left.value, right.value);
|
|
1864
|
-
if (!merged.valid)
|
|
2326
|
+
if (!merged.valid) {
|
|
2327
|
+
if (aborted(result)) return result;
|
|
2328
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2329
|
+
}
|
|
1865
2330
|
result.value = merged.data;
|
|
1866
2331
|
return result;
|
|
1867
2332
|
}
|
|
1868
2333
|
var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
1869
2334
|
$ZodType.init(inst, def);
|
|
2335
|
+
const memo = globalConfig.memoizer;
|
|
2336
|
+
memo?.attach(inst);
|
|
1870
2337
|
inst._zod.parse = (payload, ctx) => {
|
|
1871
2338
|
const input = payload.value;
|
|
1872
2339
|
if (!isPlainObject(input)) {
|
|
@@ -1880,11 +2347,12 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1880
2347
|
}
|
|
1881
2348
|
const proms = [];
|
|
1882
2349
|
const values = def.keyType._zod.values;
|
|
1883
|
-
if (values) {
|
|
1884
|
-
payload.value = {};
|
|
2350
|
+
if (values && !def.partial) {
|
|
2351
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1885
2352
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
1886
2353
|
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1887
2354
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2355
|
+
if (key === "__proto__") continue;
|
|
1888
2356
|
const keyResult = def.keyType._zod.run({
|
|
1889
2357
|
value: key,
|
|
1890
2358
|
issues: []
|
|
@@ -1902,6 +2370,7 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1902
2370
|
continue;
|
|
1903
2371
|
}
|
|
1904
2372
|
const outKey = keyResult.value;
|
|
2373
|
+
if (outKey === "__proto__") continue;
|
|
1905
2374
|
const result = def.valueType._zod.run({
|
|
1906
2375
|
value: input[key],
|
|
1907
2376
|
issues: []
|
|
@@ -1917,17 +2386,24 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1917
2386
|
}
|
|
1918
2387
|
let unrecognized;
|
|
1919
2388
|
for (const key in input) if (!recordKeys.has(key)) {
|
|
1920
|
-
|
|
1921
|
-
|
|
2389
|
+
if (def.mode === "loose") {
|
|
2390
|
+
if (key === "__proto__") continue;
|
|
2391
|
+
payload.value[key] = input[key];
|
|
2392
|
+
} else {
|
|
2393
|
+
unrecognized = unrecognized ?? [];
|
|
2394
|
+
unrecognized.push(key);
|
|
2395
|
+
}
|
|
1922
2396
|
}
|
|
1923
2397
|
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
1924
2398
|
code: "unrecognized_keys",
|
|
1925
2399
|
input,
|
|
1926
2400
|
inst,
|
|
1927
|
-
keys: unrecognized
|
|
2401
|
+
keys: unrecognized,
|
|
2402
|
+
continue: true
|
|
1928
2403
|
});
|
|
1929
2404
|
} else {
|
|
1930
|
-
payload.value = {};
|
|
2405
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2406
|
+
let unrecognized;
|
|
1931
2407
|
for (const key of Reflect.ownKeys(input)) {
|
|
1932
2408
|
if (key === "__proto__") continue;
|
|
1933
2409
|
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
@@ -1946,7 +2422,10 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1946
2422
|
}
|
|
1947
2423
|
if (keyResult.issues.length) {
|
|
1948
2424
|
if (def.mode === "loose") payload.value[key] = input[key];
|
|
1949
|
-
else
|
|
2425
|
+
else if (values) {
|
|
2426
|
+
unrecognized = unrecognized ?? [];
|
|
2427
|
+
unrecognized.push(key);
|
|
2428
|
+
} else payload.issues.push({
|
|
1950
2429
|
code: "invalid_key",
|
|
1951
2430
|
origin: "record",
|
|
1952
2431
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
@@ -1956,19 +2435,28 @@ var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1956
2435
|
});
|
|
1957
2436
|
continue;
|
|
1958
2437
|
}
|
|
2438
|
+
const outKey = keyResult.value;
|
|
2439
|
+
if (outKey === "__proto__") continue;
|
|
1959
2440
|
const result = def.valueType._zod.run({
|
|
1960
2441
|
value: input[key],
|
|
1961
2442
|
issues: []
|
|
1962
2443
|
}, ctx);
|
|
1963
2444
|
if (result instanceof Promise) proms.push(result.then((result) => {
|
|
1964
2445
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1965
|
-
payload.value[
|
|
2446
|
+
payload.value[outKey] = result.value;
|
|
1966
2447
|
}));
|
|
1967
2448
|
else {
|
|
1968
2449
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1969
|
-
payload.value[
|
|
2450
|
+
payload.value[outKey] = result.value;
|
|
1970
2451
|
}
|
|
1971
2452
|
}
|
|
2453
|
+
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
2454
|
+
code: "unrecognized_keys",
|
|
2455
|
+
input,
|
|
2456
|
+
inst,
|
|
2457
|
+
keys: unrecognized,
|
|
2458
|
+
continue: true
|
|
2459
|
+
});
|
|
1972
2460
|
}
|
|
1973
2461
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1974
2462
|
return payload;
|
|
@@ -1979,7 +2467,10 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1979
2467
|
const values = getEnumValues(def.entries);
|
|
1980
2468
|
const valuesSet = new Set(values);
|
|
1981
2469
|
inst._zod.values = valuesSet;
|
|
1982
|
-
inst
|
|
2470
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2471
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2472
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2473
|
+
});
|
|
1983
2474
|
inst._zod.parse = (payload, _ctx) => {
|
|
1984
2475
|
const input = payload.value;
|
|
1985
2476
|
if (valuesSet.has(input)) return payload;
|
|
@@ -1994,10 +2485,12 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1994
2485
|
});
|
|
1995
2486
|
var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
1996
2487
|
$ZodType.init(inst, def);
|
|
1997
|
-
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
|
|
1998
2488
|
const values = new Set(def.values);
|
|
1999
2489
|
inst._zod.values = values;
|
|
2000
|
-
inst
|
|
2490
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2491
|
+
const vals = zod.def.values;
|
|
2492
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
2493
|
+
});
|
|
2001
2494
|
inst._zod.parse = (payload, _ctx) => {
|
|
2002
2495
|
const input = payload.value;
|
|
2003
2496
|
if (values.has(input)) return payload;
|
|
@@ -2013,67 +2506,66 @@ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
2013
2506
|
var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
2014
2507
|
$ZodType.init(inst, def);
|
|
2015
2508
|
inst._zod.optin = "optional";
|
|
2509
|
+
globalConfig.memoizer?.guard(inst);
|
|
2016
2510
|
inst._zod.parse = (payload, ctx) => {
|
|
2017
2511
|
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
2018
2512
|
const _out = def.transform(payload.value, payload);
|
|
2019
2513
|
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
2020
2514
|
payload.value = output;
|
|
2021
|
-
payload.fallback = true;
|
|
2022
2515
|
return payload;
|
|
2023
2516
|
});
|
|
2024
2517
|
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2025
2518
|
payload.value = _out;
|
|
2026
|
-
payload.fallback = true;
|
|
2027
2519
|
return payload;
|
|
2028
2520
|
};
|
|
2029
2521
|
});
|
|
2030
|
-
function handleOptionalResult(
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
value: void 0
|
|
2034
|
-
};
|
|
2035
|
-
return result;
|
|
2522
|
+
function handleOptionalResult(payload, result) {
|
|
2523
|
+
payload.value = result.issues.length ? void 0 : result.value;
|
|
2524
|
+
return payload;
|
|
2036
2525
|
}
|
|
2037
2526
|
var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
2038
2527
|
$ZodType.init(inst, def);
|
|
2039
|
-
inst._zod.optin
|
|
2528
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2040
2529
|
inst._zod.optout = "optional";
|
|
2041
|
-
|
|
2042
|
-
|
|
2530
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2531
|
+
const values = zod.def.innerType._zod.values;
|
|
2532
|
+
return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
|
|
2043
2533
|
});
|
|
2044
|
-
|
|
2045
|
-
const pattern = def.innerType._zod.pattern;
|
|
2534
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2535
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2046
2536
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2047
2537
|
});
|
|
2048
2538
|
inst._zod.parse = (payload, ctx) => {
|
|
2049
|
-
if (
|
|
2050
|
-
|
|
2051
|
-
const result = def.innerType._zod.run(
|
|
2052
|
-
|
|
2053
|
-
|
|
2539
|
+
if (payload.value === void 0) {
|
|
2540
|
+
if (def.innerType._zod.optin !== "defaulted") return payload;
|
|
2541
|
+
const result = def.innerType._zod.run({
|
|
2542
|
+
value: payload.value,
|
|
2543
|
+
issues: []
|
|
2544
|
+
}, ctx);
|
|
2545
|
+
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
2546
|
+
return handleOptionalResult(payload, result);
|
|
2054
2547
|
}
|
|
2055
|
-
if (payload.value === void 0) return payload;
|
|
2056
2548
|
return def.innerType._zod.run(payload, ctx);
|
|
2057
2549
|
};
|
|
2058
2550
|
});
|
|
2059
2551
|
var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2060
2552
|
$ZodOptional.init(inst, def);
|
|
2061
|
-
|
|
2062
|
-
|
|
2553
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2554
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2063
2555
|
inst._zod.parse = (payload, ctx) => {
|
|
2064
2556
|
return def.innerType._zod.run(payload, ctx);
|
|
2065
2557
|
};
|
|
2066
2558
|
});
|
|
2067
2559
|
var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
2068
2560
|
$ZodType.init(inst, def);
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const pattern = def.innerType._zod.pattern;
|
|
2561
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2562
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2563
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2564
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2073
2565
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2074
2566
|
});
|
|
2075
|
-
|
|
2076
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2567
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2568
|
+
return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
|
|
2077
2569
|
});
|
|
2078
2570
|
inst._zod.parse = (payload, ctx) => {
|
|
2079
2571
|
if (payload.value === null) return payload;
|
|
@@ -2082,8 +2574,8 @@ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
|
2082
2574
|
});
|
|
2083
2575
|
var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
2084
2576
|
$ZodType.init(inst, def);
|
|
2085
|
-
inst._zod.optin = "
|
|
2086
|
-
|
|
2577
|
+
inst._zod.optin = "defaulted";
|
|
2578
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2087
2579
|
inst._zod.parse = (payload, ctx) => {
|
|
2088
2580
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2089
2581
|
if (payload.value === void 0) {
|
|
@@ -2104,8 +2596,8 @@ function handleDefaultResult(payload, def) {
|
|
|
2104
2596
|
}
|
|
2105
2597
|
var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
2106
2598
|
$ZodType.init(inst, def);
|
|
2107
|
-
inst._zod.optin = "
|
|
2108
|
-
|
|
2599
|
+
inst._zod.optin = "defaulted";
|
|
2600
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2109
2601
|
inst._zod.parse = (payload, ctx) => {
|
|
2110
2602
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2111
2603
|
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
@@ -2114,8 +2606,8 @@ var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
2114
2606
|
});
|
|
2115
2607
|
var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2116
2608
|
$ZodType.init(inst, def);
|
|
2117
|
-
|
|
2118
|
-
const v = def.innerType._zod.values;
|
|
2609
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2610
|
+
const v = zod.def.innerType._zod.values;
|
|
2119
2611
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2120
2612
|
});
|
|
2121
2613
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2133,46 +2625,41 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2133
2625
|
});
|
|
2134
2626
|
return payload;
|
|
2135
2627
|
}
|
|
2628
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2629
|
+
if (!result.issues.length) {
|
|
2630
|
+
payload.value = result.value;
|
|
2631
|
+
if (result.memo) payload.memo = true;
|
|
2632
|
+
return payload;
|
|
2633
|
+
}
|
|
2634
|
+
payload.value = def.catchValue({
|
|
2635
|
+
...result,
|
|
2636
|
+
value: payload.value,
|
|
2637
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2638
|
+
input: payload.value
|
|
2639
|
+
});
|
|
2640
|
+
return payload;
|
|
2641
|
+
}
|
|
2136
2642
|
var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
2137
2643
|
$ZodType.init(inst, def);
|
|
2138
|
-
inst._zod.optin
|
|
2139
|
-
|
|
2140
|
-
|
|
2644
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2645
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2646
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2141
2647
|
inst._zod.parse = (payload, ctx) => {
|
|
2142
2648
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2143
|
-
const result = def.innerType._zod.run(
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2150
|
-
input: payload.value
|
|
2151
|
-
});
|
|
2152
|
-
payload.issues = [];
|
|
2153
|
-
payload.fallback = true;
|
|
2154
|
-
}
|
|
2155
|
-
return payload;
|
|
2156
|
-
});
|
|
2157
|
-
payload.value = result.value;
|
|
2158
|
-
if (result.issues.length) {
|
|
2159
|
-
payload.value = def.catchValue({
|
|
2160
|
-
...payload,
|
|
2161
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2162
|
-
input: payload.value
|
|
2163
|
-
});
|
|
2164
|
-
payload.issues = [];
|
|
2165
|
-
payload.fallback = true;
|
|
2166
|
-
}
|
|
2167
|
-
return payload;
|
|
2649
|
+
const result = def.innerType._zod.run({
|
|
2650
|
+
value: payload.value,
|
|
2651
|
+
issues: []
|
|
2652
|
+
}, ctx);
|
|
2653
|
+
if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
2654
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2168
2655
|
};
|
|
2169
2656
|
});
|
|
2170
2657
|
var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
2171
2658
|
$ZodType.init(inst, def);
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2659
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2660
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2661
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2662
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2176
2663
|
inst._zod.parse = (payload, ctx) => {
|
|
2177
2664
|
if (ctx.direction === "backward") {
|
|
2178
2665
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -2185,22 +2672,21 @@ var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2185
2672
|
};
|
|
2186
2673
|
});
|
|
2187
2674
|
function handlePipeResult(left, next, ctx) {
|
|
2188
|
-
if (left.issues.
|
|
2675
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2189
2676
|
left.aborted = true;
|
|
2190
2677
|
return left;
|
|
2191
2678
|
}
|
|
2192
2679
|
return next._zod.run({
|
|
2193
2680
|
value: left.value,
|
|
2194
|
-
issues: left.issues
|
|
2195
|
-
fallback: left.fallback
|
|
2681
|
+
issues: left.issues
|
|
2196
2682
|
}, ctx);
|
|
2197
2683
|
}
|
|
2198
2684
|
var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
2199
2685
|
$ZodType.init(inst, def);
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2686
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2687
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2688
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2689
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2204
2690
|
inst._zod.parse = (payload, ctx) => {
|
|
2205
2691
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2206
2692
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -2209,7 +2695,7 @@ var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
|
2209
2695
|
};
|
|
2210
2696
|
});
|
|
2211
2697
|
function handleReadonlyResult(payload) {
|
|
2212
|
-
payload.value = Object.freeze(payload.value);
|
|
2698
|
+
if (!payload.memo) payload.value = Object.freeze(payload.value);
|
|
2213
2699
|
return payload;
|
|
2214
2700
|
}
|
|
2215
2701
|
var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -2239,6 +2725,367 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2239
2725
|
}
|
|
2240
2726
|
}
|
|
2241
2727
|
//#endregion
|
|
2728
|
+
//#region ../../node_modules/zod/v4/core/memoizer.js
|
|
2729
|
+
var $ZodCyclicError = class extends Error {
|
|
2730
|
+
constructor() {
|
|
2731
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2732
|
+
this.name = "ZodCyclicError";
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
/** Keyed off the context object every schema in one parse call already shares. */
|
|
2736
|
+
var STATE = "~memo";
|
|
2737
|
+
var NO_ISSUES = [];
|
|
2738
|
+
function isRef(value) {
|
|
2739
|
+
return value !== null && typeof value === "object";
|
|
2740
|
+
}
|
|
2741
|
+
function cloneIssues(issues) {
|
|
2742
|
+
return issues.map((iss) => iss.path ? {
|
|
2743
|
+
...iss,
|
|
2744
|
+
path: iss.path.slice()
|
|
2745
|
+
} : { ...iss });
|
|
2746
|
+
}
|
|
2747
|
+
var recursive = /*@__PURE__*/ new WeakMap();
|
|
2748
|
+
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
|
|
2749
|
+
var NONE = 0;
|
|
2750
|
+
var ASSUMED = 1;
|
|
2751
|
+
var PROVEN = 2;
|
|
2752
|
+
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
|
|
2753
|
+
function isRecursive(inst, stack, resolve) {
|
|
2754
|
+
const cached = recursive.get(inst);
|
|
2755
|
+
if (cached !== void 0) return cached ? PROVEN : NONE;
|
|
2756
|
+
if (stack.has(inst)) return PROVEN;
|
|
2757
|
+
stack.add(inst);
|
|
2758
|
+
let result = NONE;
|
|
2759
|
+
const check = (child) => {
|
|
2760
|
+
if (result !== PROVEN && child?._zod) {
|
|
2761
|
+
const answer = isRecursive(child, stack, resolve);
|
|
2762
|
+
if (answer > result) result = answer;
|
|
2763
|
+
}
|
|
2764
|
+
};
|
|
2765
|
+
const shape = (sh, spread) => {
|
|
2766
|
+
let answer = NONE;
|
|
2767
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
2768
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
2769
|
+
if (spread && !desc.enumerable) continue;
|
|
2770
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
2771
|
+
if (child > answer) answer = child;
|
|
2772
|
+
}
|
|
2773
|
+
return answer;
|
|
2774
|
+
};
|
|
2775
|
+
const merge = (answer) => {
|
|
2776
|
+
if (answer > result) result = answer;
|
|
2777
|
+
};
|
|
2778
|
+
const def = inst._zod.def;
|
|
2779
|
+
switch (def.type) {
|
|
2780
|
+
case "object": {
|
|
2781
|
+
const raw = rawShape(def);
|
|
2782
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
2783
|
+
check(def.catchall);
|
|
2784
|
+
break;
|
|
2785
|
+
}
|
|
2786
|
+
case "array":
|
|
2787
|
+
check(def.element);
|
|
2788
|
+
break;
|
|
2789
|
+
case "tuple":
|
|
2790
|
+
for (const el of def.items) check(el);
|
|
2791
|
+
check(def.rest);
|
|
2792
|
+
break;
|
|
2793
|
+
case "record":
|
|
2794
|
+
case "map":
|
|
2795
|
+
check(def.keyType);
|
|
2796
|
+
check(def.valueType);
|
|
2797
|
+
break;
|
|
2798
|
+
case "set":
|
|
2799
|
+
check(def.valueType);
|
|
2800
|
+
break;
|
|
2801
|
+
case "union":
|
|
2802
|
+
for (const el of def.options) check(el);
|
|
2803
|
+
break;
|
|
2804
|
+
case "intersection":
|
|
2805
|
+
check(def.left);
|
|
2806
|
+
check(def.right);
|
|
2807
|
+
break;
|
|
2808
|
+
case "optional":
|
|
2809
|
+
case "nullable":
|
|
2810
|
+
case "default":
|
|
2811
|
+
case "prefault":
|
|
2812
|
+
case "catch":
|
|
2813
|
+
case "readonly":
|
|
2814
|
+
case "nonoptional":
|
|
2815
|
+
case "promise":
|
|
2816
|
+
case "success":
|
|
2817
|
+
check(def.innerType);
|
|
2818
|
+
break;
|
|
2819
|
+
case "pipe":
|
|
2820
|
+
check(def.in);
|
|
2821
|
+
check(def.out);
|
|
2822
|
+
break;
|
|
2823
|
+
case "function":
|
|
2824
|
+
check(def.input);
|
|
2825
|
+
check(def.output);
|
|
2826
|
+
break;
|
|
2827
|
+
case "lazy": {
|
|
2828
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
2829
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
2830
|
+
break;
|
|
2831
|
+
}
|
|
2832
|
+
case "template_literal":
|
|
2833
|
+
case "string":
|
|
2834
|
+
case "number":
|
|
2835
|
+
case "int":
|
|
2836
|
+
case "boolean":
|
|
2837
|
+
case "bigint":
|
|
2838
|
+
case "symbol":
|
|
2839
|
+
case "undefined":
|
|
2840
|
+
case "null":
|
|
2841
|
+
case "void":
|
|
2842
|
+
case "never":
|
|
2843
|
+
case "any":
|
|
2844
|
+
case "unknown":
|
|
2845
|
+
case "date":
|
|
2846
|
+
case "nan":
|
|
2847
|
+
case "enum":
|
|
2848
|
+
case "literal":
|
|
2849
|
+
case "file":
|
|
2850
|
+
case "transform":
|
|
2851
|
+
case "custom": break;
|
|
2852
|
+
default: for (const key in def) {
|
|
2853
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
2854
|
+
if (!desc || desc.get) continue;
|
|
2855
|
+
const value = desc.value;
|
|
2856
|
+
if (!value || typeof value !== "object") continue;
|
|
2857
|
+
if (value._zod) check(value);
|
|
2858
|
+
else if (Array.isArray(value)) for (const el of value) check(el);
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
stack.delete(inst);
|
|
2862
|
+
return settle(inst, result);
|
|
2863
|
+
}
|
|
2864
|
+
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
|
|
2865
|
+
function settle(inst, answer) {
|
|
2866
|
+
if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
|
|
2867
|
+
return answer;
|
|
2868
|
+
}
|
|
2869
|
+
function bucketFor(state, inst) {
|
|
2870
|
+
let bucket = state.buckets.get(inst);
|
|
2871
|
+
if (!bucket) {
|
|
2872
|
+
bucket = /* @__PURE__ */ new WeakMap();
|
|
2873
|
+
state.buckets.set(inst, bucket);
|
|
2874
|
+
}
|
|
2875
|
+
return bucket;
|
|
2876
|
+
}
|
|
2877
|
+
var handoff;
|
|
2878
|
+
var open = [];
|
|
2879
|
+
var memo = {
|
|
2880
|
+
alloc(_inst, payload, empty) {
|
|
2881
|
+
const bucket = handoff;
|
|
2882
|
+
if (!bucket) return empty;
|
|
2883
|
+
handoff = void 0;
|
|
2884
|
+
const entry = {
|
|
2885
|
+
value: empty,
|
|
2886
|
+
issues: null
|
|
2887
|
+
};
|
|
2888
|
+
bucket.set(payload.value, entry);
|
|
2889
|
+
open.push(entry);
|
|
2890
|
+
return empty;
|
|
2891
|
+
},
|
|
2892
|
+
guard(inst) {
|
|
2893
|
+
var _a;
|
|
2894
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2895
|
+
inst._zod.deferred.push(() => {
|
|
2896
|
+
const base = inst._zod.parse;
|
|
2897
|
+
const wrapped = (payload, ctx) => {
|
|
2898
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
|
|
2899
|
+
return base(payload, ctx);
|
|
2900
|
+
};
|
|
2901
|
+
inst._zod.parse = wrapped;
|
|
2902
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2903
|
+
});
|
|
2904
|
+
},
|
|
2905
|
+
attach(inst) {
|
|
2906
|
+
var _a;
|
|
2907
|
+
let isRecursiveInst;
|
|
2908
|
+
let rechecked = false;
|
|
2909
|
+
let lastCtx;
|
|
2910
|
+
let lastBucket;
|
|
2911
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2912
|
+
inst._zod.deferred.push(() => {
|
|
2913
|
+
const base = inst._zod.parse;
|
|
2914
|
+
const wrapped = (payload, ctx) => {
|
|
2915
|
+
if (isRecursiveInst === void 0) {
|
|
2916
|
+
const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
|
|
2917
|
+
if (walked === NONE) {
|
|
2918
|
+
inst._zod.parse = base;
|
|
2919
|
+
if (inst._zod.run === wrapped) inst._zod.run = base;
|
|
2920
|
+
return base(payload, ctx);
|
|
2921
|
+
}
|
|
2922
|
+
if (walked === PROVEN || rechecked) isRecursiveInst = true;
|
|
2923
|
+
else rechecked = true;
|
|
2924
|
+
}
|
|
2925
|
+
const input = payload.value;
|
|
2926
|
+
if (!isRef(input)) return base(payload, ctx);
|
|
2927
|
+
let state = ctx[STATE];
|
|
2928
|
+
if (!state) {
|
|
2929
|
+
state = {
|
|
2930
|
+
buckets: /* @__PURE__ */ new WeakMap(),
|
|
2931
|
+
backEdges: void 0
|
|
2932
|
+
};
|
|
2933
|
+
ctx[STATE] = state;
|
|
2934
|
+
}
|
|
2935
|
+
let bucket;
|
|
2936
|
+
if (lastCtx === ctx) bucket = lastBucket;
|
|
2937
|
+
else {
|
|
2938
|
+
bucket = bucketFor(state, inst);
|
|
2939
|
+
lastCtx = ctx;
|
|
2940
|
+
lastBucket = bucket;
|
|
2941
|
+
}
|
|
2942
|
+
const hit = bucket.get(input);
|
|
2943
|
+
if (hit) {
|
|
2944
|
+
payload.value = hit.value;
|
|
2945
|
+
if (hit.issues) {
|
|
2946
|
+
if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
|
|
2947
|
+
} else {
|
|
2948
|
+
payload.memo = true;
|
|
2949
|
+
state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
|
|
2950
|
+
state.backEdges.add(hit.value);
|
|
2951
|
+
}
|
|
2952
|
+
return payload;
|
|
2953
|
+
}
|
|
2954
|
+
handoff = bucket;
|
|
2955
|
+
const depth = open.length;
|
|
2956
|
+
const result = base(payload, ctx);
|
|
2957
|
+
handoff = void 0;
|
|
2958
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
2959
|
+
if (result instanceof Promise) return result.then((r) => {
|
|
2960
|
+
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
2961
|
+
return r;
|
|
2962
|
+
});
|
|
2963
|
+
if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
2964
|
+
return result;
|
|
2965
|
+
};
|
|
2966
|
+
inst._zod.parse = wrapped;
|
|
2967
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
|
|
2972
|
+
function memoizer() {
|
|
2973
|
+
return memo;
|
|
2974
|
+
}
|
|
2975
|
+
/** Whether this value is a node a back-edge resolved to before it finished. */
|
|
2976
|
+
function isBackEdge(ctx, value) {
|
|
2977
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
2978
|
+
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
2979
|
+
}
|
|
2980
|
+
//#endregion
|
|
2981
|
+
//#region ../../node_modules/zod/v4/locales/en.js
|
|
2982
|
+
var error = () => {
|
|
2983
|
+
const Sizable = {
|
|
2984
|
+
string: {
|
|
2985
|
+
unit: "characters",
|
|
2986
|
+
verb: "to have"
|
|
2987
|
+
},
|
|
2988
|
+
file: {
|
|
2989
|
+
unit: "bytes",
|
|
2990
|
+
verb: "to have"
|
|
2991
|
+
},
|
|
2992
|
+
array: {
|
|
2993
|
+
unit: "items",
|
|
2994
|
+
verb: "to have"
|
|
2995
|
+
},
|
|
2996
|
+
set: {
|
|
2997
|
+
unit: "items",
|
|
2998
|
+
verb: "to have"
|
|
2999
|
+
},
|
|
3000
|
+
map: {
|
|
3001
|
+
unit: "entries",
|
|
3002
|
+
verb: "to have"
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
function getSizing(origin) {
|
|
3006
|
+
return Sizable[origin] ?? null;
|
|
3007
|
+
}
|
|
3008
|
+
const FormatDictionary = {
|
|
3009
|
+
regex: "input",
|
|
3010
|
+
email: "email address",
|
|
3011
|
+
url: "URL",
|
|
3012
|
+
emoji: "emoji",
|
|
3013
|
+
uuid: "UUID",
|
|
3014
|
+
uuidv4: "UUIDv4",
|
|
3015
|
+
uuidv6: "UUIDv6",
|
|
3016
|
+
nanoid: "nanoid",
|
|
3017
|
+
guid: "GUID",
|
|
3018
|
+
cuid: "cuid",
|
|
3019
|
+
cuid2: "cuid2",
|
|
3020
|
+
ulid: "ULID",
|
|
3021
|
+
xid: "XID",
|
|
3022
|
+
ksuid: "KSUID",
|
|
3023
|
+
datetime: "ISO datetime",
|
|
3024
|
+
date: "ISO date",
|
|
3025
|
+
time: "ISO time",
|
|
3026
|
+
duration: "ISO duration",
|
|
3027
|
+
ipv4: "IPv4 address",
|
|
3028
|
+
ipv6: "IPv6 address",
|
|
3029
|
+
mac: "MAC address",
|
|
3030
|
+
cidrv4: "IPv4 range",
|
|
3031
|
+
cidrv6: "IPv6 range",
|
|
3032
|
+
base64: "base64-encoded string",
|
|
3033
|
+
base64url: "base64url-encoded string",
|
|
3034
|
+
json_string: "JSON string",
|
|
3035
|
+
e164: "E.164 number",
|
|
3036
|
+
currency_code: "currency code",
|
|
3037
|
+
credit_card: "credit card number",
|
|
3038
|
+
iban: "IBAN",
|
|
3039
|
+
jwt: "JWT",
|
|
3040
|
+
template_literal: "input"
|
|
3041
|
+
};
|
|
3042
|
+
const TypeDictionary = { nan: "NaN" };
|
|
3043
|
+
function getTypeName(type, input) {
|
|
3044
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
|
|
3045
|
+
return TypeDictionary[type] ?? type;
|
|
3046
|
+
}
|
|
3047
|
+
return (issue) => {
|
|
3048
|
+
switch (issue.code) {
|
|
3049
|
+
case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
|
|
3050
|
+
case "invalid_value":
|
|
3051
|
+
if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
3052
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
3053
|
+
case "too_big": {
|
|
3054
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
3055
|
+
const sizing = getSizing(issue.origin);
|
|
3056
|
+
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3057
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
3058
|
+
}
|
|
3059
|
+
case "too_small": {
|
|
3060
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
3061
|
+
const sizing = getSizing(issue.origin);
|
|
3062
|
+
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
3063
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
3064
|
+
}
|
|
3065
|
+
case "invalid_format": {
|
|
3066
|
+
const _issue = issue;
|
|
3067
|
+
if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3068
|
+
if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3069
|
+
if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
|
|
3070
|
+
if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3071
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
3072
|
+
}
|
|
3073
|
+
case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
3074
|
+
case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
3075
|
+
case "invalid_key": return `Invalid key in ${issue.origin}`;
|
|
3076
|
+
case "invalid_union":
|
|
3077
|
+
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
|
|
3078
|
+
if (issue.inclusive === false) return "Invalid input: more than one option matched";
|
|
3079
|
+
return "Invalid input";
|
|
3080
|
+
case "invalid_element": return `Invalid value in ${issue.origin}`;
|
|
3081
|
+
default: return `Invalid input`;
|
|
3082
|
+
}
|
|
3083
|
+
};
|
|
3084
|
+
};
|
|
3085
|
+
function en_default() {
|
|
3086
|
+
return { localeError: error() };
|
|
3087
|
+
}
|
|
3088
|
+
//#endregion
|
|
2242
3089
|
//#region ../../node_modules/zod/v4/core/registries.js
|
|
2243
3090
|
var _a;
|
|
2244
3091
|
var $ZodRegistry = class {
|
|
@@ -2287,12 +3134,16 @@ function registry() {
|
|
|
2287
3134
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
2288
3135
|
//#endregion
|
|
2289
3136
|
//#region ../../node_modules/zod/v4/core/api.js
|
|
3137
|
+
function snapshotChecks(def) {
|
|
3138
|
+
if (def.checks) def.checks = [...def.checks];
|
|
3139
|
+
return def;
|
|
3140
|
+
}
|
|
2290
3141
|
// @__NO_SIDE_EFFECTS__
|
|
2291
3142
|
function _string(Class, params) {
|
|
2292
|
-
return new Class({
|
|
3143
|
+
return new Class(snapshotChecks({
|
|
2293
3144
|
type: "string",
|
|
2294
3145
|
...normalizeParams(params)
|
|
2295
|
-
});
|
|
3146
|
+
}));
|
|
2296
3147
|
}
|
|
2297
3148
|
// @__NO_SIDE_EFFECTS__
|
|
2298
3149
|
function _email(Class, params) {
|
|
@@ -2564,11 +3415,11 @@ function _isoDuration(Class, params) {
|
|
|
2564
3415
|
}
|
|
2565
3416
|
// @__NO_SIDE_EFFECTS__
|
|
2566
3417
|
function _number(Class, params) {
|
|
2567
|
-
return new Class({
|
|
3418
|
+
return new Class(snapshotChecks({
|
|
2568
3419
|
type: "number",
|
|
2569
3420
|
checks: [],
|
|
2570
3421
|
...normalizeParams(params)
|
|
2571
|
-
});
|
|
3422
|
+
}));
|
|
2572
3423
|
}
|
|
2573
3424
|
// @__NO_SIDE_EFFECTS__
|
|
2574
3425
|
function _int(Class, params) {
|
|
@@ -2771,7 +3622,7 @@ function _superRefine(fn, params) {
|
|
|
2771
3622
|
const _issue = issue$2;
|
|
2772
3623
|
if (_issue.fatal) _issue.continue = false;
|
|
2773
3624
|
_issue.code ?? (_issue.code = "custom");
|
|
2774
|
-
|
|
3625
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
2775
3626
|
_issue.inst ?? (_issue.inst = ch);
|
|
2776
3627
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2777
3628
|
payload.issues.push(issue(_issue));
|
|
@@ -2792,6 +3643,10 @@ function _check(fn, params) {
|
|
|
2792
3643
|
}
|
|
2793
3644
|
//#endregion
|
|
2794
3645
|
//#region ../../node_modules/zod/v4/core/to-json-schema.js
|
|
3646
|
+
function assignProps(target, ...sources) {
|
|
3647
|
+
for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
|
|
3648
|
+
return target;
|
|
3649
|
+
}
|
|
2795
3650
|
function initializeContext(params) {
|
|
2796
3651
|
let target = params?.target ?? "draft-2020-12";
|
|
2797
3652
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -2805,12 +3660,32 @@ function initializeContext(params) {
|
|
|
2805
3660
|
io: params?.io ?? "output",
|
|
2806
3661
|
counter: 0,
|
|
2807
3662
|
seen: /* @__PURE__ */ new Map(),
|
|
3663
|
+
sharedDefsExtractedFor: void 0,
|
|
3664
|
+
sharedEmitDoneFor: void 0,
|
|
2808
3665
|
cycles: params?.cycles ?? "ref",
|
|
2809
3666
|
reused: params?.reused ?? "inline",
|
|
3667
|
+
intersections: [],
|
|
3668
|
+
deferred: [],
|
|
2810
3669
|
external: params?.external ?? void 0
|
|
2811
3670
|
};
|
|
2812
3671
|
}
|
|
2813
|
-
|
|
3672
|
+
/**
|
|
3673
|
+
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
|
|
3674
|
+
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
|
|
3675
|
+
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
|
|
3676
|
+
*/
|
|
3677
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3678
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
|
|
3679
|
+
zodSchema: schema,
|
|
3680
|
+
path: params.path,
|
|
3681
|
+
message
|
|
3682
|
+
}) : ctx.unrepresentable;
|
|
3683
|
+
if (result === "any") return false;
|
|
3684
|
+
if (result === void 0 || result === "throw") throw new Error(message);
|
|
3685
|
+
Object.assign(json, result);
|
|
3686
|
+
return true;
|
|
3687
|
+
}
|
|
3688
|
+
function processSchema(schema, ctx, _params = {
|
|
2814
3689
|
path: [],
|
|
2815
3690
|
schemaPath: []
|
|
2816
3691
|
}) {
|
|
@@ -2829,6 +3704,8 @@ function process(schema, ctx, _params = {
|
|
|
2829
3704
|
path: _params.path
|
|
2830
3705
|
};
|
|
2831
3706
|
ctx.seen.set(schema, result);
|
|
3707
|
+
ctx.sharedDefsExtractedFor = void 0;
|
|
3708
|
+
ctx.sharedEmitDoneFor = void 0;
|
|
2832
3709
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2833
3710
|
if (overrideSchema) result.schema = overrideSchema;
|
|
2834
3711
|
else {
|
|
@@ -2847,12 +3724,12 @@ function process(schema, ctx, _params = {
|
|
|
2847
3724
|
const parent = schema._zod.parent;
|
|
2848
3725
|
if (parent) {
|
|
2849
3726
|
if (!result.ref) result.ref = parent;
|
|
2850
|
-
|
|
3727
|
+
processSchema(parent, ctx, params);
|
|
2851
3728
|
ctx.seen.get(parent).isParent = true;
|
|
2852
3729
|
}
|
|
2853
3730
|
}
|
|
2854
3731
|
const meta = ctx.metadataRegistry.get(schema);
|
|
2855
|
-
if (meta)
|
|
3732
|
+
if (meta) assignProps(result.schema, meta);
|
|
2856
3733
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2857
3734
|
delete result.schema.examples;
|
|
2858
3735
|
delete result.schema.default;
|
|
@@ -2861,9 +3738,13 @@ function process(schema, ctx, _params = {
|
|
|
2861
3738
|
delete result.schema._prefault;
|
|
2862
3739
|
return ctx.seen.get(schema).schema;
|
|
2863
3740
|
}
|
|
3741
|
+
function encodeJSONPointerSegment(segment) {
|
|
3742
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3743
|
+
}
|
|
2864
3744
|
function extractDefs(ctx, schema) {
|
|
2865
3745
|
const root = ctx.seen.get(schema);
|
|
2866
3746
|
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3747
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
|
|
2867
3748
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
2868
3749
|
for (const entry of ctx.seen.entries()) {
|
|
2869
3750
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -2883,15 +3764,16 @@ function extractDefs(ctx, schema) {
|
|
|
2883
3764
|
entry[1].defId = id;
|
|
2884
3765
|
return {
|
|
2885
3766
|
defId: id,
|
|
2886
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
3767
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
|
|
2887
3768
|
};
|
|
2888
3769
|
}
|
|
2889
|
-
|
|
2890
|
-
const defUriPrefix =
|
|
3770
|
+
const uriPrefix = `#`;
|
|
3771
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3772
|
+
if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
|
|
2891
3773
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2892
3774
|
return {
|
|
2893
3775
|
defId,
|
|
2894
|
-
ref: defUriPrefix + defId
|
|
3776
|
+
ref: defUriPrefix + encodeJSONPointerSegment(defId)
|
|
2895
3777
|
};
|
|
2896
3778
|
};
|
|
2897
3779
|
const extractToDef = (entry) => {
|
|
@@ -2932,12 +3814,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
2932
3814
|
continue;
|
|
2933
3815
|
}
|
|
2934
3816
|
if (seen.count > 1) {
|
|
2935
|
-
if (ctx.reused === "ref")
|
|
2936
|
-
|
|
2937
|
-
|
|
3817
|
+
if (ctx.reused === "ref") extractToDef(entry);
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
|
|
3821
|
+
}
|
|
3822
|
+
/** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
|
|
3823
|
+
function compactTypeUnion(schema) {
|
|
3824
|
+
const options = schema.anyOf;
|
|
3825
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
|
|
3826
|
+
const types = [];
|
|
3827
|
+
for (const option of options) {
|
|
3828
|
+
if (!option || typeof option !== "object") return;
|
|
3829
|
+
compactTypeUnion(option);
|
|
3830
|
+
const keys = Object.keys(option);
|
|
3831
|
+
if (keys.length !== 1 || keys[0] !== "type") return;
|
|
3832
|
+
const type = option.type;
|
|
3833
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
3834
|
+
if (typeof member !== "string") return;
|
|
3835
|
+
if (!types.includes(member)) types.push(member);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
delete schema.anyOf;
|
|
3839
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
3840
|
+
}
|
|
3841
|
+
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
|
|
3842
|
+
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
|
|
3843
|
+
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
|
|
3844
|
+
var FOLDABLE_KEYS = /* @__PURE__ */ new Set([
|
|
3845
|
+
"type",
|
|
3846
|
+
"properties",
|
|
3847
|
+
"required",
|
|
3848
|
+
"additionalProperties"
|
|
3849
|
+
]);
|
|
3850
|
+
var UNION_KEYS = ["oneOf", "anyOf"];
|
|
3851
|
+
/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
|
|
3852
|
+
function undeclaredConstraint(member) {
|
|
3853
|
+
const extra = member.additionalProperties;
|
|
3854
|
+
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
|
|
3855
|
+
return Object.keys(extra).length ? extra : null;
|
|
3856
|
+
}
|
|
3857
|
+
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
|
|
3858
|
+
function foldObjects(members) {
|
|
3859
|
+
const objects = [];
|
|
3860
|
+
for (const member of members) {
|
|
3861
|
+
if (typeof member !== "object" || member.type !== "object") return null;
|
|
3862
|
+
for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
|
|
3863
|
+
objects.push(member);
|
|
3864
|
+
}
|
|
3865
|
+
const properties = {};
|
|
3866
|
+
const required = /* @__PURE__ */ new Set();
|
|
3867
|
+
for (const object of objects) {
|
|
3868
|
+
for (const key in object.properties) {
|
|
3869
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
|
|
3870
|
+
const parts = [];
|
|
3871
|
+
for (const other of objects) {
|
|
3872
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
3873
|
+
if (part === null || part === void 0) continue;
|
|
3874
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
|
|
2938
3875
|
}
|
|
3876
|
+
assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
|
|
3877
|
+
}
|
|
3878
|
+
for (const key of object.required ?? []) required.add(key);
|
|
3879
|
+
}
|
|
3880
|
+
const folded = {
|
|
3881
|
+
type: "object",
|
|
3882
|
+
properties
|
|
3883
|
+
};
|
|
3884
|
+
if (required.size) folded.required = [...required];
|
|
3885
|
+
if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
|
|
3886
|
+
else {
|
|
3887
|
+
const constraints = [];
|
|
3888
|
+
for (const object of objects) {
|
|
3889
|
+
const constraint = undeclaredConstraint(object);
|
|
3890
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
|
|
2939
3891
|
}
|
|
3892
|
+
if (constraints.length === 1) folded.additionalProperties = constraints[0];
|
|
3893
|
+
else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
|
|
3894
|
+
}
|
|
3895
|
+
return folded;
|
|
3896
|
+
}
|
|
3897
|
+
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
|
|
3898
|
+
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
|
|
3899
|
+
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
|
|
3900
|
+
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
|
|
3901
|
+
* into one object is the encoding that says so on every target.
|
|
3902
|
+
*
|
|
3903
|
+
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
|
|
3904
|
+
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
|
|
3905
|
+
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
|
|
3906
|
+
function foldIntersection(json) {
|
|
3907
|
+
const allOf = json.allOf;
|
|
3908
|
+
if (!Array.isArray(allOf) || allOf.length < 2) return;
|
|
3909
|
+
for (const key of FOLDABLE_KEYS) if (key in json) return;
|
|
3910
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
3911
|
+
let folded = null;
|
|
3912
|
+
if (!unions.length) folded = foldObjects(allOf);
|
|
3913
|
+
else {
|
|
3914
|
+
const union = unions[0];
|
|
3915
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
3916
|
+
if (Object.keys(union).length !== 1) return;
|
|
3917
|
+
const rest = allOf.filter((m) => m !== union);
|
|
3918
|
+
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
3919
|
+
if (branches.some((b) => !b)) return;
|
|
3920
|
+
folded = { [keyword]: branches };
|
|
2940
3921
|
}
|
|
3922
|
+
if (!folded) return;
|
|
3923
|
+
delete json.allOf;
|
|
3924
|
+
assignProps(json, folded);
|
|
2941
3925
|
}
|
|
2942
3926
|
function finalize(ctx, schema) {
|
|
2943
3927
|
const root = ctx.seen.get(schema);
|
|
@@ -2956,8 +3940,8 @@ function finalize(ctx, schema) {
|
|
|
2956
3940
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2957
3941
|
schema.allOf = schema.allOf ?? [];
|
|
2958
3942
|
schema.allOf.push(refSchema);
|
|
2959
|
-
} else
|
|
2960
|
-
|
|
3943
|
+
} else assignProps(schema, refSchema);
|
|
3944
|
+
assignProps(schema, _cached);
|
|
2961
3945
|
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
2962
3946
|
if (key === "$ref" || key === "allOf") continue;
|
|
2963
3947
|
if (!(key in _cached)) delete schema[key];
|
|
@@ -2985,7 +3969,22 @@ function finalize(ctx, schema) {
|
|
|
2985
3969
|
path: seen.path ?? []
|
|
2986
3970
|
});
|
|
2987
3971
|
};
|
|
2988
|
-
|
|
3972
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
3973
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
3974
|
+
if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
3975
|
+
for (const rewrite of ctx.deferred) rewrite();
|
|
3976
|
+
if (ctx.intersections.length) {
|
|
3977
|
+
const carriers = /* @__PURE__ */ new Map();
|
|
3978
|
+
for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
|
|
3979
|
+
const allOf = json?.allOf;
|
|
3980
|
+
if (!Array.isArray(allOf)) continue;
|
|
3981
|
+
const existing = carriers.get(allOf);
|
|
3982
|
+
if (existing) existing.push(json);
|
|
3983
|
+
else carriers.set(allOf, [json]);
|
|
3984
|
+
}
|
|
3985
|
+
for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
2989
3988
|
const result = {};
|
|
2990
3989
|
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2991
3990
|
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -2996,17 +3995,18 @@ function finalize(ctx, schema) {
|
|
|
2996
3995
|
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2997
3996
|
result.$id = ctx.external.uri(id);
|
|
2998
3997
|
}
|
|
2999
|
-
|
|
3998
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
3000
3999
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
3001
4000
|
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
3002
4001
|
const defs = ctx.external?.defs ?? {};
|
|
3003
|
-
for (const entry of ctx.seen.entries()) {
|
|
4002
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
|
|
3004
4003
|
const seen = entry[1];
|
|
3005
4004
|
if (seen.def && seen.defId) {
|
|
3006
4005
|
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
3007
|
-
defs
|
|
4006
|
+
assignProp(defs, seen.defId, seen.def);
|
|
3008
4007
|
}
|
|
3009
4008
|
}
|
|
4009
|
+
if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
|
|
3010
4010
|
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
|
|
3011
4011
|
if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
3012
4012
|
else result.definitions = defs;
|
|
@@ -3038,7 +4038,7 @@ function isTransforming(_schema, _ctx) {
|
|
|
3038
4038
|
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
3039
4039
|
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
3040
4040
|
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
3041
|
-
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
4041
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault" || def.type === "catch") return isTransforming(def.innerType, ctx);
|
|
3042
4042
|
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
3043
4043
|
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3044
4044
|
if (def.type === "pipe") {
|
|
@@ -3069,7 +4069,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
3069
4069
|
...params,
|
|
3070
4070
|
processors
|
|
3071
4071
|
});
|
|
3072
|
-
|
|
4072
|
+
processSchema(schema, ctx);
|
|
3073
4073
|
extractDefs(ctx, schema);
|
|
3074
4074
|
return finalize(ctx, schema);
|
|
3075
4075
|
};
|
|
@@ -3081,12 +4081,84 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
3081
4081
|
io,
|
|
3082
4082
|
processors
|
|
3083
4083
|
});
|
|
3084
|
-
|
|
4084
|
+
processSchema(schema, ctx);
|
|
3085
4085
|
extractDefs(ctx, schema);
|
|
3086
4086
|
return finalize(ctx, schema);
|
|
3087
4087
|
};
|
|
3088
4088
|
//#endregion
|
|
3089
4089
|
//#region ../../node_modules/zod/v4/core/json-schema-processors.js
|
|
4090
|
+
var narrowMin = (agg, key, value) => {
|
|
4091
|
+
if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
|
|
4092
|
+
};
|
|
4093
|
+
var narrowMax = (agg, key, value) => {
|
|
4094
|
+
if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
|
|
4095
|
+
};
|
|
4096
|
+
var narrowBoth = (agg, value) => {
|
|
4097
|
+
narrowMin(agg, "minimum", value);
|
|
4098
|
+
narrowMax(agg, "maximum", value);
|
|
4099
|
+
};
|
|
4100
|
+
var addDivisor = (agg, value) => {
|
|
4101
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4102
|
+
if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
|
|
4103
|
+
};
|
|
4104
|
+
var addPattern = (agg, pattern) => {
|
|
4105
|
+
agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
|
|
4106
|
+
agg.patterns.add(pattern);
|
|
4107
|
+
};
|
|
4108
|
+
var intersectMime = (agg, mime) => {
|
|
4109
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4110
|
+
};
|
|
4111
|
+
var setFormat = (agg, format) => {
|
|
4112
|
+
agg.format = format;
|
|
4113
|
+
if (format.includes("int")) agg.isInt = true;
|
|
4114
|
+
};
|
|
4115
|
+
var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4116
|
+
var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4117
|
+
var formatContributor = (ranges) => (agg, def) => {
|
|
4118
|
+
setFormat(agg, def.format);
|
|
4119
|
+
const [minimum, maximum] = ranges[def.format];
|
|
4120
|
+
narrowMin(agg, "minimum", minimum);
|
|
4121
|
+
narrowMax(agg, "maximum", maximum);
|
|
4122
|
+
};
|
|
4123
|
+
var contributors = {
|
|
4124
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4125
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4126
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4127
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4128
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4129
|
+
min_length: minContributor,
|
|
4130
|
+
max_length: maxContributor,
|
|
4131
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4132
|
+
min_size: minContributor,
|
|
4133
|
+
max_size: maxContributor,
|
|
4134
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4135
|
+
string_format: (agg, def) => {
|
|
4136
|
+
setFormat(agg, def.format);
|
|
4137
|
+
if (def.pattern) addPattern(agg, def.pattern);
|
|
4138
|
+
if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
|
|
4139
|
+
if (def.local || def.precision === -1) agg.laxFormat = true;
|
|
4140
|
+
},
|
|
4141
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4142
|
+
};
|
|
4143
|
+
function aggregateChecks(schema) {
|
|
4144
|
+
const agg = {};
|
|
4145
|
+
const def = schema._zod.def;
|
|
4146
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4147
|
+
for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4148
|
+
const bag = schema._zod.bag;
|
|
4149
|
+
if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
|
|
4150
|
+
if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4151
|
+
if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
|
|
4152
|
+
if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4153
|
+
if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
|
|
4154
|
+
if (bag.format !== void 0) {
|
|
4155
|
+
agg.format ?? (agg.format = bag.format);
|
|
4156
|
+
if (bag.format.includes("int")) agg.isInt = true;
|
|
4157
|
+
}
|
|
4158
|
+
if (bag.mime) intersectMime(agg, bag.mime);
|
|
4159
|
+
for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
|
|
4160
|
+
return agg;
|
|
4161
|
+
}
|
|
3090
4162
|
var formatMap = {
|
|
3091
4163
|
guid: "uuid",
|
|
3092
4164
|
url: "uri",
|
|
@@ -3094,32 +4166,33 @@ var formatMap = {
|
|
|
3094
4166
|
json_string: "json-string",
|
|
3095
4167
|
regex: ""
|
|
3096
4168
|
};
|
|
4169
|
+
var exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
|
|
4170
|
+
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3097
4171
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
3098
4172
|
const json = _json;
|
|
3099
4173
|
json.type = "string";
|
|
3100
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
4174
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3101
4175
|
if (typeof minimum === "number") json.minLength = minimum;
|
|
3102
4176
|
if (typeof maximum === "number") json.maxLength = maximum;
|
|
3103
4177
|
if (format) {
|
|
3104
4178
|
json.format = formatMap[format] ?? format;
|
|
3105
4179
|
if (json.format === "") delete json.format;
|
|
3106
|
-
if (format === "time") delete json.format;
|
|
4180
|
+
if (format === "time" || laxFormat) delete json.format;
|
|
3107
4181
|
}
|
|
3108
4182
|
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3109
4183
|
if (patterns && patterns.size > 0) {
|
|
3110
|
-
const
|
|
3111
|
-
if (
|
|
3112
|
-
else if (
|
|
4184
|
+
const patternList = [...patterns].map(exactPattern);
|
|
4185
|
+
if (patternList.length === 1) json.pattern = patternList[0].source;
|
|
4186
|
+
else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
|
|
3113
4187
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3114
4188
|
pattern: regex.source
|
|
3115
4189
|
}))];
|
|
3116
4190
|
}
|
|
3117
4191
|
};
|
|
3118
|
-
var numberProcessor = (schema, ctx, _json,
|
|
4192
|
+
var numberProcessor = (schema, ctx, _json, params) => {
|
|
3119
4193
|
const json = _json;
|
|
3120
|
-
const { minimum, maximum,
|
|
3121
|
-
|
|
3122
|
-
else json.type = "number";
|
|
4194
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
4195
|
+
json.type = isInt ? "integer" : "number";
|
|
3123
4196
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3124
4197
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3125
4198
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
@@ -3135,7 +4208,14 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3135
4208
|
json.exclusiveMaximum = true;
|
|
3136
4209
|
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
3137
4210
|
} else if (typeof maximum === "number") json.maximum = maximum;
|
|
3138
|
-
if (
|
|
4211
|
+
if (multipleOf) {
|
|
4212
|
+
const divisors = /* @__PURE__ */ new Set();
|
|
4213
|
+
for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
|
|
4214
|
+
else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
4215
|
+
const [first, ...rest] = divisors;
|
|
4216
|
+
if (first !== void 0) json.multipleOf = first;
|
|
4217
|
+
if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
4218
|
+
}
|
|
3139
4219
|
};
|
|
3140
4220
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3141
4221
|
json.type = "boolean";
|
|
@@ -3146,18 +4226,26 @@ var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
|
3146
4226
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3147
4227
|
const def = schema._zod.def;
|
|
3148
4228
|
const values = getEnumValues(def.entries);
|
|
4229
|
+
if (values.length === 0) {
|
|
4230
|
+
json.not = {};
|
|
4231
|
+
return;
|
|
4232
|
+
}
|
|
3149
4233
|
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3150
4234
|
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3151
4235
|
json.enum = values;
|
|
3152
4236
|
};
|
|
3153
|
-
var literalProcessor = (schema, ctx, json,
|
|
4237
|
+
var literalProcessor = (schema, ctx, json, params) => {
|
|
3154
4238
|
const def = schema._zod.def;
|
|
4239
|
+
if (def.values.length === 0) {
|
|
4240
|
+
json.not = {};
|
|
4241
|
+
return;
|
|
4242
|
+
}
|
|
3155
4243
|
const vals = [];
|
|
3156
4244
|
for (const val of def.values) if (val === void 0) {
|
|
3157
|
-
if (ctx
|
|
4245
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
|
|
3158
4246
|
} else if (typeof val === "bigint") {
|
|
3159
|
-
if (ctx
|
|
3160
|
-
|
|
4247
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
|
|
4248
|
+
vals.push(Number(val));
|
|
3161
4249
|
} else vals.push(val);
|
|
3162
4250
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3163
4251
|
const val = vals[0];
|
|
@@ -3172,49 +4260,55 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
3172
4260
|
json.enum = vals;
|
|
3173
4261
|
}
|
|
3174
4262
|
};
|
|
3175
|
-
var customProcessor = (
|
|
3176
|
-
|
|
4263
|
+
var customProcessor = (schema, ctx, json, params) => {
|
|
4264
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3177
4265
|
};
|
|
3178
|
-
var transformProcessor = (
|
|
3179
|
-
|
|
4266
|
+
var transformProcessor = (schema, ctx, json, params) => {
|
|
4267
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3180
4268
|
};
|
|
3181
4269
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
3182
4270
|
const json = _json;
|
|
3183
4271
|
const def = schema._zod.def;
|
|
3184
|
-
const { minimum, maximum } = schema
|
|
4272
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3185
4273
|
if (typeof minimum === "number") json.minItems = minimum;
|
|
3186
4274
|
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3187
4275
|
json.type = "array";
|
|
3188
|
-
json.items =
|
|
4276
|
+
json.items = processSchema(def.element, ctx, {
|
|
3189
4277
|
...params,
|
|
3190
4278
|
path: [...params.path, "items"]
|
|
3191
4279
|
});
|
|
3192
4280
|
};
|
|
4281
|
+
function inputOptin(schema) {
|
|
4282
|
+
const def = schema._zod.def;
|
|
4283
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
|
|
4284
|
+
if (def.type === "catch") return inputOptin(def.innerType);
|
|
4285
|
+
return schema._zod.optin;
|
|
4286
|
+
}
|
|
3193
4287
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
3194
4288
|
const json = _json;
|
|
3195
4289
|
const def = schema._zod.def;
|
|
4290
|
+
const shape = def.shape;
|
|
4291
|
+
if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
|
|
3196
4292
|
json.type = "object";
|
|
3197
4293
|
json.properties = {};
|
|
3198
|
-
const shape
|
|
3199
|
-
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
4294
|
+
for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3200
4295
|
...params,
|
|
3201
4296
|
path: [
|
|
3202
4297
|
...params.path,
|
|
3203
4298
|
"properties",
|
|
3204
4299
|
key
|
|
3205
4300
|
]
|
|
3206
|
-
});
|
|
3207
|
-
const allKeys = new Set(Object.keys(shape));
|
|
3208
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3209
|
-
const v = def.shape[key]._zod;
|
|
3210
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
3211
|
-
else return v.optout === void 0;
|
|
3212
4301
|
}));
|
|
3213
|
-
|
|
4302
|
+
const requiredKeys = [];
|
|
4303
|
+
for (const key of Object.keys(shape)) {
|
|
4304
|
+
const field = def.shape[key];
|
|
4305
|
+
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
|
|
4306
|
+
}
|
|
4307
|
+
if (requiredKeys.length > 0) json.required = requiredKeys;
|
|
3214
4308
|
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3215
4309
|
else if (!def.catchall) {
|
|
3216
4310
|
if (ctx.io === "output") json.additionalProperties = false;
|
|
3217
|
-
} else if (def.catchall) json.additionalProperties =
|
|
4311
|
+
} else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3218
4312
|
...params,
|
|
3219
4313
|
path: [...params.path, "additionalProperties"]
|
|
3220
4314
|
});
|
|
@@ -3222,7 +4316,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3222
4316
|
var unionProcessor = (schema, ctx, json, params) => {
|
|
3223
4317
|
const def = schema._zod.def;
|
|
3224
4318
|
const isExclusive = def.inclusive === false;
|
|
3225
|
-
const options = def.options.map((x, i) =>
|
|
4319
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
3226
4320
|
...params,
|
|
3227
4321
|
path: [
|
|
3228
4322
|
...params.path,
|
|
@@ -3235,7 +4329,7 @@ var unionProcessor = (schema, ctx, json, params) => {
|
|
|
3235
4329
|
};
|
|
3236
4330
|
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
3237
4331
|
const def = schema._zod.def;
|
|
3238
|
-
const a =
|
|
4332
|
+
const a = processSchema(def.left, ctx, {
|
|
3239
4333
|
...params,
|
|
3240
4334
|
path: [
|
|
3241
4335
|
...params.path,
|
|
@@ -3243,7 +4337,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3243
4337
|
0
|
|
3244
4338
|
]
|
|
3245
4339
|
});
|
|
3246
|
-
const b =
|
|
4340
|
+
const b = processSchema(def.right, ctx, {
|
|
3247
4341
|
...params,
|
|
3248
4342
|
path: [
|
|
3249
4343
|
...params.path,
|
|
@@ -3252,16 +4346,76 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3252
4346
|
]
|
|
3253
4347
|
});
|
|
3254
4348
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3255
|
-
|
|
4349
|
+
const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
4350
|
+
json.allOf = allOf;
|
|
4351
|
+
ctx.intersections.push(allOf);
|
|
3256
4352
|
};
|
|
4353
|
+
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
|
|
4354
|
+
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
|
|
4355
|
+
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
|
|
4356
|
+
*
|
|
4357
|
+
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
|
|
4358
|
+
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
|
|
4359
|
+
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
|
|
4360
|
+
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
|
|
4361
|
+
* outright. */
|
|
4362
|
+
function stringifyKeyNames(bySchema, json, visited) {
|
|
4363
|
+
if (json.$ref) {
|
|
4364
|
+
if (visited.has(json)) return json;
|
|
4365
|
+
visited.add(json);
|
|
4366
|
+
const def = bySchema.get(json)?.def;
|
|
4367
|
+
if (!def) return json;
|
|
4368
|
+
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
4369
|
+
return inlined === def ? json : inlined;
|
|
4370
|
+
}
|
|
4371
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
4372
|
+
const branches = json[keyword];
|
|
4373
|
+
if (!Array.isArray(branches)) continue;
|
|
4374
|
+
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
4375
|
+
if (mapped.some((branch, i) => branch !== branches[i])) json = {
|
|
4376
|
+
...json,
|
|
4377
|
+
[keyword]: mapped
|
|
4378
|
+
};
|
|
4379
|
+
}
|
|
4380
|
+
const types = Array.isArray(json.type) ? json.type : [json.type];
|
|
4381
|
+
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
4382
|
+
const values = json.enum ?? (json.const !== void 0 ? [json.const] : void 0);
|
|
4383
|
+
if (!numericType && !values?.some((v) => typeof v === "number")) return json;
|
|
4384
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
|
|
4385
|
+
if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
4386
|
+
else if (typeof rest.const === "number") rest.const = String(rest.const);
|
|
4387
|
+
if (!numericType) return rest;
|
|
4388
|
+
rest.type = "string";
|
|
4389
|
+
if (!values) rest.pattern = (types.includes("number") ? number$1 : integer).source;
|
|
4390
|
+
return rest;
|
|
4391
|
+
}
|
|
4392
|
+
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
|
|
4393
|
+
var pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
4394
|
+
function rewriteKeyNames(ctx) {
|
|
4395
|
+
const bySchema = /* @__PURE__ */ new Map();
|
|
4396
|
+
for (const entry of ctx.seen.values()) if (entry.def && !bySchema.has(entry.schema)) bySchema.set(entry.schema, entry);
|
|
4397
|
+
const rewrites = /* @__PURE__ */ new Map();
|
|
4398
|
+
for (const record of pendingRecords.get(ctx) ?? []) {
|
|
4399
|
+
const seen = ctx.seen.get(record);
|
|
4400
|
+
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
4401
|
+
if (!names || names === true || rewrites.has(names)) continue;
|
|
4402
|
+
const rewritten = stringifyKeyNames(bySchema, names, /* @__PURE__ */ new Set());
|
|
4403
|
+
if (rewritten !== names) rewrites.set(names, rewritten);
|
|
4404
|
+
}
|
|
4405
|
+
if (!rewrites.size) return;
|
|
4406
|
+
for (const entry of ctx.seen.values()) for (const carrier of [entry.schema, entry.def]) {
|
|
4407
|
+
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
4408
|
+
if (rewritten) carrier.propertyNames = rewritten;
|
|
4409
|
+
}
|
|
4410
|
+
}
|
|
3257
4411
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
3258
4412
|
const json = _json;
|
|
3259
4413
|
const def = schema._zod.def;
|
|
3260
4414
|
json.type = "object";
|
|
3261
4415
|
const keyType = def.keyType;
|
|
3262
|
-
const patterns = keyType.
|
|
4416
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
3263
4417
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
3264
|
-
const valueSchema =
|
|
4418
|
+
const valueSchema = processSchema(def.valueType, ctx, {
|
|
3265
4419
|
...params,
|
|
3266
4420
|
path: [
|
|
3267
4421
|
...params.path,
|
|
@@ -3270,26 +4424,36 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
3270
4424
|
]
|
|
3271
4425
|
});
|
|
3272
4426
|
json.patternProperties = {};
|
|
3273
|
-
for (const pattern of patterns) json.patternProperties
|
|
4427
|
+
for (const pattern of patterns) assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
3274
4428
|
} else {
|
|
3275
|
-
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12")
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
4429
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
4430
|
+
json.propertyNames = processSchema(def.keyType, ctx, {
|
|
4431
|
+
...params,
|
|
4432
|
+
path: [...params.path, "propertyNames"]
|
|
4433
|
+
});
|
|
4434
|
+
let pending = pendingRecords.get(ctx);
|
|
4435
|
+
if (!pending) {
|
|
4436
|
+
pending = [];
|
|
4437
|
+
pendingRecords.set(ctx, pending);
|
|
4438
|
+
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
4439
|
+
}
|
|
4440
|
+
pending.push(schema);
|
|
4441
|
+
}
|
|
4442
|
+
json.additionalProperties = processSchema(def.valueType, ctx, {
|
|
3280
4443
|
...params,
|
|
3281
4444
|
path: [...params.path, "additionalProperties"]
|
|
3282
4445
|
});
|
|
3283
4446
|
}
|
|
3284
4447
|
const keyValues = keyType._zod.values;
|
|
3285
|
-
|
|
4448
|
+
const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
|
|
4449
|
+
if (keyValues && !def.partial && !omittableOnInput) {
|
|
3286
4450
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
3287
|
-
if (validKeyValues.length > 0) json.required = validKeyValues;
|
|
4451
|
+
if (validKeyValues.length > 0) json.required = validKeyValues.map(String);
|
|
3288
4452
|
}
|
|
3289
4453
|
};
|
|
3290
4454
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3291
4455
|
const def = schema._zod.def;
|
|
3292
|
-
const inner =
|
|
4456
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
3293
4457
|
const seen = ctx.seen.get(schema);
|
|
3294
4458
|
if (ctx.target === "openapi-3.0") {
|
|
3295
4459
|
seen.ref = def.innerType;
|
|
@@ -3298,34 +4462,53 @@ var nullableProcessor = (schema, ctx, json, params) => {
|
|
|
3298
4462
|
};
|
|
3299
4463
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3300
4464
|
const def = schema._zod.def;
|
|
3301
|
-
|
|
4465
|
+
processSchema(def.innerType, ctx, params);
|
|
3302
4466
|
const seen = ctx.seen.get(schema);
|
|
3303
4467
|
seen.ref = def.innerType;
|
|
3304
4468
|
};
|
|
4469
|
+
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
|
|
4470
|
+
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
|
|
4471
|
+
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
|
|
4472
|
+
var UNREPRESENTABLE_DEFAULT = Symbol();
|
|
4473
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4474
|
+
let unrepresentable = false;
|
|
4475
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4476
|
+
if (typeof val !== "bigint") return val;
|
|
4477
|
+
unrepresentable = true;
|
|
4478
|
+
return null;
|
|
4479
|
+
});
|
|
4480
|
+
if (!unrepresentable) return JSON.parse(serialized);
|
|
4481
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4482
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4483
|
+
}
|
|
3305
4484
|
var defaultProcessor = (schema, ctx, json, params) => {
|
|
3306
4485
|
const def = schema._zod.def;
|
|
3307
|
-
|
|
4486
|
+
processSchema(def.innerType, ctx, params);
|
|
3308
4487
|
const seen = ctx.seen.get(schema);
|
|
3309
4488
|
seen.ref = def.innerType;
|
|
3310
|
-
|
|
4489
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4490
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
|
|
3311
4491
|
};
|
|
3312
4492
|
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
3313
4493
|
const def = schema._zod.def;
|
|
3314
|
-
|
|
4494
|
+
processSchema(def.innerType, ctx, params);
|
|
3315
4495
|
const seen = ctx.seen.get(schema);
|
|
3316
4496
|
seen.ref = def.innerType;
|
|
3317
|
-
if (ctx.io
|
|
4497
|
+
if (ctx.io !== "input") return;
|
|
4498
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4499
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
|
|
3318
4500
|
};
|
|
3319
4501
|
var catchProcessor = (schema, ctx, json, params) => {
|
|
3320
4502
|
const def = schema._zod.def;
|
|
3321
|
-
|
|
4503
|
+
processSchema(def.innerType, ctx, params);
|
|
3322
4504
|
const seen = ctx.seen.get(schema);
|
|
3323
4505
|
seen.ref = def.innerType;
|
|
3324
4506
|
let catchValue;
|
|
3325
4507
|
try {
|
|
3326
4508
|
catchValue = def.catchValue(void 0);
|
|
3327
4509
|
} catch {
|
|
3328
|
-
|
|
4510
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4511
|
+
return;
|
|
3329
4512
|
}
|
|
3330
4513
|
json.default = catchValue;
|
|
3331
4514
|
};
|
|
@@ -3333,75 +4516,73 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
3333
4516
|
const def = schema._zod.def;
|
|
3334
4517
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3335
4518
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3336
|
-
|
|
4519
|
+
processSchema(innerType, ctx, params);
|
|
3337
4520
|
const seen = ctx.seen.get(schema);
|
|
3338
4521
|
seen.ref = innerType;
|
|
3339
4522
|
};
|
|
3340
4523
|
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
3341
4524
|
const def = schema._zod.def;
|
|
3342
|
-
|
|
4525
|
+
processSchema(def.innerType, ctx, params);
|
|
3343
4526
|
const seen = ctx.seen.get(schema);
|
|
3344
4527
|
seen.ref = def.innerType;
|
|
3345
4528
|
json.readOnly = true;
|
|
3346
4529
|
};
|
|
3347
4530
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
3348
4531
|
const def = schema._zod.def;
|
|
3349
|
-
|
|
4532
|
+
processSchema(def.innerType, ctx, params);
|
|
3350
4533
|
const seen = ctx.seen.get(schema);
|
|
3351
4534
|
seen.ref = def.innerType;
|
|
3352
4535
|
};
|
|
3353
4536
|
//#endregion
|
|
3354
|
-
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
3355
|
-
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
3356
|
-
$ZodISODateTime.init(inst, def);
|
|
3357
|
-
ZodStringFormat.init(inst, def);
|
|
3358
|
-
});
|
|
3359
|
-
function datetime(params) {
|
|
3360
|
-
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
3361
|
-
}
|
|
3362
|
-
var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
3363
|
-
$ZodISODate.init(inst, def);
|
|
3364
|
-
ZodStringFormat.init(inst, def);
|
|
3365
|
-
});
|
|
3366
|
-
function date(params) {
|
|
3367
|
-
return /* @__PURE__ */ _isoDate(ZodISODate, params);
|
|
3368
|
-
}
|
|
3369
|
-
var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
3370
|
-
$ZodISOTime.init(inst, def);
|
|
3371
|
-
ZodStringFormat.init(inst, def);
|
|
3372
|
-
});
|
|
3373
|
-
function time(params) {
|
|
3374
|
-
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
3375
|
-
}
|
|
3376
|
-
var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
3377
|
-
$ZodISODuration.init(inst, def);
|
|
3378
|
-
ZodStringFormat.init(inst, def);
|
|
3379
|
-
});
|
|
3380
|
-
function duration(params) {
|
|
3381
|
-
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
3382
|
-
}
|
|
3383
|
-
//#endregion
|
|
3384
4537
|
//#region ../../node_modules/zod/v4/classic/errors.js
|
|
4538
|
+
var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
4539
|
+
function _lazyMethod(proto, key, make) {
|
|
4540
|
+
Object.defineProperty(proto, key, {
|
|
4541
|
+
configurable: true,
|
|
4542
|
+
enumerable: false,
|
|
4543
|
+
get() {
|
|
4544
|
+
const value = make(this);
|
|
4545
|
+
Object.defineProperty(this, key, {
|
|
4546
|
+
value,
|
|
4547
|
+
configurable: true,
|
|
4548
|
+
writable: true
|
|
4549
|
+
});
|
|
4550
|
+
return value;
|
|
4551
|
+
},
|
|
4552
|
+
set(value) {
|
|
4553
|
+
Object.defineProperty(this, key, {
|
|
4554
|
+
value,
|
|
4555
|
+
configurable: true,
|
|
4556
|
+
writable: true
|
|
4557
|
+
});
|
|
4558
|
+
}
|
|
4559
|
+
});
|
|
4560
|
+
}
|
|
3385
4561
|
var initializer = (inst, issues) => {
|
|
3386
4562
|
$ZodError.init(inst, issues);
|
|
3387
4563
|
inst.name = "ZodError";
|
|
3388
|
-
Object.
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
4564
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4565
|
+
if (_installedErrorProtos.has(proto)) return;
|
|
4566
|
+
_installedErrorProtos.add(proto);
|
|
4567
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4568
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4569
|
+
_lazyMethod(proto, "addIssue", (self) => (issue) => {
|
|
4570
|
+
self.issues.push(issue);
|
|
4571
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4572
|
+
});
|
|
4573
|
+
_lazyMethod(proto, "addIssues", (self) => (issues) => {
|
|
4574
|
+
self.issues.push(...issues);
|
|
4575
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4576
|
+
});
|
|
4577
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4578
|
+
configurable: true,
|
|
4579
|
+
enumerable: false,
|
|
4580
|
+
get() {
|
|
4581
|
+
return this.issues.length === 0;
|
|
4582
|
+
}
|
|
3402
4583
|
});
|
|
3403
4584
|
};
|
|
3404
|
-
var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
|
|
4585
|
+
var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
|
|
3405
4586
|
//#endregion
|
|
3406
4587
|
//#region ../../node_modules/zod/v4/classic/parse.js
|
|
3407
4588
|
var parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
@@ -3418,254 +4599,319 @@ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
|
3418
4599
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3419
4600
|
//#endregion
|
|
3420
4601
|
//#region ../../node_modules/zod/v4/classic/schemas.js
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
if (!
|
|
3426
|
-
installed = /* @__PURE__ */ new Set();
|
|
3427
|
-
_installedGroups.set(proto, installed);
|
|
3428
|
-
}
|
|
3429
|
-
if (installed.has(group)) return;
|
|
3430
|
-
installed.add(group);
|
|
3431
|
-
for (const key in methods) {
|
|
3432
|
-
const fn = methods[key];
|
|
3433
|
-
Object.defineProperty(proto, key, {
|
|
3434
|
-
configurable: true,
|
|
3435
|
-
enumerable: false,
|
|
3436
|
-
get() {
|
|
3437
|
-
const bound = fn.bind(this);
|
|
3438
|
-
Object.defineProperty(this, key, {
|
|
3439
|
-
configurable: true,
|
|
3440
|
-
writable: true,
|
|
3441
|
-
enumerable: true,
|
|
3442
|
-
value: bound
|
|
3443
|
-
});
|
|
3444
|
-
return bound;
|
|
3445
|
-
},
|
|
3446
|
-
set(v) {
|
|
3447
|
-
Object.defineProperty(this, key, {
|
|
3448
|
-
configurable: true,
|
|
3449
|
-
writable: true,
|
|
3450
|
-
enumerable: true,
|
|
3451
|
-
value: v
|
|
3452
|
-
});
|
|
3453
|
-
}
|
|
3454
|
-
});
|
|
3455
|
-
}
|
|
4602
|
+
function _ensureDefaultLocale() {
|
|
4603
|
+
if (!globalConfig.localeError) config(en_default());
|
|
4604
|
+
}
|
|
4605
|
+
function _ensureDefaultMemoizer() {
|
|
4606
|
+
if (!globalConfig.memoizer) config({ memoizer: memoizer() });
|
|
3456
4607
|
}
|
|
3457
4608
|
var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
4609
|
+
_ensureDefaultLocale();
|
|
3458
4610
|
$ZodType.init(inst, def);
|
|
3459
|
-
Object.assign(inst["~standard"], { jsonSchema: {
|
|
3460
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3461
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3462
|
-
} });
|
|
3463
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3464
4611
|
inst.def = def;
|
|
3465
4612
|
inst.type = def.type;
|
|
3466
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
3467
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
3468
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
3469
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
3470
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
3471
|
-
inst.spa = inst.safeParseAsync;
|
|
3472
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
3473
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
3474
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3475
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
3476
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
3477
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3478
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3479
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3480
|
-
_installLazyMethods(inst, "ZodType", {
|
|
3481
|
-
check(...chks) {
|
|
3482
|
-
const def = this.def;
|
|
3483
|
-
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
3484
|
-
check: ch,
|
|
3485
|
-
def: { check: "custom" },
|
|
3486
|
-
onattach: []
|
|
3487
|
-
} } : ch)] }), { parent: true });
|
|
3488
|
-
},
|
|
3489
|
-
with(...chks) {
|
|
3490
|
-
return this.check(...chks);
|
|
3491
|
-
},
|
|
3492
|
-
clone(def, params) {
|
|
3493
|
-
return clone(this, def, params);
|
|
3494
|
-
},
|
|
3495
|
-
brand() {
|
|
3496
|
-
return this;
|
|
3497
|
-
},
|
|
3498
|
-
register(reg, meta) {
|
|
3499
|
-
reg.add(this, meta);
|
|
3500
|
-
return this;
|
|
3501
|
-
},
|
|
3502
|
-
refine(check, params) {
|
|
3503
|
-
return this.check(refine(check, params));
|
|
3504
|
-
},
|
|
3505
|
-
superRefine(refinement, params) {
|
|
3506
|
-
return this.check(superRefine(refinement, params));
|
|
3507
|
-
},
|
|
3508
|
-
overwrite(fn) {
|
|
3509
|
-
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
3510
|
-
},
|
|
3511
|
-
optional() {
|
|
3512
|
-
return optional(this);
|
|
3513
|
-
},
|
|
3514
|
-
exactOptional() {
|
|
3515
|
-
return exactOptional(this);
|
|
3516
|
-
},
|
|
3517
|
-
nullable() {
|
|
3518
|
-
return nullable(this);
|
|
3519
|
-
},
|
|
3520
|
-
nullish() {
|
|
3521
|
-
return optional(nullable(this));
|
|
3522
|
-
},
|
|
3523
|
-
nonoptional(params) {
|
|
3524
|
-
return nonoptional(this, params);
|
|
3525
|
-
},
|
|
3526
|
-
array() {
|
|
3527
|
-
return array(this);
|
|
3528
|
-
},
|
|
3529
|
-
or(arg) {
|
|
3530
|
-
return union([this, arg]);
|
|
3531
|
-
},
|
|
3532
|
-
and(arg) {
|
|
3533
|
-
return intersection(this, arg);
|
|
3534
|
-
},
|
|
3535
|
-
transform(tx) {
|
|
3536
|
-
return pipe(this, transform(tx));
|
|
3537
|
-
},
|
|
3538
|
-
default(d) {
|
|
3539
|
-
return _default(this, d);
|
|
3540
|
-
},
|
|
3541
|
-
prefault(d) {
|
|
3542
|
-
return prefault(this, d);
|
|
3543
|
-
},
|
|
3544
|
-
catch(params) {
|
|
3545
|
-
return _catch(this, params);
|
|
3546
|
-
},
|
|
3547
|
-
pipe(target) {
|
|
3548
|
-
return pipe(this, target);
|
|
3549
|
-
},
|
|
3550
|
-
readonly() {
|
|
3551
|
-
return readonly(this);
|
|
3552
|
-
},
|
|
3553
|
-
describe(description) {
|
|
3554
|
-
const cl = this.clone();
|
|
3555
|
-
globalRegistry.add(cl, { description });
|
|
3556
|
-
return cl;
|
|
3557
|
-
},
|
|
3558
|
-
meta(...args) {
|
|
3559
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
3560
|
-
const cl = this.clone();
|
|
3561
|
-
globalRegistry.add(cl, args[0]);
|
|
3562
|
-
return cl;
|
|
3563
|
-
},
|
|
3564
|
-
isOptional() {
|
|
3565
|
-
return this.safeParse(void 0).success;
|
|
3566
|
-
},
|
|
3567
|
-
isNullable() {
|
|
3568
|
-
return this.safeParse(null).success;
|
|
3569
|
-
},
|
|
3570
|
-
apply(fn) {
|
|
3571
|
-
return fn(this);
|
|
3572
|
-
}
|
|
3573
|
-
});
|
|
3574
|
-
Object.defineProperty(inst, "description", {
|
|
3575
|
-
get() {
|
|
3576
|
-
return globalRegistry.get(inst)?.description;
|
|
3577
|
-
},
|
|
3578
|
-
configurable: true
|
|
3579
|
-
});
|
|
3580
4613
|
return inst;
|
|
4614
|
+
}, {
|
|
4615
|
+
check(...chks) {
|
|
4616
|
+
const def = this.def;
|
|
4617
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
4618
|
+
check: ch,
|
|
4619
|
+
def: { check: "custom" },
|
|
4620
|
+
onattach: []
|
|
4621
|
+
} } : ch)] }), { parent: true });
|
|
4622
|
+
},
|
|
4623
|
+
with(...chks) {
|
|
4624
|
+
return this.check(...chks);
|
|
4625
|
+
},
|
|
4626
|
+
clone(def, params) {
|
|
4627
|
+
return clone(this, def, params);
|
|
4628
|
+
},
|
|
4629
|
+
brand() {
|
|
4630
|
+
return this;
|
|
4631
|
+
},
|
|
4632
|
+
register(reg, meta) {
|
|
4633
|
+
reg.add(this, meta);
|
|
4634
|
+
return this;
|
|
4635
|
+
},
|
|
4636
|
+
refine(check, params) {
|
|
4637
|
+
return this.check(refine(check, params));
|
|
4638
|
+
},
|
|
4639
|
+
superRefine(refinement, params) {
|
|
4640
|
+
return this.check(superRefine(refinement, params));
|
|
4641
|
+
},
|
|
4642
|
+
overwrite(fn) {
|
|
4643
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4644
|
+
},
|
|
4645
|
+
optional() {
|
|
4646
|
+
return optional(this);
|
|
4647
|
+
},
|
|
4648
|
+
exactOptional() {
|
|
4649
|
+
return exactOptional(this);
|
|
4650
|
+
},
|
|
4651
|
+
nullable() {
|
|
4652
|
+
return nullable(this);
|
|
4653
|
+
},
|
|
4654
|
+
nullish() {
|
|
4655
|
+
return optional(nullable(this));
|
|
4656
|
+
},
|
|
4657
|
+
nonoptional(params) {
|
|
4658
|
+
return nonoptional(this, params);
|
|
4659
|
+
},
|
|
4660
|
+
array() {
|
|
4661
|
+
return array(this);
|
|
4662
|
+
},
|
|
4663
|
+
or(arg) {
|
|
4664
|
+
return union([this, arg]);
|
|
4665
|
+
},
|
|
4666
|
+
and(arg) {
|
|
4667
|
+
return intersection(this, arg);
|
|
4668
|
+
},
|
|
4669
|
+
transform(tx) {
|
|
4670
|
+
return pipe(this, transform(tx));
|
|
4671
|
+
},
|
|
4672
|
+
default(d) {
|
|
4673
|
+
return _default(this, d);
|
|
4674
|
+
},
|
|
4675
|
+
prefault(d) {
|
|
4676
|
+
return prefault(this, d);
|
|
4677
|
+
},
|
|
4678
|
+
catch(params) {
|
|
4679
|
+
return _catch(this, params);
|
|
4680
|
+
},
|
|
4681
|
+
pipe(target) {
|
|
4682
|
+
return pipe(this, target);
|
|
4683
|
+
},
|
|
4684
|
+
readonly() {
|
|
4685
|
+
return readonly(this);
|
|
4686
|
+
},
|
|
4687
|
+
describe(description) {
|
|
4688
|
+
const cl = this.clone();
|
|
4689
|
+
globalRegistry.add(cl, { description });
|
|
4690
|
+
return cl;
|
|
4691
|
+
},
|
|
4692
|
+
meta(...args) {
|
|
4693
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
4694
|
+
const cl = this.clone();
|
|
4695
|
+
globalRegistry.add(cl, args[0]);
|
|
4696
|
+
return cl;
|
|
4697
|
+
},
|
|
4698
|
+
isOptional() {
|
|
4699
|
+
return this.safeParse(void 0).success;
|
|
4700
|
+
},
|
|
4701
|
+
isNullable() {
|
|
4702
|
+
return this.safeParse(null).success;
|
|
4703
|
+
},
|
|
4704
|
+
apply(fn, ...args) {
|
|
4705
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
4706
|
+
},
|
|
4707
|
+
get "~standard"() {
|
|
4708
|
+
return hide(this, "~standard", {
|
|
4709
|
+
...standardProps(this),
|
|
4710
|
+
jsonSchema: {
|
|
4711
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
4712
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
4713
|
+
}
|
|
4714
|
+
});
|
|
4715
|
+
},
|
|
4716
|
+
set "~standard"(value) {
|
|
4717
|
+
own(this, "~standard", value);
|
|
4718
|
+
},
|
|
4719
|
+
parse: function _parse(data, params) {
|
|
4720
|
+
return parse(this, data, params, { callee: _parse });
|
|
4721
|
+
},
|
|
4722
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
4723
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
4724
|
+
},
|
|
4725
|
+
safeParse(data, params) {
|
|
4726
|
+
return safeParse(this, data, params);
|
|
4727
|
+
},
|
|
4728
|
+
async safeParseAsync(data, params) {
|
|
4729
|
+
return safeParseAsync(this, data, params);
|
|
4730
|
+
},
|
|
4731
|
+
get spa() {
|
|
4732
|
+
return this?.safeParseAsync;
|
|
4733
|
+
},
|
|
4734
|
+
set spa(value) {
|
|
4735
|
+
own(this, "spa", value);
|
|
4736
|
+
},
|
|
4737
|
+
validate(data, params) {
|
|
4738
|
+
return validate(this, data, params);
|
|
4739
|
+
},
|
|
4740
|
+
validateAsync(data, params) {
|
|
4741
|
+
return validateAsync$1(this, data, params);
|
|
4742
|
+
},
|
|
4743
|
+
encode: function _encode(data, params) {
|
|
4744
|
+
return encode(this, data, params, { callee: _encode });
|
|
4745
|
+
},
|
|
4746
|
+
decode: function _decode(data, params) {
|
|
4747
|
+
return decode(this, data, params, { callee: _decode });
|
|
4748
|
+
},
|
|
4749
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
4750
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
4751
|
+
},
|
|
4752
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
4753
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
4754
|
+
},
|
|
4755
|
+
safeEncode(data, params) {
|
|
4756
|
+
return safeEncode(this, data, params);
|
|
4757
|
+
},
|
|
4758
|
+
safeDecode(data, params) {
|
|
4759
|
+
return safeDecode(this, data, params);
|
|
4760
|
+
},
|
|
4761
|
+
async safeEncodeAsync(data, params) {
|
|
4762
|
+
return safeEncodeAsync(this, data, params);
|
|
4763
|
+
},
|
|
4764
|
+
async safeDecodeAsync(data, params) {
|
|
4765
|
+
return safeDecodeAsync(this, data, params);
|
|
4766
|
+
},
|
|
4767
|
+
toJSONSchema(params) {
|
|
4768
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
4769
|
+
},
|
|
4770
|
+
get description() {
|
|
4771
|
+
return globalRegistry.get(this)?.description;
|
|
4772
|
+
},
|
|
4773
|
+
get _def() {
|
|
4774
|
+
return this._zod.def;
|
|
4775
|
+
}
|
|
3581
4776
|
});
|
|
3582
4777
|
/** @internal */
|
|
3583
4778
|
var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
3584
4779
|
$ZodString.init(inst, def);
|
|
3585
4780
|
ZodType.init(inst, def);
|
|
3586
4781
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
});
|
|
4782
|
+
}, /*@__PURE__*/ derived({
|
|
4783
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
4784
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
4785
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
4786
|
+
}, {
|
|
4787
|
+
regex(...args) {
|
|
4788
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4789
|
+
},
|
|
4790
|
+
includes(...args) {
|
|
4791
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4792
|
+
},
|
|
4793
|
+
startsWith(...args) {
|
|
4794
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4795
|
+
},
|
|
4796
|
+
endsWith(...args) {
|
|
4797
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4798
|
+
},
|
|
4799
|
+
min(...args) {
|
|
4800
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4801
|
+
},
|
|
4802
|
+
max(...args) {
|
|
4803
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4804
|
+
},
|
|
4805
|
+
length(...args) {
|
|
4806
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
4807
|
+
},
|
|
4808
|
+
nonempty(...args) {
|
|
4809
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4810
|
+
},
|
|
4811
|
+
lowercase(params) {
|
|
4812
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4813
|
+
},
|
|
4814
|
+
uppercase(params) {
|
|
4815
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4816
|
+
},
|
|
4817
|
+
trim() {
|
|
4818
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
4819
|
+
},
|
|
4820
|
+
normalize(...args) {
|
|
4821
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4822
|
+
},
|
|
4823
|
+
toLowerCase() {
|
|
4824
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4825
|
+
},
|
|
4826
|
+
toUpperCase() {
|
|
4827
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4828
|
+
},
|
|
4829
|
+
slugify() {
|
|
4830
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
4831
|
+
}
|
|
4832
|
+
}));
|
|
3639
4833
|
var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
3640
4834
|
$ZodString.init(inst, def);
|
|
3641
4835
|
_ZodString.init(inst, def);
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
4836
|
+
}, {
|
|
4837
|
+
email(params) {
|
|
4838
|
+
return this.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4839
|
+
},
|
|
4840
|
+
url(params) {
|
|
4841
|
+
return this.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4842
|
+
},
|
|
4843
|
+
jwt(params) {
|
|
4844
|
+
return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4845
|
+
},
|
|
4846
|
+
emoji(params) {
|
|
4847
|
+
return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4848
|
+
},
|
|
4849
|
+
guid(params) {
|
|
4850
|
+
return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4851
|
+
},
|
|
4852
|
+
uuid(params) {
|
|
4853
|
+
return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4854
|
+
},
|
|
4855
|
+
uuidv4(params) {
|
|
4856
|
+
return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4857
|
+
},
|
|
4858
|
+
uuidv6(params) {
|
|
4859
|
+
return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4860
|
+
},
|
|
4861
|
+
uuidv7(params) {
|
|
4862
|
+
return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4863
|
+
},
|
|
4864
|
+
nanoid(params) {
|
|
4865
|
+
return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4866
|
+
},
|
|
4867
|
+
cuid(params) {
|
|
4868
|
+
return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4869
|
+
},
|
|
4870
|
+
cuid2(params) {
|
|
4871
|
+
return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4872
|
+
},
|
|
4873
|
+
ulid(params) {
|
|
4874
|
+
return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4875
|
+
},
|
|
4876
|
+
base64(params) {
|
|
4877
|
+
return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4878
|
+
},
|
|
4879
|
+
base64url(params) {
|
|
4880
|
+
return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4881
|
+
},
|
|
4882
|
+
xid(params) {
|
|
4883
|
+
return this.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4884
|
+
},
|
|
4885
|
+
ksuid(params) {
|
|
4886
|
+
return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4887
|
+
},
|
|
4888
|
+
ipv4(params) {
|
|
4889
|
+
return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4890
|
+
},
|
|
4891
|
+
ipv6(params) {
|
|
4892
|
+
return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4893
|
+
},
|
|
4894
|
+
cidrv4(params) {
|
|
4895
|
+
return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4896
|
+
},
|
|
4897
|
+
cidrv6(params) {
|
|
4898
|
+
return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4899
|
+
},
|
|
4900
|
+
e164(params) {
|
|
4901
|
+
return this.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4902
|
+
},
|
|
4903
|
+
datetime(params) {
|
|
4904
|
+
return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
|
|
4905
|
+
},
|
|
4906
|
+
date(params) {
|
|
4907
|
+
return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
|
|
4908
|
+
},
|
|
4909
|
+
time(params) {
|
|
4910
|
+
return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
|
|
4911
|
+
},
|
|
4912
|
+
duration(params) {
|
|
4913
|
+
return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
|
|
4914
|
+
}
|
|
3669
4915
|
});
|
|
3670
4916
|
function string(params) {
|
|
3671
4917
|
return /* @__PURE__ */ _string(ZodString, params);
|
|
@@ -3674,6 +4920,22 @@ var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def)
|
|
|
3674
4920
|
$ZodStringFormat.init(inst, def);
|
|
3675
4921
|
_ZodString.init(inst, def);
|
|
3676
4922
|
});
|
|
4923
|
+
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4924
|
+
$ZodISODateTime.init(inst, def);
|
|
4925
|
+
ZodStringFormat.init(inst, def);
|
|
4926
|
+
});
|
|
4927
|
+
var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
4928
|
+
$ZodISODate.init(inst, def);
|
|
4929
|
+
ZodStringFormat.init(inst, def);
|
|
4930
|
+
});
|
|
4931
|
+
var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
4932
|
+
$ZodISOTime.init(inst, def);
|
|
4933
|
+
ZodStringFormat.init(inst, def);
|
|
4934
|
+
});
|
|
4935
|
+
var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
4936
|
+
$ZodISODuration.init(inst, def);
|
|
4937
|
+
ZodStringFormat.init(inst, def);
|
|
4938
|
+
});
|
|
3677
4939
|
var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
3678
4940
|
$ZodEmail.init(inst, def);
|
|
3679
4941
|
ZodStringFormat.init(inst, def);
|
|
@@ -3759,60 +5021,68 @@ var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
|
3759
5021
|
$ZodNumber.init(inst, def);
|
|
3760
5022
|
ZodType.init(inst, def);
|
|
3761
5023
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
3762
|
-
_installLazyMethods(inst, "ZodNumber", {
|
|
3763
|
-
gt(value, params) {
|
|
3764
|
-
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
3765
|
-
},
|
|
3766
|
-
gte(value, params) {
|
|
3767
|
-
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3768
|
-
},
|
|
3769
|
-
min(value, params) {
|
|
3770
|
-
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3771
|
-
},
|
|
3772
|
-
lt(value, params) {
|
|
3773
|
-
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
3774
|
-
},
|
|
3775
|
-
lte(value, params) {
|
|
3776
|
-
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3777
|
-
},
|
|
3778
|
-
max(value, params) {
|
|
3779
|
-
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3780
|
-
},
|
|
3781
|
-
int(params) {
|
|
3782
|
-
return this.check(int(params));
|
|
3783
|
-
},
|
|
3784
|
-
safe(params) {
|
|
3785
|
-
return this.check(int(params));
|
|
3786
|
-
},
|
|
3787
|
-
positive(params) {
|
|
3788
|
-
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
3789
|
-
},
|
|
3790
|
-
nonnegative(params) {
|
|
3791
|
-
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
3792
|
-
},
|
|
3793
|
-
negative(params) {
|
|
3794
|
-
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
3795
|
-
},
|
|
3796
|
-
nonpositive(params) {
|
|
3797
|
-
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
3798
|
-
},
|
|
3799
|
-
multipleOf(value, params) {
|
|
3800
|
-
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3801
|
-
},
|
|
3802
|
-
step(value, params) {
|
|
3803
|
-
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3804
|
-
},
|
|
3805
|
-
finite() {
|
|
3806
|
-
return this;
|
|
3807
|
-
}
|
|
3808
|
-
});
|
|
3809
|
-
const bag = inst._zod.bag;
|
|
3810
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3811
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3812
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
3813
5024
|
inst.isFinite = true;
|
|
3814
|
-
|
|
3815
|
-
|
|
5025
|
+
}, /*@__PURE__*/ derived({
|
|
5026
|
+
minValue: (inst) => {
|
|
5027
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
5028
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
5029
|
+
},
|
|
5030
|
+
maxValue: (inst) => {
|
|
5031
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
5032
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
5033
|
+
},
|
|
5034
|
+
isInt: (inst) => {
|
|
5035
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
5036
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
5037
|
+
},
|
|
5038
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
5039
|
+
}, {
|
|
5040
|
+
gt(value, params) {
|
|
5041
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
5042
|
+
},
|
|
5043
|
+
gte(value, params) {
|
|
5044
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
5045
|
+
},
|
|
5046
|
+
min(value, params) {
|
|
5047
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
5048
|
+
},
|
|
5049
|
+
lt(value, params) {
|
|
5050
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
5051
|
+
},
|
|
5052
|
+
lte(value, params) {
|
|
5053
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
5054
|
+
},
|
|
5055
|
+
max(value, params) {
|
|
5056
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
5057
|
+
},
|
|
5058
|
+
int(params) {
|
|
5059
|
+
return this.check(int(params));
|
|
5060
|
+
},
|
|
5061
|
+
safe(params) {
|
|
5062
|
+
return this.check(int(params));
|
|
5063
|
+
},
|
|
5064
|
+
positive(params) {
|
|
5065
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
5066
|
+
},
|
|
5067
|
+
nonnegative(params) {
|
|
5068
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
5069
|
+
},
|
|
5070
|
+
negative(params) {
|
|
5071
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
5072
|
+
},
|
|
5073
|
+
nonpositive(params) {
|
|
5074
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
5075
|
+
},
|
|
5076
|
+
multipleOf(value, params) {
|
|
5077
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
5078
|
+
},
|
|
5079
|
+
step(value, params) {
|
|
5080
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
5081
|
+
},
|
|
5082
|
+
finite() {
|
|
5083
|
+
return this;
|
|
5084
|
+
}
|
|
5085
|
+
}));
|
|
3816
5086
|
function number(params) {
|
|
3817
5087
|
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
3818
5088
|
}
|
|
@@ -3848,94 +5118,80 @@ function never(params) {
|
|
|
3848
5118
|
return /* @__PURE__ */ _never(ZodNever, params);
|
|
3849
5119
|
}
|
|
3850
5120
|
var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
5121
|
+
_ensureDefaultMemoizer();
|
|
3851
5122
|
$ZodArray.init(inst, def);
|
|
3852
5123
|
ZodType.init(inst, def);
|
|
3853
5124
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3854
5125
|
inst.element = def.element;
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
});
|
|
5126
|
+
}, {
|
|
5127
|
+
min(n, params) {
|
|
5128
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
5129
|
+
},
|
|
5130
|
+
nonempty(params) {
|
|
5131
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
5132
|
+
},
|
|
5133
|
+
max(n, params) {
|
|
5134
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
5135
|
+
},
|
|
5136
|
+
length(n, params) {
|
|
5137
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
5138
|
+
},
|
|
5139
|
+
unwrap() {
|
|
5140
|
+
return this.element;
|
|
5141
|
+
}
|
|
3872
5142
|
});
|
|
3873
5143
|
function array(element, params) {
|
|
3874
5144
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
3875
5145
|
}
|
|
3876
5146
|
var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
5147
|
+
_ensureDefaultMemoizer();
|
|
3877
5148
|
$ZodObjectJIT.init(inst, def);
|
|
3878
5149
|
ZodType.init(inst, def);
|
|
3879
5150
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
}
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
}
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
return merge(this, other);
|
|
3925
|
-
},
|
|
3926
|
-
pick(mask) {
|
|
3927
|
-
return pick(this, mask);
|
|
3928
|
-
},
|
|
3929
|
-
omit(mask) {
|
|
3930
|
-
return omit(this, mask);
|
|
3931
|
-
},
|
|
3932
|
-
partial(...args) {
|
|
3933
|
-
return partial(ZodOptional, this, args[0]);
|
|
3934
|
-
},
|
|
3935
|
-
required(...args) {
|
|
3936
|
-
return required(ZodNonOptional, this, args[0]);
|
|
3937
|
-
}
|
|
3938
|
-
});
|
|
5151
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
5152
|
+
}, {
|
|
5153
|
+
keyof() {
|
|
5154
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
5155
|
+
},
|
|
5156
|
+
catchall(catchall) {
|
|
5157
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
5158
|
+
},
|
|
5159
|
+
passthrough() {
|
|
5160
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5161
|
+
},
|
|
5162
|
+
loose() {
|
|
5163
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5164
|
+
},
|
|
5165
|
+
strict() {
|
|
5166
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
5167
|
+
},
|
|
5168
|
+
strip() {
|
|
5169
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
|
|
5170
|
+
},
|
|
5171
|
+
extend(incoming) {
|
|
5172
|
+
return extend(this, incoming);
|
|
5173
|
+
},
|
|
5174
|
+
safeExtend(incoming) {
|
|
5175
|
+
return safeExtend(this, incoming);
|
|
5176
|
+
},
|
|
5177
|
+
merge(other) {
|
|
5178
|
+
return merge(this, other);
|
|
5179
|
+
},
|
|
5180
|
+
pick(mask) {
|
|
5181
|
+
return pick(this, mask);
|
|
5182
|
+
},
|
|
5183
|
+
omit(mask) {
|
|
5184
|
+
return omit(this, mask);
|
|
5185
|
+
},
|
|
5186
|
+
partial(...args) {
|
|
5187
|
+
return partial(ZodOptional, this, args[0]);
|
|
5188
|
+
},
|
|
5189
|
+
exactPartial(...args) {
|
|
5190
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
5191
|
+
},
|
|
5192
|
+
required(...args) {
|
|
5193
|
+
return required(ZodNonOptional, this, args[0]);
|
|
5194
|
+
}
|
|
3939
5195
|
});
|
|
3940
5196
|
function object(shape, params) {
|
|
3941
5197
|
return new ZodObject({
|
|
@@ -3970,6 +5226,7 @@ function intersection(left, right) {
|
|
|
3970
5226
|
});
|
|
3971
5227
|
}
|
|
3972
5228
|
var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
5229
|
+
_ensureDefaultMemoizer();
|
|
3973
5230
|
$ZodRecord.init(inst, def);
|
|
3974
5231
|
ZodType.init(inst, def);
|
|
3975
5232
|
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
@@ -3995,7 +5252,7 @@ var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
|
3995
5252
|
ZodType.init(inst, def);
|
|
3996
5253
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3997
5254
|
inst.enum = def.entries;
|
|
3998
|
-
inst.options =
|
|
5255
|
+
inst.options = [...inst._zod.values];
|
|
3999
5256
|
const keys = new Set(Object.keys(def.entries));
|
|
4000
5257
|
inst.extract = (values, params) => {
|
|
4001
5258
|
const newEntries = {};
|
|
@@ -4045,6 +5302,7 @@ function literal(value, params) {
|
|
|
4045
5302
|
});
|
|
4046
5303
|
}
|
|
4047
5304
|
var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
5305
|
+
_ensureDefaultMemoizer();
|
|
4048
5306
|
$ZodTransform.init(inst, def);
|
|
4049
5307
|
ZodType.init(inst, def);
|
|
4050
5308
|
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
@@ -4056,7 +5314,7 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
4056
5314
|
const _issue = issue$1;
|
|
4057
5315
|
if (_issue.fatal) _issue.continue = false;
|
|
4058
5316
|
_issue.code ?? (_issue.code = "custom");
|
|
4059
|
-
|
|
5317
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
4060
5318
|
_issue.inst ?? (_issue.inst = inst);
|
|
4061
5319
|
payload.issues.push(issue(_issue));
|
|
4062
5320
|
}
|
|
@@ -4064,11 +5322,9 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
4064
5322
|
const output = def.transform(payload.value, payload);
|
|
4065
5323
|
if (output instanceof Promise) return output.then((output) => {
|
|
4066
5324
|
payload.value = output;
|
|
4067
|
-
payload.fallback = true;
|
|
4068
5325
|
return payload;
|
|
4069
5326
|
});
|
|
4070
5327
|
payload.value = output;
|
|
4071
|
-
payload.fallback = true;
|
|
4072
5328
|
return payload;
|
|
4073
5329
|
};
|
|
4074
5330
|
});
|
|
@@ -4169,7 +5425,7 @@ function _catch(innerType, catchValue) {
|
|
|
4169
5425
|
return new ZodCatch({
|
|
4170
5426
|
type: "catch",
|
|
4171
5427
|
innerType,
|
|
4172
|
-
catchValue: typeof catchValue === "function" ? catchValue : ()
|
|
5428
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
4173
5429
|
});
|
|
4174
5430
|
}
|
|
4175
5431
|
var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
@@ -4212,4 +5468,4 @@ function superRefine(fn, params) {
|
|
|
4212
5468
|
//#endregion
|
|
4213
5469
|
export { number as a, string as c, literal as i, unknown as l, array as n, object as o, boolean as r, record as s, _enum as t };
|
|
4214
5470
|
|
|
4215
|
-
//# sourceMappingURL=schemas-
|
|
5471
|
+
//# sourceMappingURL=schemas-BzNluG2q.js.map
|