@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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { $ as defineGenerator, A as Preset, B as Resolver, C as Plugin, D as PluginLifecycleHooks, E as PluginLifecycle, F as ResolveBannerContext, G as UserConfig, H as ResolverFileParams, I as ResolveNameParams, J as UserPlugin, K as UserGroup, L as ResolveOptionsContext, M as Printer, N as PrinterFactoryOptions, O as PluginParameter, P as PrinterPartial, Q as Generator, R as ResolvePathOptions, S as Override, T as PluginFactoryOptions, U as ResolverPathParams, V as ResolverContext, W as SchemaHook, X as UserResolver, Y as UserPluginWithLifeCycle, Z as KubbEvents, _ as LoggerContext, a as AdapterSource, at as logLevel, b as OperationsHook, c as Config, d as GeneratorContext, et as mergeGenerators, f as Group, g as Logger, h as InputPath, i as AdapterFactoryOptions, it as linters, j as Presets, k as PluginWithLifeCycle, l as DevtoolsOptions, m as InputData, n as getMode, nt as createStorage, o as BarrelType, ot as PossiblePromise, p as Include, q as UserLogger, r as Adapter, rt as formatters, s as CompatibilityPreset, st as AsyncEventEmitter, t as PluginDriver, tt as Storage, u as Exclude, v as LoggerOptions, w as PluginContext, x as Output, y as OperationHook, z as ResolvePathParams } from "./PluginDriver-D110FoJ-.js";
1
+ import { n as __name } from "./chunk-O_arW02_.js";
2
+ import { $ as FunctionParams, A as Preset, B as Resolver, C as Plugin, D as PluginLifecycleHooks, E as PluginLifecycle, F as ResolveBannerContext, G as UserConfig, H as ResolverFileParams, I as ResolveNameParams, J as UserPlugin, K as UserGroup, L as ResolveOptionsContext, M as Printer, N as PrinterFactoryOptions, O as PluginParameter, P as PrinterPartial, Q as getBarrelFiles, R as ResolvePathOptions, S as Override, T as PluginFactoryOptions, U as ResolverPathParams, V as ResolverContext, W as SchemaHook, X as UserResolver, Y as UserPluginWithLifeCycle, Z as FileMetaBase, _ as LoggerContext, _t as KubbFile_d_exports, a as AdapterSource, at as Parser, b as OperationsHook, bt as ResolvedFile, c as Config, ct as Generator, d as GeneratorContext, dt as Storage, et as FunctionParamsAST, f as Group, ft as createStorage, g as Logger, gt as File, h as InputPath, ht as logLevel, i as AdapterFactoryOptions, it as KubbEvents, j as Presets, k as PluginWithLifeCycle, l as DevtoolsOptions, lt as defineGenerator, m as InputData, mt as linters, n as getMode, nt as ConfigInput, o as BarrelType, ot as UserParser, p as Include, pt as formatters, q as UserLogger, r as Adapter, rt as defineConfig, s as CompatibilityPreset, st as defineParser, t as PluginDriver, tt as CLIOptions, u as Exclude, ut as mergeGenerators, v as LoggerOptions, w as PluginContext, x as Output, xt as AsyncEventEmitter, y as OperationHook, yt as Path, z as ResolvePathParams } from "./PluginDriver-D0dY_hpJ.js";
3
3
  import { composeTransformers, definePrinter } from "@kubb/ast";
4
4
  import { Node, RootNode, Visitor } from "@kubb/ast/types";
5
- import { Fabric, FabricFile } from "@kubb/fabric-core/types";
5
+ import { Fabric } from "@kubb/fabric-core/types";
6
6
 
7
7
  //#region ../../internals/utils/src/urlPath.d.ts
