@trpc/react-query 10.7.0 → 10.8.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/{createHooksInternal-de11647d.mjs → createHooksInternal-9c1f8ad9.mjs} +18 -9
- package/dist/{createHooksInternal-9b01c277.js → createHooksInternal-d8e5577b.js} +19 -7
- package/dist/createTRPCReact.d.ts +18 -6
- package/dist/createTRPCReact.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals/context.d.ts +35 -19
- package/dist/internals/context.d.ts.map +1 -1
- package/dist/internals/getClientArgs.d.ts +2 -0
- package/dist/internals/getClientArgs.d.ts.map +1 -0
- package/dist/internals/useHookResult.d.ts +10 -0
- package/dist/internals/useHookResult.d.ts.map +1 -0
- package/dist/shared/hooks/createHooksInternal.d.ts +19 -116
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/hooks/deprecated/createHooksInternal.d.ts +61 -0
- package/dist/shared/hooks/deprecated/createHooksInternal.d.ts.map +1 -0
- package/dist/shared/hooks/types.d.ts +78 -0
- package/dist/shared/hooks/types.d.ts.map +1 -0
- package/dist/shared/index.d.ts +12 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +4 -1
- package/dist/shared/index.mjs +1 -1
- package/dist/shared/proxy/utilsProxy.d.ts +5 -4
- package/dist/shared/proxy/utilsProxy.d.ts.map +1 -1
- package/dist/ssg/ssgProxy.d.ts +3 -3
- package/dist/ssg/ssgProxy.d.ts.map +1 -1
- package/dist/utils/inferReactQueryProcedure.d.ts +1 -1
- package/dist/utils/inferReactQueryProcedure.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/createTRPCReact.tsx +64 -21
- package/src/internals/context.tsx +53 -45
- package/src/internals/getClientArgs.ts +7 -0
- package/src/internals/useHookResult.ts +18 -0
- package/src/shared/hooks/createHooksInternal.tsx +71 -309
- package/src/shared/hooks/deprecated/createHooksInternal.tsx +628 -0
- package/src/shared/hooks/types.ts +151 -0
- package/src/shared/index.ts +17 -0
- package/src/shared/proxy/utilsProxy.ts +6 -3
- package/src/ssg/ssgProxy.ts +8 -4
- package/src/utils/inferReactQueryProcedure.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,EACrB,MAAM,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC;;;;6BAiNxB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;;wBA+C1C,MAAM,GAAG,CAAC,MAAM,CAAC;oCAsCT;QAEZ,IAAI,EAAE,MAAM;QACZ,GAAG,IAAI,EAAE,OAAO,EAAE;KACnB;;qCA4Ca;QAEZ,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;KAC5B;EAoHJ;AAED;;;GAGG;AACH,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TRPCClientErrorLike } from '@trpc/client';
|
|
2
|
+
import type { AnyRouter, ProcedureRecord, inferProcedureClientError, inferProcedureInput, inferProcedureOutput } from '@trpc/server';
|
|
3
|
+
import { inferObservableValue } from '@trpc/server/observable';
|
|
4
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
5
|
+
import { TRPCContextState } from '../../../internals/context';
|
|
6
|
+
import { TRPCUseQueries } from '../../../internals/useQueries';
|
|
7
|
+
import { CreateTRPCReactOptions } from '../../types';
|
|
8
|
+
import { CreateClient, TRPCProvider, UseDehydratedState, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCSubscriptionOptions } from '../types';
|
|
9
|
+
declare type inferInfiniteQueryNames<TObj extends ProcedureRecord> = {
|
|
10
|
+
[TPath in keyof TObj]: inferProcedureInput<TObj[TPath]> extends {
|
|
11
|
+
cursor?: any;
|
|
12
|
+
} ? TPath : never;
|
|
13
|
+
}[keyof TObj];
|
|
14
|
+
declare type inferProcedures<TObj extends ProcedureRecord> = {
|
|
15
|
+
[TPath in keyof TObj]: {
|
|
16
|
+
input: inferProcedureInput<TObj[TPath]>;
|
|
17
|
+
output: inferTransformedProcedureOutput<TObj[TPath]>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hack to infer the type of `createReactQueryHooks`
|
|
22
|
+
* @link https://stackoverflow.com/a/59072991
|
|
23
|
+
*/
|
|
24
|
+
declare class GnClass<TRouter extends AnyRouter, TSSRContext = unknown> {
|
|
25
|
+
fn(): {
|
|
26
|
+
Provider: TRPCProvider<TRouter, TSSRContext>;
|
|
27
|
+
createClient: CreateClient<TRouter>;
|
|
28
|
+
useContext: () => TRPCContextState<TRouter, TSSRContext>;
|
|
29
|
+
useQuery: <TPath extends keyof TRouter["_def"]["queries"] & string, TQueryFnData = inferProcedures<TRouter["_def"]["queries"]>[TPath]["output"], TData = inferProcedures<TRouter["_def"]["queries"]>[TPath]["output"]>(pathAndInput: [path: TPath, ...args: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TRouter["_def"]["queries"][TPath]>>], opts?: UseTRPCQueryOptions<TPath, inferProcedures<TRouter["_def"]["queries"]>[TPath]["input"], TQueryFnData, TData, TRPCClientErrorLike<TRouter>> | undefined) => UseTRPCQueryResult<TData, TRPCClientErrorLike<TRouter>>;
|
|
30
|
+
useQueries: TRPCUseQueries<TRouter>;
|
|
31
|
+
useMutation: <TPath_1 extends keyof TRouter["_def"]["mutations"] & string, TContext = unknown>(path: TPath_1 | [TPath_1], opts?: UseTRPCMutationOptions<inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["input"], TRPCClientErrorLike<TRouter>, inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["output"], TContext> | undefined) => UseTRPCMutationResult<inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["output"], TRPCClientErrorLike<TRouter>, inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["input"], TContext>;
|
|
32
|
+
useSubscription: <TPath_2 extends keyof TRouter["_def"]["subscriptions"] & string, TOutput extends inferObservableValue<inferProcedureOutput<TRouter["_def"]["subscriptions"][TPath_2]>>>(pathAndInput: [path: TPath_2, ...args: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TRouter["_def"]["subscriptions"][TPath_2]>>], opts: UseTRPCSubscriptionOptions<inferObservableValue<inferProcedureOutput<TRouter["_def"]["subscriptions"][TPath_2]>>, inferProcedureClientError<TRouter["_def"]["subscriptions"][TPath_2]>>) => void;
|
|
33
|
+
useDehydratedState: UseDehydratedState<TRouter>;
|
|
34
|
+
useInfiniteQuery: <TPath_3 extends inferInfiniteQueryNames<TRouter["_def"]["queries"]> & string>(pathAndInput: [path: TPath_3, input: Omit<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["input"], "cursor">], opts?: UseTRPCInfiniteQueryOptions<TPath_3, Omit<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["input"], "cursor">, inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["output"], TRPCClientErrorLike<TRouter>> | undefined) => UseTRPCInfiniteQueryResult<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["output"], TRPCClientErrorLike<TRouter>>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare type returnTypeInferer<TType> = TType extends (a: Record<string, string>) => infer U ? U : never;
|
|
38
|
+
declare type fooType<TRouter extends AnyRouter, TSSRContext = unknown> = GnClass<TRouter, TSSRContext>['fn'];
|
|
39
|
+
/**
|
|
40
|
+
* Infer the type of a `createReactQueryHooks` function
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
export declare type CreateReactQueryHooks<TRouter extends AnyRouter, TSSRContext = unknown> = returnTypeInferer<fooType<TRouter, TSSRContext>>;
|
|
44
|
+
/**
|
|
45
|
+
* Create strongly typed react hooks
|
|
46
|
+
* @internal
|
|
47
|
+
* @deprecated
|
|
48
|
+
*/
|
|
49
|
+
export declare function createHooksInternal<TRouter extends AnyRouter, TSSRContext = unknown>(config?: CreateTRPCReactOptions<TRouter>): {
|
|
50
|
+
Provider: TRPCProvider<TRouter, TSSRContext>;
|
|
51
|
+
createClient: CreateClient<TRouter>;
|
|
52
|
+
useContext: () => TRPCContextState<TRouter, TSSRContext>;
|
|
53
|
+
useQuery: <TPath extends keyof TRouter["_def"]["queries"] & string, TQueryFnData = inferProcedures<TRouter["_def"]["queries"]>[TPath]["output"], TData = inferProcedures<TRouter["_def"]["queries"]>[TPath]["output"]>(pathAndInput: [path: TPath, ...args: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TRouter["_def"]["queries"][TPath]>>], opts?: UseTRPCQueryOptions<TPath, inferProcedures<TRouter["_def"]["queries"]>[TPath]["input"], TQueryFnData, TData, TRPCClientErrorLike<TRouter>> | undefined) => UseTRPCQueryResult<TData, TRPCClientErrorLike<TRouter>>;
|
|
54
|
+
useQueries: TRPCUseQueries<TRouter>;
|
|
55
|
+
useMutation: <TPath_1 extends keyof TRouter["_def"]["mutations"] & string, TContext = unknown>(path: TPath_1 | [TPath_1], opts?: UseTRPCMutationOptions<inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["input"], TRPCClientErrorLike<TRouter>, inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["output"], TContext> | undefined) => UseTRPCMutationResult<inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["output"], TRPCClientErrorLike<TRouter>, inferProcedures<TRouter["_def"]["mutations"]>[TPath_1]["input"], TContext>;
|
|
56
|
+
useSubscription: <TPath_2 extends keyof TRouter["_def"]["subscriptions"] & string, TOutput extends inferObservableValue<inferProcedureOutput<TRouter["_def"]["subscriptions"][TPath_2]>>>(pathAndInput: [path: TPath_2, ...args: import("@trpc/server").ProcedureArgs<import("@trpc/server").inferProcedureParams<TRouter["_def"]["subscriptions"][TPath_2]>>], opts: UseTRPCSubscriptionOptions<inferObservableValue<inferProcedureOutput<TRouter["_def"]["subscriptions"][TPath_2]>>, inferProcedureClientError<TRouter["_def"]["subscriptions"][TPath_2]>>) => void;
|
|
57
|
+
useDehydratedState: UseDehydratedState<TRouter>;
|
|
58
|
+
useInfiniteQuery: <TPath_3 extends inferInfiniteQueryNames<TRouter["_def"]["queries"]> & string>(pathAndInput: [path: TPath_3, input: Omit<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["input"], "cursor">], opts?: UseTRPCInfiniteQueryOptions<TPath_3, Omit<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["input"], "cursor">, inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["output"], TRPCClientErrorLike<TRouter>> | undefined) => UseTRPCInfiniteQueryResult<inferProcedures<TRouter["_def"]["queries"]>[TPath_3]["output"], TRPCClientErrorLike<TRouter>>;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=createHooksInternal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../../src/shared/hooks/deprecated/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EAEf,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAO9D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,aAAa,CAAC;AAE1E,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,UAAU,CAAC;AAElB,aAAK,uBAAuB,CAAC,IAAI,SAAS,eAAe,IAAI;KAC1D,KAAK,IAAI,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS;QAC9D,MAAM,CAAC,EAAE,GAAG,CAAC;KACd,GACG,KAAK,GACL,KAAK;CACV,CAAC,MAAM,IAAI,CAAC,CAAC;AAEd,aAAK,eAAe,CAAC,IAAI,SAAS,eAAe,IAAI;KAClD,KAAK,IAAI,MAAM,IAAI,GAAG;QACrB,KAAK,EAAE,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACxC,MAAM,EAAE,+BAA+B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACtD;CACF,CAAC;AA0gBF;;;GAGG;AACH,cAAM,OAAO,CAAC,OAAO,SAAS,SAAS,EAAE,WAAW,GAAG,OAAO;IAC5D,EAAE;;;;;;;;;;;CAGH;AAED,aAAK,iBAAiB,CAAC,KAAK,IAAI,KAAK,SAAS,CAC5C,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtB,MAAM,CAAC,GACR,CAAC,GACD,KAAK,CAAC;AACV,aAAK,OAAO,CAAC,OAAO,SAAS,SAAS,EAAE,WAAW,GAAG,OAAO,IAAI,OAAO,CACtE,OAAO,EACP,WAAW,CACZ,CAAC,IAAI,CAAC,CAAC;AAER;;;GAGG;AACH,oBAAY,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,IACnB,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,EACrB,MAAM,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC;;;;;;;;;;EAKzC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { DefinedUseQueryResult, DehydratedState, InfiniteQueryObserverSuccessResult, InitialDataFunction, QueryObserverSuccessResult, QueryOptions, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { CreateTRPCClientOptions, TRPCClient, TRPCRequestOptions } from '@trpc/client';
|
|
3
|
+
import { AnyRouter } from '@trpc/server';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { TRPCContextProps } from '../../internals/context';
|
|
6
|
+
import { TRPCHookResult } from '../../internals/useHookResult';
|
|
7
|
+
export declare type OutputWithCursor<TData, TCursor = any> = {
|
|
8
|
+
cursor: TCursor | null;
|
|
9
|
+
data: TData;
|
|
10
|
+
};
|
|
11
|
+
export interface TRPCReactRequestOptions extends Omit<TRPCRequestOptions, 'signal'> {
|
|
12
|
+
/**
|
|
13
|
+
* Opt out of SSR for this query by passing `ssr: false`
|
|
14
|
+
*/
|
|
15
|
+
ssr?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Opt out or into aborting request on unmount
|
|
18
|
+
*/
|
|
19
|
+
abortOnUnmount?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TRPCUseQueryBaseOptions {
|
|
22
|
+
/**
|
|
23
|
+
* tRPC-related options
|
|
24
|
+
*/
|
|
25
|
+
trpc?: TRPCReactRequestOptions;
|
|
26
|
+
}
|
|
27
|
+
export interface UseTRPCQueryOptions<TPath, TInput, TOutput, TData, TError> extends UseQueryOptions<TOutput, TError, TData, [TPath, TInput]>, TRPCUseQueryBaseOptions {
|
|
28
|
+
}
|
|
29
|
+
/** @internal **/
|
|
30
|
+
export interface DefinedUseTRPCQueryOptions<TPath, TInput, TOutput, TData, TError> extends UseTRPCQueryOptions<TPath, TInput, TOutput, TData, TError> {
|
|
31
|
+
initialData: TOutput | InitialDataFunction<TOutput>;
|
|
32
|
+
}
|
|
33
|
+
export interface TRPCQueryOptions<TPath, TInput, TData, TError> extends QueryOptions<TData, TError, TData, [TPath, TInput]>, TRPCUseQueryBaseOptions {
|
|
34
|
+
}
|
|
35
|
+
export interface UseTRPCInfiniteQueryOptions<TPath, TInput, TOutput, TError> extends UseInfiniteQueryOptions<TOutput, TError, TOutput, TOutput, [
|
|
36
|
+
TPath,
|
|
37
|
+
TInput
|
|
38
|
+
]>, TRPCUseQueryBaseOptions {
|
|
39
|
+
}
|
|
40
|
+
export interface UseTRPCMutationOptions<TInput, TError, TOutput, TContext = unknown> extends UseMutationOptions<TOutput, TError, TInput, TContext>, TRPCUseQueryBaseOptions {
|
|
41
|
+
}
|
|
42
|
+
export interface UseTRPCSubscriptionOptions<TOutput, TError> {
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
onStarted?: () => void;
|
|
45
|
+
onData: (data: TOutput) => void;
|
|
46
|
+
onError?: (err: TError) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface TRPCProviderProps<TRouter extends AnyRouter, TSSRContext> extends TRPCContextProps<TRouter, TSSRContext> {
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}
|
|
51
|
+
export declare type TRPCProvider<TRouter extends AnyRouter, TSSRContext> = (props: TRPCProviderProps<TRouter, TSSRContext>) => JSX.Element;
|
|
52
|
+
export declare type UseDehydratedState<TRouter extends AnyRouter> = (client: TRPCClient<TRouter>, trpcState: DehydratedState | undefined) => DehydratedState | undefined;
|
|
53
|
+
export declare type CreateClient<TRouter extends AnyRouter> = (opts: CreateTRPCClientOptions<TRouter>) => TRPCClient<TRouter>;
|
|
54
|
+
/**
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare type UseTRPCQueryResult<TData, TError> = UseQueryResult<TData, TError> & TRPCHookResult;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare type DefinedUseTRPCQueryResult<TData, TError> = DefinedUseQueryResult<TData, TError> & TRPCHookResult;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export declare type UseTRPCQuerySuccessResult<TData, TError> = QueryObserverSuccessResult<TData, TError> & TRPCHookResult;
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare type UseTRPCInfiniteQueryResult<TData, TError> = UseInfiniteQueryResult<TData, TError> & TRPCHookResult;
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export declare type UseTRPCInfiniteQuerySuccessResult<TData, TError> = InfiniteQueryObserverSuccessResult<TData, TError> & TRPCHookResult;
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
export declare type UseTRPCMutationResult<TData, TError, TVariables, TContext> = UseMutationResult<TData, TError, TVariables, TContext> & TRPCHookResult;
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,oBAAY,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,IAAI;IACnD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEF,MAAM,WAAW,uBAEf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC1C;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,CAAC,EAAE,uBAAuB,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE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Y,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,IACnE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,GAAG,cAAc,CAAC"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -6,4 +6,16 @@ export type { TRPCUseQueries } from '../internals/useQueries';
|
|
|
6
6
|
export * from './hooks/createHooksInternal';
|
|
7
7
|
export * from './queryClient';
|
|
8
8
|
export * from './types';
|
|
9
|
+
export * from './hooks/types';
|
|
10
|
+
export {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated this is an internal function
|
|
13
|
+
*/
|
|
14
|
+
getClientArgs, } from '../internals/getClientArgs';
|
|
15
|
+
export {
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
TRPCContext, } from './../internals/context';
|
|
20
|
+
export * from '../internals/context';
|
|
9
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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"}
|
|
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;AAE9B,OAAO;AACL;;GAEG;AACH,aAAa,GACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO;AACL;;GAEG;AACH,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC,cAAc,sBAAsB,CAAC"}
|
package/dist/shared/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var createHooksInternal = require('../createHooksInternal-
|
|
5
|
+
var createHooksInternal = require('../createHooksInternal-d8e5577b.js');
|
|
6
6
|
var queryClient = require('../queryClient-358a9a75.js');
|
|
7
7
|
require('@trpc/server/shared');
|
|
8
8
|
require('../getArrayQueryKey-4bdb5cc2.js');
|
|
@@ -12,9 +12,12 @@ require('react');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
exports.TRPCContext = createHooksInternal.TRPCContext;
|
|
16
|
+
exports.contextProps = createHooksInternal.contextProps;
|
|
15
17
|
exports.createHooksInternal = createHooksInternal.createHooksInternal;
|
|
16
18
|
exports.createReactProxyDecoration = createHooksInternal.createReactProxyDecoration;
|
|
17
19
|
exports.createReactQueryUtilsProxy = createHooksInternal.createReactQueryUtilsProxy;
|
|
20
|
+
exports.createRootHooks = createHooksInternal.createRootHooks;
|
|
18
21
|
exports.createUseQueriesProxy = createHooksInternal.createUseQueriesProxy;
|
|
19
22
|
exports.getClientArgs = createHooksInternal.getClientArgs;
|
|
20
23
|
exports.getQueryClient = queryClient.getQueryClient;
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, d as createUseQueriesProxy, g as getClientArgs } from '../createHooksInternal-
|
|
1
|
+
export { T as TRPCContext, f as contextProps, c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, e as createRootHooks, d as createUseQueriesProxy, g as getClientArgs } from '../createHooksInternal-9c1f8ad9.mjs';
|
|
2
2
|
export { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
3
3
|
import '@trpc/server/shared';
|
|
4
4
|
import '../getArrayQueryKey-86134f8b.mjs';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CancelOptions, InfiniteData, InvalidateOptions, InvalidateQueryFilters, RefetchOptions, RefetchQueryFilters, ResetOptions, SetDataOptions, Updater } from '@tanstack/react-query';
|
|
2
2
|
import { TRPCClientError } from '@trpc/client';
|
|
3
|
-
import { AnyQueryProcedure, AnyRouter, Filter, ProcedureOptions, inferProcedureInput } from '@trpc/server';
|
|
3
|
+
import { AnyQueryProcedure, AnyRouter, Filter, ProcedureOptions, ProtectedIntersection, inferProcedureInput } from '@trpc/server';
|
|
4
4
|
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
5
|
-
import { DecoratedProxyTRPCContextProps,
|
|
5
|
+
import { DecoratedProxyTRPCContextProps, TRPCFetchInfiniteQueryOptions, TRPCFetchQueryOptions } from '../../internals/context';
|
|
6
|
+
import { TRPCContextState } from '../../internals/context';
|
|
6
7
|
declare type DecorateProcedure<TRouter extends AnyRouter, TProcedure extends AnyQueryProcedure> = {
|
|
7
8
|
/**
|
|
8
9
|
* @link https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientfetchquery
|
|
@@ -75,10 +76,10 @@ declare type DecorateRouter = {
|
|
|
75
76
|
export declare type DecoratedProcedureUtilsRecord<TRouter extends AnyRouter> = {
|
|
76
77
|
[TKey in keyof Filter<TRouter['_def']['record'], AnyRouter | AnyQueryProcedure>]: TRouter['_def']['record'][TKey] extends AnyRouter ? DecoratedProcedureUtilsRecord<TRouter['_def']['record'][TKey]> & DecorateRouter : DecorateProcedure<TRouter, TRouter['_def']['record'][TKey]>;
|
|
77
78
|
} & DecorateRouter;
|
|
78
|
-
export declare type CreateReactUtilsProxy<TRouter extends AnyRouter, TSSRContext> =
|
|
79
|
+
export declare type CreateReactUtilsProxy<TRouter extends AnyRouter, TSSRContext> = ProtectedIntersection<DecoratedProxyTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter>>;
|
|
79
80
|
/**
|
|
80
81
|
* @internal
|
|
81
82
|
*/
|
|
82
|
-
export declare function createReactQueryUtilsProxy<TRouter extends AnyRouter, TSSRContext>(context: TRPCContextState<AnyRouter, unknown>):
|
|
83
|
+
export declare function createReactQueryUtilsProxy<TRouter extends AnyRouter, TSSRContext>(context: TRPCContextState<AnyRouter, unknown>): ProtectedIntersection<DecoratedProxyTRPCContextProps<TRouter, TSSRContext>, DecoratedProcedureUtilsRecord<TRouter>>;
|
|
83
84
|
export {};
|
|
84
85
|
//# sourceMappingURL=utilsProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/utilsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAyB,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,+BAA+B,EAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,8BAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"utilsProxy.d.ts","sourceRoot":"","sources":["../../../src/shared/proxy/utilsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAA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c,CAAC;AAInB,oBAAY,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,WAAW,IACT,qBAAqB,CACvB,8BAA8B,CAAC,OAAO,EAAE,WAAW,CAAC,EACpD,6BAA6B,CAAC,OAAO,CAAC,CACvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,SAAS,SAAS,EACzB,WAAW,EACX,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,uHAkE9C"}
|
package/dist/ssg/ssgProxy.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DehydrateOptions, DehydratedState, InfiniteData, QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, inferHandlerInput } from '@trpc/server';
|
|
2
|
+
import { AnyProcedure, AnyQueryProcedure, AnyRouter, Filter, ProtectedIntersection, inferHandlerInput } from '@trpc/server';
|
|
3
3
|
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
4
|
import { CreateSSGHelpersOptions } from './ssg';
|
|
5
5
|
declare type DecorateProcedure<TProcedure extends AnyProcedure> = {
|
|
@@ -29,9 +29,9 @@ export declare type DecoratedProcedureSSGRecord<TRouter extends AnyRouter> = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Create functions you can use for server-side rendering / static generation
|
|
31
31
|
*/
|
|
32
|
-
export declare function createProxySSGHelpers<TRouter extends AnyRouter>(opts: CreateSSGHelpersOptions<TRouter>): {
|
|
32
|
+
export declare function createProxySSGHelpers<TRouter extends AnyRouter>(opts: CreateSSGHelpersOptions<TRouter>): ProtectedIntersection<{
|
|
33
33
|
queryClient: QueryClient;
|
|
34
34
|
dehydrate: (opts?: DehydrateOptions) => DehydratedState;
|
|
35
|
-
}
|
|
35
|
+
}, DecoratedProcedureSSGRecord<TRouter>>;
|
|
36
36
|
export {};
|
|
37
37
|
//# sourceMappingURL=ssgProxy.d.ts.map
|
|
@@ -1 +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E,CAAC;AAEF;;GAEG;AACH,oBAAY,2BAA2B,CAAC,OAAO,SAAS,SAAS,IAAI;KAClE,IAAI,IAAI,MAAM,MAAM,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACzB,SAAS,GAAG,iBAAiB,CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GACjD,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,GAE5D,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAIF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;iBAMrB,WAAW;uBACL,gBAAgB,KAAK,eAAe;yCAsC5D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TRPCClientErrorLike } from '@trpc/client';
|
|
2
2
|
import { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, inferProcedureInput } from '@trpc/server';
|
|
3
|
-
import { inferTransformedProcedureOutput } from '@trpc/server/
|
|
3
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
4
|
import { UseTRPCMutationOptions, UseTRPCQueryOptions } from '../shared';
|
|
5
5
|
declare type InferQueryOptions<TProcedure extends AnyProcedure, TPath extends string> = Omit<UseTRPCQueryOptions<TPath, inferProcedureInput<TProcedure>, inferTransformedProcedureOutput<TProcedure>, inferTransformedProcedureOutput<TProcedure>, TRPCClientErrorLike<TProcedure>>, 'select'>;
|
|
6
6
|
declare type InferMutationOptions<TProcedure extends AnyProcedure> = UseTRPCMutationOptions<inferProcedureInput<TProcedure>, TRPCClientErrorLike<TProcedure>, inferTransformedProcedureOutput<TProcedure>>;
|
|
@@ -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,
|
|
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,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAExE,aAAK,iBAAiB,CACpB,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,aAAK,oBAAoB,CAAC,UAAU,SAAS,YAAY,IACvD,sBAAsB,CACpB,mBAAmB,CAAC,UAAU,CAAC,EAC/B,mBAAmB,CAAC,UAAU,CAAC,EAC/B,+BAA+B,CAAC,UAAU,CAAC,CAC5C,CAAC;AAEJ,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.8.0",
|
|
4
4
|
"description": "tRPC React lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
18
18
|
"dev": "pnpm build --watch",
|
|
19
19
|
"codegen:entrypoints": "tsx entrypoints.script.ts",
|
|
20
|
+
"lint": "eslint --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src",
|
|
20
21
|
"ts-watch": "tsc --project tsconfig.watch.json"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
@@ -54,17 +55,18 @@
|
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"@tanstack/react-query": "^4.3.8",
|
|
57
|
-
"@trpc/client": "10.
|
|
58
|
-
"@trpc/server": "10.
|
|
58
|
+
"@trpc/client": "10.8.0",
|
|
59
|
+
"@trpc/server": "10.8.0",
|
|
59
60
|
"react": ">=16.8.0",
|
|
60
61
|
"react-dom": ">=16.8.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@tanstack/react-query": "^4.3.8",
|
|
64
|
-
"@trpc/client": "10.
|
|
65
|
-
"@trpc/server": "10.
|
|
65
|
+
"@trpc/client": "10.8.0",
|
|
66
|
+
"@trpc/server": "10.8.0",
|
|
66
67
|
"@types/express": "^4.17.12",
|
|
67
68
|
"@types/node": "^18.7.20",
|
|
69
|
+
"eslint": "^8.30.0",
|
|
68
70
|
"express": "^4.17.1",
|
|
69
71
|
"next": "^13.0.0",
|
|
70
72
|
"react": "^18.2.0",
|
|
@@ -76,5 +78,5 @@
|
|
|
76
78
|
"publishConfig": {
|
|
77
79
|
"access": "public"
|
|
78
80
|
},
|
|
79
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "f5b4d4f398b2880725f472a2208e822e0f6ecb87"
|
|
80
82
|
}
|
package/src/createTRPCReact.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
AnyRouter,
|
|
8
8
|
AnySubscriptionProcedure,
|
|
9
9
|
ProcedureRouterRecord,
|
|
10
|
+
ProtectedIntersection,
|
|
10
11
|
inferProcedureInput,
|
|
11
12
|
} from '@trpc/server';
|
|
12
13
|
import {
|
|
@@ -23,8 +24,13 @@ import {
|
|
|
23
24
|
createReactQueryUtilsProxy,
|
|
24
25
|
} from './shared';
|
|
25
26
|
import {
|
|
26
|
-
CreateClient,
|
|
27
27
|
CreateReactQueryHooks,
|
|
28
|
+
createHooksInternal,
|
|
29
|
+
} from './shared/hooks/createHooksInternal';
|
|
30
|
+
import {
|
|
31
|
+
CreateClient,
|
|
32
|
+
DefinedUseTRPCQueryOptions,
|
|
33
|
+
DefinedUseTRPCQueryResult,
|
|
28
34
|
TRPCProvider,
|
|
29
35
|
UseDehydratedState,
|
|
30
36
|
UseTRPCInfiniteQueryOptions,
|
|
@@ -36,10 +42,45 @@ import {
|
|
|
36
42
|
UseTRPCQueryResult,
|
|
37
43
|
UseTRPCQuerySuccessResult,
|
|
38
44
|
UseTRPCSubscriptionOptions,
|
|
39
|
-
|
|
40
|
-
} from './shared/hooks/createHooksInternal';
|
|
45
|
+
} from './shared/hooks/types';
|
|
41
46
|
import { CreateTRPCReactOptions } from './shared/types';
|
|
42
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export interface ProcedureUseQuery<
|
|
52
|
+
TProcedure extends AnyProcedure,
|
|
53
|
+
TPath extends string,
|
|
54
|
+
> {
|
|
55
|
+
<
|
|
56
|
+
TQueryFnData = inferTransformedProcedureOutput<TProcedure>,
|
|
57
|
+
TData = inferTransformedProcedureOutput<TProcedure>,
|
|
58
|
+
>(
|
|
59
|
+
input: inferProcedureInput<TProcedure>,
|
|
60
|
+
opts: DefinedUseTRPCQueryOptions<
|
|
61
|
+
TPath,
|
|
62
|
+
inferProcedureInput<TProcedure>,
|
|
63
|
+
TQueryFnData,
|
|
64
|
+
TData,
|
|
65
|
+
TRPCClientErrorLike<TProcedure>
|
|
66
|
+
>,
|
|
67
|
+
): DefinedUseTRPCQueryResult<TData, TRPCClientErrorLike<TProcedure>>;
|
|
68
|
+
|
|
69
|
+
<
|
|
70
|
+
TQueryFnData = inferTransformedProcedureOutput<TProcedure>,
|
|
71
|
+
TData = inferTransformedProcedureOutput<TProcedure>,
|
|
72
|
+
>(
|
|
73
|
+
input: inferProcedureInput<TProcedure>,
|
|
74
|
+
opts?: UseTRPCQueryOptions<
|
|
75
|
+
TPath,
|
|
76
|
+
inferProcedureInput<TProcedure>,
|
|
77
|
+
TQueryFnData,
|
|
78
|
+
TData,
|
|
79
|
+
TRPCClientErrorLike<TProcedure>
|
|
80
|
+
>,
|
|
81
|
+
): UseTRPCQueryResult<TData, TRPCClientErrorLike<TProcedure>>;
|
|
82
|
+
}
|
|
83
|
+
|
|
43
84
|
/**
|
|
44
85
|
* @internal
|
|
45
86
|
*/
|
|
@@ -58,19 +99,7 @@ export type DecorateProcedure<
|
|
|
58
99
|
input: inferProcedureInput<TProcedure>,
|
|
59
100
|
type?: QueryType,
|
|
60
101
|
) => QueryKey;
|
|
61
|
-
useQuery: <
|
|
62
|
-
TQueryFnData = inferTransformedProcedureOutput<TProcedure>,
|
|
63
|
-
TData = inferTransformedProcedureOutput<TProcedure>,
|
|
64
|
-
>(
|
|
65
|
-
input: inferProcedureInput<TProcedure>,
|
|
66
|
-
opts?: UseTRPCQueryOptions<
|
|
67
|
-
TPath,
|
|
68
|
-
inferProcedureInput<TProcedure>,
|
|
69
|
-
TQueryFnData,
|
|
70
|
-
TData,
|
|
71
|
-
TRPCClientErrorLike<TProcedure>
|
|
72
|
-
>,
|
|
73
|
-
) => UseTRPCQueryResult<TData, TRPCClientErrorLike<TProcedure>>;
|
|
102
|
+
useQuery: ProcedureUseQuery<TProcedure, TPath>;
|
|
74
103
|
} & (inferProcedureInput<TProcedure> extends { cursor?: any }
|
|
75
104
|
? {
|
|
76
105
|
useInfiniteQuery: <
|
|
@@ -186,13 +215,25 @@ export type DecoratedProcedureRecord<
|
|
|
186
215
|
: never;
|
|
187
216
|
};
|
|
188
217
|
|
|
189
|
-
|
|
218
|
+
/**
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
|
|
190
222
|
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>;
|
|
191
223
|
Provider: TRPCProvider<TRouter, TSSRContext>;
|
|
192
224
|
createClient: CreateClient<TRouter>;
|
|
193
225
|
useQueries: TRPCUseQueries<TRouter>;
|
|
194
226
|
useDehydratedState: UseDehydratedState<TRouter>;
|
|
195
|
-
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type CreateTRPCReact<
|
|
230
|
+
TRouter extends AnyRouter,
|
|
231
|
+
TSSRContext,
|
|
232
|
+
TFlags,
|
|
233
|
+
> = ProtectedIntersection<
|
|
234
|
+
CreateTRPCReactBase<TRouter, TSSRContext>,
|
|
235
|
+
DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>
|
|
236
|
+
>;
|
|
196
237
|
|
|
197
238
|
/**
|
|
198
239
|
* @internal
|
|
@@ -219,7 +260,7 @@ export function createHooksInternalProxy<
|
|
|
219
260
|
return (trpc as any)[key];
|
|
220
261
|
}
|
|
221
262
|
|
|
222
|
-
return createReactProxyDecoration(key
|
|
263
|
+
return createReactProxyDecoration(key, trpc);
|
|
223
264
|
});
|
|
224
265
|
}
|
|
225
266
|
|
|
@@ -227,9 +268,11 @@ export function createTRPCReact<
|
|
|
227
268
|
TRouter extends AnyRouter,
|
|
228
269
|
TSSRContext = unknown,
|
|
229
270
|
TFlags = null,
|
|
230
|
-
>(
|
|
271
|
+
>(
|
|
272
|
+
opts?: CreateTRPCReactOptions<TRouter>,
|
|
273
|
+
): CreateTRPCReact<TRouter, TSSRContext, TFlags> {
|
|
231
274
|
const hooks = createHooksInternal<TRouter, TSSRContext>(opts);
|
|
232
275
|
const proxy = createHooksInternalProxy<TRouter, TSSRContext, TFlags>(hooks);
|
|
233
276
|
|
|
234
|
-
return proxy;
|
|
277
|
+
return proxy as any;
|
|
235
278
|
}
|