@kubb/core 0.39.0 → 0.40.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
@@ -10,14 +10,19 @@ interface Cache<TCache = any> {
10
10
  declare function createPluginCache(cache: any): Cache;
11
11
 
12
12
  type MaybePromise<T> = Promise<T> | T;
13
- type KubbUserConfig<IsJSON = false> = Omit<KubbConfig, 'root'> & {
13
+ type KubbUserConfig = Omit<KubbConfig, 'root'> & {
14
14
  /**
15
15
  * Project root directory. Can be an absolute path, or a path relative from
16
16
  * the location of the config file itself.
17
17
  * @default process.cwd()
18
18
  */
19
19
  root?: string;
20
- plugins?: IsJSON extends true ? KubbJSONPlugin[] : KubbPlugin[];
20
+ /**
21
+ * Plugin type can be KubbJSONPlugin or KubbPlugin
22
+ * Example: ['@kubb/swagger', { output: false }]
23
+ * Or: createSwagger({ output: false })
24
+ */
25
+ plugins?: Array<unknown>;
21
26
  };
22
27
  /**
23
28
  * Global/internal config used through out the full generation.
@@ -305,7 +310,7 @@ declare function build(options: BuildOptions): Promise<BuildOutput>;
305
310
  * accepts a direct {@link KubbConfig} object, or a function that returns it.
306
311
  * The function receives a {@link ConfigEnv} object that exposes two properties:
307
312
  */
308
- declare const defineConfig: (options: MaybePromise<KubbUserConfig<false>> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>)) => MaybePromise<KubbUserConfig<false>> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>);
313
+ declare const defineConfig: (options: MaybePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>)) => MaybePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>);
309
314
 
310
315
  type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbPlugin<T>> : KubbPlugin<T>;
311
316
  declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => T["nested"] extends true ? KubbPlugin<T>[] : KubbPlugin<T>;
@@ -16902,7 +16902,16 @@ var kubb = (function (exports) {
16902
16902
  });
16903
16903
  }
16904
16904
  build(file) {
16905
- const importSource = file.imports?.reduce((prev, curr) => {
16905
+ const imports = [];
16906
+ file.imports?.forEach((curr) => {
16907
+ const exists = imports.find((imp) => imp.path === curr.path);
16908
+ if (exists) {
16909
+ exists.name = [...exists.name, ...curr.name];
16910
+ } else {
16911
+ imports.push(curr);
16912
+ }
16913
+ });
16914
+ const importSource = imports.reduce((prev, curr) => {
16906
16915
  if (Array.isArray(curr.name)) {
16907
16916
  return `${prev}
16908
16917
  import ${curr.type ? "type " : ""}{ ${curr.name.join(",")} } from "${curr.path}";`;