@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.js
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { Diagnostics, Resolver, addGenerator, ast, containsCircularRef, createResolver, defineExtension, defineGenerator, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
2
|
+
import { Diagnostics, Resolver, addGenerator, ast, camelCase, containsCircularRef, createResolver, defineExtension, defineGenerator, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
3
3
|
import { File, Function, jsxRenderer } from "kubb/jsx";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
5
5
|
import { buildParams, enumTypeName, pluginTsName } from "@kubb/plugin-ts";
|
|
6
|
-
// ../../internals/utils/src/casing.ts
|
|
7
|
-
/**
|
|
8
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
9
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
10
|
-
* and capitalizes each word according to `pascal`.
|
|
11
|
-
*
|
|
12
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
13
|
-
*/
|
|
14
|
-
function convert(text, pascal) {
|
|
15
|
-
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) => {
|
|
16
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
17
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
18
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
19
|
-
}
|
|
20
|
-
const cache = /* @__PURE__ */ new Map();
|
|
21
|
-
const cacheLimit = 1e4;
|
|
22
|
-
function toCamelOrPascal(text, pascal) {
|
|
23
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
24
|
-
const cached = cache.get(key);
|
|
25
|
-
if (cached !== void 0) return cached;
|
|
26
|
-
const result = convert(text, pascal);
|
|
27
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
28
|
-
cache.set(key, result);
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Converts `text` to camelCase.
|
|
33
|
-
*
|
|
34
|
-
* @example Word boundaries
|
|
35
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
36
|
-
*
|
|
37
|
-
* @example With a prefix
|
|
38
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
39
|
-
*/
|
|
40
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
41
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
42
|
-
}
|
|
43
6
|
// ../../internals/utils/src/reserved.ts
|
|
44
7
|
/**
|
|
45
8
|
* JavaScript and Java reserved words.
|
|
@@ -826,7 +789,7 @@ function createOperationResponseResolver() {
|
|
|
826
789
|
*/
|
|
827
790
|
function createCasedFile(caseLast) {
|
|
828
791
|
return { baseName({ name, extname }) {
|
|
829
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
792
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
830
793
|
} };
|
|
831
794
|
}
|
|
832
795
|
// ../../internals/shared/src/group.ts
|
|
@@ -1502,7 +1465,7 @@ var compatibility = {
|
|
|
1502
1465
|
"node": ">=22.22"
|
|
1503
1466
|
};
|
|
1504
1467
|
// package.json
|
|
1505
|
-
var version = "5.2.
|
|
1468
|
+
var version = "5.2.3";
|
|
1506
1469
|
// src/resolvers/resolverFaker.ts
|
|
1507
1470
|
/**
|
|
1508
1471
|
* Default resolver used by `@kubb/plugin-faker`. Decides the names and file
|
|
@@ -1519,7 +1482,7 @@ var version = "5.2.2";
|
|
|
1519
1482
|
const resolverFaker = createResolver({
|
|
1520
1483
|
pluginName: "plugin-faker",
|
|
1521
1484
|
name(name) {
|
|
1522
|
-
return ensureValidVarName(camelCase(name, { prefix: "create" }));
|
|
1485
|
+
return this.memo(`name:${name}`, () => ensureValidVarName(camelCase(name, { prefix: "create" })));
|
|
1523
1486
|
},
|
|
1524
1487
|
file: createCasedFile((part) => camelCase(part, { prefix: "create" })),
|
|
1525
1488
|
param: createOperationParamResolver(),
|