@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.d.cts
CHANGED
|
@@ -35,6 +35,32 @@ type Transformer = (props: {
|
|
|
35
35
|
variant: KeyVariant;
|
|
36
36
|
}) => Array<unknown>;
|
|
37
37
|
//#endregion
|
|
38
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.d.ts
|
|
39
|
+
/**
|
|
40
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
41
|
+
*
|
|
42
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const mutationKeyTransformer: Transformer;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
54
|
+
*
|
|
55
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const queryKeyTransformer: Transformer;
|
|
63
|
+
//#endregion
|
|
38
64
|
//#region src/types.d.ts
|
|
39
65
|
/**
|
|
40
66
|
* The concrete resolver type for `@kubb/plugin-swr`.
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,32 @@ type Transformer = (props: {
|
|
|
35
35
|
variant: KeyVariant;
|
|
36
36
|
}) => Array<unknown>;
|
|
37
37
|
//#endregion
|
|
38
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.d.ts
|
|
39
|
+
/**
|
|
40
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
41
|
+
*
|
|
42
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const mutationKeyTransformer: Transformer;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
54
|
+
*
|
|
55
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const queryKeyTransformer: Transformer;
|
|
63
|
+
//#endregion
|
|
38
64
|
//#region src/types.d.ts
|
|
39
65
|
/**
|
|
40
66
|
* The concrete resolver type for `@kubb/plugin-swr`.
|
package/dist/index.js
CHANGED
|
@@ -235,12 +235,23 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
235
235
|
*
|
|
236
236
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
237
237
|
*/
|
|
238
|
-
function
|
|
238
|
+
function convert(text, pascal) {
|
|
239
239
|
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) => {
|
|
240
240
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
241
241
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
242
242
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
243
243
|
}
|
|
244
|
+
const cache = /* @__PURE__ */ new Map();
|
|
245
|
+
const cacheLimit = 1e4;
|
|
246
|
+
function toCamelOrPascal(text, pascal) {
|
|
247
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
248
|
+
const cached = cache.get(key);
|
|
249
|
+
if (cached !== void 0) return cached;
|
|
250
|
+
const result = convert(text, pascal);
|
|
251
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
252
|
+
cache.set(key, result);
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
244
255
|
/**
|
|
245
256
|
* Converts `text` to camelCase.
|
|
246
257
|
*
|
|
@@ -302,7 +313,7 @@ var compatibility = {
|
|
|
302
313
|
};
|
|
303
314
|
//#endregion
|
|
304
315
|
//#region package.json
|
|
305
|
-
var version = "5.4.
|
|
316
|
+
var version = "5.4.5";
|
|
306
317
|
//#endregion
|
|
307
318
|
//#region ../../internals/client/src/resolveClient.ts
|
|
308
319
|
/**
|
|
@@ -785,6 +796,16 @@ function buildHookParams(node, options) {
|
|
|
785
796
|
//#endregion
|
|
786
797
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
787
798
|
const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
|
|
799
|
+
/**
|
|
800
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
801
|
+
*
|
|
802
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```ts
|
|
806
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
788
809
|
const mutationKeyTransformer = ({ node }) => {
|
|
789
810
|
if (!node.path) return [];
|
|
790
811
|
return [`{ url: '${Url.toPath(node.path)}' }`];
|
|
@@ -876,6 +897,16 @@ function createMutationResolver() {
|
|
|
876
897
|
//#endregion
|
|
877
898
|
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
878
899
|
const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
|
|
900
|
+
/**
|
|
901
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
902
|
+
*
|
|
903
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* ```ts
|
|
907
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
879
910
|
const queryKeyTransformer = ({ node, variant }) => {
|
|
880
911
|
if (!node.path) return [];
|
|
881
912
|
const { path, query } = getOperationParameters(node);
|
|
@@ -1326,6 +1357,6 @@ const pluginSwr = defineExtension({
|
|
|
1326
1357
|
}
|
|
1327
1358
|
});
|
|
1328
1359
|
//#endregion
|
|
1329
|
-
export { pluginSwr as default, pluginSwr, pluginSwrName, resolverSwr };
|
|
1360
|
+
export { pluginSwr as default, pluginSwr, mutationKeyTransformer, pluginSwrName, queryKeyTransformer, resolverSwr };
|
|
1330
1361
|
|
|
1331
1362
|
//# sourceMappingURL=index.js.map
|