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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "3NWeb client core library, embeddable into different environments",
|
|
5
5
|
"main": "build/lib-index.js",
|
|
6
6
|
"types": "build/lib-index.d.ts",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "GPL-3.0-or-later",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"ecma-nacl": "^2.5.1",
|
|
30
|
-
"protobufjs": "^6.
|
|
30
|
+
"protobufjs": "^6.11.3",
|
|
31
31
|
"punycode": "^2.1.1",
|
|
32
32
|
"rxjs": "^6.5.2",
|
|
33
|
-
"ws": "^7.
|
|
33
|
+
"ws": "^7.4.6",
|
|
34
34
|
"xsp-files": "^4.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/node": "^12.0.4",
|
|
39
39
|
"@types/ws": "^4.0.0",
|
|
40
40
|
"jasmine": "^3.9.0",
|
|
41
|
-
"spec-3nweb-server": "^1.
|
|
41
|
+
"spec-3nweb-server": "^1.4.0",
|
|
42
42
|
"typescript": "^3.7.3"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/protos/file.proto
CHANGED
|
@@ -22,6 +22,14 @@ message File {
|
|
|
22
22
|
// Request body is empty
|
|
23
23
|
// Reply body is StatsMsg
|
|
24
24
|
message StatsMsg {
|
|
25
|
+
message SyncInfo {
|
|
26
|
+
string state = 1;
|
|
27
|
+
common.UInt64Value latest = 2;
|
|
28
|
+
common.UInt64Value remote = 3;
|
|
29
|
+
repeated uint64 conflicting_remote = 4;
|
|
30
|
+
common.BooleanValue deleted_on_remote = 5;
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
common.BooleanValue is_file = 1;
|
|
26
34
|
common.BooleanValue is_folder = 2;
|
|
27
35
|
common.BooleanValue is_link = 3;
|
|
@@ -30,6 +38,7 @@ message StatsMsg {
|
|
|
30
38
|
common.UInt64Value mtime = 6;
|
|
31
39
|
common.UInt64Value ctime = 7;
|
|
32
40
|
common.UInt64Value version = 8;
|
|
41
|
+
SyncInfo sync = 9;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
// --- ReadonlyFile.getXAttr ---
|
|
@@ -79,8 +88,7 @@ message FileEventMsg {
|
|
|
79
88
|
common.BooleanValue is_remote = 3;
|
|
80
89
|
common.UInt64Value new_version = 4;
|
|
81
90
|
common.UInt64Value current = 14;
|
|
82
|
-
common.UInt64Value
|
|
83
|
-
common.UInt64Value remote_version = 16;
|
|
91
|
+
common.UInt64Value uploaded = 15;
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
|
package/protos/fs.proto
CHANGED
|
@@ -85,8 +85,8 @@ message FSEventMsg {
|
|
|
85
85
|
common.StringValue new_name = 12;
|
|
86
86
|
ListingEntryMsg entry = 13;
|
|
87
87
|
common.UInt64Value current = 14;
|
|
88
|
-
common.UInt64Value
|
|
89
|
-
common.UInt64Value
|
|
88
|
+
common.UInt64Value uploaded = 15;
|
|
89
|
+
common.UInt64Value move_label = 16;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// --- ReadonlyFS.watchFile ---
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { LogError } from '../../../lib-client/logging/log-to-file';
|
|
2
|
-
export interface UploadInfo {
|
|
3
|
-
type: 'upload';
|
|
4
|
-
transactionId?: string;
|
|
5
|
-
awaiting?: {
|
|
6
|
-
header?: true;
|
|
7
|
-
segs: BytesSection[];
|
|
8
|
-
allByteOnDisk?: true;
|
|
9
|
-
};
|
|
10
|
-
version: number;
|
|
11
|
-
baseVersion?: number;
|
|
12
|
-
done: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface BytesSection {
|
|
15
|
-
ofs: number;
|
|
16
|
-
len: number;
|
|
17
|
-
}
|
|
18
|
-
export interface RemovalInfo {
|
|
19
|
-
type: 'removal';
|
|
20
|
-
archivedVersions?: number[] | number;
|
|
21
|
-
currentVersion?: true;
|
|
22
|
-
}
|
|
23
|
-
export interface ArchivalInfo {
|
|
24
|
-
type: 'archiving';
|
|
25
|
-
archivalOfCurrent?: true;
|
|
26
|
-
}
|
|
27
|
-
export declare type UpSyncTaskInfo = UploadInfo | RemovalInfo | ArchivalInfo;
|
|
28
|
-
export declare function makeUploadInfo(version: number, baseVersion: number | undefined): UploadInfo;
|
|
29
|
-
export declare class UpSyncTasks {
|
|
30
|
-
private readonly objFolder;
|
|
31
|
-
private readonly saveProc;
|
|
32
|
-
private status;
|
|
33
|
-
private initProc;
|
|
34
|
-
private tasksAwaitingInit;
|
|
35
|
-
constructor(objFolder: string, logError: LogError);
|
|
36
|
-
queueTask(t: UpSyncTaskInfo): void;
|
|
37
|
-
nextTask(): Promise<UpSyncTaskInfo | undefined>;
|
|
38
|
-
recordInterimStateOfCurrentTask(t: UploadInfo): Promise<void>;
|
|
39
|
-
recordTaskCompletion(t: UpSyncTaskInfo): Promise<void>;
|
|
40
|
-
isDone(): boolean;
|
|
41
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2020 3NSoft Inc.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
-
version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful, but
|
|
11
|
-
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
-
See the GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.UpSyncTasks = exports.makeUploadInfo = void 0;
|
|
19
|
-
const processes_1 = require("../../../lib-common/processes");
|
|
20
|
-
const fs = require("../../../lib-common/async-fs-node");
|
|
21
|
-
const path_1 = require("path");
|
|
22
|
-
const obj_info_file_1 = require("../common/obj-info-file");
|
|
23
|
-
function makeUploadInfo(version, baseVersion) {
|
|
24
|
-
return {
|
|
25
|
-
type: 'upload',
|
|
26
|
-
done: false,
|
|
27
|
-
version,
|
|
28
|
-
baseVersion
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.makeUploadInfo = makeUploadInfo;
|
|
32
|
-
const UPSYNC_FILE_NAME = 'upsync';
|
|
33
|
-
class UpSyncTasks {
|
|
34
|
-
constructor(objFolder, logError) {
|
|
35
|
-
this.objFolder = objFolder;
|
|
36
|
-
this.saveProc = new processes_1.DeduppedRunner(async () => {
|
|
37
|
-
if (this.isDone()) {
|
|
38
|
-
await fs.unlink(path_1.join(this.objFolder, UPSYNC_FILE_NAME)).catch((e) => { if (!e.notFound) {
|
|
39
|
-
throw e;
|
|
40
|
-
} });
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
await fs.writeFile(path_1.join(this.objFolder, UPSYNC_FILE_NAME), JSON.stringify(this.status), { encoding: 'utf8' });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.status = undefined;
|
|
47
|
-
this.initProc = undefined;
|
|
48
|
-
this.tasksAwaitingInit = undefined;
|
|
49
|
-
this.initProc = readOrMakeUpSyncInfo(this.objFolder).then(status => {
|
|
50
|
-
this.status = status;
|
|
51
|
-
if (this.tasksAwaitingInit) {
|
|
52
|
-
for (const t of this.tasksAwaitingInit) {
|
|
53
|
-
this.queueTask(t);
|
|
54
|
-
}
|
|
55
|
-
this.tasksAwaitingInit = undefined;
|
|
56
|
-
}
|
|
57
|
-
this.initProc = undefined;
|
|
58
|
-
}, err => {
|
|
59
|
-
logError(err, `Can't setup upsync status.`);
|
|
60
|
-
this.initProc = undefined;
|
|
61
|
-
});
|
|
62
|
-
Object.seal(this);
|
|
63
|
-
}
|
|
64
|
-
queueTask(t) {
|
|
65
|
-
if (this.status) {
|
|
66
|
-
addTaskToQueue(this.status.queued, t);
|
|
67
|
-
this.saveProc.trigger();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
if (!this.tasksAwaitingInit) {
|
|
71
|
-
this.tasksAwaitingInit = [];
|
|
72
|
-
}
|
|
73
|
-
this.tasksAwaitingInit.push(t);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async nextTask() {
|
|
77
|
-
if (!this.status) {
|
|
78
|
-
await this.initProc;
|
|
79
|
-
if (!this.status) {
|
|
80
|
-
throw new Error(`Status not set after wait`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (this.status.current) {
|
|
84
|
-
return this.status.current;
|
|
85
|
-
}
|
|
86
|
-
this.status.current = this.status.queued.shift();
|
|
87
|
-
if (this.status.current) {
|
|
88
|
-
await this.saveProc.trigger();
|
|
89
|
-
}
|
|
90
|
-
return this.status.current;
|
|
91
|
-
}
|
|
92
|
-
async recordInterimStateOfCurrentTask(t) {
|
|
93
|
-
if (!this.status) {
|
|
94
|
-
throw new Error(`This method is called too early.`);
|
|
95
|
-
}
|
|
96
|
-
if (this.status.current === t) {
|
|
97
|
-
await this.saveProc.trigger();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
throw new Error(`Can save interim state of a current task only`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async recordTaskCompletion(t) {
|
|
104
|
-
if (!this.status) {
|
|
105
|
-
throw new Error(`This method is called too early.`);
|
|
106
|
-
}
|
|
107
|
-
if (this.status.current === t) {
|
|
108
|
-
this.status.current = undefined;
|
|
109
|
-
await this.saveProc.trigger();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
isDone() {
|
|
113
|
-
if (!this.status) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return (!this.status.current && (this.status.queued.length === 0));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.UpSyncTasks = UpSyncTasks;
|
|
122
|
-
Object.freeze(UpSyncTasks.prototype);
|
|
123
|
-
Object.freeze(UpSyncTasks);
|
|
124
|
-
function addTaskToQueue(q, t) {
|
|
125
|
-
if (t.type === 'upload') {
|
|
126
|
-
addUploadToQueue(q, t);
|
|
127
|
-
}
|
|
128
|
-
else if (t.type === 'removal') {
|
|
129
|
-
addRemovalToQueue(q, t);
|
|
130
|
-
}
|
|
131
|
-
else if (t.type === 'archiving') {
|
|
132
|
-
addArchivalToQueue(q, t);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
throw new Error(`Unsupported upsync task type`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function addUploadToQueue(q, u) {
|
|
139
|
-
// XXX
|
|
140
|
-
q.push(u);
|
|
141
|
-
}
|
|
142
|
-
function addRemovalToQueue(q, r) {
|
|
143
|
-
// XXX
|
|
144
|
-
q.push(r);
|
|
145
|
-
}
|
|
146
|
-
function addArchivalToQueue(q, a) {
|
|
147
|
-
// XXX
|
|
148
|
-
q.push(a);
|
|
149
|
-
}
|
|
150
|
-
async function readOrMakeUpSyncInfo(objFolder) {
|
|
151
|
-
const status = await obj_info_file_1.readJSONInfoFileIn(objFolder, UPSYNC_FILE_NAME);
|
|
152
|
-
if (!status) {
|
|
153
|
-
return { queued: [] };
|
|
154
|
-
}
|
|
155
|
-
// XXX we may do some checks and sanitization here
|
|
156
|
-
return status;
|
|
157
|
-
}
|
|
158
|
-
Object.freeze(exports);
|