@kubb/plugin-mcp 3.16.2 → 3.16.3
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/OperationGenerator-BMJ9Szu5.d.cts +1111 -0
- package/dist/OperationGenerator-D1X1O_-A.d.ts +1111 -0
- package/dist/Server-BX80OVzu.js +90 -0
- package/dist/Server-BX80OVzu.js.map +1 -0
- package/dist/Server-Bh-nULhJ.cjs +124 -0
- package/dist/Server-Bh-nULhJ.cjs.map +1 -0
- package/dist/components.cjs +2 -11
- package/dist/components.d.cts +31 -25
- package/dist/components.d.ts +31 -25
- package/dist/components.js +3 -3
- package/dist/generators-CFdUB1k-.js +225 -0
- package/dist/generators-CFdUB1k-.js.map +1 -0
- package/dist/generators-UZiEnnoX.cjs +236 -0
- package/dist/generators-UZiEnnoX.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +9 -9
- package/dist/generators.d.ts +9 -9
- package/dist/generators.js +4 -4
- package/dist/index.cjs +82 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +82 -95
- package/dist/index.js.map +1 -1
- package/dist/types-DLgrsgaK.d.ts +168 -0
- package/dist/types-Dg5mHzgC.d.cts +168 -0
- package/package.json +20 -35
- package/dist/chunk-JTYWPGT3.js +0 -178
- package/dist/chunk-JTYWPGT3.js.map +0 -1
- package/dist/chunk-MTZE6GGJ.cjs +0 -181
- package/dist/chunk-MTZE6GGJ.cjs.map +0 -1
- package/dist/chunk-ODMTYF4L.cjs +0 -97
- package/dist/chunk-ODMTYF4L.cjs.map +0 -1
- package/dist/chunk-YP4TIQ5F.js +0 -95
- package/dist/chunk-YP4TIQ5F.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-B4DlUSkU.d.cts +0 -54
- package/dist/types-B4DlUSkU.d.ts +0 -54
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
2
|
+
import { getPathParams, isOptional } from "@kubb/plugin-oas/utils";
|
|
3
|
+
import { Const, File, FunctionParams } from "@kubb/react";
|
|
4
|
+
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
5
|
+
import { isNullable, isReference } from "@kubb/oas";
|
|
6
|
+
|
|
7
|
+
//#region src/components/Server.tsx
|
|
8
|
+
function getParams({ schemas }) {
|
|
9
|
+
const pathParams = getPathParams(schemas.pathParams, { typed: false });
|
|
10
|
+
return FunctionParams.factory({ data: {
|
|
11
|
+
mode: "object",
|
|
12
|
+
children: {
|
|
13
|
+
...Object.entries(pathParams).reduce((acc, [key, param]) => {
|
|
14
|
+
if (param && schemas.pathParams?.name) {
|
|
15
|
+
let suffix = ".shape";
|
|
16
|
+
if (isNullable(schemas.pathParams.schema)) if (isReference(schemas.pathParams)) suffix = ".unwrap().schema.unwrap().shape";
|
|
17
|
+
else suffix = ".unwrap().shape";
|
|
18
|
+
else if (isReference(schemas.pathParams)) suffix = ".schema.shape";
|
|
19
|
+
param.value = `${schemas.pathParams?.name}${suffix}['${key}']`;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
...acc,
|
|
23
|
+
[camelCase(key)]: param
|
|
24
|
+
};
|
|
25
|
+
}, {}),
|
|
26
|
+
data: schemas.request?.name ? {
|
|
27
|
+
value: schemas.request?.name,
|
|
28
|
+
optional: isOptional(schemas.request?.schema)
|
|
29
|
+
} : void 0,
|
|
30
|
+
params: schemas.queryParams?.name ? {
|
|
31
|
+
value: schemas.queryParams?.name,
|
|
32
|
+
optional: isOptional(schemas.queryParams?.schema)
|
|
33
|
+
} : void 0,
|
|
34
|
+
headers: schemas.headerParams?.name ? {
|
|
35
|
+
value: schemas.headerParams?.name,
|
|
36
|
+
optional: isOptional(schemas.headerParams?.schema)
|
|
37
|
+
} : void 0
|
|
38
|
+
}
|
|
39
|
+
} });
|
|
40
|
+
}
|
|
41
|
+
function Server({ name, serverName, serverVersion, operations }) {
|
|
42
|
+
return /* @__PURE__ */ jsxs(File.Source, {
|
|
43
|
+
name,
|
|
44
|
+
isExportable: true,
|
|
45
|
+
isIndexable: true,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Const, {
|
|
48
|
+
name: "server",
|
|
49
|
+
export: true,
|
|
50
|
+
children: `
|
|
51
|
+
new McpServer({
|
|
52
|
+
name: '${serverName}',
|
|
53
|
+
version: '${serverVersion}',
|
|
54
|
+
})
|
|
55
|
+
`
|
|
56
|
+
}),
|
|
57
|
+
operations.map(({ tool, mcp, zod }) => {
|
|
58
|
+
const paramsClient = getParams({ schemas: zod.schemas });
|
|
59
|
+
if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) return `
|
|
60
|
+
server.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {
|
|
61
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
62
|
+
})
|
|
63
|
+
`;
|
|
64
|
+
return `
|
|
65
|
+
server.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {
|
|
66
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
67
|
+
})
|
|
68
|
+
`;
|
|
69
|
+
}).filter(Boolean),
|
|
70
|
+
`
|
|
71
|
+
async function startServer() {
|
|
72
|
+
try {
|
|
73
|
+
const transport = new StdioServerTransport()
|
|
74
|
+
await server.connect(transport)
|
|
75
|
+
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Failed to start server:', error)
|
|
78
|
+
process.exit(1)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
startServer()
|
|
83
|
+
`
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { Server };
|
|
90
|
+
//# sourceMappingURL=Server-BX80OVzu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Server-BX80OVzu.js","names":[],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAoCA,SAAS,UAAU,EAAE,SAAyB,EAAE;CAC9C,MAAM,aAAa,cAAc,QAAQ,YAAY,EACnD,OAAO,MACR,EAAC;AAEF,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU;GACR,GAAG,OAAO,QAAQ,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,KAAK;AAC1D,QAAI,SAAS,QAAQ,YAAY,MAAM;KACrC,IAAI,SAAS;AAEb,SAAI,WAAW,QAAQ,WAAW,OAAO,CACvC,KAAI,YAAY,QAAQ,WAAW,EACjC,SAAS;UAET,SAAS;cAGP,YAAY,QAAQ,WAAW,EACjC,SAAS;KAIb,MAAM,QAAQ,GAAG,QAAQ,YAAY,OAAO,OAAO,EAAE,EAAE,IAA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AAC;GACF,EAAC,CACD,OAAO,QAAQ;GAEjB,CAAC;;;;;;;;;;;;;AAaR,CAAC;;GACiB;AAEjB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const __kubb_core_transformers = __toESM(require("@kubb/core/transformers"));
|
|
25
|
+
const __kubb_plugin_oas_utils = __toESM(require("@kubb/plugin-oas/utils"));
|
|
26
|
+
const __kubb_react = __toESM(require("@kubb/react"));
|
|
27
|
+
const __kubb_react_jsx_runtime = __toESM(require("@kubb/react/jsx-runtime"));
|
|
28
|
+
const __kubb_oas = __toESM(require("@kubb/oas"));
|
|
29
|
+
|
|
30
|
+
//#region src/components/Server.tsx
|
|
31
|
+
function getParams({ schemas }) {
|
|
32
|
+
const pathParams = (0, __kubb_plugin_oas_utils.getPathParams)(schemas.pathParams, { typed: false });
|
|
33
|
+
return __kubb_react.FunctionParams.factory({ data: {
|
|
34
|
+
mode: "object",
|
|
35
|
+
children: {
|
|
36
|
+
...Object.entries(pathParams).reduce((acc, [key, param]) => {
|
|
37
|
+
if (param && schemas.pathParams?.name) {
|
|
38
|
+
let suffix = ".shape";
|
|
39
|
+
if ((0, __kubb_oas.isNullable)(schemas.pathParams.schema)) if ((0, __kubb_oas.isReference)(schemas.pathParams)) suffix = ".unwrap().schema.unwrap().shape";
|
|
40
|
+
else suffix = ".unwrap().shape";
|
|
41
|
+
else if ((0, __kubb_oas.isReference)(schemas.pathParams)) suffix = ".schema.shape";
|
|
42
|
+
param.value = `${schemas.pathParams?.name}${suffix}['${key}']`;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...acc,
|
|
46
|
+
[(0, __kubb_core_transformers.camelCase)(key)]: param
|
|
47
|
+
};
|
|
48
|
+
}, {}),
|
|
49
|
+
data: schemas.request?.name ? {
|
|
50
|
+
value: schemas.request?.name,
|
|
51
|
+
optional: (0, __kubb_plugin_oas_utils.isOptional)(schemas.request?.schema)
|
|
52
|
+
} : void 0,
|
|
53
|
+
params: schemas.queryParams?.name ? {
|
|
54
|
+
value: schemas.queryParams?.name,
|
|
55
|
+
optional: (0, __kubb_plugin_oas_utils.isOptional)(schemas.queryParams?.schema)
|
|
56
|
+
} : void 0,
|
|
57
|
+
headers: schemas.headerParams?.name ? {
|
|
58
|
+
value: schemas.headerParams?.name,
|
|
59
|
+
optional: (0, __kubb_plugin_oas_utils.isOptional)(schemas.headerParams?.schema)
|
|
60
|
+
} : void 0
|
|
61
|
+
}
|
|
62
|
+
} });
|
|
63
|
+
}
|
|
64
|
+
function Server({ name, serverName, serverVersion, operations }) {
|
|
65
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File.Source, {
|
|
66
|
+
name,
|
|
67
|
+
isExportable: true,
|
|
68
|
+
isIndexable: true,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Const, {
|
|
71
|
+
name: "server",
|
|
72
|
+
export: true,
|
|
73
|
+
children: `
|
|
74
|
+
new McpServer({
|
|
75
|
+
name: '${serverName}',
|
|
76
|
+
version: '${serverVersion}',
|
|
77
|
+
})
|
|
78
|
+
`
|
|
79
|
+
}),
|
|
80
|
+
operations.map(({ tool, mcp, zod }) => {
|
|
81
|
+
const paramsClient = getParams({ schemas: zod.schemas });
|
|
82
|
+
if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) return `
|
|
83
|
+
server.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {
|
|
84
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
85
|
+
})
|
|
86
|
+
`;
|
|
87
|
+
return `
|
|
88
|
+
server.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {
|
|
89
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
90
|
+
})
|
|
91
|
+
`;
|
|
92
|
+
}).filter(Boolean),
|
|
93
|
+
`
|
|
94
|
+
async function startServer() {
|
|
95
|
+
try {
|
|
96
|
+
const transport = new StdioServerTransport()
|
|
97
|
+
await server.connect(transport)
|
|
98
|
+
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error('Failed to start server:', error)
|
|
101
|
+
process.exit(1)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
startServer()
|
|
106
|
+
`
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
Object.defineProperty(exports, 'Server', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return Server;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, '__toESM', {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return __toESM;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=Server-Bh-nULhJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Server-Bh-nULhJ.cjs","names":["FunctionParams","File","Const"],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,UAAU,EAAE,SAAyB,EAAE;CAC9C,MAAM,wDAA2B,QAAQ,YAAY,EACnD,OAAO,MACR,EAAC;AAEF,QAAOA,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU;GACR,GAAG,OAAO,QAAQ,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,KAAK;AAC1D,QAAI,SAAS,QAAQ,YAAY,MAAM;KACrC,IAAI,SAAS;A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CAAC;AAGD,WAAO,CAAC;YACN,EAAE,KAAK,UAAU,KAAK,KAAK,CAAC,EAAE,EAAE,KAAK,UAAU,KAAK,YAAY,CAAC;SACpE,EAAE,IAAI,KAAK,CAAC,EAAE,aAAa,UAAU,CAAC;;UAErC,CAAC;GACF,EAAC,CACD,OAAO,QAAQ;GAEjB,CAAC;;;;;;;;;;;;;AAaR,CAAC;;GACiB;AAEjB"}
|
package/dist/components.cjs
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
const require_Server = require('./Server-Bh-nULhJ.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "Server", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return chunkODMTYF4L_cjs.Server; }
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=components.cjs.map
|
|
12
|
-
//# sourceMappingURL=components.cjs.map
|
|
3
|
+
exports.Server = require_Server.Server;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
1
|
+
import { File, OperationSchemas } from "./OperationGenerator-BMJ9Szu5.cjs";
|
|
3
2
|
|
|
3
|
+
//#region src/components/Server.d.ts
|
|
4
4
|
type Props = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
serverName: string;
|
|
7
|
+
serverVersion: string;
|
|
8
|
+
operations: Array<{
|
|
9
|
+
tool: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
mcp: {
|
|
14
|
+
name: string;
|
|
15
|
+
file: File;
|
|
16
|
+
};
|
|
17
|
+
zod: {
|
|
18
|
+
name: string;
|
|
19
|
+
file: File;
|
|
20
|
+
schemas: OperationSchemas;
|
|
21
|
+
};
|
|
22
|
+
type: {
|
|
23
|
+
schemas: OperationSchemas;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
26
|
};
|
|
27
|
-
declare function Server({
|
|
28
|
-
|
|
27
|
+
declare function Server({
|
|
28
|
+
name,
|
|
29
|
+
serverName,
|
|
30
|
+
serverVersion,
|
|
31
|
+
operations
|
|
32
|
+
}: Props): any;
|
|
33
|
+
//#endregion
|
|
29
34
|
export { Server };
|
|
35
|
+
//# sourceMappingURL=components.d.cts.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
1
|
+
import { File, OperationSchemas } from "./OperationGenerator-D1X1O_-A.js";
|
|
3
2
|
|
|
3
|
+
//#region src/components/Server.d.ts
|
|
4
4
|
type Props = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
serverName: string;
|
|
7
|
+
serverVersion: string;
|
|
8
|
+
operations: Array<{
|
|
9
|
+
tool: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
mcp: {
|
|
14
|
+
name: string;
|
|
15
|
+
file: File;
|
|
16
|
+
};
|
|
17
|
+
zod: {
|
|
18
|
+
name: string;
|
|
19
|
+
file: File;
|
|
20
|
+
schemas: OperationSchemas;
|
|
21
|
+
};
|
|
22
|
+
type: {
|
|
23
|
+
schemas: OperationSchemas;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
26
|
};
|
|
27
|
-
declare function Server({
|
|
28
|
-
|
|
27
|
+
declare function Server({
|
|
28
|
+
name,
|
|
29
|
+
serverName,
|
|
30
|
+
serverVersion,
|
|
31
|
+
operations
|
|
32
|
+
}: Props): any;
|
|
33
|
+
//#endregion
|
|
29
34
|
export { Server };
|
|
35
|
+
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Server } from "./Server-BX80OVzu.js";
|
|
2
|
+
|
|
3
|
+
export { Server };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Server } from "./Server-BX80OVzu.js";
|
|
2
|
+
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
3
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
+
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
5
|
+
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
6
|
+
import { File, useApp } from "@kubb/react";
|
|
7
|
+
import { Client } from "@kubb/plugin-client/components";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
9
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
10
|
+
|
|
11
|
+
//#region src/generators/mcpGenerator.tsx
|
|
12
|
+
const mcpGenerator = createReactGenerator({
|
|
13
|
+
name: "mcp",
|
|
14
|
+
Operation({ operation }) {
|
|
15
|
+
const { plugin: { options } } = useApp();
|
|
16
|
+
const oas = useOas();
|
|
17
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
18
|
+
const mcp = {
|
|
19
|
+
name: getName(operation, {
|
|
20
|
+
type: "function",
|
|
21
|
+
suffix: "handler"
|
|
22
|
+
}),
|
|
23
|
+
file: getFile(operation)
|
|
24
|
+
};
|
|
25
|
+
const type = {
|
|
26
|
+
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
27
|
+
schemas: getSchemas(operation, {
|
|
28
|
+
pluginKey: [pluginTsName],
|
|
29
|
+
type: "type"
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
33
|
+
baseName: mcp.file.baseName,
|
|
34
|
+
path: mcp.file.path,
|
|
35
|
+
meta: mcp.file.meta,
|
|
36
|
+
banner: getBanner({
|
|
37
|
+
oas,
|
|
38
|
+
output: options.output
|
|
39
|
+
}),
|
|
40
|
+
footer: getFooter({
|
|
41
|
+
oas,
|
|
42
|
+
output: options.output
|
|
43
|
+
}),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
46
|
+
name: ["CallToolResult"],
|
|
47
|
+
path: "@modelcontextprotocol/sdk/types",
|
|
48
|
+
isTypeOnly: true
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
51
|
+
name: "fetch",
|
|
52
|
+
path: options.client.importPath
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
55
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
56
|
+
path: options.client.importPath,
|
|
57
|
+
isTypeOnly: true
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
60
|
+
name: [
|
|
61
|
+
type.schemas.request?.name,
|
|
62
|
+
type.schemas.response.name,
|
|
63
|
+
type.schemas.pathParams?.name,
|
|
64
|
+
type.schemas.queryParams?.name,
|
|
65
|
+
type.schemas.headerParams?.name,
|
|
66
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
67
|
+
].filter(Boolean),
|
|
68
|
+
root: mcp.file.path,
|
|
69
|
+
path: type.file.path,
|
|
70
|
+
isTypeOnly: true
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsxs(Client, {
|
|
73
|
+
name: mcp.name,
|
|
74
|
+
isConfigurable: false,
|
|
75
|
+
returnType: "Promise<CallToolResult>",
|
|
76
|
+
baseURL: options.client.baseURL,
|
|
77
|
+
operation,
|
|
78
|
+
typeSchemas: type.schemas,
|
|
79
|
+
zodSchemas: void 0,
|
|
80
|
+
dataReturnType: options.client.dataReturnType,
|
|
81
|
+
paramsType: "object",
|
|
82
|
+
paramsCasing: "camelcase",
|
|
83
|
+
pathParamsType: "object",
|
|
84
|
+
parser: "client",
|
|
85
|
+
children: [options.client.dataReturnType === "data" && `return {
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'text',
|
|
89
|
+
text: JSON.stringify(res.data)
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}`, options.client.dataReturnType === "full" && `return {
|
|
93
|
+
content: [
|
|
94
|
+
{
|
|
95
|
+
type: 'text',
|
|
96
|
+
text: JSON.stringify(res)
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}`]
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/generators/serverGenerator.tsx
|
|
108
|
+
const serverGenerator = createReactGenerator({
|
|
109
|
+
name: "operations",
|
|
110
|
+
Operations({ operations, options }) {
|
|
111
|
+
const { pluginManager, plugin } = useApp();
|
|
112
|
+
const oas = useOas();
|
|
113
|
+
const { getFile, getName, getSchemas } = useOperationManager();
|
|
114
|
+
const name = "server";
|
|
115
|
+
const file = pluginManager.getFile({
|
|
116
|
+
name,
|
|
117
|
+
extname: ".ts",
|
|
118
|
+
pluginKey: plugin.key
|
|
119
|
+
});
|
|
120
|
+
const jsonFile = pluginManager.getFile({
|
|
121
|
+
name: ".mcp",
|
|
122
|
+
extname: ".json",
|
|
123
|
+
pluginKey: plugin.key
|
|
124
|
+
});
|
|
125
|
+
const operationsMapped = operations.map((operation) => {
|
|
126
|
+
return {
|
|
127
|
+
tool: {
|
|
128
|
+
name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,
|
|
129
|
+
description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`
|
|
130
|
+
},
|
|
131
|
+
mcp: {
|
|
132
|
+
name: getName(operation, {
|
|
133
|
+
type: "function",
|
|
134
|
+
suffix: "handler"
|
|
135
|
+
}),
|
|
136
|
+
file: getFile(operation)
|
|
137
|
+
},
|
|
138
|
+
zod: {
|
|
139
|
+
name: getName(operation, {
|
|
140
|
+
type: "function",
|
|
141
|
+
pluginKey: [pluginZodName]
|
|
142
|
+
}),
|
|
143
|
+
schemas: getSchemas(operation, {
|
|
144
|
+
pluginKey: [pluginZodName],
|
|
145
|
+
type: "function"
|
|
146
|
+
}),
|
|
147
|
+
file: getFile(operation, { pluginKey: [pluginZodName] })
|
|
148
|
+
},
|
|
149
|
+
type: { schemas: getSchemas(operation, {
|
|
150
|
+
pluginKey: [pluginTsName],
|
|
151
|
+
type: "type"
|
|
152
|
+
}) }
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
const imports = operationsMapped.flatMap(({ mcp, zod }) => {
|
|
156
|
+
return [/* @__PURE__ */ jsx(File.Import, {
|
|
157
|
+
name: [mcp.name],
|
|
158
|
+
root: file.path,
|
|
159
|
+
path: mcp.file.path
|
|
160
|
+
}, mcp.name), /* @__PURE__ */ jsx(File.Import, {
|
|
161
|
+
name: [
|
|
162
|
+
zod.schemas.request?.name,
|
|
163
|
+
zod.schemas.pathParams?.name,
|
|
164
|
+
zod.schemas.queryParams?.name,
|
|
165
|
+
zod.schemas.headerParams?.name
|
|
166
|
+
].filter(Boolean),
|
|
167
|
+
root: file.path,
|
|
168
|
+
path: zod.file.path
|
|
169
|
+
}, zod.name)];
|
|
170
|
+
});
|
|
171
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(File, {
|
|
172
|
+
baseName: file.baseName,
|
|
173
|
+
path: file.path,
|
|
174
|
+
meta: file.meta,
|
|
175
|
+
banner: getBanner({
|
|
176
|
+
oas,
|
|
177
|
+
output: options.output,
|
|
178
|
+
config: pluginManager.config
|
|
179
|
+
}),
|
|
180
|
+
footer: getFooter({
|
|
181
|
+
oas,
|
|
182
|
+
output: options.output
|
|
183
|
+
}),
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
186
|
+
name: ["McpServer"],
|
|
187
|
+
path: "@modelcontextprotocol/sdk/server/mcp"
|
|
188
|
+
}),
|
|
189
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
190
|
+
name: ["StdioServerTransport"],
|
|
191
|
+
path: "@modelcontextprotocol/sdk/server/stdio"
|
|
192
|
+
}),
|
|
193
|
+
imports,
|
|
194
|
+
/* @__PURE__ */ jsx(Server, {
|
|
195
|
+
name,
|
|
196
|
+
serverName: oas.api.info?.title,
|
|
197
|
+
serverVersion: oas.getVersion(),
|
|
198
|
+
operations: operationsMapped
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
}), /* @__PURE__ */ jsx(File, {
|
|
202
|
+
baseName: jsonFile.baseName,
|
|
203
|
+
path: jsonFile.path,
|
|
204
|
+
meta: jsonFile.meta,
|
|
205
|
+
children: /* @__PURE__ */ jsx(File.Source, {
|
|
206
|
+
name,
|
|
207
|
+
children: `
|
|
208
|
+
{
|
|
209
|
+
"mcpServers": {
|
|
210
|
+
"${oas.api.info?.title || "server"}": {
|
|
211
|
+
"type": "stdio",
|
|
212
|
+
"command": "npx",
|
|
213
|
+
"args": ["tsx", "${file.path}"]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
`
|
|
218
|
+
})
|
|
219
|
+
})] });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
export { mcpGenerator, serverGenerator };
|
|
225
|
+
//# sourceMappingURL=generators-CFdUB1k-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CFdUB1k-.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport type { PluginMcp } from '../types'\nimport { Client } from '@kubb/plugin-client/components'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const {\n plugin: { options },\n } = useApp<PluginMcp>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType}\n paramsType={'object'}\n paramsCasing={'camelcase'}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ]\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ]\n }`}\n </Client>\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const { pluginManager, plugin } = useApp<PluginMcp>()\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager()\n\n const name = 'server'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey: plugin.key })\n\n const jsonFile = pluginManager.getFile({ name: '.mcp', extname: '.json', pluginKey: plugin.key })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginKey: [pluginZodName],\n }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n },\n type: {\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[zod.schemas.request?.name, zod.schemas.pathParams?.name, zod.schemas.queryParams?.name, zod.schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server name={name} serverName={oas.api.info?.title} serverVersion={oas.getVersion()} operations={operationsMapped} />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {\n \"mcpServers\": {\n \"${oas.api.info?.title || 'server'}\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"tsx\", \"${file.path}\"]\n }\n }\n }\n `}\n </File.Source>\n </File>\n </>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,EAAE;EACvB,MAAM,EACJ,QAAQ,EAAE,SAAS,EACpB,GAAG,QAAmB;EACvB,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,SAAS,GAAG,qBAAqB;EAE9D,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;GAAW,EAAC;GACjE,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,YAAa,EAAE,EAAC;GACvD,SAAS,WAAW,WAAW;IAAE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