@trpc/react-query 10.10.0 → 10.11.0
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/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/polymorphism/index.d.ts +5 -0
- package/dist/shared/polymorphism/index.d.ts.map +1 -0
- package/dist/shared/polymorphism/mutationLike.d.ts +18 -0
- package/dist/shared/polymorphism/mutationLike.d.ts.map +1 -0
- package/dist/shared/polymorphism/queryLike.d.ts +18 -0
- package/dist/shared/polymorphism/queryLike.d.ts.map +1 -0
- package/dist/shared/polymorphism/routerLike.d.ts +10 -0
- package/dist/shared/polymorphism/routerLike.d.ts.map +1 -0
- package/dist/shared/polymorphism/utilsLike.d.ts +7 -0
- package/dist/shared/polymorphism/utilsLike.d.ts.map +1 -0
- package/dist/utils/inferReactQueryProcedure.d.ts +17 -4
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/shared/index.ts +1 -0
- package/src/shared/polymorphism/index.ts +4 -0
- package/src/shared/polymorphism/mutationLike.ts +31 -0
- package/src/shared/polymorphism/queryLike.ts +32 -0
- package/src/shared/polymorphism/routerLike.ts +23 -0
- package/src/shared/polymorphism/utilsLike.ts +8 -0
- package/src/utils/inferReactQueryProcedure.ts +36 -3
package/dist/shared/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAE/B,OAAO;AACL;;GAEG;AACH,aAAa,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO;AACL;;GAEG;AACH,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyProcedure, inferProcedureInput } from '@trpc/server';
|
|
2
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
3
|
+
import { InferMutationOptions, InferMutationResult } from '../../utils/inferReactQueryProcedure';
|
|
4
|
+
/**
|
|
5
|
+
* Use to describe a mutation route which matches a given mutation procedure's interface
|
|
6
|
+
*/
|
|
7
|
+
export declare type MutationLike<TProcedure extends AnyProcedure = AnyProcedure> = {
|
|
8
|
+
useMutation: (opts?: InferMutationOptions<TProcedure>) => InferMutationResult<TProcedure>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Use to unwrap a MutationLike's input
|
|
12
|
+
*/
|
|
13
|
+
export declare type InferMutationLikeInput<TMutationLike extends MutationLike> = TMutationLike extends MutationLike<infer TProcedure> ? inferProcedureInput<TProcedure> : never;
|
|
14
|
+
/**
|
|
15
|
+
* Use to unwrap a MutationLike's data output
|
|
16
|
+
*/
|
|
17
|
+
export declare type InferMutationLikeData<TMutationLike extends MutationLike> = TMutationLike extends MutationLike<infer TProcedure> ? inferTransformedProcedureOutput<TProcedure> : never;
|
|
18
|
+
//# sourceMappingURL=mutationLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutationLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/mutationLike.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,oBAAY,YAAY,CAAC,UAAU,SAAS,YAAY,GAAG,YAAY,IAAI;IACzE,WAAW,EAAE,CACX,IAAI,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,KACpC,mBAAmB,CAAC,UAAU,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,oBAAY,sBAAsB,CAAC,aAAa,SAAS,YAAY,IACnE,aAAa,SAAS,YAAY,CAAC,MAAM,UAAU,CAAC,GAChD,mBAAmB,CAAC,UAAU,CAAC,GAC/B,KAAK,CAAC;AAEZ;;GAEG;AACH,oBAAY,qBAAqB,CAAC,aAAa,SAAS,YAAY,IAClE,aAAa,SAAS,YAAY,CAAC,MAAM,UAAU,CAAC,GAChD,+BAA+B,CAAC,UAAU,CAAC,GAC3C,KAAK,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyProcedure, inferProcedureInput } from '@trpc/server';
|
|
2
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
3
|
+
import { InferQueryOptions, InferQueryResult } from '../../utils/inferReactQueryProcedure';
|
|
4
|
+
/**
|
|
5
|
+
* Use to request a query route which matches a given query procedure's interface
|
|
6
|
+
*/
|
|
7
|
+
export declare type QueryLike<TProcedure extends AnyProcedure = AnyProcedure> = {
|
|
8
|
+
useQuery: (variables: inferProcedureInput<TProcedure>, opts?: InferQueryOptions<TProcedure, any>) => InferQueryResult<TProcedure>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Use to unwrap a QueryLike's input
|
|
12
|
+
*/
|
|
13
|
+
export declare type InferQueryLikeInput<TQueryLike extends QueryLike> = TQueryLike extends QueryLike<infer TProcedure> ? inferProcedureInput<TProcedure> : never;
|
|
14
|
+
/**
|
|
15
|
+
* Use to unwrap a QueryLike's data output
|
|
16
|
+
*/
|
|
17
|
+
export declare type InferQueryLikeData<TQueryLike extends QueryLike> = TQueryLike extends QueryLike<infer TProcedure> ? inferTransformedProcedureOutput<TProcedure> : never;
|
|
18
|
+
//# sourceMappingURL=queryLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/queryLike.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,oBAAY,SAAS,CAAC,UAAU,SAAS,YAAY,GAAG,YAAY,IAAI;IACtE,QAAQ,EAAE,CACR,SAAS,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAC1C,IAAI,CAAC,EAAE,iBAAiB,CAAC,UAAU,EAAE,GAAG,CAAC,KACtC,gBAAgB,CAAC,UAAU,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,oBAAY,mBAAmB,CAAC,UAAU,SAAS,SAAS,IAC1D,UAAU,SAAS,SAAS,CAAC,MAAM,UAAU,CAAC,GAC1C,mBAAmB,CAAC,UAAU,CAAC,GAC/B,KAAK,CAAC;AAEZ;;GAEG;AACH,oBAAY,kBAAkB,CAAC,UAAU,SAAS,SAAS,IACzD,UAAU,SAAS,SAAS,CAAC,MAAM,UAAU,CAAC,GAC1C,+BAA+B,CAAC,UAAU,CAAC,GAC3C,KAAK,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyMutationProcedure, AnyQueryProcedure, AnyRouter } from '@trpc/server';
|
|
2
|
+
import { MutationLike } from './mutationLike';
|
|
3
|
+
import { QueryLike } from './queryLike';
|
|
4
|
+
/**
|
|
5
|
+
* Use to describe a route path which matches a given route's interface
|
|
6
|
+
*/
|
|
7
|
+
export declare type RouterLike<TRouter extends AnyRouter, TRecord extends TRouter['_def']['record'] = TRouter['_def']['record']> = {
|
|
8
|
+
[key in keyof TRecord]: TRecord[key] extends AnyRouter ? RouterLike<TRecord[key]> : TRecord[key] extends AnyQueryProcedure ? QueryLike<TRecord[key]> : TRecord[key] extends AnyMutationProcedure ? MutationLike<TRecord[key]> : never;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=routerLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/routerLike.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,oBAAY,UAAU,CACpB,OAAO,SAAS,SAAS,EACzB,OAAO,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IACnE;KACD,GAAG,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,SAAS,GAClD,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GACxB,OAAO,CAAC,GAAG,CAAC,SAAS,iBAAiB,GACtC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GACvB,OAAO,CAAC,GAAG,CAAC,SAAS,oBAAoB,GACzC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAC1B,KAAK;CACV,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AnyRouter } from '@trpc/server';
|
|
2
|
+
import { DecoratedProcedureUtilsRecord } from '../proxy/utilsProxy';
|
|
3
|
+
/**
|
|
4
|
+
* Use to describe a Utils/Context path which matches the given route's interface
|
|
5
|
+
*/
|
|
6
|
+
export declare type UtilsLike<TRouter extends AnyRouter> = DecoratedProcedureUtilsRecord<TRouter>;
|
|
7
|
+
//# sourceMappingURL=utilsLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilsLike.d.ts","sourceRoot":"","sources":["../../../src/shared/polymorphism/utilsLike.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAEpE;;GAEG;AACH,oBAAY,SAAS,CAAC,OAAO,SAAS,SAAS,IAC7C,6BAA6B,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { TRPCClientErrorLike } from '@trpc/client';
|
|
2
2
|
import { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, inferProcedureInput } from '@trpc/server';
|
|
3
3
|
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
|
-
import { UseTRPCMutationOptions, UseTRPCQueryOptions } from '../shared';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult } from '../shared';
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare type InferQueryOptions<TProcedure extends AnyProcedure, TPath extends string> = Omit<UseTRPCQueryOptions<TPath, inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<TProcedure>, inferTransformedProcedureOutput<TProcedure>, TRPCClientErrorLike<TProcedure>>, 'select'>;
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare type InferMutationOptions<TProcedure extends AnyProcedure> = UseTRPCMutationOptions<inferProcedureInput<TProcedure>, TRPCClientErrorLike<TProcedure>, inferTransformedProcedureOutput<TProcedure>>;
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare type InferQueryResult<TProcedure extends AnyProcedure> = UseTRPCQueryResult<inferTransformedProcedureOutput<TProcedure>, TRPCClientErrorLike<TProcedure>>;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare type InferMutationResult<TProcedure extends AnyProcedure, TContext = unknown> = UseTRPCMutationResult<inferTransformedProcedureOutput<TProcedure>, TRPCClientErrorLike<TProcedure>, inferProcedureInput<TProcedure>, TContext>;
|
|
7
21
|
export declare type inferReactQueryProcedureOptions<TRouter extends AnyRouter, TPath extends string = ''> = {
|
|
8
22
|
[TKey in keyof TRouter['_def']['record']]: TRouter['_def']['record'][TKey] extends infer TRouterOrProcedure ? TRouterOrProcedure extends AnyRouter ? inferReactQueryProcedureOptions<TRouterOrProcedure, `${TPath}${TKey & string}.`> : TRouterOrProcedure extends AnyMutationProcedure ? InferMutationOptions<TRouterOrProcedure> : TRouterOrProcedure extends AnyQueryProcedure ? InferQueryOptions<TRouterOrProcedure, `${TPath}${TKey & string}`> : never : never;
|
|
9
23
|
};
|
|
10
|
-
export {};
|
|
11
24
|
//# sourceMappingURL=inferReactQueryProcedure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inferReactQueryProcedure.d.ts","sourceRoot":"","sources":["../../src/utils/inferReactQueryProcedure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"inferReactQueryProcedure.d.ts","sourceRoot":"","sources":["../../src/utils/inferReactQueryProcedure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,oBAAY,iBAAiB,CAC3B,UAAU,SAAS,YAAY,EAC/B,KAAK,SAAS,MAAM,IAClB,IAAI,CACN,mBAAmB,CACjB,KAAK,EACL,mBAAmB,CAAC,UAAU,CAAC,EAC/B,+BAA+B,CAAC,UAAU,CAAC,EAC3C,+BAA+B,CAAC,UAAU,CAAC,EAC3C,mBAAmB,CAAC,UAAU,CAAC,CAChC,EACD,QAAQ,CACT,CAAC;AAEF;;GAEG;AACH,oBAAY,oBAAoB,CAAC,UAAU,SAAS,YAAY,IAC9D,sBAAsB,CACpB,mBAAmB,CAAC,UAAU,CAAC,EAC/B,mBAAmB,CAAC,UAAU,CAAC,EAC/B,+BAA+B,CAAC,UAAU,CAAC,CAC5C,CAAC;AAEJ;;GAEG;AACH,oBAAY,gBAAgB,CAAC,UAAU,SAAS,YAAY,IAC1D,kBAAkB,CAChB,+BAA+B,CAAC,UAAU,CAAC,EAC3C,mBAAmB,CAAC,UAAU,CAAC,CAChC,CAAC;AAEJ;;GAEG;AACH,oBAAY,mBAAmB,CAC7B,UAAU,SAAS,YAAY,EAC/B,QAAQ,GAAG,OAAO,IAChB,qBAAqB,CACvB,+BAA+B,CAAC,UAAU,CAAC,EAC3C,mBAAmB,CAAC,UAAU,CAAC,EAC/B,mBAAmB,CAAC,UAAU,CAAC,EAC/B,QAAQ,CACT,CAAC;AAEF,oBAAY,+BAA+B,CACzC,OAAO,SAAS,SAAS,EACzB,KAAK,SAAS,MAAM,GAAG,EAAE,IACvB;KACD,IAAI,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,kBAAkB,GACvG,kBAAkB,SAAS,SAAS,GAClC,+BAA+B,CAC7B,kBAAkB,EAClB,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,GAAG,CAC5B,GACD,kBAAkB,SAAS,oBAAoB,GAC/C,oBAAoB,CAAC,kBAAkB,CAAC,GACxC,kBAAkB,SAAS,iBAAiB,GAC5C,iBAAiB,CAAC,kBAAkB,EAAE,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC,GACjE,KAAK,GACP,KAAK;CACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.11.0",
|
|
4
4
|
"description": "tRPC React lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@tanstack/react-query": "^4.3.8",
|
|
60
|
-
"@trpc/client": "10.
|
|
61
|
-
"@trpc/server": "10.
|
|
60
|
+
"@trpc/client": "10.11.0",
|
|
61
|
+
"@trpc/server": "10.11.0",
|
|
62
62
|
"react": ">=16.8.0",
|
|
63
63
|
"react-dom": ">=16.8.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@tanstack/react-query": "^4.3.8",
|
|
67
|
-
"@trpc/client": "10.
|
|
68
|
-
"@trpc/server": "10.
|
|
67
|
+
"@trpc/client": "10.11.0",
|
|
68
|
+
"@trpc/server": "10.11.0",
|
|
69
69
|
"@types/express": "^4.17.12",
|
|
70
70
|
"@types/node": "^18.7.20",
|
|
71
71
|
"eslint": "^8.30.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "e77ed59be62562e7e8519468f9cc39387ed78476"
|
|
84
84
|
}
|
package/src/shared/index.ts
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AnyProcedure, inferProcedureInput } from '@trpc/server';
|
|
2
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
3
|
+
import {
|
|
4
|
+
InferMutationOptions,
|
|
5
|
+
InferMutationResult,
|
|
6
|
+
} from '../../utils/inferReactQueryProcedure';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use to describe a mutation route which matches a given mutation procedure's interface
|
|
10
|
+
*/
|
|
11
|
+
export type MutationLike<TProcedure extends AnyProcedure = AnyProcedure> = {
|
|
12
|
+
useMutation: (
|
|
13
|
+
opts?: InferMutationOptions<TProcedure>,
|
|
14
|
+
) => InferMutationResult<TProcedure>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Use to unwrap a MutationLike's input
|
|
19
|
+
*/
|
|
20
|
+
export type InferMutationLikeInput<TMutationLike extends MutationLike> =
|
|
21
|
+
TMutationLike extends MutationLike<infer TProcedure>
|
|
22
|
+
? inferProcedureInput<TProcedure>
|
|
23
|
+
: never;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Use to unwrap a MutationLike's data output
|
|
27
|
+
*/
|
|
28
|
+
export type InferMutationLikeData<TMutationLike extends MutationLike> =
|
|
29
|
+
TMutationLike extends MutationLike<infer TProcedure>
|
|
30
|
+
? inferTransformedProcedureOutput<TProcedure>
|
|
31
|
+
: never;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnyProcedure, inferProcedureInput } from '@trpc/server';
|
|
2
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
3
|
+
import {
|
|
4
|
+
InferQueryOptions,
|
|
5
|
+
InferQueryResult,
|
|
6
|
+
} from '../../utils/inferReactQueryProcedure';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use to request a query route which matches a given query procedure's interface
|
|
10
|
+
*/
|
|
11
|
+
export type QueryLike<TProcedure extends AnyProcedure = AnyProcedure> = {
|
|
12
|
+
useQuery: (
|
|
13
|
+
variables: inferProcedureInput<TProcedure>,
|
|
14
|
+
opts?: InferQueryOptions<TProcedure, any>,
|
|
15
|
+
) => InferQueryResult<TProcedure>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Use to unwrap a QueryLike's input
|
|
20
|
+
*/
|
|
21
|
+
export type InferQueryLikeInput<TQueryLike extends QueryLike> =
|
|
22
|
+
TQueryLike extends QueryLike<infer TProcedure>
|
|
23
|
+
? inferProcedureInput<TProcedure>
|
|
24
|
+
: never;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Use to unwrap a QueryLike's data output
|
|
28
|
+
*/
|
|
29
|
+
export type InferQueryLikeData<TQueryLike extends QueryLike> =
|
|
30
|
+
TQueryLike extends QueryLike<infer TProcedure>
|
|
31
|
+
? inferTransformedProcedureOutput<TProcedure>
|
|
32
|
+
: never;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnyMutationProcedure,
|
|
3
|
+
AnyQueryProcedure,
|
|
4
|
+
AnyRouter,
|
|
5
|
+
} from '@trpc/server';
|
|
6
|
+
import { MutationLike } from './mutationLike';
|
|
7
|
+
import { QueryLike } from './queryLike';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Use to describe a route path which matches a given route's interface
|
|
11
|
+
*/
|
|
12
|
+
export type RouterLike<
|
|
13
|
+
TRouter extends AnyRouter,
|
|
14
|
+
TRecord extends TRouter['_def']['record'] = TRouter['_def']['record'],
|
|
15
|
+
> = {
|
|
16
|
+
[key in keyof TRecord]: TRecord[key] extends AnyRouter
|
|
17
|
+
? RouterLike<TRecord[key]>
|
|
18
|
+
: TRecord[key] extends AnyQueryProcedure
|
|
19
|
+
? QueryLike<TRecord[key]>
|
|
20
|
+
: TRecord[key] extends AnyMutationProcedure
|
|
21
|
+
? MutationLike<TRecord[key]>
|
|
22
|
+
: never;
|
|
23
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyRouter } from '@trpc/server';
|
|
2
|
+
import { DecoratedProcedureUtilsRecord } from '../proxy/utilsProxy';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Use to describe a Utils/Context path which matches the given route's interface
|
|
6
|
+
*/
|
|
7
|
+
export type UtilsLike<TRouter extends AnyRouter> =
|
|
8
|
+
DecoratedProcedureUtilsRecord<TRouter>;
|
|
@@ -7,9 +7,17 @@ import {
|
|
|
7
7
|
inferProcedureInput,
|
|
8
8
|
} from '@trpc/server';
|
|
9
9
|
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
UseTRPCMutationOptions,
|
|
12
|
+
UseTRPCMutationResult,
|
|
13
|
+
UseTRPCQueryOptions,
|
|
14
|
+
UseTRPCQueryResult,
|
|
15
|
+
} from '../shared';
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export type InferQueryOptions<
|
|
13
21
|
TProcedure extends AnyProcedure,
|
|
14
22
|
TPath extends string,
|
|
15
23
|
> = Omit<
|
|
@@ -23,13 +31,38 @@ type InferQueryOptions<
|
|
|
23
31
|
'select'
|
|
24
32
|
>;
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export type InferMutationOptions<TProcedure extends AnyProcedure> =
|
|
27
38
|
UseTRPCMutationOptions<
|
|
28
39
|
inferProcedureInput<TProcedure>,
|
|
29
40
|
TRPCClientErrorLike<TProcedure>,
|
|
30
41
|
inferTransformedProcedureOutput<TProcedure>
|
|
31
42
|
>;
|
|
32
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export type InferQueryResult<TProcedure extends AnyProcedure> =
|
|
48
|
+
UseTRPCQueryResult<
|
|
49
|
+
inferTransformedProcedureOutput<TProcedure>,
|
|
50
|
+
TRPCClientErrorLike<TProcedure>
|
|
51
|
+
>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export type InferMutationResult<
|
|
57
|
+
TProcedure extends AnyProcedure,
|
|
58
|
+
TContext = unknown,
|
|
59
|
+
> = UseTRPCMutationResult<
|
|
60
|
+
inferTransformedProcedureOutput<TProcedure>,
|
|
61
|
+
TRPCClientErrorLike<TProcedure>,
|
|
62
|
+
inferProcedureInput<TProcedure>,
|
|
63
|
+
TContext
|
|
64
|
+
>;
|
|
65
|
+
|
|
33
66
|
export type inferReactQueryProcedureOptions<
|
|
34
67
|
TRouter extends AnyRouter,
|
|
35
68
|
TPath extends string = '',
|