@srpc.org/react-query 0.20.4 → 0.20.6
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/context.d.ts +3 -1
- package/dist/context.js +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -0
- package/package.json +3 -3
package/dist/context.d.ts
CHANGED
|
@@ -82,9 +82,11 @@ import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
|
82
82
|
* };
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
type OptionsFactory<Procedure extends ClientProcedure<any>, TInput = Parameters<Procedure>, TOutput = ReturnType<Procedure
|
|
85
|
+
type OptionsFactory<Procedure extends ClientProcedure<any>, TInput = Parameters<Procedure>, TOutput = Awaited<ReturnType<Procedure>>> = {
|
|
86
86
|
queryOptions: (...args: Parameters<Procedure>) => UseQueryOptions<TOutput>;
|
|
87
87
|
mutationOptions: () => UseMutationOptions<TOutput, Error, TInput>;
|
|
88
|
+
queryKey: (...args: Parameters<Procedure>) => string[];
|
|
89
|
+
mutationKey: () => string[];
|
|
88
90
|
};
|
|
89
91
|
/**
|
|
90
92
|
* Type that recursively transforms an SRPC router into a structure with React Query options.
|
package/dist/context.js
CHANGED
|
@@ -81,6 +81,12 @@ import { queryOptions, mutationOptions } from '@tanstack/react-query';
|
|
|
81
81
|
return createRecursiveProxy(({ path, args })=>{
|
|
82
82
|
const lastPath = path[path.length - 1];
|
|
83
83
|
const pathWithoutTarget = path.slice(0, -1);
|
|
84
|
+
if (lastPath === "queryKey" || lastPath === "mutationKey") {
|
|
85
|
+
return [
|
|
86
|
+
...pathWithoutTarget,
|
|
87
|
+
args
|
|
88
|
+
];
|
|
89
|
+
}
|
|
84
90
|
const procedure = pathWithoutTarget.reduce((acc, key)=>acc[key], client);
|
|
85
91
|
if (typeof procedure !== "function") {
|
|
86
92
|
throw new Error(`Procedure at path ${pathWithoutTarget.join(".")} is not a function`);
|
package/dist/index.d.ts
CHANGED
|
@@ -82,9 +82,11 @@ export { SRPCContextFactory, SRPCContextValue, createSRPCContext } from './conte
|
|
|
82
82
|
* };
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
type OptionsFactory<Procedure extends ClientProcedure<any>, TInput = Parameters<Procedure>, TOutput = ReturnType<Procedure
|
|
85
|
+
type OptionsFactory<Procedure extends ClientProcedure<any>, TInput = Parameters<Procedure>, TOutput = Awaited<ReturnType<Procedure>>> = {
|
|
86
86
|
queryOptions: (...args: Parameters<Procedure>) => UseQueryOptions<TOutput>;
|
|
87
87
|
mutationOptions: () => UseMutationOptions<TOutput, Error, TInput>;
|
|
88
|
+
queryKey: (...args: Parameters<Procedure>) => string[];
|
|
89
|
+
mutationKey: () => string[];
|
|
88
90
|
};
|
|
89
91
|
/**
|
|
90
92
|
* Type that recursively transforms an SRPC router into a structure with React Query options.
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,12 @@ export { createSRPCContext } from './context.js';
|
|
|
79
79
|
return createRecursiveProxy(({ path, args })=>{
|
|
80
80
|
const lastPath = path[path.length - 1];
|
|
81
81
|
const pathWithoutTarget = path.slice(0, -1);
|
|
82
|
+
if (lastPath === "queryKey" || lastPath === "mutationKey") {
|
|
83
|
+
return [
|
|
84
|
+
...pathWithoutTarget,
|
|
85
|
+
args
|
|
86
|
+
];
|
|
87
|
+
}
|
|
82
88
|
const procedure = pathWithoutTarget.reduce((acc, key)=>acc[key], client);
|
|
83
89
|
if (typeof procedure !== "function") {
|
|
84
90
|
throw new Error(`Procedure at path ${pathWithoutTarget.join(".")} is not a function`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srpc.org/react-query",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.6",
|
|
4
4
|
"description": "React Query integration for SRPC - Type-safe RPC with automatic React Query hooks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"get-port-please": "^3.1.2",
|
|
36
36
|
"react": "^19.2.0",
|
|
37
37
|
"vitest": "^4.0.10",
|
|
38
|
-
"@srpc.org/core": "0.20.
|
|
38
|
+
"@srpc.org/core": "0.20.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@tanstack/react-query": ">=5.90",
|
|
42
42
|
"react": ">=19",
|
|
43
|
-
"@srpc.org/core": "0.20.
|
|
43
|
+
"@srpc.org/core": "0.20.5"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "bunchee",
|