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

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.
@@ -1,6 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { Node, OperationNode, Printer, Printer as Printer$1, PrinterFactoryOptions, PrinterPartial, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
3
- import { Fabric, FabricFile } from "@kubb/fabric-core/types";
2
+ import { FileNode, ImportNode, InputNode, Node, OperationNode, Printer, Printer as Printer$1, PrinterFactoryOptions, PrinterPartial, SchemaNode, Visitor } from "@kubb/ast/types";
4
3
  import { HttpMethod } from "@kubb/oas";
5
4
  import { FabricReactNode } from "@kubb/react-fabric/types";
6
5
 
@@ -87,6 +86,44 @@ declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[
87
86
  */
88
87
  type PossiblePromise<T> = Promise<T> | T;
89
88
  //#endregion
89
+ //#region src/FileManager.d.ts
90
+ /**
91
+ * In-memory file store for generated files.
92
+ *
93
+ * Files with the same `path` are merged — sources, imports, and exports are concatenated.
94
+ * The `files` getter returns all stored files sorted by path length (shortest first).
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { FileManager } from '@kubb/core'
99
+ *
100
+ * const manager = new FileManager()
101
+ * manager.upsert(myFile)
102
+ * console.log(manager.files) // all stored files
103
+ * ```
104
+ */
105
+ declare class FileManager {
106
+ #private;
107
+ /**
108
+ * Adds one or more files. Files with the same path are merged — sources, imports,
109
+ * and exports from all calls with the same path are concatenated together.
110
+ */
111
+ add(...files: Array<FileNode>): Array<FileNode>;
112
+ /**
113
+ * Adds or merges one or more files.
114
+ * If a file with the same path already exists, its sources/imports/exports are merged together.
115
+ */
116
+ upsert(...files: Array<FileNode>): Array<FileNode>;
117
+ getByPath(path: string): FileNode | null;
118
+ deleteByPath(path: string): void;
119
+ clear(): void;
120
+ /**
121
+ * All stored files, sorted by path length (shorter paths first).
122
+ * Barrel/index files (e.g. index.ts) are sorted last within each length bucket.
123
+ */
124
+ get files(): Array<FileNode>;
125
+ }
126
+ //#endregion
90
127
  //#region src/constants.d.ts
91
128
  /**
92
129
  * Base URL for the Kubb Studio web app.
@@ -215,10 +252,10 @@ declare function createStorage<TOptions = Record<string, never>>(build: (options
215
252
  /**
216
253
  * A generator is a named object with optional `schema`, `operation`, and `operations`
217
254
  * methods. Each method is called with `this = PluginContext` of the parent plugin,
218
- * giving full access to `this.config`, `this.resolver`, `this.adapter`, `this.fabric`,
255
+ * giving full access to `this.config`, `this.resolver`, `this.adapter`,
219
256
  * `this.driver`, etc.
220
257
  *
221
- * Return a React element, an array of `FabricFile.File`, or `void` to handle file
258
+ * Return a React element, an array of `FileNode`, or `void` to handle file
222
259
  * writing manually via `this.upsertFile`. Both React and core (non-React) generators
223
260
  * use the same method signatures — the return type determines how output is handled.
224
261
  *
@@ -240,20 +277,20 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
240
277
  /** Used in diagnostic messages and debug output. */name: string;
241
278
  /**
242
279
  * Called for each schema node in the AST walk.
243
- * `this` is the parent plugin's context with `adapter` and `rootNode` guaranteed present.
280
+ * `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
244
281
  * `options` contains the per-node resolved options (after exclude/include/override).
245
282
  */
246
- schema?: (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
283
+ schema?: (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
247
284
  /**
248
285
  * Called for each operation node in the AST walk.
249
- * `this` is the parent plugin's context with `adapter` and `rootNode` guaranteed present.
286
+ * `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
250
287
  */
251
- operation?: (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
288
+ operation?: (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
252
289
  /**
253
290
  * Called once after all operations have been walked.
254
- * `this` is the parent plugin's context with `adapter` and `rootNode` guaranteed present.
291
+ * `this` is the parent plugin's context with `adapter` and `inputNode` guaranteed present.
255
292
  */
256
- operations?: (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
293
+ operations?: (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
257
294
  };
258
295
  /**
259
296
  * Defines a generator. Returns the object as-is with correct `this` typings.
@@ -285,6 +322,54 @@ declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginF
285
322
  */
286
323
  declare function mergeGenerators<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(generators: Array<Generator<TOptions>>): Generator<TOptions>;
287
324
  //#endregion
325
+ //#region src/defineParser.d.ts
326
+ type PrintOptions = {
327
+ extname?: FileNode['extname'];
328
+ };
329
+ type Parser<TMeta extends object = any> = {
330
+ name: string;
331
+ type: 'parser';
332
+ /**
333
+ * File extensions this parser handles.
334
+ * Use `undefined` to create a catch-all fallback parser.
335
+ *
336
+ * @example ['.ts', '.js']
337
+ */
338
+ extNames: Array<FileNode['extname']> | undefined;
339
+ /**
340
+ * @deprecated Will be removed once Fabric no longer requires it.
341
+ * @default () => {}
342
+ */
343
+ install(...args: unknown[]): void | Promise<void>;
344
+ /**
345
+ * Convert a resolved file to a string.
346
+ */
347
+ parse(file: FileNode<TMeta>, options?: PrintOptions): Promise<string> | string;
348
+ };
349
+ type UserParser<TMeta extends object = any> = Omit<Parser<TMeta>, 'type' | 'install'> & {
350
+ install?(...args: unknown[]): void | Promise<void>;
351
+ };
352
+ /**
353
+ * Defines a parser with type safety.
354
+ *
355
+ * Use this function to create parsers that transform generated files to strings
356
+ * based on their extension.
357
+ *
358
+ * @example
359
+ * ```ts
360
+ * import { defineParser } from '@kubb/core'
361
+ *
362
+ * export const jsonParser = defineParser({
363
+ * name: 'json',
364
+ * extNames: ['.json'],
365
+ * parse(file) {
366
+ * return file.sources.map((s) => s.value).join('\n')
367
+ * },
368
+ * })
369
+ * ```
370
+ */
371
+ declare function defineParser<TMeta extends object = any>(parser: UserParser<TMeta>): Parser<TMeta>;
372
+ //#endregion
288
373
  //#region src/Kubb.d.ts
289
374
  type DebugInfo = {
290
375
  date: Date;
@@ -354,7 +439,7 @@ interface KubbEvents {
354
439
  /**
355
440
  * Emitted when code generation phase completes.
356
441
  */
357
- 'generation:end': [config: Config, files: Array<FabricFile.ResolvedFile>, sources: Map<FabricFile.Path, string>];
442
+ 'generation:end': [config: Config, files: Array<FileNode>, sources: Map<string, string>];
358
443
  /**
359
444
  * Emitted with a summary of the generation results.
360
445
  * Contains summary lines, title, and success status.
@@ -441,7 +526,7 @@ interface KubbEvents {
441
526
  * Emitted when file processing starts.
442
527
  * Contains the list of files to be processed.
443
528
  */
444
- 'files:processing:start': [files: Array<FabricFile.ResolvedFile>];
529
+ 'files:processing:start': [files: Array<FileNode>];
445
530
  /**
446
531
  * Emitted for each file being processed, providing progress updates.
447
532
  * Contains processed count, total count, percentage, and file details.
@@ -466,7 +551,7 @@ interface KubbEvents {
466
551
  /**
467
552
  * The file being processed.
468
553
  */
469
- file: FabricFile.ResolvedFile;
554
+ file: FileNode;
470
555
  /**
471
556
  * Kubb configuration (not present in Fabric).
472
557
  * Provides access to the current config during file processing.
@@ -477,7 +562,7 @@ interface KubbEvents {
477
562
  * Emitted when file processing completes.
478
563
  * Contains the list of processed files.
479
564
  */
480
- 'files:processing:end': [files: Array<FabricFile.ResolvedFile>];
565
+ 'files:processing:end': [files: Array<FileNode>];
481
566
  /**
482
567
  * Emitted when a plugin starts executing.
483
568
  */
@@ -515,6 +600,132 @@ interface KubbEvents {
515
600
  'plugins:hook:processing:end': [result: HookResult];
516
601
  }
517
602
  //#endregion
603
+ //#region src/defineConfig.d.ts
604
+ /**
605
+ * CLI options derived from command-line flags.
606
+ */
607
+ type CLIOptions = {
608
+ /**
609
+ * Path to `kubb.config.js`.
610
+ */
611
+ config?: string;
612
+ /**
613
+ * Enable watch mode for input files.
614
+ */
615
+ watch?: boolean;
616
+ /**
617
+ * Logging verbosity for CLI usage.
618
+ *
619
+ * - `silent`: hide non-essential logs
620
+ * - `info`: show general logs (non-plugin-related)
621
+ * - `debug`: include detailed plugin lifecycle logs
622
+ * @default 'silent'
623
+ */
624
+ logLevel?: 'silent' | 'info' | 'debug';
625
+ };
626
+ /**
627
+ * All accepted forms of a Kubb configuration.
628
+ */
629
+ type ConfigInput = PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>);
630
+ /**
631
+ * Helper for defining a Kubb configuration.
632
+ *
633
+ * Accepts either:
634
+ * - A config object or array of configs
635
+ * - A function returning the config(s), optionally async,
636
+ * receiving the CLI options as argument
637
+ *
638
+ * @example
639
+ * export default defineConfig(({ logLevel }) => ({
640
+ * root: 'src',
641
+ * plugins: [myPlugin()],
642
+ * }))
643
+ * @deprecated as of Kubb v5, @kubb/core will not expose `defineConfig` anymore. use the `kubb` package instead
644
+ */
645
+ declare function defineConfig(config: (cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>): typeof config;
646
+ declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]>): typeof config;
647
+ //#endregion
648
+ //#region src/utils/FunctionParams.d.ts
649
+ type FunctionParamsASTWithoutType = {
650
+ name?: string;
651
+ type?: string;
652
+ /**
653
+ * @default true
654
+ */
655
+ required?: boolean;
656
+ /**
657
+ * @default true
658
+ */
659
+ enabled?: boolean;
660
+ default?: string;
661
+ };
662
+ type FunctionParamsASTWithType = {
663
+ name?: never;
664
+ type: string;
665
+ /**
666
+ * @default true
667
+ */
668
+ required?: boolean;
669
+ /**
670
+ * @default true
671
+ */
672
+ enabled?: boolean;
673
+ default?: string;
674
+ };
675
+ /**
676
+ * @deprecated use ast package instead
677
+ */
678
+ type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
679
+ /**
680
+ * @deprecated use ast package instead
681
+ */
682
+ declare class FunctionParams {
683
+ #private;
684
+ get items(): FunctionParamsAST[];
685
+ add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
686
+ static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
687
+ toObject(): FunctionParamsAST;
688
+ static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
689
+ toString(): string;
690
+ }
691
+ //#endregion
692
+ //#region src/utils/getBarrelFiles.d.ts
693
+ type FileMetaBase = {
694
+ pluginName?: string;
695
+ };
696
+ type AddIndexesProps = {
697
+ type: BarrelType | false | undefined;
698
+ /**
699
+ * Root based on root and output.path specified in the config
700
+ */
701
+ root: string;
702
+ /**
703
+ * Output for plugin
704
+ */
705
+ output: {
706
+ path: string;
707
+ };
708
+ group?: {
709
+ output: string;
710
+ exportAs: string;
711
+ };
712
+ meta?: FileMetaBase;
713
+ };
714
+ /**
715
+ * Generates `index.ts` barrel files for all directories under `root/output.path`.
716
+ *
717
+ * - Returns an empty array when `type` is falsy or `'propagate'`.
718
+ * - Skips generation when the output path itself ends with `index` (already a barrel).
719
+ * - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
720
+ * - Attaches `meta` to each barrel file for downstream plugin identification.
721
+ */
722
+ declare function getBarrelFiles(files: Array<FileNode>, {
723
+ type,
724
+ meta,
725
+ root,
726
+ output
727
+ }: AddIndexesProps): Promise<Array<FileNode>>;
728
+ //#endregion
518
729
  //#region src/types.d.ts
519
730
  declare global {
520
731
  namespace Kubb {
@@ -548,12 +759,43 @@ declare global {
548
759
  * ...
549
760
  * })
550
761
  */
551
- type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins'> & {
762
+ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter'> & {
552
763
  /**
553
764
  * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
554
765
  * @default process.cwd()
555
766
  */
556
767
  root?: string;
768
+ /**
769
+ * An array of parsers used to convert generated files to strings.
770
+ * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
771
+ *
772
+ * A catch-all fallback parser is always appended last for any unhandled extension.
773
+ *
774
+ * When omitted, `parserTs` from `@kubb/parser-ts` is used automatically as the
775
+ * default (requires `@kubb/parser-ts` to be installed as an optional dependency).
776
+ * @default [parserTs] — from `@kubb/parser-ts`
777
+ * @example
778
+ * ```ts
779
+ * import { parserTs, tsxParser } from '@kubb/parser-ts'
780
+ * export default defineConfig({
781
+ * parsers: [parserTs, tsxParser],
782
+ * })
783
+ * ```
784
+ */
785
+ parsers?: Array<Parser>;
786
+ /**
787
+ * Adapter that converts the input file into a `@kubb/ast` `InputNode` — the universal
788
+ * intermediate representation consumed by all Kubb plugins.
789
+ *
790
+ * When omitted, `adapterOas()` from `@kubb/adapter-oas` is used automatically as the
791
+ * default (requires `@kubb/adapter-oas` to be installed as an optional dependency).
792
+ *
793
+ * - Use `@kubb/adapter-oas` for OpenAPI / Swagger (default).
794
+ * - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
795
+ *
796
+ * @default adapterOas() — from `@kubb/adapter-oas`
797
+ */
798
+ adapter?: Adapter;
557
799
  /**
558
800
  * 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.
559
801
  */
@@ -571,7 +813,7 @@ type InputData = {
571
813
  */
572
814
  data: string | unknown;
573
815
  };
574
- type Input = InputPath | InputData | Array<InputPath>;
816
+ type Input = InputPath | InputData;
575
817
  /**
576
818
  * The raw source passed to an adapter's `parse` function.
577
819
  * Mirrors the shape of `Config['input']` with paths already resolved to absolute.
@@ -602,10 +844,10 @@ type AdapterFactoryOptions<TName extends string = string, TOptions extends objec
602
844
  document: TDocument;
603
845
  };
604
846
  /**
605
- * An adapter converts a source file or data into a `@kubb/ast` `RootNode`.
847
+ * An adapter converts a source file or data into a `@kubb/ast` `InputNode`.
606
848
  *
607
849
  * Adapters are the single entry-point for different schema formats
608
- * (OpenAPI, AsyncAPI, Drizzle, …) and produce the universal `RootNode`
850
+ * (OpenAPI, AsyncAPI, Drizzle, …) and produce the universal `InputNode`
609
851
  * that all Kubb plugins consume.
610
852
  *
611
853
  * @example
@@ -633,13 +875,13 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
633
875
  * `undefined` before parsing; typed by the adapter's `TDocument` generic.
634
876
  */
635
877
  document: TOptions['document'] | null;
636
- rootNode: RootNode | null;
878
+ inputNode: InputNode | null;
637
879
  /**
638
- * Convert the raw source into a universal `RootNode`.
880
+ * Convert the raw source into a universal `InputNode`.
639
881
  */
640
- parse: (source: AdapterSource) => PossiblePromise<RootNode>;
882
+ parse: (source: AdapterSource) => PossiblePromise<InputNode>;
641
883
  /**
642
- * Extracts `FabricFile.Import` entries needed by a `SchemaNode` tree.
884
+ * Extracts `ImportNode` entries needed by a `SchemaNode` tree.
643
885
  * Populated after the first `parse()` call. Returns an empty array before that.
644
886
  *
645
887
  * The `resolve` callback receives the collision-corrected schema name and must
@@ -648,7 +890,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
648
890
  getImports: (node: SchemaNode, resolve: (schemaName: string) => {
649
891
  name: string;
650
892
  path: string;
651
- }) => Array<FabricFile.Import>;
893
+ }) => Array<ImportNode>;
652
894
  };
653
895
  type BarrelType = 'all' | 'named' | 'propagate';
654
896
  type DevtoolsOptions = {
@@ -673,23 +915,40 @@ type Config<TInput = Input> = {
673
915
  */
674
916
  root: string;
675
917
  /**
676
- * Adapter that converts the input file into a `@kubb/ast` `RootNode` — the universal
918
+ * An array of parsers used to convert generated files to strings.
919
+ * Each parser handles specific file extensions (e.g. `.ts`, `.tsx`).
920
+ *
921
+ * A catch-all fallback parser is always appended last for any unhandled extension.
922
+ *
923
+ * When omitted, `parserTs` from `@kubb/parser-ts` is used automatically as the
924
+ * default (requires `@kubb/parser-ts` to be installed as an optional dependency).
925
+ * @default [parserTs] — from `@kubb/parser-ts`
926
+ * @example
927
+ * ```ts
928
+ * import { parserTs, tsxParser } from '@kubb/parser-ts'
929
+ * export default defineConfig({
930
+ * parsers: [parserTs, tsxParser],
931
+ * })
932
+ * ```
933
+ */
934
+ parsers: Array<Parser>;
935
+ /**
936
+ * Adapter that converts the input file into a `@kubb/ast` `InputNode` — the universal
677
937
  * intermediate representation consumed by all Kubb plugins.
678
938
  *
679
- * - Omit (or pass `undefined`) to use the built-in OpenAPI/Swagger adapter.
680
- * - Use `@kubb/adapter-oas` for explicit OpenAPI configuration (validate, contentType, …).
939
+ * - Use `@kubb/adapter-oas` for OpenAPI / Swagger.
681
940
  * - Use `@kubb/adapter-drizzle` or `@kubb/adapter-asyncapi` for other formats.
682
941
  *
683
942
  * @example
684
943
  * ```ts
685
- * import { drizzleAdapter } from '@kubb/adapter-drizzle'
944
+ * import { adapterOas } from '@kubb/adapter-oas'
686
945
  * export default defineConfig({
687
- * adapter: drizzleAdapter(),
688
- * input: { path: './src/schema.ts' },
946
+ * adapter: adapterOas(),
947
+ * input: { path: './petStore.yaml' },
689
948
  * })
690
949
  * ```
691
950
  */
692
- adapter?: Adapter;
951
+ adapter: Adapter;
693
952
  /**
694
953
  * You can use either `input.path` or `input.data`, depending on your specific needs.
695
954
  */
@@ -747,7 +1006,7 @@ type Config<TInput = Input> = {
747
1006
  * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
748
1007
  * @default { '.ts': '.ts'}
749
1008
  */
750
- extension?: Record<FabricFile.Extname, FabricFile.Extname | ''>;
1009
+ extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
751
1010
  /**
752
1011
  * 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`).
753
1012
  * @default 'named'
@@ -839,10 +1098,10 @@ type Resolver = {
839
1098
  pluginName: Plugin['name'];
840
1099
  default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string;
841
1100
  resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
842
- resolvePath(params: ResolverPathParams, context: ResolverContext): FabricFile.Path;
843
- resolveFile(params: ResolverFileParams, context: ResolverContext): FabricFile.File;
844
- resolveBanner(node: RootNode | null, context: ResolveBannerContext): string | undefined;
845
- resolveFooter(node: RootNode | null, context: ResolveBannerContext): string | undefined;
1101
+ resolvePath(params: ResolverPathParams, context: ResolverContext): string;
1102
+ resolveFile(params: ResolverFileParams, context: ResolverContext): FileNode;
1103
+ resolveBanner(node: InputNode | null, context: ResolveBannerContext): string | undefined;
1104
+ resolveFooter(node: InputNode | null, context: ResolveBannerContext): string | undefined;
846
1105
  };
847
1106
  /**
848
1107
  * The user-facing subset of a `Resolver` — everything except the four methods injected by
@@ -959,15 +1218,15 @@ type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<string, object, object,
959
1218
  /**
960
1219
  * Handler for a single schema node. Used by the `schema` hook on a plugin.
961
1220
  */
962
- type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
1221
+ type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
963
1222
  /**
964
1223
  * Handler for a single operation node. Used by the `operation` hook on a plugin.
965
1224
  */
966
- type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
1225
+ type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
967
1226
  /**
968
1227
  * Handler for all collected operation nodes. Used by the `operations` hook on a plugin.
969
1228
  */
970
- type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FabricFile.File> | void>;
1229
+ type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<FabricReactNode | Array<FileNode> | void>;
971
1230
  type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
972
1231
  /**
973
1232
  * Unique name used for the plugin
@@ -1021,7 +1280,7 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1021
1280
  buildEnd: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1022
1281
  /**
1023
1282
  * Called for each schema node during the AST walk.
1024
- * Return a React element, an array of `FabricFile.File`, or `void` for manual handling.
1283
+ * Return a React element, an array of `FileNode`, or `void` for manual handling.
1025
1284
  * Nodes matching `exclude`/`include` filters are skipped automatically.
1026
1285
  *
1027
1286
  * For multiple generators, use `composeGenerators` inside the plugin factory.
@@ -1029,7 +1288,7 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1029
1288
  schema?: SchemaHook<TOptions>;
1030
1289
  /**
1031
1290
  * Called for each operation node during the AST walk.
1032
- * Return a React element, an array of `FabricFile.File`, or `void` for manual handling.
1291
+ * Return a React element, an array of `FileNode`, or `void` for manual handling.
1033
1292
  *
1034
1293
  * For multiple generators, use `composeGenerators` inside the plugin factory.
1035
1294
  */
@@ -1062,7 +1321,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
1062
1321
  buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1063
1322
  /**
1064
1323
  * Called for each schema node during the AST walk.
1065
- * Return a React element (`<File>...</File>`), an array of `FabricFile.File` objects,
1324
+ * Return a React element (`<File>...</File>`), an array of `FileNode` objects,
1066
1325
  * or `void` to handle file writing manually via `this.upsertFile`.
1067
1326
  * Nodes matching `exclude` / `include` filters are skipped automatically.
1068
1327
  *
@@ -1071,7 +1330,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
1071
1330
  schema?: SchemaHook<TOptions>;
1072
1331
  /**
1073
1332
  * Called for each operation node during the AST walk.
1074
- * Return a React element (`<File>...</File>`), an array of `FabricFile.File` objects,
1333
+ * Return a React element (`<File>...</File>`), an array of `FileNode` objects,
1075
1334
  * or `void` to handle file writing manually via `this.upsertFile`.
1076
1335
  *
1077
1336
  * For multiple generators, use `composeGenerators` inside the plugin factory.
@@ -1091,7 +1350,7 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
1091
1350
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
1092
1351
  * @deprecated this will be replaced by resolvers
1093
1352
  */
1094
- resolvePath?: (this: PluginContext<TOptions>, baseName: FabricFile.BaseName, mode?: FabricFile.Mode, options?: TOptions['resolvePathOptions']) => FabricFile.Path;
1353
+ resolvePath?: (this: PluginContext<TOptions>, baseName: FileNode['baseName'], mode?: 'single' | 'split', options?: TOptions['resolvePathOptions']) => string;
1095
1354
  /**
1096
1355
  * Resolve to a name based on a string.
1097
1356
  * Useful when converting to PascalCase or camelCase.
@@ -1105,8 +1364,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
1105
1364
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
1106
1365
  type ResolvePathParams<TOptions = object> = {
1107
1366
  pluginName?: string;
1108
- baseName: FabricFile.BaseName;
1109
- mode?: FabricFile.Mode;
1367
+ baseName: FileNode['baseName'];
1368
+ mode?: 'single' | 'split';
1110
1369
  /**
1111
1370
  * Options to be passed to 'resolvePath' 3th parameter
1112
1371
  */
@@ -1126,7 +1385,6 @@ type ResolveNameParams = {
1126
1385
  type?: 'file' | 'function' | 'type' | 'const';
1127
1386
  };
1128
1387
  type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1129
- fabric: Fabric;
1130
1388
  config: Config;
1131
1389
  /**
1132
1390
  * Absolute path to the output directory for the current plugin.
@@ -1140,7 +1398,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1140
1398
  */
1141
1399
  getMode: (output: {
1142
1400
  path: string;
1143
- }) => FabricFile.Mode;
1401
+ }) => 'single' | 'split';
1144
1402
  driver: PluginDriver;
1145
1403
  /**
1146
1404
  * Get a plugin by name. Returns the plugin typed via `Kubb.PluginRegistry` when
@@ -1157,11 +1415,11 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1157
1415
  /**
1158
1416
  * Only add when the file does not exist yet
1159
1417
  */
1160
- addFile: (...file: Array<FabricFile.File>) => Promise<void>;
1418
+ addFile: (...file: Array<FileNode>) => Promise<void>;
1161
1419
  /**
1162
1420
  * merging multiple sources into the same output file
1163
1421
  */
1164
- upsertFile: (...file: Array<FabricFile.File>) => Promise<void>;
1422
+ upsertFile: (...file: Array<FileNode>) => Promise<void>;
1165
1423
  /**
1166
1424
  * @deprecated use this.warn, this.error, this.info instead
1167
1425
  */
@@ -1195,23 +1453,23 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1195
1453
  */
1196
1454
  info: (message: string) => void;
1197
1455
  /**
1198
- * Opens the Kubb Studio URL for the current `rootNode` in the default browser.
1456
+ * Opens the Kubb Studio URL for the current `inputNode` in the default browser.
1199
1457
  * Falls back to printing the URL if the browser cannot be launched.
1200
- * No-ops silently when no adapter has set a `rootNode`.
1458
+ * No-ops silently when no adapter has set an `inputNode`.
1201
1459
  */
1202
1460
  openInStudio: (options?: DevtoolsOptions) => Promise<void>;
1203
1461
  } & ({
1204
1462
  /**
1205
- * Returns the universal `@kubb/ast` `RootNode` produced by the configured adapter.
1463
+ * Returns the universal `@kubb/ast` `InputNode` produced by the configured adapter.
1206
1464
  * Returns `undefined` when no adapter was set (legacy OAS-only usage).
1207
1465
  */
1208
- rootNode: RootNode;
1466
+ inputNode: InputNode;
1209
1467
  /**
1210
1468
  * Return the adapter from `@kubb/ast`
1211
1469
  */
1212
1470
  adapter: Adapter;
1213
1471
  } | {
1214
- rootNode?: never;
1472
+ inputNode?: never;
1215
1473
  adapter?: never;
1216
1474
  }) & Kubb.PluginContext;
1217
1475
  /**
@@ -1219,12 +1477,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1219
1477
  *
1220
1478
  * Generators and the `schema`/`operation`/`operations` plugin hooks are only invoked from
1221
1479
  * `runPluginAstHooks`, which already guards against a missing adapter. This type reflects
1222
- * that guarantee — `this.adapter` and `this.rootNode` are always defined, so no runtime
1480
+ * that guarantee — `this.adapter` and `this.inputNode` are always defined, so no runtime
1223
1481
  * checks or casts are needed inside the method bodies.
1224
1482
  */
1225
- type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Omit<PluginContext<TOptions>, 'adapter' | 'rootNode'> & {
1483
+ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Omit<PluginContext<TOptions>, 'adapter' | 'inputNode'> & {
1226
1484
  adapter: Adapter;
1227
- rootNode: RootNode;
1485
+ inputNode: InputNode;
1228
1486
  };
1229
1487
  /**
1230
1488
  * Specify the export location for the files and define the behavior of the output
@@ -1242,11 +1500,11 @@ type Output<_TOptions = unknown> = {
1242
1500
  /**
1243
1501
  * Add a banner text in the beginning of every file
1244
1502
  */
1245
- banner?: string | ((node?: RootNode) => string);
1503
+ banner?: string | ((node?: InputNode) => string);
1246
1504
  /**
1247
1505
  * Add a footer text in the beginning of every file
1248
1506
  */
1249
- footer?: string | ((node?: RootNode) => string);
1507
+ footer?: string | ((node?: InputNode) => string);
1250
1508
  /**
1251
1509
  * Whether to override existing external files if they already exist.
1252
1510
  * @default false
@@ -1394,8 +1652,8 @@ type ResolvePathOptions = {
1394
1652
  * ```
1395
1653
  */
1396
1654
  type ResolverPathParams = {
1397
- baseName: FabricFile.BaseName;
1398
- pathMode?: FabricFile.Mode;
1655
+ baseName: FileNode['baseName'];
1656
+ pathMode?: 'single' | 'split';
1399
1657
  /**
1400
1658
  * Tag value used when `group.type === 'tag'`.
1401
1659
  */
@@ -1446,7 +1704,7 @@ type ResolverContext = {
1446
1704
  */
1447
1705
  type ResolverFileParams = {
1448
1706
  name: string;
1449
- extname: FabricFile.Extname;
1707
+ extname: FileNode['extname'];
1450
1708
  /**
1451
1709
  * Tag value used when `group.type === 'tag'`.
1452
1710
  */
@@ -1464,7 +1722,7 @@ type ResolverFileParams = {
1464
1722
  *
1465
1723
  * @example
1466
1724
  * ```ts
1467
- * resolver.resolveBanner(rootNode, { output: { banner: '// generated' }, config })
1725
+ * resolver.resolveBanner(inputNode, { output: { banner: '// generated' }, config })
1468
1726
  * // → '// generated'
1469
1727
  * ```
1470
1728
  */
@@ -1490,7 +1748,6 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
1490
1748
  plugin: Plugin;
1491
1749
  };
1492
1750
  type Options = {
1493
- fabric: Fabric;
1494
1751
  events: AsyncEventEmitter<KubbEvents>;
1495
1752
  /**
1496
1753
  * @default Number.POSITIVE_INFINITY
@@ -1502,8 +1759,8 @@ type Options = {
1502
1759
  */
1503
1760
  type GetFileOptions<TOptions = object> = {
1504
1761
  name: string;
1505
- mode?: FabricFile.Mode;
1506
- extname: FabricFile.Extname;
1762
+ mode?: 'single' | 'split';
1763
+ extname: FileNode['extname'];
1507
1764
  pluginName: string;
1508
1765
  options?: TOptions;
1509
1766
  };
@@ -1516,17 +1773,23 @@ type GetFileOptions<TOptions = object> = {
1516
1773
  * getMode('src/gen/types') // 'split'
1517
1774
  * ```
1518
1775
  */
1519
- declare function getMode(fileOrFolder: string | undefined | null): FabricFile.Mode;
1776
+ declare function getMode(fileOrFolder: string | undefined | null): 'single' | 'split';
1520
1777
  declare class PluginDriver {
1521
1778
  #private;
1522
1779
  readonly config: Config;
1523
1780
  readonly options: Options;
1524
1781
  /**
1525
- * The universal `@kubb/ast` `RootNode` produced by the adapter, set by
1782
+ * The universal `@kubb/ast` `InputNode` produced by the adapter, set by
1526
1783
  * the build pipeline after the adapter's `parse()` resolves.
1527
1784
  */
1528
- rootNode: RootNode | undefined;
1785
+ inputNode: InputNode | undefined;
1529
1786
  adapter: Adapter | undefined;
1787
+ /**
1788
+ * Central file store for all generated files.
1789
+ * Plugins should use `this.addFile()` / `this.upsertFile()` (via their context) to
1790
+ * add files; this property gives direct read/write access when needed.
1791
+ */
1792
+ readonly fileManager: FileManager;
1530
1793
  readonly plugins: Map<string, Plugin>;
1531
1794
  constructor(config: Config, options: Options);
1532
1795
  get events(): AsyncEventEmitter<KubbEvents>;
@@ -1540,13 +1803,13 @@ declare class PluginDriver {
1540
1803
  extname,
1541
1804
  pluginName,
1542
1805
  options
1543
- }: GetFileOptions<TOptions>): FabricFile.File<{
1806
+ }: GetFileOptions<TOptions>): FileNode<{
1544
1807
  pluginName: string;
1545
1808
  }>;
1546
1809
  /**
1547
1810
  * @deprecated use resolvers context instead
1548
1811
  */
1549
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => FabricFile.Path;
1812
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => string;
1550
1813
  /**
1551
1814
  * @deprecated use resolvers context instead
1552
1815
  */
@@ -1628,5 +1891,5 @@ declare class PluginDriver {
1628
1891
  requirePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions>;
1629
1892
  }
1630
1893
  //#endregion
1631
- export { defineGenerator as $, Preset as A, Resolver as B, Plugin as C, PluginLifecycleHooks as D, PluginLifecycle as E, ResolveBannerContext as F, UserConfig as G, ResolverFileParams as H, ResolveNameParams as I, UserPlugin as J, UserGroup as K, ResolveOptionsContext as L, Printer$1 as M, PrinterFactoryOptions as N, PluginParameter as O, PrinterPartial as P, Generator as Q, ResolvePathOptions as R, Override as S, PluginFactoryOptions as T, ResolverPathParams as U, ResolverContext as V, SchemaHook as W, UserResolver as X, UserPluginWithLifeCycle as Y, KubbEvents as Z, LoggerContext as _, AdapterSource as a, logLevel as at, OperationsHook as b, Config as c, GeneratorContext as d, mergeGenerators as et, Group as f, Logger as g, InputPath as h, AdapterFactoryOptions as i, linters as it, Presets as j, PluginWithLifeCycle as k, DevtoolsOptions as l, InputData as m, getMode as n, createStorage as nt, BarrelType as o, PossiblePromise as ot, Include as p, UserLogger as q, Adapter as r, formatters as rt, CompatibilityPreset as s, AsyncEventEmitter as st, PluginDriver as t, Storage as tt, Exclude as u, LoggerOptions as v, PluginContext as w, Output as x, OperationHook as y, ResolvePathParams as z };
1632
- //# sourceMappingURL=PluginDriver-D110FoJ-.d.ts.map
1894
+ export { FunctionParams as $, Preset as A, Resolver as B, Plugin as C, PluginLifecycleHooks as D, PluginLifecycle as E, ResolveBannerContext as F, UserConfig as G, ResolverFileParams as H, ResolveNameParams as I, UserPlugin as J, UserGroup as K, ResolveOptionsContext as L, Printer$1 as M, PrinterFactoryOptions as N, PluginParameter as O, PrinterPartial as P, getBarrelFiles as Q, ResolvePathOptions as R, Override as S, PluginFactoryOptions as T, ResolverPathParams as U, ResolverContext as V, SchemaHook as W, UserResolver as X, UserPluginWithLifeCycle as Y, FileMetaBase as Z, LoggerContext as _, AdapterSource as a, Parser as at, OperationsHook as b, Config as c, Generator as ct, GeneratorContext as d, Storage as dt, FunctionParamsAST as et, Group as f, createStorage as ft, Logger as g, AsyncEventEmitter as gt, InputPath as h, logLevel as ht, AdapterFactoryOptions as i, KubbEvents as it, Presets as j, PluginWithLifeCycle as k, DevtoolsOptions as l, defineGenerator as lt, InputData as m, linters as mt, getMode as n, ConfigInput as nt, BarrelType as o, UserParser as ot, Include as p, formatters as pt, UserLogger as q, Adapter as r, defineConfig as rt, CompatibilityPreset as s, defineParser as st, PluginDriver as t, CLIOptions as tt, Exclude as u, mergeGenerators as ut, LoggerOptions as v, PluginContext as w, Output as x, OperationHook as y, ResolvePathParams as z };
1895
+ //# sourceMappingURL=PluginDriver-nm7tvGs9.d.ts.map