@kubb/core 5.14.3 → 5.14.5

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/index.d.cts CHANGED
@@ -2288,9 +2288,9 @@ type Generator<TOptions extends PluginType = PluginType, TElement = unknown> = {
2288
2288
  */
2289
2289
  export declare function defineGenerator<TOptions extends PluginType = PluginType, TElement = unknown>(generator: Generator<TOptions, TElement>): Generator<TOptions, TElement>;
2290
2290
  //#endregion
2291
- //#region src/Resolver.d.ts
2291
+ //#region src/resolveOptions.d.ts
2292
2292
  /**
2293
- * Context for resolving filtered options for a given operation or schema node.
2293
+ * Filters and overrides applied to an operation or schema's options.
2294
2294
  *
2295
2295
  * @internal
2296
2296
  */
@@ -2300,6 +2300,8 @@ type ResolveOptionsContext<TOptions> = {
2300
2300
  include?: Array<Filter>;
2301
2301
  override?: Array<Override<TOptions>>;
2302
2302
  };
2303
+ //#endregion
2304
+ //#region src/Resolver.d.ts
2303
2305
  /**
2304
2306
  * The built-in resolution machinery exposed on every resolver as `resolver.default`.
2305
2307
  * Plugins delegate to it via `this.default.*` and set their own conventions through
@@ -2522,6 +2524,19 @@ type ResolverBuildOptions = {
2522
2524
  name?: (name: string) => string;
2523
2525
  file?: ResolverFile;
2524
2526
  };
2527
+ /**
2528
+ * Reuse the declaration's key when resolving its references.
2529
+ */
2530
+ type ResolveNameOptions = {
2531
+ key: string | ReadonlyArray<string | undefined>;
2532
+ name: string;
2533
+ /**
2534
+ * Compares emitted identifiers while returning raw names. Keep numeric suffixes distinct.
2535
+ * Return several names when one declaration emits more than one identifier, such as an enum's
2536
+ * value and its type alias: the raw name is only taken when all of them are free.
2537
+ */
2538
+ normalize?: (name: string) => string | ReadonlyArray<string>;
2539
+ };
2525
2540
  /**
2526
2541
  * Partial resolver fields accepted by `Resolver.merge` and `setResolver`. Parameterize with a
2527
2542
  * concrete resolver type (e.g. `ResolverPatch<ResolverTs>`) to type-check overrides and bind
@@ -2574,6 +2589,35 @@ export declare class Resolver {
2574
2589
  /** Exposes the raw build options so `Resolver.merge` can read them across `@kubb/core` copies. */
2575
2590
  get [resolverOptions](): ResolverBuildOptions;
2576
2591
  name(name: string): string;
2592
+ /**
2593
+ * Reserves emitted identifiers before allocating other declarations. The driver reserves component
2594
+ * names. Reserve extra identifiers, such as enum type aliases, before calling `resolveName`.
2595
+ *
2596
+ * @example Reserve an enum's type and value names
2597
+ * ```ts
2598
+ * resolver.reserveNames(['petStatusEnum', 'PetStatusEnumKey'])
2599
+ * ```
2600
+ */
2601
+ reserveNames(names: Iterable<string>): void;
2602
+ /**
2603
+ * Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
2604
+ * when the preferred name is taken. Array segment order and boundaries matter. String and array
2605
+ * keys are distinct. Pass an already-cased name or use `normalize` to compare emitted identifiers
2606
+ * while returning raw names. `Resolver.merge` creates a resolver with no reservations.
2607
+ *
2608
+ * @example Resolve a request body that collides with a component
2609
+ * ```ts
2610
+ * resolver.reserveNames(['CreateContainerBody'])
2611
+ * resolver.resolveName({ key: ['operation', 'POST', '/containers', 'body'], name: 'CreateContainerBody' })
2612
+ * // 'CreateContainerBody2'
2613
+ * ```
2614
+ *
2615
+ * @example Resolve a name that has to be free as both an enum value and a type alias
2616
+ * ```ts
2617
+ * resolver.resolveName({ key: ['enum', 'Pet', 'status'], name: 'Status', normalize: (name) => [camelCase(name), `${name}Key`] })
2618
+ * ```
2619
+ */
2620
+ resolveName({ key, name, normalize }: ResolveNameOptions): string;
2577
2621
  file(options: ResolveFileOptions): FileNode;
2578
2622
  /**
2579
2623
  * Builds one `ImportNode` per unique schema referenced in the tree, in first-occurrence
@@ -3134,7 +3178,8 @@ export declare function defineExtension<TFactory extends PluginType = PluginType
3134
3178
  * input shape with paths resolved to absolute.
3135
3179
  *
3136
3180
  * - `{ type: 'path' }`: single file on disk.
3137
- * - `{ type: 'data' }`: raw string or parsed object provided inline.
3181
+ * - `{ type: 'data' }`: raw string or parsed object provided inline. `root` is the folder that
3182
+ * relative external `$ref`s in it resolve from.
3138
3183
  */
3139
3184
  type AdapterSource = {
3140
3185
  type: 'path';
@@ -3142,6 +3187,7 @@ type AdapterSource = {
3142
3187
  } | {
3143
3188
  type: 'data';
3144
3189
  data: string | unknown;
3190
+ root?: string;
3145
3191
  };
3146
3192
  /**
3147
3193
  * Generic parameters used by `defineExtension` with `kind: 'adapter'` and the resulting `Adapter` type.
@@ -3194,6 +3240,11 @@ type Adapter<TOptions extends AdapterFactoryOptions = AdapterFactoryOptions> = {
3194
3240
  * Parsed source document after the first `parse()` call. `null` before parsing.
3195
3241
  */
3196
3242
  document: TOptions['document'] | null;
3243
+ /**
3244
+ * The files and URLs the last `parse()` read, such as the ones external `$ref`s point at, including
3245
+ * any that could not be read. Inline data is not listed. A watcher rebuilds when one of them changes.
3246
+ */
3247
+ sources?: Array<string>;
3197
3248
  /**
3198
3249
  * Parse the source into a universal `InputNode`.
3199
3250
  *
@@ -3901,5 +3952,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
3901
3952
  resolveFrom?: Array<string>;
3902
3953
  }): Promise<Array<InstalledPackage>>;
3903
3954
  //#endregion
3904
- export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputManifest, OutputMode, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, PerformanceDiagnostic, Plugin, PluginDefinition, PluginFactory, PluginName, PluginType, ProblemCode, ProblemDiagnostic, RegistryArtifact, RegistryDetail, RegistryEntry, RegistryGuide, RegistryIndex, Renderer, RendererFactory, Reporter, ReporterContext, ReporterName, ReporterPluginFiles, ResolveBannerContext, ResolveBannerFile, ResolveFileOptions, ResolveImportsOptions, ResolveOptionsContext, ResolvePathOptions, ResolvePluginOptions, ResolverDefault, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, ResolverPathParams, RunHookOptions, RunOutputPassesOptions, SerializedDiagnostic, Storage, SummaryRenderer, UpdateDiagnostic, UserReporter };
3955
+ export type { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, CreateKubbOptions, Diagnostic, DiagnosticDoc, DiagnosticFormatOptions, DiagnosticKind, DiagnosticLocation, DiagnosticSeverity, Exclude$1 as Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Filter, GenerateOptions, GenerateResult, GenerationResult, Generator, GeneratorContext, Group, HookResult, Include, InputKind, InstalledPackage, JSONValue, Kubb$1 as Kubb, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputManifest, OutputMode, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, PerformanceDiagnostic, Plugin, PluginDefinition, PluginFactory, PluginName, PluginType, ProblemCode, ProblemDiagnostic, RegistryArtifact, RegistryDetail, RegistryEntry, RegistryGuide, RegistryIndex, Renderer, RendererFactory, Reporter, ReporterContext, ReporterName, ReporterPluginFiles, ResolveBannerContext, ResolveBannerFile, ResolveFileOptions, ResolveImportsOptions, ResolveNameOptions, ResolveOptionsContext, ResolvePathOptions, ResolvePluginOptions, ResolverDefault, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, ResolverPathParams, RunHookOptions, RunOutputPassesOptions, SerializedDiagnostic, Storage, SummaryRenderer, UpdateDiagnostic, UserReporter };
3905
3956
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as NodeCache, $t as ReporterContext, 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 createOutputManifest, H as ResolvePathOptions, Ht as KubbDriver, I as BannerMeta, It as PossibleConfig, J as ResolverPatch, Jt as createRenderer, K as ResolverFileParams, Kt as Renderer, 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 Reporter, 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 OutputManifest, X as Generator, Xt as createStorage, Y as ResolverPathParams, Yt as Storage, Z as GeneratorContext, Zt as GenerationResult, _ as Filter, _t as KubbDiagnosticContext, a as AdapterSource, an as DiagnosticFormatOptions, at as Diagnostics, b as KubbPluginEndContext, bt as KubbFilesProcessingEndContext, c as ExtensionDependency, cn as ParserDefinition, ct as ProblemDiagnostic, d as ExtensionKind, dt as CLIOptions, en as ReporterName, 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 logLevel, it as DiagnosticSeverity, j as PluginName, jt as KubbLifecycleStartContext, k as PluginDefinition, kt as KubbHooks, l as ExtensionDependencyRecord, ln as ParserFactory, lt as UpdateDiagnostic, m as defineExtension, mt as Input, n as AdapterDefinition, nn as UserReporter, nt as DiagnosticKind, o as createAdapter, on as SerializedDiagnostic, ot as PerformanceDiagnostic, p as checkCompatibility, pt as FilesContext, q as ResolverFilePathParams, qt as RendererFactory, r as AdapterFactory, rn as createReporter, rt as DiagnosticLocation, s as ExtensionDependencies, sn as Parser, st as ProblemCode, t as Adapter, tn as ReporterPluginFiles, tt as DiagnosticDoc, u as ExtensionFactory, un as defineParser, 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-DwnjwKN0.js";
1
+ import { $ as defineGenerator, $t as Reporter, A as PluginFactory, At as KubbHooks, B as ResolveImportsOptions, Bt as HookResult, C as NormalizedPlugin, Ct as KubbFilesProcessingUpdateContext, D as Override, Dt as KubbHookEndContext, E as OutputOptions, Et as KubbGenerationSummaryContext, F as definePlugin, Ft as KubbSuccessContext, G as ResolverFile, Gt as OutputManifest, H as ResolvePathOptions, Ht as runHook, I as BannerMeta, It as KubbWarnContext, J as ResolverPatch, Jt as RendererFactory, K as ResolverFileParams, Kt as createOutputManifest, L as ResolveBannerContext, Lt as PossibleConfig, M as PluginType, Mt as KubbLifecycleStartContext, N as ResolvePluginOptions, Nt as KubbMessageContext, O as Plugin, Ot as KubbHookLineContext, P as assertPluginOption, Pt as KubbPluginsEndContext, Q as GeneratorContext, Qt as GenerationResult, R as ResolveBannerFile, Rt as PostGenerateCommand, S as KubbPluginStartContext, St as KubbFilesProcessingStartContext, T as OutputMode, Tt as KubbGenerationStartContext, U as Resolver, Ut as KubbDriver, V as ResolveNameOptions, Vt as RunHookOptions, W as ResolverDefault, Wt as Hookable, X as ResolveOptionsContext, Xt as Storage, Y as ResolverPathParams, Yt as createRenderer, Z as Generator, Zt as createStorage, _ as Filter, _t as KubbBuildStartContext, a as AdapterSource, an as logLevel, at as DiagnosticSeverity, b as KubbPluginEndContext, bt as KubbFileProcessingUpdate, c as ExtensionDependency, cn as Parser, ct as ProblemCode, d as ExtensionKind, dn as defineParser, dt as BuildOutput, en as ReporterContext, et as NodeCache, f as ExtensionMeta, ft as CLIOptions, g as Exclude, gt as KubbBuildEndContext, h as resolveMeta, ht as Input, i as AdapterFactoryOptions, in as createReporter, it as DiagnosticLocation, j as PluginName, jt as KubbInfoContext, k as PluginDefinition, kt as KubbHookStartContext, l as ExtensionDependencyRecord, ln as ParserDefinition, lt as ProblemDiagnostic, m as defineExtension, mt as FilesContext, n as AdapterDefinition, nn as ReporterPluginFiles, nt as DiagnosticDoc, o as createAdapter, on as DiagnosticFormatOptions, ot as Diagnostics, p as checkCompatibility, pt as Config, q as ResolverFilePathParams, qt as Renderer, r as AdapterFactory, rn as UserReporter, rt as DiagnosticKind, s as ExtensionDependencies, sn as SerializedDiagnostic, st as PerformanceDiagnostic, t as Adapter, tn as ReporterName, tt as Diagnostic, u as ExtensionFactory, un as ParserFactory, ut as UpdateDiagnostic, v as Group, vt as KubbDiagnosticContext, w as Output, wt as KubbGenerationEndContext, x as KubbPluginSetupContext, xt as KubbFilesProcessingEndContext, y as Include, yt as KubbErrorContext, z as ResolveFileOptions, zt as UserConfig } from "./createAdapter-BD4waEKc.js";
2
2
  import { FileNode, Macro, UserFileNode } from "@kubb/ast";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import net from "node:net";
@@ -648,5 +648,5 @@ export declare function readInstalledPackages({ root, packages, resolveFrom }: {
648
648
  resolveFrom?: Array<string>;
649
649
  }): Promise<Array<InstalledPackage>>;
650
650
  //#endregion
651
- 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 OutputManifest, 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, createOutputManifest, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
651
+ 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 OutputManifest, 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 ResolveNameOptions, 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, createOutputManifest, createRenderer, createReporter, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, logLevel, resolveMeta, runHook };
652
652
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as formatMs, B as writeRaw, C as useConfig, D as defineExtension, E as checkCompatibility, F as isPathInside, I as listFiles, L as read, M as inParallel, N as exists, O as resolveMeta, P as existsSync$1, R as rm$1, S as tryUseKubb, T as useOptions, V as toError, _ as kubbContext, b as setOptions, c as Resolver, d as isPublicAddress, f as assertPluginOption, g as injectFile, h as addMacro, j as getElapsedMs, k as Diagnostics, l as getInputKind, m as addGenerator, n as KubbDriver, o as _usingCtx, p as definePlugin, s as createResolver, t as Hookable, u as checkoutGitInput, v as requirePlugin, w as useKubb, x as setResolver, y as setMacros, z as write } from "./Hookable-a3f_W95w.js";
1
+ import { A as formatMs, B as writeRaw, C as useConfig, D as defineExtension, E as checkCompatibility, F as isPathInside, I as listFiles, L as read, M as inParallel, N as exists, O as resolveMeta, P as existsSync$1, R as rm$1, S as tryUseKubb, T as useOptions, V as toError, _ as kubbContext, b as setOptions, c as Resolver, d as isPublicAddress, f as assertPluginOption, g as injectFile, h as addMacro, j as getElapsedMs, k as Diagnostics, l as getInputKind, m as addGenerator, n as KubbDriver, o as _usingCtx, p as definePlugin, s as createResolver, t as Hookable, u as checkoutGitInput, v as requirePlugin, w as useKubb, x as setResolver, y as setMacros, z as write } from "./Hookable-BLHdV93L.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { isValid } from "verkit";
4
4
  import process$1 from "node:process";