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