@kubb/core 1.15.0-canary.20231024T104207 → 1.15.0-canary.20231025T103357
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 +296 -448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -238
- package/dist/index.d.ts +171 -238
- package/dist/index.js +267 -428
- package/dist/index.js.map +1 -1
- package/globals.d.ts +16 -33
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -47,6 +47,8 @@ declare class FunctionParams {
|
|
|
47
47
|
toString(): string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
declare function getUniqueName(originalName: string, data: Record<string, number>): string;
|
|
51
|
+
|
|
50
52
|
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
51
53
|
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
52
54
|
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
@@ -59,11 +61,6 @@ declare function createJSDocBlockText({ comments }: {
|
|
|
59
61
|
|
|
60
62
|
type LogType = 'error' | 'info' | 'warning';
|
|
61
63
|
type Logger = {
|
|
62
|
-
/**
|
|
63
|
-
* Optional config name to show in CLI output
|
|
64
|
-
*/
|
|
65
|
-
name?: string;
|
|
66
|
-
logLevel: LogLevel;
|
|
67
64
|
log: (message: string | null) => void;
|
|
68
65
|
error: (message: string | null) => void;
|
|
69
66
|
info: (message: string | null) => void;
|
|
@@ -71,41 +68,22 @@ type Logger = {
|
|
|
71
68
|
spinner?: Ora;
|
|
72
69
|
logs: string[];
|
|
73
70
|
};
|
|
74
|
-
|
|
75
|
-
name?: string;
|
|
76
|
-
logLevel: LogLevel;
|
|
77
|
-
spinner?: Ora;
|
|
78
|
-
};
|
|
79
|
-
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
71
|
+
declare function createLogger(spinner?: Ora): Logger;
|
|
80
72
|
|
|
81
73
|
declare function nameSorter<T extends {
|
|
82
74
|
name: string;
|
|
83
75
|
}>(a: T, b: T): 0 | 1 | -1;
|
|
84
76
|
|
|
85
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
86
|
-
#private;
|
|
87
|
-
constructor();
|
|
88
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
89
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
90
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
91
|
-
removeAll(): void;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
77
|
type QueueJob<T = unknown> = {
|
|
95
|
-
(...args: unknown[]): Promise<T | void>;
|
|
78
|
+
(...args: unknown[]): Promise<T> | Promise<void>;
|
|
96
79
|
};
|
|
97
80
|
type RunOptions = {
|
|
98
81
|
controller?: AbortController;
|
|
99
82
|
name?: string;
|
|
100
83
|
description?: string;
|
|
101
84
|
};
|
|
102
|
-
type Events$1 = {
|
|
103
|
-
jobDone: [result: unknown];
|
|
104
|
-
jobFailed: [error: Error];
|
|
105
|
-
};
|
|
106
85
|
declare class Queue {
|
|
107
86
|
#private;
|
|
108
|
-
readonly eventEmitter: EventEmitter<Events$1>;
|
|
109
87
|
constructor(maxParallel: number, debug?: boolean);
|
|
110
88
|
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
111
89
|
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
@@ -113,10 +91,73 @@ declare class Queue {
|
|
|
113
91
|
get count(): number;
|
|
114
92
|
}
|
|
115
93
|
|
|
94
|
+
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
116
95
|
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
117
96
|
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
118
97
|
|
|
98
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
99
|
+
type CacheItem = KubbFile.ResolvedFile & {
|
|
100
|
+
cancel?: () => void;
|
|
101
|
+
};
|
|
102
|
+
declare namespace KubbFile {
|
|
103
|
+
type Import = {
|
|
104
|
+
name: string | Array<string>;
|
|
105
|
+
path: string;
|
|
106
|
+
isTypeOnly?: boolean;
|
|
107
|
+
};
|
|
108
|
+
type Export = {
|
|
109
|
+
name?: string | Array<string>;
|
|
110
|
+
path: string;
|
|
111
|
+
isTypeOnly?: boolean;
|
|
112
|
+
asAlias?: boolean;
|
|
113
|
+
};
|
|
114
|
+
type UUID = string;
|
|
115
|
+
type Source = string;
|
|
116
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
117
|
+
type Mode = 'file' | 'directory';
|
|
118
|
+
type BaseName = `${string}${Extname}`;
|
|
119
|
+
type Path = string;
|
|
120
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
121
|
+
type OptionalPath = Path | undefined | null;
|
|
122
|
+
type File<TMeta extends {
|
|
123
|
+
pluginName?: string;
|
|
124
|
+
} = {
|
|
125
|
+
pluginName?: string;
|
|
126
|
+
}, TBaseName extends BaseName = BaseName> = {
|
|
127
|
+
/**
|
|
128
|
+
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
129
|
+
* Based on UNIX basename
|
|
130
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
131
|
+
*/
|
|
132
|
+
baseName: TBaseName;
|
|
133
|
+
/**
|
|
134
|
+
* Path will be full qualified path to a specified file
|
|
135
|
+
*/
|
|
136
|
+
path: AdvancedPath<TBaseName> | Path;
|
|
137
|
+
source: Source;
|
|
138
|
+
imports?: Import[];
|
|
139
|
+
exports?: Export[];
|
|
140
|
+
/**
|
|
141
|
+
* This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
|
|
142
|
+
* @default `false`
|
|
143
|
+
*/
|
|
144
|
+
override?: boolean;
|
|
145
|
+
meta?: TMeta;
|
|
146
|
+
/**
|
|
147
|
+
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
148
|
+
*/
|
|
149
|
+
env?: NodeJS.ProcessEnv;
|
|
150
|
+
};
|
|
151
|
+
type ResolvedFile = KubbFile.File & {
|
|
152
|
+
/**
|
|
153
|
+
* crypto.randomUUID()
|
|
154
|
+
*/
|
|
155
|
+
id: UUID;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
119
159
|
declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
|
|
160
|
+
declare function getPathMode(path: string | undefined | null): KubbFile.Mode;
|
|
120
161
|
declare function read(path: string): Promise<string>;
|
|
121
162
|
declare function readSync(path: string): string;
|
|
122
163
|
|
|
@@ -144,18 +185,8 @@ declare function escape(text?: string): string;
|
|
|
144
185
|
*/
|
|
145
186
|
declare function jsStringEscape(input: any): string;
|
|
146
187
|
|
|
147
|
-
declare function createIndent(size: number): string;
|
|
148
|
-
|
|
149
188
|
declare function transformReservedWord(word: string): string;
|
|
150
189
|
|
|
151
|
-
declare const transformers: {
|
|
152
|
-
readonly combineCodes: typeof combineCodes;
|
|
153
|
-
readonly escape: typeof escape;
|
|
154
|
-
readonly jsStringEscape: typeof jsStringEscape;
|
|
155
|
-
readonly createIndent: typeof createIndent;
|
|
156
|
-
readonly transformReservedWord: typeof transformReservedWord;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
190
|
type TreeNodeOptions = DirectoryTreeOptions;
|
|
160
191
|
declare class TreeNode<T = unknown> {
|
|
161
192
|
data: T;
|
|
@@ -172,9 +203,6 @@ declare class TreeNode<T = unknown> {
|
|
|
172
203
|
|
|
173
204
|
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
174
205
|
|
|
175
|
-
declare function getUniqueName(originalName: string, data: Record<string, number>): string;
|
|
176
|
-
declare function setUniqueName(originalName: string, data: Record<string, number>): string;
|
|
177
|
-
|
|
178
206
|
type URLObject = {
|
|
179
207
|
url: string;
|
|
180
208
|
params?: Record<string, string>;
|
|
@@ -227,113 +255,69 @@ declare class Warning extends Error {
|
|
|
227
255
|
});
|
|
228
256
|
}
|
|
229
257
|
|
|
230
|
-
declare function write(data: string, path: string): Promise<
|
|
258
|
+
declare function write(data: string, path: string): Promise<void>;
|
|
231
259
|
|
|
232
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
233
|
-
declare namespace KubbFile {
|
|
234
|
-
type Import = {
|
|
235
|
-
name: string | Array<string>;
|
|
236
|
-
path: string;
|
|
237
|
-
isTypeOnly?: boolean;
|
|
238
|
-
};
|
|
239
|
-
type Export = {
|
|
240
|
-
name?: string | Array<string>;
|
|
241
|
-
path: string;
|
|
242
|
-
isTypeOnly?: boolean;
|
|
243
|
-
asAlias?: boolean;
|
|
244
|
-
};
|
|
245
|
-
type UUID = string;
|
|
246
|
-
type Source = string;
|
|
247
|
-
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
248
|
-
type Mode = 'file' | 'directory';
|
|
249
|
-
type BaseName = `${string}${Extname}`;
|
|
250
|
-
type Path = string;
|
|
251
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
252
|
-
type OptionalPath = Path | undefined | null;
|
|
253
|
-
type File<TMeta extends {
|
|
254
|
-
pluginKey?: KubbPlugin['key'];
|
|
255
|
-
} = {
|
|
256
|
-
pluginKey?: KubbPlugin['key'];
|
|
257
|
-
}, TBaseName extends BaseName = BaseName> = {
|
|
258
|
-
/**
|
|
259
|
-
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
260
|
-
* Based on UNIX basename
|
|
261
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
262
|
-
*/
|
|
263
|
-
baseName: TBaseName;
|
|
264
|
-
/**
|
|
265
|
-
* Path will be full qualified path to a specified file
|
|
266
|
-
*/
|
|
267
|
-
path: AdvancedPath<TBaseName> | Path;
|
|
268
|
-
source: Source;
|
|
269
|
-
imports?: Import[];
|
|
270
|
-
exports?: Export[];
|
|
271
|
-
/**
|
|
272
|
-
* This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
|
|
273
|
-
* @default `false`
|
|
274
|
-
*/
|
|
275
|
-
override?: boolean;
|
|
276
|
-
meta?: TMeta;
|
|
277
|
-
/**
|
|
278
|
-
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
279
|
-
*/
|
|
280
|
-
env?: NodeJS.ProcessEnv;
|
|
281
|
-
};
|
|
282
|
-
type ResolvedFile = KubbFile.File & {
|
|
283
|
-
/**
|
|
284
|
-
* crypto.randomUUID()
|
|
285
|
-
*/
|
|
286
|
-
id: UUID;
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
type IndexesOptions = {
|
|
291
|
-
treeNode?: TreeNodeOptions;
|
|
292
|
-
isTypeOnly?: boolean;
|
|
293
|
-
filter?: (file: KubbFile.File) => boolean;
|
|
294
|
-
map?: (file: KubbFile.File) => KubbFile.File;
|
|
295
|
-
includeExt?: boolean;
|
|
296
|
-
output?: string;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
type AddIndexesProps = {
|
|
300
|
-
root: KubbFile.Path;
|
|
301
|
-
extName?: KubbFile.Extname;
|
|
302
|
-
options?: IndexesOptions;
|
|
303
|
-
meta?: KubbFile.File['meta'];
|
|
304
|
-
};
|
|
305
|
-
type Options$1 = {
|
|
306
|
-
queue?: Queue;
|
|
307
|
-
task?: QueueJob<KubbFile.ResolvedFile>;
|
|
308
|
-
/**
|
|
309
|
-
* Timeout between writes
|
|
310
|
-
*/
|
|
311
|
-
timeout?: number;
|
|
312
|
-
};
|
|
313
260
|
declare class FileManager {
|
|
314
261
|
#private;
|
|
315
|
-
constructor(options?:
|
|
262
|
+
constructor(options?: {
|
|
263
|
+
queue?: Queue;
|
|
264
|
+
task?: QueueJob<KubbFile.ResolvedFile>;
|
|
265
|
+
});
|
|
316
266
|
get extensions(): Array<KubbFile.Extname>;
|
|
317
267
|
get files(): Array<KubbFile.File>;
|
|
318
268
|
get isExecuting(): boolean;
|
|
319
269
|
add(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
320
270
|
addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
321
|
-
addIndexes(
|
|
271
|
+
addIndexes(root: KubbFile.Path, extName?: KubbFile.Extname, options?: TreeNodeOptions): Promise<Array<KubbFile.File> | undefined>;
|
|
322
272
|
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
323
273
|
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
324
274
|
remove(path: KubbFile.Path): void;
|
|
325
|
-
write(...params: Parameters<typeof write>): Promise<
|
|
275
|
+
write(...params: Parameters<typeof write>): Promise<void>;
|
|
326
276
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
327
|
-
static getSource(file: KubbFile.File): string;
|
|
328
|
-
static combineFiles(files: Array<KubbFile.File | null>): Array<KubbFile.File>;
|
|
329
|
-
static getMode(path: string | undefined | null): KubbFile.Mode;
|
|
330
277
|
}
|
|
331
278
|
|
|
332
|
-
|
|
333
|
-
declare function
|
|
334
|
-
|
|
335
|
-
|
|
279
|
+
declare function getIndexes(root: string, extName?: KubbFile.Extname, options?: TreeNodeOptions): Array<KubbFile.File> | null;
|
|
280
|
+
declare function combineFiles(files: Array<KubbFile.File | null>): Array<KubbFile.File>;
|
|
281
|
+
/**
|
|
282
|
+
* Support for js, ts and tsx(React)
|
|
283
|
+
*/
|
|
284
|
+
declare const extensions: Array<KubbFile.Extname>;
|
|
285
|
+
declare function isExtensionAllowed(baseName: string): boolean;
|
|
286
|
+
declare function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export>;
|
|
287
|
+
declare function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source: string): Array<KubbFile.Import>;
|
|
288
|
+
declare function createFileSource(file: KubbFile.File): string;
|
|
289
|
+
|
|
290
|
+
type PackageJSON = {
|
|
291
|
+
dependencies?: Record<string, string>;
|
|
292
|
+
devDependencies?: Record<string, string>;
|
|
336
293
|
};
|
|
294
|
+
type DependencyName = string;
|
|
295
|
+
type DependencyVersion = string;
|
|
296
|
+
declare class PackageManager {
|
|
297
|
+
#private;
|
|
298
|
+
constructor(workspace?: string);
|
|
299
|
+
set workspace(workspace: string);
|
|
300
|
+
get workspace(): string | undefined;
|
|
301
|
+
normalizeDirectory(directory: string): string;
|
|
302
|
+
getLocation(path: string): string;
|
|
303
|
+
import(path: string): Promise<any | undefined>;
|
|
304
|
+
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
305
|
+
getPackageJSONSync(): PackageJSON | undefined;
|
|
306
|
+
static setVersion(dependency: DependencyName, version: DependencyVersion): void;
|
|
307
|
+
getVersion(dependency: DependencyName): Promise<DependencyVersion | undefined>;
|
|
308
|
+
getVersionSync(dependency: DependencyName): DependencyVersion | undefined;
|
|
309
|
+
isValid(dependency: DependencyName, version: DependencyVersion): Promise<boolean>;
|
|
310
|
+
isValidSync(dependency: DependencyName, version: DependencyVersion): boolean;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
314
|
+
#private;
|
|
315
|
+
constructor();
|
|
316
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
317
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
318
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
319
|
+
removeAll(): void;
|
|
320
|
+
}
|
|
337
321
|
|
|
338
322
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
339
323
|
/**
|
|
@@ -356,17 +340,11 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
356
340
|
};
|
|
357
341
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<RequiredPluginLifecycle[H]>;
|
|
358
342
|
|
|
359
|
-
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string,
|
|
360
|
-
type Options = {
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Task for the FileManager
|
|
364
|
-
*/
|
|
343
|
+
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false, unknown, Record<string, unknown>>>];
|
|
344
|
+
type Options$1 = {
|
|
345
|
+
debug?: boolean;
|
|
365
346
|
task: QueueJob<KubbFile.ResolvedFile>;
|
|
366
|
-
|
|
367
|
-
* Timeout between writes in the FileManager
|
|
368
|
-
*/
|
|
369
|
-
writeTimeout?: number;
|
|
347
|
+
logger: Logger;
|
|
370
348
|
};
|
|
371
349
|
type Events = {
|
|
372
350
|
execute: [executer: Executer];
|
|
@@ -381,24 +359,23 @@ declare class PluginManager {
|
|
|
381
359
|
readonly queue: Queue;
|
|
382
360
|
readonly executed: Executer[];
|
|
383
361
|
readonly logger: Logger;
|
|
384
|
-
|
|
385
|
-
constructor(config: KubbConfig, options: Options);
|
|
362
|
+
constructor(config: KubbConfig, options: Options$1);
|
|
386
363
|
resolvePath: (params: ResolvePathParams) => KubbFile.OptionalPath;
|
|
387
364
|
resolveName: (params: ResolveNameParams) => string;
|
|
388
365
|
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
389
366
|
/**
|
|
390
367
|
* Run only hook for a specific plugin name
|
|
391
368
|
*/
|
|
392
|
-
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
393
|
-
|
|
369
|
+
hookForPlugin<H extends PluginLifecycleHooks>({ pluginName, hookName, parameters, }: {
|
|
370
|
+
pluginName: string;
|
|
394
371
|
hookName: H;
|
|
395
372
|
parameters: PluginParameter<H>;
|
|
396
|
-
}): Promise<
|
|
397
|
-
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
398
|
-
|
|
373
|
+
}): Promise<ReturnType<ParseResult<H>> | null> | null;
|
|
374
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({ pluginName, hookName, parameters, }: {
|
|
375
|
+
pluginName: string;
|
|
399
376
|
hookName: H;
|
|
400
377
|
parameters: PluginParameter<H>;
|
|
401
|
-
}):
|
|
378
|
+
}): ReturnType<ParseResult<H>> | null;
|
|
402
379
|
/**
|
|
403
380
|
* Chains, first non-null result stops and returns
|
|
404
381
|
*/
|
|
@@ -437,7 +414,7 @@ declare class PluginManager {
|
|
|
437
414
|
hookName: H;
|
|
438
415
|
parameters?: PluginParameter<H>;
|
|
439
416
|
}): Promise<void>;
|
|
440
|
-
|
|
417
|
+
getPlugin(hookName: keyof PluginLifecycle, pluginName: string): KubbPlugin;
|
|
441
418
|
}
|
|
442
419
|
|
|
443
420
|
declare class PluginError extends Error {
|
|
@@ -484,7 +461,7 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
|
|
|
484
461
|
* Example: ['@kubb/swagger', { output: false }]
|
|
485
462
|
* Or: createSwagger({ output: false })
|
|
486
463
|
*/
|
|
487
|
-
plugins?: Array<
|
|
464
|
+
plugins?: Array<KubbPlugin> | Array<KubbJSONPlugins> | KubbObjectPlugins;
|
|
488
465
|
};
|
|
489
466
|
type InputPath = {
|
|
490
467
|
/**
|
|
@@ -502,18 +479,14 @@ type Input = InputPath | InputData;
|
|
|
502
479
|
/**
|
|
503
480
|
* @private
|
|
504
481
|
*/
|
|
505
|
-
type KubbConfig
|
|
506
|
-
/**
|
|
507
|
-
* Optional config name to show in CLI output
|
|
508
|
-
*/
|
|
509
|
-
name?: string;
|
|
482
|
+
type KubbConfig = {
|
|
510
483
|
/**
|
|
511
484
|
* Project root directory. Can be an absolute path, or a path relative from
|
|
512
485
|
* the location of the config file itself.
|
|
513
486
|
* @default process.cwd()
|
|
514
487
|
*/
|
|
515
488
|
root: string;
|
|
516
|
-
input:
|
|
489
|
+
input: Input;
|
|
517
490
|
output: {
|
|
518
491
|
/**
|
|
519
492
|
* Path to be used to export all generated files.
|
|
@@ -574,50 +547,40 @@ type BuildOutput = {
|
|
|
574
547
|
pluginManager: PluginManager;
|
|
575
548
|
};
|
|
576
549
|
type KubbPluginKind = 'schema' | 'controller';
|
|
577
|
-
type
|
|
578
|
-
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
579
|
-
type
|
|
550
|
+
type KubbJSONPlugins = [plugin: keyof Kubb.OptionsPlugins | (string & {}), options: Kubb.OptionsPlugins[keyof Kubb.OptionsPlugins]];
|
|
551
|
+
type KubbObjectPlugin = keyof Kubb.OptionsPlugins;
|
|
552
|
+
type KubbObjectPlugins = {
|
|
553
|
+
[K in keyof Kubb.OptionsPlugins]: Kubb.OptionsPlugins[K] | object;
|
|
554
|
+
};
|
|
580
555
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
581
556
|
/**
|
|
582
557
|
* Unique name used for the plugin
|
|
583
558
|
* @example @kubb/typescript
|
|
584
559
|
*/
|
|
585
|
-
name:
|
|
586
|
-
/**
|
|
587
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
588
|
-
* @private
|
|
589
|
-
*/
|
|
590
|
-
key?: TOptions['key'];
|
|
560
|
+
name: PluginFactoryOptions['name'];
|
|
591
561
|
/**
|
|
592
562
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
593
563
|
*/
|
|
594
564
|
options: TOptions['options'] extends never ? undefined : TOptions['options'];
|
|
595
|
-
} & Partial<PluginLifecycle<TOptions>> & (TOptions['api'] extends never ? {
|
|
596
|
-
api?: never;
|
|
597
|
-
} : {
|
|
598
|
-
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
599
|
-
}) & (TOptions['kind'] extends never ? {
|
|
600
|
-
kind?: never;
|
|
601
|
-
} : {
|
|
602
565
|
/**
|
|
603
566
|
* Kind/type for the plugin
|
|
604
567
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
605
568
|
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
606
569
|
* @default undefined
|
|
607
570
|
*/
|
|
608
|
-
kind
|
|
571
|
+
kind?: KubbPluginKind;
|
|
572
|
+
} & Partial<PluginLifecycle<TOptions>> & (TOptions['api'] extends never ? {
|
|
573
|
+
api?: never;
|
|
574
|
+
} : {
|
|
575
|
+
api: (this: Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
609
576
|
});
|
|
610
577
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
611
578
|
/**
|
|
612
579
|
* Unique name used for the plugin
|
|
613
580
|
* @example @kubb/typescript
|
|
614
581
|
*/
|
|
615
|
-
name:
|
|
616
|
-
|
|
617
|
-
* Internal key used when a developer uses more than one of the same plugin
|
|
618
|
-
* @private
|
|
619
|
-
*/
|
|
620
|
-
key: TOptions['key'];
|
|
582
|
+
name: PluginFactoryOptions['name'];
|
|
583
|
+
key?: [kind: KubbPluginKind | undefined, name: PluginFactoryOptions['name'], identifier: string];
|
|
621
584
|
/**
|
|
622
585
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
623
586
|
*/
|
|
@@ -634,13 +597,8 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
634
597
|
} : {
|
|
635
598
|
api: TOptions['api'];
|
|
636
599
|
});
|
|
637
|
-
type PluginFactoryOptions<Name = string,
|
|
600
|
+
type PluginFactoryOptions<Name = string, Options = unknown | never, Nested extends boolean = false, API = unknown | never, resolvePathOptions = Record<string, unknown>> = {
|
|
638
601
|
name: Name;
|
|
639
|
-
kind: Kind;
|
|
640
|
-
/**
|
|
641
|
-
* Same like `QueryKey` in `@tanstack/react-query`
|
|
642
|
-
*/
|
|
643
|
-
key: [kind: Kind | undefined, name: Name, identifier?: string | number];
|
|
644
602
|
options: Options;
|
|
645
603
|
nested: Nested;
|
|
646
604
|
api: API;
|
|
@@ -685,7 +643,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
685
643
|
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
686
644
|
* @type hookParallel
|
|
687
645
|
*/
|
|
688
|
-
writeFile?: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<
|
|
646
|
+
writeFile?: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<void>;
|
|
689
647
|
/**
|
|
690
648
|
* End of the plugin lifecycle.
|
|
691
649
|
* @type hookParallel
|
|
@@ -695,7 +653,11 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
695
653
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
696
654
|
type PluginCache = Record<string, [number, unknown]>;
|
|
697
655
|
type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
698
|
-
|
|
656
|
+
/**
|
|
657
|
+
* When set, resolvePath will only call resolvePath of the name of the plugin set here.
|
|
658
|
+
* If not defined it will fall back on the resolvePath of the core plugin.
|
|
659
|
+
*/
|
|
660
|
+
pluginName?: string;
|
|
699
661
|
baseName: string;
|
|
700
662
|
directory?: string | undefined;
|
|
701
663
|
/**
|
|
@@ -705,7 +667,11 @@ type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
|
705
667
|
};
|
|
706
668
|
type ResolveNameParams = {
|
|
707
669
|
name: string;
|
|
708
|
-
|
|
670
|
+
/**
|
|
671
|
+
* When set, resolvePath will only call resolvePath of the name of the plugin set here.
|
|
672
|
+
* If not defined it will fall back on the resolvePath of the core plugin.
|
|
673
|
+
*/
|
|
674
|
+
pluginName?: string;
|
|
709
675
|
type?: 'file' | 'function';
|
|
710
676
|
};
|
|
711
677
|
type PluginContext<TOptions = Record<string, unknown>> = {
|
|
@@ -717,14 +683,7 @@ type PluginContext<TOptions = Record<string, unknown>> = {
|
|
|
717
683
|
resolvePath: (params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
718
684
|
resolveName: (params: ResolveNameParams) => string;
|
|
719
685
|
logger: Logger;
|
|
720
|
-
/**
|
|
721
|
-
* All plugins
|
|
722
|
-
*/
|
|
723
686
|
plugins: KubbPlugin[];
|
|
724
|
-
/**
|
|
725
|
-
* Current plugin
|
|
726
|
-
*/
|
|
727
|
-
plugin: KubbPlugin;
|
|
728
687
|
};
|
|
729
688
|
type TransformResult = string | null;
|
|
730
689
|
declare const LogLevel: {
|
|
@@ -740,13 +699,6 @@ type Prettify<T> = {
|
|
|
740
699
|
[K in keyof T]: T[K];
|
|
741
700
|
} & {};
|
|
742
701
|
type PossiblePromise<T> = Promise<T> | T;
|
|
743
|
-
type PromiseFunc<T, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
744
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
745
|
-
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
746
|
-
type Push<T extends any[], V> = [...T, V];
|
|
747
|
-
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
|
|
748
|
-
type ObjValueTuple<T, KS extends any[] = TuplifyUnion<keyof T>, R extends any[] = []> = KS extends [infer K, ...infer KT] ? ObjValueTuple<T, KT, [...R, [name: K & keyof T, options: T[K & keyof T]]]> : R;
|
|
749
|
-
type TupleToUnion<T> = T extends Array<infer ITEMS> ? ITEMS : never;
|
|
750
702
|
|
|
751
703
|
type BuildOptions = {
|
|
752
704
|
config: PluginContext['config'];
|
|
@@ -754,6 +706,7 @@ type BuildOptions = {
|
|
|
754
706
|
* @default Logger without the spinner
|
|
755
707
|
*/
|
|
756
708
|
logger?: Logger;
|
|
709
|
+
logLevel?: LogLevel;
|
|
757
710
|
};
|
|
758
711
|
declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
759
712
|
|
|
@@ -762,10 +715,9 @@ declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
|
762
715
|
* accepts a direct {@link KubbConfig} object, or a function that returns it.
|
|
763
716
|
* The function receives a {@link ConfigEnv} object that exposes two properties:
|
|
764
717
|
*/
|
|
765
|
-
declare function defineConfig(options: PossiblePromise<KubbUserConfig |
|
|
718
|
+
declare function defineConfig(options: PossiblePromise<KubbUserConfig> | ((
|
|
766
719
|
/** The options derived from the CLI flags */
|
|
767
|
-
cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig
|
|
768
|
-
declare function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath>;
|
|
720
|
+
cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig>)): typeof options;
|
|
769
721
|
|
|
770
722
|
/**
|
|
771
723
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
@@ -787,38 +739,19 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
787
739
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
788
740
|
}
|
|
789
741
|
|
|
790
|
-
type
|
|
791
|
-
dependencies?: Record<string, string>;
|
|
792
|
-
devDependencies?: Record<string, string>;
|
|
793
|
-
};
|
|
794
|
-
declare class PackageManager {
|
|
795
|
-
#private;
|
|
796
|
-
constructor(workspace?: string);
|
|
797
|
-
set workspace(workspace: string);
|
|
798
|
-
get workspace(): string | undefined;
|
|
799
|
-
normalizeDirectory(directory: string): string;
|
|
800
|
-
getLocation(path: string): string;
|
|
801
|
-
import(path: string): Promise<any | undefined>;
|
|
802
|
-
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
803
|
-
getPackageJSONSync(): PackageJSON | undefined;
|
|
804
|
-
getVersion(dependency: string): Promise<string | undefined>;
|
|
805
|
-
getVersionSync(dependency: string): string | undefined;
|
|
806
|
-
isValid(dependency: string, version: string): Promise<boolean>;
|
|
807
|
-
isValidSync(dependency: string, version: string): boolean;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPlugin<T>;
|
|
742
|
+
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbUserPlugin<T>> : KubbUserPlugin<T>;
|
|
811
743
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
744
|
+
type Options = {
|
|
745
|
+
config: PluginContext['config'];
|
|
746
|
+
fileManager: FileManager;
|
|
747
|
+
pluginManager: PluginManager;
|
|
748
|
+
resolvePath: PluginContext['resolvePath'];
|
|
749
|
+
resolveName: PluginContext['resolveName'];
|
|
750
|
+
logger: PluginContext['logger'];
|
|
751
|
+
getPlugins: () => KubbPlugin[];
|
|
752
|
+
plugin: KubbPlugin;
|
|
819
753
|
};
|
|
820
|
-
type
|
|
821
|
-
|
|
822
|
-
type Plugin = keyof Plugins;
|
|
754
|
+
type CorePluginOptions = PluginFactoryOptions<'core', Options, false, PluginContext>;
|
|
755
|
+
declare const pluginName: CorePluginOptions['name'];
|
|
823
756
|
|
|
824
|
-
export { AppMeta, BuildOutput, CLIOptions, Cache, FileManager, FunctionParams, FunctionParamsAST, Generator,
|
|
757
|
+
export { AppMeta, Argument0, BuildOutput, CLIOptions, Cache, CacheItem, Executer, FileManager, FunctionParams, FunctionParamsAST, Generator, KubbConfig, KubbFile, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogType, Logger, PackageManager, ParallelPluginError, ParseResult, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PossiblePromise, Prettify, Queue, QueueJob, RequiredPluginLifecycle, ResolveNameParams, ResolvePathParams, SafeParseResult, SchemaGenerator, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLObject, URLPath, ValidationPluginError, Warning, build, clean, combineCodes, combineExports, combineFiles, combineImports, createFileSource, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, escape, extensions, getDependedPlugins, getIndexes, getPathMode, getRelativePath, getUniqueName, hooks, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, jsStringEscape, pluginName as name, nameSorter, pluginName, randomColour, randomPicoColour, read, readSync, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
|