@kubb/plugin-ts 4.3.1 → 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/chunk-DMmIE7y6.js +28 -0
- package/dist/{components-hXzJhjcI.cjs → components-dMdRcFGC.cjs} +13 -13
- package/dist/components-dMdRcFGC.cjs.map +1 -0
- package/dist/{components-Bbw-D3Zw.js → components-w0oFnzqd.js} +3 -3
- package/dist/components-w0oFnzqd.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +4 -3
- package/dist/components.d.ts +4 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +3 -3
- package/dist/generators.d.ts +3 -3
- 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-CiX20dYa.js → plugin-DII8Z_zh.js} +8 -5
- package/dist/plugin-DII8Z_zh.js.map +1 -0
- package/dist/{plugin-BCpsNJQR.cjs → plugin-DOspIoKu.cjs} +21 -18
- package/dist/plugin-DOspIoKu.cjs.map +1 -0
- package/dist/{types-Djigz1rf.d.cts → types-3xBQBYqb.d.cts} +220 -201
- package/dist/{types-BRA-0BWf.d.ts → types-CvqW_Qsz.d.ts} +225 -206
- package/package.json +9 -9
- package/src/components/OasType.tsx +3 -3
- package/src/components/Type.tsx +3 -2
- package/src/generators/oasGenerator.tsx +1 -1
- package/src/generators/typeGenerator.tsx +3 -2
- package/src/plugin.ts +2 -0
- package/src/types.ts +1 -1
- package/dist/components-Bbw-D3Zw.js.map +0 -1
- package/dist/components-hXzJhjcI.cjs.map +0 -1
- package/dist/plugin-BCpsNJQR.cjs.map +0 -1
- package/dist/plugin-CiX20dYa.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import * as OasTypes from "oas/types";
|
|
3
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -5,8 +6,8 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
5
6
|
import { OpenAPIV3 } from "openapi-types";
|
|
6
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
8
|
import BaseOas from "oas";
|
|
9
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
8
10
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
9
|
-
import { FileManager } from "@kubb/fabric-core";
|
|
10
11
|
|
|
11
12
|
//#region ../oas/src/types.d.ts
|
|
12
13
|
type contentType = 'application/json' | (string & {});
|
|
@@ -48,17 +49,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
48
49
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
49
50
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
50
51
|
*/
|
|
51
|
-
declare abstract class BaseGenerator<TOptions
|
|
52
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
52
53
|
#private;
|
|
53
|
-
constructor(options?: TOptions
|
|
54
|
-
get options(): TOptions
|
|
54
|
+
constructor(options?: TOptions, context?: TContext);
|
|
55
|
+
get options(): TOptions;
|
|
55
56
|
get context(): TContext;
|
|
56
|
-
set options(options: TOptions
|
|
57
|
+
set options(options: TOptions);
|
|
57
58
|
abstract build(...params: unknown[]): unknown;
|
|
58
59
|
}
|
|
59
60
|
//#endregion
|
|
60
61
|
//#region ../core/src/fs/types.d.ts
|
|
61
|
-
type BasePath<T
|
|
62
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
62
63
|
type Import = {
|
|
63
64
|
/**
|
|
64
65
|
* Import name to be used
|
|
@@ -132,9 +133,9 @@ type BaseName = `${string}.${string}`;
|
|
|
132
133
|
* Path will be full qualified path to a specified file
|
|
133
134
|
*/
|
|
134
135
|
type Path = string;
|
|
135
|
-
type AdvancedPath<T
|
|
136
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
136
137
|
type OptionalPath = Path | undefined | null;
|
|
137
|
-
type File<TMeta extends object = object> = {
|
|
138
|
+
type File$1<TMeta extends object = object> = {
|
|
138
139
|
/**
|
|
139
140
|
* Name to be used to create the path
|
|
140
141
|
* Based on UNIX basename, `${name}.extname`
|
|
@@ -157,7 +158,7 @@ type File<TMeta extends object = object> = {
|
|
|
157
158
|
};
|
|
158
159
|
type ResolvedImport = Import;
|
|
159
160
|
type ResolvedExport = Export;
|
|
160
|
-
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
161
|
+
type ResolvedFile<TMeta extends object = object> = File$1<TMeta> & {
|
|
161
162
|
/**
|
|
162
163
|
* @default object-hash
|
|
163
164
|
*/
|
|
@@ -221,7 +222,7 @@ type Logger = {
|
|
|
221
222
|
};
|
|
222
223
|
//#endregion
|
|
223
224
|
//#region ../core/src/utils/types.d.ts
|
|
224
|
-
type PossiblePromise<T
|
|
225
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
225
226
|
//#endregion
|
|
226
227
|
//#region ../core/src/types.d.ts
|
|
227
228
|
type InputPath = {
|
|
@@ -334,11 +335,11 @@ TName extends string = string,
|
|
|
334
335
|
/**
|
|
335
336
|
* Options of the plugin.
|
|
336
337
|
*/
|
|
337
|
-
TOptions
|
|
338
|
+
TOptions extends object = object,
|
|
338
339
|
/**
|
|
339
340
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
340
341
|
*/
|
|
341
|
-
TResolvedOptions extends object = TOptions
|
|
342
|
+
TResolvedOptions extends object = TOptions,
|
|
342
343
|
/**
|
|
343
344
|
* Context that you want to expose to other plugins.
|
|
344
345
|
*/
|
|
@@ -352,23 +353,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
352
353
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
353
354
|
*/
|
|
354
355
|
key: PluginKey<TName | string>;
|
|
355
|
-
options: TOptions
|
|
356
|
+
options: TOptions;
|
|
356
357
|
resolvedOptions: TResolvedOptions;
|
|
357
358
|
context: TContext;
|
|
358
359
|
resolvePathOptions: TResolvePathOptions;
|
|
359
360
|
};
|
|
360
361
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
361
|
-
type UserPlugin<TOptions
|
|
362
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
362
363
|
/**
|
|
363
364
|
* Unique name used for the plugin
|
|
364
365
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
365
366
|
* @example @kubb/typescript
|
|
366
367
|
*/
|
|
367
|
-
name: TOptions
|
|
368
|
+
name: TOptions['name'];
|
|
368
369
|
/**
|
|
369
370
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
370
371
|
*/
|
|
371
|
-
options: TOptions
|
|
372
|
+
options: TOptions['resolvedOptions'];
|
|
372
373
|
/**
|
|
373
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.
|
|
374
375
|
* Can be used to validate dependent plugins.
|
|
@@ -378,23 +379,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
378
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.
|
|
379
380
|
*/
|
|
380
381
|
post?: Array<string>;
|
|
381
|
-
} & (TOptions
|
|
382
|
+
} & (TOptions['context'] extends never ? {
|
|
382
383
|
context?: never;
|
|
383
384
|
} : {
|
|
384
|
-
context: (this: TOptions
|
|
385
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
385
386
|
});
|
|
386
|
-
type UserPluginWithLifeCycle<TOptions
|
|
387
|
-
type Plugin<TOptions
|
|
387
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
388
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
388
389
|
/**
|
|
389
390
|
* Unique name used for the plugin
|
|
390
391
|
* @example @kubb/typescript
|
|
391
392
|
*/
|
|
392
|
-
name: TOptions
|
|
393
|
+
name: TOptions['name'];
|
|
393
394
|
/**
|
|
394
395
|
* Internal key used when a developer uses more than one of the same plugin
|
|
395
396
|
* @private
|
|
396
397
|
*/
|
|
397
|
-
key: TOptions
|
|
398
|
+
key: TOptions['key'];
|
|
398
399
|
/**
|
|
399
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.
|
|
400
401
|
* Can be used to validate dependent plugins.
|
|
@@ -407,49 +408,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
407
408
|
/**
|
|
408
409
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
409
410
|
*/
|
|
410
|
-
options: TOptions
|
|
411
|
-
} & (TOptions
|
|
411
|
+
options: TOptions['resolvedOptions'];
|
|
412
|
+
} & (TOptions['context'] extends never ? {
|
|
412
413
|
context?: never;
|
|
413
414
|
} : {
|
|
414
|
-
context: TOptions
|
|
415
|
+
context: TOptions['context'];
|
|
415
416
|
});
|
|
416
|
-
type PluginWithLifeCycle<TOptions
|
|
417
|
-
type PluginLifecycle<TOptions
|
|
417
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
418
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
418
419
|
/**
|
|
419
420
|
* Start of the lifecycle of a plugin.
|
|
420
421
|
* @type hookParallel
|
|
421
422
|
*/
|
|
422
|
-
buildStart?: (this: PluginContext<TOptions
|
|
423
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
423
424
|
/**
|
|
424
425
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
425
426
|
* Options can als be included.
|
|
426
427
|
* @type hookFirst
|
|
427
428
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
428
429
|
*/
|
|
429
|
-
resolvePath?: (this: PluginContext<TOptions
|
|
430
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
430
431
|
/**
|
|
431
432
|
* Resolve to a name based on a string.
|
|
432
433
|
* Useful when converting to PascalCase or camelCase.
|
|
433
434
|
* @type hookFirst
|
|
434
435
|
* @example ('pet') => 'Pet'
|
|
435
436
|
*/
|
|
436
|
-
resolveName?: (this: PluginContext<TOptions
|
|
437
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
437
438
|
/**
|
|
438
439
|
* End of the plugin lifecycle.
|
|
439
440
|
* @type hookParallel
|
|
440
441
|
*/
|
|
441
|
-
buildEnd?: (this: PluginContext<TOptions
|
|
442
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
442
443
|
};
|
|
443
444
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
444
|
-
type PluginParameter<H
|
|
445
|
-
type ResolvePathParams<TOptions
|
|
445
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
446
|
+
type ResolvePathParams<TOptions = object> = {
|
|
446
447
|
pluginKey?: Plugin['key'];
|
|
447
448
|
baseName: BaseName;
|
|
448
449
|
mode?: Mode;
|
|
449
450
|
/**
|
|
450
451
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
451
452
|
*/
|
|
452
|
-
options?: TOptions
|
|
453
|
+
options?: TOptions;
|
|
453
454
|
};
|
|
454
455
|
type ResolveNameParams = {
|
|
455
456
|
name: string;
|
|
@@ -462,15 +463,16 @@ type ResolveNameParams = {
|
|
|
462
463
|
*/
|
|
463
464
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
464
465
|
};
|
|
465
|
-
type PluginContext<TOptions
|
|
466
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
467
|
+
fabric: Fabric;
|
|
466
468
|
config: Config;
|
|
467
469
|
/**
|
|
468
470
|
* @deprecated
|
|
469
471
|
*/
|
|
470
472
|
fileManager: FileManager;
|
|
471
473
|
pluginManager: PluginManager;
|
|
472
|
-
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
473
|
-
resolvePath: (params: ResolvePathParams<TOptions
|
|
474
|
+
addFile: (...file: Array<File$1>) => Promise<Array<ResolvedFile>>;
|
|
475
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
474
476
|
resolveName: (params: ResolveNameParams) => string;
|
|
475
477
|
logger: Logger;
|
|
476
478
|
/**
|
|
@@ -480,12 +482,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
480
482
|
/**
|
|
481
483
|
* Current plugin
|
|
482
484
|
*/
|
|
483
|
-
plugin: Plugin<TOptions
|
|
485
|
+
plugin: Plugin<TOptions>;
|
|
484
486
|
};
|
|
485
487
|
/**
|
|
486
488
|
* Specify the export location for the files and define the behavior of the output
|
|
487
489
|
*/
|
|
488
|
-
type Output<TOptions
|
|
490
|
+
type Output<TOptions> = {
|
|
489
491
|
/**
|
|
490
492
|
* Path to the output folder or file that will contain the generated code
|
|
491
493
|
*/
|
|
@@ -498,11 +500,11 @@ type Output<TOptions$1> = {
|
|
|
498
500
|
/**
|
|
499
501
|
* Add a banner text in the beginning of every file
|
|
500
502
|
*/
|
|
501
|
-
banner?: string | ((options: TOptions
|
|
503
|
+
banner?: string | ((options: TOptions) => string);
|
|
502
504
|
/**
|
|
503
505
|
* Add a footer text in the beginning of every file
|
|
504
506
|
*/
|
|
505
|
-
footer?: string | ((options: TOptions
|
|
507
|
+
footer?: string | ((options: TOptions) => string);
|
|
506
508
|
};
|
|
507
509
|
type GroupContext = {
|
|
508
510
|
group: string;
|
|
@@ -521,20 +523,21 @@ type Group = {
|
|
|
521
523
|
//#region ../core/src/PluginManager.d.ts
|
|
522
524
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
523
525
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
524
|
-
type Executer<H
|
|
526
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
525
527
|
message: string;
|
|
526
528
|
strategy: Strategy;
|
|
527
|
-
hookName: H
|
|
529
|
+
hookName: H;
|
|
528
530
|
plugin: Plugin;
|
|
529
531
|
parameters?: unknown[] | undefined;
|
|
530
532
|
output?: unknown;
|
|
531
533
|
};
|
|
532
|
-
type ParseResult<H
|
|
533
|
-
type SafeParseResult<H
|
|
534
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
535
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
534
536
|
result: Result;
|
|
535
537
|
plugin: Plugin;
|
|
536
538
|
};
|
|
537
539
|
type Options$2 = {
|
|
540
|
+
fabric: Fabric;
|
|
538
541
|
logger: Logger;
|
|
539
542
|
/**
|
|
540
543
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -546,20 +549,16 @@ type Events = {
|
|
|
546
549
|
executed: [executer: Executer];
|
|
547
550
|
error: [error: Error];
|
|
548
551
|
};
|
|
549
|
-
type GetFileProps<TOptions
|
|
552
|
+
type GetFileProps<TOptions = object> = {
|
|
550
553
|
name: string;
|
|
551
554
|
mode?: Mode;
|
|
552
555
|
extname: Extname;
|
|
553
556
|
pluginKey: Plugin['key'];
|
|
554
|
-
options?: TOptions
|
|
557
|
+
options?: TOptions;
|
|
555
558
|
};
|
|
556
559
|
declare class PluginManager {
|
|
557
560
|
#private;
|
|
558
561
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
559
|
-
/**
|
|
560
|
-
* @deprecated do not use from pluginManager
|
|
561
|
-
*/
|
|
562
|
-
readonly fileManager: FileManager;
|
|
563
562
|
readonly events: EventEmitter<Events>;
|
|
564
563
|
readonly config: Config;
|
|
565
564
|
readonly executed: Array<Executer>;
|
|
@@ -572,7 +571,7 @@ declare class PluginManager {
|
|
|
572
571
|
extname,
|
|
573
572
|
pluginKey,
|
|
574
573
|
options
|
|
575
|
-
}: GetFileProps<TOptions>): File<{
|
|
574
|
+
}: GetFileProps<TOptions>): File$1<{
|
|
576
575
|
pluginKey: Plugin['key'];
|
|
577
576
|
}>;
|
|
578
577
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
@@ -672,6 +671,170 @@ type FileMetaBase = {
|
|
|
672
671
|
pluginKey?: Plugin['key'];
|
|
673
672
|
};
|
|
674
673
|
//#endregion
|
|
674
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
675
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
676
|
+
name: string;
|
|
677
|
+
type: 'react';
|
|
678
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
679
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
680
|
+
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
681
|
+
};
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
684
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
685
|
+
/**
|
|
686
|
+
* @deprecated
|
|
687
|
+
*/
|
|
688
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
689
|
+
options: TOptions['resolvedOptions'];
|
|
690
|
+
operations: Array<Operation$1>;
|
|
691
|
+
};
|
|
692
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
693
|
+
/**
|
|
694
|
+
* @deprecated
|
|
695
|
+
*/
|
|
696
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
697
|
+
options: TOptions['resolvedOptions'];
|
|
698
|
+
operation: Operation$1;
|
|
699
|
+
};
|
|
700
|
+
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
701
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
702
|
+
options: TOptions['resolvedOptions'];
|
|
703
|
+
schema: {
|
|
704
|
+
name: string;
|
|
705
|
+
tree: Array<Schema>;
|
|
706
|
+
value: SchemaObject$1;
|
|
707
|
+
};
|
|
708
|
+
};
|
|
709
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
712
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
713
|
+
name: string;
|
|
714
|
+
type: 'core';
|
|
715
|
+
operations: (props: OperationsProps<TOptions>) => Promise<File$1[]>;
|
|
716
|
+
operation: (props: OperationProps<TOptions>) => Promise<File$1[]>;
|
|
717
|
+
schema: (props: SchemaProps$1<TOptions>) => Promise<File$1[]>;
|
|
718
|
+
};
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
721
|
+
type ResolvePathOptions = {
|
|
722
|
+
pluginKey?: Plugin['key'];
|
|
723
|
+
group?: {
|
|
724
|
+
tag?: string;
|
|
725
|
+
path?: string;
|
|
726
|
+
};
|
|
727
|
+
type?: ResolveNameParams['type'];
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
731
|
+
* @example import { Pet } from './Pet'
|
|
732
|
+
*
|
|
733
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
734
|
+
*
|
|
735
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
736
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
737
|
+
*/
|
|
738
|
+
type Ref = {
|
|
739
|
+
propertyName: string;
|
|
740
|
+
originalName: string;
|
|
741
|
+
path: OptionalPath;
|
|
742
|
+
pluginKey?: Plugin['key'];
|
|
743
|
+
};
|
|
744
|
+
type Refs = Record<string, Ref>;
|
|
745
|
+
type OperationSchema = {
|
|
746
|
+
/**
|
|
747
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
748
|
+
*/
|
|
749
|
+
name: string;
|
|
750
|
+
schema: SchemaObject$1;
|
|
751
|
+
operation?: Operation$1;
|
|
752
|
+
/**
|
|
753
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
754
|
+
*/
|
|
755
|
+
operationName: string;
|
|
756
|
+
description?: string;
|
|
757
|
+
statusCode?: number;
|
|
758
|
+
keys?: string[];
|
|
759
|
+
keysToOmit?: string[];
|
|
760
|
+
withData?: boolean;
|
|
761
|
+
};
|
|
762
|
+
type OperationSchemas = {
|
|
763
|
+
pathParams?: OperationSchema & {
|
|
764
|
+
keysToOmit?: never;
|
|
765
|
+
};
|
|
766
|
+
queryParams?: OperationSchema & {
|
|
767
|
+
keysToOmit?: never;
|
|
768
|
+
};
|
|
769
|
+
headerParams?: OperationSchema & {
|
|
770
|
+
keysToOmit?: never;
|
|
771
|
+
};
|
|
772
|
+
request?: OperationSchema;
|
|
773
|
+
response: OperationSchema;
|
|
774
|
+
responses: Array<OperationSchema>;
|
|
775
|
+
statusCodes?: Array<OperationSchema>;
|
|
776
|
+
errors?: Array<OperationSchema>;
|
|
777
|
+
};
|
|
778
|
+
type ByTag = {
|
|
779
|
+
type: 'tag';
|
|
780
|
+
pattern: string | RegExp;
|
|
781
|
+
};
|
|
782
|
+
type ByOperationId = {
|
|
783
|
+
type: 'operationId';
|
|
784
|
+
pattern: string | RegExp;
|
|
785
|
+
};
|
|
786
|
+
type ByPath = {
|
|
787
|
+
type: 'path';
|
|
788
|
+
pattern: string | RegExp;
|
|
789
|
+
};
|
|
790
|
+
type ByMethod = {
|
|
791
|
+
type: 'method';
|
|
792
|
+
pattern: HttpMethod | RegExp;
|
|
793
|
+
};
|
|
794
|
+
type BySchemaName = {
|
|
795
|
+
type: 'schemaName';
|
|
796
|
+
pattern: string | RegExp;
|
|
797
|
+
};
|
|
798
|
+
type ByContentType = {
|
|
799
|
+
type: 'contentType';
|
|
800
|
+
pattern: string | RegExp;
|
|
801
|
+
};
|
|
802
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
803
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
804
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
805
|
+
options: Partial<TOptions>;
|
|
806
|
+
};
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
809
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
810
|
+
fabric: Fabric;
|
|
811
|
+
oas: Oas;
|
|
812
|
+
exclude: Array<Exclude$1> | undefined;
|
|
813
|
+
include: Array<Include> | undefined;
|
|
814
|
+
override: Array<Override<TOptions>> | undefined;
|
|
815
|
+
contentType: contentType | undefined;
|
|
816
|
+
pluginManager: PluginManager;
|
|
817
|
+
/**
|
|
818
|
+
* Current plugin
|
|
819
|
+
*/
|
|
820
|
+
plugin: Plugin<TPluginOptions>;
|
|
821
|
+
mode: Mode;
|
|
822
|
+
};
|
|
823
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
824
|
+
#private;
|
|
825
|
+
getSchemas(operation: Operation$1, {
|
|
826
|
+
resolveName
|
|
827
|
+
}?: {
|
|
828
|
+
resolveName?: (name: string) => string;
|
|
829
|
+
}): OperationSchemas;
|
|
830
|
+
getOperations(): Promise<Array<{
|
|
831
|
+
path: string;
|
|
832
|
+
method: HttpMethod;
|
|
833
|
+
operation: Operation$1;
|
|
834
|
+
}>>;
|
|
835
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File$1<TFileMeta>>>;
|
|
836
|
+
}
|
|
837
|
+
//#endregion
|
|
675
838
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
676
839
|
type SchemaKeywordMapper = {
|
|
677
840
|
object: {
|
|
@@ -889,96 +1052,9 @@ type Schema = {
|
|
|
889
1052
|
keyword: string;
|
|
890
1053
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
891
1054
|
//#endregion
|
|
892
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
893
|
-
type ResolvePathOptions = {
|
|
894
|
-
pluginKey?: Plugin['key'];
|
|
895
|
-
group?: {
|
|
896
|
-
tag?: string;
|
|
897
|
-
path?: string;
|
|
898
|
-
};
|
|
899
|
-
type?: ResolveNameParams['type'];
|
|
900
|
-
};
|
|
901
|
-
/**
|
|
902
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
903
|
-
* @example import { Pet } from './Pet'
|
|
904
|
-
*
|
|
905
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
906
|
-
*
|
|
907
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
908
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
909
|
-
*/
|
|
910
|
-
type Ref = {
|
|
911
|
-
propertyName: string;
|
|
912
|
-
originalName: string;
|
|
913
|
-
path: OptionalPath;
|
|
914
|
-
pluginKey?: Plugin['key'];
|
|
915
|
-
};
|
|
916
|
-
type Refs = Record<string, Ref>;
|
|
917
|
-
type OperationSchema = {
|
|
918
|
-
/**
|
|
919
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
920
|
-
*/
|
|
921
|
-
name: string;
|
|
922
|
-
schema: SchemaObject$1;
|
|
923
|
-
operation?: Operation$1;
|
|
924
|
-
/**
|
|
925
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
926
|
-
*/
|
|
927
|
-
operationName: string;
|
|
928
|
-
description?: string;
|
|
929
|
-
statusCode?: number;
|
|
930
|
-
keys?: string[];
|
|
931
|
-
keysToOmit?: string[];
|
|
932
|
-
withData?: boolean;
|
|
933
|
-
};
|
|
934
|
-
type OperationSchemas = {
|
|
935
|
-
pathParams?: OperationSchema & {
|
|
936
|
-
keysToOmit?: never;
|
|
937
|
-
};
|
|
938
|
-
queryParams?: OperationSchema & {
|
|
939
|
-
keysToOmit?: never;
|
|
940
|
-
};
|
|
941
|
-
headerParams?: OperationSchema & {
|
|
942
|
-
keysToOmit?: never;
|
|
943
|
-
};
|
|
944
|
-
request?: OperationSchema;
|
|
945
|
-
response: OperationSchema;
|
|
946
|
-
responses: Array<OperationSchema>;
|
|
947
|
-
statusCodes?: Array<OperationSchema>;
|
|
948
|
-
errors?: Array<OperationSchema>;
|
|
949
|
-
};
|
|
950
|
-
type ByTag = {
|
|
951
|
-
type: 'tag';
|
|
952
|
-
pattern: string | RegExp;
|
|
953
|
-
};
|
|
954
|
-
type ByOperationId = {
|
|
955
|
-
type: 'operationId';
|
|
956
|
-
pattern: string | RegExp;
|
|
957
|
-
};
|
|
958
|
-
type ByPath = {
|
|
959
|
-
type: 'path';
|
|
960
|
-
pattern: string | RegExp;
|
|
961
|
-
};
|
|
962
|
-
type ByMethod = {
|
|
963
|
-
type: 'method';
|
|
964
|
-
pattern: HttpMethod | RegExp;
|
|
965
|
-
};
|
|
966
|
-
type BySchemaName = {
|
|
967
|
-
type: 'schemaName';
|
|
968
|
-
pattern: string | RegExp;
|
|
969
|
-
};
|
|
970
|
-
type ByContentType = {
|
|
971
|
-
type: 'contentType';
|
|
972
|
-
pattern: string | RegExp;
|
|
973
|
-
};
|
|
974
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
975
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
976
|
-
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
977
|
-
options: Partial<TOptions$1>;
|
|
978
|
-
};
|
|
979
|
-
//#endregion
|
|
980
1055
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
981
|
-
type Context
|
|
1056
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1057
|
+
fabric: Fabric;
|
|
982
1058
|
oas: Oas;
|
|
983
1059
|
pluginManager: PluginManager;
|
|
984
1060
|
/**
|
|
@@ -987,7 +1063,7 @@ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
987
1063
|
plugin: Plugin<TPluginOptions>;
|
|
988
1064
|
mode: Mode;
|
|
989
1065
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
990
|
-
override: Array<Override<TOptions
|
|
1066
|
+
override: Array<Override<TOptions>> | undefined;
|
|
991
1067
|
contentType?: contentType;
|
|
992
1068
|
output?: string;
|
|
993
1069
|
};
|
|
@@ -1010,15 +1086,15 @@ type SchemaGeneratorOptions = {
|
|
|
1010
1086
|
* TODO TODO add docs
|
|
1011
1087
|
* @beta
|
|
1012
1088
|
*/
|
|
1013
|
-
schema?: (schemaProps: SchemaProps
|
|
1089
|
+
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1014
1090
|
};
|
|
1015
1091
|
};
|
|
1016
|
-
type SchemaProps
|
|
1092
|
+
type SchemaProps = {
|
|
1017
1093
|
schemaObject?: SchemaObject$1;
|
|
1018
1094
|
name?: string;
|
|
1019
1095
|
parentName?: string;
|
|
1020
1096
|
};
|
|
1021
|
-
declare class SchemaGenerator<TOptions
|
|
1097
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1022
1098
|
#private;
|
|
1023
1099
|
refs: Refs;
|
|
1024
1100
|
/**
|
|
@@ -1026,71 +1102,14 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
1026
1102
|
* Delegates to getBaseTypeFromSchema internally and
|
|
1027
1103
|
* optionally adds a union with null.
|
|
1028
1104
|
*/
|
|
1029
|
-
parse(props: SchemaProps
|
|
1105
|
+
parse(props: SchemaProps): Schema[];
|
|
1030
1106
|
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1031
1107
|
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1032
1108
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1033
1109
|
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1034
1110
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1035
1111
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
1036
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1037
|
-
}
|
|
1038
|
-
//#endregion
|
|
1039
|
-
//#region ../plugin-oas/src/generator.d.ts
|
|
1040
|
-
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1041
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1042
|
-
options: TOptions$1['resolvedOptions'];
|
|
1043
|
-
operations: Array<Operation$1>;
|
|
1044
|
-
};
|
|
1045
|
-
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1046
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1047
|
-
options: TOptions$1['resolvedOptions'];
|
|
1048
|
-
operation: Operation$1;
|
|
1049
|
-
};
|
|
1050
|
-
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1051
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1052
|
-
options: TOptions$1['resolvedOptions'];
|
|
1053
|
-
schema: {
|
|
1054
|
-
name: string;
|
|
1055
|
-
tree: Array<Schema>;
|
|
1056
|
-
value: SchemaObject$1;
|
|
1057
|
-
};
|
|
1058
|
-
};
|
|
1059
|
-
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1060
|
-
name: string;
|
|
1061
|
-
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1062
|
-
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1063
|
-
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1064
|
-
};
|
|
1065
|
-
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1066
|
-
//#endregion
|
|
1067
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1068
|
-
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1069
|
-
oas: Oas;
|
|
1070
|
-
exclude: Array<Exclude$1> | undefined;
|
|
1071
|
-
include: Array<Include> | undefined;
|
|
1072
|
-
override: Array<Override<TOptions$1>> | undefined;
|
|
1073
|
-
contentType: contentType | undefined;
|
|
1074
|
-
pluginManager: PluginManager;
|
|
1075
|
-
/**
|
|
1076
|
-
* Current plugin
|
|
1077
|
-
*/
|
|
1078
|
-
plugin: Plugin<TPluginOptions>;
|
|
1079
|
-
mode: Mode;
|
|
1080
|
-
};
|
|
1081
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
1082
|
-
#private;
|
|
1083
|
-
getSchemas(operation: Operation$1, {
|
|
1084
|
-
resolveName
|
|
1085
|
-
}?: {
|
|
1086
|
-
resolveName?: (name: string) => string;
|
|
1087
|
-
}): OperationSchemas;
|
|
1088
|
-
getOperations(): Promise<Array<{
|
|
1089
|
-
path: string;
|
|
1090
|
-
method: HttpMethod;
|
|
1091
|
-
operation: Operation$1;
|
|
1092
|
-
}>>;
|
|
1093
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1112
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File$1<TFileMeta>>>;
|
|
1094
1113
|
}
|
|
1095
1114
|
//#endregion
|
|
1096
1115
|
//#region src/types.d.ts
|
|
@@ -1205,5 +1224,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
|
|
|
1205
1224
|
usedEnumNames: Record<string, number>;
|
|
1206
1225
|
}, ResolvePathOptions>;
|
|
1207
1226
|
//#endregion
|
|
1208
|
-
export { UserPluginWithLifeCycle as a,
|
|
1209
|
-
//# sourceMappingURL=types-
|
|
1227
|
+
export { UserPluginWithLifeCycle as a, ReactGenerator as i, PluginTs as n, OasTypes as o, Schema as r, SchemaObject$1 as s, Options$1 as t };
|
|
1228
|
+
//# sourceMappingURL=types-CvqW_Qsz.d.ts.map
|