@kubb/core 5.0.0-beta.55 → 5.0.0-beta.57

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.ts CHANGED
@@ -2,6 +2,105 @@ import { t as __name } from "./chunk-C0LytTxp.js";
2
2
  import { $ as KubbPluginSetupContext, A as KubbHookStartContext, At as Adapter, B as ParsedFile, C as KubbFilesProcessingEndContext, Ct as GenerationResult, D as KubbGenerationStartContext, Dt as UserReporter, E as KubbGenerationEndContext, Et as ReporterName, F as KubbSuccessContext, G as Generator, H as createKubb, I as KubbWarnContext, J as KubbDriver, K as GeneratorContext, L as PossibleConfig, M as KubbInfoContext, Mt as AdapterSource, N as KubbLifecycleStartContext, Nt as createAdapter, O as KubbHookEndContext, Ot as createReporter, P as KubbPluginsEndContext, Pt as AsyncEventEmitter, Q as KubbPluginEndContext, R as UserConfig, S as KubbFileProcessingUpdate, St as createStorage, T as KubbFilesProcessingUpdateContext, Tt as ReporterContext, U as Parser, V as Kubb, W as defineParser, X as Group, Y as Exclude, Z as Include, _ as InputPath, _t as defineResolver, a as DiagnosticLocation, at as Override, b as KubbDiagnosticContext, bt as createRenderer, c as PerformanceDiagnostic, ct as definePlugin, d as SerializedDiagnostic, dt as ResolveBannerFile, et as KubbPluginStartContext, f as UpdateDiagnostic, ft as ResolveOptionsContext, g as InputData, gt as ResolverPathParams, h as Config, ht as ResolverFileParams, i as DiagnosticKind, it as OutputOptions, j as KubbHooks, jt as AdapterFactoryOptions, k as KubbHookLineContext, kt as logLevel, l as ProblemCode, lt as BannerMeta, m as CLIOptions, mt as ResolverContext, n as DiagnosticByCode, nt as Output, o as DiagnosticSeverity, ot as Plugin, p as BuildOutput, pt as Resolver, q as defineGenerator, r as DiagnosticDoc, rt as OutputMode, s as Diagnostics, st as PluginFactoryOptions, t as Diagnostic, tt as NormalizedPlugin, u as ProblemDiagnostic, ut as ResolveBannerContext, v as KubbBuildEndContext, vt as Renderer, w as KubbFilesProcessingStartContext, wt as Reporter, x as KubbErrorContext, xt as Storage, y as KubbBuildStartContext, yt as RendererFactory, z as FileProcessorHooks } from "./diagnostics-Bf2bC8lV.js";
3
3
  import * as ast from "@kubb/ast";
4
4
 
5
+ //#region ../../internals/utils/src/url.d.ts
6
+ type URLObject = {
7
+ /**
8
+ * The resolved URL string (Express-style or template literal, depending on context).
9
+ */
10
+ url: string;
11
+ /**
12
+ * Extracted path parameters as a key-value map, or `null` when the path has none.
13
+ */
14
+ params: Record<string, string> | null;
15
+ };
16
+ /**
17
+ * Supported identifier casing strategies for path parameters.
18
+ */
19
+ type PathCasing = 'camelcase';
20
+ type TemplateOptions = {
21
+ /**
22
+ * Literal text prepended inside the template literal, e.g. a base URL.
23
+ */
24
+ prefix?: string | null;
25
+ /**
26
+ * Transform applied to each extracted parameter name before interpolation.
27
+ */
28
+ replacer?: (pathParam: string) => string;
29
+ /**
30
+ * Casing strategy applied to path parameter names.
31
+ */
32
+ casing?: PathCasing;
33
+ };
34
+ type ObjectOptions = {
35
+ /**
36
+ * Controls whether the `url` is rendered as an Express path or a template literal.
37
+ * @default 'path'
38
+ */
39
+ type?: 'path' | 'template';
40
+ /**
41
+ * Transform applied to each extracted parameter name.
42
+ */
43
+ replacer?: (pathParam: string) => string;
44
+ /**
45
+ * When `true`, the result is serialized to a string expression instead of a plain object.
46
+ */
47
+ stringify?: boolean;
48
+ /**
49
+ * Casing strategy applied to path parameter names.
50
+ */
51
+ casing?: PathCasing;
52
+ };
53
+ /**
54
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
55
+ */
56
+ declare class Url {
57
+ /**
58
+ * Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.
59
+ *
60
+ * @example
61
+ * Url.canParse('https://petstore.swagger.io/v2') // true
62
+ * Url.canParse('/pet/{petId}') // false
63
+ */
64
+ static canParse(url: string, base?: string | URL): boolean;
65
+ /**
66
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
67
+ *
68
+ * @example
69
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
70
+ */
71
+ static toPath(path: string): string;
72
+ /**
73
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
74
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
75
+ * and `casing` controls parameter identifier casing.
76
+ *
77
+ * @example
78
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
79
+ *
80
+ * @example
81
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
82
+ */
83
+ static toTemplateString(path: string, {
84
+ prefix,
85
+ replacer,
86
+ casing
87
+ }?: TemplateOptions): string;
88
+ /**
89
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
90
+ * expression when `stringify` is set.
91
+ *
92
+ * @example
93
+ * Url.toObject('/pet/{petId}')
94
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
95
+ */
96
+ static toObject(path: string, {
97
+ type,
98
+ replacer,
99
+ stringify,
100
+ casing
101
+ }?: ObjectOptions): URLObject | string;
102
+ }
103
+ //#endregion
5
104
  //#region src/reporters/cliReporter.d.ts
