@kubb/core 5.18.6 → 5.18.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/dist/index.cjs +82 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -10
- package/dist/index.d.ts +30 -10
- package/dist/index.js +93 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -165,7 +165,7 @@ declare const diagnosticCatalog: {
|
|
|
165
165
|
readonly code: 'KUBB_INVALID_DOCUMENT';
|
|
166
166
|
readonly title: 'Invalid document';
|
|
167
167
|
readonly cause: 'The `input` cannot be read as an OpenAPI or Swagger document: its JSON or YAML has a syntax error, it declares no `openapi` or `swagger` version field, or its version cannot be upgraded to OpenAPI 3.1.';
|
|
168
|
-
readonly fix: 'Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0
|
|
168
|
+
readonly fix: 'Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0 or OpenAPI 3.0, 3.1, or 3.2 document, and check that a passed object is the spec itself rather than a wrapper around it.';
|
|
169
169
|
};
|
|
170
170
|
readonly invalidSpec: {
|
|
171
171
|
readonly code: 'KUBB_INVALID_SPEC';
|
|
@@ -290,8 +290,8 @@ declare const diagnosticCatalog: {
|
|
|
290
290
|
readonly invalidPluginOptions: {
|
|
291
291
|
readonly code: 'KUBB_INVALID_PLUGIN_OPTIONS';
|
|
292
292
|
readonly title: 'Invalid plugin options';
|
|
293
|
-
readonly cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.";
|
|
294
|
-
readonly fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option or
|
|
293
|
+
readonly cause: "A plugin was configured with options that cannot be honored, for example a single-file output (`output.mode: 'file'`, or an `output.path` with a file extension) paired with a `group` option.";
|
|
294
|
+
readonly fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option, give `output.path` a directory name, or set `output.mode: 'directory'`.";
|
|
295
295
|
};
|
|
296
296
|
readonly postGenerateFailed: {
|
|
297
297
|
readonly code: 'KUBB_POST_GENERATE_FAILED';
|
|
@@ -1717,6 +1717,10 @@ export type BuildOutput = {
|
|
|
1717
1717
|
* The plugin driver that orchestrated this build.
|
|
1718
1718
|
*/
|
|
1719
1719
|
driver: KubbDriver;
|
|
1720
|
+
/**
|
|
1721
|
+
* The parsed spec the build generated from, `null` when there was none to parse.
|
|
1722
|
+
*/
|
|
1723
|
+
input: InputNode | null;
|
|
1720
1724
|
/**
|
|
1721
1725
|
* The configured `Storage` backend, for reading back a generated file's final content.
|
|
1722
1726
|
* Use `files` to list what this build produced.
|
|
@@ -2322,7 +2326,7 @@ type ResolverPathParams = Omit<ResolverFileParams, 'name' | 'extname'> & {
|
|
|
2322
2326
|
*/
|
|
2323
2327
|
type ResolvePathOptions = ResolverPathParams & {
|
|
2324
2328
|
/**
|
|
2325
|
-
* Absolute
|
|
2329
|
+
* Absolute directory the plugin's `output.path` is resolved against. Generators pass `ctx.root`, the config's output directory.
|
|
2326
2330
|
*/
|
|
2327
2331
|
root: string;
|
|
2328
2332
|
/**
|
|
@@ -2803,7 +2807,8 @@ type ByMethod = {
|
|
|
2803
2807
|
type: 'method';
|
|
2804
2808
|
/**
|
|
2805
2809
|
* HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
|
|
2806
|
-
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`) or a regex.
|
|
2810
|
+
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`) or a regex. Matching ignores
|
|
2811
|
+
* case, so `'get'` and `/get/` work too.
|
|
2807
2812
|
*/
|
|
2808
2813
|
pattern: HttpMethod | RegExp;
|
|
2809
2814
|
};
|
|
@@ -3272,7 +3277,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
3272
3277
|
type AdapterDefinition<T extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
3273
3278
|
meta: ExtensionMeta<T['name']>;
|
|
3274
3279
|
/**
|
|
3275
|
-
* Takes the user's options and returns the resolved options, which `build` receives
|
|
3280
|
+
* Takes the user's options and returns the resolved options, which `build` receives. The adapter exposes the user's options as `options`.
|
|
3276
3281
|
* Without `setup`, the user's options are the resolved options.
|
|
3277
3282
|
*/
|
|
3278
3283
|
setup?(options: T['options']): T['resolvedOptions'];
|
|
@@ -3392,8 +3397,15 @@ type CreateKubbOptions = {
|
|
|
3392
3397
|
*/
|
|
3393
3398
|
signal?: AbortSignal;
|
|
3394
3399
|
};
|
|
3400
|
+
type ConfigGenerateResult = GenerateResult & {
|
|
3401
|
+
kubb: Kubb$1;
|
|
3402
|
+
/**
|
|
3403
|
+
* What the build threw outside its own diagnostics. `diagnostics` holds it too.
|
|
3404
|
+
*/
|
|
3405
|
+
error?: unknown;
|
|
3406
|
+
};
|
|
3395
3407
|
/**
|
|
3396
|
-
* Host hooks for a single {@link Kubb
|
|
3408
|
+
* Host hooks for a single {@link Kubb#generate} call. All optional. Progress narration rides the
|
|
3397
3409
|
* `kubb:*` lifecycle hooks on `.hooks`, so hosts subscribe there rather than pass a callback.
|
|
3398
3410
|
*/
|
|
3399
3411
|
type GenerateOptions = {
|
|
@@ -3405,7 +3417,7 @@ type GenerateOptions = {
|
|
|
3405
3417
|
processOutput?: (context: RunOutputPassesOptions) => Promise<Array<Diagnostic>>;
|
|
3406
3418
|
};
|
|
3407
3419
|
/**
|
|
3408
|
-
* What a {@link Kubb
|
|
3420
|
+
* What a {@link Kubb#generate} call produced, for the host to map onto its own result shape.
|
|
3409
3421
|
*/
|
|
3410
3422
|
type GenerateResult = {
|
|
3411
3423
|
/**
|
|
@@ -3420,6 +3432,10 @@ type GenerateResult = {
|
|
|
3420
3432
|
* Build diagnostics plus any collected from the output passes.
|
|
3421
3433
|
*/
|
|
3422
3434
|
diagnostics: Array<Diagnostic>;
|
|
3435
|
+
/**
|
|
3436
|
+
* The parsed spec the build generated from, `null` when the build failed before parsing.
|
|
3437
|
+
*/
|
|
3438
|
+
input: InputNode | null;
|
|
3423
3439
|
};
|
|
3424
3440
|
/**
|
|
3425
3441
|
* Kubb code-generation instance bound to a single config entry. Resolves the user
|
|
@@ -3443,6 +3459,11 @@ declare class Kubb$1 {
|
|
|
3443
3459
|
readonly hooks: Hookable<KubbHooks>;
|
|
3444
3460
|
readonly config: Config;
|
|
3445
3461
|
constructor(userConfig: UserConfig, options?: CreateKubbOptions);
|
|
3462
|
+
/**
|
|
3463
|
+
* Generates every config of a `defineConfig([...])` array in order and yields each result as its config finishes, so
|
|
3464
|
+
* memory holds one config at a time. A config that fails does not stop the others. Only an aborted `signal` rejects.
|
|
3465
|
+
*/
|
|
3466
|
+
static generate(configs: Array<UserConfig>, { hooks, signal }?: Pick<CreateKubbOptions, 'hooks' | 'signal'>): AsyncGenerator<ConfigGenerateResult, void, void>;
|
|
3446
3467
|
get storage(): Storage;
|
|
3447
3468
|
get driver(): KubbDriver;
|
|
3448
3469
|
/**
|
|
@@ -3916,5 +3937,4 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
3916
3937
|
packages?: Iterable<string>;
|
|
3917
3938
|
resolveFrom?: Array<string>;
|
|
3918
3939
|
}): Promise<Array<InstalledPackage>>;
|
|
3919
|
-
export type
|
|
3920
|
-
//# sourceMappingURL=index.d.cts.map
|
|
3940
|
+
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type ConfigGenerateResult, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticFormatOptions, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, type Exclude$1 as Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, type Include, type InputKind, type InstalledPackage, type JSONValue, Kubb$1 as Kubb, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Memo, type NormalizedPlugin, type Output, type OutputManifest, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveNameOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, type UserReporter };
|
package/dist/index.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ declare const diagnosticCatalog: {
|
|
|
165
165
|
readonly code: 'KUBB_INVALID_DOCUMENT';
|
|
166
166
|
readonly title: 'Invalid document';
|
|
167
167
|
readonly cause: 'The `input` cannot be read as an OpenAPI or Swagger document: its JSON or YAML has a syntax error, it declares no `openapi` or `swagger` version field, or its version cannot be upgraded to OpenAPI 3.1.';
|
|
168
|
-
readonly fix: 'Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0
|
|
168
|
+
readonly fix: 'Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0 or OpenAPI 3.0, 3.1, or 3.2 document, and check that a passed object is the spec itself rather than a wrapper around it.';
|
|
169
169
|
};
|
|
170
170
|
readonly invalidSpec: {
|
|
171
171
|
readonly code: 'KUBB_INVALID_SPEC';
|
|
@@ -290,8 +290,8 @@ declare const diagnosticCatalog: {
|
|
|
290
290
|
readonly invalidPluginOptions: {
|
|
291
291
|
readonly code: 'KUBB_INVALID_PLUGIN_OPTIONS';
|
|
292
292
|
readonly title: 'Invalid plugin options';
|
|
293
|
-
readonly cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.";
|
|
294
|
-
readonly fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option or
|
|
293
|
+
readonly cause: "A plugin was configured with options that cannot be honored, for example a single-file output (`output.mode: 'file'`, or an `output.path` with a file extension) paired with a `group` option.";
|
|
294
|
+
readonly fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option, give `output.path` a directory name, or set `output.mode: 'directory'`.";
|
|
295
295
|
};
|
|
296
296
|
readonly postGenerateFailed: {
|
|
297
297
|
readonly code: 'KUBB_POST_GENERATE_FAILED';
|
|
@@ -1717,6 +1717,10 @@ export type BuildOutput = {
|
|
|
1717
1717
|
* The plugin driver that orchestrated this build.
|
|
1718
1718
|
*/
|
|
1719
1719
|
driver: KubbDriver;
|
|
1720
|
+
/**
|
|
1721
|
+
* The parsed spec the build generated from, `null` when there was none to parse.
|
|
1722
|
+
*/
|
|
1723
|
+
input: InputNode | null;
|
|
1720
1724
|
/**
|
|
1721
1725
|
* The configured `Storage` backend, for reading back a generated file's final content.
|
|
1722
1726
|
* Use `files` to list what this build produced.
|
|
@@ -2322,7 +2326,7 @@ type ResolverPathParams = Omit<ResolverFileParams, 'name' | 'extname'> & {
|
|
|
2322
2326
|
*/
|
|
2323
2327
|
type ResolvePathOptions = ResolverPathParams & {
|
|
2324
2328
|
/**
|
|
2325
|
-
* Absolute
|
|
2329
|
+
* Absolute directory the plugin's `output.path` is resolved against. Generators pass `ctx.root`, the config's output directory.
|
|
2326
2330
|
*/
|
|
2327
2331
|
root: string;
|
|
2328
2332
|
/**
|
|
@@ -2803,7 +2807,8 @@ type ByMethod = {
|
|
|
2803
2807
|
type: 'method';
|
|
2804
2808
|
/**
|
|
2805
2809
|
* HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
|
|
2806
|
-
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`) or a regex.
|
|
2810
|
+
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`) or a regex. Matching ignores
|
|
2811
|
+
* case, so `'get'` and `/get/` work too.
|
|
2807
2812
|
*/
|
|
2808
2813
|
pattern: HttpMethod | RegExp;
|
|
2809
2814
|
};
|
|
@@ -3272,7 +3277,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
|
3272
3277
|
type AdapterDefinition<T extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
3273
3278
|
meta: ExtensionMeta<T['name']>;
|
|
3274
3279
|
/**
|
|
3275
|
-
* Takes the user's options and returns the resolved options, which `build` receives
|
|
3280
|
+
* Takes the user's options and returns the resolved options, which `build` receives. The adapter exposes the user's options as `options`.
|
|
3276
3281
|
* Without `setup`, the user's options are the resolved options.
|
|
3277
3282
|
*/
|
|
3278
3283
|
setup?(options: T['options']): T['resolvedOptions'];
|
|
@@ -3392,8 +3397,15 @@ type CreateKubbOptions = {
|
|
|
3392
3397
|
*/
|
|
3393
3398
|
signal?: AbortSignal;
|
|
3394
3399
|
};
|
|
3400
|
+
type ConfigGenerateResult = GenerateResult & {
|
|
3401
|
+
kubb: Kubb$1;
|
|
3402
|
+
/**
|
|
3403
|
+
* What the build threw outside its own diagnostics. `diagnostics` holds it too.
|
|
3404
|
+
*/
|
|
3405
|
+
error?: unknown;
|
|
3406
|
+
};
|
|
3395
3407
|
/**
|
|
3396
|
-
* Host hooks for a single {@link Kubb
|
|
3408
|
+
* Host hooks for a single {@link Kubb#generate} call. All optional. Progress narration rides the
|
|
3397
3409
|
* `kubb:*` lifecycle hooks on `.hooks`, so hosts subscribe there rather than pass a callback.
|
|
3398
3410
|
*/
|
|
3399
3411
|
type GenerateOptions = {
|
|
@@ -3405,7 +3417,7 @@ type GenerateOptions = {
|
|
|
3405
3417
|
processOutput?: (context: RunOutputPassesOptions) => Promise<Array<Diagnostic>>;
|
|
3406
3418
|
};
|
|
3407
3419
|
/**
|
|
3408
|
-
* What a {@link Kubb
|
|
3420
|
+
* What a {@link Kubb#generate} call produced, for the host to map onto its own result shape.
|
|
3409
3421
|
*/
|
|
3410
3422
|
type GenerateResult = {
|
|
3411
3423
|
/**
|
|
@@ -3420,6 +3432,10 @@ type GenerateResult = {
|
|
|
3420
3432
|
* Build diagnostics plus any collected from the output passes.
|
|
3421
3433
|
*/
|
|
3422
3434
|
diagnostics: Array<Diagnostic>;
|
|
3435
|
+
/**
|
|
3436
|
+
* The parsed spec the build generated from, `null` when the build failed before parsing.
|
|
3437
|
+
*/
|
|
3438
|
+
input: InputNode | null;
|
|
3423
3439
|
};
|
|
3424
3440
|
/**
|
|
3425
3441
|
* Kubb code-generation instance bound to a single config entry. Resolves the user
|
|
@@ -3443,6 +3459,11 @@ declare class Kubb$1 {
|
|
|
3443
3459
|
readonly hooks: Hookable<KubbHooks>;
|
|
3444
3460
|
readonly config: Config;
|
|
3445
3461
|
constructor(userConfig: UserConfig, options?: CreateKubbOptions);
|
|
3462
|
+
/**
|
|
3463
|
+
* Generates every config of a `defineConfig([...])` array in order and yields each result as its config finishes, so
|
|
3464
|
+
* memory holds one config at a time. A config that fails does not stop the others. Only an aborted `signal` rejects.
|
|
3465
|
+
*/
|
|
3466
|
+
static generate(configs: Array<UserConfig>, { hooks, signal }?: Pick<CreateKubbOptions, 'hooks' | 'signal'>): AsyncGenerator<ConfigGenerateResult, void, void>;
|
|
3446
3467
|
get storage(): Storage;
|
|
3447
3468
|
get driver(): KubbDriver;
|
|
3448
3469
|
/**
|
|
@@ -3916,5 +3937,4 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
|
|
|
3916
3937
|
packages?: Iterable<string>;
|
|
3917
3938
|
resolveFrom?: Array<string>;
|
|
3918
3939
|
}): Promise<Array<InstalledPackage>>;
|
|
3919
|
-
export type
|
|
3920
|
-
//# sourceMappingURL=index.d.ts.map
|
|
3940
|
+
export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type ConfigGenerateResult, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticFormatOptions, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, type Exclude$1 as Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, type Include, type InputKind, type InstalledPackage, type JSONValue, Kubb$1 as Kubb, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Memo, type NormalizedPlugin, type Output, type OutputManifest, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveNameOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, type UserReporter };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isValid, satisfies } from "verkit";
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import process$1 from "node:process";
|
|
5
5
|
import { x } from "tinyexec";
|
|
6
|
-
import { access, glob, mkdir, mkdtemp, readFile, readdir, rename, rm, rm as rm$1, writeFile } from "node:fs/promises";
|
|
6
|
+
import { access, glob, mkdir as mkdir$1, mkdtemp as mkdtemp$1, readFile, readdir, rename, rm, rm as rm$1, writeFile } from "node:fs/promises";
|
|
7
7
|
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
import { chmodSync, existsSync, existsSync as existsSync$1, mkdirSync } from "node:fs";
|
|
9
9
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -21,7 +21,7 @@ var __name = (target, value) => __defProp(target, "name", {
|
|
|
21
21
|
configurable: true
|
|
22
22
|
});
|
|
23
23
|
// package.json
|
|
24
|
-
var version = "5.18.
|
|
24
|
+
var version = "5.18.7";
|
|
25
25
|
// ../../internals/utils/src/casing.ts
|
|
26
26
|
/**
|
|
27
27
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -259,7 +259,7 @@ async function writeRaw(path, content) {
|
|
|
259
259
|
await writeFile(resolved, content, { encoding: "utf-8" });
|
|
260
260
|
} catch (error) {
|
|
261
261
|
if (error.code !== "ENOENT") throw error;
|
|
262
|
-
await mkdir(dirname(resolved), { recursive: true });
|
|
262
|
+
await mkdir$1(dirname(resolved), { recursive: true });
|
|
263
263
|
await writeFile(resolved, content, { encoding: "utf-8" });
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -549,7 +549,7 @@ const diagnosticCatalog = {
|
|
|
549
549
|
code: "KUBB_INVALID_DOCUMENT",
|
|
550
550
|
title: "Invalid document",
|
|
551
551
|
cause: "The `input` cannot be read as an OpenAPI or Swagger document: its JSON or YAML has a syntax error, it declares no `openapi` or `swagger` version field, or its version cannot be upgraded to OpenAPI 3.1.",
|
|
552
|
-
fix: "Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0
|
|
552
|
+
fix: "Fix the syntax at the reported line, and check that `input` points at the spec and not an HTML page. Point `input` at a Swagger 2.0 or OpenAPI 3.0, 3.1, or 3.2 document, and check that a passed object is the spec itself rather than a wrapper around it."
|
|
553
553
|
},
|
|
554
554
|
invalidSpec: {
|
|
555
555
|
code: "KUBB_INVALID_SPEC",
|
|
@@ -674,8 +674,8 @@ const diagnosticCatalog = {
|
|
|
674
674
|
invalidPluginOptions: {
|
|
675
675
|
code: "KUBB_INVALID_PLUGIN_OPTIONS",
|
|
676
676
|
title: "Invalid plugin options",
|
|
677
|
-
cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.",
|
|
678
|
-
fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option or
|
|
677
|
+
cause: "A plugin was configured with options that cannot be honored, for example a single-file output (`output.mode: 'file'`, or an `output.path` with a file extension) paired with a `group` option.",
|
|
678
|
+
fix: "Fix the plugin options. A single-file output has nothing to group, so remove the `group` option, give `output.path` a directory name, or set `output.mode: 'directory'`."
|
|
679
679
|
},
|
|
680
680
|
postGenerateFailed: {
|
|
681
681
|
code: "KUBB_POST_GENERATE_FAILED",
|
|
@@ -1573,8 +1573,8 @@ async function checkoutGitInput(input, signal, { publicOnly = false, authorizati
|
|
|
1573
1573
|
authorization
|
|
1574
1574
|
}) : {};
|
|
1575
1575
|
const fetchConfig = publicOnly ? await resolvePublicFetchConfig(repo, signal) : [];
|
|
1576
|
-
const dir = await mkdtemp(join(tmpdir(), "kubb-git-"));
|
|
1577
|
-
const dispose = () => rm(dir, {
|
|
1576
|
+
const dir = await mkdtemp$1(join(tmpdir(), "kubb-git-"));
|
|
1577
|
+
const dispose = () => rm$1(dir, {
|
|
1578
1578
|
recursive: true,
|
|
1579
1579
|
force: true
|
|
1580
1580
|
});
|
|
@@ -1718,11 +1718,16 @@ function inputToAdapterSource(config) {
|
|
|
1718
1718
|
}
|
|
1719
1719
|
// src/resolveOptions.ts
|
|
1720
1720
|
const patterns = /* @__PURE__ */ new Map();
|
|
1721
|
+
const methodPatterns = /* @__PURE__ */ new Map();
|
|
1721
1722
|
const nodeCaches = /* @__PURE__ */ new WeakMap();
|
|
1722
1723
|
function testPattern(value, pattern) {
|
|
1723
1724
|
if (typeof pattern === "string") return memo$1(patterns, pattern, () => new RegExp(pattern)).test(value);
|
|
1724
1725
|
return value.match(pattern) !== null;
|
|
1725
1726
|
}
|
|
1727
|
+
function testMethod(method, pattern) {
|
|
1728
|
+
if (typeof pattern === "string") return memo$1(methodPatterns, pattern, () => new RegExp(pattern, "i")).test(method);
|
|
1729
|
+
return method.match(pattern.ignoreCase ? pattern : new RegExp(pattern.source, `${pattern.flags}i`)) !== null;
|
|
1730
|
+
}
|
|
1726
1731
|
function matchesOperation(node, filter) {
|
|
1727
1732
|
if (filter.type === "extension") {
|
|
1728
1733
|
const { extensions } = node;
|
|
@@ -1732,7 +1737,7 @@ function matchesOperation(node, filter) {
|
|
|
1732
1737
|
if (type === "tag") return node.tags.some((tag) => testPattern(tag, pattern));
|
|
1733
1738
|
if (type === "operationId") return testPattern(node.operationId, pattern);
|
|
1734
1739
|
if (type === "path") return node.path !== void 0 && testPattern(node.path, pattern);
|
|
1735
|
-
if (type === "method") return node.method !== void 0 &&
|
|
1740
|
+
if (type === "method") return node.method !== void 0 && testMethod(node.method, pattern);
|
|
1736
1741
|
if (type === "contentType") return node.requestBody?.content?.some((c) => testPattern(c.contentType, pattern)) ?? false;
|
|
1737
1742
|
return false;
|
|
1738
1743
|
}
|
|
@@ -2035,15 +2040,15 @@ var Resolver = class Resolver {
|
|
|
2035
2040
|
/**
|
|
2036
2041
|
* Resolves a resolver-supplied full path (`file.path`) against `root`, bypassing `output.path`
|
|
2037
2042
|
* and `group`. The path may not escape `root`, which keeps a `file.path` that interpolates
|
|
2038
|
-
* spec-derived values from writing outside the
|
|
2043
|
+
* spec-derived values from writing outside the output directory.
|
|
2039
2044
|
*/
|
|
2040
2045
|
#resolveOverridePath(filePath, root) {
|
|
2041
2046
|
const resolved = path.resolve(root, filePath);
|
|
2042
2047
|
assertInside({
|
|
2043
2048
|
target: resolved,
|
|
2044
2049
|
parent: root,
|
|
2045
|
-
message: `Resolved path "${resolved}" is outside the
|
|
2046
|
-
help: "A resolver `file.path` must return a path inside the
|
|
2050
|
+
message: `Resolved path "${resolved}" is outside the output directory "${root}".`,
|
|
2051
|
+
help: "A resolver `file.path` must return a path inside the output directory (`config.output.path`)."
|
|
2047
2052
|
});
|
|
2048
2053
|
return resolved;
|
|
2049
2054
|
}
|
|
@@ -2186,7 +2191,7 @@ var Resolver = class Resolver {
|
|
|
2186
2191
|
function createResolver(options) {
|
|
2187
2192
|
return new Resolver(options);
|
|
2188
2193
|
}
|
|
2189
|
-
// \0@oxc-project+runtime@0.
|
|
2194
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/usingCtx.js
|
|
2190
2195
|
function _usingCtx() {
|
|
2191
2196
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
2192
2197
|
var n = Error();
|
|
@@ -2556,6 +2561,22 @@ function normalizePluginOptions(rawOptions, pluginName) {
|
|
|
2556
2561
|
group,
|
|
2557
2562
|
pluginName
|
|
2558
2563
|
});
|
|
2564
|
+
options.override = options.override?.map((entry) => {
|
|
2565
|
+
const { output } = entry.options;
|
|
2566
|
+
if (!output) return entry;
|
|
2567
|
+
const entryGroup = "group" in entry.options ? entry.options.group : group;
|
|
2568
|
+
return {
|
|
2569
|
+
...entry,
|
|
2570
|
+
options: {
|
|
2571
|
+
...entry.options,
|
|
2572
|
+
output: normalizeOutput({
|
|
2573
|
+
output,
|
|
2574
|
+
group: entryGroup,
|
|
2575
|
+
pluginName
|
|
2576
|
+
})
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
});
|
|
2559
2580
|
return options;
|
|
2560
2581
|
}
|
|
2561
2582
|
/**
|
|
@@ -3380,7 +3401,7 @@ const fsStorage = createStorage(() => ({
|
|
|
3380
3401
|
});
|
|
3381
3402
|
},
|
|
3382
3403
|
async removeItem(key) {
|
|
3383
|
-
await rm
|
|
3404
|
+
await rm(resolve(key), { force: true });
|
|
3384
3405
|
},
|
|
3385
3406
|
async readKeys(base) {
|
|
3386
3407
|
return Array.fromAsync(listFiles(resolve(base ?? process.cwd()))).catch(() => []);
|
|
@@ -3393,14 +3414,14 @@ const fsStorage = createStorage(() => ({
|
|
|
3393
3414
|
try {
|
|
3394
3415
|
await rename(dir, join(parent, `${prefix}${process.pid}-${Date.now()}`));
|
|
3395
3416
|
} catch (_error) {
|
|
3396
|
-
await rm
|
|
3417
|
+
await rm(dir, {
|
|
3397
3418
|
recursive: true,
|
|
3398
3419
|
force: true
|
|
3399
3420
|
});
|
|
3400
3421
|
return;
|
|
3401
3422
|
}
|
|
3402
3423
|
const trash = (await readdir(parent)).filter((name) => name.startsWith(prefix));
|
|
3403
|
-
Promise.all(trash.map((name) => rm
|
|
3424
|
+
Promise.all(trash.map((name) => rm(join(parent, name), {
|
|
3404
3425
|
recursive: true,
|
|
3405
3426
|
force: true
|
|
3406
3427
|
}))).catch(() => {});
|
|
@@ -3418,7 +3439,7 @@ const fsStorage = createStorage(() => ({
|
|
|
3418
3439
|
*/
|
|
3419
3440
|
function resolveCacheDir(root) {
|
|
3420
3441
|
const nodeModules = join(root, "node_modules");
|
|
3421
|
-
if (existsSync
|
|
3442
|
+
if (existsSync(nodeModules)) return join(nodeModules, ".cache", "kubb");
|
|
3422
3443
|
return join(tmpdir(), "kubb", hash("sha256", root).slice(0, 16));
|
|
3423
3444
|
}
|
|
3424
3445
|
/**
|
|
@@ -3657,7 +3678,7 @@ async function runToolPass({ pass, setting, outputPath, hooks, cwd, signal }) {
|
|
|
3657
3678
|
}
|
|
3658
3679
|
if (setting === "auto") await hooks.callHook("kubb:info", { message: `Auto-detected ${pass.label}: ${styleText("dim", detected)}` });
|
|
3659
3680
|
const tool = pass.tools[detected];
|
|
3660
|
-
if (!tool || !existsSync(outputPath)) return null;
|
|
3681
|
+
if (!tool || !existsSync$1(outputPath)) return null;
|
|
3661
3682
|
const result = await runHook({
|
|
3662
3683
|
hooks,
|
|
3663
3684
|
command: tool.command,
|
|
@@ -3786,7 +3807,7 @@ function hasOutputPasses({ output, storage }) {
|
|
|
3786
3807
|
* const { files, diagnostics } = await kubb.safeBuild()
|
|
3787
3808
|
* ```
|
|
3788
3809
|
*/
|
|
3789
|
-
var Kubb = class {
|
|
3810
|
+
var Kubb = class Kubb {
|
|
3790
3811
|
hooks;
|
|
3791
3812
|
config;
|
|
3792
3813
|
#driver = null;
|
|
@@ -3797,6 +3818,34 @@ var Kubb = class {
|
|
|
3797
3818
|
this.hooks = options.hooks ?? new Hookable();
|
|
3798
3819
|
this.#signal = options.signal;
|
|
3799
3820
|
}
|
|
3821
|
+
/**
|
|
3822
|
+
* Generates every config of a `defineConfig([...])` array in order and yields each result as its config finishes, so
|
|
3823
|
+
* memory holds one config at a time. A config that fails does not stop the others. Only an aborted `signal` rejects.
|
|
3824
|
+
*/
|
|
3825
|
+
static async *generate(configs, { hooks = new Hookable(), signal } = {}) {
|
|
3826
|
+
for (const config of configs) {
|
|
3827
|
+
const kubb = new Kubb(config, {
|
|
3828
|
+
hooks,
|
|
3829
|
+
signal
|
|
3830
|
+
});
|
|
3831
|
+
try {
|
|
3832
|
+
yield {
|
|
3833
|
+
...await kubb.generate(),
|
|
3834
|
+
kubb
|
|
3835
|
+
};
|
|
3836
|
+
} catch (error) {
|
|
3837
|
+
if (signal?.aborted) throw error;
|
|
3838
|
+
yield {
|
|
3839
|
+
success: false,
|
|
3840
|
+
files: [],
|
|
3841
|
+
diagnostics: [Diagnostics.from(error)],
|
|
3842
|
+
input: null,
|
|
3843
|
+
kubb,
|
|
3844
|
+
error
|
|
3845
|
+
};
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3800
3849
|
get storage() {
|
|
3801
3850
|
return this.config.storage;
|
|
3802
3851
|
}
|
|
@@ -3867,7 +3916,8 @@ var Kubb = class {
|
|
|
3867
3916
|
diagnostics,
|
|
3868
3917
|
files: driver.fileManager.files,
|
|
3869
3918
|
driver,
|
|
3870
|
-
storage
|
|
3919
|
+
storage,
|
|
3920
|
+
input: driver.inputNode
|
|
3871
3921
|
};
|
|
3872
3922
|
} catch (_) {
|
|
3873
3923
|
_usingCtx$1.e = _;
|
|
@@ -3903,15 +3953,16 @@ var Kubb = class {
|
|
|
3903
3953
|
if (signal?.aborted) throw caughtError;
|
|
3904
3954
|
output = {
|
|
3905
3955
|
files: [],
|
|
3906
|
-
diagnostics: [Diagnostics.from(caughtError)]
|
|
3956
|
+
diagnostics: [Diagnostics.from(caughtError)],
|
|
3957
|
+
input: null
|
|
3907
3958
|
};
|
|
3908
3959
|
}
|
|
3909
|
-
const { files, diagnostics } = output;
|
|
3960
|
+
const { files, diagnostics, input } = output;
|
|
3910
3961
|
const storage = this.storage;
|
|
3911
3962
|
signal?.throwIfAborted();
|
|
3912
3963
|
for (const diagnostic of diagnostics) if (Diagnostics.isProblem(diagnostic)) await Diagnostics.emit(hooks, diagnostic);
|
|
3913
3964
|
if (Diagnostics.hasError(diagnostics)) {
|
|
3914
|
-
await
|
|
3965
|
+
await this.#end({
|
|
3915
3966
|
config,
|
|
3916
3967
|
storage,
|
|
3917
3968
|
diagnostics,
|
|
@@ -3922,7 +3973,8 @@ var Kubb = class {
|
|
|
3922
3973
|
return {
|
|
3923
3974
|
success: false,
|
|
3924
3975
|
files,
|
|
3925
|
-
diagnostics
|
|
3976
|
+
diagnostics,
|
|
3977
|
+
input
|
|
3926
3978
|
};
|
|
3927
3979
|
}
|
|
3928
3980
|
const processOutput = options.processOutput ?? runOutputPasses;
|
|
@@ -3935,7 +3987,7 @@ var Kubb = class {
|
|
|
3935
3987
|
const finalDiagnostics = [...diagnostics, ...outputDiagnostics];
|
|
3936
3988
|
const failed = Diagnostics.hasError(outputDiagnostics);
|
|
3937
3989
|
if (!failed) await this.#manifest?.commit();
|
|
3938
|
-
await
|
|
3990
|
+
await this.#end({
|
|
3939
3991
|
config,
|
|
3940
3992
|
storage,
|
|
3941
3993
|
diagnostics: finalDiagnostics,
|
|
@@ -3946,11 +3998,23 @@ var Kubb = class {
|
|
|
3946
3998
|
return {
|
|
3947
3999
|
success: !failed,
|
|
3948
4000
|
files,
|
|
3949
|
-
diagnostics: finalDiagnostics
|
|
4001
|
+
diagnostics: finalDiagnostics,
|
|
4002
|
+
input
|
|
3950
4003
|
};
|
|
3951
4004
|
}
|
|
4005
|
+
/** Ends a run: `kubb:generation:end`, then the totals on `kubb:generation:summary`. */
|
|
4006
|
+
async #end(ctx) {
|
|
4007
|
+
await this.hooks.callHook("kubb:generation:end", ctx);
|
|
4008
|
+
await this.hooks.callHook("kubb:generation:summary", {
|
|
4009
|
+
duration: Math.round(getElapsedMs(ctx.hrStart)),
|
|
4010
|
+
fileCount: ctx.filesCreated,
|
|
4011
|
+
failedPlugins: Diagnostics.failedPlugins(ctx.diagnostics).length,
|
|
4012
|
+
status: ctx.status
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
3952
4015
|
dispose() {
|
|
3953
4016
|
this.#driver?.dispose();
|
|
4017
|
+
this.#driver = null;
|
|
3954
4018
|
}
|
|
3955
4019
|
[Symbol.dispose]() {
|
|
3956
4020
|
this.dispose();
|
|
@@ -4085,7 +4149,7 @@ function kubbStorage({ base } = {}) {
|
|
|
4085
4149
|
await writeRaw(pathOf(key), typeof value === "string" ? value : JSON.stringify(value));
|
|
4086
4150
|
},
|
|
4087
4151
|
async removeItem(key) {
|
|
4088
|
-
await rm
|
|
4152
|
+
await rm(pathOf(key), { force: true });
|
|
4089
4153
|
}
|
|
4090
4154
|
};
|
|
4091
4155
|
}
|
|
@@ -4542,7 +4606,7 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
|
|
|
4542
4606
|
const packageJSON = await readJSON(path.join(root, "package.json")).catch(() => null);
|
|
4543
4607
|
const dependencies = [packageJSON?.dependencies, packageJSON?.devDependencies].flatMap((record) => typeof record === "object" && record !== null ? Object.keys(record) : []);
|
|
4544
4608
|
return Promise.all([.../* @__PURE__ */ new Set([...dependencies, ...packages])].filter(isPackageName).map(async (name) => {
|
|
4545
|
-
const dir = requires.flatMap((require) => require.resolve.paths(name) ?? []).map((dir) => path.join(dir, name)).find((dir) => existsSync(path.join(dir, "package.json")));
|
|
4609
|
+
const dir = requires.flatMap((require) => require.resolve.paths(name) ?? []).map((dir) => path.join(dir, name)).find((dir) => existsSync$1(path.join(dir, "package.json")));
|
|
4546
4610
|
if (!dir) return { package: name };
|
|
4547
4611
|
try {
|
|
4548
4612
|
const { version } = await readJSON(path.join(dir, "package.json"));
|
|
@@ -4557,6 +4621,6 @@ async function readInstalledPackages({ root, packages = [], resolveFrom = [] })
|
|
|
4557
4621
|
}
|
|
4558
4622
|
}));
|
|
4559
4623
|
}
|
|
4560
|
-
export { Diagnostics, Hookable, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, camelCase, checkCompatibility, checkoutGitInput, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, hasOutputPasses, htmlReporter, injectFile, isExtensionManifest, isPackageName, isPublicAddress, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memo, memoryStorage, pascalCase, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
4624
|
+
export { Diagnostics, Hookable, Kubb, KubbDriver, Resolver, addGenerator, addMacro, assertPluginOption, cacheStorage, camelCase, checkCompatibility, checkoutGitInput, cliReporter, createAdapter, createCliReporter, createKubb, createOutputManifest, createRenderer, createReporter, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fileReporter, fsStorage, getInputKind, hasOutputPasses, htmlReporter, injectFile, isExtensionManifest, isPackageName, isPublicAddress, isRegistryEntry, jsonReporter, kubbContext, kubbStorage, logLevel, manifestProblems, memo, memoryStorage, pascalCase, readInstalledPackages, requirePlugin, resolveCacheDir, resolveKubbDir, resolveMeta, runHook, runOutputPasses, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
|
|
4561
4625
|
|
|
4562
4626
|
//# sourceMappingURL=index.js.map
|