11import type { Client , ClientContext } from '@orpc/client'
22import type { MaybeOptionalOptions } from '@orpc/shared'
33import type { InfiniteData } from '@tanstack/vue-query'
4- import type { InfiniteOptionsBase , InfiniteOptionsIn , MutationOptionsBase , MutationOptionsIn , QueryOptionsBase , QueryOptionsIn } from './types'
4+ import type { InfiniteOptionsBase , InfiniteOptionsIn , MutationOptions , MutationOptionsIn , QueryOptionsBase , QueryOptionsIn } from './types'
55import { computed } from 'vue'
66import { buildKey } from './key'
77import { unrefDeep } from './utils'
@@ -19,11 +19,9 @@ export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TO
1919 options : U & InfiniteOptionsIn < TClientContext , TInput , TOutput , TError , USelectData , UPageParam >
2020 ) : NoInfer < U & Omit < InfiniteOptionsBase < TOutput , TError , UPageParam > , keyof U > >
2121
22- mutationOptions < U , UMutationContext > (
23- ...rest : MaybeOptionalOptions <
24- U & MutationOptionsIn < TClientContext , TInput , TOutput , TError , UMutationContext >
25- >
26- ) : NoInfer < U & Omit < MutationOptionsBase < TInput , TOutput , TError > , keyof U > >
22+ mutationOptions < UMutationContext > (
23+ ...rest : MaybeOptionalOptions < MutationOptionsIn < TClientContext , TInput , TOutput , TError , UMutationContext > >
24+ ) : MutationOptions < TInput , TOutput , TError , UMutationContext >
2725}
2826
2927export function createProcedureUtils < TClientContext extends ClientContext , TInput , TOutput , TError extends Error > (
@@ -33,31 +31,31 @@ export function createProcedureUtils<TClientContext extends ClientContext, TInpu
3331 return {
3432 call : client ,
3533
36- queryOptions ( ...[ { input , context , ... rest } = { } ] ) {
34+ queryOptions ( ...[ options = { } as any ] ) {
3735 return {
38- queryKey : computed ( ( ) => buildKey ( path , { type : 'query' , input : unrefDeep ( input ) as any } ) ) ,
39- queryFn : ( { signal } ) => client ( unrefDeep ( input ) as any , { signal, context : unrefDeep ( context ) as any } ) ,
40- ...( rest as any ) ,
36+ queryKey : computed ( ( ) => buildKey ( path , { type : 'query' , input : unrefDeep ( options . input ) } ) ) ,
37+ queryFn : ( { signal } ) => client ( unrefDeep ( options . input ) , { signal, context : unrefDeep ( options . context ) } ) ,
38+ ...options ,
4139 }
4240 } ,
4341
44- infiniteOptions ( { input , context , ... rest } ) {
42+ infiniteOptions ( options ) {
4543 return {
4644 queryKey : computed ( ( ) => {
47- return buildKey ( path , { type : 'infinite' , input : unrefDeep ( input ( unrefDeep ( rest . initialPageParam ) as any ) as any ) } )
45+ return buildKey ( path , { type : 'infinite' , input : unrefDeep ( options . input ( unrefDeep ( options . initialPageParam ) as any ) as any ) } )
4846 } ) ,
4947 queryFn : ( { pageParam, signal } ) => {
50- return client ( unrefDeep ( input ( pageParam as any ) ) as any , { signal, context : unrefDeep ( context ) as any } )
48+ return client ( unrefDeep ( options . input ( pageParam as any ) ) as any , { signal, context : unrefDeep ( options . context ) as any } )
5149 } ,
52- ...( rest as any ) ,
50+ ...( options as any ) ,
5351 }
5452 } ,
5553
56- mutationOptions ( ...[ { context , ... rest } = { } ] ) {
54+ mutationOptions ( ...[ options = { } as any ] ) {
5755 return {
5856 mutationKey : buildKey ( path , { type : 'mutation' } ) ,
59- mutationFn : input => client ( input , { context : unrefDeep ( context ) as any } ) ,
60- ...( rest as any ) ,
57+ mutationFn : input => client ( input , { context : unrefDeep ( options . context ) } ) ,
58+ ...( options as any ) ,
6159 }
6260 } ,
6361 }
0 commit comments