@mulmoclaude/google-plugin 3.0.0 → 3.0.2
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/index.js +2336 -1156
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -52,82 +52,34 @@ function definePlugin(setup) {
|
|
|
52
52
|
return setup;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region ../../../node_modules/zod/v4/core/core.js
|
|
56
|
-
var _a$1;
|
|
57
|
-
function $constructor(name, initializer, params) {
|
|
58
|
-
function init(inst, def) {
|
|
59
|
-
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
60
|
-
value: {
|
|
61
|
-
def,
|
|
62
|
-
constr: _,
|
|
63
|
-
traits: /* @__PURE__ */ new Set()
|
|
64
|
-
},
|
|
65
|
-
enumerable: false
|
|
66
|
-
});
|
|
67
|
-
if (inst._zod.traits.has(name)) return;
|
|
68
|
-
inst._zod.traits.add(name);
|
|
69
|
-
initializer(inst, def);
|
|
70
|
-
const proto = _.prototype;
|
|
71
|
-
const keys = Object.keys(proto);
|
|
72
|
-
for (let i = 0; i < keys.length; i++) {
|
|
73
|
-
const k = keys[i];
|
|
74
|
-
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const Parent = params?.Parent ?? Object;
|
|
78
|
-
class Definition extends Parent {}
|
|
79
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
80
|
-
function _(def) {
|
|
81
|
-
var _a;
|
|
82
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
83
|
-
init(inst, def);
|
|
84
|
-
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
85
|
-
for (const fn of inst._zod.deferred) fn();
|
|
86
|
-
return inst;
|
|
87
|
-
}
|
|
88
|
-
Object.defineProperty(_, "init", { value: init });
|
|
89
|
-
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
90
|
-
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
91
|
-
return inst?._zod?.traits?.has(name);
|
|
92
|
-
} });
|
|
93
|
-
Object.defineProperty(_, "name", { value: name });
|
|
94
|
-
return _;
|
|
95
|
-
}
|
|
96
|
-
var $ZodAsyncError = class extends Error {
|
|
97
|
-
constructor() {
|
|
98
|
-
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var $ZodEncodeError = class extends Error {
|
|
102
|
-
constructor(name) {
|
|
103
|
-
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
104
|
-
this.name = "ZodEncodeError";
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
108
|
-
var globalConfig = globalThis.__zod_globalConfig;
|
|
109
|
-
function config(newConfig) {
|
|
110
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
111
|
-
return globalConfig;
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
55
|
//#region ../../../node_modules/zod/v4/core/util.js
|
|
115
56
|
function getEnumValues(entries) {
|
|
116
57
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
117
58
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
118
59
|
}
|
|
60
|
+
function joinValues(array, separator = "|") {
|
|
61
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
62
|
+
}
|
|
119
63
|
function jsonStringifyReplacer(_, value) {
|
|
120
64
|
if (typeof value === "bigint") return value.toString();
|
|
121
65
|
return value;
|
|
122
66
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
67
|
+
var Cached = class {
|
|
68
|
+
constructor(getter) {
|
|
69
|
+
this._getter = getter;
|
|
70
|
+
this._value = void 0;
|
|
71
|
+
}
|
|
72
|
+
get value() {
|
|
73
|
+
const getter = this._getter;
|
|
74
|
+
if (getter !== void 0) {
|
|
75
|
+
this._value = getter();
|
|
76
|
+
this._getter = void 0;
|
|
129
77
|
}
|
|
130
|
-
|
|
78
|
+
return this._value;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function cached(getter) {
|
|
82
|
+
return new Cached(getter);
|
|
131
83
|
}
|
|
132
84
|
function nullish(input) {
|
|
133
85
|
return input === null || input === void 0;
|
|
@@ -140,28 +92,10 @@ function cleanRegex(source) {
|
|
|
140
92
|
function floatSafeRemainder(val, step) {
|
|
141
93
|
const ratio = val / step;
|
|
142
94
|
const roundedRatio = Math.round(ratio);
|
|
143
|
-
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
95
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
144
96
|
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
145
97
|
return ratio - roundedRatio;
|
|
146
98
|
}
|
|
147
|
-
var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
|
148
|
-
function defineLazy(object, key, getter) {
|
|
149
|
-
let value = void 0;
|
|
150
|
-
Object.defineProperty(object, key, {
|
|
151
|
-
get() {
|
|
152
|
-
if (value === EVALUATING) return;
|
|
153
|
-
if (value === void 0) {
|
|
154
|
-
value = EVALUATING;
|
|
155
|
-
value = getter();
|
|
156
|
-
}
|
|
157
|
-
return value;
|
|
158
|
-
},
|
|
159
|
-
set(v) {
|
|
160
|
-
Object.defineProperty(object, key, { value: v });
|
|
161
|
-
},
|
|
162
|
-
configurable: true
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
99
|
function assignProp(target, prop, value) {
|
|
166
100
|
Object.defineProperty(target, prop, {
|
|
167
101
|
value,
|
|
@@ -170,6 +104,58 @@ function assignProp(target, prop, value) {
|
|
|
170
104
|
configurable: true
|
|
171
105
|
});
|
|
172
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
109
|
+
*
|
|
110
|
+
* 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.
|
|
111
|
+
*/
|
|
112
|
+
function rawShape(def) {
|
|
113
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
114
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
115
|
+
}
|
|
116
|
+
function sourceShape(schema) {
|
|
117
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
118
|
+
}
|
|
119
|
+
function deferProp(target, key, getter) {
|
|
120
|
+
Object.defineProperty(target, key, {
|
|
121
|
+
get() {
|
|
122
|
+
const value = getter();
|
|
123
|
+
assignProp(this, key, value);
|
|
124
|
+
return value;
|
|
125
|
+
},
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function putProp(target, key, value) {
|
|
131
|
+
if (key in target) assignProp(target, key, value);
|
|
132
|
+
else target[key] = value;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
136
|
+
*
|
|
137
|
+
* 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.
|
|
138
|
+
*/
|
|
139
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
140
|
+
const raw = sourceShape(source);
|
|
141
|
+
for (const key of keys) {
|
|
142
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
143
|
+
if (!desc.enumerable) continue;
|
|
144
|
+
if (desc.get) deferProp(target, key, () => {
|
|
145
|
+
const value = source._zod.def.shape[key];
|
|
146
|
+
return wrap ? wrap(value, key) : value;
|
|
147
|
+
});
|
|
148
|
+
else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function mirrorProps(target, source) {
|
|
152
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
153
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
154
|
+
if (!desc.enumerable) continue;
|
|
155
|
+
if (desc.get) deferProp(target, key, () => source[key]);
|
|
156
|
+
else putProp(target, key, desc.value);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
173
159
|
function mergeDefs(...defs) {
|
|
174
160
|
const mergedDescriptors = {};
|
|
175
161
|
for (const def of defs) {
|
|
@@ -243,51 +229,56 @@ function normalizeParams(_params) {
|
|
|
243
229
|
};
|
|
244
230
|
return params;
|
|
245
231
|
}
|
|
232
|
+
function stringifyPrimitive(value) {
|
|
233
|
+
if (typeof value === "bigint") return value.toString() + "n";
|
|
234
|
+
if (typeof value === "string") return `"${value}"`;
|
|
235
|
+
return `${value}`;
|
|
236
|
+
}
|
|
246
237
|
function optionalKeys(shape) {
|
|
247
238
|
return Object.keys(shape).filter((k) => {
|
|
248
|
-
return shape[k]._zod.optin
|
|
239
|
+
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
|
|
249
240
|
});
|
|
250
241
|
}
|
|
251
|
-
var NUMBER_FORMAT_RANGES = {
|
|
242
|
+
var NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
|
|
252
243
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
253
244
|
int32: [-2147483648, 2147483647],
|
|
254
245
|
uint32: [0, 4294967295],
|
|
255
246
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
256
247
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
248
|
+
}))();
|
|
249
|
+
var BIGINT_FORMAT_RANGES = {
|
|
250
|
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
251
|
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
|
|
257
252
|
};
|
|
258
253
|
function pick(schema, mask) {
|
|
259
254
|
const currDef = schema._zod.def;
|
|
260
255
|
const checks = currDef.checks;
|
|
261
256
|
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
267
|
-
if (!mask[key]) continue;
|
|
268
|
-
newShape[key] = currDef.shape[key];
|
|
269
|
-
}
|
|
270
|
-
assignProp(this, "shape", newShape);
|
|
271
|
-
return newShape;
|
|
272
|
-
},
|
|
257
|
+
const newShape = {};
|
|
258
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
259
|
+
return clone(schema, mergeDefs(currDef, {
|
|
260
|
+
shape: newShape,
|
|
273
261
|
checks: []
|
|
274
262
|
}));
|
|
275
263
|
}
|
|
264
|
+
function maskedKeys(schema, mask) {
|
|
265
|
+
const raw = sourceShape(schema);
|
|
266
|
+
const keys = [];
|
|
267
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
268
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
269
|
+
if (mask[key]) keys.push(key);
|
|
270
|
+
}
|
|
271
|
+
return keys;
|
|
272
|
+
}
|
|
276
273
|
function omit(schema, mask) {
|
|
277
274
|
const currDef = schema._zod.def;
|
|
278
275
|
const checks = currDef.checks;
|
|
279
276
|
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (!mask[key]) continue;
|
|
286
|
-
delete newShape[key];
|
|
287
|
-
}
|
|
288
|
-
assignProp(this, "shape", newShape);
|
|
289
|
-
return newShape;
|
|
290
|
-
},
|
|
277
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
278
|
+
const newShape = {};
|
|
279
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
280
|
+
return clone(schema, mergeDefs(currDef, {
|
|
281
|
+
shape: newShape,
|
|
291
282
|
checks: []
|
|
292
283
|
}));
|
|
293
284
|
}
|
|
@@ -295,90 +286,57 @@ function extend(schema, shape) {
|
|
|
295
286
|
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
296
287
|
const checks = schema._zod.def.checks;
|
|
297
288
|
if (checks && checks.length > 0) {
|
|
298
|
-
const existingShape = schema
|
|
299
|
-
for (const key
|
|
289
|
+
const existingShape = sourceShape(schema);
|
|
290
|
+
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.");
|
|
300
291
|
}
|
|
301
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
} }));
|
|
292
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
293
|
+
}
|
|
294
|
+
function extended(schema, shape) {
|
|
295
|
+
const newShape = {};
|
|
296
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
297
|
+
mirrorProps(newShape, shape);
|
|
298
|
+
return newShape;
|
|
309
299
|
}
|
|
310
300
|
function safeExtend(schema, shape) {
|
|
311
301
|
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
312
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
313
|
-
const _shape = {
|
|
314
|
-
...schema._zod.def.shape,
|
|
315
|
-
...shape
|
|
316
|
-
};
|
|
317
|
-
assignProp(this, "shape", _shape);
|
|
318
|
-
return _shape;
|
|
319
|
-
} }));
|
|
302
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
320
303
|
}
|
|
321
304
|
function merge(a, b) {
|
|
305
|
+
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
322
306
|
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
307
|
+
const newShape = {};
|
|
308
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
309
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
323
310
|
return clone(a, mergeDefs(a._zod.def, {
|
|
324
|
-
|
|
325
|
-
const _shape = {
|
|
326
|
-
...a._zod.def.shape,
|
|
327
|
-
...b._zod.def.shape
|
|
328
|
-
};
|
|
329
|
-
assignProp(this, "shape", _shape);
|
|
330
|
-
return _shape;
|
|
331
|
-
},
|
|
311
|
+
shape: newShape,
|
|
332
312
|
get catchall() {
|
|
333
313
|
return b._zod.def.catchall;
|
|
334
314
|
},
|
|
335
315
|
checks: b._zod.def.checks ?? []
|
|
336
316
|
}));
|
|
337
317
|
}
|
|
338
|
-
function partial(Class, schema, mask) {
|
|
318
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
339
319
|
const checks = schema._zod.def.checks;
|
|
340
|
-
if (checks && checks.length > 0) throw new Error(
|
|
320
|
+
if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
321
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
322
|
+
const newShape = {};
|
|
323
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
|
|
324
|
+
type: "optional",
|
|
325
|
+
innerType: value
|
|
326
|
+
})));
|
|
341
327
|
return clone(schema, mergeDefs(schema._zod.def, {
|
|
342
|
-
|
|
343
|
-
const oldShape = schema._zod.def.shape;
|
|
344
|
-
const shape = { ...oldShape };
|
|
345
|
-
if (mask) for (const key in mask) {
|
|
346
|
-
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
347
|
-
if (!mask[key]) continue;
|
|
348
|
-
shape[key] = Class ? new Class({
|
|
349
|
-
type: "optional",
|
|
350
|
-
innerType: oldShape[key]
|
|
351
|
-
}) : oldShape[key];
|
|
352
|
-
}
|
|
353
|
-
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
354
|
-
type: "optional",
|
|
355
|
-
innerType: oldShape[key]
|
|
356
|
-
}) : oldShape[key];
|
|
357
|
-
assignProp(this, "shape", shape);
|
|
358
|
-
return shape;
|
|
359
|
-
},
|
|
328
|
+
shape: newShape,
|
|
360
329
|
checks: []
|
|
361
330
|
}));
|
|
362
331
|
}
|
|
363
332
|
function required(Class, schema, mask) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
type: "nonoptional",
|
|
372
|
-
innerType: oldShape[key]
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
else for (const key in oldShape) shape[key] = new Class({
|
|
376
|
-
type: "nonoptional",
|
|
377
|
-
innerType: oldShape[key]
|
|
378
|
-
});
|
|
379
|
-
assignProp(this, "shape", shape);
|
|
380
|
-
return shape;
|
|
381
|
-
} }));
|
|
333
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
334
|
+
const newShape = {};
|
|
335
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
|
|
336
|
+
type: "nonoptional",
|
|
337
|
+
innerType: value
|
|
338
|
+
}));
|
|
339
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
382
340
|
}
|
|
383
341
|
function aborted(x, startIndex = 0) {
|
|
384
342
|
if (x.aborted === true) return true;
|
|
@@ -401,19 +359,58 @@ function prefixIssues(path, issues) {
|
|
|
401
359
|
function unwrapMessage(message) {
|
|
402
360
|
return typeof message === "string" ? message : message?.message;
|
|
403
361
|
}
|
|
362
|
+
function attachSchema(issues, start, inst) {
|
|
363
|
+
var _a;
|
|
364
|
+
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
|
|
365
|
+
}
|
|
404
366
|
function finalizeIssue(iss, ctx, config) {
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
367
|
+
var _a;
|
|
368
|
+
const traits = iss.inst?._zod?.traits;
|
|
369
|
+
if (traits?.has("$ZodType")) {
|
|
370
|
+
if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
|
|
371
|
+
else iss.schema = iss.inst;
|
|
372
|
+
}
|
|
373
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
374
|
+
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";
|
|
375
|
+
const full = {};
|
|
376
|
+
for (const k of Object.keys(iss)) {
|
|
377
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
|
|
378
|
+
full[k] = iss[k];
|
|
379
|
+
}
|
|
380
|
+
full.path ?? (full.path = []);
|
|
381
|
+
full.message = message;
|
|
382
|
+
if (ctx?.reportInput) full.input = iss.input;
|
|
383
|
+
return full;
|
|
384
|
+
}
|
|
385
|
+
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
386
|
+
function codePointLength(str) {
|
|
387
|
+
const units = str.length;
|
|
388
|
+
if (!highSurrogate.test(str)) return units;
|
|
389
|
+
let count = units;
|
|
390
|
+
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
391
|
+
count--;
|
|
392
|
+
i++;
|
|
393
|
+
}
|
|
394
|
+
return count;
|
|
411
395
|
}
|
|
412
396
|
function getLengthableOrigin(input) {
|
|
413
397
|
if (Array.isArray(input)) return "array";
|
|
414
398
|
if (typeof input === "string") return "string";
|
|
415
399
|
return "unknown";
|
|
416
400
|
}
|
|
401
|
+
function parsedType(data) {
|
|
402
|
+
const t = typeof data;
|
|
403
|
+
switch (t) {
|
|
404
|
+
case "number": return Number.isNaN(data) ? "nan" : "number";
|
|
405
|
+
case "object": {
|
|
406
|
+
if (data === null) return "null";
|
|
407
|
+
if (Array.isArray(data)) return "array";
|
|
408
|
+
const obj = data;
|
|
409
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return t;
|
|
413
|
+
}
|
|
417
414
|
function issue(...args) {
|
|
418
415
|
const [iss, input, inst] = args;
|
|
419
416
|
if (typeof iss === "string") return {
|
|
@@ -424,33 +421,339 @@ function issue(...args) {
|
|
|
424
421
|
};
|
|
425
422
|
return { ...iss };
|
|
426
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* 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.
|
|
426
|
+
*
|
|
427
|
+
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
|
|
428
|
+
*/
|
|
429
|
+
function members(proto, table) {
|
|
430
|
+
for (const key in table) {
|
|
431
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
432
|
+
if (desc.get) Object.defineProperty(proto, key, {
|
|
433
|
+
...desc,
|
|
434
|
+
enumerable: false
|
|
435
|
+
});
|
|
436
|
+
else defineBound(proto, key, desc.value);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
440
|
+
function own(inst, key, value, enumerable = true) {
|
|
441
|
+
Object.defineProperty(inst, key, {
|
|
442
|
+
configurable: true,
|
|
443
|
+
writable: true,
|
|
444
|
+
enumerable,
|
|
445
|
+
value
|
|
446
|
+
});
|
|
447
|
+
return value;
|
|
448
|
+
}
|
|
449
|
+
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
|
|
450
|
+
function hide(inst, key, value) {
|
|
451
|
+
return own(inst, key, value, false);
|
|
452
|
+
}
|
|
453
|
+
/** 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. */
|
|
454
|
+
function derived(computes, table) {
|
|
455
|
+
for (const key in computes) {
|
|
456
|
+
const compute = computes[key];
|
|
457
|
+
Object.defineProperty(table, key, {
|
|
458
|
+
configurable: true,
|
|
459
|
+
enumerable: true,
|
|
460
|
+
get() {
|
|
461
|
+
return own(this, key, compute(this));
|
|
462
|
+
},
|
|
463
|
+
set(value) {
|
|
464
|
+
own(this, key, value);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return table;
|
|
469
|
+
}
|
|
470
|
+
function defineBound(proto, key, fn) {
|
|
471
|
+
Object.defineProperty(proto, key, {
|
|
472
|
+
configurable: true,
|
|
473
|
+
get() {
|
|
474
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
475
|
+
},
|
|
476
|
+
set(value) {
|
|
477
|
+
own(this, key, value);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
|
|
482
|
+
function claim(inst, sentinel) {
|
|
483
|
+
const proto = Object.getPrototypeOf(inst);
|
|
484
|
+
return sentinel in proto ? void 0 : proto;
|
|
485
|
+
}
|
|
486
|
+
var installing;
|
|
487
|
+
var broke = false;
|
|
488
|
+
var breaker = {
|
|
489
|
+
configurable: true,
|
|
490
|
+
get() {
|
|
491
|
+
broke = true;
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
|
|
496
|
+
* constructor, computed from the internals object itself and cached there on
|
|
497
|
+
* first read. One accessor per constructor rather than one per instance.
|
|
498
|
+
*/
|
|
499
|
+
function defineLazyInternal(inst, key, compute) {
|
|
500
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
501
|
+
if (key in proto && installing !== inst._zod) {
|
|
502
|
+
installing = void 0;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
installing = inst._zod;
|
|
506
|
+
Object.defineProperty(proto, key, {
|
|
507
|
+
configurable: true,
|
|
508
|
+
get() {
|
|
509
|
+
Object.defineProperty(this, key, breaker);
|
|
510
|
+
const outer = broke;
|
|
511
|
+
broke = false;
|
|
512
|
+
try {
|
|
513
|
+
const value = compute(this);
|
|
514
|
+
if (broke) delete this[key];
|
|
515
|
+
else Object.defineProperty(this, key, {
|
|
516
|
+
configurable: true,
|
|
517
|
+
writable: true,
|
|
518
|
+
value
|
|
519
|
+
});
|
|
520
|
+
broke = broke || outer;
|
|
521
|
+
return value;
|
|
522
|
+
} catch (err) {
|
|
523
|
+
delete this[key];
|
|
524
|
+
broke = broke || outer;
|
|
525
|
+
throw err;
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
set(value) {
|
|
529
|
+
Object.defineProperty(this, key, {
|
|
530
|
+
configurable: true,
|
|
531
|
+
writable: true,
|
|
532
|
+
value
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
|
|
539
|
+
* data property. One accessor per constructor rather than one per instance, because an own accessor
|
|
540
|
+
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
|
|
541
|
+
*/
|
|
542
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
543
|
+
const proto = claim(inst, key);
|
|
544
|
+
if (!proto) return;
|
|
545
|
+
Object.defineProperty(proto, key, {
|
|
546
|
+
configurable: true,
|
|
547
|
+
get() {
|
|
548
|
+
const desc = {
|
|
549
|
+
configurable: true,
|
|
550
|
+
writable: true,
|
|
551
|
+
enumerable,
|
|
552
|
+
value: void 0
|
|
553
|
+
};
|
|
554
|
+
Object.defineProperty(this, key, desc);
|
|
555
|
+
desc.value = make(this);
|
|
556
|
+
Object.defineProperty(this, key, desc);
|
|
557
|
+
return desc.value;
|
|
558
|
+
},
|
|
559
|
+
set(value) {
|
|
560
|
+
Object.defineProperty(this, key, {
|
|
561
|
+
configurable: true,
|
|
562
|
+
writable: true,
|
|
563
|
+
enumerable,
|
|
564
|
+
value
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
/** 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. */
|
|
570
|
+
var CONSTANT_CATCH = "~constantCatch";
|
|
571
|
+
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
|
|
572
|
+
function constantCatch(value) {
|
|
573
|
+
const fn = () => value;
|
|
574
|
+
fn[CONSTANT_CATCH] = true;
|
|
575
|
+
return fn;
|
|
576
|
+
}
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region ../../../node_modules/zod/v4/core/core.js
|
|
579
|
+
var _a$1;
|
|
580
|
+
var _zodDesc = {
|
|
581
|
+
value: void 0,
|
|
582
|
+
enumerable: false
|
|
583
|
+
};
|
|
584
|
+
var _E = "captureStackTrace" in Error ? Error : null;
|
|
585
|
+
function newError(Definition) {
|
|
586
|
+
const E = _E;
|
|
587
|
+
if (E) {
|
|
588
|
+
const saved = E.stackTraceLimit;
|
|
589
|
+
if (typeof saved === "number") {
|
|
590
|
+
try {
|
|
591
|
+
E.stackTraceLimit = 0;
|
|
592
|
+
} catch {
|
|
593
|
+
_E = null;
|
|
594
|
+
return new Definition();
|
|
595
|
+
}
|
|
596
|
+
try {
|
|
597
|
+
return new Definition();
|
|
598
|
+
} finally {
|
|
599
|
+
E.stackTraceLimit = saved;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return new Definition();
|
|
604
|
+
}
|
|
605
|
+
function $constructor(name, initializer, proto, params) {
|
|
606
|
+
const zodProto = {};
|
|
607
|
+
function Internals(def) {
|
|
608
|
+
this.def = def;
|
|
609
|
+
this.constr = _;
|
|
610
|
+
this.traits = /* @__PURE__ */ new Set();
|
|
611
|
+
}
|
|
612
|
+
Internals.prototype = zodProto;
|
|
613
|
+
const protoMembers = proto;
|
|
614
|
+
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
615
|
+
function init(inst, def) {
|
|
616
|
+
if (!inst._zod) {
|
|
617
|
+
_zodDesc.value = new Internals(def);
|
|
618
|
+
try {
|
|
619
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
620
|
+
} finally {
|
|
621
|
+
_zodDesc.value = void 0;
|
|
622
|
+
}
|
|
623
|
+
} else if (inst._zod.traits.has(name)) return;
|
|
624
|
+
inst._zod.traits.add(name);
|
|
625
|
+
initializer(inst, def);
|
|
626
|
+
if (initialized) {
|
|
627
|
+
const own = Object.getPrototypeOf(inst);
|
|
628
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
629
|
+
let up = own;
|
|
630
|
+
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
631
|
+
const target = up ?? own;
|
|
632
|
+
if (!initialized.has(target)) {
|
|
633
|
+
initialized.add(target);
|
|
634
|
+
members(target, protoMembers);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
const proto = _.prototype;
|
|
638
|
+
for (const k in proto) {
|
|
639
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
640
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const Parent = params?.Parent ?? Object;
|
|
644
|
+
class Definition extends Parent {}
|
|
645
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
646
|
+
function _(def) {
|
|
647
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
648
|
+
init(inst, def);
|
|
649
|
+
const deferred = inst._zod.deferred;
|
|
650
|
+
if (deferred) {
|
|
651
|
+
for (const fn of deferred) fn();
|
|
652
|
+
inst._zod.deferred = void 0;
|
|
653
|
+
}
|
|
654
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
655
|
+
if (pp) pp(inst);
|
|
656
|
+
return inst;
|
|
657
|
+
}
|
|
658
|
+
Object.defineProperty(_, "init", { value: init });
|
|
659
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
660
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
661
|
+
return inst?._zod?.traits?.has(name);
|
|
662
|
+
} });
|
|
663
|
+
Object.defineProperty(_, "name", { value: name });
|
|
664
|
+
return _;
|
|
665
|
+
}
|
|
666
|
+
var $ZodAsyncError = class extends Error {
|
|
667
|
+
constructor() {
|
|
668
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
var $ZodEncodeError = class extends Error {
|
|
672
|
+
constructor(name) {
|
|
673
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
674
|
+
this.name = "ZodEncodeError";
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
678
|
+
var globalConfig = globalThis.__zod_globalConfig;
|
|
679
|
+
function config(newConfig) {
|
|
680
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
681
|
+
return globalConfig;
|
|
682
|
+
}
|
|
427
683
|
//#endregion
|
|
428
684
|
//#region ../../../node_modules/zod/v4/core/errors.js
|
|
685
|
+
function _getMessage() {
|
|
686
|
+
const internals = this._zod;
|
|
687
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
688
|
+
return internals.message;
|
|
689
|
+
}
|
|
690
|
+
function _setMessage(value) {
|
|
691
|
+
this._zod.message = value;
|
|
692
|
+
}
|
|
693
|
+
var _messageDesc = {
|
|
694
|
+
get: _getMessage,
|
|
695
|
+
set: _setMessage,
|
|
696
|
+
enumerable: true,
|
|
697
|
+
configurable: true
|
|
698
|
+
};
|
|
699
|
+
var _issuesDesc = {
|
|
700
|
+
value: void 0,
|
|
701
|
+
enumerable: false
|
|
702
|
+
};
|
|
703
|
+
var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
429
704
|
var initializer$1 = (inst, def) => {
|
|
430
705
|
inst.name = "$ZodError";
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
Object.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
706
|
+
_issuesDesc.value = def;
|
|
707
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
708
|
+
_issuesDesc.value = void 0;
|
|
709
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
710
|
+
const proto = Object.getPrototypeOf(inst);
|
|
711
|
+
if (!_installedToString.has(proto)) {
|
|
712
|
+
_installedToString.add(proto);
|
|
713
|
+
Object.defineProperty(proto, "toString", {
|
|
714
|
+
configurable: true,
|
|
715
|
+
enumerable: false,
|
|
716
|
+
get() {
|
|
717
|
+
const value = () => this.message;
|
|
718
|
+
Object.defineProperty(this, "toString", {
|
|
719
|
+
value,
|
|
720
|
+
configurable: true,
|
|
721
|
+
writable: true
|
|
722
|
+
});
|
|
723
|
+
return value;
|
|
724
|
+
},
|
|
725
|
+
set(value) {
|
|
726
|
+
Object.defineProperty(this, "toString", {
|
|
727
|
+
value,
|
|
728
|
+
configurable: true,
|
|
729
|
+
writable: true
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|
|
444
734
|
};
|
|
445
735
|
var $ZodError = $constructor("$ZodError", initializer$1);
|
|
446
|
-
|
|
736
|
+
$constructor("$ZodError", initializer$1, void 0, { Parent: Error });
|
|
737
|
+
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
738
|
+
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
739
|
+
* "__proto__" would hit the setter instead of creating a key. */
|
|
740
|
+
function node(obj, key, make) {
|
|
741
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
742
|
+
if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
743
|
+
value: make(),
|
|
744
|
+
writable: true,
|
|
745
|
+
enumerable: true,
|
|
746
|
+
configurable: true
|
|
747
|
+
});
|
|
748
|
+
else obj[key] = make();
|
|
749
|
+
}
|
|
750
|
+
return obj[key];
|
|
751
|
+
}
|
|
447
752
|
function flattenError(error, mapper = (issue) => issue.message) {
|
|
448
753
|
const fieldErrors = {};
|
|
449
754
|
const formErrors = [];
|
|
450
|
-
for (const sub of error.issues) if (sub.path.length > 0)
|
|
451
|
-
|
|
452
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
453
|
-
} else formErrors.push(mapper(sub));
|
|
755
|
+
for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
756
|
+
else formErrors.push(mapper(sub));
|
|
454
757
|
return {
|
|
455
758
|
formErrors,
|
|
456
759
|
fieldErrors
|
|
@@ -470,12 +773,21 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
470
773
|
let i = 0;
|
|
471
774
|
while (i < fullpath.length) {
|
|
472
775
|
const el = fullpath[i];
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
776
|
+
const terminal = i === fullpath.length - 1;
|
|
777
|
+
if (el === "_errors") {
|
|
778
|
+
if (terminal) curr._errors.push(mapper(issue));
|
|
779
|
+
i++;
|
|
780
|
+
continue;
|
|
477
781
|
}
|
|
478
|
-
curr
|
|
782
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
|
|
783
|
+
value: { _errors: [] },
|
|
784
|
+
enumerable: true,
|
|
785
|
+
writable: true,
|
|
786
|
+
configurable: true
|
|
787
|
+
});
|
|
788
|
+
const node = curr[el];
|
|
789
|
+
if (terminal) node._errors.push(mapper(issue));
|
|
790
|
+
curr = node;
|
|
479
791
|
i++;
|
|
480
792
|
}
|
|
481
793
|
}
|
|
@@ -486,39 +798,51 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
486
798
|
}
|
|
487
799
|
//#endregion
|
|
488
800
|
//#region ../../../node_modules/zod/v4/core/parse.js
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
801
|
+
function finalizeParams(callee, params) {
|
|
802
|
+
return {
|
|
803
|
+
callee: params?.callee ?? callee,
|
|
804
|
+
Err: params?.Err
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
var _parse = (_Err) => {
|
|
808
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
809
|
+
const ctx = _ctx ? {
|
|
810
|
+
..._ctx,
|
|
811
|
+
async: false
|
|
812
|
+
} : { async: false };
|
|
813
|
+
const result = schema._zod.run({
|
|
814
|
+
value,
|
|
815
|
+
issues: []
|
|
816
|
+
}, ctx);
|
|
817
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
818
|
+
if (result.issues.length) {
|
|
819
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
820
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
821
|
+
throw e;
|
|
822
|
+
}
|
|
823
|
+
return result.value;
|
|
824
|
+
};
|
|
825
|
+
return fn;
|
|
505
826
|
};
|
|
506
|
-
var _parseAsync = (_Err) =>
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
827
|
+
var _parseAsync = (_Err) => {
|
|
828
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
829
|
+
const ctx = _ctx ? {
|
|
830
|
+
..._ctx,
|
|
831
|
+
async: true
|
|
832
|
+
} : { async: true };
|
|
833
|
+
let result = schema._zod.run({
|
|
834
|
+
value,
|
|
835
|
+
issues: []
|
|
836
|
+
}, ctx);
|
|
837
|
+
if (result instanceof Promise) result = await result;
|
|
838
|
+
if (result.issues.length) {
|
|
839
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
840
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
841
|
+
throw e;
|
|
842
|
+
}
|
|
843
|
+
return result.value;
|
|
844
|
+
};
|
|
845
|
+
return fn;
|
|
522
846
|
};
|
|
523
847
|
var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
524
848
|
const ctx = _ctx ? {
|
|
@@ -530,15 +854,30 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
530
854
|
issues: []
|
|
531
855
|
}, ctx);
|
|
532
856
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
533
|
-
return result.issues.length ? {
|
|
534
|
-
success: false,
|
|
535
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
536
|
-
} : {
|
|
857
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
537
858
|
success: true,
|
|
538
859
|
data: result.value
|
|
539
860
|
};
|
|
540
861
|
};
|
|
541
|
-
|
|
862
|
+
function failure(Err, issues, ctx) {
|
|
863
|
+
let error;
|
|
864
|
+
return {
|
|
865
|
+
success: false,
|
|
866
|
+
get error() {
|
|
867
|
+
if (!error) {
|
|
868
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
869
|
+
issues = void 0;
|
|
870
|
+
ctx = void 0;
|
|
871
|
+
}
|
|
872
|
+
return error;
|
|
873
|
+
},
|
|
874
|
+
set error(e) {
|
|
875
|
+
error = e;
|
|
876
|
+
issues = void 0;
|
|
877
|
+
ctx = void 0;
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
}
|
|
542
881
|
var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
543
882
|
const ctx = _ctx ? {
|
|
544
883
|
..._ctx,
|
|
@@ -549,34 +888,96 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
549
888
|
issues: []
|
|
550
889
|
}, ctx);
|
|
551
890
|
if (result instanceof Promise) result = await result;
|
|
552
|
-
return result.issues.length ? {
|
|
553
|
-
success: false,
|
|
554
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
555
|
-
} : {
|
|
891
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
556
892
|
success: true,
|
|
557
893
|
data: result.value
|
|
558
894
|
};
|
|
559
895
|
};
|
|
560
|
-
var
|
|
561
|
-
var
|
|
896
|
+
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
897
|
+
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
898
|
+
var validate = ((schema, value, _ctx) => {
|
|
899
|
+
const validator = schema._zod.bag.validator;
|
|
900
|
+
if (validator !== void 0) {
|
|
901
|
+
if (validator(value) !== COMPILE_INVALID) return true;
|
|
902
|
+
if (validator.definite === true && _ctx === void 0) return false;
|
|
903
|
+
}
|
|
904
|
+
return validateFallback(schema, value, _ctx);
|
|
905
|
+
});
|
|
906
|
+
function validateFallback(schema, value, _ctx) {
|
|
562
907
|
const ctx = _ctx ? {
|
|
563
908
|
..._ctx,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
909
|
+
async: false,
|
|
910
|
+
abortEarly: true
|
|
911
|
+
} : {
|
|
912
|
+
async: false,
|
|
913
|
+
abortEarly: true
|
|
914
|
+
};
|
|
915
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
916
|
+
let result;
|
|
917
|
+
if (fallbackRun) {
|
|
918
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
919
|
+
result = fallbackRun({
|
|
920
|
+
value,
|
|
921
|
+
issues: []
|
|
922
|
+
}, ctx);
|
|
923
|
+
} else result = schema._zod.run({
|
|
924
|
+
value,
|
|
925
|
+
issues: []
|
|
926
|
+
}, ctx);
|
|
927
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
928
|
+
return result.issues.length === 0;
|
|
929
|
+
}
|
|
930
|
+
var validateAsync$1 = async (schema, value, _ctx) => {
|
|
572
931
|
const ctx = _ctx ? {
|
|
573
932
|
..._ctx,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
933
|
+
async: true,
|
|
934
|
+
abortEarly: true
|
|
935
|
+
} : {
|
|
936
|
+
async: true,
|
|
937
|
+
abortEarly: true
|
|
938
|
+
};
|
|
939
|
+
let result = schema._zod.run({
|
|
940
|
+
value,
|
|
941
|
+
issues: []
|
|
942
|
+
}, ctx);
|
|
943
|
+
if (result instanceof Promise) result = await result;
|
|
944
|
+
return result.issues.length === 0;
|
|
945
|
+
};
|
|
946
|
+
var _encode = (_Err) => {
|
|
947
|
+
const parse = _parse(_Err);
|
|
948
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
949
|
+
const ctx = _ctx ? {
|
|
950
|
+
..._ctx,
|
|
951
|
+
direction: "backward"
|
|
952
|
+
} : { direction: "backward" };
|
|
953
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
954
|
+
};
|
|
955
|
+
return fn;
|
|
956
|
+
};
|
|
957
|
+
var _decode = (_Err) => {
|
|
958
|
+
const parse = _parse(_Err);
|
|
959
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
960
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
961
|
+
};
|
|
962
|
+
return fn;
|
|
963
|
+
};
|
|
964
|
+
var _encodeAsync = (_Err) => {
|
|
965
|
+
const parseAsync = _parseAsync(_Err);
|
|
966
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
967
|
+
const ctx = _ctx ? {
|
|
968
|
+
..._ctx,
|
|
969
|
+
direction: "backward"
|
|
970
|
+
} : { direction: "backward" };
|
|
971
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
972
|
+
};
|
|
973
|
+
return fn;
|
|
577
974
|
};
|
|
578
|
-
var _decodeAsync = (_Err) =>
|
|
579
|
-
|
|
975
|
+
var _decodeAsync = (_Err) => {
|
|
976
|
+
const parseAsync = _parseAsync(_Err);
|
|
977
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
978
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
979
|
+
};
|
|
980
|
+
return fn;
|
|
580
981
|
};
|
|
581
982
|
var _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
582
983
|
const ctx = _ctx ? {
|
|
@@ -607,12 +1008,15 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
607
1008
|
*/
|
|
608
1009
|
var cuid = /^[cC][0-9a-z]{6,}$/;
|
|
609
1010
|
var cuid2 = /^[0-9a-z]+$/;
|
|
610
|
-
var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{
|
|
1011
|
+
var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
611
1012
|
var xid = /^[0-9a-vA-V]{20}$/;
|
|
612
1013
|
var ksuid = /^[A-Za-z0-9]{27}$/;
|
|
613
1014
|
var nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1015
|
+
function nanoidOfLength(length) {
|
|
1016
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
1017
|
+
}
|
|
614
1018
|
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
615
|
-
var duration
|
|
1019
|
+
var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
616
1020
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
617
1021
|
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})$/;
|
|
618
1022
|
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
@@ -623,41 +1027,45 @@ var uuid = (version) => {
|
|
|
623
1027
|
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})$`);
|
|
624
1028
|
};
|
|
625
1029
|
/** Practical email validation */
|
|
626
|
-
var email = /^(
|
|
627
|
-
var _emoji$1 = `^(\\p{Extended_Pictographic}
|
|
1030
|
+
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,}$/;
|
|
1031
|
+
var _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
628
1032
|
function emoji() {
|
|
629
1033
|
return new RegExp(_emoji$1, "u");
|
|
630
1034
|
}
|
|
631
1035
|
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])$/;
|
|
632
1036
|
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}|:))$/;
|
|
633
1037
|
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])$/;
|
|
634
|
-
var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
1038
|
+
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])$/;
|
|
635
1039
|
var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
636
|
-
var base64url = /^[A-Za-z0-9_-]
|
|
1040
|
+
var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
637
1041
|
var httpProtocol = /^https?$/;
|
|
638
1042
|
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
639
1043
|
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])))`;
|
|
640
|
-
|
|
1044
|
+
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
1045
|
+
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
1046
|
+
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
|
|
1047
|
+
function anchor(source) {
|
|
1048
|
+
return new RegExp(`^${source}$`);
|
|
1049
|
+
}
|
|
1050
|
+
var date = /*@__PURE__*/ anchor(dateSource);
|
|
641
1051
|
function timeSource(args) {
|
|
642
1052
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
643
|
-
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+)?)?`;
|
|
1053
|
+
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+)?)?`;
|
|
644
1054
|
}
|
|
645
|
-
function time
|
|
1055
|
+
function time(args) {
|
|
646
1056
|
return new RegExp(`^${timeSource(args)}$`);
|
|
647
1057
|
}
|
|
648
|
-
function datetime
|
|
649
|
-
const time = timeSource({ precision: args.precision });
|
|
1058
|
+
function datetime(args) {
|
|
650
1059
|
const opts = ["Z"];
|
|
651
|
-
if (args.local) opts.push("");
|
|
652
1060
|
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
653
|
-
const
|
|
1061
|
+
const qualified = `${timeSource({
|
|
1062
|
+
precision: args.precision,
|
|
1063
|
+
seconds: true
|
|
1064
|
+
})}(?:${opts.join("|")})`;
|
|
1065
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
654
1066
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
655
1067
|
}
|
|
656
|
-
var
|
|
657
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
658
|
-
return new RegExp(`^${regex}$`);
|
|
659
|
-
};
|
|
660
|
-
var integer = /^-?\d+$/;
|
|
1068
|
+
var anyString = /^[\s\S]{0,}$/;
|
|
661
1069
|
var number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
662
1070
|
var boolean$1 = /^(?:true|false)$/i;
|
|
663
1071
|
var lowercase = /^[^A-Z]*$/;
|
|
@@ -670,6 +1078,11 @@ var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
|
670
1078
|
inst._zod.def = def;
|
|
671
1079
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
672
1080
|
});
|
|
1081
|
+
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
|
|
1082
|
+
var _whenHasLength = (payload) => {
|
|
1083
|
+
const val = payload.value;
|
|
1084
|
+
return !nullish(val) && val.length !== void 0;
|
|
1085
|
+
};
|
|
673
1086
|
var numericOriginMap = {
|
|
674
1087
|
number: "number",
|
|
675
1088
|
bigint: "bigint",
|
|
@@ -678,16 +1091,10 @@ var numericOriginMap = {
|
|
|
678
1091
|
var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
679
1092
|
$ZodCheck.init(inst, def);
|
|
680
1093
|
const origin = numericOriginMap[typeof def.value];
|
|
681
|
-
inst._zod.onattach.push((inst) => {
|
|
682
|
-
const bag = inst._zod.bag;
|
|
683
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
684
|
-
if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
|
|
685
|
-
else bag.exclusiveMaximum = def.value;
|
|
686
|
-
});
|
|
687
1094
|
inst._zod.check = (payload) => {
|
|
688
1095
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
689
1096
|
payload.issues.push({
|
|
690
|
-
origin,
|
|
1097
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
691
1098
|
code: "too_big",
|
|
692
1099
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
693
1100
|
input: payload.value,
|
|
@@ -700,16 +1107,10 @@ var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, d
|
|
|
700
1107
|
var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
701
1108
|
$ZodCheck.init(inst, def);
|
|
702
1109
|
const origin = numericOriginMap[typeof def.value];
|
|
703
|
-
inst._zod.onattach.push((inst) => {
|
|
704
|
-
const bag = inst._zod.bag;
|
|
705
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
706
|
-
if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
|
|
707
|
-
else bag.exclusiveMinimum = def.value;
|
|
708
|
-
});
|
|
709
1110
|
inst._zod.check = (payload) => {
|
|
710
1111
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
711
1112
|
payload.issues.push({
|
|
712
|
-
origin,
|
|
1113
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
713
1114
|
code: "too_small",
|
|
714
1115
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
715
1116
|
input: payload.value,
|
|
@@ -721,13 +1122,9 @@ var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (i
|
|
|
721
1122
|
});
|
|
722
1123
|
var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
723
1124
|
$ZodCheck.init(inst, def);
|
|
724
|
-
inst._zod.onattach.push((inst) => {
|
|
725
|
-
var _a;
|
|
726
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
727
|
-
});
|
|
728
1125
|
inst._zod.check = (payload) => {
|
|
729
1126
|
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
730
|
-
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
1127
|
+
if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
731
1128
|
payload.issues.push({
|
|
732
1129
|
origin: typeof payload.value,
|
|
733
1130
|
code: "not_multiple_of",
|
|
@@ -744,13 +1141,6 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
|
|
|
744
1141
|
const isInt = def.format?.includes("int");
|
|
745
1142
|
const origin = isInt ? "int" : "number";
|
|
746
1143
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
747
|
-
inst._zod.onattach.push((inst) => {
|
|
748
|
-
const bag = inst._zod.bag;
|
|
749
|
-
bag.format = def.format;
|
|
750
|
-
bag.minimum = minimum;
|
|
751
|
-
bag.maximum = maximum;
|
|
752
|
-
if (isInt) bag.pattern = integer;
|
|
753
|
-
});
|
|
754
1144
|
inst._zod.check = (payload) => {
|
|
755
1145
|
const input = payload.value;
|
|
756
1146
|
if (isInt) {
|
|
@@ -812,17 +1202,11 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
|
|
|
812
1202
|
var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
813
1203
|
var _a;
|
|
814
1204
|
$ZodCheck.init(inst, def);
|
|
815
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
816
|
-
const val = payload.value;
|
|
817
|
-
return !nullish(val) && val.length !== void 0;
|
|
818
|
-
});
|
|
819
|
-
inst._zod.onattach.push((inst) => {
|
|
820
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
821
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
822
|
-
});
|
|
1205
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
823
1206
|
inst._zod.check = (payload) => {
|
|
824
1207
|
const input = payload.value;
|
|
825
|
-
|
|
1208
|
+
const units = input.length;
|
|
1209
|
+
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
826
1210
|
const origin = getLengthableOrigin(input);
|
|
827
1211
|
payload.issues.push({
|
|
828
1212
|
origin,
|
|
@@ -838,17 +1222,11 @@ var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst,
|
|
|
838
1222
|
var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
839
1223
|
var _a;
|
|
840
1224
|
$ZodCheck.init(inst, def);
|
|
841
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
842
|
-
const val = payload.value;
|
|
843
|
-
return !nullish(val) && val.length !== void 0;
|
|
844
|
-
});
|
|
845
|
-
inst._zod.onattach.push((inst) => {
|
|
846
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
847
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
848
|
-
});
|
|
1225
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
849
1226
|
inst._zod.check = (payload) => {
|
|
850
1227
|
const input = payload.value;
|
|
851
|
-
|
|
1228
|
+
const units = input.length;
|
|
1229
|
+
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
852
1230
|
const origin = getLengthableOrigin(input);
|
|
853
1231
|
payload.issues.push({
|
|
854
1232
|
origin,
|
|
@@ -864,19 +1242,11 @@ var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst,
|
|
|
864
1242
|
var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
865
1243
|
var _a;
|
|
866
1244
|
$ZodCheck.init(inst, def);
|
|
867
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
868
|
-
const val = payload.value;
|
|
869
|
-
return !nullish(val) && val.length !== void 0;
|
|
870
|
-
});
|
|
871
|
-
inst._zod.onattach.push((inst) => {
|
|
872
|
-
const bag = inst._zod.bag;
|
|
873
|
-
bag.minimum = def.length;
|
|
874
|
-
bag.maximum = def.length;
|
|
875
|
-
bag.length = def.length;
|
|
876
|
-
});
|
|
1245
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
877
1246
|
inst._zod.check = (payload) => {
|
|
878
1247
|
const input = payload.value;
|
|
879
|
-
const
|
|
1248
|
+
const units = input.length;
|
|
1249
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
880
1250
|
if (length === def.length) return;
|
|
881
1251
|
const origin = getLengthableOrigin(input);
|
|
882
1252
|
const tooBig = length > def.length;
|
|
@@ -900,14 +1270,6 @@ var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals",
|
|
|
900
1270
|
var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
901
1271
|
var _a, _b;
|
|
902
1272
|
$ZodCheck.init(inst, def);
|
|
903
|
-
inst._zod.onattach.push((inst) => {
|
|
904
|
-
const bag = inst._zod.bag;
|
|
905
|
-
bag.format = def.format;
|
|
906
|
-
if (def.pattern) {
|
|
907
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
908
|
-
bag.patterns.add(def.pattern);
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
1273
|
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
912
1274
|
def.pattern.lastIndex = 0;
|
|
913
1275
|
if (def.pattern.test(payload.value)) return;
|
|
@@ -950,13 +1312,7 @@ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst,
|
|
|
950
1312
|
var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
951
1313
|
$ZodCheck.init(inst, def);
|
|
952
1314
|
const escapedRegex = escapeRegex(def.includes);
|
|
953
|
-
|
|
954
|
-
def.pattern = pattern;
|
|
955
|
-
inst._zod.onattach.push((inst) => {
|
|
956
|
-
const bag = inst._zod.bag;
|
|
957
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
958
|
-
bag.patterns.add(pattern);
|
|
959
|
-
});
|
|
1315
|
+
def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
960
1316
|
inst._zod.check = (payload) => {
|
|
961
1317
|
if (payload.value.includes(def.includes, def.position)) return;
|
|
962
1318
|
payload.issues.push({
|
|
@@ -974,11 +1330,6 @@ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (ins
|
|
|
974
1330
|
$ZodCheck.init(inst, def);
|
|
975
1331
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
976
1332
|
def.pattern ?? (def.pattern = pattern);
|
|
977
|
-
inst._zod.onattach.push((inst) => {
|
|
978
|
-
const bag = inst._zod.bag;
|
|
979
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
980
|
-
bag.patterns.add(pattern);
|
|
981
|
-
});
|
|
982
1333
|
inst._zod.check = (payload) => {
|
|
983
1334
|
if (payload.value.startsWith(def.prefix)) return;
|
|
984
1335
|
payload.issues.push({
|
|
@@ -996,11 +1347,6 @@ var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, d
|
|
|
996
1347
|
$ZodCheck.init(inst, def);
|
|
997
1348
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
998
1349
|
def.pattern ?? (def.pattern = pattern);
|
|
999
|
-
inst._zod.onattach.push((inst) => {
|
|
1000
|
-
const bag = inst._zod.bag;
|
|
1001
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1002
|
-
bag.patterns.add(pattern);
|
|
1003
|
-
});
|
|
1004
1350
|
inst._zod.check = (payload) => {
|
|
1005
1351
|
if (payload.value.endsWith(def.suffix)) return;
|
|
1006
1352
|
payload.issues.push({
|
|
@@ -1023,15 +1369,19 @@ var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst,
|
|
|
1023
1369
|
//#endregion
|
|
1024
1370
|
//#region ../../../node_modules/zod/v4/core/doc.js
|
|
1025
1371
|
var Doc = class {
|
|
1026
|
-
constructor(args = []) {
|
|
1372
|
+
constructor(args = [], closed = {}) {
|
|
1027
1373
|
this.content = [];
|
|
1028
1374
|
this.indent = 0;
|
|
1029
|
-
|
|
1375
|
+
this.args = args;
|
|
1376
|
+
this.closed = closed;
|
|
1030
1377
|
}
|
|
1031
1378
|
indented(fn) {
|
|
1032
1379
|
this.indent += 1;
|
|
1033
|
-
|
|
1034
|
-
|
|
1380
|
+
try {
|
|
1381
|
+
fn(this);
|
|
1382
|
+
} finally {
|
|
1383
|
+
this.indent -= 1;
|
|
1384
|
+
}
|
|
1035
1385
|
}
|
|
1036
1386
|
write(arg) {
|
|
1037
1387
|
if (typeof arg === "function") {
|
|
@@ -1046,17 +1396,16 @@ var Doc = class {
|
|
|
1046
1396
|
}
|
|
1047
1397
|
compile() {
|
|
1048
1398
|
const F = Function;
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
return new F(...args, lines.join("\n"));
|
|
1399
|
+
const content = this?.content ?? [``];
|
|
1400
|
+
return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
|
|
1052
1401
|
}
|
|
1053
1402
|
};
|
|
1054
1403
|
//#endregion
|
|
1055
1404
|
//#region ../../../node_modules/zod/v4/core/versions.js
|
|
1056
1405
|
var version = {
|
|
1057
1406
|
major: 4,
|
|
1058
|
-
minor:
|
|
1059
|
-
patch:
|
|
1407
|
+
minor: 6,
|
|
1408
|
+
patch: 5
|
|
1060
1409
|
};
|
|
1061
1410
|
//#endregion
|
|
1062
1411
|
//#region ../../../node_modules/zod/v4/core/schemas.js
|
|
@@ -1066,8 +1415,8 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1066
1415
|
inst._zod.def = def;
|
|
1067
1416
|
inst._zod.bag = inst._zod.bag || {};
|
|
1068
1417
|
inst._zod.version = version;
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1418
|
+
const defChecks = inst._zod.def.checks;
|
|
1419
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1071
1420
|
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1072
1421
|
if (checks.length === 0) {
|
|
1073
1422
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
@@ -1076,6 +1425,7 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1076
1425
|
});
|
|
1077
1426
|
} else {
|
|
1078
1427
|
const runChecks = (payload, checks, ctx) => {
|
|
1428
|
+
if (payload.memo) return payload;
|
|
1079
1429
|
let isAborted = aborted(payload);
|
|
1080
1430
|
let asyncResult;
|
|
1081
1431
|
for (const ch of checks) {
|
|
@@ -1089,10 +1439,12 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1089
1439
|
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1090
1440
|
await _;
|
|
1091
1441
|
if (payload.issues.length === currLen) return;
|
|
1442
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1092
1443
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1093
1444
|
});
|
|
1094
1445
|
else {
|
|
1095
1446
|
if (payload.issues.length === currLen) continue;
|
|
1447
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1096
1448
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1097
1449
|
}
|
|
1098
1450
|
}
|
|
@@ -1136,22 +1488,43 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1136
1488
|
return runChecks(result, checks, ctx);
|
|
1137
1489
|
};
|
|
1138
1490
|
}
|
|
1139
|
-
|
|
1491
|
+
}, {
|
|
1492
|
+
get "~standard"() {
|
|
1493
|
+
return hide(this, "~standard", standardProps(this));
|
|
1494
|
+
},
|
|
1495
|
+
set "~standard"(value) {
|
|
1496
|
+
own(this, "~standard", value);
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
1500
|
+
var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1501
|
+
async function validateAsync(inst, value) {
|
|
1502
|
+
const ctx = { async: true };
|
|
1503
|
+
return toStandardResult(await inst._zod.run({
|
|
1504
|
+
value,
|
|
1505
|
+
issues: []
|
|
1506
|
+
}, ctx), ctx);
|
|
1507
|
+
}
|
|
1508
|
+
function standardProps(inst) {
|
|
1509
|
+
return {
|
|
1140
1510
|
validate: (value) => {
|
|
1511
|
+
const ctx = { async: false };
|
|
1141
1512
|
try {
|
|
1142
|
-
const r =
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1513
|
+
const r = inst._zod.run({
|
|
1514
|
+
value,
|
|
1515
|
+
issues: []
|
|
1516
|
+
}, ctx);
|
|
1517
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
1518
|
+
} catch (_) {}
|
|
1519
|
+
return validateAsync(inst, value);
|
|
1147
1520
|
},
|
|
1148
1521
|
vendor: "zod",
|
|
1149
1522
|
version: 1
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1152
1525
|
var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
1153
1526
|
$ZodType.init(inst, def);
|
|
1154
|
-
inst._zod.pattern =
|
|
1527
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1155
1528
|
inst._zod.parse = (payload, _) => {
|
|
1156
1529
|
if (def.coerce) try {
|
|
1157
1530
|
payload.value = String(payload.value);
|
|
@@ -1195,51 +1568,95 @@ var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1195
1568
|
def.pattern ?? (def.pattern = email);
|
|
1196
1569
|
$ZodStringFormat.init(inst, def);
|
|
1197
1570
|
});
|
|
1571
|
+
function canParseURL(input) {
|
|
1572
|
+
try {
|
|
1573
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
1574
|
+
new URL(input);
|
|
1575
|
+
return true;
|
|
1576
|
+
} catch {
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
function validateURL(trimmed, def) {
|
|
1581
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
|
|
1582
|
+
return parseURLObject(trimmed, def);
|
|
1583
|
+
}
|
|
1584
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
1585
|
+
function parseURLObject(trimmed, def) {
|
|
1586
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
|
|
1587
|
+
try {
|
|
1588
|
+
if (typeof URL !== "undefined") {
|
|
1589
|
+
const URLStatic = URL;
|
|
1590
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
|
|
1591
|
+
}
|
|
1592
|
+
return new URL(trimmed);
|
|
1593
|
+
} catch {
|
|
1594
|
+
return 2;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
var asciiTabOrNewline = /[\t\n\r]/g;
|
|
1598
|
+
/** 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. */
|
|
1599
|
+
function stripTabAndNewline(value) {
|
|
1600
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1601
|
+
}
|
|
1602
|
+
function urlHostnameOk(url, hostname) {
|
|
1603
|
+
hostname.lastIndex = 0;
|
|
1604
|
+
return hostname.test(url.hostname);
|
|
1605
|
+
}
|
|
1606
|
+
function urlProtocolOk(url, protocol) {
|
|
1607
|
+
protocol.lastIndex = 0;
|
|
1608
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1609
|
+
}
|
|
1198
1610
|
var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
1199
1611
|
$ZodStringFormat.init(inst, def);
|
|
1200
1612
|
inst._zod.check = (payload) => {
|
|
1201
1613
|
try {
|
|
1202
1614
|
const trimmed = payload.value.trim();
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
code: "invalid_format",
|
|
1207
|
-
format: "url",
|
|
1208
|
-
note: "Invalid URL format",
|
|
1209
|
-
input: payload.value,
|
|
1210
|
-
inst,
|
|
1211
|
-
continue: !def.abort
|
|
1212
|
-
});
|
|
1213
|
-
return;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
const url = new URL(trimmed);
|
|
1217
|
-
if (def.hostname) {
|
|
1218
|
-
def.hostname.lastIndex = 0;
|
|
1219
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1615
|
+
const url = validateURL(trimmed, def);
|
|
1616
|
+
if (url === 1) {
|
|
1617
|
+
payload.issues.push({
|
|
1220
1618
|
code: "invalid_format",
|
|
1221
1619
|
format: "url",
|
|
1222
|
-
note: "Invalid
|
|
1223
|
-
pattern: def.hostname.source,
|
|
1620
|
+
note: "Invalid URL format",
|
|
1224
1621
|
input: payload.value,
|
|
1225
1622
|
inst,
|
|
1226
1623
|
continue: !def.abort
|
|
1227
1624
|
});
|
|
1625
|
+
return;
|
|
1228
1626
|
}
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1231
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1627
|
+
if (url === 2) {
|
|
1628
|
+
payload.issues.push({
|
|
1232
1629
|
code: "invalid_format",
|
|
1233
1630
|
format: "url",
|
|
1234
|
-
note: "Invalid protocol",
|
|
1235
|
-
pattern: def.protocol.source,
|
|
1236
1631
|
input: payload.value,
|
|
1237
1632
|
inst,
|
|
1238
1633
|
continue: !def.abort
|
|
1239
1634
|
});
|
|
1635
|
+
return;
|
|
1240
1636
|
}
|
|
1241
|
-
if (
|
|
1242
|
-
|
|
1637
|
+
if (url === true) {
|
|
1638
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
|
|
1642
|
+
code: "invalid_format",
|
|
1643
|
+
format: "url",
|
|
1644
|
+
note: "Invalid hostname",
|
|
1645
|
+
pattern: def.hostname.source,
|
|
1646
|
+
input: payload.value,
|
|
1647
|
+
inst,
|
|
1648
|
+
continue: !def.abort
|
|
1649
|
+
});
|
|
1650
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
|
|
1651
|
+
code: "invalid_format",
|
|
1652
|
+
format: "url",
|
|
1653
|
+
note: "Invalid protocol",
|
|
1654
|
+
pattern: def.protocol.source,
|
|
1655
|
+
input: payload.value,
|
|
1656
|
+
inst,
|
|
1657
|
+
continue: !def.abort
|
|
1658
|
+
});
|
|
1659
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1243
1660
|
return;
|
|
1244
1661
|
} catch (_) {
|
|
1245
1662
|
payload.issues.push({
|
|
@@ -1257,7 +1674,8 @@ var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
|
|
|
1257
1674
|
$ZodStringFormat.init(inst, def);
|
|
1258
1675
|
});
|
|
1259
1676
|
var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
1260
|
-
def.
|
|
1677
|
+
if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1678
|
+
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
1261
1679
|
$ZodStringFormat.init(inst, def);
|
|
1262
1680
|
});
|
|
1263
1681
|
/**
|
|
@@ -1286,70 +1704,69 @@ var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
1286
1704
|
$ZodStringFormat.init(inst, def);
|
|
1287
1705
|
});
|
|
1288
1706
|
var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1289
|
-
def.pattern ?? (def.pattern = datetime
|
|
1707
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1290
1708
|
$ZodStringFormat.init(inst, def);
|
|
1291
1709
|
});
|
|
1292
1710
|
var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
1293
|
-
def.pattern ?? (def.pattern = date
|
|
1711
|
+
def.pattern ?? (def.pattern = date);
|
|
1294
1712
|
$ZodStringFormat.init(inst, def);
|
|
1295
1713
|
});
|
|
1296
1714
|
var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
1297
|
-
def.pattern ?? (def.pattern = time
|
|
1715
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1298
1716
|
$ZodStringFormat.init(inst, def);
|
|
1299
1717
|
});
|
|
1300
1718
|
var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
1301
|
-
def.pattern ?? (def.pattern = duration
|
|
1719
|
+
def.pattern ?? (def.pattern = duration);
|
|
1302
1720
|
$ZodStringFormat.init(inst, def);
|
|
1303
1721
|
});
|
|
1304
1722
|
var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
1305
1723
|
def.pattern ?? (def.pattern = ipv4);
|
|
1306
1724
|
$ZodStringFormat.init(inst, def);
|
|
1307
|
-
inst._zod.bag.format = `ipv4`;
|
|
1308
1725
|
});
|
|
1726
|
+
/** 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`. */
|
|
1727
|
+
var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1728
|
+
function isValidIPv6(value) {
|
|
1729
|
+
if (!ipv6Alphabet.test(value)) return false;
|
|
1730
|
+
return canParseURL(`http://[${value}]`);
|
|
1731
|
+
}
|
|
1309
1732
|
var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
1310
1733
|
def.pattern ?? (def.pattern = ipv6);
|
|
1311
1734
|
$ZodStringFormat.init(inst, def);
|
|
1312
|
-
inst._zod.bag.format = `ipv6`;
|
|
1313
1735
|
inst._zod.check = (payload) => {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
payload.
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
inst,
|
|
1322
|
-
continue: !def.abort
|
|
1323
|
-
});
|
|
1324
|
-
}
|
|
1736
|
+
if (!isValidIPv6(payload.value)) payload.issues.push({
|
|
1737
|
+
code: "invalid_format",
|
|
1738
|
+
format: "ipv6",
|
|
1739
|
+
input: payload.value,
|
|
1740
|
+
inst,
|
|
1741
|
+
continue: !def.abort
|
|
1742
|
+
});
|
|
1325
1743
|
};
|
|
1326
1744
|
});
|
|
1327
1745
|
var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1328
1746
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1329
1747
|
$ZodStringFormat.init(inst, def);
|
|
1330
1748
|
});
|
|
1749
|
+
function isValidCIDRv6(value) {
|
|
1750
|
+
const parts = value.split("/");
|
|
1751
|
+
if (parts.length !== 2) return false;
|
|
1752
|
+
const [address, prefix] = parts;
|
|
1753
|
+
if (!prefix) return false;
|
|
1754
|
+
const prefixNum = Number(prefix);
|
|
1755
|
+
if (`${prefixNum}` !== prefix) return false;
|
|
1756
|
+
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
1757
|
+
return isValidIPv6(address);
|
|
1758
|
+
}
|
|
1331
1759
|
var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1332
1760
|
def.pattern ?? (def.pattern = cidrv6);
|
|
1333
1761
|
$ZodStringFormat.init(inst, def);
|
|
1334
1762
|
inst._zod.check = (payload) => {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1343
|
-
new URL(`http://[${address}]`);
|
|
1344
|
-
} catch {
|
|
1345
|
-
payload.issues.push({
|
|
1346
|
-
code: "invalid_format",
|
|
1347
|
-
format: "cidrv6",
|
|
1348
|
-
input: payload.value,
|
|
1349
|
-
inst,
|
|
1350
|
-
continue: !def.abort
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1763
|
+
if (!isValidCIDRv6(payload.value)) payload.issues.push({
|
|
1764
|
+
code: "invalid_format",
|
|
1765
|
+
format: "cidrv6",
|
|
1766
|
+
input: payload.value,
|
|
1767
|
+
inst,
|
|
1768
|
+
continue: !def.abort
|
|
1769
|
+
});
|
|
1353
1770
|
};
|
|
1354
1771
|
});
|
|
1355
1772
|
function isValidBase64(data) {
|
|
@@ -1363,10 +1780,10 @@ function isValidBase64(data) {
|
|
|
1363
1780
|
return false;
|
|
1364
1781
|
}
|
|
1365
1782
|
}
|
|
1783
|
+
var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1366
1784
|
var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
1367
|
-
def.pattern ?? (def.pattern =
|
|
1785
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1368
1786
|
$ZodStringFormat.init(inst, def);
|
|
1369
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1370
1787
|
inst._zod.check = (payload) => {
|
|
1371
1788
|
if (isValidBase64(payload.value)) return;
|
|
1372
1789
|
payload.issues.push({
|
|
@@ -1378,15 +1795,15 @@ var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1378
1795
|
});
|
|
1379
1796
|
};
|
|
1380
1797
|
});
|
|
1798
|
+
var base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1381
1799
|
function isValidBase64URL(data) {
|
|
1382
|
-
if (!
|
|
1800
|
+
if (!base64urlCharset.test(data)) return false;
|
|
1383
1801
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1384
1802
|
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
1385
1803
|
}
|
|
1386
1804
|
var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1387
|
-
def.pattern ?? (def.pattern =
|
|
1805
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1388
1806
|
$ZodStringFormat.init(inst, def);
|
|
1389
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1390
1807
|
inst._zod.check = (payload) => {
|
|
1391
1808
|
if (isValidBase64URL(payload.value)) return;
|
|
1392
1809
|
payload.issues.push({
|
|
@@ -1432,14 +1849,14 @@ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1432
1849
|
});
|
|
1433
1850
|
var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
1434
1851
|
$ZodType.init(inst, def);
|
|
1435
|
-
inst._zod.pattern =
|
|
1852
|
+
inst._zod.pattern = number$1;
|
|
1436
1853
|
inst._zod.parse = (payload, _ctx) => {
|
|
1437
1854
|
if (def.coerce) try {
|
|
1438
1855
|
payload.value = Number(payload.value);
|
|
1439
1856
|
} catch (_) {}
|
|
1440
1857
|
const input = payload.value;
|
|
1441
1858
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1442
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ?
|
|
1859
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
|
|
1443
1860
|
payload.issues.push({
|
|
1444
1861
|
expected: "number",
|
|
1445
1862
|
code: "invalid_type",
|
|
@@ -1494,6 +1911,8 @@ function handleArrayResult(result, final, index) {
|
|
|
1494
1911
|
}
|
|
1495
1912
|
var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
1496
1913
|
$ZodType.init(inst, def);
|
|
1914
|
+
const memo = globalConfig.memoizer;
|
|
1915
|
+
memo?.attach(inst);
|
|
1497
1916
|
inst._zod.parse = (payload, ctx) => {
|
|
1498
1917
|
const input = payload.value;
|
|
1499
1918
|
if (!Array.isArray(input)) {
|
|
@@ -1505,8 +1924,9 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1505
1924
|
});
|
|
1506
1925
|
return payload;
|
|
1507
1926
|
}
|
|
1508
|
-
payload.value = Array(input.length);
|
|
1927
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1509
1928
|
const proms = [];
|
|
1929
|
+
const abortEarly = ctx?.abortEarly;
|
|
1510
1930
|
for (let i = 0; i < input.length; i++) {
|
|
1511
1931
|
const item = input[i];
|
|
1512
1932
|
const result = def.element._zod.run({
|
|
@@ -1514,19 +1934,24 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1514
1934
|
issues: []
|
|
1515
1935
|
}, ctx);
|
|
1516
1936
|
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1517
|
-
else
|
|
1937
|
+
else {
|
|
1938
|
+
handleArrayResult(result, payload, i);
|
|
1939
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
|
|
1940
|
+
}
|
|
1518
1941
|
}
|
|
1519
1942
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1520
1943
|
return payload;
|
|
1521
1944
|
};
|
|
1522
1945
|
});
|
|
1523
|
-
function handlePropertyResult(result, final, key, input,
|
|
1946
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1524
1947
|
const isPresent = key in input;
|
|
1948
|
+
const isOptionalOut = optout === "optional";
|
|
1949
|
+
if (!isPresent && isOptionalOut && optin === "optional") return;
|
|
1525
1950
|
if (result.issues.length) {
|
|
1526
|
-
if (
|
|
1951
|
+
if (optin !== void 0 && isOptionalOut && !isPresent) return;
|
|
1527
1952
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1528
1953
|
}
|
|
1529
|
-
if (!isPresent &&
|
|
1954
|
+
if (!isPresent && optin === void 0) {
|
|
1530
1955
|
if (!result.issues.length) final.issues.push({
|
|
1531
1956
|
code: "invalid_type",
|
|
1532
1957
|
expected: "nonoptional",
|
|
@@ -1536,31 +1961,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
|
|
|
1536
1961
|
return;
|
|
1537
1962
|
}
|
|
1538
1963
|
if (result.value === void 0) {
|
|
1539
|
-
if (isPresent) final.value[key] = void 0;
|
|
1964
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
|
|
1540
1965
|
} else final.value[key] = result.value;
|
|
1541
1966
|
}
|
|
1967
|
+
var NO_SYMBOL_KEYS = [];
|
|
1542
1968
|
function normalizeDef(def) {
|
|
1543
1969
|
const keys = Object.keys(def.shape);
|
|
1544
|
-
|
|
1970
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
1971
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
1972
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
1973
|
+
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`);
|
|
1545
1974
|
const okeys = optionalKeys(def.shape);
|
|
1546
1975
|
return {
|
|
1547
1976
|
...def,
|
|
1548
|
-
|
|
1977
|
+
allKeys,
|
|
1978
|
+
symbolKeys,
|
|
1549
1979
|
keySet: new Set(keys),
|
|
1550
1980
|
numKeys: keys.length,
|
|
1551
1981
|
optionalKeys: new Set(okeys)
|
|
1552
1982
|
};
|
|
1553
1983
|
}
|
|
1554
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1984
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1555
1985
|
const unrecognized = [];
|
|
1556
1986
|
const keySet = def.keySet;
|
|
1557
1987
|
const _catchall = def.catchall._zod;
|
|
1558
1988
|
const t = _catchall.def.type;
|
|
1559
|
-
const
|
|
1560
|
-
const
|
|
1989
|
+
const optin = _catchall.optin;
|
|
1990
|
+
const optout = _catchall.optout;
|
|
1991
|
+
let seen = 0;
|
|
1561
1992
|
for (const key in input) {
|
|
1562
|
-
if (
|
|
1993
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1994
|
+
if (aborted(payload, seen)) break;
|
|
1995
|
+
seen = payload.issues.length;
|
|
1996
|
+
}
|
|
1563
1997
|
if (keySet.has(key)) continue;
|
|
1998
|
+
if (key === "__proto__") {
|
|
1999
|
+
if (t === "never") unrecognized.push(key);
|
|
2000
|
+
continue;
|
|
2001
|
+
}
|
|
1564
2002
|
if (t === "never") {
|
|
1565
2003
|
unrecognized.push(key);
|
|
1566
2004
|
continue;
|
|
@@ -1569,14 +2007,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1569
2007
|
value: input[key],
|
|
1570
2008
|
issues: []
|
|
1571
2009
|
}, ctx);
|
|
1572
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1573
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2010
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2011
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1574
2012
|
}
|
|
1575
2013
|
if (unrecognized.length) payload.issues.push({
|
|
1576
2014
|
code: "unrecognized_keys",
|
|
1577
2015
|
keys: unrecognized,
|
|
1578
2016
|
input,
|
|
1579
|
-
inst
|
|
2017
|
+
inst,
|
|
2018
|
+
continue: true
|
|
1580
2019
|
});
|
|
1581
2020
|
if (!proms.length) return payload;
|
|
1582
2021
|
return Promise.all(proms).then(() => {
|
|
@@ -1585,23 +2024,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1585
2024
|
}
|
|
1586
2025
|
var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
1587
2026
|
$ZodType.init(inst, def);
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
2027
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2028
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
2029
|
+
if (sh) {
|
|
2030
|
+
const get = () => {
|
|
1591
2031
|
const newSh = { ...sh };
|
|
1592
2032
|
Object.defineProperty(def, "shape", { value: newSh });
|
|
2033
|
+
get.raw = newSh;
|
|
1593
2034
|
return newSh;
|
|
1594
|
-
}
|
|
2035
|
+
};
|
|
2036
|
+
get.raw = sh;
|
|
2037
|
+
Object.defineProperty(def, "shape", { get });
|
|
1595
2038
|
}
|
|
1596
2039
|
const _normalized = cached(() => normalizeDef(def));
|
|
1597
|
-
|
|
1598
|
-
const shape = def.shape;
|
|
2040
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2041
|
+
const shape = zod.def.shape;
|
|
1599
2042
|
const propValues = {};
|
|
1600
2043
|
for (const key in shape) {
|
|
1601
2044
|
const field = shape[key]._zod;
|
|
1602
2045
|
if (field.values) {
|
|
1603
|
-
propValues
|
|
2046
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
|
|
1604
2047
|
for (const v of field.values) propValues[key].add(v);
|
|
2048
|
+
if (field.optin !== void 0) propValues[key].add(void 0);
|
|
1605
2049
|
}
|
|
1606
2050
|
}
|
|
1607
2051
|
return propValues;
|
|
@@ -1609,6 +2053,8 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1609
2053
|
const isObject$2 = isObject;
|
|
1610
2054
|
const catchall = def.catchall;
|
|
1611
2055
|
let value;
|
|
2056
|
+
const memo = globalConfig.memoizer;
|
|
2057
|
+
memo?.attach(inst);
|
|
1612
2058
|
inst._zod.parse = (payload, ctx) => {
|
|
1613
2059
|
value ?? (value = _normalized.value);
|
|
1614
2060
|
const input = payload.value;
|
|
@@ -1621,77 +2067,90 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1621
2067
|
});
|
|
1622
2068
|
return payload;
|
|
1623
2069
|
}
|
|
1624
|
-
payload.value = {};
|
|
2070
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1625
2071
|
const proms = [];
|
|
1626
2072
|
const shape = value.shape;
|
|
1627
|
-
|
|
2073
|
+
const abortEarly = ctx?.abortEarly;
|
|
2074
|
+
let seen = payload.issues.length;
|
|
2075
|
+
for (const key of value.allKeys) {
|
|
2076
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2077
|
+
if (aborted(payload, seen)) break;
|
|
2078
|
+
seen = payload.issues.length;
|
|
2079
|
+
}
|
|
2080
|
+
if (key === "__proto__") continue;
|
|
1628
2081
|
const el = shape[key];
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
2082
|
+
const optin = el._zod.optin;
|
|
2083
|
+
const optout = el._zod.optout;
|
|
1631
2084
|
const r = el._zod.run({
|
|
1632
2085
|
value: input[key],
|
|
1633
2086
|
issues: []
|
|
1634
2087
|
}, ctx);
|
|
1635
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1636
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2088
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2089
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1637
2090
|
}
|
|
1638
2091
|
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1639
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2092
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1640
2093
|
};
|
|
1641
2094
|
});
|
|
1642
2095
|
var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1643
2096
|
$ZodObject.init(inst, def);
|
|
1644
2097
|
const superParse = inst._zod.parse;
|
|
1645
2098
|
const _normalized = cached(() => normalizeDef(def));
|
|
2099
|
+
const memo = globalConfig.memoizer;
|
|
1646
2100
|
const generateFastpass = (shape) => {
|
|
1647
|
-
const doc = new Doc([
|
|
1648
|
-
"shape",
|
|
1649
|
-
"payload",
|
|
1650
|
-
"ctx"
|
|
1651
|
-
]);
|
|
1652
2101
|
const normalized = _normalized.value;
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
2102
|
+
const syms = normalized.symbolKeys;
|
|
2103
|
+
const doc = new Doc(["payload", "ctx"], {
|
|
2104
|
+
shape,
|
|
2105
|
+
inst,
|
|
2106
|
+
memo,
|
|
2107
|
+
syms
|
|
2108
|
+
});
|
|
2109
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2110
|
+
const prefixStr = (id, k) => `
|
|
2111
|
+
let ${id}_ab = false;
|
|
2112
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2113
|
+
const iss = ${id}.issues[i];
|
|
2114
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2115
|
+
payload.issues.push(iss);
|
|
2116
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2117
|
+
}
|
|
2118
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2119
|
+
payload.value = newResult;
|
|
2120
|
+
return payload;
|
|
2121
|
+
}`;
|
|
1657
2122
|
doc.write(`const input = payload.value;`);
|
|
1658
2123
|
const ids = Object.create(null);
|
|
1659
2124
|
let counter = 0;
|
|
1660
|
-
for (const key of normalized.
|
|
1661
|
-
doc.write(`const newResult = {};`);
|
|
1662
|
-
for (const key of normalized.
|
|
2125
|
+
for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
|
|
2126
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2127
|
+
for (const key of normalized.allKeys) {
|
|
2128
|
+
if (key === "__proto__") continue;
|
|
1663
2129
|
const id = ids[key];
|
|
1664
|
-
const k = esc(key);
|
|
2130
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2131
|
+
const isPresent = `${k} in input`;
|
|
1665
2132
|
const schema = shape[key];
|
|
1666
|
-
const
|
|
2133
|
+
const optin = schema?._zod?.optin;
|
|
2134
|
+
const isOptionalIn = optin !== void 0;
|
|
1667
2135
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1668
|
-
doc.write(`const ${id} = ${parseStr(
|
|
1669
|
-
if (isOptionalIn && isOptionalOut)
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
})));
|
|
2136
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
2137
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2138
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
2139
|
+
doc.write(`
|
|
2140
|
+
const ${id}_present = ${isPresent};
|
|
2141
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2142
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1676
2143
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
if (${k} in input) {
|
|
1681
|
-
newResult[${k}] = undefined;
|
|
2144
|
+
|
|
2145
|
+
if (${assign}) {
|
|
2146
|
+
newResult[${k}] = ${id}.value;
|
|
1682
2147
|
}
|
|
1683
|
-
} else {
|
|
1684
|
-
newResult[${k}] = ${id}.value;
|
|
1685
2148
|
}
|
|
1686
|
-
|
|
2149
|
+
|
|
1687
2150
|
`);
|
|
1688
|
-
else if (!isOptionalIn) doc.write(`
|
|
1689
|
-
const ${id}_present = ${
|
|
1690
|
-
if (${id}.issues.length) {
|
|
1691
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1692
|
-
...iss,
|
|
1693
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1694
|
-
})));
|
|
2151
|
+
} else if (!isOptionalIn) doc.write(`
|
|
2152
|
+
const ${id}_present = ${isPresent};
|
|
2153
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1695
2154
|
}
|
|
1696
2155
|
if (!${id}_present && !${id}.issues.length) {
|
|
1697
2156
|
payload.issues.push({
|
|
@@ -1700,39 +2159,33 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
1700
2159
|
input: undefined,
|
|
1701
2160
|
path: [${k}]
|
|
1702
2161
|
});
|
|
2162
|
+
if (ctx && ctx.abortEarly) {
|
|
2163
|
+
payload.value = newResult;
|
|
2164
|
+
return payload;
|
|
2165
|
+
}
|
|
1703
2166
|
}
|
|
1704
2167
|
|
|
1705
2168
|
if (${id}_present) {
|
|
1706
|
-
|
|
1707
|
-
newResult[${k}] = undefined;
|
|
1708
|
-
} else {
|
|
1709
|
-
newResult[${k}] = ${id}.value;
|
|
1710
|
-
}
|
|
2169
|
+
newResult[${k}] = ${id}.value;
|
|
1711
2170
|
}
|
|
1712
2171
|
|
|
1713
2172
|
`);
|
|
1714
|
-
else
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
...iss,
|
|
1718
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1719
|
-
})));
|
|
2173
|
+
else {
|
|
2174
|
+
doc.write(`
|
|
2175
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1720
2176
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
}
|
|
1726
|
-
} else {
|
|
2177
|
+
`);
|
|
2178
|
+
if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2179
|
+
else doc.write(`
|
|
2180
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1727
2181
|
newResult[${k}] = ${id}.value;
|
|
1728
2182
|
}
|
|
1729
|
-
|
|
1730
2183
|
`);
|
|
2184
|
+
}
|
|
1731
2185
|
}
|
|
1732
2186
|
doc.write(`payload.value = newResult;`);
|
|
1733
2187
|
doc.write(`return payload;`);
|
|
1734
|
-
|
|
1735
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2188
|
+
return doc.compile();
|
|
1736
2189
|
};
|
|
1737
2190
|
let fastpass;
|
|
1738
2191
|
const isObject$1 = isObject;
|
|
@@ -1756,7 +2209,7 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
|
1756
2209
|
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1757
2210
|
payload = fastpass(payload, ctx);
|
|
1758
2211
|
if (!catchall) return payload;
|
|
1759
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2212
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
1760
2213
|
}
|
|
1761
2214
|
return superParse(payload, ctx);
|
|
1762
2215
|
};
|
|
@@ -1781,14 +2234,14 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1781
2234
|
}
|
|
1782
2235
|
var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
1783
2236
|
$ZodType.init(inst, def);
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2237
|
+
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);
|
|
2238
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2239
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2240
|
+
if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1788
2241
|
});
|
|
1789
|
-
|
|
1790
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1791
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2242
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2243
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2244
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
1792
2245
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1793
2246
|
}
|
|
1794
2247
|
});
|
|
@@ -1816,35 +2269,42 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
1816
2269
|
});
|
|
1817
2270
|
};
|
|
1818
2271
|
});
|
|
2272
|
+
function discriminatorMap(def) {
|
|
2273
|
+
const map = /* @__PURE__ */ new Map();
|
|
2274
|
+
for (const option of def.options) {
|
|
2275
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
2276
|
+
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2277
|
+
for (const value of values) if (map.has(value)) {
|
|
2278
|
+
if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
2279
|
+
map.set(value, null);
|
|
2280
|
+
} else map.set(value, option);
|
|
2281
|
+
}
|
|
2282
|
+
return map;
|
|
2283
|
+
}
|
|
1819
2284
|
var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
1820
2285
|
def.inclusive = false;
|
|
1821
2286
|
$ZodUnion.init(inst, def);
|
|
1822
2287
|
const _super = inst._zod.parse;
|
|
1823
|
-
|
|
2288
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
1824
2289
|
const propValues = {};
|
|
1825
|
-
|
|
2290
|
+
let undefinedCount = 0;
|
|
2291
|
+
for (const option of zod.def.options) {
|
|
1826
2292
|
const pv = option._zod.propValues;
|
|
1827
|
-
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2293
|
+
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
2294
|
+
if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
|
|
1828
2295
|
for (const [k, v] of Object.entries(pv)) {
|
|
1829
|
-
if (!propValues
|
|
2296
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
1830
2297
|
for (const val of v) propValues[k].add(val);
|
|
1831
2298
|
}
|
|
1832
2299
|
}
|
|
2300
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
|
|
1833
2301
|
return propValues;
|
|
1834
2302
|
});
|
|
1835
|
-
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
for (const o of opts) {
|
|
1839
|
-
const values = o._zod.propValues?.[def.discriminator];
|
|
1840
|
-
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
1841
|
-
for (const v of values) {
|
|
1842
|
-
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
1843
|
-
map.set(v, o);
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
return map;
|
|
2303
|
+
def.options.forEach((option, i) => {
|
|
2304
|
+
const propShape = rawShape(option._zod.def);
|
|
2305
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
1847
2306
|
});
|
|
2307
|
+
const disc = cached(() => discriminatorMap(def));
|
|
1848
2308
|
inst._zod.parse = (payload, ctx) => {
|
|
1849
2309
|
const input = payload.value;
|
|
1850
2310
|
if (!isObject(input)) {
|
|
@@ -1856,15 +2316,16 @@ var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion"
|
|
|
1856
2316
|
});
|
|
1857
2317
|
return payload;
|
|
1858
2318
|
}
|
|
1859
|
-
const
|
|
1860
|
-
|
|
2319
|
+
const value = input?.[def.discriminator];
|
|
2320
|
+
const opt = disc.value.get(value);
|
|
2321
|
+
if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
|
|
1861
2322
|
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
|
|
1862
2323
|
payload.issues.push({
|
|
1863
2324
|
code: "invalid_union",
|
|
1864
2325
|
errors: [],
|
|
1865
2326
|
note: "No matching discriminator",
|
|
1866
2327
|
discriminator: def.discriminator,
|
|
1867
|
-
options: Array.from(disc.value.keys()),
|
|
2328
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
1868
2329
|
input,
|
|
1869
2330
|
path: [def.discriminator],
|
|
1870
2331
|
inst
|
|
@@ -1906,7 +2367,9 @@ function mergeValues(a, b) {
|
|
|
1906
2367
|
...a,
|
|
1907
2368
|
...b
|
|
1908
2369
|
};
|
|
2370
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
1909
2371
|
for (const key of sharedKeys) {
|
|
2372
|
+
if (key === "__proto__") continue;
|
|
1910
2373
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1911
2374
|
if (!sharedValue.valid) return {
|
|
1912
2375
|
valid: false,
|
|
@@ -1948,26 +2411,39 @@ function mergeValues(a, b) {
|
|
|
1948
2411
|
function handleIntersectionResults(result, left, right) {
|
|
1949
2412
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1950
2413
|
let unrecIssue;
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2414
|
+
const keyIssues = /* @__PURE__ */ new Map();
|
|
2415
|
+
const collect = (iss, side) => {
|
|
2416
|
+
let keys;
|
|
2417
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2418
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2419
|
+
keys = iss.keys;
|
|
2420
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2421
|
+
const k = String(iss.path[0]);
|
|
2422
|
+
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
2423
|
+
keys = [k];
|
|
2424
|
+
} else return false;
|
|
2425
|
+
for (const k of keys) {
|
|
1954
2426
|
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1955
|
-
unrecKeys.get(k)
|
|
2427
|
+
unrecKeys.get(k)[side] = true;
|
|
1956
2428
|
}
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
}
|
|
1962
|
-
else result.issues.push(iss);
|
|
2429
|
+
return true;
|
|
2430
|
+
};
|
|
2431
|
+
for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
|
|
2432
|
+
for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
|
|
1963
2433
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1964
|
-
if (bothKeys.length
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2434
|
+
if (bothKeys.length) {
|
|
2435
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2436
|
+
if (aggregated.length) result.issues.push({
|
|
2437
|
+
...unrecIssue,
|
|
2438
|
+
keys: aggregated
|
|
2439
|
+
});
|
|
2440
|
+
for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
|
|
2441
|
+
}
|
|
1969
2442
|
const merged = mergeValues(left.value, right.value);
|
|
1970
|
-
if (!merged.valid)
|
|
2443
|
+
if (!merged.valid) {
|
|
2444
|
+
if (aborted(result)) return result;
|
|
2445
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2446
|
+
}
|
|
1971
2447
|
result.value = merged.data;
|
|
1972
2448
|
return result;
|
|
1973
2449
|
}
|
|
@@ -1976,7 +2452,10 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1976
2452
|
const values = getEnumValues(def.entries);
|
|
1977
2453
|
const valuesSet = new Set(values);
|
|
1978
2454
|
inst._zod.values = valuesSet;
|
|
1979
|
-
inst
|
|
2455
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2456
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2457
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2458
|
+
});
|
|
1980
2459
|
inst._zod.parse = (payload, _ctx) => {
|
|
1981
2460
|
const input = payload.value;
|
|
1982
2461
|
if (valuesSet.has(input)) return payload;
|
|
@@ -1991,10 +2470,12 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1991
2470
|
});
|
|
1992
2471
|
var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
1993
2472
|
$ZodType.init(inst, def);
|
|
1994
|
-
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
|
|
1995
2473
|
const values = new Set(def.values);
|
|
1996
2474
|
inst._zod.values = values;
|
|
1997
|
-
inst
|
|
2475
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2476
|
+
const vals = zod.def.values;
|
|
2477
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
2478
|
+
});
|
|
1998
2479
|
inst._zod.parse = (payload, _ctx) => {
|
|
1999
2480
|
const input = payload.value;
|
|
2000
2481
|
if (values.has(input)) return payload;
|
|
@@ -2010,67 +2491,66 @@ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
2010
2491
|
var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
2011
2492
|
$ZodType.init(inst, def);
|
|
2012
2493
|
inst._zod.optin = "optional";
|
|
2494
|
+
globalConfig.memoizer?.guard(inst);
|
|
2013
2495
|
inst._zod.parse = (payload, ctx) => {
|
|
2014
2496
|
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
2015
2497
|
const _out = def.transform(payload.value, payload);
|
|
2016
2498
|
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
2017
2499
|
payload.value = output;
|
|
2018
|
-
payload.fallback = true;
|
|
2019
2500
|
return payload;
|
|
2020
2501
|
});
|
|
2021
2502
|
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2022
2503
|
payload.value = _out;
|
|
2023
|
-
payload.fallback = true;
|
|
2024
2504
|
return payload;
|
|
2025
2505
|
};
|
|
2026
2506
|
});
|
|
2027
|
-
function handleOptionalResult(
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
value: void 0
|
|
2031
|
-
};
|
|
2032
|
-
return result;
|
|
2507
|
+
function handleOptionalResult(payload, result) {
|
|
2508
|
+
payload.value = result.issues.length ? void 0 : result.value;
|
|
2509
|
+
return payload;
|
|
2033
2510
|
}
|
|
2034
2511
|
var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
2035
2512
|
$ZodType.init(inst, def);
|
|
2036
|
-
inst._zod.optin
|
|
2513
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2037
2514
|
inst._zod.optout = "optional";
|
|
2038
|
-
|
|
2039
|
-
|
|
2515
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2516
|
+
const values = zod.def.innerType._zod.values;
|
|
2517
|
+
return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
|
|
2040
2518
|
});
|
|
2041
|
-
|
|
2042
|
-
const pattern = def.innerType._zod.pattern;
|
|
2519
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2520
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2043
2521
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2044
2522
|
});
|
|
2045
2523
|
inst._zod.parse = (payload, ctx) => {
|
|
2046
|
-
if (
|
|
2047
|
-
|
|
2048
|
-
const result = def.innerType._zod.run(
|
|
2049
|
-
|
|
2050
|
-
|
|
2524
|
+
if (payload.value === void 0) {
|
|
2525
|
+
if (def.innerType._zod.optin !== "defaulted") return payload;
|
|
2526
|
+
const result = def.innerType._zod.run({
|
|
2527
|
+
value: payload.value,
|
|
2528
|
+
issues: []
|
|
2529
|
+
}, ctx);
|
|
2530
|
+
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
2531
|
+
return handleOptionalResult(payload, result);
|
|
2051
2532
|
}
|
|
2052
|
-
if (payload.value === void 0) return payload;
|
|
2053
2533
|
return def.innerType._zod.run(payload, ctx);
|
|
2054
2534
|
};
|
|
2055
2535
|
});
|
|
2056
2536
|
var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
|
|
2057
2537
|
$ZodOptional.init(inst, def);
|
|
2058
|
-
|
|
2059
|
-
|
|
2538
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2539
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2060
2540
|
inst._zod.parse = (payload, ctx) => {
|
|
2061
2541
|
return def.innerType._zod.run(payload, ctx);
|
|
2062
2542
|
};
|
|
2063
2543
|
});
|
|
2064
2544
|
var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
2065
2545
|
$ZodType.init(inst, def);
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
const pattern = def.innerType._zod.pattern;
|
|
2546
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2547
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2548
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2549
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2070
2550
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2071
2551
|
});
|
|
2072
|
-
|
|
2073
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2552
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2553
|
+
return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
|
|
2074
2554
|
});
|
|
2075
2555
|
inst._zod.parse = (payload, ctx) => {
|
|
2076
2556
|
if (payload.value === null) return payload;
|
|
@@ -2079,8 +2559,8 @@ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
|
2079
2559
|
});
|
|
2080
2560
|
var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
2081
2561
|
$ZodType.init(inst, def);
|
|
2082
|
-
inst._zod.optin = "
|
|
2083
|
-
|
|
2562
|
+
inst._zod.optin = "defaulted";
|
|
2563
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2084
2564
|
inst._zod.parse = (payload, ctx) => {
|
|
2085
2565
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2086
2566
|
if (payload.value === void 0) {
|
|
@@ -2101,8 +2581,8 @@ function handleDefaultResult(payload, def) {
|
|
|
2101
2581
|
}
|
|
2102
2582
|
var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
2103
2583
|
$ZodType.init(inst, def);
|
|
2104
|
-
inst._zod.optin = "
|
|
2105
|
-
|
|
2584
|
+
inst._zod.optin = "defaulted";
|
|
2585
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2106
2586
|
inst._zod.parse = (payload, ctx) => {
|
|
2107
2587
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2108
2588
|
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
@@ -2111,8 +2591,8 @@ var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
2111
2591
|
});
|
|
2112
2592
|
var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2113
2593
|
$ZodType.init(inst, def);
|
|
2114
|
-
|
|
2115
|
-
const v = def.innerType._zod.values;
|
|
2594
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2595
|
+
const v = zod.def.innerType._zod.values;
|
|
2116
2596
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2117
2597
|
});
|
|
2118
2598
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2130,46 +2610,41 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2130
2610
|
});
|
|
2131
2611
|
return payload;
|
|
2132
2612
|
}
|
|
2613
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2614
|
+
if (!result.issues.length) {
|
|
2615
|
+
payload.value = result.value;
|
|
2616
|
+
if (result.memo) payload.memo = true;
|
|
2617
|
+
return payload;
|
|
2618
|
+
}
|
|
2619
|
+
payload.value = def.catchValue({
|
|
2620
|
+
...result,
|
|
2621
|
+
value: payload.value,
|
|
2622
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2623
|
+
input: payload.value
|
|
2624
|
+
});
|
|
2625
|
+
return payload;
|
|
2626
|
+
}
|
|
2133
2627
|
var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
2134
2628
|
$ZodType.init(inst, def);
|
|
2135
|
-
inst._zod.optin
|
|
2136
|
-
|
|
2137
|
-
|
|
2629
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2630
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2631
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2138
2632
|
inst._zod.parse = (payload, ctx) => {
|
|
2139
2633
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2140
|
-
const result = def.innerType._zod.run(
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2147
|
-
input: payload.value
|
|
2148
|
-
});
|
|
2149
|
-
payload.issues = [];
|
|
2150
|
-
payload.fallback = true;
|
|
2151
|
-
}
|
|
2152
|
-
return payload;
|
|
2153
|
-
});
|
|
2154
|
-
payload.value = result.value;
|
|
2155
|
-
if (result.issues.length) {
|
|
2156
|
-
payload.value = def.catchValue({
|
|
2157
|
-
...payload,
|
|
2158
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2159
|
-
input: payload.value
|
|
2160
|
-
});
|
|
2161
|
-
payload.issues = [];
|
|
2162
|
-
payload.fallback = true;
|
|
2163
|
-
}
|
|
2164
|
-
return payload;
|
|
2634
|
+
const result = def.innerType._zod.run({
|
|
2635
|
+
value: payload.value,
|
|
2636
|
+
issues: []
|
|
2637
|
+
}, ctx);
|
|
2638
|
+
if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
2639
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2165
2640
|
};
|
|
2166
2641
|
});
|
|
2167
2642
|
var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
2168
2643
|
$ZodType.init(inst, def);
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2644
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2645
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2646
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2647
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2173
2648
|
inst._zod.parse = (payload, ctx) => {
|
|
2174
2649
|
if (ctx.direction === "backward") {
|
|
2175
2650
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -2182,22 +2657,21 @@ var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2182
2657
|
};
|
|
2183
2658
|
});
|
|
2184
2659
|
function handlePipeResult(left, next, ctx) {
|
|
2185
|
-
if (left.issues.
|
|
2660
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2186
2661
|
left.aborted = true;
|
|
2187
2662
|
return left;
|
|
2188
2663
|
}
|
|
2189
2664
|
return next._zod.run({
|
|
2190
2665
|
value: left.value,
|
|
2191
|
-
issues: left.issues
|
|
2192
|
-
fallback: left.fallback
|
|
2666
|
+
issues: left.issues
|
|
2193
2667
|
}, ctx);
|
|
2194
2668
|
}
|
|
2195
2669
|
var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
2196
2670
|
$ZodType.init(inst, def);
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2671
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2672
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2673
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2674
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2201
2675
|
inst._zod.parse = (payload, ctx) => {
|
|
2202
2676
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2203
2677
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -2206,7 +2680,7 @@ var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
|
2206
2680
|
};
|
|
2207
2681
|
});
|
|
2208
2682
|
function handleReadonlyResult(payload) {
|
|
2209
|
-
payload.value = Object.freeze(payload.value);
|
|
2683
|
+
if (!payload.memo) payload.value = Object.freeze(payload.value);
|
|
2210
2684
|
return payload;
|
|
2211
2685
|
}
|
|
2212
2686
|
var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -2221,19 +2695,380 @@ var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
|
2221
2695
|
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
|
|
2222
2696
|
handleRefineResult(r, payload, input, inst);
|
|
2223
2697
|
};
|
|
2224
|
-
});
|
|
2225
|
-
function handleRefineResult(result, payload, input, inst) {
|
|
2226
|
-
if (!result) {
|
|
2227
|
-
const _iss = {
|
|
2228
|
-
code: "custom",
|
|
2229
|
-
input,
|
|
2230
|
-
inst,
|
|
2231
|
-
path: [...inst._zod.def.path ?? []],
|
|
2232
|
-
continue: !inst._zod.def.abort
|
|
2233
|
-
};
|
|
2234
|
-
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2235
|
-
payload.issues.push(issue(_iss));
|
|
2698
|
+
});
|
|
2699
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
2700
|
+
if (!result) {
|
|
2701
|
+
const _iss = {
|
|
2702
|
+
code: "custom",
|
|
2703
|
+
input,
|
|
2704
|
+
inst,
|
|
2705
|
+
path: [...inst._zod.def.path ?? []],
|
|
2706
|
+
continue: !inst._zod.def.abort
|
|
2707
|
+
};
|
|
2708
|
+
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2709
|
+
payload.issues.push(issue(_iss));
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
//#endregion
|
|
2713
|
+
//#region ../../../node_modules/zod/v4/core/memoizer.js
|
|
2714
|
+
var $ZodCyclicError = class extends Error {
|
|
2715
|
+
constructor() {
|
|
2716
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2717
|
+
this.name = "ZodCyclicError";
|
|
2718
|
+
}
|
|
2719
|
+
};
|
|
2720
|
+
/** Keyed off the context object every schema in one parse call already shares. */
|
|
2721
|
+
var STATE = "~memo";
|
|
2722
|
+
var NO_ISSUES = [];
|
|
2723
|
+
function isRef(value) {
|
|
2724
|
+
return value !== null && typeof value === "object";
|
|
2725
|
+
}
|
|
2726
|
+
function cloneIssues(issues) {
|
|
2727
|
+
return issues.map((iss) => iss.path ? {
|
|
2728
|
+
...iss,
|
|
2729
|
+
path: iss.path.slice()
|
|
2730
|
+
} : { ...iss });
|
|
2731
|
+
}
|
|
2732
|
+
var recursive = /*@__PURE__*/ new WeakMap();
|
|
2733
|
+
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
|
|
2734
|
+
var NONE = 0;
|
|
2735
|
+
var ASSUMED = 1;
|
|
2736
|
+
var PROVEN = 2;
|
|
2737
|
+
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
|
|
2738
|
+
function isRecursive(inst, stack, resolve) {
|
|
2739
|
+
const cached = recursive.get(inst);
|
|
2740
|
+
if (cached !== void 0) return cached ? PROVEN : NONE;
|
|
2741
|
+
if (stack.has(inst)) return PROVEN;
|
|
2742
|
+
stack.add(inst);
|
|
2743
|
+
let result = NONE;
|
|
2744
|
+
const check = (child) => {
|
|
2745
|
+
if (result !== PROVEN && child?._zod) {
|
|
2746
|
+
const answer = isRecursive(child, stack, resolve);
|
|
2747
|
+
if (answer > result) result = answer;
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
const shape = (sh, spread) => {
|
|
2751
|
+
let answer = NONE;
|
|
2752
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
2753
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
2754
|
+
if (spread && !desc.enumerable) continue;
|
|
2755
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
2756
|
+
if (child > answer) answer = child;
|
|
2757
|
+
}
|
|
2758
|
+
return answer;
|
|
2759
|
+
};
|
|
2760
|
+
const merge = (answer) => {
|
|
2761
|
+
if (answer > result) result = answer;
|
|
2762
|
+
};
|
|
2763
|
+
const def = inst._zod.def;
|
|
2764
|
+
switch (def.type) {
|
|
2765
|
+
case "object": {
|
|
2766
|
+
const raw = rawShape(def);
|
|
2767
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
2768
|
+
check(def.catchall);
|
|
2769
|
+
break;
|
|
2770
|
+
}
|
|
2771
|
+
case "array":
|
|
2772
|
+
check(def.element);
|
|
2773
|
+
break;
|
|
2774
|
+
case "tuple":
|
|
2775
|
+
for (const el of def.items) check(el);
|
|
2776
|
+
check(def.rest);
|
|
2777
|
+
break;
|
|
2778
|
+
case "record":
|
|
2779
|
+
case "map":
|
|
2780
|
+
check(def.keyType);
|
|
2781
|
+
check(def.valueType);
|
|
2782
|
+
break;
|
|
2783
|
+
case "set":
|
|
2784
|
+
check(def.valueType);
|
|
2785
|
+
break;
|
|
2786
|
+
case "union":
|
|
2787
|
+
for (const el of def.options) check(el);
|
|
2788
|
+
break;
|
|
2789
|
+
case "intersection":
|
|
2790
|
+
check(def.left);
|
|
2791
|
+
check(def.right);
|
|
2792
|
+
break;
|
|
2793
|
+
case "optional":
|
|
2794
|
+
case "nullable":
|
|
2795
|
+
case "default":
|
|
2796
|
+
case "prefault":
|
|
2797
|
+
case "catch":
|
|
2798
|
+
case "readonly":
|
|
2799
|
+
case "nonoptional":
|
|
2800
|
+
case "promise":
|
|
2801
|
+
case "success":
|
|
2802
|
+
check(def.innerType);
|
|
2803
|
+
break;
|
|
2804
|
+
case "pipe":
|
|
2805
|
+
check(def.in);
|
|
2806
|
+
check(def.out);
|
|
2807
|
+
break;
|
|
2808
|
+
case "function":
|
|
2809
|
+
check(def.input);
|
|
2810
|
+
check(def.output);
|
|
2811
|
+
break;
|
|
2812
|
+
case "lazy": {
|
|
2813
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
2814
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
case "template_literal":
|
|
2818
|
+
case "string":
|
|
2819
|
+
case "number":
|
|
2820
|
+
case "int":
|
|
2821
|
+
case "boolean":
|
|
2822
|
+
case "bigint":
|
|
2823
|
+
case "symbol":
|
|
2824
|
+
case "undefined":
|
|
2825
|
+
case "null":
|
|
2826
|
+
case "void":
|
|
2827
|
+
case "never":
|
|
2828
|
+
case "any":
|
|
2829
|
+
case "unknown":
|
|
2830
|
+
case "date":
|
|
2831
|
+
case "nan":
|
|
2832
|
+
case "enum":
|
|
2833
|
+
case "literal":
|
|
2834
|
+
case "file":
|
|
2835
|
+
case "transform":
|
|
2836
|
+
case "custom": break;
|
|
2837
|
+
default: for (const key in def) {
|
|
2838
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
2839
|
+
if (!desc || desc.get) continue;
|
|
2840
|
+
const value = desc.value;
|
|
2841
|
+
if (!value || typeof value !== "object") continue;
|
|
2842
|
+
if (value._zod) check(value);
|
|
2843
|
+
else if (Array.isArray(value)) for (const el of value) check(el);
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
stack.delete(inst);
|
|
2847
|
+
return settle(inst, result);
|
|
2848
|
+
}
|
|
2849
|
+
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
|
|
2850
|
+
function settle(inst, answer) {
|
|
2851
|
+
if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
|
|
2852
|
+
return answer;
|
|
2853
|
+
}
|
|
2854
|
+
function bucketFor(state, inst) {
|
|
2855
|
+
let bucket = state.buckets.get(inst);
|
|
2856
|
+
if (!bucket) {
|
|
2857
|
+
bucket = /* @__PURE__ */ new WeakMap();
|
|
2858
|
+
state.buckets.set(inst, bucket);
|
|
2859
|
+
}
|
|
2860
|
+
return bucket;
|
|
2861
|
+
}
|
|
2862
|
+
var handoff;
|
|
2863
|
+
var open = [];
|
|
2864
|
+
var memo = {
|
|
2865
|
+
alloc(_inst, payload, empty) {
|
|
2866
|
+
const bucket = handoff;
|
|
2867
|
+
if (!bucket) return empty;
|
|
2868
|
+
handoff = void 0;
|
|
2869
|
+
const entry = {
|
|
2870
|
+
value: empty,
|
|
2871
|
+
issues: null
|
|
2872
|
+
};
|
|
2873
|
+
bucket.set(payload.value, entry);
|
|
2874
|
+
open.push(entry);
|
|
2875
|
+
return empty;
|
|
2876
|
+
},
|
|
2877
|
+
guard(inst) {
|
|
2878
|
+
var _a;
|
|
2879
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2880
|
+
inst._zod.deferred.push(() => {
|
|
2881
|
+
const base = inst._zod.parse;
|
|
2882
|
+
const wrapped = (payload, ctx) => {
|
|
2883
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
|
|
2884
|
+
return base(payload, ctx);
|
|
2885
|
+
};
|
|
2886
|
+
inst._zod.parse = wrapped;
|
|
2887
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2888
|
+
});
|
|
2889
|
+
},
|
|
2890
|
+
attach(inst) {
|
|
2891
|
+
var _a;
|
|
2892
|
+
let isRecursiveInst;
|
|
2893
|
+
let rechecked = false;
|
|
2894
|
+
let lastCtx;
|
|
2895
|
+
let lastBucket;
|
|
2896
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2897
|
+
inst._zod.deferred.push(() => {
|
|
2898
|
+
const base = inst._zod.parse;
|
|
2899
|
+
const wrapped = (payload, ctx) => {
|
|
2900
|
+
if (isRecursiveInst === void 0) {
|
|
2901
|
+
const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
|
|
2902
|
+
if (walked === NONE) {
|
|
2903
|
+
inst._zod.parse = base;
|
|
2904
|
+
if (inst._zod.run === wrapped) inst._zod.run = base;
|
|
2905
|
+
return base(payload, ctx);
|
|
2906
|
+
}
|
|
2907
|
+
if (walked === PROVEN || rechecked) isRecursiveInst = true;
|
|
2908
|
+
else rechecked = true;
|
|
2909
|
+
}
|
|
2910
|
+
const input = payload.value;
|
|
2911
|
+
if (!isRef(input)) return base(payload, ctx);
|
|
2912
|
+
let state = ctx[STATE];
|
|
2913
|
+
if (!state) {
|
|
2914
|
+
state = {
|
|
2915
|
+
buckets: /* @__PURE__ */ new WeakMap(),
|
|
2916
|
+
backEdges: void 0
|
|
2917
|
+
};
|
|
2918
|
+
ctx[STATE] = state;
|
|
2919
|
+
}
|
|
2920
|
+
let bucket;
|
|
2921
|
+
if (lastCtx === ctx) bucket = lastBucket;
|
|
2922
|
+
else {
|
|
2923
|
+
bucket = bucketFor(state, inst);
|
|
2924
|
+
lastCtx = ctx;
|
|
2925
|
+
lastBucket = bucket;
|
|
2926
|
+
}
|
|
2927
|
+
const hit = bucket.get(input);
|
|
2928
|
+
if (hit) {
|
|
2929
|
+
payload.value = hit.value;
|
|
2930
|
+
if (hit.issues) {
|
|
2931
|
+
if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
|
|
2932
|
+
} else {
|
|
2933
|
+
payload.memo = true;
|
|
2934
|
+
state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
|
|
2935
|
+
state.backEdges.add(hit.value);
|
|
2936
|
+
}
|
|
2937
|
+
return payload;
|
|
2938
|
+
}
|
|
2939
|
+
handoff = bucket;
|
|
2940
|
+
const depth = open.length;
|
|
2941
|
+
const result = base(payload, ctx);
|
|
2942
|
+
handoff = void 0;
|
|
2943
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
2944
|
+
if (result instanceof Promise) return result.then((r) => {
|
|
2945
|
+
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
2946
|
+
return r;
|
|
2947
|
+
});
|
|
2948
|
+
if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
2949
|
+
return result;
|
|
2950
|
+
};
|
|
2951
|
+
inst._zod.parse = wrapped;
|
|
2952
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
};
|
|
2956
|
+
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
|
|
2957
|
+
function memoizer() {
|
|
2958
|
+
return memo;
|
|
2959
|
+
}
|
|
2960
|
+
/** Whether this value is a node a back-edge resolved to before it finished. */
|
|
2961
|
+
function isBackEdge(ctx, value) {
|
|
2962
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
2963
|
+
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
2964
|
+
}
|
|
2965
|
+
//#endregion
|
|
2966
|
+
//#region ../../../node_modules/zod/v4/locales/en.js
|
|
2967
|
+
var error = () => {
|
|
2968
|
+
const Sizable = {
|
|
2969
|
+
string: {
|
|
2970
|
+
unit: "characters",
|
|
2971
|
+
verb: "to have"
|
|
2972
|
+
},
|
|
2973
|
+
file: {
|
|
2974
|
+
unit: "bytes",
|
|
2975
|
+
verb: "to have"
|
|
2976
|
+
},
|
|
2977
|
+
array: {
|
|
2978
|
+
unit: "items",
|
|
2979
|
+
verb: "to have"
|
|
2980
|
+
},
|
|
2981
|
+
set: {
|
|
2982
|
+
unit: "items",
|
|
2983
|
+
verb: "to have"
|
|
2984
|
+
},
|
|
2985
|
+
map: {
|
|
2986
|
+
unit: "entries",
|
|
2987
|
+
verb: "to have"
|
|
2988
|
+
}
|
|
2989
|
+
};
|
|
2990
|
+
function getSizing(origin) {
|
|
2991
|
+
return Sizable[origin] ?? null;
|
|
2992
|
+
}
|
|
2993
|
+
const FormatDictionary = {
|
|
2994
|
+
regex: "input",
|
|
2995
|
+
email: "email address",
|
|
2996
|
+
url: "URL",
|
|
2997
|
+
emoji: "emoji",
|
|
2998
|
+
uuid: "UUID",
|
|
2999
|
+
uuidv4: "UUIDv4",
|
|
3000
|
+
uuidv6: "UUIDv6",
|
|
3001
|
+
nanoid: "nanoid",
|
|
3002
|
+
guid: "GUID",
|
|
3003
|
+
cuid: "cuid",
|
|
3004
|
+
cuid2: "cuid2",
|
|
3005
|
+
ulid: "ULID",
|
|
3006
|
+
xid: "XID",
|
|
3007
|
+
ksuid: "KSUID",
|
|
3008
|
+
datetime: "ISO datetime",
|
|
3009
|
+
date: "ISO date",
|
|
3010
|
+
time: "ISO time",
|
|
3011
|
+
duration: "ISO duration",
|
|
3012
|
+
ipv4: "IPv4 address",
|
|
3013
|
+
ipv6: "IPv6 address",
|
|
3014
|
+
mac: "MAC address",
|
|
3015
|
+
cidrv4: "IPv4 range",
|
|
3016
|
+
cidrv6: "IPv6 range",
|
|
3017
|
+
base64: "base64-encoded string",
|
|
3018
|
+
base64url: "base64url-encoded string",
|
|
3019
|
+
json_string: "JSON string",
|
|
3020
|
+
e164: "E.164 number",
|
|
3021
|
+
currency_code: "currency code",
|
|
3022
|
+
credit_card: "credit card number",
|
|
3023
|
+
iban: "IBAN",
|
|
3024
|
+
jwt: "JWT",
|
|
3025
|
+
template_literal: "input"
|
|
3026
|
+
};
|
|
3027
|
+
const TypeDictionary = { nan: "NaN" };
|
|
3028
|
+
function getTypeName(type, input) {
|
|
3029
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
|
|
3030
|
+
return TypeDictionary[type] ?? type;
|
|
2236
3031
|
}
|
|
3032
|
+
return (issue) => {
|
|
3033
|
+
switch (issue.code) {
|
|
3034
|
+
case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
|
|
3035
|
+
case "invalid_value":
|
|
3036
|
+
if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
3037
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
3038
|
+
case "too_big": {
|
|
3039
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
3040
|
+
const sizing = getSizing(issue.origin);
|
|
3041
|
+
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3042
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
3043
|
+
}
|
|
3044
|
+
case "too_small": {
|
|
3045
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
3046
|
+
const sizing = getSizing(issue.origin);
|
|
3047
|
+
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
3048
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
3049
|
+
}
|
|
3050
|
+
case "invalid_format": {
|
|
3051
|
+
const _issue = issue;
|
|
3052
|
+
if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3053
|
+
if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3054
|
+
if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
|
|
3055
|
+
if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3056
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
3057
|
+
}
|
|
3058
|
+
case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
3059
|
+
case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
3060
|
+
case "invalid_key": return `Invalid key in ${issue.origin}`;
|
|
3061
|
+
case "invalid_union":
|
|
3062
|
+
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
|
|
3063
|
+
if (issue.inclusive === false) return "Invalid input: more than one option matched";
|
|
3064
|
+
return "Invalid input";
|
|
3065
|
+
case "invalid_element": return `Invalid value in ${issue.origin}`;
|
|
3066
|
+
default: return `Invalid input`;
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3069
|
+
};
|
|
3070
|
+
function en_default() {
|
|
3071
|
+
return { localeError: error() };
|
|
2237
3072
|
}
|
|
2238
3073
|
//#endregion
|
|
2239
3074
|
//#region ../../../node_modules/zod/v4/core/registries.js
|
|
@@ -2284,12 +3119,16 @@ function registry() {
|
|
|
2284
3119
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
2285
3120
|
//#endregion
|
|
2286
3121
|
//#region ../../../node_modules/zod/v4/core/api.js
|
|
3122
|
+
function snapshotChecks(def) {
|
|
3123
|
+
if (def.checks) def.checks = [...def.checks];
|
|
3124
|
+
return def;
|
|
3125
|
+
}
|
|
2287
3126
|
// @__NO_SIDE_EFFECTS__
|
|
2288
3127
|
function _string(Class, params) {
|
|
2289
|
-
return new Class({
|
|
3128
|
+
return new Class(snapshotChecks({
|
|
2290
3129
|
type: "string",
|
|
2291
3130
|
...normalizeParams(params)
|
|
2292
|
-
});
|
|
3131
|
+
}));
|
|
2293
3132
|
}
|
|
2294
3133
|
// @__NO_SIDE_EFFECTS__
|
|
2295
3134
|
function _email(Class, params) {
|
|
@@ -2561,11 +3400,11 @@ function _isoDuration(Class, params) {
|
|
|
2561
3400
|
}
|
|
2562
3401
|
// @__NO_SIDE_EFFECTS__
|
|
2563
3402
|
function _number(Class, params) {
|
|
2564
|
-
return new Class({
|
|
3403
|
+
return new Class(snapshotChecks({
|
|
2565
3404
|
type: "number",
|
|
2566
3405
|
checks: [],
|
|
2567
3406
|
...normalizeParams(params)
|
|
2568
|
-
});
|
|
3407
|
+
}));
|
|
2569
3408
|
}
|
|
2570
3409
|
// @__NO_SIDE_EFFECTS__
|
|
2571
3410
|
function _int(Class, params) {
|
|
@@ -2768,7 +3607,7 @@ function _superRefine(fn, params) {
|
|
|
2768
3607
|
const _issue = issue$2;
|
|
2769
3608
|
if (_issue.fatal) _issue.continue = false;
|
|
2770
3609
|
_issue.code ?? (_issue.code = "custom");
|
|
2771
|
-
|
|
3610
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
2772
3611
|
_issue.inst ?? (_issue.inst = ch);
|
|
2773
3612
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2774
3613
|
payload.issues.push(issue(_issue));
|
|
@@ -2789,6 +3628,10 @@ function _check(fn, params) {
|
|
|
2789
3628
|
}
|
|
2790
3629
|
//#endregion
|
|
2791
3630
|
//#region ../../../node_modules/zod/v4/core/to-json-schema.js
|
|
3631
|
+
function assignProps(target, ...sources) {
|
|
3632
|
+
for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
|
|
3633
|
+
return target;
|
|
3634
|
+
}
|
|
2792
3635
|
function initializeContext(params) {
|
|
2793
3636
|
let target = params?.target ?? "draft-2020-12";
|
|
2794
3637
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -2802,12 +3645,32 @@ function initializeContext(params) {
|
|
|
2802
3645
|
io: params?.io ?? "output",
|
|
2803
3646
|
counter: 0,
|
|
2804
3647
|
seen: /* @__PURE__ */ new Map(),
|
|
3648
|
+
sharedDefsExtractedFor: void 0,
|
|
3649
|
+
sharedEmitDoneFor: void 0,
|
|
2805
3650
|
cycles: params?.cycles ?? "ref",
|
|
2806
3651
|
reused: params?.reused ?? "inline",
|
|
3652
|
+
intersections: [],
|
|
3653
|
+
deferred: [],
|
|
2807
3654
|
external: params?.external ?? void 0
|
|
2808
3655
|
};
|
|
2809
3656
|
}
|
|
2810
|
-
|
|
3657
|
+
/**
|
|
3658
|
+
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
|
|
3659
|
+
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
|
|
3660
|
+
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
|
|
3661
|
+
*/
|
|
3662
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3663
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
|
|
3664
|
+
zodSchema: schema,
|
|
3665
|
+
path: params.path,
|
|
3666
|
+
message
|
|
3667
|
+
}) : ctx.unrepresentable;
|
|
3668
|
+
if (result === "any") return false;
|
|
3669
|
+
if (result === void 0 || result === "throw") throw new Error(message);
|
|
3670
|
+
Object.assign(json, result);
|
|
3671
|
+
return true;
|
|
3672
|
+
}
|
|
3673
|
+
function processSchema(schema, ctx, _params = {
|
|
2811
3674
|
path: [],
|
|
2812
3675
|
schemaPath: []
|
|
2813
3676
|
}) {
|
|
@@ -2826,6 +3689,8 @@ function process(schema, ctx, _params = {
|
|
|
2826
3689
|
path: _params.path
|
|
2827
3690
|
};
|
|
2828
3691
|
ctx.seen.set(schema, result);
|
|
3692
|
+
ctx.sharedDefsExtractedFor = void 0;
|
|
3693
|
+
ctx.sharedEmitDoneFor = void 0;
|
|
2829
3694
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2830
3695
|
if (overrideSchema) result.schema = overrideSchema;
|
|
2831
3696
|
else {
|
|
@@ -2844,12 +3709,12 @@ function process(schema, ctx, _params = {
|
|
|
2844
3709
|
const parent = schema._zod.parent;
|
|
2845
3710
|
if (parent) {
|
|
2846
3711
|
if (!result.ref) result.ref = parent;
|
|
2847
|
-
|
|
3712
|
+
processSchema(parent, ctx, params);
|
|
2848
3713
|
ctx.seen.get(parent).isParent = true;
|
|
2849
3714
|
}
|
|
2850
3715
|
}
|
|
2851
3716
|
const meta = ctx.metadataRegistry.get(schema);
|
|
2852
|
-
if (meta)
|
|
3717
|
+
if (meta) assignProps(result.schema, meta);
|
|
2853
3718
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2854
3719
|
delete result.schema.examples;
|
|
2855
3720
|
delete result.schema.default;
|
|
@@ -2858,9 +3723,13 @@ function process(schema, ctx, _params = {
|
|
|
2858
3723
|
delete result.schema._prefault;
|
|
2859
3724
|
return ctx.seen.get(schema).schema;
|
|
2860
3725
|
}
|
|
3726
|
+
function encodeJSONPointerSegment(segment) {
|
|
3727
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3728
|
+
}
|
|
2861
3729
|
function extractDefs(ctx, schema) {
|
|
2862
3730
|
const root = ctx.seen.get(schema);
|
|
2863
3731
|
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3732
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
|
|
2864
3733
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
2865
3734
|
for (const entry of ctx.seen.entries()) {
|
|
2866
3735
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -2880,15 +3749,16 @@ function extractDefs(ctx, schema) {
|
|
|
2880
3749
|
entry[1].defId = id;
|
|
2881
3750
|
return {
|
|
2882
3751
|
defId: id,
|
|
2883
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
3752
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
|
|
2884
3753
|
};
|
|
2885
3754
|
}
|
|
2886
|
-
|
|
2887
|
-
const defUriPrefix =
|
|
3755
|
+
const uriPrefix = `#`;
|
|
3756
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3757
|
+
if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
|
|
2888
3758
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2889
3759
|
return {
|
|
2890
3760
|
defId,
|
|
2891
|
-
ref: defUriPrefix + defId
|
|
3761
|
+
ref: defUriPrefix + encodeJSONPointerSegment(defId)
|
|
2892
3762
|
};
|
|
2893
3763
|
};
|
|
2894
3764
|
const extractToDef = (entry) => {
|
|
@@ -2929,12 +3799,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
2929
3799
|
continue;
|
|
2930
3800
|
}
|
|
2931
3801
|
if (seen.count > 1) {
|
|
2932
|
-
if (ctx.reused === "ref")
|
|
2933
|
-
|
|
2934
|
-
|
|
3802
|
+
if (ctx.reused === "ref") extractToDef(entry);
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
|
|
3806
|
+
}
|
|
3807
|
+
/** 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. */
|
|
3808
|
+
function compactTypeUnion(schema) {
|
|
3809
|
+
const options = schema.anyOf;
|
|
3810
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
|
|
3811
|
+
const types = [];
|
|
3812
|
+
for (const option of options) {
|
|
3813
|
+
if (!option || typeof option !== "object") return;
|
|
3814
|
+
compactTypeUnion(option);
|
|
3815
|
+
const keys = Object.keys(option);
|
|
3816
|
+
if (keys.length !== 1 || keys[0] !== "type") return;
|
|
3817
|
+
const type = option.type;
|
|
3818
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
3819
|
+
if (typeof member !== "string") return;
|
|
3820
|
+
if (!types.includes(member)) types.push(member);
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
delete schema.anyOf;
|
|
3824
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
3825
|
+
}
|
|
3826
|
+
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
|
|
3827
|
+
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
|
|
3828
|
+
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
|
|
3829
|
+
var FOLDABLE_KEYS = /* @__PURE__ */ new Set([
|
|
3830
|
+
"type",
|
|
3831
|
+
"properties",
|
|
3832
|
+
"required",
|
|
3833
|
+
"additionalProperties"
|
|
3834
|
+
]);
|
|
3835
|
+
var UNION_KEYS = ["oneOf", "anyOf"];
|
|
3836
|
+
/** 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. */
|
|
3837
|
+
function undeclaredConstraint(member) {
|
|
3838
|
+
const extra = member.additionalProperties;
|
|
3839
|
+
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
|
|
3840
|
+
return Object.keys(extra).length ? extra : null;
|
|
3841
|
+
}
|
|
3842
|
+
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
|
|
3843
|
+
function foldObjects(members) {
|
|
3844
|
+
const objects = [];
|
|
3845
|
+
for (const member of members) {
|
|
3846
|
+
if (typeof member !== "object" || member.type !== "object") return null;
|
|
3847
|
+
for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
|
|
3848
|
+
objects.push(member);
|
|
3849
|
+
}
|
|
3850
|
+
const properties = {};
|
|
3851
|
+
const required = /* @__PURE__ */ new Set();
|
|
3852
|
+
for (const object of objects) {
|
|
3853
|
+
for (const key in object.properties) {
|
|
3854
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
|
|
3855
|
+
const parts = [];
|
|
3856
|
+
for (const other of objects) {
|
|
3857
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
3858
|
+
if (part === null || part === void 0) continue;
|
|
3859
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
|
|
2935
3860
|
}
|
|
3861
|
+
assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
|
|
3862
|
+
}
|
|
3863
|
+
for (const key of object.required ?? []) required.add(key);
|
|
3864
|
+
}
|
|
3865
|
+
const folded = {
|
|
3866
|
+
type: "object",
|
|
3867
|
+
properties
|
|
3868
|
+
};
|
|
3869
|
+
if (required.size) folded.required = [...required];
|
|
3870
|
+
if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
|
|
3871
|
+
else {
|
|
3872
|
+
const constraints = [];
|
|
3873
|
+
for (const object of objects) {
|
|
3874
|
+
const constraint = undeclaredConstraint(object);
|
|
3875
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
|
|
2936
3876
|
}
|
|
3877
|
+
if (constraints.length === 1) folded.additionalProperties = constraints[0];
|
|
3878
|
+
else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
|
|
3879
|
+
}
|
|
3880
|
+
return folded;
|
|
3881
|
+
}
|
|
3882
|
+
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
|
|
3883
|
+
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
|
|
3884
|
+
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
|
|
3885
|
+
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
|
|
3886
|
+
* into one object is the encoding that says so on every target.
|
|
3887
|
+
*
|
|
3888
|
+
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
|
|
3889
|
+
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
|
|
3890
|
+
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
|
|
3891
|
+
function foldIntersection(json) {
|
|
3892
|
+
const allOf = json.allOf;
|
|
3893
|
+
if (!Array.isArray(allOf) || allOf.length < 2) return;
|
|
3894
|
+
for (const key of FOLDABLE_KEYS) if (key in json) return;
|
|
3895
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
3896
|
+
let folded = null;
|
|
3897
|
+
if (!unions.length) folded = foldObjects(allOf);
|
|
3898
|
+
else {
|
|
3899
|
+
const union = unions[0];
|
|
3900
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
3901
|
+
if (Object.keys(union).length !== 1) return;
|
|
3902
|
+
const rest = allOf.filter((m) => m !== union);
|
|
3903
|
+
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
3904
|
+
if (branches.some((b) => !b)) return;
|
|
3905
|
+
folded = { [keyword]: branches };
|
|
2937
3906
|
}
|
|
3907
|
+
if (!folded) return;
|
|
3908
|
+
delete json.allOf;
|
|
3909
|
+
assignProps(json, folded);
|
|
2938
3910
|
}
|
|
2939
3911
|
function finalize(ctx, schema) {
|
|
2940
3912
|
const root = ctx.seen.get(schema);
|
|
@@ -2953,8 +3925,8 @@ function finalize(ctx, schema) {
|
|
|
2953
3925
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2954
3926
|
schema.allOf = schema.allOf ?? [];
|
|
2955
3927
|
schema.allOf.push(refSchema);
|
|
2956
|
-
} else
|
|
2957
|
-
|
|
3928
|
+
} else assignProps(schema, refSchema);
|
|
3929
|
+
assignProps(schema, _cached);
|
|
2958
3930
|
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
2959
3931
|
if (key === "$ref" || key === "allOf") continue;
|
|
2960
3932
|
if (!(key in _cached)) delete schema[key];
|
|
@@ -2982,7 +3954,22 @@ function finalize(ctx, schema) {
|
|
|
2982
3954
|
path: seen.path ?? []
|
|
2983
3955
|
});
|
|
2984
3956
|
};
|
|
2985
|
-
|
|
3957
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
3958
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
3959
|
+
if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
3960
|
+
for (const rewrite of ctx.deferred) rewrite();
|
|
3961
|
+
if (ctx.intersections.length) {
|
|
3962
|
+
const carriers = /* @__PURE__ */ new Map();
|
|
3963
|
+
for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
|
|
3964
|
+
const allOf = json?.allOf;
|
|
3965
|
+
if (!Array.isArray(allOf)) continue;
|
|
3966
|
+
const existing = carriers.get(allOf);
|
|
3967
|
+
if (existing) existing.push(json);
|
|
3968
|
+
else carriers.set(allOf, [json]);
|
|
3969
|
+
}
|
|
3970
|
+
for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
2986
3973
|
const result = {};
|
|
2987
3974
|
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2988
3975
|
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -2993,19 +3980,22 @@ function finalize(ctx, schema) {
|
|
|
2993
3980
|
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2994
3981
|
result.$id = ctx.external.uri(id);
|
|
2995
3982
|
}
|
|
2996
|
-
|
|
3983
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
2997
3984
|
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
2998
3985
|
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
2999
3986
|
const defs = ctx.external?.defs ?? {};
|
|
3000
|
-
for (const entry of ctx.seen.entries()) {
|
|
3987
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
|
|
3001
3988
|
const seen = entry[1];
|
|
3002
3989
|
if (seen.def && seen.defId) {
|
|
3003
3990
|
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
3004
|
-
defs
|
|
3991
|
+
assignProp(defs, seen.defId, seen.def);
|
|
3005
3992
|
}
|
|
3006
3993
|
}
|
|
3007
|
-
if (ctx.external)
|
|
3008
|
-
else
|
|
3994
|
+
if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
|
|
3995
|
+
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
|
|
3996
|
+
if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
3997
|
+
else result.definitions = defs;
|
|
3998
|
+
}
|
|
3009
3999
|
try {
|
|
3010
4000
|
const finalized = JSON.parse(JSON.stringify(result));
|
|
3011
4001
|
Object.defineProperty(finalized, "~standard", {
|
|
@@ -3033,7 +4023,7 @@ function isTransforming(_schema, _ctx) {
|
|
|
3033
4023
|
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
3034
4024
|
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
3035
4025
|
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
3036
|
-
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);
|
|
4026
|
+
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);
|
|
3037
4027
|
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
3038
4028
|
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
3039
4029
|
if (def.type === "pipe") {
|
|
@@ -3064,7 +4054,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
3064
4054
|
...params,
|
|
3065
4055
|
processors
|
|
3066
4056
|
});
|
|
3067
|
-
|
|
4057
|
+
processSchema(schema, ctx);
|
|
3068
4058
|
extractDefs(ctx, schema);
|
|
3069
4059
|
return finalize(ctx, schema);
|
|
3070
4060
|
};
|
|
@@ -3076,12 +4066,84 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
|
|
|
3076
4066
|
io,
|
|
3077
4067
|
processors
|
|
3078
4068
|
});
|
|
3079
|
-
|
|
4069
|
+
processSchema(schema, ctx);
|
|
3080
4070
|
extractDefs(ctx, schema);
|
|
3081
4071
|
return finalize(ctx, schema);
|
|
3082
4072
|
};
|
|
3083
4073
|
//#endregion
|
|
3084
4074
|
//#region ../../../node_modules/zod/v4/core/json-schema-processors.js
|
|
4075
|
+
var narrowMin = (agg, key, value) => {
|
|
4076
|
+
if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
|
|
4077
|
+
};
|
|
4078
|
+
var narrowMax = (agg, key, value) => {
|
|
4079
|
+
if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
|
|
4080
|
+
};
|
|
4081
|
+
var narrowBoth = (agg, value) => {
|
|
4082
|
+
narrowMin(agg, "minimum", value);
|
|
4083
|
+
narrowMax(agg, "maximum", value);
|
|
4084
|
+
};
|
|
4085
|
+
var addDivisor = (agg, value) => {
|
|
4086
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4087
|
+
if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
|
|
4088
|
+
};
|
|
4089
|
+
var addPattern = (agg, pattern) => {
|
|
4090
|
+
agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
|
|
4091
|
+
agg.patterns.add(pattern);
|
|
4092
|
+
};
|
|
4093
|
+
var intersectMime = (agg, mime) => {
|
|
4094
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4095
|
+
};
|
|
4096
|
+
var setFormat = (agg, format) => {
|
|
4097
|
+
agg.format = format;
|
|
4098
|
+
if (format.includes("int")) agg.isInt = true;
|
|
4099
|
+
};
|
|
4100
|
+
var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4101
|
+
var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4102
|
+
var formatContributor = (ranges) => (agg, def) => {
|
|
4103
|
+
setFormat(agg, def.format);
|
|
4104
|
+
const [minimum, maximum] = ranges[def.format];
|
|
4105
|
+
narrowMin(agg, "minimum", minimum);
|
|
4106
|
+
narrowMax(agg, "maximum", maximum);
|
|
4107
|
+
};
|
|
4108
|
+
var contributors = {
|
|
4109
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4110
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4111
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4112
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4113
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4114
|
+
min_length: minContributor,
|
|
4115
|
+
max_length: maxContributor,
|
|
4116
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4117
|
+
min_size: minContributor,
|
|
4118
|
+
max_size: maxContributor,
|
|
4119
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4120
|
+
string_format: (agg, def) => {
|
|
4121
|
+
setFormat(agg, def.format);
|
|
4122
|
+
if (def.pattern) addPattern(agg, def.pattern);
|
|
4123
|
+
if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
|
|
4124
|
+
if (def.local || def.precision === -1) agg.laxFormat = true;
|
|
4125
|
+
},
|
|
4126
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4127
|
+
};
|
|
4128
|
+
function aggregateChecks(schema) {
|
|
4129
|
+
const agg = {};
|
|
4130
|
+
const def = schema._zod.def;
|
|
4131
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4132
|
+
for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4133
|
+
const bag = schema._zod.bag;
|
|
4134
|
+
if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
|
|
4135
|
+
if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4136
|
+
if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
|
|
4137
|
+
if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4138
|
+
if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
|
|
4139
|
+
if (bag.format !== void 0) {
|
|
4140
|
+
agg.format ?? (agg.format = bag.format);
|
|
4141
|
+
if (bag.format.includes("int")) agg.isInt = true;
|
|
4142
|
+
}
|
|
4143
|
+
if (bag.mime) intersectMime(agg, bag.mime);
|
|
4144
|
+
for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
|
|
4145
|
+
return agg;
|
|
4146
|
+
}
|
|
3085
4147
|
var formatMap = {
|
|
3086
4148
|
guid: "uuid",
|
|
3087
4149
|
url: "uri",
|
|
@@ -3089,46 +4151,56 @@ var formatMap = {
|
|
|
3089
4151
|
json_string: "json-string",
|
|
3090
4152
|
regex: ""
|
|
3091
4153
|
};
|
|
4154
|
+
var exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
|
|
4155
|
+
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3092
4156
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
3093
4157
|
const json = _json;
|
|
3094
4158
|
json.type = "string";
|
|
3095
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
4159
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3096
4160
|
if (typeof minimum === "number") json.minLength = minimum;
|
|
3097
4161
|
if (typeof maximum === "number") json.maxLength = maximum;
|
|
3098
4162
|
if (format) {
|
|
3099
4163
|
json.format = formatMap[format] ?? format;
|
|
3100
4164
|
if (json.format === "") delete json.format;
|
|
3101
|
-
if (format === "time") delete json.format;
|
|
4165
|
+
if (format === "time" || laxFormat) delete json.format;
|
|
3102
4166
|
}
|
|
3103
4167
|
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3104
4168
|
if (patterns && patterns.size > 0) {
|
|
3105
|
-
const
|
|
3106
|
-
if (
|
|
3107
|
-
else if (
|
|
4169
|
+
const patternList = [...patterns].map(exactPattern);
|
|
4170
|
+
if (patternList.length === 1) json.pattern = patternList[0].source;
|
|
4171
|
+
else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
|
|
3108
4172
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3109
4173
|
pattern: regex.source
|
|
3110
4174
|
}))];
|
|
3111
4175
|
}
|
|
3112
4176
|
};
|
|
3113
|
-
var numberProcessor = (schema, ctx, _json,
|
|
4177
|
+
var numberProcessor = (schema, ctx, _json, params) => {
|
|
3114
4178
|
const json = _json;
|
|
3115
|
-
const { minimum, maximum,
|
|
3116
|
-
|
|
3117
|
-
else json.type = "number";
|
|
4179
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
4180
|
+
json.type = isInt ? "integer" : "number";
|
|
3118
4181
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3119
4182
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3120
4183
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3121
|
-
if (exMin)
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
if (
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
4184
|
+
if (exMin) {
|
|
4185
|
+
if (legacy) {
|
|
4186
|
+
json.minimum = exclusiveMinimum;
|
|
4187
|
+
json.exclusiveMinimum = true;
|
|
4188
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
4189
|
+
} else if (typeof minimum === "number") json.minimum = minimum;
|
|
4190
|
+
if (exMax) {
|
|
4191
|
+
if (legacy) {
|
|
4192
|
+
json.maximum = exclusiveMaximum;
|
|
4193
|
+
json.exclusiveMaximum = true;
|
|
4194
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
4195
|
+
} else if (typeof maximum === "number") json.maximum = maximum;
|
|
4196
|
+
if (multipleOf) {
|
|
4197
|
+
const divisors = /* @__PURE__ */ new Set();
|
|
4198
|
+
for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
|
|
4199
|
+
else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
4200
|
+
const [first, ...rest] = divisors;
|
|
4201
|
+
if (first !== void 0) json.multipleOf = first;
|
|
4202
|
+
if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
4203
|
+
}
|
|
3132
4204
|
};
|
|
3133
4205
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3134
4206
|
json.type = "boolean";
|
|
@@ -3139,18 +4211,27 @@ var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
|
3139
4211
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3140
4212
|
const def = schema._zod.def;
|
|
3141
4213
|
const values = getEnumValues(def.entries);
|
|
4214
|
+
if (values.length === 0) {
|
|
4215
|
+
json.not = {};
|
|
4216
|
+
return;
|
|
4217
|
+
}
|
|
3142
4218
|
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3143
4219
|
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3144
4220
|
json.enum = values;
|
|
3145
4221
|
};
|
|
3146
|
-
var literalProcessor = (schema, ctx, json,
|
|
4222
|
+
var literalProcessor = (schema, ctx, json, params) => {
|
|
3147
4223
|
const def = schema._zod.def;
|
|
4224
|
+
if (def.values.length === 0) {
|
|
4225
|
+
json.not = {};
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
3148
4228
|
const vals = [];
|
|
3149
4229
|
for (const val of def.values) if (val === void 0) {
|
|
3150
|
-
if (ctx
|
|
3151
|
-
} else if (typeof val === "bigint")
|
|
3152
|
-
|
|
3153
|
-
|
|
4230
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
|
|
4231
|
+
} else if (typeof val === "bigint") {
|
|
4232
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
|
|
4233
|
+
vals.push(Number(val));
|
|
4234
|
+
} else vals.push(val);
|
|
3154
4235
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3155
4236
|
const val = vals[0];
|
|
3156
4237
|
json.type = val === null ? "null" : typeof val;
|
|
@@ -3164,49 +4245,55 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
3164
4245
|
json.enum = vals;
|
|
3165
4246
|
}
|
|
3166
4247
|
};
|
|
3167
|
-
var customProcessor = (
|
|
3168
|
-
|
|
4248
|
+
var customProcessor = (schema, ctx, json, params) => {
|
|
4249
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3169
4250
|
};
|
|
3170
|
-
var transformProcessor = (
|
|
3171
|
-
|
|
4251
|
+
var transformProcessor = (schema, ctx, json, params) => {
|
|
4252
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3172
4253
|
};
|
|
3173
4254
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
3174
4255
|
const json = _json;
|
|
3175
4256
|
const def = schema._zod.def;
|
|
3176
|
-
const { minimum, maximum } = schema
|
|
4257
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3177
4258
|
if (typeof minimum === "number") json.minItems = minimum;
|
|
3178
4259
|
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3179
4260
|
json.type = "array";
|
|
3180
|
-
json.items =
|
|
4261
|
+
json.items = processSchema(def.element, ctx, {
|
|
3181
4262
|
...params,
|
|
3182
4263
|
path: [...params.path, "items"]
|
|
3183
4264
|
});
|
|
3184
4265
|
};
|
|
4266
|
+
function inputOptin(schema) {
|
|
4267
|
+
const def = schema._zod.def;
|
|
4268
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
|
|
4269
|
+
if (def.type === "catch") return inputOptin(def.innerType);
|
|
4270
|
+
return schema._zod.optin;
|
|
4271
|
+
}
|
|
3185
4272
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
3186
4273
|
const json = _json;
|
|
3187
4274
|
const def = schema._zod.def;
|
|
4275
|
+
const shape = def.shape;
|
|
4276
|
+
if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
|
|
3188
4277
|
json.type = "object";
|
|
3189
4278
|
json.properties = {};
|
|
3190
|
-
const shape
|
|
3191
|
-
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
4279
|
+
for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3192
4280
|
...params,
|
|
3193
4281
|
path: [
|
|
3194
4282
|
...params.path,
|
|
3195
4283
|
"properties",
|
|
3196
4284
|
key
|
|
3197
4285
|
]
|
|
3198
|
-
});
|
|
3199
|
-
const allKeys = new Set(Object.keys(shape));
|
|
3200
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3201
|
-
const v = def.shape[key]._zod;
|
|
3202
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
3203
|
-
else return v.optout === void 0;
|
|
3204
4286
|
}));
|
|
3205
|
-
|
|
4287
|
+
const requiredKeys = [];
|
|
4288
|
+
for (const key of Object.keys(shape)) {
|
|
4289
|
+
const field = def.shape[key];
|
|
4290
|
+
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
|
|
4291
|
+
}
|
|
4292
|
+
if (requiredKeys.length > 0) json.required = requiredKeys;
|
|
3206
4293
|
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3207
4294
|
else if (!def.catchall) {
|
|
3208
4295
|
if (ctx.io === "output") json.additionalProperties = false;
|
|
3209
|
-
} else if (def.catchall) json.additionalProperties =
|
|
4296
|
+
} else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3210
4297
|
...params,
|
|
3211
4298
|
path: [...params.path, "additionalProperties"]
|
|
3212
4299
|
});
|
|
@@ -3214,7 +4301,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3214
4301
|
var unionProcessor = (schema, ctx, json, params) => {
|
|
3215
4302
|
const def = schema._zod.def;
|
|
3216
4303
|
const isExclusive = def.inclusive === false;
|
|
3217
|
-
const options = def.options.map((x, i) =>
|
|
4304
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
3218
4305
|
...params,
|
|
3219
4306
|
path: [
|
|
3220
4307
|
...params.path,
|
|
@@ -3227,7 +4314,7 @@ var unionProcessor = (schema, ctx, json, params) => {
|
|
|
3227
4314
|
};
|
|
3228
4315
|
var intersectionProcessor = (schema, ctx, json, params) => {
|
|
3229
4316
|
const def = schema._zod.def;
|
|
3230
|
-
const a =
|
|
4317
|
+
const a = processSchema(def.left, ctx, {
|
|
3231
4318
|
...params,
|
|
3232
4319
|
path: [
|
|
3233
4320
|
...params.path,
|
|
@@ -3235,7 +4322,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3235
4322
|
0
|
|
3236
4323
|
]
|
|
3237
4324
|
});
|
|
3238
|
-
const b =
|
|
4325
|
+
const b = processSchema(def.right, ctx, {
|
|
3239
4326
|
...params,
|
|
3240
4327
|
path: [
|
|
3241
4328
|
...params.path,
|
|
@@ -3244,11 +4331,13 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3244
4331
|
]
|
|
3245
4332
|
});
|
|
3246
4333
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3247
|
-
|
|
4334
|
+
const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
4335
|
+
json.allOf = allOf;
|
|
4336
|
+
ctx.intersections.push(allOf);
|
|
3248
4337
|
};
|
|
3249
4338
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3250
4339
|
const def = schema._zod.def;
|
|
3251
|
-
const inner =
|
|
4340
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
3252
4341
|
const seen = ctx.seen.get(schema);
|
|
3253
4342
|
if (ctx.target === "openapi-3.0") {
|
|
3254
4343
|
seen.ref = def.innerType;
|
|
@@ -3257,34 +4346,53 @@ var nullableProcessor = (schema, ctx, json, params) => {
|
|
|
3257
4346
|
};
|
|
3258
4347
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3259
4348
|
const def = schema._zod.def;
|
|
3260
|
-
|
|
4349
|
+
processSchema(def.innerType, ctx, params);
|
|
3261
4350
|
const seen = ctx.seen.get(schema);
|
|
3262
4351
|
seen.ref = def.innerType;
|
|
3263
4352
|
};
|
|
4353
|
+
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
|
|
4354
|
+
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
|
|
4355
|
+
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
|
|
4356
|
+
var UNREPRESENTABLE_DEFAULT = Symbol();
|
|
4357
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4358
|
+
let unrepresentable = false;
|
|
4359
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4360
|
+
if (typeof val !== "bigint") return val;
|
|
4361
|
+
unrepresentable = true;
|
|
4362
|
+
return null;
|
|
4363
|
+
});
|
|
4364
|
+
if (!unrepresentable) return JSON.parse(serialized);
|
|
4365
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4366
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4367
|
+
}
|
|
3264
4368
|
var defaultProcessor = (schema, ctx, json, params) => {
|
|
3265
4369
|
const def = schema._zod.def;
|
|
3266
|
-
|
|
4370
|
+
processSchema(def.innerType, ctx, params);
|
|
3267
4371
|
const seen = ctx.seen.get(schema);
|
|
3268
4372
|
seen.ref = def.innerType;
|
|
3269
|
-
|
|
4373
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4374
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
|
|
3270
4375
|
};
|
|
3271
4376
|
var prefaultProcessor = (schema, ctx, json, params) => {
|
|
3272
4377
|
const def = schema._zod.def;
|
|
3273
|
-
|
|
4378
|
+
processSchema(def.innerType, ctx, params);
|
|
3274
4379
|
const seen = ctx.seen.get(schema);
|
|
3275
4380
|
seen.ref = def.innerType;
|
|
3276
|
-
if (ctx.io
|
|
4381
|
+
if (ctx.io !== "input") return;
|
|
4382
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4383
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
|
|
3277
4384
|
};
|
|
3278
4385
|
var catchProcessor = (schema, ctx, json, params) => {
|
|
3279
4386
|
const def = schema._zod.def;
|
|
3280
|
-
|
|
4387
|
+
processSchema(def.innerType, ctx, params);
|
|
3281
4388
|
const seen = ctx.seen.get(schema);
|
|
3282
4389
|
seen.ref = def.innerType;
|
|
3283
4390
|
let catchValue;
|
|
3284
4391
|
try {
|
|
3285
4392
|
catchValue = def.catchValue(void 0);
|
|
3286
4393
|
} catch {
|
|
3287
|
-
|
|
4394
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4395
|
+
return;
|
|
3288
4396
|
}
|
|
3289
4397
|
json.default = catchValue;
|
|
3290
4398
|
};
|
|
@@ -3292,75 +4400,73 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
3292
4400
|
const def = schema._zod.def;
|
|
3293
4401
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
3294
4402
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
3295
|
-
|
|
4403
|
+
processSchema(innerType, ctx, params);
|
|
3296
4404
|
const seen = ctx.seen.get(schema);
|
|
3297
4405
|
seen.ref = innerType;
|
|
3298
4406
|
};
|
|
3299
4407
|
var readonlyProcessor = (schema, ctx, json, params) => {
|
|
3300
4408
|
const def = schema._zod.def;
|
|
3301
|
-
|
|
4409
|
+
processSchema(def.innerType, ctx, params);
|
|
3302
4410
|
const seen = ctx.seen.get(schema);
|
|
3303
4411
|
seen.ref = def.innerType;
|
|
3304
4412
|
json.readOnly = true;
|
|
3305
4413
|
};
|
|
3306
4414
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
3307
4415
|
const def = schema._zod.def;
|
|
3308
|
-
|
|
4416
|
+
processSchema(def.innerType, ctx, params);
|
|
3309
4417
|
const seen = ctx.seen.get(schema);
|
|
3310
4418
|
seen.ref = def.innerType;
|
|
3311
4419
|
};
|
|
3312
4420
|
//#endregion
|
|
3313
|
-
//#region ../../../node_modules/zod/v4/classic/iso.js
|
|
3314
|
-
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
3315
|
-
$ZodISODateTime.init(inst, def);
|
|
3316
|
-
ZodStringFormat.init(inst, def);
|
|
3317
|
-
});
|
|
3318
|
-
function datetime(params) {
|
|
3319
|
-
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
3320
|
-
}
|
|
3321
|
-
var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
3322
|
-
$ZodISODate.init(inst, def);
|
|
3323
|
-
ZodStringFormat.init(inst, def);
|
|
3324
|
-
});
|
|
3325
|
-
function date(params) {
|
|
3326
|
-
return /* @__PURE__ */ _isoDate(ZodISODate, params);
|
|
3327
|
-
}
|
|
3328
|
-
var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
3329
|
-
$ZodISOTime.init(inst, def);
|
|
3330
|
-
ZodStringFormat.init(inst, def);
|
|
3331
|
-
});
|
|
3332
|
-
function time(params) {
|
|
3333
|
-
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
|
|
3334
|
-
}
|
|
3335
|
-
var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
3336
|
-
$ZodISODuration.init(inst, def);
|
|
3337
|
-
ZodStringFormat.init(inst, def);
|
|
3338
|
-
});
|
|
3339
|
-
function duration(params) {
|
|
3340
|
-
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
3341
|
-
}
|
|
3342
|
-
//#endregion
|
|
3343
4421
|
//#region ../../../node_modules/zod/v4/classic/errors.js
|
|
4422
|
+
var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
4423
|
+
function _lazyMethod(proto, key, make) {
|
|
4424
|
+
Object.defineProperty(proto, key, {
|
|
4425
|
+
configurable: true,
|
|
4426
|
+
enumerable: false,
|
|
4427
|
+
get() {
|
|
4428
|
+
const value = make(this);
|
|
4429
|
+
Object.defineProperty(this, key, {
|
|
4430
|
+
value,
|
|
4431
|
+
configurable: true,
|
|
4432
|
+
writable: true
|
|
4433
|
+
});
|
|
4434
|
+
return value;
|
|
4435
|
+
},
|
|
4436
|
+
set(value) {
|
|
4437
|
+
Object.defineProperty(this, key, {
|
|
4438
|
+
value,
|
|
4439
|
+
configurable: true,
|
|
4440
|
+
writable: true
|
|
4441
|
+
});
|
|
4442
|
+
}
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
3344
4445
|
var initializer = (inst, issues) => {
|
|
3345
4446
|
$ZodError.init(inst, issues);
|
|
3346
4447
|
inst.name = "ZodError";
|
|
3347
|
-
Object.
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
4448
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4449
|
+
if (_installedErrorProtos.has(proto)) return;
|
|
4450
|
+
_installedErrorProtos.add(proto);
|
|
4451
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4452
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4453
|
+
_lazyMethod(proto, "addIssue", (self) => (issue) => {
|
|
4454
|
+
self.issues.push(issue);
|
|
4455
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4456
|
+
});
|
|
4457
|
+
_lazyMethod(proto, "addIssues", (self) => (issues) => {
|
|
4458
|
+
self.issues.push(...issues);
|
|
4459
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4460
|
+
});
|
|
4461
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4462
|
+
configurable: true,
|
|
4463
|
+
enumerable: false,
|
|
4464
|
+
get() {
|
|
4465
|
+
return this.issues.length === 0;
|
|
4466
|
+
}
|
|
3361
4467
|
});
|
|
3362
4468
|
};
|
|
3363
|
-
var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
|
|
4469
|
+
var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
|
|
3364
4470
|
//#endregion
|
|
3365
4471
|
//#region ../../../node_modules/zod/v4/classic/parse.js
|
|
3366
4472
|
var parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
@@ -3377,254 +4483,319 @@ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
|
3377
4483
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3378
4484
|
//#endregion
|
|
3379
4485
|
//#region ../../../node_modules/zod/v4/classic/schemas.js
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
if (!
|
|
3385
|
-
installed = /* @__PURE__ */ new Set();
|
|
3386
|
-
_installedGroups.set(proto, installed);
|
|
3387
|
-
}
|
|
3388
|
-
if (installed.has(group)) return;
|
|
3389
|
-
installed.add(group);
|
|
3390
|
-
for (const key in methods) {
|
|
3391
|
-
const fn = methods[key];
|
|
3392
|
-
Object.defineProperty(proto, key, {
|
|
3393
|
-
configurable: true,
|
|
3394
|
-
enumerable: false,
|
|
3395
|
-
get() {
|
|
3396
|
-
const bound = fn.bind(this);
|
|
3397
|
-
Object.defineProperty(this, key, {
|
|
3398
|
-
configurable: true,
|
|
3399
|
-
writable: true,
|
|
3400
|
-
enumerable: true,
|
|
3401
|
-
value: bound
|
|
3402
|
-
});
|
|
3403
|
-
return bound;
|
|
3404
|
-
},
|
|
3405
|
-
set(v) {
|
|
3406
|
-
Object.defineProperty(this, key, {
|
|
3407
|
-
configurable: true,
|
|
3408
|
-
writable: true,
|
|
3409
|
-
enumerable: true,
|
|
3410
|
-
value: v
|
|
3411
|
-
});
|
|
3412
|
-
}
|
|
3413
|
-
});
|
|
3414
|
-
}
|
|
4486
|
+
function _ensureDefaultLocale() {
|
|
4487
|
+
if (!globalConfig.localeError) config(en_default());
|
|
4488
|
+
}
|
|
4489
|
+
function _ensureDefaultMemoizer() {
|
|
4490
|
+
if (!globalConfig.memoizer) config({ memoizer: memoizer() });
|
|
3415
4491
|
}
|
|
3416
4492
|
var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
4493
|
+
_ensureDefaultLocale();
|
|
3417
4494
|
$ZodType.init(inst, def);
|
|
3418
|
-
Object.assign(inst["~standard"], { jsonSchema: {
|
|
3419
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3420
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3421
|
-
} });
|
|
3422
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3423
4495
|
inst.def = def;
|
|
3424
4496
|
inst.type = def.type;
|
|
3425
|
-
Object.defineProperty(inst, "_def", { value: def });
|
|
3426
|
-
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
3427
|
-
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
3428
|
-
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
3429
|
-
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
3430
|
-
inst.spa = inst.safeParseAsync;
|
|
3431
|
-
inst.encode = (data, params) => encode(inst, data, params);
|
|
3432
|
-
inst.decode = (data, params) => decode(inst, data, params);
|
|
3433
|
-
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
3434
|
-
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
3435
|
-
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
3436
|
-
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
3437
|
-
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
3438
|
-
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
3439
|
-
_installLazyMethods(inst, "ZodType", {
|
|
3440
|
-
check(...chks) {
|
|
3441
|
-
const def = this.def;
|
|
3442
|
-
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
3443
|
-
check: ch,
|
|
3444
|
-
def: { check: "custom" },
|
|
3445
|
-
onattach: []
|
|
3446
|
-
} } : ch)] }), { parent: true });
|
|
3447
|
-
},
|
|
3448
|
-
with(...chks) {
|
|
3449
|
-
return this.check(...chks);
|
|
3450
|
-
},
|
|
3451
|
-
clone(def, params) {
|
|
3452
|
-
return clone(this, def, params);
|
|
3453
|
-
},
|
|
3454
|
-
brand() {
|
|
3455
|
-
return this;
|
|
3456
|
-
},
|
|
3457
|
-
register(reg, meta) {
|
|
3458
|
-
reg.add(this, meta);
|
|
3459
|
-
return this;
|
|
3460
|
-
},
|
|
3461
|
-
refine(check, params) {
|
|
3462
|
-
return this.check(refine(check, params));
|
|
3463
|
-
},
|
|
3464
|
-
superRefine(refinement, params) {
|
|
3465
|
-
return this.check(superRefine(refinement, params));
|
|
3466
|
-
},
|
|
3467
|
-
overwrite(fn) {
|
|
3468
|
-
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
3469
|
-
},
|
|
3470
|
-
optional() {
|
|
3471
|
-
return optional(this);
|
|
3472
|
-
},
|
|
3473
|
-
exactOptional() {
|
|
3474
|
-
return exactOptional(this);
|
|
3475
|
-
},
|
|
3476
|
-
nullable() {
|
|
3477
|
-
return nullable(this);
|
|
3478
|
-
},
|
|
3479
|
-
nullish() {
|
|
3480
|
-
return optional(nullable(this));
|
|
3481
|
-
},
|
|
3482
|
-
nonoptional(params) {
|
|
3483
|
-
return nonoptional(this, params);
|
|
3484
|
-
},
|
|
3485
|
-
array() {
|
|
3486
|
-
return array(this);
|
|
3487
|
-
},
|
|
3488
|
-
or(arg) {
|
|
3489
|
-
return union([this, arg]);
|
|
3490
|
-
},
|
|
3491
|
-
and(arg) {
|
|
3492
|
-
return intersection(this, arg);
|
|
3493
|
-
},
|
|
3494
|
-
transform(tx) {
|
|
3495
|
-
return pipe(this, transform(tx));
|
|
3496
|
-
},
|
|
3497
|
-
default(d) {
|
|
3498
|
-
return _default(this, d);
|
|
3499
|
-
},
|
|
3500
|
-
prefault(d) {
|
|
3501
|
-
return prefault(this, d);
|
|
3502
|
-
},
|
|
3503
|
-
catch(params) {
|
|
3504
|
-
return _catch(this, params);
|
|
3505
|
-
},
|
|
3506
|
-
pipe(target) {
|
|
3507
|
-
return pipe(this, target);
|
|
3508
|
-
},
|
|
3509
|
-
readonly() {
|
|
3510
|
-
return readonly(this);
|
|
3511
|
-
},
|
|
3512
|
-
describe(description) {
|
|
3513
|
-
const cl = this.clone();
|
|
3514
|
-
globalRegistry.add(cl, { description });
|
|
3515
|
-
return cl;
|
|
3516
|
-
},
|
|
3517
|
-
meta(...args) {
|
|
3518
|
-
if (args.length === 0) return globalRegistry.get(this);
|
|
3519
|
-
const cl = this.clone();
|
|
3520
|
-
globalRegistry.add(cl, args[0]);
|
|
3521
|
-
return cl;
|
|
3522
|
-
},
|
|
3523
|
-
isOptional() {
|
|
3524
|
-
return this.safeParse(void 0).success;
|
|
3525
|
-
},
|
|
3526
|
-
isNullable() {
|
|
3527
|
-
return this.safeParse(null).success;
|
|
3528
|
-
},
|
|
3529
|
-
apply(fn) {
|
|
3530
|
-
return fn(this);
|
|
3531
|
-
}
|
|
3532
|
-
});
|
|
3533
|
-
Object.defineProperty(inst, "description", {
|
|
3534
|
-
get() {
|
|
3535
|
-
return globalRegistry.get(inst)?.description;
|
|
3536
|
-
},
|
|
3537
|
-
configurable: true
|
|
3538
|
-
});
|
|
3539
4497
|
return inst;
|
|
4498
|
+
}, {
|
|
4499
|
+
check(...chks) {
|
|
4500
|
+
const def = this.def;
|
|
4501
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
4502
|
+
check: ch,
|
|
4503
|
+
def: { check: "custom" },
|
|
4504
|
+
onattach: []
|
|
4505
|
+
} } : ch)] }), { parent: true });
|
|
4506
|
+
},
|
|
4507
|
+
with(...chks) {
|
|
4508
|
+
return this.check(...chks);
|
|
4509
|
+
},
|
|
4510
|
+
clone(def, params) {
|
|
4511
|
+
return clone(this, def, params);
|
|
4512
|
+
},
|
|
4513
|
+
brand() {
|
|
4514
|
+
return this;
|
|
4515
|
+
},
|
|
4516
|
+
register(reg, meta) {
|
|
4517
|
+
reg.add(this, meta);
|
|
4518
|
+
return this;
|
|
4519
|
+
},
|
|
4520
|
+
refine(check, params) {
|
|
4521
|
+
return this.check(refine(check, params));
|
|
4522
|
+
},
|
|
4523
|
+
superRefine(refinement, params) {
|
|
4524
|
+
return this.check(superRefine(refinement, params));
|
|
4525
|
+
},
|
|
4526
|
+
overwrite(fn) {
|
|
4527
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4528
|
+
},
|
|
4529
|
+
optional() {
|
|
4530
|
+
return optional(this);
|
|
4531
|
+
},
|
|
4532
|
+
exactOptional() {
|
|
4533
|
+
return exactOptional(this);
|
|
4534
|
+
},
|
|
4535
|
+
nullable() {
|
|
4536
|
+
return nullable(this);
|
|
4537
|
+
},
|
|
4538
|
+
nullish() {
|
|
4539
|
+
return optional(nullable(this));
|
|
4540
|
+
},
|
|
4541
|
+
nonoptional(params) {
|
|
4542
|
+
return nonoptional(this, params);
|
|
4543
|
+
},
|
|
4544
|
+
array() {
|
|
4545
|
+
return array(this);
|
|
4546
|
+
},
|
|
4547
|
+
or(arg) {
|
|
4548
|
+
return union([this, arg]);
|
|
4549
|
+
},
|
|
4550
|
+
and(arg) {
|
|
4551
|
+
return intersection(this, arg);
|
|
4552
|
+
},
|
|
4553
|
+
transform(tx) {
|
|
4554
|
+
return pipe(this, transform(tx));
|
|
4555
|
+
},
|
|
4556
|
+
default(d) {
|
|
4557
|
+
return _default(this, d);
|
|
4558
|
+
},
|
|
4559
|
+
prefault(d) {
|
|
4560
|
+
return prefault(this, d);
|
|
4561
|
+
},
|
|
4562
|
+
catch(params) {
|
|
4563
|
+
return _catch(this, params);
|
|
4564
|
+
},
|
|
4565
|
+
pipe(target) {
|
|
4566
|
+
return pipe(this, target);
|
|
4567
|
+
},
|
|
4568
|
+
readonly() {
|
|
4569
|
+
return readonly(this);
|
|
4570
|
+
},
|
|
4571
|
+
describe(description) {
|
|
4572
|
+
const cl = this.clone();
|
|
4573
|
+
globalRegistry.add(cl, { description });
|
|
4574
|
+
return cl;
|
|
4575
|
+
},
|
|
4576
|
+
meta(...args) {
|
|
4577
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
4578
|
+
const cl = this.clone();
|
|
4579
|
+
globalRegistry.add(cl, args[0]);
|
|
4580
|
+
return cl;
|
|
4581
|
+
},
|
|
4582
|
+
isOptional() {
|
|
4583
|
+
return this.safeParse(void 0).success;
|
|
4584
|
+
},
|
|
4585
|
+
isNullable() {
|
|
4586
|
+
return this.safeParse(null).success;
|
|
4587
|
+
},
|
|
4588
|
+
apply(fn, ...args) {
|
|
4589
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
4590
|
+
},
|
|
4591
|
+
get "~standard"() {
|
|
4592
|
+
return hide(this, "~standard", {
|
|
4593
|
+
...standardProps(this),
|
|
4594
|
+
jsonSchema: {
|
|
4595
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
4596
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
4597
|
+
}
|
|
4598
|
+
});
|
|
4599
|
+
},
|
|
4600
|
+
set "~standard"(value) {
|
|
4601
|
+
own(this, "~standard", value);
|
|
4602
|
+
},
|
|
4603
|
+
parse: function _parse(data, params) {
|
|
4604
|
+
return parse(this, data, params, { callee: _parse });
|
|
4605
|
+
},
|
|
4606
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
4607
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
4608
|
+
},
|
|
4609
|
+
safeParse(data, params) {
|
|
4610
|
+
return safeParse(this, data, params);
|
|
4611
|
+
},
|
|
4612
|
+
async safeParseAsync(data, params) {
|
|
4613
|
+
return safeParseAsync(this, data, params);
|
|
4614
|
+
},
|
|
4615
|
+
get spa() {
|
|
4616
|
+
return this?.safeParseAsync;
|
|
4617
|
+
},
|
|
4618
|
+
set spa(value) {
|
|
4619
|
+
own(this, "spa", value);
|
|
4620
|
+
},
|
|
4621
|
+
validate(data, params) {
|
|
4622
|
+
return validate(this, data, params);
|
|
4623
|
+
},
|
|
4624
|
+
validateAsync(data, params) {
|
|
4625
|
+
return validateAsync$1(this, data, params);
|
|
4626
|
+
},
|
|
4627
|
+
encode: function _encode(data, params) {
|
|
4628
|
+
return encode(this, data, params, { callee: _encode });
|
|
4629
|
+
},
|
|
4630
|
+
decode: function _decode(data, params) {
|
|
4631
|
+
return decode(this, data, params, { callee: _decode });
|
|
4632
|
+
},
|
|
4633
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
4634
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
4635
|
+
},
|
|
4636
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
4637
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
4638
|
+
},
|
|
4639
|
+
safeEncode(data, params) {
|
|
4640
|
+
return safeEncode(this, data, params);
|
|
4641
|
+
},
|
|
4642
|
+
safeDecode(data, params) {
|
|
4643
|
+
return safeDecode(this, data, params);
|
|
4644
|
+
},
|
|
4645
|
+
async safeEncodeAsync(data, params) {
|
|
4646
|
+
return safeEncodeAsync(this, data, params);
|
|
4647
|
+
},
|
|
4648
|
+
async safeDecodeAsync(data, params) {
|
|
4649
|
+
return safeDecodeAsync(this, data, params);
|
|
4650
|
+
},
|
|
4651
|
+
toJSONSchema(params) {
|
|
4652
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
4653
|
+
},
|
|
4654
|
+
get description() {
|
|
4655
|
+
return globalRegistry.get(this)?.description;
|
|
4656
|
+
},
|
|
4657
|
+
get _def() {
|
|
4658
|
+
return this._zod.def;
|
|
4659
|
+
}
|
|
3540
4660
|
});
|
|
3541
4661
|
/** @internal */
|
|
3542
4662
|
var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
3543
4663
|
$ZodString.init(inst, def);
|
|
3544
4664
|
ZodType.init(inst, def);
|
|
3545
4665
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
});
|
|
4666
|
+
}, /*@__PURE__*/ derived({
|
|
4667
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
4668
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
4669
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
4670
|
+
}, {
|
|
4671
|
+
regex(...args) {
|
|
4672
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4673
|
+
},
|
|
4674
|
+
includes(...args) {
|
|
4675
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4676
|
+
},
|
|
4677
|
+
startsWith(...args) {
|
|
4678
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4679
|
+
},
|
|
4680
|
+
endsWith(...args) {
|
|
4681
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4682
|
+
},
|
|
4683
|
+
min(...args) {
|
|
4684
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4685
|
+
},
|
|
4686
|
+
max(...args) {
|
|
4687
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4688
|
+
},
|
|
4689
|
+
length(...args) {
|
|
4690
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
4691
|
+
},
|
|
4692
|
+
nonempty(...args) {
|
|
4693
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4694
|
+
},
|
|
4695
|
+
lowercase(params) {
|
|
4696
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4697
|
+
},
|
|
4698
|
+
uppercase(params) {
|
|
4699
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4700
|
+
},
|
|
4701
|
+
trim() {
|
|
4702
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
4703
|
+
},
|
|
4704
|
+
normalize(...args) {
|
|
4705
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4706
|
+
},
|
|
4707
|
+
toLowerCase() {
|
|
4708
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4709
|
+
},
|
|
4710
|
+
toUpperCase() {
|
|
4711
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4712
|
+
},
|
|
4713
|
+
slugify() {
|
|
4714
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
4715
|
+
}
|
|
4716
|
+
}));
|
|
3598
4717
|
var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
3599
4718
|
$ZodString.init(inst, def);
|
|
3600
4719
|
_ZodString.init(inst, def);
|
|
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
|
-
|
|
4720
|
+
}, {
|
|
4721
|
+
email(params) {
|
|
4722
|
+
return this.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4723
|
+
},
|
|
4724
|
+
url(params) {
|
|
4725
|
+
return this.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4726
|
+
},
|
|
4727
|
+
jwt(params) {
|
|
4728
|
+
return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4729
|
+
},
|
|
4730
|
+
emoji(params) {
|
|
4731
|
+
return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4732
|
+
},
|
|
4733
|
+
guid(params) {
|
|
4734
|
+
return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4735
|
+
},
|
|
4736
|
+
uuid(params) {
|
|
4737
|
+
return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4738
|
+
},
|
|
4739
|
+
uuidv4(params) {
|
|
4740
|
+
return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4741
|
+
},
|
|
4742
|
+
uuidv6(params) {
|
|
4743
|
+
return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4744
|
+
},
|
|
4745
|
+
uuidv7(params) {
|
|
4746
|
+
return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4747
|
+
},
|
|
4748
|
+
nanoid(params) {
|
|
4749
|
+
return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4750
|
+
},
|
|
4751
|
+
cuid(params) {
|
|
4752
|
+
return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4753
|
+
},
|
|
4754
|
+
cuid2(params) {
|
|
4755
|
+
return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4756
|
+
},
|
|
4757
|
+
ulid(params) {
|
|
4758
|
+
return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4759
|
+
},
|
|
4760
|
+
base64(params) {
|
|
4761
|
+
return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4762
|
+
},
|
|
4763
|
+
base64url(params) {
|
|
4764
|
+
return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4765
|
+
},
|
|
4766
|
+
xid(params) {
|
|
4767
|
+
return this.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4768
|
+
},
|
|
4769
|
+
ksuid(params) {
|
|
4770
|
+
return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4771
|
+
},
|
|
4772
|
+
ipv4(params) {
|
|
4773
|
+
return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4774
|
+
},
|
|
4775
|
+
ipv6(params) {
|
|
4776
|
+
return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4777
|
+
},
|
|
4778
|
+
cidrv4(params) {
|
|
4779
|
+
return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4780
|
+
},
|
|
4781
|
+
cidrv6(params) {
|
|
4782
|
+
return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4783
|
+
},
|
|
4784
|
+
e164(params) {
|
|
4785
|
+
return this.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4786
|
+
},
|
|
4787
|
+
datetime(params) {
|
|
4788
|
+
return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
|
|
4789
|
+
},
|
|
4790
|
+
date(params) {
|
|
4791
|
+
return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
|
|
4792
|
+
},
|
|
4793
|
+
time(params) {
|
|
4794
|
+
return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
|
|
4795
|
+
},
|
|
4796
|
+
duration(params) {
|
|
4797
|
+
return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
|
|
4798
|
+
}
|
|
3628
4799
|
});
|
|
3629
4800
|
function string(params) {
|
|
3630
4801
|
return /* @__PURE__ */ _string(ZodString, params);
|
|
@@ -3633,6 +4804,22 @@ var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def)
|
|
|
3633
4804
|
$ZodStringFormat.init(inst, def);
|
|
3634
4805
|
_ZodString.init(inst, def);
|
|
3635
4806
|
});
|
|
4807
|
+
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4808
|
+
$ZodISODateTime.init(inst, def);
|
|
4809
|
+
ZodStringFormat.init(inst, def);
|
|
4810
|
+
});
|
|
4811
|
+
var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
4812
|
+
$ZodISODate.init(inst, def);
|
|
4813
|
+
ZodStringFormat.init(inst, def);
|
|
4814
|
+
});
|
|
4815
|
+
var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
4816
|
+
$ZodISOTime.init(inst, def);
|
|
4817
|
+
ZodStringFormat.init(inst, def);
|
|
4818
|
+
});
|
|
4819
|
+
var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
4820
|
+
$ZodISODuration.init(inst, def);
|
|
4821
|
+
ZodStringFormat.init(inst, def);
|
|
4822
|
+
});
|
|
3636
4823
|
var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
3637
4824
|
$ZodEmail.init(inst, def);
|
|
3638
4825
|
ZodStringFormat.init(inst, def);
|
|
@@ -3718,60 +4905,68 @@ var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
|
3718
4905
|
$ZodNumber.init(inst, def);
|
|
3719
4906
|
ZodType.init(inst, def);
|
|
3720
4907
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
3721
|
-
_installLazyMethods(inst, "ZodNumber", {
|
|
3722
|
-
gt(value, params) {
|
|
3723
|
-
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
3724
|
-
},
|
|
3725
|
-
gte(value, params) {
|
|
3726
|
-
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3727
|
-
},
|
|
3728
|
-
min(value, params) {
|
|
3729
|
-
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
3730
|
-
},
|
|
3731
|
-
lt(value, params) {
|
|
3732
|
-
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
3733
|
-
},
|
|
3734
|
-
lte(value, params) {
|
|
3735
|
-
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3736
|
-
},
|
|
3737
|
-
max(value, params) {
|
|
3738
|
-
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
3739
|
-
},
|
|
3740
|
-
int(params) {
|
|
3741
|
-
return this.check(int(params));
|
|
3742
|
-
},
|
|
3743
|
-
safe(params) {
|
|
3744
|
-
return this.check(int(params));
|
|
3745
|
-
},
|
|
3746
|
-
positive(params) {
|
|
3747
|
-
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
3748
|
-
},
|
|
3749
|
-
nonnegative(params) {
|
|
3750
|
-
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
3751
|
-
},
|
|
3752
|
-
negative(params) {
|
|
3753
|
-
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
3754
|
-
},
|
|
3755
|
-
nonpositive(params) {
|
|
3756
|
-
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
3757
|
-
},
|
|
3758
|
-
multipleOf(value, params) {
|
|
3759
|
-
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3760
|
-
},
|
|
3761
|
-
step(value, params) {
|
|
3762
|
-
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3763
|
-
},
|
|
3764
|
-
finite() {
|
|
3765
|
-
return this;
|
|
3766
|
-
}
|
|
3767
|
-
});
|
|
3768
|
-
const bag = inst._zod.bag;
|
|
3769
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3770
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3771
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
3772
4908
|
inst.isFinite = true;
|
|
3773
|
-
|
|
3774
|
-
|
|
4909
|
+
}, /*@__PURE__*/ derived({
|
|
4910
|
+
minValue: (inst) => {
|
|
4911
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
4912
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
4913
|
+
},
|
|
4914
|
+
maxValue: (inst) => {
|
|
4915
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
4916
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
4917
|
+
},
|
|
4918
|
+
isInt: (inst) => {
|
|
4919
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
4920
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
4921
|
+
},
|
|
4922
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
4923
|
+
}, {
|
|
4924
|
+
gt(value, params) {
|
|
4925
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
4926
|
+
},
|
|
4927
|
+
gte(value, params) {
|
|
4928
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
4929
|
+
},
|
|
4930
|
+
min(value, params) {
|
|
4931
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
4932
|
+
},
|
|
4933
|
+
lt(value, params) {
|
|
4934
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
4935
|
+
},
|
|
4936
|
+
lte(value, params) {
|
|
4937
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
4938
|
+
},
|
|
4939
|
+
max(value, params) {
|
|
4940
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
4941
|
+
},
|
|
4942
|
+
int(params) {
|
|
4943
|
+
return this.check(int(params));
|
|
4944
|
+
},
|
|
4945
|
+
safe(params) {
|
|
4946
|
+
return this.check(int(params));
|
|
4947
|
+
},
|
|
4948
|
+
positive(params) {
|
|
4949
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
4950
|
+
},
|
|
4951
|
+
nonnegative(params) {
|
|
4952
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
4953
|
+
},
|
|
4954
|
+
negative(params) {
|
|
4955
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
4956
|
+
},
|
|
4957
|
+
nonpositive(params) {
|
|
4958
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
4959
|
+
},
|
|
4960
|
+
multipleOf(value, params) {
|
|
4961
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
4962
|
+
},
|
|
4963
|
+
step(value, params) {
|
|
4964
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
4965
|
+
},
|
|
4966
|
+
finite() {
|
|
4967
|
+
return this;
|
|
4968
|
+
}
|
|
4969
|
+
}));
|
|
3775
4970
|
function number(params) {
|
|
3776
4971
|
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
3777
4972
|
}
|
|
@@ -3807,94 +5002,80 @@ function never(params) {
|
|
|
3807
5002
|
return /* @__PURE__ */ _never(ZodNever, params);
|
|
3808
5003
|
}
|
|
3809
5004
|
var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
5005
|
+
_ensureDefaultMemoizer();
|
|
3810
5006
|
$ZodArray.init(inst, def);
|
|
3811
5007
|
ZodType.init(inst, def);
|
|
3812
5008
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3813
5009
|
inst.element = def.element;
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
});
|
|
5010
|
+
}, {
|
|
5011
|
+
min(n, params) {
|
|
5012
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
5013
|
+
},
|
|
5014
|
+
nonempty(params) {
|
|
5015
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
5016
|
+
},
|
|
5017
|
+
max(n, params) {
|
|
5018
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
5019
|
+
},
|
|
5020
|
+
length(n, params) {
|
|
5021
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
5022
|
+
},
|
|
5023
|
+
unwrap() {
|
|
5024
|
+
return this.element;
|
|
5025
|
+
}
|
|
3831
5026
|
});
|
|
3832
5027
|
function array(element, params) {
|
|
3833
5028
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
3834
5029
|
}
|
|
3835
5030
|
var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
5031
|
+
_ensureDefaultMemoizer();
|
|
3836
5032
|
$ZodObjectJIT.init(inst, def);
|
|
3837
5033
|
ZodType.init(inst, def);
|
|
3838
5034
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
}
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
}
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
}
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
return merge(this, other);
|
|
3884
|
-
},
|
|
3885
|
-
pick(mask) {
|
|
3886
|
-
return pick(this, mask);
|
|
3887
|
-
},
|
|
3888
|
-
omit(mask) {
|
|
3889
|
-
return omit(this, mask);
|
|
3890
|
-
},
|
|
3891
|
-
partial(...args) {
|
|
3892
|
-
return partial(ZodOptional, this, args[0]);
|
|
3893
|
-
},
|
|
3894
|
-
required(...args) {
|
|
3895
|
-
return required(ZodNonOptional, this, args[0]);
|
|
3896
|
-
}
|
|
3897
|
-
});
|
|
5035
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
5036
|
+
}, {
|
|
5037
|
+
keyof() {
|
|
5038
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
5039
|
+
},
|
|
5040
|
+
catchall(catchall) {
|
|
5041
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
5042
|
+
},
|
|
5043
|
+
passthrough() {
|
|
5044
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5045
|
+
},
|
|
5046
|
+
loose() {
|
|
5047
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5048
|
+
},
|
|
5049
|
+
strict() {
|
|
5050
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
5051
|
+
},
|
|
5052
|
+
strip() {
|
|
5053
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
|
|
5054
|
+
},
|
|
5055
|
+
extend(incoming) {
|
|
5056
|
+
return extend(this, incoming);
|
|
5057
|
+
},
|
|
5058
|
+
safeExtend(incoming) {
|
|
5059
|
+
return safeExtend(this, incoming);
|
|
5060
|
+
},
|
|
5061
|
+
merge(other) {
|
|
5062
|
+
return merge(this, other);
|
|
5063
|
+
},
|
|
5064
|
+
pick(mask) {
|
|
5065
|
+
return pick(this, mask);
|
|
5066
|
+
},
|
|
5067
|
+
omit(mask) {
|
|
5068
|
+
return omit(this, mask);
|
|
5069
|
+
},
|
|
5070
|
+
partial(...args) {
|
|
5071
|
+
return partial(ZodOptional, this, args[0]);
|
|
5072
|
+
},
|
|
5073
|
+
exactPartial(...args) {
|
|
5074
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
5075
|
+
},
|
|
5076
|
+
required(...args) {
|
|
5077
|
+
return required(ZodNonOptional, this, args[0]);
|
|
5078
|
+
}
|
|
3898
5079
|
});
|
|
3899
5080
|
function object(shape, params) {
|
|
3900
5081
|
return new ZodObject({
|
|
@@ -3945,7 +5126,7 @@ var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
|
3945
5126
|
ZodType.init(inst, def);
|
|
3946
5127
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3947
5128
|
inst.enum = def.entries;
|
|
3948
|
-
inst.options =
|
|
5129
|
+
inst.options = [...inst._zod.values];
|
|
3949
5130
|
const keys = new Set(Object.keys(def.entries));
|
|
3950
5131
|
inst.extract = (values, params) => {
|
|
3951
5132
|
const newEntries = {};
|
|
@@ -3995,6 +5176,7 @@ function literal(value, params) {
|
|
|
3995
5176
|
});
|
|
3996
5177
|
}
|
|
3997
5178
|
var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
5179
|
+
_ensureDefaultMemoizer();
|
|
3998
5180
|
$ZodTransform.init(inst, def);
|
|
3999
5181
|
ZodType.init(inst, def);
|
|
4000
5182
|
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
@@ -4006,7 +5188,7 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
4006
5188
|
const _issue = issue$1;
|
|
4007
5189
|
if (_issue.fatal) _issue.continue = false;
|
|
4008
5190
|
_issue.code ?? (_issue.code = "custom");
|
|
4009
|
-
|
|
5191
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
4010
5192
|
_issue.inst ?? (_issue.inst = inst);
|
|
4011
5193
|
payload.issues.push(issue(_issue));
|
|
4012
5194
|
}
|
|
@@ -4014,11 +5196,9 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
4014
5196
|
const output = def.transform(payload.value, payload);
|
|
4015
5197
|
if (output instanceof Promise) return output.then((output) => {
|
|
4016
5198
|
payload.value = output;
|
|
4017
|
-
payload.fallback = true;
|
|
4018
5199
|
return payload;
|
|
4019
5200
|
});
|
|
4020
5201
|
payload.value = output;
|
|
4021
|
-
payload.fallback = true;
|
|
4022
5202
|
return payload;
|
|
4023
5203
|
};
|
|
4024
5204
|
});
|
|
@@ -4119,7 +5299,7 @@ function _catch(innerType, catchValue) {
|
|
|
4119
5299
|
return new ZodCatch({
|
|
4120
5300
|
type: "catch",
|
|
4121
5301
|
innerType,
|
|
4122
|
-
catchValue: typeof catchValue === "function" ? catchValue : ()
|
|
5302
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
4123
5303
|
});
|
|
4124
5304
|
}
|
|
4125
5305
|
var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|