@simplito/privmx-webendpoint 2.5.2 → 2.6.1
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/Types.d.ts +97 -1
- package/Types.js +102 -15
- package/api/ConnectionNative.d.ts +18 -2
- package/api/ConnectionNative.js +26 -7
- package/api/EventApiNative.d.ts +4 -3
- package/api/EventApiNative.js +7 -4
- package/api/InboxApiNative.d.ts +4 -5
- package/api/InboxApiNative.js +6 -9
- package/api/KvdbApiNative.d.ts +5 -5
- package/api/KvdbApiNative.js +8 -8
- package/api/StoreApiNative.d.ts +7 -7
- package/api/StoreApiNative.js +8 -8
- package/api/ThreadApiNative.d.ts +4 -5
- package/api/ThreadApiNative.js +6 -9
- package/assets/driver-web-context.js +1 -1
- package/assets/endpoint-wasm-module.js +1 -1
- package/assets/endpoint-wasm-module.wasm +0 -0
- package/bundle/privmx-endpoint-web.js +1 -1
- package/extra/PrivmxClient.d.ts +9 -2
- package/extra/PrivmxClient.js +15 -1
- package/extra/__mocks__/constants.d.ts +63 -0
- package/extra/__mocks__/constants.js +51 -0
- package/extra/__mocks__/mockContainerSubscriber.d.ts +8 -0
- package/extra/__mocks__/mockContainerSubscriber.js +26 -0
- package/extra/{__tests__/__mocks__ → __mocks__}/mockEventQueue.d.ts +1 -3
- package/extra/{__tests__/__mocks__ → __mocks__}/mockEventQueue.js +6 -8
- package/extra/{__tests__/__mocks__ → __mocks__}/utils.d.ts +1 -1
- package/extra/{__tests__/__mocks__ → __mocks__}/utils.js +4 -5
- package/extra/__tests__/eventsManager.test.js +38 -27
- package/extra/__tests__/inboxEventManager.js +79 -0
- package/extra/__tests__/storeEventManager.test.js +48 -28
- package/extra/__tests__/threadEventManager.test.js +49 -29
- package/extra/events.d.ts +4 -217
- package/extra/events.js +25 -213
- package/extra/files.d.ts +2 -2
- package/extra/files.js +2 -2
- package/extra/inbox.js +1 -2
- package/extra/index.d.ts +3 -3
- package/extra/index.js +9 -10
- package/extra/managers.d.ts +98 -0
- package/extra/managers.js +157 -0
- package/extra/subscriptions.d.ts +165 -0
- package/extra/subscriptions.js +51 -0
- package/extra/utils.js +4 -5
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/package.json +12 -13
- package/service/Connection.d.ts +21 -2
- package/service/Connection.js +27 -2
- package/service/CryptoApi.d.ts +1 -1
- package/service/CryptoApi.js +1 -1
- package/service/EventApi.d.ts +14 -9
- package/service/EventApi.js +35 -10
- package/service/InboxApi.d.ts +14 -13
- package/service/InboxApi.js +42 -17
- package/service/KvdbApi.d.ts +19 -11
- package/service/KvdbApi.js +51 -17
- package/service/StoreApi.d.ts +22 -13
- package/service/StoreApi.js +53 -17
- package/service/ThreadApi.d.ts +14 -13
- package/service/ThreadApi.js +44 -19
- package/service/index.d.ts +2 -1
- package/service/index.js +3 -1
- package/extra/__tests__/__mocks__/constants.d.ts +0 -36
- package/extra/__tests__/__mocks__/constants.js +0 -42
- package/extra/__tests__/__mocks__/mockContainerSubscriber.d.ts +0 -12
- package/extra/__tests__/__mocks__/mockContainerSubscriber.js +0 -25
- package/extra/__tests__/__mocks__/mockEventAPIs.d.ts +0 -30
- package/extra/__tests__/__mocks__/mockEventAPIs.js +0 -70
- package/extra/__tests__/inboxEventManager.test.js +0 -56
- /package/extra/__tests__/{inboxEventManager.test.d.ts → inboxEventManager.d.ts} +0 -0
package/service/KvdbApi.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
import { BaseApi } from "./BaseApi";
|
|
12
12
|
import { KvdbApiNative } from "../api/KvdbApiNative";
|
|
13
|
-
import { PagingQuery, PagingList, UserWithPubKey, Kvdb, ContainerPolicy, KvdbEntry, DeleteEntriesResult } from "../Types";
|
|
13
|
+
import { PagingQuery, PagingList, UserWithPubKey, Kvdb, ContainerPolicy, KvdbEntry, DeleteEntriesResult, KvdbEventSelectorType, KvdbEventType } from "../Types";
|
|
14
14
|
export declare class KvdbApi extends BaseApi {
|
|
15
15
|
protected native: KvdbApiNative;
|
|
16
16
|
constructor(native: KvdbApiNative, ptr: number);
|
|
@@ -122,21 +122,29 @@ export declare class KvdbApi extends BaseApi {
|
|
|
122
122
|
*/
|
|
123
123
|
deleteEntries(kvdbId: string, keys: string[]): Promise<DeleteEntriesResult>;
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
125
|
+
* Subscribe for the KVDB events on the given subscription query.
|
|
126
|
+
*
|
|
127
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
128
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
126
129
|
*/
|
|
127
|
-
|
|
130
|
+
subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
|
|
128
131
|
/**
|
|
129
|
-
*
|
|
132
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
133
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
130
134
|
*/
|
|
131
|
-
|
|
135
|
+
unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
|
|
132
136
|
/**
|
|
133
|
-
*
|
|
134
|
-
* @param {
|
|
137
|
+
* Generate subscription Query for the KVDB events.
|
|
138
|
+
* @param {EventType} eventType type of event which you listen for
|
|
139
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
140
|
+
* @param {string} selectorId ID of the selector
|
|
135
141
|
*/
|
|
136
|
-
|
|
142
|
+
buildSubscriptionQuery(eventType: KvdbEventType, selectorType: KvdbEventSelectorType, selectorId: string): Promise<string>;
|
|
137
143
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @param {
|
|
144
|
+
* Generate subscription Query for the KVDB events for single KvdbEntry.
|
|
145
|
+
* @param {EventType} eventType type of event which you listen for
|
|
146
|
+
* @param {string} kvdbId ID of the KVDB
|
|
147
|
+
* @param {string} kvdbEntryKey Key of Kvdb Entry
|
|
140
148
|
*/
|
|
141
|
-
|
|
149
|
+
buildSubscriptionQueryForSelectedEntry(eventType: KvdbEventType, kvdbId: string, kvdbEntryKey: string): Promise<string>;
|
|
142
150
|
}
|
package/service/KvdbApi.js
CHANGED
|
@@ -176,33 +176,67 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
176
176
|
keys,
|
|
177
177
|
]);
|
|
178
178
|
}
|
|
179
|
-
/**
|
|
180
|
-
|
|
179
|
+
// /**
|
|
180
|
+
// * Subscribes for the KVDB module main events.
|
|
181
|
+
// */
|
|
182
|
+
// async subscribeForKvdbEvents(): Promise<void> {
|
|
183
|
+
// return this.native.subscribeForKvdbEvents(this.servicePtr, []);
|
|
184
|
+
// }
|
|
185
|
+
// /**
|
|
186
|
+
// * Unsubscribes from the KVDB module main events.
|
|
187
|
+
// */
|
|
188
|
+
// async unsubscribeFromKvdbEvents(): Promise<void> {
|
|
189
|
+
// return this.native.unsubscribeFromKvdbEvents(this.servicePtr, []);
|
|
190
|
+
// }
|
|
191
|
+
// /**
|
|
192
|
+
// * Subscribes for events in given KVDB.
|
|
193
|
+
// * @param {string} kvdbId ID of the KVDB to subscribe
|
|
194
|
+
// */
|
|
195
|
+
// async subscribeForEntryEvents(kvdbId: string): Promise<void> {
|
|
196
|
+
// return this.native.subscribeForEntryEvents(this.servicePtr, [kvdbId]);
|
|
197
|
+
// }
|
|
198
|
+
// /**
|
|
199
|
+
// * Unsubscribes from events in given KVDB.
|
|
200
|
+
// * @param {string} kvdbId ID of the KVDB to unsubscribe
|
|
201
|
+
// */
|
|
202
|
+
// async unsubscribeFromEntryEvents(kvdbId: string): Promise<void> {
|
|
203
|
+
// return this.native.unsubscribeFromEntryEvents(this.servicePtr, [
|
|
204
|
+
// kvdbId,
|
|
205
|
+
// ]);
|
|
206
|
+
// }
|
|
207
|
+
/**
|
|
208
|
+
* Subscribe for the KVDB events on the given subscription query.
|
|
209
|
+
*
|
|
210
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
211
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
181
212
|
*/
|
|
182
|
-
async
|
|
183
|
-
return this.native.
|
|
213
|
+
async subscribeFor(subscriptionQueries) {
|
|
214
|
+
return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
|
|
184
215
|
}
|
|
185
216
|
/**
|
|
186
|
-
*
|
|
217
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
218
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
187
219
|
*/
|
|
188
|
-
async
|
|
189
|
-
return this.native.
|
|
220
|
+
async unsubscribeFrom(subscriptionIds) {
|
|
221
|
+
return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
|
|
190
222
|
}
|
|
191
223
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {
|
|
224
|
+
* Generate subscription Query for the KVDB events.
|
|
225
|
+
* @param {EventType} eventType type of event which you listen for
|
|
226
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
227
|
+
* @param {string} selectorId ID of the selector
|
|
194
228
|
*/
|
|
195
|
-
async
|
|
196
|
-
return this.native.
|
|
229
|
+
async buildSubscriptionQuery(eventType, selectorType, selectorId) {
|
|
230
|
+
return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
|
|
197
231
|
}
|
|
198
232
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @param {
|
|
233
|
+
* Generate subscription Query for the KVDB events for single KvdbEntry.
|
|
234
|
+
* @param {EventType} eventType type of event which you listen for
|
|
235
|
+
* @param {string} kvdbId ID of the KVDB
|
|
236
|
+
* @param {string} kvdbEntryKey Key of Kvdb Entry
|
|
201
237
|
*/
|
|
202
|
-
async
|
|
203
|
-
return this.native.
|
|
204
|
-
kvdbId,
|
|
205
|
-
]);
|
|
238
|
+
async buildSubscriptionQueryForSelectedEntry(eventType, kvdbId, kvdbEntryKey) {
|
|
239
|
+
return this.native.buildSubscriptionQueryForSelectedEntry(this.servicePtr, [eventType, kvdbId, kvdbEntryKey]);
|
|
206
240
|
}
|
|
207
241
|
}
|
|
208
242
|
exports.KvdbApi = KvdbApi;
|
package/service/StoreApi.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
import { BaseApi } from "./BaseApi";
|
|
12
12
|
import { StoreApiNative } from "../api/StoreApiNative";
|
|
13
|
-
import { PagingQuery, PagingList, UserWithPubKey, Store, File, ContainerPolicy } from "../Types";
|
|
13
|
+
import { PagingQuery, PagingList, UserWithPubKey, Store, File, ContainerPolicy, StoreEventSelectorType, StoreEventType } from "../Types";
|
|
14
14
|
export declare class StoreApi extends BaseApi {
|
|
15
15
|
private native;
|
|
16
16
|
constructor(native: StoreApiNative, ptr: number);
|
|
@@ -70,9 +70,10 @@ export declare class StoreApi extends BaseApi {
|
|
|
70
70
|
* @param {Uint8Array} publicMeta public file metadata
|
|
71
71
|
* @param {Uint8Array} privateMeta private file metadata
|
|
72
72
|
* @param {number} size size of the file
|
|
73
|
+
* @param {boolean} [randomWriteSupport] enable random write support for file
|
|
73
74
|
* @returns {number} handle to write data
|
|
74
75
|
*/
|
|
75
|
-
createFile(storeId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, size: number): Promise<number>;
|
|
76
|
+
createFile(storeId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, size: number, randomWriteSupport?: boolean): Promise<number>;
|
|
76
77
|
/**
|
|
77
78
|
* Update an existing file in a Store.
|
|
78
79
|
*
|
|
@@ -96,8 +97,9 @@ export declare class StoreApi extends BaseApi {
|
|
|
96
97
|
*
|
|
97
98
|
* @param {number} fileHandle handle to write file data
|
|
98
99
|
* @param {Uint8Array} dataChunk file data chunk
|
|
100
|
+
* @param {boolean} [truncate] truncate the file from: current pos + dataChunk size
|
|
99
101
|
*/
|
|
100
|
-
writeToFile(fileHandle: number, dataChunk: Uint8Array): Promise<void>;
|
|
102
|
+
writeToFile(fileHandle: number, dataChunk: Uint8Array, truncate?: boolean): Promise<void>;
|
|
101
103
|
/**
|
|
102
104
|
* Deletes a file by given ID.
|
|
103
105
|
*
|
|
@@ -150,21 +152,28 @@ export declare class StoreApi extends BaseApi {
|
|
|
150
152
|
*/
|
|
151
153
|
closeFile(fileHandle: number): Promise<string>;
|
|
152
154
|
/**
|
|
153
|
-
*
|
|
155
|
+
* Synchronize file handle data with newest data on server
|
|
156
|
+
*
|
|
157
|
+
* @param {number} fileHandle handle to read/write file data
|
|
154
158
|
*/
|
|
155
|
-
|
|
159
|
+
syncFile(fileHandle: number): Promise<void>;
|
|
156
160
|
/**
|
|
157
|
-
*
|
|
161
|
+
* Subscribe for the Store events on the given subscription query.
|
|
162
|
+
*
|
|
163
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
164
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
158
165
|
*/
|
|
159
|
-
|
|
166
|
+
subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
|
|
160
167
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param {string}
|
|
168
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
169
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
163
170
|
*/
|
|
164
|
-
|
|
171
|
+
unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
|
|
165
172
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param {
|
|
173
|
+
* Generate subscription Query for the Store events.
|
|
174
|
+
* @param {EventType} eventType type of event which you listen for
|
|
175
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
176
|
+
* @param {string} selectorId ID of the selector
|
|
168
177
|
*/
|
|
169
|
-
|
|
178
|
+
buildSubscriptionQuery(eventType: StoreEventType, selectorType: StoreEventSelectorType, selectorId: string): Promise<string>;
|
|
170
179
|
}
|
package/service/StoreApi.js
CHANGED
|
@@ -101,14 +101,16 @@ class StoreApi extends BaseApi_1.BaseApi {
|
|
|
101
101
|
* @param {Uint8Array} publicMeta public file metadata
|
|
102
102
|
* @param {Uint8Array} privateMeta private file metadata
|
|
103
103
|
* @param {number} size size of the file
|
|
104
|
+
* @param {boolean} [randomWriteSupport] enable random write support for file
|
|
104
105
|
* @returns {number} handle to write data
|
|
105
106
|
*/
|
|
106
|
-
async createFile(storeId, publicMeta, privateMeta, size) {
|
|
107
|
+
async createFile(storeId, publicMeta, privateMeta, size, randomWriteSupport = false) {
|
|
107
108
|
return this.native.createFile(this.servicePtr, [
|
|
108
109
|
storeId,
|
|
109
110
|
publicMeta,
|
|
110
111
|
privateMeta,
|
|
111
112
|
size,
|
|
113
|
+
randomWriteSupport
|
|
112
114
|
]);
|
|
113
115
|
}
|
|
114
116
|
/**
|
|
@@ -147,9 +149,10 @@ class StoreApi extends BaseApi_1.BaseApi {
|
|
|
147
149
|
*
|
|
148
150
|
* @param {number} fileHandle handle to write file data
|
|
149
151
|
* @param {Uint8Array} dataChunk file data chunk
|
|
152
|
+
* @param {boolean} [truncate] truncate the file from: current pos + dataChunk size
|
|
150
153
|
*/
|
|
151
|
-
async writeToFile(fileHandle, dataChunk) {
|
|
152
|
-
return this.native.writeToFile(this.servicePtr, [fileHandle, dataChunk]);
|
|
154
|
+
async writeToFile(fileHandle, dataChunk, truncate = false) {
|
|
155
|
+
return this.native.writeToFile(this.servicePtr, [fileHandle, dataChunk, truncate]);
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
158
|
* Deletes a file by given ID.
|
|
@@ -217,30 +220,63 @@ class StoreApi extends BaseApi_1.BaseApi {
|
|
|
217
220
|
return this.native.closeFile(this.servicePtr, [fileHandle]);
|
|
218
221
|
}
|
|
219
222
|
/**
|
|
220
|
-
*
|
|
223
|
+
* Synchronize file handle data with newest data on server
|
|
224
|
+
*
|
|
225
|
+
* @param {number} fileHandle handle to read/write file data
|
|
221
226
|
*/
|
|
222
|
-
async
|
|
223
|
-
return this.native.
|
|
227
|
+
async syncFile(fileHandle) {
|
|
228
|
+
return this.native.syncFile(this.servicePtr, [fileHandle]);
|
|
224
229
|
}
|
|
230
|
+
// /**
|
|
231
|
+
// * Subscribes for the Store module main events.
|
|
232
|
+
// */
|
|
233
|
+
// async subscribeForStoreEvents(): Promise<void> {
|
|
234
|
+
// return this.native.subscribeForStoreEvents(this.servicePtr, []);
|
|
235
|
+
// }
|
|
236
|
+
// /**
|
|
237
|
+
// * Unsubscribes from the Store module main events.
|
|
238
|
+
// */
|
|
239
|
+
// async unsubscribeFromStoreEvents(): Promise<void> {
|
|
240
|
+
// return this.native.unsubscribeFromStoreEvents(this.servicePtr, []);
|
|
241
|
+
// }
|
|
242
|
+
// /**
|
|
243
|
+
// * Subscribes for events in given Store.
|
|
244
|
+
// * @param {string} storeId ID of the Store to subscribe
|
|
245
|
+
// */
|
|
246
|
+
// async subscribeForFileEvents(storeId: string): Promise<void> {
|
|
247
|
+
// return this.native.subscribeForFileEvents(this.servicePtr, [storeId]);
|
|
248
|
+
// }
|
|
249
|
+
// /**
|
|
250
|
+
// * Unsubscribes from events in given Store.
|
|
251
|
+
// * @param {string} storeId ID of the Store to unsubscribe
|
|
252
|
+
// */
|
|
253
|
+
// async unsubscribeFromFileEvents(storeId: string): Promise<void> {
|
|
254
|
+
// return this.native.unsubscribeFromFileEvents(this.servicePtr, [storeId]);
|
|
255
|
+
// }
|
|
225
256
|
/**
|
|
226
|
-
*
|
|
257
|
+
* Subscribe for the Store events on the given subscription query.
|
|
258
|
+
*
|
|
259
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
260
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
227
261
|
*/
|
|
228
|
-
async
|
|
229
|
-
return this.native.
|
|
262
|
+
async subscribeFor(subscriptionQueries) {
|
|
263
|
+
return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
|
|
230
264
|
}
|
|
231
265
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param {string}
|
|
266
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
267
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
234
268
|
*/
|
|
235
|
-
async
|
|
236
|
-
return this.native.
|
|
269
|
+
async unsubscribeFrom(subscriptionIds) {
|
|
270
|
+
return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
|
|
237
271
|
}
|
|
238
272
|
/**
|
|
239
|
-
*
|
|
240
|
-
* @param {
|
|
273
|
+
* Generate subscription Query for the Store events.
|
|
274
|
+
* @param {EventType} eventType type of event which you listen for
|
|
275
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
276
|
+
* @param {string} selectorId ID of the selector
|
|
241
277
|
*/
|
|
242
|
-
async
|
|
243
|
-
return this.native.
|
|
278
|
+
async buildSubscriptionQuery(eventType, selectorType, selectorId) {
|
|
279
|
+
return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
|
|
244
280
|
}
|
|
245
281
|
}
|
|
246
282
|
exports.StoreApi = StoreApi;
|
package/service/ThreadApi.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ limitations under the License.
|
|
|
10
10
|
*/
|
|
11
11
|
import { BaseApi } from "./BaseApi";
|
|
12
12
|
import { ThreadApiNative } from "../api/ThreadApiNative";
|
|
13
|
-
import { PagingQuery, PagingList, UserWithPubKey, Thread, Message, ContainerPolicy } from "../Types";
|
|
13
|
+
import { PagingQuery, PagingList, UserWithPubKey, Thread, Message, ContainerPolicy, ThreadEventType, ThreadEventSelectorType } from "../Types";
|
|
14
14
|
export declare class ThreadApi extends BaseApi {
|
|
15
15
|
protected native: ThreadApiNative;
|
|
16
16
|
constructor(native: ThreadApiNative, ptr: number);
|
|
@@ -104,21 +104,22 @@ export declare class ThreadApi extends BaseApi {
|
|
|
104
104
|
*/
|
|
105
105
|
updateMessage(messageId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array): Promise<void>;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* Unsubscribes from the Thread module main events.
|
|
107
|
+
* Subscribe for the Thread events on the given subscription query.
|
|
108
|
+
*
|
|
109
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
110
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
112
111
|
*/
|
|
113
|
-
|
|
112
|
+
subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
|
|
114
113
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {string}
|
|
114
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
115
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
117
116
|
*/
|
|
118
|
-
|
|
117
|
+
unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
|
|
119
118
|
/**
|
|
120
|
-
*
|
|
121
|
-
* @param {
|
|
119
|
+
* Generate subscription Query for the Thread events.
|
|
120
|
+
* @param {EventType} eventType type of event which you listen for
|
|
121
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
122
|
+
* @param {string} selectorId ID of the selector
|
|
122
123
|
*/
|
|
123
|
-
|
|
124
|
+
buildSubscriptionQuery(eventType: ThreadEventType, selectorType: ThreadEventSelectorType, selectorId: string): Promise<string>;
|
|
124
125
|
}
|
package/service/ThreadApi.js
CHANGED
|
@@ -154,33 +154,58 @@ class ThreadApi extends BaseApi_1.BaseApi {
|
|
|
154
154
|
data,
|
|
155
155
|
]);
|
|
156
156
|
}
|
|
157
|
+
// /**
|
|
158
|
+
// * Subscribes for the Thread module main events.
|
|
159
|
+
// */
|
|
160
|
+
// async subscribeForThreadEvents(): Promise<void> {
|
|
161
|
+
// return this.native.subscribeForThreadEvents(this.servicePtr, []);
|
|
162
|
+
// }
|
|
163
|
+
// /**
|
|
164
|
+
// * Unsubscribes from the Thread module main events.
|
|
165
|
+
// */
|
|
166
|
+
// async unsubscribeFromThreadEvents(): Promise<void> {
|
|
167
|
+
// return this.native.unsubscribeFromThreadEvents(this.servicePtr, []);
|
|
168
|
+
// }
|
|
169
|
+
// /**
|
|
170
|
+
// * Subscribes for events in given Thread.
|
|
171
|
+
// * @param {string} threadId ID of the Thread to subscribe
|
|
172
|
+
// */
|
|
173
|
+
// async subscribeForMessageEvents(threadId: string): Promise<void> {
|
|
174
|
+
// return this.native.subscribeForMessageEvents(this.servicePtr, [threadId]);
|
|
175
|
+
// }
|
|
176
|
+
// /**
|
|
177
|
+
// * Unsubscribes from events in given Thread.
|
|
178
|
+
// * @param {string} threadId ID of the Thread to unsubscribe
|
|
179
|
+
// */
|
|
180
|
+
// async unsubscribeFromMessageEvents(threadId: string): Promise<void> {
|
|
181
|
+
// return this.native.unsubscribeFromMessageEvents(this.servicePtr, [
|
|
182
|
+
// threadId,
|
|
183
|
+
// ]);
|
|
184
|
+
// }
|
|
157
185
|
/**
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Unsubscribes from the Thread module main events.
|
|
186
|
+
* Subscribe for the Thread events on the given subscription query.
|
|
187
|
+
*
|
|
188
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
189
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
165
190
|
*/
|
|
166
|
-
async
|
|
167
|
-
return this.native.
|
|
191
|
+
async subscribeFor(subscriptionQueries) {
|
|
192
|
+
return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
|
|
168
193
|
}
|
|
169
194
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @param {string}
|
|
195
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
196
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
172
197
|
*/
|
|
173
|
-
async
|
|
174
|
-
return this.native.
|
|
198
|
+
async unsubscribeFrom(subscriptionIds) {
|
|
199
|
+
return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
|
|
175
200
|
}
|
|
176
201
|
/**
|
|
177
|
-
*
|
|
178
|
-
* @param {
|
|
202
|
+
* Generate subscription Query for the Thread events.
|
|
203
|
+
* @param {EventType} eventType type of event which you listen for
|
|
204
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
205
|
+
* @param {string} selectorId ID of the selector
|
|
179
206
|
*/
|
|
180
|
-
async
|
|
181
|
-
return this.native.
|
|
182
|
-
threadId,
|
|
183
|
-
]);
|
|
207
|
+
async buildSubscriptionQuery(eventType, selectorType, selectorId) {
|
|
208
|
+
return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
|
|
184
209
|
}
|
|
185
210
|
}
|
|
186
211
|
exports.ThreadApi = ThreadApi;
|
package/service/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ import { Connection } from "./Connection";
|
|
|
8
8
|
import { EventQueue } from "./EventQueue";
|
|
9
9
|
import { BaseApi } from "./BaseApi";
|
|
10
10
|
import { ExtKey } from "./ExtKey";
|
|
11
|
-
|
|
11
|
+
import { EventApi } from "./EventApi";
|
|
12
|
+
export { EndpointFactory, ThreadApi, StoreApi, InboxApi, KvdbApi, CryptoApi, Connection, EventQueue, BaseApi, ExtKey, EventApi };
|
package/service/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtKey = exports.BaseApi = exports.EventQueue = exports.Connection = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.StoreApi = exports.ThreadApi = exports.EndpointFactory = void 0;
|
|
3
|
+
exports.EventApi = exports.ExtKey = exports.BaseApi = exports.EventQueue = exports.Connection = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.StoreApi = exports.ThreadApi = exports.EndpointFactory = void 0;
|
|
4
4
|
const EndpointFactory_1 = require("./EndpointFactory");
|
|
5
5
|
Object.defineProperty(exports, "EndpointFactory", { enumerable: true, get: function () { return EndpointFactory_1.EndpointFactory; } });
|
|
6
6
|
const ThreadApi_1 = require("./ThreadApi");
|
|
@@ -21,3 +21,5 @@ const BaseApi_1 = require("./BaseApi");
|
|
|
21
21
|
Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return BaseApi_1.BaseApi; } });
|
|
22
22
|
const ExtKey_1 = require("./ExtKey");
|
|
23
23
|
Object.defineProperty(exports, "ExtKey", { enumerable: true, get: function () { return ExtKey_1.ExtKey; } });
|
|
24
|
+
const EventApi_1 = require("./EventApi");
|
|
25
|
+
Object.defineProperty(exports, "EventApi", { enumerable: true, get: function () { return EventApi_1.EventApi; } });
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export declare const MOCK_INBOX_CREATED_EVENT: {
|
|
2
|
-
readonly type: "inboxCreated";
|
|
3
|
-
readonly data: {};
|
|
4
|
-
readonly channel: "inbox";
|
|
5
|
-
readonly connectionId: 1;
|
|
6
|
-
};
|
|
7
|
-
export declare const MOCK_INBOX_ENTRY_DELETED_EVENT: (inboxID: string) => {
|
|
8
|
-
readonly type: "inboxEntryDeleted";
|
|
9
|
-
readonly data: {};
|
|
10
|
-
readonly channel: `inbox/${string}/entries`;
|
|
11
|
-
readonly connectionId: 1;
|
|
12
|
-
};
|
|
13
|
-
export declare const MOCK_STORE_CREATED_EVENT: {
|
|
14
|
-
readonly type: "storeUpdated";
|
|
15
|
-
readonly data: {};
|
|
16
|
-
readonly channel: "store";
|
|
17
|
-
readonly connectionId: 1;
|
|
18
|
-
};
|
|
19
|
-
export declare const MOCK_STORE_FILE_DELETED_EVENT: (storeID: string) => {
|
|
20
|
-
readonly type: "storeFileCreated";
|
|
21
|
-
readonly data: {};
|
|
22
|
-
readonly channel: `store/${string}/files`;
|
|
23
|
-
readonly connectionId: 1;
|
|
24
|
-
};
|
|
25
|
-
export declare const MOCK_THREAD_CREATED_EVENT: {
|
|
26
|
-
readonly type: "threadUpdated";
|
|
27
|
-
readonly data: {};
|
|
28
|
-
readonly channel: "thread";
|
|
29
|
-
readonly connectionId: 1;
|
|
30
|
-
};
|
|
31
|
-
export declare const MOCK_THREAD_MESSAGE_DELETED_EVENT: (threadID: string) => {
|
|
32
|
-
readonly type: "threadNewMessage";
|
|
33
|
-
readonly data: {};
|
|
34
|
-
readonly channel: `thread/${string}/messages`;
|
|
35
|
-
readonly connectionId: 1;
|
|
36
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MOCK_THREAD_MESSAGE_DELETED_EVENT = exports.MOCK_THREAD_CREATED_EVENT = exports.MOCK_STORE_FILE_DELETED_EVENT = exports.MOCK_STORE_CREATED_EVENT = exports.MOCK_INBOX_ENTRY_DELETED_EVENT = exports.MOCK_INBOX_CREATED_EVENT = void 0;
|
|
4
|
-
exports.MOCK_INBOX_CREATED_EVENT = {
|
|
5
|
-
type: 'inboxCreated',
|
|
6
|
-
data: {},
|
|
7
|
-
channel: `inbox`,
|
|
8
|
-
connectionId: 1
|
|
9
|
-
};
|
|
10
|
-
const MOCK_INBOX_ENTRY_DELETED_EVENT = (inboxID) => ({
|
|
11
|
-
type: 'inboxEntryDeleted',
|
|
12
|
-
data: {},
|
|
13
|
-
channel: `inbox/${inboxID}/entries`,
|
|
14
|
-
connectionId: 1
|
|
15
|
-
});
|
|
16
|
-
exports.MOCK_INBOX_ENTRY_DELETED_EVENT = MOCK_INBOX_ENTRY_DELETED_EVENT;
|
|
17
|
-
exports.MOCK_STORE_CREATED_EVENT = {
|
|
18
|
-
type: 'storeUpdated',
|
|
19
|
-
data: {},
|
|
20
|
-
channel: `store`,
|
|
21
|
-
connectionId: 1
|
|
22
|
-
};
|
|
23
|
-
const MOCK_STORE_FILE_DELETED_EVENT = (storeID) => ({
|
|
24
|
-
type: 'storeFileCreated',
|
|
25
|
-
data: {},
|
|
26
|
-
channel: `store/${storeID}/files`,
|
|
27
|
-
connectionId: 1
|
|
28
|
-
});
|
|
29
|
-
exports.MOCK_STORE_FILE_DELETED_EVENT = MOCK_STORE_FILE_DELETED_EVENT;
|
|
30
|
-
exports.MOCK_THREAD_CREATED_EVENT = {
|
|
31
|
-
type: 'threadUpdated',
|
|
32
|
-
data: {},
|
|
33
|
-
channel: `thread`,
|
|
34
|
-
connectionId: 1
|
|
35
|
-
};
|
|
36
|
-
const MOCK_THREAD_MESSAGE_DELETED_EVENT = (threadID) => ({
|
|
37
|
-
type: 'threadNewMessage',
|
|
38
|
-
data: {},
|
|
39
|
-
channel: `thread/${threadID}/messages`,
|
|
40
|
-
connectionId: 1
|
|
41
|
-
});
|
|
42
|
-
exports.MOCK_THREAD_MESSAGE_DELETED_EVENT = MOCK_THREAD_MESSAGE_DELETED_EVENT;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MockEventQueue } from "./mockEventQueue";
|
|
2
|
-
import { Channel } from "../../events";
|
|
3
|
-
export declare abstract class MockContainerSubscriber {
|
|
4
|
-
private queue;
|
|
5
|
-
abstract containerChannel: Channel;
|
|
6
|
-
abstract containerElementChannel(id: string): Channel;
|
|
7
|
-
protected constructor(queue: MockEventQueue);
|
|
8
|
-
protected subscribeForContainerEvents(): Promise<void>;
|
|
9
|
-
protected unsubscribeFromContainerEvents(): Promise<void>;
|
|
10
|
-
protected subscribeForContainerItemEvents(id: string): Promise<void>;
|
|
11
|
-
protected unsubscribeFromContainerItemEvents(id: string): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockContainerSubscriber = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
class MockContainerSubscriber {
|
|
6
|
-
queue;
|
|
7
|
-
constructor(queue) {
|
|
8
|
-
this.queue = queue;
|
|
9
|
-
}
|
|
10
|
-
subscribeForContainerEvents() {
|
|
11
|
-
return (0, utils_1.utils)(() => {
|
|
12
|
-
this.queue.registeredChannels.add(this.containerChannel);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
unsubscribeFromContainerEvents() {
|
|
16
|
-
return (0, utils_1.utils)(() => this.queue.registeredChannels.delete(this.containerChannel));
|
|
17
|
-
}
|
|
18
|
-
subscribeForContainerItemEvents(id) {
|
|
19
|
-
return (0, utils_1.utils)(() => this.queue.registeredChannels.add(this.containerElementChannel(id)));
|
|
20
|
-
}
|
|
21
|
-
unsubscribeFromContainerItemEvents(id) {
|
|
22
|
-
return (0, utils_1.utils)(() => this.queue.registeredChannels.delete(this.containerElementChannel(id)));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.MockContainerSubscriber = MockContainerSubscriber;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { MockContainerSubscriber } from './mockContainerSubscriber';
|
|
2
|
-
import { MockEventQueue } from "./mockEventQueue";
|
|
3
|
-
import { Channel, SubscriberForInboxEvents, SubscriberForStoreEvents, SubscriberForThreadsEvents } from "../../events";
|
|
4
|
-
export declare class MockThreadEventApi extends MockContainerSubscriber implements SubscriberForThreadsEvents {
|
|
5
|
-
containerChannel: Channel;
|
|
6
|
-
containerElementChannel(id: string): Channel;
|
|
7
|
-
constructor(queue: MockEventQueue);
|
|
8
|
-
subscribeForThreadEvents(): Promise<void>;
|
|
9
|
-
unsubscribeFromThreadEvents(): Promise<void>;
|
|
10
|
-
subscribeForMessageEvents(threadId: string): Promise<void>;
|
|
11
|
-
unsubscribeFromMessageEvents(threadId: string): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export declare class MockStoreEventApi extends MockContainerSubscriber implements SubscriberForStoreEvents {
|
|
14
|
-
containerChannel: Channel;
|
|
15
|
-
containerElementChannel(id: string): Channel;
|
|
16
|
-
constructor(queue: MockEventQueue);
|
|
17
|
-
subscribeForStoreEvents(): Promise<void>;
|
|
18
|
-
unsubscribeFromStoreEvents(): Promise<void>;
|
|
19
|
-
subscribeForFileEvents(storeId: string): Promise<void>;
|
|
20
|
-
unsubscribeFromFileEvents(storeId: string): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export declare class MockInboxEventApi extends MockContainerSubscriber implements SubscriberForInboxEvents {
|
|
23
|
-
containerChannel: Channel;
|
|
24
|
-
containerElementChannel(id: string): Channel;
|
|
25
|
-
constructor(queue: MockEventQueue);
|
|
26
|
-
subscribeForInboxEvents(): Promise<void>;
|
|
27
|
-
unsubscribeFromInboxEvents(): Promise<void>;
|
|
28
|
-
subscribeForEntryEvents(storeId: string): Promise<void>;
|
|
29
|
-
unsubscribeFromEntryEvents(storeId: string): Promise<void>;
|
|
30
|
-
}
|