@kubb/core 5.17.0 → 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 +17 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2592,6 +2592,7 @@ export declare class Resolver {
|
|
|
2592
2592
|
* ```
|
|
2593
2593
|
*/
|
|
2594
2594
|
reserveNames(names: Iterable<string>): void;
|
|
2595
|
+
setTags(tags: InputMeta['tags']): void;
|
|
2595
2596
|
/**
|
|
2596
2597
|
* Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
|
|
2597
2598
|
* when the preferred name is taken. Array segment order and boundaries matter. String and array
|
|
@@ -2703,7 +2704,7 @@ type Output = {
|
|
|
2703
2704
|
type Group = {
|
|
2704
2705
|
/**
|
|
2705
2706
|
* Property used to assign each operation to a group.
|
|
2706
|
-
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`).
|
|
2707
|
+
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`), nested in the folders of its `parent` tags.
|
|
2707
2708
|
* - `'path'` uses the first segment of the operation's URL.
|
|
2708
2709
|
*/
|
|
2709
2710
|
type: 'tag' | 'path';
|
package/dist/index.d.ts
CHANGED
|
@@ -2592,6 +2592,7 @@ export declare class Resolver {
|
|
|
2592
2592
|
* ```
|
|
2593
2593
|
*/
|
|
2594
2594
|
reserveNames(names: Iterable<string>): void;
|
|
2595
|
+
setTags(tags: InputMeta['tags']): void;
|
|
2595
2596
|
/**
|
|
2596
2597
|
* Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
|
|
2597
2598
|
* when the preferred name is taken. Array segment order and boundaries matter. String and array
|
|
@@ -2703,7 +2704,7 @@ type Output = {
|
|
|
2703
2704
|
type Group = {
|
|
2704
2705
|
/**
|
|
2705
2706
|
* Property used to assign each operation to a group.
|
|
2706
|
-
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`).
|
|
2707
|
+
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`), nested in the folders of its `parent` tags.
|
|
2707
2708
|
* - `'path'` uses the first segment of the operation's URL.
|
|
2708
2709
|
*/
|
|
2709
2710
|
type: 'tag' | 'path';
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __name = (target, value) => __defProp(target, "name", {
|
|
|
21
21
|
configurable: true
|
|
22
22
|
});
|
|
23
23
|
// package.json
|
|
24
|
-
var version = "5.
|
|
24
|
+
var version = "5.18.0";
|
|
25
25
|
// ../../internals/utils/src/casing.ts
|
|
26
26
|
/**
|
|
27
27
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -1846,6 +1846,7 @@ var Resolver = class Resolver {
|
|
|
1846
1846
|
#options;
|
|
1847
1847
|
#memo = /* @__PURE__ */ new Map();
|
|
1848
1848
|
#usedNames = /* @__PURE__ */ new Set();
|
|
1849
|
+
#tagParents = /* @__PURE__ */ new Map();
|
|
1849
1850
|
#baseName;
|
|
1850
1851
|
#filePath;
|
|
1851
1852
|
constructor(options) {
|
|
@@ -1888,6 +1889,10 @@ var Resolver = class Resolver {
|
|
|
1888
1889
|
reserveNames(names) {
|
|
1889
1890
|
for (const name of names) this.#usedNames.add(name);
|
|
1890
1891
|
}
|
|
1892
|
+
setTags(tags) {
|
|
1893
|
+
this.#tagParents.clear();
|
|
1894
|
+
for (const { name, parent } of tags ?? []) if (parent) this.#tagParents.set(name, parent);
|
|
1895
|
+
}
|
|
1891
1896
|
/**
|
|
1892
1897
|
* Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
|
|
1893
1898
|
* when the preferred name is taken. Array segment order and boundaries matter. String and array
|
|
@@ -1989,13 +1994,17 @@ var Resolver = class Resolver {
|
|
|
1989
1994
|
}
|
|
1990
1995
|
}
|
|
1991
1996
|
/**
|
|
1992
|
-
* A custom `group.name` wins; otherwise `tag` groups use the camelCased tag
|
|
1993
|
-
* groups use the first non-traversal segment (`''`
|
|
1994
|
-
* the output root, kept safe by the caller's boundary check).
|
|
1997
|
+
* A custom `group.name` wins; otherwise `tag` groups use the camelCased tag, nested in the
|
|
1998
|
+
* folders of its `parent` tags, and `path` groups use the first non-traversal segment (`''`
|
|
1999
|
+
* when none remain, placing the file in the output root, kept safe by the caller's boundary check).
|
|
1995
2000
|
*/
|
|
1996
|
-
|
|
2001
|
+
#resolveGroupDir(group, groupValue) {
|
|
1997
2002
|
if (group.name) return group.name({ group: groupValue });
|
|
1998
|
-
if (group.type === "tag")
|
|
2003
|
+
if (group.type === "tag") {
|
|
2004
|
+
const chain = [groupValue];
|
|
2005
|
+
for (let parent = this.#tagParents.get(groupValue); parent && !chain.includes(parent); parent = this.#tagParents.get(parent)) chain.unshift(parent);
|
|
2006
|
+
return path.join(...chain.map((tag) => camelCase(tag)));
|
|
2007
|
+
}
|
|
1999
2008
|
const segment = groupValue.split("/").filter((part) => part !== "" && part !== "." && part !== "..")[0];
|
|
2000
2009
|
return segment ? camelCase(segment) : "";
|
|
2001
2010
|
}
|
|
@@ -2008,7 +2017,7 @@ var Resolver = class Resolver {
|
|
|
2008
2017
|
if (output.mode !== "directory") return path.resolve(root, output.path);
|
|
2009
2018
|
const outputDir = path.resolve(root, output.path);
|
|
2010
2019
|
const groupValue = group?.type === "path" ? groupPath : tag;
|
|
2011
|
-
const result = group && groupValue ? path.resolve(outputDir,
|
|
2020
|
+
const result = group && groupValue ? path.resolve(outputDir, this.#resolveGroupDir(group, groupValue), baseName) : path.resolve(outputDir, baseName);
|
|
2012
2021
|
assertInside({
|
|
2013
2022
|
target: result,
|
|
2014
2023
|
parent: outputDir,
|
|
@@ -2796,6 +2805,7 @@ var KubbDriver = class {
|
|
|
2796
2805
|
for (const plugin of this.plugins.values()) {
|
|
2797
2806
|
this.options.signal?.throwIfAborted();
|
|
2798
2807
|
plugin.options = normalizePluginOptions(plugin.options, plugin.name);
|
|
2808
|
+
plugin.resolver.setTags(this.inputNode?.meta.tags);
|
|
2799
2809
|
}
|
|
2800
2810
|
if (this.adapter && this.inputNode) {
|
|
2801
2811
|
const { meta, schemas, operations } = this.inputNode;
|