@kubb/core 3.0.0-alpha.1 → 3.0.0-alpha.3

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.
@@ -128,7 +128,7 @@ declare class PluginManager {
128
128
  }): Promise<void>;
129
129
  getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
130
130
  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;
131
- static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
131
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
132
132
  }
133
133
 
134
134
  interface Cache<TStore extends object = object> {
@@ -154,11 +154,9 @@ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
154
154
  */
155
155
  root?: string;
156
156
  /**
157
- * Plugin type can be KubbJSONPlugin or Plugin
158
- * Example: ['@kubb/plugin-oas', { output: false }]
159
- * Or: pluginOas({ output: false })
157
+ * Plugin type should be a Kubb plugin
160
158
  */
161
- plugins?: Array<Omit<UnknownUserPlugin, 'api'>>;
159
+ plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
162
160
  };
163
161
  type InputPath = {
164
162
  /**
@@ -236,9 +234,9 @@ TOptions extends object = object,
236
234
  */
237
235
  TResolvedOptions extends object = TOptions,
238
236
  /**
239
- * API that you want to expose to other plugins.
237
+ * Context that you want to expose to other plugins.
240
238
  */
241
- TAPI = any,
239
+ TContext = any,
242
240
  /**
243
241
  * When calling `resolvePath` you can specify better types.
244
242
  */
@@ -250,7 +248,7 @@ TResolvePathOptions extends object = object> = {
250
248
  key: PluginKey<TName | string>;
251
249
  options: TOptions;
252
250
  resolvedOptions: TResolvedOptions;
253
- api: TAPI;
251
+ context: TContext;
254
252
  resolvePathOptions: TResolvePathOptions;
255
253
  };
256
254
  type PluginKey<TName> = [name: TName, identifier?: string | number];
@@ -275,10 +273,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
275
273
  * 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.
276
274
  */
277
275
  post?: Array<string>;
278
- } & (TOptions['api'] extends never ? {
279
- api?: never;
276
+ } & (TOptions['context'] extends never ? {
277
+ context?: never;
280
278
  } : {
281
- api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
279
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
282
280
  });
283
281
  type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
284
282
  type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
@@ -306,10 +304,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
306
304
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
307
305
  */
308
306
  options: TOptions['resolvedOptions'];
309
- } & (TOptions['api'] extends never ? {
310
- api?: never;
307
+ } & (TOptions['context'] extends never ? {
308
+ context?: never;
311
309
  } : {
312
- api: TOptions['api'];
310
+ context: TOptions['context'];
313
311
  });
314
312
  type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
315
313
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
@@ -332,21 +330,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
332
330
  * @example ('pet') => 'Pet'
333
331
  */
334
332
  resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
335
- /**
336
- * Makes it possible to run async logic to override the path defined previously by `resolvePath`.
337
- * @type hookFirst
338
- */
339
- load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
340
- /**
341
- * Transform the source-code.
342
- * @type hookReduceArg0
343
- */
344
- transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
345
- /**
346
- * Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
347
- * @type hookParallel
348
- */
349
- writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
350
333
  /**
351
334
  * End of the plugin lifecycle.
352
335
  * @type hookParallel
@@ -393,7 +376,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
393
376
  */
394
377
  plugin: Plugin<TOptions>;
395
378
  };
396
- type TransformResult = string | null;
397
379
 
398
380
  type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
399
381
  /**
@@ -452,4 +434,4 @@ declare class FileManager {
452
434
  static isJavascript(baseName: string): boolean;
453
435
  }
454
436
 
455
- export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type TransformResult as T, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };
437
+ export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };
@@ -128,7 +128,7 @@ declare class PluginManager {
128
128
  }): Promise<void>;
129
129
  getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
130
130
  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;
131
- static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "load", "transform", "writeFile", "buildEnd"];
131
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
132
132
  }
133
133
 
134
134
  interface Cache<TStore extends object = object> {
@@ -154,11 +154,9 @@ type UserConfig = Omit<Config, 'root' | 'plugins'> & {
154
154
  */
155
155
  root?: string;
