@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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
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";
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, a as AdapterSource, at as Parser, b as OperationsHook, 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 AsyncEventEmitter, 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, y as OperationHook, z as ResolvePathParams } from "./PluginDriver-nm7tvGs9.js";
3
3
  import { composeTransformers, definePrinter } from "@kubb/ast";
4
- import { Node, RootNode, Visitor } from "@kubb/ast/types";
5
- import { Fabric, FabricFile } from "@kubb/fabric-core/types";
4
+ import { FileNode, InputNode, Node, Visitor } from "@kubb/ast/types";
6
5
 
7
6
  //#region ../../internals/utils/src/urlPath.d.ts
8
7
  type URLObject = {
@@ -156,8 +155,7 @@ type BuildOutput = {
156
155
  plugin: Plugin;
157
156
  error: Error;
158
157
  }>;
159
- fabric: Fabric;
160
- files: Array<FabricFile.ResolvedFile>;
158
+ files: Array<FileNode>;
161
159
  driver: PluginDriver;
162
160
  /**
163
161
  * Elapsed time in milliseconds for each plugin, keyed by plugin name.
@@ -167,16 +165,17 @@ type BuildOutput = {
167
165
  /**
168
166
  * Raw generated source, keyed by absolute file path.
169
167
  */
170
- sources: Map<FabricFile.Path, string>;
168
+ sources: Map<string, string>;
171
169
  };
172
170
  /**
173
171
  * Intermediate result returned by {@link setup} and accepted by {@link safeBuild}.
174
172
  */
175
173
  type SetupResult = {
176
174
  events: AsyncEventEmitter<KubbEvents>;
177
- fabric: Fabric;
178
175
  driver: PluginDriver;
179
- sources: Map<FabricFile.Path, string>;
176
+ sources: Map<string, string>;
177
+ config: Config;
178
+ storage: Storage | null;
180
179
  };
181
180
  /**
182
181
  * Initializes all Kubb infrastructure for a build without executing any plugins.
@@ -184,7 +183,8 @@ type SetupResult = {
184
183
  * - Validates the input path (when applicable).
185
184
  * - Applies config defaults (`root`, `output.*`, `devtools`).
186
185
  * - Creates the Fabric instance and wires storage, format, and lint hooks.
187
- * - Runs the adapter (if configured) to produce the universal `RootNode`.
186
+ * - Runs the adapter (if configured) to produce the universal `InputNode`.
187
+ * When no adapter is supplied and `@kubb/adapter-oas` is installed as an
188
188
  *
189
189
  * Pass the returned {@link SetupResult} directly to {@link safeBuild} or {@link build}
190
190
  * via the `overrides` argument to reuse the same infrastructure across multiple runs.
@@ -202,61 +202,13 @@ declare function build(options: BuildOptions, overrides?: SetupResult): Promise<
202
202
  *
203
203
  * - Installs each plugin in order, recording failures in `failedPlugins`.
204
204
  * - Generates the root barrel file when `output.barrelType` is set.
205
- * - Writes all files through Fabric.
205
+ * - Writes all files through the driver's FileManager and FileProcessor.
206
206
  *
207
207
  * Returns a {@link BuildOutput} even on failure — inspect `error` and
208
208
  * `failedPlugins` to determine whether the build succeeded.
209
209
  */
210
210
  declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
211
211
  //#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
212
  //#region src/createAdapter.d.ts
261
213
  /**
262
214
  * Builder type for an {@link Adapter} — takes options and returns the adapter instance.
@@ -426,11 +378,11 @@ declare function defaultResolvePath({
426
378
  root,
427
379
  output,
428
380
  group
429
- }: ResolverContext): FabricFile.Path;
381
+ }: ResolverContext): string;
430
382
  /**
431
383
  * Default file resolver used by `defineResolver`.
432
384
  *
433
- * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
385
+ * Resolves a `FileNode` by combining name resolution (`resolver.default`) with
434
386
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
435
387
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
436
388
  *
@@ -459,7 +411,7 @@ declare function defaultResolveFile(this: Resolver, {
459
411
  extname,
460
412
  tag,
461
413
  path: groupPath
462
- }: ResolverFileParams, context: ResolverContext): FabricFile.File;
414
+ }: ResolverFileParams, context: ResolverContext): FileNode;
463
415
  /**
464
416
  * Generates the default "Generated by Kubb" banner from config and optional node metadata.
465
417
  */
