@kubb/core 5.0.0-alpha.4 → 5.0.0-alpha.41

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.
Files changed (71) hide show
  1. package/dist/PluginDriver-BQwm8hDd.cjs +1729 -0
  2. package/dist/PluginDriver-BQwm8hDd.cjs.map +1 -0
  3. package/dist/PluginDriver-CgXFtmNP.js +1617 -0
  4. package/dist/PluginDriver-CgXFtmNP.js.map +1 -0
  5. package/dist/index.cjs +915 -1901
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +268 -264
  8. package/dist/index.js +894 -1863
  9. package/dist/index.js.map +1 -1
  10. package/dist/mocks.cjs +164 -0
  11. package/dist/mocks.cjs.map +1 -0
  12. package/dist/mocks.d.ts +74 -0
  13. package/dist/mocks.js +159 -0
  14. package/dist/mocks.js.map +1 -0
  15. package/dist/types-C6NCtNqM.d.ts +2151 -0
  16. package/package.json +11 -14
  17. package/src/FileManager.ts +131 -0
  18. package/src/FileProcessor.ts +84 -0
  19. package/src/Kubb.ts +174 -85
  20. package/src/PluginDriver.ts +941 -0
  21. package/src/constants.ts +33 -43
  22. package/src/createAdapter.ts +25 -0
  23. package/src/createKubb.ts +605 -0
  24. package/src/createPlugin.ts +31 -0
  25. package/src/createRenderer.ts +57 -0
  26. package/src/createStorage.ts +58 -0
  27. package/src/defineGenerator.ts +88 -100
  28. package/src/defineLogger.ts +13 -3
  29. package/src/defineParser.ts +45 -0
  30. package/src/definePlugin.ts +90 -7
  31. package/src/defineResolver.ts +453 -0
  32. package/src/devtools.ts +14 -14
  33. package/src/index.ts +12 -17
  34. package/src/mocks.ts +234 -0
  35. package/src/renderNode.ts +35 -0
  36. package/src/storages/fsStorage.ts +29 -9
  37. package/src/storages/memoryStorage.ts +2 -2
  38. package/src/types.ts +821 -152
  39. package/src/utils/TreeNode.ts +47 -9
  40. package/src/utils/diagnostics.ts +4 -1
  41. package/src/utils/executeStrategies.ts +16 -13
  42. package/src/utils/getBarrelFiles.ts +88 -15
  43. package/src/utils/isInputPath.ts +10 -0
  44. package/src/utils/packageJSON.ts +75 -0
  45. package/dist/chunk-ByKO4r7w.cjs +0 -38
  46. package/dist/hooks.cjs +0 -50
  47. package/dist/hooks.cjs.map +0 -1
  48. package/dist/hooks.d.ts +0 -49
  49. package/dist/hooks.js +0 -46
  50. package/dist/hooks.js.map +0 -1
  51. package/dist/types-Bbh1o0yW.d.ts +0 -1057
  52. package/src/BarrelManager.ts +0 -74
  53. package/src/PackageManager.ts +0 -180
  54. package/src/PluginManager.ts +0 -668
  55. package/src/PromiseManager.ts +0 -40
  56. package/src/build.ts +0 -420
  57. package/src/config.ts +0 -56
  58. package/src/defineAdapter.ts +0 -22
  59. package/src/defineStorage.ts +0 -56
  60. package/src/errors.ts +0 -1
  61. package/src/hooks/index.ts +0 -8
  62. package/src/hooks/useKubb.ts +0 -22
  63. package/src/hooks/useMode.ts +0 -11
  64. package/src/hooks/usePlugin.ts +0 -11
  65. package/src/hooks/usePluginManager.ts +0 -11
  66. package/src/utils/FunctionParams.ts +0 -155
  67. package/src/utils/formatters.ts +0 -56
  68. package/src/utils/getConfigs.ts +0 -30
  69. package/src/utils/getPlugins.ts +0 -23
  70. package/src/utils/linters.ts +0 -25
  71. package/src/utils/resolveOptions.ts +0 -93
