@kubb/core 5.0.0-beta.38 → 5.0.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{diagnostics-CYfKPtbU.d.ts → diagnostics-DhfW8YpT.d.ts} +289 -347
- package/dist/index.cjs +553 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +164 -119
- package/dist/index.js +532 -149
- package/dist/index.js.map +1 -1
- package/dist/{KubbDriver-CyNF-NIb.js → memoryStorage-CNQTs-YG.js} +240 -157
- package/dist/memoryStorage-CNQTs-YG.js.map +1 -0
- package/dist/{KubbDriver-BYBUfOZ8.cjs → memoryStorage-DHi1d0To.cjs} +255 -196
- package/dist/memoryStorage-DHi1d0To.cjs.map +1 -0
- package/dist/mocks.cjs +36 -6
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.ts +30 -3
- package/dist/mocks.js +33 -5
- package/dist/mocks.js.map +1 -1
- package/package.json +4 -4
- package/src/KubbDriver.ts +21 -65
- package/src/Telemetry.ts +278 -0
- package/src/constants.ts +14 -21
- package/src/createKubb.ts +22 -50
- package/src/createReporter.ts +43 -13
- package/src/defineGenerator.ts +2 -6
- package/src/defineLogger.ts +13 -1
- package/src/defineResolver.ts +3 -4
- package/src/diagnostics.ts +130 -61
- package/src/index.ts +8 -16
- package/src/mocks.ts +57 -2
- package/src/reporters/cliReporter.ts +90 -0
- package/src/reporters/fileReporter.ts +103 -0
- package/src/reporters/jsonReporter.ts +20 -0
- package/src/reporters/report.ts +85 -0
- package/src/types.ts +0 -1
- package/dist/KubbDriver-BYBUfOZ8.cjs.map +0 -1
- package/dist/KubbDriver-CyNF-NIb.js.map +0 -1
- package/src/devtools.ts +0 -53
|
@@ -108,115 +108,6 @@ declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[
|
|
|
108
108
|
*/
|
|
109
109
|
type PossiblePromise<T> = Promise<T> | T;
|
|
110
110
|
//#endregion
|
|
111
|
-
//#region src/constants.d.ts
|
|
112
|
-
/**
|
|
113
|
-
* Base URL for the Kubb Studio web app.
|
|
114
|
-
*/
|
|
115
|
-
declare const DEFAULT_STUDIO_URL: "https://kubb.studio";
|
|
116
|
-
/**
|
|
117
|
-
* Numeric log-level thresholds used internally to compare verbosity.
|
|
118
|
-
*
|
|
119
|
-
* Higher numbers are more verbose.
|
|
120
|
-
*/
|
|
121
|
-
declare const logLevel: {
|
|
122
|
-
readonly silent: number;
|
|
123
|
-
readonly error: 0;
|
|
124
|
-
readonly warn: 1;
|
|
125
|
-
readonly info: 3;
|
|
126
|
-
readonly verbose: 4;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Stable codes Kubb attaches to a `Diagnostic`. Each maps to a known failure mode
|
|
130
|
-
* and stays stable so it can be referenced in tooling and (later) docs. Reference
|
|
131
|
-
* these instead of inlining the string at a throw site.
|
|
132
|
-
*/
|
|
133
|
-
declare const diagnosticCode: {
|
|
134
|
-
/**
|
|
135
|
-
* Fallback for an unstructured error with no specific code.
|
|
136
|
-
*/
|
|
137
|
-
readonly unknown: "KUBB_UNKNOWN";
|
|
138
|
-
/**
|
|
139
|
-
* The `input.path` file or URL could not be read.
|
|
140
|
-
*/
|
|
141
|
-
readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
|
|
142
|
-
/**
|
|
143
|
-
* An adapter was configured without an `input`.
|
|
144
|
-
*/
|
|
145
|
-
readonly inputRequired: "KUBB_INPUT_REQUIRED";
|
|
146
|
-
/**
|
|
147
|
-
* A `$ref` (or equivalent reference) could not be resolved in the source document.
|
|
148
|
-
*/
|
|
149
|
-
readonly refNotFound: "KUBB_REF_NOT_FOUND";
|
|
150
|
-
/**
|
|
151
|
-
* A server variable value is not allowed by its `enum`.
|
|
152
|
-
*/
|
|
153
|
-
readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
|
|
154
|
-
/**
|
|
155
|
-
* A required plugin is missing from the config.
|
|
156
|
-
*/
|
|
157
|
-
readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
|
|
158
|
-
/**
|
|
159
|
-
* A plugin threw while generating.
|
|
160
|
-
*/
|
|
161
|
-
readonly pluginFailed: "KUBB_PLUGIN_FAILED";
|
|
162
|
-
/**
|
|
163
|
-
* A plugin reported a non-fatal warning through `ctx.warn`.
|
|
164
|
-
*/
|
|
165
|
-
readonly pluginWarning: "KUBB_PLUGIN_WARNING";
|
|
166
|
-
/**
|
|
167
|
-
* A plugin reported an informational message through `ctx.info`.
|
|
168
|
-
*/
|
|
169
|
-
readonly pluginInfo: "KUBB_PLUGIN_INFO";
|
|
170
|
-
/**
|
|
171
|
-
* A schema uses a `format` Kubb does not map to a specific type. Reserved for
|
|
172
|
-
* adapters to emit as a `warning`.
|
|
173
|
-
*/
|
|
174
|
-
readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
|
|
175
|
-
/**
|
|
176
|
-
* A referenced schema or operation is marked `deprecated`. Reserved for adapters
|
|
177
|
-
* to emit as an `info`.
|
|
178
|
-
*/
|
|
179
|
-
readonly deprecated: "KUBB_DEPRECATED";
|
|
180
|
-
/**
|
|
181
|
-
* An adapter is required but the config has none. The build cannot read the input
|
|
182
|
-
* without one.
|
|
183
|
-
*/
|
|
184
|
-
readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
|
|
185
|
-
/**
|
|
186
|
-
* The `devtools` config is set to something other than an object.
|
|
187
|
-
*/
|
|
188
|
-
readonly devtoolsInvalid: "KUBB_DEVTOOLS_INVALID";
|
|
189
|
-
/**
|
|
190
|
-
* A resolved output path escapes the output directory, which can stem from a path
|
|
191
|
-
* traversal in the spec or a misconfigured `group.name`.
|
|
192
|
-
*/
|
|
193
|
-
readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
|
|
194
|
-
/**
|
|
195
|
-
* A post-generate shell hook (`hooks.done`) exited with a failure.
|
|
196
|
-
*/
|
|
197
|
-
readonly hookFailed: "KUBB_HOOK_FAILED";
|
|
198
|
-
/**
|
|
199
|
-
* The formatter pass over the generated files failed.
|
|
200
|
-
*/
|
|
201
|
-
readonly formatFailed: "KUBB_FORMAT_FAILED";
|
|
202
|
-
/**
|
|
203
|
-
* The linter pass over the generated files failed.
|
|
204
|
-
*/
|
|
205
|
-
readonly lintFailed: "KUBB_LINT_FAILED";
|
|
206
|
-
/**
|
|
207
|
-
* Not a failure. Carries a plugin's elapsed time, summed into the run total.
|
|
208
|
-
*/
|
|
209
|
-
readonly performance: "KUBB_PERFORMANCE";
|
|
210
|
-
/**
|
|
211
|
-
* Not a failure. A newer Kubb version is available on npm.
|
|
212
|
-
*/
|
|
213
|
-
readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Union of the stable {@link diagnosticCode} values.
|
|
217
|
-
*/
|
|
218
|
-
type DiagnosticCode = (typeof diagnosticCode)[keyof typeof diagnosticCode];
|
|
219
|
-
//#endregion
|
|
220
111
|
//#region src/createAdapter.d.ts
|
|
221
112
|
/**
|
|
222
113
|
* Source data handed to an adapter's `parse` function. Mirrors the config
|
|
@@ -347,6 +238,95 @@ type AdapterBuilder<T extends AdapterFactoryOptions> = (options: T['options']) =
|
|
|
347
238
|
*/
|
|
348
239
|
declare function createAdapter<T extends AdapterFactoryOptions = AdapterFactoryOptions>(build: AdapterBuilder<T>): (options?: T['options']) => Adapter<T>;
|
|
349
240
|
//#endregion
|
|
241
|
+
//#region src/constants.d.ts
|
|
242
|
+
/**
|
|
243
|
+
* Stable codes Kubb attaches to a `Diagnostic`. Each maps to a known failure mode
|
|
244
|
+
* and stays stable so it can be referenced in tooling and (later) docs. Reference
|
|
245
|
+
* these instead of inlining the string at a throw site.
|
|
246
|
+
*/
|
|
247
|
+
declare const diagnosticCode: {
|
|
248
|
+
/**
|
|
249
|
+
* Fallback for an unstructured error with no specific code.
|
|
250
|
+
*/
|
|
251
|
+
readonly unknown: "KUBB_UNKNOWN";
|
|
252
|
+
/**
|
|
253
|
+
* The `input.path` file or URL could not be read.
|
|
254
|
+
*/
|
|
255
|
+
readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
|
|
256
|
+
/**
|
|
257
|
+
* An adapter was configured without an `input`.
|
|
258
|
+
*/
|
|
259
|
+
readonly inputRequired: "KUBB_INPUT_REQUIRED";
|
|
260
|
+
/**
|
|
261
|
+
* A `$ref` (or equivalent reference) could not be resolved in the source document.
|
|
262
|
+
*/
|
|
263
|
+
readonly refNotFound: "KUBB_REF_NOT_FOUND";
|
|
264
|
+
/**
|
|
265
|
+
* A server variable value is not allowed by its `enum`.
|
|
266
|
+
*/
|
|
267
|
+
readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
|
|
268
|
+
/**
|
|
269
|
+
* A required plugin is missing from the config.
|
|
270
|
+
*/
|
|
271
|
+
readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
|
|
272
|
+
/**
|
|
273
|
+
* A plugin threw while generating.
|
|
274
|
+
*/
|
|
275
|
+
readonly pluginFailed: "KUBB_PLUGIN_FAILED";
|
|
276
|
+
/**
|
|
277
|
+
* A plugin reported a non-fatal warning through `ctx.warn`.
|
|
278
|
+
*/
|
|
279
|
+
readonly pluginWarning: "KUBB_PLUGIN_WARNING";
|
|
280
|
+
/**
|
|
281
|
+
* A plugin reported an informational message through `ctx.info`.
|
|
282
|
+
*/
|
|
283
|
+
readonly pluginInfo: "KUBB_PLUGIN_INFO";
|
|
284
|
+
/**
|
|
285
|
+
* A schema uses a `format` Kubb does not map to a specific type. Reserved for
|
|
286
|
+
* adapters to emit as a `warning`.
|
|
287
|
+
*/
|
|
288
|
+
readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
|
|
289
|
+
/**
|
|
290
|
+
* A referenced schema or operation is marked `deprecated`. Reserved for adapters
|
|
291
|
+
* to emit as an `info`.
|
|
292
|
+
*/
|
|
293
|
+
readonly deprecated: "KUBB_DEPRECATED";
|
|
294
|
+
/**
|
|
295
|
+
* An adapter is required but the config has none. The build cannot read the input
|
|
296
|
+
* without one.
|
|
297
|
+
*/
|
|
298
|
+
readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
|
|
299
|
+
/**
|
|
300
|
+
* A resolved output path escapes the output directory, which can stem from a path
|
|
301
|
+
* traversal in the spec or a misconfigured `group.name`.
|
|
302
|
+
*/
|
|
303
|
+
readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
|
|
304
|
+
/**
|
|
305
|
+
* A post-generate shell hook (`hooks.done`) exited with a failure.
|
|
306
|
+
*/
|
|
307
|
+
readonly hookFailed: "KUBB_HOOK_FAILED";
|
|
308
|
+
/**
|
|
309
|
+
* The formatter pass over the generated files failed.
|
|
310
|
+
*/
|
|
311
|
+
readonly formatFailed: "KUBB_FORMAT_FAILED";
|
|
312
|
+
/**
|
|
313
|
+
* The linter pass over the generated files failed.
|
|
314
|
+
*/
|
|
315
|
+
readonly lintFailed: "KUBB_LINT_FAILED";
|
|
316
|
+
/**
|
|
317
|
+
* Not a failure. Carries a plugin's elapsed time, summed into the run total.
|
|
318
|
+
*/
|
|
319
|
+
readonly performance: "KUBB_PERFORMANCE";
|
|
320
|
+
/**
|
|
321
|
+
* Not a failure. A newer Kubb version is available on npm.
|
|
322
|
+
*/
|
|
323
|
+
readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Union of the stable {@link diagnosticCode} values.
|
|
327
|
+
*/
|
|
328
|
+
type DiagnosticCode = (typeof diagnosticCode)[keyof typeof diagnosticCode];
|
|
329
|
+
//#endregion
|
|
350
330
|
//#region src/createStorage.d.ts
|
|
351
331
|
/**
|
|
352
332
|
* Backend that persists generated files. Kubb ships with `fsStorage` (writes
|
|
@@ -513,14 +493,85 @@ type RendererFactory<TElement = unknown> = () => Renderer<TElement>;
|
|
|
513
493
|
*/
|
|
514
494
|
declare function createRenderer<TElement = unknown>(factory: RendererFactory<TElement>): RendererFactory<TElement>;
|
|
515
495
|
//#endregion
|
|
516
|
-
//#region src/
|
|
517
|
-
|
|
496
|
+
//#region src/defineLogger.d.ts
|
|
497
|
+
/**
|
|
498
|
+
* Numeric log-level thresholds used internally to compare verbosity.
|
|
499
|
+
*
|
|
500
|
+
* Higher numbers are more verbose.
|
|
501
|
+
*/
|
|
502
|
+
declare const logLevel: {
|
|
503
|
+
readonly silent: number;
|
|
504
|
+
readonly error: 0;
|
|
505
|
+
readonly warn: 1;
|
|
506
|
+
readonly info: 3;
|
|
507
|
+
readonly verbose: 4;
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Options accepted by a logger's `install` callback.
|
|
511
|
+
*/
|
|
512
|
+
type LoggerOptions = {
|
|
518
513
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
514
|
+
* Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
|
|
515
|
+
* (`silent`, `error`, `warn`, `info`, `verbose`, `debug`).
|
|
521
516
|
*/
|
|
522
|
-
|
|
517
|
+
logLevel: (typeof logLevel)[keyof typeof logLevel];
|
|
523
518
|
};
|
|
519
|
+
/**
|
|
520
|
+
* Event emitter handed to `Logger.install`. Use `.on('kubb:info', ...)` and
|
|
521
|
+
* friends to subscribe to build events.
|
|
522
|
+
*/
|
|
523
|
+
type LoggerContext = AsyncEventEmitter<KubbHooks>;
|
|
524
|
+
/**
|
|
525
|
+
* Logger contract. A logger receives the build's event emitter and subscribes
|
|
526
|
+
* to whichever lifecycle events it wants to forward to its destination
|
|
527
|
+
* (console, file, remote sink).
|
|
528
|
+
*/
|
|
529
|
+
type Logger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = {
|
|
530
|
+
/**
|
|
531
|
+
* Display name used in diagnostics.
|
|
532
|
+
*/
|
|
533
|
+
name: string;
|
|
534
|
+
/**
|
|
535
|
+
* Called once per build with the shared event emitter. Subscribe to events
|
|
536
|
+
* here. The return value (if any) is forwarded to whoever installed the
|
|
537
|
+
* logger, which is handy for sink factories.
|
|
538
|
+
*/
|
|
539
|
+
install: (context: LoggerContext, options?: TOptions) => TInstallReturn | Promise<TInstallReturn>;
|
|
540
|
+
};
|
|
541
|
+
type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = Logger<TOptions, TInstallReturn>;
|
|
542
|
+
/**
|
|
543
|
+
* Defines a typed logger. Use the second type parameter to declare a return
|
|
544
|
+
* value from `install`, which is handy when the logger exposes a sink factory
|
|
545
|
+
* or cleanup callback to the caller.
|
|
546
|
+
*
|
|
547
|
+
* @example Basic logger
|
|
548
|
+
* ```ts
|
|
549
|
+
* import { defineLogger } from '@kubb/core'
|
|
550
|
+
*
|
|
551
|
+
* export const myLogger = defineLogger({
|
|
552
|
+
* name: 'my-logger',
|
|
553
|
+
* install(context) {
|
|
554
|
+
* context.on('kubb:info', ({ message }) => console.log('ℹ', message))
|
|
555
|
+
* context.on('kubb:error', ({ error }) => console.error('✗', error.message))
|
|
556
|
+
* },
|
|
557
|
+
* })
|
|
558
|
+
* ```
|
|
559
|
+
*
|
|
560
|
+
* @example Logger that returns a hook sink factory
|
|
561
|
+
* ```ts
|
|
562
|
+
* import { defineLogger, type LoggerOptions } from '@kubb/core'
|
|
563
|
+
* import type { HookSinkFactory } from './sinks'
|
|
564
|
+
*
|
|
565
|
+
* export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
|
|
566
|
+
* name: 'my-logger',
|
|
567
|
+
* install(context) {
|
|
568
|
+
* // … register event handlers …
|
|
569
|
+
* return () => ({ onStdout: console.log })
|
|
570
|
+
* },
|
|
571
|
+
* })
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
declare function defineLogger<Options extends LoggerOptions = LoggerOptions, TInstallReturn = void>(logger: UserLogger<Options, TInstallReturn>): Logger<Options, TInstallReturn>;
|
|
524
575
|
//#endregion
|
|
525
576
|
//#region src/createReporter.d.ts
|
|
526
577
|
/**
|
|
@@ -563,7 +614,7 @@ type ReporterContext = {
|
|
|
563
614
|
};
|
|
564
615
|
/**
|
|
565
616
|
* Host-facing reporter, as installed onto a run. Unlike a Logger (the live TUI view), a reporter
|
|
566
|
-
* never sees the event emitter. `report` runs once per config; `
|
|
617
|
+
* never sees the event emitter. `report` runs once per config; `drain`, when present, runs once
|
|
567
618
|
* after the last config.
|
|
568
619
|
*/
|
|
569
620
|
type Reporter = {
|
|
@@ -579,21 +630,21 @@ type Reporter = {
|
|
|
579
630
|
* Optional finalizer called once after the run's last config. The host wires it to
|
|
580
631
|
* `kubb:lifecycle:end`. {@link createReporter} closes it over the reports `report` returned.
|
|
581
632
|
*/
|
|
582
|
-
|
|
633
|
+
drain?: (context: ReporterContext) => void | Promise<void>;
|
|
583
634
|
};
|
|
584
635
|
/**
|
|
585
636
|
* Reporter definition passed to {@link createReporter}. `report` returns the value to collect for
|
|
586
|
-
* this config (e.g. a built report), and the optional `
|
|
637
|
+
* this config (e.g. a built report), and the optional `drain` receives the collected reports to
|
|
587
638
|
* emit as one document. `T` is inferred from `report`'s return type.
|
|
588
639
|
*/
|
|
589
640
|
type UserReporter<T = void> = {
|
|
590
641
|
name: string;
|
|
591
642
|
report: (result: GenerationResult, context: ReporterContext) => T | Promise<T>;
|
|
592
|
-
|
|
643
|
+
drain?: (context: ReporterContext, reports: Array<T>) => void | Promise<void>;
|
|
593
644
|
};
|
|
594
645
|
/**
|
|
595
|
-
* Defines a reporter. When the definition has a `
|
|
596
|
-
* `report` returns and hands the array to `
|
|
646
|
+
* Defines a reporter. When the definition has a `drain`, the returned reporter buffers each value
|
|
647
|
+
* `report` returns and hands the array to `drain` once, then clears it. Without a `drain`, nothing
|
|
597
648
|
* is buffered. Wiring the reporter onto the run's events is the host's job, so the reporter only
|
|
598
649
|
* ever deals with a {@link GenerationResult}.
|
|
599
650
|
*
|
|
@@ -606,13 +657,20 @@ type UserReporter<T = void> = {
|
|
|
606
657
|
* report(result) {
|
|
607
658
|
* return { status: Diagnostics.hasError(result.diagnostics) ? 'failed' : 'success', diagnostics: result.diagnostics }
|
|
608
659
|
* },
|
|
609
|
-
*
|
|
660
|
+
* drain(context, reports) {
|
|
610
661
|
* process.stdout.write(`${JSON.stringify(reports, null, 2)}\n`)
|
|
611
662
|
* },
|
|
612
663
|
* })
|
|
613
664
|
* ```
|
|
614
665
|
*/
|
|
615
666
|
declare function createReporter<T = void>(reporter: UserReporter<T>): Reporter;
|
|
667
|
+
/**
|
|
668
|
+
* Picks the reporters whose `name` matches one of `names`, in the order the names are given.
|
|
669
|
+
* The config carries every available reporter, and the host selects which to activate by name
|
|
670
|
+
* (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are
|
|
671
|
+
* skipped.
|
|
672
|
+
*/
|
|
673
|
+
declare function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter>;
|
|
616
674
|
//#endregion
|
|
617
675
|
//#region src/defineParser.d.ts
|
|
618
676
|
type PrintOptions = {
|
|
@@ -704,135 +762,6 @@ type ParsedFile = {
|
|
|
704
762
|
total: number;
|
|
705
763
|
percentage: number;
|
|
706
764
|
};
|
|
707
|
-
type FileProcessorOptions = {
|
|
708
|
-
/**
|
|
709
|
-
* Storage destination for queued writes.
|
|
710
|
-
*/
|
|
711
|
-
storage: Storage;
|
|
712
|
-
/**
|
|
713
|
-
* Parsers indexed by file extension.
|
|
714
|
-
*/
|
|
715
|
-
parsers?: Map<FileNode['extname'], Parser>;
|
|
716
|
-
/**
|
|
717
|
-
* Output extname per source extname, applied during conversion.
|
|
718
|
-
*/
|
|
719
|
-
extension?: Record<FileNode['extname'], FileNode['extname'] | ''>;
|
|
720
|
-
};
|
|
721
|
-
/**
|
|
722
|
-
* Turns `FileNode`s into source strings and writes them to storage.
|
|
723
|
-
*
|
|
724
|
-
* Two modes share the same instance. Stateless mode (`parse`, `stream`, `run`) just runs the
|
|
725
|
-
* conversion. Queue mode (`enqueue`, `flush`, `drain`) buffers files deduped by path and
|
|
726
|
-
* writes each batch through storage with up to `STREAM_FLUSH_EVERY` requests in flight.
|
|
727
|
-
*
|
|
728
|
-
* `flush` does not wait for its batch to finish, so dispatch can overlap with IO. The next
|
|
729
|
-
* `flush` or `drain` picks the in-flight batch up. `drain` blocks until everything has been
|
|
730
|
-
* written and is meant for the end of a build.
|
|
731
|
-
*
|
|
732
|
-
* To surface build-level hook signals (`kubb:files:processing:*` and friends) subscribe to
|
|
733
|
-
* `hooks` and re-emit on the kubb bus.
|
|
734
|
-
*/
|
|
735
|
-
declare class FileProcessor {
|
|
736
|
-
#private;
|
|
737
|
-
readonly hooks: AsyncEventEmitter<FileProcessorHooks>;
|
|
738
|
-
constructor(options: FileProcessorOptions);
|
|
739
|
-
/**
|
|
740
|
-
* Files waiting in the queue.
|
|
741
|
-
*/
|
|
742
|
-
get size(): number;
|
|
743
|
-
parse(file: FileNode): string;
|
|
744
|
-
stream(files: ReadonlyArray<FileNode>): Generator<ParsedFile>;
|
|
745
|
-
run(files: Array<FileNode>): Promise<Array<FileNode>>;
|
|
746
|
-
/**
|
|
747
|
-
* Adds a file to the next flush. A later `enqueue` for the same path replaces the previous
|
|
748
|
-
* entry, matching `FileManager.upsert`. Fires the `enqueue` event.
|
|
749
|
-
*/
|
|
750
|
-
enqueue(file: FileNode): void;
|
|
751
|
-
/**
|
|
752
|
-
* Starts processing the queued files. Waits for any previous flush to finish (so two
|
|
753
|
-
* batches never run together) and then returns without waiting for the new one. The next
|
|
754
|
-
* `flush` or `drain` picks up the in-flight task.
|
|
755
|
-
*/
|
|
756
|
-
flush(): Promise<void>;
|
|
757
|
-
/**
|
|
758
|
-
* Waits for the in-flight flush and writes any files still queued. Fires the `drain` event
|
|
759
|
-
* when both are done.
|
|
760
|
-
*/
|
|
761
|
-
drain(): Promise<void>;
|
|
762
|
-
/**
|
|
763
|
-
* Clears every listener and the pending queue.
|
|
764
|
-
*/
|
|
765
|
-
dispose(): void;
|
|
766
|
-
[Symbol.dispose](): void;
|
|
767
|
-
}
|
|
768
|
-
//#endregion
|
|
769
|
-
//#region src/defineLogger.d.ts
|
|
770
|
-
/**
|
|
771
|
-
* Options accepted by a logger's `install` callback.
|
|
772
|
-
*/
|
|
773
|
-
type LoggerOptions = {
|
|
774
|
-
/**
|
|
775
|
-
* Output verbosity. Use the `logLevel` constants exported from `@kubb/core`
|
|
776
|
-
* (`silent`, `error`, `warn`, `info`, `verbose`, `debug`).
|
|
777
|
-
*/
|
|
778
|
-
logLevel: (typeof logLevel)[keyof typeof logLevel];
|
|
779
|
-
};
|
|
780
|
-
/**
|
|
781
|
-
* Event emitter handed to `Logger.install`. Use `.on('kubb:info', ...)` and
|
|
782
|
-
* friends to subscribe to build events.
|
|
783
|
-
*/
|
|
784
|
-
type LoggerContext = AsyncEventEmitter<KubbHooks>;
|
|
785
|
-
/**
|
|
786
|
-
* Logger contract. A logger receives the build's event emitter and subscribes
|
|
787
|
-
* to whichever lifecycle events it wants to forward to its destination
|
|
788
|
-
* (console, file, remote sink).
|
|
789
|
-
*/
|
|
790
|
-
type Logger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = {
|
|
791
|
-
/**
|
|
792
|
-
* Display name used in diagnostics.
|
|
793
|
-
*/
|
|
794
|
-
name: string;
|
|
795
|
-
/**
|
|
796
|
-
* Called once per build with the shared event emitter. Subscribe to events
|
|
797
|
-
* here. The return value (if any) is forwarded to whoever installed the
|
|
798
|
-
* logger, which is handy for sink factories.
|
|
799
|
-
*/
|
|
800
|
-
install: (context: LoggerContext, options?: TOptions) => TInstallReturn | Promise<TInstallReturn>;
|
|
801
|
-
};
|
|
802
|
-
type UserLogger<TOptions extends LoggerOptions = LoggerOptions, TInstallReturn = void> = Logger<TOptions, TInstallReturn>;
|
|
803
|
-
/**
|
|
804
|
-
* Defines a typed logger. Use the second type parameter to declare a return
|
|
805
|
-
* value from `install`, which is handy when the logger exposes a sink factory
|
|
806
|
-
* or cleanup callback to the caller.
|
|
807
|
-
*
|
|
808
|
-
* @example Basic logger
|
|
809
|
-
* ```ts
|
|
810
|
-
* import { defineLogger } from '@kubb/core'
|
|
811
|
-
*
|
|
812
|
-
* export const myLogger = defineLogger({
|
|
813
|
-
* name: 'my-logger',
|
|
814
|
-
* install(context) {
|
|
815
|
-
* context.on('kubb:info', ({ message }) => console.log('ℹ', message))
|
|
816
|
-
* context.on('kubb:error', ({ error }) => console.error('✗', error.message))
|
|
817
|
-
* },
|
|
818
|
-
* })
|
|
819
|
-
* ```
|
|
820
|
-
*
|
|
821
|
-
* @example Logger that returns a hook sink factory
|
|
822
|
-
* ```ts
|
|
823
|
-
* import { defineLogger, type LoggerOptions } from '@kubb/core'
|
|
824
|
-
* import type { HookSinkFactory } from './sinks'
|
|
825
|
-
*
|
|
826
|
-
* export const myLogger = defineLogger<LoggerOptions, HookSinkFactory>({
|
|
827
|
-
* name: 'my-logger',
|
|
828
|
-
* install(context) {
|
|
829
|
-
* // … register event handlers …
|
|
830
|
-
* return () => ({ onStdout: console.log })
|
|
831
|
-
* },
|
|
832
|
-
* })
|
|
833
|
-
* ```
|
|
834
|
-
*/
|
|
835
|
-
declare function defineLogger<Options extends LoggerOptions = LoggerOptions, TInstallReturn = void>(logger: UserLogger<Options, TInstallReturn>): Logger<Options, TInstallReturn>;
|
|
836
765
|
//#endregion
|
|
837
766
|
//#region src/defineMiddleware.d.ts
|
|
838
767
|
/**
|
|
@@ -1723,7 +1652,7 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1723
1652
|
* Report a warning. Collected as a `warning` diagnostic attributed to the current
|
|
1724
1653
|
* plugin. It surfaces in the run summary but does not fail the build. For a structured
|
|
1725
1654
|
* diagnostic with a code and source location, use `Diagnostics.report` or throw a
|
|
1726
|
-
* `
|
|
1655
|
+
* `Diagnostics.Error` directly.
|
|
1727
1656
|
*/
|
|
1728
1657
|
warn: (message: string) => void;
|
|
1729
1658
|
/**
|
|
@@ -1736,10 +1665,6 @@ type GeneratorContext<TOptions extends PluginFactoryOptions = PluginFactoryOptio
|
|
|
1736
1665
|
* the current plugin.
|
|
1737
1666
|
*/
|
|
1738
1667
|
info: (message: string) => void;
|
|
1739
|
-
/**
|
|
1740
|
-
* Open the current input node in Kubb Studio.
|
|
1741
|
-
*/
|
|
1742
|
-
openInStudio: (options?: DevtoolsOptions) => Promise<void>;
|
|
1743
1668
|
/**
|
|
1744
1669
|
* The configured adapter instance.
|
|
1745
1670
|
*/
|
|
@@ -2103,26 +2028,6 @@ type Config<TInput = Input> = {
|
|
|
2103
2028
|
* @see {@link defineMiddleware} to create custom middleware.
|
|
2104
2029
|
*/
|
|
2105
2030
|
middleware?: Array<Middleware>;
|
|
2106
|
-
/**
|
|
2107
|
-
* Kubb Studio cloud integration settings.
|
|
2108
|
-
*
|
|
2109
|
-
* Kubb Studio (https://kubb.studio) is a web-based IDE for managing API specs and generated code.
|
|
2110
|
-
* Set to `true` to enable with default settings, or pass an object to customize the Studio URL.
|
|
2111
|
-
*
|
|
2112
|
-
* @default false // disabled by default
|
|
2113
|
-
* @example
|
|
2114
|
-
* ```ts
|
|
2115
|
-
* devtools: true // use default Kubb Studio
|
|
2116
|
-
* devtools: { studioUrl: 'https://my-studio.dev' } // custom Studio instance
|
|
2117
|
-
* ```
|
|
2118
|
-
*/
|
|
2119
|
-
devtools?: true | {
|
|
2120
|
-
/**
|
|
2121
|
-
* Override the Kubb Studio base URL.
|
|
2122
|
-
* @default 'https://kubb.studio'
|
|
2123
|
-
*/
|
|
2124
|
-
studioUrl?: typeof DEFAULT_STUDIO_URL | (string & {});
|
|
2125
|
-
};
|
|
2126
2031
|
/**
|
|
2127
2032
|
* Lifecycle hooks that execute during or after the build process.
|
|
2128
2033
|
*
|
|
@@ -2155,28 +2060,30 @@ type Config<TInput = Input> = {
|
|
|
2155
2060
|
done?: string | Array<string>;
|
|
2156
2061
|
};
|
|
2157
2062
|
/**
|
|
2158
|
-
*
|
|
2159
|
-
* the CLI `--reporter`
|
|
2063
|
+
* The reporters available to the run, registered as instances. The host
|
|
2064
|
+
* (the CLI via `--reporter`) selects which ones to trigger by `name` with {@link selectReporters}.
|
|
2065
|
+
* `defineConfig` from the `kubb` package registers the built-in `cli`, `json`, and `file`
|
|
2066
|
+
* reporters by default.
|
|
2160
2067
|
*
|
|
2161
2068
|
* - `cli` writes the end-of-run summary to the terminal.
|
|
2162
2069
|
* - `json` writes a machine-readable report to stdout, for CI.
|
|
2163
2070
|
* - `file` writes a debug log to `.kubb/<name>-<timestamp>.log`.
|
|
2164
2071
|
*
|
|
2165
|
-
* @default ['cli']
|
|
2166
|
-
*
|
|
2167
2072
|
* @example
|
|
2168
2073
|
* ```ts
|
|
2169
|
-
*
|
|
2074
|
+
* import { cliReporter, jsonReporter } from '@kubb/core'
|
|
2075
|
+
*
|
|
2076
|
+
* reporters: [cliReporter, jsonReporter, myReporter]
|
|
2170
2077
|
* ```
|
|
2171
2078
|
*/
|
|
2172
|
-
reporters
|
|
2079
|
+
reporters: Array<Reporter>;
|
|
2173
2080
|
};
|
|
2174
2081
|
/**
|
|
2175
2082
|
* Partial `Config` for user-facing entry points with sensible defaults.
|
|
2176
2083
|
*
|
|
2177
2084
|
* `UserConfig` is what you pass to `defineConfig()`. It has optional `root`, `plugins`, `parsers`, and `adapter`
|
|
2178
2085
|
* fields (which fall back to sensible defaults). All other Config options are available, including `output`, `input`,
|
|
2179
|
-
* `storage`, `middleware`,
|
|
2086
|
+
* `storage`, `middleware`, and `hooks`.
|
|
2180
2087
|
*
|
|
2181
2088
|
* @example
|
|
2182
2089
|
* ```ts
|
|
@@ -2187,7 +2094,7 @@ type Config<TInput = Input> = {
|
|
|
2187
2094
|
* })
|
|
2188
2095
|
* ```
|
|
2189
2096
|
*/
|
|
2190
|
-
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage'> & {
|
|
2097
|
+
type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'parsers' | 'adapter' | 'storage' | 'reporters'> & {
|
|
2191
2098
|
/**
|
|
2192
2099
|
* Project root directory, absolute or relative to the config file location.
|
|
2193
2100
|
* @default process.cwd()
|
|
@@ -2213,6 +2120,12 @@ type UserConfig<TInput = Input> = Omit<Config<TInput>, 'root' | 'plugins' | 'par
|
|
|
2213
2120
|
* @default fsStorage()
|
|
2214
2121
|
*/
|
|
2215
2122
|
storage?: Storage;
|
|
2123
|
+
/**
|
|
2124
|
+
* Reporters available to the run. `defineConfig` registers the built-in `cli`, `json`, and
|
|
2125
|
+
* `file` reporters when omitted.
|
|
2126
|
+
* @default [cliReporter, jsonReporter, fileReporter] // applied by `defineConfig` from the `kubb` package
|
|
2127
|
+
*/
|
|
2128
|
+
reporters?: Array<Reporter>;
|
|
2216
2129
|
};
|
|
2217
2130
|
declare global {
|
|
2218
2131
|
namespace Kubb {
|
|
@@ -2627,15 +2540,6 @@ type BuildOutput = {
|
|
|
2627
2540
|
*/
|
|
2628
2541
|
storage: Storage;
|
|
2629
2542
|
};
|
|
2630
|
-
/**
|
|
2631
|
-
* Type guard to check if a given config has an `input.path`.
|
|
2632
|
-
*/
|
|
2633
|
-
declare function isInputPath(config: UserConfig | undefined): config is UserConfig<InputPath> & {
|
|
2634
|
-
input: InputPath;
|
|
2635
|
-
};
|
|
2636
|
-
declare function isInputPath(config: Config | undefined): config is Config<InputPath> & {
|
|
2637
|
-
input: InputPath;
|
|
2638
|
-
};
|
|
2639
2543
|
type CreateKubbOptions = {
|
|
2640
2544
|
hooks?: AsyncEventEmitter<KubbHooks>;
|
|
2641
2545
|
};
|
|
@@ -2837,7 +2741,7 @@ type UpdateDiagnostic = {
|
|
|
2837
2741
|
*/
|
|
2838
2742
|
type Diagnostic = ProblemDiagnostic | PerformanceDiagnostic | UpdateDiagnostic;
|
|
2839
2743
|
/**
|
|
2840
|
-
* Maps each {@link DiagnosticCode} to the variant it selects, for {@link
|
|
2744
|
+
* Maps each {@link DiagnosticCode} to the variant it selects, for {@link narrow}.
|
|
2841
2745
|
* Every {@link ProblemCode} selects a {@link ProblemDiagnostic}, and the two bookkeeping codes
|
|
2842
2746
|
* select their own variant.
|
|
2843
2747
|
*/
|
|
@@ -2847,44 +2751,13 @@ type DiagnosticByCode = Record<ProblemCode, ProblemDiagnostic> & Record<typeof d
|
|
|
2847
2751
|
*
|
|
2848
2752
|
* @example
|
|
2849
2753
|
* ```ts
|
|
2850
|
-
* const update =
|
|
2754
|
+
* const update = narrow(diagnostic, diagnosticCode.updateAvailable)
|
|
2851
2755
|
* if (update) {
|
|
2852
2756
|
* console.log(update.latestVersion)
|
|
2853
2757
|
* }
|
|
2854
2758
|
* ```
|
|
2855
2759
|
*/
|
|
2856
|
-
declare function
|
|
2857
|
-
/**
|
|
2858
|
-
* Returns `true` when the diagnostic is a build {@link ProblemDiagnostic}.
|
|
2859
|
-
*
|
|
2860
|
-
* @example
|
|
2861
|
-
* ```ts
|
|
2862
|
-
* if (isProblemDiagnostic(diagnostic)) {
|
|
2863
|
-
* console.log(diagnostic.location)
|
|
2864
|
-
* }
|
|
2865
|
-
* ```
|
|
2866
|
-
*/
|
|
2867
|
-
declare const isProblemDiagnostic: (diagnostic: Diagnostic) => diagnostic is ProblemDiagnostic;
|
|
2868
|
-
/**
|
|
2869
|
-
* Returns `true` when the diagnostic is a per-plugin {@link PerformanceDiagnostic}.
|
|
2870
|
-
*
|
|
2871
|
-
* @example
|
|
2872
|
-
* ```ts
|
|
2873
|
-
* const timings = diagnostics.filter(isPerformanceDiagnostic)
|
|
2874
|
-
* ```
|
|
2875
|
-
*/
|
|
2876
|
-
declare const isPerformanceDiagnostic: (diagnostic: Diagnostic) => diagnostic is PerformanceDiagnostic;
|
|
2877
|
-
/**
|
|
2878
|
-
* Returns `true` when the diagnostic is a version-update {@link UpdateDiagnostic}.
|
|
2879
|
-
*
|
|
2880
|
-
* @example
|
|
2881
|
-
* ```ts
|
|
2882
|
-
* if (isUpdateDiagnostic(diagnostic)) {
|
|
2883
|
-
* console.log(diagnostic.latestVersion)
|
|
2884
|
-
* }
|
|
2885
|
-
* ```
|
|
2886
|
-
*/
|
|
2887
|
-
declare const isUpdateDiagnostic: (diagnostic: Diagnostic) => diagnostic is UpdateDiagnostic;
|
|
2760
|
+
declare function narrow<C extends DiagnosticCode>(diagnostic: Diagnostic, code: C): DiagnosticByCode[C] | null;
|
|
2888
2761
|
/**
|
|
2889
2762
|
* A {@link Diagnostic} reduced to its JSON-safe fields plus a `docsUrl`, for
|
|
2890
2763
|
* machine-readable output (the `--reporter json` report, the MCP tools). Drops the
|
|
@@ -2902,24 +2775,6 @@ type SerializedDiagnostic = {
|
|
|
2902
2775
|
*/
|
|
2903
2776
|
docsUrl?: string;
|
|
2904
2777
|
};
|
|
2905
|
-
/**
|
|
2906
|
-
* An `Error` that carries a {@link Diagnostic}, so structured problems can flow
|
|
2907
|
-
* through the existing throw/catch paths while keeping their code and location.
|
|
2908
|
-
*
|
|
2909
|
-
* @example
|
|
2910
|
-
* ```ts
|
|
2911
|
-
* throw new DiagnosticError({ code: diagnosticCode.refNotFound, severity: 'error', message: `Could not find ${ref}`, location: { kind: 'schema', pointer: ref, ref } })
|
|
2912
|
-
* ```
|
|
2913
|
-
*/
|
|
2914
|
-
declare class DiagnosticError extends Error {
|
|
2915
|
-
diagnostic: ProblemDiagnostic;
|
|
2916
|
-
constructor(diagnostic: ProblemDiagnostic);
|
|
2917
|
-
}
|
|
2918
|
-
/**
|
|
2919
|
-
* Explanation for every {@link diagnosticCode}. Use {@link Diagnostics.explain} to look one up
|
|
2920
|
-
* and `Diagnostics.docsUrl` for the matching kubb.dev page.
|
|
2921
|
-
*/
|
|
2922
|
-
declare const diagnosticCatalog: Record<DiagnosticCode, DiagnosticDoc>;
|
|
2923
2778
|
/**
|
|
2924
2779
|
* Static helpers for working with {@link Diagnostic}s, plus the run-scoped sink
|
|
2925
2780
|
* that lets deep code report a diagnostic without threading a callback.
|
|
@@ -2931,6 +2786,75 @@ declare const diagnosticCatalog: Record<DiagnosticCode, DiagnosticDoc>;
|
|
|
2931
2786
|
*/
|
|
2932
2787
|
declare class Diagnostics {
|
|
2933
2788
|
#private;
|
|
2789
|
+
/**
|
|
2790
|
+
* The diagnostic code catalog, exposed as `Diagnostics.code` (e.g. `Diagnostics.code.refNotFound`).
|
|
2791
|
+
*/
|
|
2792
|
+
static code: {
|
|
2793
|
+
readonly unknown: "KUBB_UNKNOWN";
|
|
2794
|
+
readonly inputNotFound: "KUBB_INPUT_NOT_FOUND";
|
|
2795
|
+
readonly inputRequired: "KUBB_INPUT_REQUIRED";
|
|
2796
|
+
readonly refNotFound: "KUBB_REF_NOT_FOUND";
|
|
2797
|
+
readonly invalidServerVariable: "KUBB_INVALID_SERVER_VARIABLE";
|
|
2798
|
+
readonly pluginNotFound: "KUBB_PLUGIN_NOT_FOUND";
|
|
2799
|
+
readonly pluginFailed: "KUBB_PLUGIN_FAILED";
|
|
2800
|
+
readonly pluginWarning: "KUBB_PLUGIN_WARNING";
|
|
2801
|
+
readonly pluginInfo: "KUBB_PLUGIN_INFO";
|
|
2802
|
+
readonly unsupportedFormat: "KUBB_UNSUPPORTED_FORMAT";
|
|
2803
|
+
readonly deprecated: "KUBB_DEPRECATED";
|
|
2804
|
+
readonly adapterRequired: "KUBB_ADAPTER_REQUIRED";
|
|
2805
|
+
readonly pathTraversal: "KUBB_PATH_TRAVERSAL";
|
|
2806
|
+
readonly hookFailed: "KUBB_HOOK_FAILED";
|
|
2807
|
+
readonly formatFailed: "KUBB_FORMAT_FAILED";
|
|
2808
|
+
readonly lintFailed: "KUBB_LINT_FAILED";
|
|
2809
|
+
readonly performance: "KUBB_PERFORMANCE";
|
|
2810
|
+
readonly updateAvailable: "KUBB_UPDATE_AVAILABLE";
|
|
2811
|
+
};
|
|
2812
|
+
/**
|
|
2813
|
+
* Type guard for a build {@link ProblemDiagnostic}.
|
|
2814
|
+
*/
|
|
2815
|
+
static isProblem: (diagnostic: Diagnostic) => diagnostic is ProblemDiagnostic;
|
|
2816
|
+
/**
|
|
2817
|
+
* Type guard for a version-update {@link UpdateDiagnostic}.
|
|
2818
|
+
*/
|
|
2819
|
+
static isUpdate: (diagnostic: Diagnostic) => diagnostic is UpdateDiagnostic;
|
|
2820
|
+
/**
|
|
2821
|
+
* Type guard for a per-plugin {@link PerformanceDiagnostic}.
|
|
2822
|
+
*/
|
|
2823
|
+
static isPerformance: (diagnostic: Diagnostic) => diagnostic is PerformanceDiagnostic;
|
|
2824
|
+
/**
|
|
2825
|
+
* Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
|
|
2826
|
+
*/
|
|
2827
|
+
static narrow: typeof narrow;
|
|
2828
|
+
/**
|
|
2829
|
+
* An `Error` that carries a {@link Diagnostic}, so structured problems can flow
|
|
2830
|
+
* through the existing throw/catch paths while keeping their code and location.
|
|
2831
|
+
*
|
|
2832
|
+
* @example
|
|
2833
|
+
* ```ts
|
|
2834
|
+
* throw new Diagnostics.Error({ code: diagnosticCode.refNotFound, severity: 'error', message: `Could not find ${ref}`, location: { kind: 'schema', pointer: ref, ref } })
|
|
2835
|
+
* ```
|
|
2836
|
+
*/
|
|
2837
|
+
static Error: {
|
|
2838
|
+
new (diagnostic: ProblemDiagnostic): {
|
|
2839
|
+
diagnostic: ProblemDiagnostic;
|
|
2840
|
+
name: string;
|
|
2841
|
+
message: string;
|
|
2842
|
+
stack?: string;
|
|
2843
|
+
cause?: unknown;
|
|
2844
|
+
};
|
|
2845
|
+
isError(error: unknown): error is Error;
|
|
2846
|
+
isError(value: unknown): value is Error;
|
|
2847
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
2848
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
2849
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
2850
|
+
stackTraceLimit: number;
|
|
2851
|
+
};
|
|
2852
|
+
/**
|
|
2853
|
+
* Structural check for a {@link Diagnostics.Error}, including one thrown from a duplicated
|
|
2854
|
+
* `@kubb/core` copy where `instanceof` fails. Matches on the `name` and a `diagnostic`
|
|
2855
|
+
* that carries a `code`.
|
|
2856
|
+
*/
|
|
2857
|
+
static isError(error: unknown): error is InstanceType<typeof Diagnostics.Error>;
|
|
2934
2858
|
/**
|
|
2935
2859
|
* Runs `fn` with `sink` as the active diagnostic sink for the whole async
|
|
2936
2860
|
* subtree, so {@link Diagnostics.report} reaches it from anywhere inside.
|
|
@@ -2950,7 +2874,7 @@ declare class Diagnostics {
|
|
|
2950
2874
|
*/
|
|
2951
2875
|
static emit(hooks: AsyncEventEmitter<KubbHooks>, diagnostic: ProblemDiagnostic | UpdateDiagnostic): Promise<void>;
|
|
2952
2876
|
/**
|
|
2953
|
-
* Coerces any thrown value into a {@link ProblemDiagnostic}. A {@link
|
|
2877
|
+
* Coerces any thrown value into a {@link ProblemDiagnostic}. A {@link Diagnostics.Error}
|
|
2954
2878
|
* keeps its structured data, and anything else becomes a `KUBB_UNKNOWN` error.
|
|
2955
2879
|
*/
|
|
2956
2880
|
static from(error: unknown): ProblemDiagnostic;
|
|
@@ -3015,7 +2939,25 @@ declare class Diagnostics {
|
|
|
3015
2939
|
* fields are omitted rather than set to `undefined`.
|
|
3016
2940
|
*/
|
|
3017
2941
|
static serialize(diagnostic: Diagnostic): SerializedDiagnostic;
|
|
2942
|
+
/**
|
|
2943
|
+
* Renders a {@link Diagnostic} for terminal output as its parts: the colored severity `symbol`
|
|
2944
|
+
* (the gutter glyph), the `plugin(CODE): message` `headline`, and the `details` lines (optional
|
|
2945
|
+
* `at <pointer>`, `help:`, and `docs:`).
|
|
2946
|
+
*
|
|
2947
|
+
* Hosts compose these to fit their gutter: a clack logger passes `symbol` as its own gutter and
|
|
2948
|
+
* `[headline, ...details]` as the message, while plain text outputs use {@link Diagnostics.formatLines}.
|
|
2949
|
+
*/
|
|
2950
|
+
static format(diagnostic: Diagnostic): {
|
|
2951
|
+
symbol: string;
|
|
2952
|
+
headline: string;
|
|
2953
|
+
details: Array<string>;
|
|
2954
|
+
};
|
|
2955
|
+
/**
|
|
2956
|
+
* The self-contained block form of {@link Diagnostics.format}: `${symbol} ${headline}` followed by
|
|
2957
|
+
* the detail lines. Used where there is no gutter to own the symbol (plain and file output).
|
|
2958
|
+
*/
|
|
2959
|
+
static formatLines(diagnostic: Diagnostic): Array<string>;
|
|
3018
2960
|
}
|
|
3019
2961
|
//#endregion
|
|
3020
|
-
export {
|
|
3021
|
-
//# sourceMappingURL=diagnostics-
|
|
2962
|
+
export { Override as $, KubbHookEndContext as A, logLevel as At, createKubb as B, AsyncEventEmitter as Bt, KubbErrorContext as C, createReporter as Ct, KubbFilesProcessingUpdateContext as D, LoggerOptions as Dt, KubbFilesProcessingStartContext as E, LoggerContext as Et, KubbPluginsEndContext as F, createStorage as Ft, Exclude$1 as G, GeneratorContext as H, KubbSuccessContext as I, Adapter as It, KubbPluginEndContext as J, Group as K, KubbWarnContext as L, AdapterFactoryOptions as Lt, KubbHooks as M, RendererFactory as Mt, KubbInfoContext as N, createRenderer as Nt, KubbGenerationEndContext as O, UserLogger as Ot, KubbLifecycleStartContext as P, Storage as Pt, Output as Q, PossibleConfig as R, AdapterSource as Rt, KubbDiagnosticContext as S, UserReporter as St, KubbFilesProcessingEndContext as T, Logger as Tt, defineGenerator as U, Generator$1 as V, KubbDriver as W, KubbPluginStartContext as X, KubbPluginSetupContext as Y, NormalizedPlugin as Z, InputPath as _, defineParser as _t, DiagnosticLocation as a, ResolveBannerFile as at, KubbBuildStartContext as b, ReporterContext as bt, PerformanceDiagnostic as c, ResolverContext as ct, SerializedDiagnostic as d, defineResolver as dt, Plugin as et, UpdateDiagnostic as f, Middleware as ft, InputData as g, Parser as gt, Config as h, ParsedFile as ht, DiagnosticKind as i, ResolveBannerContext as it, KubbHookStartContext as j, Renderer as jt, KubbGenerationStartContext as k, defineLogger as kt, ProblemCode as l, ResolverFileParams as lt, CLIOptions as m, FileProcessorHooks as mt, DiagnosticByCode as n, definePlugin as nt, DiagnosticSeverity as o, ResolveOptionsContext as ot, BuildOutput as p, defineMiddleware as pt, Include as q, DiagnosticDoc as r, BannerMeta as rt, Diagnostics as s, Resolver as st, Diagnostic as t, PluginFactoryOptions as tt, ProblemDiagnostic as u, ResolverPathParams as ut, Kubb$1 as v, GenerationResult as vt, KubbFileProcessingUpdate as w, selectReporters as wt, KubbConfigEndContext as x, ReporterName as xt, KubbBuildEndContext as y, Reporter as yt, UserConfig as z, createAdapter as zt };
|
|
2963
|
+
//# sourceMappingURL=diagnostics-DhfW8YpT.d.ts.map
|