core-3nweb-client-lib 0.53.15 → 0.53.17
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/build/api-defs/files.d.ts +6 -1
- package/build/core/asmail/delivery/index.js +11 -16
- package/build/core/asmail/delivery/msg.d.ts +0 -2
- package/build/core/asmail/delivery/msg.js +1 -33
- package/build/core/storage/synced/upsyncer.js +8 -9
- package/build/lib-client/asmail/sender.js +1 -1
- package/package.json +1 -1
|
@@ -1209,7 +1209,7 @@ declare namespace web3n.files {
|
|
|
1209
1209
|
syncStatus: ItemSyncStatus;
|
|
1210
1210
|
}
|
|
1211
1211
|
|
|
1212
|
-
type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDisconnectedEvent | UploadDoneEvent;
|
|
1212
|
+
type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDisconnectedEvent | UploadErredEvent | UploadDoneEvent;
|
|
1213
1213
|
|
|
1214
1214
|
interface UploadEventBase extends FSEvent {
|
|
1215
1215
|
uploadTaskId: number;
|
|
@@ -1233,6 +1233,11 @@ declare namespace web3n.files {
|
|
|
1233
1233
|
type: 'upload-disconnected';
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
|
+
interface UploadErredEvent extends UploadEventBase {
|
|
1237
|
+
type: 'upload-erred';
|
|
1238
|
+
error: any;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1236
1241
|
interface UploadDoneEvent extends UploadEventBase {
|
|
1237
1242
|
type: 'upload-done';
|
|
1238
1243
|
}
|
|
@@ -25,6 +25,7 @@ const json_utils_1 = require("../../../lib-common/json-utils");
|
|
|
25
25
|
const rxjs_1 = require("rxjs");
|
|
26
26
|
const operators_1 = require("rxjs/operators");
|
|
27
27
|
const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
|
|
28
|
+
const sleep_1 = require("../../../lib-common/processes/sleep");
|
|
28
29
|
const SMALL_MSG_SIZE = 1024 * 1024;
|
|
29
30
|
const MSGS_FOLDER = 'msgs';
|
|
30
31
|
function idToMsgFolder(id) {
|
|
@@ -101,6 +102,7 @@ class Delivery {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
observeDelivery(id, observer) {
|
|
105
|
+
var _a;
|
|
104
106
|
const msg = this.msgs.get(id);
|
|
105
107
|
if (!msg) {
|
|
106
108
|
if (observer.error) {
|
|
@@ -109,16 +111,14 @@ class Delivery {
|
|
|
109
111
|
return () => { };
|
|
110
112
|
}
|
|
111
113
|
if (msg.isDone()) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
if (observer.complete) {
|
|
116
|
-
observer.complete();
|
|
117
|
-
}
|
|
114
|
+
(_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, (0, json_utils_1.copy)(msg.progress));
|
|
115
|
+
(0, sleep_1.sleep)(1).then(() => { var _a; return (_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); });
|
|
118
116
|
return () => { };
|
|
119
117
|
}
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
else {
|
|
119
|
+
const subToProgress = msg.progress$.subscribe((0, utils_for_observables_1.toRxObserver)(observer));
|
|
120
|
+
return () => { subToProgress.unsubscribe(); };
|
|
121
|
+
}
|
|
122
122
|
}
|
|
123
123
|
observeAllDeliveries(observer) {
|
|
124
124
|
const subToProgress = this.allDeliveries$.subscribe((0, utils_for_observables_1.toRxObserver)(observer));
|
|
@@ -182,14 +182,10 @@ class Delivery {
|
|
|
182
182
|
// start/schedule delivery process, according to message's size
|
|
183
183
|
if (sendImmediately || (msg.deliverySizeLeft() <= SMALL_MSG_SIZE)) {
|
|
184
184
|
this.immediateDelivery.add(msg);
|
|
185
|
-
msg.sendThisSmallMsgInParallel()
|
|
186
|
-
|
|
187
|
-
this.immediateDelivery.delete(msg);
|
|
188
|
-
this.performQueuedDelivery();
|
|
189
|
-
}
|
|
190
|
-
}, async (err) => {
|
|
191
|
-
// XXX add to retries queue with some timestamp
|
|
185
|
+
msg.sendThisSmallMsgInParallel()
|
|
186
|
+
.catch(async (err) => {
|
|
192
187
|
await this.r.logWarning('Got error when sending a message', err);
|
|
188
|
+
}).finally(() => {
|
|
193
189
|
this.immediateDelivery.delete(msg);
|
|
194
190
|
this.performQueuedDelivery();
|
|
195
191
|
});
|
|
@@ -219,7 +215,6 @@ class Delivery {
|
|
|
219
215
|
}
|
|
220
216
|
}
|
|
221
217
|
}, async (err) => {
|
|
222
|
-
// XXX add to retries queue with some timestamp
|
|
223
218
|
await this.r.logWarning('Got error when sending a message', err);
|
|
224
219
|
if (msg === this.queuedDelivery[0]) {
|
|
225
220
|
this.queuedDelivery.shift();
|
|
@@ -13,7 +13,6 @@ export declare class Msg {
|
|
|
13
13
|
private readonly msgFS;
|
|
14
14
|
private static readonly progressSavingProcs;
|
|
15
15
|
private readonly sendingProc;
|
|
16
|
-
private completionPromise;
|
|
17
16
|
private cancelled;
|
|
18
17
|
private sender;
|
|
19
18
|
private recipients;
|
|
@@ -35,7 +34,6 @@ export declare class Msg {
|
|
|
35
34
|
isDone(): boolean;
|
|
36
35
|
isSendingNow(): boolean;
|
|
37
36
|
deliverySizeLeft(): number;
|
|
38
|
-
getCompletionPromise(): Promise<DeliveryProgress>;
|
|
39
37
|
/**
|
|
40
38
|
* Calling this method sets this message as cancelled. When returned promise
|
|
41
39
|
* completes, it is safe to remove message's folder.
|
|
@@ -23,7 +23,6 @@ const common_1 = require("./common");
|
|
|
23
23
|
const per_recipient_wip_1 = require("./per-recipient-wip");
|
|
24
24
|
const rxjs_1 = require("rxjs");
|
|
25
25
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
26
|
-
const deferred_1 = require("../../../lib-common/processes/deferred");
|
|
27
26
|
const MAIN_OBJ_FILE_NAME = 'msg.json';
|
|
28
27
|
const PROGRESS_INFO_FILE_NAME = 'progress.json';
|
|
29
28
|
const WIPS_INFO_FILE_NAME = 'wips.json';
|
|
@@ -64,7 +63,6 @@ class Msg {
|
|
|
64
63
|
this.progress = progress;
|
|
65
64
|
this.msgFS = msgFS;
|
|
66
65
|
this.sendingProc = new synced_1.SingleProc();
|
|
67
|
-
this.completionPromise = undefined;
|
|
68
66
|
this.cancelled = false;
|
|
69
67
|
this.sender = undefined;
|
|
70
68
|
this.recipients = undefined;
|
|
@@ -142,8 +140,7 @@ class Msg {
|
|
|
142
140
|
// In recipient's part, awaitingRestart flag ?
|
|
143
141
|
// retryRecipients ?
|
|
144
142
|
if (checkIfAllRecipientsDone(this.progress)) {
|
|
145
|
-
this.progress.allDone = (hasError(this.progress) ?
|
|
146
|
-
'with-errors' : 'all-ok');
|
|
143
|
+
this.progress.allDone = (hasError(this.progress) ? 'with-errors' : 'all-ok');
|
|
147
144
|
saveProgress = true;
|
|
148
145
|
}
|
|
149
146
|
this.r.notifyMsgProgress(this.id, (0, json_utils_1.copy)(this.progress));
|
|
@@ -212,15 +209,6 @@ class Msg {
|
|
|
212
209
|
}
|
|
213
210
|
return sizeLeft;
|
|
214
211
|
}
|
|
215
|
-
getCompletionPromise() {
|
|
216
|
-
if (this.isDone()) {
|
|
217
|
-
throw new Error(`Message delivery has already completed.`);
|
|
218
|
-
}
|
|
219
|
-
if (!this.completionPromise) {
|
|
220
|
-
this.completionPromise = (0, deferred_1.defer)();
|
|
221
|
-
}
|
|
222
|
-
return this.completionPromise.promise;
|
|
223
|
-
}
|
|
224
212
|
/**
|
|
225
213
|
* Calling this method sets this message as cancelled. When returned promise
|
|
226
214
|
* completes, it is safe to remove message's folder.
|
|
@@ -275,16 +263,6 @@ class Msg {
|
|
|
275
263
|
}
|
|
276
264
|
});
|
|
277
265
|
await Promise.all(wipPromises);
|
|
278
|
-
// XXX ???
|
|
279
|
-
if (this.completionPromise && this.isDone()) {
|
|
280
|
-
this.completionPromise.resolve(this.progress);
|
|
281
|
-
this.completionPromise = undefined;
|
|
282
|
-
}
|
|
283
|
-
}).catch(err => {
|
|
284
|
-
if (this.completionPromise) {
|
|
285
|
-
this.completionPromise.reject(err);
|
|
286
|
-
this.completionPromise = undefined;
|
|
287
|
-
}
|
|
288
266
|
});
|
|
289
267
|
}
|
|
290
268
|
/**
|
|
@@ -325,16 +303,6 @@ class Msg {
|
|
|
325
303
|
if (this.sequentialWIP.isDone()) {
|
|
326
304
|
this.sequentialWIP = undefined;
|
|
327
305
|
}
|
|
328
|
-
// XXX ???
|
|
329
|
-
if (this.completionPromise && this.isDone()) {
|
|
330
|
-
this.completionPromise.resolve(this.progress);
|
|
331
|
-
this.completionPromise = undefined;
|
|
332
|
-
}
|
|
333
|
-
}).catch(err => {
|
|
334
|
-
if (this.completionPromise) {
|
|
335
|
-
this.completionPromise.reject(err);
|
|
336
|
-
this.completionPromise = undefined;
|
|
337
|
-
}
|
|
338
306
|
});
|
|
339
307
|
}
|
|
340
308
|
}
|
|
@@ -211,20 +211,16 @@ class UploadTask {
|
|
|
211
211
|
}
|
|
212
212
|
await this.objStatus.recordUploadInterimState(this.info);
|
|
213
213
|
if (this.info.needUpload) {
|
|
214
|
-
|
|
215
|
-
this.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
}
|
|
214
|
+
this.emitUploadEvent('upload-progress', {
|
|
215
|
+
totalBytesToUpload: this.totalBytesToUpload,
|
|
216
|
+
bytesLeftToUpload: (0, obj_status_1.countBytesIn)(this.info)
|
|
217
|
+
});
|
|
220
218
|
return false;
|
|
221
219
|
}
|
|
222
220
|
else {
|
|
223
221
|
await this.doAtCompletion().finally(() => {
|
|
224
222
|
this.uploadCompletion.resolve();
|
|
225
|
-
|
|
226
|
-
this.emitUploadEvent('upload-done', {});
|
|
227
|
-
}
|
|
223
|
+
this.emitUploadEvent('upload-done', {});
|
|
228
224
|
});
|
|
229
225
|
return true;
|
|
230
226
|
}
|
|
@@ -247,6 +243,9 @@ class UploadTask {
|
|
|
247
243
|
uploadVersion: this.info.uploadVersion,
|
|
248
244
|
cause: exc
|
|
249
245
|
}));
|
|
246
|
+
this.emitUploadEvent('upload-erred', {
|
|
247
|
+
error: exc
|
|
248
|
+
});
|
|
250
249
|
await this.objStatus.recordUploadCancellation(this.info);
|
|
251
250
|
return true;
|
|
252
251
|
}
|
|
@@ -434,7 +434,7 @@ class MailSender {
|
|
|
434
434
|
if (!this.sessionId) {
|
|
435
435
|
throw new Error(`Delivery session is not opened, and cannot be cancelled.`);
|
|
436
436
|
}
|
|
437
|
-
// XXX make delivery canceling request within session
|
|
437
|
+
// XXX make delivery canceling request within session to protocol
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
440
|
exports.MailSender = MailSender;
|