package/dist/index.d.ts CHANGED
@@ -1,162 +1,301 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { A as UserPluginWithLifeCycle, B as formatters, C as PrinterFactoryOptions, D as UserConfig, E as UnknownUserPlugin, F as KubbEvents, H as logLevel, I as PluginManager, L as getMode, M as Generator, N as ReactGeneratorV2, O as UserLogger, P as defineGenerator, R as DefineStorage, S as Printer, T as ResolvePathParams, U as AsyncEventEmitter, V as linters, W as URLPath, _ as PluginFactoryOptions, a as Config, b as PluginParameter, c as Group, d as Logger, f as LoggerContext, g as PluginContext, h as Plugin, i as BarrelType, j as CoreGeneratorV2, k as UserPlugin, l as InputData, m as Output, n as AdapterFactoryOptions, o as DevtoolsOptions, p as LoggerOptions, r as AdapterSource, s as GetPluginFactoryOptions, t as Adapter, u as InputPath, v as PluginLifecycle, w as ResolveNameParams, x as PluginWithLifeCycle, y as PluginLifecycleHooks, z as defineStorage } from "./types-Bbh1o0yW.js";
3
- import { definePrinter } from "@kubb/ast";
4
- import { Fabric } from "@kubb/react-fabric";
5
- import { Node } from "@kubb/ast/types";
6
- import { KubbFile } from "@kubb/fabric-core/types";
2
+ import { $ as KubbHooks, A as PluginParameter, B as ResolverFileParams, C as Output, D as PluginFactoryOptions, E as PluginContext, F as ResolveOptionsContext, G as UserLogger, H as SchemaHook, I as ResolvePathOptions, J as FileMetaBase, K as UserPlugin, L as ResolvePathParams, M as PossibleConfig, N as ResolveBannerContext, O as PluginLifecycle, P as ResolveNameParams, Q as Kubb, R as Resolver, S as OperationsHook, T as Plugin, U as UserConfig, V as ResolverPathParams, W as UserGroup, X as PluginHooks, Y as HookStylePlugin, Z as definePlugin, _ as KubbPluginSetupContext, a as CLIOptions, at as defineParser, b as LoggerOptions, c as DevtoolsOptions, ct as Storage, d as Group, dt as RendererFactory, et as BuildOutput, f as Include, ft as createRenderer, g as KubbBuildStartContext, h as KubbBuildEndContext, i as BarrelType, it as Parser, j as PluginWithLifeCycle, k as PluginLifecycleHooks, l as Exclude, lt as createStorage, m as InputPath, mt as AsyncEventEmitter, n as AdapterFactoryOptions, nt as PluginDriver, o as CompatibilityPreset, ot as Generator, p as InputData, pt as logLevel, q as UserPluginWithLifeCycle, r as AdapterSource, rt as FileManager, s as Config, st as defineGenerator, t as Adapter, tt as createKubb, u as GeneratorContext, ut as Renderer, v as Logger, w as Override, x as OperationHook, y as LoggerContext, z as ResolverContext } from "./types-C6NCtNqM.js";
3
+ import * as ast from "@kubb/ast";
4
+ import { FileNode, InputNode, Node } from "@kubb/ast";
7
5
 
