@tblabs/storage 5.12.9 → 5.12.10
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/Datasets/PicturesDataset/PicturesDataset.d.ts +2 -2
- package/Datasets/PicturesDataset/PicturesDataset.js +4 -4
- package/Datasets/RawTextDataset.d.ts +2 -0
- package/Datasets/RawTextDataset.js +17 -0
- package/Messages/ClearCommand.d.ts +5 -0
- package/Messages/ClearCommand.js +6 -0
- package/Messages/DeletePictureCommand.d.ts +1 -1
- package/Messages/DeletePictureCommand.js +2 -2
- package/package.json +1 -1
- package/tblabs-storage-5.12.10.tgz +0 -0
- package/tblabs-storage-5.12.9.tgz +0 -0
|
@@ -14,9 +14,9 @@ export declare class PicturesDataset extends DatasetBase {
|
|
|
14
14
|
SetConfig(config: PicsConfig): void;
|
|
15
15
|
GetConfig(): PicsConfig;
|
|
16
16
|
GetAllIds(): Promise<string[]>;
|
|
17
|
-
GetOne(
|
|
17
|
+
GetOne(pictureDir: string): Promise<PicturePack>;
|
|
18
18
|
GetAll(): Promise<PicturePack[]>;
|
|
19
19
|
Add(files: File[]): Promise<PicturesUploadResult>;
|
|
20
|
-
Delete(
|
|
20
|
+
Delete(pictureDir: string): Promise<void>;
|
|
21
21
|
Drop(): Promise<void>;
|
|
22
22
|
}
|
|
@@ -31,8 +31,8 @@ export class PicturesDataset extends DatasetBase {
|
|
|
31
31
|
}
|
|
32
32
|
return result.Result;
|
|
33
33
|
}
|
|
34
|
-
async GetOne(
|
|
35
|
-
const result = await this._db.Send(new GetPictureQuery(this._db.Server, this._db.DatabaseDir, this.dataset,
|
|
34
|
+
async GetOne(pictureDir) {
|
|
35
|
+
const result = await this._db.Send(new GetPictureQuery(this._db.Server, this._db.DatabaseDir, this.dataset, pictureDir));
|
|
36
36
|
if (!result.IsSuccess) {
|
|
37
37
|
throw new Error("Failed to get picture: " + result.ErrorMessage);
|
|
38
38
|
}
|
|
@@ -77,8 +77,8 @@ export class PicturesDataset extends DatasetBase {
|
|
|
77
77
|
return PicturesUploadResult.Failure(`Can not upload: ${ex.message}`);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async Delete(
|
|
81
|
-
const result = await this._db.Send(new DeletePictureCommand(this._db.DatabaseDir, this.dataset,
|
|
80
|
+
async Delete(pictureDir) {
|
|
81
|
+
const result = await this._db.Send(new DeletePictureCommand(this._db.DatabaseDir, this.dataset, pictureDir));
|
|
82
82
|
if (!result.IsSuccess) {
|
|
83
83
|
throw new Error("Failed to delete picture: " + result.ErrorMessage);
|
|
84
84
|
}
|
|
@@ -12,6 +12,8 @@ export declare class RawTextDataset extends DatasetBase implements ITextRepo {
|
|
|
12
12
|
GetAllIds(): Promise<string[]>;
|
|
13
13
|
Create(id: string): Promise<void>;
|
|
14
14
|
AppendText(id: string, text: string): Promise<void>;
|
|
15
|
+
Clear(id: string): Promise<void>;
|
|
16
|
+
ReplaceText(id: string, text: string): Promise<void>;
|
|
15
17
|
AppendLine(id: string, line: string): Promise<void>;
|
|
16
18
|
Delete(id: string): Promise<void>;
|
|
17
19
|
Drop(): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DatasetBase } from "../Datasets/DatasetBase";
|
|
2
2
|
import { AppendCommand } from "../Messages/AppendCommand";
|
|
3
|
+
import { ClearCommand } from "../Messages/ClearCommand";
|
|
3
4
|
import { CreateFileCommand } from "../Messages/CreateFileCommand";
|
|
4
5
|
import { DeleteFileCommand } from "../Messages/DeleteFileCommand";
|
|
5
6
|
import { DropDatasetCommand } from "../Messages/DropDatasetCommand";
|
|
@@ -53,6 +54,22 @@ export class RawTextDataset extends DatasetBase {
|
|
|
53
54
|
this.Log(`${text.length} characters appended to "${id}" in "${this.DatasetPath}".`);
|
|
54
55
|
}
|
|
55
56
|
;
|
|
57
|
+
async Clear(id) {
|
|
58
|
+
this.Log(`Clearing "${id}" in "${this.DatasetPath}"...`);
|
|
59
|
+
const result = await this._db.Send(new ClearCommand(this._db.DatabaseDir, this.dataset, id));
|
|
60
|
+
if (!result.IsSuccess) {
|
|
61
|
+
throw new Error("Failed to clear text file: " + result.ErrorMessage);
|
|
62
|
+
}
|
|
63
|
+
this.Log(`"${id}" cleared in "${this.DatasetPath}".`);
|
|
64
|
+
}
|
|
65
|
+
;
|
|
66
|
+
async ReplaceText(id, text) {
|
|
67
|
+
this.Log(`Replacing text in "${id}" in "${this.DatasetPath}"...`);
|
|
68
|
+
await this.Clear(id);
|
|
69
|
+
await this.AppendText(id, text);
|
|
70
|
+
this.Log(`"${id}" replaced in "${this.DatasetPath}".`);
|
|
71
|
+
}
|
|
72
|
+
;
|
|
56
73
|
async AppendLine(id, line) {
|
|
57
74
|
await this.AppendText(id, line + "\n");
|
|
58
75
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
2
|
import { dir } from '../Types/dir';
|
|
3
3
|
export declare class DeletePictureCommand extends Message {
|
|
4
|
-
constructor(Database: dir, Dataset: dir,
|
|
4
|
+
constructor(Database: dir, Dataset: dir, PictureDir: string);
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from '../MessageBus/Message';
|
|
2
2
|
export class DeletePictureCommand extends Message {
|
|
3
|
-
constructor(Database, Dataset,
|
|
4
|
-
super("DeletePicture", { Database, Dataset,
|
|
3
|
+
constructor(Database, Dataset, PictureDir) {
|
|
4
|
+
super("DeletePicture", { Database, Dataset, PictureDir });
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|