@kubb/core 5.0.0-beta.57 → 5.0.0-beta.59
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/{diagnostics-Bf2bC8lV.d.ts → diagnostics-B-UZnFqP.d.ts} +54 -68
- package/dist/index.cjs +34 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -28
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-skOz0dXZ.cjs → memoryStorage-CUj1hrxa.cjs} +9 -7
- package/dist/memoryStorage-CUj1hrxa.cjs.map +1 -0
- package/dist/{memoryStorage-B0W-w994.js → memoryStorage-CWFzAz4o.js} +7 -6
- package/dist/memoryStorage-CWFzAz4o.js.map +1 -0
- package/dist/mocks.cjs +1 -2
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +1 -2
- package/dist/mocks.js +1 -2
- package/dist/mocks.js.map +1 -1
- package/package.json +4 -4
- package/src/FileManager.ts +2 -2
- package/src/FileProcessor.ts +1 -1
- package/src/KubbDriver.ts +13 -6
- package/src/createAdapter.ts +5 -6
- package/src/createRenderer.ts +3 -4
- package/src/createReporter.ts +1 -1
- package/src/createStorage.ts +4 -4
- package/src/defineGenerator.ts +2 -2
- package/src/defineParser.ts +3 -2
- package/src/definePlugin.ts +13 -18
- package/src/defineResolver.ts +7 -6
- package/src/diagnostics.ts +8 -11
- package/src/index.ts +1 -0
- package/src/mocks.ts +0 -1
- package/src/reporters/cliReporter.ts +1 -1
- package/src/types.ts +9 -15
- package/dist/memoryStorage-B0W-w994.js.map +0 -1
- package/dist/memoryStorage-skOz0dXZ.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
-
import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-
|
|
2
|
+
import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-B-UZnFqP.js";
|
|
3
3
|
import * as ast from "@kubb/ast";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/utils/src/url.d.ts
|
|
@@ -104,7 +104,7 @@ declare class Url {
|
|
|
104
104
|
//#region src/reporters/cliReporter.d.ts
|
|
105
105
|
/**
|
|
106
106
|
* The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
|
|
107
|
-
* of the live logger view. Suppressed at `silent
|
|
107
|
+
* of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
|
|
108
108
|
*/
|
|
109
109
|
declare const cliReporter: Reporter;
|
|
110
110
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
|
-
import { a as createStorage, c as camelCase, d as BuildError, f as getErrorMessage, i as FileManager, l as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as AsyncEventEmitter } from "./memoryStorage-
|
|
3
|
-
import { hash } from "node:crypto";
|
|
2
|
+
import { a as createStorage, c as camelCase, d as BuildError, f as getErrorMessage, i as FileManager, l as pascalCase, n as _usingCtx, o as OPERATION_FILTER_TYPES, r as FileProcessor, s as diagnosticCode, t as memoryStorage, u as AsyncEventEmitter } from "./memoryStorage-CWFzAz4o.js";
|
|
4
3
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
4
|
+
import { hash } from "node:crypto";
|
|
5
5
|
import { access, glob, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
6
6
|
import path, { dirname, join, relative, resolve } from "node:path";
|
|
7
7
|
import * as ast from "@kubb/ast";
|
|
8
|
-
import {
|
|
8
|
+
import { operationDef, schemaDef, transform } from "@kubb/ast";
|
|
9
9
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
+
import * as factory from "@kubb/ast/factory";
|
|
11
|
+
import { collectUsedSchemaNames } from "@kubb/ast/utils";
|
|
10
12
|
import process$1 from "node:process";
|
|
11
13
|
//#region ../../internals/utils/src/time.ts
|
|
12
14
|
/**
|
|
@@ -571,9 +573,8 @@ var Url = class Url {
|
|
|
571
573
|
//#region src/createAdapter.ts
|
|
572
574
|
/**
|
|
573
575
|
* Defines a custom adapter that translates a spec format into Kubb's universal
|
|
574
|
-
* AST
|
|
575
|
-
*
|
|
576
|
-
* OpenAPI/Swagger documents.
|
|
576
|
+
* AST, for example GraphQL, gRPC, or AsyncAPI. The built-in `@kubb/adapter-oas`
|
|
577
|
+
* handles OpenAPI/Swagger documents.
|
|
577
578
|
*
|
|
578
579
|
* Adapters must return an `InputNode` from `parse`. That node is what every
|
|
579
580
|
* plugin in the build consumes.
|
|
@@ -590,7 +591,7 @@ var Url = class Url {
|
|
|
590
591
|
* document: null,
|
|
591
592
|
* async parse(_source) {
|
|
592
593
|
* // Convert `source` (path or inline data) into an InputNode.
|
|
593
|
-
* return ast.createInput()
|
|
594
|
+
* return ast.factory.createInput()
|
|
594
595
|
* },
|
|
595
596
|
* getImports: () => [],
|
|
596
597
|
* async validate() {
|
|
@@ -605,9 +606,9 @@ function createAdapter(build) {
|
|
|
605
606
|
//#endregion
|
|
606
607
|
//#region src/diagnostics.ts
|
|
607
608
|
/**
|
|
608
|
-
* Docs major, derived from the package version so the link tracks the published major.
|
|
609
|
+
* Docs major version, derived from the package version so the link tracks the published major.
|
|
609
610
|
*/
|
|
610
|
-
const docsMajor = "5.0.0-beta.
|
|
611
|
+
const docsMajor = "5.0.0-beta.59".split(".")[0] ?? "5";
|
|
611
612
|
/**
|
|
612
613
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
613
614
|
*
|
|
@@ -1054,8 +1055,7 @@ function normalizeOutput({ output, group, pluginName }) {
|
|
|
1054
1055
|
}
|
|
1055
1056
|
/**
|
|
1056
1057
|
* Wraps a plugin factory and returns a function that accepts user options and
|
|
1057
|
-
* yields a
|
|
1058
|
-
* `hooks` object (inspired by Astro integrations).
|
|
1058
|
+
* yields a typed `Plugin`. Lifecycle handlers go inside a single `hooks` object.
|
|
1059
1059
|
*
|
|
1060
1060
|
* Pass a `PluginFactoryOptions` type parameter to get a typed `ctx` inside
|
|
1061
1061
|
* `kubb:plugin:setup`. Plugin names should follow the `plugin-<feature>`
|
|
@@ -1207,8 +1207,8 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
|
|
|
1207
1207
|
/**
|
|
1208
1208
|
* Default path resolver used by `defineResolver`.
|
|
1209
1209
|
*
|
|
1210
|
-
* - `mode: 'file'`
|
|
1211
|
-
* - `mode: 'directory'` (default)
|
|
1210
|
+
* - `mode: 'file'` resolves directly to `output.path` (the full file path, extension included).
|
|
1211
|
+
* - `mode: 'directory'` (default) resolves to `output.path/{baseName}`, or into a
|
|
1212
1212
|
* subdirectory when `group` and a `tag`/`path` value are provided.
|
|
1213
1213
|
*
|
|
1214
1214
|
* A custom `group.name` function overrides the default subdirectory naming.
|
|
@@ -1309,7 +1309,7 @@ function defaultResolveFile({ name, extname, tag, path: groupPath }, context) {
|
|
|
1309
1309
|
tag,
|
|
1310
1310
|
path: groupPath
|
|
1311
1311
|
}, context);
|
|
1312
|
-
return createFile({
|
|
1312
|
+
return factory.createFile({
|
|
1313
1313
|
path: filePath,
|
|
1314
1314
|
baseName: path.basename(filePath),
|
|
1315
1315
|
meta: { pluginName: this.pluginName },
|
|
@@ -1445,8 +1445,8 @@ function defaultResolveFooter(meta, { output, file }) {
|
|
|
1445
1445
|
* - `resolveFile` builds the full `FileNode`.
|
|
1446
1446
|
* - `resolveBanner` and `resolveFooter` produce the top and bottom of file text.
|
|
1447
1447
|
*
|
|
1448
|
-
* Methods in the returned object can call sibling resolver methods via `this
|
|
1449
|
-
*
|
|
1448
|
+
* Methods in the returned object can call sibling resolver methods via `this`.
|
|
1449
|
+
* A custom rule can delegate to a default, for example `this.default(name, 'type')`.
|
|
1450
1450
|
*
|
|
1451
1451
|
* @example Basic resolver with naming helpers
|
|
1452
1452
|
* ```ts
|
|
@@ -1558,7 +1558,8 @@ var KubbDriver = class {
|
|
|
1558
1558
|
config;
|
|
1559
1559
|
options;
|
|
1560
1560
|
/**
|
|
1561
|
-
* The streaming `InputNode<true>` produced by the adapter.
|
|
1561
|
+
* The streaming `InputNode<true>` produced by the adapter. Set after adapter setup.
|
|
1562
|
+
* Parse-only adapters are wrapped automatically.
|
|
1562
1563
|
*/
|
|
1563
1564
|
inputNode = null;
|
|
1564
1565
|
adapter = null;
|
|
@@ -1647,7 +1648,7 @@ var KubbDriver = class {
|
|
|
1647
1648
|
/**
|
|
1648
1649
|
* Parses the adapter source into `this.inputNode`. Idempotent, so repeated calls from
|
|
1649
1650
|
* `run` do not re-parse. Adapters with `stream()` are used directly.
|
|
1650
|
-
* Adapters with only `parse()` are wrapped via `
|
|
1651
|
+
* Adapters with only `parse()` are wrapped via `factory.createInput({ stream: true })` so the dispatch loop
|
|
1651
1652
|
* stays stream-only.
|
|
1652
1653
|
*/
|
|
1653
1654
|
async #parseInput() {
|
|
@@ -1659,7 +1660,12 @@ var KubbDriver = class {
|
|
|
1659
1660
|
return;
|
|
1660
1661
|
}
|
|
1661
1662
|
const parsed = await adapter.parse(source);
|
|
1662
|
-
this.inputNode =
|
|
1663
|
+
this.inputNode = factory.createInput({
|
|
1664
|
+
stream: true,
|
|
1665
|
+
schemas: arrayToAsyncIterable(parsed.schemas),
|
|
1666
|
+
operations: arrayToAsyncIterable(parsed.operations),
|
|
1667
|
+
meta: parsed.meta
|
|
1668
|
+
});
|
|
1663
1669
|
}
|
|
1664
1670
|
/**
|
|
1665
1671
|
* Registers a hook-style plugin's lifecycle handlers on the shared `AsyncEventEmitter`.
|
|
@@ -1703,7 +1709,7 @@ var KubbDriver = class {
|
|
|
1703
1709
|
}
|
|
1704
1710
|
},
|
|
1705
1711
|
injectFile: (userFileNode) => {
|
|
1706
|
-
this.fileManager.add(createFile(userFileNode));
|
|
1712
|
+
this.fileManager.add(factory.createFile(userFileNode));
|
|
1707
1713
|
}
|
|
1708
1714
|
};
|
|
1709
1715
|
return hooks["kubb:plugin:setup"](pluginCtx);
|
|
@@ -1930,7 +1936,7 @@ var KubbDriver = class {
|
|
|
1930
1936
|
*
|
|
1931
1937
|
* Plugins run sequentially so `kubb:plugin:end` fires as each plugin completes, instead
|
|
1932
1938
|
* of all at once after every plugin has marched through the parallel batches together.
|
|
1933
|
-
* That ordering is what drives the CLI's `Plugins N/M` counter
|
|
1939
|
+
* That ordering is what drives the CLI's `Plugins N/M` counter. Without it the bar would
|
|
1934
1940
|
* sit at the initial value until the very end of the run.
|
|
1935
1941
|
*
|
|
1936
1942
|
* When `entries` is empty or `this.inputNode` is `null`, every entry still gets a
|
|
@@ -2670,7 +2676,7 @@ function renderSummary(lines, { title, status }) {
|
|
|
2670
2676
|
}
|
|
2671
2677
|
/**
|
|
2672
2678
|
* The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
|
|
2673
|
-
* of the live logger view. Suppressed at `silent
|
|
2679
|
+
* of the live logger view. Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
|
|
2674
2680
|
*/
|
|
2675
2681
|
const cliReporter = createReporter({
|
|
2676
2682
|
name: "cli",
|
|
@@ -2792,10 +2798,9 @@ const jsonReporter = createReporter({
|
|
|
2792
2798
|
* (JSX, a template string, a tree of any shape) into `FileNode`s that get
|
|
2793
2799
|
* written to disk.
|
|
2794
2800
|
*
|
|
2795
|
-
*
|
|
2796
|
-
* renderer
|
|
2797
|
-
*
|
|
2798
|
-
* field on `defineGenerator`.
|
|
2801
|
+
* A renderer can target output formats beyond JSX, for instance a Handlebars
|
|
2802
|
+
* renderer or one that writes binary files. Plugins and generators pick the
|
|
2803
|
+
* renderer to use via the `renderer` field on `defineGenerator`.
|
|
2799
2804
|
*
|
|
2800
2805
|
* @example A minimal renderer that wraps a custom runtime
|
|
2801
2806
|
* ```ts
|
|
@@ -2861,14 +2866,15 @@ function defineGenerator(generator) {
|
|
|
2861
2866
|
*
|
|
2862
2867
|
* @example
|
|
2863
2868
|
* ```ts
|
|
2864
|
-
* import { defineParser
|
|
2869
|
+
* import { defineParser } from '@kubb/core'
|
|
2870
|
+
* import { extractStringsFromNodes } from '@kubb/ast/utils'
|
|
2865
2871
|
*
|
|
2866
2872
|
* export const jsonParser = defineParser({
|
|
2867
2873
|
* name: 'json',
|
|
2868
2874
|
* extNames: ['.json'],
|
|
2869
2875
|
* parse(file) {
|
|
2870
2876
|
* return file.sources
|
|
2871
|
-
* .map((source) =>
|
|
2877
|
+
* .map((source) => extractStringsFromNodes(source.nodes ?? []))
|
|
2872
2878
|
* .join('\n')
|
|
2873
2879
|
* },
|
|
2874
2880
|
* print(...nodes) {
|