@kubb/plugin-ts 4.4.0 → 4.5.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-dMdRcFGC.cjs → components-BAMqcrcR.cjs} +40 -36
- package/dist/components-BAMqcrcR.cjs.map +1 -0
- package/dist/{components-w0oFnzqd.js → components-pUMLFnXb.js} +39 -35
- package/dist/components-pUMLFnXb.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +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-DOspIoKu.cjs → plugin-BKcG9C_Y.cjs} +72 -79
- package/dist/plugin-BKcG9C_Y.cjs.map +1 -0
- package/dist/{plugin-DII8Z_zh.js → plugin-CfDmQVWY.js} +73 -80
- package/dist/plugin-CfDmQVWY.js.map +1 -0
- package/dist/{types-3xBQBYqb.d.cts → types-BXlkWRNi.d.ts} +184 -304
- package/dist/{types-CvqW_Qsz.d.ts → types-BdHzvKY0.d.cts} +184 -304
- package/package.json +16 -11
- package/src/components/Type.tsx +1 -6
- package/src/generators/index.ts +1 -1
- package/src/generators/oasGenerator.tsx +4 -4
- package/src/generators/typeGenerator.tsx +15 -21
- package/src/parser.ts +11 -15
- package/src/types.ts +2 -1
- package/dist/components-dMdRcFGC.cjs.map +0 -1
- package/dist/components-w0oFnzqd.js.map +0 -1
- package/dist/plugin-DII8Z_zh.js.map +0 -1
- package/dist/plugin-DOspIoKu.cjs.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Fabric, FileManager } 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";
|
|
@@ -5,9 +7,8 @@ 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
9
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
8
|
-
import {
|
|
10
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
9
11
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
|
-
import ts from "typescript";
|
|
11
12
|
|
|
12
13
|
//#region ../oas/src/types.d.ts
|
|
13
14
|
type contentType = 'application/json' | (string & {});
|
|
@@ -58,121 +59,6 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
58
59
|
abstract build(...params: unknown[]): unknown;
|
|
59
60
|
}
|
|
60
61
|
//#endregion
|
|
61
|
-
//#region ../core/src/fs/types.d.ts
|
|
62
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
63
|
-
type Import = {
|
|
64
|
-
/**
|
|
65
|
-
* Import name to be used
|
|
66
|
-
* @example ["useState"]
|
|
67
|
-
* @example "React"
|
|
68
|
-
*/
|
|
69
|
-
name: string | Array<string | {
|
|
70
|
-
propertyName: string;
|
|
71
|
-
name?: string;
|
|
72
|
-
}>;
|
|
73
|
-
/**
|
|
74
|
-
* Path for the import
|
|
75
|
-
* @example '@kubb/core'
|
|
76
|
-
*/
|
|
77
|
-
path: string;
|
|
78
|
-
/**
|
|
79
|
-
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
80
|
-
*/
|
|
81
|
-
isTypeOnly?: boolean;
|
|
82
|
-
isNameSpace?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
85
|
-
*/
|
|
86
|
-
root?: string;
|
|
87
|
-
};
|
|
88
|
-
type Source = {
|
|
89
|
-
name?: string;
|
|
90
|
-
value?: string;
|
|
91
|
-
isTypeOnly?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Has const or type 'export'
|
|
94
|
-
* @default false
|
|
95
|
-
*/
|
|
96
|
-
isExportable?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* When set, barrel generation will add this
|
|
99
|
-
* @default false
|
|
100
|
-
*/
|
|
101
|
-
isIndexable?: boolean;
|
|
102
|
-
};
|
|
103
|
-
type Export = {
|
|
104
|
-
/**
|
|
105
|
-
* Export name to be used.
|
|
106
|
-
* @example ["useState"]
|
|
107
|
-
* @example "React"
|
|
108
|
-
*/
|
|
109
|
-
name?: string | Array<string>;
|
|
110
|
-
/**
|
|
111
|
-
* Path for the import.
|
|
112
|
-
* @example '@kubb/core'
|
|
113
|
-
*/
|
|
114
|
-
path: string;
|
|
115
|
-
/**
|
|
116
|
-
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
117
|
-
*/
|
|
118
|
-
isTypeOnly?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
121
|
-
*/
|
|
122
|
-
asAlias?: boolean;
|
|
123
|
-
};
|
|
124
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
125
|
-
type Mode = 'single' | 'split';
|
|
126
|
-
/**
|
|
127
|
-
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
128
|
-
* Based on UNIX basename
|
|
129
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
130
|
-
*/
|
|
131
|
-
type BaseName = `${string}.${string}`;
|
|
132
|
-
/**
|
|
133
|
-
* Path will be full qualified path to a specified file
|
|
134
|
-
*/
|
|
135
|
-
type Path = string;
|
|
136
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
137
|
-
type OptionalPath = Path | undefined | null;
|
|
138
|
-
type File<TMeta extends object = object> = {
|
|
139
|
-
/**
|
|
140
|
-
* Name to be used to create the path
|
|
141
|
-
* Based on UNIX basename, `${name}.extname`
|
|
142
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
143
|
-
*/
|
|
144
|
-
baseName: BaseName;
|
|
145
|
-
/**
|
|
146
|
-
* Path will be full qualified path to a specified file
|
|
147
|
-
*/
|
|
148
|
-
path: AdvancedPath<BaseName> | Path;
|
|
149
|
-
sources: Array<Source>;
|
|
150
|
-
imports?: Array<Import>;
|
|
151
|
-
exports?: Array<Export>;
|
|
152
|
-
/**
|
|
153
|
-
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
154
|
-
*/
|
|
155
|
-
meta?: TMeta;
|
|
156
|
-
banner?: string;
|
|
157
|
-
footer?: string;
|
|
158
|
-
};
|
|
159
|
-
type ResolvedImport = Import;
|
|
160
|
-
type ResolvedExport = Export;
|
|
161
|
-
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
162
|
-
/**
|
|
163
|
-
* @default object-hash
|
|
164
|
-
*/
|
|
165
|
-
id: string;
|
|
166
|
-
/**
|
|
167
|
-
* Contains the first part of the baseName, generated based on baseName
|
|
168
|
-
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
169
|
-
*/
|
|
170
|
-
name: string;
|
|
171
|
-
extname: Extname;
|
|
172
|
-
imports: Array<ResolvedImport>;
|
|
173
|
-
exports: Array<ResolvedExport>;
|
|
174
|
-
};
|
|
175
|
-
//#endregion
|
|
176
62
|
//#region ../core/src/utils/EventEmitter.d.ts
|
|
177
63
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
178
64
|
#private;
|
|
@@ -296,7 +182,7 @@ type Config<TInput = Input> = {
|
|
|
296
182
|
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
297
183
|
* @default { '.ts': '.ts'}
|
|
298
184
|
*/
|
|
299
|
-
extension?: Record<Extname, Extname | ''>;
|
|
185
|
+
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
300
186
|
/**
|
|
301
187
|
* Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
|
|
302
188
|
* @default 'named'
|
|
@@ -427,7 +313,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
427
313
|
* @type hookFirst
|
|
428
314
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
429
315
|
*/
|
|
430
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
316
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
|
431
317
|
/**
|
|
432
318
|
* Resolve to a name based on a string.
|
|
433
319
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -445,8 +331,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
|
445
331
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
446
332
|
type ResolvePathParams<TOptions = object> = {
|
|
447
333
|
pluginKey?: Plugin['key'];
|
|
448
|
-
baseName: BaseName;
|
|
449
|
-
mode?: Mode;
|
|
334
|
+
baseName: KubbFile.BaseName;
|
|
335
|
+
mode?: KubbFile.Mode;
|
|
450
336
|
/**
|
|
451
337
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
452
338
|
*/
|
|
@@ -471,8 +357,8 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
471
357
|
*/
|
|
472
358
|
fileManager: FileManager;
|
|
473
359
|
pluginManager: PluginManager;
|
|
474
|
-
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
475
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
360
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
|
|
361
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
476
362
|
resolveName: (params: ResolveNameParams) => string;
|
|
477
363
|
logger: Logger;
|
|
478
364
|
/**
|
|
@@ -551,8 +437,8 @@ type Events = {
|
|
|
551
437
|
};
|
|
552
438
|
type GetFileProps<TOptions = object> = {
|
|
553
439
|
name: string;
|
|
554
|
-
mode?: Mode;
|
|
555
|
-
extname: Extname;
|
|
440
|
+
mode?: KubbFile.Mode;
|
|
441
|
+
extname: KubbFile.Extname;
|
|
556
442
|
pluginKey: Plugin['key'];
|
|
557
443
|
options?: TOptions;
|
|
558
444
|
};
|
|
@@ -571,10 +457,10 @@ declare class PluginManager {
|
|
|
571
457
|
extname,
|
|
572
458
|
pluginKey,
|
|
573
459
|
options
|
|
574
|
-
}: GetFileProps<TOptions>): File<{
|
|
460
|
+
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
575
461
|
pluginKey: Plugin['key'];
|
|
576
462
|
}>;
|
|
577
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
463
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
578
464
|
resolveName: (params: ResolveNameParams) => string;
|
|
579
465
|
/**
|
|
580
466
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -671,170 +557,6 @@ type FileMetaBase = {
|
|
|
671
557
|
pluginKey?: Plugin['key'];
|
|
672
558
|
};
|
|
673
559
|
//#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[]>;
|
|
716
|
-
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
717
|
-
schema: (props: SchemaProps$1<TOptions>) => Promise<File[]>;
|
|
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<TFileMeta>>>;
|
|
836
|
-
}
|
|
837
|
-
//#endregion
|
|
838
560
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
839
561
|
type SchemaKeywordMapper = {
|
|
840
562
|
object: {
|
|
@@ -948,7 +670,7 @@ type SchemaKeywordMapper = {
|
|
|
948
670
|
/**
|
|
949
671
|
* Full qualified path.
|
|
950
672
|
*/
|
|
951
|
-
path: OptionalPath;
|
|
673
|
+
path: KubbFile.OptionalPath;
|
|
952
674
|
/**
|
|
953
675
|
* When true `File.Import` will be used.
|
|
954
676
|
* When false a reference will be used inside the current file.
|
|
@@ -1052,8 +774,96 @@ type Schema = {
|
|
|
1052
774
|
keyword: string;
|
|
1053
775
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
1054
776
|
//#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
|
|
1055
865
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1056
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
866
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1057
867
|
fabric: Fabric;
|
|
1058
868
|
oas: Oas;
|
|
1059
869
|
pluginManager: PluginManager;
|
|
@@ -1061,7 +871,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1061
871
|
* Current plugin
|
|
1062
872
|
*/
|
|
1063
873
|
plugin: Plugin<TPluginOptions>;
|
|
1064
|
-
mode: Mode;
|
|
874
|
+
mode: KubbFile.Mode;
|
|
1065
875
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1066
876
|
override: Array<Override<TOptions>> | undefined;
|
|
1067
877
|
contentType?: contentType;
|
|
@@ -1086,15 +896,15 @@ type SchemaGeneratorOptions = {
|
|
|
1086
896
|
* TODO TODO add docs
|
|
1087
897
|
* @beta
|
|
1088
898
|
*/
|
|
1089
|
-
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
899
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1090
900
|
};
|
|
1091
901
|
};
|
|
1092
|
-
type SchemaProps = {
|
|
902
|
+
type SchemaProps$1 = {
|
|
1093
903
|
schemaObject?: SchemaObject$1;
|
|
1094
904
|
name?: string;
|
|
1095
905
|
parentName?: string;
|
|
1096
906
|
};
|
|
1097
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
907
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1098
908
|
#private;
|
|
1099
909
|
refs: Refs;
|
|
1100
910
|
/**
|
|
@@ -1102,14 +912,84 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1102
912
|
* Delegates to getBaseTypeFromSchema internally and
|
|
1103
913
|
* optionally adds a union with null.
|
|
1104
914
|
*/
|
|
1105
|
-
parse(props: SchemaProps): Schema[];
|
|
1106
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1107
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
915
|
+
parse(props: SchemaProps$1): Schema[];
|
|
1108
916
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1109
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1110
917
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1111
918
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
1112
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
919
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
920
|
+
}
|
|
921
|
+
//#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
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
932
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
933
|
+
name: string;
|
|
934
|
+
type: 'react';
|
|
935
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
936
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
937
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
938
|
+
};
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
941
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
942
|
+
config: Config;
|
|
943
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
944
|
+
plugin: Plugin<TOptions>;
|
|
945
|
+
operations: Array<Operation$1>;
|
|
946
|
+
};
|
|
947
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
948
|
+
config: Config;
|
|
949
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
950
|
+
plugin: Plugin<TOptions>;
|
|
951
|
+
operation: Operation$1;
|
|
952
|
+
};
|
|
953
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
954
|
+
config: Config;
|
|
955
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
956
|
+
plugin: Plugin<TOptions>;
|
|
957
|
+
schema: {
|
|
958
|
+
name: string;
|
|
959
|
+
tree: Array<Schema>;
|
|
960
|
+
value: SchemaObject$1;
|
|
961
|
+
};
|
|
962
|
+
};
|
|
963
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
966
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
967
|
+
fabric: Fabric;
|
|
968
|
+
oas: Oas;
|
|
969
|
+
exclude: Array<Exclude$1> | undefined;
|
|
970
|
+
include: Array<Include> | undefined;
|
|
971
|
+
override: Array<Override<TOptions>> | undefined;
|
|
972
|
+
contentType: contentType | undefined;
|
|
973
|
+
pluginManager: PluginManager;
|
|
974
|
+
/**
|
|
975
|
+
* Current plugin
|
|
976
|
+
*/
|
|
977
|
+
plugin: Plugin<TPluginOptions>;
|
|
978
|
+
mode: KubbFile.Mode;
|
|
979
|
+
};
|
|
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>>>;
|
|
1113
993
|
}
|
|
1114
994
|
//#endregion
|
|
1115
995
|
//#region src/types.d.ts
|
|
@@ -1224,5 +1104,5 @@ type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, {
|
|
|
1224
1104
|
usedEnumNames: Record<string, number>;
|
|
1225
1105
|
}, ResolvePathOptions>;
|
|
1226
1106
|
//#endregion
|
|
1227
|
-
export { UserPluginWithLifeCycle as a,
|
|
1228
|
-
//# sourceMappingURL=types-
|
|
1107
|
+
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-BXlkWRNi.d.ts.map
|