law-common 10.77.0 → 11.0.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/README.md +1 -1
- package/dist/src/api/index.d.ts +2 -0
- package/dist/src/api/index.js +2 -0
- package/dist/src/api/interface/leave_approval.create.dto.interface.d.ts +5 -0
- package/dist/src/api/interface/leave_approval.create.dto.interface.js +2 -0
- package/dist/src/api/interface/leave_approval.update.dto.interface.d.ts +18 -0
- package/dist/src/api/interface/leave_approval.update.dto.interface.js +16 -0
- package/dist/src/entities/enums/configuration-key.enum.d.ts +2 -1
- package/dist/src/entities/enums/configuration-key.enum.js +2 -0
- package/dist/src/entities/enums/cron-jobs-name.enum.d.ts +2 -1
- package/dist/src/entities/enums/cron-jobs-name.enum.js +1 -0
- package/dist/src/entities/enums/leave.action.enum.d.ts +3 -2
- package/dist/src/entities/enums/leave.action.enum.js +6 -2
- package/dist/src/entities/enums/leave_approval_status_enum.d.ts +13 -0
- package/dist/src/entities/enums/leave_approval_status_enum.js +17 -0
- package/dist/src/entities/flow-configs/base-flow-config.enums.d.ts +74 -0
- package/dist/src/entities/flow-configs/base-flow-config.enums.js +79 -0
- package/dist/src/entities/flow-configs/base-flow-config.factory.d.ts +116 -0
- package/dist/src/entities/flow-configs/base-flow-config.factory.js +120 -0
- package/dist/src/entities/flow-configs/leave.flow.config.d.ts +5 -1
- package/dist/src/entities/flow-configs/leave.flow.config.js +41 -26
- package/dist/src/entities/flow-configs/leave_approval_flow.config.d.ts +6 -0
- package/dist/src/entities/flow-configs/leave_approval_flow.config.js +146 -0
- package/dist/src/entities/index.d.ts +4 -0
- package/dist/src/entities/index.js +4 -0
- package/dist/src/entities/interface/entity.utils.interface.d.ts +6 -3
- package/dist/src/entities/interface/entity.utils.interface.js +1 -0
- package/dist/src/entities/interface/leave_approval.entity.interface.d.ts +10 -0
- package/dist/src/entities/interface/leave_approval.entity.interface.js +2 -0
- package/dist/src/entities/model/entity.model.interface.js +2 -0
- package/dist/src/entities/model/entity_history.entity.model.js +1 -1
- package/dist/src/entities/model/leave.entity.model.d.ts +12 -2
- package/dist/src/entities/model/leave.entity.model.js +28 -3
- package/dist/src/entities/model/leave_approval.entity.model.d.ts +42 -0
- package/dist/src/entities/model/leave_approval.entity.model.js +123 -0
- package/dist/src/entities/model/state.entity.model.js +1 -1
- package/dist/src/entities/model/user.entity.model.d.ts +5 -1
- package/dist/src/entities/model/user.entity.model.js +17 -0
- package/dist/src/entities/model/vendor.entity.model.js +1 -1
- package/dist/src/entities/model/vendor_invoice.entity.model.js +1 -1
- package/dist/src/entities/model/work-from-home.entity.model.js +1 -1
- package/dist/src/utils/entity.flow.util.js +5 -0
- package/package.json +42 -41
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# law-common
|
|
1
|
+
# law-common
|
package/dist/src/api/index.d.ts
CHANGED
|
@@ -101,3 +101,5 @@ export * from "./interface/client_quote_rate.update.dto.interface";
|
|
|
101
101
|
export * from "./interface/project-revenue-split.create.dto";
|
|
102
102
|
export * from "./interface/entity_history.create.dto.interface";
|
|
103
103
|
export * from "./interface/entity_history.update.dto.interface";
|
|
104
|
+
export * from "./interface/leave_approval.create.dto.interface";
|
|
105
|
+
export * from "./interface/leave_approval.update.dto.interface";
|
package/dist/src/api/index.js
CHANGED
|
@@ -121,3 +121,5 @@ __exportStar(require("./interface/client_quote_rate.update.dto.interface"), expo
|
|
|
121
121
|
__exportStar(require("./interface/project-revenue-split.create.dto"), exports);
|
|
122
122
|
__exportStar(require("./interface/entity_history.create.dto.interface"), exports);
|
|
123
123
|
__exportStar(require("./interface/entity_history.update.dto.interface"), exports);
|
|
124
|
+
__exportStar(require("./interface/leave_approval.create.dto.interface"), exports);
|
|
125
|
+
__exportStar(require("./interface/leave_approval.update.dto.interface"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IEntityCreateDto } from "../../entities";
|
|
2
|
+
import { ILeaveApprovalEntity } from "../../entities/interface/leave_approval.entity.interface";
|
|
3
|
+
export type ILeaveApprovalCreateExclude = "status";
|
|
4
|
+
export interface ILeaveApprovalCreateDto extends Omit<IEntityCreateDto<ILeaveApprovalEntity>, ILeaveApprovalCreateExclude> {
|
|
5
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DeepPartialButRequired } from "./api.utils.interface";
|
|
2
|
+
import { ILeaveApprovalCreateDto } from "./leave_approval.create.dto.interface";
|
|
3
|
+
export type ILeaveApprovalUpdateDto = DeepPartialButRequired<ILeaveApprovalCreateDto, never> & {
|
|
4
|
+
actionData: ILeaveApprovalActionDataDto;
|
|
5
|
+
};
|
|
6
|
+
export interface ILeaveApprovalActionDataDto {
|
|
7
|
+
action: LeaveApprovalActionEnum;
|
|
8
|
+
remark?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare enum LeaveApprovalActionEnum {
|
|
11
|
+
DELETE = "delete",
|
|
12
|
+
APPROVE = "approve",
|
|
13
|
+
REJECT = "reject",
|
|
14
|
+
RECALL = "recall",
|
|
15
|
+
ESCALATION_APPROVE = "escalationApprove",
|
|
16
|
+
ESCALATION_REJECT = "escalationReject",
|
|
17
|
+
ESCALATE = "escalate"
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveApprovalActionEnum = void 0;
|
|
4
|
+
var LeaveApprovalActionEnum;
|
|
5
|
+
(function (LeaveApprovalActionEnum) {
|
|
6
|
+
// UPDATE = "update",
|
|
7
|
+
LeaveApprovalActionEnum["DELETE"] = "delete";
|
|
8
|
+
// CREATE = "create",
|
|
9
|
+
LeaveApprovalActionEnum["APPROVE"] = "approve";
|
|
10
|
+
LeaveApprovalActionEnum["REJECT"] = "reject";
|
|
11
|
+
LeaveApprovalActionEnum["RECALL"] = "recall";
|
|
12
|
+
// DEACTIVATE = "deactivate",
|
|
13
|
+
LeaveApprovalActionEnum["ESCALATION_APPROVE"] = "escalationApprove";
|
|
14
|
+
LeaveApprovalActionEnum["ESCALATION_REJECT"] = "escalationReject";
|
|
15
|
+
LeaveApprovalActionEnum["ESCALATE"] = "escalate";
|
|
16
|
+
})(LeaveApprovalActionEnum || (exports.LeaveApprovalActionEnum = LeaveApprovalActionEnum = {}));
|
|
@@ -6,7 +6,8 @@ export declare enum ConfigurationKeyEnum {
|
|
|
6
6
|
TIMESHEET_THRESHOLD = "timesheetThreshold",
|
|
7
7
|
TIMESHEET_ENTER_THRESHOLD = "timesheetEnterThreshold",
|
|
8
8
|
ORGANIZATION_BILLING_OVERDUE_THRESHOLD = "organization_billing_overdue_threshold",
|
|
9
|
-
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset"
|
|
9
|
+
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset",
|
|
10
|
+
LEAVE_ESCALATION = "leaveEscalation"
|
|
10
11
|
}
|
|
11
12
|
export declare namespace ConfigurationKeyEnum {
|
|
12
13
|
function getNames(): string[];
|
|
@@ -13,6 +13,7 @@ var ConfigurationKeyEnum;
|
|
|
13
13
|
ConfigurationKeyEnum["TIMESHEET_ENTER_THRESHOLD"] = "timesheetEnterThreshold";
|
|
14
14
|
ConfigurationKeyEnum["ORGANIZATION_BILLING_OVERDUE_THRESHOLD"] = "organization_billing_overdue_threshold";
|
|
15
15
|
ConfigurationKeyEnum["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "projectEntityUsageNotificationSentPercentageReset";
|
|
16
|
+
ConfigurationKeyEnum["LEAVE_ESCALATION"] = "leaveEscalation";
|
|
16
17
|
})(ConfigurationKeyEnum || (exports.ConfigurationKeyEnum = ConfigurationKeyEnum = {}));
|
|
17
18
|
(function (ConfigurationKeyEnum) {
|
|
18
19
|
function getNames() {
|
|
@@ -39,6 +40,7 @@ var ConfigurationKeyEnum;
|
|
|
39
40
|
const cronJobConfigurationKeyMapping = {
|
|
40
41
|
[ConfigurationKeyEnum.PENDING_APPROVAL_TIMESHEET_REMINDER]: cron_jobs_name_enum_1.CronJobNames.PENDING_APPROVAL_TIMESHEET_REMINDER,
|
|
41
42
|
[ConfigurationKeyEnum.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET]: cron_jobs_name_enum_1.CronJobNames.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET,
|
|
43
|
+
[ConfigurationKeyEnum.LEAVE_ESCALATION]: cron_jobs_name_enum_1.CronJobNames.LEAVE_ESCALATION,
|
|
42
44
|
};
|
|
43
45
|
return cronJobConfigurationKeyMapping[configurationKey];
|
|
44
46
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare enum CronJobNames {
|
|
2
2
|
PENDING_APPROVAL_TIMESHEET_REMINDER = "pending_approval_timesheet_reminder",
|
|
3
|
-
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "project_entity_usage_notification_sent_percentage_reset"
|
|
3
|
+
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "project_entity_usage_notification_sent_percentage_reset",
|
|
4
|
+
LEAVE_ESCALATION = "leave_escalation"
|
|
4
5
|
}
|
|
@@ -5,4 +5,5 @@ var CronJobNames;
|
|
|
5
5
|
(function (CronJobNames) {
|
|
6
6
|
CronJobNames["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pending_approval_timesheet_reminder";
|
|
7
7
|
CronJobNames["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "project_entity_usage_notification_sent_percentage_reset";
|
|
8
|
+
CronJobNames["LEAVE_ESCALATION"] = "leave_escalation";
|
|
8
9
|
})(CronJobNames || (exports.CronJobNames = CronJobNames = {}));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare enum LeaveActionEnum {
|
|
2
2
|
READ = "read",
|
|
3
|
-
EDIT = "edit",
|
|
4
3
|
APPROVE = "approve",
|
|
5
4
|
REJECT = "reject",
|
|
6
5
|
DELETE = "delete",
|
|
7
|
-
RECALL = "recall"
|
|
6
|
+
RECALL = "recall",
|
|
7
|
+
LEAVE_APPROVAL_APPROVE = "leaveApprovalApprove",
|
|
8
|
+
LEAVE_APPROVAL_REJECT = "leaveApprovalReject"
|
|
8
9
|
}
|
|
9
10
|
export declare namespace LeaveActionEnum {
|
|
10
11
|
function getLabel(action: LeaveActionEnum): string;
|
|
@@ -6,20 +6,24 @@ const exceptions_1 = require("../../exceptions");
|
|
|
6
6
|
var LeaveActionEnum;
|
|
7
7
|
(function (LeaveActionEnum) {
|
|
8
8
|
LeaveActionEnum["READ"] = "read";
|
|
9
|
-
|
|
9
|
+
// EDIT = "edit",
|
|
10
10
|
LeaveActionEnum["APPROVE"] = "approve";
|
|
11
11
|
LeaveActionEnum["REJECT"] = "reject";
|
|
12
12
|
LeaveActionEnum["DELETE"] = "delete";
|
|
13
13
|
LeaveActionEnum["RECALL"] = "recall";
|
|
14
|
+
LeaveActionEnum["LEAVE_APPROVAL_APPROVE"] = "leaveApprovalApprove";
|
|
15
|
+
LeaveActionEnum["LEAVE_APPROVAL_REJECT"] = "leaveApprovalReject";
|
|
14
16
|
})(LeaveActionEnum || (exports.LeaveActionEnum = LeaveActionEnum = {}));
|
|
15
17
|
(function (LeaveActionEnum) {
|
|
16
18
|
const actionLabelMap = {
|
|
17
19
|
[LeaveActionEnum.READ]: "Read",
|
|
18
|
-
[LeaveActionEnum.EDIT]: "Edit",
|
|
20
|
+
// [LeaveActionEnum.EDIT]: "Edit",
|
|
19
21
|
[LeaveActionEnum.APPROVE]: "Approve",
|
|
20
22
|
[LeaveActionEnum.REJECT]: "Reject",
|
|
21
23
|
[LeaveActionEnum.DELETE]: "Delete",
|
|
22
24
|
[LeaveActionEnum.RECALL]: "Recall",
|
|
25
|
+
[LeaveActionEnum.LEAVE_APPROVAL_APPROVE]: "Approve",
|
|
26
|
+
[LeaveActionEnum.LEAVE_APPROVAL_REJECT]: "Reject",
|
|
23
27
|
};
|
|
24
28
|
function getLabel(action) {
|
|
25
29
|
if (!Object.values(LeaveActionEnum).includes(action)) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum LeaveApprovalStatusEnum {
|
|
2
|
+
DEACTIVATED = "DEACTIVATED",
|
|
3
|
+
CREATED = "CREATED",
|
|
4
|
+
UPDATED = "UPDATED",
|
|
5
|
+
DELETED = "DELETED",
|
|
6
|
+
APPROVED = "APPROVED",
|
|
7
|
+
REJECTED = "REJECTED",
|
|
8
|
+
CREATE_APPROVAL_PENDING = "CREATE_APPROVAL_PENDING",
|
|
9
|
+
UPDATE_APPROVAL_PENDING = "UPDATE_APPROVAL_PENDING",
|
|
10
|
+
DELETE_APPROVAL_PENDING = "DELETE_APPROVAL_PENDING",
|
|
11
|
+
RESOLVED_REJECTED = "RESOLVED_REJECTED",
|
|
12
|
+
ESCALATED = "ESCALATED"
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LeaveApprovalStatusEnum = void 0;
|
|
4
|
+
var LeaveApprovalStatusEnum;
|
|
5
|
+
(function (LeaveApprovalStatusEnum) {
|
|
6
|
+
LeaveApprovalStatusEnum["DEACTIVATED"] = "DEACTIVATED";
|
|
7
|
+
LeaveApprovalStatusEnum["CREATED"] = "CREATED";
|
|
8
|
+
LeaveApprovalStatusEnum["UPDATED"] = "UPDATED";
|
|
9
|
+
LeaveApprovalStatusEnum["DELETED"] = "DELETED";
|
|
10
|
+
LeaveApprovalStatusEnum["APPROVED"] = "APPROVED";
|
|
11
|
+
LeaveApprovalStatusEnum["REJECTED"] = "REJECTED";
|
|
12
|
+
LeaveApprovalStatusEnum["CREATE_APPROVAL_PENDING"] = "CREATE_APPROVAL_PENDING";
|
|
13
|
+
LeaveApprovalStatusEnum["UPDATE_APPROVAL_PENDING"] = "UPDATE_APPROVAL_PENDING";
|
|
14
|
+
LeaveApprovalStatusEnum["DELETE_APPROVAL_PENDING"] = "DELETE_APPROVAL_PENDING";
|
|
15
|
+
LeaveApprovalStatusEnum["RESOLVED_REJECTED"] = "RESOLVED_REJECTED";
|
|
16
|
+
LeaveApprovalStatusEnum["ESCALATED"] = "ESCALATED";
|
|
17
|
+
})(LeaveApprovalStatusEnum || (exports.LeaveApprovalStatusEnum = LeaveApprovalStatusEnum = {}));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base action enum shared across all entity flow configs.
|
|
3
|
+
*
|
|
4
|
+
* Entity-specific action enums should re-use these values for common actions
|
|
5
|
+
* and declare additional values for entity-specific actions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Extending with entity-specific actions
|
|
9
|
+
* export enum VendorActionEnum {
|
|
10
|
+
* // — base actions (re-declare to keep enum self-contained) —
|
|
11
|
+
* VIEW = BaseFlowActionEnum.VIEW,
|
|
12
|
+
* CREATE = BaseFlowActionEnum.CREATE,
|
|
13
|
+
* UPDATE = BaseFlowActionEnum.UPDATE,
|
|
14
|
+
* DELETE = BaseFlowActionEnum.DELETE,
|
|
15
|
+
* APPROVE = BaseFlowActionEnum.APPROVE,
|
|
16
|
+
* REJECT = BaseFlowActionEnum.REJECT,
|
|
17
|
+
* RECALL = BaseFlowActionEnum.RECALL,
|
|
18
|
+
* DEACTIVATE = BaseFlowActionEnum.DEACTIVATE,
|
|
19
|
+
* // — entity-specific additions —
|
|
20
|
+
* SUBMIT = "submit",
|
|
21
|
+
* ESCALATE = "escalate",
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export declare enum BaseFlowActionEnum {
|
|
25
|
+
VIEW = "view",
|
|
26
|
+
CREATE = "create",
|
|
27
|
+
UPDATE = "update",
|
|
28
|
+
DELETE = "delete",
|
|
29
|
+
APPROVE = "approve",
|
|
30
|
+
REJECT = "reject",
|
|
31
|
+
RECALL = "recall",
|
|
32
|
+
DEACTIVATE = "deactivate"
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Base status enum shared across all entity flow configs.
|
|
36
|
+
*
|
|
37
|
+
* Entity-specific status enums should re-use these values for common statuses
|
|
38
|
+
* and declare additional values for entity-specific statuses.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Extending with entity-specific statuses
|
|
42
|
+
* export enum VendorStatusEnum {
|
|
43
|
+
* // — base statuses —
|
|
44
|
+
* ACTIVE = BaseFlowStatusEnum.ACTIVE,
|
|
45
|
+
* INACTIVE = BaseFlowStatusEnum.INACTIVE,
|
|
46
|
+
* DEACTIVATED = BaseFlowStatusEnum.DEACTIVATED,
|
|
47
|
+
* CREATED = BaseFlowStatusEnum.CREATED,
|
|
48
|
+
* UPDATED = BaseFlowStatusEnum.UPDATED,
|
|
49
|
+
* DELETED = BaseFlowStatusEnum.DELETED,
|
|
50
|
+
* APPROVED = BaseFlowStatusEnum.APPROVED,
|
|
51
|
+
* REJECTED = BaseFlowStatusEnum.REJECTED,
|
|
52
|
+
* RESOLVED_REJECTED = BaseFlowStatusEnum.RESOLVED_REJECTED,
|
|
53
|
+
* CREATE_APPROVAL_PENDING = BaseFlowStatusEnum.CREATE_APPROVAL_PENDING,
|
|
54
|
+
* UPDATE_APPROVAL_PENDING = BaseFlowStatusEnum.UPDATE_APPROVAL_PENDING,
|
|
55
|
+
* DELETE_APPROVAL_PENDING = BaseFlowStatusEnum.DELETE_APPROVAL_PENDING,
|
|
56
|
+
* // — entity-specific additions —
|
|
57
|
+
* UNDER_REVIEW = "UNDER_REVIEW",
|
|
58
|
+
* SUBMITTED = "SUBMITTED",
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
export declare enum BaseFlowStatusEnum {
|
|
62
|
+
ACTIVE = "ACTIVE",
|
|
63
|
+
INACTIVE = "INACTIVE",
|
|
64
|
+
DEACTIVATED = "DEACTIVATED",
|
|
65
|
+
CREATED = "CREATED",
|
|
66
|
+
UPDATED = "UPDATED",
|
|
67
|
+
DELETED = "DELETED",
|
|
68
|
+
APPROVED = "APPROVED",
|
|
69
|
+
REJECTED = "REJECTED",
|
|
70
|
+
RESOLVED_REJECTED = "RESOLVED_REJECTED",
|
|
71
|
+
CREATE_APPROVAL_PENDING = "CREATE_APPROVAL_PENDING",
|
|
72
|
+
UPDATE_APPROVAL_PENDING = "UPDATE_APPROVAL_PENDING",
|
|
73
|
+
DELETE_APPROVAL_PENDING = "DELETE_APPROVAL_PENDING"
|
|
74
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseFlowStatusEnum = exports.BaseFlowActionEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base action enum shared across all entity flow configs.
|
|
6
|
+
*
|
|
7
|
+
* Entity-specific action enums should re-use these values for common actions
|
|
8
|
+
* and declare additional values for entity-specific actions.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Extending with entity-specific actions
|
|
12
|
+
* export enum VendorActionEnum {
|
|
13
|
+
* // — base actions (re-declare to keep enum self-contained) —
|
|
14
|
+
* VIEW = BaseFlowActionEnum.VIEW,
|
|
15
|
+
* CREATE = BaseFlowActionEnum.CREATE,
|
|
16
|
+
* UPDATE = BaseFlowActionEnum.UPDATE,
|
|
17
|
+
* DELETE = BaseFlowActionEnum.DELETE,
|
|
18
|
+
* APPROVE = BaseFlowActionEnum.APPROVE,
|
|
19
|
+
* REJECT = BaseFlowActionEnum.REJECT,
|
|
20
|
+
* RECALL = BaseFlowActionEnum.RECALL,
|
|
21
|
+
* DEACTIVATE = BaseFlowActionEnum.DEACTIVATE,
|
|
22
|
+
* // — entity-specific additions —
|
|
23
|
+
* SUBMIT = "submit",
|
|
24
|
+
* ESCALATE = "escalate",
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
var BaseFlowActionEnum;
|
|
28
|
+
(function (BaseFlowActionEnum) {
|
|
29
|
+
BaseFlowActionEnum["VIEW"] = "view";
|
|
30
|
+
BaseFlowActionEnum["CREATE"] = "create";
|
|
31
|
+
BaseFlowActionEnum["UPDATE"] = "update";
|
|
32
|
+
BaseFlowActionEnum["DELETE"] = "delete";
|
|
33
|
+
BaseFlowActionEnum["APPROVE"] = "approve";
|
|
34
|
+
BaseFlowActionEnum["REJECT"] = "reject";
|
|
35
|
+
BaseFlowActionEnum["RECALL"] = "recall";
|
|
36
|
+
BaseFlowActionEnum["DEACTIVATE"] = "deactivate";
|
|
37
|
+
})(BaseFlowActionEnum || (exports.BaseFlowActionEnum = BaseFlowActionEnum = {}));
|
|
38
|
+
/**
|
|
39
|
+
* Base status enum shared across all entity flow configs.
|
|
40
|
+
*
|
|
41
|
+
* Entity-specific status enums should re-use these values for common statuses
|
|
42
|
+
* and declare additional values for entity-specific statuses.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Extending with entity-specific statuses
|
|
46
|
+
* export enum VendorStatusEnum {
|
|
47
|
+
* // — base statuses —
|
|
48
|
+
* ACTIVE = BaseFlowStatusEnum.ACTIVE,
|
|
49
|
+
* INACTIVE = BaseFlowStatusEnum.INACTIVE,
|
|
50
|
+
* DEACTIVATED = BaseFlowStatusEnum.DEACTIVATED,
|
|
51
|
+
* CREATED = BaseFlowStatusEnum.CREATED,
|
|
52
|
+
* UPDATED = BaseFlowStatusEnum.UPDATED,
|
|
53
|
+
* DELETED = BaseFlowStatusEnum.DELETED,
|
|
54
|
+
* APPROVED = BaseFlowStatusEnum.APPROVED,
|
|
55
|
+
* REJECTED = BaseFlowStatusEnum.REJECTED,
|
|
56
|
+
* RESOLVED_REJECTED = BaseFlowStatusEnum.RESOLVED_REJECTED,
|
|
57
|
+
* CREATE_APPROVAL_PENDING = BaseFlowStatusEnum.CREATE_APPROVAL_PENDING,
|
|
58
|
+
* UPDATE_APPROVAL_PENDING = BaseFlowStatusEnum.UPDATE_APPROVAL_PENDING,
|
|
59
|
+
* DELETE_APPROVAL_PENDING = BaseFlowStatusEnum.DELETE_APPROVAL_PENDING,
|
|
60
|
+
* // — entity-specific additions —
|
|
61
|
+
* UNDER_REVIEW = "UNDER_REVIEW",
|
|
62
|
+
* SUBMITTED = "SUBMITTED",
|
|
63
|
+
* }
|
|
64
|
+
*/
|
|
65
|
+
var BaseFlowStatusEnum;
|
|
66
|
+
(function (BaseFlowStatusEnum) {
|
|
67
|
+
BaseFlowStatusEnum["ACTIVE"] = "ACTIVE";
|
|
68
|
+
BaseFlowStatusEnum["INACTIVE"] = "INACTIVE";
|
|
69
|
+
BaseFlowStatusEnum["DEACTIVATED"] = "DEACTIVATED";
|
|
70
|
+
BaseFlowStatusEnum["CREATED"] = "CREATED";
|
|
71
|
+
BaseFlowStatusEnum["UPDATED"] = "UPDATED";
|
|
72
|
+
BaseFlowStatusEnum["DELETED"] = "DELETED";
|
|
73
|
+
BaseFlowStatusEnum["APPROVED"] = "APPROVED";
|
|
74
|
+
BaseFlowStatusEnum["REJECTED"] = "REJECTED";
|
|
75
|
+
BaseFlowStatusEnum["RESOLVED_REJECTED"] = "RESOLVED_REJECTED";
|
|
76
|
+
BaseFlowStatusEnum["CREATE_APPROVAL_PENDING"] = "CREATE_APPROVAL_PENDING";
|
|
77
|
+
BaseFlowStatusEnum["UPDATE_APPROVAL_PENDING"] = "UPDATE_APPROVAL_PENDING";
|
|
78
|
+
BaseFlowStatusEnum["DELETE_APPROVAL_PENDING"] = "DELETE_APPROVAL_PENDING";
|
|
79
|
+
})(BaseFlowStatusEnum || (exports.BaseFlowStatusEnum = BaseFlowStatusEnum = {}));
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic flow-config factory.
|
|
3
|
+
*
|
|
4
|
+
* Provides a reusable, type-safe `createActionConfig` helper for any entity
|
|
5
|
+
* flow configuration. Eliminates boilerplate type plumbing (ActionStatusMap,
|
|
6
|
+
* StateStatusForAction, createTransition) that would otherwise be duplicated
|
|
7
|
+
* in every flow config file.
|
|
8
|
+
*
|
|
9
|
+
* ---
|
|
10
|
+
* **Usage — basic**
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createFlowConfigFactory } from "./base-flow-config.factory";
|
|
13
|
+
*
|
|
14
|
+
* const ACTION_MAP = {
|
|
15
|
+
* [MyActionEnum.APPROVE]: { statuses: [MyStatusEnum.APPROVED] as const, permissions: ["MY_APPROVE"] },
|
|
16
|
+
* [MyActionEnum.REJECT]: { statuses: [MyStatusEnum.REJECTED] as const, permissions: ["MY_REJECT"] },
|
|
17
|
+
* } satisfies ActionMap<MyActionEnum, MyStatusEnum>;
|
|
18
|
+
*
|
|
19
|
+
* const { createActionConfig } = createFlowConfigFactory<IMyContextData>()(ACTION_MAP);
|
|
20
|
+
*
|
|
21
|
+
* const transition = createActionConfig(MyStatusEnum.APPROVED, MyActionEnum.APPROVE);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ---
|
|
25
|
+
* **Usage — overriding a transition permission**
|
|
26
|
+
* ```typescript
|
|
27
|
+
* createActionConfig(MyStatusEnum.APPROVED, MyActionEnum.APPROVE, ["CUSTOM_APPROVE_PERM"]);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ---
|
|
31
|
+
* **Usage — context-driven (multi-outcome) transition**
|
|
32
|
+
* ```typescript
|
|
33
|
+
* createActionConfig(
|
|
34
|
+
* (ctx: IMyContextData) => ctx.fast ? MyStatusEnum.APPROVED : MyStatusEnum.PENDING,
|
|
35
|
+
* MyActionEnum.APPROVE,
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ---
|
|
40
|
+
* **Usage — subset narrowing**
|
|
41
|
+
* Restrict the compiler to a subset of the action's possible target statuses:
|
|
42
|
+
* ```typescript
|
|
43
|
+
* createActionConfig<MyActionEnum.APPROVE, MyStatusEnum.APPROVED>(
|
|
44
|
+
* MyStatusEnum.APPROVED,
|
|
45
|
+
* MyActionEnum.APPROVE,
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ---
|
|
50
|
+
* **Extending base enums**
|
|
51
|
+
* TypeScript enums cannot be inherited, but entity-specific enums can
|
|
52
|
+
* re-declare base values and add new ones:
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { BaseFlowActionEnum, BaseFlowStatusEnum } from "./base-flow-config.enums";
|
|
55
|
+
*
|
|
56
|
+
* export enum VendorActionEnum {
|
|
57
|
+
* VIEW = BaseFlowActionEnum.VIEW,
|
|
58
|
+
* CREATE = BaseFlowActionEnum.CREATE,
|
|
59
|
+
* UPDATE = BaseFlowActionEnum.UPDATE,
|
|
60
|
+
* DELETE = BaseFlowActionEnum.DELETE,
|
|
61
|
+
* APPROVE = BaseFlowActionEnum.APPROVE,
|
|
62
|
+
* REJECT = BaseFlowActionEnum.REJECT,
|
|
63
|
+
* RECALL = BaseFlowActionEnum.RECALL,
|
|
64
|
+
* DEACTIVATE = BaseFlowActionEnum.DEACTIVATE,
|
|
65
|
+
* SUBMIT = "submit", // ← extension
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* export enum VendorStatusEnum {
|
|
69
|
+
* ACTIVE = BaseFlowStatusEnum.ACTIVE,
|
|
70
|
+
* // ... all base statuses ...
|
|
71
|
+
* SUBMITTED = "SUBMITTED", // ← extension
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* Shape of a single entry in the action map.
|
|
77
|
+
* `statuses` must be a `const` tuple so TypeScript preserves the exact union
|
|
78
|
+
* of reachable statuses for subset-narrowing in `createActionConfig`.
|
|
79
|
+
*/
|
|
80
|
+
export type ActionMapEntry<S extends string> = {
|
|
81
|
+
readonly reachableStatues: readonly S[];
|
|
82
|
+
readonly permissions: string[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Full action map: one entry per action value.
|
|
86
|
+
* Use `satisfies ActionMap<MyActionEnum, MyStatusEnum>` on your map literal
|
|
87
|
+
* so that the compiler catches missing/misspelled keys while still preserving
|
|
88
|
+
* the precise `as const` tuple types for subset-narrowing.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* const ACTION_MAP = {
|
|
92
|
+
* [MyActionEnum.APPROVE]: { statuses: [MyStatusEnum.APPROVED] as const, permissions: ["MY_APPROVE"] },
|
|
93
|
+
* } satisfies ActionMap<MyActionEnum, MyStatusEnum>;
|
|
94
|
+
*/
|
|
95
|
+
export type ActionMap<A extends string, S extends string> = {
|
|
96
|
+
readonly [key in A]: ActionMapEntry<S>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Curried factory — call with the context-data type first, then pass the
|
|
100
|
+
* action map. This two-step pattern lets TypeScript infer the precise action
|
|
101
|
+
* map type (preserving `as const` tuple narrowing) while still allowing the
|
|
102
|
+
* caller to set the context-data type explicitly.
|
|
103
|
+
*
|
|
104
|
+
* @template CTX - Shape of the context object passed to function-based
|
|
105
|
+
* transition resolvers. Use `never` for flows where `next()`
|
|
106
|
+
* needs no runtime data (equivalent to `() => status`).
|
|
107
|
+
*
|
|
108
|
+
* @returns A function that accepts an `ActionMap` and returns `createActionConfig`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function createFlowConfigFactory<CTX = never>(): <A extends string, S extends string, AM extends ActionMap<A, S>>(actionMap: AM) => {
|
|
111
|
+
createActionConfig: <Act extends A, Subset extends { [key in A]: AM[key]["reachableStatues"]; }[Act][number] = { [key in A]: AM[key]["reachableStatues"]; }[Act][number]>(action: Act, nextStatus: Subset | ((context: CTX) => Subset), overridePermissions?: string[]) => {
|
|
112
|
+
permissions: string[];
|
|
113
|
+
next: (context: CTX) => Subset;
|
|
114
|
+
};
|
|
115
|
+
createTransition: <Act extends A, Subset_1 extends { [key in A]: AM[key]["reachableStatues"]; }[Act][number] = { [key in A]: AM[key]["reachableStatues"]; }[Act][number]>(transition: Subset_1 | ((context: CTX) => Subset_1)) => (context: CTX) => Subset_1;
|
|
116
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generic flow-config factory.
|
|
4
|
+
*
|
|
5
|
+
* Provides a reusable, type-safe `createActionConfig` helper for any entity
|
|
6
|
+
* flow configuration. Eliminates boilerplate type plumbing (ActionStatusMap,
|
|
7
|
+
* StateStatusForAction, createTransition) that would otherwise be duplicated
|
|
8
|
+
* in every flow config file.
|
|
9
|
+
*
|
|
10
|
+
* ---
|
|
11
|
+
* **Usage — basic**
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createFlowConfigFactory } from "./base-flow-config.factory";
|
|
14
|
+
*
|
|
15
|
+
* const ACTION_MAP = {
|
|
16
|
+
* [MyActionEnum.APPROVE]: { statuses: [MyStatusEnum.APPROVED] as const, permissions: ["MY_APPROVE"] },
|
|
17
|
+
* [MyActionEnum.REJECT]: { statuses: [MyStatusEnum.REJECTED] as const, permissions: ["MY_REJECT"] },
|
|
18
|
+
* } satisfies ActionMap<MyActionEnum, MyStatusEnum>;
|
|
19
|
+
*
|
|
20
|
+
* const { createActionConfig } = createFlowConfigFactory<IMyContextData>()(ACTION_MAP);
|
|
21
|
+
*
|
|
22
|
+
* const transition = createActionConfig(MyStatusEnum.APPROVED, MyActionEnum.APPROVE);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ---
|
|
26
|
+
* **Usage — overriding a transition permission**
|
|
27
|
+
* ```typescript
|
|
28
|
+
* createActionConfig(MyStatusEnum.APPROVED, MyActionEnum.APPROVE, ["CUSTOM_APPROVE_PERM"]);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ---
|
|
32
|
+
* **Usage — context-driven (multi-outcome) transition**
|
|
33
|
+
* ```typescript
|
|
34
|
+
* createActionConfig(
|
|
35
|
+
* (ctx: IMyContextData) => ctx.fast ? MyStatusEnum.APPROVED : MyStatusEnum.PENDING,
|
|
36
|
+
* MyActionEnum.APPROVE,
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* ---
|
|
41
|
+
* **Usage — subset narrowing**
|
|
42
|
+
* Restrict the compiler to a subset of the action's possible target statuses:
|
|
43
|
+
* ```typescript
|
|
44
|
+
* createActionConfig<MyActionEnum.APPROVE, MyStatusEnum.APPROVED>(
|
|
45
|
+
* MyStatusEnum.APPROVED,
|
|
46
|
+
* MyActionEnum.APPROVE,
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* ---
|
|
51
|
+
* **Extending base enums**
|
|
52
|
+
* TypeScript enums cannot be inherited, but entity-specific enums can
|
|
53
|
+
* re-declare base values and add new ones:
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { BaseFlowActionEnum, BaseFlowStatusEnum } from "./base-flow-config.enums";
|
|
56
|
+
*
|
|
57
|
+
* export enum VendorActionEnum {
|
|
58
|
+
* VIEW = BaseFlowActionEnum.VIEW,
|
|
59
|
+
* CREATE = BaseFlowActionEnum.CREATE,
|
|
60
|
+
* UPDATE = BaseFlowActionEnum.UPDATE,
|
|
61
|
+
* DELETE = BaseFlowActionEnum.DELETE,
|
|
62
|
+
* APPROVE = BaseFlowActionEnum.APPROVE,
|
|
63
|
+
* REJECT = BaseFlowActionEnum.REJECT,
|
|
64
|
+
* RECALL = BaseFlowActionEnum.RECALL,
|
|
65
|
+
* DEACTIVATE = BaseFlowActionEnum.DEACTIVATE,
|
|
66
|
+
* SUBMIT = "submit", // ← extension
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* export enum VendorStatusEnum {
|
|
70
|
+
* ACTIVE = BaseFlowStatusEnum.ACTIVE,
|
|
71
|
+
* // ... all base statuses ...
|
|
72
|
+
* SUBMITTED = "SUBMITTED", // ← extension
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
exports.createFlowConfigFactory = createFlowConfigFactory;
|
|
78
|
+
/**
|
|
79
|
+
* Curried factory — call with the context-data type first, then pass the
|
|
80
|
+
* action map. This two-step pattern lets TypeScript infer the precise action
|
|
81
|
+
* map type (preserving `as const` tuple narrowing) while still allowing the
|
|
82
|
+
* caller to set the context-data type explicitly.
|
|
83
|
+
*
|
|
84
|
+
* @template CTX - Shape of the context object passed to function-based
|
|
85
|
+
* transition resolvers. Use `never` for flows where `next()`
|
|
86
|
+
* needs no runtime data (equivalent to `() => status`).
|
|
87
|
+
*
|
|
88
|
+
* @returns A function that accepts an `ActionMap` and returns `createActionConfig`.
|
|
89
|
+
*/
|
|
90
|
+
function createFlowConfigFactory() {
|
|
91
|
+
return function (actionMap) {
|
|
92
|
+
const createTransition = (transition) => (context) => {
|
|
93
|
+
if (typeof transition === "function") {
|
|
94
|
+
return transition(context);
|
|
95
|
+
}
|
|
96
|
+
return transition;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Builds a single typed action-config entry for use inside a
|
|
100
|
+
* `FlowConfig` status block.
|
|
101
|
+
*
|
|
102
|
+
* @param action The action this config is for (used to look up
|
|
103
|
+
* default permissions from `actionMap`).
|
|
104
|
+
* @param nextStatus Fixed target status, or a function `(ctx) => status`
|
|
105
|
+
* for context-driven transitions.
|
|
106
|
+
* @param overridePermissions Optional permission list that replaces the
|
|
107
|
+
* default from `actionMap[action].permissions`.
|
|
108
|
+
*
|
|
109
|
+
* @typeParam Act Specific action enum member (narrows `StatusForAction`).
|
|
110
|
+
* @typeParam Subset Subset of reachable statuses to enforce at this
|
|
111
|
+
* (currentStatus, action) pair. Must be a subtype of
|
|
112
|
+
* `StatusForAction<Act>`.
|
|
113
|
+
*/
|
|
114
|
+
const createActionConfig = (action, nextStatus, overridePermissions) => ({
|
|
115
|
+
permissions: overridePermissions !== null && overridePermissions !== void 0 ? overridePermissions : actionMap[action].permissions,
|
|
116
|
+
next: createTransition(nextStatus),
|
|
117
|
+
});
|
|
118
|
+
return { createActionConfig, createTransition };
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { LeaveActionEnum } from "../enums/leave.action.enum";
|
|
2
2
|
import { LeaveStatusEnum } from "../enums/leave.status.enum";
|
|
3
|
+
import { LeaveEntityModel } from "../model/leave.entity.model";
|
|
3
4
|
import { FlowConfig } from "./flow-config.type";
|
|
4
|
-
export
|
|
5
|
+
export interface ILeaveFlowConfigContextData {
|
|
6
|
+
leaveEntity?: LeaveEntityModel;
|
|
7
|
+
}
|
|
8
|
+
export declare const leaveFlowConfig: FlowConfig<LeaveStatusEnum, LeaveActionEnum, ILeaveFlowConfigContextData>;
|