@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,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Meshagent = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const helpers_js_1 = require("./helpers.js");
|
|
5
|
+
const requirement_js_1 = require("./requirement.js");
|
|
6
|
+
const participant_token_js_1 = require("./participant-token.js");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
8
|
function pruneUndefinedValues(value) {
|
|
9
9
|
if (Array.isArray(value)) {
|
|
10
10
|
const prunedItems = value
|
|
@@ -97,7 +97,7 @@ function normalizeBinary(data) {
|
|
|
97
97
|
}
|
|
98
98
|
class Meshagent {
|
|
99
99
|
constructor({ baseUrl, token } = {}) {
|
|
100
|
-
const resolvedBaseUrl = (0,
|
|
100
|
+
const resolvedBaseUrl = (0, helpers_js_1.meshagentBaseUrl)(baseUrl).replace(/\/+$/, "");
|
|
101
101
|
this.baseUrl = resolvedBaseUrl || "https://api.meshagent.com";
|
|
102
102
|
const envToken = typeof process !== "undefined" ? process.env?.MESHAGENT_API_KEY : undefined;
|
|
103
103
|
this.token = token ?? envToken ?? undefined;
|
|
@@ -152,7 +152,7 @@ class Meshagent {
|
|
|
152
152
|
catch {
|
|
153
153
|
message = "<unable to read body>";
|
|
154
154
|
}
|
|
155
|
-
throw new
|
|
155
|
+
throw new requirement_js_1.RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message}`);
|
|
156
156
|
}
|
|
157
157
|
switch (responseType) {
|
|
158
158
|
case "json":
|
|
@@ -171,15 +171,15 @@ class Meshagent {
|
|
|
171
171
|
}
|
|
172
172
|
parseRoomShare(data) {
|
|
173
173
|
if (!data || typeof data !== "object") {
|
|
174
|
-
throw new
|
|
174
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: expected object");
|
|
175
175
|
}
|
|
176
176
|
const { id, project_id: projectId, projectId: projectIdAlt, settings } = data;
|
|
177
177
|
if (typeof id !== "string") {
|
|
178
|
-
throw new
|
|
178
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing id");
|
|
179
179
|
}
|
|
180
180
|
const finalProjectId = typeof projectIdAlt === "string" ? projectIdAlt : typeof projectId === "string" ? projectId : undefined;
|
|
181
181
|
if (!finalProjectId) {
|
|
182
|
-
throw new
|
|
182
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing project id");
|
|
183
183
|
}
|
|
184
184
|
return {
|
|
185
185
|
id,
|
|
@@ -189,23 +189,23 @@ class Meshagent {
|
|
|
189
189
|
}
|
|
190
190
|
parseRoomSession(data) {
|
|
191
191
|
if (!data || typeof data !== "object") {
|
|
192
|
-
throw new
|
|
192
|
+
throw new requirement_js_1.RoomException("Invalid room session payload");
|
|
193
193
|
}
|
|
194
194
|
const { id, room_id: roomIdRaw, roomId, room_name: roomNameRaw, roomName, created_at: createdRaw, createdAt, is_active: isActiveRaw, isActive, participants } = data;
|
|
195
195
|
if (typeof id !== "string") {
|
|
196
|
-
throw new
|
|
196
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing id");
|
|
197
197
|
}
|
|
198
198
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
199
199
|
if (typeof roomNameValue !== "string") {
|
|
200
|
-
throw new
|
|
200
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing room name");
|
|
201
201
|
}
|
|
202
202
|
const created = typeof createdAt === "string" ? createdAt : createdRaw;
|
|
203
203
|
if (typeof created !== "string") {
|
|
204
|
-
throw new
|
|
204
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing created_at");
|
|
205
205
|
}
|
|
206
206
|
const isActiveValue = typeof isActive === "boolean" ? isActive : isActiveRaw;
|
|
207
207
|
if (typeof isActiveValue !== "boolean") {
|
|
208
|
-
throw new
|
|
208
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing is_active");
|
|
209
209
|
}
|
|
210
210
|
return {
|
|
211
211
|
id,
|
|
@@ -218,11 +218,11 @@ class Meshagent {
|
|
|
218
218
|
}
|
|
219
219
|
parseRoom(data) {
|
|
220
220
|
if (!data || typeof data !== "object") {
|
|
221
|
-
throw new
|
|
221
|
+
throw new requirement_js_1.RoomException("Invalid room payload");
|
|
222
222
|
}
|
|
223
223
|
const { id, name, metadata, annotations } = data;
|
|
224
224
|
if (typeof id !== "string" || typeof name !== "string") {
|
|
225
|
-
throw new
|
|
225
|
+
throw new requirement_js_1.RoomException("Invalid room payload: missing id or name");
|
|
226
226
|
}
|
|
227
227
|
return {
|
|
228
228
|
id,
|
|
@@ -233,7 +233,7 @@ class Meshagent {
|
|
|
233
233
|
}
|
|
234
234
|
parseRoute(data) {
|
|
235
235
|
if (!data || typeof data !== "object") {
|
|
236
|
-
throw new
|
|
236
|
+
throw new requirement_js_1.RoomException("Invalid route payload: expected object");
|
|
237
237
|
}
|
|
238
238
|
if (data.spec && typeof data.spec === "object") {
|
|
239
239
|
return { domain: String(data.domain ?? data.spec.domain), spec: data.spec };
|
|
@@ -251,11 +251,11 @@ class Meshagent {
|
|
|
251
251
|
},
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
throw new
|
|
254
|
+
throw new requirement_js_1.RoomException("Invalid route payload: missing spec");
|
|
255
255
|
}
|
|
256
256
|
parseFeed(data) {
|
|
257
257
|
if (!data || typeof data !== "object") {
|
|
258
|
-
throw new
|
|
258
|
+
throw new requirement_js_1.RoomException("Invalid feed payload");
|
|
259
259
|
}
|
|
260
260
|
const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema, } = data;
|
|
261
261
|
const projectIdValue = typeof projectId === "string"
|
|
@@ -281,7 +281,7 @@ class Meshagent {
|
|
|
281
281
|
typeof createdAtValue !== "string" ||
|
|
282
282
|
typeof name !== "string" ||
|
|
283
283
|
visibilityValue === undefined) {
|
|
284
|
-
throw new
|
|
284
|
+
throw new requirement_js_1.RoomException("Invalid feed payload: missing required fields");
|
|
285
285
|
}
|
|
286
286
|
return {
|
|
287
287
|
id,
|
|
@@ -297,7 +297,7 @@ class Meshagent {
|
|
|
297
297
|
}
|
|
298
298
|
parseFeedSubscription(data) {
|
|
299
299
|
if (!data || typeof data !== "object") {
|
|
300
|
-
throw new
|
|
300
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload");
|
|
301
301
|
}
|
|
302
302
|
const { id, feed_id: feedIdRaw, feedId, project_id: projectIdRaw, projectId, room, room_id: roomIdRaw, roomId, path, filename_datetime_format: filenameDatetimeFormatRaw, filenameDatetimeFormat, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
303
303
|
const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
|
|
@@ -315,7 +315,7 @@ class Meshagent {
|
|
|
315
315
|
typeof room !== "string" ||
|
|
316
316
|
typeof path !== "string" ||
|
|
317
317
|
typeof createdAtValue !== "string") {
|
|
318
|
-
throw new
|
|
318
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload: missing required fields");
|
|
319
319
|
}
|
|
320
320
|
return {
|
|
321
321
|
id,
|
|
@@ -331,7 +331,7 @@ class Meshagent {
|
|
|
331
331
|
}
|
|
332
332
|
parseLLMLogger(data) {
|
|
333
333
|
if (!data || typeof data !== "object") {
|
|
334
|
-
throw new
|
|
334
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload");
|
|
335
335
|
}
|
|
336
336
|
const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
337
337
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
@@ -343,7 +343,7 @@ class Meshagent {
|
|
|
343
343
|
typeof destinationFeedIdValue !== "string" ||
|
|
344
344
|
typeof filterExpressionValue !== "string" ||
|
|
345
345
|
typeof createdAtValue !== "string") {
|
|
346
|
-
throw new
|
|
346
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload: missing required fields");
|
|
347
347
|
}
|
|
348
348
|
return {
|
|
349
349
|
id,
|
|
@@ -357,7 +357,7 @@ class Meshagent {
|
|
|
357
357
|
}
|
|
358
358
|
parseProjectRepository(data) {
|
|
359
359
|
if (!data || typeof data !== "object") {
|
|
360
|
-
throw new
|
|
360
|
+
throw new requirement_js_1.RoomException("Invalid repository payload");
|
|
361
361
|
}
|
|
362
362
|
const { id, project_id: projectIdRaw, projectId, name, description, annotations, created_at: createdAtRaw, createdAt, } = data;
|
|
363
363
|
const projectIdValue = typeof projectId === "string"
|
|
@@ -371,7 +371,7 @@ class Meshagent {
|
|
|
371
371
|
? createdAtRaw
|
|
372
372
|
: undefined;
|
|
373
373
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof name !== "string" || typeof createdAtValue !== "string") {
|
|
374
|
-
throw new
|
|
374
|
+
throw new requirement_js_1.RoomException("Invalid repository payload: missing required fields");
|
|
375
375
|
}
|
|
376
376
|
return {
|
|
377
377
|
id,
|
|
@@ -384,44 +384,44 @@ class Meshagent {
|
|
|
384
384
|
}
|
|
385
385
|
parseProjectRoomGrant(data) {
|
|
386
386
|
if (!data || typeof data !== "object") {
|
|
387
|
-
throw new
|
|
387
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload");
|
|
388
388
|
}
|
|
389
389
|
const roomData = data.room;
|
|
390
390
|
const room = this.parseRoom(roomData);
|
|
391
391
|
const userId = data.user_id ?? data.userId;
|
|
392
392
|
if (typeof userId !== "string") {
|
|
393
|
-
throw new
|
|
393
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload: missing user_id");
|
|
394
394
|
}
|
|
395
395
|
const permissionsRaw = data.permissions;
|
|
396
|
-
const permissions = permissionsRaw && typeof permissionsRaw === "object" ?
|
|
396
|
+
const permissions = permissionsRaw && typeof permissionsRaw === "object" ? participant_token_js_1.ApiScope.fromJSON(permissionsRaw) : new participant_token_js_1.ApiScope();
|
|
397
397
|
return { room, userId, permissions };
|
|
398
398
|
}
|
|
399
399
|
parseProjectRoomGrantCount(data) {
|
|
400
400
|
const roomData = (data && typeof data === "object") ? (data.room ?? { id: data.room_id, name: data.room_name, metadata: data.metadata ?? {} }) : undefined;
|
|
401
401
|
if (!roomData) {
|
|
402
|
-
throw new
|
|
402
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing room");
|
|
403
403
|
}
|
|
404
404
|
const room = this.parseRoom(roomData);
|
|
405
405
|
const count = data.count;
|
|
406
406
|
if (typeof count !== "number") {
|
|
407
|
-
throw new
|
|
407
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing count");
|
|
408
408
|
}
|
|
409
409
|
return { room, count };
|
|
410
410
|
}
|
|
411
411
|
parseProjectUserGrantCount(data) {
|
|
412
412
|
if (!data || typeof data !== "object") {
|
|
413
|
-
throw new
|
|
413
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload");
|
|
414
414
|
}
|
|
415
415
|
const { user_id: userIdRaw, userId, count, first_name: firstNameRaw, firstName, last_name: lastNameRaw, lastName, email } = data;
|
|
416
416
|
const userIdValue = typeof userId === "string" ? userId : userIdRaw;
|
|
417
417
|
if (typeof userIdValue !== "string") {
|
|
418
|
-
throw new
|
|
418
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing user_id");
|
|
419
419
|
}
|
|
420
420
|
if (typeof count !== "number") {
|
|
421
|
-
throw new
|
|
421
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing count");
|
|
422
422
|
}
|
|
423
423
|
if (typeof email !== "string") {
|
|
424
|
-
throw new
|
|
424
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing email");
|
|
425
425
|
}
|
|
426
426
|
return {
|
|
427
427
|
userId: userIdValue,
|
|
@@ -433,11 +433,11 @@ class Meshagent {
|
|
|
433
433
|
}
|
|
434
434
|
parseBalance(data) {
|
|
435
435
|
if (!data || typeof data !== "object") {
|
|
436
|
-
throw new
|
|
436
|
+
throw new requirement_js_1.RoomException("Invalid balance payload");
|
|
437
437
|
}
|
|
438
438
|
const balanceValue = data.balance;
|
|
439
439
|
if (typeof balanceValue !== "number") {
|
|
440
|
-
throw new
|
|
440
|
+
throw new requirement_js_1.RoomException("Invalid balance payload: missing balance");
|
|
441
441
|
}
|
|
442
442
|
const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
|
|
443
443
|
const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
|
|
@@ -457,15 +457,15 @@ class Meshagent {
|
|
|
457
457
|
}
|
|
458
458
|
parseTransaction(data) {
|
|
459
459
|
if (!data || typeof data !== "object") {
|
|
460
|
-
throw new
|
|
460
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload");
|
|
461
461
|
}
|
|
462
462
|
const { id, amount, reference, referenceType, reference_type: referenceTypeRaw, description, created_at: createdAtRaw, createdAt } = data;
|
|
463
463
|
if (typeof id !== "string" || typeof amount !== "number" || typeof description !== "string") {
|
|
464
|
-
throw new
|
|
464
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing fields");
|
|
465
465
|
}
|
|
466
466
|
const createdValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
467
467
|
if (typeof createdValue !== "string") {
|
|
468
|
-
throw new
|
|
468
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing created_at");
|
|
469
469
|
}
|
|
470
470
|
const referenceTypeValue = typeof referenceType === "string" ? referenceType : referenceTypeRaw;
|
|
471
471
|
return {
|
|
@@ -479,7 +479,7 @@ class Meshagent {
|
|
|
479
479
|
}
|
|
480
480
|
parseSecret(data) {
|
|
481
481
|
if (!data || typeof data !== "object") {
|
|
482
|
-
throw new
|
|
482
|
+
throw new requirement_js_1.RoomException("Invalid secret payload");
|
|
483
483
|
}
|
|
484
484
|
const type = data.type;
|
|
485
485
|
if (type === "docker") {
|
|
@@ -487,7 +487,7 @@ class Meshagent {
|
|
|
487
487
|
const username = data.username;
|
|
488
488
|
const password = data.password;
|
|
489
489
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
490
|
-
throw new
|
|
490
|
+
throw new requirement_js_1.RoomException("Invalid docker secret payload");
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
493
|
id: typeof data.id === "string" ? data.id : undefined,
|
|
@@ -502,7 +502,7 @@ class Meshagent {
|
|
|
502
502
|
if (type === "keys") {
|
|
503
503
|
const record = data.data;
|
|
504
504
|
if (!record || typeof record !== "object") {
|
|
505
|
-
throw new
|
|
505
|
+
throw new requirement_js_1.RoomException("Invalid keys secret payload");
|
|
506
506
|
}
|
|
507
507
|
return {
|
|
508
508
|
id: typeof data.id === "string" ? data.id : undefined,
|
|
@@ -511,15 +511,15 @@ class Meshagent {
|
|
|
511
511
|
data: record,
|
|
512
512
|
};
|
|
513
513
|
}
|
|
514
|
-
throw new
|
|
514
|
+
throw new requirement_js_1.RoomException(`Unknown secret type: ${type}`);
|
|
515
515
|
}
|
|
516
516
|
parseManagedSecretInfo(data) {
|
|
517
517
|
if (!data || typeof data !== "object") {
|
|
518
|
-
throw new
|
|
518
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload");
|
|
519
519
|
}
|
|
520
520
|
const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
|
|
521
521
|
if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
|
|
522
|
-
throw new
|
|
522
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing id, type, or name");
|
|
523
523
|
}
|
|
524
524
|
const delegatedToValue = typeof delegatedTo === "string"
|
|
525
525
|
? delegatedTo
|
|
@@ -537,7 +537,7 @@ class Meshagent {
|
|
|
537
537
|
const secret = this.parseManagedSecretInfo(data);
|
|
538
538
|
const dataBase64 = data.data_base64 ?? data.dataBase64;
|
|
539
539
|
if (typeof dataBase64 !== "string") {
|
|
540
|
-
throw new
|
|
540
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing data_base64");
|
|
541
541
|
}
|
|
542
542
|
return {
|
|
543
543
|
...secret,
|
|
@@ -548,18 +548,18 @@ class Meshagent {
|
|
|
548
548
|
parseSecretPayload(secret, rawData) {
|
|
549
549
|
let payload;
|
|
550
550
|
try {
|
|
551
|
-
payload = JSON.parse(
|
|
551
|
+
payload = JSON.parse(utils_js_1.decoder.decode(rawData));
|
|
552
552
|
}
|
|
553
553
|
catch {
|
|
554
|
-
throw new
|
|
554
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
555
555
|
}
|
|
556
556
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
557
|
-
throw new
|
|
557
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
558
558
|
}
|
|
559
559
|
if (secret.type === "docker") {
|
|
560
560
|
const { server, username, password, email } = payload;
|
|
561
561
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
562
|
-
throw new
|
|
562
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
563
563
|
}
|
|
564
564
|
return {
|
|
565
565
|
id: secret.id,
|
|
@@ -573,7 +573,7 @@ class Meshagent {
|
|
|
573
573
|
}
|
|
574
574
|
const entries = Object.entries(payload);
|
|
575
575
|
if (entries.some(([, value]) => typeof value !== "string")) {
|
|
576
|
-
throw new
|
|
576
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
577
577
|
}
|
|
578
578
|
return {
|
|
579
579
|
id: secret.id,
|
|
@@ -606,7 +606,7 @@ class Meshagent {
|
|
|
606
606
|
return null;
|
|
607
607
|
}
|
|
608
608
|
if (typeof data !== "object") {
|
|
609
|
-
throw new
|
|
609
|
+
throw new requirement_js_1.RoomException("Invalid connector payload");
|
|
610
610
|
}
|
|
611
611
|
const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId, } = data;
|
|
612
612
|
return {
|
|
@@ -645,14 +645,14 @@ class Meshagent {
|
|
|
645
645
|
}
|
|
646
646
|
parseExternalOAuthClientRegistration(data) {
|
|
647
647
|
if (!data || typeof data !== "object") {
|
|
648
|
-
throw new
|
|
648
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload");
|
|
649
649
|
}
|
|
650
650
|
const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, } = data;
|
|
651
651
|
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
|
|
652
652
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
653
653
|
const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
|
|
654
654
|
if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
|
|
655
|
-
throw new
|
|
655
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload: missing fields");
|
|
656
656
|
}
|
|
657
657
|
return {
|
|
658
658
|
id,
|
|
@@ -665,7 +665,7 @@ class Meshagent {
|
|
|
665
665
|
}
|
|
666
666
|
parseOAuthClient(data) {
|
|
667
667
|
if (!data || typeof data !== "object") {
|
|
668
|
-
throw new
|
|
668
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload");
|
|
669
669
|
}
|
|
670
670
|
const { client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, grant_types: grantTypesRaw, grantTypes, response_types: responseTypesRaw, responseTypes, redirect_uris: redirectUrisRaw, redirectUris, scope, project_id: projectIdRaw, projectId, metadata } = data;
|
|
671
671
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
@@ -681,7 +681,7 @@ class Meshagent {
|
|
|
681
681
|
!Array.isArray(redirectUrisValue) ||
|
|
682
682
|
typeof scope !== "string" ||
|
|
683
683
|
typeof projectIdValue !== "string") {
|
|
684
|
-
throw new
|
|
684
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload: missing required fields");
|
|
685
685
|
}
|
|
686
686
|
return {
|
|
687
687
|
clientId: clientIdValue,
|
|
@@ -696,14 +696,14 @@ class Meshagent {
|
|
|
696
696
|
}
|
|
697
697
|
parseRoomConnectionInfo(data) {
|
|
698
698
|
if (!data || typeof data !== "object") {
|
|
699
|
-
throw new
|
|
699
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload");
|
|
700
700
|
}
|
|
701
701
|
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, room_url: roomUrlRaw, roomUrl } = data;
|
|
702
702
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
703
703
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
704
704
|
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
705
705
|
if (typeof jwt !== "string" || typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
706
|
-
throw new
|
|
706
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload: missing fields");
|
|
707
707
|
}
|
|
708
708
|
return { jwt, roomName: roomNameValue, projectId: projectIdValue, roomUrl: roomUrlValue };
|
|
709
709
|
}
|
|
@@ -738,7 +738,7 @@ class Meshagent {
|
|
|
738
738
|
});
|
|
739
739
|
const role = payload?.role;
|
|
740
740
|
if (role !== "member" && role !== "admin" && role !== "developer") {
|
|
741
|
-
throw new
|
|
741
|
+
throw new requirement_js_1.RoomException("Invalid role payload");
|
|
742
742
|
}
|
|
743
743
|
return role;
|
|
744
744
|
}
|
|
@@ -877,7 +877,7 @@ class Meshagent {
|
|
|
877
877
|
});
|
|
878
878
|
const enabled = data?.["enabled"];
|
|
879
879
|
if (typeof enabled !== "boolean") {
|
|
880
|
-
throw new
|
|
880
|
+
throw new requirement_js_1.RoomException("Invalid status payload: expected boolean 'enabled'");
|
|
881
881
|
}
|
|
882
882
|
return enabled;
|
|
883
883
|
}
|
|
@@ -910,7 +910,7 @@ class Meshagent {
|
|
|
910
910
|
});
|
|
911
911
|
const url = data?.["checkout_url"];
|
|
912
912
|
if (typeof url !== "string") {
|
|
913
|
-
throw new
|
|
913
|
+
throw new requirement_js_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
|
|
914
914
|
}
|
|
915
915
|
return url;
|
|
916
916
|
}
|
|
@@ -922,7 +922,7 @@ class Meshagent {
|
|
|
922
922
|
});
|
|
923
923
|
const url = data?.["checkout_url"];
|
|
924
924
|
if (typeof url !== "string") {
|
|
925
|
-
throw new
|
|
925
|
+
throw new requirement_js_1.RoomException("Invalid credits payload: expected 'checkout_url' string");
|
|
926
926
|
}
|
|
927
927
|
return url;
|
|
928
928
|
}
|
|
@@ -951,7 +951,7 @@ class Meshagent {
|
|
|
951
951
|
});
|
|
952
952
|
const usage = data?.["usage"];
|
|
953
953
|
if (!Array.isArray(usage)) {
|
|
954
|
-
throw new
|
|
954
|
+
throw new requirement_js_1.RoomException("Invalid usage payload: expected 'usage' to be a list");
|
|
955
955
|
}
|
|
956
956
|
return usage.filter((item) => item && typeof item === "object");
|
|
957
957
|
}
|
|
@@ -1050,14 +1050,14 @@ class Meshagent {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
parseMailbox(item) {
|
|
1052
1052
|
if (!item || typeof item !== "object") {
|
|
1053
|
-
throw new
|
|
1053
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload");
|
|
1054
1054
|
}
|
|
1055
1055
|
const { address, room, room_id, queue } = item;
|
|
1056
1056
|
if (typeof address !== "string" || typeof room !== "string" || typeof queue !== "string") {
|
|
1057
|
-
throw new
|
|
1057
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: missing fields");
|
|
1058
1058
|
}
|
|
1059
1059
|
if (room_id !== undefined && typeof room_id !== "string") {
|
|
1060
|
-
throw new
|
|
1060
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: invalid room_id");
|
|
1061
1061
|
}
|
|
1062
1062
|
return { address, room, roomId: room_id, queue };
|
|
1063
1063
|
}
|
|
@@ -1311,7 +1311,7 @@ class Meshagent {
|
|
|
1311
1311
|
action: "create service",
|
|
1312
1312
|
});
|
|
1313
1313
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
1314
|
-
throw new
|
|
1314
|
+
throw new requirement_js_1.RoomException("Invalid create service response payload");
|
|
1315
1315
|
}
|
|
1316
1316
|
return data.id;
|
|
1317
1317
|
}
|
|
@@ -1322,7 +1322,7 @@ class Meshagent {
|
|
|
1322
1322
|
action: "create room service",
|
|
1323
1323
|
});
|
|
1324
1324
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
1325
|
-
throw new
|
|
1325
|
+
throw new requirement_js_1.RoomException("Invalid create room service response payload");
|
|
1326
1326
|
}
|
|
1327
1327
|
return data.id;
|
|
1328
1328
|
}
|
|
@@ -1356,7 +1356,7 @@ class Meshagent {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
async updateService(projectId, serviceId, service) {
|
|
1358
1358
|
if (!service.id) {
|
|
1359
|
-
throw new
|
|
1359
|
+
throw new requirement_js_1.RoomException("Service id must be set to update a service");
|
|
1360
1360
|
}
|
|
1361
1361
|
await this.request(`/accounts/projects/${projectId}/services/${serviceId}`, {
|
|
1362
1362
|
method: "PUT",
|
|
@@ -1397,7 +1397,7 @@ class Meshagent {
|
|
|
1397
1397
|
action: "create project secret",
|
|
1398
1398
|
});
|
|
1399
1399
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
1400
|
-
throw new
|
|
1400
|
+
throw new requirement_js_1.RoomException("Invalid create project secret response payload");
|
|
1401
1401
|
}
|
|
1402
1402
|
return payload.id;
|
|
1403
1403
|
}
|
|
@@ -1449,7 +1449,7 @@ class Meshagent {
|
|
|
1449
1449
|
action: "create room secret",
|
|
1450
1450
|
});
|
|
1451
1451
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
1452
|
-
throw new
|
|
1452
|
+
throw new requirement_js_1.RoomException("Invalid create room secret response payload");
|
|
1453
1453
|
}
|
|
1454
1454
|
return payload.id;
|
|
1455
1455
|
}
|
|
@@ -1507,19 +1507,19 @@ class Meshagent {
|
|
|
1507
1507
|
projectId,
|
|
1508
1508
|
name: secret.name,
|
|
1509
1509
|
type: secret.type,
|
|
1510
|
-
data:
|
|
1510
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
|
|
1511
1511
|
});
|
|
1512
1512
|
}
|
|
1513
1513
|
async updateSecret(projectId, secret) {
|
|
1514
1514
|
if (!secret.id) {
|
|
1515
|
-
throw new
|
|
1515
|
+
throw new requirement_js_1.RoomException("Secret id is required to update a secret");
|
|
1516
1516
|
}
|
|
1517
1517
|
await this.updateProjectSecret({
|
|
1518
1518
|
projectId,
|
|
1519
1519
|
secretId: secret.id,
|
|
1520
1520
|
name: secret.name,
|
|
1521
1521
|
type: secret.type,
|
|
1522
|
-
data:
|
|
1522
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
|
|
1523
1523
|
});
|
|
1524
1524
|
}
|
|
1525
1525
|
async deleteSecret(projectId, secretId) {
|
|
@@ -1547,7 +1547,7 @@ class Meshagent {
|
|
|
1547
1547
|
action: "create project external oauth registration",
|
|
1548
1548
|
});
|
|
1549
1549
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
1550
|
-
throw new
|
|
1550
|
+
throw new requirement_js_1.RoomException("Invalid create project external oauth registration response payload");
|
|
1551
1551
|
}
|
|
1552
1552
|
return payload.id;
|
|
1553
1553
|
}
|
|
@@ -1602,7 +1602,7 @@ class Meshagent {
|
|
|
1602
1602
|
action: "create room external oauth registration",
|
|
1603
1603
|
});
|
|
1604
1604
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
1605
|
-
throw new
|
|
1605
|
+
throw new requirement_js_1.RoomException("Invalid create room external oauth registration response payload");
|
|
1606
1606
|
}
|
|
1607
1607
|
return payload.id;
|
|
1608
1608
|
}
|
|
@@ -1654,7 +1654,7 @@ class Meshagent {
|
|
|
1654
1654
|
if (permissions) {
|
|
1655
1655
|
const serialized = {};
|
|
1656
1656
|
for (const [key, value] of Object.entries(permissions)) {
|
|
1657
|
-
serialized[key] = value instanceof
|
|
1657
|
+
serialized[key] = value instanceof participant_token_js_1.ApiScope ? value.toJSON() : value;
|
|
1658
1658
|
}
|
|
1659
1659
|
payload["permissions"] = serialized;
|
|
1660
1660
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from "./event-emitter";
|
|
2
|
-
import { Participant, RemoteParticipant } from "./participant";
|
|
3
|
-
import { RoomClient } from "./room-client";
|
|
4
|
-
import { RoomMessageEvent } from "./room-event";
|
|
1
|
+
import { EventEmitter } from "./event-emitter.js";
|
|
2
|
+
import { Participant, RemoteParticipant } from "./participant.js";
|
|
3
|
+
import { RoomClient } from "./room-client.js";
|
|
4
|
+
import { RoomMessageEvent } from "./room-event.js";
|
|
5
5
|
type MessagePayload = Record<string, unknown>;
|
|
6
6
|
export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
|
|
7
7
|
private readonly client;
|