@kubb/core 5.0.0-alpha.43 → 5.0.0-alpha.44

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.
@@ -387,37 +387,8 @@ declare class FileManager {
387
387
  }
388
388
  //#endregion
389
389
  //#region src/PluginDriver.d.ts
390
- type RequiredPluginLifecycle = Required<PluginLifecycle>;
391
- /**
392
- * Hook dispatch strategy used by the `PluginDriver`.
393
- *
394
- * - `hookFirst` — stops at the first non-null result.
395
- * - `hookForPlugin` — calls only the matching plugin.
396
- * - `hookParallel` — calls all plugins concurrently.
397
- * - `hookSeq` — calls all plugins in order, threading the result.
398
- */
399
- type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
400
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
401
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
402
- result: Result;
403
- plugin: Plugin;
404
- };
405
390
  type Options = {
406
- hooks?: AsyncEventEmitter<KubbHooks>;
407
- /**
408
- * @default Number.POSITIVE_INFINITY
409
- */
410
- concurrency?: number;
411
- };
412
- /**
413
- * Parameters accepted by `PluginDriver.getFile` to resolve a generated file descriptor.
414
- */
415
- type GetFileOptions<TOptions = object> = {
416
- name: string;
417
- mode?: 'single' | 'split';
418
- extname: FileNode['extname'];
419
- pluginName: string;
420
- options?: TOptions;
391
+ hooks: AsyncEventEmitter<KubbHooks>;
421
392
  };
422
393
  declare class PluginDriver {
423
394
  #private;
@@ -445,7 +416,7 @@ declare class PluginDriver {
445
416
  * add files; this property gives direct read/write access when needed.
446
417
  */
447
418
  readonly fileManager: FileManager;
448
- readonly plugins: Map<string, Plugin>;
419
+ readonly plugins: Map<string, NormalizedPlugin>;
449
420
  constructor(config: Config, options: Options);
450
421
  get hooks(): AsyncEventEmitter<KubbHooks>;
451
422
  /**
@@ -460,8 +431,10 @@ declare class PluginDriver {
460
431
  *
461
432
  * External tooling can subscribe to any of these events via `hooks.on(...)` to observe
462
433
  * the plugin lifecycle without modifying plugin behavior.
434
+ *
435
+ * @internal
463
436
  */
464
- registerPluginHooks(hookPlugin: HookStylePlugin, normalizedPlugin: Plugin): void;
437
+ registerPluginHooks(hookPlugin: Plugin, normalizedPlugin: NormalizedPlugin): void;
465
438
  /**
466
439
  * Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
467
440
  * can configure generators, resolvers, transformers and renderers before `buildStart` runs.
@@ -492,98 +465,27 @@ declare class PluginDriver {
492
465
  * for a plugin that has no static `plugin.generators`.
493
466
  */
494
467
  hasRegisteredGenerators(pluginName: string): boolean;
468
+ /**
469
+ * Unregisters all plugin lifecycle listeners from the shared event emitter.
470
+ * Called at the end of a build to prevent listener leaks across repeated builds.
471
+ *
472
+ * @internal
473
+ */
495
474
  dispose(): void;
475
+ /**
476
+ * Merges `partial` with the plugin's default resolver and stores the result.
477
+ * Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`
478
+ * get the up-to-date resolver without going through `getResolver()`.
479
+ */
496
480
  setPluginResolver(pluginName: string, partial: Partial<Resolver>): void;
497
- getResolver(pluginName: string): Resolver;
498
- getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, unknown>;
499
- /**
500
- * @deprecated use resolvers context instead
501
- */
502
- getFile<TOptions = object>({
503
- name,
504
- mode,
505
- extname,
506
- pluginName,
507
- options
508
- }: GetFileOptions<TOptions>): FileNode<{
509
- pluginName: string;
510
- }>;
511
481
  /**
512
- * @deprecated use resolvers context instead
513
- */
514
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => string;
515
- /**
516
- * @deprecated use resolvers context instead
517
- */
518
- resolveName: (params: ResolveNameParams) => string;
519
- /**
520
- * Run a specific hookName for plugin x.
521
- */
522
- hookForPlugin<H extends PluginLifecycleHooks>({
523
- pluginName,
524
- hookName,
525
- parameters
526
- }: {
527
- pluginName: string;
528
- hookName: H;
529
- parameters: PluginParameter<H>;
530
- }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
531
- /**
532
- * Run a specific hookName for plugin x.
533
- */
534
- hookForPluginSync<H extends PluginLifecycleHooks>({
535
- pluginName,
536
- hookName,
537
- parameters
538
- }: {
539
- pluginName: string;
540
- hookName: H;
541
- parameters: PluginParameter<H>;
542
- }): Array<ReturnType<ParseResult<H>>> | null;
543
- /**
544
- * Returns the first non-null result.
545
- */
546
- hookFirst<H extends PluginLifecycleHooks>({
547
- hookName,
548
- parameters,
549
- skipped
550
- }: {
551
- hookName: H;
552
- parameters: PluginParameter<H>;
553
- skipped?: ReadonlySet<Plugin> | null;
554
- }): Promise<SafeParseResult<H>>;
555
- /**
556
- * Returns the first non-null result.
557
- */
558
- hookFirstSync<H extends PluginLifecycleHooks>({
559
- hookName,
560
- parameters,
561
- skipped
562
- }: {
563
- hookName: H;
564
- parameters: PluginParameter<H>;
565
- skipped?: ReadonlySet<Plugin> | null;
566
- }): SafeParseResult<H> | null;
567
- /**
568
- * Runs all plugins in parallel based on `this.plugin` order and `dependencies` settings.
569
- */
570
- hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
571
- hookName,
572
- parameters
573
- }: {
574
- hookName: H;
575
- parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
576
- }): Promise<Awaited<TOutput>[]>;
577
- /**
578
- * Execute a lifecycle hook sequentially for all plugins that implement it.
579
- */
580
- hookSeq<H extends PluginLifecycleHooks>({
581
- hookName,
582
- parameters
583
- }: {
584
- hookName: H;
585
- parameters?: PluginParameter<H>;
586
- }): Promise<void>;
482
+ * Returns the resolver for the given plugin.
483
+ *
484
+ * Resolution order: dynamic resolver set via `setPluginResolver` → static resolver on the
485
+ * plugin → lazily created default resolver (identity name, no path transforms).
486
+ */
487
+ getResolver(pluginName: string): Resolver;
488
+ getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): GeneratorContext<TOptions> & Record<string, unknown>;
587
489
  getPlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
