@tblabs/storage 5.5.2 → 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.
@@ -37,6 +37,7 @@ export interface IStorageUserPrivileges {
37
37
  Search: boolean;
38
38
  ListDatasets: boolean;
39
39
  ListUsers: boolean;
40
+ GetLogs: boolean;
40
41
  GetUser: boolean;
41
42
  UpdateUser: boolean;
42
43
  AddUser: boolean;
@@ -16,4 +16,5 @@ export const USER_PRIVILEGES_NAMES = [
16
16
  "ListDatasets",
17
17
  "ListUsers",
18
18
  "Search",
19
+ "GetLogs",
19
20
  ];
@@ -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: any;
4
- constructor(Name: string, Body: any);
8
+ Body: MessageBody;
9
+ constructor(Name: string, Body: MessageBody);
5
10
  }
@@ -0,0 +1,5 @@
1
+ import { Message } from '../MessageBus/Message';
2
+ import { dir } from '../Types/dir';
3
+ export declare class GetLogQuery extends Message {
4
+ constructor(Database: dir, Id: string);
5
+ }
@@ -0,0 +1,6 @@
1
+ import { Message } from '../MessageBus/Message';
2
+ export class GetLogQuery extends Message {
3
+ constructor(Database, Id) {
4
+ super("GetLog", { Database, Id });
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ import { Message } from '../MessageBus/Message';
2
+ import { dir } from '../Types/dir';
3
+ export declare class ListLogsIdsQuery extends Message {
4
+ constructor(Database: dir);
5
+ }
@@ -0,0 +1,6 @@
1
+ import { Message } from '../MessageBus/Message';
2
+ export class ListLogsIdsQuery extends Message {
3
+ constructor(Database) {
4
+ super("ListLogsIds", { Database });
5
+ }
6
+ }
@@ -52,4 +52,6 @@ export declare class OnlineStorage {
52
52
  DatasetExists(datasetName: string): Promise<boolean>;
53
53
  RemoveDataset(datasetName: string): Promise<void>;
54
54
  Move(fileId: string, sourceDataset: Dataset<any>, targetDataset: Dataset<any>): Promise<void>;
55
+ GetLogsList(): Promise<string[]>;
56
+ GetLog(id: string): Promise<string>;
55
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;
@@ -230,4 +232,18 @@ export class OnlineStorage {
230
232
  }
231
233
  this.Log(`"${fileId}" moved from "${sourceDataset.Name}" to "${targetDataset.Name}".`);
232
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
+ }
233
249
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@tblabs/storage",
3
- "version": "5.5.2",
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
Binary file