8
- //#region src/build.d.ts
9
- type BuildOptions = {
10
- config: UserConfig;
11
- events?: AsyncEventEmitter<KubbEvents>;
12
- };
13
- type BuildOutput = {
14
- failedPlugins: Set<{
15
- plugin: Plugin;
16
- error: Error;
17
- }>;
18
- fabric: Fabric;
19
- files: Array<KubbFile.ResolvedFile>;
20
- pluginManager: PluginManager;
21
- pluginTimings: Map<string, number>;
22
- error?: Error;
23
- sources: Map<KubbFile.Path, string>;
6
+ //#region ../../internals/utils/src/urlPath.d.ts
7
+ type URLObject = {
8
+ /**
9
+ * The resolved URL string (Express-style or template literal, depending on context).
10
+ */
11
+ url: string;
12
+ /**
13
+ * Extracted path parameters as a key-value map, or `undefined` when the path has none.
14
+ */
15
+ params?: Record<string, string>;
24
16
  };
25
- type SetupResult = {
26
- events: AsyncEventEmitter<KubbEvents>;
27
- fabric: Fabric;
28
- pluginManager: PluginManager;
29
- sources: Map<KubbFile.Path, string>;
17
+ type ObjectOptions = {
18
+ /**
19
+ * Controls whether the `url` is rendered as an Express path or a template literal.
20
+ * @default 'path'
21
+ */
22
+ type?: 'path' | 'template';
23
+ /**
24
+ * Optional transform applied to each extracted parameter name.
25
+ */
26
+ replacer?: (pathParam: string) => string;
27
+ /**
28
+ * When `true`, the result is serialized to a string expression instead of a plain object.
29
+ */
30
+ stringify?: boolean;
30
31
  };
31
- declare function setup(options: BuildOptions): Promise<SetupResult>;
32
- declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
33
- declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
34
- //#endregion
35
- //#region src/config.d.ts
36
32
  /**
37
- * CLI options derived from command-line flags.
33
+ * Supported identifier casing strategies for path parameters.
38
34
  */
39
- type CLIOptions = {
40
- /** Path to `kubb.config.js` */config?: string; /** Enable watch mode for input files */
41
- watch?: boolean;
35
+ type PathCasing = 'camelcase';
36
+ type Options = {
42
37
  /**
43
- * Logging verbosity for CLI usage.
44
- *
45
- * - `silent`: hide non-essential logs
46
- * - `info`: show general logs (non-plugin-related)
47
- * - `debug`: include detailed plugin lifecycle logs
48
- * @default 'silent'
38
+ * Casing strategy applied to path parameter names.
39
+ * @default undefined (original identifier preserved)
49
40
  */
50
- logLevel?: 'silent' | 'info' | 'debug'; /** Run Kubb with Bun */
51
- bun?: boolean;
41
+ casing?: PathCasing;
52
42
  };
53
- /** All accepted forms of a Kubb configuration. */
54
- type ConfigInput = PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>);
55
43
  /**
56
- * Helper for defining a Kubb configuration.
57
- *
58
- * Accepts either:
59
- * - A config object or array of configs
60
- * - A function returning the config(s), optionally async,
61
- * receiving the CLI options as argument
44
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
62
45
  *
63
46
  * @example
64
- * export default defineConfig(({ logLevel }) => ({
65
- * root: 'src',
66
- * plugins: [myPlugin()],
67
- * }))
47
+ * const p = new URLPath('/pet/{petId}')
48
+ * p.URL // '/pet/:petId'
49
+ * p.template // '`/pet/${petId}`'
68
50
  */
69
- declare function defineConfig(config: (cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>): typeof config;
70
- declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]>): typeof config;
51
+ declare class URLPath {
52
+ #private;
53
+ /**
54
+ * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
55
+ */
56
+ path: string;
57
+ constructor(path: string, options?: Options);
58
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * new URLPath('/pet/{petId}').URL // '/pet/:petId'
63
+ * ```
64
+ */
65
+ get URL(): string;
66
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
71
+ * new URLPath('/pet/{petId}').isURL // false
72
+ * ```
73
+ */
74
+ get isURL(): boolean;
75
+ /**
76
+ * Converts the OpenAPI path to a TypeScript template literal string.
77
+ *
78
+ * @example
79
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
80
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
81
+ */
82
+ get template(): string;
83
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * new URLPath('/pet/{petId}').object
88
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
89
+ * ```
90
+ */
91
+ get object(): URLObject | string;
92
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * new URLPath('/pet/{petId}').params // { petId: 'petId' }
97
+ * new URLPath('/pet').params // undefined
98
+ * ```
99
+ */
100
+ get params(): Record<string, string> | undefined;
101
+ toObject({
102
+ type,
103
+ replacer,
104
+ stringify
105
+ }?: ObjectOptions): URLObject | string;
106
+ /**
107
+ * Converts the OpenAPI path to a TypeScript template literal string.
108
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
109
+ *
110
+ * @example
111
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
112
+ */
113
+ toTemplateString({
114
+ prefix,
115
+ replacer
116
+ }?: {
117
+ prefix?: string;
118
+ replacer?: (pathParam: string) => string;
119
+ }): string;
120
+ /**
121
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
122
+ * An optional `replacer` transforms each parameter name in both key and value positions.
123
+ * Returns `undefined` when no path parameters are found.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
128
+ * // { petId: 'petId', tagId: 'tagId' }
129
+ * ```
130
+ */
131
+ getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
132
+ /** Converts the OpenAPI path to Express-style colon syntax.
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
137
+ * ```
138
+ */
139
+ toURLPath(): string;
140
+ }
141
+ //#endregion
142
+ //#region src/createAdapter.d.ts
71
143
  /**
72
- * Type guard to check if a given config has an `input.path`.
144
+ * Builder type for an {@link Adapter} takes options and returns the adapter instance.
73
145
  */
74
- declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
75
- //#endregion
76
- //#region src/defineAdapter.d.ts
77
146
  type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
78
147
  /**
79
- * Wraps an adapter builder to make the options parameter optional.
148
+ * Creates an adapter factory. Call the returned function with optional options to get the adapter instance.
80
149
  *
81
150
  * @example
82
- * ```ts
83
- * export const adapterOas = defineAdapter<OasAdapter>((options) => {
84
- * const { validate = true, dateType = 'string' } = options
151
+ * export const myAdapter = createAdapter<MyAdapter>((options) => {
85
152
  * return {
86
- * name: adapterOasName,
87
- * options: { validate, dateType, ... },
88
- * parse(source) { ... },
153
+ * name: 'my-adapter',
154
+ * options,
155
+ * async parse(source) { ... },
89
156
  * }
90
157
  * })
91
- * ```
158
+ *
159
+ * // instantiate
160
+ * const adapter = myAdapter({ validate: true })
92
161
  */
93
- declare function defineAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
162
+ declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
94
163
  //#endregion
95
164
  //#region src/defineLogger.d.ts
96
- declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
97
- //#endregion
98
- //#region src/definePlugin.d.ts
99
- type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
100
165
  /**
101
- * Wraps a plugin builder to make the options parameter optional.
166
+ * Wraps a logger definition into a typed {@link Logger}.
167
+ *
168
+ * @example
169
+ * export const myLogger = defineLogger({
170
+ * name: 'my-logger',
171
+ * install(context, options) {
172
+ * context.on('kubb:info', (message) => console.log('ℹ', message))
173
+ * context.on('kubb:error', (error) => console.error('✗', error.message))
174
+ * },
175
+ * })
102
176
  */
103
- declare function definePlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(build: PluginBuilder<T>): (options?: T['options']) => UserPluginWithLifeCycle<T>;
104
- //#endregion
105
- //#region src/PackageManager.d.ts
106
- type PackageJSON = {
107
- dependencies?: Record<string, string>;
108
- devDependencies?: Record<string, string>;
109
- };
110
- type DependencyName = string;
111
- type DependencyVersion = string;
112
- declare class PackageManager {
113
- #private;
114
- constructor(workspace?: string);
115
- set workspace(workspace: string);
116
- get workspace(): string | undefined;
117
- normalizeDirectory(directory: string): string;
118
- getLocation(path: string): string;
119
- import(path: string): Promise<unknown>;
120
- getPackageJSON(): Promise<PackageJSON | undefined>;
121
- getPackageJSONSync(): PackageJSON | undefined;
122
- static setVersion(dependency: DependencyName, version: DependencyVersion): void;
123
- getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined>;
124
- getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined;
125
- isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean>;
126
- isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
127
- }
177
+ declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
128
178
  //#endregion
129
- //#region src/utils/executeStrategies.d.ts
130
- type PromiseFunc$1<T = unknown, T2 = never> = (state?: T) => T2 extends never ? Promise<T> : Promise<T> | T2;
131
- type ValueOfPromiseFuncArray<TInput extends Array<unknown>> = TInput extends Array<PromiseFunc$1<infer X, infer Y>> ? X | Y : never;
132
- type SeqOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<Array<Awaited<ValueOfPromiseFuncArray<TInput>>>>;
179
+ //#region src/defineResolver.d.ts
133
180
  /**
134
- * Chains promises
181
+ * Builder type for the plugin-specific resolver fields.
182
+ *
183
+ * `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
184
+ * are optional — built-in fallbacks are injected when omitted.
135
185
  */
136
- type HookFirstOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue = unknown> = ValueOfPromiseFuncArray<TInput>;
186
+ type ResolverBuilder<T extends PluginFactoryOptions> = () => Omit<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter' | 'name' | 'pluginName'> & Partial<Pick<T['resolver'], 'default' | 'resolveOptions' | 'resolvePath' | 'resolveFile' | 'resolveBanner' | 'resolveFooter'>> & {
187
+ name: string;
188
+ pluginName: T['name'];
189
+ } & ThisType<T['resolver']>;
137
190
  /**
138
- * Chains promises, first non-null result stops and returns
191
+ * Default option resolver applies include/exclude filters and merges matching override options.
192
+ *
193
+ * Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
194
+ *
195
+ * @example Include/exclude filtering
196
+ * ```ts
197
+ * const options = defaultResolveOptions(operationNode, {
198
+ * options: { output: 'types' },
199
+ * exclude: [{ type: 'tag', pattern: 'internal' }],
200
+ * })
201
+ * // → null when node has tag 'internal'
202
+ * ```
203
+ *
204
+ * @example Override merging
205
+ * ```ts
206
+ * const options = defaultResolveOptions(operationNode, {
207
+ * options: { enumType: 'asConst' },
208
+ * override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
209
+ * })
210
+ * // → { enumType: 'enum' } when operationId matches
211
+ * ```
139
212
  */
