@orpc/tanstack-query 2.0.0-beta.44 → 2.0.0-beta.46

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 CHANGED
@@ -1,8 +1,10 @@
1
- import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
1
+ import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError, RPCJsonSerialization } from '@orpc/client';
2
+ export { AnyNestedClient } from '@orpc/client';
2
3
  import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
3
- import { JsonifiedClient } from '@orpc/openapi';
4
- import { Promisable, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, Public, ThrowableError } from '@orpc/shared';
5
- import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, MutationFunctionContext } from '@tanstack/query-core';
4
+ import { JsonifiedClient, ContractJsonifiedClientFactory } from '@orpc/openapi';
5
+ import { Public, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
6
+ export { Public } from '@orpc/shared';
7
+ import { SkipToken, QueryKey, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, QueryFunction, InfiniteData, QueryFunctionContext, MutationFunctionContext } from '@tanstack/query-core';
6
8
 
7
9
  interface SerializableStreamedQueryOptions {
8
10
  /**
@@ -14,21 +16,15 @@ interface SerializableStreamedQueryOptions {
14
16
  *
15
17
  * @default 'reset'
16
18
  */
17
- refetchMode?: 'append' | 'reset' | 'replace';
19
+ refetchMode?: 'append' | 'reset' | 'replace' | undefined;
18
20
  /**
19
21
  * Limits the number of data chunks stored in the query result.
20
22
  * Older chunks are removed when the limit is reached.
21
23
  *
22
24
  * @default Number.POSITIVE_INFINITY (unlimited)
23
25
  */
24
- maxChunks?: number;
26
+ maxChunks?: number | undefined;
25
27
  }
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
28
 
33
29
  type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
34
30
  type InferLiveQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
@@ -64,11 +60,11 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
64
60
  } : {
65
61
  input: TInput | SkipToken;
66
62
  }) & (object extends TClientContext ? {
67
- context?: TClientContext;
63
+ context?: TClientContext | undefined;
68
64
  } : {
69
65
  context: TClientContext;
70
66
  }) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey' | '_defaulted' | '_optimisticResults'> & {
71
- queryKey?: QueryKey;
67
+ queryKey?: QueryKey | undefined;
72
68
  initialData?: TInitialData;
73
69
  };
74
70
  type QueryOptionsOut<TOutput, TError, TSelectData, TInitialData> = Pick<QueryObserverOptions<TOutput, TError, TSelectData, TOutput, DataTag<QueryKey, TOutput, TError>>, 'queryKey' | 'throwOnError' | 'select' | 'retryDelay'> & (undefined extends TInitialData ? object : {
@@ -81,12 +77,12 @@ type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
81
77
  } : {
82
78
  input: TInput | SkipToken;
83
79
  }) & {
84
- queryFnOptions?: SerializableStreamedQueryOptions;
80
+ queryFnOptions?: SerializableStreamedQueryOptions | undefined;
85
81
  }) | {
86
82
  queryKey: QueryKey;
87
83
  };
88
84
  type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
89
- queryFnOptions?: SerializableStreamedQueryOptions;
85
+ queryFnOptions?: SerializableStreamedQueryOptions | undefined;
90
86
  };
91
87
  type StreamedOptionsOut<TOutput, TError, TSelectData, TInitialData> = QueryOptionsOut<TOutput, TError, TSelectData, TInitialData>;
92
88
  type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
@@ -95,9 +91,9 @@ type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput
95
91
  type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam, TInitialData> = {
96
92
  input: ((pageParam: TPageParam) => TInput) | SkipToken;
97
93
  initialData?: TInitialData;
98
- queryKey?: QueryKey;
94
+ queryKey?: QueryKey | undefined;
99
95
  } & (object extends TClientContext ? {
100
- context?: TClientContext;
96
+ context?: TClientContext | undefined;
101
97
  } : {
102
98
  context: TClientContext;
103
99
  }) & Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | '_defaulted' | '_optimisticResults'>;
@@ -108,7 +104,7 @@ type InfiniteOptionsOut<TOutput, TError, TSelectData, TPageParam, TInitialData>
108
104
  };
109
105
  type MutationKeyOptions = Pick<MutationOptionsIn<any, any, any, any, any>, 'mutationKey'>;
110
106
  type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (object extends TClientContext ? {
111
- context?: TClientContext;
107
+ context?: TClientContext | undefined;
112
108
  } : {
113
109
  context: TClientContext;
114
110
  }) & MutationOptionsOut<TInput, TOutput, TError, TMutationContext>;
