@trpc/tanstack-react-query 11.0.0-rc.808 → 11.0.0-rc.817
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 +35 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internals/Context.d.ts +3 -2
- package/dist/internals/Context.d.ts.map +1 -1
- package/dist/internals/Context.js +14 -3
- package/dist/internals/Context.mjs +14 -3
- package/dist/internals/createOptionsProxy.d.ts +73 -31
- package/dist/internals/createOptionsProxy.d.ts.map +1 -1
- package/dist/internals/createOptionsProxy.js +34 -27
- package/dist/internals/createOptionsProxy.mjs +35 -28
- package/dist/internals/infiniteQueryOptions.d.ts +35 -16
- package/dist/internals/infiniteQueryOptions.d.ts.map +1 -1
- package/dist/internals/infiniteQueryOptions.js +2 -2
- package/dist/internals/infiniteQueryOptions.mjs +3 -3
- package/dist/internals/queryOptions.d.ts +1 -0
- package/dist/internals/queryOptions.d.ts.map +1 -1
- package/dist/internals/queryOptions.js +2 -2
- package/dist/internals/queryOptions.mjs +3 -3
- package/dist/internals/types.d.ts +21 -3
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/internals/utils.d.ts +2 -2
- package/dist/internals/utils.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +1 -1
- package/src/internals/Context.tsx +22 -6
- package/src/internals/createOptionsProxy.ts +194 -78
- package/src/internals/infiniteQueryOptions.ts +43 -34
- package/src/internals/queryOptions.ts +3 -2
- package/src/internals/types.ts +24 -1
- package/src/internals/utils.ts +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 16486,
|
|
3
|
+
"bundleOrigSize": 44524,
|
|
4
|
+
"bundleReduction": 62.97,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/internals/subscriptionOptions.ts",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"/src/index.ts",
|
|
17
17
|
"/src/internals/createOptionsProxy.ts"
|
|
18
18
|
],
|
|
19
|
-
"percent":
|
|
19
|
+
"percent": 28.75,
|
|
20
20
|
"reduction": 41.65
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"id": "/src/internals/createOptionsProxy.ts",
|
|
24
|
-
"size":
|
|
25
|
-
"origSize":
|
|
24
|
+
"size": 3879,
|
|
25
|
+
"origSize": 13605,
|
|
26
26
|
"renderedExports": [
|
|
27
27
|
"createTRPCOptionsProxy"
|
|
28
28
|
],
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"/src/index.ts",
|
|
32
32
|
"/src/internals/Context.tsx"
|
|
33
33
|
],
|
|
34
|
-
"percent":
|
|
35
|
-
"reduction":
|
|
34
|
+
"percent": 23.53,
|
|
35
|
+
"reduction": 71.49
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/internals/utils.ts",
|
|
39
39
|
"size": 3104,
|
|
40
|
-
"origSize":
|
|
40
|
+
"origSize": 3496,
|
|
41
41
|
"renderedExports": [
|
|
42
42
|
"createTRPCOptionsResult",
|
|
43
43
|
"getClientArgs",
|
|
@@ -54,8 +54,22 @@
|
|
|
54
54
|
"/src/internals/mutationOptions.ts",
|
|
55
55
|
"/src/internals/queryOptions.ts"
|
|
56
56
|
],
|
|
57
|
-
"percent":
|
|
58
|
-
"reduction":
|
|
57
|
+
"percent": 18.83,
|
|
58
|
+
"reduction": 11.21
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "/src/internals/Context.tsx",
|
|
62
|
+
"size": 1494,
|
|
63
|
+
"origSize": 2159,
|
|
64
|
+
"renderedExports": [
|
|
65
|
+
"createTRPCContext"
|
|
66
|
+
],
|
|
67
|
+
"removedExports": [],
|
|
68
|
+
"dependents": [
|
|
69
|
+
"/src/index.ts"
|
|
70
|
+
],
|
|
71
|
+
"percent": 9.06,
|
|
72
|
+
"reduction": 30.8
|
|
59
73
|
},
|
|
60
74
|
{
|
|
61
75
|
"id": "/src/internals/mutationOptions.ts",
|
|
@@ -68,13 +82,13 @@
|
|
|
68
82
|
"dependents": [
|
|
69
83
|
"/src/internals/createOptionsProxy.ts"
|
|
70
84
|
],
|
|
71
|
-
"percent":
|
|
85
|
+
"percent": 6.9,
|
|
72
86
|
"reduction": 64.62
|
|
73
87
|
},
|
|
74
88
|
{
|
|
75
89
|
"id": "/src/internals/queryOptions.ts",
|
|
76
|
-
"size":
|
|
77
|
-
"origSize":
|
|
90
|
+
"size": 1097,
|
|
91
|
+
"origSize": 5947,
|
|
78
92
|
"renderedExports": [
|
|
79
93
|
"trpcQueryOptions"
|
|
80
94
|
],
|
|
@@ -82,13 +96,13 @@
|
|
|
82
96
|
"dependents": [
|
|
83
97
|
"/src/internals/createOptionsProxy.ts"
|
|
84
98
|
],
|
|
85
|
-
"percent":
|
|
86
|
-
"reduction": 81.
|
|
99
|
+
"percent": 6.65,
|
|
100
|
+
"reduction": 81.55
|
|
87
101
|
},
|
|
88
102
|
{
|
|
89
103
|
"id": "/src/internals/infiniteQueryOptions.ts",
|
|
90
|
-
"size":
|
|
91
|
-
"origSize":
|
|
104
|
+
"size": 1036,
|
|
105
|
+
"origSize": 7022,
|
|
92
106
|
"renderedExports": [
|
|
93
107
|
"trpcInfiniteQueryOptions"
|
|
94
108
|
],
|
|
@@ -96,27 +110,13 @@
|
|
|
96
110
|
"dependents": [
|
|
97
111
|
"/src/internals/createOptionsProxy.ts"
|
|
98
112
|
],
|
|
99
|
-
"percent": 6.
|
|
100
|
-
"reduction":
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"id": "/src/internals/Context.tsx",
|
|
104
|
-
"size": 1010,
|
|
105
|
-
"origSize": 1693,
|
|
106
|
-
"renderedExports": [
|
|
107
|
-
"createTRPCContext"
|
|
108
|
-
],
|
|
109
|
-
"removedExports": [],
|
|
110
|
-
"dependents": [
|
|
111
|
-
"/src/index.ts"
|
|
112
|
-
],
|
|
113
|
-
"percent": 6.49,
|
|
114
|
-
"reduction": 40.34
|
|
113
|
+
"percent": 6.28,
|
|
114
|
+
"reduction": 85.25
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
117
|
"id": "/src/index.ts",
|
|
118
118
|
"size": 0,
|
|
119
|
-
"origSize":
|
|
119
|
+
"origSize": 960,
|
|
120
120
|
"renderedExports": [],
|
|
121
121
|
"removedExports": [],
|
|
122
122
|
"dependents": [],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createTRPCContext } from './internals/Context';
|
|
2
|
-
export type { TRPCOptionsProxy, inferInput, inferOutput, DecorateMutationProcedure, DecorateProcedure,
|
|
2
|
+
export type { TRPCOptionsProxy, inferInput, inferOutput, DecorateMutationProcedure, DecorateProcedure, DecorateRouterKeyable, DecorateQueryProcedure, DecorateSubscriptionProcedure, } from './internals/createOptionsProxy';
|
|
3
3
|
export type { TRPCQueryOptions } from './internals/queryOptions';
|
|
4
4
|
export type { TRPCInfiniteQueryOptions } from './internals/infiniteQueryOptions';
|
|
5
5
|
export type { TRPCMutationOptions } from './internals/mutationOptions';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,mBAAmB,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TRPCClient } from '@trpc/client';
|
|
3
3
|
import type { AnyTRPCRouter } from '@trpc/server';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import type { TRPCOptionsProxy } from './createOptionsProxy';
|
|
@@ -7,9 +7,10 @@ export interface CreateTRPCContextResult<TRouter extends AnyTRPCRouter> {
|
|
|
7
7
|
TRPCProvider: React.FC<{
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
queryClient: QueryClient;
|
|
10
|
-
trpcClient:
|
|
10
|
+
trpcClient: TRPCClient<TRouter>;
|
|
11
11
|
}>;
|
|
12
12
|
useTRPC: () => TRPCOptionsProxy<TRouter>;
|
|
13
|
+
useTRPCClient: () => TRPCClient<TRouter>;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Create a set of type-safe provider-consumers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/internals/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/internals/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,WAAW,uBAAuB,CAAC,OAAO,SAAS,aAAa;IACpE,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,aAAa,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;CAC1C;AACD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,aAAa,KAC1B,uBAAuB,CAAC,OAAO,CAAC,CAmDpC"}
|
|
@@ -27,6 +27,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
27
27
|
*
|
|
28
28
|
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3a-setup-the-trpc-context-provider
|
|
29
29
|
*/ function createTRPCContext() {
|
|
30
|
+
const TRPCClientContext = /*#__PURE__*/ React__namespace.createContext(null);
|
|
30
31
|
const TRPCContext = /*#__PURE__*/ React__namespace.createContext(null);
|
|
31
32
|
function TRPCProvider(props) {
|
|
32
33
|
const value = React__namespace.useMemo(()=>createOptionsProxy.createTRPCOptionsProxy({
|
|
@@ -36,9 +37,11 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
36
37
|
props.trpcClient,
|
|
37
38
|
props.queryClient
|
|
38
39
|
]);
|
|
39
|
-
return /*#__PURE__*/ React__namespace.createElement(
|
|
40
|
+
return /*#__PURE__*/ React__namespace.createElement(TRPCClientContext.Provider, {
|
|
41
|
+
value: props.trpcClient
|
|
42
|
+
}, /*#__PURE__*/ React__namespace.createElement(TRPCContext.Provider, {
|
|
40
43
|
value: value
|
|
41
|
-
}, props.children);
|
|
44
|
+
}, props.children));
|
|
42
45
|
}
|
|
43
46
|
function useTRPC() {
|
|
44
47
|
const utils = React__namespace.useContext(TRPCContext);
|
|
@@ -47,9 +50,17 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
47
50
|
}
|
|
48
51
|
return utils;
|
|
49
52
|
}
|
|
53
|
+
function useTRPCClient() {
|
|
54
|
+
const client = React__namespace.useContext(TRPCClientContext);
|
|
55
|
+
if (!client) {
|
|
56
|
+
throw new Error('useTRPCClient() can only be used inside of a <TRPCProvider>');
|
|
57
|
+
}
|
|
58
|
+
return client;
|
|
59
|
+
}
|
|
50
60
|
return {
|
|
51
61
|
TRPCProvider,
|
|
52
|
-
useTRPC
|
|
62
|
+
useTRPC,
|
|
63
|
+
useTRPCClient
|
|
53
64
|
};
|
|
54
65
|
}
|
|
55
66
|
|
|
@@ -6,6 +6,7 @@ import { createTRPCOptionsProxy } from './createOptionsProxy.mjs';
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://trpc.io/docs/client/tanstack-react-query/setup#3a-setup-the-trpc-context-provider
|
|
8
8
|
*/ function createTRPCContext() {
|
|
9
|
+
const TRPCClientContext = /*#__PURE__*/ React.createContext(null);
|
|
9
10
|
const TRPCContext = /*#__PURE__*/ React.createContext(null);
|
|
10
11
|
function TRPCProvider(props) {
|
|
11
12
|
const value = React.useMemo(()=>createTRPCOptionsProxy({
|
|
@@ -15,9 +16,11 @@ import { createTRPCOptionsProxy } from './createOptionsProxy.mjs';
|
|
|
15
16
|
props.trpcClient,
|
|
16
17
|
props.queryClient
|
|
17
18
|
]);
|
|
18
|
-
return /*#__PURE__*/ React.createElement(
|
|
19
|
+
return /*#__PURE__*/ React.createElement(TRPCClientContext.Provider, {
|
|
20
|
+
value: props.trpcClient
|
|
21
|
+
}, /*#__PURE__*/ React.createElement(TRPCContext.Provider, {
|
|
19
22
|
value: value
|
|
20
|
-
}, props.children);
|
|
23
|
+
}, props.children));
|
|
21
24
|
}
|
|
22
25
|
function useTRPC() {
|
|
23
26
|
const utils = React.useContext(TRPCContext);
|
|
@@ -26,9 +29,17 @@ import { createTRPCOptionsProxy } from './createOptionsProxy.mjs';
|
|
|
26
29
|
}
|
|
27
30
|
return utils;
|
|
28
31
|
}
|
|
32
|
+
function useTRPCClient() {
|
|
33
|
+
const client = React.useContext(TRPCClientContext);
|
|
34
|
+
if (!client) {
|
|
35
|
+
throw new Error('useTRPCClient() can only be used inside of a <TRPCProvider>');
|
|
36
|
+
}
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
29
39
|
return {
|
|
30
40
|
TRPCProvider,
|
|
31
|
-
useTRPC
|
|
41
|
+
useTRPC,
|
|
42
|
+
useTRPCClient
|
|
32
43
|
};
|
|
33
44
|
}
|
|
34
45
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataTag, QueryClient, QueryFilters } from '@tanstack/react-query';
|
|
2
|
-
import type { TRPCClient } from '@trpc/client';
|
|
2
|
+
import type { TRPCClient, TRPCClientErrorLike } from '@trpc/client';
|
|
3
3
|
import { TRPCUntypedClient } from '@trpc/client';
|
|
4
4
|
import type { AnyTRPCProcedure, AnyTRPCRootTypes, AnyTRPCRouter, inferProcedureInput, inferRouterContext, inferTransformedProcedureOutput, TRPCProcedureType, TRPCRouterRecord } from '@trpc/server';
|
|
5
5
|
import type { MaybePromise } from '@trpc/server/unstable-core-do-not-import';
|
|
@@ -8,26 +8,24 @@ import type { MutationOptionsOverride } from './mutationOptions';
|
|
|
8
8
|
import { type TRPCMutationOptions } from './mutationOptions';
|
|
9
9
|
import { type TRPCQueryOptions } from './queryOptions';
|
|
10
10
|
import { type TRPCSubscriptionOptions } from './subscriptionOptions';
|
|
11
|
-
import type { ResolverDef, TRPCMutationKey, TRPCQueryKey } from './types';
|
|
12
|
-
export interface
|
|
11
|
+
import type { OptionalCursorInput, ResolverDef, TRPCInfiniteData, TRPCMutationKey, TRPCQueryKey, WithRequired } from './types';
|
|
12
|
+
export interface DecorateRouterKeyable {
|
|
13
13
|
/**
|
|
14
|
-
* Calculate the TanStack Query Key for
|
|
14
|
+
* Calculate the TanStack Query Key for any path, could be used to invalidate every procedure beneath this path
|
|
15
15
|
*
|
|
16
16
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
17
17
|
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
pathKey: () => TRPCQueryKey;
|
|
20
20
|
/**
|
|
21
|
-
* Calculate a TanStack Query Filter for
|
|
21
|
+
* Calculate a TanStack Query Filter for any path, could be used to manipulate every procedure beneath this path
|
|
22
22
|
*
|
|
23
23
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
24
24
|
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
pathFilter: (filters?: QueryFilters<unknown, unknown, unknown, TRPCQueryKey>) => WithRequired<QueryFilters<unknown, unknown, unknown, TRPCQueryKey>, 'queryKey'>;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
export type inferOutput<TProcedure extends DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['output'];
|
|
30
|
-
export interface DecorateQueryProcedure<TDef extends ResolverDef> {
|
|
28
|
+
interface TypeHelper<TDef extends ResolverDef> {
|
|
31
29
|
/**
|
|
32
30
|
* @internal prefer using inferInput and inferOutput to access types
|
|
33
31
|
*/
|
|
@@ -36,13 +34,10 @@ export interface DecorateQueryProcedure<TDef extends ResolverDef> {
|
|
|
36
34
|
output: TDef['output'];
|
|
37
35
|
errorShape: TDef['errorShape'];
|
|
38
36
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryOptions
|
|
44
|
-
*/
|
|
45
|
-
queryOptions: TRPCQueryOptions<TDef>;
|
|
37
|
+
}
|
|
38
|
+
export type inferInput<TProcedure extends DecorateInfiniteQueryProcedure<any> | DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['input'];
|
|
39
|
+
export type inferOutput<TProcedure extends DecorateInfiniteQueryProcedure<any> | DecorateQueryProcedure<any> | DecorateMutationProcedure<any>> = TProcedure['~types']['output'];
|
|
40
|
+
export interface DecorateInfiniteQueryProcedure<TDef extends ResolverDef> extends TypeHelper<TDef> {
|
|
46
41
|
/**
|
|
47
42
|
* Create a set of type-safe infinite query options that can be passed to `useInfiniteQuery`, `prefetchInfiniteQuery` etc.
|
|
48
43
|
*
|
|
@@ -51,28 +46,74 @@ export interface DecorateQueryProcedure<TDef extends ResolverDef> {
|
|
|
51
46
|
*/
|
|
52
47
|
infiniteQueryOptions: TRPCInfiniteQueryOptions<TDef>;
|
|
53
48
|
/**
|
|
54
|
-
* Calculate the TanStack Query Key for a Query Procedure
|
|
49
|
+
* Calculate the TanStack Query Key for a Infinite Query Procedure
|
|
55
50
|
*
|
|
56
51
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
57
52
|
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
58
53
|
*/
|
|
59
|
-
|
|
54
|
+
infiniteQueryKey: (input?: Partial<TDef['input']>) => DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
55
|
+
transformer: TDef['transformer'];
|
|
56
|
+
errorShape: TDef['errorShape'];
|
|
57
|
+
}>>;
|
|
60
58
|
/**
|
|
61
|
-
* Calculate a TanStack Query Filter for a Query Procedure
|
|
59
|
+
* Calculate a TanStack Query Filter for a Infinite Query Procedure
|
|
62
60
|
*
|
|
63
61
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
64
62
|
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
65
63
|
*/
|
|
66
|
-
|
|
64
|
+
infiniteQueryFilter: (input?: Partial<TDef['input']>, filters?: QueryFilters<TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
65
|
+
transformer: TDef['transformer'];
|
|
66
|
+
errorShape: TDef['errorShape'];
|
|
67
|
+
}>, TRPCInfiniteData<TDef['input'], TDef['output']>, DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
68
|
+
transformer: TDef['transformer'];
|
|
69
|
+
errorShape: TDef['errorShape'];
|
|
70
|
+
}>>>) => WithRequired<QueryFilters<TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
71
|
+
transformer: TDef['transformer'];
|
|
72
|
+
errorShape: TDef['errorShape'];
|
|
73
|
+
}>, TRPCInfiniteData<TDef['input'], TDef['output']>, DataTag<TRPCQueryKey, TRPCInfiniteData<TDef['input'], TDef['output']>, TRPCClientErrorLike<{
|
|
74
|
+
transformer: TDef['transformer'];
|
|
75
|
+
errorShape: TDef['errorShape'];
|
|
76
|
+
}>>>, 'queryKey'>;
|
|
67
77
|
}
|
|
68
|
-
export interface
|
|
78
|
+
export interface DecorateQueryProcedure<TDef extends ResolverDef> extends TypeHelper<TDef>, DecorateRouterKeyable {
|
|
69
79
|
/**
|
|
70
|
-
*
|
|
80
|
+
* Create a set of type-safe query options that can be passed to `useQuery`, `prefetchQuery` etc.
|
|
81
|
+
*
|
|
82
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/reference/queryOptions#queryoptions
|
|
83
|
+
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryOptions
|
|
71
84
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
queryOptions: TRPCQueryOptions<TDef>;
|
|
86
|
+
/**
|
|
87
|
+
* Calculate the TanStack Query Key for a Query Procedure
|
|
88
|
+
*
|
|
89
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-keys
|
|
90
|
+
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryKey
|
|
91
|
+
*/
|
|
92
|
+
queryKey: (input?: Partial<TDef['input']>) => DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
93
|
+
transformer: TDef['transformer'];
|
|
94
|
+
errorShape: TDef['errorShape'];
|
|
95
|
+
}>>;
|
|
96
|
+
/**
|
|
97
|
+
* Calculate a TanStack Query Filter for a Query Procedure
|
|
98
|
+
*
|
|
99
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/filters
|
|
100
|
+
* @see https://trpc.io/docs/client/tanstack-react-query/usage#queryFilter
|
|
101
|
+
*/
|
|
102
|
+
queryFilter: (input?: Partial<TDef['input']>, filters?: QueryFilters<TDef['output'], TRPCClientErrorLike<{
|
|
103
|
+
transformer: TDef['transformer'];
|
|
104
|
+
errorShape: TDef['errorShape'];
|
|
105
|
+
}>, TDef['output'], DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
106
|
+
transformer: TDef['transformer'];
|
|
107
|
+
errorShape: TDef['errorShape'];
|
|
108
|
+
}>>>) => WithRequired<QueryFilters<TDef['output'], TRPCClientErrorLike<{
|
|
109
|
+
transformer: TDef['transformer'];
|
|
110
|
+
errorShape: TDef['errorShape'];
|
|
111
|
+
}>, TDef['output'], DataTag<TRPCQueryKey, TDef['output'], TRPCClientErrorLike<{
|
|
112
|
+
transformer: TDef['transformer'];
|
|
113
|
+
errorShape: TDef['errorShape'];
|
|
114
|
+
}>>>, 'queryKey'>;
|
|
115
|
+
}
|
|
116
|
+
export interface DecorateMutationProcedure<TDef extends ResolverDef> extends TypeHelper<TDef> {
|
|
76
117
|
/**
|
|
77
118
|
* Create a set of type-safe mutation options that can be passed to `useMutation`
|
|
78
119
|
*
|
|
@@ -94,19 +135,19 @@ export interface DecorateSubscriptionProcedure<TDef extends ResolverDef> {
|
|
|
94
135
|
*/
|
|
95
136
|
subscriptionOptions: TRPCSubscriptionOptions<TDef>;
|
|
96
137
|
}
|
|
97
|
-
export type DecorateProcedure<TType extends TRPCProcedureType, TDef extends ResolverDef> = TType extends 'query' ? DecorateQueryProcedure<TDef> : TType extends 'mutation' ? DecorateMutationProcedure<TDef> : TType extends 'subscription' ? DecorateSubscriptionProcedure<TDef> : never;
|
|
138
|
+
export type DecorateProcedure<TType extends TRPCProcedureType, TDef extends ResolverDef> = TType extends 'query' ? DecorateQueryProcedure<TDef> & (TDef['input'] extends OptionalCursorInput ? DecorateInfiniteQueryProcedure<TDef> : Record<string, never>) : TType extends 'mutation' ? DecorateMutationProcedure<TDef> : TType extends 'subscription' ? DecorateSubscriptionProcedure<TDef> : never;
|
|
98
139
|
/**
|
|
99
140
|
* @internal
|
|
100
141
|
*/
|
|
101
|
-
export type
|
|
102
|
-
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends TRPCRouterRecord ?
|
|
142
|
+
export type DecoratedRouterRecord<TRoot extends AnyTRPCRootTypes, TRecord extends TRPCRouterRecord> = {
|
|
143
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value ? $Value extends TRPCRouterRecord ? DecoratedRouterRecord<TRoot, $Value> & DecorateRouterKeyable : $Value extends AnyTRPCProcedure ? DecorateProcedure<$Value['_def']['type'], {
|
|
103
144
|
input: inferProcedureInput<$Value>;
|
|
104
145
|
output: inferTransformedProcedureOutput<TRoot, $Value>;
|
|
105
146
|
transformer: TRoot['transformer'];
|
|
106
147
|
errorShape: TRoot['errorShape'];
|
|
107
148
|
}> : never : never;
|
|
108
149
|
};
|
|
109
|
-
export type TRPCOptionsProxy<TRouter extends AnyTRPCRouter> =
|
|
150
|
+
export type TRPCOptionsProxy<TRouter extends AnyTRPCRouter> = DecoratedRouterRecord<TRouter['_def']['_config']['$types'], TRouter['_def']['record']> & DecorateRouterKeyable;
|
|
110
151
|
export interface TRPCOptionsProxyOptionsBase {
|
|
111
152
|
queryClient: QueryClient | (() => QueryClient);
|
|
112
153
|
overrides?: {
|
|
@@ -128,4 +169,5 @@ export type TRPCOptionsProxyOptions<TRouter extends AnyTRPCRouter> = TRPCOptions
|
|
|
128
169
|
* @see https://trpc.io/docs/client/tanstack-react-query/server-components#5-create-a-trpc-caller-for-server-components
|
|
129
170
|
*/
|
|
130
171
|
export declare function createTRPCOptionsProxy<TRouter extends AnyTRPCRouter>(opts: TRPCOptionsProxyOptions<TRouter>): TRPCOptionsProxy<TRouter>;
|
|
172
|
+
export {};
|
|
131
173
|
//# sourceMappingURL=createOptionsProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOptionsProxy.d.ts","sourceRoot":"","sources":["../../src/internals/createOptionsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createOptionsProxy.d.ts","sourceRoot":"","sources":["../../src/internals/createOptionsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,+BAA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AC;AAE1B,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,uBAAuB,CAAC;KACrC,CAAC;CACH;AAED,MAAM,WAAW,+BAA+B,CAC9C,OAAO,SAAS,aAAa;IAE7B,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EACC,kBAAkB,CAAC,OAAO,CAAC,GAC3B,CAAC,MAAM,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,+BAA+B,CAC9C,OAAO,SAAS,aAAa;IAE7B,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;CAC1D;AAED,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,aAAa,IAC/D,2BAA2B,GACzB,CACI,+BAA+B,CAAC,OAAO,CAAC,GACxC,+BAA+B,CAAC,OAAO,CAAC,CAC3C,CAAC;AASN;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,aAAa,EAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,GACrC,gBAAgB,CAAC,OAAO,CAAC,CA4G3B"}
|
|
@@ -8,15 +8,6 @@ var queryOptions = require('./queryOptions.js');
|
|
|
8
8
|
var subscriptionOptions = require('./subscriptionOptions.js');
|
|
9
9
|
var utils = require('./utils.js');
|
|
10
10
|
|
|
11
|
-
function getQueryType(method) {
|
|
12
|
-
const map = {
|
|
13
|
-
queryOptions: 'query',
|
|
14
|
-
infiniteQueryOptions: 'infinite',
|
|
15
|
-
subscriptionOptions: 'any',
|
|
16
|
-
mutationOptions: 'any'
|
|
17
|
-
};
|
|
18
|
-
return map[method];
|
|
19
|
-
}
|
|
20
11
|
/**
|
|
21
12
|
* Create a typed proxy from your router types. Can also be used on the server.
|
|
22
13
|
*
|
|
@@ -45,41 +36,54 @@ function getQueryType(method) {
|
|
|
45
36
|
];
|
|
46
37
|
const utilName = path.pop();
|
|
47
38
|
const [arg1, arg2] = args;
|
|
48
|
-
function getQueryKey() {
|
|
49
|
-
const queryType = getQueryType(utilName);
|
|
50
|
-
return utils.getQueryKeyInternal(path, arg1, queryType ?? 'any');
|
|
51
|
-
}
|
|
52
39
|
const contextMap = {
|
|
53
40
|
'~types': undefined,
|
|
54
|
-
|
|
55
|
-
return utils.
|
|
41
|
+
pathKey: ()=>{
|
|
42
|
+
return utils.getQueryKeyInternal(path);
|
|
43
|
+
},
|
|
44
|
+
pathFilter: ()=>{
|
|
45
|
+
return {
|
|
46
|
+
...arg1,
|
|
47
|
+
queryKey: utils.getQueryKeyInternal(path)
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
queryOptions: ()=>{
|
|
51
|
+
return queryOptions.trpcQueryOptions({
|
|
52
|
+
input: arg1,
|
|
53
|
+
opts: arg2,
|
|
54
|
+
path,
|
|
55
|
+
queryClient: opts.queryClient,
|
|
56
|
+
queryKey: utils.getQueryKeyInternal(path, arg1, 'query'),
|
|
57
|
+
query: callIt('query')
|
|
58
|
+
});
|
|
56
59
|
},
|
|
57
60
|
queryKey: ()=>{
|
|
58
|
-
return
|
|
61
|
+
return utils.getQueryKeyInternal(path, arg1, 'query');
|
|
59
62
|
},
|
|
60
63
|
queryFilter: ()=>{
|
|
61
64
|
return {
|
|
62
65
|
...arg2,
|
|
63
|
-
queryKey:
|
|
66
|
+
queryKey: utils.getQueryKeyInternal(path, arg1, 'query')
|
|
64
67
|
};
|
|
65
68
|
},
|
|
66
69
|
infiniteQueryOptions: ()=>{
|
|
67
70
|
return infiniteQueryOptions.trpcInfiniteQueryOptions({
|
|
71
|
+
input: arg1,
|
|
68
72
|
opts: arg2,
|
|
69
73
|
path,
|
|
70
74
|
queryClient: opts.queryClient,
|
|
71
|
-
queryKey:
|
|
75
|
+
queryKey: utils.getQueryKeyInternal(path, arg1, 'infinite'),
|
|
72
76
|
query: callIt('query')
|
|
73
77
|
});
|
|
74
78
|
},
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
79
|
+
infiniteQueryKey: ()=>{
|
|
80
|
+
return utils.getQueryKeyInternal(path, arg1, 'infinite');
|
|
81
|
+
},
|
|
82
|
+
infiniteQueryFilter: ()=>{
|
|
83
|
+
return {
|
|
84
|
+
...arg2,
|
|
85
|
+
queryKey: utils.getQueryKeyInternal(path, arg1, 'infinite')
|
|
86
|
+
};
|
|
83
87
|
},
|
|
84
88
|
mutationOptions: ()=>{
|
|
85
89
|
return mutationOptions.trpcMutationOptions({
|
|
@@ -90,11 +94,14 @@ function getQueryType(method) {
|
|
|
90
94
|
overrides: opts.overrides?.mutations
|
|
91
95
|
});
|
|
92
96
|
},
|
|
97
|
+
mutationKey: ()=>{
|
|
98
|
+
return utils.getMutationKeyInternal(path);
|
|
99
|
+
},
|
|
93
100
|
subscriptionOptions: ()=>{
|
|
94
101
|
return subscriptionOptions.trpcSubscriptionOptions({
|
|
95
102
|
opts: arg2,
|
|
96
103
|
path,
|
|
97
|
-
queryKey:
|
|
104
|
+
queryKey: utils.getQueryKeyInternal(path, arg1, 'any'),
|
|
98
105
|
subscribe: callIt('subscription')
|
|
99
106
|
});
|
|
100
107
|
}
|