@tblabs/storage 5.8.2 → 5.9.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/Dataset.d.ts +3 -0
- package/Dataset.js +24 -0
- package/DatasetInfo.d.ts +4 -0
- package/DatasetInfo.js +1 -0
- package/DummyConverter.d.ts +5 -0
- package/DummyConverter.js +8 -0
- package/Messages/AppendCommand.d.ts +5 -0
- package/Messages/AppendCommand.js +6 -0
- package/Messages/ReadFileQuery.d.ts +5 -0
- package/Messages/ReadFileQuery.js +6 -0
- package/OnlineStorage.d.ts +2 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/tblabs-storage-5.9.0.tgz +0 -0
- package/tblabs-storage-5.8.2.tgz +0 -0
package/Dataset.d.ts
CHANGED
|
@@ -13,9 +13,12 @@ export declare class Dataset<T extends object> implements IRepo<T> {
|
|
|
13
13
|
private get DatasetPath();
|
|
14
14
|
CanUserDo(action: keyof IStorageUserPrivileges): boolean;
|
|
15
15
|
GetOne(id: string): Promise<T>;
|
|
16
|
+
Read(id: string, length?: number, offset?: number): Promise<string>;
|
|
16
17
|
GetAll(): Promise<T[]>;
|
|
17
18
|
GetAllIds(): Promise<string[]>;
|
|
18
19
|
Add(id: string, item: T): Promise<void>;
|
|
20
|
+
Append(id: string, text: string): Promise<void>;
|
|
21
|
+
AppendLine(id: string, line: string): Promise<void>;
|
|
19
22
|
Update(id: string, item: T): Promise<void>;
|
|
20
23
|
Delete(id: string): Promise<void>;
|
|
21
24
|
Drop(): Promise<void>;
|
package/Dataset.js
CHANGED
|
@@ -5,6 +5,8 @@ import { ListFilesQuery } from "./Messages/ListFilesQuery";
|
|
|
5
5
|
import { GetFileQuery } from "./Messages/GetFileQuery";
|
|
6
6
|
import { UpdateFileCommand } from "./Messages/UpdateFileCommand";
|
|
7
7
|
import { ListFilesIdsQuery } from "./Messages/ListFilesIdsQuery";
|
|
8
|
+
import { AppendCommand } from "./Messages/AppendCommand";
|
|
9
|
+
import { ReadFileQuery } from "./Messages/ReadFileQuery";
|
|
8
10
|
export class Dataset {
|
|
9
11
|
_db;
|
|
10
12
|
_converter;
|
|
@@ -46,6 +48,16 @@ export class Dataset {
|
|
|
46
48
|
this._db.Log(`Fetched "${id}" from "${this.DatasetPath}".`);
|
|
47
49
|
return item;
|
|
48
50
|
}
|
|
51
|
+
async Read(id, length = 0, offset = 0) {
|
|
52
|
+
this._db.Log(`Reading "${id}" from "${this.DatasetPath}"...`);
|
|
53
|
+
const queryResult = await this._db.Send(new ReadFileQuery(this._db.DatabaseDir, this.dataset, id, length, offset));
|
|
54
|
+
if (!queryResult.IsSuccess) {
|
|
55
|
+
throw new Error("Failed to read: " + queryResult.ErrorMessage);
|
|
56
|
+
}
|
|
57
|
+
const content = queryResult.Result;
|
|
58
|
+
this._db.Log(`Read ${content.length} characters from "${id}" in "${this.DatasetPath}".`);
|
|
59
|
+
return content;
|
|
60
|
+
}
|
|
49
61
|
async GetAll() {
|
|
50
62
|
this._db.Log(`Fetching all from "${this.DatasetPath}"...`);
|
|
51
63
|
const queryResult = await this._db.Send(new ListFilesQuery(this._db.DatabaseDir, this.dataset));
|
|
@@ -77,6 +89,18 @@ export class Dataset {
|
|
|
77
89
|
this._db.Log(`"${id}" added to "${this.DatasetPath}".`);
|
|
78
90
|
}
|
|
79
91
|
;
|
|
92
|
+
async Append(id, text) {
|
|
93
|
+
this._db.Log(`Appending ${text.length} characters to "${id}" in "${this.DatasetPath}"...`);
|
|
94
|
+
const result = await this._db.Send(new AppendCommand(this._db.DatabaseDir, this.dataset, id, text));
|
|
95
|
+
if (!result.IsSuccess) {
|
|
96
|
+
throw new Error("Failed to append: " + result.ErrorMessage);
|
|
97
|
+
}
|
|
98
|
+
this._db.Log(`${text.length} characters appended to "${id}" in "${this.DatasetPath}".`);
|
|
99
|
+
}
|
|
100
|
+
;
|
|
101
|
+
async AppendLine(id, line) {
|
|
102
|
+
await this.Append(id, line + "\n");
|
|
103
|
+
}
|
|
80
104
|
async Update(id, item) {
|
|
81
105
|
this._db.Log(`Updating "${id}"...`);
|
|
82
106
|
const rawItem = this._converter.ToRaw(item);
|
package/DatasetInfo.d.ts
ADDED
package/DatasetInfo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/OnlineStorage.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { IStorageUser } from "./IStorageUser";
|
|
|
8
8
|
import { IConverter } from "./IConverter";
|
|
9
9
|
import { IStorageUserPrivileges } from "./IStorageUserPrivileges";
|
|
10
10
|
import { DatabaseInfo } from "./DatabaseInfo";
|
|
11
|
+
import { DatasetInfo } from "./DatasetInfo";
|
|
11
12
|
export declare class OnlineStorage {
|
|
12
13
|
private server;
|
|
13
14
|
private database;
|
|
@@ -23,7 +24,7 @@ export declare class OnlineStorage {
|
|
|
23
24
|
constructor(server: url, database: dir, sender?: ISender, bus?: MessageBus);
|
|
24
25
|
SetServer(server: url): this;
|
|
25
26
|
SetDatabase(database: dir): this;
|
|
26
|
-
ListDatasets(): Promise<
|
|
27
|
+
ListDatasets(): Promise<DatasetInfo[]>;
|
|
27
28
|
ListUsers(): Promise<IStorageUser[]>;
|
|
28
29
|
GetUser(userId: string): Promise<IStorageUser>;
|
|
29
30
|
AddUser(user: IStorageUser): Promise<void>;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
Binary file
|
package/tblabs-storage-5.8.2.tgz
DELETED
|
Binary file
|