@kubb/core 1.14.0-canary.20231020T164632 → 1.14.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/README.md +16 -17
- package/dist/index.cjs +506 -494
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -217
- package/dist/index.d.ts +202 -217
- package/dist/index.js +508 -493
- package/dist/index.js.map +1 -1
- package/globals.d.ts +4 -4
- package/package.json +3 -3
- package/schema.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,99 @@
|
|
|
1
|
-
import { Ora } from 'ora';
|
|
2
1
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
2
|
+
import { Ora } from 'ora';
|
|
3
3
|
export { default as pc } from 'picocolors';
|
|
4
4
|
|
|
5
|
+
interface Cache<TStore extends object = object> {
|
|
6
|
+
delete(id: keyof TStore): boolean;
|
|
7
|
+
get(id: keyof TStore): TStore[keyof TStore] | null;
|
|
8
|
+
has(id: keyof TStore): boolean;
|
|
9
|
+
set(id: keyof TStore, value: unknown): void;
|
|
10
|
+
}
|
|
11
|
+
declare function createPluginCache<TStore extends PluginCache>(Store?: TStore): Cache<TStore>;
|
|
12
|
+
|
|
13
|
+
declare function clean(path: string): Promise<void>;
|
|
14
|
+
|
|
15
|
+
type FunctionParamsASTWithoutType = {
|
|
16
|
+
name?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
/**
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
default?: string;
|
|
27
|
+
};
|
|
28
|
+
type FunctionParamsASTWithType = {
|
|
29
|
+
name?: never;
|
|
30
|
+
type: string;
|
|
31
|
+
/**
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
required?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
default?: string;
|
|
40
|
+
};
|
|
41
|
+
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
42
|
+
declare class FunctionParams {
|
|
43
|
+
type?: 'generics' | 'typed';
|
|
44
|
+
items: FunctionParamsAST[];
|
|
45
|
+
constructor(type?: 'generics' | 'typed');
|
|
46
|
+
add(item: FunctionParamsAST | Array<FunctionParamsAST | undefined> | undefined): FunctionParams;
|
|
47
|
+
toString(): string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare function getUniqueName(originalName: string, data: Record<string, number>): string;
|
|
51
|
+
|
|
5
52
|
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
6
53
|
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
7
54
|
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
8
55
|
reason: T;
|
|
9
56
|
};
|
|
10
57
|
|
|
11
|
-
declare function
|
|
58
|
+
declare function createJSDocBlockText({ comments }: {
|
|
59
|
+
comments: Array<string>;
|
|
60
|
+
}): string;
|
|
12
61
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
62
|
+
type LogType = 'error' | 'info' | 'warning';
|
|
63
|
+
type Logger = {
|
|
64
|
+
log: (message: string | null) => void;
|
|
65
|
+
error: (message: string | null) => void;
|
|
66
|
+
info: (message: string | null) => void;
|
|
67
|
+
warn: (message: string | null) => void;
|
|
68
|
+
spinner?: Ora;
|
|
69
|
+
logs: string[];
|
|
70
|
+
};
|
|
71
|
+
declare function createLogger(spinner?: Ora): Logger;
|
|
72
|
+
|
|
73
|
+
declare function nameSorter<T extends {
|
|
74
|
+
name: string;
|
|
75
|
+
}>(a: T, b: T): 0 | 1 | -1;
|
|
76
|
+
|
|
77
|
+
type QueueJob<T = unknown> = {
|
|
78
|
+
(...args: unknown[]): Promise<T> | Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
type RunOptions = {
|
|
81
|
+
controller?: AbortController;
|
|
82
|
+
name?: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
};
|
|
85
|
+
declare class Queue {
|
|
86
|
+
#private;
|
|
87
|
+
constructor(maxParallel: number, debug?: boolean);
|
|
88
|
+
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
89
|
+
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
90
|
+
get hasJobs(): boolean;
|
|
91
|
+
get count(): number;
|
|
18
92
|
}
|
|
19
|
-
|
|
93
|
+
|
|
94
|
+
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
95
|
+
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
96
|
+
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
20
97
|
|
|
21
98
|
type BasePath<T extends string = string> = `${T}/`;
|
|
22
99
|
type CacheItem = KubbFile.ResolvedFile & {
|
|
@@ -36,7 +113,7 @@ declare namespace KubbFile {
|
|
|
36
113
|
};
|
|
37
114
|
type UUID = string;
|
|
38
115
|
type Source = string;
|
|
39
|
-
type Extname = '.ts' | '.js' | '.tsx' | `.${string}`;
|
|
116
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
40
117
|
type Mode = 'file' | 'directory';
|
|
41
118
|
type BaseName = `${string}${Extname}`;
|
|
42
119
|
type Path = string;
|
|
@@ -84,34 +161,21 @@ declare function getPathMode(path: string | undefined | null): KubbFile.Mode;
|
|
|
84
161
|
declare function read(path: string): Promise<string>;
|
|
85
162
|
declare function readSync(path: string): string;
|
|
86
163
|
|
|
87
|
-
declare function
|
|
88
|
-
name: string;
|
|
89
|
-
}>(a: T, b: T): 0 | 1 | -1;
|
|
164
|
+
declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
|
|
90
165
|
|
|
91
|
-
declare
|
|
92
|
-
|
|
93
|
-
|
|
166
|
+
declare class SummaryError extends Error {
|
|
167
|
+
summary: string[];
|
|
168
|
+
constructor(message: string, options: {
|
|
169
|
+
cause: Error;
|
|
170
|
+
summary?: string[];
|
|
171
|
+
});
|
|
172
|
+
}
|
|
94
173
|
|
|
95
|
-
declare
|
|
174
|
+
declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: number) => [(...args: A) => R | undefined, () => void];
|
|
96
175
|
|
|
97
176
|
declare function timeout(ms: number): Promise<unknown>;
|
|
98
177
|
|
|
99
|
-
|
|
100
|
-
(...args: unknown[]): Promise<T> | Promise<void>;
|
|
101
|
-
};
|
|
102
|
-
type RunOptions = {
|
|
103
|
-
controller?: AbortController;
|
|
104
|
-
name?: string;
|
|
105
|
-
description?: string;
|
|
106
|
-
};
|
|
107
|
-
declare class Queue {
|
|
108
|
-
#private;
|
|
109
|
-
constructor(maxParallel: number, debug?: boolean);
|
|
110
|
-
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
111
|
-
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
112
|
-
get hasJobs(): boolean;
|
|
113
|
-
get count(): number;
|
|
114
|
-
}
|
|
178
|
+
declare function combineCodes(codes: string[]): string;
|
|
115
179
|
|
|
116
180
|
declare function escape(text?: string): string;
|
|
117
181
|
/**
|
|
@@ -123,12 +187,6 @@ declare function jsStringEscape(input: any): string;
|
|
|
123
187
|
|
|
124
188
|
declare function transformReservedWord(word: string): string;
|
|
125
189
|
|
|
126
|
-
declare function combineCodes(codes: string[]): string;
|
|
127
|
-
|
|
128
|
-
declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
|
|
129
|
-
|
|
130
|
-
declare function clean(path: string): Promise<void>;
|
|
131
|
-
|
|
132
190
|
type TreeNodeOptions = DirectoryTreeOptions;
|
|
133
191
|
declare class TreeNode<T = unknown> {
|
|
134
192
|
data: T;
|
|
@@ -145,54 +203,6 @@ declare class TreeNode<T = unknown> {
|
|
|
145
203
|
|
|
146
204
|
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
147
205
|
|
|
148
|
-
/**
|
|
149
|
-
* Normalizes directories to have a trailing slash.
|
|
150
|
-
* Resolve is pretty finicky -- if the directory name doesn't have
|
|
151
|
-
* a trailing slash then it tries to look in the parent directory.
|
|
152
|
-
* i.e., if the directory is "/usr/nzakas/foo" it will start the
|
|
153
|
-
* search in /usr/nzakas. However, if the directory is "/user/nzakas/foo/",
|
|
154
|
-
* then it will start the search in /user/nzakas/foo.
|
|
155
|
-
* @param {string} directory The directory to check.
|
|
156
|
-
* @returns {string} The normalized directory.
|
|
157
|
-
*/
|
|
158
|
-
declare function normalizeDirectory(directory: string): string;
|
|
159
|
-
declare function getLocation(path: string, cwd?: string): string;
|
|
160
|
-
declare function importModule(path: string, cwd?: string): Promise<any | undefined>;
|
|
161
|
-
|
|
162
|
-
declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: number) => [(...args: A) => R | undefined, () => void];
|
|
163
|
-
|
|
164
|
-
declare class SummaryError extends Error {
|
|
165
|
-
summary: string[];
|
|
166
|
-
constructor(message: string, options: {
|
|
167
|
-
cause: Error;
|
|
168
|
-
summary?: string[];
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Behaves as an Error to log a warning in the console(still stops the execution)
|
|
174
|
-
*/
|
|
175
|
-
declare class Warning extends Error {
|
|
176
|
-
constructor(message?: string, options?: {
|
|
177
|
-
cause: Error;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
type LogType = 'error' | 'info' | 'warning';
|
|
182
|
-
type Logger = {
|
|
183
|
-
log: (message: string | null) => void;
|
|
184
|
-
error: (message: string | null) => void;
|
|
185
|
-
info: (message: string | null) => void;
|
|
186
|
-
warn: (message: string | null) => void;
|
|
187
|
-
spinner?: Ora;
|
|
188
|
-
logs: string[];
|
|
189
|
-
};
|
|
190
|
-
declare function createLogger(spinner?: Ora): Logger;
|
|
191
|
-
|
|
192
|
-
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
193
|
-
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
194
|
-
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
195
|
-
|
|
196
206
|
type URLObject = {
|
|
197
207
|
url: string;
|
|
198
208
|
params?: Record<string, string>;
|
|
@@ -210,7 +220,7 @@ declare class URLPath {
|
|
|
210
220
|
* @example /pet/{petId} => /pet/:petId
|
|
211
221
|
*/
|
|
212
222
|
get URL(): string;
|
|
213
|
-
get
|
|
223
|
+
get isURL(): boolean;
|
|
214
224
|
/**
|
|
215
225
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
216
226
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
@@ -220,7 +230,7 @@ declare class URLPath {
|
|
|
220
230
|
get template(): string;
|
|
221
231
|
get object(): URLObject | string;
|
|
222
232
|
get params(): Record<string, string> | undefined;
|
|
223
|
-
toObject(
|
|
233
|
+
toObject({ type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
224
234
|
/**
|
|
225
235
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
226
236
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
@@ -228,58 +238,25 @@ declare class URLPath {
|
|
|
228
238
|
* @example /account/userID => `/account/${userId}`
|
|
229
239
|
*/
|
|
230
240
|
toTemplateString(replacer?: (pathParam: string) => string): string;
|
|
231
|
-
/**
|
|
232
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
233
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
234
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
235
|
-
* @example /account/userID => `/account/${userId}`
|
|
236
|
-
*/
|
|
237
|
-
static toTemplateString(path: string, replacer?: (pathParam: string) => string): string;
|
|
238
241
|
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
239
|
-
static getParams(path: string, replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
240
242
|
/**
|
|
241
243
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
242
244
|
* @example /pet/{petId} => /pet/:petId
|
|
243
245
|
*/
|
|
244
246
|
toURLPath(): string;
|
|
245
|
-
static toURLPath(path: string): string;
|
|
246
|
-
static toObject(path: string, { type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
247
|
-
static isURL(path: string): boolean;
|
|
248
247
|
}
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @default true
|
|
259
|
-
*/
|
|
260
|
-
enabled?: boolean;
|
|
261
|
-
default?: string;
|
|
262
|
-
} | {
|
|
263
|
-
name?: never;
|
|
264
|
-
type: string;
|
|
265
|
-
/**
|
|
266
|
-
* @default true
|
|
267
|
-
*/
|
|
268
|
-
required?: boolean;
|
|
269
|
-
/**
|
|
270
|
-
* @default true
|
|
271
|
-
*/
|
|
272
|
-
enabled?: boolean;
|
|
273
|
-
default?: string;
|
|
274
|
-
};
|
|
275
|
-
declare class FunctionParams {
|
|
276
|
-
type?: 'generics' | 'typed';
|
|
277
|
-
items: FunctionParamsAST[];
|
|
278
|
-
constructor(type?: 'generics' | 'typed');
|
|
279
|
-
add(item: FunctionParamsAST | Array<FunctionParamsAST | undefined> | undefined): FunctionParams;
|
|
280
|
-
toString(): string;
|
|
249
|
+
/**
|
|
250
|
+
* Behaves as an Error to log a warning in the console(still stops the execution)
|
|
251
|
+
*/
|
|
252
|
+
declare class Warning extends Error {
|
|
253
|
+
constructor(message?: string, options?: {
|
|
254
|
+
cause: Error;
|
|
255
|
+
});
|
|
281
256
|
}
|
|
282
257
|
|
|
258
|
+
declare function write(data: string, path: string): Promise<void>;
|
|
259
|
+
|
|
283
260
|
declare class FileManager {
|
|
284
261
|
#private;
|
|
285
262
|
constructor(options?: {
|
|
@@ -291,6 +268,7 @@ declare class FileManager {
|
|
|
291
268
|
get isExecuting(): boolean;
|
|
292
269
|
add(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
293
270
|
addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
271
|
+
addIndexes(root: KubbFile.Path, extName?: KubbFile.Extname, options?: TreeNodeOptions): Promise<Array<KubbFile.File> | undefined>;
|
|
294
272
|
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
295
273
|
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
296
274
|
remove(path: KubbFile.Path): void;
|
|
@@ -298,7 +276,7 @@ declare class FileManager {
|
|
|
298
276
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
299
277
|
}
|
|
300
278
|
|
|
301
|
-
declare function getIndexes(root: string, options?: TreeNodeOptions): Array<KubbFile.File> | null;
|
|
279
|
+
declare function getIndexes(root: string, extName?: KubbFile.Extname, options?: TreeNodeOptions): Array<KubbFile.File> | null;
|
|
302
280
|
declare function combineFiles(files: Array<KubbFile.File | null>): Array<KubbFile.File>;
|
|
303
281
|
/**
|
|
304
282
|
* Support for js, ts and tsx(React)
|
|
@@ -309,6 +287,26 @@ declare function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile
|
|
|
309
287
|
declare function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source: string): Array<KubbFile.Import>;
|
|
310
288
|
declare function createFileSource(file: KubbFile.File): string;
|
|
311
289
|
|
|
290
|
+
type PackageJSON = {
|
|
291
|
+
dependencies?: Record<string, string>;
|
|
292
|
+
devDependencies?: Record<string, string>;
|
|
293
|
+
};
|
|
294
|
+
declare class PackageManager {
|
|
295
|
+
#private;
|
|
296
|
+
constructor(workspace?: string);
|
|
297
|
+
set workspace(workspace: string);
|
|
298
|
+
get workspace(): string | undefined;
|
|
299
|
+
normalizeDirectory(directory: string): string;
|
|
300
|
+
getLocation(path: string): string;
|
|
301
|
+
import(path: string): Promise<any | undefined>;
|
|
302
|
+
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
303
|
+
getPackageJSONSync(): PackageJSON | undefined;
|
|
304
|
+
getVersion(dependency: string): Promise<string | undefined>;
|
|
305
|
+
getVersionSync(dependency: string): string | undefined;
|
|
306
|
+
isValid(dependency: string, version: string): Promise<boolean>;
|
|
307
|
+
isValidSync(dependency: string, version: string): boolean;
|
|
308
|
+
}
|
|
309
|
+
|
|
312
310
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
313
311
|
#private;
|
|
314
312
|
constructor();
|
|
@@ -318,20 +316,12 @@ declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
|
318
316
|
removeAll(): void;
|
|
319
317
|
}
|
|
320
318
|
|
|
321
|
-
|
|
322
|
-
pluginManager: PluginManager;
|
|
323
|
-
cause: Error;
|
|
324
|
-
constructor(message: string, options: {
|
|
325
|
-
cause: Error;
|
|
326
|
-
pluginManager: PluginManager;
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
319
|
+
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
330
320
|
/**
|
|
331
321
|
* Get the type of the first argument in a function.
|
|
332
322
|
* @example Arg0<(a: string, b: number) => void> -> string
|
|
333
323
|
*/
|
|
334
|
-
type Argument0<H extends keyof PluginLifecycle> = Parameters<
|
|
324
|
+
type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
|
|
335
325
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
|
336
326
|
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
337
327
|
strategy: Strategy;
|
|
@@ -340,13 +330,14 @@ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
|
340
330
|
parameters?: unknown[] | undefined;
|
|
341
331
|
output?: unknown;
|
|
342
332
|
};
|
|
343
|
-
type ParseResult<H extends PluginLifecycleHooks> =
|
|
333
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
344
334
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
345
335
|
result: Result;
|
|
346
336
|
plugin: KubbPlugin;
|
|
347
337
|
};
|
|
338
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<RequiredPluginLifecycle[H]>;
|
|
348
339
|
|
|
349
|
-
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false,
|
|
340
|
+
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false, unknown, Record<string, unknown>>>];
|
|
350
341
|
type Options$1 = {
|
|
351
342
|
debug?: boolean;
|
|
352
343
|
task: QueueJob<KubbFile.ResolvedFile>;
|
|
@@ -370,52 +361,47 @@ declare class PluginManager {
|
|
|
370
361
|
resolveName: (params: ResolveNameParams) => string;
|
|
371
362
|
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
372
363
|
/**
|
|
373
|
-
*
|
|
374
364
|
* Run only hook for a specific plugin name
|
|
375
365
|
*/
|
|
376
366
|
hookForPlugin<H extends PluginLifecycleHooks>({ pluginName, hookName, parameters, }: {
|
|
377
367
|
pluginName: string;
|
|
378
368
|
hookName: H;
|
|
379
|
-
parameters:
|
|
369
|
+
parameters: PluginParameter<H>;
|
|
380
370
|
}): Promise<ReturnType<ParseResult<H>> | null> | null;
|
|
381
371
|
hookForPluginSync<H extends PluginLifecycleHooks>({ pluginName, hookName, parameters, }: {
|
|
382
372
|
pluginName: string;
|
|
383
373
|
hookName: H;
|
|
384
|
-
parameters:
|
|
374
|
+
parameters: PluginParameter<H>;
|
|
385
375
|
}): ReturnType<ParseResult<H>> | null;
|
|
386
376
|
/**
|
|
387
|
-
*
|
|
388
377
|
* Chains, first non-null result stops and returns
|
|
389
378
|
*/
|
|
390
379
|
hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
|
|
391
380
|
hookName: H;
|
|
392
|
-
parameters:
|
|
381
|
+
parameters: PluginParameter<H>;
|
|
393
382
|
skipped?: ReadonlySet<KubbPlugin> | null;
|
|
394
383
|
}): Promise<SafeParseResult<H>>;
|
|
395
384
|
/**
|
|
396
|
-
*
|
|
397
385
|
* Chains, first non-null result stops and returns
|
|
398
386
|
*/
|
|
399
387
|
hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
|
|
400
388
|
hookName: H;
|
|
401
|
-
parameters:
|
|
389
|
+
parameters: PluginParameter<H>;
|
|
402
390
|
skipped?: ReadonlySet<KubbPlugin> | null;
|
|
403
391
|
}): SafeParseResult<H>;
|
|
404
392
|
/**
|
|
405
|
-
*
|
|
406
393
|
* Parallel, runs all plugins
|
|
407
394
|
*/
|
|
408
395
|
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, }: {
|
|
409
396
|
hookName: H;
|
|
410
|
-
parameters?: Parameters<
|
|
397
|
+
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
411
398
|
}): Promise<Awaited<TOuput>[]>;
|
|
412
399
|
/**
|
|
413
|
-
*
|
|
414
400
|
* Chains, reduces returned value, handling the reduced value as the first hook argument
|
|
415
401
|
*/
|
|
416
402
|
hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
|
|
417
403
|
hookName: H;
|
|
418
|
-
parameters:
|
|
404
|
+
parameters: PluginParameter<H>;
|
|
419
405
|
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
|
|
420
406
|
}): Promise<Argument0<H>>;
|
|
421
407
|
/**
|
|
@@ -423,14 +409,19 @@ declare class PluginManager {
|
|
|
423
409
|
*/
|
|
424
410
|
hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: {
|
|
425
411
|
hookName: H;
|
|
426
|
-
parameters?:
|
|
412
|
+
parameters?: PluginParameter<H>;
|
|
427
413
|
}): Promise<void>;
|
|
428
414
|
getPlugin(hookName: keyof PluginLifecycle, pluginName: string): KubbPlugin;
|
|
429
415
|
}
|
|
430
416
|
|
|
431
|
-
declare class
|
|
417
|
+
declare class PluginError extends Error {
|
|
418
|
+
pluginManager: PluginManager;
|
|
419
|
+
cause: Error;
|
|
420
|
+
constructor(message: string, options: {
|
|
421
|
+
cause: Error;
|
|
422
|
+
pluginManager: PluginManager;
|
|
423
|
+
});
|
|
432
424
|
}
|
|
433
|
-
declare function getDependedPlugins<TPlugins extends KubbPlugin[]>(plugins: KubbPlugin[], dependedPluginNames: string | string[]): TPlugins;
|
|
434
425
|
|
|
435
426
|
declare class ParallelPluginError extends Error {
|
|
436
427
|
errors: PluginError[];
|
|
@@ -443,20 +434,9 @@ declare class ParallelPluginError extends Error {
|
|
|
443
434
|
findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
|
|
444
435
|
}
|
|
445
436
|
|
|
446
|
-
|
|
447
|
-
dependencies?: Record<string, string>;
|
|
448
|
-
devDependencies?: Record<string, string>;
|
|
449
|
-
};
|
|
450
|
-
declare class PackageManager {
|
|
451
|
-
#private;
|
|
452
|
-
constructor(workspace?: string);
|
|
453
|
-
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
454
|
-
getPackageJSONSync(): PackageJSON | undefined;
|
|
455
|
-
getVersion(dependency: string): Promise<string | undefined>;
|
|
456
|
-
getVersionSync(dependency: string): string | undefined;
|
|
457
|
-
isValid(dependency: string, version: string): Promise<boolean>;
|
|
458
|
-
isValidSync(dependency: string, version: string): boolean;
|
|
437
|
+
declare class ValidationPluginError extends Error {
|
|
459
438
|
}
|
|
439
|
+
declare function getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: KubbPlugin<T1>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>] : [T1: KubbPlugin<T1>, T2: KubbPlugin<T2>, T3: KubbPlugin<T3>]>(plugins: Array<KubbPlugin>, dependedPluginNames: string | string[]): TOutput;
|
|
460
440
|
|
|
461
441
|
/**
|
|
462
442
|
* Config used in `kubb.config.js`
|
|
@@ -480,6 +460,19 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
|
|
|
480
460
|
*/
|
|
481
461
|
plugins?: Array<KubbPlugin> | Array<KubbJSONPlugins> | KubbObjectPlugins;
|
|
482
462
|
};
|
|
463
|
+
type InputPath = {
|
|
464
|
+
/**
|
|
465
|
+
* Path to be used as the input. This can be an absolute path or a path relative to the `root`.
|
|
466
|
+
*/
|
|
467
|
+
path: string;
|
|
468
|
+
};
|
|
469
|
+
type InputData = {
|
|
470
|
+
/**
|
|
471
|
+
* `string` or `object` containing the data.
|
|
472
|
+
*/
|
|
473
|
+
data: string | unknown;
|
|
474
|
+
};
|
|
475
|
+
type Input = InputPath | InputData;
|
|
483
476
|
/**
|
|
484
477
|
* @private
|
|
485
478
|
*/
|
|
@@ -490,17 +483,7 @@ type KubbConfig = {
|
|
|
490
483
|
* @default process.cwd()
|
|
491
484
|
*/
|
|
492
485
|
root: string;
|
|
493
|
-
input:
|
|
494
|
-
/**
|
|
495
|
-
* Path to be used as the input. This can be an absolute path or a path relative to the `root`.
|
|
496
|
-
*/
|
|
497
|
-
path: string;
|
|
498
|
-
} | {
|
|
499
|
-
/**
|
|
500
|
-
* `string` or `object` containing the data.
|
|
501
|
-
*/
|
|
502
|
-
data: string | unknown;
|
|
503
|
-
};
|
|
486
|
+
input: Input;
|
|
504
487
|
output: {
|
|
505
488
|
/**
|
|
506
489
|
* Path to be used to export all generated files.
|
|
@@ -575,7 +558,7 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
|
|
|
575
558
|
/**
|
|
576
559
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
577
560
|
*/
|
|
578
|
-
options
|
|
561
|
+
options: TOptions['options'] extends never ? undefined : TOptions['options'];
|
|
579
562
|
/**
|
|
580
563
|
* Kind/type for the plugin
|
|
581
564
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
@@ -583,21 +566,22 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
|
|
|
583
566
|
* @default undefined
|
|
584
567
|
*/
|
|
585
568
|
kind?: KubbPluginKind;
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
api
|
|
590
|
-
}
|
|
569
|
+
} & Partial<PluginLifecycle<TOptions>> & (TOptions['api'] extends never ? {
|
|
570
|
+
api?: never;
|
|
571
|
+
} : {
|
|
572
|
+
api: (this: Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
573
|
+
});
|
|
591
574
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
592
575
|
/**
|
|
593
576
|
* Unique name used for the plugin
|
|
594
577
|
* @example @kubb/typescript
|
|
595
578
|
*/
|
|
596
579
|
name: PluginFactoryOptions['name'];
|
|
580
|
+
key?: [kind: KubbPluginKind | undefined, name: PluginFactoryOptions['name'], identifier: string];
|
|
597
581
|
/**
|
|
598
582
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
599
583
|
*/
|
|
600
|
-
options
|
|
584
|
+
options: TOptions['options'] extends never ? undefined : TOptions['options'];
|
|
601
585
|
/**
|
|
602
586
|
* Kind/type for the plugin
|
|
603
587
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
@@ -605,12 +589,12 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
605
589
|
* @default undefined
|
|
606
590
|
*/
|
|
607
591
|
kind?: KubbPluginKind;
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
api
|
|
612
|
-
}
|
|
613
|
-
type PluginFactoryOptions<Name = string, Options = unknown, Nested extends boolean = false, API =
|
|
592
|
+
} & PluginLifecycle<TOptions> & (TOptions['api'] extends never ? {
|
|
593
|
+
api?: never;
|
|
594
|
+
} : {
|
|
595
|
+
api: TOptions['api'];
|
|
596
|
+
});
|
|
597
|
+
type PluginFactoryOptions<Name = string, Options = unknown | never, Nested extends boolean = false, API = unknown | never, resolvePathOptions = Record<string, unknown>> = {
|
|
614
598
|
name: Name;
|
|
615
599
|
options: Options;
|
|
616
600
|
nested: Nested;
|
|
@@ -622,46 +606,46 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
622
606
|
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
623
607
|
* @type hookParallel
|
|
624
608
|
*/
|
|
625
|
-
validate
|
|
609
|
+
validate?: (this: Omit<PluginContext, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
626
610
|
/**
|
|
627
611
|
* Start of the lifecycle of a plugin.
|
|
628
612
|
* @type hookParallel
|
|
629
613
|
*/
|
|
630
|
-
buildStart
|
|
614
|
+
buildStart?: (this: PluginContext, kubbConfig: KubbConfig) => PossiblePromise<void>;
|
|
631
615
|
/**
|
|
632
616
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
633
617
|
* Options can als be included.
|
|
634
618
|
* @type hookFirst
|
|
635
619
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
636
620
|
*/
|
|
637
|
-
resolvePath
|
|
621
|
+
resolvePath?: (this: PluginContext, baseName: string, directory?: string, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
|
|
638
622
|
/**
|
|
639
623
|
* Resolve to a name based on a string.
|
|
640
624
|
* Useful when converting to PascalCase or camelCase.
|
|
641
625
|
* @type hookFirst
|
|
642
626
|
* @example ('pet') => 'Pet'
|
|
643
627
|
*/
|
|
644
|
-
resolveName
|
|
628
|
+
resolveName?: (this: PluginContext, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
645
629
|
/**
|
|
646
630
|
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
647
631
|
* @type hookFirst
|
|
648
632
|
*/
|
|
649
|
-
load
|
|
633
|
+
load?: (this: Omit<PluginContext, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
|
|
650
634
|
/**
|
|
651
635
|
* Transform the source-code.
|
|
652
636
|
* @type hookReduceArg0
|
|
653
637
|
*/
|
|
654
|
-
transform
|
|
638
|
+
transform?: (this: Omit<PluginContext, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
|
|
655
639
|
/**
|
|
656
640
|
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
657
641
|
* @type hookParallel
|
|
658
642
|
*/
|
|
659
|
-
writeFile
|
|
643
|
+
writeFile?: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<void>;
|
|
660
644
|
/**
|
|
661
645
|
* End of the plugin lifecycle.
|
|
662
646
|
* @type hookParallel
|
|
663
647
|
*/
|
|
664
|
-
buildEnd
|
|
648
|
+
buildEnd?: (this: PluginContext) => PossiblePromise<void>;
|
|
665
649
|
};
|
|
666
650
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
667
651
|
type PluginCache = Record<string, [number, unknown]>;
|
|
@@ -732,20 +716,6 @@ declare function defineConfig(options: PossiblePromise<KubbUserConfig> | ((
|
|
|
732
716
|
/** The options derived from the CLI flags */
|
|
733
717
|
cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig>)): typeof options;
|
|
734
718
|
|
|
735
|
-
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbUserPlugin<T>> : KubbUserPlugin<T>;
|
|
736
|
-
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
737
|
-
type Options = {
|
|
738
|
-
config: PluginContext['config'];
|
|
739
|
-
fileManager: FileManager;
|
|
740
|
-
pluginManager: PluginManager;
|
|
741
|
-
resolvePath: PluginContext['resolvePath'];
|
|
742
|
-
resolveName: PluginContext['resolveName'];
|
|
743
|
-
logger: PluginContext['logger'];
|
|
744
|
-
getPlugins: () => KubbPlugin[];
|
|
745
|
-
};
|
|
746
|
-
type CorePluginOptions = PluginFactoryOptions<'core', Options, false, PluginContext>;
|
|
747
|
-
declare const pluginName: CorePluginOptions['name'];
|
|
748
|
-
|
|
749
719
|
/**
|
|
750
720
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
751
721
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
@@ -766,4 +736,19 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
766
736
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
767
737
|
}
|
|
768
738
|
|
|
769
|
-
|
|
739
|
+
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbUserPlugin<T>> : KubbUserPlugin<T>;
|
|
740
|
+
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
741
|
+
type Options = {
|
|
742
|
+
config: PluginContext['config'];
|
|
743
|
+
fileManager: FileManager;
|
|
744
|
+
pluginManager: PluginManager;
|
|
745
|
+
resolvePath: PluginContext['resolvePath'];
|
|
746
|
+
resolveName: PluginContext['resolveName'];
|
|
747
|
+
logger: PluginContext['logger'];
|
|
748
|
+
getPlugins: () => KubbPlugin[];
|
|
749
|
+
plugin: KubbPlugin;
|
|
750
|
+
};
|
|
751
|
+
type CorePluginOptions = PluginFactoryOptions<'core', Options, false, PluginContext>;
|
|
752
|
+
declare const pluginName: CorePluginOptions['name'];
|
|
753
|
+
|
|
754
|
+
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 };
|