@kubb/core 5.8.1 → 5.8.3

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.
@@ -26,6 +26,78 @@ type PossiblePromise<T> = Promise<T> | T;
26
26
  */
27
27
  type LiteralUnion<T extends Base, Base = string> = T | (Base & {});
28
28
  //#endregion
29
+ //#region src/defineParser.d.ts
30
+ /**
31
+ * Converts a resolved {@link FileNode} into the final source string that gets
32
+ * written to disk. Kubb ships with TypeScript and TSX parsers. Add your own
33
+ * for new file types (JSON, Markdown, ...).
34
+ */
35
+ type Parser<TMeta extends object = object, TNode = unknown, TOptions extends object = object> = ExtensionNamed & {
36
+ /**
37
+ * The options passed to the parser factory.
38
+ */
39
+ options?: TOptions;
40
+ /**
41
+ * File extensions this parser handles. The driver registers the parser for each
42
+ * extension in this list. A parser with `undefined` here is not registered, so
43
+ * files of an unclaimed extension fall back to joining their sources verbatim.
44
+ *
45
+ * @example
46
+ * `['.ts', '.js']`
47
+ */
48
+ extNames: Array<FileNode['extname']> | undefined;
49
+ /**
50
+ * Serialize the file's AST into source code.
51
+ */
52
+ parse(file: FileNode<TMeta>): string;
53
+ /**
54
+ * Turn the content of a `copy` file into a file node that `parse` prints. Omit to copy the file verbatim.
55
+ */
56
+ copy?(file: FileNode<TMeta>, source: string): UserFileNode<TMeta>;
57
+ /**
58
+ * Render compiler AST nodes for this parser's language into source text.
59
+ * Plugins call this to format the nodes they assemble before handing them
60
+ * back to the parser as `FileNode.sources`.
61
+ */
62
+ print(...nodes: Array<TNode>): string;
63
+ };
64
+ /**
65
+ * Takes the user's options and returns the parser methods.
66
+ */
67
+ type ParserBuild<TOptions extends object, TMeta extends object, TNode> = (options: TOptions) => Omit<Parser<TMeta, TNode>, 'name' | 'meta' | 'options'>;
68
+ /**
69
+ * The object passed to `defineExtension` with `kind: 'parser'`. `build` receives the user's options and returns the parser methods.
70
+ */
71
+ type ParserDefinition<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = {
72
+ meta: ExtensionMeta;
73
+ } & ({
74
+ build: ParserBuild<TOptions, TMeta, TNode>;
75
+ } | {
76
+ /**
77
+ * @deprecated Renamed to `build`.
78
+ */
79
+ setup: ParserBuild<TOptions, TMeta, TNode>;
80
+ });
81
+ /**
82
+ * The function `defineExtension` returns for a parser. Call it with user options to get a `Parser`.
83
+ */
84
+ type ParserFactory<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = ExtensionFactory<'parser', TOptions, Parser<TMeta, TNode, TOptions>>;
85
+ /**
86
+ * Defines a parser from one object and returns a factory that takes the user's options.
87
+ * Register the result in the `parsers` array on `defineConfig`.
88
+ *
89
+ * @deprecated Use `defineExtension` with `kind: 'parser'` instead.
90
+ */
91
+ declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(definition: ParserDefinition<TOptions, TMeta, TNode>): ParserFactory<TOptions, TMeta, TNode>;
92
+ /**
93
+ * Wraps a factory function that returns a `Parser`. Without `meta`, the parser gets `{ name }`.
94
+ *
95
+ * @deprecated Pass a definition object with `kind: 'parser'`, `meta`, and `build` to `defineExtension` instead. The factory form is removed in the next major.
96
+ */
97
+ declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): ((options?: TOptions) => Parser<TMeta, TNode>) & {
98
+ kind: 'parser';
99
+ };
100
+ //#endregion
29
101
  //#region src/createRenderer.d.ts
30
102
  /**
31
103
  * Minimal interface any Kubb renderer must satisfy.
@@ -875,73 +947,6 @@ type Storage = {
875
947
  */