8
8
  type URLObject = {
@@ -157,7 +157,7 @@ type BuildOutput = {
157
157
  error: Error;
158
158
  }>;
159
159
  fabric: Fabric;
160
- files: Array<FabricFile.ResolvedFile>;
160
+ files: Array<ResolvedFile>;
161
161
  driver: PluginDriver;
162
162
  /**
163
163
  * Elapsed time in milliseconds for each plugin, keyed by plugin name.
@@ -167,7 +167,7 @@ type BuildOutput = {
167
167
  /**
168
168
  * Raw generated source, keyed by absolute file path.
169
169
  */
170
- sources: Map<FabricFile.Path, string>;
170
+ sources: Map<Path, string>;
171
171
  };
172
172
  /**
173
173
  * Intermediate result returned by {@link setup} and accepted by {@link safeBuild}.
@@ -176,7 +176,8 @@ type SetupResult = {
176
176
  events: AsyncEventEmitter<KubbEvents>;
177
177
  fabric: Fabric;
178
178
  driver: PluginDriver;
179
- sources: Map<FabricFile.Path, string>;
179
+ sources: Map<Path, string>;
180
+ config: Config;
180
181
  };
181
182
  /**
182
183
  * Initializes all Kubb infrastructure for a build without executing any plugins.
@@ -185,6 +186,7 @@ type SetupResult = {
185
186
  * - Applies config defaults (`root`, `output.*`, `devtools`).
186
187
  * - Creates the Fabric instance and wires storage, format, and lint hooks.
187
188
  * - Runs the adapter (if configured) to produce the universal `RootNode`.
189
+ * When no adapter is supplied and `@kubb/adapter-oas` is installed as an
188
190
  *
189
191
  * Pass the returned {@link SetupResult} directly to {@link safeBuild} or {@link build}
190
192
  * via the `overrides` argument to reuse the same infrastructure across multiple runs.
@@ -209,54 +211,6 @@ declare function build(options: BuildOptions, overrides?: SetupResult): Promise<
209
211
  */
210
212
  declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
211
213
  //#endregion
212
- //#region src/config.d.ts
213
- /**
214
- * CLI options derived from command-line flags.
215
- */
216
- type CLIOptions = {
217
- /**
218
- * Path to `kubb.config.js`.
219
- */
220
- config?: string;
221
- /**
222
- * Enable watch mode for input files.
223
- */
224
- watch?: boolean;
225
- /**
226
- * Logging verbosity for CLI usage.
227
- *
228
- * - `silent`: hide non-essential logs
229
- * - `info`: show general logs (non-plugin-related)
230
- * - `debug`: include detailed plugin lifecycle logs
231
- * @default 'silent'
232
- */
233
- logLevel?: 'silent' | 'info' | 'debug';
234
- };
235
- /**
236
- * All accepted forms of a Kubb configuration.
237
- */
238
- type ConfigInput = PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>);
239
- /**
240
- * Helper for defining a Kubb configuration.
241
- *
242
- * Accepts either:
243
- * - A config object or array of configs
244
- * - A function returning the config(s), optionally async,
245
- * receiving the CLI options as argument
246
- *
247
- * @example
248
- * export default defineConfig(({ logLevel }) => ({
249
- * root: 'src',
250
- * plugins: [myPlugin()],
251
- * }))
252
- */
253
- declare function defineConfig(config: (cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>): typeof config;
254
- declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]>): typeof config;
255
- /**
256
- * Type guard to check if a given config has an `input.path`.
257
- */
258
- declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
259
- //#endregion
260
214
  //#region src/createAdapter.d.ts
261
215
  /**
262
216
  * Builder type for an {@link Adapter} — takes options and returns the adapter instance.
@@ -426,11 +380,11 @@ declare function defaultResolvePath({
426
380
  root,
427
381
  output,
428
382
  group
429
- }: ResolverContext): FabricFile.Path;
383
+ }: ResolverContext): Path;
430
384
  /**
431
385
  * Default file resolver used by `defineResolver`.
432
386
  *
433
- * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
387
+ * Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
434
388
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
435
389
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
436
390
  *
@@ -459,7 +413,7 @@ declare function defaultResolveFile(this: Resolver, {
459
413
  extname,
460
414
  tag,
461
415
  path: groupPath
462
- }: ResolverFileParams, context: ResolverContext): FabricFile.File;
416
+ }: ResolverFileParams, context: ResolverContext): File;
463
417
  /**
464
418
  * Generates the default "Generated by Kubb" banner from config and optional node metadata.
465
419
  */
