law-common 10.46.3 → 10.47.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.
Files changed (48) hide show
  1. package/dist/src/api/index.d.ts +0 -2
  2. package/dist/src/api/index.js +0 -2
  3. package/dist/src/entities/flow-configs/leave.flow.config.d.ts +2 -0
  4. package/dist/src/entities/flow-configs/leave.flow.config.js +127 -0
  5. package/dist/src/entities/index.d.ts +1 -5
  6. package/dist/src/entities/index.js +1 -5
  7. package/dist/src/entities/interface/entity-audit-columns.interface.d.ts +0 -2
  8. package/dist/src/entities/interface/entity.utils.interface.d.ts +4 -12
  9. package/dist/src/entities/interface/entity.utils.interface.js +0 -2
  10. package/dist/src/entities/model/entity.model.interface.d.ts +0 -3
  11. package/dist/src/entities/model/entity.model.interface.js +0 -44
  12. package/dist/src/entities/model/leave.entity.model.d.ts +17 -0
  13. package/dist/src/entities/model/leave.entity.model.js +82 -0
  14. package/dist/src/enums/error.key.enum.d.ts +6 -1
  15. package/dist/src/enums/error.key.enum.js +5 -0
  16. package/dist/src/utils/entity.flow.util.d.ts +37 -1
  17. package/dist/src/utils/entity.flow.util.js +57 -3
  18. package/dist/src/utils/string.util.d.ts +12 -0
  19. package/dist/src/utils/string.util.js +26 -3
  20. package/package.json +37 -37
  21. package/dist/src/api/interface/tds_rate.create.dto.interface.autocode.d.ts +0 -0
  22. package/dist/src/api/interface/tds_rate.create.dto.interface.autocode.js +0 -6
  23. package/dist/src/api/interface/tds_rate.create.dto.interface.d.ts +0 -6
  24. package/dist/src/api/interface/tds_rate.create.dto.interface.js +0 -2
  25. package/dist/src/api/interface/tds_rate.update.dto.interface.autocode.d.ts +0 -0
  26. package/dist/src/api/interface/tds_rate.update.dto.interface.autocode.js +0 -3
  27. package/dist/src/api/interface/tds_rate.update.dto.interface.d.ts +0 -3
  28. package/dist/src/api/interface/tds_rate.update.dto.interface.js +0 -2
  29. package/dist/src/entities/enums/tds_rate_status_enum.autocode.d.ts +0 -0
  30. package/dist/src/entities/enums/tds_rate_status_enum.autocode.js +0 -6
  31. package/dist/src/entities/enums/tds_rate_status_enum.d.ts +0 -5
  32. package/dist/src/entities/enums/tds_rate_status_enum.js +0 -9
  33. package/dist/src/entities/interface/organization_type_tds_rate_mapping.entity.interface.autocode.d.ts +0 -0
  34. package/dist/src/entities/interface/organization_type_tds_rate_mapping.entity.interface.autocode.js +0 -7
  35. package/dist/src/entities/interface/organization_type_tds_rate_mapping.entity.interface.d.ts +0 -6
  36. package/dist/src/entities/interface/organization_type_tds_rate_mapping.entity.interface.js +0 -2
  37. package/dist/src/entities/interface/tds_rate.entity.interface.autocode.d.ts +0 -0
  38. package/dist/src/entities/interface/tds_rate.entity.interface.autocode.js +0 -12
  39. package/dist/src/entities/interface/tds_rate.entity.interface.d.ts +0 -12
  40. package/dist/src/entities/interface/tds_rate.entity.interface.js +0 -2
  41. package/dist/src/entities/model/organization_type_tds_rate_mapping.entity.model.autocode.d.ts +0 -0
  42. package/dist/src/entities/model/organization_type_tds_rate_mapping.entity.model.autocode.js +0 -24
  43. package/dist/src/entities/model/organization_type_tds_rate_mapping.entity.model.d.ts +0 -20
  44. package/dist/src/entities/model/organization_type_tds_rate_mapping.entity.model.js +0 -47
  45. package/dist/src/entities/model/tds_rate.entity.model.autocode.d.ts +0 -0
  46. package/dist/src/entities/model/tds_rate.entity.model.autocode.js +0 -37
  47. package/dist/src/entities/model/tds_rate.entity.model.d.ts +0 -25
  48. package/dist/src/entities/model/tds_rate.entity.model.js +0 -47
@@ -58,5 +58,3 @@ export * from "./interface/gst_rate.create.dto.interface";
58
58
  export * from "./interface/gst_rate.update.dto.interface";
59
59
  export * from "./interface/organization_type.create.dto.interface";
60
60
  export * from "./interface/organization_type.update.dto.interface";
61
- export * from "./interface/tds_rate.create.dto.interface";
62
- export * from "./interface/tds_rate.update.dto.interface";
@@ -78,5 +78,3 @@ __exportStar(require("./interface/gst_rate.create.dto.interface"), exports);
78
78
  __exportStar(require("./interface/gst_rate.update.dto.interface"), exports);
79
79
  __exportStar(require("./interface/organization_type.create.dto.interface"), exports);
80
80
  __exportStar(require("./interface/organization_type.update.dto.interface"), exports);
