@orpc/tanstack-query 2.0.0-beta.51 → 2.0.0-beta.53
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 +4 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/procedure-utils.d.ts +2 -2
- package/dist/procedure-utils.js +11 -11
- package/dist/router-utils.d.ts +12 -0
- package/dist/ssr.d.ts +10 -1
- package/dist/ssr.js +2 -1
- package/dist/structural-sharing.d.ts +8 -1
- package/dist/structural-sharing.js +2 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.js +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [
|
|
|
63
63
|
|
|
64
64
|
| Package | Purpose | Docs |
|
|
65
65
|
| -------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
66
|
-
| [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Contract
|
|
66
|
+
| [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Router Contract](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
|
|
67
67
|
| [@orpc/server](https://www.npmjs.com/package/@orpc/server) | Build APIs or implement contracts. | [Procedure](https://orpc.dev/docs/procedure), [Router](https://orpc.dev/docs/router), [Middleware](https://orpc.dev/docs/middleware), [Context](https://orpc.dev/docs/context), [RPC Handler](https://orpc.dev/docs/rpc/handler) |
|
|
68
68
|
| [@orpc/client](https://www.npmjs.com/package/@orpc/client) | Consume APIs with end-to-end type safety. | [Client-Side Clients](https://orpc.dev/docs/client/client-side), [Server-Side Clients](https://orpc.dev/docs/client/server-side), [RPC Link](https://orpc.dev/docs/rpc/link), [Error Handling](https://orpc.dev/docs/client/error-handling) |
|
|
69
69
|
| [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi) | Add OpenAPI compatibility to APIs. | [OpenAPI Handler](https://orpc.dev/docs/openapi/handler), [OpenAPI Link](https://orpc.dev/docs/openapi/link), [Specification](https://orpc.dev/docs/openapi/specification), [Scalar](https://orpc.dev/docs/openapi/scalar) |
|
|
@@ -183,25 +183,24 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
183
183
|
<td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&v=4" width="139" alt="Denis"/><br />Denis</a></td>
|
|
184
184
|
<td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
|
|
185
185
|
<td align="center"><a href="http://ballingt.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&v=4" width="139" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
|
|
186
|
-
<td align="center"><a href="https://lee-sam.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&v=4" width="139" alt="Sam"/><br />Sam</a></td>
|
|
187
186
|
<td align="center"><a href="https://github.com/Titoine?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&v=4" width="139" alt="Titoine"/><br />Titoine</a></td>
|
|
188
187
|
<td align="center"><a href="https://rigtch.fm/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&v=4" width="139" alt="Igor Makowski"/><br />Igor Makowski</a></td>
|
|
188
|
+
<td align="center"><a href="https://blog.cwang.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
|
|
189
189
|
</tr>
|
|
190
190
|
<tr>
|
|
191
|
-
<td align="center"><a href="https://blog.cwang.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
|
|
192
191
|
<td align="center"><a href="https://dubinets.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&v=4" width="139" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
|
|
193
192
|
<td align="center"><a href="https://kellychan.im/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
194
193
|
<td align="center"><a href="https://guyariely.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
195
194
|
<td align="center"><a href="https://paulsenon.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
196
195
|
<td align="center"><a href="https://usagerail.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="UsageRail"><img src="https://avatars.githubusercontent.com/u/347653714?v=4" width="139" alt="UsageRail"/><br />UsageRail</a></td>
|
|
196
|
+
<td align="center"><a href="https://piscis.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
197
197
|
</tr>
|
|
198
198
|
<tr>
|
|
199
|
-
<td align="center"><a href="https://piscis.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
200
199
|
<td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
201
200
|
</tr>
|
|
202
201
|
</table>
|
|
203
202
|
|
|
204
|
-
With thanks to [
|
|
203
|
+
With thanks to [41 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
205
204
|
|
|
206
205
|
## Open Source Programs
|
|
207
206
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ import { RouterUtilsPlugin } from "./plugin.js";
|
|
|
5
5
|
import { ProcedureUtils, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, mergeProcedureUtilsOptions } from "./procedure-utils.js";
|
|
6
6
|
import { RouterUtils, RouterUtilsInternal, RouterUtilsOptions, RouterUtilsScoped, RouterUtilsScopedInternal, createRouterUtils } from "./router-utils.js";
|
|
7
7
|
import { SharedUtils } from "./shared-utils.js";
|
|
8
|
-
import { StreamQuerySSRUtilsPlugin, StreamQuerySSRUtilsPluginOptions, createHydrationOptions } from "./ssr.js";
|
|
8
|
+
import { CreateHydrationOptionsOptions, StreamQuerySSRUtilsPlugin, StreamQuerySSRUtilsPluginOptions, createHydrationOptions } from "./ssr.js";
|
|
9
9
|
import { SerializableStreamedQueryOptions, SettleOnFirstDataOptions } from "./stream-query.js";
|
|
10
|
-
import { StructuralSharing, createStructuralSharing } from "./structural-sharing.js";
|
|
11
|
-
import { InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut,
|
|
10
|
+
import { CreateStructuralSharingOptions, StructuralSharing, createStructuralSharing } from "./structural-sharing.js";
|
|
11
|
+
import { InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut, OperationType, QueryKeyOptions, QueryOptionsIn, QueryOptionsInRest, QueryOptionsOut, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsInRest, StreamedOptionsOut, TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, TanstackQueryOperationContext } from "./types.js";
|
|
12
12
|
import { Public } from "@orpc/shared";
|
|
13
13
|
import { AnyNestedClient } from "@orpc/client";
|
|
14
|
-
export { type AnyNestedClient, ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractOptionsUtilsPlugin, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut, OPERATION_CONTEXT_SYMBOL, OperationContext, type OperationKey, type OperationKeyBaseOptions, type OperationKeyOptions, type OperationKeyPrefixOptions, OperationType, ProcedureUtils, type ProcedureUtilsInfiniteInterceptor, type ProcedureUtilsInfiniteInterceptorOptions, type ProcedureUtilsLiveInterceptor, type ProcedureUtilsLiveInterceptorOptions, type ProcedureUtilsModifier, type ProcedureUtilsMutationInterceptor, type ProcedureUtilsMutationInterceptorOptions, type ProcedureUtilsOptions, type ProcedureUtilsQueryInterceptor, type ProcedureUtilsQueryInterceptorOptions, type ProcedureUtilsStreamedInterceptor, type ProcedureUtilsStreamedInterceptorOptions, type Public, QueryKeyOptions, QueryOptionsIn, QueryOptionsInRest, QueryOptionsOut, RouterUtils, RouterUtilsInternal, RouterUtilsOptions, type RouterUtilsPlugin, RouterUtilsScoped, RouterUtilsScopedInternal, type SerializableStreamedQueryOptions, type SettleOnFirstDataOptions, SharedUtils, StreamQuerySSRUtilsPlugin, StreamQuerySSRUtilsPluginOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsInRest, StreamedOptionsOut, StructuralSharing,
|
|
14
|
+
export { type AnyNestedClient, ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractOptionsUtilsPlugin, ContractUtilsFactory, ContractUtilsFactoryOptions, CreateHydrationOptionsOptions, CreateStructuralSharingOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut, TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL as OPERATION_CONTEXT_SYMBOL, type TanstackQueryOperationContext as OperationContext, type OperationKey, type OperationKeyBaseOptions, type OperationKeyOptions, type OperationKeyPrefixOptions, OperationType, ProcedureUtils, type ProcedureUtilsInfiniteInterceptor, type ProcedureUtilsInfiniteInterceptorOptions, type ProcedureUtilsLiveInterceptor, type ProcedureUtilsLiveInterceptorOptions, type ProcedureUtilsModifier, type ProcedureUtilsMutationInterceptor, type ProcedureUtilsMutationInterceptorOptions, type ProcedureUtilsOptions, type ProcedureUtilsQueryInterceptor, type ProcedureUtilsQueryInterceptorOptions, type ProcedureUtilsStreamedInterceptor, type ProcedureUtilsStreamedInterceptorOptions, type Public, QueryKeyOptions, QueryOptionsIn, QueryOptionsInRest, QueryOptionsOut, RouterUtils, RouterUtilsInternal, RouterUtilsOptions, type RouterUtilsPlugin, RouterUtilsScoped, RouterUtilsScopedInternal, type SerializableStreamedQueryOptions, type SettleOnFirstDataOptions, SharedUtils, StreamQuerySSRUtilsPlugin, StreamQuerySSRUtilsPluginOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsInRest, StreamedOptionsOut, StructuralSharing, TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, TanstackQueryMetaOptions, TanstackQueryMetaPlugin, TanstackQueryOperationContext, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createHydrationOptions, createRouterUtils, createStructuralSharing, createRouterUtils as createTanstackQueryUtils, getTanstackQueryMeta, mergeProcedureUtilsOptions, tanstackQuery };
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { createRouterUtils, createRouterUtils as createTanstackQueryUtils } from
|
|
|
5
5
|
export { SharedUtils } from "./shared-utils.js";
|
|
6
6
|
export { StreamQuerySSRUtilsPlugin, createHydrationOptions } from "./ssr.js";
|
|
7
7
|
export { createStructuralSharing } from "./structural-sharing.js";
|
|
8
|
-
export { OPERATION_CONTEXT_SYMBOL,
|
|
8
|
+
export { TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL as OPERATION_CONTEXT_SYMBOL, TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL } from "./types.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OperationKeyBaseOptions } from "./key.js";
|
|
2
2
|
import { SharedUtils } from "./shared-utils.js";
|
|
3
|
-
import { InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut,
|
|
3
|
+
import { InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, LiveOptionsIn, LiveOptionsInRest, MutationKeyOptions, MutationOptionsIn, MutationOptionsInRest, MutationOptionsOut, QueryKeyOptions, QueryOptionsIn, QueryOptionsInRest, QueryOptionsOut, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsInRest, StreamedOptionsOut, TanstackQueryOperationContext } from "./types.js";
|
|
4
4
|
import { Interceptor, MaybeOptionalOptions, PromiseWithError } from "@orpc/shared";
|
|
5
5
|
import { Client, ClientContext } from "@orpc/client";
|
|
6
6
|
import { DataTag, InfiniteData, MutationFunctionContext, QueryFunctionContext, QueryKey, SkipToken } from "@tanstack/query-core";
|
|
7
7
|
export interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
|
|
8
8
|
path: string[];
|
|
9
|
-
context: TClientContext &
|
|
9
|
+
context: TClientContext & TanstackQueryOperationContext;
|
|
10
10
|
input: TInput | SkipToken;
|
|
11
11
|
fnContext: QueryFunctionContext;
|
|
12
12
|
}
|
package/dist/procedure-utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { liveQuery } from "./live-query.js";
|
|
|
2
2
|
import { SharedUtils } from "./shared-utils.js";
|
|
3
3
|
import { serializableStreamedQuery } from "./stream-query.js";
|
|
4
4
|
import { createStructuralSharing } from "./structural-sharing.js";
|
|
5
|
-
import {
|
|
5
|
+
import { TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL } from "./types.js";
|
|
6
6
|
import { intercept, isAsyncIteratorObject, isNonPrimitive, resolveMaybeOptionalOptions, toArray } from "@orpc/shared";
|
|
7
7
|
import { skipToken } from "@tanstack/query-core";
|
|
8
8
|
// src/procedure-utils.ts
|
|
@@ -121,14 +121,14 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
121
121
|
};
|
|
122
122
|
const queryKey = this.queryKey(optionsIn);
|
|
123
123
|
return {
|
|
124
|
-
structuralSharing: createStructuralSharing(this.options.serializer),
|
|
124
|
+
structuralSharing: createStructuralSharing({ serializer: this.options.serializer }),
|
|
125
125
|
...optionsIn,
|
|
126
126
|
queryKey,
|
|
127
127
|
queryFn: (fnContext) => {
|
|
128
128
|
return intercept(this.options.queryInterceptors, {
|
|
129
129
|
path: this.path,
|
|
130
130
|
context: {
|
|
131
|
-
[
|
|
131
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]: {
|
|
132
132
|
key: queryKey,
|
|
133
133
|
type: "query"
|
|
134
134
|
},
|
|
@@ -161,7 +161,7 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
161
161
|
return optionsIn.queryKey ?? this.key({
|
|
162
162
|
type: "streamed",
|
|
163
163
|
input: optionsIn.input,
|
|
164
|
-
fnOptions: optionsIn.
|
|
164
|
+
fnOptions: optionsIn.fnOptions
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -186,7 +186,7 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
186
186
|
return intercept(toArray(this.options.streamedInterceptors), {
|
|
187
187
|
path: this.path,
|
|
188
188
|
context: {
|
|
189
|
-
[
|
|
189
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]: {
|
|
190
190
|
key: queryKey,
|
|
191
191
|
type: "streamed"
|
|
192
192
|
},
|
|
@@ -205,7 +205,7 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
205
205
|
if (!isAsyncIteratorObject(output)) throw new Error("streamedQuery requires an AsyncIteratorObject output");
|
|
206
206
|
return output;
|
|
207
207
|
}, {
|
|
208
|
-
...optionsIn.
|
|
208
|
+
...optionsIn.fnOptions,
|
|
209
209
|
settleOnFirstData
|
|
210
210
|
})(fnContext);
|
|
211
211
|
});
|
|
@@ -243,14 +243,14 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
243
243
|
const queryKey = this.liveKey(optionsIn);
|
|
244
244
|
const { settleOnFirstData, ...queryOptions } = optionsIn;
|
|
245
245
|
return {
|
|
246
|
-
structuralSharing: createStructuralSharing(this.options.serializer),
|
|
246
|
+
structuralSharing: createStructuralSharing({ serializer: this.options.serializer }),
|
|
247
247
|
...queryOptions,
|
|
248
248
|
queryKey,
|
|
249
249
|
queryFn: (fnContext) => {
|
|
250
250
|
return intercept(toArray(this.options.liveInterceptors), {
|
|
251
251
|
path: this.path,
|
|
252
252
|
context: {
|
|
253
|
-
[
|
|
253
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]: {
|
|
254
254
|
key: queryKey,
|
|
255
255
|
type: "live"
|
|
256
256
|
},
|
|
@@ -299,14 +299,14 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
299
299
|
};
|
|
300
300
|
const queryKey = this.infiniteKey(optionsIn);
|
|
301
301
|
return {
|
|
302
|
-
structuralSharing: createStructuralSharing(this.options.serializer),
|
|
302
|
+
structuralSharing: createStructuralSharing({ serializer: this.options.serializer }),
|
|
303
303
|
...optionsIn,
|
|
304
304
|
queryKey,
|
|
305
305
|
queryFn: (fnContext) => {
|
|
306
306
|
return intercept(toArray(this.options.infiniteInterceptors), {
|
|
307
307
|
path: this.path,
|
|
308
308
|
context: {
|
|
309
|
-
[
|
|
309
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]: {
|
|
310
310
|
key: queryKey,
|
|
311
311
|
type: "infinite"
|
|
312
312
|
},
|
|
@@ -355,7 +355,7 @@ var ProcedureUtils = class extends SharedUtils {
|
|
|
355
355
|
return intercept(toArray(this.options.mutationInterceptors), {
|
|
356
356
|
path: this.path,
|
|
357
357
|
context: {
|
|
358
|
-
[
|
|
358
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]: {
|
|
359
359
|
key: mutationKey,
|
|
360
360
|
type: "mutation"
|
|
361
361
|
},
|
package/dist/router-utils.d.ts
CHANGED
|
@@ -11,8 +11,20 @@ import { AnyNestedClient, Client, InferClientContext, InferClientError } from "@
|
|
|
11
11
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query | TanStack Query Integration}
|
|
12
12
|
*/
|
|
13
13
|
export type RouterUtils<T extends AnyNestedClient> = RouterUtilsInternal<T>;
|
|
14
|
+
/**
|
|
15
|
+
* The recursion behind {@link RouterUtils}. Exported only so TypeScript can name it
|
|
16
|
+
* in declarations emitted for generic code, do not use it directly.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
14
20
|
export type RouterUtilsInternal<T> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : { [K in keyof T]: RouterUtilsInternal<T[K] & {}>; } & Public<SharedUtils<unknown>>;
|
|
15
21
|
export type RouterUtilsScoped<T extends AnyNestedClient> = RouterUtilsScopedInternal<T>;
|
|
22
|
+
/**
|
|
23
|
+
* The recursion behind {@link RouterUtilsScoped}. Exported only so TypeScript can name it
|
|
24
|
+
* in declarations emitted for generic code, do not use it directly.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
16
28
|
export type RouterUtilsScopedInternal<T> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : { [K in keyof T]?: RouterUtilsScopedInternal<T[K] & {}> | undefined; };
|
|
17
29
|
export interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyBaseOptions {
|
|
18
30
|
/**
|
package/dist/ssr.d.ts
CHANGED
|
@@ -2,12 +2,21 @@ import { RouterUtilsPlugin } from "./plugin.js";
|
|
|
2
2
|
import { ProcedureUtilsOptions } from "./procedure-utils.js";
|
|
3
3
|
import { Public } from "@orpc/shared";
|
|
4
4
|
import { AnyNestedClient, InferClientContext, InferClientError, RPCJsonSerialization, RPCJsonSerializer } from "@orpc/client";
|
|
5
|
+
export interface CreateHydrationOptionsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Serializes query data when dehydrating, and deserializes it when hydrating.
|
|
8
|
+
* Pass the serializer your link uses so custom types are supported.
|
|
9
|
+
*
|
|
10
|
+
* @default new RPCJsonSerializer()
|
|
11
|
+
*/
|
|
12
|
+
serializer?: Public<RPCJsonSerializer> | undefined;
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
15
|
* Creates `dehydrate` and `hydrate` query client defaults that preserve oRPC types.
|
|
7
16
|
*
|
|
8
17
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
9
18
|
*/
|
|
10
|
-
export declare function createHydrationOptions(
|
|
19
|
+
export declare function createHydrationOptions(options?: CreateHydrationOptionsOptions): {
|
|
11
20
|
dehydrate: {
|
|
12
21
|
serializeData: (data: unknown) => RPCJsonSerialization;
|
|
13
22
|
};
|
package/dist/ssr.js
CHANGED
|
@@ -7,7 +7,8 @@ import { environmentManager } from "@tanstack/query-core";
|
|
|
7
7
|
*
|
|
8
8
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
9
9
|
*/
|
|
10
|
-
function createHydrationOptions(
|
|
10
|
+
function createHydrationOptions(options = {}) {
|
|
11
|
+
const serializer = options.serializer ?? new RPCJsonSerializer();
|
|
11
12
|
return {
|
|
12
13
|
dehydrate: { serializeData(data) {
|
|
13
14
|
const { json, meta } = serializer.serializeJson(data);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Public } from "@orpc/shared";
|
|
2
2
|
import { RPCJsonSerializer } from "@orpc/client";
|
|
3
3
|
export type StructuralSharing = <T>(oldData: unknown, newData: T) => T;
|
|
4
|
+
export interface CreateStructuralSharingOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Compares custom types by what their handler serializes them to.
|
|
7
|
+
* Without it, only the built-in types are compared.
|
|
8
|
+
*/
|
|
9
|
+
serializer?: Public<RPCJsonSerializer> | undefined;
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
12
|
* Creates a `structuralSharing` function that works like TanStack Query's default, but also keeps
|
|
6
13
|
* the previous reference for equal `Date`, `URL`, `Map` and `Set` values, which oRPC's serializer
|
|
@@ -11,4 +18,4 @@ export type StructuralSharing = <T>(oldData: unknown, newData: T) => T;
|
|
|
11
18
|
*
|
|
12
19
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#structural-sharing | TanStack Query Integration - Structural Sharing}
|
|
13
20
|
*/
|
|
14
|
-
export declare function createStructuralSharing(
|
|
21
|
+
export declare function createStructuralSharing(options?: CreateStructuralSharingOptions): StructuralSharing;
|
|
@@ -10,7 +10,8 @@ import { setOwn, stringifyJSON } from "@orpc/shared";
|
|
|
10
10
|
*
|
|
11
11
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#structural-sharing | TanStack Query Integration - Structural Sharing}
|
|
12
12
|
*/
|
|
13
|
-
function createStructuralSharing(
|
|
13
|
+
function createStructuralSharing(options = {}) {
|
|
14
|
+
const serializer = options.serializer;
|
|
14
15
|
return (oldData, newData) => replaceEqualDeep(oldData, newData, 0, serializer);
|
|
15
16
|
}
|
|
16
17
|
function replaceEqualDeep(a, b, depth, serializer) {
|
package/dist/types.d.ts
CHANGED
|
@@ -10,15 +10,15 @@ export type OperationType = "query" | "streamed" | "live" | "infinite" | "mutati
|
|
|
10
10
|
*
|
|
11
11
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
14
14
|
/**
|
|
15
15
|
* A client context automatically populated by TanStack Query utils,
|
|
16
16
|
* exposing the operation key and type of the calling operation.
|
|
17
17
|
*
|
|
18
18
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
19
19
|
*/
|
|
20
|
-
export interface
|
|
21
|
-
[
|
|
20
|
+
export interface TanstackQueryOperationContext {
|
|
21
|
+
[TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL]?: {
|
|
22
22
|
key: QueryKey;
|
|
23
23
|
type: OperationType;
|
|
24
24
|
};
|
|
@@ -57,12 +57,12 @@ export type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
|
57
57
|
} : {
|
|
58
58
|
input: TInput | SkipToken;
|
|
59
59
|
}) & {
|
|
60
|
-
|
|
60
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
61
61
|
}) | {
|
|
62
62
|
queryKey: QueryKey;
|
|
63
63
|
};
|
|
64
64
|
export type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
|
|
65
|
-
|
|
65
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
66
66
|
} & SettleOnFirstDataOptions;
|
|
67
67
|
/**
|
|
68
68
|
* Rest parameters of `.streamedOptions`: optional when input and context are.
|
package/dist/types.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#client-context | TanStack Query Integration - Client Context}
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
9
|
-
export {
|
|
8
|
+
const TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL = /* @__PURE__ */ Symbol.for("ORPC_TANSTACK_QUERY_OPERATION_CONTEXT");
|
|
9
|
+
export { TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.53",
|
|
4
4
|
"description": "TanStack Query integration for oRPC: typesafe queries, mutations, streaming, and SSR for React, Vue, Solid, Svelte, and Angular",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular-query",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@orpc/client": "2.0.0-beta.
|
|
45
|
-
"@orpc/contract": "2.0.0-beta.
|
|
46
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
47
|
-
"@orpc/shared": "2.0.0-beta.
|
|
44
|
+
"@orpc/client": "2.0.0-beta.53",
|
|
45
|
+
"@orpc/contract": "2.0.0-beta.53",
|
|
46
|
+
"@orpc/openapi": "2.0.0-beta.53",
|
|
47
|
+
"@orpc/shared": "2.0.0-beta.53"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@angular/core": "^22.2.4",
|