@@ -546,7 +500,7 @@ declare function defaultResolveFooter(node: RootNode | undefined, {
546
500
  * - `default` — name casing strategy (camelCase / PascalCase)
547
501
  * - `resolveOptions` — include/exclude/override filtering
548
502
  * - `resolvePath` — output path computation
549
- * - `resolveFile` — full `FabricFile.File` construction
503
+ * - `resolveFile` — full `KubbFile.File` construction
550
504
  *
551
505
  * Methods in the builder have access to `this` (the full resolver object), so they
552
506
  * can call other resolver methods without circular imports.
@@ -632,50 +586,6 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
632
586
  */
633
587
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
634
588
  //#endregion
635
- //#region src/utils/FunctionParams.d.ts
636
- type FunctionParamsASTWithoutType = {
637
- name?: string;
638
- type?: string;
639
- /**
640
- * @default true
641
- */
642
- required?: boolean;
643
- /**
644
- * @default true
645
- */
646
- enabled?: boolean;
647
- default?: string;
648
- };
649
- type FunctionParamsASTWithType = {
650
- name?: never;
651
- type: string;
652
- /**
653
- * @default true
654
- */
655
- required?: boolean;
656
- /**
657
- * @default true
658
- */
659
- enabled?: boolean;
660
- default?: string;
661
- };
662
- /**
663
- * @deprecated use ast package instead
664
- */
665
- type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
666
- /**
667
- * @deprecated use ast package instead
668
- */
669
- declare class FunctionParams {
670
- #private;
671
- get items(): FunctionParamsAST[];
672
- add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
673
- static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
674
- toObject(): FunctionParamsAST;
675
- static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
676
- toString(): string;
677
- }
678
- //#endregion
679
589
  //#region src/utils/formatters.d.ts
680
590
  type Formatter = keyof typeof formatters;
681
591
  /**
@@ -694,43 +604,6 @@ type Formatter = keyof typeof formatters;
694
604
  */
695
605
  declare function detectFormatter(): Promise<Formatter | null>;
696
606
  //#endregion
697
- //#region src/utils/getBarrelFiles.d.ts
698
- type FileMetaBase = {
699
- pluginName?: string;
700
- };
701
- type AddIndexesProps = {
702
- type: BarrelType | false | undefined;
703
- /**
704
- * Root based on root and output.path specified in the config
705
- */
706
- root: string;
707
- /**
708
- * Output for plugin
709
- */
710
- output: {
711
- path: string;
712
- };
713
- group?: {
714
- output: string;
715
- exportAs: string;
716
- };
717
- meta?: FileMetaBase;
718
- };
719
- /**
720
- * Generates `index.ts` barrel files for all directories under `root/output.path`.
721
- *
722
- * - Returns an empty array when `type` is falsy or `'propagate'`.
723
- * - Skips generation when the output path itself ends with `index` (already a barrel).
724
- * - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
725
- * - Attaches `meta` to each barrel file for downstream plugin identification.
726
- */
727
- declare function getBarrelFiles(files: Array<FabricFile.ResolvedFile>, {
728
- type,
729
- meta,
730
- root,
731
- output
732
- }: AddIndexesProps): Promise<Array<FabricFile.File>>;
733
- //#endregion
734
607
  //#region src/utils/getConfigs.d.ts
735
608
  /**
736
609
  * Resolves a {@link ConfigInput} into a normalized array of {@link Config} objects.
@@ -775,6 +648,12 @@ type GetPresetResult<TResolver extends Resolver> = {
775
648
  */
776
649
  declare function getPreset<TResolver extends Resolver = Resolver>(params: GetPresetParams<TResolver>): GetPresetResult<TResolver>;
777
650
  //#endregion
651
+ //#region src/utils/isInputPath.d.ts
652
+ /**
653
+ * Type guard to check if a given config has an `input.path`.
654
+ */
655
+ declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
656
+ //#endregion
778
657
  //#region src/utils/linters.d.ts
779
658
  type Linter = keyof typeof linters;
780
659
  /**
@@ -813,5 +692,5 @@ type DependencyVersion = string;
813
692
  */
814
693
  declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
815
694
  //#endregion
816
- export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, DevtoolsOptions, Exclude, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, GeneratorContext, Group, Include, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, OperationHook, OperationsHook, Output, Override, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, PrinterPartial, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, SchemaHook, Storage, URLPath, UserConfig, UserGroup, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, composeTransformers, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeGenerators, safeBuild, satisfiesDependency, setup };
695
+ export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileMetaBase, FunctionParams, FunctionParamsAST, Generator, GeneratorContext, Group, Include, InputData, InputPath, KubbEvents, KubbFile_d_exports as KubbFile, Logger, LoggerContext, LoggerOptions, OperationHook, OperationsHook, Output, Override, Parser, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, PrinterPartial, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, SchemaHook, Storage, URLPath, UserConfig, UserGroup, UserLogger, UserParser, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, composeTransformers, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, defineParser, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeGenerators, safeBuild, satisfiesDependency, setup };
817
696
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
- import "./chunk--u3MIqq1.js";
1
+ import { t as __exportAll } from "./chunk-O_arW02_.js";
2
2
  import { EventEmitter } from "node:events";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { access, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
5
5
  import path, { basename, dirname, extname, join, posix, relative, resolve } from "node:path";
6
6
  import { composeTransformers, composeTransformers as composeTransformers$1, definePrinter, isOperationNode, isSchemaNode, transform, walk } from "@kubb/ast";
7
7
  import { Fabric, createFabric, createReactFabric } from "@kubb/react-fabric";
8
- import { typescriptParser } from "@kubb/react-fabric/parsers";
9
8
  import { fsPlugin } from "@kubb/react-fabric/plugins";
10
9
  import { performance } from "node:perf_hooks";
11
10
  import { deflateSync } from "fflate";
@@ -615,17 +614,6 @@ var URLPath = class {
615
614
  }
616
615
  };
