@kubb/core 5.0.0-beta.9 → 5.0.0-beta.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +20 -123
  3. package/dist/index.cjs +2217 -1132
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +135 -178
  6. package/dist/index.js +2209 -1125
  7. package/dist/index.js.map +1 -1
  8. package/dist/mocks.cjs +77 -24
  9. package/dist/mocks.cjs.map +1 -1
  10. package/dist/mocks.d.ts +37 -11
  11. package/dist/mocks.js +79 -28
  12. package/dist/mocks.js.map +1 -1
  13. package/dist/types-BLFyAJLZ.d.ts +2785 -0
  14. package/dist/usingCtx-BriKju-v.js +577 -0
  15. package/dist/usingCtx-BriKju-v.js.map +1 -0
  16. package/dist/usingCtx-eyNeehd2.cjs +679 -0
  17. package/dist/usingCtx-eyNeehd2.cjs.map +1 -0
  18. package/package.json +7 -28
  19. package/dist/PluginDriver-Cu1Kj9S-.cjs +0 -1075
  20. package/dist/PluginDriver-Cu1Kj9S-.cjs.map +0 -1
  21. package/dist/PluginDriver-D8Z0Htid.js +0 -978
  22. package/dist/PluginDriver-D8Z0Htid.js.map +0 -1
  23. package/dist/createKubb-ALdb8lmq.d.ts +0 -2082
  24. package/src/FileManager.ts +0 -115
  25. package/src/FileProcessor.ts +0 -86
  26. package/src/PluginDriver.ts +0 -457
  27. package/src/constants.ts +0 -35
  28. package/src/createAdapter.ts +0 -108
  29. package/src/createKubb.ts +0 -1268
  30. package/src/createRenderer.ts +0 -57
  31. package/src/createStorage.ts +0 -70
  32. package/src/defineGenerator.ts +0 -175
  33. package/src/defineLogger.ts +0 -58
  34. package/src/defineMiddleware.ts +0 -62
  35. package/src/defineParser.ts +0 -44
  36. package/src/definePlugin.ts +0 -379
  37. package/src/defineResolver.ts +0 -654
  38. package/src/devtools.ts +0 -66
  39. package/src/index.ts +0 -20
  40. package/src/mocks.ts +0 -177
  41. package/src/storages/fsStorage.ts +0 -90
  42. package/src/storages/memoryStorage.ts +0 -55
  43. package/src/types.ts +0 -41
  44. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
