mcp-use 1.7.0-canary.1 → 1.7.0-canary.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-PE7UMCVO.js → chunk-3R5PDYIN.js} +27 -1
- package/dist/{chunk-QSLJXXMG.js → chunk-AGKMD2ZM.js} +4 -4
- package/dist/{chunk-XN2PU4PS.js → chunk-BG2APH43.js} +22 -5
- package/dist/{chunk-YURRUCIM.js → chunk-CPG2WZUL.js} +9 -11
- package/dist/{chunk-R5DJJ4IV.js → chunk-F4UHAA5L.js} +3 -91
- package/dist/chunk-MTHLLDCX.js +97 -0
- package/dist/{chunk-GVVPUU5K.js → chunk-S6K5QZBJ.js} +739 -29
- package/dist/{display-YIYC6WJE.js → display-A5IEINAP.js} +79 -17
- package/dist/index.cjs +923 -107
- package/dist/index.js +10 -9
- package/dist/{langfuse-C4HKZ3NL.js → langfuse-N5Y5BSXK.js} +1 -1
- package/dist/{oauth-CNGBFOZW.js → oauth-U4NNKN4B.js} +2 -1
- package/dist/src/agents/display.d.ts.map +1 -1
- package/dist/src/agents/index.cjs +854 -78
- package/dist/src/agents/index.js +3 -2
- package/dist/src/auth/index.cjs +30 -5
- package/dist/src/auth/index.js +1 -1
- package/dist/src/browser.cjs +888 -90
- package/dist/src/browser.js +5 -4
- package/dist/src/connectors/base.d.ts +52 -121
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/managers/server_manager.d.ts.map +1 -1
- package/dist/src/managers/tools/acquire_active_mcp_server.d.ts +2 -2
- package/dist/src/managers/tools/acquire_active_mcp_server.d.ts.map +1 -1
- package/dist/src/managers/tools/add_server_from_config.d.ts +1 -7
- package/dist/src/managers/tools/add_server_from_config.d.ts.map +1 -1
- package/dist/src/managers/tools/connect_mcp_server.d.ts +2 -10
- package/dist/src/managers/tools/connect_mcp_server.d.ts.map +1 -1
- package/dist/src/managers/tools/list_mcp_servers.d.ts +2 -2
- package/dist/src/managers/tools/list_mcp_servers.d.ts.map +1 -1
- package/dist/src/managers/tools/release_mcp_server_connection.d.ts +2 -2
- package/dist/src/managers/tools/release_mcp_server_connection.d.ts.map +1 -1
- package/dist/src/observability/langfuse.d.ts +4 -0
- package/dist/src/observability/langfuse.d.ts.map +1 -1
- package/dist/src/react/McpUseProvider.d.ts.map +1 -1
- package/dist/src/react/index.cjs +57 -12
- package/dist/src/react/index.js +4 -3
- package/dist/src/server/connect-adapter.d.ts.map +1 -1
- package/dist/src/server/index.cjs +5 -9
- package/dist/src/server/index.js +15 -17
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/utils/json-schema-to-zod/JSONSchemaToZod.d.ts +270 -0
- package/dist/src/utils/json-schema-to-zod/JSONSchemaToZod.d.ts.map +1 -0
- package/dist/src/utils/json-schema-to-zod/Type.d.ts +24 -0
- package/dist/src/utils/json-schema-to-zod/Type.d.ts.map +1 -0
- package/dist/src/utils/json-schema-to-zod/index.d.ts +3 -0
- package/dist/src/utils/json-schema-to-zod/index.d.ts.map +1 -0
- package/dist/src/utils/url-sanitize.d.ts +17 -0
- package/dist/src/utils/url-sanitize.d.ts.map +1 -0
- package/dist/tsup.config.d.ts.map +1 -1
- package/package.json +19 -36
package/dist/src/react/index.cjs
CHANGED
|
@@ -47,7 +47,32 @@ module.exports = __toCommonJS(react_exports);
|
|
|
47
47
|
|
|
48
48
|
// src/react/useMcp.ts
|
|
49
49
|
var import_react = require("react");
|
|
50
|
-
|
|
50
|
+
|
|
51
|
+
// src/utils/url-sanitize.ts
|
|
52
|
+
function sanitizeUrl(raw) {
|
|
53
|
+
const abort = /* @__PURE__ */ __name(() => {
|
|
54
|
+
throw new Error(`Invalid url to pass to open(): ${raw}`);
|
|
55
|
+
}, "abort");
|
|
56
|
+
let url;
|
|
57
|
+
try {
|
|
58
|
+
url = new URL(raw);
|
|
59
|
+
} catch (_) {
|
|
60
|
+
abort();
|
|
61
|
+
}
|
|
62
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") abort();
|
|
63
|
+
if (url.hostname !== encodeURIComponent(url.hostname)) abort();
|
|
64
|
+
if (url.username) url.username = encodeURIComponent(url.username);
|
|
65
|
+
if (url.password) url.password = encodeURIComponent(url.password);
|
|
66
|
+
url.pathname = url.pathname.slice(0, 1) + encodeURIComponent(url.pathname.slice(1)).replace(/%2f/gi, "/");
|
|
67
|
+
url.search = url.search.slice(0, 1) + Array.from(url.searchParams.entries()).map(sanitizeParam).join("&");
|
|
68
|
+
url.hash = url.hash.slice(0, 1) + encodeURIComponent(url.hash.slice(1));
|
|
69
|
+
return url.href;
|
|
70
|
+
}
|
|
71
|
+
__name(sanitizeUrl, "sanitizeUrl");
|
|
72
|
+
function sanitizeParam([k, v]) {
|
|
73
|
+
return `${encodeURIComponent(k)}${v.length > 0 ? `=${encodeURIComponent(v)}` : ""}`;
|
|
74
|
+
}
|
|
75
|
+
__name(sanitizeParam, "sanitizeParam");
|
|
51
76
|
|
|
52
77
|
// src/connectors/http.ts
|
|
53
78
|
var import_client = require("@modelcontextprotocol/sdk/client/index.js");
|
|
@@ -1147,8 +1172,12 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1147
1172
|
}
|
|
1148
1173
|
};
|
|
1149
1174
|
|
|
1150
|
-
// src/
|
|
1151
|
-
var
|
|
1175
|
+
// src/server/utils/runtime.ts
|
|
1176
|
+
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
1177
|
+
function generateUUID() {
|
|
1178
|
+
return globalThis.crypto.randomUUID();
|
|
1179
|
+
}
|
|
1180
|
+
__name(generateUUID, "generateUUID");
|
|
1152
1181
|
|
|
1153
1182
|
// src/task_managers/websocket.ts
|
|
1154
1183
|
var import_ws = __toESM(require("ws"), 1);
|
|
@@ -1268,7 +1297,7 @@ var WebSocketConnector = class extends BaseConnector {
|
|
|
1268
1297
|
}
|
|
1269
1298
|
sendRequest(method, params = null) {
|
|
1270
1299
|
if (!this.ws) throw new Error("WebSocket is not connected");
|
|
1271
|
-
const id = (
|
|
1300
|
+
const id = generateUUID();
|
|
1272
1301
|
const payload = JSON.stringify({ id, method, params: params ?? {} });
|
|
1273
1302
|
return new Promise((resolve, reject) => {
|
|
1274
1303
|
this.pending.set(id, { resolve, reject });
|
|
@@ -1675,7 +1704,6 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
1675
1704
|
};
|
|
1676
1705
|
|
|
1677
1706
|
// src/auth/browser-provider.ts
|
|
1678
|
-
var import_strict_url_sanitise = require("strict-url-sanitise");
|
|
1679
1707
|
var BrowserOAuthClientProvider = class {
|
|
1680
1708
|
static {
|
|
1681
1709
|
__name(this, "BrowserOAuthClientProvider");
|
|
@@ -1695,7 +1723,7 @@ var BrowserOAuthClientProvider = class {
|
|
|
1695
1723
|
this.serverUrlHash = this.hashString(serverUrl);
|
|
1696
1724
|
this.clientName = options.clientName || "mcp-use";
|
|
1697
1725
|
this.clientUri = options.clientUri || (typeof window !== "undefined" ? window.location.origin : "");
|
|
1698
|
-
this.callbackUrl =
|
|
1726
|
+
this.callbackUrl = sanitizeUrl(
|
|
1699
1727
|
options.callbackUrl || (typeof window !== "undefined" ? new URL("/oauth/callback", window.location.origin).toString() : "/oauth/callback")
|
|
1700
1728
|
);
|
|
1701
1729
|
this.preventAutoAuth = options.preventAutoAuth;
|
|
@@ -1704,7 +1732,7 @@ var BrowserOAuthClientProvider = class {
|
|
|
1704
1732
|
}
|
|
1705
1733
|
// --- SDK Interface Methods ---
|
|
1706
1734
|
get redirectUrl() {
|
|
1707
|
-
return
|
|
1735
|
+
return sanitizeUrl(this.callbackUrl);
|
|
1708
1736
|
}
|
|
1709
1737
|
get clientMetadata() {
|
|
1710
1738
|
return {
|
|
@@ -1800,7 +1828,7 @@ var BrowserOAuthClientProvider = class {
|
|
|
1800
1828
|
localStorage.setItem(stateKey, JSON.stringify(stateData));
|
|
1801
1829
|
authorizationUrl.searchParams.set("state", state);
|
|
1802
1830
|
const authUrlString = authorizationUrl.toString();
|
|
1803
|
-
const sanitizedAuthUrl =
|
|
1831
|
+
const sanitizedAuthUrl = sanitizeUrl(authUrlString);
|
|
1804
1832
|
localStorage.setItem(this.getKey("last_auth_url"), sanitizedAuthUrl);
|
|
1805
1833
|
return sanitizedAuthUrl;
|
|
1806
1834
|
}
|
|
@@ -1857,7 +1885,7 @@ var BrowserOAuthClientProvider = class {
|
|
|
1857
1885
|
*/
|
|
1858
1886
|
getLastAttemptedAuthUrl() {
|
|
1859
1887
|
const storedUrl = localStorage.getItem(this.getKey("last_auth_url"));
|
|
1860
|
-
return storedUrl ?
|
|
1888
|
+
return storedUrl ? sanitizeUrl(storedUrl) : null;
|
|
1861
1889
|
}
|
|
1862
1890
|
clearStorage() {
|
|
1863
1891
|
const prefixPattern = `${this.storageKeyPrefix}_${this.serverUrlHash}_`;
|
|
@@ -1924,7 +1952,7 @@ function useMcp(options) {
|
|
|
1924
1952
|
enabled = true,
|
|
1925
1953
|
clientName,
|
|
1926
1954
|
clientUri,
|
|
1927
|
-
callbackUrl = typeof window !== "undefined" ?
|
|
1955
|
+
callbackUrl = typeof window !== "undefined" ? sanitizeUrl(
|
|
1928
1956
|
new URL("/oauth/callback", window.location.origin).toString()
|
|
1929
1957
|
) : "/oauth/callback",
|
|
1930
1958
|
storageKeyPrefix = "mcp:auth",
|
|
@@ -3516,7 +3544,18 @@ __name(WidgetControls, "WidgetControls");
|
|
|
3516
3544
|
|
|
3517
3545
|
// src/react/McpUseProvider.tsx
|
|
3518
3546
|
var import_react7 = __toESM(require("react"), 1);
|
|
3519
|
-
var
|
|
3547
|
+
var BrowserRouter = null;
|
|
3548
|
+
var routerError = null;
|
|
3549
|
+
(async () => {
|
|
3550
|
+
try {
|
|
3551
|
+
const routerModule = await import("react-router-dom");
|
|
3552
|
+
BrowserRouter = routerModule.BrowserRouter;
|
|
3553
|
+
} catch (error) {
|
|
3554
|
+
routerError = new Error(
|
|
3555
|
+
"\u274C react-router-dom not installed!\n\nTo use MCP widgets with McpUseProvider, you need to install:\n\n npm install react-router-dom\n # or\n pnpm add react-router-dom\n\nThis dependency is automatically included in projects created with 'create-mcp-use-app'."
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
})();
|
|
3520
3559
|
function getBasename() {
|
|
3521
3560
|
if (typeof window === "undefined") return "/";
|
|
3522
3561
|
const path = window.location.pathname;
|
|
@@ -3610,7 +3649,13 @@ function McpUseProvider({
|
|
|
3610
3649
|
if (enableDebugger || viewControls) {
|
|
3611
3650
|
content = /* @__PURE__ */ import_react7.default.createElement(WidgetControls, { debugger: enableDebugger, viewControls }, content);
|
|
3612
3651
|
}
|
|
3613
|
-
|
|
3652
|
+
if (routerError) {
|
|
3653
|
+
throw routerError;
|
|
3654
|
+
}
|
|
3655
|
+
if (!BrowserRouter) {
|
|
3656
|
+
throw new Error("react-router-dom is still loading, please try again.");
|
|
3657
|
+
}
|
|
3658
|
+
content = /* @__PURE__ */ import_react7.default.createElement(BrowserRouter, { basename }, content);
|
|
3614
3659
|
content = /* @__PURE__ */ import_react7.default.createElement(ThemeProvider, null, content);
|
|
3615
3660
|
if (autoSize) {
|
|
3616
3661
|
const containerStyle = {
|
package/dist/src/react/index.js
CHANGED
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
useWidgetProps,
|
|
10
10
|
useWidgetState,
|
|
11
11
|
useWidgetTheme
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
12
|
+
} from "../../chunk-BG2APH43.js";
|
|
13
|
+
import "../../chunk-AGKMD2ZM.js";
|
|
14
14
|
import {
|
|
15
15
|
onMcpAuthorization
|
|
16
|
-
} from "../../chunk-
|
|
16
|
+
} from "../../chunk-3R5PDYIN.js";
|
|
17
|
+
import "../../chunk-MTHLLDCX.js";
|
|
17
18
|
import "../../chunk-2JBWOW4S.js";
|
|
18
19
|
import "../../chunk-34R6SIER.js";
|
|
19
20
|
import "../../chunk-3GQAWCBQ.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-adapter.d.ts","sourceRoot":"","sources":["../../../src/server/connect-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,iBAAiB,EAAQ,MAAM,MAAM,CAAC;AAE7D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,CA0C5D;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,GAAG,EACf,cAAc,GAAE,MAAY,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,iBAAiB,EAAE,GAAG,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"connect-adapter.d.ts","sourceRoot":"","sources":["../../../src/server/connect-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,iBAAiB,EAAQ,MAAM,MAAM,CAAC;AAE7D;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,GAAG,GAAG,OAAO,CA0C5D;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,GAAG,EACf,cAAc,GAAE,MAAY,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,iBAAiB,EAAE,GAAG,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC,CA6J5B"}
|
|
@@ -1241,10 +1241,9 @@ async function adaptConnectMiddleware(connectMiddleware, middlewarePath) {
|
|
|
1241
1241
|
createRequest = httpMocks.createRequest;
|
|
1242
1242
|
createResponse = httpMocks.createResponse;
|
|
1243
1243
|
} catch (error2) {
|
|
1244
|
-
|
|
1245
|
-
"
|
|
1244
|
+
throw new Error(
|
|
1245
|
+
"\u274C Widget middleware dependencies not installed!\n\nTo use Connect middleware adapters with MCP widgets, you need to install:\n\n npm install node-mocks-http\n # or\n pnpm add node-mocks-http\n\nThis dependency is automatically included in projects created with 'create-mcp-use-app'."
|
|
1246
1246
|
);
|
|
1247
|
-
throw error2;
|
|
1248
1247
|
}
|
|
1249
1248
|
let normalizedPath = middlewarePath;
|
|
1250
1249
|
if (normalizedPath.endsWith("*")) {
|
|
@@ -1938,6 +1937,7 @@ var McpServer = class {
|
|
|
1938
1937
|
title: promptDefinition.title,
|
|
1939
1938
|
description: promptDefinition.description ?? "",
|
|
1940
1939
|
argsSchema
|
|
1940
|
+
// Type assertion for Zod v4 compatibility
|
|
1941
1941
|
},
|
|
1942
1942
|
async (params) => {
|
|
1943
1943
|
return await promptDefinition.cb(params);
|
|
@@ -2409,13 +2409,9 @@ var McpServer = class {
|
|
|
2409
2409
|
)();
|
|
2410
2410
|
tailwindcss = tailwindModule.default;
|
|
2411
2411
|
} catch (error2) {
|
|
2412
|
-
|
|
2413
|
-
"
|
|
2414
|
-
);
|
|
2415
|
-
console.error(
|
|
2416
|
-
"[WIDGETS] For production, use 'mcp-use build' to pre-build widgets."
|
|
2412
|
+
throw new Error(
|
|
2413
|
+
"\u274C Widget dependencies not installed!\n\nTo use MCP widgets with resources folder, you need to install the required dependencies:\n\n npm install vite @vitejs/plugin-react @tailwindcss/vite\n # or\n pnpm add vite @vitejs/plugin-react @tailwindcss/vite\n\nThese dependencies are automatically included in projects created with 'create-mcp-use-app'.\nFor production, pre-build your widgets using 'mcp-use build'."
|
|
2417
2414
|
);
|
|
2418
|
-
return;
|
|
2419
2415
|
}
|
|
2420
2416
|
const widgets = entries.map((entry) => {
|
|
2421
2417
|
return {
|
package/dist/src/server/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
-
fsHelpers,
|
|
3
|
-
generateUUID,
|
|
4
2
|
getAuth,
|
|
5
|
-
getCwd,
|
|
6
|
-
getEnv,
|
|
7
3
|
hasAnyScope,
|
|
8
4
|
hasScope,
|
|
9
|
-
isDeno,
|
|
10
5
|
oauthAuth0Provider,
|
|
11
6
|
oauthCustomProvider,
|
|
12
7
|
oauthKeycloakProvider,
|
|
13
8
|
oauthSupabaseProvider,
|
|
14
9
|
oauthWorkOSProvider,
|
|
15
|
-
pathHelpers,
|
|
16
10
|
requireAnyScope,
|
|
17
11
|
requireScope
|
|
18
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-F4UHAA5L.js";
|
|
13
|
+
import {
|
|
14
|
+
fsHelpers,
|
|
15
|
+
generateUUID,
|
|
16
|
+
getCwd,
|
|
17
|
+
getEnv,
|
|
18
|
+
isDeno,
|
|
19
|
+
pathHelpers
|
|
20
|
+
} from "../../chunk-MTHLLDCX.js";
|
|
19
21
|
import {
|
|
20
22
|
__name
|
|
21
23
|
} from "../../chunk-3GQAWCBQ.js";
|
|
@@ -196,10 +198,9 @@ async function adaptConnectMiddleware(connectMiddleware, middlewarePath) {
|
|
|
196
198
|
createRequest = httpMocks.createRequest;
|
|
197
199
|
createResponse = httpMocks.createResponse;
|
|
198
200
|
} catch (error2) {
|
|
199
|
-
|
|
200
|
-
"
|
|
201
|
+
throw new Error(
|
|
202
|
+
"\u274C Widget middleware dependencies not installed!\n\nTo use Connect middleware adapters with MCP widgets, you need to install:\n\n npm install node-mocks-http\n # or\n pnpm add node-mocks-http\n\nThis dependency is automatically included in projects created with 'create-mcp-use-app'."
|
|
201
203
|
);
|
|
202
|
-
throw error2;
|
|
203
204
|
}
|
|
204
205
|
let normalizedPath = middlewarePath;
|
|
205
206
|
if (normalizedPath.endsWith("*")) {
|
|
@@ -580,7 +581,7 @@ var McpServer = class {
|
|
|
580
581
|
if (this.oauthSetupComplete) {
|
|
581
582
|
return;
|
|
582
583
|
}
|
|
583
|
-
const { setupOAuthRoutes, createBearerAuthMiddleware } = await import("../../oauth-
|
|
584
|
+
const { setupOAuthRoutes, createBearerAuthMiddleware } = await import("../../oauth-U4NNKN4B.js");
|
|
584
585
|
this.oauthProvider = oauthProvider;
|
|
585
586
|
console.log(`[OAuth] OAuth provider initialized`);
|
|
586
587
|
const baseUrl = this.getServerBaseUrl();
|
|
@@ -892,6 +893,7 @@ var McpServer = class {
|
|
|
892
893
|
title: promptDefinition.title,
|
|
893
894
|
description: promptDefinition.description ?? "",
|
|
894
895
|
argsSchema
|
|
896
|
+
// Type assertion for Zod v4 compatibility
|
|
895
897
|
},
|
|
896
898
|
async (params) => {
|
|
897
899
|
return await promptDefinition.cb(params);
|
|
@@ -1363,13 +1365,9 @@ var McpServer = class {
|
|
|
1363
1365
|
)();
|
|
1364
1366
|
tailwindcss = tailwindModule.default;
|
|
1365
1367
|
} catch (error2) {
|
|
1366
|
-
|
|
1367
|
-
"
|
|
1368
|
-
);
|
|
1369
|
-
console.error(
|
|
1370
|
-
"[WIDGETS] For production, use 'mcp-use build' to pre-build widgets."
|
|
1368
|
+
throw new Error(
|
|
1369
|
+
"\u274C Widget dependencies not installed!\n\nTo use MCP widgets with resources folder, you need to install the required dependencies:\n\n npm install vite @vitejs/plugin-react @tailwindcss/vite\n # or\n pnpm add vite @vitejs/plugin-react @tailwindcss/vite\n\nThese dependencies are automatically included in projects created with 'create-mcp-use-app'.\nFor production, pre-build your widgets using 'mcp-use build'."
|
|
1371
1370
|
);
|
|
1372
|
-
return;
|
|
1373
1371
|
}
|
|
1374
1372
|
const widgets = entries.map((entry) => {
|
|
1375
1373
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../../src/server/mcp-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,oCAAoC,CAAC;AAG5C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IAC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QAAQ,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;KACtD,KAAK,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;CACpD,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAIH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;CAAE,GAC5E,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAI3B,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC7B,iBAAiB,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type { ZodSchema } from "zod";
|
|
2
|
+
import type { JSONSchema } from "./Type.js";
|
|
3
|
+
export declare class JSONSchemaToZod {
|
|
4
|
+
/**
|
|
5
|
+
* Converts a JSON schema to a Zod schema.
|
|
6
|
+
*
|
|
7
|
+
* @param {JSONSchema} schema - The JSON schema.
|
|
8
|
+
* @returns {ZodSchema} - The Zod schema.
|
|
9
|
+
*/
|
|
10
|
+
static convert(schema: JSONSchema): ZodSchema;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if data matches a condition schema.
|
|
13
|
+
*
|
|
14
|
+
* @param {JSONValue} data - The data to check.
|
|
15
|
+
* @param {JSONSchema} condition - The condition schema.
|
|
16
|
+
* @returns {boolean} - Whether the data matches the condition.
|
|
17
|
+
*/
|
|
18
|
+
private static matchesCondition;
|
|
19
|
+
/**
|
|
20
|
+
* Validates data against a conditional schema and adds issues to context if validation fails.
|
|
21
|
+
*
|
|
22
|
+
* @param {JSONValue} data - The data to validate.
|
|
23
|
+
* @param {JSONSchema} schema - The conditional schema.
|
|
24
|
+
* @param {z.RefinementCtx} ctx - The Zod refinement context.
|
|
25
|
+
*/
|
|
26
|
+
private static validateConditionalSchema;
|
|
27
|
+
/**
|
|
28
|
+
* Validates that all required properties are present in the data.
|
|
29
|
+
*
|
|
30
|
+
* @param {JSONValue} data - The data to validate.
|
|
31
|
+
* @param {JSONSchema} schema - The schema containing required properties.
|
|
32
|
+
* @param {z.RefinementCtx} ctx - The Zod refinement context.
|
|
33
|
+
*/
|
|
34
|
+
private static validateRequiredProperties;
|
|
35
|
+
/**
|
|
36
|
+
* Validates property patterns for string properties.
|
|
37
|
+
*
|
|
38
|
+
* @param {JSONValue} data - The data to validate.
|
|
39
|
+
* @param {JSONSchema} schema - The schema containing property patterns.
|
|
40
|
+
* @param {z.RefinementCtx} ctx - The Zod refinement context.
|
|
41
|
+
*/
|
|
42
|
+
private static validatePropertyPatterns;
|
|
43
|
+
/**
|
|
44
|
+
* Validates nested if-then-else conditions.
|
|
45
|
+
*
|
|
46
|
+
* @param {JSONValue} data - The data to validate.
|
|
47
|
+
* @param {JSONSchema} schema - The schema containing if-then-else conditions.
|
|
48
|
+
* @param {z.RefinementCtx} ctx - The Zod refinement context.
|
|
49
|
+
*/
|
|
50
|
+
private static validateNestedConditions;
|
|
51
|
+
/**
|
|
52
|
+
* Parses a JSON schema and returns the corresponding Zod schema.
|
|
53
|
+
* This is the main entry point for schema conversion.
|
|
54
|
+
*
|
|
55
|
+
* @param {JSONSchema} schema - The JSON schema.
|
|
56
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
57
|
+
*/
|
|
58
|
+
private static parseSchema;
|
|
59
|
+
/**
|
|
60
|
+
* Handles schemas with an array of types.
|
|
61
|
+
*
|
|
62
|
+
* @param {JSONSchema} schema - The JSON schema with type array.
|
|
63
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
64
|
+
*/
|
|
65
|
+
private static handleTypeArray;
|
|
66
|
+
/**
|
|
67
|
+
* Handles nullable types by creating a nullable schema.
|
|
68
|
+
*
|
|
69
|
+
* @param {JSONSchema} schema - The JSON schema with nullable type.
|
|
70
|
+
* @returns {ZodTypeAny} - The nullable Zod schema.
|
|
71
|
+
*/
|
|
72
|
+
private static handleNullableType;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a union type from an array of types.
|
|
75
|
+
*
|
|
76
|
+
* @param {string[]} types - Array of type strings.
|
|
77
|
+
* @param {JSONSchema} baseSchema - The base schema to apply to each type.
|
|
78
|
+
* @returns {ZodTypeAny} - The union Zod schema.
|
|
79
|
+
*/
|
|
80
|
+
private static createUnionFromTypes;
|
|
81
|
+
/**
|
|
82
|
+
* Handles schemas with a single type.
|
|
83
|
+
*
|
|
84
|
+
* @param {JSONSchema} schema - The JSON schema with single type.
|
|
85
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
86
|
+
*/
|
|
87
|
+
private static handleSingleType;
|
|
88
|
+
/**
|
|
89
|
+
* Parses a number schema.
|
|
90
|
+
*
|
|
91
|
+
* @param {JSONSchema} schema - The JSON schema for a number.
|
|
92
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
93
|
+
*/
|
|
94
|
+
private static parseNumberSchema;
|
|
95
|
+
/**
|
|
96
|
+
* Applies bounds validation to a number schema.
|
|
97
|
+
*
|
|
98
|
+
* @param {z.ZodNumber} numberSchema - The base number schema.
|
|
99
|
+
* @param {JSONSchema} schema - The JSON schema with bounds.
|
|
100
|
+
* @returns {z.ZodNumber} - The updated schema with bounds validation.
|
|
101
|
+
*/
|
|
102
|
+
private static applyNumberBounds;
|
|
103
|
+
/**
|
|
104
|
+
* Applies multipleOf validation to a number schema.
|
|
105
|
+
*
|
|
106
|
+
* @param {z.ZodNumber} numberSchema - The base number schema.
|
|
107
|
+
* @param {JSONSchema} schema - The JSON schema with multipleOf.
|
|
108
|
+
* @returns {z.ZodNumber} - The updated schema with multipleOf validation.
|
|
109
|
+
*/
|
|
110
|
+
private static applyNumberMultipleOf;
|
|
111
|
+
/**
|
|
112
|
+
* Applies enum validation to a number schema.
|
|
113
|
+
*
|
|
114
|
+
* @param {z.ZodNumber} numberSchema - The base number schema.
|
|
115
|
+
* @param {JSONSchema} schema - The JSON schema with enum.
|
|
116
|
+
* @returns {z.ZodNumber} - The updated schema with enum validation.
|
|
117
|
+
*/
|
|
118
|
+
private static applyNumberEnum;
|
|
119
|
+
/**
|
|
120
|
+
* Applies integer constraint to a number schema if needed.
|
|
121
|
+
*
|
|
122
|
+
* @param {z.ZodNumber} numberSchema - The base number schema.
|
|
123
|
+
* @param {JSONSchema} schema - The JSON schema.
|
|
124
|
+
* @returns {z.ZodNumber} - The updated schema with integer validation if needed.
|
|
125
|
+
*/
|
|
126
|
+
private static applyIntegerConstraint;
|
|
127
|
+
/**
|
|
128
|
+
* Parses a string schema.
|
|
129
|
+
*
|
|
130
|
+
* @param {JSONSchema} schema - The JSON schema for a string.
|
|
131
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
132
|
+
*/
|
|
133
|
+
private static parseString;
|
|
134
|
+
/**
|
|
135
|
+
* Applies format validation to a string schema.
|
|
136
|
+
*
|
|
137
|
+
* @param {z.ZodString} stringSchema - The base string schema.
|
|
138
|
+
* @param {JSONSchema} schema - The JSON schema with format.
|
|
139
|
+
* @returns {ZodTypeAny} - The updated schema with format validation.
|
|
140
|
+
*/
|
|
141
|
+
private static applyStringFormat;
|
|
142
|
+
/**
|
|
143
|
+
* Applies pattern validation to a string schema.
|
|
144
|
+
*
|
|
145
|
+
* @param {z.ZodString} stringSchema - The base string schema.
|
|
146
|
+
* @param {JSONSchema} schema - The JSON schema with pattern.
|
|
147
|
+
* @returns {z.ZodString} - The updated schema with pattern validation.
|
|
148
|
+
*/
|
|
149
|
+
private static applyStringPattern;
|
|
150
|
+
/**
|
|
151
|
+
* Applies length constraints to a string schema.
|
|
152
|
+
*
|
|
153
|
+
* @param {z.ZodString} stringSchema - The base string schema.
|
|
154
|
+
* @param {JSONSchema} schema - The JSON schema with length constraints.
|
|
155
|
+
* @returns {z.ZodString} - The updated schema with length validation.
|
|
156
|
+
*/
|
|
157
|
+
private static applyStringLength;
|
|
158
|
+
/**
|
|
159
|
+
* Applies enum validation to a string schema.
|
|
160
|
+
*
|
|
161
|
+
* @param {z.ZodString} stringSchema - The base string schema.
|
|
162
|
+
* @param {JSONSchema} schema - The JSON schema with enum.
|
|
163
|
+
* @returns {ZodTypeAny} - The updated schema with enum validation.
|
|
164
|
+
*/
|
|
165
|
+
private static applyStringEnum;
|
|
166
|
+
/**
|
|
167
|
+
* Parses a JSON schema of type array and returns the corresponding Zod schema.
|
|
168
|
+
*
|
|
169
|
+
* @param {JSONSchema} schema - The JSON schema.
|
|
170
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
171
|
+
*/
|
|
172
|
+
private static parseArray;
|
|
173
|
+
/**
|
|
174
|
+
* Applies constraints to an array schema.
|
|
175
|
+
*
|
|
176
|
+
* @param {z.ZodArray<any>} arraySchema - The base array schema.
|
|
177
|
+
* @param {JSONSchema} schema - The JSON schema with array constraints.
|
|
178
|
+
* @returns {z.ZodTypeAny} - The updated array schema with constraints.
|
|
179
|
+
*/
|
|
180
|
+
private static applyArrayConstraints;
|
|
181
|
+
/**
|
|
182
|
+
* Parses an object schema.
|
|
183
|
+
*
|
|
184
|
+
* @param {JSONSchema} schema - The JSON schema for an object.
|
|
185
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
186
|
+
*/
|
|
187
|
+
private static parseObject;
|
|
188
|
+
/**
|
|
189
|
+
* Processes object properties and builds the shape object.
|
|
190
|
+
*
|
|
191
|
+
* @param {JSONSchema} schema - The JSON schema for an object.
|
|
192
|
+
* @param {Record<string, ZodTypeAny>} shape - The shape object to populate.
|
|
193
|
+
*/
|
|
194
|
+
private static processObjectProperties;
|
|
195
|
+
/**
|
|
196
|
+
* Processes additionalProperties configuration.
|
|
197
|
+
*
|
|
198
|
+
* @param {JSONSchema} schema - The JSON schema for an object.
|
|
199
|
+
* @param {z.ZodObject<any, any>} objectSchema - The Zod object schema.
|
|
200
|
+
* @returns {z.ZodObject<any, any>} - The updated Zod object schema.
|
|
201
|
+
*/
|
|
202
|
+
private static processAdditionalProperties;
|
|
203
|
+
/**
|
|
204
|
+
* Parses a conditional schema with if-then-else.
|
|
205
|
+
*
|
|
206
|
+
* @param {JSONSchema} schema - The JSON schema with conditional validation.
|
|
207
|
+
* @returns {ZodTypeAny} - The conditional Zod schema.
|
|
208
|
+
*/
|
|
209
|
+
private static parseConditional;
|
|
210
|
+
/**
|
|
211
|
+
* Creates a base object schema from the given JSON schema.
|
|
212
|
+
*
|
|
213
|
+
* @param {JSONSchema} schema - The JSON schema.
|
|
214
|
+
* @returns {z.ZodObject<any, any>} - The base Zod object schema.
|
|
215
|
+
*/
|
|
216
|
+
private static createBaseObjectSchema;
|
|
217
|
+
/**
|
|
218
|
+
* Applies default values from schema properties to data object.
|
|
219
|
+
*
|
|
220
|
+
* @param {JSONValue} data - The original data object.
|
|
221
|
+
* @param {JSONSchema} schema - The schema with default values.
|
|
222
|
+
* @returns {JSONValue} - The data object with defaults applied.
|
|
223
|
+
*/
|
|
224
|
+
private static applyDefaultValues;
|
|
225
|
+
/**
|
|
226
|
+
* Parses a schema with combinators (oneOf, anyOf, allOf).
|
|
227
|
+
* Delegates to the appropriate combinator parser based on which combinator is present.
|
|
228
|
+
*
|
|
229
|
+
* @param {JSONSchema} schema - The JSON schema with combinators.
|
|
230
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
231
|
+
*/
|
|
232
|
+
private static parseCombinator;
|
|
233
|
+
/**
|
|
234
|
+
* Parses a oneOf combinator schema.
|
|
235
|
+
*
|
|
236
|
+
* @param {JSONSchema[]} schemas - Array of JSON schemas in the oneOf.
|
|
237
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
238
|
+
*/
|
|
239
|
+
private static parseOneOf;
|
|
240
|
+
/**
|
|
241
|
+
* Parses an anyOf combinator schema.
|
|
242
|
+
*
|
|
243
|
+
* @param {JSONSchema[]} schemas - Array of JSON schemas in the anyOf.
|
|
244
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
245
|
+
*/
|
|
246
|
+
private static parseAnyOf;
|
|
247
|
+
/**
|
|
248
|
+
* Creates a union from an array of schemas, handling special cases.
|
|
249
|
+
*
|
|
250
|
+
* @param {JSONSchema[]} schemas - Array of JSON schemas to create a union from.
|
|
251
|
+
* @returns {ZodTypeAny} - The union Zod schema.
|
|
252
|
+
*/
|
|
253
|
+
private static createUnionFromSchemas;
|
|
254
|
+
/**
|
|
255
|
+
* Parses an allOf combinator schema by merging all schemas.
|
|
256
|
+
*
|
|
257
|
+
* @param {JSONSchema[]} schemas - Array of JSON schemas in the allOf.
|
|
258
|
+
* @returns {ZodTypeAny} - The ZodTypeAny schema.
|
|
259
|
+
*/
|
|
260
|
+
private static parseAllOf;
|
|
261
|
+
/**
|
|
262
|
+
* Merges two JSON schemas together.
|
|
263
|
+
*
|
|
264
|
+
* @param {JSONSchema} baseSchema - The base JSON schema.
|
|
265
|
+
* @param {JSONSchema} addSchema - The JSON schema to add.
|
|
266
|
+
* @returns {JSONSchema} - The merged JSON schema
|
|
267
|
+
*/
|
|
268
|
+
private static mergeSchemas;
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=JSONSchemaToZod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONSchemaToZod.d.ts","sourceRoot":"","sources":["../../../../src/utils/json-schema-to-zod/JSONSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAyB,MAAM,WAAW,CAAC;AAEnE,qBAAa,eAAe;IAC1B;;;;;OAKG;WACW,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS;IAIpD;;;;;;OAMG;IACH,OAAO,CAAC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AC,MAAM,CAAC,WAAW;IAgB1B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAgBtC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAoB1C;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IA0B/B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAerC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA+BjC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAiB9B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAkCrC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAmBzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;CAoB5B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents any valid JSON value.
|
|
3
|
+
*/
|
|
4
|
+
export type JSONValue = string | number | boolean | null | JSONObject | JSONValue[];
|
|
5
|
+
/**
|
|
6
|
+
* Represents a JSON object.
|
|
7
|
+
*/
|
|
8
|
+
export type JSONObject = {
|
|
9
|
+
[key: string]: JSONValue;
|
|
10
|
+
};
|
|
11
|
+
export type JSONSchema = {
|
|
12
|
+
type?: string | string[];
|
|
13
|
+
properties?: Record<string, JSONSchema>;
|
|
14
|
+
items?: JSONSchema | JSONSchema[];
|
|
15
|
+
required?: string[];
|
|
16
|
+
enum?: (string | number)[];
|
|
17
|
+
format?: string;
|
|
18
|
+
oneOf?: JSONSchema[];
|
|
19
|
+
allOf?: JSONSchema[];
|
|
20
|
+
anyOf?: JSONSchema[];
|
|
21
|
+
additionalProperties?: boolean | JSONSchema;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=Type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Type.d.ts","sourceRoot":"","sources":["../../../../src/utils/json-schema-to-zod/Type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,UAAU,GACV,SAAS,EAAE,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC5C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/json-schema-to-zod/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL sanitization utility
|
|
3
|
+
*
|
|
4
|
+
* Sanitizes URLs to prevent security issues by:
|
|
5
|
+
* - Restricting to http/https protocols only
|
|
6
|
+
* - Encoding URL components properly
|
|
7
|
+
* - Validating hostnames
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Sanitizes a URL string by encoding all components and validating the protocol.
|
|
11
|
+
*
|
|
12
|
+
* @param raw - The raw URL string to sanitize
|
|
13
|
+
* @returns The sanitized URL as a string
|
|
14
|
+
* @throws Error if the URL is invalid or uses an unsupported protocol
|
|
15
|
+
*/
|
|
16
|
+
export declare function sanitizeUrl(raw: string): string;
|
|
17
|
+
//# sourceMappingURL=url-sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-sanitize.d.ts","sourceRoot":"","sources":["../../../src/utils/url-sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA+B/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBA2CG"}
|