@dxos/edge-client 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d
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/lib/browser/{chunk-LMP5TVOP.mjs → chunk-SUXH7FH6.mjs} +8 -1
- package/dist/lib/browser/{chunk-LMP5TVOP.mjs.map → chunk-SUXH7FH6.mjs.map} +3 -3
- package/dist/lib/browser/edge-ws-muxer.mjs +1 -1
- package/dist/lib/browser/index.mjs +72 -37
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-X7J46ISZ.mjs → chunk-R6K4IIBW.mjs} +8 -1
- package/dist/lib/node-esm/{chunk-X7J46ISZ.mjs.map → chunk-R6K4IIBW.mjs.map} +3 -3
- package/dist/lib/node-esm/edge-ws-muxer.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +72 -37
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/edge-client.d.ts +1 -1
- package/dist/types/src/edge-client.d.ts.map +1 -1
- package/dist/types/src/edge-http-client.d.ts +2 -1
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/edge-ws-connection.d.ts +1 -0
- package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
- package/dist/types/src/edge-ws-muxer.d.ts.map +1 -1
- package/dist/types/src/testing/test-utils.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -15
- package/src/edge-client.ts +2 -2
- package/src/edge-http-client.ts +10 -6
- package/src/edge-ws-connection.ts +11 -3
- package/src/edge-ws-muxer.ts +1 -1
- package/src/http-client.test.ts +0 -1
- package/src/testing/test-utils.ts +1 -1
- package/src/websocket.test.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/edge-client",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.fd6878d",
|
|
4
4
|
"description": "EDGE Client",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,16 +10,19 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
17
|
},
|
|
17
18
|
"./muxer": {
|
|
19
|
+
"source": "./src/edge-ws-muxer.ts",
|
|
18
20
|
"types": "./dist/types/src/edge-ws-muxer.d.ts",
|
|
19
21
|
"browser": "./dist/lib/browser/edge-ws-muxer.mjs",
|
|
20
22
|
"node": "./dist/lib/node-esm/edge-ws-muxer.mjs"
|
|
21
23
|
},
|
|
22
24
|
"./testing": {
|
|
25
|
+
"source": "./src/testing/index.ts",
|
|
23
26
|
"types": "./dist/types/src/testing/index.d.ts",
|
|
24
27
|
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
25
28
|
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
@@ -39,24 +42,24 @@
|
|
|
39
42
|
"README.md"
|
|
40
43
|
],
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"@effect/platform": "^0.
|
|
45
|
+
"@effect/platform": "^0.90.2",
|
|
43
46
|
"isomorphic-ws": "^5.0.0",
|
|
44
47
|
"ws": "^8.14.2",
|
|
45
|
-
"@dxos/async": "0.8.4-main.
|
|
46
|
-
"@dxos/context": "0.8.4-main.
|
|
47
|
-
"@dxos/crypto": "0.8.4-main.
|
|
48
|
-
"@dxos/credentials": "0.8.4-main.
|
|
49
|
-
"@dxos/debug": "0.8.4-main.
|
|
50
|
-
"@dxos/invariant": "0.8.4-main.
|
|
51
|
-
"@dxos/keyring": "0.8.4-main.
|
|
52
|
-
"@dxos/keys": "0.8.4-main.
|
|
53
|
-
"@dxos/log": "0.8.4-main.
|
|
54
|
-
"@dxos/node-std": "0.8.4-main.
|
|
55
|
-
"@dxos/protocols": "0.8.4-main.
|
|
56
|
-
"@dxos/util": "0.8.4-main.
|
|
48
|
+
"@dxos/async": "0.8.4-main.fd6878d",
|
|
49
|
+
"@dxos/context": "0.8.4-main.fd6878d",
|
|
50
|
+
"@dxos/crypto": "0.8.4-main.fd6878d",
|
|
51
|
+
"@dxos/credentials": "0.8.4-main.fd6878d",
|
|
52
|
+
"@dxos/debug": "0.8.4-main.fd6878d",
|
|
53
|
+
"@dxos/invariant": "0.8.4-main.fd6878d",
|
|
54
|
+
"@dxos/keyring": "0.8.4-main.fd6878d",
|
|
55
|
+
"@dxos/keys": "0.8.4-main.fd6878d",
|
|
56
|
+
"@dxos/log": "0.8.4-main.fd6878d",
|
|
57
|
+
"@dxos/node-std": "0.8.4-main.fd6878d",
|
|
58
|
+
"@dxos/protocols": "0.8.4-main.fd6878d",
|
|
59
|
+
"@dxos/util": "0.8.4-main.fd6878d"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
|
-
"@dxos/test-utils": "0.8.4-main.
|
|
62
|
+
"@dxos/test-utils": "0.8.4-main.fd6878d"
|
|
60
63
|
},
|
|
61
64
|
"peerDependencies": {
|
|
62
65
|
"effect": "^3.13.3"
|
package/src/edge-client.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { Event, PersistentLifecycle, Trigger, TriggerState, scheduleMicroTask } from '@dxos/async';
|
|
6
|
+
import { type Lifecycle, Resource } from '@dxos/context';
|
|
7
7
|
import { log, logInfo } from '@dxos/log';
|
|
8
8
|
import { type Message } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
9
9
|
import { EdgeStatus } from '@dxos/protocols/proto/dxos/client/services';
|
package/src/edge-http-client.ts
CHANGED
|
@@ -10,13 +10,14 @@ import { Context } from '@dxos/context';
|
|
|
10
10
|
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import {
|
|
13
|
-
type CreateAgentResponseBody,
|
|
14
13
|
type CreateAgentRequestBody,
|
|
14
|
+
type CreateAgentResponseBody,
|
|
15
15
|
type CreateSpaceRequest,
|
|
16
16
|
type CreateSpaceResponseBody,
|
|
17
17
|
EdgeAuthChallengeError,
|
|
18
18
|
EdgeCallFailedError,
|
|
19
19
|
type EdgeHttpResponse,
|
|
20
|
+
type EdgeStatus,
|
|
20
21
|
type ExecuteWorkflowResponseBody,
|
|
21
22
|
type GetAgentStatusResponseBody,
|
|
22
23
|
type GetNotarizationResponseBody,
|
|
@@ -24,20 +25,19 @@ import {
|
|
|
24
25
|
type InitiateOAuthFlowResponse,
|
|
25
26
|
type JoinSpaceRequest,
|
|
26
27
|
type JoinSpaceResponseBody,
|
|
27
|
-
type RecoverIdentityRequest,
|
|
28
|
-
type RecoverIdentityResponseBody,
|
|
29
28
|
type ObjectId,
|
|
30
29
|
type PostNotarizationRequestBody,
|
|
31
|
-
type QueueQuery,
|
|
32
30
|
type QueryResult,
|
|
31
|
+
type QueueQuery,
|
|
32
|
+
type RecoverIdentityRequest,
|
|
33
|
+
type RecoverIdentityResponseBody,
|
|
33
34
|
type UploadFunctionRequest,
|
|
34
35
|
type UploadFunctionResponseBody,
|
|
35
|
-
type EdgeStatus,
|
|
36
36
|
} from '@dxos/protocols';
|
|
37
37
|
import { createUrl } from '@dxos/util';
|
|
38
38
|
|
|
39
39
|
import { type EdgeIdentity, handleAuthChallenge } from './edge-identity';
|
|
40
|
-
import {
|
|
40
|
+
import { HttpConfig, encodeAuthHeader, withLogging, withRetryConfig } from './http-client';
|
|
41
41
|
import { getEdgeUrlWithProtocol } from './utils';
|
|
42
42
|
|
|
43
43
|
const DEFAULT_RETRY_TIMEOUT = 1500;
|
|
@@ -164,6 +164,10 @@ export class EdgeHttpClient {
|
|
|
164
164
|
// OAuth and credentials
|
|
165
165
|
//
|
|
166
166
|
|
|
167
|
+
public async listFunctions(args?: EdgeHttpGetArgs): Promise<any> {
|
|
168
|
+
return this._call(new URL('/functions', this.baseUrl), { ...args, method: 'GET' });
|
|
169
|
+
}
|
|
170
|
+
|
|
167
171
|
public async initiateOAuthFlow(
|
|
168
172
|
body: InitiateOAuthFlowRequest,
|
|
169
173
|
args?: EdgeHttpGetArgs,
|
|
@@ -10,7 +10,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
10
10
|
import { log, logInfo } from '@dxos/log';
|
|
11
11
|
import { EdgeWebsocketProtocol } from '@dxos/protocols';
|
|
12
12
|
import { buf } from '@dxos/protocols/buf';
|
|
13
|
-
import {
|
|
13
|
+
import { type Message, MessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
14
14
|
|
|
15
15
|
import { protocol } from './defs';
|
|
16
16
|
import { type EdgeIdentity } from './edge-identity';
|
|
@@ -30,6 +30,7 @@ export class EdgeWsConnection extends Resource {
|
|
|
30
30
|
private _inactivityTimeoutCtx: Context | undefined;
|
|
31
31
|
private _ws: WebSocket | undefined;
|
|
32
32
|
private _wsMuxer: WebSocketMuxer | undefined;
|
|
33
|
+
private _lastReceivedMessageTimestamp = Date.now();
|
|
33
34
|
|
|
34
35
|
constructor(
|
|
35
36
|
private readonly _identity: EdgeIdentity,
|
|
@@ -111,6 +112,7 @@ export class EdgeWsConnection extends Resource {
|
|
|
111
112
|
log.verbose('message ignored on closed connection', { event: event.type });
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
115
|
+
this._lastReceivedMessageTimestamp = Date.now();
|
|
114
116
|
if (event.data === '__pong__') {
|
|
115
117
|
this._rescheduleHeartbeatTimeout();
|
|
116
118
|
return;
|
|
@@ -172,8 +174,14 @@ export class EdgeWsConnection extends Resource {
|
|
|
172
174
|
this._inactivityTimeoutCtx,
|
|
173
175
|
() => {
|
|
174
176
|
if (this.isOpen) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
if (Date.now() - this._lastReceivedMessageTimestamp > SIGNAL_KEEPALIVE_TIMEOUT) {
|
|
178
|
+
log.warn('restart due to inactivity timeout', {
|
|
179
|
+
lastReceivedMessageTimestamp: this._lastReceivedMessageTimestamp,
|
|
180
|
+
});
|
|
181
|
+
this._callbacks.onRestartRequired();
|
|
182
|
+
} else {
|
|
183
|
+
this._rescheduleHeartbeatTimeout();
|
|
184
|
+
}
|
|
177
185
|
}
|
|
178
186
|
},
|
|
179
187
|
SIGNAL_KEEPALIVE_TIMEOUT,
|
package/src/edge-ws-muxer.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Trigger } from '@dxos/async';
|
|
6
6
|
import { log } from '@dxos/log';
|
|
7
7
|
import { buf } from '@dxos/protocols/buf';
|
|
8
|
-
import {
|
|
8
|
+
import { type Message, MessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
9
9
|
|
|
10
10
|
import { protocol } from './defs';
|
|
11
11
|
|
package/src/http-client.test.ts
CHANGED
|
@@ -18,7 +18,6 @@ describe('HttpClient', () => {
|
|
|
18
18
|
server = await createTestServer(responseHandler((attempt) => (attempt > 2 ? { value: 100 } : false)));
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
// eslint-disable-next-line mocha/no-top-level-hooks
|
|
22
21
|
afterEach(() => {
|
|
23
22
|
server?.close();
|
|
24
23
|
server = undefined;
|
|
@@ -8,7 +8,7 @@ import { Trigger } from '@dxos/async';
|
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { EdgeWebsocketProtocol } from '@dxos/protocols';
|
|
10
10
|
import { buf } from '@dxos/protocols/buf';
|
|
11
|
-
import { MessageSchema, TextMessageSchema
|
|
11
|
+
import { type Message, MessageSchema, TextMessageSchema } from '@dxos/protocols/buf/dxos/edge/messenger_pb';
|
|
12
12
|
|
|
13
13
|
import { protocol } from '../defs';
|
|
14
14
|
import { WebSocketMuxer } from '../edge-ws-muxer';
|
package/src/websocket.test.ts
CHANGED