@kubb/core 3.0.0-alpha.9 → 3.0.0-beta.10

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 (91) hide show
  1. package/README.md +14 -5
  2. package/dist/{FileManager-B0GJlthB.d.cts → FileManager-Cn8nSj1H.d.ts} +101 -83
  3. package/dist/{FileManager-BFycBDqG.d.ts → FileManager-DKZ30qz_.d.cts} +101 -83
  4. package/dist/chunk-2EU7DMPM.js +2 -3
  5. package/dist/chunk-2EU7DMPM.js.map +1 -1
  6. package/dist/{chunk-DID47EQD.cjs → chunk-2U6NQV4E.cjs} +6 -7
  7. package/dist/chunk-2U6NQV4E.cjs.map +1 -0
  8. package/dist/{chunk-SEH6NUCX.cjs → chunk-6XTAOEVP.cjs} +10 -10
  9. package/dist/chunk-6XTAOEVP.cjs.map +1 -0
  10. package/dist/{chunk-4X5FFJPJ.js → chunk-BQXM32UO.js} +11 -16
  11. package/dist/chunk-BQXM32UO.js.map +1 -0
  12. package/dist/{chunk-27CPVXAT.js → chunk-DXGMSPTW.js} +174 -231
  13. package/dist/chunk-DXGMSPTW.js.map +1 -0
  14. package/dist/{chunk-SCR3LUXT.js → chunk-E6CN2CZC.js} +38 -27
  15. package/dist/chunk-E6CN2CZC.js.map +1 -0
  16. package/dist/chunk-HBQM723K.js +12 -26
  17. package/dist/chunk-HBQM723K.js.map +1 -1
  18. package/dist/{chunk-5IGANEGE.cjs → chunk-I2VBU4S2.cjs} +268 -301
  19. package/dist/chunk-I2VBU4S2.cjs.map +1 -0
  20. package/dist/{chunk-5E2I6KH4.cjs → chunk-MNBVVNEF.cjs} +54 -37
  21. package/dist/chunk-MNBVVNEF.cjs.map +1 -0
  22. package/dist/{chunk-A6PCLWEY.cjs → chunk-PKTBHC5T.cjs} +30 -31
  23. package/dist/chunk-PKTBHC5T.cjs.map +1 -0
  24. package/dist/{chunk-IPZQXBA2.cjs → chunk-S22N4SXV.cjs} +57 -34
  25. package/dist/chunk-S22N4SXV.cjs.map +1 -0
  26. package/dist/index.cjs +223 -241
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +4 -6
  29. package/dist/index.d.ts +4 -6
  30. package/dist/index.js +106 -148
  31. package/dist/index.js.map +1 -1
  32. package/dist/{logger-BWFeedRk.d.cts → logger-DvbHXjIO.d.cts} +10 -8
  33. package/dist/{logger-BWFeedRk.d.ts → logger-DvbHXjIO.d.ts} +10 -8
  34. package/dist/logger.cjs +25 -14
  35. package/dist/logger.cjs.map +1 -1
  36. package/dist/logger.d.cts +1 -1
  37. package/dist/logger.d.ts +1 -1
  38. package/dist/logger.js +3 -13
  39. package/dist/logger.js.map +1 -1
  40. package/dist/mocks.cjs +29 -24
  41. package/dist/mocks.cjs.map +1 -1
  42. package/dist/mocks.d.cts +4 -3
  43. package/dist/mocks.d.ts +4 -3
  44. package/dist/mocks.js +22 -25
  45. package/dist/mocks.js.map +1 -1
  46. package/dist/{prompt-DVQN7JTN.cjs → prompt-3GFRRR4Q.cjs} +89 -89
  47. package/dist/prompt-3GFRRR4Q.cjs.map +1 -0
  48. package/dist/prompt-WQQUN22Z.js +8 -13
  49. package/dist/prompt-WQQUN22Z.js.map +1 -1
  50. package/dist/transformers.cjs +63 -52
  51. package/dist/transformers.cjs.map +1 -1
  52. package/dist/transformers.d.cts +1 -1
  53. package/dist/transformers.d.ts +1 -1
  54. package/dist/transformers.js +10 -37
  55. package/dist/transformers.js.map +1 -1
  56. package/dist/utils.cjs +65 -34
  57. package/dist/utils.cjs.map +1 -1
  58. package/dist/utils.d.cts +6 -8
  59. package/dist/utils.d.ts +6 -8
  60. package/dist/utils.js +3 -33
  61. package/dist/utils.js.map +1 -1
  62. package/package.json +10 -13
  63. package/src/BarrelManager.ts +76 -74
  64. package/src/FileManager.ts +55 -60
  65. package/src/PluginManager.ts +61 -61
  66. package/src/PromiseManager.ts +1 -1
  67. package/src/__snapshots__/barrel.json +11 -29
  68. package/src/__snapshots__/grouped.json +18 -12
  69. package/src/__snapshots__/ordered.json +18 -12
  70. package/src/build.ts +24 -11
  71. package/src/config.ts +2 -4
  72. package/src/index.ts +1 -1
  73. package/src/logger.ts +41 -7
  74. package/src/plugin.ts +0 -3
  75. package/src/transformers/escape.ts +0 -10
  76. package/src/transformers/stringify.ts +1 -1
  77. package/src/types.ts +77 -46
  78. package/src/utils/TreeNode.ts +31 -56
  79. package/src/utils/executeStrategies.ts +2 -2
  80. package/src/utils/parser.ts +38 -39
  81. package/dist/chunk-27CPVXAT.js.map +0 -1
  82. package/dist/chunk-4X5FFJPJ.js.map +0 -1
  83. package/dist/chunk-5E2I6KH4.cjs.map +0 -1
  84. package/dist/chunk-5IGANEGE.cjs.map +0 -1
  85. package/dist/chunk-A6PCLWEY.cjs.map +0 -1
  86. package/dist/chunk-DID47EQD.cjs.map +0 -1
  87. package/dist/chunk-IPZQXBA2.cjs.map +0 -1
  88. package/dist/chunk-SCR3LUXT.js.map +0 -1
  89. package/dist/chunk-SEH6NUCX.cjs.map +0 -1
  90. package/dist/prompt-DVQN7JTN.cjs.map +0 -1
  91. package/src/utils/cache.ts +0 -35
