@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.
- package/dist/{PluginDriver-BkSenc-R.d.ts → PluginDriver-DZdEyCoa.d.ts} +344 -123
- package/dist/hooks.cjs +9 -91
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +10 -78
- package/dist/hooks.js +8 -88
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +347 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +275 -31
- package/dist/index.js +342 -35
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Kubb.ts +5 -5
- package/src/PluginDriver.ts +29 -9
- package/src/build.ts +9 -9
- package/src/constants.ts +2 -2
- package/src/defineBuilder.ts +26 -0
- package/src/defineGenerator.ts +25 -7
- package/src/definePreset.ts +9 -5
- package/src/defineResolver.ts +336 -16
- package/src/hooks/index.ts +1 -2
- package/src/hooks/useDriver.ts +13 -0
- package/src/hooks/useMode.ts +4 -4
- package/src/hooks/usePlugin.ts +1 -1
- package/src/index.ts +10 -1
- package/src/renderNode.tsx +10 -13
- package/src/types.ts +235 -26
- package/src/utils/TreeNode.ts +22 -7
- package/src/utils/getBarrelFiles.ts +10 -7
- package/src/utils/getPreset.ts +17 -6
- package/src/utils/mergeResolvers.ts +9 -1
- package/src/hooks/useKubb.ts +0 -160
- package/src/hooks/usePluginDriver.ts +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { $ as formatters, A as Printer, B as ResolverPathParams, C as PluginFactoryOptions, D as PluginWithLifeCycle, E as PluginParameter, F as ResolvePathOptions, G as UserResolver, H as UserLogger, I as ResolvePathParams, J as Generator, K as KubbEvents, L as Resolver, M as ResolveBannerContext, N as ResolveNameParams, O as Preset, P as ResolveOptionsContext, Q as createStorage, R as ResolverContext, S as PluginContext, T as PluginLifecycleHooks, U as UserPlugin, V as UserConfig, W as UserPluginWithLifeCycle, X as defineGenerator, Y as ReactGeneratorV2, Z as Storage, _ as LoggerContext, a as AdapterSource, b as Override, c as CompatibilityPreset, d as Exclude, et as linters, f as Group, g as Logger, h as InputPath, i as AdapterFactoryOptions, j as PrinterFactoryOptions, k as Presets, l as Config, m as InputData, n as getMode, nt as PossiblePromise, o as BarrelType, p as Include, q as CoreGeneratorV2, r as Adapter, rt as AsyncEventEmitter, s as Builder, t as PluginDriver, tt as logLevel, u as DevtoolsOptions, v as LoggerOptions, w as PluginLifecycle, x as Plugin, y as Output, z as ResolverFileParams } from "./PluginDriver-DZdEyCoa.js";
|
|
3
3
|
import { definePrinter } from "@kubb/ast";
|
|
4
|
-
import { Node, OperationNode, SchemaNode, Visitor } from "@kubb/ast/types";
|
|
5
|
-
import { Fabric,
|
|
4
|
+
import { Node, OperationNode, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
|
|
5
|
+
import { Fabric, FabricFile } from "@kubb/fabric-core/types";
|
|
6
6
|
import { Fabric as Fabric$1 } from "@kubb/react-fabric/types";
|
|
7
7
|
|
|
8
8
|
//#region ../../internals/utils/src/urlPath.d.ts
|
|
@@ -158,7 +158,7 @@ type BuildOutput = {
|
|
|
158
158
|
error: Error;
|
|
159
159
|
}>;
|
|
160
160
|
fabric: Fabric;
|
|
161
|
-
files: Array<
|
|
161
|
+
files: Array<FabricFile.ResolvedFile>;
|
|
162
162
|
driver: PluginDriver;
|
|
163
163
|
/**
|
|
164
164
|
* Elapsed time in milliseconds for each plugin, keyed by plugin name.
|
|
@@ -168,7 +168,7 @@ type BuildOutput = {
|
|
|
168
168
|
/**
|
|
169
169
|
* Raw generated source, keyed by absolute file path.
|
|
170
170
|
*/
|
|
171
|
-
sources: Map<
|
|
171
|
+
sources: Map<FabricFile.Path, string>;
|
|
172
172
|
};
|
|
173
173
|
/**
|
|
174
174
|
* Intermediate result returned by {@link setup} and accepted by {@link safeBuild}.
|
|
@@ -177,7 +177,7 @@ type SetupResult = {
|
|
|
177
177
|
events: AsyncEventEmitter<KubbEvents>;
|
|
178
178
|
fabric: Fabric;
|
|
179
179
|
driver: PluginDriver;
|
|
180
|
-
sources: Map<
|
|
180
|
+
sources: Map<FabricFile.Path, string>;
|
|
181
181
|
};
|
|
182
182
|
/**
|
|
183
183
|
* Initializes all Kubb infrastructure for a build without executing any plugins.
|
|
@@ -303,6 +303,29 @@ type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (opt
|
|
|
303
303
|
*/
|
|
304
304
|
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(build: PluginBuilder<T>): (options?: T['options']) => UserPluginWithLifeCycle<T>;
|
|
305
305
|
//#endregion
|
|
306
|
+
//#region src/defineBuilder.d.ts
|
|
307
|
+
/**
|
|
308
|
+
* Builder type for the plugin-specific builder fields.
|
|
309
|
+
* `name` is required; all other methods are defined by the concrete plugin builder type.
|
|
310
|
+
*/
|
|
311
|
+
type BuilderBuilder<T extends PluginFactoryOptions> = () => T['builder'] & ThisType<T['builder']>;
|
|
312
|
+
/**
|
|
313
|
+
* Defines a builder for a plugin — a named collection of schema-building helpers that
|
|
314
|
+
* can be exported alongside the plugin and imported by other plugins or generators.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* export const builder = defineBuilder<PluginTs>(() => ({
|
|
318
|
+
* name: 'default',
|
|
319
|
+
* buildParamsSchema({ params, node, resolver }) {
|
|
320
|
+
* return createSchema({ type: 'object', properties: [] })
|
|
321
|
+
* },
|
|
322
|
+
* buildDataSchemaNode({ node, resolver }) {
|
|
323
|
+
* return createSchema({ type: 'object', properties: [] })
|
|
324
|
+
* },
|
|
325
|
+
* }))
|
|
326
|
+
*/
|
|
327
|
+
declare function defineBuilder<T extends PluginFactoryOptions>(build: BuilderBuilder<T>): T['builder'];
|
|
328
|
+
//#endregion
|
|
306
329
|
//#region src/defineLogger.d.ts
|
|
307
330
|
/**
|
|
308
331
|
* Wraps a logger definition into a typed {@link Logger}.
|
|
@@ -320,8 +343,8 @@ declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(log
|
|
|
320
343
|
//#endregion
|
|
321
344
|
//#region src/definePreset.d.ts
|
|
322
345
|
/**
|
|
323
|
-
* Creates a typed preset object that bundles a name, resolvers,
|
|
324
|
-
* transformers — the building block for composable plugin presets.
|
|
346
|
+
* Creates a typed preset object that bundles a name, resolvers, optional
|
|
347
|
+
* transformers, and optional generators — the building block for composable plugin presets.
|
|
325
348
|
*
|
|
326
349
|
* @example
|
|
327
350
|
* import { definePreset } from '@kubb/core'
|
|
@@ -332,13 +355,19 @@ declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(log
|
|
|
332
355
|
* @example
|
|
333
356
|
* // With custom transformers
|
|
334
357
|
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], transformers: [myTransformer] })
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* // With generators
|
|
361
|
+
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], generators: [typeGeneratorLegacy] })
|
|
335
362
|
*/
|
|
336
363
|
declare function definePreset<TResolver extends Resolver = Resolver, TName extends string = string>(name: TName, {
|
|
337
364
|
resolvers,
|
|
338
|
-
transformers
|
|
365
|
+
transformers,
|
|
366
|
+
generators
|
|
339
367
|
}: {
|
|
340
368
|
resolvers: Array<TResolver>;
|
|
341
369
|
transformers?: Array<Visitor>;
|
|
370
|
+
generators?: Array<Generator<any>>;
|
|
342
371
|
}): Preset<TResolver> & {
|
|
343
372
|
name: TName;
|
|
344
373
|
};
|
|
@@ -360,14 +389,36 @@ declare function definePresets<TResolver extends Resolver = Resolver>(presets: P
|
|
|
360
389
|
//#region src/defineResolver.d.ts
|
|
361
390
|
/**
|
|
362
391
|
* Builder type for the plugin-specific resolver fields.
|
|
363
|
-
*
|
|
392
|
+
*
|
|
393
|
+
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
394
|
+
* are optional — built-in fallbacks are injected when omitted.
|
|
364
395
|
*/
|
|
365
|
-
type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions' | 'name'> & Partial<Pick<T['resolver'], 'default' | 'resolveOptions'>> & {
|
|
396
|
+
type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'> & Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {
|
|
366
397
|
name: string;
|
|
398
|
+
pluginName: T['name'];
|
|
367
399
|
} & ThisType<T['resolver']>;
|
|
368
400
|
/**
|
|
369
|
-
* Default option resolver — applies include/exclude filters and merges
|
|
370
|
-
*
|
|
401
|
+
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
402
|
+
*
|
|
403
|
+
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
404
|
+
*
|
|
405
|
+
* @example Include/exclude filtering
|
|
406
|
+
* ```ts
|
|
407
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
408
|
+
* options: { output: 'types' },
|
|
409
|
+
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
410
|
+
* })
|
|
411
|
+
* // → null when node has tag 'internal'
|
|
412
|
+
* ```
|
|
413
|
+
*
|
|
414
|
+
* @example Override merging
|
|
415
|
+
* ```ts
|
|
416
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
417
|
+
* options: { enumType: 'asConst' },
|
|
418
|
+
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
419
|
+
* })
|
|
420
|
+
* // → { enumType: 'enum' } when operationId matches
|
|
421
|
+
* ```
|
|
371
422
|
*/
|
|
372
423
|
declare function defaultResolveOptions<TOptions>(node: Node, {
|
|
373
424
|
options,
|
|
@@ -376,22 +427,205 @@ declare function defaultResolveOptions<TOptions>(node: Node, {
|
|
|
376
427
|
override
|
|
377
428
|
}: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
378
429
|
/**
|
|
379
|
-
*
|
|
380
|
-
* Override `default` or `resolveOptions` in the builder to customize the behavior.
|
|
430
|
+
* Default path resolver used by `defineResolver`.
|
|
381
431
|
*
|
|
382
|
-
*
|
|
432
|
+
* - Returns the output directory in `single` mode.
|
|
433
|
+
* - Resolves into a tag- or path-based subdirectory when `group` and a `tag`/`path` value are provided.
|
|
434
|
+
* - Falls back to a flat `output/baseName` path otherwise.
|
|
435
|
+
*
|
|
436
|
+
* A custom `group.name` function overrides the default subdirectory naming.
|
|
437
|
+
* For `tag` groups the default is `${camelCase(tag)}Controller`.
|
|
438
|
+
* For `path` groups the default is the first path segment after `/`.
|
|
439
|
+
*
|
|
440
|
+
* @example Flat output
|
|
441
|
+
* ```ts
|
|
442
|
+
* defaultResolvePath({ baseName: 'petTypes.ts' }, { root: '/src', output: { path: 'types' } })
|
|
443
|
+
* // → '/src/types/petTypes.ts'
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @example Tag-based grouping
|
|
447
|
+
* ```ts
|
|
448
|
+
* defaultResolvePath(
|
|
449
|
+
* { baseName: 'petTypes.ts', tag: 'pets' },
|
|
450
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
451
|
+
* )
|
|
452
|
+
* // → '/src/types/petsController/petTypes.ts'
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @example Path-based grouping
|
|
456
|
+
* ```ts
|
|
457
|
+
* defaultResolvePath(
|
|
458
|
+
* { baseName: 'petTypes.ts', path: '/pets/list' },
|
|
459
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'path' } },
|
|
460
|
+
* )
|
|
461
|
+
* // → '/src/types/pets/petTypes.ts'
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* @example Single-file mode
|
|
465
|
+
* ```ts
|
|
466
|
+
* defaultResolvePath(
|
|
467
|
+
* { baseName: 'petTypes.ts', pathMode: 'single' },
|
|
468
|
+
* { root: '/src', output: { path: 'types' } },
|
|
469
|
+
* )
|
|
470
|
+
* // → '/src/types'
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
declare function defaultResolvePath({
|
|
474
|
+
baseName,
|
|
475
|
+
pathMode,
|
|
476
|
+
tag,
|
|
477
|
+
path: groupPath
|
|
478
|
+
}: ResolverPathParams, {
|
|
479
|
+
root,
|
|
480
|
+
output,
|
|
481
|
+
group
|
|
482
|
+
}: ResolverContext): FabricFile.Path;
|
|
483
|
+
/**
|
|
484
|
+
* Default file resolver used by `defineResolver`.
|
|
485
|
+
*
|
|
486
|
+
* Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
|
|
487
|
+
* path resolution (`resolver.resolvePath`). The resolved file always has empty
|
|
488
|
+
* `sources`, `imports`, and `exports` arrays — consumers populate those separately.
|
|
489
|
+
*
|
|
490
|
+
* In `single` mode the name is omitted and the file sits directly in the output directory.
|
|
491
|
+
*
|
|
492
|
+
* @example Resolve a schema file
|
|
493
|
+
* ```ts
|
|
494
|
+
* const file = defaultResolveFile.call(resolver,
|
|
495
|
+
* { name: 'pet', extname: '.ts' },
|
|
496
|
+
* { root: '/src', output: { path: 'types' } },
|
|
497
|
+
* )
|
|
498
|
+
* // → { baseName: 'pet.ts', path: '/src/types/pet.ts', sources: [], ... }
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @example Resolve an operation file with tag grouping
|
|
502
|
+
* ```ts
|
|
503
|
+
* const file = defaultResolveFile.call(resolver,
|
|
504
|
+
* { name: 'listPets', extname: '.ts', tag: 'pets' },
|
|
505
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
506
|
+
* )
|
|
507
|
+
* // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare function defaultResolveFile(this: Resolver, {
|
|
511
|
+
name,
|
|
512
|
+
extname,
|
|
513
|
+
tag,
|
|
514
|
+
path: groupPath
|
|
515
|
+
}: ResolverFileParams, context: ResolverContext): FabricFile.File;
|
|
516
|
+
/**
|
|
517
|
+
* Generates the default "Generated by Kubb" banner from config and optional node metadata.
|
|
518
|
+
*/
|
|
519
|
+
declare function buildDefaultBanner({
|
|
520
|
+
title,
|
|
521
|
+
description,
|
|
522
|
+
version,
|
|
523
|
+
config
|
|
524
|
+
}: {
|
|
525
|
+
title?: string;
|
|
526
|
+
description?: string;
|
|
527
|
+
version?: string;
|
|
528
|
+
config: Config;
|
|
529
|
+
}): string;
|
|
530
|
+
/**
|
|
531
|
+
* Default banner resolver — returns the banner string for a generated file.
|
|
532
|
+
*
|
|
533
|
+
* - When `output.banner` is a function and `node` is provided, calls it with the node.
|
|
534
|
+
* - When `output.banner` is a function and `node` is absent, falls back to the default Kubb banner.
|
|
535
|
+
* - When `output.banner` is a string, returns it directly.
|
|
536
|
+
* - When `config.output.defaultBanner` is `false`, returns `undefined`.
|
|
537
|
+
* - Otherwise returns the default "Generated by Kubb" banner.
|
|
538
|
+
*
|
|
539
|
+
* @example String banner
|
|
540
|
+
* ```ts
|
|
541
|
+
* defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
|
|
542
|
+
* // → '// my banner'
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @example Function banner with node
|
|
546
|
+
* ```ts
|
|
547
|
+
* defaultResolveBanner(rootNode, { output: { banner: (node) => `// v${node.version}` }, config })
|
|
548
|
+
* // → '// v3.0.0'
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @example Disabled banner
|
|
552
|
+
* ```ts
|
|
553
|
+
* defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
|
|
554
|
+
* // → undefined
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
declare function defaultResolveBanner(node: RootNode | undefined, {
|
|
558
|
+
output,
|
|
559
|
+
config
|
|
560
|
+
}: ResolveBannerContext): string | undefined;
|
|
561
|
+
/**
|
|
562
|
+
* Default footer resolver — returns the footer string for a generated file.
|
|
563
|
+
*
|
|
564
|
+
* - When `output.footer` is a function and `node` is provided, calls it with the node.
|
|
565
|
+
* - When `output.footer` is a function and `node` is absent, returns `undefined`.
|
|
566
|
+
* - When `output.footer` is a string, returns it directly.
|
|
567
|
+
* - Otherwise returns `undefined`.
|
|
568
|
+
*
|
|
569
|
+
* @example String footer
|
|
570
|
+
* ```ts
|
|
571
|
+
* defaultResolveFooter(undefined, { output: { footer: '// end of file' }, config })
|
|
572
|
+
* // → '// end of file'
|
|
573
|
+
* ```
|
|
574
|
+
*
|
|
575
|
+
* @example Function footer with node
|
|
576
|
+
* ```ts
|
|
577
|
+
* defaultResolveFooter(rootNode, { output: { footer: (node) => `// ${node.title}` }, config })
|
|
578
|
+
* // → '// Pet Store'
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
declare function defaultResolveFooter(node: RootNode | undefined, {
|
|
582
|
+
output
|
|
583
|
+
}: ResolveBannerContext): string | undefined;
|
|
584
|
+
/**
|
|
585
|
+
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
586
|
+
* include/exclude/override filtering, path resolution, and file construction.
|
|
587
|
+
*
|
|
588
|
+
* All four defaults can be overridden by providing them in the builder function:
|
|
589
|
+
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
590
|
+
* - `resolveOptions` — include/exclude/override filtering
|
|
591
|
+
* - `resolvePath` — output path computation
|
|
592
|
+
* - `resolveFile` — full `FabricFile.File` construction
|
|
593
|
+
*
|
|
594
|
+
* Methods in the builder have access to `this` (the full resolver object), so they
|
|
595
|
+
* can call other resolver methods without circular imports.
|
|
596
|
+
*
|
|
597
|
+
* @example Basic resolver with naming helpers
|
|
598
|
+
* ```ts
|
|
383
599
|
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
384
600
|
* name: 'default',
|
|
385
|
-
* resolveName(
|
|
386
|
-
* return this.default(name, 'function')
|
|
601
|
+
* resolveName(node) {
|
|
602
|
+
* return this.default(node.name, 'function')
|
|
387
603
|
* },
|
|
388
|
-
* resolveTypedName(
|
|
389
|
-
* return this.default(name, 'type')
|
|
604
|
+
* resolveTypedName(node) {
|
|
605
|
+
* return this.default(node.name, 'type')
|
|
390
606
|
* },
|
|
607
|
+
* }))
|
|
608
|
+
* ```
|
|
609
|
+
*
|
|
610
|
+
* @example Override resolvePath for a custom output structure
|
|
611
|
+
* ```ts
|
|
612
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
613
|
+
* name: 'custom',
|
|
614
|
+
* resolvePath({ baseName }, { root, output }) {
|
|
615
|
+
* return path.resolve(root, output.path, 'generated', baseName)
|
|
616
|
+
* },
|
|
617
|
+
* }))
|
|
618
|
+
* ```
|
|
619
|
+
*
|
|
620
|
+
* @example Use this.default inside a helper
|
|
621
|
+
* ```ts
|
|
622
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
623
|
+
* name: 'default',
|
|
391
624
|
* resolveParamName(node, param) {
|
|
392
|
-
* return this.
|
|
625
|
+
* return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
|
|
393
626
|
* },
|
|
394
627
|
* }))
|
|
628
|
+
* ```
|
|
395
629
|
*/
|
|
396
630
|
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
397
631
|
//#endregion
|
|
@@ -403,7 +637,6 @@ type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = {
|
|
|
403
637
|
Component: ReactGeneratorV2<TOptions>['Operations'] | undefined;
|
|
404
638
|
adapter: Adapter;
|
|
405
639
|
driver: PluginDriver;
|
|
406
|
-
mode: KubbFile.Mode;
|
|
407
640
|
options: TOptions['resolvedOptions'];
|
|
408
641
|
};
|
|
409
642
|
/**
|
|
@@ -417,7 +650,6 @@ type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = {
|
|
|
417
650
|
Component: ReactGeneratorV2<TOptions>['Operation'] | undefined;
|
|
418
651
|
adapter: Adapter;
|
|
419
652
|
driver: PluginDriver;
|
|
420
|
-
mode: KubbFile.Mode;
|
|
421
653
|
options: TOptions['resolvedOptions'];
|
|
422
654
|
};
|
|
423
655
|
/**
|
|
@@ -431,7 +663,6 @@ type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = {
|
|
|
431
663
|
Component: ReactGeneratorV2<TOptions>['Schema'] | undefined;
|
|
432
664
|
adapter: Adapter;
|
|
433
665
|
driver: PluginDriver;
|
|
434
|
-
mode: KubbFile.Mode;
|
|
435
666
|
options: TOptions['resolvedOptions'];
|
|
436
667
|
};
|
|
437
668
|
/**
|
|
@@ -577,12 +808,12 @@ type AddIndexesProps = {
|
|
|
577
808
|
* - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
|
|
578
809
|
* - Attaches `meta` to each barrel file for downstream plugin identification.
|
|
579
810
|
*/
|
|
580
|
-
declare function getBarrelFiles(files: Array<
|
|
811
|
+
declare function getBarrelFiles(files: Array<FabricFile.ResolvedFile>, {
|
|
581
812
|
type,
|
|
582
813
|
meta,
|
|
583
814
|
root,
|
|
584
815
|
output
|
|
585
|
-
}: AddIndexesProps): Promise<Array<
|
|
816
|
+
}: AddIndexesProps): Promise<Array<FabricFile.File>>;
|
|
586
817
|
//#endregion
|
|
587
818
|
//#region src/utils/getConfigs.d.ts
|
|
588
819
|
/**
|
|
@@ -599,20 +830,25 @@ type GetPresetParams<TResolver extends Resolver> = {
|
|
|
599
830
|
preset: CompatibilityPreset;
|
|
600
831
|
presets: Presets<TResolver>;
|
|
601
832
|
resolvers: Array<TResolver>;
|
|
833
|
+
/**
|
|
834
|
+
* User-supplied generators to append after the preset's generators.
|
|
835
|
+
*/
|
|
836
|
+
generators: Array<Generator<any>>;
|
|
602
837
|
transformers?: Array<Visitor>;
|
|
603
838
|
};
|
|
604
839
|
type GetPresetResult<TResolver extends Resolver> = {
|
|
605
|
-
baseResolver: TResolver;
|
|
606
840
|
resolver: TResolver;
|
|
607
841
|
transformers: Array<Visitor>;
|
|
842
|
+
generators: Array<Generator<any>>;
|
|
608
843
|
preset: Preset<TResolver> | undefined;
|
|
609
844
|
};
|
|
610
845
|
/**
|
|
611
|
-
* Resolves a named preset into merged resolvers and
|
|
846
|
+
* Resolves a named preset into merged resolvers, transformers, and generators.
|
|
612
847
|
*
|
|
613
|
-
* - Merges the preset's resolvers on top of the first (default)
|
|
848
|
+
* - Merges the preset's resolvers on top of the first (default)
|
|
614
849
|
* - Merges any additional user-supplied resolvers on top of that to produce the final `resolver`.
|
|
615
850
|
* - Concatenates preset transformers before user-supplied transformers.
|
|
851
|
+
* - Combines preset generators with user-supplied generators; falls back to the `default` preset's generators when neither provides any.
|
|
616
852
|
*/
|
|
617
853
|
declare function getPreset<TResolver extends Resolver = Resolver>(params: GetPresetParams<TResolver>): GetPresetResult<TResolver>;
|
|
618
854
|
//#endregion
|
|
@@ -636,7 +872,15 @@ declare function detectLinter(): Promise<Linter | null>;
|
|
|
636
872
|
//#endregion
|
|
637
873
|
//#region src/utils/mergeResolvers.d.ts
|
|
638
874
|
/**
|
|
639
|
-
* Merges an
|
|
875
|
+
* Merges an ordered list of resolvers into a single resolver by shallow-merging each entry left to right.
|
|
876
|
+
*
|
|
877
|
+
* Later entries win when keys conflict, so the last resolver in the list takes highest precedence.
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```ts
|
|
881
|
+
* const resolver = mergeResolvers(resolverTs, resolverTsLegacy)
|
|
882
|
+
* // resolverTsLegacy methods override resolverTs where they overlap
|
|
883
|
+
* ```
|
|
640
884
|
*/
|
|
641
885
|
declare function mergeResolvers<T extends Resolver>(...resolvers: Array<T>): T;
|
|
642
886
|
//#endregion
|
|
@@ -660,5 +904,5 @@ type DependencyVersion = string;
|
|
|
660
904
|
*/
|
|
661
905
|
declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
|
|
662
906
|
//#endregion
|
|
663
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveNameParams, ResolveOptionsContext, ResolvePathParams, Resolver, Storage, URLPath, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, createAdapter, createPlugin, createStorage, defaultResolveOptions, defineConfig, defineGenerator, defineLogger, definePreset, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
|
|
907
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, Builder, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, Exclude, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, Include, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Override, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineBuilder, defineConfig, defineGenerator, defineLogger, definePreset, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
|
|
664
908
|
//# sourceMappingURL=index.d.ts.map
|