81
- __exportStar(require("./interface/tds_rate.create.dto.interface"), exports);
82
- __exportStar(require("./interface/tds_rate.update.dto.interface"), exports);
@@ -0,0 +1,2 @@
1
+ import { ILeaveFlowConfig } from "../../api";
2
+ export declare const leaveFlowConfig: ILeaveFlowConfig;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.leaveFlowConfig = void 0;
4
+ const leave_action_enum_1 = require("../enums/leave.action.enum");
5
+ const leave_status_enum_1 = require("../enums/leave.status.enum");
6
+ exports.leaveFlowConfig = {
7
+ [leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: {
8
+ actions: {
9
+ // [LeaveActionEnum.READ]: {
10
+ // permissions: ["LEAVE_READ_ORG"],
11
+ // next: () => LeaveStatusEnum.PENDING_APPROVAL,
12
+ // },
13
+ [leave_action_enum_1.LeaveActionEnum.EDIT]: {
14
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
15
+ next: () => leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
16
+ },
17
+ [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
18
+ permissions: ["LEAVE_APPROVER_ORG"],
19
+ next: () => leave_status_enum_1.LeaveStatusEnum.APPROVED,
20
+ },
21
+ [leave_action_enum_1.LeaveActionEnum.REJECT]: {
22
+ permissions: ["LEAVE_APPROVER_ORG"],
23
+ next: () => leave_status_enum_1.LeaveStatusEnum.REJECTED,
24
+ },
25
+ [leave_action_enum_1.LeaveActionEnum.DELETE]: {
26
+ permissions: ["LEAVE_DELETE_SELF"],
27
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETED,
28
+ },
29
+ },
30
+ },
31
+ [leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: {
32
+ actions: {
33
+ // [LeaveActionEnum.READ]: {
34
+ // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
35
+ // next: () => LeaveStatusEnum.EDIT_APPROVAL,
36
+ // },
37
+ [leave_action_enum_1.LeaveActionEnum.EDIT]: {
38
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
39
+ next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
40
+ },
41
+ [leave_action_enum_1.LeaveActionEnum.RECALL]: {
42
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
43
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL, // Rolls back to previous state
44
+ },
45
+ [leave_action_enum_1.LeaveActionEnum.REJECT]: {
46
+ permissions: ["LEAVE_APPROVER_ORG"],
47
+ next: () => leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED,
48
+ },
49
+ [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
50
+ permissions: ["LEAVE_APPROVER_ORG"],
51
+ next: () => leave_status_enum_1.LeaveStatusEnum.APPROVED,
52
+ },
53
+ },
54
+ },
55
+ [leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: {
56
+ actions: {
57
+ // [LeaveActionEnum.READ]: {
58
+ // permissions: ["LEAVE_CREATOR"],
59
+ // next: () => LeaveStatusEnum.DELETE_APPROVAL,
60
+ // },
61
+ [leave_action_enum_1.LeaveActionEnum.EDIT]: {
62
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
63
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
64
+ },
65
+ [leave_action_enum_1.LeaveActionEnum.RECALL]: {
66
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
67
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETED, // Rolls back to previous state
68
+ },
69
+ [leave_action_enum_1.LeaveActionEnum.REJECT]: {
70
+ permissions: ["LEAVE_APPROVER_ORG"],
71
+ next: () => leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED,
72
+ },
73
+ [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
74
+ permissions: ["LEAVE_APPROVER_ORG"],
75
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETED,
76
+ },
77
+ },
78
+ },
79
+ [leave_status_enum_1.LeaveStatusEnum.APPROVED]: {
80
+ actions: {
81
+ // [LeaveActionEnum.READ]: {
82
+ // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
83
+ // next: () => LeaveStatusEnum.APPROVED,
84
+ // },
85
+ [leave_action_enum_1.LeaveActionEnum.EDIT]: {
86
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
87
+ next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
88
+ },
89
+ [leave_action_enum_1.LeaveActionEnum.DELETE]: {
90
+ permissions: ["LEAVE_DELETE_SELF"],
91
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
92
+ },
93
+ },
94
+ },
95
+ // [LeaveStatusEnum.DELETED]: {
96
+ // actions: {
97
+ // [LeaveActionEnum.READ]: {
98
+ // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
99
+ // next: () => LeaveStatusEnum.DELETED,
100
+ // },
101
+ // },
102
+ // },
103
+ [leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED]: {
104
+ actions: {
105
+ // [LeaveActionEnum.READ]: {
106
+ // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
107
+ // next: () => LeaveStatusEnum.RESOLVE_REJECTED,
108
+ // },
109
+ [leave_action_enum_1.LeaveActionEnum.EDIT]: {
110
+ permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
111
+ next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
112
+ },
113
+ [leave_action_enum_1.LeaveActionEnum.DELETE]: {
114
+ permissions: ["LEAVE_DELETE_SELF"],
115
+ next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
116
+ },
117
+ },
118
+ },
119
+ // [LeaveStatusEnum.REJECTED]: {
120
+ // actions: {
121
+ // [LeaveActionEnum.READ]: {
122
+ // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
123
+ // next: () => LeaveStatusEnum.REJECTED,
124
+ // },
125
+ // },
126
+ // },
127
+ };
@@ -113,9 +113,5 @@ export * from "./model/gst_rate.entity.model";
113
113
  export * from "./enums/organization_type_status_enum";
114
114
  export * from "./interface/organization_type.entity.interface";
115
115
  export * from "./model/organization_type.entity.model";
116
- export * from "./interface/organization_type_tds_rate_mapping.entity.interface";
117
- export * from "./model/organization_type_tds_rate_mapping.entity.model";
118
- export * from "./enums/tds_rate_status_enum";
119
- export * from "./interface/tds_rate.entity.interface";
120
- export * from "./model/tds_rate.entity.model";
121
116
  export * from "./model/interface/billing.model.interface";
117
+ export * from "./flow-configs/leave.flow.config";
@@ -129,9 +129,5 @@ __exportStar(require("./model/gst_rate.entity.model"), exports);
129
129
  __exportStar(require("./enums/organization_type_status_enum"), exports);
130
130
  __exportStar(require("./interface/organization_type.entity.interface"), exports);
131
131
  __exportStar(require("./model/organization_type.entity.model"), exports);
132
- __exportStar(require("./interface/organization_type_tds_rate_mapping.entity.interface"), exports);
133
- __exportStar(require("./model/organization_type_tds_rate_mapping.entity.model"), exports);
134
- __exportStar(require("./enums/tds_rate_status_enum"), exports);
135
- __exportStar(require("./interface/tds_rate.entity.interface"), exports);
136
- __exportStar(require("./model/tds_rate.entity.model"), exports);
137
132
  __exportStar(require("./model/interface/billing.model.interface"), exports);
133
+ __exportStar(require("./flow-configs/leave.flow.config"), exports);
@@ -1,8 +1,6 @@
1
- import { EntityMap } from "./entity.utils.interface";
2
1
  export interface IEntityAuditColumn {
3
2
  createdOn: number;
4
3
  updatedOn: number;
5
4
  createdBy: number;
6
5
  updatedBy: number;
7
- entityMap?: EntityMap;
8
6
  }
@@ -18,14 +18,12 @@ import { HolidayEntityModel } from "../model/holiday.entity.model";
18
18
  import { LeaveEntityModel } from "../model/leave.entity.model";
19
19
  import { LeaveCountVirtualEntityModel } from "../model/leave_count.entity.model";
20
20
  import { OrganizationTypeEntityModel } from "../model/organization_type.entity.model";
21
- import { OrganizationTypeTdsRateMappingEntityModel } from "../model/organization_type_tds_rate_mapping.entity.model";
22
21
  import { ProjectUserMappingEntityModel } from "../model/project-user-mapping.entity.model";
23
22
  import { ProjectEntityModel } from "../model/project.entity.model";
24
23
  import { ReimbursementExpenseEntityModel } from "../model/reimbursement-expense.entity.model";
25
24
  import { ReimbursementEntityModel } from "../model/reimbursement.entity.model";
26
25
  import { StateEntityModel } from "../model/state.entity.model";
27
26
  import { TaskEntityModel } from "../model/task.entity.model";
28
- import { TdsRateEntityModel } from "../model/tds_rate.entity.model";
29
27
  import { TimesheetEntityModel } from "../model/timesheet.entity.model";
30
28
  import { UserEntityModel } from "../model/user.entity.model";
31
29
  import { IAddressBookEntity } from "./address-book.entity.interface";
@@ -55,7 +53,6 @@ import { ILeaveHistoryEntity } from "./leave_history.entity.interface";
55
53
  import { IOfficeLocationEntity } from "./office.location.entity";
56
54
  import { IOrganizationEntity } from "./organization.entity.interface";
57
55
  import { IOrganizationTypeEntity } from "./organization_type.entity.interface";
58
- import { IOrganizationTypeTdsRateMappingEntity } from "./organization_type_tds_rate_mapping.entity.interface";
59
56
  import { IPermissionEntity } from "./permission.entity.interface";
60
57
  import { IProjectEntity, IProjectUserMappingEntity } from "./project.entity.interface";
61
58
  import { IRateEntity } from "./rate.entity.interface";
@@ -65,7 +62,6 @@ import { IRoleEntity } from "./role.entity.interface";
65
62
  import { IRolePermissionMappingEntity } from "./role.permission.mapping.entity.interface";
66
63
  import { IStateEntity } from "./state.entity.interface";
67
64
  import { ITaskEntity } from "./task.entity.interface";
68
- import { ITdsRateEntity } from "./tds_rate.entity.interface";
69
65
  import { ITimesheetEntity } from "./timesheet.entity.interface";
70
66
  import { ITimesheetHistoryEntity } from "./timesheet_history.entity.interface";
71
67
  import { IToDoListEntity } from "./to-do.entity.interface";
@@ -76,9 +72,7 @@ export type IApiEntity<T> = Modify<T, {
76
72
  createdOn: string;
77
73
  updatedOn: string;
78
74
  }>;
79
- export type IEntityCreateDto<T> = Omit<T, "id" | keyof IEntityAuditColumn> & {
80
- fetch?: EntityEnum[];
81
- };
75
+ export type IEntityCreateDto<T> = Omit<T, "id" | keyof IEntityAuditColumn>;
82
76
  export type IEntityUpdateDto<T> = Omit<Partial<T>, "id" | keyof IEntityAuditColumn>;
83
77
  /**
84
78
  * EntityEnum
@@ -158,9 +152,7 @@ export declare enum EntityEnum {
158
152
  ADDRESS_BOOK = "address_book",
159
153
  STATE = "state",
160
154
  GST_RATE = "gst_rate",
161
- ORGANIZATION_TYPE = "organization_type",
162
- TDS_RATE = "tds_rate",
163
- ORGANIZATION_TYPE_TDS_RATE_MAPPING = "organization_type_tds_rate_mapping"
155
+ ORGANIZATION_TYPE = "organization_type"
164
156
  }
165
157
  export type EntityRelations = {
166
158
  [K in EntityEnum | VirtualEntityEnum]: K;
@@ -179,7 +171,7 @@ export type IBaseEntityApiResponse<T> = {
179
171
  [K in EntityEnum | VirtualEntityEnum]?: IBaseEntityApiResponse<EnumEntityType<K>>;
180
172
  };
181
173
  };
182
- export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? IBillingTransactionHistoryEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? IClientIntroducingMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : T extends EntityEnum.ADDRESS_BOOK ? IAddressBookEntity : T extends EntityEnum.STATE ? IStateEntity : T extends EntityEnum.GST_RATE ? IGstRateEntity : T extends EntityEnum.ORGANIZATION_TYPE ? IOrganizationTypeEntity : T extends EntityEnum.TDS_RATE ? ITdsRateEntity : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? IOrganizationTypeTdsRateMappingEntity : never) & {
174
+ export type EnumEntityType<T extends EntityEnum | VirtualEntityEnum> = (T extends EntityEnum.BILLING ? IBillingEntity : T extends EntityEnum.BILLING_TIMESHEET ? IBillingTimesheetEntity : T extends EntityEnum.BILLING_REIMBURSEMENT_EXPENSE ? IBillingReimbursementExpenseEntity : T extends EntityEnum.TIMESHEET ? ITimesheetEntity : T extends EntityEnum.USER ? IUserEntity : T extends EntityEnum.PROJECT ? IProjectEntity : T extends EntityEnum.CLIENT ? IClientEntity : T extends EntityEnum.LEAVE ? ILeaveEntity : T extends EntityEnum.BANK ? IBankEntity : T extends EntityEnum.BILLING_PAYMENT ? IBillingPaymentEntity : T extends EntityEnum.BILLING_TRANSACTION ? IBillingTransactionEntity : T extends EntityEnum.BILLING_TRANSACTION_HISTORY ? IBillingTransactionHistoryEntity : T extends EntityEnum.CLIENT_AFFILIATE ? IClientAffiliateEntity : T extends EntityEnum.CONFIGURATION ? IConfigurationEntity : T extends EntityEnum.HOLIDAY ? IHolidayEntity : T extends EntityEnum.HOLIDAY_LIST ? IHolidayListEntity : T extends EntityEnum.COUNTRY ? ICountryEntity : T extends EntityEnum.EXPENSE_TYPE ? IExpenseTypeEntity : T extends EntityEnum.INDUSTRY ? IIndustryEntity : T extends EntityEnum.INTERMEDIARY_BANK ? IIntermediaryBankEntity : T extends EntityEnum.OFFICE_LOCATION ? IOfficeLocationEntity : T extends EntityEnum.PERMISSION ? IPermissionEntity : T extends EntityEnum.ROLE ? IRoleEntity : T extends EntityEnum.TASK ? ITaskEntity : T extends EntityEnum.DESIGNATION ? IDesignationEntity : T extends EntityEnum.RATE ? IRateEntity : T extends EntityEnum.REIMBURSEMENT ? IReimbursementEntity : T extends EntityEnum.REIMBURSEMENT_EXPENSE ? IReimbursementExpenseEntity : T extends EntityEnum.WORK_FROM_HOME ? IWorkFromHomeEntity : T extends EntityEnum.ORGANIZATION ? IOrganizationEntity : T extends EntityEnum.PROJECT_USER_MAPPING ? IProjectUserMappingEntity : T extends EntityEnum.CLIENT_USER_MAPPING ? IClientUserMappingEntity : T extends EntityEnum.CLIENT_INTRODUCING_MAPPING ? IClientIntroducingMappingEntity : T extends EntityEnum.TO_DO_LIST ? IToDoListEntity : T extends EntityEnum.CRON_JOBS ? ICronJobsEntity : T extends EntityEnum.ROLE_PERMISSION_MAPPING ? IRolePermissionMappingEntity : T extends EntityEnum.BANK_HISTORY ? IBankHistoryEntity : T extends VirtualEntityEnum.LEAVE_COUNT ? ILeaveCountVirtualEntity : T extends EntityEnum.LEAVE_HISTORY ? ILeaveHistoryEntity : T extends EntityEnum.WORK_FROM_HOME_HISTORY ? IWorkFromHomeHistoryEntity : T extends EntityEnum.TIMESHEET_HISTORY ? ITimesheetHistoryEntity : T extends EntityEnum.ADDRESS_BOOK ? IAddressBookEntity : T extends EntityEnum.STATE ? IStateEntity : T extends EntityEnum.GST_RATE ? IGstRateEntity : T extends EntityEnum.ORGANIZATION_TYPE ? IOrganizationTypeEntity : never) & {
183
175
  id: number;
184
176
  };
185
177
  export type EntityRelationConfig<T extends EntityEnum | VirtualEntityEnum> = {
@@ -302,7 +294,7 @@ export declare enum VirtualEntityEnum {
302
294
  }
303
295
  export type IHistoryConstraintSearchResponse<T> = IBaseResponse<IHistoryEntitySearchByConstraintResponse<T>[]>;
304
296
  export type IHistoryConstraintSearchServiceResponse<T> = IHistoryEntitySearchByConstraintResponse<T>[];
305
- 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.LEAVE ? LeaveEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : 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 : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : T extends EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING ? OrganizationTypeTdsRateMappingEntityModel : T extends EntityEnum.TDS_RATE ? TdsRateEntityModel : UserEntityModel;
297
+ 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.LEAVE ? LeaveEntityModel : T extends EntityEnum.HOLIDAY ? HolidayEntityModel : T extends VirtualEntityEnum.LEAVE_COUNT ? LeaveCountVirtualEntityModel : 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 : T extends EntityEnum.COUNTRY ? CountryEntityModel : T extends EntityEnum.BILLING_TRANSACTION ? BillingTransactionEntityModel : T extends EntityEnum.ADDRESS_BOOK ? AddressBookEntityModel : T extends EntityEnum.STATE ? StateEntityModel : T extends EntityEnum.GST_RATE ? GstRateEntityModel : T extends EntityEnum.ORGANIZATION_TYPE ? OrganizationTypeEntityModel : UserEntityModel;
306
298
  export type EntityMap = {
307
299
  [key in EntityEnum | VirtualEntityEnum]: EnumToModel<key>[];
308
300
  };
@@ -81,8 +81,6 @@ var EntityEnum;
81
81
  EntityEnum["STATE"] = "state";
82
82
  EntityEnum["GST_RATE"] = "gst_rate";
83
83
  EntityEnum["ORGANIZATION_TYPE"] = "organization_type";
84
- EntityEnum["TDS_RATE"] = "tds_rate";
85
- EntityEnum["ORGANIZATION_TYPE_TDS_RATE_MAPPING"] = "organization_type_tds_rate_mapping";
86
84
  })(EntityEnum || (exports.EntityEnum = EntityEnum = {}));
87
85
  var VirtualEntityEnum;
88
86
  (function (VirtualEntityEnum) {
@@ -34,9 +34,6 @@ export declare class EntityModelRelationHelper {
34
34
  addEntityModel<T extends EntityEnum | VirtualEntityEnum>(entityModel: BaseEntityModel<T>, config?: {
35
35
  populateRelations?: boolean;
36
36
  }): EntityModelRelationHelper;
37
- mergeEntityMap(entityMap: EntityMap, config?: {
38
- populateRelations?: boolean;
39
- }): EntityModelRelationHelper;
40
37
  addEntity<T extends EntityEnum | VirtualEntityEnum>(entity: EnumEntityType<T>, entityEnum: T, config?: {
41
38
  populateRelations?: boolean;
42
39
  }): EntityModelRelationHelper;
@@ -26,14 +26,12 @@ const holiday_entity_model_1 = require("./holiday.entity.model");
26
26
  const leave_entity_model_1 = require("./leave.entity.model");
27
27
  const leave_count_entity_model_1 = require("./leave_count.entity.model");
28
28
  const organization_type_entity_model_1 = require("./organization_type.entity.model");
29
- const organization_type_tds_rate_mapping_entity_model_1 = require("./organization_type_tds_rate_mapping.entity.model");
30
29
  const project_user_mapping_entity_model_1 = require("./project-user-mapping.entity.model");
31
30
  const project_entity_model_1 = require("./project.entity.model");
32
31
  const reimbursement_expense_entity_model_1 = require("./reimbursement-expense.entity.model");
33
32
  const reimbursement_entity_model_1 = require("./reimbursement.entity.model");
34
33
  const state_entity_model_1 = require("./state.entity.model");
35
34
  const task_entity_model_1 = require("./task.entity.model");
36
- const tds_rate_entity_model_1 = require("./tds_rate.entity.model");
37
35
  const timesheet_entity_model_1 = require("./timesheet.entity.model");
38
36
  const user_entity_model_1 = require("./user.entity.model");
39
37
  function mapToIndex(entityMap) {
@@ -88,8 +86,6 @@ exports.entityEnumToEntityModel = {
88
86
  [entity_utils_interface_1.EntityEnum.STATE]: state_entity_model_1.StateEntityModel.fromEntity,
89
87
  [entity_utils_interface_1.EntityEnum.GST_RATE]: gst_rate_entity_model_1.GstRateEntityModel.fromEntity,
90
88
  [entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE]: organization_type_entity_model_1.OrganizationTypeEntityModel.fromEntity,
91
- [entity_utils_interface_1.EntityEnum.TDS_RATE]: tds_rate_entity_model_1.TdsRateEntityModel.fromEntity,
92
- [entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING]: organization_type_tds_rate_mapping_entity_model_1.OrganizationTypeTdsRateMappingEntityModel.fromEntity,
93
89
  };
94
90
  function entityMapToModels(entityMap) {
95
91
  for (const entityName in entityMap) {
@@ -220,46 +216,6 @@ class EntityModelRelationHelper {
220
216
  }
221
217
  return EntityModelRelationHelper.getClone(this);
222
218
  }
223
- mergeEntityMap(entityMap, config = { populateRelations: false }) {
224
- const models = [];
225
- for (const entityName in entityMap) {
226
- if (!(entityName in exports.entityEnumToEntityModel)) {
227
- throw new Error(`Unknown entity: ${entityName}`);
228
- }
229
- const entityModels = entityMap[entityName];
230
- for (const entity of entityModels) {
231
- if (!(entityName in exports.entityEnumToEntityModel)) {
232
- throw new Error(`Unknown entity: ${entityName}`);
233
- }
234
- if (!this.entityMap[entityName]) {
235
- this.entityMap[entityName] = [];
236
- }
237
- if (!this.entityModelMap[entityName]) {
238
- this.entityModelMap[entityName] = [];
239
- }
240
- if (!this.entityModelIndexMap[entityName]) {
241
- this.entityModelIndexMap[entityName] = {};
242
- }
243
- this.entityMap[entityName].push(entity);
244
- const entityModel = exports.entityEnumToEntityModel[entityName
245
- // @ts-ignore
246
- ](entity);
247
- // @ts-ignore
248
- this.entityModelMap[entityName].push(entityModel);
249
- // @ts-ignore
250
- this.entityModelIndexMap[entityName][entityModel.id] =
251
- // @ts-ignore
252
- entityModel;
253
- if (config.populateRelations) {
254
- models.push(entityModel);
255
- }
256
- }
257
- }
258
- for (const model of models) {
259
- this.populateRelationsByEntityModel(model);
260
- }
261
- return EntityModelRelationHelper.getClone(this);
262
- }
263
219
  addEntity(entity, entityEnum, config = { populateRelations: false }) {
264
220
  if (!(entityEnum in exports.entityEnumToEntityModel)) {
265
221
  throw new Error(`Unknown entity: ${entityEnum}`);
@@ -1,6 +1,8 @@
1
+ import { ILeaveUpdateDto } from "../../api";
1
2
  import { DateCodeModel, Weekday } from "../../utils";
2
3
  import { DurationTypeEnum } from "../enums/duration-type.enum";
3
4
  import { LeaveTypeEnum } from "../enums/leave-type.enum";
5
+ import { LeaveActionEnum } from "../enums/leave.action.enum";
4
6
  import { LeaveStatusEnum } from "../enums/leave.status.enum";
5
7
  import { RelationType } from "../enums/relation-type.enum";
6
8
  import { EntityEnum, VirtualEntityEnum } from "../interface/entity.utils.interface";
@@ -73,4 +75,19 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
73
75
  approved: number;
74
76
  rejected: number;
75
77
  };
78
+ getAvailableActions(currentUser: UserEntityModel, config?: {
79
+ combinedActions?: Record<string, {
80
+ combineActions: LeaveActionEnum[];
81
+ label: string;
82
+ }>;
83
+ customLabels?: Partial<Record<LeaveActionEnum, string>>;
84
+ }): Map<LeaveActionEnum | string, string>;
85
+ getUpdateActionVisibility(currentUser: UserEntityModel): {
86
+ [key: string]: () => boolean;
87
+ };
88
+ getAvailableActionsLabelValue(availableActionsFromModel: Map<LeaveActionEnum | string, string>): {
89
+ label: string;
90
+ value: string;
91
+ }[];
92
+ getNextStatus(currentUser: UserEntityModel, dto: ILeaveUpdateDto): LeaveStatusEnum;
76
93
  }
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LeaveEntityModel = void 0;
4
+ const error_key_enum_1 = require("../../enums/error.key.enum");
5
+ const exceptions_1 = require("../../exceptions");
4
6
  const utils_1 = require("../../utils");
5
7
  const string_util_1 = require("../../utils/string.util");
6
8
  const duration_type_enum_1 = require("../enums/duration-type.enum");
7
9
  const leave_type_enum_1 = require("../enums/leave-type.enum");
8
10
  const leave_status_enum_1 = require("../enums/leave.status.enum");
9
11
  const relation_type_enum_1 = require("../enums/relation-type.enum");
12
+ const leave_flow_config_1 = require("../flow-configs/leave.flow.config");
10
13
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
11
14
  const base_entity_model_1 = require("./base.entity.model");
12
15
  class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
@@ -190,6 +193,85 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
190
193
  [leave_status_enum_1.LeaveStatusEnum.REJECTED]: 5,
191
194
  };
192
195
  }
196
+ getAvailableActions(currentUser, config) {
197
+ var _a;
198
+ const combinedActions = (_a = config === null || config === void 0 ? void 0 : config.combinedActions) !== null && _a !== void 0 ? _a : {};
199
+ if (!currentUser.permissions || !this.status) {
200
+ return new Map();
201
+ }
202
+ // get permitted action values
203
+ const permittedActions = (0, utils_1.getPermittedActions)(leave_flow_config_1.leaveFlowConfig, this.status, currentUser.permissions, this.getUpdateActionVisibility.bind(this, currentUser));
204
+ let result = new Map();
205
+ // combine + label
206
+ result = (0, utils_1.combinePermittedActions)(permittedActions, combinedActions);
207
+ return (0, utils_1.applyActionLabels)(permittedActions, result, config === null || config === void 0 ? void 0 : config.customLabels);
208
+ }
209
+ getUpdateActionVisibility(currentUser) {
210
+ return {
211
+ LEAVE_UPDATE_SELF: () => currentUser.id === this.createdBy,
212
+ LEAVE_DELETE_SELF: () => currentUser.id === this.createdBy,
213
+ };
214
+ }
215
+ getAvailableActionsLabelValue(availableActionsFromModel) {
216
+ const availableActionsForRes = [];
217
+ for (const [value, label] of availableActionsFromModel.entries()) {
218
+ availableActionsForRes.push({
219
+ label,
220
+ value: value.toString(),
221
+ });
222
+ }
223
+ return availableActionsForRes;
224
+ }
225
+ getNextStatus(currentUser, dto) {
226
+ if (!this.status) {
227
+ throw new exceptions_1.AppBadRequestException({
228
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
229
+ message: [`Status not found: ${this.status}`],
230
+ });
231
+ }
232
+ //Here we flow config for current status
233
+ const flowForStatus = leave_flow_config_1.leaveFlowConfig[this.status];
234
+ if (!flowForStatus) {
235
+ throw new exceptions_1.AppBadRequestException({
236
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
237
+ message: [`No flow configuration found for status: ${this.status}`],
238
+ });
239
+ }
240
+ if (!(dto === null || dto === void 0 ? void 0 : dto.actionData)) {
241
+ throw new exceptions_1.AppBadRequestException({
242
+ key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
243
+ message: ["dto.actionData is required"],
244
+ });
245
+ }
246
+ // Here we get the permissionConfig for action in dto
247
+ const matchingPermissionConfig = flowForStatus.actions[dto.actionData.action];
248
+ if (!matchingPermissionConfig) {
249
+ throw new exceptions_1.AppBadRequestException({
250
+ key: error_key_enum_1.ErrorKeyEnum.ACTION,
251
+ message: [
252
+ `Action '${dto.actionData.action}' is not valid for the current status.`,
253
+ ],
254
+ });
255
+ }
256
+ // Here we compare users permission & permissions from matchingPermissionConfig
257
+ if (!currentUser.permissions || currentUser.permissions.length === 0) {
258
+ throw new exceptions_1.AppBadRequestException({
259
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSIONS,
260
+ message: ["Permission not available for currentUser"],
261
+ });
262
+ }
263
+ const hasPermission = matchingPermissionConfig.permissions.some((permission) => { var _a; return (_a = currentUser.permissions) === null || _a === void 0 ? void 0 : _a.includes(permission); });
264
+ if (!hasPermission) {
265
+ throw new exceptions_1.AppBadRequestException({
266
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSION,
267
+ message: [
268
+ `Current user does not have permission to ${dto.actionData.action} leave`,
269
+ ],
270
+ });
271
+ }
272
+ const nextStatus = matchingPermissionConfig.next();
273
+ return nextStatus;
274
+ }
193
275
  }
194
276
  exports.LeaveEntityModel = LeaveEntityModel;
195
277
  LeaveEntityModel.relationConfigs = [
@@ -23,5 +23,10 @@ export declare enum ErrorKeyEnum {
23
23
  WORK_FROM_HOME_KEY = "WORK_FROM_HOME_KEY",
24
24
  RELATED_ENTITIES = "RELATED_ENTITIES",
25
25
  USER_ROLE = "USER_ROLE",
26
- ADVANCE_BILLING_ID = "ADVANCE_BILLING_ID"
26
+ ADVANCE_BILLING_ID = "ADVANCE_BILLING_ID",
27
+ STATUS = "STATUS",
28
+ ACTION_DATA = "ACTION_DATA",
29
+ ACTION = "ACTION",
30
+ PERMISSIONS = "PERMISSIONS",
31
+ PERMISSION = "PERMISSION"
27
32
  }
@@ -28,4 +28,9 @@ var ErrorKeyEnum;
28
28
  ErrorKeyEnum["RELATED_ENTITIES"] = "RELATED_ENTITIES";
29
29
  ErrorKeyEnum["USER_ROLE"] = "USER_ROLE";
30
30
  ErrorKeyEnum["ADVANCE_BILLING_ID"] = "ADVANCE_BILLING_ID";
31
+ ErrorKeyEnum["STATUS"] = "STATUS";
32
+ ErrorKeyEnum["ACTION_DATA"] = "ACTION_DATA";
33
+ ErrorKeyEnum["ACTION"] = "ACTION";
34
+ ErrorKeyEnum["PERMISSIONS"] = "PERMISSIONS";
35
+ ErrorKeyEnum["PERMISSION"] = "PERMISSION";
31
36
  })(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
@@ -13,7 +13,7 @@ export type LeaveStatusActionPair = {
13
13
  * @param data - Optional function to provide additional visibility conditions
14
14
  * @returns Array of available actions with labels and values
15
15
  */
16
- export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(entityFlowConfig: {
16
+ export declare function getPermittedActionsOld<T extends LeaveStatusActionPair, E>(entityFlowConfig: {
17
17
  [key in T["status"]]?: {
18
18
  actions: {
19
19
  [key in T["action"]]?: {
@@ -30,3 +30,39 @@ export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(
30
30
  label: string;
31
31
  value: T["action"] | string;
32
32
  }[];
33
+ /**
34
+ * Combines permitted action values into grouped actions where applicable.
35
+ * Returns a map of action keys (enum values or combined string keys) to labels.
36
+ */
37
+ export declare function combinePermittedActions<T extends string>(actions: readonly T[], combinedActions: Record<string, {
38
+ combineActions: readonly T[];
39
+ label: string;
40
+ }>): Map<T | string, string>;
41
+ /**
42
+ * Maps leave actions to human-readable labels and stores them in a Map.
43
+ * Uses custom labels if provided; otherwise, converts the action to Title Case.
44
+ *
45
+ * @template T - Type extending LeaveActionEnum.
46
+ * @param actions - Array of leave actions to process.
47
+ * @param result - Map to store action-to-label pairs.
48
+ * @param customLabels - Optional custom labels for specific actions.
49
+ * @returns The updated Map with action labels.
50
+ */
51
+ export declare function applyActionLabels<T extends LeaveActionEnum>(actions: T[], result: Map<string, string>, customLabels?: Partial<Record<T, string>>): Map<string, string>;
52
+ /**
53
+ * Returns raw permitted action values for the given status and user permissions.
54
+ * This function performs permission and visibility filtering only.
55
+ * It does not apply action combination or labeling.
56
+ */
57
+ export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(entityFlowConfig: {
58
+ [key in T["status"]]?: {
59
+ actions: {
60
+ [key in T["action"]]?: {
61
+ permissions: string[];
62
+ next: () => T["status"];
63
+ };
64
+ };
65
+ };
66
+ }, currentStatus: T["status"] | null, userPermissions: string[], data?: (a: E) => {
67
+ [key: string]: () => boolean;
68
+ }): T["action"][];
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPermittedActionsOld = getPermittedActionsOld;
4
+ exports.combinePermittedActions = combinePermittedActions;
5
+ exports.applyActionLabels = applyActionLabels;
3
6
  exports.getPermittedActions = getPermittedActions;
7
+ const string_util_1 = require("./string.util");
4
8
  /**
5
9
  * Converts an action or combined action to a value-label pair
6
10
  * @param action - The action or combined action key
@@ -43,12 +47,14 @@ function _getPermittedActions(actionConfig, userPermissions, data) {
43
47
  * @param combineActions - Array of actions to combine
44
48
  * @returns Array of action keys, with combined action if applicable
45
49
  */
46
- function combinePermittedActions(permittedActions, combineActions) {
50
+ function combinePermittedActionsOld(permittedActions, combineActions) {
47
51
  if (combineActions.length === 0) {
48
52
  return permittedActions;
49
53
  }
50
54
  const isCombinedActionPresent = combineActions.every((action) => permittedActions.includes(action));
51
55
  if (isCombinedActionPresent) {
56
+ // if combinedActions requested are present then join them
57
+ // return them along with permissted actions
52
58
  const combinedValue = combineActions.join("_");
53
59
  return [
54
60
  ...permittedActions.filter((action) => !combineActions.includes(action)),
@@ -67,7 +73,7 @@ function combinePermittedActions(permittedActions, combineActions) {
67
73
  * @param data - Optional function to provide additional visibility conditions
68
74
  * @returns Array of available actions with labels and values
69
75
  */
70
- function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], actionLabels = {}, data = (_) => ({})) {
76
+ function getPermittedActionsOld(entityFlowConfig, currentStatus, userPermissions, combineActions = [], actionLabels = {}, data = (_) => ({})) {
71
77
  var _a;
72
78
  // Handle invalid inputs
73
79
  if (!currentStatus || !entityFlowConfig[currentStatus]) {
@@ -77,7 +83,55 @@ function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, c
77
83
  // Get permitted actions
78
84
  const permittedActions = _getPermittedActions(actionConfig, userPermissions, data);
79
85
  // Combine actions if specified
80
- const finalActions = combinePermittedActions(permittedActions, combineActions);
86
+ const finalActions = combinePermittedActionsOld(permittedActions, combineActions);
81
87
  // Convert to value-label pairs
82
88
  return finalActions.map((action) => convertToValueLabel(action, actionLabels));
83
89
  }
90
+ /**
91
+ * Combines permitted action values into grouped actions where applicable.
92
+ * Returns a map of action keys (enum values or combined string keys) to labels.
93
+ */
94
+ function combinePermittedActions(actions, combinedActions) {
95
+ let remaining = [...actions];
96
+ const result = new Map();
97
+ for (const [combinedKey, config] of Object.entries(combinedActions)) {
98
+ if (config.combineActions.every((a) => remaining.includes(a))) {
99
+ remaining = remaining.filter((a) => !config.combineActions.includes(a));
100
+ result.set(combinedKey, config.label);
101
+ }
102
+ }
103
+ return result;
104
+ }
105
+ /**
106
+ * Maps leave actions to human-readable labels and stores them in a Map.
107
+ * Uses custom labels if provided; otherwise, converts the action to Title Case.
108
+ *
109
+ * @template T - Type extending LeaveActionEnum.
110
+ * @param actions - Array of leave actions to process.
111
+ * @param result - Map to store action-to-label pairs.
112
+ * @param customLabels - Optional custom labels for specific actions.
113
+ * @returns The updated Map with action labels.
114
+ */
115
+ function applyActionLabels(actions, result, customLabels) {
116
+ let remaining = [...actions];
117
+ for (const action of remaining) {
118
+ result.set(action, customLabels && customLabels[action]
119
+ ? customLabels[action]
120
+ : (0, string_util_1.toTitleCase)(action.toString()));
121
+ }
122
+ return result;
123
+ }
124
+ /**
125
+ * Returns raw permitted action values for the given status and user permissions.
126
+ * This function performs permission and visibility filtering only.
127
+ * It does not apply action combination or labeling.
128
+ */
129
+ function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, data = (_) => ({})) {
130
+ var _a, _b;
131
+ if (!currentStatus || !entityFlowConfig[currentStatus]) {
132
+ return [];
133
+ }
134
+ const actionConfig = (_b = (_a = entityFlowConfig[currentStatus]) === null || _a === void 0 ? void 0 : _a.actions) !== null && _b !== void 0 ? _b : {};
135
+ // @ts-ignore
136
+ return _getPermittedActions(actionConfig, userPermissions, data);
137
+ }
@@ -1 +1,13 @@
1
1
  export declare function formatString(input: string): string;
2
+ /**
3
+ * Converts a string to Title Case.
4
+ *
5
+ * Examples:
6
+ * - "APPROVE" => "Approve"
7
+ * - "PENDING_REVIEW" => "Pending Review"
8
+ * - "in_progress" => "In Progress"
9
+ *
10
+ * @param {string} input - The string to convert.
11
+ * @returns {string} - The string in Title Case.
12
+ */
13
+ export declare function toTitleCase(input: string): string;
@@ -1,15 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatString = formatString;
4
+ exports.toTitleCase = toTitleCase;
4
5
  function formatString(input) {
5
- if (input.includes('_')) {
6
+ if (input.includes("_")) {
6
7
  return input
7
- .split('_')
8
+ .split("_")
8
9
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
9
- .join(' ');
10
+ .join(" ");
10
11
  }
11
12
  else {
12
13
  // For single-word strings, capitalize the first letter
13
14
  return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
14
15
  }
15
16
  }
17
+ /**
18
+ * Converts a string to Title Case.
19
+ *
20
+ * Examples:
21
+ * - "APPROVE" => "Approve"
22
+ * - "PENDING_REVIEW" => "Pending Review"
23
+ * - "in_progress" => "In Progress"
24
+ *
25
+ * @param {string} input - The string to convert.
26
+ * @returns {string} - The string in Title Case.
27
+ */
28
+ function toTitleCase(input) {
29
+ if (!input)
30
+ return "";
31
+ // Replace underscores or hyphens with spaces, then split into words
32
+ const words = input.replace(/[_-]+/g, " ").split(" ");
33
+ // Capitalize first letter of each word
34
+ const titleCased = words
35
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
36
+ .join(" ");
37
+ return titleCased;
38
+ }
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.46.3",
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/lodash": "^4.17.21",
25
- "@types/node": "^22.6.1",
26
- "jest": "^29.7.0",
27
- "ts-jest": "^29.2.5",
28
- "ts-node": "^10.9.2",
29
- "typescript": "^5.6.2"
30
- },
31
- "dependencies": {
32
- "@types/express": "^5.0.0",
33
- "@types/multer": "^1.4.12",
34
- "date-fns": "^4.1.0",
35
- "lodash": "4.17.21"
36
- }
37
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.47.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/lodash": "^4.17.21",
25
+ "@types/node": "^22.6.1",
26
+ "jest": "^29.7.0",
27
+ "ts-jest": "^29.2.5",
28
+ "ts-node": "^10.9.2",
29
+ "typescript": "^5.6.2"
30
+ },
31
+ "dependencies": {
32
+ "@types/express": "^5.0.0",
33
+ "@types/multer": "^1.4.12",
34
+ "date-fns": "^4.1.0",
35
+ "lodash": "4.17.21"
36
+ }
37
+ }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- // import { IEntityCreateDto } from "../../entities";
3
- // export type ITdsRateCreateExclude = "status";
4
- // export interface ITdsRateCreateDto extends Omit<IEntityCreateDto<ITdsRateEntity>, ITdsRateCreateExclude> {
5
- // organizationTypeIds: number[];
6
- // }
@@ -1,6 +0,0 @@
1
- import { IEntityCreateDto } from "../../entities";
2
- import { ITdsRateEntity } from "../../entities/interface/tds_rate.entity.interface";
3
- export type ITdsRateCreateExclude = "status";
4
- export interface ITdsRateCreateDto extends Omit<IEntityCreateDto<ITdsRateEntity>, ITdsRateCreateExclude> {
5
- organizationTypeIds: number[];
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- "use strict";
2
- // import { DeepPartialButRequired } from "./api.utils.interface";
3
- // export type ITdsRateUpdateDto = DeepPartialButRequired<ITdsRateCreateDto, never>;
@@ -1,3 +0,0 @@
1
- import { DeepPartialButRequired } from "./api.utils.interface";
2
- import { ITdsRateCreateDto } from "./tds_rate.create.dto.interface";
3
- export type ITdsRateUpdateDto = DeepPartialButRequired<ITdsRateCreateDto, never>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- "use strict";
2
- // export enum TdsRateStatusEnum {
3
- // ACTIVE = "ACTIVE",
4
- // INACTIVE = "INACTIVE",
5
- // DEACTIVE = "DEACTIVE",
6
- // }
@@ -1,5 +0,0 @@
1
- export declare enum TdsRateStatusEnum {
2
- ACTIVE = "ACTIVE",
3
- INACTIVE = "INACTIVE",
4
- DEACTIVE = "DEACTIVE"
5
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TdsRateStatusEnum = void 0;
4
- var TdsRateStatusEnum;
5
- (function (TdsRateStatusEnum) {
6
- TdsRateStatusEnum["ACTIVE"] = "ACTIVE";
7
- TdsRateStatusEnum["INACTIVE"] = "INACTIVE";
8
- TdsRateStatusEnum["DEACTIVE"] = "DEACTIVE";
9
- })(TdsRateStatusEnum || (exports.TdsRateStatusEnum = TdsRateStatusEnum = {}));
@@ -1,7 +0,0 @@
1
- "use strict";
2
- // import { IEntityAuditColumn } from "./entity-audit-columns.interface";
3
- // export interface IOrganizationTypeTdsRateMappingEntity extends IEntityAuditColumn {
4
- // id: number;
5
- // organizationTypeId: number;
6
- // tdsRateId: number;
7
- // }
@@ -1,6 +0,0 @@
1
- import { IEntityAuditColumn } from "./entity-audit-columns.interface";
2
- export interface IOrganizationTypeTdsRateMappingEntity extends IEntityAuditColumn {
3
- id: number;
4
- organizationTypeId: number;
5
- tdsRateId: number;
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- // import { IEntityAuditColumn } from "./entity-audit-columns.interface";
3
- // export interface ITdsRateEntity extends IEntityAuditColumn {
4
- // id: number;
5
- // section: string;
6
- // code: string;
7
- // description?: string;
8
- // panAvailableRate: number;
9
- // panNotAvailableRate: number;
10
- // effectiveFrom: number;
11
- // status: TdsRateStatusEnum;
12
- // }
@@ -1,12 +0,0 @@
1
- import { TdsRateStatusEnum } from "../enums/tds_rate_status_enum";
2
- import { IEntityAuditColumn } from "./entity-audit-columns.interface";
3
- export interface ITdsRateEntity extends IEntityAuditColumn {
4
- id: number;
5
- section: string;
6
- code: string;
7
- description?: string;
8
- panAvailableRate: number;
9
- panNotAvailableRate: number;
10
- effectiveFrom: number;
11
- status: TdsRateStatusEnum;
12
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // import { EntityEnum } from "../interface/entity.utils.interface";
3
- // import { BaseEntityModel } from "./base.entity.model";
4
- // export class OrganizationTypeTdsRateMappingEntityModel
5
- // extends BaseEntityModel<EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING>
6
- // implements IOrganizationTypeTdsRateMappingEntity
7
- // {
8
- // id: number = 0;
9
- // organizationTypeId: number = 0;
10
- // tdsRateId: number = 0;
11
- // createdOn: number = 0;
12
- // updatedOn: number = 0;
13
- // createdBy: number = 0;
14
- // updatedBy: number = 0;
15
- // static relationConfigs = [];
16
- // static fromEntity(entity: IOrganizationTypeTdsRateMappingEntity): OrganizationTypeTdsRateMappingEntityModel {
17
- // const result = new OrganizationTypeTdsRateMappingEntityModel(EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING);
18
- // Object.assign(result, entity);
19
- // return result;
20
- // }
21
- // getRelationConfigs(): any[] {
22
- // return this.constructor.prototype.constructor.relationConfigs || [];
23
- // }
24
- // }
@@ -1,20 +0,0 @@
1
- import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
2
- import { IOrganizationTypeTdsRateMappingEntity } from "../interface/organization_type_tds_rate_mapping.entity.interface";
3
- import { RelationConfigs } from "../interface/relation-config.interface";
4
- import { BaseEntityModel } from "./base.entity.model";
5
- import { OrganizationTypeEntityModel } from "./organization_type.entity.model";
6
- import { TdsRateEntityModel } from "./tds_rate.entity.model";
7
- export declare class OrganizationTypeTdsRateMappingEntityModel extends BaseEntityModel<EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING> implements IOrganizationTypeTdsRateMappingEntity {
8
- id: number;
9
- organizationTypeId: number;
10
- tdsRateId: number;
11
- createdOn: number;
12
- updatedOn: number;
13
- createdBy: number;
14
- updatedBy: number;
15
- tdsRate?: TdsRateEntityModel;
16
- organizationType?: OrganizationTypeEntityModel;
17
- static relationConfigs: RelationConfigs<[EntityEnum.TDS_RATE, EntityEnum.ORGANIZATION_TYPE], EnumEntityType<EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING>>;
18
- static fromEntity(entity: IOrganizationTypeTdsRateMappingEntity): OrganizationTypeTdsRateMappingEntityModel;
19
- getRelationConfigs(): any[];
20
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrganizationTypeTdsRateMappingEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
5
- const entity_utils_interface_1 = require("../interface/entity.utils.interface");
6
- const base_entity_model_1 = require("./base.entity.model");
7
- class OrganizationTypeTdsRateMappingEntityModel extends base_entity_model_1.BaseEntityModel {
8
- constructor() {
9
- super(...arguments);
10
- this.id = 0;
11
- this.organizationTypeId = 0;
12
- this.tdsRateId = 0;
13
- this.createdOn = 0;
14
- this.updatedOn = 0;
15
- this.createdBy = 0;
16
- this.updatedBy = 0;
17
- }
18
- static fromEntity(entity) {
19
- const result = new OrganizationTypeTdsRateMappingEntityModel(entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING);
20
- Object.assign(result, entity);
21
- return result;
22
- }
23
- getRelationConfigs() {
24
- return this.constructor.prototype.constructor.relationConfigs || [];
25
- }
26
- }
27
- exports.OrganizationTypeTdsRateMappingEntityModel = OrganizationTypeTdsRateMappingEntityModel;
28
- OrganizationTypeTdsRateMappingEntityModel.relationConfigs = [
29
- {
30
- name: entity_utils_interface_1.EntityEnum.TDS_RATE,
31
- relation: relation_type_enum_1.RelationType.ONE,
32
- key: "tdsRate",
33
- mapKeyConfig: {
34
- relationKey: "id",
35
- key: "tdsRateId",
36
- },
37
- },
38
- {
39
- name: entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE,
40
- relation: relation_type_enum_1.RelationType.ONE,
41
- key: "organizationType",
42
- mapKeyConfig: {
43
- relationKey: "id",
44
- key: "organizationTypeId",
45
- },
46
- },
47
- ];
@@ -1,37 +0,0 @@
1
- "use strict";
2
- // import { EntityEnum } from "../interface/entity.utils.interface";
3
- // import { BaseEntityModel } from "./base.entity.model";
4
- // export class TdsRateEntityModel extends BaseEntityModel<EntityEnum.TDS_RATE> implements ITdsRateEntity {
5
- // id: number = 0;
6
- // section: string = "";
7
- // code: string = "";
8
- // description?: string;
9
- // panAvailableRate: number = 0;
10
- // panNotAvailableRate: number = 0;
11
- // effectiveFrom: number = 0;
12
- // status: TdsRateStatusEnum = TdsRateStatusEnum.ACTIVE;
13
- // createdOn: number = 0;
14
- // updatedOn: number = 0;
15
- // createdBy: number = 0;
16
- // updatedBy: number = 0;
17
- // organizationTypeTdsRateMappings?: OrganizationTypeTdsRateMappingEntityModel[];
18
- // static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING], EnumEntityType<EntityEnum.TDS_RATE>> = [
19
- // {
20
- // name: EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING,
21
- // relation: RelationType.MANY,
22
- // key: "organizationTypeTdsRateMappings",
23
- // mapKeyConfig: {
24
- // relationKey: "tdsRateId",
25
- // key: "id",
26
- // },
27
- // },
28
- // ];
29
- // static fromEntity(entity: ITdsRateEntity): TdsRateEntityModel {
30
- // const result = new TdsRateEntityModel(EntityEnum.TDS_RATE);
31
- // Object.assign(result, entity);
32
- // return result;
33
- // }
34
- // getRelationConfigs(): any[] {
35
- // return this.constructor.prototype.constructor.relationConfigs || [];
36
- // }
37
- // }
@@ -1,25 +0,0 @@
1
- import { TdsRateStatusEnum } from "../enums/tds_rate_status_enum";
2
- import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
3
- import { RelationConfigs } from "../interface/relation-config.interface";
4
- import { ITdsRateEntity } from "../interface/tds_rate.entity.interface";
5
- import { BaseEntityModel } from "./base.entity.model";
6
- import { OrganizationTypeTdsRateMappingEntityModel } from "./organization_type_tds_rate_mapping.entity.model";
7
- export declare class TdsRateEntityModel extends BaseEntityModel<EntityEnum.TDS_RATE> implements ITdsRateEntity {
8
- id: number;
9
- section: string;
10
- code: string;
11
- description?: string;
12
- panAvailableRate: number;
13
- panNotAvailableRate: number;
14
- effectiveFrom: number;
15
- status: TdsRateStatusEnum;
16
- createdOn: number;
17
- updatedOn: number;
18
- createdBy: number;
19
- updatedBy: number;
20
- organizationTypeTdsRateMappings?: OrganizationTypeTdsRateMappingEntityModel[];
21
- static relationConfigs: RelationConfigs<[EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING], EnumEntityType<EntityEnum.TDS_RATE>>;
22
- static fromEntity(entity: ITdsRateEntity): TdsRateEntityModel;
23
- getRelationConfigs(): any[];
24
- get organizationTypeIds(): number[];
25
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TdsRateEntityModel = void 0;
4
- const relation_type_enum_1 = require("../enums/relation-type.enum");
5
- const tds_rate_status_enum_1 = require("../enums/tds_rate_status_enum");
6
- const entity_utils_interface_1 = require("../interface/entity.utils.interface");
7
- const base_entity_model_1 = require("./base.entity.model");
8
- class TdsRateEntityModel extends base_entity_model_1.BaseEntityModel {
9
- constructor() {
10
- super(...arguments);
11
- this.id = 0;
12
- this.section = "";
13
- this.code = "";
14
- this.panAvailableRate = 0;
15
- this.panNotAvailableRate = 0;
16
- this.effectiveFrom = 0;
17
- this.status = tds_rate_status_enum_1.TdsRateStatusEnum.ACTIVE;
18
- this.createdOn = 0;
19
- this.updatedOn = 0;
20
- this.createdBy = 0;
21
- this.updatedBy = 0;
22
- }
23
- static fromEntity(entity) {
24
- const result = new TdsRateEntityModel(entity_utils_interface_1.EntityEnum.TDS_RATE);
25
- Object.assign(result, entity);
26
- return result;
27
- }
28
- getRelationConfigs() {
29
- return this.constructor.prototype.constructor.relationConfigs || [];
30
- }
31
- get organizationTypeIds() {
32
- var _a;
33
- return ((_a = this.organizationTypeTdsRateMappings) === null || _a === void 0 ? void 0 : _a.map((mapping) => mapping.organizationTypeId)) || [];
34
- }
35
- }
36
- exports.TdsRateEntityModel = TdsRateEntityModel;
37
- TdsRateEntityModel.relationConfigs = [
38
- {
39
- name: entity_utils_interface_1.EntityEnum.ORGANIZATION_TYPE_TDS_RATE_MAPPING,
40
- relation: relation_type_enum_1.RelationType.MANY,
41
- key: "organizationTypeTdsRateMappings",
42
- mapKeyConfig: {
43
- relationKey: "tdsRateId",
44
- key: "id",
45
- },
46
- },
47
- ];