@@ -119,31 +115,46 @@ interface OperationKeyPrefixOptions {
119
115
  * Prepended as the first element of the key when present.
120
116
  * Use this to avoid key conflicts when multiple router utils share the same client.
121
117
  */
122
- prefix?: string;
118
+ prefix?: string | undefined;
119
+ }
120
+ interface OperationKeyBaseOptions extends OperationKeyPrefixOptions {
121
+ /**
122
+ * Serializes inputs into JSON-compatible values when building keys,
123
+ * and compares custom types in structural sharing.
124
+ * Pass the serializer your link uses so custom types are supported.
125
+ *
126
+ * @default new RPCJsonSerializer()
127
+ */
128
+ serializer?: Public<RPCJsonSerializer> | undefined;
123
129
  }
124
- type OperationKeyOptions<TType extends OperationType, TInput> = OperationKeyPrefixOptions & {
125
- type?: TType;
126
- input?: TType extends 'mutation' ? never : PartialDeep<TInput>;
127
- fnOptions?: TType extends 'streamed' ? SerializableStreamedQueryOptions : never;
130
+ type OperationKeyOptions<TType extends OperationType, TInput> = OperationKeyBaseOptions & {
131
+ type?: TType | undefined;
132
+ input?: (TType extends 'mutation' ? never : PartialDeep<TInput>) | undefined;
133
+ fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
128
134
  };
129
- type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, 'prefix'> & {
135
+ type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions> & {
130
136
  /**
131
137
  * Set in place of `input` when the operation is disabled with `skipToken`,
132
138
  * because query key hashers drop symbols.
133
139
  */
134
140
  skipToken?: TType extends 'mutation' ? never : true;
141
+ /**
142
+ * Serializer types of non-JSON values in `input`, keyed by their JSON-encoded path,
143
+ * so inputs with the same JSON form (like a `Date` and its ISO string) produce different keys.
144
+ * Keyed by path (not a list) so partial keys still match.
145
+ */
146
+ inputMeta?: Record<string, string[]> | undefined;
135
147
  };
136
148
  type OperationKey<TType extends OperationType, TInput> = [path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>];
137
- declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
138
149
 
139
150
  declare class SharedUtils<TInput> {
140
151
  protected readonly path: string[];
141
- protected readonly options: OperationKeyPrefixOptions;
142
- constructor(path: string[], options: OperationKeyPrefixOptions);
152
+ protected readonly options: OperationKeyBaseOptions;
153
+ constructor(path: string[], options: OperationKeyBaseOptions);
143
154
  /**
144
155
  * Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
145
156
  */
146
- key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, 'prefix'>): OperationKey<TType, TInput>;
157
+ key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions>): OperationKey<TType, TInput>;
147
158
  }
148
159
 
149
160
  interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
@@ -173,79 +184,78 @@ type ProcedureUtilsMutationInterceptor<TClientContext extends ClientContext, TIn
173
184
  * or a function that receives per-call options and returns overridden this.options.
174
185
  */
175
186
  type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
