@kubb/core 5.0.0-alpha.9 → 5.0.0-beta.10
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/README.md +13 -40
- package/dist/PluginDriver-Cu1Kj9S-.cjs +1075 -0
- package/dist/PluginDriver-Cu1Kj9S-.cjs.map +1 -0
- package/dist/PluginDriver-D8Z0Htid.js +978 -0
- package/dist/PluginDriver-D8Z0Htid.js.map +1 -0
- package/dist/createKubb-ALdb8lmq.d.ts +2082 -0
- package/dist/index.cjs +747 -1667
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +175 -269
- package/dist/index.js +734 -1638
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +145 -0
- package/dist/mocks.cjs.map +1 -0
- package/dist/mocks.d.ts +80 -0
- package/dist/mocks.js +140 -0
- package/dist/mocks.js.map +1 -0
- package/package.json +47 -60
- package/src/FileManager.ts +115 -0
- package/src/FileProcessor.ts +86 -0
- package/src/PluginDriver.ts +355 -561
- package/src/constants.ts +21 -48
- package/src/createAdapter.ts +88 -5
- package/src/createKubb.ts +1266 -0
- package/src/createRenderer.ts +57 -0
- package/src/createStorage.ts +13 -1
- package/src/defineGenerator.ts +160 -119
- package/src/defineLogger.ts +46 -5
- package/src/defineMiddleware.ts +62 -0
- package/src/defineParser.ts +44 -0
- package/src/definePlugin.ts +379 -0
- package/src/defineResolver.ts +548 -25
- package/src/devtools.ts +22 -15
- package/src/index.ts +13 -15
- package/src/mocks.ts +177 -0
- package/src/storages/fsStorage.ts +13 -8
- package/src/storages/memoryStorage.ts +4 -2
- package/src/types.ts +40 -547
- package/dist/PluginDriver-BkFepPdm.d.ts +0 -1054
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/hooks.cjs +0 -103
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts +0 -77
- package/dist/hooks.js +0 -98
- package/dist/hooks.js.map +0 -1
- package/src/Kubb.ts +0 -224
- package/src/build.ts +0 -418
- package/src/config.ts +0 -56
- package/src/createPlugin.ts +0 -28
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useKubb.ts +0 -143
- package/src/hooks/useMode.ts +0 -11
- package/src/hooks/usePlugin.ts +0 -11
- package/src/hooks/usePluginDriver.ts +0 -11
- package/src/utils/FunctionParams.ts +0 -155
- package/src/utils/TreeNode.ts +0 -215
- package/src/utils/diagnostics.ts +0 -15
- package/src/utils/executeStrategies.ts +0 -81
- package/src/utils/formatters.ts +0 -56
- package/src/utils/getBarrelFiles.ts +0 -141
- package/src/utils/getConfigs.ts +0 -12
- package/src/utils/linters.ts +0 -25
- package/src/utils/packageJSON.ts +0 -61
|
@@ -0,0 +1,2082 @@
|
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
+
import { FileNode, HttpMethod, ImportNode, InputNode, Node, OperationNode, SchemaNode, UserFileNode, Visitor } from "@kubb/ast";
|
|
3
|
+
|
|
4
|
+
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A function that can be registered as an event listener, synchronous or async.
|
|
7
|
+
*/
|
|
8
|
+
type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Typed `EventEmitter` that awaits all async listeners before resolving.
|
|
11
|
+
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
|
|
16
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
17
|
+
* await emitter.emit('build', 'petstore') // all listeners awaited
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum number of listeners per event before Node emits a memory-leak warning.
|
|
24
|
+
* @default 10
|
|
25
|
+
*/
|
|
26
|
+
constructor(maxListener?: number);
|
|
27
|
+
/**
|
|
28
|
+
* Emits `eventName` and awaits all registered listeners sequentially.
|
|
29
|
+
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* await emitter.emit('build', 'petstore')
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Registers a persistent listener for `eventName`.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* emitter.on('build', async (name) => { console.log(name) })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Registers a one-shot listener that removes itself after the first invocation.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* emitter.onOnce('build', async (name) => { console.log(name) })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Removes a previously registered listener.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* emitter.off('build', handler)
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the number of listeners registered for `eventName`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* emitter.on('build', handler)
|
|
70
|
+
* emitter.listenerCount('build') // 1
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
listenerCount<TEventName extends keyof TEvents & string>(eventName: TEventName): number;
|
|
74
|
+
/**
|
|
75
|
+
* Removes all listeners from every event channel.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* emitter.removeAll()
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
removeAll(): void;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region ../../internals/utils/src/promise.d.ts
|
|
86
|
+
/** A value that may already be resolved or still pending.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* function load(id: string): PossiblePromise<string> {
|
|
91
|
+
* return cache.get(id) ?? fetchRemote(id)
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/constants.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* Base URL for the Kubb Studio web app.
|
|
100
|
+
*/
|
|
101
|
+
declare const DEFAULT_STUDIO_URL: "https://kubb.studio";
|
|
102
|
+
/**
|
|
103
|
+
* Numeric log-level thresholds used internally to compare verbosity.
|
|
104
|
+
*
|
|
105
|
+
* Higher numbers are more verbose.
|
|
106
|
+
*/
|
|
107
|
+
declare const logLevel: {
|
|
108
|
+
readonly silent: number;
|
|
109
|
+
readonly error: 0;
|
|
110
|
+
readonly warn: 1;
|
|
111
|
+
readonly info: 3;
|
|
112
|
+
readonly verbose: 4;
|
|
113
|
+
readonly debug: 5;
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/createAdapter.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* Source data passed to an adapter's `parse` function.
|
|
119
|
+
* Mirrors the config input shape with paths resolved to absolute.
|
|
120
|
+
*/
|
|
121
|
+
type AdapterSource = {
|
|
122
|
+
type: 'path';
|
|
123
|
+
path: string;
|
|
124
|
+
} | {
|
|
125
|
+
type: 'data';
|
|
126
|
+
data: string | unknown;
|
|
127
|
+
} | {
|
|
128
|
+
type: 'paths';
|
|
129
|
+
paths: Array<string>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Generic type parameters for an adapter definition.
|
|
133
|
+
*
|
|
134
|
+
* - `TName` — unique identifier (e.g. `'oas'`, `'asyncapi'`)
|
|
135
|
+
* - `TOptions` — user-facing options passed to the adapter factory
|
|
136
|
+
* - `TResolvedOptions` — options after defaults applied
|
|
137
|
+
* - `TDocument` — type of the parsed source document
|
|
138
|
+
*/
|
|
139
|
+
type AdapterFactoryOptions<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions, TDocument = unknown> = {
|
|
140
|
+
name: TName;
|
|
141
|
+
options: TOptions;
|
|
142
|
+
resolvedOptions: TResolvedOptions;
|
|
143
|
+
document: TDocument;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Adapter that converts input files or data into an `InputNode`.
|
|
147
|
+
*
|
|
148
|
+
* Adapters parse different schema formats (OpenAPI, AsyncAPI, Drizzle, etc.) into Kubb's
|
|
149
|
+
* universal intermediate representation that all plugins consume.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { adapterOas } from '@kubb/adapter-oas'
|
|
154
|
+
*
|
|
155
|
+
* export default defineConfig({
|
|
156
|
+
* adapter: adapterOas(),
|
|
157
|
+
* input: { path: './openapi.yaml' },
|
|
158
|
+
* plugins: [pluginTs(), pluginZod()],
|
|
159
|
+
* })
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
|
|
163
|
+
/**
|
|
164
|
+
* Human-readable adapter identifier (e.g. `'oas'`, `'asyncapi'`).
|
|
165
|
+
*/
|
|
166
|
+
name: TOptions['name'];
|
|
167
|
+
/**
|
|
168
|
+
* Resolved adapter options after defaults have been applied.
|
|
169
|
+
*/
|
|
170
|
+
options: TOptions['resolvedOptions'];
|
|
171
|
+
/**
|
|
172
|
+
* Parsed source document after the first `parse()` call. `null` before parsing.
|
|
173
|
+
*/
|
|
174
|
+
document: TOptions['document'] | null;
|
|
175
|
+
inputNode: InputNode | null;
|
|
176
|
+
/**
|
|
177
|
+
* Parse the source into a universal `InputNode`.
|
|
178
|
+
*/
|
|
179
|
+
parse: (source: AdapterSource) => PossiblePromise<InputNode>;
|
|
180
|
+
/**
|
|
181
|
+
* Extract `ImportNode` entries for a schema tree.
|
|
182
|
+
* Returns an empty array before the first `parse()` call.
|
|
183
|
+
*
|
|
184
|
+
* The `resolve` callback receives the collision-corrected schema name and must
|
|
185
|
+
* return `{ name, path }` for the import, or `undefined` to skip it.
|
|
186
|
+
*/
|
|
187
|
+
getImports: (node: SchemaNode, resolve: (schemaName: string) => {
|
|
188
|
+
name: string;
|
|
189
|
+
path: string;
|
|
190
|
+
}) => Array<ImportNode>;
|
|
191
|
+
/**
|
|
192
|
+
* Validate the document at the given path or URL.
|
|
193
|
+
*/
|
|
194
|
+
validate: (input: string, options?: {
|
|
195
|
+
throwOnError?: boolean;
|
|
196
|
+
}) => Promise<void>;
|
|
197
|
+
};
|
|
198
|
+
type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
|
|
199
|
+
/**
|
|
200
|
+
* Factory for implementing custom adapters that translate non-OpenAPI specs into Kubb's AST.
|
|
201
|
+
*
|
|
202
|
+
* Use this to support GraphQL schemas, gRPC definitions, AsyncAPI, or custom domain-specific languages.
|
|
203
|
+
* Built-in adapters include `@kubb/adapter-oas` for OpenAPI and Swagger documents.
|
|
204
|
+
*
|
|
205
|
+
* @note Adapters must parse their input format to Kubb's `InputNode` structure.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* export const myAdapter = createAdapter<MyAdapter>((options) => {
|
|
210
|
+
* return {
|
|
211
|
+
* name: 'my-adapter',
|
|
212
|
+
* options,
|
|
213
|
+
* async parse(source) {
|
|
214
|
+
* // Transform source format to InputNode
|
|
215
|
+
* return { ... }
|
|
216
|
+
* },
|
|
217
|
+
* }
|
|
218
|
+
* })
|
|
219
|
+
*
|
|
220
|
+
* // Instantiate:
|
|
221
|
+
* const adapter = myAdapter({ validate: true })
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/createRenderer.d.ts
|
|
227
|
+
/**
|
|
228
|
+
* Minimal interface any Kubb renderer must satisfy.
|
|
229
|
+
*
|
|
230
|
+
* The generic `TElement` is the type of the element the renderer accepts —
|
|
231
|
+
* e.g. `KubbReactElement` for `@kubb/renderer-jsx`, or a custom type for
|
|
232
|
+
* your own renderer. Defaults to `unknown` so that generators which do not
|
|
233
|
+
* care about the element type continue to work without specifying it.
|
|
234
|
+
*
|
|
235
|
+
* This allows core to drive rendering without a hard dependency on
|
|
236
|
+
* `@kubb/renderer-jsx` or any specific renderer implementation.
|
|
237
|
+
*/
|
|
238
|
+
type Renderer<TElement = unknown> = {
|
|
239
|
+
render(element: TElement): Promise<void>;
|
|
240
|
+
unmount(error?: Error | number | null): void;
|
|
241
|
+
readonly files: Array<FileNode>;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* A factory function that produces a fresh {@link Renderer} per render.
|
|
245
|
+
*
|
|
246
|
+
* Generators use this to declare which renderer handles their output.
|
|
247
|
+
*/
|
|
248
|
+
type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a renderer factory for use in generator definitions.
|
|
251
|
+
*
|
|
252
|
+
* Wrap your renderer factory function with this helper to register it as the
|
|
253
|
+
* renderer for a generator. Core will call this factory once per render cycle
|
|
254
|
+
* to obtain a fresh renderer instance.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* // packages/renderer-jsx/src/index.ts
|
|
259
|
+
* export const jsxRenderer = createRenderer(() => {
|
|
260
|
+
* const runtime = new Runtime()
|
|
261
|
+
* return {
|
|
262
|
+
* async render(element) { await runtime.render(element) },
|
|
263
|
+
* get files() { return runtime.nodes },
|
|
264
|
+
* unmount(error) { runtime.unmount(error) },
|
|
265
|
+
* }
|
|
266
|
+
* })
|
|
267
|
+
*
|
|
268
|
+
* // packages/plugin-zod/src/generators/zodGenerator.tsx
|
|
269
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
270
|
+
* export const zodGenerator = defineGenerator<PluginZod>({
|
|
271
|
+
* name: 'zod',
|
|
272
|
+
* renderer: jsxRenderer,
|
|
273
|
+
* schema(node, options) { return <File ...>...</File> },
|
|
274
|
+
* })
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
declare function createRenderer<TElement = unknown>(factory: RendererFactory<TElement>): RendererFactory<TElement>;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/createStorage.d.ts
|
|
280
|
+
type Storage = {
|
|
281
|
+
/**
|
|
282
|
+
* Identifier used for logging and debugging (e.g. `'fs'`, `'s3'`).
|
|
283
|
+
*/
|
|
284
|
+
readonly name: string;
|
|
285
|
+
/**
|
|
286
|
+
* Returns `true` when an entry for `key` exists in storage.
|
|
287
|
+
*/
|
|
288
|
+
hasItem(key: string): Promise<boolean>;
|
|
289
|
+
/**
|
|
290
|
+
* Returns the stored string value, or `null` when `key` does not exist.
|
|
291
|
+
*/
|
|
292
|
+
getItem(key: string): Promise<string | null>;
|
|
293
|
+
/**
|
|
294
|
+
* Persists `value` under `key`, creating any required structure.
|
|
295
|
+
*/
|
|
296
|
+
setItem(key: string, value: string): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Removes the entry for `key`. No-ops when the key does not exist.
|
|
299
|
+
*/
|
|
300
|
+
removeItem(key: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Returns all keys, optionally filtered to those starting with `base`.
|
|
303
|
+
*/
|
|
304
|
+
getKeys(base?: string): Promise<Array<string>>;
|
|
305
|
+
/**
|
|
306
|
+
* Removes all entries, optionally scoped to those starting with `base`.
|
|
307
|
+
*/
|
|
308
|
+
clear(base?: string): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Optional teardown hook called after the build completes.
|
|
311
|
+
*/
|
|
312
|
+
dispose?(): Promise<void>;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Factory for implementing custom storage backends that control where generated files are written.
|
|
316
|
+
*
|
|
317
|
+
* Takes a builder function `(options: TOptions) => Storage` and returns a factory `(options?: TOptions) => Storage`.
|
|
318
|
+
* Kubb provides filesystem and in-memory implementations out of the box.
|
|
319
|
+
*
|
|
320
|
+
* @note Call the returned factory with optional options to instantiate the storage adapter.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```ts
|
|
324
|
+
* import { createStorage } from '@kubb/core'
|
|
325
|
+
*
|
|
326
|
+
* export const memoryStorage = createStorage(() => {
|
|
327
|
+
* const store = new Map<string, string>()
|
|
328
|
+
* return {
|
|
329
|
+
* name: 'memory',
|
|
330
|
+
* async hasItem(key) { return store.has(key) },
|
|
331
|
+
* async getItem(key) { return store.get(key) ?? null },
|
|
332
|
+
* async setItem(key, value) { store.set(key, value) },
|
|
333
|
+
* async removeItem(key) { store.delete(key) },
|
|
334
|
+
* async getKeys(base) {
|
|
335
|
+
* const keys = [...store.keys()]
|
|
336
|
+
* return base ? keys.filter((k) => k.startsWith(base)) : keys
|
|
337
|
+
* },
|
|
338
|
+
* async clear(base) { if (!base) store.clear() },
|
|
339
|
+
* }
|
|
340
|
+
* })
|
|
341
|
+
*
|
|
342
|
+
* // Instantiate:
|
|
343
|
+
* const storage = memoryStorage()
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => Storage): (options?: TOptions) => Storage;
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/devtools.d.ts
|
|
349
|
+
type DevtoolsOptions = {
|
|
350
|
+
/**
|
|
351
|
+
* Open the AST inspector in Kubb Studio (`/ast`). Defaults to the main Studio page.
|
|
352
|
+
* @default false
|
|
353
|
+
*/
|
|
354
|
+
ast?: boolean;
|
|
355
|
+
};
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/defineLogger.d.ts
|
|
358
|
+
type LoggerOptions = {
|
|
359
|
+
/**
|
|
360
|
+
* Log level for output verbosity.
|
|
361
|
+
* @default 3
|
|
362
|
+
*/
|
|
363
|
+
logLevel: (typeof logLevel)[keyof typeof logLevel];
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Shared context passed to plugins, parsers, and other internals.
|
|
367
|
+
*/
|
|
368
|
+
type LoggerContext = AsyncEventEmitter<KubbHooks>;
|
|
369
|
+
type Logger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = {
|
|
370
|
+
name: string;
|
|
371
|
+
install: (context: LoggerContext, options?: TOptions) => TInstallReturn | Promise<TInstallReturn>;
|
|
372
|
+
};
|
|
373
|
+
type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = Logger<TOptions, TInstallReturn>;
|
|
374
|
+
/**
|
|
375
|
+
* Wraps a logger definition into a typed {@link Logger}.
|
|
376
|
+
*
|
|
377
|
+
* The optional second type parameter `TInstallReturn` allows loggers to return
|
|
378
|
+
* a value from `install` — for example, a sink factory that the caller can
|
|
379
|
+
* forward to hook execution.
|
|
380
|
+
*
|
|
381
|
+
* @example Basic logger
|
|
382
|
+
* ```ts
|
|
383
|
+
* export const myLogger = defineLogger({
|
|
384
|
+
* name: 'my-logger',
|
|
385
|
+
* install(context, options) {
|
|
386
|
+
* context.on('kubb:info', (message) => console.log('ℹ', message))
|
|
387
|
+
* context.on('kubb:error', (error) => console.error('✗', error.message))
|
|
388
|
+
* },
|
|
389
|
+
* })
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* @example Logger that returns a hook sink factory
|
|
393
|
+
* ```ts
|
|
394
|
+
* export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
|
|
395
|
+
* name: 'my-logger',
|
|
396
|
+
* install(context, options) {
|
|
397
|
+
* // … register event handlers …
|
|
398
|
+
* return (commandWithArgs) => ({ onStdout: console.log })
|
|
399
|
+
* },
|
|
400
|
+
* })
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
declare function defineLogger<Options extends LoggerOptions = LoggerOptions, TInstallReturn = void>(logger: UserLogger<Options, TInstallReturn>): Logger<Options, TInstallReturn>;
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/defineMiddleware.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* A middleware instance produced by calling a factory created with `defineMiddleware`.
|
|
408
|
+
* It declares event handlers under a `hooks` object which are registered on the
|
|
409
|
+
* shared emitter after all plugin hooks, so middleware handlers for any event
|
|
410
|
+
* always fire last.
|
|
411
|
+
*/
|
|
412
|
+
type Middleware = {
|
|
413
|
+
/**
|
|
414
|
+
* Unique identifier for this middleware.
|
|
415
|
+
*/
|
|
416
|
+
name: string;
|
|
417
|
+
/**
|
|
418
|
+
* Lifecycle event handlers for this middleware.
|
|
419
|
+
* Any event from the global `KubbHooks` map can be subscribed to here.
|
|
420
|
+
* Handlers are registered after all plugin handlers, so they always fire last.
|
|
421
|
+
*/
|
|
422
|
+
hooks: { [K in keyof KubbHooks]?: (...args: KubbHooks[K]) => void | Promise<void> };
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Creates a middleware factory using the hook-style `hooks` API.
|
|
426
|
+
*
|
|
427
|
+
* Middleware handlers fire after all plugin handlers for any given event, making them ideal for post-processing, logging, and auditing.
|
|
428
|
+
* Per-build state (such as accumulators) belongs inside the factory closure so each `createKubb` invocation gets its own isolated instance.
|
|
429
|
+
*
|
|
430
|
+
* @note The factory can accept typed options. See examples for using options and per-build state patterns.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* import { defineMiddleware } from '@kubb/core'
|
|
435
|
+
*
|
|
436
|
+
* // Stateless middleware
|
|
437
|
+
* export const logMiddleware = defineMiddleware(() => ({
|
|
438
|
+
* name: 'log-middleware',
|
|
439
|
+
* hooks: {
|
|
440
|
+
* 'kubb:build:end'({ files }) {
|
|
441
|
+
* console.log(`Build complete with ${files.length} files`)
|
|
442
|
+
* },
|
|
443
|
+
* },
|
|
444
|
+
* }))
|
|
445
|
+
*
|
|
446
|
+
* // Middleware with options and per-build state
|
|
447
|
+
* export const prefixMiddleware = defineMiddleware((options: { prefix: string } = { prefix: '' }) => {
|
|
448
|
+
* const seen = new Set<string>()
|
|
449
|
+
* return {
|
|
450
|
+
* name: 'prefix-middleware',
|
|
451
|
+
* hooks: {
|
|
452
|
+
* 'kubb:plugin:end'({ plugin }) {
|
|
453
|
+
* seen.add(`${options.prefix}${plugin.name}`)
|
|
454
|
+
* },
|
|
455
|
+
* },
|
|
456
|
+
* }
|
|
457
|
+
* })
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
declare function defineMiddleware<TOptions extends object = object>(factory: (options: TOptions) => Middleware): (options?: TOptions) => Middleware;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/defineParser.d.ts
|
|
463
|
+
type PrintOptions = {
|
|
464
|
+
extname?: FileNode['extname'];
|
|
465
|
+
};
|
|
466
|
+
type Parser<TMeta extends object = any> = {
|
|
467
|
+
name: string;
|
|
468
|
+
/**
|
|
469
|
+
* File extensions this parser handles.
|
|
470
|
+
* Use `undefined` to create a catch-all fallback parser.
|
|
471
|
+
*
|
|
472
|
+
* @example Handled extensions
|
|
473
|
+
* `['.ts', '.js']`
|
|
474
|
+
*/
|
|
475
|
+
extNames: Array<FileNode['extname']> | undefined;
|
|
476
|
+
/**
|
|
477
|
+
* Convert a resolved file to a string.
|
|
478
|
+
*/
|
|
479
|
+
parse(file: FileNode<TMeta>, options?: PrintOptions): Promise<string> | string;
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Defines a parser with type safety. Creates parsers that transform generated files to strings based on their extension.
|
|
483
|
+
*
|
|
484
|
+
* @note Call the returned factory with optional options to instantiate the parser.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```ts
|
|
488
|
+
* import { defineParser } from '@kubb/core'
|
|
489
|
+
*
|
|
490
|
+
* export const jsonParser = defineParser({
|
|
491
|
+
* name: 'json',
|
|
492
|
+
* extNames: ['.json'],
|
|
493
|
+
* parse(file) {
|
|
494
|
+
* const { extractStringsFromNodes } = await import('@kubb/ast')
|
|
495
|
+
* return file.sources.map((s) => extractStringsFromNodes(s.nodes ?? [])).join('\n')
|
|
496
|
+
* },
|
|
497
|
+
* })
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
declare function defineParser<TMeta extends object = any>(parser: Parser<TMeta>): Parser<TMeta>;
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/defineResolver.d.ts
|
|
503
|
+
/**
|
|
504
|
+
* Type/string pattern filter for include/exclude/override matching.
|
|
505
|
+
*/
|
|
506
|
+
type PatternFilter = {
|
|
507
|
+
type: string;
|
|
508
|
+
pattern: string | RegExp;
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Pattern filter with partial option overrides applied when the pattern matches.
|
|
512
|
+
*/
|
|
513
|
+
type PatternOverride<TOptions> = PatternFilter & {
|
|
514
|
+
options: Omit<Partial<TOptions>, 'override'>;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Context for resolving filtered options for a given operation or schema node.
|
|
518
|
+
*
|
|
519
|
+
* @internal
|
|
520
|
+
*/
|
|
521
|
+
type ResolveOptionsContext<TOptions> = {
|
|
522
|
+
options: TOptions;
|
|
523
|
+
exclude?: Array<PatternFilter>;
|
|
524
|
+
include?: Array<PatternFilter>;
|
|
525
|
+
override?: Array<PatternOverride<TOptions>>;
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Base constraint for all plugin resolver objects.
|
|
529
|
+
*
|
|
530
|
+
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
531
|
+
* are injected automatically by `defineResolver` — extend this type to add custom resolution methods.
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```ts
|
|
535
|
+
* type MyResolver = Resolver & {
|
|
536
|
+
* resolveName(node: SchemaNode): string
|
|
537
|
+
* resolveTypedName(node: SchemaNode): string
|
|
538
|
+
* }
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
type Resolver = {
|
|
542
|
+
name: string;
|
|
543
|
+
pluginName: string;
|
|
544
|
+
default(name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
545
|
+
resolveOptions<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
|
|
546
|
+
resolvePath(params: ResolverPathParams, context: ResolverContext): string;
|
|
547
|
+
resolveFile(params: ResolverFileParams, context: ResolverContext): FileNode;
|
|
548
|
+
resolveBanner(node: InputNode | null, context: ResolveBannerContext): string | undefined;
|
|
549
|
+
resolveFooter(node: InputNode | null, context: ResolveBannerContext): string | undefined;
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* File-specific parameters for `Resolver.resolvePath`.
|
|
553
|
+
*
|
|
554
|
+
* Pass alongside a `ResolverContext` to identify which file to resolve.
|
|
555
|
+
* Provide `tag` for tag-based grouping or `path` for path-based grouping.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* resolver.resolvePath(
|
|
560
|
+
* { baseName: 'petTypes.ts', tag: 'pets' },
|
|
561
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
562
|
+
* )
|
|
563
|
+
* // → '/src/types/petsController/petTypes.ts'
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
type ResolverPathParams = {
|
|
567
|
+
baseName: FileNode['baseName'];
|
|
568
|
+
pathMode?: 'single' | 'split';
|
|
569
|
+
/**
|
|
570
|
+
* Tag value used when `group.type === 'tag'`.
|
|
571
|
+
*/
|
|
572
|
+
tag?: string;
|
|
573
|
+
/**
|
|
574
|
+
* Path value used when `group.type === 'path'`.
|
|
575
|
+
*/
|
|
576
|
+
path?: string;
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Shared context passed as the second argument to `Resolver.resolvePath` and `Resolver.resolveFile`.
|
|
580
|
+
*
|
|
581
|
+
* Describes where on disk output is rooted, which output config is active, and the optional
|
|
582
|
+
* grouping strategy that controls subdirectory layout.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```ts
|
|
586
|
+
* const context: ResolverContext = {
|
|
587
|
+
* root: config.root,
|
|
588
|
+
* output,
|
|
589
|
+
* group,
|
|
590
|
+
* }
|
|
591
|
+
* ```
|
|
592
|
+
*/
|
|
593
|
+
type ResolverContext = {
|
|
594
|
+
root: string;
|
|
595
|
+
output: Output;
|
|
596
|
+
group?: Group;
|
|
597
|
+
/**
|
|
598
|
+
* Plugin name used to populate `meta.pluginName` on the resolved file.
|
|
599
|
+
*/
|
|
600
|
+
pluginName?: string;
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* File-specific parameters for `Resolver.resolveFile`.
|
|
604
|
+
*
|
|
605
|
+
* Pass alongside a `ResolverContext` to fully describe the file to resolve.
|
|
606
|
+
* `tag` and `path` are used only when a matching `group` is present in the context.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```ts
|
|
610
|
+
* resolver.resolveFile(
|
|
611
|
+
* { name: 'listPets', extname: '.ts', tag: 'pets' },
|
|
612
|
+
* { root: '/src', output: { path: 'types' }, group: { type: 'tag' } },
|
|
613
|
+
* )
|
|
614
|
+
* // → { baseName: 'listPets.ts', path: '/src/types/petsController/listPets.ts', ... }
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
type ResolverFileParams = {
|
|
618
|
+
name: string;
|
|
619
|
+
extname: FileNode['extname'];
|
|
620
|
+
/**
|
|
621
|
+
* Tag value used when `group.type === 'tag'`.
|
|
622
|
+
*/
|
|
623
|
+
tag?: string;
|
|
624
|
+
/**
|
|
625
|
+
* Path value used when `group.type === 'path'`.
|
|
626
|
+
*/
|
|
627
|
+
path?: string;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Context passed to `Resolver.resolveBanner` and `Resolver.resolveFooter`.
|
|
631
|
+
*
|
|
632
|
+
* `output` is optional — not every plugin configures a banner/footer.
|
|
633
|
+
* `config` carries the global Kubb config, used to derive the default Kubb banner.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* resolver.resolveBanner(inputNode, { output: { banner: '// generated' }, config })
|
|
638
|
+
* // → '// generated'
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
type ResolveBannerContext = {
|
|
642
|
+
output?: Pick<Output, 'banner' | 'footer'>;
|
|
643
|
+
config: Config;
|
|
644
|
+
};
|
|
645
|
+
/**
|
|
646
|
+
* Builder type for the plugin-specific resolver fields.
|
|
647
|
+
*
|
|
648
|
+
* `default`, `resolveOptions`, `resolvePath`, `resolveFile`, `resolveBanner`, and `resolveFooter`
|
|
649
|
+
* are optional — built-in fallbacks are injected when omitted.
|
|
650
|
+
*
|
|
651
|
+
* Methods in the returned object can call sibling resolver methods via `this`.
|
|
652
|
+
*/
|
|
653
|
+
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'>> & {
|
|
654
|
+
name: string;
|
|
655
|
+
pluginName: T['name'];
|
|
656
|
+
} & ThisType<T['resolver']>;
|
|
657
|
+
/**
|
|
658
|
+
* Default option resolver — applies include/exclude filters and merges matching override options.
|
|
659
|
+
*
|
|
660
|
+
* Returns `null` when the node is filtered out by an `exclude` rule or not matched by any `include` rule.
|
|
661
|
+
*
|
|
662
|
+
* @example Include/exclude filtering
|
|
663
|
+
* ```ts
|
|
664
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
665
|
+
* options: { output: 'types' },
|
|
666
|
+
* exclude: [{ type: 'tag', pattern: 'internal' }],
|
|
667
|
+
* })
|
|
668
|
+
* // → null when node has tag 'internal'
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @example Override merging
|
|
672
|
+
* ```ts
|
|
673
|
+
* const options = defaultResolveOptions(operationNode, {
|
|
674
|
+
* options: { enumType: 'asConst' },
|
|
675
|
+
* override: [{ type: 'operationId', pattern: 'listPets', options: { enumType: 'enum' } }],
|
|
676
|
+
* })
|
|
677
|
+
* // → { enumType: 'enum' } when operationId matches
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
/**
|
|
681
|
+
* Defines a resolver for a plugin, injecting built-in defaults for name casing,
|
|
682
|
+
* include/exclude/override filtering, path resolution, and file construction.
|
|
683
|
+
*
|
|
684
|
+
* All four defaults can be overridden by providing them in the builder function:
|
|
685
|
+
* - `default` — name casing strategy (camelCase / PascalCase)
|
|
686
|
+
* - `resolveOptions` — include/exclude/override filtering
|
|
687
|
+
* - `resolvePath` — output path computation
|
|
688
|
+
* - `resolveFile` — full `FileNode` construction
|
|
689
|
+
*
|
|
690
|
+
* Methods in the returned object can call sibling resolver methods via `this`.
|
|
691
|
+
*
|
|
692
|
+
* @example Basic resolver with naming helpers
|
|
693
|
+
* ```ts
|
|
694
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
695
|
+
* name: 'default',
|
|
696
|
+
* resolveName(node) {
|
|
697
|
+
* return this.default(node.name, 'function')
|
|
698
|
+
* },
|
|
699
|
+
* resolveTypedName(node) {
|
|
700
|
+
* return this.default(node.name, 'type')
|
|
701
|
+
* },
|
|
702
|
+
* }))
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
705
|
+
* @example Override resolvePath for a custom output structure
|
|
706
|
+
* ```ts
|
|
707
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
708
|
+
* name: 'custom',
|
|
709
|
+
* resolvePath({ baseName }, { root, output }) {
|
|
710
|
+
* return path.resolve(root, output.path, 'generated', baseName)
|
|
711
|
+
* },
|
|
712
|
+
* }))
|
|
713
|
+
* ```
|
|
714
|
+
*
|
|
715
|
+
* @example Use this.default inside a helper
|
|
716
|
+
* ```ts
|
|
717
|
+
* export const resolver = defineResolver<PluginTs>(() => ({
|
|
718
|
+
* name: 'default',
|
|
719
|
+
* resolveParamName(node, param) {
|
|
720
|
+
* return this.default(`${node.operationId} ${param.in} ${param.name}`, 'type')
|
|
721
|
+
* },
|
|
722
|
+
* }))
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
declare function defineResolver<T extends PluginFactoryOptions>(build: ResolverBuilder<T>): T['resolver'];
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/definePlugin.d.ts
|
|
728
|
+
/**
|
|
729
|
+
* Safely extracts a type from a registry, returning `{}` if the key doesn't exist.
|
|
730
|
+
* Enables optional interface augmentation for `Kubb.ConfigOptionsRegistry` and `Kubb.PluginOptionsRegistry`
|
|
731
|
+
* without requiring changes to core.
|
|
732
|
+
*
|
|
733
|
+
* @internal
|
|
734
|
+
*/
|
|
735
|
+
type ExtractRegistryKey$1<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
|
|
736
|
+
/**
|
|
737
|
+
* Output configuration for generated files.
|
|
738
|
+
*/
|
|
739
|
+
type Output<_TOptions = unknown> = {
|
|
740
|
+
/**
|
|
741
|
+
* Output folder or file path for generated code.
|
|
742
|
+
*/
|
|
743
|
+
path: string;
|
|
744
|
+
/**
|
|
745
|
+
* Text or function prepended to every generated file.
|
|
746
|
+
* When a function, receives the current `InputNode` and returns a string.
|
|
747
|
+
*/
|
|
748
|
+
banner?: string | ((node?: InputNode) => string);
|
|
749
|
+
/**
|
|
750
|
+
* Text or function appended to every generated file.
|
|
751
|
+
* When a function, receives the current `InputNode` and returns a string.
|
|
752
|
+
*/
|
|
753
|
+
footer?: string | ((node?: InputNode) => string);
|
|
754
|
+
/**
|
|
755
|
+
* Whether to override existing external files if they already exist.
|
|
756
|
+
* @default false
|
|
757
|
+
*/
|
|
758
|
+
override?: boolean;
|
|
759
|
+
} & ExtractRegistryKey$1<Kubb.PluginOptionsRegistry, 'output'>;
|
|
760
|
+
type Group = {
|
|
761
|
+
/**
|
|
762
|
+
* How to group files into subdirectories.
|
|
763
|
+
* - `'tag'` — group by OpenAPI tags
|
|
764
|
+
* - `'path'` — group by OpenAPI paths
|
|
765
|
+
*/
|
|
766
|
+
type: 'tag' | 'path';
|
|
767
|
+
/**
|
|
768
|
+
* Function that returns the subdirectory name for a group value.
|
|
769
|
+
* Defaults to `${camelCase(group)}Controller` for tags, first path segment for paths.
|
|
770
|
+
*/
|
|
771
|
+
name?: (context: {
|
|
772
|
+
group: string;
|
|
773
|
+
}) => string;
|
|
774
|
+
};
|
|
775
|
+
type ByTag = {
|
|
776
|
+
/**
|
|
777
|
+
* Filter by OpenAPI `tags` field. Matches one or more tags assigned to operations.
|
|
778
|
+
*/
|
|
779
|
+
type: 'tag';
|
|
780
|
+
/**
|
|
781
|
+
* Tag name to match (case-sensitive). Can be a literal string or regex pattern.
|
|
782
|
+
*/
|
|
783
|
+
pattern: string | RegExp;
|
|
784
|
+
};
|
|
785
|
+
type ByOperationId = {
|
|
786
|
+
/**
|
|
787
|
+
* Filter by OpenAPI `operationId` field. Each operation (GET, POST, etc.) has a unique identifier.
|
|
788
|
+
*/
|
|
789
|
+
type: 'operationId';
|
|
790
|
+
/**
|
|
791
|
+
* Operation ID to match (case-sensitive). Can be a literal string or regex pattern.
|
|
792
|
+
*/
|
|
793
|
+
pattern: string | RegExp;
|
|
794
|
+
};
|
|
795
|
+
type ByPath = {
|
|
796
|
+
/**
|
|
797
|
+
* Filter by OpenAPI `path` (URL endpoint). Useful to group or filter by service segments like `/pets`, `/users`, etc.
|
|
798
|
+
*/
|
|
799
|
+
type: 'path';
|
|
800
|
+
/**
|
|
801
|
+
* URL path to match (case-sensitive). Can be a literal string or regex pattern. Matches against the full path.
|
|
802
|
+
*/
|
|
803
|
+
pattern: string | RegExp;
|
|
804
|
+
};
|
|
805
|
+
type ByMethod = {
|
|
806
|
+
/**
|
|
807
|
+
* Filter by HTTP method: `'get'`, `'post'`, `'put'`, `'delete'`, `'patch'`, `'head'`, `'options'`.
|
|
808
|
+
*/
|
|
809
|
+
type: 'method';
|
|
810
|
+
/**
|
|
811
|
+
* HTTP method to match (case-insensitive when using string, or regex for dynamic matching).
|
|
812
|
+
*/
|
|
813
|
+
pattern: HttpMethod | RegExp;
|
|
814
|
+
};
|
|
815
|
+
type BySchemaName = {
|
|
816
|
+
/**
|
|
817
|
+
* Filter by schema component name (TypeScript or JSON schema). Matches schemas in `#/components/schemas`.
|
|
818
|
+
*/
|
|
819
|
+
type: 'schemaName';
|
|
820
|
+
/**
|
|
821
|
+
* Schema name to match (case-sensitive). Can be a literal string or regex pattern.
|
|
822
|
+
*/
|
|
823
|
+
pattern: string | RegExp;
|
|
824
|
+
};
|
|
825
|
+
type ByContentType = {
|
|
826
|
+
/**
|
|
827
|
+
* Filter by response or request content type: `'application/json'`, `'application/xml'`, etc.
|
|
828
|
+
*/
|
|
829
|
+
type: 'contentType';
|
|
830
|
+
/**
|
|
831
|
+
* Content type to match (case-sensitive). Can be a literal string or regex pattern.
|
|
832
|
+
*/
|
|
833
|
+
pattern: string | RegExp;
|
|
834
|
+
};
|
|
835
|
+
/**
|
|
836
|
+
* A pattern filter that prevents matching nodes from being generated.
|
|
837
|
+
*
|
|
838
|
+
* Use to skip code generation for specific operations or schemas. For example, exclude deprecated endpoints
|
|
839
|
+
* or internal-only schemas. Can filter by tag, operationId, path, HTTP method, content type, or schema name.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* exclude: [
|
|
844
|
+
* { type: 'tag', pattern: 'internal' }, // skip "internal" tag
|
|
845
|
+
* { type: 'path', pattern: /^\/admin/ }, // skip all /admin endpoints
|
|
846
|
+
* { type: 'operationId', pattern: 'deprecated_*' } // skip operationIds matching pattern
|
|
847
|
+
* ]
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
|
|
851
|
+
/**
|
|
852
|
+
* A pattern filter that restricts generation to only matching nodes.
|
|
853
|
+
*
|
|
854
|
+
* Use to generate code for a subset of operations or schemas. For example, only generate for a specific service
|
|
855
|
+
* tag or only for "production" endpoints. Can filter by tag, operationId, path, HTTP method, content type, or schema name.
|
|
856
|
+
*
|
|
857
|
+
* @example
|
|
858
|
+
* ```ts
|
|
859
|
+
* include: [
|
|
860
|
+
* { type: 'tag', pattern: 'public' }, // generate only "public" tag
|
|
861
|
+
* { type: 'path', pattern: /^\/api\/v1/ }, // generate only v1 endpoints
|
|
862
|
+
* ]
|
|
863
|
+
* ```
|
|
864
|
+
*/
|
|
865
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
|
|
866
|
+
/**
|
|
867
|
+
* A pattern filter paired with partial option overrides applied when the pattern matches.
|
|
868
|
+
*
|
|
869
|
+
* Use to customize generation for specific operations or schemas. For example, apply different output paths
|
|
870
|
+
* for different tags, or use custom resolver functions per operation. Can filter by tag, operationId, path,
|
|
871
|
+
* HTTP method, schema name, or content type.
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```ts
|
|
875
|
+
* override: [
|
|
876
|
+
* {
|
|
877
|
+
* type: 'tag',
|
|
878
|
+
* pattern: 'admin',
|
|
879
|
+
* options: { output: { path: './src/gen/admin' } } // admin APIs go to separate folder
|
|
880
|
+
* },
|
|
881
|
+
* {
|
|
882
|
+
* type: 'operationId',
|
|
883
|
+
* pattern: 'listPets',
|
|
884
|
+
* options: { exclude: true } // skip this specific operation
|
|
885
|
+
* }
|
|
886
|
+
* ]
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
890
|
+
options: Partial<TOptions>;
|
|
891
|
+
};
|
|
892
|
+
type PluginFactoryOptions<
|
|
893
|
+
/**
|
|
894
|
+
* Unique plugin name.
|
|
895
|
+
*/
|
|
896
|
+
TName extends string = string,
|
|
897
|
+
/**
|
|
898
|
+
* User-facing plugin options.
|
|
899
|
+
*/
|
|
900
|
+
TOptions extends object = object,
|
|
901
|
+
/**
|
|
902
|
+
* Plugin options after defaults are applied.
|
|
903
|
+
*/
|
|
904
|
+
TResolvedOptions extends object = TOptions,
|
|
905
|
+
/**
|
|
906
|
+
* Resolver that encapsulates naming and path-resolution helpers.
|
|
907
|
+
* Define with `defineResolver` and export alongside the plugin.
|
|
908
|
+
*/
|
|
909
|
+
TResolver extends Resolver = Resolver> = {
|
|
910
|
+
name: TName;
|
|
911
|
+
options: TOptions;
|
|
912
|
+
resolvedOptions: TResolvedOptions;
|
|
913
|
+
resolver: TResolver;
|
|
914
|
+
};
|
|
915
|
+
/**
|
|
916
|
+
* Context for hook-style plugin `kubb:plugin:setup` handler.
|
|
917
|
+
* Provides methods to register generators, configure resolvers, transformers, and renderers.
|
|
918
|
+
*/
|
|
919
|
+
type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
920
|
+
/**
|
|
921
|
+
* Register a generator dynamically. Generators fire during the AST walk (schema/operation/operations)
|
|
922
|
+
* just like generators declared statically on `createPlugin`.
|
|
923
|
+
*/
|
|
924
|
+
addGenerator<TElement = unknown>(generator: Generator<TFactory, TElement>): void;
|
|
925
|
+
/**
|
|
926
|
+
* Set or override the resolver for this plugin.
|
|
927
|
+
* The resolver controls file naming and path resolution.
|
|
928
|
+
*/
|
|
929
|
+
setResolver(resolver: Partial<TFactory['resolver']>): void;
|
|
930
|
+
/**
|
|
931
|
+
* Set the AST transformer to pre-process nodes before they reach generators.
|
|
932
|
+
*/
|
|
933
|
+
setTransformer(visitor: Visitor): void;
|
|
934
|
+
/**
|
|
935
|
+
* Set the renderer factory to process JSX elements from generators.
|
|
936
|
+
*/
|
|
937
|
+
setRenderer(renderer: RendererFactory): void;
|
|
938
|
+
/**
|
|
939
|
+
* Set resolved options merged into the normalized plugin's `options`.
|
|
940
|
+
* Call this in `kubb:plugin:setup` to provide options generators need.
|
|
941
|
+
*/
|
|
942
|
+
setOptions(options: TFactory['resolvedOptions']): void;
|
|
943
|
+
/**
|
|
944
|
+
* Inject a raw file into the build output, bypassing the generation pipeline.
|
|
945
|
+
*/
|
|
946
|
+
injectFile(userFileNode: UserFileNode): void;
|
|
947
|
+
/**
|
|
948
|
+
* Merge a partial config update into the current build configuration.
|
|
949
|
+
*/
|
|
950
|
+
updateConfig(config: Partial<Config>): void;
|
|
951
|
+
/**
|
|
952
|
+
* The resolved build configuration at setup time.
|
|
953
|
+
*/
|
|
954
|
+
config: Config;
|
|
955
|
+
/**
|
|
956
|
+
* The plugin's user-provided options.
|
|
957
|
+
*/
|
|
958
|
+
options: TFactory['options'];
|
|
959
|
+
};
|
|
960
|
+
/**
|
|
961
|
+
* A plugin object produced by `definePlugin`.
|
|
962
|
+
* Instead of flat lifecycle methods, it groups all handlers under a `hooks:` property
|
|
963
|
+
* (matching Astro's integration naming convention).
|
|
964
|
+
*
|
|
965
|
+
* @template TFactory - The plugin's `PluginFactoryOptions` type.
|
|
966
|
+
*/
|
|
967
|
+
type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
968
|
+
/**
|
|
969
|
+
* Unique name for the plugin, following the same naming convention as `createPlugin`.
|
|
970
|
+
*/
|
|
971
|
+
name: string;
|
|
972
|
+
/**
|
|
973
|
+
* Plugins that must be registered before this plugin executes.
|
|
974
|
+
* An error is thrown at startup when any listed dependency is missing.
|
|
975
|
+
*/
|
|
976
|
+
dependencies?: Array<string>;
|
|
977
|
+
/**
|
|
978
|
+
* Controls the execution order of this plugin relative to others.
|
|
979
|
+
*
|
|
980
|
+
* - `'pre'` — runs before all normal plugins.
|
|
981
|
+
* - `'post'` — runs after all normal plugins.
|
|
982
|
+
* - `undefined` (default) — runs in declaration order among normal plugins.
|
|
983
|
+
*
|
|
984
|
+
* Dependency constraints always take precedence over `enforce`.
|
|
985
|
+
*/
|
|
986
|
+
enforce?: 'pre' | 'post';
|
|
987
|
+
/**
|
|
988
|
+
* The options passed by the user when calling the plugin factory.
|
|
989
|
+
*/
|
|
990
|
+
options?: TFactory['options'];
|
|
991
|
+
/**
|
|
992
|
+
* Lifecycle event handlers for this plugin.
|
|
993
|
+
* Any event from the global `KubbHooks` map can be subscribed to here.
|
|
994
|
+
*/
|
|
995
|
+
hooks: { [K in keyof KubbHooks as K extends 'kubb:plugin:setup' ? never : K]?: (...args: KubbHooks[K]) => void | Promise<void> } & {
|
|
996
|
+
'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>;
|
|
997
|
+
};
|
|
998
|
+
};
|
|
999
|
+
/**
|
|
1000
|
+
* Normalized plugin after setup, with runtime fields populated.
|
|
1001
|
+
* For internal use only — plugins use the public `Plugin` type externally.
|
|
1002
|
+
*
|
|
1003
|
+
* @internal
|
|
1004
|
+
*/
|
|
1005
|
+
type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {
|
|
1006
|
+
options: TOptions['resolvedOptions'] & {
|
|
1007
|
+
output: Output;
|
|
1008
|
+
include?: Array<Include>;
|
|
1009
|
+
exclude: Array<Exclude>;
|
|
1010
|
+
override: Array<Override<TOptions['resolvedOptions']>>;
|
|
1011
|
+
};
|
|
1012
|
+
resolver: TOptions['resolver'];
|
|
1013
|
+
transformer?: Visitor;
|
|
1014
|
+
renderer?: RendererFactory;
|
|
1015
|
+
generators?: Array<Generator>;
|
|
1016
|
+
apply?: (config: Config) => boolean;
|
|
1017
|
+
version?: string;
|
|
1018
|
+
};
|
|
1019
|
+
type KubbPluginStartContext = {
|
|
1020
|
+
plugin: NormalizedPlugin;
|
|
1021
|
+
};
|
|
1022
|
+
type KubbPluginEndContext = {
|
|
1023
|
+
plugin: NormalizedPlugin;
|
|
1024
|
+
duration: number;
|
|
1025
|
+
success: boolean;
|
|
1026
|
+
error?: Error;
|
|
1027
|
+
config: Config;
|
|
1028
|
+
/**
|
|
1029
|
+
* Returns all files currently in the file manager (lazy snapshot).
|
|
1030
|
+
* Includes files added by plugins that have already run.
|
|
1031
|
+
*/
|
|
1032
|
+
readonly files: ReadonlyArray<FileNode>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Upsert one or more files into the file manager.
|
|
1035
|
+
*/
|
|
1036
|
+
upsertFile: (...files: Array<FileNode>) => void;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Wraps a factory function and returns a typed `Plugin` with lifecycle handlers grouped under `hooks`.
|
|
1040
|
+
*
|
|
1041
|
+
* Handlers live in a single `hooks` object (inspired by Astro integrations).
|
|
1042
|
+
* All lifecycle events from `KubbHooks` are available for subscription.
|
|
1043
|
+
*
|
|
1044
|
+
* @note For real plugins, use a `PluginFactoryOptions` type parameter to get type-safe context in `kubb:plugin:setup`.
|
|
1045
|
+
* Plugin names should follow the convention `plugin-<feature>` (e.g., `plugin-react-query`, `plugin-zod`).
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```ts
|
|
1049
|
+
* import { definePlugin } from '@kubb/core'
|
|
1050
|
+
*
|
|
1051
|
+
* export const pluginTs = definePlugin((options: { prefix?: string } = {}) => ({
|
|
1052
|
+
* name: 'plugin-ts',
|
|
1053
|
+
* hooks: {
|
|
1054
|
+
* 'kubb:plugin:setup'(ctx) {
|
|
1055
|
+
* ctx.setResolver(resolverTs)
|
|
1056
|
+
* },
|
|
1057
|
+
* },
|
|
1058
|
+
* }))
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): (options?: TFactory['options']) => Plugin<TFactory>;
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/FileManager.d.ts
|
|
1064
|
+
/**
|
|
1065
|
+
* In-memory file store for generated files.
|
|
1066
|
+
*
|
|
1067
|
+
* Files with the same `path` are merged — sources, imports, and exports are concatenated.
|
|
1068
|
+
* The `files` getter returns all stored files sorted by path length (shortest first).
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```ts
|
|
1072
|
+
* import { FileManager } from '@kubb/core'
|
|
1073
|
+
*
|
|
1074
|
+
* const manager = new FileManager()
|
|
1075
|
+
* manager.upsert(myFile)
|
|
1076
|
+
* console.log(manager.files) // all stored files
|
|
1077
|
+
* ```
|
|
1078
|
+
*/
|
|
1079
|
+
declare class FileManager {
|
|
1080
|
+
#private;
|
|
1081
|
+
/**
|
|
1082
|
+
* Adds one or more files. Incoming files with the same path are merged
|
|
1083
|
+
* (sources/imports/exports concatenated), but existing cache entries are
|
|
1084
|
+
* replaced — use {@link upsert} when you want to merge into the cache too.
|
|
1085
|
+
*/
|
|
1086
|
+
add(...files: Array<FileNode>): Array<FileNode>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Adds or merges one or more files.
|
|
1089
|
+
* If a file with the same path already exists in the cache, its
|
|
1090
|
+
* sources/imports/exports are merged into the incoming file.
|
|
1091
|
+
*/
|
|
1092
|
+
upsert(...files: Array<FileNode>): Array<FileNode>;
|
|
1093
|
+
getByPath(path: string): FileNode | null;
|
|
1094
|
+
deleteByPath(path: string): void;
|
|
1095
|
+
clear(): void;
|
|
1096
|
+
/**
|
|
1097
|
+
* All stored files, sorted by path length (shorter paths first).
|
|
1098
|
+
*/
|
|
1099
|
+
get files(): Array<FileNode>;
|
|
1100
|
+
}
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region src/PluginDriver.d.ts
|
|
1103
|
+
type Options = {
|
|
1104
|
+
hooks: AsyncEventEmitter<KubbHooks>;
|
|
1105
|
+
};
|
|
1106
|
+
declare class PluginDriver {
|
|
1107
|
+
#private;
|
|
1108
|
+
readonly config: Config;
|
|
1109
|
+
readonly options: Options;
|
|
1110
|
+
/**
|
|
1111
|
+
* Returns `'single'` when `fileOrFolder` has a file extension, `'split'` otherwise.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```ts
|
|
1115
|
+
* PluginDriver.getMode('src/gen/types.ts') // 'single'
|
|
1116
|
+
* PluginDriver.getMode('src/gen/types') // 'split'
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
1119
|
+
static getMode(fileOrFolder: string | undefined | null): 'single' | 'split';
|
|
1120
|
+
/**
|
|
1121
|
+
* The universal `@kubb/ast` `InputNode` produced by the adapter, set by
|
|
1122
|
+
* the build pipeline after the adapter's `parse()` resolves.
|
|
1123
|
+
*/
|
|
1124
|
+
inputNode: InputNode | undefined;
|
|
1125
|
+
adapter: Adapter | undefined;
|
|
1126
|
+
/**
|
|
1127
|
+
* Central file store for all generated files.
|
|
1128
|
+
* Plugins should use `this.addFile()` / `this.upsertFile()` (via their context) to
|
|
1129
|
+
* add files; this property gives direct read/write access when needed.
|
|
1130
|
+
*/
|
|
1131
|
+
readonly fileManager: FileManager;
|
|
1132
|
+
readonly plugins: Map<string, NormalizedPlugin>;
|
|
1133
|
+
constructor(config: Config, options: Options);
|
|
1134
|
+
get hooks(): AsyncEventEmitter<KubbHooks>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Registers a hook-style plugin's lifecycle handlers on the shared `AsyncEventEmitter`.
|
|
1137
|
+
*
|
|
1138
|
+
* For `kubb:plugin:setup`, the registered listener wraps the globally emitted context with a
|
|
1139
|
+
* plugin-specific one so that `addGenerator`, `setResolver`, `setTransformer`, and
|
|
1140
|
+
* `setRenderer` all target the correct `normalizedPlugin` entry in the plugins map.
|
|
1141
|
+
*
|
|
1142
|
+
* All other hooks are iterated and registered directly as pass-through listeners.
|
|
1143
|
+
* Any event key present in the global `KubbHooks` interface can be subscribed to.
|
|
1144
|
+
*
|
|
1145
|
+
* External tooling can subscribe to any of these events via `hooks.on(...)` to observe
|
|
1146
|
+
* the plugin lifecycle without modifying plugin behavior.
|
|
1147
|
+
*
|
|
1148
|
+
* @internal
|
|
1149
|
+
*/
|
|
1150
|
+
registerPluginHooks(hookPlugin: Plugin, normalizedPlugin: NormalizedPlugin): void;
|
|
1151
|
+
/**
|
|
1152
|
+
* Emits the `kubb:plugin:setup` event so that all registered hook-style plugin listeners
|
|
1153
|
+
* can configure generators, resolvers, transformers and renderers before `buildStart` runs.
|
|
1154
|
+
*
|
|
1155
|
+
* Call this once from `safeBuild` before the plugin execution loop begins.
|
|
1156
|
+
*/
|
|
1157
|
+
emitSetupHooks(): Promise<void>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Registers a generator for the given plugin on the shared event emitter.
|
|
1160
|
+
*
|
|
1161
|
+
* The generator's `schema`, `operation`, and `operations` methods are registered as
|
|
1162
|
+
* listeners on `kubb:generate:schema`, `kubb:generate:operation`, and `kubb:generate:operations`
|
|
1163
|
+
* respectively. Each listener is scoped to the owning plugin via a `ctx.plugin.name` check
|
|
1164
|
+
* so that generators from different plugins do not cross-fire.
|
|
1165
|
+
*
|
|
1166
|
+
* The renderer resolution chain is: `generator.renderer → plugin.renderer → config.renderer`.
|
|
1167
|
+
* Set `generator.renderer = null` to explicitly opt out of rendering even when the plugin
|
|
1168
|
+
* declares a renderer.
|
|
1169
|
+
*
|
|
1170
|
+
* Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
|
|
1171
|
+
*/
|
|
1172
|
+
registerGenerator(pluginName: string, gen: Generator): void;
|
|
1173
|
+
/**
|
|
1174
|
+
* Returns `true` when at least one generator was registered for the given plugin
|
|
1175
|
+
* via `addGenerator()` in `kubb:plugin:setup` (event-based path).
|
|
1176
|
+
*
|
|
1177
|
+
* Used by the build loop to decide whether to walk the AST and emit generator events
|
|
1178
|
+
* for a plugin that has no static `plugin.generators`.
|
|
1179
|
+
*/
|
|
1180
|
+
hasRegisteredGenerators(pluginName: string): boolean;
|
|
1181
|
+
/**
|
|
1182
|
+
* Unregisters all plugin lifecycle listeners from the shared event emitter.
|
|
1183
|
+
* Called at the end of a build to prevent listener leaks across repeated builds.
|
|
1184
|
+
*
|
|
1185
|
+
* @internal
|
|
1186
|
+
*/
|
|
1187
|
+
dispose(): void;
|
|
1188
|
+
/**
|
|
1189
|
+
* Merges `partial` with the plugin's default resolver and stores the result.
|
|
1190
|
+
* Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`
|
|
1191
|
+
* get the up-to-date resolver without going through `getResolver()`.
|
|
1192
|
+
*/
|
|
1193
|
+
setPluginResolver(pluginName: string, partial: Partial<Resolver>): void;
|
|
1194
|
+
/**
|
|
1195
|
+
* Returns the resolver for the given plugin.
|
|
1196
|
+
*
|
|
1197
|
+
* Resolution order: dynamic resolver set via `setPluginResolver` → static resolver on the
|
|
1198
|
+
* plugin → lazily created default resolver (identity name, no path transforms).
|
|
1199
|
+
*/
|
|
1200
|
+
getResolver<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Kubb.PluginRegistry[TName]['resolver'];
|
|
1201
|
+
getResolver<TResolver extends Resolver = Resolver>(pluginName: string): TResolver;
|
|
1202
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): GeneratorContext<TOptions> & Record<string, unknown>;
|
|
1203
|
+
getPlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
|
|
1204
|
+
getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined;
|
|
1205
|
+
/**
|
|
1206
|
+
* Like `getPlugin` but throws a descriptive error when the plugin is not found.
|
|
1207
|
+
*/
|
|
1208
|
+
requirePlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]>;
|
|
1209
|
+
requirePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions>;
|
|
1210
|
+
}
|
|
1211
|
+
//#endregion
|
|
1212
|
+
//#region src/defineGenerator.d.ts
|
|
1213
|
+
/**
|
|
1214
|
+
* Context object passed to generator `schema`, `operation`, and `operations` methods.
|
|
1215
|
+
*
|
|
1216
|
+
* The adapter is always defined (guaranteed by `runPluginAstHooks`) so no runtime checks
|
|
1217
|
+
* are needed. `ctx.options` carries resolved per-node options after exclude/include/override
|
|
1218
|
+
* filtering for individual schema/operation calls, or plugin-level options for operations.
|
|
1219
|
+
*/
|
|
1220
|
+
type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
1221
|
+
config: Config;
|
|
1222
|
+
/**
|
|
1223
|
+
* Absolute path to the current plugin's output directory.
|
|
1224
|
+
*/
|
|
1225
|
+
root: string;
|
|
1226
|
+
/**
|
|
1227
|
+
* Determine output mode based on the output config.
|
|
1228
|
+
* Returns `'single'` when `output.path` is a file, `'split'` for a directory.
|
|
1229
|
+
*/
|
|
1230
|
+
getMode: (output: {
|
|
1231
|
+
path: string;
|
|
1232
|
+
}) => 'single' | 'split';
|
|
1233
|
+
driver: PluginDriver;
|
|
1234
|
+
/**
|
|
1235
|
+
* Get a plugin by name, typed via `Kubb.PluginRegistry` when registered.
|
|
1236
|
+
*/
|
|
1237
|
+
getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
|
|
1238
|
+
getPlugin(name: string): Plugin | undefined;
|
|
1239
|
+
/**
|
|
1240
|
+
* Get a plugin by name, throws an error if not found.
|
|
1241
|
+
*/
|
|
1242
|
+
requirePlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]>;
|
|
1243
|
+
requirePlugin(name: string): Plugin;
|
|
1244
|
+
/**
|
|
1245
|
+
* Get a resolver by plugin name, typed via `Kubb.PluginRegistry` when registered.
|
|
1246
|
+
*/
|
|
1247
|
+
getResolver<TName extends keyof Kubb.PluginRegistry>(name: TName): Kubb.PluginRegistry[TName]['resolver'];
|
|
1248
|
+
getResolver(name: string): Resolver;
|
|
1249
|
+
/**
|
|
1250
|
+
* Add files only if they don't exist.
|
|
1251
|
+
*/
|
|
1252
|
+
addFile: (...file: Array<FileNode>) => Promise<void>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Merge sources into the same output file.
|
|
1255
|
+
*/
|
|
1256
|
+
upsertFile: (...file: Array<FileNode>) => Promise<void>;
|
|
1257
|
+
hooks: AsyncEventEmitter<KubbHooks>;
|
|
1258
|
+
/**
|
|
1259
|
+
* The current plugin instance.
|
|
1260
|
+
*/
|
|
1261
|
+
plugin: Plugin<TOptions>;
|
|
1262
|
+
/**
|
|
1263
|
+
* The current plugin's resolver.
|
|
1264
|
+
*/
|
|
1265
|
+
resolver: TOptions['resolver'];
|
|
1266
|
+
/**
|
|
1267
|
+
* The current plugin's transformer.
|
|
1268
|
+
*/
|
|
1269
|
+
transformer: Visitor | undefined;
|
|
1270
|
+
/**
|
|
1271
|
+
* Emit a warning.
|
|
1272
|
+
*/
|
|
1273
|
+
warn: (message: string) => void;
|
|
1274
|
+
/**
|
|
1275
|
+
* Emit an error.
|
|
1276
|
+
*/
|
|
1277
|
+
error: (error: string | Error) => void;
|
|
1278
|
+
/**
|
|
1279
|
+
* Emit an info message.
|
|
1280
|
+
*/
|
|
1281
|
+
info: (message: string) => void;
|
|
1282
|
+
/**
|
|
1283
|
+
* Open the current input node in Kubb Studio.
|
|
1284
|
+
*/
|
|
1285
|
+
openInStudio: (options?: DevtoolsOptions) => Promise<void>;
|
|
1286
|
+
/**
|
|
1287
|
+
* The configured adapter instance.
|
|
1288
|
+
*/
|
|
1289
|
+
adapter: Adapter;
|
|
1290
|
+
/**
|
|
1291
|
+
* The universal `InputNode` produced by the adapter.
|
|
1292
|
+
*/
|
|
1293
|
+
inputNode: InputNode;
|
|
1294
|
+
/**
|
|
1295
|
+
* Resolved options after exclude/include/override filtering.
|
|
1296
|
+
*/
|
|
1297
|
+
options: TOptions['resolvedOptions'];
|
|
1298
|
+
};
|
|
1299
|
+
/**
|
|
1300
|
+
* Declares a named generator unit that walks the AST and emits files.
|
|
1301
|
+
*
|
|
1302
|
+
* Each method (`schema`, `operation`, `operations`) is called for the matching node type.
|
|
1303
|
+
* Each method returns `TElement | Array<FileNode> | void`. JSX-based generators require a `renderer` factory.
|
|
1304
|
+
* Return `Array<FileNode>` directly or call `ctx.upsertFile()` manually and return `void` to bypass rendering.
|
|
1305
|
+
*
|
|
1306
|
+
* @note Generators are consumed by plugins and registered via `ctx.addGenerator()` in `kubb:plugin:setup`.
|
|
1307
|
+
*
|
|
1308
|
+
* @example
|
|
1309
|
+
* ```ts
|
|
1310
|
+
* import { defineGenerator } from '@kubb/core'
|
|
1311
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
1312
|
+
*
|
|
1313
|
+
* export const typeGenerator = defineGenerator({
|
|
1314
|
+
* name: 'typescript',
|
|
1315
|
+
* renderer: jsxRenderer,
|
|
1316
|
+
* schema(node, ctx) {
|
|
1317
|
+
* const { adapter, resolver, root, options } = ctx
|
|
1318
|
+
* return <File ...><Type node={node} resolver={resolver} /></File>
|
|
1319
|
+
* },
|
|
1320
|
+
* })
|
|
1321
|
+
* ```
|
|
1322
|
+
*/
|
|
1323
|
+
type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown> = {
|
|
1324
|
+
/**
|
|
1325
|
+
* Used in diagnostic messages and debug output.
|
|
1326
|
+
*/
|
|
1327
|
+
name: string;
|
|
1328
|
+
/**
|
|
1329
|
+
* Optional renderer factory that produces a {@link Renderer} for each render cycle.
|
|
1330
|
+
*
|
|
1331
|
+
* Generators that return renderer elements (e.g. JSX via `@kubb/renderer-jsx`) must set this
|
|
1332
|
+
* to the matching renderer factory (e.g. `jsxRenderer` from `@kubb/renderer-jsx`).
|
|
1333
|
+
*
|
|
1334
|
+
* Generators that only return `Array<FileNode>` or `void` do not need to set this.
|
|
1335
|
+
*
|
|
1336
|
+
* Set `renderer: null` to explicitly opt out of rendering even when the parent plugin
|
|
1337
|
+
* declares a `renderer` (overrides the plugin-level fallback).
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```ts
|
|
1341
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
1342
|
+
* export const myGenerator = defineGenerator<PluginTs>({
|
|
1343
|
+
* renderer: jsxRenderer,
|
|
1344
|
+
* schema(node, ctx) { return <File ...>...</File> },
|
|
1345
|
+
* })
|
|
1346
|
+
* ```
|
|
1347
|
+
*/
|
|
1348
|
+
renderer?: RendererFactory<TElement> | null;
|
|
1349
|
+
/**
|
|
1350
|
+
* Called for each schema node in the AST walk.
|
|
1351
|
+
* `ctx` carries the plugin context with `adapter` and `inputNode` guaranteed present,
|
|
1352
|
+
* plus `ctx.options` with the per-node resolved options (after exclude/include/override).
|
|
1353
|
+
*/
|
|
1354
|
+
schema?: (node: SchemaNode, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | void>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Called for each operation node in the AST walk.
|
|
1357
|
+
* `ctx` carries the plugin context with `adapter` and `inputNode` guaranteed present,
|
|
1358
|
+
* plus `ctx.options` with the per-node resolved options (after exclude/include/override).
|
|
1359
|
+
*/
|
|
1360
|
+
operation?: (node: OperationNode, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | void>;
|
|
1361
|
+
/**
|
|
1362
|
+
* Called once after all operations have been walked.
|
|
1363
|
+
* `ctx` carries the plugin context with `adapter` and `inputNode` guaranteed present,
|
|
1364
|
+
* plus `ctx.options` with the plugin-level options for the batch call.
|
|
1365
|
+
*/
|
|
1366
|
+
operations?: (nodes: Array<OperationNode>, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | void>;
|
|
1367
|
+
};
|
|
1368
|
+
/**
|
|
1369
|
+
* Defines a generator. Returns the object as-is with correct `this` typings.
|
|
1370
|
+
* `applyHookResult` handles renderer elements and `File[]` uniformly using
|
|
1371
|
+
* the generator's declared `renderer` factory.
|
|
1372
|
+
*/
|
|
1373
|
+
declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region src/createKubb.d.ts
|
|
1376
|
+
/**
|
|
1377
|
+
* Safely extracts a type from a registry, returning `{}` if the key doesn't exist.
|
|
1378
|
+
* Enables optional interface augmentation for `Kubb.ConfigOptionsRegistry` and `Kubb.PluginOptionsRegistry`
|
|
1379
|
+
* without requiring changes to core.
|
|
1380
|
+
*
|
|
1381
|
+
* @internal
|
|
1382
|
+
*/
|
|
1383
|
+
type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
|
|
1384
|
+
/**
|
|
1385
|
+
* Reference to an input file to generate code from.
|
|
1386
|
+
*
|
|
1387
|
+
* Specify an absolute path or a path relative to the config file location.
|
|
1388
|
+
* The adapter will parse this file (e.g., OpenAPI YAML or JSON) into the universal AST.
|
|
1389
|
+
*/
|
|
1390
|
+
type InputPath = {
|
|
1391
|
+
/**
|
|
1392
|
+
* Path to your Swagger/OpenAPI file, absolute or relative to the config file location.
|
|
1393
|
+
*
|
|
1394
|
+
* @example
|
|
1395
|
+
* ```ts
|
|
1396
|
+
* { path: './petstore.yaml' }
|
|
1397
|
+
* { path: '/absolute/path/to/openapi.json' }
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
path: string;
|
|
1401
|
+
};
|
|
1402
|
+
/**
|
|
1403
|
+
* Inline input data to generate code from.
|
|
1404
|
+
*
|
|
1405
|
+
* Useful when you want to pass the specification directly instead of from a file.
|
|
1406
|
+
* Can be a string (YAML/JSON) or a parsed object.
|
|
1407
|
+
*/
|
|
1408
|
+
type InputData = {
|
|
1409
|
+
/**
|
|
1410
|
+
* Swagger/OpenAPI data as a string (YAML/JSON) or a parsed object.
|
|
1411
|
+
*
|
|
1412
|
+
* @example
|
|
1413
|
+
* ```ts
|
|
1414
|
+
* { data: fs.readFileSync('./openapi.yaml', 'utf8') }
|
|
1415
|
+
* { data: { openapi: '3.1.0', info: { ... } } }
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
1418
|
+
data: string | unknown;
|
|
1419
|
+
};
|
|
1420
|
+
type Input = InputPath | InputData;
|
|
1421
|
+
/**
|
|
1422
|
+
* Build configuration for Kubb code generation.
|
|
1423
|
+
*
|
|
1424
|
+
* The Config is the main entry point for customizing how Kubb generates code. It specifies:
|
|
1425
|
+
* - What to generate from (adapter + input)
|
|
1426
|
+
* - Where to output generated code (output)
|
|
1427
|
+
* - How to generate (plugins + middleware)
|
|
1428
|
+
* - Runtime details (parsers, storage, renderer)
|
|
1429
|
+
*
|
|
1430
|
+
* See `UserConfig` for a relaxed version with sensible defaults.
|
|
1431
|
+
*
|
|
1432
|
+
* @private
|
|
1433
|
+
*/
|
|
1434
|
+
type Config<TInput = Input> = {
|
|
1435
|
+
/**
|
|
1436
|
+
* Display name for this configuration in CLI output and logs.
|
|
1437
|
+
* Useful when running multiple builds with `defineConfig` arrays.
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* name: 'api-client'
|
|
1442
|
+
* ```
|
|
1443
|
+
*/
|
|
1444
|
+
name?: string;
|
|
1445
|
+
/**
|
|
1446
|
+
* Project root directory, absolute or relative to the config file.
|
|
1447
|
+
* @default process.cwd()
|
|
1448
|
+
*/
|
|
1449
|
+
root: string;
|
|
1450
|
+
/**
|
|
1451
|
+
* Parsers that convert generated files to strings.
|
|
1452
|
+
* Each parser handles specific extensions (e.g. `.ts`, `.tsx`).
|
|
1453
|
+
* A fallback parser is appended for unhandled extensions.
|
|
1454
|
+
* When omitted, defaults to `parserTs` from `@kubb/parser-ts`.
|
|
1455
|
+
*
|
|
1456
|
+
* @default [parserTs] from `@kubb/parser-ts`
|
|
1457
|
+
* @example
|
|
1458
|
+
* ```ts
|
|
1459
|
+
* import { parserTs, tsxParser } from '@kubb/parser-ts'
|
|
1460
|
+
* export default defineConfig({
|
|
1461
|
+
* parsers: [parserTs, tsxParser],
|
|
1462
|
+
* })
|
|
1463
|
+
* ```
|
|
1464
|
+
*/
|
|
1465
|
+
parsers: Array<Parser>;
|
|
1466
|
+
/**
|
|
1467
|
+
* Adapter that parses input files into the universal `InputNode` representation.
|
|
1468
|
+
* Use `@kubb/adapter-oas` for OpenAPI/Swagger or `@kubb/adapter-asyncapi` for other formats.
|
|
1469
|
+
*
|
|
1470
|
+
* When omitted, Kubb runs in plugin-only mode: `kubb:plugin:setup` fires and files
|
|
1471
|
+
* injected via `injectFile` are written, but no AST walk occurs and generator hooks
|
|
1472
|
+
* (`kubb:generate:schema`, `kubb:generate:operation`) are never emitted.
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* ```ts
|
|
1476
|
+
* import { adapterOas } from '@kubb/adapter-oas'
|
|
1477
|
+
* export default defineConfig({
|
|
1478
|
+
* adapter: adapterOas(),
|
|
1479
|
+
* input: { path: './petstore.yaml' },
|
|
1480
|
+
* })
|
|
1481
|
+
* ```
|
|
1482
|
+
*/
|
|
1483
|
+
adapter?: Adapter;
|
|
1484
|
+
/**
|
|
1485
|
+
* Source file or data to generate code from.
|
|
1486
|
+
* Use `input.path` for a file path or `input.data` for inline data.
|
|
1487
|
+
* Required when an adapter is configured; omit when running in plugin-only mode.
|
|
1488
|
+
*/
|
|
1489
|
+
input?: TInput;
|
|
1490
|
+
output: {
|
|
1491
|
+
/**
|
|
1492
|
+
* Output directory for generated files, absolute or relative to `root`.
|
|
1493
|
+
*
|
|
1494
|
+
* All generated files will be written under this directory. Subdirectories can be created
|
|
1495
|
+
* by plugins based on grouping strategy (by tag, path, etc.).
|
|
1496
|
+
*
|
|
1497
|
+
* @example
|
|
1498
|
+
* ```ts
|
|
1499
|
+
* output: {
|
|
1500
|
+
* path: './src/gen', // generates ./src/gen/api.ts, ./src/gen/types.ts, etc.
|
|
1501
|
+
* }
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
path: string;
|
|
1505
|
+
/**
|
|
1506
|
+
* Remove all files from the output directory before starting the build.
|
|
1507
|
+
*
|
|
1508
|
+
* Useful to ensure old generated files aren't mixed with new ones.
|
|
1509
|
+
* Set to `true` for fresh builds, `false` to preserve manual edits in output dir.
|
|
1510
|
+
*
|
|
1511
|
+
* @default false
|
|
1512
|
+
* @example
|
|
1513
|
+
* ```ts
|
|
1514
|
+
* clean: true // wipes ./src/gen/* before generating
|
|
1515
|
+
* ```
|
|
1516
|
+
*/
|
|
1517
|
+
clean?: boolean;
|
|
1518
|
+
/**
|
|
1519
|
+
* Auto-format generated files after code generation completes.
|
|
1520
|
+
*
|
|
1521
|
+
* Applies a code formatter to all generated files. Use `'auto'` to detect which formatter
|
|
1522
|
+
* is available on your system. Pass `false` to skip formatting (useful for CI or specific workflows).
|
|
1523
|
+
*
|
|
1524
|
+
* @default false
|
|
1525
|
+
* @example
|
|
1526
|
+
* ```ts
|
|
1527
|
+
* format: 'auto' // auto-detect prettier, biome, or oxfmt
|
|
1528
|
+
* format: 'prettier' // force prettier
|
|
1529
|
+
* format: false // skip formatting
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1532
|
+
format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
|
|
1533
|
+
/**
|
|
1534
|
+
* Auto-lint generated files after code generation completes.
|
|
1535
|
+
*
|
|
1536
|
+
* Analyzes all generated files for style/correctness issues. Use `'auto'` to detect which linter
|
|
1537
|
+
* is available on your system. Pass `false` to skip linting.
|
|
1538
|
+
*
|
|
1539
|
+
* @default false
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```ts
|
|
1542
|
+
* lint: 'auto' // auto-detect oxlint, biome, or eslint
|
|
1543
|
+
* lint: 'eslint' // force eslint
|
|
1544
|
+
* lint: false // skip linting
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
|
|
1548
|
+
/**
|
|
1549
|
+
* Map file extensions to different output extensions.
|
|
1550
|
+
*
|
|
1551
|
+
* Useful when you want generated `.ts` imports to reference `.js` files or vice versa (e.g., for ESM dual packages).
|
|
1552
|
+
* Keys are the original extension, values are the output extension. Use empty string `''` to omit extension.
|
|
1553
|
+
*
|
|
1554
|
+
* @default { '.ts': '.ts' }
|
|
1555
|
+
* @example
|
|
1556
|
+
* ```ts
|
|
1557
|
+
* extension: { '.ts': '.js' } // generates import './api.js' instead of './api.ts'
|
|
1558
|
+
* extension: { '.ts': '', '.tsx': '.jsx' }
|
|
1559
|
+
* ```
|
|
1560
|
+
*/
|
|
1561
|
+
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
|
|
1562
|
+
/**
|
|
1563
|
+
* Banner text prepended to every generated file.
|
|
1564
|
+
*
|
|
1565
|
+
* Useful for auto-generation notices or license headers. Choose a preset or write custom text.
|
|
1566
|
+
* Use `'simple'` for a basic Kubb banner, `'full'` for detailed metadata, or `false` to omit.
|
|
1567
|
+
*
|
|
1568
|
+
* @default 'simple'
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```ts
|
|
1571
|
+
* defaultBanner: 'simple' // "This file was autogenerated by Kubb"
|
|
1572
|
+
* defaultBanner: 'full' // adds source, title, description, API version
|
|
1573
|
+
* defaultBanner: false // no banner
|
|
1574
|
+
* ```
|
|
1575
|
+
*/
|
|
1576
|
+
defaultBanner?: 'simple' | 'full' | false;
|
|
1577
|
+
/**
|
|
1578
|
+
* When `true`, overwrites existing files. When `false`, skips generated files that already exist.
|
|
1579
|
+
*
|
|
1580
|
+
* Individual plugins can override this setting. This is useful for preventing accidental data loss
|
|
1581
|
+
* when re-generating while you have local edits in the output folder.
|
|
1582
|
+
*
|
|
1583
|
+
* @default false
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```ts
|
|
1586
|
+
* override: true // regenerate everything, even existing files
|
|
1587
|
+
* override: false // skip files that already exist
|
|
1588
|
+
* ```
|
|
1589
|
+
*/
|
|
1590
|
+
override?: boolean;
|
|
1591
|
+
} & ExtractRegistryKey<Kubb$1.ConfigOptionsRegistry, 'output'>;
|
|
1592
|
+
/**
|
|
1593
|
+
* Storage backend that controls where and how generated files are persisted.
|
|
1594
|
+
*
|
|
1595
|
+
* Defaults to `fsStorage()` which writes to the file system. Pass `memoryStorage()` to keep files in RAM,
|
|
1596
|
+
* or implement a custom `Storage` interface to write to cloud storage, databases, or other backends.
|
|
1597
|
+
*
|
|
1598
|
+
* @default fsStorage()
|
|
1599
|
+
* @example
|
|
1600
|
+
* ```ts
|
|
1601
|
+
* import { memoryStorage } from '@kubb/core'
|
|
1602
|
+
*
|
|
1603
|
+
* // Keep generated files in memory (useful for testing, CI pipelines)
|
|
1604
|
+
* storage: memoryStorage()
|
|
1605
|
+
*
|
|
1606
|
+
* // Use custom S3 storage
|
|
1607
|
+
* storage: myS3Storage()
|
|
1608
|
+
* ```
|
|
1609
|
+
*
|
|
1610
|
+
* @see {@link Storage} interface for implementing custom backends.
|
|
1611
|
+
*/
|
|
1612
|
+
storage: Storage;
|
|
1613
|
+
/**
|
|
1614
|
+
* Plugins that execute during the build to generate code and transform the AST.
|
|
1615
|
+
*
|
|
1616
|
+
* Each plugin processes the AST produced by the adapter and can emit files for different
|
|
1617
|
+
* programming languages or formats (TypeScript, Zod schemas, Faker data, etc.).
|
|
1618
|
+
* Dependencies are enforced — an error is thrown if a plugin requires another plugin that isn't registered.
|
|
1619
|
+
*
|
|
1620
|
+
* Plugins can declare their own options via `PluginFactoryOptions`. See plugin documentation for details.
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* ```ts
|
|
1624
|
+
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1625
|
+
* import { pluginZod } from '@kubb/plugin-zod'
|
|
1626
|
+
*
|
|
1627
|
+
* plugins: [
|
|
1628
|
+
* pluginTs({ output: { path: './src/gen' } }),
|
|
1629
|
+
* pluginZod({ output: { path: './src/gen' } }),
|
|
1630
|
+
* ]
|
|
1631
|
+
* ```
|
|
1632
|
+
*/
|
|
1633
|
+
plugins: Array<Plugin>;
|
|
1634
|
+
/**
|
|
1635
|
+
* Middleware instances that observe build events and post-process generated code.
|
|
1636
|
+
*
|
|
1637
|
+
* Middleware fires AFTER all plugins for each event. Perfect for tasks like:
|
|
1638
|
+
* - Auditing what was generated
|
|
1639
|
+
* - Adding barrel/index files
|
|
1640
|
+
* - Validating output
|
|
1641
|
+
* - Running custom transformations
|
|
1642
|
+
*
|
|
1643
|
+
* @example
|
|
1644
|
+
* ```ts
|
|
1645
|
+
* import { middlewareBarrel } from '@kubb/middleware-barrel'
|
|
1646
|
+
*
|
|
1647
|
+
* middleware: [middlewareBarrel()]
|
|
1648
|
+
* ```
|
|
1649
|
+
*
|
|
1650
|
+
* @see {@link defineMiddleware} to create custom middleware.
|
|
1651
|
+
*/
|
|
1652
|
+
middleware?: Array<Middleware>;
|
|
1653
|
+
/**
|
|
1654
|
+
* Renderer that converts generated AST nodes to code strings.
|
|
1655
|
+
*
|
|
1656
|
+
* By default, Kubb uses the JSX renderer (`rendererJsx`). Pass a custom renderer to support
|
|
1657
|
+
* different output formats (template engines, code generation DSLs, etc.).
|
|
1658
|
+
*
|
|
1659
|
+
* @default rendererJsx() // from @kubb/renderer-jsx
|
|
1660
|
+
* @example
|
|
1661
|
+
* ```ts
|
|
1662
|
+
* import { rendererJsx } from '@kubb/renderer-jsx'
|
|
1663
|
+
* renderer: rendererJsx()
|
|
1664
|
+
* ```
|
|
1665
|
+
*
|
|
1666
|
+
* @see {@link Renderer} to implement a custom renderer.
|
|
1667
|
+
*/
|
|
1668
|
+
renderer?: RendererFactory;
|
|
1669
|
+
/**
|
|
1670
|
+
* Kubb Studio cloud integration settings.
|
|
1671
|
+
*
|
|
1672
|
+
* Kubb Studio (https://kubb.studio) is a web-based IDE for managing API specs and generated code.
|
|
1673
|
+
* Set to `true` to enable with default settings, or pass an object to customize the Studio URL.
|
|
1674
|
+
*
|
|
1675
|
+
* @default false // disabled by default
|
|
1676
|
+
* @example
|
|
1677
|
+
* ```ts
|
|
1678
|
+
* devtools: true // use default Kubb Studio
|
|
1679
|
+
* devtools: { studioUrl: 'https://my-studio.dev' } // custom Studio instance
|
|
1680
|
+
* ```
|
|
1681
|
+
*/
|
|
1682
|
+
devtools?: true | {
|
|
1683
|
+
/**
|
|
1684
|
+
* Override the Kubb Studio base URL.
|
|
1685
|
+
* @default 'https://kubb.studio'
|
|
1686
|
+
*/
|
|
1687
|
+
studioUrl?: typeof DEFAULT_STUDIO_URL | (string & {});
|
|
1688
|
+
};
|
|
1689
|
+
/**
|
|
1690
|
+
* Lifecycle hooks that execute during or after the build process.
|
|
1691
|
+
*
|
|
1692
|
+
* Hooks allow you to run external tools (prettier, eslint, custom scripts) based on build events.
|
|
1693
|
+
* Currently supports the `done` hook which fires after all plugins and middleware complete.
|
|
1694
|
+
*
|
|
1695
|
+
* @example
|
|
1696
|
+
* ```ts
|
|
1697
|
+
* hooks: {
|
|
1698
|
+
* done: 'prettier --write "./src/gen"', // auto-format generated files
|
|
1699
|
+
* // or multiple commands:
|
|
1700
|
+
* done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
|
|
1701
|
+
* }
|
|
1702
|
+
* ```
|
|
1703
|
+
*/
|
|
1704
|
+
hooks?: {
|
|
1705
|
+
/**
|
|
1706
|
+
* Command(s) to run after all plugins and middleware complete generation.
|
|
1707
|
+
*
|
|
1708
|
+
* Useful for post-processing: formatting, linting, copying files, or custom validation.
|
|
1709
|
+
* Pass a single command string or array of command strings to run sequentially.
|
|
1710
|
+
* Commands are executed relative to the `root` directory.
|
|
1711
|
+
*
|
|
1712
|
+
* @example
|
|
1713
|
+
* ```ts
|
|
1714
|
+
* done: 'prettier --write "./src/gen"'
|
|
1715
|
+
* done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
|
|
1716
|
+
* ```
|
|
1717
|
+
*/
|
|
1718
|
+
done?: string | Array<string>;
|
|
1719
|
+
};
|
|
1720
|
+
};
|
|
1721
|
+
/**
|
|
1722
|
+
* Partial `Config` for user-facing entry points with sensible defaults.
|
|
1723
|
+
*
|
|
1724
|
+
* `UserConfig` is what you pass to `defineConfig()`. It has optional `root`, `plugins`, `parsers`, and `adapter`
|
|
1725
|
+
* fields (which fall back to sensible defaults). All other Config options are available, including `output`, `input`,
|
|
1726
|
+
* `storage`, `middleware`, `renderer`, `devtools`, and `hooks`.
|
|
1727
|
+
*
|
|
1728
|
+
* @example
|
|
1729
|
+
* ```ts
|
|
1730
|
+
* export default defineConfig({
|
|
1731
|
+
* input: { path: './petstore.yaml' },
|
|
1732
|
+
* output: { path: './src/gen' },
|
|
1733
|
+
* plugins: [pluginTs(), pluginZod()],
|
|
1734
|
+
* })
|
|
1735
|
+
* ```
|
|
1736
|
+
*/
|
|
1737
|
+
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage'> & {
|
|
1738
|
+
/**
|
|
1739
|
+
* Project root directory, absolute or relative to the config file location.
|
|
1740
|
+
* @default process.cwd()
|
|
1741
|
+
*/
|
|
1742
|
+
root?: string;
|
|
1743
|
+
/**
|
|
1744
|
+
* Custom parsers that convert generated AST nodes to strings (TypeScript, JSON, markdown, etc.).
|
|
1745
|
+
* @default [parserTs] // from `@kubb/parser-ts`
|
|
1746
|
+
*/
|
|
1747
|
+
parsers?: Array<Parser>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Adapter that parses your API specification into Kubb's universal AST.
|
|
1750
|
+
* When omitted, Kubb runs in plugin-only mode.
|
|
1751
|
+
*/
|
|
1752
|
+
adapter?: Adapter;
|
|
1753
|
+
/**
|
|
1754
|
+
* Plugins that execute during the build to generate code and transform the AST.
|
|
1755
|
+
* @default []
|
|
1756
|
+
*/
|
|
1757
|
+
plugins?: Array<Plugin>;
|
|
1758
|
+
/**
|
|
1759
|
+
* Storage backend that controls where and how generated files are persisted.
|
|
1760
|
+
* @default fsStorage()
|
|
1761
|
+
*/
|
|
1762
|
+
storage?: Storage;
|
|
1763
|
+
};
|
|
1764
|
+
declare global {
|
|
1765
|
+
namespace Kubb {
|
|
1766
|
+
/**
|
|
1767
|
+
* Registry that maps plugin names to their `PluginFactoryOptions`.
|
|
1768
|
+
* Augment this interface in each plugin's `types.ts` to enable automatic
|
|
1769
|
+
* typing for `getPlugin` and `requirePlugin`.
|
|
1770
|
+
*
|
|
1771
|
+
* @example
|
|
1772
|
+
* ```ts
|
|
1773
|
+
* // packages/plugin-ts/src/types.ts
|
|
1774
|
+
* declare global {
|
|
1775
|
+
* namespace Kubb {
|
|
1776
|
+
* interface PluginRegistry {
|
|
1777
|
+
* 'plugin-ts': PluginTs
|
|
1778
|
+
* }
|
|
1779
|
+
* }
|
|
1780
|
+
* }
|
|
1781
|
+
* ```
|
|
1782
|
+
*/
|
|
1783
|
+
interface PluginRegistry {}
|
|
1784
|
+
/**
|
|
1785
|
+
* Extension point for root `Config['output']` options.
|
|
1786
|
+
* Augment the `output` key in middleware or plugin packages to add extra fields
|
|
1787
|
+
* to the global output configuration without touching core types.
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```ts
|
|
1791
|
+
* // packages/middleware-barrel/src/types.ts
|
|
1792
|
+
* declare global {
|
|
1793
|
+
* namespace Kubb {
|
|
1794
|
+
* interface ConfigOptionsRegistry {
|
|
1795
|
+
* output: {
|
|
1796
|
+
* barrel?: import('./types.ts').BarrelConfig | false
|
|
1797
|
+
* }
|
|
1798
|
+
* }
|
|
1799
|
+
* }
|
|
1800
|
+
* }
|
|
1801
|
+
* ```
|
|
1802
|
+
*/
|
|
1803
|
+
interface ConfigOptionsRegistry {}
|
|
1804
|
+
/**
|
|
1805
|
+
* Extension point for per-plugin `Output` options.
|
|
1806
|
+
* Augment the `output` key in middleware or plugin packages to add extra fields
|
|
1807
|
+
* to the per-plugin output configuration without touching core types.
|
|
1808
|
+
*
|
|
1809
|
+
* @example
|
|
1810
|
+
* ```ts
|
|
1811
|
+
* // packages/middleware-barrel/src/types.ts
|
|
1812
|
+
* declare global {
|
|
1813
|
+
* namespace Kubb {
|
|
1814
|
+
* interface PluginOptionsRegistry {
|
|
1815
|
+
* output: {
|
|
1816
|
+
* barrel?: import('./types.ts').PluginBarrelConfig | false
|
|
1817
|
+
* }
|
|
1818
|
+
* }
|
|
1819
|
+
* }
|
|
1820
|
+
* }
|
|
1821
|
+
* ```
|
|
1822
|
+
*/
|
|
1823
|
+
interface PluginOptionsRegistry {}
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Lifecycle events emitted during Kubb code generation.
|
|
1828
|
+
* Use these for logging, progress tracking, and custom integrations.
|
|
1829
|
+
*
|
|
1830
|
+
* @example
|
|
1831
|
+
* ```typescript
|
|
1832
|
+
* import type { AsyncEventEmitter } from '@internals/utils'
|
|
1833
|
+
* import type { KubbHooks } from '@kubb/core'
|
|
1834
|
+
*
|
|
1835
|
+
* const hooks: AsyncEventEmitter<KubbHooks> = new AsyncEventEmitter()
|
|
1836
|
+
*
|
|
1837
|
+
* hooks.on('kubb:lifecycle:start', () => {
|
|
1838
|
+
* console.log('Starting Kubb generation')
|
|
1839
|
+
* })
|
|
1840
|
+
*
|
|
1841
|
+
* hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
1842
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
1843
|
+
* })
|
|
1844
|
+
* ```
|
|
1845
|
+
*/
|
|
1846
|
+
interface KubbHooks {
|
|
1847
|
+
'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext];
|
|
1848
|
+
'kubb:lifecycle:end': [];
|
|
1849
|
+
'kubb:config:start': [];
|
|
1850
|
+
'kubb:config:end': [ctx: KubbConfigEndContext];
|
|
1851
|
+
'kubb:generation:start': [ctx: KubbGenerationStartContext];
|
|
1852
|
+
'kubb:generation:end': [ctx: KubbGenerationEndContext];
|
|
1853
|
+
'kubb:generation:summary': [ctx: KubbGenerationSummaryContext];
|
|
1854
|
+
'kubb:format:start': [];
|
|
1855
|
+
'kubb:format:end': [];
|
|
1856
|
+
'kubb:lint:start': [];
|
|
1857
|
+
'kubb:lint:end': [];
|
|
1858
|
+
'kubb:hooks:start': [];
|
|
1859
|
+
'kubb:hooks:end': [];
|
|
1860
|
+
'kubb:hook:start': [ctx: KubbHookStartContext];
|
|
1861
|
+
'kubb:hook:end': [ctx: KubbHookEndContext];
|
|
1862
|
+
'kubb:version:new': [ctx: KubbVersionNewContext];
|
|
1863
|
+
'kubb:info': [ctx: KubbInfoContext];
|
|
1864
|
+
'kubb:error': [ctx: KubbErrorContext];
|
|
1865
|
+
'kubb:success': [ctx: KubbSuccessContext];
|
|
1866
|
+
'kubb:warn': [ctx: KubbWarnContext];
|
|
1867
|
+
'kubb:debug': [ctx: KubbDebugContext];
|
|
1868
|
+
'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext];
|
|
1869
|
+
'kubb:file:processing:update': [ctx: KubbFileProcessingUpdateContext];
|
|
1870
|
+
'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext];
|
|
1871
|
+
'kubb:plugin:start': [ctx: KubbPluginStartContext];
|
|
1872
|
+
'kubb:plugin:end': [ctx: KubbPluginEndContext];
|
|
1873
|
+
'kubb:plugin:setup': [ctx: KubbPluginSetupContext];
|
|
1874
|
+
'kubb:build:start': [ctx: KubbBuildStartContext];
|
|
1875
|
+
'kubb:plugins:end': [ctx: KubbPluginsEndContext];
|
|
1876
|
+
'kubb:build:end': [ctx: KubbBuildEndContext];
|
|
1877
|
+
'kubb:generate:schema': [node: SchemaNode, ctx: GeneratorContext];
|
|
1878
|
+
'kubb:generate:operation': [node: OperationNode, ctx: GeneratorContext];
|
|
1879
|
+
'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext];
|
|
1880
|
+
}
|
|
1881
|
+
type KubbBuildStartContext = {
|
|
1882
|
+
config: Config;
|
|
1883
|
+
adapter: Adapter;
|
|
1884
|
+
inputNode: InputNode;
|
|
1885
|
+
getPlugin<TName extends keyof Kubb$1.PluginRegistry>(name: TName): Plugin<Kubb$1.PluginRegistry[TName]> | undefined;
|
|
1886
|
+
getPlugin(name: string): Plugin | undefined;
|
|
1887
|
+
readonly files: ReadonlyArray<FileNode>;
|
|
1888
|
+
upsertFile: (...files: Array<FileNode>) => void;
|
|
1889
|
+
};
|
|
1890
|
+
type KubbPluginsEndContext = {
|
|
1891
|
+
config: Config;
|
|
1892
|
+
readonly files: ReadonlyArray<FileNode>;
|
|
1893
|
+
upsertFile: (...files: Array<FileNode>) => void;
|
|
1894
|
+
};
|
|
1895
|
+
type KubbBuildEndContext = {
|
|
1896
|
+
files: Array<FileNode>;
|
|
1897
|
+
config: Config;
|
|
1898
|
+
outputDir: string;
|
|
1899
|
+
};
|
|
1900
|
+
type KubbLifecycleStartContext = {
|
|
1901
|
+
version: string;
|
|
1902
|
+
};
|
|
1903
|
+
type KubbConfigEndContext = {
|
|
1904
|
+
configs: Array<Config>;
|
|
1905
|
+
};
|
|
1906
|
+
type KubbGenerationStartContext = {
|
|
1907
|
+
config: Config;
|
|
1908
|
+
};
|
|
1909
|
+
type KubbGenerationEndContext = {
|
|
1910
|
+
config: Config;
|
|
1911
|
+
files: Array<FileNode>;
|
|
1912
|
+
sources: Map<string, string>;
|
|
1913
|
+
};
|
|
1914
|
+
type KubbGenerationSummaryContext = {
|
|
1915
|
+
config: Config;
|
|
1916
|
+
failedPlugins: Set<{
|
|
1917
|
+
plugin: Plugin;
|
|
1918
|
+
error: Error;
|
|
1919
|
+
}>;
|
|
1920
|
+
status: 'success' | 'failed';
|
|
1921
|
+
hrStart: [number, number];
|
|
1922
|
+
filesCreated: number;
|
|
1923
|
+
pluginTimings?: Map<Plugin['name'], number>;
|
|
1924
|
+
};
|
|
1925
|
+
type KubbVersionNewContext = {
|
|
1926
|
+
currentVersion: string;
|
|
1927
|
+
latestVersion: string;
|
|
1928
|
+
};
|
|
1929
|
+
type KubbInfoContext = {
|
|
1930
|
+
message: string;
|
|
1931
|
+
info?: string;
|
|
1932
|
+
};
|
|
1933
|
+
type KubbErrorContext = {
|
|
1934
|
+
error: Error;
|
|
1935
|
+
meta?: Record<string, unknown>;
|
|
1936
|
+
};
|
|
1937
|
+
type KubbSuccessContext = {
|
|
1938
|
+
message: string;
|
|
1939
|
+
info?: string;
|
|
1940
|
+
};
|
|
1941
|
+
type KubbWarnContext = {
|
|
1942
|
+
message: string;
|
|
1943
|
+
info?: string;
|
|
1944
|
+
};
|
|
1945
|
+
type KubbDebugContext = {
|
|
1946
|
+
date: Date;
|
|
1947
|
+
logs: Array<string>;
|
|
1948
|
+
fileName?: string;
|
|
1949
|
+
};
|
|
1950
|
+
type KubbFilesProcessingStartContext = {
|
|
1951
|
+
files: Array<FileNode>;
|
|
1952
|
+
};
|
|
1953
|
+
type KubbFileProcessingUpdateContext = {
|
|
1954
|
+
processed: number;
|
|
1955
|
+
total: number;
|
|
1956
|
+
percentage: number;
|
|
1957
|
+
source?: string;
|
|
1958
|
+
file: FileNode;
|
|
1959
|
+
config: Config;
|
|
1960
|
+
};
|
|
1961
|
+
type KubbFilesProcessingEndContext = {
|
|
1962
|
+
files: Array<FileNode>;
|
|
1963
|
+
};
|
|
1964
|
+
type KubbHookStartContext = {
|
|
1965
|
+
id?: string;
|
|
1966
|
+
command: string;
|
|
1967
|
+
args?: readonly string[];
|
|
1968
|
+
};
|
|
1969
|
+
type KubbHookEndContext = {
|
|
1970
|
+
id?: string;
|
|
1971
|
+
command: string;
|
|
1972
|
+
args?: readonly string[];
|
|
1973
|
+
success: boolean;
|
|
1974
|
+
error: Error | null;
|
|
1975
|
+
};
|
|
1976
|
+
/**
|
|
1977
|
+
* CLI options derived from command-line flags.
|
|
1978
|
+
*/
|
|
1979
|
+
type CLIOptions = {
|
|
1980
|
+
config?: string;
|
|
1981
|
+
watch?: boolean; /** @default 'silent' */
|
|
1982
|
+
logLevel?: 'silent' | 'info' | 'debug';
|
|
1983
|
+
};
|
|
1984
|
+
/**
|
|
1985
|
+
* All accepted forms of a Kubb configuration.
|
|
1986
|
+
* Accepts `Config`/`Config[]`/promise or a factory (optionally receiving `TCliOptions`).
|
|
1987
|
+
*/
|
|
1988
|
+
type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Config[]> | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Config[]>);
|
|
1989
|
+
/**
|
|
1990
|
+
* Full output produced by a successful or failed build.
|
|
1991
|
+
*/
|
|
1992
|
+
type BuildOutput = {
|
|
1993
|
+
/**
|
|
1994
|
+
* Plugins that threw during installation, paired with the caught error.
|
|
1995
|
+
*/
|
|
1996
|
+
failedPlugins: Set<{
|
|
1997
|
+
plugin: Plugin;
|
|
1998
|
+
error: Error;
|
|
1999
|
+
}>;
|
|
2000
|
+
files: Array<FileNode>;
|
|
2001
|
+
driver: PluginDriver;
|
|
2002
|
+
/**
|
|
2003
|
+
* Elapsed time in milliseconds for each plugin, keyed by plugin name.
|
|
2004
|
+
*/
|
|
2005
|
+
pluginTimings: Map<string, number>;
|
|
2006
|
+
error?: Error;
|
|
2007
|
+
/**
|
|
2008
|
+
* Raw generated source, keyed by absolute file path.
|
|
2009
|
+
*/
|
|
2010
|
+
sources: Map<string, string>;
|
|
2011
|
+
};
|
|
2012
|
+
/**
|
|
2013
|
+
* Kubb code generation instance returned by {@link createKubb}.
|
|
2014
|
+
*
|
|
2015
|
+
* Use this when orchestrating multiple builds, inspecting plugin timings, or integrating Kubb into a larger toolchain.
|
|
2016
|
+
* For a single one-off build, chain directly: `await createKubb(config).build()`.
|
|
2017
|
+
*/
|
|
2018
|
+
type Kubb$1 = {
|
|
2019
|
+
/**
|
|
2020
|
+
* Shared event emitter for lifecycle and status events. Attach listeners before calling `setup()` or `build()`.
|
|
2021
|
+
*/
|
|
2022
|
+
readonly hooks: AsyncEventEmitter<KubbHooks>;
|
|
2023
|
+
/**
|
|
2024
|
+
* Generated source code keyed by absolute file path. Available after `build()` or `safeBuild()` completes.
|
|
2025
|
+
*/
|
|
2026
|
+
readonly sources: Map<string, string>;
|
|
2027
|
+
/**
|
|
2028
|
+
* Plugin driver managing all plugins. Available after `setup()` completes.
|
|
2029
|
+
*/
|
|
2030
|
+
readonly driver: PluginDriver | undefined;
|
|
2031
|
+
/**
|
|
2032
|
+
* Resolved configuration with defaults applied. Available after `setup()` completes.
|
|
2033
|
+
*/
|
|
2034
|
+
readonly config: Config | undefined;
|
|
2035
|
+
/**
|
|
2036
|
+
* Resolves config and initializes the driver. `build()` calls this automatically.
|
|
2037
|
+
*/
|
|
2038
|
+
setup(): Promise<void>;
|
|
2039
|
+
/**
|
|
2040
|
+
* Runs the full pipeline and throws on any plugin error. Automatically calls `setup()` if needed.
|
|
2041
|
+
*/
|
|
2042
|
+
build(): Promise<BuildOutput>;
|
|
2043
|
+
/**
|
|
2044
|
+
* Runs the full pipeline and captures errors in `BuildOutput` instead of throwing. Automatically calls `setup()` if needed.
|
|
2045
|
+
*/
|
|
2046
|
+
safeBuild(): Promise<BuildOutput>;
|
|
2047
|
+
};
|
|
2048
|
+
/**
|
|
2049
|
+
* Type guard to check if a given config has an `input.path`.
|
|
2050
|
+
*/
|
|
2051
|
+
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath> & {
|
|
2052
|
+
input: InputPath;
|
|
2053
|
+
};
|
|
2054
|
+
declare function isInputPath(config: Config | undefined): config is Config<InputPath> & {
|
|
2055
|
+
input: InputPath;
|
|
2056
|
+
};
|
|
2057
|
+
type CreateKubbOptions = {
|
|
2058
|
+
hooks?: AsyncEventEmitter<KubbHooks>;
|
|
2059
|
+
};
|
|
2060
|
+
/**
|
|
2061
|
+
* Creates a Kubb instance bound to a single config entry.
|
|
2062
|
+
*
|
|
2063
|
+
* Accepts a user-facing config shape and resolves it to a full {@link Config} during
|
|
2064
|
+
* `setup()`. The instance then holds shared state (`hooks`, `sources`, `driver`, `config`)
|
|
2065
|
+
* across the `setup → build` lifecycle. Attach event listeners to `kubb.hooks` before
|
|
2066
|
+
* calling `setup()` or `build()`.
|
|
2067
|
+
*
|
|
2068
|
+
* @example
|
|
2069
|
+
* ```ts
|
|
2070
|
+
* const kubb = createKubb(userConfig)
|
|
2071
|
+
*
|
|
2072
|
+
* kubb.hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
|
|
2073
|
+
* console.log(`${plugin.name} completed in ${duration}ms`)
|
|
2074
|
+
* })
|
|
2075
|
+
*
|
|
2076
|
+
* const { files, failedPlugins } = await kubb.safeBuild()
|
|
2077
|
+
* ```
|
|
2078
|
+
*/
|
|
2079
|
+
declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb$1;
|
|
2080
|
+
//#endregion
|
|
2081
|
+
export { ResolverPathParams as $, isInputPath as A, KubbPluginSetupContext as B, KubbPluginsEndContext as C, PossibleConfig as D, KubbWarnContext as E, FileManager as F, Plugin as G, NormalizedPlugin as H, Exclude as I, ResolveBannerContext as J, PluginFactoryOptions as K, Group as L, GeneratorContext as M, defineGenerator as N, UserConfig as O, PluginDriver as P, ResolverFileParams as Q, Include as R, KubbLifecycleStartContext as S, KubbVersionNewContext as T, Output as U, KubbPluginStartContext as V, Override as W, Resolver as X, ResolveOptionsContext as Y, ResolverContext as Z, KubbGenerationSummaryContext as _, AdapterFactoryOptions as _t, InputPath as a, Logger as at, KubbHooks as b, logLevel as bt, KubbBuildStartContext as c, UserLogger as ct, KubbErrorContext as d, Storage as dt, defineResolver as et, KubbFileProcessingUpdateContext as f, createStorage as ft, KubbGenerationStartContext as g, Adapter as gt, KubbGenerationEndContext as h, createRenderer as ht, InputData as i, defineMiddleware as it, Generator as j, createKubb as k, KubbConfigEndContext as l, defineLogger as lt, KubbFilesProcessingStartContext as m, RendererFactory as mt, CLIOptions as n, defineParser as nt, Kubb$1 as o, LoggerContext as ot, KubbFilesProcessingEndContext as p, Renderer as pt, definePlugin as q, Config as r, Middleware as rt, KubbBuildEndContext as s, LoggerOptions as st, BuildOutput as t, Parser as tt, KubbDebugContext as u, DevtoolsOptions as ut, KubbHookEndContext as v, AdapterSource as vt, KubbSuccessContext as w, KubbInfoContext as x, AsyncEventEmitter as xt, KubbHookStartContext as y, createAdapter as yt, KubbPluginEndContext as z };
|
|
2082
|
+
//# sourceMappingURL=createKubb-ALdb8lmq.d.ts.map
|