@kubb/plugin-fetch 5.10.0 → 5.10.1
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 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -53
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -236,55 +236,6 @@ function getOperationSuccessResponses(node) {
|
|
|
236
236
|
function getPrimarySuccessResponse(node) {
|
|
237
237
|
return getOperationSuccessResponses(node)[0] ?? null;
|
|
238
238
|
}
|
|
239
|
-
// ../../internals/utils/src/casing.ts
|
|
240
|
-
/**
|
|
241
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
242
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
243
|
-
* and capitalizes each word according to `pascal`.
|
|
244
|
-
*
|
|
245
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
246
|
-
*/
|
|
247
|
-
function convert(text, pascal) {
|
|
248
|
-
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) => {
|
|
249
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
250
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
251
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
252
|
-
}
|
|
253
|
-
const cache = /* @__PURE__ */ new Map();
|
|
254
|
-
const cacheLimit = 1e4;
|
|
255
|
-
function toCamelOrPascal(text, pascal) {
|
|
256
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
257
|
-
const cached = cache.get(key);
|
|
258
|
-
if (cached !== void 0) return cached;
|
|
259
|
-
const result = convert(text, pascal);
|
|
260
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
261
|
-
cache.set(key, result);
|
|
262
|
-
return result;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Converts `text` to camelCase.
|
|
266
|
-
*
|
|
267
|
-
* @example Word boundaries
|
|
268
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
269
|
-
*
|
|
270
|
-
* @example With a prefix
|
|
271
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
272
|
-
*/
|
|
273
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
274
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Converts `text` to PascalCase.
|
|
278
|
-
*
|
|
279
|
-
* @example Word boundaries
|
|
280
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
281
|
-
*
|
|
282
|
-
* @example With a suffix
|
|
283
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
284
|
-
*/
|
|
285
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
286
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
287
|
-
}
|
|
288
239
|
// ../../internals/utils/src/reserved.ts
|
|
289
240
|
/**
|
|
290
241
|
* JavaScript and Java reserved words.
|
|
@@ -441,8 +392,11 @@ function buildJSDoc(comments, options = {}) {
|
|
|
441
392
|
return `/**\n${comments.map((c) => `${indent}${c}`).join("\n")}\n */${suffix}`;
|
|
442
393
|
}
|
|
443
394
|
// ../../internals/shared/src/resolver.ts
|
|
395
|
+
/**
|
|
396
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
397
|
+
*/
|
|
444
398
|
function resolveOperationName(name) {
|
|
445
|
-
return ensureValidVarName(camelCase(name));
|
|
399
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
446
400
|
}
|
|
447
401
|
/**
|
|
448
402
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -485,7 +439,7 @@ function createGroupConfig(group) {
|
|
|
485
439
|
if (!group) return null;
|
|
486
440
|
const defaultName = (ctx) => {
|
|
487
441
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
488
|
-
return camelCase(ctx.group);
|
|
442
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
489
443
|
};
|
|
490
444
|
return {
|
|
491
445
|
...group,
|
|
@@ -925,6 +879,7 @@ function toZodTypeResolver(resolver) {
|
|
|
925
879
|
return {
|
|
926
880
|
...resolver,
|
|
927
881
|
file: resolver.file.bind(resolver),
|
|
882
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
928
883
|
param: {
|
|
929
884
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
930
885
|
path: (node, p) => type(resolver.param.path(node, p)),
|
|
@@ -1295,7 +1250,7 @@ function buildControllers(nodes, ctx, types) {
|
|
|
1295
1250
|
return nodes.reduce((acc, operationNode) => {
|
|
1296
1251
|
if (!kubb_kit.ast.isHttpOperationNode(operationNode)) return acc;
|
|
1297
1252
|
const tag = operationNode.tags[0];
|
|
1298
|
-
const name = tag ? group?.name?.({ group: camelCase(tag) }) ?? resolver.groupName(tag) : resolver.className("ApiClient");
|
|
1253
|
+
const name = tag ? ensureValidVarName(group?.name?.({ group: (0, kubb_kit.camelCase)(tag) }) ?? resolver.groupName(tag)) : resolver.className("ApiClient");
|
|
1299
1254
|
const file = resolver.file({
|
|
1300
1255
|
name,
|
|
1301
1256
|
extname: ".ts",
|
|
@@ -1519,13 +1474,13 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1519
1474
|
pluginName: "plugin-contract-client",
|
|
1520
1475
|
name: resolveOperationName,
|
|
1521
1476
|
className(name) {
|
|
1522
|
-
return ensureValidVarName(pascalCase(name));
|
|
1477
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(name));
|
|
1523
1478
|
},
|
|
1524
1479
|
groupName(name) {
|
|
1525
|
-
return ensureValidVarName(pascalCase(`${name} Client`));
|
|
1480
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
|
|
1526
1481
|
},
|
|
1527
1482
|
propertyName(name) {
|
|
1528
|
-
return ensureValidVarName(camelCase(name));
|
|
1483
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name));
|
|
1529
1484
|
}
|
|
1530
1485
|
});
|
|
1531
1486
|
// src/generators/clientGenerator.tsx
|
|
@@ -1541,7 +1496,7 @@ var compatibility = {
|
|
|
1541
1496
|
"node": ">=22.22"
|
|
1542
1497
|
};
|
|
1543
1498
|
// package.json
|
|
1544
|
-
var version = "5.10.
|
|
1499
|
+
var version = "5.10.1";
|
|
1545
1500
|
// src/templates.ts
|
|
1546
1501
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|
|
1547
1502
|
const fetchClientTemplatePath = (0, node_url.fileURLToPath)(new URL("../templates/fetch.ts", require("url").pathToFileURL(__filename).href));
|