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