617
616
  //#endregion
618
- //#region src/config.ts
619
- function defineConfig(config) {
620
- return config;
621
- }
622
- /**
623
- * Type guard to check if a given config has an `input.path`.
624
- */
625
- function isInputPath(config) {
626
- return typeof config?.input === "object" && config.input !== null && "path" in config.input;
627
- }
628
- //#endregion
629
617
  //#region src/constants.ts
630
618
  /**
631
619
  * Base URL for the Kubb Studio web app.
@@ -717,6 +705,34 @@ const formatters = {
717
705
  }
718
706
  };
719
707
  //#endregion
708
+ //#region src/defineParser.ts
709
+ /**
710
+ * Defines a parser with type safety.
711
+ *
712
+ * Use this function to create parsers that transform generated files to strings
713
+ * based on their extension.
714
+ *
715
+ * @example
716
+ * ```ts
717
+ * import { defineParser } from '@kubb/core'
718
+ *
719
+ * export const jsonParser = defineParser({
720
+ * name: 'json',
721
+ * extNames: ['.json'],
722
+ * parse(file) {
723
+ * return file.sources.map((s) => s.value).join('\n')
724
+ * },
725
+ * })
726
+ * ```
727
+ */
728
+ function defineParser(parser) {
729
+ return {
730
+ install() {},
731
+ type: "parser",
732
+ ...parser
733
+ };
734
+ }
735
+ //#endregion
720
736
  //#region src/devtools.ts
