core-3nweb-client-lib 0.25.6 → 0.26.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/README.md +2 -2
- package/build/api-defs/files.d.ts +23 -20
- package/build/core/asmail/config/common.js +2 -2
- package/build/core/asmail/delivery/index.js +4 -3
- package/build/core/asmail/delivery/msg.js +5 -4
- package/build/core/asmail/delivery/per-recipient-wip.js +2 -2
- package/build/core/asmail/inbox/attachments/fs.js +6 -0
- package/build/core/asmail/inbox/cached-msgs.js +2 -2
- package/build/core/asmail/inbox/inbox-events.js +2 -1
- package/build/core/asmail/inbox/index.js +2 -2
- package/build/core/asmail/inbox/msg-downloader.js +2 -2
- package/build/core/asmail/inbox/msg-indexing.js +3 -3
- package/build/core/asmail/inbox/msg-on-disk.js +2 -2
- package/build/core/asmail/keyring/keyring-storage.js +2 -2
- package/build/core/asmail/sending-params/own-params.js +2 -2
- package/build/core/asmail/sending-params/params-from-others.js +2 -2
- package/build/core/id-manager.js +2 -2
- package/build/core/sign-in.d.ts +5 -4
- package/build/core/sign-in.js +9 -11
- package/build/core/sign-up.d.ts +1 -0
- package/build/core/sign-up.js +7 -3
- package/build/core/storage/common/json-saving.d.ts +21 -0
- package/build/core/storage/common/json-saving.js +82 -0
- package/build/core/storage/common/obj-info-file.d.ts +43 -0
- package/build/core/storage/common/obj-info-file.js +119 -3
- package/build/core/storage/index.js +1 -1
- package/build/core/storage/local/obj-files-gc.js +8 -6
- package/build/core/storage/local/obj-files.d.ts +3 -3
- package/build/core/storage/local/obj-files.js +9 -9
- package/build/core/storage/local/obj-status.d.ts +9 -25
- package/build/core/storage/local/obj-status.js +28 -110
- package/build/core/storage/local/storage.d.ts +8 -1
- package/build/core/storage/local/storage.js +10 -2
- package/build/core/storage/synced/downloader.js +6 -5
- package/build/core/storage/synced/obj-files-gc.d.ts +1 -0
- package/build/core/storage/synced/obj-files-gc.js +44 -5
- package/build/core/storage/synced/obj-files.d.ts +13 -20
- package/build/core/storage/synced/obj-files.js +70 -48
- package/build/core/storage/synced/obj-status.d.ts +74 -15
- package/build/core/storage/synced/obj-status.js +291 -107
- package/build/core/storage/synced/remote-events.js +32 -26
- package/build/core/storage/synced/storage.d.ts +11 -1
- package/build/core/storage/synced/storage.js +28 -3
- package/build/core/storage/synced/upsyncer.d.ts +8 -7
- package/build/core/storage/synced/upsyncer.js +211 -163
- package/build/ipc-via-protobuf/asmail-cap.js +15 -32
- package/build/ipc-via-protobuf/connector-clients-side.js +2 -2
- package/build/ipc-via-protobuf/file.js +22 -14
- package/build/ipc-via-protobuf/fs.js +31 -33
- package/build/ipc-via-protobuf/startup-cap.js +5 -5
- package/build/lib-client/3nstorage/exceptions.d.ts +9 -8
- package/build/lib-client/3nstorage/exceptions.js +18 -9
- package/build/lib-client/3nstorage/service.js +10 -6
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +18 -4
- package/build/lib-client/3nstorage/xsp-fs/common.js +6 -1
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +3 -3
- package/build/lib-client/3nstorage/xsp-fs/file.js +4 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +27 -13
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +11 -6
- package/build/lib-client/3nstorage/xsp-fs/fs.js +189 -58
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +4 -0
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +51 -24
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +2 -2
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +2 -2
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +3 -3
- package/build/lib-client/cryptor/cryptor-in-worker.js +4 -4
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-wasm.js +2 -2
- package/build/lib-client/files.js +2 -0
- package/build/lib-client/fs-collection.js +3 -2
- package/build/lib-client/logging/log-to-file.js +4 -4
- package/build/lib-client/objs-on-disk/file-writing-proc.js +2 -2
- package/build/lib-client/objs-on-disk/obj-folders.js +2 -2
- package/build/lib-client/request-utils.js +2 -2
- package/build/lib-client/server-events.js +4 -3
- package/build/lib-client/ws-utils.js +2 -2
- package/build/lib-common/async-fs-node.js +4 -3
- package/build/lib-common/byte-streaming/wrapping.js +17 -17
- package/build/lib-common/exceptions/file.js +6 -1
- package/build/lib-common/ipc/generic-ipc.js +2 -2
- package/build/lib-common/json-utils.js +2 -1
- package/build/lib-common/objs-on-disk/obj-file.js +4 -3
- package/build/lib-common/objs-on-disk/utils.js +2 -2
- package/build/lib-common/processes/deferred.d.ts +6 -0
- package/build/lib-common/processes/deferred.js +30 -0
- package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
- package/build/lib-common/processes/labelled-exec-pools.js +141 -0
- package/build/lib-common/processes/pressure.d.ts +7 -0
- package/build/lib-common/processes/pressure.js +56 -0
- package/build/lib-common/processes/sleep.d.ts +1 -0
- package/build/lib-common/processes/sleep.js +26 -0
- package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
- package/build/lib-common/{processes.js → processes/synced.js} +187 -204
- package/build/lib-common/processes/timeout.d.ts +1 -0
- package/build/lib-common/processes/timeout.js +51 -0
- package/build/lib-common/service-api/3nstorage/owner.d.ts +5 -4
- package/build/lib-common/service-api/3nstorage/owner.js +3 -2
- package/build/lib-common/utils-for-observables.d.ts +15 -1
- package/build/lib-common/utils-for-observables.js +68 -17
- package/build/protos/asmail.proto.js +404 -78
- package/build/protos/file.proto.js +370 -44
- package/build/protos/fs.proto.js +404 -78
- package/package.json +4 -4
- package/protos/file.proto +10 -2
- package/protos/fs.proto +2 -2
- package/build/core/storage/synced/upsync-status.d.ts +0 -41
- package/build/core/storage/synced/upsync-status.js +0 -158
|
@@ -21,7 +21,7 @@ exports.NodeInFS = void 0;
|
|
|
21
21
|
* Everything in this module is assumed to be inside of a file system
|
|
22
22
|
* reliance set.
|
|
23
23
|
*/
|
|
24
|
-
const
|
|
24
|
+
const synced_1 = require("../../../lib-common/processes/synced");
|
|
25
25
|
const file_1 = require("../../../lib-common/exceptions/file");
|
|
26
26
|
const error_1 = require("../../../lib-common/exceptions/error");
|
|
27
27
|
const rxjs_1 = require("rxjs");
|
|
@@ -96,7 +96,7 @@ class NodeInFS {
|
|
|
96
96
|
getAttrs() {
|
|
97
97
|
return this.attrs;
|
|
98
98
|
}
|
|
99
|
-
processRemoteEvent(event) {
|
|
99
|
+
async processRemoteEvent(event) {
|
|
100
100
|
this.bufferRemoteEvent(event);
|
|
101
101
|
return this.doChange(true, async () => {
|
|
102
102
|
const event = this.getBufferedEvent();
|
|
@@ -104,6 +104,10 @@ class NodeInFS {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
if (event.type === 'remote-change') {
|
|
107
|
+
// TODO
|
|
108
|
+
// uploader should show if there is process for this obj uploads with version
|
|
109
|
+
// in the event, and if so, wait for completion of that process to either ignore
|
|
110
|
+
// remote event, or to set conflict, or whatever
|
|
107
111
|
// XXX should we use here synced storage methods here?
|
|
108
112
|
// This method is called only in synced storage.
|
|
109
113
|
// XXX detect if there is a conflict
|
|
@@ -127,6 +131,9 @@ class NodeInFS {
|
|
|
127
131
|
this.remoteEvents = [];
|
|
128
132
|
}
|
|
129
133
|
this.remoteEvents.push(event);
|
|
134
|
+
if (this.remoteEvents.length > 1) {
|
|
135
|
+
// XXX attempt to compress events
|
|
136
|
+
}
|
|
130
137
|
}
|
|
131
138
|
getBufferedEvent() {
|
|
132
139
|
if (!this.remoteEvents) {
|
|
@@ -141,13 +148,27 @@ class NodeInFS {
|
|
|
141
148
|
localDelete() {
|
|
142
149
|
return this.doChange(true, () => this.delete());
|
|
143
150
|
}
|
|
151
|
+
broadcastUpSyncEvent(task) {
|
|
152
|
+
if (task.type === 'upload') {
|
|
153
|
+
this.broadcastEvent({
|
|
154
|
+
type: 'sync-upload',
|
|
155
|
+
path: this.name,
|
|
156
|
+
current: this.version,
|
|
157
|
+
uploaded: task.version
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
144
161
|
/**
|
|
145
162
|
* This non-synchronized method deletes object from storage, and detaches
|
|
146
163
|
* this node from storage. Make sure to call it inside access synchronization
|
|
147
164
|
* construct.
|
|
148
165
|
*/
|
|
149
166
|
async delete(remoteEvent) {
|
|
150
|
-
if (
|
|
167
|
+
if (remoteEvent) {
|
|
168
|
+
// XXX
|
|
169
|
+
throw Error(`Removal from remote side is not implemented, yet.`);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
151
172
|
await this.storage.removeObj(this.objId);
|
|
152
173
|
}
|
|
153
174
|
this.storage.nodes.delete(this);
|
|
@@ -173,34 +194,32 @@ class NodeInFS {
|
|
|
173
194
|
*/
|
|
174
195
|
async doChange(awaitPrevChange, change) {
|
|
175
196
|
if (!this.writeProc) {
|
|
176
|
-
this.writeProc = new
|
|
197
|
+
this.writeProc = new synced_1.SingleProc();
|
|
177
198
|
}
|
|
178
199
|
if (!awaitPrevChange && this.writeProc.isProcessing()) {
|
|
179
200
|
throw file_1.makeFileException(file_1.Code.concurrentUpdate, this.name + ` type ${this.type}`);
|
|
180
201
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
throw file_1.makeFileException(file_1.Code.notFound, this.name);
|
|
185
|
-
}
|
|
186
|
-
return change();
|
|
187
|
-
});
|
|
188
|
-
return res;
|
|
189
|
-
}
|
|
190
|
-
catch (exc) {
|
|
191
|
-
if (!exc.runtimeException) {
|
|
192
|
-
throw error_1.errWithCause(exc, `Cannot save changes to ${this.type} ${this.name}, version ${this.version}`);
|
|
202
|
+
const res = await this.writeProc.startOrChain(() => {
|
|
203
|
+
if (this.currentVersion < 0) {
|
|
204
|
+
throw file_1.makeFileException(file_1.Code.notFound, this.name, `Object is marked removed`);
|
|
193
205
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
206
|
+
return change()
|
|
207
|
+
.catch((exc) => {
|
|
208
|
+
if (!exc.runtimeException) {
|
|
209
|
+
throw error_1.errWithCause(exc, `Cannot save changes to ${this.type} ${this.name}, version ${this.version}`);
|
|
197
210
|
}
|
|
198
|
-
|
|
199
|
-
|
|
211
|
+
if (exc.type === 'storage') {
|
|
212
|
+
if (exc.concurrentTransaction) {
|
|
213
|
+
throw file_1.makeFileException(file_1.Code.concurrentUpdate, this.name, exc);
|
|
214
|
+
}
|
|
215
|
+
else if (exc.objNotFound) {
|
|
216
|
+
throw file_1.makeFileException(file_1.Code.notFound, this.name, exc);
|
|
217
|
+
}
|
|
200
218
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
219
|
+
throw file_1.makeFileException(file_1.Code.ioError, this.name, exc);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
return res;
|
|
204
223
|
}
|
|
205
224
|
/**
|
|
206
225
|
* This method is called on conflict with remote version. This method
|
|
@@ -238,12 +257,14 @@ class NodeInFS {
|
|
|
238
257
|
this.broadcastEvent(event);
|
|
239
258
|
}
|
|
240
259
|
broadcastEvent(event, complete) {
|
|
260
|
+
this.storage.broadcastNodeEvent(this.objId, this.parentId, event);
|
|
241
261
|
if (!this.events) {
|
|
242
262
|
return;
|
|
243
263
|
}
|
|
244
264
|
this.events.next(event);
|
|
245
265
|
if (complete) {
|
|
246
266
|
this.events.complete();
|
|
267
|
+
this.events = undefined;
|
|
247
268
|
}
|
|
248
269
|
}
|
|
249
270
|
get event$() {
|
|
@@ -252,6 +273,12 @@ class NodeInFS {
|
|
|
252
273
|
}
|
|
253
274
|
return this.events.asObservable().pipe(operators_1.share());
|
|
254
275
|
}
|
|
276
|
+
async sync() {
|
|
277
|
+
if ((this.storage.type === 'synced')
|
|
278
|
+
|| (this.storage.type === 'share')) {
|
|
279
|
+
return this.storage.getObjSyncInfo(this.objId);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
255
282
|
}
|
|
256
283
|
exports.NodeInFS = NodeInFS;
|
|
257
284
|
Object.freeze(NodeInFS.prototype);
|
|
@@ -23,7 +23,7 @@ exports.NodePersistance = void 0;
|
|
|
23
23
|
*/
|
|
24
24
|
const xsp_files_1 = require("xsp-files");
|
|
25
25
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
26
|
-
const
|
|
26
|
+
const deferred_1 = require("../../../lib-common/processes/deferred");
|
|
27
27
|
const random = require("../../../lib-common/random-node");
|
|
28
28
|
const pv1 = require("./xsp-payload-v1");
|
|
29
29
|
const pv2 = require("./xsp-payload-v2");
|
|
@@ -148,7 +148,7 @@ class NodePersistance {
|
|
|
148
148
|
this.segWriterWithBase(newVersion, base) :
|
|
149
149
|
this.segWriter(newVersion));
|
|
150
150
|
const { sink, sub } = xsp_files_1.makeEncryptingByteSink(segWriter);
|
|
151
|
-
const defSink =
|
|
151
|
+
const defSink = deferred_1.defer();
|
|
152
152
|
return {
|
|
153
153
|
sinkPromise: defSink.promise,
|
|
154
154
|
sub: (obs, backpressure) => {
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.makeReadonlyPayload = void 0;
|
|
20
20
|
const assert_1 = require("../../../lib-common/assert");
|
|
21
21
|
const file_1 = require("../../../lib-common/exceptions/file");
|
|
22
|
-
const
|
|
22
|
+
const synced_1 = require("../../../lib-common/processes/synced");
|
|
23
23
|
const attrs_1 = require("./attrs");
|
|
24
24
|
async function makeReadonlyPayload(src) {
|
|
25
25
|
const payload = await ReadonlyPayloadV1.makeFor(src);
|
|
@@ -31,7 +31,7 @@ class ReadonlyPayloadV1 {
|
|
|
31
31
|
this.src = src;
|
|
32
32
|
this.size = size;
|
|
33
33
|
this.isEndless = isEndless;
|
|
34
|
-
this.syncProc = new
|
|
34
|
+
this.syncProc = new synced_1.SingleProc();
|
|
35
35
|
this.xattrs = undefined;
|
|
36
36
|
this.isEndless = (this.size === undefined);
|
|
37
37
|
Object.seal(this);
|
|
@@ -20,7 +20,7 @@ exports.makeWritablePayloadFromBase = exports.makeWritablePayload = exports.make
|
|
|
20
20
|
const assert_1 = require("../../../lib-common/assert");
|
|
21
21
|
const big_endian_1 = require("../../../lib-common/big-endian");
|
|
22
22
|
const attrs_1 = require("./attrs");
|
|
23
|
-
const
|
|
23
|
+
const synced_1 = require("../../../lib-common/processes/synced");
|
|
24
24
|
const wrapping_1 = require("../../../lib-common/byte-streaming/wrapping");
|
|
25
25
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
26
26
|
async function makeReadonlyPayload(src) {
|
|
@@ -47,7 +47,7 @@ class ReadonlyPayloadV2 {
|
|
|
47
47
|
this.attrs = attrs;
|
|
48
48
|
this.contentSections = contentSections;
|
|
49
49
|
this.xattrsSections = xattrsSections;
|
|
50
|
-
this.syncProc = new
|
|
50
|
+
this.syncProc = new synced_1.SingleProc();
|
|
51
51
|
this.xattrs = undefined;
|
|
52
52
|
this.size = sizeOfContent(this.contentSections);
|
|
53
53
|
Object.seal(this);
|
|
@@ -247,7 +247,7 @@ class WritablePayloadV2 {
|
|
|
247
247
|
this.attrs = attrs;
|
|
248
248
|
this.contentSections = contentSections;
|
|
249
249
|
this.xattrsSections = xattrsSections;
|
|
250
|
-
this.syncProc = new
|
|
250
|
+
this.syncProc = new synced_1.SingleProc();
|
|
251
251
|
this.completionErr = undefined;
|
|
252
252
|
assert_1.assert(!!this.sink);
|
|
253
253
|
if ((this.contentSections.length + this.xattrsSections.length) === 0) {
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.makeInWorkerWasmCryptor = exports.makeInWorkerCryptor = void 0;
|
|
20
20
|
const worker_threads_1 = require("worker_threads");
|
|
21
21
|
const os_1 = require("os");
|
|
22
|
-
const
|
|
22
|
+
const deferred_1 = require("../../lib-common/processes/deferred");
|
|
23
23
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
24
24
|
const path_1 = require("path");
|
|
25
25
|
const protobuf_type_1 = require("../protobuf-type");
|
|
@@ -82,7 +82,7 @@ class Workers {
|
|
|
82
82
|
return this.makeWorker();
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
const deferred =
|
|
85
|
+
const deferred = deferred_1.defer();
|
|
86
86
|
this.waitingForIdle.push(deferred);
|
|
87
87
|
const worker = await deferred.promise;
|
|
88
88
|
return worker;
|
|
@@ -216,7 +216,7 @@ class JsWorkers extends Workers {
|
|
|
216
216
|
super(workerScriptFor('js'), logErr, logWarning, maxThreads);
|
|
217
217
|
}
|
|
218
218
|
call(func, args, trans, interim) {
|
|
219
|
-
return this.doRequest({ func, args }, trans, { res:
|
|
219
|
+
return this.doRequest({ func, args }, trans, { res: deferred_1.defer(), interim });
|
|
220
220
|
}
|
|
221
221
|
processReply(reply) {
|
|
222
222
|
return reply;
|
|
@@ -270,7 +270,7 @@ class WasmWorkers extends Workers {
|
|
|
270
270
|
}
|
|
271
271
|
call(req, interim) {
|
|
272
272
|
const msg = this.reqType.pack(req);
|
|
273
|
-
return this.doRequest(msg, undefined, { res:
|
|
273
|
+
return this.doRequest(msg, undefined, { res: deferred_1.defer(), interim });
|
|
274
274
|
}
|
|
275
275
|
processReply(replyBytes) {
|
|
276
276
|
const { res, interim, err } = this.replyType.unpack(replyBytes);
|