@kubb/core 5.0.0-alpha.21 → 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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
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-CEQPafXV.js";
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
4
  import { Node, OperationNode, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
5
- import { Fabric, KubbFile } from "@kubb/fabric-core/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<KubbFile.ResolvedFile>;
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<KubbFile.Path, string>;
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<KubbFile.Path, string>;
180
+ sources: Map<FabricFile.Path, string>;
181
181
  };
182
182
  /**
183
183
  * Initializes all Kubb infrastructure for a build without executing any plugins.
@@ -479,11 +479,11 @@ declare function defaultResolvePath({
479
479
  root,
480
480
  output,
481
481
  group
482
- }: ResolverContext): KubbFile.Path;
482
+ }: ResolverContext): FabricFile.Path;
483
483
  /**
484
484
  * Default file resolver used by `defineResolver`.
485
485
  *
486
- * Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
486
+ * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
487
487
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
488
488
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
489
489
  *
@@ -512,7 +512,7 @@ declare function defaultResolveFile(this: Resolver, {
512
512
  extname,
513
513
  tag,
514
514
  path: groupPath
515
- }: ResolverFileParams, context: ResolverContext): KubbFile.File;
515
+ }: ResolverFileParams, context: ResolverContext): FabricFile.File;
516
516
  /**
517
517
  * Generates the default "Generated by Kubb" banner from config and optional node metadata.
518
518
  */