588
490
  getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined;
589
491
  /**
@@ -647,25 +549,6 @@ type DebugInfo = {
647
549
  logs: Array<string>;
648
550
  fileName?: string;
649
551
  };
650
- type HookProgress<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
651
- hookName: H;
652
- plugins: Array<Plugin>;
653
- };
654
- type HookExecution<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
655
- strategy: Strategy;
656
- hookName: H;
657
- plugin: Plugin;
658
- parameters?: Array<unknown>;
659
- output?: unknown;
660
- };
661
- type HookResult<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
662
- duration: number;
663
- strategy: Strategy;
664
- hookName: H;
665
- plugin: Plugin;
666
- parameters?: Array<unknown>;
667
- output?: unknown;
668
- };
669
552
  /**
670
553
  * The instance returned by {@link createKubb}.
671
554
  */
@@ -887,28 +770,6 @@ interface KubbHooks {
887
770
  success: boolean;
888
771
  error?: Error;
889
772
  }];
890
- /**
891
- * Emitted when plugin hook progress tracking starts.
892
- * Contains the hook name and list of plugins to execute.
893
- */
894
- 'kubb:plugins:hook:progress:start': [progress: HookProgress];
895
- /**
896
- * Emitted when plugin hook progress tracking ends.
897
- * Contains the hook name that completed.
898
- */
899
- 'kubb:plugins:hook:progress:end': [{
900
- hookName: PluginLifecycleHooks;
901
- }];
902
- /**
903
- * Emitted when a plugin hook starts processing.
904
- * Contains strategy, hook name, plugin, parameters, and output.
905
- */
906
- 'kubb:plugins:hook:processing:start': [execution: HookExecution];
907
- /**
908
- * Emitted when a plugin hook completes processing.
909
- * Contains duration, strategy, hook name, plugin, parameters, and output.
910
- */
911
- 'kubb:plugins:hook:processing:end': [result: HookResult];
912
773
  /**
913
774
  * Fired once — before any plugin's `buildStart` runs — so that hook-style plugins
914
775
  * can register generators, configure resolvers/transformers/renderers, or inject
@@ -950,7 +811,6 @@ interface KubbHooks {
950
811
  }
951
812
  declare global {
952
813
  namespace Kubb {
953
- interface PluginContext {}
954
814
  /**
955
815
  * Registry that maps plugin names to their `PluginFactoryOptions`.
956
816
  * Augment this interface in each plugin's `types.ts` to enable automatic
@@ -974,35 +834,13 @@ declare global {
974
834
  //#endregion
975
835
  //#region src/definePlugin.d.ts
976
836
  /**
977
- * Base hook handlers for all events except `kubb:plugin:setup`.
978
- * These handlers have identical signatures regardless of the plugin's
979
- * `PluginFactoryOptions` generic — they are split out so that the
980
- * interface below only needs to override the one event that depends on
981
- * the plugin type.
982
- */
983
- type PluginHooksBase = { [K in Exclude<keyof KubbHooks, 'kubb:plugin:setup'>]?: (...args: KubbHooks[K]) => void | Promise<void> };
984
- /**
985
- * Plugin hook handlers.
986
- *
987
- * `kubb:plugin:setup` is typed with the plugin's own `PluginFactoryOptions` so
988
- * `ctx.setResolver`, `ctx.setOptions`, `ctx.options` etc. use the correct types.
989
- *
990
- * Uses interface + method shorthand for `kubb:plugin:setup`
991
- * checking, allowing `PluginHooks<PluginTs>` to be assignable to `PluginHooks`.
992
- *
993
- * @template TFactory - The plugin's `PluginFactoryOptions` type.
994
- */
995
- interface PluginHooks<TFactory extends PluginFactoryOptions = PluginFactoryOptions> extends PluginHooksBase {
996
- 'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>;
997
- }
998
- /**
999
- * A hook-style plugin object produced by `definePlugin`.
837
+ * A plugin object produced by `definePlugin`.
1000
838
  * Instead of flat lifecycle methods, it groups all handlers under a `hooks:` property
1001
839
  * (matching Astro's integration naming convention).
1002
840
  *
1003
841
  * @template TFactory - The plugin's `PluginFactoryOptions` type.
1004
842
  */
