@kubb/core 1.1.13 → 1.2.1
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 +435 -221
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +163 -71
- package/dist/index.js +415 -221
- package/dist/index.js.map +1 -1
- package/globals.d.ts +39 -0
- package/package.json +14 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import { Ora } from 'ora';
|
|
2
2
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
3
|
+
export { default as pc } from 'picocolors';
|
|
4
|
+
|
|
5
|
+
type LogType = 'error' | 'info' | 'warning';
|
|
6
|
+
type Logger = {
|
|
7
|
+
log: (message: string | null) => void;
|
|
8
|
+
error: (message: string | null) => void;
|
|
9
|
+
info: (message: string | null) => void;
|
|
10
|
+
warn: (message: string | null) => void;
|
|
11
|
+
spinner?: Ora;
|
|
12
|
+
};
|
|
13
|
+
declare function createLogger(spinner?: Ora): Logger;
|
|
14
|
+
declare function canLogHierarchy(input: LogLevels | undefined, compareTo: LogLevels): boolean;
|
|
3
15
|
|
|
4
|
-
declare function isPromise<T>(result:
|
|
16
|
+
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
17
|
+
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
18
|
+
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
19
|
+
reason: T;
|
|
20
|
+
};
|
|
5
21
|
|
|
6
22
|
declare function write(data: string, path: string): Promise<void>;
|
|
7
23
|
|
|
@@ -45,12 +61,17 @@ declare function timeout(ms: number): Promise<unknown>;
|
|
|
45
61
|
type QueueTask<T = unknown> = {
|
|
46
62
|
(...args: unknown[]): Promise<T> | Promise<void>;
|
|
47
63
|
};
|
|
64
|
+
type RunOptions = {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
48
68
|
declare class Queue {
|
|
49
69
|
private readonly queue;
|
|
50
70
|
workerCount: number;
|
|
51
71
|
private maxParallel;
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
private debug;
|
|
73
|
+
constructor(maxParallel: number, debug?: boolean);
|
|
74
|
+
run<T>(task: QueueTask<T>, options?: RunOptions): Promise<T>;
|
|
54
75
|
private work;
|
|
55
76
|
}
|
|
56
77
|
|
|
@@ -80,8 +101,43 @@ declare function getStackTrace(belowFn?: Function): NodeJS.CallSite[];
|
|
|
80
101
|
|
|
81
102
|
declare const uniqueId: (str?: string) => string;
|
|
82
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Normalizes directories to have a trailing slash.
|
|
106
|
+
* Resolve is pretty finicky -- if the directory name doesn't have
|
|
107
|
+
* a trailing slash then it tries to look in the parent directory.
|
|
108
|
+
* i.e., if the directory is "/usr/nzakas/foo" it will start the
|
|
109
|
+
* search in /usr/nzakas. However, if the directory is "/user/nzakas/foo/",
|
|
110
|
+
* then it will start the search in /user/nzakas/foo.
|
|
111
|
+
* @param {string} directory The directory to check.
|
|
112
|
+
* @returns {string} The normalized directory.
|
|
113
|
+
*/
|
|
114
|
+
declare function normalizeDirectory(directory: string): string;
|
|
115
|
+
declare function getLocation(path: string, cwd?: string): string;
|
|
116
|
+
declare function importModule(path: string, cwd?: string): Promise<any | undefined>;
|
|
117
|
+
|
|
83
118
|
declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: number) => [(...args: A) => R | undefined, () => void];
|
|
84
119
|
|
|
120
|
+
declare class SummaryError extends Error {
|
|
121
|
+
summary: string[];
|
|
122
|
+
constructor(message: string, options: {
|
|
123
|
+
cause: Error;
|
|
124
|
+
summary?: string[];
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Behaves as an Error to log a warning in the console(still stops the execution)
|
|
130
|
+
*/
|
|
131
|
+
declare class Warning extends Error {
|
|
132
|
+
constructor(message?: string, options?: {
|
|
133
|
+
cause: Error;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
138
|
+
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
139
|
+
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
140
|
+
|
|
85
141
|
type Import = {
|
|
86
142
|
name: string | string[];
|
|
87
143
|
path: string;
|
|
@@ -93,6 +149,8 @@ type Export = {
|
|
|
93
149
|
isTypeOnly?: boolean;
|
|
94
150
|
asAlias?: boolean;
|
|
95
151
|
};
|
|
152
|
+
type UUID = string;
|
|
153
|
+
type Source = string;
|
|
96
154
|
type File = {
|
|
97
155
|
/**
|
|
98
156
|
* Name to be used to dynamicly create the fileName(based on input.path)
|
|
@@ -101,8 +159,8 @@ type File = {
|
|
|
101
159
|
/**
|
|
102
160
|
* Path will be full qualified path to a specified file
|
|
103
161
|
*/
|
|
104
|
-
path:
|
|
105
|
-
source:
|
|
162
|
+
path: Path;
|
|
163
|
+
source: Source;
|
|
106
164
|
imports?: Import[];
|
|
107
165
|
exports?: Export[];
|
|
108
166
|
/**
|
|
@@ -113,40 +171,45 @@ type File = {
|
|
|
113
171
|
meta?: {
|
|
114
172
|
pluginName?: string;
|
|
115
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
176
|
+
*/
|
|
177
|
+
env?: NodeJS.ProcessEnv;
|
|
116
178
|
};
|
|
117
|
-
type
|
|
118
|
-
|
|
179
|
+
type ResolvedFile = File & {
|
|
180
|
+
/**
|
|
181
|
+
* crypto.randomUUID()
|
|
182
|
+
*/
|
|
119
183
|
id: UUID;
|
|
120
|
-
file: File;
|
|
121
|
-
status: Status;
|
|
122
184
|
};
|
|
123
185
|
type Status = 'new' | 'success' | 'removed';
|
|
124
186
|
|
|
187
|
+
declare function writeIndexes(root: string, options?: TreeNodeOptions): File[] | null;
|
|
188
|
+
declare function combineFiles(files: Array<File | null>): File[];
|
|
189
|
+
type Extension = '.ts' | '.js';
|
|
190
|
+
declare const extensions: Array<Extension>;
|
|
191
|
+
declare function getFileSource(file: File): string;
|
|
192
|
+
|
|
125
193
|
declare class FileManager {
|
|
126
194
|
private cache;
|
|
127
195
|
private task?;
|
|
128
196
|
private queue?;
|
|
129
197
|
constructor(options?: {
|
|
130
198
|
queue: Queue;
|
|
131
|
-
task?: QueueTask<
|
|
199
|
+
task?: QueueTask<ResolvedFile>;
|
|
132
200
|
});
|
|
133
|
-
|
|
134
|
-
getCacheByPath(path: string | undefined): CacheStore | undefined;
|
|
201
|
+
get extensions(): Extension[];
|
|
135
202
|
get files(): File[];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
get(
|
|
141
|
-
remove(
|
|
203
|
+
add(file: File): Promise<ResolvedFile>;
|
|
204
|
+
addOrAppend(file: File): Promise<ResolvedFile>;
|
|
205
|
+
private append;
|
|
206
|
+
getCacheByUUID(UUID: UUID): File | undefined;
|
|
207
|
+
get(path: Path): File[] | undefined;
|
|
208
|
+
remove(path: Path): void;
|
|
142
209
|
write(...params: Parameters<typeof write>): Promise<void>;
|
|
143
210
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
144
211
|
}
|
|
145
212
|
|
|
146
|
-
declare function writeIndexes(root: string, options?: TreeNodeOptions): File[] | null;
|
|
147
|
-
declare function combineFiles(files: Array<File | null>): File[];
|
|
148
|
-
declare function getFileSource(file: File): string;
|
|
149
|
-
|
|
150
213
|
/**
|
|
151
214
|
* Get the type of the first argument in a function.
|
|
152
215
|
* @example Arg0<(a: string, b: number) => void> -> string
|
|
@@ -157,6 +220,8 @@ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
|
157
220
|
strategy: Strategy;
|
|
158
221
|
hookName: H;
|
|
159
222
|
plugin: KubbPlugin;
|
|
223
|
+
input?: unknown[] | undefined;
|
|
224
|
+
output?: unknown;
|
|
160
225
|
};
|
|
161
226
|
type OnExecute<H extends PluginLifecycleHooks = PluginLifecycleHooks> = (this: PluginManager, executer: Executer<H> | undefined, pluginManager: PluginManager) => void;
|
|
162
227
|
type ParseResult<H extends PluginLifecycleHooks> = PluginLifecycle[H];
|
|
@@ -165,9 +230,11 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
165
230
|
plugin: KubbPlugin;
|
|
166
231
|
};
|
|
167
232
|
|
|
168
|
-
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<unknown, false, any, Record<string, any>>>];
|
|
233
|
+
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false, any, Record<string, any>>>];
|
|
169
234
|
type Options$1 = {
|
|
170
|
-
|
|
235
|
+
debug?: boolean;
|
|
236
|
+
task: QueueTask<ResolvedFile>;
|
|
237
|
+
logger: Logger;
|
|
171
238
|
onExecute?: OnExecute<PluginLifecycleHooks>;
|
|
172
239
|
};
|
|
173
240
|
declare class PluginManager {
|
|
@@ -176,10 +243,9 @@ declare class PluginManager {
|
|
|
176
243
|
private readonly onExecute?;
|
|
177
244
|
private readonly core;
|
|
178
245
|
queue: Queue;
|
|
179
|
-
executer: Executer | undefined;
|
|
180
246
|
executed: Executer[];
|
|
247
|
+
logger: Logger;
|
|
181
248
|
constructor(config: KubbConfig, options: Options$1);
|
|
182
|
-
getExecuter(): Executer | undefined;
|
|
183
249
|
resolvePath: (params: ResolvePathParams) => OptionalPath;
|
|
184
250
|
resolveName: (params: ResolveNameParams) => string | null;
|
|
185
251
|
load: (id: string) => Promise<SafeParseResult<"load">>;
|
|
@@ -230,7 +296,7 @@ declare class PluginManager {
|
|
|
230
296
|
hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
|
|
231
297
|
hookName: H;
|
|
232
298
|
parameters: Parameters<PluginLifecycle[H]>;
|
|
233
|
-
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) =>
|
|
299
|
+
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
|
|
234
300
|
}): Promise<Argument0<H>>;
|
|
235
301
|
/**
|
|
236
302
|
* Chains plugins
|
|
@@ -241,7 +307,7 @@ declare class PluginManager {
|
|
|
241
307
|
}): Promise<void>;
|
|
242
308
|
private getSortedPlugins;
|
|
243
309
|
getPlugin(hookName: keyof PluginLifecycle, pluginName: string): KubbPlugin;
|
|
244
|
-
private
|
|
310
|
+
private addExecutedToCallStack;
|
|
245
311
|
/**
|
|
246
312
|
* Run an async plugin hook and return the result.
|
|
247
313
|
* @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
|
|
@@ -266,8 +332,9 @@ declare function validatePlugins(plugins: KubbPlugin[], dependedPluginNames: str
|
|
|
266
332
|
|
|
267
333
|
declare class PluginError extends Error {
|
|
268
334
|
pluginManager: PluginManager;
|
|
335
|
+
cause: Error;
|
|
269
336
|
constructor(message: string, options: {
|
|
270
|
-
cause
|
|
337
|
+
cause: Error;
|
|
271
338
|
pluginManager: PluginManager;
|
|
272
339
|
});
|
|
273
340
|
}
|
|
@@ -280,19 +347,12 @@ declare class ParallelPluginError extends Error {
|
|
|
280
347
|
errors: PluginError[];
|
|
281
348
|
pluginManager: PluginManager;
|
|
282
349
|
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
declare class SummaryError extends Error {
|
|
286
|
-
summary: string[];
|
|
287
|
-
constructor(message: string, options: {
|
|
288
|
-
cause: Error;
|
|
289
|
-
summary?: string[];
|
|
290
|
-
});
|
|
350
|
+
findError<T extends Error = Error>(searchError: T): T | undefined;
|
|
291
351
|
}
|
|
292
352
|
|
|
293
353
|
interface Register {
|
|
294
354
|
}
|
|
295
|
-
type
|
|
355
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
296
356
|
/**
|
|
297
357
|
* Config used in `kubb.config.js`
|
|
298
358
|
*
|
|
@@ -313,7 +373,7 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
|
|
|
313
373
|
* Example: ['@kubb/swagger', { output: false }]
|
|
314
374
|
* Or: createSwagger({ output: false })
|
|
315
375
|
*/
|
|
316
|
-
plugins?: KubbPlugin[] |
|
|
376
|
+
plugins?: KubbPlugin[] | KubbJSONPlugins[] | KubbObjectPlugins;
|
|
317
377
|
};
|
|
318
378
|
/**
|
|
319
379
|
* Global/internal config used through out the full generation.
|
|
@@ -365,10 +425,15 @@ type KubbConfig = {
|
|
|
365
425
|
};
|
|
366
426
|
/**
|
|
367
427
|
* Log level to report when using the CLI
|
|
368
|
-
*
|
|
428
|
+
*
|
|
429
|
+
* `silent` will hide all information that is not relevant
|
|
430
|
+
*
|
|
431
|
+
* `info` will show all information possible(not related to the PluginManager)
|
|
432
|
+
*
|
|
433
|
+
* `stacktrace` will show all information possible(related to the PluginManager), handy for seeing logs
|
|
369
434
|
* @default `silent`
|
|
370
435
|
*/
|
|
371
|
-
logLevel?:
|
|
436
|
+
logLevel?: LogLevels;
|
|
372
437
|
};
|
|
373
438
|
type CLIOptions = {
|
|
374
439
|
/**
|
|
@@ -391,7 +456,7 @@ type CLIOptions = {
|
|
|
391
456
|
* Override `logLevel` defined in `kubb.config.js`
|
|
392
457
|
* @default `'silent'`
|
|
393
458
|
*/
|
|
394
|
-
logLevel?:
|
|
459
|
+
logLevel?: LogLevels;
|
|
395
460
|
init?: unknown;
|
|
396
461
|
};
|
|
397
462
|
type BuildOutput = {
|
|
@@ -399,16 +464,21 @@ type BuildOutput = {
|
|
|
399
464
|
pluginManager: PluginManager;
|
|
400
465
|
};
|
|
401
466
|
type KubbPluginKind = 'schema' | 'controller';
|
|
402
|
-
type
|
|
403
|
-
type KubbObjectPlugin =
|
|
467
|
+
type KubbJSONPlugins = [plugin: keyof Register | string, options: Register[keyof Register] | object];
|
|
468
|
+
type KubbObjectPlugin = keyof Register;
|
|
469
|
+
type KubbObjectPlugins = {
|
|
404
470
|
[K in keyof Register]: Register[K] | object;
|
|
405
471
|
};
|
|
406
|
-
type
|
|
472
|
+
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
407
473
|
/**
|
|
408
474
|
* Unique name used for the plugin
|
|
409
475
|
* @example @kubb/typescript
|
|
410
476
|
*/
|
|
411
|
-
name:
|
|
477
|
+
name: PluginFactoryOptions['name'];
|
|
478
|
+
/**
|
|
479
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
480
|
+
*/
|
|
481
|
+
options?: TOptions['options'];
|
|
412
482
|
/**
|
|
413
483
|
* Kind/type for the plugin
|
|
414
484
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
@@ -417,15 +487,34 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
417
487
|
*/
|
|
418
488
|
kind?: KubbPluginKind;
|
|
419
489
|
/**
|
|
420
|
-
*
|
|
490
|
+
* Define an api that can be used by other plugins, see `PluginManager' where we convert from `KubbUserPlugin` to `KubbPlugin`(used when calling `createPlugin`).
|
|
421
491
|
*/
|
|
422
|
-
api?: TOptions['api'];
|
|
492
|
+
api?: (this: Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
493
|
+
} & Partial<PluginLifecycle<TOptions>>;
|
|
494
|
+
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
423
495
|
/**
|
|
424
|
-
*
|
|
496
|
+
* Unique name used for the plugin
|
|
497
|
+
* @example @kubb/typescript
|
|
498
|
+
*/
|
|
499
|
+
name: PluginFactoryOptions['name'];
|
|
500
|
+
/**
|
|
501
|
+
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
425
502
|
*/
|
|
426
503
|
options?: TOptions['options'];
|
|
504
|
+
/**
|
|
505
|
+
* Kind/type for the plugin
|
|
506
|
+
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
507
|
+
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
508
|
+
* @default undefined
|
|
509
|
+
*/
|
|
510
|
+
kind?: KubbPluginKind;
|
|
511
|
+
/**
|
|
512
|
+
* Define an api that can be used by other plugins, see `PluginManager' where we convert from `KubbUserPlugin` to `KubbPlugin`(used when calling `createPlugin`).
|
|
513
|
+
*/
|
|
514
|
+
api?: TOptions['api'];
|
|
427
515
|
} & Partial<PluginLifecycle<TOptions>>;
|
|
428
|
-
type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, API = any, resolvePathOptions = Record<string, any>> = {
|
|
516
|
+
type PluginFactoryOptions<Name = string, Options = unknown, Nested extends boolean = false, API = any, resolvePathOptions = Record<string, any>> = {
|
|
517
|
+
name: Name;
|
|
429
518
|
options: Options;
|
|
430
519
|
nested: Nested;
|
|
431
520
|
api: API;
|
|
@@ -436,12 +525,12 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
436
525
|
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
437
526
|
* @type hookParallel
|
|
438
527
|
*/
|
|
439
|
-
validate: (this: Omit<PluginContext, 'addFile'>, plugins: KubbPlugin[]) =>
|
|
528
|
+
validate: (this: Omit<PluginContext, 'addFile'>, plugins: KubbPlugin[]) => PossiblePromise<true>;
|
|
440
529
|
/**
|
|
441
530
|
* Start of the lifecycle of a plugin.
|
|
442
531
|
* @type hookParallel
|
|
443
532
|
*/
|
|
444
|
-
buildStart: (this: PluginContext, kubbConfig: KubbConfig) =>
|
|
533
|
+
buildStart: (this: PluginContext, kubbConfig: KubbConfig) => PossiblePromise<void>;
|
|
445
534
|
/**
|
|
446
535
|
* Resolve to a Path based on a fileName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
447
536
|
* Options can als be included.
|
|
@@ -460,22 +549,22 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
460
549
|
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
461
550
|
* @type hookFirst
|
|
462
551
|
*/
|
|
463
|
-
load: (this: Omit<PluginContext, 'addFile'>, path: Path) =>
|
|
552
|
+
load: (this: Omit<PluginContext, 'addFile'>, path: Path) => PossiblePromise<TransformResult | null>;
|
|
464
553
|
/**
|
|
465
554
|
* Transform the source-code.
|
|
466
555
|
* @type hookReduceArg0
|
|
467
556
|
*/
|
|
468
|
-
transform: (this: Omit<PluginContext, 'addFile'>, source: string, path: Path) =>
|
|
557
|
+
transform: (this: Omit<PluginContext, 'addFile'>, source: string, path: Path) => PossiblePromise<TransformResult>;
|
|
469
558
|
/**
|
|
470
559
|
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
471
560
|
* @type hookParallel
|
|
472
561
|
*/
|
|
473
|
-
writeFile: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: Path) =>
|
|
562
|
+
writeFile: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: Path) => PossiblePromise<void>;
|
|
474
563
|
/**
|
|
475
564
|
* End of the plugin lifecycle.
|
|
476
565
|
* @type hookParallel
|
|
477
566
|
*/
|
|
478
|
-
buildEnd: (this: PluginContext) =>
|
|
567
|
+
buildEnd: (this: PluginContext) => PossiblePromise<void>;
|
|
479
568
|
};
|
|
480
569
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
481
570
|
type ResolvePathParams<TOptions = Record<string, any>> = {
|
|
@@ -507,6 +596,7 @@ type PluginContext<TOptions = Record<string, any>> = {
|
|
|
507
596
|
resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
508
597
|
resolveName: (params: ResolveNameParams) => string | null | undefined;
|
|
509
598
|
load: (id: string) => Promise<SafeParseResult<'load'>>;
|
|
599
|
+
logger: Logger;
|
|
510
600
|
};
|
|
511
601
|
type TransformResult = string | null;
|
|
512
602
|
/**
|
|
@@ -515,18 +605,20 @@ type TransformResult = string | null;
|
|
|
515
605
|
type Path = string;
|
|
516
606
|
type OptionalPath = Path | null | undefined;
|
|
517
607
|
type FileName = string | null | undefined;
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
logLevel: LogLevel;
|
|
523
|
-
params?: TParams;
|
|
524
|
-
}) => void;
|
|
525
|
-
spinner?: Ora;
|
|
608
|
+
declare const LogLevel: {
|
|
609
|
+
readonly silent: "silent";
|
|
610
|
+
readonly info: "info";
|
|
611
|
+
readonly stacktrace: "stacktrace";
|
|
526
612
|
};
|
|
613
|
+
type LogLevels = keyof typeof LogLevel;
|
|
614
|
+
|
|
527
615
|
type BuildOptions = {
|
|
528
616
|
config: PluginContext['config'];
|
|
617
|
+
/**
|
|
618
|
+
* @default Logger without the spinner
|
|
619
|
+
*/
|
|
529
620
|
logger?: Logger;
|
|
621
|
+
debug?: boolean;
|
|
530
622
|
};
|
|
531
623
|
declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
532
624
|
|
|
@@ -535,20 +627,20 @@ declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
|
535
627
|
* accepts a direct {@link KubbConfig} object, or a function that returns it.
|
|
536
628
|
* The function receives a {@link ConfigEnv} object that exposes two properties:
|
|
537
629
|
*/
|
|
538
|
-
declare const defineConfig: (options:
|
|
630
|
+
declare const defineConfig: (options: PossiblePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig>)) => PossiblePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig>);
|
|
539
631
|
|
|
540
|
-
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<
|
|
541
|
-
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => T["nested"] extends true ?
|
|
632
|
+
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbUserPlugin<T>> : KubbUserPlugin<T>;
|
|
633
|
+
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => T["nested"] extends true ? KubbUserPlugin<T>[] : KubbUserPlugin<T>;
|
|
542
634
|
type Options = {
|
|
543
635
|
config: PluginContext['config'];
|
|
544
636
|
fileManager: FileManager;
|
|
545
637
|
resolvePath: PluginContext['resolvePath'];
|
|
546
638
|
resolveName: PluginContext['resolveName'];
|
|
547
639
|
load: PluginContext['load'];
|
|
548
|
-
|
|
640
|
+
logger: PluginContext['logger'];
|
|
549
641
|
};
|
|
550
|
-
type CorePluginOptions = PluginFactoryOptions<Options, false, PluginContext>;
|
|
551
|
-
declare const
|
|
642
|
+
type CorePluginOptions = PluginFactoryOptions<'core', Options, false, PluginContext>;
|
|
643
|
+
declare const pluginName: CorePluginOptions['name'];
|
|
552
644
|
|
|
553
645
|
/**
|
|
554
646
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
@@ -568,4 +660,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
568
660
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
569
661
|
}
|
|
570
662
|
|
|
571
|
-
export { Argument0, BuildOutput, CLIOptions, Cache,
|
|
663
|
+
export { Argument0, BuildOutput, CLIOptions, Cache, CorePluginOptions, Executer, Extension, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OnExecute, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueTask, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, isURL, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueId, validatePlugins, write, writeIndexes };
|