@kubb/plugin-swr 5.4.3 → 5.4.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 +35 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/docs/options.md +20 -4
- package/kubb-extension.json +14 -0
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -261,12 +261,23 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
261
261
|
*
|
|
262
262
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
263
263
|
*/
|
|
264
|
-
function
|
|
264
|
+
function convert(text, pascal) {
|
|
265
265
|
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) => {
|
|
266
266
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
267
267
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
268
268
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
269
269
|
}
|
|
270
|
+
const cache = /* @__PURE__ */ new Map();
|
|
271
|
+
const cacheLimit = 1e4;
|
|
272
|
+
function toCamelOrPascal(text, pascal) {
|
|
273
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
274
|
+
const cached = cache.get(key);
|
|
275
|
+
if (cached !== void 0) return cached;
|
|
276
|
+
const result = convert(text, pascal);
|
|
277
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
278
|
+
cache.set(key, result);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
270
281
|
/**
|
|
271
282
|
* Converts `text` to camelCase.
|
|
272
283
|
*
|
|
@@ -328,7 +339,7 @@ var compatibility = {
|
|
|
328
339
|
};
|
|
329
340
|
//#endregion
|
|
330
341
|
//#region package.json
|
|
331
|
-
var version = "5.4.
|
|
342
|
+
var version = "5.4.5";
|
|
332
343
|
//#endregion
|
|
333
344
|
//#region ../../internals/client/src/resolveClient.ts
|
|
334
345
|
/**
|
|
@@ -811,6 +822,16 @@ function buildHookParams(node, options) {
|
|
|
811
822
|
//#endregion
|
|
812
823
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
813
824
|
const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
825
|
+
/**
|
|
826
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
827
|
+
*
|
|
828
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```ts
|
|
832
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
833
|
+
* ```
|
|
834
|
+
*/
|
|
814
835
|
const mutationKeyTransformer = ({ node }) => {
|
|
815
836
|
if (!node.path) return [];
|
|
816
837
|
return [`{ url: '${kubb_kit.Url.toPath(node.path)}' }`];
|
|
@@ -902,6 +923,16 @@ function createMutationResolver() {
|
|
|
902
923
|
//#endregion
|
|
903
924
|
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
904
925
|
const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
|
|
926
|
+
/**
|
|
927
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
928
|
+
*
|
|
929
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
905
936
|
const queryKeyTransformer = ({ node, variant }) => {
|
|
906
937
|
if (!node.path) return [];
|
|
907
938
|
const { path, query } = getOperationParameters(node);
|
|
@@ -1353,8 +1384,10 @@ const pluginSwr = (0, kubb_kit.defineExtension)({
|
|
|
1353
1384
|
});
|
|
1354
1385
|
//#endregion
|
|
1355
1386
|
exports.default = pluginSwr;
|
|
1387
|
+
exports.mutationKeyTransformer = mutationKeyTransformer;
|
|
1356
1388
|
exports.pluginSwr = pluginSwr;
|
|
1357
1389
|
exports.pluginSwrName = pluginSwrName;
|
|
1390
|
+
exports.queryKeyTransformer = queryKeyTransformer;
|
|
1358
1391
|
exports.resolverSwr = resolverSwr;
|
|
1359
1392
|
|
|
1360
1393
|
//# sourceMappingURL=index.cjs.map
|