1005
- type HookStylePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
843
+ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1006
844
  /**
1007
845
  * Unique name for the plugin, following the same naming convention as `createPlugin`.
1008
846
  */
@@ -1020,12 +858,14 @@ type HookStylePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOption
1020
858
  * Lifecycle event handlers for this plugin.
1021
859
  * Any event from the global `KubbHooks` map can be subscribed to here.
1022
860
  */
1023
- hooks: PluginHooks<TFactory>;
861
+ hooks: { [K in Exclude<keyof KubbHooks, 'kubb:plugin:setup'>]?: (...args: KubbHooks[K]) => void | Promise<void> } & {
862
+ 'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>;
863
+ };
1024
864
  };
1025
865
  /**
1026
- * Creates a plugin factory using the new hook-style (`hooks:`) API.
866
+ * Creates a plugin factory using the hook-style (`hooks:`) API.
1027
867
  *
1028
- * The returned factory is called with optional options and produces a `HookStylePlugin`
868
+ * The returned factory is called with optional options and produces a `Plugin`
1029
869
  * that coexists with plugins created via the legacy `createPlugin` API in the same
1030
870
  * `kubb.config.ts`.
1031
871
  *
@@ -1045,9 +885,14 @@ type HookStylePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOption
1045
885
  * }))
1046
886
  * ```
1047
887
  */
1048
- declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => HookStylePlugin<TFactory>): (options?: TFactory['options']) => HookStylePlugin<TFactory>;
888
+ declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): (options?: TFactory['options']) => Plugin<TFactory>;
1049
889
  //#endregion
1050
890
  //#region src/utils/getBarrelFiles.d.ts
891
+ /**
892
+ * Minimal file metadata attached to every generated file for barrel-file bookkeeping.
893
+ *
894
+ * @internal
895
+ */
1051
896
  type FileMetaBase = {
1052
897
  pluginName?: string;
1053
898
  };