@@ -0,0 +1,2785 @@
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { Enforce, FileNode, HttpMethod, ImportNode, InputMeta, InputNode, Macro, Node, OperationNode, SchemaNode, UserFileNode } from "@kubb/ast";
3
+
4
+ //#region ../../internals/utils/src/promise.d.ts
5
+ /** A value that may already be resolved or still pending.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * function load(id: string): PossiblePromise<string> {
10
+ * return cache.get(id) ?? fetchRemote(id)
11
+ * }
12
+ * ```
13
+ */
14
+ type PossiblePromise<T> = Promise<T> | T;
15
+ //#endregion
16
+ //#region src/createAdapter.d.ts
17
+ /**
18
+ * Source data handed to an adapter's `parse` function. Mirrors the config
19
+ * input shape with paths resolved to absolute.
20
+ *
21
+ * - `{ type: 'path' }`: single file on disk.
22
+ * - `{ type: 'data' }`: raw string or parsed object provided inline.
23
+ */
24
+ type AdapterSource = {
25
+ type: 'path';
26
+ path: string;
27
+ } | {
28
+ type: 'data';
29
+ data: string | unknown;
30
+ };
31
+ /**
32
+ * Generic parameters used by `createAdapter` and the resulting `Adapter` type.
33
+ *
34
+ * - `TName`: unique adapter identifier (`'oas'`, `'asyncapi'`, ...).
35
+ * - `TOptions`: user-facing options accepted by the adapter factory.
36
+ * - `TResolvedOptions`: options after defaults are applied.
37
+ * - `TDocument`: type of the parsed source document.
38
+ */
39
+ type AdapterFactoryOptions<TName extends string = string, TOptions extends object = object, TResolvedOptions extends object = TOptions, TDocument = unknown> = {
40
+ name: TName;
41
+ options: TOptions;
42
+ resolvedOptions: TResolvedOptions;
43
+ document: TDocument;
44
+ };
45
+ /**
46
+ * Converts input files or inline data into Kubb's universal AST `InputNode`.
47
+ *
48
+ * Adapters live between the spec format and the plugins. The built-in
49
+ * `@kubb/adapter-oas` handles OpenAPI 2.0, 3.0, and 3.1. A custom adapter can
50
+ * support GraphQL, gRPC, or another schema language.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { defineConfig } from 'kubb'
55
+ * import { adapterOas } from '@kubb/adapter-oas'
56
+ * import { pluginTs } from '@kubb/plugin-ts'
57
+ *
58
+ * export default defineConfig({
59
+ * input: './petStore.yaml',
60
+ * output: { path: './src/gen' },
61
+ * adapter: adapterOas(),
62
+ * plugins: [pluginTs()],
63
+ * })
64
+ * ```
65
+ */
66
+ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
67
+ /**
68
+ * Human-readable adapter identifier (e.g. `'oas'`, `'asyncapi'`).
69
+ */
70
+ name: TOptions['name'];
71
+ /**
72
+ * Resolved adapter options after defaults have been applied.
73
+ */
74
+ options: TOptions['resolvedOptions'];
75
+ /**
76
+ * Parsed source document after the first `parse()` call. `null` before parsing.
77
+ */
78
+ document: TOptions['document'] | null;
79
+ /**
80
+ * Parse the source into a universal `InputNode`.
81
+ */
82
+ parse: (source: AdapterSource) => PossiblePromise<InputNode>;
83
+ /**
84
+ * Extract `ImportNode` entries for a schema tree.
85
+ * Returns an empty array before the first `parse()` call.
86
+ *
87
+ * The `resolve` callback receives the collision-corrected schema name and must
88
+ * return `{ name, path }` for the import, or `undefined` to skip it.
89
+ */
90
+ getImports: (node: SchemaNode, resolve: (schemaName: string) => {
91
+ name: string;
92
+ path: string;
93
+ }) => Array<ImportNode>;
94
+ /**
95
+ * Validate the document at the given path or URL.
96
+ */
97
+ validate: (input: string, options?: {
98
+ throwOnError?: boolean;
99
+ }) => Promise<void>;
100
+ };
101
+ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) => Adapter<T>;
102
+ /**
103
+ * Defines a custom adapter that translates a spec format into Kubb's universal
104
+ * AST, for example GraphQL, gRPC, or AsyncAPI. The built-in `@kubb/adapter-oas`
105
+ * handles OpenAPI/Swagger documents.
106
+ *
107
+ * Adapters must return an `InputNode` from `parse`. That node is what every
108
+ * plugin in the build consumes.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { createAdapter, type AdapterFactoryOptions } from '@kubb/core'
113
+ * import { ast } from '@kubb/ast'
114
+ *
115
+ * type MyAdapter = AdapterFactoryOptions<'my-adapter', { validate?: boolean }>
116
+ *
117
+ * export const myAdapter = createAdapter<MyAdapter>((options) => ({
118
+ * name: 'my-adapter',
119
+ * options,
120
+ * document: null,
121
+ * async parse(_source) {
122
+ * // Convert the source (path or inline data) into an InputNode.
123
+ * return ast.factory.createInput()
124
+ * },
125
+ * getImports: () => [],
126
+ * async validate() {
127
+ * // Throw here when the spec is invalid.
128
+ * },
129
+ * }))
130
+ * ```
131
+ */
132
+ declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
133
+ //#endregion
134
+ //#region src/constants.d.ts
135
+ /**
136
+ * Stable codes Kubb attaches to a `Diagnostic`. Each maps to a known failure mode
137
+ * and stays stable so it can be referenced in tooling and (later) docs. Reference
138
+ * these instead of inlining the string at a throw site.
139
+ */
140
+ declare const diagnosticCode: {
141
+ /**
142
+ * Fallback for an unstructured error with no specific code.
143
+ */
144
+ readonly unknown: "KUBB_UNKNOWN";
145
+ /**
146
+ * The file or URL set as `input` could not be read.
147
+ */
148
+ readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
149
+ /**
150
+ * An adapter was configured without an `input`.
151
+ */
152
+ readonly inputRequired: "KUBB_INPUT_REQUIRED";
153
+ /**
154
+ * A `$ref` (or equivalent reference) could not be resolved in the source document.
155
+ */
156
+ readonly refNotFound: "KUBB_REF_NOT_FOUND";
157
+ /**
158
+ * A server variable value is not allowed by its `enum`.
159
+ */
160
+ readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
161
+ /**
162
+ * A required plugin is missing from the config.
163
+ */
164
+ readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
165
+ /**
166
+ * A plugin threw while generating.
167
+ */
168
+ readonly pluginFailed: "KUBB_PLUGIN_FAILED";
169
+ /**
170
+ * A plugin reported a non-fatal warning through `ctx.warn`.
171
+ */
172
+ readonly pluginWarning: "KUBB_PLUGIN_WARNING";
173
+ /**
174
+ * A plugin reported an informational message through `ctx.info`.
175
+ */
176
+ readonly pluginInfo: "KUBB_PLUGIN_INFO";
177
+ /**
178
+ * A schema uses a `format` Kubb does not map to a specific type. Reserved for
179
+ * adapters to emit as a `warning`.
180
+ */
181
+ readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
182
+ /**
183
+ * A referenced schema or operation is marked `deprecated`. Reserved for adapters
184
+ * to emit as an `info`.
185
+ */
186
+ readonly deprecated: "KUBB_DEPRECATED";
187
+ /**
188
+ * An adapter is required but the config has none. The build cannot read the input
189
+ * without one.
190
+ */
191
+ readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
192
+ /**
193
+ * A resolved output path escapes the output directory, which can stem from a path
194
+ * traversal in the spec or a misconfigured `group.name`.
195
+ */
196
+ readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
197
+ /**
198
+ * A plugin's options are invalid, for example `output.mode: 'file'` paired with a `group` option.
199
+ */
200
+ readonly invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS";
201
+ /**
202
+ * A post-generate command (`output.postGenerate`) exited with a failure.
203
+ */
204
+ readonly postGenerateFailed: "KUBB_POST_GENERATE_FAILED";
205
+ /**
206
+ * The formatter pass over the generated files failed.
207
+ */
208
+ readonly formatFailed: "KUBB_FORMAT_FAILED";
209
+ /**
210
+ * The linter pass over the generated files failed.
211
+ */
212
+ readonly lintFailed: "KUBB_LINT_FAILED";
213
+ /**
214
+ * Not a failure. Carries a plugin's elapsed time, summed into the run total.
215
+ */
216
+ readonly performance: "KUBB_PERFORMANCE";
217
+ /**
218
+ * Not a failure. A newer Kubb version is available on npm.
219
+ */
220
+ readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
221
+ };
222
+ /**
223
+ * Union of the stable {@link diagnosticCode} values.
224
+ */
225
+ type DiagnosticCode = (typeof diagnosticCode)[keyof typeof diagnosticCode];
226
+ //#endregion
227
+ //#region src/Hookable.d.ts
228
+ /**
229
+ * A function that can be registered as a hook listener, synchronous or async. Any return value is
230
+ * allowed and ignored, so handlers that return a result for their own callers still register.
231
+ */
232
+ type AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => unknown;
233
+ /**
234
+ * Typed hook emitter that awaits all async listeners before resolving.
235
+ * Wraps Node's `EventEmitter` with full TypeScript hook-map inference.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * const hooks = new Hookable<{ build: [name: string] }>()
240
+ * hooks.hook('build', async (name) => { console.log(name) })
241
+ * await hooks.callHook('build', 'petstore') // all listeners awaited
242
+ * ```
243
+ */
244
+ declare class Hookable<THooks extends { [K in keyof THooks]: Array<unknown> }> {
245
+ #private;
246
+ /**
247
+ * Maximum number of listeners per hook before Node emits a memory-leak warning.
248
+ * @default 10
249
+ */
250
+ constructor(maxListener?: number);
251
+ /**
252
+ * Calls `hookName` and awaits all registered listeners sequentially.
253
+ * Throws if any listener rejects, wrapping the cause with the hook name and serialized arguments.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * await hooks.callHook('build', 'petstore')
258
+ * ```
259
+ */
260
+ callHook<THookName extends keyof THooks & string>(hookName: THookName, ...hookArgs: THooks[THookName]): Promise<void> | void;
261
+ /**
262
+ * Registers a persistent listener for `hookName` and returns a function that removes it.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * const unhook = hooks.hook('build', async (name) => { console.log(name) })
267
+ * unhook() // removes it
268
+ * ```
269
+ */
270
+ hook<THookName extends keyof THooks & string>(hookName: THookName, handler: AsyncListener<THooks[THookName]>): () => void;
271
+ /**
272
+ * Registers every handler in `configHooks` at once and returns a function that removes them
273
+ * all. Undefined entries are skipped, so a partial hook object registers only its present keys.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * const unhook = hooks.addHooks({ build: onBuild, done: onDone })
278
+ * unhook() // removes both
279
+ * ```
280
+ */
281
+ addHooks(configHooks: Partial<{ [K in keyof THooks & string]: AsyncListener<THooks[K]> }>): () => void;
282
+ /**
283
+ * Removes a previously registered listener.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * hooks.removeHook('build', handler)
288
+ * ```
289
+ */
290
+ removeHook<THookName extends keyof THooks & string>(hookName: THookName, handler: AsyncListener<THooks[THookName]>): void;
291
+ /**
292
+ * Returns the number of listeners registered for `hookName`.
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * hooks.hook('build', handler)
297
+ * hooks.listenerCount('build') // 1
298
+ * ```
299
+ */
300
+ listenerCount<THookName extends keyof THooks & string>(hookName: THookName): number;
301
+ /**
302
+ * Raises or lowers the per-hook listener ceiling before Node warns about a memory leak.
303
+ * Set this above the expected listener count when many listeners attach by design.
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * hooks.setMaxListeners(40)
308
+ * ```
309
+ */
310
+ setMaxListeners(max: number): void;
311
+ /**
312
+ * Removes all listeners from every hook channel.
313
+ *
314
+ * @example
315
+ * ```ts
316
+ * hooks.removeAllHooks()
317
+ * ```
318
+ */
319
+ removeAllHooks(): void;
320
+ }
321
+ //#endregion
322
+ //#region src/Diagnostics.d.ts
323
+ /**
324
+ * How serious a diagnostic is. `error` fails the build, `warning` and `info`
325
+ * are reported but do not.
326
+ */
327
+ type DiagnosticSeverity = 'error' | 'warning' | 'info';
328
+ /**
329
+ * A human-readable explanation of a diagnostic code: a short title, what triggers it, and how
330
+ * to resolve it. This is the source of truth the kubb.dev `/diagnostics/<slug>` pages mirror, so
331
+ * every code stays documented in one place. Adding a code without documenting it fails the build.
332
+ */
333
+ type DiagnosticDoc = {
334
+ /**
335
+ * Short title shown as the docs heading.
336
+ */
337
+ title: string;
338
+ /**
339
+ * What triggers the diagnostic.
340
+ */
341
+ cause: string;
342
+ /**
343
+ * The action that resolves it.
344
+ */
345
+ fix: string;
346
+ };
347
+ /**
348
+ * Points a diagnostic back into the source document. Inputs are parsed into an
349
+ * object model with no line/column, so locations carry a JSON pointer the adapter
350
+ * builds (the OAS adapter emits `#/components/schemas/Pet`). A `config` diagnostic
351
+ * points at the Kubb config itself and so has no pointer.
352
+ */
353
+ type DiagnosticLocation = {
354
+ kind: 'schema';
355
+ /**
356
+ * RFC 6901 JSON pointer into the source document.
357
+ */
358
+ pointer: string;
359
+ /**
360
+ * The original reference when the diagnostic stems from an unresolved one.
361
+ */
362
+ ref?: string;
363
+ } | {
364
+ kind: 'operation' | 'document';
365
+ /**
366
+ * RFC 6901 JSON pointer into the source document.
367
+ */
368
+ pointer: string;
369
+ } | {
370
+ kind: 'config';
371
+ };
372
+ /**
373
+ * What a diagnostic carries.
374
+ * - `problem` is a build issue shown to the user, and the only kind rendered as a problem.
375
+ * - `performance` records a plugin's elapsed time.
376
+ * - `update` is a version notice.
377
+ */
378
+ type DiagnosticKind = 'problem' | 'performance' | 'update';
379
+ /**
380
+ * Codes that describe a build problem: every {@link DiagnosticCode} except the
381
+ * `performance` and `updateAvailable` codes, which ride on their own variants.
382
+ */
383
+ type ProblemCode = Exclude<DiagnosticCode, typeof diagnosticCode.performance | typeof diagnosticCode.updateAvailable>;
384
+ /**
385
+ * A build problem collected during a run, gathered into the result instead of
386
+ * aborting on the first failure.
387
+ */
388
+ type ProblemDiagnostic = {
389
+ /**
390
+ * @default 'problem'
391
+ */
392
+ kind?: 'problem';
393
+ /**
394
+ * Stable identifier for the problem, from the {@link diagnosticCode} catalog.
395
+ */
396
+ code: ProblemCode;
397
+ severity: DiagnosticSeverity;
398
+ message: string;
399
+ location?: DiagnosticLocation;
400
+ /**
401
+ * A suggested fix, phrased as an action the user can take.
402
+ */
403
+ help?: string;
404
+ /**
405
+ * Name of the plugin or subsystem that produced the diagnostic.
406
+ */
407
+ plugin?: string;
408
+ /**
409
+ * The underlying error, when the diagnostic wraps a thrown one.
410
+ */
411
+ cause?: Error;
412
+ };
413
+ /**
414
+ * A per-plugin performance record, built with {@link Diagnostics.performance}. The `performance`
415
+ * kind keeps it out of the problem list. It feeds the per-plugin timing bars, and reporters sum
416
+ * these into the run total.
417
+ */
418
+ type PerformanceDiagnostic = {
419
+ kind: 'performance';
420
+ code: typeof diagnosticCode.performance;
421
+ severity: 'info';
422
+ message: string;
423
+ /**
424
+ * The plugin this measurement belongs to.
425
+ */
426
+ plugin: string;
427
+ /**
428
+ * Elapsed milliseconds.
429
+ */
430
+ duration: number;
431
+ };
432
+ /**
433
+ * A notice that a newer Kubb version is available on npm, built with {@link Diagnostics.update}.
434
+ * It renders like any info diagnostic.
435
+ */
436
+ type UpdateDiagnostic = {
437
+ kind: 'update';
438
+ code: typeof diagnosticCode.updateAvailable;
439
+ severity: 'info';
440
+ message: string;
441
+ /**
442
+ * The running Kubb version.
443
+ */
444
+ currentVersion: string;
445
+ /**
446
+ * The newest version published on npm.
447
+ */
448
+ latestVersion: string;
449
+ };
450
+ /**
451
+ * A structured record collected during a build, discriminated on `kind`: a
452
+ * {@link ProblemDiagnostic} for an issue, a {@link PerformanceDiagnostic} for a per-plugin
453
+ * timing, or an {@link UpdateDiagnostic} for a version notice.
454
+ */
455
+ type Diagnostic = ProblemDiagnostic | PerformanceDiagnostic | UpdateDiagnostic;
456
+ /**
457
+ * A {@link Diagnostic} reduced to its JSON-safe fields plus a `docsUrl`, for
458
+ * machine-readable output (the `--reporter json` report, the MCP tools). Drops the
459
+ * non-serializable `cause` and the `kind`/`duration` bookkeeping.
460
+ */
461
+ type SerializedDiagnostic = {
462
+ code: DiagnosticCode;
463
+ severity: DiagnosticSeverity;
464
+ message: string;
465
+ location?: DiagnosticLocation;
466
+ help?: string;
467
+ plugin?: string;
468
+ /**
469
+ * The kubb.dev docs link for the code, omitted for the unknown fallback.
470
+ */
471
+ docsUrl?: string;
472
+ };
473
+ /**
474
+ * Static helpers for working with {@link Diagnostic}s, plus the run-scoped sink
475
+ * that lets deep code report a diagnostic without threading a callback.
476
+ *
477
+ * The sink lives in a single `AsyncLocalStorage` in the `@kubb/core` bundle.
478
+ * `Diagnostics.scope` activates it for a run, so anything inside that run (the
479
+ * adapter parse, a generator) reports through `Diagnostics.report` and lands
480
+ * in the same run.
481
+ */
482
+ declare class Diagnostics {
483
+ #private;
484
+ /**
485
+ * The diagnostic code catalog, exposed as `Diagnostics.code` (e.g. `Diagnostics.code.refNotFound`).
486
+ */
487
+ static code: {
488
+ readonly unknown: "KUBB_UNKNOWN";
489
+ readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
490
+ readonly inputRequired: "KUBB_INPUT_REQUIRED";
491
+ readonly refNotFound: "KUBB_REF_NOT_FOUND";
492
+ readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
493
+ readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
494
+ readonly pluginFailed: "KUBB_PLUGIN_FAILED";
495
+ readonly pluginWarning: "KUBB_PLUGIN_WARNING";
496
+ readonly pluginInfo: "KUBB_PLUGIN_INFO";
497
+ readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
498
+ readonly deprecated: "KUBB_DEPRECATED";
499
+ readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
500
+ readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
501
+ readonly invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS";
502
+ readonly postGenerateFailed: "KUBB_POST_GENERATE_FAILED";
503
+ readonly formatFailed: "KUBB_FORMAT_FAILED";
504
+ readonly lintFailed: "KUBB_LINT_FAILED";
505
+ readonly performance: "KUBB_PERFORMANCE";
506
+ readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
507
+ };
508
+ /**
509
+ * Type guard for a build {@link ProblemDiagnostic}.
510
+ */
511
+ static isProblem: (diagnostic: Diagnostic) => diagnostic is ProblemDiagnostic;
512
+ /**
513
+ * Type guard for a version-update {@link UpdateDiagnostic}.
514
+ */
515
+ static isUpdate: (diagnostic: Diagnostic) => diagnostic is UpdateDiagnostic;
516
+ /**
517
+ * Type guard for a per-plugin {@link PerformanceDiagnostic}.
518
+ */
519
+ static isPerformance: (diagnostic: Diagnostic) => diagnostic is PerformanceDiagnostic;
520
+ /**
521
+ * An `Error` that carries a {@link Diagnostic}, so structured problems can flow
522
+ * through the existing throw/catch paths while keeping their code and location.
523
+ *
524
+ * @example
525
+ * ```ts
526
+ * throw new Diagnostics.Error({ code: diagnosticCode.refNotFound, severity: 'error', message: `Could not find ${ref}`, location: { kind: 'schema', pointer: ref, ref } })
527
+ * ```
528
+ */
529
+ static Error: {
530
+ new (diagnostic: ProblemDiagnostic): {
531
+ diagnostic: ProblemDiagnostic;
532
+ name: string;
533
+ message: string;
534
+ stack?: string;
535
+ cause?: unknown;
536
+ };
537
+ isError(error: unknown): error is Error;
538
+ isError(value: unknown): value is Error;
539
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
540
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
541
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
542
+ stackTraceLimit: number;
543
+ };
544
+ /**
545
+ * Structural check for a {@link Diagnostics.Error}, including one thrown from a duplicated
546
+ * `@kubb/core` copy where `instanceof` fails. Matches on the `name` and a `diagnostic`
547
+ * that carries a `code`.
548
+ */
549
+ static isError(error: unknown): error is InstanceType<typeof Diagnostics.Error>;
550
+ /**
551
+ * Runs `fn` with `sink` as the active diagnostic sink for the whole async
552
+ * subtree, so {@link Diagnostics.report} reaches it from anywhere inside.
553
+ */
554
+ static scope<T>(sink: (diagnostic: Diagnostic) => void, fn: () => T): T;
555
+ /**
556
+ * Collects a diagnostic into the active build via the run-scoped sink, without throwing.
557
+ * Returns `true` when a run consumed it, `false` when called outside a {@link Diagnostics.scope}
558
+ * (so callers can fall back to throwing). Use a `warning`/`info` severity for non-fatal issues.
559
+ * For rendering a diagnostic live on the hook bus, use {@link Diagnostics.emit} instead.
560
+ */
561
+ static report(diagnostic: Diagnostic): boolean;
562
+ /**
563
+ * Emits a diagnostic on the run's `kubb:diagnostic` hook so the loggers render it live.
564
+ * Use it instead of calling `hooks.callHook('kubb:diagnostic', ...)` directly. To collect a
565
+ * diagnostic into the build result from deep in a run, use {@link Diagnostics.report} instead.
566
+ */
567
+ static emit(hooks: Hookable<KubbHooks>, diagnostic: ProblemDiagnostic | UpdateDiagnostic): Promise<void>;
568
+ /**
569
+ * Coerces any thrown value into a {@link ProblemDiagnostic}. A {@link Diagnostics.Error}
570
+ * keeps its structured data, and anything else becomes a `KUBB_UNKNOWN` error.
571
+ */
572
+ static from(error: unknown): ProblemDiagnostic;
573
+ /**
574
+ * Builds a per-plugin performance record. Reporters sum these into the run total.
575
+ */
576
+ static performance({
577
+ plugin,
578
+ duration
579
+ }: {
580
+ plugin: string;
581
+ duration: number;
582
+ }): PerformanceDiagnostic;
583
+ /**
584
+ * Builds the version-update notice shown when a newer Kubb is published on npm.
585
+ */
586
+ static update({
587
+ currentVersion,
588
+ latestVersion
589
+ }: {
590
+ currentVersion: string;
591
+ latestVersion: string;
592
+ }): UpdateDiagnostic;
593
+ /**
594
+ * True when any diagnostic is an error, the severity that fails a build. Non-error
595
+ * diagnostics are ignored.
596
+ */
597
+ static hasError(diagnostics: ReadonlyArray<Diagnostic>): boolean;
598
+ /**
599
+ * Names of the plugins that failed, deduped, derived from the error diagnostics
600
+ * that carry a `plugin`.
601
+ */
602
+ static failedPlugins(diagnostics: ReadonlyArray<Diagnostic>): Array<string>;
603
+ /**
604
+ * Counts `problem` diagnostics by severity for the run summary. `performance` and
605
+ * `update` diagnostics are ignored.
606
+ */
607
+ static count(diagnostics: ReadonlyArray<Diagnostic>): {
608
+ errors: number;
609
+ warnings: number;
610
+ infos: number;
611
+ };
612
+ /**
613
+ * Drops duplicate `problem` diagnostics that share a code, location pointer, and
614
+ * plugin, so the same issue reported across several passes is shown once. Non-problem
615
+ * diagnostics are always kept.
616
+ */
617
+ static dedupe(diagnostics: ReadonlyArray<Diagnostic>): Array<Diagnostic>;
618
+ /**
619
+ * Builds the kubb.dev docs URL for a diagnostic code, e.g.
620
+ * `KUBB_REF_NOT_FOUND` → `https://kubb.dev/docs/5.x/reference/diagnostics/kubb-ref-not-found`.
621
+ */
622
+ static docsUrl(code: string): string;
623
+ /**
624
+ * The catalog entry for a code: its title, cause, and fix. Mirrors the kubb.dev
625
+ * `/diagnostics/<slug>` page.
626
+ */
627
+ static explain(code: DiagnosticCode): DiagnosticDoc;
628
+ /**
629
+ * Reduces a diagnostic to its JSON-safe fields plus a `docsUrl`, for machine-readable
630
+ * consumers. The `cause`, `kind`, and `duration` are dropped, and absent optional
631
+ * fields are omitted rather than set to `undefined`.
632
+ */
633
+ static serialize(diagnostic: Diagnostic): SerializedDiagnostic;
634
+ /**
635
+ * Renders a {@link Diagnostic} for terminal output as its parts: the `headline`
636
+ * (`[CODE] plugin: message`, with the code in the severity color) and the indented `details`
637
+ * rows (`at:` pointer, `fix:` help, `see:` docs link).
638
+ *
639
+ * Hosts compose these to fit their gutter: a clack logger passes `[headline, ...details]` as the
640
+ * message with no gutter symbol, while plain text outputs use {@link Diagnostics.formatLines}.
641
+ */
642
+ static format(diagnostic: Diagnostic): {
643
+ headline: string;
644
+ details: Array<string>;
645
+ };
646
+ /**
647
+ * The self-contained block form of {@link Diagnostics.format}: the `headline` followed by the
648
+ * indented detail rows. Used where there is no gutter (plain and file output).
649
+ */
650
+ static formatLines(diagnostic: Diagnostic): Array<string>;
651
+ }
652
+ //#endregion
653
+ //#region src/createReporter.d.ts
654
+ /**
655
+ * Numeric log-level thresholds used internally to compare verbosity.
656
+ *
657
+ * Higher numbers are more verbose.
658
+ */
659
+ declare const logLevel: {
660
+ readonly silent: number;
661
+ readonly error: 0;
662
+ readonly warn: 1;
663
+ readonly info: 3;
664
+ readonly verbose: 4;
665
+ };
666
+ /**
667
+ * A built-in reporter that renders a run's output, independent of the live logger view.
668
+ *
669
+ * - `cli` renders the per-config summary to the terminal (the default).
670
+ * - `json` writes a machine-readable report to stdout, for CI.
671
+ * - `file` writes a config's diagnostics to `.kubb/kubb-<name>-<timestamp>.log`.
672
+ */
673
+ type ReporterName = 'cli' | 'json' | 'file';
674
+ /**
675
+ * One config's outcome within a run, as handed to a {@link Reporter}.
676
+ */
677
+ type GenerationResult = {
678
+ config: Config;
679
+ /**
680
+ * Diagnostics collected while generating this config.
681
+ */
682
+ diagnostics: Array<Diagnostic>;
683
+ /**
684
+ * Number of files written for this config.
685
+ */
686
+ filesCreated: number;
687
+ status: 'success' | 'failed';
688
+ /**
689
+ * `process.hrtime()` snapshot taken when this config started generating.
690
+ */
691
+ hrStart: [number, number];
692
+ };
693
+ /**
694
+ * Render settings passed alongside the {@link GenerationResult}. These are not part of the run
695
+ * data, such as the output verbosity.
696
+ */
697
+ type ReporterContext = {
698
+ /**
699
+ * Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
700
+ * (`silent`, `error`, `warn`, `info`, `verbose`).
701
+ */
702
+ logLevel: (typeof logLevel)[keyof typeof logLevel];
703
+ };
704
+ /**
705
+ * Host-facing reporter, as installed onto a run. Unlike a Logger (the live TUI view), a reporter
706
+ * never sees the hook emitter. `report` runs once per config. `drain`, when present, runs once
707
+ * after the last config.
708
+ */
709
+ type Reporter = {
710
+ /**
711
+ * Display name, matching a {@link ReporterName} for the built-ins.
712
+ */
713
+ name: string;
714
+ /**
715
+ * Called once per config with that config's result and the render context.
716
+ */
717
+ report: (result: GenerationResult, context: ReporterContext) => void | Promise<void>;
718
+ /**
719
+ * Optional finalizer called once after the run's last config. The host wires it to
720
+ * `kubb:lifecycle:end`. {@link createReporter} closes it over the values that `report` returned.
721
+ */
722
+ drain: (context: ReporterContext) => void | Promise<void>;
723
+ [Symbol.dispose](): void;
724
+ };
725
+ /**
726
+ * Reporter definition passed to {@link createReporter}. `report` returns the value to collect for
727
+ * this config (e.g. a built report), and the optional `drain` receives the collected reports to
728
+ * emit as one document. `T` is inferred from `report`'s return type.
729
+ */
730
+ type UserReporter<T = void> = {
731
+ name: string;
732
+ report: (result: GenerationResult, context: ReporterContext) => T | Promise<T>;
733
+ drain?: (context: ReporterContext, reports: Array<T>) => void | Promise<void>;
734
+ };
735
+ /**
736
+ * Defines a reporter. When the definition has a `drain`, the returned reporter buffers each value
737
+ * `report` returns and hands the array to `drain` once, then clears it. Without a `drain`, nothing
738
+ * is buffered. Wiring the reporter onto the run's hooks is the host's job, so the reporter only
739
+ * ever deals with a {@link GenerationResult}.
740
+ *
741
+ * @example
742
+ * ```ts
743
+ * import { createReporter, Diagnostics } from '@kubb/core'
744
+ *
745
+ * export const jsonReporter = createReporter({
746
+ * name: 'json',
747
+ * report(result) {
748
+ * return { status: Diagnostics.hasError(result.diagnostics) ? 'failed' : 'success', diagnostics: result.diagnostics }
749
+ * },
750
+ * drain(context, reports) {
751
+ * process.stdout.write(`${JSON.stringify(reports, null, 2)}\n`)
752
+ * },
753
+ * })
754
+ * ```
755
+ */
756
+ declare function createReporter<T = void>(reporter: UserReporter<T>): Reporter;
757
+ //#endregion
758
+ //#region src/createStorage.d.ts
759
+ /**
760
+ * Backend that persists generated files. Kubb ships with `fsStorage` (writes
761
+ * to disk) and `memoryStorage` (keeps everything in RAM). Implement this
762
+ * interface to write somewhere else, such as S3 or a database.
763
+ */
764
+ type Storage = {
765
+ /**
766
+ * Identifier used in logs and diagnostics (`'fs'`, `'memory'`, `'s3'`).
767
+ */
768
+ readonly name: string;
769
+ /**
770
+ * Returns `true` when an entry for `key` exists.
771
+ */
772
+ hasItem(key: string): Promise<boolean>;
773
+ /**
774
+ * Reads the stored string. Returns `null` when the key is missing.
775
+ */
776
+ getItem(key: string): Promise<string | null>;
777
+ /**
778
+ * Stores `value` under `key`, creating any required structure (directories,
779
+ * buckets, ...).
780
+ */
781
+ setItem(key: string, value: string): Promise<void>;
782
+ /**
783
+ * Deletes the entry for `key`. No-op when the key does not exist.
784
+ */
785
+ removeItem(key: string): Promise<void>;
786
+ /**
787
+ * Returns every key. Pass `base` to filter to keys starting with that prefix.
788
+ */
789
+ getKeys(base?: string): Promise<Array<string>>;
790
+ /**
791
+ * Removes every entry. Pass `base` to scope the wipe to a key prefix.
792
+ */
793
+ clear(base?: string): Promise<void>;
794
+ };
795
+ /**
796
+ * Defines a custom storage backend. The builder receives user options and
797
+ * returns a `Storage` implementation. Kubb ships with filesystem and in-memory
798
+ * storages. A custom backend writes generated files elsewhere, such as cloud
799
+ * storage or a database.
800
+ *
801
+ * @example In-memory storage (the built-in implementation)
802
+ * ```ts
803
+ * import { createStorage } from '@kubb/core'
804
+ *
805
+ * export const memoryStorage = createStorage(() => {
806
+ * const store = new Map<string, string>()
807
+ *
808
+ * return {
809
+ * name: 'memory',
810
+ * async hasItem(key) {
811
+ * return store.has(key)
812
+ * },
813
+ * async getItem(key) {
814
+ * return store.get(key) ?? null
815
+ * },
816
+ * async setItem(key, value) {
817
+ * store.set(key, value)
818
+ * },
819
+ * async removeItem(key) {
820
+ * store.delete(key)
821
+ * },
822
+ * async getKeys(base) {
823
+ * const keys = [...store.keys()]
824
+ * return base ? keys.filter((k) => k.startsWith(base)) : keys
825
+ * },
826
+ * async clear(base) {
827
+ * if (!base) store.clear()
828
+ * },
829
+ * }
830
+ * })
831
+ * ```
832
+ */
833
+ declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => Storage): (options?: TOptions) => Storage;
834
+ //#endregion
835
+ //#region src/createRenderer.d.ts
836
+ /**
837
+ * Minimal interface any Kubb renderer must satisfy.
838
+ *
839
+ * `TElement` is the type the renderer accepts, for example `KubbReactElement`
840
+ * for `@kubb/renderer-jsx` or a custom type for your own renderer. Defaults to
841
+ * `unknown` so generators that don't care about the element type work without
842
+ * specifying it.
843
+ */
844
+ type Renderer<TElement = unknown> = {
845
+ /**
846
+ * Renders `element` and populates {@link files} with the resulting {@link FileNode} objects.
847
+ * Called once per render cycle. Must resolve before {@link files} is read.
848
+ */
849
+ render(element: TElement): Promise<void>;
850
+ /**
851
+ * Accumulated {@link FileNode} results produced by the last {@link render} call.
852
+ */
853
+ readonly files: Array<FileNode>;
854
+ /**
855
+ * Disposer hook so renderers participate in `using` blocks: `using r = rendererFactory()`
856
+ * runs cleanup on every exit path, including thrown errors.
857
+ */
858
+ [Symbol.dispose](): void;
859
+ };
860
+ /**
861
+ * A factory function that produces a fresh {@link Renderer} per render cycle.
862
+ *
863
+ * Generators use this to declare which renderer handles their output.
864
+ */
865
+ type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
866
+ /**
867
+ * Defines a renderer factory. Renderers turn the generator's return value
868
+ * (JSX, a template string, a tree of any shape) into `FileNode`s that get
869
+ * written to disk.
870
+ *
871
+ * A renderer can target output formats beyond JSX, for instance a Handlebars
872
+ * renderer or one that writes binary files. Plugins and generators pick the
873
+ * renderer to use via the `renderer` field on `defineGenerator`.
874
+ *
875
+ * @example A minimal renderer that wraps a custom runtime
876
+ * ```ts
877
+ * import { createRenderer } from '@kubb/core'
878
+ *
879
+ * export const myRenderer = createRenderer(() => {
880
+ * const runtime = new MyRuntime()
881
+ * return {
882
+ * async render(element) {
883
+ * await runtime.render(element)
884
+ * },
885
+ * get files() {
886
+ * return runtime.files
887
+ * },
888
+ * [Symbol.dispose]() {
889
+ * runtime.dispose()
890
+ * },
891
+ * }
892
+ * })
893
+ * ```
894
+ */
895
+ declare function createRenderer<TElement = unknown>(factory: RendererFactory<TElement>): RendererFactory<TElement>;
896
+ //#endregion
897
+ //#region src/Resolver.d.ts
898
+ /**
899
+ * Context for resolving filtered options for a given operation or schema node.
900
+ *
901
+ * @internal
902
+ */
903
+ type ResolveOptionsContext<TOptions> = {
904
+ options: TOptions;
905
+ exclude?: Array<Filter>;
906
+ include?: Array<Filter>;
907
+ override?: Array<Override<TOptions>>;
908
+ };
909
+ /**
910
+ * The built-in resolution machinery exposed on every resolver as `resolver.default`.
911
+ * Plugins delegate to it via `this.default.*` and set their own conventions through
912
+ * the top-level `name` and `file` entries.
913
+ */
914
+ type ResolverDefault = {
915
+ /**
916
+ * Built-in camelCase casing for a generated identifier.
917
+ */
918
+ name(name: string): string;
919
+ options<TOptions>(node: Node, context: ResolveOptionsContext<TOptions>): TOptions | null;
920
+ path(options: ResolvePathOptions): string;
921
+ file(options: ResolveFileOptions): FileNode;
922
+ banner(meta: InputMeta | undefined, context: ResolveBannerContext): string | null;
923
+ footer(meta: InputMeta | undefined, context: ResolveBannerContext): string | null;
924
+ };
925
+ /**
926
+ * The name request for `resolver.default.path`: a `baseName` plus the optional `tag`/`path` that
927
+ * grouping keys off.
928
+ */
929
+ type ResolverPathParams = {
930
+ baseName: FileNode['baseName'];
931
+ /**
932
+ * Tag value used when `group.type === 'tag'`.
933
+ */
934
+ tag?: string;
935
+ /**
936
+ * Path value used when `group.type === 'path'`.
937
+ */
938
+ path?: string;
939
+ };
940
+ /**
941
+ * Options for `resolver.default.path`: the name request (`baseName`, `tag`, `path`) plus where the
942
+ * output goes (`root`, `output`, `group`).
943
+ *
944
+ * @example
945
+ * ```ts
946
+ * resolver.default.path({ baseName: 'petTypes.ts', tag: 'pets', root: '/src', output: { path: 'types' }, group: { type: 'tag' } })
947
+ * // → '/src/types/pets/petTypes.ts'
948
+ * ```
949
+ */
950
+ type ResolvePathOptions = ResolverPathParams & {
951
+ /**
952
+ * Absolute project root that the output path is resolved against.
953
+ */
954
+ root: string;
955
+ /**
956
+ * Active output config; `output.path` is the base directory.
957
+ */
958
+ output: Output;
959
+ /**
960
+ * Optional grouping strategy applied to `tag` (tag grouping) or `path` (path grouping).
961
+ */
962
+ group?: Group;
963
+ };
964
+ /**
965
+ * The file request for `resolver.file` and `resolver.default.file`: the `name` and `extname` plus
966
+ * the optional `tag`/`path` that grouping keys off.
967
+ */
968
+ type ResolverFileParams = {
969
+ name: string;
970
+ extname: FileNode['extname'];
971
+ /**
972
+ * Tag value used when `group.type === 'tag'`.
973
+ */
974
+ tag?: string;
975
+ /**
976
+ * Path value used when `group.type === 'path'`.
977
+ */
978
+ path?: string;
979
+ };
980
+ /**
981
+ * Options for `resolver.file` and `resolver.default.file`: the file request (`name`, `extname`,
982
+ * `tag`, `path`) plus where the output goes (`root`, `output`, `group`).
983
+ *
984
+ * @example
985
+ * ```ts
986
+ * resolver.default.file({ name: 'listPets', extname: '.ts', tag: 'pets', root: '/src', output: { path: 'types' }, group: { type: 'tag' } })
987
+ * // → { baseName: 'listPets.ts', path: '/src/types/pets/listPets.ts', ... }
988
+ * ```
989
+ */
990
+ type ResolveFileOptions = ResolverFileParams & {
991
+ root: string;
992
+ output: Output;
993
+ group?: Group;
994
+ };
995
+ /**
996
+ * The `file` field of a resolver: decides what a generated file is called and, optionally, where
997
+ * it lives. This is how a resolver renames or relocates its files, replacing the older per-call
998
+ * `resolveName` hook.
999
+ *
1000
+ * @example Suffix every generated file
1001
+ * ```ts
1002
+ * file: {
1003
+ * baseName({ name, extname }) {
1004
+ * return `${name}Faker${extname}`
1005
+ * },
1006
+ * }
1007
+ * ```
1008
+ *
1009
+ * @example Own the full path
1010
+ * ```ts
1011
+ * file: {
1012
+ * path({ baseName, output }) {
1013
+ * return `${output.path}/mocks/${baseName}`
1014
+ * },
1015
+ * }
1016
+ * ```
1017
+ */
1018
+ type ResolverFile = {
1019
+ /**
1020
+ * Builds the file's complete base name, extension included, from the identifier and the target
1021
+ * `extname`. Defaults to `toFilePath(name)` with `extname` appended. Reaches sibling resolver
1022
+ * helpers through `this`.
1023
+ */
1024
+ baseName?(params: Pick<ResolverFileParams, 'name' | 'extname'>): FileNode['baseName'];
1025
+ /**
1026
+ * Returns the file's complete path, resolved against the project `root`. Bypasses `output.path`
1027
+ * and `group`, so the resolver owns the layout. The returned path may not escape `root`. Reaches
1028
+ * sibling resolver helpers through `this`.
1029
+ */
1030
+ path?(params: ResolverFilePathParams): string;
1031
+ };
1032
+ /**
1033
+ * The argument to a resolver's `file.path`: the resolved `baseName` (what `file.baseName` produced,
1034
+ * with the extension already appended) and the active `output`. `tag`, `path`, and `group` are
1035
+ * omitted because `file.path` owns the whole path and bypasses grouping, and `root` because the
1036
+ * returned path is resolved against it.
1037
+ */
1038
+ type ResolverFilePathParams = {
1039
+ baseName: FileNode['baseName'];
1040
+ output: Output;
1041
+ };
1042
+ /**
1043
+ * Per-file context describing the file a banner/footer is being resolved for, so a
1044
+ * `banner`/`footer` function can branch on the file kind (e.g. skip a `'use server'`
1045
+ * directive on re-export files).
1046
+ */
1047
+ type ResolveBannerFile = {
1048
+ /**
1049
+ * Full output path of the file being generated.
1050
+ */
1051
+ path: string;
1052
+ /**
1053
+ * File name only, e.g. `'stocks.ts'`.
1054
+ */
1055
+ baseName: string;
1056
+ /**
1057
+ * `true` for `index.ts` re-export barrels.
1058
+ */
1059
+ isBarrel?: boolean;
1060
+ /**
1061
+ * `true` for group `[dir]/[dir].ts` aggregation files.
1062
+ */
1063
+ isAggregation?: boolean;
1064
+ };
1065
+ /**
1066
+ * Document metadata extended with per-file context, passed to a `banner`/`footer` function.
1067
+ *
1068
+ * @example Skip a directive on re-export files
1069
+ * `banner: (meta) => (meta.isBarrel || meta.isAggregation) ? '' : "'use server'"`
1070
+ */
1071
+ type BannerMeta = InputMeta & {
1072
+ /**
1073
+ * Full output path of the file being generated.
1074
+ */
1075
+ filePath: string;
1076
+ /**
1077
+ * File name only, e.g. `'stocks.ts'`.
1078
+ */
1079
+ baseName: string;
1080
+ /**
1081
+ * `true` for `index.ts` re-export barrels.
1082
+ */
1083
+ isBarrel: boolean;
1084
+ /**
1085
+ * `true` for group `[dir]/[dir].ts` aggregation files.
1086
+ */
1087
+ isAggregation: boolean;
1088
+ };
1089
+ /**
1090
+ * Context passed to `resolver.default.banner` and `resolver.default.footer`.
1091
+ * `output` is optional since not every plugin configures a banner/footer, and `config`
1092
+ * carries the global Kubb config used to derive the default Kubb banner.
1093
+ */
1094
+ type ResolveBannerContext = {
1095
+ output?: Pick<Output, 'banner' | 'footer'>;
1096
+ config: Config;
1097
+ file?: ResolveBannerFile;
1098
+ };
1099
+ /**
1100
+ * Raw resolver fields passed to `createResolver` or patched through `Resolver.merge`.
1101
+ * `default` is the built-in machinery and is not user-settable.
1102
+ */
1103
+ type ResolverBuildOptions = {
1104
+ pluginName: string;
1105
+ name?: (name: string) => string;
1106
+ file?: ResolverFile;
1107
+ [key: string]: unknown;
1108
+ };
1109
+ /**
1110
+ * Partial resolver fields accepted by `Resolver.merge` and `setResolver`. Parameterize with a
1111
+ * concrete resolver type (e.g. `ResolverPatch<ResolverTs>`) to type-check overrides and bind
1112
+ * `this` to the full resolver. Namespaces are partial, so a patch may override a single method
1113
+ * (`query.name`) and the rest keep the plugin defaults. Overriding a whole resolver is not the
1114
+ * job of this patch, that is what a custom plugin is for.
1115
+ */
1116
+ type ResolverPatch<T extends Resolver = Resolver> = { [K in keyof Omit<T, keyof Resolver>]?: T[K] extends ((...args: Array<never>) => unknown) ? T[K] : Partial<T[K]> } & {
1117
+ name?: T['name'];
1118
+ file?: ResolverFile;
1119
+ } & ThisType<T>;
1120
+ /**
1121
+ * Shared brand for reaching a resolver's build options. `Resolver.merge` reads this instead of
1122
+ * relying on `instanceof`, which fails when a CommonJS config and the ESM CLI each load their own
1123
+ * copy of `@kubb/core`. `Symbol.for` resolves to one key across those copies, so the options stay
1124
+ * reachable and a `file` override is never dropped.
1125
+ */
1126
+ declare const resolverOptions: unique symbol;
1127
+ /**
1128
+ * Base constraint for all plugin resolver objects.
1129
+ *
1130
+ * The built-in machinery lives under `default`. Generators call the top-level `name` and
1131
+ * `file`, and a plugin overrides them to set its conventions. Extend with top-level helpers
1132
+ * (`typeName`, …) and/or grouped namespaces (`query`, `schema`, …).
1133
+ *
1134
+ * @example Top-level helper
1135
+ * ```ts
1136
+ * type MyResolver = Resolver & {
1137
+ * typeName(name: string): string
1138
+ * }
1139
+ * ```
1140
+ *
1141
+ * @example Grouped namespace
1142
+ * ```ts
1143
+ * type MyResolver = Resolver & {
1144
+ * query: {
1145
+ * name(node: OperationNode): string
1146
+ * keyName(node: OperationNode): string
1147
+ * }
1148
+ * }
1149
+ * ```
1150
+ */
1151
+ declare class Resolver {
1152
+ #private;
1153
+ readonly pluginName: string;
1154
+ constructor(options: ResolverBuildOptions);
1155
+ /** Exposes the raw build options so `Resolver.merge` can read them across `@kubb/core` copies. */
1156
+ get [resolverOptions](): ResolverBuildOptions;
1157
+ /**
1158
+ * The built-in resolution machinery. Always reaches the untouched defaults, even when a
1159
+ * plugin overrides the top-level `name` or `file`.
1160
+ */
1161
+ get default(): ResolverDefault;
1162
+ name(name: string): string;
1163
+ file(options: ResolveFileOptions): FileNode;
1164
+ /**
1165
+ * Merges `override` over `base` and returns a new resolver with helpers re-bound. Top-level
1166
+ * keys replace, and a namespace (or `file`) merges per method, so overriding `query.name`
1167
+ * keeps the base `query.keyName`. Used when applying `setResolver` partial overrides. Reads a
1168
+ * resolver's options through the shared brand rather than `instanceof`, so a `file` override
1169
+ * survives even when `base` and `override` come from different `@kubb/core` copies.
1170
+ */
1171
+ static merge<T extends Resolver>(base: T, override: ResolverPatch<T> | Resolver): T;
1172
+ }
1173
+ //#endregion
1174
+ //#region src/definePlugin.d.ts
1175
+ type ExtractRegistryKey$1<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
1176
+ /**
1177
+ * How a plugin consolidates its generated code into files.
1178
+ * - `'directory'` writes one file per operation or schema under `path`.
1179
+ * - `'file'` writes everything into a single file.
1180
+ */
1181
+ type OutputMode = 'directory' | 'file';
1182
+ /**
1183
+ * Output configuration shared by every plugin. Each plugin extends this with
1184
+ * its own keys via the `Kubb.PluginOptionsRegistry.output` interface merge.
1185
+ */
1186
+ type Output = {
1187
+ /**
1188
+ * Directory where the plugin writes its generated code, resolved against the global
1189
+ * `output.path` set on `defineConfig`. With `mode: 'file'`, this is the full output file
1190
+ * path and must include the extension (e.g. `'types.ts'`, `'models.py'`).
1191
+ */
1192
+ path: string;
1193
+ /**
1194
+ * How generated code is consolidated into files.
1195
+ * - `'directory'` writes one file per operation or schema under `path`.
1196
+ * - `'file'` writes everything into a single file. The `path` must include the file extension.
1197
+ *
1198
+ * @default 'directory'
1199
+ */
1200
+ mode?: OutputMode;
1201
+ /**
1202
+ * Text prepended to every generated file. Useful for license headers,
1203
+ * lint disables, or `@ts-nocheck` directives.
1204
+ *
1205
+ * A string is applied to every file (including barrel and aggregation re-export files).
1206
+ * Pass a function to compute the banner from the file's `BannerMeta` document metadata
1207
+ * plus per-file context (`isBarrel`, `isAggregation`, `filePath`, `baseName`), so you can
1208
+ * skip the banner on specific files.
1209
+ *
1210
+ * @example Add a directive to source files but not re-export files
1211
+ * `banner: (meta) => (meta.isBarrel || meta.isAggregation) ? '' : "'use server'"`
1212
+ */
1213
+ banner?: string | ((meta: BannerMeta) => string);
1214
+ /**
1215
+ * Text appended at the end of every generated file. Mirror of `banner`.
1216
+ * Pass a function to compute the footer from the file's `BannerMeta`.
1217
+ */
1218
+ footer?: string | ((meta: BannerMeta) => string);
1219
+ } & ExtractRegistryKey$1<Kubb.PluginOptionsRegistry, 'output'>;
1220
+ /**
1221
+ * Groups generated files into subdirectories based on an OpenAPI tag or path
1222
+ * segment.
1223
+ */
1224
+ type Group = {
1225
+ /**
1226
+ * Property used to assign each operation to a group.
1227
+ * - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`).
1228
+ * - `'path'` uses the first segment of the operation's URL.
1229
+ */
1230
+ type: 'tag' | 'path';
1231
+ /**
1232
+ * Returns the subdirectory name from the group key. Defaults to the camelCased tag for
1233
+ * `tag` groups, or the camelCased first path segment for `path` groups.
1234
+ */
1235
+ name?: (context: {
1236
+ group: string;
1237
+ }) => string;
1238
+ };
1239
+ /**
1240
+ * Couples `output.mode` with the plugin's `group` option at the type level.
1241
+ * - `mode: 'file'` forbids `group` (a single file has nothing to group).
1242
+ * - `mode: 'directory'` (or no mode) allows an optional `group` to organize
1243
+ * files into per-group subdirectories.
1244
+ *
1245
+ * Intersect into a plugin's `Options` type instead of declaring `output` and
1246
+ * `group` directly, since `mode` lives inside `output` while `group` is its sibling.
1247
+ * The generic keeps a plugin's extended `Output` shape intact.
1248
+ *
1249
+ * @example
1250
+ * ```ts
1251
+ * export type Options = OutputOptions & {
1252
+ * exclude?: Array<Exclude>
1253
+ * }
1254
+ * ```
1255
+ */
1256
+ type OutputOptions<TOutput extends Output = Output> = {
1257
+ output?: TOutput & {
1258
+ mode?: 'directory';
1259
+ };
1260
+ group?: Group;
1261
+ } | {
1262
+ output: TOutput & {
1263
+ mode: 'file';
1264
+ };
1265
+ group?: never;
1266
+ };
1267
+ type ByTag = {
1268
+ /**
1269
+ * Filter by OpenAPI `tags` field. Matches one or more tags assigned to operations.
1270
+ */
1271
+ type: 'tag';
1272
+ /**
1273
+ * Tag name to match (case-sensitive). Can be a literal string or regex pattern.
1274
+ */
1275
+ pattern: string | RegExp;
1276
+ };
1277
+ type ByOperationId = {
1278
+ /**
1279
+ * Filter by OpenAPI `operationId` field. Each operation (GET, POST, etc.) has a unique identifier.
1280
+ */
1281
+ type: 'operationId';
1282
+ /**
1283
+ * Operation ID to match (case-sensitive). Can be a literal string or regex pattern.
1284
+ */
1285
+ pattern: string | RegExp;
1286
+ };
1287
+ type ByPath = {
1288
+ /**
1289
+ * Filter by OpenAPI `path` (URL endpoint). Useful to group or filter by service segments like `/pets`, `/users`, etc.
1290
+ */
1291
+ type: 'path';
1292
+ /**
1293
+ * URL path to match (case-sensitive). Can be a literal string or regex pattern. Matches against the full path.
1294
+ */
1295
+ pattern: string | RegExp;
1296
+ };
1297
+ type ByMethod = {
1298
+ /**
1299
+ * Filter by HTTP method: `'GET'`, `'POST'`, `'PUT'`, `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`.
1300
+ */
1301
+ type: 'method';
1302
+ /**
1303
+ * HTTP method to match, as one of the `HttpMethod` values (`'GET'`, `'POST'`, `'PUT'`,
1304
+ * `'PATCH'`, `'DELETE'`, `'HEAD'`, `'OPTIONS'`, `'TRACE'`) or a regex.
1305
+ */
1306
+ pattern: HttpMethod | RegExp;
1307
+ };
1308
+ type BySchemaName = {
1309
+ /**
1310
+ * Filter by schema component name (TypeScript or JSON schema). Matches schemas in `#/components/schemas`.
1311
+ */
1312
+ type: 'schemaName';
1313
+ /**
1314
+ * Schema name to match (case-sensitive). Can be a literal string or regex pattern.
1315
+ */
1316
+ pattern: string | RegExp;
1317
+ };
1318
+ type ByContentType = {
1319
+ /**
1320
+ * Filter by response or request content type: `'application/json'`, `'application/xml'`, etc.
1321
+ */
1322
+ type: 'contentType';
1323
+ /**
1324
+ * Content type to match (case-sensitive). Can be a literal string or regex pattern.
1325
+ */
1326
+ pattern: string | RegExp;
1327
+ };
1328
+ /**
1329
+ * Pattern filter for include, exclude, and override rules. Matches operations or schemas
1330
+ * by tag, operationId, path, method, content type, or schema name.
1331
+ */
1332
+ type Filter = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
1333
+ /**
1334
+ * Filter that skips matching operations or schemas during generation, for example
1335
+ * deprecated endpoints or internal-only schemas.
1336
+ *
1337
+ * @example
1338
+ * ```ts
1339
+ * exclude: [
1340
+ * { type: 'tag', pattern: 'internal' },
1341
+ * { type: 'path', pattern: /^\/admin/ },
1342
+ * { type: 'operationId', pattern: /^deprecated_/ },
1343
+ * ]
1344
+ * ```
1345
+ */
1346
+ type Exclude$1 = Filter;
1347
+ /**
1348
+ * Filter that restricts generation to operations or schemas matching at least
1349
+ * one entry. Useful for partial builds (one tag, one API version).
1350
+ *
1351
+ * @example
1352
+ * ```ts
1353
+ * include: [
1354
+ * { type: 'tag', pattern: 'public' },
1355
+ * { type: 'path', pattern: /^\/api\/v1/ },
1356
+ * ]
1357
+ * ```
1358
+ */
1359
+ type Include = Filter;
1360
+ /**
1361
+ * Filter paired with a partial options object. When the filter matches, the
1362
+ * options are merged on top of the plugin defaults for that operation only.
1363
+ * Useful for "this one tag goes to a different folder" rules.
1364
+ *
1365
+ * Entries are evaluated top to bottom. The first matching entry wins.
1366
+ *
1367
+ * @example
1368
+ * ```ts
1369
+ * override: [
1370
+ * {
1371
+ * type: 'tag',
1372
+ * pattern: 'admin',
1373
+ * options: { output: { path: './src/gen/admin' } },
1374
+ * },
1375
+ * {
1376
+ * type: 'operationId',
1377
+ * pattern: 'listPets',
1378
+ * options: { enumType: 'literal' },
1379
+ * },
1380
+ * ]
1381
+ * ```
1382
+ */
1383
+ type Override<TOptions> = Filter & {
1384
+ options: Omit<Partial<TOptions>, 'override'>;
1385
+ };
1386
+ type PluginFactoryOptions<
1387
+ /**
1388
+ * Unique plugin name.
1389
+ */
1390
+ TName extends string = string,
1391
+ /**
1392
+ * User-facing plugin options.
1393
+ */
1394
+ TOptions extends object = object,
1395
+ /**
1396
+ * Plugin options after defaults are applied.
1397
+ */
1398
+ TResolvedOptions extends object = TOptions,
1399
+ /**
1400
+ * Resolver that encapsulates naming and path-resolution helpers.
1401
+ * Define with `createResolver` and export alongside the plugin.
1402
+ */
1403
+ TResolver extends Resolver = Resolver> = {
1404
+ name: TName;
1405
+ options: TOptions;
1406
+ resolvedOptions: TResolvedOptions;
1407
+ resolver: TResolver;
1408
+ };
1409
+ /**
1410
+ * Context passed to a plugin's `kubb:plugin:setup` handler, where it registers generators and
1411
+ * sets its resolver, transformer, and options.
1412
+ */
1413
+ type KubbPluginSetupContext<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1414
+ /**
1415
+ * Register one or more generators dynamically. Generators fire during the AST walk
1416
+ * (schema/operation/operations) just like generators declared statically on `createPlugin`.
1417
+ *
1418
+ * Pass generators as separate arguments. Spread an existing list to register it in one call.
1419
+ *
1420
+ * @example
1421
+ * ```ts
1422
+ * ctx.addGenerator(myGenerator)
1423
+ * ctx.addGenerator(schemaGenerator, operationGenerator)
1424
+ * ctx.addGenerator(...selectedGenerators)
1425
+ * ```
1426
+ */
1427
+ addGenerator<TElement = unknown>(...generators: Array<Generator<TFactory, TElement>>): void;
1428
+ /**
1429
+ * Set or override the resolver for this plugin.
1430
+ * The resolver controls file naming and path resolution. Overrides merge over the built-in
1431
+ * defaults, so a partial `core` or a single namespace method replaces only what it names.
1432
+ */
1433
+ setResolver(resolver: ResolverPatch<TFactory['resolver']> | TFactory['resolver']): void;
1434
+ /**
1435
+ * Add a macro that rewrites AST nodes before they reach generators. Macros run in the order they
1436
+ * are added, after any macros from earlier `addMacro` calls.
1437
+ */
1438
+ addMacro(macro: Macro): void;
1439
+ /**
1440
+ * Replace this plugin's macros with `macros`.
1441
+ */
1442
+ setMacros(macros: ReadonlyArray<Macro>): void;
1443
+ /**
1444
+ * Set resolved options merged into the normalized plugin's `options`.
1445
+ * Call this in `kubb:plugin:setup` to provide options generators need.
1446
+ */
1447
+ setOptions(options: TFactory['resolvedOptions']): void;
1448
+ /**
1449
+ * Inject a raw file into the build output, bypassing the generation pipeline.
1450
+ *
1451
+ * Pass `copy` with an absolute path to emit a real source file (a shipped template) into the
1452
+ * generated folder verbatim, instead of building its content from `sources`.
1453
+ */
1454
+ injectFile(userFileNode: UserFileNode): void;
1455
+ /**
1456
+ * The resolved build configuration at setup time.
1457
+ */
1458
+ config: Config;
1459
+ /**
1460
+ * The plugin's user-provided options.
1461
+ */
1462
+ options: TFactory['options'];
1463
+ };
1464
+ /**
1465
+ * A plugin object produced by `definePlugin`. Its lifecycle handlers live under a single
1466
+ * `hooks` property rather than flat methods.
1467
+ */
1468
+ type Plugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions> = {
1469
+ /**
1470
+ * Unique name for the plugin, following the same naming convention as `createPlugin`.
1471
+ */
1472
+ name: string;
1473
+ /**
1474
+ * Plugins that must be registered before this plugin executes.
1475
+ * An error is thrown at startup when any listed dependency is missing.
1476
+ */
1477
+ dependencies?: Array<string>;
1478
+ /**
1479
+ * Controls the execution order of this plugin relative to others.
1480
+ *
1481
+ * - `'pre'` runs before all normal plugins.
1482
+ * - `'post'` runs after all normal plugins.
1483
+ * - `undefined` (default) runs in declaration order among normal plugins.
1484
+ *
1485
+ * Dependency constraints always take precedence over `enforce`.
1486
+ */
1487
+ enforce?: Enforce;
1488
+ /**
1489
+ * The options passed by the user when calling the plugin factory.
1490
+ */
1491
+ options?: TFactory['options'];
1492
+ /**
1493
+ * Lifecycle hook handlers for this plugin.
1494
+ * Any hook from the global `KubbHooks` map can be subscribed to here.
1495
+ */
1496
+ hooks: { [K in keyof KubbHooks as K extends 'kubb:plugin:setup' ? never : K]?: (...args: KubbHooks[K]) => void | Promise<void> } & {
1497
+ 'kubb:plugin:setup'?(ctx: KubbPluginSetupContext<TFactory>): void | Promise<void>;
1498
+ };
1499
+ };
1500
+ /**
1501
+ * Normalized plugin after setup, with runtime fields populated. Internal only. Plugins use the
1502
+ * public `Plugin` type.
1503
+ *
1504
+ * @internal
1505
+ */
1506
+ type NormalizedPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & {
1507
+ options: TOptions['resolvedOptions'] & {
1508
+ output: Output;
1509
+ include?: Array<Include>;
1510
+ exclude: Array<Exclude$1>;
1511
+ override: Array<Override<TOptions['resolvedOptions']>>;
1512
+ };
1513
+ resolver: TOptions['resolver'];
1514
+ macros?: Array<Macro>;
1515
+ generators?: Array<Generator>;
1516
+ };
1517
+ type KubbPluginStartContext = {
1518
+ plugin: NormalizedPlugin;
1519
+ };
1520
+ type KubbPluginEndContext = {
1521
+ plugin: NormalizedPlugin;
1522
+ duration: number;
1523
+ success: boolean;
1524
+ error?: Error;
1525
+ config: Config;
1526
+ /**
1527
+ * Returns all files currently in the file manager (lazy snapshot).
1528
+ * Includes files added by plugins that have already run.
1529
+ */
1530
+ readonly files: ReadonlyArray<FileNode>;
1531
+ /**
1532
+ * Upsert one or more files into the file manager.
1533
+ */
1534
+ upsertFile: (...files: Array<FileNode>) => void;
1535
+ };
1536
+ /**
1537
+ * Wraps a plugin factory and returns a function that accepts user options and
1538
+ * yields a typed `Plugin`. Lifecycle handlers go inside a single `hooks` object.
1539
+ *
1540
+ * Pass a `PluginFactoryOptions` type parameter to get a typed `ctx` inside
1541
+ * `kubb:plugin:setup`. Plugin names should follow the `plugin-<feature>`
1542
+ * convention (`plugin-react-query`, `plugin-zod`, ...).
1543
+ *
1544
+ * @example
1545
+ * ```ts
1546
+ * import { definePlugin } from '@kubb/core'
1547
+ *
1548
+ * export const pluginTs = definePlugin((options: { prefix?: string } = {}) => ({
1549
+ * name: 'plugin-ts',
1550
+ * hooks: {
1551
+ * 'kubb:plugin:setup'(ctx) {
1552
+ * ctx.setResolver(resolverTs)
1553
+ * },
1554
+ * },
1555
+ * }))
1556
+ * ```
1557
+ */
1558
+ declare function definePlugin<TFactory extends PluginFactoryOptions = PluginFactoryOptions>(factory: (options: TFactory['options']) => Plugin<TFactory>): (options?: TFactory['options']) => Plugin<TFactory>;
1559
+ //#endregion
1560
+ //#region src/defineParser.d.ts
1561
+ /**
1562
+ * Converts a resolved {@link FileNode} into the final source string that gets
1563
+ * written to disk. Kubb ships with TypeScript and TSX parsers. Add your own
1564
+ * for new file types (JSON, Markdown, ...).
1565
+ */
1566
+ type Parser<TMeta extends object = object, TNode = unknown> = {
1567
+ /**
1568
+ * Display name used in diagnostics and the parser registry.
1569
+ */
1570
+ name: string;
1571
+ /**
1572
+ * File extensions this parser handles. The driver registers the parser for each
1573
+ * extension in this list. A parser with `undefined` here is not registered, so
1574
+ * files of an unclaimed extension fall back to joining their sources verbatim.
1575
+ *
1576
+ * @example
1577
+ * `['.ts', '.js']`
1578
+ */
1579
+ extNames: Array<FileNode['extname']> | undefined;
1580
+ /**
1581
+ * Serialize the file's AST into source code.
1582
+ */
1583
+ parse(file: FileNode<TMeta>): string;
1584
+ /**
1585
+ * Render compiler AST nodes for this parser's language into source text.
1586
+ * Plugins call this to format the nodes they assemble before handing them
1587
+ * back to the parser as `FileNode.sources`.
1588
+ */
1589
+ print(...nodes: Array<TNode>): string;
1590
+ };
1591
+ /**
1592
+ * Wraps a parser factory and returns a function that accepts user options and
1593
+ * yields a typed {@link Parser}. Mirrors {@link definePlugin}: the factory
1594
+ * receives the caller's options, and calling the returned function without
1595
+ * options passes an empty object.
1596
+ *
1597
+ * Register the result in the `parsers` array on `defineConfig`, calling it to
1598
+ * apply options (`parserTs({ extension: { '.ts': '.js' } })`).
1599
+ *
1600
+ * @example
1601
+ * ```ts
1602
+ * import { defineParser } from '@kubb/core'
1603
+ * import { extractStringsFromNodes } from '@kubb/ast'
1604
+ *
1605
+ * export const parserJson = defineParser((options: { pretty?: boolean } = {}) => ({
1606
+ * name: 'json',
1607
+ * extNames: ['.json'],
1608
+ * parse(file) {
1609
+ * const source = file.sources.map((source) => extractStringsFromNodes(source.nodes ?? [])).join('\n')
1610
+ * return options.pretty ? JSON.stringify(JSON.parse(source), null, 2) : source
1611
+ * },
1612
+ * print(...nodes) {
1613
+ * return nodes.map(String).join('\n')
1614
+ * },
1615
+ * }))
1616
+ * ```
1617
+ */
1618
+ declare function defineParser<TOptions extends object = object, TMeta extends object = object, TNode = unknown>(factory: (options: TOptions) => Parser<TMeta, TNode>): (options?: TOptions) => Parser<TMeta, TNode>;
1619
+ //#endregion
1620
+ //#region src/FileManager.d.ts
1621
+ /**
1622
+ * Hooks fired around a `FileManager#write` batch: `start` before it, `update` per file, `end` after.
1623
+ */
1624
+ type FileManagerHooks = {
1625
+ start: [files: Array<FileNode>];
1626
+ update: [params: {
1627
+ file: FileNode;
1628
+ source?: string;
1629
+ processed: number;
1630
+ total: number;
1631
+ percentage: number;
1632
+ }];
1633
+ end: [files: Array<FileNode>];
1634
+ };
1635
+ type ParseOptions = {
1636
+ parsers?: Map<FileNode['extname'], Parser>;
1637
+ };
1638
+ type WriteOptions = ParseOptions & {
1639
+ storage: Storage;
1640
+ };
1641
+ /**
1642
+ * In-memory file store for generated files, and the writer that turns them into source
1643
+ * strings on `storage`. Files sharing a `path` are merged (sources/imports/exports
1644
+ * concatenated). The `files` getter is sorted by path length (barrel `index.ts` last
1645
+ * within a bucket).
1646
+ *
1647
+ * @example
1648
+ * ```ts
1649
+ * const manager = new FileManager()
1650
+ * manager.upsert(myFile)
1651
+ * manager.files // sorted view
1652
+ * await manager.write(manager.files, { storage: fsStorage() })
1653
+ * ```
1654
+ */
1655
+ declare class FileManager {
1656
+ #private;
1657
+ readonly hooks: Hookable<FileManagerHooks>;
1658
+ add(...files: Array<FileNode>): Array<FileNode>;
1659
+ upsert(...files: Array<FileNode>): Array<FileNode>;
1660
+ clear(): void;
1661
+ /**
1662
+ * Releases all stored files and clears every `hooks` listener. Called by the core after
1663
+ * `kubb:build:end`.
1664
+ */
1665
+ dispose(): void;
1666
+ /**
1667
+ * All stored files in stable sort order (shortest path first, barrel files
1668
+ * last within a length bucket). Returns a cached view, do not mutate.
1669
+ */
1670
+ get files(): Array<FileNode>;
1671
+ /**
1672
+ * Converts a file's AST sources (or its `copy` source) into the final on-disk string.
1673
+ */
1674
+ parse(file: FileNode, {
1675
+ parsers
1676
+ }?: ParseOptions): Promise<string>;
1677
+ /**
1678
+ * Converts and writes every file at once, letting `storage.setItem` decide how much of
1679
+ * that runs concurrently.
1680
+ */
1681
+ write(files: Array<FileNode>, {
1682
+ storage,
1683
+ parsers
1684
+ }: WriteOptions): Promise<void>;
1685
+ }
1686
+ //#endregion
1687
+ //#region src/KubbDriver.d.ts
1688
+ type Options = {
1689
+ hooks: Hookable<KubbHooks>;
1690
+ };
1691
+ type RequirePluginContext = {
1692
+ /**
1693
+ * Name of the plugin that declared the dependency, included in the error so users can
1694
+ * trace which plugin needs the missing one.
1695
+ */
1696
+ requiredBy?: string;
1697
+ };
1698
+ declare class KubbDriver {
1699
+ #private;
1700
+ readonly config: Config;
1701
+ readonly options: Options;
1702
+ /**
1703
+ * The `InputNode` produced by the adapter. Set after adapter setup.
1704
+ */
1705
+ inputNode: InputNode | null;
1706
+ adapter: Adapter | null;
1707
+ /**
1708
+ * Central file store for all generated files.
1709
+ * Plugins should use `this.addFile()` / `this.upsertFile()` (via their context) to
1710
+ * add files. This property gives direct read/write access when needed.
1711
+ */
1712
+ readonly fileManager: FileManager;
1713
+ readonly plugins: Map<string, NormalizedPlugin>;
1714
+ constructor(config: Config, options: Options);
1715
+ /**
1716
+ * Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
1717
+ * A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
1718
+ * `'post'`. When the config has an adapter, the adapter source is resolved from the input
1719
+ * so `run` can parse it later.
1720
+ */
1721
+ setup(): Promise<void>;
1722
+ get hooks(): Hookable<KubbHooks>;
1723
+ /**
1724
+ * Runs each plugin's `kubb:plugin:setup` handler, in plugin order, with a context scoped to that
1725
+ * plugin so `addGenerator`, `setResolver`, `addMacro`, `setMacros`, and `setOptions` target its
1726
+ * `NormalizedPlugin` entry. Called once from `run` before the plugin execution loop begins, so
1727
+ * plugins can configure generators, resolvers, macros, and options before `buildStart`.
1728
+ */
1729
+ setupHooks(): Promise<void>;
1730
+ /**
1731
+ * Registers a generator for the given plugin on the shared hook emitter.
1732
+ *
1733
+ * The generator's `schema`, `operation`, and `operations` methods are registered as
1734
+ * listeners on `kubb:generate:schema`, `kubb:generate:operation`, and `kubb:generate:operations`
1735
+ * respectively. Each listener is scoped to the owning plugin via a `ctx.plugin.name` check
1736
+ * so that generators from different plugins do not cross-fire.
1737
+ *
1738
+ * The renderer comes from `generator.renderer`. Set `generator.renderer = null` (or leave it
1739
+ * unset) to opt out of rendering.
1740
+ *
1741
+ * Call this method inside `addGenerator()` (in `kubb:plugin:setup`) to wire up a generator.
1742
+ */
1743
+ registerGenerator(pluginName: string, generator: Generator): void;
1744
+ /**
1745
+ * Returns `true` when at least one generator was registered for the given plugin
1746
+ * via `addGenerator()` in `kubb:plugin:setup`.
1747
+ *
1748
+ * Used by the build loop to decide whether to walk the AST and emit generator hooks
1749
+ * for a plugin.
1750
+ */
1751
+ hasHookGenerators(pluginName: string): boolean;
1752
+ /**
1753
+ * Runs the full plugin pipeline. Returns the diagnostics collected so far even
1754
+ * when an outer hook throws, since the orchestrator preserves partial state by capturing
1755
+ * the failure as a {@link Diagnostic} instead of propagating. Each plugin also
1756
+ * contributes a `timing` diagnostic for the run summary.
1757
+ */
1758
+ run(): Promise<{
1759
+ diagnostics: Array<Diagnostic>;
1760
+ }>;
1761
+ /**
1762
+ * Stores whatever a generator method or `kubb:generate:*` hook returned.
1763
+ *
1764
+ * - An `Array<FileNode>` goes straight into `fileManager` via `upsert`.
1765
+ * - A renderer element runs through `renderer` (the renderer factory, e.g. JSX) and the
1766
+ * produced files go to `fileManager.upsert`.
1767
+ * - A falsy result is treated as a no-op. The generator wrote files itself via
1768
+ * `ctx.upsertFile`.
1769
+ *
1770
+ * Pass `renderer` when the result may be a renderer element. Generators that only return
1771
+ * `Array<FileNode>` do not need one.
1772
+ */
1773
+ dispatch<TElement = unknown>({
1774
+ result,
1775
+ renderer
1776
+ }: {
1777
+ result: TElement | Array<FileNode> | undefined | null;
1778
+ renderer?: RendererFactory<TElement> | null;
1779
+ }): Promise<void>;
1780
+ /**
1781
+ * Removes every listener the driver added. Listeners attached directly to `hooks` from outside
1782
+ * the driver survive. Called at the end of a build to prevent leaks across repeated builds.
1783
+ *
1784
+ * @internal
1785
+ */
1786
+ dispose(): void;
1787
+ [Symbol.dispose](): void;
1788
+ /**
1789
+ * Merges `partial` with the plugin's default resolver and stores the result.
1790
+ * Also mirrors it onto `plugin.resolver` so callers using `getPlugin(name).resolver`
1791
+ * get the up-to-date resolver without going through `getResolver()`.
1792
+ */
1793
+ setPluginResolver(pluginName: string, partial: ResolverPatch | Resolver): void;
1794
+ /**
1795
+ * Returns the resolver for the given plugin.
1796
+ *
1797
+ * Resolution order: resolver set via `setPluginResolver` → lazily created default
1798
+ * resolver (identity name, no path transforms).
1799
+ */
1800
+ getResolver<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Kubb.PluginRegistry[TName]['resolver'];
1801
+ getResolver<TResolver extends Resolver = Resolver>(pluginName: string): TResolver;
1802
+ getContext<TOptions extends PluginFactoryOptions>(plugin: NormalizedPlugin<TOptions>): Omit<GeneratorContext<TOptions>, 'options'>;
1803
+ getPlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
1804
+ getPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string): Plugin<TOptions> | undefined;
1805
+ /**
1806
+ * Like `getPlugin` but throws a descriptive error when the plugin is not found.
1807
+ */
1808
+ requirePlugin<TName extends keyof Kubb.PluginRegistry>(pluginName: TName, context?: RequirePluginContext): Plugin<Kubb.PluginRegistry[TName]>;
1809
+ requirePlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions>(pluginName: string, context?: RequirePluginContext): Plugin<TOptions>;
1810
+ }
1811
+ //#endregion
1812
+ //#region src/defineGenerator.d.ts
1813
+ /**
1814
+ * Context passed to a generator's `schema`, `operation`, and `operations` methods.
1815
+ *
1816
+ * The driver sets `adapter` on the context before it runs a generator, so methods can read it
1817
+ * without a null check. `ctx.options` carries the per-node options after exclude/include/override
1818
+ * filtering for `schema` and `operation`, or the plugin-level options for `operations`.
1819
+ */
1820
+ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
1821
+ /**
1822
+ * The resolved Kubb config for this build, including `root`, `input`, `output`, and the
1823
+ * full plugin list.
1824
+ */
1825
+ config: Config;
1826
+ /**
1827
+ * Absolute path to the current plugin's output directory.
1828
+ */
1829
+ root: string;
1830
+ /**
1831
+ * The driver running this build. Most generators never need it. Prefer the scoped helpers
1832
+ * on this context (`getPlugin`, `getResolver`, `upsertFile`) over reaching into the driver.
1833
+ */
1834
+ driver: KubbDriver;
1835
+ /**
1836
+ * Get a plugin by name, typed via `Kubb.PluginRegistry` when registered.
1837
+ */
1838
+ getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
1839
+ getPlugin(name: string): Plugin | undefined;
1840
+ /**
1841
+ * Get a plugin by name, throws an error if not found.
1842
+ */
1843
+ requirePlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]>;
1844
+ requirePlugin(name: string): Plugin;
1845
+ /**
1846
+ * Get a resolver by plugin name, typed via `Kubb.PluginRegistry` when registered.
1847
+ */
1848
+ getResolver<TName extends keyof Kubb.PluginRegistry>(name: TName): Kubb.PluginRegistry[TName]['resolver'];
1849
+ getResolver(name: string): Resolver;
1850
+ /**
1851
+ * Add files only if they don't exist.
1852
+ */
1853
+ addFile: (...file: Array<FileNode>) => Promise<void>;
1854
+ /**
1855
+ * Merge sources into the same output file.
1856
+ */
1857
+ upsertFile: (...file: Array<FileNode>) => Promise<void>;
1858
+ /**
1859
+ * The build's hook bus. Emit or listen to any `KubbHooks` hook, for example to react to
1860
+ * `kubb:build:end` from inside a generator.
1861
+ */
1862
+ hooks: Hookable<KubbHooks>;
1863
+ /**
1864
+ * The current plugin instance.
1865
+ */
1866
+ plugin: Plugin<TOptions>;
1867
+ /**
1868
+ * The current plugin's resolver. It decides what every generated symbol and file path is
1869
+ * called. Kubb picks a `setResolver` registration first, then the plugin's static
1870
+ * `resolver`, then the built-in default.
1871
+ *
1872
+ * @example Resolve a name
1873
+ * `ctx.resolver.name('pet') // 'pet'`
1874
+ *
1875
+ * @example Resolve an output file
1876
+ * `ctx.resolver.file({ name: 'pet', extname: '.ts', root, output })`
1877
+ */
1878
+ resolver: TOptions['resolver'];
1879
+ /**
1880
+ * Report a warning. Collected as a `warning` diagnostic attributed to the current
1881
+ * plugin. It surfaces in the run summary but does not fail the build. For a structured
1882
+ * diagnostic with a code and source location, use `Diagnostics.report` or throw a
1883
+ * `Diagnostics.Error` directly.
1884
+ */
1885
+ warn: (message: string) => void;
1886
+ /**
1887
+ * Report an error. Collected as an `error` diagnostic attributed to the current
1888
+ * plugin, which fails the build.
1889
+ */
1890
+ error: (error: string | Error) => void;
1891
+ /**
1892
+ * Report an informational message. Collected as an `info` diagnostic attributed to
1893
+ * the current plugin.
1894
+ */
1895
+ info: (message: string) => void;
1896
+ /**
1897
+ * The configured adapter instance.
1898
+ */
1899
+ adapter: Adapter;
1900
+ /**
1901
+ * Document metadata from the adapter: title, version, base URL, and pre-computed
1902
+ * schema index fields (`circularNames`, `enumNames`).
1903
+ */
1904
+ meta: InputMeta;
1905
+ /**
1906
+ * Resolved options after exclude/include/override filtering.
1907
+ */
1908
+ options: TOptions['resolvedOptions'];
1909
+ };
1910
+ /**
1911
+ * Declares a named generator unit that walks the AST and emits files.
1912
+ *
1913
+ * `schema` runs for each schema node and `operation` for each operation node. `operations` runs
1914
+ * once after every operation node is walked. JSX-based generators require a `renderer` factory.
1915
+ * Return `Array<FileNode>` directly, or call `ctx.upsertFile()` manually and return `null` to
1916
+ * bypass rendering.
1917
+ *
1918
+ * @note Generators are consumed by plugins and registered via `ctx.addGenerator()` in `kubb:plugin:setup`.
1919
+ *
1920
+ * @example
1921
+ * ```ts
1922
+ * import { defineGenerator } from '@kubb/core'
1923
+ * import { jsxRenderer } from '@kubb/renderer-jsx'
1924
+ *
1925
+ * export const typeGenerator = defineGenerator({
1926
+ * name: 'typescript',
1927
+ * renderer: jsxRenderer,
1928
+ * schema(node, ctx) {
1929
+ * const { adapter, resolver, root, options } = ctx
1930
+ * return <File ...><Type node={node} resolver={resolver} /></File>
1931
+ * },
1932
+ * })
1933
+ * ```
1934
+ */
1935
+ type Generator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown> = {
1936
+ /**
1937
+ * Used in diagnostic messages and debug output.
1938
+ */
1939
+ name: string;
1940
+ /**
1941
+ * Optional renderer factory that produces a {@link Renderer} for each render cycle.
1942
+ *
1943
+ * Generators that return renderer elements (e.g. JSX via `@kubb/renderer-jsx`) must set this
1944
+ * to the matching renderer factory (e.g. `jsxRenderer` from `@kubb/renderer-jsx`).
1945
+ *
1946
+ * Generators that only return `Array<FileNode>` or `void` do not need to set this.
1947
+ *
1948
+ * Leave it unset or set `renderer: null` to opt out of rendering.
1949
+ *
1950
+ * @example
1951
+ * ```ts
1952
+ * import { jsxRenderer } from '@kubb/renderer-jsx'
1953
+ * export const myGenerator = defineGenerator<PluginTs>({
1954
+ * renderer: jsxRenderer,
1955
+ * schema(node, ctx) { return <File ...>...</File> },
1956
+ * })
1957
+ * ```
1958
+ */
1959
+ renderer?: RendererFactory<TElement> | null;
1960
+ /**
1961
+ * Called for each schema node in the AST walk.
1962
+ * `ctx` carries the plugin context with `adapter` and `meta` (document metadata),
1963
+ * plus `ctx.options` with the per-node resolved options (after exclude/include/override).
1964
+ */
1965
+ schema?: (node: SchemaNode, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | undefined | null>;
1966
+ /**
1967
+ * Called for each operation node in the AST walk.
1968
+ * `ctx` carries the plugin context with `adapter` and `meta` (document metadata),
1969
+ * plus `ctx.options` with the per-node resolved options (after exclude/include/override).
1970
+ */
1971
+ operation?: (node: OperationNode, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | undefined | null>;
1972
+ /**
1973
+ * Called once after all operations have been walked.
1974
+ * `ctx` carries the plugin context with `adapter` and `meta` (document metadata),
1975
+ * plus `ctx.options` with the plugin-level options for the batch call.
1976
+ */
1977
+ operations?: (nodes: Array<OperationNode>, ctx: GeneratorContext<TOptions>) => PossiblePromise<TElement | Array<FileNode> | undefined | null>;
1978
+ };
1979
+ /**
1980
+ * Defines a generator: a unit of work that runs during the plugin's AST walk
1981
+ * and produces files. Plugins register generators via `ctx.addGenerator()`
1982
+ * inside `kubb:plugin:setup`.
1983
+ *
1984
+ * The returned object is the input as-is, but with `this` types preserved so
1985
+ * `schema`/`operation`/`operations` methods are correctly typed against the
1986
+ * plugin's `PluginFactoryOptions`. Renderer elements and `FileNode[]` returns
1987
+ * are both handled by the runtime, so pick whichever style fits.
1988
+ *
1989
+ * @example JSX-based schema generator
1990
+ * ```tsx
1991
+ * import { defineGenerator } from '@kubb/core'
1992
+ * import { jsxRenderer } from '@kubb/renderer-jsx'
1993
+ *
1994
+ * export const typeGenerator = defineGenerator({
1995
+ * name: 'typescript',
1996
+ * renderer: jsxRenderer,
1997
+ * schema(node, ctx) {
1998
+ * return (
1999
+ * <File path={`${ctx.root}/${node.name}.ts`}>
2000
+ * <Type node={node} resolver={ctx.resolver} />
2001
+ * </File>
2002
+ * )
2003
+ * },
2004
+ * })
2005
+ * ```
2006
+ */
2007
+ declare function defineGenerator<TOptions extends PluginFactoryOptions = PluginFactoryOptions, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
2008
+ //#endregion
2009
+ //#region src/createKubb.d.ts
2010
+ type CreateKubbOptions = {
2011
+ hooks?: Hookable<KubbHooks>;
2012
+ };
2013
+ /**
2014
+ * Kubb code-generation instance bound to a single config entry. Resolves the user
2015
+ * config in the constructor, so `config` is available right away, and shares `hooks`,
2016
+ * `storage`, and `driver` across the `setup → build` lifecycle.
2017
+ *
2018
+ * `createKubb` takes a plain config object (the shape `defineConfig` produces),
2019
+ * not a fluent builder.
2020
+ *
2021
+ * Attach hook listeners to `.hooks` before calling `setup()` or `build()`.
2022
+ *
2023
+ * @example
2024
+ * ```ts
2025
+ * const kubb = createKubb(userConfig)
2026
+ * kubb.hooks.hook('kubb:plugin:end', ({ plugin, duration }) => console.log(plugin.name, duration))
2027
+ * const { files, diagnostics } = await kubb.safeBuild()
2028
+ * ```
2029
+ */
2030
+ declare class Kubb$1 {
2031
+ #private;
2032
+ readonly hooks: Hookable<KubbHooks>;
2033
+ readonly config: Config;
2034
+ constructor(userConfig: UserConfig, options?: CreateKubbOptions);
2035
+ get storage(): Storage;
2036
+ get driver(): KubbDriver;
2037
+ /**
2038
+ * Initializes the driver and storage. `build()` calls this automatically.
2039
+ */
2040
+ setup(): Promise<void>;
2041
+ /**
2042
+ * Runs the full pipeline and throws on any plugin error.
2043
+ * Automatically calls `setup()` if needed.
2044
+ */
2045
+ build(): Promise<BuildOutput>;
2046
+ /**
2047
+ * Runs the full pipeline and captures errors in `BuildOutput` instead of throwing.
2048
+ * Automatically calls `setup()` if needed. This is the canonical call: it never throws on
2049
+ * plugin errors, so callers stay in control of how failures surface.
2050
+ */
2051
+ safeBuild(): Promise<BuildOutput>;
2052
+ dispose(): void;
2053
+ [Symbol.dispose](): void;
2054
+ }
2055
+ /**
2056
+ * Constructs a {@link Kubb} build orchestrator from a user config. Equivalent
2057
+ * to `new Kubb(userConfig, options)` and the canonical public entry point.
2058
+ *
2059
+ * @example
2060
+ * ```ts
2061
+ * import { createKubb } from '@kubb/core'
2062
+ * import { adapterOas } from '@kubb/adapter-oas'
2063
+ * import { pluginTs } from '@kubb/plugin-ts'
2064
+ *
2065
+ * const kubb = createKubb({
2066
+ * input: './petStore.yaml',
2067
+ * output: { path: './src/gen' },
2068
+ * adapter: adapterOas(),
2069
+ * plugins: [pluginTs()],
2070
+ * })
2071
+ *
2072
+ * await kubb.build()
2073
+ * ```
2074
+ */
2075
+ declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb$1;
2076
+ //#endregion
2077
+ //#region src/types.d.ts
2078
+ /**
2079
+ * @internal
2080
+ */
2081
+ type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {};
2082
+ /**
2083
+ * Source to generate from. Kubb detects what it was given:
2084
+ *
2085
+ * - A string that is a local file path (absolute or relative to the config file) or a URL is
2086
+ * read and parsed by the adapter (e.g. an OpenAPI YAML or JSON spec).
2087
+ * - A string that is inline OpenAPI content (JSON or YAML) is parsed directly.
2088
+ * - A parsed object is used as-is, without touching the filesystem.
2089
+ *
2090
+ * @example
2091
+ * ```ts
2092
+ * './petstore.yaml' // local path
2093
+ * 'https://example.com/openapi.json' // URL
2094
+ * '{ "openapi": "3.1.0", "info": {...} }' // inline JSON
2095
+ * { openapi: '3.1.0', info: { ... } } // parsed object
2096
+ * ```
2097
+ */
2098
+ type Input = string | Record<string, unknown>;
2099
+ /**
2100
+ * A post-generate step: a shell command string, or an object that pairs the command with a `name`
2101
+ * shown in the CLI output. Steps run in sequence after the generated files are formatted and linted.
2102
+ */
2103
+ type PostGenerateCommand = string | {
2104
+ name?: string;
2105
+ command: string;
2106
+ };
2107
+ /**
2108
+ * Resolved build configuration for a Kubb run: what to generate from (adapter, input), where to
2109
+ * write it (output), how (plugins), and the runtime pieces (parsers, storage). See
2110
+ * `UserConfig` for the relaxed form with defaults applied.
2111
+ *
2112
+ * @private
2113
+ */
2114
+ type Config<TInput = Input> = {
2115
+ /**
2116
+ * Display name for this configuration in CLI output and logs.
2117
+ * Useful when running multiple builds with `defineConfig` arrays.
2118
+ *
2119
+ * @example
2120
+ * ```ts
2121
+ * name: 'api-client'
2122
+ * ```
2123
+ */
2124
+ name?: string;
2125
+ /**
2126
+ * Project root directory, absolute or relative to the config file. Already
2127
+ * resolved on the `Config` instance (see `UserConfig` for the optional
2128
+ * form that defaults to `process.cwd()`).
2129
+ */
2130
+ root: string;
2131
+ /**
2132
+ * Parsers that convert generated files into strings. Each parser handles a
2133
+ * set of file extensions, and a fallback parser handles anything else.
2134
+ *
2135
+ * Already resolved on the `Config` instance (see `UserConfig` for the
2136
+ * optional form that defaults to `[parserTs(), parserTsx(), parserMd()]`).
2137
+ *
2138
+ * @example
2139
+ * ```ts
2140
+ * import { defineConfig } from 'kubb'
2141
+ * import { parserTs, parserTsx } from '@kubb/parser-ts'
2142
+ *
2143
+ * export default defineConfig({
2144
+ * parsers: [parserTs(), parserTsx()],
2145
+ * })
2146
+ * ```
2147
+ */
2148
+ parsers: Array<Parser>;
2149
+ /**
2150
+ * Adapter that parses input files into the universal AST representation.
2151
+ * Use `@kubb/adapter-oas` for OpenAPI/Swagger or `@kubb/adapter-asyncapi` for other formats.
2152
+ *
2153
+ * When omitted, Kubb runs in plugin-only mode: `kubb:plugin:setup` fires and files
2154
+ * injected via `injectFile` are written, but no AST walk occurs and generator hooks
2155
+ * (`kubb:generate:schema`, `kubb:generate:operation`) are never emitted.
2156
+ *
2157
+ * @example
2158
+ * ```ts
2159
+ * import { adapterOas } from '@kubb/adapter-oas'
2160
+ * export default defineConfig({
2161
+ * adapter: adapterOas(),
2162
+ * input: './petstore.yaml',
2163
+ * })
2164
+ * ```
2165
+ */
2166
+ adapter?: Adapter;
2167
+ /**
2168
+ * Source to generate code from: a local file path, a URL, inline OpenAPI content
2169
+ * (JSON or YAML string), or a parsed spec object. Kubb detects which one it was given.
2170
+ * Required when an adapter is configured. Omit it when running in plugin-only mode.
2171
+ */
2172
+ input?: TInput;
2173
+ output: {
2174
+ /**
2175
+ * Output directory for generated files, absolute or relative to `root`. Plugins can nest
2176
+ * subdirectories under it by grouping strategy (tag, path).
2177
+ *
2178
+ * @example
2179
+ * ```ts
2180
+ * output: {
2181
+ * path: './src/gen', // generates ./src/gen/api.ts, ./src/gen/types.ts, etc.
2182
+ * }
2183
+ * ```
2184
+ */
2185
+ path: string;
2186
+ /**
2187
+ * Remove every file in the output directory before the build, so stale output isn't mixed
2188
+ * with new files. Leave `false` to preserve manual edits in the output directory.
2189
+ *
2190
+ * @example
2191
+ * ```ts
2192
+ * clean: true // wipes ./src/gen/* before generating
2193
+ * ```
2194
+ */
2195
+ clean?: boolean;
2196
+ /**
2197
+ * Format the generated files after generation. `'auto'` runs the first formatter it finds
2198
+ * (oxfmt, biome, or prettier), a named tool forces that one, and `false` skips formatting.
2199
+ *
2200
+ * @example
2201
+ * ```ts
2202
+ * format: 'auto' // auto-detect oxfmt, biome, or prettier
2203
+ * format: 'prettier' // force prettier
2204
+ * format: false // skip formatting
2205
+ * ```
2206
+ */
2207
+ format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
2208
+ /**
2209
+ * Lint the generated files after generation. `'auto'` runs the first linter it finds
2210
+ * (oxlint, biome, or eslint), a named tool forces that one, and `false` skips linting.
2211
+ *
2212
+ * @example
2213
+ * ```ts
2214
+ * lint: 'auto' // auto-detect oxlint, biome, or eslint
2215
+ * lint: 'eslint' // force eslint
2216
+ * lint: false // skip linting
2217
+ * ```
2218
+ */
2219
+ lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
2220
+ /**
2221
+ * Shell commands to run after the generated files are formatted and linted, for post-processing
2222
+ * such as a type check or a custom script. Steps run in sequence from the `root` directory. Pass
2223
+ * a plain command string, or `{ name, command }` to label the step in the CLI output.
2224
+ *
2225
+ * @example
2226
+ * ```ts
2227
+ * postGenerate: ['npm run typecheck']
2228
+ * postGenerate: [{ name: 'types', command: 'npm run typecheck' }, 'biome check --write ./src/gen']
2229
+ * ```
2230
+ */
2231
+ postGenerate?: Array<PostGenerateCommand>;
2232
+ /**
2233
+ * Banner prepended to every generated file. `'simple'` is the basic Kubb notice, `'full'` adds
2234
+ * source, title, description, and API version, and `false` omits it.
2235
+ *
2236
+ * @default 'simple'
2237
+ * @example
2238
+ * ```ts
2239
+ * defaultBanner: 'simple' // "This file was autogenerated by Kubb"
2240
+ * defaultBanner: 'full' // adds source, title, description, API version
2241
+ * defaultBanner: false // no banner
2242
+ * ```
2243
+ */
2244
+ defaultBanner?: 'simple' | 'full' | false;
2245
+ } & ExtractRegistryKey<Kubb.ConfigOptionsRegistry, 'output'>;
2246
+ /**
2247
+ * Where generated files are persisted. Defaults to `fsStorage()` (disk). Pass `memoryStorage()`
2248
+ * to keep files in RAM, or implement `Storage` for a custom backend such as cloud or a database.
2249
+ *
2250
+ * @default fsStorage()
2251
+ * @example
2252
+ * ```ts
2253
+ * import { memoryStorage } from '@kubb/core'
2254
+ *
2255
+ * // Keep generated files in memory (useful for testing, CI pipelines)
2256
+ * storage: memoryStorage()
2257
+ *
2258
+ * // Use custom S3 storage
2259
+ * storage: myS3Storage()
2260
+ * ```
2261
+ *
2262
+ * @see {@link Storage} interface for implementing custom backends.
2263
+ */
2264
+ storage: Storage;
2265
+ /**
2266
+ * Plugins that run during the build to generate code and transform the AST. Each one processes
2267
+ * the adapter's AST and can emit files for a different target (TypeScript, Zod, Faker). A plugin
2268
+ * that depends on another throws when that plugin isn't registered.
2269
+ *
2270
+ * @example
2271
+ * ```ts
2272
+ * import { pluginTs } from '@kubb/plugin-ts'
2273
+ * import { pluginZod } from '@kubb/plugin-zod'
2274
+ *
2275
+ * plugins: [
2276
+ * pluginTs({ output: { path: './src/gen' } }),
2277
+ * pluginZod({ output: { path: './src/gen' } }),
2278
+ * ]
2279
+ * ```
2280
+ */
2281
+ plugins: Array<Plugin>;
2282
+ /**
2283
+ * The reporters available to the run, registered as instances. The host
2284
+ * (the CLI via `--reporter`) selects which ones to trigger by `name` with {@link selectReporters}.
2285
+ * `defineConfig` from the `kubb` package registers the built-in `cli`, `json`, and `file`
2286
+ * reporters by default.
2287
+ *
2288
+ * - `cli` writes the end-of-run summary to the terminal.
2289
+ * - `json` writes a machine-readable report to stdout, for CI.
2290
+ * - `file` writes a debug log to `.kubb/<name>-<timestamp>.log`.
2291
+ *
2292
+ * @example
2293
+ * ```ts
2294
+ * import { cliReporter, jsonReporter } from '@kubb/core'
2295
+ *
2296
+ * reporters: [cliReporter, jsonReporter, myReporter]
2297
+ * ```
2298
+ */
2299
+ reporters: Array<Reporter>;
2300
+ };
2301
+ /**
2302
+ * Partial `Config` for user-facing entry points with sensible defaults.
2303
+ *
2304
+ * `UserConfig` is what you pass to `defineConfig()`. It has optional `root`, `plugins`, `parsers`, and `adapter`
2305
+ * fields (which fall back to sensible defaults). All other Config options are available, including `output`, `input`,
2306
+ * `storage`, and `hooks`.
2307
+ *
2308
+ * @example
2309
+ * ```ts
2310
+ * export default defineConfig({
2311
+ * input: './petstore.yaml',
2312
+ * output: { path: './src/gen' },
2313
+ * plugins: [pluginTs(), pluginZod()],
2314
+ * })
2315
+ * ```
2316
+ */
2317
+ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage' | 'reporters'> & {
2318
+ /**
2319
+ * Project root directory, absolute or relative to the config file location.
2320
+ * @default process.cwd()
2321
+ */
2322
+ root?: string;
2323
+ /**
2324
+ * Custom parsers that convert generated AST nodes to strings (TypeScript, JSON, markdown, etc.).
2325
+ * @default [parserTs(), parserTsx(), parserMd()] // applied by `defineConfig` from the `kubb` package
2326
+ */
2327
+ parsers?: Array<Parser>;
2328
+ /**
2329
+ * Adapter that parses your API specification into Kubb's universal AST.
2330
+ * When omitted, Kubb runs in plugin-only mode.
2331
+ */
2332
+ adapter?: Adapter;
2333
+ /**
2334
+ * Plugins that execute during the build to generate code and transform the AST.
2335
+ * @default []
2336
+ */
2337
+ plugins?: Array<Plugin>;
2338
+ /**
2339
+ * Storage backend that controls where and how generated files are persisted.
2340
+ * @default fsStorage()
2341
+ */
2342
+ storage?: Storage;
2343
+ /**
2344
+ * Reporters available to the run. `defineConfig` registers the built-in `cli`, `json`, and
2345
+ * `file` reporters when omitted.
2346
+ * @default [cliReporter, jsonReporter, fileReporter] // applied by `defineConfig` from the `kubb` package
2347
+ */
2348
+ reporters?: Array<Reporter>;
2349
+ };
2350
+ declare global {
2351
+ namespace Kubb {
2352
+ /**
2353
+ * Registry that maps plugin names to their `PluginFactoryOptions`.
2354
+ * Augment this interface in each plugin's `types.ts` to enable automatic
2355
+ * typing for `getPlugin` and `requirePlugin`.
2356
+ *
2357
+ * @example
2358
+ * ```ts
2359
+ * // packages/plugin-ts/src/types.ts
2360
+ * declare global {
2361
+ * namespace Kubb {
2362
+ * interface PluginRegistry {
2363
+ * 'plugin-ts': PluginTs
2364
+ * }
2365
+ * }
2366
+ * }
2367
+ * ```
2368
+ */
2369
+ interface PluginRegistry {}
2370
+ /**
2371
+ * Extension point for root `Config['output']` options.
2372
+ * Augment the `output` key in plugin packages to add extra fields
2373
+ * to the global output configuration without touching core types.
2374
+ *
2375
+ * @example
2376
+ * ```ts
2377
+ * // packages/plugin-barrel/src/plugin.ts
2378
+ * declare global {
2379
+ * namespace Kubb {
2380
+ * interface ConfigOptionsRegistry {
2381
+ * output: {
2382
+ * barrel?: import('./types.ts').BarrelConfig | false
2383
+ * }
2384
+ * }
2385
+ * }
2386
+ * }
2387
+ * ```
2388
+ */
2389
+ interface ConfigOptionsRegistry {}
2390
+ /**
2391
+ * Extension point for per-plugin `Output` options.
2392
+ * Augment the `output` key in plugin packages to add extra fields
2393
+ * to the per-plugin output configuration without touching core types.
2394
+ *
2395
+ * @example
2396
+ * ```ts
2397
+ * // packages/plugin-barrel/src/plugin.ts
2398
+ * declare global {
2399
+ * namespace Kubb {
2400
+ * interface PluginOptionsRegistry {
2401
+ * output: {
2402
+ * barrel?: import('./types.ts').PluginBarrelConfig | false
2403
+ * }
2404
+ * }
2405
+ * }
2406
+ * }
2407
+ * ```
2408
+ */
2409
+ interface PluginOptionsRegistry {}
2410
+ }
2411
+ }
2412
+ /**
2413
+ * Lifecycle hooks emitted during Kubb code generation.
2414
+ * Attach listeners before calling `setup()` or `build()` to observe and react to build progress.
2415
+ *
2416
+ * @example
2417
+ * ```ts
2418
+ * kubb.hooks.hook('kubb:lifecycle:start', () => {
2419
+ * console.log('Starting Kubb generation')
2420
+ * })
2421
+ *
2422
+ * kubb.hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {
2423
+ * console.log(`${plugin.name} completed in ${duration}ms`)
2424
+ * })
2425
+ * ```
2426
+ */
2427
+ interface KubbHooks {
2428
+ 'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext];
2429
+ 'kubb:lifecycle:end': [];
2430
+ 'kubb:generation:start': [ctx: KubbGenerationStartContext];
2431
+ 'kubb:generation:end': [ctx: KubbGenerationEndContext];
2432
+ 'kubb:format:start': [];
2433
+ 'kubb:format:end': [];
2434
+ 'kubb:lint:start': [];
2435
+ 'kubb:lint:end': [];
2436
+ 'kubb:hooks:start': [];
2437
+ 'kubb:hooks:end': [];
2438
+ 'kubb:hook:start': [ctx: KubbHookStartContext];
2439
+ 'kubb:hook:line': [ctx: KubbHookLineContext];
2440
+ 'kubb:hook:end': [ctx: KubbHookEndContext];
2441
+ 'kubb:info': [ctx: KubbInfoContext];
2442
+ 'kubb:error': [ctx: KubbErrorContext];
2443
+ 'kubb:success': [ctx: KubbSuccessContext];
2444
+ 'kubb:warn': [ctx: KubbWarnContext];
2445
+ 'kubb:diagnostic': [ctx: KubbDiagnosticContext];
2446
+ 'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext];
2447
+ 'kubb:files:processing:update': [ctx: KubbFilesProcessingUpdateContext];
2448
+ 'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext];
2449
+ 'kubb:plugin:start': [ctx: KubbPluginStartContext];
2450
+ 'kubb:plugin:end': [ctx: KubbPluginEndContext];
2451
+ 'kubb:plugin:setup': [ctx: KubbPluginSetupContext];
2452
+ 'kubb:build:start': [ctx: KubbBuildStartContext];
2453
+ 'kubb:plugins:end': [ctx: KubbPluginsEndContext];
2454
+ 'kubb:build:end': [ctx: KubbBuildEndContext];
2455
+ 'kubb:generate:schema': [node: SchemaNode, ctx: GeneratorContext];
2456
+ 'kubb:generate:operation': [node: OperationNode, ctx: GeneratorContext];
2457
+ 'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext];
2458
+ }
2459
+ type KubbBuildStartContext = {
2460
+ /**
2461
+ * Resolved configuration for this build.
2462
+ */
2463
+ config: Config;
2464
+ /**
2465
+ * Adapter that parsed the input into the universal AST.
2466
+ */
2467
+ adapter: Adapter;
2468
+ /**
2469
+ * Metadata about the parsed document (title, version, base URL, circular schema names, enum names).
2470
+ * To observe individual schemas and operations use the `kubb:generate:schema` / `kubb:generate:operation` hooks.
2471
+ */
2472
+ meta: InputMeta | undefined;
2473
+ /**
2474
+ * Looks up a registered plugin by name, typed by the plugin registry.
2475
+ */
2476
+ getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined;
2477
+ getPlugin(name: string): Plugin | undefined;
2478
+ /**
2479
+ * Snapshot of all files accumulated so far.
2480
+ */
2481
+ readonly files: ReadonlyArray<FileNode>;
2482
+ /**
2483
+ * Adds or merges one or more files into the file manager.
2484
+ */
2485
+ upsertFile: (...files: Array<FileNode>) => void;
2486
+ };
2487
+ type KubbPluginsEndContext = {
2488
+ /**
2489
+ * Resolved configuration for this build.
2490
+ */
2491
+ config: Config;
2492
+ /**
2493
+ * Snapshot of all files accumulated across all plugins.
2494
+ */
2495
+ readonly files: ReadonlyArray<FileNode>;
2496
+ /**
2497
+ * Adds or merges one or more files into the file manager.
2498
+ */
2499
+ upsertFile: (...files: Array<FileNode>) => void;
2500
+ };
2501
+ type KubbBuildEndContext = {
2502
+ /**
2503
+ * All files generated during this build.
2504
+ */
2505
+ files: Array<FileNode>;
2506
+ /**
2507
+ * Resolved configuration for this build.
2508
+ */
2509
+ config: Config;
2510
+ /**
2511
+ * Absolute path to the output directory.
2512
+ */
2513
+ outputDir: string;
2514
+ };
2515
+ type KubbLifecycleStartContext = {
2516
+ /**
2517
+ * Current Kubb version string.
2518
+ */
2519
+ version: string;
2520
+ };
2521
+ type KubbGenerationStartContext = {
2522
+ /**
2523
+ * Resolved configuration for this generation run.
2524
+ */
2525
+ config: Config;
2526
+ };
2527
+ type KubbGenerationEndContext = {
2528
+ /**
2529
+ * Resolved configuration for this generation run.
2530
+ */
2531
+ config: Config;
2532
+ /**
2533
+ * Read-only view of the files written during this build.
2534
+ * Reads go directly to `config.storage`, nothing extra is held in memory.
2535
+ *
2536
+ * @example Read a generated file
2537
+ * `const code = await storage.getItem('/src/gen/pet.ts')`
2538
+ *
2539
+ * @example Walk every generated file
2540
+ * ```ts
2541
+ * for (const path of await storage.getKeys()) {
2542
+ * const code = await storage.getItem(path)
2543
+ * }
2544
+ * ```
2545
+ */
2546
+ storage: Storage;
2547
+ /**
2548
+ * Diagnostics collected during the build: error/warning/info problems plus a
2549
+ * `performance` diagnostic per plugin. The end-of-run summary derives its failure counts
2550
+ * and per-plugin timings from these. Set by the CLI runner, omitted by other callers.
2551
+ */
2552
+ diagnostics?: Array<Diagnostic>;
2553
+ /**
2554
+ * `'success'` when all plugins completed without errors, `'failed'` otherwise.
2555
+ */
2556
+ status?: 'success' | 'failed';
2557
+ /**
2558
+ * High-resolution start time from `process.hrtime()`, used to compute the elapsed time.
2559
+ */
2560
+ hrStart?: [number, number];
2561
+ /**
2562
+ * Total number of files created during this run.
2563
+ */
2564
+ filesCreated?: number;
2565
+ };
2566
+ type KubbInfoContext = {
2567
+ /**
2568
+ * Human-readable info message.
2569
+ */
2570
+ message: string;
2571
+ /**
2572
+ * Optional supplementary detail.
2573
+ */
2574
+ info?: string;
2575
+ };
2576
+ type KubbErrorContext = {
2577
+ /**
2578
+ * The caught error.
2579
+ */
2580
+ error: Error;
2581
+ /**
2582
+ * Optional structured metadata for additional context.
2583
+ */
2584
+ meta?: Record<string, unknown>;
2585
+ };
2586
+ type KubbSuccessContext = {
2587
+ /**
2588
+ * Human-readable success message.
2589
+ */
2590
+ message: string;
2591
+ /**
2592
+ * Optional supplementary detail.
2593
+ */
2594
+ info?: string;
2595
+ };
2596
+ type KubbWarnContext = {
2597
+ /**
2598
+ * Human-readable warning message.
2599
+ */
2600
+ message: string;
2601
+ /**
2602
+ * Optional supplementary detail.
2603
+ */
2604
+ info?: string;
2605
+ };
2606
+ type KubbDiagnosticContext = {
2607
+ /**
2608
+ * The structured diagnostic to render: a build problem or a version-update notice.
2609
+ */
2610
+ diagnostic: ProblemDiagnostic | UpdateDiagnostic;
2611
+ };
2612
+ type KubbFilesProcessingStartContext = {
2613
+ /**
2614
+ * Files about to be serialized and written.
2615
+ */
2616
+ files: Array<FileNode>;
2617
+ };
2618
+ type KubbFileProcessingUpdate = {
2619
+ /**
2620
+ * Number of files processed so far in this batch.
2621
+ */
2622
+ processed: number;
2623
+ /**
2624
+ * Total number of files in this batch.
2625
+ */
2626
+ total: number;
2627
+ /**
2628
+ * Completion percentage, `0` to `100`.
2629
+ */
2630
+ percentage: number;
2631
+ /**
2632
+ * Serialized file content, or `undefined` when the file produced no output.
2633
+ */
2634
+ source?: string;
2635
+ /**
2636
+ * The file that was just processed.
2637
+ */
2638
+ file: FileNode;
2639
+ /**
2640
+ * Resolved configuration for this build.
2641
+ */
2642
+ config: Config;
2643
+ };
2644
+ type KubbFilesProcessingUpdateContext = {
2645
+ /**
2646
+ * All files processed in this flush chunk.
2647
+ */
2648
+ files: Array<KubbFileProcessingUpdate>;
2649
+ };
2650
+ type KubbFilesProcessingEndContext = {
2651
+ /**
2652
+ * All files that were serialized in this batch.
2653
+ */
2654
+ files: Array<FileNode>;
2655
+ };
2656
+ type KubbHookStartContext = {
2657
+ /**
2658
+ * Optional identifier for correlating start/end hooks.
2659
+ */
2660
+ id?: string;
2661
+ /**
2662
+ * The shell command that is about to run.
2663
+ */
2664
+ command: string;
2665
+ /**
2666
+ * Optional label for the command, shown in the CLI output when set.
2667
+ */
2668
+ name?: string;
2669
+ /**
2670
+ * Parsed argument list, when available.
2671
+ */
2672
+ args?: ReadonlyArray<string>;
2673
+ };
2674
+ /**
2675
+ * Emitted for each line streamed from a hook's stdout while it runs.
2676
+ * A logger correlates the line to its active UI element via `id`.
2677
+ */
2678
+ type KubbHookLineContext = {
2679
+ /**
2680
+ * Identifier matching the corresponding `kubb:hook:start` hook.
2681
+ */
2682
+ id: string;
2683
+ /**
2684
+ * A single streamed stdout line, without its trailing newline.
2685
+ */
2686
+ line: string;
2687
+ };
2688
+ type KubbHookEndContext = {
2689
+ /**
2690
+ * Optional identifier matching the corresponding `kubb:hook:start` hook.
2691
+ */
2692
+ id?: string;
2693
+ /**
2694
+ * The shell command that ran.
2695
+ */
2696
+ command: string;
2697
+ /**
2698
+ * Optional label for the command, shown in the CLI output when set.
2699
+ */
2700
+ name?: string;
2701
+ /**
2702
+ * Parsed argument list, when available.
2703
+ */
2704
+ args?: ReadonlyArray<string>;
2705
+ /**
2706
+ * `true` when the command exited with code `0`.
2707
+ */
2708
+ success: boolean;
2709
+ /**
2710
+ * Error thrown by the command, or `null` on success.
2711
+ */
2712
+ error: Error | null;
2713
+ /**
2714
+ * Captured stdout from the process, populated when it exits non-zero.
2715
+ */
2716
+ stdout?: string;
2717
+ /**
2718
+ * Captured stderr from the process, populated when it exits non-zero.
2719
+ */
2720
+ stderr?: string;
2721
+ };
2722
+ /**
2723
+ * CLI options derived from command-line flags.
2724
+ */
2725
+ type CLIOptions = {
2726
+ /**
2727
+ * Path to the Kubb config file.
2728
+ */
2729
+ config?: string;
2730
+ /**
2731
+ * OpenAPI input path or URL passed as the positional argument to `kubb generate`.
2732
+ * Overrides `config.input` when set.
2733
+ */
2734
+ input?: string;
2735
+ /**
2736
+ * Re-run generation whenever input files change.
2737
+ */
2738
+ watch?: boolean;
2739
+ /**
2740
+ * Controls how much output the CLI prints.
2741
+ *
2742
+ * @default 'info'
2743
+ */
2744
+ logLevel?: 'silent' | 'info' | 'verbose';
2745
+ /**
2746
+ * Reporters selected on the CLI via `--reporter`, overriding `config.reporters`.
2747
+ */
2748
+ reporters?: Array<ReporterName>;
2749
+ };
2750
+ /**
2751
+ * All accepted forms of a Kubb configuration.
2752
+ * Accepts `Config`/`Config[]`/promise or a factory (optionally receiving `TCliOptions`).
2753
+ */
2754
+ type PossibleConfig<TCliOptions = undefined> = PossiblePromise<Config | Array<Config>> | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Array<Config>>);
2755
+ /**
2756
+ * Full output produced by a successful or failed build.
2757
+ */
2758
+ type BuildOutput = {
2759
+ /**
2760
+ * Structured diagnostics collected during the build: error/warning/info problems
2761
+ * (each with a code, severity, and where known a JSON-pointer location) plus a
2762
+ * `performance` diagnostic per plugin. Includes a top-level diagnostic when the build
2763
+ * threw before completing. Use {@link Diagnostics.hasError} to test for failure.
2764
+ */
2765
+ diagnostics: Array<Diagnostic>;
2766
+ /**
2767
+ * All files generated during this build.
2768
+ */
2769
+ files: Array<FileNode>;
2770
+ /**
2771
+ * The plugin driver that orchestrated this build.
2772
+ */
2773
+ driver: KubbDriver;
2774
+ /**
2775
+ * The configured `Storage` backend, for reading back a generated file's final content.
2776
+ * Use `files` to list what this build produced.
2777
+ *
2778
+ * @example Read a generated file
2779
+ * `const code = await buildOutput.storage.getItem('/src/gen/pet.ts')`
2780
+ */
2781
+ storage: Storage;
2782
+ };
2783
+ //#endregion
2784
+ export { ResolveBannerContext as $, Generator as A, ProblemCode as At, Include as B, KubbWarnContext as C, Diagnostic as Ct, CreateKubbOptions as D, DiagnosticSeverity as Dt, UserConfig as E, DiagnosticLocation as Et, Parser as F, Adapter as Ft, Output as G, KubbPluginSetupContext as H, defineParser as I, AdapterFactoryOptions as It, Override as J, OutputMode as K, Exclude$1 as L, AdapterSource as Lt, defineGenerator as M, SerializedDiagnostic as Mt, KubbDriver as N, UpdateDiagnostic as Nt, Kubb$1 as O, Diagnostics as Ot, FileManagerHooks as P, Hookable as Pt, BannerMeta as Q, Filter as R, createAdapter as Rt, KubbSuccessContext as S, logLevel as St, PostGenerateCommand as T, DiagnosticKind as Tt, KubbPluginStartContext as U, KubbPluginEndContext as V, NormalizedPlugin as W, PluginFactoryOptions as X, Plugin as Y, definePlugin as Z, KubbHookStartContext as _, Reporter as _t, KubbBuildEndContext as a, ResolverDefault as at, KubbLifecycleStartContext as b, UserReporter as bt, KubbErrorContext as c, ResolverFilePathParams as ct, KubbFilesProcessingStartContext as d, Renderer as dt, ResolveBannerFile as et, KubbFilesProcessingUpdateContext as f, RendererFactory as ft, KubbHookLineContext as g, GenerationResult as gt, KubbHookEndContext as h, createStorage as ht, Input as i, Resolver as it, GeneratorContext as j, ProblemDiagnostic as jt, createKubb as k, PerformanceDiagnostic as kt, KubbFileProcessingUpdate as l, ResolverPatch as lt, KubbGenerationStartContext as m, Storage as mt, CLIOptions as n, ResolveOptionsContext as nt, KubbBuildStartContext as o, ResolverFile as ot, KubbGenerationEndContext as p, createRenderer as pt, OutputOptions as q, Config as r, ResolvePathOptions as rt, KubbDiagnosticContext as s, ResolverFileParams as st, BuildOutput as t, ResolveFileOptions as tt, KubbFilesProcessingEndContext as u, ResolverPathParams as ut, KubbHooks as v, ReporterContext as vt, PossibleConfig as w, DiagnosticDoc as wt, KubbPluginsEndContext as x, createReporter as xt, KubbInfoContext as y, ReporterName as yt, Group as z };
2785
+ //# sourceMappingURL=types-BLFyAJLZ.d.ts.map