@kubb/core 5.0.0-alpha.2 → 5.0.0-alpha.21
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/{types-B7eZvqwD.d.ts → PluginDriver-CEQPafXV.d.ts} +687 -298
- package/dist/hooks.cjs +15 -9
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +11 -5
- package/dist/hooks.js +16 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +1131 -536
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +674 -89
- package/dist/index.js +1114 -532
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/Kubb.ts +37 -55
- package/src/{PluginManager.ts → PluginDriver.ts} +51 -40
- package/src/build.ts +74 -29
- package/src/config.ts +9 -8
- package/src/constants.ts +44 -1
- package/src/createAdapter.ts +25 -0
- package/src/createPlugin.ts +28 -0
- package/src/createStorage.ts +58 -0
- package/src/defineBuilder.ts +26 -0
- package/src/defineGenerator.ts +137 -0
- package/src/defineLogger.ts +13 -3
- package/src/definePreset.ts +27 -0
- package/src/definePresets.ts +16 -0
- package/src/defineResolver.ts +448 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useDriver.ts +8 -0
- package/src/hooks/useMode.ts +5 -2
- package/src/hooks/usePlugin.ts +5 -2
- package/src/index.ts +21 -6
- package/src/renderNode.tsx +105 -0
- package/src/storages/fsStorage.ts +2 -2
- package/src/storages/memoryStorage.ts +2 -2
- package/src/types.ts +342 -42
- package/src/utils/FunctionParams.ts +2 -2
- package/src/utils/TreeNode.ts +24 -1
- package/src/utils/diagnostics.ts +4 -1
- package/src/utils/executeStrategies.ts +23 -10
- package/src/utils/formatters.ts +10 -21
- package/src/utils/getBarrelFiles.ts +79 -9
- package/src/utils/getConfigs.ts +8 -22
- package/src/utils/getPreset.ts +52 -0
- package/src/utils/linters.ts +23 -3
- package/src/utils/mergeResolvers.ts +8 -0
- package/src/utils/packageJSON.ts +76 -0
- package/src/BarrelManager.ts +0 -74
- package/src/PackageManager.ts +0 -180
- package/src/PromiseManager.ts +0 -40
- package/src/defineAdapter.ts +0 -22
- package/src/definePlugin.ts +0 -12
- package/src/defineStorage.ts +0 -56
- package/src/errors.ts +0 -1
- package/src/hooks/usePluginManager.ts +0 -8
- package/src/utils/getPlugins.ts +0 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,34 +1,213 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { $ as formatters, A as Printer, B as ResolverPathParams, C as PluginFactoryOptions, D as PluginWithLifeCycle, E as PluginParameter, F as ResolvePathOptions, G as UserResolver, H as UserLogger, I as ResolvePathParams, J as Generator, K as KubbEvents, L as Resolver, M as ResolveBannerContext, N as ResolveNameParams, O as Preset, P as ResolveOptionsContext, Q as createStorage, R as ResolverContext, S as PluginContext, T as PluginLifecycleHooks, U as UserPlugin, V as UserConfig, W as UserPluginWithLifeCycle, X as defineGenerator, Y as ReactGeneratorV2, Z as Storage, _ as LoggerContext, a as AdapterSource, b as Override, c as CompatibilityPreset, d as Exclude, et as linters, f as Group, g as Logger, h as InputPath, i as AdapterFactoryOptions, j as PrinterFactoryOptions, k as Presets, l as Config, m as InputData, n as getMode, nt as PossiblePromise, o as BarrelType, p as Include, q as CoreGeneratorV2, r as Adapter, rt as AsyncEventEmitter, s as Builder, t as PluginDriver, tt as logLevel, u as DevtoolsOptions, v as LoggerOptions, w as PluginLifecycle, x as Plugin, y as Output, z as ResolverFileParams } from "./PluginDriver-CEQPafXV.js";
|
|
3
3
|
import { definePrinter } from "@kubb/ast";
|
|
4
|
-
import {
|
|
5
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
|
+
import { Node, OperationNode, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
|
|
5
|
+
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
6
|
+
import { Fabric as Fabric$1 } from "@kubb/react-fabric/types";
|
|
6
7
|
|
|
8
|
+
//#region ../../internals/utils/src/urlPath.d.ts
|
|
9
|
+
type URLObject = {
|
|
10
|
+
/**
|
|
11
|
+
* The resolved URL string (Express-style or template literal, depending on context).
|
|
12
|
+
*/
|
|
13
|
+
url: string;
|
|
14
|
+
/**
|
|
15
|
+
* Extracted path parameters as a key-value map, or `undefined` when the path has none.
|
|
16
|
+
*/
|
|
17
|
+
params?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
type ObjectOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* Controls whether the `url` is rendered as an Express path or a template literal.
|
|
22
|
+
* @default 'path'
|
|
23
|
+
*/
|
|
24
|
+
type?: 'path' | 'template';
|
|
25
|
+
/**
|
|
26
|
+
* Optional transform applied to each extracted parameter name.
|
|
27
|
+
*/
|
|
28
|
+
replacer?: (pathParam: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* When `true`, the result is serialized to a string expression instead of a plain object.
|
|
31
|
+
*/
|
|
32
|
+
stringify?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Supported identifier casing strategies for path parameters.
|
|
36
|
+
*/
|
|
37
|
+
type PathCasing = 'camelcase';
|
|
38
|
+
type Options = {
|
|
39
|
+
/**
|
|
40
|
+
* Casing strategy applied to path parameter names.
|
|
41
|
+
* @default undefined (original identifier preserved)
|
|
42
|
+
*/
|
|
43
|
+
casing?: PathCasing;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const p = new URLPath('/pet/{petId}')
|
|
50
|
+
* p.URL // '/pet/:petId'
|
|
51
|
+
* p.template // '`/pet/${petId}`'
|
|
52
|
+
*/
|
|
53
|
+
declare class URLPath {
|
|
54
|
+
#private;
|
|
55
|
+
/**
|
|
56
|
+
* The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
|
|
57
|
+
*/
|
|
58
|
+
path: string;
|
|
59
|
+
constructor(path: string, options?: Options);
|
|
60
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* new URLPath('/pet/{petId}').URL // '/pet/:petId'
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
get URL(): string;
|
|
68
|
+
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
|
|
73
|
+
* new URLPath('/pet/{petId}').isURL // false
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
get isURL(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
82
|
+
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
83
|
+
*/
|
|
84
|
+
get template(): string;
|
|
85
|
+
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* new URLPath('/pet/{petId}').object
|
|
90
|
+
* // { url: '/pet/:petId', params: { petId: 'petId' } }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
get object(): URLObject | string;
|
|
94
|
+
/** Returns a map of path parameter names, or `undefined` when the path has no parameters.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* new URLPath('/pet/{petId}').params // { petId: 'petId' }
|
|
99
|
+
* new URLPath('/pet').params // undefined
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
get params(): Record<string, string> | undefined;
|
|
103
|
+
toObject({
|
|
104
|
+
type,
|
|
105
|
+
replacer,
|
|
106
|
+
stringify
|
|
107
|
+
}?: ObjectOptions): URLObject | string;
|
|
108
|
+
/**
|
|
109
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
110
|
+
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
114
|
+
*/
|
|
115
|
+
toTemplateString({
|
|
116
|
+
prefix,
|
|
117
|
+
replacer
|
|
118
|
+
}?: {
|
|
119
|
+
prefix?: string;
|
|
120
|
+
replacer?: (pathParam: string) => string;
|
|
121
|
+
}): string;
|
|
122
|
+
/**
|
|
123
|
+
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
124
|
+
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
125
|
+
* Returns `undefined` when no path parameters are found.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* new URLPath('/pet/{petId}/tag/{tagId}').getParams()
|
|
130
|
+
* // { petId: 'petId', tagId: 'tagId' }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
134
|
+
/** Converts the OpenAPI path to Express-style colon syntax.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
toURLPath(): string;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
7
144
|
//#region src/build.d.ts
|
|
8
145
|
type BuildOptions = {
|
|
9
146
|
config: UserConfig;
|
|
10
147
|
events?: AsyncEventEmitter<KubbEvents>;
|
|
11
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Full output produced by a successful or failed build.
|
|
151
|
+
*/
|
|
12
152
|
type BuildOutput = {
|
|
153
|
+
/**
|
|
154
|
+
* Plugins that threw during installation, paired with the caught error.
|
|
155
|
+
*/
|
|
13
156
|
failedPlugins: Set<{
|
|
14
157
|
plugin: Plugin;
|
|
15
158
|
error: Error;
|
|
16
159
|
}>;
|
|
17
160
|
fabric: Fabric;
|
|
18
161
|
files: Array<KubbFile.ResolvedFile>;
|
|
19
|
-
|
|
162
|
+
driver: PluginDriver;
|
|
163
|
+
/**
|
|
164
|
+
* Elapsed time in milliseconds for each plugin, keyed by plugin name.
|
|
165
|
+
*/
|
|
20
166
|
pluginTimings: Map<string, number>;
|
|
21
167
|
error?: Error;
|
|
168
|
+
/**
|
|
169
|
+
* Raw generated source, keyed by absolute file path.
|
|
170
|
+
*/
|
|
22
171
|
sources: Map<KubbFile.Path, string>;
|
|
23
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Intermediate result returned by {@link setup} and accepted by {@link safeBuild}.
|
|
175
|
+
*/
|
|
24
176
|
type SetupResult = {
|
|
25
177
|
events: AsyncEventEmitter<KubbEvents>;
|
|
26
178
|
fabric: Fabric;
|
|
27
|
-
|
|
179
|
+
driver: PluginDriver;
|
|
28
180
|
sources: Map<KubbFile.Path, string>;
|
|
29
181
|
};
|
|
182
|
+
/**
|
|
183
|
+
* Initializes all Kubb infrastructure for a build without executing any plugins.
|
|
184
|
+
*
|
|
185
|
+
* - Validates the input path (when applicable).
|
|
186
|
+
* - Applies config defaults (`root`, `output.*`, `devtools`).
|
|
187
|
+
* - Creates the Fabric instance and wires storage, format, and lint hooks.
|
|
188
|
+
* - Runs the adapter (if configured) to produce the universal `RootNode`.
|
|
189
|
+
*
|
|
190
|
+
* Pass the returned {@link SetupResult} directly to {@link safeBuild} or {@link build}
|
|
191
|
+
* via the `overrides` argument to reuse the same infrastructure across multiple runs.
|
|
192
|
+
*/
|
|
30
193
|
declare function setup(options: BuildOptions): Promise<SetupResult>;
|
|
194
|
+
/**
|
|
195
|
+
* Runs a full Kubb build and throws on any error or plugin failure.
|
|
196
|
+
*
|
|
197
|
+
* Internally delegates to {@link safeBuild} and rethrows collected errors.
|
|
198
|
+
* Pass an existing {@link SetupResult} via `overrides` to skip the setup phase.
|
|
199
|
+
*/
|
|
31
200
|
declare function build(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
201
|
+
/**
|
|
202
|
+
* Runs a full Kubb build and captures errors instead of throwing.
|
|
203
|
+
*
|
|
204
|
+
* - Installs each plugin in order, recording failures in `failedPlugins`.
|
|
205
|
+
* - Generates the root barrel file when `output.barrelType` is set.
|
|
206
|
+
* - Writes all files through Fabric.
|
|
207
|
+
*
|
|
208
|
+
* Returns a {@link BuildOutput} even on failure — inspect `error` and
|
|
209
|
+
* `failedPlugins` to determine whether the build succeeded.
|
|
210
|
+
*/
|
|
32
211
|
declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Promise<BuildOutput>;
|
|
33
212
|
//#endregion
|
|
34
213
|
//#region src/config.d.ts
|
|
@@ -36,7 +215,13 @@ declare function safeBuild(options: BuildOptions, overrides?: SetupResult): Prom
|
|
|
36
215
|
* CLI options derived from command-line flags.
|
|
37
216
|
*/
|
|
38
217
|
type CLIOptions = {
|
|
39
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Path to `kubb.config.js`.
|
|
220
|
+
*/
|
|
221
|
+
config?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Enable watch mode for input files.
|
|
224
|
+
*/
|
|
40
225
|
watch?: boolean;
|
|
41
226
|
/**
|
|
42
227
|
* Logging verbosity for CLI usage.
|
|
@@ -46,10 +231,11 @@ type CLIOptions = {
|
|
|
46
231
|
* - `debug`: include detailed plugin lifecycle logs
|
|
47
232
|
* @default 'silent'
|
|
48
233
|
*/
|
|
49
|
-
logLevel?: 'silent' | 'info' | 'debug';
|
|
50
|
-
bun?: boolean;
|
|
234
|
+
logLevel?: 'silent' | 'info' | 'debug';
|
|
51
235
|
};
|
|
52
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* All accepted forms of a Kubb configuration.
|
|
238
|
+
*/
|
|
53
239
|
type ConfigInput = PossiblePromise<UserConfig | UserConfig[]> | ((cli: CLIOptions) => PossiblePromise<UserConfig | UserConfig[]>);
|
|
54
240
|
/**
|
|
55
241
|
* Helper for defining a Kubb configuration.
|
|
@@ -72,91 +258,417 @@ declare function defineConfig(config: PossiblePromise<UserConfig | UserConfig[]>
|
|
|
72
258
|
*/
|
|
73
259
|
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath>;
|
|
74
260
|
//#endregion
|
|
75
|
-
//#region src/
|
|
261
|
+
//#region src/createAdapter.d.ts
|
|
262
|
+
/**
|
|
263
|
+
* Builder type for an {@link Adapter} — takes options and returns the adapter instance.
|
|
264
|
+
*/
|
|
76
265
|
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
77
266
|
/**
|
|
78
|
-
*
|
|
267
|
+
* Creates an adapter factory. Call the returned function with optional options to get the adapter instance.
|
|
79
268
|
*
|
|
80
269
|
* @example
|
|
81
|
-
*
|
|
82
|
-
* export const adapterOas = defineAdapter<OasAdapter>((options) => {
|
|
83
|
-
* const { validate = true, dateType = 'string' } = options
|
|
270
|
+
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
84
271
|
* return {
|
|
85
|
-
* name:
|
|
86
|
-
* options
|
|
87
|
-
* parse(source) { ... },
|
|
272
|
+
* name: 'my-adapter',
|
|
273
|
+
* options,
|
|
274
|
+
* async parse(source) { ... },
|
|
88
275
|
* }
|
|
89
276
|
* })
|
|
90
|
-
*
|
|
277
|
+
*
|
|
278
|
+
* // instantiate
|
|
279
|
+
* const adapter = myAdapter({ validate: true })
|
|
91
280
|
*/
|
|
92
|
-
declare function
|
|
281
|
+
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/createPlugin.d.ts
|
|
284
|
+
/**
|
|
285
|
+
* Builder type for a {@link UserPluginWithLifeCycle} — takes options and returns the plugin instance.
|
|
286
|
+
*/
|
|
287
|
+
type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
|
|
288
|
+
/**
|
|
289
|
+
* Creates a plugin factory. Call the returned function with optional options to get the plugin instance.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* export const myPlugin = createPlugin<MyPlugin>((options) => {
|
|
293
|
+
* return {
|
|
294
|
+
* name: 'my-plugin',
|
|
295
|
+
* options,
|
|
296
|
+
* resolvePath(baseName) { ... },
|
|
297
|
+
* resolveName(name, type) { ... },
|
|
298
|
+
* }
|
|
299
|
+
* })
|
|
300
|
+
*
|
|
301
|
+
* // instantiate
|
|
302
|
+
* const plugin = myPlugin({ output: { path: 'src/gen' } })
|
|
303
|
+
*/
|
|
304
|
+
declare function createPlugin<T extends PluginFactoryOptions = PluginFactoryOptions>(build: PluginBuilder<T>): (options?: T['options']) => UserPluginWithLifeCycle<T>;
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/defineBuilder.d.ts
|
|
307
|
+
/**
|
|
308
|
+
* Builder type for the plugin-specific builder fields.
|
|
309
|
+
* `name` is required; all other methods are defined by the concrete plugin builder type.
|
|
310
|
+
*/
|
|
311
|
+
type BuilderBuilder<T extends PluginFactoryOptions> = () => T['builder'] & ThisType<T['builder']>;
|
|
312
|
+
/**
|
|
313
|
+
* Defines a builder for a plugin — a named collection of schema-building helpers that
|
|
314
|
+
* can be exported alongside the plugin and imported by other plugins or generators.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* export const builder = defineBuilder<PluginTs>(() => ({
|
|
318
|
+
* name: 'default',
|
|
319
|
+
* buildParamsSchema({ params, node, resolver }) {
|
|
320
|
+
* return createSchema({ type: 'object', properties: [] })
|
|
321
|
+
* },
|
|
322
|
+
* buildDataSchemaNode({ node, resolver }) {
|
|
323
|
+
* return createSchema({ type: 'object', properties: [] })
|
|
324
|
+
* },
|
|
325
|
+
* }))
|
|
326
|
+
*/
|
|
327
|
+
declare function defineBuilder<T extends PluginFactoryOptions>(build: BuilderBuilder<T>): T['builder'];
|
|
93
328
|
//#endregion
|
|
94
329
|
//#region src/defineLogger.d.ts
|
|
330
|
+
/**
|
|
331
|
+
* Wraps a logger definition into a typed {@link Logger}.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* export const myLogger = defineLogger({
|
|
335
|
+
* name: 'my-logger',
|
|
336
|
+
* install(context, options) {
|
|
337
|
+
* context.on('info', (message) => console.log('ℹ', message))
|
|
338
|
+
* context.on('error', (error) => console.error('✗', error.message))
|
|
339
|
+
* },
|
|
340
|
+
* })
|
|
341
|
+
*/
|
|
95
342
|
declare function defineLogger<Options extends LoggerOptions = LoggerOptions>(logger: UserLogger<Options>): Logger<Options>;
|
|
96
343
|
//#endregion
|
|
97
|
-
//#region src/
|
|
98
|
-
type PluginBuilder<T extends PluginFactoryOptions = PluginFactoryOptions> = (options: T['options']) => UserPluginWithLifeCycle<T>;
|
|
344
|
+
//#region src/definePreset.d.ts
|
|
99
345
|
/**
|
|
100
|
-
*
|
|
346
|
+
* Creates a typed preset object that bundles a name, resolvers, optional
|
|
347
|
+
* transformers, and optional generators — the building block for composable plugin presets.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* import { definePreset } from '@kubb/core'
|
|
351
|
+
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
352
|
+
*
|
|
353
|
+
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy] })
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* // With custom transformers
|
|
357
|
+
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], transformers: [myTransformer] })
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* // With generators
|
|
361
|
+
* export const myPreset = definePreset('myPreset', { resolvers: [resolverTsLegacy], generators: [typeGeneratorLegacy] })
|
|
101
362
|
*/
|
|
102
|
-
declare function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
363
|
+
declare function definePreset<TResolver extends Resolver = Resolver, TName extends string = string>(name: TName, {
|
|
364
|
+
resolvers,
|
|
365
|
+
transformers,
|
|
366
|
+
generators
|
|
367
|
+
}: {
|
|
368
|
+
resolvers: Array<TResolver>;
|
|
369
|
+
transformers?: Array<Visitor>;
|
|
370
|
+
generators?: Array<Generator<any>>;
|
|
371
|
+
}): Preset<TResolver> & {
|
|
372
|
+
name: TName;
|
|
108
373
|
};
|
|
109
|
-
type DependencyName = string;
|
|
110
|
-
type DependencyVersion = string;
|
|
111
|
-
declare class PackageManager {
|
|
112
|
-
#private;
|
|
113
|
-
constructor(workspace?: string);
|
|
114
|
-
set workspace(workspace: string);
|
|
115
|
-
get workspace(): string | undefined;
|
|
116
|
-
normalizeDirectory(directory: string): string;
|
|
117
|
-
getLocation(path: string): string;
|
|
118
|
-
import(path: string): Promise<unknown>;
|
|
119
|
-
getPackageJSON(): Promise<PackageJSON | undefined>;
|
|
120
|
-
getPackageJSONSync(): PackageJSON | undefined;
|
|
121
|
-
static setVersion(dependency: DependencyName, version: DependencyVersion): void;
|
|
122
|
-
getVersion(dependency: DependencyName | RegExp): Promise<DependencyVersion | undefined>;
|
|
123
|
-
getVersionSync(dependency: DependencyName | RegExp): DependencyVersion | undefined;
|
|
124
|
-
isValid(dependency: DependencyName | RegExp, version: DependencyVersion): Promise<boolean>;
|
|
125
|
-
isValidSync(dependency: DependencyName | RegExp, version: DependencyVersion): boolean;
|
|
126
|
-
}
|
|
127
374
|
//#endregion
|
|
128
|
-
//#region src/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
375
|
+
//#region src/definePresets.d.ts
|
|
376
|
+
/**
|
|
377
|
+
* Creates a typed presets registry object — a named collection of {@link Preset} entries.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* import { definePreset, definePresets } from '@kubb/core'
|
|
381
|
+
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
382
|
+
*
|
|
383
|
+
* export const myPresets = definePresets({
|
|
384
|
+
* kubbV4: definePreset('kubbV4', { resolvers: [resolverTsLegacy] }),
|
|
385
|
+
* })
|
|
386
|
+
*/
|
|
387
|
+
declare function definePresets<TResolver extends Resolver = Resolver>(presets: Presets<TResolver>): Presets<TResolver>;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/defineResolver.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* Builder type for the plugin-specific resolver fields.
|
|
392
|
+
*
|
|
393
|
+
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
394
|
+
* are optional — built-in fallbacks are injected when omitted.
|
|
395
|
+
*/
|
|
396
|
+
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'>> & {
|
|
397
|
+
name: string;
|
|
398
|
+
pluginName: T['name'];
|
|
399
|
+
} & ThisType<T['resolver']>;
|
|
132
400
|
/**
|
|
133
|
-
*
|
|
401
|
+
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
402
|
+
*
|
|
403
|
+
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
404
|
+
*
|
|
405
|
+
* @example Include/exclude filtering
|
|
406
|
+
* ```ts
|
|
407
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
408
|
+
* options: { output: 'types' },
|
|
409
|
+
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
410
|
+
* })
|
|
411
|
+
* // → null when node has tag 'internal'
|
|
412
|
+
* ```
|
|
413
|
+
*
|
|
414
|
+
* @example Override merging
|
|
415
|
+
* ```ts
|
|
416
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
417
|
+
* options: { enumType: 'asConst' },
|
|
418
|
+
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
419
|
+
* })
|
|
420
|
+
* // → { enumType: 'enum' } when operationId matches
|
|
421
|
+
* ```
|
|
134
422
|
*/
|
|
135
|
-
|
|
423
|
+
declare function defaultResolveOptions<TOptions>(node: Node, {
|
|
424
|
+
options,
|
|
425
|
+
exclude,
|
|
426
|
+
include,
|
|
427
|
+
override
|
|
428
|
+
}: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
136
429
|
/**
|
|
137
|
-
*
|
|
430
|
+
* Default path resolver used by `defineResolver`.
|
|
431
|
+
*
|
|
432
|
+
* - Returns the output directory in `single` mode.
|
|
433
|
+
* - Resolves into a tag- or path-based subdirectory when `group` and a `tag`/`path` value are provided.
|
|
434
|
+
* - Falls back to a flat `output/baseName` path otherwise.
|
|
435
|
+
*
|
|
436
|
+
* A custom `group.name` function overrides the default subdirectory naming.
|
|
437
|
+
* For `tag` groups the default is `${camelCase(tag)}Controller`.
|
|
438
|
+
* For `path` groups the default is the first path segment after `/`.
|
|
439
|
+
*
|
|
440
|
+
* @example Flat output
|
|
441
|
+
* ```ts
|
|
442
|
+
* defaultResolvePath({ baseName: 'petTypes.ts' }, { root: '/src', output: { path: 'types' } })
|
|
443
|
+
* // → '/src/types/petTypes.ts'
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @example Tag-based grouping
|
|
447
|
+
* ```ts
|
|
448
|
+
* defaultResolvePath(
|
|
449
|
+
* { baseName: 'petTypes.ts', tag: 'pets' },
|
|
450
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
451
|
+
* )
|
|
452
|
+
* // → '/src/types/petsController/petTypes.ts'
|
|
453
|
+
* ```
|
|
454
|
+
*
|
|
455
|
+
* @example Path-based grouping
|
|
456
|
+
* ```ts
|
|
457
|
+
* defaultResolvePath(
|
|
458
|
+
* { baseName: 'petTypes.ts', path: '/pets/list' },
|
|
459
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'path' } },
|
|
460
|
+
* )
|
|
461
|
+
* // → '/src/types/pets/petTypes.ts'
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* @example Single-file mode
|
|
465
|
+
* ```ts
|
|
466
|
+
* defaultResolvePath(
|
|
467
|
+
* { baseName: 'petTypes.ts', pathMode: 'single' },
|
|
468
|
+
* { root: '/src', output: { path: 'types' } },
|
|
469
|
+
* )
|
|
470
|
+
* // → '/src/types'
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
declare function defaultResolvePath({
|
|
474
|
+
baseName,
|
|
475
|
+
pathMode,
|
|
476
|
+
tag,
|
|
477
|
+
path: groupPath
|
|
478
|
+
}: ResolverPathParams, {
|
|
479
|
+
root,
|
|
480
|
+
output,
|
|
481
|
+
group
|
|
482
|
+
}: ResolverContext): KubbFile.Path;
|
|
483
|
+
/**
|
|
484
|
+
* Default file resolver used by `defineResolver`.
|
|
485
|
+
*
|
|
486
|
+
* Resolves a `KubbFile.File` by combining name resolution (`resolver.default`) with
|
|
487
|
+
* path resolution (`resolver.resolvePath`). The resolved file always has empty
|
|
488
|
+
* `sources`, `imports`, and `exports` arrays — consumers populate those separately.
|
|
489
|
+
*
|
|
490
|
+
* In `single` mode the name is omitted and the file sits directly in the output directory.
|
|
491
|
+
*
|
|
492
|
+
* @example Resolve a schema file
|
|
493
|
+
* ```ts
|
|
494
|
+
* const file = defaultResolveFile.call(resolver,
|
|
495
|
+
* { name: 'pet', extname: '.ts' },
|
|
496
|
+
* { root: '/src', output: { path: 'types' } },
|
|
497
|
+
* )
|
|
498
|
+
* // → { baseName: 'pet.ts', path: '/src/types/pet.ts', sources: [], ... }
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @example Resolve an operation file with tag grouping
|
|
502
|
+
* ```ts
|
|
503
|
+
* const file = defaultResolveFile.call(resolver,
|
|
504
|
+
* { name: 'listPets', extname: '.ts', tag: 'pets' },
|
|
505
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
506
|
+
* )
|
|
507
|
+
* // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare function defaultResolveFile(this: Resolver, {
|
|
511
|
+
name,
|
|
512
|
+
extname,
|
|
513
|
+
tag,
|
|
514
|
+
path: groupPath
|
|
515
|
+
}: ResolverFileParams, context: ResolverContext): KubbFile.File;
|
|
516
|
+
/**
|
|
517
|
+
* Generates the default "Generated by Kubb" banner from config and optional node metadata.
|
|
518
|
+
*/
|
|
519
|
+
declare function buildDefaultBanner({
|
|
520
|
+
title,
|
|
521
|
+
description,
|
|
522
|
+
version,
|
|
523
|
+
config
|
|
524
|
+
}: {
|
|
525
|
+
title?: string;
|
|
526
|
+
description?: string;
|
|
527
|
+
version?: string;
|
|
528
|
+
config: Config;
|
|
529
|
+
}): string;
|
|
530
|
+
/**
|
|
531
|
+
* Default banner resolver — returns the banner string for a generated file.
|
|
532
|
+
*
|
|
533
|
+
* - When `output.banner` is a function and `node` is provided, calls it with the node.
|
|
534
|
+
* - When `output.banner` is a function and `node` is absent, falls back to the default Kubb banner.
|
|
535
|
+
* - When `output.banner` is a string, returns it directly.
|
|
536
|
+
* - When `config.output.defaultBanner` is `false`, returns `undefined`.
|
|
537
|
+
* - Otherwise returns the default "Generated by Kubb" banner.
|
|
538
|
+
*
|
|
539
|
+
* @example String banner
|
|
540
|
+
* ```ts
|
|
541
|
+
* defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
|
|
542
|
+
* // → '// my banner'
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @example Function banner with node
|
|
546
|
+
* ```ts
|
|
547
|
+
* defaultResolveBanner(rootNode, { output: { banner: (node) => `// v${node.version}` }, config })
|
|
548
|
+
* // → '// v3.0.0'
|
|
549
|
+
* ```
|
|
550
|
+
*
|
|
551
|
+
* @example Disabled banner
|
|
552
|
+
* ```ts
|
|
553
|
+
* defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
|
|
554
|
+
* // → undefined
|
|
555
|
+
* ```
|
|
556
|
+
*/
|
|
557
|
+
declare function defaultResolveBanner(node: RootNode | undefined, {
|
|
558
|
+
output,
|
|
559
|
+
config
|
|
560
|
+
}: ResolveBannerContext): string | undefined;
|
|
561
|
+
/**
|
|
562
|
+
* Default footer resolver — returns the footer string for a generated file.
|
|
563
|
+
*
|
|
564
|
+
* - When `output.footer` is a function and `node` is provided, calls it with the node.
|
|
565
|
+
* - When `output.footer` is a function and `node` is absent, returns `undefined`.
|
|
566
|
+
* - When `output.footer` is a string, returns it directly.
|
|
567
|
+
* - Otherwise returns `undefined`.
|
|
568
|
+
*
|
|
569
|
+
* @example String footer
|
|
570
|
+
* ```ts
|
|
571
|
+
* defaultResolveFooter(undefined, { output: { footer: '// end of file' }, config })
|
|
572
|
+
* // → '// end of file'
|
|
573
|
+
* ```
|
|
574
|
+
*
|
|
575
|
+
* @example Function footer with node
|
|
576
|
+
* ```ts
|
|
577
|
+
* defaultResolveFooter(rootNode, { output: { footer: (node) => `// ${node.title}` }, config })
|
|
578
|
+
* // → '// Pet Store'
|
|
579
|
+
* ```
|
|
138
580
|
*/
|
|
139
|
-
|
|
581
|
+
declare function defaultResolveFooter(node: RootNode | undefined, {
|
|
582
|
+
output
|
|
583
|
+
}: ResolveBannerContext): string | undefined;
|
|
140
584
|
/**
|
|
141
|
-
*
|
|
585
|
+
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
586
|
+
* include/exclude/override filtering, path resolution, and file construction.
|
|
587
|
+
*
|
|
588
|
+
* All four defaults can be overridden by providing them in the builder function:
|
|
589
|
+
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
590
|
+
* - `resolveOptions` — include/exclude/override filtering
|
|
591
|
+
* - `resolvePath` — output path computation
|
|
592
|
+
* - `resolveFile` — full `KubbFile.File` construction
|
|
593
|
+
*
|
|
594
|
+
* Methods in the builder have access to `this` (the full resolver object), so they
|
|
595
|
+
* can call other resolver methods without circular imports.
|
|
596
|
+
*
|
|
597
|
+
* @example Basic resolver with naming helpers
|
|
598
|
+
* ```ts
|
|
599
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
600
|
+
* name: 'default',
|
|
601
|
+
* resolveName(node) {
|
|
602
|
+
* return this.default(node.name, 'function')
|
|
603
|
+
* },
|
|
604
|
+
* resolveTypedName(node) {
|
|
605
|
+
* return this.default(node.name, 'type')
|
|
606
|
+
* },
|
|
607
|
+
* }))
|
|
608
|
+
* ```
|
|
609
|
+
*
|
|
610
|
+
* @example Override resolvePath for a custom output structure
|
|
611
|
+
* ```ts
|
|
612
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
613
|
+
* name: 'custom',
|
|
614
|
+
* resolvePath({ baseName }, { root, output }) {
|
|
615
|
+
* return path.resolve(root, output.path, 'generated', baseName)
|
|
616
|
+
* },
|
|
617
|
+
* }))
|
|
618
|
+
* ```
|
|
619
|
+
*
|
|
620
|
+
* @example Use this.default inside a helper
|
|
621
|
+
* ```ts
|
|
622
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
623
|
+
* name: 'default',
|
|
624
|
+
* resolveParamName(node, param) {
|
|
625
|
+
* return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
|
|
626
|
+
* },
|
|
627
|
+
* }))
|
|
628
|
+
* ```
|
|
142
629
|
*/
|
|
143
|
-
|
|
144
|
-
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;
|
|
630
|
+
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
145
631
|
//#endregion
|
|
146
|
-
//#region src/
|
|
147
|
-
type
|
|
148
|
-
|
|
149
|
-
|
|
632
|
+
//#region src/renderNode.d.ts
|
|
633
|
+
type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = {
|
|
634
|
+
config: Config;
|
|
635
|
+
fabric: Fabric$1;
|
|
636
|
+
plugin: Plugin<TOptions>;
|
|
637
|
+
Component: ReactGeneratorV2<TOptions>['Operations'] | undefined;
|
|
638
|
+
adapter: Adapter;
|
|
639
|
+
driver: PluginDriver;
|
|
640
|
+
options: TOptions['resolvedOptions'];
|
|
150
641
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
642
|
+
/**
|
|
643
|
+
* Renders a React component for a list of operation nodes (V2 generators).
|
|
644
|
+
*/
|
|
645
|
+
declare function renderOperations<TOptions extends PluginFactoryOptions>(nodes: Array<OperationNode>, options: BuildOperationsV2Options<TOptions>): Promise<void>;
|
|
646
|
+
type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = {
|
|
647
|
+
config: Config;
|
|
648
|
+
fabric: Fabric$1;
|
|
649
|
+
plugin: Plugin<TOptions>;
|
|
650
|
+
Component: ReactGeneratorV2<TOptions>['Operation'] | undefined;
|
|
651
|
+
adapter: Adapter;
|
|
652
|
+
driver: PluginDriver;
|
|
653
|
+
options: TOptions['resolvedOptions'];
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* Renders a React component for a single operation node (V2 generators).
|
|
657
|
+
*/
|
|
658
|
+
declare function renderOperation<TOptions extends PluginFactoryOptions>(node: OperationNode, options: BuildOperationV2Options<TOptions>): Promise<void>;
|
|
659
|
+
type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = {
|
|
660
|
+
config: Config;
|
|
661
|
+
fabric: Fabric$1;
|
|
662
|
+
plugin: Plugin<TOptions>;
|
|
663
|
+
Component: ReactGeneratorV2<TOptions>['Schema'] | undefined;
|
|
664
|
+
adapter: Adapter;
|
|
665
|
+
driver: PluginDriver;
|
|
666
|
+
options: TOptions['resolvedOptions'];
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Renders a React component for a single schema node (V2 generators).
|
|
670
|
+
*/
|
|
671
|
+
declare function renderSchema<TOptions extends PluginFactoryOptions>(node: SchemaNode, options: BuildSchemaV2Options<TOptions>): Promise<void>;
|
|
160
672
|
//#endregion
|
|
161
673
|
//#region src/storages/fsStorage.d.ts
|
|
162
674
|
/**
|
|
@@ -182,7 +694,7 @@ declare class PromiseManager<TState = unknown> {
|
|
|
182
694
|
* })
|
|
183
695
|
* ```
|
|
184
696
|
*/
|
|
185
|
-
declare const fsStorage: (options?: Record<string, never> | undefined) =>
|
|
697
|
+
declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
186
698
|
//#endregion
|
|
187
699
|
//#region src/storages/memoryStorage.d.ts
|
|
188
700
|
/**
|
|
@@ -202,7 +714,7 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Define
|
|
|
202
714
|
* })
|
|
203
715
|
* ```
|
|
204
716
|
*/
|
|
205
|
-
declare const memoryStorage: (options?: Record<string, never> | undefined) =>
|
|
717
|
+
declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
|
|
206
718
|
//#endregion
|
|
207
719
|
//#region src/utils/FunctionParams.d.ts
|
|
208
720
|
type FunctionParamsASTWithoutType = {
|
|
@@ -232,11 +744,11 @@ type FunctionParamsASTWithType = {
|
|
|
232
744
|
default?: string;
|
|
233
745
|
};
|
|
234
746
|
/**
|
|
235
|
-
* @deprecated
|
|
747
|
+
* @deprecated use ast package instead
|
|
236
748
|
*/
|
|
237
749
|
type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType;
|
|
238
750
|
/**
|
|
239
|
-
* @deprecated
|
|
751
|
+
* @deprecated use ast package instead
|
|
240
752
|
*/
|
|
241
753
|
declare class FunctionParams {
|
|
242
754
|
#private;
|
|
@@ -251,26 +763,20 @@ declare class FunctionParams {
|
|
|
251
763
|
//#region src/utils/formatters.d.ts
|
|
252
764
|
type Formatter = keyof typeof formatters;
|
|
253
765
|
/**
|
|
254
|
-
*
|
|
766
|
+
* Detects the first available code formatter on the current system.
|
|
255
767
|
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* @remarks
|
|
259
|
-
* Checks in order of preference: biome, oxfmt, prettier.
|
|
260
|
-
* Uses the `--version` flag to detect if each formatter command is available.
|
|
261
|
-
* This is a reliable method as all supported formatters implement this flag.
|
|
768
|
+
* - Checks in preference order: `biome`, `oxfmt`, `prettier`.
|
|
769
|
+
* - Returns `null` when none are found.
|
|
262
770
|
*
|
|
263
771
|
* @example
|
|
264
|
-
* ```
|
|
772
|
+
* ```ts
|
|
265
773
|
* const formatter = await detectFormatter()
|
|
266
774
|
* if (formatter) {
|
|
267
775
|
* console.log(`Using ${formatter} for formatting`)
|
|
268
|
-
* } else {
|
|
269
|
-
* console.log('No formatter found')
|
|
270
776
|
* }
|
|
271
777
|
* ```
|
|
272
778
|
*/
|
|
273
|
-
declare function detectFormatter(): Promise<Formatter |
|
|
779
|
+
declare function detectFormatter(): Promise<Formatter | null>;
|
|
274
780
|
//#endregion
|
|
275
781
|
//#region src/utils/getBarrelFiles.d.ts
|
|
276
782
|
type FileMetaBase = {
|
|
@@ -294,22 +800,101 @@ type AddIndexesProps = {
|
|
|
294
800
|
};
|
|
295
801
|
meta?: FileMetaBase;
|
|
296
802
|
};
|
|
803
|
+
/**
|
|
804
|
+
* Generates `index.ts` barrel files for all directories under `root/output.path`.
|
|
805
|
+
*
|
|
806
|
+
* - Returns an empty array when `type` is falsy or `'propagate'`.
|
|
807
|
+
* - Skips generation when the output path itself ends with `index` (already a barrel).
|
|
808
|
+
* - When `type` is `'all'`, strips named exports so every re-export becomes a wildcard (`export * from`).
|
|
809
|
+
* - Attaches `meta` to each barrel file for downstream plugin identification.
|
|
810
|
+
*/
|
|
297
811
|
declare function getBarrelFiles(files: Array<KubbFile.ResolvedFile>, {
|
|
298
812
|
type,
|
|
299
813
|
meta,
|
|
300
814
|
root,
|
|
301
815
|
output
|
|
302
|
-
}: AddIndexesProps): Promise<KubbFile.File
|
|
816
|
+
}: AddIndexesProps): Promise<Array<KubbFile.File>>;
|
|
303
817
|
//#endregion
|
|
304
818
|
//#region src/utils/getConfigs.d.ts
|
|
305
819
|
/**
|
|
306
|
-
*
|
|
820
|
+
* Resolves a {@link ConfigInput} into a normalized array of {@link Config} objects.
|
|
821
|
+
*
|
|
822
|
+
* - Awaits the config when it is a `Promise`.
|
|
823
|
+
* - Calls the factory function with `args` when the config is a function.
|
|
824
|
+
* - Wraps a single config object in an array for uniform downstream handling.
|
|
307
825
|
*/
|
|
308
826
|
declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions): Promise<Array<Config>>;
|
|
309
827
|
//#endregion
|
|
828
|
+
//#region src/utils/getPreset.d.ts
|
|
829
|
+
type GetPresetParams<TResolver extends Resolver> = {
|
|
830
|
+
preset: CompatibilityPreset;
|
|
831
|
+
presets: Presets<TResolver>;
|
|
832
|
+
resolvers: Array<TResolver>;
|
|
833
|
+
/**
|
|
834
|
+
* User-supplied generators to append after the preset's generators.
|
|
835
|
+
*/
|
|
836
|
+
generators: Array<Generator<any>>;
|
|
837
|
+
transformers?: Array<Visitor>;
|
|
838
|
+
};
|
|
839
|
+
type GetPresetResult<TResolver extends Resolver> = {
|
|
840
|
+
resolver: TResolver;
|
|
841
|
+
transformers: Array<Visitor>;
|
|
842
|
+
generators: Array<Generator<any>>;
|
|
843
|
+
preset: Preset<TResolver> | undefined;
|
|
844
|
+
};
|
|
845
|
+
/**
|
|
846
|
+
* Resolves a named preset into merged resolvers, transformers, and generators.
|
|
847
|
+
*
|
|
848
|
+
* - Merges the preset's resolvers on top of the first (default)
|
|
849
|
+
* - Merges any additional user-supplied resolvers on top of that to produce the final `resolver`.
|
|
850
|
+
* - Concatenates preset transformers before user-supplied transformers.
|
|
851
|
+
* - Combines preset generators with user-supplied generators; falls back to the `default` preset's generators when neither provides any.
|
|
852
|
+
*/
|
|
853
|
+
declare function getPreset<TResolver extends Resolver = Resolver>(params: GetPresetParams<TResolver>): GetPresetResult<TResolver>;
|
|
854
|
+
//#endregion
|
|
310
855
|
//#region src/utils/linters.d.ts
|
|
311
856
|
type Linter = keyof typeof linters;
|
|
312
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Detects the first available linter on the current system.
|
|
859
|
+
*
|
|
860
|
+
* - Checks in preference order: `biome`, `oxlint`, `eslint`.
|
|
861
|
+
* - Returns `null` when none are found.
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```ts
|
|
865
|
+
* const linter = await detectLinter()
|
|
866
|
+
* if (linter) {
|
|
867
|
+
* console.log(`Using ${linter} for linting`)
|
|
868
|
+
* }
|
|
869
|
+
* ```
|
|
870
|
+
*/
|
|
871
|
+
declare function detectLinter(): Promise<Linter | null>;
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/utils/mergeResolvers.d.ts
|
|
874
|
+
/**
|
|
875
|
+
* Merges an array of resolvers into a single resolver. Later entries override earlier ones (last wins).
|
|
876
|
+
*/
|
|
877
|
+
declare function mergeResolvers<T extends Resolver>(...resolvers: Array<T>): T;
|
|
878
|
+
//#endregion
|
|
879
|
+
//#region src/utils/packageJSON.d.ts
|
|
880
|
+
type DependencyName = string;
|
|
881
|
+
type DependencyVersion = string;
|
|
882
|
+
/**
|
|
883
|
+
* Returns `true` when the nearest `package.json` declares a dependency that
|
|
884
|
+
* satisfies the given semver range.
|
|
885
|
+
*
|
|
886
|
+
* - Searches both `dependencies` and `devDependencies`.
|
|
887
|
+
* - Accepts a string package name or a `RegExp` to match scoped/pattern packages.
|
|
888
|
+
* - Uses `semver.satisfies` for range comparison; returns `false` when the
|
|
889
|
+
* version string cannot be coerced into a valid semver.
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```ts
|
|
893
|
+
* satisfiesDependency('react', '>=18') // true when react@18.x is installed
|
|
894
|
+
* satisfiesDependency(/^@tanstack\//, '>=5') // true when any @tanstack/* >=5 is found
|
|
895
|
+
* ```
|
|
896
|
+
*/
|
|
897
|
+
declare function satisfiesDependency(dependency: DependencyName | RegExp, version: DependencyVersion, cwd?: string): boolean;
|
|
313
898
|
//#endregion
|
|
314
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, Config, type ConfigInput,
|
|
899
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, Builder, type CLIOptions, CompatibilityPreset, Config, type ConfigInput, CoreGeneratorV2, DevtoolsOptions, Exclude, type FileMetaBase, FunctionParams, type FunctionParamsAST, Generator, Group, Include, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, Override, Plugin, PluginContext, PluginDriver, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginParameter, PluginWithLifeCycle, Preset, Presets, Printer, PrinterFactoryOptions, ReactGeneratorV2, ResolveBannerContext, ResolveNameParams, ResolveOptionsContext, ResolvePathOptions, ResolvePathParams, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, URLPath, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, UserResolver, build, build as default, buildDefaultBanner, createAdapter, createPlugin, createStorage, defaultResolveBanner, defaultResolveFile, defaultResolveFooter, defaultResolveOptions, defaultResolvePath, defineBuilder, defineConfig, defineGenerator, defineLogger, definePreset, definePresets, definePrinter, defineResolver, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, getPreset, isInputPath, linters, logLevel, memoryStorage, mergeResolvers, renderOperation, renderOperations, renderSchema, safeBuild, satisfiesDependency, setup };
|
|
315
900
|
//# sourceMappingURL=index.d.ts.map
|