@kubb/core 5.0.0-alpha.27 → 5.0.0-alpha.29

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
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { $ as createStorage, A as PrinterFactoryOptions, B as ResolverPathParams, C as PluginLifecycle, D as Preset, E as PluginWithLifeCycle, F as ResolvePathOptions, G as UserPluginWithLifeCycle, H as UserGroup, I as ResolvePathParams, J as CoreGeneratorV2, K as UserResolver, L as Resolver, M as ResolveBannerContext, N as ResolveNameParams, O as Presets, P as ResolveOptionsContext, Q as Storage, R as ResolverContext, S as PluginFactoryOptions, T as PluginParameter, U as UserLogger, V as UserConfig, W as UserPlugin, X as ReactGeneratorV2, Y as Generator, Z as defineGenerator, _ as LoggerOptions, a as AdapterSource, b as Plugin, c as Config, d as Group, et as formatters, f as Include, g as LoggerContext, h as Logger, i as AdapterFactoryOptions, it as AsyncEventEmitter, j as PrinterPartial, k as Printer, l as DevtoolsOptions, m as InputPath, n as getMode, nt as logLevel, o as BarrelType, p as InputData, q as KubbEvents, r as Adapter, rt as PossiblePromise, s as CompatibilityPreset, t as PluginDriver, tt as linters, u as Exclude, v as Output, w as PluginLifecycleHooks, x as PluginContext, y as Override, z as ResolverFileParams } from "./PluginDriver-B12z6KO-.js";
2
+ import { $ as createStorage, A as PrinterFactoryOptions, B as ResolverPathParams, C as PluginLifecycle, D as Preset, E as PluginWithLifeCycle, F as ResolvePathOptions, G as UserPluginWithLifeCycle, H as UserGroup, I as ResolvePathParams, J as CoreGeneratorV2, K as UserResolver, L as Resolver, M as ResolveBannerContext, N as ResolveNameParams, O as Presets, P as ResolveOptionsContext, Q as Storage, R as ResolverContext, S as PluginFactoryOptions, T as PluginParameter, U as UserLogger, V as UserConfig, W as UserPlugin, X as ReactGeneratorV2, Y as Generator, Z as defineGenerator, _ as LoggerOptions, a as AdapterSource, b as Plugin, c as Config, d as Group, et as formatters, f as Include, g as LoggerContext, h as Logger, i as AdapterFactoryOptions, it as AsyncEventEmitter, j as PrinterPartial, k as Printer, l as DevtoolsOptions, m as InputPath, n as getMode, nt as logLevel, o as BarrelType, p as InputData, q as KubbEvents, r as Adapter, rt as PossiblePromise, s as CompatibilityPreset, t as PluginDriver, tt as linters, u as Exclude, v as Output, w as PluginLifecycleHooks, x as PluginContext, y as Override, z as ResolverFileParams } from "./PluginDriver-C6VX0skO.js";
3
3
  import { composeTransformers, definePrinter } from "@kubb/ast";
4
4
  import { Node, OperationNode, RootNode, SchemaNode, Visitor } from "@kubb/ast/types";
5
5
  import { Fabric, FabricFile } from "@kubb/fabric-core/types";
