@kubb/core 0.39.1 → 0.41.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.
@@ -91,6 +96,10 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
91
96
  * Defined an api that can be used by other plugins
92
97
  */
93
98
  api?: TOptions['api'];
99
+ /**
100
+ * Options set for a specific plugin(see kubb.config.ts)
101
+ */
102
+ options?: TOptions['options'];
94
103
  } & Partial<PluginLifecycle>;
95
104
  type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, Api = any> = {
96
105
  options: Options;
@@ -153,9 +162,7 @@ type PluginContext = {
153
162
  config: KubbConfig;
154
163
  cache: Cache;
155
164
  fileManager: FileManager;
156
- addFile: (emitedFile: EmittedFile | File, options?: {
157
- root?: true;
158
- }) => Promise<File>;
165
+ addFile: (file: File) => Promise<File>;
159
166
  resolveId: (params: ResolveIdParams) => MaybePromise<OptionalPath>;
160
167
  load: (id: string) => MaybePromise<TransformResult | void>;
161
168
  };
@@ -179,29 +186,6 @@ type PathMode = 'file' | 'directory';
179
186
  declare const getPathMode: (path: string | undefined | null) => PathMode | undefined;
180
187
  declare const read: (path: string) => Promise<string>;
181
188
 
182
- /**
183
- * @deprecated Use userFile instead
184
- */
185
- type EmittedFile = {
186
- /**
187
- * equal to importee when getting passed through resolveId
188
- */
189
- id: string;
190
- /**
191
- * The importer is the fully resolved id of the importing module.
192
- */
193
- importer?: string;
194
- /**
195
- * Name to be used to dynamicly create the fileName(based on input.path)
196
- */
197
- name?: string;
198
- /**
199
- * FileName will be the end result so no input.path will not be added
200
- */
201
- fileName?: string;
202
- source?: string;
203
- options?: Record<string, any>;
204
- };
205
189
  type Import = {
206
190
  name: string | string[];
207
191
  path: string;
@@ -246,6 +230,7 @@ declare class FileManager {
246
230
  private getCache;
247
231
  private getCacheByPath;
248
232
  private getCountByStatus;
233
+ private getSource;
249
234
  get files(): File[];
250
235
  add(file: File): Promise<File>;
251
236
  build(file: File): string;
@@ -305,7 +290,7 @@ declare function build(options: BuildOptions): Promise<BuildOutput>;
305
290
  * accepts a direct {@link KubbConfig} object, or a function that returns it.
306
291
  * The function receives a {@link ConfigEnv} object that exposes two properties:
307
292
  */
308
- declare const defineConfig: (options: MaybePromise<KubbUserConfig<false>> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>)) => MaybePromise<KubbUserConfig<false>> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>);
293
+ declare const defineConfig: (options: MaybePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>)) => MaybePromise<KubbUserConfig> | ((cliOptions: CLIOptions) => MaybePromise<KubbUserConfig>);
309
294
 
310
295
  type KubbPluginFactory<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => T['nested'] extends true ? Array<KubbPlugin<T>> : KubbPlugin<T>;
311
296
  declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(factory: KubbPluginFactory<T>): (options: T['options']) => T["nested"] extends true ? KubbPlugin<T>[] : KubbPlugin<T>;
@@ -383,4 +368,4 @@ declare abstract class SchemaGenerator<TOptions extends object, TInput, TOutput>
383
368
  abstract build(schema: TInput, name: string, description?: string): TOutput;
384
369
  }
385
370
 
386
- export { Argument0, CLIOptions, Cache, CacheStore, CorePluginOptions, EmittedFile, File, FileManager, FileName, Generator, KubbBuild, KubbConfig, KubbJSONPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, LogType, Logger, MaybePromise, OptionalPath, Path, PathMode, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, ResolveIdParams, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, UUID, ValidationPluginError, build, clean, createPlugin, createPluginCache, build as default, defineConfig, getPathMode, getRelativePath, hooks, isPromise, name, read, validatePlugins, write };
371
+ export { Argument0, CLIOptions, Cache, CacheStore, CorePluginOptions, File, FileManager, FileName, Generator, KubbBuild, KubbConfig, KubbJSONPlugin, KubbPlugin, KubbPluginKind, KubbUserConfig, LogLevel, LogType, Logger, MaybePromise, OptionalPath, Path, PathMode, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, ResolveIdParams, SchemaGenerator, Status, Strategy, TransformResult, TreeNode, UUID, ValidationPluginError, build, clean, createPlugin, createPluginCache, build as default, defineConfig, getPathMode, getRelativePath, hooks, isPromise, name, read, validatePlugins, write };