@kubb/plugin-mcp 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OperationGenerator-Bq_OAgZR.d.cts → SchemaGenerator-C1vgcKII.d.cts} +220 -201
- package/dist/{OperationGenerator-CVN32WMS.d.ts → SchemaGenerator-wXj7HtlS.d.ts} +225 -206
- package/dist/{Server-CKHk0vlR.js → Server-DMDo69md.js} +3 -3
- package/dist/Server-DMDo69md.js.map +1 -0
- package/dist/{Server-AWXKgK_d.cjs → Server-vKCXRjmg.cjs} +8 -8
- package/dist/Server-vKCXRjmg.cjs.map +1 -0
- package/dist/chunk-DMmIE7y6.js +28 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +3 -2
- package/dist/components.d.ts +3 -2
- package/dist/components.js +1 -1
- package/dist/{generators-naBCKi9F.cjs → generators-8HowWmDg.cjs} +20 -20
- package/dist/generators-8HowWmDg.cjs.map +1 -0
- package/dist/{generators-zuKj-GtG.js → generators-Bp0d1HbP.js} +4 -4
- package/dist/generators-Bp0d1HbP.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +3 -2
- 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 +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-BtZpMsBD.d.ts → types-3zb5y21F.d.cts} +2 -2
- package/dist/{types-Dr8_aqGF.d.cts → types-b6nPxXzv.d.ts} +2 -2
- package/package.json +10 -10
- package/src/components/Server.tsx +3 -2
- package/src/generators/mcpGenerator.tsx +1 -1
- package/src/generators/serverGenerator.tsx +1 -1
- package/src/plugin.ts +1 -0
- package/src/types.ts +2 -2
- package/dist/Server-AWXKgK_d.cjs.map +0 -1
- package/dist/Server-CKHk0vlR.js.map +0 -1
- package/dist/generators-naBCKi9F.cjs.map +0 -1
- package/dist/generators-zuKj-GtG.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
2
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
1
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
|
-
import { FileManager } from "@kubb/fabric-core";
|
|
3
4
|
import * as OasTypes from "oas/types";
|
|
4
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
5
6
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -8,7 +9,7 @@ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
|
8
9
|
import BaseOas from "oas";
|
|
9
10
|
|
|
10
11
|
//#region ../core/src/fs/types.d.ts
|
|
11
|
-
type BasePath<T
|
|
12
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
12
13
|
type Import = {
|
|
13
14
|
/**
|
|
14
15
|
* Import name to be used
|
|
@@ -82,7 +83,7 @@ type BaseName = `${string}.${string}`;
|
|
|
82
83
|
* Path will be full qualified path to a specified file
|
|
83
84
|
*/
|
|
84
85
|
type Path = string;
|
|
85
|
-
type AdvancedPath<T
|
|
86
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
86
87
|
type OptionalPath = Path | undefined | null;
|
|
87
88
|
type File<TMeta extends object = object> = {
|
|
88
89
|
/**
|
|
@@ -127,12 +128,12 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
|
127
128
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
128
129
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
129
130
|
*/
|
|
130
|
-
declare abstract class BaseGenerator<TOptions
|
|
131
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
131
132
|
#private;
|
|
132
|
-
constructor(options?: TOptions
|
|
133
|
-
get options(): TOptions
|
|
133
|
+
constructor(options?: TOptions, context?: TContext);
|
|
134
|
+
get options(): TOptions;
|
|
134
135
|
get context(): TContext;
|
|
135
|
-
set options(options: TOptions
|
|
136
|
+
set options(options: TOptions);
|
|
136
137
|
abstract build(...params: unknown[]): unknown;
|
|
137
138
|
}
|
|
138
139
|
//#endregion
|
|
@@ -185,7 +186,7 @@ type Logger = {
|
|
|
185
186
|
};
|
|
186
187
|
//#endregion
|
|
187
188
|
//#region ../core/src/utils/types.d.ts
|
|
188
|
-
type PossiblePromise<T
|
|
189
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
189
190
|
//#endregion
|
|
190
191
|
//#region ../core/src/types.d.ts
|
|
191
192
|
type InputPath = {
|
|
@@ -298,11 +299,11 @@ TName extends string = string,
|
|
|
298
299
|
/**
|
|
299
300
|
* Options of the plugin.
|
|
300
301
|
*/
|
|
301
|
-
TOptions
|
|
302
|
+
TOptions extends object = object,
|
|
302
303
|
/**
|
|
303
304
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
304
305
|
*/
|
|
305
|
-
TResolvedOptions extends object = TOptions
|
|
306
|
+
TResolvedOptions extends object = TOptions,
|
|
306
307
|
/**
|
|
307
308
|
* Context that you want to expose to other plugins.
|
|
308
309
|
*/
|
|
@@ -316,23 +317,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
316
317
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
317
318
|
*/
|
|
318
319
|
key: PluginKey<TName | string>;
|
|
319
|
-
options: TOptions
|
|
320
|
+
options: TOptions;
|
|
320
321
|
resolvedOptions: TResolvedOptions;
|
|
321
322
|
context: TContext;
|
|
322
323
|
resolvePathOptions: TResolvePathOptions;
|
|
323
324
|
};
|
|
324
325
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
325
|
-
type UserPlugin<TOptions
|
|
326
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
326
327
|
/**
|
|
327
328
|
* Unique name used for the plugin
|
|
328
329
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
329
330
|
* @example @kubb/typescript
|
|
330
331
|
*/
|
|
331
|
-
name: TOptions
|
|
332
|
+
name: TOptions['name'];
|
|
332
333
|
/**
|
|
333
334
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
334
335
|
*/
|
|
335
|
-
options: TOptions
|
|
336
|
+
options: TOptions['resolvedOptions'];
|
|
336
337
|
/**
|
|
337
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.
|
|
338
339
|
* Can be used to validate dependent plugins.
|
|
@@ -342,23 +343,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
342
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.
|
|
343
344
|
*/
|
|
344
345
|
post?: Array<string>;
|
|
345
|
-
} & (TOptions
|
|
346
|
+
} & (TOptions['context'] extends never ? {
|
|
346
347
|
context?: never;
|
|
347
348
|
} : {
|
|
348
|
-
context: (this: TOptions
|
|
349
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
349
350
|
});
|
|
350
|
-
type UserPluginWithLifeCycle<TOptions
|
|
351
|
-
type Plugin<TOptions
|
|
351
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
352
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
352
353
|
/**
|
|
353
354
|
* Unique name used for the plugin
|
|
354
355
|
* @example @kubb/typescript
|
|
355
356
|
*/
|
|
356
|
-
name: TOptions
|
|
357
|
+
name: TOptions['name'];
|
|
357
358
|
/**
|
|
358
359
|
* Internal key used when a developer uses more than one of the same plugin
|
|
359
360
|
* @private
|
|
360
361
|
*/
|
|
361
|
-
key: TOptions
|
|
362
|
+
key: TOptions['key'];
|
|
362
363
|
/**
|
|
363
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.
|
|
364
365
|
* Can be used to validate dependent plugins.
|
|
@@ -371,49 +372,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
371
372
|
/**
|
|
372
373
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
373
374
|
*/
|
|
374
|
-
options: TOptions
|
|
375
|
-
} & (TOptions
|
|
375
|
+
options: TOptions['resolvedOptions'];
|
|
376
|
+
} & (TOptions['context'] extends never ? {
|
|
376
377
|
context?: never;
|
|
377
378
|
} : {
|
|
378
|
-
context: TOptions
|
|
379
|
+
context: TOptions['context'];
|
|
379
380
|
});
|
|
380
|
-
type PluginWithLifeCycle<TOptions
|
|
381
|
-
type PluginLifecycle<TOptions
|
|
381
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
382
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
382
383
|
/**
|
|
383
384
|
* Start of the lifecycle of a plugin.
|
|
384
385
|
* @type hookParallel
|
|
385
386
|
*/
|
|
386
|
-
buildStart?: (this: PluginContext<TOptions
|
|
387
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
387
388
|
/**
|
|
388
389
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
389
390
|
* Options can als be included.
|
|
390
391
|
* @type hookFirst
|
|
391
392
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
392
393
|
*/
|
|
393
|
-
resolvePath?: (this: PluginContext<TOptions
|
|
394
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
394
395
|
/**
|
|
395
396
|
* Resolve to a name based on a string.
|
|
396
397
|
* Useful when converting to PascalCase or camelCase.
|
|
397
398
|
* @type hookFirst
|
|
398
399
|
* @example ('pet') => 'Pet'
|
|
399
400
|
*/
|
|
400
|
-
resolveName?: (this: PluginContext<TOptions
|
|
401
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
401
402
|
/**
|
|
402
403
|
* End of the plugin lifecycle.
|
|
403
404
|
* @type hookParallel
|
|
404
405
|
*/
|
|
405
|
-
buildEnd?: (this: PluginContext<TOptions
|
|
406
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
406
407
|
};
|
|
407
408
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
408
|
-
type PluginParameter<H
|
|
409
|
-
type ResolvePathParams<TOptions
|
|
409
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
410
|
+
type ResolvePathParams<TOptions = object> = {
|
|
410
411
|
pluginKey?: Plugin['key'];
|
|
411
412
|
baseName: BaseName;
|
|
412
413
|
mode?: Mode;
|
|
413
414
|
/**
|
|
414
415
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
415
416
|
*/
|
|
416
|
-
options?: TOptions
|
|
417
|
+
options?: TOptions;
|
|
417
418
|
};
|
|
418
419
|
type ResolveNameParams = {
|
|
419
420
|
name: string;
|
|
@@ -426,7 +427,8 @@ type ResolveNameParams = {
|
|
|
426
427
|
*/
|
|
427
428
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
428
429
|
};
|
|
429
|
-
type PluginContext<TOptions
|
|
430
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
431
|
+
fabric: Fabric;
|
|
430
432
|
config: Config;
|
|
431
433
|
/**
|
|
432
434
|
* @deprecated
|
|
@@ -434,7 +436,7 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
434
436
|
fileManager: FileManager;
|
|
435
437
|
pluginManager: PluginManager;
|
|
436
438
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
437
|
-
resolvePath: (params: ResolvePathParams<TOptions
|
|
439
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
438
440
|
resolveName: (params: ResolveNameParams) => string;
|
|
439
441
|
logger: Logger;
|
|
440
442
|
/**
|
|
@@ -444,12 +446,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
444
446
|
/**
|
|
445
447
|
* Current plugin
|
|
446
448
|
*/
|
|
447
|
-
plugin: Plugin<TOptions
|
|
449
|
+
plugin: Plugin<TOptions>;
|
|
448
450
|
};
|
|
449
451
|
/**
|
|
450
452
|
* Specify the export location for the files and define the behavior of the output
|
|
451
453
|
*/
|
|
452
|
-
type Output<TOptions
|
|
454
|
+
type Output<TOptions> = {
|
|
453
455
|
/**
|
|
454
456
|
* Path to the output folder or file that will contain the generated code
|
|
455
457
|
*/
|
|
@@ -462,11 +464,11 @@ type Output<TOptions$1> = {
|
|
|
462
464
|
/**
|
|
463
465
|
* Add a banner text in the beginning of every file
|
|
464
466
|
*/
|
|
465
|
-
banner?: string | ((options: TOptions
|
|
467
|
+
banner?: string | ((options: TOptions) => string);
|
|
466
468
|
/**
|
|
467
469
|
* Add a footer text in the beginning of every file
|
|
468
470
|
*/
|
|
469
|
-
footer?: string | ((options: TOptions
|
|
471
|
+
footer?: string | ((options: TOptions) => string);
|
|
470
472
|
};
|
|
471
473
|
type GroupContext = {
|
|
472
474
|
group: string;
|
|
@@ -485,20 +487,21 @@ type Group = {
|
|
|
485
487
|
//#region ../core/src/PluginManager.d.ts
|
|
486
488
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
487
489
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
488
|
-
type Executer<H
|
|
490
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
489
491
|
message: string;
|
|
490
492
|
strategy: Strategy;
|
|
491
|
-
hookName: H
|
|
493
|
+
hookName: H;
|
|
492
494
|
plugin: Plugin;
|
|
493
495
|
parameters?: unknown[] | undefined;
|
|
494
496
|
output?: unknown;
|
|
495
497
|
};
|
|
496
|
-
type ParseResult<H
|
|
497
|
-
type SafeParseResult<H
|
|
498
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
499
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
498
500
|
result: Result;
|
|
499
501
|
plugin: Plugin;
|
|
500
502
|
};
|
|
501
503
|
type Options$2 = {
|
|
504
|
+
fabric: Fabric;
|
|
502
505
|
logger: Logger;
|
|
503
506
|
/**
|
|
504
507
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -510,20 +513,16 @@ type Events = {
|
|
|
510
513
|
executed: [executer: Executer];
|
|
511
514
|
error: [error: Error];
|
|
512
515
|
};
|
|
513
|
-
type GetFileProps<TOptions
|
|
516
|
+
type GetFileProps<TOptions = object> = {
|
|
514
517
|
name: string;
|
|
515
518
|
mode?: Mode;
|
|
516
519
|
extname: Extname;
|
|
517
520
|
pluginKey: Plugin['key'];
|
|
518
|
-
options?: TOptions
|
|
521
|
+
options?: TOptions;
|
|
519
522
|
};
|
|
520
523
|
declare class PluginManager {
|
|
521
524
|
#private;
|
|
522
525
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
523
|
-
/**
|
|
524
|
-
* @deprecated do not use from pluginManager
|
|
525
|
-
*/
|
|
526
|
-
readonly fileManager: FileManager;
|
|
527
526
|
readonly events: EventEmitter<Events>;
|
|
528
527
|
readonly config: Config;
|
|
529
528
|
readonly executed: Array<Executer>;
|
|
@@ -671,6 +670,170 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
671
670
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
672
671
|
}
|
|
673
672
|
//#endregion
|
|
673
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
674
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
675
|
+
name: string;
|
|
676
|
+
type: 'react';
|
|
677
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
678
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
679
|
+
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
680
|
+
};
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
683
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
684
|
+
/**
|
|
685
|
+
* @deprecated
|
|
686
|
+
*/
|
|
687
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
688
|
+
options: TOptions['resolvedOptions'];
|
|
689
|
+
operations: Array<Operation$1>;
|
|
690
|
+
};
|
|
691
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
692
|
+
/**
|
|
693
|
+
* @deprecated
|
|
694
|
+
*/
|
|
695
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
696
|
+
options: TOptions['resolvedOptions'];
|
|
697
|
+
operation: Operation$1;
|
|
698
|
+
};
|
|
699
|
+
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
700
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
701
|
+
options: TOptions['resolvedOptions'];
|
|
702
|
+
schema: {
|
|
703
|
+
name: string;
|
|
704
|
+
tree: Array<Schema>;
|
|
705
|
+
value: SchemaObject$1;
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
711
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
712
|
+
name: string;
|
|
713
|
+
type: 'core';
|
|
714
|
+
operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
715
|
+
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
716
|
+
schema: (props: SchemaProps$1<TOptions>) => Promise<File[]>;
|
|
717
|
+
};
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
720
|
+
type ResolvePathOptions = {
|
|
721
|
+
pluginKey?: Plugin['key'];
|
|
722
|
+
group?: {
|
|
723
|
+
tag?: string;
|
|
724
|
+
path?: string;
|
|
725
|
+
};
|
|
726
|
+
type?: ResolveNameParams['type'];
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
730
|
+
* @example import { Pet } from './Pet'
|
|
731
|
+
*
|
|
732
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
733
|
+
*
|
|
734
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
735
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
736
|
+
*/
|
|
737
|
+
type Ref = {
|
|
738
|
+
propertyName: string;
|
|
739
|
+
originalName: string;
|
|
740
|
+
path: OptionalPath;
|
|
741
|
+
pluginKey?: Plugin['key'];
|
|
742
|
+
};
|
|
743
|
+
type Refs = Record<string, Ref>;
|
|
744
|
+
type OperationSchema = {
|
|
745
|
+
/**
|
|
746
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
747
|
+
*/
|
|
748
|
+
name: string;
|
|
749
|
+
schema: SchemaObject$1;
|
|
750
|
+
operation?: Operation$1;
|
|
751
|
+
/**
|
|
752
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
753
|
+
*/
|
|
754
|
+
operationName: string;
|
|
755
|
+
description?: string;
|
|
756
|
+
statusCode?: number;
|
|
757
|
+
keys?: string[];
|
|
758
|
+
keysToOmit?: string[];
|
|
759
|
+
withData?: boolean;
|
|
760
|
+
};
|
|
761
|
+
type OperationSchemas = {
|
|
762
|
+
pathParams?: OperationSchema & {
|
|
763
|
+
keysToOmit?: never;
|
|
764
|
+
};
|
|
765
|
+
queryParams?: OperationSchema & {
|
|
766
|
+
keysToOmit?: never;
|
|
767
|
+
};
|
|
768
|
+
headerParams?: OperationSchema & {
|
|
769
|
+
keysToOmit?: never;
|
|
770
|
+
};
|
|
771
|
+
request?: OperationSchema;
|
|
772
|
+
response: OperationSchema;
|
|
773
|
+
responses: Array<OperationSchema>;
|
|
774
|
+
statusCodes?: Array<OperationSchema>;
|
|
775
|
+
errors?: Array<OperationSchema>;
|
|
776
|
+
};
|
|
777
|
+
type ByTag = {
|
|
778
|
+
type: 'tag';
|
|
779
|
+
pattern: string | RegExp;
|
|
780
|
+
};
|
|
781
|
+
type ByOperationId = {
|
|
782
|
+
type: 'operationId';
|
|
783
|
+
pattern: string | RegExp;
|
|
784
|
+
};
|
|
785
|
+
type ByPath = {
|
|
786
|
+
type: 'path';
|
|
787
|
+
pattern: string | RegExp;
|
|
788
|
+
};
|
|
789
|
+
type ByMethod = {
|
|
790
|
+
type: 'method';
|
|
791
|
+
pattern: HttpMethod | RegExp;
|
|
792
|
+
};
|
|
793
|
+
type BySchemaName = {
|
|
794
|
+
type: 'schemaName';
|
|
795
|
+
pattern: string | RegExp;
|
|
796
|
+
};
|
|
797
|
+
type ByContentType = {
|
|
798
|
+
type: 'contentType';
|
|
799
|
+
pattern: string | RegExp;
|
|
800
|
+
};
|
|
801
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
802
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
803
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
804
|
+
options: Partial<TOptions>;
|
|
805
|
+
};
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
808
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
809
|
+
fabric: Fabric;
|
|
810
|
+
oas: Oas;
|
|
811
|
+
exclude: Array<Exclude$1> | undefined;
|
|
812
|
+
include: Array<Include> | undefined;
|
|
813
|
+
override: Array<Override<TOptions>> | undefined;
|
|
814
|
+
contentType: contentType | undefined;
|
|
815
|
+
pluginManager: PluginManager;
|
|
816
|
+
/**
|
|
817
|
+
* Current plugin
|
|
818
|
+
*/
|
|
819
|
+
plugin: Plugin<TPluginOptions>;
|
|
820
|
+
mode: Mode;
|
|
821
|
+
};
|
|
822
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
823
|
+
#private;
|
|
824
|
+
getSchemas(operation: Operation$1, {
|
|
825
|
+
resolveName
|
|
826
|
+
}?: {
|
|
827
|
+
resolveName?: (name: string) => string;
|
|
828
|
+
}): OperationSchemas;
|
|
829
|
+
getOperations(): Promise<Array<{
|
|
830
|
+
path: string;
|
|
831
|
+
method: HttpMethod;
|
|
832
|
+
operation: Operation$1;
|
|
833
|
+
}>>;
|
|
834
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
835
|
+
}
|
|
836
|
+
//#endregion
|
|
674
837
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
675
838
|
type SchemaKeywordMapper = {
|
|
676
839
|
object: {
|
|
@@ -888,96 +1051,9 @@ type Schema = {
|
|
|
888
1051
|
keyword: string;
|
|
889
1052
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
890
1053
|
//#endregion
|
|
891
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
892
|
-
type ResolvePathOptions = {
|
|
893
|
-
pluginKey?: Plugin['key'];
|
|
894
|
-
group?: {
|
|
895
|
-
tag?: string;
|
|
896
|
-
path?: string;
|
|
897
|
-
};
|
|
898
|
-
type?: ResolveNameParams['type'];
|
|
899
|
-
};
|
|
900
|
-
/**
|
|
901
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
902
|
-
* @example import { Pet } from './Pet'
|
|
903
|
-
*
|
|
904
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
905
|
-
*
|
|
906
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
907
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
908
|
-
*/
|
|
909
|
-
type Ref = {
|
|
910
|
-
propertyName: string;
|
|
911
|
-
originalName: string;
|
|
912
|
-
path: OptionalPath;
|
|
913
|
-
pluginKey?: Plugin['key'];
|
|
914
|
-
};
|
|
915
|
-
type Refs = Record<string, Ref>;
|
|
916
|
-
type OperationSchema = {
|
|
917
|
-
/**
|
|
918
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
919
|
-
*/
|
|
920
|
-
name: string;
|
|
921
|
-
schema: SchemaObject$1;
|
|
922
|
-
operation?: Operation$1;
|
|
923
|
-
/**
|
|
924
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
925
|
-
*/
|
|
926
|
-
operationName: string;
|
|
927
|
-
description?: string;
|
|
928
|
-
statusCode?: number;
|
|
929
|
-
keys?: string[];
|
|
930
|
-
keysToOmit?: string[];
|
|
931
|
-
withData?: boolean;
|
|
932
|
-
};
|
|
933
|
-
type OperationSchemas = {
|
|
934
|
-
pathParams?: OperationSchema & {
|
|
935
|
-
keysToOmit?: never;
|
|
936
|
-
};
|
|
937
|
-
queryParams?: OperationSchema & {
|
|
938
|
-
keysToOmit?: never;
|
|
939
|
-
};
|
|
940
|
-
headerParams?: OperationSchema & {
|
|
941
|
-
keysToOmit?: never;
|
|
942
|
-
};
|
|
943
|
-
request?: OperationSchema;
|
|
944
|
-
response: OperationSchema;
|
|
945
|
-
responses: Array<OperationSchema>;
|
|
946
|
-
statusCodes?: Array<OperationSchema>;
|
|
947
|
-
errors?: Array<OperationSchema>;
|
|
948
|
-
};
|
|
949
|
-
type ByTag = {
|
|
950
|
-
type: 'tag';
|
|
951
|
-
pattern: string | RegExp;
|
|
952
|
-
};
|
|
953
|
-
type ByOperationId = {
|
|
954
|
-
type: 'operationId';
|
|
955
|
-
pattern: string | RegExp;
|
|
956
|
-
};
|
|
957
|
-
type ByPath = {
|
|
958
|
-
type: 'path';
|
|
959
|
-
pattern: string | RegExp;
|
|
960
|
-
};
|
|
961
|
-
type ByMethod = {
|
|
962
|
-
type: 'method';
|
|
963
|
-
pattern: HttpMethod | RegExp;
|
|
964
|
-
};
|
|
965
|
-
type BySchemaName = {
|
|
966
|
-
type: 'schemaName';
|
|
967
|
-
pattern: string | RegExp;
|
|
968
|
-
};
|
|
969
|
-
type ByContentType = {
|
|
970
|
-
type: 'contentType';
|
|
971
|
-
pattern: string | RegExp;
|
|
972
|
-
};
|
|
973
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
974
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
975
|
-
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
976
|
-
options: Partial<TOptions$1>;
|
|
977
|
-
};
|
|
978
|
-
//#endregion
|
|
979
1054
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
980
|
-
type Context
|
|
1055
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1056
|
+
fabric: Fabric;
|
|
981
1057
|
oas: Oas;
|
|
982
1058
|
pluginManager: PluginManager;
|
|
983
1059
|
/**
|
|
@@ -986,7 +1062,7 @@ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
986
1062
|
plugin: Plugin<TPluginOptions>;
|
|
987
1063
|
mode: Mode;
|
|
988
1064
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
989
|
-
override: Array<Override<TOptions
|
|
1065
|
+
override: Array<Override<TOptions>> | undefined;
|
|
990
1066
|
contentType?: contentType;
|
|
991
1067
|
output?: string;
|
|
992
1068
|
};
|
|
@@ -1009,15 +1085,15 @@ type SchemaGeneratorOptions = {
|
|
|
1009
1085
|
* TODO TODO add docs
|
|
1010
1086
|
* @beta
|
|
1011
1087
|
*/
|
|
1012
|
-
schema?: (schemaProps: SchemaProps
|
|
1088
|
+
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1013
1089
|
};
|
|
1014
1090
|
};
|
|
1015
|
-
type SchemaProps
|
|
1091
|
+
type SchemaProps = {
|
|
1016
1092
|
schemaObject?: SchemaObject$1;
|
|
1017
1093
|
name?: string;
|
|
1018
1094
|
parentName?: string;
|
|
1019
1095
|
};
|
|
1020
|
-
declare class SchemaGenerator<TOptions
|
|
1096
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1021
1097
|
#private;
|
|
1022
1098
|
refs: Refs;
|
|
1023
1099
|
/**
|
|
@@ -1025,7 +1101,7 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
1025
1101
|
* Delegates to getBaseTypeFromSchema internally and
|
|
1026
1102
|
* optionally adds a union with null.
|
|
1027
1103
|
*/
|
|
1028
|
-
parse(props: SchemaProps
|
|
1104
|
+
parse(props: SchemaProps): Schema[];
|
|
1029
1105
|
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1030
1106
|
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1031
1107
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
@@ -1035,62 +1111,5 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
1035
1111
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1036
1112
|
}
|
|
1037
1113
|
//#endregion
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1041
|
-
options: TOptions$1['resolvedOptions'];
|
|
1042
|
-
operations: Array<Operation$1>;
|
|
1043
|
-
};
|
|
1044
|
-
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1045
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1046
|
-
options: TOptions$1['resolvedOptions'];
|
|
1047
|
-
operation: Operation$1;
|
|
1048
|
-
};
|
|
1049
|
-
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1050
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1051
|
-
options: TOptions$1['resolvedOptions'];
|
|
1052
|
-
schema: {
|
|
1053
|
-
name: string;
|
|
1054
|
-
tree: Array<Schema>;
|
|
1055
|
-
value: SchemaObject$1;
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
|
-
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1059
|
-
name: string;
|
|
1060
|
-
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1061
|
-
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1062
|
-
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1063
|
-
};
|
|
1064
|
-
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1065
|
-
//#endregion
|
|
1066
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1067
|
-
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1068
|
-
oas: Oas;
|
|
1069
|
-
exclude: Array<Exclude$1> | undefined;
|
|
1070
|
-
include: Array<Include> | undefined;
|
|
1071
|
-
override: Array<Override<TOptions$1>> | undefined;
|
|
1072
|
-
contentType: contentType | undefined;
|
|
1073
|
-
pluginManager: PluginManager;
|
|
1074
|
-
/**
|
|
1075
|
-
* Current plugin
|
|
1076
|
-
*/
|
|
1077
|
-
plugin: Plugin<TPluginOptions>;
|
|
1078
|
-
mode: Mode;
|
|
1079
|
-
};
|
|
1080
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
1081
|
-
#private;
|
|
1082
|
-
getSchemas(operation: Operation$1, {
|
|
1083
|
-
resolveName
|
|
1084
|
-
}?: {
|
|
1085
|
-
resolveName?: (name: string) => string;
|
|
1086
|
-
}): OperationSchemas;
|
|
1087
|
-
getOperations(): Promise<Array<{
|
|
1088
|
-
path: string;
|
|
1089
|
-
method: HttpMethod;
|
|
1090
|
-
operation: Operation$1;
|
|
1091
|
-
}>>;
|
|
1092
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1093
|
-
}
|
|
1094
|
-
//#endregion
|
|
1095
|
-
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 };
|
|
1096
|
-
//# sourceMappingURL=OperationGenerator-Bq_OAgZR.d.cts.map
|
|
1114
|
+
export { ResolvePathOptions as a, Oas as c, Output as d, PluginFactoryOptions as f, File as h, Override as i, contentType as l, UserPluginWithLifeCycle as m, Include as n, Generator as o, ResolveNameParams as p, OperationSchemas as r, ReactGenerator as s, Exclude$1 as t, Group as u };
|
|
1115
|
+
//# sourceMappingURL=SchemaGenerator-C1vgcKII.d.cts.map
|