@kubb/plugin-mcp 5.0.0-beta.56 → 5.0.0-beta.73
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/README.md +2 -2
- package/dist/index.cjs +298 -262
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -119
- package/dist/index.js +298 -261
- package/dist/index.js.map +1 -1
- package/package.json +10 -11
- package/src/components/McpHandler.tsx +0 -157
- package/src/components/Server.tsx +0 -159
- package/src/generators/mcpGenerator.tsx +0 -89
- package/src/generators/serverGenerator.tsx +0 -149
- package/src/index.ts +0 -11
- package/src/plugin.ts +0 -142
- package/src/resolvers/resolverMcp.ts +0 -35
- package/src/types.ts +0 -90
- package/src/utils.ts +0 -48
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -25,17 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
27
|
let node_path = require("node:path");
|
|
28
|
-
|
|
29
|
-
node_path = __toESM(node_path);
|
|
28
|
+
node_path = __toESM(node_path, 1);
|
|
30
29
|
let _kubb_core = require("@kubb/core");
|
|
31
|
-
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
32
30
|
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
33
31
|
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
32
|
+
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
34
33
|
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
35
|
-
let _kubb_plugin_client = require("@kubb/plugin-client");
|
|
36
|
-
let _kubb_plugin_client_templates_clients_axios_source = require("@kubb/plugin-client/templates/clients/axios.source");
|
|
37
|
-
let _kubb_plugin_client_templates_clients_fetch_source = require("@kubb/plugin-client/templates/clients/fetch.source");
|
|
38
|
-
let _kubb_plugin_client_templates_config_source = require("@kubb/plugin-client/templates/config.source");
|
|
39
34
|
//#region ../../internals/utils/src/casing.ts
|
|
40
35
|
/**
|
|
41
36
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -248,6 +243,22 @@ var Url = class Url {
|
|
|
248
243
|
return `\`${prefix ?? ""}${result}\``;
|
|
249
244
|
}
|
|
250
245
|
/**
|
|
246
|
+
* Converts an OpenAPI/Swagger path to a template literal that reads each parameter off the
|
|
247
|
+
* grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``. Parameter
|
|
248
|
+
* names are camelCased to match the generated `path` type, and `prefix` is prepended inside the
|
|
249
|
+
* literal. Shared by the client and cypress generators that pass a grouped `path` object.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'
|
|
253
|
+
*/
|
|
254
|
+
static toGroupedTemplateString(path, { prefix } = {}) {
|
|
255
|
+
return Url.toTemplateString(path, {
|
|
256
|
+
prefix,
|
|
257
|
+
casing: "camelcase",
|
|
258
|
+
replacer: (name) => `path.${name}`
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
251
262
|
* Returns the path and its extracted params as a structured `URLObject`, or as a stringified
|
|
252
263
|
* expression when `stringify` is set.
|
|
253
264
|
*
|
|
@@ -275,13 +286,121 @@ var Url = class Url {
|
|
|
275
286
|
}
|
|
276
287
|
};
|
|
277
288
|
//#endregion
|
|
289
|
+
//#region ../../internals/shared/src/params.ts
|
|
290
|
+
const caseParamsCache = /* @__PURE__ */ new WeakMap();
|
|
291
|
+
/**
|
|
292
|
+
* Applies camelCase to parameter names and returns a new array without mutating the input.
|
|
293
|
+
*
|
|
294
|
+
* Run it before handing parameters to schema builders so output property keys get the right casing
|
|
295
|
+
* while `OperationNode.parameters` stays intact for other consumers. When `casing` is unset, the
|
|
296
|
+
* original array is returned unchanged. Results are cached per input array.
|
|
297
|
+
*/
|
|
298
|
+
function caseParams(params, casing) {
|
|
299
|
+
if (!casing) return params;
|
|
300
|
+
const cached = caseParamsCache.get(params);
|
|
301
|
+
if (cached) return cached;
|
|
302
|
+
const result = params.map((param) => ({
|
|
303
|
+
...param,
|
|
304
|
+
name: camelCase(param.name)
|
|
305
|
+
}));
|
|
306
|
+
caseParamsCache.set(params, result);
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
278
310
|
//#region ../../internals/shared/src/operation.ts
|
|
311
|
+
/**
|
|
312
|
+
* Builds the `ResolverFileParams` every operation generator passes to
|
|
313
|
+
* `resolver.resolveFile`: a file named `name`, tagged by the operation's first
|
|
314
|
+
* tag (or `'default'`), at the operation's path. Centralizes the entry object
|
|
315
|
+
* that was repeated at dozens of call sites across the client and query plugins.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* resolver.resolveFile(operationFileEntry(node, node.operationId), { root, output, group })
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
function operationFileEntry(node, name, extname = ".ts") {
|
|
323
|
+
return {
|
|
324
|
+
name,
|
|
325
|
+
extname,
|
|
326
|
+
tag: node.tags[0] ?? "default",
|
|
327
|
+
path: node.path
|
|
328
|
+
};
|
|
329
|
+
}
|
|
279
330
|
function getOperationLink(node, link) {
|
|
280
331
|
if (!link) return null;
|
|
281
332
|
if (typeof link === "function") return link(node) ?? null;
|
|
282
333
|
if (link === "urlPath") return node.path ? `{@link ${Url.toPath(node.path)}}` : null;
|
|
283
334
|
return node.path ? `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}` : null;
|
|
284
335
|
}
|
|
336
|
+
function getContentTypeInfo(node) {
|
|
337
|
+
const contentTypes = node.requestBody?.content?.map((e) => e.contentType) ?? [];
|
|
338
|
+
const isMultipleContentTypes = contentTypes.length > 1;
|
|
339
|
+
return {
|
|
340
|
+
contentTypes,
|
|
341
|
+
isMultipleContentTypes,
|
|
342
|
+
contentTypeUnion: isMultipleContentTypes ? contentTypes.map((ct) => JSON.stringify(ct)).join(" | ") : "",
|
|
343
|
+
defaultContentType: contentTypes[0] ?? "application/json",
|
|
344
|
+
hasFormData: contentTypes.some((ct) => ct === "multipart/form-data")
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function buildRequestConfigType(node) {
|
|
348
|
+
const { isMultipleContentTypes, contentTypeUnion } = getContentTypeInfo(node);
|
|
349
|
+
const configType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`;
|
|
350
|
+
const contentTypeProp = isMultipleContentTypes ? `contentType?: ${contentTypeUnion}` : null;
|
|
351
|
+
return contentTypeProp ? `${configType} & { ${contentTypeProp} }` : configType;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Which of the grouped request options an operation carries.
|
|
355
|
+
*/
|
|
356
|
+
function getRequestGroups(node) {
|
|
357
|
+
const { path, query, header } = getOperationParameters(node);
|
|
358
|
+
return {
|
|
359
|
+
path: path.length > 0,
|
|
360
|
+
query: query.length > 0,
|
|
361
|
+
body: Boolean(node.requestBody?.content?.[0]?.schema),
|
|
362
|
+
headers: header.length > 0
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Resolves which grouped request options an operation carries together with whether each group
|
|
367
|
+
* holds a required member. The grouped parameter stays optional only when nothing inside it is
|
|
368
|
+
* required, matching the generated `RequestConfig` type.
|
|
369
|
+
*/
|
|
370
|
+
function getRequestGroupOptionality(node) {
|
|
371
|
+
const groups = getRequestGroups(node);
|
|
372
|
+
const { path, query, header } = getOperationParameters(node);
|
|
373
|
+
const hasRequiredPath = path.some((param) => param.required);
|
|
374
|
+
const hasRequiredQuery = query.some((param) => param.required);
|
|
375
|
+
const hasRequiredHeader = header.some((param) => param.required);
|
|
376
|
+
return {
|
|
377
|
+
groups,
|
|
378
|
+
hasRequiredPath,
|
|
379
|
+
hasRequiredQuery,
|
|
380
|
+
hasRequiredHeader,
|
|
381
|
+
isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !groups.body
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Builds the grouped `{ path, query, body, headers }` parameter for a generated client
|
|
386
|
+
* function, typed from the operation's `RequestConfig` (minus `url`). Only the groups the
|
|
387
|
+
* operation actually has are destructured. The trailing `config` parameter carries the
|
|
388
|
+
* runtime `RequestConfig` overrides plus `client`.
|
|
389
|
+
*/
|
|
390
|
+
function buildRequestParamsSignature(node, resolver, options = {}) {
|
|
391
|
+
const { isConfigurable = true } = options;
|
|
392
|
+
const { groups, isOptional } = getRequestGroupOptionality(node);
|
|
393
|
+
const names = [
|
|
394
|
+
"path",
|
|
395
|
+
"query",
|
|
396
|
+
"body",
|
|
397
|
+
"headers"
|
|
398
|
+
].filter((key) => groups[key]);
|
|
399
|
+
return {
|
|
400
|
+
signature: [names.length > 0 ? `{ ${names.join(", ")} }: ${resolver.resolveRequestConfigName(node)}${isOptional ? " = {}" : ""}` : null, isConfigurable ? `config: ${buildRequestConfigType(node)} = {}` : null].filter(Boolean).join(", "),
|
|
401
|
+
groups
|
|
402
|
+
};
|
|
403
|
+
}
|
|
285
404
|
function buildOperationComments(node, options = {}) {
|
|
286
405
|
const { link = "pathTemplate", linkPosition = "afterDeprecated", splitLines = false } = options;
|
|
287
406
|
const linkComment = getOperationLink(node, link);
|
|
@@ -300,7 +419,7 @@ function buildOperationComments(node, options = {}) {
|
|
|
300
419
|
return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
|
|
301
420
|
}
|
|
302
421
|
function getOperationParameters(node, options = {}) {
|
|
303
|
-
const params =
|
|
422
|
+
const params = caseParams(node.parameters, options.paramsCasing === "original" ? void 0 : "camelcase");
|
|
304
423
|
return {
|
|
305
424
|
path: params.filter((param) => param.in === "path"),
|
|
306
425
|
query: params.filter((param) => param.in === "query"),
|
|
@@ -316,48 +435,6 @@ function isSuccessStatusCode(statusCode) {
|
|
|
316
435
|
const code = getStatusCodeNumber(statusCode);
|
|
317
436
|
return code !== null && code >= 200 && code < 300;
|
|
318
437
|
}
|
|
319
|
-
function isErrorStatusCode(statusCode) {
|
|
320
|
-
const code = getStatusCodeNumber(statusCode);
|
|
321
|
-
return code !== null && code >= 400;
|
|
322
|
-
}
|
|
323
|
-
function resolveErrorNames(node, resolver) {
|
|
324
|
-
return node.responses.filter((response) => isErrorStatusCode(response.statusCode)).map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
|
|
325
|
-
}
|
|
326
|
-
function resolveStatusCodeNames(node, resolver) {
|
|
327
|
-
return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
|
|
328
|
-
}
|
|
329
|
-
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
330
|
-
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
331
|
-
const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
|
|
332
|
-
let byResolver = typeNamesByResolver.get(resolver);
|
|
333
|
-
if (byResolver) {
|
|
334
|
-
const cached = byResolver.get(cacheKey);
|
|
335
|
-
if (cached) return cached;
|
|
336
|
-
} else {
|
|
337
|
-
byResolver = /* @__PURE__ */ new Map();
|
|
338
|
-
typeNamesByResolver.set(resolver, byResolver);
|
|
339
|
-
}
|
|
340
|
-
const { path, query, header } = getOperationParameters(node, { paramsCasing: options.paramsCasing });
|
|
341
|
-
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
342
|
-
const exclude = new Set(options.exclude ?? []);
|
|
343
|
-
const paramNames = [
|
|
344
|
-
...path.map((param) => resolver.resolvePathParamsName(node, param)),
|
|
345
|
-
...query.map((param) => resolver.resolveQueryParamsName(node, param)),
|
|
346
|
-
...header.map((param) => resolver.resolveHeaderParamsName(node, param))
|
|
347
|
-
];
|
|
348
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null, resolver.resolveResponseName(node)];
|
|
349
|
-
const result = (options.order === "body-response-first" ? [
|
|
350
|
-
...bodyAndResponseNames,
|
|
351
|
-
...paramNames,
|
|
352
|
-
...responseStatusNames
|
|
353
|
-
] : [
|
|
354
|
-
...paramNames,
|
|
355
|
-
...bodyAndResponseNames,
|
|
356
|
-
...responseStatusNames
|
|
357
|
-
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
358
|
-
byResolver.set(cacheKey, result);
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
438
|
function findSuccessStatusCode(responses) {
|
|
362
439
|
for (const response of responses) if (isSuccessStatusCode(response.statusCode)) return response.statusCode;
|
|
363
440
|
return null;
|
|
@@ -394,76 +471,19 @@ function createGroupConfig(group) {
|
|
|
394
471
|
};
|
|
395
472
|
}
|
|
396
473
|
//#endregion
|
|
397
|
-
//#region ../../internals/shared/src/params.ts
|
|
398
|
-
function buildParamsMapping(originalParams, mappedParams) {
|
|
399
|
-
const mapping = {};
|
|
400
|
-
let hasChanged = false;
|
|
401
|
-
originalParams.forEach((param, i) => {
|
|
402
|
-
const mappedName = mappedParams[i]?.name ?? param.name;
|
|
403
|
-
mapping[param.name] = mappedName;
|
|
404
|
-
if (param.name !== mappedName) hasChanged = true;
|
|
405
|
-
});
|
|
406
|
-
return hasChanged ? mapping : null;
|
|
407
|
-
}
|
|
408
|
-
function buildTransformedParamsMapping(params, transformName) {
|
|
409
|
-
if (!params.length) return null;
|
|
410
|
-
return buildParamsMapping(params, params.map((param) => ({
|
|
411
|
-
...param,
|
|
412
|
-
name: transformName(param.name)
|
|
413
|
-
})));
|
|
414
|
-
}
|
|
415
|
-
//#endregion
|
|
416
474
|
//#region src/components/McpHandler.tsx
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
function McpHandler({ name, node, resolver, baseURL, dataReturnType, paramsCasing }) {
|
|
475
|
+
const requestGroupOrder = [
|
|
476
|
+
"path",
|
|
477
|
+
"query",
|
|
478
|
+
"headers",
|
|
479
|
+
"body"
|
|
480
|
+
];
|
|
481
|
+
function McpHandler({ name, clientName, node, resolver }) {
|
|
425
482
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
426
|
-
const
|
|
427
|
-
const
|
|
428
|
-
const
|
|
429
|
-
const
|
|
430
|
-
const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
|
|
431
|
-
const responseName = resolver.resolveResponseName(node);
|
|
432
|
-
const errorResponses = node.responses.filter((r) => Number(r.statusCode) >= 400).map((r) => resolver.resolveResponseStatusName(node, r.statusCode));
|
|
433
|
-
const generics = [
|
|
434
|
-
responseName,
|
|
435
|
-
`ResponseErrorConfig<${errorResponses.length > 0 ? errorResponses.join(" | ") : "Error"}>`,
|
|
436
|
-
requestName || "unknown"
|
|
437
|
-
].filter(Boolean);
|
|
438
|
-
const paramsNode = _kubb_core.ast.createOperationParams(node, {
|
|
439
|
-
paramsType: "object",
|
|
440
|
-
pathParamsType: "inline",
|
|
441
|
-
resolver,
|
|
442
|
-
paramsCasing
|
|
443
|
-
});
|
|
444
|
-
const baseParamsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
445
|
-
const paramsSignature = baseParamsSignature ? `${baseParamsSignature}, request: RequestHandlerExtra<ServerRequest, ServerNotification>` : "request: RequestHandlerExtra<ServerRequest, ServerNotification>";
|
|
446
|
-
const pathParamsMapping = paramsCasing ? buildTransformedParamsMapping(originalPathParams, camelCase) : null;
|
|
447
|
-
const queryParamsMapping = paramsCasing ? buildTransformedParamsMapping(originalQueryParams, camelCase) : null;
|
|
448
|
-
const headerParamsMapping = paramsCasing ? buildTransformedParamsMapping(originalHeaderParams, camelCase) : null;
|
|
449
|
-
const contentTypeHeader = contentType && contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : null;
|
|
450
|
-
const headers = [headerParams.length ? headerParamsMapping ? "...mappedHeaders" : "...headers" : null, contentTypeHeader].filter(Boolean);
|
|
451
|
-
const fetchConfig = [];
|
|
452
|
-
fetchConfig.push(`method: ${JSON.stringify(node.method.toUpperCase())}`);
|
|
453
|
-
fetchConfig.push(`url: ${Url.toTemplateString(node.path)}`);
|
|
454
|
-
if (baseURL) fetchConfig.push(`baseURL: \`${baseURL}\``);
|
|
455
|
-
if (queryParams.length) fetchConfig.push(queryParamsMapping ? "params: mappedParams" : "params");
|
|
456
|
-
if (requestName) fetchConfig.push(`data: ${isFormData ? "formData as FormData" : "requestData"}`);
|
|
457
|
-
if (headers.length) fetchConfig.push(`headers: { ${headers.join(", ")} }`);
|
|
458
|
-
const callToolResult = `return {
|
|
459
|
-
content: [
|
|
460
|
-
{
|
|
461
|
-
type: 'text',
|
|
462
|
-
text: JSON.stringify(${dataReturnType === "data" ? "res.data" : "res"})
|
|
463
|
-
}
|
|
464
|
-
],
|
|
465
|
-
structuredContent: { data: res.data }
|
|
466
|
-
}`;
|
|
483
|
+
const { signature, groups } = buildRequestParamsSignature(node, resolver, { isConfigurable: false });
|
|
484
|
+
const paramsSignature = [signature, "request: RequestHandlerExtra<ServerRequest, ServerNotification>"].filter(Boolean).join(", ");
|
|
485
|
+
const callArgs = requestGroupOrder.filter((key) => groups[key]);
|
|
486
|
+
const callConfig = callArgs.length ? `{ ${callArgs.join(", ")} }` : "{}";
|
|
467
487
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
468
488
|
name,
|
|
469
489
|
isExportable: true,
|
|
@@ -476,28 +496,17 @@ function McpHandler({ name, node, resolver, baseURL, dataReturnType, paramsCasin
|
|
|
476
496
|
JSDoc: { comments: buildOperationComments(node) },
|
|
477
497
|
returnType: "Promise<CallToolResult>",
|
|
478
498
|
children: [
|
|
479
|
-
|
|
480
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
481
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
482
|
-
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
483
|
-
pathParamsMapping && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})] }),
|
|
484
|
-
queryParamsMapping && queryParams.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
485
|
-
buildRemappingCode(queryParamsMapping, "mappedParams", "params"),
|
|
486
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
487
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
488
|
-
] }),
|
|
489
|
-
headerParamsMapping && headerParams.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
490
|
-
buildRemappingCode(headerParamsMapping, "mappedHeaders", "headers"),
|
|
491
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
492
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
|
|
493
|
-
] }),
|
|
494
|
-
requestName && "const requestData = data",
|
|
495
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
496
|
-
isFormData && requestName && "const formData = buildFormData(requestData)",
|
|
499
|
+
`const res = await ${clientName}(${callConfig})`,
|
|
497
500
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
498
|
-
`
|
|
499
|
-
|
|
500
|
-
|
|
501
|
+
`return {
|
|
502
|
+
content: [
|
|
503
|
+
{
|
|
504
|
+
type: 'text',
|
|
505
|
+
text: JSON.stringify(res.data)
|
|
506
|
+
}
|
|
507
|
+
],
|
|
508
|
+
structuredContent: { data: res.data }
|
|
509
|
+
}`
|
|
501
510
|
]
|
|
502
511
|
})
|
|
503
512
|
});
|
|
@@ -537,37 +546,37 @@ function zodExprFromSchemaNode(schema) {
|
|
|
537
546
|
}
|
|
538
547
|
//#endregion
|
|
539
548
|
//#region src/components/Server.tsx
|
|
540
|
-
const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "
|
|
541
|
-
function Server({ name, serverName, serverVersion,
|
|
549
|
+
const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "call" });
|
|
550
|
+
function Server({ name, serverName, serverVersion, operations }) {
|
|
542
551
|
const registrations = operations.map(({ tool, mcp, zod, node }) => {
|
|
543
|
-
const { path: pathParams } = getOperationParameters(node
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
552
|
+
const { path: pathParams } = getOperationParameters(node);
|
|
553
|
+
const entries = [];
|
|
554
|
+
if (pathParams.length) {
|
|
555
|
+
const pathFields = pathParams.map((p) => {
|
|
556
|
+
const zodParam = zod.pathParams.find((zp) => zp.name === p.name);
|
|
557
|
+
return `${JSON.stringify(p.name)}: ${zodParam ? zodParam.schemaName : zodExprFromSchemaNode(p.schema)}`;
|
|
558
|
+
}).join(", ");
|
|
559
|
+
entries.push({
|
|
560
|
+
key: "path",
|
|
561
|
+
value: `z.object({ ${pathFields} })`
|
|
551
562
|
});
|
|
552
563
|
}
|
|
553
|
-
if (zod.
|
|
554
|
-
key: "
|
|
555
|
-
value: zod.requestName
|
|
556
|
-
});
|
|
557
|
-
if (zod.queryParams) otherEntries.push({
|
|
558
|
-
key: "params",
|
|
564
|
+
if (zod.queryParams) entries.push({
|
|
565
|
+
key: "query",
|
|
559
566
|
value: zodGroupExpr(zod.queryParams)
|
|
560
567
|
});
|
|
561
|
-
if (zod.headerParams)
|
|
568
|
+
if (zod.headerParams) entries.push({
|
|
562
569
|
key: "headers",
|
|
563
570
|
value: zodGroupExpr(zod.headerParams)
|
|
564
571
|
});
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
572
|
+
if (zod.requestName) entries.push({
|
|
573
|
+
key: "body",
|
|
574
|
+
value: zod.requestName
|
|
575
|
+
});
|
|
576
|
+
const paramsNode = entries.length ? (0, _kubb_plugin_ts.createFunctionParameters)({ params: [(0, _kubb_plugin_ts.createFunctionParameter)({
|
|
577
|
+
name: (0, _kubb_plugin_ts.createObjectBindingPattern)({ elements: entries.map((e) => ({ name: e.key })) }),
|
|
569
578
|
optional: false
|
|
570
|
-
})
|
|
579
|
+
})] }) : null;
|
|
571
580
|
const destructured = paramsNode ? keysPrinter.print(paramsNode) ?? "" : "";
|
|
572
581
|
const inputSchema = entries.length ? `{ ${entries.map((e) => `${e.key}: ${e.value}`).join(", ")} }` : null;
|
|
573
582
|
const outputSchema = zod.responseName;
|
|
@@ -629,12 +638,105 @@ return server`
|
|
|
629
638
|
});
|
|
630
639
|
}
|
|
631
640
|
//#endregion
|
|
641
|
+
//#region ../../internals/client/src/resolveClient.ts
|
|
642
|
+
/**
|
|
643
|
+
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
644
|
+
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
645
|
+
*
|
|
646
|
+
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
647
|
+
* contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
|
|
648
|
+
*
|
|
649
|
+
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
650
|
+
* imports and calls them.
|
|
651
|
+
* - `error` — no client plugin is registered, several are registered without a selector, or the
|
|
652
|
+
* requested one is missing.
|
|
653
|
+
*
|
|
654
|
+
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
655
|
+
* contract client plugin is picked up automatically.
|
|
656
|
+
*/
|
|
657
|
+
const pluginFetchName = "plugin-fetch";
|
|
658
|
+
const pluginAxiosName = "plugin-axios";
|
|
659
|
+
const selectorToPlugin = {
|
|
660
|
+
fetch: pluginFetchName,
|
|
661
|
+
axios: pluginAxiosName
|
|
662
|
+
};
|
|
663
|
+
const contractPlugins = [pluginFetchName, pluginAxiosName];
|
|
664
|
+
/**
|
|
665
|
+
* Applies the `client` resolution rules. See the module comment for the strategy shape.
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```ts
|
|
669
|
+
* resolveClient({ client: 'fetch', pluginNames: ['plugin-ts', 'plugin-fetch'] })
|
|
670
|
+
* // { kind: 'contract', pluginName: 'plugin-fetch' }
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```ts
|
|
675
|
+
* resolveClient({ client: undefined, pluginNames: ['plugin-ts'] })
|
|
676
|
+
* // { kind: 'error', message: 'No client plugin is registered…' }
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
function resolveClient(options) {
|
|
680
|
+
const { client, pluginNames } = options;
|
|
681
|
+
const has = (name) => pluginNames.includes(name);
|
|
682
|
+
if (client === "fetch" || client === "axios") {
|
|
683
|
+
const pluginName = selectorToPlugin[client];
|
|
684
|
+
if (!has(pluginName)) return {
|
|
685
|
+
kind: "error",
|
|
686
|
+
message: `\`client: '${client}'\` is set but \`@kubb/plugin-${client}\` is not registered in \`plugins\`. Add it, or drop \`client\` to use a different client plugin.`
|
|
687
|
+
};
|
|
688
|
+
return {
|
|
689
|
+
kind: "contract",
|
|
690
|
+
pluginName
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
const registered = contractPlugins.filter(has);
|
|
694
|
+
if (registered.length === 1) return {
|
|
695
|
+
kind: "contract",
|
|
696
|
+
pluginName: registered[0]
|
|
697
|
+
};
|
|
698
|
+
if (registered.length > 1) return {
|
|
699
|
+
kind: "error",
|
|
700
|
+
message: `Multiple client plugins are registered (${registered.map((name) => `\`@kubb/${name}\``).join(", ")}). Set \`client: 'fetch' | 'axios'\` to choose which client the hooks call, or register a single client plugin.`
|
|
701
|
+
};
|
|
702
|
+
return {
|
|
703
|
+
kind: "error",
|
|
704
|
+
message: "No client plugin is registered. Add `@kubb/plugin-axios` or `@kubb/plugin-fetch` to `plugins` so the generated code has an HTTP client to call."
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region ../../internals/client/src/resolveClientOperation.ts
|
|
709
|
+
/**
|
|
710
|
+
* Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
|
|
711
|
+
* the registered contract client plugin's resolver and output. Works for any contract client plugin
|
|
712
|
+
* (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
|
|
713
|
+
* path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
|
|
714
|
+
* read `RequestConfig` / `ResponseErrorConfig` from.
|
|
715
|
+
*/
|
|
716
|
+
function resolveClientOperation(options) {
|
|
717
|
+
const { clientPlugin, driver, node, root, output } = options;
|
|
718
|
+
if (!clientPlugin) return null;
|
|
719
|
+
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
720
|
+
if (!resolver) return null;
|
|
721
|
+
const plugin = driver.getPlugin(clientPlugin.pluginName);
|
|
722
|
+
const file = resolver.resolveFile(operationFileEntry(node, node.operationId), {
|
|
723
|
+
root,
|
|
724
|
+
output: plugin?.options?.output ?? output,
|
|
725
|
+
group: plugin?.options?.group ?? void 0
|
|
726
|
+
});
|
|
727
|
+
return {
|
|
728
|
+
name: resolver.resolveName(node.operationId),
|
|
729
|
+
path: file.path,
|
|
730
|
+
clientPath: node_path.default.resolve(root, ".kubb/client.ts")
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
632
734
|
//#region src/generators/mcpGenerator.tsx
|
|
633
735
|
/**
|
|
634
736
|
* Built-in operation generator for `@kubb/plugin-mcp`. Emits one MCP tool
|
|
635
|
-
* handler per OpenAPI operation
|
|
636
|
-
*
|
|
637
|
-
*
|
|
737
|
+
* handler per OpenAPI operation. The handler takes the grouped `{ path, query,
|
|
738
|
+
* headers, body }` config and forwards it to the registered client plugin's
|
|
739
|
+
* (`@kubb/plugin-axios` / `@kubb/plugin-fetch`) `<op>` function.
|
|
638
740
|
*/
|
|
639
741
|
const mcpGenerator = (0, _kubb_core.defineGenerator)({
|
|
640
742
|
name: "mcp",
|
|
@@ -642,14 +744,19 @@ const mcpGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
642
744
|
operation(node, ctx) {
|
|
643
745
|
if (!_kubb_core.ast.isHttpOperationNode(node)) return null;
|
|
644
746
|
const { resolver, driver, root } = ctx;
|
|
645
|
-
const { output, client,
|
|
747
|
+
const { output, client, group } = ctx.options;
|
|
646
748
|
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
647
749
|
if (!pluginTs) return null;
|
|
648
750
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
751
|
+
const contractOp = resolveClientOperation({
|
|
752
|
+
clientPlugin: { pluginName: client.pluginName },
|
|
753
|
+
driver,
|
|
754
|
+
node,
|
|
755
|
+
root,
|
|
756
|
+
output
|
|
652
757
|
});
|
|
758
|
+
if (!contractOp) return null;
|
|
759
|
+
const requestConfigName = tsResolver.resolveRequestConfigName(node);
|
|
653
760
|
const meta = {
|
|
654
761
|
name: resolver.resolveHandlerName(node),
|
|
655
762
|
file: resolver.resolveFile({
|
|
@@ -678,8 +785,8 @@ const mcpGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
678
785
|
path: meta.file.path,
|
|
679
786
|
meta: meta.file.meta,
|
|
680
787
|
children: [
|
|
681
|
-
meta.fileTs &&
|
|
682
|
-
name:
|
|
788
|
+
meta.fileTs && requestConfigName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
789
|
+
name: [requestConfigName],
|
|
683
790
|
root: meta.file.path,
|
|
684
791
|
path: meta.fileTs.path,
|
|
685
792
|
isTypeOnly: true
|
|
@@ -699,59 +806,15 @@ const mcpGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
699
806
|
isTypeOnly: true
|
|
700
807
|
}),
|
|
701
808
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
702
|
-
name: [
|
|
809
|
+
name: [contractOp.name],
|
|
703
810
|
root: meta.file.path,
|
|
704
|
-
path:
|
|
811
|
+
path: contractOp.path
|
|
705
812
|
}),
|
|
706
|
-
client.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
707
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
708
|
-
name: [
|
|
709
|
-
"Client",
|
|
710
|
-
"RequestConfig",
|
|
711
|
-
"ResponseErrorConfig"
|
|
712
|
-
],
|
|
713
|
-
path: client.importPath,
|
|
714
|
-
isTypeOnly: true
|
|
715
|
-
}),
|
|
716
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
717
|
-
name: "client",
|
|
718
|
-
path: client.importPath
|
|
719
|
-
}),
|
|
720
|
-
client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
721
|
-
name: ["ResponseConfig"],
|
|
722
|
-
path: client.importPath,
|
|
723
|
-
isTypeOnly: true
|
|
724
|
-
})
|
|
725
|
-
] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
726
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
727
|
-
name: [
|
|
728
|
-
"Client",
|
|
729
|
-
"RequestConfig",
|
|
730
|
-
"ResponseErrorConfig"
|
|
731
|
-
],
|
|
732
|
-
root: meta.file.path,
|
|
733
|
-
path: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
734
|
-
isTypeOnly: true
|
|
735
|
-
}),
|
|
736
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
737
|
-
name: ["client"],
|
|
738
|
-
root: meta.file.path,
|
|
739
|
-
path: node_path.default.resolve(root, ".kubb/client.ts")
|
|
740
|
-
}),
|
|
741
|
-
client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
742
|
-
name: ["ResponseConfig"],
|
|
743
|
-
root: meta.file.path,
|
|
744
|
-
path: node_path.default.resolve(root, ".kubb/client.ts"),
|
|
745
|
-
isTypeOnly: true
|
|
746
|
-
})
|
|
747
|
-
] }),
|
|
748
813
|
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(McpHandler, {
|
|
749
814
|
name: meta.name,
|
|
815
|
+
clientName: contractOp.name,
|
|
750
816
|
node,
|
|
751
|
-
resolver: tsResolver
|
|
752
|
-
baseURL: client.baseURL,
|
|
753
|
-
dataReturnType: client.dataReturnType || "data",
|
|
754
|
-
paramsCasing
|
|
817
|
+
resolver: tsResolver
|
|
755
818
|
})
|
|
756
819
|
]
|
|
757
820
|
});
|
|
@@ -771,7 +834,7 @@ const serverGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
771
834
|
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
772
835
|
operations(nodes, ctx) {
|
|
773
836
|
const { config, resolver, plugin, driver, root } = ctx;
|
|
774
|
-
const { output,
|
|
837
|
+
const { output, group } = ctx.options;
|
|
775
838
|
const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
|
|
776
839
|
if (!pluginZod) return;
|
|
777
840
|
const zodResolver = driver.getResolver(_kubb_plugin_zod.pluginZodName);
|
|
@@ -787,7 +850,7 @@ const serverGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
787
850
|
meta: { pluginName: plugin.name }
|
|
788
851
|
};
|
|
789
852
|
const operationsMapped = nodes.filter(_kubb_core.ast.isHttpOperationNode).map((node) => {
|
|
790
|
-
const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node
|
|
853
|
+
const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node);
|
|
791
854
|
const mcpFile = resolver.resolveFile({
|
|
792
855
|
name: node.operationId,
|
|
793
856
|
extname: ".ts",
|
|
@@ -893,7 +956,6 @@ const serverGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
893
956
|
name,
|
|
894
957
|
serverName: ctx.meta.title ?? "server",
|
|
895
958
|
serverVersion: ctx.meta.version ?? "0.0.0",
|
|
896
|
-
paramsCasing,
|
|
897
959
|
operations: operationsMapped
|
|
898
960
|
})
|
|
899
961
|
]
|
|
@@ -959,13 +1021,13 @@ const pluginMcpName = "plugin-mcp";
|
|
|
959
1021
|
/**
|
|
960
1022
|
* Generates a Model Context Protocol (MCP) server from an OpenAPI spec. Every
|
|
961
1023
|
* operation becomes a typed MCP tool that AI assistants (Claude Desktop, Claude
|
|
962
|
-
* Code, MCP-compatible clients) can call directly.
|
|
1024
|
+
* Code, MCP-compatible clients) can call directly. Each handler calls a contract
|
|
1025
|
+
* client `<op>` from a registered `@kubb/plugin-axios` or `@kubb/plugin-fetch`.
|
|
963
1026
|
*
|
|
964
1027
|
* @example
|
|
965
1028
|
* ```ts
|
|
966
1029
|
* import { defineConfig } from 'kubb'
|
|
967
1030
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
968
|
-
* import { pluginClient } from '@kubb/plugin-client'
|
|
969
1031
|
* import { pluginZod } from '@kubb/plugin-zod'
|
|
970
1032
|
* import { pluginMcp } from '@kubb/plugin-mcp'
|
|
971
1033
|
*
|
|
@@ -974,11 +1036,10 @@ const pluginMcpName = "plugin-mcp";
|
|
|
974
1036
|
* output: { path: './src/gen' },
|
|
975
1037
|
* plugins: [
|
|
976
1038
|
* pluginTs(),
|
|
977
|
-
* pluginClient(),
|
|
978
1039
|
* pluginZod(),
|
|
979
1040
|
* pluginMcp({
|
|
980
1041
|
* output: { path: './mcp' },
|
|
981
|
-
*
|
|
1042
|
+
* baseURL: 'https://petstore.swagger.io/v2',
|
|
982
1043
|
* }),
|
|
983
1044
|
* ],
|
|
984
1045
|
* })
|
|
@@ -988,9 +1049,7 @@ const pluginMcp = (0, _kubb_core.definePlugin)((options) => {
|
|
|
988
1049
|
const { output = {
|
|
989
1050
|
path: "mcp",
|
|
990
1051
|
barrel: { type: "named" }
|
|
991
|
-
}, group, exclude = [], include, override = [],
|
|
992
|
-
const clientName = client?.client ?? "axios";
|
|
993
|
-
const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
|
|
1052
|
+
}, group, exclude = [], include, override = [], client, resolver: userResolver, macros: userMacros } = options;
|
|
994
1053
|
const groupConfig = createGroupConfig(group);
|
|
995
1054
|
return {
|
|
996
1055
|
name: pluginMcpName,
|
|
@@ -1001,51 +1060,28 @@ const pluginMcp = (0, _kubb_core.definePlugin)((options) => {
|
|
|
1001
1060
|
...resolverMcp,
|
|
1002
1061
|
...userResolver
|
|
1003
1062
|
} : resolverMcp;
|
|
1063
|
+
const resolvedClient = resolveClient({
|
|
1064
|
+
client,
|
|
1065
|
+
pluginNames: (ctx.config.plugins ?? []).map((p) => p.name).filter((name) => Boolean(name))
|
|
1066
|
+
});
|
|
1067
|
+
if (resolvedClient.kind === "error") throw new Error(resolvedClient.message);
|
|
1068
|
+
const resolvedClientDescriptor = {
|
|
1069
|
+
kind: "contract",
|
|
1070
|
+
pluginName: resolvedClient.pluginName
|
|
1071
|
+
};
|
|
1004
1072
|
ctx.setOptions({
|
|
1005
1073
|
output,
|
|
1006
1074
|
exclude,
|
|
1007
1075
|
include,
|
|
1008
1076
|
override,
|
|
1009
1077
|
group: groupConfig,
|
|
1010
|
-
|
|
1011
|
-
client: {
|
|
1012
|
-
client: clientName,
|
|
1013
|
-
clientType: client?.clientType ?? "function",
|
|
1014
|
-
importPath: clientImportPath,
|
|
1015
|
-
dataReturnType: client?.dataReturnType ?? "data",
|
|
1016
|
-
bundle: client?.bundle,
|
|
1017
|
-
baseURL: client?.baseURL,
|
|
1018
|
-
paramsCasing: client?.paramsCasing
|
|
1019
|
-
},
|
|
1078
|
+
client: resolvedClientDescriptor,
|
|
1020
1079
|
resolver
|
|
1021
1080
|
});
|
|
1022
1081
|
ctx.setResolver(resolver);
|
|
1023
|
-
if (
|
|
1082
|
+
if (userMacros?.length) ctx.setMacros(userMacros);
|
|
1024
1083
|
ctx.addGenerator(mcpGenerator);
|
|
1025
1084
|
ctx.addGenerator(serverGenerator);
|
|
1026
|
-
for (const gen of userGenerators) ctx.addGenerator(gen);
|
|
1027
|
-
const root = node_path$1.default.resolve(ctx.config.root, ctx.config.output.path);
|
|
1028
|
-
const hasClientPlugin = ctx.config.plugins?.some((p) => p.name === _kubb_plugin_client.pluginClientName);
|
|
1029
|
-
if (client?.bundle && !hasClientPlugin && !clientImportPath) ctx.injectFile({
|
|
1030
|
-
baseName: "client.ts",
|
|
1031
|
-
path: node_path$1.default.resolve(root, ".kubb/client.ts"),
|
|
1032
|
-
sources: [_kubb_core.ast.createSource({
|
|
1033
|
-
name: "client",
|
|
1034
|
-
nodes: [_kubb_core.ast.createText(clientName === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source)],
|
|
1035
|
-
isExportable: true,
|
|
1036
|
-
isIndexable: true
|
|
1037
|
-
})]
|
|
1038
|
-
});
|
|
1039
|
-
if (!hasClientPlugin) ctx.injectFile({
|
|
1040
|
-
baseName: "config.ts",
|
|
1041
|
-
path: node_path$1.default.resolve(root, ".kubb/config.ts"),
|
|
1042
|
-
sources: [_kubb_core.ast.createSource({
|
|
1043
|
-
name: "config",
|
|
1044
|
-
nodes: [_kubb_core.ast.createText(_kubb_plugin_client_templates_config_source.source)],
|
|
1045
|
-
isExportable: false,
|
|
1046
|
-
isIndexable: false
|
|
1047
|
-
})]
|
|
1048
|
-
});
|
|
1049
1085
|
} }
|
|
1050
1086
|
};
|
|
1051
1087
|
});
|