6
105
  /**
7
106
  * The default `cli` reporter. Renders the {@link Report} for each config as it finishes, independent
@@ -83,5 +182,5 @@ declare const fsStorage: (options?: Record<string, never> | undefined) => Storag
83
182
  */
84
183
  declare const memoryStorage: (options?: Record<string, never> | undefined) => Storage;
85
184
  //#endregion
86
- export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, BuildOutput, CLIOptions, Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, InputData, InputPath, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, type UpdateDiagnostic, UserConfig, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
185
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, AsyncEventEmitter, type BannerMeta, BuildOutput, CLIOptions, Config, type Diagnostic, type DiagnosticByCode, type DiagnosticDoc, type DiagnosticKind, type DiagnosticLocation, type DiagnosticSeverity, Diagnostics, type Exclude, type FileProcessorHooks, type GenerationResult, type Generator, type GeneratorContext, type Group, type Include, InputData, InputPath, type Kubb, KubbBuildEndContext, KubbBuildStartContext, KubbDiagnosticContext, KubbDriver, KubbErrorContext, KubbFileProcessingUpdate, KubbFilesProcessingEndContext, KubbFilesProcessingStartContext, KubbFilesProcessingUpdateContext, KubbGenerationEndContext, KubbGenerationStartContext, KubbHookEndContext, KubbHookLineContext, KubbHookStartContext, KubbHooks, KubbInfoContext, KubbLifecycleStartContext, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, KubbPluginsEndContext, KubbSuccessContext, KubbWarnContext, type NormalizedPlugin, type Output, type OutputMode, type OutputOptions, type Override, type ParsedFile, type Parser, type PerformanceDiagnostic, type Plugin, type PluginFactoryOptions, PossibleConfig, type ProblemCode, type ProblemDiagnostic, type Renderer, type RendererFactory, type Reporter, type ReporterContext, type ReporterName, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type SerializedDiagnostic, type Storage, type UpdateDiagnostic, Url, UserConfig, type UserReporter, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
87
186
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { stripVTControlCharacters, styleText } from "node:util";
5
5
  import { access, glob, mkdir, readFile, rm, writeFile } from "node:fs/promises";
6
6
  import path, { dirname, join, relative, resolve } from "node:path";
7
7
  import * as ast from "@kubb/ast";
8
- import { collectUsedSchemaNames, createFile, createStreamInput, isOperationNode, isSchemaNode, transform } from "@kubb/ast";
8
+ import { collectUsedSchemaNames, createFile, createStreamInput, operationDef, schemaDef, transform } from "@kubb/ast";
9
9
  import { AsyncLocalStorage } from "node:async_hooks";
10
10
  import process$1 from "node:process";
11
11
  //#region ../../internals/utils/src/time.ts
@@ -607,7 +607,7 @@ function createAdapter(build) {
607
607
  /**
608
608
  * Docs major, derived from the package version so the link tracks the published major.
609
609
  */
610
- const docsMajor = "5.0.0-beta.55".split(".")[0] ?? "5";
610
+ const docsMajor = "5.0.0-beta.57".split(".")[0] ?? "5";
611
611
  /**
612
612
  * Narrows a {@link Diagnostic} to the variant for `code`, or `null` when it does not match.
613
613
  *
@@ -1168,7 +1168,7 @@ function defaultResolver(name, type) {
1168
1168
  */
1169
1169
  const resolveOptionsCache = /* @__PURE__ */ new WeakMap();
1170
1170
  function computeOptions(node, options, exclude, include, override) {
1171
- if (isOperationNode(node)) {
1171
+ if (operationDef.is(node)) {
1172
1172
  if (exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
1173
1173
  if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
1174
1174
  const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options;
@@ -1177,7 +1177,7 @@ function computeOptions(node, options, exclude, include, override) {
1177
1177
  ...overrideOptions
1178
1178
  };
1179
1179
  }
1180
- if (isSchemaNode(node)) {
1180
+ if (schemaDef.is(node)) {
1181
1181
  if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) return null;
1182
1182
  if (include) {
1183
1183
  const applicable = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern)).filter((result) => result !== null);
@@ -2881,6 +2881,6 @@ function defineParser(parser) {
2881
2881
  return parser;
2882
2882
  }
2883
2883
  //#endregion
2884
- export { AsyncEventEmitter, Diagnostics, KubbDriver, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
2884
+ export { AsyncEventEmitter, Diagnostics, KubbDriver, Url, ast, cliReporter, createAdapter, createKubb, createRenderer, createReporter, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fileReporter, fsStorage, jsonReporter, logLevel, memoryStorage };
2885
2885
 
2886
2886
  //# sourceMappingURL=index.js.map