@tblabs/storage 5.12.0 → 5.12.1
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/Dataset.d.ts +2 -0
- package/Datasets/Dataset.js +2 -0
- package/Datasets/DatasetBase.d.ts +4 -1
- package/Datasets/PicturesDataset/PicturesDataset.d.ts +5 -1
- package/Datasets/PicturesDataset/PicturesDataset.js +19 -1
- package/Datasets/RawTextDataset.d.ts +2 -0
- package/Datasets/RawTextDataset.js +2 -0
- package/Messages/GetPictureQuery.d.ts +5 -0
- package/Messages/GetPictureQuery.js +6 -0
- package/Messages/ListPicturesIdsQuery.d.ts +5 -0
- package/Messages/ListPicturesIdsQuery.js +6 -0
- package/package.json +1 -1
- package/tblabs-storage-5.12.1.tgz +0 -0
- package/tblabs-storage-5.12.0.tgz +0 -0
package/Datasets/Dataset.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import { IConverter } from "../Converters/IConverter";
|
|
|
3
3
|
import { IRepo } from "../Datasets/IRepo";
|
|
4
4
|
import { dir } from "../Types/dir";
|
|
5
5
|
import { DatasetBase } from "../Datasets/DatasetBase";
|
|
6
|
+
import { DatasetType } from "../Services/DatasetType";
|
|
6
7
|
export declare class Dataset<T extends object> extends DatasetBase implements IRepo<T> {
|
|
7
8
|
protected _db: OnlineStorage;
|
|
8
9
|
protected _converter: IConverter<any, T>;
|
|
9
10
|
protected dataset: dir;
|
|
11
|
+
Type: DatasetType;
|
|
10
12
|
constructor(_db: OnlineStorage, _converter: IConverter<any, T>, dataset: dir);
|
|
11
13
|
GetOne(id: string): Promise<T>;
|
|
12
14
|
GetAll(): Promise<T[]>;
|
package/Datasets/Dataset.js
CHANGED
|
@@ -6,10 +6,12 @@ import { GetFileQuery } from "../Messages/GetFileQuery";
|
|
|
6
6
|
import { UpdateFileCommand } from "../Messages/UpdateFileCommand";
|
|
7
7
|
import { ListFilesIdsQuery } from "../Messages/ListFilesIdsQuery";
|
|
8
8
|
import { DatasetBase } from "../Datasets/DatasetBase";
|
|
9
|
+
import { DatasetType } from "../Services/DatasetType";
|
|
9
10
|
export class Dataset extends DatasetBase {
|
|
10
11
|
_db;
|
|
11
12
|
_converter;
|
|
12
13
|
dataset;
|
|
14
|
+
Type = DatasetType.Objects;
|
|
13
15
|
constructor(_db, _converter, dataset) {
|
|
14
16
|
super(_db, dataset);
|
|
15
17
|
this._db = _db;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { IStorageUserPrivileges } from "../Models/IStorageUserPrivileges";
|
|
2
|
+
import { DatasetType } from "../Services/DatasetType";
|
|
2
3
|
import { OnlineStorage } from "../Services/OnlineStorage";
|
|
3
4
|
import { dir } from "../Types/dir";
|
|
4
|
-
export declare class DatasetBase {
|
|
5
|
+
export declare abstract class DatasetBase {
|
|
5
6
|
protected _db: OnlineStorage;
|
|
6
7
|
protected dataset: dir;
|
|
8
|
+
abstract Type: DatasetType;
|
|
9
|
+
abstract GetAllIds(): Promise<string[]>;
|
|
7
10
|
constructor(_db: OnlineStorage, dataset: dir);
|
|
8
11
|
get Name(): string;
|
|
9
12
|
get Database(): OnlineStorage;
|
|
@@ -4,12 +4,16 @@ import { DatasetBase } from "../DatasetBase";
|
|
|
4
4
|
import { PicturesUploadResult } from "./PicturesUploadResult";
|
|
5
5
|
import { PicsConfig } from "./PicsConfig";
|
|
6
6
|
import { PicturePack } from "./PicturePack";
|
|
7
|
+
import { DatasetType } from "../../Services/DatasetType";
|
|
7
8
|
export declare class PicturesDataset extends DatasetBase {
|
|
8
9
|
protected _db: OnlineStorage;
|
|
9
10
|
protected dataset: dir;
|
|
10
11
|
protected picsConfig: PicsConfig;
|
|
12
|
+
Type: DatasetType;
|
|
11
13
|
constructor(_db: OnlineStorage, dataset: dir, picsConfig?: PicsConfig);
|
|
12
|
-
|
|
14
|
+
GetAllIds(): Promise<string[]>;
|
|
15
|
+
GetPicture(id: string): Promise<PicturePack>;
|
|
16
|
+
GetAllPictures(): Promise<PicturePack[]>;
|
|
13
17
|
UploadPictures(files: File[]): Promise<PicturesUploadResult>;
|
|
14
18
|
DeletePicture(id: string): Promise<void>;
|
|
15
19
|
}
|
|
@@ -3,17 +3,35 @@ import { ListPicturesQuery } from "../../Messages/ListPicturesQuery";
|
|
|
3
3
|
import { DatasetBase } from "../DatasetBase";
|
|
4
4
|
import { DefaultPicsConfig } from "./DefaultPicsConfig";
|
|
5
5
|
import { PicturesUploadResult } from "./PicturesUploadResult";
|
|
6
|
+
import { DatasetType } from "../../Services/DatasetType";
|
|
7
|
+
import { ListPicturesIdsQuery } from "../../Messages/ListPicturesIdsQuery";
|
|
8
|
+
import { GetPictureQuery } from "../../Messages/GetPictureQuery";
|
|
6
9
|
export class PicturesDataset extends DatasetBase {
|
|
7
10
|
_db;
|
|
8
11
|
dataset;
|
|
9
12
|
picsConfig;
|
|
13
|
+
Type = DatasetType.Pictures;
|
|
10
14
|
constructor(_db, dataset, picsConfig = DefaultPicsConfig) {
|
|
11
15
|
super(_db, dataset);
|
|
12
16
|
this._db = _db;
|
|
13
17
|
this.dataset = dataset;
|
|
14
18
|
this.picsConfig = picsConfig;
|
|
15
19
|
}
|
|
16
|
-
async
|
|
20
|
+
async GetAllIds() {
|
|
21
|
+
const result = await this._db.Send(new ListPicturesIdsQuery(this._db.DatabaseDir, this.dataset));
|
|
22
|
+
if (!result.IsSuccess) {
|
|
23
|
+
throw new Error("Failed to list pictures ids: " + result.ErrorMessage);
|
|
24
|
+
}
|
|
25
|
+
return result.Result;
|
|
26
|
+
}
|
|
27
|
+
async GetPicture(id) {
|
|
28
|
+
const result = await this._db.Send(new GetPictureQuery(this._db.DatabaseDir, this.dataset, id));
|
|
29
|
+
if (!result.IsSuccess) {
|
|
30
|
+
throw new Error("Failed to get picture: " + result.ErrorMessage);
|
|
31
|
+
}
|
|
32
|
+
return result.Result;
|
|
33
|
+
}
|
|
34
|
+
async GetAllPictures() {
|
|
17
35
|
const result = await this._db.Send(new ListPicturesQuery(this._db.DatabaseDir, this.dataset));
|
|
18
36
|
if (!result.IsSuccess) {
|
|
19
37
|
throw new Error("Failed to list picture packs: " + result.ErrorMessage);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DatasetBase } from "../Datasets/DatasetBase";
|
|
2
2
|
import { ITextRepo } from "../Datasets/ITextRepo";
|
|
3
|
+
import { DatasetType } from "../Services/DatasetType";
|
|
3
4
|
import { OnlineStorage } from "../Services/OnlineStorage";
|
|
4
5
|
import { dir } from "../Types/dir";
|
|
5
6
|
export declare class RawTextDataset extends DatasetBase implements ITextRepo {
|
|
6
7
|
protected _db: OnlineStorage;
|
|
7
8
|
protected dataset: dir;
|
|
9
|
+
Type: DatasetType;
|
|
8
10
|
constructor(_db: OnlineStorage, dataset: dir);
|
|
9
11
|
Read(id: string, offset?: number, limit?: number): Promise<string[]>;
|
|
10
12
|
GetAllIds(): Promise<string[]>;
|
|
@@ -5,9 +5,11 @@ import { DeleteFileCommand } from "../Messages/DeleteFileCommand";
|
|
|
5
5
|
import { DropDatasetCommand } from "../Messages/DropDatasetCommand";
|
|
6
6
|
import { ListFilesIdsQuery } from "../Messages/ListFilesIdsQuery";
|
|
7
7
|
import { ReadFileQuery } from "../Messages/ReadFileQuery";
|
|
8
|
+
import { DatasetType } from "../Services/DatasetType";
|
|
8
9
|
export class RawTextDataset extends DatasetBase {
|
|
9
10
|
_db;
|
|
10
11
|
dataset;
|
|
12
|
+
Type = DatasetType.Texts;
|
|
11
13
|
constructor(_db, dataset) {
|
|
12
14
|
super(_db, dataset);
|
|
13
15
|
this._db = _db;
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|