@orpc/tanstack-query 0.0.0-next.e91d2fd → 0.0.0-next.eaec0b2
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/README.md +8 -8
- package/dist/index.d.mts +99 -26
- package/dist/index.d.ts +99 -26
- package/dist/index.mjs +54 -24
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://codecov.io/gh/
|
|
9
|
-
<img alt="codecov" src="https://codecov.io/gh/
|
|
8
|
+
<a href="https://codecov.io/gh/middleapi/orpc">
|
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/main/graph/badge.svg">
|
|
10
10
|
</a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@orpc/tanstack-query">
|
|
12
12
|
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Ftanstack-query?logo=npm" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/
|
|
15
|
-
<img alt="MIT License" src="https://img.shields.io/github/license/
|
|
14
|
+
<a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
|
|
15
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
|
|
16
16
|
</a>
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
-
<a href="https://deepwiki.com/
|
|
20
|
+
<a href="https://deepwiki.com/middleapi/orpc">
|
|
21
21
|
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
22
|
</a>
|
|
23
23
|
</div>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
## Documentation
|
|
47
47
|
|
|
48
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
49
49
|
|
|
50
50
|
## Packages
|
|
51
51
|
|
|
@@ -78,4 +78,4 @@ Shared logic for oRPC integrations with [TanStack Query](https://tanstack.com/qu
|
|
|
78
78
|
|
|
79
79
|
## License
|
|
80
80
|
|
|
81
|
-
Distributed under the MIT License. See [LICENSE](https://github.com/
|
|
81
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
|
2
2
|
import { Promisable, SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions,
|
|
3
|
+
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
interface experimental_SerializableStreamedQueryOptions {
|
|
6
6
|
/**
|
|
@@ -100,7 +100,7 @@ interface GeneralUtils<TInput> {
|
|
|
100
100
|
/**
|
|
101
101
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
102
102
|
*
|
|
103
|
-
* @see {@link https://orpc.
|
|
103
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
104
104
|
*/
|
|
105
105
|
key<TType extends OperationType>(options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
106
106
|
}
|
|
@@ -112,92 +112,165 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
112
112
|
/**
|
|
113
113
|
* Calling corresponding procedure client
|
|
114
114
|
*
|
|
115
|
-
* @see {@link https://orpc.
|
|
115
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#calling-clients Tanstack Calling Procedure Client Docs}
|
|
116
116
|
*/
|
|
117
117
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
118
118
|
/**
|
|
119
|
-
* Generate a **full matching** key for [Query Options](https://orpc.
|
|
119
|
+
* Generate a **full matching** key for [Query Options](https://orpc.dev/docs/integrations/tanstack-query#query-options).
|
|
120
120
|
*
|
|
121
|
-
* @see {@link https://orpc.
|
|
121
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
122
122
|
*/
|
|
123
123
|
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
124
124
|
/**
|
|
125
125
|
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
126
126
|
*
|
|
127
|
-
* @see {@link https://orpc.
|
|
127
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
128
128
|
*/
|
|
129
129
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
130
130
|
/**
|
|
131
|
-
* Generate a **full matching** key for [Streamed Query Options](https://orpc.
|
|
131
|
+
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options).
|
|
132
132
|
*
|
|
133
|
-
* @see {@link https://orpc.
|
|
133
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
134
134
|
*/
|
|
135
135
|
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
136
136
|
/**
|
|
137
|
-
* Configure queries for [Event Iterator](https://orpc.
|
|
137
|
+
* Configure queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
138
138
|
* This is built on [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
139
139
|
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
140
140
|
*
|
|
141
|
-
* @see {@link https://orpc.
|
|
141
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
142
142
|
*/
|
|
143
143
|
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>>;
|
|
144
144
|
/**
|
|
145
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.
|
|
145
|
+
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/tanstack-query#live-query-options).
|
|
146
146
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
148
148
|
*/
|
|
149
149
|
experimental_liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, experimental_LiveQueryOutput<TOutput>, TError>;
|
|
150
150
|
/**
|
|
151
|
-
* Configure live queries for [Event Iterator](https://orpc.
|
|
151
|
+
* Configure live queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
152
152
|
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
153
153
|
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
154
154
|
*
|
|
155
|
-
* @see {@link https://orpc.
|
|
155
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
156
156
|
*/
|
|
157
157
|
experimental_liveOptions<U, USelectData = experimental_LiveQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<experimental_LiveQueryOutput<TOutput>, TError>, keyof U>>;
|
|
158
158
|
/**
|
|
159
|
-
* Generate a **full matching** key for [Infinite Query Options](https://orpc.
|
|
159
|
+
* Generate a **full matching** key for [Infinite Query Options](https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options).
|
|
160
160
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
161
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
162
162
|
*/
|
|
163
163
|
infiniteKey<UPageParam>(options: Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, UPageParam>, UPageParam>, 'input' | 'initialPageParam' | 'queryKey'>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
164
164
|
/**
|
|
165
165
|
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
166
166
|
*
|
|
167
|
-
* @see {@link https://orpc.
|
|
167
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
168
168
|
*/
|
|
169
169
|
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>>;
|
|
170
170
|
/**
|
|
171
|
-
* Generate a **full matching** key for [Mutation Options](https://orpc.
|
|
171
|
+
* Generate a **full matching** key for [Mutation Options](https://orpc.dev/docs/integrations/tanstack-query#mutation-options).
|
|
172
172
|
*
|
|
173
|
-
* @see {@link https://orpc.
|
|
173
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
174
174
|
*/
|
|
175
175
|
mutationKey(options?: Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>): DataTag<QueryKey, TOutput, TError>;
|
|
176
176
|
/**
|
|
177
177
|
* Generate options used for useMutation/...
|
|
178
178
|
*
|
|
179
|
-
* @see {@link https://orpc.
|
|
179
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
180
180
|
*/
|
|
181
181
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
|
182
182
|
}
|
|
183
|
-
interface
|
|
183
|
+
interface experimental_ProcedureUtilsDefaults<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
184
|
+
/**
|
|
185
|
+
* Default options for queryKey utility
|
|
186
|
+
*
|
|
187
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
188
|
+
*/
|
|
189
|
+
queryKey?: Partial<QueryKeyOptions<TInput>>;
|
|
190
|
+
/**
|
|
191
|
+
* Default options for queryOptions utility
|
|
192
|
+
*
|
|
193
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
194
|
+
*/
|
|
195
|
+
queryOptions?: Partial<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
|
|
196
|
+
/**
|
|
197
|
+
* Default options for experimental_streamedKey utility
|
|
198
|
+
*
|
|
199
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
200
|
+
*/
|
|
201
|
+
experimental_streamedKey?: Partial<experimental_StreamedKeyOptions<TInput>>;
|
|
202
|
+
/**
|
|
203
|
+
* Default options for experimental_streamedOptions utility
|
|
204
|
+
*
|
|
205
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
206
|
+
*/
|
|
207
|
+
experimental_streamedOptions?: Partial<experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, unknown>>;
|
|
208
|
+
/**
|
|
209
|
+
* Default options for experimental_liveKey utility
|
|
210
|
+
*
|
|
211
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
212
|
+
*/
|
|
213
|
+
experimental_liveKey?: Partial<QueryKeyOptions<TInput>>;
|
|
214
|
+
/**
|
|
215
|
+
* Default options for experimental_liveOptions utility
|
|
216
|
+
*
|
|
217
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
218
|
+
*/
|
|
219
|
+
experimental_liveOptions?: Partial<experimental_StreamedOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, unknown>>;
|
|
220
|
+
/**
|
|
221
|
+
* Default options for infiniteKey utility
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
224
|
+
*/
|
|
225
|
+
infiniteKey?: Partial<Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, unknown>, unknown>, 'input' | 'initialPageParam' | 'queryKey'>>;
|
|
226
|
+
/**
|
|
227
|
+
* Default options for infiniteOptions utility
|
|
228
|
+
*
|
|
229
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
230
|
+
*/
|
|
231
|
+
infiniteOptions?: Partial<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>>;
|
|
232
|
+
/**
|
|
233
|
+
* Default options for mutationKey utility
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
236
|
+
*/
|
|
237
|
+
mutationKey?: Partial<Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>>;
|
|
238
|
+
/**
|
|
239
|
+
* Default options for mutationOptions utility
|
|
240
|
+
*
|
|
241
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
242
|
+
*/
|
|
243
|
+
mutationOptions?: Partial<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @todo remove default generic types on v2
|
|
247
|
+
*/
|
|
248
|
+
interface CreateProcedureUtilsOptions<TClientContext extends ClientContext = ClientContext, TInput = unknown, TOutput = unknown, TError = unknown> {
|
|
184
249
|
path: readonly string[];
|
|
250
|
+
experimental_defaults?: experimental_ProcedureUtilsDefaults<TClientContext, TInput, TOutput, TError>;
|
|
185
251
|
}
|
|
186
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
252
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
187
253
|
|
|
188
254
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
189
255
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
190
256
|
} & GeneralUtils<unknown>;
|
|
191
|
-
|
|
257
|
+
type experimental_RouterUtilsDefaults<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? experimental_ProcedureUtilsDefaults<UClientContext, UInput, UOutput, UError> : {
|
|
258
|
+
[K in keyof T]?: T[K] extends NestedClient<any> ? experimental_RouterUtilsDefaults<T[K]> : never;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* @todo remove default generic types on v2
|
|
262
|
+
*/
|
|
263
|
+
interface CreateRouterUtilsOptions<T extends NestedClient<any> = NestedClient<any>> {
|
|
192
264
|
path?: readonly string[];
|
|
265
|
+
experimental_defaults?: experimental_RouterUtilsDefaults<T>;
|
|
193
266
|
}
|
|
194
267
|
/**
|
|
195
268
|
* Create a router utils from a client.
|
|
196
269
|
*
|
|
197
270
|
* @info Both client-side and server-side clients are supported.
|
|
198
|
-
* @see {@link https://orpc.
|
|
271
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query Tanstack Query Integration}
|
|
199
272
|
*/
|
|
200
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
273
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions<T>): RouterUtils<T>;
|
|
201
274
|
|
|
202
275
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, experimental_serializableStreamedQuery, generateOperationKey };
|
|
203
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_LiveQueryOutput, experimental_SerializableStreamedQueryOptions, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
|
276
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_LiveQueryOutput, experimental_ProcedureUtilsDefaults, experimental_RouterUtilsDefaults, experimental_SerializableStreamedQueryOptions, 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 { Promisable, SetOptional, PartialDeep, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions,
|
|
3
|
+
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData } from '@tanstack/query-core';
|
|
4
4
|
|
|
5
5
|
interface experimental_SerializableStreamedQueryOptions {
|
|
6
6
|
/**
|
|
@@ -100,7 +100,7 @@ interface GeneralUtils<TInput> {
|
|
|
100
100
|
/**
|
|
101
101
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
102
102
|
*
|
|
103
|
-
* @see {@link https://orpc.
|
|
103
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
104
104
|
*/
|
|
105
105
|
key<TType extends OperationType>(options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
106
106
|
}
|
|
@@ -112,92 +112,165 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
|
112
112
|
/**
|
|
113
113
|
* Calling corresponding procedure client
|
|
114
114
|
*
|
|
115
|
-
* @see {@link https://orpc.
|
|
115
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#calling-clients Tanstack Calling Procedure Client Docs}
|
|
116
116
|
*/
|
|
117
117
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
118
118
|
/**
|
|
119
|
-
* Generate a **full matching** key for [Query Options](https://orpc.
|
|
119
|
+
* Generate a **full matching** key for [Query Options](https://orpc.dev/docs/integrations/tanstack-query#query-options).
|
|
120
120
|
*
|
|
121
|
-
* @see {@link https://orpc.
|
|
121
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
122
122
|
*/
|
|
123
123
|
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
124
124
|
/**
|
|
125
125
|
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
126
126
|
*
|
|
127
|
-
* @see {@link https://orpc.
|
|
127
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
128
128
|
*/
|
|
129
129
|
queryOptions<U, USelectData = TOutput>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<TOutput, TError>, keyof U>>;
|
|
130
130
|
/**
|
|
131
|
-
* Generate a **full matching** key for [Streamed Query Options](https://orpc.
|
|
131
|
+
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options).
|
|
132
132
|
*
|
|
133
|
-
* @see {@link https://orpc.
|
|
133
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
134
134
|
*/
|
|
135
135
|
experimental_streamedKey(...rest: MaybeOptionalOptions<experimental_StreamedKeyOptions<TInput>>): DataTag<QueryKey, experimental_StreamedQueryOutput<TOutput>, TError>;
|
|
136
136
|
/**
|
|
137
|
-
* Configure queries for [Event Iterator](https://orpc.
|
|
137
|
+
* Configure queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
138
138
|
* This is built on [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
139
139
|
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
140
140
|
*
|
|
141
|
-
* @see {@link https://orpc.
|
|
141
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
142
142
|
*/
|
|
143
143
|
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>>;
|
|
144
144
|
/**
|
|
145
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.
|
|
145
|
+
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/tanstack-query#live-query-options).
|
|
146
146
|
*
|
|
147
|
-
* @see {@link https://orpc.
|
|
147
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
148
148
|
*/
|
|
149
149
|
experimental_liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, experimental_LiveQueryOutput<TOutput>, TError>;
|
|
150
150
|
/**
|
|
151
|
-
* Configure live queries for [Event Iterator](https://orpc.
|
|
151
|
+
* Configure live queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
152
152
|
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
153
153
|
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
154
154
|
*
|
|
155
|
-
* @see {@link https://orpc.
|
|
155
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
156
156
|
*/
|
|
157
157
|
experimental_liveOptions<U, USelectData = experimental_LiveQueryOutput<TOutput>>(...rest: MaybeOptionalOptions<U & QueryOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, USelectData>>): NoInfer<U & Omit<QueryOptionsBase<experimental_LiveQueryOutput<TOutput>, TError>, keyof U>>;
|
|
158
158
|
/**
|
|
159
|
-
* Generate a **full matching** key for [Infinite Query Options](https://orpc.
|
|
159
|
+
* Generate a **full matching** key for [Infinite Query Options](https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options).
|
|
160
160
|
*
|
|
161
|
-
* @see {@link https://orpc.
|
|
161
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
162
162
|
*/
|
|
163
163
|
infiniteKey<UPageParam>(options: Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, UPageParam>, UPageParam>, 'input' | 'initialPageParam' | 'queryKey'>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
164
164
|
/**
|
|
165
165
|
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
166
166
|
*
|
|
167
|
-
* @see {@link https://orpc.
|
|
167
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
168
168
|
*/
|
|
169
169
|
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>>;
|
|
170
170
|
/**
|
|
171
|
-
* Generate a **full matching** key for [Mutation Options](https://orpc.
|
|
171
|
+
* Generate a **full matching** key for [Mutation Options](https://orpc.dev/docs/integrations/tanstack-query#mutation-options).
|
|
172
172
|
*
|
|
173
|
-
* @see {@link https://orpc.
|
|
173
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
174
174
|
*/
|
|
175
175
|
mutationKey(options?: Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>): DataTag<QueryKey, TOutput, TError>;
|
|
176
176
|
/**
|
|
177
177
|
* Generate options used for useMutation/...
|
|
178
178
|
*
|
|
179
|
-
* @see {@link https://orpc.
|
|
179
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
180
180
|
*/
|
|
181
181
|
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
|
182
182
|
}
|
|
183
|
-
interface
|
|
183
|
+
interface experimental_ProcedureUtilsDefaults<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
184
|
+
/**
|
|
185
|
+
* Default options for queryKey utility
|
|
186
|
+
*
|
|
187
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
188
|
+
*/
|
|
189
|
+
queryKey?: Partial<QueryKeyOptions<TInput>>;
|
|
190
|
+
/**
|
|
191
|
+
* Default options for queryOptions utility
|
|
192
|
+
*
|
|
193
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-options Tanstack Query Options Utility Docs}
|
|
194
|
+
*/
|
|
195
|
+
queryOptions?: Partial<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
|
|
196
|
+
/**
|
|
197
|
+
* Default options for experimental_streamedKey utility
|
|
198
|
+
*
|
|
199
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
200
|
+
*/
|
|
201
|
+
experimental_streamedKey?: Partial<experimental_StreamedKeyOptions<TInput>>;
|
|
202
|
+
/**
|
|
203
|
+
* Default options for experimental_streamedOptions utility
|
|
204
|
+
*
|
|
205
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options Tanstack Streamed Query Options Utility Docs}
|
|
206
|
+
*/
|
|
207
|
+
experimental_streamedOptions?: Partial<experimental_StreamedOptionsIn<TClientContext, TInput, experimental_StreamedQueryOutput<TOutput>, TError, unknown>>;
|
|
208
|
+
/**
|
|
209
|
+
* Default options for experimental_liveKey utility
|
|
210
|
+
*
|
|
211
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
212
|
+
*/
|
|
213
|
+
experimental_liveKey?: Partial<QueryKeyOptions<TInput>>;
|
|
214
|
+
/**
|
|
215
|
+
* Default options for experimental_liveOptions utility
|
|
216
|
+
*
|
|
217
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
|
|
218
|
+
*/
|
|
219
|
+
experimental_liveOptions?: Partial<experimental_StreamedOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, unknown>>;
|
|
220
|
+
/**
|
|
221
|
+
* Default options for infiniteKey utility
|
|
222
|
+
*
|
|
223
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
224
|
+
*/
|
|
225
|
+
infiniteKey?: Partial<Pick<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, InfiniteData<TOutput, unknown>, unknown>, 'input' | 'initialPageParam' | 'queryKey'>>;
|
|
226
|
+
/**
|
|
227
|
+
* Default options for infiniteOptions utility
|
|
228
|
+
*
|
|
229
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options Tanstack Infinite Query Options Utility Docs}
|
|
230
|
+
*/
|
|
231
|
+
infiniteOptions?: Partial<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>>;
|
|
232
|
+
/**
|
|
233
|
+
* Default options for mutationKey utility
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#query-mutation-key Tanstack Query/Mutation Key Docs}
|
|
236
|
+
*/
|
|
237
|
+
mutationKey?: Partial<Pick<MutationOptionsIn<TClientContext, TInput, TOutput, TError, any>, 'mutationKey'>>;
|
|
238
|
+
/**
|
|
239
|
+
* Default options for mutationOptions utility
|
|
240
|
+
*
|
|
241
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#mutation-options Tanstack Mutation Options Docs}
|
|
242
|
+
*/
|
|
243
|
+
mutationOptions?: Partial<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @todo remove default generic types on v2
|
|
247
|
+
*/
|
|
248
|
+
interface CreateProcedureUtilsOptions<TClientContext extends ClientContext = ClientContext, TInput = unknown, TOutput = unknown, TError = unknown> {
|
|
184
249
|
path: readonly string[];
|
|
250
|
+
experimental_defaults?: experimental_ProcedureUtilsDefaults<TClientContext, TInput, TOutput, TError>;
|
|
185
251
|
}
|
|
186
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
252
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
|
187
253
|
|
|
188
254
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
|
189
255
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
|
190
256
|
} & GeneralUtils<unknown>;
|
|
191
|
-
|
|
257
|
+
type experimental_RouterUtilsDefaults<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? experimental_ProcedureUtilsDefaults<UClientContext, UInput, UOutput, UError> : {
|
|
258
|
+
[K in keyof T]?: T[K] extends NestedClient<any> ? experimental_RouterUtilsDefaults<T[K]> : never;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* @todo remove default generic types on v2
|
|
262
|
+
*/
|
|
263
|
+
interface CreateRouterUtilsOptions<T extends NestedClient<any> = NestedClient<any>> {
|
|
192
264
|
path?: readonly string[];
|
|
265
|
+
experimental_defaults?: experimental_RouterUtilsDefaults<T>;
|
|
193
266
|
}
|
|
194
267
|
/**
|
|
195
268
|
* Create a router utils from a client.
|
|
196
269
|
*
|
|
197
270
|
* @info Both client-side and server-side clients are supported.
|
|
198
|
-
* @see {@link https://orpc.
|
|
271
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query Tanstack Query Integration}
|
|
199
272
|
*/
|
|
200
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
|
273
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions<T>): RouterUtils<T>;
|
|
201
274
|
|
|
202
275
|
export { OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createGeneralUtils, createProcedureUtils, createRouterUtils, createRouterUtils as createTanstackQueryUtils, experimental_serializableStreamedQuery, generateOperationKey };
|
|
203
|
-
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_LiveQueryOutput, experimental_SerializableStreamedQueryOptions, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
|
276
|
+
export type { CreateProcedureUtilsOptions, CreateRouterUtilsOptions, GeneralUtils, InfiniteOptionsBase, InfiniteOptionsIn, MutationOptions, MutationOptionsIn, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtils, QueryKeyOptions, QueryOptionsBase, QueryOptionsIn, RouterUtils, OperationContext as TanstackQueryOperationContext, experimental_LiveQueryOutput, experimental_ProcedureUtilsDefaults, experimental_RouterUtilsDefaults, experimental_SerializableStreamedQueryOptions, experimental_StreamedKeyOptions, experimental_StreamedOptionsBase, experimental_StreamedOptionsIn, experimental_StreamedQueryOutput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyJSON, isAsyncIteratorObject, toArray } from '@orpc/shared';
|
|
1
|
+
import { stringifyJSON, isAsyncIteratorObject, toArray, get } from '@orpc/shared';
|
|
2
2
|
import { skipToken } from '@tanstack/query-core';
|
|
3
3
|
|
|
4
4
|
function generateOperationKey(path, state = {}) {
|
|
@@ -40,44 +40,57 @@ function experimental_liveQuery(queryFn) {
|
|
|
40
40
|
function experimental_serializableStreamedQuery(queryFn, { refetchMode = "reset", maxChunks = Number.POSITIVE_INFINITY } = {}) {
|
|
41
41
|
return async (context) => {
|
|
42
42
|
const query = context.client.getQueryCache().find({ queryKey: context.queryKey, exact: true });
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const hasPreviousData = !!query && query.state.data !== void 0;
|
|
44
|
+
if (hasPreviousData) {
|
|
45
|
+
if (refetchMode === "reset") {
|
|
46
|
+
query.setState({
|
|
47
|
+
status: "pending",
|
|
48
|
+
data: void 0,
|
|
49
|
+
error: null,
|
|
50
|
+
fetchStatus: "fetching"
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
context.client.setQueryData(
|
|
54
|
+
context.queryKey,
|
|
55
|
+
(prev = []) => limitArraySize(prev, maxChunks)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
59
|
let result = [];
|
|
53
60
|
const stream = await queryFn(context);
|
|
61
|
+
const shouldUpdateCacheDuringStream = !hasPreviousData || refetchMode !== "replace";
|
|
62
|
+
context.client.setQueryData(
|
|
63
|
+
context.queryKey,
|
|
64
|
+
(prev = []) => limitArraySize(prev, maxChunks)
|
|
65
|
+
);
|
|
54
66
|
for await (const chunk of stream) {
|
|
55
67
|
if (context.signal.aborted) {
|
|
56
68
|
throw context.signal.reason;
|
|
57
69
|
}
|
|
58
|
-
|
|
70
|
+
result.push(chunk);
|
|
71
|
+
result = limitArraySize(result, maxChunks);
|
|
72
|
+
if (shouldUpdateCacheDuringStream) {
|
|
59
73
|
context.client.setQueryData(
|
|
60
74
|
context.queryKey,
|
|
61
|
-
(prev = []) =>
|
|
62
|
-
return addToEnd(prev, chunk, maxChunks);
|
|
63
|
-
}
|
|
75
|
+
(prev = []) => limitArraySize([...prev, chunk], maxChunks)
|
|
64
76
|
);
|
|
65
77
|
}
|
|
66
|
-
result = addToEnd(result, chunk, maxChunks);
|
|
67
78
|
}
|
|
68
|
-
if (
|
|
79
|
+
if (!shouldUpdateCacheDuringStream) {
|
|
69
80
|
context.client.setQueryData(context.queryKey, result);
|
|
70
81
|
}
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
82
|
+
const cachedData = context.client.getQueryData(context.queryKey);
|
|
83
|
+
if (cachedData) {
|
|
84
|
+
return limitArraySize(cachedData, maxChunks);
|
|
74
85
|
}
|
|
75
|
-
return
|
|
86
|
+
return result;
|
|
76
87
|
};
|
|
77
88
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
function limitArraySize(items, maxSize) {
|
|
90
|
+
if (items.length <= maxSize) {
|
|
91
|
+
return items;
|
|
92
|
+
}
|
|
93
|
+
return items.slice(items.length - maxSize);
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
const OPERATION_CONTEXT_SYMBOL = Symbol("ORPC_OPERATION_CONTEXT");
|
|
@@ -86,10 +99,12 @@ function createProcedureUtils(client, options) {
|
|
|
86
99
|
const utils = {
|
|
87
100
|
call: client,
|
|
88
101
|
queryKey(...[optionsIn = {}]) {
|
|
102
|
+
optionsIn = { ...options.experimental_defaults?.queryKey, ...optionsIn };
|
|
89
103
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "query", input: optionsIn.input });
|
|
90
104
|
return queryKey;
|
|
91
105
|
},
|
|
92
106
|
queryOptions(...[optionsIn = {}]) {
|
|
107
|
+
optionsIn = { ...options.experimental_defaults?.queryOptions, ...optionsIn };
|
|
93
108
|
const queryKey = utils.queryKey(optionsIn);
|
|
94
109
|
return {
|
|
95
110
|
queryFn: ({ signal }) => {
|
|
@@ -113,10 +128,12 @@ function createProcedureUtils(client, options) {
|
|
|
113
128
|
};
|
|
114
129
|
},
|
|
115
130
|
experimental_streamedKey(...[optionsIn = {}]) {
|
|
131
|
+
optionsIn = { ...options.experimental_defaults?.experimental_streamedKey, ...optionsIn };
|
|
116
132
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "streamed", input: optionsIn.input, fnOptions: optionsIn.queryFnOptions });
|
|
117
133
|
return queryKey;
|
|
118
134
|
},
|
|
119
135
|
experimental_streamedOptions(...[optionsIn = {}]) {
|
|
136
|
+
optionsIn = { ...options.experimental_defaults?.experimental_streamedOptions, ...optionsIn };
|
|
120
137
|
const queryKey = utils.experimental_streamedKey(optionsIn);
|
|
121
138
|
return {
|
|
122
139
|
queryFn: experimental_serializableStreamedQuery(
|
|
@@ -147,10 +164,12 @@ function createProcedureUtils(client, options) {
|
|
|
147
164
|
};
|
|
148
165
|
},
|
|
149
166
|
experimental_liveKey(...[optionsIn = {}]) {
|
|
167
|
+
optionsIn = { ...options.experimental_defaults?.experimental_liveKey, ...optionsIn };
|
|
150
168
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, { type: "live", input: optionsIn.input });
|
|
151
169
|
return queryKey;
|
|
152
170
|
},
|
|
153
171
|
experimental_liveOptions(...[optionsIn = {}]) {
|
|
172
|
+
optionsIn = { ...options.experimental_defaults?.experimental_liveOptions, ...optionsIn };
|
|
154
173
|
const queryKey = utils.experimental_liveKey(optionsIn);
|
|
155
174
|
return {
|
|
156
175
|
queryFn: experimental_liveQuery(async ({ signal }) => {
|
|
@@ -178,6 +197,7 @@ function createProcedureUtils(client, options) {
|
|
|
178
197
|
};
|
|
179
198
|
},
|
|
180
199
|
infiniteKey(optionsIn) {
|
|
200
|
+
optionsIn = { ...options.experimental_defaults?.infiniteKey, ...optionsIn };
|
|
181
201
|
const queryKey = optionsIn.queryKey ?? generateOperationKey(options.path, {
|
|
182
202
|
type: "infinite",
|
|
183
203
|
input: optionsIn.input === skipToken ? skipToken : optionsIn.input(optionsIn.initialPageParam)
|
|
@@ -185,6 +205,7 @@ function createProcedureUtils(client, options) {
|
|
|
185
205
|
return queryKey;
|
|
186
206
|
},
|
|
187
207
|
infiniteOptions(optionsIn) {
|
|
208
|
+
optionsIn = { ...options.experimental_defaults?.infiniteOptions, ...optionsIn };
|
|
188
209
|
const queryKey = utils.infiniteKey(optionsIn);
|
|
189
210
|
return {
|
|
190
211
|
queryFn: ({ pageParam, signal }) => {
|
|
@@ -208,10 +229,12 @@ function createProcedureUtils(client, options) {
|
|
|
208
229
|
};
|
|
209
230
|
},
|
|
210
231
|
mutationKey(...[optionsIn = {}]) {
|
|
232
|
+
optionsIn = { ...options.experimental_defaults?.mutationKey, ...optionsIn };
|
|
211
233
|
const mutationKey = optionsIn.mutationKey ?? generateOperationKey(options.path, { type: "mutation" });
|
|
212
234
|
return mutationKey;
|
|
213
235
|
},
|
|
214
236
|
mutationOptions(...[optionsIn = {}]) {
|
|
237
|
+
optionsIn = { ...options.experimental_defaults?.mutationOptions, ...optionsIn };
|
|
215
238
|
const mutationKey = utils.mutationKey(optionsIn);
|
|
216
239
|
return {
|
|
217
240
|
mutationFn: (input) => client(input, {
|
|
@@ -234,7 +257,10 @@ function createProcedureUtils(client, options) {
|
|
|
234
257
|
function createRouterUtils(client, options = {}) {
|
|
235
258
|
const path = toArray(options.path);
|
|
236
259
|
const generalUtils = createGeneralUtils(path);
|
|
237
|
-
const procedureUtils = createProcedureUtils(client, {
|
|
260
|
+
const procedureUtils = createProcedureUtils(client, {
|
|
261
|
+
path,
|
|
262
|
+
experimental_defaults: options.experimental_defaults
|
|
263
|
+
});
|
|
238
264
|
const recursive = new Proxy({
|
|
239
265
|
...generalUtils,
|
|
240
266
|
...procedureUtils
|
|
@@ -244,7 +270,11 @@ function createRouterUtils(client, options = {}) {
|
|
|
244
270
|
if (typeof prop !== "string") {
|
|
245
271
|
return value;
|
|
246
272
|
}
|
|
247
|
-
const nextUtils = createRouterUtils(client[prop], {
|
|
273
|
+
const nextUtils = createRouterUtils(client[prop], {
|
|
274
|
+
...options,
|
|
275
|
+
path: [...path, prop],
|
|
276
|
+
experimental_defaults: get(options.experimental_defaults, [prop])
|
|
277
|
+
});
|
|
248
278
|
if (typeof value !== "function") {
|
|
249
279
|
return nextUtils;
|
|
250
280
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.eaec0b2",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/middleapi/orpc.git",
|
|
10
10
|
"directory": "packages/tanstack-query"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
],
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@tanstack/query-core": ">=5.80.2",
|
|
28
|
-
"@orpc/client": "0.0.0-next.
|
|
28
|
+
"@orpc/client": "0.0.0-next.eaec0b2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@orpc/shared": "0.0.0-next.
|
|
31
|
+
"@orpc/shared": "0.0.0-next.eaec0b2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@angular/core": "^
|
|
35
|
-
"@tanstack/angular-query-experimental": "^5.90.
|
|
36
|
-
"@tanstack/query-core": "^5.90.
|
|
37
|
-
"@tanstack/react-query": "^5.90.
|
|
38
|
-
"@tanstack/solid-query": "^5.90.
|
|
39
|
-
"@tanstack/svelte-query": "^6.0.
|
|
40
|
-
"@tanstack/vue-query": "^5.
|
|
41
|
-
"svelte": "^5.
|
|
42
|
-
"vue": "^3.5.
|
|
43
|
-
"zod": "^4.
|
|
34
|
+
"@angular/core": "^21.1.0",
|
|
35
|
+
"@tanstack/angular-query-experimental": "^5.90.21",
|
|
36
|
+
"@tanstack/query-core": "^5.90.17",
|
|
37
|
+
"@tanstack/react-query": "^5.90.17",
|
|
38
|
+
"@tanstack/solid-query": "^5.90.20",
|
|
39
|
+
"@tanstack/svelte-query": "^6.0.15",
|
|
40
|
+
"@tanstack/vue-query": "^5.92.6",
|
|
41
|
+
"svelte": "^5.46.3",
|
|
42
|
+
"vue": "^3.5.26",
|
|
43
|
+
"zod": "^4.3.5"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "unbuild",
|