@orpc/tanstack-query 2.0.0-beta.5 → 2.0.0-beta.50
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 +137 -102
- package/dist/contract-utils.d.ts +35 -0
- package/dist/contract-utils.js +42 -0
- package/dist/index.d.ts +14 -374
- package/dist/index.js +8 -0
- package/dist/key.d.ts +41 -0
- package/dist/key.js +46 -0
- package/dist/live-query.js +30 -0
- package/dist/meta.d.ts +42 -0
- package/dist/meta.js +53 -0
- package/dist/plugin.d.ts +44 -0
- package/dist/plugin.js +19 -0
- package/dist/procedure-utils.d.ts +164 -0
- package/dist/procedure-utils.js +371 -0
- package/dist/router-utils.d.ts +62 -0
- package/dist/router-utils.js +54 -0
- package/dist/shared-utils.d.ts +11 -0
- package/dist/shared-utils.js +21 -0
- package/dist/ssr.d.ts +36 -0
- package/dist/ssr.js +47 -0
- package/dist/stream-query.d.ts +32 -0
- package/dist/stream-query.js +38 -0
- package/dist/structural-sharing.d.ts +14 -0
- package/dist/structural-sharing.js +105 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +9 -0
- package/package.json +45 -33
- package/dist/index.d.mts +0 -374
- package/dist/index.mjs +0 -533
package/dist/index.d.mts
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError, ThrowableError } from '@orpc/client';
|
|
2
|
-
import { AnySchema, ErrorMap, ProcedureContract, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap, RouterContractClient, RouterContract, ContractCaller } from '@orpc/contract';
|
|
3
|
-
import { JsonifiedValue, JsonifiedClientError, JsonifiedClient } from '@orpc/openapi';
|
|
4
|
-
import { Promisable, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, Public } from '@orpc/shared';
|
|
5
|
-
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, MutationFunctionContext } from '@tanstack/query-core';
|
|
6
|
-
|
|
7
|
-
interface SerializableStreamedQueryOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Determines how data is handled when the query is fetched again
|
|
10
|
-
*
|
|
11
|
-
* - `'reset'`: Clears existing data and returns the query to a pending state.
|
|
12
|
-
* - `'append'`: Adds new streamed chunks to the existing data.
|
|
13
|
-
* - `'replace'`: Buffers streamed data and replaces the cache after the stream completes.
|
|
14
|
-
*
|
|
15
|
-
* @default 'reset'
|
|
16
|
-
*/
|
|
17
|
-
refetchMode?: 'append' | 'reset' | 'replace';
|
|
18
|
-
/**
|
|
19
|
-
* Limits the number of data chunks stored in the query result.
|
|
20
|
-
* Older chunks are removed when the limit is reached.
|
|
21
|
-
*
|
|
22
|
-
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
23
|
-
*/
|
|
24
|
-
maxChunks?: number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A variant of `streamedQuery` where:
|
|
28
|
-
* - Options are serializable
|
|
29
|
-
* - The output is predictable
|
|
30
|
-
*/
|
|
31
|
-
declare function serializableStreamedQuery<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>(queryFn: (context: QueryFunctionContext<TQueryKey>) => Promisable<AsyncIterable<TQueryFnData>>, { refetchMode, maxChunks }?: SerializableStreamedQueryOptions): QueryFunction<TQueryFnData[], TQueryKey>;
|
|
32
|
-
|
|
33
|
-
type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
34
|
-
type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
35
|
-
type OperationType = 'query' | 'streamed' | 'live' | 'infinite' | 'mutation';
|
|
36
|
-
type OperationKeyOptions<TType extends OperationType, TInput> = {
|
|
37
|
-
type?: TType;
|
|
38
|
-
input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
|
|
39
|
-
fnOptions?: TType extends 'streamed' ? SerializableStreamedQueryOptions : never;
|
|
40
|
-
};
|
|
41
|
-
type OperationKey<TType extends OperationType, TInput> = [path: string[], options: OperationKeyOptions<TType, TInput>];
|
|
42
|
-
declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
43
|
-
interface OperationContext {
|
|
44
|
-
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
45
|
-
key: QueryKey;
|
|
46
|
-
type: OperationType;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
type QueryKeyOptions<TInput> = (undefined extends TInput ? {
|
|
50
|
-
input?: TInput | SkipToken;
|
|
51
|
-
} : {
|
|
52
|
-
input: TInput | SkipToken;
|
|
53
|
-
}) | {
|
|
54
|
-
queryKey: QueryKey;
|
|
55
|
-
};
|
|
56
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = (undefined extends TInput ? {
|
|
57
|
-
input?: TInput | SkipToken;
|
|
58
|
-
} : {
|
|
59
|
-
input: TInput | SkipToken;
|
|
60
|
-
}) & (object extends TClientContext ? {
|
|
61
|
-
context?: TClientContext;
|
|
62
|
-
} : {
|
|
63
|
-
context: TClientContext;
|
|
64
|
-
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey' | '_defaulted' | '_optimisticResults'> & {
|
|
65
|
-
queryKey?: QueryKey;
|
|
66
|
-
initialData?: TInitialData;
|
|
67
|
-
};
|
|
68
|
-
type QueryOptionsOut<TOutput, TError, TSelectData, TInitialData> = Pick<QueryObserverOptions<TOutput, TError, TSelectData, TOutput, DataTag<QueryKey, TOutput, TError>>, 'queryKey' | 'throwOnError' | 'select' | 'retryDelay'> & (undefined extends TInitialData ? object : {
|
|
69
|
-
initialData: TInitialData;
|
|
70
|
-
}) & {
|
|
71
|
-
queryFn: QueryFunction<TOutput, DataTag<QueryKey, TOutput, TError>>;
|
|
72
|
-
};
|
|
73
|
-
type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
74
|
-
input?: TInput | SkipToken;
|
|
75
|
-
} : {
|
|
76
|
-
input: TInput | SkipToken;
|
|
77
|
-
}) & {
|
|
78
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
79
|
-
}) | {
|
|
80
|
-
queryKey: QueryKey;
|
|
81
|
-
};
|
|
82
|
-
type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
|
|
83
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
84
|
-
};
|
|
85
|
-
type StreamedOptionsOut<TOutput, TError, TSelectData, TInitialData> = QueryOptionsOut<TOutput, TError, TSelectData, TInitialData>;
|
|
86
|
-
type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
87
|
-
queryKey: QueryKey;
|
|
88
|
-
};
|
|
89
|
-
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam, TInitialData> = {
|
|
90
|
-
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
91
|
-
initialData?: TInitialData;
|
|
92
|
-
queryKey?: QueryKey;
|
|
93
|
-
} & (object extends TClientContext ? {
|
|
94
|
-
context?: TClientContext;
|
|
95
|
-
} : {
|
|
96
|
-
context: TClientContext;
|
|
97
|
-
}) & Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | '_defaulted' | '_optimisticResults'>;
|
|
98
|
-
type InfiniteOptionsOut<TOutput, TError, TSelectData, TPageParam, TInitialData> = Pick<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>, TPageParam>, 'queryKey' | 'select' | 'throwOnError' | 'retryDelay' | 'initialPageParam' | 'getNextPageParam' | 'getPreviousPageParam'> & (undefined extends TInitialData ? object : {
|
|
99
|
-
initialData: TInitialData;
|
|
100
|
-
}) & {
|
|
101
|
-
queryFn: QueryFunction<TOutput, DataTag<QueryKey, InfiniteData<TOutput, TPageParam>, TError>, TPageParam>;
|
|
102
|
-
};
|
|
103
|
-
type MutationKeyOptions = Pick<MutationOptionsIn<any, any, any, any, any>, 'mutationKey'>;
|
|
104
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (object extends TClientContext ? {
|
|
105
|
-
context?: TClientContext;
|
|
106
|
-
} : {
|
|
107
|
-
context: TClientContext;
|
|
108
|
-
}) & MutationOptionsOut<TInput, TOutput, TError, TMutationContext>;
|
|
109
|
-
type MutationOptionsOut<TInput, TOutput, TError, TMutationContext> = MutationObserverOptions<TOutput, TError, TInput, TMutationContext>;
|
|
110
|
-
|
|
111
|
-
interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
|
|
112
|
-
path: string[];
|
|
113
|
-
context: TClientContext & OperationContext;
|
|
114
|
-
input: TInput | SkipToken;
|
|
115
|
-
fnContext: QueryFunctionContext;
|
|
116
|
-
}
|
|
117
|
-
type ProcedureUtilsQueryInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
118
|
-
interface ProcedureUtilsStreamedInterceptorOptions<TClientContext extends ClientContext, TInput> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
|
|
119
|
-
}
|
|
120
|
-
type ProcedureUtilsStreamedInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsStreamedInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferStreamedQueryOutput<TOutput>, TError>>;
|
|
121
|
-
interface ProcedureUtilsLiveInterceptorOptions<TClientContext extends ClientContext, TInput> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
|
|
122
|
-
}
|
|
123
|
-
type ProcedureUtilsLiveInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsLiveInterceptorOptions<TClientContext, TInput>, PromiseWithError<InferLiveQueryOutput<TOutput>, TError>>;
|
|
124
|
-
interface ProcedureUtilsInfiniteInterceptorOptions<TClientContext extends ClientContext, TInput> extends ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput> {
|
|
125
|
-
fnContext: QueryFunctionContext<QueryKey, any>;
|
|
126
|
-
}
|
|
127
|
-
type ProcedureUtilsInfiniteInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsInfiniteInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
128
|
-
interface ProcedureUtilsMutationInterceptorOptions<TClientContext extends ClientContext, TInput> extends Omit<ProcedureUtilsQueryInterceptorOptions<TClientContext, TInput>, 'input' | 'fnContext'> {
|
|
129
|
-
input: TInput;
|
|
130
|
-
fnContext: MutationFunctionContext;
|
|
131
|
-
}
|
|
132
|
-
type ProcedureUtilsMutationInterceptor<TClientContext extends ClientContext, TInput, TOutput, TError> = Interceptor<ProcedureUtilsMutationInterceptorOptions<TClientContext, TInput>, PromiseWithError<TOutput, TError>>;
|
|
133
|
-
/**
|
|
134
|
-
* Can be partial options for spread-merged options,
|
|
135
|
-
* or a function that receives per-call options and returns overridden this.options.
|
|
136
|
-
*/
|
|
137
|
-
type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
|
|
138
|
-
interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
139
|
-
/**
|
|
140
|
-
* Key options modifier for .queryKey and .queryOptions
|
|
141
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
142
|
-
*/
|
|
143
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>>;
|
|
144
|
-
/**
|
|
145
|
-
* Interceptors that intercept queryFn inside .queryOptions, guaranteed to be executed.
|
|
146
|
-
*/
|
|
147
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
148
|
-
/**
|
|
149
|
-
* Options modifier for .queryOptions
|
|
150
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
151
|
-
*/
|
|
152
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>>;
|
|
153
|
-
/**
|
|
154
|
-
* Key options modifier for .streamedKey and .streamedOptions
|
|
155
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
156
|
-
*/
|
|
157
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>>;
|
|
158
|
-
/**
|
|
159
|
-
* Interceptors that intercept queryFn inside .streamedOptions, guaranteed to be executed.
|
|
160
|
-
*/
|
|
161
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
162
|
-
/**
|
|
163
|
-
* Options modifier for .streamedOptions
|
|
164
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
165
|
-
*/
|
|
166
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>>;
|
|
167
|
-
/**
|
|
168
|
-
* Key options modifier for .liveKey and .liveOptions
|
|
169
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
170
|
-
*/
|
|
171
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>>;
|
|
172
|
-
/**
|
|
173
|
-
* Interceptors that intercept queryFn inside .liveOptions, guaranteed to be executed.
|
|
174
|
-
*/
|
|
175
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
176
|
-
/**
|
|
177
|
-
* Options modifier for .liveOptions
|
|
178
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
179
|
-
*/
|
|
180
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>>;
|
|
181
|
-
/**
|
|
182
|
-
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
183
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
184
|
-
*/
|
|
185
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>>;
|
|
186
|
-
/**
|
|
187
|
-
* Interceptors that intercept queryFn inside .infiniteOptions, guaranteed to be executed.
|
|
188
|
-
*/
|
|
189
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
190
|
-
/**
|
|
191
|
-
* Options modifier for .infiniteOptions
|
|
192
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
193
|
-
*/
|
|
194
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>>;
|
|
195
|
-
/**
|
|
196
|
-
* Key options modifier for .mutationKey and .mutationOptions
|
|
197
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
198
|
-
*/
|
|
199
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions>;
|
|
200
|
-
/**
|
|
201
|
-
* Interceptors that intercept mutationFn inside .mutationOptions, guaranteed to be executed.
|
|
202
|
-
*/
|
|
203
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
204
|
-
/**
|
|
205
|
-
* Options modifier for .mutationOptions
|
|
206
|
-
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
207
|
-
*/
|
|
208
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
|
|
209
|
-
}
|
|
210
|
-
declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
211
|
-
private readonly path;
|
|
212
|
-
private readonly options;
|
|
213
|
-
/**
|
|
214
|
-
* Calling corresponding procedure client
|
|
215
|
-
*/
|
|
216
|
-
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
217
|
-
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>);
|
|
218
|
-
/**
|
|
219
|
-
* Generate a **full matching** key for [Query Options](https://orpc.dev/docs/integrations/tanstack-query#query-options).
|
|
220
|
-
*/
|
|
221
|
-
queryKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, TOutput, TError>;
|
|
222
|
-
/**
|
|
223
|
-
* Generate options used for useQuery/useSuspenseQuery/prefetchQuery/...
|
|
224
|
-
*/
|
|
225
|
-
queryOptions<USelectData = TOutput, UInitialData = undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UInitialData>>): NoInfer<QueryOptionsOut<TOutput, TError, USelectData, UInitialData>>;
|
|
226
|
-
/**
|
|
227
|
-
* Generate a **full matching** key for [Streamed Query Options](https://orpc.dev/docs/integrations/tanstack-query#streamed-query-options).
|
|
228
|
-
*/
|
|
229
|
-
streamedKey(...rest: MaybeOptionalOptions<StreamedKeyOptions<TInput>>): DataTag<QueryKey, InferStreamedQueryOutput<TOutput>, TError>;
|
|
230
|
-
/**
|
|
231
|
-
* Configure queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
232
|
-
* This is built on [TanStack Query streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
|
|
233
|
-
* and works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
234
|
-
*/
|
|
235
|
-
streamedOptions<USelectData = InferStreamedQueryOutput<TOutput>, UInitialData = undefined>(...rest: MaybeOptionalOptions<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, USelectData, UInitialData>>): NoInfer<StreamedOptionsOut<InferStreamedQueryOutput<TOutput>, TError, USelectData, UInitialData>>;
|
|
236
|
-
/**
|
|
237
|
-
* Generate a **full matching** key for [Live Query Options](https://orpc.dev/docs/integrations/tanstack-query#live-query-options).
|
|
238
|
-
*/
|
|
239
|
-
liveKey(...rest: MaybeOptionalOptions<QueryKeyOptions<TInput>>): DataTag<QueryKey, InferLiveQueryOutput<TOutput>, TError>;
|
|
240
|
-
/**
|
|
241
|
-
* Configure live queries for [Event Iterator](https://orpc.dev/docs/event-iterator).
|
|
242
|
-
* Unlike `.streamedOptions` which accumulates chunks, live queries replace the entire result with each new chunk received.
|
|
243
|
-
* Works with hooks like `useQuery`, `useSuspenseQuery`, or `prefetchQuery`.
|
|
244
|
-
*/
|
|
245
|
-
liveOptions<USelectData = InferLiveQueryOutput<TOutput>, UInitialData = undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, USelectData, UInitialData>>): NoInfer<QueryOptionsOut<InferLiveQueryOutput<TOutput>, TError, USelectData, UInitialData>>;
|
|
246
|
-
/**
|
|
247
|
-
* Generate a **full matching** key for [Infinite Query Options](https://orpc.dev/docs/integrations/tanstack-query#infinite-query-options).
|
|
248
|
-
*/
|
|
249
|
-
infiniteKey<UPageParam>(optionsIn: InfiniteKeyOptions<TInput, UPageParam>): DataTag<QueryKey, InfiniteData<TOutput, UPageParam>, TError>;
|
|
250
|
-
/**
|
|
251
|
-
* Generate options used for useInfiniteQuery/useSuspenseInfiniteQuery/prefetchInfiniteQuery/...
|
|
252
|
-
*/
|
|
253
|
-
infiniteOptions<UPageParam, USelectData = InfiniteData<TOutput, UPageParam>, UInitialData = undefined>(optionsIn: InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, USelectData, UPageParam, UInitialData>): NoInfer<InfiniteOptionsOut<TOutput, TError, USelectData, UPageParam, UInitialData>>;
|
|
254
|
-
/**
|
|
255
|
-
* Generate a **full matching** key for [Mutation Options](https://orpc.dev/docs/integrations/tanstack-query#mutation-options).
|
|
256
|
-
*/
|
|
257
|
-
mutationKey(optionsIn?: MutationKeyOptions): DataTag<QueryKey, TOutput, TError>;
|
|
258
|
-
/**
|
|
259
|
-
* Generate options used for useMutation/...
|
|
260
|
-
*/
|
|
261
|
-
mutationOptions<UMutationContext>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptionsOut<TInput, TOutput, TError, UMutationContext>>;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
|
|
265
|
-
/**
|
|
266
|
-
* Initializes the router utils plugin and returns updated router utils options.
|
|
267
|
-
* Called once per plugin instance during composition.
|
|
268
|
-
*
|
|
269
|
-
* This method allows plugins to wrap, extend, or transform router utils options,
|
|
270
|
-
* such as interceptors or configuration.
|
|
271
|
-
*
|
|
272
|
-
* @param options - The current router utils options from previous plugins or base configuration
|
|
273
|
-
* @returns Transformed router utils options with this plugin's modifications applied
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```ts
|
|
277
|
-
* init(options) {
|
|
278
|
-
* return {
|
|
279
|
-
* ...options,
|
|
280
|
-
* mutationInterceptors: [...(options.mutationInterceptors ?? []), myInterceptor]
|
|
281
|
-
* }
|
|
282
|
-
* }
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
init?(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
|
|
286
|
-
/**
|
|
287
|
-
* Initializes per-procedure router utils options and returns updated options.
|
|
288
|
-
* Called once per procedure utils instance during composition.
|
|
289
|
-
*
|
|
290
|
-
* This method allows plugins to customize merged procedure-specific defaults,
|
|
291
|
-
* such as query or mutation options, for the current path.
|
|
292
|
-
*
|
|
293
|
-
* @param path - The current procedure path
|
|
294
|
-
* @param options - The merged procedure utils options for the current procedure
|
|
295
|
-
* @returns Transformed procedure utils options with this plugin's modifications applied
|
|
296
|
-
*/
|
|
297
|
-
initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
declare class SharedRouterUtils<TInput> {
|
|
301
|
-
private readonly path;
|
|
302
|
-
constructor(path: string[]);
|
|
303
|
-
/**
|
|
304
|
-
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
305
|
-
*/
|
|
306
|
-
key<TType extends OperationType>(options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
307
|
-
}
|
|
308
|
-
type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> & Public<SharedRouterUtils<UInput>> : {
|
|
309
|
-
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
310
|
-
} & Public<SharedRouterUtils<unknown>>;
|
|
311
|
-
type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
|
|
312
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
|
|
313
|
-
};
|
|
314
|
-
interface RouterUtilsOptions<T extends AnyNestedClient> {
|
|
315
|
-
/**
|
|
316
|
-
* Base path for all query keys. Use this to avoid conflicts when mounting
|
|
317
|
-
* multiple router utils instances.
|
|
318
|
-
*/
|
|
319
|
-
path?: string[] | undefined;
|
|
320
|
-
/**
|
|
321
|
-
* Interceptors that intercept queryFn inside .queryOptions
|
|
322
|
-
*/
|
|
323
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
324
|
-
/**
|
|
325
|
-
* Interceptors that intercept queryFn inside .streamedOptions
|
|
326
|
-
*/
|
|
327
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
328
|
-
/**
|
|
329
|
-
* Interceptors that intercept queryFn inside .liveOptions
|
|
330
|
-
*/
|
|
331
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
332
|
-
/**
|
|
333
|
-
* Interceptors that intercept queryFn inside .infiniteOptions
|
|
334
|
-
*/
|
|
335
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
336
|
-
/**
|
|
337
|
-
* Interceptors that intercept mutationFn inside .mutationOptions
|
|
338
|
-
*/
|
|
339
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
340
|
-
/**
|
|
341
|
-
* Per-procedure options following the shape of the router.
|
|
342
|
-
* Allows fine-grained configuration of individual procedure utils
|
|
343
|
-
* without affecting the rest of the router.
|
|
344
|
-
*/
|
|
345
|
-
scoped?: RouterUtilsScoped<T> | undefined;
|
|
346
|
-
/**
|
|
347
|
-
* Plugins to extend router utils behavior.
|
|
348
|
-
*/
|
|
349
|
-
plugins?: RouterUtilsPlugin<T>[] | undefined;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Create a router utils from a client.
|
|
353
|
-
*
|
|
354
|
-
* @info Both client-side and server-side clients are supported.
|
|
355
|
-
*/
|
|
356
|
-
declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: NoInfer<RouterUtilsOptions<T>>): RouterUtils<T>;
|
|
357
|
-
|
|
358
|
-
interface ContractUtilsFactory<TClientContext extends ClientContext> {
|
|
359
|
-
<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(procedure: ProcedureContract<TInputSchema, TOutputSchema, TErrorMap>): Public<SharedRouterUtils<InferSchemaInput<TInputSchema>>> & Public<ProcedureUtils<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>>;
|
|
360
|
-
}
|
|
361
|
-
interface ContractUtilsFactoryOptions<TClientContext extends ClientContext> extends RouterUtilsOptions<RouterContractClient<RouterContract, TClientContext>> {
|
|
362
|
-
}
|
|
363
|
-
declare function createContractUtilsFactory<TClientContext extends ClientContext>(caller: ContractCaller<TClientContext>, options: ContractUtilsFactoryOptions<TClientContext>): ContractUtilsFactory<TClientContext>;
|
|
364
|
-
interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
|
|
365
|
-
<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(procedure: ProcedureContract<TInputSchema, TOutputSchema, TErrorMap>): SharedRouterUtils<InferSchemaInput<TInputSchema>> & ProcedureUtils<TClientContext, InferSchemaInput<TInputSchema>, JsonifiedValue<InferSchemaOutput<TOutputSchema>>, JsonifiedClientError<ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>>;
|
|
366
|
-
}
|
|
367
|
-
interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>> {
|
|
368
|
-
}
|
|
369
|
-
declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(caller: ContractCaller<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
|
|
370
|
-
|
|
371
|
-
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], state?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
372
|
-
|
|
373
|
-
export { OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedRouterUtils, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey, serializableStreamedQuery };
|
|
374
|
-
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyOptions, OperationType, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, OperationContext as TanstackQueryOperationContext };
|