@kubb/plugin-ts 4.5.1 → 4.5.3
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.cjs +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-BKcG9C_Y.cjs → plugin-CE_zX-yD.cjs} +7 -10
- package/dist/plugin-CE_zX-yD.cjs.map +1 -0
- package/dist/{plugin-CfDmQVWY.js → plugin-G3YVWEvI.js} +8 -11
- package/dist/plugin-G3YVWEvI.js.map +1 -0
- package/dist/{types-BXlkWRNi.d.ts → types-3bqiJQCB.d.cts} +174 -169
- package/dist/{types-BdHzvKY0.d.cts → types-Ck_bg9OD.d.ts} +174 -169
- package/package.json +8 -8
- package/src/plugin.ts +6 -13
- package/src/types.ts +1 -1
- package/dist/plugin-BKcG9C_Y.cjs.map +0 -1
- package/dist/plugin-CfDmQVWY.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
2
|
+
import ts from "typescript";
|
|
1
3
|
import * as OasTypes from "oas/types";
|
|
2
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
5
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
4
6
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
8
|
import BaseOas from "oas";
|
|
7
|
-
import { KubbNode } from "@kubb/react-fabric/types";
|
|
8
9
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
9
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
10
10
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
11
|
-
import
|
|
11
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
12
12
|
|
|
13
13
|
//#region ../oas/src/types.d.ts
|
|
14
14
|
type contentType = 'application/json' | (string & {});
|
|
@@ -111,6 +111,21 @@ type Logger = {
|
|
|
111
111
|
type PossiblePromise<T> = Promise<T> | T;
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region ../core/src/types.d.ts
|
|
114
|
+
declare global {
|
|
115
|
+
namespace Kubb {
|
|
116
|
+
interface PluginContext {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Config used in `kubb.config.ts`
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* import { defineConfig } from '@kubb/core'
|
|
124
|
+
* export default defineConfig({
|
|
125
|
+
* ...
|
|
126
|
+
* })
|
|
127
|
+
*/
|
|
128
|
+
|
|
114
129
|
type InputPath = {
|
|
115
130
|
/**
|
|
116
131
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -265,11 +280,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
265
280
|
* 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.
|
|
266
281
|
*/
|
|
267
282
|
post?: Array<string>;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} : {
|
|
271
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
272
|
-
});
|
|
283
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
284
|
+
};
|
|
273
285
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
274
286
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
275
287
|
/**
|
|
@@ -295,25 +307,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
295
307
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
296
308
|
*/
|
|
297
309
|
options: TOptions['resolvedOptions'];
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
310
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
313
|
+
*/
|
|
314
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
315
|
+
};
|
|
303
316
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
304
317
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
305
318
|
/**
|
|
306
319
|
* Start of the lifecycle of a plugin.
|
|
307
320
|
* @type hookParallel
|
|
308
321
|
*/
|
|
309
|
-
|
|
322
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
310
323
|
/**
|
|
311
324
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
312
325
|
* Options can als be included.
|
|
313
326
|
* @type hookFirst
|
|
314
327
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
315
328
|
*/
|
|
316
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
329
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
317
330
|
/**
|
|
318
331
|
* Resolve to a name based on a string.
|
|
319
332
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -321,11 +334,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
321
334
|
* @example ('pet') => 'Pet'
|
|
322
335
|
*/
|
|
323
336
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
324
|
-
/**
|
|
325
|
-
* End of the plugin lifecycle.
|
|
326
|
-
* @type hookParallel
|
|
327
|
-
*/
|
|
328
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
329
337
|
};
|
|
330
338
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
331
339
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -352,24 +360,15 @@ type ResolveNameParams = {
|
|
|
352
360
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
361
|
fabric: Fabric;
|
|
354
362
|
config: Config;
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated
|
|
357
|
-
*/
|
|
358
|
-
fileManager: FileManager;
|
|
359
363
|
pluginManager: PluginManager;
|
|
360
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
362
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
364
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
363
365
|
logger: Logger;
|
|
364
|
-
|
|
365
|
-
* All plugins
|
|
366
|
-
*/
|
|
367
|
-
plugins: Plugin[];
|
|
366
|
+
mode: KubbFile.Mode;
|
|
368
367
|
/**
|
|
369
368
|
* Current plugin
|
|
370
369
|
*/
|
|
371
370
|
plugin: Plugin<TOptions>;
|
|
372
|
-
};
|
|
371
|
+
} & Kubb.PluginContext;
|
|
373
372
|
/**
|
|
374
373
|
* Specify the export location for the files and define the behavior of the output
|
|
375
374
|
*/
|
|
@@ -444,13 +443,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
444
443
|
};
|
|
445
444
|
declare class PluginManager {
|
|
446
445
|
#private;
|
|
447
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
448
446
|
readonly events: EventEmitter<Events>;
|
|
449
447
|
readonly config: Config;
|
|
450
448
|
readonly executed: Array<Executer>;
|
|
451
449
|
readonly logger: Logger;
|
|
452
450
|
readonly options: Options$2;
|
|
453
451
|
constructor(config: Config, options: Options$2);
|
|
452
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
453
|
+
get plugins(): Array<Plugin>;
|
|
454
454
|
getFile<TOptions = object>({
|
|
455
455
|
name,
|
|
456
456
|
mode,
|
|
@@ -460,7 +460,7 @@ declare class PluginManager {
|
|
|
460
460
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
461
461
|
pluginKey: Plugin['key'];
|
|
462
462
|
}>;
|
|
463
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
463
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
464
464
|
resolveName: (params: ResolveNameParams) => string;
|
|
465
465
|
/**
|
|
466
466
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -548,15 +548,140 @@ declare class PluginManager {
|
|
|
548
548
|
}): Promise<void>;
|
|
549
549
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
550
550
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
551
|
-
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;
|
|
552
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
553
551
|
}
|
|
554
552
|
//#endregion
|
|
555
|
-
//#region ../core/src/
|
|
553
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
556
554
|
type FileMetaBase = {
|
|
557
555
|
pluginKey?: Plugin['key'];
|
|
558
556
|
};
|
|
559
557
|
//#endregion
|
|
558
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
559
|
+
type Context$2 = {
|
|
560
|
+
getOas(): Promise<Oas>;
|
|
561
|
+
getBaseURL(): Promise<string | undefined>;
|
|
562
|
+
};
|
|
563
|
+
declare global {
|
|
564
|
+
namespace Kubb {
|
|
565
|
+
interface PluginContext extends Context$2 {}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
type ResolvePathOptions = {
|
|
569
|
+
pluginKey?: Plugin['key'];
|
|
570
|
+
group?: {
|
|
571
|
+
tag?: string;
|
|
572
|
+
path?: string;
|
|
573
|
+
};
|
|
574
|
+
type?: ResolveNameParams['type'];
|
|
575
|
+
};
|
|
576
|
+
/**
|
|
577
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
578
|
+
* @example import { Pet } from './Pet'
|
|
579
|
+
*
|
|
580
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
581
|
+
*
|
|
582
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
583
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
584
|
+
*/
|
|
585
|
+
type Ref = {
|
|
586
|
+
propertyName: string;
|
|
587
|
+
originalName: string;
|
|
588
|
+
path: KubbFile.Path;
|
|
589
|
+
pluginKey?: Plugin['key'];
|
|
590
|
+
};
|
|
591
|
+
type Refs = Record<string, Ref>;
|
|
592
|
+
type OperationSchema = {
|
|
593
|
+
/**
|
|
594
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
595
|
+
*/
|
|
596
|
+
name: string;
|
|
597
|
+
schema: SchemaObject$1;
|
|
598
|
+
operation?: Operation$1;
|
|
599
|
+
/**
|
|
600
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
601
|
+
*/
|
|
602
|
+
operationName: string;
|
|
603
|
+
description?: string;
|
|
604
|
+
statusCode?: number;
|
|
605
|
+
keys?: string[];
|
|
606
|
+
keysToOmit?: string[];
|
|
607
|
+
withData?: boolean;
|
|
608
|
+
};
|
|
609
|
+
type OperationSchemas = {
|
|
610
|
+
pathParams?: OperationSchema & {
|
|
611
|
+
keysToOmit?: never;
|
|
612
|
+
};
|
|
613
|
+
queryParams?: OperationSchema & {
|
|
614
|
+
keysToOmit?: never;
|
|
615
|
+
};
|
|
616
|
+
headerParams?: OperationSchema & {
|
|
617
|
+
keysToOmit?: never;
|
|
618
|
+
};
|
|
619
|
+
request?: OperationSchema;
|
|
620
|
+
response: OperationSchema;
|
|
621
|
+
responses: Array<OperationSchema>;
|
|
622
|
+
statusCodes?: Array<OperationSchema>;
|
|
623
|
+
errors?: Array<OperationSchema>;
|
|
624
|
+
};
|
|
625
|
+
type ByTag = {
|
|
626
|
+
type: 'tag';
|
|
627
|
+
pattern: string | RegExp;
|
|
628
|
+
};
|
|
629
|
+
type ByOperationId = {
|
|
630
|
+
type: 'operationId';
|
|
631
|
+
pattern: string | RegExp;
|
|
632
|
+
};
|
|
633
|
+
type ByPath = {
|
|
634
|
+
type: 'path';
|
|
635
|
+
pattern: string | RegExp;
|
|
636
|
+
};
|
|
637
|
+
type ByMethod = {
|
|
638
|
+
type: 'method';
|
|
639
|
+
pattern: HttpMethod | RegExp;
|
|
640
|
+
};
|
|
641
|
+
type BySchemaName = {
|
|
642
|
+
type: 'schemaName';
|
|
643
|
+
pattern: string | RegExp;
|
|
644
|
+
};
|
|
645
|
+
type ByContentType = {
|
|
646
|
+
type: 'contentType';
|
|
647
|
+
pattern: string | RegExp;
|
|
648
|
+
};
|
|
649
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
650
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
651
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
652
|
+
options: Partial<TOptions>;
|
|
653
|
+
};
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
656
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
657
|
+
fabric: Fabric;
|
|
658
|
+
oas: Oas;
|
|
659
|
+
exclude: Array<Exclude$1> | undefined;
|
|
660
|
+
include: Array<Include> | undefined;
|
|
661
|
+
override: Array<Override<TOptions>> | undefined;
|
|
662
|
+
contentType: contentType | undefined;
|
|
663
|
+
pluginManager: PluginManager;
|
|
664
|
+
/**
|
|
665
|
+
* Current plugin
|
|
666
|
+
*/
|
|
667
|
+
plugin: Plugin<TPluginOptions>;
|
|
668
|
+
mode: KubbFile.Mode;
|
|
669
|
+
};
|
|
670
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
671
|
+
#private;
|
|
672
|
+
getSchemas(operation: Operation$1, {
|
|
673
|
+
resolveName
|
|
674
|
+
}?: {
|
|
675
|
+
resolveName?: (name: string) => string;
|
|
676
|
+
}): OperationSchemas;
|
|
677
|
+
getOperations(): Promise<Array<{
|
|
678
|
+
path: string;
|
|
679
|
+
method: HttpMethod;
|
|
680
|
+
operation: Operation$1;
|
|
681
|
+
}>>;
|
|
682
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
560
685
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
561
686
|
type SchemaKeywordMapper = {
|
|
562
687
|
object: {
|
|
@@ -670,7 +795,7 @@ type SchemaKeywordMapper = {
|
|
|
670
795
|
/**
|
|
671
796
|
* Full qualified path.
|
|
672
797
|
*/
|
|
673
|
-
path: KubbFile.
|
|
798
|
+
path: KubbFile.Path;
|
|
674
799
|
/**
|
|
675
800
|
* When true `File.Import` will be used.
|
|
676
801
|
* When false a reference will be used inside the current file.
|
|
@@ -774,96 +899,8 @@ type Schema = {
|
|
|
774
899
|
keyword: string;
|
|
775
900
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
776
901
|
//#endregion
|
|
777
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
778
|
-
type ResolvePathOptions = {
|
|
779
|
-
pluginKey?: Plugin['key'];
|
|
780
|
-
group?: {
|
|
781
|
-
tag?: string;
|
|
782
|
-
path?: string;
|
|
783
|
-
};
|
|
784
|
-
type?: ResolveNameParams['type'];
|
|
785
|
-
};
|
|
786
|
-
/**
|
|
787
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
788
|
-
* @example import { Pet } from './Pet'
|
|
789
|
-
*
|
|
790
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
791
|
-
*
|
|
792
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
793
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
794
|
-
*/
|
|
795
|
-
type Ref = {
|
|
796
|
-
propertyName: string;
|
|
797
|
-
originalName: string;
|
|
798
|
-
path: KubbFile.OptionalPath;
|
|
799
|
-
pluginKey?: Plugin['key'];
|
|
800
|
-
};
|
|
801
|
-
type Refs = Record<string, Ref>;
|
|
802
|
-
type OperationSchema = {
|
|
803
|
-
/**
|
|
804
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
805
|
-
*/
|
|
806
|
-
name: string;
|
|
807
|
-
schema: SchemaObject$1;
|
|
808
|
-
operation?: Operation$1;
|
|
809
|
-
/**
|
|
810
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
811
|
-
*/
|
|
812
|
-
operationName: string;
|
|
813
|
-
description?: string;
|
|
814
|
-
statusCode?: number;
|
|
815
|
-
keys?: string[];
|
|
816
|
-
keysToOmit?: string[];
|
|
817
|
-
withData?: boolean;
|
|
818
|
-
};
|
|
819
|
-
type OperationSchemas = {
|
|
820
|
-
pathParams?: OperationSchema & {
|
|
821
|
-
keysToOmit?: never;
|
|
822
|
-
};
|
|
823
|
-
queryParams?: OperationSchema & {
|
|
824
|
-
keysToOmit?: never;
|
|
825
|
-
};
|
|
826
|
-
headerParams?: OperationSchema & {
|
|
827
|
-
keysToOmit?: never;
|
|
828
|
-
};
|
|
829
|
-
request?: OperationSchema;
|
|
830
|
-
response: OperationSchema;
|
|
831
|
-
responses: Array<OperationSchema>;
|
|
832
|
-
statusCodes?: Array<OperationSchema>;
|
|
833
|
-
errors?: Array<OperationSchema>;
|
|
834
|
-
};
|
|
835
|
-
type ByTag = {
|
|
836
|
-
type: 'tag';
|
|
837
|
-
pattern: string | RegExp;
|
|
838
|
-
};
|
|
839
|
-
type ByOperationId = {
|
|
840
|
-
type: 'operationId';
|
|
841
|
-
pattern: string | RegExp;
|
|
842
|
-
};
|
|
843
|
-
type ByPath = {
|
|
844
|
-
type: 'path';
|
|
845
|
-
pattern: string | RegExp;
|
|
846
|
-
};
|
|
847
|
-
type ByMethod = {
|
|
848
|
-
type: 'method';
|
|
849
|
-
pattern: HttpMethod | RegExp;
|
|
850
|
-
};
|
|
851
|
-
type BySchemaName = {
|
|
852
|
-
type: 'schemaName';
|
|
853
|
-
pattern: string | RegExp;
|
|
854
|
-
};
|
|
855
|
-
type ByContentType = {
|
|
856
|
-
type: 'contentType';
|
|
857
|
-
pattern: string | RegExp;
|
|
858
|
-
};
|
|
859
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
860
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
861
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
862
|
-
options: Partial<TOptions>;
|
|
863
|
-
};
|
|
864
|
-
//#endregion
|
|
865
902
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
866
|
-
type Context
|
|
903
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
867
904
|
fabric: Fabric;
|
|
868
905
|
oas: Oas;
|
|
869
906
|
pluginManager: PluginManager;
|
|
@@ -904,7 +941,7 @@ type SchemaProps$1 = {
|
|
|
904
941
|
name?: string;
|
|
905
942
|
parentName?: string;
|
|
906
943
|
};
|
|
907
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context
|
|
944
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
908
945
|
#private;
|
|
909
946
|
refs: Refs;
|
|
910
947
|
/**
|
|
@@ -919,15 +956,6 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
919
956
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
920
957
|
}
|
|
921
958
|
//#endregion
|
|
922
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
923
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
924
|
-
name: string;
|
|
925
|
-
type: 'core';
|
|
926
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
927
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
928
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
929
|
-
};
|
|
930
|
-
//#endregion
|
|
931
959
|
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
932
960
|
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
933
961
|
name: string;
|
|
@@ -962,35 +990,14 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
|
962
990
|
};
|
|
963
991
|
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
964
992
|
//#endregion
|
|
965
|
-
//#region ../plugin-oas/src/
|
|
966
|
-
type
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
contentType: contentType | undefined;
|
|
973
|
-
pluginManager: PluginManager;
|
|
974
|
-
/**
|
|
975
|
-
* Current plugin
|
|
976
|
-
*/
|
|
977
|
-
plugin: Plugin<TPluginOptions>;
|
|
978
|
-
mode: KubbFile.Mode;
|
|
993
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
994
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
995
|
+
name: string;
|
|
996
|
+
type: 'core';
|
|
997
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
998
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
999
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
979
1000
|
};
|
|
980
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
981
|
-
#private;
|
|
982
|
-
getSchemas(operation: Operation$1, {
|
|
983
|
-
resolveName
|
|
984
|
-
}?: {
|
|
985
|
-
resolveName?: (name: string) => string;
|
|
986
|
-
}): OperationSchemas;
|
|
987
|
-
getOperations(): Promise<Array<{
|
|
988
|
-
path: string;
|
|
989
|
-
method: HttpMethod;
|
|
990
|
-
operation: Operation$1;
|
|
991
|
-
}>>;
|
|
992
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
993
|
-
}
|
|
994
1001
|
//#endregion
|
|
995
1002
|
//#region src/types.d.ts
|
|
996
1003
|
type Options$1 = {
|
|
@@ -1100,9 +1107,7 @@ type ResolvedOptions = {
|
|
|
1100
1107
|
syntaxType: NonNullable<Options$1['syntaxType']>;
|
|
1101
1108
|
mapper: Record<string, any>;
|
|
1102
1109
|
};
|
|
1103
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions,
|
|
1104
|
-
usedEnumNames: Record<string, number>;
|
|
1105
|
-
}, ResolvePathOptions>;
|
|
1110
|
+
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1106
1111
|
//#endregion
|
|
1107
1112
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1108
|
-
//# sourceMappingURL=types-
|
|
1113
|
+
//# sourceMappingURL=types-Ck_bg9OD.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
}
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@kubb/fabric-core": "0.2.
|
|
68
|
-
"@kubb/react-fabric": "0.2.
|
|
67
|
+
"@kubb/fabric-core": "0.2.19",
|
|
68
|
+
"@kubb/react-fabric": "0.2.19",
|
|
69
69
|
"remeda": "^2.32.0",
|
|
70
70
|
"typescript": "5.9.3",
|
|
71
|
-
"@kubb/core": "4.5.
|
|
72
|
-
"@kubb/oas": "4.5.
|
|
73
|
-
"@kubb/plugin-oas": "4.5.
|
|
71
|
+
"@kubb/core": "4.5.3",
|
|
72
|
+
"@kubb/oas": "4.5.3",
|
|
73
|
+
"@kubb/plugin-oas": "4.5.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@kubb/plugin-oas": "4.5.
|
|
76
|
+
"@kubb/plugin-oas": "4.5.3"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@kubb/react-fabric": "0.2.
|
|
79
|
+
"@kubb/react-fabric": "0.2.19"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=20"
|
package/src/plugin.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
2
|
+
import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
|
|
3
3
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
4
|
-
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
4
|
import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
6
5
|
import { oasGenerator, typeGenerator } from './generators'
|
|
7
6
|
import type { PluginTs } from './types.ts'
|
|
8
7
|
|
|
9
8
|
export const pluginTsName = 'plugin-ts' satisfies PluginTs['name']
|
|
10
9
|
|
|
11
|
-
export const pluginTs =
|
|
10
|
+
export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
12
11
|
const {
|
|
13
12
|
output = { path: 'types', barrelType: 'named' },
|
|
14
13
|
group,
|
|
@@ -45,11 +44,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
45
44
|
group,
|
|
46
45
|
override,
|
|
47
46
|
mapper,
|
|
48
|
-
|
|
49
|
-
context() {
|
|
50
|
-
return {
|
|
51
|
-
usedEnumNames: {} as Record<string, number>,
|
|
52
|
-
}
|
|
47
|
+
usedEnumNames: {},
|
|
53
48
|
},
|
|
54
49
|
pre: [pluginOasName],
|
|
55
50
|
resolvePath(baseName, pathMode, options) {
|
|
@@ -95,12 +90,10 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
95
90
|
|
|
96
91
|
return resolvedName
|
|
97
92
|
},
|
|
98
|
-
async
|
|
99
|
-
const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
|
|
100
|
-
|
|
101
|
-
const oas = await swaggerPlugin.context.getOas()
|
|
93
|
+
async install() {
|
|
102
94
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
103
95
|
const mode = getMode(path.resolve(root, output.path))
|
|
96
|
+
const oas = await this.getOas()
|
|
104
97
|
|
|
105
98
|
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
106
99
|
fabric: this.fabric,
|
|
@@ -132,7 +125,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
132
125
|
const operationFiles = await operationGenerator.build(...generators)
|
|
133
126
|
await this.addFile(...operationFiles)
|
|
134
127
|
|
|
135
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
128
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
136
129
|
type: output.barrelType ?? 'named',
|
|
137
130
|
root,
|
|
138
131
|
output,
|
package/src/types.ts
CHANGED
|
@@ -113,4 +113,4 @@ type ResolvedOptions = {
|
|
|
113
113
|
mapper: Record<string, any>
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions,
|
|
116
|
+
export type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-BKcG9C_Y.cjs","names":["File","OasType","properties: Record<string, ts.TypeNode>","transformers","SchemaGenerator","options","type","File","Type","schemaKeywords","pluginOasName","path","options","groupName: Group['name']","transformers","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/oasGenerator.tsx","../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations({ plugin }) {\n const {\n options: { output },\n key: pluginKey,\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/fabric-core/parsers/typescript'\nimport { isKeyword, type OperationSchemas, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport type ts from 'typescript'\nimport { Type } from '../components'\nimport * as factory from '../factory.ts'\nimport { pluginTsName } from '../plugin.ts'\nimport type { PluginTs } from '../types'\n\nfunction printCombinedSchema({ name, schemas, pluginManager }: { name: string; schemas: OperationSchemas; pluginManager: PluginManager }): string {\n const properties: Record<string, ts.TypeNode> = {}\n\n if (schemas.response) {\n properties['response'] = factory.createUnionDeclaration({\n nodes: schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['request'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['pathParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['queryParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['headerParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map((error) => {\n const identifier = pluginManager.resolveName({\n name: error.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(\n Object.keys(properties)\n .map((key) => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature({\n name: transformers.pascalCase(key),\n type,\n })\n })\n .filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print([namespaceNode])\n}\n\nexport const typeGenerator = createReactGenerator<PluginTs>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, syntaxType, optionalType },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const type = getName(operation, { type: 'function', pluginKey: [pluginTsName] })\n const combinedSchemaName = operation.method === 'get' ? `${type}Query` : `${type}Mutation`\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const type = {\n name: schemaManager.getName(name, { type: 'type' }),\n typedName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(options.operationName || name, { group }),\n }\n\n return (\n <>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={description}\n tree={tree}\n schema={schemaObject}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n keysToOmit={keysToOmit}\n syntaxType={syntaxType}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {operationSchemas.map(mapOperationSchema)}\n\n <File.Source name={combinedSchemaName} isExportable isIndexable isTypeOnly>\n {printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager })}\n </File.Source>\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const {\n options: { mapper, enumType, syntaxType, optionalType, output },\n } = plugin\n const mode = useMode()\n\n const oas = useOas()\n const pluginManager = usePluginManager()\n\n const { getName, getImports, getFile } = useSchemaManager()\n const imports = getImports(schema.tree)\n const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema)\n\n if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\n\n let typedName = getName(schema.name, { type: 'type' })\n\n if (enumType === 'asConst' && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) {\n typedName = typedName += 'Key' //Suffix for avoiding collisions (https://github.com/kubb-labs/kubb/issues/1873)\n }\n\n const type = {\n name: getName(schema.name, { type: 'function' }),\n typedName,\n file: getFile(schema.name),\n }\n\n return (\n <File\n baseName={type.file.baseName}\n path={type.file.path}\n meta={type.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[schema.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { oasGenerator, typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = createPlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumSuffix = 'enum',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n },\n context() {\n return {\n usedEnumNames: {} as Record<string, number>,\n }\n },\n pre: [pluginOasName],\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)}Controller`\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 = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\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 operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.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":";;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,sEAA8C;CACzD,MAAM;CACN,WAAW,EAAE,UAAU;EACrB,MAAM,EACJ,SAAS,EAAE,UACX,KAAK,cACH;EACJ,MAAM,yDAAkC;EACxC,MAAM,2CAAc;EAEpB,MAAM,OAAO,cAAc,QAAQ;GAAE,MAAM;GAAO,SAAS;GAAO;GAAW,CAAC;AAE9E,SACE,0DAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,yDAACA,yBAAK;IAAO,MAAM,CAA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