@powerhousedao/ph-cli 6.2.3-dev.61 → 6.2.3-dev.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-skPHsKkL.mjs → build-BM-zayLm.mjs} +7 -3
- package/dist/build-BM-zayLm.mjs.map +1 -0
- package/dist/build-BZGpUn8f.mjs +4 -0
- package/dist/{cli-connect-override-CuheCf3N.mjs → cli-connect-override-DP5vRA7N.mjs} +4 -4
- package/dist/{cli-connect-override-CuheCf3N.mjs.map → cli-connect-override-DP5vRA7N.mjs.map} +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/{connect-build-CyNALLxq.mjs → connect-build-xRrXk9-p.mjs} +31 -10
- package/dist/connect-build-xRrXk9-p.mjs.map +1 -0
- package/dist/{connect-config-B0WoJoZv.mjs → connect-config-BvS0chVq.mjs} +4 -4
- package/dist/{connect-config-B0WoJoZv.mjs.map → connect-config-BvS0chVq.mjs.map} +1 -1
- package/dist/{connect-preview-Clue7SVp.mjs → connect-preview-BW6XnRtj.mjs} +42 -11
- package/dist/connect-preview-BW6XnRtj.mjs.map +1 -0
- package/dist/{connect-studio-B-HTpgG2.mjs → connect-studio-8EyDblpG.mjs} +4 -4
- package/dist/{connect-studio-B-HTpgG2.mjs.map → connect-studio-8EyDblpG.mjs.map} +1 -1
- package/dist/{connect-studio-ClS1PdVV.mjs → connect-studio-NxCVdXDv.mjs} +3 -3
- package/dist/{dist-BsyiY0Fw.mjs → dist-BqeDFgEy.mjs} +5 -5
- package/dist/{dist-BsyiY0Fw.mjs.map → dist-BqeDFgEy.mjs.map} +1 -1
- package/dist/{explain-j11Vgf0Z.mjs → explain-D6gLYBd0.mjs} +4 -4
- package/dist/{explain-j11Vgf0Z.mjs.map → explain-D6gLYBd0.mjs.map} +1 -1
- package/dist/{generate-desktop-shell-DFOsRPgq.mjs → generate-desktop-shell-itIzf77U.mjs} +4 -4
- package/dist/{generate-desktop-shell-DFOsRPgq.mjs.map → generate-desktop-shell-itIzf77U.mjs.map} +1 -1
- package/dist/{host-schemas-CL_wFpY7-BDyTA_z_.mjs → host-schemas-CL_wFpY7-B_pY14Jy.mjs} +5 -5
- package/dist/{host-schemas-CL_wFpY7-BDyTA_z_.mjs.map → host-schemas-CL_wFpY7-B_pY14Jy.mjs.map} +1 -1
- package/dist/{index-CApW1xbO.d.mts → index-CspiP73o.d.mts} +840 -297
- package/dist/index-CspiP73o.d.mts.map +1 -0
- package/dist/{ph-cli-commands-ByuH-lXH.mjs → ph-cli-commands-CLJP7yKV.mjs} +12 -12
- package/dist/{ph-cli-commands-ByuH-lXH.mjs.map → ph-cli-commands-CLJP7yKV.mjs.map} +1 -1
- package/dist/ph-cli-commands-NHDoX5i7.mjs +4 -0
- package/dist/{plugins-PTnPaBIG.mjs → plugins-CHVv4qup.mjs} +4 -4
- package/dist/{plugins-PTnPaBIG.mjs.map → plugins-CHVv4qup.mjs.map} +1 -1
- package/dist/{reactor-env-Dx0Hxi5I.mjs → reactor-env-BbR86_Li.mjs} +4 -4
- package/dist/{reactor-env-Dx0Hxi5I.mjs.map → reactor-env-BbR86_Li.mjs.map} +1 -1
- package/dist/reactor-env-D_EvBtLB.mjs +4 -0
- package/dist/{run-sugar-D3C0Ptvv.mjs → run-sugar-DveBlJqh.mjs} +4 -4
- package/dist/{run-sugar-D3C0Ptvv.mjs.map → run-sugar-DveBlJqh.mjs.map} +1 -1
- package/dist/runners/compound.d.mts +1 -1
- package/dist/runners/compound.mjs +4 -4
- package/dist/runners/connect.d.mts +1 -1
- package/dist/runners/connect.mjs +7 -7
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +7 -7
- package/dist/{schemas-BZZWQ72W.mjs → schemas-BQSPev1x.mjs} +2545 -970
- package/dist/schemas-BQSPev1x.mjs.map +1 -0
- package/dist/{start-run-1mjFpX7H.mjs → start-run-CASbiOWI.mjs} +4 -4
- package/dist/{start-run-1mjFpX7H.mjs.map → start-run-CASbiOWI.mjs.map} +1 -1
- package/dist/{vetra-BBcDGKgI.mjs → vetra-BV5F0YeG.mjs} +6 -6
- package/dist/{vetra-BBcDGKgI.mjs.map → vetra-BV5F0YeG.mjs.map} +1 -1
- package/package.json +14 -14
- package/dist/build-DmqwT-PR.mjs +0 -4
- package/dist/build-skPHsKkL.mjs.map +0 -1
- package/dist/connect-build-CyNALLxq.mjs.map +0 -1
- package/dist/connect-preview-Clue7SVp.mjs.map +0 -1
- package/dist/index-CApW1xbO.d.mts.map +0 -1
- package/dist/ph-cli-commands-sgvuh-kj.mjs +0 -4
- package/dist/reactor-env-BgyzjfYc.mjs +0 -4
- package/dist/schemas-BZZWQ72W.mjs.map +0 -1
|
@@ -1,79 +1,33 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
1
2
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
Object.freeze({ status: "aborted" });
|
|
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
|
-
const globalConfig = {};
|
|
55
|
-
function config(newConfig) {
|
|
56
|
-
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
57
|
-
return globalConfig;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd23951b-05b2-5ced-9ed3-1edf36cf8d22")}catch(e){}}();
|
|
61
4
|
function getEnumValues(entries) {
|
|
62
5
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
63
6
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
64
7
|
}
|
|
8
|
+
function joinValues(array, separator = "|") {
|
|
9
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
10
|
+
}
|
|
65
11
|
function jsonStringifyReplacer(_, value) {
|
|
66
12
|
if (typeof value === "bigint") return value.toString();
|
|
67
13
|
return value;
|
|
68
14
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
15
|
+
var Cached = class {
|
|
16
|
+
constructor(getter) {
|
|
17
|
+
this._getter = getter;
|
|
18
|
+
this._value = void 0;
|
|
19
|
+
}
|
|
20
|
+
get value() {
|
|
21
|
+
const getter = this._getter;
|
|
22
|
+
if (getter !== void 0) {
|
|
23
|
+
this._value = getter();
|
|
24
|
+
this._getter = void 0;
|
|
75
25
|
}
|
|
76
|
-
|
|
26
|
+
return this._value;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function cached(getter) {
|
|
30
|
+
return new Cached(getter);
|
|
77
31
|
}
|
|
78
32
|
function nullish(input) {
|
|
79
33
|
return input === null || input === void 0;
|
|
@@ -84,33 +38,11 @@ function cleanRegex(source) {
|
|
|
84
38
|
return source.slice(start, end);
|
|
85
39
|
}
|
|
86
40
|
function floatSafeRemainder(val, step) {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
93
|
-
}
|
|
94
|
-
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
95
|
-
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
96
|
-
}
|
|
97
|
-
const EVALUATING = Symbol("evaluating");
|
|
98
|
-
function defineLazy(object, key, getter) {
|
|
99
|
-
let value = void 0;
|
|
100
|
-
Object.defineProperty(object, key, {
|
|
101
|
-
get() {
|
|
102
|
-
if (value === EVALUATING) return;
|
|
103
|
-
if (value === void 0) {
|
|
104
|
-
value = EVALUATING;
|
|
105
|
-
value = getter();
|
|
106
|
-
}
|
|
107
|
-
return value;
|
|
108
|
-
},
|
|
109
|
-
set(v) {
|
|
110
|
-
Object.defineProperty(object, key, { value: v });
|
|
111
|
-
},
|
|
112
|
-
configurable: true
|
|
113
|
-
});
|
|
41
|
+
const ratio = val / step;
|
|
42
|
+
const roundedRatio = Math.round(ratio);
|
|
43
|
+
const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
|
44
|
+
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
|
|
45
|
+
return ratio - roundedRatio;
|
|
114
46
|
}
|
|
115
47
|
function assignProp(target, prop, value) {
|
|
116
48
|
Object.defineProperty(target, prop, {
|
|
@@ -120,6 +52,58 @@ function assignProp(target, prop, value) {
|
|
|
120
52
|
configurable: true
|
|
121
53
|
});
|
|
122
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
|
|
57
|
+
*
|
|
58
|
+
* 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.
|
|
59
|
+
*/
|
|
60
|
+
function rawShape(def) {
|
|
61
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
62
|
+
return desc?.get ? desc.get.raw : desc?.value;
|
|
63
|
+
}
|
|
64
|
+
function sourceShape(schema) {
|
|
65
|
+
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
66
|
+
}
|
|
67
|
+
function deferProp(target, key, getter) {
|
|
68
|
+
Object.defineProperty(target, key, {
|
|
69
|
+
get() {
|
|
70
|
+
const value = getter();
|
|
71
|
+
assignProp(this, key, value);
|
|
72
|
+
return value;
|
|
73
|
+
},
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function putProp(target, key, value) {
|
|
79
|
+
if (key in target) assignProp(target, key, value);
|
|
80
|
+
else target[key] = value;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
|
|
84
|
+
*
|
|
85
|
+
* 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.
|
|
86
|
+
*/
|
|
87
|
+
function mirrorShape(target, source, keys, wrap) {
|
|
88
|
+
const raw = sourceShape(source);
|
|
89
|
+
for (const key of keys) {
|
|
90
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
91
|
+
if (!desc.enumerable) continue;
|
|
92
|
+
if (desc.get) deferProp(target, key, () => {
|
|
93
|
+
const value = source._zod.def.shape[key];
|
|
94
|
+
return wrap ? wrap(value, key) : value;
|
|
95
|
+
});
|
|
96
|
+
else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function mirrorProps(target, source) {
|
|
100
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
101
|
+
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
102
|
+
if (!desc.enumerable) continue;
|
|
103
|
+
if (desc.get) deferProp(target, key, () => source[key]);
|
|
104
|
+
else putProp(target, key, desc.value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
123
107
|
function mergeDefs(...defs) {
|
|
124
108
|
const mergedDescriptors = {};
|
|
125
109
|
for (const def of defs) {
|
|
@@ -138,7 +122,8 @@ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace
|
|
|
138
122
|
function isObject(data) {
|
|
139
123
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
140
124
|
}
|
|
141
|
-
const allowsEval = cached(() => {
|
|
125
|
+
const allowsEval = /* @__PURE__*/ cached(() => {
|
|
126
|
+
if (globalConfig.jitless) return false;
|
|
142
127
|
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
143
128
|
try {
|
|
144
129
|
new Function("");
|
|
@@ -160,9 +145,11 @@ function isPlainObject(o) {
|
|
|
160
145
|
function shallowClone(o) {
|
|
161
146
|
if (isPlainObject(o)) return { ...o };
|
|
162
147
|
if (Array.isArray(o)) return [...o];
|
|
148
|
+
if (o instanceof Map) return new Map(o);
|
|
149
|
+
if (o instanceof Set) return new Set(o);
|
|
163
150
|
return o;
|
|
164
151
|
}
|
|
165
|
-
const propertyKeyTypes = /* @__PURE__
|
|
152
|
+
const propertyKeyTypes = /* @__PURE__*/ new Set([
|
|
166
153
|
"string",
|
|
167
154
|
"number",
|
|
168
155
|
"symbol"
|
|
@@ -190,51 +177,56 @@ function normalizeParams(_params) {
|
|
|
190
177
|
};
|
|
191
178
|
return params;
|
|
192
179
|
}
|
|
180
|
+
function stringifyPrimitive(value) {
|
|
181
|
+
if (typeof value === "bigint") return value.toString() + "n";
|
|
182
|
+
if (typeof value === "string") return `"${value}"`;
|
|
183
|
+
return `${value}`;
|
|
184
|
+
}
|
|
193
185
|
function optionalKeys(shape) {
|
|
194
186
|
return Object.keys(shape).filter((k) => {
|
|
195
|
-
return shape[k]._zod.optin
|
|
187
|
+
return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
|
|
196
188
|
});
|
|
197
189
|
}
|
|
198
|
-
const NUMBER_FORMAT_RANGES = {
|
|
190
|
+
const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
|
|
199
191
|
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
200
192
|
int32: [-2147483648, 2147483647],
|
|
201
193
|
uint32: [0, 4294967295],
|
|
202
194
|
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
203
195
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
196
|
+
}))();
|
|
197
|
+
const BIGINT_FORMAT_RANGES = {
|
|
198
|
+
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
199
|
+
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
|
|
204
200
|
};
|
|
205
201
|
function pick(schema, mask) {
|
|
206
202
|
const currDef = schema._zod.def;
|
|
207
203
|
const checks = currDef.checks;
|
|
208
204
|
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
214
|
-
if (!mask[key]) continue;
|
|
215
|
-
newShape[key] = currDef.shape[key];
|
|
216
|
-
}
|
|
217
|
-
assignProp(this, "shape", newShape);
|
|
218
|
-
return newShape;
|
|
219
|
-
},
|
|
205
|
+
const newShape = {};
|
|
206
|
+
mirrorShape(newShape, schema, maskedKeys(schema, mask));
|
|
207
|
+
return clone(schema, mergeDefs(currDef, {
|
|
208
|
+
shape: newShape,
|
|
220
209
|
checks: []
|
|
221
210
|
}));
|
|
222
211
|
}
|
|
212
|
+
function maskedKeys(schema, mask) {
|
|
213
|
+
const raw = sourceShape(schema);
|
|
214
|
+
const keys = [];
|
|
215
|
+
for (const key of Reflect.ownKeys(mask)) {
|
|
216
|
+
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
217
|
+
if (mask[key]) keys.push(key);
|
|
218
|
+
}
|
|
219
|
+
return keys;
|
|
220
|
+
}
|
|
223
221
|
function omit(schema, mask) {
|
|
224
222
|
const currDef = schema._zod.def;
|
|
225
223
|
const checks = currDef.checks;
|
|
226
224
|
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (!mask[key]) continue;
|
|
233
|
-
delete newShape[key];
|
|
234
|
-
}
|
|
235
|
-
assignProp(this, "shape", newShape);
|
|
236
|
-
return newShape;
|
|
237
|
-
},
|
|
225
|
+
const omitted = new Set(maskedKeys(schema, mask));
|
|
226
|
+
const newShape = {};
|
|
227
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
|
|
228
|
+
return clone(schema, mergeDefs(currDef, {
|
|
229
|
+
shape: newShape,
|
|
238
230
|
checks: []
|
|
239
231
|
}));
|
|
240
232
|
}
|
|
@@ -242,95 +234,68 @@ function extend(schema, shape) {
|
|
|
242
234
|
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
243
235
|
const checks = schema._zod.def.checks;
|
|
244
236
|
if (checks && checks.length > 0) {
|
|
245
|
-
const existingShape = schema
|
|
246
|
-
for (const key
|
|
237
|
+
const existingShape = sourceShape(schema);
|
|
238
|
+
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.");
|
|
247
239
|
}
|
|
248
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
} }));
|
|
240
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
241
|
+
}
|
|
242
|
+
function extended(schema, shape) {
|
|
243
|
+
const newShape = {};
|
|
244
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
|
|
245
|
+
mirrorProps(newShape, shape);
|
|
246
|
+
return newShape;
|
|
256
247
|
}
|
|
257
248
|
function safeExtend(schema, shape) {
|
|
258
249
|
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
259
|
-
return clone(schema, mergeDefs(schema._zod.def, {
|
|
260
|
-
const _shape = {
|
|
261
|
-
...schema._zod.def.shape,
|
|
262
|
-
...shape
|
|
263
|
-
};
|
|
264
|
-
assignProp(this, "shape", _shape);
|
|
265
|
-
return _shape;
|
|
266
|
-
} }));
|
|
250
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
267
251
|
}
|
|
268
252
|
function merge(a, b) {
|
|
253
|
+
if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
254
|
+
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
255
|
+
const newShape = {};
|
|
256
|
+
mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
|
|
257
|
+
mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
|
|
269
258
|
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
|
-
},
|
|
259
|
+
shape: newShape,
|
|
278
260
|
get catchall() {
|
|
279
261
|
return b._zod.def.catchall;
|
|
280
262
|
},
|
|
281
|
-
checks: []
|
|
263
|
+
checks: b._zod.def.checks ?? []
|
|
282
264
|
}));
|
|
283
265
|
}
|
|
284
|
-
function partial(Class, schema, mask) {
|
|
266
|
+
function partial(Class, schema, mask, name = "partial") {
|
|
285
267
|
const checks = schema._zod.def.checks;
|
|
286
|
-
if (checks && checks.length > 0) throw new Error(
|
|
268
|
+
if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
269
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
270
|
+
const newShape = {};
|
|
271
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
|
|
272
|
+
type: "optional",
|
|
273
|
+
innerType: value
|
|
274
|
+
})));
|
|
287
275
|
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
|
-
},
|
|
276
|
+
shape: newShape,
|
|
306
277
|
checks: []
|
|
307
278
|
}));
|
|
308
279
|
}
|
|
309
280
|
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
|
-
} }));
|
|
281
|
+
const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
|
|
282
|
+
const newShape = {};
|
|
283
|
+
mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
|
|
284
|
+
type: "nonoptional",
|
|
285
|
+
innerType: value
|
|
286
|
+
}));
|
|
287
|
+
return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
|
|
328
288
|
}
|
|
329
289
|
function aborted(x, startIndex = 0) {
|
|
330
290
|
if (x.aborted === true) return true;
|
|
331
291
|
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
332
292
|
return false;
|
|
333
293
|
}
|
|
294
|
+
function explicitlyAborted(x, startIndex = 0) {
|
|
295
|
+
if (x.aborted === true) return true;
|
|
296
|
+
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
334
299
|
function prefixIssues(path, issues) {
|
|
335
300
|
return issues.map((iss) => {
|
|
336
301
|
var _a;
|
|
@@ -342,22 +307,58 @@ function prefixIssues(path, issues) {
|
|
|
342
307
|
function unwrapMessage(message) {
|
|
343
308
|
return typeof message === "string" ? message : message?.message;
|
|
344
309
|
}
|
|
310
|
+
function attachSchema(issues, start, inst) {
|
|
311
|
+
var _a;
|
|
312
|
+
for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
|
|
313
|
+
}
|
|
345
314
|
function finalizeIssue(iss, ctx, config) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
315
|
+
var _a;
|
|
316
|
+
const traits = iss.inst?._zod?.traits;
|
|
317
|
+
if (traits?.has("$ZodType")) {
|
|
318
|
+
if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
|
|
319
|
+
else iss.schema = iss.inst;
|
|
320
|
+
}
|
|
321
|
+
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
322
|
+
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";
|
|
323
|
+
const full = {};
|
|
324
|
+
for (const k of Object.keys(iss)) {
|
|
325
|
+
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
|
|
326
|
+
full[k] = iss[k];
|
|
327
|
+
}
|
|
328
|
+
full.path ?? (full.path = []);
|
|
329
|
+
full.message = message;
|
|
330
|
+
if (ctx?.reportInput) full.input = iss.input;
|
|
354
331
|
return full;
|
|
355
332
|
}
|
|
333
|
+
const highSurrogate = /[\uD800-\uDBFF]/;
|
|
334
|
+
function codePointLength(str) {
|
|
335
|
+
const units = str.length;
|
|
336
|
+
if (!highSurrogate.test(str)) return units;
|
|
337
|
+
let count = units;
|
|
338
|
+
for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
339
|
+
count--;
|
|
340
|
+
i++;
|
|
341
|
+
}
|
|
342
|
+
return count;
|
|
343
|
+
}
|
|
356
344
|
function getLengthableOrigin(input) {
|
|
357
345
|
if (Array.isArray(input)) return "array";
|
|
358
346
|
if (typeof input === "string") return "string";
|
|
359
347
|
return "unknown";
|
|
360
348
|
}
|
|
349
|
+
function parsedType(data) {
|
|
350
|
+
const t = typeof data;
|
|
351
|
+
switch (t) {
|
|
352
|
+
case "number": return Number.isNaN(data) ? "nan" : "number";
|
|
353
|
+
case "object": {
|
|
354
|
+
if (data === null) return "null";
|
|
355
|
+
if (Array.isArray(data)) return "array";
|
|
356
|
+
const obj = data;
|
|
357
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return t;
|
|
361
|
+
}
|
|
361
362
|
function issue(...args) {
|
|
362
363
|
const [iss, input, inst] = args;
|
|
363
364
|
if (typeof iss === "string") return {
|
|
@@ -368,33 +369,339 @@ function issue(...args) {
|
|
|
368
369
|
};
|
|
369
370
|
return { ...iss };
|
|
370
371
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
372
|
+
/**
|
|
373
|
+
* 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.
|
|
374
|
+
*
|
|
375
|
+
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
|
|
376
|
+
*/
|
|
377
|
+
function members(proto, table) {
|
|
378
|
+
for (const key in table) {
|
|
379
|
+
const desc = Object.getOwnPropertyDescriptor(table, key);
|
|
380
|
+
if (desc.get) Object.defineProperty(proto, key, {
|
|
381
|
+
...desc,
|
|
382
|
+
enumerable: false
|
|
383
|
+
});
|
|
384
|
+
else defineBound(proto, key, desc.value);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
|
|
388
|
+
function own(inst, key, value, enumerable = true) {
|
|
389
|
+
Object.defineProperty(inst, key, {
|
|
390
|
+
configurable: true,
|
|
391
|
+
writable: true,
|
|
392
|
+
enumerable,
|
|
393
|
+
value
|
|
394
|
+
});
|
|
395
|
+
return value;
|
|
396
|
+
}
|
|
397
|
+
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
|
|
398
|
+
function hide(inst, key, value) {
|
|
399
|
+
return own(inst, key, value, false);
|
|
400
|
+
}
|
|
401
|
+
/** 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. */
|
|
402
|
+
function derived(computes, table) {
|
|
403
|
+
for (const key in computes) {
|
|
404
|
+
const compute = computes[key];
|
|
405
|
+
Object.defineProperty(table, key, {
|
|
406
|
+
configurable: true,
|
|
407
|
+
enumerable: true,
|
|
408
|
+
get() {
|
|
409
|
+
return own(this, key, compute(this));
|
|
410
|
+
},
|
|
411
|
+
set(value) {
|
|
412
|
+
own(this, key, value);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return table;
|
|
417
|
+
}
|
|
418
|
+
function defineBound(proto, key, fn) {
|
|
419
|
+
Object.defineProperty(proto, key, {
|
|
420
|
+
configurable: true,
|
|
421
|
+
get() {
|
|
422
|
+
return this == null ? fn : own(this, key, fn.bind(this));
|
|
423
|
+
},
|
|
424
|
+
set(value) {
|
|
425
|
+
own(this, key, value);
|
|
426
|
+
}
|
|
378
427
|
});
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
428
|
+
}
|
|
429
|
+
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
|
|
430
|
+
function claim(inst, sentinel) {
|
|
431
|
+
const proto = Object.getPrototypeOf(inst);
|
|
432
|
+
return sentinel in proto ? void 0 : proto;
|
|
433
|
+
}
|
|
434
|
+
let installing;
|
|
435
|
+
let broke = false;
|
|
436
|
+
const breaker = {
|
|
437
|
+
configurable: true,
|
|
438
|
+
get() {
|
|
439
|
+
broke = true;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
|
|
444
|
+
* constructor, computed from the internals object itself and cached there on
|
|
445
|
+
* first read. One accessor per constructor rather than one per instance.
|
|
446
|
+
*/
|
|
447
|
+
function defineLazyInternal(inst, key, compute) {
|
|
448
|
+
const proto = Object.getPrototypeOf(inst._zod);
|
|
449
|
+
if (key in proto && installing !== inst._zod) {
|
|
450
|
+
installing = void 0;
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
installing = inst._zod;
|
|
454
|
+
Object.defineProperty(proto, key, {
|
|
455
|
+
configurable: true,
|
|
456
|
+
get() {
|
|
457
|
+
Object.defineProperty(this, key, breaker);
|
|
458
|
+
const outer = broke;
|
|
459
|
+
broke = false;
|
|
460
|
+
try {
|
|
461
|
+
const value = compute(this);
|
|
462
|
+
if (broke) delete this[key];
|
|
463
|
+
else Object.defineProperty(this, key, {
|
|
464
|
+
configurable: true,
|
|
465
|
+
writable: true,
|
|
466
|
+
value
|
|
467
|
+
});
|
|
468
|
+
broke = broke || outer;
|
|
469
|
+
return value;
|
|
470
|
+
} catch (err) {
|
|
471
|
+
delete this[key];
|
|
472
|
+
broke = broke || outer;
|
|
473
|
+
throw err;
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
set(value) {
|
|
477
|
+
Object.defineProperty(this, key, {
|
|
478
|
+
configurable: true,
|
|
479
|
+
writable: true,
|
|
480
|
+
value
|
|
481
|
+
});
|
|
482
|
+
}
|
|
382
483
|
});
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
|
|
487
|
+
* data property. One accessor per constructor rather than one per instance, because an own accessor
|
|
488
|
+
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
|
|
489
|
+
*/
|
|
490
|
+
function installLazyProp(inst, key, make, enumerable) {
|
|
491
|
+
const proto = claim(inst, key);
|
|
492
|
+
if (!proto) return;
|
|
493
|
+
Object.defineProperty(proto, key, {
|
|
494
|
+
configurable: true,
|
|
495
|
+
get() {
|
|
496
|
+
const desc = {
|
|
497
|
+
configurable: true,
|
|
498
|
+
writable: true,
|
|
499
|
+
enumerable,
|
|
500
|
+
value: void 0
|
|
501
|
+
};
|
|
502
|
+
Object.defineProperty(this, key, desc);
|
|
503
|
+
desc.value = make(this);
|
|
504
|
+
Object.defineProperty(this, key, desc);
|
|
505
|
+
return desc.value;
|
|
506
|
+
},
|
|
507
|
+
set(value) {
|
|
508
|
+
Object.defineProperty(this, key, {
|
|
509
|
+
configurable: true,
|
|
510
|
+
writable: true,
|
|
511
|
+
enumerable,
|
|
512
|
+
value
|
|
513
|
+
});
|
|
514
|
+
}
|
|
387
515
|
});
|
|
516
|
+
}
|
|
517
|
+
/** 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. */
|
|
518
|
+
const CONSTANT_CATCH = "~constantCatch";
|
|
519
|
+
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
|
|
520
|
+
function constantCatch(value) {
|
|
521
|
+
const fn = () => value;
|
|
522
|
+
fn[CONSTANT_CATCH] = true;
|
|
523
|
+
return fn;
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/core.js
|
|
527
|
+
var _a$1;
|
|
528
|
+
const _zodDesc = {
|
|
529
|
+
value: void 0,
|
|
530
|
+
enumerable: false
|
|
531
|
+
};
|
|
532
|
+
let _E = "captureStackTrace" in Error ? Error : null;
|
|
533
|
+
function newError(Definition) {
|
|
534
|
+
const E = _E;
|
|
535
|
+
if (E) {
|
|
536
|
+
const saved = E.stackTraceLimit;
|
|
537
|
+
if (typeof saved === "number") {
|
|
538
|
+
try {
|
|
539
|
+
E.stackTraceLimit = 0;
|
|
540
|
+
} catch {
|
|
541
|
+
_E = null;
|
|
542
|
+
return new Definition();
|
|
543
|
+
}
|
|
544
|
+
try {
|
|
545
|
+
return new Definition();
|
|
546
|
+
} finally {
|
|
547
|
+
E.stackTraceLimit = saved;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return new Definition();
|
|
552
|
+
}
|
|
553
|
+
function $constructor(name, initializer, proto, params) {
|
|
554
|
+
const zodProto = {};
|
|
555
|
+
function Internals(def) {
|
|
556
|
+
this.def = def;
|
|
557
|
+
this.constr = _;
|
|
558
|
+
this.traits = /* @__PURE__ */ new Set();
|
|
559
|
+
}
|
|
560
|
+
Internals.prototype = zodProto;
|
|
561
|
+
const protoMembers = proto;
|
|
562
|
+
const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
|
|
563
|
+
function init(inst, def) {
|
|
564
|
+
if (!inst._zod) {
|
|
565
|
+
_zodDesc.value = new Internals(def);
|
|
566
|
+
try {
|
|
567
|
+
Object.defineProperty(inst, "_zod", _zodDesc);
|
|
568
|
+
} finally {
|
|
569
|
+
_zodDesc.value = void 0;
|
|
570
|
+
}
|
|
571
|
+
} else if (inst._zod.traits.has(name)) return;
|
|
572
|
+
inst._zod.traits.add(name);
|
|
573
|
+
initializer(inst, def);
|
|
574
|
+
if (initialized) {
|
|
575
|
+
const own = Object.getPrototypeOf(inst);
|
|
576
|
+
const ctorProto = inst._zod.constr.prototype;
|
|
577
|
+
let up = own;
|
|
578
|
+
while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
|
|
579
|
+
const target = up ?? own;
|
|
580
|
+
if (!initialized.has(target)) {
|
|
581
|
+
initialized.add(target);
|
|
582
|
+
members(target, protoMembers);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const proto = _.prototype;
|
|
586
|
+
for (const k in proto) {
|
|
587
|
+
if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
|
|
588
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
const Parent = params?.Parent ?? Object;
|
|
592
|
+
class Definition extends Parent {}
|
|
593
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
594
|
+
function _(def) {
|
|
595
|
+
const inst = params?.Parent ? newError(Definition) : this;
|
|
596
|
+
init(inst, def);
|
|
597
|
+
const deferred = inst._zod.deferred;
|
|
598
|
+
if (deferred) {
|
|
599
|
+
for (const fn of deferred) fn();
|
|
600
|
+
inst._zod.deferred = void 0;
|
|
601
|
+
}
|
|
602
|
+
const pp = globalThis.__zod_globalConfig?.postProcessor;
|
|
603
|
+
if (pp) pp(inst);
|
|
604
|
+
return inst;
|
|
605
|
+
}
|
|
606
|
+
Object.defineProperty(_, "init", { value: init });
|
|
607
|
+
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
|
|
608
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
609
|
+
return inst?._zod?.traits?.has(name);
|
|
610
|
+
} });
|
|
611
|
+
Object.defineProperty(_, "name", { value: name });
|
|
612
|
+
return _;
|
|
613
|
+
}
|
|
614
|
+
var $ZodAsyncError = class extends Error {
|
|
615
|
+
constructor() {
|
|
616
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
var $ZodEncodeError = class extends Error {
|
|
620
|
+
constructor(name) {
|
|
621
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
622
|
+
this.name = "ZodEncodeError";
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
626
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
627
|
+
function config(newConfig) {
|
|
628
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
629
|
+
return globalConfig;
|
|
630
|
+
}
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/errors.js
|
|
633
|
+
function _getMessage() {
|
|
634
|
+
const internals = this._zod;
|
|
635
|
+
internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
|
|
636
|
+
return internals.message;
|
|
637
|
+
}
|
|
638
|
+
function _setMessage(value) {
|
|
639
|
+
this._zod.message = value;
|
|
640
|
+
}
|
|
641
|
+
const _messageDesc = {
|
|
642
|
+
get: _getMessage,
|
|
643
|
+
set: _setMessage,
|
|
644
|
+
enumerable: true,
|
|
645
|
+
configurable: true
|
|
646
|
+
};
|
|
647
|
+
const _issuesDesc = {
|
|
648
|
+
value: void 0,
|
|
649
|
+
enumerable: false
|
|
650
|
+
};
|
|
651
|
+
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
652
|
+
const initializer$1 = (inst, def) => {
|
|
653
|
+
inst.name = "$ZodError";
|
|
654
|
+
_issuesDesc.value = def;
|
|
655
|
+
Object.defineProperty(inst, "issues", _issuesDesc);
|
|
656
|
+
_issuesDesc.value = void 0;
|
|
657
|
+
Object.defineProperty(inst, "message", _messageDesc);
|
|
658
|
+
const proto = Object.getPrototypeOf(inst);
|
|
659
|
+
if (!_installedToString.has(proto)) {
|
|
660
|
+
_installedToString.add(proto);
|
|
661
|
+
Object.defineProperty(proto, "toString", {
|
|
662
|
+
configurable: true,
|
|
663
|
+
enumerable: false,
|
|
664
|
+
get() {
|
|
665
|
+
const value = () => this.message;
|
|
666
|
+
Object.defineProperty(this, "toString", {
|
|
667
|
+
value,
|
|
668
|
+
configurable: true,
|
|
669
|
+
writable: true
|
|
670
|
+
});
|
|
671
|
+
return value;
|
|
672
|
+
},
|
|
673
|
+
set(value) {
|
|
674
|
+
Object.defineProperty(this, "toString", {
|
|
675
|
+
value,
|
|
676
|
+
configurable: true,
|
|
677
|
+
writable: true
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
388
682
|
};
|
|
389
683
|
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
390
|
-
|
|
684
|
+
$constructor("$ZodError", initializer$1, void 0, { Parent: Error });
|
|
685
|
+
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
|
|
686
|
+
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
|
|
687
|
+
* "__proto__" would hit the setter instead of creating a key. */
|
|
688
|
+
function node(obj, key, make) {
|
|
689
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
690
|
+
if (key === "__proto__") Object.defineProperty(obj, key, {
|
|
691
|
+
value: make(),
|
|
692
|
+
writable: true,
|
|
693
|
+
enumerable: true,
|
|
694
|
+
configurable: true
|
|
695
|
+
});
|
|
696
|
+
else obj[key] = make();
|
|
697
|
+
}
|
|
698
|
+
return obj[key];
|
|
699
|
+
}
|
|
391
700
|
function flattenError(error, mapper = (issue) => issue.message) {
|
|
392
701
|
const fieldErrors = {};
|
|
393
702
|
const formErrors = [];
|
|
394
|
-
for (const sub of error.issues) if (sub.path.length > 0)
|
|
395
|
-
|
|
396
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
397
|
-
} else formErrors.push(mapper(sub));
|
|
703
|
+
for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
|
|
704
|
+
else formErrors.push(mapper(sub));
|
|
398
705
|
return {
|
|
399
706
|
formErrors,
|
|
400
707
|
fieldErrors
|
|
@@ -402,23 +709,35 @@ function flattenError(error, mapper = (issue) => issue.message) {
|
|
|
402
709
|
}
|
|
403
710
|
function formatError(error, mapper = (issue) => issue.message) {
|
|
404
711
|
const fieldErrors = { _errors: [] };
|
|
405
|
-
const processError = (error) => {
|
|
406
|
-
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
|
|
407
|
-
else if (issue.code === "invalid_key") processError({ issues: issue.issues });
|
|
408
|
-
else if (issue.code === "invalid_element") processError({ issues: issue.issues });
|
|
409
|
-
else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
712
|
+
const processError = (error, path = []) => {
|
|
713
|
+
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
714
|
+
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
715
|
+
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
410
716
|
else {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
717
|
+
const fullpath = [...path, ...issue.path];
|
|
718
|
+
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
|
|
719
|
+
else {
|
|
720
|
+
let curr = fieldErrors;
|
|
721
|
+
let i = 0;
|
|
722
|
+
while (i < fullpath.length) {
|
|
723
|
+
const el = fullpath[i];
|
|
724
|
+
const terminal = i === fullpath.length - 1;
|
|
725
|
+
if (el === "_errors") {
|
|
726
|
+
if (terminal) curr._errors.push(mapper(issue));
|
|
727
|
+
i++;
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
|
|
731
|
+
value: { _errors: [] },
|
|
732
|
+
enumerable: true,
|
|
733
|
+
writable: true,
|
|
734
|
+
configurable: true
|
|
735
|
+
});
|
|
736
|
+
const node = curr[el];
|
|
737
|
+
if (terminal) node._errors.push(mapper(issue));
|
|
738
|
+
curr = node;
|
|
739
|
+
i++;
|
|
419
740
|
}
|
|
420
|
-
curr = curr[el];
|
|
421
|
-
i++;
|
|
422
741
|
}
|
|
423
742
|
}
|
|
424
743
|
};
|
|
@@ -479,34 +798,52 @@ function prettifyError(error) {
|
|
|
479
798
|
return lines.join("\n");
|
|
480
799
|
}
|
|
481
800
|
//#endregion
|
|
482
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
801
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/parse.js
|
|
802
|
+
function finalizeParams(callee, params) {
|
|
803
|
+
return {
|
|
804
|
+
callee: params?.callee ?? callee,
|
|
805
|
+
Err: params?.Err
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
const _parse = (_Err) => {
|
|
809
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
810
|
+
const ctx = _ctx ? {
|
|
811
|
+
..._ctx,
|
|
812
|
+
async: false
|
|
813
|
+
} : { async: false };
|
|
814
|
+
const result = schema._zod.run({
|
|
815
|
+
value,
|
|
816
|
+
issues: []
|
|
817
|
+
}, ctx);
|
|
818
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
819
|
+
if (result.issues.length) {
|
|
820
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
821
|
+
captureStackTrace(e, _params?.callee ?? fn);
|
|
822
|
+
throw e;
|
|
823
|
+
}
|
|
824
|
+
return result.value;
|
|
825
|
+
};
|
|
826
|
+
return fn;
|
|
496
827
|
};
|
|
497
|
-
const _parseAsync = (_Err) =>
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
828
|
+
const _parseAsync = (_Err) => {
|
|
829
|
+
const fn = async (schema, value, _ctx, params) => {
|
|
830
|
+
const ctx = _ctx ? {
|
|
831
|
+
..._ctx,
|
|
832
|
+
async: true
|
|
833
|
+
} : { async: true };
|
|
834
|
+
let result = schema._zod.run({
|
|
835
|
+
value,
|
|
836
|
+
issues: []
|
|
837
|
+
}, ctx);
|
|
838
|
+
if (result instanceof Promise) result = await result;
|
|
839
|
+
if (result.issues.length) {
|
|
840
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
841
|
+
captureStackTrace(e, params?.callee ?? fn);
|
|
842
|
+
throw e;
|
|
843
|
+
}
|
|
844
|
+
return result.value;
|
|
845
|
+
};
|
|
846
|
+
return fn;
|
|
510
847
|
};
|
|
511
848
|
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
512
849
|
const ctx = _ctx ? {
|
|
@@ -518,69 +855,169 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
518
855
|
issues: []
|
|
519
856
|
}, ctx);
|
|
520
857
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
521
|
-
return result.issues.length ? {
|
|
522
|
-
success: false,
|
|
523
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
524
|
-
} : {
|
|
858
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
525
859
|
success: true,
|
|
526
860
|
data: result.value
|
|
527
861
|
};
|
|
528
862
|
};
|
|
529
|
-
|
|
863
|
+
function failure(Err, issues, ctx) {
|
|
864
|
+
let error;
|
|
865
|
+
return {
|
|
866
|
+
success: false,
|
|
867
|
+
get error() {
|
|
868
|
+
if (!error) {
|
|
869
|
+
error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
870
|
+
issues = void 0;
|
|
871
|
+
ctx = void 0;
|
|
872
|
+
}
|
|
873
|
+
return error;
|
|
874
|
+
},
|
|
875
|
+
set error(e) {
|
|
876
|
+
error = e;
|
|
877
|
+
issues = void 0;
|
|
878
|
+
ctx = void 0;
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
530
882
|
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
531
|
-
const ctx = _ctx ?
|
|
883
|
+
const ctx = _ctx ? {
|
|
884
|
+
..._ctx,
|
|
885
|
+
async: true
|
|
886
|
+
} : { async: true };
|
|
532
887
|
let result = schema._zod.run({
|
|
533
888
|
value,
|
|
534
889
|
issues: []
|
|
535
890
|
}, ctx);
|
|
536
891
|
if (result instanceof Promise) result = await result;
|
|
537
|
-
return result.issues.length ? {
|
|
538
|
-
success: false,
|
|
539
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
540
|
-
} : {
|
|
892
|
+
return result.issues.length ? failure(_Err, result.issues, ctx) : {
|
|
541
893
|
success: true,
|
|
542
894
|
data: result.value
|
|
543
895
|
};
|
|
544
896
|
};
|
|
545
|
-
const
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
897
|
+
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
898
|
+
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
899
|
+
const validate = ((schema, value, _ctx) => {
|
|
900
|
+
const validator = schema._zod.bag.validator;
|
|
901
|
+
if (validator !== void 0) {
|
|
902
|
+
if (validator(value) !== COMPILE_INVALID) return true;
|
|
903
|
+
if (validator.definite === true && _ctx === void 0) return false;
|
|
904
|
+
}
|
|
905
|
+
return validateFallback(schema, value, _ctx);
|
|
906
|
+
});
|
|
907
|
+
function validateFallback(schema, value, _ctx) {
|
|
908
|
+
const ctx = _ctx ? {
|
|
909
|
+
..._ctx,
|
|
910
|
+
async: false,
|
|
911
|
+
abortEarly: true
|
|
912
|
+
} : {
|
|
913
|
+
async: false,
|
|
914
|
+
abortEarly: true
|
|
915
|
+
};
|
|
916
|
+
const fallbackRun = schema._zod.bag.fallbackRun;
|
|
917
|
+
let result;
|
|
918
|
+
if (fallbackRun) {
|
|
919
|
+
ctx[COMPILE_FALLBACK] = true;
|
|
920
|
+
result = fallbackRun({
|
|
921
|
+
value,
|
|
922
|
+
issues: []
|
|
923
|
+
}, ctx);
|
|
924
|
+
} else result = schema._zod.run({
|
|
925
|
+
value,
|
|
926
|
+
issues: []
|
|
927
|
+
}, ctx);
|
|
928
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
929
|
+
return result.issues.length === 0;
|
|
930
|
+
}
|
|
931
|
+
const validateAsync$1 = async (schema, value, _ctx) => {
|
|
932
|
+
const ctx = _ctx ? {
|
|
933
|
+
..._ctx,
|
|
934
|
+
async: true,
|
|
935
|
+
abortEarly: true
|
|
936
|
+
} : {
|
|
937
|
+
async: true,
|
|
938
|
+
abortEarly: true
|
|
939
|
+
};
|
|
940
|
+
let result = schema._zod.run({
|
|
941
|
+
value,
|
|
942
|
+
issues: []
|
|
943
|
+
}, ctx);
|
|
944
|
+
if (result instanceof Promise) result = await result;
|
|
945
|
+
return result.issues.length === 0;
|
|
549
946
|
};
|
|
550
|
-
const
|
|
551
|
-
|
|
947
|
+
const _encode = (_Err) => {
|
|
948
|
+
const parse = _parse(_Err);
|
|
949
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
950
|
+
const ctx = _ctx ? {
|
|
951
|
+
..._ctx,
|
|
952
|
+
direction: "backward"
|
|
953
|
+
} : { direction: "backward" };
|
|
954
|
+
return parse(schema, value, ctx, finalizeParams(fn, _params));
|
|
955
|
+
};
|
|
956
|
+
return fn;
|
|
552
957
|
};
|
|
553
|
-
const
|
|
554
|
-
const
|
|
555
|
-
|
|
958
|
+
const _decode = (_Err) => {
|
|
959
|
+
const parse = _parse(_Err);
|
|
960
|
+
const fn = (schema, value, _ctx, _params) => {
|
|
961
|
+
return parse(schema, value, _ctx, finalizeParams(fn, _params));
|
|
962
|
+
};
|
|
963
|
+
return fn;
|
|
556
964
|
};
|
|
557
|
-
const
|
|
558
|
-
|
|
965
|
+
const _encodeAsync = (_Err) => {
|
|
966
|
+
const parseAsync = _parseAsync(_Err);
|
|
967
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
968
|
+
const ctx = _ctx ? {
|
|
969
|
+
..._ctx,
|
|
970
|
+
direction: "backward"
|
|
971
|
+
} : { direction: "backward" };
|
|
972
|
+
return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
|
|
973
|
+
};
|
|
974
|
+
return fn;
|
|
975
|
+
};
|
|
976
|
+
const _decodeAsync = (_Err) => {
|
|
977
|
+
const parseAsync = _parseAsync(_Err);
|
|
978
|
+
const fn = async (schema, value, _ctx, _params) => {
|
|
979
|
+
return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
|
|
980
|
+
};
|
|
981
|
+
return fn;
|
|
559
982
|
};
|
|
560
983
|
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
561
|
-
const ctx = _ctx ?
|
|
984
|
+
const ctx = _ctx ? {
|
|
985
|
+
..._ctx,
|
|
986
|
+
direction: "backward"
|
|
987
|
+
} : { direction: "backward" };
|
|
562
988
|
return _safeParse(_Err)(schema, value, ctx);
|
|
563
989
|
};
|
|
564
990
|
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
565
991
|
return _safeParse(_Err)(schema, value, _ctx);
|
|
566
992
|
};
|
|
567
993
|
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
568
|
-
const ctx = _ctx ?
|
|
994
|
+
const ctx = _ctx ? {
|
|
995
|
+
..._ctx,
|
|
996
|
+
direction: "backward"
|
|
997
|
+
} : { direction: "backward" };
|
|
569
998
|
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
570
999
|
};
|
|
571
1000
|
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
572
1001
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
573
1002
|
};
|
|
574
1003
|
//#endregion
|
|
575
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
576
|
-
|
|
1004
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/regexes.js
|
|
1005
|
+
/**
|
|
1006
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
1007
|
+
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
1008
|
+
* See https://github.com/paralleldrive/cuid.
|
|
1009
|
+
*/
|
|
1010
|
+
const cuid = /^[cC][0-9a-z]{6,}$/;
|
|
577
1011
|
const cuid2 = /^[0-9a-z]+$/;
|
|
578
|
-
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{
|
|
1012
|
+
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
|
|
579
1013
|
const xid = /^[0-9a-vA-V]{20}$/;
|
|
580
1014
|
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
581
1015
|
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1016
|
+
function nanoidOfLength(length) {
|
|
1017
|
+
return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
|
|
1018
|
+
}
|
|
582
1019
|
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
|
|
583
|
-
const duration
|
|
1020
|
+
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
584
1021
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
585
1022
|
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})$/;
|
|
586
1023
|
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
@@ -591,52 +1028,63 @@ const uuid = (version) => {
|
|
|
591
1028
|
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})$`);
|
|
592
1029
|
};
|
|
593
1030
|
/** Practical email validation */
|
|
594
|
-
const email = /^(
|
|
595
|
-
const _emoji$1 = `^(\\p{Extended_Pictographic}
|
|
1031
|
+
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,}$/;
|
|
1032
|
+
const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
596
1033
|
function emoji() {
|
|
597
1034
|
return new RegExp(_emoji$1, "u");
|
|
598
1035
|
}
|
|
599
1036
|
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])$/;
|
|
600
1037
|
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}|:))$/;
|
|
601
1038
|
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])$/;
|
|
602
|
-
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
1039
|
+
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])$/;
|
|
603
1040
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
604
|
-
const base64url = /^[A-Za-z0-9_-]
|
|
1041
|
+
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
|
|
1042
|
+
const httpProtocol = /^https?$/;
|
|
605
1043
|
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
606
1044
|
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])))`;
|
|
607
|
-
|
|
1045
|
+
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
|
|
1046
|
+
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
|
|
1047
|
+
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
|
|
1048
|
+
function anchor(source) {
|
|
1049
|
+
return new RegExp(`^${source}$`);
|
|
1050
|
+
}
|
|
1051
|
+
const date = /*@__PURE__*/ anchor(dateSource);
|
|
608
1052
|
function timeSource(args) {
|
|
609
1053
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
610
|
-
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+)?)?`;
|
|
1054
|
+
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+)?)?`;
|
|
611
1055
|
}
|
|
612
|
-
function time
|
|
1056
|
+
function time(args) {
|
|
613
1057
|
return new RegExp(`^${timeSource(args)}$`);
|
|
614
1058
|
}
|
|
615
|
-
function datetime
|
|
616
|
-
const time = timeSource({ precision: args.precision });
|
|
1059
|
+
function datetime(args) {
|
|
617
1060
|
const opts = ["Z"];
|
|
618
|
-
if (args.local) opts.push("");
|
|
619
1061
|
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
620
|
-
const
|
|
1062
|
+
const qualified = `${timeSource({
|
|
1063
|
+
precision: args.precision,
|
|
1064
|
+
seconds: true
|
|
1065
|
+
})}(?:${opts.join("|")})`;
|
|
1066
|
+
const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
|
|
621
1067
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
622
1068
|
}
|
|
623
|
-
const
|
|
624
|
-
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
625
|
-
return new RegExp(`^${regex}$`);
|
|
626
|
-
};
|
|
1069
|
+
const anyString = /^[\s\S]{0,}$/;
|
|
627
1070
|
const integer = /^-?\d+$/;
|
|
628
1071
|
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
629
1072
|
const boolean$1 = /^(?:true|false)$/i;
|
|
630
1073
|
const lowercase = /^[^A-Z]*$/;
|
|
631
1074
|
const uppercase = /^[^a-z]*$/;
|
|
632
1075
|
//#endregion
|
|
633
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
1076
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/checks.js
|
|
634
1077
|
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
635
1078
|
var _a;
|
|
636
1079
|
inst._zod ?? (inst._zod = {});
|
|
637
1080
|
inst._zod.def = def;
|
|
638
1081
|
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
639
1082
|
});
|
|
1083
|
+
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
|
|
1084
|
+
const _whenHasLength = (payload) => {
|
|
1085
|
+
const val = payload.value;
|
|
1086
|
+
return !nullish(val) && val.length !== void 0;
|
|
1087
|
+
};
|
|
640
1088
|
const numericOriginMap = {
|
|
641
1089
|
number: "number",
|
|
642
1090
|
bigint: "bigint",
|
|
@@ -645,18 +1093,10 @@ const numericOriginMap = {
|
|
|
645
1093
|
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
|
|
646
1094
|
$ZodCheck.init(inst, def);
|
|
647
1095
|
const origin = numericOriginMap[typeof def.value];
|
|
648
|
-
inst._zod.onattach.push((inst) => {
|
|
649
|
-
const bag = inst._zod.bag;
|
|
650
|
-
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
651
|
-
if (def.value < curr) {
|
|
652
|
-
if (def.inclusive) bag.maximum = def.value;
|
|
653
|
-
else bag.exclusiveMaximum = def.value;
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
1096
|
inst._zod.check = (payload) => {
|
|
657
1097
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
658
1098
|
payload.issues.push({
|
|
659
|
-
origin,
|
|
1099
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
660
1100
|
code: "too_big",
|
|
661
1101
|
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
662
1102
|
input: payload.value,
|
|
@@ -669,18 +1109,10 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
|
|
|
669
1109
|
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
670
1110
|
$ZodCheck.init(inst, def);
|
|
671
1111
|
const origin = numericOriginMap[typeof def.value];
|
|
672
|
-
inst._zod.onattach.push((inst) => {
|
|
673
|
-
const bag = inst._zod.bag;
|
|
674
|
-
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
675
|
-
if (def.value > curr) {
|
|
676
|
-
if (def.inclusive) bag.minimum = def.value;
|
|
677
|
-
else bag.exclusiveMinimum = def.value;
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
1112
|
inst._zod.check = (payload) => {
|
|
681
1113
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
682
1114
|
payload.issues.push({
|
|
683
|
-
origin,
|
|
1115
|
+
origin: numericOriginMap[typeof payload.value] ?? origin,
|
|
684
1116
|
code: "too_small",
|
|
685
1117
|
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
686
1118
|
input: payload.value,
|
|
@@ -692,13 +1124,9 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
|
|
|
692
1124
|
});
|
|
693
1125
|
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
694
1126
|
$ZodCheck.init(inst, def);
|
|
695
|
-
inst._zod.onattach.push((inst) => {
|
|
696
|
-
var _a;
|
|
697
|
-
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
698
|
-
});
|
|
699
1127
|
inst._zod.check = (payload) => {
|
|
700
1128
|
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
701
|
-
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
1129
|
+
if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
|
|
702
1130
|
payload.issues.push({
|
|
703
1131
|
origin: typeof payload.value,
|
|
704
1132
|
code: "not_multiple_of",
|
|
@@ -715,13 +1143,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
|
|
|
715
1143
|
const isInt = def.format?.includes("int");
|
|
716
1144
|
const origin = isInt ? "int" : "number";
|
|
717
1145
|
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
|
|
718
|
-
inst._zod.onattach.push((inst) => {
|
|
719
|
-
const bag = inst._zod.bag;
|
|
720
|
-
bag.format = def.format;
|
|
721
|
-
bag.minimum = minimum;
|
|
722
|
-
bag.maximum = maximum;
|
|
723
|
-
if (isInt) bag.pattern = integer;
|
|
724
|
-
});
|
|
725
1146
|
inst._zod.check = (payload) => {
|
|
726
1147
|
const input = payload.value;
|
|
727
1148
|
if (isInt) {
|
|
@@ -783,17 +1204,11 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
|
|
|
783
1204
|
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
784
1205
|
var _a;
|
|
785
1206
|
$ZodCheck.init(inst, def);
|
|
786
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
787
|
-
const val = payload.value;
|
|
788
|
-
return !nullish(val) && val.length !== void 0;
|
|
789
|
-
});
|
|
790
|
-
inst._zod.onattach.push((inst) => {
|
|
791
|
-
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
792
|
-
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
|
|
793
|
-
});
|
|
1207
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
794
1208
|
inst._zod.check = (payload) => {
|
|
795
1209
|
const input = payload.value;
|
|
796
|
-
|
|
1210
|
+
const units = input.length;
|
|
1211
|
+
if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
|
|
797
1212
|
const origin = getLengthableOrigin(input);
|
|
798
1213
|
payload.issues.push({
|
|
799
1214
|
origin,
|
|
@@ -809,17 +1224,11 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
|
|
|
809
1224
|
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
810
1225
|
var _a;
|
|
811
1226
|
$ZodCheck.init(inst, def);
|
|
812
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
813
|
-
const val = payload.value;
|
|
814
|
-
return !nullish(val) && val.length !== void 0;
|
|
815
|
-
});
|
|
816
|
-
inst._zod.onattach.push((inst) => {
|
|
817
|
-
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
818
|
-
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
|
|
819
|
-
});
|
|
1227
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
820
1228
|
inst._zod.check = (payload) => {
|
|
821
1229
|
const input = payload.value;
|
|
822
|
-
|
|
1230
|
+
const units = input.length;
|
|
1231
|
+
if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
|
|
823
1232
|
const origin = getLengthableOrigin(input);
|
|
824
1233
|
payload.issues.push({
|
|
825
1234
|
origin,
|
|
@@ -835,19 +1244,11 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
|
|
|
835
1244
|
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
836
1245
|
var _a;
|
|
837
1246
|
$ZodCheck.init(inst, def);
|
|
838
|
-
(_a = inst._zod.def).when ?? (_a.when =
|
|
839
|
-
const val = payload.value;
|
|
840
|
-
return !nullish(val) && val.length !== void 0;
|
|
841
|
-
});
|
|
842
|
-
inst._zod.onattach.push((inst) => {
|
|
843
|
-
const bag = inst._zod.bag;
|
|
844
|
-
bag.minimum = def.length;
|
|
845
|
-
bag.maximum = def.length;
|
|
846
|
-
bag.length = def.length;
|
|
847
|
-
});
|
|
1247
|
+
(_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
|
|
848
1248
|
inst._zod.check = (payload) => {
|
|
849
1249
|
const input = payload.value;
|
|
850
|
-
const
|
|
1250
|
+
const units = input.length;
|
|
1251
|
+
const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
|
|
851
1252
|
if (length === def.length) return;
|
|
852
1253
|
const origin = getLengthableOrigin(input);
|
|
853
1254
|
const tooBig = length > def.length;
|
|
@@ -871,14 +1272,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
|
|
|
871
1272
|
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
872
1273
|
var _a, _b;
|
|
873
1274
|
$ZodCheck.init(inst, def);
|
|
874
|
-
inst._zod.onattach.push((inst) => {
|
|
875
|
-
const bag = inst._zod.bag;
|
|
876
|
-
bag.format = def.format;
|
|
877
|
-
if (def.pattern) {
|
|
878
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
879
|
-
bag.patterns.add(def.pattern);
|
|
880
|
-
}
|
|
881
|
-
});
|
|
882
1275
|
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
883
1276
|
def.pattern.lastIndex = 0;
|
|
884
1277
|
if (def.pattern.test(payload.value)) return;
|
|
@@ -921,13 +1314,7 @@ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (ins
|
|
|
921
1314
|
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
922
1315
|
$ZodCheck.init(inst, def);
|
|
923
1316
|
const escapedRegex = escapeRegex(def.includes);
|
|
924
|
-
|
|
925
|
-
def.pattern = pattern;
|
|
926
|
-
inst._zod.onattach.push((inst) => {
|
|
927
|
-
const bag = inst._zod.bag;
|
|
928
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
929
|
-
bag.patterns.add(pattern);
|
|
930
|
-
});
|
|
1317
|
+
def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
|
|
931
1318
|
inst._zod.check = (payload) => {
|
|
932
1319
|
if (payload.value.includes(def.includes, def.position)) return;
|
|
933
1320
|
payload.issues.push({
|
|
@@ -945,11 +1332,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
|
|
|
945
1332
|
$ZodCheck.init(inst, def);
|
|
946
1333
|
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
947
1334
|
def.pattern ?? (def.pattern = pattern);
|
|
948
|
-
inst._zod.onattach.push((inst) => {
|
|
949
|
-
const bag = inst._zod.bag;
|
|
950
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
951
|
-
bag.patterns.add(pattern);
|
|
952
|
-
});
|
|
953
1335
|
inst._zod.check = (payload) => {
|
|
954
1336
|
if (payload.value.startsWith(def.prefix)) return;
|
|
955
1337
|
payload.issues.push({
|
|
@@ -967,11 +1349,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
|
|
|
967
1349
|
$ZodCheck.init(inst, def);
|
|
968
1350
|
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
969
1351
|
def.pattern ?? (def.pattern = pattern);
|
|
970
|
-
inst._zod.onattach.push((inst) => {
|
|
971
|
-
const bag = inst._zod.bag;
|
|
972
|
-
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
973
|
-
bag.patterns.add(pattern);
|
|
974
|
-
});
|
|
975
1352
|
inst._zod.check = (payload) => {
|
|
976
1353
|
if (payload.value.endsWith(def.suffix)) return;
|
|
977
1354
|
payload.issues.push({
|
|
@@ -992,17 +1369,21 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
|
|
|
992
1369
|
};
|
|
993
1370
|
});
|
|
994
1371
|
//#endregion
|
|
995
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
1372
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/doc.js
|
|
996
1373
|
var Doc = class {
|
|
997
|
-
constructor(args = []) {
|
|
1374
|
+
constructor(args = [], closed = {}) {
|
|
998
1375
|
this.content = [];
|
|
999
1376
|
this.indent = 0;
|
|
1000
|
-
|
|
1377
|
+
this.args = args;
|
|
1378
|
+
this.closed = closed;
|
|
1001
1379
|
}
|
|
1002
1380
|
indented(fn) {
|
|
1003
1381
|
this.indent += 1;
|
|
1004
|
-
|
|
1005
|
-
|
|
1382
|
+
try {
|
|
1383
|
+
fn(this);
|
|
1384
|
+
} finally {
|
|
1385
|
+
this.indent -= 1;
|
|
1386
|
+
}
|
|
1006
1387
|
}
|
|
1007
1388
|
write(arg) {
|
|
1008
1389
|
if (typeof arg === "function") {
|
|
@@ -1017,28 +1398,27 @@ var Doc = class {
|
|
|
1017
1398
|
}
|
|
1018
1399
|
compile() {
|
|
1019
1400
|
const F = Function;
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
return new F(...args, lines.join("\n"));
|
|
1401
|
+
const content = this?.content ?? [``];
|
|
1402
|
+
return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
|
|
1023
1403
|
}
|
|
1024
1404
|
};
|
|
1025
1405
|
//#endregion
|
|
1026
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
1406
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/versions.js
|
|
1027
1407
|
const version = {
|
|
1028
1408
|
major: 4,
|
|
1029
|
-
minor:
|
|
1030
|
-
patch:
|
|
1409
|
+
minor: 6,
|
|
1410
|
+
patch: 5
|
|
1031
1411
|
};
|
|
1032
1412
|
//#endregion
|
|
1033
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
1413
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/schemas.js
|
|
1034
1414
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
1035
1415
|
var _a;
|
|
1036
1416
|
inst ?? (inst = {});
|
|
1037
1417
|
inst._zod.def = def;
|
|
1038
1418
|
inst._zod.bag = inst._zod.bag || {};
|
|
1039
1419
|
inst._zod.version = version;
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1420
|
+
const defChecks = inst._zod.def.checks;
|
|
1421
|
+
const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
|
|
1042
1422
|
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1043
1423
|
if (checks.length === 0) {
|
|
1044
1424
|
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
@@ -1047,10 +1427,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1047
1427
|
});
|
|
1048
1428
|
} else {
|
|
1049
1429
|
const runChecks = (payload, checks, ctx) => {
|
|
1430
|
+
if (payload.memo) return payload;
|
|
1050
1431
|
let isAborted = aborted(payload);
|
|
1051
1432
|
let asyncResult;
|
|
1052
1433
|
for (const ch of checks) {
|
|
1053
1434
|
if (ch._zod.def.when) {
|
|
1435
|
+
if (explicitlyAborted(payload)) continue;
|
|
1054
1436
|
if (!ch._zod.def.when(payload)) continue;
|
|
1055
1437
|
} else if (isAborted) continue;
|
|
1056
1438
|
const currLen = payload.issues.length;
|
|
@@ -1059,10 +1441,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1059
1441
|
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1060
1442
|
await _;
|
|
1061
1443
|
if (payload.issues.length === currLen) return;
|
|
1444
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1062
1445
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1063
1446
|
});
|
|
1064
1447
|
else {
|
|
1065
1448
|
if (payload.issues.length === currLen) continue;
|
|
1449
|
+
attachSchema(payload.issues, currLen, inst);
|
|
1066
1450
|
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1067
1451
|
}
|
|
1068
1452
|
}
|
|
@@ -1106,22 +1490,43 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
|
1106
1490
|
return runChecks(result, checks, ctx);
|
|
1107
1491
|
};
|
|
1108
1492
|
}
|
|
1109
|
-
|
|
1493
|
+
}, {
|
|
1494
|
+
get "~standard"() {
|
|
1495
|
+
return hide(this, "~standard", standardProps(this));
|
|
1496
|
+
},
|
|
1497
|
+
set "~standard"(value) {
|
|
1498
|
+
own(this, "~standard", value);
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
1502
|
+
const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
|
|
1503
|
+
async function validateAsync(inst, value) {
|
|
1504
|
+
const ctx = { async: true };
|
|
1505
|
+
return toStandardResult(await inst._zod.run({
|
|
1506
|
+
value,
|
|
1507
|
+
issues: []
|
|
1508
|
+
}, ctx), ctx);
|
|
1509
|
+
}
|
|
1510
|
+
function standardProps(inst) {
|
|
1511
|
+
return {
|
|
1110
1512
|
validate: (value) => {
|
|
1513
|
+
const ctx = { async: false };
|
|
1111
1514
|
try {
|
|
1112
|
-
const r =
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1515
|
+
const r = inst._zod.run({
|
|
1516
|
+
value,
|
|
1517
|
+
issues: []
|
|
1518
|
+
}, ctx);
|
|
1519
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
1520
|
+
} catch (_) {}
|
|
1521
|
+
return validateAsync(inst, value);
|
|
1117
1522
|
},
|
|
1118
1523
|
vendor: "zod",
|
|
1119
1524
|
version: 1
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1122
1527
|
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
|
|
1123
1528
|
$ZodType.init(inst, def);
|
|
1124
|
-
inst._zod.pattern =
|
|
1529
|
+
inst._zod.pattern = def.pattern ?? anyString;
|
|
1125
1530
|
inst._zod.parse = (payload, _) => {
|
|
1126
1531
|
if (def.coerce) try {
|
|
1127
1532
|
payload.value = String(payload.value);
|
|
@@ -1165,38 +1570,95 @@ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
|
|
|
1165
1570
|
def.pattern ?? (def.pattern = email);
|
|
1166
1571
|
$ZodStringFormat.init(inst, def);
|
|
1167
1572
|
});
|
|
1573
|
+
function canParseURL(input) {
|
|
1574
|
+
try {
|
|
1575
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
1576
|
+
new URL(input);
|
|
1577
|
+
return true;
|
|
1578
|
+
} catch {
|
|
1579
|
+
return false;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
function validateURL(trimmed, def) {
|
|
1583
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
|
|
1584
|
+
return parseURLObject(trimmed, def);
|
|
1585
|
+
}
|
|
1586
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
1587
|
+
function parseURLObject(trimmed, def) {
|
|
1588
|
+
if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
|
|
1589
|
+
try {
|
|
1590
|
+
if (typeof URL !== "undefined") {
|
|
1591
|
+
const URLStatic = URL;
|
|
1592
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
|
|
1593
|
+
}
|
|
1594
|
+
return new URL(trimmed);
|
|
1595
|
+
} catch {
|
|
1596
|
+
return 2;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
1600
|
+
/** 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. */
|
|
1601
|
+
function stripTabAndNewline(value) {
|
|
1602
|
+
return value.replace(asciiTabOrNewline, "");
|
|
1603
|
+
}
|
|
1604
|
+
function urlHostnameOk(url, hostname) {
|
|
1605
|
+
hostname.lastIndex = 0;
|
|
1606
|
+
return hostname.test(url.hostname);
|
|
1607
|
+
}
|
|
1608
|
+
function urlProtocolOk(url, protocol) {
|
|
1609
|
+
protocol.lastIndex = 0;
|
|
1610
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
1611
|
+
}
|
|
1168
1612
|
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
|
|
1169
1613
|
$ZodStringFormat.init(inst, def);
|
|
1170
1614
|
inst._zod.check = (payload) => {
|
|
1171
1615
|
try {
|
|
1172
1616
|
const trimmed = payload.value.trim();
|
|
1173
|
-
const url =
|
|
1174
|
-
if (
|
|
1175
|
-
|
|
1176
|
-
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1617
|
+
const url = validateURL(trimmed, def);
|
|
1618
|
+
if (url === 1) {
|
|
1619
|
+
payload.issues.push({
|
|
1177
1620
|
code: "invalid_format",
|
|
1178
1621
|
format: "url",
|
|
1179
|
-
note: "Invalid
|
|
1180
|
-
pattern: def.hostname.source,
|
|
1622
|
+
note: "Invalid URL format",
|
|
1181
1623
|
input: payload.value,
|
|
1182
1624
|
inst,
|
|
1183
1625
|
continue: !def.abort
|
|
1184
1626
|
});
|
|
1627
|
+
return;
|
|
1185
1628
|
}
|
|
1186
|
-
if (
|
|
1187
|
-
|
|
1188
|
-
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1629
|
+
if (url === 2) {
|
|
1630
|
+
payload.issues.push({
|
|
1189
1631
|
code: "invalid_format",
|
|
1190
1632
|
format: "url",
|
|
1191
|
-
note: "Invalid protocol",
|
|
1192
|
-
pattern: def.protocol.source,
|
|
1193
1633
|
input: payload.value,
|
|
1194
1634
|
inst,
|
|
1195
1635
|
continue: !def.abort
|
|
1196
1636
|
});
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1639
|
+
if (url === true) {
|
|
1640
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
1641
|
+
return;
|
|
1197
1642
|
}
|
|
1198
|
-
if (def.
|
|
1199
|
-
|
|
1643
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
|
|
1644
|
+
code: "invalid_format",
|
|
1645
|
+
format: "url",
|
|
1646
|
+
note: "Invalid hostname",
|
|
1647
|
+
pattern: def.hostname.source,
|
|
1648
|
+
input: payload.value,
|
|
1649
|
+
inst,
|
|
1650
|
+
continue: !def.abort
|
|
1651
|
+
});
|
|
1652
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
|
|
1653
|
+
code: "invalid_format",
|
|
1654
|
+
format: "url",
|
|
1655
|
+
note: "Invalid protocol",
|
|
1656
|
+
pattern: def.protocol.source,
|
|
1657
|
+
input: payload.value,
|
|
1658
|
+
inst,
|
|
1659
|
+
continue: !def.abort
|
|
1660
|
+
});
|
|
1661
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
1200
1662
|
return;
|
|
1201
1663
|
} catch (_) {
|
|
1202
1664
|
payload.issues.push({
|
|
@@ -1214,9 +1676,15 @@ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
|
|
|
1214
1676
|
$ZodStringFormat.init(inst, def);
|
|
1215
1677
|
});
|
|
1216
1678
|
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
|
|
1217
|
-
def.
|
|
1679
|
+
if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
1680
|
+
def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
|
|
1218
1681
|
$ZodStringFormat.init(inst, def);
|
|
1219
1682
|
});
|
|
1683
|
+
/**
|
|
1684
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
1685
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
1686
|
+
* See https://github.com/paralleldrive/cuid.
|
|
1687
|
+
*/
|
|
1220
1688
|
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
|
|
1221
1689
|
def.pattern ?? (def.pattern = cuid);
|
|
1222
1690
|
$ZodStringFormat.init(inst, def);
|
|
@@ -1238,74 +1706,74 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
1238
1706
|
$ZodStringFormat.init(inst, def);
|
|
1239
1707
|
});
|
|
1240
1708
|
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1241
|
-
def.pattern ?? (def.pattern = datetime
|
|
1709
|
+
def.pattern ?? (def.pattern = datetime(def));
|
|
1242
1710
|
$ZodStringFormat.init(inst, def);
|
|
1243
1711
|
});
|
|
1244
1712
|
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
1245
|
-
def.pattern ?? (def.pattern = date
|
|
1713
|
+
def.pattern ?? (def.pattern = date);
|
|
1246
1714
|
$ZodStringFormat.init(inst, def);
|
|
1247
1715
|
});
|
|
1248
1716
|
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
1249
|
-
def.pattern ?? (def.pattern = time
|
|
1717
|
+
def.pattern ?? (def.pattern = time(def));
|
|
1250
1718
|
$ZodStringFormat.init(inst, def);
|
|
1251
1719
|
});
|
|
1252
1720
|
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
1253
|
-
def.pattern ?? (def.pattern = duration
|
|
1721
|
+
def.pattern ?? (def.pattern = duration);
|
|
1254
1722
|
$ZodStringFormat.init(inst, def);
|
|
1255
1723
|
});
|
|
1256
1724
|
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
|
|
1257
1725
|
def.pattern ?? (def.pattern = ipv4);
|
|
1258
1726
|
$ZodStringFormat.init(inst, def);
|
|
1259
|
-
inst._zod.bag.format = `ipv4`;
|
|
1260
1727
|
});
|
|
1728
|
+
/** 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`. */
|
|
1729
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
1730
|
+
function isValidIPv6(value) {
|
|
1731
|
+
if (!ipv6Alphabet.test(value)) return false;
|
|
1732
|
+
return canParseURL(`http://[${value}]`);
|
|
1733
|
+
}
|
|
1261
1734
|
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
|
|
1262
1735
|
def.pattern ?? (def.pattern = ipv6);
|
|
1263
1736
|
$ZodStringFormat.init(inst, def);
|
|
1264
|
-
inst._zod.bag.format = `ipv6`;
|
|
1265
1737
|
inst._zod.check = (payload) => {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
payload.
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
inst,
|
|
1274
|
-
continue: !def.abort
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1738
|
+
if (!isValidIPv6(payload.value)) payload.issues.push({
|
|
1739
|
+
code: "invalid_format",
|
|
1740
|
+
format: "ipv6",
|
|
1741
|
+
input: payload.value,
|
|
1742
|
+
inst,
|
|
1743
|
+
continue: !def.abort
|
|
1744
|
+
});
|
|
1277
1745
|
};
|
|
1278
1746
|
});
|
|
1279
1747
|
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1280
1748
|
def.pattern ?? (def.pattern = cidrv4);
|
|
1281
1749
|
$ZodStringFormat.init(inst, def);
|
|
1282
1750
|
});
|
|
1751
|
+
function isValidCIDRv6(value) {
|
|
1752
|
+
const parts = value.split("/");
|
|
1753
|
+
if (parts.length !== 2) return false;
|
|
1754
|
+
const [address, prefix] = parts;
|
|
1755
|
+
if (!prefix) return false;
|
|
1756
|
+
const prefixNum = Number(prefix);
|
|
1757
|
+
if (`${prefixNum}` !== prefix) return false;
|
|
1758
|
+
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
1759
|
+
return isValidIPv6(address);
|
|
1760
|
+
}
|
|
1283
1761
|
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1284
1762
|
def.pattern ?? (def.pattern = cidrv6);
|
|
1285
1763
|
$ZodStringFormat.init(inst, def);
|
|
1286
1764
|
inst._zod.check = (payload) => {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1295
|
-
new URL(`http://[${address}]`);
|
|
1296
|
-
} catch {
|
|
1297
|
-
payload.issues.push({
|
|
1298
|
-
code: "invalid_format",
|
|
1299
|
-
format: "cidrv6",
|
|
1300
|
-
input: payload.value,
|
|
1301
|
-
inst,
|
|
1302
|
-
continue: !def.abort
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1765
|
+
if (!isValidCIDRv6(payload.value)) payload.issues.push({
|
|
1766
|
+
code: "invalid_format",
|
|
1767
|
+
format: "cidrv6",
|
|
1768
|
+
input: payload.value,
|
|
1769
|
+
inst,
|
|
1770
|
+
continue: !def.abort
|
|
1771
|
+
});
|
|
1305
1772
|
};
|
|
1306
1773
|
});
|
|
1307
1774
|
function isValidBase64(data) {
|
|
1308
1775
|
if (data === "") return true;
|
|
1776
|
+
if (/\s/.test(data)) return false;
|
|
1309
1777
|
if (data.length % 4 !== 0) return false;
|
|
1310
1778
|
try {
|
|
1311
1779
|
atob(data);
|
|
@@ -1314,10 +1782,10 @@ function isValidBase64(data) {
|
|
|
1314
1782
|
return false;
|
|
1315
1783
|
}
|
|
1316
1784
|
}
|
|
1785
|
+
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1317
1786
|
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
1318
|
-
def.pattern ?? (def.pattern =
|
|
1787
|
+
def.pattern ?? (def.pattern = base64Charset);
|
|
1319
1788
|
$ZodStringFormat.init(inst, def);
|
|
1320
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
1321
1789
|
inst._zod.check = (payload) => {
|
|
1322
1790
|
if (isValidBase64(payload.value)) return;
|
|
1323
1791
|
payload.issues.push({
|
|
@@ -1329,15 +1797,15 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
|
|
|
1329
1797
|
});
|
|
1330
1798
|
};
|
|
1331
1799
|
});
|
|
1800
|
+
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
1332
1801
|
function isValidBase64URL(data) {
|
|
1333
|
-
if (!
|
|
1802
|
+
if (!base64urlCharset.test(data)) return false;
|
|
1334
1803
|
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
1335
1804
|
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
|
|
1336
1805
|
}
|
|
1337
1806
|
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1338
|
-
def.pattern ?? (def.pattern =
|
|
1807
|
+
def.pattern ?? (def.pattern = base64urlCharset);
|
|
1339
1808
|
$ZodStringFormat.init(inst, def);
|
|
1340
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
1341
1809
|
inst._zod.check = (payload) => {
|
|
1342
1810
|
if (isValidBase64URL(payload.value)) return;
|
|
1343
1811
|
payload.issues.push({
|
|
@@ -1383,14 +1851,14 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
|
|
|
1383
1851
|
});
|
|
1384
1852
|
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
|
|
1385
1853
|
$ZodType.init(inst, def);
|
|
1386
|
-
inst._zod.pattern =
|
|
1854
|
+
inst._zod.pattern = number$1;
|
|
1387
1855
|
inst._zod.parse = (payload, _ctx) => {
|
|
1388
1856
|
if (def.coerce) try {
|
|
1389
1857
|
payload.value = Number(payload.value);
|
|
1390
1858
|
} catch (_) {}
|
|
1391
1859
|
const input = payload.value;
|
|
1392
1860
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
|
|
1393
|
-
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ?
|
|
1861
|
+
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
|
|
1394
1862
|
payload.issues.push({
|
|
1395
1863
|
expected: "number",
|
|
1396
1864
|
code: "invalid_type",
|
|
@@ -1445,6 +1913,8 @@ function handleArrayResult(result, final, index) {
|
|
|
1445
1913
|
}
|
|
1446
1914
|
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
1447
1915
|
$ZodType.init(inst, def);
|
|
1916
|
+
const memo = globalConfig.memoizer;
|
|
1917
|
+
memo?.attach(inst);
|
|
1448
1918
|
inst._zod.parse = (payload, ctx) => {
|
|
1449
1919
|
const input = payload.value;
|
|
1450
1920
|
if (!Array.isArray(input)) {
|
|
@@ -1456,8 +1926,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1456
1926
|
});
|
|
1457
1927
|
return payload;
|
|
1458
1928
|
}
|
|
1459
|
-
payload.value = Array(input.length);
|
|
1929
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1460
1930
|
const proms = [];
|
|
1931
|
+
const abortEarly = ctx?.abortEarly;
|
|
1461
1932
|
for (let i = 0; i < input.length; i++) {
|
|
1462
1933
|
const item = input[i];
|
|
1463
1934
|
const result = def.element._zod.run({
|
|
@@ -1465,41 +1936,71 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
|
|
|
1465
1936
|
issues: []
|
|
1466
1937
|
}, ctx);
|
|
1467
1938
|
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1468
|
-
else
|
|
1939
|
+
else {
|
|
1940
|
+
handleArrayResult(result, payload, i);
|
|
1941
|
+
if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
|
|
1942
|
+
}
|
|
1469
1943
|
}
|
|
1470
1944
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1471
1945
|
return payload;
|
|
1472
1946
|
};
|
|
1473
1947
|
});
|
|
1474
|
-
function handlePropertyResult(result, final, key, input,
|
|
1948
|
+
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
1949
|
+
const isPresent = key in input;
|
|
1950
|
+
const isOptionalOut = optout === "optional";
|
|
1951
|
+
if (!isPresent && isOptionalOut && optin === "optional") return;
|
|
1475
1952
|
if (result.issues.length) {
|
|
1476
|
-
if (isOptionalOut && !
|
|
1953
|
+
if (optin !== void 0 && isOptionalOut && !isPresent) return;
|
|
1477
1954
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
1478
1955
|
}
|
|
1956
|
+
if (!isPresent && optin === void 0) {
|
|
1957
|
+
if (!result.issues.length) final.issues.push({
|
|
1958
|
+
code: "invalid_type",
|
|
1959
|
+
expected: "nonoptional",
|
|
1960
|
+
input: void 0,
|
|
1961
|
+
path: [key]
|
|
1962
|
+
});
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1479
1965
|
if (result.value === void 0) {
|
|
1480
|
-
if (
|
|
1966
|
+
if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
|
|
1481
1967
|
} else final.value[key] = result.value;
|
|
1482
1968
|
}
|
|
1969
|
+
const NO_SYMBOL_KEYS = [];
|
|
1483
1970
|
function normalizeDef(def) {
|
|
1484
1971
|
const keys = Object.keys(def.shape);
|
|
1485
|
-
|
|
1972
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
1973
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
1974
|
+
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
1975
|
+
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`);
|
|
1486
1976
|
const okeys = optionalKeys(def.shape);
|
|
1487
1977
|
return {
|
|
1488
1978
|
...def,
|
|
1489
|
-
|
|
1979
|
+
allKeys,
|
|
1980
|
+
symbolKeys,
|
|
1490
1981
|
keySet: new Set(keys),
|
|
1491
1982
|
numKeys: keys.length,
|
|
1492
1983
|
optionalKeys: new Set(okeys)
|
|
1493
1984
|
};
|
|
1494
1985
|
}
|
|
1495
|
-
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
1986
|
+
function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
|
|
1496
1987
|
const unrecognized = [];
|
|
1497
1988
|
const keySet = def.keySet;
|
|
1498
1989
|
const _catchall = def.catchall._zod;
|
|
1499
1990
|
const t = _catchall.def.type;
|
|
1500
|
-
const
|
|
1991
|
+
const optin = _catchall.optin;
|
|
1992
|
+
const optout = _catchall.optout;
|
|
1993
|
+
let seen = 0;
|
|
1501
1994
|
for (const key in input) {
|
|
1995
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
1996
|
+
if (aborted(payload, seen)) break;
|
|
1997
|
+
seen = payload.issues.length;
|
|
1998
|
+
}
|
|
1502
1999
|
if (keySet.has(key)) continue;
|
|
2000
|
+
if (key === "__proto__") {
|
|
2001
|
+
if (t === "never") unrecognized.push(key);
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
1503
2004
|
if (t === "never") {
|
|
1504
2005
|
unrecognized.push(key);
|
|
1505
2006
|
continue;
|
|
@@ -1508,14 +2009,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1508
2009
|
value: input[key],
|
|
1509
2010
|
issues: []
|
|
1510
2011
|
}, ctx);
|
|
1511
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1512
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2012
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2013
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1513
2014
|
}
|
|
1514
2015
|
if (unrecognized.length) payload.issues.push({
|
|
1515
2016
|
code: "unrecognized_keys",
|
|
1516
2017
|
keys: unrecognized,
|
|
1517
2018
|
input,
|
|
1518
|
-
inst
|
|
2019
|
+
inst,
|
|
2020
|
+
continue: true
|
|
1519
2021
|
});
|
|
1520
2022
|
if (!proms.length) return payload;
|
|
1521
2023
|
return Promise.all(proms).then(() => {
|
|
@@ -1524,23 +2026,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
1524
2026
|
}
|
|
1525
2027
|
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
1526
2028
|
$ZodType.init(inst, def);
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
2029
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
2030
|
+
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
2031
|
+
if (sh) {
|
|
2032
|
+
const get = () => {
|
|
1530
2033
|
const newSh = { ...sh };
|
|
1531
2034
|
Object.defineProperty(def, "shape", { value: newSh });
|
|
2035
|
+
get.raw = newSh;
|
|
1532
2036
|
return newSh;
|
|
1533
|
-
}
|
|
2037
|
+
};
|
|
2038
|
+
get.raw = sh;
|
|
2039
|
+
Object.defineProperty(def, "shape", { get });
|
|
1534
2040
|
}
|
|
1535
2041
|
const _normalized = cached(() => normalizeDef(def));
|
|
1536
|
-
|
|
1537
|
-
const shape = def.shape;
|
|
2042
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2043
|
+
const shape = zod.def.shape;
|
|
1538
2044
|
const propValues = {};
|
|
1539
2045
|
for (const key in shape) {
|
|
1540
2046
|
const field = shape[key]._zod;
|
|
1541
2047
|
if (field.values) {
|
|
1542
|
-
propValues
|
|
2048
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
|
|
1543
2049
|
for (const v of field.values) propValues[key].add(v);
|
|
2050
|
+
if (field.optin !== void 0) propValues[key].add(void 0);
|
|
1544
2051
|
}
|
|
1545
2052
|
}
|
|
1546
2053
|
return propValues;
|
|
@@ -1548,6 +2055,8 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1548
2055
|
const isObject$2 = isObject;
|
|
1549
2056
|
const catchall = def.catchall;
|
|
1550
2057
|
let value;
|
|
2058
|
+
const memo = globalConfig.memoizer;
|
|
2059
|
+
memo?.attach(inst);
|
|
1551
2060
|
inst._zod.parse = (payload, ctx) => {
|
|
1552
2061
|
value ?? (value = _normalized.value);
|
|
1553
2062
|
const input = payload.value;
|
|
@@ -1560,89 +2069,125 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
|
|
|
1560
2069
|
});
|
|
1561
2070
|
return payload;
|
|
1562
2071
|
}
|
|
1563
|
-
payload.value = {};
|
|
2072
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1564
2073
|
const proms = [];
|
|
1565
2074
|
const shape = value.shape;
|
|
1566
|
-
|
|
2075
|
+
const abortEarly = ctx?.abortEarly;
|
|
2076
|
+
let seen = payload.issues.length;
|
|
2077
|
+
for (const key of value.allKeys) {
|
|
2078
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2079
|
+
if (aborted(payload, seen)) break;
|
|
2080
|
+
seen = payload.issues.length;
|
|
2081
|
+
}
|
|
2082
|
+
if (key === "__proto__") continue;
|
|
1567
2083
|
const el = shape[key];
|
|
1568
|
-
const
|
|
2084
|
+
const optin = el._zod.optin;
|
|
2085
|
+
const optout = el._zod.optout;
|
|
1569
2086
|
const r = el._zod.run({
|
|
1570
2087
|
value: input[key],
|
|
1571
2088
|
issues: []
|
|
1572
2089
|
}, ctx);
|
|
1573
|
-
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
1574
|
-
else handlePropertyResult(r, payload, key, input,
|
|
2090
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
2091
|
+
else handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1575
2092
|
}
|
|
1576
2093
|
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1577
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2094
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1578
2095
|
};
|
|
1579
2096
|
});
|
|
1580
2097
|
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
1581
2098
|
$ZodObject.init(inst, def);
|
|
1582
2099
|
const superParse = inst._zod.parse;
|
|
1583
2100
|
const _normalized = cached(() => normalizeDef(def));
|
|
2101
|
+
const memo = globalConfig.memoizer;
|
|
1584
2102
|
const generateFastpass = (shape) => {
|
|
1585
|
-
const doc = new Doc([
|
|
1586
|
-
"shape",
|
|
1587
|
-
"payload",
|
|
1588
|
-
"ctx"
|
|
1589
|
-
]);
|
|
1590
2103
|
const normalized = _normalized.value;
|
|
1591
|
-
const
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
2104
|
+
const syms = normalized.symbolKeys;
|
|
2105
|
+
const doc = new Doc(["payload", "ctx"], {
|
|
2106
|
+
shape,
|
|
2107
|
+
inst,
|
|
2108
|
+
memo,
|
|
2109
|
+
syms
|
|
2110
|
+
});
|
|
2111
|
+
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2112
|
+
const prefixStr = (id, k) => `
|
|
2113
|
+
let ${id}_ab = false;
|
|
2114
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2115
|
+
const iss = ${id}.issues[i];
|
|
2116
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2117
|
+
payload.issues.push(iss);
|
|
2118
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2119
|
+
}
|
|
2120
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2121
|
+
payload.value = newResult;
|
|
2122
|
+
return payload;
|
|
2123
|
+
}`;
|
|
1595
2124
|
doc.write(`const input = payload.value;`);
|
|
1596
2125
|
const ids = Object.create(null);
|
|
1597
2126
|
let counter = 0;
|
|
1598
|
-
for (const key of normalized.
|
|
1599
|
-
doc.write(`const newResult = {};`);
|
|
1600
|
-
for (const key of normalized.
|
|
2127
|
+
for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
|
|
2128
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2129
|
+
for (const key of normalized.allKeys) {
|
|
2130
|
+
if (key === "__proto__") continue;
|
|
1601
2131
|
const id = ids[key];
|
|
1602
|
-
const k = esc(key);
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
2132
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
2133
|
+
const isPresent = `${k} in input`;
|
|
2134
|
+
const schema = shape[key];
|
|
2135
|
+
const optin = schema?._zod?.optin;
|
|
2136
|
+
const isOptionalIn = optin !== void 0;
|
|
2137
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2138
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
2139
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2140
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
2141
|
+
doc.write(`
|
|
2142
|
+
const ${id}_present = ${isPresent};
|
|
2143
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2144
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
if (${assign}) {
|
|
2148
|
+
newResult[${k}] = ${id}.value;
|
|
1612
2149
|
}
|
|
1613
2150
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
2151
|
+
|
|
2152
|
+
`);
|
|
2153
|
+
} else if (!isOptionalIn) doc.write(`
|
|
2154
|
+
const ${id}_present = ${isPresent};
|
|
2155
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2156
|
+
}
|
|
2157
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2158
|
+
payload.issues.push({
|
|
2159
|
+
code: "invalid_type",
|
|
2160
|
+
expected: "nonoptional",
|
|
2161
|
+
input: undefined,
|
|
2162
|
+
path: [${k}]
|
|
2163
|
+
});
|
|
2164
|
+
if (ctx && ctx.abortEarly) {
|
|
2165
|
+
payload.value = newResult;
|
|
2166
|
+
return payload;
|
|
1618
2167
|
}
|
|
1619
|
-
}
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
if (${id}_present) {
|
|
1620
2171
|
newResult[${k}] = ${id}.value;
|
|
1621
2172
|
}
|
|
1622
|
-
|
|
2173
|
+
|
|
1623
2174
|
`);
|
|
1624
|
-
else
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
...iss,
|
|
1628
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1629
|
-
})));
|
|
2175
|
+
else {
|
|
2176
|
+
doc.write(`
|
|
2177
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1630
2178
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
}
|
|
1636
|
-
} else {
|
|
2179
|
+
`);
|
|
2180
|
+
if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2181
|
+
else doc.write(`
|
|
2182
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1637
2183
|
newResult[${k}] = ${id}.value;
|
|
1638
2184
|
}
|
|
1639
|
-
|
|
1640
2185
|
`);
|
|
2186
|
+
}
|
|
1641
2187
|
}
|
|
1642
2188
|
doc.write(`payload.value = newResult;`);
|
|
1643
2189
|
doc.write(`return payload;`);
|
|
1644
|
-
|
|
1645
|
-
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2190
|
+
return doc.compile();
|
|
1646
2191
|
};
|
|
1647
2192
|
let fastpass;
|
|
1648
2193
|
const isObject$1 = isObject;
|
|
@@ -1666,7 +2211,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
1666
2211
|
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
1667
2212
|
payload = fastpass(payload, ctx);
|
|
1668
2213
|
if (!catchall) return payload;
|
|
1669
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2214
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
1670
2215
|
}
|
|
1671
2216
|
return superParse(payload, ctx);
|
|
1672
2217
|
};
|
|
@@ -1691,21 +2236,20 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
1691
2236
|
}
|
|
1692
2237
|
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
1693
2238
|
$ZodType.init(inst, def);
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
1698
|
-
});
|
|
1699
|
-
|
|
1700
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
1701
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2239
|
+
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);
|
|
2240
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
2241
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2242
|
+
if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2243
|
+
});
|
|
2244
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2245
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2246
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
1702
2247
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
1703
2248
|
}
|
|
1704
2249
|
});
|
|
1705
|
-
const
|
|
1706
|
-
const first = def.options[0]._zod.run;
|
|
2250
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
1707
2251
|
inst._zod.parse = (payload, ctx) => {
|
|
1708
|
-
if (
|
|
2252
|
+
if (first) return first(payload, ctx);
|
|
1709
2253
|
let async = false;
|
|
1710
2254
|
const results = [];
|
|
1711
2255
|
for (const option of def.options) {
|
|
@@ -1761,7 +2305,9 @@ function mergeValues(a, b) {
|
|
|
1761
2305
|
...a,
|
|
1762
2306
|
...b
|
|
1763
2307
|
};
|
|
2308
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
1764
2309
|
for (const key of sharedKeys) {
|
|
2310
|
+
if (key === "__proto__") continue;
|
|
1765
2311
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
1766
2312
|
if (!sharedValue.valid) return {
|
|
1767
2313
|
valid: false,
|
|
@@ -1803,31 +2349,46 @@ function mergeValues(a, b) {
|
|
|
1803
2349
|
function handleIntersectionResults(result, left, right) {
|
|
1804
2350
|
const unrecKeys = /* @__PURE__ */ new Map();
|
|
1805
2351
|
let unrecIssue;
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2352
|
+
const keyIssues = /* @__PURE__ */ new Map();
|
|
2353
|
+
const collect = (iss, side) => {
|
|
2354
|
+
let keys;
|
|
2355
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2356
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
2357
|
+
keys = iss.keys;
|
|
2358
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2359
|
+
const k = String(iss.path[0]);
|
|
2360
|
+
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
2361
|
+
keys = [k];
|
|
2362
|
+
} else return false;
|
|
2363
|
+
for (const k of keys) {
|
|
1809
2364
|
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
1810
|
-
unrecKeys.get(k)
|
|
2365
|
+
unrecKeys.get(k)[side] = true;
|
|
1811
2366
|
}
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
else result.issues.push(iss);
|
|
2367
|
+
return true;
|
|
2368
|
+
};
|
|
2369
|
+
for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
|
|
2370
|
+
for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
|
|
1818
2371
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
1819
|
-
if (bothKeys.length
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
2372
|
+
if (bothKeys.length) {
|
|
2373
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
|
|
2374
|
+
if (aggregated.length) result.issues.push({
|
|
2375
|
+
...unrecIssue,
|
|
2376
|
+
keys: aggregated
|
|
2377
|
+
});
|
|
2378
|
+
for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
|
|
2379
|
+
}
|
|
1824
2380
|
const merged = mergeValues(left.value, right.value);
|
|
1825
|
-
if (!merged.valid)
|
|
2381
|
+
if (!merged.valid) {
|
|
2382
|
+
if (aborted(result)) return result;
|
|
2383
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2384
|
+
}
|
|
1826
2385
|
result.value = merged.data;
|
|
1827
2386
|
return result;
|
|
1828
2387
|
}
|
|
1829
2388
|
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
1830
2389
|
$ZodType.init(inst, def);
|
|
2390
|
+
const memo = globalConfig.memoizer;
|
|
2391
|
+
memo?.attach(inst);
|
|
1831
2392
|
inst._zod.parse = (payload, ctx) => {
|
|
1832
2393
|
const input = payload.value;
|
|
1833
2394
|
if (!isPlainObject(input)) {
|
|
@@ -1841,39 +2402,66 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1841
2402
|
}
|
|
1842
2403
|
const proms = [];
|
|
1843
2404
|
const values = def.keyType._zod.values;
|
|
1844
|
-
if (values) {
|
|
1845
|
-
payload.value = {};
|
|
2405
|
+
if (values && !def.partial) {
|
|
2406
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1846
2407
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
1847
2408
|
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
1848
2409
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2410
|
+
if (key === "__proto__") continue;
|
|
2411
|
+
const keyResult = def.keyType._zod.run({
|
|
2412
|
+
value: key,
|
|
2413
|
+
issues: []
|
|
2414
|
+
}, ctx);
|
|
2415
|
+
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
2416
|
+
if (keyResult.issues.length) {
|
|
2417
|
+
payload.issues.push({
|
|
2418
|
+
code: "invalid_key",
|
|
2419
|
+
origin: "record",
|
|
2420
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
2421
|
+
input: key,
|
|
2422
|
+
path: [key],
|
|
2423
|
+
inst
|
|
2424
|
+
});
|
|
2425
|
+
continue;
|
|
2426
|
+
}
|
|
2427
|
+
const outKey = keyResult.value;
|
|
2428
|
+
if (outKey === "__proto__") continue;
|
|
1849
2429
|
const result = def.valueType._zod.run({
|
|
1850
2430
|
value: input[key],
|
|
1851
2431
|
issues: []
|
|
1852
2432
|
}, ctx);
|
|
1853
2433
|
if (result instanceof Promise) proms.push(result.then((result) => {
|
|
1854
2434
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1855
|
-
payload.value[
|
|
2435
|
+
payload.value[outKey] = result.value;
|
|
1856
2436
|
}));
|
|
1857
2437
|
else {
|
|
1858
2438
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1859
|
-
payload.value[
|
|
2439
|
+
payload.value[outKey] = result.value;
|
|
1860
2440
|
}
|
|
1861
2441
|
}
|
|
1862
2442
|
let unrecognized;
|
|
1863
2443
|
for (const key in input) if (!recordKeys.has(key)) {
|
|
1864
|
-
|
|
1865
|
-
|
|
2444
|
+
if (def.mode === "loose") {
|
|
2445
|
+
if (key === "__proto__") continue;
|
|
2446
|
+
payload.value[key] = input[key];
|
|
2447
|
+
} else {
|
|
2448
|
+
unrecognized = unrecognized ?? [];
|
|
2449
|
+
unrecognized.push(key);
|
|
2450
|
+
}
|
|
1866
2451
|
}
|
|
1867
2452
|
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
1868
2453
|
code: "unrecognized_keys",
|
|
1869
2454
|
input,
|
|
1870
2455
|
inst,
|
|
1871
|
-
keys: unrecognized
|
|
2456
|
+
keys: unrecognized,
|
|
2457
|
+
continue: true
|
|
1872
2458
|
});
|
|
1873
2459
|
} else {
|
|
1874
|
-
payload.value = {};
|
|
2460
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2461
|
+
let unrecognized;
|
|
1875
2462
|
for (const key of Reflect.ownKeys(input)) {
|
|
1876
2463
|
if (key === "__proto__") continue;
|
|
2464
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
1877
2465
|
let keyResult = def.keyType._zod.run({
|
|
1878
2466
|
value: key,
|
|
1879
2467
|
issues: []
|
|
@@ -1889,7 +2477,10 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1889
2477
|
}
|
|
1890
2478
|
if (keyResult.issues.length) {
|
|
1891
2479
|
if (def.mode === "loose") payload.value[key] = input[key];
|
|
1892
|
-
else
|
|
2480
|
+
else if (values) {
|
|
2481
|
+
unrecognized = unrecognized ?? [];
|
|
2482
|
+
unrecognized.push(key);
|
|
2483
|
+
} else payload.issues.push({
|
|
1893
2484
|
code: "invalid_key",
|
|
1894
2485
|
origin: "record",
|
|
1895
2486
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
@@ -1899,19 +2490,28 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
1899
2490
|
});
|
|
1900
2491
|
continue;
|
|
1901
2492
|
}
|
|
2493
|
+
const outKey = keyResult.value;
|
|
2494
|
+
if (outKey === "__proto__") continue;
|
|
1902
2495
|
const result = def.valueType._zod.run({
|
|
1903
2496
|
value: input[key],
|
|
1904
2497
|
issues: []
|
|
1905
2498
|
}, ctx);
|
|
1906
2499
|
if (result instanceof Promise) proms.push(result.then((result) => {
|
|
1907
2500
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1908
|
-
payload.value[
|
|
2501
|
+
payload.value[outKey] = result.value;
|
|
1909
2502
|
}));
|
|
1910
2503
|
else {
|
|
1911
2504
|
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
|
|
1912
|
-
payload.value[
|
|
2505
|
+
payload.value[outKey] = result.value;
|
|
1913
2506
|
}
|
|
1914
2507
|
}
|
|
2508
|
+
if (unrecognized && unrecognized.length > 0) payload.issues.push({
|
|
2509
|
+
code: "unrecognized_keys",
|
|
2510
|
+
input,
|
|
2511
|
+
inst,
|
|
2512
|
+
keys: unrecognized,
|
|
2513
|
+
continue: true
|
|
2514
|
+
});
|
|
1915
2515
|
}
|
|
1916
2516
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1917
2517
|
return payload;
|
|
@@ -1922,7 +2522,10 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1922
2522
|
const values = getEnumValues(def.entries);
|
|
1923
2523
|
const valuesSet = new Set(values);
|
|
1924
2524
|
inst._zod.values = valuesSet;
|
|
1925
|
-
inst
|
|
2525
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2526
|
+
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
2527
|
+
return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
|
|
2528
|
+
});
|
|
1926
2529
|
inst._zod.parse = (payload, _ctx) => {
|
|
1927
2530
|
const input = payload.value;
|
|
1928
2531
|
if (valuesSet.has(input)) return payload;
|
|
@@ -1937,10 +2540,12 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
|
|
|
1937
2540
|
});
|
|
1938
2541
|
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
1939
2542
|
$ZodType.init(inst, def);
|
|
1940
|
-
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
|
|
1941
2543
|
const values = new Set(def.values);
|
|
1942
2544
|
inst._zod.values = values;
|
|
1943
|
-
inst
|
|
2545
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2546
|
+
const vals = zod.def.values;
|
|
2547
|
+
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
2548
|
+
});
|
|
1944
2549
|
inst._zod.parse = (payload, _ctx) => {
|
|
1945
2550
|
const input = payload.value;
|
|
1946
2551
|
if (values.has(input)) return payload;
|
|
@@ -1955,6 +2560,8 @@ const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
1955
2560
|
});
|
|
1956
2561
|
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
|
|
1957
2562
|
$ZodType.init(inst, def);
|
|
2563
|
+
inst._zod.optin = "optional";
|
|
2564
|
+
globalConfig.memoizer?.guard(inst);
|
|
1958
2565
|
inst._zod.parse = (payload, ctx) => {
|
|
1959
2566
|
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
1960
2567
|
const _out = def.transform(payload.value, payload);
|
|
@@ -1967,52 +2574,53 @@ const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) =>
|
|
|
1967
2574
|
return payload;
|
|
1968
2575
|
};
|
|
1969
2576
|
});
|
|
1970
|
-
function handleOptionalResult(
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
value: void 0
|
|
1974
|
-
};
|
|
1975
|
-
return result;
|
|
2577
|
+
function handleOptionalResult(payload, result) {
|
|
2578
|
+
payload.value = result.issues.length ? void 0 : result.value;
|
|
2579
|
+
return payload;
|
|
1976
2580
|
}
|
|
1977
2581
|
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
1978
2582
|
$ZodType.init(inst, def);
|
|
1979
|
-
inst._zod.optin
|
|
2583
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
1980
2584
|
inst._zod.optout = "optional";
|
|
1981
|
-
|
|
1982
|
-
|
|
2585
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2586
|
+
const values = zod.def.innerType._zod.values;
|
|
2587
|
+
return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
|
|
1983
2588
|
});
|
|
1984
|
-
|
|
1985
|
-
const pattern = def.innerType._zod.pattern;
|
|
2589
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2590
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
1986
2591
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
1987
2592
|
});
|
|
1988
2593
|
inst._zod.parse = (payload, ctx) => {
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2594
|
+
if (payload.value === void 0) {
|
|
2595
|
+
if (def.innerType._zod.optin !== "defaulted") return payload;
|
|
2596
|
+
const result = def.innerType._zod.run({
|
|
2597
|
+
value: payload.value,
|
|
2598
|
+
issues: []
|
|
2599
|
+
}, ctx);
|
|
2600
|
+
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
2601
|
+
return handleOptionalResult(payload, result);
|
|
1993
2602
|
}
|
|
1994
|
-
if (payload.value === void 0) return payload;
|
|
1995
2603
|
return def.innerType._zod.run(payload, ctx);
|
|
1996
2604
|
};
|
|
1997
2605
|
});
|
|
1998
2606
|
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
|
|
1999
2607
|
$ZodOptional.init(inst, def);
|
|
2000
|
-
|
|
2001
|
-
|
|
2608
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2609
|
+
defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
2002
2610
|
inst._zod.parse = (payload, ctx) => {
|
|
2003
2611
|
return def.innerType._zod.run(payload, ctx);
|
|
2004
2612
|
};
|
|
2005
2613
|
});
|
|
2006
2614
|
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
2007
2615
|
$ZodType.init(inst, def);
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
const pattern = def.innerType._zod.pattern;
|
|
2616
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
2617
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2618
|
+
defineLazyInternal(inst, "pattern", (zod) => {
|
|
2619
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
2012
2620
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2013
2621
|
});
|
|
2014
|
-
|
|
2015
|
-
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2622
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2623
|
+
return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
|
|
2016
2624
|
});
|
|
2017
2625
|
inst._zod.parse = (payload, ctx) => {
|
|
2018
2626
|
if (payload.value === null) return payload;
|
|
@@ -2021,8 +2629,8 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
|
2021
2629
|
});
|
|
2022
2630
|
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
|
|
2023
2631
|
$ZodType.init(inst, def);
|
|
2024
|
-
inst._zod.optin = "
|
|
2025
|
-
|
|
2632
|
+
inst._zod.optin = "defaulted";
|
|
2633
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2026
2634
|
inst._zod.parse = (payload, ctx) => {
|
|
2027
2635
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2028
2636
|
if (payload.value === void 0) {
|
|
@@ -2043,8 +2651,8 @@ function handleDefaultResult(payload, def) {
|
|
|
2043
2651
|
}
|
|
2044
2652
|
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
2045
2653
|
$ZodType.init(inst, def);
|
|
2046
|
-
inst._zod.optin = "
|
|
2047
|
-
|
|
2654
|
+
inst._zod.optin = "defaulted";
|
|
2655
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2048
2656
|
inst._zod.parse = (payload, ctx) => {
|
|
2049
2657
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2050
2658
|
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
@@ -2053,8 +2661,8 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
|
|
|
2053
2661
|
});
|
|
2054
2662
|
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2055
2663
|
$ZodType.init(inst, def);
|
|
2056
|
-
|
|
2057
|
-
const v = def.innerType._zod.values;
|
|
2664
|
+
defineLazyInternal(inst, "values", (zod) => {
|
|
2665
|
+
const v = zod.def.innerType._zod.values;
|
|
2058
2666
|
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
|
|
2059
2667
|
});
|
|
2060
2668
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2072,44 +2680,41 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
2072
2680
|
});
|
|
2073
2681
|
return payload;
|
|
2074
2682
|
}
|
|
2683
|
+
function handleCatchResult(payload, result, def, ctx) {
|
|
2684
|
+
if (!result.issues.length) {
|
|
2685
|
+
payload.value = result.value;
|
|
2686
|
+
if (result.memo) payload.memo = true;
|
|
2687
|
+
return payload;
|
|
2688
|
+
}
|
|
2689
|
+
payload.value = def.catchValue({
|
|
2690
|
+
...result,
|
|
2691
|
+
value: payload.value,
|
|
2692
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2693
|
+
input: payload.value
|
|
2694
|
+
});
|
|
2695
|
+
return payload;
|
|
2696
|
+
}
|
|
2075
2697
|
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
|
|
2076
2698
|
$ZodType.init(inst, def);
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2699
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
2700
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
2701
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2080
2702
|
inst._zod.parse = (payload, ctx) => {
|
|
2081
2703
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2082
|
-
const result = def.innerType._zod.run(
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2089
|
-
input: payload.value
|
|
2090
|
-
});
|
|
2091
|
-
payload.issues = [];
|
|
2092
|
-
}
|
|
2093
|
-
return payload;
|
|
2094
|
-
});
|
|
2095
|
-
payload.value = result.value;
|
|
2096
|
-
if (result.issues.length) {
|
|
2097
|
-
payload.value = def.catchValue({
|
|
2098
|
-
...payload,
|
|
2099
|
-
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2100
|
-
input: payload.value
|
|
2101
|
-
});
|
|
2102
|
-
payload.issues = [];
|
|
2103
|
-
}
|
|
2104
|
-
return payload;
|
|
2704
|
+
const result = def.innerType._zod.run({
|
|
2705
|
+
value: payload.value,
|
|
2706
|
+
issues: []
|
|
2707
|
+
}, ctx);
|
|
2708
|
+
if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
2709
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
2105
2710
|
};
|
|
2106
2711
|
});
|
|
2107
2712
|
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
2108
2713
|
$ZodType.init(inst, def);
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2714
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
2715
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
2716
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
2717
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
2113
2718
|
inst._zod.parse = (payload, ctx) => {
|
|
2114
2719
|
if (ctx.direction === "backward") {
|
|
2115
2720
|
const right = def.out._zod.run(payload, ctx);
|
|
@@ -2122,7 +2727,7 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
|
|
|
2122
2727
|
};
|
|
2123
2728
|
});
|
|
2124
2729
|
function handlePipeResult(left, next, ctx) {
|
|
2125
|
-
if (left.issues.
|
|
2730
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
2126
2731
|
left.aborted = true;
|
|
2127
2732
|
return left;
|
|
2128
2733
|
}
|
|
@@ -2133,10 +2738,10 @@ function handlePipeResult(left, next, ctx) {
|
|
|
2133
2738
|
}
|
|
2134
2739
|
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
2135
2740
|
$ZodType.init(inst, def);
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2741
|
+
defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
2742
|
+
defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
2743
|
+
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
2744
|
+
defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
2140
2745
|
inst._zod.parse = (payload, ctx) => {
|
|
2141
2746
|
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
2142
2747
|
const result = def.innerType._zod.run(payload, ctx);
|
|
@@ -2145,7 +2750,7 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
|
|
|
2145
2750
|
};
|
|
2146
2751
|
});
|
|
2147
2752
|
function handleReadonlyResult(payload) {
|
|
2148
|
-
payload.value = Object.freeze(payload.value);
|
|
2753
|
+
if (!payload.memo) payload.value = Object.freeze(payload.value);
|
|
2149
2754
|
return payload;
|
|
2150
2755
|
}
|
|
2151
2756
|
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
|
|
@@ -2175,7 +2780,368 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
2175
2780
|
}
|
|
2176
2781
|
}
|
|
2177
2782
|
//#endregion
|
|
2178
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
2783
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js
|
|
2784
|
+
var $ZodCyclicError = class extends Error {
|
|
2785
|
+
constructor() {
|
|
2786
|
+
super(`Cannot parse a reference cycle that closes through a transform`);
|
|
2787
|
+
this.name = "ZodCyclicError";
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
/** Keyed off the context object every schema in one parse call already shares. */
|
|
2791
|
+
const STATE = "~memo";
|
|
2792
|
+
const NO_ISSUES = [];
|
|
2793
|
+
function isRef(value) {
|
|
2794
|
+
return value !== null && typeof value === "object";
|
|
2795
|
+
}
|
|
2796
|
+
function cloneIssues(issues) {
|
|
2797
|
+
return issues.map((iss) => iss.path ? {
|
|
2798
|
+
...iss,
|
|
2799
|
+
path: iss.path.slice()
|
|
2800
|
+
} : { ...iss });
|
|
2801
|
+
}
|
|
2802
|
+
const recursive = /*@__PURE__*/ new WeakMap();
|
|
2803
|
+
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
|
|
2804
|
+
const NONE = 0;
|
|
2805
|
+
const ASSUMED = 1;
|
|
2806
|
+
const PROVEN = 2;
|
|
2807
|
+
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
|
|
2808
|
+
function isRecursive(inst, stack, resolve) {
|
|
2809
|
+
const cached = recursive.get(inst);
|
|
2810
|
+
if (cached !== void 0) return cached ? PROVEN : NONE;
|
|
2811
|
+
if (stack.has(inst)) return PROVEN;
|
|
2812
|
+
stack.add(inst);
|
|
2813
|
+
let result = NONE;
|
|
2814
|
+
const check = (child) => {
|
|
2815
|
+
if (result !== PROVEN && child?._zod) {
|
|
2816
|
+
const answer = isRecursive(child, stack, resolve);
|
|
2817
|
+
if (answer > result) result = answer;
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
const shape = (sh, spread) => {
|
|
2821
|
+
let answer = NONE;
|
|
2822
|
+
for (const key of Reflect.ownKeys(sh)) {
|
|
2823
|
+
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
2824
|
+
if (spread && !desc.enumerable) continue;
|
|
2825
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
|
|
2826
|
+
if (child > answer) answer = child;
|
|
2827
|
+
}
|
|
2828
|
+
return answer;
|
|
2829
|
+
};
|
|
2830
|
+
const merge = (answer) => {
|
|
2831
|
+
if (answer > result) result = answer;
|
|
2832
|
+
};
|
|
2833
|
+
const def = inst._zod.def;
|
|
2834
|
+
switch (def.type) {
|
|
2835
|
+
case "object": {
|
|
2836
|
+
const raw = rawShape(def);
|
|
2837
|
+
merge(raw ? shape(raw, true) : ASSUMED);
|
|
2838
|
+
check(def.catchall);
|
|
2839
|
+
break;
|
|
2840
|
+
}
|
|
2841
|
+
case "array":
|
|
2842
|
+
check(def.element);
|
|
2843
|
+
break;
|
|
2844
|
+
case "tuple":
|
|
2845
|
+
for (const el of def.items) check(el);
|
|
2846
|
+
check(def.rest);
|
|
2847
|
+
break;
|
|
2848
|
+
case "record":
|
|
2849
|
+
case "map":
|
|
2850
|
+
check(def.keyType);
|
|
2851
|
+
check(def.valueType);
|
|
2852
|
+
break;
|
|
2853
|
+
case "set":
|
|
2854
|
+
check(def.valueType);
|
|
2855
|
+
break;
|
|
2856
|
+
case "union":
|
|
2857
|
+
for (const el of def.options) check(el);
|
|
2858
|
+
break;
|
|
2859
|
+
case "intersection":
|
|
2860
|
+
check(def.left);
|
|
2861
|
+
check(def.right);
|
|
2862
|
+
break;
|
|
2863
|
+
case "optional":
|
|
2864
|
+
case "nullable":
|
|
2865
|
+
case "default":
|
|
2866
|
+
case "prefault":
|
|
2867
|
+
case "catch":
|
|
2868
|
+
case "readonly":
|
|
2869
|
+
case "nonoptional":
|
|
2870
|
+
case "promise":
|
|
2871
|
+
case "success":
|
|
2872
|
+
check(def.innerType);
|
|
2873
|
+
break;
|
|
2874
|
+
case "pipe":
|
|
2875
|
+
check(def.in);
|
|
2876
|
+
check(def.out);
|
|
2877
|
+
break;
|
|
2878
|
+
case "function":
|
|
2879
|
+
check(def.input);
|
|
2880
|
+
check(def.output);
|
|
2881
|
+
break;
|
|
2882
|
+
case "lazy": {
|
|
2883
|
+
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
2884
|
+
merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
2885
|
+
break;
|
|
2886
|
+
}
|
|
2887
|
+
case "template_literal":
|
|
2888
|
+
case "string":
|
|
2889
|
+
case "number":
|
|
2890
|
+
case "int":
|
|
2891
|
+
case "boolean":
|
|
2892
|
+
case "bigint":
|
|
2893
|
+
case "symbol":
|
|
2894
|
+
case "undefined":
|
|
2895
|
+
case "null":
|
|
2896
|
+
case "void":
|
|
2897
|
+
case "never":
|
|
2898
|
+
case "any":
|
|
2899
|
+
case "unknown":
|
|
2900
|
+
case "date":
|
|
2901
|
+
case "nan":
|
|
2902
|
+
case "enum":
|
|
2903
|
+
case "literal":
|
|
2904
|
+
case "file":
|
|
2905
|
+
case "transform":
|
|
2906
|
+
case "custom": break;
|
|
2907
|
+
default: for (const key in def) {
|
|
2908
|
+
const desc = Object.getOwnPropertyDescriptor(def, key);
|
|
2909
|
+
if (!desc || desc.get) continue;
|
|
2910
|
+
const value = desc.value;
|
|
2911
|
+
if (!value || typeof value !== "object") continue;
|
|
2912
|
+
if (value._zod) check(value);
|
|
2913
|
+
else if (Array.isArray(value)) for (const el of value) check(el);
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
stack.delete(inst);
|
|
2917
|
+
return settle(inst, result);
|
|
2918
|
+
}
|
|
2919
|
+
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
|
|
2920
|
+
function settle(inst, answer) {
|
|
2921
|
+
if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
|
|
2922
|
+
return answer;
|
|
2923
|
+
}
|
|
2924
|
+
function bucketFor(state, inst) {
|
|
2925
|
+
let bucket = state.buckets.get(inst);
|
|
2926
|
+
if (!bucket) {
|
|
2927
|
+
bucket = /* @__PURE__ */ new WeakMap();
|
|
2928
|
+
state.buckets.set(inst, bucket);
|
|
2929
|
+
}
|
|
2930
|
+
return bucket;
|
|
2931
|
+
}
|
|
2932
|
+
let handoff;
|
|
2933
|
+
const open = [];
|
|
2934
|
+
const memo = {
|
|
2935
|
+
alloc(_inst, payload, empty) {
|
|
2936
|
+
const bucket = handoff;
|
|
2937
|
+
if (!bucket) return empty;
|
|
2938
|
+
handoff = void 0;
|
|
2939
|
+
const entry = {
|
|
2940
|
+
value: empty,
|
|
2941
|
+
issues: null
|
|
2942
|
+
};
|
|
2943
|
+
bucket.set(payload.value, entry);
|
|
2944
|
+
open.push(entry);
|
|
2945
|
+
return empty;
|
|
2946
|
+
},
|
|
2947
|
+
guard(inst) {
|
|
2948
|
+
var _a;
|
|
2949
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2950
|
+
inst._zod.deferred.push(() => {
|
|
2951
|
+
const base = inst._zod.parse;
|
|
2952
|
+
const wrapped = (payload, ctx) => {
|
|
2953
|
+
if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
|
|
2954
|
+
return base(payload, ctx);
|
|
2955
|
+
};
|
|
2956
|
+
inst._zod.parse = wrapped;
|
|
2957
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
2958
|
+
});
|
|
2959
|
+
},
|
|
2960
|
+
attach(inst) {
|
|
2961
|
+
var _a;
|
|
2962
|
+
let isRecursiveInst;
|
|
2963
|
+
let rechecked = false;
|
|
2964
|
+
let lastCtx;
|
|
2965
|
+
let lastBucket;
|
|
2966
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
2967
|
+
inst._zod.deferred.push(() => {
|
|
2968
|
+
const base = inst._zod.parse;
|
|
2969
|
+
const wrapped = (payload, ctx) => {
|
|
2970
|
+
if (isRecursiveInst === void 0) {
|
|
2971
|
+
const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
|
|
2972
|
+
if (walked === NONE) {
|
|
2973
|
+
inst._zod.parse = base;
|
|
2974
|
+
if (inst._zod.run === wrapped) inst._zod.run = base;
|
|
2975
|
+
return base(payload, ctx);
|
|
2976
|
+
}
|
|
2977
|
+
if (walked === PROVEN || rechecked) isRecursiveInst = true;
|
|
2978
|
+
else rechecked = true;
|
|
2979
|
+
}
|
|
2980
|
+
const input = payload.value;
|
|
2981
|
+
if (!isRef(input)) return base(payload, ctx);
|
|
2982
|
+
let state = ctx[STATE];
|
|
2983
|
+
if (!state) {
|
|
2984
|
+
state = {
|
|
2985
|
+
buckets: /* @__PURE__ */ new WeakMap(),
|
|
2986
|
+
backEdges: void 0
|
|
2987
|
+
};
|
|
2988
|
+
ctx[STATE] = state;
|
|
2989
|
+
}
|
|
2990
|
+
let bucket;
|
|
2991
|
+
if (lastCtx === ctx) bucket = lastBucket;
|
|
2992
|
+
else {
|
|
2993
|
+
bucket = bucketFor(state, inst);
|
|
2994
|
+
lastCtx = ctx;
|
|
2995
|
+
lastBucket = bucket;
|
|
2996
|
+
}
|
|
2997
|
+
const hit = bucket.get(input);
|
|
2998
|
+
if (hit) {
|
|
2999
|
+
payload.value = hit.value;
|
|
3000
|
+
if (hit.issues) {
|
|
3001
|
+
if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
|
|
3002
|
+
} else {
|
|
3003
|
+
payload.memo = true;
|
|
3004
|
+
state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
|
|
3005
|
+
state.backEdges.add(hit.value);
|
|
3006
|
+
}
|
|
3007
|
+
return payload;
|
|
3008
|
+
}
|
|
3009
|
+
handoff = bucket;
|
|
3010
|
+
const depth = open.length;
|
|
3011
|
+
const result = base(payload, ctx);
|
|
3012
|
+
handoff = void 0;
|
|
3013
|
+
const entry = open.length > depth ? open.pop() : void 0;
|
|
3014
|
+
if (result instanceof Promise) return result.then((r) => {
|
|
3015
|
+
if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
|
|
3016
|
+
return r;
|
|
3017
|
+
});
|
|
3018
|
+
if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
|
|
3019
|
+
return result;
|
|
3020
|
+
};
|
|
3021
|
+
inst._zod.parse = wrapped;
|
|
3022
|
+
if (inst._zod.run === base) inst._zod.run = wrapped;
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
};
|
|
3026
|
+
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
|
|
3027
|
+
function memoizer() {
|
|
3028
|
+
return memo;
|
|
3029
|
+
}
|
|
3030
|
+
/** Whether this value is a node a back-edge resolved to before it finished. */
|
|
3031
|
+
function isBackEdge(ctx, value) {
|
|
3032
|
+
const backEdges = ctx[STATE]?.backEdges;
|
|
3033
|
+
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
3034
|
+
}
|
|
3035
|
+
//#endregion
|
|
3036
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/en.js
|
|
3037
|
+
const error = () => {
|
|
3038
|
+
const Sizable = {
|
|
3039
|
+
string: {
|
|
3040
|
+
unit: "characters",
|
|
3041
|
+
verb: "to have"
|
|
3042
|
+
},
|
|
3043
|
+
file: {
|
|
3044
|
+
unit: "bytes",
|
|
3045
|
+
verb: "to have"
|
|
3046
|
+
},
|
|
3047
|
+
array: {
|
|
3048
|
+
unit: "items",
|
|
3049
|
+
verb: "to have"
|
|
3050
|
+
},
|
|
3051
|
+
set: {
|
|
3052
|
+
unit: "items",
|
|
3053
|
+
verb: "to have"
|
|
3054
|
+
},
|
|
3055
|
+
map: {
|
|
3056
|
+
unit: "entries",
|
|
3057
|
+
verb: "to have"
|
|
3058
|
+
}
|
|
3059
|
+
};
|
|
3060
|
+
function getSizing(origin) {
|
|
3061
|
+
return Sizable[origin] ?? null;
|
|
3062
|
+
}
|
|
3063
|
+
const FormatDictionary = {
|
|
3064
|
+
regex: "input",
|
|
3065
|
+
email: "email address",
|
|
3066
|
+
url: "URL",
|
|
3067
|
+
emoji: "emoji",
|
|
3068
|
+
uuid: "UUID",
|
|
3069
|
+
uuidv4: "UUIDv4",
|
|
3070
|
+
uuidv6: "UUIDv6",
|
|
3071
|
+
nanoid: "nanoid",
|
|
3072
|
+
guid: "GUID",
|
|
3073
|
+
cuid: "cuid",
|
|
3074
|
+
cuid2: "cuid2",
|
|
3075
|
+
ulid: "ULID",
|
|
3076
|
+
xid: "XID",
|
|
3077
|
+
ksuid: "KSUID",
|
|
3078
|
+
datetime: "ISO datetime",
|
|
3079
|
+
date: "ISO date",
|
|
3080
|
+
time: "ISO time",
|
|
3081
|
+
duration: "ISO duration",
|
|
3082
|
+
ipv4: "IPv4 address",
|
|
3083
|
+
ipv6: "IPv6 address",
|
|
3084
|
+
mac: "MAC address",
|
|
3085
|
+
cidrv4: "IPv4 range",
|
|
3086
|
+
cidrv6: "IPv6 range",
|
|
3087
|
+
base64: "base64-encoded string",
|
|
3088
|
+
base64url: "base64url-encoded string",
|
|
3089
|
+
json_string: "JSON string",
|
|
3090
|
+
e164: "E.164 number",
|
|
3091
|
+
currency_code: "currency code",
|
|
3092
|
+
credit_card: "credit card number",
|
|
3093
|
+
iban: "IBAN",
|
|
3094
|
+
jwt: "JWT",
|
|
3095
|
+
template_literal: "input"
|
|
3096
|
+
};
|
|
3097
|
+
const TypeDictionary = { nan: "NaN" };
|
|
3098
|
+
function getTypeName(type, input) {
|
|
3099
|
+
if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
|
|
3100
|
+
return TypeDictionary[type] ?? type;
|
|
3101
|
+
}
|
|
3102
|
+
return (issue) => {
|
|
3103
|
+
switch (issue.code) {
|
|
3104
|
+
case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
|
|
3105
|
+
case "invalid_value":
|
|
3106
|
+
if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
3107
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
3108
|
+
case "too_big": {
|
|
3109
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
|
|
3110
|
+
const sizing = getSizing(issue.origin);
|
|
3111
|
+
if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
3112
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
3113
|
+
}
|
|
3114
|
+
case "too_small": {
|
|
3115
|
+
const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
|
|
3116
|
+
const sizing = getSizing(issue.origin);
|
|
3117
|
+
if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
3118
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
3119
|
+
}
|
|
3120
|
+
case "invalid_format": {
|
|
3121
|
+
const _issue = issue;
|
|
3122
|
+
if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
|
|
3123
|
+
if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
|
|
3124
|
+
if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
|
|
3125
|
+
if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
3126
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
3127
|
+
}
|
|
3128
|
+
case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
3129
|
+
case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
3130
|
+
case "invalid_key": return `Invalid key in ${issue.origin}`;
|
|
3131
|
+
case "invalid_union":
|
|
3132
|
+
if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
|
|
3133
|
+
if (issue.inclusive === false) return "Invalid input: more than one option matched";
|
|
3134
|
+
return "Invalid input";
|
|
3135
|
+
case "invalid_element": return `Invalid value in ${issue.origin}`;
|
|
3136
|
+
default: return `Invalid input`;
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
};
|
|
3140
|
+
function en_default() {
|
|
3141
|
+
return { localeError: error() };
|
|
3142
|
+
}
|
|
3143
|
+
//#endregion
|
|
3144
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/registries.js
|
|
2179
3145
|
var _a;
|
|
2180
3146
|
var $ZodRegistry = class {
|
|
2181
3147
|
constructor() {
|
|
@@ -2222,13 +3188,17 @@ function registry() {
|
|
|
2222
3188
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2223
3189
|
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2224
3190
|
//#endregion
|
|
2225
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
3191
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/api.js
|
|
3192
|
+
function snapshotChecks(def) {
|
|
3193
|
+
if (def.checks) def.checks = [...def.checks];
|
|
3194
|
+
return def;
|
|
3195
|
+
}
|
|
2226
3196
|
// @__NO_SIDE_EFFECTS__
|
|
2227
3197
|
function _string(Class, params) {
|
|
2228
|
-
return new Class({
|
|
3198
|
+
return new Class(snapshotChecks({
|
|
2229
3199
|
type: "string",
|
|
2230
3200
|
...normalizeParams(params)
|
|
2231
|
-
});
|
|
3201
|
+
}));
|
|
2232
3202
|
}
|
|
2233
3203
|
// @__NO_SIDE_EFFECTS__
|
|
2234
3204
|
function _email(Class, params) {
|
|
@@ -2323,6 +3293,11 @@ function _nanoid(Class, params) {
|
|
|
2323
3293
|
...normalizeParams(params)
|
|
2324
3294
|
});
|
|
2325
3295
|
}
|
|
3296
|
+
/**
|
|
3297
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
3298
|
+
* (timestamps embedded in the id). Use {@link _cuid2} instead.
|
|
3299
|
+
* See https://github.com/paralleldrive/cuid.
|
|
3300
|
+
*/
|
|
2326
3301
|
// @__NO_SIDE_EFFECTS__
|
|
2327
3302
|
function _cuid(Class, params) {
|
|
2328
3303
|
return new Class({
|
|
@@ -2495,11 +3470,11 @@ function _isoDuration(Class, params) {
|
|
|
2495
3470
|
}
|
|
2496
3471
|
// @__NO_SIDE_EFFECTS__
|
|
2497
3472
|
function _number(Class, params) {
|
|
2498
|
-
return new Class({
|
|
3473
|
+
return new Class(snapshotChecks({
|
|
2499
3474
|
type: "number",
|
|
2500
3475
|
checks: [],
|
|
2501
3476
|
...normalizeParams(params)
|
|
2502
|
-
});
|
|
3477
|
+
}));
|
|
2503
3478
|
}
|
|
2504
3479
|
// @__NO_SIDE_EFFECTS__
|
|
2505
3480
|
function _int(Class, params) {
|
|
@@ -2694,7 +3669,7 @@ function _refine(Class, fn, _params) {
|
|
|
2694
3669
|
});
|
|
2695
3670
|
}
|
|
2696
3671
|
// @__NO_SIDE_EFFECTS__
|
|
2697
|
-
function _superRefine(fn) {
|
|
3672
|
+
function _superRefine(fn, params) {
|
|
2698
3673
|
const ch = /* @__PURE__ */ _check((payload) => {
|
|
2699
3674
|
payload.addIssue = (issue$2) => {
|
|
2700
3675
|
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
@@ -2702,14 +3677,14 @@ function _superRefine(fn) {
|
|
|
2702
3677
|
const _issue = issue$2;
|
|
2703
3678
|
if (_issue.fatal) _issue.continue = false;
|
|
2704
3679
|
_issue.code ?? (_issue.code = "custom");
|
|
2705
|
-
|
|
3680
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
2706
3681
|
_issue.inst ?? (_issue.inst = ch);
|
|
2707
3682
|
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
2708
3683
|
payload.issues.push(issue(_issue));
|
|
2709
3684
|
}
|
|
2710
3685
|
};
|
|
2711
3686
|
return fn(payload.value, payload);
|
|
2712
|
-
});
|
|
3687
|
+
}, params);
|
|
2713
3688
|
return ch;
|
|
2714
3689
|
}
|
|
2715
3690
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -2722,7 +3697,11 @@ function _check(fn, params) {
|
|
|
2722
3697
|
return ch;
|
|
2723
3698
|
}
|
|
2724
3699
|
//#endregion
|
|
2725
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
3700
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/to-json-schema.js
|
|
3701
|
+
function assignProps(target, ...sources) {
|
|
3702
|
+
for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
|
|
3703
|
+
return target;
|
|
3704
|
+
}
|
|
2726
3705
|
function initializeContext(params) {
|
|
2727
3706
|
let target = params?.target ?? "draft-2020-12";
|
|
2728
3707
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -2736,12 +3715,32 @@ function initializeContext(params) {
|
|
|
2736
3715
|
io: params?.io ?? "output",
|
|
2737
3716
|
counter: 0,
|
|
2738
3717
|
seen: /* @__PURE__ */ new Map(),
|
|
3718
|
+
sharedDefsExtractedFor: void 0,
|
|
3719
|
+
sharedEmitDoneFor: void 0,
|
|
2739
3720
|
cycles: params?.cycles ?? "ref",
|
|
2740
3721
|
reused: params?.reused ?? "inline",
|
|
3722
|
+
intersections: [],
|
|
3723
|
+
deferred: [],
|
|
2741
3724
|
external: params?.external ?? void 0
|
|
2742
3725
|
};
|
|
2743
3726
|
}
|
|
2744
|
-
|
|
3727
|
+
/**
|
|
3728
|
+
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
|
|
3729
|
+
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
|
|
3730
|
+
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
|
|
3731
|
+
*/
|
|
3732
|
+
function handleUnrepresentable(schema, ctx, json, params, message) {
|
|
3733
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
|
|
3734
|
+
zodSchema: schema,
|
|
3735
|
+
path: params.path,
|
|
3736
|
+
message
|
|
3737
|
+
}) : ctx.unrepresentable;
|
|
3738
|
+
if (result === "any") return false;
|
|
3739
|
+
if (result === void 0 || result === "throw") throw new Error(message);
|
|
3740
|
+
Object.assign(json, result);
|
|
3741
|
+
return true;
|
|
3742
|
+
}
|
|
3743
|
+
function processSchema(schema, ctx, _params = {
|
|
2745
3744
|
path: [],
|
|
2746
3745
|
schemaPath: []
|
|
2747
3746
|
}) {
|
|
@@ -2760,6 +3759,8 @@ function process(schema, ctx, _params = {
|
|
|
2760
3759
|
path: _params.path
|
|
2761
3760
|
};
|
|
2762
3761
|
ctx.seen.set(schema, result);
|
|
3762
|
+
ctx.sharedDefsExtractedFor = void 0;
|
|
3763
|
+
ctx.sharedEmitDoneFor = void 0;
|
|
2763
3764
|
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
2764
3765
|
if (overrideSchema) result.schema = overrideSchema;
|
|
2765
3766
|
else {
|
|
@@ -2778,23 +3779,27 @@ function process(schema, ctx, _params = {
|
|
|
2778
3779
|
const parent = schema._zod.parent;
|
|
2779
3780
|
if (parent) {
|
|
2780
3781
|
if (!result.ref) result.ref = parent;
|
|
2781
|
-
|
|
3782
|
+
processSchema(parent, ctx, params);
|
|
2782
3783
|
ctx.seen.get(parent).isParent = true;
|
|
2783
3784
|
}
|
|
2784
3785
|
}
|
|
2785
3786
|
const meta = ctx.metadataRegistry.get(schema);
|
|
2786
|
-
if (meta)
|
|
3787
|
+
if (meta) assignProps(result.schema, meta);
|
|
2787
3788
|
if (ctx.io === "input" && isTransforming(schema)) {
|
|
2788
3789
|
delete result.schema.examples;
|
|
2789
3790
|
delete result.schema.default;
|
|
2790
3791
|
}
|
|
2791
|
-
if (ctx.io === "input" && result.schema
|
|
3792
|
+
if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
2792
3793
|
delete result.schema._prefault;
|
|
2793
3794
|
return ctx.seen.get(schema).schema;
|
|
2794
3795
|
}
|
|
3796
|
+
function encodeJSONPointerSegment(segment) {
|
|
3797
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3798
|
+
}
|
|
2795
3799
|
function extractDefs(ctx, schema) {
|
|
2796
3800
|
const root = ctx.seen.get(schema);
|
|
2797
3801
|
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3802
|
+
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
|
|
2798
3803
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
2799
3804
|
for (const entry of ctx.seen.entries()) {
|
|
2800
3805
|
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
@@ -2814,15 +3819,16 @@ function extractDefs(ctx, schema) {
|
|
|
2814
3819
|
entry[1].defId = id;
|
|
2815
3820
|
return {
|
|
2816
3821
|
defId: id,
|
|
2817
|
-
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
3822
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
|
|
2818
3823
|
};
|
|
2819
3824
|
}
|
|
2820
|
-
|
|
2821
|
-
const defUriPrefix =
|
|
3825
|
+
const uriPrefix = `#`;
|
|
3826
|
+
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
3827
|
+
if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
|
|
2822
3828
|
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
2823
3829
|
return {
|
|
2824
3830
|
defId,
|
|
2825
|
-
ref: defUriPrefix + defId
|
|
3831
|
+
ref: defUriPrefix + encodeJSONPointerSegment(defId)
|
|
2826
3832
|
};
|
|
2827
3833
|
};
|
|
2828
3834
|
const extractToDef = (entry) => {
|
|
@@ -2863,12 +3869,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
2863
3869
|
continue;
|
|
2864
3870
|
}
|
|
2865
3871
|
if (seen.count > 1) {
|
|
2866
|
-
if (ctx.reused === "ref")
|
|
2867
|
-
|
|
2868
|
-
|
|
3872
|
+
if (ctx.reused === "ref") extractToDef(entry);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
|
|
3876
|
+
}
|
|
3877
|
+
/** 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. */
|
|
3878
|
+
function compactTypeUnion(schema) {
|
|
3879
|
+
const options = schema.anyOf;
|
|
3880
|
+
if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
|
|
3881
|
+
const types = [];
|
|
3882
|
+
for (const option of options) {
|
|
3883
|
+
if (!option || typeof option !== "object") return;
|
|
3884
|
+
compactTypeUnion(option);
|
|
3885
|
+
const keys = Object.keys(option);
|
|
3886
|
+
if (keys.length !== 1 || keys[0] !== "type") return;
|
|
3887
|
+
const type = option.type;
|
|
3888
|
+
for (const member of Array.isArray(type) ? type : [type]) {
|
|
3889
|
+
if (typeof member !== "string") return;
|
|
3890
|
+
if (!types.includes(member)) types.push(member);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
delete schema.anyOf;
|
|
3894
|
+
schema.type = types.length === 1 ? types[0] : types;
|
|
3895
|
+
}
|
|
3896
|
+
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
|
|
3897
|
+
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
|
|
3898
|
+
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
|
|
3899
|
+
const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
|
|
3900
|
+
"type",
|
|
3901
|
+
"properties",
|
|
3902
|
+
"required",
|
|
3903
|
+
"additionalProperties"
|
|
3904
|
+
]);
|
|
3905
|
+
const UNION_KEYS = ["oneOf", "anyOf"];
|
|
3906
|
+
/** 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. */
|
|
3907
|
+
function undeclaredConstraint(member) {
|
|
3908
|
+
const extra = member.additionalProperties;
|
|
3909
|
+
if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
|
|
3910
|
+
return Object.keys(extra).length ? extra : null;
|
|
3911
|
+
}
|
|
3912
|
+
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
|
|
3913
|
+
function foldObjects(members) {
|
|
3914
|
+
const objects = [];
|
|
3915
|
+
for (const member of members) {
|
|
3916
|
+
if (typeof member !== "object" || member.type !== "object") return null;
|
|
3917
|
+
for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
|
|
3918
|
+
objects.push(member);
|
|
3919
|
+
}
|
|
3920
|
+
const properties = {};
|
|
3921
|
+
const required = /* @__PURE__ */ new Set();
|
|
3922
|
+
for (const object of objects) {
|
|
3923
|
+
for (const key in object.properties) {
|
|
3924
|
+
if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
|
|
3925
|
+
const parts = [];
|
|
3926
|
+
for (const other of objects) {
|
|
3927
|
+
const part = other.properties?.[key] ?? undeclaredConstraint(other);
|
|
3928
|
+
if (part === null || part === void 0) continue;
|
|
3929
|
+
if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
|
|
2869
3930
|
}
|
|
3931
|
+
assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
|
|
3932
|
+
}
|
|
3933
|
+
for (const key of object.required ?? []) required.add(key);
|
|
3934
|
+
}
|
|
3935
|
+
const folded = {
|
|
3936
|
+
type: "object",
|
|
3937
|
+
properties
|
|
3938
|
+
};
|
|
3939
|
+
if (required.size) folded.required = [...required];
|
|
3940
|
+
if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
|
|
3941
|
+
else {
|
|
3942
|
+
const constraints = [];
|
|
3943
|
+
for (const object of objects) {
|
|
3944
|
+
const constraint = undeclaredConstraint(object);
|
|
3945
|
+
if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
|
|
2870
3946
|
}
|
|
3947
|
+
if (constraints.length === 1) folded.additionalProperties = constraints[0];
|
|
3948
|
+
else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
|
|
3949
|
+
}
|
|
3950
|
+
return folded;
|
|
3951
|
+
}
|
|
3952
|
+
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
|
|
3953
|
+
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
|
|
3954
|
+
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
|
|
3955
|
+
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
|
|
3956
|
+
* into one object is the encoding that says so on every target.
|
|
3957
|
+
*
|
|
3958
|
+
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
|
|
3959
|
+
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
|
|
3960
|
+
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
|
|
3961
|
+
function foldIntersection(json) {
|
|
3962
|
+
const allOf = json.allOf;
|
|
3963
|
+
if (!Array.isArray(allOf) || allOf.length < 2) return;
|
|
3964
|
+
for (const key of FOLDABLE_KEYS) if (key in json) return;
|
|
3965
|
+
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
3966
|
+
let folded = null;
|
|
3967
|
+
if (!unions.length) folded = foldObjects(allOf);
|
|
3968
|
+
else {
|
|
3969
|
+
const union = unions[0];
|
|
3970
|
+
const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
|
|
3971
|
+
if (Object.keys(union).length !== 1) return;
|
|
3972
|
+
const rest = allOf.filter((m) => m !== union);
|
|
3973
|
+
const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
|
|
3974
|
+
if (branches.some((b) => !b)) return;
|
|
3975
|
+
folded = { [keyword]: branches };
|
|
2871
3976
|
}
|
|
3977
|
+
if (!folded) return;
|
|
3978
|
+
delete json.allOf;
|
|
3979
|
+
assignProps(json, folded);
|
|
2872
3980
|
}
|
|
2873
3981
|
function finalize(ctx, schema) {
|
|
2874
3982
|
const root = ctx.seen.get(schema);
|
|
@@ -2887,8 +3995,8 @@ function finalize(ctx, schema) {
|
|
|
2887
3995
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
2888
3996
|
schema.allOf = schema.allOf ?? [];
|
|
2889
3997
|
schema.allOf.push(refSchema);
|
|
2890
|
-
} else
|
|
2891
|
-
|
|
3998
|
+
} else assignProps(schema, refSchema);
|
|
3999
|
+
assignProps(schema, _cached);
|
|
2892
4000
|
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
2893
4001
|
if (key === "$ref" || key === "allOf") continue;
|
|
2894
4002
|
if (!(key in _cached)) delete schema[key];
|
|
@@ -2916,7 +4024,22 @@ function finalize(ctx, schema) {
|
|
|
2916
4024
|
path: seen.path ?? []
|
|
2917
4025
|
});
|
|
2918
4026
|
};
|
|
2919
|
-
|
|
4027
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
|
|
4028
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
4029
|
+
if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
|
|
4030
|
+
for (const rewrite of ctx.deferred) rewrite();
|
|
4031
|
+
if (ctx.intersections.length) {
|
|
4032
|
+
const carriers = /* @__PURE__ */ new Map();
|
|
4033
|
+
for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
|
|
4034
|
+
const allOf = json?.allOf;
|
|
4035
|
+
if (!Array.isArray(allOf)) continue;
|
|
4036
|
+
const existing = carriers.get(allOf);
|
|
4037
|
+
if (existing) existing.push(json);
|
|
4038
|
+
else carriers.set(allOf, [json]);
|
|
4039
|
+
}
|
|
4040
|
+
for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
2920
4043
|
const result = {};
|
|
2921
4044
|
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
2922
4045
|
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -2927,12 +4050,18 @@ function finalize(ctx, schema) {
|
|
|
2927
4050
|
if (!id) throw new Error("Schema is missing an `id` property");
|
|
2928
4051
|
result.$id = ctx.external.uri(id);
|
|
2929
4052
|
}
|
|
2930
|
-
|
|
4053
|
+
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
4054
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
4055
|
+
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
|
|
2931
4056
|
const defs = ctx.external?.defs ?? {};
|
|
2932
|
-
for (const entry of ctx.seen.entries()) {
|
|
4057
|
+
if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
|
|
2933
4058
|
const seen = entry[1];
|
|
2934
|
-
if (seen.def && seen.defId)
|
|
4059
|
+
if (seen.def && seen.defId) {
|
|
4060
|
+
if (seen.def.id === seen.defId) delete seen.def.id;
|
|
4061
|
+
assignProp(defs, seen.defId, seen.def);
|
|
4062
|
+
}
|
|
2935
4063
|
}
|
|
4064
|
+
if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
|
|
2936
4065
|
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
|
|
2937
4066
|
if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
2938
4067
|
else result.definitions = defs;
|
|
@@ -2964,10 +4093,13 @@ function isTransforming(_schema, _ctx) {
|
|
|
2964
4093
|
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
2965
4094
|
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
2966
4095
|
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
2967
|
-
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);
|
|
4096
|
+
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);
|
|
2968
4097
|
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
2969
4098
|
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
2970
|
-
if (def.type === "pipe")
|
|
4099
|
+
if (def.type === "pipe") {
|
|
4100
|
+
if (_schema._zod.traits.has("$ZodCodec")) return true;
|
|
4101
|
+
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
4102
|
+
}
|
|
2971
4103
|
if (def.type === "object") {
|
|
2972
4104
|
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
2973
4105
|
return false;
|
|
@@ -2992,7 +4124,7 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
2992
4124
|
...params,
|
|
2993
4125
|
processors
|
|
2994
4126
|
});
|
|
2995
|
-
|
|
4127
|
+
processSchema(schema, ctx);
|
|
2996
4128
|
extractDefs(ctx, schema);
|
|
2997
4129
|
return finalize(ctx, schema);
|
|
2998
4130
|
};
|
|
@@ -3004,12 +4136,84 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
|
|
|
3004
4136
|
io,
|
|
3005
4137
|
processors
|
|
3006
4138
|
});
|
|
3007
|
-
|
|
4139
|
+
processSchema(schema, ctx);
|
|
3008
4140
|
extractDefs(ctx, schema);
|
|
3009
4141
|
return finalize(ctx, schema);
|
|
3010
4142
|
};
|
|
3011
4143
|
//#endregion
|
|
3012
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
4144
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/json-schema-processors.js
|
|
4145
|
+
const narrowMin = (agg, key, value) => {
|
|
4146
|
+
if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
|
|
4147
|
+
};
|
|
4148
|
+
const narrowMax = (agg, key, value) => {
|
|
4149
|
+
if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
|
|
4150
|
+
};
|
|
4151
|
+
const narrowBoth = (agg, value) => {
|
|
4152
|
+
narrowMin(agg, "minimum", value);
|
|
4153
|
+
narrowMax(agg, "maximum", value);
|
|
4154
|
+
};
|
|
4155
|
+
const addDivisor = (agg, value) => {
|
|
4156
|
+
agg.multipleOf ?? (agg.multipleOf = []);
|
|
4157
|
+
if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
|
|
4158
|
+
};
|
|
4159
|
+
const addPattern = (agg, pattern) => {
|
|
4160
|
+
agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
|
|
4161
|
+
agg.patterns.add(pattern);
|
|
4162
|
+
};
|
|
4163
|
+
const intersectMime = (agg, mime) => {
|
|
4164
|
+
agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
|
|
4165
|
+
};
|
|
4166
|
+
const setFormat = (agg, format) => {
|
|
4167
|
+
agg.format = format;
|
|
4168
|
+
if (format.includes("int")) agg.isInt = true;
|
|
4169
|
+
};
|
|
4170
|
+
const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
|
|
4171
|
+
const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
|
|
4172
|
+
const formatContributor = (ranges) => (agg, def) => {
|
|
4173
|
+
setFormat(agg, def.format);
|
|
4174
|
+
const [minimum, maximum] = ranges[def.format];
|
|
4175
|
+
narrowMin(agg, "minimum", minimum);
|
|
4176
|
+
narrowMax(agg, "maximum", maximum);
|
|
4177
|
+
};
|
|
4178
|
+
const contributors = {
|
|
4179
|
+
greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
|
|
4180
|
+
less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
|
|
4181
|
+
multiple_of: (agg, def) => addDivisor(agg, def.value),
|
|
4182
|
+
number_format: formatContributor(NUMBER_FORMAT_RANGES),
|
|
4183
|
+
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
|
|
4184
|
+
min_length: minContributor,
|
|
4185
|
+
max_length: maxContributor,
|
|
4186
|
+
length_equals: (agg, def) => narrowBoth(agg, def.length),
|
|
4187
|
+
min_size: minContributor,
|
|
4188
|
+
max_size: maxContributor,
|
|
4189
|
+
size_equals: (agg, def) => narrowBoth(agg, def.size),
|
|
4190
|
+
string_format: (agg, def) => {
|
|
4191
|
+
setFormat(agg, def.format);
|
|
4192
|
+
if (def.pattern) addPattern(agg, def.pattern);
|
|
4193
|
+
if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
|
|
4194
|
+
if (def.local || def.precision === -1) agg.laxFormat = true;
|
|
4195
|
+
},
|
|
4196
|
+
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
4197
|
+
};
|
|
4198
|
+
function aggregateChecks(schema) {
|
|
4199
|
+
const agg = {};
|
|
4200
|
+
const def = schema._zod.def;
|
|
4201
|
+
const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
4202
|
+
for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
4203
|
+
const bag = schema._zod.bag;
|
|
4204
|
+
if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
|
|
4205
|
+
if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
|
|
4206
|
+
if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
|
|
4207
|
+
if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
|
|
4208
|
+
if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
|
|
4209
|
+
if (bag.format !== void 0) {
|
|
4210
|
+
agg.format ?? (agg.format = bag.format);
|
|
4211
|
+
if (bag.format.includes("int")) agg.isInt = true;
|
|
4212
|
+
}
|
|
4213
|
+
if (bag.mime) intersectMime(agg, bag.mime);
|
|
4214
|
+
for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
|
|
4215
|
+
return agg;
|
|
4216
|
+
}
|
|
3013
4217
|
const formatMap = {
|
|
3014
4218
|
guid: "uuid",
|
|
3015
4219
|
url: "uri",
|
|
@@ -3017,59 +4221,56 @@ const formatMap = {
|
|
|
3017
4221
|
json_string: "json-string",
|
|
3018
4222
|
regex: ""
|
|
3019
4223
|
};
|
|
4224
|
+
const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
|
|
4225
|
+
const exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
3020
4226
|
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
3021
4227
|
const json = _json;
|
|
3022
4228
|
json.type = "string";
|
|
3023
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema
|
|
4229
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
3024
4230
|
if (typeof minimum === "number") json.minLength = minimum;
|
|
3025
4231
|
if (typeof maximum === "number") json.maxLength = maximum;
|
|
3026
4232
|
if (format) {
|
|
3027
4233
|
json.format = formatMap[format] ?? format;
|
|
3028
4234
|
if (json.format === "") delete json.format;
|
|
3029
|
-
if (format === "time") delete json.format;
|
|
4235
|
+
if (format === "time" || laxFormat) delete json.format;
|
|
3030
4236
|
}
|
|
3031
4237
|
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
3032
4238
|
if (patterns && patterns.size > 0) {
|
|
3033
|
-
const
|
|
3034
|
-
if (
|
|
3035
|
-
else if (
|
|
4239
|
+
const patternList = [...patterns].map(exactPattern);
|
|
4240
|
+
if (patternList.length === 1) json.pattern = patternList[0].source;
|
|
4241
|
+
else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
|
|
3036
4242
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3037
4243
|
pattern: regex.source
|
|
3038
4244
|
}))];
|
|
3039
4245
|
}
|
|
3040
4246
|
};
|
|
3041
|
-
const numberProcessor = (schema, ctx, _json,
|
|
4247
|
+
const numberProcessor = (schema, ctx, _json, params) => {
|
|
3042
4248
|
const json = _json;
|
|
3043
|
-
const { minimum, maximum,
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
4249
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
4250
|
+
json.type = isInt ? "integer" : "number";
|
|
4251
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
4252
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
4253
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
4254
|
+
if (exMin) {
|
|
4255
|
+
if (legacy) {
|
|
3048
4256
|
json.minimum = exclusiveMinimum;
|
|
3049
4257
|
json.exclusiveMinimum = true;
|
|
3050
4258
|
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
3051
|
-
}
|
|
3052
|
-
if (
|
|
3053
|
-
|
|
3054
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
3055
|
-
if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
3056
|
-
else delete json.exclusiveMinimum;
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
if (typeof exclusiveMaximum === "number") {
|
|
3060
|
-
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
4259
|
+
} else if (typeof minimum === "number") json.minimum = minimum;
|
|
4260
|
+
if (exMax) {
|
|
4261
|
+
if (legacy) {
|
|
3061
4262
|
json.maximum = exclusiveMaximum;
|
|
3062
4263
|
json.exclusiveMaximum = true;
|
|
3063
4264
|
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
4265
|
+
} else if (typeof maximum === "number") json.maximum = maximum;
|
|
4266
|
+
if (multipleOf) {
|
|
4267
|
+
const divisors = /* @__PURE__ */ new Set();
|
|
4268
|
+
for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
|
|
4269
|
+
else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
4270
|
+
const [first, ...rest] = divisors;
|
|
4271
|
+
if (first !== void 0) json.multipleOf = first;
|
|
4272
|
+
if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
3064
4273
|
}
|
|
3065
|
-
if (typeof maximum === "number") {
|
|
3066
|
-
json.maximum = maximum;
|
|
3067
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
3068
|
-
if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
3069
|
-
else delete json.exclusiveMaximum;
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
3073
4274
|
};
|
|
3074
4275
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3075
4276
|
json.type = "boolean";
|
|
@@ -3080,18 +4281,26 @@ const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
|
3080
4281
|
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
3081
4282
|
const def = schema._zod.def;
|
|
3082
4283
|
const values = getEnumValues(def.entries);
|
|
4284
|
+
if (values.length === 0) {
|
|
4285
|
+
json.not = {};
|
|
4286
|
+
return;
|
|
4287
|
+
}
|
|
3083
4288
|
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
3084
4289
|
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
3085
4290
|
json.enum = values;
|
|
3086
4291
|
};
|
|
3087
|
-
const literalProcessor = (schema, ctx, json,
|
|
4292
|
+
const literalProcessor = (schema, ctx, json, params) => {
|
|
3088
4293
|
const def = schema._zod.def;
|
|
4294
|
+
if (def.values.length === 0) {
|
|
4295
|
+
json.not = {};
|
|
4296
|
+
return;
|
|
4297
|
+
}
|
|
3089
4298
|
const vals = [];
|
|
3090
4299
|
for (const val of def.values) if (val === void 0) {
|
|
3091
|
-
if (ctx
|
|
4300
|
+
if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
|
|
3092
4301
|
} else if (typeof val === "bigint") {
|
|
3093
|
-
if (ctx
|
|
3094
|
-
|
|
4302
|
+
if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
|
|
4303
|
+
vals.push(Number(val));
|
|
3095
4304
|
} else vals.push(val);
|
|
3096
4305
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3097
4306
|
const val = vals[0];
|
|
@@ -3106,49 +4315,55 @@ const literalProcessor = (schema, ctx, json, _params) => {
|
|
|
3106
4315
|
json.enum = vals;
|
|
3107
4316
|
}
|
|
3108
4317
|
};
|
|
3109
|
-
const customProcessor = (
|
|
3110
|
-
|
|
4318
|
+
const customProcessor = (schema, ctx, json, params) => {
|
|
4319
|
+
handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
|
|
3111
4320
|
};
|
|
3112
|
-
const transformProcessor = (
|
|
3113
|
-
|
|
4321
|
+
const transformProcessor = (schema, ctx, json, params) => {
|
|
4322
|
+
handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
|
|
3114
4323
|
};
|
|
3115
4324
|
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
3116
4325
|
const json = _json;
|
|
3117
4326
|
const def = schema._zod.def;
|
|
3118
|
-
const { minimum, maximum } = schema
|
|
4327
|
+
const { minimum, maximum } = aggregateChecks(schema);
|
|
3119
4328
|
if (typeof minimum === "number") json.minItems = minimum;
|
|
3120
4329
|
if (typeof maximum === "number") json.maxItems = maximum;
|
|
3121
4330
|
json.type = "array";
|
|
3122
|
-
json.items =
|
|
4331
|
+
json.items = processSchema(def.element, ctx, {
|
|
3123
4332
|
...params,
|
|
3124
4333
|
path: [...params.path, "items"]
|
|
3125
4334
|
});
|
|
3126
4335
|
};
|
|
4336
|
+
function inputOptin(schema) {
|
|
4337
|
+
const def = schema._zod.def;
|
|
4338
|
+
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
|
|
4339
|
+
if (def.type === "catch") return inputOptin(def.innerType);
|
|
4340
|
+
return schema._zod.optin;
|
|
4341
|
+
}
|
|
3127
4342
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
3128
4343
|
const json = _json;
|
|
3129
4344
|
const def = schema._zod.def;
|
|
4345
|
+
const shape = def.shape;
|
|
4346
|
+
if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
|
|
3130
4347
|
json.type = "object";
|
|
3131
4348
|
json.properties = {};
|
|
3132
|
-
const shape
|
|
3133
|
-
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
|
|
4349
|
+
for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
|
|
3134
4350
|
...params,
|
|
3135
4351
|
path: [
|
|
3136
4352
|
...params.path,
|
|
3137
4353
|
"properties",
|
|
3138
4354
|
key
|
|
3139
4355
|
]
|
|
3140
|
-
});
|
|
3141
|
-
const allKeys = new Set(Object.keys(shape));
|
|
3142
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
3143
|
-
const v = def.shape[key]._zod;
|
|
3144
|
-
if (ctx.io === "input") return v.optin === void 0;
|
|
3145
|
-
else return v.optout === void 0;
|
|
3146
4356
|
}));
|
|
3147
|
-
|
|
4357
|
+
const requiredKeys = [];
|
|
4358
|
+
for (const key of Object.keys(shape)) {
|
|
4359
|
+
const field = def.shape[key];
|
|
4360
|
+
if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
|
|
4361
|
+
}
|
|
4362
|
+
if (requiredKeys.length > 0) json.required = requiredKeys;
|
|
3148
4363
|
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
3149
4364
|
else if (!def.catchall) {
|
|
3150
4365
|
if (ctx.io === "output") json.additionalProperties = false;
|
|
3151
|
-
} else if (def.catchall) json.additionalProperties =
|
|
4366
|
+
} else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
|
|
3152
4367
|
...params,
|
|
3153
4368
|
path: [...params.path, "additionalProperties"]
|
|
3154
4369
|
});
|
|
@@ -3156,7 +4371,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
3156
4371
|
const unionProcessor = (schema, ctx, json, params) => {
|
|
3157
4372
|
const def = schema._zod.def;
|
|
3158
4373
|
const isExclusive = def.inclusive === false;
|
|
3159
|
-
const options = def.options.map((x, i) =>
|
|
4374
|
+
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
3160
4375
|
...params,
|
|
3161
4376
|
path: [
|
|
3162
4377
|
...params.path,
|
|
@@ -3169,7 +4384,7 @@ const unionProcessor = (schema, ctx, json, params) => {
|
|
|
3169
4384
|
};
|
|
3170
4385
|
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
3171
4386
|
const def = schema._zod.def;
|
|
3172
|
-
const a =
|
|
4387
|
+
const a = processSchema(def.left, ctx, {
|
|
3173
4388
|
...params,
|
|
3174
4389
|
path: [
|
|
3175
4390
|
...params.path,
|
|
@@ -3177,7 +4392,7 @@ const intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3177
4392
|
0
|
|
3178
4393
|
]
|
|
3179
4394
|
});
|
|
3180
|
-
const b =
|
|
4395
|
+
const b = processSchema(def.right, ctx, {
|
|
3181
4396
|
...params,
|
|
3182
4397
|
path: [
|
|
3183
4398
|
...params.path,
|
|
@@ -3186,16 +4401,76 @@ const intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3186
4401
|
]
|
|
3187
4402
|
});
|
|
3188
4403
|
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
3189
|
-
|
|
4404
|
+
const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
4405
|
+
json.allOf = allOf;
|
|
4406
|
+
ctx.intersections.push(allOf);
|
|
3190
4407
|
};
|
|
4408
|
+
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
|
|
4409
|
+
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
|
|
4410
|
+
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
|
|
4411
|
+
*
|
|
4412
|
+
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
|
|
4413
|
+
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
|
|
4414
|
+
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
|
|
4415
|
+
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
|
|
4416
|
+
* outright. */
|
|
4417
|
+
function stringifyKeyNames(bySchema, json, visited) {
|
|
4418
|
+
if (json.$ref) {
|
|
4419
|
+
if (visited.has(json)) return json;
|
|
4420
|
+
visited.add(json);
|
|
4421
|
+
const def = bySchema.get(json)?.def;
|
|
4422
|
+
if (!def) return json;
|
|
4423
|
+
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
4424
|
+
return inlined === def ? json : inlined;
|
|
4425
|
+
}
|
|
4426
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
4427
|
+
const branches = json[keyword];
|
|
4428
|
+
if (!Array.isArray(branches)) continue;
|
|
4429
|
+
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
4430
|
+
if (mapped.some((branch, i) => branch !== branches[i])) json = {
|
|
4431
|
+
...json,
|
|
4432
|
+
[keyword]: mapped
|
|
4433
|
+
};
|
|
4434
|
+
}
|
|
4435
|
+
const types = Array.isArray(json.type) ? json.type : [json.type];
|
|
4436
|
+
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
4437
|
+
const values = json.enum ?? (json.const !== void 0 ? [json.const] : void 0);
|
|
4438
|
+
if (!numericType && !values?.some((v) => typeof v === "number")) return json;
|
|
4439
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
|
|
4440
|
+
if (rest.enum) rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
4441
|
+
else if (typeof rest.const === "number") rest.const = String(rest.const);
|
|
4442
|
+
if (!numericType) return rest;
|
|
4443
|
+
rest.type = "string";
|
|
4444
|
+
if (!values) rest.pattern = (types.includes("number") ? number$1 : integer).source;
|
|
4445
|
+
return rest;
|
|
4446
|
+
}
|
|
4447
|
+
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
|
|
4448
|
+
const pendingRecords = /* @__PURE__ */ new WeakMap();
|
|
4449
|
+
function rewriteKeyNames(ctx) {
|
|
4450
|
+
const bySchema = /* @__PURE__ */ new Map();
|
|
4451
|
+
for (const entry of ctx.seen.values()) if (entry.def && !bySchema.has(entry.schema)) bySchema.set(entry.schema, entry);
|
|
4452
|
+
const rewrites = /* @__PURE__ */ new Map();
|
|
4453
|
+
for (const record of pendingRecords.get(ctx) ?? []) {
|
|
4454
|
+
const seen = ctx.seen.get(record);
|
|
4455
|
+
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
4456
|
+
if (!names || names === true || rewrites.has(names)) continue;
|
|
4457
|
+
const rewritten = stringifyKeyNames(bySchema, names, /* @__PURE__ */ new Set());
|
|
4458
|
+
if (rewritten !== names) rewrites.set(names, rewritten);
|
|
4459
|
+
}
|
|
4460
|
+
if (!rewrites.size) return;
|
|
4461
|
+
for (const entry of ctx.seen.values()) for (const carrier of [entry.schema, entry.def]) {
|
|
4462
|
+
const rewritten = carrier && rewrites.get(carrier.propertyNames);
|
|
4463
|
+
if (rewritten) carrier.propertyNames = rewritten;
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
3191
4466
|
const recordProcessor = (schema, ctx, _json, params) => {
|
|
3192
4467
|
const json = _json;
|
|
3193
4468
|
const def = schema._zod.def;
|
|
3194
4469
|
json.type = "object";
|
|
3195
4470
|
const keyType = def.keyType;
|
|
3196
|
-
const patterns = keyType.
|
|
4471
|
+
const patterns = aggregateChecks(keyType).patterns;
|
|
3197
4472
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
3198
|
-
const valueSchema =
|
|
4473
|
+
const valueSchema = processSchema(def.valueType, ctx, {
|
|
3199
4474
|
...params,
|
|
3200
4475
|
path: [
|
|
3201
4476
|
...params.path,
|
|
@@ -3204,26 +4479,36 @@ const recordProcessor = (schema, ctx, _json, params) => {
|
|
|
3204
4479
|
]
|
|
3205
4480
|
});
|
|
3206
4481
|
json.patternProperties = {};
|
|
3207
|
-
for (const pattern of patterns) json.patternProperties
|
|
4482
|
+
for (const pattern of patterns) assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
3208
4483
|
} else {
|
|
3209
|
-
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12")
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
4484
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
4485
|
+
json.propertyNames = processSchema(def.keyType, ctx, {
|
|
4486
|
+
...params,
|
|
4487
|
+
path: [...params.path, "propertyNames"]
|
|
4488
|
+
});
|
|
4489
|
+
let pending = pendingRecords.get(ctx);
|
|
4490
|
+
if (!pending) {
|
|
4491
|
+
pending = [];
|
|
4492
|
+
pendingRecords.set(ctx, pending);
|
|
4493
|
+
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
4494
|
+
}
|
|
4495
|
+
pending.push(schema);
|
|
4496
|
+
}
|
|
4497
|
+
json.additionalProperties = processSchema(def.valueType, ctx, {
|
|
3214
4498
|
...params,
|
|
3215
4499
|
path: [...params.path, "additionalProperties"]
|
|
3216
4500
|
});
|
|
3217
4501
|
}
|
|
3218
4502
|
const keyValues = keyType._zod.values;
|
|
3219
|
-
|
|
4503
|
+
const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
|
|
4504
|
+
if (keyValues && !def.partial && !omittableOnInput) {
|
|
3220
4505
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
3221
|
-
if (validKeyValues.length > 0) json.required = validKeyValues;
|
|
4506
|
+
if (validKeyValues.length > 0) json.required = validKeyValues.map(String);
|
|
3222
4507
|
}
|
|
3223
4508
|
};
|
|
3224
4509
|
const nullableProcessor = (schema, ctx, json, params) => {
|
|
3225
4510
|
const def = schema._zod.def;
|
|
3226
|
-
const inner =
|
|
4511
|
+
const inner = processSchema(def.innerType, ctx, params);
|
|
3227
4512
|
const seen = ctx.seen.get(schema);
|
|
3228
4513
|
if (ctx.target === "openapi-3.0") {
|
|
3229
4514
|
seen.ref = def.innerType;
|
|
@@ -3232,112 +4517,129 @@ const nullableProcessor = (schema, ctx, json, params) => {
|
|
|
3232
4517
|
};
|
|
3233
4518
|
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
3234
4519
|
const def = schema._zod.def;
|
|
3235
|
-
|
|
4520
|
+
processSchema(def.innerType, ctx, params);
|
|
3236
4521
|
const seen = ctx.seen.get(schema);
|
|
3237
4522
|
seen.ref = def.innerType;
|
|
3238
4523
|
};
|
|
4524
|
+
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
|
|
4525
|
+
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
|
|
4526
|
+
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
|
|
4527
|
+
const UNREPRESENTABLE_DEFAULT = Symbol();
|
|
4528
|
+
function serializeDefaultValue(value, schema, ctx, json, params) {
|
|
4529
|
+
let unrepresentable = false;
|
|
4530
|
+
const serialized = JSON.stringify(value, (_, val) => {
|
|
4531
|
+
if (typeof val !== "bigint") return val;
|
|
4532
|
+
unrepresentable = true;
|
|
4533
|
+
return null;
|
|
4534
|
+
});
|
|
4535
|
+
if (!unrepresentable) return JSON.parse(serialized);
|
|
4536
|
+
handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
4537
|
+
return UNREPRESENTABLE_DEFAULT;
|
|
4538
|
+
}
|
|
3239
4539
|
const defaultProcessor = (schema, ctx, json, params) => {
|
|
3240
4540
|
const def = schema._zod.def;
|
|
3241
|
-
|
|
4541
|
+
processSchema(def.innerType, ctx, params);
|
|
3242
4542
|
const seen = ctx.seen.get(schema);
|
|
3243
4543
|
seen.ref = def.innerType;
|
|
3244
|
-
|
|
4544
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4545
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
|
|
3245
4546
|
};
|
|
3246
4547
|
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
3247
4548
|
const def = schema._zod.def;
|
|
3248
|
-
|
|
4549
|
+
processSchema(def.innerType, ctx, params);
|
|
3249
4550
|
const seen = ctx.seen.get(schema);
|
|
3250
4551
|
seen.ref = def.innerType;
|
|
3251
|
-
if (ctx.io
|
|
4552
|
+
if (ctx.io !== "input") return;
|
|
4553
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
|
|
4554
|
+
if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
|
|
3252
4555
|
};
|
|
3253
4556
|
const catchProcessor = (schema, ctx, json, params) => {
|
|
3254
4557
|
const def = schema._zod.def;
|
|
3255
|
-
|
|
4558
|
+
processSchema(def.innerType, ctx, params);
|
|
3256
4559
|
const seen = ctx.seen.get(schema);
|
|
3257
4560
|
seen.ref = def.innerType;
|
|
3258
4561
|
let catchValue;
|
|
3259
4562
|
try {
|
|
3260
4563
|
catchValue = def.catchValue(void 0);
|
|
3261
4564
|
} catch {
|
|
3262
|
-
|
|
4565
|
+
handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
|
|
4566
|
+
return;
|
|
3263
4567
|
}
|
|
3264
4568
|
json.default = catchValue;
|
|
3265
4569
|
};
|
|
3266
4570
|
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
3267
4571
|
const def = schema._zod.def;
|
|
3268
|
-
const
|
|
3269
|
-
|
|
4572
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
4573
|
+
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
4574
|
+
processSchema(innerType, ctx, params);
|
|
3270
4575
|
const seen = ctx.seen.get(schema);
|
|
3271
4576
|
seen.ref = innerType;
|
|
3272
4577
|
};
|
|
3273
4578
|
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
3274
4579
|
const def = schema._zod.def;
|
|
3275
|
-
|
|
4580
|
+
processSchema(def.innerType, ctx, params);
|
|
3276
4581
|
const seen = ctx.seen.get(schema);
|
|
3277
4582
|
seen.ref = def.innerType;
|
|
3278
4583
|
json.readOnly = true;
|
|
3279
4584
|
};
|
|
3280
4585
|
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
3281
4586
|
const def = schema._zod.def;
|
|
3282
|
-
|
|
4587
|
+
processSchema(def.innerType, ctx, params);
|
|
3283
4588
|
const seen = ctx.seen.get(schema);
|
|
3284
4589
|
seen.ref = def.innerType;
|
|
3285
4590
|
};
|
|
3286
4591
|
//#endregion
|
|
3287
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
3288
|
-
const
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
}
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
}
|
|
3309
|
-
|
|
3310
|
-
$ZodISODuration.init(inst, def);
|
|
3311
|
-
ZodStringFormat.init(inst, def);
|
|
3312
|
-
});
|
|
3313
|
-
function duration(params) {
|
|
3314
|
-
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
4592
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/errors.js
|
|
4593
|
+
const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
|
|
4594
|
+
function _lazyMethod(proto, key, make) {
|
|
4595
|
+
Object.defineProperty(proto, key, {
|
|
4596
|
+
configurable: true,
|
|
4597
|
+
enumerable: false,
|
|
4598
|
+
get() {
|
|
4599
|
+
const value = make(this);
|
|
4600
|
+
Object.defineProperty(this, key, {
|
|
4601
|
+
value,
|
|
4602
|
+
configurable: true,
|
|
4603
|
+
writable: true
|
|
4604
|
+
});
|
|
4605
|
+
return value;
|
|
4606
|
+
},
|
|
4607
|
+
set(value) {
|
|
4608
|
+
Object.defineProperty(this, key, {
|
|
4609
|
+
value,
|
|
4610
|
+
configurable: true,
|
|
4611
|
+
writable: true
|
|
4612
|
+
});
|
|
4613
|
+
}
|
|
4614
|
+
});
|
|
3315
4615
|
}
|
|
3316
|
-
//#endregion
|
|
3317
|
-
//#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
|
|
3318
4616
|
const initializer = (inst, issues) => {
|
|
3319
4617
|
$ZodError.init(inst, issues);
|
|
3320
4618
|
inst.name = "ZodError";
|
|
3321
|
-
Object.
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
4619
|
+
const proto = Object.getPrototypeOf(inst);
|
|
4620
|
+
if (_installedErrorProtos.has(proto)) return;
|
|
4621
|
+
_installedErrorProtos.add(proto);
|
|
4622
|
+
_lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
|
|
4623
|
+
_lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
|
|
4624
|
+
_lazyMethod(proto, "addIssue", (self) => (issue) => {
|
|
4625
|
+
self.issues.push(issue);
|
|
4626
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4627
|
+
});
|
|
4628
|
+
_lazyMethod(proto, "addIssues", (self) => (issues) => {
|
|
4629
|
+
self.issues.push(...issues);
|
|
4630
|
+
self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
|
|
4631
|
+
});
|
|
4632
|
+
Object.defineProperty(proto, "isEmpty", {
|
|
4633
|
+
configurable: true,
|
|
4634
|
+
enumerable: false,
|
|
4635
|
+
get() {
|
|
4636
|
+
return this.issues.length === 0;
|
|
4637
|
+
}
|
|
4638
|
+
});
|
|
4639
|
+
};
|
|
4640
|
+
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
|
|
3339
4641
|
//#endregion
|
|
3340
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
4642
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/parse.js
|
|
3341
4643
|
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
3342
4644
|
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
3343
4645
|
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -3351,138 +4653,320 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
|
3351
4653
|
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3352
4654
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3353
4655
|
//#endregion
|
|
3354
|
-
//#region ../../node_modules/.pnpm/zod@4.
|
|
4656
|
+
//#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/schemas.js
|
|
4657
|
+
function _ensureDefaultLocale() {
|
|
4658
|
+
if (!globalConfig.localeError) config(en_default());
|
|
4659
|
+
}
|
|
4660
|
+
function _ensureDefaultMemoizer() {
|
|
4661
|
+
if (!globalConfig.memoizer) config({ memoizer: memoizer() });
|
|
4662
|
+
}
|
|
3355
4663
|
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
4664
|
+
_ensureDefaultLocale();
|
|
3356
4665
|
$ZodType.init(inst, def);
|
|
3357
|
-
Object.assign(inst["~standard"], { jsonSchema: {
|
|
3358
|
-
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
3359
|
-
output: createStandardJSONSchemaMethod(inst, "output")
|
|
3360
|
-
} });
|
|
3361
|
-
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
3362
4666
|
inst.def = def;
|
|
3363
4667
|
inst.type = def.type;
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
4668
|
+
return inst;
|
|
4669
|
+
}, {
|
|
4670
|
+
check(...chks) {
|
|
4671
|
+
const def = this.def;
|
|
4672
|
+
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
3367
4673
|
check: ch,
|
|
3368
4674
|
def: { check: "custom" },
|
|
3369
4675
|
onattach: []
|
|
3370
4676
|
} } : ch)] }), { parent: true });
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
4677
|
+
},
|
|
4678
|
+
with(...chks) {
|
|
4679
|
+
return this.check(...chks);
|
|
4680
|
+
},
|
|
4681
|
+
clone(def, params) {
|
|
4682
|
+
return clone(this, def, params);
|
|
4683
|
+
},
|
|
4684
|
+
brand() {
|
|
4685
|
+
return this;
|
|
4686
|
+
},
|
|
4687
|
+
register(reg, meta) {
|
|
4688
|
+
reg.add(this, meta);
|
|
4689
|
+
return this;
|
|
4690
|
+
},
|
|
4691
|
+
refine(check, params) {
|
|
4692
|
+
return this.check(refine(check, params));
|
|
4693
|
+
},
|
|
4694
|
+
superRefine(refinement, params) {
|
|
4695
|
+
return this.check(superRefine(refinement, params));
|
|
4696
|
+
},
|
|
4697
|
+
overwrite(fn) {
|
|
4698
|
+
return this.check(/* @__PURE__ */ _overwrite(fn));
|
|
4699
|
+
},
|
|
4700
|
+
optional() {
|
|
4701
|
+
return optional(this);
|
|
4702
|
+
},
|
|
4703
|
+
exactOptional() {
|
|
4704
|
+
return exactOptional(this);
|
|
4705
|
+
},
|
|
4706
|
+
nullable() {
|
|
4707
|
+
return nullable(this);
|
|
4708
|
+
},
|
|
4709
|
+
nullish() {
|
|
4710
|
+
return optional(nullable(this));
|
|
4711
|
+
},
|
|
4712
|
+
nonoptional(params) {
|
|
4713
|
+
return nonoptional(this, params);
|
|
4714
|
+
},
|
|
4715
|
+
array() {
|
|
4716
|
+
return array(this);
|
|
4717
|
+
},
|
|
4718
|
+
or(arg) {
|
|
4719
|
+
return union([this, arg]);
|
|
4720
|
+
},
|
|
4721
|
+
and(arg) {
|
|
4722
|
+
return intersection(this, arg);
|
|
4723
|
+
},
|
|
4724
|
+
transform(tx) {
|
|
4725
|
+
return pipe(this, transform(tx));
|
|
4726
|
+
},
|
|
4727
|
+
default(d) {
|
|
4728
|
+
return _default(this, d);
|
|
4729
|
+
},
|
|
4730
|
+
prefault(d) {
|
|
4731
|
+
return prefault(this, d);
|
|
4732
|
+
},
|
|
4733
|
+
catch(params) {
|
|
4734
|
+
return _catch(this, params);
|
|
4735
|
+
},
|
|
4736
|
+
pipe(target) {
|
|
4737
|
+
return pipe(this, target);
|
|
4738
|
+
},
|
|
4739
|
+
readonly() {
|
|
4740
|
+
return readonly(this);
|
|
4741
|
+
},
|
|
4742
|
+
describe(description) {
|
|
4743
|
+
const cl = this.clone();
|
|
3411
4744
|
globalRegistry.add(cl, { description });
|
|
3412
4745
|
return cl;
|
|
3413
|
-
}
|
|
3414
|
-
|
|
3415
|
-
get()
|
|
3416
|
-
|
|
3417
|
-
},
|
|
3418
|
-
configurable: true
|
|
3419
|
-
});
|
|
3420
|
-
inst.meta = (...args) => {
|
|
3421
|
-
if (args.length === 0) return globalRegistry.get(inst);
|
|
3422
|
-
const cl = inst.clone();
|
|
4746
|
+
},
|
|
4747
|
+
meta(...args) {
|
|
4748
|
+
if (args.length === 0) return globalRegistry.get(this);
|
|
4749
|
+
const cl = this.clone();
|
|
3423
4750
|
globalRegistry.add(cl, args[0]);
|
|
3424
4751
|
return cl;
|
|
3425
|
-
}
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
4752
|
+
},
|
|
4753
|
+
isOptional() {
|
|
4754
|
+
return this.safeParse(void 0).success;
|
|
4755
|
+
},
|
|
4756
|
+
isNullable() {
|
|
4757
|
+
return this.safeParse(null).success;
|
|
4758
|
+
},
|
|
4759
|
+
apply(fn, ...args) {
|
|
4760
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
4761
|
+
},
|
|
4762
|
+
get "~standard"() {
|
|
4763
|
+
return hide(this, "~standard", {
|
|
4764
|
+
...standardProps(this),
|
|
4765
|
+
jsonSchema: {
|
|
4766
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
4767
|
+
output: createStandardJSONSchemaMethod(this, "output")
|
|
4768
|
+
}
|
|
4769
|
+
});
|
|
4770
|
+
},
|
|
4771
|
+
set "~standard"(value) {
|
|
4772
|
+
own(this, "~standard", value);
|
|
4773
|
+
},
|
|
4774
|
+
parse: function _parse(data, params) {
|
|
4775
|
+
return parse(this, data, params, { callee: _parse });
|
|
4776
|
+
},
|
|
4777
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
4778
|
+
return await parseAsync(this, data, params, { callee: _parseAsync });
|
|
4779
|
+
},
|
|
4780
|
+
safeParse(data, params) {
|
|
4781
|
+
return safeParse(this, data, params);
|
|
4782
|
+
},
|
|
4783
|
+
async safeParseAsync(data, params) {
|
|
4784
|
+
return safeParseAsync(this, data, params);
|
|
4785
|
+
},
|
|
4786
|
+
get spa() {
|
|
4787
|
+
return this?.safeParseAsync;
|
|
4788
|
+
},
|
|
4789
|
+
set spa(value) {
|
|
4790
|
+
own(this, "spa", value);
|
|
4791
|
+
},
|
|
4792
|
+
validate(data, params) {
|
|
4793
|
+
return validate(this, data, params);
|
|
4794
|
+
},
|
|
4795
|
+
validateAsync(data, params) {
|
|
4796
|
+
return validateAsync$1(this, data, params);
|
|
4797
|
+
},
|
|
4798
|
+
encode: function _encode(data, params) {
|
|
4799
|
+
return encode(this, data, params, { callee: _encode });
|
|
4800
|
+
},
|
|
4801
|
+
decode: function _decode(data, params) {
|
|
4802
|
+
return decode(this, data, params, { callee: _decode });
|
|
4803
|
+
},
|
|
4804
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
4805
|
+
return await encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
4806
|
+
},
|
|
4807
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
4808
|
+
return await decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
4809
|
+
},
|
|
4810
|
+
safeEncode(data, params) {
|
|
4811
|
+
return safeEncode(this, data, params);
|
|
4812
|
+
},
|
|
4813
|
+
safeDecode(data, params) {
|
|
4814
|
+
return safeDecode(this, data, params);
|
|
4815
|
+
},
|
|
4816
|
+
async safeEncodeAsync(data, params) {
|
|
4817
|
+
return safeEncodeAsync(this, data, params);
|
|
4818
|
+
},
|
|
4819
|
+
async safeDecodeAsync(data, params) {
|
|
4820
|
+
return safeDecodeAsync(this, data, params);
|
|
4821
|
+
},
|
|
4822
|
+
toJSONSchema(params) {
|
|
4823
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
4824
|
+
},
|
|
4825
|
+
get description() {
|
|
4826
|
+
return globalRegistry.get(this)?.description;
|
|
4827
|
+
},
|
|
4828
|
+
get _def() {
|
|
4829
|
+
return this._zod.def;
|
|
4830
|
+
}
|
|
3430
4831
|
});
|
|
3431
4832
|
/** @internal */
|
|
3432
4833
|
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
|
|
3433
4834
|
$ZodString.init(inst, def);
|
|
3434
4835
|
ZodType.init(inst, def);
|
|
3435
4836
|
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
}
|
|
4837
|
+
}, /*@__PURE__*/ derived({
|
|
4838
|
+
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
4839
|
+
minLength: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
4840
|
+
maxLength: (inst) => aggregateChecks(inst).maximum ?? null
|
|
4841
|
+
}, {
|
|
4842
|
+
regex(...args) {
|
|
4843
|
+
return this.check(/* @__PURE__ */ _regex(...args));
|
|
4844
|
+
},
|
|
4845
|
+
includes(...args) {
|
|
4846
|
+
return this.check(/* @__PURE__ */ _includes(...args));
|
|
4847
|
+
},
|
|
4848
|
+
startsWith(...args) {
|
|
4849
|
+
return this.check(/* @__PURE__ */ _startsWith(...args));
|
|
4850
|
+
},
|
|
4851
|
+
endsWith(...args) {
|
|
4852
|
+
return this.check(/* @__PURE__ */ _endsWith(...args));
|
|
4853
|
+
},
|
|
4854
|
+
min(...args) {
|
|
4855
|
+
return this.check(/* @__PURE__ */ _minLength(...args));
|
|
4856
|
+
},
|
|
4857
|
+
max(...args) {
|
|
4858
|
+
return this.check(/* @__PURE__ */ _maxLength(...args));
|
|
4859
|
+
},
|
|
4860
|
+
length(...args) {
|
|
4861
|
+
return this.check(/* @__PURE__ */ _length(...args));
|
|
4862
|
+
},
|
|
4863
|
+
nonempty(...args) {
|
|
4864
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...args));
|
|
4865
|
+
},
|
|
4866
|
+
lowercase(params) {
|
|
4867
|
+
return this.check(/* @__PURE__ */ _lowercase(params));
|
|
4868
|
+
},
|
|
4869
|
+
uppercase(params) {
|
|
4870
|
+
return this.check(/* @__PURE__ */ _uppercase(params));
|
|
4871
|
+
},
|
|
4872
|
+
trim() {
|
|
4873
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
4874
|
+
},
|
|
4875
|
+
normalize(...args) {
|
|
4876
|
+
return this.check(/* @__PURE__ */ _normalize(...args));
|
|
4877
|
+
},
|
|
4878
|
+
toLowerCase() {
|
|
4879
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
4880
|
+
},
|
|
4881
|
+
toUpperCase() {
|
|
4882
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
4883
|
+
},
|
|
4884
|
+
slugify() {
|
|
4885
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
4886
|
+
}
|
|
4887
|
+
}));
|
|
3456
4888
|
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
|
|
3457
4889
|
$ZodString.init(inst, def);
|
|
3458
4890
|
_ZodString.init(inst, def);
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
4891
|
+
}, {
|
|
4892
|
+
email(params) {
|
|
4893
|
+
return this.check(/* @__PURE__ */ _email(ZodEmail, params));
|
|
4894
|
+
},
|
|
4895
|
+
url(params) {
|
|
4896
|
+
return this.check(/* @__PURE__ */ _url(ZodURL, params));
|
|
4897
|
+
},
|
|
4898
|
+
jwt(params) {
|
|
4899
|
+
return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
|
|
4900
|
+
},
|
|
4901
|
+
emoji(params) {
|
|
4902
|
+
return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
|
|
4903
|
+
},
|
|
4904
|
+
guid(params) {
|
|
4905
|
+
return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
|
|
4906
|
+
},
|
|
4907
|
+
uuid(params) {
|
|
4908
|
+
return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
|
|
4909
|
+
},
|
|
4910
|
+
uuidv4(params) {
|
|
4911
|
+
return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
|
|
4912
|
+
},
|
|
4913
|
+
uuidv6(params) {
|
|
4914
|
+
return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
|
|
4915
|
+
},
|
|
4916
|
+
uuidv7(params) {
|
|
4917
|
+
return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
|
|
4918
|
+
},
|
|
4919
|
+
nanoid(params) {
|
|
4920
|
+
return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
|
|
4921
|
+
},
|
|
4922
|
+
cuid(params) {
|
|
4923
|
+
return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
|
|
4924
|
+
},
|
|
4925
|
+
cuid2(params) {
|
|
4926
|
+
return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
|
|
4927
|
+
},
|
|
4928
|
+
ulid(params) {
|
|
4929
|
+
return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
|
|
4930
|
+
},
|
|
4931
|
+
base64(params) {
|
|
4932
|
+
return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
|
|
4933
|
+
},
|
|
4934
|
+
base64url(params) {
|
|
4935
|
+
return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
|
|
4936
|
+
},
|
|
4937
|
+
xid(params) {
|
|
4938
|
+
return this.check(/* @__PURE__ */ _xid(ZodXID, params));
|
|
4939
|
+
},
|
|
4940
|
+
ksuid(params) {
|
|
4941
|
+
return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
|
|
4942
|
+
},
|
|
4943
|
+
ipv4(params) {
|
|
4944
|
+
return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
|
|
4945
|
+
},
|
|
4946
|
+
ipv6(params) {
|
|
4947
|
+
return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
|
|
4948
|
+
},
|
|
4949
|
+
cidrv4(params) {
|
|
4950
|
+
return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
|
|
4951
|
+
},
|
|
4952
|
+
cidrv6(params) {
|
|
4953
|
+
return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
|
|
4954
|
+
},
|
|
4955
|
+
e164(params) {
|
|
4956
|
+
return this.check(/* @__PURE__ */ _e164(ZodE164, params));
|
|
4957
|
+
},
|
|
4958
|
+
datetime(params) {
|
|
4959
|
+
return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
|
|
4960
|
+
},
|
|
4961
|
+
date(params) {
|
|
4962
|
+
return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
|
|
4963
|
+
},
|
|
4964
|
+
time(params) {
|
|
4965
|
+
return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
|
|
4966
|
+
},
|
|
4967
|
+
duration(params) {
|
|
4968
|
+
return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
|
|
4969
|
+
}
|
|
3486
4970
|
});
|
|
3487
4971
|
function string(params) {
|
|
3488
4972
|
return /* @__PURE__ */ _string(ZodString, params);
|
|
@@ -3491,6 +4975,22 @@ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def
|
|
|
3491
4975
|
$ZodStringFormat.init(inst, def);
|
|
3492
4976
|
_ZodString.init(inst, def);
|
|
3493
4977
|
});
|
|
4978
|
+
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
4979
|
+
$ZodISODateTime.init(inst, def);
|
|
4980
|
+
ZodStringFormat.init(inst, def);
|
|
4981
|
+
});
|
|
4982
|
+
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
|
|
4983
|
+
$ZodISODate.init(inst, def);
|
|
4984
|
+
ZodStringFormat.init(inst, def);
|
|
4985
|
+
});
|
|
4986
|
+
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
|
|
4987
|
+
$ZodISOTime.init(inst, def);
|
|
4988
|
+
ZodStringFormat.init(inst, def);
|
|
4989
|
+
});
|
|
4990
|
+
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
|
|
4991
|
+
$ZodISODuration.init(inst, def);
|
|
4992
|
+
ZodStringFormat.init(inst, def);
|
|
4993
|
+
});
|
|
3494
4994
|
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
|
|
3495
4995
|
$ZodEmail.init(inst, def);
|
|
3496
4996
|
ZodStringFormat.init(inst, def);
|
|
@@ -3515,6 +5015,11 @@ const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
|
|
|
3515
5015
|
$ZodNanoID.init(inst, def);
|
|
3516
5016
|
ZodStringFormat.init(inst, def);
|
|
3517
5017
|
});
|
|
5018
|
+
/**
|
|
5019
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
5020
|
+
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
5021
|
+
* See https://github.com/paralleldrive/cuid.
|
|
5022
|
+
*/
|
|
3518
5023
|
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
|
|
3519
5024
|
$ZodCUID.init(inst, def);
|
|
3520
5025
|
ZodStringFormat.init(inst, def);
|
|
@@ -3571,28 +5076,68 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
|
|
|
3571
5076
|
$ZodNumber.init(inst, def);
|
|
3572
5077
|
ZodType.init(inst, def);
|
|
3573
5078
|
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
3574
|
-
inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
|
|
3575
|
-
inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
|
|
3576
|
-
inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
|
|
3577
|
-
inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
|
|
3578
|
-
inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
|
|
3579
|
-
inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
|
|
3580
|
-
inst.int = (params) => inst.check(int(params));
|
|
3581
|
-
inst.safe = (params) => inst.check(int(params));
|
|
3582
|
-
inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(0, params));
|
|
3583
|
-
inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(0, params));
|
|
3584
|
-
inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(0, params));
|
|
3585
|
-
inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(0, params));
|
|
3586
|
-
inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3587
|
-
inst.step = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
3588
|
-
inst.finite = () => inst;
|
|
3589
|
-
const bag = inst._zod.bag;
|
|
3590
|
-
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
3591
|
-
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
3592
|
-
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
|
|
3593
5079
|
inst.isFinite = true;
|
|
3594
|
-
|
|
3595
|
-
|
|
5080
|
+
}, /*@__PURE__*/ derived({
|
|
5081
|
+
minValue: (inst) => {
|
|
5082
|
+
const { minimum, exclusiveMinimum } = aggregateChecks(inst);
|
|
5083
|
+
return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
|
|
5084
|
+
},
|
|
5085
|
+
maxValue: (inst) => {
|
|
5086
|
+
const { maximum, exclusiveMaximum } = aggregateChecks(inst);
|
|
5087
|
+
return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
|
|
5088
|
+
},
|
|
5089
|
+
isInt: (inst) => {
|
|
5090
|
+
const { isInt, multipleOf } = aggregateChecks(inst);
|
|
5091
|
+
return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
|
|
5092
|
+
},
|
|
5093
|
+
format: (inst) => aggregateChecks(inst).format ?? null
|
|
5094
|
+
}, {
|
|
5095
|
+
gt(value, params) {
|
|
5096
|
+
return this.check(/* @__PURE__ */ _gt(value, params));
|
|
5097
|
+
},
|
|
5098
|
+
gte(value, params) {
|
|
5099
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
5100
|
+
},
|
|
5101
|
+
min(value, params) {
|
|
5102
|
+
return this.check(/* @__PURE__ */ _gte(value, params));
|
|
5103
|
+
},
|
|
5104
|
+
lt(value, params) {
|
|
5105
|
+
return this.check(/* @__PURE__ */ _lt(value, params));
|
|
5106
|
+
},
|
|
5107
|
+
lte(value, params) {
|
|
5108
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
5109
|
+
},
|
|
5110
|
+
max(value, params) {
|
|
5111
|
+
return this.check(/* @__PURE__ */ _lte(value, params));
|
|
5112
|
+
},
|
|
5113
|
+
int(params) {
|
|
5114
|
+
return this.check(int(params));
|
|
5115
|
+
},
|
|
5116
|
+
safe(params) {
|
|
5117
|
+
return this.check(int(params));
|
|
5118
|
+
},
|
|
5119
|
+
positive(params) {
|
|
5120
|
+
return this.check(/* @__PURE__ */ _gt(0, params));
|
|
5121
|
+
},
|
|
5122
|
+
nonnegative(params) {
|
|
5123
|
+
return this.check(/* @__PURE__ */ _gte(0, params));
|
|
5124
|
+
},
|
|
5125
|
+
negative(params) {
|
|
5126
|
+
return this.check(/* @__PURE__ */ _lt(0, params));
|
|
5127
|
+
},
|
|
5128
|
+
nonpositive(params) {
|
|
5129
|
+
return this.check(/* @__PURE__ */ _lte(0, params));
|
|
5130
|
+
},
|
|
5131
|
+
multipleOf(value, params) {
|
|
5132
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
5133
|
+
},
|
|
5134
|
+
step(value, params) {
|
|
5135
|
+
return this.check(/* @__PURE__ */ _multipleOf(value, params));
|
|
5136
|
+
},
|
|
5137
|
+
finite() {
|
|
5138
|
+
return this;
|
|
5139
|
+
}
|
|
5140
|
+
}));
|
|
3596
5141
|
function number(params) {
|
|
3597
5142
|
return /* @__PURE__ */ _number(ZodNumber, params);
|
|
3598
5143
|
}
|
|
@@ -3628,58 +5173,80 @@ function never(params) {
|
|
|
3628
5173
|
return /* @__PURE__ */ _never(ZodNever, params);
|
|
3629
5174
|
}
|
|
3630
5175
|
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
|
|
5176
|
+
_ensureDefaultMemoizer();
|
|
3631
5177
|
$ZodArray.init(inst, def);
|
|
3632
5178
|
ZodType.init(inst, def);
|
|
3633
5179
|
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
3634
5180
|
inst.element = def.element;
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
5181
|
+
}, {
|
|
5182
|
+
min(n, params) {
|
|
5183
|
+
return this.check(/* @__PURE__ */ _minLength(n, params));
|
|
5184
|
+
},
|
|
5185
|
+
nonempty(params) {
|
|
5186
|
+
return this.check(/* @__PURE__ */ _minLength(1, params));
|
|
5187
|
+
},
|
|
5188
|
+
max(n, params) {
|
|
5189
|
+
return this.check(/* @__PURE__ */ _maxLength(n, params));
|
|
5190
|
+
},
|
|
5191
|
+
length(n, params) {
|
|
5192
|
+
return this.check(/* @__PURE__ */ _length(n, params));
|
|
5193
|
+
},
|
|
5194
|
+
unwrap() {
|
|
5195
|
+
return this.element;
|
|
5196
|
+
}
|
|
3640
5197
|
});
|
|
3641
5198
|
function array(element, params) {
|
|
3642
5199
|
return /* @__PURE__ */ _array(ZodArray, element, params);
|
|
3643
5200
|
}
|
|
3644
5201
|
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
5202
|
+
_ensureDefaultMemoizer();
|
|
3645
5203
|
$ZodObjectJIT.init(inst, def);
|
|
3646
5204
|
ZodType.init(inst, def);
|
|
3647
5205
|
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
catchall
|
|
3655
|
-
}
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
catchall:
|
|
3667
|
-
}
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
5206
|
+
installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
5207
|
+
}, {
|
|
5208
|
+
keyof() {
|
|
5209
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
5210
|
+
},
|
|
5211
|
+
catchall(catchall) {
|
|
5212
|
+
return this.clone(mergeDefs(this._zod.def, { catchall }));
|
|
5213
|
+
},
|
|
5214
|
+
passthrough() {
|
|
5215
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5216
|
+
},
|
|
5217
|
+
loose() {
|
|
5218
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
|
|
5219
|
+
},
|
|
5220
|
+
strict() {
|
|
5221
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
|
|
5222
|
+
},
|
|
5223
|
+
strip() {
|
|
5224
|
+
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
|
|
5225
|
+
},
|
|
5226
|
+
extend(incoming) {
|
|
5227
|
+
return extend(this, incoming);
|
|
5228
|
+
},
|
|
5229
|
+
safeExtend(incoming) {
|
|
5230
|
+
return safeExtend(this, incoming);
|
|
5231
|
+
},
|
|
5232
|
+
merge(other) {
|
|
5233
|
+
return merge(this, other);
|
|
5234
|
+
},
|
|
5235
|
+
pick(mask) {
|
|
5236
|
+
return pick(this, mask);
|
|
5237
|
+
},
|
|
5238
|
+
omit(mask) {
|
|
5239
|
+
return omit(this, mask);
|
|
5240
|
+
},
|
|
5241
|
+
partial(...args) {
|
|
5242
|
+
return partial(ZodOptional, this, args[0]);
|
|
5243
|
+
},
|
|
5244
|
+
exactPartial(...args) {
|
|
5245
|
+
return partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
5246
|
+
},
|
|
5247
|
+
required(...args) {
|
|
5248
|
+
return required(ZodNonOptional, this, args[0]);
|
|
5249
|
+
}
|
|
3683
5250
|
});
|
|
3684
5251
|
function strictObject(shape, params) {
|
|
3685
5252
|
return new ZodObject({
|
|
@@ -3723,6 +5290,7 @@ function intersection(left, right) {
|
|
|
3723
5290
|
});
|
|
3724
5291
|
}
|
|
3725
5292
|
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
5293
|
+
_ensureDefaultMemoizer();
|
|
3726
5294
|
$ZodRecord.init(inst, def);
|
|
3727
5295
|
ZodType.init(inst, def);
|
|
3728
5296
|
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
@@ -3730,6 +5298,12 @@ const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
|
3730
5298
|
inst.valueType = def.valueType;
|
|
3731
5299
|
});
|
|
3732
5300
|
function record(keyType, valueType, params) {
|
|
5301
|
+
if (!valueType || !valueType._zod) return new ZodRecord({
|
|
5302
|
+
type: "record",
|
|
5303
|
+
keyType: string(),
|
|
5304
|
+
valueType: keyType,
|
|
5305
|
+
...normalizeParams(valueType)
|
|
5306
|
+
});
|
|
3733
5307
|
return new ZodRecord({
|
|
3734
5308
|
type: "record",
|
|
3735
5309
|
keyType,
|
|
@@ -3742,7 +5316,7 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
|
|
|
3742
5316
|
ZodType.init(inst, def);
|
|
3743
5317
|
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
3744
5318
|
inst.enum = def.entries;
|
|
3745
|
-
inst.options =
|
|
5319
|
+
inst.options = [...inst._zod.values];
|
|
3746
5320
|
const keys = new Set(Object.keys(def.entries));
|
|
3747
5321
|
inst.extract = (values, params) => {
|
|
3748
5322
|
const newEntries = {};
|
|
@@ -3793,6 +5367,7 @@ function literal(value, params) {
|
|
|
3793
5367
|
});
|
|
3794
5368
|
}
|
|
3795
5369
|
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
5370
|
+
_ensureDefaultMemoizer();
|
|
3796
5371
|
$ZodTransform.init(inst, def);
|
|
3797
5372
|
ZodType.init(inst, def);
|
|
3798
5373
|
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
@@ -3804,7 +5379,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
|
|
|
3804
5379
|
const _issue = issue$1;
|
|
3805
5380
|
if (_issue.fatal) _issue.continue = false;
|
|
3806
5381
|
_issue.code ?? (_issue.code = "custom");
|
|
3807
|
-
|
|
5382
|
+
if (!("input" in _issue)) _issue.input = payload.value;
|
|
3808
5383
|
_issue.inst ?? (_issue.inst = inst);
|
|
3809
5384
|
payload.issues.push(issue(_issue));
|
|
3810
5385
|
}
|
|
@@ -3915,7 +5490,7 @@ function _catch(innerType, catchValue) {
|
|
|
3915
5490
|
return new ZodCatch({
|
|
3916
5491
|
type: "catch",
|
|
3917
5492
|
innerType,
|
|
3918
|
-
catchValue: typeof catchValue === "function" ? catchValue : ()
|
|
5493
|
+
catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
|
|
3919
5494
|
});
|
|
3920
5495
|
}
|
|
3921
5496
|
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
|
|
@@ -3952,11 +5527,11 @@ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
|
|
|
3952
5527
|
function refine(fn, _params = {}) {
|
|
3953
5528
|
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
|
|
3954
5529
|
}
|
|
3955
|
-
function superRefine(fn) {
|
|
3956
|
-
return /* @__PURE__ */ _superRefine(fn);
|
|
5530
|
+
function superRefine(fn, params) {
|
|
5531
|
+
return /* @__PURE__ */ _superRefine(fn, params);
|
|
3957
5532
|
}
|
|
3958
5533
|
//#endregion
|
|
3959
5534
|
export { looseObject as a, strictObject as c, unknown as d, prettifyError as f, literal as i, string as l, array as n, number as o, boolean as r, record as s, _enum as t, union as u };
|
|
3960
5535
|
|
|
3961
|
-
//# sourceMappingURL=schemas-
|
|
3962
|
-
//# debugId=
|
|
5536
|
+
//# sourceMappingURL=schemas-BQSPev1x.mjs.map
|
|
5537
|
+
//# debugId=cd23951b-05b2-5ced-9ed3-1edf36cf8d22
|