turf-common 1.0.16-beta.2 → 1.0.16-beta.3
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 +0 -1
- package/build/index.js +1 -1
- package/build/types/entity/entity-audit-column.type.d.ts +8 -2
- package/build/types/entity/entity-audit-column.type.js +7 -0
- package/build/types/entity/pitch-entity.type.d.ts +9 -0
- package/build/types/entity/pitch-entity.type.js +2 -0
- package/build/types/entity/turf-entity.type.d.ts +24 -5
- package/build/types/entity/turf-entity.type.js +100 -0
- package/package.json +1 -1
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
|
-
|
|
27
|
+
// export * from "./types/entity/turf-entity.type";
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export
|
|
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
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IPitchStatus } from "../../enums/pitch-status.enum";
|
|
2
2
|
import { ITurf } from "../../interface/get-turf-entity.interface";
|
|
3
|
-
import { IEntityAuditColumn } from "./entity-audit-column.type";
|
|
4
|
-
|
|
3
|
+
import { EntityAuditColumnModel, IEntityAuditColumn } from "./entity-audit-column.type";
|
|
4
|
+
import { IPitchEntity } from "./pitch-entity.type";
|
|
5
|
+
export interface ITurfEntity extends IEntityAuditColumn, TurfEntityStatic {
|
|
5
6
|
id: number;
|
|
6
7
|
turfName: string;
|
|
7
8
|
numberOfPitches: number;
|
|
@@ -10,10 +11,28 @@ export type ITurfEntity = {
|
|
|
10
11
|
adhocRefund: boolean;
|
|
11
12
|
getPitchStatusCount(): IPitchStatus;
|
|
12
13
|
getModifiedTurfEntity(): ITurf;
|
|
13
|
-
|
|
14
|
+
}
|
|
15
|
+
export interface ITurfEntityRel {
|
|
16
|
+
pitches: IPitchEntity[];
|
|
17
|
+
}
|
|
18
|
+
export declare class TurfEntityStatic {
|
|
19
|
+
static toMap(turfEntities: ITurfEntity[]): {
|
|
14
20
|
[key: number]: ITurf;
|
|
15
21
|
};
|
|
16
|
-
toKeyValue(turfEntities: ITurfEntity[]): {
|
|
22
|
+
static toKeyValue(turfEntities: ITurfEntity[]): {
|
|
17
23
|
[key: number]: ITurfEntity;
|
|
18
24
|
};
|
|
19
|
-
|
|
25
|
+
static fromEntity(data: ITurfEntity): TurfModel;
|
|
26
|
+
}
|
|
27
|
+
export declare class TurfModel extends EntityAuditColumnModel {
|
|
28
|
+
id: number;
|
|
29
|
+
turfName: string;
|
|
30
|
+
numberOfPitches: number;
|
|
31
|
+
address: string;
|
|
32
|
+
org_id: number;
|
|
33
|
+
adhocRefund: boolean;
|
|
34
|
+
pitches: IPitchEntity[];
|
|
35
|
+
constructor(data: ITurfEntity);
|
|
36
|
+
getPitchStatusCount(): IPitchStatus;
|
|
37
|
+
getModifiedTurfEntity(): ITurf;
|
|
38
|
+
}
|
|
@@ -1,2 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.TurfModel = exports.TurfEntityStatic = void 0;
|
|
19
|
+
var pitch_status_enum_1 = require("../../enums/pitch-status.enum");
|
|
20
|
+
var entity_audit_column_type_1 = require("./entity-audit-column.type");
|
|
21
|
+
// function staticImplements<T>(): T {
|
|
22
|
+
// return <U extends T>(constructor: U) => {
|
|
23
|
+
// constructor;
|
|
24
|
+
// };
|
|
25
|
+
// }
|
|
26
|
+
// @staticImplements<ITurfEntityStatic>()
|
|
27
|
+
var TurfEntityStatic = /** @class */ (function () {
|
|
28
|
+
function TurfEntityStatic() {
|
|
29
|
+
}
|
|
30
|
+
TurfEntityStatic.toMap = function (turfEntities) {
|
|
31
|
+
var response = {};
|
|
32
|
+
turfEntities.forEach(function (turfEntity) {
|
|
33
|
+
if (!response[turfEntity.id]) {
|
|
34
|
+
response[turfEntity.id] = turfEntity.getModifiedTurfEntity();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return response;
|
|
38
|
+
};
|
|
39
|
+
TurfEntityStatic.toKeyValue = function (turfEntities) {
|
|
40
|
+
var response = {};
|
|
41
|
+
turfEntities.forEach(function (turfEntity) {
|
|
42
|
+
if (!response[turfEntity.id]) {
|
|
43
|
+
response[turfEntity.id] = turfEntity;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return response;
|
|
47
|
+
};
|
|
48
|
+
TurfEntityStatic.fromEntity = function (data) {
|
|
49
|
+
return new TurfModel(data);
|
|
50
|
+
};
|
|
51
|
+
return TurfEntityStatic;
|
|
52
|
+
}());
|
|
53
|
+
exports.TurfEntityStatic = TurfEntityStatic;
|
|
54
|
+
var TurfModel = /** @class */ (function (_super) {
|
|
55
|
+
__extends(TurfModel, _super);
|
|
56
|
+
function TurfModel(data) {
|
|
57
|
+
var _this = _super.call(this) || this;
|
|
58
|
+
Object.assign(_this, data);
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
TurfModel.prototype.getPitchStatusCount = function () {
|
|
62
|
+
var statusCount = {};
|
|
63
|
+
for (var _i = 0, _a = Object.values(pitch_status_enum_1.PitchStatus); _i < _a.length; _i++) {
|
|
64
|
+
var status_1 = _a[_i];
|
|
65
|
+
statusCount[status_1] = 0;
|
|
66
|
+
}
|
|
67
|
+
for (var _b = 0, _c = this.pitches; _b < _c.length; _b++) {
|
|
68
|
+
var pitch = _c[_b];
|
|
69
|
+
statusCount[pitch.status] += 1;
|
|
70
|
+
}
|
|
71
|
+
return statusCount;
|
|
72
|
+
};
|
|
73
|
+
TurfModel.prototype.getModifiedTurfEntity = function () {
|
|
74
|
+
return {
|
|
75
|
+
id: this.id,
|
|
76
|
+
turfName: this.turfName,
|
|
77
|
+
numberOfPitches: this.numberOfPitches,
|
|
78
|
+
address: this.address,
|
|
79
|
+
org_id: this.org_id,
|
|
80
|
+
updatedBy: this.updatedBy,
|
|
81
|
+
updatedOn: this.updatedOn,
|
|
82
|
+
createdBy: this.createdBy,
|
|
83
|
+
createdOn: this.createdOn,
|
|
84
|
+
pitches: this.pitches.map(function (_a) {
|
|
85
|
+
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;
|
|
86
|
+
return ({
|
|
87
|
+
turf: turf.id,
|
|
88
|
+
number: number,
|
|
89
|
+
name: name,
|
|
90
|
+
status: status,
|
|
91
|
+
sports: sports.split(",").map(function (sport) { return ({ name: sport }); }),
|
|
92
|
+
createdBy: createdBy,
|
|
93
|
+
createdOn: createdOn,
|
|
94
|
+
updatedBy: updatedBy,
|
|
95
|
+
updatedOn: updatedOn,
|
|
96
|
+
});
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
return TurfModel;
|
|
101
|
+
}(entity_audit_column_type_1.EntityAuditColumnModel));
|
|
102
|
+
exports.TurfModel = TurfModel;
|