@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.cjs
CHANGED
|
@@ -669,6 +669,7 @@ __export(util_exports, {
|
|
|
669
669
|
objectClone: () => objectClone,
|
|
670
670
|
omit: () => omit,
|
|
671
671
|
optionalKeys: () => optionalKeys,
|
|
672
|
+
parsedType: () => parsedType,
|
|
672
673
|
partial: () => partial,
|
|
673
674
|
pick: () => pick,
|
|
674
675
|
prefixIssues: () => prefixIssues,
|
|
@@ -1001,6 +1002,11 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
1001
1002
|
};
|
|
1002
1003
|
function pick(schema, mask) {
|
|
1003
1004
|
const currDef = schema._zod.def;
|
|
1005
|
+
const checks = currDef.checks;
|
|
1006
|
+
const hasChecks = checks && checks.length > 0;
|
|
1007
|
+
if (hasChecks) {
|
|
1008
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1009
|
+
}
|
|
1004
1010
|
const def = mergeDefs(schema._zod.def, {
|
|
1005
1011
|
get shape() {
|
|
1006
1012
|
const newShape = {};
|
|
@@ -1021,6 +1027,11 @@ function pick(schema, mask) {
|
|
|
1021
1027
|
}
|
|
1022
1028
|
function omit(schema, mask) {
|
|
1023
1029
|
const currDef = schema._zod.def;
|
|
1030
|
+
const checks = currDef.checks;
|
|
1031
|
+
const hasChecks = checks && checks.length > 0;
|
|
1032
|
+
if (hasChecks) {
|
|
1033
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1034
|
+
}
|
|
1024
1035
|
const def = mergeDefs(schema._zod.def, {
|
|
1025
1036
|
get shape() {
|
|
1026
1037
|
const newShape = { ...schema._zod.def.shape };
|
|
@@ -1046,15 +1057,19 @@ function extend(schema, shape) {
|
|
|
1046
1057
|
const checks = schema._zod.def.checks;
|
|
1047
1058
|
const hasChecks = checks && checks.length > 0;
|
|
1048
1059
|
if (hasChecks) {
|
|
1049
|
-
|
|
1060
|
+
const existingShape = schema._zod.def.shape;
|
|
1061
|
+
for (const key in shape) {
|
|
1062
|
+
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
1063
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1050
1066
|
}
|
|
1051
1067
|
const def = mergeDefs(schema._zod.def, {
|
|
1052
1068
|
get shape() {
|
|
1053
1069
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
1054
1070
|
assignProp(this, "shape", _shape);
|
|
1055
1071
|
return _shape;
|
|
1056
|
-
}
|
|
1057
|
-
checks: []
|
|
1072
|
+
}
|
|
1058
1073
|
});
|
|
1059
1074
|
return clone(schema, def);
|
|
1060
1075
|
}
|
|
@@ -1062,15 +1077,13 @@ function safeExtend(schema, shape) {
|
|
|
1062
1077
|
if (!isPlainObject(shape)) {
|
|
1063
1078
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1064
1079
|
}
|
|
1065
|
-
const def = {
|
|
1066
|
-
...schema._zod.def,
|
|
1080
|
+
const def = mergeDefs(schema._zod.def, {
|
|
1067
1081
|
get shape() {
|
|
1068
1082
|
const _shape = { ...schema._zod.def.shape, ...shape };
|
|
1069
1083
|
assignProp(this, "shape", _shape);
|
|
1070
1084
|
return _shape;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
};
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1074
1087
|
return clone(schema, def);
|
|
1075
1088
|
}
|
|
1076
1089
|
function merge(a, b) {
|
|
@@ -1089,6 +1102,12 @@ function merge(a, b) {
|
|
|
1089
1102
|
return clone(a, def);
|
|
1090
1103
|
}
|
|
1091
1104
|
function partial(Class2, schema, mask) {
|
|
1105
|
+
const currDef = schema._zod.def;
|
|
1106
|
+
const checks = currDef.checks;
|
|
1107
|
+
const hasChecks = checks && checks.length > 0;
|
|
1108
|
+
if (hasChecks) {
|
|
1109
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1110
|
+
}
|
|
1092
1111
|
const def = mergeDefs(schema._zod.def, {
|
|
1093
1112
|
get shape() {
|
|
1094
1113
|
const oldShape = schema._zod.def.shape;
|
|
@@ -1147,8 +1166,7 @@ function required(Class2, schema, mask) {
|
|
|
1147
1166
|
}
|
|
1148
1167
|
assignProp(this, "shape", shape);
|
|
1149
1168
|
return shape;
|
|
1150
|
-
}
|
|
1151
|
-
checks: []
|
|
1169
|
+
}
|
|
1152
1170
|
});
|
|
1153
1171
|
return clone(schema, def);
|
|
1154
1172
|
}
|
|
@@ -1202,6 +1220,27 @@ function getLengthableOrigin(input) {
|
|
|
1202
1220
|
return "string";
|
|
1203
1221
|
return "unknown";
|
|
1204
1222
|
}
|
|
1223
|
+
function parsedType(data) {
|
|
1224
|
+
const t = typeof data;
|
|
1225
|
+
switch (t) {
|
|
1226
|
+
case "number": {
|
|
1227
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
1228
|
+
}
|
|
1229
|
+
case "object": {
|
|
1230
|
+
if (data === null) {
|
|
1231
|
+
return "null";
|
|
1232
|
+
}
|
|
1233
|
+
if (Array.isArray(data)) {
|
|
1234
|
+
return "array";
|
|
1235
|
+
}
|
|
1236
|
+
const obj = data;
|
|
1237
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
1238
|
+
return obj.constructor.name;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
return t;
|
|
1243
|
+
}
|
|
1205
1244
|
function issue(...args) {
|
|
1206
1245
|
const [iss, input, inst] = args;
|
|
1207
1246
|
if (typeof iss === "string") {
|
|
@@ -1508,7 +1547,7 @@ var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/
|
|
|
1508
1547
|
var base64url = /^[A-Za-z0-9_-]*$/;
|
|
1509
1548
|
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])?)*\.?$/;
|
|
1510
1549
|
var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
1511
|
-
var e164 = /^\+
|
|
1550
|
+
var e164 = /^\+[1-9]\d{6,14}$/;
|
|
1512
1551
|
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])))`;
|
|
1513
1552
|
var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
1514
1553
|
function timeSource(args) {
|
|
@@ -1535,7 +1574,7 @@ var string = (params) => {
|
|
|
1535
1574
|
};
|
|
1536
1575
|
var bigint = /^-?\d+n?$/;
|
|
1537
1576
|
var integer = /^-?\d+$/;
|
|
1538
|
-
var number = /^-?\d+(?:\.\d+)
|
|
1577
|
+
var number = /^-?\d+(?:\.\d+)?$/;
|
|
1539
1578
|
var boolean = /^(?:true|false)$/i;
|
|
1540
1579
|
var _null = /^null$/i;
|
|
1541
1580
|
var _undefined = /^undefined$/i;
|
|
@@ -1596,7 +1635,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
|
|
|
1596
1635
|
payload.issues.push({
|
|
1597
1636
|
origin,
|
|
1598
1637
|
code: "too_big",
|
|
1599
|
-
maximum: def.value,
|
|
1638
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1600
1639
|
input: payload.value,
|
|
1601
1640
|
inclusive: def.inclusive,
|
|
1602
1641
|
inst,
|
|
@@ -1624,7 +1663,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
|
|
|
1624
1663
|
payload.issues.push({
|
|
1625
1664
|
origin,
|
|
1626
1665
|
code: "too_small",
|
|
1627
|
-
minimum: def.value,
|
|
1666
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
1628
1667
|
input: payload.value,
|
|
1629
1668
|
inclusive: def.inclusive,
|
|
1630
1669
|
inst,
|
|
@@ -1691,6 +1730,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1691
1730
|
note: "Integers must be within the safe integer range.",
|
|
1692
1731
|
inst,
|
|
1693
1732
|
origin,
|
|
1733
|
+
inclusive: true,
|
|
1694
1734
|
continue: !def.abort
|
|
1695
1735
|
});
|
|
1696
1736
|
} else {
|
|
@@ -1701,6 +1741,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1701
1741
|
note: "Integers must be within the safe integer range.",
|
|
1702
1742
|
inst,
|
|
1703
1743
|
origin,
|
|
1744
|
+
inclusive: true,
|
|
1704
1745
|
continue: !def.abort
|
|
1705
1746
|
});
|
|
1706
1747
|
}
|
|
@@ -1724,7 +1765,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
1724
1765
|
input,
|
|
1725
1766
|
code: "too_big",
|
|
1726
1767
|
maximum,
|
|
1727
|
-
|
|
1768
|
+
inclusive: true,
|
|
1769
|
+
inst,
|
|
1770
|
+
continue: !def.abort
|
|
1728
1771
|
});
|
|
1729
1772
|
}
|
|
1730
1773
|
};
|
|
@@ -1757,7 +1800,9 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
|
|
|
1757
1800
|
input,
|
|
1758
1801
|
code: "too_big",
|
|
1759
1802
|
maximum,
|
|
1760
|
-
|
|
1803
|
+
inclusive: true,
|
|
1804
|
+
inst,
|
|
1805
|
+
continue: !def.abort
|
|
1761
1806
|
});
|
|
1762
1807
|
}
|
|
1763
1808
|
};
|
|
@@ -2145,8 +2190,8 @@ var Doc = class {
|
|
|
2145
2190
|
// __mcpc__core_latest/node_modules/zod/v4/core/versions.js
|
|
2146
2191
|
var version = {
|
|
2147
2192
|
major: 4,
|
|
2148
|
-
minor:
|
|
2149
|
-
patch:
|
|
2193
|
+
minor: 3,
|
|
2194
|
+
patch: 5
|
|
2150
2195
|
};
|
|
2151
2196
|
|
|
2152
2197
|
// __mcpc__core_latest/node_modules/zod/v4/core/schemas.js
|
|
@@ -2246,7 +2291,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2246
2291
|
return runChecks(result, checks, ctx);
|
|
2247
2292
|
};
|
|
2248
2293
|
}
|
|
2249
|
-
inst
|
|
2294
|
+
defineLazy(inst, "~standard", () => ({
|
|
2250
2295
|
validate: (value) => {
|
|
2251
2296
|
try {
|
|
2252
2297
|
const r = safeParse(inst, value);
|
|
@@ -2257,7 +2302,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
2257
2302
|
},
|
|
2258
2303
|
vendor: "zod",
|
|
2259
2304
|
version: 1
|
|
2260
|
-
};
|
|
2305
|
+
}));
|
|
2261
2306
|
});
|
|
2262
2307
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
2263
2308
|
$ZodType.init(inst, def);
|
|
@@ -2791,8 +2836,11 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
2791
2836
|
return payload;
|
|
2792
2837
|
};
|
|
2793
2838
|
});
|
|
2794
|
-
function handlePropertyResult(result, final, key, input) {
|
|
2839
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
2795
2840
|
if (result.issues.length) {
|
|
2841
|
+
if (isOptionalOut && !(key in input)) {
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2796
2844
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
2797
2845
|
}
|
|
2798
2846
|
if (result.value === void 0) {
|
|
@@ -2824,6 +2872,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2824
2872
|
const keySet = def.keySet;
|
|
2825
2873
|
const _catchall = def.catchall._zod;
|
|
2826
2874
|
const t = _catchall.def.type;
|
|
2875
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
2827
2876
|
for (const key in input) {
|
|
2828
2877
|
if (keySet.has(key))
|
|
2829
2878
|
continue;
|
|
@@ -2833,9 +2882,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
2833
2882
|
}
|
|
2834
2883
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
2835
2884
|
if (r instanceof Promise) {
|
|
2836
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
2885
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
2837
2886
|
} else {
|
|
2838
|
-
handlePropertyResult(r, payload, key, input);
|
|
2887
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
2839
2888
|
}
|
|
2840
2889
|
}
|
|
2841
2890
|
if (unrecognized.length) {
|
|
@@ -2901,11 +2950,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2901
2950
|
const shape = value.shape;
|
|
2902
2951
|
for (const key of value.keys) {
|
|
2903
2952
|
const el = shape[key];
|
|
2953
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
2904
2954
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2905
2955
|
if (r instanceof Promise) {
|
|
2906
|
-
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
|
|
2956
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
2907
2957
|
} else {
|
|
2908
|
-
handlePropertyResult(r, payload, key, input);
|
|
2958
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
2909
2959
|
}
|
|
2910
2960
|
}
|
|
2911
2961
|
if (!catchall) {
|
|
@@ -2935,8 +2985,31 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2935
2985
|
for (const key of normalized.keys) {
|
|
2936
2986
|
const id = ids[key];
|
|
2937
2987
|
const k = esc(key);
|
|
2988
|
+
const schema = shape[key];
|
|
2989
|
+
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
2938
2990
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
2939
|
-
|
|
2991
|
+
if (isOptionalOut) {
|
|
2992
|
+
doc.write(`
|
|
2993
|
+
if (${id}.issues.length) {
|
|
2994
|
+
if (${k} in input) {
|
|
2995
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2996
|
+
...iss,
|
|
2997
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
2998
|
+
})));
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
if (${id}.value === undefined) {
|
|
3003
|
+
if (${k} in input) {
|
|
3004
|
+
newResult[${k}] = undefined;
|
|
3005
|
+
}
|
|
3006
|
+
} else {
|
|
3007
|
+
newResult[${k}] = ${id}.value;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
`);
|
|
3011
|
+
} else {
|
|
3012
|
+
doc.write(`
|
|
2940
3013
|
if (${id}.issues.length) {
|
|
2941
3014
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
2942
3015
|
...iss,
|
|
@@ -2944,7 +3017,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2944
3017
|
})));
|
|
2945
3018
|
}
|
|
2946
3019
|
|
|
2947
|
-
|
|
2948
3020
|
if (${id}.value === undefined) {
|
|
2949
3021
|
if (${k} in input) {
|
|
2950
3022
|
newResult[${k}] = undefined;
|
|
@@ -2954,6 +3026,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2954
3026
|
}
|
|
2955
3027
|
|
|
2956
3028
|
`);
|
|
3029
|
+
}
|
|
2957
3030
|
}
|
|
2958
3031
|
doc.write(`payload.value = newResult;`);
|
|
2959
3032
|
doc.write(`return payload;`);
|
|
@@ -3236,11 +3309,34 @@ function mergeValues(a, b) {
|
|
|
3236
3309
|
return { valid: false, mergeErrorPath: [] };
|
|
3237
3310
|
}
|
|
3238
3311
|
function handleIntersectionResults(result, left, right) {
|
|
3239
|
-
|
|
3240
|
-
|
|
3312
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
3313
|
+
let unrecIssue;
|
|
3314
|
+
for (const iss of left.issues) {
|
|
3315
|
+
if (iss.code === "unrecognized_keys") {
|
|
3316
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
3317
|
+
for (const k of iss.keys) {
|
|
3318
|
+
if (!unrecKeys.has(k))
|
|
3319
|
+
unrecKeys.set(k, {});
|
|
3320
|
+
unrecKeys.get(k).l = true;
|
|
3321
|
+
}
|
|
3322
|
+
} else {
|
|
3323
|
+
result.issues.push(iss);
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
for (const iss of right.issues) {
|
|
3327
|
+
if (iss.code === "unrecognized_keys") {
|
|
3328
|
+
for (const k of iss.keys) {
|
|
3329
|
+
if (!unrecKeys.has(k))
|
|
3330
|
+
unrecKeys.set(k, {});
|
|
3331
|
+
unrecKeys.get(k).r = true;
|
|
3332
|
+
}
|
|
3333
|
+
} else {
|
|
3334
|
+
result.issues.push(iss);
|
|
3335
|
+
}
|
|
3241
3336
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3337
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
3338
|
+
if (bothKeys.length && unrecIssue) {
|
|
3339
|
+
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
3244
3340
|
}
|
|
3245
3341
|
if (aborted(result))
|
|
3246
3342
|
return result;
|
|
@@ -3274,7 +3370,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
3274
3370
|
const tooSmall = input.length < optStart - 1;
|
|
3275
3371
|
if (tooBig || tooSmall) {
|
|
3276
3372
|
payload.issues.push({
|
|
3277
|
-
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
3373
|
+
...tooBig ? { code: "too_big", maximum: items.length, inclusive: true } : { code: "too_small", minimum: items.length },
|
|
3278
3374
|
input,
|
|
3279
3375
|
inst,
|
|
3280
3376
|
origin: "array"
|
|
@@ -3382,10 +3478,20 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3382
3478
|
for (const key of Reflect.ownKeys(input)) {
|
|
3383
3479
|
if (key === "__proto__")
|
|
3384
3480
|
continue;
|
|
3385
|
-
|
|
3481
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
3386
3482
|
if (keyResult instanceof Promise) {
|
|
3387
3483
|
throw new Error("Async schemas not supported in object keys currently");
|
|
3388
3484
|
}
|
|
3485
|
+
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length && keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
|
|
3486
|
+
if (checkNumericKey) {
|
|
3487
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
3488
|
+
if (retryResult instanceof Promise) {
|
|
3489
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
3490
|
+
}
|
|
3491
|
+
if (retryResult.issues.length === 0) {
|
|
3492
|
+
keyResult = retryResult;
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3389
3495
|
if (keyResult.issues.length) {
|
|
3390
3496
|
if (def.mode === "loose") {
|
|
3391
3497
|
payload.value[key] = input[key];
|
|
@@ -3625,6 +3731,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
|
3625
3731
|
return def.innerType._zod.run(payload, ctx);
|
|
3626
3732
|
};
|
|
3627
3733
|
});
|
|
3734
|
+
var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
3735
|
+
$ZodOptional.init(inst, def);
|
|
3736
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
3737
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
3738
|
+
inst._zod.parse = (payload, ctx) => {
|
|
3739
|
+
return def.innerType._zod.run(payload, ctx);
|
|
3740
|
+
};
|
|
3741
|
+
});
|
|
3628
3742
|
var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
3629
3743
|
$ZodType.init(inst, def);
|
|
3630
3744
|
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
@@ -3903,7 +4017,7 @@ var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (i
|
|
|
3903
4017
|
payload.issues.push({
|
|
3904
4018
|
input: payload.value,
|
|
3905
4019
|
inst,
|
|
3906
|
-
expected: "
|
|
4020
|
+
expected: "string",
|
|
3907
4021
|
code: "invalid_type"
|
|
3908
4022
|
});
|
|
3909
4023
|
return payload;
|
|
@@ -4052,37 +4166,18 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
4052
4166
|
}
|
|
4053
4167
|
|
|
4054
4168
|
// __mcpc__core_latest/node_modules/zod/v4/locales/en.js
|
|
4055
|
-
var parsedType = (data) => {
|
|
4056
|
-
const t = typeof data;
|
|
4057
|
-
switch (t) {
|
|
4058
|
-
case "number": {
|
|
4059
|
-
return Number.isNaN(data) ? "NaN" : "number";
|
|
4060
|
-
}
|
|
4061
|
-
case "object": {
|
|
4062
|
-
if (Array.isArray(data)) {
|
|
4063
|
-
return "array";
|
|
4064
|
-
}
|
|
4065
|
-
if (data === null) {
|
|
4066
|
-
return "null";
|
|
4067
|
-
}
|
|
4068
|
-
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
4069
|
-
return data.constructor.name;
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
|
-
}
|
|
4073
|
-
return t;
|
|
4074
|
-
};
|
|
4075
4169
|
var error = () => {
|
|
4076
4170
|
const Sizable = {
|
|
4077
4171
|
string: { unit: "characters", verb: "to have" },
|
|
4078
4172
|
file: { unit: "bytes", verb: "to have" },
|
|
4079
4173
|
array: { unit: "items", verb: "to have" },
|
|
4080
|
-
set: { unit: "items", verb: "to have" }
|
|
4174
|
+
set: { unit: "items", verb: "to have" },
|
|
4175
|
+
map: { unit: "entries", verb: "to have" }
|
|
4081
4176
|
};
|
|
4082
4177
|
function getSizing(origin) {
|
|
4083
4178
|
return Sizable[origin] ?? null;
|
|
4084
4179
|
}
|
|
4085
|
-
const
|
|
4180
|
+
const FormatDictionary = {
|
|
4086
4181
|
regex: "input",
|
|
4087
4182
|
email: "email address",
|
|
4088
4183
|
url: "URL",
|
|
@@ -4113,10 +4208,19 @@ var error = () => {
|
|
|
4113
4208
|
jwt: "JWT",
|
|
4114
4209
|
template_literal: "input"
|
|
4115
4210
|
};
|
|
4211
|
+
const TypeDictionary = {
|
|
4212
|
+
// Compatibility: "nan" -> "NaN" for display
|
|
4213
|
+
nan: "NaN"
|
|
4214
|
+
// All other type names omitted - they fall back to raw values via ?? operator
|
|
4215
|
+
};
|
|
4116
4216
|
return (issue2) => {
|
|
4117
4217
|
switch (issue2.code) {
|
|
4118
|
-
case "invalid_type":
|
|
4119
|
-
|
|
4218
|
+
case "invalid_type": {
|
|
4219
|
+
const expected = TypeDictionary[issue2.expected] ?? issue2.expected;
|
|
4220
|
+
const receivedType = parsedType(issue2.input);
|
|
4221
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
4222
|
+
return `Invalid input: expected ${expected}, received ${received}`;
|
|
4223
|
+
}
|
|
4120
4224
|
case "invalid_value":
|
|
4121
4225
|
if (issue2.values.length === 1)
|
|
4122
4226
|
return `Invalid input: expected ${stringifyPrimitive(issue2.values[0])}`;
|
|
@@ -4147,7 +4251,7 @@ var error = () => {
|
|
|
4147
4251
|
return `Invalid string: must include "${_issue.includes}"`;
|
|
4148
4252
|
if (_issue.format === "regex")
|
|
4149
4253
|
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
4150
|
-
return `Invalid ${
|
|
4254
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue2.format}`;
|
|
4151
4255
|
}
|
|
4152
4256
|
case "not_multiple_of":
|
|
4153
4257
|
return `Invalid number: must be a multiple of ${issue2.divisor}`;
|
|
@@ -4183,9 +4287,6 @@ var $ZodRegistry = class {
|
|
|
4183
4287
|
const meta3 = _meta[0];
|
|
4184
4288
|
this._map.set(schema, meta3);
|
|
4185
4289
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
4186
|
-
if (this._idmap.has(meta3.id)) {
|
|
4187
|
-
throw new Error(`ID ${meta3.id} already exists in the registry`);
|
|
4188
|
-
}
|
|
4189
4290
|
this._idmap.set(meta3.id, schema);
|
|
4190
4291
|
}
|
|
4191
4292
|
return this;
|
|
@@ -4224,12 +4325,14 @@ function registry() {
|
|
|
4224
4325
|
var globalRegistry = globalThis.__zod_globalRegistry;
|
|
4225
4326
|
|
|
4226
4327
|
// __mcpc__core_latest/node_modules/zod/v4/core/api.js
|
|
4328
|
+
// @__NO_SIDE_EFFECTS__
|
|
4227
4329
|
function _string(Class2, params) {
|
|
4228
4330
|
return new Class2({
|
|
4229
4331
|
type: "string",
|
|
4230
4332
|
...normalizeParams(params)
|
|
4231
4333
|
});
|
|
4232
4334
|
}
|
|
4335
|
+
// @__NO_SIDE_EFFECTS__
|
|
4233
4336
|
function _coercedString(Class2, params) {
|
|
4234
4337
|
return new Class2({
|
|
4235
4338
|
type: "string",
|
|
@@ -4237,6 +4340,7 @@ function _coercedString(Class2, params) {
|
|
|
4237
4340
|
...normalizeParams(params)
|
|
4238
4341
|
});
|
|
4239
4342
|
}
|
|
4343
|
+
// @__NO_SIDE_EFFECTS__
|
|
4240
4344
|
function _email(Class2, params) {
|
|
4241
4345
|
return new Class2({
|
|
4242
4346
|
type: "string",
|
|
@@ -4246,6 +4350,7 @@ function _email(Class2, params) {
|
|
|
4246
4350
|
...normalizeParams(params)
|
|
4247
4351
|
});
|
|
4248
4352
|
}
|
|
4353
|
+
// @__NO_SIDE_EFFECTS__
|
|
4249
4354
|
function _guid(Class2, params) {
|
|
4250
4355
|
return new Class2({
|
|
4251
4356
|
type: "string",
|
|
@@ -4255,6 +4360,7 @@ function _guid(Class2, params) {
|
|
|
4255
4360
|
...normalizeParams(params)
|
|
4256
4361
|
});
|
|
4257
4362
|
}
|
|
4363
|
+
// @__NO_SIDE_EFFECTS__
|
|
4258
4364
|
function _uuid(Class2, params) {
|
|
4259
4365
|
return new Class2({
|
|
4260
4366
|
type: "string",
|
|
@@ -4264,6 +4370,7 @@ function _uuid(Class2, params) {
|
|
|
4264
4370
|
...normalizeParams(params)
|
|
4265
4371
|
});
|
|
4266
4372
|
}
|
|
4373
|
+
// @__NO_SIDE_EFFECTS__
|
|
4267
4374
|
function _uuidv4(Class2, params) {
|
|
4268
4375
|
return new Class2({
|
|
4269
4376
|
type: "string",
|
|
@@ -4274,6 +4381,7 @@ function _uuidv4(Class2, params) {
|
|
|
4274
4381
|
...normalizeParams(params)
|
|
4275
4382
|
});
|
|
4276
4383
|
}
|
|
4384
|
+
// @__NO_SIDE_EFFECTS__
|
|
4277
4385
|
function _uuidv6(Class2, params) {
|
|
4278
4386
|
return new Class2({
|
|
4279
4387
|
type: "string",
|
|
@@ -4284,6 +4392,7 @@ function _uuidv6(Class2, params) {
|
|
|
4284
4392
|
...normalizeParams(params)
|
|
4285
4393
|
});
|
|
4286
4394
|
}
|
|
4395
|
+
// @__NO_SIDE_EFFECTS__
|
|
4287
4396
|
function _uuidv7(Class2, params) {
|
|
4288
4397
|
return new Class2({
|
|
4289
4398
|
type: "string",
|
|
@@ -4294,6 +4403,7 @@ function _uuidv7(Class2, params) {
|
|
|
4294
4403
|
...normalizeParams(params)
|
|
4295
4404
|
});
|
|
4296
4405
|
}
|
|
4406
|
+
// @__NO_SIDE_EFFECTS__
|
|
4297
4407
|
function _url(Class2, params) {
|
|
4298
4408
|
return new Class2({
|
|
4299
4409
|
type: "string",
|
|
@@ -4303,6 +4413,7 @@ function _url(Class2, params) {
|
|
|
4303
4413
|
...normalizeParams(params)
|
|
4304
4414
|
});
|
|
4305
4415
|
}
|
|
4416
|
+
// @__NO_SIDE_EFFECTS__
|
|
4306
4417
|
function _emoji2(Class2, params) {
|
|
4307
4418
|
return new Class2({
|
|
4308
4419
|
type: "string",
|
|
@@ -4312,6 +4423,7 @@ function _emoji2(Class2, params) {
|
|
|
4312
4423
|
...normalizeParams(params)
|
|
4313
4424
|
});
|
|
4314
4425
|
}
|
|
4426
|
+
// @__NO_SIDE_EFFECTS__
|
|
4315
4427
|
function _nanoid(Class2, params) {
|
|
4316
4428
|
return new Class2({
|
|
4317
4429
|
type: "string",
|
|
@@ -4321,6 +4433,7 @@ function _nanoid(Class2, params) {
|
|
|
4321
4433
|
...normalizeParams(params)
|
|
4322
4434
|
});
|
|
4323
4435
|
}
|
|
4436
|
+
// @__NO_SIDE_EFFECTS__
|
|
4324
4437
|
function _cuid(Class2, params) {
|
|
4325
4438
|
return new Class2({
|
|
4326
4439
|
type: "string",
|
|
@@ -4330,6 +4443,7 @@ function _cuid(Class2, params) {
|
|
|
4330
4443
|
...normalizeParams(params)
|
|
4331
4444
|
});
|
|
4332
4445
|
}
|
|
4446
|
+
// @__NO_SIDE_EFFECTS__
|
|
4333
4447
|
function _cuid2(Class2, params) {
|
|
4334
4448
|
return new Class2({
|
|
4335
4449
|
type: "string",
|
|
@@ -4339,6 +4453,7 @@ function _cuid2(Class2, params) {
|
|
|
4339
4453
|
...normalizeParams(params)
|
|
4340
4454
|
});
|
|
4341
4455
|
}
|
|
4456
|
+
// @__NO_SIDE_EFFECTS__
|
|
4342
4457
|
function _ulid(Class2, params) {
|
|
4343
4458
|
return new Class2({
|
|
4344
4459
|
type: "string",
|
|
@@ -4348,6 +4463,7 @@ function _ulid(Class2, params) {
|
|
|
4348
4463
|
...normalizeParams(params)
|
|
4349
4464
|
});
|
|
4350
4465
|
}
|
|
4466
|
+
// @__NO_SIDE_EFFECTS__
|
|
4351
4467
|
function _xid(Class2, params) {
|
|
4352
4468
|
return new Class2({
|
|
4353
4469
|
type: "string",
|
|
@@ -4357,6 +4473,7 @@ function _xid(Class2, params) {
|
|
|
4357
4473
|
...normalizeParams(params)
|
|
4358
4474
|
});
|
|
4359
4475
|
}
|
|
4476
|
+
// @__NO_SIDE_EFFECTS__
|
|
4360
4477
|
function _ksuid(Class2, params) {
|
|
4361
4478
|
return new Class2({
|
|
4362
4479
|
type: "string",
|
|
@@ -4366,6 +4483,7 @@ function _ksuid(Class2, params) {
|
|
|
4366
4483
|
...normalizeParams(params)
|
|
4367
4484
|
});
|
|
4368
4485
|
}
|
|
4486
|
+
// @__NO_SIDE_EFFECTS__
|
|
4369
4487
|
function _ipv4(Class2, params) {
|
|
4370
4488
|
return new Class2({
|
|
4371
4489
|
type: "string",
|
|
@@ -4375,6 +4493,7 @@ function _ipv4(Class2, params) {
|
|
|
4375
4493
|
...normalizeParams(params)
|
|
4376
4494
|
});
|
|
4377
4495
|
}
|
|
4496
|
+
// @__NO_SIDE_EFFECTS__
|
|
4378
4497
|
function _ipv6(Class2, params) {
|
|
4379
4498
|
return new Class2({
|
|
4380
4499
|
type: "string",
|
|
@@ -4384,6 +4503,7 @@ function _ipv6(Class2, params) {
|
|
|
4384
4503
|
...normalizeParams(params)
|
|
4385
4504
|
});
|
|
4386
4505
|
}
|
|
4506
|
+
// @__NO_SIDE_EFFECTS__
|
|
4387
4507
|
function _mac(Class2, params) {
|
|
4388
4508
|
return new Class2({
|
|
4389
4509
|
type: "string",
|
|
@@ -4393,6 +4513,7 @@ function _mac(Class2, params) {
|
|
|
4393
4513
|
...normalizeParams(params)
|
|
4394
4514
|
});
|
|
4395
4515
|
}
|
|
4516
|
+
// @__NO_SIDE_EFFECTS__
|
|
4396
4517
|
function _cidrv4(Class2, params) {
|
|
4397
4518
|
return new Class2({
|
|
4398
4519
|
type: "string",
|
|
@@ -4402,6 +4523,7 @@ function _cidrv4(Class2, params) {
|
|
|
4402
4523
|
...normalizeParams(params)
|
|
4403
4524
|
});
|
|
4404
4525
|
}
|
|
4526
|
+
// @__NO_SIDE_EFFECTS__
|
|
4405
4527
|
function _cidrv6(Class2, params) {
|
|
4406
4528
|
return new Class2({
|
|
4407
4529
|
type: "string",
|
|
@@ -4411,6 +4533,7 @@ function _cidrv6(Class2, params) {
|
|
|
4411
4533
|
...normalizeParams(params)
|
|
4412
4534
|
});
|
|
4413
4535
|
}
|
|
4536
|
+
// @__NO_SIDE_EFFECTS__
|
|
4414
4537
|
function _base64(Class2, params) {
|
|
4415
4538
|
return new Class2({
|
|
4416
4539
|
type: "string",
|
|
@@ -4420,6 +4543,7 @@ function _base64(Class2, params) {
|
|
|
4420
4543
|
...normalizeParams(params)
|
|
4421
4544
|
});
|
|
4422
4545
|
}
|
|
4546
|
+
// @__NO_SIDE_EFFECTS__
|
|
4423
4547
|
function _base64url(Class2, params) {
|
|
4424
4548
|
return new Class2({
|
|
4425
4549
|
type: "string",
|
|
@@ -4429,6 +4553,7 @@ function _base64url(Class2, params) {
|
|
|
4429
4553
|
...normalizeParams(params)
|
|
4430
4554
|
});
|
|
4431
4555
|
}
|
|
4556
|
+
// @__NO_SIDE_EFFECTS__
|
|
4432
4557
|
function _e164(Class2, params) {
|
|
4433
4558
|
return new Class2({
|
|
4434
4559
|
type: "string",
|
|
@@ -4438,6 +4563,7 @@ function _e164(Class2, params) {
|
|
|
4438
4563
|
...normalizeParams(params)
|
|
4439
4564
|
});
|
|
4440
4565
|
}
|
|
4566
|
+
// @__NO_SIDE_EFFECTS__
|
|
4441
4567
|
function _jwt(Class2, params) {
|
|
4442
4568
|
return new Class2({
|
|
4443
4569
|
type: "string",
|
|
@@ -4447,6 +4573,7 @@ function _jwt(Class2, params) {
|
|
|
4447
4573
|
...normalizeParams(params)
|
|
4448
4574
|
});
|
|
4449
4575
|
}
|
|
4576
|
+
// @__NO_SIDE_EFFECTS__
|
|
4450
4577
|
function _isoDateTime(Class2, params) {
|
|
4451
4578
|
return new Class2({
|
|
4452
4579
|
type: "string",
|
|
@@ -4458,6 +4585,7 @@ function _isoDateTime(Class2, params) {
|
|
|
4458
4585
|
...normalizeParams(params)
|
|
4459
4586
|
});
|
|
4460
4587
|
}
|
|
4588
|
+
// @__NO_SIDE_EFFECTS__
|
|
4461
4589
|
function _isoDate(Class2, params) {
|
|
4462
4590
|
return new Class2({
|
|
4463
4591
|
type: "string",
|
|
@@ -4466,6 +4594,7 @@ function _isoDate(Class2, params) {
|
|
|
4466
4594
|
...normalizeParams(params)
|
|
4467
4595
|
});
|
|
4468
4596
|
}
|
|
4597
|
+
// @__NO_SIDE_EFFECTS__
|
|
4469
4598
|
function _isoTime(Class2, params) {
|
|
4470
4599
|
return new Class2({
|
|
4471
4600
|
type: "string",
|
|
@@ -4475,6 +4604,7 @@ function _isoTime(Class2, params) {
|
|
|
4475
4604
|
...normalizeParams(params)
|
|
4476
4605
|
});
|
|
4477
4606
|
}
|
|
4607
|
+
// @__NO_SIDE_EFFECTS__
|
|
4478
4608
|
function _isoDuration(Class2, params) {
|
|
4479
4609
|
return new Class2({
|
|
4480
4610
|
type: "string",
|
|
@@ -4483,6 +4613,7 @@ function _isoDuration(Class2, params) {
|
|
|
4483
4613
|
...normalizeParams(params)
|
|
4484
4614
|
});
|
|
4485
4615
|
}
|
|
4616
|
+
// @__NO_SIDE_EFFECTS__
|
|
4486
4617
|
function _number(Class2, params) {
|
|
4487
4618
|
return new Class2({
|
|
4488
4619
|
type: "number",
|
|
@@ -4490,6 +4621,7 @@ function _number(Class2, params) {
|
|
|
4490
4621
|
...normalizeParams(params)
|
|
4491
4622
|
});
|
|
4492
4623
|
}
|
|
4624
|
+
// @__NO_SIDE_EFFECTS__
|
|
4493
4625
|
function _coercedNumber(Class2, params) {
|
|
4494
4626
|
return new Class2({
|
|
4495
4627
|
type: "number",
|
|
@@ -4498,6 +4630,7 @@ function _coercedNumber(Class2, params) {
|
|
|
4498
4630
|
...normalizeParams(params)
|
|
4499
4631
|
});
|
|
4500
4632
|
}
|
|
4633
|
+
// @__NO_SIDE_EFFECTS__
|
|
4501
4634
|
function _int(Class2, params) {
|
|
4502
4635
|
return new Class2({
|
|
4503
4636
|
type: "number",
|
|
@@ -4507,6 +4640,7 @@ function _int(Class2, params) {
|
|
|
4507
4640
|
...normalizeParams(params)
|
|
4508
4641
|
});
|
|
4509
4642
|
}
|
|
4643
|
+
// @__NO_SIDE_EFFECTS__
|
|
4510
4644
|
function _float32(Class2, params) {
|
|
4511
4645
|
return new Class2({
|
|
4512
4646
|
type: "number",
|
|
@@ -4516,6 +4650,7 @@ function _float32(Class2, params) {
|
|
|
4516
4650
|
...normalizeParams(params)
|
|
4517
4651
|
});
|
|
4518
4652
|
}
|
|
4653
|
+
// @__NO_SIDE_EFFECTS__
|
|
4519
4654
|
function _float64(Class2, params) {
|
|
4520
4655
|
return new Class2({
|
|
4521
4656
|
type: "number",
|
|
@@ -4525,6 +4660,7 @@ function _float64(Class2, params) {
|
|
|
4525
4660
|
...normalizeParams(params)
|
|
4526
4661
|
});
|
|
4527
4662
|
}
|
|
4663
|
+
// @__NO_SIDE_EFFECTS__
|
|
4528
4664
|
function _int32(Class2, params) {
|
|
4529
4665
|
return new Class2({
|
|
4530
4666
|
type: "number",
|
|
@@ -4534,6 +4670,7 @@ function _int32(Class2, params) {
|
|
|
4534
4670
|
...normalizeParams(params)
|
|
4535
4671
|
});
|
|
4536
4672
|
}
|
|
4673
|
+
// @__NO_SIDE_EFFECTS__
|
|
4537
4674
|
function _uint32(Class2, params) {
|
|
4538
4675
|
return new Class2({
|
|
4539
4676
|
type: "number",
|
|
@@ -4543,12 +4680,14 @@ function _uint32(Class2, params) {
|
|
|
4543
4680
|
...normalizeParams(params)
|
|
4544
4681
|
});
|
|
4545
4682
|
}
|
|
4683
|
+
// @__NO_SIDE_EFFECTS__
|
|
4546
4684
|
function _boolean(Class2, params) {
|
|
4547
4685
|
return new Class2({
|
|
4548
4686
|
type: "boolean",
|
|
4549
4687
|
...normalizeParams(params)
|
|
4550
4688
|
});
|
|
4551
4689
|
}
|
|
4690
|
+
// @__NO_SIDE_EFFECTS__
|
|
4552
4691
|
function _coercedBoolean(Class2, params) {
|
|
4553
4692
|
return new Class2({
|
|
4554
4693
|
type: "boolean",
|
|
@@ -4556,12 +4695,14 @@ function _coercedBoolean(Class2, params) {
|
|
|
4556
4695
|
...normalizeParams(params)
|
|
4557
4696
|
});
|
|
4558
4697
|
}
|
|
4698
|
+
// @__NO_SIDE_EFFECTS__
|
|
4559
4699
|
function _bigint(Class2, params) {
|
|
4560
4700
|
return new Class2({
|
|
4561
4701
|
type: "bigint",
|
|
4562
4702
|
...normalizeParams(params)
|
|
4563
4703
|
});
|
|
4564
4704
|
}
|
|
4705
|
+
// @__NO_SIDE_EFFECTS__
|
|
4565
4706
|
function _coercedBigint(Class2, params) {
|
|
4566
4707
|
return new Class2({
|
|
4567
4708
|
type: "bigint",
|
|
@@ -4569,6 +4710,7 @@ function _coercedBigint(Class2, params) {
|
|
|
4569
4710
|
...normalizeParams(params)
|
|
4570
4711
|
});
|
|
4571
4712
|
}
|
|
4713
|
+
// @__NO_SIDE_EFFECTS__
|
|
4572
4714
|
function _int64(Class2, params) {
|
|
4573
4715
|
return new Class2({
|
|
4574
4716
|
type: "bigint",
|
|
@@ -4578,6 +4720,7 @@ function _int64(Class2, params) {
|
|
|
4578
4720
|
...normalizeParams(params)
|
|
4579
4721
|
});
|
|
4580
4722
|
}
|
|
4723
|
+
// @__NO_SIDE_EFFECTS__
|
|
4581
4724
|
function _uint64(Class2, params) {
|
|
4582
4725
|
return new Class2({
|
|
4583
4726
|
type: "bigint",
|
|
@@ -4587,52 +4730,61 @@ function _uint64(Class2, params) {
|
|
|
4587
4730
|
...normalizeParams(params)
|
|
4588
4731
|
});
|
|
4589
4732
|
}
|
|
4733
|
+
// @__NO_SIDE_EFFECTS__
|
|
4590
4734
|
function _symbol(Class2, params) {
|
|
4591
4735
|
return new Class2({
|
|
4592
4736
|
type: "symbol",
|
|
4593
4737
|
...normalizeParams(params)
|
|
4594
4738
|
});
|
|
4595
4739
|
}
|
|
4740
|
+
// @__NO_SIDE_EFFECTS__
|
|
4596
4741
|
function _undefined2(Class2, params) {
|
|
4597
4742
|
return new Class2({
|
|
4598
4743
|
type: "undefined",
|
|
4599
4744
|
...normalizeParams(params)
|
|
4600
4745
|
});
|
|
4601
4746
|
}
|
|
4747
|
+
// @__NO_SIDE_EFFECTS__
|
|
4602
4748
|
function _null2(Class2, params) {
|
|
4603
4749
|
return new Class2({
|
|
4604
4750
|
type: "null",
|
|
4605
4751
|
...normalizeParams(params)
|
|
4606
4752
|
});
|
|
4607
4753
|
}
|
|
4754
|
+
// @__NO_SIDE_EFFECTS__
|
|
4608
4755
|
function _any(Class2) {
|
|
4609
4756
|
return new Class2({
|
|
4610
4757
|
type: "any"
|
|
4611
4758
|
});
|
|
4612
4759
|
}
|
|
4760
|
+
// @__NO_SIDE_EFFECTS__
|
|
4613
4761
|
function _unknown(Class2) {
|
|
4614
4762
|
return new Class2({
|
|
4615
4763
|
type: "unknown"
|
|
4616
4764
|
});
|
|
4617
4765
|
}
|
|
4766
|
+
// @__NO_SIDE_EFFECTS__
|
|
4618
4767
|
function _never(Class2, params) {
|
|
4619
4768
|
return new Class2({
|
|
4620
4769
|
type: "never",
|
|
4621
4770
|
...normalizeParams(params)
|
|
4622
4771
|
});
|
|
4623
4772
|
}
|
|
4773
|
+
// @__NO_SIDE_EFFECTS__
|
|
4624
4774
|
function _void(Class2, params) {
|
|
4625
4775
|
return new Class2({
|
|
4626
4776
|
type: "void",
|
|
4627
4777
|
...normalizeParams(params)
|
|
4628
4778
|
});
|
|
4629
4779
|
}
|
|
4780
|
+
// @__NO_SIDE_EFFECTS__
|
|
4630
4781
|
function _date(Class2, params) {
|
|
4631
4782
|
return new Class2({
|
|
4632
4783
|
type: "date",
|
|
4633
4784
|
...normalizeParams(params)
|
|
4634
4785
|
});
|
|
4635
4786
|
}
|
|
4787
|
+
// @__NO_SIDE_EFFECTS__
|
|
4636
4788
|
function _coercedDate(Class2, params) {
|
|
4637
4789
|
return new Class2({
|
|
4638
4790
|
type: "date",
|
|
@@ -4640,12 +4792,14 @@ function _coercedDate(Class2, params) {
|
|
|
4640
4792
|
...normalizeParams(params)
|
|
4641
4793
|
});
|
|
4642
4794
|
}
|
|
4795
|
+
// @__NO_SIDE_EFFECTS__
|
|
4643
4796
|
function _nan(Class2, params) {
|
|
4644
4797
|
return new Class2({
|
|
4645
4798
|
type: "nan",
|
|
4646
4799
|
...normalizeParams(params)
|
|
4647
4800
|
});
|
|
4648
4801
|
}
|
|
4802
|
+
// @__NO_SIDE_EFFECTS__
|
|
4649
4803
|
function _lt(value, params) {
|
|
4650
4804
|
return new $ZodCheckLessThan({
|
|
4651
4805
|
check: "less_than",
|
|
@@ -4654,6 +4808,7 @@ function _lt(value, params) {
|
|
|
4654
4808
|
inclusive: false
|
|
4655
4809
|
});
|
|
4656
4810
|
}
|
|
4811
|
+
// @__NO_SIDE_EFFECTS__
|
|
4657
4812
|
function _lte(value, params) {
|
|
4658
4813
|
return new $ZodCheckLessThan({
|
|
4659
4814
|
check: "less_than",
|
|
@@ -4662,6 +4817,7 @@ function _lte(value, params) {
|
|
|
4662
4817
|
inclusive: true
|
|
4663
4818
|
});
|
|
4664
4819
|
}
|
|
4820
|
+
// @__NO_SIDE_EFFECTS__
|
|
4665
4821
|
function _gt(value, params) {
|
|
4666
4822
|
return new $ZodCheckGreaterThan({
|
|
4667
4823
|
check: "greater_than",
|
|
@@ -4670,6 +4826,7 @@ function _gt(value, params) {
|
|
|
4670
4826
|
inclusive: false
|
|
4671
4827
|
});
|
|
4672
4828
|
}
|
|
4829
|
+
// @__NO_SIDE_EFFECTS__
|
|
4673
4830
|
function _gte(value, params) {
|
|
4674
4831
|
return new $ZodCheckGreaterThan({
|
|
4675
4832
|
check: "greater_than",
|
|
@@ -4678,18 +4835,23 @@ function _gte(value, params) {
|
|
|
4678
4835
|
inclusive: true
|
|
4679
4836
|
});
|
|
4680
4837
|
}
|
|
4838
|
+
// @__NO_SIDE_EFFECTS__
|
|
4681
4839
|
function _positive(params) {
|
|
4682
|
-
return _gt(0, params);
|
|
4840
|
+
return /* @__PURE__ */ _gt(0, params);
|
|
4683
4841
|
}
|
|
4842
|
+
// @__NO_SIDE_EFFECTS__
|
|
4684
4843
|
function _negative(params) {
|
|
4685
|
-
return _lt(0, params);
|
|
4844
|
+
return /* @__PURE__ */ _lt(0, params);
|
|
4686
4845
|
}
|
|
4846
|
+
// @__NO_SIDE_EFFECTS__
|
|
4687
4847
|
function _nonpositive(params) {
|
|
4688
|
-
return _lte(0, params);
|
|
4848
|
+
return /* @__PURE__ */ _lte(0, params);
|
|
4689
4849
|
}
|
|
4850
|
+
// @__NO_SIDE_EFFECTS__
|
|
4690
4851
|
function _nonnegative(params) {
|
|
4691
|
-
return _gte(0, params);
|
|
4852
|
+
return /* @__PURE__ */ _gte(0, params);
|
|
4692
4853
|
}
|
|
4854
|
+
// @__NO_SIDE_EFFECTS__
|
|
4693
4855
|
function _multipleOf(value, params) {
|
|
4694
4856
|
return new $ZodCheckMultipleOf({
|
|
4695
4857
|
check: "multiple_of",
|
|
@@ -4697,6 +4859,7 @@ function _multipleOf(value, params) {
|
|
|
4697
4859
|
value
|
|
4698
4860
|
});
|
|
4699
4861
|
}
|
|
4862
|
+
// @__NO_SIDE_EFFECTS__
|
|
4700
4863
|
function _maxSize(maximum, params) {
|
|
4701
4864
|
return new $ZodCheckMaxSize({
|
|
4702
4865
|
check: "max_size",
|
|
@@ -4704,6 +4867,7 @@ function _maxSize(maximum, params) {
|
|
|
4704
4867
|
maximum
|
|
4705
4868
|
});
|
|
4706
4869
|
}
|
|
4870
|
+
// @__NO_SIDE_EFFECTS__
|
|
4707
4871
|
function _minSize(minimum, params) {
|
|
4708
4872
|
return new $ZodCheckMinSize({
|
|
4709
4873
|
check: "min_size",
|
|
@@ -4711,6 +4875,7 @@ function _minSize(minimum, params) {
|
|
|
4711
4875
|
minimum
|
|
4712
4876
|
});
|
|
4713
4877
|
}
|
|
4878
|
+
// @__NO_SIDE_EFFECTS__
|
|
4714
4879
|
function _size(size, params) {
|
|
4715
4880
|
return new $ZodCheckSizeEquals({
|
|
4716
4881
|
check: "size_equals",
|
|
@@ -4718,6 +4883,7 @@ function _size(size, params) {
|
|
|
4718
4883
|
size
|
|
4719
4884
|
});
|
|
4720
4885
|
}
|
|
4886
|
+
// @__NO_SIDE_EFFECTS__
|
|
4721
4887
|
function _maxLength(maximum, params) {
|
|
4722
4888
|
const ch = new $ZodCheckMaxLength({
|
|
4723
4889
|
check: "max_length",
|
|
@@ -4726,6 +4892,7 @@ function _maxLength(maximum, params) {
|
|
|
4726
4892
|
});
|
|
4727
4893
|
return ch;
|
|
4728
4894
|
}
|
|
4895
|
+
// @__NO_SIDE_EFFECTS__
|
|
4729
4896
|
function _minLength(minimum, params) {
|
|
4730
4897
|
return new $ZodCheckMinLength({
|
|
4731
4898
|
check: "min_length",
|
|
@@ -4733,6 +4900,7 @@ function _minLength(minimum, params) {
|
|
|
4733
4900
|
minimum
|
|
4734
4901
|
});
|
|
4735
4902
|
}
|
|
4903
|
+
// @__NO_SIDE_EFFECTS__
|
|
4736
4904
|
function _length(length, params) {
|
|
4737
4905
|
return new $ZodCheckLengthEquals({
|
|
4738
4906
|
check: "length_equals",
|
|
@@ -4740,6 +4908,7 @@ function _length(length, params) {
|
|
|
4740
4908
|
length
|
|
4741
4909
|
});
|
|
4742
4910
|
}
|
|
4911
|
+
// @__NO_SIDE_EFFECTS__
|
|
4743
4912
|
function _regex(pattern, params) {
|
|
4744
4913
|
return new $ZodCheckRegex({
|
|
4745
4914
|
check: "string_format",
|
|
@@ -4748,6 +4917,7 @@ function _regex(pattern, params) {
|
|
|
4748
4917
|
pattern
|
|
4749
4918
|
});
|
|
4750
4919
|
}
|
|
4920
|
+
// @__NO_SIDE_EFFECTS__
|
|
4751
4921
|
function _lowercase(params) {
|
|
4752
4922
|
return new $ZodCheckLowerCase({
|
|
4753
4923
|
check: "string_format",
|
|
@@ -4755,6 +4925,7 @@ function _lowercase(params) {
|
|
|
4755
4925
|
...normalizeParams(params)
|
|
4756
4926
|
});
|
|
4757
4927
|
}
|
|
4928
|
+
// @__NO_SIDE_EFFECTS__
|
|
4758
4929
|
function _uppercase(params) {
|
|
4759
4930
|
return new $ZodCheckUpperCase({
|
|
4760
4931
|
check: "string_format",
|
|
@@ -4762,6 +4933,7 @@ function _uppercase(params) {
|
|
|
4762
4933
|
...normalizeParams(params)
|
|
4763
4934
|
});
|
|
4764
4935
|
}
|
|
4936
|
+
// @__NO_SIDE_EFFECTS__
|
|
4765
4937
|
function _includes(includes, params) {
|
|
4766
4938
|
return new $ZodCheckIncludes({
|
|
4767
4939
|
check: "string_format",
|
|
@@ -4770,6 +4942,7 @@ function _includes(includes, params) {
|
|
|
4770
4942
|
includes
|
|
4771
4943
|
});
|
|
4772
4944
|
}
|
|
4945
|
+
// @__NO_SIDE_EFFECTS__
|
|
4773
4946
|
function _startsWith(prefix, params) {
|
|
4774
4947
|
return new $ZodCheckStartsWith({
|
|
4775
4948
|
check: "string_format",
|
|
@@ -4778,6 +4951,7 @@ function _startsWith(prefix, params) {
|
|
|
4778
4951
|
prefix
|
|
4779
4952
|
});
|
|
4780
4953
|
}
|
|
4954
|
+
// @__NO_SIDE_EFFECTS__
|
|
4781
4955
|
function _endsWith(suffix, params) {
|
|
4782
4956
|
return new $ZodCheckEndsWith({
|
|
4783
4957
|
check: "string_format",
|
|
@@ -4786,6 +4960,7 @@ function _endsWith(suffix, params) {
|
|
|
4786
4960
|
suffix
|
|
4787
4961
|
});
|
|
4788
4962
|
}
|
|
4963
|
+
// @__NO_SIDE_EFFECTS__
|
|
4789
4964
|
function _property(property, schema, params) {
|
|
4790
4965
|
return new $ZodCheckProperty({
|
|
4791
4966
|
check: "property",
|
|
@@ -4794,6 +4969,7 @@ function _property(property, schema, params) {
|
|
|
4794
4969
|
...normalizeParams(params)
|
|
4795
4970
|
});
|
|
4796
4971
|
}
|
|
4972
|
+
// @__NO_SIDE_EFFECTS__
|
|
4797
4973
|
function _mime(types, params) {
|
|
4798
4974
|
return new $ZodCheckMimeType({
|
|
4799
4975
|
check: "mime_type",
|
|
@@ -4801,27 +4977,34 @@ function _mime(types, params) {
|
|
|
4801
4977
|
...normalizeParams(params)
|
|
4802
4978
|
});
|
|
4803
4979
|
}
|
|
4980
|
+
// @__NO_SIDE_EFFECTS__
|
|
4804
4981
|
function _overwrite(tx) {
|
|
4805
4982
|
return new $ZodCheckOverwrite({
|
|
4806
4983
|
check: "overwrite",
|
|
4807
4984
|
tx
|
|
4808
4985
|
});
|
|
4809
4986
|
}
|
|
4987
|
+
// @__NO_SIDE_EFFECTS__
|
|
4810
4988
|
function _normalize(form) {
|
|
4811
|
-
return _overwrite((input) => input.normalize(form));
|
|
4989
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
4812
4990
|
}
|
|
4991
|
+
// @__NO_SIDE_EFFECTS__
|
|
4813
4992
|
function _trim() {
|
|
4814
|
-
return _overwrite((input) => input.trim());
|
|
4993
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
4815
4994
|
}
|
|
4995
|
+
// @__NO_SIDE_EFFECTS__
|
|
4816
4996
|
function _toLowerCase() {
|
|
4817
|
-
return _overwrite((input) => input.toLowerCase());
|
|
4997
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
4818
4998
|
}
|
|
4999
|
+
// @__NO_SIDE_EFFECTS__
|
|
4819
5000
|
function _toUpperCase() {
|
|
4820
|
-
return _overwrite((input) => input.toUpperCase());
|
|
5001
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
4821
5002
|
}
|
|
5003
|
+
// @__NO_SIDE_EFFECTS__
|
|
4822
5004
|
function _slugify() {
|
|
4823
|
-
return _overwrite((input) => slugify(input));
|
|
5005
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
4824
5006
|
}
|
|
5007
|
+
// @__NO_SIDE_EFFECTS__
|
|
4825
5008
|
function _array(Class2, element, params) {
|
|
4826
5009
|
return new Class2({
|
|
4827
5010
|
type: "array",
|
|
@@ -4832,12 +5015,14 @@ function _array(Class2, element, params) {
|
|
|
4832
5015
|
...normalizeParams(params)
|
|
4833
5016
|
});
|
|
4834
5017
|
}
|
|
5018
|
+
// @__NO_SIDE_EFFECTS__
|
|
4835
5019
|
function _file(Class2, params) {
|
|
4836
5020
|
return new Class2({
|
|
4837
5021
|
type: "file",
|
|
4838
5022
|
...normalizeParams(params)
|
|
4839
5023
|
});
|
|
4840
5024
|
}
|
|
5025
|
+
// @__NO_SIDE_EFFECTS__
|
|
4841
5026
|
function _custom(Class2, fn, _params) {
|
|
4842
5027
|
const norm = normalizeParams(_params);
|
|
4843
5028
|
norm.abort ?? (norm.abort = true);
|
|
@@ -4849,6 +5034,7 @@ function _custom(Class2, fn, _params) {
|
|
|
4849
5034
|
});
|
|
4850
5035
|
return schema;
|
|
4851
5036
|
}
|
|
5037
|
+
// @__NO_SIDE_EFFECTS__
|
|
4852
5038
|
function _refine(Class2, fn, _params) {
|
|
4853
5039
|
const schema = new Class2({
|
|
4854
5040
|
type: "custom",
|
|
@@ -4858,8 +5044,9 @@ function _refine(Class2, fn, _params) {
|
|
|
4858
5044
|
});
|
|
4859
5045
|
return schema;
|
|
4860
5046
|
}
|
|
5047
|
+
// @__NO_SIDE_EFFECTS__
|
|
4861
5048
|
function _superRefine(fn) {
|
|
4862
|
-
const ch = _check((payload) => {
|
|
5049
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
4863
5050
|
payload.addIssue = (issue2) => {
|
|
4864
5051
|
if (typeof issue2 === "string") {
|
|
4865
5052
|
payload.issues.push(issue(issue2, payload.value, ch._zod.def));
|
|
@@ -4878,6 +5065,7 @@ function _superRefine(fn) {
|
|
|
4878
5065
|
});
|
|
4879
5066
|
return ch;
|
|
4880
5067
|
}
|
|
5068
|
+
// @__NO_SIDE_EFFECTS__
|
|
4881
5069
|
function _check(fn, params) {
|
|
4882
5070
|
const ch = new $ZodCheck({
|
|
4883
5071
|
check: "custom",
|
|
@@ -4886,6 +5074,7 @@ function _check(fn, params) {
|
|
|
4886
5074
|
ch._zod.check = fn;
|
|
4887
5075
|
return ch;
|
|
4888
5076
|
}
|
|
5077
|
+
// @__NO_SIDE_EFFECTS__
|
|
4889
5078
|
function describe(description) {
|
|
4890
5079
|
const ch = new $ZodCheck({ check: "describe" });
|
|
4891
5080
|
ch._zod.onattach = [
|
|
@@ -4898,6 +5087,7 @@ function describe(description) {
|
|
|
4898
5087
|
};
|
|
4899
5088
|
return ch;
|
|
4900
5089
|
}
|
|
5090
|
+
// @__NO_SIDE_EFFECTS__
|
|
4901
5091
|
function meta(metadata) {
|
|
4902
5092
|
const ch = new $ZodCheck({ check: "meta" });
|
|
4903
5093
|
ch._zod.onattach = [
|
|
@@ -4910,6 +5100,7 @@ function meta(metadata) {
|
|
|
4910
5100
|
};
|
|
4911
5101
|
return ch;
|
|
4912
5102
|
}
|
|
5103
|
+
// @__NO_SIDE_EFFECTS__
|
|
4913
5104
|
function _stringbool(Classes, _params) {
|
|
4914
5105
|
const params = normalizeParams(_params);
|
|
4915
5106
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -4960,6 +5151,7 @@ function _stringbool(Classes, _params) {
|
|
|
4960
5151
|
});
|
|
4961
5152
|
return codec2;
|
|
4962
5153
|
}
|
|
5154
|
+
// @__NO_SIDE_EFFECTS__
|
|
4963
5155
|
function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
4964
5156
|
const params = normalizeParams(_params);
|
|
4965
5157
|
const def = {
|
|
@@ -5022,12 +5214,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
5022
5214
|
schemaPath: [..._params.schemaPath, schema],
|
|
5023
5215
|
path: _params.path
|
|
5024
5216
|
};
|
|
5025
|
-
|
|
5026
|
-
if (parent) {
|
|
5027
|
-
result.ref = parent;
|
|
5028
|
-
process2(parent, ctx, params);
|
|
5029
|
-
ctx.seen.get(parent).isParent = true;
|
|
5030
|
-
} else if (schema._zod.processJSONSchema) {
|
|
5217
|
+
if (schema._zod.processJSONSchema) {
|
|
5031
5218
|
schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
5032
5219
|
} else {
|
|
5033
5220
|
const _json = result.schema;
|
|
@@ -5037,6 +5224,13 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
5037
5224
|
}
|
|
5038
5225
|
processor(schema, ctx, _json, params);
|
|
5039
5226
|
}
|
|
5227
|
+
const parent = schema._zod.parent;
|
|
5228
|
+
if (parent) {
|
|
5229
|
+
if (!result.ref)
|
|
5230
|
+
result.ref = parent;
|
|
5231
|
+
process2(parent, ctx, params);
|
|
5232
|
+
ctx.seen.get(parent).isParent = true;
|
|
5233
|
+
}
|
|
5040
5234
|
}
|
|
5041
5235
|
const meta3 = ctx.metadataRegistry.get(schema);
|
|
5042
5236
|
if (meta3)
|
|
@@ -5055,6 +5249,17 @@ function extractDefs(ctx, schema) {
|
|
|
5055
5249
|
const root = ctx.seen.get(schema);
|
|
5056
5250
|
if (!root)
|
|
5057
5251
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
5252
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
5253
|
+
for (const entry of ctx.seen.entries()) {
|
|
5254
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
5255
|
+
if (id) {
|
|
5256
|
+
const existing = idToSchema.get(id);
|
|
5257
|
+
if (existing && existing !== entry[0]) {
|
|
5258
|
+
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
5259
|
+
}
|
|
5260
|
+
idToSchema.set(id, entry[0]);
|
|
5261
|
+
}
|
|
5262
|
+
}
|
|
5058
5263
|
const makeURI = (entry) => {
|
|
5059
5264
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
5060
5265
|
if (ctx.external) {
|
|
@@ -5136,30 +5341,65 @@ function finalize(ctx, schema) {
|
|
|
5136
5341
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
5137
5342
|
const flattenRef = (zodSchema) => {
|
|
5138
5343
|
const seen = ctx.seen.get(zodSchema);
|
|
5344
|
+
if (seen.ref === null)
|
|
5345
|
+
return;
|
|
5139
5346
|
const schema2 = seen.def ?? seen.schema;
|
|
5140
5347
|
const _cached = { ...schema2 };
|
|
5141
|
-
if (seen.ref === null) {
|
|
5142
|
-
return;
|
|
5143
|
-
}
|
|
5144
5348
|
const ref = seen.ref;
|
|
5145
5349
|
seen.ref = null;
|
|
5146
5350
|
if (ref) {
|
|
5147
5351
|
flattenRef(ref);
|
|
5148
|
-
const
|
|
5352
|
+
const refSeen = ctx.seen.get(ref);
|
|
5353
|
+
const refSchema = refSeen.schema;
|
|
5149
5354
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
5150
5355
|
schema2.allOf = schema2.allOf ?? [];
|
|
5151
5356
|
schema2.allOf.push(refSchema);
|
|
5152
5357
|
} else {
|
|
5153
5358
|
Object.assign(schema2, refSchema);
|
|
5154
|
-
|
|
5359
|
+
}
|
|
5360
|
+
Object.assign(schema2, _cached);
|
|
5361
|
+
const isParentRef = zodSchema._zod.parent === ref;
|
|
5362
|
+
if (isParentRef) {
|
|
5363
|
+
for (const key in schema2) {
|
|
5364
|
+
if (key === "$ref" || key === "allOf")
|
|
5365
|
+
continue;
|
|
5366
|
+
if (!(key in _cached)) {
|
|
5367
|
+
delete schema2[key];
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
if (refSchema.$ref) {
|
|
5372
|
+
for (const key in schema2) {
|
|
5373
|
+
if (key === "$ref" || key === "allOf")
|
|
5374
|
+
continue;
|
|
5375
|
+
if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
|
|
5376
|
+
delete schema2[key];
|
|
5377
|
+
}
|
|
5378
|
+
}
|
|
5155
5379
|
}
|
|
5156
5380
|
}
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5381
|
+
const parent = zodSchema._zod.parent;
|
|
5382
|
+
if (parent && parent !== ref) {
|
|
5383
|
+
flattenRef(parent);
|
|
5384
|
+
const parentSeen = ctx.seen.get(parent);
|
|
5385
|
+
if (parentSeen?.schema.$ref) {
|
|
5386
|
+
schema2.$ref = parentSeen.schema.$ref;
|
|
5387
|
+
if (parentSeen.def) {
|
|
5388
|
+
for (const key in schema2) {
|
|
5389
|
+
if (key === "$ref" || key === "allOf")
|
|
5390
|
+
continue;
|
|
5391
|
+
if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
5392
|
+
delete schema2[key];
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
ctx.override({
|
|
5399
|
+
zodSchema,
|
|
5400
|
+
jsonSchema: schema2,
|
|
5401
|
+
path: seen.path ?? []
|
|
5402
|
+
});
|
|
5163
5403
|
};
|
|
5164
5404
|
for (const entry of [...ctx.seen.entries()].reverse()) {
|
|
5165
5405
|
flattenRef(entry[0]);
|
|
@@ -5204,8 +5444,8 @@ function finalize(ctx, schema) {
|
|
|
5204
5444
|
value: {
|
|
5205
5445
|
...schema["~standard"],
|
|
5206
5446
|
jsonSchema: {
|
|
5207
|
-
input: createStandardJSONSchemaMethod(schema, "input"),
|
|
5208
|
-
output: createStandardJSONSchemaMethod(schema, "output")
|
|
5447
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
5448
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
5209
5449
|
}
|
|
5210
5450
|
},
|
|
5211
5451
|
enumerable: false,
|
|
@@ -5273,9 +5513,9 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
5273
5513
|
extractDefs(ctx, schema);
|
|
5274
5514
|
return finalize(ctx, schema);
|
|
5275
5515
|
};
|
|
5276
|
-
var createStandardJSONSchemaMethod = (schema, io) => (params) => {
|
|
5516
|
+
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
5277
5517
|
const { libraryOptions, target } = params ?? {};
|
|
5278
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors
|
|
5518
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
5279
5519
|
process2(schema, ctx);
|
|
5280
5520
|
extractDefs(ctx, schema);
|
|
5281
5521
|
return finalize(ctx, schema);
|
|
@@ -5302,6 +5542,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
5302
5542
|
json2.format = formatMap[format] ?? format;
|
|
5303
5543
|
if (json2.format === "")
|
|
5304
5544
|
delete json2.format;
|
|
5545
|
+
if (format === "time") {
|
|
5546
|
+
delete json2.format;
|
|
5547
|
+
}
|
|
5305
5548
|
}
|
|
5306
5549
|
if (contentEncoding)
|
|
5307
5550
|
json2.contentEncoding = contentEncoding;
|
|
@@ -5486,10 +5729,8 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
5486
5729
|
file2.contentMediaType = mime[0];
|
|
5487
5730
|
Object.assign(_json, file2);
|
|
5488
5731
|
} else {
|
|
5489
|
-
_json
|
|
5490
|
-
|
|
5491
|
-
return mFile;
|
|
5492
|
-
});
|
|
5732
|
+
Object.assign(_json, file2);
|
|
5733
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
5493
5734
|
}
|
|
5494
5735
|
} else {
|
|
5495
5736
|
Object.assign(_json, file2);
|
|
@@ -5646,16 +5887,37 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
5646
5887
|
const json2 = _json;
|
|
5647
5888
|
const def = schema._zod.def;
|
|
5648
5889
|
json2.type = "object";
|
|
5649
|
-
|
|
5650
|
-
|
|
5890
|
+
const keyType = def.keyType;
|
|
5891
|
+
const keyBag = keyType._zod.bag;
|
|
5892
|
+
const patterns = keyBag?.patterns;
|
|
5893
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
5894
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
5651
5895
|
...params,
|
|
5652
|
-
path: [...params.path, "
|
|
5896
|
+
path: [...params.path, "patternProperties", "*"]
|
|
5897
|
+
});
|
|
5898
|
+
json2.patternProperties = {};
|
|
5899
|
+
for (const pattern of patterns) {
|
|
5900
|
+
json2.patternProperties[pattern.source] = valueSchema;
|
|
5901
|
+
}
|
|
5902
|
+
} else {
|
|
5903
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
5904
|
+
json2.propertyNames = process2(def.keyType, ctx, {
|
|
5905
|
+
...params,
|
|
5906
|
+
path: [...params.path, "propertyNames"]
|
|
5907
|
+
});
|
|
5908
|
+
}
|
|
5909
|
+
json2.additionalProperties = process2(def.valueType, ctx, {
|
|
5910
|
+
...params,
|
|
5911
|
+
path: [...params.path, "additionalProperties"]
|
|
5653
5912
|
});
|
|
5654
5913
|
}
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5914
|
+
const keyValues = keyType._zod.values;
|
|
5915
|
+
if (keyValues) {
|
|
5916
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
5917
|
+
if (validKeyValues.length > 0) {
|
|
5918
|
+
json2.required = validKeyValues;
|
|
5919
|
+
}
|
|
5920
|
+
}
|
|
5659
5921
|
};
|
|
5660
5922
|
var nullableProcessor = (schema, ctx, json2, params) => {
|
|
5661
5923
|
const def = schema._zod.def;
|
|
@@ -5760,6 +6022,7 @@ __export(schemas_exports2, {
|
|
|
5760
6022
|
ZodEmail: () => ZodEmail,
|
|
5761
6023
|
ZodEmoji: () => ZodEmoji,
|
|
5762
6024
|
ZodEnum: () => ZodEnum,
|
|
6025
|
+
ZodExactOptional: () => ZodExactOptional,
|
|
5763
6026
|
ZodFile: () => ZodFile,
|
|
5764
6027
|
ZodFunction: () => ZodFunction,
|
|
5765
6028
|
ZodGUID: () => ZodGUID,
|
|
@@ -5829,6 +6092,7 @@ __export(schemas_exports2, {
|
|
|
5829
6092
|
email: () => email2,
|
|
5830
6093
|
emoji: () => emoji2,
|
|
5831
6094
|
enum: () => _enum,
|
|
6095
|
+
exactOptional: () => exactOptional,
|
|
5832
6096
|
file: () => file,
|
|
5833
6097
|
float32: () => float32,
|
|
5834
6098
|
float64: () => float64,
|
|
@@ -6050,8 +6314,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6050
6314
|
...def.checks ?? [],
|
|
6051
6315
|
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
6052
6316
|
]
|
|
6053
|
-
})
|
|
6317
|
+
}), {
|
|
6318
|
+
parent: true
|
|
6319
|
+
});
|
|
6054
6320
|
};
|
|
6321
|
+
inst.with = inst.check;
|
|
6055
6322
|
inst.clone = (def2, params) => clone(inst, def2, params);
|
|
6056
6323
|
inst.brand = () => inst;
|
|
6057
6324
|
inst.register = ((reg, meta3) => {
|
|
@@ -6075,6 +6342,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6075
6342
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
6076
6343
|
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
6077
6344
|
inst.optional = () => optional(inst);
|
|
6345
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
6078
6346
|
inst.nullable = () => nullable(inst);
|
|
6079
6347
|
inst.nullish = () => optional(nullable(inst));
|
|
6080
6348
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
@@ -6108,6 +6376,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6108
6376
|
};
|
|
6109
6377
|
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
6110
6378
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
6379
|
+
inst.apply = (fn) => fn(inst);
|
|
6111
6380
|
return inst;
|
|
6112
6381
|
});
|
|
6113
6382
|
var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
@@ -6687,6 +6956,10 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
6687
6956
|
inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
|
|
6688
6957
|
inst.keyType = def.keyType;
|
|
6689
6958
|
inst.valueType = def.valueType;
|
|
6959
|
+
inst.min = (...args) => inst.check(_minSize(...args));
|
|
6960
|
+
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
6961
|
+
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
6962
|
+
inst.size = (...args) => inst.check(_size(...args));
|
|
6690
6963
|
});
|
|
6691
6964
|
function map(keyType, valueType, params) {
|
|
6692
6965
|
return new ZodMap({
|
|
@@ -6847,6 +7120,18 @@ function optional(innerType) {
|
|
|
6847
7120
|
innerType
|
|
6848
7121
|
});
|
|
6849
7122
|
}
|
|
7123
|
+
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
7124
|
+
$ZodExactOptional.init(inst, def);
|
|
7125
|
+
ZodType.init(inst, def);
|
|
7126
|
+
inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
|
|
7127
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
7128
|
+
});
|
|
7129
|
+
function exactOptional(innerType) {
|
|
7130
|
+
return new ZodExactOptional({
|
|
7131
|
+
type: "optional",
|
|
7132
|
+
innerType
|
|
7133
|
+
});
|
|
7134
|
+
}
|
|
6850
7135
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
6851
7136
|
$ZodNullable.init(inst, def);
|
|
6852
7137
|
ZodType.init(inst, def);
|
|
@@ -7052,9 +7337,7 @@ function superRefine(fn) {
|
|
|
7052
7337
|
}
|
|
7053
7338
|
var describe2 = describe;
|
|
7054
7339
|
var meta2 = meta;
|
|
7055
|
-
function _instanceof(cls, params = {
|
|
7056
|
-
error: `Input not instance of ${cls.name}`
|
|
7057
|
-
}) {
|
|
7340
|
+
function _instanceof(cls, params = {}) {
|
|
7058
7341
|
const inst = new ZodCustom({
|
|
7059
7342
|
type: "custom",
|
|
7060
7343
|
check: "custom",
|
|
@@ -7063,6 +7346,17 @@ function _instanceof(cls, params = {
|
|
|
7063
7346
|
...util_exports.normalizeParams(params)
|
|
7064
7347
|
});
|
|
7065
7348
|
inst._zod.bag.Class = cls;
|
|
7349
|
+
inst._zod.check = (payload) => {
|
|
7350
|
+
if (!(payload.value instanceof cls)) {
|
|
7351
|
+
payload.issues.push({
|
|
7352
|
+
code: "invalid_type",
|
|
7353
|
+
expected: cls.name,
|
|
7354
|
+
input: payload.value,
|
|
7355
|
+
inst,
|
|
7356
|
+
path: [...inst._zod.def.path ?? []]
|
|
7357
|
+
});
|
|
7358
|
+
}
|
|
7359
|
+
};
|
|
7066
7360
|
return inst;
|
|
7067
7361
|
}
|
|
7068
7362
|
var stringbool = (...args) => _stringbool({
|
|
@@ -20004,7 +20298,16 @@ var MCPSamplingLanguageModel = class {
|
|
|
20004
20298
|
* Generate a response using MCP's createMessage capability
|
|
20005
20299
|
*/
|
|
20006
20300
|
async doGenerate(options) {
|
|
20007
|
-
const
|
|
20301
|
+
const useNativeTools = this.supportsSamplingTools();
|
|
20302
|
+
this.server.sendLoggingMessage({
|
|
20303
|
+
level: "info",
|
|
20304
|
+
data: `Client supports native tools: ${useNativeTools}`
|
|
20305
|
+
});
|
|
20306
|
+
const messages = this.convertMessages(options.prompt, useNativeTools);
|
|
20307
|
+
this.server.sendLoggingMessage({
|
|
20308
|
+
level: "info",
|
|
20309
|
+
data: `Converted messages for MCP: ${JSON.stringify(messages)}`
|
|
20310
|
+
});
|
|
20008
20311
|
let systemPrompt;
|
|
20009
20312
|
for (const msg of options.prompt) {
|
|
20010
20313
|
if (msg.role === "system") {
|
|
@@ -20012,7 +20315,10 @@ var MCPSamplingLanguageModel = class {
|
|
|
20012
20315
|
break;
|
|
20013
20316
|
}
|
|
20014
20317
|
}
|
|
20015
|
-
|
|
20318
|
+
this.server.sendLoggingMessage({
|
|
20319
|
+
level: "info",
|
|
20320
|
+
data: `Client supports native tools: ${useNativeTools}`
|
|
20321
|
+
});
|
|
20016
20322
|
systemPrompt = this.injectResponseFormatInstructions(systemPrompt, options.responseFormat, useNativeTools);
|
|
20017
20323
|
systemPrompt = this.injectToolInstructions(systemPrompt, options.tools, useNativeTools);
|
|
20018
20324
|
const createMessageParams = {
|
|
@@ -20026,8 +20332,34 @@ var MCPSamplingLanguageModel = class {
|
|
|
20026
20332
|
createMessageParams.toolChoice = {
|
|
20027
20333
|
mode: "auto"
|
|
20028
20334
|
};
|
|
20335
|
+
this.server.sendLoggingMessage({
|
|
20336
|
+
level: "info",
|
|
20337
|
+
data: `Converted ${options.tools.length} tools to MCP format: ${JSON.stringify(createMessageParams.tools?.map((t) => t.name))}`
|
|
20338
|
+
});
|
|
20339
|
+
} else if (options.tools && options.tools.length > 0) {
|
|
20340
|
+
this.server.sendLoggingMessage({
|
|
20341
|
+
level: "info",
|
|
20342
|
+
data: `Tools provided but not using native mode - injecting into system prompt instead`
|
|
20343
|
+
});
|
|
20029
20344
|
}
|
|
20345
|
+
this.server.sendLoggingMessage({
|
|
20346
|
+
level: "info",
|
|
20347
|
+
data: `Calling createMessage with params: ${JSON.stringify({
|
|
20348
|
+
hasSystemPrompt: !!systemPrompt,
|
|
20349
|
+
hasTools: !!createMessageParams.tools,
|
|
20350
|
+
toolCount: createMessageParams.tools?.length || 0,
|
|
20351
|
+
createMessageParams
|
|
20352
|
+
}, null, 2)}`
|
|
20353
|
+
});
|
|
20030
20354
|
const result = await this.server.createMessage(createMessageParams);
|
|
20355
|
+
this.server.sendLoggingMessage({
|
|
20356
|
+
level: "info",
|
|
20357
|
+
data: `createMessage result: ${JSON.stringify({
|
|
20358
|
+
contentType: result.content.type,
|
|
20359
|
+
stopReason: result.stopReason,
|
|
20360
|
+
text: result.content
|
|
20361
|
+
})}`
|
|
20362
|
+
});
|
|
20031
20363
|
const content = [];
|
|
20032
20364
|
if (useNativeTools) {
|
|
20033
20365
|
const contentArray = Array.isArray(result.content) ? result.content : [
|
|
@@ -20145,8 +20477,52 @@ var MCPSamplingLanguageModel = class {
|
|
|
20145
20477
|
/**
|
|
20146
20478
|
* Convert AI SDK messages to MCP sampling format
|
|
20147
20479
|
*/
|
|
20148
|
-
convertMessages(prompt) {
|
|
20149
|
-
|
|
20480
|
+
convertMessages(prompt, useNativeTools) {
|
|
20481
|
+
if (!useNativeTools) {
|
|
20482
|
+
return convertAISDKToMCPMessages(prompt);
|
|
20483
|
+
}
|
|
20484
|
+
const messages = [];
|
|
20485
|
+
for (const msg of prompt) {
|
|
20486
|
+
if (msg.role === "system") continue;
|
|
20487
|
+
const role = msg.role === "assistant" ? "assistant" : "user";
|
|
20488
|
+
const contentBlocks = [];
|
|
20489
|
+
for (const part of msg.content) {
|
|
20490
|
+
if (part.type === "text") {
|
|
20491
|
+
contentBlocks.push({
|
|
20492
|
+
type: "text",
|
|
20493
|
+
text: part.text
|
|
20494
|
+
});
|
|
20495
|
+
} else if (part.type === "tool-call") {
|
|
20496
|
+
const call = part;
|
|
20497
|
+
contentBlocks.push({
|
|
20498
|
+
type: "tool_use",
|
|
20499
|
+
id: call.toolCallId,
|
|
20500
|
+
name: call.toolName,
|
|
20501
|
+
input: call.args ?? call.input ?? {}
|
|
20502
|
+
});
|
|
20503
|
+
} else if (part.type === "tool-result") {
|
|
20504
|
+
const result = part;
|
|
20505
|
+
contentBlocks.push({
|
|
20506
|
+
type: "tool_result",
|
|
20507
|
+
toolUseId: result.toolCallId,
|
|
20508
|
+
// TODO: Handle different result types properly
|
|
20509
|
+
content: [
|
|
20510
|
+
{
|
|
20511
|
+
type: "text",
|
|
20512
|
+
text: result.output.type === "text" ? result.output.value?.toString() : JSON.stringify(result.output)
|
|
20513
|
+
}
|
|
20514
|
+
]
|
|
20515
|
+
});
|
|
20516
|
+
}
|
|
20517
|
+
}
|
|
20518
|
+
if (contentBlocks.length > 0) {
|
|
20519
|
+
messages.push({
|
|
20520
|
+
role,
|
|
20521
|
+
content: contentBlocks
|
|
20522
|
+
});
|
|
20523
|
+
}
|
|
20524
|
+
}
|
|
20525
|
+
return messages;
|
|
20150
20526
|
}
|
|
20151
20527
|
/**
|
|
20152
20528
|
* Map MCP stop reason to AI SDK finish reason
|
|
@@ -20159,7 +20535,12 @@ var MCPSamplingLanguageModel = class {
|
|
|
20159
20535
|
*/
|
|
20160
20536
|
supportsSamplingTools() {
|
|
20161
20537
|
const capabilities = this.server.getClientCapabilities();
|
|
20162
|
-
|
|
20538
|
+
const supportsTools = !!capabilities?.sampling?.tools;
|
|
20539
|
+
this.server.sendLoggingMessage({
|
|
20540
|
+
level: "info",
|
|
20541
|
+
data: `Client capabilities check: sampling=${!!capabilities?.sampling}, tools=${supportsTools}`
|
|
20542
|
+
});
|
|
20543
|
+
return supportsTools;
|
|
20163
20544
|
}
|
|
20164
20545
|
/**
|
|
20165
20546
|
* Convert AI SDK tools to MCP Tool format
|
|
@@ -20225,8 +20606,16 @@ IMPORTANT: You MUST respond with valid JSON only. Do not include any text before
|
|
|
20225
20606
|
return systemPrompt;
|
|
20226
20607
|
}
|
|
20227
20608
|
if (useNativeTools) {
|
|
20609
|
+
this.server.sendLoggingMessage({
|
|
20610
|
+
level: "info",
|
|
20611
|
+
data: `Using native tools mode - skipping XML tool injection`
|
|
20612
|
+
});
|
|
20228
20613
|
return systemPrompt;
|
|
20229
20614
|
}
|
|
20615
|
+
this.server.sendLoggingMessage({
|
|
20616
|
+
level: "info",
|
|
20617
|
+
data: `Injecting ${tools.length} tools into system prompt (fallback mode)`
|
|
20618
|
+
});
|
|
20230
20619
|
let enhanced = systemPrompt || "";
|
|
20231
20620
|
const toolsPrompt = `
|
|
20232
20621
|
|
|
@@ -20237,7 +20626,7 @@ You have access to the following tools. To use a tool, respond with this XML for
|
|
|
20237
20626
|
</use_tool>
|
|
20238
20627
|
|
|
20239
20628
|
Follow the JSON schema definition for each tool's parameters.
|
|
20240
|
-
You can use multiple tools in one response.
|
|
20629
|
+
You can use multiple tools in one response. DO NOT include text before or after tool calls - wait for the tool results first.
|
|
20241
20630
|
|
|
20242
20631
|
Tools:`;
|
|
20243
20632
|
const toolDescriptions = tools.map((tool2) => {
|