@trpc/react-query 11.0.0-next-beta.264 → 11.0.0-next-beta.272
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 +8 -8
- package/dist/createTRPCReact.d.ts +38 -24
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/internals/getQueryKey.d.ts +6 -11
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/internals/getQueryKey.js +2 -2
- package/dist/internals/getQueryKey.mjs +2 -2
- package/dist/server/ssgProxy.d.ts +2 -2
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.ts +3 -2
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +102 -121
- package/src/internals/getQueryKey.ts +18 -57
- package/src/server/ssgProxy.ts +2 -2
- package/src/shared/polymorphism/queryLike.ts +15 -8
- package/src/shared/polymorphism/routerLike.ts +12 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bundleSize": 27242,
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
3
|
+
"bundleOrigSize": 60201,
|
|
4
|
+
"bundleReduction": 54.75,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/shared/hooks/createHooksInternal.tsx",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
{
|
|
21
21
|
"id": "/src/server/ssgProxy.ts",
|
|
22
22
|
"size": 3673,
|
|
23
|
-
"origSize":
|
|
23
|
+
"origSize": 7403,
|
|
24
24
|
"renderedExports": [
|
|
25
25
|
"createServerSideHelpers"
|
|
26
26
|
],
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"/src/server/index.ts"
|
|
30
30
|
],
|
|
31
31
|
"percent": 13.48,
|
|
32
|
-
"reduction": 50.
|
|
32
|
+
"reduction": 50.38
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"id": "/src/utils/createUtilityFunctions.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
{
|
|
66
66
|
"id": "/src/internals/getQueryKey.ts",
|
|
67
67
|
"size": 1894,
|
|
68
|
-
"origSize":
|
|
68
|
+
"origSize": 3254,
|
|
69
69
|
"renderedExports": [
|
|
70
70
|
"getQueryKeyInternal",
|
|
71
71
|
"getQueryKey"
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"/src/shared/hooks/createHooksInternal.tsx"
|
|
80
80
|
],
|
|
81
81
|
"percent": 6.95,
|
|
82
|
-
"reduction":
|
|
82
|
+
"reduction": 41.79
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"id": "/src/createTRPCReact.tsx",
|
|
86
86
|
"size": 850,
|
|
87
|
-
"origSize":
|
|
87
|
+
"origSize": 7749,
|
|
88
88
|
"renderedExports": [
|
|
89
89
|
"createHooksInternal",
|
|
90
90
|
"createTRPCReact"
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"/src/index.ts"
|
|
95
95
|
],
|
|
96
96
|
"percent": 3.12,
|
|
97
|
-
"reduction":
|
|
97
|
+
"reduction": 89.03
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"id": "/src/shared/proxy/decorationProxy.ts",
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyProcedure, AnyRootTypes, AnyRouter, inferProcedureInput, inferTransformedProcedureOutput, ProcedureType, ProtectedIntersection, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type { TRPCUseQueries, TRPCUseSuspenseQueries } from './internals/useQueries';
|
|
4
4
|
import type { CreateReactUtils } from './shared';
|
|
5
5
|
import type { CreateReactQueryHooks } from './shared/hooks/createHooksInternal';
|
|
6
6
|
import type { CreateClient, DefinedUseTRPCQueryOptions, DefinedUseTRPCQueryResult, TRPCProvider, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCSubscriptionOptions, UseTRPCSuspenseInfiniteQueryOptions, UseTRPCSuspenseInfiniteQueryResult, UseTRPCSuspenseQueryOptions, UseTRPCSuspenseQueryResult } from './shared/hooks/types';
|
|
7
7
|
import type { CreateTRPCReactOptions } from './shared/types';
|
|
8
|
+
type ResolverDef = {
|
|
9
|
+
input: any;
|
|
10
|
+
output: any;
|
|
11
|
+
transformer: boolean;
|
|
12
|
+
errorShape: any;
|
|
13
|
+
};
|
|
8
14
|
/**
|
|
9
15
|
* @internal
|
|
10
16
|
*/
|
|
11
|
-
export interface ProcedureUseQuery<
|
|
12
|
-
<TQueryFnData extends
|
|
13
|
-
|
|
17
|
+
export interface ProcedureUseQuery<TDef extends ResolverDef> {
|
|
18
|
+
<TQueryFnData extends TDef['output'] = TDef['output'], TData = TQueryFnData>(input: TDef['input'], opts: DefinedUseTRPCQueryOptions<TQueryFnData, TData, TRPCClientErrorLike<{
|
|
19
|
+
errorShape: TDef['errorShape'];
|
|
20
|
+
transformer: TDef['transformer'];
|
|
21
|
+
}>, TDef['output']>): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<{
|
|
22
|
+
errorShape: TDef['errorShape'];
|
|
23
|
+
transformer: TDef['transformer'];
|
|
24
|
+
}>>;
|
|
25
|
+
<TQueryFnData extends TDef['output'] = TDef['output'], TData = TQueryFnData>(input: TDef['input'], opts?: UseTRPCQueryOptions<TQueryFnData, TData, TRPCClientErrorLike<TDef>, TDef['output']>): UseTRPCQueryResult<TData, TRPCClientErrorLike<TDef>>;
|
|
14
26
|
}
|
|
15
27
|
/**
|
|
16
28
|
* @remark `void` is here due to https://github.com/trpc/trpc/pull/4374
|
|
@@ -21,56 +33,58 @@ type CursorInput = {
|
|
|
21
33
|
/**
|
|
22
34
|
* @internal
|
|
23
35
|
*/
|
|
24
|
-
export type MaybeDecoratedInfiniteQuery<
|
|
36
|
+
export type MaybeDecoratedInfiniteQuery<TDef extends ResolverDef> = TDef['input'] extends CursorInput ? {
|
|
25
37
|
/**
|
|
26
38
|
* @link https://trpc.io/docs/v11/client/react/suspense#useinfinitesuspensequery
|
|
27
39
|
*/
|
|
28
|
-
useInfiniteQuery: (input: Omit<
|
|
40
|
+
useInfiniteQuery: (input: Omit<TDef['input'], 'cursor'>, opts: UseTRPCInfiniteQueryOptions<TDef['input'], TDef['output'], TRPCClientErrorLike<TDef>>) => UseTRPCInfiniteQueryResult<TDef['output'], TRPCClientErrorLike<TDef>, TDef['input']>;
|
|
29
41
|
/**
|
|
30
42
|
* @link https://trpc.io/docs/v11/client/react/suspense
|
|
31
43
|
*/
|
|
32
|
-
useSuspenseInfiniteQuery: (input: Omit<
|
|
44
|
+
useSuspenseInfiniteQuery: (input: Omit<TDef['input'], 'cursor'>, opts: UseTRPCSuspenseInfiniteQueryOptions<TDef['input'], TDef['output'], TRPCClientErrorLike<TDef>>) => UseTRPCSuspenseInfiniteQueryResult<TDef['output'], TRPCClientErrorLike<TDef>, TDef['input']>;
|
|
33
45
|
} : object;
|
|
34
46
|
/**
|
|
35
47
|
* @internal
|
|
36
48
|
*/
|
|
37
|
-
export type DecoratedQueryMethods<
|
|
49
|
+
export type DecoratedQueryMethods<TDef extends ResolverDef> = {
|
|
38
50
|
/**
|
|
39
51
|
* @link https://trpc.io/docs/v11/client/react/useQuery
|
|
40
52
|
*/
|
|
41
|
-
useQuery: ProcedureUseQuery<
|
|
53
|
+
useQuery: ProcedureUseQuery<TDef>;
|
|
42
54
|
/**
|
|
43
55
|
* @link https://trpc.io/docs/v11/client/react/suspense#usesuspensequery
|
|
44
56
|
*/
|
|
45
|
-
useSuspenseQuery: <TQueryFnData extends
|
|
57
|
+
useSuspenseQuery: <TQueryFnData extends TDef['output'] = TDef['output'], TData = TQueryFnData>(input: TDef['input'], opts?: UseTRPCSuspenseQueryOptions<TQueryFnData, TData, TRPCClientErrorLike<TDef>>) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<TDef>>;
|
|
46
58
|
};
|
|
47
59
|
/**
|
|
48
60
|
* @internal
|
|
49
61
|
*/
|
|
50
|
-
export type DecoratedQuery<
|
|
51
|
-
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
export interface DecoratedMutation<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> {
|
|
62
|
+
export type DecoratedQuery<TDef extends ResolverDef> = MaybeDecoratedInfiniteQuery<TDef> & DecoratedQueryMethods<TDef>;
|
|
63
|
+
export type DecoratedMutation<TDef extends ResolverDef> = {
|
|
55
64
|
/**
|
|
56
65
|
* @link https://trpc.io/docs/v11/client/react/useMutation
|
|
57
66
|
*/
|
|
58
|
-
useMutation: <TContext = unknown>(opts?: UseTRPCMutationOptions<
|
|
59
|
-
}
|
|
67
|
+
useMutation: <TContext = unknown>(opts?: UseTRPCMutationOptions<TDef['input'], TRPCClientErrorLike<TDef>, TDef['output'], TContext>) => UseTRPCMutationResult<TDef['output'], TRPCClientErrorLike<TDef>, TDef['input'], TContext>;
|
|
68
|
+
};
|
|
60
69
|
/**
|
|
61
70
|
* @internal
|
|
62
71
|
*/
|
|
63
|
-
export type DecorateProcedure<
|
|
72
|
+
export type DecorateProcedure<TType extends ProcedureType, TDef extends ResolverDef> = TType extends 'query' ? DecoratedQuery<TDef> : TType extends 'mutation' ? DecoratedMutation<TDef> : TType extends 'subscription' ? {
|
|
64
73
|
/**
|
|
65
74
|
* @link https://trpc.io/docs/v11/subscriptions
|
|
66
75
|
*/
|
|
67
|
-
useSubscription: (input:
|
|
76
|
+
useSubscription: (input: TDef['input'], opts?: UseTRPCSubscriptionOptions<TDef['output'], TRPCClientErrorLike<TDef>>) => void;
|
|
68
77
|
} : never;
|
|
69
78
|
/**
|
|
70
79
|
* @internal
|
|
71
80
|
*/
|
|
72
|
-
export type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord
|
|
73
|
-
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value
|
|
81
|
+
export type DecorateRouterRecord<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = {
|
|
82
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends RouterRecord ? DecorateRouterRecord<TRoot, $Value> : $Value extends AnyProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
|
83
|
+
input: inferProcedureInput<$Value>;
|
|
84
|
+
output: inferTransformedProcedureOutput<TRoot, $Value>;
|
|
85
|
+
transformer: TRoot['transformer'];
|
|
86
|
+
errorShape: TRoot['errorShape'];
|
|
87
|
+
}> : never : never;
|
|
74
88
|
};
|
|
75
89
|
/**
|
|
76
90
|
* @internal
|
|
@@ -91,11 +105,11 @@ export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
|
|
|
91
105
|
useQueries: TRPCUseQueries<TRouter>;
|
|
92
106
|
useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;
|
|
93
107
|
};
|
|
94
|
-
export type CreateTRPCReact<TRouter extends AnyRouter, TSSRContext
|
|
108
|
+
export type CreateTRPCReact<TRouter extends AnyRouter, TSSRContext> = ProtectedIntersection<CreateTRPCReactBase<TRouter, TSSRContext>, DecorateRouterRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']>>;
|
|
95
109
|
/**
|
|
96
110
|
* @internal
|
|
97
111
|
*/
|
|
98
|
-
export declare function createHooksInternal<TRouter extends AnyRouter, TSSRContext = unknown
|
|
99
|
-
export declare function createTRPCReact<TRouter extends AnyRouter, TSSRContext = unknown
|
|
112
|
+
export declare function createHooksInternal<TRouter extends AnyRouter, TSSRContext = unknown>(trpc: CreateReactQueryHooks<TRouter, TSSRContext>): ProtectedIntersection<CreateTRPCReactBase<TRouter, TSSRContext>, DecorateRouterRecord<TRouter["_def"]["_config"]["$types"], TRouter["_def"]["record"]>>;
|
|
113
|
+
export declare function createTRPCReact<TRouter extends AnyRouter, TSSRContext = unknown>(opts?: CreateTRPCReactOptions<TRouter>): CreateTRPCReact<TRouter, TSSRContext>;
|
|
100
114
|
export {};
|
|
101
115
|
//# sourceMappingURL=createTRPCReact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTRPCReact.d.ts","sourceRoot":"","sources":["../src/createTRPCReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"createTRPCReact.d.ts","sourceRoot":"","sources":["../src/createTRPCReact.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,+BAA+B,EAC/B,aAAa,EACb,qBAAqB,EACrB,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEhF,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC1B,mCAAmC,EACnC,kCAAkC,EAClC,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,GAAG,C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WAAW,GAAG,OAAO,EAErB,IAAI,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACrC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAKvC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { DeepPartial } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { DecoratedMutation, DecoratedQuery } from '../createTRPCReact';
|
|
3
|
+
import type { DecorateRouterRecord } from '../shared';
|
|
3
4
|
export type QueryType = 'any' | 'infinite' | 'query';
|
|
4
5
|
export type TRPCQueryKey = [
|
|
5
6
|
string[],
|
|
@@ -8,6 +9,7 @@ export type TRPCQueryKey = [
|
|
|
8
9
|
type?: Exclude<QueryType, 'any'>;
|
|
9
10
|
}?
|
|
10
11
|
];
|
|
12
|
+
type ProcedureOrRouter = DecoratedMutation<any> | DecoratedQuery<any> | DecorateRouterRecord<any, any>;
|
|
11
13
|
/**
|
|
12
14
|
* To allow easy interactions with groups of related queries, such as
|
|
13
15
|
* invalidating all queries of a router, we use an array as the path when
|
|
@@ -19,14 +21,7 @@ type GetInfiniteQueryInput<TProcedureInput, TInputWithoutCursor = Omit<TProcedur
|
|
|
19
21
|
export type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {
|
|
20
22
|
cursor?: any;
|
|
21
23
|
} ? GetInfiniteQueryInput<TProcedureInput> : DeepPartial<TProcedureInput> | undefined;
|
|
22
|
-
type
|
|
23
|
-
type GetParams<TRoot extends AnyRootTypes, TProcedureOrRouter extends AnyMutationProcedure | AnyQueryProcedure | AnyRouter, TFlags> = TProcedureOrRouter extends AnyQueryProcedure ? [
|
|
24
|
-
procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>,
|
|
25
|
-
..._params: GetQueryParams<TProcedureOrRouter>
|
|
26
|
-
] : TProcedureOrRouter extends AnyMutationProcedure ? [procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>] : TProcedureOrRouter extends AnyRouter ? [
|
|
27
|
-
procedureOrRouter: DecorateRouterRecord<TRoot, TProcedureOrRouter['_def']['record'], TFlags>
|
|
28
|
-
] : never;
|
|
29
|
-
type GetQueryKeyParams<TRoot extends AnyRootTypes, TProcedureOrRouter extends AnyMutationProcedure | AnyQueryProcedure | AnyRouter, TFlags> = GetParams<TRoot, TProcedureOrRouter, TFlags>;
|
|
24
|
+
type GetParams<TProcedureOrRouter extends ProcedureOrRouter> = TProcedureOrRouter extends DecoratedQuery<infer $Def> ? [input?: GetQueryProcedureInput<$Def['input']>, type?: QueryType] : [];
|
|
30
25
|
/**
|
|
31
26
|
* Method to extract the query key for a procedure
|
|
32
27
|
* @param procedureOrRouter - procedure or AnyRouter
|
|
@@ -34,7 +29,7 @@ type GetQueryKeyParams<TRoot extends AnyRootTypes, TProcedureOrRouter extends An
|
|
|
34
29
|
* @param type - defaults to `any`
|
|
35
30
|
* @link https://trpc.io/docs/v11/getQueryKey
|
|
36
31
|
*/
|
|
37
|
-
export declare function getQueryKey<
|
|
32
|
+
export declare function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(procedureOrRouter: TProcedureOrRouter, ..._params: GetParams<TProcedureOrRouter>): TRPCQueryKey;
|
|
38
33
|
export type QueryKeyKnown<TInput, TType extends Exclude<QueryType, 'any'>> = [
|
|
39
34
|
string[],
|
|
40
35
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQueryKey.d.ts","sourceRoot":"","sources":["../../src/internals/getQueryKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getQueryKey.d.ts","sourceRoot":"","sources":["../../src/internals/getQueryKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAA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AE,kBAAkB,EACrC,GAAG,OAAO,EAAE,SAAS,CAAC,kBAAkB,CAAC,gBAQ1C;AAGD,MAAM,MAAM,aAAa,CAAC,MAAM,EAAE,KAAK,SAAS,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI;IAC3E,MAAM,EAAE;IACR;QAAE,KAAK,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC;CACzD,CAAC"}
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
* @param input - input to procedureOrRouter
|
|
46
46
|
* @param type - defaults to `any`
|
|
47
47
|
* @link https://trpc.io/docs/v11/getQueryKey
|
|
48
|
-
*/ function getQueryKey(..._params) {
|
|
49
|
-
const [
|
|
48
|
+
*/ function getQueryKey(procedureOrRouter, ..._params) {
|
|
49
|
+
const [input, type] = _params;
|
|
50
50
|
// @ts-expect-error - we don't expose _def on the type layer
|
|
51
51
|
const path = procedureOrRouter._def().path;
|
|
52
52
|
const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
* @param input - input to procedureOrRouter
|
|
44
44
|
* @param type - defaults to `any`
|
|
45
45
|
* @link https://trpc.io/docs/v11/getQueryKey
|
|
46
|
-
*/ function getQueryKey(..._params) {
|
|
47
|
-
const [
|
|
46
|
+
*/ function getQueryKey(procedureOrRouter, ..._params) {
|
|
47
|
+
const [input, type] = _params;
|
|
48
48
|
// @ts-expect-error - we don't expose _def on the type layer
|
|
49
49
|
const path = procedureOrRouter._def().path;
|
|
50
50
|
const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
|
|
@@ -2,12 +2,12 @@ import type { DehydratedState, DehydrateOptions, InfiniteData, QueryClient } fro
|
|
|
2
2
|
import type { inferRouterClient, TRPCClientError } from '@trpc/client';
|
|
3
3
|
import { TRPCUntypedClient } from '@trpc/client';
|
|
4
4
|
import { type TransformerOptions } from '@trpc/client/unstable-internals';
|
|
5
|
-
import type { AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter,
|
|
5
|
+
import type { AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, inferClientTypes, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput, ProtectedIntersection, RouterRecord } from '@trpc/server/unstable-core-do-not-import';
|
|
6
6
|
import type { CreateTRPCReactQueryClientConfig, ExtractCursorType, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions } from '../shared';
|
|
7
7
|
type CreateSSGHelpersInternal<TRouter extends AnyRouter> = {
|
|
8
8
|
router: TRouter;
|
|
9
9
|
ctx: inferRouterContext<TRouter>;
|
|
10
|
-
} & TransformerOptions<
|
|
10
|
+
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
11
11
|
interface CreateSSGHelpersExternal<TRouter extends AnyRouter> {
|
|
12
12
|
client: inferRouterClient<TRouter> | TRPCUntypedClient<TRouter>;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssgProxy.d.ts","sourceRoot":"","sources":["../../src/server/ssgProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"ssgProxy.d.ts","sourceRoot":"","sources":["../../src/server/ssgProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACZ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K,GACP,KAAK;CACV,CAAC;AAIF;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAC/D,IAAI,EAAE,8BAA8B,CAAC,OAAO,CAAC;iBAqD5B,WAAW;uBACL,gBAAgB,KAAK,eAAe;iGA+D5D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
2
|
import type { AnyProcedure, AnyRootTypes, inferProcedureInput, inferProcedureOutput, inferTransformedProcedureOutput } from '@trpc/server/unstable-core-do-not-import';
|
|
3
|
+
import type { DecoratedQuery } from '../../createTRPCReact';
|
|
3
4
|
import type { InferQueryOptions, InferQueryResult } from '../../utils/inferReactQueryProcedure';
|
|
4
5
|
import type { UseTRPCSuspenseQueryResult } from '../hooks/types';
|
|
5
6
|
/**
|
|
@@ -12,9 +13,9 @@ export type QueryLike<TRoot extends AnyRootTypes, TProcedure extends AnyProcedur
|
|
|
12
13
|
/**
|
|
13
14
|
* Use to unwrap a QueryLike's input
|
|
14
15
|
*/
|
|
15
|
-
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;
|
|
16
17
|
/**
|
|
17
18
|
* Use to unwrap a QueryLike's data output
|
|
18
19
|
*/
|
|
19
|
-
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;
|
|
20
21
|
//# sourceMappingURL=queryLike.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/queryLike.ts"],"names":[],"mappings":"A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.0-next-beta.
|
|
3
|
+
"version": "11.0.0-next-beta.272+765a5e71a",
|
|
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.272+765a5e71a",
|
|
62
|
+
"@trpc/server": "11.0.0-next-beta.272+765a5e71a",
|
|
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.272+765a5e71a",
|
|
69
|
+
"@trpc/server": "11.0.0-next-beta.272+765a5e71a",
|
|
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": "765a5e71a5b84d54d6275ec93e4314d43feb10cf"
|
|
89
89
|
}
|
package/src/createTRPCReact.tsx
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
2
|
import type {
|
|
3
|
-
AnyMutationProcedure,
|
|
4
3
|
AnyProcedure,
|
|
5
|
-
AnyQueryProcedure,
|
|
6
4
|
AnyRootTypes,
|
|
7
5
|
AnyRouter,
|
|
8
|
-
AnySubscriptionProcedure,
|
|
9
6
|
inferProcedureInput,
|
|
10
7
|
inferTransformedProcedureOutput,
|
|
11
|
-
|
|
8
|
+
ProcedureType,
|
|
12
9
|
ProtectedIntersection,
|
|
13
10
|
RouterRecord,
|
|
14
11
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
@@ -41,44 +38,44 @@ import type {
|
|
|
41
38
|
} from './shared/hooks/types';
|
|
42
39
|
import type { CreateTRPCReactOptions } from './shared/types';
|
|
43
40
|
|
|
41
|
+
type ResolverDef = {
|
|
42
|
+
input: any;
|
|
43
|
+
output: any;
|
|
44
|
+
transformer: boolean;
|
|
45
|
+
errorShape: any;
|
|
46
|
+
};
|
|
44
47
|
/**
|
|
45
48
|
* @internal
|
|
46
49
|
*/
|
|
47
|
-
export interface ProcedureUseQuery<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
> {
|
|
51
|
-
<
|
|
52
|
-
TQueryFnData extends inferTransformedProcedureOutput<
|
|
53
|
-
TRoot,
|
|
54
|
-
TProcedure
|
|
55
|
-
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
56
|
-
TData = TQueryFnData,
|
|
57
|
-
>(
|
|
58
|
-
input: inferProcedureInput<TProcedure>,
|
|
50
|
+
export interface ProcedureUseQuery<TDef extends ResolverDef> {
|
|
51
|
+
<TQueryFnData extends TDef['output'] = TDef['output'], TData = TQueryFnData>(
|
|
52
|
+
input: TDef['input'],
|
|
59
53
|
opts: DefinedUseTRPCQueryOptions<
|
|
60
54
|
TQueryFnData,
|
|
61
55
|
TData,
|
|
62
|
-
TRPCClientErrorLike<
|
|
63
|
-
|
|
56
|
+
TRPCClientErrorLike<{
|
|
57
|
+
errorShape: TDef['errorShape'];
|
|
58
|
+
transformer: TDef['transformer'];
|
|
59
|
+
}>,
|
|
60
|
+
TDef['output']
|
|
64
61
|
>,
|
|
65
|
-
): DefinedUseTRPCQueryResult<
|
|
62
|
+
): DefinedUseTRPCQueryResult<
|
|
63
|
+
TData,
|
|
64
|
+
TRPCClientErrorLike<{
|
|
65
|
+
errorShape: TDef['errorShape'];
|
|
66
|
+
transformer: TDef['transformer'];
|
|
67
|
+
}>
|
|
68
|
+
>;
|
|
66
69
|
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
TRoot,
|
|
70
|
-
TProcedure
|
|
71
|
-
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
72
|
-
TData = TQueryFnData,
|
|
73
|
-
>(
|
|
74
|
-
input: inferProcedureInput<TProcedure>,
|
|
70
|
+
<TQueryFnData extends TDef['output'] = TDef['output'], TData = TQueryFnData>(
|
|
71
|
+
input: TDef['input'],
|
|
75
72
|
opts?: UseTRPCQueryOptions<
|
|
76
73
|
TQueryFnData,
|
|
77
74
|
TData,
|
|
78
|
-
TRPCClientErrorLike<
|
|
79
|
-
|
|
75
|
+
TRPCClientErrorLike<TDef>,
|
|
76
|
+
TDef['output']
|
|
80
77
|
>,
|
|
81
|
-
): UseTRPCQueryResult<TData, TRPCClientErrorLike<
|
|
78
|
+
): UseTRPCQueryResult<TData, TRPCClientErrorLike<TDef>>;
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
/**
|
|
@@ -91,129 +88,110 @@ type CursorInput = {
|
|
|
91
88
|
/**
|
|
92
89
|
* @internal
|
|
93
90
|
*/
|
|
94
|
-
export type MaybeDecoratedInfiniteQuery<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
: object;
|
|
91
|
+
export type MaybeDecoratedInfiniteQuery<TDef extends ResolverDef> =
|
|
92
|
+
TDef['input'] extends CursorInput
|
|
93
|
+
? {
|
|
94
|
+
/**
|
|
95
|
+
* @link https://trpc.io/docs/v11/client/react/suspense#useinfinitesuspensequery
|
|
96
|
+
*/
|
|
97
|
+
useInfiniteQuery: (
|
|
98
|
+
input: Omit<TDef['input'], 'cursor'>,
|
|
99
|
+
opts: UseTRPCInfiniteQueryOptions<
|
|
100
|
+
TDef['input'],
|
|
101
|
+
TDef['output'],
|
|
102
|
+
TRPCClientErrorLike<TDef>
|
|
103
|
+
>,
|
|
104
|
+
) => UseTRPCInfiniteQueryResult<
|
|
105
|
+
TDef['output'],
|
|
106
|
+
TRPCClientErrorLike<TDef>,
|
|
107
|
+
TDef['input']
|
|
108
|
+
>;
|
|
109
|
+
/**
|
|
110
|
+
* @link https://trpc.io/docs/v11/client/react/suspense
|
|
111
|
+
*/
|
|
112
|
+
useSuspenseInfiniteQuery: (
|
|
113
|
+
input: Omit<TDef['input'], 'cursor'>,
|
|
114
|
+
opts: UseTRPCSuspenseInfiniteQueryOptions<
|
|
115
|
+
TDef['input'],
|
|
116
|
+
TDef['output'],
|
|
117
|
+
TRPCClientErrorLike<TDef>
|
|
118
|
+
>,
|
|
119
|
+
) => UseTRPCSuspenseInfiniteQueryResult<
|
|
120
|
+
TDef['output'],
|
|
121
|
+
TRPCClientErrorLike<TDef>,
|
|
122
|
+
TDef['input']
|
|
123
|
+
>;
|
|
124
|
+
}
|
|
125
|
+
: object;
|
|
131
126
|
|
|
132
127
|
/**
|
|
133
128
|
* @internal
|
|
134
129
|
*/
|
|
135
|
-
export type DecoratedQueryMethods<
|
|
136
|
-
TRoot extends AnyRootTypes,
|
|
137
|
-
TProcedure extends AnyProcedure,
|
|
138
|
-
> = {
|
|
130
|
+
export type DecoratedQueryMethods<TDef extends ResolverDef> = {
|
|
139
131
|
/**
|
|
140
132
|
* @link https://trpc.io/docs/v11/client/react/useQuery
|
|
141
133
|
*/
|
|
142
|
-
useQuery: ProcedureUseQuery<
|
|
134
|
+
useQuery: ProcedureUseQuery<TDef>;
|
|
143
135
|
/**
|
|
144
136
|
* @link https://trpc.io/docs/v11/client/react/suspense#usesuspensequery
|
|
145
137
|
*/
|
|
146
138
|
useSuspenseQuery: <
|
|
147
|
-
TQueryFnData extends
|
|
148
|
-
TRoot,
|
|
149
|
-
TProcedure
|
|
150
|
-
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
139
|
+
TQueryFnData extends TDef['output'] = TDef['output'],
|
|
151
140
|
TData = TQueryFnData,
|
|
152
141
|
>(
|
|
153
|
-
input:
|
|
142
|
+
input: TDef['input'],
|
|
154
143
|
opts?: UseTRPCSuspenseQueryOptions<
|
|
155
144
|
TQueryFnData,
|
|
156
145
|
TData,
|
|
157
|
-
TRPCClientErrorLike<
|
|
146
|
+
TRPCClientErrorLike<TDef>
|
|
158
147
|
>,
|
|
159
|
-
) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<
|
|
148
|
+
) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<TDef>>;
|
|
160
149
|
};
|
|
161
150
|
|
|
162
151
|
/**
|
|
163
152
|
* @internal
|
|
164
153
|
*/
|
|
165
|
-
export type DecoratedQuery<
|
|
166
|
-
|
|
167
|
-
TProcedure extends AnyProcedure,
|
|
168
|
-
> = MaybeDecoratedInfiniteQuery<TProcedure, TRoot> &
|
|
169
|
-
DecoratedQueryMethods<TRoot, TProcedure>;
|
|
154
|
+
export type DecoratedQuery<TDef extends ResolverDef> =
|
|
155
|
+
MaybeDecoratedInfiniteQuery<TDef> & DecoratedQueryMethods<TDef>;
|
|
170
156
|
|
|
171
|
-
|
|
172
|
-
* @internal
|
|
173
|
-
*/
|
|
174
|
-
export interface DecoratedMutation<
|
|
175
|
-
TRoot extends AnyRootTypes,
|
|
176
|
-
TProcedure extends AnyProcedure,
|
|
177
|
-
> {
|
|
157
|
+
export type DecoratedMutation<TDef extends ResolverDef> = {
|
|
178
158
|
/**
|
|
179
159
|
* @link https://trpc.io/docs/v11/client/react/useMutation
|
|
180
160
|
*/
|
|
181
161
|
useMutation: <TContext = unknown>(
|
|
182
162
|
opts?: UseTRPCMutationOptions<
|
|
183
|
-
|
|
184
|
-
TRPCClientErrorLike<
|
|
185
|
-
|
|
163
|
+
TDef['input'],
|
|
164
|
+
TRPCClientErrorLike<TDef>,
|
|
165
|
+
TDef['output'],
|
|
186
166
|
TContext
|
|
187
167
|
>,
|
|
188
168
|
) => UseTRPCMutationResult<
|
|
189
|
-
|
|
190
|
-
TRPCClientErrorLike<
|
|
191
|
-
|
|
169
|
+
TDef['output'],
|
|
170
|
+
TRPCClientErrorLike<TDef>,
|
|
171
|
+
TDef['input'],
|
|
192
172
|
TContext
|
|
193
173
|
>;
|
|
194
|
-
}
|
|
195
|
-
|
|
174
|
+
};
|
|
196
175
|
/**
|
|
197
176
|
* @internal
|
|
198
177
|
*/
|
|
199
178
|
export type DecorateProcedure<
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
: TProcedure extends AnySubscriptionProcedure
|
|
179
|
+
TType extends ProcedureType,
|
|
180
|
+
TDef extends ResolverDef,
|
|
181
|
+
> = TType extends 'query'
|
|
182
|
+
? DecoratedQuery<TDef>
|
|
183
|
+
: TType extends 'mutation'
|
|
184
|
+
? DecoratedMutation<TDef>
|
|
185
|
+
: TType extends 'subscription'
|
|
208
186
|
? {
|
|
209
187
|
/**
|
|
210
188
|
* @link https://trpc.io/docs/v11/subscriptions
|
|
211
189
|
*/
|
|
212
190
|
useSubscription: (
|
|
213
|
-
input:
|
|
191
|
+
input: TDef['input'],
|
|
214
192
|
opts?: UseTRPCSubscriptionOptions<
|
|
215
|
-
|
|
216
|
-
TRPCClientErrorLike<
|
|
193
|
+
TDef['output'],
|
|
194
|
+
TRPCClientErrorLike<TDef>
|
|
217
195
|
>,
|
|
218
196
|
) => void;
|
|
219
197
|
}
|
|
@@ -225,13 +203,20 @@ export type DecorateProcedure<
|
|
|
225
203
|
export type DecorateRouterRecord<
|
|
226
204
|
TRoot extends AnyRootTypes,
|
|
227
205
|
TRecord extends RouterRecord,
|
|
228
|
-
TFlags,
|
|
229
206
|
> = {
|
|
230
207
|
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
231
208
|
? $Value extends RouterRecord
|
|
232
|
-
? DecorateRouterRecord<TRoot, $Value
|
|
209
|
+
? DecorateRouterRecord<TRoot, $Value>
|
|
233
210
|
: $Value extends AnyProcedure
|
|
234
|
-
? DecorateProcedure<
|
|
211
|
+
? DecorateProcedure<
|
|
212
|
+
$Value['_def']['type'],
|
|
213
|
+
{
|
|
214
|
+
input: inferProcedureInput<$Value>;
|
|
215
|
+
output: inferTransformedProcedureOutput<TRoot, $Value>;
|
|
216
|
+
transformer: TRoot['transformer'];
|
|
217
|
+
errorShape: TRoot['errorShape'];
|
|
218
|
+
}
|
|
219
|
+
>
|
|
235
220
|
: never
|
|
236
221
|
: never;
|
|
237
222
|
};
|
|
@@ -259,13 +244,11 @@ export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
|
|
|
259
244
|
export type CreateTRPCReact<
|
|
260
245
|
TRouter extends AnyRouter,
|
|
261
246
|
TSSRContext,
|
|
262
|
-
TFlags,
|
|
263
247
|
> = ProtectedIntersection<
|
|
264
248
|
CreateTRPCReactBase<TRouter, TSSRContext>,
|
|
265
249
|
DecorateRouterRecord<
|
|
266
250
|
TRouter['_def']['_config']['$types'],
|
|
267
|
-
TRouter['_def']['record']
|
|
268
|
-
TFlags
|
|
251
|
+
TRouter['_def']['record']
|
|
269
252
|
>
|
|
270
253
|
>;
|
|
271
254
|
|
|
@@ -275,9 +258,8 @@ export type CreateTRPCReact<
|
|
|
275
258
|
export function createHooksInternal<
|
|
276
259
|
TRouter extends AnyRouter,
|
|
277
260
|
TSSRContext = unknown,
|
|
278
|
-
TFlags = null,
|
|
279
261
|
>(trpc: CreateReactQueryHooks<TRouter, TSSRContext>) {
|
|
280
|
-
type CreateHooksInternal = CreateTRPCReact<TRouter, TSSRContext
|
|
262
|
+
type CreateHooksInternal = CreateTRPCReact<TRouter, TSSRContext>;
|
|
281
263
|
|
|
282
264
|
return createFlatProxy<CreateHooksInternal>((key) => {
|
|
283
265
|
if (key === 'useContext' || key === 'useUtils') {
|
|
@@ -301,12 +283,11 @@ export function createHooksInternal<
|
|
|
301
283
|
export function createTRPCReact<
|
|
302
284
|
TRouter extends AnyRouter,
|
|
303
285
|
TSSRContext = unknown,
|
|
304
|
-
TFlags = null,
|
|
305
286
|
>(
|
|
306
287
|
opts?: CreateTRPCReactOptions<TRouter>,
|
|
307
|
-
): CreateTRPCReact<TRouter, TSSRContext
|
|
288
|
+
): CreateTRPCReact<TRouter, TSSRContext> {
|
|
308
289
|
const hooks = createRootHooks<TRouter, TSSRContext>(opts);
|
|
309
|
-
const proxy = createHooksInternal<TRouter, TSSRContext
|
|
290
|
+
const proxy = createHooksInternal<TRouter, TSSRContext>(hooks);
|
|
310
291
|
|
|
311
292
|
return proxy as any;
|
|
312
293
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
AnyRootTypes,
|
|
5
|
-
AnyRouter,
|
|
6
|
-
DeepPartial,
|
|
7
|
-
inferProcedureInput,
|
|
8
|
-
} from '@trpc/server/unstable-core-do-not-import';
|
|
9
|
-
import type { DecorateProcedure, DecorateRouterRecord } from '../shared';
|
|
1
|
+
import type { DeepPartial } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
+
import type { DecoratedMutation, DecoratedQuery } from '../createTRPCReact';
|
|
3
|
+
import type { DecorateRouterRecord } from '../shared';
|
|
10
4
|
|
|
11
5
|
export type QueryType = 'any' | 'infinite' | 'query';
|
|
12
6
|
|
|
@@ -15,6 +9,11 @@ export type TRPCQueryKey = [
|
|
|
15
9
|
{ input?: unknown; type?: Exclude<QueryType, 'any'> }?,
|
|
16
10
|
];
|
|
17
11
|
|
|
12
|
+
type ProcedureOrRouter =
|
|
13
|
+
| DecoratedMutation<any>
|
|
14
|
+
| DecoratedQuery<any>
|
|
15
|
+
| DecorateRouterRecord<any, any>;
|
|
16
|
+
|
|
18
17
|
/**
|
|
19
18
|
* To allow easy interactions with groups of related queries, such as
|
|
20
19
|
* invalidating all queries of a router, we use an array as the path when
|
|
@@ -77,45 +76,10 @@ export type GetQueryProcedureInput<TProcedureInput> = TProcedureInput extends {
|
|
|
77
76
|
? GetInfiniteQueryInput<TProcedureInput>
|
|
78
77
|
: DeepPartial<TProcedureInput> | undefined;
|
|
79
78
|
|
|
80
|
-
type
|
|
81
|
-
TProcedureOrRouter extends
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
? []
|
|
85
|
-
: [input?: GetQueryProcedureInput<TProcedureInput>, type?: QueryType];
|
|
86
|
-
|
|
87
|
-
type GetParams<
|
|
88
|
-
TRoot extends AnyRootTypes,
|
|
89
|
-
TProcedureOrRouter extends
|
|
90
|
-
| AnyMutationProcedure
|
|
91
|
-
| AnyQueryProcedure
|
|
92
|
-
| AnyRouter,
|
|
93
|
-
TFlags,
|
|
94
|
-
> = TProcedureOrRouter extends AnyQueryProcedure
|
|
95
|
-
? [
|
|
96
|
-
procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>,
|
|
97
|
-
..._params: GetQueryParams<TProcedureOrRouter>,
|
|
98
|
-
]
|
|
99
|
-
: TProcedureOrRouter extends AnyMutationProcedure
|
|
100
|
-
? [procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>]
|
|
101
|
-
: TProcedureOrRouter extends AnyRouter
|
|
102
|
-
? [
|
|
103
|
-
procedureOrRouter: DecorateRouterRecord<
|
|
104
|
-
TRoot,
|
|
105
|
-
TProcedureOrRouter['_def']['record'],
|
|
106
|
-
TFlags
|
|
107
|
-
>,
|
|
108
|
-
]
|
|
109
|
-
: never;
|
|
110
|
-
|
|
111
|
-
type GetQueryKeyParams<
|
|
112
|
-
TRoot extends AnyRootTypes,
|
|
113
|
-
TProcedureOrRouter extends
|
|
114
|
-
| AnyMutationProcedure
|
|
115
|
-
| AnyQueryProcedure
|
|
116
|
-
| AnyRouter,
|
|
117
|
-
TFlags,
|
|
118
|
-
> = GetParams<TRoot, TProcedureOrRouter, TFlags>;
|
|
79
|
+
type GetParams<TProcedureOrRouter extends ProcedureOrRouter> =
|
|
80
|
+
TProcedureOrRouter extends DecoratedQuery<infer $Def>
|
|
81
|
+
? [input?: GetQueryProcedureInput<$Def['input']>, type?: QueryType]
|
|
82
|
+
: [];
|
|
119
83
|
|
|
120
84
|
/**
|
|
121
85
|
* Method to extract the query key for a procedure
|
|
@@ -124,15 +88,12 @@ type GetQueryKeyParams<
|
|
|
124
88
|
* @param type - defaults to `any`
|
|
125
89
|
* @link https://trpc.io/docs/v11/getQueryKey
|
|
126
90
|
*/
|
|
127
|
-
export function getQueryKey<
|
|
128
|
-
|
|
129
|
-
TProcedureOrRouter
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
TFlags,
|
|
134
|
-
>(..._params: GetQueryKeyParams<TRoot, TProcedureOrRouter, TFlags>) {
|
|
135
|
-
const [procedureOrRouter, input, type] = _params;
|
|
91
|
+
export function getQueryKey<TProcedureOrRouter extends ProcedureOrRouter>(
|
|
92
|
+
procedureOrRouter: TProcedureOrRouter,
|
|
93
|
+
..._params: GetParams<TProcedureOrRouter>
|
|
94
|
+
) {
|
|
95
|
+
const [input, type] = _params;
|
|
96
|
+
|
|
136
97
|
// @ts-expect-error - we don't expose _def on the type layer
|
|
137
98
|
const path = procedureOrRouter._def().path as string[];
|
|
138
99
|
const queryKey = getQueryKeyInternal(path, input, type ?? 'any');
|
package/src/server/ssgProxy.ts
CHANGED
|
@@ -17,8 +17,8 @@ import type {
|
|
|
17
17
|
AnyQueryProcedure,
|
|
18
18
|
AnyRootTypes,
|
|
19
19
|
AnyRouter,
|
|
20
|
+
inferClientTypes,
|
|
20
21
|
inferProcedureInput,
|
|
21
|
-
inferRootTypes,
|
|
22
22
|
inferRouterContext,
|
|
23
23
|
inferTransformedProcedureOutput,
|
|
24
24
|
Maybe,
|
|
@@ -42,7 +42,7 @@ import { getQueryClient, getQueryType } from '../shared';
|
|
|
42
42
|
type CreateSSGHelpersInternal<TRouter extends AnyRouter> = {
|
|
43
43
|
router: TRouter;
|
|
44
44
|
ctx: inferRouterContext<TRouter>;
|
|
45
|
-
} & TransformerOptions<
|
|
45
|
+
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
46
46
|
|
|
47
47
|
interface CreateSSGHelpersExternal<TRouter extends AnyRouter> {
|
|
48
48
|
client: inferRouterClient<TRouter> | TRPCUntypedClient<TRouter>;
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
inferProcedureOutput,
|
|
7
7
|
inferTransformedProcedureOutput,
|
|
8
8
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
9
|
+
import type { DecoratedQuery } from '../../createTRPCReact';
|
|
9
10
|
import type {
|
|
10
11
|
InferQueryOptions,
|
|
11
12
|
InferQueryResult,
|
|
@@ -36,15 +37,21 @@ export type QueryLike<
|
|
|
36
37
|
/**
|
|
37
38
|
* Use to unwrap a QueryLike's input
|
|
38
39
|
*/
|
|
39
|
-
export type InferQueryLikeInput<TQueryLike extends
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
export type InferQueryLikeInput<TQueryLike> = TQueryLike extends DecoratedQuery<
|
|
41
|
+
infer $Def
|
|
42
|
+
>
|
|
43
|
+
? $Def['input']
|
|
44
|
+
: TQueryLike extends QueryLike<any, infer TProcedure>
|
|
45
|
+
? inferProcedureInput<TProcedure>
|
|
46
|
+
: never;
|
|
43
47
|
|
|
44
48
|
/**
|
|
45
49
|
* Use to unwrap a QueryLike's data output
|
|
46
50
|
*/
|
|
47
|
-
export type InferQueryLikeData<TQueryLike extends
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
export type InferQueryLikeData<TQueryLike> = TQueryLike extends DecoratedQuery<
|
|
52
|
+
infer $Def
|
|
53
|
+
>
|
|
54
|
+
? $Def['output']
|
|
55
|
+
: TQueryLike extends QueryLike<infer TRoot, infer TProcedure>
|
|
56
|
+
? inferTransformedProcedureOutput<TRoot, TProcedure>
|
|
57
|
+
: never;
|
|
@@ -29,3 +29,15 @@ export type RouterLikeInner<
|
|
|
29
29
|
: never
|
|
30
30
|
: never;
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
// /**
|
|
34
|
+
// * Use to describe a route path which matches a given route's interface
|
|
35
|
+
// */
|
|
36
|
+
// export type RouterLike<TRouter extends AnyRouter> = RouterLikeInner<
|
|
37
|
+
// TRouter['_def']['_config']['$types'],
|
|
38
|
+
// TRouter['_def']['procedures']
|
|
39
|
+
// >;
|
|
40
|
+
// export type RouterLikeInner<
|
|
41
|
+
// TRoot extends AnyRootTypes,
|
|
42
|
+
// TRecord extends RouterRecord,
|
|
43
|
+
// > = DecorateRouterRecord<TRoot, TRecord>;
|