turf-common 1.0.16-beta.1 → 1.0.16-beta.10

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.
@@ -0,0 +1,15 @@
1
+ export declare enum OrganizationStatus {
2
+ REGISTRATION = "registration",
3
+ REGISTRATION_INVALID = "registration_invalid",
4
+ REGISTRATION_APPROVED = "registration_approved",
5
+ SETUP_INVALID = "setup_invalid",
6
+ SETUP_DONE = "setup_done",
7
+ PAYMENT_INVALID = "payment_invalid",
8
+ PAYMENT_DONE = "payment_done",
9
+ ACCOUNT_ACTIVE = "account_active",
10
+ ACCOUNT_SUSPENDED = "account_suspended"
11
+ }
12
+ export declare namespace OrganizationStatus {
13
+ function allowPermissionSuperAdmin(): OrganizationStatus[];
14
+ function allowPermissionOwner(): OrganizationStatus[];
15
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationStatus = void 0;
4
+ var OrganizationStatus;
5
+ (function (OrganizationStatus) {
6
+ OrganizationStatus["REGISTRATION"] = "registration";
7
+ OrganizationStatus["REGISTRATION_INVALID"] = "registration_invalid";
8
+ OrganizationStatus["REGISTRATION_APPROVED"] = "registration_approved";
9
+ OrganizationStatus["SETUP_INVALID"] = "setup_invalid";
10
+ OrganizationStatus["SETUP_DONE"] = "setup_done";
11
+ OrganizationStatus["PAYMENT_INVALID"] = "payment_invalid";
12
+ OrganizationStatus["PAYMENT_DONE"] = "payment_done";
13
+ OrganizationStatus["ACCOUNT_ACTIVE"] = "account_active";
14
+ OrganizationStatus["ACCOUNT_SUSPENDED"] = "account_suspended";
15
+ })(OrganizationStatus || (exports.OrganizationStatus = OrganizationStatus = {}));
16
+ // eslint-disable-next-line @typescript-eslint/no-namespace
17
+ (function (OrganizationStatus) {
18
+ function allowPermissionSuperAdmin() {
19
+ return Object.values(OrganizationStatus).filter(function (status) {
20
+ return status !== OrganizationStatus.SETUP_DONE &&
21
+ status !== OrganizationStatus.REGISTRATION;
22
+ });
23
+ }
24
+ OrganizationStatus.allowPermissionSuperAdmin = allowPermissionSuperAdmin;
25
+ function allowPermissionOwner() {
26
+ return Object.values(OrganizationStatus).filter(function (status) {
27
+ return status === OrganizationStatus.SETUP_DONE;
28
+ });
29
+ }
30
+ OrganizationStatus.allowPermissionOwner = allowPermissionOwner;
31
+ })(OrganizationStatus || (exports.OrganizationStatus = OrganizationStatus = {}));
package/build/index.d.ts CHANGED
@@ -5,4 +5,6 @@ export * from "./exceptions/app-badrequest.exception";
5
5
  export * from "./types/app-badrequest-exception.type";
6
6
  export * from "./types/booking-modification.type";
7
7
  export * from "./interface/get-booking-codes-per-thirty-min.interface";
8
+ export * from "./interface/get-turf-entity.interface";
8
9
  export * from "./enums/modification-discount-policy.enum";
10
+ export * from "./types/entity/entity-audit-column.type";
package/build/index.js CHANGED
@@ -21,4 +21,7 @@ __exportStar(require("./exceptions/app-badrequest.exception"), exports);
21
21
  __exportStar(require("./types/app-badrequest-exception.type"), exports);
22
22
  __exportStar(require("./types/booking-modification.type"), exports);
23
23
  __exportStar(require("./interface/get-booking-codes-per-thirty-min.interface"), exports);
24
+ __exportStar(require("./interface/get-turf-entity.interface"), exports);
24
25
  __exportStar(require("./enums/modification-discount-policy.enum"), exports);
26
+ __exportStar(require("./types/entity/entity-audit-column.type"), exports);
27
+ // export * from "./types/entity/turf-entity.type";
@@ -8,6 +8,14 @@ export interface ITurf {
8
8
  createdBy: number;
9
9
  updatedBy: number;
10
10
  org_id: number;
11
+ totalPitchCount?: number;
12
+ activePitchCount?: number;
13
+ deletePitchCount?: number;
14
+ deactivePitchCount?: number;
15
+ newPitchCount?: number;
16
+ setup_invalidPitchCount?: number;
17
+ payment_invalidPitchCount?: number;
18
+ account_suspendedPitchCount?: number;
11
19
  pitches: IPitch[];
12
20
  }
13
21
  export interface IPitch {
@@ -21,7 +29,6 @@ export interface IPitch {
21
29
  createdBy: number;
22
30
  updatedBy: number;
23
31
  }
24
- interface ISport {
32
+ export interface ISport {
25
33
  name: string;
26
34
  }
27
- export {};
@@ -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,20 @@
1
+ import { OrganizationStatus } from "../../enums/organization-status.enum";
2
+ import { ITurfEntity } from "./turf-entity.type";
3
+ export type IOrganizationEntity = {
4
+ id: number;
5
+ name: string;
6
+ email: string;
7
+ contact_no: string;
8
+ type: string;
9
+ pan_no: string;
10
+ pan_file_path: string;
11
+ gst_no: string;
12
+ gst_file_path: string;
13
+ deed: string;
14
+ deed_file_path: string;
15
+ status: OrganizationStatus;
16
+ registrationId: number;
17
+ };
18
+ export interface IOrganizationRel {
19
+ turfs: ITurfEntity[];
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 });
@@ -0,0 +1,7 @@
1
+ export type ISubscriptionPitchMapping = {
2
+ pitchId: number;
3
+ turfId: number;
4
+ subscriptionId: number;
5
+ status: string;
6
+ organizationId: number;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +1,45 @@
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 { IOrganizationEntity } from "./organization-entity.type";
5
+ import { IPitchEntity } from "./pitch-entity.type";
6
+ export interface ITurfEntity extends IEntityAuditColumn {
5
7
  id: number;
6
8
  turfName: string;
7
9
  numberOfPitches: number;
8
10
  address: string;
9
11
  org_id: number;
10
12
  adhocRefund: boolean;
13
+ }
14
+ export interface ITurfEntityRel {
15
+ pitches: IPitchEntity[];
16
+ organization: IOrganizationEntity;
17
+ }
18
+ export interface ITurfModel extends ITurfEntity, ITurfEntityRel {
11
19
  getPitchStatusCount(): IPitchStatus;
12
20
  getModifiedTurfEntity(): ITurf;
13
- toMap(turfEntities: ITurfEntity[]): {
21
+ }
22
+ export declare class TurfModel implements ITurfModel {
23
+ id: number;
24
+ turfName: string;
25
+ numberOfPitches: number;
26
+ address: string;
27
+ org_id: number;
28
+ adhocRefund: boolean;
29
+ createdOn: Date;
30
+ updatedOn: Date;
31
+ createdBy: number;
32
+ updatedBy: number;
33
+ pitches: IPitchEntity[];
34
+ organization: IOrganizationEntity;
35
+ constructor(data: ITurfEntity);
36
+ getPitchStatusCount(): IPitchStatus;
37
+ getModifiedTurfEntity(): ITurf;
38
+ static toMap(turfEntities: ITurfModel[]): {
14
39
  [key: number]: ITurf;
15
40
  };
16
- toKeyValue(turfEntities: ITurfEntity[]): {
41
+ static toKeyValue(turfEntities: ITurfEntity[]): {
17
42
  [key: number]: ITurfEntity;
18
43
  };
19
- } & IEntityAuditColumn;
44
+ static fromEntity(data: ITurfEntity): ITurfModel;
45
+ }
@@ -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.1",
3
+ "version": "1.0.16-beta.10",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  "clean": "del build",
12
12
  "build": "npm run clean && tsc",
13
13
  "version:deploy": "npm version patch && git push && npm run build && npm publish",
14
+ "version:deploy:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
14
15
  "test": "echo \"Error: no test specified\" && exit 1",
15
16
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" 2>&1| tee eslint.log",
16
17
  "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"