law-common 10.18.2-beta.6 → 10.19.1-beta.0
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/interface/billing.create.dto.interface.d.ts +2 -2
- package/dist/src/api/interface/billing.update.dto.interface.d.ts +5 -3
- package/dist/src/constants/entity_constants.d.ts +1 -0
- package/dist/src/constants/entity_constants.js +5 -1
- package/dist/src/entities/index.d.ts +2 -1
- package/dist/src/entities/index.js +2 -1
- package/dist/src/entities/interface/billing_timesheet.entity.interface.d.ts +2 -2
- package/dist/src/entities/interface/entity.utils.interface.d.ts +9 -6
- package/dist/src/entities/model/bank.entity.model.d.ts +4 -1
- package/dist/src/entities/model/bank.entity.model.js +8 -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/billing-timesheet.entity.model.d.ts +26 -0
- package/dist/src/entities/model/billing-timesheet.entity.model.js +36 -0
- package/dist/src/entities/model/billing.entity.model.d.ts +7 -1
- package/dist/src/entities/model/billing.entity.model.js +18 -0
- package/dist/src/entities/model/client-affiliate.entity.model.d.ts +19 -0
- package/dist/src/entities/model/client-affiliate.entity.model.js +30 -0
- package/dist/src/entities/model/designation.entity.model.d.ts +4 -1
- package/dist/src/entities/model/designation.entity.model.js +8 -2
- package/dist/src/entities/model/entity.model.interface.d.ts +2 -2
- package/dist/src/entities/model/entity.model.interface.js +12 -7
- 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 +4 -1
- package/dist/src/entities/model/task.entity.model.js +8 -2
- package/dist/src/entities/model/timesheet.entity.model.d.ts +4 -1
- package/dist/src/entities/model/timesheet.entity.model.js +8 -2
- package/dist/src/entities/model/user.entity.model.d.ts +4 -1
- package/dist/src/entities/model/user.entity.model.js +8 -2
- package/dist/src/utils/helper.fn.util.d.ts +28 -0
- package/dist/src/utils/helper.fn.util.js +47 -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 +33 -33
- 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 -30
- package/dist/src/utils/entity.flow.util.js +0 -54
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2
|
+
"name": "law-common",
|
|
3
|
+
"version": "10.19.1-beta.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
|
|
13
|
+
"publish:patch": "npm version patch && git push && npm run build && npm publish",
|
|
14
|
+
"publish:minor": "npm version minor && git push && npm run build && npm publish",
|
|
15
|
+
"publish:major": "npm version major && git push && npm run build && npm publish",
|
|
16
|
+
"link": "npm run build && npm link",
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.13",
|
|
24
|
+
"@types/node": "^22.6.1",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"ts-jest": "^29.2.5",
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
28
|
+
"typescript": "^5.6.2"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@types/express": "^5.0.0",
|
|
32
|
+
"@types/multer": "^1.4.12",
|
|
33
|
+
"date-fns": "^4.1.0"
|
|
34
|
+
}
|
|
35
35
|
}
|
|
@@ -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,30 +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'][], data?: (a: E) => {
|
|
26
|
-
[key: string]: () => boolean;
|
|
27
|
-
}): {
|
|
28
|
-
label: string;
|
|
29
|
-
value: T['action'] | string;
|
|
30
|
-
}[];
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPermittedActions = getPermittedActions;
|
|
4
|
-
const entities_1 = require("../entities");
|
|
5
|
-
/**
|
|
6
|
-
* Gets available actions for a leave based on current status and user permissions
|
|
7
|
-
* @param entityFlowConfig - The flow configuration for the entity
|
|
8
|
-
* @param currentStatus - The current status of the leave
|
|
9
|
-
* @param userPermissions - Array of permissions the user has
|
|
10
|
-
* @param combineActions - Array of action values to combine into a single action
|
|
11
|
-
* @param data - Optional function to provide additional visibility conditions based on the entity data
|
|
12
|
-
* @returns Array of available actions with labels and values
|
|
13
|
-
* @throws Error if user has multiple permissions for a single action
|
|
14
|
-
*/
|
|
15
|
-
function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], data = (_) => ({})) {
|
|
16
|
-
var _a;
|
|
17
|
-
// Handle invalid inputs
|
|
18
|
-
if (!currentStatus || !entityFlowConfig[currentStatus]) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const actionConfig = ((_a = entityFlowConfig[currentStatus]) === null || _a === void 0 ? void 0 : _a.actions) || {};
|
|
22
|
-
// Filter actions based on user permissions
|
|
23
|
-
const permittedActions = Object.entries(actionConfig)
|
|
24
|
-
.filter(([actionKey, config]) => {
|
|
25
|
-
var _a;
|
|
26
|
-
const actionRequiredPermissions = (_a = config.permissions) !== null && _a !== void 0 ? _a : [];
|
|
27
|
-
const matchingPermissions = actionRequiredPermissions.filter((permission) => userPermissions.includes(permission));
|
|
28
|
-
// Check for multiple permissions
|
|
29
|
-
if (matchingPermissions.length > 1) {
|
|
30
|
-
throw new Error(`Multiple permissions found for action ${actionKey}: ${matchingPermissions.join(', ')}`);
|
|
31
|
-
}
|
|
32
|
-
return matchingPermissions.length > 0 && (!data || !data({})[matchingPermissions[0]] || data({})[matchingPermissions[0]]());
|
|
33
|
-
})
|
|
34
|
-
.map(([actionKey, _]) => ({
|
|
35
|
-
label: entities_1.LeaveActionEnum.getLabel(actionKey) || '',
|
|
36
|
-
value: actionKey,
|
|
37
|
-
}));
|
|
38
|
-
// // Combine specified actions if all are present and combineActions is not empty
|
|
39
|
-
if (combineActions.length > 0) {
|
|
40
|
-
const isCombinedActionPresent = combineActions.every((action) => permittedActions.some((a) => a.value === action));
|
|
41
|
-
if (isCombinedActionPresent) {
|
|
42
|
-
return [
|
|
43
|
-
...permittedActions.filter((action) => !combineActions.includes(action.value)),
|
|
44
|
-
{
|
|
45
|
-
label: combineActions
|
|
46
|
-
.map((a) => entities_1.LeaveActionEnum.getLabel(a) || '')
|
|
47
|
-
.join('/'),
|
|
48
|
-
value: combineActions.join('_'),
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return permittedActions;
|
|
54
|
-
}
|