@@ -589,7 +589,7 @@ declare function defaultResolveFooter(node: RootNode | undefined, {
589
589
  * - `default` — name casing strategy (camelCase / PascalCase)
590
590
  * - `resolveOptions` — include/exclude/override filtering
591
591
  * - `resolvePath` — output path computation
592
- * - `resolveFile` — full `KubbFile.File` construction
592
+ * - `resolveFile` — full `FabricFile.File` construction
593
593
  *
594
594
  * Methods in the builder have access to `this` (the full resolver object), so they
595
595
  * can call other resolver methods without circular imports.
@@ -808,12 +808,12 @@ type AddIndexesProps = {
808
808
  * - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
809
809
  * - Attaches `meta` to each barrel file for downstream plugin identification.
810
810
  */
811
- declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
811
+ declare function getBarrelFiles(files: Array<FabricFile.ResolvedFile>, {
812
812
  type,
813
813
  meta,
814
814
  root,
815
815
  output
816
- }: AddIndexesProps): Promise<Array<KubbFile.File>>;
816
+ }: AddIndexesProps): Promise<Array<FabricFile.File>>;
817
817
  //#endregion
818
818
  //#region src/utils/getConfigs.d.ts
819
819
  /**
@@ -872,7 +872,15 @@ declare function detectLinter(): Promise<Linter | null>;
872
872
  //#endregion
873
873
  //#region src/utils/mergeResolvers.d.ts
874
874
  /**
875
- * Merges an array of resolvers into a single resolver. Later entries override earlier ones (last wins).
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
+ * ```
876
884
  */
877
885
  declare function mergeResolvers<T extends Resolver>(...resolvers: Array<T>): T;
878
886
  //#endregion
package/dist/index.js CHANGED
@@ -965,6 +965,15 @@ function hookParallel(promises, concurrency = Number.POSITIVE_INFINITY) {
965
965
  }
966
966
  //#endregion
967
967
  //#region src/PluginDriver.ts
968
+ /**
969
+ * Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
970
+ *
971
+ * @example
972
+ * ```ts
973
+ * getMode('src/gen/types.ts') // 'single'
974
+ * getMode('src/gen/types') // 'split'
975
+ * ```
976
+ */
968
977
  function getMode(fileOrFolder) {
969
978
  if (!fileOrFolder) return "split";
970
979
  return extname(fileOrFolder) ? "single" : "split";
@@ -1463,7 +1472,7 @@ const fsStorage = createStorage(() => ({
1463
1472
  }));
1464
1473
  //#endregion
1465
1474
  //#region package.json
1466
- var version$1 = "5.0.0-alpha.21";
1475
+ var version$1 = "5.0.0-alpha.22";
1467
1476
  //#endregion
1468
1477
  //#region src/utils/diagnostics.ts
1469
1478
  /**
@@ -2104,7 +2113,7 @@ function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root
2104
2113
  /**
2105
2114
  * Default file resolver used by `defineResolver`.
2106
2115
  *
2107
- * Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
2116
+ * Resolves a `FabricFile.File` by combining name resolution (`resolver.default`) with
2108
2117
  * path resolution (`resolver.resolvePath`). The resolved file always has empty
2109
2118
  * `sources`, `imports`, and `exports` arrays — consumers populate those separately.
2110
2119
  *
@@ -2240,7 +2249,7 @@ function defaultResolveFooter(node, { output }) {
2240
2249
  * - `default` — name casing strategy (camelCase / PascalCase)
2241
2250
  * - `resolveOptions` — include/exclude/override filtering
2242
2251
  * - `resolvePath` — output path computation
2243
- * - `resolveFile` — full `KubbFile.File` construction
2252
+ * - `resolveFile` — full `FabricFile.File` construction
2244
2253
  *
2245
2254
  * Methods in the builder have access to `this` (the full resolver object), so they
2246
2255
  * can call other resolver methods without circular imports.
@@ -2527,7 +2536,7 @@ async function detectFormatter() {
2527
2536
  //#region src/utils/TreeNode.ts
2528
2537
  /**
2529
2538
  * Tree structure used to build per-directory barrel (`index.ts`) files from a
2530
- * flat list of generated {@link KubbFile.File} entries.
2539
+ * flat list of generated {@link FabricFile.File} entries.
2531
2540
  *
2532
2541
  * Each node represents either a directory or a file within the output tree.
2533
2542
  * Use {@link TreeNode.build} to construct a root node from a file list, then
@@ -2569,24 +2578,39 @@ var TreeNode = class TreeNode {
2569
2578
  this.#cachedLeaves = leaves;
2570
2579
  return leaves;
2571
2580
  }
2581
+ /**
2582
+ * Visits this node and every descendant in depth-first order.
2583
+ */
2572
2584
  forEach(callback) {
2573
2585
  if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
2574
2586
  callback(this);
2575
2587
  for (const child of this.children) child.forEach(callback);
2576
2588
  return this;
2577
2589
  }
2590
+ /**
2591
+ * Finds the first leaf that satisfies `predicate`, or `undefined` when none match.
2592
+ */
2578
2593
  findDeep(predicate) {
2579
2594
  if (typeof predicate !== "function") throw new TypeError("find() predicate must be a function");
2580
2595
  return this.leaves.find(predicate);
2581
2596
  }
2597
+ /**
2598
+ * Calls `callback` for every leaf of this node.
2599
+ */
2582
2600
  forEachDeep(callback) {
2583
2601
  if (typeof callback !== "function") throw new TypeError("forEach() callback must be a function");
2584
2602
  this.leaves.forEach(callback);
2585
2603
  }
2604
+ /**
2605
+ * Returns all leaves that satisfy `callback`.
2606
+ */
2586
2607
  filterDeep(callback) {
2587
2608
  if (typeof callback !== "function") throw new TypeError("filter() callback must be a function");
2588
2609
  return this.leaves.filter(callback);
2589
2610
  }
2611
+ /**
2612
+ * Maps every leaf through `callback` and returns the resulting array.
2613
+ */
2590
2614
  mapDeep(callback) {
2591
2615
  if (typeof callback !== "function") throw new TypeError("map() callback must be a function");
2592
2616
  return this.leaves.map(callback);
@@ -2759,7 +2783,15 @@ async function getConfigs(config, args) {
2759
2783
  //#endregion
2760
2784
  //#region src/utils/mergeResolvers.ts
2761
2785
  /**
2762
- * Merges an array of resolvers into a single resolver. Later entries override earlier ones (last wins).
2786
+ * Merges an ordered list of resolvers into a single resolver by shallow-merging each entry left to right.
2787
+ *
2788
+ * Later entries win when keys conflict, so the last resolver in the list takes highest precedence.
2789
+ *
2790
+ * @example
2791
+ * ```ts
2792
+ * const resolver = mergeResolvers(resolverTs, resolverTsLegacy)
2793
+ * // resolverTsLegacy methods override resolverTs where they overlap
2794
+ * ```
2763
2795
  */
2764
2796
  function mergeResolvers(...resolvers) {
2765
2797
  return resolvers.reduce((acc, curr) => ({