@kubb/core 3.0.0-alpha.29 → 3.0.0-alpha.30

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 (47) hide show
  1. package/dist/{FileManager-4lbobkix.d.cts → FileManager-CqvmdzNO.d.cts} +21 -23
  2. package/dist/{FileManager-CdXrquQt.d.ts → FileManager-DIArE3b0.d.ts} +21 -23
  3. package/dist/{chunk-E3LZA47U.cjs → chunk-2UQARE2O.cjs} +8 -8
  4. package/dist/{chunk-E3LZA47U.cjs.map → chunk-2UQARE2O.cjs.map} +1 -1
  5. package/dist/{chunk-YKBUGVEZ.cjs → chunk-LLKRRIBF.cjs} +10 -10
  6. package/dist/{chunk-YKBUGVEZ.cjs.map → chunk-LLKRRIBF.cjs.map} +1 -1
  7. package/dist/{chunk-CLTNHSMO.js → chunk-MD2LDZ3Z.js} +45 -51
  8. package/dist/chunk-MD2LDZ3Z.js.map +1 -0
  9. package/dist/{chunk-P655QOG5.cjs → chunk-OX2X7B4Z.cjs} +4 -4
  10. package/dist/{chunk-P655QOG5.cjs.map → chunk-OX2X7B4Z.cjs.map} +1 -1
  11. package/dist/{chunk-BQ5EEZ3C.cjs → chunk-RIW2LFFQ.cjs} +6 -6
  12. package/dist/{chunk-BQ5EEZ3C.cjs.map → chunk-RIW2LFFQ.cjs.map} +1 -1
  13. package/dist/{chunk-YZITPSOO.cjs → chunk-SX5FHSVT.cjs} +76 -81
  14. package/dist/chunk-SX5FHSVT.cjs.map +1 -0
  15. package/dist/{chunk-6KGAP5LO.cjs → chunk-VBGWLAET.cjs} +4 -4
  16. package/dist/{chunk-6KGAP5LO.cjs.map → chunk-VBGWLAET.cjs.map} +1 -1
  17. package/dist/index.cjs +40 -40
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +9 -9
  22. package/dist/index.js.map +1 -1
  23. package/dist/logger.cjs +7 -7
  24. package/dist/mocks.cjs +11 -11
  25. package/dist/mocks.cjs.map +1 -1
  26. package/dist/mocks.d.cts +1 -1
  27. package/dist/mocks.d.ts +1 -1
  28. package/dist/mocks.js +3 -3
  29. package/dist/mocks.js.map +1 -1
  30. package/dist/{prompt-2EVJOUVT.cjs → prompt-2PN2F25D.cjs} +62 -62
  31. package/dist/{prompt-2EVJOUVT.cjs.map → prompt-2PN2F25D.cjs.map} +1 -1
  32. package/dist/transformers.cjs +23 -23
  33. package/dist/utils.cjs +17 -17
  34. package/dist/utils.d.cts +4 -7
  35. package/dist/utils.d.ts +4 -7
  36. package/dist/utils.js +1 -1
  37. package/package.json +6 -6
  38. package/src/FileManager.ts +17 -14
  39. package/src/PluginManager.ts +3 -3
  40. package/src/__snapshots__/barrel.json +11 -31
  41. package/src/__snapshots__/grouped.json +6 -6
  42. package/src/__snapshots__/ordered.json +6 -6
  43. package/src/build.ts +5 -6
  44. package/src/types.ts +17 -16
  45. package/src/utils/parser.ts +25 -35
  46. package/dist/chunk-CLTNHSMO.js.map +0 -1
  47. package/dist/chunk-YZITPSOO.cjs.map +0 -1
