@kubb/core 5.0.0-beta.62 → 5.0.0-beta.63

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.
@@ -225,12 +225,12 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
225
225
  * options,
226
226
  * document: null,
227
227
  * async parse(_source) {
228
- * // Convert `source` (path or inline data) into an InputNode.
228
+ * // Convert the source (path or inline data) into an InputNode.
229
229
  * return ast.factory.createInput()
230
230
  * },
231
231
  * getImports: () => [],
232
232
  * async validate() {
233
- * // Throw or call ctx.error here when the spec is invalid.
233
+ * // Throw here when the spec is invalid.
234
234
  * },
235
235
  * }))
236
236
  * ```
@@ -371,13 +371,13 @@ type GenerationResult = {
371
371
  hrStart: [number, number];
372
372
  };
373
373
  /**
374
- * Render context passed alongside the {@link GenerationResult}, carrying knobs a reporter needs
375
- * but that are not part of the run data (e.g. verbosity).
374
+ * Render settings passed alongside the {@link GenerationResult}. These are not part of the run
375
+ * data, such as the output verbosity.
376
376
  */
377
377
  type ReporterContext = {
378
378
  /**
379
379
  * Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
380
- * (`silent`, `error`, `warn`, `info`, `verbose`, `debug`).
380
+ * (`silent`, `error`, `warn`, `info`, `verbose`).
381
381
  */
382
382
  logLevel: (typeof logLevel)[keyof typeof logLevel];
383
383
  };
@@ -397,7 +397,7 @@ type Reporter = {
397
397
  report: (result: GenerationResult, context: ReporterContext) => void | Promise<void>;
398
398
  /**
399
399
  * Optional finalizer called once after the run's last config. The host wires it to
400
- * `kubb:lifecycle:end`. {@link createReporter} closes it over the reports `report` returned.
400
+ * `kubb:lifecycle:end`. {@link createReporter} closes it over the values that `report` returned.
401
401
  */
402
402
  drain?: (context: ReporterContext) => void | Promise<void>;
403
403
  };
@@ -471,8 +471,8 @@ type Storage = {
471
471
  */
472
472
  clear(base?: string): Promise<void>;
473
473
  /**
474
- * Optional teardown hook called after the build completes. Use to flush
475
- * buffers, close connections, or release file locks.
474
+ * Optional teardown hook for a backend to flush buffers, close connections,
475
+ * or release file locks.
476
476
  */
477
477
  dispose?(): Promise<void>;
478
478
  };
@@ -950,8 +950,8 @@ type Group = {
950
950
  */
951
951
  type: 'tag' | 'path';
952
952
  /**
953
- * Returns the subdirectory name from the group key. Defaults to the
954
- * camelCased tag for `tag` groups, or the first path segment for `path` groups.
953
+ * Returns the subdirectory name from the group key. Defaults to the camelCased tag for
954
+ * `tag` groups, or the camelCased first path segment for `path` groups.
955
955
  */
956
956
  name?: (context: {
957
957
  group: string;
@@ -1017,11 +1017,12 @@ type ByPath = {
1017
1017
  };
1018
1018
  type ByMethod = {
1019
1019
  /**
1020
- * Filter by HTTP method: `'get'`, `'post'`, `'put'`, `'delete'`, `'patch'`, `'head'`, `'options'`.
1020
+ * Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`.
1021
1021
  */
1022
1022
  type: 'method';
1023
1023
  /**
1024
- * HTTP method to match (case-insensitive when using string, or regex for dynamic matching).
1024
+ * HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
1025
+ * `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`) or a regex.
1025
1026
  */
1026
1027
  pattern: HttpMethod | RegExp;
1027
1028
  };
@@ -1186,7 +1187,7 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1186
1187
  *
1187
1188
  * - `'pre'` runs before all normal plugins.
1188
1189
  * - `'post'` runs after all normal plugins.
1189
- * - `undefined` (default), runs in declaration order among normal plugins.
1190
+ * - `undefined` (default) runs in declaration order among normal plugins.
1190
1191
  *
1191
1192
  * Dependency constraints always take precedence over `enforce`.
1192
1193
  */
