@kubb/core 5.0.0-beta.62 → 5.0.0-beta.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{diagnostics-D0G07LHG.d.ts → diagnostics-BqiNAWVS.d.ts} +47 -40
  2. package/dist/index.cjs +47 -52
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +7 -8
  5. package/dist/index.js +49 -54
  6. package/dist/index.js.map +1 -1
  7. package/dist/{memoryStorage-CWFzAz4o.js → memoryStorage-DWnhqUf2.js} +3 -3
  8. package/dist/memoryStorage-DWnhqUf2.js.map +1 -0
  9. package/dist/{memoryStorage-CUj1hrxa.cjs → memoryStorage-mojU6pbA.cjs} +2 -2
  10. package/dist/memoryStorage-mojU6pbA.cjs.map +1 -0
  11. package/dist/mocks.cjs +2 -2
  12. package/dist/mocks.cjs.map +1 -1
  13. package/dist/mocks.d.ts +3 -3
  14. package/dist/mocks.js +3 -3
  15. package/dist/mocks.js.map +1 -1
  16. package/package.json +4 -5
  17. package/dist/memoryStorage-CUj1hrxa.cjs.map +0 -1
  18. package/dist/memoryStorage-CWFzAz4o.js.map +0 -1
  19. package/src/FileManager.ts +0 -137
  20. package/src/FileProcessor.ts +0 -212
  21. package/src/KubbDriver.ts +0 -893
  22. package/src/Transform.ts +0 -105
  23. package/src/constants.ts +0 -126
  24. package/src/createAdapter.ts +0 -127
  25. package/src/createKubb.ts +0 -196
  26. package/src/createRenderer.ts +0 -72
  27. package/src/createReporter.ts +0 -134
  28. package/src/createStorage.ts +0 -83
  29. package/src/defineGenerator.ts +0 -210
  30. package/src/defineParser.ts +0 -62
  31. package/src/definePlugin.ts +0 -437
  32. package/src/defineResolver.ts +0 -711
  33. package/src/diagnostics.ts +0 -662
  34. package/src/index.ts +0 -20
  35. package/src/mocks.ts +0 -249
  36. package/src/reporters/cliReporter.ts +0 -89
  37. package/src/reporters/fileReporter.ts +0 -103
  38. package/src/reporters/jsonReporter.ts +0 -20
  39. package/src/reporters/report.ts +0 -85
  40. package/src/storages/fsStorage.ts +0 -82
  41. package/src/storages/memoryStorage.ts +0 -55
  42. package/src/types.ts +0 -829
  43. /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/src/types.ts DELETED
