@kubb/plugin-mcp 4.1.3 → 4.2.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/README.md +19 -16
- package/dist/{OperationGenerator-BfGvlSM8.d.cts → OperationGenerator-4XcPTEmW.d.ts} +69 -69
- package/dist/{OperationGenerator-C-JRX2db.d.ts → OperationGenerator-BEQNw2o0.d.cts} +69 -69
- package/dist/{Server-BX80OVzu.js → Server-CKHk0vlR.js} +2 -2
- package/dist/{Server-BX80OVzu.js.map → Server-CKHk0vlR.js.map} +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-C6GGdP_U.cjs → generators-CPxZOD9U.cjs} +8 -5
- package/dist/generators-CPxZOD9U.cjs.map +1 -0
- package/dist/{generators-CFdUB1k-.js → generators-Cvzin4vm.js} +9 -7
- package/dist/generators-Cvzin4vm.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{types-kxPXUmDf.d.ts → types-D1ZAplJE.d.ts} +3 -3
- package/dist/{types-BaQXdwM0.d.cts → types-xkoLaTAL.d.cts} +3 -3
- package/package.json +9 -11
- package/src/generators/mcpGenerator.tsx +4 -5
- package/src/generators/serverGenerator.tsx +7 -4
- package/dist/generators-C6GGdP_U.cjs.map +0 -1
- package/dist/generators-CFdUB1k-.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
<h1>Plugin MCP</h1>
|
|
3
|
+
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
4
|
+
<img width="180" src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/logo.png" alt="Kubb logo">
|
|
5
|
+
</a>
|
|
2
6
|
|
|
3
|
-
<!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
|
|
4
|
-
<h1>@kubb/plugin-mcp</h1>
|
|
5
|
-
|
|
6
|
-
<p>
|
|
7
|
-
Swagger integration to create MCP helpers.
|
|
8
|
-
</p>
|
|
9
|
-
<img src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/banner.png" alt="logo" height="auto" />
|
|
10
7
|
|
|
11
8
|
[![npm version][npm-version-src]][npm-version-href]
|
|
12
9
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
13
10
|
[![Coverage][coverage-src]][coverage-href]
|
|
14
11
|
[![License][license-src]][license-href]
|
|
15
|
-
|
|
12
|
+
[![Sponsors][sponsors-src]][sponsors-href]
|
|
16
13
|
<h4>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
<a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/main//examples/typescript" target="_blank">View Demo</a>
|
|
15
|
+
<span> · </span>
|
|
16
|
+
<a href="https://kubb.dev/" target="_blank">Documentation</a>
|
|
17
|
+
<span> · </span>
|
|
18
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
19
|
+
<span> · </span>
|
|
20
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
21
|
+
</h4>
|
|
25
22
|
</div>
|
|
26
23
|
|
|
24
|
+
|
|
25
|
+
Swagger integration to create MCP helpers.
|
|
26
|
+
|
|
27
|
+
|
|
27
28
|
## Supporting Kubb
|
|
28
29
|
|
|
29
30
|
Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
|
|
@@ -51,3 +52,5 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
51
52
|
[minified-href]: https://www.npmjs.com/package/@kubb/plugin-mcp
|
|
52
53
|
[coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
|
|
53
54
|
[coverage-href]: https://www.npmjs.com/package/@kubb/plugin-mcp
|
|
55
|
+
[sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
|
|
56
|
+
[sponsors-href]: https://github.com/sponsors/stijnvanhulle/
|
|
@@ -7,7 +7,7 @@ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
|
7
7
|
import BaseOas from "oas";
|
|
8
8
|
|
|
9
9
|
//#region ../core/src/fs/types.d.ts
|
|
10
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
10
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
11
11
|
type Import = {
|
|
12
12
|
/**
|
|
13
13
|
* Import name to be used
|
|
@@ -81,7 +81,7 @@ type BaseName = `${string}.${string}`;
|
|
|
81
81
|
* Path will be full qualified path to a specified file
|
|
82
82
|
*/
|
|
83
83
|
type Path = string;
|
|
84
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
84
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
85
85
|
type OptionalPath = Path | undefined | null;
|
|
86
86
|
type File<TMeta extends object = object> = {
|
|
87
87
|
/**
|
|
@@ -126,12 +126,12 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
126
126
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
127
127
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
128
128
|
*/
|
|
129
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
129
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
130
130
|
#private;
|
|
131
|
-
constructor(options?: TOptions, context?: TContext);
|
|
132
|
-
get options(): TOptions;
|
|
131
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
132
|
+
get options(): TOptions$1;
|
|
133
133
|
get context(): TContext;
|
|
134
|
-
set options(options: TOptions);
|
|
134
|
+
set options(options: TOptions$1);
|
|
135
135
|
abstract build(...params: unknown[]): unknown;
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
@@ -184,9 +184,9 @@ type Logger = {
|
|
|
184
184
|
};
|
|
185
185
|
//#endregion
|
|
186
186
|
//#region ../core/src/utils/types.d.ts
|
|
187
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
188
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
189
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
187
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
188
|
+
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
189
|
+
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region ../core/src/types.d.ts
|
|
192
192
|
type InputPath = {
|
|
@@ -299,11 +299,11 @@ TName extends string = string,
|
|
|
299
299
|
/**
|
|
300
300
|
* Options of the plugin.
|
|
301
301
|
*/
|
|
302
|
-
TOptions extends object = object,
|
|
302
|
+
TOptions$1 extends object = object,
|
|
303
303
|
/**
|
|
304
304
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
305
305
|
*/
|
|
306
|
-
TResolvedOptions extends object = TOptions,
|
|
306
|
+
TResolvedOptions extends object = TOptions$1,
|
|
307
307
|
/**
|
|
308
308
|
* Context that you want to expose to other plugins.
|
|
309
309
|
*/
|
|
@@ -317,23 +317,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
317
317
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
318
318
|
*/
|
|
319
319
|
key: PluginKey<TName | string>;
|
|
320
|
-
options: TOptions;
|
|
320
|
+
options: TOptions$1;
|
|
321
321
|
resolvedOptions: TResolvedOptions;
|
|
322
322
|
context: TContext;
|
|
323
323
|
resolvePathOptions: TResolvePathOptions;
|
|
324
324
|
};
|
|
325
325
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
326
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
326
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
327
327
|
/**
|
|
328
328
|
* Unique name used for the plugin
|
|
329
329
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
330
330
|
* @example @kubb/typescript
|
|
331
331
|
*/
|
|
332
|
-
name: TOptions['name'];
|
|
332
|
+
name: TOptions$1['name'];
|
|
333
333
|
/**
|
|
334
334
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
335
335
|
*/
|
|
336
|
-
options: TOptions['resolvedOptions'];
|
|
336
|
+
options: TOptions$1['resolvedOptions'];
|
|
337
337
|
/**
|
|
338
338
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
339
339
|
* Can be used to validate dependent plugins.
|
|
@@ -343,23 +343,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
343
343
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
344
344
|
*/
|
|
345
345
|
post?: Array<string>;
|
|
346
|
-
} & (TOptions['context'] extends never ? {
|
|
346
|
+
} & (TOptions$1['context'] extends never ? {
|
|
347
347
|
context?: never;
|
|
348
348
|
} : {
|
|
349
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
349
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
350
350
|
});
|
|
351
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
352
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
351
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
352
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
353
|
/**
|
|
354
354
|
* Unique name used for the plugin
|
|
355
355
|
* @example @kubb/typescript
|
|
356
356
|
*/
|
|
357
|
-
name: TOptions['name'];
|
|
357
|
+
name: TOptions$1['name'];
|
|
358
358
|
/**
|
|
359
359
|
* Internal key used when a developer uses more than one of the same plugin
|
|
360
360
|
* @private
|
|
361
361
|
*/
|
|
362
|
-
key: TOptions['key'];
|
|
362
|
+
key: TOptions$1['key'];
|
|
363
363
|
/**
|
|
364
364
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
365
365
|
* Can be used to validate dependent plugins.
|
|
@@ -372,49 +372,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
372
372
|
/**
|
|
373
373
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
374
374
|
*/
|
|
375
|
-
options: TOptions['resolvedOptions'];
|
|
376
|
-
} & (TOptions['context'] extends never ? {
|
|
375
|
+
options: TOptions$1['resolvedOptions'];
|
|
376
|
+
} & (TOptions$1['context'] extends never ? {
|
|
377
377
|
context?: never;
|
|
378
378
|
} : {
|
|
379
|
-
context: TOptions['context'];
|
|
379
|
+
context: TOptions$1['context'];
|
|
380
380
|
});
|
|
381
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
382
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
381
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
382
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
383
383
|
/**
|
|
384
384
|
* Start of the lifecycle of a plugin.
|
|
385
385
|
* @type hookParallel
|
|
386
386
|
*/
|
|
387
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
387
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
388
388
|
/**
|
|
389
389
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
390
390
|
* Options can als be included.
|
|
391
391
|
* @type hookFirst
|
|
392
392
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
393
393
|
*/
|
|
394
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
394
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
395
395
|
/**
|
|
396
396
|
* Resolve to a name based on a string.
|
|
397
397
|
* Useful when converting to PascalCase or camelCase.
|
|
398
398
|
* @type hookFirst
|
|
399
399
|
* @example ('pet') => 'Pet'
|
|
400
400
|
*/
|
|
401
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
401
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
402
402
|
/**
|
|
403
403
|
* End of the plugin lifecycle.
|
|
404
404
|
* @type hookParallel
|
|
405
405
|
*/
|
|
406
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
406
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
407
407
|
};
|
|
408
408
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
409
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
410
|
-
type ResolvePathParams<TOptions = object> = {
|
|
409
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
410
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
411
411
|
pluginKey?: Plugin['key'];
|
|
412
412
|
baseName: BaseName;
|
|
413
413
|
mode?: Mode;
|
|
414
414
|
/**
|
|
415
415
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
416
416
|
*/
|
|
417
|
-
options?: TOptions;
|
|
417
|
+
options?: TOptions$1;
|
|
418
418
|
};
|
|
419
419
|
type ResolveNameParams = {
|
|
420
420
|
name: string;
|
|
@@ -427,12 +427,12 @@ type ResolveNameParams = {
|
|
|
427
427
|
*/
|
|
428
428
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
429
429
|
};
|
|
430
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
430
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
431
431
|
config: Config;
|
|
432
432
|
fileManager: FileManager;
|
|
433
433
|
pluginManager: PluginManager;
|
|
434
434
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
435
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
435
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
436
436
|
resolveName: (params: ResolveNameParams) => string;
|
|
437
437
|
logger: Logger;
|
|
438
438
|
/**
|
|
@@ -442,12 +442,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
442
442
|
/**
|
|
443
443
|
* Current plugin
|
|
444
444
|
*/
|
|
445
|
-
plugin: Plugin<TOptions>;
|
|
445
|
+
plugin: Plugin<TOptions$1>;
|
|
446
446
|
};
|
|
447
447
|
/**
|
|
448
448
|
* Specify the export location for the files and define the behavior of the output
|
|
449
449
|
*/
|
|
450
|
-
type Output<TOptions> = {
|
|
450
|
+
type Output<TOptions$1> = {
|
|
451
451
|
/**
|
|
452
452
|
* Path to the output folder or file that will contain the generated code
|
|
453
453
|
*/
|
|
@@ -460,11 +460,11 @@ type Output<TOptions> = {
|
|
|
460
460
|
/**
|
|
461
461
|
* Add a banner text in the beginning of every file
|
|
462
462
|
*/
|
|
463
|
-
banner?: string | ((options: TOptions) => string);
|
|
463
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
464
464
|
/**
|
|
465
465
|
* Add a footer text in the beginning of every file
|
|
466
466
|
*/
|
|
467
|
-
footer?: string | ((options: TOptions) => string);
|
|
467
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
468
468
|
};
|
|
469
469
|
type GroupContext = {
|
|
470
470
|
group: string;
|
|
@@ -484,7 +484,7 @@ type Group = {
|
|
|
484
484
|
type FileMetaBase = {
|
|
485
485
|
pluginKey?: Plugin['key'];
|
|
486
486
|
};
|
|
487
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
487
|
+
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
488
488
|
type AddIndexesProps = {
|
|
489
489
|
type: BarrelType | false | undefined;
|
|
490
490
|
/**
|
|
@@ -537,16 +537,16 @@ declare class FileManager {
|
|
|
537
537
|
//#region ../core/src/PluginManager.d.ts
|
|
538
538
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
539
539
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
540
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
540
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
541
541
|
message: string;
|
|
542
542
|
strategy: Strategy;
|
|
543
|
-
hookName: H;
|
|
543
|
+
hookName: H$1;
|
|
544
544
|
plugin: Plugin;
|
|
545
545
|
parameters?: unknown[] | undefined;
|
|
546
546
|
output?: unknown;
|
|
547
547
|
};
|
|
548
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
549
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
548
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
549
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
550
550
|
result: Result;
|
|
551
551
|
plugin: Plugin;
|
|
552
552
|
};
|
|
@@ -562,12 +562,12 @@ type Events = {
|
|
|
562
562
|
executed: [executer: Executer];
|
|
563
563
|
error: [error: Error];
|
|
564
564
|
};
|
|
565
|
-
type GetFileProps<TOptions = object> = {
|
|
565
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
566
566
|
name: string;
|
|
567
567
|
mode?: Mode;
|
|
568
568
|
extname: Extname;
|
|
569
569
|
pluginKey: Plugin['key'];
|
|
570
|
-
options?: TOptions;
|
|
570
|
+
options?: TOptions$1;
|
|
571
571
|
};
|
|
572
572
|
declare class PluginManager {
|
|
573
573
|
#private;
|
|
@@ -1008,12 +1008,12 @@ type ByContentType = {
|
|
|
1008
1008
|
};
|
|
1009
1009
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1010
1010
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1011
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1012
|
-
options: Partial<TOptions>;
|
|
1011
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1012
|
+
options: Partial<TOptions$1>;
|
|
1013
1013
|
};
|
|
1014
1014
|
//#endregion
|
|
1015
1015
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1016
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1016
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1017
1017
|
oas: Oas;
|
|
1018
1018
|
pluginManager: PluginManager;
|
|
1019
1019
|
/**
|
|
@@ -1022,7 +1022,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1022
1022
|
plugin: Plugin<TPluginOptions>;
|
|
1023
1023
|
mode: Mode;
|
|
1024
1024
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1025
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1025
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1026
1026
|
contentType?: contentType;
|
|
1027
1027
|
output?: string;
|
|
1028
1028
|
};
|
|
@@ -1053,7 +1053,7 @@ type SchemaProps$1 = {
|
|
|
1053
1053
|
name?: string;
|
|
1054
1054
|
parentName?: string;
|
|
1055
1055
|
};
|
|
1056
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1056
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1057
1057
|
#private;
|
|
1058
1058
|
refs: Refs;
|
|
1059
1059
|
/**
|
|
@@ -1072,39 +1072,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1072
1072
|
}
|
|
1073
1073
|
//#endregion
|
|
1074
1074
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1075
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1076
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1077
|
-
options: TOptions['resolvedOptions'];
|
|
1075
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1076
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1077
|
+
options: TOptions$1['resolvedOptions'];
|
|
1078
1078
|
operations: Array<Operation$1>;
|
|
1079
1079
|
};
|
|
1080
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1081
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1082
|
-
options: TOptions['resolvedOptions'];
|
|
1080
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1081
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1082
|
+
options: TOptions$1['resolvedOptions'];
|
|
1083
1083
|
operation: Operation$1;
|
|
1084
1084
|
};
|
|
1085
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1086
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1087
|
-
options: TOptions['resolvedOptions'];
|
|
1085
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1086
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1087
|
+
options: TOptions$1['resolvedOptions'];
|
|
1088
1088
|
schema: {
|
|
1089
1089
|
name: string;
|
|
1090
1090
|
tree: Array<Schema>;
|
|
1091
1091
|
value: SchemaObject$1;
|
|
1092
1092
|
};
|
|
1093
1093
|
};
|
|
1094
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1094
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1095
1095
|
name: string;
|
|
1096
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1097
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1098
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1096
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1097
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1098
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1099
1099
|
};
|
|
1100
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1100
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1101
1101
|
//#endregion
|
|
1102
1102
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1103
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1103
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1104
1104
|
oas: Oas;
|
|
1105
1105
|
exclude: Array<Exclude$1> | undefined;
|
|
1106
1106
|
include: Array<Include> | undefined;
|
|
1107
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1107
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1108
1108
|
contentType: contentType | undefined;
|
|
1109
1109
|
pluginManager: PluginManager;
|
|
1110
1110
|
/**
|
|
@@ -1128,5 +1128,5 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
1128
1128
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1129
1129
|
}
|
|
1130
1130
|
//#endregion
|
|
1131
|
-
export {
|
|
1132
|
-
//# sourceMappingURL=OperationGenerator-
|
|
1131
|
+
export { Override as a, contentType as c, PluginFactoryOptions as d, ResolveNameParams as f, OperationSchemas as i, Group as l, File as m, Exclude$1 as n, ResolvePathOptions as o, UserPluginWithLifeCycle as p, Include as r, Oas as s, Generator as t, Output as u };
|
|
1132
|
+
//# sourceMappingURL=OperationGenerator-4XcPTEmW.d.ts.map
|
|
@@ -7,7 +7,7 @@ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
|
7
7
|
import BaseOas from "oas";
|
|
8
8
|
|
|
9
9
|
//#region ../core/src/fs/types.d.ts
|
|
10
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
10
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
11
11
|
type Import = {
|
|
12
12
|
/**
|
|
13
13
|
* Import name to be used
|
|
@@ -81,7 +81,7 @@ type BaseName = `${string}.${string}`;
|
|
|
81
81
|
* Path will be full qualified path to a specified file
|
|
82
82
|
*/
|
|
83
83
|
type Path = string;
|
|
84
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
84
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
85
85
|
type OptionalPath = Path | undefined | null;
|
|
86
86
|
type File<TMeta extends object = object> = {
|
|
87
87
|
/**
|
|
@@ -126,12 +126,12 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
126
126
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
127
127
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
128
128
|
*/
|
|
129
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
129
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
130
130
|
#private;
|
|
131
|
-
constructor(options?: TOptions, context?: TContext);
|
|
132
|
-
get options(): TOptions;
|
|
131
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
132
|
+
get options(): TOptions$1;
|
|
133
133
|
get context(): TContext;
|
|
134
|
-
set options(options: TOptions);
|
|
134
|
+
set options(options: TOptions$1);
|
|
135
135
|
abstract build(...params: unknown[]): unknown;
|
|
136
136
|
}
|
|
137
137
|
//#endregion
|
|
@@ -184,9 +184,9 @@ type Logger = {
|
|
|
184
184
|
};
|
|
185
185
|
//#endregion
|
|
186
186
|
//#region ../core/src/utils/types.d.ts
|
|
187
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
188
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
189
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
187
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
188
|
+
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
189
|
+
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region ../core/src/types.d.ts
|
|
192
192
|
type InputPath = {
|
|
@@ -299,11 +299,11 @@ TName extends string = string,
|
|
|
299
299
|
/**
|
|
300
300
|
* Options of the plugin.
|
|
301
301
|
*/
|
|
302
|
-
TOptions extends object = object,
|
|
302
|
+
TOptions$1 extends object = object,
|
|
303
303
|
/**
|
|
304
304
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
305
305
|
*/
|
|
306
|
-
TResolvedOptions extends object = TOptions,
|
|
306
|
+
TResolvedOptions extends object = TOptions$1,
|
|
307
307
|
/**
|
|
308
308
|
* Context that you want to expose to other plugins.
|
|
309
309
|
*/
|
|
@@ -317,23 +317,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
317
317
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
318
318
|
*/
|
|
319
319
|
key: PluginKey<TName | string>;
|
|
320
|
-
options: TOptions;
|
|
320
|
+
options: TOptions$1;
|
|
321
321
|
resolvedOptions: TResolvedOptions;
|
|
322
322
|
context: TContext;
|
|
323
323
|
resolvePathOptions: TResolvePathOptions;
|
|
324
324
|
};
|
|
325
325
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
326
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
326
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
327
327
|
/**
|
|
328
328
|
* Unique name used for the plugin
|
|
329
329
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
330
330
|
* @example @kubb/typescript
|
|
331
331
|
*/
|
|
332
|
-
name: TOptions['name'];
|
|
332
|
+
name: TOptions$1['name'];
|
|
333
333
|
/**
|
|
334
334
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
335
335
|
*/
|
|
336
|
-
options: TOptions['resolvedOptions'];
|
|
336
|
+
options: TOptions$1['resolvedOptions'];
|
|
337
337
|
/**
|
|
338
338
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
339
339
|
* Can be used to validate dependent plugins.
|
|
@@ -343,23 +343,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
343
343
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
344
344
|
*/
|
|
345
345
|
post?: Array<string>;
|
|
346
|
-
} & (TOptions['context'] extends never ? {
|
|
346
|
+
} & (TOptions$1['context'] extends never ? {
|
|
347
347
|
context?: never;
|
|
348
348
|
} : {
|
|
349
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
349
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
350
350
|
});
|
|
351
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
352
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
351
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
352
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
353
|
/**
|
|
354
354
|
* Unique name used for the plugin
|
|
355
355
|
* @example @kubb/typescript
|
|
356
356
|
*/
|
|
357
|
-
name: TOptions['name'];
|
|
357
|
+
name: TOptions$1['name'];
|
|
358
358
|
/**
|
|
359
359
|
* Internal key used when a developer uses more than one of the same plugin
|
|
360
360
|
* @private
|
|
361
361
|
*/
|
|
362
|
-
key: TOptions['key'];
|
|
362
|
+
key: TOptions$1['key'];
|
|
363
363
|
/**
|
|
364
364
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
365
365
|
* Can be used to validate dependent plugins.
|
|
@@ -372,49 +372,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
372
372
|
/**
|
|
373
373
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
374
374
|
*/
|
|
375
|
-
options: TOptions['resolvedOptions'];
|
|
376
|
-
} & (TOptions['context'] extends never ? {
|
|
375
|
+
options: TOptions$1['resolvedOptions'];
|
|
376
|
+
} & (TOptions$1['context'] extends never ? {
|
|
377
377
|
context?: never;
|
|
378
378
|
} : {
|
|
379
|
-
context: TOptions['context'];
|
|
379
|
+
context: TOptions$1['context'];
|
|
380
380
|
});
|
|
381
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
382
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
381
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
382
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
383
383
|
/**
|
|
384
384
|
* Start of the lifecycle of a plugin.
|
|
385
385
|
* @type hookParallel
|
|
386
386
|
*/
|
|
387
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
387
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
388
388
|
/**
|
|
389
389
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
390
390
|
* Options can als be included.
|
|
391
391
|
* @type hookFirst
|
|
392
392
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
393
393
|
*/
|
|
394
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
394
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
395
395
|
/**
|
|
396
396
|
* Resolve to a name based on a string.
|
|
397
397
|
* Useful when converting to PascalCase or camelCase.
|
|
398
398
|
* @type hookFirst
|
|
399
399
|
* @example ('pet') => 'Pet'
|
|
400
400
|
*/
|
|
401
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
401
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
402
402
|
/**
|
|
403
403
|
* End of the plugin lifecycle.
|
|
404
404
|
* @type hookParallel
|
|
405
405
|
*/
|
|
406
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
406
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
407
407
|
};
|
|
408
408
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
409
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
410
|
-
type ResolvePathParams<TOptions = object> = {
|
|
409
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
410
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
411
411
|
pluginKey?: Plugin['key'];
|
|
412
412
|
baseName: BaseName;
|
|
413
413
|
mode?: Mode;
|
|
414
414
|
/**
|
|
415
415
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
416
416
|
*/
|
|
417
|
-
options?: TOptions;
|
|
417
|
+
options?: TOptions$1;
|
|
418
418
|
};
|
|
419
419
|
type ResolveNameParams = {
|
|
420
420
|
name: string;
|
|
@@ -427,12 +427,12 @@ type ResolveNameParams = {
|
|
|
427
427
|
*/
|
|
428
428
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
429
429
|
};
|
|
430
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
430
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
431
431
|
config: Config;
|
|
432
432
|
fileManager: FileManager;
|
|
433
433
|
pluginManager: PluginManager;
|
|
434
434
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
435
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
435
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
436
436
|
resolveName: (params: ResolveNameParams) => string;
|
|
437
437
|
logger: Logger;
|
|
438
438
|
/**
|
|
@@ -442,12 +442,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
442
442
|
/**
|
|
443
443
|
* Current plugin
|
|
444
444
|
*/
|
|
445
|
-
plugin: Plugin<TOptions>;
|
|
445
|
+
plugin: Plugin<TOptions$1>;
|
|
446
446
|
};
|
|
447
447
|
/**
|
|
448
448
|
* Specify the export location for the files and define the behavior of the output
|
|
449
449
|
*/
|
|
450
|
-
type Output<TOptions> = {
|
|
450
|
+
type Output<TOptions$1> = {
|
|
451
451
|
/**
|
|
452
452
|
* Path to the output folder or file that will contain the generated code
|
|
453
453
|
*/
|
|
@@ -460,11 +460,11 @@ type Output<TOptions> = {
|
|
|
460
460
|
/**
|
|
461
461
|
* Add a banner text in the beginning of every file
|
|
462
462
|
*/
|
|
463
|
-
banner?: string | ((options: TOptions) => string);
|
|
463
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
464
464
|
/**
|
|
465
465
|
* Add a footer text in the beginning of every file
|
|
466
466
|
*/
|
|
467
|
-
footer?: string | ((options: TOptions) => string);
|
|
467
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
468
468
|
};
|
|
469
469
|
type GroupContext = {
|
|
470
470
|
group: string;
|
|
@@ -484,7 +484,7 @@ type Group = {
|
|
|
484
484
|
type FileMetaBase = {
|
|
485
485
|
pluginKey?: Plugin['key'];
|
|
486
486
|
};
|
|
487
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
487
|
+
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
488
488
|
type AddIndexesProps = {
|
|
489
489
|
type: BarrelType | false | undefined;
|
|
490
490
|
/**
|
|
@@ -537,16 +537,16 @@ declare class FileManager {
|
|
|
537
537
|
//#region ../core/src/PluginManager.d.ts
|
|
538
538
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
539
539
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
540
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
540
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
541
541
|
message: string;
|
|
542
542
|
strategy: Strategy;
|
|
543
|
-
hookName: H;
|
|
543
|
+
hookName: H$1;
|
|
544
544
|
plugin: Plugin;
|
|
545
545
|
parameters?: unknown[] | undefined;
|
|
546
546
|
output?: unknown;
|
|
547
547
|
};
|
|
548
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
549
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
548
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
549
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
550
550
|
result: Result;
|
|
551
551
|
plugin: Plugin;
|
|
552
552
|
};
|
|
@@ -562,12 +562,12 @@ type Events = {
|
|
|
562
562
|
executed: [executer: Executer];
|
|
563
563
|
error: [error: Error];
|
|
564
564
|
};
|
|
565
|
-
type GetFileProps<TOptions = object> = {
|
|
565
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
566
566
|
name: string;
|
|
567
567
|
mode?: Mode;
|
|
568
568
|
extname: Extname;
|
|
569
569
|
pluginKey: Plugin['key'];
|
|
570
|
-
options?: TOptions;
|
|
570
|
+
options?: TOptions$1;
|
|
571
571
|
};
|
|
572
572
|
declare class PluginManager {
|
|
573
573
|
#private;
|
|
@@ -1008,12 +1008,12 @@ type ByContentType = {
|
|
|
1008
1008
|
};
|
|
1009
1009
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1010
1010
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1011
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1012
|
-
options: Partial<TOptions>;
|
|
1011
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1012
|
+
options: Partial<TOptions$1>;
|
|
1013
1013
|
};
|
|
1014
1014
|
//#endregion
|
|
1015
1015
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1016
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1016
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1017
1017
|
oas: Oas;
|
|
1018
1018
|
pluginManager: PluginManager;
|
|
1019
1019
|
/**
|
|
@@ -1022,7 +1022,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1022
1022
|
plugin: Plugin<TPluginOptions>;
|
|
1023
1023
|
mode: Mode;
|
|
1024
1024
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1025
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1025
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1026
1026
|
contentType?: contentType;
|
|
1027
1027
|
output?: string;
|
|
1028
1028
|
};
|
|
@@ -1053,7 +1053,7 @@ type SchemaProps$1 = {
|
|
|
1053
1053
|
name?: string;
|
|
1054
1054
|
parentName?: string;
|
|
1055
1055
|
};
|
|
1056
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1056
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1057
1057
|
#private;
|
|
1058
1058
|
refs: Refs;
|
|
1059
1059
|
/**
|
|
@@ -1072,39 +1072,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1072
1072
|
}
|
|
1073
1073
|
//#endregion
|
|
1074
1074
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1075
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1076
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1077
|
-
options: TOptions['resolvedOptions'];
|
|
1075
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1076
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1077
|
+
options: TOptions$1['resolvedOptions'];
|
|
1078
1078
|
operations: Array<Operation$1>;
|
|
1079
1079
|
};
|
|
1080
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1081
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1082
|
-
options: TOptions['resolvedOptions'];
|
|
1080
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1081
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1082
|
+
options: TOptions$1['resolvedOptions'];
|
|
1083
1083
|
operation: Operation$1;
|
|
1084
1084
|
};
|
|
1085
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1086
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1087
|
-
options: TOptions['resolvedOptions'];
|
|
1085
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1086
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1087
|
+
options: TOptions$1['resolvedOptions'];
|
|
1088
1088
|
schema: {
|
|
1089
1089
|
name: string;
|
|
1090
1090
|
tree: Array<Schema>;
|
|
1091
1091
|
value: SchemaObject$1;
|
|
1092
1092
|
};
|
|
1093
1093
|
};
|
|
1094
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1094
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1095
1095
|
name: string;
|
|
1096
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1097
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1098
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1096
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1097
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1098
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1099
1099
|
};
|
|
1100
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1100
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1101
1101
|
//#endregion
|
|
1102
1102
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1103
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1103
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1104
1104
|
oas: Oas;
|
|
1105
1105
|
exclude: Array<Exclude$1> | undefined;
|
|
1106
1106
|
include: Array<Include> | undefined;
|
|
1107
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1107
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1108
1108
|
contentType: contentType | undefined;
|
|
1109
1109
|
pluginManager: PluginManager;
|
|
1110
1110
|
/**
|
|
@@ -1128,5 +1128,5 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
1128
1128
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1129
1129
|
}
|
|
1130
1130
|
//#endregion
|
|
1131
|
-
export {
|
|
1132
|
-
//# sourceMappingURL=OperationGenerator-
|
|
1131
|
+
export { Override as a, contentType as c, PluginFactoryOptions as d, ResolveNameParams as f, OperationSchemas as i, Group as l, File as m, Exclude$1 as n, ResolvePathOptions as o, UserPluginWithLifeCycle as p, Include as r, Oas as s, Generator as t, Output as u };
|
|
1132
|
+
//# sourceMappingURL=OperationGenerator-BEQNw2o0.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server-
|
|
1
|
+
{"version":3,"file":"Server-CKHk0vlR.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('Fail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IAAI,QAAQ,SAAS,QAAQ,IAAI,QAAQ,cAAc,QAAQ,IAAI,QAAQ,aAAa,QAAQ,IAAI,QAAQ,YAAY,KAC1H,QAAO;cACL,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC,IAAI,aAAa,eAAe,CAAC,WAAW,aAAa,UAAU,CAAC;WACtI,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;AAKrC,WAAO;cACH,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC;WAClE,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;KAGrC,CACD,OAAO,QAAQ;GAEjB;;;;;;;;;;;;;;;GAcW"}
|
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
package/dist/components.js
CHANGED
|
@@ -3,14 +3,16 @@ let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
|
3
3
|
__kubb_plugin_oas = require_Server.__toESM(__kubb_plugin_oas);
|
|
4
4
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
5
|
__kubb_plugin_ts = require_Server.__toESM(__kubb_plugin_ts);
|
|
6
|
+
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
7
|
+
__kubb_core_hooks = require_Server.__toESM(__kubb_core_hooks);
|
|
8
|
+
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
9
|
+
__kubb_plugin_client_components = require_Server.__toESM(__kubb_plugin_client_components);
|
|
6
10
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
7
11
|
__kubb_plugin_oas_hooks = require_Server.__toESM(__kubb_plugin_oas_hooks);
|
|
8
12
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
9
13
|
__kubb_plugin_oas_utils = require_Server.__toESM(__kubb_plugin_oas_utils);
|
|
10
14
|
let __kubb_react = require("@kubb/react");
|
|
11
15
|
__kubb_react = require_Server.__toESM(__kubb_react);
|
|
12
|
-
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
13
|
-
__kubb_plugin_client_components = require_Server.__toESM(__kubb_plugin_client_components);
|
|
14
16
|
let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
|
|
15
17
|
__kubb_react_jsx_runtime = require_Server.__toESM(__kubb_react_jsx_runtime);
|
|
16
18
|
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
@@ -20,7 +22,7 @@ __kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
|
|
|
20
22
|
const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
21
23
|
name: "mcp",
|
|
22
24
|
Operation({ operation }) {
|
|
23
|
-
const {
|
|
25
|
+
const { options } = (0, __kubb_core_hooks.usePlugin)();
|
|
24
26
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
25
27
|
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
26
28
|
const mcp = {
|
|
@@ -116,7 +118,8 @@ const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
116
118
|
const serverGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
117
119
|
name: "operations",
|
|
118
120
|
Operations({ operations, options }) {
|
|
119
|
-
const
|
|
121
|
+
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
122
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
120
123
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
121
124
|
const { getFile, getName, getSchemas } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
122
125
|
const name = "server";
|
|
@@ -241,4 +244,4 @@ Object.defineProperty(exports, 'serverGenerator', {
|
|
|
241
244
|
return serverGenerator;
|
|
242
245
|
}
|
|
243
246
|
});
|
|
244
|
-
//# sourceMappingURL=generators-
|
|
247
|
+
//# sourceMappingURL=generators-CPxZOD9U.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CPxZOD9U.cjs","names":["pluginTsName","File","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { usePlugin } from '@kubb/core/hooks'\nimport { Client } from '@kubb/plugin-client/components'\nimport { 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 } from '@kubb/react'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const { options } = usePlugin<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 { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { 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 { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const plugin = usePlugin<PluginMcp>()\n const pluginManager = usePluginManager()\n\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":";;;;;;;;;;;;;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EAAE,8CAAkC;EAC1C,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,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,CAACA,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAA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AAI,KAIT,CACH;IACD;AAEF,SACE,mGACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChF,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAElD,kDAACA,kBAAK;KAAO,MAAM,CAAC,YAAY;KAAE,MAAM;MAA0C;IAClF,kDAACA,kBAAK;KAAO,MAAM,CAAC,uBAAuB;KAAE,MAAM;MAA4C;IAE9F;IACD,kDAACC;KAAa;KAAM,YAAY,IAAI,IAAI,MAAM;KAAO,eAAe,IAAI,YAAY;KAAE,YAAY;MAAoB;;IACjH,EAEP,kDAACD;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,kDAACA,kBAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Server } from "./Server-
|
|
1
|
+
import { t as Server } from "./Server-CKHk0vlR.js";
|
|
2
2
|
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
+
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
5
|
+
import { Client } from "@kubb/plugin-client/components";
|
|
4
6
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
5
7
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
6
|
-
import { File
|
|
7
|
-
import { Client } from "@kubb/plugin-client/components";
|
|
8
|
+
import { File } from "@kubb/react";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
9
10
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ import { pluginZodName } from "@kubb/plugin-zod";
|
|
|
12
13
|
const mcpGenerator = createReactGenerator({
|
|
13
14
|
name: "mcp",
|
|
14
15
|
Operation({ operation }) {
|
|
15
|
-
const {
|
|
16
|
+
const { options } = usePlugin();
|
|
16
17
|
const oas = useOas();
|
|
17
18
|
const { getSchemas, getName, getFile } = useOperationManager();
|
|
18
19
|
const mcp = {
|
|
@@ -108,7 +109,8 @@ const mcpGenerator = createReactGenerator({
|
|
|
108
109
|
const serverGenerator = createReactGenerator({
|
|
109
110
|
name: "operations",
|
|
110
111
|
Operations({ operations, options }) {
|
|
111
|
-
const
|
|
112
|
+
const plugin = usePlugin();
|
|
113
|
+
const pluginManager = usePluginManager();
|
|
112
114
|
const oas = useOas();
|
|
113
115
|
const { getFile, getName, getSchemas } = useOperationManager();
|
|
114
116
|
const name = "server";
|
|
@@ -221,5 +223,5 @@ const serverGenerator = createReactGenerator({
|
|
|
221
223
|
});
|
|
222
224
|
|
|
223
225
|
//#endregion
|
|
224
|
-
export { mcpGenerator, serverGenerator };
|
|
225
|
-
//# sourceMappingURL=generators-
|
|
226
|
+
export { mcpGenerator as n, serverGenerator as t };
|
|
227
|
+
//# sourceMappingURL=generators-Cvzin4vm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-Cvzin4vm.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { usePlugin } from '@kubb/core/hooks'\nimport { Client } from '@kubb/plugin-client/components'\nimport { 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 } from '@kubb/react'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const { options } = usePlugin<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 { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { 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 { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const plugin = usePlugin<PluginMcp>()\n const pluginManager = usePluginManager()\n\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":";;;;;;;;;;;;AASA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EAAE,YAAY,WAAsB;EAC1C,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,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;;IAElD,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB;KAAE,MAAM;KAAmC;MAAa;IAC7F,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ,OAAO;MAAc;IAC/D,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB,sBAAsB;KAAE,MAAM,QAAQ,OAAO;KAAY;MAAa;IAC3G,oBAAC,KAAK;KACJ,MAAM;MACJ,KAAK,QAAQ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EAEP,oBAAC;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,oBAAC,KAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('./Server-AWXKgK_d.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
2
|
+
const require_generators = require('./generators-CPxZOD9U.cjs');
|
|
3
3
|
|
|
4
4
|
exports.mcpGenerator = require_generators.mcpGenerator;
|
|
5
5
|
exports.serverGenerator = require_generators.serverGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Generator } from "./OperationGenerator-
|
|
2
|
-
import { PluginMcp } from "./types-
|
|
1
|
+
import { t as Generator } from "./OperationGenerator-BEQNw2o0.cjs";
|
|
2
|
+
import { n as PluginMcp } from "./types-xkoLaTAL.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: Generator<PluginMcp>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Generator } from "./OperationGenerator-
|
|
2
|
-
import { PluginMcp } from "./types-
|
|
1
|
+
import { t as Generator } from "./OperationGenerator-4XcPTEmW.js";
|
|
2
|
+
import { n as PluginMcp } from "./types-D1ZAplJE.js";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: Generator<PluginMcp>;
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mcpGenerator, serverGenerator } from "./generators-
|
|
2
|
-
import "./Server-
|
|
1
|
+
import { n as mcpGenerator, t as serverGenerator } from "./generators-Cvzin4vm.js";
|
|
2
|
+
import "./Server-CKHk0vlR.js";
|
|
3
3
|
|
|
4
4
|
export { mcpGenerator, serverGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_Server = require('./Server-AWXKgK_d.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
2
|
+
const require_generators = require('./generators-CPxZOD9U.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_Server.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserPluginWithLifeCycle } from "./OperationGenerator-
|
|
2
|
-
import {
|
|
1
|
+
import { p as UserPluginWithLifeCycle } from "./OperationGenerator-BEQNw2o0.cjs";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-xkoLaTAL.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMcpName = "plugin-mcp";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserPluginWithLifeCycle } from "./OperationGenerator-
|
|
2
|
-
import {
|
|
1
|
+
import { p as UserPluginWithLifeCycle } from "./OperationGenerator-4XcPTEmW.js";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-D1ZAplJE.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMcpName = "plugin-mcp";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mcpGenerator, serverGenerator } from "./generators-
|
|
2
|
-
import "./Server-
|
|
1
|
+
import { n as mcpGenerator, t as serverGenerator } from "./generators-Cvzin4vm.js";
|
|
2
|
+
import "./Server-CKHk0vlR.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-4XcPTEmW.js";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
type Options$1 = {
|
|
@@ -164,5 +164,5 @@ type ResolvedOptions = {
|
|
|
164
164
|
};
|
|
165
165
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
166
166
|
//#endregion
|
|
167
|
-
export {
|
|
168
|
-
//# sourceMappingURL=types-
|
|
167
|
+
export { PluginMcp as n, Options as t };
|
|
168
|
+
//# sourceMappingURL=types-D1ZAplJE.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-BEQNw2o0.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
type Options$1 = {
|
|
@@ -164,5 +164,5 @@ type ResolvedOptions = {
|
|
|
164
164
|
};
|
|
165
165
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
166
166
|
//#endregion
|
|
167
|
-
export {
|
|
168
|
-
//# sourceMappingURL=types-
|
|
167
|
+
export { PluginMcp as n, Options as t };
|
|
168
|
+
//# sourceMappingURL=types-xkoLaTAL.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-mcp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Generator mcp",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -62,18 +62,16 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@kubb/core": "4.
|
|
66
|
-
"@kubb/oas": "4.
|
|
67
|
-
"@kubb/plugin-client": "4.
|
|
68
|
-
"@kubb/plugin-oas": "4.
|
|
69
|
-
"@kubb/plugin-ts": "4.
|
|
70
|
-
"@kubb/plugin-zod": "4.
|
|
71
|
-
"@kubb/react": "4.
|
|
65
|
+
"@kubb/core": "4.2.0",
|
|
66
|
+
"@kubb/oas": "4.2.0",
|
|
67
|
+
"@kubb/plugin-client": "4.2.0",
|
|
68
|
+
"@kubb/plugin-oas": "4.2.0",
|
|
69
|
+
"@kubb/plugin-ts": "4.2.0",
|
|
70
|
+
"@kubb/plugin-zod": "4.2.0",
|
|
71
|
+
"@kubb/react": "4.2.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"
|
|
75
|
-
"react": "^18.3.1",
|
|
76
|
-
"tsdown": "^0.15.7",
|
|
74
|
+
"tsdown": "^0.15.9",
|
|
77
75
|
"typescript": "^5.9.3"
|
|
78
76
|
},
|
|
79
77
|
"peerDependencies": {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { usePlugin } from '@kubb/core/hooks'
|
|
2
|
+
import { Client } from '@kubb/plugin-client/components'
|
|
1
3
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
4
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
5
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
4
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
5
|
-
import { File
|
|
7
|
+
import { File } from '@kubb/react'
|
|
6
8
|
import type { PluginMcp } from '../types'
|
|
7
|
-
import { Client } from '@kubb/plugin-client/components'
|
|
8
9
|
|
|
9
10
|
export const mcpGenerator = createReactGenerator<PluginMcp>({
|
|
10
11
|
name: 'mcp',
|
|
11
12
|
Operation({ operation }) {
|
|
12
|
-
const {
|
|
13
|
-
plugin: { options },
|
|
14
|
-
} = useApp<PluginMcp>()
|
|
13
|
+
const { options } = usePlugin<PluginMcp>()
|
|
15
14
|
const oas = useOas()
|
|
16
15
|
const { getSchemas, getName, getFile } = useOperationManager()
|
|
17
16
|
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
1
2
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
3
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
4
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
4
|
-
import {
|
|
5
|
+
import { pluginTsName } from '@kubb/plugin-ts'
|
|
6
|
+
import { pluginZodName } from '@kubb/plugin-zod'
|
|
7
|
+
import { File } from '@kubb/react'
|
|
5
8
|
import { Server } from '../components/Server'
|
|
6
9
|
import type { PluginMcp } from '../types'
|
|
7
|
-
import { pluginZodName } from '@kubb/plugin-zod'
|
|
8
|
-
import { pluginTsName } from '@kubb/plugin-ts'
|
|
9
10
|
|
|
10
11
|
export const serverGenerator = createReactGenerator<PluginMcp>({
|
|
11
12
|
name: 'operations',
|
|
12
13
|
Operations({ operations, options }) {
|
|
13
|
-
const
|
|
14
|
+
const plugin = usePlugin<PluginMcp>()
|
|
15
|
+
const pluginManager = usePluginManager()
|
|
16
|
+
|
|
14
17
|
const oas = useOas()
|
|
15
18
|
const { getFile, getName, getSchemas } = useOperationManager()
|
|
16
19
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-C6GGdP_U.cjs","names":["pluginTsName","File","Client","pluginZodName","pluginTsName","File","Server"],"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,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE,wCACW;EACvB,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,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,CAACA,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,mDAACC;GACC,UAAU,IAAI,KAAK;GACnB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GACf,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;GAClD,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAElD,kDAACA,kBAAK;KAAO,MAAM,CAAC,iBAAiB;KAAE,MAAM;KAAmC;MAAa;IAC7F,kDAACA,kBAA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O,MAAM,CAAC,uBAAuB;KAAE,MAAM;MAA4C;IAE9F;IACD,kDAACC;KAAa;KAAM,YAAY,IAAI,IAAI,MAAM;KAAO,eAAe,IAAI,YAAY;KAAE,YAAY;MAAoB;;IACjH,EAEP,kDAACD;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,kDAACA,kBAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE,cACR,QAAmB;EACvB,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS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