721
737
  /**
722
738
  * Encodes a `RootNode` as a compressed, URL-safe string.
@@ -1351,7 +1367,7 @@ var PluginDriver = class {
1351
1367
  * Handles the return value of a plugin AST hook or generator method.
1352
1368
  *
1353
1369
  * - React element → rendered via an isolated react-fabric context, files merged into `fabric`
1354
- * - `Array<FabricFile.File>` → upserted directly into `fabric`
1370
+ * - `Array<KubbFile.File>` → upserted directly into `fabric`
1355
1371
  * - `void` / `null` / `undefined` → no-op (plugin handled it via `this.upsertFile`)
1356
1372
  */
1357
1373
  async function applyHookResult(result, fabric) {
@@ -1463,7 +1479,7 @@ const fsStorage = createStorage(() => ({
1463
1479
  }));
1464
1480
  //#endregion
1465
1481
  //#region package.json
1466
- var version$1 = "5.0.0-alpha.30";
1482
+ var version$1 = "5.0.0-alpha.31";
1467
1483
  //#endregion
1468
1484
  //#region src/utils/diagnostics.ts
1469
1485
  /**
@@ -1485,7 +1501,7 @@ function getDiagnosticInfo() {
1485
1501
  //#region src/utils/TreeNode.ts
1486
1502
  /**
1487
1503
  * Tree structure used to build per-directory barrel (`index.ts`) files from a
1488
- * flat list of generated {@link FabricFile.File} entries.
1504
+ * flat list of generated {@link KubbFile.File} entries.
1489
1505
  *
1490
1506
  * Each node represents either a directory or a file within the output tree.
1491
1507
  * Use {@link TreeNode.build} to construct a root node from a file list, then
@@ -1717,6 +1733,14 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
1717
1733
  });
1718
1734
  }
1719
1735
  //#endregion
1736
+ //#region src/utils/isInputPath.ts
1737
+ /**
1738
+ * Type guard to check if a given config has an `input.path`.
1739
+ */
1740
+ function isInputPath(config) {
1741
+ return typeof config?.input === "object" && config.input !== null && "path" in config.input;
1742
+ }
1743
+ //#endregion
1720
1744
  //#region src/build.ts
1721
1745
  /**
1722
1746
  * Initializes all Kubb infrastructure for a build without executing any plugins.
@@ -1725,6 +1749,7 @@ async function getBarrelFiles(files, { type, meta = {}, root, output }) {
1725
1749
  * - Applies config defaults (`root`, `output.*`, `devtools`).
1726
1750
  * - Creates the Fabric instance and wires storage, format, and lint hooks.
1727
1751
  * - Runs the adapter (if configured) to produce the universal `RootNode`.
1752
+ * When no adapter is supplied and `@kubb/adapter-oas` is installed as an
1728
1753
  *
1729
1754
  * Pass the returned {@link SetupResult} directly to {@link safeBuild} or {@link build}
1730
1755
  * via the `overrides` argument to reuse the same infrastructure across multiple runs.
@@ -1764,9 +1789,12 @@ async function setup(options) {
1764
1789
  throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`, { cause: error });
1765
1790
  }
1766
1791
  }
1767
- const definedConfig = {
1792
+ if (!userConfig.adapter) throw new Error("Adapter should be defined");
1793
+ const config = {
1768
1794
  root: userConfig.root || process.cwd(),
1769
1795
  ...userConfig,
1796
+ parsers: userConfig.parsers ?? [],
1797
+ adapter: userConfig.adapter,
1770
1798
  output: {
1771
1799
  write: true,
1772
1800
  barrelType: "named",
@@ -1780,17 +1808,24 @@ async function setup(options) {
1780
1808
  } : void 0,
1781
1809
  plugins: userConfig.plugins
1782
1810
  };
1783
- const storage = definedConfig.output.write === false ? null : definedConfig.output.storage ?? fsStorage();
1784
- if (definedConfig.output.clean) {
1811
+ const storage = config.output.write === false ? null : config.output.storage ?? fsStorage();
1812
+ if (config.output.clean) {
1785
1813
  await events.emit("debug", {
1786
1814
  date: /* @__PURE__ */ new Date(),
1787
- logs: ["Cleaning output directories", ` • Output: ${definedConfig.output.path}`]
1815
+ logs: ["Cleaning output directories", ` • Output: ${config.output.path}`]
1788
1816
  });
