@meshagent/meshagent 0.36.2 → 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 +6 -0
- package/dist/browser/entrypoint.js +3 -3
- package/dist/browser/meshagent-client.js +6 -4
- 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.js +6 -4
- 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.js +6 -4
- 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,9 @@
|
|
|
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
|
+
|
|
1
7
|
## [0.36.2]
|
|
2
8
|
- Breaking: Removed share-connect API from the TypeScript client (`connectShare` / RoomShareConnectionInfo).
|
|
3
9
|
- OAuth helpers now default requested scope to `profile` (TS auth + React auth).
|
|
@@ -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
|
|
@@ -606,15 +606,17 @@ class Meshagent {
|
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
608
|
async addUserToProject(projectId, userId, options = {}) {
|
|
609
|
-
const { isAdmin
|
|
609
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
610
610
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
611
611
|
method: "POST",
|
|
612
612
|
json: {
|
|
613
613
|
project_id: projectId,
|
|
614
614
|
user_id: userId,
|
|
615
|
-
is_admin: isAdmin,
|
|
616
|
-
is_developer: isDeveloper,
|
|
617
|
-
|
|
615
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
616
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
617
|
+
...(canCreateRooms !== undefined
|
|
618
|
+
? { can_create_rooms: canCreateRooms }
|
|
619
|
+
: {}),
|
|
618
620
|
},
|
|
619
621
|
action: "add user to project",
|
|
620
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)) {
|
|
@@ -603,15 +603,17 @@ export class Meshagent {
|
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
async addUserToProject(projectId, userId, options = {}) {
|
|
606
|
-
const { isAdmin
|
|
606
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
607
607
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
608
608
|
method: "POST",
|
|
609
609
|
json: {
|
|
610
610
|
project_id: projectId,
|
|
611
611
|
user_id: userId,
|
|
612
|
-
is_admin: isAdmin,
|
|
613
|
-
is_developer: isDeveloper,
|
|
614
|
-
|
|
612
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
613
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
614
|
+
...(canCreateRooms !== undefined
|
|
615
|
+
? { can_create_rooms: canCreateRooms }
|
|
616
|
+
: {}),
|
|
615
617
|
},
|
|
616
618
|
action: "add user to project",
|
|
617
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)) {
|
|
@@ -606,15 +606,17 @@ class Meshagent {
|
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
608
|
async addUserToProject(projectId, userId, options = {}) {
|
|
609
|
-
const { isAdmin
|
|
609
|
+
const { isAdmin, isDeveloper, canCreateRooms } = options;
|
|
610
610
|
return await this.request(`/accounts/projects/${projectId}/users`, {
|
|
611
611
|
method: "POST",
|
|
612
612
|
json: {
|
|
613
613
|
project_id: projectId,
|
|
614
614
|
user_id: userId,
|
|
615
|
-
is_admin: isAdmin,
|
|
616
|
-
is_developer: isDeveloper,
|
|
617
|
-
|
|
615
|
+
...(isAdmin !== undefined ? { is_admin: isAdmin } : {}),
|
|
616
|
+
...(isDeveloper !== undefined ? { is_developer: isDeveloper } : {}),
|
|
617
|
+
...(canCreateRooms !== undefined
|
|
618
|
+
? { can_create_rooms: canCreateRooms }
|
|
619
|
+
: {}),
|
|
618
620
|
},
|
|
619
621
|
action: "add user to project",
|
|
620
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": {
|