@trpc/react-query 11.0.0-next.91 → 11.0.0-rc.329
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/README.md +4 -4
- package/dist/bundle-analysis.json +83 -51
- package/dist/createTRPCQueryUtils.d.ts +4 -0
- package/dist/createTRPCQueryUtils.d.ts.map +1 -0
- package/dist/createTRPCQueryUtils.js +16 -0
- package/dist/createTRPCQueryUtils.mjs +14 -0
- package/dist/createTRPCReact.d.ts +55 -40
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/createTRPCReact.js +58 -0
- package/dist/createTRPCReact.mjs +36 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -36
- package/dist/index.mjs +3 -35
- package/dist/internals/context.d.ts +23 -18
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/context.js +33 -0
- package/dist/internals/context.mjs +11 -0
- package/dist/internals/getClientArgs.d.ts +8 -2
- package/dist/internals/getClientArgs.d.ts.map +1 -1
- package/dist/internals/getClientArgs.js +24 -0
- package/dist/internals/getClientArgs.mjs +22 -0
- package/dist/internals/getQueryKey.d.ts +8 -13
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/internals/getQueryKey.js +60 -0
- package/dist/internals/getQueryKey.mjs +57 -0
- package/dist/internals/useHookResult.d.ts +4 -6
- package/dist/internals/useHookResult.d.ts.map +1 -1
- package/dist/internals/useHookResult.js +35 -0
- package/dist/internals/useHookResult.mjs +14 -0
- package/dist/internals/useQueries.d.ts +32 -4
- package/dist/internals/useQueries.d.ts.map +1 -1
- package/dist/server/index.js +2 -103
- package/dist/server/index.mjs +1 -104
- package/dist/server/ssgProxy.d.ts +21 -21
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/server/ssgProxy.js +109 -0
- package/dist/server/ssgProxy.mjs +107 -0
- package/dist/shared/hooks/createHooksInternal.d.ts +8 -31
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/{createHooksInternal-e2034194.js → shared/hooks/createHooksInternal.js} +98 -226
- package/dist/{createHooksInternal-3d8ebfcf.mjs → shared/hooks/createHooksInternal.mjs} +70 -210
- package/dist/shared/hooks/types.d.ts +11 -7
- package/dist/shared/hooks/types.d.ts.map +1 -1
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +14 -15
- package/dist/shared/index.mjs +7 -7
- package/dist/shared/polymorphism/mutationLike.d.ts +6 -7
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.ts +10 -7
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.ts +6 -6
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/utilsLike.d.ts +3 -3
- package/dist/shared/polymorphism/utilsLike.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/decorationProxy.js +31 -0
- package/dist/shared/proxy/decorationProxy.mjs +29 -0
- package/dist/shared/proxy/useQueriesProxy.d.ts +14 -8
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/useQueriesProxy.js +25 -0
- package/dist/shared/proxy/useQueriesProxy.mjs +23 -0
- package/dist/shared/proxy/utilsProxy.d.ts +28 -24
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.js +89 -0
- package/dist/shared/proxy/utilsProxy.mjs +85 -0
- package/dist/shared/queryClient.d.ts +2 -1
- package/dist/shared/queryClient.d.ts.map +1 -1
- package/dist/{queryClient-4d766c0c.mjs → shared/queryClient.mjs} +1 -1
- package/dist/shared/types.d.ts +2 -2
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/utils/createUtilityFunctions.d.ts +23 -0
- package/dist/utils/createUtilityFunctions.d.ts.map +1 -0
- package/dist/utils/createUtilityFunctions.js +100 -0
- package/dist/utils/createUtilityFunctions.mjs +98 -0
- package/dist/utils/inferReactQueryProcedure.d.ts +11 -10
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/createTRPCQueryUtils.tsx +11 -0
- package/src/createTRPCReact.tsx +139 -163
- package/src/index.ts +6 -1
- package/src/internals/context.tsx +27 -18
- package/src/internals/getClientArgs.ts +16 -4
- package/src/internals/getQueryKey.ts +51 -62
- package/src/internals/useHookResult.ts +12 -13
- package/src/internals/useQueries.ts +129 -4
- package/src/server/ssgProxy.ts +59 -57
- package/src/shared/hooks/createHooksInternal.tsx +115 -246
- package/src/shared/hooks/types.ts +15 -7
- package/src/shared/index.ts +5 -2
- package/src/shared/polymorphism/mutationLike.ts +21 -15
- package/src/shared/polymorphism/queryLike.ts +34 -14
- package/src/shared/polymorphism/routerLike.ts +29 -15
- package/src/shared/polymorphism/utilsLike.ts +6 -3
- package/src/shared/proxy/decorationProxy.ts +3 -3
- package/src/shared/proxy/useQueriesProxy.ts +65 -28
- package/src/shared/proxy/utilsProxy.ts +113 -86
- package/src/shared/queryClient.ts +2 -1
- package/src/shared/types.ts +5 -2
- package/src/utils/createUtilityFunctions.ts +137 -0
- package/src/utils/inferReactQueryProcedure.ts +38 -28
- package/dist/createHooksInternal-dce6e141.js +0 -435
- package/dist/queryClient-1c8d7d8a.js +0 -8
- package/dist/utilsProxy-00894da2.mjs +0 -121
- package/dist/utilsProxy-27bd93c1.js +0 -128
- package/dist/utilsProxy-7e396600.js +0 -114
- /package/dist/{queryClient-358a9a75.js → shared/queryClient.js} +0 -0
|
@@ -1,72 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useQuery, useSuspenseQuery, useQueryClient, useMutation, hashKey, useInfiniteQuery, useSuspenseInfiniteQuery, useQueries } from '@tanstack/react-query';
|
|
1
|
+
import { useQuery, useSuspenseQuery, useQueryClient, useMutation, hashKey, useInfiniteQuery, useSuspenseInfiniteQuery, useQueries, useSuspenseQueries, skipToken } from '@tanstack/react-query';
|
|
3
2
|
import { createTRPCUntypedClient } from '@trpc/client';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return createRecursiveProxy(({ path , args })=>{
|
|
12
|
-
const pathCopy = [
|
|
13
|
-
name,
|
|
14
|
-
...path
|
|
15
|
-
];
|
|
16
|
-
// The last arg is for instance `.useMutation` or `.useQuery()`
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
18
|
-
const lastArg = pathCopy.pop();
|
|
19
|
-
if (lastArg === 'useMutation') {
|
|
20
|
-
return hooks[lastArg](pathCopy, ...args);
|
|
21
|
-
}
|
|
22
|
-
if (lastArg === '_def') {
|
|
23
|
-
return {
|
|
24
|
-
path: pathCopy
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const [input, ...rest] = args;
|
|
28
|
-
const opts = rest[0] || {};
|
|
29
|
-
return hooks[lastArg](pathCopy, input, opts);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Create proxy for `useQueries` options
|
|
35
|
-
* @internal
|
|
36
|
-
*/ function createUseQueries(client) {
|
|
37
|
-
return createRecursiveProxy((opts)=>{
|
|
38
|
-
const arrayPath = opts.path;
|
|
39
|
-
const dotPath = arrayPath.join('.');
|
|
40
|
-
const [input, _opts] = opts.args;
|
|
41
|
-
const options = {
|
|
42
|
-
queryKey: getQueryKeyInternal(arrayPath, input, 'query'),
|
|
43
|
-
queryFn: ()=>{
|
|
44
|
-
return client.query(dotPath, input, _opts?.trpc);
|
|
45
|
-
},
|
|
46
|
-
..._opts
|
|
47
|
-
};
|
|
48
|
-
return options;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getClientArgs(queryKey, opts, pageParam) {
|
|
53
|
-
const path = queryKey[0];
|
|
54
|
-
const input = queryKey[1]?.input;
|
|
55
|
-
if (pageParam) input.cursor = pageParam;
|
|
56
|
-
return [
|
|
57
|
-
path.join('.'),
|
|
58
|
-
input,
|
|
59
|
-
opts?.trpc
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Makes a stable reference of the `trpc` prop
|
|
65
|
-
*/ function useHookResult(value) {
|
|
66
|
-
const ref = useRef(value);
|
|
67
|
-
ref.current.path = value.path;
|
|
68
|
-
return ref.current;
|
|
69
|
-
}
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { TRPCContext } from '../../internals/context.mjs';
|
|
5
|
+
import { getClientArgs } from '../../internals/getClientArgs.mjs';
|
|
6
|
+
import { getQueryKeyInternal } from '../../internals/getQueryKey.mjs';
|
|
7
|
+
import { useHookResult } from '../../internals/useHookResult.mjs';
|
|
8
|
+
import { createUtilityFunctions } from '../../utils/createUtilityFunctions.mjs';
|
|
9
|
+
import { createUseQueries } from '../proxy/useQueriesProxy.mjs';
|
|
70
10
|
|
|
71
11
|
/**
|
|
72
12
|
* @internal
|
|
@@ -78,127 +18,36 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
78
18
|
};
|
|
79
19
|
const TRPCProvider = (props)=>{
|
|
80
20
|
const { abortOnUnmount =false , client , queryClient , ssrContext } = props;
|
|
81
|
-
const [ssrState, setSSRState] = useState(props.ssrState ?? false);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
21
|
+
const [ssrState, setSSRState] = React.useState(props.ssrState ?? false);
|
|
22
|
+
const fns = React.useMemo(()=>createUtilityFunctions({
|
|
23
|
+
client,
|
|
24
|
+
queryClient
|
|
25
|
+
}), [
|
|
26
|
+
client,
|
|
27
|
+
queryClient
|
|
28
|
+
]);
|
|
29
|
+
const contextValue = React.useMemo(()=>({
|
|
89
30
|
abortOnUnmount,
|
|
90
31
|
queryClient,
|
|
91
32
|
client,
|
|
92
33
|
ssrContext: ssrContext ?? null,
|
|
93
34
|
ssrState,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
initialPageParam: opts?.initialCursor ?? null
|
|
112
|
-
});
|
|
113
|
-
}, [
|
|
114
|
-
client,
|
|
115
|
-
queryClient
|
|
116
|
-
]),
|
|
117
|
-
prefetchQuery: useCallback((queryKey, opts)=>{
|
|
118
|
-
return queryClient.prefetchQuery({
|
|
119
|
-
...opts,
|
|
120
|
-
queryKey,
|
|
121
|
-
queryFn: ()=>client.query(...getClientArgs(queryKey, opts))
|
|
122
|
-
});
|
|
123
|
-
}, [
|
|
124
|
-
client,
|
|
125
|
-
queryClient
|
|
126
|
-
]),
|
|
127
|
-
prefetchInfiniteQuery: useCallback((queryKey, opts)=>{
|
|
128
|
-
return queryClient.prefetchInfiniteQuery({
|
|
129
|
-
...opts,
|
|
130
|
-
queryKey,
|
|
131
|
-
queryFn: ({ pageParam })=>{
|
|
132
|
-
return client.query(...getClientArgs(queryKey, opts, pageParam));
|
|
133
|
-
},
|
|
134
|
-
initialPageParam: opts?.initialCursor ?? null
|
|
135
|
-
});
|
|
136
|
-
}, [
|
|
137
|
-
client,
|
|
138
|
-
queryClient
|
|
139
|
-
]),
|
|
140
|
-
ensureQueryData: useCallback((queryKey, opts)=>{
|
|
141
|
-
return queryClient.ensureQueryData({
|
|
142
|
-
...opts,
|
|
143
|
-
queryKey,
|
|
144
|
-
queryFn: ()=>client.query(...getClientArgs(queryKey, opts))
|
|
145
|
-
});
|
|
146
|
-
}, [
|
|
147
|
-
client,
|
|
148
|
-
queryClient
|
|
149
|
-
]),
|
|
150
|
-
invalidateQueries: useCallback((queryKey, filters, options)=>{
|
|
151
|
-
return queryClient.invalidateQueries({
|
|
152
|
-
...filters,
|
|
153
|
-
queryKey
|
|
154
|
-
}, options);
|
|
155
|
-
}, [
|
|
156
|
-
queryClient
|
|
157
|
-
]),
|
|
158
|
-
resetQueries: useCallback((queryKey, filters, options)=>{
|
|
159
|
-
return queryClient.resetQueries({
|
|
160
|
-
...filters,
|
|
161
|
-
queryKey
|
|
162
|
-
}, options);
|
|
163
|
-
}, [
|
|
164
|
-
queryClient
|
|
165
|
-
]),
|
|
166
|
-
refetchQueries: useCallback((queryKey, filters, options)=>{
|
|
167
|
-
return queryClient.refetchQueries({
|
|
168
|
-
...filters,
|
|
169
|
-
queryKey
|
|
170
|
-
}, options);
|
|
171
|
-
}, [
|
|
172
|
-
queryClient
|
|
173
|
-
]),
|
|
174
|
-
cancelQuery: useCallback((queryKey, options)=>{
|
|
175
|
-
return queryClient.cancelQueries({
|
|
176
|
-
queryKey
|
|
177
|
-
}, options);
|
|
178
|
-
}, [
|
|
179
|
-
queryClient
|
|
180
|
-
]),
|
|
181
|
-
setQueryData: useCallback((queryKey, updater, options)=>{
|
|
182
|
-
return queryClient.setQueryData(queryKey, updater, options);
|
|
183
|
-
}, [
|
|
184
|
-
queryClient
|
|
185
|
-
]),
|
|
186
|
-
getQueryData: useCallback((queryKey)=>{
|
|
187
|
-
return queryClient.getQueryData(queryKey);
|
|
188
|
-
}, [
|
|
189
|
-
queryClient
|
|
190
|
-
]),
|
|
191
|
-
setInfiniteQueryData: useCallback((queryKey, updater, options)=>{
|
|
192
|
-
return queryClient.setQueryData(queryKey, updater, options);
|
|
193
|
-
}, [
|
|
194
|
-
queryClient
|
|
195
|
-
]),
|
|
196
|
-
getInfiniteQueryData: useCallback((queryKey)=>{
|
|
197
|
-
return queryClient.getQueryData(queryKey);
|
|
198
|
-
}, [
|
|
199
|
-
queryClient
|
|
200
|
-
])
|
|
201
|
-
}
|
|
35
|
+
...fns
|
|
36
|
+
}), [
|
|
37
|
+
abortOnUnmount,
|
|
38
|
+
client,
|
|
39
|
+
fns,
|
|
40
|
+
queryClient,
|
|
41
|
+
ssrContext,
|
|
42
|
+
ssrState
|
|
43
|
+
]);
|
|
44
|
+
React.useEffect(()=>{
|
|
45
|
+
// Only updating state to `mounted` if we are using SSR.
|
|
46
|
+
// This makes it so we don't have an unnecessary re-render when opting out of SSR.
|
|
47
|
+
setSSRState((state)=>state ? 'mounted' : false);
|
|
48
|
+
}, []);
|
|
49
|
+
return /*#__PURE__*/ React.createElement(Context.Provider, {
|
|
50
|
+
value: contextValue
|
|
202
51
|
}, props.children);
|
|
203
52
|
};
|
|
204
53
|
function useContext() {
|
|
@@ -225,7 +74,8 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
225
74
|
const { abortOnUnmount , client , ssrState , queryClient , prefetchQuery } = context;
|
|
226
75
|
const queryKey = getQueryKeyInternal(path, input, 'query');
|
|
227
76
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
228
|
-
|
|
77
|
+
const isInputSkipToken = input === skipToken;
|
|
78
|
+
if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && (opts?.enabled ?? defaultOpts?.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({
|
|
229
79
|
queryKey
|
|
230
80
|
})) {
|
|
231
81
|
void prefetchQuery(queryKey, opts);
|
|
@@ -238,7 +88,7 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
238
88
|
const hook = useQuery({
|
|
239
89
|
...ssrOpts,
|
|
240
90
|
queryKey: queryKey,
|
|
241
|
-
queryFn: (queryFunctionContext)=>{
|
|
91
|
+
queryFn: isInputSkipToken ? input : (queryFunctionContext)=>{
|
|
242
92
|
const actualOpts = {
|
|
243
93
|
...ssrOpts,
|
|
244
94
|
trpc: {
|
|
@@ -252,7 +102,7 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
252
102
|
}
|
|
253
103
|
}, queryClient);
|
|
254
104
|
hook.trpc = useHookResult({
|
|
255
|
-
path
|
|
105
|
+
path
|
|
256
106
|
});
|
|
257
107
|
return hook;
|
|
258
108
|
}
|
|
@@ -275,7 +125,7 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
275
125
|
}
|
|
276
126
|
}, context.queryClient);
|
|
277
127
|
hook.trpc = useHookResult({
|
|
278
|
-
path
|
|
128
|
+
path
|
|
279
129
|
});
|
|
280
130
|
return [
|
|
281
131
|
hook.data,
|
|
@@ -310,7 +160,7 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
310
160
|
}
|
|
311
161
|
}, queryClient);
|
|
312
162
|
hook.trpc = useHookResult({
|
|
313
|
-
path
|
|
163
|
+
path
|
|
314
164
|
});
|
|
315
165
|
return hook;
|
|
316
166
|
}
|
|
@@ -318,9 +168,9 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
318
168
|
const enabled = opts?.enabled ?? true;
|
|
319
169
|
const queryKey = hashKey(getQueryKeyInternal(path, input, 'any'));
|
|
320
170
|
const { client } = useContext();
|
|
321
|
-
const optsRef = useRef(opts);
|
|
171
|
+
const optsRef = React.useRef(opts);
|
|
322
172
|
optsRef.current = opts;
|
|
323
|
-
useEffect(()=>{
|
|
173
|
+
React.useEffect(()=>{
|
|
324
174
|
if (!enabled) {
|
|
325
175
|
return;
|
|
326
176
|
}
|
|
@@ -356,7 +206,8 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
356
206
|
const { client , ssrState , prefetchInfiniteQuery , queryClient , abortOnUnmount , } = useContext();
|
|
357
207
|
const queryKey = getQueryKeyInternal(path, input, 'infinite');
|
|
358
208
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
359
|
-
|
|
209
|
+
const isInputSkipToken = input === skipToken;
|
|
210
|
+
if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && (opts?.enabled ?? defaultOpts?.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({
|
|
360
211
|
queryKey
|
|
361
212
|
})) {
|
|
362
213
|
void prefetchInfiniteQuery(queryKey, {
|
|
@@ -375,7 +226,7 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
375
226
|
initialPageParam: opts.initialCursor ?? null,
|
|
376
227
|
persister: opts.persister,
|
|
377
228
|
queryKey: queryKey,
|
|
378
|
-
queryFn: (queryFunctionContext)=>{
|
|
229
|
+
queryFn: isInputSkipToken ? input : (queryFunctionContext)=>{
|
|
379
230
|
const actualOpts = {
|
|
380
231
|
...ssrOpts,
|
|
381
232
|
trpc: {
|
|
@@ -385,11 +236,14 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
385
236
|
} : {}
|
|
386
237
|
}
|
|
387
238
|
};
|
|
388
|
-
return client.query(...getClientArgs(queryKey, actualOpts,
|
|
239
|
+
return client.query(...getClientArgs(queryKey, actualOpts, {
|
|
240
|
+
pageParam: queryFunctionContext.pageParam ?? opts.initialCursor,
|
|
241
|
+
direction: queryFunctionContext.direction
|
|
242
|
+
}));
|
|
389
243
|
}
|
|
390
244
|
}, queryClient);
|
|
391
245
|
hook.trpc = useHookResult({
|
|
392
|
-
path
|
|
246
|
+
path
|
|
393
247
|
});
|
|
394
248
|
return hook;
|
|
395
249
|
}
|
|
@@ -417,11 +271,14 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
417
271
|
} : {}
|
|
418
272
|
}
|
|
419
273
|
};
|
|
420
|
-
return context.client.query(...getClientArgs(queryKey, actualOpts,
|
|
274
|
+
return context.client.query(...getClientArgs(queryKey, actualOpts, {
|
|
275
|
+
pageParam: queryFunctionContext.pageParam ?? opts.initialCursor,
|
|
276
|
+
direction: queryFunctionContext.direction
|
|
277
|
+
}));
|
|
421
278
|
}
|
|
422
279
|
}, context.queryClient);
|
|
423
280
|
hook.trpc = useHookResult({
|
|
424
|
-
path
|
|
281
|
+
path
|
|
425
282
|
});
|
|
426
283
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
427
284
|
return [
|
|
@@ -450,17 +307,20 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
450
307
|
}))
|
|
451
308
|
}, queryClient);
|
|
452
309
|
};
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return
|
|
310
|
+
const useSuspenseQueries$1 = (queriesCallback)=>{
|
|
311
|
+
const { queryClient , client } = useContext();
|
|
312
|
+
const proxy = createUseQueries(client);
|
|
313
|
+
const queries = queriesCallback(proxy);
|
|
314
|
+
const hook = useSuspenseQueries({
|
|
315
|
+
queries: queries.map((query)=>({
|
|
316
|
+
...query,
|
|
317
|
+
queryKey: query.queryKey
|
|
318
|
+
}))
|
|
319
|
+
}, queryClient);
|
|
320
|
+
return [
|
|
321
|
+
hook.map((h)=>h.data),
|
|
322
|
+
hook
|
|
323
|
+
];
|
|
464
324
|
};
|
|
465
325
|
return {
|
|
466
326
|
Provider: TRPCProvider,
|
|
@@ -470,12 +330,12 @@ function getClientArgs(queryKey, opts, pageParam) {
|
|
|
470
330
|
useQuery: useQuery$1,
|
|
471
331
|
useSuspenseQuery: useSuspenseQuery$1,
|
|
472
332
|
useQueries: useQueries$1,
|
|
333
|
+
useSuspenseQueries: useSuspenseQueries$1,
|
|
473
334
|
useMutation: useMutation$1,
|
|
474
335
|
useSubscription,
|
|
475
|
-
useDehydratedState,
|
|
476
336
|
useInfiniteQuery: useInfiniteQuery$1,
|
|
477
337
|
useSuspenseInfiniteQuery: useSuspenseInfiniteQuery$1
|
|
478
338
|
};
|
|
479
339
|
}
|
|
480
340
|
|
|
481
|
-
export {
|
|
341
|
+
export { createRootHooks };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { DefinedUseQueryResult, DehydratedState, InfiniteData, InfiniteQueryObserverSuccessResult, InitialDataFunction, QueryObserverSuccessResult, QueryOptions, UseBaseQueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { CreateTRPCClientOptions, TRPCRequestOptions, TRPCUntypedClient } from '@trpc/client';
|
|
3
|
-
import { AnyRouter, DistributiveOmit } from '@trpc/server';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
import { TRPCContextProps } from '../../internals/context';
|
|
6
|
-
import { TRPCQueryKey } from '../../internals/getQueryKey';
|
|
7
|
-
import { TRPCHookResult } from '../../internals/useHookResult';
|
|
1
|
+
import type { DefinedUseQueryResult, DehydratedState, InfiniteData, InfiniteQueryObserverSuccessResult, InitialDataFunction, QueryObserverSuccessResult, QueryOptions, UseBaseQueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryResult, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { CreateTRPCClientOptions, TRPCRequestOptions, TRPCUntypedClient } from '@trpc/client';
|
|
3
|
+
import type { AnyRouter, DistributiveOmit } from '@trpc/server/unstable-core-do-not-import';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import type { TRPCContextProps } from '../../internals/context';
|
|
6
|
+
import type { TRPCQueryKey } from '../../internals/getQueryKey';
|
|
8
7
|
export type OutputWithCursor<TData, TCursor = any> = {
|
|
9
8
|
cursor: TCursor | null;
|
|
10
9
|
data: TData;
|
|
@@ -97,4 +96,9 @@ export type UseTRPCSuspenseInfiniteQueryResult<TData, TError, TInput> = [
|
|
|
97
96
|
* @internal
|
|
98
97
|
*/
|
|
99
98
|
export type UseTRPCMutationResult<TData, TError, TVariables, TContext> = TRPCHookResult & UseMutationResult<TData, TError, TVariables, TContext>;
|
|
99
|
+
export interface TRPCHookResult {
|
|
100
|
+
trpc: {
|
|
101
|
+
path: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
100
104
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,kCAAkC,EAClC,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,IAAI;IACnD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEF,MAAM,WAAW,uBAEf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC1C;;OAEG;IACH,GAAG,CAAC,EAAE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AAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,EAClE,MAAM,CACP,GACC,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,kCAAkC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI;IACtE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IAClE,8BAA8B,CAC5B,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,EAClE,MAAM,CACP,GACC,cAAc;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,IACnE,cAAc,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAE1E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './proxy/decorationProxy';
|
|
2
2
|
export * from './proxy/utilsProxy';
|
|
3
3
|
export * from './proxy/useQueriesProxy';
|
|
4
|
-
export type {
|
|
5
|
-
export type { TRPCUseQueries } from '../internals/useQueries';
|
|
4
|
+
export type { DecorateRouterRecord, DecorateProcedure, } from '../createTRPCReact';
|
|
5
|
+
export type { TRPCUseQueries, TRPCUseSuspenseQueries, } from '../internals/useQueries';
|
|
6
6
|
export * from './hooks/createRootHooks';
|
|
7
7
|
export * from './queryClient';
|
|
8
8
|
export * from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EACV,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,cAAc,EACd,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,OAAO;AACL;;GAEG;AACH,aAAa,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO;AACL;;GAEG;AACH,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC,cAAc,sBAAsB,CAAC"}
|
package/dist/shared/index.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var decorationProxy = require('./proxy/decorationProxy.js');
|
|
4
|
+
var utilsProxy = require('./proxy/utilsProxy.js');
|
|
5
|
+
var useQueriesProxy = require('./proxy/useQueriesProxy.js');
|
|
6
|
+
var createHooksInternal = require('./hooks/createHooksInternal.js');
|
|
7
|
+
var queryClient = require('./queryClient.js');
|
|
8
|
+
var getClientArgs = require('../internals/getClientArgs.js');
|
|
9
|
+
var context = require('../internals/context.js');
|
|
4
10
|
|
|
5
|
-
var createHooksInternal = require('../createHooksInternal-e2034194.js');
|
|
6
|
-
var utilsProxy = require('../utilsProxy-27bd93c1.js');
|
|
7
|
-
var queryClient = require('../queryClient-358a9a75.js');
|
|
8
|
-
require('@trpc/server/shared');
|
|
9
|
-
require('@tanstack/react-query');
|
|
10
|
-
require('@trpc/client');
|
|
11
|
-
require('react');
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
exports.
|
|
16
|
-
exports.createRootHooks = createHooksInternal.createRootHooks;
|
|
17
|
-
exports.createUseQueries = createHooksInternal.createUseQueries;
|
|
18
|
-
exports.getClientArgs = createHooksInternal.getClientArgs;
|
|
19
|
-
exports.TRPCContext = utilsProxy.TRPCContext;
|
|
20
|
-
exports.contextProps = utilsProxy.contextProps;
|
|
13
|
+
exports.createReactDecoration = decorationProxy.createReactDecoration;
|
|
14
|
+
exports.createQueryUtilsProxy = utilsProxy.createQueryUtilsProxy;
|
|
21
15
|
exports.createReactQueryUtils = utilsProxy.createReactQueryUtils;
|
|
22
16
|
exports.getQueryType = utilsProxy.getQueryType;
|
|
17
|
+
exports.createUseQueries = useQueriesProxy.createUseQueries;
|
|
18
|
+
exports.createRootHooks = createHooksInternal.createRootHooks;
|
|
23
19
|
exports.getQueryClient = queryClient.getQueryClient;
|
|
20
|
+
exports.getClientArgs = getClientArgs.getClientArgs;
|
|
21
|
+
exports.TRPCContext = context.TRPCContext;
|
|
22
|
+
exports.contextProps = context.contextProps;
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export { createReactDecoration } from './proxy/decorationProxy.mjs';
|
|
2
|
+
export { createQueryUtilsProxy, createReactQueryUtils, getQueryType } from './proxy/utilsProxy.mjs';
|
|
3
|
+
export { createUseQueries } from './proxy/useQueriesProxy.mjs';
|
|
4
|
+
export { createRootHooks } from './hooks/createHooksInternal.mjs';
|
|
5
|
+
export { getQueryClient } from './queryClient.mjs';
|
|
6
|
+
export { getClientArgs } from '../internals/getClientArgs.mjs';
|
|
7
|
+
export { TRPCContext, contextProps } from '../internals/context.mjs';
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { AnyProcedure,
|
|
2
|
-
import {
|
|
3
|
-
import { InferMutationOptions, InferMutationResult } from '../../utils/inferReactQueryProcedure';
|
|
1
|
+
import type { AnyProcedure, AnyRootTypes, inferProcedureInput, inferTransformedProcedureOutput } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { InferMutationOptions, InferMutationResult } from '../../utils/inferReactQueryProcedure';
|
|
4
3
|
/**
|
|
5
4
|
* Use to describe a mutation route which matches a given mutation procedure's interface
|
|
6
5
|
*/
|
|
7
|
-
export type MutationLike<
|
|
8
|
-
useMutation: (opts?: InferMutationOptions<
|
|
6
|
+
export type MutationLike<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = {
|
|
7
|
+
useMutation: (opts?: InferMutationOptions<TRoot, TProcedure>) => InferMutationResult<TRoot, TProcedure>;
|
|
9
8
|
};
|
|
10
9
|
/**
|
|
11
10
|
* Use to unwrap a MutationLike's input
|
|
12
11
|
*/
|
|
13
|
-
export type InferMutationLikeInput<TMutationLike extends MutationLike
|
|
12
|
+
export type InferMutationLikeInput<TMutationLike extends MutationLike<any, any>> = TMutationLike extends MutationLike<any, infer $Procedure> ? inferProcedureInput<$Procedure> : never;
|
|
14
13
|
/**
|
|
15
14
|
* Use to unwrap a MutationLike's data output
|
|
16
15
|
*/
|
|
17
|
-
export type InferMutationLikeData<TMutationLike extends MutationLike
|
|
16
|
+
export type InferMutationLikeData<TMutationLike extends MutationLike<any, any>> = TMutationLike extends MutationLike<infer TRoot, infer TProcedure> ? inferTransformedProcedureOutput<TRoot, TProcedure> : never;
|
|
18
17
|
//# sourceMappingURL=mutationLike.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutationLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/mutationLike.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mutationLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/mutationLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,+BAA+B,EAChC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,YAAY,CACtB,KAAK,SAAS,YAAY,EAC1B,UAAU,SAAS,YAAY,IAC7B;IACF,WAAW,EAAE,CACX,IAAI,CAAC,EAAE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,KAC3C,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAChC,aAAa,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,IAC1C,aAAa,SAAS,YAAY,CAAC,GAAG,EAAE,MAAM,UAAU,CAAC,GACzD,mBAAmB,CAAC,UAAU,CAAC,GAC/B,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAC/B,aAAa,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,IAC1C,aAAa,SAAS,YAAY,CAAC,MAAM,KAAK,EAAE,MAAM,UAAU,CAAC,GACjE,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,GAClD,KAAK,CAAC"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { inferTransformedProcedureOutput } from '@trpc/server/
|
|
3
|
-
import {
|
|
1
|
+
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
|
+
import type { AnyProcedure, AnyRootTypes, inferProcedureInput, inferProcedureOutput, inferTransformedProcedureOutput } from '@trpc/server/unstable-core-do-not-import';
|
|
3
|
+
import type { DecoratedQuery } from '../../createTRPCReact';
|
|
4
|
+
import type { InferQueryOptions, InferQueryResult } from '../../utils/inferReactQueryProcedure';
|
|
5
|
+
import type { UseTRPCSuspenseQueryResult } from '../hooks/types';
|
|
4
6
|
/**
|
|
5
7
|
* Use to request a query route which matches a given query procedure's interface
|
|
6
8
|
*/
|
|
7
|
-
export type QueryLike<
|
|
8
|
-
useQuery: (variables: inferProcedureInput<TProcedure>, opts?: InferQueryOptions<
|
|
9
|
+
export type QueryLike<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = {
|
|
10
|
+
useQuery: (variables: inferProcedureInput<TProcedure>, opts?: InferQueryOptions<TRoot, TProcedure, any>) => InferQueryResult<TRoot, TProcedure>;
|
|
11
|
+
useSuspenseQuery: (variables: inferProcedureInput<TProcedure>, opts?: InferQueryOptions<TRoot, TProcedure, any>) => UseTRPCSuspenseQueryResult<inferProcedureOutput<TProcedure>, TRPCClientErrorLike<TRoot>>;
|
|
9
12
|
};
|
|
10
13
|
/**
|
|
11
14
|
* Use to unwrap a QueryLike's input
|
|
12
15
|
*/
|
|
13
|
-
export type InferQueryLikeInput<TQueryLike extends
|
|
16
|
+
export type InferQueryLikeInput<TQueryLike> = TQueryLike extends DecoratedQuery<infer $Def> ? $Def['input'] : TQueryLike extends QueryLike<any, infer TProcedure> ? inferProcedureInput<TProcedure> : never;
|
|
14
17
|
/**
|
|
15
18
|
* Use to unwrap a QueryLike's data output
|
|
16
19
|
*/
|
|
17
|
-
export type InferQueryLikeData<TQueryLike extends
|
|
20
|
+
export type InferQueryLikeData<TQueryLike> = TQueryLike extends DecoratedQuery<infer $Def> ? $Def['output'] : TQueryLike extends QueryLike<infer TRoot, infer TProcedure> ? inferTransformedProcedureOutput<TRoot, TProcedure> : never;
|
|
18
21
|
//# sourceMappingURL=queryLike.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/queryLike.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"queryLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/queryLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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ACd,UAAU,SAAS,SAAS,CAAC,MAAM,KAAK,EAAE,MAAM,UAAU,CAAC,GAC3D,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,GAClD,KAAK,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AnyMutationProcedure,
|
|
2
|
-
import { MutationLike } from './mutationLike';
|
|
3
|
-
import { QueryLike } from './queryLike';
|
|
1
|
+
import type { AnyMutationProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { MutationLike } from './mutationLike';
|
|
3
|
+
import type { QueryLike } from './queryLike';
|
|
4
4
|
/**
|
|
5
5
|
* Use to describe a route path which matches a given route's interface
|
|
6
6
|
*/
|
|
7
|
-
export type RouterLike<TRouter extends AnyRouter> = RouterLikeInner<TRouter['_def']['_config'], TRouter['_def']['procedures']>;
|
|
8
|
-
export type RouterLikeInner<
|
|
9
|
-
[TKey in keyof
|
|
7
|
+
export type RouterLike<TRouter extends AnyRouter> = RouterLikeInner<TRouter['_def']['_config']['$types'], TRouter['_def']['procedures']>;
|
|
8
|
+
export type RouterLikeInner<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
|
|
9
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? RouterLikeInner<TRoot, $Value> : $Value extends AnyQueryProcedure ? QueryLike<TRoot, $Value> : $Value extends AnyMutationProcedure ? MutationLike<TRoot, $Value> : never : never;
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=routerLike.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/routerLike.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"routerLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/routerLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACb,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,SAAS,IAAI,eAAe,CACjE,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAC9B,CAAC;AACF,MAAM,MAAM,eAAe,CACzB,KAAK,SAAS,YAAY,EAC1B,OAAO,SAAS,YAAY,IAC1B;KACD,IAAI,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,MAAM,GACvD,MAAM,SAAS,YAAY,GACzB,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,GAC9B,MAAM,SAAS,iBAAiB,GAChC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,GACxB,MAAM,SAAS,oBAAoB,GACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,GAC3B,KAAK,GACP,KAAK;CACV,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AnyRouter } from '@trpc/server';
|
|
2
|
-
import { DecoratedProcedureUtilsRecord } from '../proxy/utilsProxy';
|
|
1
|
+
import type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { DecoratedProcedureUtilsRecord } from '../proxy/utilsProxy';
|
|
3
3
|
/**
|
|
4
4
|
* Use to describe a Utils/Context path which matches the given route's interface
|
|
5
5
|
*/
|
|
6
|
-
export type UtilsLike<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter>;
|
|
6
|
+
export type UtilsLike<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
|
|
7
7
|
//# sourceMappingURL=utilsLike.d.ts.map
|