@kubb/plugin-client 5.9.0-canary.20261027T202821 → 5.9.0-canary.20261029T082701
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 +33 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +30 -81
- 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.20261029T082701";
|
|
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)),
|
|
@@ -952,32 +899,34 @@ function toZodTypeResolver(resolver) {
|
|
|
952
899
|
* ```
|
|
953
900
|
*/
|
|
954
901
|
function resolveOperationTypes(driver, pluginName) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
902
|
+
return driver.memo(`operationTypes:${pluginName}`, () => {
|
|
903
|
+
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
904
|
+
const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
|
|
905
|
+
if (pluginTs && pluginZod?.options?.inferred !== "codec") {
|
|
906
|
+
const resolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
907
|
+
return {
|
|
908
|
+
response: resolver.response,
|
|
909
|
+
resolver,
|
|
910
|
+
output: pluginTs.options?.output,
|
|
911
|
+
group: pluginTs.options?.group ?? void 0
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
|
|
915
|
+
code: kubb_kit.Diagnostics.code.missingDependency,
|
|
916
|
+
severity: "error",
|
|
917
|
+
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
918
|
+
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
919
|
+
location: { kind: "config" },
|
|
920
|
+
plugin: pluginName
|
|
921
|
+
});
|
|
922
|
+
const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
|
|
959
923
|
return {
|
|
960
924
|
response: resolver.response,
|
|
961
925
|
resolver,
|
|
962
|
-
output:
|
|
963
|
-
group:
|
|
926
|
+
output: pluginZod.options.output,
|
|
927
|
+
group: pluginZod.options.group ?? void 0
|
|
964
928
|
};
|
|
965
|
-
}
|
|
966
|
-
if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
|
|
967
|
-
code: kubb_kit.Diagnostics.code.missingDependency,
|
|
968
|
-
severity: "error",
|
|
969
|
-
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
970
|
-
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
971
|
-
location: { kind: "config" },
|
|
972
|
-
plugin: pluginName
|
|
973
929
|
});
|
|
974
|
-
const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
|
|
975
|
-
return {
|
|
976
|
-
response: resolver.response,
|
|
977
|
-
resolver,
|
|
978
|
-
output: pluginZod.options.output,
|
|
979
|
-
group: pluginZod.options.group ?? void 0
|
|
980
|
-
};
|
|
981
930
|
}
|
|
982
931
|
// ../../internals/client/src/generators/clientGenerator.tsx
|
|
983
932
|
/**
|
|
@@ -1148,13 +1097,13 @@ const resolverClient = (0, kubb_kit.createResolver)({
|
|
|
1148
1097
|
pluginName: "plugin-contract-client",
|
|
1149
1098
|
name: resolveOperationName,
|
|
1150
1099
|
className(name) {
|
|
1151
|
-
return ensureValidVarName(pascalCase(name));
|
|
1100
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(name));
|
|
1152
1101
|
},
|
|
1153
1102
|
groupName(name) {
|
|
1154
|
-
return ensureValidVarName(pascalCase(`${name} Client`));
|
|
1103
|
+
return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
|
|
1155
1104
|
},
|
|
1156
1105
|
propertyName(name) {
|
|
1157
|
-
return ensureValidVarName(camelCase(name));
|
|
1106
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name));
|
|
1158
1107
|
}
|
|
1159
1108
|
});
|
|
1160
1109
|
// src/generators/clientGenerator.tsx
|