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