@kubb/plugin-react-query 5.5.3 → 5.5.5
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 +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/docs/options.md +20 -4
- package/kubb-extension.json +28 -0
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -263,12 +263,23 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
263
263
|
*
|
|
264
264
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
265
265
|
*/
|
|
266
|
-
function
|
|
266
|
+
function convert(text, pascal) {
|
|
267
267
|
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) => {
|
|
268
268
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
269
269
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
270
270
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
271
271
|
}
|
|
272
|
+
const cache = /* @__PURE__ */ new Map();
|
|
273
|
+
const cacheLimit = 1e4;
|
|
274
|
+
function toCamelOrPascal(text, pascal) {
|
|
275
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
276
|
+
const cached = cache.get(key);
|
|
277
|
+
if (cached !== void 0) return cached;
|
|
278
|
+
const result = convert(text, pascal);
|
|
279
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
280
|
+
cache.set(key, result);
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
272
283
|
/**
|
|
273
284
|
* Converts `text` to camelCase.
|
|
274
285
|
*
|
|
@@ -347,7 +358,7 @@ var compatibility = {
|
|
|
347
358
|
};
|
|
348
359
|
//#endregion
|
|
349
360
|
//#region package.json
|
|
350
|
-
var version = "5.5.
|
|
361
|
+
var version = "5.5.5";
|
|
351
362
|
//#endregion
|
|
352
363
|
//#region ../../internals/client/src/resolveClient.ts
|
|
353
364
|
/**
|
|
@@ -873,6 +884,11 @@ function getDefaultPageParamsWarning(node, infinite) {
|
|
|
873
884
|
return `${node.operationId}: the default infinite page params expect an array response and never end for this one. Set \`infinite.getNextPageParam\` (or \`nextParam\`) to read the next page from the response.`;
|
|
874
885
|
}
|
|
875
886
|
function matchesPattern(node, ov) {
|
|
887
|
+
if ("key" in ov) {
|
|
888
|
+
const extensions = node.extensions;
|
|
889
|
+
if (!extensions || !(ov.key in extensions)) return false;
|
|
890
|
+
return ov.value === void 0 || extensions[ov.key] === ov.value;
|
|
891
|
+
}
|
|
876
892
|
const { type, pattern } = ov;
|
|
877
893
|
const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
|
|
878
894
|
if (type === "operationId") return matches(node.operationId);
|
|
@@ -1037,6 +1053,16 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1037
1053
|
//#endregion
|
|
1038
1054
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
1039
1055
|
const declarationPrinter$5 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
1056
|
+
/**
|
|
1057
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
1058
|
+
*
|
|
1059
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
1060
|
+
*
|
|
1061
|
+
* @example
|
|
1062
|
+
* ```ts
|
|
1063
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
1064
|
+
* ```
|
|
1065
|
+
*/
|
|
1040
1066
|
const mutationKeyTransformer = ({ node }) => {
|
|
1041
1067
|
if (!node.path) return [];
|
|
1042
1068
|
return [`{ url: '${kubb_kit.Url.toPath(node.path)}' }`];
|
|
@@ -1128,6 +1154,16 @@ function createMutationResolver() {
|
|
|
1128
1154
|
//#endregion
|
|
1129
1155
|
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
1130
1156
|
const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
1157
|
+
/**
|
|
1158
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
1159
|
+
*
|
|
1160
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
1161
|
+
*
|
|
1162
|
+
* @example
|
|
1163
|
+
* ```ts
|
|
1164
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1131
1167
|
const queryKeyTransformer = ({ node, variant }) => {
|
|
1132
1168
|
if (!node.path) return [];
|
|
1133
1169
|
const { path, query } = getOperationParameters(node);
|
|
@@ -2108,8 +2144,10 @@ const pluginReactQuery = (0, kubb_kit.defineExtension)({
|
|
|
2108
2144
|
//#endregion
|
|
2109
2145
|
exports.default = pluginReactQuery;
|
|
2110
2146
|
exports.definePageParam = definePageParam;
|
|
2147
|
+
exports.mutationKeyTransformer = mutationKeyTransformer;
|
|
2111
2148
|
exports.pluginReactQuery = pluginReactQuery;
|
|
2112
2149
|
exports.pluginReactQueryName = pluginReactQueryName;
|
|
2150
|
+
exports.queryKeyTransformer = queryKeyTransformer;
|
|
2113
2151
|
exports.resolverReactQuery = resolverReactQuery;
|
|
2114
2152
|
|
|
2115
2153
|
//# sourceMappingURL=index.cjs.map
|