@meshagent/meshagent 0.42.2 → 0.43.0
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/CHANGELOG.md +7 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RuntimeDocument } from "./document";
|
|
2
|
-
import { MeshSchema } from "./schema";
|
|
1
|
+
import { RuntimeDocument } from "./document.js";
|
|
2
|
+
import { MeshSchema } from "./schema.js";
|
|
3
3
|
export type Uint8List = Uint8Array;
|
|
4
4
|
export declare class RoomServerException extends Error {
|
|
5
5
|
readonly statusCode?: number;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MeshDocument = exports.RoomServerException = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const document_js_1 = require("./document.js");
|
|
6
|
+
const completer_js_1 = require("./completer.js");
|
|
7
|
+
const runtime_js_1 = require("./runtime.js");
|
|
8
8
|
class RoomServerException extends Error {
|
|
9
9
|
constructor(message, code, { statusCode, retryable = false, } = {}) {
|
|
10
10
|
super(message);
|
|
@@ -15,15 +15,15 @@ class RoomServerException extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.RoomServerException = RoomServerException;
|
|
18
|
-
class MeshDocument extends
|
|
18
|
+
class MeshDocument extends document_js_1.RuntimeDocument {
|
|
19
19
|
constructor({ schema, sendChangesToBackend }) {
|
|
20
20
|
super({
|
|
21
21
|
id: (0, uuid_1.v4)(),
|
|
22
22
|
schema,
|
|
23
|
-
sendChanges: (base64) => (0,
|
|
23
|
+
sendChanges: (base64) => (0, runtime_js_1.applyChanges)(base64),
|
|
24
24
|
sendChangesToBackend,
|
|
25
25
|
});
|
|
26
|
-
this._synchronized = new
|
|
26
|
+
this._synchronized = new completer_js_1.Completer();
|
|
27
27
|
this.onSendUpdateToBackend = (base64) => {
|
|
28
28
|
const parsed = JSON.parse(base64);
|
|
29
29
|
if (this.sendChangesToBackend) {
|
|
@@ -34,13 +34,13 @@ class MeshDocument extends document_1.RuntimeDocument {
|
|
|
34
34
|
const parsed = JSON.parse(base64);
|
|
35
35
|
this.receiveChanges(parsed.data);
|
|
36
36
|
};
|
|
37
|
-
(0,
|
|
37
|
+
(0, runtime_js_1.registerDocument)(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
38
38
|
}
|
|
39
39
|
getState(vector) {
|
|
40
|
-
return (0,
|
|
40
|
+
return (0, runtime_js_1.getState)(this.id, vector ?? null);
|
|
41
41
|
}
|
|
42
42
|
getStateVector() {
|
|
43
|
-
return (0,
|
|
43
|
+
return (0, runtime_js_1.getStateVector)(this.id);
|
|
44
44
|
}
|
|
45
45
|
get synchronized() {
|
|
46
46
|
return this._synchronized.fut;
|
|
@@ -53,7 +53,7 @@ class MeshDocument extends document_1.RuntimeDocument {
|
|
|
53
53
|
}
|
|
54
54
|
dispose() {
|
|
55
55
|
super.dispose();
|
|
56
|
-
(0,
|
|
56
|
+
(0, runtime_js_1.unregisterDocument)(this.id);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.MeshDocument = MeshDocument;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client";
|
|
2
|
-
import { FileContent } from "./response";
|
|
3
|
-
import { RoomClient } from "./room-client";
|
|
1
|
+
import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client.js";
|
|
2
|
+
import { FileContent } from "./response.js";
|
|
3
|
+
import { RoomClient } from "./room-client.js";
|
|
4
4
|
export interface SecretInfo {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SecretsClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const response_js_1 = require("./response.js");
|
|
5
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
7
|
function isRecord(value) {
|
|
8
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
9
|
}
|
|
@@ -18,7 +18,7 @@ class SecretsClient {
|
|
|
18
18
|
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
19
19
|
}
|
|
20
20
|
unexpectedResponse(operation) {
|
|
21
|
-
return new
|
|
21
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
22
22
|
}
|
|
23
23
|
async invoke(operation, input) {
|
|
24
24
|
return await this.client.invoke({
|
|
@@ -51,7 +51,7 @@ class SecretsClient {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
parseAccessToken(operation, response) {
|
|
54
|
-
if (!(response instanceof
|
|
54
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
55
55
|
throw this.unexpectedResponse(operation);
|
|
56
56
|
}
|
|
57
57
|
const token = response.json["access_token"];
|
|
@@ -82,25 +82,25 @@ class SecretsClient {
|
|
|
82
82
|
void messageId;
|
|
83
83
|
void type;
|
|
84
84
|
if (bytes == null) {
|
|
85
|
-
throw new
|
|
85
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
86
86
|
}
|
|
87
87
|
if (this.oauthTokenRequestHandler == null) {
|
|
88
|
-
throw new
|
|
88
|
+
throw new room_server_client_js_1.RoomServerException("No oauth token handler registered");
|
|
89
89
|
}
|
|
90
|
-
const [request] = (0,
|
|
90
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
91
91
|
const requestId = request["request_id"];
|
|
92
92
|
const challenge = request["challenge"];
|
|
93
93
|
const requestPayload = request["request"];
|
|
94
94
|
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
95
|
-
throw new
|
|
95
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
96
96
|
}
|
|
97
97
|
const oauth = requestPayload["oauth"];
|
|
98
98
|
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
99
|
-
throw new
|
|
99
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
100
100
|
}
|
|
101
101
|
const scopes = oauth["scopes"];
|
|
102
102
|
if (scopes !== undefined && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
103
|
-
throw new
|
|
103
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
104
104
|
}
|
|
105
105
|
Promise.resolve(this.oauthTokenRequestHandler({
|
|
106
106
|
requestId,
|
|
@@ -120,16 +120,16 @@ class SecretsClient {
|
|
|
120
120
|
void messageId;
|
|
121
121
|
void type;
|
|
122
122
|
if (bytes == null) {
|
|
123
|
-
throw new
|
|
123
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
124
124
|
}
|
|
125
125
|
if (this.secretRequestHandler == null) {
|
|
126
|
-
throw new
|
|
126
|
+
throw new room_server_client_js_1.RoomServerException("No secret handler registered");
|
|
127
127
|
}
|
|
128
|
-
const [request] = (0,
|
|
128
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
129
129
|
const requestId = request["request_id"];
|
|
130
130
|
const requestPayload = request["request"];
|
|
131
131
|
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
132
|
-
throw new
|
|
132
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
133
133
|
}
|
|
134
134
|
Promise.resolve(this.secretRequestHandler({
|
|
135
135
|
requestId,
|
|
@@ -146,7 +146,7 @@ class SecretsClient {
|
|
|
146
146
|
code,
|
|
147
147
|
error: null,
|
|
148
148
|
});
|
|
149
|
-
if (response instanceof
|
|
149
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
@@ -157,33 +157,33 @@ class SecretsClient {
|
|
|
157
157
|
code: null,
|
|
158
158
|
error,
|
|
159
159
|
});
|
|
160
|
-
if (response instanceof
|
|
160
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
164
164
|
}
|
|
165
165
|
async provideSecret({ requestId, data, }) {
|
|
166
|
-
const response = await this.invoke("provide_secret", new
|
|
166
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
167
167
|
data,
|
|
168
168
|
headers: {
|
|
169
169
|
request_id: requestId,
|
|
170
170
|
error: null,
|
|
171
171
|
},
|
|
172
172
|
}));
|
|
173
|
-
if (response instanceof
|
|
173
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
throw this.unexpectedResponse("provide_secret");
|
|
177
177
|
}
|
|
178
178
|
async rejectSecret({ requestId, error, }) {
|
|
179
|
-
const response = await this.invoke("provide_secret", new
|
|
179
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
180
180
|
data: new Uint8Array(0),
|
|
181
181
|
headers: {
|
|
182
182
|
request_id: requestId,
|
|
183
183
|
error,
|
|
184
184
|
},
|
|
185
185
|
}));
|
|
186
|
-
if (response instanceof
|
|
186
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
throw this.unexpectedResponse("provide_secret");
|
|
@@ -210,7 +210,7 @@ class SecretsClient {
|
|
|
210
210
|
}
|
|
211
211
|
async listSecrets() {
|
|
212
212
|
const response = await this.invoke("list_secrets", {});
|
|
213
|
-
if (!(response instanceof
|
|
213
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
214
214
|
throw this.unexpectedResponse("list_secrets");
|
|
215
215
|
}
|
|
216
216
|
const secrets = response.json["secrets"];
|
|
@@ -225,7 +225,7 @@ class SecretsClient {
|
|
|
225
225
|
delegated_to: delegatedTo ?? null,
|
|
226
226
|
for_identity: forIdentity ?? null,
|
|
227
227
|
});
|
|
228
|
-
if (!(response instanceof
|
|
228
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
229
229
|
throw this.unexpectedResponse("exists");
|
|
230
230
|
}
|
|
231
231
|
return response.json["exists"];
|
|
@@ -235,7 +235,7 @@ class SecretsClient {
|
|
|
235
235
|
id: secretId,
|
|
236
236
|
delegated_to: delegatedTo ?? null,
|
|
237
237
|
});
|
|
238
|
-
if (response instanceof
|
|
238
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
241
|
throw this.unexpectedResponse("delete_secret");
|
|
@@ -246,7 +246,7 @@ class SecretsClient {
|
|
|
246
246
|
type,
|
|
247
247
|
delegated_to: delegatedTo ?? null,
|
|
248
248
|
});
|
|
249
|
-
if (response instanceof
|
|
249
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
throw this.unexpectedResponse("delete_requested_secret");
|
|
@@ -259,13 +259,13 @@ class SecretsClient {
|
|
|
259
259
|
timeout,
|
|
260
260
|
delegate_to: delegateTo ?? null,
|
|
261
261
|
});
|
|
262
|
-
if (response instanceof
|
|
262
|
+
if (response instanceof response_js_1.FileContent) {
|
|
263
263
|
return response.data;
|
|
264
264
|
}
|
|
265
265
|
throw this.unexpectedResponse("request_secret");
|
|
266
266
|
}
|
|
267
267
|
async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }) {
|
|
268
|
-
const response = await this.invoke("set_secret", new
|
|
268
|
+
const response = await this.invoke("set_secret", new response_js_1.BinaryContent({
|
|
269
269
|
data,
|
|
270
270
|
headers: {
|
|
271
271
|
secret_id: secretId ?? null,
|
|
@@ -276,7 +276,7 @@ class SecretsClient {
|
|
|
276
276
|
has_data: true,
|
|
277
277
|
},
|
|
278
278
|
}));
|
|
279
|
-
if (response instanceof
|
|
279
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
throw this.unexpectedResponse("set_secret");
|
|
@@ -288,10 +288,10 @@ class SecretsClient {
|
|
|
288
288
|
name: name ?? null,
|
|
289
289
|
delegated_to: delegatedTo ?? null,
|
|
290
290
|
});
|
|
291
|
-
if (response instanceof
|
|
291
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
292
292
|
return null;
|
|
293
293
|
}
|
|
294
|
-
if (response instanceof
|
|
294
|
+
if (response instanceof response_js_1.FileContent) {
|
|
295
295
|
return response;
|
|
296
296
|
}
|
|
297
297
|
throw this.unexpectedResponse("get_secret");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServiceSpec } from "./meshagent-client";
|
|
2
|
-
import { RoomClient } from "./room-client";
|
|
1
|
+
import type { ServiceSpec } from "./meshagent-client.js";
|
|
2
|
+
import { RoomClient } from "./room-client.js";
|
|
3
3
|
export interface ServiceRuntimeState {
|
|
4
4
|
serviceId: string;
|
|
5
5
|
state: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServicesClient = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const response_js_1 = require("./response.js");
|
|
5
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
6
6
|
function isRecord(value) {
|
|
7
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
8
|
}
|
|
@@ -14,7 +14,7 @@ function toOptionalInteger(value) {
|
|
|
14
14
|
}
|
|
15
15
|
function parseServiceRuntimeState(value) {
|
|
16
16
|
if (!isRecord(value) || typeof value["service_id"] !== "string") {
|
|
17
|
-
throw new
|
|
17
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
18
18
|
}
|
|
19
19
|
const state = value["state"];
|
|
20
20
|
const containerId = value["container_id"];
|
|
@@ -33,12 +33,12 @@ function parseServiceSpecJson(value) {
|
|
|
33
33
|
if (typeof value === "string") {
|
|
34
34
|
const parsed = JSON.parse(value);
|
|
35
35
|
if (!isRecord(parsed)) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
37
37
|
}
|
|
38
38
|
return parsed;
|
|
39
39
|
}
|
|
40
40
|
if (!isRecord(value)) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
42
42
|
}
|
|
43
43
|
return value;
|
|
44
44
|
}
|
|
@@ -47,7 +47,7 @@ class ServicesClient {
|
|
|
47
47
|
this.room = room;
|
|
48
48
|
}
|
|
49
49
|
unexpectedResponse(operation) {
|
|
50
|
-
return new
|
|
50
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from services.${operation}`);
|
|
51
51
|
}
|
|
52
52
|
async list() {
|
|
53
53
|
return (await this.listWithState()).services;
|
|
@@ -58,7 +58,7 @@ class ServicesClient {
|
|
|
58
58
|
tool: "list",
|
|
59
59
|
input: {},
|
|
60
60
|
});
|
|
61
|
-
if (!(response instanceof
|
|
61
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
62
62
|
throw this.unexpectedResponse("list");
|
|
63
63
|
}
|
|
64
64
|
const servicesRaw = response.json["services_json"];
|
|
@@ -84,7 +84,7 @@ class ServicesClient {
|
|
|
84
84
|
service_id: params.serviceId,
|
|
85
85
|
},
|
|
86
86
|
});
|
|
87
|
-
if (response instanceof
|
|
87
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
throw this.unexpectedResponse("restart");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RoomClient } from "./room-client";
|
|
2
|
-
import { Protocol } from "./protocol";
|
|
3
|
-
import { RoomEvent } from "./room-event";
|
|
4
|
-
import { BinaryContent, FileContent } from "./response";
|
|
5
|
-
import { EventEmitter } from "./event-emitter";
|
|
1
|
+
import { RoomClient } from "./room-client.js";
|
|
2
|
+
import { Protocol } from "./protocol.js";
|
|
3
|
+
import { RoomEvent } from "./room-event.js";
|
|
4
|
+
import { BinaryContent, FileContent } from "./response.js";
|
|
5
|
+
import { EventEmitter } from "./event-emitter.js";
|
|
6
6
|
type StorageClientRoom = Pick<RoomClient, "invoke" | "invokeStream" | "emit"> & {
|
|
7
7
|
isActiveProtocol(protocol: Protocol): boolean;
|
|
8
8
|
protocol: Pick<Protocol, "addHandler">;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageClient = exports.StorageEntry = exports.FileHandle = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const room_event_js_1 = require("./room-event.js");
|
|
5
|
+
const response_js_1 = require("./response.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const event_emitter_js_1 = require("./event-emitter.js");
|
|
8
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
9
9
|
const _DEFAULT_UPLOAD_MIME_TYPE = "application/octet-stream";
|
|
10
10
|
const _UPLOAD_MIME_TYPES_BY_SUFFIX = new Map([
|
|
11
11
|
[".tar.gz", "application/x-tar"],
|
|
@@ -41,7 +41,7 @@ const _UPLOAD_MIME_TYPES_BY_EXTENSION = new Map([
|
|
|
41
41
|
[".zip", "application/zip"],
|
|
42
42
|
]);
|
|
43
43
|
function _unexpectedStorageResponseError(operation) {
|
|
44
|
-
return new
|
|
44
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from storage.${operation}`);
|
|
45
45
|
}
|
|
46
46
|
function _parseStorageTimestamp(value, operation) {
|
|
47
47
|
if (value == null) {
|
|
@@ -80,7 +80,7 @@ class StorageEntry {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
exports.StorageEntry = StorageEntry;
|
|
83
|
-
class StorageClient extends
|
|
83
|
+
class StorageClient extends event_emitter_js_1.EventEmitter {
|
|
84
84
|
constructor({ room }) {
|
|
85
85
|
super();
|
|
86
86
|
this.client = room;
|
|
@@ -92,8 +92,8 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
92
92
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
const [data, _] = (0,
|
|
96
|
-
const event = new
|
|
95
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
96
|
+
const event = new room_event_js_1.FileUpdatedEvent({ path: data["path"], participantId: data["participant_id"] });
|
|
97
97
|
this.client.emit(event);
|
|
98
98
|
this.emit('file.updated', event);
|
|
99
99
|
}
|
|
@@ -101,8 +101,8 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
101
101
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
const [data, _] = (0,
|
|
105
|
-
const event = new
|
|
104
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
105
|
+
const event = new room_event_js_1.FileDeletedEvent({ path: data["path"], participantId: data["participant_id"] });
|
|
106
106
|
this.client.emit(event);
|
|
107
107
|
this.emit('file.deleted', event);
|
|
108
108
|
}
|
|
@@ -110,8 +110,8 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
110
110
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
const [data, _] = (0,
|
|
114
|
-
const event = new
|
|
113
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
114
|
+
const event = new room_event_js_1.FileMovedEvent({
|
|
115
115
|
sourcePath: data["source_path"],
|
|
116
116
|
destinationPath: data["destination_path"],
|
|
117
117
|
participantId: data["participant_id"],
|
|
@@ -145,7 +145,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
145
145
|
}
|
|
146
146
|
async list(path) {
|
|
147
147
|
const response = await this._invoke("list", { path });
|
|
148
|
-
if (!(response instanceof
|
|
148
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json["files"])) {
|
|
149
149
|
throw this._unexpectedResponseError("list");
|
|
150
150
|
}
|
|
151
151
|
const files = response.json["files"];
|
|
@@ -155,7 +155,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
155
155
|
}
|
|
156
156
|
async stat(path) {
|
|
157
157
|
const response = await this._invoke("stat", { path });
|
|
158
|
-
if (!(response instanceof
|
|
158
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
159
159
|
throw this._unexpectedResponseError("stat");
|
|
160
160
|
}
|
|
161
161
|
if (!response.json["exists"]) {
|
|
@@ -175,7 +175,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
175
175
|
}
|
|
176
176
|
async exists(path) {
|
|
177
177
|
const result = await this._invoke("exists", { path });
|
|
178
|
-
if (!(result instanceof
|
|
178
|
+
if (!(result instanceof response_js_1.JsonContent)) {
|
|
179
179
|
throw this._unexpectedResponseError("exists");
|
|
180
180
|
}
|
|
181
181
|
return result.json["exists"];
|
|
@@ -234,16 +234,16 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
234
234
|
});
|
|
235
235
|
try {
|
|
236
236
|
for await (const chunk of response) {
|
|
237
|
-
if (chunk instanceof
|
|
238
|
-
throw new
|
|
237
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
238
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
239
239
|
}
|
|
240
|
-
if (chunk instanceof
|
|
240
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
241
241
|
if (chunk.method === "close") {
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
throw this._unexpectedResponseError("upload");
|
|
245
245
|
}
|
|
246
|
-
if (!(chunk instanceof
|
|
246
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
247
247
|
throw this._unexpectedResponseError("upload");
|
|
248
248
|
}
|
|
249
249
|
if (chunk.headers["kind"] !== "pull") {
|
|
@@ -299,7 +299,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
299
299
|
data.set(part, offset);
|
|
300
300
|
offset += part.length;
|
|
301
301
|
}
|
|
302
|
-
return new
|
|
302
|
+
return new response_js_1.FileContent({ data, name, mimeType });
|
|
303
303
|
}
|
|
304
304
|
async downloadStream(path, { chunkSize = 64 * 1024, } = {}) {
|
|
305
305
|
const input = new _StorageDownloadInputStream({ path, chunkSize });
|
|
@@ -316,10 +316,10 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
316
316
|
let bytesReceived = 0;
|
|
317
317
|
try {
|
|
318
318
|
for await (const chunk of response) {
|
|
319
|
-
if (chunk instanceof
|
|
320
|
-
throw new
|
|
319
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
320
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
321
321
|
}
|
|
322
|
-
if (chunk instanceof
|
|
322
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
323
323
|
if (chunk.method === "close") {
|
|
324
324
|
if (!metadataReceived || expectedSize == null || bytesReceived !== expectedSize) {
|
|
325
325
|
throw self._unexpectedResponseError("download");
|
|
@@ -328,7 +328,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
328
328
|
}
|
|
329
329
|
throw self._unexpectedResponseError("download");
|
|
330
330
|
}
|
|
331
|
-
if (!(chunk instanceof
|
|
331
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
332
332
|
throw self._unexpectedResponseError("download");
|
|
333
333
|
}
|
|
334
334
|
const kind = chunk.headers["kind"];
|
|
@@ -377,7 +377,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
377
377
|
path,
|
|
378
378
|
download: options.download ?? false,
|
|
379
379
|
});
|
|
380
|
-
if (!(response instanceof
|
|
380
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
381
381
|
throw this._unexpectedResponseError("download_url");
|
|
382
382
|
}
|
|
383
383
|
return response.json["url"];
|
|
@@ -415,7 +415,7 @@ class _StorageDownloadInputStream {
|
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
async *stream() {
|
|
418
|
-
yield new
|
|
418
|
+
yield new response_js_1.BinaryContent({
|
|
419
419
|
data: new Uint8Array(0),
|
|
420
420
|
headers: {
|
|
421
421
|
kind: "start",
|
|
@@ -436,7 +436,7 @@ class _StorageDownloadInputStream {
|
|
|
436
436
|
continue;
|
|
437
437
|
}
|
|
438
438
|
this.pendingPulls -= 1;
|
|
439
|
-
yield new
|
|
439
|
+
yield new response_js_1.BinaryContent({
|
|
440
440
|
data: new Uint8Array(0),
|
|
441
441
|
headers: { kind: "pull" },
|
|
442
442
|
});
|
|
@@ -523,7 +523,7 @@ class _StorageUploadInputStream {
|
|
|
523
523
|
return combined;
|
|
524
524
|
}
|
|
525
525
|
async *stream() {
|
|
526
|
-
yield new
|
|
526
|
+
yield new response_js_1.BinaryContent({
|
|
527
527
|
data: new Uint8Array(0),
|
|
528
528
|
headers: {
|
|
529
529
|
kind: "start",
|
|
@@ -553,7 +553,7 @@ class _StorageUploadInputStream {
|
|
|
553
553
|
if (chunk == null) {
|
|
554
554
|
return;
|
|
555
555
|
}
|
|
556
|
-
yield new
|
|
556
|
+
yield new response_js_1.BinaryContent({
|
|
557
557
|
data: chunk,
|
|
558
558
|
headers: { kind: "data" },
|
|
559
559
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from "./event-emitter";
|
|
2
|
-
import { MeshSchema } from "./schema";
|
|
3
|
-
import { RoomClient } from "./room-client";
|
|
4
|
-
import { MeshDocument } from "./room-server-client";
|
|
1
|
+
import { EventEmitter } from "./event-emitter.js";
|
|
2
|
+
import { MeshSchema } from "./schema.js";
|
|
3
|
+
import { RoomClient } from "./room-client.js";
|
|
4
|
+
import { MeshDocument } from "./room-server-client.js";
|
|
5
5
|
export interface SyncClientEvent {
|
|
6
6
|
type: string;
|
|
7
7
|
doc?: MeshDocument;
|