140
- type HookParallelOutput<TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = Promise<PromiseSettledResult<Awaited<ValueOfPromiseFuncArray<TInput>>>[]>;
141
213
  /**
142
- * Runs an array of promise functions with optional concurrency limit.
214
+ * Defines a resolver for a plugin, injecting built-in defaults for name casing,
215
+ * include/exclude/override filtering, path resolution, and file construction.
216
+ *
217
+ * All four defaults can be overridden by providing them in the builder function:
218
+ * - `default` — name casing strategy (camelCase / PascalCase)
219
+ * - `resolveOptions` — include/exclude/override filtering
220
+ * - `resolvePath` — output path computation
221
+ * - `resolveFile` — full `FileNode` construction
222
+ *
223
+ * Methods in the builder have access to `this` (the full resolver object), so they
224
+ * can call other resolver methods without circular imports.
225
+ *
226
+ * @example Basic resolver with naming helpers
227
+ * ```ts
228
+ * export const resolver = defineResolver<PluginTs>(() => ({
229
+ * name: 'default',
230
+ * resolveName(node) {
231
+ * return this.default(node.name, 'function')
232
+ * },
233
+ * resolveTypedName(node) {
234
+ * return this.default(node.name, 'type')
235
+ * },
236
+ * }))
237
+ * ```
238
+ *
239
+ * @example Override resolvePath for a custom output structure
240
+ * ```ts
241
+ * export const resolver = defineResolver<PluginTs>(() => ({
242
+ * name: 'custom',
243
+ * resolvePath({ baseName }, { root, output }) {
244
+ * return path.resolve(root, output.path, 'generated', baseName)
245
+ * },
246
+ * }))
247
+ * ```
248
+ *
249
+ * @example Use this.default inside a helper
250
+ * ```ts
251
+ * export const resolver = defineResolver<PluginTs>(() => ({
252
+ * name: 'default',
253
+ * resolveParamName(node, param) {
254
+ * return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
255
+ * },
256
+ * }))
257
+ * ```
143
258
  */
