@kubb/core 5.17.1 → 5.18.1
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 +20 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2399,6 +2399,12 @@ type ResolveImportsOptions = {
|
|
|
2399
2399
|
* point enum refs at a suffixed type name. Defaults to the resolver's top-level `name`.
|
|
2400
2400
|
*/
|
|
2401
2401
|
name?: (schemaName: string) => string;
|
|
2402
|
+
/**
|
|
2403
|
+
* Also import the refs inside `conditionals`, `contains` and a string's `content`, for a plugin that prints those checks.
|
|
2404
|
+
*
|
|
2405
|
+
* @default false
|
|
2406
|
+
*/
|
|
2407
|
+
checks?: boolean;
|
|
2402
2408
|
};
|
|
2403
2409
|
/**
|
|
2404
2410
|
* The `file` field of a resolver: decides what a generated file is called and, optionally, where
|
|
@@ -2592,6 +2598,7 @@ export declare class Resolver {
|
|
|
2592
2598
|
* ```
|
|
2593
2599
|
*/
|
|
2594
2600
|
reserveNames(names: Iterable<string>): void;
|
|
2601
|
+
setTags(tags: InputMeta['tags']): void;
|
|
2595
2602
|
/**
|
|
2596
2603
|
* Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
|
|
2597
2604
|
* when the preferred name is taken. Array segment order and boundaries matter. String and array
|
|
@@ -2703,7 +2710,7 @@ type Output = {
|
|
|
2703
2710
|
type Group = {
|
|
2704
2711
|
/**
|
|
2705
2712
|
* Property used to assign each operation to a group.
|
|
2706
|
-
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`).
|
|
2713
|
+
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`), nested in the folders of its `parent` tags.
|
|
2707
2714
|
* - `'path'` uses the first segment of the operation's URL.
|
|
2708
2715
|
*/
|
|
2709
2716
|
type: 'tag' | 'path';
|
package/dist/index.d.ts
CHANGED
|
@@ -2399,6 +2399,12 @@ type ResolveImportsOptions = {
|
|
|
2399
2399
|
* point enum refs at a suffixed type name. Defaults to the resolver's top-level `name`.
|
|
2400
2400
|
*/
|
|
2401
2401
|
name?: (schemaName: string) => string;
|
|
2402
|
+
/**
|
|
2403
|
+
* Also import the refs inside `conditionals`, `contains` and a string's `content`, for a plugin that prints those checks.
|
|
2404
|
+
*
|
|
2405
|
+
* @default false
|
|
2406
|
+
*/
|
|
2407
|
+
checks?: boolean;
|
|
2402
2408
|
};
|
|
2403
2409
|
/**
|
|
2404
2410
|
* The `file` field of a resolver: decides what a generated file is called and, optionally, where
|
|
@@ -2592,6 +2598,7 @@ export declare class Resolver {
|
|
|
2592
2598
|
* ```
|
|
2593
2599
|
*/
|
|
2594
2600
|
reserveNames(names: Iterable<string>): void;
|
|
2601
|
+
setTags(tags: InputMeta['tags']): void;
|
|
2595
2602
|
/**
|
|
2596
2603
|
* Returns the same name for repeated declaration keys. Adds numeric suffixes starting at `2`
|
|
2597
2604
|
* when the preferred name is taken. Array segment order and boundaries matter. String and array
|
|
@@ -2703,7 +2710,7 @@ type Output = {
|
|
|
2703
2710
|
type Group = {
|
|
2704
2711
|
/**
|
|
2705
2712
|
* Property used to assign each operation to a group.
|
|
2706
|
-
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`).
|
|
2713
|
+
* - `'tag'` uses the first tag (`operation.getTags().at(0)?.name`), nested in the folders of its `parent` tags.
|
|
2707
2714
|
* - `'path'` uses the first segment of the operation's URL.
|
|
2708
2715
|
*/
|
|
2709
2716
|
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.1";
|
|
25
25
|
// ../../internals/utils/src/casing.ts
|
|
26
26
|
/**
|
|
27
27
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -31,7 +31,7 @@ var version = "5.17.1";
|
|
|
31
31
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
32
32
|
*/
|
|
33
33
|
function convert(text, pascal) {
|
|
34
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
34
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)(?!xx(?![a-z]))([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
35
35
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
36
36
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
37
37
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
@@ -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
|
|
@@ -1933,9 +1938,9 @@ var Resolver = class Resolver {
|
|
|
1933
1938
|
* reads the same ref set instead of re-scanning it per plugin.
|
|
1934
1939
|
*/
|
|
1935
1940
|
imports(options) {
|
|
1936
|
-
const { node, root, output, group, extname = ".ts", name } = options;
|
|
1941
|
+
const { node, root, output, group, extname = ".ts", name, checks } = options;
|
|
1937
1942
|
const resolveName = name ?? ((schemaName) => this.name(schemaName));
|
|
1938
|
-
return collectImportedRefNames(node).map((schemaName) => ast.factory.createImport({
|
|
1943
|
+
return collectImportedRefNames(node, { checks }).map((schemaName) => ast.factory.createImport({
|
|
1939
1944
|
name: [resolveName(schemaName)],
|
|
1940
1945
|
path: this.#resolveFilePath({
|
|
1941
1946
|
name: schemaName,
|
|
@@ -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;
|