@kubb/core 5.8.4 → 5.9.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/{KubbDriver-Iv2StSPa.cjs → KubbDriver-Cd01FAa0.cjs} +110 -97
- package/dist/KubbDriver-Cd01FAa0.cjs.map +1 -0
- package/dist/{KubbDriver-DbOEJvzz.js → KubbDriver-GBBjs4Pb.js} +111 -98
- package/dist/KubbDriver-GBBjs4Pb.js.map +1 -0
- package/dist/{createAdapter-BpJYvJTw.d.ts → createAdapter-DfbfcqcJ.d.ts} +43 -33
- package/dist/index.cjs +13 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -12
- package/dist/index.js +13 -79
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +4 -5
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +7 -7
- package/dist/mocks.js +4 -5
- package/dist/mocks.js.map +1 -1
- package/package.json +2 -2
- package/schemas/kubb-extension.json +5 -0
- package/dist/KubbDriver-DbOEJvzz.js.map +0 -1
- package/dist/KubbDriver-Iv2StSPa.cjs.map +0 -1
|
@@ -229,6 +229,10 @@ declare const diagnosticCode: {
|
|
|
229
229
|
* A plugin threw while generating.
|
|
230
230
|
*/
|
|
231
231
|
readonly pluginFailed: "KUBB_PLUGIN_FAILED";
|
|
232
|
+
/** An adapter threw while parsing the input. */
|
|
233
|
+
readonly adapterFailed: "KUBB_ADAPTER_FAILED";
|
|
234
|
+
/** A parser threw while printing a generated file. */
|
|
235
|
+
readonly parserFailed: "KUBB_PARSER_FAILED";
|
|
232
236
|
/**
|
|
233
237
|
* A plugin reported a non-fatal warning through `ctx.warn`.
|
|
234
238
|
*/
|
|
@@ -481,6 +485,8 @@ type ProblemDiagnostic = {
|
|
|
481
485
|
* Name of the plugin or subsystem that produced the diagnostic.
|
|
482
486
|
*/
|
|
483
487
|
plugin?: string;
|
|
488
|
+
/** Issue tracker URL of the extension that crashed, from its `meta.issues`. */
|
|
489
|
+
issues?: string;
|
|
484
490
|
/**
|
|
485
491
|
* The underlying error, when the diagnostic wraps a thrown one.
|
|
486
492
|
*/
|
|
@@ -541,6 +547,7 @@ type SerializedDiagnostic = {
|
|
|
541
547
|
location?: DiagnosticLocation;
|
|
542
548
|
help?: string;
|
|
543
549
|
plugin?: string;
|
|
550
|
+
issues?: string;
|
|
544
551
|
/**
|
|
545
552
|
* The kubb.dev docs link for the code, omitted for the unknown fallback.
|
|
546
553
|
*/
|
|
@@ -576,6 +583,8 @@ declare class Diagnostics {
|
|
|
576
583
|
readonly missingDependency: "KUBB_MISSING_DEPENDENCY";
|
|
577
584
|
readonly incompatibleDependency: "KUBB_INCOMPATIBLE_DEPENDENCY";
|
|
578
585
|
readonly pluginFailed: "KUBB_PLUGIN_FAILED";
|
|
586
|
+
readonly adapterFailed: "KUBB_ADAPTER_FAILED";
|
|
587
|
+
readonly parserFailed: "KUBB_PARSER_FAILED";
|
|
579
588
|
readonly pluginWarning: "KUBB_PLUGIN_WARNING";
|
|
580
589
|
readonly pluginInfo: "KUBB_PLUGIN_INFO";
|
|
581
590
|
readonly noContext: "KUBB_NO_CONTEXT";
|
|
@@ -657,6 +666,16 @@ declare class Diagnostics {
|
|
|
657
666
|
* keeps its structured data, and anything else becomes a `KUBB_UNKNOWN` error.
|
|
658
667
|
*/
|
|
659
668
|
static from(error: unknown): ProblemDiagnostic;
|
|
669
|
+
/**
|
|
670
|
+
* Coerces an error thrown by a plugin, adapter, or parser into a diagnostic attributed to it.
|
|
671
|
+
* A structured {@link Diagnostics.Error} keeps its code. Any other error is a crash: it gets the
|
|
672
|
+
* kind's `*_FAILED` code and the extension's `meta.issues` link, so the user reports it to the
|
|
673
|
+
* extension's maintainers instead of to Kubb.
|
|
674
|
+
*/
|
|
675
|
+
static fromExtension(error: unknown, { kind, extension }: {
|
|
676
|
+
kind: ExtensionKind;
|
|
677
|
+
extension: ExtensionNamed;
|
|
678
|
+
}): ProblemDiagnostic;
|
|
660
679
|
/**
|
|
661
680
|
* Builds a per-plugin performance record. Reporters sum these into the run total.
|
|
662
681
|
*/
|
|
@@ -715,7 +734,7 @@ declare class Diagnostics {
|
|
|
715
734
|
/**
|
|
716
735
|
* Renders a {@link Diagnostic} for terminal output as its parts: the `headline`
|
|
717
736
|
* (`[CODE] plugin: message`, with the code in the severity color) and the indented `details`
|
|
718
|
-
* rows (`at:` pointer, `fix:` help, `see:` docs link).
|
|
737
|
+
* rows (`at:` pointer, `fix:` help, `see:` docs link, `report:` issue tracker).
|
|
719
738
|
*
|
|
720
739
|
* Hosts compose these to fit their gutter: a clack logger passes `[headline, ...details]` as the
|
|
721
740
|
* message with no gutter symbol, while plain text outputs use {@link Diagnostics.formatLines}.
|
|
@@ -1111,8 +1130,6 @@ declare class KubbDriver {
|
|
|
1111
1130
|
* plugins can configure generators, resolvers, macros, and options before `buildStart`.
|
|
1112
1131
|
*/
|
|
1113
1132
|
setupHooks(): Promise<void>;
|
|
1114
|
-
/** `true` once `addGenerator()` in `kubb:plugin:setup` registered a generator for the plugin. */
|
|
1115
|
-
hasHookGenerators(pluginName: string): boolean;
|
|
1116
1133
|
/**
|
|
1117
1134
|
* Runs the full plugin pipeline. Returns the diagnostics collected so far even
|
|
1118
1135
|
* when an outer hook throws, since the orchestrator preserves partial state by capturing
|
|
@@ -1122,11 +1139,6 @@ declare class KubbDriver {
|
|
|
1122
1139
|
run(): Promise<{
|
|
1123
1140
|
diagnostics: Array<Diagnostic>;
|
|
1124
1141
|
}>;
|
|
1125
|
-
/** Stores whatever a generator method or `kubb:generate:*` hook returned, see {@link FileManager.dispatch}. */
|
|
1126
|
-
dispatch<TElement = unknown>(params: {
|
|
1127
|
-
result: TElement | Array<FileNode> | undefined | null;
|
|
1128
|
-
renderer?: RendererFactory<TElement> | null;
|
|
1129
|
-
}): Promise<void>;
|
|
1130
1142
|
/**
|
|
1131
1143
|
* Removes every listener the driver added. Listeners attached directly to `hooks` from outside
|
|
1132
1144
|
* the driver survive. Called at the end of a build to prevent leaks across repeated builds.
|
|
@@ -1137,7 +1149,7 @@ declare class KubbDriver {
|
|
|
1137
1149
|
[Symbol.dispose](): void;
|
|
1138
1150
|
/** Reads `plugin.resolver`, falling back to a fresh default for a name that is not a registered plugin. */
|
|
1139
1151
|
getResolver<TName extends PluginName>(pluginName: TName): ResolvePluginOptions<TName>['resolver'];
|
|
1140
|
-
getContext<TOptions extends
|
|
1152
|
+
getContext<TOptions extends PluginType>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options' | 'cache'>;
|
|
1141
1153
|
getPlugin<TName extends PluginName>(pluginName: TName): Plugin<ResolvePluginOptions<TName>> | undefined;
|
|
1142
1154
|
/**
|
|
1143
1155
|
* Like `getPlugin` but throws a descriptive error when the plugin is not found.
|
|
@@ -1454,7 +1466,7 @@ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'par
|
|
|
1454
1466
|
declare global {
|
|
1455
1467
|
namespace Kubb {
|
|
1456
1468
|
/**
|
|
1457
|
-
* Registry that maps plugin names to their `
|
|
1469
|
+
* Registry that maps plugin names to their `PluginType`.
|
|
1458
1470
|
* Augment this interface in each plugin's `types.ts` to enable automatic
|
|
1459
1471
|
* typing for `getPlugin` and `requirePlugin`.
|
|
1460
1472
|
*
|
|
@@ -1893,7 +1905,7 @@ type NodeCache = {
|
|
|
1893
1905
|
* without a null check. `ctx.options` carries the per-node options after exclude/include/override
|
|
1894
1906
|
* filtering for `schema` and `operation`, or the plugin-level options for `operations`.
|
|
1895
1907
|
*/
|
|
1896
|
-
type GeneratorContext<TOptions extends
|
|
1908
|
+
type GeneratorContext<TOptions extends PluginType = PluginType> = {
|
|
1897
1909
|
/**
|
|
1898
1910
|
* Stops cooperative generation work at the next safe checkpoint.
|
|
1899
1911
|
*/
|
|
@@ -2019,7 +2031,7 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
2019
2031
|
* })
|
|
2020
2032
|
* ```
|
|
2021
2033
|
*/
|
|
2022
|
-
type Generator<TOptions extends
|
|
2034
|
+
type Generator<TOptions extends PluginType = PluginType, TElement = unknown> = {
|
|
2023
2035
|
/**
|
|
2024
2036
|
* Used in diagnostic messages and debug output.
|
|
2025
2037
|
*/
|
|
@@ -2088,7 +2100,7 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TEl
|
|
|
2088
2100
|
*
|
|
2089
2101
|
* The returned object is the input as-is, but with `this` types preserved so
|
|
2090
2102
|
* `schema`/`operation`/`operations` methods are correctly typed against the
|
|
2091
|
-
* plugin's `
|
|
2103
|
+
* plugin's `PluginType`. Renderer elements and `FileNode[]` returns
|
|
2092
2104
|
* are both handled by the runtime, so pick whichever style fits.
|
|
2093
2105
|
*
|
|
2094
2106
|
* @example JSX-based schema generator
|
|
@@ -2109,7 +2121,7 @@ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TEl
|
|
|
2109
2121
|
* })
|
|
2110
2122
|
* ```
|
|
2111
2123
|
*/
|
|
2112
|
-
declare function defineGenerator<TOptions extends
|
|
2124
|
+
declare function defineGenerator<TOptions extends PluginType = PluginType, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
|
|
2113
2125
|
//#endregion
|
|
2114
2126
|
//#region src/Resolver.d.ts
|
|
2115
2127
|
/**
|
|
@@ -2436,10 +2448,10 @@ type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {
|
|
|
2436
2448
|
*/
|
|
2437
2449
|
type PluginName = LiteralUnion<keyof Kubb.PluginRegistry>;
|
|
2438
2450
|
/**
|
|
2439
|
-
* Resolves a plugin name to its `
|
|
2451
|
+
* Resolves a plugin name to its `PluginType`. A name registered in `Kubb.PluginRegistry`
|
|
2440
2452
|
* maps to its exact factory options, any other string falls back to the generic options.
|
|
2441
2453
|
*/
|
|
2442
|
-
type ResolvePluginOptions<TName> = TName extends keyof Kubb.PluginRegistry ? Kubb.PluginRegistry[TName] :
|
|
2454
|
+
type ResolvePluginOptions<TName> = TName extends keyof Kubb.PluginRegistry ? Kubb.PluginRegistry[TName] : PluginType;
|
|
2443
2455
|
/**
|
|
2444
2456
|
* How a plugin consolidates its generated code into files.
|
|
2445
2457
|
* - `'file'` writes everything into a single file.
|
|
@@ -2574,12 +2586,12 @@ type ByPath = {
|
|
|
2574
2586
|
};
|
|
2575
2587
|
type ByMethod = {
|
|
2576
2588
|
/**
|
|
2577
|
-
* Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`.
|
|
2589
|
+
* Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`.
|
|
2578
2590
|
*/
|
|
2579
2591
|
type: 'method';
|
|
2580
2592
|
/**
|
|
2581
2593
|
* HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
|
|
2582
|
-
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`) or a regex.
|
|
2594
|
+
* `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`, `'QUERY'`) or a regex.
|
|
2583
2595
|
*/
|
|
2584
2596
|
pattern: HttpMethod | RegExp;
|
|
2585
2597
|
};
|
|
@@ -2661,7 +2673,7 @@ type Include = Filter;
|
|
|
2661
2673
|
type Override<TOptions> = Filter & {
|
|
2662
2674
|
options: Omit<Partial<TOptions>, 'override'>;
|
|
2663
2675
|
};
|
|
2664
|
-
type
|
|
2676
|
+
type PluginType<
|
|
2665
2677
|
/**
|
|
2666
2678
|
* Unique plugin name.
|
|
2667
2679
|
*/
|
|
@@ -2684,15 +2696,11 @@ TResolver extends Resolver = Resolver> = {
|
|
|
2684
2696
|
resolvedOptions: TResolvedOptions;
|
|
2685
2697
|
resolver: TResolver;
|
|
2686
2698
|
};
|
|
2687
|
-
/**
|
|
2688
|
-
* Type parameter for the object form of `defineExtension` with `kind: 'plugin'`. Same shape as `PluginFactoryOptions`.
|
|
2689
|
-
*/
|
|
2690
|
-
type PluginType<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions, TResolver extends Resolver = Resolver> = PluginFactoryOptions<TName, TOptions, TResolvedOptions, TResolver>;
|
|
2691
2699
|
/**
|
|
2692
2700
|
* Context passed to a plugin's `kubb:plugin:setup` handler, where it registers generators and
|
|
2693
2701
|
* sets its resolver, transformer, and options.
|
|
2694
2702
|
*/
|
|
2695
|
-
type KubbPluginSetupContext<TFactory extends
|
|
2703
|
+
type KubbPluginSetupContext<TFactory extends PluginType = PluginType> = {
|
|
2696
2704
|
/**
|
|
2697
2705
|
* Register one or more generators dynamically. Generators fire during the AST walk
|
|
2698
2706
|
* (schema/operation/operations) just like generators declared statically on `createPlugin`.
|
|
@@ -2749,7 +2757,7 @@ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactor
|
|
|
2749
2757
|
* A plugin object produced by `defineExtension`. Its lifecycle handlers live under a single
|
|
2750
2758
|
* `hooks` property rather than flat methods.
|
|
2751
2759
|
*/
|
|
2752
|
-
type Plugin<TFactory extends
|
|
2760
|
+
type Plugin<TFactory extends PluginType = PluginType> = ExtensionNamed & {
|
|
2753
2761
|
/**
|
|
2754
2762
|
* Plugins this one builds on. They run first when the config has them. An array only orders
|
|
2755
2763
|
* plugins. A record also fails the run when a required entry is missing or out of range.
|
|
@@ -2784,21 +2792,21 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = Exte
|
|
|
2784
2792
|
/**
|
|
2785
2793
|
* The object passed to `defineExtension` with `kind: 'plugin'`.
|
|
2786
2794
|
*/
|
|
2787
|
-
type PluginDefinition<TFactory extends
|
|
2795
|
+
type PluginDefinition<TFactory extends PluginType = PluginType> = Pick<Plugin<TFactory>, 'dependencies' | 'enforce' | 'setup'> & {
|
|
2788
2796
|
meta: ExtensionMeta<TFactory['name']>;
|
|
2789
2797
|
hooks?: Plugin<TFactory>['hooks'];
|
|
2790
2798
|
};
|
|
2791
2799
|
/**
|
|
2792
2800
|
* The function `defineExtension` returns for a plugin. Call it with user options to get a `Plugin`.
|
|
2793
2801
|
*/
|
|
2794
|
-
type PluginFactory<TFactory extends
|
|
2802
|
+
type PluginFactory<TFactory extends PluginType = PluginType> = ExtensionFactory<'plugin', TFactory['options'], Plugin<TFactory>, TFactory['name']>;
|
|
2795
2803
|
/**
|
|
2796
2804
|
* Normalized plugin after setup, with runtime fields populated. Internal only. Plugins use the
|
|
2797
2805
|
* public `Plugin` type.
|
|
2798
2806
|
*
|
|
2799
2807
|
* @internal
|
|
2800
2808
|
*/
|
|
2801
|
-
type NormalizedPlugin<TOptions extends
|
|
2809
|
+
type NormalizedPlugin<TOptions extends PluginType = PluginType> = Plugin<TOptions> & {
|
|
2802
2810
|
name: string;
|
|
2803
2811
|
meta: ExtensionMeta;
|
|
2804
2812
|
dependencies?: Array<PluginName> | ExtensionDependencyRecord;
|
|
@@ -2827,13 +2835,13 @@ type KubbPluginEndContext = FilesContext & {
|
|
|
2827
2835
|
*
|
|
2828
2836
|
* @deprecated Use `defineExtension` with `kind: 'plugin'` instead.
|
|
2829
2837
|
*/
|
|
2830
|
-
declare function definePlugin<TFactory extends
|
|
2838
|
+
declare function definePlugin<TFactory extends PluginType = PluginType>(definition: PluginDefinition<TFactory>): PluginFactory<TFactory>;
|
|
2831
2839
|
/**
|
|
2832
2840
|
* Wraps a factory function that returns a `Plugin`. Without `meta`, the plugin gets `{ name }`.
|
|
2833
2841
|
*
|
|
2834
2842
|
* @deprecated Pass a definition object with `kind: 'plugin'`, `meta`, and `setup` to `defineExtension` instead. The factory form is removed in the next major.
|
|
2835
2843
|
*/
|
|
2836
|
-
declare function definePlugin<TFactory extends
|
|
2844
|
+
declare function definePlugin<TFactory extends PluginType = PluginType>(factory: (options: TFactory['options']) => Plugin<TFactory>): ((options?: TFactory['options']) => Plugin<TFactory>) & {
|
|
2837
2845
|
kind: 'plugin';
|
|
2838
2846
|
};
|
|
2839
2847
|
//#endregion
|
|
@@ -2876,6 +2884,8 @@ type ExtensionMeta<TName extends string = string> = {
|
|
|
2876
2884
|
node?: string;
|
|
2877
2885
|
};
|
|
2878
2886
|
docs?: string;
|
|
2887
|
+
/** Issue tracker URL. Kubb prints it when the extension crashes, so users report the bug to its maintainers. */
|
|
2888
|
+
issues?: string;
|
|
2879
2889
|
};
|
|
2880
2890
|
/**
|
|
2881
2891
|
* An extension's identity: `meta`, a `name`, or both. `name` is deprecated in favor of `meta.name`.
|
|
@@ -2948,7 +2958,7 @@ declare function defineExtension<T extends AdapterFactoryOptions = AdapterFactor
|
|
|
2948
2958
|
* defineExtension<PluginZod>({ kind: 'plugin', meta: { name: 'plugin-zod' }, setup: (options) => options })
|
|
2949
2959
|
* ```
|
|
2950
2960
|
*/
|
|
2951
|
-
declare function defineExtension<TFactory extends
|
|
2961
|
+
declare function defineExtension<TFactory extends PluginType = PluginType>(definition: {
|
|
2952
2962
|
kind: 'plugin';
|
|
2953
2963
|
} & PluginDefinition<TFactory>): PluginFactory<TFactory>;
|
|
2954
2964
|
//#endregion
|
|
@@ -3074,5 +3084,5 @@ declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryO
|
|
|
3074
3084
|
kind: 'adapter';
|
|
3075
3085
|
};
|
|
3076
3086
|
//#endregion
|
|
3077
|
-
export {
|
|
3078
|
-
//# sourceMappingURL=createAdapter-
|
|
3087
|
+
export { NodeCache as $, SerializedDiagnostic as $t, PluginFactory as A, RunHookOptions as At, ResolveImportsOptions as B, ReporterPluginFiles as Bt, NormalizedPlugin as C, KubbPluginsEndContext as Ct, Override as D, PostGenerateCommand as Dt, OutputOptions as E, PossibleConfig as Et, definePlugin as F, createStorage as Ft, ResolverFile as G, DiagnosticDoc as Gt, ResolvePathOptions as H, createReporter as Ht, BannerMeta as I, GenerationResult as It, ResolverPatch as J, DiagnosticSeverity as Jt, ResolverFileParams as K, DiagnosticKind as Kt, ResolveBannerContext as L, Reporter as Lt, PluginType as M, KubbDriver as Mt, ResolvePluginOptions as N, FileManagerHooks as Nt, Plugin as O, UserConfig as Ot, assertPluginOption as P, Storage as Pt, defineGenerator as Q, ProblemDiagnostic as Qt, ResolveBannerFile as R, ReporterContext as Rt, KubbPluginStartContext as S, KubbMessageContext as St, OutputMode as T, KubbWarnContext as Tt, Resolver as U, logLevel as Ut, ResolveOptionsContext as V, UserReporter as Vt, ResolverDefault as W, Diagnostic as Wt, Generator as X, PerformanceDiagnostic as Xt, ResolverPathParams as Y, Diagnostics as Yt, GeneratorContext as Z, ProblemCode as Zt, Filter as _, KubbHookLineContext as _t, AdapterSource as a, Parser as an, KubbBuildEndContext as at, KubbPluginEndContext as b, KubbInfoContext as bt, ExtensionDependency as c, defineParser as cn, KubbErrorContext as ct, ExtensionKind as d, KubbFilesProcessingStartContext as dt, UpdateDiagnostic as en, BuildOutput as et, ExtensionMeta as f, KubbFilesProcessingUpdateContext as ft, Exclude$1 as g, KubbHookEndContext as gt, resolveMeta as h, KubbGenerationSummaryContext as ht, AdapterFactoryOptions as i, createRenderer as in, Input as it, PluginName as j, runHook as jt, PluginDefinition as k, HookResult as kt, ExtensionDependencyRecord as l, KubbFileProcessingUpdate as lt, defineExtension as m, KubbGenerationStartContext as mt, AdapterDefinition as n, Renderer as nn, Config as nt, createAdapter as o, ParserDefinition as on, KubbBuildStartContext as ot, checkCompatibility as p, KubbGenerationEndContext as pt, ResolverFilePathParams as q, DiagnosticLocation as qt, AdapterFactory as r, RendererFactory as rn, FilesContext as rt, ExtensionDependencies as s, ParserFactory as sn, KubbDiagnosticContext as st, Adapter as t, Hookable as tn, CLIOptions as tt, ExtensionFactory as u, KubbFilesProcessingEndContext as ut, Group as v, KubbHookStartContext as vt, Output as w, KubbSuccessContext as wt, KubbPluginSetupContext as x, KubbLifecycleStartContext as xt, Include as y, KubbHooks as yt, ResolveFileOptions as z, ReporterName as zt };
|
|
3088
|
+
//# sourceMappingURL=createAdapter-DfbfcqcJ.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_KubbDriver = require("./KubbDriver-
|
|
2
|
+
const require_KubbDriver = require("./KubbDriver-Cd01FAa0.cjs");
|
|
3
3
|
let verkit = require("verkit");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
@@ -929,36 +929,6 @@ function buildReport(result) {
|
|
|
929
929
|
};
|
|
930
930
|
}
|
|
931
931
|
//#endregion
|
|
932
|
-
//#region src/reporters/colors.ts
|
|
933
|
-
/**
|
|
934
|
-
* ANSI color names used by {@link randomCliColor} for deterministic terminal coloring.
|
|
935
|
-
*/
|
|
936
|
-
const randomColors = [
|
|
937
|
-
"black",
|
|
938
|
-
"red",
|
|
939
|
-
"green",
|
|
940
|
-
"yellow",
|
|
941
|
-
"blue",
|
|
942
|
-
"white",
|
|
943
|
-
"magenta",
|
|
944
|
-
"cyan",
|
|
945
|
-
"gray"
|
|
946
|
-
];
|
|
947
|
-
/**
|
|
948
|
-
* Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
|
|
949
|
-
*
|
|
950
|
-
* @example
|
|
951
|
-
* ```ts
|
|
952
|
-
* randomCliColor('petstore') // '\x1b[33m' + 'petstore' + '\x1b[39m' (always the same color for 'petstore')
|
|
953
|
-
* ```
|
|
954
|
-
*/
|
|
955
|
-
function randomCliColor(text) {
|
|
956
|
-
if (!text) return "";
|
|
957
|
-
const index = (0, node_crypto.hash)("sha256", text, "buffer").readUInt32BE(0) % randomColors.length;
|
|
958
|
-
const color = randomColors[index] ?? "white";
|
|
959
|
-
return (0, node_util.styleText)(color, text);
|
|
960
|
-
}
|
|
961
|
-
//#endregion
|
|
962
932
|
//#region src/reporters/summary.ts
|
|
963
933
|
/**
|
|
964
934
|
* Formats the vitest/jest-style summary for one {@link Report}: right-aligned dim labels with
|
|
@@ -969,7 +939,7 @@ function formatSummary(report, { showTimings }) {
|
|
|
969
939
|
const { status, plugins, counts, filesCreated, durationMs, output, timings } = report;
|
|
970
940
|
const rows = [];
|
|
971
941
|
rows.push(["Plugins", status === "success" ? `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} (${plugins.total})` : `${(0, node_util.styleText)("green", `${plugins.passed} passed`)} | ${(0, node_util.styleText)("red", `${plugins.failed.length} failed`)} (${plugins.total})`]);
|
|
972
|
-
if (status === "failed" && plugins.failed.length > 0) rows.push(["Failed", plugins.failed.map((name) =>
|
|
942
|
+
if (status === "failed" && plugins.failed.length > 0) rows.push(["Failed", plugins.failed.map((name) => (0, node_util.styleText)("red", name)).join(", ")]);
|
|
973
943
|
if (counts.errors > 0 || counts.warnings > 0) {
|
|
974
944
|
const issues = [counts.errors > 0 ? (0, node_util.styleText)("red", `${counts.errors} ${counts.errors === 1 ? "error" : "errors"}`) : void 0, counts.warnings > 0 ? (0, node_util.styleText)("yellow", `${counts.warnings} ${counts.warnings === 1 ? "warning" : "warnings"}`) : void 0].filter(Boolean).join(" | ");
|
|
975
945
|
rows.push(["Issues", issues]);
|
|
@@ -1074,25 +1044,6 @@ function kubbStorage({ base } = {}) {
|
|
|
1074
1044
|
//#endregion
|
|
1075
1045
|
//#region src/reporters/fileReporter.ts
|
|
1076
1046
|
/**
|
|
1077
|
-
* Builds the `## Summary` section: the same counts the cli and json reporters expose, as a list of
|
|
1078
|
-
* `label value` rows with the labels padded to a common width.
|
|
1079
|
-
*/
|
|
1080
|
-
function buildSummarySection(report) {
|
|
1081
|
-
const { status, plugins, counts, filesCreated, durationMs, output } = report;
|
|
1082
|
-
const rows = [["Status", status], ["Plugins", status === "success" ? `${plugins.passed} passed (${plugins.total})` : `${plugins.passed} passed | ${plugins.failed.length} failed (${plugins.total})`]];
|
|
1083
|
-
if (plugins.failed.length > 0) rows.push(["Failed", plugins.failed.join(", ")]);
|
|
1084
|
-
rows.push(["Issues", `${counts.errors} errors | ${counts.warnings} warnings | ${counts.infos} infos`]);
|
|
1085
|
-
rows.push(["Files", `${filesCreated} generated`]);
|
|
1086
|
-
rows.push(["Duration", require_KubbDriver.formatMs(durationMs)]);
|
|
1087
|
-
rows.push(["Output", output]);
|
|
1088
|
-
const labelWidth = Math.max(...rows.map(([label]) => label.length));
|
|
1089
|
-
return [
|
|
1090
|
-
"## Summary",
|
|
1091
|
-
"",
|
|
1092
|
-
...rows.map(([label, value]) => ` ${label.padEnd(labelWidth)} ${value}`)
|
|
1093
|
-
];
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
1047
|
* Builds the `## Problems` section: each problem rendered in the miette block format, blocks
|
|
1097
1048
|
* separated by a blank line. Returns an empty array when there are no problems, so the caller
|
|
1098
1049
|
* can drop the heading.
|
|
@@ -1107,27 +1058,10 @@ function buildProblemSection(diagnostics) {
|
|
|
1107
1058
|
];
|
|
1108
1059
|
}
|
|
1109
1060
|
/**
|
|
1110
|
-
* Builds the `## Timings` section from a {@link Report}: one `plugin duration` row per record,
|
|
1111
|
-
* slowest first with the plugin names left-aligned and the durations right-aligned. Returns an
|
|
1112
|
-
* empty array when there are no timings.
|
|
1113
|
-
*/
|
|
1114
|
-
function buildTimingSection(report) {
|
|
1115
|
-
const { timings } = report;
|
|
1116
|
-
if (timings.length === 0) return [];
|
|
1117
|
-
const nameWidth = Math.max(...timings.map((timing) => timing.plugin.length));
|
|
1118
|
-
const durations = timings.map((timing) => require_KubbDriver.formatMs(timing.durationMs));
|
|
1119
|
-
const durationWidth = Math.max(...durations.map((duration) => duration.length));
|
|
1120
|
-
return [
|
|
1121
|
-
"## Timings",
|
|
1122
|
-
"",
|
|
1123
|
-
...timings.map((timing, index) => ` ${timing.plugin.padEnd(nameWidth)} ${durations[index].padStart(durationWidth)}`)
|
|
1124
|
-
];
|
|
1125
|
-
}
|
|
1126
|
-
/**
|
|
1127
1061
|
* The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
|
|
1128
|
-
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same
|
|
1129
|
-
* cli
|
|
1130
|
-
*
|
|
1062
|
+
* plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same lines the
|
|
1063
|
+
* cli reporter prints (timings included), and a `## Problems` section in the miette block format.
|
|
1064
|
+
* Selected with `--reporter file` (or `reporters: ['file']`).
|
|
1131
1065
|
*
|
|
1132
1066
|
* @note It captures the collected diagnostics once a config finishes, not the live
|
|
1133
1067
|
* `kubb:info`/`kubb:plugin` hook stream. Color is stripped so the file stays plain text even when
|
|
@@ -1140,11 +1074,11 @@ const fileReporter = createReporter({
|
|
|
1140
1074
|
if (diagnostics.length === 0) return;
|
|
1141
1075
|
const report = buildReport(result);
|
|
1142
1076
|
const header = config.name ? `# ${config.name} — ${(/* @__PURE__ */ new Date()).toISOString()}` : `# ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
1143
|
-
const sections = [
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
].filter((section) => section.length > 0);
|
|
1077
|
+
const sections = [[
|
|
1078
|
+
"## Summary",
|
|
1079
|
+
"",
|
|
1080
|
+
...formatSummary(report, { showTimings: true })
|
|
1081
|
+
], buildProblemSection(diagnostics)].filter((section) => section.length > 0);
|
|
1148
1082
|
const content = (0, node_util.stripVTControlCharacters)([header, ...sections.map((section) => section.join("\n"))].join("\n\n"));
|
|
1149
1083
|
const baseName = `${[
|
|
1150
1084
|
"kubb",
|
|
@@ -1252,7 +1186,7 @@ function createRenderer(factory) {
|
|
|
1252
1186
|
*
|
|
1253
1187
|
* The returned object is the input as-is, but with `this` types preserved so
|
|
1254
1188
|
* `schema`/`operation`/`operations` methods are correctly typed against the
|
|
1255
|
-
* plugin's `
|
|
1189
|
+
* plugin's `PluginType`. Renderer elements and `FileNode[]` returns
|
|
1256
1190
|
* are both handled by the runtime, so pick whichever style fits.
|
|
1257
1191
|
*
|
|
1258
1192
|
* @example JSX-based schema generator
|
|
@@ -1415,8 +1349,8 @@ function manifestProblems({ options = [] }) {
|
|
|
1415
1349
|
*/
|
|
1416
1350
|
function isExtensionManifest(value) {
|
|
1417
1351
|
if (!isObject(value)) return false;
|
|
1418
|
-
const { kind, name, export: exportName, displayName, description, maintainers, dependencies, compatibility, options } = value;
|
|
1419
|
-
return EXTENSION_KINDS.has(kind) && isPackageName(name) && typeof exportName === "string" && IDENTIFIER.test(exportName) && typeof displayName === "string" && typeof description === "string" && (maintainers === void 0 || Array.isArray(maintainers) && maintainers.every(isMaintainer)) && (dependencies === void 0 || Array.isArray(dependencies) && dependencies.every(isPackageName)) && (compatibility === void 0 || isObject(compatibility) && Object.entries(compatibility).every(([key, range]) => (key === "kubb" || key === "node") && typeof range === "string")) && (options === void 0 || Array.isArray(options) && options.every(isOption)) && manifestProblems(value).length === 0;
|
|
1352
|
+
const { kind, name, export: exportName, displayName, description, maintainers, dependencies, optionalDependencies, compatibility, role, options } = value;
|
|
1353
|
+
return EXTENSION_KINDS.has(kind) && isPackageName(name) && typeof exportName === "string" && IDENTIFIER.test(exportName) && typeof displayName === "string" && typeof description === "string" && (maintainers === void 0 || Array.isArray(maintainers) && maintainers.every(isMaintainer)) && (dependencies === void 0 || Array.isArray(dependencies) && dependencies.every(isPackageName)) && (optionalDependencies === void 0 || Array.isArray(optionalDependencies) && optionalDependencies.every(isPackageName)) && (compatibility === void 0 || isObject(compatibility) && Object.entries(compatibility).every(([key, range]) => (key === "kubb" || key === "node") && typeof range === "string")) && (role === void 0 || role === "client" || role === "consumer") && (options === void 0 || Array.isArray(options) && options.every(isOption)) && manifestProblems(value).length === 0;
|
|
1420
1354
|
}
|
|
1421
1355
|
/** Checks that no artifact field can reach a package manager as a flag or path, and that a GitHub tag names the version. */
|
|
1422
1356
|
function isRegistryArtifact(value) {
|