@orpc/client 0.0.0-next.cc4cb21 → 0.0.0-next.d0e429d
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.
@@ -123,7 +123,7 @@ var RPCJsonSerializer = class {
|
|
123
123
|
};
|
124
124
|
|
125
125
|
// src/rpc/serializer.ts
|
126
|
-
import { isAsyncIteratorObject } from "@orpc/shared";
|
126
|
+
import { isAsyncIteratorObject, stringifyJSON } from "@orpc/shared";
|
127
127
|
import { ErrorEvent } from "@orpc/standard-server";
|
128
128
|
var RPCSerializer = class {
|
129
129
|
constructor(jsonSerializer = new RPCJsonSerializer()) {
|
@@ -134,12 +134,6 @@ var RPCSerializer = class {
|
|
134
134
|
return mapEventIterator(data, {
|
135
135
|
value: async (value) => this.#serialize(value, false),
|
136
136
|
error: async (e) => {
|
137
|
-
if (e instanceof ErrorEvent) {
|
138
|
-
return new ErrorEvent({
|
139
|
-
data: this.#serialize(e.data, false),
|
140
|
-
cause: e
|
141
|
-
});
|
142
|
-
}
|
143
137
|
return new ErrorEvent({
|
144
138
|
data: this.#serialize(toORPCError(e).toJSON(), false),
|
145
139
|
cause: e
|
@@ -162,7 +156,7 @@ var RPCSerializer = class {
|
|
162
156
|
};
|
163
157
|
}
|
164
158
|
const form = new FormData();
|
165
|
-
form.set("data",
|
159
|
+
form.set("data", stringifyJSON({ json, meta, maps }));
|
166
160
|
blobs.forEach((blob, i) => {
|
167
161
|
form.set(i.toString(), blob);
|
168
162
|
});
|
@@ -210,4 +204,4 @@ export {
|
|
210
204
|
RPCJsonSerializer,
|
211
205
|
RPCSerializer
|
212
206
|
};
|
213
|
-
//# sourceMappingURL=chunk-
|
207
|
+
//# sourceMappingURL=chunk-I4MCMTJ2.js.map
|
package/dist/fetch.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import {
|
2
2
|
RPCSerializer
|
3
|
-
} from "./chunk-
|
3
|
+
} from "./chunk-I4MCMTJ2.js";
|
4
4
|
import {
|
5
5
|
ORPCError,
|
6
6
|
createAutoRetryEventIterator
|
7
7
|
} from "./chunk-7F3XVLRJ.js";
|
8
8
|
|
9
9
|
// src/adapters/fetch/rpc-link.ts
|
10
|
-
import { isAsyncIteratorObject, trim, value } from "@orpc/shared";
|
10
|
+
import { isAsyncIteratorObject, stringifyJSON, trim, value } from "@orpc/shared";
|
11
11
|
import { toFetchBody, toStandardBody } from "@orpc/standard-server-fetch";
|
12
12
|
var InvalidEventSourceRetryResponse = class extends Error {
|
13
13
|
};
|
@@ -22,6 +22,7 @@ var RPCLink = class {
|
|
22
22
|
eventSourceMaxNumberOfRetries;
|
23
23
|
eventSourceRetryDelay;
|
24
24
|
eventSourceRetry;
|
25
|
+
toFetchBodyOptions;
|
25
26
|
constructor(options) {
|
26
27
|
this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
27
28
|
this.rpcSerializer = options.rpcSerializer ?? new RPCSerializer();
|
@@ -33,6 +34,7 @@ var RPCLink = class {
|
|
33
34
|
this.headers = options.headers ?? {};
|
34
35
|
this.eventSourceRetry = options.eventSourceRetry ?? true;
|
35
36
|
this.eventSourceRetryDelay = options.eventSourceRetryDelay ?? (({ retryTimes, lastRetry }) => lastRetry ?? 1e3 * 2 ** retryTimes);
|
37
|
+
this.toFetchBodyOptions = options;
|
36
38
|
}
|
37
39
|
async call(path, input, options) {
|
38
40
|
const output = await this.performCall(path, input, options);
|
@@ -58,7 +60,7 @@ var RPCLink = class {
|
|
58
60
|
}
|
59
61
|
async performCall(path, input, options) {
|
60
62
|
const encoded = await this.encodeRequest(path, input, options);
|
61
|
-
const fetchBody = toFetchBody(encoded.body, encoded.headers);
|
63
|
+
const fetchBody = toFetchBody(encoded.body, encoded.headers, this.toFetchBodyOptions);
|
62
64
|
if (options.lastEventId !== void 0) {
|
63
65
|
encoded.headers.set("last-event-id", options.lastEventId);
|
64
66
|
}
|
@@ -102,7 +104,7 @@ var RPCLink = class {
|
|
102
104
|
const serialized = this.rpcSerializer.serialize(input);
|
103
105
|
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !(serialized instanceof Blob) && !isAsyncIteratorObject(serialized)) {
|
104
106
|
const getUrl = new URL(url);
|
105
|
-
getUrl.searchParams.append("data",
|
107
|
+
getUrl.searchParams.append("data", stringifyJSON(serialized) ?? "");
|
106
108
|
if (getUrl.toString().length <= this.maxUrlLength) {
|
107
109
|
return {
|
108
110
|
body: void 0,
|
package/dist/index.js
CHANGED
@@ -71,9 +71,13 @@ async function safe(promise) {
|
|
71
71
|
);
|
72
72
|
}
|
73
73
|
}
|
74
|
+
|
75
|
+
// src/index.ts
|
76
|
+
import { ErrorEvent } from "@orpc/standard-server";
|
74
77
|
export {
|
75
78
|
COMMON_ORPC_ERROR_DEFS,
|
76
79
|
DynamicLink,
|
80
|
+
ErrorEvent,
|
77
81
|
ORPCError,
|
78
82
|
createAutoRetryEventIterator,
|
79
83
|
createORPCClient,
|
package/dist/openapi.js
CHANGED
@@ -173,12 +173,6 @@ var OpenAPISerializer = class {
|
|
173
173
|
return mapEventIterator(data, {
|
174
174
|
value: async (value) => this.#serialize(value, false),
|
175
175
|
error: async (e) => {
|
176
|
-
if (e instanceof ErrorEvent) {
|
177
|
-
return new ErrorEvent({
|
178
|
-
data: this.#serialize(e.data, false),
|
179
|
-
cause: e
|
180
|
-
});
|
181
|
-
}
|
182
176
|
return new ErrorEvent({
|
183
177
|
data: this.#serialize(toORPCError(e).toJSON(), false),
|
184
178
|
cause: e
|
package/dist/rpc.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Value } from '@orpc/shared';
|
2
|
+
import type { ToFetchBodyOptions } from '@orpc/standard-server-fetch';
|
2
3
|
import type { ClientContext, ClientLink, ClientOptionsOut } from '../../types';
|
3
4
|
import type { FetchWithContext } from './types';
|
4
5
|
import { type EventIteratorReconnectOptions } from '../../event-iterator';
|
@@ -6,7 +7,7 @@ import { RPCSerializer } from '../../rpc';
|
|
6
7
|
type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
7
8
|
export declare class InvalidEventSourceRetryResponse extends Error {
|
8
9
|
}
|
9
|
-
export interface RPCLinkOptions<TClientContext extends ClientContext> {
|
10
|
+
export interface RPCLinkOptions<TClientContext extends ClientContext> extends ToFetchBodyOptions {
|
10
11
|
/**
|
11
12
|
* Base url for all requests.
|
12
13
|
*/
|
@@ -89,6 +90,7 @@ export declare class RPCLink<TClientContext extends ClientContext> implements Cl
|
|
89
90
|
private readonly eventSourceMaxNumberOfRetries;
|
90
91
|
private readonly eventSourceRetryDelay;
|
91
92
|
private readonly eventSourceRetry;
|
93
|
+
private readonly toFetchBodyOptions;
|
92
94
|
constructor(options: RPCLinkOptions<TClientContext>);
|
93
95
|
call(path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>): Promise<unknown>;
|
94
96
|
private performCall;
|
package/dist/src/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/client",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.d0e429d",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -44,9 +44,9 @@
|
|
44
44
|
"dist"
|
45
45
|
],
|
46
46
|
"dependencies": {
|
47
|
-
"@orpc/
|
48
|
-
"@orpc/
|
49
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
47
|
+
"@orpc/shared": "0.0.0-next.d0e429d",
|
48
|
+
"@orpc/standard-server": "0.0.0-next.d0e429d",
|
49
|
+
"@orpc/standard-server-fetch": "0.0.0-next.d0e429d"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"zod": "^3.24.1"
|