@orpc/client 2.0.0-beta.43 → 2.0.0-beta.44
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 +2 -10
- package/dist/adapters/fetch/index.mjs +9 -3
- package/dist/adapters/message-port/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +2 -2
- package/dist/adapters/standard/index.d.ts +2 -2
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/websocket/index.mjs +3 -3
- package/dist/index.d.mts +4 -15
- package/dist/index.d.ts +4 -15
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.d.mts +1 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +6 -3
- package/dist/shared/{client.Bstqyaro.mjs → client.B7P_ugvl.mjs} +5 -7
- package/dist/shared/{client.DpkGsZt-.mjs → client.BLfXUpyF.mjs} +54 -34
- package/dist/shared/{client.DiHfJmHK.d.ts → client.BzAY7ZC2.d.mts} +2 -2
- package/dist/shared/{client.BjbdW5Rj.d.mts → client.CHH2CNMj.d.ts} +2 -2
- package/dist/shared/{client.DD2eNne_.mjs → client.CrHurHrq.mjs} +15 -3
- package/dist/shared/{client.Dw9_40WO.d.mts → client.DZHZRyR6.d.mts} +12 -5
- package/dist/shared/{client.Dw9_40WO.d.ts → client.DZHZRyR6.d.ts} +12 -5
- package/package.json +8 -8
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
|
|
|
@@ -95,14 +95,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
95
95
|
</tr>
|
|
96
96
|
</table>
|
|
97
97
|
|
|
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
98
|
### Premium Sponsors
|
|
107
99
|
|
|
108
100
|
<table>
|
|
@@ -178,7 +170,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
178
170
|
</tr>
|
|
179
171
|
</table>
|
|
180
172
|
|
|
181
|
-
With thanks to [
|
|
173
|
+
With thanks to [39 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
182
174
|
|
|
183
175
|
## References
|
|
184
176
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { value, once } from '@orpc/shared';
|
|
2
2
|
import { toFetchBody, toFetchHeaders, toStandardLazyResponse } from '@standard-server/fetch';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B7P_ugvl.mjs';
|
|
4
4
|
import '@standard-server/core';
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.CrHurHrq.mjs';
|
|
6
|
+
import '../../shared/client.BLfXUpyF.mjs';
|
|
7
7
|
|
|
8
8
|
const GET_SUPPORTED_DUPLEX_MODE = once(() => {
|
|
9
9
|
try {
|
|
@@ -55,6 +55,12 @@ class FetchLinkTransport {
|
|
|
55
55
|
}
|
|
56
56
|
const fetch = this.fetch;
|
|
57
57
|
const response = await fetch(url, init, options, path);
|
|
58
|
+
if (response.type === "opaqueredirect") {
|
|
59
|
+
throw new TypeError("Unexpected redirect response: redirects are not followed.");
|
|
60
|
+
}
|
|
61
|
+
if (response.type === "opaque") {
|
|
62
|
+
throw new TypeError("Unexpected opaque response: the response is unreadable, likely due to a no-cors request.");
|
|
63
|
+
}
|
|
58
64
|
const standardResponse = toStandardLazyResponse(response);
|
|
59
65
|
return standardResponse;
|
|
60
66
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { value, AbortError } from '@orpc/shared';
|
|
2
2
|
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage, isPeerMessage } from '@standard-server/peer';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B7P_ugvl.mjs';
|
|
4
4
|
import '@standard-server/core';
|
|
5
5
|
import '@standard-server/fetch';
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.CrHurHrq.mjs';
|
|
7
|
+
import '../../shared/client.BLfXUpyF.mjs';
|
|
8
8
|
|
|
9
9
|
function postMessagePortMessage(port, data, transfer) {
|
|
10
10
|
if (transfer) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.
|
|
2
|
-
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.
|
|
1
|
+
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.BzAY7ZC2.mjs';
|
|
2
|
+
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.BzAY7ZC2.mjs';
|
|
3
3
|
import { Value, Promisable, Public } from '@orpc/shared';
|
|
4
4
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
5
5
|
import { ClientContext, ClientOptions } from '../../index.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.
|
|
2
|
-
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.
|
|
1
|
+
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.CHH2CNMj.js';
|
|
2
|
+
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.CHH2CNMj.js';
|
|
3
3
|
import { Value, Promisable, Public } from '@orpc/shared';
|
|
4
4
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
5
5
|
import { ClientContext, ClientOptions } from '../../index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as CompositeStandardLinkPlugin, R as RPCLinkCodec, S as StandardLink } from '../../shared/client.
|
|
1
|
+
export { C as CompositeStandardLinkPlugin, R as RPCLinkCodec, S as StandardLink } from '../../shared/client.B7P_ugvl.mjs';
|
|
2
2
|
import '@orpc/shared';
|
|
3
3
|
import '@standard-server/core';
|
|
4
4
|
import '@standard-server/fetch';
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.CrHurHrq.mjs';
|
|
6
|
+
import '../../shared/client.BLfXUpyF.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { runWithSignal, AbortError, sleep, promiseWithResolvers, sequential, loadBytes, toStringOrBytes } from '@orpc/shared';
|
|
2
2
|
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage } from '@standard-server/peer';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B7P_ugvl.mjs';
|
|
4
4
|
import '@standard-server/core';
|
|
5
5
|
import '@standard-server/fetch';
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.CrHurHrq.mjs';
|
|
7
|
+
import '../../shared/client.BLfXUpyF.mjs';
|
|
8
8
|
|
|
9
9
|
const WEBSOCKET_CONNECTING = 0;
|
|
10
10
|
const WEBSOCKET_OPEN = 1;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs,
|
|
5
|
-
import { StandardResponse } from '@standard-server/core';
|
|
6
|
-
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.DZHZRyR6.mjs';
|
|
4
|
+
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions } from './shared/client.DZHZRyR6.mjs';
|
|
7
5
|
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.BPa_Mmuh.mjs';
|
|
6
|
+
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
8
7
|
|
|
9
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
10
9
|
|
|
@@ -132,16 +131,6 @@ declare function isDefinedError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
|
132
131
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
133
132
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
134
133
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
135
|
-
/**
|
|
136
|
-
* Creates the `MALFORMED_ORPC_RESPONSE` `ORPCError` used when a response
|
|
137
|
-
* does not follow the expected oRPC format. Unless overridden via `options.message`,
|
|
138
|
-
* the message is inferred from the response body or status. The `cause` is a
|
|
139
|
-
* `MalformedResponseError` carrying the resolved response.
|
|
140
|
-
*
|
|
141
|
-
* @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
|
|
142
|
-
* @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
|
|
143
|
-
*/
|
|
144
|
-
declare function createORPCErrorFromMalformedResponse(options: MalformedResponseErrorOptions): ORPCError<'MALFORMED_ORPC_RESPONSE', StandardResponse>;
|
|
145
134
|
/**
|
|
146
135
|
* Clones an `ORPCError` while preserving its prototype chain, so instances of
|
|
147
136
|
* `ORPCError` subclasses remain `instanceof` their class.
|
|
@@ -152,5 +141,5 @@ declare function createORPCErrorFromMalformedResponse(options: MalformedResponse
|
|
|
152
141
|
*/
|
|
153
142
|
declare function cloneORPCError<T extends AnyORPCError>(error: T): T;
|
|
154
143
|
|
|
155
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion,
|
|
144
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isDefinedError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
156
145
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs,
|
|
5
|
-
import { StandardResponse } from '@standard-server/core';
|
|
6
|
-
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.DZHZRyR6.js';
|
|
4
|
+
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions } from './shared/client.DZHZRyR6.js';
|
|
7
5
|
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.BPa_Mmuh.js';
|
|
6
|
+
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
8
7
|
|
|
9
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
10
9
|
|
|
@@ -132,16 +131,6 @@ declare function isDefinedError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
|
132
131
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
133
132
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
134
133
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
135
|
-
/**
|
|
136
|
-
* Creates the `MALFORMED_ORPC_RESPONSE` `ORPCError` used when a response
|
|
137
|
-
* does not follow the expected oRPC format. Unless overridden via `options.message`,
|
|
138
|
-
* the message is inferred from the response body or status. The `cause` is a
|
|
139
|
-
* `MalformedResponseError` carrying the resolved response.
|
|
140
|
-
*
|
|
141
|
-
* @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
|
|
142
|
-
* @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
|
|
143
|
-
*/
|
|
144
|
-
declare function createORPCErrorFromMalformedResponse(options: MalformedResponseErrorOptions): ORPCError<'MALFORMED_ORPC_RESPONSE', StandardResponse>;
|
|
145
134
|
/**
|
|
146
135
|
* Clones an `ORPCError` while preserving its prototype chain, so instances of
|
|
147
136
|
* `ORPCError` subclasses remain `instanceof` their class.
|
|
@@ -152,5 +141,5 @@ declare function createORPCErrorFromMalformedResponse(options: MalformedResponse
|
|
|
152
141
|
*/
|
|
153
142
|
declare function cloneORPCError<T extends AnyORPCError>(error: T): T;
|
|
154
143
|
|
|
155
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion,
|
|
144
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isDefinedError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
156
145
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a as isDefinedError } from './shared/client.BLfXUpyF.mjs';
|
|
2
|
+
export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.BLfXUpyF.mjs';
|
|
3
3
|
import { toArray, intercept, isTypescriptObject } from '@orpc/shared';
|
|
4
4
|
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
5
|
-
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError } from './shared/client.
|
|
5
|
+
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError } from './shared/client.CrHurHrq.mjs';
|
|
6
6
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
7
|
|
|
8
8
|
const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
|
package/dist/plugins/index.d.mts
CHANGED
package/dist/plugins/index.d.ts
CHANGED
package/dist/plugins/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { toArray, value, splitInHalf, promiseWithResolvers, safeEncodeURICompone
|
|
|
2
2
|
import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@standard-server/core';
|
|
3
3
|
import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@standard-server/peer';
|
|
4
4
|
import { toFetchHeaders, toStandardBody } from '@standard-server/fetch';
|
|
5
|
-
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.
|
|
5
|
+
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.CrHurHrq.mjs';
|
|
6
6
|
|
|
7
7
|
class BatchLinkPlugin {
|
|
8
8
|
name = "~batch";
|
|
@@ -774,13 +774,14 @@ class RetryLinkPlugin {
|
|
|
774
774
|
let lastEventRetry;
|
|
775
775
|
let callback;
|
|
776
776
|
let attempt = 1;
|
|
777
|
+
let isIteratorAborted = false;
|
|
777
778
|
const callNext = async (initialError) => {
|
|
778
779
|
let currentError = initialError;
|
|
779
780
|
while (true) {
|
|
780
781
|
const updatedCallOptions = { ...callOptions, lastEventId };
|
|
781
782
|
let retryDelayMs = 0;
|
|
782
783
|
if (currentError) {
|
|
783
|
-
if (attempt > maxAttempts) {
|
|
784
|
+
if (isIteratorAborted || attempt > maxAttempts) {
|
|
784
785
|
throw currentError.error;
|
|
785
786
|
}
|
|
786
787
|
const attemptOptions = {
|
|
@@ -802,6 +803,9 @@ class RetryLinkPlugin {
|
|
|
802
803
|
try {
|
|
803
804
|
if (currentError) {
|
|
804
805
|
await sleep(retryDelayMs, { signal: updatedCallOptions.signal });
|
|
806
|
+
if (isIteratorAborted) {
|
|
807
|
+
throw currentError.error;
|
|
808
|
+
}
|
|
805
809
|
attempt++;
|
|
806
810
|
}
|
|
807
811
|
currentError = void 0;
|
|
@@ -822,7 +826,6 @@ class RetryLinkPlugin {
|
|
|
822
826
|
return output;
|
|
823
827
|
}
|
|
824
828
|
let current = output;
|
|
825
|
-
let isIteratorAborted = false;
|
|
826
829
|
return override(() => current, new AsyncIteratorClass(
|
|
827
830
|
async () => {
|
|
828
831
|
while (true) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { sortPlugins, runWithSpan, ORPC_NAME, getTracer, isAsyncIteratorObject, override, traceAsyncIterator, traceReadableStream, intercept, value, pathToHttpPath, stringifyJSON } from '@orpc/shared';
|
|
2
2
|
import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
|
|
3
3
|
import { toStandardHeaders } from '@standard-server/fetch';
|
|
4
|
-
import {
|
|
4
|
+
import { M as MalformedResponseError } from './client.CrHurHrq.mjs';
|
|
5
|
+
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.BLfXUpyF.mjs';
|
|
5
6
|
|
|
6
7
|
class CompositeStandardLinkPlugin {
|
|
7
8
|
name = "~composite";
|
|
@@ -30,7 +31,7 @@ class StandardLink {
|
|
|
30
31
|
interceptors;
|
|
31
32
|
transportInterceptors;
|
|
32
33
|
/**
|
|
33
|
-
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
34
|
+
* @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
|
|
34
35
|
*/
|
|
35
36
|
call(path, input, options) {
|
|
36
37
|
return runWithSpan(`${ORPC_NAME}.${path.join("/")}`, (span) => {
|
|
@@ -140,7 +141,7 @@ class RPCLinkCodec {
|
|
|
140
141
|
try {
|
|
141
142
|
return this.serializer.deserialize(body);
|
|
142
143
|
} catch (cause) {
|
|
143
|
-
throw
|
|
144
|
+
throw new MalformedResponseError({
|
|
144
145
|
message: "Invalid RPC response format.",
|
|
145
146
|
response: { status: response.status, headers: response.headers, body },
|
|
146
147
|
cause
|
|
@@ -151,10 +152,7 @@ class RPCLinkCodec {
|
|
|
151
152
|
if (isORPCErrorJson(deserialized)) {
|
|
152
153
|
return { kind: "error", error: createORPCErrorFromJson(deserialized) };
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
kind: "error",
|
|
156
|
-
error: createORPCErrorFromMalformedResponse({ response: { headers: response.headers, status: response.status, body } })
|
|
157
|
-
};
|
|
155
|
+
throw new MalformedResponseError({ response: { headers: response.headers, status: response.status, body } });
|
|
158
156
|
}
|
|
159
157
|
return { kind: "output", output: deserialized };
|
|
160
158
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isPlainObject, wrapAsyncIterator, isTypescriptObject, NullProtoObj, copyOnWrite, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
1
|
+
import { isPlainObject, wrapAsyncIterator, isTypescriptObject, NullProtoObj, parseBigIntString, DEFAULT_MAX_BIGINT_DIGITS, copyOnWrite, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
2
2
|
import { getEventMeta, withEventMeta, ErrorEvent } from '@standard-server/core';
|
|
3
|
-
import { O as ORPCError
|
|
3
|
+
import { O as ORPCError } from './client.CrHurHrq.mjs';
|
|
4
4
|
|
|
5
5
|
function isDefinedError(error) {
|
|
6
6
|
return error instanceof ORPCError && error.defined;
|
|
@@ -26,29 +26,6 @@ function createORPCErrorFromJson(json, options = {}) {
|
|
|
26
26
|
error.defined = json.defined;
|
|
27
27
|
return error;
|
|
28
28
|
}
|
|
29
|
-
function createORPCErrorFromMalformedResponse(options) {
|
|
30
|
-
const error = new ORPCError("MALFORMED_ORPC_RESPONSE", {
|
|
31
|
-
message: options.message ?? inferMalformedResponseMessage(options.response),
|
|
32
|
-
data: options.response
|
|
33
|
-
});
|
|
34
|
-
error.cause = new MalformedResponseError({ ...options, message: error.message });
|
|
35
|
-
return error;
|
|
36
|
-
}
|
|
37
|
-
const INFERRED_MESSAGE_MIN_LENGTH = 1;
|
|
38
|
-
const INFERRED_MESSAGE_MAX_LENGTH = 256;
|
|
39
|
-
function isInferableMessage(text) {
|
|
40
|
-
return text.length >= INFERRED_MESSAGE_MIN_LENGTH && text.length <= INFERRED_MESSAGE_MAX_LENGTH;
|
|
41
|
-
}
|
|
42
|
-
function inferMalformedResponseMessage(response) {
|
|
43
|
-
if (typeof response.body === "string" && isInferableMessage(response.body)) {
|
|
44
|
-
return response.body;
|
|
45
|
-
}
|
|
46
|
-
if (isPlainObject(response.body) && typeof response.body.message === "string" && isInferableMessage(response.body.message)) {
|
|
47
|
-
return response.body.message;
|
|
48
|
-
}
|
|
49
|
-
const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
|
|
50
|
-
return commonCode?.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
51
|
-
}
|
|
52
29
|
function cloneORPCError(error) {
|
|
53
30
|
const cloned = new ORPCError(error.code, {
|
|
54
31
|
message: error.message,
|
|
@@ -95,6 +72,16 @@ function assertSerializedType(ok, type, expected) {
|
|
|
95
72
|
throw invalidSerializedData(`type "${type}" expects ${expected}.`);
|
|
96
73
|
}
|
|
97
74
|
}
|
|
75
|
+
function isWalkable(value) {
|
|
76
|
+
return Array.isArray(value) || isPlainObject(value);
|
|
77
|
+
}
|
|
78
|
+
function walkInto(parent, key, original, restored) {
|
|
79
|
+
const value = parent[key];
|
|
80
|
+
if (!isWalkable(value) || restored?.has(value)) {
|
|
81
|
+
throw invalidSerializedData(`segment "${key}" cannot be walked into.`);
|
|
82
|
+
}
|
|
83
|
+
return value === original ? copyOnWrite(parent, key, original) : value;
|
|
84
|
+
}
|
|
98
85
|
const DEFAULT_RPC_JSON_SERIALIZER_HANDLERS = {
|
|
99
86
|
undefined: {
|
|
100
87
|
condition(data) {
|
|
@@ -118,7 +105,11 @@ const DEFAULT_RPC_JSON_SERIALIZER_HANDLERS = {
|
|
|
118
105
|
},
|
|
119
106
|
deserialize(serialized) {
|
|
120
107
|
assertSerializedType(typeof serialized === "string", "bigint", "a string");
|
|
121
|
-
|
|
108
|
+
const value = parseBigIntString(serialized, DEFAULT_MAX_BIGINT_DIGITS);
|
|
109
|
+
if (value === void 0) {
|
|
110
|
+
throw invalidSerializedData(`type "bigint" expects a decimal integer string of at most ${DEFAULT_MAX_BIGINT_DIGITS} digits.`);
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
122
113
|
},
|
|
123
114
|
isTerminal: true
|
|
124
115
|
},
|
|
@@ -368,7 +359,7 @@ class RPCJsonSerializer {
|
|
|
368
359
|
let preSegment = "json";
|
|
369
360
|
for (let j = 0; j < segments.length; j++) {
|
|
370
361
|
original = original[preSegment];
|
|
371
|
-
currentRef =
|
|
362
|
+
currentRef = walkInto(currentRef, preSegment, original);
|
|
372
363
|
preSegment = segments[j];
|
|
373
364
|
if (!Object.hasOwn(currentRef, preSegment)) {
|
|
374
365
|
throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
|
|
@@ -377,25 +368,54 @@ class RPCJsonSerializer {
|
|
|
377
368
|
currentRef[preSegment] = blob;
|
|
378
369
|
}
|
|
379
370
|
}
|
|
380
|
-
|
|
381
|
-
|
|
371
|
+
const meta = serialized.meta;
|
|
372
|
+
if (meta) {
|
|
373
|
+
let restored;
|
|
374
|
+
const chain = meta.length === 1 ? void 0 : [];
|
|
375
|
+
let chainDepth = 0;
|
|
376
|
+
for (const item of meta) {
|
|
382
377
|
const type = item[0];
|
|
383
378
|
const handler = this.handlers[type];
|
|
384
379
|
if (handler === void 0) {
|
|
385
380
|
throw invalidSerializedData(`type "${type}" is not supported.`);
|
|
386
381
|
}
|
|
382
|
+
const depth = item.length - 1;
|
|
383
|
+
const shared = Math.min(depth, chainDepth);
|
|
384
|
+
let d = 0;
|
|
387
385
|
let original = serialized;
|
|
388
386
|
let currentRef = ref;
|
|
389
387
|
let preSegment = "json";
|
|
390
|
-
|
|
388
|
+
if (chain !== void 0 && shared > 0) {
|
|
389
|
+
d = 1;
|
|
390
|
+
while (d < shared && chain[3 * d] === item[d]) {
|
|
391
|
+
d++;
|
|
392
|
+
}
|
|
393
|
+
currentRef = chain[3 * d - 2];
|
|
394
|
+
original = chain[3 * d - 1];
|
|
395
|
+
preSegment = item[d];
|
|
396
|
+
if (!Object.hasOwn(currentRef, preSegment)) {
|
|
397
|
+
throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
while (d < depth) {
|
|
391
401
|
original = original[preSegment];
|
|
392
|
-
currentRef =
|
|
393
|
-
|
|
402
|
+
currentRef = walkInto(currentRef, preSegment, original, restored);
|
|
403
|
+
if (chain !== void 0) {
|
|
404
|
+
chain[3 * d] = preSegment;
|
|
405
|
+
chain[3 * d + 1] = currentRef;
|
|
406
|
+
chain[3 * d + 2] = original;
|
|
407
|
+
}
|
|
408
|
+
preSegment = item[++d];
|
|
394
409
|
if (!Object.hasOwn(currentRef, preSegment)) {
|
|
395
410
|
throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
|
|
396
411
|
}
|
|
397
412
|
}
|
|
398
|
-
|
|
413
|
+
chainDepth = depth;
|
|
414
|
+
const value = handler.deserialize(currentRef[preSegment]);
|
|
415
|
+
currentRef[preSegment] = value;
|
|
416
|
+
if (isWalkable(value)) {
|
|
417
|
+
(restored ??= /* @__PURE__ */ new Set()).add(value);
|
|
418
|
+
}
|
|
399
419
|
}
|
|
400
420
|
}
|
|
401
421
|
return ref.json;
|
|
@@ -483,4 +503,4 @@ class RPCSerializer {
|
|
|
483
503
|
}
|
|
484
504
|
}
|
|
485
505
|
|
|
486
|
-
export { RPCSerializer as R,
|
|
506
|
+
export { RPCSerializer as R, isDefinedError as a, RPCJsonSerializer as b, createORPCErrorFromJson as c, cloneORPCError as d, isORPCErrorJson as i, toORPCError as t, wrapAsyncIteratorPreservingEventMeta as w };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
2
|
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.DZHZRyR6.mjs';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -87,7 +87,7 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
|
|
|
87
87
|
private readonly transportInterceptors;
|
|
88
88
|
constructor(codec: StandardLinkCodec<T>, transport: StandardLinkTransport<T>, options?: StandardLinkOptions<T>);
|
|
89
89
|
/**
|
|
90
|
-
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
90
|
+
* @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
|
|
91
91
|
*/
|
|
92
92
|
call(path: string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
|
|
93
93
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
2
|
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.DZHZRyR6.js';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -87,7 +87,7 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
|
|
|
87
87
|
private readonly transportInterceptors;
|
|
88
88
|
constructor(codec: StandardLinkCodec<T>, transport: StandardLinkTransport<T>, options?: StandardLinkOptions<T>);
|
|
89
89
|
/**
|
|
90
|
-
* @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
|
|
90
|
+
* @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
|
|
91
91
|
*/
|
|
92
92
|
call(path: string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
|
|
93
93
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveMaybeOptionalOptions, getConstructors } from '@orpc/shared';
|
|
1
|
+
import { resolveMaybeOptionalOptions, getConstructors, isPlainObject } from '@orpc/shared';
|
|
2
2
|
|
|
3
3
|
const COMMON_ERROR_STATUS_MAP = {
|
|
4
4
|
BAD_REQUEST: 400,
|
|
@@ -48,7 +48,7 @@ class ORPCError extends Error {
|
|
|
48
48
|
data;
|
|
49
49
|
constructor(code, ...rest) {
|
|
50
50
|
const options = resolveMaybeOptionalOptions(rest);
|
|
51
|
-
const message = options.message ?? code
|
|
51
|
+
const message = options.message ?? codeToMessage(code);
|
|
52
52
|
super(message, options);
|
|
53
53
|
this.code = code;
|
|
54
54
|
this.data = options.data;
|
|
@@ -89,9 +89,21 @@ class MalformedResponseError extends Error {
|
|
|
89
89
|
name = "MalformedResponseError";
|
|
90
90
|
response;
|
|
91
91
|
constructor(options) {
|
|
92
|
-
super(options.message, options);
|
|
92
|
+
super(options.message ?? inferMalformedResponseMessage(options.response), options);
|
|
93
93
|
this.response = options.response;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
const INFERRED_MESSAGE_MAX_LENGTH = 256;
|
|
97
|
+
function inferMalformedResponseMessage(response) {
|
|
98
|
+
const candidate = isPlainObject(response.body) ? response.body.message : response.body;
|
|
99
|
+
if (typeof candidate === "string" && candidate.length > 0 && candidate.length <= INFERRED_MESSAGE_MAX_LENGTH) {
|
|
100
|
+
return candidate;
|
|
101
|
+
}
|
|
102
|
+
const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
|
|
103
|
+
return commonCode ? codeToMessage(commonCode) : "Malformed oRPC Response";
|
|
104
|
+
}
|
|
105
|
+
function codeToMessage(code) {
|
|
106
|
+
return code.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
107
|
+
}
|
|
96
108
|
|
|
97
109
|
export { COMMON_ERROR_STATUS_MAP as C, MalformedResponseError as M, ORPCError as O };
|
|
@@ -187,13 +187,20 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
187
187
|
type AnyORPCError = ORPCError<any, any>;
|
|
188
188
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
189
189
|
interface MalformedResponseErrorOptions extends ErrorOptions {
|
|
190
|
+
/**
|
|
191
|
+
* @default inferred from the response body or status
|
|
192
|
+
*/
|
|
190
193
|
message?: string;
|
|
191
194
|
response: StandardResponse;
|
|
192
195
|
}
|
|
193
196
|
/**
|
|
194
|
-
* Error
|
|
195
|
-
*
|
|
196
|
-
* `
|
|
197
|
+
* Error thrown by links when a response does not follow the expected oRPC format,
|
|
198
|
+
* for example when a proxy or gateway answers instead of your handler. Carries the
|
|
199
|
+
* resolved response. Unless overridden via `options.message`, the message is
|
|
200
|
+
* inferred from the response body or status.
|
|
201
|
+
*
|
|
202
|
+
* Unlike `ORPCError`, it reaches a handler's callers as a generic `INTERNAL_SERVER_ERROR`
|
|
203
|
+
* when thrown from the handler, so an upstream's response is not sent to them.
|
|
197
204
|
*
|
|
198
205
|
* @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
|
|
199
206
|
* @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
|
|
@@ -204,5 +211,5 @@ declare class MalformedResponseError extends Error {
|
|
|
204
211
|
constructor(options: MalformedResponseErrorOptions);
|
|
205
212
|
}
|
|
206
213
|
|
|
207
|
-
export {
|
|
208
|
-
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I,
|
|
214
|
+
export { MalformedResponseError as M, ORPCError as h, COMMON_ERROR_STATUS_MAP as j };
|
|
215
|
+
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as g, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, MalformedResponseErrorOptions as p, ORPCErrorOptions as q };
|
|
@@ -187,13 +187,20 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
187
187
|
type AnyORPCError = ORPCError<any, any>;
|
|
188
188
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
189
189
|
interface MalformedResponseErrorOptions extends ErrorOptions {
|
|
190
|
+
/**
|
|
191
|
+
* @default inferred from the response body or status
|
|
192
|
+
*/
|
|
190
193
|
message?: string;
|
|
191
194
|
response: StandardResponse;
|
|
192
195
|
}
|
|
193
196
|
/**
|
|
194
|
-
* Error
|
|
195
|
-
*
|
|
196
|
-
* `
|
|
197
|
+
* Error thrown by links when a response does not follow the expected oRPC format,
|
|
198
|
+
* for example when a proxy or gateway answers instead of your handler. Carries the
|
|
199
|
+
* resolved response. Unless overridden via `options.message`, the message is
|
|
200
|
+
* inferred from the response body or status.
|
|
201
|
+
*
|
|
202
|
+
* Unlike `ORPCError`, it reaches a handler's callers as a generic `INTERNAL_SERVER_ERROR`
|
|
203
|
+
* when thrown from the handler, so an upstream's response is not sent to them.
|
|
197
204
|
*
|
|
198
205
|
* @see {@link https://orpc.dev/docs/rpc/link#malformed-responses | RPC Link - Malformed Responses}
|
|
199
206
|
* @see {@link https://orpc.dev/docs/openapi/link#malformed-responses | OpenAPI Link - Malformed Responses}
|
|
@@ -204,5 +211,5 @@ declare class MalformedResponseError extends Error {
|
|
|
204
211
|
constructor(options: MalformedResponseErrorOptions);
|
|
205
212
|
}
|
|
206
213
|
|
|
207
|
-
export {
|
|
208
|
-
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I,
|
|
214
|
+
export { MalformedResponseError as M, ORPCError as h, COMMON_ERROR_STATUS_MAP as j };
|
|
215
|
+
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as g, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, MalformedResponseErrorOptions as p, ORPCErrorOptions as q };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.44",
|
|
5
5
|
"description": "Consume oRPC and OpenAPI APIs with end-to-end type safety over HTTP, WebSocket, or message ports",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"dist"
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@orpc/shared": "2.0.0-beta.
|
|
67
|
-
"@standard-server/core": "~0.10.
|
|
68
|
-
"@standard-server/fetch": "~0.10.
|
|
69
|
-
"@standard-server/peer": "~0.10.
|
|
66
|
+
"@orpc/shared": "2.0.0-beta.44",
|
|
67
|
+
"@standard-server/core": "~0.10.3",
|
|
68
|
+
"@standard-server/fetch": "~0.10.3",
|
|
69
|
+
"@standard-server/peer": "~0.10.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@types/ws": "^8.18.
|
|
73
|
-
"ws": "^8.
|
|
74
|
-
"zod": "^4.5
|
|
72
|
+
"@types/ws": "^8.18.2",
|
|
73
|
+
"ws": "^8.22.0",
|
|
74
|
+
"zod": "^4.6.5"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"type:check": "tsc -b"
|