@kubb/core 5.13.1 → 5.14.1
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-CNMSwKgf.js → Hookable-3xDhh0Fc.js} +44 -5
- package/dist/Hookable-3xDhh0Fc.js.map +1 -0
- package/dist/{createAdapter-BNUEQcw9.d.ts → createAdapter-DwnjwKN0.d.ts} +24 -2
- package/dist/index.cjs +43 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -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-CNMSwKgf.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.
|
|
@@ -222,6 +226,12 @@ declare const diagnosticCatalog: {
|
|
|
222
226
|
readonly cause: 'A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.';
|
|
223
227
|
readonly fix: 'Use a format Kubb supports, or handle the custom format with a parser or plugin.';
|
|
224
228
|
};
|
|
229
|
+
readonly aliasCycle: {
|
|
230
|
+
readonly code: 'KUBB_ALIAS_CYCLE';
|
|
231
|
+
readonly title: 'Alias cycle';
|
|
232
|
+
readonly cause: 'Schemas that only `$ref` each other form a loop, so none of them has a shape to generate. Kubb resolves them to `unknown`.';
|
|
233
|
+
readonly fix: 'Break the loop by giving one of the schemas a real definition, or remove the `$ref` that closes it.';
|
|
234
|
+
};
|
|
225
235
|
readonly deprecated: {
|
|
226
236
|
readonly code: 'KUBB_DEPRECATED';
|
|
227
237
|
readonly title: 'Deprecated';
|
|
@@ -276,6 +286,12 @@ declare const diagnosticCatalog: {
|
|
|
276
286
|
readonly cause: 'Two generated modules export the same name, so the barrel cannot re-export both.';
|
|
277
287
|
readonly fix: 'Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names.';
|
|
278
288
|
};
|
|
289
|
+
readonly inlineFailed: {
|
|
290
|
+
readonly code: 'KUBB_INLINE_FAILED';
|
|
291
|
+
readonly title: 'Inline definition failed';
|
|
292
|
+
readonly cause: 'A file imports a name from a file whose sources are all inline, and that name could not be inlined.';
|
|
293
|
+
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.';
|
|
294
|
+
};
|
|
279
295
|
readonly internalError: {
|
|
280
296
|
readonly code: 'KUBB_INTERNAL_ERROR';
|
|
281
297
|
readonly title: 'Internal error';
|
|
@@ -854,6 +870,10 @@ declare class FileManager {
|
|
|
854
870
|
*/
|
|
855
871
|
pointer?: string;
|
|
856
872
|
}): Promise<void>;
|
|
873
|
+
/**
|
|
874
|
+
* Removes the files at `paths`, so they are neither listed nor written.
|
|
875
|
+
*/
|
|
876
|
+
delete(...paths: Array<string>): void;
|
|
857
877
|
/**
|
|
858
878
|
* Releases all stored files. Called by the core after `kubb:build:end`.
|
|
859
879
|
*/
|
|
@@ -1853,6 +1873,7 @@ declare class Diagnostics {
|
|
|
1853
1873
|
readonly pluginInfo: "KUBB_PLUGIN_INFO";
|
|
1854
1874
|
readonly noContext: "KUBB_NO_CONTEXT";
|
|
1855
1875
|
readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
|
|
1876
|
+
readonly aliasCycle: "KUBB_ALIAS_CYCLE";
|
|
1856
1877
|
readonly deprecated: "KUBB_DEPRECATED";
|
|
1857
1878
|
readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
|
|
1858
1879
|
readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
|
|
@@ -1862,6 +1883,7 @@ declare class Diagnostics {
|
|
|
1862
1883
|
readonly formatFailed: "KUBB_FORMAT_FAILED";
|
|
1863
1884
|
readonly lintFailed: "KUBB_LINT_FAILED";
|
|
1864
1885
|
readonly barrelDuplicateExport: "KUBB_BARREL_DUPLICATE_EXPORT";
|
|
1886
|
+
readonly inlineFailed: "KUBB_INLINE_FAILED";
|
|
1865
1887
|
readonly internalError: "KUBB_INTERNAL_ERROR";
|
|
1866
1888
|
readonly performance: "KUBB_PERFORMANCE";
|
|
1867
1889
|
readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
|
|
@@ -3232,4 +3254,4 @@ type AdapterFactory<T extends AdapterFactoryOptions = AdapterFactoryOptions> = E
|
|
|
3232
3254
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(definition: AdapterDefinition<T>): AdapterFactory<T>;
|
|
3233
3255
|
//#endregion
|
|
3234
3256
|
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-
|
|
3257
|
+
//# sourceMappingURL=createAdapter-DwnjwKN0.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.1";
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region ../../internals/utils/src/casing.ts
|
|
48
48
|
/**
|
|
@@ -650,6 +650,12 @@ const diagnosticCatalog = {
|
|
|
650
650
|
cause: "A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.",
|
|
651
651
|
fix: "Use a format Kubb supports, or handle the custom format with a parser or plugin."
|
|
652
652
|
},
|
|
653
|
+
aliasCycle: {
|
|
654
|
+
code: "KUBB_ALIAS_CYCLE",
|
|
655
|
+
title: "Alias cycle",
|
|
656
|
+
cause: "Schemas that only `$ref` each other form a loop, so none of them has a shape to generate. Kubb resolves them to `unknown`.",
|
|
657
|
+
fix: "Break the loop by giving one of the schemas a real definition, or remove the `$ref` that closes it."
|
|
658
|
+
},
|
|
653
659
|
deprecated: {
|
|
654
660
|
code: "KUBB_DEPRECATED",
|
|
655
661
|
title: "Deprecated",
|
|
@@ -704,6 +710,12 @@ const diagnosticCatalog = {
|
|
|
704
710
|
cause: "Two generated modules export the same name, so the barrel cannot re-export both.",
|
|
705
711
|
fix: "Rename one of the colliding declarations, or configure the plugin resolver to produce distinct names."
|
|
706
712
|
},
|
|
713
|
+
inlineFailed: {
|
|
714
|
+
code: "KUBB_INLINE_FAILED",
|
|
715
|
+
title: "Inline definition failed",
|
|
716
|
+
cause: "A file imports a name from a file whose sources are all inline, and that name could not be inlined.",
|
|
717
|
+
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."
|
|
718
|
+
},
|
|
707
719
|
internalError: {
|
|
708
720
|
code: "KUBB_INTERNAL_ERROR",
|
|
709
721
|
title: "Internal error",
|
|
@@ -1922,7 +1934,7 @@ var Resolver = class Resolver {
|
|
|
1922
1934
|
return null;
|
|
1923
1935
|
}
|
|
1924
1936
|
static #computeOptions(node, { options, exclude = [], include, override = [] }) {
|
|
1925
|
-
if (node.kind ===
|
|
1937
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.operation) {
|
|
1926
1938
|
if (exclude.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
|
|
1927
1939
|
if (include && !include.some((filter) => Resolver.#matchesOperation(node, filter))) return null;
|
|
1928
1940
|
return {
|
|
@@ -1930,7 +1942,7 @@ var Resolver = class Resolver {
|
|
|
1930
1942
|
...override.find((filter) => Resolver.#matchesOperation(node, filter))?.options
|
|
1931
1943
|
};
|
|
1932
1944
|
}
|
|
1933
|
-
if (node.kind ===
|
|
1945
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.schema) {
|
|
1934
1946
|
if (exclude.some((filter) => Resolver.#matchesSchema(node, filter) === true)) return null;
|
|
1935
1947
|
if (include) {
|
|
1936
1948
|
const applicable = include.map((filter) => Resolver.#matchesSchema(node, filter)).filter((result) => result !== null);
|
|
@@ -2400,6 +2412,16 @@ var FileManager = class {
|
|
|
2400
2412
|
return resolved;
|
|
2401
2413
|
}
|
|
2402
2414
|
/**
|
|
2415
|
+
* Removes the files at `paths`, so they are neither listed nor written.
|
|
2416
|
+
*/
|
|
2417
|
+
delete(...paths) {
|
|
2418
|
+
for (const path of paths) {
|
|
2419
|
+
this.#cache.delete(path);
|
|
2420
|
+
this.#pending.delete(path);
|
|
2421
|
+
}
|
|
2422
|
+
if (paths.length > 0) this.#sorted = null;
|
|
2423
|
+
}
|
|
2424
|
+
/**
|
|
2403
2425
|
* Releases all stored files. Called by the core after `kubb:build:end`.
|
|
2404
2426
|
*/
|
|
2405
2427
|
dispose() {
|
|
@@ -2560,7 +2582,7 @@ function assertPluginEntry(entry, index) {
|
|
|
2560
2582
|
* pointer into the input.
|
|
2561
2583
|
*/
|
|
2562
2584
|
function getCrashSite(node) {
|
|
2563
|
-
if (node.kind ===
|
|
2585
|
+
if (node.kind === _kubb_ast.ast.nodeKinds.schema) return {
|
|
2564
2586
|
label: node.name ? `schema "${node.name}"` : "an inline schema",
|
|
2565
2587
|
location: node.pointer ? {
|
|
2566
2588
|
kind: "schema",
|
|
@@ -2850,6 +2872,7 @@ var KubbDriver = class {
|
|
|
2850
2872
|
});
|
|
2851
2873
|
}
|
|
2852
2874
|
diagnostics.push(...await this.#runGenerators(generatorPlugins));
|
|
2875
|
+
this.#inlineFiles(parsersMap);
|
|
2853
2876
|
await hooks.callHook("kubb:plugins:end", this.#withFiles({ config }));
|
|
2854
2877
|
if (this.options.cleanPath) await config.storage.empty(this.options.cleanPath);
|
|
2855
2878
|
await fileManager.write(fileManager.files, {
|
|
@@ -2875,6 +2898,22 @@ var KubbDriver = class {
|
|
|
2875
2898
|
});
|
|
2876
2899
|
}
|
|
2877
2900
|
/**
|
|
2901
|
+
* Moves inline sources into the files that import them and drops the virtual files, before barrels
|
|
2902
|
+
* (`kubb:plugins:end`) and the write see them.
|
|
2903
|
+
*/
|
|
2904
|
+
#inlineFiles(parsers) {
|
|
2905
|
+
const { files, virtualPaths, problems } = _kubb_ast.ast.inlineFiles(this.fileManager.files, { language: (file) => parsers.get(file.extname)?.inline });
|
|
2906
|
+
if (virtualPaths.length === 0) return;
|
|
2907
|
+
this.fileManager.add(...files);
|
|
2908
|
+
this.fileManager.delete(...virtualPaths);
|
|
2909
|
+
if (problems.length > 0) Diagnostics.report({
|
|
2910
|
+
code: Diagnostics.code.inlineFailed,
|
|
2911
|
+
severity: "error",
|
|
2912
|
+
message: problems.map(({ path, message }) => `${path}: ${message}`).join("\n"),
|
|
2913
|
+
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."
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2878
2917
|
* Widens `extra` with the files present at emit time and a bound `upsertFile`, the shape every
|
|
2879
2918
|
* file-carrying hook context shares. Building it here in one place keeps the `files` and
|
|
2880
2919
|
* `upsertFile` keys from being dropped by a stray spread at the call site.
|