@@ -35,7 +35,7 @@ type Events = {
35
35
  type GetFileProps<TOptions = object> = {
36
36
  name: string;
37
37
  mode?: KubbFile.Mode;
38
- extName: KubbFile.Extname;
38
+ extname: KubbFile.Extname;
39
39
  pluginKey: Plugin['key'];
40
40
  options?: TOptions;
41
41
  };
@@ -49,7 +49,7 @@ declare class PluginManager {
49
49
  readonly logger: Logger;
50
50
  readonly options: Options;
51
51
  constructor(config: Config, options: Options);
52
- getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
52
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
53
53
  pluginKey: Plugin['key'];
54
54
  }>;
55
55
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
@@ -157,6 +157,9 @@ type InputData = {
157
157
  data: string | unknown;
158
158
  };
159
159
  type Input = InputPath | InputData;
160
+ type OutContext = {};
161
+ type OutExtension = (context: OutContext) => Record<KubbFile.Extname, KubbFile.Extname>;
162
+ type BarrelType = 'all' | 'named';
160
163
  /**
161
164
  * @private
162
165
  */
@@ -188,11 +191,16 @@ type Config<TInput = Input> = {
188
191
  * @default true
189
192
  */
190
193
  write?: boolean;
194
+ /**
195
+ * Override the extension to the generated imports and exports, default the plugin will add an extension
196
+ * @default `() => ({ '.ts': '.ts'})`
197
+ */
198
+ extension?: OutExtension;
191
199
  /**
192
200
  * Define what needs to exported, here you can also disable the export of barrel files.
193
- * @default `'barrelNamed'`
201
+ * @default `'named'`
194
202
  */
195
- exportType?: 'barrel' | 'barrelNamed' | false;
203
+ barrelType?: BarrelType | false;
196
204
  };
197
205
  /**
198
206
  * An array of Kubb plugins that will be used in the generation.
@@ -329,7 +337,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
329
337
  };
330
338
  type PluginLifecycleHooks = keyof PluginLifecycle;
331
339
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
332
- type PluginCache = Record<string, [number, unknown]>;
333
340
  type ResolvePathParams<TOptions = object> = {
334
341
  pluginKey?: Plugin['key'];
335
342
  baseName: string;
@@ -347,7 +354,7 @@ type ResolveNameParams = {
347
354
  * `function` can be used used to customize the exported functions(use of camelCase)
348
355
  * `type` is a special type for TypeScript(use of PascalCase)
349
356
  */
350
- type?: 'file' | 'function' | 'type';
357
+ type?: 'file' | 'function' | 'type' | 'const';
351
358
  };
352
359
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
353
360
  config: Config;
