@trpc/react-query 10.42.0 → 11.0.0-next.91
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/bundle-analysis.json +208 -0
- package/dist/createHooksInternal-3d8ebfcf.mjs +481 -0
- package/dist/createHooksInternal-dce6e141.js +435 -0
- package/dist/createHooksInternal-e2034194.js +490 -0
- package/dist/createTRPCReact.d.ts +46 -45
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -21
- package/dist/index.mjs +9 -21
- package/dist/internals/context.d.ts +42 -54
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/getClientArgs.d.ts +2 -1
- package/dist/internals/getClientArgs.d.ts.map +1 -1
- package/dist/internals/getQueryKey.d.ts +28 -13
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/internals/useQueries.d.ts +4 -4
- package/dist/internals/useQueries.d.ts.map +1 -1
- package/dist/server/index.d.ts +0 -6
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +52 -69
- package/dist/server/index.mjs +52 -69
- package/dist/server/ssgProxy.d.ts +23 -13
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/shared/hooks/createHooksInternal.d.ts +35 -12
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/hooks/createRootHooks.d.ts +0 -5
- package/dist/shared/hooks/createRootHooks.d.ts.map +1 -1
- package/dist/shared/hooks/types.d.ts +33 -18
- package/dist/shared/hooks/types.d.ts.map +1 -1
- package/dist/shared/index.js +9 -9
- package/dist/shared/index.mjs +3 -3
- package/dist/shared/polymorphism/mutationLike.d.ts +5 -5
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.ts +5 -5
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.ts +4 -3
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/proxy/decorationProxy.d.ts +2 -2
- package/dist/shared/proxy/decorationProxy.d.ts.map +1 -1
- package/dist/shared/proxy/useQueriesProxy.d.ts +6 -6
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.d.ts +34 -31
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/shared/types.d.ts +0 -12
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/utils/inferReactQueryProcedure.d.ts +7 -7
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/dist/utilsProxy-00894da2.mjs +121 -0
- package/dist/utilsProxy-27bd93c1.js +128 -0
- package/dist/utilsProxy-7e396600.js +114 -0
- package/package.json +8 -14
- package/src/createTRPCReact.tsx +156 -135
- package/src/index.ts +0 -1
- package/src/internals/context.tsx +93 -164
- package/src/internals/getClientArgs.ts +9 -4
- package/src/internals/getQueryKey.ts +53 -24
- package/src/internals/useQueries.ts +7 -10
- package/src/server/index.ts +0 -8
- package/src/server/ssgProxy.ts +179 -34
- package/src/shared/hooks/createHooksInternal.tsx +298 -207
- package/src/shared/hooks/createRootHooks.tsx +0 -6
- package/src/shared/hooks/types.ts +87 -36
- package/src/shared/polymorphism/mutationLike.ts +11 -8
- package/src/shared/polymorphism/queryLike.ts +17 -12
- package/src/shared/polymorphism/routerLike.ts +15 -9
- package/src/shared/proxy/decorationProxy.ts +9 -31
- package/src/shared/proxy/useQueriesProxy.ts +23 -37
- package/src/shared/proxy/utilsProxy.ts +121 -95
- package/src/shared/types.ts +0 -12
- package/src/utils/inferReactQueryProcedure.ts +28 -30
- package/dist/context-4557b3d3.js +0 -38
- package/dist/createHooksInternal-2e69c447.js +0 -582
- package/dist/createHooksInternal-37b068e0.js +0 -510
- package/dist/createHooksInternal-bdff7171.mjs +0 -568
- package/dist/getArrayQueryKey-4bdb5cc2.js +0 -36
- package/dist/getArrayQueryKey-86134f8b.mjs +0 -34
- package/dist/internals/getArrayQueryKey.d.ts +0 -25
- package/dist/internals/getArrayQueryKey.d.ts.map +0 -1
- package/dist/interop.d.ts +0 -11
- package/dist/interop.d.ts.map +0 -1
- package/dist/server/types.d.ts +0 -14
- package/dist/server/types.d.ts.map +0 -1
- package/dist/shared/hooks/deprecated/createHooksInternal.d.ts +0 -63
- package/dist/shared/hooks/deprecated/createHooksInternal.d.ts.map +0 -1
- package/dist/ssg/index.d.ts +0 -15
- package/dist/ssg/index.d.ts.map +0 -1
- package/dist/ssg/ssg.d.ts +0 -16
- package/dist/ssg/ssg.d.ts.map +0 -1
- package/src/internals/getArrayQueryKey.ts +0 -46
- package/src/interop.ts +0 -29
- package/src/server/types.ts +0 -29
- package/src/shared/hooks/deprecated/createHooksInternal.tsx +0 -641
- package/src/ssg/index.tsx +0 -16
- package/src/ssg/ssg.ts +0 -139
- package/ssg/index.d.ts +0 -1
- package/ssg/index.js +0 -1
package/src/createTRPCReact.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { InfiniteData } from '@tanstack/react-query';
|
|
2
1
|
import { TRPCClientErrorLike } from '@trpc/client';
|
|
3
2
|
import {
|
|
4
3
|
AnyMutationProcedure,
|
|
5
4
|
AnyProcedure,
|
|
6
5
|
AnyQueryProcedure,
|
|
6
|
+
AnyRootConfig,
|
|
7
7
|
AnyRouter,
|
|
8
8
|
AnySubscriptionProcedure,
|
|
9
9
|
inferProcedureInput,
|
|
@@ -16,17 +16,16 @@ import {
|
|
|
16
16
|
inferTransformedSubscriptionOutput,
|
|
17
17
|
} from '@trpc/server/shared';
|
|
18
18
|
import { useMemo } from 'react';
|
|
19
|
-
import { QueryKey, QueryType } from './internals/getArrayQueryKey';
|
|
20
19
|
import { TRPCUseQueries } from './internals/useQueries';
|
|
21
20
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
createReactDecoration,
|
|
22
|
+
createReactQueryUtils,
|
|
23
|
+
CreateReactUtils,
|
|
25
24
|
} from './shared';
|
|
26
25
|
import {
|
|
27
|
-
createHooksInternal,
|
|
28
26
|
CreateReactQueryHooks,
|
|
29
|
-
|
|
27
|
+
createRootHooks,
|
|
28
|
+
} from './shared/hooks/createHooksInternal';
|
|
30
29
|
import {
|
|
31
30
|
CreateClient,
|
|
32
31
|
DefinedUseTRPCQueryOptions,
|
|
@@ -35,13 +34,15 @@ import {
|
|
|
35
34
|
UseDehydratedState,
|
|
36
35
|
UseTRPCInfiniteQueryOptions,
|
|
37
36
|
UseTRPCInfiniteQueryResult,
|
|
38
|
-
UseTRPCInfiniteQuerySuccessResult,
|
|
39
37
|
UseTRPCMutationOptions,
|
|
40
38
|
UseTRPCMutationResult,
|
|
41
39
|
UseTRPCQueryOptions,
|
|
42
40
|
UseTRPCQueryResult,
|
|
43
|
-
UseTRPCQuerySuccessResult,
|
|
44
41
|
UseTRPCSubscriptionOptions,
|
|
42
|
+
UseTRPCSuspenseInfiniteQueryOptions,
|
|
43
|
+
UseTRPCSuspenseInfiniteQueryResult,
|
|
44
|
+
UseTRPCSuspenseQueryOptions,
|
|
45
|
+
UseTRPCSuspenseQueryResult,
|
|
45
46
|
} from './shared/hooks/types';
|
|
46
47
|
import { CreateTRPCReactOptions } from './shared/types';
|
|
47
48
|
|
|
@@ -49,144 +50,165 @@ import { CreateTRPCReactOptions } from './shared/types';
|
|
|
49
50
|
* @internal
|
|
50
51
|
*/
|
|
51
52
|
export interface ProcedureUseQuery<
|
|
53
|
+
TConfig extends AnyRootConfig,
|
|
52
54
|
TProcedure extends AnyProcedure,
|
|
53
|
-
TPath extends string,
|
|
54
55
|
> {
|
|
55
56
|
<
|
|
56
|
-
TQueryFnData extends inferTransformedProcedureOutput<
|
|
57
|
+
TQueryFnData extends inferTransformedProcedureOutput<
|
|
58
|
+
TConfig,
|
|
59
|
+
TProcedure
|
|
60
|
+
> = inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
57
61
|
TData = TQueryFnData,
|
|
58
62
|
>(
|
|
59
63
|
input: inferProcedureInput<TProcedure>,
|
|
60
64
|
opts: DefinedUseTRPCQueryOptions<
|
|
61
|
-
TPath,
|
|
62
|
-
inferProcedureInput<TProcedure>,
|
|
63
65
|
TQueryFnData,
|
|
64
66
|
TData,
|
|
65
|
-
TRPCClientErrorLike<
|
|
66
|
-
inferTransformedProcedureOutput<TProcedure>
|
|
67
|
+
TRPCClientErrorLike<TConfig>,
|
|
68
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>
|
|
67
69
|
>,
|
|
68
|
-
): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<
|
|
70
|
+
): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<TConfig>>;
|
|
69
71
|
|
|
70
72
|
<
|
|
71
|
-
TQueryFnData extends inferTransformedProcedureOutput<
|
|
73
|
+
TQueryFnData extends inferTransformedProcedureOutput<
|
|
74
|
+
TConfig,
|
|
75
|
+
TProcedure
|
|
76
|
+
> = inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
72
77
|
TData = TQueryFnData,
|
|
73
78
|
>(
|
|
74
79
|
input: inferProcedureInput<TProcedure>,
|
|
75
80
|
opts?: UseTRPCQueryOptions<
|
|
76
|
-
TPath,
|
|
77
|
-
inferProcedureInput<TProcedure>,
|
|
78
81
|
TQueryFnData,
|
|
79
82
|
TData,
|
|
80
|
-
TRPCClientErrorLike<
|
|
81
|
-
inferTransformedProcedureOutput<TProcedure>
|
|
83
|
+
TRPCClientErrorLike<TConfig>,
|
|
84
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>
|
|
82
85
|
>,
|
|
83
|
-
): UseTRPCQueryResult<TData, TRPCClientErrorLike<
|
|
86
|
+
): UseTRPCQueryResult<TData, TRPCClientErrorLike<TConfig>>;
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @remark `void` is here due to https://github.com/trpc/trpc/pull/4374
|
|
91
|
+
*/
|
|
92
|
+
type CursorInput = {
|
|
93
|
+
cursor?: any;
|
|
94
|
+
} | void;
|
|
95
|
+
|
|
86
96
|
/**
|
|
87
97
|
* @internal
|
|
88
98
|
*/
|
|
89
|
-
export type
|
|
99
|
+
export type MaybeDecoratedInfiniteQuery<
|
|
90
100
|
TProcedure extends AnyProcedure,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
? (inferProcedureInput<TProcedure> extends { cursor?: any } | void
|
|
95
|
-
? {
|
|
96
|
-
/**
|
|
97
|
-
* @see https://trpc.io/docs/client/react/suspense#useinfinitesuspensequery
|
|
98
|
-
*/
|
|
99
|
-
useInfiniteQuery: (
|
|
100
|
-
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
101
|
-
opts?: UseTRPCInfiniteQueryOptions<
|
|
102
|
-
TPath,
|
|
103
|
-
inferProcedureInput<TProcedure>,
|
|
104
|
-
inferTransformedProcedureOutput<TProcedure>,
|
|
105
|
-
TRPCClientErrorLike<TProcedure>
|
|
106
|
-
>,
|
|
107
|
-
) => UseTRPCInfiniteQueryResult<
|
|
108
|
-
inferTransformedProcedureOutput<TProcedure>,
|
|
109
|
-
TRPCClientErrorLike<TProcedure>
|
|
110
|
-
>;
|
|
111
|
-
/**
|
|
112
|
-
* @see https://trpc.io/docs/client/react/suspense
|
|
113
|
-
*/
|
|
114
|
-
useSuspenseInfiniteQuery: (
|
|
115
|
-
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
116
|
-
opts?: Omit<
|
|
117
|
-
UseTRPCInfiniteQueryOptions<
|
|
118
|
-
TPath,
|
|
119
|
-
inferProcedureInput<TProcedure>,
|
|
120
|
-
inferTransformedProcedureOutput<TProcedure>,
|
|
121
|
-
TRPCClientErrorLike<TProcedure>
|
|
122
|
-
>,
|
|
123
|
-
'enabled' | 'suspense'
|
|
124
|
-
>,
|
|
125
|
-
) => [
|
|
126
|
-
InfiniteData<inferTransformedProcedureOutput<TProcedure>>,
|
|
127
|
-
UseTRPCInfiniteQuerySuccessResult<
|
|
128
|
-
inferTransformedProcedureOutput<TProcedure>,
|
|
129
|
-
TRPCClientErrorLike<TProcedure>
|
|
130
|
-
>,
|
|
131
|
-
];
|
|
132
|
-
}
|
|
133
|
-
: object) & {
|
|
134
|
-
/**
|
|
135
|
-
* Method to extract the query key for a procedure
|
|
136
|
-
* @param type - defaults to `any`
|
|
137
|
-
* @see https://trpc.io/docs/client/react/getQueryKey
|
|
138
|
-
* @deprecated - import `getQueryKey` from `@trpc/react-query` instead
|
|
139
|
-
*/
|
|
140
|
-
getQueryKey: (
|
|
141
|
-
input: inferProcedureInput<TProcedure>,
|
|
142
|
-
type?: QueryType,
|
|
143
|
-
) => QueryKey;
|
|
144
|
-
/**
|
|
145
|
-
* @see https://trpc.io/docs/client/react/useQuery
|
|
146
|
-
*/
|
|
147
|
-
useQuery: ProcedureUseQuery<TProcedure, TPath>;
|
|
101
|
+
TConfig extends AnyRootConfig,
|
|
102
|
+
> = inferProcedureInput<TProcedure> extends CursorInput
|
|
103
|
+
? {
|
|
148
104
|
/**
|
|
149
|
-
* @see https://trpc.io/docs/client/react/suspense#
|
|
105
|
+
* @see https://trpc.io/docs/client/react/suspense#useinfinitesuspensequery
|
|
150
106
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
UseTRPCQueryOptions<
|
|
158
|
-
TPath,
|
|
159
|
-
inferProcedureInput<TProcedure>,
|
|
160
|
-
TQueryFnData,
|
|
161
|
-
TData,
|
|
162
|
-
TRPCClientErrorLike<TProcedure>
|
|
163
|
-
>,
|
|
164
|
-
'enabled' | 'suspense'
|
|
107
|
+
useInfiniteQuery: (
|
|
108
|
+
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
109
|
+
opts: UseTRPCInfiniteQueryOptions<
|
|
110
|
+
inferProcedureInput<TProcedure>,
|
|
111
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
112
|
+
TRPCClientErrorLike<TConfig>
|
|
165
113
|
>,
|
|
166
|
-
) =>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: TProcedure extends AnyMutationProcedure
|
|
172
|
-
? {
|
|
114
|
+
) => UseTRPCInfiniteQueryResult<
|
|
115
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
116
|
+
TRPCClientErrorLike<TConfig>,
|
|
117
|
+
inferProcedureInput<TProcedure>
|
|
118
|
+
>;
|
|
173
119
|
/**
|
|
174
|
-
* @see https://trpc.io/docs/client/react/
|
|
120
|
+
* @see https://trpc.io/docs/client/react/suspense
|
|
175
121
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
122
|
+
useSuspenseInfiniteQuery: (
|
|
123
|
+
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
124
|
+
opts: UseTRPCSuspenseInfiniteQueryOptions<
|
|
178
125
|
inferProcedureInput<TProcedure>,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
TContext
|
|
126
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
127
|
+
TRPCClientErrorLike<TConfig>
|
|
182
128
|
>,
|
|
183
|
-
) =>
|
|
184
|
-
inferTransformedProcedureOutput<TProcedure>,
|
|
185
|
-
TRPCClientErrorLike<
|
|
186
|
-
inferProcedureInput<TProcedure
|
|
187
|
-
TContext
|
|
129
|
+
) => UseTRPCSuspenseInfiniteQueryResult<
|
|
130
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
131
|
+
TRPCClientErrorLike<TConfig>,
|
|
132
|
+
inferProcedureInput<TProcedure>
|
|
188
133
|
>;
|
|
189
134
|
}
|
|
135
|
+
: object;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export type DecoratedQueryMethods<
|
|
141
|
+
TConfig extends AnyRootConfig,
|
|
142
|
+
TProcedure extends AnyProcedure,
|
|
143
|
+
> = {
|
|
144
|
+
/**
|
|
145
|
+
* @see https://trpc.io/docs/client/react/useQuery
|
|
146
|
+
*/
|
|
147
|
+
useQuery: ProcedureUseQuery<TConfig, TProcedure>;
|
|
148
|
+
/**
|
|
149
|
+
* @see https://trpc.io/docs/client/react/suspense#usesuspensequery
|
|
150
|
+
*/
|
|
151
|
+
useSuspenseQuery: <
|
|
152
|
+
TQueryFnData extends inferTransformedProcedureOutput<
|
|
153
|
+
TConfig,
|
|
154
|
+
TProcedure
|
|
155
|
+
> = inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
156
|
+
TData = TQueryFnData,
|
|
157
|
+
>(
|
|
158
|
+
input: inferProcedureInput<TProcedure>,
|
|
159
|
+
opts?: UseTRPCSuspenseQueryOptions<
|
|
160
|
+
TQueryFnData,
|
|
161
|
+
TData,
|
|
162
|
+
TRPCClientErrorLike<TConfig>
|
|
163
|
+
>,
|
|
164
|
+
) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<TConfig>>;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
export type DecoratedQuery<
|
|
171
|
+
TConfig extends AnyRootConfig,
|
|
172
|
+
TProcedure extends AnyProcedure,
|
|
173
|
+
> = MaybeDecoratedInfiniteQuery<TProcedure, TConfig> &
|
|
174
|
+
DecoratedQueryMethods<TConfig, TProcedure>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
export interface DecoratedMutation<
|
|
180
|
+
TConfig extends AnyRootConfig,
|
|
181
|
+
TProcedure extends AnyProcedure,
|
|
182
|
+
> {
|
|
183
|
+
/**
|
|
184
|
+
* @see https://trpc.io/docs/client/react/useMutation
|
|
185
|
+
*/
|
|
186
|
+
useMutation: <TContext = unknown>(
|
|
187
|
+
opts?: UseTRPCMutationOptions<
|
|
188
|
+
inferProcedureInput<TProcedure>,
|
|
189
|
+
TRPCClientErrorLike<TConfig>,
|
|
190
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
191
|
+
TContext
|
|
192
|
+
>,
|
|
193
|
+
) => UseTRPCMutationResult<
|
|
194
|
+
inferTransformedProcedureOutput<TConfig, TProcedure>,
|
|
195
|
+
TRPCClientErrorLike<TConfig>,
|
|
196
|
+
inferProcedureInput<TProcedure>,
|
|
197
|
+
TContext
|
|
198
|
+
>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
export type DecorateProcedure<
|
|
205
|
+
TConfig extends AnyRootConfig,
|
|
206
|
+
TProcedure extends AnyProcedure,
|
|
207
|
+
_TFlags,
|
|
208
|
+
> = TProcedure extends AnyQueryProcedure
|
|
209
|
+
? DecoratedQuery<TConfig, TProcedure>
|
|
210
|
+
: TProcedure extends AnyMutationProcedure
|
|
211
|
+
? DecoratedMutation<TConfig, TProcedure>
|
|
190
212
|
: TProcedure extends AnySubscriptionProcedure
|
|
191
213
|
? {
|
|
192
214
|
/**
|
|
@@ -195,8 +217,8 @@ export type DecorateProcedure<
|
|
|
195
217
|
useSubscription: (
|
|
196
218
|
input: inferProcedureInput<TProcedure>,
|
|
197
219
|
opts?: UseTRPCSubscriptionOptions<
|
|
198
|
-
inferTransformedSubscriptionOutput<TProcedure>,
|
|
199
|
-
TRPCClientErrorLike<
|
|
220
|
+
inferTransformedSubscriptionOutput<TConfig, TProcedure>,
|
|
221
|
+
TRPCClientErrorLike<TConfig>
|
|
200
222
|
>,
|
|
201
223
|
) => void;
|
|
202
224
|
}
|
|
@@ -206,23 +228,18 @@ export type DecorateProcedure<
|
|
|
206
228
|
* @internal
|
|
207
229
|
*/
|
|
208
230
|
export type DecoratedProcedureRecord<
|
|
231
|
+
TConfig extends AnyRootConfig,
|
|
209
232
|
TProcedures extends ProcedureRouterRecord,
|
|
210
233
|
TFlags,
|
|
211
|
-
TPath extends string = '',
|
|
212
234
|
> = {
|
|
213
235
|
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
|
|
214
236
|
? DecoratedProcedureRecord<
|
|
237
|
+
TConfig,
|
|
215
238
|
TProcedures[TKey]['_def']['record'],
|
|
216
|
-
TFlags
|
|
217
|
-
|
|
218
|
-
> & {
|
|
219
|
-
/**
|
|
220
|
-
* @deprecated - import `getQueryKey` from `@trpc/react-query` instead
|
|
221
|
-
*/
|
|
222
|
-
getQueryKey: () => QueryKey;
|
|
223
|
-
}
|
|
239
|
+
TFlags
|
|
240
|
+
>
|
|
224
241
|
: TProcedures[TKey] extends AnyProcedure
|
|
225
|
-
? DecorateProcedure<TProcedures[TKey], TFlags
|
|
242
|
+
? DecorateProcedure<TConfig, TProcedures[TKey], TFlags>
|
|
226
243
|
: never;
|
|
227
244
|
};
|
|
228
245
|
|
|
@@ -235,11 +252,11 @@ export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
|
|
|
235
252
|
*
|
|
236
253
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
237
254
|
*/
|
|
238
|
-
useContext():
|
|
255
|
+
useContext(): CreateReactUtils<TRouter, TSSRContext>;
|
|
239
256
|
/**
|
|
240
257
|
* @see https://trpc.io/docs/client/react/useUtils
|
|
241
258
|
*/
|
|
242
|
-
useUtils():
|
|
259
|
+
useUtils(): CreateReactUtils<TRouter, TSSRContext>;
|
|
243
260
|
Provider: TRPCProvider<TRouter, TSSRContext>;
|
|
244
261
|
createClient: CreateClient<TRouter>;
|
|
245
262
|
useQueries: TRPCUseQueries<TRouter>;
|
|
@@ -252,26 +269,30 @@ export type CreateTRPCReact<
|
|
|
252
269
|
TFlags,
|
|
253
270
|
> = ProtectedIntersection<
|
|
254
271
|
CreateTRPCReactBase<TRouter, TSSRContext>,
|
|
255
|
-
DecoratedProcedureRecord<
|
|
272
|
+
DecoratedProcedureRecord<
|
|
273
|
+
TRouter['_def']['_config'],
|
|
274
|
+
TRouter['_def']['record'],
|
|
275
|
+
TFlags
|
|
276
|
+
>
|
|
256
277
|
>;
|
|
257
278
|
|
|
258
279
|
/**
|
|
259
280
|
* @internal
|
|
260
281
|
*/
|
|
261
|
-
export function
|
|
282
|
+
export function createHooksInternal<
|
|
262
283
|
TRouter extends AnyRouter,
|
|
263
284
|
TSSRContext = unknown,
|
|
264
285
|
TFlags = null,
|
|
265
286
|
>(trpc: CreateReactQueryHooks<TRouter, TSSRContext>) {
|
|
266
|
-
type
|
|
287
|
+
type CreateHooksInternal = CreateTRPCReact<TRouter, TSSRContext, TFlags>;
|
|
267
288
|
|
|
268
|
-
return createFlatProxy<
|
|
289
|
+
return createFlatProxy<CreateHooksInternal>((key) => {
|
|
269
290
|
if (key === 'useContext' || key === 'useUtils') {
|
|
270
291
|
return () => {
|
|
271
292
|
const context = trpc.useUtils();
|
|
272
293
|
// create a stable reference of the utils context
|
|
273
294
|
return useMemo(() => {
|
|
274
|
-
return (
|
|
295
|
+
return (createReactQueryUtils as any)(context);
|
|
275
296
|
}, [context]);
|
|
276
297
|
};
|
|
277
298
|
}
|
|
@@ -280,7 +301,7 @@ export function createHooksInternalProxy<
|
|
|
280
301
|
return (trpc as any)[key];
|
|
281
302
|
}
|
|
282
303
|
|
|
283
|
-
return
|
|
304
|
+
return createReactDecoration(key, trpc);
|
|
284
305
|
});
|
|
285
306
|
}
|
|
286
307
|
|
|
@@ -291,8 +312,8 @@ export function createTRPCReact<
|
|
|
291
312
|
>(
|
|
292
313
|
opts?: CreateTRPCReactOptions<TRouter>,
|
|
293
314
|
): CreateTRPCReact<TRouter, TSSRContext, TFlags> {
|
|
294
|
-
const hooks =
|
|
295
|
-
const proxy =
|
|
315
|
+
const hooks = createRootHooks<TRouter, TSSRContext>(opts);
|
|
316
|
+
const proxy = createHooksInternal<TRouter, TSSRContext, TFlags>(hooks);
|
|
296
317
|
|
|
297
318
|
return proxy as any;
|
|
298
319
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,5 +2,4 @@ export * from '@trpc/client';
|
|
|
2
2
|
|
|
3
3
|
export { getQueryKey } from './internals/getQueryKey';
|
|
4
4
|
export { createTRPCReact, type CreateTRPCReact } from './createTRPCReact';
|
|
5
|
-
export { createReactQueryHooks } from './interop';
|
|
6
5
|
export type { inferReactQueryProcedureOptions } from './utils/inferReactQueryProcedure';
|