@kubb/plugin-mcp 4.20.2 → 4.20.5

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.
@@ -1,4 +1,4 @@
1
- import { a as OperationSchemas, h as __name } from "./index-CGe1JmIp.cjs";
1
+ import { a as OperationSchemas, u as __name } from "./index-RsNfvceH.cjs";
2
2
  import { KubbFile } from "@kubb/fabric-core/types";
3
3
  import { FabricReactNode } from "@kubb/react-fabric/types";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { a as OperationSchemas } from "./index-D9FArzes.js";
2
+ import { a as OperationSchemas } from "./index-DNBGPN7Z.js";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
  import { FabricReactNode } from "@kubb/react-fabric/types";
5
5
 
@@ -1,5 +1,5 @@
1
- import { h as __name, n as ReactGenerator } from "./index-CGe1JmIp.cjs";
2
- import { n as PluginMcp } from "./types-1i7hEdhc.cjs";
1
+ import { n as ReactGenerator, u as __name } from "./index-RsNfvceH.cjs";
2
+ import { n as PluginMcp } from "./types-CALFhXwx.cjs";
3
3
 
4
4
  //#region src/generators/mcpGenerator.d.ts
5
5
  declare const mcpGenerator: ReactGenerator<PluginMcp>;
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { n as ReactGenerator } from "./index-D9FArzes.js";
3
- import { n as PluginMcp } from "./types-BpFIHuV_.js";
2
+ import { n as ReactGenerator } from "./index-DNBGPN7Z.js";
3
+ import { n as PluginMcp } from "./types-BXH4nmYX.js";
4
4
 
5
5
  //#region src/generators/mcpGenerator.d.ts
6
6
  declare const mcpGenerator: ReactGenerator<PluginMcp>;
