@kubb/oas 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.cjs.map +1 -1
- package/dist/index.d.cts +212 -99
- package/dist/index.d.ts +212 -99
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/utils.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 as OpenAPIV3_1$1 } from "openapi-
|
|
|
7
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
8
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
9
9
|
import { Fabric } from "@kubb/react-fabric";
|
|
10
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
11
10
|
|
|
12
11
|
//#region src/Oas.d.ts
|
|
13
12
|
type Options$1 = {
|
|
@@ -37,75 +36,229 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
37
36
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
38
37
|
}
|
|
39
38
|
//#endregion
|
|
40
|
-
//#region ../core/src/
|
|
41
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
42
|
-
#private;
|
|
43
|
-
constructor();
|
|
44
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
45
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
46
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
47
|
-
removeAll(): void;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region ../core/src/logger.d.ts
|
|
39
|
+
//#region ../core/src/Kubb.d.ts
|
|
51
40
|
type DebugEvent = {
|
|
52
41
|
date: Date;
|
|
53
42
|
logs: string[];
|
|
54
43
|
fileName?: string;
|
|
44
|
+
};
|
|
45
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
46
|
+
hookName: H;
|
|
47
|
+
plugins: Array<Plugin>;
|
|
48
|
+
};
|
|
49
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
50
|
+
hookName: H;
|
|
51
|
+
};
|
|
52
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
53
|
+
strategy: Strategy;
|
|
54
|
+
hookName: H;
|
|
55
|
+
plugin: Plugin;
|
|
56
|
+
parameters?: unknown[] | undefined;
|
|
57
|
+
output?: unknown;
|
|
58
|
+
};
|
|
59
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
60
|
+
duration: number;
|
|
61
|
+
strategy: Strategy;
|
|
62
|
+
hookName: H;
|
|
63
|
+
plugin: Plugin;
|
|
64
|
+
parameters?: unknown[] | undefined;
|
|
65
|
+
output?: unknown;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
69
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
74
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
75
|
+
*
|
|
76
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
77
|
+
*
|
|
78
|
+
* events.on('lifecycle:start', () => {
|
|
79
|
+
* console.log('Starting Kubb generation')
|
|
80
|
+
* })
|
|
81
|
+
*
|
|
82
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
83
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
interface KubbEvents {
|
|
55
88
|
/**
|
|
56
|
-
*
|
|
57
|
-
* - 'setup': Initial configuration and environment setup
|
|
58
|
-
* - 'plugin': Plugin installation and execution
|
|
59
|
-
* - 'hook': Plugin hook execution details
|
|
60
|
-
* - 'schema': Schema parsing and generation
|
|
61
|
-
* - 'file': File operations (read/write/generate)
|
|
62
|
-
* - 'error': Error details and stack traces
|
|
63
|
-
* - undefined: Generic logs (always inline)
|
|
89
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
64
90
|
*/
|
|
65
|
-
|
|
91
|
+
'lifecycle:start': [version: string];
|
|
66
92
|
/**
|
|
67
|
-
*
|
|
93
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
68
94
|
*/
|
|
69
|
-
|
|
95
|
+
'lifecycle:end': [];
|
|
70
96
|
/**
|
|
71
|
-
*
|
|
72
|
-
* - 'start': Start of plugin execution group
|
|
73
|
-
* - 'end': End of plugin execution group
|
|
97
|
+
* Emitted when configuration loading starts.
|
|
74
98
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
'config:start': [];
|
|
100
|
+
/**
|
|
101
|
+
* Emitted when configuration loading is complete.
|
|
102
|
+
*/
|
|
103
|
+
'config:end': [configs: Array<Config>];
|
|
104
|
+
/**
|
|
105
|
+
* Emitted when code generation phase starts.
|
|
106
|
+
*/
|
|
107
|
+
'generation:start': [config: Config];
|
|
108
|
+
/**
|
|
109
|
+
* Emitted when code generation phase completes.
|
|
110
|
+
*/
|
|
111
|
+
'generation:end': [Config: Config];
|
|
112
|
+
/**
|
|
113
|
+
* Emitted with a summary of the generation results.
|
|
114
|
+
* Contains summary lines, title, and success status.
|
|
115
|
+
*/
|
|
116
|
+
'generation:summary': [Config: Config, {
|
|
117
|
+
failedPlugins: Set<{
|
|
118
|
+
plugin: Plugin;
|
|
119
|
+
error: Error;
|
|
120
|
+
}>;
|
|
121
|
+
status: 'success' | 'failed';
|
|
122
|
+
hrStart: [number, number];
|
|
123
|
+
filesCreated: number;
|
|
124
|
+
pluginTimings?: Map<string, number>;
|
|
93
125
|
}];
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
128
|
+
*/
|
|
129
|
+
'format:start': [];
|
|
130
|
+
/**
|
|
131
|
+
* Emitted when code formatting completes.
|
|
132
|
+
*/
|
|
133
|
+
'format:end': [];
|
|
134
|
+
/**
|
|
135
|
+
* Emitted when linting starts.
|
|
136
|
+
*/
|
|
137
|
+
'lint:start': [];
|
|
138
|
+
/**
|
|
139
|
+
* Emitted when linting completes.
|
|
140
|
+
*/
|
|
141
|
+
'lint:end': [];
|
|
142
|
+
/**
|
|
143
|
+
* Emitted when plugin hooks execution starts.
|
|
144
|
+
*/
|
|
145
|
+
'hooks:start': [];
|
|
146
|
+
/**
|
|
147
|
+
* Emitted when plugin hooks execution completes.
|
|
148
|
+
*/
|
|
149
|
+
'hooks:end': [];
|
|
150
|
+
/**
|
|
151
|
+
* Emitted when a single hook execution starts.
|
|
152
|
+
*/
|
|
153
|
+
'hook:start': [command: string];
|
|
154
|
+
/**
|
|
155
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
156
|
+
* The callback should be invoked when the command completes.
|
|
157
|
+
*/
|
|
158
|
+
'hook:execute': [{
|
|
159
|
+
command: string | URL;
|
|
160
|
+
args?: readonly string[];
|
|
161
|
+
}, cb: () => void];
|
|
162
|
+
/**
|
|
163
|
+
* Emitted when a single hook execution completes.
|
|
164
|
+
*/
|
|
165
|
+
'hook:end': [command: string];
|
|
166
|
+
/**
|
|
167
|
+
* Emitted when a new version of Kubb is available.
|
|
168
|
+
*/
|
|
169
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
170
|
+
/**
|
|
171
|
+
* Informational message event.
|
|
172
|
+
*/
|
|
173
|
+
info: [message: string, info?: string];
|
|
174
|
+
/**
|
|
175
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
176
|
+
*/
|
|
177
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
178
|
+
/**
|
|
179
|
+
* Success message event.
|
|
180
|
+
*/
|
|
181
|
+
success: [message: string, info?: string];
|
|
182
|
+
/**
|
|
183
|
+
* Warning message event.
|
|
184
|
+
*/
|
|
185
|
+
warn: [message: string, info?: string];
|
|
186
|
+
/**
|
|
187
|
+
* Debug event for detailed logging.
|
|
188
|
+
* Contains timestamp, log messages, and optional filename.
|
|
189
|
+
*/
|
|
190
|
+
debug: [meta: DebugEvent];
|
|
191
|
+
/**
|
|
192
|
+
* Emitted when file processing starts.
|
|
193
|
+
* Contains the list of files to be processed.
|
|
194
|
+
*/
|
|
195
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
196
|
+
/**
|
|
197
|
+
* Emitted for each file being processed, providing progress updates.
|
|
198
|
+
* Contains processed count, total count, percentage, and file details.
|
|
199
|
+
*/
|
|
200
|
+
'file:processing:update': [{
|
|
201
|
+
/** Number of files processed so far */
|
|
202
|
+
processed: number;
|
|
203
|
+
/** Total number of files to process */
|
|
204
|
+
total: number;
|
|
205
|
+
/** Processing percentage (0-100) */
|
|
206
|
+
percentage: number;
|
|
207
|
+
/** Optional source identifier */
|
|
208
|
+
source?: string;
|
|
209
|
+
/** The file being processed */
|
|
210
|
+
file: KubbFile.ResolvedFile;
|
|
211
|
+
/**
|
|
212
|
+
* Kubb configuration (not present in Fabric).
|
|
213
|
+
* Provides access to the current config during file processing.
|
|
214
|
+
*/
|
|
215
|
+
config: Config;
|
|
96
216
|
}];
|
|
97
|
-
};
|
|
98
|
-
type Logger = {
|
|
99
217
|
/**
|
|
100
|
-
*
|
|
218
|
+
* Emitted when file processing completes.
|
|
219
|
+
* Contains the list of processed files.
|
|
101
220
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
221
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
222
|
+
/**
|
|
223
|
+
* Emitted when a plugin starts executing.
|
|
224
|
+
*/
|
|
225
|
+
'plugin:start': [plugin: Plugin];
|
|
226
|
+
/**
|
|
227
|
+
* Emitted when a plugin completes execution.
|
|
228
|
+
*/
|
|
229
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
230
|
+
/**
|
|
231
|
+
* Emitted when plugin hook progress tracking starts.
|
|
232
|
+
* Contains the hook name and list of plugins to execute.
|
|
233
|
+
*/
|
|
234
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
235
|
+
/**
|
|
236
|
+
* Emitted when plugin hook progress tracking ends.
|
|
237
|
+
* Contains the hook name that completed.
|
|
238
|
+
*/
|
|
239
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
240
|
+
/**
|
|
241
|
+
* Emitted when a plugin hook starts processing.
|
|
242
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
243
|
+
*/
|
|
244
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
245
|
+
/**
|
|
246
|
+
* Emitted when a plugin hook completes processing.
|
|
247
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
248
|
+
*/
|
|
249
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
253
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
254
|
+
#private;
|
|
255
|
+
constructor(maxListener?: number);
|
|
256
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
257
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
258
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
259
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
260
|
+
removeAll(): void;
|
|
261
|
+
}
|
|
109
262
|
//#endregion
|
|
110
263
|
//#region ../core/src/utils/types.d.ts
|
|
111
264
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -346,7 +499,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
346
499
|
* merging multiple sources into the same output file
|
|
347
500
|
*/
|
|
348
501
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
349
|
-
|
|
502
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
350
503
|
mode: KubbFile.Mode;
|
|
351
504
|
/**
|
|
352
505
|
* Current plugin
|
|
@@ -357,35 +510,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
357
510
|
//#region ../core/src/PluginManager.d.ts
|
|
358
511
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
359
512
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
360
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
361
|
-
strategy: Strategy;
|
|
362
|
-
hookName: H;
|
|
363
|
-
plugin: Plugin;
|
|
364
|
-
parameters?: unknown[] | undefined;
|
|
365
|
-
output?: unknown;
|
|
366
|
-
};
|
|
367
|
-
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
368
|
-
duration: number;
|
|
369
|
-
strategy: Strategy;
|
|
370
|
-
hookName: H;
|
|
371
|
-
plugin: Plugin;
|
|
372
|
-
parameters?: unknown[] | undefined;
|
|
373
|
-
output?: unknown;
|
|
374
|
-
};
|
|
375
|
-
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
376
|
-
hookName: H;
|
|
377
|
-
duration: number;
|
|
378
|
-
strategy: Strategy;
|
|
379
|
-
parameters?: unknown[] | undefined;
|
|
380
|
-
plugin: Plugin;
|
|
381
|
-
};
|
|
382
|
-
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
383
|
-
hookName: H;
|
|
384
|
-
plugins: Array<Plugin>;
|
|
385
|
-
};
|
|
386
|
-
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
387
|
-
hookName: H;
|
|
388
|
-
};
|
|
389
513
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
390
514
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
391
515
|
result: Result;
|
|
@@ -393,19 +517,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
393
517
|
};
|
|
394
518
|
type Options = {
|
|
395
519
|
fabric: Fabric;
|
|
396
|
-
|
|
520
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
397
521
|
/**
|
|
398
522
|
* @default Number.POSITIVE_INFINITY
|
|
399
523
|
*/
|
|
400
524
|
concurrency?: number;
|
|
401
525
|
};
|
|
402
|
-
type Events = {
|
|
403
|
-
progress_start: [meta: ProgressStartMeta];
|
|
404
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
405
|
-
executing: [meta: ExecutingMeta];
|
|
406
|
-
executed: [meta: ExecutedMeta];
|
|
407
|
-
error: [error: Error, meta: ErrorMeta];
|
|
408
|
-
};
|
|
409
526
|
type GetFileProps<TOptions = object> = {
|
|
410
527
|
name: string;
|
|
411
528
|
mode?: KubbFile.Mode;
|
|
@@ -415,10 +532,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
415
532
|
};
|
|
416
533
|
declare class PluginManager {
|
|
417
534
|
#private;
|
|
418
|
-
readonly events: EventEmitter<Events>;
|
|
419
535
|
readonly config: Config;
|
|
420
536
|
readonly options: Options;
|
|
421
537
|
constructor(config: Config, options: Options);
|
|
538
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
422
539
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
423
540
|
get plugins(): Array<Plugin>;
|
|
424
541
|
getFile<TOptions = object>({
|
|
@@ -432,10 +549,6 @@ declare class PluginManager {
|
|
|
432
549
|
}>;
|
|
433
550
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
434
551
|
resolveName: (params: ResolveNameParams) => string;
|
|
435
|
-
/**
|
|
436
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
437
|
-
*/
|
|
438
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
439
552
|
/**
|
|
440
553
|
* Run a specific hookName for plugin x.
|
|
441
554
|
*/
|