@kubb/core 2.4.1 → 2.5.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.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import PQueue from 'p-queue';
2
2
  import { w as write, r as read } from './write-A6VgHkYA.cjs';
3
- import { PossiblePromise, GreaterThan, TupleToUnion, ObjValueTuple } from '@kubb/types';
3
+ import { TupleToUnion, ObjValueTuple, PossiblePromise, GreaterThan } from '@kubb/types';
4
4
  import { DirectoryTreeOptions } from 'directory-tree';
5
- import { Logger, LogLevel } from './logger.cjs';
5
+ import { E as EventEmitter, L as Logger, a as LogLevel } from './logger-wryz32Ex.cjs';
6
6
  import 'ora';
7
7
 
8
8
  type BarrelManagerOptions = {
@@ -14,13 +14,20 @@ type BarrelManagerOptions = {
14
14
  extName?: KubbFile.Extname;
15
15
  };
16
16
 
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;
17
+ type Plugins = _Register;
18
+ type OptionsPlugins = {
19
+ [K in keyof Plugins]: Plugins[K]['options'];
20
+ };
21
+ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
22
+ type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
23
+ type Plugin$1 = keyof Plugins;
24
+
25
+ type kubb_OptionsOfPlugin<K extends keyof Plugins> = OptionsOfPlugin<K>;
26
+ type kubb_OptionsPlugins = OptionsPlugins;
27
+ type kubb_PluginUnion = PluginUnion;
28
+ type kubb_Plugins = Plugins;
29
+ declare namespace kubb {
30
+ export type { kubb_OptionsOfPlugin as OptionsOfPlugin, kubb_OptionsPlugins as OptionsPlugins, Plugin$1 as Plugin, kubb_PluginUnion as PluginUnion, kubb_Plugins as Plugins };
24
31
  }
25
32
 
26
33
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
@@ -33,14 +40,14 @@ type Strategy$1 = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceAr
33
40
  type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
34
41
  strategy: Strategy$1;
35
42
  hookName: H;
36
- plugin: KubbPlugin;
43
+ plugin: Plugin;
37
44
  parameters?: unknown[] | undefined;
38
45
  output?: unknown;
39
46
  };
40
47
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
41
48
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
42
49
  result: Result;
43
- plugin: KubbPlugin;
50
+ plugin: Plugin;
44
51
  };
45
52
  type Options$2 = {
46
53
  logger: Logger;
@@ -56,14 +63,14 @@ type Events = {
56
63
  };
57
64
  declare class PluginManager {
58
65
  #private;
59
- readonly plugins: KubbPluginWithLifeCycle[];
66
+ readonly plugins: PluginWithLifeCycle[];
60
67
  readonly fileManager: FileManager;
61
68
  readonly events: EventEmitter<Events>;
62
- readonly config: KubbConfig;
69
+ readonly config: Config;
63
70
  readonly executed: Array<Executer>;
64
71
  readonly logger: Logger;
65
72
  readonly queue: PQueue;
66
- constructor(config: KubbConfig, options: Options$2);
73
+ constructor(config: Config, options: Options$2);
67
74
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
68
75
  resolveName: (params: ResolveNameParams) => string;
69
76
  /**
@@ -74,7 +81,7 @@ declare class PluginManager {
74
81
  * Run a specific hookName for plugin x.
75
82
  */
76
83
  hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
77
- pluginKey: KubbPlugin['key'];
84
+ pluginKey: Plugin['key'];
78
85
  hookName: H;
79
86
  parameters: PluginParameter<H>;
80
87
  }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null;
@@ -82,7 +89,7 @@ declare class PluginManager {
82
89
  * Run a specific hookName for plugin x.
83
90
  */
84
91
  hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
85
- pluginKey: KubbPlugin['key'];
92
+ pluginKey: Plugin['key'];
86
93
  hookName: H;
87
94
  parameters: PluginParameter<H>;
88
95
  }): Array<ReturnType<ParseResult<H>>> | null;
