@orpc/shared 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 +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.mjs +234 -217
- package/package.json +5 -5
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
|
@@ -8,6 +8,16 @@ declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>):
|
|
|
8
8
|
|
|
9
9
|
declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Default maximum digits, excluding a leading `-`, when parsing a `bigint` from a string.
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_MAX_BIGINT_DIGITS = 4300;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a `bigint.toString()` string, or returns `undefined` if it is invalid or has more than `maxDigits` digits.
|
|
17
|
+
* The length is checked first, since `BigInt()` is super-linear in the digit count.
|
|
18
|
+
*/
|
|
19
|
+
declare function parseBigIntString(value: string, maxDigits: number): bigint | undefined;
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* Load Request/Response/Blob/File/.. to a buffer (Uint8Array<ArrayBuffer>).
|
|
13
23
|
*
|
|
@@ -20,6 +30,11 @@ declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>): ReturnT
|
|
|
20
30
|
* - a Uint8Array view over the source bytes.
|
|
21
31
|
*/
|
|
22
32
|
declare function toStringOrBytes(source: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>): string | Awaited<ReturnType<Blob['bytes']>>;
|
|
33
|
+
/**
|
|
34
|
+
* Encodes bytes to standard, padded base64, as data URLs and many protocols require.
|
|
35
|
+
* Prefers the native `toBase64` or `Buffer`, which are far faster for large outputs.
|
|
36
|
+
*/
|
|
37
|
+
declare function encodeBase64(bytes: Uint8Array): string;
|
|
23
38
|
|
|
24
39
|
declare function isDeepEqual(a: unknown, b: unknown): boolean;
|
|
25
40
|
|
|
@@ -244,14 +259,14 @@ interface WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>
|
|
|
244
259
|
* Useful when you want execution to happen within a specific context,
|
|
245
260
|
* such as AsyncLocalStorage.
|
|
246
261
|
*/
|
|
247
|
-
runWith?: <T>(run: () => Promise<T>) => Promisable<T
|
|
248
|
-
mapResult?: (result: IteratorResult<TYield, TReturn>) => Promisable<IteratorResult<TMappedYield, TMappedReturn
|
|
249
|
-
mapError?: (error: ThrowableError) => Promisable<ThrowableError
|
|
250
|
-
onError?: (error: ThrowableError) => Promisable<void
|
|
262
|
+
runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
|
|
263
|
+
mapResult?: ((result: IteratorResult<TYield, TReturn>) => Promisable<IteratorResult<TMappedYield, TMappedReturn>>) | undefined;
|
|
264
|
+
mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
|
|
265
|
+
onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
|
|
251
266
|
/**
|
|
252
267
|
* Execute after the stream finishes or is cancelled.
|
|
253
268
|
*/
|
|
254
|
-
onFinish?: () => Promisable<void
|
|
269
|
+
onFinish?: (() => Promisable<void>) | undefined;
|
|
255
270
|
}
|
|
256
271
|
declare function wrapAsyncIterator<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { runWith, mapResult, mapError, onError, onFinish }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): NoInfer<AsyncIteratorClass<TMappedYield, TMappedReturn>>;
|
|
257
272
|
declare function traceAsyncIterator<T, TReturn, TNext>(options: StartSpanOptions | string, iterator: AsyncIterator<T, TReturn, TNext>): AsyncIteratorClass<T, TReturn, TNext>;
|
|
@@ -264,21 +279,21 @@ interface ConsumeAsyncIteratorOptions<T, TReturn, TError> {
|
|
|
264
279
|
/**
|
|
265
280
|
* Called once error happens
|
|
266
281
|
*/
|
|
267
|
-
onError?: (error: TError) => void;
|
|
282
|
+
onError?: ((error: TError) => void) | undefined;
|
|
268
283
|
/**
|
|
269
284
|
* Called once AsyncIteratorObject is done
|
|
270
285
|
*
|
|
271
286
|
* @remarks
|
|
272
287
|
* **Note**: If iterator is canceled, `undefined` can be passed on success
|
|
273
288
|
*/
|
|
274
|
-
onSuccess?: (value: TReturn | undefined) => void;
|
|
289
|
+
onSuccess?: ((value: TReturn | undefined) => void) | undefined;
|
|
275
290
|
/**
|
|
276
291
|
* Called once after onError or onSuccess
|
|
277
292
|
*
|
|
278
293
|
* @remarks
|
|
279
294
|
* **Note**: If iterator is canceled, `undefined` can be passed on success
|
|
280
295
|
*/
|
|
281
|
-
onFinish?: (state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void;
|
|
296
|
+
onFinish?: ((state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void) | undefined;
|
|
282
297
|
}
|
|
283
298
|
/**
|
|
284
299
|
* Consumes an AsyncIteratorObject with lifecycle callbacks.
|
|
@@ -398,7 +413,7 @@ declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args:
|
|
|
398
413
|
declare function override<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
|
|
399
414
|
|
|
400
415
|
interface AsyncIdQueueCloseOptions {
|
|
401
|
-
id?: string;
|
|
416
|
+
id?: string | undefined;
|
|
402
417
|
reason?: unknown;
|
|
403
418
|
}
|
|
404
419
|
declare class AsyncIdQueue<T> {
|
|
@@ -434,7 +449,7 @@ type ReadableStreamReadResult<T> = {
|
|
|
434
449
|
value: T;
|
|
435
450
|
} | {
|
|
436
451
|
done: true;
|
|
437
|
-
value?:
|
|
452
|
+
value?: T | undefined;
|
|
438
453
|
};
|
|
439
454
|
interface WrapReadableStreamOptions<T, TMapped> {
|
|
440
455
|
/**
|
|
@@ -442,14 +457,14 @@ interface WrapReadableStreamOptions<T, TMapped> {
|
|
|
442
457
|
* Useful when you want execution to happen within a specific context,
|
|
443
458
|
* such as AsyncLocalStorage.
|
|
444
459
|
*/
|
|
445
|
-
runWith?: <T>(run: () => Promise<T>) => Promisable<T
|
|
446
|
-
mapResult?: (result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped
|
|
447
|
-
mapError?: (error: ThrowableError) => Promisable<ThrowableError
|
|
448
|
-
onError?: (error: ThrowableError) => Promisable<void
|
|
460
|
+
runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
|
|
461
|
+
mapResult?: ((result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped>>) | undefined;
|
|
462
|
+
mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
|
|
463
|
+
onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
|
|
449
464
|
/**
|
|
450
465
|
* Guaranteed to execute exactly once after the stream finishes or is cancelled.
|
|
451
466
|
*/
|
|
452
|
-
onFinish?: () => Promisable<void
|
|
467
|
+
onFinish?: (() => Promisable<void>) | undefined;
|
|
453
468
|
}
|
|
454
469
|
declare function wrapReadableStream<T, TMapped = T>(stream: ReadableStream<T>, { runWith, mapResult, mapError, onError, onFinish }: WrapReadableStreamOptions<T, TMapped>): NoInfer<ReadableStream<TMapped>>;
|
|
455
470
|
declare function traceReadableStream<T>(options: StartSpanOptions | string, stream: ReadableStream<T>): ReadableStream<T>;
|
|
@@ -459,7 +474,7 @@ declare function traceReadableStream<T>(options: StartSpanOptions | string, stre
|
|
|
459
474
|
* @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
|
|
460
475
|
*/
|
|
461
476
|
declare function streamToAsyncIteratorObject<T>(stream: ReadableStream<T>, { signal }?: {
|
|
462
|
-
signal?:
|
|
477
|
+
signal?: AbortSignal | undefined;
|
|
463
478
|
}): AsyncIteratorClass<T>;
|
|
464
479
|
/**
|
|
465
480
|
* Converts an `AsyncIterator` into a `ReadableStream`.
|
|
@@ -473,5 +488,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
473
488
|
*/
|
|
474
489
|
declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
475
490
|
|
|
476
|
-
export { AsyncIdQueue, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
|
491
|
+
export { AsyncIdQueue, DEFAULT_MAX_BIGINT_DIGITS, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, encodeBase64, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, parseBigIntString, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
|
477
492
|
export type { AnyFunction, AsyncIdQueueCloseOptions, ConsumeAsyncIteratorOptions, DistributiveOmit, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OnFinishState, OrderablePlugin, PromiseWithError, Public, ReadableStreamReadResult, Registry, Segment, StartSpanOptions, ThrowableError, Tracer, TracingAttributeValue, TracingException, TracingExceptionLevel, TracingHeaders, TracingSpan, Value, WrapAsyncIteratorOptions, WrapReadableStreamOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,16 @@ declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>):
|
|
|
8
8
|
|
|
9
9
|
declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Default maximum digits, excluding a leading `-`, when parsing a `bigint` from a string.
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_MAX_BIGINT_DIGITS = 4300;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a `bigint.toString()` string, or returns `undefined` if it is invalid or has more than `maxDigits` digits.
|
|
17
|
+
* The length is checked first, since `BigInt()` is super-linear in the digit count.
|
|
18
|
+
*/
|
|
19
|
+
declare function parseBigIntString(value: string, maxDigits: number): bigint | undefined;
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* Load Request/Response/Blob/File/.. to a buffer (Uint8Array<ArrayBuffer>).
|
|
13
23
|
*
|
|
@@ -20,6 +30,11 @@ declare function loadBytes(source: Pick<Blob, 'arrayBuffer' | 'bytes'>): ReturnT
|
|
|
20
30
|
* - a Uint8Array view over the source bytes.
|
|
21
31
|
*/
|
|
22
32
|
declare function toStringOrBytes(source: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>): string | Awaited<ReturnType<Blob['bytes']>>;
|
|
33
|
+
/**
|
|
34
|
+
* Encodes bytes to standard, padded base64, as data URLs and many protocols require.
|
|
35
|
+
* Prefers the native `toBase64` or `Buffer`, which are far faster for large outputs.
|
|
36
|
+
*/
|
|
37
|
+
declare function encodeBase64(bytes: Uint8Array): string;
|
|
23
38
|
|
|
24
39
|
declare function isDeepEqual(a: unknown, b: unknown): boolean;
|
|
25
40
|
|
|
@@ -244,14 +259,14 @@ interface WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>
|
|
|
244
259
|
* Useful when you want execution to happen within a specific context,
|
|
245
260
|
* such as AsyncLocalStorage.
|
|
246
261
|
*/
|
|
247
|
-
runWith?: <T>(run: () => Promise<T>) => Promisable<T
|
|
248
|
-
mapResult?: (result: IteratorResult<TYield, TReturn>) => Promisable<IteratorResult<TMappedYield, TMappedReturn
|
|
249
|
-
mapError?: (error: ThrowableError) => Promisable<ThrowableError
|
|
250
|
-
onError?: (error: ThrowableError) => Promisable<void
|
|
262
|
+
runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
|
|
263
|
+
mapResult?: ((result: IteratorResult<TYield, TReturn>) => Promisable<IteratorResult<TMappedYield, TMappedReturn>>) | undefined;
|
|
264
|
+
mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
|
|
265
|
+
onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
|
|
251
266
|
/**
|
|
252
267
|
* Execute after the stream finishes or is cancelled.
|
|
253
268
|
*/
|
|
254
|
-
onFinish?: () => Promisable<void
|
|
269
|
+
onFinish?: (() => Promisable<void>) | undefined;
|
|
255
270
|
}
|
|
256
271
|
declare function wrapAsyncIterator<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { runWith, mapResult, mapError, onError, onFinish }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): NoInfer<AsyncIteratorClass<TMappedYield, TMappedReturn>>;
|
|
257
272
|
declare function traceAsyncIterator<T, TReturn, TNext>(options: StartSpanOptions | string, iterator: AsyncIterator<T, TReturn, TNext>): AsyncIteratorClass<T, TReturn, TNext>;
|
|
@@ -264,21 +279,21 @@ interface ConsumeAsyncIteratorOptions<T, TReturn, TError> {
|
|
|
264
279
|
/**
|
|
265
280
|
* Called once error happens
|
|
266
281
|
*/
|
|
267
|
-
onError?: (error: TError) => void;
|
|
282
|
+
onError?: ((error: TError) => void) | undefined;
|
|
268
283
|
/**
|
|
269
284
|
* Called once AsyncIteratorObject is done
|
|
270
285
|
*
|
|
271
286
|
* @remarks
|
|
272
287
|
* **Note**: If iterator is canceled, `undefined` can be passed on success
|
|
273
288
|
*/
|
|
274
|
-
onSuccess?: (value: TReturn | undefined) => void;
|
|
289
|
+
onSuccess?: ((value: TReturn | undefined) => void) | undefined;
|
|
275
290
|
/**
|
|
276
291
|
* Called once after onError or onSuccess
|
|
277
292
|
*
|
|
278
293
|
* @remarks
|
|
279
294
|
* **Note**: If iterator is canceled, `undefined` can be passed on success
|
|
280
295
|
*/
|
|
281
|
-
onFinish?: (state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void;
|
|
296
|
+
onFinish?: ((state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void) | undefined;
|
|
282
297
|
}
|
|
283
298
|
/**
|
|
284
299
|
* Consumes an AsyncIteratorObject with lifecycle callbacks.
|
|
@@ -398,7 +413,7 @@ declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args:
|
|
|
398
413
|
declare function override<T extends object, U extends object>(target: Value<T>, partial: U): U & Omit<T, keyof U>;
|
|
399
414
|
|
|
400
415
|
interface AsyncIdQueueCloseOptions {
|
|
401
|
-
id?: string;
|
|
416
|
+
id?: string | undefined;
|
|
402
417
|
reason?: unknown;
|
|
403
418
|
}
|
|
404
419
|
declare class AsyncIdQueue<T> {
|
|
@@ -434,7 +449,7 @@ type ReadableStreamReadResult<T> = {
|
|
|
434
449
|
value: T;
|
|
435
450
|
} | {
|
|
436
451
|
done: true;
|
|
437
|
-
value?:
|
|
452
|
+
value?: T | undefined;
|
|
438
453
|
};
|
|
439
454
|
interface WrapReadableStreamOptions<T, TMapped> {
|
|
440
455
|
/**
|
|
@@ -442,14 +457,14 @@ interface WrapReadableStreamOptions<T, TMapped> {
|
|
|
442
457
|
* Useful when you want execution to happen within a specific context,
|
|
443
458
|
* such as AsyncLocalStorage.
|
|
444
459
|
*/
|
|
445
|
-
runWith?: <T>(run: () => Promise<T>) => Promisable<T
|
|
446
|
-
mapResult?: (result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped
|
|
447
|
-
mapError?: (error: ThrowableError) => Promisable<ThrowableError
|
|
448
|
-
onError?: (error: ThrowableError) => Promisable<void
|
|
460
|
+
runWith?: (<T>(run: () => Promise<T>) => Promisable<T>) | undefined;
|
|
461
|
+
mapResult?: ((result: ReadableStreamReadResult<T>) => Promisable<ReadableStreamReadResult<TMapped>>) | undefined;
|
|
462
|
+
mapError?: ((error: ThrowableError) => Promisable<ThrowableError>) | undefined;
|
|
463
|
+
onError?: ((error: ThrowableError) => Promisable<void>) | undefined;
|
|
449
464
|
/**
|
|
450
465
|
* Guaranteed to execute exactly once after the stream finishes or is cancelled.
|
|
451
466
|
*/
|
|
452
|
-
onFinish?: () => Promisable<void
|
|
467
|
+
onFinish?: (() => Promisable<void>) | undefined;
|
|
453
468
|
}
|
|
454
469
|
declare function wrapReadableStream<T, TMapped = T>(stream: ReadableStream<T>, { runWith, mapResult, mapError, onError, onFinish }: WrapReadableStreamOptions<T, TMapped>): NoInfer<ReadableStream<TMapped>>;
|
|
455
470
|
declare function traceReadableStream<T>(options: StartSpanOptions | string, stream: ReadableStream<T>): ReadableStream<T>;
|
|
@@ -459,7 +474,7 @@ declare function traceReadableStream<T>(options: StartSpanOptions | string, stre
|
|
|
459
474
|
* @see {@link https://orpc.dev/docs/integrations/ai-sdk | AI SDK Integration}
|
|
460
475
|
*/
|
|
461
476
|
declare function streamToAsyncIteratorObject<T>(stream: ReadableStream<T>, { signal }?: {
|
|
462
|
-
signal?:
|
|
477
|
+
signal?: AbortSignal | undefined;
|
|
463
478
|
}): AsyncIteratorClass<T>;
|
|
464
479
|
/**
|
|
465
480
|
* Converts an `AsyncIterator` into a `ReadableStream`.
|
|
@@ -473,5 +488,5 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
473
488
|
*/
|
|
474
489
|
declare function asyncIteratorToUnproxiedDataStream<T>(iterator: AsyncIterator<T>): ReadableStream<T>;
|
|
475
490
|
|
|
476
|
-
export { AsyncIdQueue, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
|
491
|
+
export { AsyncIdQueue, DEFAULT_MAX_BIGINT_DIGITS, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, encodeBase64, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, parseBigIntString, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
|
477
492
|
export type { AnyFunction, AsyncIdQueueCloseOptions, ConsumeAsyncIteratorOptions, DistributiveOmit, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, MaybeOptionalOptions, OnFinishState, OrderablePlugin, PromiseWithError, Public, ReadableStreamReadResult, Registry, Segment, StartSpanOptions, ThrowableError, Tracer, TracingAttributeValue, TracingException, TracingExceptionLevel, TracingHeaders, TracingSpan, Value, WrapAsyncIteratorOptions, WrapReadableStreamOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { safeDecodeURIComponent, safeEncodeURIComponent, AbortError, AsyncIteratorClass,
|
|
1
|
+
import { getOrBind, isTypescriptObject, safeDecodeURIComponent, safeEncodeURIComponent, AbortError, AsyncIteratorClass, isAsyncIteratorObject, throwIfAborted } from '@standard-server/shared';
|
|
2
2
|
export { AbortError, AsyncIteratorClass, SequentialIdGenerator, getOrBind, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, safeDecodeURIComponent, safeEncodeURIComponent, sequential, sleep, stringifyJSON, throwIfAborted, toArray } from '@standard-server/shared';
|
|
3
3
|
|
|
4
4
|
function resolveMaybeOptionalOptions(rest) {
|
|
@@ -10,6 +10,16 @@ function splitInHalf(arr) {
|
|
|
10
10
|
return [arr.slice(0, half), arr.slice(half)];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
const DEFAULT_MAX_BIGINT_DIGITS = 4300;
|
|
14
|
+
const BIGINT_PATTERN = /^-?(?:0|[1-9]\d*)$/;
|
|
15
|
+
function parseBigIntString(value, maxDigits) {
|
|
16
|
+
const digits = value.startsWith("-") ? value.length - 1 : value.length;
|
|
17
|
+
if (digits > maxDigits || !BIGINT_PATTERN.test(value)) {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
return BigInt(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
async function loadBytes(source) {
|
|
14
24
|
if (typeof source.bytes === "function") {
|
|
15
25
|
return source.bytes();
|
|
@@ -54,28 +64,236 @@ function concatBytes(items) {
|
|
|
54
64
|
}
|
|
55
65
|
return result;
|
|
56
66
|
}
|
|
67
|
+
function encodeBase64(bytes) {
|
|
68
|
+
const native = bytes;
|
|
69
|
+
if (typeof native.toBase64 === "function") {
|
|
70
|
+
return native.toBase64();
|
|
71
|
+
}
|
|
72
|
+
const NodeBuffer = globalThis.process?.getBuiltinModule?.("node:buffer")?.Buffer;
|
|
73
|
+
if (NodeBuffer !== void 0) {
|
|
74
|
+
return NodeBuffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
75
|
+
}
|
|
76
|
+
const chunkSize = 8192;
|
|
77
|
+
let binaryString = "";
|
|
78
|
+
for (let i = 0; i < bytes.length; i += chunkSize) {
|
|
79
|
+
binaryString += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
|
|
80
|
+
}
|
|
81
|
+
return btoa(binaryString);
|
|
82
|
+
}
|
|
57
83
|
|
|
58
|
-
function
|
|
59
|
-
|
|
84
|
+
function findDeepMatches(check, payload, segments = [], maps = [], values = []) {
|
|
85
|
+
if (check(payload)) {
|
|
86
|
+
maps.push(segments);
|
|
87
|
+
values.push(payload);
|
|
88
|
+
} else if (Array.isArray(payload)) {
|
|
89
|
+
payload.forEach((v, i) => {
|
|
90
|
+
findDeepMatches(check, v, [...segments, i], maps, values);
|
|
91
|
+
});
|
|
92
|
+
} else if (isPlainObject(payload)) {
|
|
93
|
+
for (const key of Object.keys(payload)) {
|
|
94
|
+
findDeepMatches(check, payload[key], [...segments, key], maps, values);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { maps, values };
|
|
60
98
|
}
|
|
61
|
-
function
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
99
|
+
function getConstructor(value) {
|
|
100
|
+
if (!isTypescriptObject(value)) {
|
|
101
|
+
return null;
|
|
64
102
|
}
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
return Object.getPrototypeOf(value)?.constructor;
|
|
104
|
+
}
|
|
105
|
+
function* getConstructors(value) {
|
|
106
|
+
if (!isTypescriptObject(value)) {
|
|
107
|
+
return;
|
|
67
108
|
}
|
|
68
|
-
|
|
69
|
-
|
|
109
|
+
let proto = Object.getPrototypeOf(value);
|
|
110
|
+
while (proto != null) {
|
|
111
|
+
if (proto.constructor) {
|
|
112
|
+
yield proto.constructor;
|
|
113
|
+
}
|
|
114
|
+
proto = Object.getPrototypeOf(proto);
|
|
70
115
|
}
|
|
71
|
-
|
|
116
|
+
}
|
|
117
|
+
function isPlainObject(value) {
|
|
118
|
+
if (!value || typeof value !== "object") {
|
|
72
119
|
return false;
|
|
73
120
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
121
|
+
const proto = Object.getPrototypeOf(value);
|
|
122
|
+
return proto === Object.prototype || !proto || !proto.constructor;
|
|
123
|
+
}
|
|
124
|
+
function getOwn(object, key) {
|
|
125
|
+
return Object.hasOwn(object, key) ? object[key] : void 0;
|
|
126
|
+
}
|
|
127
|
+
function get(object, path) {
|
|
128
|
+
let current = object;
|
|
129
|
+
for (const key of path) {
|
|
130
|
+
if (!isTypescriptObject(current)) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
current = getOwn(current, key);
|
|
134
|
+
}
|
|
135
|
+
return current;
|
|
136
|
+
}
|
|
137
|
+
function set(root, path, value) {
|
|
138
|
+
let current = root;
|
|
139
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
140
|
+
const key = path[i];
|
|
141
|
+
const next = getOwn(current, key);
|
|
142
|
+
if (!isTypescriptObject(next)) {
|
|
143
|
+
const child = {};
|
|
144
|
+
setOwn(current, key, child);
|
|
145
|
+
current = child;
|
|
146
|
+
} else {
|
|
147
|
+
current = next;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
setOwn(current, path.at(-1), value);
|
|
151
|
+
}
|
|
152
|
+
function setOwn(object, key, value) {
|
|
153
|
+
if (key === "__proto__") {
|
|
154
|
+
Object.defineProperty(object, key, {
|
|
155
|
+
value,
|
|
156
|
+
writable: true,
|
|
157
|
+
enumerable: true,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
object[key] = value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function mergeTwoLevels(first, second) {
|
|
165
|
+
if (!isPlainObject(first) || !isPlainObject(second)) {
|
|
166
|
+
return second;
|
|
167
|
+
}
|
|
168
|
+
const result = { ...first, ...second };
|
|
169
|
+
for (const key of Object.keys(second)) {
|
|
170
|
+
if (!Object.hasOwn(first, key)) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const firstValue = first[key];
|
|
174
|
+
const secondValue = second[key];
|
|
175
|
+
if (isPlainObject(firstValue) && isPlainObject(secondValue)) {
|
|
176
|
+
result[key] = { ...firstValue, ...secondValue };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
function omit(obj, keys) {
|
|
182
|
+
const result = { ...obj };
|
|
183
|
+
for (const key of keys) {
|
|
184
|
+
delete result[key];
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function pick(obj, keys) {
|
|
189
|
+
const result = {};
|
|
190
|
+
for (const key of keys) {
|
|
191
|
+
if (Object.hasOwn(obj, key)) {
|
|
192
|
+
result[key] = obj[key];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
function clone(value) {
|
|
198
|
+
return cloneWithVisited(value, /* @__PURE__ */ new WeakMap());
|
|
199
|
+
}
|
|
200
|
+
function cloneWithVisited(value, visited) {
|
|
201
|
+
if (Array.isArray(value)) {
|
|
202
|
+
const existing = visited.get(value);
|
|
203
|
+
if (existing) {
|
|
204
|
+
return existing;
|
|
205
|
+
}
|
|
206
|
+
const result = [];
|
|
207
|
+
visited.set(value, result);
|
|
208
|
+
for (const item of value) {
|
|
209
|
+
result.push(cloneWithVisited(item, visited));
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
if (isPlainObject(value)) {
|
|
214
|
+
const existing = visited.get(value);
|
|
215
|
+
if (existing) {
|
|
216
|
+
return existing;
|
|
217
|
+
}
|
|
218
|
+
const result = {};
|
|
219
|
+
visited.set(value, result);
|
|
220
|
+
for (const key of Object.keys(value)) {
|
|
221
|
+
setOwn(result, key, cloneWithVisited(value[key], visited));
|
|
222
|
+
}
|
|
223
|
+
for (const sym of Object.getOwnPropertySymbols(value)) {
|
|
224
|
+
setOwn(result, sym, cloneWithVisited(value[sym], visited));
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
function copyOnWrite(parent, key, original) {
|
|
231
|
+
const value = parent[key];
|
|
232
|
+
if (value !== original) {
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
let copy;
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
copy = value.slice();
|
|
238
|
+
} else if (isPlainObject(value)) {
|
|
239
|
+
copy = { ...value };
|
|
240
|
+
} else {
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
setOwn(parent, key, copy);
|
|
244
|
+
return copy;
|
|
245
|
+
}
|
|
246
|
+
function isPropertyKey(value) {
|
|
247
|
+
const type = typeof value;
|
|
248
|
+
return type === "string" || type === "number" || type === "symbol";
|
|
249
|
+
}
|
|
250
|
+
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
251
|
+
const e = function() {
|
|
252
|
+
};
|
|
253
|
+
e.prototype = /* @__PURE__ */ Object.create(null);
|
|
254
|
+
Object.freeze(e.prototype);
|
|
255
|
+
return e;
|
|
256
|
+
})();
|
|
257
|
+
function bindMethods(obj, options = {}) {
|
|
258
|
+
const unbound = new Set(options.unbound);
|
|
259
|
+
const methods = new NullProtoObj();
|
|
260
|
+
let current = obj;
|
|
261
|
+
while (current && current !== Object.prototype) {
|
|
262
|
+
for (const key of Object.getOwnPropertyNames(current)) {
|
|
263
|
+
if (key === "constructor" || key in methods) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
const val = getOrBind(obj, key, { bind: !unbound.has(key) });
|
|
267
|
+
if (typeof val === "function") {
|
|
268
|
+
methods[key] = val;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
for (const sym of Object.getOwnPropertySymbols(current)) {
|
|
272
|
+
if (sym in methods) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const val = getOrBind(obj, sym, { bind: !unbound.has(sym) });
|
|
276
|
+
if (typeof val === "function") {
|
|
277
|
+
methods[sym] = val;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
current = Object.getPrototypeOf(current);
|
|
281
|
+
}
|
|
282
|
+
return methods;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function isDeepEqual(a, b) {
|
|
286
|
+
return isDeepEqualInternal(a, b, /* @__PURE__ */ new WeakMap());
|
|
287
|
+
}
|
|
288
|
+
function isDeepEqualInternal(a, b, visited) {
|
|
289
|
+
if (Object.is(a, b)) {
|
|
290
|
+
return true;
|
|
77
291
|
}
|
|
78
|
-
if (isArray
|
|
292
|
+
if (Array.isArray(a)) {
|
|
293
|
+
if (!Array.isArray(b) || a.length !== b.length) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
} else if (!isPlainObject(a) || !isPlainObject(b)) {
|
|
79
297
|
return false;
|
|
80
298
|
}
|
|
81
299
|
const aRecord = a;
|
|
@@ -534,207 +752,6 @@ function override(target, partial) {
|
|
|
534
752
|
return proxy;
|
|
535
753
|
}
|
|
536
754
|
|
|
537
|
-
function findDeepMatches(check, payload, segments = [], maps = [], values = []) {
|
|
538
|
-
if (check(payload)) {
|
|
539
|
-
maps.push(segments);
|
|
540
|
-
values.push(payload);
|
|
541
|
-
} else if (Array.isArray(payload)) {
|
|
542
|
-
payload.forEach((v, i) => {
|
|
543
|
-
findDeepMatches(check, v, [...segments, i], maps, values);
|
|
544
|
-
});
|
|
545
|
-
} else if (isPlainObject(payload)) {
|
|
546
|
-
for (const key of Object.keys(payload)) {
|
|
547
|
-
findDeepMatches(check, payload[key], [...segments, key], maps, values);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return { maps, values };
|
|
551
|
-
}
|
|
552
|
-
function getConstructor(value) {
|
|
553
|
-
if (!isTypescriptObject(value)) {
|
|
554
|
-
return null;
|
|
555
|
-
}
|
|
556
|
-
return Object.getPrototypeOf(value)?.constructor;
|
|
557
|
-
}
|
|
558
|
-
function* getConstructors(value) {
|
|
559
|
-
if (!isTypescriptObject(value)) {
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
let proto = Object.getPrototypeOf(value);
|
|
563
|
-
while (proto != null) {
|
|
564
|
-
if (proto.constructor) {
|
|
565
|
-
yield proto.constructor;
|
|
566
|
-
}
|
|
567
|
-
proto = Object.getPrototypeOf(proto);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
function isPlainObject(value) {
|
|
571
|
-
if (!value || typeof value !== "object") {
|
|
572
|
-
return false;
|
|
573
|
-
}
|
|
574
|
-
const proto = Object.getPrototypeOf(value);
|
|
575
|
-
return proto === Object.prototype || !proto || !proto.constructor;
|
|
576
|
-
}
|
|
577
|
-
function getOwn(object, key) {
|
|
578
|
-
return Object.hasOwn(object, key) ? object[key] : void 0;
|
|
579
|
-
}
|
|
580
|
-
function get(object, path) {
|
|
581
|
-
let current = object;
|
|
582
|
-
for (const key of path) {
|
|
583
|
-
if (!isTypescriptObject(current)) {
|
|
584
|
-
return void 0;
|
|
585
|
-
}
|
|
586
|
-
current = getOwn(current, key);
|
|
587
|
-
}
|
|
588
|
-
return current;
|
|
589
|
-
}
|
|
590
|
-
function set(root, path, value) {
|
|
591
|
-
let current = root;
|
|
592
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
593
|
-
const key = path[i];
|
|
594
|
-
const next = getOwn(current, key);
|
|
595
|
-
if (!isTypescriptObject(next)) {
|
|
596
|
-
const child = {};
|
|
597
|
-
setOwn(current, key, child);
|
|
598
|
-
current = child;
|
|
599
|
-
} else {
|
|
600
|
-
current = next;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
setOwn(current, path.at(-1), value);
|
|
604
|
-
}
|
|
605
|
-
function setOwn(object, key, value) {
|
|
606
|
-
if (key === "__proto__") {
|
|
607
|
-
Object.defineProperty(object, key, {
|
|
608
|
-
value,
|
|
609
|
-
writable: true,
|
|
610
|
-
enumerable: true,
|
|
611
|
-
configurable: true
|
|
612
|
-
});
|
|
613
|
-
} else {
|
|
614
|
-
object[key] = value;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function mergeTwoLevels(first, second) {
|
|
618
|
-
if (!isPlainObject(first) || !isPlainObject(second)) {
|
|
619
|
-
return second;
|
|
620
|
-
}
|
|
621
|
-
const result = { ...first, ...second };
|
|
622
|
-
for (const key of Object.keys(second)) {
|
|
623
|
-
if (!Object.hasOwn(first, key)) {
|
|
624
|
-
continue;
|
|
625
|
-
}
|
|
626
|
-
const firstValue = first[key];
|
|
627
|
-
const secondValue = second[key];
|
|
628
|
-
if (isPlainObject(firstValue) && isPlainObject(secondValue)) {
|
|
629
|
-
result[key] = { ...firstValue, ...secondValue };
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return result;
|
|
633
|
-
}
|
|
634
|
-
function omit(obj, keys) {
|
|
635
|
-
const result = { ...obj };
|
|
636
|
-
for (const key of keys) {
|
|
637
|
-
delete result[key];
|
|
638
|
-
}
|
|
639
|
-
return result;
|
|
640
|
-
}
|
|
641
|
-
function pick(obj, keys) {
|
|
642
|
-
const result = {};
|
|
643
|
-
for (const key of keys) {
|
|
644
|
-
if (Object.hasOwn(obj, key)) {
|
|
645
|
-
result[key] = obj[key];
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return result;
|
|
649
|
-
}
|
|
650
|
-
function clone(value) {
|
|
651
|
-
return cloneWithVisited(value, /* @__PURE__ */ new WeakMap());
|
|
652
|
-
}
|
|
653
|
-
function cloneWithVisited(value, visited) {
|
|
654
|
-
if (Array.isArray(value)) {
|
|
655
|
-
const existing = visited.get(value);
|
|
656
|
-
if (existing) {
|
|
657
|
-
return existing;
|
|
658
|
-
}
|
|
659
|
-
const result = [];
|
|
660
|
-
visited.set(value, result);
|
|
661
|
-
for (const item of value) {
|
|
662
|
-
result.push(cloneWithVisited(item, visited));
|
|
663
|
-
}
|
|
664
|
-
return result;
|
|
665
|
-
}
|
|
666
|
-
if (isPlainObject(value)) {
|
|
667
|
-
const existing = visited.get(value);
|
|
668
|
-
if (existing) {
|
|
669
|
-
return existing;
|
|
670
|
-
}
|
|
671
|
-
const result = {};
|
|
672
|
-
visited.set(value, result);
|
|
673
|
-
for (const key of Object.keys(value)) {
|
|
674
|
-
setOwn(result, key, cloneWithVisited(value[key], visited));
|
|
675
|
-
}
|
|
676
|
-
for (const sym of Object.getOwnPropertySymbols(value)) {
|
|
677
|
-
setOwn(result, sym, cloneWithVisited(value[sym], visited));
|
|
678
|
-
}
|
|
679
|
-
return result;
|
|
680
|
-
}
|
|
681
|
-
return value;
|
|
682
|
-
}
|
|
683
|
-
function copyOnWrite(parent, key, original) {
|
|
684
|
-
const value = parent[key];
|
|
685
|
-
if (value !== original) {
|
|
686
|
-
return value;
|
|
687
|
-
}
|
|
688
|
-
let copy;
|
|
689
|
-
if (Array.isArray(value)) {
|
|
690
|
-
copy = value.slice();
|
|
691
|
-
} else if (isPlainObject(value)) {
|
|
692
|
-
copy = { ...value };
|
|
693
|
-
} else {
|
|
694
|
-
return value;
|
|
695
|
-
}
|
|
696
|
-
setOwn(parent, key, copy);
|
|
697
|
-
return copy;
|
|
698
|
-
}
|
|
699
|
-
function isPropertyKey(value) {
|
|
700
|
-
const type = typeof value;
|
|
701
|
-
return type === "string" || type === "number" || type === "symbol";
|
|
702
|
-
}
|
|
703
|
-
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
704
|
-
const e = function() {
|
|
705
|
-
};
|
|
706
|
-
e.prototype = /* @__PURE__ */ Object.create(null);
|
|
707
|
-
Object.freeze(e.prototype);
|
|
708
|
-
return e;
|
|
709
|
-
})();
|
|
710
|
-
function bindMethods(obj, options = {}) {
|
|
711
|
-
const unbound = new Set(options.unbound);
|
|
712
|
-
const methods = new NullProtoObj();
|
|
713
|
-
let current = obj;
|
|
714
|
-
while (current && current !== Object.prototype) {
|
|
715
|
-
for (const key of Object.getOwnPropertyNames(current)) {
|
|
716
|
-
if (key === "constructor" || key in methods) {
|
|
717
|
-
continue;
|
|
718
|
-
}
|
|
719
|
-
const val = getOrBind(obj, key, { bind: !unbound.has(key) });
|
|
720
|
-
if (typeof val === "function") {
|
|
721
|
-
methods[key] = val;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
for (const sym of Object.getOwnPropertySymbols(current)) {
|
|
725
|
-
if (sym in methods) {
|
|
726
|
-
continue;
|
|
727
|
-
}
|
|
728
|
-
const val = getOrBind(obj, sym, { bind: !unbound.has(sym) });
|
|
729
|
-
if (typeof val === "function") {
|
|
730
|
-
methods[sym] = val;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
current = Object.getPrototypeOf(current);
|
|
734
|
-
}
|
|
735
|
-
return methods;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
755
|
function promiseWithResolvers() {
|
|
739
756
|
const result = {};
|
|
740
757
|
result.promise = new Promise((resolve, reject) => {
|
|
@@ -1097,4 +1114,4 @@ async function runWithSignal(signal, fn) {
|
|
|
1097
1114
|
}
|
|
1098
1115
|
}
|
|
1099
1116
|
|
|
1100
|
-
export { AsyncIdQueue, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
|
1117
|
+
export { AsyncIdQueue, DEFAULT_MAX_BIGINT_DIGITS, NullProtoObj, ORPC_NAME, allAbortSignal, anyAbortSignal, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, bindMethods, captureAsyncContext, clone, compareSequentialIds, consumeAsyncIterator, copyOnWrite, defer, encodeBase64, findDeepMatches, get, getConstructor, getConstructors, getOwn, getTracer, intercept, isAbortError, isAcceptableEncoding, isAsyncGeneratorFunction, isCompressibleContentType, isDeepEqual, isNoTransformCacheControl, isPlainObject, isPropertyKey, loadBytes, matchesHttpPath, matchesHttpPathPrefix, mergeHttpPath, mergeTwoLevels, normalizeHttpPath, omit, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, once, override, parseAcceptEncodingQualities, parseBigIntString, pathToHttpPath, pick, promiseWithResolvers, recordSpanError, replicateAsyncIterator, replicateReadableStream, resolveMaybeOptionalOptions, runInSpanContext, runWithSignal, runWithSpan, set, setOwn, setSpanAttributeIfDefined, setTracer, sortPlugins, splitInHalf, startSpan, streamToAsyncIteratorObject, toSpanAttributeValue, toStringOrBytes, toTracingException, traceAsyncIterator, traceReadableStream, tryOrUndefined, value, varyByAcceptEncoding, wrapAsyncIterator, wrapReadableStream };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.45",
|
|
5
5
|
"description": "Internal utilities shared across oRPC packages",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@standard-server/shared": "~0.
|
|
33
|
+
"@standard-server/shared": "~0.11.0",
|
|
34
34
|
"radash": "^12.1.1",
|
|
35
|
-
"type-fest": "^5.
|
|
35
|
+
"type-fest": "^5.10.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"arktype": "^2.2.
|
|
38
|
+
"arktype": "^2.2.8",
|
|
39
39
|
"valibot": "^1.5.0",
|
|
40
|
-
"zod": "^4.
|
|
40
|
+
"zod": "^4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"type:check": "tsc -b"
|