@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.cjs
CHANGED
|
@@ -17,59 +17,20 @@ 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");
|
|
25
25
|
// ../../internals/utils/src/casing.ts
|
|
26
|
+
const wordStart = /(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/;
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
32
|
-
*/
|
|
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) => {
|
|
35
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
36
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
37
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
38
|
-
}
|
|
39
|
-
const cache = /* @__PURE__ */ new Map();
|
|
40
|
-
const cacheLimit = 1e4;
|
|
41
|
-
function toCamelOrPascal(text, pascal) {
|
|
42
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
43
|
-
const cached = cache.get(key);
|
|
44
|
-
if (cached !== void 0) return cached;
|
|
45
|
-
const result = convert(text, pascal);
|
|
46
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
47
|
-
cache.set(key, result);
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Converts `text` to camelCase.
|
|
52
|
-
*
|
|
53
|
-
* @example Word boundaries
|
|
54
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
55
|
-
*
|
|
56
|
-
* @example With a prefix
|
|
57
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
58
|
-
*/
|
|
59
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
60
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Converts `text` to PascalCase.
|
|
64
|
-
*
|
|
65
|
-
* @example Word boundaries
|
|
66
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
67
|
-
*
|
|
68
|
-
* @example With a suffix
|
|
69
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
28
|
+
* Splits `text` into words on separators (whitespace, hyphens, underscores, dots, slashes, colons)
|
|
29
|
+
* and on {@link wordStart}. A segment without lowercase letters, such as `COOL` or `2D`, is one word,
|
|
30
|
+
* so snake case leaves a name that is already in it unchanged.
|
|
70
31
|
*/
|
|
71
|
-
function
|
|
72
|
-
return
|
|
32
|
+
function words(text) {
|
|
33
|
+
return text.split(/[\s\-_./\\:]+/).filter(Boolean).flatMap((segment) => segment === segment.toUpperCase() ? segment : segment.split(wordStart));
|
|
73
34
|
}
|
|
74
35
|
/**
|
|
75
36
|
* Converts `text` to snake_case.
|
|
@@ -81,7 +42,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
|
81
42
|
* `snakeCase('Hello-World') // 'hello_world'`
|
|
82
43
|
*/
|
|
83
44
|
function snakeCase(text, { prefix = "", suffix = "" } = {}) {
|
|
84
|
-
return `${prefix} ${text} ${suffix}
|
|
45
|
+
return words(`${prefix} ${text} ${suffix}`).map((word) => word.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()).filter(Boolean).join("_");
|
|
85
46
|
}
|
|
86
47
|
/**
|
|
87
48
|
* Converts `text` to SCREAMING_SNAKE_CASE.
|
|
@@ -301,9 +262,9 @@ function jsDocEscape(input) {
|
|
|
301
262
|
* @example Suffix applied to the final segment only
|
|
302
263
|
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
303
264
|
*/
|
|
304
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
265
|
+
function toFilePath(name, caseLast = kubb_kit.camelCase) {
|
|
305
266
|
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
306
|
-
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("/");
|
|
307
268
|
}
|
|
308
269
|
// src/factory.ts
|
|
309
270
|
var factory_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -559,8 +520,8 @@ function applyEnumKeyCasing(key, casing = "none") {
|
|
|
559
520
|
if (casing === "none") return key;
|
|
560
521
|
if (casing === "screamingSnakeCase") return screamingSnakeCase(key);
|
|
561
522
|
if (casing === "snakeCase") return snakeCase(key);
|
|
562
|
-
if (casing === "pascalCase") return pascalCase(key);
|
|
563
|
-
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);
|
|
564
525
|
return key;
|
|
565
526
|
}
|
|
566
527
|
/**
|
|
@@ -817,7 +778,7 @@ function buildIndexSignatures(node, propertyCount, printNode) {
|
|
|
817
778
|
function getEnumNames({ node, enum: enumOptions, resolver }) {
|
|
818
779
|
const resolved = resolver.name(node.name);
|
|
819
780
|
return {
|
|
820
|
-
enumName: enumOptions.constCasing === "pascalCase" ? resolved : ensureValidVarName(camelCase(node.name)),
|
|
781
|
+
enumName: enumOptions.constCasing === "pascalCase" ? resolved : ensureValidVarName((0, kubb_kit.camelCase)(node.name)),
|
|
821
782
|
typeName: enumOptions.type === "asConst" ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved
|
|
822
783
|
};
|
|
823
784
|
}
|
|
@@ -1211,7 +1172,7 @@ function createOperationResponseResolver() {
|
|
|
1211
1172
|
*/
|
|
1212
1173
|
function createCasedFile(caseLast) {
|
|
1213
1174
|
return { baseName({ name, extname }) {
|
|
1214
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
1175
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
1215
1176
|
} };
|
|
1216
1177
|
}
|
|
1217
1178
|
// ../../internals/shared/src/group.ts
|
|
@@ -1237,7 +1198,7 @@ function createGroupConfig(group) {
|
|
|
1237
1198
|
if (!group) return null;
|
|
1238
1199
|
const defaultName = (ctx) => {
|
|
1239
1200
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
1240
|
-
return camelCase(ctx.group);
|
|
1201
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
1241
1202
|
};
|
|
1242
1203
|
return {
|
|
1243
1204
|
...group,
|
|
@@ -1918,7 +1879,7 @@ var compatibility = {
|
|
|
1918
1879
|
"node": ">=22.22"
|
|
1919
1880
|
};
|
|
1920
1881
|
// package.json
|
|
1921
|
-
var version = "5.3.
|
|
1882
|
+
var version = "5.3.3";
|
|
1922
1883
|
// src/resolvers/resolverTs.ts
|
|
1923
1884
|
/**
|
|
1924
1885
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|
|
@@ -1941,9 +1902,9 @@ var version = "5.3.1";
|
|
|
1941
1902
|
const resolverTs = (0, kubb_kit.createResolver)({
|
|
1942
1903
|
pluginName: "plugin-ts",
|
|
1943
1904
|
name(name) {
|
|
1944
|
-
return ensureValidVarName(pascalCase(name));
|
|
1905
|
+
return this.memo(`name:${name}`, () => ensureValidVarName((0, kubb_kit.pascalCase)(name)));
|
|
1945
1906
|
},
|
|
1946
|
-
file: createCasedFile(pascalCase),
|
|
1907
|
+
file: createCasedFile(kubb_kit.pascalCase),
|
|
1947
1908
|
param: createOperationParamResolver(),
|
|
1948
1909
|
response: {
|
|
1949
1910
|
...createOperationResponseResolver(),
|