@@ -92,7 +99,7 @@ declare class PluginManager {
92
99
  hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
93
100
  hookName: H;
94
101
  parameters: PluginParameter<H>;
95
- skipped?: ReadonlySet<KubbPlugin> | null;
102
+ skipped?: ReadonlySet<Plugin> | null;
96
103
  }): Promise<SafeParseResult<H>>;
97
104
  /**
98
105
  * First non-null result stops and will return it's value.
@@ -100,7 +107,7 @@ declare class PluginManager {
100
107
  hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
101
108
  hookName: H;
102
109
  parameters: PluginParameter<H>;
103
- skipped?: ReadonlySet<KubbPlugin> | null;
110
+ skipped?: ReadonlySet<Plugin> | null;
104
111
  }): SafeParseResult<H>;
105
112
  /**
106
113
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
@@ -115,7 +122,7 @@ declare class PluginManager {
115
122
  hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
116
123
  hookName: H;
117
124
  parameters: PluginParameter<H>;
118
- reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
125
+ reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>;
119
126
  }): Promise<Argument0<H>>;
120
127
  /**
121
128
  * Chains plugins
@@ -124,8 +131,8 @@ declare class PluginManager {
124
131
  hookName: H;
125
132
  parameters?: PluginParameter<H>;
126
133
  }): Promise<void>;
127
- getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
128
- 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;
134
+ getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
135
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>] : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>]>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
129
136
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
130
137
  }
131
138
 
@@ -144,7 +151,7 @@ interface Cache<TStore extends object = object> {
144
151
  * ...
145
152
  * })
146
153
  */
147
- type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
154
+ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
148
155
  /**
149
156
  * Project root directory. Can be an absolute path, or a path relative from
150
157
  * the location of the config file itself.
@@ -152,11 +159,11 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
152
159
  */
153
160
  root?: string;
154
161
  /**
155
- * Plugin type can be KubbJSONPlugin or KubbPlugin
162
+ * Plugin type can be KubbJSONPlugin or Plugin
156
163
  * Example: ['@kubb/swagger', { output: false }]
157
164
  * Or: createSwagger({ output: false })
158
165
  */
159
- plugins?: Array<Omit<UnknownKubbUserPlugin, 'api'> | KubbUnionPlugins | [name: string, options: object]>;
166
+ plugins?: Array<Omit<UnknownUserPlugin, 'api'> | UnionPlugins | [name: string, options: object]>;
160
167
  };
