turf-common 1.0.16-beta.2 → 1.0.16-beta.4

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/build/index.d.ts CHANGED
@@ -8,4 +8,3 @@ export * from "./interface/get-booking-codes-per-thirty-min.interface";
8
8
  export * from "./interface/get-turf-entity.interface";
9
9
  export * from "./enums/modification-discount-policy.enum";
10
10
  export * from "./types/entity/entity-audit-column.type";
11
- export * from "./types/entity/turf-entity.type";
package/build/index.js CHANGED
@@ -24,4 +24,4 @@ __exportStar(require("./interface/get-booking-codes-per-thirty-min.interface"),
24
24
  __exportStar(require("./interface/get-turf-entity.interface"), exports);
25
25
  __exportStar(require("./enums/modification-discount-policy.enum"), exports);
26
26
  __exportStar(require("./types/entity/entity-audit-column.type"), exports);
27
- __exportStar(require("./types/entity/turf-entity.type"), exports);
27
+ // export * from "./types/entity/turf-entity.type";
@@ -1,6 +1,12 @@
1
- export type IEntityAuditColumn = {
1
+ export interface IEntityAuditColumn {
2
2
  createdOn: Date;
3
3
  updatedOn: Date;
4
4
  createdBy: number;
5
5
  updatedBy: number;
6
- };
6
+ }
7
+ export declare class EntityAuditColumnModel implements IEntityAuditColumn {
8
+ createdOn: Date;
9
+ updatedOn: Date;
10
+ createdBy: number;
11
+ updatedBy: number;
12
+ }
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityAuditColumnModel = void 0;
4
+ var EntityAuditColumnModel = /** @class */ (function () {
5
+ function EntityAuditColumnModel() {
6
+ }
7
+ return EntityAuditColumnModel;
8
+ }());
9
+ exports.EntityAuditColumnModel = EntityAuditColumnModel;
@@ -0,0 +1,9 @@
1
+ import { IEntityAuditColumn } from "./entity-audit-column.type";
2
+ import { ITurfEntity } from "./turf-entity.type";
3
+ export interface IPitchEntity extends IEntityAuditColumn {
4
+ turf: ITurfEntity;
5
+ number: number;
6
+ name: string;
7
+ status: string;
8
+ sports: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +1,42 @@
1
1
  import { IPitchStatus } from "../../enums/pitch-status.enum";
2
2
  import { ITurf } from "../../interface/get-turf-entity.interface";
3
3
  import { IEntityAuditColumn } from "./entity-audit-column.type";
4
- export type ITurfEntity = {
4
+ import { IPitchEntity } from "./pitch-entity.type";
5
+ export interface ITurfEntity extends IEntityAuditColumn {
5
6
  id: number;
6
7
  turfName: string;
7
8
  numberOfPitches: number;
8
9
  address: string;
9
10
  org_id: number;
10
11
  adhocRefund: boolean;
12
+ }
13
+ export interface ITurfEntityRel {
14
+ pitches: IPitchEntity[];
15
+ }
16
+ export interface ITurfModel extends ITurfEntity, ITurfEntityRel {
11
17
  getPitchStatusCount(): IPitchStatus;
12
18
  getModifiedTurfEntity(): ITurf;
13
- toMap(turfEntities: ITurfEntity[]): {
19
+ }
20
+ export declare class TurfModel implements ITurfModel {
21
+ id: number;
22
+ turfName: string;
23
+ numberOfPitches: number;
24
+ address: string;
25
+ org_id: number;
26
+ adhocRefund: boolean;
27
+ createdOn: Date;
28
+ updatedOn: Date;
29
+ createdBy: number;
30
+ updatedBy: number;
31
+ pitches: IPitchEntity[];
32
+ constructor(data: ITurfEntity);
33
+ getPitchStatusCount(): IPitchStatus;
34
+ getModifiedTurfEntity(): ITurf;
35
+ static toMap(turfEntities: ITurfModel[]): {
14
36
  [key: number]: ITurf;
15
37
  };
16
- toKeyValue(turfEntities: ITurfEntity[]): {
17
- [key: number]: ITurfEntity;
38
+ static toKeyValue(turfEntities: ITurfModel[]): {
39
+ [key: number]: ITurfModel;
18
40
  };
19
- } & IEntityAuditColumn;
41
+ static fromEntity(data: ITurfEntity): ITurfModel;
42
+ }
@@ -1,2 +1,71 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurfModel = void 0;
4
+ var pitch_status_enum_1 = require("../../enums/pitch-status.enum");
5
+ var TurfModel = /** @class */ (function () {
6
+ function TurfModel(data) {
7
+ Object.assign(this, data);
8
+ }
9
+ TurfModel.prototype.getPitchStatusCount = function () {
10
+ var statusCount = {};
11
+ for (var _i = 0, _a = Object.values(pitch_status_enum_1.PitchStatus); _i < _a.length; _i++) {
12
+ var status_1 = _a[_i];
13
+ statusCount[status_1] = 0;
14
+ }
15
+ for (var _b = 0, _c = this.pitches; _b < _c.length; _b++) {
16
+ var pitch = _c[_b];
17
+ statusCount[pitch.status] += 1;
18
+ }
19
+ return statusCount;
20
+ };
21
+ TurfModel.prototype.getModifiedTurfEntity = function () {
22
+ return {
23
+ id: this.id,
24
+ turfName: this.turfName,
25
+ numberOfPitches: this.numberOfPitches,
26
+ address: this.address,
27
+ org_id: this.org_id,
28
+ updatedBy: this.updatedBy,
29
+ updatedOn: this.updatedOn,
30
+ createdBy: this.createdBy,
31
+ createdOn: this.createdOn,
32
+ pitches: this.pitches.map(function (_a) {
33
+ var turf = _a.turf, number = _a.number, name = _a.name, status = _a.status, sports = _a.sports, createdBy = _a.createdBy, createdOn = _a.createdOn, updatedBy = _a.updatedBy, updatedOn = _a.updatedOn;
34
+ return ({
35
+ turf: turf.id,
36
+ number: number,
37
+ name: name,
38
+ status: status,
39
+ sports: sports.split(",").map(function (sport) { return ({ name: sport }); }),
40
+ createdBy: createdBy,
41
+ createdOn: createdOn,
42
+ updatedBy: updatedBy,
43
+ updatedOn: updatedOn,
44
+ });
45
+ }),
46
+ };
47
+ };
48
+ TurfModel.toMap = function (turfEntities) {
49
+ var response = {};
50
+ turfEntities.forEach(function (turfEntity) {
51
+ if (!response[turfEntity.id]) {
52
+ response[turfEntity.id] = turfEntity.getModifiedTurfEntity();
53
+ }
54
+ });
55
+ return response;
56
+ };
57
+ TurfModel.toKeyValue = function (turfEntities) {
58
+ var response = {};
59
+ turfEntities.forEach(function (turfEntity) {
60
+ if (!response[turfEntity.id]) {
61
+ response[turfEntity.id] = turfEntity;
62
+ }
63
+ });
64
+ return response;
65
+ };
66
+ TurfModel.fromEntity = function (data) {
67
+ return new TurfModel(data);
68
+ };
69
+ return TurfModel;
70
+ }());
71
+ exports.TurfModel = TurfModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.0.16-beta.2",
3
+ "version": "1.0.16-beta.4",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",