@kubb/core 5.0.0-alpha.30 → 5.0.0-alpha.31

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.
@@ -2,7 +2,7 @@ import path from 'node:path'
2
2
  import { camelCase, pascalCase } from '@internals/utils'
3
3
  import { isOperationNode, isSchemaNode } from '@kubb/ast'
4
4
  import type { Node, OperationNode, RootNode, SchemaNode } from '@kubb/ast/types'
5
- import type { FabricFile } from '@kubb/fabric-core/types'
5
+ import type * as KubbFile from './KubbFile.ts'
6
6
  import { getMode } from './PluginDriver.ts'
7
7
  import type {
8
8
  Config,
@@ -195,27 +195,24 @@ export function defaultResolveOptions<TOptions>(
195
195
  * // → '/src/types'
196
196
  * ```
197
197
  */
198
- export function defaultResolvePath(
199
- { baseName, pathMode, tag, path: groupPath }: ResolverPathParams,
200
- { root, output, group }: ResolverContext,
201
- ): FabricFile.Path {
198
+ export function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }: ResolverPathParams, { root, output, group }: ResolverContext): KubbFile.Path {
202
199
  const mode = pathMode ?? getMode(path.resolve(root, output.path))
203
200
 
204
201
  if (mode === 'single') {
205
- return path.resolve(root, output.path) as FabricFile.Path
202
+ return path.resolve(root, output.path) as KubbFile.Path
206
203
  }
207
204
 
208
205
  if (group && (groupPath || tag)) {
209
- return path.resolve(root, output.path, group.name({ group: group.type === 'path' ? groupPath! : tag! }), baseName) as FabricFile.Path
206
+ return path.resolve(root, output.path, group.name({ group: group.type === 'path' ? groupPath! : tag! }), baseName) as KubbFile.Path
210
207
  }
211
208
 
212
- return path.resolve(root, output.path, baseName) as FabricFile.Path
209
+ return path.resolve(root, output.path, baseName) as KubbFile.Path
213
210
  }
214
211
 
215
212
  /**
216
213
  * Default file resolver used by `defineResolver`.
217
214
  *
218
- * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
215
+ * Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
219
216
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
220
217
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
221
218
  *
@@ -239,15 +236,15 @@ export function defaultResolvePath(
239
236
  * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
240
237
  * ```
241
238
  */
242
- export function defaultResolveFile(this: Resolver, { name, extname, tag, path: groupPath }: ResolverFileParams, context: ResolverContext): FabricFile.File {
239
+ export function defaultResolveFile(this: Resolver, { name, extname, tag, path: groupPath }: ResolverFileParams, context: ResolverContext): KubbFile.File {
243
240
  const pathMode = getMode(path.resolve(context.root, context.output.path))
244
241
  const resolvedName = pathMode === 'single' ? '' : this.default(name, 'file')
245
- const baseName = `${resolvedName}${extname}` as FabricFile.BaseName
242
+ const baseName = `${resolvedName}${extname}` as KubbFile.BaseName
246
243
  const filePath = this.resolvePath({ baseName, pathMode, tag, path: groupPath }, context)
247
244
 
248
245
  return {
249
246
  path: filePath,
250
- baseName: path.basename(filePath) as FabricFile.BaseName,
247
+ baseName: path.basename(filePath) as KubbFile.BaseName,
251
248
  meta: {
252
249
  pluginName: this.pluginName,
253
250
  },
@@ -406,7 +403,7 @@ export function defaultResolveFooter(node: RootNode | undefined, { output }: Res
406
403
  * - `default` — name casing strategy (camelCase / PascalCase)
407
404
  * - `resolveOptions` — include/exclude/override filtering
408
405
  * - `resolvePath` — output path computation
409
- * - `resolveFile` — full `FabricFile.File` construction
406
+ * - `resolveFile` — full `KubbFile.File` construction
410
407
  *
411
408
  * Methods in the builder have access to `this` (the full resolver object), so they
412
409
  * can call other resolver methods without circular imports.
@@ -1,11 +1,11 @@
1
- import type { FabricFile } from '@kubb/fabric-core/types'
2
1
  import { useFabric } from '@kubb/react-fabric'
2
+ import type * as KubbFile from '../KubbFile.ts'
3
3
 
4
4
  /**
5
5
  * @deprecated use `mode` from the generator component props instead
6
6
  */
7
- export function useMode(): FabricFile.Mode {
8
- const { meta } = useFabric<{ mode: FabricFile.Mode }>()
7
+ export function useMode(): KubbFile.Mode {
8
+ const { meta } = useFabric<{ mode: KubbFile.Mode }>()
9
9
 
10
10
  return meta.mode
11
11
  }
package/src/index.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  export { AsyncEventEmitter, URLPath } from '@internals/utils'
2
2
  export { composeTransformers, definePrinter } from '@kubb/ast'
3
3
  export { build, build as default, safeBuild, setup } from './build.ts'
4
- export { type CLIOptions, type ConfigInput, defineConfig, isInputPath } from './config.ts'
5
4
  export { formatters, linters, logLevel } from './constants.ts'
6
5
  export { createAdapter } from './createAdapter.ts'
7
6
  export { createPlugin } from './createPlugin.ts'
8
7
  export { createStorage } from './createStorage.ts'
8
+ export { defineConfig } from './defineConfig.ts'
9
9
  export { defineGenerator, mergeGenerators } from './defineGenerator.ts'
10
10
  export { defineLogger } from './defineLogger.ts'
11
+ export { defineParser } from './defineParser.ts'
11
12
  export { definePresets } from './definePresets.ts'
12
13
  export {
13
14
  buildDefaultBanner,
@@ -18,16 +19,16 @@ export {
18
19
  defaultResolvePath,
19
20
  defineResolver,
20
21
  } from './defineResolver.ts'
22
+ export * as KubbFile from './KubbFile.ts'
21
23
  export { getMode, PluginDriver } from './PluginDriver.ts'
22
24
  export { fsStorage } from './storages/fsStorage.ts'
23
25
  export { memoryStorage } from './storages/memoryStorage.ts'
24
26
  export * from './types.ts'
25
- export type { FunctionParamsAST } from './utils/FunctionParams.ts'
26
27
  export { FunctionParams } from './utils/FunctionParams.ts'
27
28
  export { detectFormatter } from './utils/formatters.ts'
28
- export type { FileMetaBase } from './utils/getBarrelFiles.ts'
29
29
  export { getBarrelFiles } from './utils/getBarrelFiles.ts'
30
30
  export { getConfigs } from './utils/getConfigs.ts'
31
31
  export { getPreset } from './utils/getPreset.ts'
32
+ export { isInputPath } from './utils/isInputPath.ts'
32
33
  export { detectLinter } from './utils/linters.ts'
33
34
  export { satisfiesDependency } from './utils/packageJSON.ts'
@@ -1,19 +1,19 @@
1
- import type { FabricFile } from '@kubb/fabric-core/types'
2
1
  import { createReactFabric, Fabric } from '@kubb/react-fabric'
3
2
  import type { FabricReactNode, Fabric as FabricType } from '@kubb/react-fabric/types'
3
+ import type * as KubbFile from './KubbFile.ts'
4
4
 
5
5
  /**
6
6
  * Handles the return value of a plugin AST hook or generator method.
7
7
  *
8
8
  * - React element → rendered via an isolated react-fabric context, files merged into `fabric`
9
- * - `Array<FabricFile.File>` → upserted directly into `fabric`
9
+ * - `Array<KubbFile.File>` → upserted directly into `fabric`
10
10
  * - `void` / `null` / `undefined` → no-op (plugin handled it via `this.upsertFile`)
11
11
  */
12
- export async function applyHookResult(result: FabricReactNode | Array<FabricFile.File> | void, fabric: FabricType): Promise<void> {
12
+ export async function applyHookResult(result: FabricReactNode | Array<KubbFile.File> | void, fabric: FabricType): Promise<void> {
13
13
  if (!result) return
14
14
 
15
15
  if (Array.isArray(result)) {
16
- await fabric.upsertFile(...(result as Array<FabricFile.File>))
16
+ await fabric.upsertFile(...(result as Array<KubbFile.File>))
17
17
  return
18
18
  }
19
19
 
package/src/types.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import type { AsyncEventEmitter, PossiblePromise } from '@internals/utils'
2
2
  import type { Node, OperationNode, Printer, RootNode, SchemaNode, Visitor } from '@kubb/ast/types'
3
- import type { FabricFile, Fabric as FabricType } from '@kubb/fabric-core/types'
3
+ import type { Fabric as FabricType } from '@kubb/fabric-core/types'
4
4
  import type { HttpMethod } from '@kubb/oas'
5
5
  import type { FabricReactNode } from '@kubb/react-fabric/types'
6
6
  import type { DEFAULT_STUDIO_URL, logLevel } from './constants.ts'
7
7
  import type { Storage } from './createStorage.ts'
8
8
  import type { Generator } from './defineGenerator.ts'
9
+ import type { Parser } from './defineParser.ts'
9
10
  import type { KubbEvents } from './Kubb.ts'
11
+ import type * as KubbFile from './KubbFile.ts'
10
12
  import type { PluginDriver } from './PluginDriver.ts'
11
13
 
12
14
  export type { Printer, PrinterFactoryOptions, PrinterPartial } from '@kubb/ast/types'
@@ -44,12 +46,43 @@ declare global {
44
46
  * ...
45
47
  * })
46
48
  */
47
- export type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
49
+ export type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter'> & {
48
50
  /**
49
51
  * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
50
52
  * @default process.cwd()
51
53
  */
52
54
  root?: string
55
+ /**
56
+ * An array of parsers used to convert generated files to strings.
57
+ * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
58
+ *
59
+ * A catch-all fallback parser is always appended last for any unhandled extension.
60
+ *
61
+ * When omitted, `parserTs` from `@kubb/parser-ts` is used automatically as the
62
+ * default (requires `@kubb/parser-ts` to be installed as an optional dependency).
63
+ * @default [parserTs] — from `@kubb/parser-ts`
64
+ * @example
65
+ * ```ts
66
+ * import { parserTs, tsxParser } from '@kubb/parser-ts'
67
+ * export default defineConfig({
68
+ * parsers: [parserTs, tsxParser],
69
+ * })
70
+ * ```
71
+ */
72
+ parsers?: Array<Parser>
73
+ /**
74
+ * Adapter that converts the input file into a `@kubb/ast` `RootNode` — the universal
75
+ * intermediate representation consumed by all Kubb plugins.
76
+ *
77
+ * When omitted, `adapterOas()` from `@kubb/adapter-oas` is used automatically as the
78
+ * default (requires `@kubb/adapter-oas` to be installed as an optional dependency).
79
+ *
80
+ * - Use `@kubb/adapter-oas` for OpenAPI / Swagger (default).
81
+ * - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
82
+ *
83
+ * @default adapterOas() — from `@kubb/adapter-oas`
84
+ */
85
+ adapter?: Adapter
53
86
  /**
54
87
  * 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.
55
88
  */
@@ -71,7 +104,7 @@ export type InputData = {
71
104
  data: string | unknown
72
105
  }
73
106
 
74
- type Input = InputPath | InputData | Array<InputPath>
107
+ type Input = InputPath | InputData
75
108
 
76
109
  /**
77
110
  * The raw source passed to an adapter's `parse` function.
@@ -138,13 +171,13 @@ export type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptio
138
171
  */
139
172
  parse: (source: AdapterSource) => PossiblePromise<RootNode>
140
173
  /**
141
- * Extracts `FabricFile.Import` entries needed by a `SchemaNode` tree.
174
+ * Extracts `KubbFile.Import` entries needed by a `SchemaNode` tree.
142
175
  * Populated after the first `parse()` call. Returns an empty array before that.
143
176
  *
144
177
  * The `resolve` callback receives the collision-corrected schema name and must
145
178
  * return the `{ name, path }` pair for the import, or `undefined` to skip it.
146
179
  */
147
- getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<FabricFile.Import>
180
+ getImports: (node: SchemaNode, resolve: (schemaName: string) => { name: string; path: string }) => Array<KubbFile.Import>
148
181
  }
149
182
 
150
183
  export type BarrelType = 'all' | 'named' | 'propagate'
@@ -171,24 +204,41 @@ export type Config<TInput = Input> = {
171
204
  * @default process.cwd()
172
205
  */
173
206
  root: string
207
+ /**
208
+ * An array of parsers used to convert generated files to strings.
209
+ * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
210
+ *
211
+ * A catch-all fallback parser is always appended last for any unhandled extension.
212
+ *
213
+ * When omitted, `parserTs` from `@kubb/parser-ts` is used automatically as the
214
+ * default (requires `@kubb/parser-ts` to be installed as an optional dependency).
215
+ * @default [parserTs] — from `@kubb/parser-ts`
216
+ * @example
217
+ * ```ts
218
+ * import { parserTs, tsxParser } from '@kubb/parser-ts'
219
+ * export default defineConfig({
220
+ * parsers: [parserTs, tsxParser],
221
+ * })
222
+ * ```
223
+ */
224
+ parsers: Array<Parser>
174
225
  /**
175
226
  * Adapter that converts the input file into a `@kubb/ast` `RootNode` — the universal
176
227
  * intermediate representation consumed by all Kubb plugins.
177
228
  *
178
- * - Omit (or pass `undefined`) to use the built-in OpenAPI/Swagger adapter.
179
- * - Use `@kubb/adapter-oas` for explicit OpenAPI configuration (validate, contentType, …).
229
+ * - Use `@kubb/adapter-oas` for OpenAPI / Swagger.
180
230
  * - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
181
231
  *
182
232
  * @example
183
233
  * ```ts
184
- * import { drizzleAdapter } from '@kubb/adapter-drizzle'
234
+ * import { adapterOas } from '@kubb/adapter-oas'
185
235
  * export default defineConfig({
186
- * adapter: drizzleAdapter(),
187
- * input: { path: './src/schema.ts' },
236
+ * adapter: adapterOas(),
237
+ * input: { path: './petStore.yaml' },
188
238
  * })
189
239
  * ```
190
240
  */
191
- adapter?: Adapter
241
+ adapter: Adapter
192
242
  /**
193
243
  * You can use either `input.path` or `input.data`, depending on your specific needs.
194
244
  */
@@ -246,7 +296,7 @@ export type Config<TInput = Input> = {
246
296
  * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
247
297
  * @default { '.ts': '.ts'}
248
298
  */
249
- extension?: Record<FabricFile.Extname, FabricFile.Extname | ''>
299
+ extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>
250
300
  /**
251
301
  * Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
252
302
  * @default 'named'
@@ -346,8 +396,8 @@ export type Resolver = {
346
396
  pluginName: Plugin['name']
347
397
  default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string
348
398
  resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null
349
- resolvePath(params: ResolverPathParams, context: ResolverContext): FabricFile.Path
350
- resolveFile(params: ResolverFileParams, context: ResolverContext): FabricFile.File
399
+ resolvePath(params: ResolverPathParams, context: ResolverContext): KubbFile.Path
400
+ resolveFile(params: ResolverFileParams, context: ResolverContext): KubbFile.File
351
401
  resolveBanner(node: RootNode | null, context: ResolveBannerContext): string | undefined
352
402
  resolveFooter(node: RootNode | null, context: ResolveBannerContext): string | undefined
353
403
  }
@@ -477,7 +527,7 @@ export type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOpti
477
527
  this: GeneratorContext<TOptions>,
478
528
  node: SchemaNode,
479
529
  options: TOptions['resolvedOptions'],
480
- ) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>
530
+ ) => PossiblePromise<FabricReactNode | Array<KubbFile.File> | void>
481
531
 
482
532
  /**
483
533
  * Handler for a single operation node. Used by the `operation` hook on a plugin.
@@ -486,7 +536,7 @@ export type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryO
486
536
  this: GeneratorContext<TOptions>,
487
537
  node: OperationNode,
488
538
  options: TOptions['resolvedOptions'],
489
- ) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>
539
+ ) => PossiblePromise<FabricReactNode | Array<KubbFile.File> | void>
490
540
 
491
541
  /**
492
542
  * Handler for all collected operation nodes. Used by the `operations` hook on a plugin.
@@ -495,7 +545,7 @@ export type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactory
495
545
  this: GeneratorContext<TOptions>,
496
546
  nodes: Array<OperationNode>,
497
547
  options: TOptions['resolvedOptions'],
498
- ) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>
548
+ ) => PossiblePromise<FabricReactNode | Array<KubbFile.File> | void>
499
549
 
500
550
  export type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
501
551
  /**
@@ -552,7 +602,7 @@ export type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
552
602
  buildEnd: (this: PluginContext<TOptions>) => PossiblePromise<void>
553
603
  /**
554
604
  * Called for each schema node during the AST walk.
555
- * Return a React element, an array of `FabricFile.File`, or `void` for manual handling.
605
+ * Return a React element, an array of `KubbFile.File`, or `void` for manual handling.
556
606
  * Nodes matching `exclude`/`include` filters are skipped automatically.
557
607
  *
558
608
  * For multiple generators, use `composeGenerators` inside the plugin factory.
@@ -560,7 +610,7 @@ export type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
560
610
  schema?: SchemaHook<TOptions>
561
611
  /**
562
612
  * Called for each operation node during the AST walk.
563
- * Return a React element, an array of `FabricFile.File`, or `void` for manual handling.
613
+ * Return a React element, an array of `KubbFile.File`, or `void` for manual handling.
564
614
  *
565
615
  * For multiple generators, use `composeGenerators` inside the plugin factory.
566
616
  */
@@ -595,7 +645,7 @@ export type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactor
595
645
  buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>
596
646
  /**
597
647
  * Called for each schema node during the AST walk.
598
- * Return a React element (`<File>...</File>`), an array of `FabricFile.File` objects,
648
+ * Return a React element (`<File>...</File>`), an array of `KubbFile.File` objects,
599
649
  * or `void` to handle file writing manually via `this.upsertFile`.
600
650
  * Nodes matching `exclude` / `include` filters are skipped automatically.
601
651
  *
@@ -604,7 +654,7 @@ export type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactor
604
654
  schema?: SchemaHook<TOptions>
605
655
  /**
606
656
  * Called for each operation node during the AST walk.
607
- * Return a React element (`<File>...</File>`), an array of `FabricFile.File` objects,
657
+ * Return a React element (`<File>...</File>`), an array of `KubbFile.File` objects,
608
658
  * or `void` to handle file writing manually via `this.upsertFile`.
609
659
  *
610
660
  * For multiple generators, use `composeGenerators` inside the plugin factory.
@@ -624,12 +674,7 @@ export type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactor
624
674
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
625
675
  * @deprecated this will be replaced by resolvers
626
676
  */
627
- resolvePath?: (
628
- this: PluginContext<TOptions>,
629
- baseName: FabricFile.BaseName,
630
- mode?: FabricFile.Mode,
631
- options?: TOptions['resolvePathOptions'],
632
- ) => FabricFile.Path
677
+ resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path
633
678
  /**
634
679
  * Resolve to a name based on a string.
635
680
  * Useful when converting to PascalCase or camelCase.
@@ -646,8 +691,8 @@ export type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Require
646
691
 
647
692
  export type ResolvePathParams<TOptions = object> = {
648
693
  pluginName?: string
649
- baseName: FabricFile.BaseName
650
- mode?: FabricFile.Mode
694
+ baseName: KubbFile.BaseName
695
+ mode?: KubbFile.Mode
651
696
  /**
652
697
  * Options to be passed to 'resolvePath' 3th parameter
653
698
  */
@@ -681,7 +726,7 @@ export type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryO
681
726
  * Returns `'single'` when `output.path` has a file extension, `'split'` otherwise.
682
727
  * Shorthand for `getMode(path.resolve(this.root, output.path))`.
683
728
  */
684
- getMode: (output: { path: string }) => FabricFile.Mode
729
+ getMode: (output: { path: string }) => KubbFile.Mode
685
730
  driver: PluginDriver
686
731
  /**
687
732
  * Get a plugin by name. Returns the plugin typed via `Kubb.PluginRegistry` when
@@ -698,11 +743,11 @@ export type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryO
698
743
  /**
699
744
  * Only add when the file does not exist yet
700
745
  */
701
- addFile: (...file: Array<FabricFile.File>) => Promise<void>
746
+ addFile: (...file: Array<KubbFile.File>) => Promise<void>
702
747
  /**
703
748
  * merging multiple sources into the same output file
704
749
  */
705
- upsertFile: (...file: Array<FabricFile.File>) => Promise<void>
750
+ upsertFile: (...file: Array<KubbFile.File>) => Promise<void>
706
751
  /**
707
752
  * @deprecated use this.warn, this.error, this.info instead
708
753
  */
@@ -966,8 +1011,8 @@ export type ResolvePathOptions = {
966
1011
  * ```
967
1012
  */
968
1013
  export type ResolverPathParams = {
969
- baseName: FabricFile.BaseName
970
- pathMode?: FabricFile.Mode
1014
+ baseName: KubbFile.BaseName
1015
+ pathMode?: KubbFile.Mode
971
1016
  /**
972
1017
  * Tag value used when `group.type === 'tag'`.
973
1018
  */
@@ -1020,7 +1065,7 @@ export type ResolverContext = {
1020
1065
  */
1021
1066
  export type ResolverFileParams = {
1022
1067
  name: string
1023
- extname: FabricFile.Extname
1068
+ extname: KubbFile.Extname
1024
1069
  /**
1025
1070
  * Tag value used when `group.type === 'tag'`.
1026
1071
  */
@@ -1047,3 +1092,8 @@ export type ResolveBannerContext = {
1047
1092
  output?: Pick<Output, 'banner' | 'footer'>
1048
1093
  config: Config
1049
1094
  }
1095
+
1096
+ export type { CLIOptions, ConfigInput } from './defineConfig.ts'
1097
+ export type { Parser, UserParser } from './defineParser.ts'
1098
+ export type { FunctionParamsAST } from './utils/FunctionParams.ts'
1099
+ export type { FileMetaBase } from './utils/getBarrelFiles.ts'
@@ -1,20 +1,20 @@
1
1
  import path from 'node:path'
2
- import type { FabricFile } from '@kubb/fabric-core/types'
2
+ import type * as KubbFile from '../KubbFile.ts'
3
3
  import { getMode } from '../PluginDriver.ts'
4
4
 
5
5
  type BarrelData = {
6
- file?: FabricFile.File
6
+ file?: KubbFile.File
7
7
  /**
8
8
  * @deprecated use file instead
9
9
  */
10
- type: FabricFile.Mode
10
+ type: KubbFile.Mode
11
11
  path: string
12
12
  name: string
13
13
  }
14
14
 
15
15
  /**
16
16
  * Tree structure used to build per-directory barrel (`index.ts`) files from a
17
- * flat list of generated {@link FabricFile.File} entries.
17
+ * flat list of generated {@link KubbFile.File} entries.
18
18
  *
19
19
  * Each node represents either a directory or a file within the output tree.
20
20
  * Use {@link TreeNode.build} to construct a root node from a file list, then
@@ -143,7 +143,7 @@ export class TreeNode {
143
143
  * - Filters to files under `root` (when provided) and skips `.json` files.
144
144
  * - Returns `null` when no files match.
145
145
  */
146
- public static build(files: FabricFile.File[], root?: string): TreeNode | null {
146
+ public static build(files: KubbFile.File[], root?: string): TreeNode | null {
147
147
  try {
148
148
  const filteredTree = buildDirectoryTree(files, root)
149
149
 
@@ -187,13 +187,13 @@ export class TreeNode {
187
187
  type DirectoryTree = {
188
188
  name: string
189
189
  path: string
190
- file?: FabricFile.File
190
+ file?: KubbFile.File
191
191
  children: Array<DirectoryTree>
192
192
  }
193
193
 
194
194
  const normalizePath = (p: string): string => p.replaceAll('\\', '/')
195
195
 
196
- function buildDirectoryTree(files: Array<FabricFile.File>, rootFolder = ''): DirectoryTree | null {
196
+ function buildDirectoryTree(files: Array<KubbFile.File>, rootFolder = ''): DirectoryTree | null {
197
197
  const normalizedRootFolder = normalizePath(rootFolder)
198
198
  const rootPrefix = normalizedRootFolder.endsWith('/') ? normalizedRootFolder : `${normalizedRootFolder}/`
199
199
 
@@ -1,7 +1,7 @@
1
1
  /** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */
2
2
  import { join } from 'node:path'
3
3
  import { getRelativePath } from '@internals/utils'
4
- import type { FabricFile } from '@kubb/fabric-core/types'
4
+ import type * as KubbFile from '../KubbFile.ts'
5
5
  import type { BarrelType } from '../types.ts'
6
6
  import { TreeNode } from './TreeNode.ts'
7
7
 
@@ -29,16 +29,16 @@ type AddIndexesProps = {
29
29
  meta?: FileMetaBase
30
30
  }
31
31
 
32
- function getBarrelFilesByRoot(root: string | undefined, files: Array<FabricFile.ResolvedFile>): Array<FabricFile.File> {
33
- const cachedFiles = new Map<FabricFile.Path, FabricFile.File>()
32
+ function getBarrelFilesByRoot(root: string | undefined, files: Array<KubbFile.ResolvedFile>): Array<KubbFile.File> {
33
+ const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()
34
34
 
35
35
  TreeNode.build(files, root)?.forEach((treeNode) => {
36
36
  if (!treeNode?.children || !treeNode.parent?.data.path) {
37
37
  return
38
38
  }
39
39
 
40
- const barrelFilePath = join(treeNode.parent?.data.path, 'index.ts') as FabricFile.Path
41
- const barrelFile: FabricFile.File = {
40
+ const barrelFilePath = join(treeNode.parent?.data.path, 'index.ts') as KubbFile.Path
41
+ const barrelFile: KubbFile.File = {
42
42
  path: barrelFilePath,
43
43
  baseName: 'index.ts',
44
44
  exports: [],
@@ -113,10 +113,7 @@ function trimExtName(text: string): string {
113
113
  * - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
114
114
  * - Attaches `meta` to each barrel file for downstream plugin identification.
115
115
  */
116
- export async function getBarrelFiles(
117
- files: Array<FabricFile.ResolvedFile>,
118
- { type, meta = {}, root, output }: AddIndexesProps,
119
- ): Promise<Array<FabricFile.File>> {
116
+ export async function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, { type, meta = {}, root, output }: AddIndexesProps): Promise<Array<KubbFile.File>> {
120
117
  if (!type || type === 'propagate') {
121
118
  return []
122
119
  }
@@ -1,4 +1,4 @@
1
- import type { CLIOptions, ConfigInput } from '../config.ts'
1
+ import type { CLIOptions, ConfigInput } from '../defineConfig.ts'
2
2
  import type { Config, UserConfig } from '../types.ts'
3
3
 
4
4
  /**
@@ -0,0 +1,8 @@
1
+ import type { InputPath, UserConfig } from '../types'
2
+
3
+ /**
4
+ * Type guard to check if a given config has an `input.path`.
5
+ */
6
+ export function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath> {
7
+ return typeof config?.input === 'object' && config.input !== null && 'path' in config.input
8
+ }
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };