@kubb/core 1.15.0-canary.20231025T103357 → 1.15.0-canary.20231025T223729
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 +938 -876
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +266 -320
- package/dist/index.d.ts +266 -320
- package/dist/index.js +863 -783
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1194 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +228 -0
- package/dist/utils.d.ts +228 -0
- package/dist/utils.js +1145 -0
- package/dist/utils.js.map +1 -0
- package/globals.d.ts +33 -16
- package/package.json +9 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,89 +1,43 @@
|
|
|
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 getUniqueName(originalName: string, data: Record<string, number>): string;
|
|
51
|
-
|
|
52
|
-
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
53
|
-
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
54
|
-
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
55
|
-
reason: T;
|
|
56
|
-
};
|
|
4
|
+
declare function read(path: string): Promise<string>;
|
|
57
5
|
|
|
58
|
-
declare function
|
|
59
|
-
comments: Array<string>;
|
|
60
|
-
}): string;
|
|
6
|
+
declare function write(data: string, path: string): Promise<string | undefined>;
|
|
61
7
|
|
|
62
|
-
type
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
logs: string[];
|
|
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;
|
|
70
15
|
};
|
|
71
|
-
declare function createLogger(spinner?: Ora): Logger;
|
|
72
16
|
|
|
73
|
-
declare
|
|
74
|
-
|
|
75
|
-
|
|
17
|
+
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
18
|
+
#private;
|
|
19
|
+
constructor();
|
|
20
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
21
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
22
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
23
|
+
removeAll(): void;
|
|
24
|
+
}
|
|
76
25
|
|
|
77
26
|
type QueueJob<T = unknown> = {
|
|
78
|
-
(...args: unknown[]): Promise<T
|
|
27
|
+
(...args: unknown[]): Promise<T | void>;
|
|
79
28
|
};
|
|
80
29
|
type RunOptions = {
|
|
81
30
|
controller?: AbortController;
|
|
82
31
|
name?: string;
|
|
83
32
|
description?: string;
|
|
84
33
|
};
|
|
34
|
+
type Events$1 = {
|
|
35
|
+
jobDone: [result: unknown];
|
|
36
|
+
jobFailed: [error: Error];
|
|
37
|
+
};
|
|
85
38
|
declare class Queue {
|
|
86
39
|
#private;
|
|
40
|
+
readonly eventEmitter: EventEmitter<Events$1>;
|
|
87
41
|
constructor(maxParallel: number, debug?: boolean);
|
|
88
42
|
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
89
43
|
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
@@ -91,14 +45,7 @@ declare class Queue {
|
|
|
91
45
|
get count(): number;
|
|
92
46
|
}
|
|
93
47
|
|
|
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;
|
|
97
|
-
|
|
98
48
|
type BasePath<T extends string = string> = `${T}/`;
|
|
99
|
-
type CacheItem = KubbFile.ResolvedFile & {
|
|
100
|
-
cancel?: () => void;
|
|
101
|
-
};
|
|
102
49
|
declare namespace KubbFile {
|
|
103
50
|
type Import = {
|
|
104
51
|
name: string | Array<string>;
|
|
@@ -119,11 +66,15 @@ declare namespace KubbFile {
|
|
|
119
66
|
type Path = string;
|
|
120
67
|
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
121
68
|
type OptionalPath = Path | undefined | null;
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
69
|
+
type FileMetaBase = {
|
|
70
|
+
pluginKey?: KubbPlugin['key'];
|
|
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;
|
|
127
78
|
/**
|
|
128
79
|
* Name to be used to dynamicly create the baseName(based on input.path)
|
|
129
80
|
* Based on UNIX basename
|
|
@@ -139,6 +90,7 @@ declare namespace KubbFile {
|
|
|
139
90
|
exports?: Export[];
|
|
140
91
|
/**
|
|
141
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
|
|
142
94
|
* @default `false`
|
|
143
95
|
*/
|
|
144
96
|
override?: boolean;
|
|
@@ -147,22 +99,67 @@ declare namespace KubbFile {
|
|
|
147
99
|
* This will override `process.env[key]` inside the `source`, see `getFileSource`.
|
|
148
100
|
*/
|
|
149
101
|
env?: NodeJS.ProcessEnv;
|
|
102
|
+
validate?: boolean;
|
|
150
103
|
};
|
|
151
104
|
type ResolvedFile = KubbFile.File & {
|
|
152
105
|
/**
|
|
153
|
-
* crypto.randomUUID()
|
|
106
|
+
* @default crypto.randomUUID()
|
|
154
107
|
*/
|
|
155
108
|
id: UUID;
|
|
156
109
|
};
|
|
157
110
|
}
|
|
111
|
+
type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
|
|
112
|
+
type AddIndexesProps = {
|
|
113
|
+
root: KubbFile.Path;
|
|
114
|
+
extName?: KubbFile.Extname;
|
|
115
|
+
options?: BarrelManagerOptions;
|
|
116
|
+
meta?: KubbFile.File['meta'];
|
|
117
|
+
};
|
|
118
|
+
type Options$2 = {
|
|
119
|
+
queue?: Queue;
|
|
120
|
+
task?: QueueJob<KubbFile.ResolvedFile>;
|
|
121
|
+
/**
|
|
122
|
+
* Timeout between writes
|
|
123
|
+
*/
|
|
124
|
+
timeout?: number;
|
|
125
|
+
};
|
|
126
|
+
declare class FileManager {
|
|
127
|
+
#private;
|
|
128
|
+
constructor(options?: Options$2);
|
|
129
|
+
get files(): Array<KubbFile.File>;
|
|
130
|
+
get isExecuting(): boolean;
|
|
131
|
+
add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
|
|
132
|
+
addIndexes({ root, extName, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
|
|
133
|
+
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
134
|
+
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
135
|
+
remove(path: KubbFile.Path): void;
|
|
136
|
+
write(...params: Parameters<typeof write>): Promise<string | undefined>;
|
|
137
|
+
read(...params: Parameters<typeof read>): Promise<string>;
|
|
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>>;
|
|
140
|
+
static getMode(path: string | undefined | null): KubbFile.Mode;
|
|
141
|
+
static get extensions(): Array<KubbFile.Extname>;
|
|
142
|
+
static isExtensionAllowed(baseName: string): boolean;
|
|
143
|
+
}
|
|
158
144
|
|
|
159
|
-
declare
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
145
|
+
declare class PluginError extends Error {
|
|
146
|
+
pluginManager: PluginManager;
|
|
147
|
+
cause: Error;
|
|
148
|
+
constructor(message: string, options: {
|
|
149
|
+
cause: Error;
|
|
150
|
+
pluginManager: PluginManager;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
declare class ParallelPluginError extends Error {
|
|
154
|
+
errors: PluginError[];
|
|
155
|
+
pluginManager: PluginManager;
|
|
156
|
+
constructor(message: string, options: {
|
|
157
|
+
cause?: Error;
|
|
158
|
+
errors: PluginError[];
|
|
159
|
+
pluginManager: PluginManager;
|
|
160
|
+
});
|
|
161
|
+
findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
|
|
162
|
+
}
|
|
166
163
|
declare class SummaryError extends Error {
|
|
167
164
|
summary: string[];
|
|
168
165
|
constructor(message: string, options: {
|
|
@@ -170,82 +167,6 @@ declare class SummaryError extends Error {
|
|
|
170
167
|
summary?: string[];
|
|
171
168
|
});
|
|
172
169
|
}
|
|
173
|
-
|
|
174
|
-
declare const throttle: <R, A extends any[]>(fn: (...args: A) => R, delay: number) => [(...args: A) => R | undefined, () => void];
|
|
175
|
-
|
|
176
|
-
declare function timeout(ms: number): Promise<unknown>;
|
|
177
|
-
|
|
178
|
-
declare function combineCodes(codes: string[]): string;
|
|
179
|
-
|
|
180
|
-
declare function escape(text?: string): string;
|
|
181
|
-
/**
|
|
182
|
-
* Escape all characters not included in SingleStringCharacters and DoubleStringCharacters on
|
|
183
|
-
* @link http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
184
|
-
* @link https://github.com/joliss/js-string-escape/blob/master/index.js
|
|
185
|
-
*/
|
|
186
|
-
declare function jsStringEscape(input: any): string;
|
|
187
|
-
|
|
188
|
-
declare function transformReservedWord(word: string): string;
|
|
189
|
-
|
|
190
|
-
type TreeNodeOptions = DirectoryTreeOptions;
|
|
191
|
-
declare class TreeNode<T = unknown> {
|
|
192
|
-
data: T;
|
|
193
|
-
parent?: TreeNode<T>;
|
|
194
|
-
children: Array<TreeNode<T>>;
|
|
195
|
-
constructor(data: T, parent?: TreeNode<T>);
|
|
196
|
-
addChild(data: T): TreeNode<T>;
|
|
197
|
-
find(data?: T): TreeNode<T> | null;
|
|
198
|
-
get leaves(): TreeNode<T>[];
|
|
199
|
-
get root(): TreeNode<T>;
|
|
200
|
-
forEach(callback: (treeNode: TreeNode<T>) => void): this;
|
|
201
|
-
static build<T = unknown>(path: string, options?: TreeNodeOptions): TreeNode<T> | null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
declare const uniqueIdFactory: (counter: number) => (str?: string) => string;
|
|
205
|
-
|
|
206
|
-
type URLObject = {
|
|
207
|
-
url: string;
|
|
208
|
-
params?: Record<string, string>;
|
|
209
|
-
};
|
|
210
|
-
type ObjectOptions = {
|
|
211
|
-
type?: 'path' | 'template';
|
|
212
|
-
replacer?: (pathParam: string) => string;
|
|
213
|
-
stringify?: boolean;
|
|
214
|
-
};
|
|
215
|
-
declare class URLPath {
|
|
216
|
-
path: string;
|
|
217
|
-
constructor(path: string);
|
|
218
|
-
/**
|
|
219
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
220
|
-
* @example /pet/{petId} => /pet/:petId
|
|
221
|
-
*/
|
|
222
|
-
get URL(): string;
|
|
223
|
-
get isURL(): boolean;
|
|
224
|
-
/**
|
|
225
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
226
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
227
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
228
|
-
* @example /account/userID => `/account/${userId}`
|
|
229
|
-
*/
|
|
230
|
-
get template(): string;
|
|
231
|
-
get object(): URLObject | string;
|
|
232
|
-
get params(): Record<string, string> | undefined;
|
|
233
|
-
toObject({ type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
234
|
-
/**
|
|
235
|
-
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
236
|
-
* @example /pet/{petId} => `/pet/${petId}`
|
|
237
|
-
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
238
|
-
* @example /account/userID => `/account/${userId}`
|
|
239
|
-
*/
|
|
240
|
-
toTemplateString(replacer?: (pathParam: string) => string): string;
|
|
241
|
-
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Convert Swagger path to URLPath(syntax of Express)
|
|
244
|
-
* @example /pet/{petId} => /pet/:petId
|
|
245
|
-
*/
|
|
246
|
-
toURLPath(): string;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
170
|
/**
|
|
250
171
|
* Behaves as an Error to log a warning in the console(still stops the execution)
|
|
251
172
|
*/
|
|
@@ -254,70 +175,28 @@ declare class Warning extends Error {
|
|
|
254
175
|
cause: Error;
|
|
255
176
|
});
|
|
256
177
|
}
|
|
257
|
-
|
|
258
|
-
declare function write(data: string, path: string): Promise<void>;
|
|
259
|
-
|
|
260
|
-
declare class FileManager {
|
|
261
|
-
#private;
|
|
262
|
-
constructor(options?: {
|
|
263
|
-
queue?: Queue;
|
|
264
|
-
task?: QueueJob<KubbFile.ResolvedFile>;
|
|
265
|
-
});
|
|
266
|
-
get extensions(): Array<KubbFile.Extname>;
|
|
267
|
-
get files(): Array<KubbFile.File>;
|
|
268
|
-
get isExecuting(): boolean;
|
|
269
|
-
add(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
270
|
-
addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
|
|
271
|
-
addIndexes(root: KubbFile.Path, extName?: KubbFile.Extname, options?: TreeNodeOptions): Promise<Array<KubbFile.File> | undefined>;
|
|
272
|
-
getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
|
|
273
|
-
get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
|
|
274
|
-
remove(path: KubbFile.Path): void;
|
|
275
|
-
write(...params: Parameters<typeof write>): Promise<void>;
|
|
276
|
-
read(...params: Parameters<typeof read>): Promise<string>;
|
|
178
|
+
declare class ValidationPluginError extends Error {
|
|
277
179
|
}
|
|
278
180
|
|
|
279
|
-
declare
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
181
|
+
declare const LogLevel: {
|
|
182
|
+
readonly silent: "silent";
|
|
183
|
+
readonly info: "info";
|
|
184
|
+
readonly debug: "debug";
|
|
185
|
+
};
|
|
186
|
+
type LogLevel = keyof typeof LogLevel;
|
|
187
|
+
type Logger = {
|
|
188
|
+
/**
|
|
189
|
+
* Optional config name to show in CLI output
|
|
190
|
+
*/
|
|
191
|
+
name?: string;
|
|
192
|
+
logLevel: LogLevel;
|
|
193
|
+
log: (message: string | null) => void;
|
|
194
|
+
error: (message: string | null) => void;
|
|
195
|
+
info: (message: string | null) => void;
|
|
196
|
+
warn: (message: string | null) => void;
|
|
197
|
+
spinner?: Ora;
|
|
198
|
+
logs: string[];
|
|
293
199
|
};
|
|
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
|
-
}
|
|
321
200
|
|
|
322
201
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
323
202
|
/**
|
|
@@ -325,9 +204,9 @@ type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
|
325
204
|
* @example Arg0<(a: string, b: number) => void> -> string
|
|
326
205
|
*/
|
|
327
206
|
type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
|
|
328
|
-
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
|
207
|
+
type Strategy$1 = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
|
|
329
208
|
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
330
|
-
strategy: Strategy;
|
|
209
|
+
strategy: Strategy$1;
|
|
331
210
|
hookName: H;
|
|
332
211
|
plugin: KubbPlugin;
|
|
333
212
|
parameters?: unknown[] | undefined;
|
|
@@ -338,13 +217,16 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
338
217
|
result: Result;
|
|
339
218
|
plugin: KubbPlugin;
|
|
340
219
|
};
|
|
341
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<RequiredPluginLifecycle[H]>;
|
|
342
|
-
|
|
343
|
-
declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false, unknown, Record<string, unknown>>>];
|
|
344
220
|
type Options$1 = {
|
|
345
|
-
debug?: boolean;
|
|
346
|
-
task: QueueJob<KubbFile.ResolvedFile>;
|
|
347
221
|
logger: Logger;
|
|
222
|
+
/**
|
|
223
|
+
* Task for the FileManager
|
|
224
|
+
*/
|
|
225
|
+
task: QueueJob<KubbFile.ResolvedFile>;
|
|
226
|
+
/**
|
|
227
|
+
* Timeout between writes in the FileManager
|
|
228
|
+
*/
|
|
229
|
+
writeTimeout?: number;
|
|
348
230
|
};
|
|
349
231
|
type Events = {
|
|
350
232
|
execute: [executer: Executer];
|
|
@@ -366,16 +248,16 @@ declare class PluginManager {
|
|
|
366
248
|
/**
|
|
367
249
|
* Run only hook for a specific plugin name
|
|
368
250
|
*/
|
|
369
|
-
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
370
|
-
|
|
251
|
+
hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
|
|
252
|
+
pluginKey: KubbPlugin['key'];
|
|
371
253
|
hookName: H;
|
|
372
254
|
parameters: PluginParameter<H>;
|
|
373
|
-
}): Promise<ReturnType<ParseResult<H>> | null
|
|
374
|
-
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
375
|
-
|
|
255
|
+
}): Promise<Array<ReturnType<ParseResult<H>> | null>> | null;
|
|
256
|
+
hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
|
|
257
|
+
pluginKey: KubbPlugin['key'];
|
|
376
258
|
hookName: H;
|
|
377
259
|
parameters: PluginParameter<H>;
|
|
378
|
-
}): ReturnType<ParseResult<H
|
|
260
|
+
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
379
261
|
/**
|
|
380
262
|
* Chains, first non-null result stops and returns
|
|
381
263
|
*/
|
|
@@ -405,7 +287,7 @@ declare class PluginManager {
|
|
|
405
287
|
hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
|
|
406
288
|
hookName: H;
|
|
407
289
|
parameters: PluginParameter<H>;
|
|
408
|
-
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
|
|
290
|
+
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise$1<Argument0<H> | null>;
|
|
409
291
|
}): Promise<Argument0<H>>;
|
|
410
292
|
/**
|
|
411
293
|
* Chains plugins
|
|
@@ -414,32 +296,17 @@ declare class PluginManager {
|
|
|
414
296
|
hookName: H;
|
|
415
297
|
parameters?: PluginParameter<H>;
|
|
416
298
|
}): Promise<void>;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
declare class PluginError extends Error {
|
|
421
|
-
pluginManager: PluginManager;
|
|
422
|
-
cause: Error;
|
|
423
|
-
constructor(message: string, options: {
|
|
424
|
-
cause: Error;
|
|
425
|
-
pluginManager: PluginManager;
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
declare class ParallelPluginError extends Error {
|
|
430
|
-
errors: PluginError[];
|
|
431
|
-
pluginManager: PluginManager;
|
|
432
|
-
constructor(message: string, options: {
|
|
433
|
-
cause?: Error;
|
|
434
|
-
errors: PluginError[];
|
|
435
|
-
pluginManager: PluginManager;
|
|
436
|
-
});
|
|
437
|
-
findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
|
|
299
|
+
getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
|
|
300
|
+
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;
|
|
301
|
+
static get hooks(): readonly ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
|
|
438
302
|
}
|
|
439
303
|
|
|
440
|
-
|
|
304
|
+
interface Cache<TStore extends object = object> {
|
|
305
|
+
delete(id: keyof TStore): boolean;
|
|
306
|
+
get(id: keyof TStore): TStore[keyof TStore] | null;
|
|
307
|
+
has(id: keyof TStore): boolean;
|
|
308
|
+
set(id: keyof TStore, value: unknown): void;
|
|
441
309
|
}
|
|
442
|
-
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;
|
|
443
310
|
|
|
444
311
|
/**
|
|
445
312
|
* Config used in `kubb.config.js`
|
|
@@ -461,7 +328,7 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
|
|
|
461
328
|
* Example: ['@kubb/swagger', { output: false }]
|
|
462
329
|
* Or: createSwagger({ output: false })
|
|
463
330
|
*/
|
|
464
|
-
plugins?: Array<
|
|
331
|
+
plugins?: Array<Omit<KubbUserPlugin, 'api'> | KubbUnionPlugins | [name: string, options: object]>;
|
|
465
332
|
};
|
|
466
333
|
type InputPath = {
|
|
467
334
|
/**
|
|
@@ -479,14 +346,18 @@ type Input = InputPath | InputData;
|
|
|
479
346
|
/**
|
|
480
347
|
* @private
|
|
481
348
|
*/
|
|
482
|
-
type KubbConfig = {
|
|
349
|
+
type KubbConfig<TInput = Input> = {
|
|
350
|
+
/**
|
|
351
|
+
* Optional config name to show in CLI output
|
|
352
|
+
*/
|
|
353
|
+
name?: string;
|
|
483
354
|
/**
|
|
484
355
|
* Project root directory. Can be an absolute path, or a path relative from
|
|
485
356
|
* the location of the config file itself.
|
|
486
357
|
* @default process.cwd()
|
|
487
358
|
*/
|
|
488
359
|
root: string;
|
|
489
|
-
input:
|
|
360
|
+
input: TInput;
|
|
490
361
|
output: {
|
|
491
362
|
/**
|
|
492
363
|
* Path to be used to export all generated files.
|
|
@@ -547,40 +418,50 @@ type BuildOutput = {
|
|
|
547
418
|
pluginManager: PluginManager;
|
|
548
419
|
};
|
|
549
420
|
type KubbPluginKind = 'schema' | 'controller';
|
|
550
|
-
type
|
|
551
|
-
type KubbObjectPlugin = keyof
|
|
552
|
-
type
|
|
553
|
-
[K in keyof Kubb.OptionsPlugins]: Kubb.OptionsPlugins[K] | object;
|
|
554
|
-
};
|
|
421
|
+
type KubbUnionPlugins = PluginUnion;
|
|
422
|
+
type KubbObjectPlugin = keyof OptionsPlugins;
|
|
423
|
+
type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
|
|
555
424
|
type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
556
425
|
/**
|
|
557
426
|
* Unique name used for the plugin
|
|
558
427
|
* @example @kubb/typescript
|
|
559
428
|
*/
|
|
560
|
-
name:
|
|
429
|
+
name: TOptions['name'];
|
|
430
|
+
/**
|
|
431
|
+
* Internal key used when a developer uses more than one of the same plugin
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
key?: TOptions['key'];
|
|
561
435
|
/**
|
|
562
436
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
563
437
|
*/
|
|
564
438
|
options: TOptions['options'] extends never ? undefined : TOptions['options'];
|
|
439
|
+
} & Partial<PluginLifecycle<TOptions>> & (TOptions['api'] extends never ? {
|
|
440
|
+
api?: never;
|
|
441
|
+
} : {
|
|
442
|
+
api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
443
|
+
}) & (TOptions['kind'] extends never ? {
|
|
444
|
+
kind?: never;
|
|
445
|
+
} : {
|
|
565
446
|
/**
|
|
566
447
|
* Kind/type for the plugin
|
|
567
448
|
* Type 'schema' can be used for JSON schema's, TypeScript types, ...
|
|
568
449
|
* Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
|
|
569
450
|
* @default undefined
|
|
570
451
|
*/
|
|
571
|
-
kind
|
|
572
|
-
} & Partial<PluginLifecycle<TOptions>> & (TOptions['api'] extends never ? {
|
|
573
|
-
api?: never;
|
|
574
|
-
} : {
|
|
575
|
-
api: (this: Omit<PluginContext, 'addFile'>) => TOptions['api'];
|
|
452
|
+
kind: TOptions['kind'];
|
|
576
453
|
});
|
|
577
454
|
type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
578
455
|
/**
|
|
579
456
|
* Unique name used for the plugin
|
|
580
457
|
* @example @kubb/typescript
|
|
581
458
|
*/
|
|
582
|
-
name:
|
|
583
|
-
|
|
459
|
+
name: TOptions['name'];
|
|
460
|
+
/**
|
|
461
|
+
* Internal key used when a developer uses more than one of the same plugin
|
|
462
|
+
* @private
|
|
463
|
+
*/
|
|
464
|
+
key: TOptions['key'];
|
|
584
465
|
/**
|
|
585
466
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
586
467
|
*/
|
|
@@ -597,8 +478,13 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
597
478
|
} : {
|
|
598
479
|
api: TOptions['api'];
|
|
599
480
|
});
|
|
600
|
-
type PluginFactoryOptions<Name = string, Options = unknown | never, Nested extends boolean = false, API = unknown | never, resolvePathOptions = Record<string, unknown>> = {
|
|
481
|
+
type PluginFactoryOptions<Name = string, Kind extends KubbPluginKind = KubbPluginKind | never, Options = unknown | never, Nested extends boolean = false, API = unknown | never, resolvePathOptions = Record<string, unknown>> = {
|
|
601
482
|
name: Name;
|
|
483
|
+
kind: Kind;
|
|
484
|
+
/**
|
|
485
|
+
* Same like `QueryKey` in `@tanstack/react-query`
|
|
486
|
+
*/
|
|
487
|
+
key: [kind: Kind | undefined, name: Name, identifier?: string | number];
|
|
602
488
|
options: Options;
|
|
603
489
|
nested: Nested;
|
|
604
490
|
api: API;
|
|
@@ -609,12 +495,12 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
609
495
|
* Valdiate all plugins to see if their depended plugins are installed and configured.
|
|
610
496
|
* @type hookParallel
|
|
611
497
|
*/
|
|
612
|
-
validate?: (this: Omit<PluginContext, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
|
|
498
|
+
validate?: (this: Omit<PluginContext, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise$1<true>;
|
|
613
499
|
/**
|
|
614
500
|
* Start of the lifecycle of a plugin.
|
|
615
501
|
* @type hookParallel
|
|
616
502
|
*/
|
|
617
|
-
buildStart?: (this: PluginContext, kubbConfig: KubbConfig) => PossiblePromise<void>;
|
|
503
|
+
buildStart?: (this: PluginContext, kubbConfig: KubbConfig) => PossiblePromise$1<void>;
|
|
618
504
|
/**
|
|
619
505
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
620
506
|
* Options can als be included.
|
|
@@ -633,31 +519,28 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
633
519
|
* Makes it possible to run async logic to override the path defined previously by `resolvePath`.
|
|
634
520
|
* @type hookFirst
|
|
635
521
|
*/
|
|
636
|
-
load?: (this: Omit<PluginContext, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
|
|
522
|
+
load?: (this: Omit<PluginContext, 'addFile'>, path: KubbFile.Path) => PossiblePromise$1<TransformResult | null>;
|
|
637
523
|
/**
|
|
638
524
|
* Transform the source-code.
|
|
639
525
|
* @type hookReduceArg0
|
|
640
526
|
*/
|
|
641
|
-
transform?: (this: Omit<PluginContext, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
|
|
527
|
+
transform?: (this: Omit<PluginContext, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise$1<TransformResult>;
|
|
642
528
|
/**
|
|
643
529
|
* Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
|
|
644
530
|
* @type hookParallel
|
|
645
531
|
*/
|
|
646
|
-
writeFile?: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise<void>;
|
|
532
|
+
writeFile?: (this: Omit<PluginContext, 'addFile'>, source: string | undefined, path: KubbFile.Path) => PossiblePromise$1<string | void>;
|
|
647
533
|
/**
|
|
648
534
|
* End of the plugin lifecycle.
|
|
649
535
|
* @type hookParallel
|
|
650
536
|
*/
|
|
651
|
-
buildEnd?: (this: PluginContext) => PossiblePromise<void>;
|
|
537
|
+
buildEnd?: (this: PluginContext) => PossiblePromise$1<void>;
|
|
652
538
|
};
|
|
653
539
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
540
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
654
541
|
type PluginCache = Record<string, [number, unknown]>;
|
|
655
542
|
type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
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;
|
|
543
|
+
pluginKey?: KubbPlugin['key'];
|
|
661
544
|
baseName: string;
|
|
662
545
|
directory?: string | undefined;
|
|
663
546
|
/**
|
|
@@ -667,11 +550,7 @@ type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
|
667
550
|
};
|
|
668
551
|
type ResolveNameParams = {
|
|
669
552
|
name: string;
|
|
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;
|
|
553
|
+
pluginKey?: KubbPlugin['key'];
|
|
675
554
|
type?: 'file' | 'function';
|
|
676
555
|
};
|
|
677
556
|
type PluginContext<TOptions = Record<string, unknown>> = {
|
|
@@ -683,22 +562,51 @@ type PluginContext<TOptions = Record<string, unknown>> = {
|
|
|
683
562
|
resolvePath: (params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
|
|
684
563
|
resolveName: (params: ResolveNameParams) => string;
|
|
685
564
|
logger: Logger;
|
|
565
|
+
/**
|
|
566
|
+
* All plugins
|
|
567
|
+
*/
|
|
686
568
|
plugins: KubbPlugin[];
|
|
569
|
+
/**
|
|
570
|
+
* Current plugin
|
|
571
|
+
*/
|
|
572
|
+
plugin: KubbPlugin;
|
|
687
573
|
};
|
|
688
574
|
type TransformResult = string | null;
|
|
689
|
-
declare const LogLevel: {
|
|
690
|
-
readonly silent: "silent";
|
|
691
|
-
readonly info: "info";
|
|
692
|
-
readonly debug: "debug";
|
|
693
|
-
};
|
|
694
|
-
type LogLevel = keyof typeof LogLevel;
|
|
695
575
|
type AppMeta = {
|
|
696
576
|
pluginManager: PluginManager;
|
|
697
577
|
};
|
|
698
578
|
type Prettify<T> = {
|
|
699
579
|
[K in keyof T]: T[K];
|
|
700
580
|
} & {};
|
|
701
|
-
|
|
581
|
+
/**
|
|
582
|
+
* TODO move to @kubb/types
|
|
583
|
+
* @deprecated
|
|
584
|
+
*/
|
|
585
|
+
type PossiblePromise$1<T> = Promise<T> | T;
|
|
586
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
587
|
+
type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
588
|
+
type Push<T extends any[], V> = [...T, V];
|
|
589
|
+
type TuplifyUnion<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<TuplifyUnion<Exclude<T, L>>, L>;
|
|
590
|
+
/**
|
|
591
|
+
* TODO move to @kubb/types
|
|
592
|
+
* @deprecated
|
|
593
|
+
*/
|
|
594
|
+
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;
|
|
595
|
+
/**
|
|
596
|
+
* TODO move to @kubb/types
|
|
597
|
+
* @deprecated
|
|
598
|
+
*/
|
|
599
|
+
type TupleToUnion<T> = T extends Array<infer ITEMS> ? ITEMS : never;
|
|
600
|
+
/**
|
|
601
|
+
* TODO move to @kubb/types
|
|
602
|
+
* @deprecated
|
|
603
|
+
*/
|
|
604
|
+
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
605
|
+
/**
|
|
606
|
+
* TODO move to @kubb/types
|
|
607
|
+
* @deprecated
|
|
608
|
+
*/
|
|
609
|
+
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
702
610
|
|
|
703
611
|
type BuildOptions = {
|
|
704
612
|
config: PluginContext['config'];
|
|
@@ -706,7 +614,6 @@ type BuildOptions = {
|
|
|
706
614
|
* @default Logger without the spinner
|
|
707
615
|
*/
|
|
708
616
|
logger?: Logger;
|
|
709
|
-
logLevel?: LogLevel;
|
|
710
617
|
};
|
|
711
618
|
declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
712
619
|
|
|
@@ -715,9 +622,10 @@ declare function build(options: BuildOptions): Promise<BuildOutput>;
|
|
|
715
622
|
* accepts a direct {@link KubbConfig} object, or a function that returns it.
|
|
716
623
|
* The function receives a {@link ConfigEnv} object that exposes two properties:
|
|
717
624
|
*/
|
|
718
|
-
declare function defineConfig(options: PossiblePromise<KubbUserConfig
|
|
625
|
+
declare function defineConfig(options: PossiblePromise$1<KubbUserConfig | Array<KubbUserConfig>> | ((
|
|
719
626
|
/** The options derived from the CLI flags */
|
|
720
|
-
cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig
|
|
627
|
+
cliOptions: CLIOptions) => PossiblePromise$1<KubbUserConfig | Array<KubbUserConfig>>)): typeof options;
|
|
628
|
+
declare function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath>;
|
|
721
629
|
|
|
722
630
|
/**
|
|
723
631
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
@@ -732,6 +640,49 @@ declare abstract class Generator<TOptions = unknown, TContext = unknown> {
|
|
|
732
640
|
abstract build(...params: unknown[]): unknown;
|
|
733
641
|
}
|
|
734
642
|
|
|
643
|
+
type PackageJSON = {
|
|
644
|
+
dependencies?: Record<string, string>;
|
|
645
|
+
devDependencies?: Record<string, string>;
|
|
646
|
+
};
|
|
647
|
+
type DependencyName = string;
|
|
648
|
+
type DependencyVersion = string;
|
|
649
|
+
declare class PackageManager {
|
|
650
|
+
#private;
|
|
651
|
+
constructor(workspace?: string);
|
|
652
|
+
set workspace(workspace: string);
|
|
653
|
+
get workspace(): string | undefined;
|
|
654
|
+
normalizeDirectory(directory: string): string;
|
|
655
|
+
getLocation(path: string): string;
|
|
656
|
+
import(path: string): Promise<any | undefined>;
|
|
657
|
+
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
658
|
+
getPackageJSONSync(): PackageJSON | undefined;
|
|
659
|
+
static setVersion(dependency: DependencyName, version: DependencyVersion): void;
|
|
660
|
+
getVersion(dependency: DependencyName): Promise<DependencyVersion | undefined>;
|
|
661
|
+
getVersionSync(dependency: DependencyName): DependencyVersion | undefined;
|
|
662
|
+
isValid(dependency: DependencyName, version: DependencyVersion): Promise<boolean>;
|
|
663
|
+
isValidSync(dependency: DependencyName, version: DependencyVersion): boolean;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPlugin<T>;
|
|
667
|
+
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
|
|
668
|
+
declare const pluginName = "core";
|
|
669
|
+
|
|
670
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
671
|
+
type PromiseFunc<T, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
|
|
672
|
+
type SeqOutput<TInput extends Array<PromiseFunc<TPromise, null>>, TPromise = unknown> = ReturnType<NonNullable<TInput[number]>>;
|
|
673
|
+
type Options = {};
|
|
674
|
+
type Strategy = 'seq';
|
|
675
|
+
declare class PromiseManager {
|
|
676
|
+
#private;
|
|
677
|
+
constructor(options?: Options);
|
|
678
|
+
run<TInput extends Array<PromiseFunc<TPromise, null>>, TPromise = unknown, TOutput = SeqOutput<TInput, TPromise>>(strategy: Strategy, promises: TInput): TOutput;
|
|
679
|
+
}
|
|
680
|
+
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
681
|
+
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
682
|
+
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
683
|
+
reason: T;
|
|
684
|
+
};
|
|
685
|
+
|
|
735
686
|
/**
|
|
736
687
|
* Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
|
|
737
688
|
*/
|
|
@@ -739,19 +690,14 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
739
690
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
740
691
|
}
|
|
741
692
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
type
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
pluginManager: PluginManager;
|
|
748
|
-
resolvePath: PluginContext['resolvePath'];
|
|
749
|
-
resolveName: PluginContext['resolveName'];
|
|
750
|
-
logger: PluginContext['logger'];
|
|
751
|
-
getPlugins: () => KubbPlugin[];
|
|
752
|
-
plugin: KubbPlugin;
|
|
693
|
+
interface _Register {
|
|
694
|
+
}
|
|
695
|
+
type Plugins = _Register;
|
|
696
|
+
type OptionsPlugins = {
|
|
697
|
+
[K in keyof Plugins]: Plugins[K]['options'];
|
|
753
698
|
};
|
|
754
|
-
type
|
|
755
|
-
|
|
699
|
+
type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
|
|
700
|
+
type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
|
|
701
|
+
type Plugin = keyof Plugins;
|
|
756
702
|
|
|
757
|
-
export { AppMeta,
|
|
703
|
+
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$1 as PossiblePromise, Prettify, PromiseManager, ResolveNameParams, ResolvePathParams, SchemaGenerator, SummaryError, TransformResult, TupleToUnion, ValidationPluginError, Warning, _Register, build, createPlugin, build as default, defineConfig, isInputPath, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, pluginName };
|