@kubb/core 5.0.0-beta.61 → 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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-DiaUv_iK.js";
2
+ import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-IjkPEgAO.js";
3
3
  import * as ast from "@kubb/ast";
4
4
 
5
5
  //#region ../../internals/utils/src/url.d.ts
@@ -113,12 +113,11 @@ declare const cliReporter: Reporter;
113
113
  * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
114
114
  * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
115
115
  * cli and json reporters expose, a `## Problems` section in the miette block format, and a
116
- * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`), replacing the
117
- * old `--debug` flag.
116
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
118
117
  *
119
- * @note Unlike the streaming logger it replaced, it captures the collected diagnostics once a
120
- * config finishes, not the live `kubb:info`/`kubb:plugin` event stream. Color is stripped so the
121
- * file stays plain text even when the run is attached to a TTY.
118
+ * @note It captures the collected diagnostics once a config finishes, not the live
119
+ * `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
120
+ * the run is attached to a TTY.
122
121
  */
123
122
  declare const fileReporter: Reporter;
124
123
  //#endregion
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./chunk-C0LytTxp.js";
2
2
  import { a as createStorage, c as camelCase, d as BuildError, f as getErrorMessage, i as FileManager, l as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as AsyncEventEmitter } from "./memoryStorage-CWFzAz4o.js";
3
- import { hash } from "node:crypto";
4
3
  import { stripVTControlCharacters, styleText } from "node:util";
4
+ import { hash } from "node:crypto";
5
5
  import { access, glob, mkdir, readFile, rm, writeFile } from "node:fs/promises";
6
6
  import path, { dirname, join, relative, resolve } from "node:path";
7
7
  import * as ast from "@kubb/ast";
@@ -590,12 +590,12 @@ var Url = class Url {
590
590
  * options,
591
591
  * document: null,
592
592
  * async parse(_source) {
593
- * // Convert `source` (path or inline data) into an InputNode.
593
+ * // Convert the source (path or inline data) into an InputNode.
594
594
  * return ast.factory.createInput()
595
595
  * },
596
596
  * getImports: () => [],
597
597
  * async validate() {
598
- * // Throw or call ctx.error here when the spec is invalid.
598
+ * // Throw here when the spec is invalid.
599
599
  * },
600
600
  * }))
601
601
  * ```
@@ -608,7 +608,7 @@ function createAdapter(build) {
608
608
  /**
609
609
  * Docs major version, derived from the package version so the link tracks the published major.
610
610
  */
611
- const docsMajor = "5.0.0-beta.61".split(".")[0] ?? "5";
611
+ const docsMajor = "5.0.0-beta.63".split(".")[0] ?? "5";
612
612
  /**
613
613
  * Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
614
614
  *
@@ -928,8 +928,8 @@ var Diagnostics = class Diagnostics {
928
928
  return [...names];
929
929
  }
930
930
  /**
931
- * Counts `problem` diagnostics by severity for the run summary. `timing`
932
- * diagnostics are ignored.
931
+ * Counts `problem` diagnostics by severity for the run summary. `performance` and
932
+ * `update` diagnostics are ignored.
933
933
  */
934
934
  static count(diagnostics) {
935
935
  let errors = 0;
@@ -1497,7 +1497,7 @@ function defineResolver(build) {
1497
1497
  * leaves the tree untouched, so callers can detect a no-op by identity.
1498
1498
  *
1499
1499
  * Registration order matches the order setup hooks fire, which the driver has already sorted by
1500
- * `enforce` and dependency edges. The registry preserves that order; macro `enforce` only reorders
1500
+ * `enforce` and dependency edges. The registry preserves that order. Macro `enforce` only reorders
1501
1501
  * within a single plugin's list.
1502
1502
  */
1503
1503
  var Transform = class {
@@ -1630,6 +1630,12 @@ var KubbDriver = class {
1630
1630
  this.hooks.on(event, handler);
1631
1631
  this.#listeners.push([event, handler]);
1632
1632
  }
1633
+ /**
1634
+ * Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
1635
+ * A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
1636
+ * `'post'`. When the config has an adapter, the adapter source is resolved from the input
1637
+ * so `run` can parse it later.
1638
+ */
1633
1639
  async setup() {
1634
1640
  const normalized = this.config.plugins.map((rawPlugin) => this.#normalizePlugin(rawPlugin));
1635
1641
  const dependenciesByName = new Map(normalized.map((plugin) => [plugin.name, new Set(plugin.dependencies ?? [])]));
@@ -1649,8 +1655,9 @@ var KubbDriver = class {
1649
1655
  return this.options.hooks;
1650
1656
  }
1651
1657
  /**
1652
- * Creates an `NormalizedPlugin` from a hook-style plugin and registers
1653
- * its lifecycle handlers on the `AsyncEventEmitter`.
1658
+ * Builds a `NormalizedPlugin` from a hook-style plugin, filling in default
1659
+ * options and copying `apply` when present. Registering its lifecycle handlers
1660
+ * on the `AsyncEventEmitter` is done separately by `#registerPlugin`.
1654
1661
  */
