@kubb/plugin-ts 5.3.1 → 5.3.3
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 +18 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -50
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Resolver, addGenerator, ast, camelCase, createResolver, defineExtension, defineGenerator, isStringType, pascalCase, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
1
2
|
import { File, jsxRenderer } from "kubb/jsx";
|
|
2
|
-
import { Resolver, addGenerator, ast, createResolver, defineExtension, defineGenerator, isStringType, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
3
3
|
import { generate } from "yuku-codegen";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
5
5
|
import { parserTs } from "@kubb/parser-ts";
|
|
@@ -19,53 +19,14 @@ var __exportAll = (all, no_symbols) => {
|
|
|
19
19
|
return target;
|
|
20
20
|
};
|
|
21
21
|
// ../../internals/utils/src/casing.ts
|
|
22
|
+
const wordStart = /(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/;
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
28
|
-
*/
|
|
29
|
-
function convert(text, pascal) {
|
|
30
|
-
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) => {
|
|
31
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
32
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
33
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
34
|
-
}
|
|
35
|
-
const cache = /* @__PURE__ */ new Map();
|
|
36
|
-
const cacheLimit = 1e4;
|
|
37
|
-
function toCamelOrPascal(text, pascal) {
|
|
38
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
39
|
-
const cached = cache.get(key);
|
|
40
|
-
if (cached !== void 0) return cached;
|
|
41
|
-
const result = convert(text, pascal);
|
|
42
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
43
|
-
cache.set(key, result);
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Converts `text` to camelCase.
|
|
48
|
-
*
|
|
49
|
-
* @example Word boundaries
|
|
50
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
51
|
-
*
|
|
52
|
-
* @example With a prefix
|
|
53
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
54
|
-
*/
|
|
55
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
56
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Converts `text` to PascalCase.
|
|
60
|
-
*
|
|
61
|
-
* @example Word boundaries
|
|
62
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
63
|
-
*
|
|
64
|
-
* @example With a suffix
|
|
65
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
24
|
+
* Splits `text` into words on separators (whitespace, hyphens, underscores, dots, slashes, colons)
|
|
25
|
+
* and on {@link wordStart}. A segment without lowercase letters, such as `COOL` or `2D`, is one word,
|
|
26
|
+
* so snake case leaves a name that is already in it unchanged.
|
|
66
27
|
*/
|
|
67
|
-
function
|
|
68
|
-
return
|
|
28
|
+
function words(text) {
|
|
29
|
+
return text.split(/[\s\-_./\\:]+/).filter(Boolean).flatMap((segment) => segment === segment.toUpperCase() ? segment : segment.split(wordStart));
|
|
69
30
|
}
|
|
70
31
|
/**
|
|
71
32
|
* Converts `text` to snake_case.
|
|
@@ -77,7 +38,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
77
38
|
* `snakeCase('Hello-World') // 'hello_world'`
|
|
78
39
|
*/
|
|
79
40
|
function snakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
80
|
-
return `${prefix} ${text} ${suffix}
|
|
41
|
+
return words(`${prefix} ${text} ${suffix}`).map((word) => word.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()).filter(Boolean).join("_");
|
|
81
42
|
}
|
|
82
43
|
/**
|
|
83
44
|
* Converts `text` to SCREAMING_SNAKE_CASE.
|
|
@@ -1207,7 +1168,7 @@ function createOperationResponseResolver() {
|
|
|
1207
1168
|
*/
|
|
1208
1169
|
function createCasedFile(caseLast) {
|
|
1209
1170
|
return { baseName({ name, extname }) {
|
|
1210
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
1171
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
1211
1172
|
} };
|
|
1212
1173
|
}
|
|
1213
1174
|
// ../../internals/shared/src/group.ts
|
|
@@ -1914,7 +1875,7 @@ var compatibility = {
|
|
|
1914
1875
|
"node": ">=22.22"
|
|
1915
1876
|
};
|
|
1916
1877
|
// package.json
|
|
1917
|
-
var version = "5.3.
|
|
1878
|
+
var version = "5.3.3";
|
|
1918
1879
|
// src/resolvers/resolverTs.ts
|
|
1919
1880
|
/**
|
|
1920
1881
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|
|
@@ -1937,7 +1898,7 @@ var version = "5.3.1";
|
|
|
1937
1898
|
const resolverTs = createResolver({
|
|
1938
1899
|
pluginName: "plugin-ts",
|
|
1939
1900
|
name(name) {
|
|
1940
|
-
return ensureValidVarName(pascalCase(name));
|
|
1901
|
+
return this.memo(`name:${name}`, () => ensureValidVarName(pascalCase(name)));
|
|
1941
1902
|
},
|
|
1942
1903
|
file: createCasedFile(pascalCase),
|
|
1943
1904
|
param: createOperationParamResolver(),
|