@nathapp/nestjs-data 1.0.0-rc.14 → 1.0.0-rc.16

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.
@@ -5,13 +5,19 @@ export declare class TransformOptions<T> {
5
5
  cls?: ClassConstructor<T>;
6
6
  }
7
7
  export declare class PageOption {
8
+ constructor();
9
+ constructor(current: number);
10
+ constructor(current: number, size: number);
8
11
  current: number;
9
12
  size: number;
13
+ static from(current: number, size: number): PageOption;
10
14
  }
11
15
  export declare class Page<T> {
12
16
  total: number;
13
17
  size: number;
14
18
  current: number;
19
+ hasNext: boolean;
20
+ hasPrev: boolean;
15
21
  records: T[];
16
22
  transformOptions: TransformOptions<T>;
17
23
  constructor(page: PageOption, total: number, records: T[], transformOptions?: TransformOptions<T>);
@@ -16,19 +16,28 @@ class TransformOptions {
16
16
  }
17
17
  exports.TransformOptions = TransformOptions;
18
18
  class PageOption {
19
- constructor() {
19
+ constructor(current, size) {
20
20
  this.current = 1;
21
21
  this.size = 25;
22
+ this.current = current;
23
+ this.size = size;
24
+ }
25
+ static from(current, size) {
26
+ return new PageOption(current, size);
22
27
  }
23
28
  }
24
29
  exports.PageOption = PageOption;
25
30
  class Page {
26
31
  constructor(page, total, records, transformOptions) {
32
+ this.hasNext = false;
33
+ this.hasPrev = false;
27
34
  this.size = Number(page.size);
28
35
  this.current = Number(page.current);
29
36
  this.total = Number(total);
30
37
  this.transformOptions = transformOptions;
31
38
  this.records = records;
39
+ this.hasPrev = this.current != 1;
40
+ this.hasNext = (this.current * this.size) < this.total;
32
41
  }
33
42
  toInstance(transformOptions) {
34
43
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-data",
3
- "version": "1.0.0-rc.14",
3
+ "version": "1.0.0-rc.16",
4
4
  "description": "@nathapp/nestjs-data",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc -p tsconfig.json",