@tblabs/storage 5.5.1 → 5.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/IStorageUserPrivileges.d.ts +1 -0
- package/IStorageUserPrivileges.js +1 -0
- package/MessageBus/Message.d.ts +7 -2
- package/Messages/GetLogQuery.d.ts +5 -0
- package/Messages/GetLogQuery.js +6 -0
- package/Messages/GetLogsListQuery.d.ts +5 -0
- package/Messages/GetLogsListQuery.js +6 -0
- package/Messages/LoginUserQuery.d.ts +1 -1
- package/Messages/LoginUserQuery.js +2 -2
- package/OnlineStorage.d.ts +6 -1
- package/OnlineStorage.js +24 -2
- package/package.json +2 -1
- package/tblabs-storage-5.6.0.tgz +0 -0
- package/tblabs-storage-5.5.1.tgz +0 -0
package/MessageBus/Message.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { dir } from "../Types/dir";
|
|
2
|
+
export interface MessageBody {
|
|
3
|
+
Database: dir;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
1
6
|
export declare class Message {
|
|
2
7
|
Name: string;
|
|
3
|
-
Body:
|
|
4
|
-
constructor(Name: string, Body:
|
|
8
|
+
Body: MessageBody;
|
|
9
|
+
constructor(Name: string, Body: MessageBody);
|
|
5
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "../MessageBus/Message";
|
|
2
2
|
export class LoginUserQuery extends Message {
|
|
3
|
-
constructor(Database, Password) {
|
|
4
|
-
super("LoginUser", { Database, Password });
|
|
3
|
+
constructor(Database, Password, Login) {
|
|
4
|
+
super("LoginUser", { Database, Password, Login });
|
|
5
5
|
}
|
|
6
6
|
}
|
package/OnlineStorage.d.ts
CHANGED
|
@@ -32,7 +32,10 @@ export declare class OnlineStorage {
|
|
|
32
32
|
private IsBrowserEnvironment;
|
|
33
33
|
private LoadUserFromLocalStorage;
|
|
34
34
|
get User(): IStorageUser;
|
|
35
|
-
Login(password: string): Promise<IStorageUser>;
|
|
35
|
+
Login(password: string, login?: string): Promise<IStorageUser>;
|
|
36
|
+
SetLoginPolicy(): void;
|
|
37
|
+
GetNextPassword(): void;
|
|
38
|
+
SetDefaultPrivileges(byRole: Record<string, IStorageUserPrivileges>): void;
|
|
36
39
|
private SaveUserInLocalStorage;
|
|
37
40
|
OnUserChange(handler: (user: IStorageUser, isAuthorized: boolean, appStart: boolean) => void): this;
|
|
38
41
|
Logout(): this;
|
|
@@ -49,4 +52,6 @@ export declare class OnlineStorage {
|
|
|
49
52
|
DatasetExists(datasetName: string): Promise<boolean>;
|
|
50
53
|
RemoveDataset(datasetName: string): Promise<void>;
|
|
51
54
|
Move(fileId: string, sourceDataset: Dataset<any>, targetDataset: Dataset<any>): Promise<void>;
|
|
55
|
+
GetLogsList(): Promise<string[]>;
|
|
56
|
+
GetLog(id: string): Promise<string>;
|
|
52
57
|
}
|
package/OnlineStorage.js
CHANGED
|
@@ -12,6 +12,8 @@ import { AddUserCommand } from "./Messages/AddUserCommand";
|
|
|
12
12
|
import { DeleteUserCommand } from "./Messages/DeleteUserCommand";
|
|
13
13
|
import { GetUserQuery } from "./Messages/GetUserQuery";
|
|
14
14
|
import { USER_PRIVILEGES_NAMES } from "./IStorageUserPrivileges";
|
|
15
|
+
import { GetLogQuery } from "./Messages/GetLogQuery";
|
|
16
|
+
import { ListLogsIdsQuery } from "./Messages/GetLogsListQuery";
|
|
15
17
|
export class OnlineStorage {
|
|
16
18
|
server;
|
|
17
19
|
database;
|
|
@@ -108,8 +110,8 @@ export class OnlineStorage {
|
|
|
108
110
|
get User() {
|
|
109
111
|
return this.user;
|
|
110
112
|
}
|
|
111
|
-
async Login(password) {
|
|
112
|
-
const result = await this._bus.SendMessage(new LoginUserQuery(this.DatabaseDir, password));
|
|
113
|
+
async Login(password, login) {
|
|
114
|
+
const result = await this._bus.SendMessage(new LoginUserQuery(this.DatabaseDir, password, login));
|
|
113
115
|
if (!result.IsSuccess) {
|
|
114
116
|
throw new Error(`Could not login: ${result.ErrorMessage}`);
|
|
115
117
|
}
|
|
@@ -119,6 +121,12 @@ export class OnlineStorage {
|
|
|
119
121
|
this.CallOnUserChanged(false);
|
|
120
122
|
return this.user;
|
|
121
123
|
}
|
|
124
|
+
SetLoginPolicy() {
|
|
125
|
+
}
|
|
126
|
+
GetNextPassword() {
|
|
127
|
+
}
|
|
128
|
+
SetDefaultPrivileges(byRole) {
|
|
129
|
+
}
|
|
122
130
|
SaveUserInLocalStorage() {
|
|
123
131
|
if (this.IsBrowserEnvironment()) {
|
|
124
132
|
window.localStorage.setItem(this.USER_LOCAL_STORAGE_KEY, JSON.stringify(this.user));
|
|
@@ -224,4 +232,18 @@ export class OnlineStorage {
|
|
|
224
232
|
}
|
|
225
233
|
this.Log(`"${fileId}" moved from "${sourceDataset.Name}" to "${targetDataset.Name}".`);
|
|
226
234
|
}
|
|
235
|
+
async GetLogsList() {
|
|
236
|
+
const result = await this._bus.SendMessage(new ListLogsIdsQuery(this.DatabaseDir));
|
|
237
|
+
if (!result.IsSuccess) {
|
|
238
|
+
throw new Error(`Could not get logs list: ${result.ErrorMessage}`);
|
|
239
|
+
}
|
|
240
|
+
return result.Result;
|
|
241
|
+
}
|
|
242
|
+
async GetLog(id) {
|
|
243
|
+
const result = await this._bus.SendMessage(new GetLogQuery(this.DatabaseDir, id));
|
|
244
|
+
if (!result.IsSuccess) {
|
|
245
|
+
throw new Error(`Could not get log '${id}': ${result.ErrorMessage}`);
|
|
246
|
+
}
|
|
247
|
+
return result.Result;
|
|
248
|
+
}
|
|
227
249
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tblabs/storage",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "online storage module with auth",
|
|
5
5
|
"license": "beerware",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"test": "jest --runInBand",
|
|
9
10
|
"pack": "cd ./bin && npm pack",
|
|
10
11
|
"clean": "rm ./bin -rf && rm *.tgz -rf",
|
|
11
12
|
"build": "npm run clean && tsc ./src/index.ts --declaration --outDir ./bin && cp ./package.json ./bin/package.json",
|
|
Binary file
|
package/tblabs-storage-5.5.1.tgz
DELETED
|
Binary file
|