@kubb/plugin-client 3.16.2 → 3.16.4
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/Operations-Cxn7C-GC.cjs +228 -0
- package/dist/Operations-Cxn7C-GC.cjs.map +1 -0
- package/dist/Operations-tGJwS9Oj.js +210 -0
- package/dist/Operations-tGJwS9Oj.js.map +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/clients/axios.cjs +24 -30
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.d.cts +23 -21
- package/dist/clients/axios.d.ts +23 -21
- package/dist/clients/axios.js +23 -23
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +37 -36
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.d.cts +20 -18
- package/dist/clients/fetch.d.ts +20 -18
- package/dist/clients/fetch.js +37 -34
- package/dist/clients/fetch.js.map +1 -1
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +97 -56
- package/dist/components.d.ts +97 -56
- package/dist/components.js +3 -3
- package/dist/generators-BQnLTqYl.js +216 -0
- package/dist/generators-BQnLTqYl.js.map +1 -0
- package/dist/generators-XXsaqEtA.cjs +234 -0
- package/dist/generators-XXsaqEtA.cjs.map +1 -0
- package/dist/generators.cjs +5 -20
- package/dist/generators.d.cts +12 -11
- package/dist/generators.d.ts +12 -11
- package/dist/generators.js +4 -4
- package/dist/index.cjs +89 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +88 -112
- package/dist/index.js.map +1 -1
- package/dist/types-CdM4kNiz.d.ts +1274 -0
- package/dist/types-Cpfa5PKO.d.cts +1274 -0
- package/package.json +27 -34
- package/dist/chunk-H5KNP3DD.cjs +0 -205
- package/dist/chunk-H5KNP3DD.cjs.map +0 -1
- package/dist/chunk-LNJCFB5O.js +0 -201
- package/dist/chunk-LNJCFB5O.js.map +0 -1
- package/dist/chunk-QNFXNUH5.js +0 -187
- package/dist/chunk-QNFXNUH5.js.map +0 -1
- package/dist/chunk-SDEXSATF.cjs +0 -191
- package/dist/chunk-SDEXSATF.cjs.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-DFo3xInC.d.cts +0 -119
- package/dist/types-DFo3xInC.d.ts +0 -119
|
@@ -0,0 +1,1274 @@
|
|
|
1
|
+
import * as OasTypes from "oas/types";
|
|
2
|
+
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
|
+
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
4
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
5
|
+
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
|
+
import BaseOas from "oas";
|
|
7
|
+
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
+
import { ReactNode } from "react";
|
|
9
|
+
|
|
10
|
+
//#region ../oas/src/types.d.ts
|
|
11
|
+
type contentType = 'application/json' | (string & {});
|
|
12
|
+
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
13
|
+
'x-nullable'?: boolean;
|
|
14
|
+
$ref?: string;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../oas/src/Oas.d.ts
|
|
18
|
+
type Options$4 = {
|
|
19
|
+
contentType?: contentType;
|
|
20
|
+
discriminator?: 'strict' | 'inherit';
|
|
21
|
+
};
|
|
22
|
+
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
23
|
+
#private;
|
|
24
|
+
document: TOAS;
|
|
25
|
+
constructor({
|
|
26
|
+
oas,
|
|
27
|
+
user
|
|
28
|
+
}: {
|
|
29
|
+
oas: TOAS | OASDocument | string;
|
|
30
|
+
user?: User;
|
|
31
|
+
});
|
|
32
|
+
setOptions(options: Options$4): void;
|
|
33
|
+
get options(): Options$4;
|
|
34
|
+
get($ref: string): any;
|
|
35
|
+
getKey($ref: string): string | undefined;
|
|
36
|
+
set($ref: string, value: unknown): false | undefined;
|
|
37
|
+
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
38
|
+
dereferenceWithRef(schema?: unknown): any;
|
|
39
|
+
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
40
|
+
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
41
|
+
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
42
|
+
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../core/src/BaseGenerator.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
48
|
+
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
49
|
+
*/
|
|
50
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
51
|
+
#private;
|
|
52
|
+
constructor(options?: TOptions, context?: TContext);
|
|
53
|
+
get options(): TOptions;
|
|
54
|
+
get context(): TContext;
|
|
55
|
+
set options(options: TOptions);
|
|
56
|
+
abstract build(...params: unknown[]): unknown;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../core/src/fs/types.d.ts
|
|
60
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
61
|
+
type Import = {
|
|
62
|
+
/**
|
|
63
|
+
* Import name to be used
|
|
64
|
+
* @example ["useState"]
|
|
65
|
+
* @example "React"
|
|
66
|
+
*/
|
|
67
|
+
name: string | Array<string | {
|
|
68
|
+
propertyName: string;
|
|
69
|
+
name?: string;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Path for the import
|
|
73
|
+
* @example '@kubb/core'
|
|
74
|
+
*/
|
|
75
|
+
path: string;
|
|
76
|
+
/**
|
|
77
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
78
|
+
*/
|
|
79
|
+
isTypeOnly?: boolean;
|
|
80
|
+
isNameSpace?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
83
|
+
*/
|
|
84
|
+
root?: string;
|
|
85
|
+
};
|
|
86
|
+
type Source = {
|
|
87
|
+
name?: string;
|
|
88
|
+
value?: string;
|
|
89
|
+
isTypeOnly?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Has const or type 'export'
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
isExportable?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* When set, barrel generation will add this
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
isIndexable?: boolean;
|
|
100
|
+
};
|
|
101
|
+
type Export = {
|
|
102
|
+
/**
|
|
103
|
+
* Export name to be used.
|
|
104
|
+
* @example ["useState"]
|
|
105
|
+
* @example "React"
|
|
106
|
+
*/
|
|
107
|
+
name?: string | Array<string>;
|
|
108
|
+
/**
|
|
109
|
+
* Path for the import.
|
|
110
|
+
* @example '@kubb/core'
|
|
111
|
+
*/
|
|
112
|
+
path: string;
|
|
113
|
+
/**
|
|
114
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
115
|
+
*/
|
|
116
|
+
isTypeOnly?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
119
|
+
*/
|
|
120
|
+
asAlias?: boolean;
|
|
121
|
+
};
|
|
122
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
123
|
+
type Mode = 'single' | 'split';
|
|
124
|
+
/**
|
|
125
|
+
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
126
|
+
* Based on UNIX basename
|
|
127
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
128
|
+
*/
|
|
129
|
+
type BaseName = `${string}.${string}`;
|
|
130
|
+
/**
|
|
131
|
+
* Path will be full qualified path to a specified file
|
|
132
|
+
*/
|
|
133
|
+
type Path = string;
|
|
134
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
135
|
+
type OptionalPath = Path | undefined | null;
|
|
136
|
+
type File<TMeta extends object = object> = {
|
|
137
|
+
/**
|
|
138
|
+
* Name to be used to create the path
|
|
139
|
+
* Based on UNIX basename, `${name}.extname`
|
|
140
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
141
|
+
*/
|
|
142
|
+
baseName: BaseName;
|
|
143
|
+
/**
|
|
144
|
+
* Path will be full qualified path to a specified file
|
|
145
|
+
*/
|
|
146
|
+
path: AdvancedPath<BaseName> | Path;
|
|
147
|
+
sources: Array<Source>;
|
|
148
|
+
imports?: Array<Import>;
|
|
149
|
+
exports?: Array<Export>;
|
|
150
|
+
/**
|
|
151
|
+
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
152
|
+
*/
|
|
153
|
+
meta?: TMeta;
|
|
154
|
+
banner?: string;
|
|
155
|
+
footer?: string;
|
|
156
|
+
};
|
|
157
|
+
type ResolvedImport = Import;
|
|
158
|
+
type ResolvedExport = Export;
|
|
159
|
+
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
160
|
+
/**
|
|
161
|
+
* @default object-hash
|
|
162
|
+
*/
|
|
163
|
+
id: string;
|
|
164
|
+
/**
|
|
165
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
166
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
167
|
+
*/
|
|
168
|
+
name: string;
|
|
169
|
+
extname: Extname;
|
|
170
|
+
imports: Array<ResolvedImport>;
|
|
171
|
+
exports: Array<ResolvedExport>;
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region ../core/src/utils/EventEmitter.d.ts
|
|
175
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
176
|
+
#private;
|
|
177
|
+
constructor();
|
|
178
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
179
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
180
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
181
|
+
removeAll(): void;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ../core/src/logger.d.ts
|
|
185
|
+
type DebugEvent = {
|
|
186
|
+
date: Date;
|
|
187
|
+
logs: string[];
|
|
188
|
+
fileName?: string;
|
|
189
|
+
};
|
|
190
|
+
type Events$1 = {
|
|
191
|
+
start: [message: string];
|
|
192
|
+
success: [message: string];
|
|
193
|
+
error: [message: string, cause: Error];
|
|
194
|
+
warning: [message: string];
|
|
195
|
+
debug: [DebugEvent];
|
|
196
|
+
info: [message: string];
|
|
197
|
+
progress_start: [{
|
|
198
|
+
id: string;
|
|
199
|
+
size: number;
|
|
200
|
+
message?: string;
|
|
201
|
+
}];
|
|
202
|
+
progressed: [{
|
|
203
|
+
id: string;
|
|
204
|
+
message?: string;
|
|
205
|
+
}];
|
|
206
|
+
progress_stop: [{
|
|
207
|
+
id: string;
|
|
208
|
+
}];
|
|
209
|
+
};
|
|
210
|
+
type Logger = {
|
|
211
|
+
/**
|
|
212
|
+
* Optional config name to show in CLI output
|
|
213
|
+
*/
|
|
214
|
+
name?: string;
|
|
215
|
+
logLevel: LogLevel;
|
|
216
|
+
consola?: ConsolaInstance;
|
|
217
|
+
on: EventEmitter<Events$1>['on'];
|
|
218
|
+
emit: EventEmitter<Events$1>['emit'];
|
|
219
|
+
writeLogs: () => Promise<string[]>;
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
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;
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region ../core/src/types.d.ts
|
|
228
|
+
type InputPath = {
|
|
229
|
+
/**
|
|
230
|
+
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
231
|
+
*/
|
|
232
|
+
path: string;
|
|
233
|
+
};
|
|
234
|
+
type InputData = {
|
|
235
|
+
/**
|
|
236
|
+
* A `string` or `object` that contains your Swagger/OpenAPI data.
|
|
237
|
+
*/
|
|
238
|
+
data: string | unknown;
|
|
239
|
+
};
|
|
240
|
+
type Input = InputPath | InputData | Array<InputPath>;
|
|
241
|
+
type BarrelType = 'all' | 'named' | 'propagate';
|
|
242
|
+
/**
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
type Config<TInput = Input> = {
|
|
246
|
+
/**
|
|
247
|
+
* The name to display in the CLI output.
|
|
248
|
+
*/
|
|
249
|
+
name?: string;
|
|
250
|
+
/**
|
|
251
|
+
* The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
|
|
252
|
+
* @default process.cwd()
|
|
253
|
+
*/
|
|
254
|
+
root: string;
|
|
255
|
+
/**
|
|
256
|
+
* You can use either `input.path` or `input.data`, depending on your specific needs.
|
|
257
|
+
*/
|
|
258
|
+
input: TInput;
|
|
259
|
+
output: {
|
|
260
|
+
/**
|
|
261
|
+
* The path where all generated files will be exported.
|
|
262
|
+
* This can be an absolute path or a path relative to the specified root option.
|
|
263
|
+
*/
|
|
264
|
+
path: string;
|
|
265
|
+
/**
|
|
266
|
+
* Clean the output directory before each build.
|
|
267
|
+
*/
|
|
268
|
+
clean?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Save files to the file system.
|
|
271
|
+
* @default true
|
|
272
|
+
*/
|
|
273
|
+
write?: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
276
|
+
* @default { '.ts': '.ts'}
|
|
277
|
+
*/
|
|
278
|
+
extension?: Record<Extname, Extname | ''>;
|
|
279
|
+
/**
|
|
280
|
+
* 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`.
|
|
281
|
+
* @default 'named'
|
|
282
|
+
*/
|
|
283
|
+
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
284
|
+
/**
|
|
285
|
+
* Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
|
|
286
|
+
* - 'simple': will only add banner with link to Kubb
|
|
287
|
+
* - 'full': will add source, title, description and the OpenAPI version used
|
|
288
|
+
* @default 'simple'
|
|
289
|
+
*/
|
|
290
|
+
defaultBanner?: 'simple' | 'full' | false;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* An array of Kubb plugins that will be used in the generation.
|
|
294
|
+
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
295
|
+
* If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
|
|
296
|
+
*/
|
|
297
|
+
plugins?: Array<Plugin>;
|
|
298
|
+
/**
|
|
299
|
+
* Hooks that will be called when a specific action is triggered in Kubb.
|
|
300
|
+
*/
|
|
301
|
+
hooks?: {
|
|
302
|
+
/**
|
|
303
|
+
* Hook that will be triggered at the end of all executions.
|
|
304
|
+
* Useful for running Prettier or ESLint to format/lint your code.
|
|
305
|
+
*/
|
|
306
|
+
done?: string | Array<string>;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
type PluginFactoryOptions<
|
|
310
|
+
/**
|
|
311
|
+
* Name to be used for the plugin, this will also be used for they key.
|
|
312
|
+
*/
|
|
313
|
+
TName extends string = string,
|
|
314
|
+
/**
|
|
315
|
+
* Options of the plugin.
|
|
316
|
+
*/
|
|
317
|
+
TOptions extends object = object,
|
|
318
|
+
/**
|
|
319
|
+
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
320
|
+
*/
|
|
321
|
+
TResolvedOptions extends object = TOptions,
|
|
322
|
+
/**
|
|
323
|
+
* Context that you want to expose to other plugins.
|
|
324
|
+
*/
|
|
325
|
+
TContext = any,
|
|
326
|
+
/**
|
|
327
|
+
* When calling `resolvePath` you can specify better types.
|
|
328
|
+
*/
|
|
329
|
+
TResolvePathOptions extends object = object> = {
|
|
330
|
+
name: TName;
|
|
331
|
+
/**
|
|
332
|
+
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
333
|
+
*/
|
|
334
|
+
key: PluginKey<TName | string>;
|
|
335
|
+
options: TOptions;
|
|
336
|
+
resolvedOptions: TResolvedOptions;
|
|
337
|
+
context: TContext;
|
|
338
|
+
resolvePathOptions: TResolvePathOptions;
|
|
339
|
+
};
|
|
340
|
+
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
341
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
342
|
+
/**
|
|
343
|
+
* Unique name used for the plugin
|
|
344
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
345
|
+
* @example @kubb/typescript
|
|
346
|
+
*/
|
|
347
|
+
name: TOptions['name'];
|
|
348
|
+
/**
|
|
349
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
350
|
+
*/
|
|
351
|
+
options: TOptions['resolvedOptions'];
|
|
352
|
+
/**
|
|
353
|
+
* 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.
|
|
354
|
+
* Can be used to validate dependent plugins.
|
|
355
|
+
*/
|
|
356
|
+
pre?: Array<string>;
|
|
357
|
+
/**
|
|
358
|
+
* 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.
|
|
359
|
+
*/
|
|
360
|
+
post?: Array<string>;
|
|
361
|
+
} & (TOptions['context'] extends never ? {
|
|
362
|
+
context?: never;
|
|
363
|
+
} : {
|
|
364
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
365
|
+
});
|
|
366
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
367
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
368
|
+
/**
|
|
369
|
+
* Unique name used for the plugin
|
|
370
|
+
* @example @kubb/typescript
|
|
371
|
+
*/
|
|
372
|
+
name: TOptions['name'];
|
|
373
|
+
/**
|
|
374
|
+
* Internal key used when a developer uses more than one of the same plugin
|
|
375
|
+
* @private
|
|
376
|
+
*/
|
|
377
|
+
key: TOptions['key'];
|
|
378
|
+
/**
|
|
379
|
+
* 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.
|
|
380
|
+
* Can be used to validate dependent plugins.
|
|
381
|
+
*/
|
|
382
|
+
pre?: Array<string>;
|
|
383
|
+
/**
|
|
384
|
+
* 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.
|
|
385
|
+
*/
|
|
386
|
+
post?: Array<string>;
|
|
387
|
+
/**
|
|
388
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
389
|
+
*/
|
|
390
|
+
options: TOptions['resolvedOptions'];
|
|
391
|
+
} & (TOptions['context'] extends never ? {
|
|
392
|
+
context?: never;
|
|
393
|
+
} : {
|
|
394
|
+
context: TOptions['context'];
|
|
395
|
+
});
|
|
396
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
397
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
398
|
+
/**
|
|
399
|
+
* Start of the lifecycle of a plugin.
|
|
400
|
+
* @type hookParallel
|
|
401
|
+
*/
|
|
402
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
405
|
+
* Options can als be included.
|
|
406
|
+
* @type hookFirst
|
|
407
|
+
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
408
|
+
*/
|
|
409
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
410
|
+
/**
|
|
411
|
+
* Resolve to a name based on a string.
|
|
412
|
+
* Useful when converting to PascalCase or camelCase.
|
|
413
|
+
* @type hookFirst
|
|
414
|
+
* @example ('pet') => 'Pet'
|
|
415
|
+
*/
|
|
416
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
417
|
+
/**
|
|
418
|
+
* End of the plugin lifecycle.
|
|
419
|
+
* @type hookParallel
|
|
420
|
+
*/
|
|
421
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
422
|
+
};
|
|
423
|
+
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
424
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
425
|
+
type ResolvePathParams<TOptions = object> = {
|
|
426
|
+
pluginKey?: Plugin['key'];
|
|
427
|
+
baseName: BaseName;
|
|
428
|
+
mode?: Mode;
|
|
429
|
+
/**
|
|
430
|
+
* Options to be passed to 'resolvePath' 3th parameter
|
|
431
|
+
*/
|
|
432
|
+
options?: TOptions;
|
|
433
|
+
};
|
|
434
|
+
type ResolveNameParams = {
|
|
435
|
+
name: string;
|
|
436
|
+
pluginKey?: Plugin['key'];
|
|
437
|
+
/**
|
|
438
|
+
* `file` will be used to customize the name of the created file(use of camelCase)
|
|
439
|
+
* `function` can be used to customize the exported functions(use of camelCase)
|
|
440
|
+
* `type` is a special type for TypeScript(use of PascalCase)
|
|
441
|
+
* `const` can be used for variables(use of camelCase)
|
|
442
|
+
*/
|
|
443
|
+
type?: 'file' | 'function' | 'type' | 'const';
|
|
444
|
+
};
|
|
445
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
446
|
+
config: Config;
|
|
447
|
+
fileManager: FileManager;
|
|
448
|
+
pluginManager: PluginManager;
|
|
449
|
+
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
450
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
451
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
452
|
+
logger: Logger;
|
|
453
|
+
/**
|
|
454
|
+
* All plugins
|
|
455
|
+
*/
|
|
456
|
+
plugins: Plugin[];
|
|
457
|
+
/**
|
|
458
|
+
* Current plugin
|
|
459
|
+
*/
|
|
460
|
+
plugin: Plugin<TOptions>;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Specify the export location for the files and define the behavior of the output
|
|
464
|
+
*/
|
|
465
|
+
type Output<TOptions> = {
|
|
466
|
+
/**
|
|
467
|
+
* Path to the output folder or file that will contain the generated code
|
|
468
|
+
*/
|
|
469
|
+
path: string;
|
|
470
|
+
/**
|
|
471
|
+
* Define what needs to be exported, here you can also disable the export of barrel files
|
|
472
|
+
* @default 'named'
|
|
473
|
+
*/
|
|
474
|
+
barrelType?: BarrelType | false;
|
|
475
|
+
/**
|
|
476
|
+
* Add a banner text in the beginning of every file
|
|
477
|
+
*/
|
|
478
|
+
banner?: string | ((options: TOptions) => string);
|
|
479
|
+
/**
|
|
480
|
+
* Add a footer text in the beginning of every file
|
|
481
|
+
*/
|
|
482
|
+
footer?: string | ((options: TOptions) => string);
|
|
483
|
+
};
|
|
484
|
+
type GroupContext = {
|
|
485
|
+
group: string;
|
|
486
|
+
};
|
|
487
|
+
type Group = {
|
|
488
|
+
/**
|
|
489
|
+
* Define a type where to group the files on
|
|
490
|
+
*/
|
|
491
|
+
type: 'tag' | 'path';
|
|
492
|
+
/**
|
|
493
|
+
* Return the name of a group based on the group name, this will be used for the file and name generation
|
|
494
|
+
*/
|
|
495
|
+
name?: (context: GroupContext) => string;
|
|
496
|
+
};
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region ../core/src/FileManager.d.ts
|
|
499
|
+
type FileMetaBase = {
|
|
500
|
+
pluginKey?: Plugin['key'];
|
|
501
|
+
};
|
|
502
|
+
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
503
|
+
type AddIndexesProps = {
|
|
504
|
+
type: BarrelType | false | undefined;
|
|
505
|
+
/**
|
|
506
|
+
* Root based on root and output.path specified in the config
|
|
507
|
+
*/
|
|
508
|
+
root: string;
|
|
509
|
+
/**
|
|
510
|
+
* Output for plugin
|
|
511
|
+
*/
|
|
512
|
+
output: {
|
|
513
|
+
path: string;
|
|
514
|
+
};
|
|
515
|
+
group?: {
|
|
516
|
+
output: string;
|
|
517
|
+
exportAs: string;
|
|
518
|
+
};
|
|
519
|
+
logger?: Logger;
|
|
520
|
+
meta?: FileMetaBase;
|
|
521
|
+
};
|
|
522
|
+
type WriteFilesProps = {
|
|
523
|
+
root: Config['root'];
|
|
524
|
+
extension?: Record<Extname, Extname | ''>;
|
|
525
|
+
logger?: Logger;
|
|
526
|
+
dryRun?: boolean;
|
|
527
|
+
};
|
|
528
|
+
declare class FileManager {
|
|
529
|
+
#private;
|
|
530
|
+
constructor();
|
|
531
|
+
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
532
|
+
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
533
|
+
deleteByPath(path: Path): Promise<void>;
|
|
534
|
+
clear(): Promise<void>;
|
|
535
|
+
getFiles(): Promise<Array<ResolvedFile>>;
|
|
536
|
+
processFiles({
|
|
537
|
+
dryRun,
|
|
538
|
+
root,
|
|
539
|
+
extension,
|
|
540
|
+
logger
|
|
541
|
+
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
542
|
+
getBarrelFiles({
|
|
543
|
+
type,
|
|
544
|
+
meta,
|
|
545
|
+
root,
|
|
546
|
+
output,
|
|
547
|
+
logger
|
|
548
|
+
}: AddIndexesProps): Promise<File[]>;
|
|
549
|
+
static getMode(path: string | undefined | null): Mode;
|
|
550
|
+
}
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region ../core/src/PluginManager.d.ts
|
|
553
|
+
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
554
|
+
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
555
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
556
|
+
message: string;
|
|
557
|
+
strategy: Strategy;
|
|
558
|
+
hookName: H;
|
|
559
|
+
plugin: Plugin;
|
|
560
|
+
parameters?: unknown[] | undefined;
|
|
561
|
+
output?: unknown;
|
|
562
|
+
};
|
|
563
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
564
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
565
|
+
result: Result;
|
|
566
|
+
plugin: Plugin;
|
|
567
|
+
};
|
|
568
|
+
type Options$3 = {
|
|
569
|
+
logger: Logger;
|
|
570
|
+
/**
|
|
571
|
+
* @default Number.POSITIVE_INFINITY
|
|
572
|
+
*/
|
|
573
|
+
concurrency?: number;
|
|
574
|
+
};
|
|
575
|
+
type Events = {
|
|
576
|
+
executing: [executer: Executer];
|
|
577
|
+
executed: [executer: Executer];
|
|
578
|
+
error: [error: Error];
|
|
579
|
+
};
|
|
580
|
+
type GetFileProps<TOptions = object> = {
|
|
581
|
+
name: string;
|
|
582
|
+
mode?: Mode;
|
|
583
|
+
extname: Extname;
|
|
584
|
+
pluginKey: Plugin['key'];
|
|
585
|
+
options?: TOptions;
|
|
586
|
+
};
|
|
587
|
+
declare class PluginManager {
|
|
588
|
+
#private;
|
|
589
|
+
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
590
|
+
readonly fileManager: FileManager;
|
|
591
|
+
readonly events: EventEmitter<Events>;
|
|
592
|
+
readonly config: Config;
|
|
593
|
+
readonly executed: Array<Executer>;
|
|
594
|
+
readonly logger: Logger;
|
|
595
|
+
readonly options: Options$3;
|
|
596
|
+
constructor(config: Config, options: Options$3);
|
|
597
|
+
getFile<TOptions = object>({
|
|
598
|
+
name,
|
|
599
|
+
mode,
|
|
600
|
+
extname,
|
|
601
|
+
pluginKey,
|
|
602
|
+
options
|
|
603
|
+
}: GetFileProps<TOptions>): File<{
|
|
604
|
+
pluginKey: Plugin['key'];
|
|
605
|
+
}>;
|
|
606
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
607
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
608
|
+
/**
|
|
609
|
+
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
610
|
+
*/
|
|
611
|
+
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
612
|
+
/**
|
|
613
|
+
* Run a specific hookName for plugin x.
|
|
614
|
+
*/
|
|
615
|
+
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
616
|
+
pluginKey,
|
|
617
|
+
hookName,
|
|
618
|
+
parameters,
|
|
619
|
+
message
|
|
620
|
+
}: {
|
|
621
|
+
pluginKey: Plugin['key'];
|
|
622
|
+
hookName: H;
|
|
623
|
+
parameters: PluginParameter<H>;
|
|
624
|
+
message: string;
|
|
625
|
+
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
626
|
+
/**
|
|
627
|
+
* Run a specific hookName for plugin x.
|
|
628
|
+
*/
|
|
629
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
630
|
+
pluginKey,
|
|
631
|
+
hookName,
|
|
632
|
+
parameters,
|
|
633
|
+
message
|
|
634
|
+
}: {
|
|
635
|
+
pluginKey: Plugin['key'];
|
|
636
|
+
hookName: H;
|
|
637
|
+
parameters: PluginParameter<H>;
|
|
638
|
+
message: string;
|
|
639
|
+
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
640
|
+
/**
|
|
641
|
+
* First non-null result stops and will return it's value.
|
|
642
|
+
*/
|
|
643
|
+
hookFirst<H extends PluginLifecycleHooks>({
|
|
644
|
+
hookName,
|
|
645
|
+
parameters,
|
|
646
|
+
skipped,
|
|
647
|
+
message
|
|
648
|
+
}: {
|
|
649
|
+
hookName: H;
|
|
650
|
+
parameters: PluginParameter<H>;
|
|
651
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
652
|
+
message: string;
|
|
653
|
+
}): Promise<SafeParseResult<H>>;
|
|
654
|
+
/**
|
|
655
|
+
* First non-null result stops and will return it's value.
|
|
656
|
+
*/
|
|
657
|
+
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
658
|
+
hookName,
|
|
659
|
+
parameters,
|
|
660
|
+
skipped,
|
|
661
|
+
message
|
|
662
|
+
}: {
|
|
663
|
+
hookName: H;
|
|
664
|
+
parameters: PluginParameter<H>;
|
|
665
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
666
|
+
message: string;
|
|
667
|
+
}): SafeParseResult<H>;
|
|
668
|
+
/**
|
|
669
|
+
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
670
|
+
*/
|
|
671
|
+
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
672
|
+
hookName,
|
|
673
|
+
parameters,
|
|
674
|
+
message
|
|
675
|
+
}: {
|
|
676
|
+
hookName: H;
|
|
677
|
+
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
678
|
+
message: string;
|
|
679
|
+
}): Promise<Awaited<TOuput>[]>;
|
|
680
|
+
/**
|
|
681
|
+
* Chains plugins
|
|
682
|
+
*/
|
|
683
|
+
hookSeq<H extends PluginLifecycleHooks>({
|
|
684
|
+
hookName,
|
|
685
|
+
parameters,
|
|
686
|
+
message
|
|
687
|
+
}: {
|
|
688
|
+
hookName: H;
|
|
689
|
+
parameters?: PluginParameter<H>;
|
|
690
|
+
message: string;
|
|
691
|
+
}): Promise<void>;
|
|
692
|
+
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
693
|
+
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
694
|
+
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;
|
|
695
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
696
|
+
}
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region ../react/src/utils/getFunctionParams.d.ts
|
|
699
|
+
type Param = {
|
|
700
|
+
/**
|
|
701
|
+
* `object` will return the pathParams as an object.
|
|
702
|
+
*
|
|
703
|
+
* `inline` will return the pathParams as comma separated params.
|
|
704
|
+
* @default `'inline'`
|
|
705
|
+
* @private
|
|
706
|
+
*/
|
|
707
|
+
mode?: 'object' | 'inline' | 'inlineSpread';
|
|
708
|
+
type?: 'string' | 'number' | (string & {});
|
|
709
|
+
optional?: boolean;
|
|
710
|
+
/**
|
|
711
|
+
* @example test = "default"
|
|
712
|
+
*/
|
|
713
|
+
default?: string;
|
|
714
|
+
/**
|
|
715
|
+
* Used for no TypeScript(with mode object)
|
|
716
|
+
* @example test: "default"
|
|
717
|
+
*/
|
|
718
|
+
value?: string;
|
|
719
|
+
children?: Params;
|
|
720
|
+
};
|
|
721
|
+
type Params = Record<string, Param | undefined>;
|
|
722
|
+
type Options$2 = {
|
|
723
|
+
type: 'constructor' | 'call' | 'object' | 'objectValue';
|
|
724
|
+
transformName?: (name: string) => string;
|
|
725
|
+
transformType?: (type: string) => string;
|
|
726
|
+
};
|
|
727
|
+
declare class FunctionParams {
|
|
728
|
+
#private;
|
|
729
|
+
static factory(params: Params): FunctionParams;
|
|
730
|
+
constructor(params: Params);
|
|
731
|
+
get params(): Params;
|
|
732
|
+
get flatParams(): Params;
|
|
733
|
+
toCall({
|
|
734
|
+
transformName,
|
|
735
|
+
transformType
|
|
736
|
+
}?: Pick<Options$2, 'transformName' | 'transformType'>): string;
|
|
737
|
+
toObject(): string;
|
|
738
|
+
toObjectValue(): string;
|
|
739
|
+
toConstructor(): string;
|
|
740
|
+
}
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region ../react/src/types.d.ts
|
|
743
|
+
type KubbNode = ReactNode;
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
746
|
+
type SchemaKeywordMapper = {
|
|
747
|
+
object: {
|
|
748
|
+
keyword: 'object';
|
|
749
|
+
args: {
|
|
750
|
+
properties: {
|
|
751
|
+
[x: string]: Schema[];
|
|
752
|
+
};
|
|
753
|
+
additionalProperties: Schema[];
|
|
754
|
+
strict?: boolean;
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
url: {
|
|
758
|
+
keyword: 'url';
|
|
759
|
+
};
|
|
760
|
+
readOnly: {
|
|
761
|
+
keyword: 'readOnly';
|
|
762
|
+
};
|
|
763
|
+
writeOnly: {
|
|
764
|
+
keyword: 'writeOnly';
|
|
765
|
+
};
|
|
766
|
+
uuid: {
|
|
767
|
+
keyword: 'uuid';
|
|
768
|
+
};
|
|
769
|
+
email: {
|
|
770
|
+
keyword: 'email';
|
|
771
|
+
};
|
|
772
|
+
firstName: {
|
|
773
|
+
keyword: 'firstName';
|
|
774
|
+
};
|
|
775
|
+
lastName: {
|
|
776
|
+
keyword: 'lastName';
|
|
777
|
+
};
|
|
778
|
+
phone: {
|
|
779
|
+
keyword: 'phone';
|
|
780
|
+
};
|
|
781
|
+
password: {
|
|
782
|
+
keyword: 'password';
|
|
783
|
+
};
|
|
784
|
+
date: {
|
|
785
|
+
keyword: 'date';
|
|
786
|
+
args: {
|
|
787
|
+
type?: 'date' | 'string';
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
time: {
|
|
791
|
+
keyword: 'time';
|
|
792
|
+
args: {
|
|
793
|
+
type?: 'date' | 'string';
|
|
794
|
+
};
|
|
795
|
+
};
|
|
796
|
+
datetime: {
|
|
797
|
+
keyword: 'datetime';
|
|
798
|
+
args: {
|
|
799
|
+
offset?: boolean;
|
|
800
|
+
local?: boolean;
|
|
801
|
+
};
|
|
802
|
+
};
|
|
803
|
+
tuple: {
|
|
804
|
+
keyword: 'tuple';
|
|
805
|
+
args: {
|
|
806
|
+
items: Schema[];
|
|
807
|
+
min?: number;
|
|
808
|
+
max?: number;
|
|
809
|
+
rest?: Schema;
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
array: {
|
|
813
|
+
keyword: 'array';
|
|
814
|
+
args: {
|
|
815
|
+
items: Schema[];
|
|
816
|
+
min?: number;
|
|
817
|
+
max?: number;
|
|
818
|
+
unique?: boolean;
|
|
819
|
+
};
|
|
820
|
+
};
|
|
821
|
+
enum: {
|
|
822
|
+
keyword: 'enum';
|
|
823
|
+
args: {
|
|
824
|
+
name: string;
|
|
825
|
+
typeName: string;
|
|
826
|
+
asConst: boolean;
|
|
827
|
+
items: Array<{
|
|
828
|
+
name: string | number;
|
|
829
|
+
format: 'string' | 'number' | 'boolean';
|
|
830
|
+
value?: string | number | boolean;
|
|
831
|
+
}>;
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
and: {
|
|
835
|
+
keyword: 'and';
|
|
836
|
+
args: Schema[];
|
|
837
|
+
};
|
|
838
|
+
const: {
|
|
839
|
+
keyword: 'const';
|
|
840
|
+
args: {
|
|
841
|
+
name: string | number;
|
|
842
|
+
format: 'string' | 'number' | 'boolean';
|
|
843
|
+
value?: string | number | boolean;
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
union: {
|
|
847
|
+
keyword: 'union';
|
|
848
|
+
args: Schema[];
|
|
849
|
+
};
|
|
850
|
+
ref: {
|
|
851
|
+
keyword: 'ref';
|
|
852
|
+
args: {
|
|
853
|
+
name: string;
|
|
854
|
+
$ref: string;
|
|
855
|
+
/**
|
|
856
|
+
* Full qualified path.
|
|
857
|
+
*/
|
|
858
|
+
path: OptionalPath;
|
|
859
|
+
/**
|
|
860
|
+
* When true `File.Import` will be used.
|
|
861
|
+
* When false a reference will be used inside the current file.
|
|
862
|
+
*/
|
|
863
|
+
isImportable: boolean;
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
matches: {
|
|
867
|
+
keyword: 'matches';
|
|
868
|
+
args?: string;
|
|
869
|
+
};
|
|
870
|
+
boolean: {
|
|
871
|
+
keyword: 'boolean';
|
|
872
|
+
};
|
|
873
|
+
default: {
|
|
874
|
+
keyword: 'default';
|
|
875
|
+
args: string | number | boolean;
|
|
876
|
+
};
|
|
877
|
+
string: {
|
|
878
|
+
keyword: 'string';
|
|
879
|
+
};
|
|
880
|
+
integer: {
|
|
881
|
+
keyword: 'integer';
|
|
882
|
+
};
|
|
883
|
+
number: {
|
|
884
|
+
keyword: 'number';
|
|
885
|
+
};
|
|
886
|
+
max: {
|
|
887
|
+
keyword: 'max';
|
|
888
|
+
args: number;
|
|
889
|
+
};
|
|
890
|
+
min: {
|
|
891
|
+
keyword: 'min';
|
|
892
|
+
args: number;
|
|
893
|
+
};
|
|
894
|
+
describe: {
|
|
895
|
+
keyword: 'describe';
|
|
896
|
+
args: string;
|
|
897
|
+
};
|
|
898
|
+
example: {
|
|
899
|
+
keyword: 'example';
|
|
900
|
+
args: string;
|
|
901
|
+
};
|
|
902
|
+
deprecated: {
|
|
903
|
+
keyword: 'deprecated';
|
|
904
|
+
};
|
|
905
|
+
optional: {
|
|
906
|
+
keyword: 'optional';
|
|
907
|
+
};
|
|
908
|
+
undefined: {
|
|
909
|
+
keyword: 'undefined';
|
|
910
|
+
};
|
|
911
|
+
nullish: {
|
|
912
|
+
keyword: 'nullish';
|
|
913
|
+
};
|
|
914
|
+
nullable: {
|
|
915
|
+
keyword: 'nullable';
|
|
916
|
+
};
|
|
917
|
+
null: {
|
|
918
|
+
keyword: 'null';
|
|
919
|
+
};
|
|
920
|
+
any: {
|
|
921
|
+
keyword: 'any';
|
|
922
|
+
};
|
|
923
|
+
unknown: {
|
|
924
|
+
keyword: 'unknown';
|
|
925
|
+
};
|
|
926
|
+
void: {
|
|
927
|
+
keyword: 'void';
|
|
928
|
+
};
|
|
929
|
+
blob: {
|
|
930
|
+
keyword: 'blob';
|
|
931
|
+
};
|
|
932
|
+
schema: {
|
|
933
|
+
keyword: 'schema';
|
|
934
|
+
args: {
|
|
935
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
936
|
+
format?: string;
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
name: {
|
|
940
|
+
keyword: 'name';
|
|
941
|
+
args: string;
|
|
942
|
+
};
|
|
943
|
+
catchall: {
|
|
944
|
+
keyword: 'catchall';
|
|
945
|
+
};
|
|
946
|
+
interface: {
|
|
947
|
+
keyword: 'interface';
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
type Schema = {
|
|
951
|
+
keyword: string;
|
|
952
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
955
|
+
type ResolvePathOptions = {
|
|
956
|
+
pluginKey?: Plugin['key'];
|
|
957
|
+
group?: {
|
|
958
|
+
tag?: string;
|
|
959
|
+
path?: string;
|
|
960
|
+
};
|
|
961
|
+
type?: ResolveNameParams['type'];
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
965
|
+
* @example import { Pet } from './Pet'
|
|
966
|
+
*
|
|
967
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
968
|
+
*
|
|
969
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
970
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
971
|
+
*/
|
|
972
|
+
type Ref = {
|
|
973
|
+
propertyName: string;
|
|
974
|
+
originalName: string;
|
|
975
|
+
path: OptionalPath;
|
|
976
|
+
pluginKey?: Plugin['key'];
|
|
977
|
+
};
|
|
978
|
+
type Refs = Record<string, Ref>;
|
|
979
|
+
type OperationSchema = {
|
|
980
|
+
/**
|
|
981
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
982
|
+
*/
|
|
983
|
+
name: string;
|
|
984
|
+
schema: SchemaObject$1;
|
|
985
|
+
operation?: Operation$1;
|
|
986
|
+
/**
|
|
987
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
988
|
+
*/
|
|
989
|
+
operationName: string;
|
|
990
|
+
description?: string;
|
|
991
|
+
statusCode?: number;
|
|
992
|
+
keys?: string[];
|
|
993
|
+
keysToOmit?: string[];
|
|
994
|
+
withData?: boolean;
|
|
995
|
+
};
|
|
996
|
+
type OperationSchemas = {
|
|
997
|
+
pathParams?: OperationSchema & {
|
|
998
|
+
keysToOmit?: never;
|
|
999
|
+
};
|
|
1000
|
+
queryParams?: OperationSchema & {
|
|
1001
|
+
keysToOmit?: never;
|
|
1002
|
+
};
|
|
1003
|
+
headerParams?: OperationSchema & {
|
|
1004
|
+
keysToOmit?: never;
|
|
1005
|
+
};
|
|
1006
|
+
request?: OperationSchema;
|
|
1007
|
+
response: OperationSchema;
|
|
1008
|
+
responses: Array<OperationSchema>;
|
|
1009
|
+
statusCodes?: Array<OperationSchema>;
|
|
1010
|
+
errors?: Array<OperationSchema>;
|
|
1011
|
+
};
|
|
1012
|
+
type ByTag = {
|
|
1013
|
+
type: 'tag';
|
|
1014
|
+
pattern: string | RegExp;
|
|
1015
|
+
};
|
|
1016
|
+
type ByOperationId = {
|
|
1017
|
+
type: 'operationId';
|
|
1018
|
+
pattern: string | RegExp;
|
|
1019
|
+
};
|
|
1020
|
+
type ByPath = {
|
|
1021
|
+
type: 'path';
|
|
1022
|
+
pattern: string | RegExp;
|
|
1023
|
+
};
|
|
1024
|
+
type ByMethod = {
|
|
1025
|
+
type: 'method';
|
|
1026
|
+
pattern: HttpMethod | RegExp;
|
|
1027
|
+
};
|
|
1028
|
+
type BySchemaName = {
|
|
1029
|
+
type: 'schemaName';
|
|
1030
|
+
pattern: string | RegExp;
|
|
1031
|
+
};
|
|
1032
|
+
type ByContentType = {
|
|
1033
|
+
type: 'contentType';
|
|
1034
|
+
pattern: string | RegExp;
|
|
1035
|
+
};
|
|
1036
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1037
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1038
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1039
|
+
options: Partial<TOptions>;
|
|
1040
|
+
};
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1043
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1044
|
+
oas: Oas;
|
|
1045
|
+
pluginManager: PluginManager;
|
|
1046
|
+
/**
|
|
1047
|
+
* Current plugin
|
|
1048
|
+
*/
|
|
1049
|
+
plugin: Plugin<TPluginOptions>;
|
|
1050
|
+
mode: Mode;
|
|
1051
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1052
|
+
override: Array<Override<TOptions>> | undefined;
|
|
1053
|
+
contentType?: contentType;
|
|
1054
|
+
output?: string;
|
|
1055
|
+
};
|
|
1056
|
+
type SchemaGeneratorOptions = {
|
|
1057
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
1058
|
+
unknownType: 'any' | 'unknown' | 'void';
|
|
1059
|
+
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
1060
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
1061
|
+
enumSuffix?: string;
|
|
1062
|
+
usedEnumNames?: Record<string, number>;
|
|
1063
|
+
mapper?: Record<string, string>;
|
|
1064
|
+
typed?: boolean;
|
|
1065
|
+
transformers: {
|
|
1066
|
+
/**
|
|
1067
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
1068
|
+
*/
|
|
1069
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1070
|
+
/**
|
|
1071
|
+
* Receive schema and name(propertName) and return FakerMeta array
|
|
1072
|
+
* TODO TODO add docs
|
|
1073
|
+
* @beta
|
|
1074
|
+
*/
|
|
1075
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1076
|
+
};
|
|
1077
|
+
};
|
|
1078
|
+
type SchemaProps$1 = {
|
|
1079
|
+
schemaObject?: SchemaObject$1;
|
|
1080
|
+
name?: string;
|
|
1081
|
+
parentName?: string;
|
|
1082
|
+
};
|
|
1083
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1084
|
+
#private;
|
|
1085
|
+
refs: Refs;
|
|
1086
|
+
/**
|
|
1087
|
+
* Creates a type node from a given schema.
|
|
1088
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
1089
|
+
* optionally adds a union with null.
|
|
1090
|
+
*/
|
|
1091
|
+
parse(props: SchemaProps$1): Schema[];
|
|
1092
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1093
|
+
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1094
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1095
|
+
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1096
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1097
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
1098
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1099
|
+
}
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region ../plugin-oas/src/generator.d.ts
|
|
1102
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1103
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1104
|
+
options: TOptions['resolvedOptions'];
|
|
1105
|
+
operations: Array<Operation$1>;
|
|
1106
|
+
};
|
|
1107
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1108
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1109
|
+
options: TOptions['resolvedOptions'];
|
|
1110
|
+
operation: Operation$1;
|
|
1111
|
+
};
|
|
1112
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1113
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1114
|
+
options: TOptions['resolvedOptions'];
|
|
1115
|
+
schema: {
|
|
1116
|
+
name: string;
|
|
1117
|
+
tree: Array<Schema>;
|
|
1118
|
+
value: SchemaObject$1;
|
|
1119
|
+
};
|
|
1120
|
+
};
|
|
1121
|
+
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1122
|
+
name: string;
|
|
1123
|
+
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1124
|
+
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1125
|
+
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1126
|
+
};
|
|
1127
|
+
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1130
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1131
|
+
oas: Oas;
|
|
1132
|
+
exclude: Array<Exclude$1> | undefined;
|
|
1133
|
+
include: Array<Include> | undefined;
|
|
1134
|
+
override: Array<Override<TOptions>> | undefined;
|
|
1135
|
+
contentType: contentType | undefined;
|
|
1136
|
+
pluginManager: PluginManager;
|
|
1137
|
+
/**
|
|
1138
|
+
* Current plugin
|
|
1139
|
+
*/
|
|
1140
|
+
plugin: Plugin<TPluginOptions>;
|
|
1141
|
+
mode: Mode;
|
|
1142
|
+
};
|
|
1143
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
1144
|
+
#private;
|
|
1145
|
+
getSchemas(operation: Operation$1, {
|
|
1146
|
+
resolveName
|
|
1147
|
+
}?: {
|
|
1148
|
+
resolveName?: (name: string) => string;
|
|
1149
|
+
}): OperationSchemas;
|
|
1150
|
+
getOperations(): Promise<Array<{
|
|
1151
|
+
path: string;
|
|
1152
|
+
method: HttpMethod;
|
|
1153
|
+
operation: Operation$1;
|
|
1154
|
+
}>>;
|
|
1155
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1156
|
+
}
|
|
1157
|
+
//#endregion
|
|
1158
|
+
//#region src/types.d.ts
|
|
1159
|
+
type Options$1 = {
|
|
1160
|
+
/**
|
|
1161
|
+
* Specify the export location for the files and define the behavior of the output
|
|
1162
|
+
* @default { path: 'clients', barrelType: 'named' }
|
|
1163
|
+
*/
|
|
1164
|
+
output?: Output<Oas>;
|
|
1165
|
+
/**
|
|
1166
|
+
* Define which contentType should be used.
|
|
1167
|
+
* By default, the first JSON valid mediaType will be used
|
|
1168
|
+
*/
|
|
1169
|
+
contentType?: contentType;
|
|
1170
|
+
/**
|
|
1171
|
+
* Group the clients based on the provided name.
|
|
1172
|
+
*/
|
|
1173
|
+
group?: Group;
|
|
1174
|
+
/**
|
|
1175
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
1176
|
+
*/
|
|
1177
|
+
exclude?: Array<Exclude$1>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
1180
|
+
*/
|
|
1181
|
+
include?: Array<Include>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
1184
|
+
*/
|
|
1185
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Create `operations.ts` file with all operations grouped by methods.
|
|
1188
|
+
* @default false
|
|
1189
|
+
*/
|
|
1190
|
+
operations?: boolean;
|
|
1191
|
+
/**
|
|
1192
|
+
* Export urls that are used by operation x
|
|
1193
|
+
* `export` will make them part of your barrel file
|
|
1194
|
+
* false will not make them exportable
|
|
1195
|
+
* @example getGetPetByIdUrl
|
|
1196
|
+
*/
|
|
1197
|
+
urlType?: 'export' | false;
|
|
1198
|
+
/**
|
|
1199
|
+
* Path to the client import path that will be used to do the API calls.
|
|
1200
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
1201
|
+
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
1202
|
+
* @default '@kubb/plugin-client/clients/axios'
|
|
1203
|
+
*/
|
|
1204
|
+
importPath?: string;
|
|
1205
|
+
/**
|
|
1206
|
+
* Allows you to set a custom base url for all generated calls.
|
|
1207
|
+
*/
|
|
1208
|
+
baseURL?: string;
|
|
1209
|
+
/**
|
|
1210
|
+
* ReturnType that will be used when calling the client.
|
|
1211
|
+
* - 'data' will return ResponseConfig[data].
|
|
1212
|
+
* - 'full' will return ResponseConfig.
|
|
1213
|
+
* @default 'data'
|
|
1214
|
+
*/
|
|
1215
|
+
dataReturnType?: 'data' | 'full';
|
|
1216
|
+
/**
|
|
1217
|
+
* How to style your params, by default no casing is applied
|
|
1218
|
+
* - 'camelcase' will use camelcase for the params names
|
|
1219
|
+
*/
|
|
1220
|
+
paramsCasing?: 'camelcase';
|
|
1221
|
+
/**
|
|
1222
|
+
* How to pass your params
|
|
1223
|
+
* - 'object' will return the params and pathParams as an object.
|
|
1224
|
+
* - 'inline' will return the params as comma separated params.
|
|
1225
|
+
* @default 'inline'
|
|
1226
|
+
*/
|
|
1227
|
+
paramsType?: 'object' | 'inline';
|
|
1228
|
+
/**
|
|
1229
|
+
* How to pass your pathParams.
|
|
1230
|
+
* - 'object' will return the pathParams as an object.
|
|
1231
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
1232
|
+
* @default 'inline'
|
|
1233
|
+
*/
|
|
1234
|
+
pathParamsType?: 'object' | 'inline';
|
|
1235
|
+
/**
|
|
1236
|
+
* Which parser can be used before returning the data
|
|
1237
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
1238
|
+
* @default 'client'
|
|
1239
|
+
*/
|
|
1240
|
+
parser?: 'client' | 'zod';
|
|
1241
|
+
/**
|
|
1242
|
+
* Which client should be used to do the HTTP calls
|
|
1243
|
+
* - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
|
|
1244
|
+
* - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
|
|
1245
|
+
* @default 'axios'
|
|
1246
|
+
*/
|
|
1247
|
+
client?: 'axios' | 'fetch';
|
|
1248
|
+
transformers?: {
|
|
1249
|
+
/**
|
|
1250
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
1251
|
+
*/
|
|
1252
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1253
|
+
};
|
|
1254
|
+
/**
|
|
1255
|
+
* Define some generators next to the client generators
|
|
1256
|
+
*/
|
|
1257
|
+
generators?: Array<Generator<PluginClient>>;
|
|
1258
|
+
};
|
|
1259
|
+
type ResolvedOptions = {
|
|
1260
|
+
output: Output<Oas>;
|
|
1261
|
+
group?: Options$1['group'];
|
|
1262
|
+
baseURL: string | undefined;
|
|
1263
|
+
parser: NonNullable<Options$1['parser']>;
|
|
1264
|
+
urlType: NonNullable<Options$1['urlType']>;
|
|
1265
|
+
importPath: NonNullable<Options$1['importPath']>;
|
|
1266
|
+
dataReturnType: NonNullable<Options$1['dataReturnType']>;
|
|
1267
|
+
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
1268
|
+
paramsType: NonNullable<Options$1['paramsType']>;
|
|
1269
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
1270
|
+
};
|
|
1271
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1272
|
+
//#endregion
|
|
1273
|
+
export { FunctionParams, Generator, KubbNode, type Operation$1 as Operation, OperationSchemas, Options$1 as Options, PluginClient, UserPluginWithLifeCycle };
|
|
1274
|
+
//# sourceMappingURL=types-CdM4kNiz.d.ts.map
|