@kubb/core 5.3.5 → 5.3.6

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 PluginFactoryOptions, A as Kubb, At as Diagnostic, B as Exclude, Bt as UpdateDiagnostic, C as KubbWarnContext, Ct as Reporter, D as CreateKubbOptions, Dt as UserReporter, E as UserConfig, Et as ReporterPluginFiles, F as NodeCache, Ft as Diagnostics, G as KubbPluginSetupContext, Gt as createAdapter, H as Group, Ht as Adapter, I as KubbDriver, It as PerformanceDiagnostic, J as Output, K as KubbPluginStartContext, L as FileManagerHooks, Lt as ProblemCode, M as Generator, Mt as DiagnosticKind, N as GeneratorContext, Nt as DiagnosticLocation, O as GenerateOptions, Ot as createReporter, P as defineGenerator, Pt as DiagnosticSeverity, Q as Plugin, R as Parser, Rt as ProblemDiagnostic, S as KubbSuccessContext, St as GenerationResult, T as PostGenerateCommand, Tt as ReporterName, U as Include, Ut as AdapterFactoryOptions, V as Filter, Vt as Hookable, W as KubbPluginEndContext, Wt as AdapterSource, X as OutputOptions, Y as OutputMode, Z as Override, _ as KubbHookStartContext, _t as Renderer, a as KubbBuildEndContext, at as ResolveBannerFile, b as KubbLifecycleStartContext, bt as Storage, c as KubbErrorContext, ct as ResolveOptionsContext, d as KubbFilesProcessingStartContext, dt as ResolverDefault, et as PluginName, f as KubbFilesProcessingUpdateContext, ft as ResolverFile, g as KubbHookLineContext, gt as ResolverPathParams, h as KubbHookEndContext, ht as ResolverPatch, i as Input, it as ResolveBannerContext, j as createKubb, jt as DiagnosticDoc, k as GenerateResult, kt as logLevel, l as KubbFileProcessingUpdate, lt as ResolvePathOptions, m as KubbGenerationStartContext, mt as ResolverFilePathParams, n as CLIOptions, nt as definePlugin, o as KubbBuildStartContext, ot as ResolveFileOptions, p as KubbGenerationEndContext, pt as ResolverFileParams, q as NormalizedPlugin, r as Config, rt as BannerMeta, s as KubbDiagnosticContext, st as ResolveImportsOptions, t as BuildOutput, tt as ResolvePluginOptions, u as KubbFilesProcessingEndContext, ut as Resolver, v as KubbHooks, vt as RendererFactory, w as PossibleConfig, wt as ReporterContext, x as KubbPluginsEndContext, xt as createStorage, y as KubbInfoContext, yt as createRenderer, z as defineParser, zt as SerializedDiagnostic } from "./types-DIHOpbmO.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";
3
3
  //#region src/applyConfigDefaults.d.ts
4
4
  type ApplyConfigDefaultsOptions<TOutput> = {
5
5
  defaultAdapter: Adapter;
@@ -190,5 +190,5 @@ export declare const fsStorage: (options?: Record<string, never> | undefined) =>
190
190
  */
191
191
  export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
192
192
  //#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, 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 };
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 };
194
194
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { a as OPERATION_FILTER_TYPES, c as clean, d as toPosixPath, f as write, h as camelCase, i as Hookable, l as isPathInside, m as toError, n as createNodeCache, o as diagnosticCode, p as getErrorMessage, r as FileManager, s as inParallel, t as _usingCtx, u as read } from "./usingCtx-BfeNtY1B.js";
2
+ import { a as OPERATION_FILTER_TYPES, c as clean, d as toPosixPath, f as write, h as camelCase, i as Hookable, l as isPathInside, m as toError, n as createNodeCache, o as diagnosticCode, p as getErrorMessage, r as FileManager, s as inParallel, t as _usingCtx, u as read } from "./usingCtx-BoFplz1D.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { stripVTControlCharacters, styleText } from "node:util";
5
5
  import process$1 from "node:process";