876
948
  declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => Storage): (options?: TOptions) => Storage;
877
949
  //#endregion
878
- //#region src/defineParser.d.ts
879
- /**
880
- * Converts a resolved {@link FileNode} into the final source string that gets
881
- * written to disk. Kubb ships with TypeScript and TSX parsers. Add your own
882
- * for new file types (JSON, Markdown, ...).
883
- */
884
- type Parser<TMeta extends object = object, TNode = unknown, TOptions extends object = object> = ExtensionNamed & {
885
- /**
886
- * The options passed to the parser factory.
887
- */
888
- options?: TOptions;
889
- /**
890
- * File extensions this parser handles. The driver registers the parser for each
891
- * extension in this list. A parser with `undefined` here is not registered, so
892
- * files of an unclaimed extension fall back to joining their sources verbatim.
893
- *
894
- * @example
895
- * `['.ts', '.js']`
896
- */
897
- extNames: Array<FileNode['extname']> | undefined;
898
- /**
899
- * Serialize the file's AST into source code.
900
- */
901
- parse(file: FileNode<TMeta>): string;
902
- /**
903
- * Turn the content of a `copy` file into a file node that `parse` prints. Omit to copy the file verbatim.
904
- */
905
- copy?(file: FileNode<TMeta>, source: string): UserFileNode<TMeta>;
906
- /**
907
- * Render compiler AST nodes for this parser's language into source text.
908
- * Plugins call this to format the nodes they assemble before handing them
909
- * back to the parser as `FileNode.sources`.
910
- */
911
- print(...nodes: Array<TNode>): string;
912
- };
913
- type ParserBuild<TOptions extends object, TMeta extends object, TNode> = (options: TOptions) => Omit<Parser<TMeta, TNode>, 'name' | 'meta' | 'options'>;
914
- /**
915
- * The object passed to `defineParser`. `build` receives the user's options and returns the parser methods.
916
- */
917
- type ParserDefinition<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = {
918
- meta: ExtensionMeta;
919
- } & ({
920
- build: ParserBuild<TOptions, TMeta, TNode>;
921
- } | {
922
- /**
923
- * @deprecated Renamed to `build`.
924
- */
925
- setup: ParserBuild<TOptions, TMeta, TNode>;
926
- });
927
- /**
928
- * The function `defineParser` returns. Call it with user options to get a `Parser`.
929
- */
930
- type ParserFactory<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = ExtensionFactory<'parser', TOptions, Parser<TMeta, TNode, TOptions>>;
931
- /**
932
- * Defines a parser from one object and returns a factory that takes the user's options.
933
- * Register the result in the `parsers` array on `defineConfig`.
934
- */
935
- declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(definition: ParserDefinition<TOptions, TMeta, TNode>): ParserFactory<TOptions, TMeta, TNode>;
936
- /**
937
- * Wraps a factory function that returns a `Parser`. Without `meta`, the parser gets `{ name }`.
938
- *
939
- * @deprecated Pass a definition object with `meta` and `build` instead. The factory form is removed in the next major.
940
- */
941
- declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): ((options?: TOptions) => Parser<TMeta, TNode>) & {
942
- kind: 'parser';
943
- };
944
- //#endregion
945
950
  //#region src/outputManifest.d.ts
946
951
  /**
947
952
  * Remembers what the output passes did to each generated file, so the next run can tell "the
@@ -2680,7 +2685,7 @@ TResolver extends Resolver = Resolver> = {
2680
2685
  resolver: TResolver;
2681
2686
  };
2682
2687
  /**
2683
- * Type parameter for the object form of `definePlugin`. Same shape as `PluginFactoryOptions`.
2688
+ * Type parameter for the object form of `defineExtension` with `kind: 'plugin'`. Same shape as `PluginFactoryOptions`.
2684
2689
  */
2685
2690
  type PluginType<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions, TResolver extends Resolver = Resolver> = PluginFactoryOptions<TName, TOptions, TResolvedOptions, TResolver>;
