@kubb/plugin-mcp 4.5.1 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/{index-BlpJVG8h.d.ts → index-C_nVtJQu.d.cts} +45 -38
- package/dist/{OperationGenerator-Beq8iOZY.d.cts → index-gt-MUKWq.d.ts} +45 -38
- package/dist/index.cjs +6 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -1
- package/dist/{types-Cy3TnfH5.d.ts → types-DJTMVuHu.d.ts} +2 -2
- package/dist/{types-B4xu5uHh.d.cts → types-SQo1omqs.d.cts} +2 -2
- package/package.json +9 -9
- package/src/plugin.ts +7 -10
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
package/dist/generators.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ReactGenerator } from "./
|
|
2
|
-
import { n as PluginMcp } from "./types-
|
|
1
|
+
import { n as ReactGenerator } from "./index-C_nVtJQu.cjs";
|
|
2
|
+
import { n as PluginMcp } from "./types-SQo1omqs.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: ReactGenerator<PluginMcp>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ReactGenerator } from "./index-
|
|
2
|
-
import { n as PluginMcp } from "./types-
|
|
1
|
+
import { n as ReactGenerator } from "./index-gt-MUKWq.js";
|
|
2
|
+
import { n as PluginMcp } from "./types-DJTMVuHu.js";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: ReactGenerator<PluginMcp>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
2
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
import * as OasTypes from "oas/types";
|
|
5
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -75,6 +75,21 @@ type Logger = {
|
|
|
75
75
|
type PossiblePromise<T> = Promise<T> | T;
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region ../core/src/types.d.ts
|
|
78
|
+
declare global {
|
|
79
|
+
namespace Kubb {
|
|
80
|
+
interface PluginContext {}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Config used in `kubb.config.ts`
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* import { defineConfig } from '@kubb/core'
|
|
88
|
+
* export default defineConfig({
|
|
89
|
+
* ...
|
|
90
|
+
* })
|
|
91
|
+
*/
|
|
92
|
+
|
|
78
93
|
type InputPath = {
|
|
79
94
|
/**
|
|
80
95
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -229,11 +244,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
229
244
|
* 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.
|
|
230
245
|
*/
|
|
231
246
|
post?: Array<string>;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} : {
|
|
235
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
236
|
-
});
|
|
247
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
248
|
+
};
|
|
237
249
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
238
250
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
239
251
|
/**
|
|
@@ -259,25 +271,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
259
271
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
260
272
|
*/
|
|
261
273
|
options: TOptions['resolvedOptions'];
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
274
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
277
|
+
*/
|
|
278
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
279
|
+
};
|
|
267
280
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
268
281
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
269
282
|
/**
|
|
270
283
|
* Start of the lifecycle of a plugin.
|
|
271
284
|
* @type hookParallel
|
|
272
285
|
*/
|
|
273
|
-
|
|
286
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
274
287
|
/**
|
|
275
288
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
276
289
|
* Options can als be included.
|
|
277
290
|
* @type hookFirst
|
|
278
291
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
279
292
|
*/
|
|
280
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
293
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
281
294
|
/**
|
|
282
295
|
* Resolve to a name based on a string.
|
|
283
296
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -285,11 +298,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
285
298
|
* @example ('pet') => 'Pet'
|
|
286
299
|
*/
|
|
287
300
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
288
|
-
/**
|
|
289
|
-
* End of the plugin lifecycle.
|
|
290
|
-
* @type hookParallel
|
|
291
|
-
*/
|
|
292
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
293
301
|
};
|
|
294
302
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
295
303
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -316,24 +324,15 @@ type ResolveNameParams = {
|
|
|
316
324
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
317
325
|
fabric: Fabric;
|
|
318
326
|
config: Config;
|
|
319
|
-
/**
|
|
320
|
-
* @deprecated
|
|
321
|
-
*/
|
|
322
|
-
fileManager: FileManager;
|
|
323
327
|
pluginManager: PluginManager;
|
|
324
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
325
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
326
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
328
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
327
329
|
logger: Logger;
|
|
328
|
-
|
|
329
|
-
* All plugins
|
|
330
|
-
*/
|
|
331
|
-
plugins: Plugin[];
|
|
330
|
+
mode: KubbFile.Mode;
|
|
332
331
|
/**
|
|
333
332
|
* Current plugin
|
|
334
333
|
*/
|
|
335
334
|
plugin: Plugin<TOptions>;
|
|
336
|
-
};
|
|
335
|
+
} & Kubb.PluginContext;
|
|
337
336
|
/**
|
|
338
337
|
* Specify the export location for the files and define the behavior of the output
|
|
339
338
|
*/
|
|
@@ -408,13 +407,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
408
407
|
};
|
|
409
408
|
declare class PluginManager {
|
|
410
409
|
#private;
|
|
411
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
412
410
|
readonly events: EventEmitter<Events>;
|
|
413
411
|
readonly config: Config;
|
|
414
412
|
readonly executed: Array<Executer>;
|
|
415
413
|
readonly logger: Logger;
|
|
416
414
|
readonly options: Options$2;
|
|
417
415
|
constructor(config: Config, options: Options$2);
|
|
416
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
417
|
+
get plugins(): Array<Plugin>;
|
|
418
418
|
getFile<TOptions = object>({
|
|
419
419
|
name,
|
|
420
420
|
mode,
|
|
@@ -424,7 +424,7 @@ declare class PluginManager {
|
|
|
424
424
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
425
425
|
pluginKey: Plugin['key'];
|
|
426
426
|
}>;
|
|
427
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
427
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
428
428
|
resolveName: (params: ResolveNameParams) => string;
|
|
429
429
|
/**
|
|
430
430
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -512,11 +512,9 @@ declare class PluginManager {
|
|
|
512
512
|
}): Promise<void>;
|
|
513
513
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
514
514
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
515
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
516
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
517
515
|
}
|
|
518
516
|
//#endregion
|
|
519
|
-
//#region ../core/src/
|
|
517
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
520
518
|
type FileMetaBase = {
|
|
521
519
|
pluginKey?: Plugin['key'];
|
|
522
520
|
};
|
|
@@ -669,7 +667,7 @@ type SchemaKeywordMapper = {
|
|
|
669
667
|
/**
|
|
670
668
|
* Full qualified path.
|
|
671
669
|
*/
|
|
672
|
-
path: KubbFile.
|
|
670
|
+
path: KubbFile.Path;
|
|
673
671
|
/**
|
|
674
672
|
* When true `File.Import` will be used.
|
|
675
673
|
* When false a reference will be used inside the current file.
|
|
@@ -774,6 +772,15 @@ type Schema = {
|
|
|
774
772
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
775
773
|
//#endregion
|
|
776
774
|
//#region ../plugin-oas/src/types.d.ts
|
|
775
|
+
type Context$2 = {
|
|
776
|
+
getOas(): Promise<Oas>;
|
|
777
|
+
getBaseURL(): Promise<string | undefined>;
|
|
778
|
+
};
|
|
779
|
+
declare global {
|
|
780
|
+
namespace Kubb {
|
|
781
|
+
interface PluginContext extends Context$2 {}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
777
784
|
type ResolvePathOptions = {
|
|
778
785
|
pluginKey?: Plugin['key'];
|
|
779
786
|
group?: {
|
|
@@ -794,7 +801,7 @@ type ResolvePathOptions = {
|
|
|
794
801
|
type Ref = {
|
|
795
802
|
propertyName: string;
|
|
796
803
|
originalName: string;
|
|
797
|
-
path: KubbFile.
|
|
804
|
+
path: KubbFile.Path;
|
|
798
805
|
pluginKey?: Plugin['key'];
|
|
799
806
|
};
|
|
800
807
|
type Refs = Record<string, Ref>;
|
|
@@ -992,4 +999,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
992
999
|
}
|
|
993
1000
|
//#endregion
|
|
994
1001
|
export { OperationSchemas as a, Oas as c, Output as d, PluginFactoryOptions as f, Include as i, contentType as l, UserPluginWithLifeCycle as m, ReactGenerator as n, Override as o, ResolveNameParams as p, Exclude$1 as r, ResolvePathOptions as s, Generator as t, Group as u };
|
|
995
|
-
//# sourceMappingURL=index-
|
|
1002
|
+
//# sourceMappingURL=index-C_nVtJQu.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
1
2
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
import * as OasTypes from "oas/types";
|
|
5
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -75,6 +75,21 @@ type Logger = {
|
|
|
75
75
|
type PossiblePromise<T> = Promise<T> | T;
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region ../core/src/types.d.ts
|
|
78
|
+
declare global {
|
|
79
|
+
namespace Kubb {
|
|
80
|
+
interface PluginContext {}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Config used in `kubb.config.ts`
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* import { defineConfig } from '@kubb/core'
|
|
88
|
+
* export default defineConfig({
|
|
89
|
+
* ...
|
|
90
|
+
* })
|
|
91
|
+
*/
|
|
92
|
+
|
|
78
93
|
type InputPath = {
|
|
79
94
|
/**
|
|
80
95
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -229,11 +244,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
229
244
|
* 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.
|
|
230
245
|
*/
|
|
231
246
|
post?: Array<string>;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} : {
|
|
235
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
236
|
-
});
|
|
247
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
248
|
+
};
|
|
237
249
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
238
250
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
239
251
|
/**
|
|
@@ -259,25 +271,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
259
271
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
260
272
|
*/
|
|
261
273
|
options: TOptions['resolvedOptions'];
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
274
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
277
|
+
*/
|
|
278
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
279
|
+
};
|
|
267
280
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
268
281
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
269
282
|
/**
|
|
270
283
|
* Start of the lifecycle of a plugin.
|
|
271
284
|
* @type hookParallel
|
|
272
285
|
*/
|
|
273
|
-
|
|
286
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
274
287
|
/**
|
|
275
288
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
276
289
|
* Options can als be included.
|
|
277
290
|
* @type hookFirst
|
|
278
291
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
279
292
|
*/
|
|
280
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
293
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
281
294
|
/**
|
|
282
295
|
* Resolve to a name based on a string.
|
|
283
296
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -285,11 +298,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
285
298
|
* @example ('pet') => 'Pet'
|
|
286
299
|
*/
|
|
287
300
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
288
|
-
/**
|
|
289
|
-
* End of the plugin lifecycle.
|
|
290
|
-
* @type hookParallel
|
|
291
|
-
*/
|
|
292
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
293
301
|
};
|
|
294
302
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
295
303
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -316,24 +324,15 @@ type ResolveNameParams = {
|
|
|
316
324
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
317
325
|
fabric: Fabric;
|
|
318
326
|
config: Config;
|
|
319
|
-
/**
|
|
320
|
-
* @deprecated
|
|
321
|
-
*/
|
|
322
|
-
fileManager: FileManager;
|
|
323
327
|
pluginManager: PluginManager;
|
|
324
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
325
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
326
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
328
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
327
329
|
logger: Logger;
|
|
328
|
-
|
|
329
|
-
* All plugins
|
|
330
|
-
*/
|
|
331
|
-
plugins: Plugin[];
|
|
330
|
+
mode: KubbFile.Mode;
|
|
332
331
|
/**
|
|
333
332
|
* Current plugin
|
|
334
333
|
*/
|
|
335
334
|
plugin: Plugin<TOptions>;
|
|
336
|
-
};
|
|
335
|
+
} & Kubb.PluginContext;
|
|
337
336
|
/**
|
|
338
337
|
* Specify the export location for the files and define the behavior of the output
|
|
339
338
|
*/
|
|
@@ -408,13 +407,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
408
407
|
};
|
|
409
408
|
declare class PluginManager {
|
|
410
409
|
#private;
|
|
411
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
412
410
|
readonly events: EventEmitter<Events>;
|
|
413
411
|
readonly config: Config;
|
|
414
412
|
readonly executed: Array<Executer>;
|
|
415
413
|
readonly logger: Logger;
|
|
416
414
|
readonly options: Options$2;
|
|
417
415
|
constructor(config: Config, options: Options$2);
|
|
416
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
417
|
+
get plugins(): Array<Plugin>;
|
|
418
418
|
getFile<TOptions = object>({
|
|
419
419
|
name,
|
|
420
420
|
mode,
|
|
@@ -424,7 +424,7 @@ declare class PluginManager {
|
|
|
424
424
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
425
425
|
pluginKey: Plugin['key'];
|
|
426
426
|
}>;
|
|
427
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
427
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
428
428
|
resolveName: (params: ResolveNameParams) => string;
|
|
429
429
|
/**
|
|
430
430
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -512,11 +512,9 @@ declare class PluginManager {
|
|
|
512
512
|
}): Promise<void>;
|
|
513
513
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
514
514
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
515
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
516
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
517
515
|
}
|
|
518
516
|
//#endregion
|
|
519
|
-
//#region ../core/src/
|
|
517
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
520
518
|
type FileMetaBase = {
|
|
521
519
|
pluginKey?: Plugin['key'];
|
|
522
520
|
};
|
|
@@ -669,7 +667,7 @@ type SchemaKeywordMapper = {
|
|
|
669
667
|
/**
|
|
670
668
|
* Full qualified path.
|
|
671
669
|
*/
|
|
672
|
-
path: KubbFile.
|
|
670
|
+
path: KubbFile.Path;
|
|
673
671
|
/**
|
|
674
672
|
* When true `File.Import` will be used.
|
|
675
673
|
* When false a reference will be used inside the current file.
|
|
@@ -774,6 +772,15 @@ type Schema = {
|
|
|
774
772
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
775
773
|
//#endregion
|
|
776
774
|
//#region ../plugin-oas/src/types.d.ts
|
|
775
|
+
type Context$2 = {
|
|
776
|
+
getOas(): Promise<Oas>;
|
|
777
|
+
getBaseURL(): Promise<string | undefined>;
|
|
778
|
+
};
|
|
779
|
+
declare global {
|
|
780
|
+
namespace Kubb {
|
|
781
|
+
interface PluginContext extends Context$2 {}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
777
784
|
type ResolvePathOptions = {
|
|
778
785
|
pluginKey?: Plugin['key'];
|
|
779
786
|
group?: {
|
|
@@ -794,7 +801,7 @@ type ResolvePathOptions = {
|
|
|
794
801
|
type Ref = {
|
|
795
802
|
propertyName: string;
|
|
796
803
|
originalName: string;
|
|
797
|
-
path: KubbFile.
|
|
804
|
+
path: KubbFile.Path;
|
|
798
805
|
pluginKey?: Plugin['key'];
|
|
799
806
|
};
|
|
800
807
|
type Refs = Record<string, Ref>;
|
|
@@ -992,4 +999,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
992
999
|
}
|
|
993
1000
|
//#endregion
|
|
994
1001
|
export { OperationSchemas as a, Oas as c, Output as d, PluginFactoryOptions as f, Include as i, contentType as l, UserPluginWithLifeCycle as m, ReactGenerator as n, Override as o, ResolveNameParams as p, Exclude$1 as r, ResolvePathOptions as s, Generator as t, Group as u };
|
|
995
|
-
//# sourceMappingURL=
|
|
1002
|
+
//# sourceMappingURL=index-gt-MUKWq.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ __kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
|
|
|
17
17
|
|
|
18
18
|
//#region src/plugin.ts
|
|
19
19
|
const pluginMcpName = "plugin-mcp";
|
|
20
|
-
const pluginMcp = (0, __kubb_core.
|
|
20
|
+
const pluginMcp = (0, __kubb_core.definePlugin)((options) => {
|
|
21
21
|
const { output = {
|
|
22
22
|
path: "mcp",
|
|
23
23
|
barrelType: "named"
|
|
@@ -60,14 +60,13 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
|
|
|
60
60
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
61
61
|
return resolvedName;
|
|
62
62
|
},
|
|
63
|
-
async
|
|
64
|
-
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
65
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
63
|
+
async install() {
|
|
66
64
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
67
65
|
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
68
|
-
const
|
|
66
|
+
const oas = await this.getOas();
|
|
67
|
+
const baseURL = await this.getBaseURL();
|
|
69
68
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
70
|
-
const containsFetcher = this.
|
|
69
|
+
const containsFetcher = this.fabric.files.some((file) => file.baseName === "fetcher.ts");
|
|
71
70
|
if (!this.plugin.options.client.importPath && !containsFetcher) await this.addFile({
|
|
72
71
|
baseName: "fetcher.ts",
|
|
73
72
|
path: node_path.default.resolve(root, ".kubb/fetcher.ts"),
|
|
@@ -88,7 +87,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
|
|
|
88
87
|
mode
|
|
89
88
|
}).build(...generators);
|
|
90
89
|
await this.addFile(...files);
|
|
91
|
-
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.
|
|
90
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
92
91
|
type: output.barrelType ?? "named",
|
|
93
92
|
root,
|
|
94
93
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: 'axios',\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const containsFetcher = this.fabric.files.some((file) => file.baseName === 'fetcher.ts')\n\n if (!this.plugin.options.client.importPath && !containsFetcher) {\n // pre add bundled fetcher\n await this.addFile({\n baseName: 'fetcher.ts',\n path: path.resolve(root, '.kubb/fetcher.ts'),\n sources: [\n {\n name: 'fetcher',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,iCAAcC,mCAAgB,CAAC,OAAO,QAAQ,EAC5D,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,QAAQ;IACR,gBAAgB;IAChB,GAAG,QAAQ;IACZ;GACF;EACD,KAAK;GAACC;GAAeC;GAAcC;GAAc,CAAC,OAAO,QAAQ;EACjE,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,qCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUC,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,2CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASC,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOD,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAC/B,MAAM,UAAU,MAAM,KAAK,YAAY;AAEvC,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAGvC,MAAM,kBAAkB,KAAK,OAAO,MAAM,MAAM,SAAS,KAAK,aAAa,aAAa;AAExF,OAAI,CAAC,KAAK,OAAO,QAAQ,OAAO,cAAc,CAAC,gBAE7C,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMA,kBAAK,QAAQ,MAAM,mBAAmB;IAC5C,SAAS,CACP;KACE,MAAM;KACN,kDACE,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACH,CACF;IACF,CAAC;GAeJ,MAAM,QAAQ,MAZa,IAAIG,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as UserPluginWithLifeCycle } from "./
|
|
2
|
-
import { n as PluginMcp, t as Options } from "./types-
|
|
1
|
+
import { m as UserPluginWithLifeCycle } from "./index-C_nVtJQu.cjs";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-SQo1omqs.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 { m as UserPluginWithLifeCycle } from "./index-
|
|
2
|
-
import { n as PluginMcp, t as Options } from "./types-
|
|
1
|
+
import { m as UserPluginWithLifeCycle } from "./index-gt-MUKWq.js";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-DJTMVuHu.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMcpName = "plugin-mcp";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as mcpGenerator, t as serverGenerator } from "./generators-DP6UAisL.js";
|
|
2
2
|
import "./Server-DMDo69md.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { resolveModuleSource } from "@kubb/core/utils";
|
|
7
7
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
@@ -10,7 +10,7 @@ import { pluginZodName } from "@kubb/plugin-zod";
|
|
|
10
10
|
|
|
11
11
|
//#region src/plugin.ts
|
|
12
12
|
const pluginMcpName = "plugin-mcp";
|
|
13
|
-
const pluginMcp =
|
|
13
|
+
const pluginMcp = definePlugin((options) => {
|
|
14
14
|
const { output = {
|
|
15
15
|
path: "mcp",
|
|
16
16
|
barrelType: "named"
|
|
@@ -53,14 +53,13 @@ const pluginMcp = createPlugin((options) => {
|
|
|
53
53
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
54
54
|
return resolvedName;
|
|
55
55
|
},
|
|
56
|
-
async
|
|
57
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
58
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
56
|
+
async install() {
|
|
59
57
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
60
58
|
const mode = getMode(path.resolve(root, output.path));
|
|
61
|
-
const
|
|
59
|
+
const oas = await this.getOas();
|
|
60
|
+
const baseURL = await this.getBaseURL();
|
|
62
61
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
63
|
-
const containsFetcher = this.
|
|
62
|
+
const containsFetcher = this.fabric.files.some((file) => file.baseName === "fetcher.ts");
|
|
64
63
|
if (!this.plugin.options.client.importPath && !containsFetcher) await this.addFile({
|
|
65
64
|
baseName: "fetcher.ts",
|
|
66
65
|
path: path.resolve(root, ".kubb/fetcher.ts"),
|
|
@@ -81,7 +80,7 @@ const pluginMcp = createPlugin((options) => {
|
|
|
81
80
|
mode
|
|
82
81
|
}).build(...generators);
|
|
83
82
|
await this.addFile(...files);
|
|
84
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
83
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
85
84
|
type: output.barrelType ?? "named",
|
|
86
85
|
root,
|
|
87
86
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: 'axios',\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const containsFetcher = this.fabric.files.some((file) => file.baseName === 'fetcher.ts')\n\n if (!this.plugin.options.client.importPath && !containsFetcher) {\n // pre add bundled fetcher\n await this.addFile({\n baseName: 'fetcher.ts',\n path: path.resolve(root, '.kubb/fetcher.ts'),\n sources: [\n {\n name: 'fetcher',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,cAAc,gBAAgB,CAAC,OAAO,QAAQ,EAC5D,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,QAAQ;IACR,gBAAgB;IAChB,GAAG,QAAQ;IACZ;GACF;EACD,KAAK;GAAC;GAAe;GAAc;GAAc,CAAC,OAAO,QAAQ;EACjE,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAC/B,MAAM,UAAU,MAAM,KAAK,YAAY;AAEvC,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAGvC,MAAM,kBAAkB,KAAK,OAAO,MAAM,MAAM,SAAS,KAAK,aAAa,aAAa;AAExF,OAAI,CAAC,KAAK,OAAO,QAAQ,OAAO,cAAc,CAAC,gBAE7C,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,mBAAmB;IAC5C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBACL,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACH,CACF;IACF,CAAC;GAeJ,MAAM,QAAQ,MAZa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-
|
|
1
|
+
import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-gt-MUKWq.js";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
|
|
@@ -164,4 +164,4 @@ type ResolvedOptions = {
|
|
|
164
164
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
165
165
|
//#endregion
|
|
166
166
|
export { PluginMcp as n, Options as t };
|
|
167
|
-
//# sourceMappingURL=types-
|
|
167
|
+
//# sourceMappingURL=types-DJTMVuHu.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./
|
|
1
|
+
import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-C_nVtJQu.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
|
|
@@ -164,4 +164,4 @@ type ResolvedOptions = {
|
|
|
164
164
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
165
165
|
//#endregion
|
|
166
166
|
export { PluginMcp as n, Options as t };
|
|
167
|
-
//# sourceMappingURL=types-
|
|
167
|
+
//# sourceMappingURL=types-SQo1omqs.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-mcp",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"description": "Generator mcp",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
}
|
|
70
70
|
],
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@kubb/react-fabric": "0.2.
|
|
73
|
-
"@kubb/core": "4.5.
|
|
74
|
-
"@kubb/
|
|
75
|
-
"@kubb/plugin-
|
|
76
|
-
"@kubb/plugin-
|
|
77
|
-
"@kubb/plugin-
|
|
78
|
-
"@kubb/
|
|
72
|
+
"@kubb/react-fabric": "0.2.19",
|
|
73
|
+
"@kubb/core": "4.5.2",
|
|
74
|
+
"@kubb/plugin-client": "4.5.2",
|
|
75
|
+
"@kubb/plugin-oas": "4.5.2",
|
|
76
|
+
"@kubb/plugin-ts": "4.5.2",
|
|
77
|
+
"@kubb/plugin-zod": "4.5.2",
|
|
78
|
+
"@kubb/oas": "4.5.2"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react-fabric": "0.2.
|
|
82
|
+
"@kubb/react-fabric": "0.2.19"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
package/src/plugin.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
2
|
+
import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
|
|
3
3
|
import { camelCase } from '@kubb/core/transformers'
|
|
4
4
|
import { resolveModuleSource } from '@kubb/core/utils'
|
|
5
|
-
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
6
5
|
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
7
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
8
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
@@ -11,7 +10,7 @@ import type { PluginMcp } from './types.ts'
|
|
|
11
10
|
|
|
12
11
|
export const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']
|
|
13
12
|
|
|
14
|
-
export const pluginMcp =
|
|
13
|
+
export const pluginMcp = definePlugin<PluginMcp>((options) => {
|
|
15
14
|
const {
|
|
16
15
|
output = { path: 'mcp', barrelType: 'named' },
|
|
17
16
|
group,
|
|
@@ -80,19 +79,17 @@ export const pluginMcp = createPlugin<PluginMcp>((options) => {
|
|
|
80
79
|
|
|
81
80
|
return resolvedName
|
|
82
81
|
},
|
|
83
|
-
async
|
|
84
|
-
const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
|
|
85
|
-
|
|
86
|
-
const oas = await swaggerPlugin.context.getOas()
|
|
82
|
+
async install() {
|
|
87
83
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
88
84
|
const mode = getMode(path.resolve(root, output.path))
|
|
89
|
-
const
|
|
85
|
+
const oas = await this.getOas()
|
|
86
|
+
const baseURL = await this.getBaseURL()
|
|
90
87
|
|
|
91
88
|
if (baseURL) {
|
|
92
89
|
this.plugin.options.client.baseURL = baseURL
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
const containsFetcher = this.
|
|
92
|
+
const containsFetcher = this.fabric.files.some((file) => file.baseName === 'fetcher.ts')
|
|
96
93
|
|
|
97
94
|
if (!this.plugin.options.client.importPath && !containsFetcher) {
|
|
98
95
|
// pre add bundled fetcher
|
|
@@ -125,7 +122,7 @@ export const pluginMcp = createPlugin<PluginMcp>((options) => {
|
|
|
125
122
|
const files = await operationGenerator.build(...generators)
|
|
126
123
|
await this.addFile(...files)
|
|
127
124
|
|
|
128
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
125
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
129
126
|
type: output.barrelType ?? 'named',
|
|
130
127
|
root,
|
|
131
128
|
output,
|