@orpc/client 1.0.0-beta.2 → 1.0.0-beta.3
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/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.mjs +14 -14
- package/dist/shared/{client.Be-O_tdu.mjs → client.3Q53fveR.mjs} +3 -0
- package/package.json +4 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
import { toFetchRequest, toStandardLazyResponse } from '@orpc/standard-server-fetch';
|
2
|
-
import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.
|
2
|
+
import { b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer, S as StandardLink } from '../../shared/client.3Q53fveR.mjs';
|
3
3
|
import '@orpc/shared';
|
4
4
|
import '../../shared/client.CvnV7_uV.mjs';
|
5
5
|
import '@orpc/standard-server';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.
|
1
|
+
export { I as InvalidEventIteratorRetryResponse, a as STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES, S as StandardLink, b as StandardRPCJsonSerializer, c as StandardRPCLinkCodec, d as StandardRPCSerializer } from '../../shared/client.3Q53fveR.mjs';
|
2
2
|
import '@orpc/shared';
|
3
3
|
import '../../shared/client.CvnV7_uV.mjs';
|
4
4
|
import '@orpc/standard-server';
|
package/dist/plugins/index.d.mts
CHANGED
@@ -5,8 +5,8 @@ import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM
|
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
|
7
7
|
interface ClientRetryPluginAttemptOptions {
|
8
|
-
|
9
|
-
|
8
|
+
lastEventRetry: number | undefined;
|
9
|
+
lastEventId: string | undefined;
|
10
10
|
attemptIndex: number;
|
11
11
|
error: unknown;
|
12
12
|
}
|
@@ -21,7 +21,7 @@ interface ClientRetryPluginContext {
|
|
21
21
|
/**
|
22
22
|
* Delay (in ms) before retrying.
|
23
23
|
*
|
24
|
-
* @default (o) => o.
|
24
|
+
* @default (o) => o.lastEventRetry ?? 2000
|
25
25
|
*/
|
26
26
|
retryDelay?: Value<number, [
|
27
27
|
attemptOptions: ClientRetryPluginAttemptOptions,
|
package/dist/plugins/index.d.ts
CHANGED
@@ -5,8 +5,8 @@ import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM
|
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
|
7
7
|
interface ClientRetryPluginAttemptOptions {
|
8
|
-
|
9
|
-
|
8
|
+
lastEventRetry: number | undefined;
|
9
|
+
lastEventId: string | undefined;
|
10
10
|
attemptIndex: number;
|
11
11
|
error: unknown;
|
12
12
|
}
|
@@ -21,7 +21,7 @@ interface ClientRetryPluginContext {
|
|
21
21
|
/**
|
22
22
|
* Delay (in ms) before retrying.
|
23
23
|
*
|
24
|
-
* @default (o) => o.
|
24
|
+
* @default (o) => o.lastEventRetry ?? 2000
|
25
25
|
*/
|
26
26
|
retryDelay?: Value<number, [
|
27
27
|
attemptOptions: ClientRetryPluginAttemptOptions,
|
package/dist/plugins/index.mjs
CHANGED
@@ -11,7 +11,7 @@ class ClientRetryPlugin {
|
|
11
11
|
defaultOnRetry;
|
12
12
|
constructor(options = {}) {
|
13
13
|
this.defaultRetry = options.default?.retry ?? 0;
|
14
|
-
this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.
|
14
|
+
this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.lastEventRetry ?? 2e3);
|
15
15
|
this.defaultShouldRetry = options.default?.shouldRetry ?? true;
|
16
16
|
this.defaultOnRetry = options.default?.onRetry;
|
17
17
|
}
|
@@ -25,13 +25,14 @@ class ClientRetryPlugin {
|
|
25
25
|
if (maxAttempts <= 0) {
|
26
26
|
return interceptorOptions.next();
|
27
27
|
}
|
28
|
-
let
|
29
|
-
let
|
28
|
+
let lastEventId = interceptorOptions.options.lastEventId;
|
29
|
+
let lastEventRetry;
|
30
30
|
let unsubscribe;
|
31
31
|
let attemptIndex = 0;
|
32
32
|
const next = async (initial) => {
|
33
33
|
let current = initial;
|
34
34
|
while (true) {
|
35
|
+
const newClientOptions = { ...interceptorOptions.options, lastEventId };
|
35
36
|
if (current) {
|
36
37
|
if (attemptIndex >= maxAttempts) {
|
37
38
|
throw current.error;
|
@@ -39,13 +40,13 @@ class ClientRetryPlugin {
|
|
39
40
|
const attemptOptions = {
|
40
41
|
attemptIndex,
|
41
42
|
error: current.error,
|
42
|
-
|
43
|
-
|
43
|
+
lastEventId,
|
44
|
+
lastEventRetry
|
44
45
|
};
|
45
46
|
const shouldRetryBool = await value(
|
46
47
|
shouldRetry,
|
47
48
|
attemptOptions,
|
48
|
-
|
49
|
+
newClientOptions,
|
49
50
|
interceptorOptions.path,
|
50
51
|
interceptorOptions.input
|
51
52
|
);
|
@@ -54,14 +55,14 @@ class ClientRetryPlugin {
|
|
54
55
|
}
|
55
56
|
unsubscribe = onRetry?.(
|
56
57
|
attemptOptions,
|
57
|
-
|
58
|
+
newClientOptions,
|
58
59
|
interceptorOptions.path,
|
59
60
|
interceptorOptions.input
|
60
61
|
);
|
61
62
|
const retryDelayMs = await value(
|
62
63
|
retryDelay,
|
63
64
|
attemptOptions,
|
64
|
-
|
65
|
+
newClientOptions,
|
65
66
|
interceptorOptions.path,
|
66
67
|
interceptorOptions.input
|
67
68
|
);
|
@@ -69,14 +70,13 @@ class ClientRetryPlugin {
|
|
69
70
|
attemptIndex++;
|
70
71
|
}
|
71
72
|
try {
|
72
|
-
const newClientOptions = { ...interceptorOptions.options, lastEventId: eventIteratorLastEventId };
|
73
73
|
const output2 = await interceptorOptions.next({
|
74
74
|
...interceptorOptions,
|
75
75
|
options: newClientOptions
|
76
76
|
});
|
77
77
|
return output2;
|
78
78
|
} catch (error) {
|
79
|
-
if (
|
79
|
+
if (newClientOptions.signal?.aborted === true) {
|
80
80
|
throw error;
|
81
81
|
}
|
82
82
|
current = { error };
|
@@ -97,16 +97,16 @@ class ClientRetryPlugin {
|
|
97
97
|
try {
|
98
98
|
const item = await current.next();
|
99
99
|
const meta = getEventMeta(item.value);
|
100
|
-
|
101
|
-
|
100
|
+
lastEventId = meta?.id ?? lastEventId;
|
101
|
+
lastEventRetry = meta?.retry ?? lastEventRetry;
|
102
102
|
if (item.done) {
|
103
103
|
return item.value;
|
104
104
|
}
|
105
105
|
yield item.value;
|
106
106
|
} catch (error) {
|
107
107
|
const meta = getEventMeta(error);
|
108
|
-
|
109
|
-
|
108
|
+
lastEventId = meta?.id ?? lastEventId;
|
109
|
+
lastEventRetry = meta?.retry ?? lastEventRetry;
|
110
110
|
const maybeEventIterator = await next({ error });
|
111
111
|
if (!isAsyncIteratorObject(maybeEventIterator)) {
|
112
112
|
throw new ClientRetryPluginInvalidEventIteratorRetryResponse(
|
@@ -111,6 +111,9 @@ class StandardRPCJsonSerializer {
|
|
111
111
|
if (isObject(data)) {
|
112
112
|
const json = {};
|
113
113
|
for (const k in data) {
|
114
|
+
if (k === "toJSON" && typeof data[k] === "function") {
|
115
|
+
continue;
|
116
|
+
}
|
114
117
|
json[k] = this.serialize(data[k], [...segments, k], meta, maps, blobs)[0];
|
115
118
|
}
|
116
119
|
return [json, meta, maps, blobs];
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/client",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.0.0-beta.
|
4
|
+
"version": "1.0.0-beta.3",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -39,9 +39,9 @@
|
|
39
39
|
"dist"
|
40
40
|
],
|
41
41
|
"dependencies": {
|
42
|
-
"@orpc/shared": "1.0.0-beta.
|
43
|
-
"@orpc/standard-server
|
44
|
-
"@orpc/standard-server": "1.0.0-beta.
|
42
|
+
"@orpc/shared": "1.0.0-beta.3",
|
43
|
+
"@orpc/standard-server": "1.0.0-beta.3",
|
44
|
+
"@orpc/standard-server-fetch": "1.0.0-beta.3"
|
45
45
|
},
|
46
46
|
"devDependencies": {
|
47
47
|
"zod": "^3.24.2"
|