144
- type Strategy = 'seq' | 'first' | 'parallel';
145
- type StrategySwitch<TStrategy extends Strategy, TInput extends Array<PromiseFunc$1<TValue, null>>, TValue> = TStrategy extends 'first' ? HookFirstOutput<TInput, TValue> : TStrategy extends 'seq' ? SeqOutput<TInput, TValue> : TStrategy extends 'parallel' ? HookParallelOutput<TInput, TValue> : never;
259
+ declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
146
260
  //#endregion
147
- //#region src/PromiseManager.d.ts
148
- type PromiseFunc<T = unknown, T2 = never> = () => T2 extends never ? Promise<T> : Promise<T> | T2;
149
- type Options<TState = unknown> = {
150
- nullCheck?: (state: TState) => boolean;
261
+ //#region src/FileProcessor.d.ts
262
+ type ParseOptions = {
263
+ parsers?: Map<FileNode['extname'], Parser>;
264
+ extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
265
+ };
266
+ type RunOptions = ParseOptions & {
267
+ /**
268
+ * @default 'sequential'
269
+ */
270
+ mode?: 'sequential' | 'parallel';
271
+ onStart?: (files: Array<FileNode>) => Promise<void> | void;
272
+ onEnd?: (files: Array<FileNode>) => Promise<void> | void;
273
+ onUpdate?: (params: {
274
+ file: FileNode;
275
+ source?: string;
276
+ processed: number;
277
+ total: number;
278
+ percentage: number;
279
+ }) => Promise<void> | void;
151
280
  };
152
- declare class PromiseManager<TState = unknown> {
281
+ /**
282
+ * Converts a single file to a string using the registered parsers.
283
+ * Falls back to joining source values when no matching parser is found.
284
+ */
285
+ declare class FileProcessor {
153
286
  #private;
154
- constructor(options?: Options<TState>);
155
- run<TInput extends Array<PromiseFunc<TValue, null>>, TValue, TStrategy extends Strategy, TOutput = StrategySwitch<TStrategy, TInput, TValue>>(strategy: TStrategy, promises: TInput, {
156
- concurrency
157
- }?: {
158
- concurrency?: number;
159
- }): TOutput;
287
+ parse(file: FileNode, {
288
+ parsers,
289
+ extension
290
+ }?: ParseOptions): Promise<string>;
291
+ run(files: Array<FileNode>, {
292
+ parsers,
293
+ mode,
294
+ extension,
295
+ onStart,
296
+ onEnd,
297
+ onUpdate
298
+ }?: RunOptions): Promise<Array<FileNode>>;
160
299
  }
161
300
  //#endregion
162
301
  //#region src/storages/fsStorage.d.ts
@@ -183,7 +322,7 @@ declare class PromiseManager<TState = unknown> {
183
322
  * })
184
323
  * ```
185
324
  */
186
- declare const fsStorage: (options?: Record<string, never> | undefined) => DefineStorage;
325
+ declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
187
326
  //#endregion
188
327
  //#region src/storages/memoryStorage.d.ts
189
328
  /**
@@ -203,149 +342,14 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Define
203
342
  * })
204
343
  * ```
205
344
  */
206
- declare const memoryStorage: (options?: Record<string, never> | undefined) => DefineStorage;
345
+ declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
207
346
  //#endregion
208
- //#region src/utils/FunctionParams.d.ts
209
- type FunctionParamsASTWithoutType = {
210
- name?: string;
211
- type?: string;
212
- /**
213
- * @default true
214
- */
215
- required?: boolean;
216
- /**
217
- * @default true
218
- */
219
- enabled?: boolean;
220
- default?: string;
221
- };
222
- type FunctionParamsASTWithType = {
223
- name?: never;
224
- type: string;
225
- /**
226
- * @default true
227
- */
228
- required?: boolean;
229
- /**
230
- * @default true
231
- */
232
- enabled?: boolean;
233
- default?: string;
234
- };
235
- /**
236
- * @deprecated
237
- */
238
- type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
347
+ //#region src/utils/isInputPath.d.ts
239
348
  /**
240
- * @deprecated
241
- */
242
- declare class FunctionParams {
243
- #private;
244
- get items(): FunctionParamsAST[];
245
- add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams;
246
- static toObject(items: FunctionParamsAST[]): FunctionParamsAST;
247
- toObject(): FunctionParamsAST;
248
- static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string;
249
- toString(): string;
250
- }
251
- //#endregion
252
- //#region src/utils/formatters.d.ts
253
- type Formatter = keyof typeof formatters;
254
- /**
255
- * Detect which formatter is available in the system.
256
- *
257
- * @returns Promise that resolves to the first available formatter or undefined if none are found
258
- *
259
- * @remarks
260
- * Checks in order of preference: biome, oxfmt, prettier.
261
- * Uses the `--version` flag to detect if each formatter command is available.
262
- * This is a reliable method as all supported formatters implement this flag.
263
- *
264
- * @example
265
- * ```typescript
266
- * const formatter = await detectFormatter()
267
- * if (formatter) {
268
- * console.log(`Using ${formatter} for formatting`)
269
- * } else {
270
- * console.log('No formatter found')
271
- * }
272
- * ```
273
- */
274
- declare function detectFormatter(): Promise<Formatter | undefined>;
275
- //#endregion
276
- //#region src/utils/getBarrelFiles.d.ts
277
- type FileMetaBase = {
278
- pluginName?: string;
279
- };
280
- type AddIndexesProps = {
281
- type: BarrelType | false | undefined;
282
- /**
283
- * Root based on root and output.path specified in the config
284
- */
285
- root: string;
286
- /**
287
- * Output for plugin
288
- */
289
- output: {
290
- path: string;
291
- };
292
- group?: {
293
- output: string;
294
- exportAs: string;
295
- };
296
- meta?: FileMetaBase;
297
- };
298
- declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
299
- type,
300
- meta,
301
- root,
302
- output
303
- }: AddIndexesProps): Promise<KubbFile.File[]>;
304
- //#endregion
305
- //#region src/utils/getConfigs.d.ts
306
- /**
307
- * Converting UserConfig to Config Array without a change in the object beside the JSON convert.
308
- */
309
- declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions): Promise<Array<Config>>;
310
- //#endregion
311
- //#region src/utils/linters.d.ts
312
- type Linter = keyof typeof linters;
313
- declare function detectLinter(): Promise<Linter | undefined>;
314
- //#endregion
315
- //#region src/utils/resolveOptions.d.ts
316
- type FilterItem = {
317
- type: string;
318
- pattern: string | RegExp;
319
- };
320
- type OverrideItem<TOptions> = FilterItem & {
321
- options: Partial<TOptions>;
322
- };
323
- type ResolveOptionsContext<TOptions> = {
324
- options: TOptions;
325
- exclude?: Array<FilterItem>;
326
- include?: Array<FilterItem>;
327
- override?: Array<OverrideItem<TOptions>>;
328
- };
329
- /**
330
- * Resolves the effective plugin options for a given AST node by applying
331
- * `exclude`, `include`, and `override` rules from the plugin configuration.
332
- *
333
- * Returns `null` when the node is excluded or not matched by `include`.
334
- * Returns the merged options (base options merged with any matching `override`) otherwise.
335
- *
336
- * Supported filter types for `OperationNode`: `tag`, `operationId`, `path`, `method`.
337
- * Supported filter types for `SchemaNode`: `schemaName`.
338
- *
339
- * @example
340
- * const resolved = resolveOptions(operationNode, { options, exclude, include, override })
341
- * if (!resolved) return // excluded
349
+ * Type guard to check if a given config has an `input.path`.
342
350
  */
