@tblabs/storage 5.7.1 → 5.7.3
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.d.ts +2 -1
- package/Dataset.js +25 -7
- package/OnlineStorage.d.ts +0 -3
- package/OnlineStorage.js +0 -6
- package/package.json +1 -1
- package/tblabs-storage-5.7.3.tgz +0 -0
- package/tblabs-storage-5.7.1.tgz +0 -0
package/Dataset.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export declare class Dataset<T extends object> implements IRepo<T> {
|
|
|
7
7
|
private _db;
|
|
8
8
|
private _converter;
|
|
9
9
|
private dataset;
|
|
10
|
-
get Name(): string;
|
|
11
10
|
constructor(_db: OnlineStorage, _converter: IConverter<any, T>, dataset: dir);
|
|
11
|
+
get Name(): string;
|
|
12
|
+
get Database(): OnlineStorage;
|
|
12
13
|
private get DatasetPath();
|
|
13
14
|
CanUserDo(action: keyof IStorageUserPrivileges): boolean;
|
|
14
15
|
GetOne(id: string): Promise<T>;
|
package/Dataset.js
CHANGED
|
@@ -9,14 +9,17 @@ export class Dataset {
|
|
|
9
9
|
_db;
|
|
10
10
|
_converter;
|
|
11
11
|
dataset;
|
|
12
|
-
get Name() {
|
|
13
|
-
return this.dataset;
|
|
14
|
-
}
|
|
15
12
|
constructor(_db, _converter, dataset) {
|
|
16
13
|
this._db = _db;
|
|
17
14
|
this._converter = _converter;
|
|
18
15
|
this.dataset = dataset;
|
|
19
16
|
}
|
|
17
|
+
get Name() {
|
|
18
|
+
return this.dataset;
|
|
19
|
+
}
|
|
20
|
+
get Database() {
|
|
21
|
+
return this._db;
|
|
22
|
+
}
|
|
20
23
|
get DatasetPath() {
|
|
21
24
|
return this._db.DatabaseDir + "/Datasets/" + this.dataset;
|
|
22
25
|
}
|
|
@@ -35,6 +38,9 @@ export class Dataset {
|
|
|
35
38
|
async GetOne(id) {
|
|
36
39
|
this._db.Log(`Fetching "${id}"...`);
|
|
37
40
|
const queryResult = await this._db.Send(new GetFileQuery(this._db.DatabaseDir, this.dataset, id));
|
|
41
|
+
if (!queryResult.IsSuccess) {
|
|
42
|
+
throw new Error("Failed to get one item: " + queryResult.ErrorMessage);
|
|
43
|
+
}
|
|
38
44
|
const rawItem = queryResult.Result;
|
|
39
45
|
const item = this._converter.FromRaw(rawItem);
|
|
40
46
|
this._db.Log(`Fetched "${id}" from "${this.DatasetPath}".`);
|
|
@@ -64,25 +70,37 @@ export class Dataset {
|
|
|
64
70
|
async Add(id, item) {
|
|
65
71
|
this._db.Log(`Adding "${id}" to "${this.DatasetPath}"...`);
|
|
66
72
|
const rawItem = this._converter.ToRaw(item);
|
|
67
|
-
await this._db.Send(new AddFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
73
|
+
const result = await this._db.Send(new AddFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
74
|
+
if (!result.IsSuccess) {
|
|
75
|
+
throw new Error("Failed to add item: " + result.ErrorMessage);
|
|
76
|
+
}
|
|
68
77
|
this._db.Log(`"${id}" added to "${this.DatasetPath}".`);
|
|
69
78
|
}
|
|
70
79
|
;
|
|
71
80
|
async Update(id, item) {
|
|
72
81
|
this._db.Log(`Updating "${id}"...`);
|
|
73
82
|
const rawItem = this._converter.ToRaw(item);
|
|
74
|
-
await this._db.Send(new UpdateFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
83
|
+
const result = await this._db.Send(new UpdateFileCommand(this._db.DatabaseDir, this.dataset, id, rawItem));
|
|
84
|
+
if (!result.IsSuccess) {
|
|
85
|
+
throw new Error("Failed to update item: " + result.ErrorMessage);
|
|
86
|
+
}
|
|
75
87
|
this._db.Log(`"${id}" updated in "${this.DatasetPath}".`);
|
|
76
88
|
}
|
|
77
89
|
;
|
|
78
90
|
async Delete(id) {
|
|
79
91
|
this._db.Log(`Deleting "${id}" from "${this.DatasetPath}"...`);
|
|
80
|
-
await this._db.Send(new DeleteFileCommand(this._db.DatabaseDir, this.dataset, id));
|
|
92
|
+
const result = await this._db.Send(new DeleteFileCommand(this._db.DatabaseDir, this.dataset, id));
|
|
93
|
+
if (!result.IsSuccess) {
|
|
94
|
+
throw new Error("Failed to delete item: " + result.ErrorMessage);
|
|
95
|
+
}
|
|
81
96
|
this._db.Log(`Deleted "${id}" from "${this.DatasetPath}".`);
|
|
82
97
|
}
|
|
83
98
|
async Drop() {
|
|
84
99
|
this._db.Log(`Dropping "${this.DatasetPath}"...`);
|
|
85
|
-
await this._db.Send(new DropDatasetCommand(this._db.DatabaseDir, this.dataset));
|
|
100
|
+
const result = await this._db.Send(new DropDatasetCommand(this._db.DatabaseDir, this.dataset));
|
|
101
|
+
if (!result.IsSuccess) {
|
|
102
|
+
throw new Error("Failed to drop dataset: " + result.ErrorMessage);
|
|
103
|
+
}
|
|
86
104
|
this._db.Log(`"${this.DatasetPath}" dropped.`);
|
|
87
105
|
}
|
|
88
106
|
}
|
package/OnlineStorage.d.ts
CHANGED
|
@@ -34,9 +34,6 @@ export declare class OnlineStorage {
|
|
|
34
34
|
private LoadUserFromLocalStorage;
|
|
35
35
|
get User(): IStorageUser;
|
|
36
36
|
Login(password: string, login?: string): Promise<IStorageUser>;
|
|
37
|
-
SetLoginPolicy(): void;
|
|
38
|
-
GetNextPassword(): void;
|
|
39
|
-
SetDefaultPrivileges(byRole: Record<string, IStorageUserPrivileges>): void;
|
|
40
37
|
private SaveUserInLocalStorage;
|
|
41
38
|
OnUserChange(handler: (user: IStorageUser, isAuthorized: boolean, appStart: boolean) => void): this;
|
|
42
39
|
Logout(): this;
|
package/OnlineStorage.js
CHANGED
|
@@ -124,12 +124,6 @@ export class OnlineStorage {
|
|
|
124
124
|
this.CallOnUserChanged(false);
|
|
125
125
|
return this.user;
|
|
126
126
|
}
|
|
127
|
-
SetLoginPolicy() {
|
|
128
|
-
}
|
|
129
|
-
GetNextPassword() {
|
|
130
|
-
}
|
|
131
|
-
SetDefaultPrivileges(byRole) {
|
|
132
|
-
}
|
|
133
127
|
SaveUserInLocalStorage() {
|
|
134
128
|
if (this.IsBrowserEnvironment()) {
|
|
135
129
|
window.localStorage.setItem(this.USER_LOCAL_STORAGE_KEY, JSON.stringify(this.user));
|
package/package.json
CHANGED
|
Binary file
|
package/tblabs-storage-5.7.1.tgz
DELETED
|
Binary file
|