@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,620 @@
1
+ import { $ as NodeCache, $t as ReporterPluginFiles, A as PluginFactory, At as KubbInfoContext, B as ResolveImportsOptions, Bt as RunHookOptions, C as NormalizedPlugin, Ct as KubbGenerationEndContext, D as Override, Dt as KubbHookLineContext, E as OutputOptions, Et as KubbHookEndContext, F as definePlugin, Ft as KubbWarnContext, G as ResolverFile, Gt as RendererFactory, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createStorage, K as ResolverFileParams, Kt as createRenderer, L as ResolveBannerContext, Lt as PostGenerateCommand, M as PluginType, Mt as KubbMessageContext, N as ResolvePluginOptions, Nt as KubbPluginsEndContext, O as Plugin, Ot as KubbHookStartContext, P as assertPluginOption, Pt as KubbSuccessContext, Q as defineGenerator, Qt as ReporterName, R as ResolveBannerFile, Rt as UserConfig, S as KubbPluginStartContext, St as KubbFilesProcessingUpdateContext, T as OutputMode, Tt as KubbGenerationSummaryContext, U as Resolver, Ut as Hookable, V as ResolveOptionsContext, Vt as runHook, W as ResolverDefault, Wt as Renderer, X as Generator, Xt as Reporter, Y as ResolverPathParams, Yt as GenerationResult, Z as GeneratorContext, Zt as ReporterContext, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as Parser, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as defineParser, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as UserReporter, et as Diagnostic, f as ExtensionMeta, ft as Config, g as Exclude, gt as KubbBuildStartContext, h as resolveMeta, ht as KubbBuildEndContext, i as AdapterFactoryOptions, in as SerializedDiagnostic, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as logLevel, nt as DiagnosticKind, o as createAdapter, on as ParserDefinition, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as Storage, r as AdapterFactory, rn as DiagnosticFormatOptions, rt as DiagnosticLocation, s as ExtensionDependencies, sn as ParserFactory, st as ProblemCode, t as Adapter, tn as createReporter, tt as DiagnosticDoc, u as ExtensionFactory, ut as BuildOutput, v as Group, vt as KubbErrorContext, w as Output, wt as KubbGenerationStartContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingStartContext, y as Include, yt as KubbFileProcessingUpdate, z as ResolveFileOptions, zt as HookResult } from "./createAdapter-B5kKMsWV.cjs";
2
+ import { FileNode, Macro, UserFileNode } from "@kubb/ast";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
+ //#region src/composables.d.ts
5
+ /**
6
+ * Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
7
+ *
8
+ * The store lives on `globalThis`, so the ESM and CommonJS builds of `@kubb/core` share one. A plugin that a
9
+ * CommonJS config loads would otherwise read an empty store and fail with `KUBB_NO_CONTEXT`.
10
+ */
11
+ export declare const kubbContext: AsyncLocalStorage<KubbPluginSetupContext>;
12
+ /**
13
+ * Returns the context of the plugin whose `kubb:plugin:setup` is running. It stays available after an `await`.
14
+ * Throws `KUBB_NO_CONTEXT` outside setup.
15
+ */
16
+ export declare function useKubb<TFactory extends PluginType = PluginType>(): KubbPluginSetupContext<TFactory>;
17
+ /**
18
+ * Returns the same context as {@link useKubb}, or `undefined` outside `setup` and `kubb:plugin:setup`.
19
+ */
20
+ export declare function tryUseKubb<TFactory extends PluginType = PluginType>(): KubbPluginSetupContext<TFactory> | undefined;
21
+ /**
22
+ * Registers generators on the plugin being set up, like `ctx.addGenerator`.
23
+ *
24
+ * @example
25
+ * `addGenerator(typeGenerator, enumGenerator)`
26
+ */
27
+ export declare function addGenerator<TFactory extends PluginType = PluginType, TElement = unknown>(...generators: Array<Generator<TFactory, TElement>>): void;
28
+ /**
29
+ * Sets the resolver of the plugin being set up, like `ctx.setResolver`.
30
+ */
31
+ export declare function setResolver<TResolver extends Resolver = Resolver>(resolver: ResolverPatch<TResolver> | TResolver): void;
32
+ /**
33
+ * Adds a macro to the plugin being set up, like `ctx.addMacro`.
34
+ */
35
+ export declare function addMacro(macro: Macro): void;
36
+ /**
37
+ * Replaces the macros of the plugin being set up, like `ctx.setMacros`.
38
+ */
39
+ export declare function setMacros(macros: ReadonlyArray<Macro>): void;
40
+ /**
41
+ * Adds a raw file to the build output, like `ctx.injectFile`.
42
+ */
43
+ export declare function injectFile(file: UserFileNode): void;
44
+ /**
45
+ * Returns the options the user passed to the plugin being set up, like `ctx.options`.
46
+ */
47
+ export declare function useOptions<TFactory extends PluginType = PluginType>(): TFactory['options'];
48
+ /**
49
+ * Sets the resolved options of the plugin being set up, like `ctx.setOptions`.
50
+ */
51
+ export declare function setOptions<TFactory extends PluginType = PluginType>(options: TFactory['resolvedOptions']): void;
52
+ /**
53
+ * Returns the resolved build configuration, like `ctx.config`.
54
+ */
55
+ export declare function useConfig(): Config;
56
+ /**
57
+ * Returns another plugin from the config, typed through `Kubb.PluginRegistry`, like `ctx.requirePlugin`.
58
+ */
59
+ export declare function requirePlugin<TName extends PluginName>(name: TName): NormalizedPlugin<ResolvePluginOptions<TName>>;
60
+ //#endregion
61
+ //#region src/output/runOutputPasses.d.ts
62
+ type RunOutputPassesOptions = {
63
+ config: Config;
64
+ /**
65
+ * Absolute directory the formatter and linter run over.
66
+ */
67
+ outputPath: string;
68
+ hooks: Hookable<KubbHooks>;
69
+ signal?: AbortSignal;
70
+ };
71
+ /**
72
+ * Runs `output.format`, `output.lint` and `output.postGenerate` over the generated output and
73
+ * returns the diagnostics they produced. Each failure is emitted through `Diagnostics.emit` and
74
+ * returned, so it reaches the summary, the reporters and the exit code; the passes keep going so
75
+ * one failing tool does not hide the next. `Kubb.generate()` runs this after an error-free build
76
+ * unless the host passes its own `processOutput`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const diagnostics = await runOutputPasses({ config, outputPath: '/repo/src/gen', hooks })
81
+ * ```
82
+ */
83
+ export declare function runOutputPasses({ config, outputPath, hooks, signal }: RunOutputPassesOptions): Promise<Array<Diagnostic>>;
84
+ //#endregion
85
+ //#region src/createKubb.d.ts
86
+ type CreateKubbOptions = {
87
+ /**
88
+ * Receives Kubb lifecycle hooks for the run.
89
+ */
90
+ hooks?: Hookable<KubbHooks>;
91
+ /**
92
+ * Stops the build at the next safe checkpoint.
93
+ */
94
+ signal?: AbortSignal;
95
+ };
96
+ /**
97
+ * Host hooks for a single {@link Kubb.generate} call. All optional. Progress narration rides the
98
+ * `kubb:*` lifecycle hooks on `.hooks`, so hosts subscribe there rather than pass a callback.
99
+ */
100
+ type GenerateOptions = {
101
+ /**
102
+ * Replaces the output passes that run after an error-free build. The default,
103
+ * {@link runOutputPasses}, formats, lints and runs `output.postGenerate` over the generated
104
+ * output and returns the diagnostics they emitted.
105
+ */
106
+ processOutput?: (context: RunOutputPassesOptions) => Promise<Array<Diagnostic>>;
107
+ };
108
+ /**
109
+ * What a {@link Kubb.generate} call produced, for the host to map onto its own result shape.
110
+ */
111
+ type GenerateResult = {
112
+ /**
113
+ * `true` when the build and every output pass completed without an error-level diagnostic.
114
+ */
115
+ success: boolean;
116
+ /**
117
+ * All files generated during the build.
118
+ */
119
+ files: Array<FileNode>;
120
+ /**
121
+ * Build diagnostics plus any collected from the output passes.
122
+ */
123
+ diagnostics: Array<Diagnostic>;
124
+ };
125
+ /**
126
+ * Kubb code-generation instance bound to a single config entry. Resolves the user
127
+ * config in the constructor, so `config` is available right away, and shares `hooks`,
128
+ * `storage`, and `driver` across the `setup → build` lifecycle.
129
+ *
130
+ * `createKubb` takes a plain config object (the shape `defineConfig` produces),
131
+ * not a fluent builder.
132
+ *
133
+ * Attach hook listeners to `.hooks` before calling `setup()` or `build()`.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const kubb = createKubb(userConfig)
138
+ * kubb.hooks.hook('kubb:plugin:end', ({ plugin, duration }) => console.log(plugin.name, duration))
139
+ * const { files, diagnostics } = await kubb.safeBuild()
140
+ * ```
141
+ */
142
+ declare class Kubb {
143
+ #private;
144
+ readonly hooks: Hookable<KubbHooks>;
145
+ readonly config: Config;
146
+ constructor(userConfig: UserConfig, options?: CreateKubbOptions);
147
+ get storage(): Storage;
148
+ get driver(): KubbDriver;
149
+ /**
150
+ * Initializes the driver and storage. `build()` calls this automatically.
151
+ */
152
+ setup(): Promise<void>;
153
+ /**
154
+ * Runs the full pipeline and throws on any plugin error.
155
+ * Automatically calls `setup()` if needed.
156
+ */
157
+ build(): Promise<BuildOutput>;
158
+ /**
159
+ * Runs the full pipeline and captures errors in `BuildOutput` instead of throwing.
160
+ * Automatically calls `setup()` if needed. This is the canonical call: it never throws on
161
+ * plugin errors, so callers stay in control of how failures surface.
162
+ */
163
+ safeBuild(): Promise<BuildOutput>;
164
+ /**
165
+ * Run one build and its output passes end to end, emitting the surrounding `kubb:generation:*`
166
+ * hooks. Never throws on a build error: the outcome comes back in {@link GenerateResult} so the
167
+ * host decides how failures surface. Telemetry and progress narration stay with the host, which
168
+ * reads the result and subscribes to the `kubb:*` hooks.
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * const result = await createKubb(config, { hooks }).generate()
173
+ * if (!result.success) process.exitCode = 1
174
+ * ```
175
+ */
176
+ generate(options?: GenerateOptions): Promise<GenerateResult>;
177
+ dispose(): void;
178
+ [Symbol.dispose](): void;
179
+ }
180
+ /**
181
+ * Constructs a {@link Kubb} build orchestrator from a user config. Equivalent
182
+ * to `new Kubb(userConfig, options)` and the canonical public entry point.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * import { createKubb } from '@kubb/core'
187
+ * import { adapterOas } from '@kubb/adapter-oas'
188
+ * import { pluginTs } from '@kubb/plugin-ts'
189
+ *
190
+ * const kubb = createKubb({
191
+ * input: './petStore.yaml',
192
+ * output: { path: './src/gen' },
193
+ * adapter: adapterOas(),
194
+ * plugins: [pluginTs()],
195
+ * })
196
+ *
197
+ * await kubb.build()
198
+ * ```
199
+ */
200
+ export declare function createKubb(userConfig: UserConfig, options?: CreateKubbOptions): Kubb;
201
+ //#endregion
202
+ //#region src/reporters/summary.d.ts
203
+ /**
204
+ * Writes a finished summary. The `cli` reporter formats the lines and hands them to one of these,
205
+ * so the caller decides where they land: plain `console.log` by default, or the active logger's own
206
+ * output when a host installs one.
207
+ */
208
+ type SummaryRenderer = (lines: ReadonlyArray<string>, meta: {
209
+ title: string;
210
+ status: 'success' | 'failed';
211
+ }) => void;
212
+ //#endregion
213
+ //#region src/reporters/cliReporter.d.ts
214
+ /**
215
+ * Builds a `cli` reporter that renders the {@link Report} for each config as it finishes.
216
+ * Suppressed at `silent`. The `verbose` level adds the per-plugin timings.
217
+ *
218
+ * Pass `render` to send the summary through output the host already owns, so it lands inside that
219
+ * host's grouping instead of alongside it. Omit it for the plain `console.log` writer.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * const reporter = createCliReporter({ render: (lines) => lines.forEach((line) => clack.log.message(line)) })
224
+ * ```
225
+ */
226
+ export declare function createCliReporter({ render }?: {
227
+ render?: SummaryRenderer;
228
+ }): Reporter;
229
+ /**
230
+ * The default `cli` reporter, writing its summary straight to the console. Independent of the live
231
+ * logger view.
232
+ */
233
+ export declare const cliReporter: Reporter;
234
+ //#endregion
235
+ //#region src/reporters/fileReporter.d.ts
236
+ /**
237
+ * The `file` reporter. Writes a config's {@link Report} to `.kubb/kubb-<name>-<timestamp>.log` as a
238
+ * plain-text document: a `# <name> — <timestamp>` header, a `## Summary` with the same lines the
239
+ * cli reporter prints (timings included), and a `## Problems` section in the miette block format.
240
+ * Selected with `--reporter file` (or `reporters: ['file']`).
241
+ *
242
+ * @note It captures the collected diagnostics once a config finishes, not the live
243
+ * `kubb:info`/`kubb:plugin` hook stream. Color is stripped so the file stays plain text even when
244
+ * the run is attached to a TTY.
245
+ */
246
+ export declare const fileReporter: Reporter;
247
+ //#endregion
248
+ //#region src/reporters/jsonReporter.d.ts
249
+ /**
250
+ * The `json` reporter. `report` returns one config's {@link Report}, which {@link createReporter}
251
+ * buffers, and `drain` writes them as a single pretty-printed JSON array on `kubb:lifecycle:end`.
252
+ * Buffering keeps a multi-config run one valid JSON document on stdout instead of concatenated
253
+ * objects that would break `jq .`. The terminal reporter is suppressed while `json` is active so
254
+ * stdout stays valid JSON.
255
+ */
256
+ export declare const jsonReporter: Reporter;
257
+ //#endregion
258
+ //#region src/reporters/htmlReporter.d.ts
259
+ /**
260
+ * Writes a static HTML report directory selected with `--reporter html`.
261
+ */
262
+ export declare const htmlReporter: Reporter;
263
+ //#endregion
264
+ //#region src/createResolver.d.ts
265
+ /**
266
+ * The plugin-specific resolver fields handed to `createResolver`. `name` and `file` fall
267
+ * back to the built-ins when omitted. Every method reaches sibling helpers through `this`,
268
+ * which `ThisType` types as the full resolver.
269
+ */
270
+ type ResolverOptions<T extends PluginType> = Omit<T['resolver'], keyof Resolver> & {
271
+ pluginName: T['name'];
272
+ name?: T['resolver']['name'];
273
+ file?: ResolverFile;
274
+ } & ThisType<T['resolver']>;
275
+ /**
276
+ * Defines a plugin resolver, the object that decides what every generated symbol and file
277
+ * path is called. Override the top-level `name` and `file` to set the plugin's conventions,
278
+ * and add your own naming helpers, top-level (`typeName`, …) or grouped in namespaces
279
+ * (`query`, `schema`, …). Every method reaches sibling helpers and the built-in machinery
280
+ * through `this.name`, `this.file`, and `this.default`.
281
+ *
282
+ * @example Custom identifier casing
283
+ * ```ts
284
+ * export const resolverTs = createResolver<PluginTs>({
285
+ * pluginName: 'plugin-ts',
286
+ * name(name) {
287
+ * return ensureValidVarName(pascalCase(name))
288
+ * },
289
+ * })
290
+ * ```
291
+ *
292
+ * @example Rename generated files with `file.baseName`
293
+ * ```ts
294
+ * export const resolverFaker = createResolver<PluginFaker>({
295
+ * pluginName: 'plugin-faker',
296
+ * name(name) {
297
+ * return camelCase(name, { prefix: 'create' })
298
+ * },
299
+ * file: {
300
+ * baseName({ name, extname }) {
301
+ * return `${camelCase(name, { prefix: 'create' })}${extname}`
302
+ * },
303
+ * },
304
+ * })
305
+ * ```
306
+ *
307
+ * @example Own the full path with `file.path`
308
+ * ```ts
309
+ * export const resolverFaker = createResolver<PluginFaker>({
310
+ * pluginName: 'plugin-faker',
311
+ * file: {
312
+ * path({ baseName, output }) {
313
+ * return `${output.path}/mocks/${baseName}`
314
+ * },
315
+ * },
316
+ * })
317
+ * ```
318
+ */
319
+ export declare function createResolver<T extends PluginType>(options: ResolverOptions<T>): T['resolver'];
320
+ //#endregion
321
+ //#region src/input.d.ts
322
+ /**
323
+ * What an `input` value points at, once Kubb has looked at it.
324
+ *
325
+ * - `file` is a local file path, absolute or relative to the config file.
326
+ * - `url` is a remote document to fetch.
327
+ * - `inline` is OpenAPI content held in the string itself (JSON or YAML).
328
+ * - `object` is an already-parsed spec.
329
+ */
330
+ type InputKind = 'file' | 'url' | 'inline' | 'object';
331
+ /**
332
+ * Classifies an `input` value so callers branch on it once instead of repeating the checks.
333
+ *
334
+ * A non-string is a parsed spec (`object`). A string is `inline` when it holds OpenAPI content,
335
+ * meaning it starts with `{` or `[`, spans multiple lines, or opens with a YAML `openapi:` or
336
+ * `swagger:` key. Otherwise a string is a `url` when it parses as one, or a `file` path.
337
+ */
338
+ export declare function getInputKind(input: NonNullable<Input>): InputKind;
339
+ //#endregion
340
+ //#region src/storages/cacheStorage.d.ts
341
+ type CacheStorageOptions = {
342
+ /**
343
+ * Project root the cache directory is derived from.
344
+ *
345
+ * @default process.cwd()
346
+ */
347
+ root?: string;
348
+ };
349
+ /**
350
+ * Directory Kubb keeps build caches in. A project with a `node_modules` gets
351
+ * `node_modules/.cache/kubb`, the convention babel and eslint already use, so the cache stays out
352
+ * of version control. Without one it falls back to the OS temp directory, keyed by root so two
353
+ * projects sharing that directory keep their own cache.
354
+ *
355
+ * @example Inside a project
356
+ * `resolveCacheDir('/project') // '/project/node_modules/.cache/kubb'`
357
+ */
358
+ export declare function resolveCacheDir(root: string): string;
359
+ /**
360
+ * Filesystem storage for build caches rather than generated code. Keys are plain names resolved
361
+ * inside {@link resolveCacheDir}, so a caller stores `'x.json'` without knowing where the cache
362
+ * lives. Kept apart from the configured output storage, which may not be a local disk at all.
363
+ *
364
+ * @example
365
+ * ```ts
366
+ * const cache = cacheStorage({ root: config.root })
367
+ * await cache.writeItem('output-manifest.json', JSON.stringify(entries))
368
+ * ```
369
+ */
370
+ export declare const cacheStorage: (options?: CacheStorageOptions | undefined) => Storage;
371
+ //#endregion
372
+ //#region src/storages/fsStorage.d.ts
373
+ /**
374
+ * Built-in filesystem storage driver.
375
+ *
376
+ * This is the default storage when no `storage` option is configured in the root config.
377
+ * Keys are resolved against `process.cwd()`, so root-relative paths such as
378
+ * `src/gen/api/getPets.ts` are written to the correct location without extra configuration.
379
+ *
380
+ * Writes are deduplicated and directory-safe:
381
+ * - leading and trailing whitespace is trimmed before writing
382
+ * - the write is skipped when the file already holds that content, ignoring any trailing newline
383
+ * a formatter left behind
384
+ * - missing parent directories are created automatically
385
+ * - `FileManager.write` bounds in-flight writes, so this driver does not pace itself
386
+ *
387
+ * @example
388
+ * ```ts
389
+ * import { fsStorage } from '@kubb/core'
390
+ * import { defineConfig } from 'kubb'
391
+ *
392
+ * export default defineConfig({
393
+ * input: './petStore.yaml',
394
+ * output: { path: './src/gen' },
395
+ * storage: fsStorage(),
396
+ * })
397
+ * ```
398
+ */
399
+ export declare const fsStorage: (options?: Record<string, never> | undefined) => Storage;
400
+ //#endregion
401
+ //#region src/storages/kubbStorage.d.ts
402
+ type KubbStorageOptions = {
403
+ /**
404
+ * Folder inside the Kubb home, or an absolute path such as `<cwd>/.kubb`.
405
+ */
406
+ base?: string;
407
+ };
408
+ /**
409
+ * Folder Kubb keeps its own files in, created with mode 0700. `base` resolves inside `KUBB_HOME`
410
+ * (default `~/.kubb`). When that folder is not writable, it falls back to a folder in the OS temp directory.
411
+ *
412
+ * @example
413
+ * `resolveKubbDir('cache') // '/home/me/.kubb/cache'`
414
+ */
415
+ export declare function resolveKubbDir(base?: string): string;
416
+ /**
417
+ * unstorage on the fs driver, rooted at {@link resolveKubbDir}. The fs driver cannot set a file
418
+ * mode, so the 0700 folder keeps files such as a stored token private.
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * const storage = kubbStorage({ base: 'cache' })
423
+ * await storage.setItem('machine-secret', secret)
424
+ * ```
425
+ */
426
+ export declare function kubbStorage({ base }?: KubbStorageOptions): import("unstorage").Storage<import("unstorage").StorageValue>;
427
+ //#endregion
428
+ //#region src/storages/memoryStorage.d.ts
429
+ /**
430
+ * In-memory storage driver. Useful for testing and dry-run scenarios where
431
+ * generated output should be captured without touching the filesystem.
432
+ *
433
+ * All data lives in a `Map` scoped to the storage instance and is discarded
434
+ * when the instance is garbage-collected.
435
+ *
436
+ * @example
437
+ * ```ts
438
+ * import { memoryStorage } from '@kubb/core'
439
+ * import { defineConfig } from 'kubb'
440
+ *
441
+ * export default defineConfig({
442
+ * input: './petStore.yaml',
443
+ * output: { path: './src/gen' },
444
+ * storage: memoryStorage(),
445
+ * })
446
+ * ```
447
+ */
448
+ export declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
449
+ //#endregion
450
+ //#region src/manifest.d.ts
451
+ /** A value that survives `JSON.stringify` and `JSON.parse` unchanged. */
452
+ type JSONValue = string | number | boolean | null | Array<JSONValue> | {
453
+ [key: string]: JSONValue;
454
+ };
455
+ /**
456
+ * One form field Studio renders for an extension. It edits the value at `path` in the options
457
+ * object the user passes to the factory.
458
+ */
459
+ type ExtensionManifestOption = {
460
+ /** Stable UI key, unique within the manifest. */
461
+ key: string;
462
+ /** Where the value lives, such as `['output', 'path']`. */
463
+ path: Array<string>;
464
+ label: string;
465
+ description?: string;
466
+ type: 'select' | 'boolean' | 'text' | 'number' | 'list';
467
+ /** The extension's runtime default, shown when the option is unset. */
468
+ default?: JSONValue;
469
+ /** For `select`. A choice with value `null` leaves the option unset. */
470
+ choices?: Array<{
471
+ label?: string;
472
+ value: JSONValue;
473
+ }>;
474
+ /** For `boolean`: the value written for `true`, `true` when unset. */
475
+ trueValue?: JSONValue;
476
+ /** For `boolean`: the value written for `false`, `false` when unset. */
477
+ falseValue?: JSONValue;
478
+ /** For `list`: template for each entry, where every `"$item"` string is replaced by the entry. */
479
+ item?: JSONValue;
480
+ /** For `list`: upper-case each entry before writing it. */
481
+ itemCase?: 'upper';
482
+ };
483
+ /**
484
+ * The `kubb-extension.json` file an extension package ships at its root. Studio, the kubb.dev
485
+ * registry, and `kubb add` read it.
486
+ */
487
+ type ExtensionManifest = {
488
+ $schema?: string;
489
+ kind: ExtensionKind;
490
+ /** Equals the extension's `meta.name`. */
491
+ name: string;
492
+ /** The factory export users call in `kubb.config.ts`, such as `pluginZod`. */
493
+ export: string;
494
+ displayName: string;
495
+ description: string;
496
+ category?: string;
497
+ icon?: {
498
+ light: string;
499
+ dark?: string;
500
+ };
501
+ /** HTTPS image or video URLs. */
502
+ media?: Array<string>;
503
+ tags?: Array<string>;
504
+ docs?: string;
505
+ /** People who maintain the extension, shown on its kubb.dev page. */
506
+ maintainers?: Array<{
507
+ name: string;
508
+ github?: string;
509
+ }>;
510
+ /** Names of the extensions that must be in the same config, such as `['plugin-ts']`. */
511
+ dependencies?: Array<string>;
512
+ /** Names of the extensions used when they are in the config, or needed only for some option values, such as `['plugin-faker']`. */
513
+ optionalDependencies?: Array<string>;
514
+ compatibility?: {
515
+ kubb?: string;
516
+ node?: string;
517
+ };
518
+ /** Plugins only: `client` ships the HTTP client runtime, `consumer` calls one but ships none. */
519
+ role?: 'client' | 'consumer';
520
+ options?: Array<ExtensionManifestOption>;
521
+ };
522
+ /** What `kubb add` installs: a reviewed npm version, or a GitHub release tag and the commit it points to. */
523
+ type RegistryArtifact = {
524
+ kind: 'npm';
525
+ package: string;
526
+ version: string;
527
+ } | {
528
+ kind: 'github';
529
+ /** The `name` in the root `package.json`, so the package installs under this name. */
530
+ package: string;
531
+ /** The release version, equal to `tag` without a leading `v`. */
532
+ version: string;
533
+ owner: string;
534
+ repo: string;
535
+ tag: string;
536
+ /** The full commit SHA the tag points to. */
537
+ commit: string;
538
+ };
539
+ /** One extension in a registry's `index.json`. */
540
+ type RegistryEntry = {
541
+ /** `<owner>/<slug>`, such as `kubb-labs/plugin-zod`. */
542
+ id: string;
543
+ kind: ExtensionKind;
544
+ type: 'official' | 'community';
545
+ artifact: RegistryArtifact;
546
+ repository?: {
547
+ url: string;
548
+ };
549
+ manifest: ExtensionManifest;
550
+ stats?: {
551
+ downloads?: number;
552
+ weekly?: number;
553
+ stars?: number;
554
+ };
555
+ submittedAt: string;
556
+ publishedAt: string;
557
+ reviewedAt: string;
558
+ };
559
+ /** The registry's `index.json`. */
560
+ type RegistryIndex = {
561
+ version: 1;
562
+ generatedAt: string;
563
+ extensions: Array<RegistryEntry>;
564
+ };
565
+ /** One `docs/guides/<id>.md`: `id` is the file name, `title` its `#` heading, `description` the first paragraph. */
566
+ type RegistryGuide = {
567
+ id: string;
568
+ title: string;
569
+ description: string;
570
+ content: string;
571
+ };
572
+ /** The registry's `<owner>/<slug>.json`: an entry plus the Markdown docs its pinned version ships. */
573
+ type RegistryDetail = RegistryEntry & {
574
+ overview: string | null;
575
+ options?: string | null;
576
+ guides?: Array<RegistryGuide>;
577
+ };
578
+ /**
579
+ * Whether `name` is a valid npm package name, such as `@kubb/plugin-ts`. Rejects paths, URLs,
580
+ * `node:` specifiers, and names that start with `-`, so the result is safe to pass to `import()` or
581
+ * a package manager.
582
+ */
583
+ export declare function isPackageName(name: unknown): name is string;
584
+ /**
585
+ * What is wrong with the options of a well-formed manifest, beyond their shape: keys are unique, a
586
+ * select has choices, and a select's default is one of its choice values. Empty when they pass.
587
+ */
588
+ export declare function manifestProblems({ options }: ExtensionManifest): Array<string>;
589
+ /**
590
+ * Checks a parsed `kubb-extension.json` or a registry response before Kubb or Studio uses it: the
591
+ * fields Kubb reads, every option's shape (including option paths that cannot reach a prototype),
592
+ * and `manifestProblems`. A malformed manifest is skipped instead of trusted.
593
+ */
594
+ export declare function isExtensionManifest(value: unknown): value is ExtensionManifest;
595
+ /**
596
+ * Checks one entry of a registry's `index.json` or `<owner>/<slug>.json`: a full `<owner>/<slug>` id,
597
+ * an npm or GitHub artifact pinned to a valid version, and a valid manifest of the entry's kind.
598
+ */
599
+ export declare function isRegistryEntry(value: unknown): value is RegistryEntry;
600
+ //#endregion
601
+ //#region src/installedPackages.d.ts
602
+ type InstalledPackage = {
603
+ package: string;
604
+ version?: string;
605
+ manifest?: ExtensionManifest;
606
+ };
607
+ /**
608
+ * The `dependencies` and `devDependencies` of the project at `root`, plus `packages`, with the
609
+ * installed version and the valid `kubb-extension.json` each one ships, when it does. A package
610
+ * also counts as installed when it resolves from one of the `resolveFrom` packages, such as `kubb`
611
+ * for the extensions it ships with.
612
+ */
613
+ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
614
+ root: string;
615
+ packages?: Iterable<string>;
616
+ resolveFrom?: Array<string>;
617
+ }): Promise<Array<InstalledPackage>>;
618
+ //#endregion
619
+ export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticFormatOptions, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
620
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
2
- import { $ as NodeCache, $t as UpdateDiagnostic, A as PluginFactory, At as RunHookOptions, B as ResolveImportsOptions, Bt as UserReporter, C as NormalizedPlugin, Ct as KubbPluginsEndContext, D as Override, Dt as PostGenerateCommand, E as OutputOptions, Et as PossibleConfig, F as definePlugin, Ft as GenerationResult, G as ResolverFile, Gt as DiagnosticKind, H as ResolvePathOptions, Ht as logLevel, I as BannerMeta, It as Reporter, J as ResolverPatch, Jt as Diagnostics, K as ResolverFileParams, Kt as DiagnosticLocation, L as ResolveBannerContext, Lt as ReporterContext, M as PluginType, Mt as KubbDriver, N as ResolvePluginOptions, Nt as Storage, O as Plugin, Ot as UserConfig, P as assertPluginOption, Pt as createStorage, Q as defineGenerator, Qt as SerializedDiagnostic, R as ResolveBannerFile, Rt as ReporterName, S as KubbPluginStartContext, St as KubbMessageContext, T as OutputMode, Tt as KubbWarnContext, U as Resolver, Ut as Diagnostic, V as ResolveOptionsContext, Vt as createReporter, W as ResolverDefault, Wt as DiagnosticDoc, X as Generator, Xt as ProblemCode, Y as ResolverPathParams, Yt as PerformanceDiagnostic, Z as GeneratorContext, Zt as ProblemDiagnostic, _ as Filter, _t as KubbHookLineContext, a as AdapterSource, an as ParserDefinition, at as KubbBuildEndContext, b as KubbPluginEndContext, bt as KubbInfoContext, c as ExtensionDependency, ct as KubbErrorContext, d as ExtensionKind, dt as KubbFilesProcessingStartContext, en as Hookable, et as BuildOutput, f as ExtensionMeta, ft as KubbFilesProcessingUpdateContext, g as Exclude, gt as KubbHookEndContext, h as resolveMeta, ht as KubbGenerationSummaryContext, i as AdapterFactoryOptions, in as Parser, it as Input, j as PluginName, jt as runHook, k as PluginDefinition, kt as HookResult, l as ExtensionDependencyRecord, lt as KubbFileProcessingUpdate, m as defineExtension, mt as KubbGenerationStartContext, n as AdapterDefinition, nn as RendererFactory, nt as Config, o as createAdapter, on as ParserFactory, ot as KubbBuildStartContext, p as checkCompatibility, pt as KubbGenerationEndContext, q as ResolverFilePathParams, qt as DiagnosticSeverity, r as AdapterFactory, rn as createRenderer, rt as FilesContext, s as ExtensionDependencies, sn as defineParser, st as KubbDiagnosticContext, t as Adapter, tn as Renderer, tt as CLIOptions, u as ExtensionFactory, ut as KubbFilesProcessingEndContext, v as Group, vt as KubbHookStartContext, w as Output, wt as KubbSuccessContext, x as KubbPluginSetupContext, xt as KubbLifecycleStartContext, y as Include, yt as KubbHooks, z as ResolveFileOptions, zt as ReporterPluginFiles } from "./createAdapter-D55JE9lX.js";
3
- import { AsyncLocalStorage } from "node:async_hooks";
1
+ import { $ as NodeCache, $t as ReporterPluginFiles, A as PluginFactory, At as KubbInfoContext, B as ResolveImportsOptions, Bt as RunHookOptions, C as NormalizedPlugin, Ct as KubbGenerationEndContext, D as Override, Dt as KubbHookLineContext, E as OutputOptions, Et as KubbHookEndContext, F as definePlugin, Ft as KubbWarnContext, G as ResolverFile, Gt as RendererFactory, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createStorage, K as ResolverFileParams, Kt as createRenderer, L as ResolveBannerContext, Lt as PostGenerateCommand, M as PluginType, Mt as KubbMessageContext, N as ResolvePluginOptions, Nt as KubbPluginsEndContext, O as Plugin, Ot as KubbHookStartContext, P as assertPluginOption, Pt as KubbSuccessContext, Q as defineGenerator, Qt as ReporterName, R as ResolveBannerFile, Rt as UserConfig, S as KubbPluginStartContext, St as KubbFilesProcessingUpdateContext, T as OutputMode, Tt as KubbGenerationSummaryContext, U as Resolver, Ut as Hookable, V as ResolveOptionsContext, Vt as runHook, W as ResolverDefault, Wt as Renderer, X as Generator, Xt as Reporter, Y as ResolverPathParams, Yt as GenerationResult, Z as GeneratorContext, Zt as ReporterContext, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as Parser, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as defineParser, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as UserReporter, et as Diagnostic, f as ExtensionMeta, ft as Config, g as Exclude, gt as KubbBuildStartContext, h as resolveMeta, ht as KubbBuildEndContext, i as AdapterFactoryOptions, in as SerializedDiagnostic, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as logLevel, nt as DiagnosticKind, o as createAdapter, on as ParserDefinition, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as Storage, r as AdapterFactory, rn as DiagnosticFormatOptions, rt as DiagnosticLocation, s as ExtensionDependencies, sn as ParserFactory, st as ProblemCode, t as Adapter, tn as createReporter, tt as DiagnosticDoc, u as ExtensionFactory, ut as BuildOutput, v as Group, vt as KubbErrorContext, w as Output, wt as KubbGenerationStartContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingStartContext, y as Include, yt as KubbFileProcessingUpdate, z as ResolveFileOptions, zt as HookResult } from "./createAdapter-B5kKMsWV.js";
4
2
  import { FileNode, Macro, UserFileNode } from "@kubb/ast";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
