@stemy/backend 2.7.4 → 2.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stemy/backend",
3
- "version": "2.7.4",
3
+ "version": "2.8.0",
4
4
  "license": "MIT",
5
5
  "repository": "git@github.com:stemyke/node-backend.git",
6
6
  "builders": "builders.json",
@@ -4,22 +4,19 @@ import { Readable } from "stream";
4
4
  import { Collection, GridFSBucket } from "mongodb";
5
5
  import { ObjectId } from "bson";
6
6
  import { IAsset, IAssetCropInfo, IAssetImageParams, IAssetMeta } from "../../common-types";
7
- export declare class Asset implements IAsset {
8
- readonly fileId: ObjectId;
9
- readonly filename: string;
10
- readonly contentType: string;
11
- readonly metadata: IAssetMeta;
7
+ import { BaseEntity } from "./base-entity";
8
+ export declare class Asset extends BaseEntity<IAsset> implements IAsset {
12
9
  protected bucket: GridFSBucket;
13
- protected collection: Collection;
14
10
  protected static toCropRegion(cropInfo: string | IAssetCropInfo): Region;
15
11
  protected static toImage(stream: Readable, meta?: IAssetMeta, params?: IAssetImageParams): Promise<Readable>;
16
- get id(): string;
12
+ get filename(): string;
13
+ get contentType(): string;
14
+ get metadata(): IAssetMeta;
17
15
  get stream(): Readable;
18
- constructor(fileId: ObjectId, filename: string, contentType: string, metadata: IAssetMeta, bucket: GridFSBucket, collection: Collection);
16
+ constructor(id: ObjectId, data: Partial<IAsset>, collection: Collection, bucket: GridFSBucket);
19
17
  unlink(): Promise<string>;
20
18
  getBuffer(): Promise<Buffer>;
21
19
  download(metadata?: IAssetMeta): Promise<Readable>;
22
20
  getImage(params?: IAssetImageParams): Promise<Readable>;
23
21
  downloadImage(params?: IAssetImageParams, metadata?: IAssetMeta): Promise<Readable>;
24
- toJSON(): any;
25
22
  }
@@ -0,0 +1,13 @@
1
+ import { Collection } from "mongodb";
2
+ import { ObjectId } from "bson";
3
+ export declare class BaseEntity<T> {
4
+ readonly mId: ObjectId;
5
+ protected data: Partial<T>;
6
+ protected collection: Collection;
7
+ get id(): string;
8
+ protected deleted: boolean;
9
+ constructor(mId: ObjectId, data: Partial<T>, collection: Collection);
10
+ save(): Promise<any>;
11
+ load(): Promise<this>;
12
+ toJSON(): any;
13
+ }
@@ -4,26 +4,20 @@ import { IAsset, ILazyAsset } from "../../common-types";
4
4
  import { Assets } from "../assets";
5
5
  import { JobManager } from "../job-manager";
6
6
  import { Progresses } from "../progresses";
7
- export declare class LazyAsset implements ILazyAsset {
8
- readonly lazyId: ObjectId;
9
- readonly jobName: string;
10
- readonly jobParams: any;
11
- readonly jobQue: string;
12
- protected mProgressId: string;
13
- protected mAssetId: string;
7
+ import { BaseEntity } from "./base-entity";
8
+ export declare class LazyAsset extends BaseEntity<ILazyAsset> implements ILazyAsset {
14
9
  protected assets: Assets;
15
10
  protected progresses: Progresses;
16
11
  protected jobMan: JobManager;
17
- protected collection: Collection;
18
- get id(): string;
12
+ get jobName(): string;
13
+ get jobParams(): any;
14
+ get jobQue(): string;
19
15
  get progressId(): string;
20
16
  get assetId(): string;
21
- constructor(lazyId: ObjectId, jobName: string, jobParams: any, jobQue: string, mProgressId: string, mAssetId: string, assets: Assets, progresses: Progresses, jobMan: JobManager, collection: Collection);
17
+ constructor(id: ObjectId, data: Partial<ILazyAsset>, collection: Collection, assets: Assets, progresses: Progresses, jobMan: JobManager);
22
18
  unlink(): Promise<string>;
23
19
  startWorking(): void;
24
20
  loadAsset(): Promise<IAsset>;
25
21
  writeAsset(asset: IAsset): Promise<IAsset>;
26
- save(): Promise<any>;
27
- toJSON(): any;
28
22
  protected startWorkingOnAsset(): Promise<any>;
29
23
  }
@@ -2,48 +2,46 @@
2
2
  import { ObjectId } from "bson";
3
3
  import { Collection } from "mongodb";
4
4
  import { IProgress } from "../../common-types";
5
- export declare class Progress implements IProgress {
6
- readonly progressId: ObjectId;
7
- protected mCurrent: number;
8
- protected mMax: number;
9
- protected mMessage: string;
10
- protected mError: string;
5
+ import { BaseEntity } from "./base-entity";
6
+ export declare class Progress extends BaseEntity<IProgress> implements IProgress {
11
7
  protected client: SocketIOClient.Socket;
12
- protected collection: Collection;
13
- get id(): string;
14
8
  get current(): number;
15
9
  get max(): number;
16
10
  get message(): string;
17
11
  get error(): string;
12
+ get canceled(): boolean;
18
13
  get percent(): number;
19
14
  get remaining(): number;
20
- constructor(progressId: ObjectId, mCurrent: number, mMax: number, mMessage: string, mError: string, client: SocketIOClient.Socket, collection: Collection);
15
+ constructor(id: ObjectId, data: Partial<IProgress>, collection: Collection, client: SocketIOClient.Socket);
21
16
  createSubProgress(progressValue: number, max?: number, message?: string): Promise<IProgress>;
22
17
  setMax(max: number): Promise<any>;
18
+ setMessage(message: string): Promise<any>;
23
19
  setError(error: string): Promise<any>;
24
20
  advance(value?: number): Promise<any>;
25
- toJSON(): any;
26
- save(): Promise<any>;
21
+ cancel(): Promise<any>;
27
22
  }
28
23
  export declare class SubProgress implements IProgress {
29
- private parent;
30
- private progressFrom;
31
- private progressValue;
32
- private max;
24
+ protected parent: IProgress;
25
+ protected progressFrom: number;
26
+ protected progressValue: number;
27
+ protected mMax: number;
33
28
  get id(): string;
29
+ get current(): number;
30
+ get max(): number;
34
31
  get message(): string;
35
- set message(value: string);
36
32
  get error(): string;
37
- set error(value: string);
38
33
  get percent(): number;
39
- get current(): number;
40
34
  get remaining(): number;
41
- private currentValue;
42
- constructor(parent: IProgress, progressFrom: number, progressValue: number, max?: number);
35
+ get canceled(): boolean;
36
+ protected mCurrent: number;
37
+ constructor(parent: IProgress, progressFrom: number, progressValue: number, mMax?: number);
43
38
  createSubProgress(progressValue: number, max?: number, message?: string): Promise<IProgress>;
44
39
  setMax(max: number): Promise<any>;
40
+ setMessage(message: string): Promise<any>;
45
41
  setError(error: string): Promise<any>;
46
42
  advance(value?: number): Promise<any>;
43
+ cancel(): Promise<any>;
47
44
  save(): Promise<any>;
45
+ load(): Promise<any>;
48
46
  toJSON(): any;
49
47
  }