@kubb/plugin-redoc 4.11.3 → 4.12.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/index.d.cts +212 -99
- package/dist/index.d.ts +212 -99
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
2
|
import { Fabric } from "@kubb/react-fabric";
|
|
3
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
3
|
import * as OasTypes from "oas/types";
|
|
5
4
|
import { OASDocument, SchemaObject, User } from "oas/types";
|
|
6
5
|
import { Operation } from "oas/operation";
|
|
@@ -8,75 +7,229 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
8
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
9
8
|
import BaseOas from "oas";
|
|
10
9
|
|
|
11
|
-
//#region ../core/src/
|
|
12
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
13
|
-
#private;
|
|
14
|
-
constructor();
|
|
15
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
16
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
17
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
18
|
-
removeAll(): void;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region ../core/src/logger.d.ts
|
|
10
|
+
//#region ../core/src/Kubb.d.ts
|
|
22
11
|
type DebugEvent = {
|
|
23
12
|
date: Date;
|
|
24
13
|
logs: string[];
|
|
25
14
|
fileName?: string;
|
|
15
|
+
};
|
|
16
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
17
|
+
hookName: H;
|
|
18
|
+
plugins: Array<Plugin>;
|
|
19
|
+
};
|
|
20
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
21
|
+
hookName: H;
|
|
22
|
+
};
|
|
23
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
24
|
+
strategy: Strategy;
|
|
25
|
+
hookName: H;
|
|
26
|
+
plugin: Plugin;
|
|
27
|
+
parameters?: unknown[] | undefined;
|
|
28
|
+
output?: unknown;
|
|
29
|
+
};
|
|
30
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
31
|
+
duration: number;
|
|
32
|
+
strategy: Strategy;
|
|
33
|
+
hookName: H;
|
|
34
|
+
plugin: Plugin;
|
|
35
|
+
parameters?: unknown[] | undefined;
|
|
36
|
+
output?: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
40
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
45
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
46
|
+
*
|
|
47
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
48
|
+
*
|
|
49
|
+
* events.on('lifecycle:start', () => {
|
|
50
|
+
* console.log('Starting Kubb generation')
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
54
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
interface KubbEvents {
|
|
26
59
|
/**
|
|
27
|
-
*
|
|
28
|
-
* - 'setup': Initial configuration and environment setup
|
|
29
|
-
* - 'plugin': Plugin installation and execution
|
|
30
|
-
* - 'hook': Plugin hook execution details
|
|
31
|
-
* - 'schema': Schema parsing and generation
|
|
32
|
-
* - 'file': File operations (read/write/generate)
|
|
33
|
-
* - 'error': Error details and stack traces
|
|
34
|
-
* - undefined: Generic logs (always inline)
|
|
60
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
35
61
|
*/
|
|
36
|
-
|
|
62
|
+
'lifecycle:start': [version: string];
|
|
37
63
|
/**
|
|
38
|
-
*
|
|
64
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
39
65
|
*/
|
|
40
|
-
|
|
66
|
+
'lifecycle:end': [];
|
|
41
67
|
/**
|
|
42
|
-
*
|
|
43
|
-
* - 'start': Start of plugin execution group
|
|
44
|
-
* - 'end': End of plugin execution group
|
|
68
|
+
* Emitted when configuration loading starts.
|
|
45
69
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
'config:start': [];
|
|
71
|
+
/**
|
|
72
|
+
* Emitted when configuration loading is complete.
|
|
73
|
+
*/
|
|
74
|
+
'config:end': [configs: Array<Config>];
|
|
75
|
+
/**
|
|
76
|
+
* Emitted when code generation phase starts.
|
|
77
|
+
*/
|
|
78
|
+
'generation:start': [config: Config];
|
|
79
|
+
/**
|
|
80
|
+
* Emitted when code generation phase completes.
|
|
81
|
+
*/
|
|
82
|
+
'generation:end': [Config: Config];
|
|
83
|
+
/**
|
|
84
|
+
* Emitted with a summary of the generation results.
|
|
85
|
+
* Contains summary lines, title, and success status.
|
|
86
|
+
*/
|
|
87
|
+
'generation:summary': [Config: Config, {
|
|
88
|
+
failedPlugins: Set<{
|
|
89
|
+
plugin: Plugin;
|
|
90
|
+
error: Error;
|
|
91
|
+
}>;
|
|
92
|
+
status: 'success' | 'failed';
|
|
93
|
+
hrStart: [number, number];
|
|
94
|
+
filesCreated: number;
|
|
95
|
+
pluginTimings?: Map<string, number>;
|
|
64
96
|
}];
|
|
65
|
-
|
|
66
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
99
|
+
*/
|
|
100
|
+
'format:start': [];
|
|
101
|
+
/**
|
|
102
|
+
* Emitted when code formatting completes.
|
|
103
|
+
*/
|
|
104
|
+
'format:end': [];
|
|
105
|
+
/**
|
|
106
|
+
* Emitted when linting starts.
|
|
107
|
+
*/
|
|
108
|
+
'lint:start': [];
|
|
109
|
+
/**
|
|
110
|
+
* Emitted when linting completes.
|
|
111
|
+
*/
|
|
112
|
+
'lint:end': [];
|
|
113
|
+
/**
|
|
114
|
+
* Emitted when plugin hooks execution starts.
|
|
115
|
+
*/
|
|
116
|
+
'hooks:start': [];
|
|
117
|
+
/**
|
|
118
|
+
* Emitted when plugin hooks execution completes.
|
|
119
|
+
*/
|
|
120
|
+
'hooks:end': [];
|
|
121
|
+
/**
|
|
122
|
+
* Emitted when a single hook execution starts.
|
|
123
|
+
*/
|
|
124
|
+
'hook:start': [command: string];
|
|
125
|
+
/**
|
|
126
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
127
|
+
* The callback should be invoked when the command completes.
|
|
128
|
+
*/
|
|
129
|
+
'hook:execute': [{
|
|
130
|
+
command: string | URL;
|
|
131
|
+
args?: readonly string[];
|
|
132
|
+
}, cb: () => void];
|
|
133
|
+
/**
|
|
134
|
+
* Emitted when a single hook execution completes.
|
|
135
|
+
*/
|
|
136
|
+
'hook:end': [command: string];
|
|
137
|
+
/**
|
|
138
|
+
* Emitted when a new version of Kubb is available.
|
|
139
|
+
*/
|
|
140
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
141
|
+
/**
|
|
142
|
+
* Informational message event.
|
|
143
|
+
*/
|
|
144
|
+
info: [message: string, info?: string];
|
|
145
|
+
/**
|
|
146
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
147
|
+
*/
|
|
148
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
149
|
+
/**
|
|
150
|
+
* Success message event.
|
|
151
|
+
*/
|
|
152
|
+
success: [message: string, info?: string];
|
|
153
|
+
/**
|
|
154
|
+
* Warning message event.
|
|
155
|
+
*/
|
|
156
|
+
warn: [message: string, info?: string];
|
|
157
|
+
/**
|
|
158
|
+
* Debug event for detailed logging.
|
|
159
|
+
* Contains timestamp, log messages, and optional filename.
|
|
160
|
+
*/
|
|
161
|
+
debug: [meta: DebugEvent];
|
|
162
|
+
/**
|
|
163
|
+
* Emitted when file processing starts.
|
|
164
|
+
* Contains the list of files to be processed.
|
|
165
|
+
*/
|
|
166
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
167
|
+
/**
|
|
168
|
+
* Emitted for each file being processed, providing progress updates.
|
|
169
|
+
* Contains processed count, total count, percentage, and file details.
|
|
170
|
+
*/
|
|
171
|
+
'file:processing:update': [{
|
|
172
|
+
/** Number of files processed so far */
|
|
173
|
+
processed: number;
|
|
174
|
+
/** Total number of files to process */
|
|
175
|
+
total: number;
|
|
176
|
+
/** Processing percentage (0-100) */
|
|
177
|
+
percentage: number;
|
|
178
|
+
/** Optional source identifier */
|
|
179
|
+
source?: string;
|
|
180
|
+
/** The file being processed */
|
|
181
|
+
file: KubbFile.ResolvedFile;
|
|
182
|
+
/**
|
|
183
|
+
* Kubb configuration (not present in Fabric).
|
|
184
|
+
* Provides access to the current config during file processing.
|
|
185
|
+
*/
|
|
186
|
+
config: Config;
|
|
67
187
|
}];
|
|
68
|
-
};
|
|
69
|
-
type Logger = {
|
|
70
188
|
/**
|
|
71
|
-
*
|
|
189
|
+
* Emitted when file processing completes.
|
|
190
|
+
* Contains the list of processed files.
|
|
72
191
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
192
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
193
|
+
/**
|
|
194
|
+
* Emitted when a plugin starts executing.
|
|
195
|
+
*/
|
|
196
|
+
'plugin:start': [plugin: Plugin];
|
|
197
|
+
/**
|
|
198
|
+
* Emitted when a plugin completes execution.
|
|
199
|
+
*/
|
|
200
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
201
|
+
/**
|
|
202
|
+
* Emitted when plugin hook progress tracking starts.
|
|
203
|
+
* Contains the hook name and list of plugins to execute.
|
|
204
|
+
*/
|
|
205
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
206
|
+
/**
|
|
207
|
+
* Emitted when plugin hook progress tracking ends.
|
|
208
|
+
* Contains the hook name that completed.
|
|
209
|
+
*/
|
|
210
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
211
|
+
/**
|
|
212
|
+
* Emitted when a plugin hook starts processing.
|
|
213
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
214
|
+
*/
|
|
215
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
216
|
+
/**
|
|
217
|
+
* Emitted when a plugin hook completes processing.
|
|
218
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
219
|
+
*/
|
|
220
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
224
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
225
|
+
#private;
|
|
226
|
+
constructor(maxListener?: number);
|
|
227
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
228
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
229
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
230
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
231
|
+
removeAll(): void;
|
|
232
|
+
}
|
|
80
233
|
//#endregion
|
|
81
234
|
//#region ../core/src/utils/types.d.ts
|
|
82
235
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -340,7 +493,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
340
493
|
* merging multiple sources into the same output file
|
|
341
494
|
*/
|
|
342
495
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
343
|
-
|
|
496
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
344
497
|
mode: KubbFile.Mode;
|
|
345
498
|
/**
|
|
346
499
|
* Current plugin
|
|
@@ -373,35 +526,6 @@ type Output<TOptions> = {
|
|
|
373
526
|
//#region ../core/src/PluginManager.d.ts
|
|
374
527
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
375
528
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
376
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
377
|
-
strategy: Strategy;
|
|
378
|
-
hookName: H;
|
|
379
|
-
plugin: Plugin;
|
|
380
|
-
parameters?: unknown[] | undefined;
|
|
381
|
-
output?: unknown;
|
|
382
|
-
};
|
|
383
|
-
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
384
|
-
duration: number;
|
|
385
|
-
strategy: Strategy;
|
|
386
|
-
hookName: H;
|
|
387
|
-
plugin: Plugin;
|
|
388
|
-
parameters?: unknown[] | undefined;
|
|
389
|
-
output?: unknown;
|
|
390
|
-
};
|
|
391
|
-
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
392
|
-
hookName: H;
|
|
393
|
-
duration: number;
|
|
394
|
-
strategy: Strategy;
|
|
395
|
-
parameters?: unknown[] | undefined;
|
|
396
|
-
plugin: Plugin;
|
|
397
|
-
};
|
|
398
|
-
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
399
|
-
hookName: H;
|
|
400
|
-
plugins: Array<Plugin>;
|
|
401
|
-
};
|
|
402
|
-
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
403
|
-
hookName: H;
|
|
404
|
-
};
|
|
405
529
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
406
530
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
407
531
|
result: Result;
|
|
@@ -409,19 +533,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
409
533
|
};
|
|
410
534
|
type Options$2 = {
|
|
411
535
|
fabric: Fabric;
|
|
412
|
-
|
|
536
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
413
537
|
/**
|
|
414
538
|
* @default Number.POSITIVE_INFINITY
|
|
415
539
|
*/
|
|
416
540
|
concurrency?: number;
|
|
417
541
|
};
|
|
418
|
-
type Events = {
|
|
419
|
-
progress_start: [meta: ProgressStartMeta];
|
|
420
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
421
|
-
executing: [meta: ExecutingMeta];
|
|
422
|
-
executed: [meta: ExecutedMeta];
|
|
423
|
-
error: [error: Error, meta: ErrorMeta];
|
|
424
|
-
};
|
|
425
542
|
type GetFileProps<TOptions = object> = {
|
|
426
543
|
name: string;
|
|
427
544
|
mode?: KubbFile.Mode;
|
|
@@ -431,10 +548,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
431
548
|
};
|
|
432
549
|
declare class PluginManager {
|
|
433
550
|
#private;
|
|
434
|
-
readonly events: EventEmitter<Events>;
|
|
435
551
|
readonly config: Config;
|
|
436
552
|
readonly options: Options$2;
|
|
437
553
|
constructor(config: Config, options: Options$2);
|
|
554
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
438
555
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
439
556
|
get plugins(): Array<Plugin>;
|
|
440
557
|
getFile<TOptions = object>({
|
|
@@ -448,10 +565,6 @@ declare class PluginManager {
|
|
|
448
565
|
}>;
|
|
449
566
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
450
567
|
resolveName: (params: ResolveNameParams) => string;
|
|
451
|
-
/**
|
|
452
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
453
|
-
*/
|
|
454
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
455
568
|
/**
|
|
456
569
|
* Run a specific hookName for plugin x.
|
|
457
570
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
2
|
import { Fabric } from "@kubb/react-fabric";
|
|
3
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
3
|
import * as OasTypes from "oas/types";
|
|
5
4
|
import { OASDocument, SchemaObject, User } from "oas/types";
|
|
6
5
|
import { Operation } from "oas/operation";
|
|
@@ -8,75 +7,229 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
8
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
9
8
|
import BaseOas from "oas";
|
|
10
9
|
|
|
11
|
-
//#region ../core/src/
|
|
12
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
13
|
-
#private;
|
|
14
|
-
constructor();
|
|
15
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
16
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
17
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
18
|
-
removeAll(): void;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region ../core/src/logger.d.ts
|
|
10
|
+
//#region ../core/src/Kubb.d.ts
|
|
22
11
|
type DebugEvent = {
|
|
23
12
|
date: Date;
|
|
24
13
|
logs: string[];
|
|
25
14
|
fileName?: string;
|
|
15
|
+
};
|
|
16
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
17
|
+
hookName: H;
|
|
18
|
+
plugins: Array<Plugin>;
|
|
19
|
+
};
|
|
20
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
21
|
+
hookName: H;
|
|
22
|
+
};
|
|
23
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
24
|
+
strategy: Strategy;
|
|
25
|
+
hookName: H;
|
|
26
|
+
plugin: Plugin;
|
|
27
|
+
parameters?: unknown[] | undefined;
|
|
28
|
+
output?: unknown;
|
|
29
|
+
};
|
|
30
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
31
|
+
duration: number;
|
|
32
|
+
strategy: Strategy;
|
|
33
|
+
hookName: H;
|
|
34
|
+
plugin: Plugin;
|
|
35
|
+
parameters?: unknown[] | undefined;
|
|
36
|
+
output?: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
40
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
45
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
46
|
+
*
|
|
47
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
48
|
+
*
|
|
49
|
+
* events.on('lifecycle:start', () => {
|
|
50
|
+
* console.log('Starting Kubb generation')
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
54
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
interface KubbEvents {
|
|
26
59
|
/**
|
|
27
|
-
*
|
|
28
|
-
* - 'setup': Initial configuration and environment setup
|
|
29
|
-
* - 'plugin': Plugin installation and execution
|
|
30
|
-
* - 'hook': Plugin hook execution details
|
|
31
|
-
* - 'schema': Schema parsing and generation
|
|
32
|
-
* - 'file': File operations (read/write/generate)
|
|
33
|
-
* - 'error': Error details and stack traces
|
|
34
|
-
* - undefined: Generic logs (always inline)
|
|
60
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
35
61
|
*/
|
|
36
|
-
|
|
62
|
+
'lifecycle:start': [version: string];
|
|
37
63
|
/**
|
|
38
|
-
*
|
|
64
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
39
65
|
*/
|
|
40
|
-
|
|
66
|
+
'lifecycle:end': [];
|
|
41
67
|
/**
|
|
42
|
-
*
|
|
43
|
-
* - 'start': Start of plugin execution group
|
|
44
|
-
* - 'end': End of plugin execution group
|
|
68
|
+
* Emitted when configuration loading starts.
|
|
45
69
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
70
|
+
'config:start': [];
|
|
71
|
+
/**
|
|
72
|
+
* Emitted when configuration loading is complete.
|
|
73
|
+
*/
|
|
74
|
+
'config:end': [configs: Array<Config>];
|
|
75
|
+
/**
|
|
76
|
+
* Emitted when code generation phase starts.
|
|
77
|
+
*/
|
|
78
|
+
'generation:start': [config: Config];
|
|
79
|
+
/**
|
|
80
|
+
* Emitted when code generation phase completes.
|
|
81
|
+
*/
|
|
82
|
+
'generation:end': [Config: Config];
|
|
83
|
+
/**
|
|
84
|
+
* Emitted with a summary of the generation results.
|
|
85
|
+
* Contains summary lines, title, and success status.
|
|
86
|
+
*/
|
|
87
|
+
'generation:summary': [Config: Config, {
|
|
88
|
+
failedPlugins: Set<{
|
|
89
|
+
plugin: Plugin;
|
|
90
|
+
error: Error;
|
|
91
|
+
}>;
|
|
92
|
+
status: 'success' | 'failed';
|
|
93
|
+
hrStart: [number, number];
|
|
94
|
+
filesCreated: number;
|
|
95
|
+
pluginTimings?: Map<string, number>;
|
|
64
96
|
}];
|
|
65
|
-
|
|
66
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
99
|
+
*/
|
|
100
|
+
'format:start': [];
|
|
101
|
+
/**
|
|
102
|
+
* Emitted when code formatting completes.
|
|
103
|
+
*/
|
|
104
|
+
'format:end': [];
|
|
105
|
+
/**
|
|
106
|
+
* Emitted when linting starts.
|
|
107
|
+
*/
|
|
108
|
+
'lint:start': [];
|
|
109
|
+
/**
|
|
110
|
+
* Emitted when linting completes.
|
|
111
|
+
*/
|
|
112
|
+
'lint:end': [];
|
|
113
|
+
/**
|
|
114
|
+
* Emitted when plugin hooks execution starts.
|
|
115
|
+
*/
|
|
116
|
+
'hooks:start': [];
|
|
117
|
+
/**
|
|
118
|
+
* Emitted when plugin hooks execution completes.
|
|
119
|
+
*/
|
|
120
|
+
'hooks:end': [];
|
|
121
|
+
/**
|
|
122
|
+
* Emitted when a single hook execution starts.
|
|
123
|
+
*/
|
|
124
|
+
'hook:start': [command: string];
|
|
125
|
+
/**
|
|
126
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
127
|
+
* The callback should be invoked when the command completes.
|
|
128
|
+
*/
|
|
129
|
+
'hook:execute': [{
|
|
130
|
+
command: string | URL;
|
|
131
|
+
args?: readonly string[];
|
|
132
|
+
}, cb: () => void];
|
|
133
|
+
/**
|
|
134
|
+
* Emitted when a single hook execution completes.
|
|
135
|
+
*/
|
|
136
|
+
'hook:end': [command: string];
|
|
137
|
+
/**
|
|
138
|
+
* Emitted when a new version of Kubb is available.
|
|
139
|
+
*/
|
|
140
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
141
|
+
/**
|
|
142
|
+
* Informational message event.
|
|
143
|
+
*/
|
|
144
|
+
info: [message: string, info?: string];
|
|
145
|
+
/**
|
|
146
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
147
|
+
*/
|
|
148
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
149
|
+
/**
|
|
150
|
+
* Success message event.
|
|
151
|
+
*/
|
|
152
|
+
success: [message: string, info?: string];
|
|
153
|
+
/**
|
|
154
|
+
* Warning message event.
|
|
155
|
+
*/
|
|
156
|
+
warn: [message: string, info?: string];
|
|
157
|
+
/**
|
|
158
|
+
* Debug event for detailed logging.
|
|
159
|
+
* Contains timestamp, log messages, and optional filename.
|
|
160
|
+
*/
|
|
161
|
+
debug: [meta: DebugEvent];
|
|
162
|
+
/**
|
|
163
|
+
* Emitted when file processing starts.
|
|
164
|
+
* Contains the list of files to be processed.
|
|
165
|
+
*/
|
|
166
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
167
|
+
/**
|
|
168
|
+
* Emitted for each file being processed, providing progress updates.
|
|
169
|
+
* Contains processed count, total count, percentage, and file details.
|
|
170
|
+
*/
|
|
171
|
+
'file:processing:update': [{
|
|
172
|
+
/** Number of files processed so far */
|
|
173
|
+
processed: number;
|
|
174
|
+
/** Total number of files to process */
|
|
175
|
+
total: number;
|
|
176
|
+
/** Processing percentage (0-100) */
|
|
177
|
+
percentage: number;
|
|
178
|
+
/** Optional source identifier */
|
|
179
|
+
source?: string;
|
|
180
|
+
/** The file being processed */
|
|
181
|
+
file: KubbFile.ResolvedFile;
|
|
182
|
+
/**
|
|
183
|
+
* Kubb configuration (not present in Fabric).
|
|
184
|
+
* Provides access to the current config during file processing.
|
|
185
|
+
*/
|
|
186
|
+
config: Config;
|
|
67
187
|
}];
|
|
68
|
-
};
|
|
69
|
-
type Logger = {
|
|
70
188
|
/**
|
|
71
|
-
*
|
|
189
|
+
* Emitted when file processing completes.
|
|
190
|
+
* Contains the list of processed files.
|
|
72
191
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
192
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
193
|
+
/**
|
|
194
|
+
* Emitted when a plugin starts executing.
|
|
195
|
+
*/
|
|
196
|
+
'plugin:start': [plugin: Plugin];
|
|
197
|
+
/**
|
|
198
|
+
* Emitted when a plugin completes execution.
|
|
199
|
+
*/
|
|
200
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
201
|
+
/**
|
|
202
|
+
* Emitted when plugin hook progress tracking starts.
|
|
203
|
+
* Contains the hook name and list of plugins to execute.
|
|
204
|
+
*/
|
|
205
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
206
|
+
/**
|
|
207
|
+
* Emitted when plugin hook progress tracking ends.
|
|
208
|
+
* Contains the hook name that completed.
|
|
209
|
+
*/
|
|
210
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
211
|
+
/**
|
|
212
|
+
* Emitted when a plugin hook starts processing.
|
|
213
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
214
|
+
*/
|
|
215
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
216
|
+
/**
|
|
217
|
+
* Emitted when a plugin hook completes processing.
|
|
218
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
219
|
+
*/
|
|
220
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
224
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
225
|
+
#private;
|
|
226
|
+
constructor(maxListener?: number);
|
|
227
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
228
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
229
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
230
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
231
|
+
removeAll(): void;
|
|
232
|
+
}
|
|
80
233
|
//#endregion
|
|
81
234
|
//#region ../core/src/utils/types.d.ts
|
|
82
235
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -340,7 +493,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
340
493
|
* merging multiple sources into the same output file
|
|
341
494
|
*/
|
|
342
495
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
343
|
-
|
|
496
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
344
497
|
mode: KubbFile.Mode;
|
|
345
498
|
/**
|
|
346
499
|
* Current plugin
|
|
@@ -373,35 +526,6 @@ type Output<TOptions> = {
|
|
|
373
526
|
//#region ../core/src/PluginManager.d.ts
|
|
374
527
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
375
528
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
376
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
377
|
-
strategy: Strategy;
|
|
378
|
-
hookName: H;
|
|
379
|
-
plugin: Plugin;
|
|
380
|
-
parameters?: unknown[] | undefined;
|
|
381
|
-
output?: unknown;
|
|
382
|
-
};
|
|
383
|
-
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
384
|
-
duration: number;
|
|
385
|
-
strategy: Strategy;
|
|
386
|
-
hookName: H;
|
|
387
|
-
plugin: Plugin;
|
|
388
|
-
parameters?: unknown[] | undefined;
|
|
389
|
-
output?: unknown;
|
|
390
|
-
};
|
|
391
|
-
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
392
|
-
hookName: H;
|
|
393
|
-
duration: number;
|
|
394
|
-
strategy: Strategy;
|
|
395
|
-
parameters?: unknown[] | undefined;
|
|
396
|
-
plugin: Plugin;
|
|
397
|
-
};
|
|
398
|
-
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
399
|
-
hookName: H;
|
|
400
|
-
plugins: Array<Plugin>;
|
|
401
|
-
};
|
|
402
|
-
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
403
|
-
hookName: H;
|
|
404
|
-
};
|
|
405
529
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
406
530
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
407
531
|
result: Result;
|
|
@@ -409,19 +533,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
409
533
|
};
|
|
410
534
|
type Options$2 = {
|
|
411
535
|
fabric: Fabric;
|
|
412
|
-
|
|
536
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
413
537
|
/**
|
|
414
538
|
* @default Number.POSITIVE_INFINITY
|
|
415
539
|
*/
|
|
416
540
|
concurrency?: number;
|
|
417
541
|
};
|
|
418
|
-
type Events = {
|
|
419
|
-
progress_start: [meta: ProgressStartMeta];
|
|
420
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
421
|
-
executing: [meta: ExecutingMeta];
|
|
422
|
-
executed: [meta: ExecutedMeta];
|
|
423
|
-
error: [error: Error, meta: ErrorMeta];
|
|
424
|
-
};
|
|
425
542
|
type GetFileProps<TOptions = object> = {
|
|
426
543
|
name: string;
|
|
427
544
|
mode?: KubbFile.Mode;
|
|
@@ -431,10 +548,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
431
548
|
};
|
|
432
549
|
declare class PluginManager {
|
|
433
550
|
#private;
|
|
434
|
-
readonly events: EventEmitter<Events>;
|
|
435
551
|
readonly config: Config;
|
|
436
552
|
readonly options: Options$2;
|
|
437
553
|
constructor(config: Config, options: Options$2);
|
|
554
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
438
555
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
439
556
|
get plugins(): Array<Plugin>;
|
|
440
557
|
getFile<TOptions = object>({
|
|
@@ -448,10 +565,6 @@ declare class PluginManager {
|
|
|
448
565
|
}>;
|
|
449
566
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
450
567
|
resolveName: (params: ResolveNameParams) => string;
|
|
451
|
-
/**
|
|
452
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
453
|
-
*/
|
|
454
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
455
568
|
/**
|
|
456
569
|
* Run a specific hookName for plugin x.
|
|
457
570
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-redoc",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Beautiful docs with Redoc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
}
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@kubb/react-fabric": "0.
|
|
49
|
+
"@kubb/react-fabric": "0.7.0",
|
|
50
50
|
"handlebars": "^4.7.8",
|
|
51
|
-
"@kubb/core": "4.
|
|
52
|
-
"@kubb/oas": "4.
|
|
53
|
-
"@kubb/plugin-oas": "4.
|
|
51
|
+
"@kubb/core": "4.12.0",
|
|
52
|
+
"@kubb/oas": "4.12.0",
|
|
53
|
+
"@kubb/plugin-oas": "4.12.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@kubb/react-fabric": "0.
|
|
56
|
+
"@kubb/react-fabric": "0.7.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=20"
|