@kubb/core 1.11.0-canary.20231011T124923 → 1.11.0-canary.20231011T130347
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 +5 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -36
- package/dist/index.d.ts +9 -36
- package/dist/index.js +5 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.d.cts
CHANGED
|
@@ -23,8 +23,8 @@ type PathMode = 'file' | 'directory';
|
|
|
23
23
|
declare function getPathMode(path: string | undefined | null): PathMode;
|
|
24
24
|
declare function read(path: string): Promise<string>;
|
|
25
25
|
|
|
26
|
-
type
|
|
27
|
-
name
|
|
26
|
+
type FunctionParamsAst = {
|
|
27
|
+
name: string;
|
|
28
28
|
type?: string;
|
|
29
29
|
/**
|
|
30
30
|
* @default true
|
|
@@ -35,24 +35,12 @@ type FunctionParamsAST = {
|
|
|
35
35
|
*/
|
|
36
36
|
enabled?: boolean;
|
|
37
37
|
default?: string;
|
|
38
|
-
} | {
|
|
39
|
-
name?: never;
|
|
40
|
-
type: string;
|
|
41
|
-
/**
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
required?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* @default true
|
|
47
|
-
*/
|
|
48
|
-
enabled?: boolean;
|
|
49
|
-
default?: string;
|
|
50
38
|
};
|
|
51
39
|
/**
|
|
52
40
|
* Convert an string array to a string of parameters that can be used inside a function
|
|
53
41
|
* The parameter name is converted to `camelcase`
|
|
54
42
|
*/
|
|
55
|
-
declare function createFunctionParams(
|
|
43
|
+
declare function createFunctionParams(data: FunctionParamsAst[]): string;
|
|
56
44
|
|
|
57
45
|
declare function nameSorter<T extends {
|
|
58
46
|
name: string;
|
|
@@ -83,7 +71,6 @@ declare class Queue {
|
|
|
83
71
|
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
84
72
|
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
85
73
|
get hasJobs(): boolean;
|
|
86
|
-
get count(): number;
|
|
87
74
|
private work;
|
|
88
75
|
}
|
|
89
76
|
|
|
@@ -305,15 +292,6 @@ declare class FileManager {
|
|
|
305
292
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
306
293
|
}
|
|
307
294
|
|
|
308
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
309
|
-
constructor();
|
|
310
|
-
private emitter;
|
|
311
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
312
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
313
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
314
|
-
removeAll(): void;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
295
|
declare class PluginError extends Error {
|
|
318
296
|
pluginManager: PluginManager;
|
|
319
297
|
cause: Error;
|
|
@@ -356,11 +334,11 @@ type Events = {
|
|
|
356
334
|
declare class PluginManager {
|
|
357
335
|
plugins: KubbPlugin[];
|
|
358
336
|
readonly fileManager: FileManager;
|
|
359
|
-
readonly eventEmitter: EventEmitter<Events>;
|
|
360
|
-
readonly queue: Queue;
|
|
361
|
-
readonly executed: Executer[];
|
|
362
|
-
readonly logger: Logger;
|
|
363
337
|
private readonly core;
|
|
338
|
+
queue: Queue;
|
|
339
|
+
executed: Executer[];
|
|
340
|
+
logger: Logger;
|
|
341
|
+
private eventEmitter;
|
|
364
342
|
constructor(config: KubbConfig, options: Options$1);
|
|
365
343
|
resolvePath: (params: ResolvePathParams) => OptionalPath;
|
|
366
344
|
resolveName: (params: ResolveNameParams) => string;
|
|
@@ -678,18 +656,17 @@ type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
|
678
656
|
options?: TOptions;
|
|
679
657
|
};
|
|
680
658
|
type ResolveNameParams = {
|
|
681
|
-
name: string;
|
|
682
659
|
/**
|
|
683
660
|
* When set, resolvePath will only call resolvePath of the name of the plugin set here.
|
|
684
661
|
* If not defined it will fall back on the resolvePath of the core plugin.
|
|
685
662
|
*/
|
|
686
663
|
pluginName?: string;
|
|
664
|
+
name: string;
|
|
687
665
|
};
|
|
688
666
|
type PluginContext<TOptions = Record<string, unknown>> = {
|
|
689
667
|
config: KubbConfig;
|
|
690
668
|
cache: Cache<PluginCache>;
|
|
691
669
|
fileManager: FileManager;
|
|
692
|
-
pluginManager: PluginManager;
|
|
693
670
|
addFile: (...file: File[]) => Promise<File[]>;
|
|
694
671
|
resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
695
672
|
resolveName: (params: ResolveNameParams) => string;
|
|
@@ -709,9 +686,6 @@ declare const LogLevel: {
|
|
|
709
686
|
readonly debug: "debug";
|
|
710
687
|
};
|
|
711
688
|
type LogLevel = keyof typeof LogLevel;
|
|
712
|
-
type AppMeta = {
|
|
713
|
-
pluginManager: PluginManager;
|
|
714
|
-
};
|
|
715
689
|
|
|
716
690
|
type BuildOptions = {
|
|
717
691
|
config: PluginContext['config'];
|
|
@@ -737,7 +711,6 @@ declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOpti
|
|
|
737
711
|
type Options = {
|
|
738
712
|
config: PluginContext['config'];
|
|
739
713
|
fileManager: FileManager;
|
|
740
|
-
pluginManager: PluginManager;
|
|
741
714
|
resolvePath: PluginContext['resolvePath'];
|
|
742
715
|
resolveName: PluginContext['resolveName'];
|
|
743
716
|
logger: PluginContext['logger'];
|
|
@@ -764,4 +737,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
764
737
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
765
738
|
}
|
|
766
739
|
|
|
767
|
-
export {
|
|
740
|
+
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, Executer, Export, Extension, File, FileManager, FileName, Generator, Import, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, clean, combineCodes, combineExports, combineFiles, combineImports, createFileSource, createFunctionParams, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, escape, extensions, getDependedPlugins, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, jsStringEscape, pluginName as name, nameSorter, normalizeDirectory, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ type PathMode = 'file' | 'directory';
|
|
|
23
23
|
declare function getPathMode(path: string | undefined | null): PathMode;
|
|
24
24
|
declare function read(path: string): Promise<string>;
|
|
25
25
|
|
|
26
|
-
type
|
|
27
|
-
name
|
|
26
|
+
type FunctionParamsAst = {
|
|
27
|
+
name: string;
|
|
28
28
|
type?: string;
|
|
29
29
|
/**
|
|
30
30
|
* @default true
|
|
@@ -35,24 +35,12 @@ type FunctionParamsAST = {
|
|
|
35
35
|
*/
|
|
36
36
|
enabled?: boolean;
|
|
37
37
|
default?: string;
|
|
38
|
-
} | {
|
|
39
|
-
name?: never;
|
|
40
|
-
type: string;
|
|
41
|
-
/**
|
|
42
|
-
* @default true
|
|
43
|
-
*/
|
|
44
|
-
required?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* @default true
|
|
47
|
-
*/
|
|
48
|
-
enabled?: boolean;
|
|
49
|
-
default?: string;
|
|
50
38
|
};
|
|
51
39
|
/**
|
|
52
40
|
* Convert an string array to a string of parameters that can be used inside a function
|
|
53
41
|
* The parameter name is converted to `camelcase`
|
|
54
42
|
*/
|
|
55
|
-
declare function createFunctionParams(
|
|
43
|
+
declare function createFunctionParams(data: FunctionParamsAst[]): string;
|
|
56
44
|
|
|
57
45
|
declare function nameSorter<T extends {
|
|
58
46
|
name: string;
|
|
@@ -83,7 +71,6 @@ declare class Queue {
|
|
|
83
71
|
run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
|
|
84
72
|
runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
|
|
85
73
|
get hasJobs(): boolean;
|
|
86
|
-
get count(): number;
|
|
87
74
|
private work;
|
|
88
75
|
}
|
|
89
76
|
|
|
@@ -305,15 +292,6 @@ declare class FileManager {
|
|
|
305
292
|
read(...params: Parameters<typeof read>): Promise<string>;
|
|
306
293
|
}
|
|
307
294
|
|
|
308
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
309
|
-
constructor();
|
|
310
|
-
private emitter;
|
|
311
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
312
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
313
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
314
|
-
removeAll(): void;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
295
|
declare class PluginError extends Error {
|
|
318
296
|
pluginManager: PluginManager;
|
|
319
297
|
cause: Error;
|
|
@@ -356,11 +334,11 @@ type Events = {
|
|
|
356
334
|
declare class PluginManager {
|
|
357
335
|
plugins: KubbPlugin[];
|
|
358
336
|
readonly fileManager: FileManager;
|
|
359
|
-
readonly eventEmitter: EventEmitter<Events>;
|
|
360
|
-
readonly queue: Queue;
|
|
361
|
-
readonly executed: Executer[];
|
|
362
|
-
readonly logger: Logger;
|
|
363
337
|
private readonly core;
|
|
338
|
+
queue: Queue;
|
|
339
|
+
executed: Executer[];
|
|
340
|
+
logger: Logger;
|
|
341
|
+
private eventEmitter;
|
|
364
342
|
constructor(config: KubbConfig, options: Options$1);
|
|
365
343
|
resolvePath: (params: ResolvePathParams) => OptionalPath;
|
|
366
344
|
resolveName: (params: ResolveNameParams) => string;
|
|
@@ -678,18 +656,17 @@ type ResolvePathParams<TOptions = Record<string, unknown>> = {
|
|
|
678
656
|
options?: TOptions;
|
|
679
657
|
};
|
|
680
658
|
type ResolveNameParams = {
|
|
681
|
-
name: string;
|
|
682
659
|
/**
|
|
683
660
|
* When set, resolvePath will only call resolvePath of the name of the plugin set here.
|
|
684
661
|
* If not defined it will fall back on the resolvePath of the core plugin.
|
|
685
662
|
*/
|
|
686
663
|
pluginName?: string;
|
|
664
|
+
name: string;
|
|
687
665
|
};
|
|
688
666
|
type PluginContext<TOptions = Record<string, unknown>> = {
|
|
689
667
|
config: KubbConfig;
|
|
690
668
|
cache: Cache<PluginCache>;
|
|
691
669
|
fileManager: FileManager;
|
|
692
|
-
pluginManager: PluginManager;
|
|
693
670
|
addFile: (...file: File[]) => Promise<File[]>;
|
|
694
671
|
resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath;
|
|
695
672
|
resolveName: (params: ResolveNameParams) => string;
|
|
@@ -709,9 +686,6 @@ declare const LogLevel: {
|
|
|
709
686
|
readonly debug: "debug";
|
|
710
687
|
};
|
|
711
688
|
type LogLevel = keyof typeof LogLevel;
|
|
712
|
-
type AppMeta = {
|
|
713
|
-
pluginManager: PluginManager;
|
|
714
|
-
};
|
|
715
689
|
|
|
716
690
|
type BuildOptions = {
|
|
717
691
|
config: PluginContext['config'];
|
|
@@ -737,7 +711,6 @@ declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOpti
|
|
|
737
711
|
type Options = {
|
|
738
712
|
config: PluginContext['config'];
|
|
739
713
|
fileManager: FileManager;
|
|
740
|
-
pluginManager: PluginManager;
|
|
741
714
|
resolvePath: PluginContext['resolvePath'];
|
|
742
715
|
resolveName: PluginContext['resolveName'];
|
|
743
716
|
logger: PluginContext['logger'];
|
|
@@ -764,4 +737,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
|
|
|
764
737
|
abstract build(schema: TInput, name: string, description?: string): TOutput;
|
|
765
738
|
}
|
|
766
739
|
|
|
767
|
-
export {
|
|
740
|
+
export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, Executer, Export, Extension, File, FileManager, FileName, Generator, Import, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogType, Logger, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueJob, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, clean, combineCodes, combineExports, combineFiles, combineImports, createFileSource, createFunctionParams, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, escape, extensions, getDependedPlugins, getIndexes, getLocation, getPathMode, getRelativePath, getUniqueName, hooks, importModule, isExtensionAllowed, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, jsStringEscape, pluginName as name, nameSorter, normalizeDirectory, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueIdFactory, write };
|
package/dist/index.js
CHANGED
|
@@ -128,13 +128,9 @@ var reader = switcher(
|
|
|
128
128
|
async function read(path) {
|
|
129
129
|
return reader(path);
|
|
130
130
|
}
|
|
131
|
-
function createFunctionParams(
|
|
132
|
-
const sortedData = orderBy(
|
|
131
|
+
function createFunctionParams(data) {
|
|
132
|
+
const sortedData = orderBy(data, [(v) => v.default, (v) => v.required ?? true], ["desc", "desc"]);
|
|
133
133
|
return sortedData.filter(({ enabled = true }) => enabled).reduce((acc, { name, type, required = true, ...rest }) => {
|
|
134
|
-
if (!name) {
|
|
135
|
-
acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
|
|
136
|
-
return acc;
|
|
137
|
-
}
|
|
138
134
|
const parameterName = camelCase(name, { delimiter: "", transform: camelCaseTransformMerge });
|
|
139
135
|
if (type) {
|
|
140
136
|
if (required) {
|
|
@@ -223,9 +219,6 @@ var Queue = class {
|
|
|
223
219
|
get hasJobs() {
|
|
224
220
|
return this.workerCount > 0 || this.queue.length > 0;
|
|
225
221
|
}
|
|
226
|
-
get count() {
|
|
227
|
-
return this.workerCount;
|
|
228
|
-
}
|
|
229
222
|
work() {
|
|
230
223
|
if (this.workerCount >= this.maxParallel) {
|
|
231
224
|
return;
|
|
@@ -1033,7 +1026,7 @@ function createPlugin(factory) {
|
|
|
1033
1026
|
}
|
|
1034
1027
|
var pluginName = "core";
|
|
1035
1028
|
var definePlugin = createPlugin((options) => {
|
|
1036
|
-
const { fileManager,
|
|
1029
|
+
const { fileManager, resolvePath, resolveName, logger } = options;
|
|
1037
1030
|
return {
|
|
1038
1031
|
name: pluginName,
|
|
1039
1032
|
options,
|
|
@@ -1047,7 +1040,6 @@ var definePlugin = createPlugin((options) => {
|
|
|
1047
1040
|
},
|
|
1048
1041
|
logger,
|
|
1049
1042
|
fileManager,
|
|
1050
|
-
pluginManager,
|
|
1051
1043
|
async addFile(...files) {
|
|
1052
1044
|
return Promise.all(
|
|
1053
1045
|
files.map((file) => {
|
|
@@ -1076,9 +1068,6 @@ var definePlugin = createPlugin((options) => {
|
|
|
1076
1068
|
};
|
|
1077
1069
|
});
|
|
1078
1070
|
var EventEmitter = class {
|
|
1079
|
-
constructor() {
|
|
1080
|
-
this.emitter.setMaxListeners(100);
|
|
1081
|
-
}
|
|
1082
1071
|
emitter = new EventEmitter$1();
|
|
1083
1072
|
emit(eventName, ...eventArg) {
|
|
1084
1073
|
this.emitter.emit(eventName, ...eventArg);
|
|
@@ -1089,9 +1078,6 @@ var EventEmitter = class {
|
|
|
1089
1078
|
off(eventName, handler) {
|
|
1090
1079
|
this.emitter.off(eventName, handler);
|
|
1091
1080
|
}
|
|
1092
|
-
removeAll() {
|
|
1093
|
-
this.emitter.removeAllListeners();
|
|
1094
|
-
}
|
|
1095
1081
|
};
|
|
1096
1082
|
|
|
1097
1083
|
// src/managers/pluginManager/ParallelPluginError.ts
|
|
@@ -1159,11 +1145,11 @@ var hooks = Object.keys(hookNames);
|
|
|
1159
1145
|
var PluginManager = class {
|
|
1160
1146
|
plugins;
|
|
1161
1147
|
fileManager;
|
|
1162
|
-
|
|
1148
|
+
core;
|
|
1163
1149
|
queue;
|
|
1164
1150
|
executed = [];
|
|
1165
1151
|
logger;
|
|
1166
|
-
|
|
1152
|
+
eventEmitter = new EventEmitter();
|
|
1167
1153
|
constructor(config, options) {
|
|
1168
1154
|
this.logger = options.logger;
|
|
1169
1155
|
this.queue = new Queue(100, options.debug);
|
|
@@ -1171,7 +1157,6 @@ var PluginManager = class {
|
|
|
1171
1157
|
const core = definePlugin({
|
|
1172
1158
|
config,
|
|
1173
1159
|
logger: this.logger,
|
|
1174
|
-
pluginManager: this,
|
|
1175
1160
|
fileManager: this.fileManager,
|
|
1176
1161
|
resolvePath: this.resolvePath.bind(this),
|
|
1177
1162
|
resolveName: this.resolveName.bind(this),
|