2686
2691
  /**
@@ -2741,7 +2746,7 @@ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactor
2741
2746
  options: TFactory['options'];
2742
2747
  };
2743
2748
  /**
2744
- * A plugin object produced by `definePlugin`. Its lifecycle handlers live under a single
2749
+ * A plugin object produced by `defineExtension`. Its lifecycle handlers live under a single
2745
2750
  * `hooks` property rather than flat methods.
2746
2751
  */
2747
2752
  type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = ExtensionNamed & {
@@ -2777,14 +2782,14 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = Exte
2777
2782
  setup?(options: TFactory['options'], kubb: KubbPluginSetupContext<TFactory>): TFactory['resolvedOptions'] | Promise<TFactory['resolvedOptions']>;
2778
2783
  };
2779
2784
  /**
2780
- * The object passed to `definePlugin`.
2785
+ * The object passed to `defineExtension` with `kind: 'plugin'`.
2781
2786
  */
2782
2787
  type PluginDefinition<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = Pick<Plugin<TFactory>, 'dependencies' | 'enforce' | 'setup'> & {
2783
2788
  meta: ExtensionMeta<TFactory['name']>;
2784
2789
  hooks?: Plugin<TFactory>['hooks'];
2785
2790
  };
2786
2791
  /**
2787
- * The function `definePlugin` returns. Call it with user options to get a `Plugin`.
2792
+ * The function `defineExtension` returns for a plugin. Call it with user options to get a `Plugin`.
2788
2793
  */
2789
2794
  type PluginFactory<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = ExtensionFactory<'plugin', TFactory['options'], Plugin<TFactory>, TFactory['name']>;
2790
2795
  /**
@@ -2819,25 +2824,14 @@ type KubbPluginEndContext = FilesContext & {
2819
2824
  };
2820
2825
  /**
2821
2826
  * Defines a plugin from one object and returns a factory that takes the user's options.
2822
- * Name plugins `plugin-<feature>`.
2823
2827
  *
2824
- * @example
2825
- * ```ts
2826
- * export const pluginZod = definePlugin<PluginZod>({
2827
- * meta: { name: 'plugin-zod', compatibility: { kubb: '>=5.7.0' } },
2828
- * dependencies: { 'plugin-ts': { optional: true } },
2829
- * setup(options, kubb) {
2830
- * kubb.addGenerator(zodGenerator)
2831
- * return { ...options, inferred: options.inferred ?? false }
2832
- * },
2833
- * })
2834
- * ```
2828
+ * @deprecated Use `defineExtension` with `kind: 'plugin'` instead.
2835
2829
  */
2836
2830
  declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(definition: PluginDefinition<TFactory>): PluginFactory<TFactory>;
2837
2831
  /**
2838
2832
  * Wraps a factory function that returns a `Plugin`. Without `meta`, the plugin gets `{ name }`.
2839
2833
  *
2840
- * @deprecated Pass a definition object with `meta` and `setup` instead. The factory form is removed in the next major.
2834
+ * @deprecated Pass a definition object with `kind: 'plugin'`, `meta`, and `setup` to `defineExtension` instead. The factory form is removed in the next major.
2841
2835
  */
2842
2836
  declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): ((options?: TFactory['options']) => Plugin<TFactory>) & {
2843
2837
  kind: 'plugin';
@@ -2932,6 +2926,31 @@ type ExtensionFactory<TKind extends ExtensionKind, TOptions, TExtension, TName e
2932
2926
  kind: TKind;
2933
2927
  meta: ExtensionMeta<TName>;
2934
2928
  };