@@ -495,13 +447,13 @@ declare function buildDefaultBanner({
495
447
  *
496
448
  * @example Function banner with node
497
449
  * ```ts
498
- * defaultResolveBanner(rootNode, { output: { banner: (node) => `// v${node.version}` }, config })
450
+ * defaultResolveBanner(inputNode, { output: { banner: (node) => `// v${node.version}` }, config })
499
451
  * // → '// v3.0.0'
500
452
  * ```
501
453
  *
502
454
  * @example No user banner — Kubb notice with OAS metadata
503
455
  * ```ts
504
- * defaultResolveBanner(rootNode, { config })
456
+ * defaultResolveBanner(inputNode, { config })
505
457
  * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
506
458
  * ```
507
459
  *
@@ -511,7 +463,7 @@ declare function buildDefaultBanner({
511
463
  * // → undefined
512
464
  * ```
513
465
  */
514
- declare function defaultResolveBanner(node: RootNode | undefined, {
466
+ declare function defaultResolveBanner(node: InputNode | undefined, {
515
467
  output,
516
468
  config
517
469
  }: ResolveBannerContext): string | undefined;
@@ -531,11 +483,11 @@ declare function defaultResolveBanner(node: RootNode | undefined, {
531
483
  *
532
484
  * @example Function footer with node
533
485
  * ```ts
534
- * defaultResolveFooter(rootNode, { output: { footer: (node) => `// ${node.title}` }, config })
486
+ * defaultResolveFooter(inputNode, { output: { footer: (node) => `// ${node.title}` }, config })
535
487
  * // → '// Pet Store'
536
488
  * ```
537
489
  */
538
- declare function defaultResolveFooter(node: RootNode | undefined, {
490
+ declare function defaultResolveFooter(node: InputNode | undefined, {
539
491
  output
540
492
  }: ResolveBannerContext): string | undefined;
541
493
  /**
@@ -546,7 +498,7 @@ declare function defaultResolveFooter(node: RootNode | undefined, {
546
498
  * - `default` — name casing strategy (camelCase / PascalCase)
547
499
  * - `resolveOptions` — include/exclude/override filtering
548
500
  * - `resolvePath` — output path computation
549
- * - `resolveFile` — full `FabricFile.File` construction
501
+ * - `resolveFile` — full `FileNode` construction
550
502
  *
551
503
  * Methods in the builder have access to `this` (the full resolver object), so they
552
504
  * can call other resolver methods without circular imports.
@@ -632,50 +584,6 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
632
584
  */
633
585
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
634
586
  //#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
587
  //#region src/utils/formatters.d.ts
680
588
  type Formatter = keyof typeof formatters;
681
589
  /**
@@ -694,43 +602,6 @@ type Formatter = keyof typeof formatters;
694
602
  */
695
603
  declare function detectFormatter(): Promise<Formatter | null>;
696
604
  //#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
605
  //#region src/utils/getConfigs.d.ts
735
606
  /**
736
607
  * Resolves a {@link ConfigInput} into a normalized array of {@link Config} objects.
@@ -775,6 +646,12 @@ type GetPresetResult<TResolver extends Resolver> = {
775
646
  */
776
647
  declare function getPreset<TResolver extends Resolver = Resolver>(params: GetPresetParams<TResolver>): GetPresetResult<TResolver>;
777
648
  //#endregion
649
+ //#region src/utils/isInputPath.d.ts
650
+ /**
651
+ * Type guard to check if a given config has an `input.path`.
652
+ */
653
+ declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
654
+ //#endregion
778
655
  //#region src/utils/linters.d.ts
779
656
  type Linter = keyof typeof linters;
780
657
  /**
@@ -813,5 +690,5 @@ type DependencyVersion = string;
813
690
  */
814
691
  declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
815
692
  //#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 };
693
+ export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, CLIOptions, CompatibilityPreset, Config, ConfigInput, DevtoolsOptions, Exclude, FileMetaBase, FunctionParams, FunctionParamsAST, Generator, GeneratorContext, Group, Include, InputData, InputPath, KubbEvents, 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
694
  //# sourceMappingURL=index.d.ts.map