spec-3nweb-server 1.5.2 → 1.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/build/3nstorage/owner.js +6 -4
- package/build/3nstorage/resources/store.d.ts +2 -2
- package/build/3nstorage/resources/store.js +5 -3
- package/build/3nstorage/resources/users.d.ts +3 -3
- package/build/3nstorage/resources/users.js +2 -2
- package/build/3nstorage/routes/owner/get-obj-status.d.ts +3 -0
- package/build/3nstorage/routes/owner/{list-obj-archive.js → get-obj-status.js} +8 -8
- package/build/lib-common/service-api/3nstorage/owner.d.ts +24 -5
- package/build/lib-common/service-api/3nstorage/owner.js +29 -11
- package/package.json +1 -1
- package/build/3nstorage/routes/owner/list-obj-archive.d.ts +0 -3
package/build/3nstorage/owner.js
CHANGED
|
@@ -37,7 +37,7 @@ const get_current_obj_1 = require("./routes/owner/get-current-obj");
|
|
|
37
37
|
const get_archived_obj_ver_1 = require("./routes/owner/get-archived-obj-ver");
|
|
38
38
|
const delete_obj_1 = require("./routes/owner/delete-obj");
|
|
39
39
|
const archive_obj_version_1 = require("./routes/owner/archive-obj-version");
|
|
40
|
-
const
|
|
40
|
+
const get_obj_status_1 = require("./routes/owner/get-obj-status");
|
|
41
41
|
const api = require("../lib-common/service-api/3nstorage/owner");
|
|
42
42
|
function makeApp(domain, sessions, users, midAuthorizer) {
|
|
43
43
|
const app = new app_1.AppWithWSs();
|
|
@@ -88,14 +88,16 @@ function setHttpPart(app, domain, sessions, users, midAuthorizer) {
|
|
|
88
88
|
app.http.route('/' + api.archivedObjVersion.EXPRESS_URL_END)
|
|
89
89
|
.get((0, get_archived_obj_ver_1.getArchivedObjVersion)(false, users.getArchivedObjVersion));
|
|
90
90
|
// Archive root's current version
|
|
91
|
-
app.http.route('/' + api.archiveRoot.
|
|
92
|
-
.get((0, list_obj_archive_1.listObjArchive)(true, users.listObjArchive))
|
|
91
|
+
app.http.route('/' + api.archiveRoot.EXPRESS_URL_END)
|
|
93
92
|
.post((0, body_parsers_1.emptyBody)(), (0, archive_obj_version_1.archiveCurrentObjVersion)(true, users.archiveObjVersion))
|
|
94
93
|
.delete((0, delete_obj_1.deleteArchivedObjVer)(true, users.deleteArchivedObjVersion));
|
|
95
94
|
// Archive non-root object's current version
|
|
96
95
|
app.http.route('/' + api.archiveObj.EXPRESS_URL_END)
|
|
97
|
-
.get((0, list_obj_archive_1.listObjArchive)(false, users.listObjArchive))
|
|
98
96
|
.post((0, body_parsers_1.emptyBody)(), (0, archive_obj_version_1.archiveCurrentObjVersion)(false, users.archiveObjVersion))
|
|
99
97
|
.delete((0, delete_obj_1.deleteArchivedObjVer)(false, users.deleteArchivedObjVersion));
|
|
98
|
+
// Getting root object status
|
|
99
|
+
app.http.get('/' + api.rootStatus.EXPRESS_URL_END, (0, get_obj_status_1.getObjStatus)(true, users.getObjStatus));
|
|
100
|
+
// Getting object status
|
|
101
|
+
app.http.get('/' + api.objStatus.EXPRESS_URL_END, (0, get_obj_status_1.getObjStatus)(false, users.getObjStatus));
|
|
100
102
|
}
|
|
101
103
|
Object.freeze(exports);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
import { PutObjFirstQueryOpts, PutObjSecondQueryOpts } from '../../lib-common/service-api/3nstorage/owner';
|
|
4
4
|
import { UserFiles, ObjReader } from '../../lib-server/resources/user-files';
|
|
5
|
-
import { DiffInfo, events } from '../../lib-common/service-api/3nstorage/owner';
|
|
5
|
+
import { DiffInfo, events, ObjStatus } from '../../lib-common/service-api/3nstorage/owner';
|
|
6
6
|
export { DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
|
|
7
7
|
export { ObjPipe, ObjReader } from '../../lib-server/resources/user-files';
|
|
8
8
|
export declare type StorageEventsSink = (userId: string, channel: events.EventNameType, event: events.AllTypes) => void;
|
|
@@ -111,7 +111,7 @@ export declare class Store extends UserFiles {
|
|
|
111
111
|
*/
|
|
112
112
|
private rmObjFiles;
|
|
113
113
|
archiveCurrentObjVersion(objId: string, version: number): Promise<void>;
|
|
114
|
-
|
|
114
|
+
getObjStatus(objId: string): Promise<ObjStatus>;
|
|
115
115
|
static getSpaceQuota(store: Store): Promise<number>;
|
|
116
116
|
static getKeyDerivParams(store: Store): Promise<any>;
|
|
117
117
|
static setKeyDerivParams(store: Store, params: any, setDefault: boolean): Promise<boolean>;
|
|
@@ -413,10 +413,12 @@ class Store extends user_files_1.UserFiles {
|
|
|
413
413
|
await this.statuses.set(objId, status);
|
|
414
414
|
this.storageEventsSink(this.userId, owner_1.events.objVersionArchived.EVENT_NAME, { objId, archivedVer: version });
|
|
415
415
|
}
|
|
416
|
-
async
|
|
416
|
+
async getObjStatus(objId) {
|
|
417
417
|
const status = await this.statuses.get(objId);
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
return {
|
|
419
|
+
current: status.currentVersion,
|
|
420
|
+
archived: status.archivedVersions
|
|
421
|
+
};
|
|
420
422
|
}
|
|
421
423
|
static getSpaceQuota(store) {
|
|
422
424
|
return store.getSpaceQuota();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Readable as ReadableStream } from 'stream';
|
|
8
8
|
import { ObjReader, StorageEventsSink } from './store';
|
|
9
|
-
import { PutObjFirstQueryOpts, PutObjSecondQueryOpts, DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
|
|
9
|
+
import { PutObjFirstQueryOpts, PutObjSecondQueryOpts, DiffInfo, ObjStatus } from '../../lib-common/service-api/3nstorage/owner';
|
|
10
10
|
export { SC, ObjReader, MismatchedObjVerException } from './store';
|
|
11
11
|
export declare type UserExists = (userId: string) => Promise<boolean>;
|
|
12
12
|
export declare type GetCurrentObj = (userId: string, objId: string | null, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<{
|
|
@@ -17,7 +17,7 @@ export declare type SaveNewObjVersion = (userId: string, objId: string | null, f
|
|
|
17
17
|
export declare type GetArchivedObjVersion = (userId: string, objId: string | null, version: number, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
|
|
18
18
|
export declare type CancelTransaction = (userId: string, objId: string, transactionId?: string) => Promise<void>;
|
|
19
19
|
export declare type ArchiveObjCurrentVersion = (userId: string, objId: string, version: number) => Promise<void>;
|
|
20
|
-
export declare type
|
|
20
|
+
export declare type GetObjStatus = (userId: string, objId: string) => Promise<ObjStatus>;
|
|
21
21
|
export declare type DeleteCurrentObjVersion = (userId: string, objId: string, version?: number) => Promise<void>;
|
|
22
22
|
export declare type DeleteArchivedObjVersion = (userId: string, objId: string | null, version: number) => Promise<void>;
|
|
23
23
|
declare type GetParam<T> = (userId: string) => Promise<T>;
|
|
@@ -39,7 +39,7 @@ export interface Factory {
|
|
|
39
39
|
saveNewObjVersion: SaveNewObjVersion;
|
|
40
40
|
saveNewRootVersion: SaveNewObjVersion;
|
|
41
41
|
getCurrentRootObj: GetCurrentObj;
|
|
42
|
-
|
|
42
|
+
getObjStatus: GetObjStatus;
|
|
43
43
|
archiveObjVersion: ArchiveObjCurrentVersion;
|
|
44
44
|
getArchivedRootVersion: GetArchivedObjVersion;
|
|
45
45
|
getArchivedObjVersion: GetArchivedObjVersion;
|
|
@@ -130,9 +130,9 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
|
|
|
130
130
|
const store = await getStore(userId);
|
|
131
131
|
await store.archiveCurrentObjVersion(objId, version);
|
|
132
132
|
},
|
|
133
|
-
|
|
133
|
+
getObjStatus: async (userId, objId) => {
|
|
134
134
|
const store = await getStore(userId);
|
|
135
|
-
return store.
|
|
135
|
+
return store.getObjStatus(objId);
|
|
136
136
|
},
|
|
137
137
|
deleteArchivedObjVersion: async (userId, objId, version) => {
|
|
138
138
|
const store = await getStore(userId);
|
|
@@ -16,26 +16,26 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.getObjStatus = void 0;
|
|
20
20
|
const users_1 = require("../../resources/users");
|
|
21
21
|
const owner_1 = require("../../../lib-common/service-api/3nstorage/owner");
|
|
22
|
-
function
|
|
23
|
-
if ('function' !== typeof
|
|
24
|
-
throw new TypeError("Given argument '
|
|
22
|
+
function getObjStatus(root, getObjStatusFunc) {
|
|
23
|
+
if ('function' !== typeof getObjStatusFunc) {
|
|
24
|
+
throw new TypeError("Given argument 'getObjStatusFunc' must be function, but is not.");
|
|
25
25
|
}
|
|
26
26
|
return async (req, res, next) => {
|
|
27
27
|
const userId = req.session.params.userId;
|
|
28
28
|
const objId = (root ? null : req.params.objId);
|
|
29
29
|
try {
|
|
30
|
-
const lst = await
|
|
31
|
-
res.status(owner_1.
|
|
30
|
+
const lst = await getObjStatusFunc(userId, objId);
|
|
31
|
+
res.status(owner_1.objStatus.SC.ok).json(lst);
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
34
34
|
if ("string" !== typeof err) {
|
|
35
35
|
next(err);
|
|
36
36
|
}
|
|
37
37
|
else if (err === users_1.SC.OBJ_UNKNOWN) {
|
|
38
|
-
res.status(owner_1.
|
|
38
|
+
res.status(owner_1.objStatus.SC.unknownObj).send(root ?
|
|
39
39
|
`Root object is set.` : `Object ${objId} is unknown.`);
|
|
40
40
|
}
|
|
41
41
|
else if (err === users_1.SC.USER_UNKNOWN) {
|
|
@@ -48,6 +48,6 @@ function listObjArchive(root, listObjArchiveFunc) {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
exports.
|
|
51
|
+
exports.getObjStatus = getObjStatus;
|
|
52
52
|
;
|
|
53
53
|
Object.freeze(exports);
|
|
@@ -109,6 +109,7 @@ export interface PutObjSecondQueryOpts {
|
|
|
109
109
|
export declare namespace currentObj {
|
|
110
110
|
const EXPRESS_URL_END = "obj/:objId/current";
|
|
111
111
|
function getReqUrlEnd(objId: string, opts?: GetObjQueryOpts): string;
|
|
112
|
+
function delReqUrlEnd(objId: string, ver?: number): string;
|
|
112
113
|
function firstPutReqUrlEnd(objId: string, opts: PutObjFirstQueryOpts): string;
|
|
113
114
|
function secondPutReqUrlEnd(objId: string, opts: PutObjSecondQueryOpts): string;
|
|
114
115
|
interface ReplyToPut {
|
|
@@ -214,13 +215,33 @@ export declare namespace cancelRootTransaction {
|
|
|
214
215
|
missing: number;
|
|
215
216
|
};
|
|
216
217
|
}
|
|
218
|
+
export interface ObjStatus {
|
|
219
|
+
current?: number;
|
|
220
|
+
archived?: number[];
|
|
221
|
+
}
|
|
222
|
+
export declare namespace objStatus {
|
|
223
|
+
const EXPRESS_URL_END = "obj/:objId/status";
|
|
224
|
+
function getReqUrlEnd(objId: string): string;
|
|
225
|
+
type Reply = ObjStatus;
|
|
226
|
+
const SC: {
|
|
227
|
+
ok: number;
|
|
228
|
+
unknownObj: number;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export declare namespace rootStatus {
|
|
232
|
+
const EXPRESS_URL_END = "root/status";
|
|
233
|
+
function getReqUrlEnd(): string;
|
|
234
|
+
type Reply = ObjStatus;
|
|
235
|
+
const SC: {
|
|
236
|
+
ok: number;
|
|
237
|
+
unknownObj: number;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
217
240
|
export declare namespace archiveObj {
|
|
218
241
|
const EXPRESS_URL_END = "obj/:objId/archive";
|
|
219
|
-
function getReqUrlEnd(objId: string): string;
|
|
220
242
|
function postAndDelReqUrlEnd(objId: string, version: number): string;
|
|
221
243
|
type VersionsList = number[];
|
|
222
244
|
const SC: {
|
|
223
|
-
okGet: number;
|
|
224
245
|
okPost: number;
|
|
225
246
|
okDelete: number;
|
|
226
247
|
unknownObj: number;
|
|
@@ -228,12 +249,10 @@ export declare namespace archiveObj {
|
|
|
228
249
|
};
|
|
229
250
|
}
|
|
230
251
|
export declare namespace archiveRoot {
|
|
231
|
-
const
|
|
232
|
-
function getReqUrlEnd(): string;
|
|
252
|
+
const EXPRESS_URL_END = "root/archive";
|
|
233
253
|
function postAndDelReqUrlEnd(version: number): string;
|
|
234
254
|
type VersionsList = archiveObj.VersionsList;
|
|
235
255
|
const SC: {
|
|
236
|
-
okGet: number;
|
|
237
256
|
okPost: number;
|
|
238
257
|
okDelete: number;
|
|
239
258
|
unknownObj: number;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.events = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
|
|
19
|
+
exports.events = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.rootStatus = exports.objStatus = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
|
|
20
20
|
/**
|
|
21
21
|
* This defines interfaces for 3nstorage owner's requests.
|
|
22
22
|
*/
|
|
@@ -79,6 +79,10 @@ var currentObj;
|
|
|
79
79
|
return `obj/${objId}/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
|
|
80
80
|
}
|
|
81
81
|
currentObj.getReqUrlEnd = getReqUrlEnd;
|
|
82
|
+
function delReqUrlEnd(objId, ver) {
|
|
83
|
+
return `obj/${objId}/current${ver ? `?${(0, querystring_1.stringify)({ ver })}` : ''}`;
|
|
84
|
+
}
|
|
85
|
+
currentObj.delReqUrlEnd = delReqUrlEnd;
|
|
82
86
|
function firstPutReqUrlEnd(objId, opts) {
|
|
83
87
|
return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
|
|
84
88
|
}
|
|
@@ -220,19 +224,37 @@ var cancelRootTransaction;
|
|
|
220
224
|
cancelRootTransaction.SC = cancelTransaction.SC;
|
|
221
225
|
})(cancelRootTransaction = exports.cancelRootTransaction || (exports.cancelRootTransaction = {}));
|
|
222
226
|
Object.freeze(cancelRootTransaction);
|
|
227
|
+
var objStatus;
|
|
228
|
+
(function (objStatus) {
|
|
229
|
+
objStatus.EXPRESS_URL_END = 'obj/:objId/status';
|
|
230
|
+
function getReqUrlEnd(objId) {
|
|
231
|
+
return `obj/${objId}/status`;
|
|
232
|
+
}
|
|
233
|
+
objStatus.getReqUrlEnd = getReqUrlEnd;
|
|
234
|
+
objStatus.SC = {
|
|
235
|
+
ok: 200,
|
|
236
|
+
unknownObj: 474,
|
|
237
|
+
};
|
|
238
|
+
})(objStatus = exports.objStatus || (exports.objStatus = {}));
|
|
239
|
+
Object.freeze(objStatus);
|
|
240
|
+
var rootStatus;
|
|
241
|
+
(function (rootStatus) {
|
|
242
|
+
rootStatus.EXPRESS_URL_END = 'root/status';
|
|
243
|
+
function getReqUrlEnd() {
|
|
244
|
+
return 'root/status';
|
|
245
|
+
}
|
|
246
|
+
rootStatus.getReqUrlEnd = getReqUrlEnd;
|
|
247
|
+
rootStatus.SC = objStatus.SC;
|
|
248
|
+
})(rootStatus = exports.rootStatus || (exports.rootStatus = {}));
|
|
249
|
+
Object.freeze(rootStatus);
|
|
223
250
|
var archiveObj;
|
|
224
251
|
(function (archiveObj) {
|
|
225
252
|
archiveObj.EXPRESS_URL_END = 'obj/:objId/archive';
|
|
226
|
-
function getReqUrlEnd(objId) {
|
|
227
|
-
return `obj/${objId}/archive`;
|
|
228
|
-
}
|
|
229
|
-
archiveObj.getReqUrlEnd = getReqUrlEnd;
|
|
230
253
|
function postAndDelReqUrlEnd(objId, version) {
|
|
231
254
|
return `obj/${objId}/archive?ver=${version}`;
|
|
232
255
|
}
|
|
233
256
|
archiveObj.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
|
|
234
257
|
archiveObj.SC = {
|
|
235
|
-
okGet: 200,
|
|
236
258
|
okPost: 200,
|
|
237
259
|
okDelete: 200,
|
|
238
260
|
unknownObj: 474,
|
|
@@ -242,11 +264,7 @@ var archiveObj;
|
|
|
242
264
|
Object.freeze(archiveObj);
|
|
243
265
|
var archiveRoot;
|
|
244
266
|
(function (archiveRoot) {
|
|
245
|
-
archiveRoot.
|
|
246
|
-
function getReqUrlEnd() {
|
|
247
|
-
return `root/archive`;
|
|
248
|
-
}
|
|
249
|
-
archiveRoot.getReqUrlEnd = getReqUrlEnd;
|
|
267
|
+
archiveRoot.EXPRESS_URL_END = 'root/archive';
|
|
250
268
|
function postAndDelReqUrlEnd(version) {
|
|
251
269
|
return `root/archive?ver=${version}`;
|
|
252
270
|
}
|
package/package.json
CHANGED