@kubb/core 1.13.0 → 1.14.0-canary.20231020T164632

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.cts CHANGED
@@ -105,16 +105,12 @@ type RunOptions = {
105
105
  description?: string;
106
106
  };
107
107
  declare class Queue {
108
- private queue;
109
- private workerCount;
110
- private maxParallel;
111
- private debug;
108
+ #private;
112
109
  constructor(maxParallel: number, debug?: boolean);
113
110
  run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
114
111
  runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
115
112
  get hasJobs(): boolean;
116
113
  get count(): number;
117
- private work;
118
114
  }
119
115
 
120
116
  declare function escape(text?: string): string;
@@ -285,9 +281,7 @@ declare class FunctionParams {
285
281
  }
286
282
 
287
283
  declare class FileManager {
288
- private cache;
289
- private task?;
290
- private queue?;
284
+ #private;
291
285
  constructor(options?: {
292
286
  queue?: Queue;
293
287
  task?: QueueJob<KubbFile.ResolvedFile>;
@@ -297,7 +291,6 @@ declare class FileManager {
297
291
  get isExecuting(): boolean;
298
292
  add(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
299
293
  addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
300
- private append;
301
294
  getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
302
295
  get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
303
296
  remove(path: KubbFile.Path): void;
@@ -317,8 +310,8 @@ declare function combineImports(imports: Array<KubbFile.Import>, exports: Array<
317
310
  declare function createFileSource(file: KubbFile.File): string;
318
311
 
319
312
  declare class EventEmitter<TEvents extends Record<string, any>> {
313
+ #private;
320
314
  constructor();
321
- private emitter;
322
315
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
323
316
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
324
317
  off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
@@ -365,13 +358,13 @@ type Events = {
365
358
  error: [pluginError: PluginError];
366
359
  };
367
360
  declare class PluginManager {
361
+ #private;
368
362
  plugins: KubbPlugin[];
369
363
  readonly fileManager: FileManager;
370
364
  readonly eventEmitter: EventEmitter<Events>;
371
365
  readonly queue: Queue;
372
366
  readonly executed: Executer[];
373
367
  readonly logger: Logger;
374
- private readonly core;
375
368
  constructor(config: KubbConfig, options: Options$1);
376
369
  resolvePath: (params: ResolvePathParams) => KubbFile.OptionalPath;
377
370
  resolveName: (params: ResolveNameParams) => string;
@@ -432,25 +425,7 @@ declare class PluginManager {
432
425
  hookName: H;
433
426
  parameters?: Parameters<PluginLifecycle[H]>;
434
427
  }): Promise<void>;
435
- private getSortedPlugins;
436
428
  getPlugin(hookName: keyof PluginLifecycle, pluginName: string): KubbPlugin;
437
- private addExecutedToCallStack;
438
- /**
439
- * Run an async plugin hook and return the result.
440
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
441
- * @param args Arguments passed to the plugin hook.
442
- * @param plugin The actual pluginObject to run.
443
- */
444
- private execute;
445
- /**
446
- * Run a sync plugin hook and return the result.
447
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
448
- * @param args Arguments passed to the plugin hook.
449
- * @param plugin The acutal plugin
450
- * @param replaceContext When passed, the plugin context can be overridden.
451
- */
452
- private executeSync;
453
- private catcher;
454
429
  }
455
430
 
456
431
  declare class ValidationPluginError extends Error {
@@ -473,7 +448,7 @@ type PackageJSON = {
473
448
  devDependencies?: Record<string, string>;
474
449
  };
475
450
  declare class PackageManager {
476
- private cwd;
451
+ #private;
477
452
  constructor(workspace?: string);
478
453
  getPackageJSON(): Promise<PackageJSON | undefined>;
479
454
  getPackageJSONSync(): PackageJSON | undefined;
@@ -506,7 +481,7 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
506
481
  plugins?: Array<KubbPlugin> | Array<KubbJSONPlugins> | KubbObjectPlugins;
507
482
  };
508
483
  /**
509
- * Global/internal config used through out the full generation.
484
+ * @private
510
485
  */
511
486
  type KubbConfig = {
512
487
  /**
@@ -517,27 +492,28 @@ type KubbConfig = {
517
492
  root: string;
518
493
  input: {
519
494
  /**
520
- * Path to be used as the input. Can be an absolute path, or a path relative from
521
- * the defined root option.
495
+ * Path to be used as the input. This can be an absolute path or a path relative to the `root`.
522
496
  */
523
497
  path: string;
524
498
  } | {
525
499
  /**
526
- * String or object containing the data that you would normally import.
500
+ * `string` or `object` containing the data.
527
501
  */
528
502
  data: string | unknown;
529
503
  };
530
504
  output: {
531
505
  /**
532
- * Path to be used to export all generated files. Can be an absolute path, or a path relative based of the defined root option.
506
+ * Path to be used to export all generated files.
507
+ * This can be an absolute path, or a path relative based of the defined `root` option.
533
508
  */
534
509
  path: string;
535
510
  /**
536
- * Remove previous generated files and folders.
511
+ * Clean output directory before each build.
537
512
  */
538
513
  clean?: boolean;
539
514
  /**
540
- * Enabled or disable the writing to the filesystem. This is being used for the playground.
515
+ * Write files to the fileSystem
516
+ * This is being used for the playground.
541
517
  * @default true
542
518
  */
543
519
  write?: boolean;
@@ -553,8 +529,8 @@ type KubbConfig = {
553
529
  */
554
530
  hooks?: {
555
531
  /**
556
- * Hook that will be triggerend at the end of all executions.
557
- * Useful for running Prettier or ESLint to use your own linting structure.
532
+ * Hook that will be triggered at the end of all executions.
533
+ * Useful for running Prettier or ESLint to format/lint your code.
558
534
  */
559
535
  done?: string | Array<string>;
560
536
  };
@@ -774,10 +750,12 @@ declare const pluginName: CorePluginOptions['name'];
774
750
  * Abstract class that contains the building blocks for plugins to create their own Generator
775
751
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
776
752
  */
777
- declare abstract class Generator<TOptions extends object = object> {
778
- private _options;
779
- constructor(options?: TOptions);
753
+ declare abstract class Generator<TOptions = unknown, TContext = unknown> {
754
+ #private;
755
+ constructor(options?: TOptions, context?: TContext);
780
756
  get options(): TOptions;
757
+ get context(): TContext;
758
+ set options(options: TOptions);
781
759
  abstract build(...params: unknown[]): unknown;
782
760
  }
783
761
 
package/dist/index.d.ts CHANGED
@@ -105,16 +105,12 @@ type RunOptions = {
105
105
  description?: string;
106
106
  };
107
107
  declare class Queue {
108
- private queue;
109
- private workerCount;
110
- private maxParallel;
111
- private debug;
108
+ #private;
112
109
  constructor(maxParallel: number, debug?: boolean);
113
110
  run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
114
111
  runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
115
112
  get hasJobs(): boolean;
116
113
  get count(): number;
117
- private work;
118
114
  }
119
115
 
120
116
  declare function escape(text?: string): string;
@@ -285,9 +281,7 @@ declare class FunctionParams {
285
281
  }
286
282
 
287
283
  declare class FileManager {
288
- private cache;
289
- private task?;
290
- private queue?;
284
+ #private;
291
285
  constructor(options?: {
292
286
  queue?: Queue;
293
287
  task?: QueueJob<KubbFile.ResolvedFile>;
@@ -297,7 +291,6 @@ declare class FileManager {
297
291
  get isExecuting(): boolean;
298
292
  add(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
299
293
  addOrAppend(file: KubbFile.File): Promise<KubbFile.ResolvedFile>;
300
- private append;
301
294
  getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
302
295
  get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
303
296
  remove(path: KubbFile.Path): void;
@@ -317,8 +310,8 @@ declare function combineImports(imports: Array<KubbFile.Import>, exports: Array<
317
310
  declare function createFileSource(file: KubbFile.File): string;
318
311
 
319
312
  declare class EventEmitter<TEvents extends Record<string, any>> {
313
+ #private;
320
314
  constructor();
321
- private emitter;
322
315
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
323
316
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
324
317
  off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
@@ -365,13 +358,13 @@ type Events = {
365
358
  error: [pluginError: PluginError];
366
359
  };
367
360
  declare class PluginManager {
361
+ #private;
368
362
  plugins: KubbPlugin[];
369
363
  readonly fileManager: FileManager;
370
364
  readonly eventEmitter: EventEmitter<Events>;
371
365
  readonly queue: Queue;
372
366
  readonly executed: Executer[];
373
367
  readonly logger: Logger;
374
- private readonly core;
375
368
  constructor(config: KubbConfig, options: Options$1);
376
369
  resolvePath: (params: ResolvePathParams) => KubbFile.OptionalPath;
377
370
  resolveName: (params: ResolveNameParams) => string;
@@ -432,25 +425,7 @@ declare class PluginManager {
432
425
  hookName: H;
433
426
  parameters?: Parameters<PluginLifecycle[H]>;
434
427
  }): Promise<void>;
435
- private getSortedPlugins;
436
428
  getPlugin(hookName: keyof PluginLifecycle, pluginName: string): KubbPlugin;
437
- private addExecutedToCallStack;
438
- /**
439
- * Run an async plugin hook and return the result.
440
- * @param hookName Name of the plugin hook. Must be either in `PluginHooks` or `OutputPluginValueHooks`.
441
- * @param args Arguments passed to the plugin hook.
442
- * @param plugin The actual pluginObject to run.
443
- */
444
- private execute;
445
- /**
446
- * Run a sync plugin hook and return the result.
447
- * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
448
- * @param args Arguments passed to the plugin hook.
449
- * @param plugin The acutal plugin
450
- * @param replaceContext When passed, the plugin context can be overridden.
451
- */
452
- private executeSync;
453
- private catcher;
454
429
  }
455
430
 
456
431
  declare class ValidationPluginError extends Error {
@@ -473,7 +448,7 @@ type PackageJSON = {
473
448
  devDependencies?: Record<string, string>;
474
449
  };
475
450
  declare class PackageManager {
476
- private cwd;
451
+ #private;
477
452
  constructor(workspace?: string);
478
453
  getPackageJSON(): Promise<PackageJSON | undefined>;
479
454
  getPackageJSONSync(): PackageJSON | undefined;
@@ -506,7 +481,7 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
506
481
  plugins?: Array<KubbPlugin> | Array<KubbJSONPlugins> | KubbObjectPlugins;
507
482
  };
508
483
  /**
509
- * Global/internal config used through out the full generation.
484
+ * @private
510
485
  */
511
486
  type KubbConfig = {
512
487
  /**
@@ -517,27 +492,28 @@ type KubbConfig = {
517
492
  root: string;
518
493
  input: {
519
494
  /**
520
- * Path to be used as the input. Can be an absolute path, or a path relative from
521
- * the defined root option.
495
+ * Path to be used as the input. This can be an absolute path or a path relative to the `root`.
522
496
  */
523
497
  path: string;
524
498
  } | {
525
499
  /**
526
- * String or object containing the data that you would normally import.
500
+ * `string` or `object` containing the data.
527
501
  */
528
502
  data: string | unknown;
529
503
  };
530
504
  output: {
531
505
  /**
532
- * Path to be used to export all generated files. Can be an absolute path, or a path relative based of the defined root option.
506
+ * Path to be used to export all generated files.
507
+ * This can be an absolute path, or a path relative based of the defined `root` option.
533
508
  */
534
509
  path: string;
535
510
  /**
536
- * Remove previous generated files and folders.
511
+ * Clean output directory before each build.
537
512
  */
538
513
  clean?: boolean;
539
514
  /**
540
- * Enabled or disable the writing to the filesystem. This is being used for the playground.
515
+ * Write files to the fileSystem
516
+ * This is being used for the playground.
541
517
  * @default true
542
518
  */
543
519
  write?: boolean;
@@ -553,8 +529,8 @@ type KubbConfig = {
553
529
  */
554
530
  hooks?: {
555
531
  /**
556
- * Hook that will be triggerend at the end of all executions.
557
- * Useful for running Prettier or ESLint to use your own linting structure.
532
+ * Hook that will be triggered at the end of all executions.
533
+ * Useful for running Prettier or ESLint to format/lint your code.
558
534
  */
559
535
  done?: string | Array<string>;
560
536
  };
@@ -774,10 +750,12 @@ declare const pluginName: CorePluginOptions['name'];
774
750
  * Abstract class that contains the building blocks for plugins to create their own Generator
775
751
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
776
752
  */
777
- declare abstract class Generator<TOptions extends object = object> {
778
- private _options;
779
- constructor(options?: TOptions);
753
+ declare abstract class Generator<TOptions = unknown, TContext = unknown> {
754
+ #private;
755
+ constructor(options?: TOptions, context?: TContext);
780
756
  get options(): TOptions;
757
+ get context(): TContext;
758
+ set options(options: TOptions);
781
759
  abstract build(...params: unknown[]): unknown;
782
760
  }
783
761