@kubb/core 1.2.3 → 1.3.0

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.d.ts CHANGED
@@ -34,8 +34,6 @@ type PathMode = 'file' | 'directory';
34
34
  declare function getPathMode(path: string | undefined | null): PathMode;
35
35
  declare function read(path: string): Promise<string>;
36
36
 
37
- declare function isURL(data: string): boolean;
38
-
39
37
  type Data = string[][];
40
38
  type Options$2 = {
41
39
  typed?: boolean;
@@ -58,20 +56,23 @@ declare function getUniqueName(originalName: string, data: Record<string, number
58
56
 
59
57
  declare function timeout(ms: number): Promise<unknown>;
60
58
 
61
- type QueueTask<T = unknown> = {
59
+ type QueueJob<T = unknown> = {
62
60
  (...args: unknown[]): Promise<T> | Promise<void>;
63
61
  };
64
62
  type RunOptions = {
65
- name: string;
66
- description: string;
63
+ controller?: AbortController;
64
+ name?: string;
65
+ description?: string;
67
66
  };
68
67
  declare class Queue {
69
- private readonly queue;
70
- workerCount: number;
68
+ private queue;
69
+ private workerCount;
71
70
  private maxParallel;
72
71
  private debug;
73
72
  constructor(maxParallel: number, debug?: boolean);
74
- run<T>(task: QueueTask<T>, options?: RunOptions): Promise<T>;
73
+ run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
74
+ runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
75
+ get hasJobs(): boolean;
75
76
  private work;
76
77
  }
77
78
 
@@ -146,6 +147,7 @@ declare class URLPath {
146
147
  * @example /pet/{petId} => /pet/:petId
147
148
  */
148
149
  get URL(): string;
150
+ get isUrl(): boolean;
149
151
  /**
150
152
  * Convert Swagger path to template literals/ template strings(camelcase)
151
153
  * @example /pet/{petId} => `/pet/${petId}`
@@ -173,6 +175,7 @@ declare class URLPath {
173
175
  */
174
176
  toURLPath(): string;
175
177
  static toURLPath(path: string): string;
178
+ static isURL(path: string): boolean;
176
179
  }
177
180
 
178
181
  type Import = {
@@ -219,9 +222,12 @@ type ResolvedFile = File & {
219
222
  */
220
223
  id: UUID;
221
224
  };
225
+ type CacheItem = ResolvedFile & {
226
+ cancel?: () => void;
227
+ };
222
228
  type Status = 'new' | 'success' | 'removed';
223
229
 
224
- declare function writeIndexes(root: string, options?: TreeNodeOptions): File[] | null;
230
+ declare function getIndexes(root: string, options?: TreeNodeOptions): File[] | null;
225
231
  declare function combineFiles(files: Array<File | null>): File[];
226
232
  type Extension = '.ts' | '.js';
227
233
  declare const extensions: Array<Extension>;
@@ -232,11 +238,12 @@ declare class FileManager {
232
238
  private task?;
233
239
  private queue?;
234
240
  constructor(options?: {
235
- queue: Queue;
236
- task?: QueueTask<ResolvedFile>;
241
+ queue?: Queue;
242
+ task?: QueueJob<ResolvedFile>;
237
243
  });
238
244
  get extensions(): Extension[];
239
245
  get files(): File[];
246
+ get isExecuting(): boolean;
240
247
  add(file: File): Promise<ResolvedFile>;
241
248
  addOrAppend(file: File): Promise<ResolvedFile>;
242
249
  private append;
@@ -247,6 +254,15 @@ declare class FileManager {
247
254
  read(...params: Parameters<typeof read>): Promise<string>;
248
255
  }
249
256
 
257
+ declare class PluginError extends Error {
258
+ pluginManager: PluginManager;
259
+ cause: Error;
260
+ constructor(message: string, options: {
261
+ cause: Error;
262
+ pluginManager: PluginManager;
263
+ });
264
+ }
265
+
250
266
  /**
251
267
  * Get the type of the first argument in a function.
252
268
  * @example Arg0<(a: string, b: number) => void> -> string
@@ -257,10 +273,9 @@ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
257
273
  strategy: Strategy;
258
274
  hookName: H;
259
275
  plugin: KubbPlugin;
260
- input?: unknown[] | undefined;
276
+ parameters?: unknown[] | undefined;
261
277
  output?: unknown;
262
278
  };
263
- type OnExecute<H extends PluginLifecycleHooks = PluginLifecycleHooks> = (this: PluginManager, executer: Executer<H> | undefined, pluginManager: PluginManager) => void;
264
279
  type ParseResult<H extends PluginLifecycleHooks> = PluginLifecycle[H];
265
280
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
266
281
  result: Result;
@@ -270,22 +285,26 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
270
285
  declare const hooks: [keyof PluginLifecycle<PluginFactoryOptions<string, unknown, false, any, Record<string, unknown>>>];
271
286
  type Options$1 = {
272
287
  debug?: boolean;
273
- task: QueueTask<ResolvedFile>;
288
+ task: QueueJob<ResolvedFile>;
274
289
  logger: Logger;
275
- onExecute?: OnExecute<PluginLifecycleHooks>;
290
+ };
291
+ type Events = {
292
+ execute: [executer: Executer];
293
+ executed: [executer: Executer];
294
+ error: [pluginError: PluginError];
276
295
  };
277
296
  declare class PluginManager {
278
297
  plugins: KubbPlugin[];
279
298
  readonly fileManager: FileManager;
280
- private readonly onExecute?;
281
299
  private readonly core;
282
300
  queue: Queue;
283
301
  executed: Executer[];
284
302
  logger: Logger;
303
+ private eventEmitter;
285
304
  constructor(config: KubbConfig, options: Options$1);
286
305
  resolvePath: (params: ResolvePathParams) => OptionalPath;
287
306
  resolveName: (params: ResolveNameParams) => string;
288
- load: (id: string) => Promise<SafeParseResult<'load'>>;
307
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
289
308
  /**
290
309
  *
291
310
  * Run only hook for a specific plugin name
@@ -367,15 +386,6 @@ declare class ValidationPluginError extends Error {
367
386
  }
368
387
  declare function validatePlugins(plugins: KubbPlugin[], dependedPluginNames: string | string[]): true;
369
388
 
370
- declare class PluginError extends Error {
371
- pluginManager: PluginManager;
372
- cause: Error;
373
- constructor(message: string, options: {
374
- cause: Error;
375
- pluginManager: PluginManager;
376
- });
377
- }
378
-
379
389
  declare class ParallelPluginError extends Error {
380
390
  errors: PluginError[];
381
391
  pluginManager: PluginManager;
@@ -384,7 +394,7 @@ declare class ParallelPluginError extends Error {
384
394
  errors: PluginError[];
385
395
  pluginManager: PluginManager;
386
396
  });
387
- findError<T extends Error = Error>(searchError: T): T | undefined;
397
+ findError<T extends Error = Error>(searchError: T | undefined): T | undefined;
388
398
  }
389
399
 
390
400
  interface Register {
@@ -629,7 +639,6 @@ type PluginContext<TOptions = Record<string, unknown>> = {
629
639
  addFile: (...file: File[]) => Promise<File[]>;
630
640
  resolvePath: (params: ResolvePathParams<TOptions>) => OptionalPath;
631
641
  resolveName: (params: ResolveNameParams) => string;
632
- load: (id: string) => Promise<SafeParseResult<'load'>>;
633
642
  logger: Logger;
634
643
  };
635
644
  type TransformResult = string | null;
@@ -672,7 +681,6 @@ type Options = {
672
681
  fileManager: FileManager;
673
682
  resolvePath: PluginContext['resolvePath'];
674
683
  resolveName: PluginContext['resolveName'];
675
- load: PluginContext['load'];
676
684
  logger: PluginContext['logger'];
677
685
  };
678
686
  type CorePluginOptions = PluginFactoryOptions<'core', Options, false, PluginContext>;
@@ -696,4 +704,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
696
704
  abstract build(schema: TInput, name: string, description?: string): TOutput;
697
705
  }
698
706
 
699
- export { Argument0, BuildOutput, CLIOptions, Cache, CorePluginOptions, Executer, Extension, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, LogType, Logger, OnExecute, OptionalPath, ParallelPluginError, ParseResult, Path, PathMode, PluginCache, PluginContext, PluginError, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PossiblePromise, Queue, QueueTask, Register, ResolveNameParams, ResolvePathParams, ResolvedFile, SafeParseResult, SchemaGenerator, Source, Status, Strategy, SummaryError, TransformResult, TreeNode, TreeNodeOptions, URLPath, UUID, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, isURL, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueId, validatePlugins, write, writeIndexes };
707
+ export { Argument0, BuildOutput, CLIOptions, Cache, CacheItem, CorePluginOptions, Executer, Extension, File, FileManager, FileName, Generator, KubbConfig, KubbJSONPlugins, KubbObjectPlugin, KubbObjectPlugins, KubbPlugin, KubbPluginKind, KubbUserConfig, KubbUserPlugin, LogLevel, LogLevels, 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, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, build as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueId, validatePlugins, write };
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import pc3 from 'picocolors';
12
12
  export { default as pc } from 'picocolors';
13
13
  import seedrandom from 'seedrandom';
14
14
  import { createImportDeclaration, print, createExportDeclaration } from '@kubb/ts-codegen';
15
+ import { EventEmitter as EventEmitter$1 } from 'node:events';
15
16
 
16
17
  createRequire(import.meta.url);
17
18
 
@@ -97,19 +98,6 @@ function getPathMode(path) {
97
98
  async function read(path) {
98
99
  return fs.readFile(path, { encoding: "utf8" });
99
100
  }
100
-
101
- // src/utils/isURL.ts
102
- function isURL(data) {
103
- try {
104
- const url = new URL(data);
105
- if (url?.href) {
106
- return true;
107
- }
108
- } catch (error) {
109
- return false;
110
- }
111
- return false;
112
- }
113
101
  function objectToParameters(data, options = {}) {
114
102
  const { typed } = options;
115
103
  return data.reduce((acc, [key, value]) => {
@@ -176,13 +164,30 @@ var Queue = class {
176
164
  this.maxParallel = maxParallel;
177
165
  this.debug = debug;
178
166
  }
179
- run(task, options = { name: crypto.randomUUID(), description: "" }) {
167
+ run(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
180
168
  return new Promise((resolve, reject) => {
181
- const item = { reject, resolve, task, name: options.name, description: options.description || options.name };
169
+ const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
170
+ options.controller?.signal.addEventListener("abort", () => {
171
+ this.queue = this.queue.filter((queueItem) => queueItem.name === item.name);
172
+ reject("Aborted");
173
+ });
182
174
  this.queue.push(item);
183
175
  this.work();
184
176
  });
185
177
  }
178
+ runSync(job, options = { controller: new AbortController(), name: crypto.randomUUID(), description: "" }) {
179
+ new Promise((resolve, reject) => {
180
+ const item = { reject, resolve, job, name: options.name, description: options.description || options.name };
181
+ options.controller?.signal.addEventListener("abort", () => {
182
+ this.queue = this.queue.filter((queueItem) => queueItem.name === item.name);
183
+ });
184
+ this.queue.push(item);
185
+ this.work();
186
+ });
187
+ }
188
+ get hasJobs() {
189
+ return this.workerCount > 0 || this.queue.length > 0;
190
+ }
186
191
  work() {
187
192
  if (this.workerCount >= this.maxParallel) {
188
193
  return;
@@ -190,11 +195,11 @@ var Queue = class {
190
195
  this.workerCount++;
191
196
  let entry;
192
197
  while (entry = this.queue.shift()) {
193
- const { reject, resolve, task, name, description } = entry;
198
+ const { reject, resolve, job, name, description } = entry;
194
199
  if (this.debug) {
195
200
  performance.mark(name + "_start");
196
201
  }
197
- task().then((result) => {
202
+ job().then((result) => {
198
203
  resolve(result);
199
204
  if (this.debug) {
200
205
  performance.mark(name + "_stop");
@@ -399,7 +404,7 @@ var reservedWords = [
399
404
  "valueOf"
400
405
  ];
401
406
  function transformReservedWord(word) {
402
- if (word && reservedWords.includes(word)) {
407
+ if (word && reservedWords.includes(word) || word?.match(/^\d/)) {
403
408
  return `_${word}`;
404
409
  }
405
410
  return word;
@@ -567,6 +572,9 @@ var URLPath = class {
567
572
  get URL() {
568
573
  return this.toURLPath();
569
574
  }
575
+ get isUrl() {
576
+ return URLPath.isURL(this.path);
577
+ }
570
578
  /**
571
579
  * Convert Swagger path to template literals/ template strings(camelcase)
572
580
  * @example /pet/{petId} => `/pet/${petId}`
@@ -613,8 +621,19 @@ var URLPath = class {
613
621
  static toURLPath(path) {
614
622
  return path.replaceAll("{", ":").replaceAll("}", "");
615
623
  }
624
+ static isURL(path) {
625
+ try {
626
+ const url = new URL(path);
627
+ if (url?.href) {
628
+ return true;
629
+ }
630
+ } catch (error) {
631
+ return false;
632
+ }
633
+ return false;
634
+ }
616
635
  };
617
- function writeIndexes(root, options = {}) {
636
+ function getIndexes(root, options = {}) {
618
637
  const tree = TreeNode.build(root, { extensions: /\.ts/, ...options });
619
638
  if (!tree) {
620
639
  return null;
@@ -800,13 +819,24 @@ var FileManager = class {
800
819
  });
801
820
  return files;
802
821
  }
822
+ get isExecuting() {
823
+ return this.queue?.hasJobs ?? false;
824
+ }
803
825
  async add(file) {
826
+ const controller = new AbortController();
804
827
  const resolvedFile = { id: crypto.randomUUID(), ...file };
805
- this.cache.set(resolvedFile.path, [resolvedFile]);
828
+ this.cache.set(resolvedFile.path, [{ cancel: () => controller.abort(), ...resolvedFile }]);
806
829
  if (this.queue) {
807
- await this.queue.run(async () => {
808
- await this.task?.(resolvedFile);
809
- });
830
+ try {
831
+ await this.queue.run(
832
+ async () => {
833
+ return this.task?.(resolvedFile);
834
+ },
835
+ { controller }
836
+ );
837
+ } catch {
838
+ return resolvedFile;
839
+ }
810
840
  }
811
841
  return resolvedFile;
812
842
  }
@@ -818,6 +848,7 @@ var FileManager = class {
818
848
  if (sourceAlreadyExists) {
819
849
  return Promise.resolve(previousCache);
820
850
  }
851
+ previousCache.cancel?.();
821
852
  this.cache.delete(previousCache.path);
822
853
  return this.add({
823
854
  ...file,
@@ -884,7 +915,7 @@ function createPlugin(factory) {
884
915
  }
885
916
  var pluginName = "core";
886
917
  var definePlugin = createPlugin((options) => {
887
- const { fileManager, resolvePath, resolveName, load, logger } = options;
918
+ const { fileManager, resolvePath, resolveName, logger } = options;
888
919
  return {
889
920
  name: pluginName,
890
921
  options,
@@ -928,7 +959,6 @@ var definePlugin = createPlugin((options) => {
928
959
  const name = resolveName(params);
929
960
  return transformReservedWord(name);
930
961
  },
931
- load,
932
962
  cache: createPluginCache()
933
963
  };
934
964
  },
@@ -953,6 +983,9 @@ var ParallelPluginError = class extends Error {
953
983
  this.pluginManager = options.pluginManager;
954
984
  }
955
985
  findError(searchError) {
986
+ if (!searchError) {
987
+ return void 0;
988
+ }
956
989
  return this.errors.find((error) => {
957
990
  if (error.cause) {
958
991
  if (error.cause.name == searchError.name) {
@@ -976,6 +1009,30 @@ var PluginError = class extends Error {
976
1009
  this.pluginManager = options.pluginManager;
977
1010
  }
978
1011
  };
1012
+ var EventEmitter = class {
1013
+ emitter = new EventEmitter$1();
1014
+ emit(eventName, ...eventArg) {
1015
+ this.emitter.emit(eventName, ...eventArg);
1016
+ }
1017
+ on(eventName, handler) {
1018
+ this.emitter.on(eventName, handler);
1019
+ }
1020
+ off(eventName, handler) {
1021
+ this.emitter.off(eventName, handler);
1022
+ }
1023
+ };
1024
+
1025
+ // src/managers/pluginManager/pluginParser.ts
1026
+ function pluginParser(plugin, context) {
1027
+ if (plugin.api && typeof plugin.api === "function") {
1028
+ const api = plugin.api.call(context);
1029
+ return {
1030
+ ...plugin,
1031
+ api
1032
+ };
1033
+ }
1034
+ return null;
1035
+ }
979
1036
 
980
1037
  // src/managers/pluginManager/PluginManager.ts
981
1038
  var hookNames = {
@@ -989,41 +1046,28 @@ var hookNames = {
989
1046
  buildEnd: 1
990
1047
  };
991
1048
  var hooks = Object.keys(hookNames);
992
- var convertKubbUserPluginToKubbPlugin = (plugin, context) => {
993
- if (plugin.api && typeof plugin.api === "function") {
994
- const api = plugin.api.call(context);
995
- return {
996
- ...plugin,
997
- api
998
- };
999
- }
1000
- return null;
1001
- };
1002
1049
  var PluginManager = class {
1003
1050
  plugins;
1004
1051
  fileManager;
1005
- onExecute;
1006
1052
  core;
1007
1053
  queue;
1008
1054
  executed = [];
1009
1055
  logger;
1056
+ eventEmitter = new EventEmitter();
1010
1057
  constructor(config, options) {
1011
- this.onExecute = options.onExecute?.bind(this);
1012
1058
  this.logger = options.logger;
1013
- this.queue = new Queue(100, options.debug);
1059
+ this.queue = new Queue(50, options.debug);
1014
1060
  this.fileManager = new FileManager({ task: options.task, queue: this.queue });
1015
1061
  const core = definePlugin({
1016
1062
  config,
1017
1063
  logger: this.logger,
1018
1064
  fileManager: this.fileManager,
1019
- load: this.load,
1020
1065
  resolvePath: this.resolvePath,
1021
1066
  resolveName: this.resolveName
1022
1067
  });
1023
- const convertedCore = convertKubbUserPluginToKubbPlugin(core, core.api.call(null));
1024
- this.core = convertedCore;
1068
+ this.core = pluginParser(core, core.api.call(null));
1025
1069
  this.plugins = [this.core, ...config.plugins || []].reduce((prev, plugin) => {
1026
- const convertedApi = convertKubbUserPluginToKubbPlugin(plugin, convertedCore?.api);
1070
+ const convertedApi = pluginParser(plugin, this.core?.api);
1027
1071
  if (convertedApi) {
1028
1072
  return [...prev, convertedApi];
1029
1073
  }
@@ -1056,12 +1100,9 @@ var PluginManager = class {
1056
1100
  parameters: [params.name]
1057
1101
  }).result;
1058
1102
  };
1059
- load = async (id) => {
1060
- return this.hookFirst({
1061
- hookName: "load",
1062
- parameters: [id]
1063
- });
1064
- };
1103
+ on(eventName, handler) {
1104
+ this.eventEmitter.on(eventName, handler);
1105
+ }
1065
1106
  /**
1066
1107
  *
1067
1108
  * Run only hook for a specific plugin name
@@ -1234,8 +1275,8 @@ var PluginManager = class {
1234
1275
  return pluginByPluginName;
1235
1276
  }
1236
1277
  addExecutedToCallStack(executer) {
1237
- this.onExecute?.call(this, executer, this);
1238
1278
  if (executer) {
1279
+ this.eventEmitter.emit("execute", executer);
1239
1280
  this.executed.push(executer);
1240
1281
  }
1241
1282
  }
@@ -1257,6 +1298,7 @@ var PluginManager = class {
1257
1298
  if (!hook) {
1258
1299
  return null;
1259
1300
  }
1301
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1260
1302
  const task = Promise.resolve().then(() => {
1261
1303
  if (typeof hook === "function") {
1262
1304
  const possiblePromiseResult = hook.apply(this.core.api, parameters);
@@ -1274,7 +1316,7 @@ var PluginManager = class {
1274
1316
  return null;
1275
1317
  }).finally(() => {
1276
1318
  this.addExecutedToCallStack({
1277
- input: parameters,
1319
+ parameters,
1278
1320
  output,
1279
1321
  strategy,
1280
1322
  hookName,
@@ -1301,6 +1343,7 @@ var PluginManager = class {
1301
1343
  if (!hook) {
1302
1344
  return null;
1303
1345
  }
1346
+ this.eventEmitter.emit("execute", { strategy, hookName, parameters, plugin });
1304
1347
  try {
1305
1348
  if (typeof hook === "function") {
1306
1349
  const fn = hook.apply(this.core.api, parameters);
@@ -1314,7 +1357,7 @@ var PluginManager = class {
1314
1357
  return null;
1315
1358
  } finally {
1316
1359
  this.addExecutedToCallStack({
1317
- input: parameters,
1360
+ parameters,
1318
1361
  output,
1319
1362
  strategy,
1320
1363
  hookName,
@@ -1325,7 +1368,9 @@ var PluginManager = class {
1325
1368
  catcher(e, plugin, hookName) {
1326
1369
  const text = `${e.message} (plugin: ${plugin.name}, hook: ${hookName})
1327
1370
  `;
1328
- throw new PluginError(text, { cause: e, pluginManager: this });
1371
+ const pluginError = new PluginError(text, { cause: e, pluginManager: this });
1372
+ this.eventEmitter.emit("error", pluginError);
1373
+ throw pluginError;
1329
1374
  }
1330
1375
  };
1331
1376
  function noReturn() {
@@ -1364,7 +1409,7 @@ async function transformReducer(_previousCode, result, _plugin) {
1364
1409
  async function build(options) {
1365
1410
  const { config, debug, logger = createLogger() } = options;
1366
1411
  try {
1367
- if (!isURL(config.input.path)) {
1412
+ if (!URLPath.isURL(config.input.path)) {
1368
1413
  await read(config.input.path);
1369
1414
  }
1370
1415
  } catch (e) {
@@ -1405,32 +1450,29 @@ async function build(options) {
1405
1450
  }
1406
1451
  }
1407
1452
  };
1408
- const onExecute = (executer) => {
1409
- if (!executer) {
1410
- return;
1411
- }
1412
- const { hookName, plugin, output, input } = executer;
1453
+ const pluginManager = new PluginManager(config, { debug, logger, task: queueTask });
1454
+ const { plugins, fileManager } = pluginManager;
1455
+ pluginManager.on("execute", (executer) => {
1456
+ const { hookName, plugin, output, parameters } = executer;
1413
1457
  const messsage = `${randomPicoColour(plugin.name)} Executing ${hookName}`;
1414
- if (config.logLevel === LogLevel.info && logger?.spinner && input) {
1458
+ if (config.logLevel === LogLevel.info && logger?.spinner && parameters) {
1415
1459
  if (debug) {
1416
1460
  logger.info(messsage);
1417
1461
  } else {
1418
1462
  logger.spinner.suffixText = messsage;
1419
1463
  }
1420
1464
  }
1421
- if (config.logLevel === LogLevel.stacktrace && logger?.spinner && input) {
1465
+ if (config.logLevel === LogLevel.stacktrace && logger?.spinner && parameters) {
1422
1466
  logger.info(messsage);
1423
1467
  const logs = [
1424
- input && `${pc3.bgWhite(`Input`)} ${randomPicoColour(plugin.name)} ${hookName}`,
1425
- JSON.stringify(input, void 0, 2),
1468
+ parameters && `${pc3.bgWhite(`Parameters`)} ${randomPicoColour(plugin.name)} ${hookName}`,
1469
+ JSON.stringify(parameters, void 0, 2),
1426
1470
  output && `${pc3.bgWhite("Output")} ${randomPicoColour(plugin.name)} ${hookName}`,
1427
1471
  output
1428
1472
  ].filter(Boolean);
1429
1473
  console.log(logs.join("\n"));
1430
1474
  }
1431
- };
1432
- const pluginManager = new PluginManager(config, { debug, logger, task: queueTask, onExecute });
1433
- const { plugins, fileManager } = pluginManager;
1475
+ });
1434
1476
  await pluginManager.hookParallel({
1435
1477
  hookName: "validate",
1436
1478
  parameters: [plugins]
@@ -1472,6 +1514,6 @@ var SchemaGenerator = class extends Generator {
1472
1514
  // src/index.ts
1473
1515
  var src_default = build;
1474
1516
 
1475
- export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, isURL, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueId, validatePlugins, write, writeIndexes };
1517
+ export { FileManager, Generator, LogLevel, ParallelPluginError, PluginError, PluginManager, Queue, SchemaGenerator, SummaryError, TreeNode, URLPath, ValidationPluginError, Warning, build, canLogHierarchy, clean, combineFiles, createJSDocBlockText, createLogger, createPlugin, createPluginCache, src_default as default, defaultColours, defineConfig, extensions, getEncodedText, getFileSource, getIndexes, getLocation, getPathMode, getRelativePath, getStackTrace, getUniqueName, hooks, importModule, isPromise, isPromiseFulfilledResult, isPromiseRejectedResult, pluginName as name, nameSorter, normalizeDirectory, objectToParameters, pluginName, randomColour, randomPicoColour, read, renderTemplate, throttle, timeout, transformReservedWord, uniqueId, validatePlugins, write };
1476
1518
  //# sourceMappingURL=out.js.map
1477
1519
  //# sourceMappingURL=index.js.map