@kubb/core 2.0.0-beta.1 → 2.0.0-beta.10

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.
Files changed (44) hide show
  1. package/dist/index.cjs +292 -240
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +61 -61
  4. package/dist/index.d.ts +61 -61
  5. package/dist/index.js +289 -236
  6. package/dist/index.js.map +1 -1
  7. package/dist/transformers.cjs +222 -0
  8. package/dist/transformers.cjs.map +1 -0
  9. package/dist/transformers.d.cts +55 -0
  10. package/dist/transformers.d.ts +55 -0
  11. package/dist/transformers.js +207 -0
  12. package/dist/transformers.js.map +1 -0
  13. package/dist/utils.cjs +302 -274
  14. package/dist/utils.cjs.map +1 -1
  15. package/dist/utils.d.cts +515 -67
  16. package/dist/utils.d.ts +515 -67
  17. package/dist/utils.js +303 -274
  18. package/dist/utils.js.map +1 -1
  19. package/package.json +14 -9
  20. package/src/BarrelManager.ts +55 -65
  21. package/src/FileManager.ts +93 -24
  22. package/src/PluginManager.ts +35 -17
  23. package/src/build.ts +1 -11
  24. package/src/index.ts +0 -1
  25. package/src/plugin.ts +4 -4
  26. package/src/transformers/casing.ts +9 -0
  27. package/src/transformers/createJSDocBlockText.ts +9 -0
  28. package/src/transformers/index.ts +36 -0
  29. package/src/transformers/trim.ts +7 -0
  30. package/src/types.ts +22 -41
  31. package/src/utils/FunctionParams.ts +3 -2
  32. package/src/utils/TreeNode.ts +6 -3
  33. package/src/utils/URLPath.ts +5 -5
  34. package/src/utils/index.ts +0 -1
  35. package/src/SchemaGenerator.ts +0 -8
  36. package/src/utils/transformers/createJSDocBlockText.ts +0 -15
  37. package/src/utils/transformers/index.ts +0 -22
  38. package/src/utils/transformers/trim.ts +0 -3
  39. /package/src/{utils/transformers → transformers}/combineCodes.ts +0 -0
  40. /package/src/{utils/transformers → transformers}/escape.ts +0 -0
  41. /package/src/{utils/transformers → transformers}/indent.ts +0 -0
  42. /package/src/{utils/transformers → transformers}/nameSorter.ts +0 -0
  43. /package/src/{utils/transformers → transformers}/searchAndReplace.ts +0 -0
  44. /package/src/{utils/transformers → transformers}/transformReservedWord.ts +0 -0
package/dist/index.d.cts CHANGED
@@ -9,10 +9,10 @@ declare function write(data: string, path: string): Promise<string | undefined>;
9
9
  type BarrelManagerOptions = {
10
10
  treeNode?: DirectoryTreeOptions;
11
11
  isTypeOnly?: boolean;
12
- filter?: (file: KubbFile.File) => boolean;
13
- map?: (file: KubbFile.File) => KubbFile.File;
14
- includeExt?: boolean;
15
- output?: string;
12
+ /**
13
+ * Add .ts or .js
14
+ */
15
+ extName?: KubbFile.Extname;
16
16
  };
17
17
 
18
18
  declare class EventEmitter<TEvents extends Record<string, any>> {
@@ -167,7 +167,7 @@ declare class PluginManager {
167
167
  }): Promise<void>;
168
168
  getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
169
169
  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;
170
- static get hooks(): readonly ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
170
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
171
171
  }
172
172
 
