@kubb/core 1.15.0-canary.20231025T123615 → 1.15.0-canary.20231026T131818
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 +706 -810
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -265
- package/dist/index.d.ts +137 -265
- package/dist/index.js +698 -792
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1208 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +235 -0
- package/dist/utils.d.ts +235 -0
- package/dist/utils.js +1156 -0
- package/dist/utils.js.map +1 -0
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,86 +1,18 @@
|
|
|
1
1
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
2
2
|
import { Ora } from 'ora';
|
|
3
|
-
export { default as pc } from 'picocolors';
|
|
4
3
|
|
|
5
|
-
|
|
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 isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
51
|
-
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
52
|
-
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
53
|
-
reason: T;
|
|
54
|
-
};
|
|
4
|
+
declare function read(path: string): Promise<string>;
|
|
55
5
|
|
|
56
|
-
declare function
|
|
57
|
-
comments: Array<string>;
|
|
58
|
-
}): string;
|
|
6
|
+
declare function write(data: string, path: string): Promise<string | undefined>;
|
|
59
7
|
|
|
60
|
-
type
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
log: (message: string | null) => void;
|
|
68
|
-
error: (message: string | null) => void;
|
|
69
|
-
info: (message: string | null) => void;
|
|
70
|
-
warn: (message: string | null) => void;
|
|
71
|
-
spinner?: Ora;
|
|
72
|
-
logs: string[];
|
|
73
|
-
};
|
|
74
|
-
type Props = {
|
|
75
|
-
name?: string;
|
|
76
|
-
logLevel: LogLevel;
|
|
77
|
-
spinner?: Ora;
|
|
8
|
+
type BarrelManagerOptions = {
|
|
9
|
+
treeNode?: DirectoryTreeOptions;
|
|
10
|
+
isTypeOnly?: boolean;
|
|
11
|
+
filter?: (file: KubbFile.File) => boolean;
|
|
12
|
+
map?: (file: KubbFile.File) => KubbFile.File;
|
|
13
|
+
includeExt?: boolean;
|
|
14
|
+
output?: string;
|
|
78
15
|
};
|
|
79
|
-
declare function createLogger({ logLevel, name, spinner }: Props): Logger;
|
|
80
|
-
|
|
81
|
-
declare function nameSorter<T extends {
|
|
82
|
-
name: string;
|
|
83
|
-
}>(a: T, b: T): 0 | 1 | -1;
|
|
84
16
|
|
|
85
17
|
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
86
18
|
#private;
|
|
@@ -113,122 +45,6 @@ declare class Queue {
|
|
|
113
45
|
get count(): number;
|
|
114
46
|
}
|
|
115
47
|
|
|
116
|
-
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
117
|
-
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
118
|
-
|
|
119
|
-
declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
|
|
120
|
-
declare function read(path: string): Promise<string>;
|
|
121
|
-
declare function readSync(path: string): string;
|
|
122
|
-
|
|
123
|
-
declare function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data?: TData | undefined): string;
|
|
124
|
-
|
|
125
|
-
declare class SummaryError extends Error {
|
|
126
|
-
summary: string[];
|
|
127
|
-
constructor(message: string, options: {
|
|
128
|
-
cause: Error;
|
|
129
|
-
summary?: string[];
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: number) => [(...args: A) => R | undefined, () => void];
|
|
134
|
-
|
|
135
|
-
declare function timeout(ms: number): Promise<unknown>;
|
|
136
|
-
|
|
137
|
-
declare function combineCodes(codes: string[]): string;
|
|
138
|
-
|
|
139
|
-
declare function escape(text?: string): string;
|
|
140
|
-
/**
|
|
141
|
-
* Escape all characters not included in SingleStringCharacters and DoubleStringCharacters on
|
|
142
|
-
* @link http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
143
|
-
* @link https://github.com/joliss/js-string-escape/blob/master/index.js
|
|
144
|
-
*/
|
|
145
|
-
declare function jsStringEscape(input: any): string;
|
|
146
|
-
|
|
147
|
-
declare function createIndent(size: number): string;
|
|
148
|
-
|
|
149
|
-
declare function transformReservedWord(word: string): string;
|
|
150
|
-
|
|
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
|
-
type TreeNodeOptions = DirectoryTreeOptions;
|
|
160
|
-
declare class TreeNode<T = unknown> {
|
|
161
|
-
data: T;
|
|
162
|
-
parent?: TreeNode<T>;
|
|
163
|
-
children: Array<TreeNode<T>>;
|
|
164
|
-
constructor(data: T, parent?: TreeNode<T>);
|
|
165
|
-
addChild(data: T): TreeNode<T>;
|
|
166
|
-
find(data?: T): TreeNode<T> | null;
|
|
167
|
-
get leaves(): TreeNode<T>[];
|
|
168
|
-
get root(): TreeNode<T>;
|
|
169
|
-
forEach(callback: (treeNode: TreeNode<T>) => void): this;
|
|
170
|
-
static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
174
|
-
|
|
175
|
-
declare function getUniqueName(originalName: string, data: Record<string, number>): string;
|
|
176
|
-
declare function setUniqueName(originalName: string, data: Record<string, number>): string;
|
|
177
|
-
|
|
178
|
-
type URLObject = {
|
|
179
|
-
url: string;
|
|
180
|
-
params?: Record<string, string>;
|
|
181
|
-
};
|
|
182
|
-
type ObjectOptions = {
|
|
183
|
-
type?: 'path' | 'template';
|
|
184
|
-
replacer?: (pathParam: string) => string;
|
|
185
|
-
stringify?: boolean;
|
|
186
|
-
};
|
|
187
|
-
declare class URLPath {
|
|
188
|
-
path: string;
|
|
189
|
-
constructor(path: string);
|
|
190
|
-
/**
|
|
191
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
192
|
-
* @example /pet/{petId} => /pet/:petId
|
|
193
|
-
*/
|
|
194
|
-
get URL(): string;
|
|
195
|
-
get isURL(): boolean;
|
|
196
|
-
/**
|
|
197
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
198
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
199
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
200
|
-
* @example /account/userID => `/account/${userId}`
|
|
201
|
-
*/
|
|
202
|
-
get template(): string;
|
|
203
|
-
get object(): URLObject | string;
|
|
204
|
-
get params(): Record<string, string> | undefined;
|
|
205
|
-
toObject({ type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
206
|
-
/**
|
|
207
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
208
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
209
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
210
|
-
* @example /account/userID => `/account/${userId}`
|
|
211
|
-
*/
|
|
212
|
-
toTemplateString(replacer?: (pathParam: string) => string): string;
|
|
213
|
-
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
214
|
-
/**
|
|
215
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
216
|
-
* @example /pet/{petId} => /pet/:petId
|
|
217
|
-
*/
|
|
218
|
-
toURLPath(): string;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Behaves as an Error to log a warning in the console(still stops the execution)
|
|
223
|
-
*/
|
|
224
|
-
declare class Warning extends Error {
|
|
225
|
-
constructor(message?: string, options?: {
|
|
226
|
-
cause: Error;
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
declare function write(data: string, path: string): Promise<string | undefined>;
|
|
231
|
-
|
|
232
48
|
type BasePath<T extends string = string> = `${T}/`;
|
|
233
49
|
declare namespace KubbFile {
|
|
234
50
|
type Import = {
|
|
@@ -250,11 +66,15 @@ declare namespace KubbFile {
|
|
|
250
66
|
type Path = string;
|
|
251
67
|
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
252
68
|
type OptionalPath = Path | undefined | null;
|
|
253
|
-
type
|
|
254
|
-
pluginKey?: KubbPlugin['key'];
|
|
255
|
-
} = {
|
|
69
|
+
type FileMetaBase = {
|
|
256
70
|
pluginKey?: KubbPlugin['key'];
|
|
257
|
-
}
|
|
71
|
+
};
|
|
72
|
+
type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
|
|
73
|
+
/**
|
|
74
|
+
* Unique identifier to reuse later
|
|
75
|
+
* @default crypto.randomUUID()
|
|
76
|
+
*/
|
|
77
|
+
id?: string;
|
|
258
78
|
/**
|
|
259
79
|
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
260
80
|
* Based on UNIX basename
|
|
@@ -270,6 +90,7 @@ declare namespace KubbFile {
|
|
|
270
90
|
exports?: Export[];
|
|
271
91
|
/**
|
|
272
92
|
* This will call fileManager.add instead of fileManager.addOrAppend, adding the source when the files already exists
|
|
93
|
+
* This will also ignore the combinefiles utils
|
|
273
94
|
* @default `false`
|
|
274
95
|
*/
|
|
275
96
|
override?: boolean;
|
|
@@ -278,31 +99,23 @@ declare namespace KubbFile {
|
|
|
278
99
|
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
279
100
|
*/
|
|
280
101
|
env?: NodeJS.ProcessEnv;
|
|
102
|
+
validate?: boolean;
|
|
281
103
|
};
|
|
282
104
|
type ResolvedFile = KubbFile.File & {
|
|
283
105
|
/**
|
|
284
|
-
* crypto.randomUUID()
|
|
106
|
+
* @default crypto.randomUUID()
|
|
285
107
|
*/
|
|
286
108
|
id: UUID;
|
|
287
109
|
};
|
|
288
110
|
}
|
|
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
|
-
|
|
111
|
+
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
|
299
112
|
type AddIndexesProps = {
|
|
300
113
|
root: KubbFile.Path;
|
|
301
114
|
extName?: KubbFile.Extname;
|
|
302
|
-
options?:
|
|
115
|
+
options?: BarrelManagerOptions;
|
|
303
116
|
meta?: KubbFile.File['meta'];
|
|
304
117
|
};
|
|
305
|
-
type Options$
|
|
118
|
+
type Options$2 = {
|
|
306
119
|
queue?: Queue;
|
|
307
120
|
task?: QueueJob<KubbFile.ResolvedFile>;
|
|
308
121
|
/**
|
|
@@ -312,27 +125,79 @@ type Options$1 = {
|
|
|
312
125
|
};
|
|
313
126
|
declare class FileManager {
|
|
314
127
|
#private;
|
|
315
|
-
constructor(options?: Options$
|
|
316
|
-
get extensions(): Array<KubbFile.Extname>;
|
|
128
|
+
constructor(options?: Options$2);
|
|
317
129
|
get files(): Array<KubbFile.File>;
|
|
318
130
|
get isExecuting(): boolean;
|
|
319
|
-
add
|
|
320
|
-
addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
131
|
+
add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
|
|
321
132
|
addIndexes({ root, extName, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
|
|
322
133
|
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
323
134
|
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
324
135
|
remove(path: KubbFile.Path): void;
|
|
325
136
|
write(...params: Parameters<typeof write>): Promise<string | undefined>;
|
|
326
137
|
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
|
|
138
|
+
static getSource<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(file: KubbFile.File<TMeta>): string;
|
|
139
|
+
static combineFiles<TMeta extends KubbFile.FileMetaBase = KubbFile.FileMetaBase>(files: Array<KubbFile.File<TMeta> | null>): Array<KubbFile.File<TMeta>>;
|
|
329
140
|
static getMode(path: string | undefined | null): KubbFile.Mode;
|
|
141
|
+
static get extensions(): Array<KubbFile.Extname>;
|
|
142
|
+
static isExtensionAllowed(baseName: string): boolean;
|
|
330
143
|
}
|
|
144
|
+
declare function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export>;
|
|
145
|
+
declare function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import>;
|
|
331
146
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
147
|
+
declare class PluginError extends Error {
|
|
148
|
+
pluginManager: PluginManager;
|
|
149
|
+
cause: Error;
|
|
150
|
+
constructor(message: string, options: {
|
|
151
|
+
cause: Error;
|
|
152
|
+
pluginManager: PluginManager;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
declare class ParallelPluginError extends Error {
|
|
156
|
+
errors: PluginError[];
|
|
157
|
+
pluginManager: PluginManager;
|
|
158
|
+
constructor(message: string, options: {
|
|
159
|
+
cause?: Error;
|
|
160
|
+
errors: PluginError[];
|
|
161
|
+
pluginManager: PluginManager;
|
|
162
|
+
});
|
|
163
|
+
findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
|
|
164
|
+
}
|
|
165
|
+
declare class SummaryError extends Error {
|
|
166
|
+
summary: string[];
|
|
167
|
+
constructor(message: string, options: {
|
|
168
|
+
cause: Error;
|
|
169
|
+
summary?: string[];
|
|
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
|
+
declare class ValidationPluginError extends Error {
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare const LogLevel: {
|
|
184
|
+
readonly silent: "silent";
|
|
185
|
+
readonly info: "info";
|
|
186
|
+
readonly debug: "debug";
|
|
187
|
+
};
|
|
188
|
+
type LogLevel = keyof typeof LogLevel;
|
|
189
|
+
type Logger = {
|
|
190
|
+
/**
|
|
191
|
+
* Optional config name to show in CLI output
|
|
192
|
+
*/
|
|
193
|
+
name?: string;
|
|
194
|
+
logLevel: LogLevel;
|
|
195
|
+
log: (message: string | null) => void;
|
|
196
|
+
error: (message: string | null) => void;
|
|
197
|
+
info: (message: string | null) => void;
|
|
198
|
+
warn: (message: string | null) => void;
|
|
199
|
+
spinner?: Ora;
|
|
200
|
+
logs: string[];
|
|
336
201
|
};
|
|
337
202
|
|
|
338
203
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
@@ -341,9 +206,9 @@ type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
|
341
206
|
* @example Arg0<(a: string, b: number) => void> -> string
|
|
342
207
|
*/
|
|
343
208
|
type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
|
|
344
|
-
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
|
209
|
+
type Strategy$1 = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
|
345
210
|
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
346
|
-
strategy: Strategy;
|
|
211
|
+
strategy: Strategy$1;
|
|
347
212
|
hookName: H;
|
|
348
213
|
plugin: KubbPlugin;
|
|
349
214
|
parameters?: unknown[] | undefined;
|
|
@@ -354,10 +219,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
354
219
|
result: Result;
|
|
355
220
|
plugin: KubbPlugin;
|
|
356
221
|
};
|
|
357
|
-
type
|
|
358
|
-
|
|
359
|
-
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, KubbPluginKind, unknown, false, unknown, Record<string, unknown>>>];
|
|
360
|
-
type Options = {
|
|
222
|
+
type Options$1 = {
|
|
361
223
|
logger: Logger;
|
|
362
224
|
/**
|
|
363
225
|
* Task for the FileManager
|
|
@@ -381,8 +243,7 @@ declare class PluginManager {
|
|
|
381
243
|
readonly queue: Queue;
|
|
382
244
|
readonly executed: Executer[];
|
|
383
245
|
readonly logger: Logger;
|
|
384
|
-
|
|
385
|
-
constructor(config: KubbConfig, options: Options);
|
|
246
|
+
constructor(config: KubbConfig, options: Options$1);
|
|
386
247
|
resolvePath: (params: ResolvePathParams) => KubbFile.OptionalPath;
|
|
387
248
|
resolveName: (params: ResolveNameParams) => string;
|
|
388
249
|
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
@@ -438,31 +299,16 @@ declare class PluginManager {
|
|
|
438
299
|
parameters?: PluginParameter<H>;
|
|
439
300
|
}): Promise<void>;
|
|
440
301
|
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
302
|
+
static 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;
|
|
303
|
+
static get hooks(): readonly ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
441
304
|
}
|
|
442
305
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
pluginManager: PluginManager;
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
declare class ParallelPluginError extends Error {
|
|
453
|
-
errors: PluginError[];
|
|
454
|
-
pluginManager: PluginManager;
|
|
455
|
-
constructor(message: string, options: {
|
|
456
|
-
cause?: Error;
|
|
457
|
-
errors: PluginError[];
|
|
458
|
-
pluginManager: PluginManager;
|
|
459
|
-
});
|
|
460
|
-
findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
declare class ValidationPluginError extends Error {
|
|
306
|
+
interface Cache<TStore extends object = object> {
|
|
307
|
+
delete(id: keyof TStore): boolean;
|
|
308
|
+
get(id: keyof TStore): TStore[keyof TStore] | null;
|
|
309
|
+
has(id: keyof TStore): boolean;
|
|
310
|
+
set(id: keyof TStore, value: unknown): void;
|
|
464
311
|
}
|
|
465
|
-
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;
|
|
466
312
|
|
|
467
313
|
/**
|
|
468
314
|
* Config used in `kubb.config.js`
|
|
@@ -693,6 +539,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
693
539
|
buildEnd?: (this: PluginContext) => PossiblePromise<void>;
|
|
694
540
|
};
|
|
695
541
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
542
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
696
543
|
type PluginCache = Record<string, [number, unknown]>;
|
|
697
544
|
type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
698
545
|
pluginKey?: KubbPlugin['key'];
|
|
@@ -727,26 +574,41 @@ type PluginContext<TOptions = Record<string, unknown>> = {
|
|
|
727
574
|
plugin: KubbPlugin;
|
|
728
575
|
};
|
|
729
576
|
type TransformResult = string | null;
|
|
730
|
-
declare const LogLevel: {
|
|
731
|
-
readonly silent: "silent";
|
|
732
|
-
readonly info: "info";
|
|
733
|
-
readonly debug: "debug";
|
|
734
|
-
};
|
|
735
|
-
type LogLevel = keyof typeof LogLevel;
|
|
736
577
|
type AppMeta = {
|
|
737
578
|
pluginManager: PluginManager;
|
|
738
579
|
};
|
|
739
580
|
type Prettify<T> = {
|
|
740
581
|
[K in keyof T]: T[K];
|
|
741
582
|
} & {};
|
|
583
|
+
/**
|
|
584
|
+
* TODO move to @kubb/types
|
|
585
|
+
* @deprecated
|
|
586
|
+
*/
|
|
742
587
|
type PossiblePromise<T> = Promise<T> | T;
|
|
743
|
-
type PromiseFunc<T, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
744
588
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
745
589
|
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
746
590
|
type Push<T extends any[], V> = [...T, V];
|
|
747
591
|
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
|
|
592
|
+
/**
|
|
593
|
+
* TODO move to @kubb/types
|
|
594
|
+
* @deprecated
|
|
595
|
+
*/
|
|
748
596
|
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;
|
|
597
|
+
/**
|
|
598
|
+
* TODO move to @kubb/types
|
|
599
|
+
* @deprecated
|
|
600
|
+
*/
|
|
749
601
|
type TupleToUnion<T> = T extends Array<infer ITEMS> ? ITEMS : never;
|
|
602
|
+
/**
|
|
603
|
+
* TODO move to @kubb/types
|
|
604
|
+
* @deprecated
|
|
605
|
+
*/
|
|
606
|
+
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
607
|
+
/**
|
|
608
|
+
* TODO move to @kubb/types
|
|
609
|
+
* @deprecated
|
|
610
|
+
*/
|
|
611
|
+
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
750
612
|
|
|
751
613
|
type BuildOptions = {
|
|
752
614
|
config: PluginContext['config'];
|
|
@@ -780,13 +642,6 @@ declare abstract class Generator<TOptions = unknown, TContext = unknown> {
|
|
|
780
642
|
abstract build(...params: unknown[]): unknown;
|
|
781
643
|
}
|
|
782
644
|
|
|
783
|
-
/**
|
|
784
|
-
* Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
|
|
785
|
-
*/
|
|
786
|
-
declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
|
|
787
|
-
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
788
|
-
}
|
|
789
|
-
|
|
790
645
|
type PackageJSON = {
|
|
791
646
|
dependencies?: Record<string, string>;
|
|
792
647
|
devDependencies?: Record<string, string>;
|
|
@@ -814,6 +669,23 @@ type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
814
669
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
815
670
|
declare const pluginName = "core";
|
|
816
671
|
|
|
672
|
+
type PromiseFunc<T, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
673
|
+
type SeqOutput<TInput extends Array<PromiseFunc<TPromise, null>>, TPromise = unknown> = ReturnType<NonNullable<TInput[number]>>;
|
|
674
|
+
type Options = {};
|
|
675
|
+
type Strategy = 'seq';
|
|
676
|
+
declare class PromiseManager {
|
|
677
|
+
#private;
|
|
678
|
+
constructor(options?: Options);
|
|
679
|
+
run<TInput extends Array<PromiseFunc<TPromise, null>>, TPromise = unknown, TOutput = SeqOutput<TInput, TPromise>>(strategy: Strategy, promises: TInput): TOutput;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
|
|
684
|
+
*/
|
|
685
|
+
declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
|
|
686
|
+
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
687
|
+
}
|
|
688
|
+
|
|
817
689
|
interface _Register {
|
|
818
690
|
}
|
|
819
691
|
type Plugins = _Register;
|
|
@@ -824,4 +696,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
|
824
696
|
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
825
697
|
type Plugin = keyof Plugins;
|
|
826
698
|
|
|
827
|
-
export { AppMeta, BuildOutput, CLIOptions,
|
|
699
|
+
export { AppMeta, BuildOutput, CLIOptions, FileManager, Generator, GetPluginFactoryOptions, GreaterThan, InputData, InputPath, KubbConfig, KubbFile, KubbObjectPlugin, KubbPlugin, KubbPluginKind, KubbUnionPlugins, KubbUserConfig, KubbUserPlugin, ObjValueTuple, OptionsOfPlugin, OptionsPlugins, PackageManager, ParallelPluginError, Plugin, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginUnion, Plugins, PossiblePromise, Prettify, PromiseManager, ResolveNameParams, ResolvePathParams, SchemaGenerator, SummaryError, TransformResult, TupleToUnion, ValidationPluginError, Warning, _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName };
|