5
4
  //#region src/composables.d.ts
6
5
  /**
7
6
  * Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
@@ -617,5 +616,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
617
616
  resolveFrom?: Array<string>;
618
617
  }): Promise<Array<InstalledPackage>>;
619
618
  //#endregion
620
- export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
619
+ export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, BuildOutput, CLIOptions, Config, type CreateKubbOptions, type Diagnostic, type DiagnosticDoc, type DiagnosticFormatOptions, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, FilesContext, type Filter, type GenerateOptions, type GenerateResult, type GenerationResult, type Generator, type GeneratorContext, type Group, type HookResult, Hookable, type Include, Input, type InputKind, type InstalledPackage, type JSONValue, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbGenerationSummaryContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, KubbMessageContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NodeCache, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type PerformanceDiagnostic, type Plugin, type PluginDefinition, type PluginFactory, type PluginName, type PluginType, PossibleConfig, PostGenerateCommand, type ProblemCode, type ProblemDiagnostic, type RegistryArtifact, type RegistryDetail, type RegistryEntry, type RegistryGuide, type RegistryIndex, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ReporterPluginFiles, type ResolveBannerContext, type ResolveBannerFile, type ResolveFileOptions, type ResolveImportsOptions, type ResolveOptionsContext, type ResolvePathOptions, type ResolvePluginOptions, Resolver, type ResolverDefault, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type ResolverPathParams, type RunHookOptions, type RunOutputPassesOptions, type SerializedDiagnostic, type Storage, type SummaryRenderer, type UpdateDiagnostic, UserConfig, type UserReporter, assertPluginOption, checkCompatibility, createAdapter, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
621
620
  //# sourceMappingURL=index.d.ts.map