@kubb/plugin-faker 5.2.2 → 5.2.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 +7 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -41
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -7,43 +7,6 @@ let kubb_kit = require("kubb/kit");
|
|
|
7
7
|
let kubb_jsx = require("kubb/jsx");
|
|
8
8
|
let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
|
|
9
9
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
10
|
-
// ../../internals/utils/src/casing.ts
|
|
11
|
-
/**
|
|
12
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
13
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
14
|
-
* and capitalizes each word according to `pascal`.
|
|
15
|
-
*
|
|
16
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
17
|
-
*/
|
|
18
|
-
function convert(text, pascal) {
|
|
19
|
-
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) => {
|
|
20
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
21
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
22
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
23
|
-
}
|
|
24
|
-
const cache = /* @__PURE__ */ new Map();
|
|
25
|
-
const cacheLimit = 1e4;
|
|
26
|
-
function toCamelOrPascal(text, pascal) {
|
|
27
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
28
|
-
const cached = cache.get(key);
|
|
29
|
-
if (cached !== void 0) return cached;
|
|
30
|
-
const result = convert(text, pascal);
|
|
31
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
32
|
-
cache.set(key, result);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Converts `text` to camelCase.
|
|
37
|
-
*
|
|
38
|
-
* @example Word boundaries
|
|
39
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
40
|
-
*
|
|
41
|
-
* @example With a prefix
|
|
42
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
43
|
-
*/
|
|
44
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
45
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
46
|
-
}
|
|
47
10
|
// ../../internals/utils/src/reserved.ts
|
|
48
11
|
/**
|
|
49
12
|
* JavaScript and Java reserved words.
|
|
@@ -367,9 +330,9 @@ function getRelativePath(rootDir, filePath) {
|
|
|
367
330
|
* @example Suffix applied to the final segment only
|
|
368
331
|
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
369
332
|
*/
|
|
370
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
333
|
+
function toFilePath(name, caseLast = kubb_kit.camelCase) {
|
|
371
334
|
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
372
|
-
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
|
|
335
|
+
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : (0, kubb_kit.camelCase)(part)).filter(Boolean).join("/");
|
|
373
336
|
}
|
|
374
337
|
// src/utils.ts
|
|
375
338
|
/**
|
|
@@ -830,7 +793,7 @@ function createOperationResponseResolver() {
|
|
|
830
793
|
*/
|
|
831
794
|
function createCasedFile(caseLast) {
|
|
832
795
|
return { baseName({ name, extname }) {
|
|
833
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
796
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
834
797
|
} };
|
|
835
798
|
}
|
|
836
799
|
// ../../internals/shared/src/group.ts
|
|
@@ -856,7 +819,7 @@ function createGroupConfig(group) {
|
|
|
856
819
|
if (!group) return null;
|
|
857
820
|
const defaultName = (ctx) => {
|
|
858
821
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
859
|
-
return camelCase(ctx.group);
|
|
822
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
860
823
|
};
|
|
861
824
|
return {
|
|
862
825
|
...group,
|
|
@@ -1506,7 +1469,7 @@ var compatibility = {
|
|
|
1506
1469
|
"node": ">=22.22"
|
|
1507
1470
|
};
|
|
1508
1471
|
// package.json
|
|
1509
|
-
var version = "5.2.
|
|
1472
|
+
var version = "5.2.3";
|
|
1510
1473
|
// src/resolvers/resolverFaker.ts
|
|
1511
1474
|
/**
|
|
1512
1475
|
* Default resolver used by `@kubb/plugin-faker`. Decides the names and file
|
|
@@ -1523,9 +1486,9 @@ var version = "5.2.2";
|
|
|
1523
1486
|
const resolverFaker = (0, kubb_kit.createResolver)({
|
|
1524
1487
|
pluginName: "plugin-faker",
|
|
1525
1488
|
name(name) {
|
|
1526
|
-
return ensureValidVarName(camelCase(name, { prefix: "create" }));
|
|
1489
|
+
return this.memo(`name:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name, { prefix: "create" })));
|
|
1527
1490
|
},
|
|
1528
|
-
file: createCasedFile((part) => camelCase(part, { prefix: "create" })),
|
|
1491
|
+
file: createCasedFile((part) => (0, kubb_kit.camelCase)(part, { prefix: "create" })),
|
|
1529
1492
|
param: createOperationParamResolver(),
|
|
1530
1493
|
response: createOperationResponseResolver()
|
|
1531
1494
|
});
|