1789
- await storage?.clear(resolve(definedConfig.root, definedConfig.output.path));
1817
+ await storage?.clear(resolve(config.root, config.output.path));
1790
1818
  }
1791
1819
  const fabric = createFabric();
1792
1820
  fabric.use(fsPlugin);
1793
- fabric.use(typescriptParser);
1821
+ for (const parser of config.parsers) fabric.use(parser);
1822
+ fabric.use(defineParser({
1823
+ name: "fallback",
1824
+ extNames: void 0,
1825
+ parse(file) {
1826
+ return file.sources.map((item) => item.value).filter((value) => value != null).join("\n\n");
1827
+ }
1828
+ }));
1794
1829
  fabric.context.on("files:processing:start", (files) => {
1795
1830
  events.emit("files:processing:start", files);
1796
1831
  events.emit("debug", {
@@ -1802,11 +1837,11 @@ async function setup(options) {
1802
1837
  const { file, source } = params;
1803
1838
  await events.emit("file:processing:update", {
1804
1839
  ...params,
1805
- config: definedConfig,
1840
+ config,
1806
1841
  source
1807
1842
  });
1808
1843
  if (source) {
1809
- const key = relative(resolve(definedConfig.root), file.path);
1844
+ const key = relative(resolve(config.root), file.path);
1810
1845
  await storage?.setItem(key, source);
1811
1846
  sources.set(file.path, source);
1812
1847
  }
@@ -1823,35 +1858,36 @@ async function setup(options) {
1823
1858
  logs: [
1824
1859
  "✓ Fabric initialized",
1825
1860
  ` • Storage: ${storage ? storage.name : "disabled (dry-run)"}`,
1826
- ` • Barrel type: ${definedConfig.output.barrelType || "none"}`
1861
+ ` • Barrel type: ${config.output.barrelType || "none"}`
1827
1862
  ]
1828
1863
  });
1829
- const pluginDriver = new PluginDriver(definedConfig, {
1864
+ const driver = new PluginDriver(config, {
1830
1865
  fabric,
1831
1866
  events,
1832
1867
  concurrency: 15
1833
1868
  });
1834
- if (definedConfig.adapter) {
1835
- const source = inputToAdapterSource(definedConfig);
1836
- await events.emit("debug", {
1837
- date: /* @__PURE__ */ new Date(),
1838
- logs: [`Running adapter: ${definedConfig.adapter.name}`]
1839
- });
1840
- pluginDriver.adapter = definedConfig.adapter;
1841
- pluginDriver.rootNode = await definedConfig.adapter.parse(source);
1842
- await events.emit("debug", {
1843
- date: /* @__PURE__ */ new Date(),
1844
- logs: [
1845
- `✓ Adapter '${definedConfig.adapter.name}' resolved RootNode`,
1846
- ` • Schemas: ${pluginDriver.rootNode.schemas.length}`,
1847
- ` • Operations: ${pluginDriver.rootNode.operations.length}`
1848
- ]
1849
- });
1850
- }
1869
+ const adapter = config.adapter;
1870
+ if (!adapter) throw new Error("No adapter configured. Please provide an adapter in your kubb.config.ts.");
1871
+ const source = inputToAdapterSource(config);
1872
+ await events.emit("debug", {
1873
+ date: /* @__PURE__ */ new Date(),
1874
+ logs: [`Running adapter: ${adapter.name}`]
1875
+ });
1876
+ driver.adapter = adapter;
1877
+ driver.rootNode = await adapter.parse(source);
1878
+ await events.emit("debug", {
1879
+ date: /* @__PURE__ */ new Date(),
1880
+ logs: [
1881
+ `✓ Adapter '${adapter.name}' resolved RootNode`,
1882
+ ` • Schemas: ${driver.rootNode.schemas.length}`,
1883
+ ` • Operations: ${driver.rootNode.operations.length}`
1884
+ ]
1885
+ });
1851
1886
  return {
1887
+ config,
1852
1888
  events,
1853
1889
  fabric,
1854
- driver: pluginDriver,
1890
+ driver,
1855
1891
  sources
1856
1892
  };
1857
1893
  }
@@ -1885,7 +1921,7 @@ async function build(options, overrides) {
1885
1921
  * - Each hook accepts a single handler **or an array** — all entries are called in sequence.
1886
1922
  * - Nodes that are excluded by `exclude`/`include` plugin options are skipped automatically.
1887
1923
  * - Return values are handled via `applyHookResult`: React elements are rendered,
1888
- * `FabricFile.File[]` are written via upsert, and `void` is a no-op (manual handling).
1924
+ * `KubbFile.File[]` are written via upsert, and `void` is a no-op (manual handling).
1889
1925
  * - Barrel files are generated automatically when `output.barrelType` is set.
1890
1926
  */
1891
1927
  async function runPluginAstHooks(plugin, context) {
@@ -2148,6 +2184,11 @@ function createPlugin(build) {
2148
2184
  return (options) => build(options ?? {});
2149
2185
  }
2150
2186
  //#endregion
2187
+ //#region src/defineConfig.ts
2188
+ function defineConfig(config) {
2189
+ return config;
2190
+ }
2191
+ //#endregion
2151
2192
  //#region src/defineGenerator.ts
2152
2193
  /**
2153
2194
  * Defines a generator. Returns the object as-is with correct `this` typings.
@@ -2373,7 +2414,7 @@ function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root
2373
2414
  /**
2374
2415
  * Default file resolver used by `defineResolver`.
2375
2416
  *
2376
- * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
2417
+ * Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
2377
2418
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
2378
2419
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
2379
2420
  *
@@ -2523,7 +2564,7 @@ function defaultResolveFooter(node, { output }) {
2523
2564
  * - `default` — name casing strategy (camelCase / PascalCase)
2524
2565
  * - `resolveOptions` — include/exclude/override filtering
2525
2566
  * - `resolvePath` — output path computation
2526
- * - `resolveFile` — full `FabricFile.File` construction
2567
+ * - `resolveFile` — full `KubbFile.File` construction
2527
2568
  *
2528
2569
  * Methods in the builder have access to `this` (the full resolver object), so they
2529
2570
  * can call other resolver methods without circular imports.
@@ -2573,6 +2614,9 @@ function defineResolver(build) {
2573
2614
  };
2574
2615
  }
2575
2616
  //#endregion
2617
+ //#region src/KubbFile.ts
2618
+ var KubbFile_exports = /* @__PURE__ */ __exportAll({});
2619
+ //#endregion
2576
2620
  //#region src/storages/memoryStorage.ts
2577
2621
  /**
2578
2622
  * In-memory storage driver. Useful for testing and dry-run scenarios where
@@ -2875,6 +2919,6 @@ function satisfiesDependency(dependency, version, cwd) {
2875
2919
  return satisfies(semVer, version);
2876
2920
  }
2877
2921
  //#endregion
2878
- export { AsyncEventEmitter, FunctionParams, PluginDriver, URLPath, build, build as default, buildDefaultBanner, composeTransformers, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeGenerators, safeBuild, satisfiesDependency, setup };
2922
+ export { AsyncEventEmitter, FunctionParams, KubbFile_exports as KubbFile, PluginDriver, URLPath, build, build as default, buildDefaultBanner, composeTransformers, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineConfig, defineGenerator, defineLogger, defineParser, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeGenerators, safeBuild, satisfiesDependency, setup };
2879
2923
 
2880
2924
  //# sourceMappingURL=index.js.map