2929
+ /**
2930
+ * Defines a parser and returns a factory that takes the user's options. `build` returns the parser methods.
2931
+ */
2932
+ declare function defineExtension<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(definition: {
2933
+ kind: 'parser';
2934
+ meta: ExtensionMeta;
2935
+ build: ParserBuild<TOptions, TMeta, TNode>;
2936
+ }): ParserFactory<TOptions, TMeta, TNode>;
2937
+ /**
2938
+ * Defines an adapter and returns a factory that takes the user's options. `parse` must return an `InputNode`.
2939
+ */
2940
+ declare function defineExtension<T extends AdapterFactoryOptions = AdapterFactoryOptions>(definition: {
2941
+ kind: 'adapter';
2942
+ } & AdapterDefinition<T>): AdapterFactory<T>;
2943
+ /**
2944
+ * Defines a plugin and returns a factory that takes the user's options. Name plugins `plugin-<feature>`.
2945
+ *
2946
+ * @example
2947
+ * ```ts
2948
+ * defineExtension<PluginZod>({ kind: 'plugin', meta: { name: 'plugin-zod' }, setup: (options) => options })
2949
+ * ```
2950
+ */
2951
+ declare function defineExtension<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(definition: {
2952
+ kind: 'plugin';
2953
+ } & PluginDefinition<TFactory>): PluginFactory<TFactory>;
2935
2954
  //#endregion
2936
2955
  //#region src/createAdapter.d.ts
2937
2956
  /**
@@ -2949,7 +2968,7 @@ type AdapterSource = {
2949
2968
  data: string | unknown;
2950
2969
  };
2951
2970
  /**
2952
- * Generic parameters used by `createAdapter` and the resulting `Adapter` type.
2971
+ * Generic parameters used by `defineExtension` with `kind: 'adapter'` and the resulting `Adapter` type.
2953
2972
  *
2954
2973
  * - `TName`: unique adapter identifier (`'oas'`, `'asyncapi'`, ...).
2955
2974
  * - `TOptions`: user-facing options accepted by the adapter factory.
@@ -3017,7 +3036,7 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
3017
3036
  };
3018
3037
  type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
3019
3038
  /**
3020
- * The object passed to `createAdapter`.
3039
+ * The object passed to `defineExtension` with `kind: 'adapter'`.
3021
3040
  */
3022
3041
  type AdapterDefinition<T extends AdapterFactoryOptions = AdapterFactoryOptions> = {
3023
3042
  meta: ExtensionMeta<T['name']>;
@@ -3032,7 +3051,7 @@ type AdapterDefinition<T extends AdapterFactoryOptions = AdapterFactoryOptions>
3032
3051
  build(options: T['resolvedOptions']): Omit<Adapter<T>, 'name' | 'meta' | 'options'>;
3033
3052
  };
3034
3053
  /**
3035
- * The function `createAdapter` returns. Call it with user options to get an `Adapter`.
3054
+ * The function `defineExtension` returns for an adapter. Call it with user options to get an `Adapter`.
3036
3055
  */
3037
3056
  type AdapterFactory<T extends AdapterFactoryOptions = AdapterFactoryOptions> = ExtensionFactory<'adapter', T['options'], Adapter<T>, T['name']>;
3038
3057
  /**
@@ -3043,38 +3062,17 @@ type AdapterFactory<T extends AdapterFactoryOptions = AdapterFactoryOptions> = E
3043
3062
  * Adapters must return an `InputNode` from `parse`. That node is what every
3044
3063
  * plugin in the build consumes.
3045
3064
  *
3046
- * @example
3047
- * ```ts
3048
- * import { createAdapter, type AdapterFactoryOptions } from '@kubb/core'
3049
- * import { ast } from '@kubb/ast'
3050
- *
3051
- * type MyAdapter = AdapterFactoryOptions<'my-adapter', { validate?: boolean }, { validate: boolean }>
3052
- *
3053
- * export const myAdapter = createAdapter<MyAdapter>({
3054
- * meta: { name: 'my-adapter', compatibility: { kubb: '>=5.7.0' } },
3055
- * setup: (options) => ({ validate: options.validate ?? true }),
3056
- * build: (options) => ({
3057
- * document: null,
3058
- * async parse(_source) {
3059
- * // Convert the source (path or inline data) into an InputNode.
3060
- * return ast.factory.createInput()
3061
- * },
3062
- * async validate() {
3063
- * // Throw here when `options.validate` is set and the spec is invalid.
3064
- * },
3065
- * }),
3066
- * })
3067
- * ```
3065
+ * @deprecated Use `defineExtension` with `kind: 'adapter'` instead.
3068
3066
  */
