@trpc/react-query 11.0.0-next-beta.237 → 11.0.0-next-beta.240
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 +24 -24
- package/dist/createTRPCReact.d.ts +19 -19
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/internals/getQueryKey.d.ts +7 -7
- package/dist/internals/getQueryKey.d.ts.map +1 -1
- package/dist/server/ssgProxy.d.ts +7 -7
- package/dist/server/ssgProxy.d.ts.map +1 -1
- package/dist/shared/polymorphism/mutationLike.d.ts +4 -4
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/queryLike.d.ts +5 -5
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -1
- package/dist/shared/polymorphism/routerLike.d.ts +4 -4
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -1
- package/dist/shared/proxy/useQueriesProxy.d.ts +5 -5
- package/dist/shared/proxy/useQueriesProxy.d.ts.map +1 -1
- package/dist/shared/proxy/utilsProxy.d.ts +13 -13
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/utils/inferReactQueryProcedure.d.ts +6 -6
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/createTRPCReact.tsx +44 -44
- package/src/internals/getQueryKey.ts +9 -9
- package/src/server/ssgProxy.ts +13 -13
- package/src/shared/polymorphism/mutationLike.ts +6 -6
- package/src/shared/polymorphism/queryLike.ts +8 -8
- package/src/shared/polymorphism/routerLike.ts +6 -6
- package/src/shared/proxy/useQueriesProxy.ts +15 -15
- package/src/shared/proxy/utilsProxy.ts +23 -23
- package/src/utils/inferReactQueryProcedure.ts +23 -17
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import type { 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,
|
|
3
|
+
import type { AnyQueryProcedure, AnyRootTypes, AnyRouter, DeepPartial, Filter, inferProcedureInput, inferTransformedProcedureOutput, ProtectedIntersection } 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';
|
|
7
|
-
type DecorateProcedure<
|
|
7
|
+
type DecorateProcedure<TRoot extends AnyRootTypes, TProcedure extends AnyQueryProcedure> = {
|
|
8
8
|
/**
|
|
9
9
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchquery
|
|
10
10
|
*/
|
|
11
|
-
fetch(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<
|
|
11
|
+
fetch(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientError<TRoot>>): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
|
|
12
12
|
/**
|
|
13
13
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchinfinitequery
|
|
14
14
|
*/
|
|
15
|
-
fetchInfinite(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<
|
|
15
|
+
fetchInfinite(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientError<TRoot>>): Promise<InfiniteData<inferTransformedProcedureOutput<TRoot, TProcedure>, NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null>>;
|
|
16
16
|
/**
|
|
17
17
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchquery
|
|
18
18
|
*/
|
|
19
|
-
prefetch(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<
|
|
19
|
+
prefetch(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientError<TRoot>>): Promise<void>;
|
|
20
20
|
/**
|
|
21
21
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchinfinitequery
|
|
22
22
|
*/
|
|
23
|
-
prefetchInfinite(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<
|
|
23
|
+
prefetchInfinite(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchInfiniteQueryOptions<inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientError<TRoot>>): Promise<void>;
|
|
24
24
|
/**
|
|
25
25
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientensurequerydata
|
|
26
26
|
*/
|
|
27
|
-
ensureData(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<
|
|
27
|
+
ensureData(input: inferProcedureInput<TProcedure>, opts?: TRPCFetchQueryOptions<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientError<TRoot>>): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
|
|
28
28
|
/**
|
|
29
29
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientinvalidatequeries
|
|
30
30
|
*/
|
|
31
31
|
invalidate(input?: DeepPartial<inferProcedureInput<TProcedure>>, filters?: Omit<InvalidateQueryFilters, 'predicate'> & {
|
|
32
|
-
predicate?: (query: Query<inferProcedureInput<TProcedure>, TRPCClientError<
|
|
32
|
+
predicate?: (query: Query<inferProcedureInput<TProcedure>, TRPCClientError<TRoot>, inferProcedureInput<TProcedure>, QueryKeyKnown<inferProcedureInput<TProcedure>, inferProcedureInput<TProcedure> extends {
|
|
33
33
|
cursor?: any;
|
|
34
34
|
} | void ? 'infinite' : 'query'>>) => boolean;
|
|
35
35
|
}, options?: InvalidateOptions): Promise<void>;
|
|
@@ -52,19 +52,19 @@ type DecorateProcedure<TConfig extends AnyRootConfig, TProcedure extends AnyQuer
|
|
|
52
52
|
/**
|
|
53
53
|
* The input of the procedure
|
|
54
54
|
*/
|
|
55
|
-
input: inferProcedureInput<TProcedure>, updater: Updater<inferTransformedProcedureOutput<
|
|
55
|
+
input: inferProcedureInput<TProcedure>, updater: Updater<inferTransformedProcedureOutput<TRoot, TProcedure> | undefined, inferTransformedProcedureOutput<TRoot, TProcedure> | undefined>, options?: SetDataOptions): void;
|
|
56
56
|
/**
|
|
57
57
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata
|
|
58
58
|
*/
|
|
59
|
-
setInfiniteData(input: inferProcedureInput<TProcedure>, updater: Updater<InfiniteData<inferTransformedProcedureOutput<
|
|
59
|
+
setInfiniteData(input: inferProcedureInput<TProcedure>, updater: Updater<InfiniteData<inferTransformedProcedureOutput<TRoot, TProcedure>, NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null> | undefined, InfiniteData<inferTransformedProcedureOutput<TRoot, TProcedure>, NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null> | undefined>, options?: SetDataOptions): void;
|
|
60
60
|
/**
|
|
61
61
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata
|
|
62
62
|
*/
|
|
63
|
-
getData(input?: inferProcedureInput<TProcedure>): inferTransformedProcedureOutput<
|
|
63
|
+
getData(input?: inferProcedureInput<TProcedure>): inferTransformedProcedureOutput<TRoot, TProcedure> | undefined;
|
|
64
64
|
/**
|
|
65
65
|
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata
|
|
66
66
|
*/
|
|
67
|
-
getInfiniteData(input?: inferProcedureInput<TProcedure>): InfiniteData<inferTransformedProcedureOutput<
|
|
67
|
+
getInfiniteData(input?: inferProcedureInput<TProcedure>): InfiniteData<inferTransformedProcedureOutput<TRoot, TProcedure>, NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null> | undefined;
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
70
|
* this is the type that is used to add in procedures that can be used on
|
|
@@ -82,7 +82,7 @@ type DecorateRouter = {
|
|
|
82
82
|
* @internal
|
|
83
83
|
*/
|
|
84
84
|
export type DecoratedProcedureUtilsRecord<TRouter extends AnyRouter> = DecorateRouter & {
|
|
85
|
-
[TKey in keyof Filter<TRouter['_def']['record'], AnyQueryProcedure | AnyRouter>]: TRouter['_def']['record'][TKey] extends AnyRouter ? DecoratedProcedureUtilsRecord<TRouter['_def']['record'][TKey]> & DecorateRouter : DecorateProcedure<TRouter['_def']['_config'], TRouter['_def']['record'][TKey]>;
|
|
85
|
+
[TKey in keyof Filter<TRouter['_def']['record'], AnyQueryProcedure | AnyRouter>]: TRouter['_def']['record'][TKey] extends AnyRouter ? DecoratedProcedureUtilsRecord<TRouter['_def']['record'][TKey]> & DecorateRouter : DecorateProcedure<TRouter['_def']['_config']['$types'], TRouter['_def']['record'][TKey]>;
|
|
86
86
|
};
|
|
87
87
|
type AnyDecoratedProcedure = DecorateProcedure<any, any>;
|
|
88
88
|
export type CreateReactUtils<TRouter extends AnyRouter, TSSRContext> = ProtectedIntersection<DecoratedTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter>>;
|
|
@@ -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,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B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAC5D,cAAc,GAEhB,iBAAiB,CACf,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAChC;CACN,CAAC;AAEJ,KAAK,qBAAqB,GAAG,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEzD,MAAM,MAAM,gBAAgB,CAC1B,OAAO,SAAS,SAAS,EACzB,WAAW,IACT,qBAAqB,CACvB,yBAAyB,CAAC,OAAO,EAAE,WAAW,CAAC,EAC/C,6BAA6B,CAAC,OAAO,CAAC,CACvC,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,IACpD,6BAA6B,CAAC,OAAO,CAAC,CAAC;AAEzC,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,kHAelD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAC/B,gBAAgB,CAAC,OAAO,CAAC,CAI3B"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { TRPCClientErrorLike } from '@trpc/client';
|
|
2
|
-
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure,
|
|
2
|
+
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRootTypes, AnyRouter, inferProcedureInput, inferTransformedProcedureOutput } from '@trpc/server/unstable-core-do-not-import';
|
|
3
3
|
import type { UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult } from '../shared';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export type InferQueryOptions<
|
|
7
|
+
export type InferQueryOptions<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure, TData = inferTransformedProcedureOutput<TRoot, TProcedure>> = Omit<UseTRPCQueryOptions<inferTransformedProcedureOutput<TRoot, TProcedure>, inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientErrorLike<TRoot>, TData>, 'select'>;
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export type InferMutationOptions<
|
|
11
|
+
export type InferMutationOptions<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = UseTRPCMutationOptions<inferProcedureInput<TProcedure>, TRPCClientErrorLike<TRoot>, inferTransformedProcedureOutput<TRoot, TProcedure>>;
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
export type InferQueryResult<
|
|
15
|
+
export type InferQueryResult<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure> = UseTRPCQueryResult<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientErrorLike<TRoot>>;
|
|
16
16
|
/**
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
|
-
export type InferMutationResult<
|
|
19
|
+
export type InferMutationResult<TRoot extends AnyRootTypes, TProcedure extends AnyProcedure, TContext = unknown> = UseTRPCMutationResult<inferTransformedProcedureOutput<TRoot, TProcedure>, TRPCClientErrorLike<TRoot>, inferProcedureInput<TProcedure>, TContext>;
|
|
20
20
|
export type inferReactQueryProcedureOptions<TRouter extends AnyRouter> = {
|
|
21
|
-
[TKey in keyof TRouter['_def']['record']]: TRouter['_def']['record'][TKey] extends infer TRouterOrProcedure ? TRouterOrProcedure extends AnyRouter ? inferReactQueryProcedureOptions<TRouterOrProcedure> : TRouterOrProcedure extends AnyMutationProcedure ? InferMutationOptions<TRouter['_def']['_config'], TRouterOrProcedure> : TRouterOrProcedure extends AnyQueryProcedure ? InferQueryOptions<TRouter['_def']['_config'], TRouterOrProcedure> : never : never;
|
|
21
|
+
[TKey in keyof TRouter['_def']['record']]: TRouter['_def']['record'][TKey] extends infer TRouterOrProcedure ? TRouterOrProcedure extends AnyRouter ? inferReactQueryProcedureOptions<TRouterOrProcedure> : TRouterOrProcedure extends AnyMutationProcedure ? InferMutationOptions<TRouter['_def']['_config']['$types'], TRouterOrProcedure> : TRouterOrProcedure extends AnyQueryProcedure ? InferQueryOptions<TRouter['_def']['_config']['$types'], TRouterOrProcedure> : never : never;
|
|
22
22
|
};
|
|
23
23
|
//# 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,
|
|
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,EAChC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAC3B,KAAK,SAAS,YAAY,EAC1B,UAAU,SAAS,YAAY,EAC/B,KAAK,GAAG,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,IACxD,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AAC,CAAC,QAAQ,CAAC,EACpC,kBAAkB,CACnB,GACD,kBAAkB,SAAS,iBAAiB,GAC5C,iBAAiB,CACf,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EACpC,kBAAkB,CACnB,GACD,KAAK,GACP,KAAK;CACV,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.240+1ef5fe131",
|
|
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.240+1ef5fe131",
|
|
62
|
+
"@trpc/server": "11.0.0-next-beta.240+1ef5fe131",
|
|
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.240+1ef5fe131",
|
|
69
|
+
"@trpc/server": "11.0.0-next-beta.240+1ef5fe131",
|
|
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": "1ef5fe131658bf73429ab43f6f3ba697d7919b09"
|
|
89
89
|
}
|
package/src/createTRPCReact.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
AnyMutationProcedure,
|
|
4
4
|
AnyProcedure,
|
|
5
5
|
AnyQueryProcedure,
|
|
6
|
-
|
|
6
|
+
AnyRootTypes,
|
|
7
7
|
AnyRouter,
|
|
8
8
|
AnySubscriptionProcedure,
|
|
9
9
|
inferProcedureInput,
|
|
@@ -46,40 +46,40 @@ import type { CreateTRPCReactOptions } from './shared/types';
|
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
48
|
export interface ProcedureUseQuery<
|
|
49
|
-
|
|
49
|
+
TRoot extends AnyRootTypes,
|
|
50
50
|
TProcedure extends AnyProcedure,
|
|
51
51
|
> {
|
|
52
52
|
<
|
|
53
53
|
TQueryFnData extends inferTransformedProcedureOutput<
|
|
54
|
-
|
|
54
|
+
TRoot,
|
|
55
55
|
TProcedure
|
|
56
|
-
> = inferTransformedProcedureOutput<
|
|
56
|
+
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
57
57
|
TData = TQueryFnData,
|
|
58
58
|
>(
|
|
59
59
|
input: inferProcedureInput<TProcedure>,
|
|
60
60
|
opts: DefinedUseTRPCQueryOptions<
|
|
61
61
|
TQueryFnData,
|
|
62
62
|
TData,
|
|
63
|
-
TRPCClientErrorLike<
|
|
64
|
-
inferTransformedProcedureOutput<
|
|
63
|
+
TRPCClientErrorLike<TRoot>,
|
|
64
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>
|
|
65
65
|
>,
|
|
66
|
-
): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<
|
|
66
|
+
): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<TRoot>>;
|
|
67
67
|
|
|
68
68
|
<
|
|
69
69
|
TQueryFnData extends inferTransformedProcedureOutput<
|
|
70
|
-
|
|
70
|
+
TRoot,
|
|
71
71
|
TProcedure
|
|
72
|
-
> = inferTransformedProcedureOutput<
|
|
72
|
+
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
73
73
|
TData = TQueryFnData,
|
|
74
74
|
>(
|
|
75
75
|
input: inferProcedureInput<TProcedure>,
|
|
76
76
|
opts?: UseTRPCQueryOptions<
|
|
77
77
|
TQueryFnData,
|
|
78
78
|
TData,
|
|
79
|
-
TRPCClientErrorLike<
|
|
80
|
-
inferTransformedProcedureOutput<
|
|
79
|
+
TRPCClientErrorLike<TRoot>,
|
|
80
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>
|
|
81
81
|
>,
|
|
82
|
-
): UseTRPCQueryResult<TData, TRPCClientErrorLike<
|
|
82
|
+
): UseTRPCQueryResult<TData, TRPCClientErrorLike<TRoot>>;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -94,7 +94,7 @@ type CursorInput = {
|
|
|
94
94
|
*/
|
|
95
95
|
export type MaybeDecoratedInfiniteQuery<
|
|
96
96
|
TProcedure extends AnyProcedure,
|
|
97
|
-
|
|
97
|
+
TRoot extends AnyRootTypes,
|
|
98
98
|
> = inferProcedureInput<TProcedure> extends CursorInput
|
|
99
99
|
? {
|
|
100
100
|
/**
|
|
@@ -104,12 +104,12 @@ export type MaybeDecoratedInfiniteQuery<
|
|
|
104
104
|
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
105
105
|
opts: UseTRPCInfiniteQueryOptions<
|
|
106
106
|
inferProcedureInput<TProcedure>,
|
|
107
|
-
inferTransformedProcedureOutput<
|
|
108
|
-
TRPCClientErrorLike<
|
|
107
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
108
|
+
TRPCClientErrorLike<TRoot>
|
|
109
109
|
>,
|
|
110
110
|
) => UseTRPCInfiniteQueryResult<
|
|
111
|
-
inferTransformedProcedureOutput<
|
|
112
|
-
TRPCClientErrorLike<
|
|
111
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
112
|
+
TRPCClientErrorLike<TRoot>,
|
|
113
113
|
inferProcedureInput<TProcedure>
|
|
114
114
|
>;
|
|
115
115
|
/**
|
|
@@ -119,12 +119,12 @@ export type MaybeDecoratedInfiniteQuery<
|
|
|
119
119
|
input: Omit<inferProcedureInput<TProcedure>, 'cursor'>,
|
|
120
120
|
opts: UseTRPCSuspenseInfiniteQueryOptions<
|
|
121
121
|
inferProcedureInput<TProcedure>,
|
|
122
|
-
inferTransformedProcedureOutput<
|
|
123
|
-
TRPCClientErrorLike<
|
|
122
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
123
|
+
TRPCClientErrorLike<TRoot>
|
|
124
124
|
>,
|
|
125
125
|
) => UseTRPCSuspenseInfiniteQueryResult<
|
|
126
|
-
inferTransformedProcedureOutput<
|
|
127
|
-
TRPCClientErrorLike<
|
|
126
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
127
|
+
TRPCClientErrorLike<TRoot>,
|
|
128
128
|
inferProcedureInput<TProcedure>
|
|
129
129
|
>;
|
|
130
130
|
}
|
|
@@ -134,46 +134,46 @@ export type MaybeDecoratedInfiniteQuery<
|
|
|
134
134
|
* @internal
|
|
135
135
|
*/
|
|
136
136
|
export type DecoratedQueryMethods<
|
|
137
|
-
|
|
137
|
+
TRoot extends AnyRootTypes,
|
|
138
138
|
TProcedure extends AnyProcedure,
|
|
139
139
|
> = {
|
|
140
140
|
/**
|
|
141
141
|
* @link https://trpc.io/docs/v11/client/react/useQuery
|
|
142
142
|
*/
|
|
143
|
-
useQuery: ProcedureUseQuery<
|
|
143
|
+
useQuery: ProcedureUseQuery<TRoot, TProcedure>;
|
|
144
144
|
/**
|
|
145
145
|
* @link https://trpc.io/docs/v11/client/react/suspense#usesuspensequery
|
|
146
146
|
*/
|
|
147
147
|
useSuspenseQuery: <
|
|
148
148
|
TQueryFnData extends inferTransformedProcedureOutput<
|
|
149
|
-
|
|
149
|
+
TRoot,
|
|
150
150
|
TProcedure
|
|
151
|
-
> = inferTransformedProcedureOutput<
|
|
151
|
+
> = inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
152
152
|
TData = TQueryFnData,
|
|
153
153
|
>(
|
|
154
154
|
input: inferProcedureInput<TProcedure>,
|
|
155
155
|
opts?: UseTRPCSuspenseQueryOptions<
|
|
156
156
|
TQueryFnData,
|
|
157
157
|
TData,
|
|
158
|
-
TRPCClientErrorLike<
|
|
158
|
+
TRPCClientErrorLike<TRoot>
|
|
159
159
|
>,
|
|
160
|
-
) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<
|
|
160
|
+
) => UseTRPCSuspenseQueryResult<TData, TRPCClientErrorLike<TRoot>>;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* @internal
|
|
165
165
|
*/
|
|
166
166
|
export type DecoratedQuery<
|
|
167
|
-
|
|
167
|
+
TRoot extends AnyRootTypes,
|
|
168
168
|
TProcedure extends AnyProcedure,
|
|
169
|
-
> = MaybeDecoratedInfiniteQuery<TProcedure,
|
|
170
|
-
DecoratedQueryMethods<
|
|
169
|
+
> = MaybeDecoratedInfiniteQuery<TProcedure, TRoot> &
|
|
170
|
+
DecoratedQueryMethods<TRoot, TProcedure>;
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
173
|
* @internal
|
|
174
174
|
*/
|
|
175
175
|
export interface DecoratedMutation<
|
|
176
|
-
|
|
176
|
+
TRoot extends AnyRootTypes,
|
|
177
177
|
TProcedure extends AnyProcedure,
|
|
178
178
|
> {
|
|
179
179
|
/**
|
|
@@ -182,13 +182,13 @@ export interface DecoratedMutation<
|
|
|
182
182
|
useMutation: <TContext = unknown>(
|
|
183
183
|
opts?: UseTRPCMutationOptions<
|
|
184
184
|
inferProcedureInput<TProcedure>,
|
|
185
|
-
TRPCClientErrorLike<
|
|
186
|
-
inferTransformedProcedureOutput<
|
|
185
|
+
TRPCClientErrorLike<TRoot>,
|
|
186
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
187
187
|
TContext
|
|
188
188
|
>,
|
|
189
189
|
) => UseTRPCMutationResult<
|
|
190
|
-
inferTransformedProcedureOutput<
|
|
191
|
-
TRPCClientErrorLike<
|
|
190
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
191
|
+
TRPCClientErrorLike<TRoot>,
|
|
192
192
|
inferProcedureInput<TProcedure>,
|
|
193
193
|
TContext
|
|
194
194
|
>;
|
|
@@ -198,13 +198,13 @@ export interface DecoratedMutation<
|
|
|
198
198
|
* @internal
|
|
199
199
|
*/
|
|
200
200
|
export type DecorateProcedure<
|
|
201
|
-
|
|
201
|
+
TRoot extends AnyRootTypes,
|
|
202
202
|
TProcedure extends AnyProcedure,
|
|
203
203
|
_TFlags,
|
|
204
204
|
> = TProcedure extends AnyQueryProcedure
|
|
205
|
-
? DecoratedQuery<
|
|
205
|
+
? DecoratedQuery<TRoot, TProcedure>
|
|
206
206
|
: TProcedure extends AnyMutationProcedure
|
|
207
|
-
? DecoratedMutation<
|
|
207
|
+
? DecoratedMutation<TRoot, TProcedure>
|
|
208
208
|
: TProcedure extends AnySubscriptionProcedure
|
|
209
209
|
? {
|
|
210
210
|
/**
|
|
@@ -213,8 +213,8 @@ export type DecorateProcedure<
|
|
|
213
213
|
useSubscription: (
|
|
214
214
|
input: inferProcedureInput<TProcedure>,
|
|
215
215
|
opts?: UseTRPCSubscriptionOptions<
|
|
216
|
-
inferTransformedSubscriptionOutput<
|
|
217
|
-
TRPCClientErrorLike<
|
|
216
|
+
inferTransformedSubscriptionOutput<TRoot, TProcedure>,
|
|
217
|
+
TRPCClientErrorLike<TRoot>
|
|
218
218
|
>,
|
|
219
219
|
) => void;
|
|
220
220
|
}
|
|
@@ -224,18 +224,18 @@ export type DecorateProcedure<
|
|
|
224
224
|
* @internal
|
|
225
225
|
*/
|
|
226
226
|
export type DecoratedProcedureRecord<
|
|
227
|
-
|
|
227
|
+
TRoot extends AnyRootTypes,
|
|
228
228
|
TProcedures extends ProcedureRouterRecord,
|
|
229
229
|
TFlags,
|
|
230
230
|
> = {
|
|
231
231
|
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
|
|
232
232
|
? DecoratedProcedureRecord<
|
|
233
|
-
|
|
233
|
+
TRoot,
|
|
234
234
|
TProcedures[TKey]['_def']['record'],
|
|
235
235
|
TFlags
|
|
236
236
|
>
|
|
237
237
|
: TProcedures[TKey] extends AnyProcedure
|
|
238
|
-
? DecorateProcedure<
|
|
238
|
+
? DecorateProcedure<TRoot, TProcedures[TKey], TFlags>
|
|
239
239
|
: never;
|
|
240
240
|
};
|
|
241
241
|
|
|
@@ -267,7 +267,7 @@ export type CreateTRPCReact<
|
|
|
267
267
|
> = ProtectedIntersection<
|
|
268
268
|
CreateTRPCReactBase<TRouter, TSSRContext>,
|
|
269
269
|
DecoratedProcedureRecord<
|
|
270
|
-
TRouter['_def']['_config'],
|
|
270
|
+
TRouter['_def']['_config']['$types'],
|
|
271
271
|
TRouter['_def']['record'],
|
|
272
272
|
TFlags
|
|
273
273
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyMutationProcedure,
|
|
3
3
|
AnyQueryProcedure,
|
|
4
|
-
|
|
4
|
+
AnyRootTypes,
|
|
5
5
|
AnyRouter,
|
|
6
6
|
DeepPartial,
|
|
7
7
|
inferProcedureInput,
|
|
@@ -85,7 +85,7 @@ type GetQueryParams<
|
|
|
85
85
|
: [input?: GetQueryProcedureInput<TProcedureInput>, type?: QueryType];
|
|
86
86
|
|
|
87
87
|
type GetParams<
|
|
88
|
-
|
|
88
|
+
TRoot extends AnyRootTypes,
|
|
89
89
|
TProcedureOrRouter extends
|
|
90
90
|
| AnyMutationProcedure
|
|
91
91
|
| AnyQueryProcedure
|
|
@@ -93,15 +93,15 @@ type GetParams<
|
|
|
93
93
|
TFlags,
|
|
94
94
|
> = TProcedureOrRouter extends AnyQueryProcedure
|
|
95
95
|
? [
|
|
96
|
-
procedureOrRouter: DecorateProcedure<
|
|
96
|
+
procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>,
|
|
97
97
|
..._params: GetQueryParams<TProcedureOrRouter>,
|
|
98
98
|
]
|
|
99
99
|
: TProcedureOrRouter extends AnyMutationProcedure
|
|
100
|
-
? [procedureOrRouter: DecorateProcedure<
|
|
100
|
+
? [procedureOrRouter: DecorateProcedure<TRoot, TProcedureOrRouter, TFlags>]
|
|
101
101
|
: TProcedureOrRouter extends AnyRouter
|
|
102
102
|
? [
|
|
103
103
|
procedureOrRouter: DecoratedProcedureRecord<
|
|
104
|
-
|
|
104
|
+
TRoot,
|
|
105
105
|
TProcedureOrRouter['_def']['record'],
|
|
106
106
|
TFlags
|
|
107
107
|
>,
|
|
@@ -109,13 +109,13 @@ type GetParams<
|
|
|
109
109
|
: never;
|
|
110
110
|
|
|
111
111
|
type GetQueryKeyParams<
|
|
112
|
-
|
|
112
|
+
TRoot extends AnyRootTypes,
|
|
113
113
|
TProcedureOrRouter extends
|
|
114
114
|
| AnyMutationProcedure
|
|
115
115
|
| AnyQueryProcedure
|
|
116
116
|
| AnyRouter,
|
|
117
117
|
TFlags,
|
|
118
|
-
> = GetParams<
|
|
118
|
+
> = GetParams<TRoot, TProcedureOrRouter, TFlags>;
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* Method to extract the query key for a procedure
|
|
@@ -125,13 +125,13 @@ type GetQueryKeyParams<
|
|
|
125
125
|
* @link https://trpc.io/docs/v11/getQueryKey
|
|
126
126
|
*/
|
|
127
127
|
export function getQueryKey<
|
|
128
|
-
|
|
128
|
+
TRoot extends AnyRootTypes,
|
|
129
129
|
TProcedureOrRouter extends
|
|
130
130
|
| AnyMutationProcedure
|
|
131
131
|
| AnyQueryProcedure
|
|
132
132
|
| AnyRouter,
|
|
133
133
|
TFlags,
|
|
134
|
-
>(..._params: GetQueryKeyParams<
|
|
134
|
+
>(..._params: GetQueryKeyParams<TRoot, TProcedureOrRouter, TFlags>) {
|
|
135
135
|
const [procedureOrRouter, input, type] = _params;
|
|
136
136
|
// @ts-expect-error - we don't expose _def on the type layer
|
|
137
137
|
const path = procedureOrRouter._def().path as string[];
|
package/src/server/ssgProxy.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { getUntypedClient, TRPCUntypedClient } from '@trpc/client';
|
|
|
10
10
|
import type {
|
|
11
11
|
AnyProcedure,
|
|
12
12
|
AnyQueryProcedure,
|
|
13
|
-
|
|
13
|
+
AnyRootTypes,
|
|
14
14
|
AnyRouter,
|
|
15
15
|
DataTransformerOptions,
|
|
16
16
|
Filter,
|
|
@@ -49,7 +49,7 @@ type CreateServerSideHelpersOptions<TRouter extends AnyRouter> =
|
|
|
49
49
|
(CreateSSGHelpersExternal<TRouter> | CreateSSGHelpersInternal<TRouter>);
|
|
50
50
|
|
|
51
51
|
type DecorateProcedure<
|
|
52
|
-
|
|
52
|
+
TRoot extends AnyRootTypes,
|
|
53
53
|
TProcedure extends AnyProcedure,
|
|
54
54
|
> = {
|
|
55
55
|
/**
|
|
@@ -58,10 +58,10 @@ type DecorateProcedure<
|
|
|
58
58
|
fetch(
|
|
59
59
|
input: inferProcedureInput<TProcedure>,
|
|
60
60
|
opts?: TRPCFetchQueryOptions<
|
|
61
|
-
inferTransformedProcedureOutput<
|
|
62
|
-
TRPCClientError<
|
|
61
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
62
|
+
TRPCClientError<TRoot>
|
|
63
63
|
>,
|
|
64
|
-
): Promise<inferTransformedProcedureOutput<
|
|
64
|
+
): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching
|
|
@@ -70,12 +70,12 @@ type DecorateProcedure<
|
|
|
70
70
|
input: inferProcedureInput<TProcedure>,
|
|
71
71
|
opts?: TRPCFetchInfiniteQueryOptions<
|
|
72
72
|
inferProcedureInput<TProcedure>,
|
|
73
|
-
inferTransformedProcedureOutput<
|
|
74
|
-
TRPCClientError<
|
|
73
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
74
|
+
TRPCClientError<TRoot>
|
|
75
75
|
>,
|
|
76
76
|
): Promise<
|
|
77
77
|
InfiniteData<
|
|
78
|
-
inferTransformedProcedureOutput<
|
|
78
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
79
79
|
NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null
|
|
80
80
|
>
|
|
81
81
|
>;
|
|
@@ -86,8 +86,8 @@ type DecorateProcedure<
|
|
|
86
86
|
prefetch(
|
|
87
87
|
input: inferProcedureInput<TProcedure>,
|
|
88
88
|
opts?: TRPCFetchQueryOptions<
|
|
89
|
-
inferTransformedProcedureOutput<
|
|
90
|
-
TRPCClientError<
|
|
89
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
90
|
+
TRPCClientError<TRoot>
|
|
91
91
|
>,
|
|
92
92
|
): Promise<void>;
|
|
93
93
|
|
|
@@ -98,8 +98,8 @@ type DecorateProcedure<
|
|
|
98
98
|
input: inferProcedureInput<TProcedure>,
|
|
99
99
|
opts?: TRPCFetchInfiniteQueryOptions<
|
|
100
100
|
inferProcedureInput<TProcedure>,
|
|
101
|
-
inferTransformedProcedureOutput<
|
|
102
|
-
TRPCClientError<
|
|
101
|
+
inferTransformedProcedureOutput<TRoot, TProcedure>,
|
|
102
|
+
TRPCClientError<TRoot>
|
|
103
103
|
>,
|
|
104
104
|
): Promise<void>;
|
|
105
105
|
};
|
|
@@ -115,7 +115,7 @@ type DecoratedProcedureSSGRecord<TRouter extends AnyRouter> = {
|
|
|
115
115
|
? DecoratedProcedureSSGRecord<TRouter['_def']['record'][TKey]>
|
|
116
116
|
: // utils only apply to queries
|
|
117
117
|
DecorateProcedure<
|
|
118
|
-
TRouter['_def']['_config'],
|
|
118
|
+
TRouter['_def']['_config']['$types'],
|
|
119
119
|
TRouter['_def']['record'][TKey]
|
|
120
120
|
>;
|
|
121
121
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyProcedure,
|
|
3
|
-
|
|
3
|
+
AnyRootTypes,
|
|
4
4
|
inferProcedureInput,
|
|
5
5
|
inferTransformedProcedureOutput,
|
|
6
6
|
} from '@trpc/server/unstable-core-do-not-import';
|
|
@@ -13,12 +13,12 @@ import type {
|
|
|
13
13
|
* Use to describe a mutation route which matches a given mutation procedure's interface
|
|
14
14
|
*/
|
|
15
15
|
export type MutationLike<
|
|
16
|
-
|
|
16
|
+
TRoot extends AnyRootTypes,
|
|
17
17
|
TProcedure extends AnyProcedure,
|
|
18
18
|
> = {
|
|
19
19
|
useMutation: (
|
|
20
|
-
opts?: InferMutationOptions<
|
|
21
|
-
) => InferMutationResult<
|
|
20
|
+
opts?: InferMutationOptions<TRoot, TProcedure>,
|
|
21
|
+
) => InferMutationResult<TRoot, TProcedure>;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -35,6 +35,6 @@ export type InferMutationLikeInput<
|
|
|
35
35
|
*/
|
|
36
36
|
export type InferMutationLikeData<
|
|
37
37
|
TMutationLike extends MutationLike<any, any>,
|
|
38
|
-
> = TMutationLike extends MutationLike<infer
|
|
39
|
-
? inferTransformedProcedureOutput<
|
|
38
|
+
> = TMutationLike extends MutationLike<infer TRoot, infer TProcedure>
|
|
39
|
+
? inferTransformedProcedureOutput<TRoot, TProcedure>
|
|
40
40
|
: never;
|