@simplito/privmx-webendpoint 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Types.d.ts +98 -2
- 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 +6 -7
- package/api/StoreApiNative.js +6 -9
- package/api/ThreadApiNative.d.ts +4 -5
- package/api/ThreadApiNative.js +6 -9
- package/assets/driver-web-context.js +1 -1
- package/assets/e2ee-worker.js +1 -0
- package/assets/endpoint-wasm-module.js +2 -19
- package/assets/endpoint-wasm-module.wasm +0 -0
- package/assets/privmx-endpoint-web.js +2 -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 +33 -25
- package/service/KvdbApi.js +65 -31
- package/service/StoreApi.d.ts +18 -15
- package/service/StoreApi.js +48 -20
- 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);
|
|
@@ -18,28 +18,28 @@ export declare class KvdbApi extends BaseApi {
|
|
|
18
18
|
* Creates a new KVDB in given Context.
|
|
19
19
|
*
|
|
20
20
|
* @param {string} contextId ID of the Context to create the KVDB in
|
|
21
|
-
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created
|
|
21
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB
|
|
22
22
|
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
23
|
-
* the created
|
|
23
|
+
* the created KVDB
|
|
24
24
|
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
25
25
|
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
26
|
-
* @param {ContainerPolicy} policies
|
|
27
|
-
* @returns {string} ID of the created
|
|
26
|
+
* @param {ContainerPolicy} policies KVDB's policies
|
|
27
|
+
* @returns {string} ID of the created KVDB
|
|
28
28
|
*/
|
|
29
29
|
createKvdb(contextId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, policies?: ContainerPolicy): Promise<string>;
|
|
30
30
|
/**
|
|
31
|
-
* Updates an existing
|
|
31
|
+
* Updates an existing KVDB.
|
|
32
32
|
*
|
|
33
33
|
* @param {string} kvdbId ID of the KVDB to update
|
|
34
|
-
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created
|
|
34
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB
|
|
35
35
|
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
36
|
-
* the created
|
|
36
|
+
* the created KVDB
|
|
37
37
|
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
38
38
|
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
39
|
-
* @param {number} version current version of the updated
|
|
39
|
+
* @param {number} version current version of the updated KVDB
|
|
40
40
|
* @param {boolean} force force update (without checking version)
|
|
41
|
-
* @param {boolean} forceGenerateNewKey force to regenerate a key for the
|
|
42
|
-
* @param {ContainerPolicy} policies
|
|
41
|
+
* @param {boolean} forceGenerateNewKey force to regenerate a key for the KVDB
|
|
42
|
+
* @param {ContainerPolicy} policies KVDB's policies
|
|
43
43
|
*/
|
|
44
44
|
updateKvdb(kvdbId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, version: number, force: boolean, forceGenerateNewKey: boolean, policies?: ContainerPolicy): Promise<void>;
|
|
45
45
|
/**
|
|
@@ -52,7 +52,7 @@ export declare class KvdbApi extends BaseApi {
|
|
|
52
52
|
* Gets a KVDB by given KVDB ID.
|
|
53
53
|
*
|
|
54
54
|
* @param {string} kvdbId ID of KVDB to get
|
|
55
|
-
* @returns {Kvdb} containing info about the
|
|
55
|
+
* @returns {Kvdb} containing info about the KVDB
|
|
56
56
|
*/
|
|
57
57
|
getKvdb(kvdbId: string): Promise<Kvdb>;
|
|
58
58
|
/**
|
|
@@ -80,7 +80,7 @@ export declare class KvdbApi extends BaseApi {
|
|
|
80
80
|
*/
|
|
81
81
|
hasEntry(kvdbId: string, key: string): Promise<boolean>;
|
|
82
82
|
/**
|
|
83
|
-
* Gets a list of KVDB entries keys from a
|
|
83
|
+
* Gets a list of KVDB entries keys from a KVDB.
|
|
84
84
|
*
|
|
85
85
|
* @param {string} kvdbId ID of the KVDB to list KVDB entries from
|
|
86
86
|
* @param {PagingQuery} pagingQuery with list query parameters
|
|
@@ -88,7 +88,7 @@ export declare class KvdbApi extends BaseApi {
|
|
|
88
88
|
*/
|
|
89
89
|
listEntriesKeys(kvdbId: string, pagingQuery: PagingQuery): Promise<PagingList<string>>;
|
|
90
90
|
/**
|
|
91
|
-
* Gets a list of KVDB entries from a
|
|
91
|
+
* Gets a list of KVDB entries from a KVDB.
|
|
92
92
|
*
|
|
93
93
|
* @param {string} kvdbId ID of the KVDB to list KVDB entries from
|
|
94
94
|
* @param {PagingQuery} pagingQuery with list query parameters
|
|
@@ -96,7 +96,7 @@ export declare class KvdbApi extends BaseApi {
|
|
|
96
96
|
*/
|
|
97
97
|
listEntries(kvdbId: string, pagingQuery: PagingQuery): Promise<PagingList<KvdbEntry>>;
|
|
98
98
|
/**
|
|
99
|
-
* Sets a KVDB entry in the given
|
|
99
|
+
* Sets a KVDB entry in the given KVDB.
|
|
100
100
|
* @param {string} kvdbId ID of the KVDB to set the entry to
|
|
101
101
|
* @param {string} key KVDB entry key
|
|
102
102
|
* @param {Uint8Array} publicMeta public KVDB entry metadata
|
|
@@ -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
|
@@ -22,13 +22,13 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
22
22
|
* Creates a new KVDB in given Context.
|
|
23
23
|
*
|
|
24
24
|
* @param {string} contextId ID of the Context to create the KVDB in
|
|
25
|
-
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created
|
|
25
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB
|
|
26
26
|
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
27
|
-
* the created
|
|
27
|
+
* the created KVDB
|
|
28
28
|
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
29
29
|
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
30
|
-
* @param {ContainerPolicy} policies
|
|
31
|
-
* @returns {string} ID of the created
|
|
30
|
+
* @param {ContainerPolicy} policies KVDB's policies
|
|
31
|
+
* @returns {string} ID of the created KVDB
|
|
32
32
|
*/
|
|
33
33
|
async createKvdb(contextId, users, managers, publicMeta, privateMeta, policies) {
|
|
34
34
|
return this.native.createKvdb(this.servicePtr, [
|
|
@@ -41,18 +41,18 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
41
41
|
]);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Updates an existing
|
|
44
|
+
* Updates an existing KVDB.
|
|
45
45
|
*
|
|
46
46
|
* @param {string} kvdbId ID of the KVDB to update
|
|
47
|
-
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created
|
|
47
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB
|
|
48
48
|
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
49
|
-
* the created
|
|
49
|
+
* the created KVDB
|
|
50
50
|
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
51
51
|
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
52
|
-
* @param {number} version current version of the updated
|
|
52
|
+
* @param {number} version current version of the updated KVDB
|
|
53
53
|
* @param {boolean} force force update (without checking version)
|
|
54
|
-
* @param {boolean} forceGenerateNewKey force to regenerate a key for the
|
|
55
|
-
* @param {ContainerPolicy} policies
|
|
54
|
+
* @param {boolean} forceGenerateNewKey force to regenerate a key for the KVDB
|
|
55
|
+
* @param {ContainerPolicy} policies KVDB's policies
|
|
56
56
|
*/
|
|
57
57
|
async updateKvdb(kvdbId, users, managers, publicMeta, privateMeta, version, force, forceGenerateNewKey, policies) {
|
|
58
58
|
return this.native.updateKvdb(this.servicePtr, [
|
|
@@ -79,7 +79,7 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
79
79
|
* Gets a KVDB by given KVDB ID.
|
|
80
80
|
*
|
|
81
81
|
* @param {string} kvdbId ID of KVDB to get
|
|
82
|
-
* @returns {Kvdb} containing info about the
|
|
82
|
+
* @returns {Kvdb} containing info about the KVDB
|
|
83
83
|
*/
|
|
84
84
|
async getKvdb(kvdbId) {
|
|
85
85
|
return this.native.getKvdb(this.servicePtr, [kvdbId]);
|
|
@@ -115,7 +115,7 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
115
115
|
return this.native.hasEntry(this.servicePtr, [kvdbId, key]);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* Gets a list of KVDB entries keys from a
|
|
118
|
+
* Gets a list of KVDB entries keys from a KVDB.
|
|
119
119
|
*
|
|
120
120
|
* @param {string} kvdbId ID of the KVDB to list KVDB entries from
|
|
121
121
|
* @param {PagingQuery} pagingQuery with list query parameters
|
|
@@ -125,7 +125,7 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
125
125
|
return this.native.listEntriesKeys(this.servicePtr, [kvdbId, pagingQuery]);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
* Gets a list of KVDB entries from a
|
|
128
|
+
* Gets a list of KVDB entries from a KVDB.
|
|
129
129
|
*
|
|
130
130
|
* @param {string} kvdbId ID of the KVDB to list KVDB entries from
|
|
131
131
|
* @param {PagingQuery} pagingQuery with list query parameters
|
|
@@ -135,7 +135,7 @@ class KvdbApi extends BaseApi_1.BaseApi {
|
|
|
135
135
|
return this.native.listEntries(this.servicePtr, [kvdbId, pagingQuery]);
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
|
-
* Sets a KVDB entry in the given
|
|
138
|
+
* Sets a KVDB entry in the given KVDB.
|
|
139
139
|
* @param {string} kvdbId ID of the KVDB to set the entry to
|
|
140
140
|
* @param {string} key KVDB entry key
|
|
141
141
|
* @param {Uint8Array} publicMeta public KVDB entry metadata
|
|
@@ -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,22 @@ export declare class StoreApi extends BaseApi {
|
|
|
150
152
|
*/
|
|
151
153
|
closeFile(fileHandle: number): Promise<string>;
|
|
152
154
|
/**
|
|
153
|
-
*
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
* Unsubscribes from the Store module main events.
|
|
155
|
+
* Subscribe for the Store events on the given subscription query.
|
|
156
|
+
*
|
|
157
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
158
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
158
159
|
*/
|
|
159
|
-
|
|
160
|
+
subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
|
|
160
161
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param {string}
|
|
162
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
163
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
163
164
|
*/
|
|
164
|
-
|
|
165
|
+
unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
|
|
165
166
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param {
|
|
167
|
+
* Generate subscription Query for the Store events.
|
|
168
|
+
* @param {EventType} eventType type of event which you listen for
|
|
169
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
170
|
+
* @param {string} selectorId ID of the selector
|
|
168
171
|
*/
|
|
169
|
-
|
|
172
|
+
buildSubscriptionQuery(eventType: StoreEventType, selectorType: StoreEventSelectorType, selectorId: string): Promise<string>;
|
|
170
173
|
}
|
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.
|
|
@@ -216,31 +219,56 @@ class StoreApi extends BaseApi_1.BaseApi {
|
|
|
216
219
|
async closeFile(fileHandle) {
|
|
217
220
|
return this.native.closeFile(this.servicePtr, [fileHandle]);
|
|
218
221
|
}
|
|
222
|
+
// /**
|
|
223
|
+
// * Subscribes for the Store module main events.
|
|
224
|
+
// */
|
|
225
|
+
// async subscribeForStoreEvents(): Promise<void> {
|
|
226
|
+
// return this.native.subscribeForStoreEvents(this.servicePtr, []);
|
|
227
|
+
// }
|
|
228
|
+
// /**
|
|
229
|
+
// * Unsubscribes from the Store module main events.
|
|
230
|
+
// */
|
|
231
|
+
// async unsubscribeFromStoreEvents(): Promise<void> {
|
|
232
|
+
// return this.native.unsubscribeFromStoreEvents(this.servicePtr, []);
|
|
233
|
+
// }
|
|
234
|
+
// /**
|
|
235
|
+
// * Subscribes for events in given Store.
|
|
236
|
+
// * @param {string} storeId ID of the Store to subscribe
|
|
237
|
+
// */
|
|
238
|
+
// async subscribeForFileEvents(storeId: string): Promise<void> {
|
|
239
|
+
// return this.native.subscribeForFileEvents(this.servicePtr, [storeId]);
|
|
240
|
+
// }
|
|
241
|
+
// /**
|
|
242
|
+
// * Unsubscribes from events in given Store.
|
|
243
|
+
// * @param {string} storeId ID of the Store to unsubscribe
|
|
244
|
+
// */
|
|
245
|
+
// async unsubscribeFromFileEvents(storeId: string): Promise<void> {
|
|
246
|
+
// return this.native.unsubscribeFromFileEvents(this.servicePtr, [storeId]);
|
|
247
|
+
// }
|
|
219
248
|
/**
|
|
220
|
-
*
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Unsubscribes from the Store module main events.
|
|
249
|
+
* Subscribe for the Store events on the given subscription query.
|
|
250
|
+
*
|
|
251
|
+
* @param {string[]} subscriptionQueries list of queries
|
|
252
|
+
* @return list of subscriptionIds in maching order to subscriptionQueries
|
|
227
253
|
*/
|
|
228
|
-
async
|
|
229
|
-
return this.native.
|
|
254
|
+
async subscribeFor(subscriptionQueries) {
|
|
255
|
+
return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
|
|
230
256
|
}
|
|
231
257
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param {string}
|
|
258
|
+
* Unsubscribe from events for the given subscriptionId.
|
|
259
|
+
* @param {string[]} subscriptionIds list of subscriptionId
|
|
234
260
|
*/
|
|
235
|
-
async
|
|
236
|
-
return this.native.
|
|
261
|
+
async unsubscribeFrom(subscriptionIds) {
|
|
262
|
+
return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
|
|
237
263
|
}
|
|
238
264
|
/**
|
|
239
|
-
*
|
|
240
|
-
* @param {
|
|
265
|
+
* Generate subscription Query for the Store events.
|
|
266
|
+
* @param {EventType} eventType type of event which you listen for
|
|
267
|
+
* @param {EventSelectorType} selectorType scope on which you listen for events
|
|
268
|
+
* @param {string} selectorId ID of the selector
|
|
241
269
|
*/
|
|
242
|
-
async
|
|
243
|
-
return this.native.
|
|
270
|
+
async buildSubscriptionQuery(eventType, selectorType, selectorId) {
|
|
271
|
+
return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
|
|
244
272
|
}
|
|
245
273
|
}
|
|
246
274
|
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
|
-
};
|