3069
3067
  declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(definition: AdapterDefinition<T>): AdapterFactory<T>;
3070
3068
  /**
3071
3069
  * Wraps a factory function that returns an `Adapter`.
3072
3070
  *
3073
- * @deprecated Pass a definition object with `meta` and `build` instead. The factory form is removed in the next major.
3071
+ * @deprecated Pass a definition object with `kind: 'adapter'`, `meta`, and `build` to `defineExtension` instead. The factory form is removed in the next major.
3074
3072
  */
3075
3073
  declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): ((options?: T['options']) => Adapter<T>) & {
3076
3074
  kind: 'adapter';
3077
3075
  };
3078
3076
  //#endregion
3079
- export { NodeCache as $, Diagnostics as $t, PluginFactoryOptions as A, RunHookOptions as At, ResolveImportsOptions as B, GenerationResult as Bt, Output as C, KubbPluginsEndContext as Ct, Plugin as D, PostGenerateCommand as Dt, Override as E, PossibleConfig as Et, definePlugin as F, ParserDefinition as Ft, ResolverFile as G, UserReporter as Gt, ResolvePathOptions as H, ReporterContext as Ht, BannerMeta as I, ParserFactory as It, ResolverPatch as J, Diagnostic as Jt, ResolverFileParams as K, createReporter as Kt, ResolveBannerContext as L, defineParser as Lt, PluginType as M, KubbDriver as Mt, ResolvePluginOptions as N, FileManagerHooks as Nt, PluginDefinition as O, UserConfig as Ot, assertPluginOption as P, Parser as Pt, defineGenerator as Q, DiagnosticSeverity as Qt, ResolveBannerFile as R, Storage as Rt, NormalizedPlugin as S, KubbMessageContext as St, OutputOptions as T, KubbWarnContext as Tt, Resolver as U, ReporterName as Ut, ResolveOptionsContext as V, Reporter as Vt, ResolverDefault as W, ReporterPluginFiles as Wt, Generator as X, DiagnosticKind as Xt, ResolverPathParams as Y, DiagnosticDoc as Yt, GeneratorContext as Z, DiagnosticLocation as Zt, Group as _, KubbHookLineContext as _t, AdapterSource as a, Hookable as an, KubbBuildEndContext as at, KubbPluginSetupContext as b, KubbInfoContext as bt, ExtensionDependency as c, createRenderer as cn, KubbErrorContext as ct, ExtensionKind as d, KubbFilesProcessingStartContext as dt, PerformanceDiagnostic as en, BuildOutput as et, ExtensionMeta as f, KubbFilesProcessingUpdateContext as ft, Filter as g, KubbHookEndContext as gt, Exclude$1 as h, KubbGenerationSummaryContext as ht, AdapterFactoryOptions as i, UpdateDiagnostic as in, Input as it, PluginName as j, runHook as jt, PluginFactory as k, HookResult as kt, ExtensionDependencyRecord as l, KubbFileProcessingUpdate as lt, resolveMeta as m, KubbGenerationStartContext as mt, AdapterDefinition as n, ProblemDiagnostic as nn, Config as nt, createAdapter as o, Renderer as on, KubbBuildStartContext as ot, checkCompatibility as p, KubbGenerationEndContext as pt, ResolverFilePathParams as q, logLevel as qt, AdapterFactory as r, SerializedDiagnostic as rn, FilesContext as rt, ExtensionDependencies as s, RendererFactory as sn, KubbDiagnosticContext as st, Adapter as t, ProblemCode as tn, CLIOptions as tt, ExtensionFactory as u, KubbFilesProcessingEndContext as ut, Include as v, KubbHookStartContext as vt, OutputMode as w, KubbSuccessContext as wt, KubbPluginStartContext as x, KubbLifecycleStartContext as xt, KubbPluginEndContext as y, KubbHooks as yt, ResolveFileOptions as z, createStorage as zt };
3080
- //# sourceMappingURL=createAdapter-BO_AxI05.d.ts.map
3077
+ export { defineGenerator as $, ProblemDiagnostic as $t, PluginFactory as A, HookResult as At, ResolveFileOptions as B, ReporterName as Bt, NormalizedPlugin as C, KubbMessageContext as Ct, Override as D, PossibleConfig as Dt, OutputOptions as E, KubbWarnContext as Et, assertPluginOption as F, Storage as Ft, ResolverDefault as G, Diagnostic as Gt, ResolveOptionsContext as H, UserReporter as Ht, definePlugin as I, createStorage as It, ResolverFilePathParams as J, DiagnosticLocation as Jt, ResolverFile as K, DiagnosticDoc as Kt, BannerMeta as L, GenerationResult as Lt, PluginName as M, runHook as Mt, PluginType as N, KubbDriver as Nt, Plugin as O, PostGenerateCommand as Ot, ResolvePluginOptions as P, FileManagerHooks as Pt, GeneratorContext as Q, ProblemCode as Qt, ResolveBannerContext as R, Reporter as Rt, KubbPluginStartContext as S, KubbLifecycleStartContext as St, OutputMode as T, KubbSuccessContext as Tt, ResolvePathOptions as U, createReporter as Ut, ResolveImportsOptions as V, ReporterPluginFiles as Vt, Resolver as W, logLevel as Wt, ResolverPathParams as X, Diagnostics as Xt, ResolverPatch as Y, DiagnosticSeverity as Yt, Generator as Z, PerformanceDiagnostic as Zt, Filter as _, KubbHookEndContext as _t, AdapterSource as a, createRenderer as an, Input as at, KubbPluginEndContext as b, KubbHooks as bt, ExtensionDependency as c, ParserFactory as cn, KubbDiagnosticContext as ct, ExtensionKind as d, KubbFilesProcessingEndContext as dt, SerializedDiagnostic as en, NodeCache as et, ExtensionMeta as f, KubbFilesProcessingStartContext as ft, Exclude$1 as g, KubbGenerationSummaryContext as gt, resolveMeta as h, KubbGenerationStartContext as ht, AdapterFactoryOptions as i, RendererFactory as in, FilesContext as it, PluginFactoryOptions as j, RunHookOptions as jt, PluginDefinition as k, UserConfig as kt, ExtensionDependencyRecord as l, defineParser as ln, KubbErrorContext as lt, defineExtension as m, KubbGenerationEndContext as mt, AdapterDefinition as n, Hookable as nn, CLIOptions as nt, createAdapter as o, Parser as on, KubbBuildEndContext as ot, checkCompatibility as p, KubbFilesProcessingUpdateContext as pt, ResolverFileParams as q, DiagnosticKind as qt, AdapterFactory as r, Renderer as rn, Config as rt, ExtensionDependencies as s, ParserDefinition as sn, KubbBuildStartContext as st, Adapter as t, UpdateDiagnostic as tn, BuildOutput as tt, ExtensionFactory as u, KubbFileProcessingUpdate as ut, Group as v, KubbHookLineContext as vt, Output as w, KubbPluginsEndContext as wt, KubbPluginSetupContext as x, KubbInfoContext as xt, Include as y, KubbHookStartContext as yt, ResolveBannerFile as z, ReporterContext as zt };
3078
+ //# sourceMappingURL=createAdapter-BpJYvJTw.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-DQ7pt93q.cjs");
2
+ const require_KubbDriver = require("./KubbDriver-iAEw2oH5.cjs");
3
3
  let verkit = require("verkit");
