@kubb/core 5.13.0 → 5.14.0
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/{Hookable-BR69O7aj.js → Hookable-CvvyqvN3.js} +39 -6
- package/dist/Hookable-CvvyqvN3.js.map +1 -0
- package/dist/{createAdapter-BNUEQcw9.d.ts → createAdapter-CpL5uM0P.d.ts} +17 -2
- package/dist/index.cjs +38 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/package.json +2 -2
- package/dist/Hookable-BR69O7aj.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Enforce, FileNode, HttpMethod, ImportNode, InputMeta, InputNode, Macro, Node, OperationNode, SchemaNode, UserFileNode } from "@kubb/ast";
|
|
1
|
+
import { Enforce, FileNode, HttpMethod, ImportNode, InlineLanguage, InputMeta, InputNode, Macro, Node, OperationNode, SchemaNode, UserFileNode } from "@kubb/ast";
|
|
2
2
|
//#region ../../internals/utils/src/promise.d.ts
|
|
3
3
|
/** A value that may already be resolved or still pending.
|
|
4
4
|
*
|
|
@@ -59,6 +59,10 @@ type Parser<TMeta extends object = object, TNode = unknown, TOptions extends obj
|
|
|
59
59
|
* back to the parser as `FileNode.sources`.
|
|
60
60
|
*/
|
|
61
61
|
print(...nodes: Array<TNode>): string;
|
|
62
|
+
/**
|
|
63
|
+
* How this language finds and replaces names so its files can absorb inline sources. Omit it when there is no support.
|
|
64
|
+
*/
|
|
65
|
+
inline?: InlineLanguage;
|
|
62
66
|
};
|
|
63
67
|
/**
|
|
64
68
|
* Takes the user's options and returns the parser methods.
|
|
@@ -276,6 +280,12 @@ declare const diagnosticCatalog: {
|
|
|
276
280
|
readonly cause: 'Two generated modules export the same name, so the barrel cannot re-export both.';
|
|
277
281
|
readonly fix: 'Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names.';
|
|
278
282
|
};
|
|
283
|
+
readonly inlineFailed: {
|
|
284
|
+
readonly code: 'KUBB_INLINE_FAILED';
|
|
285
|
+
readonly title: 'Inline definition failed';
|
|
286
|
+
readonly cause: 'A file imports a name from a file whose sources are all inline, and that name could not be inlined.';
|
|
287
|
+
readonly fix: 'Give every name the file imports an inline definition, register a parser with inline support for its extension, or stop marking the source as inline.';
|
|
288
|
+
};
|
|
279
289
|
readonly internalError: {
|
|
280
290
|
readonly code: 'KUBB_INTERNAL_ERROR';
|
|
281
291
|
readonly title: 'Internal error';
|
|
@@ -854,6 +864,10 @@ declare class FileManager {
|
|
|
854
864
|
*/
|
|
855
865
|
pointer?: string;
|
|
856
866
|
}): Promise<void>;
|
|
867
|
+
/**
|
|
868
|
+
* Removes the files at `paths`, so they are neither listed nor written.
|
|
869
|
+
*/
|
|
870
|
+
delete(...paths: Array<string>): void;
|
|
857
871
|
/**
|
|
858
872
|
* Releases all stored files. Called by the core after `kubb:build:end`.
|
|
859
873
|
*/
|
|
@@ -1862,6 +1876,7 @@ declare class Diagnostics {
|
|
|
1862
1876
|
readonly formatFailed: "KUBB_FORMAT_FAILED";
|
|
1863
1877
|
readonly lintFailed: "KUBB_LINT_FAILED";
|
|
1864
1878
|
readonly barrelDuplicateExport: "KUBB_BARREL_DUPLICATE_EXPORT";
|
|
1879
|
+
readonly inlineFailed: "KUBB_INLINE_FAILED";
|
|
1865
1880
|
readonly internalError: "KUBB_INTERNAL_ERROR";
|
|
1866
1881
|
readonly performance: "KUBB_PERFORMANCE";
|
|
1867
1882
|
readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
|
|
@@ -3232,4 +3247,4 @@ type AdapterFactory<T extends AdapterFactoryOptions = AdapterFactoryOptions> = E
|
|
|
3232
3247
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(definition: AdapterDefinition<T>): AdapterFactory<T>;
|
|
3233
3248
|
//#endregion
|
|
3234
3249
|
export { NodeCache as $, ReporterContext as $t, PluginFactory as A, KubbInfoContext as At, ResolveImportsOptions as B, RunHookOptions as Bt, NormalizedPlugin as C, KubbGenerationEndContext as Ct, Override as D, KubbHookLineContext as Dt, OutputOptions as E, KubbHookEndContext as Et, definePlugin as F, KubbWarnContext as Ft, ResolverFile as G, createOutputManifest as Gt, ResolvePathOptions as H, KubbDriver as Ht, BannerMeta as I, PossibleConfig as It, ResolverPatch as J, createRenderer as Jt, ResolverFileParams as K, Renderer as Kt, ResolveBannerContext as L, PostGenerateCommand as Lt, PluginType as M, KubbMessageContext as Mt, ResolvePluginOptions as N, KubbPluginsEndContext as Nt, Plugin as O, KubbHookStartContext as Ot, assertPluginOption as P, KubbSuccessContext as Pt, defineGenerator as Q, Reporter as Qt, ResolveBannerFile as R, UserConfig as Rt, KubbPluginStartContext as S, KubbFilesProcessingUpdateContext as St, OutputMode as T, KubbGenerationSummaryContext as Tt, Resolver as U, Hookable as Ut, ResolveOptionsContext as V, runHook as Vt, ResolverDefault as W, OutputManifest as Wt, Generator as X, createStorage as Xt, ResolverPathParams as Y, Storage as Yt, GeneratorContext as Z, GenerationResult as Zt, Filter as _, KubbDiagnosticContext as _t, AdapterSource as a, DiagnosticFormatOptions as an, Diagnostics as at, KubbPluginEndContext as b, KubbFilesProcessingEndContext as bt, ExtensionDependency as c, ParserDefinition as cn, ProblemDiagnostic as ct, ExtensionKind as d, CLIOptions as dt, ReporterName as en, Diagnostic as et, ExtensionMeta as f, Config as ft, Exclude$1 as g, KubbBuildStartContext as gt, resolveMeta as h, KubbBuildEndContext as ht, AdapterFactoryOptions as i, logLevel as in, DiagnosticSeverity as it, PluginName as j, KubbLifecycleStartContext as jt, PluginDefinition as k, KubbHooks as kt, ExtensionDependencyRecord as l, ParserFactory as ln, UpdateDiagnostic as lt, defineExtension as m, Input as mt, AdapterDefinition as n, UserReporter as nn, DiagnosticKind as nt, createAdapter as o, SerializedDiagnostic as on, PerformanceDiagnostic as ot, checkCompatibility as p, FilesContext as pt, ResolverFilePathParams as q, RendererFactory as qt, AdapterFactory as r, createReporter as rn, DiagnosticLocation as rt, ExtensionDependencies as s, Parser as sn, ProblemCode as st, Adapter as t, ReporterPluginFiles as tn, DiagnosticDoc as tt, ExtensionFactory as u, defineParser as un, BuildOutput as ut, Group as v, KubbErrorContext as vt, Output as w, KubbGenerationStartContext as wt, KubbPluginSetupContext as x, KubbFilesProcessingStartContext as xt, Include as y, KubbFileProcessingUpdate as yt, ResolveFileOptions as z, HookResult as zt };
|
|
3235
|
-
//# sourceMappingURL=createAdapter-
|
|
3250
|
+
//# sourceMappingURL=createAdapter-CpL5uM0P.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ let node_readline = require("node:readline");
|
|
|
42
42
|
let node_url = require("node:url");
|
|
43
43
|
let node_module = require("node:module");
|
|
44
44
|
//#region package.json
|
|
45
|
-
var version = "5.
|
|
45
|
+
var version = "5.14.0";
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region ../../internals/utils/src/casing.ts
|
|
48
48
|
/**
|
|
@@ -704,6 +704,12 @@ const diagnosticCatalog = {
|
|
|
704
704
|
cause: "Two generated modules export the same name, so the barrel cannot re-export both.",
|
|
705
705
|
fix: "Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names."
|
|
706
706
|
},
|
|
707
|
+
inlineFailed: {
|
|
708
|
+
code: "KUBB_INLINE_FAILED",
|
|
709
|
+
title: "Inline definition failed",
|
|
710
|
+
cause: "A file imports a name from a file whose sources are all inline, and that name could not be inlined.",
|
|
711
|
+
fix: "Give every name the file imports an inline definition, register a parser with inline support for its extension, or stop marking the source as inline."
|
|
712
|
+
},
|
|
707
713
|
internalError: {
|
|
708
714
|
code: "KUBB_INTERNAL_ERROR",
|
|
709
715
|
title: "Internal error",
|
|
@@ -1164,7 +1170,7 @@ function resolveMeta(extension) {
|
|
|
1164
1170
|
function checkCompatibility(meta) {
|
|
1165
1171
|
const checks = [{
|
|
1166
1172
|
target: "Kubb",
|
|
1167
|
-
range: meta.compatibility?.kubb,
|
|
1173
|
+
range: version.startsWith("0.0.0-") ? void 0 : meta.compatibility?.kubb,
|
|
1168
1174
|
version
|
|
1169
1175
|
}, {
|
|
1170
1176
|
target: "Node.js",
|
|
@@ -1922,7 +1928,7 @@ var Resolver = class Resolver {
|
|
|
1922
1928
|
return null;
|
|
1923
1929
|
}
|
|
1924
1930
|
static #computeOptions(node, { options, exclude = [], include, override = [] }) {
|
|
1925
|
-
if (node.kind ===
|
|
1931
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.operation) {
|
|
1926
1932
|
if (exclude.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
|
|
1927
1933
|
if (include && !include.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
|
|
1928
1934
|
return {
|
|
@@ -1930,7 +1936,7 @@ var Resolver = class Resolver {
|
|
|
1930
1936
|
...override.find((filter) => Resolver.#matchesOperation(node, filter))?.options
|
|
1931
1937
|
};
|
|
1932
1938
|
}
|
|
1933
|
-
if (node.kind ===
|
|
1939
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.schema) {
|
|
1934
1940
|
if (exclude.some((filter) => Resolver.#matchesSchema(node, filter) === true)) return null;
|
|
1935
1941
|
if (include) {
|
|
1936
1942
|
const applicable = include.map((filter) => Resolver.#matchesSchema(node, filter)).filter((result) => result !== null);
|
|
@@ -2400,6 +2406,16 @@ var FileManager = class {
|
|
|
2400
2406
|
return resolved;
|
|
2401
2407
|
}
|
|
2402
2408
|
/**
|
|
2409
|
+
* Removes the files at `paths`, so they are neither listed nor written.
|
|
2410
|
+
*/
|
|
2411
|
+
delete(...paths) {
|
|
2412
|
+
for (const path of paths) {
|
|
2413
|
+
this.#cache.delete(path);
|
|
2414
|
+
this.#pending.delete(path);
|
|
2415
|
+
}
|
|
2416
|
+
if (paths.length > 0) this.#sorted = null;
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2403
2419
|
* Releases all stored files. Called by the core after `kubb:build:end`.
|
|
2404
2420
|
*/
|
|
2405
2421
|
dispose() {
|
|
@@ -2560,7 +2576,7 @@ function assertPluginEntry(entry, index) {
|
|
|
2560
2576
|
* pointer into the input.
|
|
2561
2577
|
*/
|
|
2562
2578
|
function getCrashSite(node) {
|
|
2563
|
-
if (node.kind ===
|
|
2579
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.schema) return {
|
|
2564
2580
|
label: node.name ? `schema "${node.name}"` : "an inline schema",
|
|
2565
2581
|
location: node.pointer ? {
|
|
2566
2582
|
kind: "schema",
|
|
@@ -2850,6 +2866,7 @@ var KubbDriver = class {
|
|
|
2850
2866
|
});
|
|
2851
2867
|
}
|
|
2852
2868
|
diagnostics.push(...await this.#runGenerators(generatorPlugins));
|
|
2869
|
+
this.#inlineFiles(parsersMap);
|
|
2853
2870
|
await hooks.callHook("kubb:plugins:end", this.#withFiles({ config }));
|
|
2854
2871
|
if (this.options.cleanPath) await config.storage.empty(this.options.cleanPath);
|
|
2855
2872
|
await fileManager.write(fileManager.files, {
|
|
@@ -2875,6 +2892,22 @@ var KubbDriver = class {
|
|
|
2875
2892
|
});
|
|
2876
2893
|
}
|
|
2877
2894
|
/**
|
|
2895
|
+
* Moves inline sources into the files that import them and drops the virtual files, before barrels
|
|
2896
|
+
* (`kubb:plugins:end`) and the write see them.
|
|
2897
|
+
*/
|
|
2898
|
+
#inlineFiles(parsers) {
|
|
2899
|
+
const { files, virtualPaths, problems } = _kubb_ast.ast.inlineFiles(this.fileManager.files, { language: (file) => parsers.get(file.extname)?.inline });
|
|
2900
|
+
if (virtualPaths.length === 0) return;
|
|
2901
|
+
this.fileManager.add(...files);
|
|
2902
|
+
this.fileManager.delete(...virtualPaths);
|
|
2903
|
+
if (problems.length > 0) Diagnostics.report({
|
|
2904
|
+
code: Diagnostics.code.inlineFailed,
|
|
2905
|
+
severity: "error",
|
|
2906
|
+
message: problems.map(({ path, message }) => `${path}: ${message}`).join("\n"),
|
|
2907
|
+
help: "Give every name the file imports an inline definition, register a parser with inline support for its extension, or stop marking the source as inline."
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2878
2911
|
* Widens `extra` with the files present at emit time and a bound `upsertFile`, the shape every
|
|
2879
2912
|
* file-carrying hook context shares. Building it here in one place keeps the `files` and
|
|
2880
2913
|
* `upsertFile` keys from being dropped by a stray spread at the call site.
|