176
- interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends OperationKeyPrefixOptions {
187
+ interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends OperationKeyBaseOptions {
177
188
  /**
178
189
  * Key options modifier for .queryKey and .queryOptions
179
190
  * Can be partial options or a function that receives per-call options and returns override this.options.
180
191
  */
181
- queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>>;
192
+ queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
182
193
  /**
183
194
  * Interceptors that intercept queryFn inside .queryOptions, guaranteed to be executed.
184
195
  */
185
- queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
196
+ queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
186
197
  /**
187
198
  * Options modifier for .queryOptions
188
199
  * Can be partial options or a function that receives per-call options and returns override this.options.
189
200
  */
190
- queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>>;
201
+ queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>> | undefined;
191
202
  /**
192
203
  * Key options modifier for .streamedKey and .streamedOptions
193
204
  * Can be partial options or a function that receives per-call options and returns override this.options.
194
205
  */
195
- streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>>;
206
+ streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
196
207
  /**
197
208
  * Interceptors that intercept queryFn inside .streamedOptions, guaranteed to be executed.
198
209
  */
199
- streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
210
+ streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
200
211
  /**
201
212
  * Options modifier for .streamedOptions
202
213
  * Can be partial options or a function that receives per-call options and returns override this.options.
203
214
  */
204
- streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>>;
215
+ streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
205
216
  /**
206
217
  * Key options modifier for .liveKey and .liveOptions
207
218
  * Can be partial options or a function that receives per-call options and returns override this.options.
208
219
  */
209
- liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>>;
220
+ liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
210
221
  /**
211
222
  * Interceptors that intercept queryFn inside .liveOptions, guaranteed to be executed.
212
223
  */
213
- liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
224
+ liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
214
225
  /**
215
226
  * Options modifier for .liveOptions
216
227
  * Can be partial options or a function that receives per-call options and returns override this.options.
217
228
  */
218
- liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>>;
229
+ liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
219
230
  /**
220
231
  * Key options modifier for .infiniteKey and .infiniteOptions
221
232
  * Can be partial options or a function that receives per-call options and returns override this.options.
222
233
  */
223
- infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>>;
234
+ infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
224
235
  /**
225
236
  * Interceptors that intercept queryFn inside .infiniteOptions, guaranteed to be executed.
226
237
  */
227
- infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
238
+ infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
228
239
  /**
229
240
  * Options modifier for .infiniteOptions
230
241
  * Can be partial options or a function that receives per-call options and returns override this.options.
231
242
  */
232
- infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>>;
243
+ infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>> | undefined;
233
244
  /**
234
245
  * Key options modifier for .mutationKey and .mutationOptions
235
246
  * Can be partial options or a function that receives per-call options and returns override this.options.
236
247
  */
237
- mutationKey?: ProcedureUtilsModifier<MutationKeyOptions>;
248
+ mutationKey?: ProcedureUtilsModifier<MutationKeyOptions> | undefined;
238
249
  /**
239
250
  * Interceptors that intercept mutationFn inside .mutationOptions, guaranteed to be executed.
240
251
  */
241
- mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
252
+ mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
242
253
  /**
243
254
  * Options modifier for .mutationOptions
244
255
  * Can be partial options or a function that receives per-call options and returns override this.options.
245
256
  */
246
- mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>>;
257
+ mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>> | undefined;
247
258
  }
248
- declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
249
259
  /**
250
260
  * Merge two procedure utils options where `override` takes priority.
251
261
  * A key explicitly set to `undefined` in `override` resets the base value.
@@ -347,13 +357,6 @@ interface RouterUtilsPlugin<T extends AnyNestedClient> extends OrderablePlugin {
347
357
  */
348
358
  initProcedureOptions?(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
349
359
  }
350
- declare class CompositeRouterUtilsPlugin<T extends AnyNestedClient> implements RouterUtilsPlugin<T> {
351
- protected readonly plugins: RouterUtilsPlugin<T>[];
352
- readonly name = "~composite";
353
- constructor(plugins?: RouterUtilsPlugin<T>[]);
354
- init(options: RouterUtilsOptions<T>): RouterUtilsOptions<T>;
355
- initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
356
- }
357
360
 
358
361
  /**
359
362
  * The utils shape derived from a client: procedure clients map to procedure
@@ -365,9 +368,9 @@ type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientCont
365
368
  [K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
366
369
  } & Public<SharedUtils<unknown>>;
367
370
  type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
368
- [K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
371
+ [K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
369
372
  };
370
- interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPrefixOptions {
373
+ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyBaseOptions {
371
374
  /**
372
375
  * Base path for all query keys.
373
376
  *
@@ -377,23 +380,23 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
377
380
  /**
378
381
  * Interceptors that intercept queryFn inside .queryOptions
379
382
  */
380
- queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
383
+ queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
381
384
  /**
382
385
  * Interceptors that intercept queryFn inside .streamedOptions
383
386
  */
384
- streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
387
+ streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
385
388
  /**
386
389
  * Interceptors that intercept queryFn inside .liveOptions
387
390
  */
388
- liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
391
+ liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
389
392
  /**
390
393
  * Interceptors that intercept queryFn inside .infiniteOptions
391
394
  */
392
- infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
395
+ infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
393
396
  /**
394
397
  * Interceptors that intercept mutationFn inside .mutationOptions
395
398
  */
396
- mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
399
+ mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
397
400
  /**
398
401
  * Per-procedure options following the shape of the router.
399
402
  * Allows fine-grained configuration of individual procedure utils
@@ -437,9 +440,20 @@ interface ContractJsonifiedUtilsFactory<TClientContext extends ClientContext> {
437
440
  }
438
441
  interface ContractJsonifiedUtilsFactoryOptions<TClientContext extends ClientContext> extends Omit<RouterUtilsOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'path'> {
439
442
  }
440
- declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
443
+ /**
444
+ * Like `createContractUtilsFactory`, but for clients whose types are wrapped in `JsonifiedClient`,
445
+ * such as clients using OpenAPI Link.
446
+ *
447
+ * @remarks
448
+ * Takes a client factory created by `createContractJsonifiedClientFactory` from `@orpc/openapi`.
449
+ *
450
+ * **Note**: The contract must define a `path` meta matching its position in the root router contract.
451
+ *
452
+ * @see {@link https://orpc.dev/docs/contract/client-factory#tanstack-query-integration | Contract Client Factory - TanStack Query Integration}
453
+ */
454
+ declare function createContractJsonifiedUtilsFactory<TClientContext extends ClientContext>(clientFactory: ContractJsonifiedClientFactory<TClientContext>, options: ContractJsonifiedUtilsFactoryOptions<TClientContext>): ContractJsonifiedUtilsFactory<TClientContext>;
441
455
 
442
- type TanstackQueryMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, 'prefix'>;
456
+ type TanstackQueryMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
443
457
  interface TanstackQueryMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
444
458
  name: '~tanstack-query';
445
459
  }
