law-common 10.21.1-beta.2 → 10.21.1
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/dist/src/api/index.d.ts +0 -2
- package/dist/src/api/index.js +1 -2
- package/dist/src/entities/func/convert-to-common-entity.func.js +2 -8
- package/dist/src/entities/index.d.ts +1 -1
- package/dist/src/entities/index.js +1 -1
- package/dist/src/entities/interface/entity-audit-columns.interface.d.ts +6 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +5 -14
- package/dist/src/entities/interface/task.entity.interface.d.ts +2 -2
- package/dist/src/entities/model/base.entity.model.d.ts +2 -8
- package/dist/src/entities/model/base.entity.model.js +35 -43
- package/dist/src/entities/model/entity.model.interface.d.ts +2 -12
- package/dist/src/entities/model/entity.model.interface.js +42 -60
- package/dist/src/entities/model/holiday.entity.model.d.ts +1 -14
- package/dist/src/entities/model/holiday.entity.model.js +42 -25
- package/dist/src/entities/model/leave.entity.model.d.ts +3 -50
- package/dist/src/entities/model/leave.entity.model.js +21 -154
- package/dist/src/entities/model/task.entity.model.d.ts +5 -5
- package/dist/src/entities/model/task.entity.model.js +2 -2
- package/dist/src/utils/index.d.ts +0 -2
- package/dist/src/utils/index.js +0 -2
- package/dist/src/utils/string.util.d.ts +0 -1
- package/dist/src/utils/string.util.js +0 -14
- package/package.json +1 -1
- package/dist/src/api/interface/task.entity.api.d.ts +0 -3
- package/dist/src/api/interface/task.entity.response.d.ts +0 -4
- package/dist/src/api/interface/task.entity.response.js +0 -2
- package/dist/src/entities/model/leave_count.entity.model.d.ts +0 -19
- package/dist/src/entities/model/leave_count.entity.model.js +0 -60
- package/dist/src/utils/entity.flow.util.d.ts +0 -32
- package/dist/src/utils/entity.flow.util.js +0 -51
- /package/dist/src/{api/interface/task.entity.api.js → entities/interface/entity-audit-columns.interface.js} +0 -0
package/dist/src/api/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from "./interface/base.response.interface";
|
|
2
2
|
export * from "./interface/task.create.dto.interface";
|
|
3
3
|
export * from "./interface/task.update.dto.interface";
|
|
4
|
-
export * from "./interface/task.entity.response";
|
|
5
|
-
export * from "./interface/task.entity.api";
|
|
6
4
|
export * from "./interface/user.entity.api";
|
|
7
5
|
export * from "./interface/user.entity.response";
|
|
8
6
|
export * from "./interface/user.create.dto.interace";
|
package/dist/src/api/index.js
CHANGED
|
@@ -17,8 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./interface/base.response.interface"), exports);
|
|
18
18
|
__exportStar(require("./interface/task.create.dto.interface"), exports);
|
|
19
19
|
__exportStar(require("./interface/task.update.dto.interface"), exports);
|
|
20
|
-
|
|
21
|
-
__exportStar(require("./interface/task.entity.api"), exports);
|
|
20
|
+
// export * from "./interface/task.entity.api";
|
|
22
21
|
__exportStar(require("./interface/user.entity.api"), exports);
|
|
23
22
|
__exportStar(require("./interface/user.entity.response"), exports);
|
|
24
23
|
__exportStar(require("./interface/user.create.dto.interace"), exports);
|
|
@@ -14,15 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.ConvertToCommonEntity = ConvertToCommonEntity;
|
|
15
15
|
exports.ConvertApiToEntity = ConvertApiToEntity;
|
|
16
16
|
function ConvertToCommonEntity(obj) {
|
|
17
|
+
var _a, _b;
|
|
17
18
|
const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
|
|
18
|
-
|
|
19
|
-
if (obj.createdOn) {
|
|
20
|
-
dateTransformerObj["createdOn"] = obj.createdOn.toISOString();
|
|
21
|
-
}
|
|
22
|
-
if (obj.updatedOn) {
|
|
23
|
-
dateTransformerObj["updatedOn"] = obj.updatedOn.toISOString();
|
|
24
|
-
}
|
|
25
|
-
return Object.assign(Object.assign({}, dateTransformerObj), objectToAssign);
|
|
19
|
+
return Object.assign({ createdOn: (_a = obj.createdOn) === null || _a === void 0 ? void 0 : _a.toISOString(), updatedOn: (_b = obj.updatedOn) === null || _b === void 0 ? void 0 : _b.toISOString() }, objectToAssign);
|
|
26
20
|
}
|
|
27
21
|
function ConvertApiToEntity(obj) {
|
|
28
22
|
const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
|
|
@@ -66,7 +66,6 @@ export * from "./interface/intermediary_bank.entity.interface";
|
|
|
66
66
|
export * from "./interface/holiday-list.entity.interface";
|
|
67
67
|
export * from "./interface/holiday.entity.interface";
|
|
68
68
|
export * from "./model/leave.entity.model";
|
|
69
|
-
export * from "./model/leave_count.entity.model";
|
|
70
69
|
export * from "./model/holiday.entity.model";
|
|
71
70
|
export * from "./enums/cron-jobs-name.enum";
|
|
72
71
|
export * from "./enums/cron-jobs-status.enum";
|
|
@@ -98,3 +97,4 @@ export * from "./model/timesheet.entity.model";
|
|
|
98
97
|
export * from "./model/user.entity.model";
|
|
99
98
|
export * from "./model/client-affiliate.entity.model";
|
|
100
99
|
export * from "./model/billing-timesheet.entity.model";
|
|
100
|
+
export * from "./interface/entity-audit-columns.interface";
|
|
@@ -83,7 +83,6 @@ __exportStar(require("./interface/intermediary_bank.entity.interface"), exports)
|
|
|
83
83
|
__exportStar(require("./interface/holiday-list.entity.interface"), exports);
|
|
84
84
|
__exportStar(require("./interface/holiday.entity.interface"), exports);
|
|
85
85
|
__exportStar(require("./model/leave.entity.model"), exports);
|
|
86
|
-
__exportStar(require("./model/leave_count.entity.model"), exports);
|
|
87
86
|
__exportStar(require("./model/holiday.entity.model"), exports);
|
|
88
87
|
__exportStar(require("./enums/cron-jobs-name.enum"), exports);
|
|
89
88
|
__exportStar(require("./enums/cron-jobs-status.enum"), exports);
|
|
@@ -115,3 +114,4 @@ __exportStar(require("./model/timesheet.entity.model"), exports);
|
|
|
115
114
|
__exportStar(require("./model/user.entity.model"), exports);
|
|
116
115
|
__exportStar(require("./model/client-affiliate.entity.model"), exports);
|
|
117
116
|
__exportStar(require("./model/billing-timesheet.entity.model"), exports);
|
|
117
|
+
__exportStar(require("./interface/entity-audit-columns.interface"), exports);
|
|
@@ -10,9 +10,6 @@ import { BillingEntityModel } from "../model/billing.entity.model";
|
|
|
10
10
|
import { ClientAffiliateEntityModel } from "../model/client-affiliate.entity.model";
|
|
11
11
|
import { ClientEntityModel } from "../model/client.entity.model";
|
|
12
12
|
import { ConfigurationEntityModel } from "../model/configuration.model";
|
|
13
|
-
import { HolidayEntityModel } from "../model/holiday.entity.model";
|
|
14
|
-
import { LeaveEntityModel } from "../model/leave.entity.model";
|
|
15
|
-
import { LeaveCountVirtualEntityModel } from "../model/leave_count.entity.model";
|
|
16
13
|
import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
|
|
17
14
|
import { ProjectEntityModel } from "../model/project.entity.model";
|
|
18
15
|
import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
|
|
@@ -57,10 +54,7 @@ import { IToDoListEntity } from "./to-do.entity.interface";
|
|
|
57
54
|
import { IUserEntity } from "./user.entity.interface";
|
|
58
55
|
import { IWorkFromHomeEntity } from "./work_from_home.entity.interface";
|
|
59
56
|
import { IWorkFromHomeHistoryEntity } from "./work_from_home_history.entity.interface";
|
|
60
|
-
export type IApiEntity<T
|
|
61
|
-
createdOn: Date;
|
|
62
|
-
updatedOn: Date;
|
|
63
|
-
}> = Modify<T, {
|
|
57
|
+
export type IApiEntity<T> = Modify<T, {
|
|
64
58
|
createdOn: string;
|
|
65
59
|
updatedOn: string;
|
|
66
60
|
}>;
|
|
@@ -152,10 +146,7 @@ export type IBaseEntityServiceResponse<T> = {
|
|
|
152
146
|
relatedEntities?: IEntityServiceResponse;
|
|
153
147
|
virtualEntities?: IEntityServiceResponse;
|
|
154
148
|
};
|
|
155
|
-
export type IBaseEntityApiResponse<T
|
|
156
|
-
createdOn: Date;
|
|
157
|
-
updatedOn: Date;
|
|
158
|
-
}> = {
|
|
149
|
+
export type IBaseEntityApiResponse<T> = {
|
|
159
150
|
baseEntities: IApiEntity<T>[];
|
|
160
151
|
relatedEntities?: {
|
|
161
152
|
[K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
|
|
@@ -284,12 +275,12 @@ export declare enum VirtualEntityEnum {
|
|
|
284
275
|
}
|
|
285
276
|
export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
|
|
286
277
|
export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
|
|
287
|
-
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.
|
|
278
|
+
export type EnumToModel<T extends EntityEnum | VirtualEntityEnum> = T extends EntityEnum.BILLING ? BillingEntityModel : T extends EntityEnum.CLIENT ? ClientEntityModel : T extends EntityEnum.PROJECT ? ProjectEntityModel : T extends EntityEnum.PROJECT_USER_MAPPING ? ProjectUserMappingEntityModel : T extends EntityEnum.REIMBURSEMENT ? ReimbursementEntityModel : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? ReimbursementExpenseEntityModel : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? BillingReimbursementExpneseEntityModel : T extends EntityEnum.CLIENT_AFFILIATE ? ClientAffiliateEntityModel : T extends EntityEnum.BANK ? BankEntityModel : T extends EntityEnum.CONFIGURATION ? ConfigurationEntityModel : T extends EntityEnum.TASK ? TaskEntityModel : T extends EntityEnum.BILLING_TIMESHEET ? BillingTimesheetEntityModel : T extends EntityEnum.TIMESHEET ? TimesheetEntityModel : UserEntityModel;
|
|
288
279
|
export type EntityMap = {
|
|
289
|
-
[key in EntityEnum
|
|
280
|
+
[key in EntityEnum]: EnumToModel<key>[];
|
|
290
281
|
};
|
|
291
282
|
export type EntityIndexMap = {
|
|
292
|
-
[key in EntityEnum
|
|
283
|
+
[key in EntityEnum]: {
|
|
293
284
|
[id: number]: EnumToModel<key>;
|
|
294
285
|
};
|
|
295
286
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TaskStatusEnum, TaskTypeEnum } from "../enums/task.entity.enum";
|
|
2
|
-
import {
|
|
2
|
+
import { IEntityAuditColumn } from "./entity-audit-columns.interface";
|
|
3
3
|
import { IEntityFilterData } from "./entity.utils.interface";
|
|
4
|
-
export interface ITaskEntity extends
|
|
4
|
+
export interface ITaskEntity extends IEntityAuditColumn {
|
|
5
5
|
id: number;
|
|
6
6
|
name: string;
|
|
7
7
|
description: string;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap
|
|
2
|
-
export declare
|
|
3
|
-
ONE = "one",
|
|
4
|
-
MANY = "many"
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class BaseEntityModel<T extends EntityEnum | VirtualEntityEnum> {
|
|
1
|
+
import { EntityEnum, EntityIndexMap } from "../interface/entity.utils.interface";
|
|
2
|
+
export declare abstract class BaseEntityModel<T extends EntityEnum> {
|
|
7
3
|
protected entityName: T;
|
|
8
4
|
constructor(entityName: T);
|
|
9
5
|
abstract getRelationConfigs(): any[];
|
|
10
6
|
populateRelationsByIndex(entityIndexMap: EntityIndexMap): void;
|
|
11
7
|
static populateRelationsForEntities(entityIndexMap: EntityIndexMap, entityType: EntityEnum): void;
|
|
12
|
-
populateRelations(entityIndexMap: EntityIndexMap): void;
|
|
13
|
-
overwrite(entityIndexMap: EntityIndexMap, indexKey?: string): this;
|
|
14
8
|
}
|
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseEntityModel =
|
|
4
|
-
|
|
5
|
-
(function (RelationType) {
|
|
6
|
-
RelationType["ONE"] = "one";
|
|
7
|
-
RelationType["MANY"] = "many";
|
|
8
|
-
})(RelationType || (exports.RelationType = RelationType = {}));
|
|
3
|
+
exports.BaseEntityModel = void 0;
|
|
4
|
+
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
9
5
|
class BaseEntityModel {
|
|
10
6
|
constructor(entityName) {
|
|
11
7
|
this.entityName = entityName;
|
|
12
8
|
}
|
|
13
9
|
populateRelationsByIndex(entityIndexMap) {
|
|
14
10
|
for (const relationConfig of this.getRelationConfigs() || []) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const thisKey = relationConfig.key;
|
|
18
|
-
// console.log('Populating relation for', relationConfig.name, 'on', this.entityName, relationConfig);
|
|
19
|
-
// debugger;
|
|
20
|
-
if (relationConfig.relation === RelationType.ONE) {
|
|
11
|
+
if (relationConfig.relation === relation_type_enum_1.RelationType.ONE) {
|
|
12
|
+
// @ts-ignore
|
|
21
13
|
const relatedEntities = entityIndexMap[relationConfig.name] || {};
|
|
14
|
+
// @ts-ignore
|
|
22
15
|
let foundRelatedEntities = [];
|
|
23
|
-
if (
|
|
24
|
-
const [parentKey, childKey] =
|
|
25
|
-
|
|
16
|
+
if (relationConfig.mapKeyConfig.key.includes(".")) {
|
|
17
|
+
const [parentKey, childKey] = relationConfig.mapKeyConfig.key.split(".");
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
if (this[parentKey] && this[parentKey][childKey]) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
foundRelatedEntities = [relatedEntities[this[parentKey][childKey]]];
|
|
22
|
+
}
|
|
26
23
|
}
|
|
27
24
|
else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
foundRelatedEntities = Object.values(relatedEntities).filter((entity) => entity[relatedMappingKey] === this[thisMappingKey]);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
foundRelatedEntities = [];
|
|
38
|
-
}
|
|
25
|
+
foundRelatedEntities = relatedEntities[
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
this[relationConfig.mapKeyConfig.key]]
|
|
28
|
+
? // @ts-ignore
|
|
29
|
+
[relatedEntities[this[relationConfig.mapKeyConfig.key]]]
|
|
30
|
+
: [];
|
|
39
31
|
}
|
|
40
32
|
if (foundRelatedEntities.length > 1) {
|
|
41
33
|
throw new Error(`Expected one related entity for ${relationConfig.name} but found ${foundRelatedEntities.length}`);
|
|
42
34
|
}
|
|
43
35
|
if (foundRelatedEntities.length === 0) {
|
|
44
|
-
console.warn(`No related entity found for ${relationConfig.name} with ${
|
|
36
|
+
console.warn(`No related entity found for ${relationConfig.name} with ${relationConfig.mapKeyConfig.key
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
}=${this[relationConfig.mapKeyConfig.foreignKey]}`);
|
|
45
39
|
}
|
|
46
|
-
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
this[relationConfig.key] = foundRelatedEntities[0];
|
|
47
42
|
}
|
|
48
|
-
else if (relationConfig.relation === RelationType.MANY) {
|
|
49
|
-
|
|
43
|
+
else if (relationConfig.relation === relation_type_enum_1.RelationType.MANY) {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
this[relationConfig.key] = [];
|
|
46
|
+
// @ts-ignore
|
|
50
47
|
const relatedEntities = entityIndexMap[relationConfig.name] || {};
|
|
51
48
|
for (const relatedEntity of Object.values(relatedEntities)) {
|
|
52
|
-
if (
|
|
53
|
-
|
|
49
|
+
if (
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
relatedEntity[relationConfig.mapKeyConfig.relationKey] ===
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
this[relationConfig.mapKeyConfig.key]) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
this[relationConfig.key].push(relatedEntity);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -58,20 +60,10 @@ class BaseEntityModel {
|
|
|
58
60
|
}
|
|
59
61
|
static populateRelationsForEntities(entityIndexMap, entityType) {
|
|
60
62
|
for (const key of Object.keys(entityIndexMap[entityType] || {})) {
|
|
63
|
+
// @ts-ignore
|
|
61
64
|
const entity = entityIndexMap[entityType][key];
|
|
62
65
|
entity.populateRelationsByIndex(entityIndexMap);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
populateRelations(entityIndexMap) {
|
|
66
|
-
this.populateRelationsByIndex(entityIndexMap);
|
|
67
|
-
}
|
|
68
|
-
overwrite(entityIndexMap, indexKey = "id") {
|
|
69
|
-
if (this[indexKey] === undefined) {
|
|
70
|
-
console.warn(`Entity of type ${this.entityName} does not have ${indexKey}, cannot merge`);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
entityIndexMap[this.entityName][this[indexKey]] = this;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
68
|
}
|
|
77
69
|
exports.BaseEntityModel = BaseEntityModel;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType,
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, IBaseEntityApiResponse } from "../interface/entity.utils.interface";
|
|
2
2
|
export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
|
|
3
3
|
export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
|
|
4
4
|
existingEntityIndexMap: EntityIndexMap;
|
|
5
5
|
enumEntities: EntityEnum[];
|
|
6
6
|
}): EntityIndexMap;
|
|
7
7
|
export declare function populateRelationsFor(entityIndexMap: EntityIndexMap, enumEntities: EntityEnum[]): void;
|
|
8
|
-
export declare
|
|
9
|
-
[E in EntityEnum | VirtualEntityEnum]?: (json: IApiEntity<EnumEntityType<E>>) => EnumToModel<E>;
|
|
10
|
-
};
|
|
11
|
-
export declare function entityMapToModels(entityMap: EntityMap): void;
|
|
12
|
-
export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
|
|
13
|
-
export declare function entityMapToEntityIndexMap(entityMap: EntityMap, entityRelationsFor: EntityEnum[]): EntityIndexMap;
|
|
14
|
-
export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
|
|
15
|
-
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
16
|
-
}): {
|
|
17
|
-
[E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
|
|
18
|
-
};
|
|
8
|
+
export declare function parseEntities<T extends EnumEntityType<EntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum, entityMap: EntityMap, epoch?: boolean): EntityMap;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.entityEnumToEntityModel = void 0;
|
|
4
3
|
exports.mapToIndex = mapToIndex;
|
|
5
4
|
exports.getEntityIndexMap = getEntityIndexMap;
|
|
6
5
|
exports.populateRelationsFor = populateRelationsFor;
|
|
7
|
-
exports.entityMapToModels = entityMapToModels;
|
|
8
6
|
exports.parseEntities = parseEntities;
|
|
9
|
-
exports.entityMapToEntityIndexMap = entityMapToEntityIndexMap;
|
|
10
|
-
exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
|
|
11
7
|
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
12
8
|
const bank_entity_model_1 = require("./bank.entity.model");
|
|
13
9
|
const base_entity_model_1 = require("./base.entity.model");
|
|
@@ -16,9 +12,6 @@ const billing_timesheet_entity_model_1 = require("./billing-timesheet.entity.mod
|
|
|
16
12
|
const billing_entity_model_1 = require("./billing.entity.model");
|
|
17
13
|
const client_affiliate_entity_model_1 = require("./client-affiliate.entity.model");
|
|
18
14
|
const client_entity_model_1 = require("./client.entity.model");
|
|
19
|
-
const holiday_entity_model_1 = require("./holiday.entity.model");
|
|
20
|
-
const leave_entity_model_1 = require("./leave.entity.model");
|
|
21
|
-
const leave_count_entity_model_1 = require("./leave_count.entity.model");
|
|
22
15
|
const configuration_model_1 = require("./configuration.model");
|
|
23
16
|
const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
|
|
24
17
|
const project_entity_model_1 = require("./project.entity.model");
|
|
@@ -54,66 +47,55 @@ function populateRelationsFor(entityIndexMap, enumEntities) {
|
|
|
54
47
|
base_entity_model_1.BaseEntityModel.populateRelationsForEntities(entityIndexMap, entity);
|
|
55
48
|
});
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
[entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
|
|
59
|
-
[entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
|
|
60
|
-
[entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
|
|
61
|
-
[entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
|
|
62
|
-
[entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
|
|
63
|
-
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
|
|
64
|
-
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
|
|
65
|
-
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
|
|
66
|
-
[entity_utils_interface_1.EntityEnum.HOLIDAY]: holiday_entity_model_1.HolidayEntityModel.fromApiEntity,
|
|
67
|
-
[entity_utils_interface_1.EntityEnum.LEAVE]: leave_entity_model_1.LeaveEntityModel.fromApiEntity,
|
|
68
|
-
[entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT]: leave_count_entity_model_1.LeaveCountVirtualEntityModel.fromApiEntity,
|
|
69
|
-
// Add other entities here as needed
|
|
70
|
-
[entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
|
|
71
|
-
[entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
|
|
72
|
-
[entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
|
|
73
|
-
[entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
|
|
74
|
-
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
|
|
75
|
-
[entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
|
|
76
|
-
};
|
|
77
|
-
function entityMapToModels(entityMap) {
|
|
78
|
-
for (const entityName in entityMap) {
|
|
79
|
-
if (!(entityName in exports.entityEnumToEntityModel)) {
|
|
80
|
-
throw new Error(`Unknown entity: ${entityName}`);
|
|
81
|
-
}
|
|
82
|
-
entityMap[entityName] = entityMap[entityName].map((entity) => exports.entityEnumToEntityModel[entityName](entity));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function parseEntities(json, baseEntity, entityMap) {
|
|
50
|
+
function parseEntities(json, baseEntity, entityMap, epoch) {
|
|
86
51
|
var _a;
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
const nonEpochEntityFromJsonMappings = {
|
|
53
|
+
[entity_utils_interface_1.EntityEnum.PROJECT]: project_entity_model_1.ProjectEntityModel.fromApiEntity,
|
|
54
|
+
[entity_utils_interface_1.EntityEnum.CLIENT]: client_entity_model_1.ClientEntityModel.fromApiEntity,
|
|
55
|
+
[entity_utils_interface_1.EntityEnum.BILLING]: billing_entity_model_1.BillingEntityModel.fromApiEntity,
|
|
56
|
+
[entity_utils_interface_1.EntityEnum.USER]: user_entity_model_1.UserEntityModel.fromApiEntity,
|
|
57
|
+
[entity_utils_interface_1.EntityEnum.PROJECT_USER_MAPPING]: project_user_mapping_entity_model_1.ProjectUserMappingEntityModel.fromApiEntity,
|
|
58
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT]: reimbursement_entity_model_1.ReimbursementEntityModel.fromApiEntity,
|
|
59
|
+
[entity_utils_interface_1.EntityEnum.REIMBURSEMENT_EXPENSE]: reimbursement_expense_entity_model_1.ReimbursementExpenseEntityModel.fromApiEntity,
|
|
60
|
+
[entity_utils_interface_1.EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]: billing_reimbursement_expense_entity_model_1.BillingReimbursementExpneseEntityModel.fromApiEntity,
|
|
61
|
+
[entity_utils_interface_1.EntityEnum.CLIENT_AFFILIATE]: client_affiliate_entity_model_1.ClientAffiliateEntityModel.fromApiEntity,
|
|
62
|
+
[entity_utils_interface_1.EntityEnum.BANK]: bank_entity_model_1.BankEntityModel.fromApiEntity,
|
|
63
|
+
[entity_utils_interface_1.EntityEnum.CONFIGURATION]: configuration_model_1.ConfigurationEntityModel.fromApiEntity,
|
|
64
|
+
// [EntityEnum.TASK]: TaskEntityModel.fromApiEntity,
|
|
65
|
+
[entity_utils_interface_1.EntityEnum.BILLING_TIMESHEET]: billing_timesheet_entity_model_1.BillingTimesheetEntityModel.fromApiEntity,
|
|
66
|
+
[entity_utils_interface_1.EntityEnum.TIMESHEET]: timesheet_entity_model_1.TimesheetEntityModel.fromApiEntity,
|
|
67
|
+
};
|
|
68
|
+
const epochEntityFromJsonMappings = {
|
|
69
|
+
// [EntityEnum.PROJECT]: ProjectEntityModel.fromApiEntity,
|
|
70
|
+
// [EntityEnum.CLIENT]: ClientEntityModel.fromApiEntity,
|
|
71
|
+
// [EntityEnum.BILLING]: BillingEntityModel.fromApiEntity,
|
|
72
|
+
// [EntityEnum.USER]: UserEntityModel.fromApiEntity,
|
|
73
|
+
// [EntityEnum.PROJECT_USER_MAPPING]:
|
|
74
|
+
// ProjectUserMappingEntityModel.fromApiEntity,
|
|
75
|
+
// [EntityEnum.REIMBURSEMENT]: ReimbursementEntityModel.fromApiEntity,
|
|
76
|
+
// [EntityEnum.REIMBURSEMENT_EXPENSE]:
|
|
77
|
+
// ReimbursementExpenseEntityModel.fromApiEntity,
|
|
78
|
+
// [EntityEnum.BILLING_REIMBURSEMENT_EXPENSE]:
|
|
79
|
+
// BillingReimbursementExpneseEntityModel.fromApiEntity,
|
|
80
|
+
// [EntityEnum.CLIENT_AFFILIATE]: ClientAffiliateEntityModel.fromApiEntity,
|
|
81
|
+
// [EntityEnum.BANK]: BankEntityModel.fromApiEntity,
|
|
82
|
+
// [EntityEnum.CONFIGURATION]: ConfigurationEntityModel.fromApiEntity,
|
|
83
|
+
[entity_utils_interface_1.EntityEnum.TASK]: task_entity_model_1.TaskEntityModel.fromApiEntity,
|
|
84
|
+
// [EntityEnum.BILLING_TIMESHEET]: BillingTimesheetEntityModel.fromApiEntity,
|
|
85
|
+
// [EntityEnum.TIMESHEET]: TimesheetEntityModel.fromApiEntity,
|
|
86
|
+
};
|
|
87
|
+
let entityFromJsonMappings = nonEpochEntityFromJsonMappings;
|
|
88
|
+
if (epoch) {
|
|
89
|
+
entityFromJsonMappings = epochEntityFromJsonMappings;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
if (json["relatedEntities"]) {
|
|
92
|
-
const relatedEntities = json["relatedEntities"];
|
|
93
|
-
for (const entityName in relatedEntities) {
|
|
94
|
-
parseEntities(
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
relatedEntities[entityName], entityName, entityMap);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return entityMap;
|
|
100
|
-
}
|
|
101
|
-
function entityMapToEntityIndexMap(entityMap, entityRelationsFor) {
|
|
102
|
-
entityMapToModels(entityMap);
|
|
103
|
-
const entityIndexMap = mapToIndex(entityMap);
|
|
104
|
-
populateRelationsFor(entityIndexMap, entityRelationsFor);
|
|
105
|
-
return entityIndexMap;
|
|
106
|
-
}
|
|
107
|
-
function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
|
|
108
|
-
var _a;
|
|
109
|
-
if (!(baseEntity in exports.entityEnumToEntityModel)) {
|
|
91
|
+
if (!(baseEntity in entityFromJsonMappings)) {
|
|
110
92
|
throw new Error(`Unknown entity: ${baseEntity}`);
|
|
111
93
|
}
|
|
112
|
-
entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []);
|
|
94
|
+
entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []).map((e) => entityFromJsonMappings[baseEntity](e));
|
|
113
95
|
if (json["relatedEntities"]) {
|
|
114
96
|
const relatedEntities = json["relatedEntities"];
|
|
115
97
|
for (const entityName in relatedEntities) {
|
|
116
|
-
|
|
98
|
+
parseEntities(
|
|
117
99
|
// @ts-ignore
|
|
118
100
|
relatedEntities[entityName], entityName, entityMap);
|
|
119
101
|
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
-
import { BaseEntityModel } from "./base.entity.model";
|
|
4
|
-
export declare class HolidayEntityModel extends BaseEntityModel<EntityEnum.HOLIDAY> implements IHolidayApiEntity {
|
|
5
|
-
id: number;
|
|
6
|
-
holidayListId: number;
|
|
7
|
-
dateCode: string;
|
|
8
|
-
createdBy: number;
|
|
9
|
-
updatedBy: number;
|
|
10
|
-
createdOn: string;
|
|
11
|
-
updatedOn: string;
|
|
12
|
-
getRelationConfigs(): never[];
|
|
13
|
-
static fromApiEntity(apiEntity: IHolidayApiEntity): HolidayEntityModel;
|
|
14
|
-
}
|
|
1
|
+
export declare const toBeDeleted = "holiday";
|
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import { DateCodeModel } from "../../utils";
|
|
3
|
+
// import { IAuditColumnEntity } from "../interface/audit-column.entity.interface";
|
|
4
|
+
// import { IHolidayEntity } from "../interface/holiday.entity.interface";
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
exports.toBeDeleted = void 0;
|
|
7
|
+
// export class BaseEntityModelV1<T extends IAuditColumnEntity> {
|
|
8
|
+
// createdOn: Date;
|
|
9
|
+
// updatedOn: Date;
|
|
10
|
+
// createdBy: number;
|
|
11
|
+
// updatedBy: number;
|
|
12
|
+
// constructor(data: T) {
|
|
13
|
+
// this.createdOn = data.createdOn;
|
|
14
|
+
// this.updatedOn = data.updatedOn;
|
|
15
|
+
// this.createdBy = data.createdBy;
|
|
16
|
+
// this.updatedBy = data.updatedBy;
|
|
17
|
+
// }
|
|
18
|
+
// }
|
|
19
|
+
// export class HolidayEntityModel
|
|
20
|
+
// extends BaseEntityModelV1<IHolidayEntity>
|
|
21
|
+
// implements IHolidayEntity
|
|
22
|
+
// {
|
|
23
|
+
// id: number;
|
|
24
|
+
// holidayListId: number;
|
|
25
|
+
// dateCode: string;
|
|
26
|
+
// private constructor(data: IHolidayEntity) {
|
|
27
|
+
// super(data);
|
|
28
|
+
// this.id = data.id;
|
|
29
|
+
// this.holidayListId = data.holidayListId;
|
|
30
|
+
// this.dateCode = data.dateCode;
|
|
31
|
+
// }
|
|
32
|
+
// getDateCodeModel(): DateCodeModel {
|
|
33
|
+
// return new DateCodeModel(this.dateCode);
|
|
34
|
+
// }
|
|
35
|
+
// static fromEntity(data: IHolidayEntity): HolidayEntityModel {
|
|
36
|
+
// return new HolidayEntityModel(data);
|
|
37
|
+
// }
|
|
38
|
+
// static getDateCodeModelFromDate(
|
|
39
|
+
// models: HolidayEntityModel[]
|
|
40
|
+
// ): DateCodeModel[] {
|
|
41
|
+
// return models.map((model) => model.getDateCodeModel());
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
exports.toBeDeleted = "holiday";
|
|
@@ -3,12 +3,7 @@ import { DateCodeModel, Weekday } from "../../utils";
|
|
|
3
3
|
import { DurationTypeEnum } from "../enums/duration-type.enum";
|
|
4
4
|
import { LeaveTypeEnum } from "../enums/leave-type.enum";
|
|
5
5
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
6
|
-
|
|
7
|
-
import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
8
|
-
import { BaseEntityModel } from "./base.entity.model";
|
|
9
|
-
import { LeaveCountVirtualEntityModel } from "./leave_count.entity.model";
|
|
10
|
-
import { UserEntityModel } from "./user.entity.model";
|
|
11
|
-
export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE> implements ILeaveApiEntity {
|
|
6
|
+
export declare class LeaveEntityModel implements ILeaveApiEntity {
|
|
12
7
|
id: number;
|
|
13
8
|
employeeId: number;
|
|
14
9
|
fromDate: string;
|
|
@@ -22,55 +17,13 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
|
|
|
22
17
|
updatedOn: string;
|
|
23
18
|
createdBy: number;
|
|
24
19
|
updatedBy: number;
|
|
25
|
-
|
|
26
|
-
createdByUser?: UserEntityModel;
|
|
27
|
-
updatedByUser?: UserEntityModel;
|
|
28
|
-
user?: UserEntityModel;
|
|
20
|
+
private constructor();
|
|
29
21
|
static fromEntity(data: ILeaveApiEntity): LeaveEntityModel;
|
|
22
|
+
isMoreThanOneDayLeave(): boolean;
|
|
30
23
|
getLeaveDuration(excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[]): number;
|
|
31
24
|
static getLeaveDuration(leaves: LeaveEntityModel[], excludeWeekdays?: Weekday[], excludeDates?: DateCodeModel[], leaveStatusEnum?: LeaveStatusEnum[]): number;
|
|
32
25
|
getDateCodeModels(dateCodeIncludePredicates?: ((dateModel: DateCodeModel) => boolean)[], dateCodeExcludePredicates?: ((dateModel: DateCodeModel) => boolean)[]): DateCodeModel[];
|
|
33
26
|
static getLeaveApprovePredicate(): (leave: LeaveEntityModel) => boolean;
|
|
34
27
|
static getLeavePendingPredicate(): (leave: LeaveEntityModel) => boolean;
|
|
35
28
|
static getLeavesByPredicates(leaves: LeaveEntityModel[], includePredicates?: ((leave: LeaveEntityModel) => boolean)[], excludePredicates?: ((leave: LeaveEntityModel) => boolean)[]): LeaveEntityModel[];
|
|
36
|
-
static orderByFromDateAsc(leaves: LeaveEntityModel[]): LeaveEntityModel[];
|
|
37
|
-
isWeekendSucceeds(): boolean;
|
|
38
|
-
isWeekendPrecedes(): boolean;
|
|
39
|
-
isHolidaySucceeds(holidays: DateCodeModel[]): boolean;
|
|
40
|
-
isHolidayPrecedes(holidays: DateCodeModel[]): boolean;
|
|
41
|
-
getRelationConfigs(): any[];
|
|
42
|
-
static relationConfigs: ({
|
|
43
|
-
name: VirtualEntityEnum;
|
|
44
|
-
relation: RelationType;
|
|
45
|
-
key: string;
|
|
46
|
-
mapKeyConfig: {
|
|
47
|
-
relationKey: string;
|
|
48
|
-
key: string;
|
|
49
|
-
};
|
|
50
|
-
} | {
|
|
51
|
-
name: EntityEnum;
|
|
52
|
-
relation: RelationType;
|
|
53
|
-
key: string;
|
|
54
|
-
mapKeyConfig: {
|
|
55
|
-
relationKey: string;
|
|
56
|
-
key: string;
|
|
57
|
-
};
|
|
58
|
-
})[];
|
|
59
|
-
static fromApiEntity(apiEntity: ILeaveApiEntity): LeaveEntityModel;
|
|
60
|
-
static getPendingApprovalStatuses(): LeaveStatusEnum[];
|
|
61
|
-
getStatusLabel(): string;
|
|
62
|
-
getTypeLabel(): string;
|
|
63
|
-
getLeaveCount(): number;
|
|
64
|
-
static getLeaveCount(leaveEntities: LeaveEntityModel[]): number;
|
|
65
|
-
isMoreThanOneDayLeave(): boolean;
|
|
66
|
-
getFromDateLabel(): string;
|
|
67
|
-
getToDateLabel(): string;
|
|
68
|
-
getDateDurationLabel(): string;
|
|
69
|
-
static getLeaveStatusPriority(): {
|
|
70
|
-
pending_approval: number;
|
|
71
|
-
edit_approval: number;
|
|
72
|
-
delete_approval: number;
|
|
73
|
-
approved: number;
|
|
74
|
-
rejected: number;
|
|
75
|
-
};
|
|
76
29
|
}
|
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LeaveEntityModel = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
|
-
const string_util_1 = require("../../utils/string.util");
|
|
6
5
|
const duration_type_enum_1 = require("../enums/duration-type.enum");
|
|
7
|
-
const leave_type_enum_1 = require("../enums/leave-type.enum");
|
|
8
6
|
const leave_status_enum_1 = require("../enums/leave.status.enum");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const base_entity_model_1 = require("./base.entity.model");
|
|
12
|
-
class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
15
|
-
this.id = 0;
|
|
16
|
-
this.employeeId = 0;
|
|
17
|
-
this.fromDate = "";
|
|
18
|
-
this.toDate = "";
|
|
19
|
-
this.reason = "";
|
|
20
|
-
this.durationType = duration_type_enum_1.DurationTypeEnum.FULL;
|
|
21
|
-
this.status = leave_status_enum_1.LeaveStatusEnum.DELETED;
|
|
22
|
-
this.type = leave_type_enum_1.LeaveTypeEnum.SICK;
|
|
7
|
+
class LeaveEntityModel {
|
|
8
|
+
constructor(data) {
|
|
23
9
|
this.createdOn = "";
|
|
24
10
|
this.updatedOn = "";
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
11
|
+
this.id = data.id;
|
|
12
|
+
this.employeeId = data.employeeId;
|
|
13
|
+
this.fromDate = data.fromDate;
|
|
14
|
+
this.toDate = data.toDate;
|
|
15
|
+
this.reason = data.reason;
|
|
16
|
+
this.durationType = data.durationType;
|
|
17
|
+
this.status = data.status;
|
|
18
|
+
this.remark = data.remark;
|
|
19
|
+
this.type = data.type;
|
|
20
|
+
this.createdOn = data.createdOn;
|
|
21
|
+
this.updatedOn = data.updatedOn;
|
|
22
|
+
this.createdBy = data.createdBy;
|
|
23
|
+
this.updatedBy = data.updatedBy;
|
|
27
24
|
}
|
|
28
25
|
static fromEntity(data) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
return new LeaveEntityModel(data);
|
|
27
|
+
}
|
|
28
|
+
isMoreThanOneDayLeave() {
|
|
29
|
+
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
30
|
+
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
31
|
+
return fromDate.diffInDays(toDate) > 1;
|
|
32
32
|
}
|
|
33
33
|
getLeaveDuration(excludeWeekdays = [], excludeDates = []) {
|
|
34
34
|
if (!this.isMoreThanOneDayLeave()) {
|
|
@@ -80,138 +80,5 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
80
80
|
return leaves.filter((leave) => includePredicates.every((predicate) => predicate(leave)) &&
|
|
81
81
|
excludePredicates.every((predicate) => !predicate(leave)));
|
|
82
82
|
}
|
|
83
|
-
static orderByFromDateAsc(leaves) {
|
|
84
|
-
return leaves.sort((a, b) => {
|
|
85
|
-
const dateA = new Date(a.fromDate);
|
|
86
|
-
const dateB = new Date(b.fromDate);
|
|
87
|
-
return dateA.getTime() - dateB.getTime();
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
isWeekendSucceeds() {
|
|
91
|
-
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
92
|
-
const nextDate = toDate.getByOffset(1);
|
|
93
|
-
return nextDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
|
|
94
|
-
}
|
|
95
|
-
isWeekendPrecedes() {
|
|
96
|
-
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
97
|
-
const prevDate = fromDate.getByOffset(-1);
|
|
98
|
-
return prevDate.isDayPresent([utils_1.Weekday.Saturday, utils_1.Weekday.Sunday]);
|
|
99
|
-
}
|
|
100
|
-
isHolidaySucceeds(holidays) {
|
|
101
|
-
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
102
|
-
const nextDate = toDate.getByOffset(1);
|
|
103
|
-
return holidays.some((holiday) => holiday.isSame(nextDate));
|
|
104
|
-
}
|
|
105
|
-
isHolidayPrecedes(holidays) {
|
|
106
|
-
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
107
|
-
const prevDate = fromDate.getByOffset(-1);
|
|
108
|
-
return holidays.some((holiday) => holiday.isSame(prevDate));
|
|
109
|
-
}
|
|
110
|
-
getRelationConfigs() {
|
|
111
|
-
return this.constructor.prototype.constructor.relationConfigs;
|
|
112
|
-
}
|
|
113
|
-
static fromApiEntity(apiEntity) {
|
|
114
|
-
return LeaveEntityModel.fromEntity(apiEntity);
|
|
115
|
-
}
|
|
116
|
-
static getPendingApprovalStatuses() {
|
|
117
|
-
return [
|
|
118
|
-
leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
|
|
119
|
-
leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
|
|
120
|
-
leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
|
|
121
|
-
];
|
|
122
|
-
}
|
|
123
|
-
getStatusLabel() {
|
|
124
|
-
const pendingStatuses = LeaveEntityModel.getPendingApprovalStatuses();
|
|
125
|
-
let statusLabel = '';
|
|
126
|
-
if (pendingStatuses.includes(this.status)) {
|
|
127
|
-
statusLabel = 'PENDING_APPROVAL';
|
|
128
|
-
}
|
|
129
|
-
else if (this.status === leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED) {
|
|
130
|
-
statusLabel = 'CHANGES_REJECTED';
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
statusLabel = this.status.toString();
|
|
134
|
-
}
|
|
135
|
-
return (0, string_util_1.formatString)(statusLabel);
|
|
136
|
-
}
|
|
137
|
-
getTypeLabel() {
|
|
138
|
-
return (0, string_util_1.formatString)(this.type.toString());
|
|
139
|
-
}
|
|
140
|
-
getLeaveCount() {
|
|
141
|
-
var _a;
|
|
142
|
-
return ((_a = this.leaveCount) === null || _a === void 0 ? void 0 : _a.count) || 0;
|
|
143
|
-
}
|
|
144
|
-
static getLeaveCount(leaveEntities) {
|
|
145
|
-
return leaveEntities.reduce((acc, leave) => acc + leave.getLeaveCount(), 0);
|
|
146
|
-
}
|
|
147
|
-
isMoreThanOneDayLeave() {
|
|
148
|
-
const fromDate = new utils_1.DateCodeModel(this.fromDate);
|
|
149
|
-
const toDate = new utils_1.DateCodeModel(this.toDate);
|
|
150
|
-
return fromDate.diffInDays(toDate) > 1;
|
|
151
|
-
}
|
|
152
|
-
getFromDateLabel() {
|
|
153
|
-
const statues = [duration_type_enum_1.DurationTypeEnum.SECOND, duration_type_enum_1.DurationTypeEnum.SECOND_FULL, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
|
|
154
|
-
if (statues.includes(this.durationType)) {
|
|
155
|
-
return 'Second Half';
|
|
156
|
-
}
|
|
157
|
-
return 'Full Day';
|
|
158
|
-
}
|
|
159
|
-
getToDateLabel() {
|
|
160
|
-
const statues = [duration_type_enum_1.DurationTypeEnum.FIRST, duration_type_enum_1.DurationTypeEnum.FULL_FIRST, duration_type_enum_1.DurationTypeEnum.SECOND_FIRST];
|
|
161
|
-
if (statues.includes(this.durationType)) {
|
|
162
|
-
return 'First Half';
|
|
163
|
-
}
|
|
164
|
-
return 'Full Day';
|
|
165
|
-
}
|
|
166
|
-
getDateDurationLabel() {
|
|
167
|
-
if (!this.isMoreThanOneDayLeave()) {
|
|
168
|
-
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} ${this.durationType === duration_type_enum_1.DurationTypeEnum.FULL ? '(Full Day)' : this.durationType === duration_type_enum_1.DurationTypeEnum.FIRST ? '(First Half)' : '(Second Half)'}`;
|
|
169
|
-
}
|
|
170
|
-
return `${new utils_1.DateCodeModel(this.fromDate).getFormattedDateWithMonthName()} (${this.getFromDateLabel()}) - ${new utils_1.DateCodeModel(this.toDate).getFormattedDateWithMonthName()} (${this.getToDateLabel()})`;
|
|
171
|
-
}
|
|
172
|
-
static getLeaveStatusPriority() {
|
|
173
|
-
return {
|
|
174
|
-
[leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: 1,
|
|
175
|
-
[leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: 2,
|
|
176
|
-
[leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: 3,
|
|
177
|
-
[leave_status_enum_1.LeaveStatusEnum.APPROVED]: 4,
|
|
178
|
-
[leave_status_enum_1.LeaveStatusEnum.REJECTED]: 5,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
83
|
}
|
|
182
84
|
exports.LeaveEntityModel = LeaveEntityModel;
|
|
183
|
-
LeaveEntityModel.relationConfigs = [
|
|
184
|
-
{
|
|
185
|
-
name: entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT,
|
|
186
|
-
relation: relation_type_enum_1.RelationType.ONE,
|
|
187
|
-
key: 'leaveCount',
|
|
188
|
-
mapKeyConfig: {
|
|
189
|
-
relationKey: 'leaveId',
|
|
190
|
-
key: 'id',
|
|
191
|
-
},
|
|
192
|
-
}, {
|
|
193
|
-
name: entity_utils_interface_1.EntityEnum.USER,
|
|
194
|
-
relation: relation_type_enum_1.RelationType.ONE,
|
|
195
|
-
key: 'createdByUser',
|
|
196
|
-
mapKeyConfig: {
|
|
197
|
-
relationKey: 'id',
|
|
198
|
-
key: 'createdBy',
|
|
199
|
-
},
|
|
200
|
-
}, {
|
|
201
|
-
name: entity_utils_interface_1.EntityEnum.USER,
|
|
202
|
-
relation: relation_type_enum_1.RelationType.ONE,
|
|
203
|
-
key: 'updatedByUser',
|
|
204
|
-
mapKeyConfig: {
|
|
205
|
-
relationKey: 'id',
|
|
206
|
-
key: 'updatedBy',
|
|
207
|
-
},
|
|
208
|
-
}, {
|
|
209
|
-
name: entity_utils_interface_1.EntityEnum.USER,
|
|
210
|
-
relation: relation_type_enum_1.RelationType.ONE,
|
|
211
|
-
key: 'user',
|
|
212
|
-
mapKeyConfig: {
|
|
213
|
-
relationKey: 'id',
|
|
214
|
-
key: 'employeeId',
|
|
215
|
-
},
|
|
216
|
-
}
|
|
217
|
-
];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ITaskApiEntity } from "../../api";
|
|
2
1
|
import { TaskStatusEnum, TaskTypeEnum } from "../enums/task.entity.enum";
|
|
3
2
|
import { EntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
+
import { ITaskEntity } from "../interface/task.entity.interface";
|
|
4
4
|
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
-
export declare class TaskEntityModel extends BaseEntityModel<EntityEnum.TASK> implements
|
|
5
|
+
export declare class TaskEntityModel extends BaseEntityModel<EntityEnum.TASK> implements ITaskEntity {
|
|
6
6
|
id: number;
|
|
7
7
|
name: string;
|
|
8
8
|
description: string;
|
|
@@ -10,8 +10,8 @@ export declare class TaskEntityModel extends BaseEntityModel<EntityEnum.TASK> im
|
|
|
10
10
|
type: TaskTypeEnum;
|
|
11
11
|
createdBy: number;
|
|
12
12
|
updatedBy: number;
|
|
13
|
-
createdOn:
|
|
14
|
-
updatedOn:
|
|
15
|
-
static fromApiEntity(apiEntity:
|
|
13
|
+
createdOn: number;
|
|
14
|
+
updatedOn: number;
|
|
15
|
+
static fromApiEntity(apiEntity: ITaskEntity): TaskEntityModel;
|
|
16
16
|
getRelationConfigs(): any[];
|
|
17
17
|
}
|
|
@@ -14,8 +14,8 @@ class TaskEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
14
14
|
this.type = task_entity_enum_1.TaskTypeEnum.billable;
|
|
15
15
|
this.createdBy = 0;
|
|
16
16
|
this.updatedBy = 0;
|
|
17
|
-
this.createdOn =
|
|
18
|
-
this.updatedOn =
|
|
17
|
+
this.createdOn = 0;
|
|
18
|
+
this.updatedOn = 0;
|
|
19
19
|
}
|
|
20
20
|
static fromApiEntity(apiEntity) {
|
|
21
21
|
const entity = new TaskEntityModel(entity_utils_interface_1.EntityEnum.TASK);
|
package/dist/src/utils/index.js
CHANGED
|
@@ -17,5 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./date.util"), exports);
|
|
18
18
|
__exportStar(require("./helper.fn.util"), exports);
|
|
19
19
|
__exportStar(require("./models/date-code.model.util"), exports);
|
|
20
|
-
__exportStar(require("./string.util"), exports);
|
|
21
|
-
__exportStar(require("./entity.flow.util"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatString(input: string): string;
|
|
@@ -1,15 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatString = formatString;
|
|
4
|
-
function formatString(input) {
|
|
5
|
-
if (input.includes('_')) {
|
|
6
|
-
return input
|
|
7
|
-
.split('_')
|
|
8
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
9
|
-
.join(' ');
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
// For single-word strings, capitalize the first letter
|
|
13
|
-
return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
|
|
14
|
-
}
|
|
15
|
-
}
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DateCodeModel } from "../../utils";
|
|
2
|
-
import { IApiEntity, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
3
|
-
import { ILeaveCountVirtualEntity } from "../interface/leave.entity.interface";
|
|
4
|
-
import { BaseEntityModel } from "./base.entity.model";
|
|
5
|
-
import { LeaveEntityModel } from "./leave.entity.model";
|
|
6
|
-
export declare class LeaveCountVirtualEntityModel extends BaseEntityModel<VirtualEntityEnum.LEAVE_COUNT> implements IApiEntity<ILeaveCountVirtualEntity> {
|
|
7
|
-
id: number;
|
|
8
|
-
period: string;
|
|
9
|
-
leaveId?: number;
|
|
10
|
-
count: number;
|
|
11
|
-
createdBy: number;
|
|
12
|
-
updatedBy: number;
|
|
13
|
-
createdOn: string;
|
|
14
|
-
updatedOn: string;
|
|
15
|
-
static fromApiEntity(apiEntity: IApiEntity<ILeaveCountVirtualEntity>): LeaveCountVirtualEntityModel;
|
|
16
|
-
getRelationConfigs(): any[];
|
|
17
|
-
static relationConfigs: never[];
|
|
18
|
-
static fromLeaveHoliday(leaveModel: LeaveEntityModel, holidayDateCodes: DateCodeModel[]): LeaveCountVirtualEntityModel;
|
|
19
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LeaveCountVirtualEntityModel = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const leave_type_enum_1 = require("../enums/leave-type.enum");
|
|
6
|
-
const entity_utils_interface_1 = require("../interface/entity.utils.interface");
|
|
7
|
-
const base_entity_model_1 = require("./base.entity.model");
|
|
8
|
-
class LeaveCountVirtualEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.id = 0;
|
|
12
|
-
this.period = "";
|
|
13
|
-
this.count = 0;
|
|
14
|
-
this.createdBy = 0;
|
|
15
|
-
this.updatedBy = 0;
|
|
16
|
-
this.createdOn = "";
|
|
17
|
-
this.updatedOn = "";
|
|
18
|
-
}
|
|
19
|
-
static fromApiEntity(apiEntity) {
|
|
20
|
-
const entity = new LeaveCountVirtualEntityModel(entity_utils_interface_1.VirtualEntityEnum.LEAVE_COUNT);
|
|
21
|
-
Object.assign(entity, apiEntity);
|
|
22
|
-
return entity;
|
|
23
|
-
}
|
|
24
|
-
getRelationConfigs() {
|
|
25
|
-
return this.constructor.prototype.constructor.relationConfigs;
|
|
26
|
-
}
|
|
27
|
-
static fromLeaveHoliday(leaveModel, holidayDateCodes) {
|
|
28
|
-
const leaveCountVirtualEntity = {
|
|
29
|
-
leaveId: leaveModel.id,
|
|
30
|
-
count: leaveModel.getLeaveDuration([utils_1.Weekday.Sunday, utils_1.Weekday.Saturday], holidayDateCodes) +
|
|
31
|
-
(leaveModel.type === leave_type_enum_1.LeaveTypeEnum.SICK &&
|
|
32
|
-
(leaveModel.isWeekendPrecedes() ||
|
|
33
|
-
leaveModel.isWeekendSucceeds() ||
|
|
34
|
-
leaveModel.isHolidayPrecedes(holidayDateCodes) ||
|
|
35
|
-
leaveModel.isHolidaySucceeds(holidayDateCodes))
|
|
36
|
-
? 2
|
|
37
|
-
: 0),
|
|
38
|
-
createdBy: leaveModel.createdBy,
|
|
39
|
-
updatedBy: leaveModel.updatedBy,
|
|
40
|
-
createdOn: leaveModel.createdOn,
|
|
41
|
-
updatedOn: leaveModel.updatedOn,
|
|
42
|
-
id: leaveModel.id,
|
|
43
|
-
period: leaveModel.fromDate + leaveModel.toDate + leaveModel.durationType,
|
|
44
|
-
};
|
|
45
|
-
return LeaveCountVirtualEntityModel.fromApiEntity(leaveCountVirtualEntity);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.LeaveCountVirtualEntityModel = LeaveCountVirtualEntityModel;
|
|
49
|
-
// static relationConfigs = [
|
|
50
|
-
// {
|
|
51
|
-
// name: EntityEnum.LEAVE,
|
|
52
|
-
// relation: RelationType.ONE,
|
|
53
|
-
// key: 'leaveCount',
|
|
54
|
-
// mapKeyConfig: {
|
|
55
|
-
// relationKey: 'id',
|
|
56
|
-
// key: 'leaveId',
|
|
57
|
-
// },
|
|
58
|
-
// },
|
|
59
|
-
// ];
|
|
60
|
-
LeaveCountVirtualEntityModel.relationConfigs = [];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { LeaveActionEnum, LeaveStatusEnum } from "../entities";
|
|
2
|
-
export type LeaveStatusActionPair = {
|
|
3
|
-
status: LeaveStatusEnum;
|
|
4
|
-
action: LeaveActionEnum;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Gets available actions for a leave based on current status and user permissions
|
|
8
|
-
* @param entityFlowConfig - The flow configuration for the entity
|
|
9
|
-
* @param currentStatus - The current status of the leave
|
|
10
|
-
* @param userPermissions - Array of permissions the user has
|
|
11
|
-
* @param combineActions - Array of action values to combine into a single action
|
|
12
|
-
* @param data - Optional function to provide additional visibility conditions based on the entity data
|
|
13
|
-
* @returns Array of available actions with labels and values
|
|
14
|
-
* @throws Error if user has multiple permissions for a single action
|
|
15
|
-
*/
|
|
16
|
-
export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(entityFlowConfig: {
|
|
17
|
-
[key in T['status']]?: {
|
|
18
|
-
actions: {
|
|
19
|
-
[key in T['action']]?: {
|
|
20
|
-
permissions: string[];
|
|
21
|
-
next: () => T['status'];
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}, currentStatus: T['status'] | null, userPermissions: string[], combineActions?: T['action'][], actionLabels?: {
|
|
26
|
-
[key in T['action']]?: string;
|
|
27
|
-
}, data?: (a: E) => {
|
|
28
|
-
[key: string]: () => boolean;
|
|
29
|
-
}): {
|
|
30
|
-
label: string;
|
|
31
|
-
value: T['action'] | string;
|
|
32
|
-
}[];
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPermittedActions = getPermittedActions;
|
|
4
|
-
/**
|
|
5
|
-
* Gets available actions for a leave based on current status and user permissions
|
|
6
|
-
* @param entityFlowConfig - The flow configuration for the entity
|
|
7
|
-
* @param currentStatus - The current status of the leave
|
|
8
|
-
* @param userPermissions - Array of permissions the user has
|
|
9
|
-
* @param combineActions - Array of action values to combine into a single action
|
|
10
|
-
* @param data - Optional function to provide additional visibility conditions based on the entity data
|
|
11
|
-
* @returns Array of available actions with labels and values
|
|
12
|
-
* @throws Error if user has multiple permissions for a single action
|
|
13
|
-
*/
|
|
14
|
-
function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], actionLabels = {}, data = (_) => ({})) {
|
|
15
|
-
var _a;
|
|
16
|
-
// Handle invalid inputs
|
|
17
|
-
if (!currentStatus || !entityFlowConfig[currentStatus]) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const actionConfig = ((_a = entityFlowConfig[currentStatus]) === null || _a === void 0 ? void 0 : _a.actions) || {};
|
|
21
|
-
// Filter actions based on user permissions
|
|
22
|
-
const permittedActions = Object.entries(actionConfig)
|
|
23
|
-
.filter(([actionKey, config]) => {
|
|
24
|
-
var _a;
|
|
25
|
-
const actionRequiredPermissions = (_a = config.permissions) !== null && _a !== void 0 ? _a : [];
|
|
26
|
-
const matchingPermissions = actionRequiredPermissions.filter((permission) => userPermissions.includes(permission));
|
|
27
|
-
// Check for multiple permissions
|
|
28
|
-
if (matchingPermissions.length > 1) {
|
|
29
|
-
throw new Error(`Multiple permissions found for action ${actionKey}: ${matchingPermissions.join(', ')}`);
|
|
30
|
-
}
|
|
31
|
-
return matchingPermissions.length > 0 && (!data || !data({})[matchingPermissions[0]] || data({})[matchingPermissions[0]]());
|
|
32
|
-
})
|
|
33
|
-
.map(([actionKey, _]) => ({
|
|
34
|
-
label: actionLabels[actionKey] || actionKey,
|
|
35
|
-
value: actionKey,
|
|
36
|
-
}));
|
|
37
|
-
// // Combine specified actions if all are present and combineActions is not empty
|
|
38
|
-
if (combineActions.length > 0) {
|
|
39
|
-
const isCombinedActionPresent = combineActions.every((action) => permittedActions.some((a) => a.value === action));
|
|
40
|
-
if (isCombinedActionPresent) {
|
|
41
|
-
return [
|
|
42
|
-
...permittedActions.filter((action) => !combineActions.includes(action.value)),
|
|
43
|
-
{
|
|
44
|
-
label: actionLabels[combineActions.join('_')] || combineActions.join('_'),
|
|
45
|
-
value: combineActions.join('_'),
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return permittedActions;
|
|
51
|
-
}
|
|
File without changes
|