package/README.md CHANGED
@@ -13,12 +13,8 @@
13
13
  [![Coverage][coverage-src]][coverage-href]
14
14
  [![License][license-src]][license-href]
15
15
 
16
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
- </p>
19
-
20
16
  <h4>
21
- <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
17
+ <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/main//examples/typescript" target="_blank">View Demo</a>
22
18
  <span> · </span>
23
19
  <a href="https://kubb.dev/" target="_blank">Documentation</a>
24
20
  <span> · </span>
@@ -28,6 +24,19 @@
28
24
  </h4>
29
25
  </div>
30
26
 
27
+ ## Supporting Kubb
28
+
29
+ Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
30
+
31
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/sponsors/stijnvanhulle">
35
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
36
+ </a>
37
+ </p>
38
+
39
+
31
40
  <!-- Badges -->
32
41
 
33
42
  [npm-version-src]: https://img.shields.io/npm/v/@kubb/core?flat&colorA=18181B&colorB=f58517
@@ -2,16 +2,12 @@ import { write, read } from '@kubb/fs';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
3
  import { ResolvedFile } from '@kubb/fs/types';
4
4
  import { PossiblePromise, GreaterThan } from '@kubb/types';
5
- import { E as EventEmitter, L as Logger } from './logger-BWFeedRk.cjs';
5
+ import { E as EventEmitter, L as Logger } from './logger-DvbHXjIO.js';
6
6
 