@@ -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.5".split(".")[0] ?? "5";
128
+ const docsMajor = "5.3.6".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`.
@@ -457,9 +457,15 @@ var Diagnostics = class Diagnostics {
457
457
  let infos = 0;
458
458
  for (const diagnostic of diagnostics) {
459
459
  if (!isProblem(diagnostic)) continue;
460
- if (diagnostic.severity === "error") errors += 1;
461
- else if (diagnostic.severity === "warning") warnings += 1;
462
- else infos += 1;
460
+ if (diagnostic.severity === "error") {
461
+ errors += 1;
462
+ continue;
463
+ }
464
+ if (diagnostic.severity === "warning") {
465
+ warnings += 1;
466
+ continue;
467
+ }
468
+ infos += 1;
463
469
  }
464
470
  return {
465
471
  errors,
@@ -1023,9 +1029,7 @@ var Resolver = class Resolver {
1023
1029
  ];
1024
1030
  if (config.output.defaultBanner !== "simple") {
1025
1031
  const input = config.input;
1026
- let source = "";
1027
- if (typeof input === "string") source = getInputKind(input) === "inline" ? "text content" : path.basename(input);
1028
- else if (input) source = "text content";
1032
+ const source = typeof input === "string" ? getInputKind(input) === "inline" ? "text content" : path.basename(input) : input ? "text content" : "";
1029
1033
  if (source) lines.push(`* Source: ${source}`);
1030
1034
  if (title) lines.push(`* Title: ${title}`);
1031
1035
  if (version) lines.push(`* OpenAPI spec version: ${version}`);
@@ -1256,6 +1260,7 @@ var KubbDriver = class {
1256
1260
  * so `run` can parse it later.
1257
1261
  */
1258
1262
  async setup() {
1263
+ this.options.signal?.throwIfAborted();
1259
1264
  const normalized = this.#sortPlugins(this.config.plugins.map((rawPlugin) => {
1260
1265
  return {
1261
1266
  name: rawPlugin.name,
@@ -1310,7 +1315,8 @@ var KubbDriver = class {
1310
1315
  */
1311
1316
  async #parseInput() {
1312
1317
  if (this.inputNode || !this.adapter || !this.#adapterSource) return;
1313
- this.inputNode = await this.adapter.parse(this.#adapterSource);
1318
+ this.options.signal?.throwIfAborted();
1319
+ this.inputNode = await this.adapter.parse(this.#adapterSource, { signal: this.options.signal });
1314
1320
  }
1315
1321
  /**
1316
1322
  * Registers a plugin's lifecycle hooks on the shared `Hookable` as pass-through listeners that
@@ -1431,10 +1437,14 @@ var KubbDriver = class {
1431
1437
  });
1432
1438
  return Diagnostics.scope((diagnostic) => diagnostics.push(diagnostic), async () => {
1433
1439
  try {
1440
+ this.options.signal?.throwIfAborted();
1434
1441
  const outputRoot = resolve(config.root, config.output.path);
1435
1442
  await this.#parseInput();
1436
1443
  await this.setupHooks();
1437
- for (const plugin of this.plugins.values()) plugin.options = normalizePluginOptions(plugin.options, plugin.name);
1444
+ for (const plugin of this.plugins.values()) {
1445
+ this.options.signal?.throwIfAborted();
1446
+ plugin.options = normalizePluginOptions(plugin.options, plugin.name);
1447
+ }
1438
1448
  if (this.adapter && this.inputNode) {
1439
1449
  const buildStartContext = this.#withFiles({
1440
1450
  config,
@@ -1492,7 +1502,8 @@ var KubbDriver = class {
1492
1502
  await fileManager.write(fileManager.files, {
1493
1503
  storage: config.storage,
1494
1504
  parsers: parsersMap,
1495
- manifest: this.options.manifest
1505
+ manifest: this.options.manifest,
1506
+ signal: this.options.signal
1496
1507
  });
1497
1508
  await hooks.callHook("kubb:build:end", {
1498
1509
  files: this.fileManager.files,
@@ -1782,6 +1793,7 @@ var KubbDriver = class {
1782
1793
  };
1783
1794
  return {
1784
1795
  config: driver.config,
1796
+ signal: driver.options.signal,
1785
1797
  get root() {
1786
1798
  return resolve(driver.config.root, driver.config.output.path);
1787
1799
  },
@@ -2158,9 +2170,11 @@ var Kubb = class {
2158
2170
  #driver = null;
2159
2171
  #storage = null;
2160
2172
  #manifest = null;
2173
+ #signal;
2161
2174
  constructor(userConfig, options = {}) {
2162
2175
  this.config = resolveConfig(userConfig);
2163
2176
  this.hooks = options.hooks ?? new Hookable();
2177
+ this.#signal = options.signal;
2164
2178
  }
2165
2179
  get storage() {
2166
2180
  if (!this.#storage) throw new Error("[kubb] setup() must be called before accessing storage");
@@ -2174,6 +2188,8 @@ var Kubb = class {
2174
2188
  * Initializes the driver and storage. `build()` calls this automatically.
2175
2189
  */
2176
2190
  async setup() {
2191
+ const signal = this.#signal;
2192
+ signal?.throwIfAborted();
2177
2193
  const config = this.config;
2178
2194
  const manifest = hasOutputPasses(config.output) ? await createOutputManifest({
2179
2195
  storage: config.storage,
@@ -2181,7 +2197,8 @@ var Kubb = class {
2181
2197
  }) : void 0;
2182
2198
  const driver = new KubbDriver(config, {
2183
2199
  hooks: this.hooks,
2184
- manifest
2200
+ manifest,
2201
+ signal
2185
2202
  });
2186
2203
  this.hooks.setMaxListeners(Math.max(10, config.plugins.length * 4));
2187
2204
  if (config.output.clean) {
@@ -2220,6 +2237,7 @@ var Kubb = class {
2220
2237
  async safeBuild() {
2221
2238
  try {
2222
2239
  var _usingCtx$1 = _usingCtx();
2240
+ this.#signal?.throwIfAborted();
2223
2241
  if (!this.#driver) await this.setup();
2224
2242
  const self = _usingCtx$1.u(this);
2225
2243
  const driver = self.driver;
@@ -2250,6 +2268,8 @@ var Kubb = class {
2250
2268
  * ```
2251
2269
  */
2252
2270
  async generate(options = {}) {
2271
+ const signal = this.#signal;
2272
+ signal?.throwIfAborted();
2253
2273
  const { hooks, config } = this;
2254
2274
  const hrStart = process.hrtime();
2255
2275
  await hooks.callHook("kubb:generation:start", { config });
@@ -2257,6 +2277,7 @@ var Kubb = class {
2257
2277
  await this.setup();
2258
2278
  await hooks.callHook("kubb:setup:end");
2259
2279
  const { files, diagnostics, storage } = await this.safeBuild();
2280
+ signal?.throwIfAborted();
2260
2281
  for (const diagnostic of diagnostics) {
2261
2282
  if (!Diagnostics.isProblem(diagnostic)) continue;
2262
2283
  if (diagnostic.code === Diagnostics.code.unknown) {