@paretools/shared 0.16.0 → 0.16.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-input.d.ts","sourceRoot":"","sources":["../src/strict-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"strict-input.d.ts","sourceRoot":"","sources":["../src/strict-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6DH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA0BpD"}
|
package/dist/strict-input.js
CHANGED
|
@@ -10,6 +10,42 @@
|
|
|
10
10
|
* clear error message listing the unrecognized key.
|
|
11
11
|
*/
|
|
12
12
|
import { z } from "zod";
|
|
13
|
+
/**
|
|
14
|
+
* Coerce string "true"/"false" to actual booleans.
|
|
15
|
+
* Unlike z.coerce.boolean() which uses JS Boolean() (where "false" → true),
|
|
16
|
+
* this correctly maps the string "false" → false.
|
|
17
|
+
*/
|
|
18
|
+
function coerceBool(val) {
|
|
19
|
+
if (typeof val === "string") {
|
|
20
|
+
const lower = val.toLowerCase();
|
|
21
|
+
if (lower === "false" || lower === "0" || lower === "")
|
|
22
|
+
return false;
|
|
23
|
+
if (lower === "true" || lower === "1")
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return val;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks whether a Zod schema is a boolean type (possibly wrapped in optional/default).
|
|
30
|
+
* Handles both Zod v4 (_zod.def.type / _zod.def.innerType) and v3 (_def.typeName / _def.innerType).
|
|
31
|
+
*/
|
|
32
|
+
function isBooleanSchema(schema) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
let s = schema;
|
|
35
|
+
const maxDepth = 10;
|
|
36
|
+
for (let i = 0; i < maxDepth && s; i++) {
|
|
37
|
+
// Zod v4: check _zod.def.type or _zod.type
|
|
38
|
+
const type = s._zod?.def?.type ?? s._zod?.type ?? s._def?.typeName;
|
|
39
|
+
if (type === "boolean" || type === "ZodBoolean")
|
|
40
|
+
return true;
|
|
41
|
+
// Unwrap optional/default/nullable/preprocess wrappers
|
|
42
|
+
const inner = s._zod?.def?.innerType ?? s._def?.innerType ?? s._def?.schema;
|
|
43
|
+
if (!inner || inner === s)
|
|
44
|
+
break;
|
|
45
|
+
s = inner;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
13
49
|
/**
|
|
14
50
|
* Checks whether a value is a Zod schema instance (has `_zod` for v4).
|
|
15
51
|
*/
|
|
@@ -44,10 +80,19 @@ export function strictifyInputSchema(schema) {
|
|
|
44
80
|
if (!schema)
|
|
45
81
|
return schema;
|
|
46
82
|
if (isRawShape(schema)) {
|
|
83
|
+
// Wrap boolean fields with preprocess to coerce "true"/"false" strings.
|
|
84
|
+
// MCP clients sometimes send booleans as strings.
|
|
85
|
+
const shape = schema;
|
|
86
|
+
const coerced = {};
|
|
87
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
88
|
+
coerced[key] = isBooleanSchema(fieldSchema)
|
|
89
|
+
? z.preprocess(coerceBool, fieldSchema)
|
|
90
|
+
: fieldSchema;
|
|
91
|
+
}
|
|
47
92
|
// Convert raw shape to strict object schema.
|
|
48
93
|
// The MCP SDK's normalizeObjectSchema will recognize this as a pre-built
|
|
49
94
|
// Zod v4 schema and use it directly instead of wrapping in z.object().
|
|
50
|
-
return z.strictObject(
|
|
95
|
+
return z.strictObject(coerced);
|
|
51
96
|
}
|
|
52
97
|
// If it's already a Zod object schema, apply .strict()
|
|
53
98
|
const schemaObj = schema;
|
package/dist/strict-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-input.js","sourceRoot":"","sources":["../src/strict-input.ts"],"names":[],"mappings":"AAAA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,EAAE,CAAC;QAClE,OAAQ,SAAS,CAAC,MAAwB,EAAO,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paretools/shared",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Shared utilities for Pare MCP servers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
44
44
|
"zod": "^4.3.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/node": "^25.
|
|
48
|
-
"typescript": "^
|
|
49
|
-
"vitest": "^4.1.
|
|
47
|
+
"@types/node": "^25.5.2",
|
|
48
|
+
"typescript": "^6.0.2",
|
|
49
|
+
"vitest": "^4.1.2",
|
|
50
50
|
"@paretools/tsconfig": "0.0.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|