@@ -1,829 +0,0 @@
1
- import type { PossiblePromise } from '@internals/utils'
2
- import type { FileNode, InputMeta, OperationNode, SchemaNode } from '@kubb/ast'
3
- import type { Adapter } from './createAdapter.ts'
4
- import type { Reporter, ReporterName } from './createReporter.ts'
5
- import type { Storage } from './createStorage.ts'
6
- import type { Diagnostic, ProblemDiagnostic, UpdateDiagnostic } from './diagnostics.ts'
7
- import type { GeneratorContext } from './defineGenerator.ts'
8
- import type { Parser } from './defineParser.ts'
9
- import type { KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Plugin } from './definePlugin.ts'
10
- import type { KubbDriver } from './KubbDriver.ts'
11
-
12
- /**
13
- * Extracts a type from a registry, falling back to `{}` when the key doesn't exist.
14
- * Lets plugins augment `Kubb.ConfigOptionsRegistry` and `Kubb.PluginOptionsRegistry`
15
- * without changing core.
16
- *
17
- * @internal
18
- */
19
- type ExtractRegistryKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : {}
20
-
21
- /**
22
- * Path to an input file to generate from, absolute or relative to the config file. The adapter
23
- * parses it (e.g. an OpenAPI YAML or JSON spec) into the universal AST.
24
- */
25
- export type InputPath = {
26
- /**
27
- * Path to your Swagger/OpenAPI file, absolute or relative to the config file location.
28
- *
29
- * @example
30
- * ```ts
31
- * { path: './petstore.yaml' }
32
- * { path: '/absolute/path/to/openapi.json' }
33
- * ```
34
- */
35
- path: string
36
- }
37
-
38
- /**
39
- * Inline spec to generate from, passed directly instead of read from a file. A string
40
- * (YAML/JSON) or a parsed object.
41
- */
42
- export type InputData = {
43
- /**
44
- * Swagger/OpenAPI data as a string (YAML/JSON) or a parsed object.
45
- *
46
- * @example
47
- * ```ts
48
- * { data: fs.readFileSync('./openapi.yaml', 'utf8') }
49
- * { data: { openapi: '3.1.0', info: { ... } } }
50
- * ```
51
- */
52
- data: string | unknown
53
- }
54
-
55
- type Input = InputPath | InputData
56
-
57
- /**
58
- * Resolved build configuration for a Kubb run: what to generate from (adapter, input), where to
59
- * write it (output), how (plugins), and the runtime pieces (parsers, storage). See
60
- * `UserConfig` for the relaxed form with defaults applied.
61
- *
62
- * @private
63
- */
64
- export type Config<TInput = Input> = {
65
- /**
66
- * Display name for this configuration in CLI output and logs.
67
- * Useful when running multiple builds with `defineConfig` arrays.
68
- *
69
- * @example
70
- * ```ts
71
- * name: 'api-client'
72
- * ```
73
- */
74
- name?: string
75
- /**
76
- * Project root directory, absolute or relative to the config file. Already
77
- * resolved on the `Config` instance (see `UserConfig` for the optional
78
- * form that defaults to `process.cwd()`).
79
- */
80
- root: string
81
- /**
82
- * Parsers that convert generated files into strings. Each parser handles a
83
- * set of file extensions, and a fallback parser handles anything else.
84
- *
85
- * Already resolved on the `Config` instance (see `UserConfig` for the
86
- * optional form that defaults to `[parserTs, parserTsx, parserMd]`).
87
- *
88
- * @example
89
- * ```ts
90
- * import { defineConfig } from 'kubb'
91
- * import { parserTs, parserTsx } from '@kubb/parser-ts'
92
- *
93
- * export default defineConfig({
94
- * parsers: [parserTs, parserTsx],
95
- * })
96
- * ```
97
- */
98
- parsers: Array<Parser>
99
- /**
100
- * Adapter that parses input files into the universal AST representation.
101
- * Use `@kubb/adapter-oas` for OpenAPI/Swagger or `@kubb/adapter-asyncapi` for other formats.
102
- *
103
- * When omitted, Kubb runs in plugin-only mode: `kubb:plugin:setup` fires and files
104
- * injected via `injectFile` are written, but no AST walk occurs and generator hooks
105
- * (`kubb:generate:schema`, `kubb:generate:operation`) are never emitted.
106
- *
107
- * @example
108
- * ```ts
109
- * import { adapterOas } from '@kubb/adapter-oas'
110
- * export default defineConfig({
111
- * adapter: adapterOas(),
112
- * input: { path: './petstore.yaml' },
113
- * })
114
- * ```
115
- */
116
- adapter?: Adapter
117
- /**
118
- * Source file or data to generate code from.
119
- * Use `input.path` for a file path or `input.data` for inline data.
120
- * Required when an adapter is configured. Omit it when running in plugin-only mode.
121
- */
122
- input?: TInput
123
- output: {
124
- /**
125
- * Output directory for generated files, absolute or relative to `root`. Plugins can nest
126
- * subdirectories under it by grouping strategy (tag, path).
127
- *
128
- * @example
129
- * ```ts
130
- * output: {
131
- * path: './src/gen', // generates ./src/gen/api.ts, ./src/gen/types.ts, etc.
132
- * }
133
- * ```
134
- */
135
- path: string
136
- /**
137
- * Remove every file in the output directory before the build, so stale output isn't mixed
138
- * with new files. Leave `false` to preserve manual edits in the output directory.
139
- *
140
- * @example
141
- * ```ts
142
- * clean: true // wipes ./src/gen/* before generating
143
- * ```
144
- */
145
- clean?: boolean
146
- /**
147
- * Format the generated files after generation. `'auto'` runs the first formatter it finds
148
- * (oxfmt, biome, or prettier), a named tool forces that one, and `false` skips formatting.
149
- *
150
- * @example
151
- * ```ts
152
- * format: 'auto' // auto-detect prettier, biome, or oxfmt
153
- * format: 'prettier' // force prettier
154
- * format: false // skip formatting
155
- * ```
156
- */
157
- format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false
158
- /**
159
- * Lint the generated files after generation. `'auto'` runs the first linter it finds
160
- * (oxlint, biome, or eslint), a named tool forces that one, and `false` skips linting.
161
- *
162
- * @example
163
- * ```ts
164
- * lint: 'auto' // auto-detect oxlint, biome, or eslint
165
- * lint: 'eslint' // force eslint
166
- * lint: false // skip linting
167
- * ```
168
- */
169
- lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false
170
- /**
171
- * Rewrite import extensions in generated files, e.g. emit `.js` imports from `.ts` sources for
172
- * ESM dual packages. Keys are the source extension, values the output, and `''` drops it.
173
- *
174
- * @default { '.ts': '.ts' }
175
- * @example
176
- * ```ts
177
- * extension: { '.ts': '.js' } // generates import './api.js' instead of './api.ts'
178
- * extension: { '.ts': '', '.tsx': '.jsx' }
179
- * ```
180
- */
181
- extension?: Record<FileNode['extname'], FileNode['extname'] | ''>
182
- /**
183
- * Banner prepended to every generated file. `'simple'` is the basic Kubb notice, `'full'` adds
184
- * source, title, description, and API version, and `false` omits it.
185
- *
186
- * @default 'simple'
187
- * @example
188
- * ```ts
189
- * defaultBanner: 'simple' // "This file was autogenerated by Kubb"
190
- * defaultBanner: 'full' // adds source, title, description, API version
191
- * defaultBanner: false // no banner
192
- * ```
193
- */
194
- defaultBanner?: 'simple' | 'full' | false
195
- /**
196
- * Overwrite existing files when `true`, skip files that already exist when `false`. Individual
197
- * plugins can override it. Keep `false` to avoid clobbering local edits in the output folder.
198
- *
199
- * @example
200
- * ```ts
201
- * override: true // regenerate everything, even existing files
202
- * override: false // skip files that already exist
203
- * ```
204
- */
205
- override?: boolean
206
- } & ExtractRegistryKey<Kubb.ConfigOptionsRegistry, 'output'>
207
- /**
208
- * Where generated files are persisted. Defaults to `fsStorage()` (disk). Pass `memoryStorage()`
209
- * to keep files in RAM, or implement `Storage` for a custom backend such as cloud or a database.
210
- *
211
- * @default fsStorage()
212
- * @example
213
- * ```ts
214
- * import { memoryStorage } from '@kubb/core'
215
- *
216
- * // Keep generated files in memory (useful for testing, CI pipelines)
217
- * storage: memoryStorage()
218
- *
219
- * // Use custom S3 storage
220
- * storage: myS3Storage()
221
- * ```
222
- *
223
- * @see {@link Storage} interface for implementing custom backends.
224
- */
225
- storage: Storage
226
- /**
227
- * Plugins that run during the build to generate code and transform the AST. Each one processes
228
- * the adapter's AST and can emit files for a different target (TypeScript, Zod, Faker). A plugin
229
- * that depends on another throws when that plugin isn't registered.
230
- *
231
- * @example
232
- * ```ts
233
- * import { pluginTs } from '@kubb/plugin-ts'
234
- * import { pluginZod } from '@kubb/plugin-zod'
235
- *
236
- * plugins: [
237
- * pluginTs({ output: { path: './src/gen' } }),
238
- * pluginZod({ output: { path: './src/gen' } }),
239
- * ]
240
- * ```
241
- */
242
- plugins: Array<Plugin>
243
- /**
244
- * Lifecycle hooks that run external tools (prettier, eslint, a custom script) on build events.
245
- *
246
- * Currently supports the `done` hook, which fires after all plugins complete.
247
- *
248
- * @example
249
- * ```ts
250
- * hooks: {
251
- * done: 'prettier --write "./src/gen"', // auto-format generated files
252
- * // or multiple commands:
253
- * done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
254
- * }
255
- * ```
256
- */
257
- hooks?: {
258
- /**
259
- * Command(s) to run after all plugins finish generating, for post-processing the output.
260
- *
261
- * Pass a single command string, or an array to run them in sequence.
262
- * Commands run relative to the `root` directory.
263
- *
264
- * @example
265
- * ```ts
266
- * done: 'prettier --write "./src/gen"'
267
- * done: ['prettier --write "./src/gen"', 'eslint --fix "./src/gen"']
268
- * ```
269
- */
270
- done?: string | Array<string>
271
- }
272
- /**
273
- * The reporters available to the run, registered as instances. The host
274
- * (the CLI via `--reporter`) selects which ones to trigger by `name` with {@link selectReporters}.
275
- * `defineConfig` from the `kubb` package registers the built-in `cli`, `json`, and `file`
276
- * reporters by default.
277
- *
278
- * - `cli` writes the end-of-run summary to the terminal.
279
- * - `json` writes a machine-readable report to stdout, for CI.
280
- * - `file` writes a debug log to `.kubb/<name>-<timestamp>.log`.
281
- *
282
- * @example
283
- * ```ts
284
- * import { cliReporter, jsonReporter } from '@kubb/core'
285
- *
286
- * reporters: [cliReporter, jsonReporter, myReporter]
287
- * ```
288
- */
289
- reporters: Array<Reporter>
290
- }
291
-
292
- /**
293
- * Partial `Config` for user-facing entry points with sensible defaults.
294
- *
295
- * `UserConfig` is what you pass to `defineConfig()`. It has optional `root`, `plugins`, `parsers`, and `adapter`
296
- * fields (which fall back to sensible defaults). All other Config options are available, including `output`, `input`,
297
- * `storage`, and `hooks`.
298
- *
299
- * @example
300
- * ```ts
301
- * export default defineConfig({
302
- * input: { path: './petstore.yaml' },
303
- * output: { path: './src/gen' },
304
- * plugins: [pluginTs(), pluginZod()],
305
- * })
306
- * ```
307
- */
308
- export type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage' | 'reporters'> & {
309
- /**
310
- * Project root directory, absolute or relative to the config file location.
311
- * @default process.cwd()
312
- */
313
- root?: string
314
- /**
315
- * Custom parsers that convert generated AST nodes to strings (TypeScript, JSON, markdown, etc.).
316
- * @default [parserTs, parserTsx, parserMd] // applied by `defineConfig` from the `kubb` package
317
- */
318
- parsers?: Array<Parser>
319
- /**
320
- * Adapter that parses your API specification into Kubb's universal AST.
321
- * When omitted, Kubb runs in plugin-only mode.
322
- */
323
- adapter?: Adapter
324
- /**
325
- * Plugins that execute during the build to generate code and transform the AST.
326
- * @default []
327
- */
328
- plugins?: Array<Plugin>
329
- /**
330
- * Storage backend that controls where and how generated files are persisted.
331
- * @default fsStorage()
332
- */
333
- storage?: Storage
334
- /**
335
- * Reporters available to the run. `defineConfig` registers the built-in `cli`, `json`, and
336
- * `file` reporters when omitted.
337
- * @default [cliReporter, jsonReporter, fileReporter] // applied by `defineConfig` from the `kubb` package
338
- */
339
- reporters?: Array<Reporter>
340
- }
341
-
342
- declare global {
343
- namespace Kubb {
344
- /**
345
- * Registry that maps plugin names to their `PluginFactoryOptions`.
346
- * Augment this interface in each plugin's `types.ts` to enable automatic
347
- * typing for `getPlugin` and `requirePlugin`.
348
- *
349
- * @example
350
- * ```ts
351
- * // packages/plugin-ts/src/types.ts
352
- * declare global {
353
- * namespace Kubb {
354
- * interface PluginRegistry {
355
- * 'plugin-ts': PluginTs
356
- * }
357
- * }
358
- * }
359
- * ```
360
- */
361
- interface PluginRegistry {}
362
-
363
- /**
364
- * Extension point for root `Config['output']` options.
365
- * Augment the `output` key in plugin packages to add extra fields
366
- * to the global output configuration without touching core types.
367
- *
368
- * @example
369
- * ```ts
370
- * // packages/plugin-barrel/src/plugin.ts
371
- * declare global {
372
- * namespace Kubb {
373
- * interface ConfigOptionsRegistry {
374
- * output: {
375
- * barrel?: import('./types.ts').BarrelConfig | false
376
- * }
377
- * }
378
- * }
379
- * }
380
- * ```
381
- */
382
- interface ConfigOptionsRegistry {}
383
-
384
- /**
385
- * Extension point for per-plugin `Output` options.
386
- * Augment the `output` key in plugin packages to add extra fields
387
- * to the per-plugin output configuration without touching core types.
388
- *
389
- * @example
390
- * ```ts
391
- * // packages/plugin-barrel/src/plugin.ts
392
- * declare global {
393
- * namespace Kubb {
394
- * interface PluginOptionsRegistry {
395
- * output: {
396
- * barrel?: import('./types.ts').PluginBarrelConfig | false
397
- * }
398
- * }
399
- * }
400
- * }
401
- * ```
402
- */
403
- interface PluginOptionsRegistry {}
404
- }
405
- }
406
-
407
- /**
408
- * Lifecycle events emitted during Kubb code generation.
409
- * Attach listeners before calling `setup()` or `build()` to observe and react to build progress.
410
- *
411
- * @example
412
- * ```ts
413
- * kubb.hooks.on('kubb:lifecycle:start', () => {
414
- * console.log('Starting Kubb generation')
415
- * })
416
- *
417
- * kubb.hooks.on('kubb:plugin:end', ({ plugin, duration }) => {
418
- * console.log(`${plugin.name} completed in ${duration}ms`)
419
- * })
420
- * ```
421
- */
422
- export interface KubbHooks {
423
- 'kubb:lifecycle:start': [ctx: KubbLifecycleStartContext]
424
- 'kubb:lifecycle:end': []
425
- 'kubb:generation:start': [ctx: KubbGenerationStartContext]
426
- 'kubb:generation:end': [ctx: KubbGenerationEndContext]
427
- 'kubb:format:start': []
428
- 'kubb:format:end': []
429
- 'kubb:lint:start': []
430
- 'kubb:lint:end': []
431
- 'kubb:hooks:start': []
432
- 'kubb:hooks:end': []
433
- 'kubb:hook:start': [ctx: KubbHookStartContext]
434
- 'kubb:hook:line': [ctx: KubbHookLineContext]
435
- 'kubb:hook:end': [ctx: KubbHookEndContext]
436
- 'kubb:info': [ctx: KubbInfoContext]
437
- 'kubb:error': [ctx: KubbErrorContext]
438
- 'kubb:success': [ctx: KubbSuccessContext]
439
- 'kubb:warn': [ctx: KubbWarnContext]
440
- 'kubb:diagnostic': [ctx: KubbDiagnosticContext]
441
- 'kubb:files:processing:start': [ctx: KubbFilesProcessingStartContext]
442
- 'kubb:files:processing:update': [ctx: KubbFilesProcessingUpdateContext]
443
- 'kubb:files:processing:end': [ctx: KubbFilesProcessingEndContext]
444
- 'kubb:plugin:start': [ctx: KubbPluginStartContext]
445
- 'kubb:plugin:end': [ctx: KubbPluginEndContext]
446
- 'kubb:plugin:setup': [ctx: KubbPluginSetupContext]
447
- 'kubb:build:start': [ctx: KubbBuildStartContext]
448
- 'kubb:plugins:end': [ctx: KubbPluginsEndContext]
449
- 'kubb:build:end': [ctx: KubbBuildEndContext]
450
- 'kubb:generate:schema': [node: SchemaNode, ctx: GeneratorContext]
451
- 'kubb:generate:operation': [node: OperationNode, ctx: GeneratorContext]
452
- 'kubb:generate:operations': [nodes: Array<OperationNode>, ctx: GeneratorContext]
453
- }
454
-
455
- export type KubbBuildStartContext = {
456
- /**
457
- * Resolved configuration for this build.
458
- */
459
- config: Config
460
- /**
461
- * Adapter that parsed the input into the universal AST.
462
- */
463
- adapter: Adapter
464
- /**
465
- * Metadata about the parsed document (title, version, base URL, circular schema names, enum names).
466
- * To observe individual schemas and operations use the `kubb:generate:schema` / `kubb:generate:operation` hooks.
467
- */
468
- meta: InputMeta | undefined
469
- /**
470
- * Looks up a registered plugin by name, typed by the plugin registry.
471
- */
472
- getPlugin<TName extends keyof Kubb.PluginRegistry>(name: TName): Plugin<Kubb.PluginRegistry[TName]> | undefined
473
- getPlugin(name: string): Plugin | undefined
474
- /**
475
- * Snapshot of all files accumulated so far.
476
- */
477
- readonly files: ReadonlyArray<FileNode>
478
- /**
479
- * Adds or merges one or more files into the file manager.
480
- */
481
- upsertFile: (...files: Array<FileNode>) => void
482
- }
483
-
484
- export type KubbPluginsEndContext = {
485
- /**
486
- * Resolved configuration for this build.
487
- */
488
- config: Config
489
- /**
490
- * Snapshot of all files accumulated across all plugins.
491
- */
492
- readonly files: ReadonlyArray<FileNode>
493
- /**
494
- * Adds or merges one or more files into the file manager.
495
- */
496
- upsertFile: (...files: Array<FileNode>) => void
497
- }
498
-
499
- export type KubbBuildEndContext = {
500
- /**
501
- * All files generated during this build.
502
- */
503
- files: Array<FileNode>
504
- /**
505
- * Resolved configuration for this build.
506
- */
507
- config: Config
508
- /**
509
- * Absolute path to the output directory.
510
- */
511
- outputDir: string
512
- }
513
-
514
- export type KubbLifecycleStartContext = {
515
- /**
516
- * Current Kubb version string.
517
- */
518
- version: string
519
- }
520
-
521
- export type KubbGenerationStartContext = {
522
- /**
523
- * Resolved configuration for this generation run.
524
- */
525
- config: Config
526
- }
527
-
528
- export type KubbGenerationEndContext = {
529
- /**
530
- * Resolved configuration for this generation run.
531
- */
532
- config: Config
533
- /**
534
- * Read-only view of the files written during this build.
535
- * Reads go directly to `config.storage`, nothing extra is held in memory.
536
- *
537
- * @example Read a generated file
538
- * `const code = await storage.getItem('/src/gen/pet.ts')`
539
- *
540
- * @example Walk every generated file
541
- * ```ts
542
- * for (const path of await storage.getKeys()) {
543
- * const code = await storage.getItem(path)
544
- * }
545
- * ```
546
- */
547
- storage: Storage
548
- /**
549
- * Diagnostics collected during the build: error/warning/info problems plus a
550
- * `performance` diagnostic per plugin. The end-of-run summary derives its failure counts
551
- * and per-plugin timings from these. Set by the CLI runner, omitted by other callers.
552
- */
553
- diagnostics?: Array<Diagnostic>
554
- /**
555
- * `'success'` when all plugins completed without errors, `'failed'` otherwise.
556
- */
557
- status?: 'success' | 'failed'
558
- /**
559
- * High-resolution start time from `process.hrtime()`, used to compute the elapsed time.
560
- */
561
- hrStart?: [number, number]
562
- /**
563
- * Total number of files created during this run.
564
- */
565
- filesCreated?: number
566
- }
567
-
568
- export type KubbInfoContext = {
569
- /**
570
- * Human-readable info message.
571
- */
572
- message: string
573
- /**
574
- * Optional supplementary detail.
575
- */
576
- info?: string
577
- }
578
-
579
- export type KubbErrorContext = {
580
- /**
581
- * The caught error.
582
- */
583
- error: Error
584
- /**
585
- * Optional structured metadata for additional context.
586
- */
587
- meta?: Record<string, unknown>
588
- }
589
-
590
- export type KubbSuccessContext = {
591
- /**
592
- * Human-readable success message.
593
- */
594
- message: string
595
- /**
596
- * Optional supplementary detail.
597
- */
598
- info?: string
599
- }
600
-
601
- export type KubbWarnContext = {
602
- /**
603
- * Human-readable warning message.
604
- */
605
- message: string
606
- /**
607
- * Optional supplementary detail.
608
- */
609
- info?: string
610
- }
611
-
612
- export type KubbDiagnosticContext = {
613
- /**
614
- * The structured diagnostic to render: a build problem or a version-update notice.
615
- */
616
- diagnostic: ProblemDiagnostic | UpdateDiagnostic
617
- }
618
-
619
- export type KubbFilesProcessingStartContext = {
620
- /**
621
- * Files about to be serialized and written.
622
- */
623
- files: Array<FileNode>
624
- }
625
-
626
- export type KubbFileProcessingUpdate = {
627
- /**
628
- * Number of files processed so far in this batch.
629
- */
630
- processed: number
631
- /**
632
- * Total number of files in this batch.
633
- */
634
- total: number
635
- /**
636
- * Completion percentage, `0` to `100`.
637
- */
638
- percentage: number
639
- /**
640
- * Serialized file content, or `undefined` when the file produced no output.
641
- */
642
- source?: string
643
- /**
644
- * The file that was just processed.
645
- */
646
- file: FileNode
647
- /**
648
- * Resolved configuration for this build.
649
- */
650
- config: Config
651
- }
652
-
653
- export type KubbFilesProcessingUpdateContext = {
654
- /**
655
- * All files processed in this flush chunk.
656
- */
657
- files: Array<KubbFileProcessingUpdate>
658
- }
659
-
660
- export type KubbFilesProcessingEndContext = {
661
- /**
662
- * All files that were serialized in this batch.
663
- */
664
- files: Array<FileNode>
665
- }
666
-
667
- export type KubbHookStartContext = {
668
- /**
669
- * Optional identifier for correlating start/end events.
670
- */
671
- id?: string
672
- /**
673
- * The shell command that is about to run.
674
- */
675
- command: string
676
- /**
677
- * Parsed argument list, when available.
678
- */
679
- args?: ReadonlyArray<string>
680
- }
681
-
682
- /**
683
- * Emitted for each line streamed from a hook's stdout while it runs.
684
- * A logger correlates the line to its active UI element via `id`.
685
- */
686
- export type KubbHookLineContext = {
687
- /**
688
- * Identifier matching the corresponding `kubb:hook:start` event.
689
- */
690
- id: string
691
- /**
692
- * A single streamed stdout line, without its trailing newline.
693
- */
694
- line: string
695
- }
696
-
697
- export type KubbHookEndContext = {
698
- /**
699
- * Optional identifier matching the corresponding `kubb:hook:start` event.
700
- */
701
- id?: string
702
- /**
703
- * The shell command that ran.
704
- */
705
- command: string
706
- /**
707
- * Parsed argument list, when available.
708
- */
709
- args?: ReadonlyArray<string>
710
- /**
711
- * `true` when the command exited with code `0`.
712
- */
713
- success: boolean
714
- /**
715
- * Error thrown by the command, or `null` on success.
716
- */
717
- error: Error | null
718
- /**
719
- * Captured stdout from the process, populated when it exits non-zero.
720
- */
721
- stdout?: string
722
- /**
723
- * Captured stderr from the process, populated when it exits non-zero.
724
- */
725
- stderr?: string
726
- }
727
-
728
- /**
729
- * CLI options derived from command-line flags.
730
- */
731
- export type CLIOptions = {
732
- /**
733
- * Path to the Kubb config file.
734
- */
735
- config?: string
736
- /**
737
- * OpenAPI input path passed as the positional argument to `kubb generate`.
738
- * Overrides `config.input.path` when set.
739
- */
740
- input?: string
741
- /**
742
- * Re-run generation whenever input files change.
743
- */
744
- watch?: boolean
745
- /**
746
- * Controls how much output the CLI prints.
747
- *
748
- * @default 'info'
749
- */
750
- logLevel?: 'silent' | 'info' | 'verbose'
751
- /**
752
- * Reporters selected on the CLI via `--reporter`, overriding `config.reporters`.
753
- */
754
- reporters?: Array<ReporterName>
755
- }
756
-
757
- /**
758
- * All accepted forms of a Kubb configuration.
759
- * Accepts `Config`/`Config[]`/promise or a factory (optionally receiving `TCliOptions`).
760
- */
761
- export type PossibleConfig<TCliOptions = undefined> =
762
- | PossiblePromise<Config | Array<Config>>
763
- | ((...args: [TCliOptions] extends [undefined] ? [] : [TCliOptions]) => PossiblePromise<Config | Array<Config>>)
764
-
765
- /**
766
- * Full output produced by a successful or failed build.
767
- */
768
- export type BuildOutput = {
769
- /**
770
- * Structured diagnostics collected during the build: error/warning/info problems
771
- * (each with a code, severity, and where known a JSON-pointer location) plus a
772
- * `performance` diagnostic per plugin. Includes a top-level diagnostic when the build
773
- * threw before completing. Use {@link Diagnostics.hasError} to test for failure.
774
- */
775
- diagnostics: Array<Diagnostic>
776
- /**
777
- * All files generated during this build.
778
- */
779
- files: Array<FileNode>
780
- /**
781
- * The plugin driver that orchestrated this build.
782
- */
783
- driver: KubbDriver
784
- /**
785
- * Read-only view of every file written during this build.
786
- * Reads go straight to `config.storage`, nothing extra is held in memory.
787
- *
788
- * @example Read a generated file
789
- * `const code = await buildOutput.storage.getItem('/src/gen/pet.ts')`
790
- *
791
- * @example List all generated file paths
792
- * `const paths = await buildOutput.storage.getKeys()`
793
- */
794
- storage: Storage
795
- }
796
-
797
- export type { Adapter, AdapterFactoryOptions, AdapterSource } from './createAdapter.ts'
798
- export type {
799
- Diagnostic,
800
- DiagnosticByCode,
801
- DiagnosticDoc,
802
- DiagnosticKind,
803
- DiagnosticLocation,
804
- DiagnosticSeverity,
805
- PerformanceDiagnostic,
806
- ProblemCode,
807
- ProblemDiagnostic,
808
- SerializedDiagnostic,
809
- UpdateDiagnostic,
810
- } from './diagnostics.ts'
811
- export type { Kubb } from './createKubb.ts'
812
- export type { GenerationResult, Reporter, ReporterContext, ReporterName, UserReporter } from './createReporter.ts'
813
- export type { Renderer, RendererFactory } from './createRenderer.ts'
814
- export type { Storage } from './createStorage.ts'
815
- export type { FileProcessorHooks, ParsedFile } from './FileProcessor.ts'
816
- export type { Generator, GeneratorContext } from './defineGenerator.ts'
817
- export type { Parser } from './defineParser.ts'
818
- export type { Exclude, Group, Include, Output, OutputMode, OutputOptions, Override } from './definePlugin.ts'
819
- export type { KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NormalizedPlugin, Plugin, PluginFactoryOptions } from './definePlugin.ts'
820
- export type {
821
- BannerMeta,
822
- ResolveBannerContext,
823
- ResolveBannerFile,
824
- ResolveOptionsContext,
825
- Resolver,
826
- ResolverContext,
827
- ResolverFileParams,
828
- ResolverPathParams,
829
- } from './defineResolver.ts'