@tblabs/storage 5.4.1 → 5.5.1
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/Dataset.js +20 -13
- package/IEntitiesSet.d.ts +1 -0
- package/IEntitiesSet.js +1 -0
- package/IStorageUserPrivileges.d.ts +19 -18
- package/IStorageUserPrivileges.js +19 -1
- package/Messages/{AddCommand.d.ts → AddFileCommand.d.ts} +1 -1
- package/Messages/AddFileCommand.js +6 -0
- package/Messages/{UserAddCommand.d.ts → AddUserCommand.d.ts} +1 -1
- package/Messages/AddUserCommand.js +6 -0
- package/Messages/CreateDatasetCommand.d.ts +5 -0
- package/Messages/CreateDatasetCommand.js +6 -0
- package/Messages/DatasetExistsCommand.d.ts +5 -0
- package/Messages/DatasetExistsCommand.js +6 -0
- package/Messages/{DeleteCommand.d.ts → DeleteFileCommand.d.ts} +1 -1
- package/Messages/DeleteFileCommand.js +6 -0
- package/Messages/{UserDeleteCommand.d.ts → DeleteUserCommand.d.ts} +1 -1
- package/Messages/DeleteUserCommand.js +6 -0
- package/Messages/DropDatasetCommand.d.ts +5 -0
- package/Messages/DropDatasetCommand.js +6 -0
- package/Messages/{GetQuery.d.ts → GetFileQuery.d.ts} +1 -1
- package/Messages/{DeleteCommand.js → GetFileQuery.js} +2 -2
- package/Messages/{UserGetQuery.d.ts → GetUserQuery.d.ts} +1 -1
- package/Messages/{UserGetQuery.js → GetUserQuery.js} +2 -2
- package/Messages/ListFilesIdsQuery.d.ts +5 -0
- package/Messages/ListFilesIdsQuery.js +6 -0
- package/Messages/{DropCommand.d.ts → ListFilesQuery.d.ts} +1 -1
- package/Messages/ListFilesQuery.js +6 -0
- package/Messages/{LoginQuery.d.ts → LoginUserQuery.d.ts} +1 -1
- package/Messages/LoginUserQuery.js +6 -0
- package/Messages/{MoveCommand.d.ts → MoveFileCommand.d.ts} +1 -1
- package/Messages/MoveFileCommand.js +6 -0
- package/Messages/RemoveDatasetCommand.d.ts +5 -0
- package/Messages/RemoveDatasetCommand.js +6 -0
- package/Messages/{UpdateCommand.d.ts → UpdateFileCommand.d.ts} +1 -1
- package/Messages/UpdateFileCommand.js +6 -0
- package/Messages/{UserUpdateCommand.d.ts → UpdateUserCommand.d.ts} +1 -1
- package/Messages/UpdateUserCommand.js +6 -0
- package/OnlineStorage.d.ts +3 -0
- package/OnlineStorage.js +27 -36
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/tblabs-storage-5.5.1.tgz +0 -0
- package/Messages/AddCommand.js +0 -6
- package/Messages/AddDirCommand.d.ts +0 -11
- package/Messages/AddDirCommand.js +0 -16
- package/Messages/DropCommand.js +0 -6
- package/Messages/GetQuery.js +0 -6
- package/Messages/ListQuery.d.ts +0 -8
- package/Messages/ListQuery.js +0 -11
- package/Messages/LoginQuery.js +0 -6
- package/Messages/MoveCommand.js +0 -6
- package/Messages/UpdateCommand.js +0 -6
- package/Messages/UserAddCommand.js +0 -6
- package/Messages/UserDeleteCommand.js +0 -6
- package/Messages/UserUpdateCommand.js +0 -6
- package/tblabs-storage-5.4.1.tgz +0 -0
package/Dataset.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { AddFileCommand } from "./Messages/AddFileCommand";
|
|
2
|
+
import { DeleteFileCommand } from "./Messages/DeleteFileCommand";
|
|
3
|
+
import { DropDatasetCommand } from "./Messages/DropDatasetCommand";
|
|
4
|
+
import { ListFilesQuery } from "./Messages/ListFilesQuery";
|
|
5
|
+
import { GetFileQuery } from "./Messages/GetFileQuery";
|
|
6
|
+
import { UpdateFileCommand } from "./Messages/UpdateFileCommand";
|
|
7
|
+
import { ListFilesIdsQuery } from "./Messages/ListFilesIdsQuery";
|
|
7
8
|
export class Dataset {
|
|
8
9
|
_db;
|
|
9
10
|
_converter;
|
|
@@ -33,7 +34,7 @@ export class Dataset {
|
|
|
33
34
|
}
|
|
34
35
|
async GetOne(id) {
|
|
35
36
|
this._db.Log(`Fetching "${id}"...`);
|
|
36
|
-
const queryResult = await this._db.Send(new
|
|
37
|
+
const queryResult = await this._db.Send(new GetFileQuery(this._db.DatabaseDir, this.dataset, id));
|
|
37
38
|
const rawItem = queryResult.Result;
|
|
38
39
|
const item = this._converter.FromRaw(rawItem);
|
|
39
40
|
this._db.Log(`Fetched "${id}" from "${this.DatasetPath}".`);
|
|
@@ -41,7 +42,10 @@ export class Dataset {
|
|
|
41
42
|
}
|
|
42
43
|
async GetAll() {
|
|
43
44
|
this._db.Log(`Fetching all from "${this.DatasetPath}"...`);
|
|
44
|
-
const queryResult = await this._db.Send(new
|
|
45
|
+
const queryResult = await this._db.Send(new ListFilesQuery(this._db.DatabaseDir, this.dataset));
|
|
46
|
+
if (!queryResult.IsSuccess) {
|
|
47
|
+
throw new Error("Failed to fetch all items: " + queryResult.ErrorMessage);
|
|
48
|
+
}
|
|
45
49
|
const rawItems = queryResult.Result;
|
|
46
50
|
const items = rawItems.map((raw) => this._converter.FromRaw(raw));
|
|
47
51
|
this._db.Log(`Fetched ${items.length} items from "${this.DatasetPath}".`);
|
|
@@ -49,7 +53,10 @@ export class Dataset {
|
|
|
49
53
|
}
|
|
50
54
|
async GetAllIds() {
|
|
51
55
|
this._db.Log(`Fetching all files IDs from "${this.DatasetPath}"...`);
|
|
52
|
-
const queryResult = await this._db.Send(new
|
|
56
|
+
const queryResult = await this._db.Send(new ListFilesIdsQuery(this._db.DatabaseDir, this.dataset));
|
|
57
|
+
if (!queryResult.IsSuccess) {
|
|
58
|
+
throw new Error("Failed to fetch all items ids: " + queryResult.ErrorMessage);
|
|
59
|
+
}
|
|
53
60
|
const ids = queryResult.Result;
|
|
54
61
|
this._db.Log(`Found ${ids.length} files in "${this.DatasetPath}".`);
|
|
55
62
|
return ids;
|
|
@@ -57,25 +64,25 @@ export class Dataset {
|
|
|
57
64
|
async Add(id, item) {
|
|
58
65
|
this._db.Log(`Adding "${id}" to "${this.DatasetPath}"...`);
|
|
59
66
|
const rawItem = this._converter.ToRaw(item);
|
|
60
|
-
await this._db.Send(new
|
|
67
|
+
await this._db.Send(new AddFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
61
68
|
this._db.Log(`"${id}" added to "${this.DatasetPath}".`);
|
|
62
69
|
}
|
|
63
70
|
;
|
|
64
71
|
async Update(id, item) {
|
|
65
72
|
this._db.Log(`Updating "${id}"...`);
|
|
66
73
|
const rawItem = this._converter.ToRaw(item);
|
|
67
|
-
await this._db.Send(new
|
|
74
|
+
await this._db.Send(new UpdateFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
68
75
|
this._db.Log(`"${id}" updated in "${this.DatasetPath}".`);
|
|
69
76
|
}
|
|
70
77
|
;
|
|
71
78
|
async Delete(id) {
|
|
72
79
|
this._db.Log(`Deleting "${id}" from "${this.DatasetPath}"...`);
|
|
73
|
-
await this._db.Send(new
|
|
80
|
+
await this._db.Send(new DeleteFileCommand(this._db.DatabaseDir, this.dataset, id));
|
|
74
81
|
this._db.Log(`Deleted "${id}" from "${this.DatasetPath}".`);
|
|
75
82
|
}
|
|
76
83
|
async Drop() {
|
|
77
84
|
this._db.Log(`Dropping "${this.DatasetPath}"...`);
|
|
78
|
-
await this._db.Send(new
|
|
85
|
+
await this._db.Send(new DropDatasetCommand(this._db.DatabaseDir, this.dataset));
|
|
79
86
|
this._db.Log(`"${this.DatasetPath}" dropped.`);
|
|
80
87
|
}
|
|
81
88
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type IEntitiesSet = string[] | "all" | "none";
|
package/IEntitiesSet.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import { IEntitiesSet } from "./IEntitiesSet";
|
|
2
2
|
export interface IStorageUserPrivileges {
|
|
3
|
-
|
|
3
|
+
AddFile: {
|
|
4
4
|
Datasets: IEntitiesSet;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
UpdateFile: {
|
|
7
7
|
Datasets: IEntitiesSet;
|
|
8
8
|
Files: IEntitiesSet;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
DeleteFile: {
|
|
11
11
|
Datasets: IEntitiesSet;
|
|
12
12
|
Files: IEntitiesSet;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
ListFiles: {
|
|
15
15
|
Datasets: IEntitiesSet;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
GetFile: {
|
|
18
18
|
Datasets: IEntitiesSet;
|
|
19
19
|
Files: IEntitiesSet;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
DropDataset: {
|
|
22
22
|
Datasets: IEntitiesSet;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
MoveFile: {
|
|
25
25
|
Datasets: IEntitiesSet;
|
|
26
26
|
Files: IEntitiesSet;
|
|
27
27
|
};
|
|
28
|
-
|
|
28
|
+
CreateDataset: {
|
|
29
29
|
Datasets: IEntitiesSet;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
DatasetExists: {
|
|
32
32
|
Datasets: IEntitiesSet;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
RemoveDataset: {
|
|
35
35
|
Datasets: IEntitiesSet;
|
|
36
36
|
};
|
|
37
|
-
Search:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
Search: boolean;
|
|
38
|
+
ListDatasets: boolean;
|
|
39
|
+
ListUsers: boolean;
|
|
40
|
+
GetUser: boolean;
|
|
41
|
+
UpdateUser: boolean;
|
|
42
|
+
AddUser: boolean;
|
|
43
|
+
DeleteUser: boolean;
|
|
44
44
|
}
|
|
45
|
+
export declare const USER_PRIVILEGES_NAMES: (keyof IStorageUserPrivileges)[];
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const USER_PRIVILEGES_NAMES = [
|
|
2
|
+
"GetFile",
|
|
3
|
+
"AddFile",
|
|
4
|
+
"DropDataset",
|
|
5
|
+
"ListFiles",
|
|
6
|
+
"UpdateFile",
|
|
7
|
+
"DeleteFile",
|
|
8
|
+
"CreateDataset",
|
|
9
|
+
"DatasetExists",
|
|
10
|
+
"RemoveDataset",
|
|
11
|
+
"MoveFile",
|
|
12
|
+
"GetUser",
|
|
13
|
+
"UpdateUser",
|
|
14
|
+
"AddUser",
|
|
15
|
+
"DeleteUser",
|
|
16
|
+
"ListDatasets",
|
|
17
|
+
"ListUsers",
|
|
18
|
+
"Search",
|
|
19
|
+
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
2
|
import { dir } from '../Types/dir';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class AddFileCommand extends Message {
|
|
4
4
|
constructor(Database: dir, Dataset: dir, FileId: string, Content: object);
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IStorageUser } from '../IStorageUser';
|
|
2
2
|
import { Message } from '../MessageBus/Message';
|
|
3
3
|
import { dir } from '../Types/dir';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class AddUserCommand extends Message {
|
|
5
5
|
constructor(Database: dir, User: IStorageUser);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
|
-
export class
|
|
2
|
+
export class GetFileQuery extends Message {
|
|
3
3
|
constructor(Database, Dataset, FileId) {
|
|
4
|
-
super("
|
|
4
|
+
super("GetFile", { Database, Dataset, FileId });
|
|
5
5
|
}
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
|
-
export class
|
|
2
|
+
export class GetUserQuery extends Message {
|
|
3
3
|
constructor(Database, UserId) {
|
|
4
|
-
super("
|
|
4
|
+
super("GetUser", { Database, UserId });
|
|
5
5
|
}
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
2
|
import { dir } from '../Types/dir';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class MoveFileCommand extends Message {
|
|
4
4
|
constructor(Database: dir, FileId: string, Source: dir, Target: dir);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
2
|
import { dir } from '../Types/dir';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class UpdateFileCommand extends Message {
|
|
4
4
|
constructor(Database: dir, Dataset: dir, FileId: string, Content: object);
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IStorageUser } from '../IStorageUser';
|
|
2
2
|
import { Message } from '../MessageBus/Message';
|
|
3
3
|
import { dir } from '../Types/dir';
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class UpdateUserCommand extends Message {
|
|
5
5
|
constructor(Database: dir, User: IStorageUser);
|
|
6
6
|
}
|
package/OnlineStorage.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { MessageBusResponse } from "./MessageBus/MessageBusResponse";
|
|
|
6
6
|
import { Dataset } from "./Dataset";
|
|
7
7
|
import { IStorageUser } from "./IStorageUser";
|
|
8
8
|
import { IConverter } from "./IConverter";
|
|
9
|
+
import { IStorageUserPrivileges } from "./IStorageUserPrivileges";
|
|
9
10
|
export declare class OnlineStorage {
|
|
10
11
|
private server;
|
|
11
12
|
private database;
|
|
@@ -15,6 +16,7 @@ export declare class OnlineStorage {
|
|
|
15
16
|
private readonly _bus;
|
|
16
17
|
private onUserChange;
|
|
17
18
|
private USER_LOCAL_STORAGE_KEY;
|
|
19
|
+
get AvailableUserPrivileges(): (keyof IStorageUserPrivileges)[];
|
|
18
20
|
get Server(): string;
|
|
19
21
|
get DatabaseDir(): dir;
|
|
20
22
|
constructor(server: url, database: dir, sender?: ISender, bus?: MessageBus);
|
|
@@ -36,6 +38,7 @@ export declare class OnlineStorage {
|
|
|
36
38
|
Logout(): this;
|
|
37
39
|
private CallOnUserChanged;
|
|
38
40
|
get IsAuthorized(): boolean;
|
|
41
|
+
get IsNotLoggedIn(): boolean;
|
|
39
42
|
SetUser(user: IStorageUser): this;
|
|
40
43
|
EnableLog(): this;
|
|
41
44
|
DisableLog(): this;
|
package/OnlineStorage.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { MessageBus } from "./MessageBus/MessageBus";
|
|
2
|
-
import {
|
|
2
|
+
import { CreateDatasetCommand } from './Messages/CreateDatasetCommand';
|
|
3
|
+
import { DatasetExistsCommand } from './Messages/DatasetExistsCommand';
|
|
4
|
+
import { RemoveDatasetCommand } from './Messages/RemoveDatasetCommand';
|
|
3
5
|
import { Dataset } from "./Dataset";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import { MoveFileCommand } from "./Messages/MoveFileCommand";
|
|
7
|
+
import { LoginUserQuery } from "./Messages/LoginUserQuery";
|
|
6
8
|
import { ListUsersQuery } from "./Messages/ListUsersQuery";
|
|
7
9
|
import { ListDatasetsQuery } from "./Messages/ListDatabasesQuery";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { UpdateUserCommand } from "./Messages/UpdateUserCommand";
|
|
11
|
+
import { AddUserCommand } from "./Messages/AddUserCommand";
|
|
12
|
+
import { DeleteUserCommand } from "./Messages/DeleteUserCommand";
|
|
13
|
+
import { GetUserQuery } from "./Messages/GetUserQuery";
|
|
14
|
+
import { USER_PRIVILEGES_NAMES } from "./IStorageUserPrivileges";
|
|
12
15
|
export class OnlineStorage {
|
|
13
16
|
server;
|
|
14
17
|
database;
|
|
@@ -18,6 +21,9 @@ export class OnlineStorage {
|
|
|
18
21
|
_bus;
|
|
19
22
|
onUserChange = [];
|
|
20
23
|
USER_LOCAL_STORAGE_KEY = "";
|
|
24
|
+
get AvailableUserPrivileges() {
|
|
25
|
+
return USER_PRIVILEGES_NAMES;
|
|
26
|
+
}
|
|
21
27
|
get Server() {
|
|
22
28
|
return this.server;
|
|
23
29
|
}
|
|
@@ -34,6 +40,7 @@ export class OnlineStorage {
|
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
SetServer(server) {
|
|
43
|
+
this.server = server;
|
|
37
44
|
this._bus.SetServer(server);
|
|
38
45
|
return this;
|
|
39
46
|
}
|
|
@@ -57,7 +64,7 @@ export class OnlineStorage {
|
|
|
57
64
|
return result.Result;
|
|
58
65
|
}
|
|
59
66
|
async GetUser(userId) {
|
|
60
|
-
const result = await this._bus.SendMessage(new
|
|
67
|
+
const result = await this._bus.SendMessage(new GetUserQuery(this.DatabaseDir, userId));
|
|
61
68
|
if (!result.IsSuccess) {
|
|
62
69
|
throw new Error(`Could not get user: ${result.ErrorMessage}`);
|
|
63
70
|
}
|
|
@@ -65,44 +72,25 @@ export class OnlineStorage {
|
|
|
65
72
|
}
|
|
66
73
|
async AddUser(user) {
|
|
67
74
|
this.Log(`Adding user "${user.Id}"...`);
|
|
68
|
-
await this._bus.SendMessage(new
|
|
75
|
+
await this._bus.SendMessage(new AddUserCommand(this.DatabaseDir, user));
|
|
69
76
|
this.Log(`User "${user.Id}" added.`);
|
|
70
77
|
}
|
|
71
78
|
;
|
|
72
79
|
async UpdateUser(user) {
|
|
73
80
|
this.Log(`Updating user "${user.Id}"...`);
|
|
74
|
-
await this._bus.SendMessage(new
|
|
81
|
+
await this._bus.SendMessage(new UpdateUserCommand(this.DatabaseDir, user));
|
|
75
82
|
this.Log(`User "${user.Id}" updated.`);
|
|
76
83
|
}
|
|
77
84
|
;
|
|
78
85
|
async DeleteUser(user) {
|
|
79
86
|
this.Log(`Deleting user "${user.Id}"...`);
|
|
80
|
-
await this._bus.SendMessage(new
|
|
87
|
+
await this._bus.SendMessage(new DeleteUserCommand(this.DatabaseDir, user.Id));
|
|
81
88
|
this.Log(`User "${user.Id}" deleted.`);
|
|
82
89
|
}
|
|
83
90
|
;
|
|
84
91
|
GetDataset(datasetName, converter) {
|
|
85
92
|
return new Dataset(this, converter, datasetName);
|
|
86
93
|
}
|
|
87
|
-
// private WasAnonymousUserEverLoaded(): boolean
|
|
88
|
-
// {
|
|
89
|
-
// return (this.User.Id === this.ANONYMOUS_USER.Id && this.user.Privileges !== undefined);
|
|
90
|
-
// }
|
|
91
|
-
// public SetAnonymousUserPrivileges(privileges: IStorageUserPrivileges): this
|
|
92
|
-
// {
|
|
93
|
-
// this.user.Privileges = privileges;
|
|
94
|
-
// return this;
|
|
95
|
-
// }
|
|
96
|
-
// public async InitOnce()
|
|
97
|
-
// {
|
|
98
|
-
// // console.log("INIT", this.WasAnonymousUserEverLoaded());
|
|
99
|
-
// if (this.WasAnonymousUserEverLoaded())
|
|
100
|
-
// {
|
|
101
|
-
// // console.log("INIT RETURN WasAnonymousUserEverLoaded()=true");
|
|
102
|
-
// return;
|
|
103
|
-
// }
|
|
104
|
-
// this.user = await this.Login("Anonymous"); // TODO: Tutaj można my zrobić dedykowaną metode do pobierania ustawień użytkownika Anonymous
|
|
105
|
-
// }
|
|
106
94
|
IsBrowserEnvironment() {
|
|
107
95
|
return typeof window !== "undefined" && typeof window.localStorage !== "undefined";
|
|
108
96
|
}
|
|
@@ -121,7 +109,7 @@ export class OnlineStorage {
|
|
|
121
109
|
return this.user;
|
|
122
110
|
}
|
|
123
111
|
async Login(password) {
|
|
124
|
-
const result = await this._bus.SendMessage(new
|
|
112
|
+
const result = await this._bus.SendMessage(new LoginUserQuery(this.DatabaseDir, password));
|
|
125
113
|
if (!result.IsSuccess) {
|
|
126
114
|
throw new Error(`Could not login: ${result.ErrorMessage}`);
|
|
127
115
|
}
|
|
@@ -170,7 +158,10 @@ export class OnlineStorage {
|
|
|
170
158
|
this.onUserChange.forEach(handler => handler(this.user, this.IsAuthorized, appStart));
|
|
171
159
|
}
|
|
172
160
|
get IsAuthorized() {
|
|
173
|
-
return this.user.Id !== this.ANONYMOUS_USER.Id;
|
|
161
|
+
return this.user && this.user.Id !== this.ANONYMOUS_USER.Id;
|
|
162
|
+
}
|
|
163
|
+
get IsNotLoggedIn() {
|
|
164
|
+
return !this.user || this.user.Id === this.ANONYMOUS_USER.Id;
|
|
174
165
|
}
|
|
175
166
|
SetUser(user) {
|
|
176
167
|
this.user = user;
|
|
@@ -202,7 +193,7 @@ export class OnlineStorage {
|
|
|
202
193
|
}
|
|
203
194
|
async CreateDataset(datasetName) {
|
|
204
195
|
this.Log(`Creating dataset "${datasetName}"...`);
|
|
205
|
-
const result = await this._bus.SendMessage(new
|
|
196
|
+
const result = await this._bus.SendMessage(new CreateDatasetCommand(this.DatabaseDir, datasetName));
|
|
206
197
|
if (!result.IsSuccess) {
|
|
207
198
|
throw new Error(`Could not add dataset: ${result.ErrorMessage}`);
|
|
208
199
|
}
|
|
@@ -210,7 +201,7 @@ export class OnlineStorage {
|
|
|
210
201
|
}
|
|
211
202
|
async DatasetExists(datasetName) {
|
|
212
203
|
this.Log(`Checking if dataset "${datasetName}" exists...`);
|
|
213
|
-
const result = await this._bus.SendMessage(new
|
|
204
|
+
const result = await this._bus.SendMessage(new DatasetExistsCommand(this.DatabaseDir, datasetName));
|
|
214
205
|
if (!result.IsSuccess) {
|
|
215
206
|
throw new Error(`Could not check if dataset exists: ${result.ErrorMessage}`);
|
|
216
207
|
}
|
|
@@ -219,7 +210,7 @@ export class OnlineStorage {
|
|
|
219
210
|
}
|
|
220
211
|
async RemoveDataset(datasetName) {
|
|
221
212
|
this.Log(`Removing dataset "${datasetName}"...`);
|
|
222
|
-
const result = await this._bus.SendMessage(new
|
|
213
|
+
const result = await this._bus.SendMessage(new RemoveDatasetCommand(this.DatabaseDir, datasetName));
|
|
223
214
|
if (!result.IsSuccess) {
|
|
224
215
|
throw new Error(`Could not remove dataset: ${result.ErrorMessage}`);
|
|
225
216
|
}
|
|
@@ -227,7 +218,7 @@ export class OnlineStorage {
|
|
|
227
218
|
}
|
|
228
219
|
async Move(fileId, sourceDataset, targetDataset) {
|
|
229
220
|
this.Log(`Moving "${fileId}" from "${sourceDataset.Name}" to "${targetDataset.Name}"...`);
|
|
230
|
-
const result = await this._bus.SendMessage(new
|
|
221
|
+
const result = await this._bus.SendMessage(new MoveFileCommand(this.DatabaseDir, fileId, sourceDataset.Name, targetDataset.Name));
|
|
231
222
|
if (!result.IsSuccess) {
|
|
232
223
|
throw new Error(`Could not move "${fileId}" from "${sourceDataset.Name}" to "${targetDataset.Name}": ${result.ErrorMessage}`);
|
|
233
224
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
Binary file
|
package/Messages/AddCommand.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Message } from '../MessageBus/Message';
|
|
2
|
-
import { dir } from '../Types/dir';
|
|
3
|
-
export declare class CreateCommand extends Message {
|
|
4
|
-
constructor(Database: dir, Dataset: dir);
|
|
5
|
-
}
|
|
6
|
-
export declare class ExistsCommand extends Message {
|
|
7
|
-
constructor(Database: dir, Dataset: dir);
|
|
8
|
-
}
|
|
9
|
-
export declare class RemoveCommand extends Message {
|
|
10
|
-
constructor(Database: dir, Dataset: dir);
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Message } from '../MessageBus/Message';
|
|
2
|
-
export class CreateCommand extends Message {
|
|
3
|
-
constructor(Database, Dataset) {
|
|
4
|
-
super("Create", { Database, Dataset });
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export class ExistsCommand extends Message {
|
|
8
|
-
constructor(Database, Dataset) {
|
|
9
|
-
super("Exists", { Database, Dataset });
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class RemoveCommand extends Message {
|
|
13
|
-
constructor(Database, Dataset) {
|
|
14
|
-
super("Remove", { Database, Dataset });
|
|
15
|
-
}
|
|
16
|
-
}
|
package/Messages/DropCommand.js
DELETED
package/Messages/GetQuery.js
DELETED
package/Messages/ListQuery.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Message } from '../MessageBus/Message';
|
|
2
|
-
import { dir } from '../Types/dir';
|
|
3
|
-
export declare class ListQuery extends Message {
|
|
4
|
-
constructor(Database: dir, Dataset: dir);
|
|
5
|
-
}
|
|
6
|
-
export declare class ListIdsQuery extends Message {
|
|
7
|
-
constructor(Database: dir, Dataset: dir);
|
|
8
|
-
}
|
package/Messages/ListQuery.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Message } from '../MessageBus/Message';
|
|
2
|
-
export class ListQuery extends Message {
|
|
3
|
-
constructor(Database, Dataset) {
|
|
4
|
-
super("List", { Database, Dataset });
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export class ListIdsQuery extends Message {
|
|
8
|
-
constructor(Database, Dataset) {
|
|
9
|
-
super("ListIds", { Database, Dataset });
|
|
10
|
-
}
|
|
11
|
-
}
|
package/Messages/LoginQuery.js
DELETED
package/Messages/MoveCommand.js
DELETED
package/tblabs-storage-5.4.1.tgz
DELETED
|
Binary file
|