4
4
  let node_util = require("node:util");
5
5
  let node_process = require("node:process");
@@ -157,22 +157,13 @@ function tokenize(command) {
157
157
  //#endregion
158
158
  //#region src/createAdapter.ts
159
159
  function createAdapter(input) {
160
- if (typeof input === "function") return require_KubbDriver.defineExtension({
160
+ if (typeof input === "function") return require_KubbDriver.createExtensionFactory({
161
161
  kind: "adapter",
162
162
  build: (options) => input(options)
163
163
  });
164
- const { meta, setup, build } = input;
165
164
  return require_KubbDriver.defineExtension({
166
165
  kind: "adapter",
167
- meta,
168
- build: (raw) => {
169
- const options = setup ? setup(raw) : raw;
170
- return Object.assign(build(options), {
171
- name: meta.name,
172
- meta,
173
- options
174
- });
175
- }
166
+ ...input
176
167
  });
177
168
  }
178
169
  //#endregion
@@ -1288,7 +1279,7 @@ function defineGenerator(generator) {
1288
1279
  //#endregion
1289
1280
  //#region src/defineParser.ts
1290
1281
  function defineParser(input) {
1291
- if (typeof input === "function") return require_KubbDriver.defineExtension({
1282
+ if (typeof input === "function") return require_KubbDriver.createExtensionFactory({
1292
1283
  kind: "parser",
1293
1284
  build: (options) => {
1294
1285
  const parser = input(options);
@@ -1298,17 +1289,10 @@ function defineParser(input) {
1298
1289
  };
1299
1290
  }
1300
1291
  });
1301
- const { meta } = input;
1302
- const build = "build" in input ? input.build : input.setup;
1303
1292
  return require_KubbDriver.defineExtension({
1304
1293
  kind: "parser",
1305
- meta,
1306
- build: (options) => ({
1307
- ...build(options),
1308
- name: meta.name,
1309
- meta,
1310
- options
1311
- })
1294
+ meta: input.meta,
1295
+ build: "build" in input ? input.build : input.setup
1312
1296
  });
1313
1297
  }
1314
1298
  //#endregion
@@ -1397,6 +1381,9 @@ const canonicalJSON = (value) => JSON.stringify(value, (_key, item) => isObject(
1397
1381
  function isPackageName(name) {
1398
1382
  return typeof name === "string" && name.length <= 214 && PACKAGE_NAME.test(name);
1399
1383
  }
1384
+ function isMaintainer(value) {
1385
+ return isObject(value) && Object.keys(value).every((key) => key === "name" || key === "github") && isFilledString(value.name) && (value.github === void 0 || isFilledString(value.github));
1386
+ }
1400
1387
  /** Checks the shape of one manifest option, including that its path cannot reach a prototype. */
1401
1388
  function isOption(value) {
1402
1389
  if (!isObject(value)) return false;
@@ -1424,8 +1411,8 @@ function manifestProblems({ options = [] }) {
1424
1411
  */
1425
1412
  function isExtensionManifest(value) {
1426
1413
  if (!isObject(value)) return false;
1427
- const { kind, name, export: exportName, displayName, description, compatibility, options } = value;
1428
- return EXTENSION_KINDS.has(kind) && isPackageName(name) && typeof exportName === "string" && IDENTIFIER.test(exportName) && typeof displayName === "string" && typeof description === "string" && (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;
1414
+ const { kind, name, export: exportName, displayName, description, maintainers, dependencies, compatibility, options } = value;
1415
+ 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;
1429
1416
  }
1430
1417
  /**
1431
1418
  * Checks one entry of a registry's `index.json` or `<owner>/<slug>.json`: a full `<owner>/<slug>` id,
@@ -1492,6 +1479,7 @@ exports.createRenderer = createRenderer;
1492
1479
  exports.createReporter = createReporter;
1493
1480
  exports.createResolver = require_KubbDriver.createResolver;
1494
1481
  exports.createStorage = createStorage;
1482
+ exports.defineExtension = require_KubbDriver.defineExtension;
1495
1483
  exports.defineGenerator = defineGenerator;
1496
1484
  exports.defineParser = defineParser;
1497
1485
  exports.definePlugin = require_KubbDriver.definePlugin;