@kubb/plugin-client 5.8.0 → 5.8.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 +10 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -52
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -235,55 +235,6 @@ function getOperationSuccessResponses(node) {
|
|
|
235
235
|
function getPrimarySuccessResponse(node) {
|
|
236
236
|
return getOperationSuccessResponses(node)[0] ?? null;
|
|
237
237
|
}
|
|
238
|
-
// ../../internals/utils/src/casing.ts
|
|
239
|
-
/**
|
|
240
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
241
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
242
|
-
* and capitalizes each word according to `pascal`.
|
|
243
|
-
*
|
|
244
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
245
|
-
*/
|
|
246
|
-
function convert(text, pascal) {
|
|
247
|
-
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) => {
|
|
248
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
249
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
250
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
251
|
-
}
|
|
252
|
-
const cache = /* @__PURE__ */ new Map();
|
|
253
|
-
const cacheLimit = 1e4;
|
|
254
|
-
function toCamelOrPascal(text, pascal) {
|
|
255
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
256
|
-
const cached = cache.get(key);
|
|
257
|
-
if (cached !== void 0) return cached;
|
|
258
|
-
const result = convert(text, pascal);
|
|
259
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
260
|
-
cache.set(key, result);
|
|
261
|
-
return result;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Converts `text` to camelCase.
|
|
265
|
-
*
|
|
266
|
-
* @example Word boundaries
|
|
267
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
268
|
-
*
|
|
269
|
-
* @example With a prefix
|
|
270
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
271
|
-
*/
|
|
272
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
273
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Converts `text` to PascalCase.
|
|
277
|
-
*
|
|
278
|
-
* @example Word boundaries
|
|
279
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
280
|
-
*
|
|
281
|
-
* @example With a suffix
|
|
282
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
283
|
-
*/
|
|
284
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
285
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
286
|
-
}
|
|
287
238
|
// ../../internals/utils/src/reserved.ts
|
|
288
239
|
/**
|
|
289
240
|
* JavaScript and Java reserved words.
|
|
@@ -424,8 +375,11 @@ function isIdentifier(name) {
|
|
|
424
375
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
425
376
|
}
|
|
426
377
|
// ../../internals/shared/src/resolver.ts
|
|
378
|
+
/**
|
|
379
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
380
|
+
*/
|
|
427
381
|
function resolveOperationName(name) {
|
|
428
|
-
return ensureValidVarName(camelCase(name));
|
|
382
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
429
383
|
}
|
|
430
384
|
/**
|
|
431
385
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -468,7 +422,7 @@ function createGroupConfig(group) {
|
|
|
468
422
|
if (!group) return null;
|
|
469
423
|
const defaultName = (ctx) => {
|
|
470
424
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
471
|
-
return camelCase(ctx.group);
|
|
425
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
472
426
|
};
|
|
473
427
|
return {
|
|
474
428
|
...group,
|
|
@@ -481,7 +435,7 @@ var compatibility = {
|
|
|
481
435
|
"node": ">=22.22"
|
|
482
436
|
};
|
|
483
437
|
// package.json
|
|
484
|
-
var version = "5.8.
|
|
438
|
+
var version = "5.8.1";
|
|
485
439
|
// ../../internals/client/src/builders/validatorOptions.ts
|
|
486
440
|
/**
|
|
487
441
|
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
@@ -915,6 +869,7 @@ function toZodTypeResolver(resolver) {
|
|
|
915
869
|
return {
|
|
916
870
|
...resolver,
|
|
917
871
|
file: resolver.file.bind(resolver),
|
|
872
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
918
873
|
param: {
|
|
919
874
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
920
875
|
path: (node, p) => type(resolver.param.path(node, p)),
|
|
@@ -1140,13 +1095,13 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1140
1095
|
pluginName: "plugin-contract-client",
|
|
1141
1096
|
name: resolveOperationName,
|
|
1142
1097
|
className(name) {
|
|
1143
|
-
return ensureValidVarName(pascalCase(name));
|
|
1098
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(name));
|
|
1144
1099
|
},
|
|
1145
1100
|
groupName(name) {
|
|
1146
|
-
return ensureValidVarName(pascalCase(`${name} Client`));
|
|
1101
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
|
|
1147
1102
|
},
|
|
1148
1103
|
propertyName(name) {
|
|
1149
|
-
return ensureValidVarName(camelCase(name));
|
|
1104
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name));
|
|
1150
1105
|
}
|
|
1151
1106
|
});
|
|
1152
1107
|
// src/generators/clientGenerator.tsx
|