@kubb/core 5.0.0-beta.100 → 5.0.0-beta.102

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/mocks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { A as Generator, F as Parser, N as KubbDriver, Rt as Adapter, W as NormalizedPlugin, X as PluginFactoryOptions, r as Config, zt as AdapterFactoryOptions } from "./types-DM7-MGjZ.js";
2
+ import { Bt as Adapter, F as KubbDriver, K as NormalizedPlugin, L as Parser, M as Generator, Q as PluginFactoryOptions, Vt as AdapterFactoryOptions, r as Config } from "./types-B14Ba9P7.js";
3
3
  import { FileNode, InputMeta, Macro, OperationNode, SchemaNode } from "@kubb/ast";
4
4
  //#region src/mocks.d.ts
5
5
  /**
@@ -1788,15 +1788,13 @@ declare class KubbDriver {
1788
1788
  */
1789
1789
  setupHooks(): Promise<void>;
1790
1790
  /**
1791
- * Registers a generator for the given plugin on the shared hook emitter.
1791
+ * Appends a generator to its owning plugin so the generate loop can call it directly.
1792
1792
  *
1793
- * The generator's `schema`, `operation`, and `operations` methods are registered as
1794
- * listeners on `kubb:generate:schema`, `kubb:generate:operation`, and `kubb:generate:operations`
1795
- * respectively. Each listener is scoped to the owning plugin via a `ctx.plugin.name` check
1796
- * so that generators from different plugins do not cross-fire.
1797
- *
1798
- * The renderer comes from `generator.renderer`. Set `generator.renderer = null` (or leave it
1799
- * unset) to opt out of rendering.
1793
+ * The generator's `schema`, `operation`, and `operations` methods run per node during the AST
1794
+ * walk in `#runGenerators`, and their result is routed through `dispatch`. Because a generator is
1795
+ * bound to a plugin, generators from different plugins never cross-fire without a name check. The
1796
+ * renderer comes from `generator.renderer`; set it to `null` (or leave it unset) to opt out of
1797
+ * rendering.
1800
1798
  *
1801
1799
  * Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
1802
1800
  */