@@ -476,5 +490,52 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
476
490
  initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
477
491
  }
478
492
 
479
- export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey, getTanstackQueryMeta, isProcedureUtilsOptions, mergeProcedureUtilsOptions, serializableStreamedQuery, tanstackQuery };
480
- export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, TanstackQueryMetaOptions, TanstackQueryMetaPlugin, OperationContext as TanstackQueryOperationContext };
493
+ /**
494
+ * Creates `dehydrate` and `hydrate` query client defaults that preserve oRPC types.
495
+ *
496
+ * @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
497
+ */
498
+ declare function createHydrationOptions(serializer?: Public<RPCJsonSerializer>): {
499
+ dehydrate: {
500
+ serializeData: (data: unknown) => RPCJsonSerialization;
501
+ };
502
+ hydrate: {
503
+ deserializeData: (data: RPCJsonSerialization) => unknown;
504
+ };
505
+ };
506
+ interface StreamQuerySSRUtilsPluginOptions {
507
+ /**
508
+ * Whether utils run on the server, where streamed and live queries are cancelled once they have data.
509
+ * Defaults to `true` when there is no global `window`.
510
+ */
511
+ isServer?: boolean | undefined;
512
+ }
513
+ /**
514
+ * Router utils plugin for SSR of streamed and live queries. On the server, streamed queries are
515
+ * cancelled once they connect and live queries on their first event, keeping the data received so far;
516
+ * in the browser, they refetch on mount so streams reopen after hydration.
517
+ *
518
+ * @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-and-live-queries | TanStack Query Integration - Streamed and Live Queries}
519
+ */
520
+ declare class StreamQuerySSRUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
521
+ readonly name = "~stream-query-ssr";
522
+ private readonly isServer;
523
+ constructor(options?: StreamQuerySSRUtilsPluginOptions);
524
+ initProcedureOptions(_path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
525
+ }
526
+
527
+ type StructuralSharing = <T>(oldData: unknown, newData: T) => T;
528
+ /**
529
+ * Creates a `structuralSharing` function that works like TanStack Query's default, but also keeps
530
+ * the previous reference for equal `Date`, `URL`, `Map` and `Set` values, which oRPC's serializer
531
+ * recreates on every response, and for custom types that serialize the same with a type-aware
532
+ * serializer like `RPCJsonSerializer`.
533
+ *
534
+ * Used by default in `.queryOptions`, `.liveOptions` and `.infiniteOptions`, pass `structuralSharing: false` to opt out.
535
+ *
536
+ * @see {@link https://orpc.dev/docs/integrations/tanstack-query#structural-sharing | TanStack Query Integration - Structural Sharing}
537
+ */
538
+ declare function createStructuralSharing(serializer?: Public<RPCJsonSerializer>): StructuralSharing;
539
+
540
+ export { ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, StreamQuerySSRUtilsPlugin, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createHydrationOptions, createRouterUtils, createStructuralSharing, createRouterUtils as createTanstackQueryUtils, getTanstackQueryMeta, mergeProcedureUtilsOptions, tanstackQuery };
541
+ export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyBaseOptions, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamQuerySSRUtilsPluginOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, StructuralSharing, TanstackQueryMetaOptions, TanstackQueryMetaPlugin, OperationContext as TanstackQueryOperationContext };