@kubb/plugin-ts 4.1.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components-Cf7RuPmU.cjs +580 -0
- package/dist/components-Cf7RuPmU.cjs.map +1 -0
- package/dist/components-Wl2A-qA2.js +491 -0
- package/dist/components-Wl2A-qA2.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +2 -3
- package/dist/components.d.ts +2 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{plugin-C6Jg0eqz.js → plugin-BCbcbpEe.js} +27 -23
- package/dist/plugin-BCbcbpEe.js.map +1 -0
- package/dist/{plugin--SAE5fJd.cjs → plugin-CmAjGGxS.cjs} +27 -23
- package/dist/plugin-CmAjGGxS.cjs.map +1 -0
- package/dist/{types-BLgrg7-y.d.cts → types-3wehoZmV.d.ts} +70 -70
- package/dist/{types-C7OjrC1J.d.ts → types-uOjOvgDO.d.cts} +69 -69
- package/package.json +10 -10
- package/src/components/Type.tsx +8 -10
- package/src/factory.ts +578 -0
- package/src/generators/oasGenerator.tsx +6 -7
- package/src/generators/typeGenerator.tsx +21 -12
- package/src/parser.ts +1 -1
- package/dist/components-3SwDb74W.cjs +0 -1962
- package/dist/components-3SwDb74W.cjs.map +0 -1
- package/dist/components-CSEFpzdz.js +0 -1940
- package/dist/components-CSEFpzdz.js.map +0 -1
- package/dist/plugin--SAE5fJd.cjs.map +0 -1
- package/dist/plugin-C6Jg0eqz.js.map +0 -1
|
@@ -47,17 +47,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
47
47
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
48
48
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
49
49
|
*/
|
|
50
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
50
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
51
51
|
#private;
|
|
52
|
-
constructor(options?: TOptions, context?: TContext);
|
|
53
|
-
get options(): TOptions;
|
|
52
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
53
|
+
get options(): TOptions$1;
|
|
54
54
|
get context(): TContext;
|
|
55
|
-
set options(options: TOptions);
|
|
55
|
+
set options(options: TOptions$1);
|
|
56
56
|
abstract build(...params: unknown[]): unknown;
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region ../core/src/fs/types.d.ts
|
|
60
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
60
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
61
61
|
type Import = {
|
|
62
62
|
/**
|
|
63
63
|
* Import name to be used
|
|
@@ -131,7 +131,7 @@ type BaseName = `${string}.${string}`;
|
|
|
131
131
|
* Path will be full qualified path to a specified file
|
|
132
132
|
*/
|
|
133
133
|
type Path = string;
|
|
134
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
134
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
135
135
|
type OptionalPath = Path | undefined | null;
|
|
136
136
|
type File<TMeta extends object = object> = {
|
|
137
137
|
/**
|
|
@@ -220,9 +220,9 @@ type Logger = {
|
|
|
220
220
|
};
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region ../core/src/utils/types.d.ts
|
|
223
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
224
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
225
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
223
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
224
|
+
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
225
|
+
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
226
226
|
//#endregion
|
|
227
227
|
//#region ../core/src/types.d.ts
|
|
228
228
|
type InputPath = {
|
|
@@ -335,11 +335,11 @@ TName extends string = string,
|
|
|
335
335
|
/**
|
|
336
336
|
* Options of the plugin.
|
|
337
337
|
*/
|
|
338
|
-
TOptions extends object = object,
|
|
338
|
+
TOptions$1 extends object = object,
|
|
339
339
|
/**
|
|
340
340
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
341
341
|
*/
|
|
342
|
-
TResolvedOptions extends object = TOptions,
|
|
342
|
+
TResolvedOptions extends object = TOptions$1,
|
|
343
343
|
/**
|
|
344
344
|
* Context that you want to expose to other plugins.
|
|
345
345
|
*/
|
|
@@ -353,23 +353,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
353
353
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
354
354
|
*/
|
|
355
355
|
key: PluginKey<TName | string>;
|
|
356
|
-
options: TOptions;
|
|
356
|
+
options: TOptions$1;
|
|
357
357
|
resolvedOptions: TResolvedOptions;
|
|
358
358
|
context: TContext;
|
|
359
359
|
resolvePathOptions: TResolvePathOptions;
|
|
360
360
|
};
|
|
361
361
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
362
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
362
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
363
363
|
/**
|
|
364
364
|
* Unique name used for the plugin
|
|
365
365
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
366
366
|
* @example @kubb/typescript
|
|
367
367
|
*/
|
|
368
|
-
name: TOptions['name'];
|
|
368
|
+
name: TOptions$1['name'];
|
|
369
369
|
/**
|
|
370
370
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
371
371
|
*/
|
|
372
|
-
options: TOptions['resolvedOptions'];
|
|
372
|
+
options: TOptions$1['resolvedOptions'];
|
|
373
373
|
/**
|
|
374
374
|
* 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.
|
|
375
375
|
* Can be used to validate dependent plugins.
|
|
@@ -379,23 +379,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
379
379
|
* 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.
|
|
380
380
|
*/
|
|
381
381
|
post?: Array<string>;
|
|
382
|
-
} & (TOptions['context'] extends never ? {
|
|
382
|
+
} & (TOptions$1['context'] extends never ? {
|
|
383
383
|
context?: never;
|
|
384
384
|
} : {
|
|
385
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
385
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
386
386
|
});
|
|
387
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
388
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
387
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
388
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
389
389
|
/**
|
|
390
390
|
* Unique name used for the plugin
|
|
391
391
|
* @example @kubb/typescript
|
|
392
392
|
*/
|
|
393
|
-
name: TOptions['name'];
|
|
393
|
+
name: TOptions$1['name'];
|
|
394
394
|
/**
|
|
395
395
|
* Internal key used when a developer uses more than one of the same plugin
|
|
396
396
|
* @private
|
|
397
397
|
*/
|
|
398
|
-
key: TOptions['key'];
|
|
398
|
+
key: TOptions$1['key'];
|
|
399
399
|
/**
|
|
400
400
|
* 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.
|
|
401
401
|
* Can be used to validate dependent plugins.
|
|
@@ -408,49 +408,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
408
408
|
/**
|
|
409
409
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
410
410
|
*/
|
|
411
|
-
options: TOptions['resolvedOptions'];
|
|
412
|
-
} & (TOptions['context'] extends never ? {
|
|
411
|
+
options: TOptions$1['resolvedOptions'];
|
|
412
|
+
} & (TOptions$1['context'] extends never ? {
|
|
413
413
|
context?: never;
|
|
414
414
|
} : {
|
|
415
|
-
context: TOptions['context'];
|
|
415
|
+
context: TOptions$1['context'];
|
|
416
416
|
});
|
|
417
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
418
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
417
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
418
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
419
419
|
/**
|
|
420
420
|
* Start of the lifecycle of a plugin.
|
|
421
421
|
* @type hookParallel
|
|
422
422
|
*/
|
|
423
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
423
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
424
424
|
/**
|
|
425
425
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
426
426
|
* Options can als be included.
|
|
427
427
|
* @type hookFirst
|
|
428
428
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
429
429
|
*/
|
|
430
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
430
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
431
431
|
/**
|
|
432
432
|
* Resolve to a name based on a string.
|
|
433
433
|
* Useful when converting to PascalCase or camelCase.
|
|
434
434
|
* @type hookFirst
|
|
435
435
|
* @example ('pet') => 'Pet'
|
|
436
436
|
*/
|
|
437
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
437
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
438
|
/**
|
|
439
439
|
* End of the plugin lifecycle.
|
|
440
440
|
* @type hookParallel
|
|
441
441
|
*/
|
|
442
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
442
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
443
443
|
};
|
|
444
444
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
445
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
446
|
-
type ResolvePathParams<TOptions = object> = {
|
|
445
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
446
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
447
447
|
pluginKey?: Plugin['key'];
|
|
448
448
|
baseName: BaseName;
|
|
449
449
|
mode?: Mode;
|
|
450
450
|
/**
|
|
451
451
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
452
452
|
*/
|
|
453
|
-
options?: TOptions;
|
|
453
|
+
options?: TOptions$1;
|
|
454
454
|
};
|
|
455
455
|
type ResolveNameParams = {
|
|
456
456
|
name: string;
|
|
@@ -463,12 +463,12 @@ type ResolveNameParams = {
|
|
|
463
463
|
*/
|
|
464
464
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
465
465
|
};
|
|
466
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
467
467
|
config: Config;
|
|
468
468
|
fileManager: FileManager;
|
|
469
469
|
pluginManager: PluginManager;
|
|
470
470
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
471
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
471
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
472
472
|
resolveName: (params: ResolveNameParams) => string;
|
|
473
473
|
logger: Logger;
|
|
474
474
|
/**
|
|
@@ -478,12 +478,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
478
478
|
/**
|
|
479
479
|
* Current plugin
|
|
480
480
|
*/
|
|
481
|
-
plugin: Plugin<TOptions>;
|
|
481
|
+
plugin: Plugin<TOptions$1>;
|
|
482
482
|
};
|
|
483
483
|
/**
|
|
484
484
|
* Specify the export location for the files and define the behavior of the output
|
|
485
485
|
*/
|
|
486
|
-
type Output<TOptions> = {
|
|
486
|
+
type Output<TOptions$1> = {
|
|
487
487
|
/**
|
|
488
488
|
* Path to the output folder or file that will contain the generated code
|
|
489
489
|
*/
|
|
@@ -496,11 +496,11 @@ type Output<TOptions> = {
|
|
|
496
496
|
/**
|
|
497
497
|
* Add a banner text in the beginning of every file
|
|
498
498
|
*/
|
|
499
|
-
banner?: string | ((options: TOptions) => string);
|
|
499
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
500
500
|
/**
|
|
501
501
|
* Add a footer text in the beginning of every file
|
|
502
502
|
*/
|
|
503
|
-
footer?: string | ((options: TOptions) => string);
|
|
503
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
504
504
|
};
|
|
505
505
|
type GroupContext = {
|
|
506
506
|
group: string;
|
|
@@ -520,7 +520,7 @@ type Group = {
|
|
|
520
520
|
type FileMetaBase = {
|
|
521
521
|
pluginKey?: Plugin['key'];
|
|
522
522
|
};
|
|
523
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
523
|
+
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
524
524
|
type AddIndexesProps = {
|
|
525
525
|
type: BarrelType | false | undefined;
|
|
526
526
|
/**
|
|
@@ -573,16 +573,16 @@ declare class FileManager {
|
|
|
573
573
|
//#region ../core/src/PluginManager.d.ts
|
|
574
574
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
575
575
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
576
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
576
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
577
577
|
message: string;
|
|
578
578
|
strategy: Strategy;
|
|
579
|
-
hookName: H;
|
|
579
|
+
hookName: H$1;
|
|
580
580
|
plugin: Plugin;
|
|
581
581
|
parameters?: unknown[] | undefined;
|
|
582
582
|
output?: unknown;
|
|
583
583
|
};
|
|
584
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
585
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
584
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
585
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
586
586
|
result: Result;
|
|
587
587
|
plugin: Plugin;
|
|
588
588
|
};
|
|
@@ -598,12 +598,12 @@ type Events = {
|
|
|
598
598
|
executed: [executer: Executer];
|
|
599
599
|
error: [error: Error];
|
|
600
600
|
};
|
|
601
|
-
type GetFileProps<TOptions = object> = {
|
|
601
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
602
602
|
name: string;
|
|
603
603
|
mode?: Mode;
|
|
604
604
|
extname: Extname;
|
|
605
605
|
pluginKey: Plugin['key'];
|
|
606
|
-
options?: TOptions;
|
|
606
|
+
options?: TOptions$1;
|
|
607
607
|
};
|
|
608
608
|
declare class PluginManager {
|
|
609
609
|
#private;
|
|
@@ -1009,12 +1009,12 @@ type ByContentType = {
|
|
|
1009
1009
|
};
|
|
1010
1010
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1011
1011
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1012
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1013
|
-
options: Partial<TOptions>;
|
|
1012
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1013
|
+
options: Partial<TOptions$1>;
|
|
1014
1014
|
};
|
|
1015
1015
|
//#endregion
|
|
1016
1016
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1017
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1017
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1018
1018
|
oas: Oas;
|
|
1019
1019
|
pluginManager: PluginManager;
|
|
1020
1020
|
/**
|
|
@@ -1023,7 +1023,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1023
1023
|
plugin: Plugin<TPluginOptions>;
|
|
1024
1024
|
mode: Mode;
|
|
1025
1025
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1026
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1026
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1027
1027
|
contentType?: contentType;
|
|
1028
1028
|
output?: string;
|
|
1029
1029
|
};
|
|
@@ -1054,7 +1054,7 @@ type SchemaProps$1 = {
|
|
|
1054
1054
|
name?: string;
|
|
1055
1055
|
parentName?: string;
|
|
1056
1056
|
};
|
|
1057
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1057
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1058
1058
|
#private;
|
|
1059
1059
|
refs: Refs;
|
|
1060
1060
|
/**
|
|
@@ -1073,39 +1073,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1073
1073
|
}
|
|
1074
1074
|
//#endregion
|
|
1075
1075
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1076
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1077
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1078
|
-
options: TOptions['resolvedOptions'];
|
|
1076
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1077
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1078
|
+
options: TOptions$1['resolvedOptions'];
|
|
1079
1079
|
operations: Array<Operation$1>;
|
|
1080
1080
|
};
|
|
1081
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1082
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1083
|
-
options: TOptions['resolvedOptions'];
|
|
1081
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1082
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1083
|
+
options: TOptions$1['resolvedOptions'];
|
|
1084
1084
|
operation: Operation$1;
|
|
1085
1085
|
};
|
|
1086
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1087
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1088
|
-
options: TOptions['resolvedOptions'];
|
|
1086
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1087
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1088
|
+
options: TOptions$1['resolvedOptions'];
|
|
1089
1089
|
schema: {
|
|
1090
1090
|
name: string;
|
|
1091
1091
|
tree: Array<Schema>;
|
|
1092
1092
|
value: SchemaObject$1;
|
|
1093
1093
|
};
|
|
1094
1094
|
};
|
|
1095
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1095
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1096
1096
|
name: string;
|
|
1097
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1098
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1099
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1097
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1098
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1099
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1100
1100
|
};
|
|
1101
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1101
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1102
1102
|
//#endregion
|
|
1103
1103
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1104
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1104
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1105
1105
|
oas: Oas;
|
|
1106
1106
|
exclude: Array<Exclude$1> | undefined;
|
|
1107
1107
|
include: Array<Include> | undefined;
|
|
1108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1108
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1109
1109
|
contentType: contentType | undefined;
|
|
1110
1110
|
pluginManager: PluginManager;
|
|
1111
1111
|
/**
|
|
@@ -1241,5 +1241,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
|
|
|
1241
1241
|
usedEnumNames: Record<string, number>;
|
|
1242
1242
|
}, ResolvePathOptions>;
|
|
1243
1243
|
//#endregion
|
|
1244
|
-
export {
|
|
1245
|
-
//# sourceMappingURL=types-
|
|
1244
|
+
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, Generator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1245
|
+
//# sourceMappingURL=types-uOjOvgDO.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
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",
|
|
@@ -57,18 +57,18 @@
|
|
|
57
57
|
"!/**/__tests__/**"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@kubb/core": "
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"@kubb/
|
|
64
|
-
"@kubb/
|
|
60
|
+
"@kubb/fabric-core": "^0.1.0",
|
|
61
|
+
"remeda": "^2.32.0",
|
|
62
|
+
"typescript": "5.9.3",
|
|
63
|
+
"@kubb/core": "4.2.0",
|
|
64
|
+
"@kubb/oas": "4.2.0",
|
|
65
|
+
"@kubb/plugin-oas": "4.2.0",
|
|
66
|
+
"@kubb/react": "4.2.0"
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
67
|
-
"
|
|
68
|
-
"react": "^18.3.1",
|
|
69
|
-
"tsdown": "^0.14.2",
|
|
69
|
+
"tsdown": "^0.15.9",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
|
-
"@kubb/plugin-oas": "4.
|
|
71
|
+
"@kubb/plugin-oas": "4.2.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@kubb/react": "^4.0.0"
|
package/src/components/Type.tsx
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import transformers from '@kubb/core/transformers'
|
|
2
|
+
import { print } from '@kubb/fabric-core/parsers/typescript'
|
|
2
3
|
import type { SchemaObject } from '@kubb/oas'
|
|
3
|
-
import { print } from '@kubb/parser-ts'
|
|
4
|
-
import * as factory from '@kubb/parser-ts/factory'
|
|
5
|
-
import { createTypeDeclaration } from '@kubb/parser-ts/factory'
|
|
6
4
|
import { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
|
|
7
5
|
import { File } from '@kubb/react'
|
|
8
|
-
import { Fragment, type ReactNode } from 'react'
|
|
9
6
|
import type ts from 'typescript'
|
|
7
|
+
import * as factory from '../factory.ts'
|
|
10
8
|
import { parse, typeKeywordMapper } from '../parser.ts'
|
|
11
9
|
import type { PluginTs } from '../types.ts'
|
|
12
10
|
|
|
@@ -23,7 +21,7 @@ type Props = {
|
|
|
23
21
|
keysToOmit?: string[]
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxType, enumType, mapper, description }: Props)
|
|
24
|
+
export function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxType, enumType, mapper, description }: Props) {
|
|
27
25
|
const typeNodes: ts.Node[] = []
|
|
28
26
|
|
|
29
27
|
if (!tree.length) {
|
|
@@ -97,7 +95,7 @@ export function Type({ name, typedName, tree, keysToOmit, schema, optionalType,
|
|
|
97
95
|
const useTypeGeneration = syntaxType === 'type' || [factory.syntaxKind.union].includes(type.kind as typeof factory.syntaxKind.union) || !!keysToOmit?.length
|
|
98
96
|
|
|
99
97
|
typeNodes.push(
|
|
100
|
-
createTypeDeclaration({
|
|
98
|
+
factory.createTypeDeclaration({
|
|
101
99
|
name,
|
|
102
100
|
isExportable: true,
|
|
103
101
|
type: keysToOmit?.length
|
|
@@ -142,9 +140,9 @@ export function Type({ name, typedName, tree, keysToOmit, schema, optionalType,
|
|
|
142
140
|
})
|
|
143
141
|
|
|
144
142
|
return (
|
|
145
|
-
|
|
143
|
+
<>
|
|
146
144
|
{enums.map(({ name, nameNode, typeName, typeNode }) => (
|
|
147
|
-
|
|
145
|
+
<>
|
|
148
146
|
{nameNode && (
|
|
149
147
|
<File.Source name={name} isExportable isIndexable>
|
|
150
148
|
{print([nameNode])}
|
|
@@ -160,13 +158,13 @@ export function Type({ name, typedName, tree, keysToOmit, schema, optionalType,
|
|
|
160
158
|
{print([typeNode])}
|
|
161
159
|
</File.Source>
|
|
162
160
|
}
|
|
163
|
-
|
|
161
|
+
</>
|
|
164
162
|
))}
|
|
165
163
|
{enums.every((item) => item.typeName !== name) && (
|
|
166
164
|
<File.Source name={typedName} isTypeOnly isExportable isIndexable>
|
|
167
165
|
{print(typeNodes)}
|
|
168
166
|
</File.Source>
|
|
169
167
|
)}
|
|
170
|
-
|
|
168
|
+
</>
|
|
171
169
|
)
|
|
172
170
|
}
|