@dxos/edge-client 0.7.4 → 0.7.5-feature-compute.4d9d99a
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/index.mjs +72 -24
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +72 -24
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +72 -24
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/edge-http-client.d.ts +4 -1
- package/dist/types/src/edge-http-client.d.ts.map +1 -1
- package/dist/types/src/edge-ws-connection.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +14 -14
- package/src/edge-http-client.ts +57 -0
- package/src/edge-ws-connection.ts +7 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from '@dxos/context';
|
|
2
2
|
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
3
|
-
import { type GetNotarizationResponseBody, type PostNotarizationRequestBody, type JoinSpaceRequest, type JoinSpaceResponseBody, type CreateAgentResponseBody, type CreateAgentRequestBody, type GetAgentStatusResponseBody, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
3
|
+
import { type GetNotarizationResponseBody, type PostNotarizationRequestBody, type JoinSpaceRequest, type JoinSpaceResponseBody, type CreateAgentResponseBody, type CreateAgentRequestBody, type GetAgentStatusResponseBody, type RecoverIdentityRequest, type RecoverIdentityResponseBody, type UploadFunctionRequest, type UploadFunctionResponseBody, type ObjectId, type ExecuteWorkflowResponseBody, type QueueQuery, type QueryResult } from '@dxos/protocols';
|
|
4
4
|
import { type EdgeIdentity } from './edge-identity';
|
|
5
5
|
export declare class EdgeHttpClient {
|
|
6
6
|
private readonly _baseUrl;
|
|
@@ -19,10 +19,13 @@ export declare class EdgeHttpClient {
|
|
|
19
19
|
notarizeCredentials(spaceId: SpaceId, body: PostNotarizationRequestBody, args?: EdgeHttpGetArgs): Promise<void>;
|
|
20
20
|
joinSpaceByInvitation(spaceId: SpaceId, body: JoinSpaceRequest, args?: EdgeHttpGetArgs): Promise<JoinSpaceResponseBody>;
|
|
21
21
|
recoverIdentity(body: RecoverIdentityRequest, args?: EdgeHttpGetArgs): Promise<RecoverIdentityResponseBody>;
|
|
22
|
+
executeWorkflow(spaceId: SpaceId, graphId: ObjectId, input: any, args?: EdgeHttpGetArgs): Promise<ExecuteWorkflowResponseBody>;
|
|
22
23
|
uploadFunction(pathParts: {
|
|
23
24
|
spaceId: SpaceId;
|
|
24
25
|
functionId?: string;
|
|
25
26
|
}, body: UploadFunctionRequest, args?: EdgeHttpGetArgs): Promise<UploadFunctionResponseBody>;
|
|
27
|
+
queryQueue(subspaceTag: string, spaceId: SpaceId, query: QueueQuery, args?: EdgeHttpGetArgs): Promise<QueryResult>;
|
|
28
|
+
insertIntoQueue(subspaceTag: string, spaceId: SpaceId, queueId: ObjectId, objects: unknown[], args?: EdgeHttpGetArgs): Promise<void>;
|
|
26
29
|
private _call;
|
|
27
30
|
private _handleUnauthorized;
|
|
28
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-http-client.d.ts","sourceRoot":"","sources":["../../../src/edge-http-client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EAGL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAE1B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC3B,KAAK,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AM,WAAW,GAAG;IACxB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAEzE,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-ws-connection.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAGzF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"edge-ws-connection.d.ts","sourceRoot":"","sources":["../../../src/edge-ws-connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIlD,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,4CAA4C,CAAC;AAGzF,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMpD,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,QAAQ;IAK1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAN7B,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,GAAG,CAAwB;gBAGhB,SAAS,EAAE,YAAY,EACvB,eAAe,EAAE;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EACtD,UAAU,EAAE,yBAAyB;IAKxD,IACW,IAAI;;;;MAMd;IAEM,IAAI,CAAC,OAAO,EAAE,OAAO;cAMH,KAAK;cAkDL,MAAM;IAc/B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,2BAA2B;CAiBpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/edge-client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-feature-compute.4d9d99a",
|
|
4
4
|
"description": "EDGE Client",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"isomorphic-ws": "^5.0.0",
|
|
37
37
|
"ws": "^8.14.2",
|
|
38
|
-
"@dxos/async": "0.7.
|
|
39
|
-
"@dxos/credentials": "0.7.
|
|
40
|
-
"@dxos/crypto": "0.7.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
38
|
+
"@dxos/async": "0.7.5-feature-compute.4d9d99a",
|
|
39
|
+
"@dxos/credentials": "0.7.5-feature-compute.4d9d99a",
|
|
40
|
+
"@dxos/crypto": "0.7.5-feature-compute.4d9d99a",
|
|
41
|
+
"@dxos/invariant": "0.7.5-feature-compute.4d9d99a",
|
|
42
|
+
"@dxos/context": "0.7.5-feature-compute.4d9d99a",
|
|
43
|
+
"@dxos/keyring": "0.7.5-feature-compute.4d9d99a",
|
|
44
|
+
"@dxos/debug": "0.7.5-feature-compute.4d9d99a",
|
|
45
|
+
"@dxos/keys": "0.7.5-feature-compute.4d9d99a",
|
|
46
|
+
"@dxos/protocols": "0.7.5-feature-compute.4d9d99a",
|
|
47
|
+
"@dxos/util": "0.7.5-feature-compute.4d9d99a",
|
|
48
|
+
"@dxos/node-std": "0.7.5-feature-compute.4d9d99a",
|
|
49
|
+
"@dxos/log": "0.7.5-feature-compute.4d9d99a"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@dxos/test-utils": "0.7.
|
|
52
|
+
"@dxos/test-utils": "0.7.5-feature-compute.4d9d99a"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/edge-http-client.ts
CHANGED
|
@@ -21,6 +21,10 @@ import {
|
|
|
21
21
|
type RecoverIdentityResponseBody,
|
|
22
22
|
type UploadFunctionRequest,
|
|
23
23
|
type UploadFunctionResponseBody,
|
|
24
|
+
type ObjectId,
|
|
25
|
+
type ExecuteWorkflowResponseBody,
|
|
26
|
+
type QueueQuery,
|
|
27
|
+
type QueryResult,
|
|
24
28
|
} from '@dxos/protocols';
|
|
25
29
|
|
|
26
30
|
import { type EdgeIdentity, handleAuthChallenge } from './edge-identity';
|
|
@@ -34,6 +38,7 @@ export class EdgeHttpClient {
|
|
|
34
38
|
private readonly _baseUrl: string;
|
|
35
39
|
|
|
36
40
|
private _edgeIdentity: EdgeIdentity | undefined;
|
|
41
|
+
|
|
37
42
|
/**
|
|
38
43
|
* Auth header is cached until receiving the next 401 from EDGE, at which point it gets refreshed.
|
|
39
44
|
*/
|
|
@@ -89,6 +94,15 @@ export class EdgeHttpClient {
|
|
|
89
94
|
return this._call('/identity/recover', { ...args, body, method: 'POST' });
|
|
90
95
|
}
|
|
91
96
|
|
|
97
|
+
public async executeWorkflow(
|
|
98
|
+
spaceId: SpaceId,
|
|
99
|
+
graphId: ObjectId,
|
|
100
|
+
input: any,
|
|
101
|
+
args?: EdgeHttpGetArgs,
|
|
102
|
+
): Promise<ExecuteWorkflowResponseBody> {
|
|
103
|
+
return this._call(`/workflows/${spaceId}/${graphId}`, { ...args, body: input, method: 'POST' });
|
|
104
|
+
}
|
|
105
|
+
|
|
92
106
|
public async uploadFunction(
|
|
93
107
|
pathParts: { spaceId: SpaceId; functionId?: string },
|
|
94
108
|
body: UploadFunctionRequest,
|
|
@@ -98,6 +112,49 @@ export class EdgeHttpClient {
|
|
|
98
112
|
return this._call(path, { ...args, body, method: 'PUT' });
|
|
99
113
|
}
|
|
100
114
|
|
|
115
|
+
public async queryQueue(
|
|
116
|
+
subspaceTag: string,
|
|
117
|
+
spaceId: SpaceId,
|
|
118
|
+
query: QueueQuery,
|
|
119
|
+
args?: EdgeHttpGetArgs,
|
|
120
|
+
): Promise<QueryResult> {
|
|
121
|
+
const { queueId, ...rest } = query;
|
|
122
|
+
const queryParams = new URLSearchParams();
|
|
123
|
+
if (query.after != null) {
|
|
124
|
+
queryParams.set('after', query.after);
|
|
125
|
+
}
|
|
126
|
+
if (query.before != null) {
|
|
127
|
+
queryParams.set('before', query.before);
|
|
128
|
+
}
|
|
129
|
+
if (query.limit != null) {
|
|
130
|
+
queryParams.set('limit', query.limit.toString());
|
|
131
|
+
}
|
|
132
|
+
if (query.reverse != null) {
|
|
133
|
+
queryParams.set('reverse', query.reverse.toString());
|
|
134
|
+
}
|
|
135
|
+
if (query.objectIds != null) {
|
|
136
|
+
queryParams.set('objectIds', query.objectIds.join(','));
|
|
137
|
+
}
|
|
138
|
+
return this._call(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}/query?${queryParams.toString()}`, {
|
|
139
|
+
...args,
|
|
140
|
+
method: 'GET',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public async insertIntoQueue(
|
|
145
|
+
subspaceTag: string,
|
|
146
|
+
spaceId: SpaceId,
|
|
147
|
+
queueId: ObjectId,
|
|
148
|
+
objects: unknown[],
|
|
149
|
+
args?: EdgeHttpGetArgs,
|
|
150
|
+
): Promise<void> {
|
|
151
|
+
return this._call(`/spaces/${subspaceTag}/${spaceId}/queue/${queueId}`, {
|
|
152
|
+
...args,
|
|
153
|
+
body: { objects },
|
|
154
|
+
method: 'POST',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
101
158
|
private async _call<T>(path: string, args: EdgeHttpCallArgs): Promise<T> {
|
|
102
159
|
const requestContext = args.context ?? new Context();
|
|
103
160
|
const shouldRetry = createRetryHandler(args);
|
|
@@ -15,7 +15,8 @@ import { protocol } from './defs';
|
|
|
15
15
|
import { type EdgeIdentity } from './edge-identity';
|
|
16
16
|
import { toUint8Array } from './protocol';
|
|
17
17
|
|
|
18
|
-
const SIGNAL_KEEPALIVE_INTERVAL =
|
|
18
|
+
const SIGNAL_KEEPALIVE_INTERVAL = 4_000;
|
|
19
|
+
const SIGNAL_KEEPALIVE_TIMEOUT = 12_000;
|
|
19
20
|
|
|
20
21
|
export type EdgeWsConnectionCallbacks = {
|
|
21
22
|
onConnected: () => void;
|
|
@@ -52,7 +53,7 @@ export class EdgeWsConnection extends Resource {
|
|
|
52
53
|
|
|
53
54
|
protected override async _open() {
|
|
54
55
|
this._ws = new WebSocket(
|
|
55
|
-
this._connectionInfo.url,
|
|
56
|
+
this._connectionInfo.url.toString(),
|
|
56
57
|
this._connectionInfo.protocolHeader ? [this._connectionInfo.protocolHeader] : [],
|
|
57
58
|
);
|
|
58
59
|
|
|
@@ -65,9 +66,9 @@ export class EdgeWsConnection extends Resource {
|
|
|
65
66
|
log.verbose('connected after becoming inactive', { currentIdentity: this._identity });
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
|
-
this._ws.onclose = () => {
|
|
69
|
+
this._ws.onclose = (event) => {
|
|
69
70
|
if (this.isOpen) {
|
|
70
|
-
log('disconnected while being open');
|
|
71
|
+
log.info('disconnected while being open', { event });
|
|
71
72
|
this._callbacks.onRestartRequired();
|
|
72
73
|
}
|
|
73
74
|
};
|
|
@@ -139,10 +140,11 @@ export class EdgeWsConnection extends Resource {
|
|
|
139
140
|
this._inactivityTimeoutCtx,
|
|
140
141
|
() => {
|
|
141
142
|
if (this.isOpen) {
|
|
143
|
+
log.warn('restart due to inactivity timeout');
|
|
142
144
|
this._callbacks.onRestartRequired();
|
|
143
145
|
}
|
|
144
146
|
},
|
|
145
|
-
|
|
147
|
+
SIGNAL_KEEPALIVE_TIMEOUT,
|
|
146
148
|
);
|
|
147
149
|
}
|
|
148
150
|
}
|