@@ -476,13 +476,17 @@ declare function buildDefaultBanner({
476
476
  /**
477
477
  * Default banner resolver — returns the banner string for a generated file.
478
478
  *
479
- * - When `output.banner` is a function and `node` is provided, calls it with the node.
480
- * - When `output.banner` is a function and `node` is absent, falls back to the default Kubb banner.
479
+ * A user-supplied `output.banner` overrides the default Kubb "Generated by Kubb" notice.
480
+ * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`
481
+ * from the OAS spec when a `node` is provided).
482
+ *
483
+ * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.
484
+ * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.
481
485
  * - When `output.banner` is a string, returns it directly.
482
486
  * - When `config.output.defaultBanner` is `false`, returns `undefined`.
483
- * - Otherwise returns the default "Generated by Kubb" banner.
487
+ * - Otherwise returns the Kubb "Generated by Kubb" notice.
484
488
  *
485
- * @example String banner
489
+ * @example String banner overrides default
486
490
  * ```ts
487
491
  * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
488
492
  * // → '// my banner'
@@ -494,7 +498,13 @@ declare function buildDefaultBanner({
494
498
  * // → '// v3.0.0'
495
499
  * ```
496
500
  *
497
- * @example Disabled banner
501
+ * @example No user banner — Kubb notice with OAS metadata
502
+ * ```ts
503
+ * defaultResolveBanner(rootNode, { config })
504
+ * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
505
+ * ```
506
+ *
507
+ * @example Disabled default banner
498
508
  * ```ts
499
509
  * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
500
510
  * // → undefined
package/dist/index.js CHANGED
@@ -1413,7 +1413,7 @@ const fsStorage = createStorage(() => ({
1413
1413
  }));
1414
1414
  //#endregion
1415
1415
  //#region package.json
1416
- var version$1 = "5.0.0-alpha.27";
1416
+ var version$1 = "5.0.0-alpha.29";
1417
1417
  //#endregion
1418
1418
  //#region src/utils/diagnostics.ts
1419
1419
  /**
@@ -1874,6 +1874,7 @@ function matchesOperationPattern(node, type, pattern) {
1874
1874
  case "operationId": return !!node.operationId.match(pattern);
1875
1875
  case "path": return !!node.path.match(pattern);
1876
1876
  case "method": return !!node.method.toLowerCase().match(pattern);
1877
+ case "contentType": return !!node.requestBody?.contentType?.match(pattern);
1877
1878
  default: return false;
1878
1879
  }
1879
1880
  }
@@ -2074,13 +2075,17 @@ function buildDefaultBanner({ title, description, version, config }) {
2074
2075
  /**
2075
2076
  * Default banner resolver — returns the banner string for a generated file.
2076
2077
  *
2077
- * - When `output.banner` is a function and `node` is provided, calls it with the node.
2078
- * - When `output.banner` is a function and `node` is absent, falls back to the default Kubb banner.
2078
+ * A user-supplied `output.banner` overrides the default Kubb "Generated by Kubb" notice.
2079
+ * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`
2080
+ * from the OAS spec when a `node` is provided).
2081
+ *
2082
+ * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.
2083
+ * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.
2079
2084
  * - When `output.banner` is a string, returns it directly.
2080
2085
  * - When `config.output.defaultBanner` is `false`, returns `undefined`.
2081
- * - Otherwise returns the default "Generated by Kubb" banner.
2086
+ * - Otherwise returns the Kubb "Generated by Kubb" notice.
2082
2087
  *
2083
- * @example String banner
2088
+ * @example String banner overrides default
2084
2089
  * ```ts
2085
2090
  * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
2086
2091
  * // → '// my banner'
@@ -2092,17 +2097,27 @@ function buildDefaultBanner({ title, description, version, config }) {
2092
2097
  * // → '// v3.0.0'
2093
2098
  * ```
2094
2099
  *
2095
- * @example Disabled banner
2100
+ * @example No user banner — Kubb notice with OAS metadata
2101
+ * ```ts
2102
+ * defaultResolveBanner(rootNode, { config })
2103
+ * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
2104
+ * ```
2105
+ *
2106
+ * @example Disabled default banner
2096
2107
  * ```ts
2097
2108
  * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
2098
2109
  * // → undefined
2099
2110
  * ```
2100
2111
  */
2101
2112
  function defaultResolveBanner(node, { output, config }) {
2102
- if (typeof output?.banner === "function") return node ? output.banner(node) : buildDefaultBanner({ config });
2113
+ if (typeof output?.banner === "function") return output.banner(node);
2103
2114
  if (typeof output?.banner === "string") return output.banner;
2104
2115
  if (config.output.defaultBanner === false) return;
2105
- return buildDefaultBanner({ config });
2116
+ return buildDefaultBanner({
2117
+ title: node?.meta?.title,
2118
+ version: node?.meta?.version,
2119
+ config
2120
+ });
2106
2121
  }
2107
2122
  /**
2108
2123
  * Default footer resolver — returns the footer string for a generated file.