@kubb/plugin-redoc 3.16.2 → 3.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +61 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +678 -14
- package/dist/index.d.ts +678 -14
- package/dist/index.js +57 -42
- package/dist/index.js.map +1 -1
- package/package.json +14 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,686 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
|
+
import * as OasTypes from "oas/types";
|
|
3
|
+
import { OASDocument, SchemaObject, User } from "oas/types";
|
|
4
|
+
import { Operation } from "oas/operation";
|
|
5
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
6
|
+
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
|
+
import BaseOas from "oas";
|
|
4
8
|
|
|
9
|
+
//#region ../core/src/fs/types.d.ts
|
|
10
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
11
|
+
type Import = {
|
|
12
|
+
/**
|
|
13
|
+
* Import name to be used
|
|
14
|
+
* @example ["useState"]
|
|
15
|
+
* @example "React"
|
|
16
|
+
*/
|
|
17
|
+
name: string | Array<string | {
|
|
18
|
+
propertyName: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Path for the import
|
|
23
|
+
* @example '@kubb/core'
|
|
24
|
+
*/
|
|
25
|
+
path: string;
|
|
26
|
+
/**
|
|
27
|
+
* Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
|
|
28
|
+
*/
|
|
29
|
+
isTypeOnly?: boolean;
|
|
30
|
+
isNameSpace?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When root is set it will get the path with relative getRelativePath(root, path).
|
|
33
|
+
*/
|
|
34
|
+
root?: string;
|
|
35
|
+
};
|
|
36
|
+
type Source = {
|
|
37
|
+
name?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
isTypeOnly?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Has const or type 'export'
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
isExportable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* When set, barrel generation will add this
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
isIndexable?: boolean;
|
|
50
|
+
};
|
|
51
|
+
type Export = {
|
|
52
|
+
/**
|
|
53
|
+
* Export name to be used.
|
|
54
|
+
* @example ["useState"]
|
|
55
|
+
* @example "React"
|
|
56
|
+
*/
|
|
57
|
+
name?: string | Array<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Path for the import.
|
|
60
|
+
* @example '@kubb/core'
|
|
61
|
+
*/
|
|
62
|
+
path: string;
|
|
63
|
+
/**
|
|
64
|
+
* Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
|
|
65
|
+
*/
|
|
66
|
+
isTypeOnly?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
|
|
69
|
+
*/
|
|
70
|
+
asAlias?: boolean;
|
|
71
|
+
};
|
|
72
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
73
|
+
type Mode = 'single' | 'split';
|
|
74
|
+
/**
|
|
75
|
+
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
76
|
+
* Based on UNIX basename
|
|
77
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
78
|
+
*/
|
|
79
|
+
type BaseName = `${string}.${string}`;
|
|
80
|
+
/**
|
|
81
|
+
* Path will be full qualified path to a specified file
|
|
82
|
+
*/
|
|
83
|
+
type Path = string;
|
|
84
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
85
|
+
type OptionalPath = Path | undefined | null;
|
|
86
|
+
type File<TMeta extends object = object> = {
|
|
87
|
+
/**
|
|
88
|
+
* Name to be used to create the path
|
|
89
|
+
* Based on UNIX basename, `${name}.extname`
|
|
90
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
91
|
+
*/
|
|
92
|
+
baseName: BaseName;
|
|
93
|
+
/**
|
|
94
|
+
* Path will be full qualified path to a specified file
|
|
95
|
+
*/
|
|
96
|
+
path: AdvancedPath<BaseName> | Path;
|
|
97
|
+
sources: Array<Source>;
|
|
98
|
+
imports?: Array<Import>;
|
|
99
|
+
exports?: Array<Export>;
|
|
100
|
+
/**
|
|
101
|
+
* Use extra meta, this is getting used to generate the barrel/index files.
|
|
102
|
+
*/
|
|
103
|
+
meta?: TMeta;
|
|
104
|
+
banner?: string;
|
|
105
|
+
footer?: string;
|
|
106
|
+
};
|
|
107
|
+
type ResolvedImport = Import;
|
|
108
|
+
type ResolvedExport = Export;
|
|
109
|
+
type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
|
|
110
|
+
/**
|
|
111
|
+
* @default object-hash
|
|
112
|
+
*/
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* Contains the first part of the baseName, generated based on baseName
|
|
116
|
+
* @link https://nodejs.org/api/path.html#pathformatpathobject
|
|
117
|
+
*/
|
|
118
|
+
name: string;
|
|
119
|
+
extname: Extname;
|
|
120
|
+
imports: Array<ResolvedImport>;
|
|
121
|
+
exports: Array<ResolvedExport>;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../core/src/utils/EventEmitter.d.ts
|
|
125
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
126
|
+
#private;
|
|
127
|
+
constructor();
|
|
128
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
129
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
130
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
131
|
+
removeAll(): void;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region ../core/src/logger.d.ts
|
|
135
|
+
type DebugEvent = {
|
|
136
|
+
date: Date;
|
|
137
|
+
logs: string[];
|
|
138
|
+
fileName?: string;
|
|
139
|
+
};
|
|
140
|
+
type Events$1 = {
|
|
141
|
+
start: [message: string];
|
|
142
|
+
success: [message: string];
|
|
143
|
+
error: [message: string, cause: Error];
|
|
144
|
+
warning: [message: string];
|
|
145
|
+
debug: [DebugEvent];
|
|
146
|
+
info: [message: string];
|
|
147
|
+
progress_start: [{
|
|
148
|
+
id: string;
|
|
149
|
+
size: number;
|
|
150
|
+
message?: string;
|
|
151
|
+
}];
|
|
152
|
+
progressed: [{
|
|
153
|
+
id: string;
|
|
154
|
+
message?: string;
|
|
155
|
+
}];
|
|
156
|
+
progress_stop: [{
|
|
157
|
+
id: string;
|
|
158
|
+
}];
|
|
159
|
+
};
|
|
160
|
+
type Logger = {
|
|
161
|
+
/**
|
|
162
|
+
* Optional config name to show in CLI output
|
|
163
|
+
*/
|
|
164
|
+
name?: string;
|
|
165
|
+
logLevel: LogLevel;
|
|
166
|
+
consola?: ConsolaInstance;
|
|
167
|
+
on: EventEmitter<Events$1>['on'];
|
|
168
|
+
emit: EventEmitter<Events$1>['emit'];
|
|
169
|
+
writeLogs: () => Promise<string[]>;
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ../core/src/utils/types.d.ts
|
|
173
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
174
|
+
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
175
|
+
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region ../core/src/types.d.ts
|
|
178
|
+
type InputPath = {
|
|
179
|
+
/**
|
|
180
|
+
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
181
|
+
*/
|
|
182
|
+
path: string;
|
|
183
|
+
};
|
|
184
|
+
type InputData = {
|
|
185
|
+
/**
|
|
186
|
+
* A `string` or `object` that contains your Swagger/OpenAPI data.
|
|
187
|
+
*/
|
|
188
|
+
data: string | unknown;
|
|
189
|
+
};
|
|
190
|
+
type Input = InputPath | InputData | Array<InputPath>;
|
|
191
|
+
type BarrelType = 'all' | 'named' | 'propagate';
|
|
192
|
+
/**
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
type Config<TInput = Input> = {
|
|
196
|
+
/**
|
|
197
|
+
* The name to display in the CLI output.
|
|
198
|
+
*/
|
|
199
|
+
name?: string;
|
|
200
|
+
/**
|
|
201
|
+
* The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
|
|
202
|
+
* @default process.cwd()
|
|
203
|
+
*/
|
|
204
|
+
root: string;
|
|
205
|
+
/**
|
|
206
|
+
* You can use either `input.path` or `input.data`, depending on your specific needs.
|
|
207
|
+
*/
|
|
208
|
+
input: TInput;
|
|
209
|
+
output: {
|
|
210
|
+
/**
|
|
211
|
+
* The path where all generated files will be exported.
|
|
212
|
+
* This can be an absolute path or a path relative to the specified root option.
|
|
213
|
+
*/
|
|
214
|
+
path: string;
|
|
215
|
+
/**
|
|
216
|
+
* Clean the output directory before each build.
|
|
217
|
+
*/
|
|
218
|
+
clean?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Save files to the file system.
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
write?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Override the extension to the generated imports and exports, by default each plugin will add an extension
|
|
226
|
+
* @default { '.ts': '.ts'}
|
|
227
|
+
*/
|
|
228
|
+
extension?: Record<Extname, Extname | ''>;
|
|
229
|
+
/**
|
|
230
|
+
* 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`.
|
|
231
|
+
* @default 'named'
|
|
232
|
+
*/
|
|
233
|
+
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
234
|
+
/**
|
|
235
|
+
* Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
|
|
236
|
+
* - 'simple': will only add banner with link to Kubb
|
|
237
|
+
* - 'full': will add source, title, description and the OpenAPI version used
|
|
238
|
+
* @default 'simple'
|
|
239
|
+
*/
|
|
240
|
+
defaultBanner?: 'simple' | 'full' | false;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* An array of Kubb plugins that will be used in the generation.
|
|
244
|
+
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
245
|
+
* If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
|
|
246
|
+
*/
|
|
247
|
+
plugins?: Array<Plugin>;
|
|
248
|
+
/**
|
|
249
|
+
* Hooks that will be called when a specific action is triggered in Kubb.
|
|
250
|
+
*/
|
|
251
|
+
hooks?: {
|
|
252
|
+
/**
|
|
253
|
+
* Hook that will be triggered at the end of all executions.
|
|
254
|
+
* Useful for running Prettier or ESLint to format/lint your code.
|
|
255
|
+
*/
|
|
256
|
+
done?: string | Array<string>;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
type PluginFactoryOptions<
|
|
260
|
+
/**
|
|
261
|
+
* Name to be used for the plugin, this will also be used for they key.
|
|
262
|
+
*/
|
|
263
|
+
TName extends string = string,
|
|
264
|
+
/**
|
|
265
|
+
* Options of the plugin.
|
|
266
|
+
*/
|
|
267
|
+
TOptions extends object = object,
|
|
268
|
+
/**
|
|
269
|
+
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
270
|
+
*/
|
|
271
|
+
TResolvedOptions extends object = TOptions,
|
|
272
|
+
/**
|
|
273
|
+
* Context that you want to expose to other plugins.
|
|
274
|
+
*/
|
|
275
|
+
TContext = any,
|
|
276
|
+
/**
|
|
277
|
+
* When calling `resolvePath` you can specify better types.
|
|
278
|
+
*/
|
|
279
|
+
TResolvePathOptions extends object = object> = {
|
|
280
|
+
name: TName;
|
|
281
|
+
/**
|
|
282
|
+
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
283
|
+
*/
|
|
284
|
+
key: PluginKey<TName | string>;
|
|
285
|
+
options: TOptions;
|
|
286
|
+
resolvedOptions: TResolvedOptions;
|
|
287
|
+
context: TContext;
|
|
288
|
+
resolvePathOptions: TResolvePathOptions;
|
|
289
|
+
};
|
|
290
|
+
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
291
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
292
|
+
/**
|
|
293
|
+
* Unique name used for the plugin
|
|
294
|
+
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
295
|
+
* @example @kubb/typescript
|
|
296
|
+
*/
|
|
297
|
+
name: TOptions['name'];
|
|
298
|
+
/**
|
|
299
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
300
|
+
*/
|
|
301
|
+
options: TOptions['resolvedOptions'];
|
|
302
|
+
/**
|
|
303
|
+
* 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.
|
|
304
|
+
* Can be used to validate dependent plugins.
|
|
305
|
+
*/
|
|
306
|
+
pre?: Array<string>;
|
|
307
|
+
/**
|
|
308
|
+
* 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.
|
|
309
|
+
*/
|
|
310
|
+
post?: Array<string>;
|
|
311
|
+
} & (TOptions['context'] extends never ? {
|
|
312
|
+
context?: never;
|
|
313
|
+
} : {
|
|
314
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
315
|
+
});
|
|
316
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
317
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
318
|
+
/**
|
|
319
|
+
* Unique name used for the plugin
|
|
320
|
+
* @example @kubb/typescript
|
|
321
|
+
*/
|
|
322
|
+
name: TOptions['name'];
|
|
323
|
+
/**
|
|
324
|
+
* Internal key used when a developer uses more than one of the same plugin
|
|
325
|
+
* @private
|
|
326
|
+
*/
|
|
327
|
+
key: TOptions['key'];
|
|
328
|
+
/**
|
|
329
|
+
* 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.
|
|
330
|
+
* Can be used to validate dependent plugins.
|
|
331
|
+
*/
|
|
332
|
+
pre?: Array<string>;
|
|
333
|
+
/**
|
|
334
|
+
* 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.
|
|
335
|
+
*/
|
|
336
|
+
post?: Array<string>;
|
|
337
|
+
/**
|
|
338
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
339
|
+
*/
|
|
340
|
+
options: TOptions['resolvedOptions'];
|
|
341
|
+
} & (TOptions['context'] extends never ? {
|
|
342
|
+
context?: never;
|
|
343
|
+
} : {
|
|
344
|
+
context: TOptions['context'];
|
|
345
|
+
});
|
|
346
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
347
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
348
|
+
/**
|
|
349
|
+
* Start of the lifecycle of a plugin.
|
|
350
|
+
* @type hookParallel
|
|
351
|
+
*/
|
|
352
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
355
|
+
* Options can als be included.
|
|
356
|
+
* @type hookFirst
|
|
357
|
+
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
358
|
+
*/
|
|
359
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
360
|
+
/**
|
|
361
|
+
* Resolve to a name based on a string.
|
|
362
|
+
* Useful when converting to PascalCase or camelCase.
|
|
363
|
+
* @type hookFirst
|
|
364
|
+
* @example ('pet') => 'Pet'
|
|
365
|
+
*/
|
|
366
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
367
|
+
/**
|
|
368
|
+
* End of the plugin lifecycle.
|
|
369
|
+
* @type hookParallel
|
|
370
|
+
*/
|
|
371
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
372
|
+
};
|
|
373
|
+
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
374
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
375
|
+
type ResolvePathParams<TOptions = object> = {
|
|
376
|
+
pluginKey?: Plugin['key'];
|
|
377
|
+
baseName: BaseName;
|
|
378
|
+
mode?: Mode;
|
|
379
|
+
/**
|
|
380
|
+
* Options to be passed to 'resolvePath' 3th parameter
|
|
381
|
+
*/
|
|
382
|
+
options?: TOptions;
|
|
383
|
+
};
|
|
384
|
+
type ResolveNameParams = {
|
|
385
|
+
name: string;
|
|
386
|
+
pluginKey?: Plugin['key'];
|
|
387
|
+
/**
|
|
388
|
+
* `file` will be used to customize the name of the created file(use of camelCase)
|
|
389
|
+
* `function` can be used to customize the exported functions(use of camelCase)
|
|
390
|
+
* `type` is a special type for TypeScript(use of PascalCase)
|
|
391
|
+
* `const` can be used for variables(use of camelCase)
|
|
392
|
+
*/
|
|
393
|
+
type?: 'file' | 'function' | 'type' | 'const';
|
|
394
|
+
};
|
|
395
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
396
|
+
config: Config;
|
|
397
|
+
fileManager: FileManager;
|
|
398
|
+
pluginManager: PluginManager;
|
|
399
|
+
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
400
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
401
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
402
|
+
logger: Logger;
|
|
403
|
+
/**
|
|
404
|
+
* All plugins
|
|
405
|
+
*/
|
|
406
|
+
plugins: Plugin[];
|
|
407
|
+
/**
|
|
408
|
+
* Current plugin
|
|
409
|
+
*/
|
|
410
|
+
plugin: Plugin<TOptions>;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Specify the export location for the files and define the behavior of the output
|
|
414
|
+
*/
|
|
415
|
+
type Output<TOptions> = {
|
|
416
|
+
/**
|
|
417
|
+
* Path to the output folder or file that will contain the generated code
|
|
418
|
+
*/
|
|
419
|
+
path: string;
|
|
420
|
+
/**
|
|
421
|
+
* Define what needs to be exported, here you can also disable the export of barrel files
|
|
422
|
+
* @default 'named'
|
|
423
|
+
*/
|
|
424
|
+
barrelType?: BarrelType | false;
|
|
425
|
+
/**
|
|
426
|
+
* Add a banner text in the beginning of every file
|
|
427
|
+
*/
|
|
428
|
+
banner?: string | ((options: TOptions) => string);
|
|
429
|
+
/**
|
|
430
|
+
* Add a footer text in the beginning of every file
|
|
431
|
+
*/
|
|
432
|
+
footer?: string | ((options: TOptions) => string);
|
|
433
|
+
};
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region ../core/src/FileManager.d.ts
|
|
436
|
+
type FileMetaBase = {
|
|
437
|
+
pluginKey?: Plugin['key'];
|
|
438
|
+
};
|
|
439
|
+
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
440
|
+
type AddIndexesProps = {
|
|
441
|
+
type: BarrelType | false | undefined;
|
|
442
|
+
/**
|
|
443
|
+
* Root based on root and output.path specified in the config
|
|
444
|
+
*/
|
|
445
|
+
root: string;
|
|
446
|
+
/**
|
|
447
|
+
* Output for plugin
|
|
448
|
+
*/
|
|
449
|
+
output: {
|
|
450
|
+
path: string;
|
|
451
|
+
};
|
|
452
|
+
group?: {
|
|
453
|
+
output: string;
|
|
454
|
+
exportAs: string;
|
|
455
|
+
};
|
|
456
|
+
logger?: Logger;
|
|
457
|
+
meta?: FileMetaBase;
|
|
458
|
+
};
|
|
459
|
+
type WriteFilesProps = {
|
|
460
|
+
root: Config['root'];
|
|
461
|
+
extension?: Record<Extname, Extname | ''>;
|
|
462
|
+
logger?: Logger;
|
|
463
|
+
dryRun?: boolean;
|
|
464
|
+
};
|
|
465
|
+
declare class FileManager {
|
|
466
|
+
#private;
|
|
467
|
+
constructor();
|
|
468
|
+
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
469
|
+
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
470
|
+
deleteByPath(path: Path): Promise<void>;
|
|
471
|
+
clear(): Promise<void>;
|
|
472
|
+
getFiles(): Promise<Array<ResolvedFile>>;
|
|
473
|
+
processFiles({
|
|
474
|
+
dryRun,
|
|
475
|
+
root,
|
|
476
|
+
extension,
|
|
477
|
+
logger
|
|
478
|
+
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
479
|
+
getBarrelFiles({
|
|
480
|
+
type,
|
|
481
|
+
meta,
|
|
482
|
+
root,
|
|
483
|
+
output,
|
|
484
|
+
logger
|
|
485
|
+
}: AddIndexesProps): Promise<File[]>;
|
|
486
|
+
static getMode(path: string | undefined | null): Mode;
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region ../core/src/PluginManager.d.ts
|
|
490
|
+
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
491
|
+
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
492
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
493
|
+
message: string;
|
|
494
|
+
strategy: Strategy;
|
|
495
|
+
hookName: H;
|
|
496
|
+
plugin: Plugin;
|
|
497
|
+
parameters?: unknown[] | undefined;
|
|
498
|
+
output?: unknown;
|
|
499
|
+
};
|
|
500
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
501
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
502
|
+
result: Result;
|
|
503
|
+
plugin: Plugin;
|
|
504
|
+
};
|
|
505
|
+
type Options$2 = {
|
|
506
|
+
logger: Logger;
|
|
507
|
+
/**
|
|
508
|
+
* @default Number.POSITIVE_INFINITY
|
|
509
|
+
*/
|
|
510
|
+
concurrency?: number;
|
|
511
|
+
};
|
|
512
|
+
type Events = {
|
|
513
|
+
executing: [executer: Executer];
|
|
514
|
+
executed: [executer: Executer];
|
|
515
|
+
error: [error: Error];
|
|
516
|
+
};
|
|
517
|
+
type GetFileProps<TOptions = object> = {
|
|
518
|
+
name: string;
|
|
519
|
+
mode?: Mode;
|
|
520
|
+
extname: Extname;
|
|
521
|
+
pluginKey: Plugin['key'];
|
|
522
|
+
options?: TOptions;
|
|
523
|
+
};
|
|
524
|
+
declare class PluginManager {
|
|
525
|
+
#private;
|
|
526
|
+
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
527
|
+
readonly fileManager: FileManager;
|
|
528
|
+
readonly events: EventEmitter<Events>;
|
|
529
|
+
readonly config: Config;
|
|
530
|
+
readonly executed: Array<Executer>;
|
|
531
|
+
readonly logger: Logger;
|
|
532
|
+
readonly options: Options$2;
|
|
533
|
+
constructor(config: Config, options: Options$2);
|
|
534
|
+
getFile<TOptions = object>({
|
|
535
|
+
name,
|
|
536
|
+
mode,
|
|
537
|
+
extname,
|
|
538
|
+
pluginKey,
|
|
539
|
+
options
|
|
540
|
+
}: GetFileProps<TOptions>): File<{
|
|
541
|
+
pluginKey: Plugin['key'];
|
|
542
|
+
}>;
|
|
543
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
544
|
+
resolveName: (params: ResolveNameParams) => string;
|
|
545
|
+
/**
|
|
546
|
+
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
547
|
+
*/
|
|
548
|
+
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
549
|
+
/**
|
|
550
|
+
* Run a specific hookName for plugin x.
|
|
551
|
+
*/
|
|
552
|
+
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
553
|
+
pluginKey,
|
|
554
|
+
hookName,
|
|
555
|
+
parameters,
|
|
556
|
+
message
|
|
557
|
+
}: {
|
|
558
|
+
pluginKey: Plugin['key'];
|
|
559
|
+
hookName: H;
|
|
560
|
+
parameters: PluginParameter<H>;
|
|
561
|
+
message: string;
|
|
562
|
+
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
563
|
+
/**
|
|
564
|
+
* Run a specific hookName for plugin x.
|
|
565
|
+
*/
|
|
566
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
567
|
+
pluginKey,
|
|
568
|
+
hookName,
|
|
569
|
+
parameters,
|
|
570
|
+
message
|
|
571
|
+
}: {
|
|
572
|
+
pluginKey: Plugin['key'];
|
|
573
|
+
hookName: H;
|
|
574
|
+
parameters: PluginParameter<H>;
|
|
575
|
+
message: string;
|
|
576
|
+
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
577
|
+
/**
|
|
578
|
+
* First non-null result stops and will return it's value.
|
|
579
|
+
*/
|
|
580
|
+
hookFirst<H extends PluginLifecycleHooks>({
|
|
581
|
+
hookName,
|
|
582
|
+
parameters,
|
|
583
|
+
skipped,
|
|
584
|
+
message
|
|
585
|
+
}: {
|
|
586
|
+
hookName: H;
|
|
587
|
+
parameters: PluginParameter<H>;
|
|
588
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
589
|
+
message: string;
|
|
590
|
+
}): Promise<SafeParseResult<H>>;
|
|
591
|
+
/**
|
|
592
|
+
* First non-null result stops and will return it's value.
|
|
593
|
+
*/
|
|
594
|
+
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
595
|
+
hookName,
|
|
596
|
+
parameters,
|
|
597
|
+
skipped,
|
|
598
|
+
message
|
|
599
|
+
}: {
|
|
600
|
+
hookName: H;
|
|
601
|
+
parameters: PluginParameter<H>;
|
|
602
|
+
skipped?: ReadonlySet<Plugin> | null;
|
|
603
|
+
message: string;
|
|
604
|
+
}): SafeParseResult<H>;
|
|
605
|
+
/**
|
|
606
|
+
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
607
|
+
*/
|
|
608
|
+
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
609
|
+
hookName,
|
|
610
|
+
parameters,
|
|
611
|
+
message
|
|
612
|
+
}: {
|
|
613
|
+
hookName: H;
|
|
614
|
+
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
615
|
+
message: string;
|
|
616
|
+
}): Promise<Awaited<TOuput>[]>;
|
|
617
|
+
/**
|
|
618
|
+
* Chains plugins
|
|
619
|
+
*/
|
|
620
|
+
hookSeq<H extends PluginLifecycleHooks>({
|
|
621
|
+
hookName,
|
|
622
|
+
parameters,
|
|
623
|
+
message
|
|
624
|
+
}: {
|
|
625
|
+
hookName: H;
|
|
626
|
+
parameters?: PluginParameter<H>;
|
|
627
|
+
message: string;
|
|
628
|
+
}): Promise<void>;
|
|
629
|
+
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
630
|
+
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
631
|
+
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;
|
|
632
|
+
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region ../oas/src/types.d.ts
|
|
636
|
+
type contentType = 'application/json' | (string & {});
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region ../oas/src/Oas.d.ts
|
|
639
|
+
type Options$1 = {
|
|
640
|
+
contentType?: contentType;
|
|
641
|
+
discriminator?: 'strict' | 'inherit';
|
|
642
|
+
};
|
|
643
|
+
declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
644
|
+
#private;
|
|
645
|
+
document: TOAS;
|
|
646
|
+
constructor({
|
|
647
|
+
oas,
|
|
648
|
+
user
|
|
649
|
+
}: {
|
|
650
|
+
oas: TOAS | OASDocument | string;
|
|
651
|
+
user?: User;
|
|
652
|
+
});
|
|
653
|
+
setOptions(options: Options$1): void;
|
|
654
|
+
get options(): Options$1;
|
|
655
|
+
get($ref: string): any;
|
|
656
|
+
getKey($ref: string): string | undefined;
|
|
657
|
+
set($ref: string, value: unknown): false | undefined;
|
|
658
|
+
getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
|
|
659
|
+
dereferenceWithRef(schema?: unknown): any;
|
|
660
|
+
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
661
|
+
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
662
|
+
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
663
|
+
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/types.d.ts
|
|
5
667
|
type Options = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
668
|
+
output?: {
|
|
669
|
+
/**
|
|
670
|
+
* Output for the generated doc, [https://redocly.com/](https://redocly.com/) is being used for the generation
|
|
671
|
+
* @default 'docs.html'
|
|
672
|
+
*/
|
|
673
|
+
path: string;
|
|
674
|
+
};
|
|
13
675
|
};
|
|
14
676
|
type ResolveOptions = {
|
|
15
|
-
|
|
677
|
+
output: Output<Oas>;
|
|
16
678
|
};
|
|
17
679
|
type PluginRedoc = PluginFactoryOptions<'plugin-redoc', Options, ResolveOptions, never>;
|
|
18
|
-
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/plugin.d.ts
|
|
19
682
|
declare const pluginRedocName = "plugin-redoc";
|
|
20
|
-
declare const pluginRedoc: (options?: Options | undefined) =>
|
|
21
|
-
|
|
683
|
+
declare const pluginRedoc: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginRedoc>;
|
|
684
|
+
//#endregion
|
|
22
685
|
export { type PluginRedoc, pluginRedoc, pluginRedocName };
|
|
686
|
+
//# sourceMappingURL=index.d.ts.map
|