@@ -1348,6 +1193,11 @@ type PatternOverride<TOptions> = PatternFilter & {
1348
1193
  * Context passed to `resolver.resolveOptions` to apply include/exclude/override filtering
1349
1194
  * for a given operation or schema node.
1350
1195
  */
1196
+ /**
1197
+ * Resolves filtered options for a given operation or schema node.
1198
+ *
1199
+ * @internal
1200
+ */
1351
1201
  type ResolveOptionsContext<TOptions> = {
1352
1202
  options: TOptions;
1353
1203
  exclude?: Array<PatternFilter>;
@@ -1372,7 +1222,7 @@ type ResolveOptionsContext<TOptions> = {
1372
1222
  type Resolver = {
1373
1223
  name: string;
1374
1224
  pluginName: Plugin['name'];
1375
- default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string;
1225
+ default(name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
1376
1226
  resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
1377
1227
  resolvePath(params: ResolverPathParams, context: ResolverContext): string;
1378
1228
  resolveFile(params: ResolverFileParams, context: ResolverContext): FileNode;
@@ -1413,95 +1263,25 @@ TResolver extends Resolver = Resolver> = {
1413
1263
  resolver: TResolver;
1414
1264
  };
1415
1265
  /**
1416
- * @deprecated
1266
+ * Internal representation of a plugin after normalization.
1267
+ * Extends the user-facing `Plugin` with runtime fields populated during `kubb:plugin:setup`.
1268
+ * Not part of the public API — use `Plugin` for external-facing interactions.
1269
+ * @internal
1417
1270
  */
1418
- type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1419
- /**
1420
- * Unique name used for the plugin.
1421
- * The name follows the format `scope:foo-bar` or `foo-bar` — adding a scope avoids conflicts with other plugins.
1422
- *
1423
- * @example Plugin name
1424
- * `'@kubb/typescript'`
1425
- */
1426
- name: TOptions['name'];
1427
- /**
1428
- * Resolved options merged with output/include/exclude/override defaults for the current plugin.
1429
- */
1271
+ type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {
1430
1272
  options: TOptions['resolvedOptions'] & {
1431
1273
  output: Output;
1432
1274
  include?: Array<Include>;
1433
1275
  exclude: Array<Exclude$1>;
1434
1276
  override: Array<Override<TOptions['resolvedOptions']>>;
1435
1277
  };
1436
- /**
1437
- * The resolver for this plugin.
1438
- * Set via `setResolver()` in `kubb:plugin:setup` or passed as a user option.
1439
- */
1440
- resolver?: TOptions['resolver'];
1441
- /**
1442
- * The composed transformer for this plugin.
1443
- * Set via `setTransformer()` in `kubb:plugin:setup` or passed as a user option.
1444
- */
1278
+ resolver: TOptions['resolver'];
1445
1279
  transformer?: Visitor;
1446
- /**
1447
- * Plugin-level renderer factory. All generators that do not declare their own `renderer`
1448
- * inherit this value. A generator can explicitly opt out by setting `renderer: null`.
1449
- *
1450
- * @example
1451
- * ```ts
1452
- * import { jsxRenderer } from '@kubb/renderer-jsx'
1453
- * createPlugin((options) => ({
1454
- * name: 'my-plugin',
1455
- * renderer: jsxRenderer,
1456
- * generators: [
1457
- * { name: 'types', schema(node) { return <File>...</File> } }, // inherits jsxRenderer
1458
- * { name: 'raw', renderer: null, schema(node) { return [...] } }, // explicit opt-out
1459
- * ],
1460
- * }))
1461
- * ```
1462
- */
1463
1280
  renderer?: RendererFactory;
1464
- /**
1465
- * Generators declared directly on the plugin. Each generator's `renderer` takes precedence
1466
- * over `plugin.renderer`; set `renderer: null` on a generator to opt out of rendering even
1467
- * when the plugin declares a renderer.
1468
- */
1469
1281
  generators?: Array<Generator>;
1470
- /**
1471
- * Specifies the plugins that the current plugin depends on. The current plugin is executed after all listed plugins.
1472
- * An error is returned if any required dependency plugin is missing.
1473
- */
1474
- dependencies?: Array<string>;
1475
- /**
1476
- * When `apply` is defined, the plugin is only activated when `apply(config)` returns `true`.
1477
- * Inspired by Vite's `apply` option.
1478
- *
1479
- * @example
1480
- * ```ts
1481
- * apply: (config) => config.output.path !== 'disabled'
1482
- * ```
1483
- */
1484
1282
  apply?: (config: Config) => boolean;
1485
- /**
1486
- * Expose shared helpers or data to all other plugins via `PluginContext`.
1487
- * The object returned is merged into the context that every plugin receives.
1488
- * Use the `declare global { namespace Kubb { interface PluginContext { … } } }` pattern
1489
- * to make the injected properties type-safe.
1490
- *
1491
- * @example
1492
- * ```ts
1493
- * inject() {
1494
- * return { getOas: () => parseSpec(this.config) }
1495
- * }
1496
- * // Other plugins can then call `this.getOas()` inside buildStart()
1497
- * ```
1498
- */
1499
- inject?: (this: PluginContext<TOptions>) => TOptions['context'];
1283
+ version?: string;
1500
1284
  };
1501
- /**
1502
- * @deprecated
1503
- */
1504
- type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
1505
1285
  /**
1506
1286
  * Partial version of {@link Config} intended for user-facing config entry points.
1507
1287
  *
@@ -1525,187 +1305,10 @@ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'par
1525
1305
  */
1526
1306
  adapter?: Adapter;
1527
1307
  /**
1528
- * User-facing plugins can be either legacy createPlugin instances or hook-style plugins.
1529
- */
1530
- plugins?: Array<Omit<UserPlugin<any>, 'inject'> | HookStylePlugin<any>>;
1531
- };
1532
- /**
1533
- * Handler for a single schema node. Used by the `schema` hook on a plugin.
1534
- */
1535
- type SchemaHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: SchemaNode, options: TOptions['resolvedOptions']) => PossiblePromise<unknown | Array<FileNode> | void>;
1536
- /**
1537
- * Handler for a single operation node. Used by the `operation` hook on a plugin.
1538
- */
1539
- type OperationHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, node: OperationNode, options: TOptions['resolvedOptions']) => PossiblePromise<unknown | Array<FileNode> | void>;
1540
- /**
1541
- * Handler for all collected operation nodes. Used by the `operations` hook on a plugin.
1542
- */
1543
- type OperationsHook<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = (this: GeneratorContext<TOptions>, nodes: Array<OperationNode>, options: TOptions['resolvedOptions']) => PossiblePromise<unknown | Array<FileNode> | void>;
1544
- /**
1545
- * @deprecated will be replaced with HookStylePlugin
1546
- */
1547
- type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1548
- /**
1549
- * Unique name used for the plugin.
1550
- *
1551
- * @example Plugin name
1552
- * `'@kubb/typescript'`
1553
- */
1554
- name: TOptions['name'];
1555
- /**
1556
- * Specifies the plugins that the current plugin depends on. The current plugin is executed after all listed plugins.
1557
- * An error is returned if any required dependency plugin is missing.
1558
- */
1559
- dependencies?: Array<string>;
1560
- /**
1561
- * Options set for a specific plugin(see kubb.config.js), passthrough of options.
1562
- */
1563
- options: TOptions['resolvedOptions'] & {
1564
- output: Output;
1565
- include?: Array<Include>;
1566
- exclude: Array<Exclude$1>;
1567
- override: Array<Override<TOptions['resolvedOptions']>>;
1568
- };
1569
- /**
1570
- * The resolver for this plugin.
1571
- * Set via `setResolver()` in `kubb:plugin:setup` or passed as a user option.
1572
- */
1573
- resolver: TOptions['resolver'];
1574
- /**
1575
- * The composed transformer for this plugin.
1576
- * Set via `setTransformer()` in `kubb:plugin:setup` or passed as a user option.
1577
- */
1578
- transformer?: Visitor;
1579
- /**
1580
- * When `apply` is defined, the plugin is only activated when `apply(config)` returns `true`.
1581
- * Inspired by Vite's `apply` option.
1582
- */
1583
- apply?: (config: Config) => boolean;
1584
- /**
1585
- * Optional semver version string for this plugin, e.g. `"1.2.3"`.
1586
- * Used in diagnostic messages and version-conflict detection.
1587
- */
1588
- version?: string;
1589
- /**
1590
- * Plugin-level renderer factory. All generators that do not declare their own `renderer`
1591
- * inherit this value. A generator can explicitly opt out by setting `renderer: null`.
1592
- */
1593
- renderer?: RendererFactory;
1594
- /**
1595
- * Generators declared directly on the plugin. Each generator's `renderer` takes precedence
1596
- * over `plugin.renderer`; set `renderer: null` on a generator to opt out of rendering even
1597
- * when the plugin declares a renderer.
1598
- */
1599
- generators?: Array<Generator>;
1600
- buildStart: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1601
- /**
1602
- * Called once per plugin after all files have been written to disk.
1603
- * Use this for post-processing, copying assets, or generating summary reports.
1604
- */
1605
- buildEnd: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1606
- /**
1607
- * Called for each schema node during the AST walk.
1608
- * Return a React element, an array of `FileNode`, or `void` for manual handling.
1609
- * Nodes matching `exclude`/`include` filters are skipped automatically.
1610
- *
1611
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1612
- */
1613
- schema?: SchemaHook<TOptions>;
1614
- /**
1615
- * Called for each operation node during the AST walk.
1616
- * Return a React element, an array of `FileNode`, or `void` for manual handling.
1617
- *
1618
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1619
- */
1620
- operation?: OperationHook<TOptions>;
1621
- /**
1622
- * Called once after all operations have been walked, with the full collected set.
1623
- *
1624
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1625
- */
1626
- operations?: OperationsHook<TOptions>;
1627
- /**
1628
- * Expose shared helpers or data to all other plugins via `PluginContext`.
1629
- * The returned object is merged into the context received by every plugin.
1630
- */
1631
- inject: (this: PluginContext<TOptions>) => TOptions['context'];
1632
- };
1633
- /**
1634
- * @deprecated
1635
- */
1636
- type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
1637
- /**
1638
- * @deprecated
1639
- */
1640
- type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1641
- /**
1642
- * Called once per plugin at the start of its processing phase, before schema/operation/operations hooks run.
1643
- * Use this to set up shared state, fetch remote data, or perform any async initialization.
1644
- */
1645
- buildStart?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1646
- /**
1647
- * Called once per plugin after all files have been written to disk.
1648
- * Use this for post-processing, copying assets, or generating summary reports.
1649
- */
1650
- buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
1651
- /**
1652
- * Called for each schema node during the AST walk.
1653
- * Return a React element (`<File>...</File>`), an array of `FileNode` objects,
1654
- * or `void` to handle file writing manually via `this.upsertFile`.
1655
- * Nodes matching `exclude` / `include` filters are skipped automatically.
1656
- *
1657
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1658
- */
1659
- schema?: SchemaHook<TOptions>;
1660
- /**
1661
- * Called for each operation node during the AST walk.
1662
- * Return a React element (`<File>...</File>`), an array of `FileNode` objects,
1663
- * or `void` to handle file writing manually via `this.upsertFile`.
1664
- *
1665
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1666
- */
1667
- operation?: OperationHook<TOptions>;
1668
- /**
1669
- * Called once after all operation nodes have been walked, with the full collection.
1670
- * Useful for generating index/barrel files per group or aggregate operation handlers.
1671
- *
1672
- * For multiple generators, use `composeGenerators` inside the plugin factory.
1673
- */
1674
- operations?: OperationsHook<TOptions>;
1675
- /**
1676
- * Resolves a path from a baseName and directory.
1677
- * Options can also be included.
1678
- *
1679
- * @example
1680
- * `('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'`
1681
- *
1682
- * @deprecated Use resolvers instead.
1683
- */
1684
- resolvePath?: (this: PluginContext<TOptions>, baseName: FileNode['baseName'], mode?: 'single' | 'split', options?: TOptions['resolvePathOptions']) => string;
1685
- /**
1686
- * Resolves a display name from a raw string.
1687
- * Useful when converting to PascalCase or camelCase.
1688
- *
1689
- * @example
1690
- * `('pet') => 'Pet'`
1691
- *
1692
- * @deprecated Use resolvers instead.
1693
- */
1694
- resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1695
- };
1696
- /**
1697
- * @deprecated
1698
- */
1699
- type PluginLifecycleHooks = keyof PluginLifecycle;
1700
- type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
1701
- type ResolvePathParams<TOptions = object> = {
1702
- pluginName?: string;
1703
- baseName: FileNode['baseName'];
1704
- mode?: 'single' | 'split';
1705
- /**
1706
- * Options passed as the third argument to `resolvePath`.
1308
+ * An array of Kubb plugins used for code generation.
1309
+ * Each entry is a hook-style plugin created with `definePlugin`.
1707
1310
  */
1708
- options?: TOptions;
1311
+ plugins?: Array<Plugin>;
1709
1312
  };