156
156
  /**
157
- * Plugin type can be KubbJSONPlugin or Plugin
158
- * Example: ['@kubb/plugin-oas', { output: false }]
159
- * Or: pluginOas({ output: false })
157
+ * Plugin type should be a Kubb plugin
160
158
  */
161
- plugins?: Array<Omit<UnknownUserPlugin, 'api'>>;
159
+ plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
162
160
  };
163
161
  type InputPath = {
164
162
  /**
@@ -236,9 +234,9 @@ TOptions extends object = object,
236
234
  */
237
235
  TResolvedOptions extends object = TOptions,
238
236
  /**
239
- * API that you want to expose to other plugins.
237
+ * Context that you want to expose to other plugins.
240
238
  */
241
- TAPI = any,
239
+ TContext = any,
242
240
  /**
243
241
  * When calling `resolvePath` you can specify better types.
244
242
  */
@@ -250,7 +248,7 @@ TResolvePathOptions extends object = object> = {
250
248
  key: PluginKey<TName | string>;
251
249
  options: TOptions;
252
250
  resolvedOptions: TResolvedOptions;
253
- api: TAPI;
251
+ context: TContext;
254
252
  resolvePathOptions: TResolvePathOptions;
255
253
  };
256
254
  type PluginKey<TName> = [name: TName, identifier?: string | number];
@@ -275,10 +273,10 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
275
273
  * 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.
276
274
  */
277
275
  post?: Array<string>;
278
- } & (TOptions['api'] extends never ? {
279
- api?: never;
276
+ } & (TOptions['context'] extends never ? {
277
+ context?: never;
280
278
  } : {
281
- api: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['api'];
279
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
282
280
  });
283
281
  type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
284
282
  type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
@@ -306,10 +304,10 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
306
304
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
307
305
  */
308
306
  options: TOptions['resolvedOptions'];
309
- } & (TOptions['api'] extends never ? {
310
- api?: never;
307
+ } & (TOptions['context'] extends never ? {
308
+ context?: never;
311
309
  } : {
312
- api: TOptions['api'];
310
+ context: TOptions['context'];
313
311
  });
314
312
  type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
315
313
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
@@ -332,21 +330,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
332
330
  * @example ('pet') => 'Pet'
333
331
  */
334
332
  resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
335
- /**
336
- * Makes it possible to run async logic to override the path defined previously by `resolvePath`.
337
- * @type hookFirst
338
- */
339
- load?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path) => PossiblePromise<TransformResult | null>;
340
- /**
341
- * Transform the source-code.
342
- * @type hookReduceArg0
343
- */
344
- transform?: (this: Omit<PluginContext<TOptions>, 'addFile'>, source: string, path: KubbFile.Path) => PossiblePromise<TransformResult>;
345
- /**
346
- * Write the result to the file-system based on the id(defined by `resolvePath` or changed by `load`).
347
- * @type hookParallel
348
- */
349
- writeFile?: (this: Omit<PluginContext<TOptions>, 'addFile'>, path: KubbFile.Path, source: string | undefined) => PossiblePromise<string | void>;
350
333
  /**
351
334
  * End of the plugin lifecycle.
352
335
  * @type hookParallel
@@ -393,7 +376,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
393
376
  */
394
377
  plugin: Plugin<TOptions>;
395
378
  };
396
- type TransformResult = string | null;
397
379
 
398
380
  type ResolvedFile<TMeta extends FileMetaBase = FileMetaBase, TBaseName extends BaseName = BaseName> = File<TMeta, TBaseName> & {
399
381
  /**
@@ -452,4 +434,4 @@ declare class FileManager {
452
434
  static isJavascript(baseName: string): boolean;
453
435
  }
454
436
 
455
- export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type TransformResult as T, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };
437
+ export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type PluginContext as P, type ResolvePathParams as R, type UserConfig as U, PluginManager as a, type PluginFactoryOptions as b, type UserPluginWithLifeCycle as c, type FileMetaBase as d, type InputData as e, type PluginKey as f, type UserPlugin as g, type Plugin as h, type PluginWithLifeCycle as i, type PluginLifecycle as j, type PluginLifecycleHooks as k, type PluginParameter as l, type PluginCache as m, type ResolveNameParams as n };