161
168
  type InputPath = {
162
169
  /**
@@ -174,7 +181,7 @@ type Input = InputPath | InputData;
174
181
  /**
175
182
  * @private
176
183
  */
177
- type KubbConfig<TInput = Input> = {
184
+ type Config<TInput = Input> = {
178
185
  /**
179
186
  * Optional config name to show in CLI output
180
187
  */
@@ -208,7 +215,7 @@ type KubbConfig<TInput = Input> = {
208
215
  * The plugin/package can forsee some options that you need to pass through.
209
216
  * Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.
210
217
  */
211
- plugins?: Array<KubbPlugin>;
218
+ plugins?: Array<Plugin>;
212
219
  /**
213
220
  * Hooks that will be called when a specific action is triggered in Kubb.
214
221
  */
@@ -241,8 +248,7 @@ type CLIOptions = {
241
248
  */
242
249
  logLevel?: LogLevel;
243
250
  };
244
- type KubbUnionPlugins = PluginUnion;
245
- type KubbObjectPlugin = keyof OptionsPlugins;
251
+ type UnionPlugins = PluginUnion;
246
252
  type PluginFactoryOptions<
247
253
  /**
248
254
  * Name to be used for the plugin, this will also be used for they key.
@@ -280,11 +286,10 @@ TAppMeta = unknown> = {
280
286
  resolvePathOptions: TResolvePathOptions;
281
287
  appMeta: {
282
288
  pluginManager: PluginManager;
283
- plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
289
+ plugin: Plugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
284
290
  } & TAppMeta;
285
291
  };
286
- type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
287
- type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
292
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
288
293
  /**
289
294
  * Unique name used for the plugin
290
295
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
@@ -309,9 +314,9 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
309
314
  } : {
310
315
  api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
311
316
  });
312
- type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
313
- type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
314
- type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
317
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
318
+ type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
319
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
315
320
  /**
316
321
  * Unique name used for the plugin
317
322
  * @example @kubb/typescript
@@ -340,13 +345,13 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
340
345
  } : {
341
346
  api: TOptions['api'];
342
347
  });
343
- type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
348
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
344
349
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
345
350
  /**
346
351
  * Start of the lifecycle of a plugin.
347
352
  * @type hookParallel
348
353
  */
349
- buildStart?: (this: PluginContext<TOptions>, kubbConfig: KubbConfig) => PossiblePromise<void>;
354
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
350
355
  /**
351
356
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
352
357
  * Options can als be included.
@@ -386,7 +391,7 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
386
391
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
387
392
  type PluginCache = Record<string, [number, unknown]>;
388
393
  type ResolvePathParams<TOptions = object> = {
389
- pluginKey?: KubbPlugin['key'];
394
+ pluginKey?: Plugin['key'];
390
395
  baseName: string;
391
396
  directory?: string | undefined;
392
397
  /**
@@ -396,7 +401,7 @@ type ResolvePathParams<TOptions = object> = {
396
401
  };
397
402
  type ResolveNameParams = {
398
403
  name: string;
399
- pluginKey?: KubbPlugin['key'];
404
+ pluginKey?: Plugin['key'];
400
405
  /**
401
406
  * `file` will be used to customize the name of the created file(use of camelCase)
402
407
  * `function` can be used used to customize the exported functions(use of camelCase)
@@ -405,7 +410,7 @@ type ResolveNameParams = {
405
410
  type?: 'file' | 'function' | 'type';
406
411
  };
407
412
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
408
- config: KubbConfig;
413
+ config: Config;
409
414
  cache: Cache<PluginCache>;
410
415
  fileManager: FileManager;
411
416
  pluginManager: PluginManager;
@@ -416,11 +421,11 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
416
421
  /**
417
422
  * All plugins
418
423
  */
419
- plugins: KubbPlugin[];
424
+ plugins: Plugin[];
420
425
  /**
421
426
  * Current plugin
422
427
  */
423
- plugin: KubbPlugin<TOptions>;
428
+ plugin: Plugin<TOptions>;
424
429
  };
425
430
  type TransformResult = string | null;
426
431
 
@@ -496,7 +501,7 @@ declare namespace KubbFile {
496
501
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
497
502
  type OptionalPath = Path | undefined | null;
498
503
  type FileMetaBase = {
499
- pluginKey?: KubbPlugin['key'];
504
+ pluginKey?: Plugin['key'];
500
505
  };
501
506
  type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
502
507
  /**
@@ -605,13 +610,13 @@ declare function safeBuild(options: BuildOptions): Promise<BuildOutput>;
605
610
 
606
611
  /**
607
612
  * Type helper to make it easier to use kubb.config.js
608
- * accepts a direct {@link KubbConfig} object, or a function that returns it.
613
+ * accepts a direct {@link Config} object, or a function that returns it.
609
614
  * The function receives a {@link ConfigEnv} object that exposes two properties:
610
615
  */
611
- declare function defineConfig(options: PossiblePromise<KubbUserConfig | Array<KubbUserConfig>> | ((
616
+ declare function defineConfig(options: PossiblePromise<UserConfig | Array<UserConfig>> | ((
612
617
  /** The options derived from the CLI flags */
613
- cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>)): typeof options;
614
- declare function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath>;
618
+ cliOptions: CLIOptions) => PossiblePromise<UserConfig | Array<UserConfig>>)): typeof options;
619
+ declare function isInputPath(result: Config | undefined): result is Config<InputPath>;
615
620
 
616
621
  /**
617
622
  * Behaves as an Error to log a warning in the console(still stops the execution)
@@ -658,8 +663,8 @@ declare class PackageManager {
658
663
  isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
659
664
  }
660
665
 
661
- type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPluginWithLifeCycle<T>;
662
- declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
666
+ type PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
667
+ declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): (options: T['options']) => ReturnType<PluginFactory<T>>;
663
668
  declare const pluginName = "core";
664
669
 
665
670
  type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
@@ -682,12 +687,5 @@ declare class PromiseManager<TState = any> {
682
687
 
683
688
  interface _Register {
684
689
  }
685
- type Plugins = _Register;
686
- type OptionsPlugins = {
687
- [K in keyof Plugins]: Plugins[K]['options'];
688
- };
689
- type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
690
- type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
691
- type Plugin = keyof Plugins;
692
690
 
693
- 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, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
691
+ export { type CLIOptions, type Config, FileManager, Generator, kubb as Kubb, KubbFile, PackageManager, type Plugin, type PluginFactoryOptions, PluginManager, PromiseManager, type ResolveNameParams, type ResolvePathParams, type UserConfig, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import PQueue from 'p-queue';
2
2
  import { w as write, r as read } from './write-A6VgHkYA.js';
3
- import { PossiblePromise, GreaterThan, TupleToUnion, ObjValueTuple } from '@kubb/types';
3
+ import { TupleToUnion, ObjValueTuple, PossiblePromise, GreaterThan } from '@kubb/types';
4
4
  import { DirectoryTreeOptions } from 'directory-tree';
5
- import { Logger, LogLevel } from './logger.js';
5
+ import { E as EventEmitter, L as Logger, a as LogLevel } from './logger-wryz32Ex.js';
6
6
  import 'ora';
7
7
 
8
8
  type BarrelManagerOptions = {
@@ -14,13 +14,20 @@ type BarrelManagerOptions = {
14
14
  extName?: KubbFile.Extname;
15
15
  };
16
16
 
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;
17
+ type Plugins = _Register;
18
+ type OptionsPlugins = {
19
+ [K in keyof Plugins]: Plugins[K]['options'];
20
+ };
21
+ type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
22
+ type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
23
+ type Plugin$1 = keyof Plugins;
24
+
25
+ type kubb_OptionsOfPlugin<K extends keyof Plugins> = OptionsOfPlugin<K>;
26
+ type kubb_OptionsPlugins = OptionsPlugins;
27
+ type kubb_PluginUnion = PluginUnion;
28
+ type kubb_Plugins = Plugins;
29
+ declare namespace kubb {
30
+ export type { kubb_OptionsOfPlugin as OptionsOfPlugin, kubb_OptionsPlugins as OptionsPlugins, Plugin$1 as Plugin, kubb_PluginUnion as PluginUnion, kubb_Plugins as Plugins };
24
31
  }
25
32
 
26
33
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
@@ -33,14 +40,14 @@ type Strategy$1 = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceAr
33
40
  type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
34
41
  strategy: Strategy$1;
35
42
  hookName: H;
36
- plugin: KubbPlugin;
43
+ plugin: Plugin;
37
44
  parameters?: unknown[] | undefined;
38
45
  output?: unknown;
39
46
  };
40
47
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
41
48
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
42
49
  result: Result;
43
- plugin: KubbPlugin;
50
+ plugin: Plugin;
44
51
  };
45
52
  type Options$2 = {
46
53
  logger: Logger;
@@ -56,14 +63,14 @@ type Events = {
56
63
  };
57
64
  declare class PluginManager {
58
65
  #private;
59
- readonly plugins: KubbPluginWithLifeCycle[];
66
+ readonly plugins: PluginWithLifeCycle[];
60
67
  readonly fileManager: FileManager;
61
68
  readonly events: EventEmitter<Events>;
62
- readonly config: KubbConfig;
69
+ readonly config: Config;
63
70
  readonly executed: Array<Executer>;
64
71
  readonly logger: Logger;
65
72
  readonly queue: PQueue;
66
- constructor(config: KubbConfig, options: Options$2);
73
+ constructor(config: Config, options: Options$2);
67
74
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
68
75
  resolveName: (params: ResolveNameParams) => string;
69
76
  /**
@@ -74,7 +81,7 @@ declare class PluginManager {
74
81
  * Run a specific hookName for plugin x.
75
82
  */
76
83
  hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
77
- pluginKey: KubbPlugin['key'];
84
+ pluginKey: Plugin['key'];
78
85
  hookName: H;
79
86
  parameters: PluginParameter<H>;
80
87
  }): Promise<Array<ReturnType<ParseResult<H>> | null>> | null;
@@ -82,7 +89,7 @@ declare class PluginManager {
82
89
  * Run a specific hookName for plugin x.
83
90
  */
84
91
  hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
85
- pluginKey: KubbPlugin['key'];
92
+ pluginKey: Plugin['key'];
86
93
  hookName: H;
87
94
  parameters: PluginParameter<H>;
88
95
  }): Array<ReturnType<ParseResult<H>>> | null;
@@ -92,7 +99,7 @@ declare class PluginManager {
92
99
  hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
93
100
  hookName: H;
94
101
  parameters: PluginParameter<H>;
95
- skipped?: ReadonlySet<KubbPlugin> | null;
102
+ skipped?: ReadonlySet<Plugin> | null;
96
103
  }): Promise<SafeParseResult<H>>;
97
104
  /**
98
105
  * First non-null result stops and will return it's value.
@@ -100,7 +107,7 @@ declare class PluginManager {
100
107
  hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
101
108
  hookName: H;
102
109
  parameters: PluginParameter<H>;
103
- skipped?: ReadonlySet<KubbPlugin> | null;
110
+ skipped?: ReadonlySet<Plugin> | null;
104
111
  }): SafeParseResult<H>;
105
112
  /**
106
113
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
@@ -115,7 +122,7 @@ declare class PluginManager {
115
122
  hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
116
123
  hookName: H;
117
124
  parameters: PluginParameter<H>;
118
- reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: KubbPlugin) => PossiblePromise<Argument0<H> | null>;
125
+ reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>;
119
126
  }): Promise<Argument0<H>>;
120
127
  /**
121
128
  * Chains plugins
@@ -124,8 +131,8 @@ declare class PluginManager {
124
131
  hookName: H;
125
132
  parameters?: PluginParameter<H>;
126
133
  }): Promise<void>;
127
- getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: KubbPlugin['key']): KubbPlugin[];
128
- 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;
134
+ getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
135
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = T3 extends never ? T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>] : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>]>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
129
136
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
130
137
  }
131
138
 
@@ -144,7 +151,7 @@ interface Cache<TStore extends object = object> {
144
151
  * ...
145
152
  * })
146
153
  */
147
- type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
154
+ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
148
155
  /**
149
156
  * Project root directory. Can be an absolute path, or a path relative from
150
157
  * the location of the config file itself.
@@ -152,11 +159,11 @@ type KubbUserConfig = Omit<KubbConfig, 'root' | 'plugins'> & {
152
159
  */
153
160
  root?: string;
154
161
  /**
155
- * Plugin type can be KubbJSONPlugin or KubbPlugin
162
+ * Plugin type can be KubbJSONPlugin or Plugin
156
163
  * Example: ['@kubb/swagger', { output: false }]
157
164
  * Or: createSwagger({ output: false })
158
165
  */
159
- plugins?: Array<Omit<UnknownKubbUserPlugin, 'api'> | KubbUnionPlugins | [name: string, options: object]>;
166
+ plugins?: Array<Omit<UnknownUserPlugin, 'api'> | UnionPlugins | [name: string, options: object]>;
160
167
  };
