@orpc/experimental-durable-iterator 0.0.0-next.01f0b7a → 0.0.0-next.03cefb3
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 +0 -3
- package/dist/client/index.d.mts +1 -8
- package/dist/client/index.d.ts +1 -8
- package/dist/client/index.mjs +21 -29
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
-
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
-
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
-
</a>
|
|
23
20
|
</div>
|
|
24
21
|
|
|
25
22
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
package/dist/client/index.d.mts
CHANGED
|
@@ -39,12 +39,6 @@ interface DurableIteratorLinkPluginOptions<T extends ClientContext> extends Omit
|
|
|
39
39
|
* @default NaN (disabled)
|
|
40
40
|
*/
|
|
41
41
|
refreshTokenBeforeExpireInSeconds?: Value<Promisable<number>, [tokenPayload: DurableIteratorTokenPayload, options: StandardLinkInterceptorOptions<T>]>;
|
|
42
|
-
/**
|
|
43
|
-
* Minimum delay between token refresh attempts.
|
|
44
|
-
*
|
|
45
|
-
* @default 2 (seconds)
|
|
46
|
-
*/
|
|
47
|
-
refreshTokenDelayInSeconds?: Value<Promisable<number>, [tokenPayload: DurableIteratorTokenPayload, options: StandardLinkInterceptorOptions<T>]>;
|
|
48
42
|
}
|
|
49
43
|
/**
|
|
50
44
|
* @see {@link https://orpc.unnoq.com/docs/integrations/durable-iterator Durable Iterator Integration}
|
|
@@ -58,9 +52,8 @@ declare class DurableIteratorLinkPlugin<T extends ClientContext> implements Stan
|
|
|
58
52
|
private readonly url;
|
|
59
53
|
private readonly createId;
|
|
60
54
|
private readonly refreshTokenBeforeExpireInSeconds;
|
|
61
|
-
private readonly refreshTokenDelayInSeconds;
|
|
62
55
|
private readonly linkOptions;
|
|
63
|
-
constructor({ url, refreshTokenBeforeExpireInSeconds,
|
|
56
|
+
constructor({ url, refreshTokenBeforeExpireInSeconds, ...options }: DurableIteratorLinkPluginOptions<T>);
|
|
64
57
|
init(options: StandardLinkOptions<T>): void;
|
|
65
58
|
private validateToken;
|
|
66
59
|
}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -39,12 +39,6 @@ interface DurableIteratorLinkPluginOptions<T extends ClientContext> extends Omit
|
|
|
39
39
|
* @default NaN (disabled)
|
|
40
40
|
*/
|
|
41
41
|
refreshTokenBeforeExpireInSeconds?: Value<Promisable<number>, [tokenPayload: DurableIteratorTokenPayload, options: StandardLinkInterceptorOptions<T>]>;
|
|
42
|
-
/**
|
|
43
|
-
* Minimum delay between token refresh attempts.
|
|
44
|
-
*
|
|
45
|
-
* @default 2 (seconds)
|
|
46
|
-
*/
|
|
47
|
-
refreshTokenDelayInSeconds?: Value<Promisable<number>, [tokenPayload: DurableIteratorTokenPayload, options: StandardLinkInterceptorOptions<T>]>;
|
|
48
42
|
}
|
|
49
43
|
/**
|
|
50
44
|
* @see {@link https://orpc.unnoq.com/docs/integrations/durable-iterator Durable Iterator Integration}
|
|
@@ -58,9 +52,8 @@ declare class DurableIteratorLinkPlugin<T extends ClientContext> implements Stan
|
|
|
58
52
|
private readonly url;
|
|
59
53
|
private readonly createId;
|
|
60
54
|
private readonly refreshTokenBeforeExpireInSeconds;
|
|
61
|
-
private readonly refreshTokenDelayInSeconds;
|
|
62
55
|
private readonly linkOptions;
|
|
63
|
-
constructor({ url, refreshTokenBeforeExpireInSeconds,
|
|
56
|
+
constructor({ url, refreshTokenBeforeExpireInSeconds, ...options }: DurableIteratorLinkPluginOptions<T>);
|
|
64
57
|
init(options: StandardLinkOptions<T>): void;
|
|
65
58
|
private validateToken;
|
|
66
59
|
}
|
package/dist/client/index.mjs
CHANGED
|
@@ -18,13 +18,11 @@ class DurableIteratorLinkPlugin {
|
|
|
18
18
|
url;
|
|
19
19
|
createId;
|
|
20
20
|
refreshTokenBeforeExpireInSeconds;
|
|
21
|
-
refreshTokenDelayInSeconds;
|
|
22
21
|
linkOptions;
|
|
23
|
-
constructor({ url, refreshTokenBeforeExpireInSeconds,
|
|
22
|
+
constructor({ url, refreshTokenBeforeExpireInSeconds, ...options }) {
|
|
24
23
|
this.url = url;
|
|
25
24
|
this.createId = fallback(options.createId, () => crypto.randomUUID());
|
|
26
25
|
this.refreshTokenBeforeExpireInSeconds = fallback(refreshTokenBeforeExpireInSeconds, Number.NaN);
|
|
27
|
-
this.refreshTokenDelayInSeconds = fallback(refreshTokenDelayInSeconds, 2);
|
|
28
26
|
this.linkOptions = options;
|
|
29
27
|
}
|
|
30
28
|
init(options) {
|
|
@@ -64,37 +62,31 @@ class DurableIteratorLinkPlugin {
|
|
|
64
62
|
let refreshTokenBeforeExpireTimeoutId;
|
|
65
63
|
const refreshTokenBeforeExpire = async () => {
|
|
66
64
|
const beforeSeconds = await value(this.refreshTokenBeforeExpireInSeconds, tokenAndPayload.payload, options2);
|
|
67
|
-
const delayMilliseconds = await value(this.refreshTokenDelayInSeconds, tokenAndPayload.payload, options2) * 1e3;
|
|
68
65
|
if (isFinished || !Number.isFinite(beforeSeconds)) {
|
|
69
66
|
return;
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
throw err;
|
|
68
|
+
const nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
69
|
+
refreshTokenBeforeExpireTimeoutId = setTimeout(async () => {
|
|
70
|
+
const newTokenAndPayload = await retry({ times: Number.POSITIVE_INFINITY, delay: 2e3 }, async (exit) => {
|
|
71
|
+
try {
|
|
72
|
+
const output2 = await next();
|
|
73
|
+
return this.validateToken(output2, options2.path);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (isFinished) {
|
|
76
|
+
exit(err);
|
|
82
77
|
}
|
|
83
|
-
|
|
84
|
-
const canProactivelyUpdateToken = newTokenAndPayload.payload.chn === tokenAndPayload.payload.chn && stringifyJSON(newTokenAndPayload.payload.tags) === stringifyJSON(tokenAndPayload.payload.tags);
|
|
85
|
-
tokenAndPayload = newTokenAndPayload;
|
|
86
|
-
await refreshTokenBeforeExpire();
|
|
87
|
-
if (canProactivelyUpdateToken) {
|
|
88
|
-
await durableClient.updateToken({ token: tokenAndPayload.token });
|
|
89
|
-
} else {
|
|
90
|
-
websocket.reconnect();
|
|
78
|
+
throw err;
|
|
91
79
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
97
|
-
|
|
80
|
+
});
|
|
81
|
+
const canProactivelyUpdateToken = newTokenAndPayload.payload.chn === tokenAndPayload.payload.chn && stringifyJSON(newTokenAndPayload.payload.tags) === stringifyJSON(tokenAndPayload.payload.tags);
|
|
82
|
+
tokenAndPayload = newTokenAndPayload;
|
|
83
|
+
await refreshTokenBeforeExpire();
|
|
84
|
+
if (canProactivelyUpdateToken) {
|
|
85
|
+
await durableClient.updateToken({ token: tokenAndPayload.token });
|
|
86
|
+
} else {
|
|
87
|
+
websocket.reconnect();
|
|
88
|
+
}
|
|
89
|
+
}, (tokenAndPayload.payload.exp - nowInSeconds - beforeSeconds) * 1e3);
|
|
98
90
|
};
|
|
99
91
|
refreshTokenBeforeExpire();
|
|
100
92
|
const closeConnection = () => {
|
package/dist/index.d.mts
CHANGED
|
@@ -52,6 +52,8 @@ interface DurableIteratorOptions<T extends DurableIteratorObject<any>, RPC exten
|
|
|
52
52
|
* The methods that are allowed to be called remotely.
|
|
53
53
|
*
|
|
54
54
|
* @warning Please use .rpc method to set this field in case ts complains about value you pass
|
|
55
|
+
*
|
|
56
|
+
* @default []
|
|
55
57
|
*/
|
|
56
58
|
rpc?: readonly RPC[];
|
|
57
59
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ interface DurableIteratorOptions<T extends DurableIteratorObject<any>, RPC exten
|
|
|
52
52
|
* The methods that are allowed to be called remotely.
|
|
53
53
|
*
|
|
54
54
|
* @warning Please use .rpc method to set this field in case ts complains about value you pass
|
|
55
|
+
*
|
|
56
|
+
* @default []
|
|
55
57
|
*/
|
|
56
58
|
rpc?: readonly RPC[];
|
|
57
59
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/experimental-durable-iterator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.03cefb3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"partysocket": "^1.1.5",
|
|
38
38
|
"valibot": "^1.1.0",
|
|
39
|
-
"@orpc/client": "0.0.0-next.
|
|
40
|
-
"@orpc/contract": "0.0.0-next.
|
|
41
|
-
"@orpc/
|
|
42
|
-
"@orpc/
|
|
39
|
+
"@orpc/client": "0.0.0-next.03cefb3",
|
|
40
|
+
"@orpc/contract": "0.0.0-next.03cefb3",
|
|
41
|
+
"@orpc/shared": "0.0.0-next.03cefb3",
|
|
42
|
+
"@orpc/server": "0.0.0-next.03cefb3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@cloudflare/workers-types": "^4.
|
|
45
|
+
"@cloudflare/workers-types": "^4.20250922.0",
|
|
46
46
|
"@types/node": "^22.15.30",
|
|
47
|
-
"@orpc/standard-server-peer": "0.0.0-next.
|
|
47
|
+
"@orpc/standard-server-peer": "0.0.0-next.03cefb3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "unbuild",
|