@kubb/core 5.6.3 → 5.8.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.
@@ -192,6 +192,18 @@ declare const diagnosticCode: {
192
192
  * A required plugin is missing from the config.
193
193
  */
194
194
  readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
195
+ /**
196
+ * The running Kubb or Node.js version is outside a plugin's `meta.compatibility`.
197
+ */
198
+ readonly incompatibleExtension: "KUBB_INCOMPATIBLE_EXTENSION";
199
+ /**
200
+ * A required entry in a plugin's `dependencies` record is missing from the config.
201
+ */
202
+ readonly missingDependency: "KUBB_MISSING_DEPENDENCY";
203
+ /**
204
+ * A dependency's `meta.version` is outside the range a plugin's `dependencies` record declares.
205
+ */
206
+ readonly incompatibleDependency: "KUBB_INCOMPATIBLE_DEPENDENCY";
195
207
  /**
196
208
  * A plugin threw while generating.
197
209
  */
@@ -204,6 +216,10 @@ declare const diagnosticCode: {
204
216
  * A plugin reported an informational message through `ctx.info`.
205
217
  */
206
218
  readonly pluginInfo: "KUBB_PLUGIN_INFO";
219
+ /**
220
+ * A `kubb/kit` composable was called outside a plugin's `setup` and `kubb:plugin:setup`.
221
+ */
222
+ readonly noContext: "KUBB_NO_CONTEXT";
207
223
  /**
208
224
  * A schema uses a `format` Kubb does not map to a specific type. Reserved for
209
225
  * adapters to emit as a `warning`.
@@ -233,6 +249,10 @@ declare const diagnosticCode: {
233
249
  * A plugin's options are invalid, for example `output.mode: 'file'` paired with a `group` option.
234
250
  */
235
251
  readonly invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS";
252
+ /**
253
+ * An extension's options fail its options `schema`.
254
+ */
255
+ readonly invalidOptions: "KUBB_INVALID_OPTIONS";
236
256
  /**
237
257
  * A post-generate command (`output.postGenerate`) exited with a failure.
238
258
  */
@@ -535,15 +555,20 @@ declare class Diagnostics {
535
555
  readonly refNotFound: "KUBB_REF_NOT_FOUND";
536
556
  readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
537
557
  readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
558
+ readonly incompatibleExtension: "KUBB_INCOMPATIBLE_EXTENSION";
559
+ readonly missingDependency: "KUBB_MISSING_DEPENDENCY";
560
+ readonly incompatibleDependency: "KUBB_INCOMPATIBLE_DEPENDENCY";
538
561
  readonly pluginFailed: "KUBB_PLUGIN_FAILED";
539
562
  readonly pluginWarning: "KUBB_PLUGIN_WARNING";
540
563
  readonly pluginInfo: "KUBB_PLUGIN_INFO";
564
+ readonly noContext: "KUBB_NO_CONTEXT";
541
565
  readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
542
566
  readonly deprecated: "KUBB_DEPRECATED";
543
567
  readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
544
568
  readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
545
569
  readonly cleanRoot: "KUBB_CLEAN_ROOT";
546
570
  readonly invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS";
571
+ readonly invalidOptions: "KUBB_INVALID_OPTIONS";
547
572
  readonly postGenerateFailed: "KUBB_POST_GENERATE_FAILED";
548
573
  readonly formatFailed: "KUBB_FORMAT_FAILED";
549
574
  readonly lintFailed: "KUBB_LINT_FAILED";
@@ -968,6 +993,133 @@ type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
968
993
  */
969
994
  declare function createRenderer<TElement = unknown>(factory: RendererFactory<TElement>): RendererFactory<TElement>;
970
995
  //#endregion
996
+ //#region src/standardSchema.d.ts
997
+ /**
998
+ * The parts of the Standard Schema v1 interfaces (https://standardschema.dev) that Kubb reads,
999
+ * copied as the spec recommends so core needs no schema library. Zod, Valibot and ArkType
1000
+ * schemas all match them.
1001
+ */
1002
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
1003
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
1004
+ }
1005
+ declare namespace StandardSchemaV1 {
1006
+ interface Props<Input = unknown, Output = Input> {
1007
+ readonly version: 1;
1008
+ readonly vendor: string;
1009
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
1010
+ readonly types?: Types<Input, Output> | undefined;
1011
+ }
1012
+ type Result<Output> = SuccessResult<Output> | FailureResult;
1013
+ interface SuccessResult<Output> {
1014
+ readonly value: Output;
1015
+ readonly issues?: undefined;
1016
+ }
1017
+ interface FailureResult {
1018
+ readonly issues: ReadonlyArray<Issue>;
1019
+ }
1020
+ interface Issue {
1021
+ readonly message: string;
1022
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
1023
+ }
1024
+ interface PathSegment {
1025
+ readonly key: PropertyKey;
1026
+ }
1027
+ interface Types<Input = unknown, Output = Input> {
1028
+ readonly input: Input;
1029
+ readonly output: Output;
1030
+ }
1031
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
1032
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
1033
+ }
1034
+ //#endregion
1035
+ //#region src/defineExtension.d.ts
1036
+ /**
1037
+ * What an extension extends: a plugin generates code, an adapter reads the input, a parser prints files.
1038
+ */
1039
+ type ExtensionKind = 'plugin' | 'adapter' | 'parser';
1040
+ /**
1041
+ * Identity and registry data for an extension. Kubb reads `name` and `compatibility` at runtime.
1042
+ * Studio, the kubb.dev registry, and the docs read the rest.
1043
+ */
1044
+ type ExtensionMeta<TName extends string = string> = {
1045
+ /**
1046
+ * Unique name, such as `'plugin-ts'`. Becomes the plugin's `name`.
1047
+ */
1048
+ name: TName;
1049
+ /**
1050
+ * Package version. Dependents check their `version` range against it.
1051
+ */
1052
+ version?: string;
1053
+ displayName?: string;
1054
+ /**
1055
+ * One-sentence summary of what the extension generates or does.
1056
+ */
1057
+ description?: string;
1058
+ category?: string;
1059
+ icon?: {
1060
+ light: string;
1061
+ dark?: string;
1062
+ };
1063
+ tags?: Array<string>;
1064
+ /**
1065
+ * Semver ranges the extension supports. A mismatch fails the run with `KUBB_INCOMPATIBLE_EXTENSION`.
1066
+ */
1067
+ compatibility?: {
1068
+ kubb?: string;
1069
+ node?: string;
1070
+ };
1071
+ docs?: string;
1072
+ };
1073
+ /**
1074
+ * An extension's identity: `meta`, a `name`, or both. `name` is deprecated in favor of `meta.name`.
1075
+ */
1076
+ type ExtensionNamed = {
1077
+ name?: string;
1078
+ meta?: ExtensionMeta;
1079
+ };
1080
+ /**
1081
+ * Returns `meta`, or `{ name }` for an extension that only sets the deprecated `name`. Throws `KUBB_INVALID_PLUGIN_OPTIONS` when it has neither.
1082
+ */
1083
+ declare function resolveMeta({ name, meta }: ExtensionNamed): ExtensionMeta;
1084
+ /**
1085
+ * Sets how Kubb checks one entry in a `dependencies` record.
1086
+ */
1087
+ type ExtensionDependency = {
1088
+ /**
1089
+ * Semver range the dependency's `meta.version` must satisfy. Skipped when the dependency has no `meta.version`.
1090
+ */
1091
+ version?: string;
1092
+ /**
1093
+ * When `true`, Kubb skips the entry if the plugin is missing, but still checks `version` on an installed one.
1094
+ * Otherwise a missing plugin fails the run with `KUBB_MISSING_DEPENDENCY`.
1095
+ */
1096
+ optional?: boolean;
1097
+ };
1098
+ /**
1099
+ * Plugins an extension builds on, keyed by name, or a function that picks them from the user's options.
1100
+ */
1101
+ type ExtensionDependencies<TOptions = object> = ExtensionDependencyRecord | {
1102
+ resolve(options: TOptions, kubb: {
1103
+ config: Config;
1104
+ }): ExtensionDependencyRecord;
1105
+ }['resolve'];
1106
+ /**
1107
+ * Maps each dependency's plugin name to how Kubb checks it.
1108
+ */
1109
+ type ExtensionDependencyRecord = Partial<Record<PluginName, ExtensionDependency>>;
1110
+ /**
1111
+ * The function an extension definition returns. Call it with user options to get the extension.
1112
+ */
1113
+ type ExtensionFactory<TKind extends ExtensionKind, TOptions, TExtension, TName extends string = string, TParsedOptions = TOptions> = {
1114
+ (options?: TOptions): TExtension;
1115
+ kind: TKind;
1116
+ meta: ExtensionMeta<TName>;
1117
+ /**
1118
+ * The definition's options schema, so tools can read it without calling the factory.
1119
+ */
1120
+ schema?: StandardSchemaV1<TOptions, TParsedOptions>;
1121
+ };
1122
+ //#endregion
971
1123
  //#region src/Resolver.d.ts
972
1124
  /**
973
1125
  * Context for resolving filtered options for a given operation or schema node.
@@ -1535,12 +1687,30 @@ TResolvedOptions extends object = TOptions,
1535
1687
  * Resolver that encapsulates naming and path-resolution helpers.
1536
1688
  * Define with `createResolver` and export alongside the plugin.
1537
1689
  */
1538
- TResolver extends Resolver = Resolver> = {
1690
+ TResolver extends Resolver = Resolver,
1691
+ /**
1692
+ * Plugin options after the options `schema` parsed them, with its defaults applied.
1693
+ */
1694
+ TParsedOptions extends object = TOptions> = {
1539
1695
  name: TName;
1540
1696
  options: TOptions;
1697
+ parsedOptions: TParsedOptions;
1541
1698
  resolvedOptions: TResolvedOptions;
1542
1699
  resolver: TResolver;
1543
1700
  };
1701
+ type AsObject<T> = T extends object ? T : object;
1702
+ type InferOptionsInput<TOptions> = TOptions extends StandardSchemaV1 ? AsObject<StandardSchemaV1.InferInput<TOptions>> : TOptions;
1703
+ type InferOptionsOutput<TOptions> = TOptions extends StandardSchemaV1 ? AsObject<StandardSchemaV1.InferOutput<TOptions>> : TOptions;
1704
+ /**
1705
+ * Type parameter for the object form of `definePlugin`. Same shape as `PluginFactoryOptions`, except that
1706
+ * `TOptions` can also be the plugin's options schema. Then `options` is the schema's input type, and
1707
+ * `parsedOptions` and the default `resolvedOptions` are its output type.
1708
+ */
1709
+ type PluginType<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = InferOptionsOutput<TOptions>, TResolver extends Resolver = Resolver> = PluginFactoryOptions<TName, InferOptionsInput<TOptions>, TResolvedOptions, TResolver, InferOptionsOutput<TOptions>>;
1710
+ /**
1711
+ * The options a user passes to a plugin with options schema `TSchema`: the schema's input type, before defaults apply.
1712
+ */
1713
+ type PluginOptions<TSchema extends StandardSchemaV1> = StandardSchemaV1.InferInput<TSchema>;
1544
1714
  /**
1545
1715
  * Context passed to a plugin's `kubb:plugin:setup` handler, where it registers generators and
1546
1716
  * sets its resolver, transformer, and options.
@@ -1594,24 +1764,20 @@ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactor
1594
1764
  */
1595
1765
  config: Config;
1596
1766
  /**
1597
- * The plugin's user-provided options.
1767
+ * The plugin's options, parsed by its options `schema` when it has one.
1598
1768
  */
1599
- options: TFactory['options'];
1769
+ options: TFactory['parsedOptions'];
1600
1770
  };
1601
1771
  /**
1602
1772
  * A plugin object produced by `definePlugin`. Its lifecycle handlers live under a single
1603
1773
  * `hooks` property rather than flat methods.
1604
1774
  */
1605
- type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1775
+ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = ExtensionNamed & {
1606
1776
  /**
1607
- * Unique name for the plugin, following the same naming convention as `createPlugin`.
1777
+ * Plugins this one builds on. They run first when the config has them. An array only orders
1778
+ * plugins. A record also fails the run when a required entry is missing or out of range.
1608
1779
  */
1609
- name: string;
1610
- /**
1611
- * Plugins this one builds on. They run first when the config has them; a missing one is skipped.
1612
- * Call `ctx.requirePlugin` in `kubb:plugin:setup` to fail the run when one is missing.
1613
- */
1614
- dependencies?: Array<PluginName>;
1780
+ dependencies?: Array<PluginName> | ExtensionDependencies<TFactory['parsedOptions']>;
1615
1781
  /**
1616
1782
  * Controls the execution order of this plugin relative to others.
1617
1783
  *
@@ -1626,6 +1792,10 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1626
1792
  * The options passed by the user when calling the plugin factory.
1627
1793
  */
1628
1794
  options?: TFactory['options'];
1795
+ /**
1796
+ * The options after the plugin's options `schema` parsed them, with its defaults applied. Set only when the plugin has a `schema`.
1797
+ */
1798
+ parsedOptions?: TFactory['parsedOptions'];
1629
1799
  /**
1630
1800
  * Lifecycle hook handlers for this plugin.
1631
1801
  * Any hook from the global `KubbHooks` map can be subscribed to here.
@@ -1633,7 +1803,27 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1633
1803
  hooks: { [K in keyof KubbHooks as K extends 'kubb:plugin:setup' ? never : K]?: (...args: KubbHooks[K]) => void | Promise<void>; } & {
1634
1804
  'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>;
1635
1805
  };
1806
+ /**
1807
+ * Runs before `kubb:plugin:setup`. Takes the parsed options and returns the resolved options.
1808
+ */
1809
+ setup?(options: TFactory['parsedOptions'], kubb: KubbPluginSetupContext<TFactory>): TFactory['resolvedOptions'] | Promise<TFactory['resolvedOptions']>;
1810
+ };
1811
+ /**
1812
+ * The object passed to `definePlugin`.
1813
+ */
1814
+ type PluginDefinition<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = Pick<Plugin<TFactory>, 'dependencies' | 'enforce' | 'setup'> & {
1815
+ meta: ExtensionMeta<TFactory['name']>;
1816
+ /**
1817
+ * Any Standard Schema, such as a Zod schema, that validates the options and applies their defaults
1818
+ * when the factory is called. Invalid options throw `KUBB_INVALID_OPTIONS`. The schema must validate synchronously.
1819
+ */
1820
+ schema?: StandardSchemaV1<TFactory['options'], TFactory['parsedOptions']>;
1821
+ hooks?: Plugin<TFactory>['hooks'];
1636
1822
  };
1823
+ /**
1824
+ * The function `definePlugin` returns. Call it with user options to get a `Plugin`.
1825
+ */
1826
+ type PluginFactory<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = ExtensionFactory<'plugin', TFactory['options'], Plugin<TFactory>, TFactory['name'], TFactory['parsedOptions']>;
1637
1827
  /**
1638
1828
  * Normalized plugin after setup, with runtime fields populated. Internal only. Plugins use the
1639
1829
  * public `Plugin` type.
@@ -1641,6 +1831,9 @@ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1641
1831
  * @internal
1642
1832
  */
1643
1833
  type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {
1834
+ name: string;
1835
+ meta: ExtensionMeta;
1836
+ dependencies?: Array<PluginName> | ExtensionDependencyRecord;
1644
1837
  options: TOptions['resolvedOptions'] & {
1645
1838
  output: Output;
1646
1839
  include?: Array<Include>;
@@ -1662,28 +1855,31 @@ type KubbPluginEndContext = FilesContext & {
1662
1855
  config: Config;
1663
1856
  };
1664
1857
  /**
1665
- * Wraps a plugin factory and returns a function that accepts user options and
1666
- * yields a typed `Plugin`. Lifecycle handlers go inside a single `hooks` object.
1667
- *
1668
- * Pass a `PluginFactoryOptions` type parameter to get a typed `ctx` inside
1669
- * `kubb:plugin:setup`. Plugin names should follow the `plugin-<feature>`
1670
- * convention (`plugin-react-query`, `plugin-zod`, ...).
1858
+ * Defines a plugin from one object and returns a factory that takes the user's options.
1859
+ * Name plugins `plugin-<feature>`. Set `schema` to validate the options and apply their defaults
1860
+ * before `setup` receives them.
1671
1861
  *
1672
1862
  * @example
1673
1863
  * ```ts
1674
- * import { definePlugin } from '@kubb/core'
1675
- *
1676
- * export const pluginTs = definePlugin((options: { prefix?: string } = {}) => ({
1677
- * name: 'plugin-ts',
1678
- * hooks: {
1679
- * 'kubb:plugin:setup'(ctx) {
1680
- * ctx.setResolver(resolverTs)
1681
- * },
1864
+ * export const pluginZod = definePlugin<PluginZod>({
1865
+ * meta: { name: 'plugin-zod', compatibility: { kubb: '>=5.7.0' } },
1866
+ * dependencies: { 'plugin-ts': { optional: true } },
1867
+ * setup(options, kubb) {
1868
+ * kubb.addGenerator(zodGenerator)
1869
+ * return { ...options, inferred: options.inferred ?? false }
1682
1870
  * },
1683
- * }))
1871
+ * })
1684
1872
  * ```
1685
1873
  */
1686
- declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): (options?: TFactory['options']) => Plugin<TFactory>;
1874
+ declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(definition: PluginDefinition<TFactory>): PluginFactory<TFactory>;
1875
+ /**
1876
+ * Wraps a factory function that returns a `Plugin`. Without `meta`, the plugin gets `{ name }`.
1877
+ *
1878
+ * @deprecated Pass a definition object with `meta` and `setup` instead. The factory form is removed in the next major.
1879
+ */
1880
+ declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): ((options?: TFactory['options']) => Plugin<TFactory>) & {
1881
+ kind: 'plugin';
1882
+ };
1687
1883
  //#endregion
1688
1884
  //#region src/defineParser.d.ts
1689
1885
  /**
@@ -1691,11 +1887,7 @@ declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFact
1691
1887
  * written to disk. Kubb ships with TypeScript and TSX parsers. Add your own
1692
1888
  * for new file types (JSON, Markdown, ...).
1693
1889
  */
1694
- type Parser<TMeta extends object = object, TNode = unknown> = {
1695
- /**
1696
- * Display name used in diagnostics and the parser registry.
1697
- */
1698
- name: string;
1890
+ type Parser<TMeta extends object = object, TNode = unknown> = ExtensionNamed & {
1699
1891
  /**
1700
1892
  * File extensions this parser handles. The driver registers the parser for each
1701
1893
  * extension in this list. A parser with `undefined` here is not registered, so
@@ -1721,33 +1913,29 @@ type Parser<TMeta extends object = object, TNode = unknown> = {
1721
1913
  print(...nodes: Array<TNode>): string;
1722
1914
  };
1723
1915
  /**
1724
- * Wraps a parser factory and returns a function that accepts user options and
1725
- * yields a typed {@link Parser}. Mirrors {@link definePlugin}: the factory
1726
- * receives the caller's options, and calling the returned function without
1727
- * options passes an empty object.
1728
- *
1729
- * Register the result in the `parsers` array on `defineConfig`, calling it to
1730
- * apply options (`parserTs({ extension: { '.ts': '.js' } })`).
1731
- *
1732
- * @example
1733
- * ```ts
1734
- * import { defineParser } from '@kubb/core'
1735
- * import { extractStringsFromNodes } from '@kubb/ast'
1916
+ * The object passed to `defineParser`. `setup` receives the user's options and returns the parser methods.
1917
+ */
1918
+ type ParserDefinition<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = {
1919
+ meta: ExtensionMeta;
1920
+ setup(options: TOptions): Omit<Parser<TMeta, TNode>, 'name' | 'meta'>;
1921
+ };
1922
+ /**
1923
+ * The function `defineParser` returns. Call it with user options to get a `Parser`.
1924
+ */
1925
+ type ParserFactory<TOptions extends object = object, TMeta extends object = object, TNode = unknown> = ExtensionFactory<'parser', TOptions, Parser<TMeta, TNode>>;
1926
+ /**
1927
+ * Defines a parser from one object and returns a factory that takes the user's options.
1928
+ * Register the result in the `parsers` array on `defineConfig`.
1929
+ */
1930
+ declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(definition: ParserDefinition<TOptions, TMeta, TNode>): ParserFactory<TOptions, TMeta, TNode>;
1931
+ /**
1932
+ * Wraps a factory function that returns a `Parser`. Without `meta`, the parser gets `{ name }`.
1736
1933
  *
1737
- * export const parserJson = defineParser((options: { pretty?: boolean } = {}) => ({
1738
- * name: 'json',
1739
- * extNames: ['.json'],
1740
- * parse(file) {
1741
- * const source = file.sources.map((source) => extractStringsFromNodes(source.nodes ?? [])).join('\n')
1742
- * return options.pretty ? JSON.stringify(JSON.parse(source), null, 2) : source
1743
- * },
1744
- * print(...nodes) {
1745
- * return nodes.map(String).join('\n')
1746
- * },
1747
- * }))
1748
- * ```
1934
+ * @deprecated Pass a definition object with `meta` and `setup` instead. The factory form is removed in the next major.
1749
1935
  */
1750
- declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): (options?: TOptions) => Parser<TMeta, TNode>;
1936
+ declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): ((options?: TOptions) => Parser<TMeta, TNode>) & {
1937
+ kind: 'parser';
1938
+ };
1751
1939
  //#endregion
1752
1940
  //#region src/outputManifest.d.ts
1753
1941
  /**
@@ -1899,7 +2087,7 @@ declare class KubbDriver {
1899
2087
  readonly plugins: Map<string, NormalizedPlugin>;
1900
2088
  constructor(config: Config, options: Options);
1901
2089
  /**
1902
- * Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
2090
+ * Normalizes and checks every configured plugin, orders them, and registers their lifecycle handlers.
1903
2091
  * A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
1904
2092
  * `'post'`. When the config has an adapter, the adapter source is resolved from the input
1905
2093
  * so `run` can parse it later.
@@ -1907,7 +2095,7 @@ declare class KubbDriver {
1907
2095
  setup(): Promise<void>;
1908
2096
  get hooks(): Hookable<Kubb.KubbHooksRegistry>;
1909
2097
  /**
1910
- * Runs each plugin's `kubb:plugin:setup` handler, in plugin order, with a context scoped to that
2098
+ * Runs each plugin's `setup` and `kubb:plugin:setup` handler, in plugin order, with a context scoped to that
1911
2099
  * plugin so `addGenerator`, `setResolver`, `addMacro`, `setMacros`, and `setOptions` target its
1912
2100
  * `NormalizedPlugin` entry. Called once from `run` before the plugin execution loop begins, so
1913
2101
  * plugins can configure generators, resolvers, macros, and options before `buildStart`.
@@ -2034,7 +2222,10 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
2034
2222
  /**
2035
2223
  * The current plugin instance.
2036
2224
  */
2037
- plugin: Plugin<TOptions>;
2225
+ plugin: Plugin<TOptions> & {
2226
+ name: string;
2227
+ meta: ExtensionMeta;
2228
+ };
2038
2229
  /**
2039
2230
  * The current plugin's resolver. It decides what every generated symbol and file path is
2040
2231
  * called. Kubb picks a `setResolver` registration first, then the plugin's static
@@ -2910,5 +3101,5 @@ type BuildOutput = {
2910
3101
  storage: Storage;
2911
3102
  };
2912
3103
  //#endregion
2913
- export { Plugin as $, HookResult as A, createReporter as At, defineParser as B, ProblemDiagnostic as Bt, KubbMessageContext as C, createStorage as Ct, PossibleConfig as D, ReporterName as Dt, KubbWarnContext as E, ReporterContext as Et, defineGenerator as F, DiagnosticLocation as Ft, KubbPluginEndContext as G, AdapterFactoryOptions as Gt, Filter as H, UpdateDiagnostic as Ht, NodeCache as I, DiagnosticSeverity as It, NormalizedPlugin as J, KubbPluginSetupContext as K, AdapterSource as Kt, KubbDriver as L, Diagnostics as Lt, runHook as M, Diagnostic as Mt, Generator as N, DiagnosticDoc as Nt, PostGenerateCommand as O, ReporterPluginFiles as Ot, GeneratorContext as P, DiagnosticKind as Pt, Override as Q, FileManagerHooks as R, PerformanceDiagnostic as Rt, KubbLifecycleStartContext as S, Storage as St, KubbSuccessContext as T, Reporter as Tt, Group as U, Hookable as Ut, Exclude$1 as V, SerializedDiagnostic as Vt, Include as W, Adapter as Wt, OutputMode as X, Output as Y, OutputOptions as Z, KubbHookEndContext as _, ResolverPatch as _t, Input as a, BannerMeta as at, KubbHooks as b, RendererFactory as bt, KubbDiagnosticContext as c, ResolveFileOptions as ct, KubbFilesProcessingEndContext as d, ResolvePathOptions as dt, PluginFactoryOptions as et, KubbFilesProcessingStartContext as f, Resolver as ft, KubbGenerationSummaryContext as g, ResolverFilePathParams as gt, KubbGenerationStartContext as h, ResolverFileParams as ht, FilesContext as i, definePlugin as it, RunHookOptions as j, logLevel as jt, UserConfig as k, UserReporter as kt, KubbErrorContext as l, ResolveImportsOptions as lt, KubbGenerationEndContext as m, ResolverFile as mt, CLIOptions as n, ResolvePluginOptions as nt, KubbBuildEndContext as o, ResolveBannerContext as ot, KubbFilesProcessingUpdateContext as p, ResolverDefault as pt, KubbPluginStartContext as q, createAdapter as qt, Config as r, assertPluginOption as rt, KubbBuildStartContext as s, ResolveBannerFile as st, BuildOutput as t, PluginName as tt, KubbFileProcessingUpdate as u, ResolveOptionsContext as ut, KubbHookLineContext as v, ResolverPathParams as vt, KubbPluginsEndContext as w, GenerationResult as wt, KubbInfoContext as x, createRenderer as xt, KubbHookStartContext as y, Renderer as yt, Parser as z, ProblemCode as zt };
2914
- //# sourceMappingURL=types-BjZ8hdyZ.d.ts.map
3104
+ export { OutputOptions as $, ProblemCode as $t, HookResult as A, ExtensionMeta as At, ParserDefinition as B, ReporterContext as Bt, KubbMessageContext as C, ResolverPatch as Ct, PossibleConfig as D, ExtensionDependencyRecord as Dt, KubbWarnContext as E, ExtensionDependency as Et, defineGenerator as F, createRenderer as Ft, Group as G, logLevel as Gt, defineParser as H, ReporterPluginFiles as Ht, NodeCache as I, Storage as It, KubbPluginSetupContext as J, DiagnosticKind as Jt, Include as K, Diagnostic as Kt, KubbDriver as L, createStorage as Lt, runHook as M, StandardSchemaV1 as Mt, Generator as N, Renderer as Nt, PostGenerateCommand as O, ExtensionFactory as Ot, GeneratorContext as P, RendererFactory as Pt, OutputMode as Q, PerformanceDiagnostic as Qt, FileManagerHooks as R, GenerationResult as Rt, KubbLifecycleStartContext as S, ResolverFilePathParams as St, KubbSuccessContext as T, ExtensionDependencies as Tt, Exclude$1 as U, UserReporter as Ut, ParserFactory as V, ReporterName as Vt, Filter as W, createReporter as Wt, NormalizedPlugin as X, DiagnosticSeverity as Xt, KubbPluginStartContext as Y, DiagnosticLocation as Yt, Output as Z, Diagnostics as Zt, KubbHookEndContext as _, ResolvePathOptions as _t, Input as a, AdapterFactoryOptions as an, PluginName as at, KubbHooks as b, ResolverFile as bt, KubbDiagnosticContext as c, ResolvePluginOptions as ct, KubbFilesProcessingEndContext as d, BannerMeta as dt, ProblemDiagnostic as en, Override as et, KubbFilesProcessingStartContext as f, ResolveBannerContext as ft, KubbGenerationSummaryContext as g, ResolveOptionsContext as gt, KubbGenerationStartContext as h, ResolveImportsOptions as ht, FilesContext as i, Adapter as in, PluginFactoryOptions as it, RunHookOptions as j, resolveMeta as jt, UserConfig as k, ExtensionKind as kt, KubbErrorContext as l, assertPluginOption as lt, KubbGenerationEndContext as m, ResolveFileOptions as mt, CLIOptions as n, UpdateDiagnostic as nn, PluginDefinition as nt, KubbBuildEndContext as o, AdapterSource as on, PluginOptions as ot, KubbFilesProcessingUpdateContext as p, ResolveBannerFile as pt, KubbPluginEndContext as q, DiagnosticDoc as qt, Config as r, Hookable as rn, PluginFactory as rt, KubbBuildStartContext as s, createAdapter as sn, PluginType as st, BuildOutput as t, SerializedDiagnostic as tn, Plugin as tt, KubbFileProcessingUpdate as u, definePlugin as ut, KubbHookLineContext as v, Resolver as vt, KubbPluginsEndContext as w, ResolverPathParams as wt, KubbInfoContext as x, ResolverFileParams as xt, KubbHookStartContext as y, ResolverDefault as yt, Parser as z, Reporter as zt };
3105
+ //# sourceMappingURL=types-anBcq2U0.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "5.6.3",
3
+ "version": "5.8.0",
4
4
  "description": "Core engine for Kubb. Provides the plugin driver, file manager and build orchestration used by every Kubb plugin.",
5
5
  "keywords": [
6
6
  "code-generator",
@@ -72,9 +72,10 @@
72
72
  "registry": "https://registry.npmjs.org/"
73
73
  },
74
74
  "dependencies": {
75
- "@kubb/ast": "5.6.3",
75
+ "@kubb/ast": "5.8.0",
76
76
  "tinyexec": "^1.3.1",
77
- "unstorage": "^1.17.5"
77
+ "unstorage": "^1.17.5",
78
+ "verkit": "^0.5.0"
78
79
  },
79
80
  "devDependencies": {
80
81
  "@internals/utils": "0.0.1",