@@ -1340,13 +1341,19 @@ declare class KubbDriver {
1340
1341
  readonly fileManager: FileManager;
1341
1342
  readonly plugins: Map<string, NormalizedPlugin>;
1342
1343
  constructor(config: Config, options: Options);
1344
+ /**
1345
+ * Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
1346
+ * A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
1347
+ * `'post'`. When the config has an adapter, the adapter source is resolved from the input
1348
+ * so `run` can parse it later.
1349
+ */
1343
1350
  setup(): Promise<void>;
1344
1351
  get hooks(): AsyncEventEmitter<KubbHooks>;
1345
1352
  /**
1346
1353
  * Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
1347
1354
  * can configure generators, resolvers, macros and renderers before `buildStart` runs.
1348
1355
  *
1349
- * Call this once from `safeBuild` before the plugin execution loop begins.
1356
+ * Called once from `run` before the plugin execution loop begins.
1350
1357
  */
1351
1358
  emitSetupHooks(): Promise<void>;
1352
1359
  /**
@@ -1437,11 +1444,11 @@ declare class KubbDriver {
1437
1444
  //#endregion
1438
1445
  //#region src/defineGenerator.d.ts
1439
1446
  /**
1440
- * Context object passed to generator `schema`, `operation`, and `operations` methods.
1447
+ * Context passed to a generator's `schema`, `operation`, and `operations` methods.
1441
1448
  *
1442
- * The adapter is always defined (guaranteed by `runPluginAstHooks`) so no runtime checks
1443
- * are needed. `ctx.options` carries resolved per-node options after exclude/include/override
1444
- * filtering for individual schema/operation calls, or plugin-level options for operations.
1449
+ * The driver sets `adapter` on the context before it runs a generator, so methods can read it
1450
+ * without a null check. `ctx.options` carries the per-node options after exclude/include/override
1451
+ * filtering for `schema` and `operation`, or the plugin-level options for `operations`.
1445
1452
  */
1446
1453
  type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1447
1454
  /**
@@ -1536,9 +1543,10 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
1536
1543
  /**
1537
1544
  * Declares a named generator unit that walks the AST and emits files.
1538
1545
  *
1539
- * Each method (`schema`, `operation`, `operations`) is called for the matching node type.
1540
- * JSX-based generators require a `renderer` factory. Return `Array<FileNode>` directly, or call
1541
- * `ctx.upsertFile()` manually and return `null` to bypass rendering.
1546
+ * `schema` runs for each schema node and `operation` for each operation node. `operations` runs
1547
+ * once after every operation node is walked. JSX-based generators require a `renderer` factory.
1548
+ * Return `Array<FileNode>` directly, or call `ctx.upsertFile()` manually and return `null` to
1549
+ * bypass rendering.
1542
1550
  *
1543
1551
  * @note Generators are consumed by plugins and registered via `ctx.addGenerator()` in `kubb:plugin:setup`.
1544
1552
  *
@@ -1646,8 +1654,9 @@ type Parser<TMeta extends object = object, TNode = unknown> = {
1646
1654
  */
1647
1655
  name: string;
1648
1656
  /**
1649
- * File extensions this parser handles. Set to `undefined` to define a
1650
- * catch-all fallback used when no other parser claims the extension.
1657
+ * File extensions this parser handles. The driver registers the parser for each
1658
+ * extension in this list. A parser with `undefined` here is not registered, so
1659
+ * files of an unclaimed extension fall back to joining their sources verbatim.
1651
1660
  *
1652
1661
  * @example
1653
1662
  * `['.ts', '.js']`
@@ -1698,9 +1707,8 @@ type CreateKubbOptions = {
1698
1707
  * config in the constructor, so `config` is available right away, and shares `hooks`,
1699
1708
  * `storage`, and `driver` across the `setup → build` lifecycle.
1700
1709
  *
1701
- * `createKubb` takes a plain, serializable config object (the shape `defineConfig`
1702
- * produces), not a fluent builder. Config stays plain data so it can be cache
1703
- * fingerprinted and validated against the shipped JSON schema.
1710
+ * `createKubb` takes a plain config object (the shape `defineConfig` produces),
1711
+ * not a fluent builder.
1704
1712
  *
1705
1713
  * Attach event listeners to `.hooks` before calling `setup()` or `build()`.
1706
1714
  *
@@ -1929,7 +1937,7 @@ type Config<TInput = Input> = {
1929
1937
  *
1930
1938
  * @example
1931
1939
  * ```ts
1932
- * format: 'auto' // auto-detect prettier, biome, or oxfmt
1940
+ * format: 'auto' // auto-detect oxfmt, biome, or prettier
1933
1941
  * format: 'prettier' // force prettier
1934
1942
  * format: false // skip formatting
1935
1943
  * ```
@@ -2701,7 +2709,7 @@ declare function narrow<C extends DiagnosticCode>(diagnostic: Diagnostic, code:
2701
2709
  /**
2702
2710
  * A {@link Diagnostic} reduced to its JSON-safe fields plus a `docsUrl`, for
2703
2711
  * machine-readable output (the `--reporter json` report, the MCP tools). Drops the
2704
- * non-serializable `cause` and the `timing`/`duration` bookkeeping.
2712
+ * non-serializable `cause` and the `kind`/`duration` bookkeeping.
2705
2713
  */
2706
2714
  type SerializedDiagnostic = {
2707
2715
  code: DiagnosticCode;
@@ -2850,8 +2858,8 @@ declare class Diagnostics {
2850
2858
  */
2851
2859
  static failedPlugins(diagnostics: ReadonlyArray<Diagnostic>): Array<string>;
2852
2860
  /**
2853
- * Counts `problem` diagnostics by severity for the run summary. `timing`
2854
- * diagnostics are ignored.
2861
+ * Counts `problem` diagnostics by severity for the run summary. `performance` and
2862
+ * `update` diagnostics are ignored.
2855
2863
  */
2856
2864
  static count(diagnostics: ReadonlyArray<Diagnostic>): {
2857
2865
  errors: number;
@@ -2901,4 +2909,4 @@ declare class Diagnostics {
2901
2909
  }
2902
2910
  //#endregion
2903
2911
  export { KubbPluginSetupContext as $, KubbHookStartContext as A, Adapter as At, ParsedFile as B, KubbFilesProcessingEndContext as C, GenerationResult as Ct, KubbGenerationStartContext as D, UserReporter as Dt, KubbGenerationEndContext as E, ReporterName as Et, KubbSuccessContext as F, Generator$1 as G, createKubb as H, KubbWarnContext as I, KubbDriver as J, GeneratorContext as K, PossibleConfig as L, KubbInfoContext as M, AdapterSource as Mt, KubbLifecycleStartContext as N, createAdapter as Nt, KubbHookEndContext as O, createReporter as Ot, KubbPluginsEndContext as P, AsyncEventEmitter as Pt, KubbPluginEndContext as Q, UserConfig as R, KubbFileProcessingUpdate as S, createStorage as St, KubbFilesProcessingUpdateContext as T, ReporterContext as Tt, Parser as U, Kubb$1 as V, defineParser as W, Group as X, Exclude$1 as Y, Include as Z, InputPath as _, defineResolver as _t, DiagnosticLocation as a, Override as at, KubbDiagnosticContext as b, createRenderer as bt, PerformanceDiagnostic as c, definePlugin as ct, SerializedDiagnostic as d, ResolveBannerFile as dt, KubbPluginStartContext as et, UpdateDiagnostic as f, ResolveOptionsContext as ft, InputData as g, ResolverPathParams as gt, Config as h, ResolverFileParams as ht, DiagnosticKind as i, OutputOptions as it, KubbHooks as j, AdapterFactoryOptions as jt, KubbHookLineContext as k, logLevel as kt, ProblemCode as l, BannerMeta as lt, CLIOptions as m, ResolverContext as mt, DiagnosticByCode as n, Output as nt, DiagnosticSeverity as o, Plugin as ot, BuildOutput as p, Resolver as pt, defineGenerator as q, DiagnosticDoc as r, OutputMode as rt, Diagnostics as s, PluginFactoryOptions as st, Diagnostic as t, NormalizedPlugin as tt, ProblemDiagnostic as u, ResolveBannerContext as ut, KubbBuildEndContext as v, Renderer as vt, KubbFilesProcessingStartContext as w, Reporter as wt, KubbErrorContext as x, Storage as xt, KubbBuildStartContext as y, RendererFactory as yt, FileProcessorHooks as z };
2904
- //# sourceMappingURL=diagnostics-D0G07LHG.d.ts.map
2912
+ //# sourceMappingURL=diagnostics-IjkPEgAO.d.ts.map
package/dist/index.cjs CHANGED
@@ -593,12 +593,12 @@ var Url = class Url {
593
593
  * options,
594
594
  * document: null,
595
595
  * async parse(_source) {
596
- * // Convert `source` (path or inline data) into an InputNode.
596
+ * // Convert the source (path or inline data) into an InputNode.
597
597
  * return ast.factory.createInput()
598
598
  * },
599
599
  * getImports: () => [],
600
600
  * async validate() {
601
- * // Throw or call ctx.error here when the spec is invalid.
601
+ * // Throw here when the spec is invalid.
602
602
  * },
603
603
  * }))
604
604
  * ```
@@ -611,7 +611,7 @@ function createAdapter(build) {
611
611
  /**
612
612
  * Docs major version, derived from the package version so the link tracks the published major.
613
613
  */
614
- const docsMajor = "5.0.0-beta.62".split(".")[0] ?? "5";
614
+ const docsMajor = "5.0.0-beta.63".split(".")[0] ?? "5";
615
615
  /**
616
616
  * Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
617
617
  *
@@ -931,8 +931,8 @@ var Diagnostics = class Diagnostics {
931
931
  return [...names];
932
932
  }
933
933
  /**
934
- * Counts `problem` diagnostics by severity for the run summary. `timing`
935
- * diagnostics are ignored.
934
+ * Counts `problem` diagnostics by severity for the run summary. `performance` and
935
+ * `update` diagnostics are ignored.
936
936
  */
937
937
  static count(diagnostics) {
938
938
  let errors = 0;
@@ -1500,7 +1500,7 @@ function defineResolver(build) {
1500
1500
  * leaves the tree untouched, so callers can detect a no-op by identity.
1501
1501
  *
1502
1502
  * Registration order matches the order setup hooks fire, which the driver has already sorted by
1503
- * `enforce` and dependency edges. The registry preserves that order; macro `enforce` only reorders
1503
+ * `enforce` and dependency edges. The registry preserves that order. Macro `enforce` only reorders
1504
1504
  * within a single plugin's list.
1505
1505
  */
1506
1506
  var Transform = class {
@@ -1633,6 +1633,12 @@ var KubbDriver = class {
1633
1633
  this.hooks.on(event, handler);
1634
1634
  this.#listeners.push([event, handler]);
1635
1635
  }
1636
+ /**
1637
+ * Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
1638
+ * A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
1639
+ * `'post'`. When the config has an adapter, the adapter source is resolved from the input
1640
+ * so `run` can parse it later.
1641
+ */
1636
1642
  async setup() {
1637
1643
  const normalized = this.config.plugins.map((rawPlugin) => this.#normalizePlugin(rawPlugin));
1638
1644
  const dependenciesByName = new Map(normalized.map((plugin) => [plugin.name, new Set(plugin.dependencies ?? [])]));
@@ -1652,8 +1658,9 @@ var KubbDriver = class {
1652
1658
  return this.options.hooks;
1653
1659
  }
1654
1660
  /**
1655
- * Creates an `NormalizedPlugin` from a hook-style plugin and registers
1656
- * its lifecycle handlers on the `AsyncEventEmitter`.
1661
+ * Builds a `NormalizedPlugin` from a hook-style plugin, filling in default
1662
+ * options and copying `apply` when present. Registering its lifecycle handlers
1663
+ * on the `AsyncEventEmitter` is done separately by `#registerPlugin`.
1657
1664
  */
1658
1665
  #normalizePlugin(plugin) {
1659
1666
  const normalized = {
@@ -1758,7 +1765,7 @@ var KubbDriver = class {
1758
1765
  * Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
1759
1766
  * can configure generators, resolvers, macros and renderers before `buildStart` runs.
1760
1767
  *
1761
- * Call this once from `safeBuild` before the plugin execution loop begins.
1768
+ * Called once from `run` before the plugin execution loop begins.
1762
1769
  */
1763
1770
  async emitSetupHooks() {
1764
1771
  const noop = () => {};
@@ -1953,8 +1960,8 @@ var KubbDriver = class {
1953
1960
  * That ordering is what drives the CLI's `Plugins N/M` counter. Without it the bar would
1954
1961
  * sit at the initial value until the very end of the run.
1955
1962
  *
1956
- * When `entries` is empty or `this.inputNode` is `null`, every entry still gets a
1957
- * `kubb:plugin:end` so post-plugin listeners (the barrel writer and friends) complete.
1963
+ * When `this.inputNode` is `null`, every entry still gets a `kubb:plugin:end` so
1964
+ * post-plugin listeners (the barrel writer and friends) complete.
1958
1965
  */
1959
1966
  async #runGenerators(entries, flushPending) {
1960
1967
  const diagnostics = [];
@@ -2445,9 +2452,8 @@ function resolveConfig(userConfig) {
2445
2452
  * config in the constructor, so `config` is available right away, and shares `hooks`,
2446
2453
  * `storage`, and `driver` across the `setup → build` lifecycle.
2447
2454
  *
2448
- * `createKubb` takes a plain, serializable config object (the shape `defineConfig`
2449
- * produces), not a fluent builder. Config stays plain data so it can be cache
2450
- * fingerprinted and validated against the shipped JSON schema.
2455
+ * `createKubb` takes a plain config object (the shape `defineConfig` produces),
2456
+ * not a fluent builder.
2451
2457
  *
2452
2458
  * Attach event listeners to `.hooks` before calling `setup()` or `build()`.
2453
2459
  *
@@ -2756,12 +2762,11 @@ function buildTimingSection(report) {
2756
2762
  * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
2757
2763
  * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
2758
2764
  * cli and json reporters expose, a `## Problems` section in the miette block format, and a
2759
- * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`), replacing the
2760
- * old `--debug` flag.
2765
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
2761
2766
  *
2762
- * @note Unlike the streaming logger it replaced, it captures the collected diagnostics once a
2763
- * config finishes, not the live `kubb:info`/`kubb:plugin` event stream. Color is stripped so the
2764
- * file stays plain text even when the run is attached to a TTY.
2767
+ * @note It captures the collected diagnostics once a config finishes, not the live
2768
+ * `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
2769
+ * the run is attached to a TTY.
2765
2770
  */
2766
2771
  const fileReporter = createReporter({
2767
2772
  name: "file",