@kubb/core 5.17.1 → 5.18.0

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.cjs CHANGED
@@ -45,7 +45,7 @@ let node_readline = require("node:readline");
45
45
  let node_url = require("node:url");
46
46
  let node_module = require("node:module");
47
47
  // package.json
48
- var version = "5.17.1";
48
+ var version = "5.18.0";
49
49
  // ../../internals/utils/src/casing.ts
50
50
  /**
51
51
  * Shared implementation for camelCase and PascalCase conversion.
@@ -1870,6 +1870,7 @@ var Resolver = class Resolver {
1870
1870
  #options;
1871
1871
  #memo = /* @__PURE__ */ new Map();
1872
1872
  #usedNames = /* @__PURE__ */ new Set();
1873
+ #tagParents = /* @__PURE__ */ new Map();
1873
1874
  #baseName;
1874
1875
  #filePath;
1875
1876
  constructor(options) {
@@ -1912,6 +1913,10 @@ var Resolver = class Resolver {
1912
1913
  reserveNames(names) {
1913
1914
  for (const name of names) this.#usedNames.add(name);
1914
1915
  }
1916
+ setTags(tags) {
1917
+ this.#tagParents.clear();
1918
+ for (const { name, parent } of tags ?? []) if (parent) this.#tagParents.set(name, parent);
1919
+ }
1915
1920
  /**
1916
1921
  * Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
1917
1922
  * when the preferred name is taken. Array segment order and boundaries matter. String and array
@@ -2013,13 +2018,17 @@ var Resolver = class Resolver {
2013
2018
  }
2014
2019
  }
2015
2020
  /**
2016
- * A custom `group.name` wins; otherwise `tag` groups use the camelCased tag and `path`
2017
- * groups use the first non-traversal segment (`''` when none remain, placing the file in
2018
- * the output root, kept safe by the caller's boundary check).
2021
+ * A custom `group.name` wins; otherwise `tag` groups use the camelCased tag, nested in the
2022
+ * folders of its `parent` tags, and `path` groups use the first non-traversal segment (`''`
2023
+ * when none remain, placing the file in the output root, kept safe by the caller's boundary check).
2019
2024
  */
2020
- static #resolveGroupDir(group, groupValue) {
2025
+ #resolveGroupDir(group, groupValue) {
2021
2026
  if (group.name) return group.name({ group: groupValue });
2022
- if (group.type === "tag") return camelCase(groupValue);
2027
+ if (group.type === "tag") {
2028
+ const chain = [groupValue];
2029
+ for (let parent = this.#tagParents.get(groupValue); parent && !chain.includes(parent); parent = this.#tagParents.get(parent)) chain.unshift(parent);
2030
+ return node_path.default.join(...chain.map((tag) => camelCase(tag)));
2031
+ }
2023
2032
  const segment = groupValue.split("/").filter((part) => part !== "" && part !== "." && part !== "..")[0];
2024
2033
  return segment ? camelCase(segment) : "";
2025
2034
  }
@@ -2032,7 +2041,7 @@ var Resolver = class Resolver {
2032
2041
  if (output.mode !== "directory") return node_path.default.resolve(root, output.path);
2033
2042
  const outputDir = node_path.default.resolve(root, output.path);
2034
2043
  const groupValue = group?.type === "path" ? groupPath : tag;
2035
- const result = group && groupValue ? node_path.default.resolve(outputDir, Resolver.#resolveGroupDir(group, groupValue), baseName) : node_path.default.resolve(outputDir, baseName);
2044
+ const result = group && groupValue ? node_path.default.resolve(outputDir, this.#resolveGroupDir(group, groupValue), baseName) : node_path.default.resolve(outputDir, baseName);
2036
2045
  assertInside({
2037
2046
  target: result,
2038
2047
  parent: outputDir,
@@ -2820,6 +2829,7 @@ var KubbDriver = class {
2820
2829
  for (const plugin of this.plugins.values()) {
2821
2830
  this.options.signal?.throwIfAborted();
2822
2831
  plugin.options = normalizePluginOptions(plugin.options, plugin.name);
2832
+ plugin.resolver.setTags(this.inputNode?.meta.tags);
2823
2833
  }
2824
2834
  if (this.adapter && this.inputNode) {
2825
2835
  const { meta, schemas, operations } = this.inputNode;