@tblabs/storage 5.5.2 → 5.7.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/CreateDatabaseCommand.d.ts +5 -0
- package/CreateDatabaseCommand.js +6 -0
- package/DeleteDatabaseCommand.d.ts +5 -0
- package/DeleteDatabaseCommand.js +6 -0
- package/IStorageUserPrivileges.d.ts +4 -0
- package/IStorageUserPrivileges.js +1 -0
- package/ListDatabasesQuery.d.ts +4 -0
- package/ListDatabasesQuery.js +6 -0
- package/MessageBus/Message.d.ts +5 -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/OnlineStorage.d.ts +10 -0
- package/OnlineStorage.js +61 -1
- package/package.json +2 -1
- package/tblabs-storage-5.7.0.tgz +0 -0
- package/tblabs-storage-5.5.2.tgz +0 -0
|
@@ -37,6 +37,10 @@ export interface IStorageUserPrivileges {
|
|
|
37
37
|
Search: boolean;
|
|
38
38
|
ListDatasets: boolean;
|
|
39
39
|
ListUsers: boolean;
|
|
40
|
+
GetLogs: boolean;
|
|
41
|
+
ListDatabases: boolean;
|
|
42
|
+
CreateDatabase: boolean;
|
|
43
|
+
DeleteDatabase: boolean;
|
|
40
44
|
GetUser: boolean;
|
|
41
45
|
UpdateUser: boolean;
|
|
42
46
|
AddUser: boolean;
|
package/MessageBus/Message.d.ts
CHANGED
package/OnlineStorage.d.ts
CHANGED
|
@@ -52,4 +52,14 @@ 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>;
|
|
57
|
+
ListDatabases(): Promise<DatabaseInfo[]>;
|
|
58
|
+
CreateDatabase(databaseDir: string): Promise<void>;
|
|
59
|
+
DeleteDatabase(databaseDir: string): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface DatabaseInfo {
|
|
62
|
+
Dir: string;
|
|
63
|
+
DatasetsCount: number;
|
|
64
|
+
UsersCount: number;
|
|
55
65
|
}
|
package/OnlineStorage.js
CHANGED
|
@@ -6,12 +6,17 @@ import { Dataset } from "./Dataset";
|
|
|
6
6
|
import { MoveFileCommand } from "./Messages/MoveFileCommand";
|
|
7
7
|
import { LoginUserQuery } from "./Messages/LoginUserQuery";
|
|
8
8
|
import { ListUsersQuery } from "./Messages/ListUsersQuery";
|
|
9
|
-
import { ListDatasetsQuery } from "./Messages/ListDatabasesQuery";
|
|
10
9
|
import { UpdateUserCommand } from "./Messages/UpdateUserCommand";
|
|
11
10
|
import { AddUserCommand } from "./Messages/AddUserCommand";
|
|
12
11
|
import { DeleteUserCommand } from "./Messages/DeleteUserCommand";
|
|
13
12
|
import { GetUserQuery } from "./Messages/GetUserQuery";
|
|
14
13
|
import { USER_PRIVILEGES_NAMES } from "./IStorageUserPrivileges";
|
|
14
|
+
import { GetLogQuery } from "./Messages/GetLogQuery";
|
|
15
|
+
import { ListLogsIdsQuery } from "./Messages/GetLogsListQuery";
|
|
16
|
+
import { ListDatabasesQuery } from "./ListDatabasesQuery";
|
|
17
|
+
import { CreateDatabaseCommand } from "./CreateDatabaseCommand";
|
|
18
|
+
import { ListDatasetsQuery } from "./Messages/ListDatabasesQuery";
|
|
19
|
+
import { DeleteDatabaseCommand } from "./DeleteDatabaseCommand";
|
|
15
20
|
export class OnlineStorage {
|
|
16
21
|
server;
|
|
17
22
|
database;
|
|
@@ -230,4 +235,59 @@ export class OnlineStorage {
|
|
|
230
235
|
}
|
|
231
236
|
this.Log(`"${fileId}" moved from "${sourceDataset.Name}" to "${targetDataset.Name}".`);
|
|
232
237
|
}
|
|
238
|
+
async GetLogsList() {
|
|
239
|
+
const result = await this._bus.SendMessage(new ListLogsIdsQuery(this.DatabaseDir));
|
|
240
|
+
if (!result.IsSuccess) {
|
|
241
|
+
throw new Error(`Could not get logs list: ${result.ErrorMessage}`);
|
|
242
|
+
}
|
|
243
|
+
return result.Result;
|
|
244
|
+
}
|
|
245
|
+
async GetLog(id) {
|
|
246
|
+
const result = await this._bus.SendMessage(new GetLogQuery(this.DatabaseDir, id));
|
|
247
|
+
if (!result.IsSuccess) {
|
|
248
|
+
throw new Error(`Could not get log '${id}': ${result.ErrorMessage}`);
|
|
249
|
+
}
|
|
250
|
+
return result.Result;
|
|
251
|
+
}
|
|
252
|
+
/*
|
|
253
|
+
Search() USAGE:
|
|
254
|
+
|
|
255
|
+
datasetId = storage.Search(fileId)
|
|
256
|
+
file = dataset.GetOne(fileId)
|
|
257
|
+
|
|
258
|
+
;/ to jest bardziej problematyczne niż myślałem.....
|
|
259
|
+
bo gdzieś przecież trzeba konwersji typu dokonać a sam search odbywa się na całej bazie
|
|
260
|
+
*/
|
|
261
|
+
// public async Search<T extends object>(fileId: string): Promise<Dataset<T>>
|
|
262
|
+
// {
|
|
263
|
+
// this.Log(`Searching for "${fileId}" in entire database...`);
|
|
264
|
+
// const result = await this._bus.SendMessage(new SearchQuery(this.DatabaseDir, fileId));
|
|
265
|
+
// if (!result.IsSuccess)
|
|
266
|
+
// {
|
|
267
|
+
// throw new Error(`Could not find "${fileId}": ${result.ErrorMessage}`);
|
|
268
|
+
// }
|
|
269
|
+
// const datasetName = result.Result.Dataset;
|
|
270
|
+
// const dataset = this.GetDataset<T>(datasetName, converter); ?????????
|
|
271
|
+
// this.Log(`"${fileId}" found in "${dataset} dataset".`);
|
|
272
|
+
// return result.Result;
|
|
273
|
+
// }
|
|
274
|
+
async ListDatabases() {
|
|
275
|
+
const result = await this._bus.SendMessage(new ListDatabasesQuery());
|
|
276
|
+
if (!result.IsSuccess) {
|
|
277
|
+
throw new Error(`Could not list databases: ${result.ErrorMessage}`);
|
|
278
|
+
}
|
|
279
|
+
return result.Result;
|
|
280
|
+
}
|
|
281
|
+
async CreateDatabase(databaseDir) {
|
|
282
|
+
const result = await this._bus.SendMessage(new CreateDatabaseCommand(databaseDir));
|
|
283
|
+
if (!result.IsSuccess) {
|
|
284
|
+
throw new Error(`Could not create database: ${result.ErrorMessage}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async DeleteDatabase(databaseDir) {
|
|
288
|
+
const result = await this._bus.SendMessage(new DeleteDatabaseCommand(databaseDir));
|
|
289
|
+
if (!result.IsSuccess) {
|
|
290
|
+
throw new Error(`Could not delete database: ${result.ErrorMessage}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
233
293
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tblabs/storage",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.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.2.tgz
DELETED
|
Binary file
|