1655
1662
  #normalizePlugin(plugin) {
1656
1663
  const normalized = {
@@ -1755,7 +1762,7 @@ var KubbDriver = class {
1755
1762
  * Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
1756
1763
  * can configure generators, resolvers, macros and renderers before `buildStart` runs.
1757
1764
  *
1758
- * Call this once from `safeBuild` before the plugin execution loop begins.
1765
+ * Called once from `run` before the plugin execution loop begins.
1759
1766
  */
1760
1767
  async emitSetupHooks() {
1761
1768
  const noop = () => {};
@@ -1785,39 +1792,21 @@ var KubbDriver = class {
1785
1792
  * Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
1786
1793
  */
1787
1794
  registerGenerator(pluginName, generator) {
1788
- if (generator.schema) {
1789
- const schemaHandler = async (node, ctx) => {
1790
- if (ctx.plugin.name !== pluginName) return;
1791
- const result = await generator.schema(node, ctx);
1792
- await this.dispatch({
1793
- result,
1794
- renderer: generator.renderer
1795
- });
1796
- };
1797
- this.#trackListener("kubb:generate:schema", schemaHandler);
1798
- }
1799
- if (generator.operation) {
1800
- const operationHandler = async (node, ctx) => {
1795
+ const register = (event, method) => {
1796
+ if (!method) return;
1797
+ const handler = async (node, ctx) => {
1801
1798
  if (ctx.plugin.name !== pluginName) return;
1802
- const result = await generator.operation(node, ctx);
1799
+ const result = await method(node, ctx);
1803
1800
  await this.dispatch({
1804
1801
  result,
1805
1802
  renderer: generator.renderer
1806
1803
  });
1807
1804
  };
1808
- this.#trackListener("kubb:generate:operation", operationHandler);
1809
- }
1810
- if (generator.operations) {
1811
- const operationsHandler = async (nodes, ctx) => {
1812
- if (ctx.plugin.name !== pluginName) return;
1813
- const result = await generator.operations(nodes, ctx);
1814
- await this.dispatch({
1815
- result,
1816
- renderer: generator.renderer
1817
- });
1818
- };
1819
- this.#trackListener("kubb:generate:operations", operationsHandler);
1820
- }
1805
+ this.#trackListener(event, handler);
1806
+ };
1807
+ register("kubb:generate:schema", generator.schema);
1808
+ register("kubb:generate:operation", generator.operation);
1809
+ register("kubb:generate:operations", generator.operations);
1821
1810
  this.#eventGeneratorPlugins.add(pluginName);
1822
1811
  }
1823
1812
  /**
@@ -1968,8 +1957,8 @@ var KubbDriver = class {
1968
1957
  * That ordering is what drives the CLI's `Plugins N/M` counter. Without it the bar would
1969
1958
  * sit at the initial value until the very end of the run.
1970
1959
  *
1971
- * When `entries` is empty or `this.inputNode` is `null`, every entry still gets a
1972
- * `kubb:plugin:end` so post-plugin listeners (the barrel writer and friends) complete.
1960
+ * When `this.inputNode` is `null`, every entry still gets a `kubb:plugin:end` so
1961
+ * post-plugin listeners (the barrel writer and friends) complete.
1973
1962
  */
1974
1963
  async #runGenerators(entries, flushPending) {
1975
1964
  const diagnostics = [];
@@ -2460,9 +2449,8 @@ function resolveConfig(userConfig) {
2460
2449
  * config in the constructor, so `config` is available right away, and shares `hooks`,
2461
2450
  * `storage`, and `driver` across the `setup → build` lifecycle.
2462
2451
  *
2463
- * `createKubb` takes a plain, serializable config object (the shape `defineConfig`
2464
- * produces), not a fluent builder. Config stays plain data so it can be cache
2465
- * fingerprinted and validated against the shipped JSON schema.
2452
+ * `createKubb` takes a plain config object (the shape `defineConfig` produces),
2453
+ * not a fluent builder.
2466
2454
  *
2467
2455
  * Attach event listeners to `.hooks` before calling `setup()` or `build()`.
2468
2456
  *
@@ -2771,12 +2759,11 @@ function buildTimingSection(report) {
2771
2759
  * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
2772
2760
  * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same counts the
2773
2761
  * cli and json reporters expose, a `## Problems` section in the miette block format, and a
2774
- * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`), replacing the
2775
- * old `--debug` flag.
2762
+ * `## Timings` section. Selected with `--reporter file` (or `reporters: ['file']`).
2776
2763
  *
2777
- * @note Unlike the streaming logger it replaced, it captures the collected diagnostics once a
2778
- * config finishes, not the live `kubb:info`/`kubb:plugin` event stream. Color is stripped so the
2779
- * file stays plain text even when the run is attached to a TTY.
2764
+ * @note It captures the collected diagnostics once a config finishes, not the live
2765
+ * `kubb:info`/`kubb:plugin` event stream. Color is stripped so the file stays plain text even when
2766
+ * the run is attached to a TTY.
2780
2767
  */
2781
2768
  const fileReporter = createReporter({
2782
2769
  name: "file",