@orpc/tanstack-query 2.0.0-beta.43 → 2.0.0-beta.45
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 +56 -57
- package/dist/index.d.mts +90 -43
- package/dist/index.d.ts +90 -43
- package/dist/index.mjs +72 -13
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
18
18
|
</a>
|
|
19
19
|
<a href="https://deepwiki.com/middleapi/orpc">
|
|
20
|
-
<img src="https://
|
|
20
|
+
<img alt="Ask DeepWiki" src="https://img.shields.io/badge/Ask-DeepWiki-blue" />
|
|
21
21
|
</a>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
@@ -60,10 +60,11 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
60
60
|
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
61
61
|
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
|
|
62
62
|
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
|
|
63
|
+
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp) | Expose procedures as [MCP](https://modelcontextprotocol.io/) tools. | [MCP](https://orpc.dev/docs/integrations/mcp) |
|
|
63
64
|
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
|
|
64
65
|
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
|
|
65
66
|
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
66
|
-
| [@orpc/
|
|
67
|
+
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
67
68
|
| [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
68
69
|
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
69
70
|
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
|
|
@@ -95,27 +96,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
95
96
|
</tr>
|
|
96
97
|
</table>
|
|
97
98
|
|
|
98
|
-
### Special Sponsors
|
|
99
|
-
|
|
100
|
-
<table>
|
|
101
|
-
<tr>
|
|
102
|
-
<td align="center"><a href="http://twitter.com/rauchg?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guillermo Rauch"><img src="https://avatars.githubusercontent.com/u/13041?u=1ee8d111657cdd02ff6d253df00978d17ee6d722&v=4" width="279" alt="Guillermo Rauch"/><br />Guillermo Rauch</a></td>
|
|
103
|
-
</tr>
|
|
104
|
-
</table>
|
|
105
|
-
|
|
106
|
-
### Premium Sponsors
|
|
107
|
-
|
|
108
|
-
<table>
|
|
109
|
-
<tr>
|
|
110
|
-
<td align="center"><a href="https://github.com/nexa-ca?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nexa"><img src="https://avatars.githubusercontent.com/u/199146462?v=4" width="209" alt="Nexa"/><br />Nexa</a></td>
|
|
111
|
-
</tr>
|
|
112
|
-
</table>
|
|
113
|
-
|
|
114
99
|
### Organization Sponsors
|
|
115
100
|
|
|
116
101
|
<table>
|
|
117
102
|
<tr>
|
|
118
|
-
<td align="center"><a href="https://lnmarkets.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="
|
|
103
|
+
<td align="center"><a href="https://lnmarkets.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="209" alt="LN Markets"/><br />LN Markets</a></td>
|
|
119
104
|
</tr>
|
|
120
105
|
</table>
|
|
121
106
|
|
|
@@ -123,27 +108,29 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
123
108
|
|
|
124
109
|
<table>
|
|
125
110
|
<tr>
|
|
126
|
-
<td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="
|
|
127
|
-
<td align="center"><a href="https://soymilk.party/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&v=4" width="
|
|
128
|
-
<td align="center"><a href="https://github.com/nicognaW?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&v=4" width="
|
|
129
|
-
<td align="center"><a href="https://supastarter.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="
|
|
130
|
-
<td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&v=4" width="
|
|
131
|
-
<td align="center"><a href="https://laststance.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&v=4" width="139" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
|
|
111
|
+
<td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="167" alt="Reece McDonald"/><br />Reece McDonald</a></td>
|
|
112
|
+
<td align="center"><a href="https://soymilk.party/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&v=4" width="167" alt="あわわわとーにゅ"/><br />あわわわとーにゅ</a></td>
|
|
113
|
+
<td align="center"><a href="https://github.com/nicognaW?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&v=4" width="167" alt="nk"/><br />nk</a></td>
|
|
114
|
+
<td align="center"><a href="https://supastarter.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="167" alt="supastarter"/><br />supastarter</a></td>
|
|
115
|
+
<td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&v=4" width="167" alt="herrfugbaum"/><br />herrfugbaum</a></td>
|
|
132
116
|
</tr>
|
|
133
117
|
<tr>
|
|
134
|
-
<td align="center"><a href="https://
|
|
135
|
-
<td align="center"><a href="https://
|
|
136
|
-
<td align="center"><a href="https://
|
|
137
|
-
<td align="center"><a href="https://
|
|
138
|
-
<td align="center"><a href="https://
|
|
139
|
-
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
118
|
+
<td align="center"><a href="https://laststance.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&v=4" width="167" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
|
|
119
|
+
<td align="center"><a href="https://cra.mr/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Cramer"><img src="https://avatars.githubusercontent.com/u/23610?v=4" width="167" alt="David Cramer"/><br />David Cramer</a></td>
|
|
120
|
+
<td align="center"><a href="https://valerii15298.github.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&v=4" width="167" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
|
|
121
|
+
<td align="center"><a href="https://letstri.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&v=4" width="167" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
|
|
122
|
+
<td align="center"><a href="https://blacklight.sh/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&v=4" width="167" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
|
|
140
123
|
</tr>
|
|
141
124
|
<tr>
|
|
142
|
-
<td align="center"><a href="https://github.com/
|
|
143
|
-
<td align="center"><a href="https://github.com/
|
|
144
|
-
<td align="center"><a href="https://github.com/
|
|
145
|
-
<td align="center"><a href="https://
|
|
146
|
-
<td align="center"><a href="https://
|
|
125
|
+
<td align="center"><a href="https://github.com/christ12938?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
|
|
126
|
+
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
127
|
+
<td align="center"><a href="https://github.com/itigoore01?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="167" alt="shota"/><br />shota</a></td>
|
|
128
|
+
<td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
129
|
+
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
133
|
+
<td align="center"><a href="https://automatio.ai/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
147
134
|
</tr>
|
|
148
135
|
</table>
|
|
149
136
|
|
|
@@ -151,34 +138,46 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
151
138
|
|
|
152
139
|
<table>
|
|
153
140
|
<tr>
|
|
154
|
-
<td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&v=4" width="
|
|
155
|
-
<td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&v=4" width="
|
|
156
|
-
<td align="center"><a href="https://robbevaes.be/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&v=4" width="
|
|
157
|
-
<td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="
|
|
158
|
-
<td align="center"><a href="https://github.com/soonoo?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&v=4" width="
|
|
159
|
-
<td align="center"><a href="https://kevinporten.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&v=4" width="
|
|
160
|
-
|
|
141
|
+
<td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&v=4" width="139" alt="David Walsh"/><br />David Walsh</a></td>
|
|
142
|
+
<td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&v=4" width="139" alt="IPv4Addr"/><br />IPv4Addr</a></td>
|
|
143
|
+
<td align="center"><a href="https://robbevaes.be/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&v=4" width="139" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
|
|
144
|
+
<td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="139" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
|
|
145
|
+
<td align="center"><a href="https://github.com/soonoo?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&v=4" width="139" alt="soonoo"/><br />soonoo</a></td>
|
|
146
|
+
<td align="center"><a href="https://kevinporten.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&v=4" width="139" alt="Kevin Porten"/><br />Kevin Porten</a></td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<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>
|
|
150
|
+
<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>
|
|
151
|
+
<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>
|
|
152
|
+
<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>
|
|
153
|
+
<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>
|
|
154
|
+
<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>
|
|
161
155
|
</tr>
|
|
162
156
|
<tr>
|
|
163
|
-
<td align="center"><a href="https://
|
|
164
|
-
<td align="center"><a href="
|
|
165
|
-
<td align="center"><a href="https://
|
|
166
|
-
<td align="center"><a href="https://
|
|
167
|
-
<td align="center"><a href="https://
|
|
168
|
-
<td align="center"><a href="https://
|
|
169
|
-
<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="119" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
|
|
157
|
+
<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>
|
|
158
|
+
<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>
|
|
159
|
+
<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>
|
|
160
|
+
<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>
|
|
161
|
+
<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>
|
|
162
|
+
<td align="center"><a href="https://nakasyou.how/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&v=4" width="139" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
|
|
170
163
|
</tr>
|
|
171
164
|
<tr>
|
|
172
|
-
<td align="center"><a href="https://
|
|
173
|
-
<td align="center"><a href="https://
|
|
174
|
-
<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="119" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
175
|
-
<td align="center"><a href="https://nakasyou.how/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&v=4" width="119" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
|
|
176
|
-
<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="119" alt="Alex"/><br />Alex</a></td>
|
|
177
|
-
<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="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
165
|
+
<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>
|
|
166
|
+
<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>
|
|
178
167
|
</tr>
|
|
179
168
|
</table>
|
|
180
169
|
|
|
181
|
-
With thanks to [
|
|
170
|
+
With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
171
|
+
|
|
172
|
+
## Open Source Programs
|
|
173
|
+
|
|
174
|
+
[middleapi](https://github.com/middleapi) is supported by these open source programs:
|
|
175
|
+
|
|
176
|
+
<table>
|
|
177
|
+
<tr>
|
|
178
|
+
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude for Open Source</a></td>
|
|
179
|
+
</tr>
|
|
180
|
+
</table>
|
|
182
181
|
|
|
183
182
|
## References
|
|
184
183
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
1
|
+
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError, RPCJsonSerialization } from '@orpc/client';
|
|
2
2
|
import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
3
3
|
import { JsonifiedClient } from '@orpc/openapi';
|
|
4
|
-
import { Promisable, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin,
|
|
5
|
-
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, MutationFunctionContext } from '@tanstack/query-core';
|
|
4
|
+
import { Promisable, PartialDeep, Public, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
|
|
5
|
+
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, QueryKeyHashFunction, MutationFunctionContext } from '@tanstack/query-core';
|
|
6
6
|
|
|
7
7
|
interface SerializableStreamedQueryOptions {
|
|
8
8
|
/**
|
|
@@ -14,14 +14,14 @@ interface SerializableStreamedQueryOptions {
|
|
|
14
14
|
*
|
|
15
15
|
* @default 'reset'
|
|
16
16
|
*/
|
|
17
|
-
refetchMode?: 'append' | 'reset' | 'replace';
|
|
17
|
+
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Limits the number of data chunks stored in the query result.
|
|
20
20
|
* Older chunks are removed when the limit is reached.
|
|
21
21
|
*
|
|
22
22
|
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
23
23
|
*/
|
|
24
|
-
maxChunks?: number;
|
|
24
|
+
maxChunks?: number | undefined;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* A variant of `streamedQuery` where:
|
|
@@ -64,11 +64,11 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
64
64
|
} : {
|
|
65
65
|
input: TInput | SkipToken;
|
|
66
66
|
}) & (object extends TClientContext ? {
|
|
67
|
-
context?: TClientContext;
|
|
67
|
+
context?: TClientContext | undefined;
|
|
68
68
|
} : {
|
|
69
69
|
context: TClientContext;
|
|
70
70
|
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey' | '_defaulted' | '_optimisticResults'> & {
|
|
71
|
-
queryKey?: QueryKey;
|
|
71
|
+
queryKey?: QueryKey | undefined;
|
|
72
72
|
initialData?: TInitialData;
|
|
73
73
|
};
|
|
74
74
|
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 +81,12 @@ type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
|
81
81
|
} : {
|
|
82
82
|
input: TInput | SkipToken;
|
|
83
83
|
}) & {
|
|
84
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
84
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
85
85
|
}) | {
|
|
86
86
|
queryKey: QueryKey;
|
|
87
87
|
};
|
|
88
88
|
type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
|
|
89
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
89
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
90
90
|
};
|
|
91
91
|
type StreamedOptionsOut<TOutput, TError, TSelectData, TInitialData> = QueryOptionsOut<TOutput, TError, TSelectData, TInitialData>;
|
|
92
92
|
type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
@@ -95,9 +95,9 @@ type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput
|
|
|
95
95
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam, TInitialData> = {
|
|
96
96
|
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
97
97
|
initialData?: TInitialData;
|
|
98
|
-
queryKey?: QueryKey;
|
|
98
|
+
queryKey?: QueryKey | undefined;
|
|
99
99
|
} & (object extends TClientContext ? {
|
|
100
|
-
context?: TClientContext;
|
|
100
|
+
context?: TClientContext | undefined;
|
|
101
101
|
} : {
|
|
102
102
|
context: TClientContext;
|
|
103
103
|
}) & Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | '_defaulted' | '_optimisticResults'>;
|
|
@@ -108,7 +108,7 @@ type InfiniteOptionsOut<TOutput, TError, TSelectData, TPageParam, TInitialData>
|
|
|
108
108
|
};
|
|
109
109
|
type MutationKeyOptions = Pick<MutationOptionsIn<any, any, any, any, any>, 'mutationKey'>;
|
|
110
110
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (object extends TClientContext ? {
|
|
111
|
-
context?: TClientContext;
|
|
111
|
+
context?: TClientContext | undefined;
|
|
112
112
|
} : {
|
|
113
113
|
context: TClientContext;
|
|
114
114
|
}) & MutationOptionsOut<TInput, TOutput, TError, TMutationContext>;
|
|
@@ -119,15 +119,28 @@ interface OperationKeyPrefixOptions {
|
|
|
119
119
|
* Prepended as the first element of the key when present.
|
|
120
120
|
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
121
121
|
*/
|
|
122
|
-
prefix?: string;
|
|
122
|
+
prefix?: string | undefined;
|
|
123
123
|
}
|
|
124
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;
|
|
125
|
+
type?: TType | undefined;
|
|
126
|
+
input?: (TType extends 'mutation' ? never : PartialDeep<TInput>) | undefined;
|
|
127
|
+
fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
|
|
128
128
|
};
|
|
129
|
-
type
|
|
129
|
+
type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, 'prefix'> & {
|
|
130
|
+
/**
|
|
131
|
+
* Set in place of `input` when the operation is disabled with `skipToken`,
|
|
132
|
+
* because query key hashers drop symbols.
|
|
133
|
+
*/
|
|
134
|
+
skipToken?: TType extends 'mutation' ? never : true;
|
|
135
|
+
};
|
|
136
|
+
type OperationKey<TType extends OperationType, TInput> = [path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>];
|
|
130
137
|
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
138
|
+
/**
|
|
139
|
+
* Creates a `queryKeyHashFn` that supports oRPC types such as `bigint` and `Date`.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
142
|
+
*/
|
|
143
|
+
declare function createQueryKeyHashFn(serializer?: Public<RPCJsonSerializer>): QueryKeyHashFunction<QueryKey>;
|
|
131
144
|
|
|
132
145
|
declare class SharedUtils<TInput> {
|
|
133
146
|
protected readonly path: string[];
|
|
@@ -171,80 +184,80 @@ interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TO
|
|
|
171
184
|
* Key options modifier for .queryKey and .queryOptions
|
|
172
185
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
173
186
|
*/
|
|
174
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
187
|
+
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
175
188
|
/**
|
|
176
189
|
* Interceptors that intercept queryFn inside .queryOptions, guaranteed to be executed.
|
|
177
190
|
*/
|
|
178
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
191
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
179
192
|
/**
|
|
180
193
|
* Options modifier for .queryOptions
|
|
181
194
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
182
195
|
*/
|
|
183
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown
|
|
196
|
+
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>> | undefined;
|
|
184
197
|
/**
|
|
185
198
|
* Key options modifier for .streamedKey and .streamedOptions
|
|
186
199
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
187
200
|
*/
|
|
188
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput
|
|
201
|
+
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
|
|
189
202
|
/**
|
|
190
203
|
* Interceptors that intercept queryFn inside .streamedOptions, guaranteed to be executed.
|
|
191
204
|
*/
|
|
192
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
205
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
193
206
|
/**
|
|
194
207
|
* Options modifier for .streamedOptions
|
|
195
208
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
196
209
|
*/
|
|
197
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown
|
|
210
|
+
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
198
211
|
/**
|
|
199
212
|
* Key options modifier for .liveKey and .liveOptions
|
|
200
213
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
201
214
|
*/
|
|
202
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
215
|
+
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
203
216
|
/**
|
|
204
217
|
* Interceptors that intercept queryFn inside .liveOptions, guaranteed to be executed.
|
|
205
218
|
*/
|
|
206
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
219
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
207
220
|
/**
|
|
208
221
|
* Options modifier for .liveOptions
|
|
209
222
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
210
223
|
*/
|
|
211
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown
|
|
224
|
+
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
212
225
|
/**
|
|
213
226
|
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
214
227
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
215
228
|
*/
|
|
216
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown
|
|
229
|
+
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
|
|
217
230
|
/**
|
|
218
231
|
* Interceptors that intercept queryFn inside .infiniteOptions, guaranteed to be executed.
|
|
219
232
|
*/
|
|
220
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
233
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
221
234
|
/**
|
|
222
235
|
* Options modifier for .infiniteOptions
|
|
223
236
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
224
237
|
*/
|
|
225
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown
|
|
238
|
+
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>> | undefined;
|
|
226
239
|
/**
|
|
227
240
|
* Key options modifier for .mutationKey and .mutationOptions
|
|
228
241
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
229
242
|
*/
|
|
230
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions
|
|
243
|
+
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions> | undefined;
|
|
231
244
|
/**
|
|
232
245
|
* Interceptors that intercept mutationFn inside .mutationOptions, guaranteed to be executed.
|
|
233
246
|
*/
|
|
234
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
247
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
235
248
|
/**
|
|
236
249
|
* Options modifier for .mutationOptions
|
|
237
250
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
238
251
|
*/
|
|
239
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown
|
|
252
|
+
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>> | undefined;
|
|
240
253
|
}
|
|
241
254
|
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
242
255
|
/**
|
|
243
256
|
* Merge two procedure utils options where `override` takes priority.
|
|
244
257
|
* A key explicitly set to `undefined` in `override` resets the base value.
|
|
245
|
-
* When both sides define a key
|
|
246
|
-
* modifiers are
|
|
247
|
-
*
|
|
258
|
+
* When both sides define a key, interceptors are concatenated (base ones run first) and
|
|
259
|
+
* modifiers are combined so that, for object values, per-call options beat `override`,
|
|
260
|
+
* which beats `base`. A function modifier receives the merged options and its result wins.
|
|
248
261
|
*/
|
|
249
262
|
declare function mergeProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError>(base: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, override: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
|
|
250
263
|
declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> extends SharedUtils<TInput> {
|
|
@@ -358,7 +371,7 @@ type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientCont
|
|
|
358
371
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
359
372
|
} & Public<SharedUtils<unknown>>;
|
|
360
373
|
type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
|
|
361
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
|
|
374
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
|
|
362
375
|
};
|
|
363
376
|
interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPrefixOptions {
|
|
364
377
|
/**
|
|
@@ -370,23 +383,23 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
370
383
|
/**
|
|
371
384
|
* Interceptors that intercept queryFn inside .queryOptions
|
|
372
385
|
*/
|
|
373
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
386
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
374
387
|
/**
|
|
375
388
|
* Interceptors that intercept queryFn inside .streamedOptions
|
|
376
389
|
*/
|
|
377
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
390
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
378
391
|
/**
|
|
379
392
|
* Interceptors that intercept queryFn inside .liveOptions
|
|
380
393
|
*/
|
|
381
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
394
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
382
395
|
/**
|
|
383
396
|
* Interceptors that intercept queryFn inside .infiniteOptions
|
|
384
397
|
*/
|
|
385
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
398
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
386
399
|
/**
|
|
387
400
|
* Interceptors that intercept mutationFn inside .mutationOptions
|
|
388
401
|
*/
|
|
389
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
402
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
390
403
|
/**
|
|
391
404
|
* Per-procedure options following the shape of the router.
|
|
392
405
|
* Allows fine-grained configuration of individual procedure utils
|
|
@@ -469,5 +482,39 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
469
482
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
470
483
|
}
|
|
471
484
|
|
|
472
|
-
|
|
473
|
-
|
|
485
|
+
/**
|
|
486
|
+
* Creates `dehydrate` and `hydrate` query client defaults that preserve oRPC types.
|
|
487
|
+
*
|
|
488
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
489
|
+
*/
|
|
490
|
+
declare function createHydrationOptions(serializer?: Public<RPCJsonSerializer>): {
|
|
491
|
+
dehydrate: {
|
|
492
|
+
serializeData: (data: unknown) => RPCJsonSerialization;
|
|
493
|
+
};
|
|
494
|
+
hydrate: {
|
|
495
|
+
deserializeData: (data: RPCJsonSerialization) => unknown;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
interface StreamQuerySSRUtilsPluginOptions {
|
|
499
|
+
/**
|
|
500
|
+
* Whether utils run on the server, where streamed and live queries are cancelled once they have data.
|
|
501
|
+
* Defaults to `true` when there is no global `window`.
|
|
502
|
+
*/
|
|
503
|
+
isServer?: boolean | undefined;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Router utils plugin for SSR of streamed and live queries. On the server, streamed queries are
|
|
507
|
+
* cancelled once they connect and live queries on their first event, keeping the data received so far;
|
|
508
|
+
* in the browser, they refetch on mount so streams reopen after hydration.
|
|
509
|
+
*
|
|
510
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-and-live-queries | TanStack Query Integration - Streamed and Live Queries}
|
|
511
|
+
*/
|
|
512
|
+
declare class StreamQuerySSRUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
513
|
+
readonly name = "~stream-query-ssr";
|
|
514
|
+
private readonly isServer;
|
|
515
|
+
constructor(options?: StreamQuerySSRUtilsPluginOptions);
|
|
516
|
+
initProcedureOptions(_path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, StreamQuerySSRUtilsPlugin, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createHydrationOptions, createQueryKeyHashFn, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey, getTanstackQueryMeta, isProcedureUtilsOptions, mergeProcedureUtilsOptions, serializableStreamedQuery, tanstackQuery };
|
|
520
|
+
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, StreamQuerySSRUtilsPluginOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, TanstackQueryMetaOptions, TanstackQueryMetaPlugin, OperationContext as TanstackQueryOperationContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
1
|
+
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError, RPCJsonSerialization } from '@orpc/client';
|
|
2
2
|
import { RouterContract, RouterContractClient, ContractClientFactory, AnySchema, ErrorMap, MetaPlugin, Meta, InferSchemaInput, InferSchemaOutput, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
3
3
|
import { JsonifiedClient } from '@orpc/openapi';
|
|
4
|
-
import { Promisable, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin,
|
|
5
|
-
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, MutationFunctionContext } from '@tanstack/query-core';
|
|
4
|
+
import { Promisable, PartialDeep, Public, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
|
|
5
|
+
import { QueryKey, QueryFunctionContext, QueryFunction, SkipToken, QueryObserverOptions, InfiniteQueryObserverOptions, MutationObserverOptions, DataTag, InfiniteData, QueryKeyHashFunction, MutationFunctionContext } from '@tanstack/query-core';
|
|
6
6
|
|
|
7
7
|
interface SerializableStreamedQueryOptions {
|
|
8
8
|
/**
|
|
@@ -14,14 +14,14 @@ interface SerializableStreamedQueryOptions {
|
|
|
14
14
|
*
|
|
15
15
|
* @default 'reset'
|
|
16
16
|
*/
|
|
17
|
-
refetchMode?: 'append' | 'reset' | 'replace';
|
|
17
|
+
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Limits the number of data chunks stored in the query result.
|
|
20
20
|
* Older chunks are removed when the limit is reached.
|
|
21
21
|
*
|
|
22
22
|
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
23
23
|
*/
|
|
24
|
-
maxChunks?: number;
|
|
24
|
+
maxChunks?: number | undefined;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* A variant of `streamedQuery` where:
|
|
@@ -64,11 +64,11 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
64
64
|
} : {
|
|
65
65
|
input: TInput | SkipToken;
|
|
66
66
|
}) & (object extends TClientContext ? {
|
|
67
|
-
context?: TClientContext;
|
|
67
|
+
context?: TClientContext | undefined;
|
|
68
68
|
} : {
|
|
69
69
|
context: TClientContext;
|
|
70
70
|
}) & Omit<QueryObserverOptions<TOutput, TError, TSelectData>, 'queryKey' | '_defaulted' | '_optimisticResults'> & {
|
|
71
|
-
queryKey?: QueryKey;
|
|
71
|
+
queryKey?: QueryKey | undefined;
|
|
72
72
|
initialData?: TInitialData;
|
|
73
73
|
};
|
|
74
74
|
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 +81,12 @@ type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
|
81
81
|
} : {
|
|
82
82
|
input: TInput | SkipToken;
|
|
83
83
|
}) & {
|
|
84
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
84
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
85
85
|
}) | {
|
|
86
86
|
queryKey: QueryKey;
|
|
87
87
|
};
|
|
88
88
|
type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TInitialData> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TSelectData, TInitialData> & {
|
|
89
|
-
queryFnOptions?: SerializableStreamedQueryOptions;
|
|
89
|
+
queryFnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
90
90
|
};
|
|
91
91
|
type StreamedOptionsOut<TOutput, TError, TSelectData, TInitialData> = QueryOptionsOut<TOutput, TError, TSelectData, TInitialData>;
|
|
92
92
|
type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
@@ -95,9 +95,9 @@ type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput
|
|
|
95
95
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TSelectData, TPageParam, TInitialData> = {
|
|
96
96
|
input: ((pageParam: TPageParam) => TInput) | SkipToken;
|
|
97
97
|
initialData?: TInitialData;
|
|
98
|
-
queryKey?: QueryKey;
|
|
98
|
+
queryKey?: QueryKey | undefined;
|
|
99
99
|
} & (object extends TClientContext ? {
|
|
100
|
-
context?: TClientContext;
|
|
100
|
+
context?: TClientContext | undefined;
|
|
101
101
|
} : {
|
|
102
102
|
context: TClientContext;
|
|
103
103
|
}) & Omit<InfiniteQueryObserverOptions<TOutput, TError, TSelectData, QueryKey, TPageParam>, 'queryKey' | '_defaulted' | '_optimisticResults'>;
|
|
@@ -108,7 +108,7 @@ type InfiniteOptionsOut<TOutput, TError, TSelectData, TPageParam, TInitialData>
|
|
|
108
108
|
};
|
|
109
109
|
type MutationKeyOptions = Pick<MutationOptionsIn<any, any, any, any, any>, 'mutationKey'>;
|
|
110
110
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext> = (object extends TClientContext ? {
|
|
111
|
-
context?: TClientContext;
|
|
111
|
+
context?: TClientContext | undefined;
|
|
112
112
|
} : {
|
|
113
113
|
context: TClientContext;
|
|
114
114
|
}) & MutationOptionsOut<TInput, TOutput, TError, TMutationContext>;
|
|
@@ -119,15 +119,28 @@ interface OperationKeyPrefixOptions {
|
|
|
119
119
|
* Prepended as the first element of the key when present.
|
|
120
120
|
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
121
121
|
*/
|
|
122
|
-
prefix?: string;
|
|
122
|
+
prefix?: string | undefined;
|
|
123
123
|
}
|
|
124
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;
|
|
125
|
+
type?: TType | undefined;
|
|
126
|
+
input?: (TType extends 'mutation' ? never : PartialDeep<TInput>) | undefined;
|
|
127
|
+
fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
|
|
128
128
|
};
|
|
129
|
-
type
|
|
129
|
+
type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, 'prefix'> & {
|
|
130
|
+
/**
|
|
131
|
+
* Set in place of `input` when the operation is disabled with `skipToken`,
|
|
132
|
+
* because query key hashers drop symbols.
|
|
133
|
+
*/
|
|
134
|
+
skipToken?: TType extends 'mutation' ? never : true;
|
|
135
|
+
};
|
|
136
|
+
type OperationKey<TType extends OperationType, TInput> = [path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>];
|
|
130
137
|
declare function generateOperationKey<TType extends OperationType, TInput>(path: string[], options?: OperationKeyOptions<TType, TInput>): OperationKey<TType, TInput>;
|
|
138
|
+
/**
|
|
139
|
+
* Creates a `queryKeyHashFn` that supports oRPC types such as `bigint` and `Date`.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
142
|
+
*/
|
|
143
|
+
declare function createQueryKeyHashFn(serializer?: Public<RPCJsonSerializer>): QueryKeyHashFunction<QueryKey>;
|
|
131
144
|
|
|
132
145
|
declare class SharedUtils<TInput> {
|
|
133
146
|
protected readonly path: string[];
|
|
@@ -171,80 +184,80 @@ interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TO
|
|
|
171
184
|
* Key options modifier for .queryKey and .queryOptions
|
|
172
185
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
173
186
|
*/
|
|
174
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
187
|
+
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
175
188
|
/**
|
|
176
189
|
* Interceptors that intercept queryFn inside .queryOptions, guaranteed to be executed.
|
|
177
190
|
*/
|
|
178
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
191
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
179
192
|
/**
|
|
180
193
|
* Options modifier for .queryOptions
|
|
181
194
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
182
195
|
*/
|
|
183
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown
|
|
196
|
+
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown>> | undefined;
|
|
184
197
|
/**
|
|
185
198
|
* Key options modifier for .streamedKey and .streamedOptions
|
|
186
199
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
187
200
|
*/
|
|
188
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput
|
|
201
|
+
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
|
|
189
202
|
/**
|
|
190
203
|
* Interceptors that intercept queryFn inside .streamedOptions, guaranteed to be executed.
|
|
191
204
|
*/
|
|
192
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
205
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
193
206
|
/**
|
|
194
207
|
* Options modifier for .streamedOptions
|
|
195
208
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
196
209
|
*/
|
|
197
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown
|
|
210
|
+
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
198
211
|
/**
|
|
199
212
|
* Key options modifier for .liveKey and .liveOptions
|
|
200
213
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
201
214
|
*/
|
|
202
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
215
|
+
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
203
216
|
/**
|
|
204
217
|
* Interceptors that intercept queryFn inside .liveOptions, guaranteed to be executed.
|
|
205
218
|
*/
|
|
206
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
219
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
207
220
|
/**
|
|
208
221
|
* Options modifier for .liveOptions
|
|
209
222
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
210
223
|
*/
|
|
211
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown
|
|
224
|
+
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, unknown, unknown>> | undefined;
|
|
212
225
|
/**
|
|
213
226
|
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
214
227
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
215
228
|
*/
|
|
216
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown
|
|
229
|
+
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
|
|
217
230
|
/**
|
|
218
231
|
* Interceptors that intercept queryFn inside .infiniteOptions, guaranteed to be executed.
|
|
219
232
|
*/
|
|
220
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
233
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
221
234
|
/**
|
|
222
235
|
* Options modifier for .infiniteOptions
|
|
223
236
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
224
237
|
*/
|
|
225
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown
|
|
238
|
+
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, unknown, unknown>> | undefined;
|
|
226
239
|
/**
|
|
227
240
|
* Key options modifier for .mutationKey and .mutationOptions
|
|
228
241
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
229
242
|
*/
|
|
230
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions
|
|
243
|
+
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions> | undefined;
|
|
231
244
|
/**
|
|
232
245
|
* Interceptors that intercept mutationFn inside .mutationOptions, guaranteed to be executed.
|
|
233
246
|
*/
|
|
234
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
247
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
235
248
|
/**
|
|
236
249
|
* Options modifier for .mutationOptions
|
|
237
250
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
238
251
|
*/
|
|
239
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown
|
|
252
|
+
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, unknown>> | undefined;
|
|
240
253
|
}
|
|
241
254
|
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
242
255
|
/**
|
|
243
256
|
* Merge two procedure utils options where `override` takes priority.
|
|
244
257
|
* A key explicitly set to `undefined` in `override` resets the base value.
|
|
245
|
-
* When both sides define a key
|
|
246
|
-
* modifiers are
|
|
247
|
-
*
|
|
258
|
+
* When both sides define a key, interceptors are concatenated (base ones run first) and
|
|
259
|
+
* modifiers are combined so that, for object values, per-call options beat `override`,
|
|
260
|
+
* which beats `base`. A function modifier receives the merged options and its result wins.
|
|
248
261
|
*/
|
|
249
262
|
declare function mergeProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError>(base: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, override: ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>): ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>;
|
|
250
263
|
declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> extends SharedUtils<TInput> {
|
|
@@ -358,7 +371,7 @@ type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientCont
|
|
|
358
371
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
359
372
|
} & Public<SharedUtils<unknown>>;
|
|
360
373
|
type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
|
|
361
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
|
|
374
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
|
|
362
375
|
};
|
|
363
376
|
interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPrefixOptions {
|
|
364
377
|
/**
|
|
@@ -370,23 +383,23 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
370
383
|
/**
|
|
371
384
|
* Interceptors that intercept queryFn inside .queryOptions
|
|
372
385
|
*/
|
|
373
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
386
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
374
387
|
/**
|
|
375
388
|
* Interceptors that intercept queryFn inside .streamedOptions
|
|
376
389
|
*/
|
|
377
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
390
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
378
391
|
/**
|
|
379
392
|
* Interceptors that intercept queryFn inside .liveOptions
|
|
380
393
|
*/
|
|
381
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
394
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
382
395
|
/**
|
|
383
396
|
* Interceptors that intercept queryFn inside .infiniteOptions
|
|
384
397
|
*/
|
|
385
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
398
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
386
399
|
/**
|
|
387
400
|
* Interceptors that intercept mutationFn inside .mutationOptions
|
|
388
401
|
*/
|
|
389
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
402
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
390
403
|
/**
|
|
391
404
|
* Per-procedure options following the shape of the router.
|
|
392
405
|
* Allows fine-grained configuration of individual procedure utils
|
|
@@ -469,5 +482,39 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
469
482
|
initProcedureOptions(path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
470
483
|
}
|
|
471
484
|
|
|
472
|
-
|
|
473
|
-
|
|
485
|
+
/**
|
|
486
|
+
* Creates `dehydrate` and `hydrate` query client defaults that preserve oRPC types.
|
|
487
|
+
*
|
|
488
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
489
|
+
*/
|
|
490
|
+
declare function createHydrationOptions(serializer?: Public<RPCJsonSerializer>): {
|
|
491
|
+
dehydrate: {
|
|
492
|
+
serializeData: (data: unknown) => RPCJsonSerialization;
|
|
493
|
+
};
|
|
494
|
+
hydrate: {
|
|
495
|
+
deserializeData: (data: RPCJsonSerialization) => unknown;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
interface StreamQuerySSRUtilsPluginOptions {
|
|
499
|
+
/**
|
|
500
|
+
* Whether utils run on the server, where streamed and live queries are cancelled once they have data.
|
|
501
|
+
* Defaults to `true` when there is no global `window`.
|
|
502
|
+
*/
|
|
503
|
+
isServer?: boolean | undefined;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Router utils plugin for SSR of streamed and live queries. On the server, streamed queries are
|
|
507
|
+
* cancelled once they connect and live queries on their first event, keeping the data received so far;
|
|
508
|
+
* in the browser, they refetch on mount so streams reopen after hydration.
|
|
509
|
+
*
|
|
510
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#streamed-and-live-queries | TanStack Query Integration - Streamed and Live Queries}
|
|
511
|
+
*/
|
|
512
|
+
declare class StreamQuerySSRUtilsPlugin<T extends AnyNestedClient = AnyNestedClient> implements RouterUtilsPlugin<T> {
|
|
513
|
+
readonly name = "~stream-query-ssr";
|
|
514
|
+
private readonly isServer;
|
|
515
|
+
constructor(options?: StreamQuerySSRUtilsPluginOptions);
|
|
516
|
+
initProcedureOptions(_path: string[], options: ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>): ProcedureUtilsOptions<InferClientContext<T>, any, any, InferClientError<T>>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, StreamQuerySSRUtilsPlugin, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createHydrationOptions, createQueryKeyHashFn, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey, getTanstackQueryMeta, isProcedureUtilsOptions, mergeProcedureUtilsOptions, serializableStreamedQuery, tanstackQuery };
|
|
520
|
+
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, StreamQuerySSRUtilsPluginOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, TanstackQueryMetaOptions, TanstackQueryMetaPlugin, OperationContext as TanstackQueryOperationContext };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveBasePathMeta, getRouterContract, ProcedureContract } from '@orpc/contract';
|
|
2
|
-
import { sortPlugins,
|
|
3
|
-
import { RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
4
|
-
import { skipToken } from '@tanstack/query-core';
|
|
2
|
+
import { sortPlugins, stringifyJSON, throwIfAborted, resolveMaybeOptionalOptions, intercept, toArray, isAsyncIteratorObject, isTypescriptObject, bindMethods, pick, get } from '@orpc/shared';
|
|
3
|
+
import { RPCJsonSerializer, RECURSIVE_CLIENT_UNWRAP_KEYS } from '@orpc/client';
|
|
4
|
+
import { hashKey, skipToken } from '@tanstack/query-core';
|
|
5
5
|
|
|
6
6
|
class CompositeRouterUtilsPlugin {
|
|
7
7
|
constructor(plugins = []) {
|
|
@@ -32,12 +32,21 @@ function generateOperationKey(path, options = {}) {
|
|
|
32
32
|
...options.prefix !== void 0 ? [options.prefix] : [],
|
|
33
33
|
path,
|
|
34
34
|
{
|
|
35
|
-
...options.input !== void 0 ? { input: options.input } : {},
|
|
35
|
+
...options.input === skipToken ? { skipToken: true } : options.input !== void 0 ? { input: options.input } : {},
|
|
36
36
|
...options.type !== void 0 ? { type: options.type } : {},
|
|
37
37
|
...options.fnOptions !== void 0 ? { fnOptions: options.fnOptions } : {}
|
|
38
38
|
}
|
|
39
39
|
];
|
|
40
40
|
}
|
|
41
|
+
function createQueryKeyHashFn(serializer = new RPCJsonSerializer()) {
|
|
42
|
+
return (queryKey) => {
|
|
43
|
+
const { json, meta } = serializer.serializeJson(queryKey);
|
|
44
|
+
return hashKey([
|
|
45
|
+
json,
|
|
46
|
+
meta?.map((entry) => stringifyJSON(entry)).sort()
|
|
47
|
+
]);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
41
50
|
|
|
42
51
|
function liveQuery(queryFn) {
|
|
43
52
|
return async (context) => {
|
|
@@ -83,10 +92,9 @@ function serializableStreamedQuery(queryFn, { refetchMode = "reset", maxChunks =
|
|
|
83
92
|
fetchStatus: "fetching"
|
|
84
93
|
});
|
|
85
94
|
} else {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
);
|
|
95
|
+
query.setState({
|
|
96
|
+
data: limitArraySize(query.state.data, maxChunks)
|
|
97
|
+
});
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
let result = [];
|
|
@@ -96,6 +104,10 @@ function serializableStreamedQuery(queryFn, { refetchMode = "reset", maxChunks =
|
|
|
96
104
|
context.queryKey,
|
|
97
105
|
(prev = []) => limitArraySize(prev, maxChunks)
|
|
98
106
|
);
|
|
107
|
+
if (context.signal.aborted) {
|
|
108
|
+
await stream[Symbol.asyncIterator]().return?.();
|
|
109
|
+
throw context.signal.reason;
|
|
110
|
+
}
|
|
99
111
|
for await (const chunk of stream) {
|
|
100
112
|
if (context.signal.aborted) {
|
|
101
113
|
throw context.signal.reason;
|
|
@@ -172,12 +184,14 @@ function isProcedureUtilsOptions(value) {
|
|
|
172
184
|
return true;
|
|
173
185
|
}
|
|
174
186
|
function mergeProcedureUtilsModifier(base, override) {
|
|
175
|
-
if (typeof
|
|
176
|
-
|
|
187
|
+
if (typeof override !== "function") {
|
|
188
|
+
if (typeof base !== "function") {
|
|
189
|
+
return { ...base, ...override };
|
|
190
|
+
}
|
|
191
|
+
return (options) => base({ ...override, ...options });
|
|
177
192
|
}
|
|
178
193
|
const applyBase = typeof base === "function" ? base : (options) => ({ ...base, ...options });
|
|
179
|
-
|
|
180
|
-
return (options) => applyOverride(applyBase(options));
|
|
194
|
+
return (options) => override(applyBase(options));
|
|
181
195
|
}
|
|
182
196
|
function mergeProcedureUtilsOptions(base, override) {
|
|
183
197
|
const merged = { ...base, ...override };
|
|
@@ -610,4 +624,49 @@ class ContractOptionsUtilsPlugin {
|
|
|
610
624
|
}
|
|
611
625
|
}
|
|
612
626
|
|
|
613
|
-
|
|
627
|
+
function createHydrationOptions(serializer = new RPCJsonSerializer()) {
|
|
628
|
+
return {
|
|
629
|
+
dehydrate: {
|
|
630
|
+
serializeData(data) {
|
|
631
|
+
const { json, meta } = serializer.serializeJson(data);
|
|
632
|
+
return { json, meta };
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
hydrate: {
|
|
636
|
+
deserializeData(data) {
|
|
637
|
+
return serializer.deserializeJson(data);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const cancelOnFirstData = async ({ next, fnContext }) => {
|
|
643
|
+
const cache = fnContext.client.getQueryCache();
|
|
644
|
+
const query = cache.find({ queryKey: fnContext.queryKey, exact: true });
|
|
645
|
+
const unsubscribe = cache.subscribe((event) => {
|
|
646
|
+
if (event.query === query && event.type === "updated" && event.action.type === "success") {
|
|
647
|
+
unsubscribe();
|
|
648
|
+
void event.query.cancel({ revert: true });
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
try {
|
|
652
|
+
return await next();
|
|
653
|
+
} finally {
|
|
654
|
+
unsubscribe();
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
class StreamQuerySSRUtilsPlugin {
|
|
658
|
+
name = "~stream-query-ssr";
|
|
659
|
+
isServer;
|
|
660
|
+
constructor(options = {}) {
|
|
661
|
+
this.isServer = options.isServer ?? !("window" in globalThis);
|
|
662
|
+
}
|
|
663
|
+
initProcedureOptions(_path, options) {
|
|
664
|
+
return mergeProcedureUtilsOptions({
|
|
665
|
+
...this.isServer ? { streamedInterceptors: [cancelOnFirstData], liveInterceptors: [cancelOnFirstData] } : {},
|
|
666
|
+
streamedOptions: { initialData: [], refetchOnMount: "always" },
|
|
667
|
+
liveOptions: { refetchOnMount: "always" }
|
|
668
|
+
}, options);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, StreamQuerySSRUtilsPlugin, OPERATION_CONTEXT_SYMBOL as TANSTACK_QUERY_OPERATION_CONTEXT_SYMBOL, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createHydrationOptions, createQueryKeyHashFn, createRouterUtils, createRouterUtils as createTanstackQueryUtils, generateOperationKey, getTanstackQueryMeta, isProcedureUtilsOptions, mergeProcedureUtilsOptions, serializableStreamedQuery, tanstackQuery };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/tanstack-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.45",
|
|
5
5
|
"description": "TanStack Query integration for oRPC: typesafe queries, mutations, streaming, and SSR for React, Vue, Solid, Svelte, and Angular",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"@tanstack/query-core": ">=5.89.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@orpc/client": "2.0.0-beta.
|
|
48
|
-
"@orpc/contract": "2.0.0-beta.
|
|
49
|
-
"@orpc/openapi": "2.0.0-beta.
|
|
50
|
-
"@orpc/shared": "2.0.0-beta.
|
|
47
|
+
"@orpc/client": "2.0.0-beta.45",
|
|
48
|
+
"@orpc/contract": "2.0.0-beta.45",
|
|
49
|
+
"@orpc/openapi": "2.0.0-beta.45",
|
|
50
|
+
"@orpc/shared": "2.0.0-beta.45"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@angular/core": "^22.
|
|
54
|
-
"@tanstack/angular-query-experimental": "^5.
|
|
55
|
-
"@tanstack/query-core": "^5.
|
|
56
|
-
"@tanstack/react-query": "^5.
|
|
57
|
-
"@tanstack/solid-query": "^5.
|
|
58
|
-
"@tanstack/svelte-query": "^6.
|
|
59
|
-
"@tanstack/vue-query": "^5.
|
|
60
|
-
"svelte": "^5.
|
|
61
|
-
"vue": "^3.5.
|
|
62
|
-
"zod": "^4.
|
|
53
|
+
"@angular/core": "^22.2.3",
|
|
54
|
+
"@tanstack/angular-query-experimental": "^5.104.3",
|
|
55
|
+
"@tanstack/query-core": "^5.104.3",
|
|
56
|
+
"@tanstack/react-query": "^5.104.3",
|
|
57
|
+
"@tanstack/solid-query": "^5.104.3",
|
|
58
|
+
"@tanstack/svelte-query": "^6.3.3",
|
|
59
|
+
"@tanstack/vue-query": "^5.104.3",
|
|
60
|
+
"svelte": "^5.57.2",
|
|
61
|
+
"vue": "^3.5.44",
|
|
62
|
+
"zod": "^4.6.7"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"type:check": "tsc -b"
|