@orpc/tanstack-query 1.4.5 → 1.5.1
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/index.d.mts +44 -14
- package/dist/index.d.ts +44 -14
- package/dist/index.mjs +22 -5
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import { SkipToken, QueryObserverOptions,
|
|
3
|
+
import { SkipToken, QueryKey, QueryObserverOptions, DataTag, QueryFunction, experimental_streamedQuery, InfiniteQueryObserverOptions, InfiniteData, MutationObserverOptions } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
type experimental_StreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
6
6
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
@@ -18,22 +18,28 @@ interface OperationContext {
|
|
|
18
18
|
type: OperationType;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
type
|
|
21
|
+
type QueryKeyOptions<TInput> = (undefined extends TInput ? {
|
|
22
22
|
input?: TInput | SkipToken;
|
|
23
23
|
} : {
|
|
24
24
|
input: TInput | SkipToken;
|
|
25
|
-
}) &
|
|
25
|
+
}) & {
|
|
26
|
+
queryKey?: QueryKey;
|
|
27
|
+
};
|
|
28
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryKeyOptions<TInput> & (Record<never, never> extends TClientContext ? {
|
|
26
29
|
context?: TClientContext;
|
|
27
30
|
} : {
|
|
28
31
|
context: TClientContext;
|
|
29
|
-
}) &
|
|
32
|
+
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey'>;
|
|
30
33
|
interface QueryOptionsBase<TOutput, TError> {
|
|
31
|
-
queryKey: QueryKey
|
|
34
|
+
queryKey: DataTag<QueryKey, TOutput, TError>;
|
|
32
35
|
queryFn: QueryFunction<TOutput>;
|
|
33
36
|
throwOnError?: (error: TError) => boolean;
|
|
34
37
|
retryDelay?: (count: number, error: TError) => number;
|
|
35
38
|
enabled: boolean;
|
|
36
39
|
}
|
|
40
|
+
type experimental_StreamedKeyOptions<TInput> = QueryKeyOptions<TInput> & {
|
|
41
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
42
|
+
};
|
|
37
43
|
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
38
44
|
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
39
45
|
};
|
|
@@ -47,7 +53,7 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
|
|
|
47
53
|
context: TClientContext;
|
|
48
54
|
}) & SetOptional<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey'>;
|
|
49
55
|
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
50
|
-
queryKey: QueryKey
|
|
56
|
+
queryKey: DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>;
|
|
51
57
|
queryFn: QueryFunction<TOutput, QueryKey, TPageParam>;
|
|
52
58
|
select?(): InfiniteData<TOutput, TPageParam>;
|
|
53
59
|
throwOnError?: (error: TError) => boolean;
|
|
@@ -66,9 +72,9 @@ type MutationOptions<TInput, TOutput, TError, TMutationContext> = MutationObserv
|
|
|
66
72
|
*/
|
|
67
73
|
interface GeneralUtils<TInput> {
|
|
68
74
|
/**
|
|
69
|
-
* Generate a
|
|
75
|
+
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
70
76
|
*
|
|
71
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
77
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
72
78
|
*/
|
|
73
79
|
key<TType extends OperationType>(options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
74
80
|
}
|
|
@@ -80,32 +86,56 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
80
86
|
/**
|
|
81
87
|
* Calling corresponding procedure client
|
|
82
88
|
*
|
|
83
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
89
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#calling-clients Tanstack Calling Procedure Client Docs}
|
|
84
90
|
*/
|
|
85
91
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
92
|
+
/**
|
|
93
|
+
* Generate a **full matching** key for [Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#query-options).
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
96
|
+
*/
|
|
97
|
+
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
86
98
|
/**
|
|
87
99
|
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
88
100
|
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
90
102
|
*/
|
|
91
103
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
104
|
+
/**
|
|
105
|
+
* Generate a **full matching** key for [Streamed Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options).
|
|
106
|
+
*
|
|
107
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
108
|
+
*/
|
|
109
|
+
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
92
110
|
/**
|
|
93
111
|
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
94
112
|
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
95
113
|
*
|
|
96
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
114
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
97
115
|
*/
|
|
98
116
|
experimental_streamedOptions<U, USelectData = experimental_StreamedQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_StreamedQueryOutput<TOutput>, TError>, keyof U>>;
|
|
117
|
+
/**
|
|
118
|
+
* Generate a **full matching** key for [Infinite Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options).
|
|
119
|
+
*
|
|
120
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
121
|
+
*/
|
|
122
|
+
infiniteKey<UPageParam>(options: Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, UPageParam>, UPageParam>, 'input' | 'initialPageParam' | 'queryKey'>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
99
123
|
/**
|
|
100
124
|
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
101
125
|
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
126
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
103
127
|
*/
|
|
104
128
|
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
|
|
129
|
+
/**
|
|
130
|
+
* Generate a **full matching** key for [Mutation Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#mutation-options).
|
|
131
|
+
*
|
|
132
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
133
|
+
*/
|
|
134
|
+
mutationKey(options?: Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>): DataTag<QueryKey, TOutput, TError>;
|
|
105
135
|
/**
|
|
106
136
|
* Generate options used for useMutation/...
|
|
107
137
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
138
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
109
139
|
*/
|
|
110
140
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
|
111
141
|
}
|
|
@@ -129,4 +159,4 @@ interface CreateRouterUtilsOptions {
|
|
|
129
159
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
130
160
|
|
|
131
161
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey };
|
|
132
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
|
162
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import { SkipToken, QueryObserverOptions,
|
|
3
|
+
import { SkipToken, QueryKey, QueryObserverOptions, DataTag, QueryFunction, experimental_streamedQuery, InfiniteQueryObserverOptions, InfiniteData, MutationObserverOptions } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
type experimental_StreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
6
6
|
type experimental_StreamedQueryOptions = Omit<Parameters<typeof experimental_streamedQuery>[0], 'queryFn'>;
|
|
@@ -18,22 +18,28 @@ interface OperationContext {
|
|
|
18
18
|
type: OperationType;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
type
|
|
21
|
+
type QueryKeyOptions<TInput> = (undefined extends TInput ? {
|
|
22
22
|
input?: TInput | SkipToken;
|
|
23
23
|
} : {
|
|
24
24
|
input: TInput | SkipToken;
|
|
25
|
-
}) &
|
|
25
|
+
}) & {
|
|
26
|
+
queryKey?: QueryKey;
|
|
27
|
+
};
|
|
28
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryKeyOptions<TInput> & (Record<never, never> extends TClientContext ? {
|
|
26
29
|
context?: TClientContext;
|
|
27
30
|
} : {
|
|
28
31
|
context: TClientContext;
|
|
29
|
-
}) &
|
|
32
|
+
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey'>;
|
|
30
33
|
interface QueryOptionsBase<TOutput, TError> {
|
|
31
|
-
queryKey: QueryKey
|
|
34
|
+
queryKey: DataTag<QueryKey, TOutput, TError>;
|
|
32
35
|
queryFn: QueryFunction<TOutput>;
|
|
33
36
|
throwOnError?: (error: TError) => boolean;
|
|
34
37
|
retryDelay?: (count: number, error: TError) => number;
|
|
35
38
|
enabled: boolean;
|
|
36
39
|
}
|
|
40
|
+
type experimental_StreamedKeyOptions<TInput> = QueryKeyOptions<TInput> & {
|
|
41
|
+
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
42
|
+
};
|
|
37
43
|
type experimental_StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData> & {
|
|
38
44
|
queryFnOptions?: experimental_StreamedQueryOptions;
|
|
39
45
|
};
|
|
@@ -47,7 +53,7 @@ type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TE
|
|
|
47
53
|
context: TClientContext;
|
|
48
54
|
}) & SetOptional<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey'>;
|
|
49
55
|
interface InfiniteOptionsBase<TOutput, TError, TPageParam> {
|
|
50
|
-
queryKey: QueryKey
|
|
56
|
+
queryKey: DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>;
|
|
51
57
|
queryFn: QueryFunction<TOutput, QueryKey, TPageParam>;
|
|
52
58
|
select?(): InfiniteData<TOutput, TPageParam>;
|
|
53
59
|
throwOnError?: (error: TError) => boolean;
|
|
@@ -66,9 +72,9 @@ type MutationOptions<TInput, TOutput, TError, TMutationContext> = MutationObserv
|
|
|
66
72
|
*/
|
|
67
73
|
interface GeneralUtils<TInput> {
|
|
68
74
|
/**
|
|
69
|
-
* Generate a
|
|
75
|
+
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
70
76
|
*
|
|
71
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
77
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
72
78
|
*/
|
|
73
79
|
key<TType extends OperationType>(options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
74
80
|
}
|
|
@@ -80,32 +86,56 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
80
86
|
/**
|
|
81
87
|
* Calling corresponding procedure client
|
|
82
88
|
*
|
|
83
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
89
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#calling-clients Tanstack Calling Procedure Client Docs}
|
|
84
90
|
*/
|
|
85
91
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
92
|
+
/**
|
|
93
|
+
* Generate a **full matching** key for [Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#query-options).
|
|
94
|
+
*
|
|
95
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
96
|
+
*/
|
|
97
|
+
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
86
98
|
/**
|
|
87
99
|
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
88
100
|
*
|
|
89
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
101
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
90
102
|
*/
|
|
91
103
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
104
|
+
/**
|
|
105
|
+
* Generate a **full matching** key for [Streamed Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options).
|
|
106
|
+
*
|
|
107
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
108
|
+
*/
|
|
109
|
+
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
92
110
|
/**
|
|
93
111
|
* Generate [Event Iterator](https://orpc.unnoq.com/docs/event-iterator) options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
94
112
|
* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
95
113
|
*
|
|
96
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
114
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
97
115
|
*/
|
|
98
116
|
experimental_streamedOptions<U, USelectData = experimental_StreamedQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<experimental_StreamedOptionsBase<experimental_StreamedQueryOutput<TOutput>, TError>, keyof U>>;
|
|
117
|
+
/**
|
|
118
|
+
* Generate a **full matching** key for [Infinite Query Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options).
|
|
119
|
+
*
|
|
120
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
121
|
+
*/
|
|
122
|
+
infiniteKey<UPageParam>(options: Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, UPageParam>, UPageParam>, 'input' | 'initialPageParam' | 'queryKey'>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
99
123
|
/**
|
|
100
124
|
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
101
125
|
*
|
|
102
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
126
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
103
127
|
*/
|
|
104
128
|
infiniteOptions<U, UPageParam, USelectData = InfiniteData<TOutput, UPageParam>>(options: U & InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam>): NoInfer<U & Omit<InfiniteOptionsBase<TOutput, TError, UPageParam>, keyof U>>;
|
|
129
|
+
/**
|
|
130
|
+
* Generate a **full matching** key for [Mutation Options](https://orpc.unnoq.com/docs/integrations/tanstack-query#mutation-options).
|
|
131
|
+
*
|
|
132
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
133
|
+
*/
|
|
134
|
+
mutationKey(options?: Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>): DataTag<QueryKey, TOutput, TError>;
|
|
105
135
|
/**
|
|
106
136
|
* Generate options used for useMutation/...
|
|
107
137
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query
|
|
138
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
109
139
|
*/
|
|
110
140
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
|
111
141
|
}
|
|
@@ -129,4 +159,4 @@ interface CreateRouterUtilsOptions {
|
|
|
129
159
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
130
160
|
|
|
131
161
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey };
|
|
132
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
|
162
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
package/dist/index.mjs
CHANGED
|
@@ -20,10 +20,14 @@ function createGeneralUtils(path) {
|
|
|
20
20
|
const OPERATION_CONTEXT_SYMBOL = Symbol("ORPC_OPERATION_CONTEXT");
|
|
21
21
|
|
|
22
22
|
function createProcedureUtils(client, options) {
|
|
23
|
-
|
|
23
|
+
const utils = {
|
|
24
24
|
call: client,
|
|
25
|
-
|
|
25
|
+
queryKey(...[optionsIn = {}]) {
|
|
26
26
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "query", input: optionsIn.input });
|
|
27
|
+
return queryKey;
|
|
28
|
+
},
|
|
29
|
+
queryOptions(...[optionsIn = {}]) {
|
|
30
|
+
const queryKey = utils.queryKey(optionsIn);
|
|
27
31
|
return {
|
|
28
32
|
queryFn: ({ signal }) => {
|
|
29
33
|
if (optionsIn.input === skipToken) {
|
|
@@ -45,8 +49,12 @@ function createProcedureUtils(client, options) {
|
|
|
45
49
|
queryKey
|
|
46
50
|
};
|
|
47
51
|
},
|
|
48
|
-
|
|
52
|
+
experimental_streamedKey(...[optionsIn = {}]) {
|
|
49
53
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "streamed", input: optionsIn.input, fnOptions: optionsIn.queryFnOptions });
|
|
54
|
+
return queryKey;
|
|
55
|
+
},
|
|
56
|
+
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
57
|
+
const queryKey = utils.experimental_streamedKey(optionsIn);
|
|
50
58
|
return {
|
|
51
59
|
enabled: optionsIn.input !== skipToken,
|
|
52
60
|
queryFn: experimental_streamedQuery({
|
|
@@ -75,11 +83,15 @@ function createProcedureUtils(client, options) {
|
|
|
75
83
|
queryKey
|
|
76
84
|
};
|
|
77
85
|
},
|
|
78
|
-
|
|
86
|
+
infiniteKey(optionsIn) {
|
|
79
87
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, {
|
|
80
88
|
type: "infinite",
|
|
81
89
|
input: optionsIn.input === skipToken ? skipToken : optionsIn.input(optionsIn.initialPageParam)
|
|
82
90
|
});
|
|
91
|
+
return queryKey;
|
|
92
|
+
},
|
|
93
|
+
infiniteOptions(optionsIn) {
|
|
94
|
+
const queryKey = utils.infiniteKey(optionsIn);
|
|
83
95
|
return {
|
|
84
96
|
queryFn: ({ pageParam, signal }) => {
|
|
85
97
|
if (optionsIn.input === skipToken) {
|
|
@@ -101,8 +113,12 @@ function createProcedureUtils(client, options) {
|
|
|
101
113
|
queryKey
|
|
102
114
|
};
|
|
103
115
|
},
|
|
104
|
-
|
|
116
|
+
mutationKey(...[optionsIn = {}]) {
|
|
105
117
|
const mutationKey = optionsIn.mutationKey ?? generateOperationKey(options.path, { type: "mutation" });
|
|
118
|
+
return mutationKey;
|
|
119
|
+
},
|
|
120
|
+
mutationOptions(...[optionsIn = {}]) {
|
|
121
|
+
const mutationKey = utils.mutationKey(optionsIn);
|
|
106
122
|
return {
|
|
107
123
|
mutationFn: (input) => client(input, {
|
|
108
124
|
context: {
|
|
@@ -118,6 +134,7 @@ function createProcedureUtils(client, options) {
|
|
|
118
134
|
};
|
|
119
135
|
}
|
|
120
136
|
};
|
|
137
|
+
return utils;
|
|
121
138
|
}
|
|
122
139
|
|
|
123
140
|
function createRouterUtils(client, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
],
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@tanstack/query-core": ">=5.80.2",
|
|
28
|
-
"@orpc/client": "1.
|
|
28
|
+
"@orpc/client": "1.5.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@orpc/shared": "1.
|
|
31
|
+
"@orpc/shared": "1.5.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@angular/core": "^20.0.
|
|
35
|
-
"@tanstack/angular-query-experimental": "^5.80.
|
|
36
|
-
"@tanstack/query-core": "^5.80.
|
|
37
|
-
"@tanstack/react-query": "^5.80.
|
|
38
|
-
"@tanstack/solid-query": "^5.80.
|
|
39
|
-
"@tanstack/svelte-query": "^5.80.
|
|
40
|
-
"@tanstack/vue-query": "^5.80.
|
|
41
|
-
"svelte": "^5.
|
|
34
|
+
"@angular/core": "^20.0.3",
|
|
35
|
+
"@tanstack/angular-query-experimental": "^5.80.7",
|
|
36
|
+
"@tanstack/query-core": "^5.80.7",
|
|
37
|
+
"@tanstack/react-query": "^5.80.7",
|
|
38
|
+
"@tanstack/solid-query": "^5.80.7",
|
|
39
|
+
"@tanstack/svelte-query": "^5.80.7",
|
|
40
|
+
"@tanstack/vue-query": "^5.80.7",
|
|
41
|
+
"svelte": "^5.34.1",
|
|
42
42
|
"vue": "^3.5.16",
|
|
43
|
-
"zod": "^3.25.
|
|
43
|
+
"zod": "^3.25.63"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "unbuild",
|