173
173
  interface Cache<TStore extends object = object> {
@@ -282,7 +282,6 @@ type CLIOptions = {
282
282
  */
283
283
  logLevel?: LogLevel;
284
284
  };
285
- type KubbPluginKind = 'schema' | 'controller';
286
285
  type KubbUnionPlugins = PluginUnion;
287
286
  type KubbObjectPlugin = keyof OptionsPlugins;
288
287
  type PluginFactoryOptions<
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
290
289
  * Name to be used for the plugin, this will also be used for they key.
291
290
  */
292
291
  TName extends string = string,
293
- /**
294
- * @type "schema" | "controller"
295
- */
296
- TKind extends KubbPluginKind = KubbPluginKind,
297
292
  /**
298
293
  * Options of the plugin.
299
294
  */
@@ -316,55 +311,47 @@ TResolvePathOptions extends object = object,
316
311
  */
317
312
  TAppMeta = unknown> = {
318
313
  name: TName;
319
- kind: TKind;
320
314
  /**
321
315
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
322
316
  */
323
- key: [kind: TKind | undefined, name: TName | string, identifier?: string | number];
317
+ key: [name: TName | string, identifier?: string | number];
324
318
  options: TOptions;
325
319
  resolvedOptions: TResolvedOptions;
326
320
  api: TAPI;
327
321
  resolvePathOptions: TResolvePathOptions;
328
322
  appMeta: {
329
323
  pluginManager: PluginManager;
330
- plugin: KubbPlugin<PluginFactoryOptions<TName, TKind, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
324
+ plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
331
325
  } & TAppMeta;
332
326
  };
333
327
  type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
334
328
  type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
335
329
  /**
336
330
  * Unique name used for the plugin
331
+ * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
337
332
  * @example @kubb/typescript
338
333
  */
339
334
  name: TOptions['name'];
340
- /**
341
- * Internal key used when a developer uses more than one of the same plugin
342
- * @private
343
- */
344
- key?: TOptions['key'];
345
335
  /**
346
336
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
347
337
  */
348
338
  options: TOptions['resolvedOptions'];
339
+ /**
340
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
341
+ * Can be used to validate depended plugins.
342
+ */
343
+ pre?: Array<string>;
344
+ /**
345
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
346
+ */
347
+ post?: Array<string>;
349
348
  } & (TOptions['api'] extends never ? {
350
349
  api?: never;
351
350
  } : {
352
351
  api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
353
- }) & (TOptions['kind'] extends never ? {
354
- kind?: never;
355
- } : {
356
- /**
357
- * Kind/type for the plugin
358
- *
359
- * Type 'schema' can be used for JSON schema's, TypeScript types, ...
360
- *
361
- * Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
362
- * @default undefined
363
- */
364
- kind: TOptions['kind'];
365
352
  });
366
353
  type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
367
- type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any, any>>;
354
+ type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
368
355
  type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
369
356
  /**
370
357
  * Unique name used for the plugin
@@ -377,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
377
364
  */
378
365
  key: TOptions['key'];
379
366
  /**
380
- * Options set for a specific plugin(see kubb.config.js), passthrough of options.
367
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
368
+ * Can be used to validate depended plugins.
381
369
  */
382
- options: TOptions['resolvedOptions'];
370
+ pre?: Array<string>;
371
+ /**
372
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
373
+ */
374
+ post?: Array<string>;
383
375
  /**
384
- * Kind/type for the plugin
385
- * Type 'schema' can be used for JSON schema's, TypeScript types, ...
386
- * Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
387
- * @default undefined
376
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
388
377
  */
389
- kind?: TOptions['kind'];
378
+ options: TOptions['resolvedOptions'];
390
379
  } & (TOptions['api'] extends never ? {
391
380
  api?: never;
392
381
  } : {
@@ -394,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
394
383
  });
395
384
  type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
396
385
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
397
- /**
398
- * Valdiate all plugins to see if their depended plugins are installed and configured.
399
- * @type hookParallel
400
- */
401
- validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
402
386
  /**
403
387
  * Start of the lifecycle of a plugin.
404
388
  * @type hookParallel
@@ -489,7 +473,10 @@ declare namespace KubbFile {
489
473
  * @example ["useState"]
490
474
  * @example "React"
491
475
  */
492
- name: string | Array<string>;
476
+ name: string | Array<string | {
477
+ propertyName: string;
478
+ name?: string;
479
+ }>;
493
480
  /**
494
481
  * Path for the import
495
482
  * @xample '@kubb/core'
@@ -499,6 +486,14 @@ declare namespace KubbFile {
499
486
  * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
500
487
  */
501
488
  isTypeOnly?: boolean;
489
+ /**
490
+ * Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
491
+ */
492
+ isNameSpace?: boolean;
493
+ /**
494
+ * When root is set it will get the path with relative getRelativePath(root, path).
495
+ */
496
+ root?: string;
502
497
  };
