@kubb/core 5.3.5 → 5.3.7
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/README.md +6 -0
- package/dist/index.cjs +33 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +33 -12
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-DIHOpbmO.d.ts → types-Cw20YGzh.d.ts} +30 -8
- package/dist/{usingCtx-BfeNtY1B.js → usingCtx-BoFplz1D.js} +5 -2
- package/dist/{usingCtx-BfeNtY1B.js.map → usingCtx-BoFplz1D.js.map} +1 -1
- package/dist/{usingCtx-CBWq26N5.cjs → usingCtx-DOy3BJPz.cjs} +5 -2
- package/dist/{usingCtx-CBWq26N5.cjs.map → usingCtx-DOy3BJPz.cjs.map} +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { $ as
|
|
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-
|
|
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.
|
|
128
|
+
const docsMajor = "5.3.7".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")
|
|
461
|
-
|
|
462
|
-
|
|
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
|
-
|
|
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.
|
|
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())
|
|
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) {
|