@orpc/client 2.0.0-beta.3 → 2.0.0-beta.31
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 +71 -101
- package/dist/adapters/fetch/index.d.mts +10 -5
- package/dist/adapters/fetch/index.d.ts +10 -5
- package/dist/adapters/fetch/index.mjs +31 -6
- package/dist/adapters/message-port/index.d.mts +11 -6
- package/dist/adapters/message-port/index.d.ts +11 -6
- package/dist/adapters/message-port/index.mjs +20 -15
- package/dist/adapters/standard/index.d.mts +6 -7
- package/dist/adapters/standard/index.d.ts +6 -7
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/websocket/index.d.mts +19 -14
- package/dist/adapters/websocket/index.d.ts +19 -14
- package/dist/adapters/websocket/index.mjs +11 -11
- package/dist/index.d.mts +49 -48
- package/dist/index.d.ts +49 -48
- package/dist/index.mjs +32 -49
- package/dist/plugins/index.d.mts +124 -12
- package/dist/plugins/index.d.ts +124 -12
- package/dist/plugins/index.mjs +290 -23
- package/dist/shared/{client.Cby_-GGh.d.mts → client.B0-4UDVl.d.mts} +1 -1
- package/dist/shared/{client.CPF3hX6O.d.ts → client.BhTyskpV.d.ts} +1 -1
- package/dist/shared/{client.DMXKFDyV.mjs → client.BnATe4Ob.mjs} +176 -58
- package/dist/shared/{client.8ug8I-zu.d.mts → client.CFVTHyN6.d.mts} +54 -6
- package/dist/shared/{client.8ug8I-zu.d.ts → client.CFVTHyN6.d.ts} +54 -6
- package/dist/shared/{client.Dnfj8jnT.mjs → client.DcoDDrD4.mjs} +17 -8
- package/dist/shared/{client.BdItY5DT.d.mts → client.Qwo2aQOm.d.mts} +18 -0
- package/dist/shared/{client.BdItY5DT.d.ts → client.Qwo2aQOm.d.ts} +18 -0
- package/dist/shared/{client.DXhchJ84.mjs → client.vEM0O_Eg.mjs} +8 -9
- package/package.json +19 -6
|
@@ -73,11 +73,23 @@ interface RPCJsonSerializerOptions {
|
|
|
73
73
|
*/
|
|
74
74
|
omitUndefinedProperties?: boolean | undefined;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Serializes and deserializes native types like Date, BigInt, Set, and Map
|
|
78
|
+
* into a JSON value plus separate metadata describing how to restore them.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
81
|
+
*/
|
|
76
82
|
declare class RPCJsonSerializer {
|
|
77
83
|
private readonly handlers;
|
|
84
|
+
private readonly inlineBuiltInHandlers;
|
|
85
|
+
private readonly handlerEntries;
|
|
78
86
|
private readonly omitUndefinedProperties;
|
|
79
87
|
constructor(options?: RPCJsonSerializerOptions);
|
|
80
88
|
serialize(data: unknown): RPCJsonSerialization;
|
|
89
|
+
/**
|
|
90
|
+
* `segments` is a shared mutable stack (push/pop while walking),
|
|
91
|
+
* so it must be copied before being stored in `meta` or `maps`.
|
|
92
|
+
*/
|
|
81
93
|
private serializeValue;
|
|
82
94
|
deserialize(serialized: RPCJsonSerialization): unknown;
|
|
83
95
|
}
|
|
@@ -97,6 +109,12 @@ interface RPCSerializerOptions extends RPCJsonSerializerOptions {
|
|
|
97
109
|
*/
|
|
98
110
|
serialize?: RPCSerializerSerializeOptions | undefined;
|
|
99
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Serializes and deserializes data for the RPC protocol,
|
|
114
|
+
* preserving native types like Date, BigInt, Set, and Map that plain JSON cannot represent.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://orpc.dev/docs/rpc/serializer | RPC Serializer}
|
|
117
|
+
*/
|
|
100
118
|
declare class RPCSerializer {
|
|
101
119
|
private readonly jsonSerializer;
|
|
102
120
|
private readonly defaultSerializeOptions;
|
|
@@ -73,11 +73,23 @@ interface RPCJsonSerializerOptions {
|
|
|
73
73
|
*/
|
|
74
74
|
omitUndefinedProperties?: boolean | undefined;
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Serializes and deserializes native types like Date, BigInt, Set, and Map
|
|
78
|
+
* into a JSON value plus separate metadata describing how to restore them.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#custom-serializers | TanStack Query Integration - Custom Serializers}
|
|
81
|
+
*/
|
|
76
82
|
declare class RPCJsonSerializer {
|
|
77
83
|
private readonly handlers;
|
|
84
|
+
private readonly inlineBuiltInHandlers;
|
|
85
|
+
private readonly handlerEntries;
|
|
78
86
|
private readonly omitUndefinedProperties;
|
|
79
87
|
constructor(options?: RPCJsonSerializerOptions);
|
|
80
88
|
serialize(data: unknown): RPCJsonSerialization;
|
|
89
|
+
/**
|
|
90
|
+
* `segments` is a shared mutable stack (push/pop while walking),
|
|
91
|
+
* so it must be copied before being stored in `meta` or `maps`.
|
|
92
|
+
*/
|
|
81
93
|
private serializeValue;
|
|
82
94
|
deserialize(serialized: RPCJsonSerialization): unknown;
|
|
83
95
|
}
|
|
@@ -97,6 +109,12 @@ interface RPCSerializerOptions extends RPCJsonSerializerOptions {
|
|
|
97
109
|
*/
|
|
98
110
|
serialize?: RPCSerializerSerializeOptions | undefined;
|
|
99
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Serializes and deserializes data for the RPC protocol,
|
|
114
|
+
* preserving native types like Date, BigInt, Set, and Map that plain JSON cannot represent.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://orpc.dev/docs/rpc/serializer | RPC Serializer}
|
|
117
|
+
*/
|
|
100
118
|
declare class RPCSerializer {
|
|
101
119
|
private readonly jsonSerializer;
|
|
102
120
|
private readonly defaultSerializeOptions;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { sortPlugins, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, intercept, getOpenTelemetryConfig, value, pathToHttpPath, stringifyJSON } from '@orpc/shared';
|
|
2
2
|
import { mergeStandardHeaders, parseStandardUrl } from '@standardserver/core';
|
|
3
3
|
import { toStandardHeaders } from '@standardserver/fetch';
|
|
4
|
-
import {
|
|
5
|
-
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.DMXKFDyV.mjs';
|
|
4
|
+
import { R as RPCSerializer, c as createORPCErrorFromMalformedResponse, i as isORPCErrorJson, a as createORPCErrorFromJson } from './client.BnATe4Ob.mjs';
|
|
6
5
|
|
|
7
6
|
class CompositeStandardLinkPlugin {
|
|
8
7
|
name = "~composite";
|
|
@@ -38,7 +37,7 @@ class StandardLink {
|
|
|
38
37
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
39
38
|
span?.setAttribute("rpc.method", path.join("."));
|
|
40
39
|
if (isAsyncIteratorObject(input)) {
|
|
41
|
-
input = override(input, traceAsyncIterator("
|
|
40
|
+
input = override(input, traceAsyncIterator("consume_async_iterator_object_input", input));
|
|
42
41
|
}
|
|
43
42
|
return intercept(this.interceptors, { ...options, path, input }, async ({ path: path2, input: input2, ...options2 }) => {
|
|
44
43
|
const otel = getOpenTelemetryConfig();
|
|
@@ -80,7 +79,7 @@ class StandardLink {
|
|
|
80
79
|
}
|
|
81
80
|
const output = decodedResult.output;
|
|
82
81
|
if (isAsyncIteratorObject(output)) {
|
|
83
|
-
return override(output, traceAsyncIterator("
|
|
82
|
+
return override(output, traceAsyncIterator("consume_async_iterator_object_output", output));
|
|
84
83
|
}
|
|
85
84
|
return output;
|
|
86
85
|
});
|
|
@@ -139,13 +138,15 @@ class RPCLinkCodec {
|
|
|
139
138
|
};
|
|
140
139
|
}
|
|
141
140
|
async decodeResponse(response) {
|
|
142
|
-
const isOk = response.status
|
|
141
|
+
const isOk = response.status < 400;
|
|
143
142
|
const body = await response.resolveBody();
|
|
144
143
|
const deserialized = await (async () => {
|
|
145
144
|
try {
|
|
146
145
|
return this.serializer.deserialize(body);
|
|
147
146
|
} catch (cause) {
|
|
148
|
-
throw
|
|
147
|
+
throw createORPCErrorFromMalformedResponse({
|
|
148
|
+
message: "Invalid RPC response format.",
|
|
149
|
+
response: { status: response.status, headers: response.headers, body },
|
|
149
150
|
cause
|
|
150
151
|
});
|
|
151
152
|
}
|
|
@@ -156,9 +157,7 @@ class RPCLinkCodec {
|
|
|
156
157
|
}
|
|
157
158
|
return {
|
|
158
159
|
kind: "error",
|
|
159
|
-
error:
|
|
160
|
-
data: { headers: response.headers, status: response.status, body: deserialized }
|
|
161
|
-
})
|
|
160
|
+
error: createORPCErrorFromMalformedResponse({ response: { headers: response.headers, status: response.status, body } })
|
|
162
161
|
};
|
|
163
162
|
}
|
|
164
163
|
return { kind: "output", output: deserialized };
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.31",
|
|
5
|
+
"description": "Consume oRPC and OpenAPI APIs with end-to-end type safety over HTTP, WebSocket, or message ports",
|
|
5
6
|
"license": "MIT",
|
|
7
|
+
"funding": [
|
|
8
|
+
"https://github.com/sponsors/dinwwwh",
|
|
9
|
+
"https://opencollective.com/middleapi"
|
|
10
|
+
],
|
|
6
11
|
"homepage": "https://orpc.dev",
|
|
7
12
|
"repository": {
|
|
8
13
|
"type": "git",
|
|
@@ -10,7 +15,15 @@
|
|
|
10
15
|
"directory": "packages/client"
|
|
11
16
|
},
|
|
12
17
|
"keywords": [
|
|
13
|
-
"orpc"
|
|
18
|
+
"orpc",
|
|
19
|
+
"rpc",
|
|
20
|
+
"api",
|
|
21
|
+
"typescript",
|
|
22
|
+
"typesafe",
|
|
23
|
+
"client",
|
|
24
|
+
"fetch",
|
|
25
|
+
"websocket",
|
|
26
|
+
"openapi"
|
|
14
27
|
],
|
|
15
28
|
"sideEffects": false,
|
|
16
29
|
"exports": {
|
|
@@ -50,10 +63,10 @@
|
|
|
50
63
|
"dist"
|
|
51
64
|
],
|
|
52
65
|
"dependencies": {
|
|
53
|
-
"@standardserver/core": "^0.0
|
|
54
|
-
"@standardserver/fetch": "^0.0
|
|
55
|
-
"@standardserver/peer": "^0.0
|
|
56
|
-
"@orpc/shared": "2.0.0-beta.
|
|
66
|
+
"@standardserver/core": "^0.8.0",
|
|
67
|
+
"@standardserver/fetch": "^0.8.0",
|
|
68
|
+
"@standardserver/peer": "^0.8.0",
|
|
69
|
+
"@orpc/shared": "2.0.0-beta.31"
|
|
57
70
|
},
|
|
58
71
|
"devDependencies": {
|
|
59
72
|
"zod": "^4.4.3"
|