@kubb/core 5.0.0-alpha.20 → 5.0.0-alpha.22

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,7 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
2
  import { Node, OperationNode, Printer, PrinterFactoryOptions, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
3
- import { Fabric, KubbFile } from "@kubb/fabric-core/types";
3
+ import { Fabric, FabricFile } from "@kubb/fabric-core/types";
4
+ import { HttpMethod } from "@kubb/oas";
4
5
  import { FabricReactNode } from "@kubb/react-fabric/types";
5
6
 
6
7
  //#region ../../internals/utils/src/asyncEventEmitter.d.ts
@@ -210,6 +211,109 @@ type Storage = {
210
211
  */
211
212
  declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => Storage): (options?: TOptions) => Storage;
212
213
  //#endregion
214
+ //#region src/defineGenerator.d.ts
215
+ /**
216
+ * Props for the `operations` lifecycle — receives all operation nodes at once.
217
+ */
218
+ type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
219
+ config: Config;
220
+ plugin: Plugin<TPlugin>;
221
+ adapter: Adapter;
222
+ options: Plugin<TPlugin>['options'];
223
+ nodes: Array<OperationNode>;
224
+ };
225
+ /**
226
+ * Props for the `operation` lifecycle — receives a single operation node.
227
+ */
228
+ type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
229
+ config: Config;
230
+ adapter: Adapter;
231
+ plugin: Plugin<TPlugin>;
232
+ options: Plugin<TPlugin>['options'];
233
+ node: OperationNode;
234
+ };
235
+ /**
236
+ * Props for the `schema` lifecycle — receives a single schema node.
237
+ */
238
+ type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
239
+ config: Config;
240
+ adapter: Adapter;
241
+ plugin: Plugin<TPlugin>;
242
+ options: Plugin<TPlugin>['options'];
243
+ node: SchemaNode;
244
+ };
245
+ /**
246
+ * Input shape for a core v2 async generator — lifecycle methods are optional.
247
+ */
248
+ type UserCoreGeneratorV2<TPlugin extends PluginFactoryOptions> = {
249
+ name: string;
250
+ type: 'core';
251
+ version?: '2';
252
+ operations?(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
253
+ operation?(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
254
+ schema?(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
255
+ };
256
+ /**
257
+ * Input shape for a React v2 generator — component methods are optional.
258
+ */
259
+ type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
260
+ name: string;
261
+ type: 'react';
262
+ version?: '2';
263
+ Operations?(props: OperationsV2Props<TPlugin>): FabricReactNode;
264
+ Operation?(props: OperationV2Props<TPlugin>): FabricReactNode;
265
+ Schema?(props: SchemaV2Props<TPlugin>): FabricReactNode;
266
+ };
267
+ /**
268
+ * A fully resolved core v2 generator with `version: '2'` and guaranteed async lifecycle methods.
269
+ */
270
+ type CoreGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
271
+ name: string;
272
+ type: 'core';
273
+ version: '2';
274
+ operations(props: OperationsV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
275
+ operation(props: OperationV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
276
+ schema(props: SchemaV2Props<TPlugin>): Promise<Array<FabricFile.File>>;
277
+ };
278
+ /**
279
+ * A fully resolved React v2 generator with `version: '2'` and guaranteed component methods.
280
+ */
281
+ type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
282
+ name: string;
283
+ type: 'react';
284
+ version: '2';
285
+ Operations(props: OperationsV2Props<TPlugin>): FabricReactNode;
286
+ Operation(props: OperationV2Props<TPlugin>): FabricReactNode;
287
+ Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
288
+ };
289
+ /**
290
+ * Union of all v2 generator shapes accepted by the plugin system.
291
+ */
292
+ type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
293
+ /**
294
+ * Defines a generator with no-op defaults for any omitted lifecycle methods.
295
+ * Works for both `core` (async file output) and `react` (JSX component) generators.
296
+ *
297
+ * @example
298
+ * // react generator
299
+ * export const typeGenerator = defineGenerator<PluginTs>({
300
+ * name: 'typescript',
301
+ * type: 'react',
302
+ * Operation({ node, options }) { return <File>...</File> },
303
+ * Schema({ node, options }) { return <File>...</File> },
304
+ * })
305
+ *
306
+ * @example
307
+ * // core generator
308
+ * export const myGenerator = defineGenerator<MyPlugin>({
309
+ * name: 'my-generator',
310
+ * type: 'core',
311
+ * async operation({ node, options }) { return [{ path: '...', content: '...' }] },
312
+ * })
313
+ */
314
+ declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserReactGeneratorV2<TPlugin>): ReactGeneratorV2<TPlugin>;
315
+ declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserCoreGeneratorV2<TPlugin>): CoreGeneratorV2<TPlugin>;
316
+ //#endregion
213
317
  //#region src/Kubb.d.ts