1710
1313
  type ResolveNameParams = {
1711
1314
  name: string;
@@ -1720,9 +1323,17 @@ type ResolveNameParams = {
1720
1323
  type?: 'file' | 'function' | 'type' | 'const';
1721
1324
  };
1722
1325
  /**
1723
- * @deprecated
1326
+ * Context object passed as the second argument to generator `schema`, `operation`, and
1327
+ * `operations` methods.
1328
+ *
1329
+ * Generators are only invoked from `runPluginAstHooks`, which already guards against a
1330
+ * missing adapter. This type reflects that guarantee — `ctx.adapter` and `ctx.inputNode`
1331
+ * are always defined, so no runtime checks or casts are needed inside generator bodies.
1332
+ *
1333
+ * `ctx.options` carries the per-node resolved options for `schema`/`operation` calls
1334
+ * (after exclude/include/override filtering) and the plugin-level options for `operations`.
1724
1335
  */
1725
- type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1336
+ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1726
1337
  config: Config;
1727
1338
  /**
1728
1339
  * Absolute path to the output directory for the current plugin.
@@ -1732,7 +1343,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1732
1343
  /**
1733
1344
  * Returns the output mode for the given output config.
1734
1345
  * Returns `'single'` when `output.path` has a file extension, `'split'` otherwise.
1735
- * Shorthand for `PluginDriver.getMode(path.resolve(this.root, output.path))`.
1736
1346
  */
1737
1347
  getMode: (output: {
1738
1348
  path: string;
@@ -1746,7 +1356,6 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1746
1356
  getPlugin(name: string): Plugin | undefined;
1747
1357
  /**
1748
1358
  * Like `getPlugin` but throws a descriptive error when the plugin is not found.
1749
- * Useful for enforcing dependencies inside `buildStart()`.
1750
1359
  */
1751
1360
  requirePlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]>;
1752
1361
  requirePlugin(name: string): Plugin;
@@ -1764,63 +1373,40 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
1764
1373
  */
1765
1374
  plugin: Plugin<TOptions>;
1766
1375
  /**
1767
- * Resolver for the current plugin. Shorthand for `plugin.resolver`.
1376
+ * Resolver for the current plugin.
1768
1377
  */
1769
1378
  resolver: TOptions['resolver'];
1770
1379
  /**
1771
- * Composed transformer for the current plugin. Shorthand for `plugin.transformer`.
1772
- * Apply with `transform(node, context.transformer)` to pre-process AST nodes before printing.
1380
+ * Composed transformer for the current plugin.
1773
1381
  */
1774
1382
  transformer: Visitor | undefined;
1775
1383
  /**
1776
1384
  * Emit a warning via the build event system.
1777
- * Shorthand for `this.hooks.emit('kubb:warn', message)`.
1778
1385
  */
1779
1386
  warn: (message: string) => void;
1780
1387
  /**
1781
1388
  * Emit an error via the build event system.
1782
- * Shorthand for `this.hooks.emit('kubb:error', error)`.
1783
1389
  */
1784
1390
  error: (error: string | Error) => void;
1785
1391
  /**
1786
1392
  * Emit an info message via the build event system.
1787
- * Shorthand for `this.hooks.emit('kubb:info', message)`.
1788
1393
  */
1789
1394
  info: (message: string) => void;
1790
1395
  /**
1791
1396
  * Opens the Kubb Studio URL for the current `inputNode` in the default browser.
1792
- * Falls back to printing the URL if the browser cannot be launched.
1793
- * No-ops silently when no adapter has set an `inputNode`.
1794
1397
  */
1795
1398
  openInStudio: (options?: DevtoolsOptions) => Promise<void>;
1796
- } & ({
1797
- /**
1798
- * Returns the universal `@kubb/ast` `InputNode` produced by the configured adapter.
1799
- * Returns `undefined` when no adapter was set (legacy OAS-only usage).
1800
- */
1801
- inputNode: InputNode;
1802
1399
  /**
1803
1400
  * The adapter from `@kubb/ast`.
1804
1401
  */
1805
1402
  adapter: Adapter;
1806
- } | {
1807
- inputNode?: never;
1808
- adapter?: never;
1809
- }) & Kubb.PluginContext;
1810
- /**
1811
- * Context object passed as the second argument to generator `schema`, `operation`, and
1812
- * `operations` methods.
1813
- *
1814
- * Generators are only invoked from `runPluginAstHooks`, which already guards against a
1815
- * missing adapter. This type reflects that guarantee — `ctx.adapter` and `ctx.inputNode`
1816
- * are always defined, so no runtime checks or casts are needed inside generator bodies.
1817
- *
1818
- * `ctx.options` carries the per-node resolved options for `schema`/`operation` calls
1819
- * (after exclude/include/override filtering) and the plugin-level options for `operations`.
1820
- */
1821
- type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Omit<PluginContext<TOptions>, 'adapter' | 'inputNode'> & {
1822
- adapter: Adapter;
1403
+ /**
1404
+ * The universal `@kubb/ast` `InputNode` produced by the configured adapter.
1405
+ */
1823
1406
  inputNode: InputNode;
1407
+ /**
1408
+ * Per-node resolved options (after exclude/include/override filtering).
1409
+ */
1824
1410
  options: TOptions['resolvedOptions'];
1825
1411
  };
1826
1412
  /**
@@ -1896,12 +1482,6 @@ type Logger<TOptions extends LoggerOptions = LoggerOptions> = {
1896
1482
  install: (context: LoggerContext, options?: TOptions) => void | Promise<void>;
1897
1483
  };
1898
1484
  type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOptions>;
1899
- /**
1900
- * Compatibility preset for code generation tools.
1901
- * - `'default'` – no compatibility adjustments (default behavior).
1902
- * - `'kubbV4'` – align generated names and structures with Kubb v4 output.
1903
- */
1904
- type CompatibilityPreset = 'default' | 'kubbV4';
1905
1485
  /**
1906
1486
  * Context passed to a hook-style plugin's `kubb:plugin:setup` handler.
1907
1487
  * Provides methods to register generators, configure the resolver, transformer,
@@ -2018,14 +1598,6 @@ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySch
2018
1598
  type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
2019
1599
  options: Partial<TOptions>;
2020
1600
  };
2021
- type ResolvePathOptions = {
2022
- pluginName?: string;
2023
- group?: {
2024
- tag?: string;
2025
- path?: string;
2026
- };
2027
- type?: ResolveNameParams['type'];
2028
- };
2029
1601
  /**
2030
1602
  * File-specific parameters for `Resolver.resolvePath`.
2031
1603
  *
@@ -2147,5 +1719,5 @@ type CLIOptions = {
2147
1719
  */
2148
1720
  type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Config[]> | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Config[]>);