503
498
  type Export = {
504
499
  /**
@@ -551,8 +546,8 @@ declare namespace KubbFile {
551
546
  */
552
547
  id?: string;
553
548
  /**
554
- * Name to be used to dynamicly create the baseName(based on input.path)
555
- * Based on UNIX basename
549
+ * Name to be used to create the path
550
+ * Based on UNIX basename, `${name}.extName`
556
551
  * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
557
552
  */
558
553
  baseName: TBaseName;
@@ -577,22 +572,34 @@ declare namespace KubbFile {
577
572
  * This will override `process.env[key]` inside the `source`, see `getFileSource`.
578
573
  */
579
574
  env?: NodeJS.ProcessEnv;
580
- /**
581
- * @deprecated
582
- */
583
- validate?: boolean;
584
575
  };
585
576
  type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
586
577
  /**
587
578
  * @default crypto.randomUUID()
588
579
  */
589
580
  id: UUID;
581
+ /**
582
+ * Contains the first part of the baseName, generated based on baseName
583
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
584
+ */
585
+ name: string;
590
586
  };
591
587
  }
592
588
  type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
593
589
  type AddIndexesProps = {
594
- root: KubbFile.Path;
595
- extName?: KubbFile.Extname;
590
+ /**
591
+ * Root based on root and output.path specified in the config
592
+ */
593
+ root: string;
594
+ /**
595
+ * Output for plugin
596
+ */
597
+ output: {
598
+ path: string;
599
+ exportAs?: string;
600
+ extName?: KubbFile.Extname;
601
+ exportType?: 'barrel' | false;
602
+ };
596
603
  options?: BarrelManagerOptions;
597
604
  meta?: KubbFile.File['meta'];
598
605
  };
