@kubb/core 5.0.0-beta.56 → 5.0.0-beta.58
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-BNcDERWL.d.ts} +5 -4
- package/dist/index.cjs +21 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/{memoryStorage-skOz0dXZ.cjs → memoryStorage-Bz4ZDIZz.cjs} +6 -4
- package/dist/memoryStorage-Bz4ZDIZz.cjs.map +1 -0
- package/dist/{memoryStorage-B0W-w994.js → memoryStorage-DZYKdzI6.js} +4 -3
- package/dist/memoryStorage-DZYKdzI6.js.map +1 -0
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +4 -4
- package/src/FileManager.ts +2 -2
- package/src/FileProcessor.ts +1 -1
- package/src/KubbDriver.ts +10 -4
- package/src/createAdapter.ts +1 -1
- package/src/defineParser.ts +3 -2
- package/src/defineResolver.ts +5 -4
- package/src/index.ts +1 -0
- package/dist/memoryStorage-B0W-w994.js.map +0 -1
- package/dist/memoryStorage-skOz0dXZ.cjs.map +0 -1
|
@@ -227,7 +227,7 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
|
|
|
227
227
|
* document: null,
|
|
228
228
|
* async parse(_source) {
|
|
229
229
|
* // Convert `source` (path or inline data) into an InputNode.
|
|
230
|
-
* return ast.createInput()
|
|
230
|
+
* return ast.factory.createInput()
|
|
231
231
|
* },
|
|
232
232
|
* getImports: () => [],
|
|
233
233
|
* async validate() {
|
|
@@ -1678,14 +1678,15 @@ type Parser<TMeta extends object = object, TNode = unknown> = {
|
|
|
1678
1678
|
*
|
|
1679
1679
|
* @example
|
|
1680
1680
|
* ```ts
|
|
1681
|
-
* import { defineParser
|
|
1681
|
+
* import { defineParser } from '@kubb/core'
|
|
1682
|
+
* import { extractStringsFromNodes } from '@kubb/ast/utils'
|
|
1682
1683
|
*
|
|
1683
1684
|
* export const jsonParser = defineParser({
|
|
1684
1685
|
* name: 'json',
|
|
1685
1686
|
* extNames: ['.json'],
|
|
1686
1687
|
* parse(file) {
|
|
1687
1688
|
* return file.sources
|
|
1688
|
-
* .map((source) =>
|
|
1689
|
+
* .map((source) => extractStringsFromNodes(source.nodes ?? []))
|
|
1689
1690
|
* .join('\n')
|
|
1690
1691
|
* },
|
|
1691
1692
|
* print(...nodes) {
|
|
@@ -2917,4 +2918,4 @@ declare class Diagnostics {
|
|
|
2917
2918
|
}
|
|
2918
2919
|
//#endregion
|
|
2919
2920
|
export { KubbPluginSetupContext as $, KubbHookStartContext as A, Adapter as At, ParsedFile as B, KubbFilesProcessingEndContext as C, GenerationResult as Ct, KubbGenerationStartContext as D, UserReporter as Dt, KubbGenerationEndContext as E, ReporterName as Et, KubbSuccessContext as F, Generator$1 as G, createKubb as H, KubbWarnContext as I, KubbDriver as J, GeneratorContext as K, PossibleConfig as L, KubbInfoContext as M, AdapterSource as Mt, KubbLifecycleStartContext as N, createAdapter as Nt, KubbHookEndContext as O, createReporter as Ot, KubbPluginsEndContext as P, AsyncEventEmitter as Pt, KubbPluginEndContext as Q, UserConfig as R, KubbFileProcessingUpdate as S, createStorage as St, KubbFilesProcessingUpdateContext as T, ReporterContext as Tt, Parser as U, Kubb$1 as V, defineParser as W, Group as X, Exclude$1 as Y, Include as Z, InputPath as _, defineResolver as _t, DiagnosticLocation as a, Override as at, KubbDiagnosticContext as b, createRenderer as bt, PerformanceDiagnostic as c, definePlugin as ct, SerializedDiagnostic as d, ResolveBannerFile as dt, KubbPluginStartContext as et, UpdateDiagnostic as f, ResolveOptionsContext as ft, InputData as g, ResolverPathParams as gt, Config as h, ResolverFileParams as ht, DiagnosticKind as i, OutputOptions as it, KubbHooks as j, AdapterFactoryOptions as jt, KubbHookLineContext as k, logLevel as kt, ProblemCode as l, BannerMeta as lt, CLIOptions as m, ResolverContext as mt, DiagnosticByCode as n, Output as nt, DiagnosticSeverity as o, Plugin as ot, BuildOutput as p, Resolver as pt, defineGenerator as q, DiagnosticDoc as r, OutputMode as rt, Diagnostics as s, PluginFactoryOptions as st, Diagnostic as t, NormalizedPlugin as tt, ProblemDiagnostic as u, ResolveBannerContext as ut, KubbBuildEndContext as v, Renderer as vt, KubbFilesProcessingStartContext as w, Reporter as wt, KubbErrorContext as x, Storage as xt, KubbBuildStartContext as y, RendererFactory as yt, FileProcessorHooks as z };
|
|
2920
|
-
//# sourceMappingURL=diagnostics-
|
|
2921
|
+
//# sourceMappingURL=diagnostics-BNcDERWL.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_memoryStorage = require("./memoryStorage-
|
|
2
|
+
const require_memoryStorage = require("./memoryStorage-Bz4ZDIZz.cjs");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -8,6 +8,9 @@ node_path = require_memoryStorage.__toESM(node_path, 1);
|
|
|
8
8
|
let _kubb_ast = require("@kubb/ast");
|
|
9
9
|
_kubb_ast = require_memoryStorage.__toESM(_kubb_ast, 1);
|
|
10
10
|
let node_async_hooks = require("node:async_hooks");
|
|
11
|
+
let _kubb_ast_factory = require("@kubb/ast/factory");
|
|
12
|
+
_kubb_ast_factory = require_memoryStorage.__toESM(_kubb_ast_factory, 1);
|
|
13
|
+
let _kubb_ast_utils = require("@kubb/ast/utils");
|
|
11
14
|
let node_process = require("node:process");
|
|
12
15
|
node_process = require_memoryStorage.__toESM(node_process, 1);
|
|
13
16
|
//#region ../../internals/utils/src/time.ts
|
|
@@ -592,7 +595,7 @@ var Url = class Url {
|
|
|
592
595
|
* document: null,
|
|
593
596
|
* async parse(_source) {
|
|
594
597
|
* // Convert `source` (path or inline data) into an InputNode.
|
|
595
|
-
* return ast.createInput()
|
|
598
|
+
* return ast.factory.createInput()
|
|
596
599
|
* },
|
|
597
600
|
* getImports: () => [],
|
|
598
601
|
* async validate() {
|
|
@@ -609,7 +612,7 @@ function createAdapter(build) {
|
|
|
609
612
|
/**
|
|
610
613
|
* Docs major, derived from the package version so the link tracks the published major.
|
|
611
614
|
*/
|
|
612
|
-
const docsMajor = "5.0.0-beta.
|
|
615
|
+
const docsMajor = "5.0.0-beta.58".split(".")[0] ?? "5";
|
|
613
616
|
/**
|
|
614
617
|
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
615
618
|
*
|
|
@@ -1170,7 +1173,7 @@ function defaultResolver(name, type) {
|
|
|
1170
1173
|
*/
|
|
1171
1174
|
const resolveOptionsCache = /* @__PURE__ */ new WeakMap();
|
|
1172
1175
|
function computeOptions(node, options, exclude, include, override) {
|
|
1173
|
-
if (
|
|
1176
|
+
if (_kubb_ast.operationDef.is(node)) {
|
|
1174
1177
|
if (exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
|
|
1175
1178
|
if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
|
|
1176
1179
|
const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options;
|
|
@@ -1179,7 +1182,7 @@ function computeOptions(node, options, exclude, include, override) {
|
|
|
1179
1182
|
...overrideOptions
|
|
1180
1183
|
};
|
|
1181
1184
|
}
|
|
1182
|
-
if (
|
|
1185
|
+
if (_kubb_ast.schemaDef.is(node)) {
|
|
1183
1186
|
if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) return null;
|
|
1184
1187
|
if (include) {
|
|
1185
1188
|
const applicable = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern)).filter((result) => result !== null);
|
|
@@ -1311,7 +1314,7 @@ function defaultResolveFile({ name, extname, tag, path: groupPath }, context) {
|
|
|
1311
1314
|
tag,
|
|
1312
1315
|
path: groupPath
|
|
1313
1316
|
}, context);
|
|
1314
|
-
return
|
|
1317
|
+
return _kubb_ast_factory.createFile({
|
|
1315
1318
|
path: filePath,
|
|
1316
1319
|
baseName: node_path.default.basename(filePath),
|
|
1317
1320
|
meta: { pluginName: this.pluginName },
|
|
@@ -1649,7 +1652,7 @@ var KubbDriver = class {
|
|
|
1649
1652
|
/**
|
|
1650
1653
|
* Parses the adapter source into `this.inputNode`. Idempotent, so repeated calls from
|
|
1651
1654
|
* `run` do not re-parse. Adapters with `stream()` are used directly.
|
|
1652
|
-
* Adapters with only `parse()` are wrapped via `
|
|
1655
|
+
* Adapters with only `parse()` are wrapped via `factory.createInput({ stream: true })` so the dispatch loop
|
|
1653
1656
|
* stays stream-only.
|
|
1654
1657
|
*/
|
|
1655
1658
|
async #parseInput() {
|
|
@@ -1661,7 +1664,12 @@ var KubbDriver = class {
|
|
|
1661
1664
|
return;
|
|
1662
1665
|
}
|
|
1663
1666
|
const parsed = await adapter.parse(source);
|
|
1664
|
-
this.inputNode =
|
|
1667
|
+
this.inputNode = _kubb_ast_factory.createInput({
|
|
1668
|
+
stream: true,
|
|
1669
|
+
schemas: arrayToAsyncIterable(parsed.schemas),
|
|
1670
|
+
operations: arrayToAsyncIterable(parsed.operations),
|
|
1671
|
+
meta: parsed.meta
|
|
1672
|
+
});
|
|
1665
1673
|
}
|
|
1666
1674
|
/**
|
|
1667
1675
|
* Registers a hook-style plugin's lifecycle handlers on the shared `AsyncEventEmitter`.
|
|
@@ -1705,7 +1713,7 @@ var KubbDriver = class {
|
|
|
1705
1713
|
}
|
|
1706
1714
|
},
|
|
1707
1715
|
injectFile: (userFileNode) => {
|
|
1708
|
-
this.fileManager.add(
|
|
1716
|
+
this.fileManager.add(_kubb_ast_factory.createFile(userFileNode));
|
|
1709
1717
|
}
|
|
1710
1718
|
};
|
|
1711
1719
|
return hooks["kubb:plugin:setup"](pluginCtx);
|
|
@@ -1998,7 +2006,7 @@ var KubbDriver = class {
|
|
|
1998
2006
|
}) !== null) includedOpsByState.get(state)?.push(operation);
|
|
1999
2007
|
}
|
|
2000
2008
|
for (const state of pruningStates) {
|
|
2001
|
-
state.allowedSchemaNames = (0,
|
|
2009
|
+
state.allowedSchemaNames = (0, _kubb_ast_utils.collectUsedSchemaNames)(includedOpsByState.get(state) ?? [], schemasBuffer);
|
|
2002
2010
|
includedOpsByState.delete(state);
|
|
2003
2011
|
}
|
|
2004
2012
|
}
|
|
@@ -2863,14 +2871,15 @@ function defineGenerator(generator) {
|
|
|
2863
2871
|
*
|
|
2864
2872
|
* @example
|
|
2865
2873
|
* ```ts
|
|
2866
|
-
* import { defineParser
|
|
2874
|
+
* import { defineParser } from '@kubb/core'
|
|
2875
|
+
* import { extractStringsFromNodes } from '@kubb/ast/utils'
|
|
2867
2876
|
*
|
|
2868
2877
|
* export const jsonParser = defineParser({
|
|
2869
2878
|
* name: 'json',
|
|
2870
2879
|
* extNames: ['.json'],
|
|
2871
2880
|
* parse(file) {
|
|
2872
2881
|
* return file.sources
|
|
2873
|
-
* .map((source) =>
|
|
2882
|
+
* .map((source) => extractStringsFromNodes(source.nodes ?? []))
|
|
2874
2883
|
* .join('\n')
|
|
2875
2884
|
* },
|
|
2876
2885
|
* print(...nodes) {
|