@@ -1805,7 +1803,7 @@ declare class KubbDriver {
1805
1803
  * Returns `true` when at least one generator was registered for the given plugin
1806
1804
  * via `addGenerator()` in `kubb:plugin:setup`.
1807
1805
  *
1808
- * Used by the build loop to decide whether to walk the AST and emit generator hooks
1806
+ * Used by the build loop to decide whether to walk the AST and run the generators
1809
1807
  * for a plugin.
1810
1808
  */
1811
1809
  hasHookGenerators(pluginName: string): boolean;
@@ -1843,16 +1841,14 @@ declare class KubbDriver {
1843
1841
  dispose(): void;
1844
1842
  [Symbol.dispose](): void;
1845
1843
  /**
1846
- * Merges `partial` with the plugin's default resolver and stores the result.
1847
- * Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`
1848
- * get the up-to-date resolver without going through `getResolver()`.
1844
+ * Merges `partial` onto a fresh default resolver and stores the result on `plugin.resolver`,
1845
+ * which is the single source `getResolver` and `getPlugin(name).resolver` both read.
1849
1846
  */
1850
1847
  setPluginResolver(pluginName: string, partial: ResolverPatch | Resolver): void;
1851
1848
  /**
1852
- * Returns the resolver for the given plugin.
1853
- *
1854
- * Resolution order: resolver set via `setPluginResolver` → lazily created default
1855
- * resolver (identity name, no path transforms).
1849
+ * Returns the resolver for the given plugin. It reads `plugin.resolver` (seeded with the default
1850
+ * at registration and replaced by `setPluginResolver`), falling back to a fresh default for a
1851
+ * name that is not a registered plugin.
1856
1852
  */
1857
1853
  getResolver<TName extends PluginName>(pluginName: TName): ResolvePluginOptions<TName>['resolver'];
1858
1854
  getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options'>;
@@ -2061,6 +2057,37 @@ declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginF
2061
2057
  type CreateKubbOptions = {
2062
2058
  hooks?: Hookable<KubbHooks>;
2063
2059
  };
2060
+ /**
2061
+ * Host hooks for a single {@link Kubb.generate} call. All optional. Progress narration rides the
2062
+ * `kubb:*` lifecycle hooks on `.hooks`, so hosts subscribe there rather than pass a callback.
2063
+ */
2064
+ type GenerateOptions = {
2065
+ /**
2066
+ * Format, lint, and run `postGenerate` over the generated output after an error-free build, and
2067
+ * return the diagnostics they emitted. CLI-only.
2068
+ */
2069
+ processOutput?: (context: {
2070
+ config: Config;
2071
+ outputPath: string;
2072
+ }) => Promise<Array<Diagnostic>>;
2073
+ };
2074
+ /**
2075
+ * What a {@link Kubb.generate} call produced, for the host to map onto its own result shape.
2076
+ */
2077
+ type GenerateResult = {
2078
+ /**
2079
+ * `true` when the build and every output pass completed without an error-level diagnostic.
2080
+ */
2081
+ success: boolean;
2082
+ /**
2083
+ * All files generated during the build.
2084
+ */
2085
+ files: Array<FileNode>;
2086
+ /**
2087
+ * Build diagnostics plus any collected from the output passes.
2088
+ */
2089
+ diagnostics: Array<Diagnostic>;
2090
+ };
2064
2091
  /**
2065
2092
  * Kubb code-generation instance bound to a single config entry. Resolves the user
2066
2093
  * config in the constructor, so `config` is available right away, and shares `hooks`,
@@ -2100,6 +2127,19 @@ declare class Kubb$1 {
2100
2127
  * plugin errors, so callers stay in control of how failures surface.
2101
2128
  */
2102
2129
  safeBuild(): Promise<BuildOutput>;
2130
+ /**
2131
+ * Run one build and its output passes end to end, emitting the surrounding `kubb:generation:*`
2132
+ * hooks. Never throws on a build error: the outcome comes back in {@link GenerateResult} so the
2133
+ * host decides how failures surface. Telemetry and progress narration stay with the host, which
2134
+ * reads the result and subscribes to the `kubb:*` hooks.
2135
+ *
2136
+ * @example
2137
+ * ```ts
2138
+ * const result = await createKubb(config, { hooks }).generate()
2139
+ * if (!result.success) process.exitCode = 1
2140
+ * ```
2141
+ */
2142
+ generate(options?: GenerateOptions): Promise<GenerateResult>;
2103
2143
  dispose(): void;
2104
2144
  [Symbol.dispose](): void;
2105
2145
  }
@@ -2483,6 +2523,8 @@ interface KubbHooks {
2483
2523
  'kubb:lifecycle:end': [];
2484
2524
  'kubb:generation:start': [ctx: KubbGenerationStartContext];
2485
2525
  'kubb:generation:end': [ctx: KubbGenerationEndContext];
2526
+ 'kubb:setup:start': [];
2527
+ 'kubb:setup:end': [];
2486
2528
  'kubb:format:start': [];
2487
2529
  'kubb:format:end': [];
2488
2530
  'kubb:lint:start': [];
@@ -2834,5 +2876,5 @@ type BuildOutput = {
2834
2876
  storage: Storage;
2835
2877
  };
2836
2878
  //#endregion
2837
- export { definePlugin as $, Generator as A, DiagnosticSeverity as At, Include as B, AdapterSource as Bt, KubbWarnContext as C, UserReporter as Ct, CreateKubbOptions as D, DiagnosticDoc as Dt, UserConfig as E, Diagnostic as Et, Parser as F, SerializedDiagnostic as Ft, Output as G, KubbPluginSetupContext as H, defineParser as I, UpdateDiagnostic as It, Override as J, OutputMode as K, Exclude$1 as L, Hookable as Lt, defineGenerator as M, PerformanceDiagnostic as Mt, KubbDriver as N, ProblemCode as Nt, Kubb$1 as O, DiagnosticKind as Ot, FileManagerHooks as P, ProblemDiagnostic as Pt, ResolvePluginOptions as Q, Filter as R, Adapter as Rt, KubbSuccessContext as S, ReporterName as St, PostGenerateCommand as T, logLevel as Tt, KubbPluginStartContext as U, KubbPluginEndContext as V, createAdapter as Vt, NormalizedPlugin as W, PluginFactoryOptions as X, Plugin as Y, PluginName as Z, KubbHookStartContext as _, Storage as _t, KubbBuildEndContext as a, ResolveOptionsContext as at, KubbLifecycleStartContext as b, Reporter as bt, KubbErrorContext as c, ResolverDefault as ct, KubbFilesProcessingStartContext as d, ResolverFilePathParams as dt, BannerMeta as et, KubbFilesProcessingUpdateContext as f, ResolverPatch as ft, KubbHookLineContext as g, createRenderer as gt, KubbHookEndContext as h, RendererFactory as ht, Input as i, ResolveImportsOptions as it, GeneratorContext as j, Diagnostics as jt, createKubb as k, DiagnosticLocation as kt, KubbFileProcessingUpdate as l, ResolverFile as lt, KubbGenerationStartContext as m, Renderer as mt, CLIOptions as n, ResolveBannerFile as nt, KubbBuildStartContext as o, ResolvePathOptions as ot, KubbGenerationEndContext as p, ResolverPathParams as pt, OutputOptions as q, Config as r, ResolveFileOptions as rt, KubbDiagnosticContext as s, Resolver as st, BuildOutput as t, ResolveBannerContext as tt, KubbFilesProcessingEndContext as u, ResolverFileParams as ut, KubbHooks as v, createStorage as vt, PossibleConfig as w, createReporter as wt, KubbPluginsEndContext as x, ReporterContext as xt, KubbInfoContext as y, GenerationResult as yt, Group as z, AdapterFactoryOptions as zt };
2838
- //# sourceMappingURL=types-DM7-MGjZ.d.ts.map
2879
+ export { PluginName as $, Kubb$1 as A, DiagnosticKind as At, Filter as B, Adapter as Bt, KubbWarnContext as C, ReporterContext as Ct, CreateKubbOptions as D, logLevel as Dt, UserConfig as E, createReporter as Et, KubbDriver as F, ProblemCode as Ft, KubbPluginStartContext as G, Include as H, AdapterSource as Ht, FileManagerHooks as I, ProblemDiagnostic as It, OutputMode as J, NormalizedPlugin as K, Parser as L, SerializedDiagnostic as Lt, Generator as M, DiagnosticSeverity as Mt, GeneratorContext as N, Diagnostics as Nt, GenerateOptions as O, Diagnostic as Ot, defineGenerator as P, PerformanceDiagnostic as Pt, PluginFactoryOptions as Q, defineParser as R, UpdateDiagnostic as Rt, KubbSuccessContext as S, Reporter as St, PostGenerateCommand as T, UserReporter as Tt, KubbPluginEndContext as U, createAdapter as Ut, Group as V, AdapterFactoryOptions as Vt, KubbPluginSetupContext as W, Override as X, OutputOptions as Y, Plugin as Z, KubbHookStartContext as _, RendererFactory as _t, KubbBuildEndContext as a, ResolveFileOptions as at, KubbLifecycleStartContext as b, createStorage as bt, KubbErrorContext as c, ResolvePathOptions as ct, KubbFilesProcessingStartContext as d, ResolverFile as dt, ResolvePluginOptions as et, KubbFilesProcessingUpdateContext as f, ResolverFileParams as ft, KubbHookLineContext as g, Renderer as gt, KubbHookEndContext as h, ResolverPathParams as ht, Input as i, ResolveBannerFile as it, createKubb as j, DiagnosticLocation as jt, GenerateResult as k, DiagnosticDoc as kt, KubbFileProcessingUpdate as l, Resolver as lt, KubbGenerationStartContext as m, ResolverPatch as mt, CLIOptions as n, BannerMeta as nt, KubbBuildStartContext as o, ResolveImportsOptions as ot, KubbGenerationEndContext as p, ResolverFilePathParams as pt, Output as q, Config as r, ResolveBannerContext as rt, KubbDiagnosticContext as s, ResolveOptionsContext as st, BuildOutput as t, definePlugin as tt, KubbFilesProcessingEndContext as u, ResolverDefault as ut, KubbHooks as v, createRenderer as vt, PossibleConfig as w, ReporterName as wt, KubbPluginsEndContext as x, GenerationResult as xt, KubbInfoContext as y, Storage as yt, Exclude$1 as z, Hookable as zt };
2880
+ //# sourceMappingURL=types-B14Ba9P7.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "5.0.0-beta.100",
3
+ "version": "5.0.0-beta.102",
4
4
  "description": "Core engine for Kubb. Provides the plugin driver, file manager and build orchestration used by every Kubb plugin.",
5
5
  "keywords": [
6
6
  "code-generator",
@@ -55,7 +55,7 @@
55
55
  "registry": "https://registry.npmjs.org/"
56
56
  },
57
57
  "dependencies": {
58
- "@kubb/ast": "5.0.0-beta.100"
58
+ "@kubb/ast": "5.0.0-beta.102"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@internals/utils": "0.0.0"