7
7
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
8
- /**
9
- * Get the type of the first argument in a function.
10
- * @example Arg0<(a: string, b: number) => void> -> string
11
- */
12
- type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0];
13
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq';
8
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
14
9
  type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
10
+ message: string;
15
11
  strategy: Strategy;
16
12
  hookName: H;
17
13
  plugin: Plugin;
@@ -27,20 +23,20 @@ type Options = {
27
23
  logger: Logger;
28
24
  };
29
25
  type Events = {
30
- execute: [executer: Executer];
26
+ executing: [executer: Executer];
31
27
  executed: [executer: Executer];
32
28
  error: [error: Error];
33
29
  };
34
30
  type GetFileProps<TOptions = object> = {
35
31
  name: string;
36
32
  mode?: KubbFile.Mode;
37
- extName: KubbFile.Extname;
33
+ extname: KubbFile.Extname;
38
34
  pluginKey: Plugin['key'];
39
35
  options?: TOptions;
40
36
  };
41
37
  declare class PluginManager {
42
38
  #private;
43
- readonly plugins: PluginWithLifeCycle[];
39
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
44
40
  readonly fileManager: FileManager;
45
41
  readonly events: EventEmitter<Events>;
46
42
  readonly config: Config;
@@ -48,7 +44,7 @@ declare class PluginManager {
48
44
  readonly logger: Logger;
49
45
  readonly options: Options;
50
46
  constructor(config: Config, options: Options);
51
- getFile<TOptions = object>({ name, mode, extName, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
47
+ getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{
52
48
  pluginKey: Plugin['key'];
53
49
  }>;
54
50
  resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
@@ -60,143 +56,141 @@ declare class PluginManager {
60
56
  /**
61
57
  * Run a specific hookName for plugin x.
62
58
  */
63
- hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
59
+ hookForPlugin<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
64
60
  pluginKey: Plugin['key'];
65
61
  hookName: H;
66
62
  parameters: PluginParameter<H>;
63
+ message: string;
67
64
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
68
65
  /**
69
66
  * Run a specific hookName for plugin x.
70
67
  */
71
- hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, }: {
68
+ hookForPluginSync<H extends PluginLifecycleHooks>({ pluginKey, hookName, parameters, message, }: {
72
69
  pluginKey: Plugin['key'];
73
70
  hookName: H;
74
71
  parameters: PluginParameter<H>;
72
+ message: string;
75
73
  }): Array<ReturnType<ParseResult<H>>> | null;
76
74
  /**
77
75
  * First non-null result stops and will return it's value.
78
76
  */
79
- hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
77
+ hookFirst<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
80
78
  hookName: H;
81
79
  parameters: PluginParameter<H>;
82
80
  skipped?: ReadonlySet<Plugin> | null;
81
+ message: string;
83
82
  }): Promise<SafeParseResult<H>>;
84
83
  /**
85
84
  * First non-null result stops and will return it's value.
86
85
  */
87
- hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, }: {
86
+ hookFirstSync<H extends PluginLifecycleHooks>({ hookName, parameters, skipped, message, }: {
88
87
  hookName: H;
89
88
  parameters: PluginParameter<H>;
90
89
  skipped?: ReadonlySet<Plugin> | null;
90
+ message: string;
91
91
  }): SafeParseResult<H>;
92
92
  /**
93
93
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
94
94
  */
95
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, }: {
95
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({ hookName, parameters, message, }: {
96
96
  hookName: H;
97
97
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
98
+ message: string;
98
99
  }): Promise<Awaited<TOuput>[]>;
99
- /**
100
- * Chain all plugins, `reduce` can be passed through to handle every returned value. The return value of the first plugin will be used as the first parameter for the plugin after that.
101
- */
102
- hookReduceArg0<H extends PluginLifecycleHooks>({ hookName, parameters, reduce, }: {
103
- hookName: H;
104
- parameters: PluginParameter<H>;
105
- reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>;
106
- }): Promise<Argument0<H>>;
107
100
  /**
108
101
  * Chains plugins
109
102
  */
110
- hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: {
103
+ hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters, message, }: {
111
104
  hookName: H;
112
105
  parameters?: PluginParameter<H>;
106
+ message: string;
113
107
  }): Promise<void>;
114
108
  getPluginsByKey(hookName: keyof PluginLifecycle, pluginKey: Plugin['key']): Plugin[];
115
109
  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;
116
110
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
117
111
  }
118
112
 
119
- interface Cache<TStore extends object = object> {
120
- delete(id: keyof TStore): boolean;
121
- get(id: keyof TStore): TStore[keyof TStore] | null;
122
- has(id: keyof TStore): boolean;
123
- set(id: keyof TStore, value: unknown): void;
124
- }
125
-
126
113
  /**
127
- * Config used in `kubb.config.js`
114
+ * Config used in `kubb.config.ts`
128
115
  *
129
- * @example import { defineConfig } from '@kubb/core'
116
+ * @example
117
+ * import { defineConfig } from '@kubb/core'
130
118
  * export default defineConfig({
131
119
  * ...
132
120
  * })
133
121
  */
134
122
  type UserConfig = Omit<Config, 'root' | 'plugins'> & {
135
123
  /**
136
- * Project root directory. Can be an absolute path, or a path relative from
137
- * the location of the config file itself.
124
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
138
125
  * @default process.cwd()
139
126
  */
140
127
  root?: string;
141
128
  /**
142
- * Plugin type should be a Kubb plugin
129
+ * An array of Kubb plugins used for generation. Each plugin may have additional configurable options (defined within the plugin itself). If a plugin relies on another plugin, an error will occur if the required dependency is missing. Refer to “pre” for more details.
143
130
  */
144
131
  plugins?: Array<Omit<UnknownUserPlugin, 'context'>>;
145
132
  };
146
133
  type InputPath = {
147
134
  /**
148
- * Path to be used as the input. This can be an absolute path or a path relative to the `root`.
135
+ * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
149
136
  */
150
137
  path: string;
151
138
  };
152
139
  type InputData = {
153
140
  /**
154
- * `string` or `object` containing the data.
141
+ * A `string` or `object` that contains your Swagger/OpenAPI data.
155
142
  */
156
143
  data: string | unknown;
157
144
  };
158
145
  type Input = InputPath | InputData;
146
+ type BarrelType = 'all' | 'named';
159
147
  /**
160
148
  * @private
161
149
  */
162
150
  type Config<TInput = Input> = {
163
151
  /**
164
- * Optional config name to show in CLI output
152
+ * The name to display in the CLI output.
165
153
  */
166
154
  name?: string;
167
155
  /**
168
- * Project root directory. Can be an absolute path, or a path relative from
169
- * the location of the config file itself.
156
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
170
157
  * @default process.cwd()
171
158
  */
172
159
  root: string;
160
+ /**
161
+ * You can use either `input.path` or `input.data`, depending on your specific needs.
162
+ */
173
163
  input: TInput;
174
164
  output: {
175
165
  /**
176
- * Path to be used to export all generated files.
177
- * This can be an absolute path, or a path relative based of the defined `root` option.
166
+ * The path where all generated files will be exported.
167
+ * This can be an absolute path or a path relative to the specified root option.
178
168
  */
179
169
  path: string;
180
170
  /**
181
- * Clean output directory before each build.
171
+ * Clean the output directory before each build.
182
172
  */
183
173
  clean?: boolean;
184
174
  /**
185
- * Write files to the fileSystem
186
- * This is being used for the playground.
175
+ * Save files to the file system.
187
176
  * @default true
188
177
  */
189
178
  write?: boolean;
190
179
  /**
191
- * Define what needs to exported, here you can also disable the export of barrel files
192
- * @default `'barrelNamed'`
180
+ * Override the extension to the generated imports and exports, by default each plugin will add an extension
181
+ * @default { '.ts': '.ts'}
182
+ */
183
+ extension?: Record<KubbFile.Extname, KubbFile.Extname>;
184
+ /**
185
+ * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
186
+ * @default 'named'
193
187
  */
194
- exportType?: 'barrel' | 'barrelNamed' | false;
188
+ barrelType?: BarrelType | false;
195
189
  };
196
190
  /**
197
- * Array of Kubb plugins to use.
198
- * The plugin/package can forsee some options that you need to pass through.
199
- * Sometimes a plugin is depended on another plugin, if that's the case you will get an error back from the plugin you installed.
191
+ * An array of Kubb plugins that will be used in the generation.
192
+ * Each plugin may include additional configurable options(defined in the plugin itself).
193
+ * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
200
194
  */
201
195
  plugins?: Array<Plugin>;
202
196
  /**
@@ -281,21 +275,6 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
281
275
  * @private
282
276
  */
283
277
  key: TOptions['key'];
284
- output?: {
285
- /**
286
- * Output to save the clients.
287
- */
288
- path: string;
289
- /**
290
- * Add an extension to the generated imports and exports, default it will not use an extension
291
- */
292
- extName?: KubbFile.Extname;
293
- /**
294
- * Define what needs to exported, here you can also disable the export of barrel files
295
- * @default `'barrelNamed'`
296
- */
297
- exportType?: 'barrel' | 'barrelNamed' | false;
298
- };
299
278
  /**
300
279
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
301
280
  * Can be used to validate dependent plugins.
@@ -327,7 +306,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
327
306
  * @type hookFirst
328
307
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
329
308
  */
330
- resolvePath?: (this: PluginContext<TOptions>, baseName: string, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
309
+ resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
331
310
  /**
332
311
  * Resolve to a name based on a string.
333
312
  * Useful when converting to PascalCase or camelCase.
@@ -343,10 +322,9 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
343
322
  };
344
323
  type PluginLifecycleHooks = keyof PluginLifecycle;
345
324
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
346
- type PluginCache = Record<string, [number, unknown]>;
347
325
  type ResolvePathParams<TOptions = object> = {
348
326
  pluginKey?: Plugin['key'];
349
- baseName: string;
327
+ baseName: KubbFile.BaseName;
350
328
  mode?: KubbFile.Mode;
351
329
  /**
352
330
  * Options to be passed to 'resolvePath' 3th parameter
@@ -358,14 +336,14 @@ type ResolveNameParams = {
358
336
  pluginKey?: Plugin['key'];
359
337
  /**
360
338
  * `file` will be used to customize the name of the created file(use of camelCase)
361
- * `function` can be used used to customize the exported functions(use of camelCase)
339
+ * `function` can be used to customize the exported functions(use of camelCase)
362
340
  * `type` is a special type for TypeScript(use of PascalCase)
341
+ * `const` can be used for variables(use of camelCase)
363
342
  */
364
- type?: 'file' | 'function' | 'type';
343
+ type?: 'file' | 'function' | 'type' | 'const';
365
344
  };
366
345
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
367
346
  config: Config;
368
- cache: Cache<PluginCache>;
369
347
  fileManager: FileManager;
370
348
  pluginManager: PluginManager;
371
349
  addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
@@ -381,6 +359,41 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
381
359
  */
382
360
  plugin: Plugin<TOptions>;
383
361
  };
362
+ /**
363
+ * Specify the export location for the files and define the behavior of the output
364
+ */
365
+ type Output = {
366
+ /**
367
+ * Path to the output folder or file that will contain the generated code
368
+ */
369
+ path: string;
370
+ /**
371
+ * Define what needs to be exported, here you can also disable the export of barrel files
372
+ * @default 'named'
373
+ */
374
+ barrelType?: BarrelType | false;
375
+ /**
376
+ * Add a banner text in the beginning of every file
377
+ */
378
+ banner?: string;
379
+ /**
380
+ * Add a footer text in the beginning of every file
381
+ */
382
+ footer?: string;
383
+ };
384
+ type GroupContext = {
385
+ group: string;
386
+ };
387
+ type Group = {
388
+ /**
389
+ * Define a type where to group the files on
390
+ */
391
+ type: 'tag';
392
+ /**
393
+ * Return the name of a group based on the group name, this will be used for the file and name generation
394
+ */
395
+ name?: (context: GroupContext) => string;
396
+ };
384
397
 
385
398
  type BarrelData = {
386
399
  file?: KubbFile.File;
@@ -392,17 +405,19 @@ type BarrelData = {
392
405
  name: string;
393
406
  };
394
407
  declare class TreeNode {
408
+ #private;
395
409
  data: BarrelData;
396
410
  parent?: TreeNode;
397
411
  children: Array<TreeNode>;
398
412
  constructor(data: BarrelData, parent?: TreeNode);
399
413
  addChild(data: BarrelData): TreeNode;
400
- find(data?: BarrelData): TreeNode | null;
401
- get leaves(): Array<TreeNode>;
402
414
  get root(): TreeNode;
415
+ get leaves(): Array<TreeNode>;
403
416
  forEach(callback: (treeNode: TreeNode) => void): this;
404
- filter(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
405
- map<T>(callback: (treeNode: TreeNode) => T): Array<T>;
417
+ findDeep(predicate?: (value: TreeNode, index: number, obj: TreeNode[]) => boolean): TreeNode | undefined;
418
+ forEachDeep(callback: (treeNode: TreeNode) => void): void;
419
+ filterDeep(callback: (treeNode: TreeNode) => boolean): Array<TreeNode>;
420
+ mapDeep<T>(callback: (treeNode: TreeNode) => T): Array<T>;
406
421
  static build(files: KubbFile.File[], root?: string): TreeNode | null;
407
422
  }
408
423
  type DirectoryTree = {
@@ -417,6 +432,7 @@ type FileMetaBase = {
417
432
  };
418
433
  type AddResult<T extends Array<KubbFile.File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
419
434
  type AddIndexesProps = {
435
+ type: BarrelType | false | undefined;
420
436
  /**
421
437
  * Root based on root and output.path specified in the config
422
438
  */
@@ -427,9 +443,6 @@ type AddIndexesProps = {
427
443
  */
428
444
  output: {
429
445
  path: string;
430
- extName?: KubbFile.Extname;
431
- exportAs?: string;
432
- exportType?: 'barrel' | 'barrelNamed' | false;
433
446
  };
434
447
  group?: {
435
448
  output: string;
@@ -450,10 +463,15 @@ declare class FileManager {
450
463
  getCacheById(id: string): KubbFile.File | undefined;
451
464
  getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | undefined;
452
465
  deleteByPath(path: KubbFile.Path): void;
453
- getBarrelFiles({ files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
466
+ getBarrelFiles({ type, files, meta, root, output, logger }: AddIndexesProps): Promise<KubbFile.File[]>;
454
467
  write(...params: Parameters<typeof write>): ReturnType<typeof write>;
455
468
  read(...params: Parameters<typeof read>): ReturnType<typeof read>;
456
469
  static getMode(path: string | undefined | null): KubbFile.Mode;
457
470
  }
471
+ type GetSourceOptions = {
472
+ extname?: KubbFile.Extname;
473
+ logger?: Logger;
474
+ };
475
+ declare function getSource<TMeta extends FileMetaBase = FileMetaBase>(file: ResolvedFile<TMeta>, { logger, extname }?: GetSourceOptions): Promise<string>;
458
476
 
459
- 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 };
477
+ 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, type Group as o };