@@ -0,0 +1,548 @@
1
+ import { t as __name } from "./chunk-eQyhnF5A.js";
2
+ import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
3
+ import { Fabric } from "@kubb/react-fabric";
4
+ import { KubbFile } from "@kubb/fabric-core/types";
5
+ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
+ import BaseOas from "oas";
7
+ import { Operation } from "oas/operation";
8
+ import { DiscriminatorObject, HttpMethods, OASDocument, SchemaObject } from "oas/types";
9
+ import { FabricReactNode } from "@kubb/react-fabric/types";
10
+
11
+ //#region ../oas/src/types.d.ts
12
+ type contentType = 'application/json' | (string & {});
13
+ type SchemaObject$1 = SchemaObject & {
14
+ 'x-nullable'?: boolean;
15
+ $ref?: string;
16
+ };
17
+ type HttpMethod = HttpMethods;
18
+ type Document = OASDocument;
19
+ type Operation$1 = Operation;
20
+ type DiscriminatorObject$1 = DiscriminatorObject;
21
+ //#endregion
22
+ //#region ../oas/src/Oas.d.ts
23
+ type OasOptions = {
24
+ contentType?: contentType;
25
+ discriminator?: 'strict' | 'inherit';
26
+ /**
27
+ * Resolve name collisions when schemas from different components share the same name (case-insensitive).
28
+ * @default false
29
+ */
30
+ collisionDetection?: boolean;
31
+ };
32
+ declare class Oas extends BaseOas {
33
+ #private;
34
+ document: Document;
35
+ constructor(document: Document);
36
+ setOptions(options: OasOptions): void;
37
+ get options(): OasOptions;
38
+ get<T = unknown>($ref: string): T | null;
39
+ getKey($ref: string): string | undefined;
40
+ set($ref: string, value: unknown): false | undefined;
41
+ getDiscriminator(schema: SchemaObject$1 | null): DiscriminatorObject$1 | null;
42
+ dereferenceWithRef<T = unknown>(schema?: T): T;
43
+ getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
44
+ getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
45
+ getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
46
+ validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
47
+ flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
48
+ /**
49
+ * Get schemas from OpenAPI components (schemas, responses, requestBodies).
50
+ * Returns schemas in dependency order along with name mapping for collision resolution.
51
+ */
52
+ getSchemas(options?: {
53
+ contentType?: contentType;
54
+ includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
55
+ collisionDetection?: boolean;
56
+ }): {
57
+ schemas: Record<string, SchemaObject$1>;
58
+ nameMapping: Map<string, string>;
59
+ };
60
+ }
61
+ //#endregion
62
+ //#region ../core/src/utils/AsyncEventEmitter.d.ts
63
+ declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
64
+ #private;
65
+ constructor(maxListener?: number);
66
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
67
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
68
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
69
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
70
+ removeAll(): void;
71
+ }
72
+ //#endregion
73
+ //#region ../core/src/types.d.ts
74
+ declare global {
75
+ namespace Kubb {
76
+ interface PluginContext {}
77
+ }
78
+ }
79
+ /**
80
+ * Config used in `kubb.config.ts`
81
+ *
82
+ * @example
83
+ * import { defineConfig } from '@kubb/core'
84
+ * export default defineConfig({
85
+ * ...
86
+ * })
87
+ */
88
+ //#endregion
89
+ //#region ../plugin-oas/src/types.d.ts
90
+ type GetOasOptions = {
91
+ validate?: boolean;
92
+ };
93
+ type Context$2 = {
94
+ getOas(options?: GetOasOptions): Promise<Oas>;
95
+ getBaseURL(): Promise<string | undefined>;
96
+ };
97
+ declare global {
98
+ namespace Kubb {
99
+ interface PluginContext extends Context$2 {}
100
+ }
101
+ }
102
+ type ResolvePathOptions = {
103
+ pluginKey?: Plugin['key'];
104
+ group?: {
105
+ tag?: string;
106
+ path?: string;
107
+ };
108
+ type?: ResolveNameParams['type'];
109
+ };
110
+ /**
111
+ * `propertyName` is the ref name + resolved with the nameResolver
112
+ * @example import { Pet } from './Pet'
113
+ *
114
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
115
+ *
116
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
117
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
118
+ */
119
+ type Ref = {
120
+ propertyName: string;
121
+ originalName: string;
122
+ path: KubbFile.Path;
123
+ pluginKey?: Plugin['key'];
124
+ };
125
+ type Refs = Record<string, Ref>;
126
+ type OperationSchema = {
127
+ /**
128
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
129
+ */
130
+ name: string;
131
+ schema: SchemaObject$1;
132
+ operation?: Operation$1;
133
+ /**
134
+ * OperationName in PascalCase, only being used in OperationGenerator
135
+ */
136
+ operationName: string;
137
+ description?: string;
138
+ statusCode?: number;
139
+ keys?: string[];
140
+ keysToOmit?: string[];
141
+ withData?: boolean;
142
+ };
143
+ type OperationSchemas = {
144
+ pathParams?: OperationSchema & {
145
+ keysToOmit?: never;
146
+ };
147
+ queryParams?: OperationSchema & {
148
+ keysToOmit?: never;
149
+ };
150
+ headerParams?: OperationSchema & {
151
+ keysToOmit?: never;
152
+ };
153
+ request?: OperationSchema;
154
+ response: OperationSchema;
155
+ responses: Array<OperationSchema>;
156
+ statusCodes?: Array<OperationSchema>;
157
+ errors?: Array<OperationSchema>;
158
+ };
159
+ type ByTag = {
160
+ type: 'tag';
161
+ pattern: string | RegExp;
162
+ };
163
+ type ByOperationId = {
164
+ type: 'operationId';
165
+ pattern: string | RegExp;
166
+ };
167
+ type ByPath = {
168
+ type: 'path';
169
+ pattern: string | RegExp;
170
+ };
171
+ type ByMethod = {
172
+ type: 'method';
173
+ pattern: HttpMethod | RegExp;
174
+ };
175
+ type BySchemaName = {
176
+ type: 'schemaName';
177
+ pattern: string | RegExp;
178
+ };
179
+ type ByContentType = {
180
+ type: 'contentType';
181
+ pattern: string | RegExp;
182
+ };
183
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
184
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
185
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
186
+ options: Partial<TOptions>;
187
+ };
188
+ //#endregion
189
+ //#region ../plugin-oas/src/OperationGenerator.d.ts
190
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
191
+ fabric: Fabric;
192
+ oas: Oas;
193
+ exclude: Array<Exclude$1> | undefined;
194
+ include: Array<Include> | undefined;
195
+ override: Array<Override<TOptions>> | undefined;
196
+ contentType: contentType | undefined;
197
+ pluginManager: PluginManager;
198
+ events?: AsyncEventEmitter<KubbEvents>;
199
+ /**
200
+ * Current plugin
201
+ */
202
+ plugin: Plugin<TPluginOptions>;
203
+ mode: KubbFile.Mode;
204
+ UNSTABLE_NAMING?: true;
205
+ };
206
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
207
+ #private;
208
+ getOptions(operation: Operation$1, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
209
+ getSchemas(operation: Operation$1, {
210
+ resolveName
211
+ }?: {
212
+ resolveName?: (name: string) => string;
213
+ }): OperationSchemas;
214
+ getOperations(): Promise<Array<{
215
+ path: string;
216
+ method: HttpMethod;
217
+ operation: Operation$1;
218
+ }>>;
219
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
220
+ }
221
+ //#endregion
222
+ //#region ../plugin-oas/src/SchemaMapper.d.ts
223
+ type SchemaKeywordMapper = {
224
+ object: {
225
+ keyword: 'object';
226
+ args: {
227
+ properties: {
228
+ [x: string]: Schema[];
229
+ };
230
+ additionalProperties: Schema[];
231
+ patternProperties?: Record<string, Schema[]>;
232
+ strict?: boolean;
233
+ };
234
+ };
235
+ url: {
236
+ keyword: 'url';
237
+ };
238
+ readOnly: {
239
+ keyword: 'readOnly';
240
+ };
241
+ writeOnly: {
242
+ keyword: 'writeOnly';
243
+ };
244
+ uuid: {
245
+ keyword: 'uuid';
246
+ };
247
+ email: {
248
+ keyword: 'email';
249
+ };
250
+ firstName: {
251
+ keyword: 'firstName';
252
+ };
253
+ lastName: {
254
+ keyword: 'lastName';
255
+ };
256
+ phone: {
257
+ keyword: 'phone';
258
+ };
259
+ password: {
260
+ keyword: 'password';
261
+ };
262
+ date: {
263
+ keyword: 'date';
264
+ args: {
265
+ type?: 'date' | 'string';
266
+ };
267
+ };
268
+ time: {
269
+ keyword: 'time';
270
+ args: {
271
+ type?: 'date' | 'string';
272
+ };
273
+ };
274
+ datetime: {
275
+ keyword: 'datetime';
276
+ args: {
277
+ offset?: boolean;
278
+ local?: boolean;
279
+ };
280
+ };
281
+ tuple: {
282
+ keyword: 'tuple';
283
+ args: {
284
+ items: Schema[];
285
+ min?: number;
286
+ max?: number;
287
+ rest?: Schema;
288
+ };
289
+ };
290
+ array: {
291
+ keyword: 'array';
292
+ args: {
293
+ items: Schema[];
294
+ min?: number;
295
+ max?: number;
296
+ unique?: boolean;
297
+ };
298
+ };
299
+ enum: {
300
+ keyword: 'enum';
301
+ args: {
302
+ name: string;
303
+ typeName: string;
304
+ asConst: boolean;
305
+ items: Array<{
306
+ name: string | number;
307
+ format: 'string' | 'number' | 'boolean';
308
+ value?: string | number | boolean;
309
+ }>;
310
+ };
311
+ };
312
+ and: {
313
+ keyword: 'and';
314
+ args: Schema[];
315
+ };
316
+ const: {
317
+ keyword: 'const';
318
+ args: {
319
+ name: string | number;
320
+ format: 'string' | 'number' | 'boolean';
321
+ value?: string | number | boolean;
322
+ };
323
+ };
324
+ union: {
325
+ keyword: 'union';
326
+ args: Schema[];
327
+ };
328
+ ref: {
329
+ keyword: 'ref';
330
+ args: {
331
+ name: string;
332
+ $ref: string;
333
+ /**
334
+ * Full qualified path.
335
+ */
336
+ path: KubbFile.Path;
337
+ /**
338
+ * When true `File.Import` is used.
339
+ * When false a reference is used inside the current file.
340
+ */
341
+ isImportable: boolean;
342
+ };
343
+ };
344
+ matches: {
345
+ keyword: 'matches';
346
+ args?: string;
347
+ };
348
+ boolean: {
349
+ keyword: 'boolean';
350
+ };
351
+ default: {
352
+ keyword: 'default';
353
+ args: string | number | boolean;
354
+ };
355
+ string: {
356
+ keyword: 'string';
357
+ };
358
+ integer: {
359
+ keyword: 'integer';
360
+ };
361
+ number: {
362
+ keyword: 'number';
363
+ };
364
+ max: {
365
+ keyword: 'max';
366
+ args: number;
367
+ };
368
+ min: {
369
+ keyword: 'min';
370
+ args: number;
371
+ };
372
+ exclusiveMaximum: {
373
+ keyword: 'exclusiveMaximum';
374
+ args: number;
375
+ };
376
+ exclusiveMinimum: {
377
+ keyword: 'exclusiveMinimum';
378
+ args: number;
379
+ };
380
+ describe: {
381
+ keyword: 'describe';
382
+ args: string;
383
+ };
384
+ example: {
385
+ keyword: 'example';
386
+ args: string;
387
+ };
388
+ deprecated: {
389
+ keyword: 'deprecated';
390
+ };
391
+ optional: {
392
+ keyword: 'optional';
393
+ };
394
+ undefined: {
395
+ keyword: 'undefined';
396
+ };
397
+ nullish: {
398
+ keyword: 'nullish';
399
+ };
400
+ nullable: {
401
+ keyword: 'nullable';
402
+ };
403
+ null: {
404
+ keyword: 'null';
405
+ };
406
+ any: {
407
+ keyword: 'any';
408
+ };
409
+ unknown: {
410
+ keyword: 'unknown';
411
+ };
412
+ void: {
413
+ keyword: 'void';
414
+ };
415
+ blob: {
416
+ keyword: 'blob';
417
+ };
418
+ schema: {
419
+ keyword: 'schema';
420
+ args: {
421
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
422
+ format?: string;
423
+ };
424
+ };
425
+ name: {
426
+ keyword: 'name';
427
+ args: string;
428
+ };
429
+ catchall: {
430
+ keyword: 'catchall';
431
+ };
432
+ interface: {
433
+ keyword: 'interface';
434
+ };
435
+ };
436
+ type Schema = {
437
+ keyword: string;
438
+ } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
439
+ //#endregion
440
+ //#region ../plugin-oas/src/SchemaGenerator.d.ts
441
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
442
+ fabric: Fabric;
443
+ oas: Oas;
444
+ pluginManager: PluginManager;
445
+ events?: AsyncEventEmitter<KubbEvents>;
446
+ /**
447
+ * Current plugin
448
+ */
449
+ plugin: Plugin<TPluginOptions>;
450
+ mode: KubbFile.Mode;
451
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
452
+ override: Array<Override<TOptions>> | undefined;
453
+ contentType?: contentType;
454
+ output?: string;
455
+ };
456
+ type SchemaGeneratorOptions = {
457
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
458
+ unknownType: 'any' | 'unknown' | 'void';
459
+ emptySchemaType: 'any' | 'unknown' | 'void';
460
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
461
+ enumSuffix?: string;
462
+ /**
463
+ * @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
464
+ * When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
465
+ * @internal
466
+ */
467
+ usedEnumNames?: Record<string, number>;
468
+ mapper?: Record<string, string>;
469
+ typed?: boolean;
470
+ transformers: {
471
+ /**
472
+ * Customize the names based on the type that is provided by the plugin.
473
+ */
474
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
475
+ /**
476
+ * Receive schema and name(propertyName) and return FakerMeta array
477
+ * TODO TODO add docs
478
+ * @beta
479
+ */
480
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
481
+ };
482
+ };
483
+ type SchemaProps$1 = {
484
+ schema: SchemaObject$1 | null;
485
+ name: string | null;
486
+ parentName: string | null;
487
+ rootName?: string | null;
488
+ };
489
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
490
+ #private;
491
+ refs: Refs;
492
+ /**
493
+ * Creates a type node from a given schema.
494
+ * Delegates to getBaseTypeFromSchema internally and
495
+ * optionally adds a union with null.
496
+ */
497
+ parse(props: SchemaProps$1): Schema[];
498
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
499
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
500
+ static combineObjects(tree: Schema[] | undefined): Schema[];
501
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
502
+ }
503
+ //#endregion
504
+ //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
505
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
506
+ name: string;
507
+ type: 'react';
508
+ Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
509
+ Operation: (props: OperationProps<TOptions>) => FabricReactNode;
510
+ Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
511
+ };
512
+ //#endregion
513
+ //#region ../plugin-oas/src/generators/types.d.ts
514
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
515
+ config: Config;
516
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
517
+ plugin: Plugin<TOptions>;
518
+ operations: Array<Operation$1>;
519
+ };
520
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
521
+ config: Config;
522
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
523
+ plugin: Plugin<TOptions>;
524
+ operation: Operation$1;
525
+ };
526
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
527
+ config: Config;
528
+ generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
529
+ plugin: Plugin<TOptions>;
530
+ schema: {
531
+ name: string;
532
+ tree: Array<Schema>;
533
+ value: SchemaObject$1;
534
+ };
535
+ };
536
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
537
+ //#endregion
538
+ //#region ../plugin-oas/src/generators/createGenerator.d.ts
539
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
540
+ name: string;
541
+ type: 'core';
542
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
543
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
544
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
545
+ };
546
+ //#endregion
547
+ export { OperationSchemas as a, Oas as c, Include as i, contentType as l, ReactGenerator as n, Override as o, Exclude$1 as r, ResolvePathOptions as s, Generator as t };
548
+ //# sourceMappingURL=index-DNBGPN7Z.d.ts.map