@kubb/plugin-ts 5.3.2 → 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 +11 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -51
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -17,8 +17,8 @@ var __exportAll = (all, no_symbols) => {
|
|
|
17
17
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
18
|
return target;
|
|
19
19
|
};
|
|
20
|
-
let kubb_jsx = require("kubb/jsx");
|
|
21
20
|
let kubb_kit = require("kubb/kit");
|
|
21
|
+
let kubb_jsx = require("kubb/jsx");
|
|
22
22
|
let yuku_codegen = require("yuku-codegen");
|
|
23
23
|
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
24
24
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
@@ -33,53 +33,6 @@ function words(text) {
|
|
|
33
33
|
return text.split(/[\s\-_./\\:]+/).filter(Boolean).flatMap((segment) => segment === segment.toUpperCase() ? segment : segment.split(wordStart));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
37
|
-
* Capitalizes each word from {@link words} according to `pascal`.
|
|
38
|
-
*
|
|
39
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
40
|
-
*/
|
|
41
|
-
function convert(text, pascal) {
|
|
42
|
-
return words(text).flatMap((word) => word.split(/(?<=\d)(?=[a-z])|(?<=[A-Z])(?=[A-Z][a-z])/)).map((word, i) => {
|
|
43
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
44
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
45
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
46
|
-
}
|
|
47
|
-
const cache = /* @__PURE__ */ new Map();
|
|
48
|
-
const cacheLimit = 1e4;
|
|
49
|
-
function toCamelOrPascal(text, pascal) {
|
|
50
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
51
|
-
const cached = cache.get(key);
|
|
52
|
-
if (cached !== void 0) return cached;
|
|
53
|
-
const result = convert(text, pascal);
|
|
54
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
55
|
-
cache.set(key, result);
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Converts `text` to camelCase.
|
|
60
|
-
*
|
|
61
|
-
* @example Word boundaries
|
|
62
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
63
|
-
*
|
|
64
|
-
* @example With a prefix
|
|
65
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
66
|
-
*/
|
|
67
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
68
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Converts `text` to PascalCase.
|
|
72
|
-
*
|
|
73
|
-
* @example Word boundaries
|
|
74
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
75
|
-
*
|
|
76
|
-
* @example With a suffix
|
|
77
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
78
|
-
*/
|
|
79
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
80
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
36
|
* Converts `text` to snake_case.
|
|
84
37
|
*
|
|
85
38
|
* @example From camelCase
|
|
@@ -309,9 +262,9 @@ function jsDocEscape(input) {
|
|
|
309
262
|
* @example Suffix applied to the final segment only
|
|
310
263
|
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
311
264
|
*/
|
|
312
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
265
|
+
function toFilePath(name, caseLast = kubb_kit.camelCase) {
|
|
313
266
|
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
314
|
-
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
|
|
267
|
+
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : (0, kubb_kit.camelCase)(part)).filter(Boolean).join("/");
|
|
315
268
|
}
|
|
316
269
|
// src/factory.ts
|
|
317
270
|
var factory_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -567,8 +520,8 @@ function applyEnumKeyCasing(key, casing = "none") {
|
|
|
567
520
|
if (casing === "none") return key;
|
|
568
521
|
if (casing === "screamingSnakeCase") return screamingSnakeCase(key);
|
|
569
522
|
if (casing === "snakeCase") return snakeCase(key);
|
|
570
|
-
if (casing === "pascalCase") return pascalCase(key);
|
|
571
|
-
if (casing === "camelCase") return camelCase(key);
|
|
523
|
+
if (casing === "pascalCase") return (0, kubb_kit.pascalCase)(key);
|
|
524
|
+
if (casing === "camelCase") return (0, kubb_kit.camelCase)(key);
|
|
572
525
|
return key;
|
|
573
526
|
}
|
|
574
527
|
/**
|
|
@@ -825,7 +778,7 @@ function buildIndexSignatures(node, propertyCount, printNode) {
|
|
|
825
778
|
function getEnumNames({ node, enum: enumOptions, resolver }) {
|
|
826
779
|
const resolved = resolver.name(node.name);
|
|
827
780
|
return {
|
|
828
|
-
enumName: enumOptions.constCasing === "pascalCase" ? resolved : ensureValidVarName(camelCase(node.name)),
|
|
781
|
+
enumName: enumOptions.constCasing === "pascalCase" ? resolved : ensureValidVarName((0, kubb_kit.camelCase)(node.name)),
|
|
829
782
|
typeName: enumOptions.type === "asConst" ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved
|
|
830
783
|
};
|
|
831
784
|
}
|
|
@@ -1219,7 +1172,7 @@ function createOperationResponseResolver() {
|
|
|
1219
1172
|
*/
|
|
1220
1173
|
function createCasedFile(caseLast) {
|
|
1221
1174
|
return { baseName({ name, extname }) {
|
|
1222
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
1175
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
1223
1176
|
} };
|
|
1224
1177
|
}
|
|
1225
1178
|
// ../../internals/shared/src/group.ts
|
|
@@ -1245,7 +1198,7 @@ function createGroupConfig(group) {
|
|
|
1245
1198
|
if (!group) return null;
|
|
1246
1199
|
const defaultName = (ctx) => {
|
|
1247
1200
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
1248
|
-
return camelCase(ctx.group);
|
|
1201
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
1249
1202
|
};
|
|
1250
1203
|
return {
|
|
1251
1204
|
...group,
|
|
@@ -1926,7 +1879,7 @@ var compatibility = {
|
|
|
1926
1879
|
"node": ">=22.22"
|
|
1927
1880
|
};
|
|
1928
1881
|
// package.json
|
|
1929
|
-
var version = "5.3.
|
|
1882
|
+
var version = "5.3.3";
|
|
1930
1883
|
// src/resolvers/resolverTs.ts
|
|
1931
1884
|
/**
|
|
1932
1885
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|
|
@@ -1949,9 +1902,9 @@ var version = "5.3.2";
|
|
|
1949
1902
|
const resolverTs = (0, kubb_kit.createResolver)({
|
|
1950
1903
|
pluginName: "plugin-ts",
|
|
1951
1904
|
name(name) {
|
|
1952
|
-
return ensureValidVarName(pascalCase(name));
|
|
1905
|
+
return this.memo(`name:${name}`, () => ensureValidVarName((0, kubb_kit.pascalCase)(name)));
|
|
1953
1906
|
},
|
|
1954
|
-
file: createCasedFile(pascalCase),
|
|
1907
|
+
file: createCasedFile(kubb_kit.pascalCase),
|
|
1955
1908
|
param: createOperationParamResolver(),
|
|
1956
1909
|
response: {
|
|
1957
1910
|
...createOperationResponseResolver(),
|