@orpc/pinia-colada 2.0.0-beta.44 → 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 +55 -48
- package/dist/index.d.mts +60 -43
- package/dist/index.d.ts +60 -43
- package/dist/index.mjs +35 -20
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -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,19 +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
|
-
### Premium Sponsors
|
|
99
|
-
|
|
100
|
-
<table>
|
|
101
|
-
<tr>
|
|
102
|
-
<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>
|
|
103
|
-
</tr>
|
|
104
|
-
</table>
|
|
105
|
-
|
|
106
99
|
### Organization Sponsors
|
|
107
100
|
|
|
108
101
|
<table>
|
|
109
102
|
<tr>
|
|
110
|
-
<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>
|
|
111
104
|
</tr>
|
|
112
105
|
</table>
|
|
113
106
|
|
|
@@ -115,27 +108,29 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
115
108
|
|
|
116
109
|
<table>
|
|
117
110
|
<tr>
|
|
118
|
-
<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="
|
|
119
|
-
<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="
|
|
120
|
-
<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="
|
|
121
|
-
<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="
|
|
122
|
-
<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="
|
|
123
|
-
|
|
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>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
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>
|
|
124
123
|
</tr>
|
|
125
124
|
<tr>
|
|
126
|
-
<td align="center"><a href="https://
|
|
127
|
-
<td align="center"><a href="https://
|
|
128
|
-
<td align="center"><a href="https://
|
|
129
|
-
<td align="center"><a href="https://
|
|
130
|
-
<td align="center"><a href="https://github.com/
|
|
131
|
-
<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>
|
|
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>
|
|
132
130
|
</tr>
|
|
133
131
|
<tr>
|
|
134
|
-
<td align="center"><a href="https://
|
|
135
|
-
<td align="center"><a href="https://
|
|
136
|
-
<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="139" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
137
|
-
<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="139" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
138
|
-
<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="139" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
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>
|
|
139
134
|
</tr>
|
|
140
135
|
</table>
|
|
141
136
|
|
|
@@ -143,34 +138,46 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
143
138
|
|
|
144
139
|
<table>
|
|
145
140
|
<tr>
|
|
146
|
-
<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="
|
|
147
|
-
<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="
|
|
148
|
-
<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="
|
|
149
|
-
<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="
|
|
150
|
-
<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="
|
|
151
|
-
<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="
|
|
152
|
-
<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="119" alt="Denis"/><br />Denis</a></td>
|
|
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>
|
|
153
147
|
</tr>
|
|
154
148
|
<tr>
|
|
155
|
-
<td align="center"><a href="https://github.com/
|
|
156
|
-
<td align="center"><a href="
|
|
157
|
-
<td align="center"><a href="
|
|
158
|
-
<td align="center"><a href="https://
|
|
159
|
-
<td align="center"><a href="https://
|
|
160
|
-
<td align="center"><a href="https://
|
|
161
|
-
<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>
|
|
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>
|
|
162
155
|
</tr>
|
|
163
156
|
<tr>
|
|
164
|
-
<td align="center"><a href="https://
|
|
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://
|
|
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>
|
|
163
|
+
</tr>
|
|
164
|
+
<tr>
|
|
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>
|
|
170
167
|
</tr>
|
|
171
168
|
</table>
|
|
172
169
|
|
|
173
|
-
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>
|
|
174
181
|
|
|
175
182
|
## References
|
|
176
183
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
1
|
+
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError } 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,
|
|
4
|
+
import { Promisable, Public, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
|
|
5
5
|
import { EntryKey, UseQueryOptions, UseMutationOptionsGlobal, DefineQueryOptions, UseInfiniteQueryData, DefineInfiniteQueryOptions, UseMutationOptions, DefineQueryOptionsTagged, DefineInfiniteQueryOptionsTagged, DefineMutationOptionsTagged, UseInfiniteQueryFnContext, EntryKeyTagged, _EmptyObject } from '@pinia/colada';
|
|
6
6
|
|
|
7
7
|
type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
@@ -44,7 +44,7 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
44
44
|
} : {
|
|
45
45
|
input: TInput;
|
|
46
46
|
}) & (object extends TClientContext ? {
|
|
47
|
-
context?: TClientContext;
|
|
47
|
+
context?: TClientContext | undefined;
|
|
48
48
|
} : {
|
|
49
49
|
context: TClientContext;
|
|
50
50
|
}) & Omit<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>>;
|
|
@@ -54,12 +54,12 @@ type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
|
54
54
|
} : {
|
|
55
55
|
input: TInput;
|
|
56
56
|
}) & {
|
|
57
|
-
fnOptions?: SerializableStreamedQueryOptions;
|
|
57
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
58
58
|
}) | {
|
|
59
59
|
key: EntryKey;
|
|
60
60
|
};
|
|
61
61
|
type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TInitialData> & {
|
|
62
|
-
fnOptions?: SerializableStreamedQueryOptions;
|
|
62
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
63
63
|
};
|
|
64
64
|
type StreamedOptionsOut<TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsOut<TOutput, TError, TInitialData>;
|
|
65
65
|
type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
@@ -68,14 +68,14 @@ type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput
|
|
|
68
68
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = {
|
|
69
69
|
input: (pageParam: TPageParam) => TInput;
|
|
70
70
|
} & (object extends TClientContext ? {
|
|
71
|
-
context?: TClientContext;
|
|
71
|
+
context?: TClientContext | undefined;
|
|
72
72
|
} : {
|
|
73
73
|
context: TClientContext;
|
|
74
74
|
}) & Omit<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'>>;
|
|
75
75
|
type InfiniteOptionsOut<TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = DefineInfiniteQueryOptionsTagged<TOutput, TError, TPageParam, TInitialData>;
|
|
76
76
|
type MutationKeyOptions<TInput> = Pick<MutationOptionsIn<any, TInput, any, any, any>, 'key'>;
|
|
77
77
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext extends Record<any, any>> = (object extends TClientContext ? {
|
|
78
|
-
context?: TClientContext;
|
|
78
|
+
context?: TClientContext | undefined;
|
|
79
79
|
} : {
|
|
80
80
|
context: TClientContext;
|
|
81
81
|
}) & Omit<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'> & Partial<Pick<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>>;
|
|
@@ -91,14 +91,14 @@ interface SerializableStreamedQueryOptions {
|
|
|
91
91
|
*
|
|
92
92
|
* @default 'reset'
|
|
93
93
|
*/
|
|
94
|
-
refetchMode?: 'append' | 'reset' | 'replace';
|
|
94
|
+
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
95
95
|
/**
|
|
96
96
|
* Limits the number of data chunks stored in the query result.
|
|
97
97
|
* Older chunks are removed when the limit is reached.
|
|
98
98
|
*
|
|
99
99
|
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
100
100
|
*/
|
|
101
|
-
maxChunks?: number;
|
|
101
|
+
maxChunks?: number | undefined;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* A Pinia Colada query function that accumulates streamed chunks into an array,
|
|
@@ -115,14 +115,31 @@ interface OperationKeyPrefixOptions {
|
|
|
115
115
|
* Prepended as the first element of the key when present.
|
|
116
116
|
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
117
117
|
*/
|
|
118
|
-
prefix?: string;
|
|
118
|
+
prefix?: string | undefined;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
interface OperationKeyBaseOptions extends OperationKeyPrefixOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Serializes inputs into JSON-compatible values when building keys.
|
|
123
|
+
* Pass the serializer your link uses so custom types produce consistent keys.
|
|
124
|
+
*
|
|
125
|
+
* @default new RPCJsonSerializer()
|
|
126
|
+
*/
|
|
127
|
+
serializer?: Public<RPCJsonSerializer> | undefined;
|
|
128
|
+
}
|
|
129
|
+
type OperationKeyOptions<TType extends OperationType, TInput> = OperationKeyBaseOptions & {
|
|
130
|
+
type?: TType | undefined;
|
|
131
|
+
input?: PartialDeep<TInput> | undefined;
|
|
132
|
+
fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
|
|
133
|
+
};
|
|
134
|
+
type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions> & {
|
|
135
|
+
/**
|
|
136
|
+
* Serializer types of non-JSON values in `input`, keyed by their JSON-encoded path,
|
|
137
|
+
* so inputs with the same JSON form (like a `Date` and its ISO string) produce different keys.
|
|
138
|
+
* Keyed by path (not a list) so partial keys still match.
|
|
139
|
+
*/
|
|
140
|
+
inputMeta?: Record<string, string[]> | undefined;
|
|
124
141
|
};
|
|
125
|
-
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options:
|
|
142
|
+
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>]);
|
|
126
143
|
/**
|
|
127
144
|
* Generate a Pinia Colada entry key for a procedure.
|
|
128
145
|
*
|
|
@@ -135,14 +152,14 @@ declare function generateOperationKey<TType extends OperationType, TInput>(path:
|
|
|
135
152
|
|
|
136
153
|
declare class SharedUtils<TInput> {
|
|
137
154
|
protected readonly path: string[];
|
|
138
|
-
protected readonly options:
|
|
139
|
-
constructor(path: string[], options:
|
|
155
|
+
protected readonly options: OperationKeyBaseOptions;
|
|
156
|
+
constructor(path: string[], options: OperationKeyBaseOptions);
|
|
140
157
|
/**
|
|
141
158
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
142
159
|
*
|
|
143
160
|
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
144
161
|
*/
|
|
145
|
-
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>,
|
|
162
|
+
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions>): OperationKey<TType, TInput>;
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
|
|
@@ -177,77 +194,77 @@ type ProcedureUtilsMutationInterceptor<TClientContext extends ClientContext, TIn
|
|
|
177
194
|
* or a function that receives per-call options and returns overridden this.options.
|
|
178
195
|
*/
|
|
179
196
|
type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
|
|
180
|
-
interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends
|
|
197
|
+
interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends OperationKeyBaseOptions {
|
|
181
198
|
/**
|
|
182
199
|
* Key options modifier for .queryKey and .queryOptions
|
|
183
200
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
184
201
|
*/
|
|
185
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
202
|
+
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
186
203
|
/**
|
|
187
204
|
* Interceptors that intercept query inside .queryOptions, guaranteed to be executed.
|
|
188
205
|
*/
|
|
189
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
206
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
190
207
|
/**
|
|
191
208
|
* Options modifier for .queryOptions
|
|
192
209
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
193
210
|
*/
|
|
194
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, TOutput | undefined
|
|
211
|
+
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, TOutput | undefined>> | undefined;
|
|
195
212
|
/**
|
|
196
213
|
* Key options modifier for .streamedKey and .streamedOptions
|
|
197
214
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
198
215
|
*/
|
|
199
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput
|
|
216
|
+
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
|
|
200
217
|
/**
|
|
201
218
|
* Interceptors that intercept query inside .streamedOptions, guaranteed to be executed.
|
|
202
219
|
*/
|
|
203
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
220
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
204
221
|
/**
|
|
205
222
|
* Options modifier for .streamedOptions
|
|
206
223
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
207
224
|
*/
|
|
208
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, InferStreamedQueryOutput<TOutput> | undefined
|
|
225
|
+
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, InferStreamedQueryOutput<TOutput> | undefined>> | undefined;
|
|
209
226
|
/**
|
|
210
227
|
* Key options modifier for .liveKey and .liveOptions
|
|
211
228
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
212
229
|
*/
|
|
213
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
230
|
+
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
214
231
|
/**
|
|
215
232
|
* Interceptors that intercept query inside .liveOptions, guaranteed to be executed.
|
|
216
233
|
*/
|
|
217
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
234
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
218
235
|
/**
|
|
219
236
|
* Options modifier for .liveOptions
|
|
220
237
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
221
238
|
*/
|
|
222
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, InferLiveQueryOutput<TOutput> | undefined
|
|
239
|
+
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, InferLiveQueryOutput<TOutput> | undefined>> | undefined;
|
|
223
240
|
/**
|
|
224
241
|
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
225
242
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
226
243
|
*/
|
|
227
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown
|
|
244
|
+
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
|
|
228
245
|
/**
|
|
229
246
|
* Interceptors that intercept query inside .infiniteOptions, guaranteed to be executed.
|
|
230
247
|
*/
|
|
231
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
248
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
232
249
|
/**
|
|
233
250
|
* Options modifier for .infiniteOptions
|
|
234
251
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
235
252
|
*/
|
|
236
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, UseInfiniteQueryData<TOutput, unknown> | undefined
|
|
253
|
+
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, UseInfiniteQueryData<TOutput, unknown> | undefined>> | undefined;
|
|
237
254
|
/**
|
|
238
255
|
* Key options modifier for .mutationKey and .mutationOptions
|
|
239
256
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
240
257
|
*/
|
|
241
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions<TInput
|
|
258
|
+
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions<TInput>> | undefined;
|
|
242
259
|
/**
|
|
243
260
|
* Interceptors that intercept mutation inside .mutationOptions, guaranteed to be executed.
|
|
244
261
|
*/
|
|
245
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
262
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
246
263
|
/**
|
|
247
264
|
* Options modifier for .mutationOptions
|
|
248
265
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
249
266
|
*/
|
|
250
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any
|
|
267
|
+
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any>>> | undefined;
|
|
251
268
|
}
|
|
252
269
|
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
253
270
|
/**
|
|
@@ -382,9 +399,9 @@ type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientCont
|
|
|
382
399
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
383
400
|
} & Public<SharedUtils<unknown>>;
|
|
384
401
|
type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
|
|
385
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
|
|
402
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
|
|
386
403
|
};
|
|
387
|
-
interface RouterUtilsOptions<T extends AnyNestedClient> extends
|
|
404
|
+
interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyBaseOptions {
|
|
388
405
|
/**
|
|
389
406
|
* Base path for all query keys.
|
|
390
407
|
*
|
|
@@ -394,23 +411,23 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
394
411
|
/**
|
|
395
412
|
* Interceptors that intercept query inside .queryOptions
|
|
396
413
|
*/
|
|
397
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
414
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
398
415
|
/**
|
|
399
416
|
* Interceptors that intercept query inside .streamedOptions
|
|
400
417
|
*/
|
|
401
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
418
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
402
419
|
/**
|
|
403
420
|
* Interceptors that intercept query inside .liveOptions
|
|
404
421
|
*/
|
|
405
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
422
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
406
423
|
/**
|
|
407
424
|
* Interceptors that intercept query inside .infiniteOptions
|
|
408
425
|
*/
|
|
409
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
426
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
410
427
|
/**
|
|
411
428
|
* Interceptors that intercept mutation inside .mutationOptions
|
|
412
429
|
*/
|
|
413
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
430
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
414
431
|
/**
|
|
415
432
|
* Per-procedure options following the shape of the router.
|
|
416
433
|
* Allows fine-grained configuration of individual procedure utils
|
|
@@ -462,7 +479,7 @@ declare function createContractJsonifiedUtilsFactory<TClientContext extends Clie
|
|
|
462
479
|
*/
|
|
463
480
|
declare function liveQuery<T>(queryFn: (context: UseQueryFnContext) => Promisable<AsyncIterable<T>>): (context: UseQueryFnContext) => Promise<T>;
|
|
464
481
|
|
|
465
|
-
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>,
|
|
482
|
+
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
|
|
466
483
|
interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
467
484
|
name: '~pinia-colada';
|
|
468
485
|
}
|
|
@@ -500,4 +517,4 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
500
517
|
}
|
|
501
518
|
|
|
502
519
|
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
503
|
-
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, PiniaColadaMetaOptions, PiniaColadaMetaPlugin, OperationContext as PiniaColadaOperationContext, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, UseMutationFnContext, UseQueryFnContext };
|
|
520
|
+
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyBaseOptions, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, PiniaColadaMetaOptions, PiniaColadaMetaPlugin, OperationContext as PiniaColadaOperationContext, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, UseMutationFnContext, UseQueryFnContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClientContext, Client, AnyNestedClient, InferClientContext, InferClientError } from '@orpc/client';
|
|
1
|
+
import { ClientContext, RPCJsonSerializer, Client, AnyNestedClient, InferClientContext, InferClientError } 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,
|
|
4
|
+
import { Promisable, Public, PartialDeep, Interceptor, PromiseWithError, MaybeOptionalOptions, OrderablePlugin, ThrowableError } from '@orpc/shared';
|
|
5
5
|
import { EntryKey, UseQueryOptions, UseMutationOptionsGlobal, DefineQueryOptions, UseInfiniteQueryData, DefineInfiniteQueryOptions, UseMutationOptions, DefineQueryOptionsTagged, DefineInfiniteQueryOptionsTagged, DefineMutationOptionsTagged, UseInfiniteQueryFnContext, EntryKeyTagged, _EmptyObject } from '@pinia/colada';
|
|
6
6
|
|
|
7
7
|
type InferStreamedQueryOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
@@ -44,7 +44,7 @@ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TErro
|
|
|
44
44
|
} : {
|
|
45
45
|
input: TInput;
|
|
46
46
|
}) & (object extends TClientContext ? {
|
|
47
|
-
context?: TClientContext;
|
|
47
|
+
context?: TClientContext | undefined;
|
|
48
48
|
} : {
|
|
49
49
|
context: TClientContext;
|
|
50
50
|
}) & Omit<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineQueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>>;
|
|
@@ -54,12 +54,12 @@ type StreamedKeyOptions<TInput> = ((undefined extends TInput ? {
|
|
|
54
54
|
} : {
|
|
55
55
|
input: TInput;
|
|
56
56
|
}) & {
|
|
57
|
-
fnOptions?: SerializableStreamedQueryOptions;
|
|
57
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
58
58
|
}) | {
|
|
59
59
|
key: EntryKey;
|
|
60
60
|
};
|
|
61
61
|
type StreamedOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsIn<TClientContext, TInput, TOutput, TError, TInitialData> & {
|
|
62
|
-
fnOptions?: SerializableStreamedQueryOptions;
|
|
62
|
+
fnOptions?: SerializableStreamedQueryOptions | undefined;
|
|
63
63
|
};
|
|
64
64
|
type StreamedOptionsOut<TOutput, TError, TInitialData extends TOutput | undefined> = QueryOptionsOut<TOutput, TError, TInitialData>;
|
|
65
65
|
type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput, any, any, TPageParam, any>, 'input' | 'initialPageParam'> | {
|
|
@@ -68,14 +68,14 @@ type InfiniteKeyOptions<TInput, TPageParam> = Pick<InfiniteOptionsIn<any, TInput
|
|
|
68
68
|
type InfiniteOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = {
|
|
69
69
|
input: (pageParam: TPageParam) => TInput;
|
|
70
70
|
} & (object extends TClientContext ? {
|
|
71
|
-
context?: TClientContext;
|
|
71
|
+
context?: TClientContext | undefined;
|
|
72
72
|
} : {
|
|
73
73
|
context: TClientContext;
|
|
74
74
|
}) & Omit<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'> & Partial<Pick<DefineInfiniteQueryOptions<TOutput, TError, TPageParam, TInitialData>, 'key' | 'query'>>;
|
|
75
75
|
type InfiniteOptionsOut<TOutput, TError, TPageParam, TInitialData extends UseInfiniteQueryData<TOutput, TPageParam> | undefined> = DefineInfiniteQueryOptionsTagged<TOutput, TError, TPageParam, TInitialData>;
|
|
76
76
|
type MutationKeyOptions<TInput> = Pick<MutationOptionsIn<any, TInput, any, any, any>, 'key'>;
|
|
77
77
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext extends Record<any, any>> = (object extends TClientContext ? {
|
|
78
|
-
context?: TClientContext;
|
|
78
|
+
context?: TClientContext | undefined;
|
|
79
79
|
} : {
|
|
80
80
|
context: TClientContext;
|
|
81
81
|
}) & Omit<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'> & Partial<Pick<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>>;
|
|
@@ -91,14 +91,14 @@ interface SerializableStreamedQueryOptions {
|
|
|
91
91
|
*
|
|
92
92
|
* @default 'reset'
|
|
93
93
|
*/
|
|
94
|
-
refetchMode?: 'append' | 'reset' | 'replace';
|
|
94
|
+
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
95
95
|
/**
|
|
96
96
|
* Limits the number of data chunks stored in the query result.
|
|
97
97
|
* Older chunks are removed when the limit is reached.
|
|
98
98
|
*
|
|
99
99
|
* @default Number.POSITIVE_INFINITY (unlimited)
|
|
100
100
|
*/
|
|
101
|
-
maxChunks?: number;
|
|
101
|
+
maxChunks?: number | undefined;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* A Pinia Colada query function that accumulates streamed chunks into an array,
|
|
@@ -115,14 +115,31 @@ interface OperationKeyPrefixOptions {
|
|
|
115
115
|
* Prepended as the first element of the key when present.
|
|
116
116
|
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
117
117
|
*/
|
|
118
|
-
prefix?: string;
|
|
118
|
+
prefix?: string | undefined;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
interface OperationKeyBaseOptions extends OperationKeyPrefixOptions {
|
|
121
|
+
/**
|
|
122
|
+
* Serializes inputs into JSON-compatible values when building keys.
|
|
123
|
+
* Pass the serializer your link uses so custom types produce consistent keys.
|
|
124
|
+
*
|
|
125
|
+
* @default new RPCJsonSerializer()
|
|
126
|
+
*/
|
|
127
|
+
serializer?: Public<RPCJsonSerializer> | undefined;
|
|
128
|
+
}
|
|
129
|
+
type OperationKeyOptions<TType extends OperationType, TInput> = OperationKeyBaseOptions & {
|
|
130
|
+
type?: TType | undefined;
|
|
131
|
+
input?: PartialDeep<TInput> | undefined;
|
|
132
|
+
fnOptions?: (TType extends 'streamed' ? SerializableStreamedQueryOptions : never) | undefined;
|
|
133
|
+
};
|
|
134
|
+
type OperationKeyContent<TType extends OperationType, TInput> = Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions> & {
|
|
135
|
+
/**
|
|
136
|
+
* Serializer types of non-JSON values in `input`, keyed by their JSON-encoded path,
|
|
137
|
+
* so inputs with the same JSON form (like a `Date` and its ISO string) produce different keys.
|
|
138
|
+
* Keyed by path (not a list) so partial keys still match.
|
|
139
|
+
*/
|
|
140
|
+
inputMeta?: Record<string, string[]> | undefined;
|
|
124
141
|
};
|
|
125
|
-
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options:
|
|
142
|
+
type OperationKey<TType extends OperationType, TInput> = EntryKey & ([path: string[], options: OperationKeyContent<TType, TInput>] | [prefix: string, path: string[], options: OperationKeyContent<TType, TInput>]);
|
|
126
143
|
/**
|
|
127
144
|
* Generate a Pinia Colada entry key for a procedure.
|
|
128
145
|
*
|
|
@@ -135,14 +152,14 @@ declare function generateOperationKey<TType extends OperationType, TInput>(path:
|
|
|
135
152
|
|
|
136
153
|
declare class SharedUtils<TInput> {
|
|
137
154
|
protected readonly path: string[];
|
|
138
|
-
protected readonly options:
|
|
139
|
-
constructor(path: string[], options:
|
|
155
|
+
protected readonly options: OperationKeyBaseOptions;
|
|
156
|
+
constructor(path: string[], options: OperationKeyBaseOptions);
|
|
140
157
|
/**
|
|
141
158
|
* Generate a **partial matching** key for actions like revalidating queries, checking mutation status, etc.
|
|
142
159
|
*
|
|
143
160
|
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
144
161
|
*/
|
|
145
|
-
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>,
|
|
162
|
+
key<TType extends OperationType>(options?: Omit<OperationKeyOptions<TType, TInput>, keyof OperationKeyBaseOptions>): OperationKey<TType, TInput>;
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
interface ProcedureUtilsQueryInterceptorOptions<TClientContext extends ClientContext, TInput> {
|
|
@@ -177,77 +194,77 @@ type ProcedureUtilsMutationInterceptor<TClientContext extends ClientContext, TIn
|
|
|
177
194
|
* or a function that receives per-call options and returns overridden this.options.
|
|
178
195
|
*/
|
|
179
196
|
type ProcedureUtilsModifier<T extends object> = Partial<T> | ((options: T) => T);
|
|
180
|
-
interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends
|
|
197
|
+
interface ProcedureUtilsOptions<TClientContext extends ClientContext, TInput, TOutput, TError> extends OperationKeyBaseOptions {
|
|
181
198
|
/**
|
|
182
199
|
* Key options modifier for .queryKey and .queryOptions
|
|
183
200
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
184
201
|
*/
|
|
185
|
-
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
202
|
+
queryKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
186
203
|
/**
|
|
187
204
|
* Interceptors that intercept query inside .queryOptions, guaranteed to be executed.
|
|
188
205
|
*/
|
|
189
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
206
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
190
207
|
/**
|
|
191
208
|
* Options modifier for .queryOptions
|
|
192
209
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
193
210
|
*/
|
|
194
|
-
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, TOutput | undefined
|
|
211
|
+
queryOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, TOutput, TError, TOutput | undefined>> | undefined;
|
|
195
212
|
/**
|
|
196
213
|
* Key options modifier for .streamedKey and .streamedOptions
|
|
197
214
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
198
215
|
*/
|
|
199
|
-
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput
|
|
216
|
+
streamedKey?: ProcedureUtilsModifier<StreamedKeyOptions<TInput>> | undefined;
|
|
200
217
|
/**
|
|
201
218
|
* Interceptors that intercept query inside .streamedOptions, guaranteed to be executed.
|
|
202
219
|
*/
|
|
203
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
220
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
204
221
|
/**
|
|
205
222
|
* Options modifier for .streamedOptions
|
|
206
223
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
207
224
|
*/
|
|
208
|
-
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, InferStreamedQueryOutput<TOutput> | undefined
|
|
225
|
+
streamedOptions?: ProcedureUtilsModifier<StreamedOptionsIn<TClientContext, TInput, InferStreamedQueryOutput<TOutput>, TError, InferStreamedQueryOutput<TOutput> | undefined>> | undefined;
|
|
209
226
|
/**
|
|
210
227
|
* Key options modifier for .liveKey and .liveOptions
|
|
211
228
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
212
229
|
*/
|
|
213
|
-
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput
|
|
230
|
+
liveKey?: ProcedureUtilsModifier<QueryKeyOptions<TInput>> | undefined;
|
|
214
231
|
/**
|
|
215
232
|
* Interceptors that intercept query inside .liveOptions, guaranteed to be executed.
|
|
216
233
|
*/
|
|
217
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
234
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
218
235
|
/**
|
|
219
236
|
* Options modifier for .liveOptions
|
|
220
237
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
221
238
|
*/
|
|
222
|
-
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, InferLiveQueryOutput<TOutput> | undefined
|
|
239
|
+
liveOptions?: ProcedureUtilsModifier<QueryOptionsIn<TClientContext, TInput, InferLiveQueryOutput<TOutput>, TError, InferLiveQueryOutput<TOutput> | undefined>> | undefined;
|
|
223
240
|
/**
|
|
224
241
|
* Key options modifier for .infiniteKey and .infiniteOptions
|
|
225
242
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
226
243
|
*/
|
|
227
|
-
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown
|
|
244
|
+
infiniteKey?: ProcedureUtilsModifier<InfiniteKeyOptions<TInput, unknown>> | undefined;
|
|
228
245
|
/**
|
|
229
246
|
* Interceptors that intercept query inside .infiniteOptions, guaranteed to be executed.
|
|
230
247
|
*/
|
|
231
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
248
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
232
249
|
/**
|
|
233
250
|
* Options modifier for .infiniteOptions
|
|
234
251
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
235
252
|
*/
|
|
236
|
-
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, UseInfiniteQueryData<TOutput, unknown> | undefined
|
|
253
|
+
infiniteOptions?: ProcedureUtilsModifier<InfiniteOptionsIn<TClientContext, TInput, TOutput, TError, unknown, UseInfiniteQueryData<TOutput, unknown> | undefined>> | undefined;
|
|
237
254
|
/**
|
|
238
255
|
* Key options modifier for .mutationKey and .mutationOptions
|
|
239
256
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
240
257
|
*/
|
|
241
|
-
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions<TInput
|
|
258
|
+
mutationKey?: ProcedureUtilsModifier<MutationKeyOptions<TInput>> | undefined;
|
|
242
259
|
/**
|
|
243
260
|
* Interceptors that intercept mutation inside .mutationOptions, guaranteed to be executed.
|
|
244
261
|
*/
|
|
245
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
262
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
246
263
|
/**
|
|
247
264
|
* Options modifier for .mutationOptions
|
|
248
265
|
* Can be partial options or a function that receives per-call options and returns override this.options.
|
|
249
266
|
*/
|
|
250
|
-
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any
|
|
267
|
+
mutationOptions?: ProcedureUtilsModifier<MutationOptionsIn<TClientContext, TInput, TOutput, TError, Record<any, any>>> | undefined;
|
|
251
268
|
}
|
|
252
269
|
declare function isProcedureUtilsOptions(value: unknown): value is ProcedureUtilsOptions<any, any, any, any>;
|
|
253
270
|
/**
|
|
@@ -382,9 +399,9 @@ type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientCont
|
|
|
382
399
|
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
383
400
|
} & Public<SharedUtils<unknown>>;
|
|
384
401
|
type RouterUtilsScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtilsOptions<UClientContext, UInput, UOutput, UError> : {
|
|
385
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never;
|
|
402
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? RouterUtilsScoped<T[K]> : never) | undefined;
|
|
386
403
|
};
|
|
387
|
-
interface RouterUtilsOptions<T extends AnyNestedClient> extends
|
|
404
|
+
interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyBaseOptions {
|
|
388
405
|
/**
|
|
389
406
|
* Base path for all query keys.
|
|
390
407
|
*
|
|
@@ -394,23 +411,23 @@ interface RouterUtilsOptions<T extends AnyNestedClient> extends OperationKeyPref
|
|
|
394
411
|
/**
|
|
395
412
|
* Interceptors that intercept query inside .queryOptions
|
|
396
413
|
*/
|
|
397
|
-
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
414
|
+
queryInterceptors?: ProcedureUtilsQueryInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
398
415
|
/**
|
|
399
416
|
* Interceptors that intercept query inside .streamedOptions
|
|
400
417
|
*/
|
|
401
|
-
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
418
|
+
streamedInterceptors?: ProcedureUtilsStreamedInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
402
419
|
/**
|
|
403
420
|
* Interceptors that intercept query inside .liveOptions
|
|
404
421
|
*/
|
|
405
|
-
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
422
|
+
liveInterceptors?: ProcedureUtilsLiveInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
406
423
|
/**
|
|
407
424
|
* Interceptors that intercept query inside .infiniteOptions
|
|
408
425
|
*/
|
|
409
|
-
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
426
|
+
infiniteInterceptors?: ProcedureUtilsInfiniteInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
410
427
|
/**
|
|
411
428
|
* Interceptors that intercept mutation inside .mutationOptions
|
|
412
429
|
*/
|
|
413
|
-
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
430
|
+
mutationInterceptors?: ProcedureUtilsMutationInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
414
431
|
/**
|
|
415
432
|
* Per-procedure options following the shape of the router.
|
|
416
433
|
* Allows fine-grained configuration of individual procedure utils
|
|
@@ -462,7 +479,7 @@ declare function createContractJsonifiedUtilsFactory<TClientContext extends Clie
|
|
|
462
479
|
*/
|
|
463
480
|
declare function liveQuery<T>(queryFn: (context: UseQueryFnContext) => Promisable<AsyncIterable<T>>): (context: UseQueryFnContext) => Promise<T>;
|
|
464
481
|
|
|
465
|
-
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>,
|
|
482
|
+
type PiniaColadaMetaOptions<TClientContext extends ClientContext, TInput, TOutput, TError> = Omit<ProcedureUtilsOptions<TClientContext, TInput, TOutput, TError>, keyof OperationKeyBaseOptions>;
|
|
466
483
|
interface PiniaColadaMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
467
484
|
name: '~pinia-colada';
|
|
468
485
|
}
|
|
@@ -500,4 +517,4 @@ declare class ContractOptionsUtilsPlugin<T extends AnyNestedClient = AnyNestedCl
|
|
|
500
517
|
}
|
|
501
518
|
|
|
502
519
|
export { CompositeRouterUtilsPlugin, ContractOptionsUtilsPlugin, OPERATION_CONTEXT_SYMBOL, OPERATION_CONTEXT_SYMBOL as PINIA_COLADA_OPERATION_CONTEXT_SYMBOL, ProcedureUtils, SharedUtils, createContractJsonifiedUtilsFactory, createContractUtilsFactory, createRouterUtils as createORPCVueColadaUtils, createRouterUtils as createPiniaColadaUtils, createRouterUtils, generateOperationKey, getPiniaColadaMeta, isProcedureUtilsOptions, liveQuery, mergeProcedureUtilsOptions, piniaColada, serializableStreamedQuery };
|
|
503
|
-
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, PiniaColadaMetaOptions, PiniaColadaMetaPlugin, OperationContext as PiniaColadaOperationContext, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, UseMutationFnContext, UseQueryFnContext };
|
|
520
|
+
export type { ContractJsonifiedUtilsFactory, ContractJsonifiedUtilsFactoryOptions, ContractUtilsFactory, ContractUtilsFactoryOptions, InferLiveQueryOutput, InferStreamedQueryOutput, InfiniteKeyOptions, InfiniteOptionsIn, InfiniteOptionsOut, MutationKeyOptions, MutationOptionsIn, MutationOptionsOut, OperationContext, OperationKey, OperationKeyBaseOptions, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, PiniaColadaMetaOptions, PiniaColadaMetaPlugin, OperationContext as PiniaColadaOperationContext, ProcedureUtilsInfiniteInterceptor, ProcedureUtilsInfiniteInterceptorOptions, ProcedureUtilsLiveInterceptor, ProcedureUtilsLiveInterceptorOptions, ProcedureUtilsModifier, ProcedureUtilsMutationInterceptor, ProcedureUtilsMutationInterceptorOptions, ProcedureUtilsOptions, ProcedureUtilsQueryInterceptor, ProcedureUtilsQueryInterceptorOptions, ProcedureUtilsStreamedInterceptor, ProcedureUtilsStreamedInterceptorOptions, QueryKeyOptions, QueryOptionsIn, QueryOptionsOut, RouterUtils, RouterUtilsOptions, RouterUtilsPlugin, RouterUtilsScoped, SerializableStreamedQueryOptions, StreamedKeyOptions, StreamedOptionsIn, StreamedOptionsOut, UseMutationFnContext, UseQueryFnContext };
|
package/dist/index.mjs
CHANGED
|
@@ -26,19 +26,6 @@ class CompositeRouterUtilsPlugin {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const serializer = new RPCJsonSerializer();
|
|
30
|
-
function generateOperationKey(path, options = {}) {
|
|
31
|
-
return [
|
|
32
|
-
...options.prefix !== void 0 ? [options.prefix] : [],
|
|
33
|
-
path,
|
|
34
|
-
{
|
|
35
|
-
...options.input !== void 0 ? { input: serializer.serialize(options.input).json } : {},
|
|
36
|
-
...options.type !== void 0 ? { type: options.type } : {},
|
|
37
|
-
...options.fnOptions !== void 0 ? { fnOptions: options.fnOptions } : {}
|
|
38
|
-
}
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
29
|
function liveQuery(queryFn) {
|
|
43
30
|
return async (context) => {
|
|
44
31
|
const { entry, signal } = context;
|
|
@@ -60,6 +47,30 @@ function liveQuery(queryFn) {
|
|
|
60
47
|
};
|
|
61
48
|
}
|
|
62
49
|
|
|
50
|
+
const defaultSerializer = new RPCJsonSerializer();
|
|
51
|
+
function generateOperationKey(path, options = {}) {
|
|
52
|
+
return [
|
|
53
|
+
...options.prefix !== void 0 ? [options.prefix] : [],
|
|
54
|
+
path,
|
|
55
|
+
{
|
|
56
|
+
...options.input !== void 0 ? serializeInput(options.serializer ?? defaultSerializer, options.input) : {},
|
|
57
|
+
...options.type !== void 0 ? { type: options.type } : {},
|
|
58
|
+
...options.fnOptions !== void 0 ? { fnOptions: options.fnOptions } : {}
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
function serializeInput(serializer, input) {
|
|
63
|
+
const { json, meta } = serializer.serializeJson(input);
|
|
64
|
+
if (!meta?.length) {
|
|
65
|
+
return { input: json };
|
|
66
|
+
}
|
|
67
|
+
const inputMeta = {};
|
|
68
|
+
for (const [type, ...segments] of meta) {
|
|
69
|
+
(inputMeta[stringifyJSON(segments)] ??= []).push(type);
|
|
70
|
+
}
|
|
71
|
+
return { input: json, inputMeta };
|
|
72
|
+
}
|
|
73
|
+
|
|
63
74
|
class SharedUtils {
|
|
64
75
|
constructor(path, options) {
|
|
65
76
|
this.path = path;
|
|
@@ -71,7 +82,7 @@ class SharedUtils {
|
|
|
71
82
|
* @see {@link https://orpc.dev/docs/integrations/pinia-colada#querymutation-key | Pinia Colada Integration - Query/Mutation Key}
|
|
72
83
|
*/
|
|
73
84
|
key(options = {}) {
|
|
74
|
-
return generateOperationKey(this.path, { ...options, prefix: this.options.prefix });
|
|
85
|
+
return generateOperationKey(this.path, { ...options, prefix: this.options.prefix, serializer: this.options.serializer });
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
|
@@ -141,6 +152,10 @@ function isProcedureUtilsOptions(value) {
|
|
|
141
152
|
if (typeof value[key] !== "string") {
|
|
142
153
|
return false;
|
|
143
154
|
}
|
|
155
|
+
} else if (key === "serializer") {
|
|
156
|
+
if (!isTypescriptObject(value[key]) || typeof value[key].serializeJson !== "function") {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
144
159
|
} else if (PROCEDURE_UTILS_INTERCEPTOR_KEYS.includes(key)) {
|
|
145
160
|
if (!Array.isArray(value[key]) || value[key].some((i) => typeof i !== "function")) {
|
|
146
161
|
return false;
|
|
@@ -204,7 +219,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
204
219
|
} else if (this.options.queryKey) {
|
|
205
220
|
optionsIn = { ...this.options.queryKey, ...optionsIn };
|
|
206
221
|
}
|
|
207
|
-
const key = optionsIn.key ??
|
|
222
|
+
const key = optionsIn.key ?? this.key({ type: "query", input: optionsIn.input });
|
|
208
223
|
return key;
|
|
209
224
|
}
|
|
210
225
|
/**
|
|
@@ -261,7 +276,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
261
276
|
} else if (this.options.streamedKey) {
|
|
262
277
|
optionsIn = { ...this.options.streamedKey, ...optionsIn };
|
|
263
278
|
}
|
|
264
|
-
const key = optionsIn.key ??
|
|
279
|
+
const key = optionsIn.key ?? this.key({ type: "streamed", input: optionsIn.input, fnOptions: optionsIn.fnOptions });
|
|
265
280
|
return key;
|
|
266
281
|
}
|
|
267
282
|
/**
|
|
@@ -327,7 +342,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
327
342
|
} else if (this.options.liveKey) {
|
|
328
343
|
optionsIn = { ...this.options.liveKey, ...optionsIn };
|
|
329
344
|
}
|
|
330
|
-
const key = optionsIn.key ??
|
|
345
|
+
const key = optionsIn.key ?? this.key({ type: "live", input: optionsIn.input });
|
|
331
346
|
return key;
|
|
332
347
|
}
|
|
333
348
|
/**
|
|
@@ -389,8 +404,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
389
404
|
} else if (this.options.infiniteKey) {
|
|
390
405
|
optionsIn = { ...this.options.infiniteKey, ...optionsIn };
|
|
391
406
|
}
|
|
392
|
-
const key = optionsIn.key ??
|
|
393
|
-
prefix: this.options.prefix,
|
|
407
|
+
const key = optionsIn.key ?? this.key({
|
|
394
408
|
type: "infinite",
|
|
395
409
|
input: optionsIn.input(
|
|
396
410
|
typeof optionsIn.initialPageParam === "function" ? optionsIn.initialPageParam() : optionsIn.initialPageParam
|
|
@@ -451,7 +465,7 @@ class ProcedureUtils extends SharedUtils {
|
|
|
451
465
|
} else if (this.options.mutationKey) {
|
|
452
466
|
optionsIn = { ...this.options.mutationKey, ...optionsIn };
|
|
453
467
|
}
|
|
454
|
-
const key = optionsIn.key ?? ((input) =>
|
|
468
|
+
const key = optionsIn.key ?? ((input) => this.key({ type: "mutation", input }));
|
|
455
469
|
return key;
|
|
456
470
|
}
|
|
457
471
|
/**
|
|
@@ -511,6 +525,7 @@ function createRouterUtilsInternal(client, options, plugin) {
|
|
|
511
525
|
plugin.initProcedureOptions(path, mergeProcedureUtilsOptions(
|
|
512
526
|
pick(options, [
|
|
513
527
|
"prefix",
|
|
528
|
+
"serializer",
|
|
514
529
|
"queryInterceptors",
|
|
515
530
|
"streamedInterceptors",
|
|
516
531
|
"liveInterceptors",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/pinia-colada",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.45",
|
|
5
5
|
"description": "Pinia Colada integration for oRPC: typesafe queries and mutations for Vue",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"vue": ">=3.5.17"
|
|
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.45",
|
|
45
|
+
"@orpc/contract": "2.0.0-beta.45",
|
|
46
|
+
"@orpc/openapi": "2.0.0-beta.45",
|
|
47
|
+
"@orpc/shared": "2.0.0-beta.45"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@pinia/colada": "^1.4.8",
|
|
51
51
|
"@vue/test-utils": "^2.5.1",
|
|
52
|
-
"pinia": "^4.0
|
|
53
|
-
"vue": "^3.5.
|
|
54
|
-
"zod": "^4.6.
|
|
52
|
+
"pinia": "^4.1.0",
|
|
53
|
+
"vue": "^3.5.44",
|
|
54
|
+
"zod": "^4.6.7"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"type:check": "tsc -b"
|