214
318
  type DebugInfo = {
215
319
  date: Date;
@@ -279,7 +383,7 @@ interface KubbEvents {
279
383
  /**
280
384
  * Emitted when code generation phase completes.
281
385
  */
282
- 'generation:end': [config: Config, files: Array<KubbFile.ResolvedFile>, sources: Map<KubbFile.Path, string>];
386
+ 'generation:end': [config: Config, files: Array<FabricFile.ResolvedFile>, sources: Map<FabricFile.Path, string>];
283
387
  /**
284
388
  * Emitted with a summary of the generation results.
285
389
  * Contains summary lines, title, and success status.
@@ -366,7 +470,7 @@ interface KubbEvents {
366
470
  * Emitted when file processing starts.
367
471
  * Contains the list of files to be processed.
368
472
  */
369
- 'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
473
+ 'files:processing:start': [files: Array<FabricFile.ResolvedFile>];
370
474
  /**
371
475
  * Emitted for each file being processed, providing progress updates.
372
476
  * Contains processed count, total count, percentage, and file details.
@@ -391,7 +495,7 @@ interface KubbEvents {
391
495
  /**
392
496
  * The file being processed.
393
497
  */
394
- file: KubbFile.ResolvedFile;
498
+ file: FabricFile.ResolvedFile;
395
499
  /**
396
500
  * Kubb configuration (not present in Fabric).
397
501
  * Provides access to the current config during file processing.
@@ -402,7 +506,7 @@ interface KubbEvents {
402
506
  * Emitted when file processing completes.
403
507
  * Contains the list of processed files.
404
508
  */
405
- 'files:processing:end': [files: Array<KubbFile.ResolvedFile>];
509
+ 'files:processing:end': [files: Array<FabricFile.ResolvedFile>];
406
510
  /**
407
511
  * Emitted when a plugin starts executing.
408
512
  */
@@ -440,91 +544,6 @@ interface KubbEvents {
440
544
  'plugins:hook:processing:end': [result: HookResult];
441
545
  }
442
546
  //#endregion
443
- //#region src/defineGenerator.d.ts
444
- /**
445
- * Props for the `operations` lifecycle — receives all operation nodes at once.
446
- */
447
- type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
448
- config: Config;
449
- adapter: Adapter;
450
- options: Plugin<TPlugin>['options'];
451
- nodes: Array<OperationNode>;
452
- };
453
- /**
454
- * Props for the `operation` lifecycle — receives a single operation node.
455
- */
456
- type OperationV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
457
- config: Config;
458
- adapter: Adapter;
459
- options: Plugin<TPlugin>['options'];
460
- node: OperationNode;
461
- };
462
- /**
463
- * Props for the `schema` lifecycle — receives a single schema node.
464
- */
465
- type SchemaV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
466
- config: Config;
467
- adapter: Adapter;
468
- options: Plugin<TPlugin>['options'];
469
- node: SchemaNode;
470
- };
471
- type UserCoreGeneratorV2<TPlugin extends PluginFactoryOptions> = {
472
- name: string;
473
- type: 'core';
474
- version?: '2';
475
- operations?(props: OperationsV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
476
- operation?(props: OperationV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
477
- schema?(props: SchemaV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
478
- };
479
- type UserReactGeneratorV2<TPlugin extends PluginFactoryOptions> = {
480
- name: string;
481
- type: 'react';
482
- version?: '2';
483
- Operations?(props: OperationsV2Props<TPlugin>): FabricReactNode;
484
- Operation?(props: OperationV2Props<TPlugin>): FabricReactNode;
485
- Schema?(props: SchemaV2Props<TPlugin>): FabricReactNode;
486
- };
487
- type CoreGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
488
- name: string;
489
- type: 'core';
490
- version: '2';
491
- operations(props: OperationsV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
492
- operation(props: OperationV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
493
- schema(props: SchemaV2Props<TPlugin>): Promise<Array<KubbFile.File>>;
494
- };
495
- type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
496
- name: string;
497
- type: 'react';
498
- version: '2';
499
- Operations(props: OperationsV2Props<TPlugin>): FabricReactNode;
500
- Operation(props: OperationV2Props<TPlugin>): FabricReactNode;
501
- Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
502
- };
503
- type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
504
- /**
505
- * Defines a generator with no-op defaults for any omitted lifecycle methods.
506
- * Works for both `core` (async file output) and `react` (JSX component) generators.
507
- *
508
- * @example
509
- * // react generator
510
- * export const typeGenerator = defineGenerator<PluginTs>({
511
- * name: 'typescript',
512
- * type: 'react',
513
- * Operation({ node, options }) { return <File>...</File> },
514
- * Schema({ node, options }) { return <File>...</File> },
515
- * })
516
- *
517
- * @example
518
- * // core generator
519
- * export const myGenerator = defineGenerator<MyPlugin>({
520
- * name: 'my-generator',
521
- * type: 'core',
522
- * async operation({ node, options }) { return [{ path: '...', content: '...' }] },
523
- * })
524
- */
525
- declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserReactGeneratorV2<TPlugin>): ReactGeneratorV2<TPlugin>;
526
- declare function defineGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserCoreGeneratorV2<TPlugin>): CoreGeneratorV2<TPlugin>;
527
- //#endregion
528
547
  //#region src/types.d.ts
529
548
  declare global {
530
549
  namespace Kubb {
@@ -624,13 +643,14 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
624
643
  * The raw source document produced after the first `parse()` call.
625
644
  * `undefined` before parsing; typed by the adapter's `TDocument` generic.
626
645
  */
627
- document?: TOptions['document'];
646
+ document: TOptions['document'] | null;
647
+ rootNode: RootNode | null;
628
648
  /**
629
649
  * Convert the raw source into a universal `RootNode`.
630
650
  */
631
651
  parse: (source: AdapterSource) => PossiblePromise<RootNode>;
632
652
  /**
633
- * Extracts `KubbFile.Import` entries needed by a `SchemaNode` tree.
653
+ * Extracts `FabricFile.Import` entries needed by a `SchemaNode` tree.
634
654
  * Populated after the first `parse()` call. Returns an empty array before that.
635
655
  *
636
656
  * The `resolve` callback receives the collision-corrected schema name and must
@@ -639,7 +659,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
639
659
  getImports: (node: SchemaNode, resolve: (schemaName: string) => {
640
660
  name: string;
641
661
  path: string;
642
- }) => Array<KubbFile.Import>;
662
+ }) => Array<FabricFile.Import>;
643
663
  };
644
664
  type BarrelType = 'all' | 'named' | 'propagate';
645
665
  type DevtoolsOptions = {
@@ -738,12 +758,12 @@ type Config<TInput = Input> = {
738
758
  * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
739
759
  * @default { '.ts': '.ts'}
740
760
  */
741
- extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
761
+ extension?: Record<FabricFile.Extname, FabricFile.Extname | ''>;
742
762
  /**
743
763
  * 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`).
744
764
  * @default 'named'
745
765
  */
746
- barrelType?: Exclude<BarrelType, 'propagate'> | false;
766
+ barrelType?: 'all' | 'named' | false;
747
767
  /**
748
768
  * Adds a default banner to the start of every generated file indicating it was generated by Kubb.
749
769
  * - 'simple' adds banner with link to Kubb.
@@ -787,13 +807,23 @@ type Config<TInput = Input> = {
787
807
  done?: string | Array<string>;
788
808
  };
789
809
  };
810
+ /**
811
+ * A type/string-pattern filter used for `include`, `exclude`, and `override` matching.
812
+ */
790
813
  type PatternFilter = {
791
814
  type: string;
792
815
  pattern: string | RegExp;
793
816
  };
817
+ /**
818
+ * A pattern filter paired with partial option overrides to apply when the pattern matches.
819
+ */
794
820
  type PatternOverride<TOptions> = PatternFilter & {
795
821
  options: Omit<Partial<TOptions>, 'override'>;
796
822
  };
823
+ /**
824
+ * Context passed to `resolver.resolveOptions` to apply include/exclude/override filtering
825
+ * for a given operation or schema node.
826
+ */
797
827
  type ResolveOptionsContext<TOptions> = {
798
828
  options: TOptions;
799
829
  exclude?: Array<PatternFilter>;
@@ -803,24 +833,51 @@ type ResolveOptionsContext<TOptions> = {
803
833
  /**
804
834
  * Base constraint for all plugin resolver objects.
805
835
  *
806
- * `default` and `resolveOptions` are injected automatically by `defineResolver` — plugin
807
- * authors may override them but never need to implement them from scratch.
808
- * Concrete plugin resolver types extend this with their own helper methods.
836
+ * `default`, `resolveOptions`, `resolvePath`, and `resolveFile` are injected automatically
837
+ * by `defineResolver` — plugin authors may override them but never need to implement them
838
+ * from scratch.
839
+ *
840
+ * @example
841
+ * ```ts
842
+ * type MyResolver = Resolver & {
843
+ * resolveName(node: SchemaNode): string
844
+ * resolveTypedName(node: SchemaNode): string
845
+ * }
846
+ * ```
809
847
  */
810
848
  type Resolver = {
811
849
  name: string;
850
+ pluginName: Plugin['name'];
812
851
  default(name: ResolveNameParams['name'], type?: ResolveNameParams['type']): string;
813
852
  resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
853
+ resolvePath(params: ResolverPathParams, context: ResolverContext): FabricFile.Path;
854
+ resolveFile(params: ResolverFileParams, context: ResolverContext): FabricFile.File;
855
+ resolveBanner(node: RootNode | null, context: ResolveBannerContext): string | undefined;
856
+ resolveFooter(node: RootNode | null, context: ResolveBannerContext): string | undefined;
814
857
  };
815
858
  /**
816
- * The user-facing subset of a `Resolver` — everything except the methods injected by
817
- * `defineResolver` (`default` and `resolveOptions`).
859
+ * The user-facing subset of a `Resolver` — everything except the four methods injected by
860
+ * `defineResolver` (`default`, `resolveOptions`, `resolvePath`, and `resolveFile`).
818
861
  *
819
- * When you pass a `UserResolver` to `defineResolver`, the standard `default` and
820
- * `resolveOptions` implementations are injected automatically so plugin authors never
821
- * need to define them by hand. Both can still be overridden by providing them explicitly.
862
+ * All four injected methods can still be overridden by providing them explicitly in the builder.
863
+ *
864
+ * @example
865
+ * ```ts
866
+ * export const resolver = defineResolver<PluginTs>(() => ({
867
+ * name: 'default',
868
+ * resolveName(node) { return this.default(node.name, 'function') },
869
+ * }))
870
+ * ```
822
871
  */
823
- type UserResolver = Omit<Resolver, 'default' | 'resolveOptions'>;
872
+ type UserResolver = Omit<Resolver, 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>;
873
+ /**
874
+ * Base type for plugin builder objects.
875
+ * Concrete plugin builder types extend this with their own schema-building helpers.
876
+ * Use `defineBuilder` to define a builder object and export it alongside the plugin.
877
+ */
878
+ type Builder = {
879
+ name: string;
880
+ };
824
881
  type PluginFactoryOptions<
825
882
  /**
826
883
  * Name to be used for the plugin.
@@ -846,13 +903,19 @@ TResolvePathOptions extends object = object,
846
903
  * Resolver object that encapsulates the naming and path-resolution helpers used by this plugin.
847
904
  * Use `defineResolver` to define the resolver object and export it alongside the plugin.
848
905
  */
849
- TResolver extends Resolver = Resolver> = {
906
+ TResolver extends Resolver = Resolver,
907
+ /**
908
+ * Builder object that encapsulates the schema-building helpers used by this plugin.
909
+ * Use `defineBuilder` to define the builder object and export it alongside the plugin.
910
+ */
911
+ TBuilder extends Builder = Builder> = {
850
912
  name: TName;
851
913
  options: TOptions;
852
914
  resolvedOptions: TResolvedOptions;
853
915
  context: TContext;
854
916
  resolvePathOptions: TResolvePathOptions;
855
917
  resolver: TResolver;
918
+ builder: TBuilder;
856
919
  };
857
920
  type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
858
921
  /**
@@ -915,13 +978,15 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
915
978
  * Options can als be included.
916
979
  * @type hookFirst
917
980
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
981
+ * @deprecated this will be replaced by resolvers
918
982
  */
919
- resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
983
+ resolvePath?: (this: PluginContext<TOptions>, baseName: FabricFile.BaseName, mode?: FabricFile.Mode, options?: TOptions['resolvePathOptions']) => FabricFile.Path;
920
984
  /**
921
985
  * Resolve to a name based on a string.
922
986
  * Useful when converting to PascalCase or camelCase.
923
987
  * @type hookFirst
924
988
  * @example ('pet') => 'Pet'
989
+ * @deprecated this will be replaced by resolvers
925
990
  */
926
991
  resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
927
992
  };
@@ -929,8 +994,8 @@ type PluginLifecycleHooks = keyof PluginLifecycle;
929
994
  type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
930
995
  type ResolvePathParams<TOptions = object> = {
931
996
  pluginName?: string;
932
- baseName: KubbFile.BaseName;
933
- mode?: KubbFile.Mode;
997
+ baseName: FabricFile.BaseName;
998
+ mode?: FabricFile.Mode;
934
999
  /**
935
1000
  * Options to be passed to 'resolvePath' 3th parameter
936
1001
  */
@@ -956,13 +1021,13 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
956
1021
  /**
957
1022
  * Only add when the file does not exist yet
958
1023
  */
959
- addFile: (...file: Array<KubbFile.File>) => Promise<void>;
1024
+ addFile: (...file: Array<FabricFile.File>) => Promise<void>;
960
1025
  /**
961
1026
  * merging multiple sources into the same output file
962
1027
  */
963
- upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
1028
+ upsertFile: (...file: Array<FabricFile.File>) => Promise<void>;
964
1029
  events: AsyncEventEmitter<KubbEvents>;
965
- mode: KubbFile.Mode;
1030
+ mode: FabricFile.Mode;
966
1031
  /**
967
1032
  * Current plugin
968
1033
  */
@@ -990,7 +1055,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
990
1055
  /**
991
1056
  * Specify the export location for the files and define the behavior of the output
992
1057
  */
993
- type Output<TOptions> = {
1058
+ type Output<_TOptions = unknown> = {
994
1059
  /**
995
1060
  * Path to the output folder or file that will contain the generated code
996
1061
  */
@@ -1003,11 +1068,11 @@ type Output<TOptions> = {
1003
1068
  /**
1004
1069
  * Add a banner text in the beginning of every file
1005
1070
  */
1006
- banner?: string | ((options: TOptions) => string);
1071
+ banner?: string | ((node: RootNode) => string);
1007
1072
  /**
1008
1073
  * Add a footer text in the beginning of every file
1009
1074
  */
1010
- footer?: string | ((options: TOptions) => string);
1075
+ footer?: string | ((node: RootNode) => string);
1011
1076
  /**
1012
1077
  * Whether to override existing external files if they already exist.
1013
1078
  * @default false
@@ -1051,8 +1116,8 @@ type UserLogger<TOptions extends LoggerOptions = LoggerOptions> = Logger<TOption
1051
1116
  */
1052
1117
  type CompatibilityPreset = 'default' | 'kubbV4';
1053
1118
  /**
1054
- * A preset bundles a name, one or more resolvers, and optional AST transformers
1055
- * into a single reusable configuration object.
1119
+ * A preset bundles a name, one or more resolvers, optional AST transformers,
1120
+ * and optional generators into a single reusable configuration object.
1056
1121
  *
1057
1122
  * @template TResolver - The concrete resolver type for this preset.
1058
1123
  */
@@ -1069,6 +1134,11 @@ type Preset<TResolver extends Resolver = Resolver> = {
1069
1134
  * Optional AST visitors / transformers applied after resolving.
1070
1135
  */
1071
1136
  transformers?: Array<Visitor>;
1137
+ /**
1138
+ * Optional generators used by this preset. Plugin implementations cast this
1139
+ * to their concrete generator type.
1140
+ */
1141
+ generators?: Array<Generator<any>>;
1072
1142
  };
1073
1143
  /**
1074
1144
  * A named registry of presets, keyed by preset name.
@@ -1077,9 +1147,148 @@ type Preset<TResolver extends Resolver = Resolver> = {
1077
1147
  * @template TName - The union of valid preset name keys.
1078
1148
  */
1079
1149
  type Presets<TResolver extends Resolver = Resolver> = Record<CompatibilityPreset, Preset<TResolver>>;
1150
+ type ByTag = {
1151
+ type: 'tag';
1152
+ pattern: string | RegExp;
1153
+ };
1154
+ type ByOperationId = {
1155
+ type: 'operationId';
1156
+ pattern: string | RegExp;
1157
+ };
1158
+ type ByPath = {
1159
+ type: 'path';
1160
+ pattern: string | RegExp;
1161
+ };
1162
+ type ByMethod = {
1163
+ type: 'method';
1164
+ pattern: HttpMethod | RegExp;
1165
+ };
1166
+ type BySchemaName = {
1167
+ type: 'schemaName';
1168
+ pattern: string | RegExp;
1169
+ };
1170
+ type ByContentType = {
1171
+ type: 'contentType';
1172
+ pattern: string | RegExp;
1173
+ };
1174
+ type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
1175
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
1176
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
1177
+ options: Partial<TOptions>;
1178
+ };
1179
+ type ResolvePathOptions = {
1180
+ pluginName?: string;
1181
+ group?: {
1182
+ tag?: string;
1183
+ path?: string;
1184
+ };
1185
+ type?: ResolveNameParams['type'];
1186
+ };
1187
+ /**
1188
+ * File-specific parameters for `Resolver.resolvePath`.
1189
+ *
1190
+ * Pass alongside a `ResolverContext` to identify which file to resolve.
1191
+ * Provide `tag` for tag-based grouping or `path` for path-based grouping.
1192
+ *
1193
+ * @example
1194
+ * ```ts
1195
+ * resolver.resolvePath(
1196
+ * { baseName: 'petTypes.ts', tag: 'pets' },
1197
+ * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
1198
+ * )
1199
+ * // → '/src/types/petsController/petTypes.ts'
1200
+ * ```
1201
+ */
1202
+ type ResolverPathParams = {
1203
+ baseName: FabricFile.BaseName;
1204
+ pathMode?: FabricFile.Mode;
1205
+ /**
1206
+ * Tag value used when `group.type === 'tag'`.
1207
+ */
1208
+ tag?: string;
1209
+ /**
1210
+ * Path value used when `group.type === 'path'`.
1211
+ */
1212
+ path?: string;
1213
+ };
1214
+ /**
1215
+ * Shared context passed as the second argument to `Resolver.resolvePath` and `Resolver.resolveFile`.
1216
+ *
1217
+ * Describes where on disk output is rooted, which output config is active, and the optional
1218
+ * grouping strategy that controls subdirectory layout.
1219
+ *
1220
+ * @example
1221
+ * ```ts
1222
+ * const context: ResolverContext = {
1223
+ * root: config.root,
1224
+ * output,
1225
+ * group,
1226
+ * }
1227
+ * ```
1228
+ */
1229
+ type ResolverContext = {
1230
+ root: string;
1231
+ output: Output;
1232
+ group?: Group;
1233
+ /**
1234
+ * Plugin name used to populate `meta.pluginName` on the resolved file.
1235
+ */
1236
+ pluginName?: string;
1237
+ };
1238
+ /**
1239
+ * File-specific parameters for `Resolver.resolveFile`.
1240
+ *
1241
+ * Pass alongside a `ResolverContext` to fully describe the file to resolve.
1242
+ * `tag` and `path` are used only when a matching `group` is present in the context.
1243
+ *
1244
+ * @example
1245
+ * ```ts
1246
+ * resolver.resolveFile(
1247
+ * { name: 'listPets', extname: '.ts', tag: 'pets' },
1248
+ * { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
1249
+ * )
1250
+ * // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
1251
+ * ```
1252
+ */
1253
+ type ResolverFileParams = {
1254
+ name: string;
1255
+ extname: FabricFile.Extname;
1256
+ /**
1257
+ * Tag value used when `group.type === 'tag'`.
1258
+ */
1259
+ tag?: string;
1260
+ /**
1261
+ * Path value used when `group.type === 'path'`.
1262
+ */
1263
+ path?: string;
1264
+ };
1265
+ /**
1266
+ * Context passed to `Resolver.resolveBanner` and `Resolver.resolveFooter`.
1267
+ *
1268
+ * `output` is optional — not every plugin configures a banner/footer.
1269
+ * `config` carries the global Kubb config, used to derive the default Kubb banner.
1270
+ *
1271
+ * @example
1272
+ * ```ts
1273
+ * resolver.resolveBanner(rootNode, { output: { banner: '// generated' }, config })
1274
+ * // → '// generated'
1275
+ * ```
1276
+ */
1277
+ type ResolveBannerContext = {
1278
+ output?: Pick<Output, 'banner' | 'footer'>;
1279
+ config: Config;
1280
+ };
1080
1281
  //#endregion
1081
1282
  //#region src/PluginDriver.d.ts
1082
1283
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
1284
+ /**
1285
+ * Hook dispatch strategy used by the `PluginDriver`.
1286
+ *
1287
+ * - `hookFirst` — stops at the first non-null result.
1288
+ * - `hookForPlugin` — calls only the matching plugin.
1289
+ * - `hookParallel` — calls all plugins concurrently.
1290
+ * - `hookSeq` — calls all plugins in order, threading the result.
1291
+ */
1083
1292
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
1084
1293
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
1085
1294
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
@@ -1094,14 +1303,26 @@ type Options = {
1094
1303
  */
1095
1304
  concurrency?: number;
1096
1305
  };
1306
+ /**
1307
+ * Parameters accepted by `PluginDriver.getFile` to resolve a generated file descriptor.
1308
+ */
1097
1309
  type GetFileOptions<TOptions = object> = {
1098
1310
  name: string;
1099
- mode?: KubbFile.Mode;
1100
- extname: KubbFile.Extname;
1311
+ mode?: FabricFile.Mode;
1312
+ extname: FabricFile.Extname;
1101
1313
  pluginName: string;
1102
1314
  options?: TOptions;
1103
1315
  };
1104
- declare function getMode(fileOrFolder: string | undefined | null): KubbFile.Mode;
1316
+ /**
1317
+ * Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
1318
+ *
1319
+ * @example
1320
+ * ```ts
1321
+ * getMode('src/gen/types.ts') // 'single'
1322
+ * getMode('src/gen/types') // 'split'
1323
+ * ```
1324
+ */
1325
+ declare function getMode(fileOrFolder: string | undefined | null): FabricFile.Mode;
1105
1326
  declare class PluginDriver {
1106
1327
  #private;
1107
1328
  readonly config: Config;
@@ -1122,10 +1343,10 @@ declare class PluginDriver {
1122
1343
  extname,
1123
1344
  pluginName,
1124
1345
  options
1125
- }: GetFileOptions<TOptions>): KubbFile.File<{
1346
+ }: GetFileOptions<TOptions>): FabricFile.File<{
1126
1347
  pluginName: string;
1127
1348
  }>;
1128
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
1349
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => FabricFile.Path;
1129
1350
  resolveName: (params: ResolveNameParams) => string;
1130
1351
  /**
1131
1352
  * Run a specific hookName for plugin x.
@@ -1199,5 +1420,5 @@ declare class PluginDriver {
1199
1420
  getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
1200
1421
  }
1201
1422
  //#endregion
1202
- export { ResolveOptionsContext as A, ReactGeneratorV2 as B, PluginParameter as C, Printer as D, Presets as E, UserPlugin as F, formatters as G, KubbEvents as H, UserPluginWithLifeCycle as I, PossiblePromise as J, linters as K, UserResolver as L, Resolver as M, UserConfig as N, PrinterFactoryOptions as O, UserLogger as P, CoreGeneratorV2 as R, PluginLifecycleHooks as S, Preset as T, Storage as U, defineGenerator as V, createStorage as W, AsyncEventEmitter as Y, Output as _, AdapterFactoryOptions as a, PluginFactoryOptions as b, CompatibilityPreset as c, Group as d, InputData as f, LoggerOptions as g, LoggerContext as h, Adapter as i, ResolvePathParams as j, ResolveNameParams as k, Config as l, Logger as m, PluginDriver as n, AdapterSource as o, InputPath as p, logLevel as q, getMode as r, BarrelType as s, GetFileOptions as t, DevtoolsOptions as u, Plugin as v, PluginWithLifeCycle as w, PluginLifecycle as x, PluginContext as y, Generator as z };
1203
- //# sourceMappingURL=PluginDriver-BkSenc-R.d.ts.map
1423
+ export { formatters as $, Printer as A, ResolverPathParams as B, PluginFactoryOptions as C, PluginWithLifeCycle as D, PluginParameter as E, ResolvePathOptions as F, UserResolver as G, UserLogger as H, ResolvePathParams as I, Generator as J, KubbEvents as K, Resolver as L, ResolveBannerContext as M, ResolveNameParams as N, Preset as O, ResolveOptionsContext as P, createStorage as Q, ResolverContext as R, PluginContext as S, PluginLifecycleHooks as T, UserPlugin as U, UserConfig as V, UserPluginWithLifeCycle as W, defineGenerator as X, ReactGeneratorV2 as Y, Storage as Z, LoggerContext as _, AdapterSource as a, Override as b, CompatibilityPreset as c, Exclude as d, linters as et, Group as f, Logger as g, InputPath as h, AdapterFactoryOptions as i, PrinterFactoryOptions as j, Presets as k, Config as l, InputData as m, getMode as n, PossiblePromise as nt, BarrelType as o, Include as p, CoreGeneratorV2 as q, Adapter as r, AsyncEventEmitter as rt, Builder as s, PluginDriver as t, logLevel as tt, DevtoolsOptions as u, LoggerOptions as v, PluginLifecycle as w, Plugin as x, Output as y, ResolverFileParams as z };
1424
+ //# sourceMappingURL=PluginDriver-DZdEyCoa.d.ts.map