161
168
  type InputPath = {
162
169
  /**
@@ -174,7 +181,7 @@ type Input = InputPath | InputData;
174
181
  /**
175
182
  * @private
176
183
  */
177
- type KubbConfig<TInput = Input> = {
184
+ type Config<TInput = Input> = {
178
185
  /**
179
186
  * Optional config name to show in CLI output
180
187
  */
@@ -208,7 +215,7 @@ type KubbConfig<TInput = Input> = {
208
215
  * The plugin/package can forsee some options that you need to pass through.
209
216
  * Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.
210
217
  */
211
- plugins?: Array<KubbPlugin>;
218
+ plugins?: Array<Plugin>;
212
219
  /**
213
220
  * Hooks that will be called when a specific action is triggered in Kubb.
214
221
  */
@@ -241,8 +248,7 @@ type CLIOptions = {
241
248
  */
242
249
  logLevel?: LogLevel;
243
250
  };
244
- type KubbUnionPlugins = PluginUnion;
245
- type KubbObjectPlugin = keyof OptionsPlugins;
251
+ type UnionPlugins = PluginUnion;
246
252
  type PluginFactoryOptions<
247
253
  /**
248
254
  * Name to be used for the plugin, this will also be used for they key.
@@ -280,11 +286,10 @@ TAppMeta = unknown> = {
280
286
  resolvePathOptions: TResolvePathOptions;
281
287
  appMeta: {
282
288
  pluginManager: PluginManager;
283
- plugin: KubbPlugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
289
+ plugin: Plugin<PluginFactoryOptions<TName, TOptions, TResolvedOptions, TAPI, TResolvePathOptions, TAppMeta>>;
284
290
  } & TAppMeta;
285
291
  };
286
- type GetPluginFactoryOptions<TPlugin extends KubbUserPlugin> = TPlugin extends KubbUserPlugin<infer X> ? X : never;
287
- type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
292
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
288
293
  /**
289
294
  * Unique name used for the plugin
290
295
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
@@ -309,9 +314,9 @@ type KubbUserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions
309
314
  } : {
310
315
  api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
311
316
  });
312
- type KubbUserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbUserPlugin<TOptions> & PluginLifecycle<TOptions>;
313
- type UnknownKubbUserPlugin = KubbUserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
314
- type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
317
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
318
+ type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any, any>>;
319
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
315
320
  /**
316
321
  * Unique name used for the plugin
317
322
  * @example @kubb/typescript
@@ -340,13 +345,13 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
340
345
  } : {
341
346
  api: TOptions['api'];
342
347
  });
343
- type KubbPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = KubbPlugin<TOptions> & PluginLifecycle<TOptions>;
348
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
344
349
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
345
350
  /**
346
351
  * Start of the lifecycle of a plugin.
347
352
  * @type hookParallel
348
353
  */
349
- buildStart?: (this: PluginContext<TOptions>, kubbConfig: KubbConfig) => PossiblePromise<void>;
354
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
350
355
  /**
351
356
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
352
357
  * Options can als be included.
@@ -386,7 +391,7 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
386
391
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
387
392
  type PluginCache = Record<string, [number, unknown]>;
388
393
  type ResolvePathParams<TOptions = object> = {
389
- pluginKey?: KubbPlugin['key'];
394
+ pluginKey?: Plugin['key'];
390
395
  baseName: string;
391
396
  directory?: string | undefined;
392
397
  /**
@@ -396,7 +401,7 @@ type ResolvePathParams<TOptions = object> = {
396
401
  };
397
402
  type ResolveNameParams = {
398
403
  name: string;
399
- pluginKey?: KubbPlugin['key'];
404
+ pluginKey?: Plugin['key'];
400
405
  /**
401
406
  * `file` will be used to customize the name of the created file(use of camelCase)
402
407
  * `function` can be used used to customize the exported functions(use of camelCase)
@@ -405,7 +410,7 @@ type ResolveNameParams = {
405
410
  type?: 'file' | 'function' | 'type';
406
411
  };
407
412
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
408
- config: KubbConfig;
413
+ config: Config;
409
414
  cache: Cache<PluginCache>;
410
415
  fileManager: FileManager;
411
416
  pluginManager: PluginManager;
@@ -416,11 +421,11 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
416
421
  /**
417
422
  * All plugins
418
423
  */
419
- plugins: KubbPlugin[];
424
+ plugins: Plugin[];
420
425
  /**
421
426
  * Current plugin
422
427
  */
423
- plugin: KubbPlugin<TOptions>;
428
+ plugin: Plugin<TOptions>;
424
429
  };
425
430
  type TransformResult = string | null;
426
431
 
@@ -496,7 +501,7 @@ declare namespace KubbFile {
496
501
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
497
502
  type OptionalPath = Path | undefined | null;
498
503
  type FileMetaBase = {
499
- pluginKey?: KubbPlugin['key'];
504
+ pluginKey?: Plugin['key'];
500
505
  };
501
506
  type File<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = {
502
507
  /**
@@ -605,13 +610,13 @@ declare function safeBuild(options: BuildOptions): Promise<BuildOutput>;
605
610
 
606
611
  /**
607
612
  * Type helper to make it easier to use kubb.config.js
608
- * accepts a direct {@link KubbConfig} object, or a function that returns it.
613
+ * accepts a direct {@link Config} object, or a function that returns it.
609
614
  * The function receives a {@link ConfigEnv} object that exposes two properties:
610
615
  */
611
- declare function defineConfig(options: PossiblePromise<KubbUserConfig | Array<KubbUserConfig>> | ((
616
+ declare function defineConfig(options: PossiblePromise<UserConfig | Array<UserConfig>> | ((
612
617
  /** The options derived from the CLI flags */
613
- cliOptions: CLIOptions) => PossiblePromise<KubbUserConfig | Array<KubbUserConfig>>)): typeof options;
614
- declare function isInputPath(result: KubbConfig | undefined): result is KubbConfig<InputPath>;
618
+ cliOptions: CLIOptions) => PossiblePromise<UserConfig | Array<UserConfig>>)): typeof options;
619
+ declare function isInputPath(result: Config | undefined): result is Config<InputPath>;
615
620
 
616
621
  /**
617
622
  * Behaves as an Error to log a warning in the console(still stops the execution)
@@ -658,8 +663,8 @@ declare class PackageManager {
658
663
  isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
659
664
  }
660
665
 
661
- type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => KubbUserPluginWithLifeCycle<T>;
662
- declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => ReturnType<KubbPluginFactory<T>>;
666
+ type PluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
667
+ declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: PluginFactory<T>): (options: T['options']) => ReturnType<PluginFactory<T>>;
663
668
  declare const pluginName = "core";
664
669
 
665
670
  type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
@@ -682,12 +687,5 @@ declare class PromiseManager<TState = any> {
682
687
 
683
688
  interface _Register {
684
689
  }
685
- type Plugins = _Register;
686
- type OptionsPlugins = {
687
- [K in keyof Plugins]: Plugins[K]['options'];
688
- };
689
- type OptionsOfPlugin<K extends keyof Plugins> = Plugins[K]['options'];
690
- type PluginUnion = TupleToUnion<ObjValueTuple<OptionsPlugins>>;
691
- type Plugin = keyof Plugins;
692
690
 
693
- 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, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };
691
+ export { type CLIOptions, type Config, FileManager, Generator, kubb as Kubb, KubbFile, PackageManager, type Plugin, type PluginFactoryOptions, PluginManager, PromiseManager, type ResolveNameParams, type ResolvePathParams, type UserConfig, Warning, type _Register, build, createPlugin, build as default, defineConfig, isInputPath, pluginName as name, pluginName, safeBuild };