@@ -372,18 +379,10 @@ type Output = {
372
379
  */
373
380
  path: string;
374
381
  /**
375
- * Name to be used for the `export * as {{exportAs}} from './'`
376
- */
377
- exportAs?: string;
378
- /**
379
- * Add an extension to the generated imports and exports, default it will not use an extension
380
- */
381
- extName?: KubbFile.Extname;
382
- /**
383
- * Define what needs to exported, here you can also disable the export of barrel files
384
- * @default `'barrelNamed'`
382
+ * Define what needs to exported, here you can also disable the export of barrel files.
383
+ * @default `'named'`
385
384
  */
386
- exportType?: 'barrel' | 'barrelNamed' | false;
385
+ barrelType?: BarrelType | false;
387
386
  /**
388
387
  * Add a banner text in the beginning of every file
389
388
  */
@@ -431,6 +430,7 @@ type FileMetaBase = {
431
430
  };
432
431
  type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
433
432
  type AddIndexesProps = {
433
+ type: BarrelType | false | undefined;
434
434
  /**
435
435
  * Root based on root and output.path specified in the config
436
436
  */
@@ -441,9 +441,6 @@ type AddIndexesProps = {
441
441
  */
442
442
  output: {
443
443
  path: string;
444
- extName?: KubbFile.Extname;
445
- exportAs?: string;
446
- exportType?: 'barrel' | 'barrelNamed' | false;
447
444
  };
448
445
  group?: {
449
446
  output: string;
@@ -464,14 +461,15 @@ declare class FileManager {
464
461
  getCacheById(id: string): KubbFile.File | undefined;
465
462
  getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined;
466
463
  deleteByPath(path: KubbFile.Path): void;
467
- getBarrelFiles({ files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
464
+ getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
468
465
  write(...params: Parameters<typeof write>): ReturnType<typeof write>;
469
466
  read(...params: Parameters<typeof read>): ReturnType<typeof read>;
470
467
  static getMode(path: string | undefined | null): KubbFile.Mode;
471
468
  }
472
469
  type GetSourceOptions = {
470
+ extname?: KubbFile.Extname;
473
471
  logger?: Logger;
474
472
  };
475
- declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger }?: GetSourceOptions): Promise<string>;
473
+ declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
476
474
 
477
- export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, 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, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type PluginCache as n, type ResolveNameParams as o };
475
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, 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, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n };
@@ -35,7 +35,7 @@ type Events = {
35
35
  type GetFileProps<TOptions = object> = {
36
36
  name: string;
37
37
  mode?: KubbFile.Mode;
38
- extName: KubbFile.Extname;
38
+ extname: KubbFile.Extname;
39
39
  pluginKey: Plugin['key'];
40
40
  options?: TOptions;
41
41
  };
@@ -49,7 +49,7 @@ declare class PluginManager {
49
49
  readonly logger: Logger;
50
50
  readonly options: Options;
51
51
  constructor(config: Config, options: Options);
52
- getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
52
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
53
53
  pluginKey: Plugin['key'];
54
54
  }>;
55
55
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
@@ -157,6 +157,9 @@ type InputData = {
157
157
  data: string | unknown;
158
158
  };
159
159
  type Input = InputPath | InputData;
160
+ type OutContext = {};
161
+ type OutExtension = (context: OutContext) => Record<KubbFile.Extname, KubbFile.Extname>;
162
+ type BarrelType = 'all' | 'named';
160
163
  /**
161
164
  * @private
162
165
  */
@@ -188,11 +191,16 @@ type Config<TInput = Input> = {
188
191
  * @default true
189
192
  */
190
193
  write?: boolean;
194
+ /**
195
+ * Override the extension to the generated imports and exports, default the plugin will add an extension
196
+ * @default `() => ({ '.ts': '.ts'})`
197
+ */
198
+ extension?: OutExtension;
191
199
  /**
192
200
  * Define what needs to exported, here you can also disable the export of barrel files.
193
- * @default `'barrelNamed'`
201
+ * @default `'named'`
194
202
  */
195
- exportType?: 'barrel' | 'barrelNamed' | false;
203
+ barrelType?: BarrelType | false;
196
204
  };
197
205
  /**
198
206
  * An array of Kubb plugins that will be used in the generation.
@@ -329,7 +337,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
329
337
  };
330
338
  type PluginLifecycleHooks = keyof PluginLifecycle;
331
339
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
332
- type PluginCache = Record<string, [number, unknown]>;
333
340
  type ResolvePathParams<TOptions = object> = {
334
341
  pluginKey?: Plugin['key'];
335
342
  baseName: string;
@@ -347,7 +354,7 @@ type ResolveNameParams = {
347
354
  * `function` can be used used to customize the exported functions(use of camelCase)
348
355
  * `type` is a special type for TypeScript(use of PascalCase)
349
356
  */
350
- type?: 'file' | 'function' | 'type';
357
+ type?: 'file' | 'function' | 'type' | 'const';
351
358
  };
352
359
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
353
360
  config: Config;
@@ -372,18 +379,10 @@ type Output = {
372
379
  */
373
380
  path: string;
374
381
  /**
375
- * Name to be used for the `export * as {{exportAs}} from './'`
376
- */
377
- exportAs?: string;
378
- /**
379
- * Add an extension to the generated imports and exports, default it will not use an extension
380
- */
381
- extName?: KubbFile.Extname;
382
- /**
383
- * Define what needs to exported, here you can also disable the export of barrel files
384
- * @default `'barrelNamed'`
382
+ * Define what needs to exported, here you can also disable the export of barrel files.
383
+ * @default `'named'`
385
384
  */
386
- exportType?: 'barrel' | 'barrelNamed' | false;
385
+ barrelType?: BarrelType | false;
387
386
  /**
388
387
  * Add a banner text in the beginning of every file
389
388
  */
@@ -431,6 +430,7 @@ type FileMetaBase = {
431
430
  };
432
431
  type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
433
432
  type AddIndexesProps = {
433
+ type: BarrelType | false | undefined;
434
434
  /**
435
435
  * Root based on root and output.path specified in the config
436
436
  */
@@ -441,9 +441,6 @@ type AddIndexesProps = {
441
441
  */
442
442
  output: {
443
443
  path: string;
444
- extName?: KubbFile.Extname;
445
- exportAs?: string;
446
- exportType?: 'barrel' | 'barrelNamed' | false;
447
444
  };
448
445
  group?: {
449
446
  output: string;
@@ -464,14 +461,15 @@ declare class FileManager {
464
461
  getCacheById(id: string): KubbFile.File | undefined;
465
462
  getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined;
466
463
  deleteByPath(path: KubbFile.Path): void;
467
- getBarrelFiles({ files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
464
+ getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
468
465
  write(...params: Parameters<typeof write>): ReturnType<typeof write>;
469
466
  read(...params: Parameters<typeof read>): ReturnType<typeof read>;
470
467
  static getMode(path: string | undefined | null): KubbFile.Mode;
471
468
  }
472
469
  type GetSourceOptions = {
470
+ extname?: KubbFile.Extname;
473
471
  logger?: Logger;
474
472
  };
475
- declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger }?: GetSourceOptions): Promise<string>;
473
+ declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
476
474
 
477
- export { type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, 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, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type PluginCache as n, type ResolveNameParams as o };
475
+ export { type BarrelType as B, type Config as C, FileManager as F, type GetPluginFactoryOptions as G, type InputPath as I, type Output as O, 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, getSource as g, type UserPlugin as h, type Plugin as i, type PluginWithLifeCycle as j, type PluginLifecycle as k, type PluginLifecycleHooks as l, type PluginParameter as m, type ResolveNameParams as n };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk6KGAP5LO_cjs = require('./chunk-6KGAP5LO.cjs');
3
+ var chunkVBGWLAET_cjs = require('./chunk-VBGWLAET.cjs');
4
4
  var util = require('util');
5
5
  var path = require('path');
6
6
  var tty = require('tty');
@@ -30,7 +30,7 @@ var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
30
30
  var process$1__default = /*#__PURE__*/_interopDefault(process$1);
31
31
 
32
32
  // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/core.mjs
33
- chunk6KGAP5LO_cjs.init_cjs_shims();
33
+ chunkVBGWLAET_cjs.init_cjs_shims();
34
34
  var LogLevels = {
35
35
  silent: Number.NEGATIVE_INFINITY,
36
36
  fatal: 0,
@@ -433,7 +433,7 @@ function createConsola(options = {}) {
433
433
  }
434
434
 
435
435
  // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
436
- chunk6KGAP5LO_cjs.init_cjs_shims();
436
+ chunkVBGWLAET_cjs.init_cjs_shims();
437
437
  function parseStack(stack) {
438
438
  const cwd = process.cwd() + path.sep;
439
439
  const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
@@ -491,7 +491,7 @@ var BasicReporter = class {
491
491
  };
492
492
 
493
493
  // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/utils.mjs
494
- chunk6KGAP5LO_cjs.init_cjs_shims();
494
+ chunkVBGWLAET_cjs.init_cjs_shims();
495
495
  var {
496
496
  env = {},
497
497
  argv = [],
@@ -723,7 +723,7 @@ function box(text, _opts = {}) {
723
723
  }
724
724
 
725
725
  // ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.36c0034f.mjs
726
- chunk6KGAP5LO_cjs.init_cjs_shims();
726
+ chunkVBGWLAET_cjs.init_cjs_shims();
727
727
  var providers = [
728
728
  ["APPVEYOR"],
729
729
  ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
@@ -1061,7 +1061,7 @@ function createConsola2(options = {}) {
1061
1061
  defaults: { level },
1062
1062
  stdout: process.stdout,
1063
1063
  stderr: process.stderr,
1064
- prompt: (...args) => import('./prompt-2EVJOUVT.cjs').then((m) => m.prompt(...args)),
1064
+ prompt: (...args) => import('./prompt-2PN2F25D.cjs').then((m) => m.prompt(...args)),
1065
1065
  reporters: options.reporters || [
1066
1066
  options.fancy ?? !(isCI2 || isTest) ? new FancyReporter() : new BasicReporter()
1067
1067
  ],
@@ -1084,5 +1084,5 @@ exports.colors = colors;
1084
1084
  exports.createConsola = createConsola2;
1085
1085
  exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
1086
1086
  exports.isUnicodeSupported = isUnicodeSupported;
1087
- //# sourceMappingURL=chunk-E3LZA47U.cjs.map
1088
- //# sourceMappingURL=chunk-E3LZA47U.cjs.map
1087
+ //# sourceMappingURL=chunk-2UQARE2O.cjs.map
1088
+ //# sourceMappingURL=chunk-2UQARE2O.cjs.map