@@ -610,7 +617,7 @@ declare class FileManager {
610
617
  get files(): Array<KubbFile.File>;
611
618
  get isExecuting(): boolean;
612
619
  add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
613
- addIndexes({ root, extName, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
620
+ addIndexes({ root, output, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
614
621
  getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
615
622
  get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
616
623
  remove(path: KubbFile.Path): void;
@@ -722,13 +729,6 @@ declare class PromiseManager<TState = any> {
722
729
  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
723
730
  }
724
731
 
725
- /**
726
- * Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
727
- */
728
- declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
729
- abstract build(schema: TInput, name: string, description?: string): TOutput;
730
- }
731
-
732
732
  interface _Register {
733
733
  }
734
734
  type Plugins = _Register;
@@ -739,4 +739,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
739
739
  type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
740
740
  type Plugin = keyof Plugins;
741
741
 
742
- export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginKind, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, SchemaGenerator, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
742
+ export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
package/dist/index.d.ts CHANGED
@@ -9,10 +9,10 @@ declare function write(data: string, path: string): Promise<string | undefined>;
9
9
  type BarrelManagerOptions = {
10
10
  treeNode?: DirectoryTreeOptions;
11
11
  isTypeOnly?: boolean;
12
- filter?: (file: KubbFile.File) => boolean;
13
- map?: (file: KubbFile.File) => KubbFile.File;
14
- includeExt?: boolean;
15
- output?: string;
12
+ /**
13
+ * Add .ts or .js
14
+ */
15
+ extName?: KubbFile.Extname;
16
16
  };
17
17
 
18
18
  declare class EventEmitter<TEvents extends Record<string, any>> {
@@ -167,7 +167,7 @@ declare class PluginManager {
167
167
  }): Promise<void>;
168
168
  getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
169
169
  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;
170
- static get hooks(): readonly ["validate", "buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
170
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
171
171
  }
172
172
 
173
173
  interface Cache<TStore extends object = object> {
@@ -282,7 +282,6 @@ type CLIOptions = {
282
282
  */
283
283
  logLevel?: LogLevel;
284
284
  };
285
- type KubbPluginKind = 'schema' | 'controller';
286
285
  type KubbUnionPlugins = PluginUnion;
287
286
  type KubbObjectPlugin = keyof OptionsPlugins;
288
287
  type PluginFactoryOptions<
@@ -290,10 +289,6 @@ type PluginFactoryOptions<
290
289
  * Name to be used for the plugin, this will also be used for they key.
291
290
  */
292
291
  TName extends string = string,
293
- /**
294
- * @type "schema" | "controller"
295
- */
296
- TKind extends KubbPluginKind = KubbPluginKind,
297
292
  /**
298
293
  * Options of the plugin.
299
294
  */
@@ -316,55 +311,47 @@ TResolvePathOptions extends object = object,
316
311
  */
317
312
  TAppMeta = unknown> = {
318
313
  name: TName;
319
- kind: TKind;
320
314
  /**
321
315
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
322
316
  */
323
- key: [kind: TKind | undefined, name: TName | string, identifier?: string | number];
317
+ key: [name: TName | string, identifier?: string | number];
324
318
  options: TOptions;
325
319
  resolvedOptions: TResolvedOptions;
326
320
  api: TAPI;
327
321
  resolvePathOptions: TResolvePathOptions;
328
322
  appMeta: {
329
323
  pluginManager: PluginManager;
330
- plugin: KubbPlugin<PluginFactoryOptions<TName, TKind, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
324
+ plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
331
325
  } & TAppMeta;
332
326
  };
333
327
  type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
334
328
  type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
335
329
  /**
336
330
  * Unique name used for the plugin
331
+ * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
337
332
  * @example @kubb/typescript
338
333
  */
339
334
  name: TOptions['name'];
340
- /**
341
- * Internal key used when a developer uses more than one of the same plugin
342
- * @private
343
- */
344
- key?: TOptions['key'];
345
335
  /**
346
336
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
347
337
  */
348
338
  options: TOptions['resolvedOptions'];
339
+ /**
340
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
341
+ * Can be used to validate depended plugins.
342
+ */
343
+ pre?: Array<string>;
344
+ /**
345
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
346
+ */
347
+ post?: Array<string>;
349
348
  } & (TOptions['api'] extends never ? {
350
349
  api?: never;
351
350
  } : {
352
351
  api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
353
- }) & (TOptions['kind'] extends never ? {
354
- kind?: never;
355
- } : {
356
- /**
357
- * Kind/type for the plugin
358
- *
359
- * Type 'schema' can be used for JSON schema's, TypeScript types, ...
360
- *
361
- * Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
362
- * @default undefined
363
- */
364
- kind: TOptions['kind'];
365
352
  });
366
353
  type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
367
- type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any, any>>;
354
+ type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
368
355
  type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
369
356
  /**
370
357
  * Unique name used for the plugin
@@ -377,16 +364,18 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
377
364
  */
378
365
  key: TOptions['key'];
379
366
  /**
380
- * Options set for a specific plugin(see kubb.config.js), passthrough of options.
367
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
368
+ * Can be used to validate depended plugins.
381
369
  */
382
- options: TOptions['resolvedOptions'];
370
+ pre?: Array<string>;
371
+ /**
372
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
373
+ */
374
+ post?: Array<string>;
383
375
  /**
384
- * Kind/type for the plugin
385
- * Type 'schema' can be used for JSON schema's, TypeScript types, ...
386
- * Type 'controller' can be used to create generate API calls, React-Query hooks, Axios controllers, ...
387
- * @default undefined
376
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
388
377
  */
389
- kind?: TOptions['kind'];
378
+ options: TOptions['resolvedOptions'];
390
379
  } & (TOptions['api'] extends never ? {
391
380
  api?: never;
392
381
  } : {
@@ -394,11 +383,6 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
394
383
  });
395
384
  type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
396
385
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
397
- /**
398
- * Valdiate all plugins to see if their depended plugins are installed and configured.
399
- * @type hookParallel
400
- */
401
- validate?: (this: Omit<PluginContext<TOptions>, 'addFile'>, plugins: NonNullable<KubbConfig['plugins']>) => PossiblePromise<true>;
402
386
  /**
403
387
  * Start of the lifecycle of a plugin.
404
388
  * @type hookParallel
@@ -489,7 +473,10 @@ declare namespace KubbFile {
489
473
  * @example ["useState"]
490
474
  * @example "React"
491
475
  */
492
- name: string | Array<string>;
476
+ name: string | Array<string | {
477
+ propertyName: string;
478
+ name?: string;
479
+ }>;
493
480
  /**
494
481
  * Path for the import
495
482
  * @xample '@kubb/core'
@@ -499,6 +486,14 @@ declare namespace KubbFile {
499
486
  * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
500
487
  */
501
488
  isTypeOnly?: boolean;
489
+ /**
490
+ * Add `* as` prefix to the import, this will result in: `import * as path from './path'`.
491
+ */
492
+ isNameSpace?: boolean;
493
+ /**
494
+ * When root is set it will get the path with relative getRelativePath(root, path).
495
+ */
496
+ root?: string;
502
497
  };
503
498
  type Export = {
504
499
  /**
@@ -551,8 +546,8 @@ declare namespace KubbFile {
551
546
  */
552
547
  id?: string;
553
548
  /**
554
- * Name to be used to dynamicly create the baseName(based on input.path)
555
- * Based on UNIX basename
549
+ * Name to be used to create the path
550
+ * Based on UNIX basename, `${name}.extName`
556
551
  * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
557
552
  */
558
553
  baseName: TBaseName;
@@ -577,22 +572,34 @@ declare namespace KubbFile {
577
572
  * This will override `process.env[key]` inside the `source`, see `getFileSource`.
578
573
  */
579
574
  env?: NodeJS.ProcessEnv;
580
- /**
581
- * @deprecated
582
- */
583
- validate?: boolean;
584
575
  };
585
576
  type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = KubbFile.File<TMeta, TBaseName> & {
586
577
  /**
587
578
  * @default crypto.randomUUID()
588
579
  */
589
580
  id: UUID;
581
+ /**
582
+ * Contains the first part of the baseName, generated based on baseName
583
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
584
+ */
585
+ name: string;
590
586
  };
591
587
  }
592
588
  type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<KubbFile.ResolvedFile[]> : Promise<KubbFile.ResolvedFile>>>;
593
589
  type AddIndexesProps = {
594
- root: KubbFile.Path;
595
- extName?: KubbFile.Extname;
590
+ /**
591
+ * Root based on root and output.path specified in the config
592
+ */
593
+ root: string;
594
+ /**
595
+ * Output for plugin
596
+ */
597
+ output: {
598
+ path: string;
599
+ exportAs?: string;
600
+ extName?: KubbFile.Extname;
601
+ exportType?: 'barrel' | false;
602
+ };
596
603
  options?: BarrelManagerOptions;
597
604
  meta?: KubbFile.File['meta'];
598
605
  };
@@ -610,7 +617,7 @@ declare class FileManager {
610
617
  get files(): Array<KubbFile.File>;
611
618
  get isExecuting(): boolean;
612
619
  add<T extends Array<KubbFile.File> = Array<KubbFile.File>>(...files: T): AddResult<T>;
613
- addIndexes({ root, extName, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
620
+ addIndexes({ root, output, meta, options }: AddIndexesProps): Promise<Array<KubbFile.File> | undefined>;
614
621
  getCacheByUUID(UUID: KubbFile.UUID): KubbFile.File | undefined;
615
622
  get(path: KubbFile.Path): Array<KubbFile.File> | undefined;
616
623
  remove(path: KubbFile.Path): void;
@@ -722,13 +729,6 @@ declare class PromiseManager<TState = any> {
722
729
  run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput): TOutput;
723
730
  }
724
731
 
725
- /**
726
- * Abstract class that contains the building blocks for plugins to create their own SchemaGenerator
727
- */
728
- declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput> extends Generator<TOptions> {
729
- abstract build(schema: TInput, name: string, description?: string): TOutput;
730
- }
731
-
732
732
  interface _Register {
733
733
  }
734
734
  type Plugins = _Register;
@@ -739,4 +739,4 @@ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
739
739
  type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
740
740
  type Plugin = keyof Plugins;
741
741
 
742
- export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginKind, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, SchemaGenerator, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
742
+ export { type CLIOptions, FileManager, Generator, type GetPluginFactoryOptions, type InputData, type InputPath, type KubbConfig, KubbFile, type KubbObjectPlugin, type KubbPlugin, type KubbPluginWithLifeCycle, type KubbUnionPlugins, type KubbUserConfig, type KubbUserPlugin, type KubbUserPluginWithLifeCycle, type OptionsOfPlugin, type OptionsPlugins, PackageManager, type Plugin, type PluginCache, type PluginContext, type PluginFactoryOptions, type PluginLifecycle, type PluginLifecycleHooks, PluginManager, type PluginParameter, type PluginUnion, type Plugins, PromiseManager, type ResolveNameParams, type ResolvePathParams, type TransformResult, ValidationPluginError, Warning, type _Register, build, combineExports, combineImports, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };