@kubb/core 5.3.8 → 5.3.9

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 "./rolldown-runtime-C0LytTxp.js";
2
- import { $ as Plugin, A as GenerateResult, At as logLevel, B as defineParser, Bt as SerializedDiagnostic, C as KubbSuccessContext, Ct as GenerationResult, D as UserConfig, Dt as ReporterPluginFiles, E as PostGenerateCommand, Et as ReporterName, F as defineGenerator, Ft as DiagnosticSeverity, G as KubbPluginEndContext, Gt as AdapterSource, H as Filter, Ht as Hookable, I as NodeCache, It as Diagnostics, J as NormalizedPlugin, K as KubbPluginSetupContext, Kt as createAdapter, L as KubbDriver, Lt as PerformanceDiagnostic, M as createKubb, Mt as DiagnosticDoc, N as Generator, Nt as DiagnosticKind, O as CreateKubbOptions, Ot as UserReporter, P as GeneratorContext, Pt as DiagnosticLocation, Q as Override, R as FileManagerHooks, Rt as ProblemCode, S as KubbPluginsEndContext, St as createStorage, T as PossibleConfig, Tt as ReporterContext, U as Group, Ut as Adapter, V as Exclude, Vt as UpdateDiagnostic, W as Include, Wt as AdapterFactoryOptions, X as OutputMode, Y as Output, Z as OutputOptions, _ as KubbHookLineContext, _t as ResolverPathParams, a as KubbBuildEndContext, at as ResolveBannerContext, b as KubbInfoContext, bt as createRenderer, c as KubbErrorContext, ct as ResolveImportsOptions, d as KubbFilesProcessingStartContext, dt as Resolver, et as PluginFactoryOptions, f as KubbFilesProcessingUpdateContext, ft as ResolverDefault, g as KubbHookEndContext, gt as ResolverPatch, h as KubbGenerationSummaryContext, ht as ResolverFilePathParams, i as Input, it as BannerMeta, j as Kubb, jt as Diagnostic, k as GenerateOptions, kt as createReporter, l as KubbFileProcessingUpdate, lt as ResolveOptionsContext, m as KubbGenerationStartContext, mt as ResolverFileParams, n as CLIOptions, nt as ResolvePluginOptions, o as KubbBuildStartContext, ot as ResolveBannerFile, p as KubbGenerationEndContext, pt as ResolverFile, q as KubbPluginStartContext, r as Config, rt as definePlugin, s as KubbDiagnosticContext, st as ResolveFileOptions, t as BuildOutput, tt as PluginName, u as KubbFilesProcessingEndContext, ut as ResolvePathOptions, v as KubbHookStartContext, vt as Renderer, w as KubbWarnContext, wt as Reporter, x as KubbLifecycleStartContext, xt as Storage, y as KubbHooks, yt as RendererFactory, z as Parser, zt as ProblemDiagnostic } from "./types-Cw20YGzh.js";
2
+ import { $ as OutputMode, A as SummaryRenderer, At as ReporterPluginFiles, B as KubbDriver, Bt as PerformanceDiagnostic, C as KubbSuccessContext, Ct as createRenderer, D as UserConfig, Dt as Reporter, E as PostGenerateCommand, Et as GenerationResult, F as createKubb, Ft as DiagnosticDoc, G as Filter, Gt as Hookable, H as Parser, Ht as ProblemDiagnostic, I as Generator, It as DiagnosticKind, J as KubbPluginEndContext, Jt as AdapterSource, K as Group, Kt as Adapter, L as GeneratorContext, Lt as DiagnosticLocation, M as GenerateOptions, Mt as createReporter, N as GenerateResult, Nt as logLevel, O as InputKind, Ot as ReporterContext, P as Kubb, Pt as Diagnostic, Q as Output, R as defineGenerator, Rt as DiagnosticSeverity, S as KubbPluginsEndContext, St as RendererFactory, T as PossibleConfig, Tt as createStorage, U as defineParser, Ut as SerializedDiagnostic, V as FileManagerHooks, Vt as ProblemCode, W as Exclude, Wt as UpdateDiagnostic, X as KubbPluginStartContext, Y as KubbPluginSetupContext, Yt as createAdapter, Z as NormalizedPlugin, _ as KubbHookLineContext, _t as ResolverFileParams, a as KubbBuildEndContext, at as ResolvePluginOptions, b as KubbInfoContext, bt as ResolverPathParams, c as KubbErrorContext, ct as ResolveBannerContext, d as KubbFilesProcessingStartContext, dt as ResolveImportsOptions, et as OutputOptions, f as KubbFilesProcessingUpdateContext, ft as ResolveOptionsContext, g as KubbHookEndContext, gt as ResolverFile, h as KubbGenerationSummaryContext, ht as ResolverDefault, i as Input, it as PluginName, j as CreateKubbOptions, jt as UserReporter, k as getInputKind, kt as ReporterName, l as KubbFileProcessingUpdate, lt as ResolveBannerFile, m as KubbGenerationStartContext, mt as Resolver, n as CLIOptions, nt as Plugin, o as KubbBuildStartContext, ot as definePlugin, p as KubbGenerationEndContext, pt as ResolvePathOptions, q as Include, qt as AdapterFactoryOptions, r as Config, rt as PluginFactoryOptions, s as KubbDiagnosticContext, st as BannerMeta, t as BuildOutput, tt as Override, u as KubbFilesProcessingEndContext, ut as ResolveFileOptions, v as KubbHookStartContext, vt as ResolverFilePathParams, w as KubbWarnContext, wt as Storage, x as KubbLifecycleStartContext, xt as Renderer, y as KubbHooks, yt as ResolverPatch, z as NodeCache, zt as Diagnostics } from "./types-DKzghz5i.js";
3
3
  //#region src/applyConfigDefaults.d.ts
4
4
  type ApplyConfigDefaultsOptions<TOutput> = {
5
5
  defaultAdapter: Adapter;
@@ -27,8 +27,23 @@ export declare function applyConfigDefaults<TOutput extends Config['output'] = C
27
27
  //#endregion
28
28
  //#region src/reporters/cliReporter.d.ts
29
29
  /**
30
- * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
31
- * of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
30
+ * Builds a `cli` reporter that renders the {@link Report} for each config as it finishes.
31
+ * Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
32
+ *
33
+ * Pass `render` to send the summary through output the host already owns, so it lands inside that
34
+ * host's grouping instead of alongside it. Omit it for the plain `console.log` writer.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const reporter = createCliReporter({ render: (lines) => lines.forEach((line) => clack.log.message(line)) })
39
+ * ```
40
+ */
41
+ export declare function createCliReporter({ render }?: {
42
+ render?: SummaryRenderer;
43
+ }): Reporter;
44
+ /**
45
+ * The default `cli` reporter, writing its summary straight to the console. Independent of the live
46
+ * logger view.
32
47
  */
33
48
  export declare const cliReporter: Reporter;
34
49
  //#endregion
@@ -118,25 +133,6 @@ type ResolverOptions<T extends PluginFactoryOptions> = Omit<T['resolver'], keyof
118
133
  */
119
134
  export declare function createResolver<T extends PluginFactoryOptions>(options: ResolverOptions<T>): T['resolver'];
120
135
  //#endregion
121
- //#region src/input.d.ts
122
- /**
123
- * What an `input` value points at, once Kubb has looked at it.
124
- *
125
- * - `file` is a local file path, absolute or relative to the config file.
126
- * - `url` is a remote document to fetch.
127
- * - `inline` is OpenAPI content held in the string itself (JSON or YAML).
128
- * - `object` is an already-parsed spec.
129
- */
130
- type InputKind = 'file' | 'url' | 'inline' | 'object';
131
- /**
132
- * Classifies an `input` value so callers branch on it once instead of repeating the checks.
133
- *
134
- * A non-string is a parsed spec (`object`). A string is `inline` when it holds OpenAPI content,
135
- * meaning it starts with `{` or `[`, spans multiple lines, or opens with a YAML `openapi:` or
136
- * `swagger:` key. Otherwise a string is a `url` when it parses as one, or a `file` path.
137
- */
138
- export declare function getInputKind(input: NonNullable<Input>): InputKind;
139
- //#endregion
140
136
  //#region src/storages/fsStorage.d.ts
141
137
  /**
142
138
  * Built-in filesystem storage driver.
@@ -190,5 +186,5 @@ export declare const fsStorage: (options?: Record<string, never> | undefined) =>
190
186
  */
191
187
  export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
192
188
  //#endregion
193
- export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileManagerHooks, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, Hookable, type Include, Input, type InputKind, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PluginName, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type SerializedDiagnostic, type Storage, type UpdateDiagnostic, UserConfig, type UserReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, logLevel };
189
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileManagerHooks, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, Hookable, type Include, Input, type InputKind, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, type PluginName, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, getInputKind, logLevel };
194
190
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ function formatMs(ms) {
125
125
  /**
126
126
  * Docs major version, derived from the package version so the link tracks the published major.
127
127
  */
128
- const docsMajor = "5.3.8".split(".")[0] ?? "5";
128
+ const docsMajor = "5.3.9".split(".")[0] ?? "5";
129
129
  /**
130
130
  * Builds a type guard that narrows a {@link Diagnostic} to the variant for `kind`. A diagnostic
131
131
  * with no `kind` is treated as a `problem`.
@@ -2406,36 +2406,6 @@ function createReporter(reporter) {
2406
2406
  };
2407
2407
  }
2408
2408
  //#endregion
2409
- //#region src/reporters/colors.ts
2410
- /**
2411
- * ANSI color names used by {@link randomCliColor} for deterministic terminal coloring.
2412
- */
2413
- const randomColors = [
2414
- "black",
2415
- "red",
2416
- "green",
2417
- "yellow",
2418
- "blue",
2419
- "white",
2420
- "magenta",
2421
- "cyan",
2422
- "gray"
2423
- ];
2424
- /**
2425
- * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
2426
- *
2427
- * @example
2428
- * ```ts
2429
- * randomCliColor('petstore') // '\x1b[33m' + 'petstore' + '\x1b[39m' (always the same color for 'petstore')
2430
- * ```
2431
- */
2432
- function randomCliColor(text) {
2433
- if (!text) return "";
2434
- const index = hash("sha256", text, "buffer").readUInt32BE(0) % randomColors.length;
2435
- const color = randomColors[index] ?? "white";
2436
- return styleText(color, text);
2437
- }
2438
- //#endregion
2439
2409
  //#region src/reporters/report.ts
2440
2410
  /**
2441
2411
  * Builds the normalized {@link Report} for one config from its {@link GenerationResult}. Splits the
@@ -2469,12 +2439,43 @@ function buildReport(result) {
2469
2439
  };
2470
2440
  }
2471
2441
  //#endregion
2472
- //#region src/reporters/cliReporter.ts
2442
+ //#region src/reporters/colors.ts
2443
+ /**
2444
+ * ANSI color names used by {@link randomCliColor} for deterministic terminal coloring.
2445
+ */
2446
+ const randomColors = [
2447
+ "black",
2448
+ "red",
2449
+ "green",
2450
+ "yellow",
2451
+ "blue",
2452
+ "white",
2453
+ "magenta",
2454
+ "cyan",
2455
+ "gray"
2456
+ ];
2473
2457
  /**
2474
- * Builds the vitest/jest-style summary for one {@link Report}: right-aligned dim labels with
2475
- * `N passed (total)` counts, and a per-plugin `Timings` section when `showTimings`.
2458
+ * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
2459
+ *
2460
+ * @example
2461
+ * ```ts
2462
+ * randomCliColor('petstore') // '\x1b[33m' + 'petstore' + '\x1b[39m' (always the same color for 'petstore')
2463
+ * ```
2476
2464
  */
2477
- function buildSummaryLines(report, { showTimings }) {
2465
+ function randomCliColor(text) {
2466
+ if (!text) return "";
2467
+ const index = hash("sha256", text, "buffer").readUInt32BE(0) % randomColors.length;
2468
+ const color = randomColors[index] ?? "white";
2469
+ return styleText(color, text);
2470
+ }
2471
+ //#endregion
2472
+ //#region src/reporters/summary.ts
2473
+ /**
2474
+ * Formats the vitest/jest-style summary for one {@link Report}: right-aligned dim labels with
2475
+ * `N passed (total)` counts, and a per-plugin `Timings` section when `showTimings`. Pure, so a host
2476
+ * can render the same lines through whatever output it already owns.
2477
+ */
2478
+ function formatSummary(report, { showTimings }) {
2478
2479
  const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
2479
2480
  const rows = [];
2480
2481
  rows.push(["Plugins", status === "success" ? `${styleText("green", `${plugins.passed} passed`)} (${plugins.total})` : `${styleText("green", `${plugins.passed} passed`)} | ${styleText("red", `${plugins.failed.length} failed`)} (${plugins.total})`]);
@@ -2501,30 +2502,47 @@ function buildSummaryLines(report, { showTimings }) {
2501
2502
  }
2502
2503
  return lines;
2503
2504
  }
2505
+ //#endregion
2506
+ //#region src/reporters/cliReporter.ts
2504
2507
  /**
2505
2508
  * Renders the summary as plain `console.log` lines so it works in every CLI (no clack/TTY
2506
2509
  * dependency): a blank line, the config name colored by status, then the summary rows.
2507
2510
  */
2508
- function renderSummary(lines, { title, status }) {
2511
+ const consoleRenderer = (lines, { title, status }) => {
2509
2512
  console.log("");
2510
2513
  if (title) console.log(styleText(status === "failed" ? "red" : "green", title));
2511
2514
  for (const line of lines) console.log(line);
2515
+ };
2516
+ /**
2517
+ * Builds a `cli` reporter that renders the {@link Report} for each config as it finishes.
2518
+ * Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
2519
+ *
2520
+ * Pass `render` to send the summary through output the host already owns, so it lands inside that
2521
+ * host's grouping instead of alongside it. Omit it for the plain `console.log` writer.
2522
+ *
2523
+ * @example
2524
+ * ```ts
2525
+ * const reporter = createCliReporter({ render: (lines) => lines.forEach((line) => clack.log.message(line)) })
2526
+ * ```
2527
+ */
2528
+ function createCliReporter({ render = consoleRenderer } = {}) {
2529
+ return createReporter({
2530
+ name: "cli",
2531
+ report(result, { logLevel: logLevel$1 }) {
2532
+ if (logLevel$1 <= logLevel.silent) return;
2533
+ const report = buildReport(result);
2534
+ render(formatSummary(report, { showTimings: logLevel$1 >= logLevel.verbose }), {
2535
+ title: report.name,
2536
+ status: report.status
2537
+ });
2538
+ }
2539
+ });
2512
2540
  }
2513
2541
  /**
2514
- * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
2515
- * of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
2542
+ * The default `cli` reporter, writing its summary straight to the console. Independent of the live
2543
+ * logger view.
2516
2544
  */
2517
- const cliReporter = createReporter({
2518
- name: "cli",
2519
- report(result, { logLevel: logLevel$1 }) {
2520
- if (logLevel$1 <= logLevel.silent) return;
2521
- const report = buildReport(result);
2522
- renderSummary(buildSummaryLines(report, { showTimings: logLevel$1 >= logLevel.verbose }), {
2523
- title: report.name,
2524
- status: report.status
2525
- });
2526
- }
2527
- });
2545
+ const cliReporter = createCliReporter();
2528
2546
  //#endregion
2529
2547
  //#region src/reporters/fileReporter.ts
2530
2548
  /**
@@ -2812,6 +2830,6 @@ const memoryStorage = createStorage(() => {
2812
2830
  };
2813
2831
  });
2814
2832
  //#endregion
2815
- export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage };
2833
+ export { Diagnostics, Hookable, KubbDriver, Resolver, applyConfigDefaults, cliReporter, createAdapter, createCliReporter, createKubb, createRenderer, createReporter, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage };
2816
2834
 
2817
2835
  //# sourceMappingURL=index.js.map