343
- declare function resolveOptions<TOptions>(node: Node, {
344
- options,
345
- exclude,
346
- include,
347
- override
348
- }: ResolveOptionsContext<TOptions>): TOptions | null;
351
+ declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
352
+ declare function isInputPath(config: Config | undefined): config is Config<InputPath>;
349
353
  //#endregion
350
- export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, Config, type ConfigInput, CoreGeneratorV2, DefineStorage, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, GetPluginFactoryOptions, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, Printer, PrinterFactoryOptions, PromiseManager, ReactGeneratorV2, ResolveNameParams, ResolvePathParams, URLPath, UnknownUserPlugin, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineAdapter, defineConfig, defineGenerator, defineLogger, definePlugin, definePrinter, defineStorage, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, resolveOptions, safeBuild, setup };
354
+ export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, BuildOutput, CLIOptions, CompatibilityPreset, Config, DevtoolsOptions, Exclude, FileManager, FileMetaBase, FileProcessor, Generator, GeneratorContext, Group, HookStylePlugin, Include, InputData, InputPath, Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbHooks, KubbPluginSetupContext, Logger, LoggerContext, LoggerOptions, OperationHook, OperationsHook, Output, Override, Parser, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginHooks, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, PossibleConfig, Renderer, RendererFactory, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, SchemaHook, Storage, URLPath, UserConfig, UserGroup, UserLogger, UserPlugin, UserPluginWithLifeCycle, ast, createAdapter, createKubb, createRenderer, createStorage, defineGenerator, defineLogger, defineParser, definePlugin, defineResolver, fsStorage, isInputPath, logLevel, memoryStorage };
351
355
  //# sourceMappingURL=index.d.ts.map