2149
1721
  //#endregion
2150
- export { KubbHooks as $, PluginParameter as A, ResolverFileParams as B, Output as C, PluginFactoryOptions as D, PluginContext as E, ResolveOptionsContext as F, UserLogger as G, SchemaHook as H, ResolvePathOptions as I, FileMetaBase as J, UserPlugin as K, ResolvePathParams as L, PossibleConfig as M, ResolveBannerContext as N, PluginLifecycle as O, ResolveNameParams as P, Kubb$1 as Q, Resolver as R, OperationsHook as S, Plugin as T, UserConfig as U, ResolverPathParams as V, UserGroup as W, PluginHooks as X, HookStylePlugin as Y, definePlugin as Z, KubbPluginSetupContext as _, CLIOptions as a, defineParser as at, LoggerOptions as b, DevtoolsOptions as c, Storage as ct, Group as d, RendererFactory as dt, BuildOutput as et, Include as f, createRenderer as ft, KubbBuildStartContext as g, KubbBuildEndContext as h, BarrelType as i, Parser as it, PluginWithLifeCycle as j, PluginLifecycleHooks as k, Exclude$1 as l, createStorage as lt, InputPath as m, AsyncEventEmitter as mt, AdapterFactoryOptions as n, PluginDriver as nt, CompatibilityPreset as o, Generator as ot, InputData as p, logLevel as pt, UserPluginWithLifeCycle as q, AdapterSource as r, FileManager as rt, Config as s, defineGenerator as st, Adapter as t, createKubb as tt, GeneratorContext as u, Renderer as ut, Logger as v, Override as w, OperationHook as x, LoggerContext as y, ResolverContext as z };
2151
- //# sourceMappingURL=types-BJX_uR-y.d.ts.map
1722
+ export { logLevel as $, ResolverFileParams as A, BuildOutput as B, PluginFactoryOptions as C, ResolveOptionsContext as D, ResolveNameParams as E, FileMetaBase as F, defineParser as G, PluginDriver as H, Plugin as I, Storage as J, Generator as K, definePlugin as L, UserConfig as M, UserGroup as N, Resolver as O, UserLogger as P, createRenderer as Q, Kubb$1 as R, Override as S, ResolveBannerContext as T, FileManager as U, createKubb as V, Parser as W, Renderer as X, createStorage as Y, RendererFactory as Z, Logger as _, CLIOptions as a, NormalizedPlugin as b, Exclude$1 as c, Include as d, AsyncEventEmitter as et, InputData as f, KubbPluginSetupContext as g, KubbBuildStartContext as h, BarrelType as i, ResolverPathParams as j, ResolverContext as k, GeneratorContext as l, KubbBuildEndContext as m, AdapterFactoryOptions as n, Config as o, InputPath as p, defineGenerator as q, AdapterSource as r, DevtoolsOptions as s, Adapter as t, Group as u, LoggerContext as v, PossibleConfig as w, Output as x, LoggerOptions as y, KubbHooks as z };
1723
+ //# sourceMappingURL=types-BUgxQiWY.d.ts.map