@meshagent/meshagent 0.36.1 → 0.36.3
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 +10 -0
- package/dist/browser/entrypoint.js +3 -3
- package/dist/browser/meshagent-client.d.ts +0 -9
- package/dist/browser/meshagent-client.js +6 -34
- package/dist/browser/room-event.d.ts +12 -0
- package/dist/browser/room-event.js +16 -1
- package/dist/browser/secrets-client.d.ts +5 -0
- package/dist/browser/secrets-client.js +11 -0
- package/dist/browser/storage-client.d.ts +4 -0
- package/dist/browser/storage-client.js +18 -0
- package/dist/esm/meshagent-client.d.ts +0 -9
- package/dist/esm/meshagent-client.js +6 -34
- package/dist/esm/room-event.d.ts +12 -0
- package/dist/esm/room-event.js +14 -0
- package/dist/esm/secrets-client.d.ts +5 -0
- package/dist/esm/secrets-client.js +11 -0
- package/dist/esm/storage-client.d.ts +4 -0
- package/dist/esm/storage-client.js +19 -1
- package/dist/node/meshagent-client.d.ts +0 -9
- package/dist/node/meshagent-client.js +6 -34
- package/dist/node/room-event.d.ts +12 -0
- package/dist/node/room-event.js +16 -1
- package/dist/node/secrets-client.d.ts +5 -0
- package/dist/node/secrets-client.js +11 -0
- package/dist/node/storage-client.d.ts +4 -0
- package/dist/node/storage-client.js +18 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [0.36.3]
|
|
2
|
+
- Storage client now supports move operations and emits file moved events.
|
|
3
|
+
- Secrets client now supports existence checks.
|
|
4
|
+
- Project user add calls now omit permission fields unless explicitly set.
|
|
5
|
+
- Updated JS toolchain dependencies: esbuild 0.28.0, jest 30.3.0, mocha 12.0.0-beta-9.2, @tailwindcss/vite 4.2.2, @vitejs/plugin-react 6.0.1, vite 8.0.7.
|
|
6
|
+
|
|
7
|
+
## [0.36.2]
|
|
8
|
+
- Breaking: Removed share-connect API from the TypeScript client (`connectShare` / RoomShareConnectionInfo).
|
|
9
|
+
- OAuth helpers now default requested scope to `profile` (TS auth + React auth).
|
|
10
|
+
|
|
1
11
|
## [0.36.1]
|
|
2
12
|
- Stability
|
|
3
13
|
|
|
@@ -995,7 +995,7 @@ try {
|
|
|
995
995
|
var varStorage = _localStorage;
|
|
996
996
|
|
|
997
997
|
// ../node_modules/lib0/trait/equality.js
|
|
998
|
-
var EqualityTraitSymbol = Symbol("Equality");
|
|
998
|
+
var EqualityTraitSymbol = /* @__PURE__ */ Symbol("Equality");
|
|
999
999
|
var equals = (a, b) => a === b || !!a?.[EqualityTraitSymbol]?.(b) || false;
|
|
1000
1000
|
|
|
1001
1001
|
// ../node_modules/lib0/object.js
|
|
@@ -1215,7 +1215,7 @@ var word = (gen, minLen = 0, maxLen = 20) => {
|
|
|
1215
1215
|
var oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
|
|
1216
1216
|
|
|
1217
1217
|
// ../node_modules/lib0/schema.js
|
|
1218
|
-
var schemaSymbol = Symbol("0schema");
|
|
1218
|
+
var schemaSymbol = /* @__PURE__ */ Symbol("0schema");
|
|
1219
1219
|
var ValidationError = class {
|
|
1220
1220
|
constructor() {
|
|
1221
1221
|
this._rerrs = [];
|
|
@@ -1493,7 +1493,7 @@ var $StringTemplate = class extends Schema {
|
|
|
1493
1493
|
}
|
|
1494
1494
|
};
|
|
1495
1495
|
var $$stringTemplate = $constructedBy($StringTemplate);
|
|
1496
|
-
var isOptionalSymbol = Symbol("optional");
|
|
1496
|
+
var isOptionalSymbol = /* @__PURE__ */ Symbol("optional");
|
|
1497
1497
|
var $Optional = class extends Schema {
|
|
1498
1498
|
/**
|
|
1499
1499
|
* @param {S} shape
|
|
@@ -5,13 +5,6 @@ export interface RoomShare {
|
|
|
5
5
|
projectId: string;
|
|
6
6
|
settings: Record<string, unknown>;
|
|
7
7
|
}
|
|
8
|
-
export interface RoomShareConnectionInfo {
|
|
9
|
-
jwt: string;
|
|
10
|
-
roomName: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
settings: Record<string, unknown>;
|
|
13
|
-
roomUrl: string;
|
|
14
|
-
}
|
|
15
8
|
export interface RoomConnectionInfo {
|
|
16
9
|
jwt: string;
|
|
17
10
|
roomName: string;
|
|
@@ -283,7 +276,6 @@ export declare class Meshagent {
|
|
|
283
276
|
private buildUrl;
|
|
284
277
|
private request;
|
|
285
278
|
private parseRoomShare;
|
|
286
|
-
private parseRoomShareConnectionInfo;
|
|
287
279
|
private parseRoomSession;
|
|
288
280
|
private parseRoom;
|
|
289
281
|
private parseProjectRoomGrant;
|
|
@@ -318,7 +310,6 @@ export declare class Meshagent {
|
|
|
318
310
|
deleteShare(projectId: string, shareId: string): Promise<void>;
|
|
319
311
|
updateShare(projectId: string, shareId: string, settings?: Record<string, unknown>): Promise<void>;
|
|
320
312
|
listShares(projectId: string): Promise<RoomShare[]>;
|
|
321
|
-
connectShare(shareId: string): Promise<RoomShareConnectionInfo>;
|
|
322
313
|
createProject(name: string, settings?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
323
314
|
addUserToProject(projectId: string, userId: string, options?: {
|
|
324
315
|
isAdmin?: boolean;
|
|
@@ -171,28 +171,6 @@ class Meshagent {
|
|
|
171
171
|
settings: (settings && typeof settings === "object") ? settings : {},
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
-
parseRoomShareConnectionInfo(data) {
|
|
175
|
-
if (!data || typeof data !== "object") {
|
|
176
|
-
throw new requirement_1.RoomException("Invalid room share connection payload");
|
|
177
|
-
}
|
|
178
|
-
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, settings, room_url: roomUrlRaw, roomUrl } = data;
|
|
179
|
-
if (typeof jwt !== "string") {
|
|
180
|
-
throw new requirement_1.RoomException("Invalid room share connection payload: missing jwt");
|
|
181
|
-
}
|
|
182
|
-
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
183
|
-
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
184
|
-
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
185
|
-
if (typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
186
|
-
throw new requirement_1.RoomException("Invalid room share connection payload: missing fields");
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
jwt,
|
|
190
|
-
roomName: roomNameValue,
|
|
191
|
-
projectId: projectIdValue,
|
|
192
|
-
settings: (settings && typeof settings === "object") ? settings : {},
|
|
193
|
-
roomUrl: roomUrlValue,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
174
|
parseRoomSession(data) {
|
|
197
175
|
if (!data || typeof data !== "object") {
|
|
198
176
|
throw new requirement_1.RoomException("Invalid room session payload");
|
|
@@ -620,14 +598,6 @@ class Meshagent {
|
|
|
620
598
|
const shares = Array.isArray(data?.shares) ? data.shares : [];
|
|
621
599
|
return shares.map((item) => this.parseRoomShare(item));
|
|
622
600
|
}
|
|
623
|
-
async connectShare(shareId) {
|
|
624
|
-
const data = await this.request(`/shares/${shareId}/connect`, {
|
|
625
|
-
method: "POST",
|
|
626
|
-
json: {},
|
|
627
|
-
action: "connect share",
|
|
628
|
-
});
|
|
629
|
-
return this.parseRoomShareConnectionInfo(data);
|
|
630
|
-
}
|
|
631
601
|
async createProject(name, settings) {
|
|
632
602
|
return await this.request(`/accounts/projects`, {
|
|
633
603
|
method: "POST",
|
|
@@ -636,15 +606,17 @@ class Meshagent {
|
|
|
636
606
|
});
|
|
637
607
|
}
|
|
638
608
|
async addUserToProject(projectId, userId, options = {}) {
|
|
639
|
-
const { isAdmin
|
|
609
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
640
610
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
641
611
|
method: "POST",
|
|
642
612
|
json: {
|
|
643
613
|
project_id: projectId,
|
|
644
614
|
user_id: userId,
|
|
645
|
-
is_admin: isAdmin,
|
|
646
|
-
is_developer: isDeveloper,
|
|
647
|
-
|
|
615
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
616
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
617
|
+
...(canCreateRooms !== undefined
|
|
618
|
+
? { can_create_rooms: canCreateRooms }
|
|
619
|
+
: {}),
|
|
648
620
|
},
|
|
649
621
|
action: "add user to project",
|
|
650
622
|
});
|
|
@@ -52,6 +52,18 @@ export declare class FileUpdatedEvent extends RoomEvent {
|
|
|
52
52
|
get name(): string;
|
|
53
53
|
get description(): string;
|
|
54
54
|
}
|
|
55
|
+
export declare class FileMovedEvent extends RoomEvent {
|
|
56
|
+
sourcePath: string;
|
|
57
|
+
destinationPath: string;
|
|
58
|
+
participantId: string;
|
|
59
|
+
constructor({ sourcePath, destinationPath, participantId, }: {
|
|
60
|
+
sourcePath: string;
|
|
61
|
+
destinationPath: string;
|
|
62
|
+
participantId: string;
|
|
63
|
+
});
|
|
64
|
+
get name(): string;
|
|
65
|
+
get description(): string;
|
|
66
|
+
}
|
|
55
67
|
export declare class RoomLogEvent extends RoomEvent {
|
|
56
68
|
type: string;
|
|
57
69
|
data: Record<string, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomLogEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
|
|
3
|
+
exports.RoomLogEvent = exports.FileMovedEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
|
|
4
4
|
class RoomEvent {
|
|
5
5
|
}
|
|
6
6
|
exports.RoomEvent = RoomEvent;
|
|
@@ -68,6 +68,21 @@ class FileUpdatedEvent extends RoomEvent {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
exports.FileUpdatedEvent = FileUpdatedEvent;
|
|
71
|
+
class FileMovedEvent extends RoomEvent {
|
|
72
|
+
constructor({ sourcePath, destinationPath, participantId, }) {
|
|
73
|
+
super();
|
|
74
|
+
this.sourcePath = sourcePath;
|
|
75
|
+
this.destinationPath = destinationPath;
|
|
76
|
+
this.participantId = participantId;
|
|
77
|
+
}
|
|
78
|
+
get name() {
|
|
79
|
+
return "file moved";
|
|
80
|
+
}
|
|
81
|
+
get description() {
|
|
82
|
+
return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.FileMovedEvent = FileMovedEvent;
|
|
71
86
|
class RoomLogEvent extends RoomEvent {
|
|
72
87
|
constructor({ type, data }) {
|
|
73
88
|
super();
|
|
@@ -73,6 +73,11 @@ export declare class SecretsClient {
|
|
|
73
73
|
delegateTo?: string | null;
|
|
74
74
|
}): Promise<string | null>;
|
|
75
75
|
listSecrets(): Promise<SecretInfo[]>;
|
|
76
|
+
exists({ secretId, delegatedTo, forIdentity, }: {
|
|
77
|
+
secretId: string;
|
|
78
|
+
delegatedTo?: string | null;
|
|
79
|
+
forIdentity?: string | null;
|
|
80
|
+
}): Promise<boolean>;
|
|
76
81
|
deleteSecret({ secretId, delegatedTo, }: {
|
|
77
82
|
secretId: string;
|
|
78
83
|
delegatedTo?: string | null;
|
|
@@ -215,6 +215,17 @@ class SecretsClient {
|
|
|
215
215
|
}
|
|
216
216
|
return secrets.map((item) => this.parseSecretInfo(item));
|
|
217
217
|
}
|
|
218
|
+
async exists({ secretId, delegatedTo, forIdentity, }) {
|
|
219
|
+
const response = await this.invoke("exists", {
|
|
220
|
+
secret_id: secretId,
|
|
221
|
+
delegated_to: delegatedTo ?? null,
|
|
222
|
+
for_identity: forIdentity ?? null,
|
|
223
|
+
});
|
|
224
|
+
if (!(response instanceof response_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
225
|
+
throw this.unexpectedResponse("exists");
|
|
226
|
+
}
|
|
227
|
+
return response.json["exists"];
|
|
228
|
+
}
|
|
218
229
|
async deleteSecret({ secretId, delegatedTo, }) {
|
|
219
230
|
const response = await this.invoke("delete_secret", {
|
|
220
231
|
id: secretId,
|
|
@@ -34,6 +34,7 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
34
34
|
});
|
|
35
35
|
private _handleFileUpdated;
|
|
36
36
|
private _handleFileDeleted;
|
|
37
|
+
private _handleFileMoved;
|
|
37
38
|
private _unexpectedResponseError;
|
|
38
39
|
private _storageEntry;
|
|
39
40
|
private _invoke;
|
|
@@ -42,6 +43,9 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
42
43
|
delete(path: string, { recursive, }?: {
|
|
43
44
|
recursive?: boolean | null;
|
|
44
45
|
}): Promise<void>;
|
|
46
|
+
move(sourcePath: string, destinationPath: string, { overwrite, }?: {
|
|
47
|
+
overwrite?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
45
49
|
exists(path: string): Promise<boolean>;
|
|
46
50
|
private _defaultUploadName;
|
|
47
51
|
private _defaultUploadMimeType;
|
|
@@ -85,6 +85,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
85
85
|
super();
|
|
86
86
|
this.client = room;
|
|
87
87
|
this.client.protocol.addHandler("storage.file.deleted", this._handleFileDeleted.bind(this));
|
|
88
|
+
this.client.protocol.addHandler("storage.file.moved", this._handleFileMoved.bind(this));
|
|
88
89
|
this.client.protocol.addHandler("storage.file.updated", this._handleFileUpdated.bind(this));
|
|
89
90
|
}
|
|
90
91
|
async _handleFileUpdated(protocol, messageId, type, bytes) {
|
|
@@ -99,6 +100,16 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
99
100
|
this.client.emit(event);
|
|
100
101
|
this.emit('file.deleted', event);
|
|
101
102
|
}
|
|
103
|
+
async _handleFileMoved(protocol, messageId, type, bytes) {
|
|
104
|
+
const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
|
|
105
|
+
const event = new room_event_1.FileMovedEvent({
|
|
106
|
+
sourcePath: data["source_path"],
|
|
107
|
+
destinationPath: data["destination_path"],
|
|
108
|
+
participantId: data["participant_id"],
|
|
109
|
+
});
|
|
110
|
+
this.client.emit(event);
|
|
111
|
+
this.emit("file.moved", event);
|
|
112
|
+
}
|
|
102
113
|
_unexpectedResponseError(operation) {
|
|
103
114
|
return _unexpectedStorageResponseError(operation);
|
|
104
115
|
}
|
|
@@ -147,6 +158,13 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
147
158
|
async delete(path, { recursive = null, } = {}) {
|
|
148
159
|
await this._invoke("delete", { path, recursive });
|
|
149
160
|
}
|
|
161
|
+
async move(sourcePath, destinationPath, { overwrite = false, } = {}) {
|
|
162
|
+
await this._invoke("move", {
|
|
163
|
+
source_path: sourcePath,
|
|
164
|
+
destination_path: destinationPath,
|
|
165
|
+
overwrite,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
150
168
|
async exists(path) {
|
|
151
169
|
const result = await this._invoke("exists", { path });
|
|
152
170
|
if (!(result instanceof response_1.JsonContent)) {
|
|
@@ -5,13 +5,6 @@ export interface RoomShare {
|
|
|
5
5
|
projectId: string;
|
|
6
6
|
settings: Record<string, unknown>;
|
|
7
7
|
}
|
|
8
|
-
export interface RoomShareConnectionInfo {
|
|
9
|
-
jwt: string;
|
|
10
|
-
roomName: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
settings: Record<string, unknown>;
|
|
13
|
-
roomUrl: string;
|
|
14
|
-
}
|
|
15
8
|
export interface RoomConnectionInfo {
|
|
16
9
|
jwt: string;
|
|
17
10
|
roomName: string;
|
|
@@ -283,7 +276,6 @@ export declare class Meshagent {
|
|
|
283
276
|
private buildUrl;
|
|
284
277
|
private request;
|
|
285
278
|
private parseRoomShare;
|
|
286
|
-
private parseRoomShareConnectionInfo;
|
|
287
279
|
private parseRoomSession;
|
|
288
280
|
private parseRoom;
|
|
289
281
|
private parseProjectRoomGrant;
|
|
@@ -318,7 +310,6 @@ export declare class Meshagent {
|
|
|
318
310
|
deleteShare(projectId: string, shareId: string): Promise<void>;
|
|
319
311
|
updateShare(projectId: string, shareId: string, settings?: Record<string, unknown>): Promise<void>;
|
|
320
312
|
listShares(projectId: string): Promise<RoomShare[]>;
|
|
321
|
-
connectShare(shareId: string): Promise<RoomShareConnectionInfo>;
|
|
322
313
|
createProject(name: string, settings?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
323
314
|
addUserToProject(projectId: string, userId: string, options?: {
|
|
324
315
|
isAdmin?: boolean;
|
|
@@ -168,28 +168,6 @@ export class Meshagent {
|
|
|
168
168
|
settings: (settings && typeof settings === "object") ? settings : {},
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
parseRoomShareConnectionInfo(data) {
|
|
172
|
-
if (!data || typeof data !== "object") {
|
|
173
|
-
throw new RoomException("Invalid room share connection payload");
|
|
174
|
-
}
|
|
175
|
-
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, settings, room_url: roomUrlRaw, roomUrl } = data;
|
|
176
|
-
if (typeof jwt !== "string") {
|
|
177
|
-
throw new RoomException("Invalid room share connection payload: missing jwt");
|
|
178
|
-
}
|
|
179
|
-
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
180
|
-
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
181
|
-
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
182
|
-
if (typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
183
|
-
throw new RoomException("Invalid room share connection payload: missing fields");
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
jwt,
|
|
187
|
-
roomName: roomNameValue,
|
|
188
|
-
projectId: projectIdValue,
|
|
189
|
-
settings: (settings && typeof settings === "object") ? settings : {},
|
|
190
|
-
roomUrl: roomUrlValue,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
171
|
parseRoomSession(data) {
|
|
194
172
|
if (!data || typeof data !== "object") {
|
|
195
173
|
throw new RoomException("Invalid room session payload");
|
|
@@ -617,14 +595,6 @@ export class Meshagent {
|
|
|
617
595
|
const shares = Array.isArray(data?.shares) ? data.shares : [];
|
|
618
596
|
return shares.map((item) => this.parseRoomShare(item));
|
|
619
597
|
}
|
|
620
|
-
async connectShare(shareId) {
|
|
621
|
-
const data = await this.request(`/shares/${shareId}/connect`, {
|
|
622
|
-
method: "POST",
|
|
623
|
-
json: {},
|
|
624
|
-
action: "connect share",
|
|
625
|
-
});
|
|
626
|
-
return this.parseRoomShareConnectionInfo(data);
|
|
627
|
-
}
|
|
628
598
|
async createProject(name, settings) {
|
|
629
599
|
return await this.request(`/accounts/projects`, {
|
|
630
600
|
method: "POST",
|
|
@@ -633,15 +603,17 @@ export class Meshagent {
|
|
|
633
603
|
});
|
|
634
604
|
}
|
|
635
605
|
async addUserToProject(projectId, userId, options = {}) {
|
|
636
|
-
const { isAdmin
|
|
606
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
637
607
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
638
608
|
method: "POST",
|
|
639
609
|
json: {
|
|
640
610
|
project_id: projectId,
|
|
641
611
|
user_id: userId,
|
|
642
|
-
is_admin: isAdmin,
|
|
643
|
-
is_developer: isDeveloper,
|
|
644
|
-
|
|
612
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
613
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
614
|
+
...(canCreateRooms !== undefined
|
|
615
|
+
? { can_create_rooms: canCreateRooms }
|
|
616
|
+
: {}),
|
|
645
617
|
},
|
|
646
618
|
action: "add user to project",
|
|
647
619
|
});
|
package/dist/esm/room-event.d.ts
CHANGED
|
@@ -52,6 +52,18 @@ export declare class FileUpdatedEvent extends RoomEvent {
|
|
|
52
52
|
get name(): string;
|
|
53
53
|
get description(): string;
|
|
54
54
|
}
|
|
55
|
+
export declare class FileMovedEvent extends RoomEvent {
|
|
56
|
+
sourcePath: string;
|
|
57
|
+
destinationPath: string;
|
|
58
|
+
participantId: string;
|
|
59
|
+
constructor({ sourcePath, destinationPath, participantId, }: {
|
|
60
|
+
sourcePath: string;
|
|
61
|
+
destinationPath: string;
|
|
62
|
+
participantId: string;
|
|
63
|
+
});
|
|
64
|
+
get name(): string;
|
|
65
|
+
get description(): string;
|
|
66
|
+
}
|
|
55
67
|
export declare class RoomLogEvent extends RoomEvent {
|
|
56
68
|
type: string;
|
|
57
69
|
data: Record<string, any>;
|
package/dist/esm/room-event.js
CHANGED
|
@@ -59,6 +59,20 @@ export class FileUpdatedEvent extends RoomEvent {
|
|
|
59
59
|
return `a file was updated at the path ${this.path}`;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
export class FileMovedEvent extends RoomEvent {
|
|
63
|
+
constructor({ sourcePath, destinationPath, participantId, }) {
|
|
64
|
+
super();
|
|
65
|
+
this.sourcePath = sourcePath;
|
|
66
|
+
this.destinationPath = destinationPath;
|
|
67
|
+
this.participantId = participantId;
|
|
68
|
+
}
|
|
69
|
+
get name() {
|
|
70
|
+
return "file moved";
|
|
71
|
+
}
|
|
72
|
+
get description() {
|
|
73
|
+
return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
62
76
|
export class RoomLogEvent extends RoomEvent {
|
|
63
77
|
constructor({ type, data }) {
|
|
64
78
|
super();
|
|
@@ -73,6 +73,11 @@ export declare class SecretsClient {
|
|
|
73
73
|
delegateTo?: string | null;
|
|
74
74
|
}): Promise<string | null>;
|
|
75
75
|
listSecrets(): Promise<SecretInfo[]>;
|
|
76
|
+
exists({ secretId, delegatedTo, forIdentity, }: {
|
|
77
|
+
secretId: string;
|
|
78
|
+
delegatedTo?: string | null;
|
|
79
|
+
forIdentity?: string | null;
|
|
80
|
+
}): Promise<boolean>;
|
|
76
81
|
deleteSecret({ secretId, delegatedTo, }: {
|
|
77
82
|
secretId: string;
|
|
78
83
|
delegatedTo?: string | null;
|
|
@@ -212,6 +212,17 @@ export class SecretsClient {
|
|
|
212
212
|
}
|
|
213
213
|
return secrets.map((item) => this.parseSecretInfo(item));
|
|
214
214
|
}
|
|
215
|
+
async exists({ secretId, delegatedTo, forIdentity, }) {
|
|
216
|
+
const response = await this.invoke("exists", {
|
|
217
|
+
secret_id: secretId,
|
|
218
|
+
delegated_to: delegatedTo ?? null,
|
|
219
|
+
for_identity: forIdentity ?? null,
|
|
220
|
+
});
|
|
221
|
+
if (!(response instanceof JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
222
|
+
throw this.unexpectedResponse("exists");
|
|
223
|
+
}
|
|
224
|
+
return response.json["exists"];
|
|
225
|
+
}
|
|
215
226
|
async deleteSecret({ secretId, delegatedTo, }) {
|
|
216
227
|
const response = await this.invoke("delete_secret", {
|
|
217
228
|
id: secretId,
|
|
@@ -34,6 +34,7 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
34
34
|
});
|
|
35
35
|
private _handleFileUpdated;
|
|
36
36
|
private _handleFileDeleted;
|
|
37
|
+
private _handleFileMoved;
|
|
37
38
|
private _unexpectedResponseError;
|
|
38
39
|
private _storageEntry;
|
|
39
40
|
private _invoke;
|
|
@@ -42,6 +43,9 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
42
43
|
delete(path: string, { recursive, }?: {
|
|
43
44
|
recursive?: boolean | null;
|
|
44
45
|
}): Promise<void>;
|
|
46
|
+
move(sourcePath: string, destinationPath: string, { overwrite, }?: {
|
|
47
|
+
overwrite?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
45
49
|
exists(path: string): Promise<boolean>;
|
|
46
50
|
private _defaultUploadName;
|
|
47
51
|
private _defaultUploadMimeType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileDeletedEvent, FileUpdatedEvent } from "./room-event";
|
|
1
|
+
import { FileDeletedEvent, FileMovedEvent, FileUpdatedEvent } from "./room-event";
|
|
2
2
|
import { BinaryContent, ControlContent, ErrorContent, JsonContent, FileContent } from "./response";
|
|
3
3
|
import { unpackMessage } from "./utils";
|
|
4
4
|
import { EventEmitter } from "./event-emitter";
|
|
@@ -80,6 +80,7 @@ export class StorageClient extends EventEmitter {
|
|
|
80
80
|
super();
|
|
81
81
|
this.client = room;
|
|
82
82
|
this.client.protocol.addHandler("storage.file.deleted", this._handleFileDeleted.bind(this));
|
|
83
|
+
this.client.protocol.addHandler("storage.file.moved", this._handleFileMoved.bind(this));
|
|
83
84
|
this.client.protocol.addHandler("storage.file.updated", this._handleFileUpdated.bind(this));
|
|
84
85
|
}
|
|
85
86
|
async _handleFileUpdated(protocol, messageId, type, bytes) {
|
|
@@ -94,6 +95,16 @@ export class StorageClient extends EventEmitter {
|
|
|
94
95
|
this.client.emit(event);
|
|
95
96
|
this.emit('file.deleted', event);
|
|
96
97
|
}
|
|
98
|
+
async _handleFileMoved(protocol, messageId, type, bytes) {
|
|
99
|
+
const [data, _] = unpackMessage(bytes || new Uint8Array());
|
|
100
|
+
const event = new FileMovedEvent({
|
|
101
|
+
sourcePath: data["source_path"],
|
|
102
|
+
destinationPath: data["destination_path"],
|
|
103
|
+
participantId: data["participant_id"],
|
|
104
|
+
});
|
|
105
|
+
this.client.emit(event);
|
|
106
|
+
this.emit("file.moved", event);
|
|
107
|
+
}
|
|
97
108
|
_unexpectedResponseError(operation) {
|
|
98
109
|
return _unexpectedStorageResponseError(operation);
|
|
99
110
|
}
|
|
@@ -142,6 +153,13 @@ export class StorageClient extends EventEmitter {
|
|
|
142
153
|
async delete(path, { recursive = null, } = {}) {
|
|
143
154
|
await this._invoke("delete", { path, recursive });
|
|
144
155
|
}
|
|
156
|
+
async move(sourcePath, destinationPath, { overwrite = false, } = {}) {
|
|
157
|
+
await this._invoke("move", {
|
|
158
|
+
source_path: sourcePath,
|
|
159
|
+
destination_path: destinationPath,
|
|
160
|
+
overwrite,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
145
163
|
async exists(path) {
|
|
146
164
|
const result = await this._invoke("exists", { path });
|
|
147
165
|
if (!(result instanceof JsonContent)) {
|
|
@@ -5,13 +5,6 @@ export interface RoomShare {
|
|
|
5
5
|
projectId: string;
|
|
6
6
|
settings: Record<string, unknown>;
|
|
7
7
|
}
|
|
8
|
-
export interface RoomShareConnectionInfo {
|
|
9
|
-
jwt: string;
|
|
10
|
-
roomName: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
settings: Record<string, unknown>;
|
|
13
|
-
roomUrl: string;
|
|
14
|
-
}
|
|
15
8
|
export interface RoomConnectionInfo {
|
|
16
9
|
jwt: string;
|
|
17
10
|
roomName: string;
|
|
@@ -283,7 +276,6 @@ export declare class Meshagent {
|
|
|
283
276
|
private buildUrl;
|
|
284
277
|
private request;
|
|
285
278
|
private parseRoomShare;
|
|
286
|
-
private parseRoomShareConnectionInfo;
|
|
287
279
|
private parseRoomSession;
|
|
288
280
|
private parseRoom;
|
|
289
281
|
private parseProjectRoomGrant;
|
|
@@ -318,7 +310,6 @@ export declare class Meshagent {
|
|
|
318
310
|
deleteShare(projectId: string, shareId: string): Promise<void>;
|
|
319
311
|
updateShare(projectId: string, shareId: string, settings?: Record<string, unknown>): Promise<void>;
|
|
320
312
|
listShares(projectId: string): Promise<RoomShare[]>;
|
|
321
|
-
connectShare(shareId: string): Promise<RoomShareConnectionInfo>;
|
|
322
313
|
createProject(name: string, settings?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
323
314
|
addUserToProject(projectId: string, userId: string, options?: {
|
|
324
315
|
isAdmin?: boolean;
|
|
@@ -171,28 +171,6 @@ class Meshagent {
|
|
|
171
171
|
settings: (settings && typeof settings === "object") ? settings : {},
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
-
parseRoomShareConnectionInfo(data) {
|
|
175
|
-
if (!data || typeof data !== "object") {
|
|
176
|
-
throw new requirement_1.RoomException("Invalid room share connection payload");
|
|
177
|
-
}
|
|
178
|
-
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, settings, room_url: roomUrlRaw, roomUrl } = data;
|
|
179
|
-
if (typeof jwt !== "string") {
|
|
180
|
-
throw new requirement_1.RoomException("Invalid room share connection payload: missing jwt");
|
|
181
|
-
}
|
|
182
|
-
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
183
|
-
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
184
|
-
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
185
|
-
if (typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
186
|
-
throw new requirement_1.RoomException("Invalid room share connection payload: missing fields");
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
jwt,
|
|
190
|
-
roomName: roomNameValue,
|
|
191
|
-
projectId: projectIdValue,
|
|
192
|
-
settings: (settings && typeof settings === "object") ? settings : {},
|
|
193
|
-
roomUrl: roomUrlValue,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
174
|
parseRoomSession(data) {
|
|
197
175
|
if (!data || typeof data !== "object") {
|
|
198
176
|
throw new requirement_1.RoomException("Invalid room session payload");
|
|
@@ -620,14 +598,6 @@ class Meshagent {
|
|
|
620
598
|
const shares = Array.isArray(data?.shares) ? data.shares : [];
|
|
621
599
|
return shares.map((item) => this.parseRoomShare(item));
|
|
622
600
|
}
|
|
623
|
-
async connectShare(shareId) {
|
|
624
|
-
const data = await this.request(`/shares/${shareId}/connect`, {
|
|
625
|
-
method: "POST",
|
|
626
|
-
json: {},
|
|
627
|
-
action: "connect share",
|
|
628
|
-
});
|
|
629
|
-
return this.parseRoomShareConnectionInfo(data);
|
|
630
|
-
}
|
|
631
601
|
async createProject(name, settings) {
|
|
632
602
|
return await this.request(`/accounts/projects`, {
|
|
633
603
|
method: "POST",
|
|
@@ -636,15 +606,17 @@ class Meshagent {
|
|
|
636
606
|
});
|
|
637
607
|
}
|
|
638
608
|
async addUserToProject(projectId, userId, options = {}) {
|
|
639
|
-
const { isAdmin
|
|
609
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
640
610
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
641
611
|
method: "POST",
|
|
642
612
|
json: {
|
|
643
613
|
project_id: projectId,
|
|
644
614
|
user_id: userId,
|
|
645
|
-
is_admin: isAdmin,
|
|
646
|
-
is_developer: isDeveloper,
|
|
647
|
-
|
|
615
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
616
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
617
|
+
...(canCreateRooms !== undefined
|
|
618
|
+
? { can_create_rooms: canCreateRooms }
|
|
619
|
+
: {}),
|
|
648
620
|
},
|
|
649
621
|
action: "add user to project",
|
|
650
622
|
});
|
|
@@ -52,6 +52,18 @@ export declare class FileUpdatedEvent extends RoomEvent {
|
|
|
52
52
|
get name(): string;
|
|
53
53
|
get description(): string;
|
|
54
54
|
}
|
|
55
|
+
export declare class FileMovedEvent extends RoomEvent {
|
|
56
|
+
sourcePath: string;
|
|
57
|
+
destinationPath: string;
|
|
58
|
+
participantId: string;
|
|
59
|
+
constructor({ sourcePath, destinationPath, participantId, }: {
|
|
60
|
+
sourcePath: string;
|
|
61
|
+
destinationPath: string;
|
|
62
|
+
participantId: string;
|
|
63
|
+
});
|
|
64
|
+
get name(): string;
|
|
65
|
+
get description(): string;
|
|
66
|
+
}
|
|
55
67
|
export declare class RoomLogEvent extends RoomEvent {
|
|
56
68
|
type: string;
|
|
57
69
|
data: Record<string, any>;
|
package/dist/node/room-event.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomLogEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
|
|
3
|
+
exports.RoomLogEvent = exports.FileMovedEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
|
|
4
4
|
class RoomEvent {
|
|
5
5
|
}
|
|
6
6
|
exports.RoomEvent = RoomEvent;
|
|
@@ -68,6 +68,21 @@ class FileUpdatedEvent extends RoomEvent {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
exports.FileUpdatedEvent = FileUpdatedEvent;
|
|
71
|
+
class FileMovedEvent extends RoomEvent {
|
|
72
|
+
constructor({ sourcePath, destinationPath, participantId, }) {
|
|
73
|
+
super();
|
|
74
|
+
this.sourcePath = sourcePath;
|
|
75
|
+
this.destinationPath = destinationPath;
|
|
76
|
+
this.participantId = participantId;
|
|
77
|
+
}
|
|
78
|
+
get name() {
|
|
79
|
+
return "file moved";
|
|
80
|
+
}
|
|
81
|
+
get description() {
|
|
82
|
+
return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.FileMovedEvent = FileMovedEvent;
|
|
71
86
|
class RoomLogEvent extends RoomEvent {
|
|
72
87
|
constructor({ type, data }) {
|
|
73
88
|
super();
|
|
@@ -73,6 +73,11 @@ export declare class SecretsClient {
|
|
|
73
73
|
delegateTo?: string | null;
|
|
74
74
|
}): Promise<string | null>;
|
|
75
75
|
listSecrets(): Promise<SecretInfo[]>;
|
|
76
|
+
exists({ secretId, delegatedTo, forIdentity, }: {
|
|
77
|
+
secretId: string;
|
|
78
|
+
delegatedTo?: string | null;
|
|
79
|
+
forIdentity?: string | null;
|
|
80
|
+
}): Promise<boolean>;
|
|
76
81
|
deleteSecret({ secretId, delegatedTo, }: {
|
|
77
82
|
secretId: string;
|
|
78
83
|
delegatedTo?: string | null;
|
|
@@ -215,6 +215,17 @@ class SecretsClient {
|
|
|
215
215
|
}
|
|
216
216
|
return secrets.map((item) => this.parseSecretInfo(item));
|
|
217
217
|
}
|
|
218
|
+
async exists({ secretId, delegatedTo, forIdentity, }) {
|
|
219
|
+
const response = await this.invoke("exists", {
|
|
220
|
+
secret_id: secretId,
|
|
221
|
+
delegated_to: delegatedTo ?? null,
|
|
222
|
+
for_identity: forIdentity ?? null,
|
|
223
|
+
});
|
|
224
|
+
if (!(response instanceof response_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
225
|
+
throw this.unexpectedResponse("exists");
|
|
226
|
+
}
|
|
227
|
+
return response.json["exists"];
|
|
228
|
+
}
|
|
218
229
|
async deleteSecret({ secretId, delegatedTo, }) {
|
|
219
230
|
const response = await this.invoke("delete_secret", {
|
|
220
231
|
id: secretId,
|
|
@@ -34,6 +34,7 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
34
34
|
});
|
|
35
35
|
private _handleFileUpdated;
|
|
36
36
|
private _handleFileDeleted;
|
|
37
|
+
private _handleFileMoved;
|
|
37
38
|
private _unexpectedResponseError;
|
|
38
39
|
private _storageEntry;
|
|
39
40
|
private _invoke;
|
|
@@ -42,6 +43,9 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
42
43
|
delete(path: string, { recursive, }?: {
|
|
43
44
|
recursive?: boolean | null;
|
|
44
45
|
}): Promise<void>;
|
|
46
|
+
move(sourcePath: string, destinationPath: string, { overwrite, }?: {
|
|
47
|
+
overwrite?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
45
49
|
exists(path: string): Promise<boolean>;
|
|
46
50
|
private _defaultUploadName;
|
|
47
51
|
private _defaultUploadMimeType;
|
|
@@ -85,6 +85,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
85
85
|
super();
|
|
86
86
|
this.client = room;
|
|
87
87
|
this.client.protocol.addHandler("storage.file.deleted", this._handleFileDeleted.bind(this));
|
|
88
|
+
this.client.protocol.addHandler("storage.file.moved", this._handleFileMoved.bind(this));
|
|
88
89
|
this.client.protocol.addHandler("storage.file.updated", this._handleFileUpdated.bind(this));
|
|
89
90
|
}
|
|
90
91
|
async _handleFileUpdated(protocol, messageId, type, bytes) {
|
|
@@ -99,6 +100,16 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
99
100
|
this.client.emit(event);
|
|
100
101
|
this.emit('file.deleted', event);
|
|
101
102
|
}
|
|
103
|
+
async _handleFileMoved(protocol, messageId, type, bytes) {
|
|
104
|
+
const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
|
|
105
|
+
const event = new room_event_1.FileMovedEvent({
|
|
106
|
+
sourcePath: data["source_path"],
|
|
107
|
+
destinationPath: data["destination_path"],
|
|
108
|
+
participantId: data["participant_id"],
|
|
109
|
+
});
|
|
110
|
+
this.client.emit(event);
|
|
111
|
+
this.emit("file.moved", event);
|
|
112
|
+
}
|
|
102
113
|
_unexpectedResponseError(operation) {
|
|
103
114
|
return _unexpectedStorageResponseError(operation);
|
|
104
115
|
}
|
|
@@ -147,6 +158,13 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
147
158
|
async delete(path, { recursive = null, } = {}) {
|
|
148
159
|
await this._invoke("delete", { path, recursive });
|
|
149
160
|
}
|
|
161
|
+
async move(sourcePath, destinationPath, { overwrite = false, } = {}) {
|
|
162
|
+
await this._invoke("move", {
|
|
163
|
+
source_path: sourcePath,
|
|
164
|
+
destination_path: destinationPath,
|
|
165
|
+
overwrite,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
150
168
|
async exists(path) {
|
|
151
169
|
const result = await this._invoke("exists", { path });
|
|
152
170
|
if (!(result instanceof response_1.JsonContent)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshagent/meshagent",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.3",
|
|
4
4
|
"description": "Meshagent Client",
|
|
5
5
|
"homepage": "https://github.com/meshagent/meshagent-ts",
|
|
6
6
|
"scripts": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"@types/node": "^22.13.9",
|
|
36
36
|
"@types/ws": "^8.18.0",
|
|
37
37
|
"chai": "^5.2.0",
|
|
38
|
-
"esbuild": "^0.
|
|
38
|
+
"esbuild": "^0.28.0",
|
|
39
39
|
"esm": "^3.2.25",
|
|
40
|
-
"mocha": "^
|
|
40
|
+
"mocha": "^12.0.0-beta-9.2",
|
|
41
41
|
"typescript": "^5.8.2"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|