@kubb/core 5.10.1 → 5.10.3

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