@kubb/plugin-mcp 4.21.2 → 4.22.0
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/components.d.cts +2 -1
- package/dist/components.d.ts +1 -1
- package/dist/{generators-DOGoAPGT.cjs → generators-BLuJpiEp.cjs} +11 -3
- package/dist/generators-BLuJpiEp.cjs.map +1 -0
- package/dist/{generators-CrC1R2wh.js → generators-CIGzlv3P.js} +11 -3
- package/dist/generators-CIGzlv3P.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +458 -2
- package/dist/generators.d.ts +457 -2
- package/dist/generators.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/types-Bg_tbyZc.d.ts +64 -0
- package/dist/types-Cb1Tkjj0.d.cts +64 -0
- package/package.json +7 -7
- package/src/generators/mcpGenerator.tsx +2 -2
- package/dist/generators-CrC1R2wh.js.map +0 -1
- package/dist/generators-DOGoAPGT.cjs.map +0 -1
- package/dist/index-DNBGPN7Z.d.ts +0 -548
- package/dist/index-RsNfvceH.d.cts +0 -549
- package/dist/types-BtFvu11q.d.ts +0 -196
- package/dist/types-Bw-588-z.d.cts +0 -195
package/dist/components.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __name } from "./chunk-DHUGjThq.cjs";
|
|
2
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
|
+
import { OperationSchemas } from "@kubb/plugin-oas";
|
|
3
4
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
4
5
|
|
|
5
6
|
//#region src/components/Server.d.ts
|
package/dist/components.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-eQyhnF5A.js";
|
|
2
|
-
import {
|
|
2
|
+
import { OperationSchemas } from "@kubb/plugin-oas";
|
|
3
3
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
4
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
5
|
|
|
@@ -51,7 +51,11 @@ const mcpGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
51
51
|
path: options.client.importPath
|
|
52
52
|
}),
|
|
53
53
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
54
|
-
name: [
|
|
54
|
+
name: [
|
|
55
|
+
"Client",
|
|
56
|
+
"RequestConfig",
|
|
57
|
+
"ResponseErrorConfig"
|
|
58
|
+
],
|
|
55
59
|
path: options.client.importPath,
|
|
56
60
|
isTypeOnly: true
|
|
57
61
|
}),
|
|
@@ -67,7 +71,11 @@ const mcpGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
67
71
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
68
72
|
}),
|
|
69
73
|
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
70
|
-
name: [
|
|
74
|
+
name: [
|
|
75
|
+
"Client",
|
|
76
|
+
"RequestConfig",
|
|
77
|
+
"ResponseErrorConfig"
|
|
78
|
+
],
|
|
71
79
|
root: mcp.file.path,
|
|
72
80
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
73
81
|
isTypeOnly: true
|
|
@@ -268,4 +276,4 @@ Object.defineProperty(exports, 'serverGenerator', {
|
|
|
268
276
|
return serverGenerator;
|
|
269
277
|
}
|
|
270
278
|
});
|
|
271
|
-
//# sourceMappingURL=generators-
|
|
279
|
+
//# sourceMappingURL=generators-BLuJpiEp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-BLuJpiEp.cjs","names":["pluginTsName","File","path","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ config, operation, generator, plugin }) {\n const { options } = plugin\n const oas = useOas()\n\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mcp.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n <File.Import name={['buildFormData']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} 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 || 'data'}\n paramsType={'object'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\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 { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n const { options } = plugin\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager(generator)\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\n name={name}\n serverName={oas.api.info?.title}\n serverVersion={oas.getVersion()}\n paramsCasing={options.paramsCasing}\n operations={operationsMapped}\n />\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":";;;;;;;;;;;;;;A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,IAAI,KAAK;MAHV,IAAI,KAIT,CACH;IACD;AAEF,SACE,+GACE,yDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,8CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChF,8CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAElD,wDAACA,wBAAK;KAAO,MAAM,CAAC,YAAY;KAAE,MAAM;MAA0C;IAClF,wDAACA,wBAAK;KAAO,MAAM,CAAC,uBAAuB;KAAE,MAAM;MAA4C;IAE9F;IACD,wDAACC;KACO;KACN,YAAY,IAAI,IAAI,MAAM;KAC1B,eAAe,IAAI,YAAY;KAC/B,cAAc,QAAQ;KACtB,YAAY;MACZ;;IACG,EAEP,wDAACD;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,wDAACA,wBAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
|
@@ -51,7 +51,11 @@ const mcpGenerator = createReactGenerator({
|
|
|
51
51
|
path: options.client.importPath
|
|
52
52
|
}),
|
|
53
53
|
/* @__PURE__ */ jsx(File.Import, {
|
|
54
|
-
name: [
|
|
54
|
+
name: [
|
|
55
|
+
"Client",
|
|
56
|
+
"RequestConfig",
|
|
57
|
+
"ResponseErrorConfig"
|
|
58
|
+
],
|
|
55
59
|
path: options.client.importPath,
|
|
56
60
|
isTypeOnly: true
|
|
57
61
|
}),
|
|
@@ -67,7 +71,11 @@ const mcpGenerator = createReactGenerator({
|
|
|
67
71
|
path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
68
72
|
}),
|
|
69
73
|
/* @__PURE__ */ jsx(File.Import, {
|
|
70
|
-
name: [
|
|
74
|
+
name: [
|
|
75
|
+
"Client",
|
|
76
|
+
"RequestConfig",
|
|
77
|
+
"ResponseErrorConfig"
|
|
78
|
+
],
|
|
71
79
|
root: mcp.file.path,
|
|
72
80
|
path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
73
81
|
isTypeOnly: true
|
|
@@ -257,4 +265,4 @@ const serverGenerator = createReactGenerator({
|
|
|
257
265
|
|
|
258
266
|
//#endregion
|
|
259
267
|
export { mcpGenerator as n, serverGenerator as t };
|
|
260
|
-
//# sourceMappingURL=generators-
|
|
268
|
+
//# sourceMappingURL=generators-CIGzlv3P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CIGzlv3P.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ config, operation, generator, plugin }) {\n const { options } = plugin\n const oas = useOas()\n\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mcp.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n <File.Import name={['buildFormData']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} 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 || 'data'}\n paramsType={'object'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\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 { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n const { options } = plugin\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager(generator)\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\n name={name}\n serverName={oas.api.info?.title}\n serverVersion={oas.getVersion()}\n paramsCasing={options.paramsCasing}\n operations={operationsMapped}\n />\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":";;;;;;;;;;;;;;AASA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EAAE,YAAY;EACpB,MAAM,MAAM,QAAQ;EAEpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,UAAU;EAEvE,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAW,CAAC;GACjE,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,IAAI,KAAK;GACnB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GACf,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;GAClD,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAEjD,QAAQ,OAAO,aACd;KACE,oBAAC,KAAK;MAAO,MAAM;MAAS,MAAM,QAAQ,OAAO;OAAc;KAC/D,oBAAC,KAAK;MAAO,MAAM;OAAC;OAAU;OAAiB;OAAsB;M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|
1
|
-
import {
|
|
2
|
-
import { n as PluginMcp } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-DHUGjThq.cjs";
|
|
2
|
+
import { n as PluginMcp } from "./types-Cb1Tkjj0.cjs";
|
|
3
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
|
+
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
|
+
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
6
|
+
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
7
|
+
import { AsyncEventEmitter } from "@kubb/core/utils";
|
|
8
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
3
9
|
|
|
10
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
11
|
+
type GetOasOptions = {
|
|
12
|
+
validate?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type Context$2 = {
|
|
15
|
+
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
16
|
+
getBaseURL(): Promise<string | undefined>;
|
|
17
|
+
};
|
|
18
|
+
declare global {
|
|
19
|
+
namespace Kubb {
|
|
20
|
+
interface PluginContext extends Context$2 {}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
25
|
+
* @example import { Pet } from './Pet'
|
|
26
|
+
*
|
|
27
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
28
|
+
*
|
|
29
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
30
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
31
|
+
*/
|
|
32
|
+
type Ref = {
|
|
33
|
+
propertyName: string;
|
|
34
|
+
originalName: string;
|
|
35
|
+
path: KubbFile.Path;
|
|
36
|
+
pluginKey?: Plugin['key'];
|
|
37
|
+
};
|
|
38
|
+
type Refs = Record<string, Ref>;
|
|
39
|
+
type OperationSchema = {
|
|
40
|
+
/**
|
|
41
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
42
|
+
*/
|
|
43
|
+
name: string;
|
|
44
|
+
schema: SchemaObject;
|
|
45
|
+
operation?: Operation;
|
|
46
|
+
/**
|
|
47
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
48
|
+
*/
|
|
49
|
+
operationName: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
statusCode?: number;
|
|
52
|
+
keys?: string[];
|
|
53
|
+
keysToOmit?: string[];
|
|
54
|
+
withData?: boolean;
|
|
55
|
+
};
|
|
56
|
+
type OperationSchemas = {
|
|
57
|
+
pathParams?: OperationSchema & {
|
|
58
|
+
keysToOmit?: never;
|
|
59
|
+
};
|
|
60
|
+
queryParams?: OperationSchema & {
|
|
61
|
+
keysToOmit?: never;
|
|
62
|
+
};
|
|
63
|
+
headerParams?: OperationSchema & {
|
|
64
|
+
keysToOmit?: never;
|
|
65
|
+
};
|
|
66
|
+
request?: OperationSchema;
|
|
67
|
+
response: OperationSchema;
|
|
68
|
+
responses: Array<OperationSchema>;
|
|
69
|
+
statusCodes?: Array<OperationSchema>;
|
|
70
|
+
errors?: Array<OperationSchema>;
|
|
71
|
+
};
|
|
72
|
+
type ByTag = {
|
|
73
|
+
type: 'tag';
|
|
74
|
+
pattern: string | RegExp;
|
|
75
|
+
};
|
|
76
|
+
type ByOperationId = {
|
|
77
|
+
type: 'operationId';
|
|
78
|
+
pattern: string | RegExp;
|
|
79
|
+
};
|
|
80
|
+
type ByPath = {
|
|
81
|
+
type: 'path';
|
|
82
|
+
pattern: string | RegExp;
|
|
83
|
+
};
|
|
84
|
+
type ByMethod = {
|
|
85
|
+
type: 'method';
|
|
86
|
+
pattern: HttpMethod | RegExp;
|
|
87
|
+
};
|
|
88
|
+
type BySchemaName = {
|
|
89
|
+
type: 'schemaName';
|
|
90
|
+
pattern: string | RegExp;
|
|
91
|
+
};
|
|
92
|
+
type ByContentType = {
|
|
93
|
+
type: 'contentType';
|
|
94
|
+
pattern: string | RegExp;
|
|
95
|
+
};
|
|
96
|
+
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
99
|
+
options: Partial<TOptions>;
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
103
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
104
|
+
fabric: Fabric;
|
|
105
|
+
oas: Oas;
|
|
106
|
+
exclude: Array<Exclude> | undefined;
|
|
107
|
+
include: Array<Include> | undefined;
|
|
108
|
+
override: Array<Override<TOptions>> | undefined;
|
|
109
|
+
contentType: contentType | undefined;
|
|
110
|
+
pluginManager: PluginManager;
|
|
111
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
112
|
+
/**
|
|
113
|
+
* Current plugin
|
|
114
|
+
*/
|
|
115
|
+
plugin: Plugin<TPluginOptions>;
|
|
116
|
+
mode: KubbFile.Mode;
|
|
117
|
+
UNSTABLE_NAMING?: true;
|
|
118
|
+
};
|
|
119
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
120
|
+
#private;
|
|
121
|
+
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
122
|
+
getSchemas(operation: Operation, {
|
|
123
|
+
resolveName
|
|
124
|
+
}?: {
|
|
125
|
+
resolveName?: (name: string) => string;
|
|
126
|
+
}): OperationSchemas;
|
|
127
|
+
getOperations(): Promise<Array<{
|
|
128
|
+
path: string;
|
|
129
|
+
method: HttpMethod;
|
|
130
|
+
operation: Operation;
|
|
131
|
+
}>>;
|
|
132
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
136
|
+
type SchemaKeywordMapper = {
|
|
137
|
+
object: {
|
|
138
|
+
keyword: 'object';
|
|
139
|
+
args: {
|
|
140
|
+
properties: {
|
|
141
|
+
[x: string]: Schema[];
|
|
142
|
+
};
|
|
143
|
+
additionalProperties: Schema[];
|
|
144
|
+
patternProperties?: Record<string, Schema[]>;
|
|
145
|
+
strict?: boolean;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
url: {
|
|
149
|
+
keyword: 'url';
|
|
150
|
+
};
|
|
151
|
+
readOnly: {
|
|
152
|
+
keyword: 'readOnly';
|
|
153
|
+
};
|
|
154
|
+
writeOnly: {
|
|
155
|
+
keyword: 'writeOnly';
|
|
156
|
+
};
|
|
157
|
+
uuid: {
|
|
158
|
+
keyword: 'uuid';
|
|
159
|
+
};
|
|
160
|
+
email: {
|
|
161
|
+
keyword: 'email';
|
|
162
|
+
};
|
|
163
|
+
firstName: {
|
|
164
|
+
keyword: 'firstName';
|
|
165
|
+
};
|
|
166
|
+
lastName: {
|
|
167
|
+
keyword: 'lastName';
|
|
168
|
+
};
|
|
169
|
+
phone: {
|
|
170
|
+
keyword: 'phone';
|
|
171
|
+
};
|
|
172
|
+
password: {
|
|
173
|
+
keyword: 'password';
|
|
174
|
+
};
|
|
175
|
+
date: {
|
|
176
|
+
keyword: 'date';
|
|
177
|
+
args: {
|
|
178
|
+
type?: 'date' | 'string';
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
time: {
|
|
182
|
+
keyword: 'time';
|
|
183
|
+
args: {
|
|
184
|
+
type?: 'date' | 'string';
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
datetime: {
|
|
188
|
+
keyword: 'datetime';
|
|
189
|
+
args: {
|
|
190
|
+
offset?: boolean;
|
|
191
|
+
local?: boolean;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
tuple: {
|
|
195
|
+
keyword: 'tuple';
|
|
196
|
+
args: {
|
|
197
|
+
items: Schema[];
|
|
198
|
+
min?: number;
|
|
199
|
+
max?: number;
|
|
200
|
+
rest?: Schema;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
array: {
|
|
204
|
+
keyword: 'array';
|
|
205
|
+
args: {
|
|
206
|
+
items: Schema[];
|
|
207
|
+
min?: number;
|
|
208
|
+
max?: number;
|
|
209
|
+
unique?: boolean;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
enum: {
|
|
213
|
+
keyword: 'enum';
|
|
214
|
+
args: {
|
|
215
|
+
name: string;
|
|
216
|
+
typeName: string;
|
|
217
|
+
asConst: boolean;
|
|
218
|
+
items: Array<{
|
|
219
|
+
name: string | number;
|
|
220
|
+
format: 'string' | 'number' | 'boolean';
|
|
221
|
+
value?: string | number | boolean;
|
|
222
|
+
}>;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
and: {
|
|
226
|
+
keyword: 'and';
|
|
227
|
+
args: Schema[];
|
|
228
|
+
};
|
|
229
|
+
const: {
|
|
230
|
+
keyword: 'const';
|
|
231
|
+
args: {
|
|
232
|
+
name: string | number;
|
|
233
|
+
format: 'string' | 'number' | 'boolean';
|
|
234
|
+
value?: string | number | boolean;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
union: {
|
|
238
|
+
keyword: 'union';
|
|
239
|
+
args: Schema[];
|
|
240
|
+
};
|
|
241
|
+
ref: {
|
|
242
|
+
keyword: 'ref';
|
|
243
|
+
args: {
|
|
244
|
+
name: string;
|
|
245
|
+
$ref: string;
|
|
246
|
+
/**
|
|
247
|
+
* Full qualified path.
|
|
248
|
+
*/
|
|
249
|
+
path: KubbFile.Path;
|
|
250
|
+
/**
|
|
251
|
+
* When true `File.Import` is used.
|
|
252
|
+
* When false a reference is used inside the current file.
|
|
253
|
+
*/
|
|
254
|
+
isImportable: boolean;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
matches: {
|
|
258
|
+
keyword: 'matches';
|
|
259
|
+
args?: string;
|
|
260
|
+
};
|
|
261
|
+
boolean: {
|
|
262
|
+
keyword: 'boolean';
|
|
263
|
+
};
|
|
264
|
+
default: {
|
|
265
|
+
keyword: 'default';
|
|
266
|
+
args: string | number | boolean;
|
|
267
|
+
};
|
|
268
|
+
string: {
|
|
269
|
+
keyword: 'string';
|
|
270
|
+
};
|
|
271
|
+
integer: {
|
|
272
|
+
keyword: 'integer';
|
|
273
|
+
};
|
|
274
|
+
number: {
|
|
275
|
+
keyword: 'number';
|
|
276
|
+
};
|
|
277
|
+
max: {
|
|
278
|
+
keyword: 'max';
|
|
279
|
+
args: number;
|
|
280
|
+
};
|
|
281
|
+
min: {
|
|
282
|
+
keyword: 'min';
|
|
283
|
+
args: number;
|
|
284
|
+
};
|
|
285
|
+
exclusiveMaximum: {
|
|
286
|
+
keyword: 'exclusiveMaximum';
|
|
287
|
+
args: number;
|
|
288
|
+
};
|
|
289
|
+
exclusiveMinimum: {
|
|
290
|
+
keyword: 'exclusiveMinimum';
|
|
291
|
+
args: number;
|
|
292
|
+
};
|
|
293
|
+
describe: {
|
|
294
|
+
keyword: 'describe';
|
|
295
|
+
args: string;
|
|
296
|
+
};
|
|
297
|
+
example: {
|
|
298
|
+
keyword: 'example';
|
|
299
|
+
args: string;
|
|
300
|
+
};
|
|
301
|
+
deprecated: {
|
|
302
|
+
keyword: 'deprecated';
|
|
303
|
+
};
|
|
304
|
+
optional: {
|
|
305
|
+
keyword: 'optional';
|
|
306
|
+
};
|
|
307
|
+
undefined: {
|
|
308
|
+
keyword: 'undefined';
|
|
309
|
+
};
|
|
310
|
+
nullish: {
|
|
311
|
+
keyword: 'nullish';
|
|
312
|
+
};
|
|
313
|
+
nullable: {
|
|
314
|
+
keyword: 'nullable';
|
|
315
|
+
};
|
|
316
|
+
null: {
|
|
317
|
+
keyword: 'null';
|
|
318
|
+
};
|
|
319
|
+
any: {
|
|
320
|
+
keyword: 'any';
|
|
321
|
+
};
|
|
322
|
+
unknown: {
|
|
323
|
+
keyword: 'unknown';
|
|
324
|
+
};
|
|
325
|
+
void: {
|
|
326
|
+
keyword: 'void';
|
|
327
|
+
};
|
|
328
|
+
blob: {
|
|
329
|
+
keyword: 'blob';
|
|
330
|
+
};
|
|
331
|
+
schema: {
|
|
332
|
+
keyword: 'schema';
|
|
333
|
+
args: {
|
|
334
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
335
|
+
format?: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
name: {
|
|
339
|
+
keyword: 'name';
|
|
340
|
+
args: string;
|
|
341
|
+
};
|
|
342
|
+
catchall: {
|
|
343
|
+
keyword: 'catchall';
|
|
344
|
+
};
|
|
345
|
+
interface: {
|
|
346
|
+
keyword: 'interface';
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
type Schema = {
|
|
350
|
+
keyword: string;
|
|
351
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
354
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
355
|
+
fabric: Fabric;
|
|
356
|
+
oas: Oas;
|
|
357
|
+
pluginManager: PluginManager;
|
|
358
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
359
|
+
/**
|
|
360
|
+
* Current plugin
|
|
361
|
+
*/
|
|
362
|
+
plugin: Plugin<TPluginOptions>;
|
|
363
|
+
mode: KubbFile.Mode;
|
|
364
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
365
|
+
override: Array<Override<TOptions>> | undefined;
|
|
366
|
+
contentType?: contentType;
|
|
367
|
+
output?: string;
|
|
368
|
+
};
|
|
369
|
+
type SchemaGeneratorOptions = {
|
|
370
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
371
|
+
unknownType: 'any' | 'unknown' | 'void';
|
|
372
|
+
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
373
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
374
|
+
enumSuffix?: string;
|
|
375
|
+
/**
|
|
376
|
+
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
377
|
+
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
378
|
+
* @internal
|
|
379
|
+
*/
|
|
380
|
+
usedEnumNames?: Record<string, number>;
|
|
381
|
+
mapper?: Record<string, string>;
|
|
382
|
+
typed?: boolean;
|
|
383
|
+
transformers: {
|
|
384
|
+
/**
|
|
385
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
386
|
+
*/
|
|
387
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
388
|
+
/**
|
|
389
|
+
* Receive schema and name(propertyName) and return FakerMeta array
|
|
390
|
+
* TODO TODO add docs
|
|
391
|
+
* @beta
|
|
392
|
+
*/
|
|
393
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
type SchemaProps$1 = {
|
|
397
|
+
schema: SchemaObject | null;
|
|
398
|
+
name: string | null;
|
|
399
|
+
parentName: string | null;
|
|
400
|
+
rootName?: string | null;
|
|
401
|
+
};
|
|
402
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
403
|
+
#private;
|
|
404
|
+
refs: Refs;
|
|
405
|
+
/**
|
|
406
|
+
* Creates a type node from a given schema.
|
|
407
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
408
|
+
* optionally adds a union with null.
|
|
409
|
+
*/
|
|
410
|
+
parse(props: SchemaProps$1): Schema[];
|
|
411
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
412
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
413
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
414
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
415
|
+
}
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
418
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
419
|
+
name: string;
|
|
420
|
+
type: 'core';
|
|
421
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
422
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
423
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
424
|
+
};
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
427
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
428
|
+
config: Config;
|
|
429
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
430
|
+
plugin: Plugin<TOptions>;
|
|
431
|
+
operations: Array<Operation>;
|
|
432
|
+
};
|
|
433
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
434
|
+
config: Config;
|
|
435
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
436
|
+
plugin: Plugin<TOptions>;
|
|
437
|
+
operation: Operation;
|
|
438
|
+
};
|
|
439
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
440
|
+
config: Config;
|
|
441
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
442
|
+
plugin: Plugin<TOptions>;
|
|
443
|
+
schema: {
|
|
444
|
+
name: string;
|
|
445
|
+
tree: Array<Schema>;
|
|
446
|
+
value: SchemaObject;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
452
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
453
|
+
name: string;
|
|
454
|
+
type: 'react';
|
|
455
|
+
Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
|
|
456
|
+
Operation: (props: OperationProps<TOptions>) => FabricReactNode;
|
|
457
|
+
Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
|
|
458
|
+
};
|
|
459
|
+
//#endregion
|
|
4
460
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
461
|
declare const mcpGenerator: ReactGenerator<PluginMcp>;
|
|
6
462
|
//#endregion
|