@trpc/react-query 11.0.0-next-beta.242 → 11.0.0-next-beta.285
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 +28 -28
- package/dist/createTRPCReact.d.ts +6 -7
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/internals/getQueryKey.d.ts +2 -2
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/internals/useQueries.d.ts +2 -2
- package/dist/internals/useQueries.d.ts.map +1 -1
- package/dist/server/ssgProxy.d.ts +7 -7
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/server/ssgProxy.js +5 -3
- package/dist/server/ssgProxy.mjs +5 -3
- package/dist/shared/hooks/createHooksInternal.d.ts +1 -3
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/hooks/createHooksInternal.js +0 -13
- package/dist/shared/hooks/createHooksInternal.mjs +0 -13
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.ts +3 -3
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/utilsLike.d.ts +1 -1
- package/dist/shared/polymorphism/utilsLike.d.ts.map +1 -1
- package/dist/shared/proxy/useQueriesProxy.d.ts +7 -7
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.d.ts +6 -6
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/utils/inferReactQueryProcedure.d.ts +5 -3
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +10 -14
- package/src/internals/getQueryKey.ts +2 -2
- package/src/internals/useQueries.ts +8 -2
- package/src/server/ssgProxy.ts +31 -22
- package/src/shared/hooks/createHooksInternal.tsx +0 -17
- package/src/shared/index.ts +1 -1
- package/src/shared/polymorphism/routerLike.ts +10 -8
- package/src/shared/polymorphism/utilsLike.ts +4 -1
- package/src/shared/proxy/useQueriesProxy.ts +28 -23
- package/src/shared/proxy/utilsProxy.ts +21 -16
- package/src/utils/inferReactQueryProcedure.ts +18 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueriesProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/useQueriesProxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"useQueriesProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/useQueriesProxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,+BAA+B,EAC/B,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,6BAA6B,EAC7B,qCAAqC,EACtC,MAAM,4BAA4B,CAAC;AAGpC,KAAK,eAAe,CAClB,KAAK,SAAS,YAAY,EAC1B,UAAU,SAAS,YAAY,IAC7B,CAAC,KAAK,GAAG,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7D,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,EACtC,IAAI,CAAC,EAAE,6BAA6B,CAClC,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,EAClD,KAAK,EACL,eAAe,CAAC,KAAK,CAAC,CACvB,KACE,6BAA6B,CAChC,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,EAClD,KAAK,EACL,eAAe,CAAC,KAAK,CAAC,CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBA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{ CancelOptions, InfiniteData, InvalidateOptions, InvalidateQueryFilters, Query, RefetchOptions, RefetchQueryFilters, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
|
2
2
|
import type { TRPCClientError } from '@trpc/client';
|
|
3
|
-
import type { AnyQueryProcedure, AnyRootTypes, AnyRouter, DeepPartial,
|
|
3
|
+
import type { AnyQueryProcedure, AnyRootTypes, AnyRouter, DeepPartial, inferProcedureInput, inferTransformedProcedureOutput, ProtectedIntersection, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
4
4
|
import type { DecoratedTRPCContextProps, TRPCContextState, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions, TRPCQueryUtils } from '../../internals/context';
|
|
5
5
|
import type { QueryKeyKnown, QueryType } from '../../internals/getQueryKey';
|
|
6
6
|
import type { ExtractCursorType } from '../hooks/types';
|
|
@@ -81,17 +81,17 @@ type DecorateRouter = {
|
|
|
81
81
|
/**
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
84
|
-
export type DecoratedProcedureUtilsRecord<
|
|
85
|
-
[TKey in keyof
|
|
84
|
+
export type DecoratedProcedureUtilsRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = DecorateRouter & {
|
|
85
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? DecoratedProcedureUtilsRecord<TRoot, $Value> & DecorateRouter : $Value extends AnyQueryProcedure ? DecorateProcedure<TRoot, $Value> : never : never;
|
|
86
86
|
};
|
|
87
87
|
type AnyDecoratedProcedure = DecorateProcedure<any, any>;
|
|
88
|
-
export type CreateReactUtils<TRouter extends AnyRouter, TSSRContext> = ProtectedIntersection<DecoratedTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter>>;
|
|
89
|
-
export type CreateQueryUtils<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter>;
|
|
88
|
+
export type CreateReactUtils<TRouter extends AnyRouter, TSSRContext> = ProtectedIntersection<DecoratedTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>>;
|
|
89
|
+
export type CreateQueryUtils<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
|
|
90
90
|
export declare const getQueryType: (utilName: keyof AnyDecoratedProcedure) => QueryType;
|
|
91
91
|
/**
|
|
92
92
|
* @internal
|
|
93
93
|
*/
|
|
94
|
-
export declare function createReactQueryUtils<TRouter extends AnyRouter, TSSRContext>(context: TRPCContextState<AnyRouter, TSSRContext>): ProtectedIntersection<DecoratedTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter>>;
|
|
94
|
+
export declare function createReactQueryUtils<TRouter extends AnyRouter, TSSRContext>(context: TRPCContextState<AnyRouter, TSSRContext>): ProtectedIntersection<DecoratedTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>>;
|
|
95
95
|
/**
|
|
96
96
|
* @internal
|
|
97
97
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/utilsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"utilsProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/utilsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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C,6BAA6B,CAC3B,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAC1B,CACF,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,IACpD,6BAA6B,CAC3B,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAC1B,CAAC;AAEJ,eAAO,MAAM,YAAY,aACb,MAAM,qBAAqB,KACpC,SAqBF,CAAC;AA2CF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAAE,WAAW,EAC1E,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,0KAelD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAC/B,gBAAgB,CAAC,OAAO,CAAC,CAI3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
|
-
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, inferProcedureInput, inferTransformedProcedureOutput } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, inferProcedureInput, inferTransformedProcedureOutput, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type { UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult } from '../shared';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
@@ -17,7 +17,9 @@ export type InferQueryResult<TRoot extends AnyRootTypes, TProcedure extends AnyP
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export type InferMutationResult<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure, TContext = unknown> = UseTRPCMutationResult<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientErrorLike<TRoot>, inferProcedureInput<TProcedure>, TContext>;
|
|
20
|
-
|
|
21
|
-
[TKey in keyof
|
|
20
|
+
type inferReactQueryProcedureOptionsInner<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
|
|
21
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? inferReactQueryProcedureOptionsInner<TRoot, $Value> : $Value extends AnyMutationProcedure ? InferMutationOptions<TRoot, $Value> : $Value extends AnyQueryProcedure ? InferQueryOptions<TRoot, $Value> : never : never;
|
|
22
22
|
};
|
|
23
|
+
export type inferReactQueryProcedureOptions<TRouter extends AnyRouter> = inferReactQueryProcedureOptionsInner<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
|
|
24
|
+
export {};
|
|
23
25
|
//# sourceMappingURL=inferReactQueryProcedure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inferReactQueryProcedure.d.ts","sourceRoot":"","sources":["../../src/utils/inferReactQueryProcedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,+BAA+B,
|
|
1
|
+
{"version":3,"file":"inferReactQueryProcedure.d.ts","sourceRoot":"","sources":["../../src/utils/inferReactQueryProcedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,+BAA+B,EAC/B,YAAY,EACb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,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,MAAM,MAAM,GACvD,MAAM,SAAS,YAAY,GACzB,oCAAoC,CAAC,KAAK,EAAE,MAAM,CAAC,GACnD,MAAM,SAAS,oBAAoB,GACnC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,GACnC,MAAM,SAAS,iBAAiB,GAChC,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,GAChC,KAAK,GACP,KAAK;CACV,CAAC;AAEF,MAAM,MAAM,+BAA+B,CAAC,OAAO,SAAS,SAAS,IACnE,oCAAoC,CAClC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
|
-
"version": "11.0.0-next-beta.
|
|
3
|
+
"version": "11.0.0-next-beta.285+e18d84950",
|
|
4
4
|
"description": "The tRPC React library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@tanstack/react-query": "^5.0.0",
|
|
61
|
-
"@trpc/client": "11.0.0-next-beta.
|
|
62
|
-
"@trpc/server": "11.0.0-next-beta.
|
|
61
|
+
"@trpc/client": "11.0.0-next-beta.285+e18d84950",
|
|
62
|
+
"@trpc/server": "11.0.0-next-beta.285+e18d84950",
|
|
63
63
|
"react": ">=18.2.0",
|
|
64
64
|
"react-dom": ">=18.2.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@tanstack/react-query": "^5.0.0",
|
|
68
|
-
"@trpc/client": "11.0.0-next-beta.
|
|
69
|
-
"@trpc/server": "11.0.0-next-beta.
|
|
68
|
+
"@trpc/client": "11.0.0-next-beta.285+e18d84950",
|
|
69
|
+
"@trpc/server": "11.0.0-next-beta.285+e18d84950",
|
|
70
70
|
"@types/express": "^4.17.17",
|
|
71
71
|
"@types/node": "^20.10.0",
|
|
72
72
|
"@types/react": "^18.2.33",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"funding": [
|
|
86
86
|
"https://trpc.io/sponsor"
|
|
87
87
|
],
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "e18d84950b13f4cfce437473dde62e39a27c4879"
|
|
89
89
|
}
|
package/src/createTRPCReact.tsx
CHANGED
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
inferProcedureInput,
|
|
10
10
|
inferTransformedProcedureOutput,
|
|
11
11
|
inferTransformedSubscriptionOutput,
|
|
12
|
-
ProcedureRouterRecord,
|
|
13
12
|
ProtectedIntersection,
|
|
13
|
+
RouterRecord,
|
|
14
14
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
15
15
|
import { createFlatProxy } from '@trpc/server/unstable-core-do-not-import';
|
|
16
16
|
import * as React from 'react';
|
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
DefinedUseTRPCQueryOptions,
|
|
28
28
|
DefinedUseTRPCQueryResult,
|
|
29
29
|
TRPCProvider,
|
|
30
|
-
UseDehydratedState,
|
|
31
30
|
UseTRPCInfiniteQueryOptions,
|
|
32
31
|
UseTRPCInfiniteQueryResult,
|
|
33
32
|
UseTRPCMutationOptions,
|
|
@@ -223,19 +222,17 @@ export type DecorateProcedure<
|
|
|
223
222
|
/**
|
|
224
223
|
* @internal
|
|
225
224
|
*/
|
|
226
|
-
export type
|
|
225
|
+
export type DecorateRouterRecord<
|
|
227
226
|
TRoot extends AnyRootTypes,
|
|
228
|
-
|
|
227
|
+
TRecord extends RouterRecord,
|
|
229
228
|
TFlags,
|
|
230
229
|
> = {
|
|
231
|
-
[TKey in keyof
|
|
232
|
-
?
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
: TProcedures[TKey] extends AnyProcedure
|
|
238
|
-
? DecorateProcedure<TRoot, TProcedures[TKey], TFlags>
|
|
230
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
231
|
+
? $Value extends RouterRecord
|
|
232
|
+
? DecorateRouterRecord<TRoot, $Value, TFlags>
|
|
233
|
+
: $Value extends AnyProcedure
|
|
234
|
+
? DecorateProcedure<TRoot, $Value, TFlags>
|
|
235
|
+
: never
|
|
239
236
|
: never;
|
|
240
237
|
};
|
|
241
238
|
|
|
@@ -257,7 +254,6 @@ export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
|
|
|
257
254
|
createClient: CreateClient<TRouter>;
|
|
258
255
|
useQueries: TRPCUseQueries<TRouter>;
|
|
259
256
|
useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;
|
|
260
|
-
useDehydratedState: UseDehydratedState<TRouter>;
|
|
261
257
|
};
|
|
262
258
|
|
|
263
259
|
export type CreateTRPCReact<
|
|
@@ -266,7 +262,7 @@ export type CreateTRPCReact<
|
|
|
266
262
|
TFlags,
|
|
267
263
|
> = ProtectedIntersection<
|
|
268
264
|
CreateTRPCReactBase<TRouter, TSSRContext>,
|
|
269
|
-
|
|
265
|
+
DecorateRouterRecord<
|
|
270
266
|
TRouter['_def']['_config']['$types'],
|
|
271
267
|
TRouter['_def']['record'],
|
|
272
268
|
TFlags
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
DeepPartial,
|
|
7
7
|
inferProcedureInput,
|
|
8
8
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
9
|
-
import type {
|
|
9
|
+
import type { DecorateProcedure, DecorateRouterRecord } from '../shared';
|
|
10
10
|
|
|
11
11
|
export type QueryType = 'any' | 'infinite' | 'query';
|
|
12
12
|
|
|
@@ -100,7 +100,7 @@ type GetParams<
|
|
|
100
100
|
? [procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>]
|
|
101
101
|
: TProcedureOrRouter extends AnyRouter
|
|
102
102
|
? [
|
|
103
|
-
procedureOrRouter:
|
|
103
|
+
procedureOrRouter: DecorateRouterRecord<
|
|
104
104
|
TRoot,
|
|
105
105
|
TProcedureOrRouter['_def']['record'],
|
|
106
106
|
TFlags
|
|
@@ -179,7 +179,10 @@ export type TRPCUseQueries<TRouter extends AnyRouter> = <
|
|
|
179
179
|
TQueryOptions extends UseQueryOptionsForUseQueries<any, any, any, any>[],
|
|
180
180
|
>(
|
|
181
181
|
queriesCallback: (
|
|
182
|
-
t: UseQueriesProcedureRecord<
|
|
182
|
+
t: UseQueriesProcedureRecord<
|
|
183
|
+
TRouter['_def']['_config']['$types'],
|
|
184
|
+
TRouter['_def']['record']
|
|
185
|
+
>,
|
|
183
186
|
) => readonly [...QueriesOptions<TQueryOptions>],
|
|
184
187
|
) => QueriesResults<TQueryOptions>;
|
|
185
188
|
|
|
@@ -195,6 +198,9 @@ export type TRPCUseSuspenseQueries<TRouter extends AnyRouter> = <
|
|
|
195
198
|
>[],
|
|
196
199
|
>(
|
|
197
200
|
queriesCallback: (
|
|
198
|
-
t: UseSuspenseQueriesProcedureRecord<
|
|
201
|
+
t: UseSuspenseQueriesProcedureRecord<
|
|
202
|
+
TRouter['_def']['_config']['$types'],
|
|
203
|
+
TRouter['_def']['record']
|
|
204
|
+
>,
|
|
199
205
|
) => readonly [...SuspenseQueriesOptions<TQueryOptions>],
|
|
200
206
|
) => SuspenseQueriesResults<TQueryOptions>;
|
package/src/server/ssgProxy.ts
CHANGED
|
@@ -7,18 +7,23 @@ import type {
|
|
|
7
7
|
import { dehydrate } from '@tanstack/react-query';
|
|
8
8
|
import type { inferRouterClient, TRPCClientError } from '@trpc/client';
|
|
9
9
|
import { getUntypedClient, TRPCUntypedClient } from '@trpc/client';
|
|
10
|
+
import type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';
|
|
11
|
+
import {
|
|
12
|
+
getTransformer,
|
|
13
|
+
type TransformerOptions,
|
|
14
|
+
} from '@trpc/client/unstable-internals';
|
|
10
15
|
import type {
|
|
11
16
|
AnyProcedure,
|
|
12
17
|
AnyQueryProcedure,
|
|
13
18
|
AnyRootTypes,
|
|
14
19
|
AnyRouter,
|
|
15
|
-
DataTransformerOptions,
|
|
16
|
-
Filter,
|
|
17
20
|
inferProcedureInput,
|
|
21
|
+
inferRootTypes,
|
|
18
22
|
inferRouterContext,
|
|
19
23
|
inferTransformedProcedureOutput,
|
|
20
24
|
Maybe,
|
|
21
25
|
ProtectedIntersection,
|
|
26
|
+
RouterRecord,
|
|
22
27
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
23
28
|
import {
|
|
24
29
|
callProcedure,
|
|
@@ -34,11 +39,10 @@ import type {
|
|
|
34
39
|
} from '../shared';
|
|
35
40
|
import { getQueryClient, getQueryType } from '../shared';
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
type CreateSSGHelpersInternal<TRouter extends AnyRouter> = {
|
|
38
43
|
router: TRouter;
|
|
39
44
|
ctx: inferRouterContext<TRouter>;
|
|
40
|
-
|
|
41
|
-
}
|
|
45
|
+
} & TransformerOptions<inferRootTypes<TRouter>>;
|
|
42
46
|
|
|
43
47
|
interface CreateSSGHelpersExternal<TRouter extends AnyRouter> {
|
|
44
48
|
client: inferRouterClient<TRouter> | TRPCUntypedClient<TRouter>;
|
|
@@ -107,17 +111,18 @@ type DecorateProcedure<
|
|
|
107
111
|
/**
|
|
108
112
|
* @internal
|
|
109
113
|
*/
|
|
110
|
-
type DecoratedProcedureSSGRecord<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
?
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
type DecoratedProcedureSSGRecord<
|
|
115
|
+
TRoot extends AnyRootTypes,
|
|
116
|
+
TRecord extends RouterRecord,
|
|
117
|
+
> = {
|
|
118
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
119
|
+
? $Value extends RouterRecord
|
|
120
|
+
? DecoratedProcedureSSGRecord<TRoot, $Value>
|
|
121
|
+
: // utils only apply to queries
|
|
122
|
+
$Value extends AnyQueryProcedure
|
|
123
|
+
? DecorateProcedure<TRoot, $Value>
|
|
124
|
+
: never
|
|
125
|
+
: never;
|
|
121
126
|
};
|
|
122
127
|
|
|
123
128
|
type AnyDecoratedProcedure = DecorateProcedure<any, any>;
|
|
@@ -130,17 +135,18 @@ export function createServerSideHelpers<TRouter extends AnyRouter>(
|
|
|
130
135
|
opts: CreateServerSideHelpersOptions<TRouter>,
|
|
131
136
|
) {
|
|
132
137
|
const queryClient = getQueryClient(opts);
|
|
138
|
+
const transformer = getTransformer(
|
|
139
|
+
(opts as CoercedTransformerParameters).transformer,
|
|
140
|
+
);
|
|
133
141
|
|
|
134
142
|
const resolvedOpts: {
|
|
135
143
|
serialize: (obj: unknown) => any;
|
|
136
144
|
query: (queryOpts: { path: string; input: unknown }) => Promise<unknown>;
|
|
137
145
|
} = (() => {
|
|
138
146
|
if ('router' in opts) {
|
|
139
|
-
const {
|
|
147
|
+
const { ctx, router } = opts;
|
|
140
148
|
return {
|
|
141
|
-
serialize: transformer
|
|
142
|
-
? ('input' in transformer ? transformer.input : transformer).serialize
|
|
143
|
-
: (obj) => obj,
|
|
149
|
+
serialize: transformer.output.serialize,
|
|
144
150
|
query: (queryOpts) => {
|
|
145
151
|
return callProcedure({
|
|
146
152
|
procedures: router._def.procedures,
|
|
@@ -160,7 +166,7 @@ export function createServerSideHelpers<TRouter extends AnyRouter>(
|
|
|
160
166
|
return {
|
|
161
167
|
query: (queryOpts) =>
|
|
162
168
|
untypedClient.query(queryOpts.path, queryOpts.input),
|
|
163
|
-
serialize: (obj) =>
|
|
169
|
+
serialize: (obj) => transformer.output.serialize(obj),
|
|
164
170
|
};
|
|
165
171
|
})();
|
|
166
172
|
|
|
@@ -182,7 +188,10 @@ export function createServerSideHelpers<TRouter extends AnyRouter>(
|
|
|
182
188
|
queryClient: QueryClient;
|
|
183
189
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
184
190
|
},
|
|
185
|
-
DecoratedProcedureSSGRecord<
|
|
191
|
+
DecoratedProcedureSSGRecord<
|
|
192
|
+
TRouter['_def']['_config']['$types'],
|
|
193
|
+
TRouter['_def']['record']
|
|
194
|
+
>
|
|
186
195
|
>;
|
|
187
196
|
|
|
188
197
|
return createFlatProxy<CreateSSGHelpers>((key) => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DehydratedState } from '@tanstack/react-query';
|
|
2
1
|
import {
|
|
3
2
|
useInfiniteQuery as __useInfiniteQuery,
|
|
4
3
|
useMutation as __useMutation,
|
|
@@ -31,7 +30,6 @@ import type {
|
|
|
31
30
|
CreateClient,
|
|
32
31
|
TRPCProvider,
|
|
33
32
|
TRPCQueryOptions,
|
|
34
|
-
UseDehydratedState,
|
|
35
33
|
UseTRPCInfiniteQueryOptions,
|
|
36
34
|
UseTRPCInfiniteQueryResult,
|
|
37
35
|
UseTRPCMutationOptions,
|
|
@@ -490,20 +488,6 @@ export function createRootHooks<
|
|
|
490
488
|
return [hook.map((h) => h.data), hook] as any;
|
|
491
489
|
};
|
|
492
490
|
|
|
493
|
-
const useDehydratedState: UseDehydratedState<TRouter> = (
|
|
494
|
-
client,
|
|
495
|
-
trpcState,
|
|
496
|
-
) => {
|
|
497
|
-
const transformed: DehydratedState | undefined = React.useMemo(() => {
|
|
498
|
-
if (!trpcState) {
|
|
499
|
-
return trpcState;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return client.runtime.transformer.deserialize(trpcState);
|
|
503
|
-
}, [trpcState, client]);
|
|
504
|
-
return transformed;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
491
|
return {
|
|
508
492
|
Provider: TRPCProvider,
|
|
509
493
|
createClient,
|
|
@@ -515,7 +499,6 @@ export function createRootHooks<
|
|
|
515
499
|
useSuspenseQueries,
|
|
516
500
|
useMutation,
|
|
517
501
|
useSubscription,
|
|
518
|
-
useDehydratedState,
|
|
519
502
|
useInfiniteQuery,
|
|
520
503
|
useSuspenseInfiniteQuery,
|
|
521
504
|
};
|
package/src/shared/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyMutationProcedure,
|
|
3
|
-
AnyProcedure,
|
|
4
3
|
AnyQueryProcedure,
|
|
5
4
|
AnyRootTypes,
|
|
6
5
|
AnyRouter,
|
|
6
|
+
RouterRecord,
|
|
7
7
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
8
8
|
import type { MutationLike } from './mutationLike';
|
|
9
9
|
import type { QueryLike } from './queryLike';
|
|
@@ -17,13 +17,15 @@ export type RouterLike<TRouter extends AnyRouter> = RouterLikeInner<
|
|
|
17
17
|
>;
|
|
18
18
|
export type RouterLikeInner<
|
|
19
19
|
TRoot extends AnyRootTypes,
|
|
20
|
-
|
|
20
|
+
TRecord extends RouterRecord,
|
|
21
21
|
> = {
|
|
22
|
-
[TKey in keyof
|
|
23
|
-
?
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
23
|
+
? $Value extends RouterRecord
|
|
24
|
+
? RouterLikeInner<TRoot, $Value>
|
|
25
|
+
: $Value extends AnyQueryProcedure
|
|
26
|
+
? QueryLike<TRoot, $Value>
|
|
27
|
+
: $Value extends AnyMutationProcedure
|
|
28
|
+
? MutationLike<TRoot, $Value>
|
|
29
|
+
: never
|
|
28
30
|
: never;
|
|
29
31
|
};
|
|
@@ -5,4 +5,7 @@ import type { DecoratedProcedureUtilsRecord } from '../proxy/utilsProxy';
|
|
|
5
5
|
* Use to describe a Utils/Context path which matches the given route's interface
|
|
6
6
|
*/
|
|
7
7
|
export type UtilsLike<TRouter extends AnyRouter> =
|
|
8
|
-
DecoratedProcedureUtilsRecord<
|
|
8
|
+
DecoratedProcedureUtilsRecord<
|
|
9
|
+
TRouter['_def']['_config']['$types'],
|
|
10
|
+
TRouter['_def']['record']
|
|
11
|
+
>;
|
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
AnyQueryProcedure,
|
|
6
6
|
AnyRootTypes,
|
|
7
7
|
AnyRouter,
|
|
8
|
-
Filter,
|
|
9
8
|
inferProcedureInput,
|
|
10
9
|
inferTransformedProcedureOutput,
|
|
10
|
+
RouterRecord,
|
|
11
11
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
12
12
|
import { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';
|
|
13
13
|
import { getQueryKeyInternal } from '../../internals/getQueryKey';
|
|
@@ -36,21 +36,22 @@ type GetQueryOptions<
|
|
|
36
36
|
/**
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
|
-
export type UseQueriesProcedureRecord<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
?
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
export type UseQueriesProcedureRecord<
|
|
40
|
+
TRoot extends AnyRootTypes,
|
|
41
|
+
TRecord extends RouterRecord,
|
|
42
|
+
> = {
|
|
43
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
44
|
+
? $Value extends RouterRecord
|
|
45
|
+
? UseQueriesProcedureRecord<TRoot, $Value>
|
|
46
|
+
: $Value extends AnyQueryProcedure
|
|
47
|
+
? GetQueryOptions<TRoot, $Value>
|
|
48
|
+
: never
|
|
49
|
+
: never;
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
type GetSuspenseQueryOptions<
|
|
52
53
|
TRoot extends AnyRootTypes,
|
|
53
|
-
TProcedure extends
|
|
54
|
+
TProcedure extends AnyQueryProcedure,
|
|
54
55
|
> = <TData = inferTransformedProcedureOutput<TRoot, TProcedure>>(
|
|
55
56
|
input: inferProcedureInput<TProcedure>,
|
|
56
57
|
opts?: TrpcQueryOptionsForUseSuspenseQueries<
|
|
@@ -67,16 +68,17 @@ type GetSuspenseQueryOptions<
|
|
|
67
68
|
/**
|
|
68
69
|
* @internal
|
|
69
70
|
*/
|
|
70
|
-
export type UseSuspenseQueriesProcedureRecord<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
?
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
export type UseSuspenseQueriesProcedureRecord<
|
|
72
|
+
TRoot extends AnyRootTypes,
|
|
73
|
+
TRecord extends RouterRecord,
|
|
74
|
+
> = {
|
|
75
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
76
|
+
? $Value extends RouterRecord
|
|
77
|
+
? UseSuspenseQueriesProcedureRecord<TRoot, $Value>
|
|
78
|
+
: $Value extends AnyQueryProcedure
|
|
79
|
+
? GetSuspenseQueryOptions<TRoot, $Value>
|
|
80
|
+
: never
|
|
81
|
+
: never;
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
/**
|
|
@@ -103,5 +105,8 @@ export function createUseQueries<TRouter extends AnyRouter>(
|
|
|
103
105
|
};
|
|
104
106
|
|
|
105
107
|
return options;
|
|
106
|
-
}) as UseQueriesProcedureRecord<
|
|
108
|
+
}) as UseQueriesProcedureRecord<
|
|
109
|
+
TRouter['_def']['_config']['$types'],
|
|
110
|
+
TRouter['_def']['record']
|
|
111
|
+
>;
|
|
107
112
|
}
|
|
@@ -17,10 +17,10 @@ import type {
|
|
|
17
17
|
AnyRootTypes,
|
|
18
18
|
AnyRouter,
|
|
19
19
|
DeepPartial,
|
|
20
|
-
Filter,
|
|
21
20
|
inferProcedureInput,
|
|
22
21
|
inferTransformedProcedureOutput,
|
|
23
22
|
ProtectedIntersection,
|
|
23
|
+
RouterRecord,
|
|
24
24
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
25
25
|
import {
|
|
26
26
|
createFlatProxy,
|
|
@@ -227,20 +227,19 @@ type DecorateRouter = {
|
|
|
227
227
|
/**
|
|
228
228
|
* @internal
|
|
229
229
|
*/
|
|
230
|
-
export type DecoratedProcedureUtilsRecord<
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
? DecoratedProcedureUtilsRecord<
|
|
237
|
-
DecorateRouter
|
|
230
|
+
export type DecoratedProcedureUtilsRecord<
|
|
231
|
+
TRoot extends AnyRootTypes,
|
|
232
|
+
TRecord extends RouterRecord,
|
|
233
|
+
> = DecorateRouter & {
|
|
234
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
235
|
+
? $Value extends RouterRecord
|
|
236
|
+
? DecoratedProcedureUtilsRecord<TRoot, $Value> & DecorateRouter
|
|
238
237
|
: // utils only apply to queries
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
$Value extends AnyQueryProcedure
|
|
239
|
+
? DecorateProcedure<TRoot, $Value>
|
|
240
|
+
: never
|
|
241
|
+
: never;
|
|
242
|
+
}; // Add functions that should be available at utils root
|
|
244
243
|
|
|
245
244
|
type AnyDecoratedProcedure = DecorateProcedure<any, any>;
|
|
246
245
|
|
|
@@ -249,11 +248,17 @@ export type CreateReactUtils<
|
|
|
249
248
|
TSSRContext,
|
|
250
249
|
> = ProtectedIntersection<
|
|
251
250
|
DecoratedTRPCContextProps<TRouter, TSSRContext>,
|
|
252
|
-
DecoratedProcedureUtilsRecord<
|
|
251
|
+
DecoratedProcedureUtilsRecord<
|
|
252
|
+
TRouter['_def']['_config']['$types'],
|
|
253
|
+
TRouter['_def']['record']
|
|
254
|
+
>
|
|
253
255
|
>;
|
|
254
256
|
|
|
255
257
|
export type CreateQueryUtils<TRouter extends AnyRouter> =
|
|
256
|
-
DecoratedProcedureUtilsRecord<
|
|
258
|
+
DecoratedProcedureUtilsRecord<
|
|
259
|
+
TRouter['_def']['_config']['$types'],
|
|
260
|
+
TRouter['_def']['record']
|
|
261
|
+
>;
|
|
257
262
|
|
|
258
263
|
export const getQueryType = (
|
|
259
264
|
utilName: keyof AnyDecoratedProcedure,
|