@trpc/react-query
Advanced tools
Comparing version 10.0.0-rc.6 to 10.0.0-rc.7
@@ -0,1 +1,2 @@ | ||
import { InfiniteData } from '@tanstack/react-query'; | ||
import { TRPCClientErrorLike } from '@trpc/client'; | ||
@@ -5,3 +6,3 @@ import { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, ProcedureRouterRecord, inferProcedureInput, inferProcedureOutput } from '@trpc/server'; | ||
import { CreateReactUtilsProxy } from './shared'; | ||
import { CreateClient, CreateReactQueryHooks, TRPCProvider, UseDehydratedState, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCSubscriptionOptions } from './shared/hooks/createHooksInternal'; | ||
import { CreateClient, CreateReactQueryHooks, TRPCProvider, UseDehydratedState, UseTRPCInfiniteQueryOptions, UseTRPCInfiniteQueryResult, UseTRPCInfiniteQuerySuccessResult, UseTRPCMutationOptions, UseTRPCMutationResult, UseTRPCQueryOptions, UseTRPCQueryResult, UseTRPCQuerySuccessResult, UseTRPCSubscriptionOptions } from './shared/hooks/createHooksInternal'; | ||
import { CreateTRPCReactOptions } from './shared/types'; | ||
@@ -11,3 +12,3 @@ /** | ||
*/ | ||
export declare type DecorateProcedure<TProcedure extends AnyProcedure, TPath extends string> = TProcedure extends AnyQueryProcedure ? { | ||
export declare type DecorateProcedure<TProcedure extends AnyProcedure, TFlags, TPath extends string> = TProcedure extends AnyQueryProcedure ? { | ||
useQuery: <TQueryFnData = inferProcedureOutput<TProcedure>, TData = inferProcedureOutput<TProcedure>>(input: inferProcedureInput<TProcedure>, opts?: UseTRPCQueryOptions<TPath, inferProcedureInput<TProcedure>, TQueryFnData, TData, TRPCClientErrorLike<TProcedure>>) => UseTRPCQueryResult<TData, TRPCClientErrorLike<TProcedure>>; | ||
@@ -18,2 +19,12 @@ } & (inferProcedureInput<TProcedure> extends { | ||
useInfiniteQuery: <_TQueryFnData = inferProcedureOutput<TProcedure>, TData = inferProcedureOutput<TProcedure>>(input: Omit<inferProcedureInput<TProcedure>, 'cursor'>, opts?: UseTRPCInfiniteQueryOptions<TPath, inferProcedureInput<TProcedure>, TData, TRPCClientErrorLike<TProcedure>>) => UseTRPCInfiniteQueryResult<TData, TRPCClientErrorLike<TProcedure>>; | ||
} & (TFlags extends 'ExperimentalSuspense' ? { | ||
useSuspenseInfiniteQuery: <_TQueryFnData = inferProcedureOutput<TProcedure>, TData = inferProcedureOutput<TProcedure>>(input: Omit<inferProcedureInput<TProcedure>, 'cursor'>, opts?: Omit<UseTRPCInfiniteQueryOptions<TPath, inferProcedureInput<TProcedure>, TData, TRPCClientErrorLike<TProcedure>>, 'enabled' | 'suspense'>) => [ | ||
InfiniteData<TData>, | ||
UseTRPCInfiniteQuerySuccessResult<TData, TRPCClientErrorLike<TProcedure>> | ||
]; | ||
} : {}) : {}) & (TFlags extends 'ExperimentalSuspense' ? { | ||
useSuspenseQuery: <TQueryFnData = inferProcedureOutput<TProcedure>, TData = inferProcedureOutput<TProcedure>>(input: inferProcedureInput<TProcedure>, opts?: Omit<UseTRPCQueryOptions<TPath, inferProcedureInput<TProcedure>, TQueryFnData, TData, TRPCClientErrorLike<TProcedure>>, 'enabled' | 'suspense'>) => [ | ||
TData, | ||
UseTRPCQuerySuccessResult<TData, TRPCClientErrorLike<TProcedure>> | ||
]; | ||
} : {}) : TProcedure extends AnyMutationProcedure ? { | ||
@@ -27,6 +38,6 @@ useMutation: <TContext = unknown>(opts?: UseTRPCMutationOptions<inferProcedureInput<TProcedure>, TRPCClientErrorLike<TProcedure>, inferProcedureOutput<TProcedure>, TContext>) => UseTRPCMutationResult<inferProcedureOutput<TProcedure>, TRPCClientErrorLike<TProcedure>, inferProcedureInput<TProcedure>, TContext>; | ||
*/ | ||
export declare type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord, TPath extends string = ''> = { | ||
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record'], `${TPath}${TKey & string}.`> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey], `${TPath}${TKey & string}`> : never; | ||
export declare type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord, TFlags, TPath extends string = ''> = { | ||
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record'], TFlags, `${TPath}${TKey & string}.`> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey], TFlags, `${TPath}${TKey & string}`> : never; | ||
}; | ||
export declare type CreateTRPCReact<TRouter extends AnyRouter, TSSRContext> = { | ||
export declare type CreateTRPCReact<TRouter extends AnyRouter, TSSRContext, TFlags> = { | ||
useContext(): CreateReactUtilsProxy<TRouter, TSSRContext>; | ||
@@ -36,8 +47,8 @@ Provider: TRPCProvider<TRouter, TSSRContext>; | ||
useDehydratedState: UseDehydratedState<TRouter>; | ||
} & DecoratedProcedureRecord<TRouter['_def']['record']>; | ||
} & DecoratedProcedureRecord<TRouter['_def']['record'], TFlags>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function createHooksInternalProxy<TRouter extends AnyRouter, TSSRContext = unknown>(trpc: CreateReactQueryHooks<TRouter, TSSRContext>): CreateTRPCReact<TRouter, TSSRContext>; | ||
export declare function createTRPCReact<TRouter extends AnyRouter, TSSRContext = unknown>(opts?: CreateTRPCReactOptions<TRouter>): CreateTRPCReact<TRouter, TSSRContext>; | ||
export declare function createHooksInternalProxy<TRouter extends AnyRouter, TSSRContext = unknown, TFlags = null>(trpc: CreateReactQueryHooks<TRouter, TSSRContext>): CreateTRPCReact<TRouter, TSSRContext, TFlags>; | ||
export declare function createTRPCReact<TRouter extends AnyRouter, TSSRContext = unknown, TFlags = null>(opts?: CreateTRPCReactOptions<TRouter>): CreateTRPCReact<TRouter, TSSRContext, TFlags>; | ||
//# sourceMappingURL=createTRPCReact.d.ts.map |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var React = require('react'); | ||
var createHooksInternal = require('./createHooksInternal-62a3b7fb.js'); | ||
var createHooksInternal = require('./createHooksInternal-c6b8f183.js'); | ||
require('@tanstack/react-query'); | ||
@@ -11,0 +11,0 @@ require('./getArrayQueryKey-5ab807a3.js'); |
@@ -8,5 +8,5 @@ import { AnyRouter } from '@trpc/server'; | ||
*/ | ||
export declare function createReactQueryHooks<TRouter extends AnyRouter, TSSRContext = unknown>(opts?: CreateTRPCReactOptions<TRouter>): CreateReactQueryHooks<TRouter, TSSRContext> & { | ||
proxy: CreateTRPCReact<TRouter, TSSRContext>; | ||
export declare function createReactQueryHooks<TRouter extends AnyRouter, TSSRContext = unknown, TFlags = null>(opts?: CreateTRPCReactOptions<TRouter>): CreateReactQueryHooks<TRouter, TSSRContext> & { | ||
proxy: CreateTRPCReact<TRouter, TSSRContext, TFlags>; | ||
}; | ||
//# sourceMappingURL=interop.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { DehydratedState, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import { DehydratedState, InfiniteQueryObserverSuccessResult, QueryObserverSuccessResult, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import { CreateTRPCClientOptions, TRPCClient, TRPCClientErrorLike, TRPCRequestOptions } from '@trpc/client'; | ||
@@ -73,2 +73,6 @@ import type { AnyRouter, ProcedureRecord, inferHandlerInput, inferProcedureClientError, inferProcedureInput, inferProcedureOutput } from '@trpc/server'; | ||
*/ | ||
export declare type UseTRPCQuerySuccessResult<TData, TError> = QueryObserverSuccessResult<TData, TError> & TRPCHookResult; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type UseTRPCInfiniteQueryResult<TData, TError> = UseInfiniteQueryResult<TData, TError> & TRPCHookResult; | ||
@@ -78,2 +82,6 @@ /** | ||
*/ | ||
export declare type UseTRPCInfiniteQuerySuccessResult<TData, TError> = InfiniteQueryObserverSuccessResult<TData, TError> & TRPCHookResult; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type UseTRPCMutationResult<TData, TError, TVariables, TContext> = UseMutationResult<TData, TError, TVariables, TContext> & TRPCHookResult; | ||
@@ -80,0 +88,0 @@ /** |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var createHooksInternal = require('../createHooksInternal-62a3b7fb.js'); | ||
var createHooksInternal = require('../createHooksInternal-c6b8f183.js'); | ||
var queryClient = require('../queryClient-358a9a75.js'); | ||
@@ -8,0 +8,0 @@ require('@trpc/server/shared'); |
{ | ||
"name": "@trpc/react-query", | ||
"version": "10.0.0-rc.6", | ||
"version": "10.0.0-rc.7", | ||
"description": "tRPC React lib", | ||
@@ -57,4 +57,4 @@ "author": "KATT", | ||
"@tanstack/react-query": "^4.3.8", | ||
"@trpc/client": "10.0.0-rc.6", | ||
"@trpc/server": "10.0.0-rc.6", | ||
"@trpc/client": "10.0.0-rc.7", | ||
"@trpc/server": "10.0.0-rc.7", | ||
"react": ">=16.8.0", | ||
@@ -65,8 +65,8 @@ "react-dom": ">=16.8.0" | ||
"@tanstack/react-query": "^4.3.8", | ||
"@trpc/client": "10.0.0-rc.6", | ||
"@trpc/server": "10.0.0-rc.6", | ||
"@trpc/client": "10.0.0-rc.7", | ||
"@trpc/server": "10.0.0-rc.7", | ||
"@types/express": "^4.17.12", | ||
"@types/node": "^18.7.20", | ||
"express": "^4.17.1", | ||
"next": "^12.3.1", | ||
"next": "^13.0.0", | ||
"react": "^18.2.0", | ||
@@ -81,3 +81,3 @@ "react-dom": "^18.2.0", | ||
}, | ||
"gitHead": "9ec752b68e28a45e0278fdc13c5318bc7403eb74" | ||
"gitHead": "f019f64a8200a881cbaf18f3e238c6a8898f3d70" | ||
} |
@@ -16,9 +16,10 @@ // interop: | ||
TSSRContext = unknown, | ||
TFlags = null, | ||
>( | ||
opts?: CreateTRPCReactOptions<TRouter>, | ||
): CreateReactQueryHooks<TRouter, TSSRContext> & { | ||
proxy: CreateTRPCReact<TRouter, TSSRContext>; | ||
proxy: CreateTRPCReact<TRouter, TSSRContext, TFlags>; | ||
} { | ||
const trpc = createHooksInternal<TRouter, TSSRContext>(opts); | ||
const proxy = createHooksInternalProxy<TRouter, TSSRContext>(trpc); | ||
const proxy = createHooksInternalProxy<TRouter, TSSRContext, TFlags>(trpc); | ||
@@ -25,0 +26,0 @@ return { |
@@ -31,4 +31,15 @@ import { AnyRouter } from '@trpc/server'; | ||
const queryKey = getQueryKey(path, input); | ||
if (lastArg.startsWith('useSuspense')) { | ||
const opts = rest[0] || {}; | ||
const fn = | ||
lastArg === 'useSuspenseQuery' ? 'useQuery' : 'useInfiniteQuery'; | ||
const result = (hooks as any)[fn](queryKey, { | ||
...opts, | ||
suspense: true, | ||
enabled: true, | ||
}); | ||
return [result.data, result]; | ||
} | ||
return (hooks as any)[lastArg](queryKey, ...rest); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166279
3501