@mcpc-tech/core 0.3.13 → 0.3.14
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/index.cjs +503 -114
- package/index.mjs +503 -114
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -657,6 +657,7 @@ __export(util_exports, {
|
|
|
657
657
|
objectClone: () => objectClone,
|
|
658
658
|
omit: () => omit,
|
|
659
659
|
optionalKeys: () => optionalKeys,
|
|
660
|
+
parsedType: () => parsedType,
|
|
660
661
|
partial: () => partial,
|
|
661
662
|
pick: () => pick,
|
|
662
663
|
prefixIssues: () => prefixIssues,
|
|
@@ -989,6 +990,11 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
989
990
|
};
|
|
990
991
|
function pick(schema, mask) {
|
|
991
992
|
const currDef = schema._zod.def;
|
|
993
|
+
const checks = currDef.checks;
|
|
994
|
+
const hasChecks = checks && checks.length > 0;
|
|
995
|
+
if (hasChecks) {
|
|
996
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
997
|
+
}
|
|
992
998
|
const def = mergeDefs(schema._zod.def, {
|
|
993
999
|
get shape() {
|
|
994
1000
|
const newShape = {};
|
|
@@ -1009,6 +1015,11 @@ function pick(schema, mask) {
|
|
|
1009
1015
|
}
|
|
1010
1016
|
function omit(schema, mask) {
|
|
1011
1017
|
const currDef = schema._zod.def;
|
|
1018
|
+
const checks = currDef.checks;
|
|
1019
|
+
const hasChecks = checks && checks.length > 0;
|
|
1020
|
+
if (hasChecks) {
|
|
1021
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1022
|
+
}
|
|
1012
1023
|
const def = mergeDefs(schema._zod.def, {
|
|
1013
1024
|
get shape() {
|
|
1014
1025
|
const newShape = { ...schema._zod.def.shape };
|
|
@@ -1034,15 +1045,19 @@ function extend(schema, shape) {
|
|
|
1034
1045
|
const checks = schema._zod.def.checks;
|
|
1035
1046
|
const hasChecks = checks && checks.length > 0;
|
|
1036
1047
|
if (hasChecks) {
|
|
1037
|
-
|
|
1048
|
+
const existingShape = schema._zod.def.shape;
|
|
1049
|
+
for (const key in shape) {
|
|
1050
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
1051
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1038
1054
|
}
|
|
1039
1055
|
const def = mergeDefs(schema._zod.def, {
|
|
1040
1056
|
get shape() {
|
|
1041
1057
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
1042
1058
|
assignProp(this, "shape", _shape);
|
|
1043
1059
|
return _shape;
|
|
1044
|
-
}
|
|
1045
|
-
checks: []
|
|
1060
|
+
}
|
|
1046
1061
|
});
|
|
1047
1062
|
return clone(schema, def);
|
|
1048
1063
|
}
|
|
@@ -1050,15 +1065,13 @@ function safeExtend(schema, shape) {
|
|
|
1050
1065
|
if (!isPlainObject(shape)) {
|
|
1051
1066
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1052
1067
|
}
|
|
1053
|
-
const def = {
|
|
1054
|
-
...schema._zod.def,
|
|
1068
|
+
const def = mergeDefs(schema._zod.def, {
|
|
1055
1069
|
get shape() {
|
|
1056
1070
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
1057
1071
|
assignProp(this, "shape", _shape);
|
|
1058
1072
|
return _shape;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
};
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1062
1075
|
return clone(schema, def);
|
|
1063
1076
|
}
|
|
1064
1077
|
function merge(a, b) {
|
|
@@ -1077,6 +1090,12 @@ function merge(a, b) {
|
|
|
1077
1090
|
return clone(a, def);
|
|
1078
1091
|
}
|
|
1079
1092
|
function partial(Class2, schema, mask) {
|
|
1093
|
+
const currDef = schema._zod.def;
|
|
1094
|
+
const checks = currDef.checks;
|
|
1095
|
+
const hasChecks = checks && checks.length > 0;
|
|
1096
|
+
if (hasChecks) {
|
|
1097
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1098
|
+
}
|
|
1080
1099
|
const def = mergeDefs(schema._zod.def, {
|
|
1081
1100
|
get shape() {
|
|
1082
1101
|
const oldShape = schema._zod.def.shape;
|
|
@@ -1135,8 +1154,7 @@ function required(Class2, schema, mask) {
|
|
|
1135
1154
|
}
|
|
1136
1155
|
assignProp(this, "shape", shape);
|
|
1137
1156
|
return shape;
|
|
1138
|
-
}
|
|
1139
|
-
checks: []
|
|
1157
|
+
}
|
|
1140
1158
|
});
|
|
1141
1159
|
return clone(schema, def);
|
|
1142
1160
|
}
|
|
@@ -1190,6 +1208,27 @@ function getLengthableOrigin(input) {
|
|
|
1190
1208
|
return "string";
|
|
1191
1209
|
return "unknown";
|
|
1192
1210
|
}
|
|
1211
|
+
function parsedType(data) {
|
|
1212
|
+
const t = typeof data;
|
|
1213
|
+
switch (t) {
|
|
1214
|
+
case "number": {
|
|
1215
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
1216
|
+
}
|
|
1217
|
+
case "object": {
|
|
1218
|
+
if (data === null) {
|
|
1219
|
+
return "null";
|
|
1220
|
+
}
|
|
1221
|
+
if (Array.isArray(data)) {
|
|
1222
|
+
return "array";
|
|
1223
|
+
}
|
|
1224
|
+
const obj = data;
|
|
1225
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
1226
|
+
return obj.constructor.name;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return t;
|
|
1231
|
+
}
|
|
1193
1232
|
function issue(...args) {
|
|
1194
1233
|
const [iss, input, inst] = args;
|
|
1195
1234
|
if (typeof iss === "string") {
|
|
@@ -1496,7 +1535,7 @@ var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/
|
|
|
1496
1535
|
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
1497
1536
|
var hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
1498
1537
|
var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
1499
|
-
var e164 = /^\+
|
|
1538
|
+
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
1500
1539
|
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
1501
1540
|
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
1502
1541
|
function timeSource(args) {
|
|
@@ -1523,7 +1562,7 @@ var string = (params) => {
|
|
|
1523
1562
|
};
|
|
1524
1563
|
var bigint = /^-?\d+n?$/;
|
|
1525
1564
|
var integer = /^-?\d+$/;
|
|
1526
|
-
var number = /^-?\d+(?:\.\d+)
|
|
1565
|
+
var number = /^-?\d+(?:\.\d+)?$/;
|
|
1527
1566
|
var boolean = /^(?:true|false)$/i;
|
|
1528
1567
|
var _null = /^null$/i;
|
|
1529
1568
|
var _undefined = /^undefined$/i;
|
|
@@ -1584,7 +1623,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
|
|
|
1584
1623
|
payload.issues.push({
|
|
1585
1624
|
origin,
|
|
1586
1625
|
code: "too_big",
|
|
1587
|
-
maximum: def.value,
|
|
1626
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1588
1627
|
input: payload.value,
|
|
1589
1628
|
inclusive: def.inclusive,
|
|
1590
1629
|
inst,
|
|
@@ -1612,7 +1651,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
1612
1651
|
payload.issues.push({
|
|
1613
1652
|
origin,
|
|
1614
1653
|
code: "too_small",
|
|
1615
|
-
minimum: def.value,
|
|
1654
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1616
1655
|
input: payload.value,
|
|
1617
1656
|
inclusive: def.inclusive,
|
|
1618
1657
|
inst,
|
|
@@ -1679,6 +1718,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1679
1718
|
note: "Integers must be within the safe integer range.",
|
|
1680
1719
|
inst,
|
|
1681
1720
|
origin,
|
|
1721
|
+
inclusive: true,
|
|
1682
1722
|
continue: !def.abort
|
|
1683
1723
|
});
|
|
1684
1724
|
} else {
|
|
@@ -1689,6 +1729,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1689
1729
|
note: "Integers must be within the safe integer range.",
|
|
1690
1730
|
inst,
|
|
1691
1731
|
origin,
|
|
1732
|
+
inclusive: true,
|
|
1692
1733
|
continue: !def.abort
|
|
1693
1734
|
});
|
|
1694
1735
|
}
|
|
@@ -1712,7 +1753,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1712
1753
|
input,
|
|
1713
1754
|
code: "too_big",
|
|
1714
1755
|
maximum,
|
|
1715
|
-
|
|
1756
|
+
inclusive: true,
|
|
1757
|
+
inst,
|
|
1758
|
+
continue: !def.abort
|
|
1716
1759
|
});
|
|
1717
1760
|
}
|
|
1718
1761
|
};
|
|
@@ -1745,7 +1788,9 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
1745
1788
|
input,
|
|
1746
1789
|
code: "too_big",
|
|
1747
1790
|
maximum,
|
|
1748
|
-
|
|
1791
|
+
inclusive: true,
|
|
1792
|
+
inst,
|
|
1793
|
+
continue: !def.abort
|
|
1749
1794
|
});
|
|
1750
1795
|
}
|
|
1751
1796
|
};
|
|
@@ -2133,8 +2178,8 @@ var Doc = class {
|
|
|
2133
2178
|
// __mcpc__core_latest/node_modules/zod/v4/core/versions.js
|
|
2134
2179
|
var version = {
|
|
2135
2180
|
major: 4,
|
|
2136
|
-
minor:
|
|
2137
|
-
patch:
|
|
2181
|
+
minor: 3,
|
|
2182
|
+
patch: 5
|
|
2138
2183
|
};
|
|
2139
2184
|
|
|
2140
2185
|
// __mcpc__core_latest/node_modules/zod/v4/core/schemas.js
|
|
@@ -2234,7 +2279,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2234
2279
|
return runChecks(result, checks, ctx);
|
|
2235
2280
|
};
|
|
2236
2281
|
}
|
|
2237
|
-
inst
|
|
2282
|
+
defineLazy(inst, "~standard", () => ({
|
|
2238
2283
|
validate: (value) => {
|
|
2239
2284
|
try {
|
|
2240
2285
|
const r = safeParse(inst, value);
|
|
@@ -2245,7 +2290,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2245
2290
|
},
|
|
2246
2291
|
vendor: "zod",
|
|
2247
2292
|
version: 1
|
|
2248
|
-
};
|
|
2293
|
+
}));
|
|
2249
2294
|
});
|
|
2250
2295
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
2251
2296
|
$ZodType.init(inst, def);
|
|
@@ -2779,8 +2824,11 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
2779
2824
|
return payload;
|
|
2780
2825
|
};
|
|
2781
2826
|
});
|
|
2782
|
-
function handlePropertyResult(result, final, key, input) {
|
|
2827
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
2783
2828
|
if (result.issues.length) {
|
|
2829
|
+
if (isOptionalOut && !(key in input)) {
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2784
2832
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
2785
2833
|
}
|
|
2786
2834
|
if (result.value === void 0) {
|
|
@@ -2812,6 +2860,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2812
2860
|
const keySet = def.keySet;
|
|
2813
2861
|
const _catchall = def.catchall._zod;
|
|
2814
2862
|
const t = _catchall.def.type;
|
|
2863
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
2815
2864
|
for (const key in input) {
|
|
2816
2865
|
if (keySet.has(key))
|
|
2817
2866
|
continue;
|
|
@@ -2821,9 +2870,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2821
2870
|
}
|
|
2822
2871
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
2823
2872
|
if (r instanceof Promise) {
|
|
2824
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
2873
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
2825
2874
|
} else {
|
|
2826
|
-
handlePropertyResult(r, payload, key, input);
|
|
2875
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
2827
2876
|
}
|
|
2828
2877
|
}
|
|
2829
2878
|
if (unrecognized.length) {
|
|
@@ -2889,11 +2938,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2889
2938
|
const shape = value.shape;
|
|
2890
2939
|
for (const key of value.keys) {
|
|
2891
2940
|
const el = shape[key];
|
|
2941
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
2892
2942
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2893
2943
|
if (r instanceof Promise) {
|
|
2894
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
2944
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
2895
2945
|
} else {
|
|
2896
|
-
handlePropertyResult(r, payload, key, input);
|
|
2946
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
2897
2947
|
}
|
|
2898
2948
|
}
|
|
2899
2949
|
if (!catchall) {
|
|
@@ -2923,8 +2973,31 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2923
2973
|
for (const key of normalized.keys) {
|
|
2924
2974
|
const id = ids[key];
|
|
2925
2975
|
const k = esc(key);
|
|
2976
|
+
const schema = shape[key];
|
|
2977
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2926
2978
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2927
|
-
|
|
2979
|
+
if (isOptionalOut) {
|
|
2980
|
+
doc.write(`
|
|
2981
|
+
if (${id}.issues.length) {
|
|
2982
|
+
if (${k} in input) {
|
|
2983
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2984
|
+
...iss,
|
|
2985
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2986
|
+
})));
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
if (${id}.value === undefined) {
|
|
2991
|
+
if (${k} in input) {
|
|
2992
|
+
newResult[${k}] = undefined;
|
|
2993
|
+
}
|
|
2994
|
+
} else {
|
|
2995
|
+
newResult[${k}] = ${id}.value;
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2998
|
+
`);
|
|
2999
|
+
} else {
|
|
3000
|
+
doc.write(`
|
|
2928
3001
|
if (${id}.issues.length) {
|
|
2929
3002
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2930
3003
|
...iss,
|
|
@@ -2932,7 +3005,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2932
3005
|
})));
|
|
2933
3006
|
}
|
|
2934
3007
|
|
|
2935
|
-
|
|
2936
3008
|
if (${id}.value === undefined) {
|
|
2937
3009
|
if (${k} in input) {
|
|
2938
3010
|
newResult[${k}] = undefined;
|
|
@@ -2942,6 +3014,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2942
3014
|
}
|
|
2943
3015
|
|
|
2944
3016
|
`);
|
|
3017
|
+
}
|
|
2945
3018
|
}
|
|
2946
3019
|
doc.write(`payload.value = newResult;`);
|
|
2947
3020
|
doc.write(`return payload;`);
|
|
@@ -3224,11 +3297,34 @@ function mergeValues(a, b) {
|
|
|
3224
3297
|
return { valid: false, mergeErrorPath: [] };
|
|
3225
3298
|
}
|
|
3226
3299
|
function handleIntersectionResults(result, left, right) {
|
|
3227
|
-
|
|
3228
|
-
|
|
3300
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
3301
|
+
let unrecIssue;
|
|
3302
|
+
for (const iss of left.issues) {
|
|
3303
|
+
if (iss.code === "unrecognized_keys") {
|
|
3304
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
3305
|
+
for (const k of iss.keys) {
|
|
3306
|
+
if (!unrecKeys.has(k))
|
|
3307
|
+
unrecKeys.set(k, {});
|
|
3308
|
+
unrecKeys.get(k).l = true;
|
|
3309
|
+
}
|
|
3310
|
+
} else {
|
|
3311
|
+
result.issues.push(iss);
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
for (const iss of right.issues) {
|
|
3315
|
+
if (iss.code === "unrecognized_keys") {
|
|
3316
|
+
for (const k of iss.keys) {
|
|
3317
|
+
if (!unrecKeys.has(k))
|
|
3318
|
+
unrecKeys.set(k, {});
|
|
3319
|
+
unrecKeys.get(k).r = true;
|
|
3320
|
+
}
|
|
3321
|
+
} else {
|
|
3322
|
+
result.issues.push(iss);
|
|
3323
|
+
}
|
|
3229
3324
|
}
|
|
3230
|
-
|
|
3231
|
-
|
|
3325
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
3326
|
+
if (bothKeys.length && unrecIssue) {
|
|
3327
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
3232
3328
|
}
|
|
3233
3329
|
if (aborted(result))
|
|
3234
3330
|
return result;
|
|
@@ -3262,7 +3358,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3262
3358
|
const tooSmall = input.length < optStart - 1;
|
|
3263
3359
|
if (tooBig || tooSmall) {
|
|
3264
3360
|
payload.issues.push({
|
|
3265
|
-
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
3361
|
+
...tooBig ? { code: "too_big", maximum: items.length, inclusive: true } : { code: "too_small", minimum: items.length },
|
|
3266
3362
|
input,
|
|
3267
3363
|
inst,
|
|
3268
3364
|
origin: "array"
|
|
@@ -3370,10 +3466,20 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3370
3466
|
for (const key of Reflect.ownKeys(input)) {
|
|
3371
3467
|
if (key === "__proto__")
|
|
3372
3468
|
continue;
|
|
3373
|
-
|
|
3469
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
3374
3470
|
if (keyResult instanceof Promise) {
|
|
3375
3471
|
throw new Error("Async schemas not supported in object keys currently");
|
|
3376
3472
|
}
|
|
3473
|
+
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length && keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
|
|
3474
|
+
if (checkNumericKey) {
|
|
3475
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
3476
|
+
if (retryResult instanceof Promise) {
|
|
3477
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
3478
|
+
}
|
|
3479
|
+
if (retryResult.issues.length === 0) {
|
|
3480
|
+
keyResult = retryResult;
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3377
3483
|
if (keyResult.issues.length) {
|
|
3378
3484
|
if (def.mode === "loose") {
|
|
3379
3485
|
payload.value[key] = input[key];
|
|
@@ -3613,6 +3719,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
3613
3719
|
return def.innerType._zod.run(payload, ctx);
|
|
3614
3720
|
};
|
|
3615
3721
|
});
|
|
3722
|
+
var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
3723
|
+
$ZodOptional.init(inst, def);
|
|
3724
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3725
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
3726
|
+
inst._zod.parse = (payload, ctx) => {
|
|
3727
|
+
return def.innerType._zod.run(payload, ctx);
|
|
3728
|
+
};
|
|
3729
|
+
});
|
|
3616
3730
|
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
3617
3731
|
$ZodType.init(inst, def);
|
|
3618
3732
|
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
@@ -3891,7 +4005,7 @@ var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (i
|
|
|
3891
4005
|
payload.issues.push({
|
|
3892
4006
|
input: payload.value,
|
|
3893
4007
|
inst,
|
|
3894
|
-
expected: "
|
|
4008
|
+
expected: "string",
|
|
3895
4009
|
code: "invalid_type"
|
|
3896
4010
|
});
|
|
3897
4011
|
return payload;
|
|
@@ -4040,37 +4154,18 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
4040
4154
|
}
|
|
4041
4155
|
|
|
4042
4156
|
// __mcpc__core_latest/node_modules/zod/v4/locales/en.js
|
|
4043
|
-
var parsedType = (data) => {
|
|
4044
|
-
const t = typeof data;
|
|
4045
|
-
switch (t) {
|
|
4046
|
-
case "number": {
|
|
4047
|
-
return Number.isNaN(data) ? "NaN" : "number";
|
|
4048
|
-
}
|
|
4049
|
-
case "object": {
|
|
4050
|
-
if (Array.isArray(data)) {
|
|
4051
|
-
return "array";
|
|
4052
|
-
}
|
|
4053
|
-
if (data === null) {
|
|
4054
|
-
return "null";
|
|
4055
|
-
}
|
|
4056
|
-
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
4057
|
-
return data.constructor.name;
|
|
4058
|
-
}
|
|
4059
|
-
}
|
|
4060
|
-
}
|
|
4061
|
-
return t;
|
|
4062
|
-
};
|
|
4063
4157
|
var error = () => {
|
|
4064
4158
|
const Sizable = {
|
|
4065
4159
|
string: { unit: "characters", verb: "to have" },
|
|
4066
4160
|
file: { unit: "bytes", verb: "to have" },
|
|
4067
4161
|
array: { unit: "items", verb: "to have" },
|
|
4068
|
-
set: { unit: "items", verb: "to have" }
|
|
4162
|
+
set: { unit: "items", verb: "to have" },
|
|
4163
|
+
map: { unit: "entries", verb: "to have" }
|
|
4069
4164
|
};
|
|
4070
4165
|
function getSizing(origin) {
|
|
4071
4166
|
return Sizable[origin] ?? null;
|
|
4072
4167
|
}
|
|
4073
|
-
const
|
|
4168
|
+
const FormatDictionary = {
|
|
4074
4169
|
regex: "input",
|
|
4075
4170
|
email: "email address",
|
|
4076
4171
|
url: "URL",
|
|
@@ -4101,10 +4196,19 @@ var error = () => {
|
|
|
4101
4196
|
jwt: "JWT",
|
|
4102
4197
|
template_literal: "input"
|
|
4103
4198
|
};
|
|
4199
|
+
const TypeDictionary = {
|
|
4200
|
+
// Compatibility: "nan" -> "NaN" for display
|
|
4201
|
+
nan: "NaN"
|
|
4202
|
+
// All other type names omitted - they fall back to raw values via ?? operator
|
|
4203
|
+
};
|
|
4104
4204
|
return (issue2) => {
|
|
4105
4205
|
switch (issue2.code) {
|
|
4106
|
-
case "invalid_type":
|
|
4107
|
-
|
|
4206
|
+
case "invalid_type": {
|
|
4207
|
+
const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
|
|
4208
|
+
const receivedType = parsedType(issue2.input);
|
|
4209
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
4210
|
+
return `Invalid input: expected ${expected}, received ${received}`;
|
|
4211
|
+
}
|
|
4108
4212
|
case "invalid_value":
|
|
4109
4213
|
if (issue2.values.length === 1)
|
|
4110
4214
|
return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
|
|
@@ -4135,7 +4239,7 @@ var error = () => {
|
|
|
4135
4239
|
return `Invalid string: must include "${_issue.includes}"`;
|
|
4136
4240
|
if (_issue.format === "regex")
|
|
4137
4241
|
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
4138
|
-
return `Invalid ${
|
|
4242
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
|
|
4139
4243
|
}
|
|
4140
4244
|
case "not_multiple_of":
|
|
4141
4245
|
return `Invalid number: must be a multiple of ${issue2.divisor}`;
|
|
@@ -4171,9 +4275,6 @@ var $ZodRegistry = class {
|
|
|
4171
4275
|
const meta3 = _meta[0];
|
|
4172
4276
|
this._map.set(schema, meta3);
|
|
4173
4277
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
4174
|
-
if (this._idmap.has(meta3.id)) {
|
|
4175
|
-
throw new Error(`ID ${meta3.id} already exists in the registry`);
|
|
4176
|
-
}
|
|
4177
4278
|
this._idmap.set(meta3.id, schema);
|
|
4178
4279
|
}
|
|
4179
4280
|
return this;
|
|
@@ -4212,12 +4313,14 @@ function registry() {
|
|
|
4212
4313
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
4213
4314
|
|
|
4214
4315
|
// __mcpc__core_latest/node_modules/zod/v4/core/api.js
|
|
4316
|
+
// @__NO_SIDE_EFFECTS__
|
|
4215
4317
|
function _string(Class2, params) {
|
|
4216
4318
|
return new Class2({
|
|
4217
4319
|
type: "string",
|
|
4218
4320
|
...normalizeParams(params)
|
|
4219
4321
|
});
|
|
4220
4322
|
}
|
|
4323
|
+
// @__NO_SIDE_EFFECTS__
|
|
4221
4324
|
function _coercedString(Class2, params) {
|
|
4222
4325
|
return new Class2({
|
|
4223
4326
|
type: "string",
|
|
@@ -4225,6 +4328,7 @@ function _coercedString(Class2, params) {
|
|
|
4225
4328
|
...normalizeParams(params)
|
|
4226
4329
|
});
|
|
4227
4330
|
}
|
|
4331
|
+
// @__NO_SIDE_EFFECTS__
|
|
4228
4332
|
function _email(Class2, params) {
|
|
4229
4333
|
return new Class2({
|
|
4230
4334
|
type: "string",
|
|
@@ -4234,6 +4338,7 @@ function _email(Class2, params) {
|
|
|
4234
4338
|
...normalizeParams(params)
|
|
4235
4339
|
});
|
|
4236
4340
|
}
|
|
4341
|
+
// @__NO_SIDE_EFFECTS__
|
|
4237
4342
|
function _guid(Class2, params) {
|
|
4238
4343
|
return new Class2({
|
|
4239
4344
|
type: "string",
|
|
@@ -4243,6 +4348,7 @@ function _guid(Class2, params) {
|
|
|
4243
4348
|
...normalizeParams(params)
|
|
4244
4349
|
});
|
|
4245
4350
|
}
|
|
4351
|
+
// @__NO_SIDE_EFFECTS__
|
|
4246
4352
|
function _uuid(Class2, params) {
|
|
4247
4353
|
return new Class2({
|
|
4248
4354
|
type: "string",
|
|
@@ -4252,6 +4358,7 @@ function _uuid(Class2, params) {
|
|
|
4252
4358
|
...normalizeParams(params)
|
|
4253
4359
|
});
|
|
4254
4360
|
}
|
|
4361
|
+
// @__NO_SIDE_EFFECTS__
|
|
4255
4362
|
function _uuidv4(Class2, params) {
|
|
4256
4363
|
return new Class2({
|
|
4257
4364
|
type: "string",
|
|
@@ -4262,6 +4369,7 @@ function _uuidv4(Class2, params) {
|
|
|
4262
4369
|
...normalizeParams(params)
|
|
4263
4370
|
});
|
|
4264
4371
|
}
|
|
4372
|
+
// @__NO_SIDE_EFFECTS__
|
|
4265
4373
|
function _uuidv6(Class2, params) {
|
|
4266
4374
|
return new Class2({
|
|
4267
4375
|
type: "string",
|
|
@@ -4272,6 +4380,7 @@ function _uuidv6(Class2, params) {
|
|
|
4272
4380
|
...normalizeParams(params)
|
|
4273
4381
|
});
|
|
4274
4382
|
}
|
|
4383
|
+
// @__NO_SIDE_EFFECTS__
|
|
4275
4384
|
function _uuidv7(Class2, params) {
|
|
4276
4385
|
return new Class2({
|
|
4277
4386
|
type: "string",
|
|
@@ -4282,6 +4391,7 @@ function _uuidv7(Class2, params) {
|
|
|
4282
4391
|
...normalizeParams(params)
|
|
4283
4392
|
});
|
|
4284
4393
|
}
|
|
4394
|
+
// @__NO_SIDE_EFFECTS__
|
|
4285
4395
|
function _url(Class2, params) {
|
|
4286
4396
|
return new Class2({
|
|
4287
4397
|
type: "string",
|
|
@@ -4291,6 +4401,7 @@ function _url(Class2, params) {
|
|
|
4291
4401
|
...normalizeParams(params)
|
|
4292
4402
|
});
|
|
4293
4403
|
}
|
|
4404
|
+
// @__NO_SIDE_EFFECTS__
|
|
4294
4405
|
function _emoji2(Class2, params) {
|
|
4295
4406
|
return new Class2({
|
|
4296
4407
|
type: "string",
|
|
@@ -4300,6 +4411,7 @@ function _emoji2(Class2, params) {
|
|
|
4300
4411
|
...normalizeParams(params)
|
|
4301
4412
|
});
|
|
4302
4413
|
}
|
|
4414
|
+
// @__NO_SIDE_EFFECTS__
|
|
4303
4415
|
function _nanoid(Class2, params) {
|
|
4304
4416
|
return new Class2({
|
|
4305
4417
|
type: "string",
|
|
@@ -4309,6 +4421,7 @@ function _nanoid(Class2, params) {
|
|
|
4309
4421
|
...normalizeParams(params)
|
|
4310
4422
|
});
|
|
4311
4423
|
}
|
|
4424
|
+
// @__NO_SIDE_EFFECTS__
|
|
4312
4425
|
function _cuid(Class2, params) {
|
|
4313
4426
|
return new Class2({
|
|
4314
4427
|
type: "string",
|
|
@@ -4318,6 +4431,7 @@ function _cuid(Class2, params) {
|
|
|
4318
4431
|
...normalizeParams(params)
|
|
4319
4432
|
});
|
|
4320
4433
|
}
|
|
4434
|
+
// @__NO_SIDE_EFFECTS__
|
|
4321
4435
|
function _cuid2(Class2, params) {
|
|
4322
4436
|
return new Class2({
|
|
4323
4437
|
type: "string",
|
|
@@ -4327,6 +4441,7 @@ function _cuid2(Class2, params) {
|
|
|
4327
4441
|
...normalizeParams(params)
|
|
4328
4442
|
});
|
|
4329
4443
|
}
|
|
4444
|
+
// @__NO_SIDE_EFFECTS__
|
|
4330
4445
|
function _ulid(Class2, params) {
|
|
4331
4446
|
return new Class2({
|
|
4332
4447
|
type: "string",
|
|
@@ -4336,6 +4451,7 @@ function _ulid(Class2, params) {
|
|
|
4336
4451
|
...normalizeParams(params)
|
|
4337
4452
|
});
|
|
4338
4453
|
}
|
|
4454
|
+
// @__NO_SIDE_EFFECTS__
|
|
4339
4455
|
function _xid(Class2, params) {
|
|
4340
4456
|
return new Class2({
|
|
4341
4457
|
type: "string",
|
|
@@ -4345,6 +4461,7 @@ function _xid(Class2, params) {
|
|
|
4345
4461
|
...normalizeParams(params)
|
|
4346
4462
|
});
|
|
4347
4463
|
}
|
|
4464
|
+
// @__NO_SIDE_EFFECTS__
|
|
4348
4465
|
function _ksuid(Class2, params) {
|
|
4349
4466
|
return new Class2({
|
|
4350
4467
|
type: "string",
|
|
@@ -4354,6 +4471,7 @@ function _ksuid(Class2, params) {
|
|
|
4354
4471
|
...normalizeParams(params)
|
|
4355
4472
|
});
|
|
4356
4473
|
}
|
|
4474
|
+
// @__NO_SIDE_EFFECTS__
|
|
4357
4475
|
function _ipv4(Class2, params) {
|
|
4358
4476
|
return new Class2({
|
|
4359
4477
|
type: "string",
|
|
@@ -4363,6 +4481,7 @@ function _ipv4(Class2, params) {
|
|
|
4363
4481
|
...normalizeParams(params)
|
|
4364
4482
|
});
|
|
4365
4483
|
}
|
|
4484
|
+
// @__NO_SIDE_EFFECTS__
|
|
4366
4485
|
function _ipv6(Class2, params) {
|
|
4367
4486
|
return new Class2({
|
|
4368
4487
|
type: "string",
|
|
@@ -4372,6 +4491,7 @@ function _ipv6(Class2, params) {
|
|
|
4372
4491
|
...normalizeParams(params)
|
|
4373
4492
|
});
|
|
4374
4493
|
}
|
|
4494
|
+
// @__NO_SIDE_EFFECTS__
|
|
4375
4495
|
function _mac(Class2, params) {
|
|
4376
4496
|
return new Class2({
|
|
4377
4497
|
type: "string",
|
|
@@ -4381,6 +4501,7 @@ function _mac(Class2, params) {
|
|
|
4381
4501
|
...normalizeParams(params)
|
|
4382
4502
|
});
|
|
4383
4503
|
}
|
|
4504
|
+
// @__NO_SIDE_EFFECTS__
|
|
4384
4505
|
function _cidrv4(Class2, params) {
|
|
4385
4506
|
return new Class2({
|
|
4386
4507
|
type: "string",
|
|
@@ -4390,6 +4511,7 @@ function _cidrv4(Class2, params) {
|
|
|
4390
4511
|
...normalizeParams(params)
|
|
4391
4512
|
});
|
|
4392
4513
|
}
|
|
4514
|
+
// @__NO_SIDE_EFFECTS__
|
|
4393
4515
|
function _cidrv6(Class2, params) {
|
|
4394
4516
|
return new Class2({
|
|
4395
4517
|
type: "string",
|
|
@@ -4399,6 +4521,7 @@ function _cidrv6(Class2, params) {
|
|
|
4399
4521
|
...normalizeParams(params)
|
|
4400
4522
|
});
|
|
4401
4523
|
}
|
|
4524
|
+
// @__NO_SIDE_EFFECTS__
|
|
4402
4525
|
function _base64(Class2, params) {
|
|
4403
4526
|
return new Class2({
|
|
4404
4527
|
type: "string",
|
|
@@ -4408,6 +4531,7 @@ function _base64(Class2, params) {
|
|
|
4408
4531
|
...normalizeParams(params)
|
|
4409
4532
|
});
|
|
4410
4533
|
}
|
|
4534
|
+
// @__NO_SIDE_EFFECTS__
|
|
4411
4535
|
function _base64url(Class2, params) {
|
|
4412
4536
|
return new Class2({
|
|
4413
4537
|
type: "string",
|
|
@@ -4417,6 +4541,7 @@ function _base64url(Class2, params) {
|
|
|
4417
4541
|
...normalizeParams(params)
|
|
4418
4542
|
});
|
|
4419
4543
|
}
|
|
4544
|
+
// @__NO_SIDE_EFFECTS__
|
|
4420
4545
|
function _e164(Class2, params) {
|
|
4421
4546
|
return new Class2({
|
|
4422
4547
|
type: "string",
|
|
@@ -4426,6 +4551,7 @@ function _e164(Class2, params) {
|
|
|
4426
4551
|
...normalizeParams(params)
|
|
4427
4552
|
});
|
|
4428
4553
|
}
|
|
4554
|
+
// @__NO_SIDE_EFFECTS__
|
|
4429
4555
|
function _jwt(Class2, params) {
|
|
4430
4556
|
return new Class2({
|
|
4431
4557
|
type: "string",
|
|
@@ -4435,6 +4561,7 @@ function _jwt(Class2, params) {
|
|
|
4435
4561
|
...normalizeParams(params)
|
|
4436
4562
|
});
|
|
4437
4563
|
}
|
|
4564
|
+
// @__NO_SIDE_EFFECTS__
|
|
4438
4565
|
function _isoDateTime(Class2, params) {
|
|
4439
4566
|
return new Class2({
|
|
4440
4567
|
type: "string",
|
|
@@ -4446,6 +4573,7 @@ function _isoDateTime(Class2, params) {
|
|
|
4446
4573
|
...normalizeParams(params)
|
|
4447
4574
|
});
|
|
4448
4575
|
}
|
|
4576
|
+
// @__NO_SIDE_EFFECTS__
|
|
4449
4577
|
function _isoDate(Class2, params) {
|
|
4450
4578
|
return new Class2({
|
|
4451
4579
|
type: "string",
|
|
@@ -4454,6 +4582,7 @@ function _isoDate(Class2, params) {
|
|
|
4454
4582
|
...normalizeParams(params)
|
|
4455
4583
|
});
|
|
4456
4584
|
}
|
|
4585
|
+
// @__NO_SIDE_EFFECTS__
|
|
4457
4586
|
function _isoTime(Class2, params) {
|
|
4458
4587
|
return new Class2({
|
|
4459
4588
|
type: "string",
|
|
@@ -4463,6 +4592,7 @@ function _isoTime(Class2, params) {
|
|
|
4463
4592
|
...normalizeParams(params)
|
|
4464
4593
|
});
|
|
4465
4594
|
}
|
|
4595
|
+
// @__NO_SIDE_EFFECTS__
|
|
4466
4596
|
function _isoDuration(Class2, params) {
|
|
4467
4597
|
return new Class2({
|
|
4468
4598
|
type: "string",
|
|
@@ -4471,6 +4601,7 @@ function _isoDuration(Class2, params) {
|
|
|
4471
4601
|
...normalizeParams(params)
|
|
4472
4602
|
});
|
|
4473
4603
|
}
|
|
4604
|
+
// @__NO_SIDE_EFFECTS__
|
|
4474
4605
|
function _number(Class2, params) {
|
|
4475
4606
|
return new Class2({
|
|
4476
4607
|
type: "number",
|
|
@@ -4478,6 +4609,7 @@ function _number(Class2, params) {
|
|
|
4478
4609
|
...normalizeParams(params)
|
|
4479
4610
|
});
|
|
4480
4611
|
}
|
|
4612
|
+
// @__NO_SIDE_EFFECTS__
|
|
4481
4613
|
function _coercedNumber(Class2, params) {
|
|
4482
4614
|
return new Class2({
|
|
4483
4615
|
type: "number",
|
|
@@ -4486,6 +4618,7 @@ function _coercedNumber(Class2, params) {
|
|
|
4486
4618
|
...normalizeParams(params)
|
|
4487
4619
|
});
|
|
4488
4620
|
}
|
|
4621
|
+
// @__NO_SIDE_EFFECTS__
|
|
4489
4622
|
function _int(Class2, params) {
|
|
4490
4623
|
return new Class2({
|
|
4491
4624
|
type: "number",
|
|
@@ -4495,6 +4628,7 @@ function _int(Class2, params) {
|
|
|
4495
4628
|
...normalizeParams(params)
|
|
4496
4629
|
});
|
|
4497
4630
|
}
|
|
4631
|
+
// @__NO_SIDE_EFFECTS__
|
|
4498
4632
|
function _float32(Class2, params) {
|
|
4499
4633
|
return new Class2({
|
|
4500
4634
|
type: "number",
|
|
@@ -4504,6 +4638,7 @@ function _float32(Class2, params) {
|
|
|
4504
4638
|
...normalizeParams(params)
|
|
4505
4639
|
});
|
|
4506
4640
|
}
|
|
4641
|
+
// @__NO_SIDE_EFFECTS__
|
|
4507
4642
|
function _float64(Class2, params) {
|
|
4508
4643
|
return new Class2({
|
|
4509
4644
|
type: "number",
|
|
@@ -4513,6 +4648,7 @@ function _float64(Class2, params) {
|
|
|
4513
4648
|
...normalizeParams(params)
|
|
4514
4649
|
});
|
|
4515
4650
|
}
|
|
4651
|
+
// @__NO_SIDE_EFFECTS__
|
|
4516
4652
|
function _int32(Class2, params) {
|
|
4517
4653
|
return new Class2({
|
|
4518
4654
|
type: "number",
|
|
@@ -4522,6 +4658,7 @@ function _int32(Class2, params) {
|
|
|
4522
4658
|
...normalizeParams(params)
|
|
4523
4659
|
});
|
|
4524
4660
|
}
|
|
4661
|
+
// @__NO_SIDE_EFFECTS__
|
|
4525
4662
|
function _uint32(Class2, params) {
|
|
4526
4663
|
return new Class2({
|
|
4527
4664
|
type: "number",
|
|
@@ -4531,12 +4668,14 @@ function _uint32(Class2, params) {
|
|
|
4531
4668
|
...normalizeParams(params)
|
|
4532
4669
|
});
|
|
4533
4670
|
}
|
|
4671
|
+
// @__NO_SIDE_EFFECTS__
|
|
4534
4672
|
function _boolean(Class2, params) {
|
|
4535
4673
|
return new Class2({
|
|
4536
4674
|
type: "boolean",
|
|
4537
4675
|
...normalizeParams(params)
|
|
4538
4676
|
});
|
|
4539
4677
|
}
|
|
4678
|
+
// @__NO_SIDE_EFFECTS__
|
|
4540
4679
|
function _coercedBoolean(Class2, params) {
|
|
4541
4680
|
return new Class2({
|
|
4542
4681
|
type: "boolean",
|
|
@@ -4544,12 +4683,14 @@ function _coercedBoolean(Class2, params) {
|
|
|
4544
4683
|
...normalizeParams(params)
|
|
4545
4684
|
});
|
|
4546
4685
|
}
|
|
4686
|
+
// @__NO_SIDE_EFFECTS__
|
|
4547
4687
|
function _bigint(Class2, params) {
|
|
4548
4688
|
return new Class2({
|
|
4549
4689
|
type: "bigint",
|
|
4550
4690
|
...normalizeParams(params)
|
|
4551
4691
|
});
|
|
4552
4692
|
}
|
|
4693
|
+
// @__NO_SIDE_EFFECTS__
|
|
4553
4694
|
function _coercedBigint(Class2, params) {
|
|
4554
4695
|
return new Class2({
|
|
4555
4696
|
type: "bigint",
|
|
@@ -4557,6 +4698,7 @@ function _coercedBigint(Class2, params) {
|
|
|
4557
4698
|
...normalizeParams(params)
|
|
4558
4699
|
});
|
|
4559
4700
|
}
|
|
4701
|
+
// @__NO_SIDE_EFFECTS__
|
|
4560
4702
|
function _int64(Class2, params) {
|
|
4561
4703
|
return new Class2({
|
|
4562
4704
|
type: "bigint",
|
|
@@ -4566,6 +4708,7 @@ function _int64(Class2, params) {
|
|
|
4566
4708
|
...normalizeParams(params)
|
|
4567
4709
|
});
|
|
4568
4710
|
}
|
|
4711
|
+
// @__NO_SIDE_EFFECTS__
|
|
4569
4712
|
function _uint64(Class2, params) {
|
|
4570
4713
|
return new Class2({
|
|
4571
4714
|
type: "bigint",
|
|
@@ -4575,52 +4718,61 @@ function _uint64(Class2, params) {
|
|
|
4575
4718
|
...normalizeParams(params)
|
|
4576
4719
|
});
|
|
4577
4720
|
}
|
|
4721
|
+
// @__NO_SIDE_EFFECTS__
|
|
4578
4722
|
function _symbol(Class2, params) {
|
|
4579
4723
|
return new Class2({
|
|
4580
4724
|
type: "symbol",
|
|
4581
4725
|
...normalizeParams(params)
|
|
4582
4726
|
});
|
|
4583
4727
|
}
|
|
4728
|
+
// @__NO_SIDE_EFFECTS__
|
|
4584
4729
|
function _undefined2(Class2, params) {
|
|
4585
4730
|
return new Class2({
|
|
4586
4731
|
type: "undefined",
|
|
4587
4732
|
...normalizeParams(params)
|
|
4588
4733
|
});
|
|
4589
4734
|
}
|
|
4735
|
+
// @__NO_SIDE_EFFECTS__
|
|
4590
4736
|
function _null2(Class2, params) {
|
|
4591
4737
|
return new Class2({
|
|
4592
4738
|
type: "null",
|
|
4593
4739
|
...normalizeParams(params)
|
|
4594
4740
|
});
|
|
4595
4741
|
}
|
|
4742
|
+
// @__NO_SIDE_EFFECTS__
|
|
4596
4743
|
function _any(Class2) {
|
|
4597
4744
|
return new Class2({
|
|
4598
4745
|
type: "any"
|
|
4599
4746
|
});
|
|
4600
4747
|
}
|
|
4748
|
+
// @__NO_SIDE_EFFECTS__
|
|
4601
4749
|
function _unknown(Class2) {
|
|
4602
4750
|
return new Class2({
|
|
4603
4751
|
type: "unknown"
|
|
4604
4752
|
});
|
|
4605
4753
|
}
|
|
4754
|
+
// @__NO_SIDE_EFFECTS__
|
|
4606
4755
|
function _never(Class2, params) {
|
|
4607
4756
|
return new Class2({
|
|
4608
4757
|
type: "never",
|
|
4609
4758
|
...normalizeParams(params)
|
|
4610
4759
|
});
|
|
4611
4760
|
}
|
|
4761
|
+
// @__NO_SIDE_EFFECTS__
|
|
4612
4762
|
function _void(Class2, params) {
|
|
4613
4763
|
return new Class2({
|
|
4614
4764
|
type: "void",
|
|
4615
4765
|
...normalizeParams(params)
|
|
4616
4766
|
});
|
|
4617
4767
|
}
|
|
4768
|
+
// @__NO_SIDE_EFFECTS__
|
|
4618
4769
|
function _date(Class2, params) {
|
|
4619
4770
|
return new Class2({
|
|
4620
4771
|
type: "date",
|
|
4621
4772
|
...normalizeParams(params)
|
|
4622
4773
|
});
|
|
4623
4774
|
}
|
|
4775
|
+
// @__NO_SIDE_EFFECTS__
|
|
4624
4776
|
function _coercedDate(Class2, params) {
|
|
4625
4777
|
return new Class2({
|
|
4626
4778
|
type: "date",
|
|
@@ -4628,12 +4780,14 @@ function _coercedDate(Class2, params) {
|
|
|
4628
4780
|
...normalizeParams(params)
|
|
4629
4781
|
});
|
|
4630
4782
|
}
|
|
4783
|
+
// @__NO_SIDE_EFFECTS__
|
|
4631
4784
|
function _nan(Class2, params) {
|
|
4632
4785
|
return new Class2({
|
|
4633
4786
|
type: "nan",
|
|
4634
4787
|
...normalizeParams(params)
|
|
4635
4788
|
});
|
|
4636
4789
|
}
|
|
4790
|
+
// @__NO_SIDE_EFFECTS__
|
|
4637
4791
|
function _lt(value, params) {
|
|
4638
4792
|
return new $ZodCheckLessThan({
|
|
4639
4793
|
check: "less_than",
|
|
@@ -4642,6 +4796,7 @@ function _lt(value, params) {
|
|
|
4642
4796
|
inclusive: false
|
|
4643
4797
|
});
|
|
4644
4798
|
}
|
|
4799
|
+
// @__NO_SIDE_EFFECTS__
|
|
4645
4800
|
function _lte(value, params) {
|
|
4646
4801
|
return new $ZodCheckLessThan({
|
|
4647
4802
|
check: "less_than",
|
|
@@ -4650,6 +4805,7 @@ function _lte(value, params) {
|
|
|
4650
4805
|
inclusive: true
|
|
4651
4806
|
});
|
|
4652
4807
|
}
|
|
4808
|
+
// @__NO_SIDE_EFFECTS__
|
|
4653
4809
|
function _gt(value, params) {
|
|
4654
4810
|
return new $ZodCheckGreaterThan({
|
|
4655
4811
|
check: "greater_than",
|
|
@@ -4658,6 +4814,7 @@ function _gt(value, params) {
|
|
|
4658
4814
|
inclusive: false
|
|
4659
4815
|
});
|
|
4660
4816
|
}
|
|
4817
|
+
// @__NO_SIDE_EFFECTS__
|
|
4661
4818
|
function _gte(value, params) {
|
|
4662
4819
|
return new $ZodCheckGreaterThan({
|
|
4663
4820
|
check: "greater_than",
|
|
@@ -4666,18 +4823,23 @@ function _gte(value, params) {
|
|
|
4666
4823
|
inclusive: true
|
|
4667
4824
|
});
|
|
4668
4825
|
}
|
|
4826
|
+
// @__NO_SIDE_EFFECTS__
|
|
4669
4827
|
function _positive(params) {
|
|
4670
|
-
return _gt(0, params);
|
|
4828
|
+
return /* @__PURE__ */ _gt(0, params);
|
|
4671
4829
|
}
|
|
4830
|
+
// @__NO_SIDE_EFFECTS__
|
|
4672
4831
|
function _negative(params) {
|
|
4673
|
-
return _lt(0, params);
|
|
4832
|
+
return /* @__PURE__ */ _lt(0, params);
|
|
4674
4833
|
}
|
|
4834
|
+
// @__NO_SIDE_EFFECTS__
|
|
4675
4835
|
function _nonpositive(params) {
|
|
4676
|
-
return _lte(0, params);
|
|
4836
|
+
return /* @__PURE__ */ _lte(0, params);
|
|
4677
4837
|
}
|
|
4838
|
+
// @__NO_SIDE_EFFECTS__
|
|
4678
4839
|
function _nonnegative(params) {
|
|
4679
|
-
return _gte(0, params);
|
|
4840
|
+
return /* @__PURE__ */ _gte(0, params);
|
|
4680
4841
|
}
|
|
4842
|
+
// @__NO_SIDE_EFFECTS__
|
|
4681
4843
|
function _multipleOf(value, params) {
|
|
4682
4844
|
return new $ZodCheckMultipleOf({
|
|
4683
4845
|
check: "multiple_of",
|
|
@@ -4685,6 +4847,7 @@ function _multipleOf(value, params) {
|
|
|
4685
4847
|
value
|
|
4686
4848
|
});
|
|
4687
4849
|
}
|
|
4850
|
+
// @__NO_SIDE_EFFECTS__
|
|
4688
4851
|
function _maxSize(maximum, params) {
|
|
4689
4852
|
return new $ZodCheckMaxSize({
|
|
4690
4853
|
check: "max_size",
|
|
@@ -4692,6 +4855,7 @@ function _maxSize(maximum, params) {
|
|
|
4692
4855
|
maximum
|
|
4693
4856
|
});
|
|
4694
4857
|
}
|
|
4858
|
+
// @__NO_SIDE_EFFECTS__
|
|
4695
4859
|
function _minSize(minimum, params) {
|
|
4696
4860
|
return new $ZodCheckMinSize({
|
|
4697
4861
|
check: "min_size",
|
|
@@ -4699,6 +4863,7 @@ function _minSize(minimum, params) {
|
|
|
4699
4863
|
minimum
|
|
4700
4864
|
});
|
|
4701
4865
|
}
|
|
4866
|
+
// @__NO_SIDE_EFFECTS__
|
|
4702
4867
|
function _size(size, params) {
|
|
4703
4868
|
return new $ZodCheckSizeEquals({
|
|
4704
4869
|
check: "size_equals",
|
|
@@ -4706,6 +4871,7 @@ function _size(size, params) {
|
|
|
4706
4871
|
size
|
|
4707
4872
|
});
|
|
4708
4873
|
}
|
|
4874
|
+
// @__NO_SIDE_EFFECTS__
|
|
4709
4875
|
function _maxLength(maximum, params) {
|
|
4710
4876
|
const ch = new $ZodCheckMaxLength({
|
|
4711
4877
|
check: "max_length",
|
|
@@ -4714,6 +4880,7 @@ function _maxLength(maximum, params) {
|
|
|
4714
4880
|
});
|
|
4715
4881
|
return ch;
|
|
4716
4882
|
}
|
|
4883
|
+
// @__NO_SIDE_EFFECTS__
|
|
4717
4884
|
function _minLength(minimum, params) {
|
|
4718
4885
|
return new $ZodCheckMinLength({
|
|
4719
4886
|
check: "min_length",
|
|
@@ -4721,6 +4888,7 @@ function _minLength(minimum, params) {
|
|
|
4721
4888
|
minimum
|
|
4722
4889
|
});
|
|
4723
4890
|
}
|
|
4891
|
+
// @__NO_SIDE_EFFECTS__
|
|
4724
4892
|
function _length(length, params) {
|
|
4725
4893
|
return new $ZodCheckLengthEquals({
|
|
4726
4894
|
check: "length_equals",
|
|
@@ -4728,6 +4896,7 @@ function _length(length, params) {
|
|
|
4728
4896
|
length
|
|
4729
4897
|
});
|
|
4730
4898
|
}
|
|
4899
|
+
// @__NO_SIDE_EFFECTS__
|
|
4731
4900
|
function _regex(pattern, params) {
|
|
4732
4901
|
return new $ZodCheckRegex({
|
|
4733
4902
|
check: "string_format",
|
|
@@ -4736,6 +4905,7 @@ function _regex(pattern, params) {
|
|
|
4736
4905
|
pattern
|
|
4737
4906
|
});
|
|
4738
4907
|
}
|
|
4908
|
+
// @__NO_SIDE_EFFECTS__
|
|
4739
4909
|
function _lowercase(params) {
|
|
4740
4910
|
return new $ZodCheckLowerCase({
|
|
4741
4911
|
check: "string_format",
|
|
@@ -4743,6 +4913,7 @@ function _lowercase(params) {
|
|
|
4743
4913
|
...normalizeParams(params)
|
|
4744
4914
|
});
|
|
4745
4915
|
}
|
|
4916
|
+
// @__NO_SIDE_EFFECTS__
|
|
4746
4917
|
function _uppercase(params) {
|
|
4747
4918
|
return new $ZodCheckUpperCase({
|
|
4748
4919
|
check: "string_format",
|
|
@@ -4750,6 +4921,7 @@ function _uppercase(params) {
|
|
|
4750
4921
|
...normalizeParams(params)
|
|
4751
4922
|
});
|
|
4752
4923
|
}
|
|
4924
|
+
// @__NO_SIDE_EFFECTS__
|
|
4753
4925
|
function _includes(includes, params) {
|
|
4754
4926
|
return new $ZodCheckIncludes({
|
|
4755
4927
|
check: "string_format",
|
|
@@ -4758,6 +4930,7 @@ function _includes(includes, params) {
|
|
|
4758
4930
|
includes
|
|
4759
4931
|
});
|
|
4760
4932
|
}
|
|
4933
|
+
// @__NO_SIDE_EFFECTS__
|
|
4761
4934
|
function _startsWith(prefix, params) {
|
|
4762
4935
|
return new $ZodCheckStartsWith({
|
|
4763
4936
|
check: "string_format",
|
|
@@ -4766,6 +4939,7 @@ function _startsWith(prefix, params) {
|
|
|
4766
4939
|
prefix
|
|
4767
4940
|
});
|
|
4768
4941
|
}
|
|
4942
|
+
// @__NO_SIDE_EFFECTS__
|
|
4769
4943
|
function _endsWith(suffix, params) {
|
|
4770
4944
|
return new $ZodCheckEndsWith({
|
|
4771
4945
|
check: "string_format",
|
|
@@ -4774,6 +4948,7 @@ function _endsWith(suffix, params) {
|
|
|
4774
4948
|
suffix
|
|
4775
4949
|
});
|
|
4776
4950
|
}
|
|
4951
|
+
// @__NO_SIDE_EFFECTS__
|
|
4777
4952
|
function _property(property, schema, params) {
|
|
4778
4953
|
return new $ZodCheckProperty({
|
|
4779
4954
|
check: "property",
|
|
@@ -4782,6 +4957,7 @@ function _property(property, schema, params) {
|
|
|
4782
4957
|
...normalizeParams(params)
|
|
4783
4958
|
});
|
|
4784
4959
|
}
|
|
4960
|
+
// @__NO_SIDE_EFFECTS__
|
|
4785
4961
|
function _mime(types, params) {
|
|
4786
4962
|
return new $ZodCheckMimeType({
|
|
4787
4963
|
check: "mime_type",
|
|
@@ -4789,27 +4965,34 @@ function _mime(types, params) {
|
|
|
4789
4965
|
...normalizeParams(params)
|
|
4790
4966
|
});
|
|
4791
4967
|
}
|
|
4968
|
+
// @__NO_SIDE_EFFECTS__
|
|
4792
4969
|
function _overwrite(tx) {
|
|
4793
4970
|
return new $ZodCheckOverwrite({
|
|
4794
4971
|
check: "overwrite",
|
|
4795
4972
|
tx
|
|
4796
4973
|
});
|
|
4797
4974
|
}
|
|
4975
|
+
// @__NO_SIDE_EFFECTS__
|
|
4798
4976
|
function _normalize(form) {
|
|
4799
|
-
return _overwrite((input) => input.normalize(form));
|
|
4977
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
4800
4978
|
}
|
|
4979
|
+
// @__NO_SIDE_EFFECTS__
|
|
4801
4980
|
function _trim() {
|
|
4802
|
-
return _overwrite((input) => input.trim());
|
|
4981
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
4803
4982
|
}
|
|
4983
|
+
// @__NO_SIDE_EFFECTS__
|
|
4804
4984
|
function _toLowerCase() {
|
|
4805
|
-
return _overwrite((input) => input.toLowerCase());
|
|
4985
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
4806
4986
|
}
|
|
4987
|
+
// @__NO_SIDE_EFFECTS__
|
|
4807
4988
|
function _toUpperCase() {
|
|
4808
|
-
return _overwrite((input) => input.toUpperCase());
|
|
4989
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
4809
4990
|
}
|
|
4991
|
+
// @__NO_SIDE_EFFECTS__
|
|
4810
4992
|
function _slugify() {
|
|
4811
|
-
return _overwrite((input) => slugify(input));
|
|
4993
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
4812
4994
|
}
|
|
4995
|
+
// @__NO_SIDE_EFFECTS__
|
|
4813
4996
|
function _array(Class2, element, params) {
|
|
4814
4997
|
return new Class2({
|
|
4815
4998
|
type: "array",
|
|
@@ -4820,12 +5003,14 @@ function _array(Class2, element, params) {
|
|
|
4820
5003
|
...normalizeParams(params)
|
|
4821
5004
|
});
|
|
4822
5005
|
}
|
|
5006
|
+
// @__NO_SIDE_EFFECTS__
|
|
4823
5007
|
function _file(Class2, params) {
|
|
4824
5008
|
return new Class2({
|
|
4825
5009
|
type: "file",
|
|
4826
5010
|
...normalizeParams(params)
|
|
4827
5011
|
});
|
|
4828
5012
|
}
|
|
5013
|
+
// @__NO_SIDE_EFFECTS__
|
|
4829
5014
|
function _custom(Class2, fn, _params) {
|
|
4830
5015
|
const norm = normalizeParams(_params);
|
|
4831
5016
|
norm.abort ?? (norm.abort = true);
|
|
@@ -4837,6 +5022,7 @@ function _custom(Class2, fn, _params) {
|
|
|
4837
5022
|
});
|
|
4838
5023
|
return schema;
|
|
4839
5024
|
}
|
|
5025
|
+
// @__NO_SIDE_EFFECTS__
|
|
4840
5026
|
function _refine(Class2, fn, _params) {
|
|
4841
5027
|
const schema = new Class2({
|
|
4842
5028
|
type: "custom",
|
|
@@ -4846,8 +5032,9 @@ function _refine(Class2, fn, _params) {
|
|
|
4846
5032
|
});
|
|
4847
5033
|
return schema;
|
|
4848
5034
|
}
|
|
5035
|
+
// @__NO_SIDE_EFFECTS__
|
|
4849
5036
|
function _superRefine(fn) {
|
|
4850
|
-
const ch = _check((payload) => {
|
|
5037
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
4851
5038
|
payload.addIssue = (issue2) => {
|
|
4852
5039
|
if (typeof issue2 === "string") {
|
|
4853
5040
|
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
@@ -4866,6 +5053,7 @@ function _superRefine(fn) {
|
|
|
4866
5053
|
});
|
|
4867
5054
|
return ch;
|
|
4868
5055
|
}
|
|
5056
|
+
// @__NO_SIDE_EFFECTS__
|
|
4869
5057
|
function _check(fn, params) {
|
|
4870
5058
|
const ch = new $ZodCheck({
|
|
4871
5059
|
check: "custom",
|
|
@@ -4874,6 +5062,7 @@ function _check(fn, params) {
|
|
|
4874
5062
|
ch._zod.check = fn;
|
|
4875
5063
|
return ch;
|
|
4876
5064
|
}
|
|
5065
|
+
// @__NO_SIDE_EFFECTS__
|
|
4877
5066
|
function describe(description) {
|
|
4878
5067
|
const ch = new $ZodCheck({ check: "describe" });
|
|
4879
5068
|
ch._zod.onattach = [
|
|
@@ -4886,6 +5075,7 @@ function describe(description) {
|
|
|
4886
5075
|
};
|
|
4887
5076
|
return ch;
|
|
4888
5077
|
}
|
|
5078
|
+
// @__NO_SIDE_EFFECTS__
|
|
4889
5079
|
function meta(metadata) {
|
|
4890
5080
|
const ch = new $ZodCheck({ check: "meta" });
|
|
4891
5081
|
ch._zod.onattach = [
|
|
@@ -4898,6 +5088,7 @@ function meta(metadata) {
|
|
|
4898
5088
|
};
|
|
4899
5089
|
return ch;
|
|
4900
5090
|
}
|
|
5091
|
+
// @__NO_SIDE_EFFECTS__
|
|
4901
5092
|
function _stringbool(Classes, _params) {
|
|
4902
5093
|
const params = normalizeParams(_params);
|
|
4903
5094
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -4948,6 +5139,7 @@ function _stringbool(Classes, _params) {
|
|
|
4948
5139
|
});
|
|
4949
5140
|
return codec2;
|
|
4950
5141
|
}
|
|
5142
|
+
// @__NO_SIDE_EFFECTS__
|
|
4951
5143
|
function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
4952
5144
|
const params = normalizeParams(_params);
|
|
4953
5145
|
const def = {
|
|
@@ -5010,12 +5202,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
5010
5202
|
schemaPath: [..._params.schemaPath, schema],
|
|
5011
5203
|
path: _params.path
|
|
5012
5204
|
};
|
|
5013
|
-
|
|
5014
|
-
if (parent) {
|
|
5015
|
-
result.ref = parent;
|
|
5016
|
-
process2(parent, ctx, params);
|
|
5017
|
-
ctx.seen.get(parent).isParent = true;
|
|
5018
|
-
} else if (schema._zod.processJSONSchema) {
|
|
5205
|
+
if (schema._zod.processJSONSchema) {
|
|
5019
5206
|
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
5020
5207
|
} else {
|
|
5021
5208
|
const _json = result.schema;
|
|
@@ -5025,6 +5212,13 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
5025
5212
|
}
|
|
5026
5213
|
processor(schema, ctx, _json, params);
|
|
5027
5214
|
}
|
|
5215
|
+
const parent = schema._zod.parent;
|
|
5216
|
+
if (parent) {
|
|
5217
|
+
if (!result.ref)
|
|
5218
|
+
result.ref = parent;
|
|
5219
|
+
process2(parent, ctx, params);
|
|
5220
|
+
ctx.seen.get(parent).isParent = true;
|
|
5221
|
+
}
|
|
5028
5222
|
}
|
|
5029
5223
|
const meta3 = ctx.metadataRegistry.get(schema);
|
|
5030
5224
|
if (meta3)
|
|
@@ -5043,6 +5237,17 @@ function extractDefs(ctx, schema) {
|
|
|
5043
5237
|
const root = ctx.seen.get(schema);
|
|
5044
5238
|
if (!root)
|
|
5045
5239
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
5240
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
5241
|
+
for (const entry of ctx.seen.entries()) {
|
|
5242
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
5243
|
+
if (id) {
|
|
5244
|
+
const existing = idToSchema.get(id);
|
|
5245
|
+
if (existing && existing !== entry[0]) {
|
|
5246
|
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
5247
|
+
}
|
|
5248
|
+
idToSchema.set(id, entry[0]);
|
|
5249
|
+
}
|
|
5250
|
+
}
|
|
5046
5251
|
const makeURI = (entry) => {
|
|
5047
5252
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
5048
5253
|
if (ctx.external) {
|
|
@@ -5124,30 +5329,65 @@ function finalize(ctx, schema) {
|
|
|
5124
5329
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
5125
5330
|
const flattenRef = (zodSchema) => {
|
|
5126
5331
|
const seen = ctx.seen.get(zodSchema);
|
|
5332
|
+
if (seen.ref === null)
|
|
5333
|
+
return;
|
|
5127
5334
|
const schema2 = seen.def ?? seen.schema;
|
|
5128
5335
|
const _cached = { ...schema2 };
|
|
5129
|
-
if (seen.ref === null) {
|
|
5130
|
-
return;
|
|
5131
|
-
}
|
|
5132
5336
|
const ref = seen.ref;
|
|
5133
5337
|
seen.ref = null;
|
|
5134
5338
|
if (ref) {
|
|
5135
5339
|
flattenRef(ref);
|
|
5136
|
-
const
|
|
5340
|
+
const refSeen = ctx.seen.get(ref);
|
|
5341
|
+
const refSchema = refSeen.schema;
|
|
5137
5342
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
5138
5343
|
schema2.allOf = schema2.allOf ?? [];
|
|
5139
5344
|
schema2.allOf.push(refSchema);
|
|
5140
5345
|
} else {
|
|
5141
5346
|
Object.assign(schema2, refSchema);
|
|
5142
|
-
|
|
5347
|
+
}
|
|
5348
|
+
Object.assign(schema2, _cached);
|
|
5349
|
+
const isParentRef = zodSchema._zod.parent === ref;
|
|
5350
|
+
if (isParentRef) {
|
|
5351
|
+
for (const key in schema2) {
|
|
5352
|
+
if (key === "$ref" || key === "allOf")
|
|
5353
|
+
continue;
|
|
5354
|
+
if (!(key in _cached)) {
|
|
5355
|
+
delete schema2[key];
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
if (refSchema.$ref) {
|
|
5360
|
+
for (const key in schema2) {
|
|
5361
|
+
if (key === "$ref" || key === "allOf")
|
|
5362
|
+
continue;
|
|
5363
|
+
if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
|
|
5364
|
+
delete schema2[key];
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5143
5367
|
}
|
|
5144
5368
|
}
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5369
|
+
const parent = zodSchema._zod.parent;
|
|
5370
|
+
if (parent && parent !== ref) {
|
|
5371
|
+
flattenRef(parent);
|
|
5372
|
+
const parentSeen = ctx.seen.get(parent);
|
|
5373
|
+
if (parentSeen?.schema.$ref) {
|
|
5374
|
+
schema2.$ref = parentSeen.schema.$ref;
|
|
5375
|
+
if (parentSeen.def) {
|
|
5376
|
+
for (const key in schema2) {
|
|
5377
|
+
if (key === "$ref" || key === "allOf")
|
|
5378
|
+
continue;
|
|
5379
|
+
if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
5380
|
+
delete schema2[key];
|
|
5381
|
+
}
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
ctx.override({
|
|
5387
|
+
zodSchema,
|
|
5388
|
+
jsonSchema: schema2,
|
|
5389
|
+
path: seen.path ?? []
|
|
5390
|
+
});
|
|
5151
5391
|
};
|
|
5152
5392
|
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
5153
5393
|
flattenRef(entry[0]);
|
|
@@ -5192,8 +5432,8 @@ function finalize(ctx, schema) {
|
|
|
5192
5432
|
value: {
|
|
5193
5433
|
...schema["~standard"],
|
|
5194
5434
|
jsonSchema: {
|
|
5195
|
-
input: createStandardJSONSchemaMethod(schema, "input"),
|
|
5196
|
-
output: createStandardJSONSchemaMethod(schema, "output")
|
|
5435
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
5436
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
5197
5437
|
}
|
|
5198
5438
|
},
|
|
5199
5439
|
enumerable: false,
|
|
@@ -5261,9 +5501,9 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
5261
5501
|
extractDefs(ctx, schema);
|
|
5262
5502
|
return finalize(ctx, schema);
|
|
5263
5503
|
};
|
|
5264
|
-
var createStandardJSONSchemaMethod = (schema, io) => (params) => {
|
|
5504
|
+
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
5265
5505
|
const { libraryOptions, target } = params ?? {};
|
|
5266
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors
|
|
5506
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
5267
5507
|
process2(schema, ctx);
|
|
5268
5508
|
extractDefs(ctx, schema);
|
|
5269
5509
|
return finalize(ctx, schema);
|
|
@@ -5290,6 +5530,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
5290
5530
|
json2.format = formatMap[format] ?? format;
|
|
5291
5531
|
if (json2.format === "")
|
|
5292
5532
|
delete json2.format;
|
|
5533
|
+
if (format === "time") {
|
|
5534
|
+
delete json2.format;
|
|
5535
|
+
}
|
|
5293
5536
|
}
|
|
5294
5537
|
if (contentEncoding)
|
|
5295
5538
|
json2.contentEncoding = contentEncoding;
|
|
@@ -5474,10 +5717,8 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
5474
5717
|
file2.contentMediaType = mime[0];
|
|
5475
5718
|
Object.assign(_json, file2);
|
|
5476
5719
|
} else {
|
|
5477
|
-
_json
|
|
5478
|
-
|
|
5479
|
-
return mFile;
|
|
5480
|
-
});
|
|
5720
|
+
Object.assign(_json, file2);
|
|
5721
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
5481
5722
|
}
|
|
5482
5723
|
} else {
|
|
5483
5724
|
Object.assign(_json, file2);
|
|
@@ -5634,16 +5875,37 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
5634
5875
|
const json2 = _json;
|
|
5635
5876
|
const def = schema._zod.def;
|
|
5636
5877
|
json2.type = "object";
|
|
5637
|
-
|
|
5638
|
-
|
|
5878
|
+
const keyType = def.keyType;
|
|
5879
|
+
const keyBag = keyType._zod.bag;
|
|
5880
|
+
const patterns = keyBag?.patterns;
|
|
5881
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
5882
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
5639
5883
|
...params,
|
|
5640
|
-
path: [...params.path, "
|
|
5884
|
+
path: [...params.path, "patternProperties", "*"]
|
|
5885
|
+
});
|
|
5886
|
+
json2.patternProperties = {};
|
|
5887
|
+
for (const pattern of patterns) {
|
|
5888
|
+
json2.patternProperties[pattern.source] = valueSchema;
|
|
5889
|
+
}
|
|
5890
|
+
} else {
|
|
5891
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
5892
|
+
json2.propertyNames = process2(def.keyType, ctx, {
|
|
5893
|
+
...params,
|
|
5894
|
+
path: [...params.path, "propertyNames"]
|
|
5895
|
+
});
|
|
5896
|
+
}
|
|
5897
|
+
json2.additionalProperties = process2(def.valueType, ctx, {
|
|
5898
|
+
...params,
|
|
5899
|
+
path: [...params.path, "additionalProperties"]
|
|
5641
5900
|
});
|
|
5642
5901
|
}
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5902
|
+
const keyValues = keyType._zod.values;
|
|
5903
|
+
if (keyValues) {
|
|
5904
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
5905
|
+
if (validKeyValues.length > 0) {
|
|
5906
|
+
json2.required = validKeyValues;
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5647
5909
|
};
|
|
5648
5910
|
var nullableProcessor = (schema, ctx, json2, params) => {
|
|
5649
5911
|
const def = schema._zod.def;
|
|
@@ -5748,6 +6010,7 @@ __export(schemas_exports2, {
|
|
|
5748
6010
|
ZodEmail: () => ZodEmail,
|
|
5749
6011
|
ZodEmoji: () => ZodEmoji,
|
|
5750
6012
|
ZodEnum: () => ZodEnum,
|
|
6013
|
+
ZodExactOptional: () => ZodExactOptional,
|
|
5751
6014
|
ZodFile: () => ZodFile,
|
|
5752
6015
|
ZodFunction: () => ZodFunction,
|
|
5753
6016
|
ZodGUID: () => ZodGUID,
|
|
@@ -5817,6 +6080,7 @@ __export(schemas_exports2, {
|
|
|
5817
6080
|
email: () => email2,
|
|
5818
6081
|
emoji: () => emoji2,
|
|
5819
6082
|
enum: () => _enum,
|
|
6083
|
+
exactOptional: () => exactOptional,
|
|
5820
6084
|
file: () => file,
|
|
5821
6085
|
float32: () => float32,
|
|
5822
6086
|
float64: () => float64,
|
|
@@ -6038,8 +6302,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6038
6302
|
...def.checks ?? [],
|
|
6039
6303
|
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
6040
6304
|
]
|
|
6041
|
-
})
|
|
6305
|
+
}), {
|
|
6306
|
+
parent: true
|
|
6307
|
+
});
|
|
6042
6308
|
};
|
|
6309
|
+
inst.with = inst.check;
|
|
6043
6310
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
6044
6311
|
inst.brand = () => inst;
|
|
6045
6312
|
inst.register = ((reg, meta3) => {
|
|
@@ -6063,6 +6330,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6063
6330
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
6064
6331
|
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
6065
6332
|
inst.optional = () => optional(inst);
|
|
6333
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
6066
6334
|
inst.nullable = () => nullable(inst);
|
|
6067
6335
|
inst.nullish = () => optional(nullable(inst));
|
|
6068
6336
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
@@ -6096,6 +6364,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6096
6364
|
};
|
|
6097
6365
|
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
6098
6366
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
6367
|
+
inst.apply = (fn) => fn(inst);
|
|
6099
6368
|
return inst;
|
|
6100
6369
|
});
|
|
6101
6370
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
@@ -6675,6 +6944,10 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
6675
6944
|
inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
|
|
6676
6945
|
inst.keyType = def.keyType;
|
|
6677
6946
|
inst.valueType = def.valueType;
|
|
6947
|
+
inst.min = (...args) => inst.check(_minSize(...args));
|
|
6948
|
+
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
6949
|
+
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
6950
|
+
inst.size = (...args) => inst.check(_size(...args));
|
|
6678
6951
|
});
|
|
6679
6952
|
function map(keyType, valueType, params) {
|
|
6680
6953
|
return new ZodMap({
|
|
@@ -6835,6 +7108,18 @@ function optional(innerType) {
|
|
|
6835
7108
|
innerType
|
|
6836
7109
|
});
|
|
6837
7110
|
}
|
|
7111
|
+
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
7112
|
+
$ZodExactOptional.init(inst, def);
|
|
7113
|
+
ZodType.init(inst, def);
|
|
7114
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
|
|
7115
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
7116
|
+
});
|
|
7117
|
+
function exactOptional(innerType) {
|
|
7118
|
+
return new ZodExactOptional({
|
|
7119
|
+
type: "optional",
|
|
7120
|
+
innerType
|
|
7121
|
+
});
|
|
7122
|
+
}
|
|
6838
7123
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
6839
7124
|
$ZodNullable.init(inst, def);
|
|
6840
7125
|
ZodType.init(inst, def);
|
|
@@ -7040,9 +7325,7 @@ function superRefine(fn) {
|
|
|
7040
7325
|
}
|
|
7041
7326
|
var describe2 = describe;
|
|
7042
7327
|
var meta2 = meta;
|
|
7043
|
-
function _instanceof(cls, params = {
|
|
7044
|
-
error: `Input not instance of ${cls.name}`
|
|
7045
|
-
}) {
|
|
7328
|
+
function _instanceof(cls, params = {}) {
|
|
7046
7329
|
const inst = new ZodCustom({
|
|
7047
7330
|
type: "custom",
|
|
7048
7331
|
check: "custom",
|
|
@@ -7051,6 +7334,17 @@ function _instanceof(cls, params = {
|
|
|
7051
7334
|
...util_exports.normalizeParams(params)
|
|
7052
7335
|
});
|
|
7053
7336
|
inst._zod.bag.Class = cls;
|
|
7337
|
+
inst._zod.check = (payload) => {
|
|
7338
|
+
if (!(payload.value instanceof cls)) {
|
|
7339
|
+
payload.issues.push({
|
|
7340
|
+
code: "invalid_type",
|
|
7341
|
+
expected: cls.name,
|
|
7342
|
+
input: payload.value,
|
|
7343
|
+
inst,
|
|
7344
|
+
path: [...inst._zod.def.path ?? []]
|
|
7345
|
+
});
|
|
7346
|
+
}
|
|
7347
|
+
};
|
|
7054
7348
|
return inst;
|
|
7055
7349
|
}
|
|
7056
7350
|
var stringbool = (...args) => _stringbool({
|
|
@@ -19992,7 +20286,16 @@ var MCPSamplingLanguageModel = class {
|
|
|
19992
20286
|
* Generate a response using MCP's createMessage capability
|
|
19993
20287
|
*/
|
|
19994
20288
|
async doGenerate(options) {
|
|
19995
|
-
const
|
|
20289
|
+
const useNativeTools = this.supportsSamplingTools();
|
|
20290
|
+
this.server.sendLoggingMessage({
|
|
20291
|
+
level: "info",
|
|
20292
|
+
data: `Client supports native tools: ${useNativeTools}`
|
|
20293
|
+
});
|
|
20294
|
+
const messages = this.convertMessages(options.prompt, useNativeTools);
|
|
20295
|
+
this.server.sendLoggingMessage({
|
|
20296
|
+
level: "info",
|
|
20297
|
+
data: `Converted messages for MCP: ${JSON.stringify(messages)}`
|
|
20298
|
+
});
|
|
19996
20299
|
let systemPrompt;
|
|
19997
20300
|
for (const msg of options.prompt) {
|
|
19998
20301
|
if (msg.role === "system") {
|
|
@@ -20000,7 +20303,10 @@ var MCPSamplingLanguageModel = class {
|
|
|
20000
20303
|
break;
|
|
20001
20304
|
}
|
|
20002
20305
|
}
|
|
20003
|
-
|
|
20306
|
+
this.server.sendLoggingMessage({
|
|
20307
|
+
level: "info",
|
|
20308
|
+
data: `Client supports native tools: ${useNativeTools}`
|
|
20309
|
+
});
|
|
20004
20310
|
systemPrompt = this.injectResponseFormatInstructions(systemPrompt, options.responseFormat, useNativeTools);
|
|
20005
20311
|
systemPrompt = this.injectToolInstructions(systemPrompt, options.tools, useNativeTools);
|
|
20006
20312
|
const createMessageParams = {
|
|
@@ -20014,8 +20320,34 @@ var MCPSamplingLanguageModel = class {
|
|
|
20014
20320
|
createMessageParams.toolChoice = {
|
|
20015
20321
|
mode: "auto"
|
|
20016
20322
|
};
|
|
20323
|
+
this.server.sendLoggingMessage({
|
|
20324
|
+
level: "info",
|
|
20325
|
+
data: `Converted ${options.tools.length} tools to MCP format: ${JSON.stringify(createMessageParams.tools?.map((t) => t.name))}`
|
|
20326
|
+
});
|
|
20327
|
+
} else if (options.tools && options.tools.length > 0) {
|
|
20328
|
+
this.server.sendLoggingMessage({
|
|
20329
|
+
level: "info",
|
|
20330
|
+
data: `Tools provided but not using native mode - injecting into system prompt instead`
|
|
20331
|
+
});
|
|
20017
20332
|
}
|
|
20333
|
+
this.server.sendLoggingMessage({
|
|
20334
|
+
level: "info",
|
|
20335
|
+
data: `Calling createMessage with params: ${JSON.stringify({
|
|
20336
|
+
hasSystemPrompt: !!systemPrompt,
|
|
20337
|
+
hasTools: !!createMessageParams.tools,
|
|
20338
|
+
toolCount: createMessageParams.tools?.length || 0,
|
|
20339
|
+
createMessageParams
|
|
20340
|
+
}, null, 2)}`
|
|
20341
|
+
});
|
|
20018
20342
|
const result = await this.server.createMessage(createMessageParams);
|
|
20343
|
+
this.server.sendLoggingMessage({
|
|
20344
|
+
level: "info",
|
|
20345
|
+
data: `createMessage result: ${JSON.stringify({
|
|
20346
|
+
contentType: result.content.type,
|
|
20347
|
+
stopReason: result.stopReason,
|
|
20348
|
+
text: result.content
|
|
20349
|
+
})}`
|
|
20350
|
+
});
|
|
20019
20351
|
const content = [];
|
|
20020
20352
|
if (useNativeTools) {
|
|
20021
20353
|
const contentArray = Array.isArray(result.content) ? result.content : [
|
|
@@ -20133,8 +20465,52 @@ var MCPSamplingLanguageModel = class {
|
|
|
20133
20465
|
/**
|
|
20134
20466
|
* Convert AI SDK messages to MCP sampling format
|
|
20135
20467
|
*/
|
|
20136
|
-
convertMessages(prompt) {
|
|
20137
|
-
|
|
20468
|
+
convertMessages(prompt, useNativeTools) {
|
|
20469
|
+
if (!useNativeTools) {
|
|
20470
|
+
return convertAISDKToMCPMessages(prompt);
|
|
20471
|
+
}
|
|
20472
|
+
const messages = [];
|
|
20473
|
+
for (const msg of prompt) {
|
|
20474
|
+
if (msg.role === "system") continue;
|
|
20475
|
+
const role = msg.role === "assistant" ? "assistant" : "user";
|
|
20476
|
+
const contentBlocks = [];
|
|
20477
|
+
for (const part of msg.content) {
|
|
20478
|
+
if (part.type === "text") {
|
|
20479
|
+
contentBlocks.push({
|
|
20480
|
+
type: "text",
|
|
20481
|
+
text: part.text
|
|
20482
|
+
});
|
|
20483
|
+
} else if (part.type === "tool-call") {
|
|
20484
|
+
const call = part;
|
|
20485
|
+
contentBlocks.push({
|
|
20486
|
+
type: "tool_use",
|
|
20487
|
+
id: call.toolCallId,
|
|
20488
|
+
name: call.toolName,
|
|
20489
|
+
input: call.args ?? call.input ?? {}
|
|
20490
|
+
});
|
|
20491
|
+
} else if (part.type === "tool-result") {
|
|
20492
|
+
const result = part;
|
|
20493
|
+
contentBlocks.push({
|
|
20494
|
+
type: "tool_result",
|
|
20495
|
+
toolUseId: result.toolCallId,
|
|
20496
|
+
// TODO: Handle different result types properly
|
|
20497
|
+
content: [
|
|
20498
|
+
{
|
|
20499
|
+
type: "text",
|
|
20500
|
+
text: result.output.type === "text" ? result.output.value?.toString() : JSON.stringify(result.output)
|
|
20501
|
+
}
|
|
20502
|
+
]
|
|
20503
|
+
});
|
|
20504
|
+
}
|
|
20505
|
+
}
|
|
20506
|
+
if (contentBlocks.length > 0) {
|
|
20507
|
+
messages.push({
|
|
20508
|
+
role,
|
|
20509
|
+
content: contentBlocks
|
|
20510
|
+
});
|
|
20511
|
+
}
|
|
20512
|
+
}
|
|
20513
|
+
return messages;
|
|
20138
20514
|
}
|
|
20139
20515
|
/**
|
|
20140
20516
|
* Map MCP stop reason to AI SDK finish reason
|
|
@@ -20147,7 +20523,12 @@ var MCPSamplingLanguageModel = class {
|
|
|
20147
20523
|
*/
|
|
20148
20524
|
supportsSamplingTools() {
|
|
20149
20525
|
const capabilities = this.server.getClientCapabilities();
|
|
20150
|
-
|
|
20526
|
+
const supportsTools = !!capabilities?.sampling?.tools;
|
|
20527
|
+
this.server.sendLoggingMessage({
|
|
20528
|
+
level: "info",
|
|
20529
|
+
data: `Client capabilities check: sampling=${!!capabilities?.sampling}, tools=${supportsTools}`
|
|
20530
|
+
});
|
|
20531
|
+
return supportsTools;
|
|
20151
20532
|
}
|
|
20152
20533
|
/**
|
|
20153
20534
|
* Convert AI SDK tools to MCP Tool format
|
|
@@ -20213,8 +20594,16 @@ IMPORTANT: You MUST respond with valid JSON only. Do not include any text before
|
|
|
20213
20594
|
return systemPrompt;
|
|
20214
20595
|
}
|
|
20215
20596
|
if (useNativeTools) {
|
|
20597
|
+
this.server.sendLoggingMessage({
|
|
20598
|
+
level: "info",
|
|
20599
|
+
data: `Using native tools mode - skipping XML tool injection`
|
|
20600
|
+
});
|
|
20216
20601
|
return systemPrompt;
|
|
20217
20602
|
}
|
|
20603
|
+
this.server.sendLoggingMessage({
|
|
20604
|
+
level: "info",
|
|
20605
|
+
data: `Injecting ${tools.length} tools into system prompt (fallback mode)`
|
|
20606
|
+
});
|
|
20218
20607
|
let enhanced = systemPrompt || "";
|
|
20219
20608
|
const toolsPrompt = `
|
|
20220
20609
|
|
|
@@ -20225,7 +20614,7 @@ You have access to the following tools. To use a tool, respond with this XML for
|
|
|
20225
20614
|
</use_tool>
|
|
20226
20615
|
|
|
20227
20616
|
Follow the JSON schema definition for each tool's parameters.
|
|
20228
|
-
You can use multiple tools in one response.
|
|
20617
|
+
You can use multiple tools in one response. DO NOT include text before or after tool calls - wait for the tool results first.
|
|
20229
20618
|
|
|
20230
20619
|
Tools:`;
|
|
20231
20620
|
const toolDescriptions = tools.map((tool2) => {
|