@kubb/plugin-client 5.9.0-canary.20261027T202821 → 5.9.0-canary.20261028T230157
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 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -60
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -235,63 +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
|
-
const wordStart = /(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/;
|
|
240
|
-
/**
|
|
241
|
-
* Splits `text` into words on separators (whitespace, hyphens, underscores, dots, slashes, colons)
|
|
242
|
-
* and on {@link wordStart}. A segment without lowercase letters, such as `COOL` or `2D`, is one word,
|
|
243
|
-
* so snake case leaves a name that is already in it unchanged.
|
|
244
|
-
*/
|
|
245
|
-
function words(text) {
|
|
246
|
-
return text.split(/[\s\-_./\\:]+/).filter(Boolean).flatMap((segment) => segment === segment.toUpperCase() ? segment : segment.split(wordStart));
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
250
|
-
* Capitalizes each word from {@link words} according to `pascal`.
|
|
251
|
-
*
|
|
252
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
253
|
-
*/
|
|
254
|
-
function convert(text, pascal) {
|
|
255
|
-
return words(text).flatMap((word) => word.split(/(?<=\d)(?=[a-z])|(?<=[A-Z])(?=[A-Z][a-z])/)).map((word, i) => {
|
|
256
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
257
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
258
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
259
|
-
}
|
|
260
|
-
const cache = /* @__PURE__ */ new Map();
|
|
261
|
-
const cacheLimit = 1e4;
|
|
262
|
-
function toCamelOrPascal(text, pascal) {
|
|
263
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
264
|
-
const cached = cache.get(key);
|
|
265
|
-
if (cached !== void 0) return cached;
|
|
266
|
-
const result = convert(text, pascal);
|
|
267
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
268
|
-
cache.set(key, result);
|
|
269
|
-
return result;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Converts `text` to camelCase.
|
|
273
|
-
*
|
|
274
|
-
* @example Word boundaries
|
|
275
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
276
|
-
*
|
|
277
|
-
* @example With a prefix
|
|
278
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
279
|
-
*/
|
|
280
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
281
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Converts `text` to PascalCase.
|
|
285
|
-
*
|
|
286
|
-
* @example Word boundaries
|
|
287
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
288
|
-
*
|
|
289
|
-
* @example With a suffix
|
|
290
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
291
|
-
*/
|
|
292
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
293
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
294
|
-
}
|
|
295
238
|
// ../../internals/utils/src/reserved.ts
|
|
296
239
|
/**
|
|
297
240
|
* JavaScript and Java reserved words.
|
|
@@ -432,8 +375,11 @@ function isIdentifier(name) {
|
|
|
432
375
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
433
376
|
}
|
|
434
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
|
+
*/
|
|
435
381
|
function resolveOperationName(name) {
|
|
436
|
-
return ensureValidVarName(camelCase(name));
|
|
382
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
437
383
|
}
|
|
438
384
|
/**
|
|
439
385
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -476,7 +422,7 @@ function createGroupConfig(group) {
|
|
|
476
422
|
if (!group) return null;
|
|
477
423
|
const defaultName = (ctx) => {
|
|
478
424
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
479
|
-
return camelCase(ctx.group);
|
|
425
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
480
426
|
};
|
|
481
427
|
return {
|
|
482
428
|
...group,
|
|
@@ -489,7 +435,7 @@ var compatibility = {
|
|
|
489
435
|
"node": ">=22.22"
|
|
490
436
|
};
|
|
491
437
|
// package.json
|
|
492
|
-
var version = "5.9.0-canary.
|
|
438
|
+
var version = "5.9.0-canary.20261028T230157";
|
|
493
439
|
// ../../internals/client/src/builders/validatorOptions.ts
|
|
494
440
|
/**
|
|
495
441
|
* Returns `true` when any direction of the validator uses zod (used for dependency checks).
|
|
@@ -923,6 +869,7 @@ function toZodTypeResolver(resolver) {
|
|
|
923
869
|
return {
|
|
924
870
|
...resolver,
|
|
925
871
|
file: resolver.file.bind(resolver),
|
|
872
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
926
873
|
param: {
|
|
927
874
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
928
875
|
path: (node, p) => type(resolver.param.path(node, p)),
|
|
@@ -1148,13 +1095,13 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1148
1095
|
pluginName: "plugin-contract-client",
|
|
1149
1096
|
name: resolveOperationName,
|
|
1150
1097
|
className(name) {
|
|
1151
|
-
return ensureValidVarName(pascalCase(name));
|
|
1098
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(name));
|
|
1152
1099
|
},
|
|
1153
1100
|
groupName(name) {
|
|
1154
|
-
return ensureValidVarName(pascalCase(`${name} Client`));
|
|
1101
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
|
|
1155
1102
|
},
|
|
1156
1103
|
propertyName(name) {
|
|
1157
|
-
return ensureValidVarName(camelCase(name));
|
|
1104
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name));
|
|
1158
1105
|
}
|
|
1159
1106
|
});
|
|
1160
1107
|
// src/generators/clientGenerator.tsx
|