law-common 10.74.0 → 10.75.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/state.update.dto.interface.d.ts +6 -3
- package/dist/src/api/interface/state.update.dto.interface.js +6 -2
- package/dist/src/api/interface/vendor_invoice_payment.create.dto.interface.d.ts +5 -0
- package/dist/src/api/interface/vendor_invoice_payment.create.dto.interface.js +2 -0
- package/dist/src/api/interface/vendor_invoice_payment.update.dto.interface.d.ts +18 -0
- package/dist/src/api/interface/vendor_invoice_payment.update.dto.interface.js +13 -0
- package/dist/src/entities/enums/configuration-key.enum.d.ts +8 -2
- package/dist/src/entities/enums/configuration-key.enum.js +7 -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/state_status_enum.d.ts +10 -3
- package/dist/src/entities/enums/state_status_enum.js +13 -3
- package/dist/src/entities/enums/vendor_invoice_payment_mode_enum.d.ts +7 -0
- package/dist/src/entities/enums/vendor_invoice_payment_mode_enum.js +11 -0
- package/dist/src/entities/enums/vendor_invoice_payment_status_enum.d.ts +12 -0
- package/dist/src/entities/enums/vendor_invoice_payment_status_enum.js +16 -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/state_flow.config.js +261 -56
- package/dist/src/entities/flow-configs/vendor_invoice_payment_flow.config.d.ts +6 -0
- package/dist/src/entities/flow-configs/vendor_invoice_payment_flow.config.js +256 -0
- package/dist/src/entities/index.d.ts +5 -0
- package/dist/src/entities/index.js +7 -0
- package/dist/src/entities/interface/configuration.entity.interface.d.ts +2 -1
- 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/vendor_invoice_payment.entity.interface.d.ts +14 -0
- package/dist/src/entities/interface/vendor_invoice_payment.entity.interface.js +2 -0
- package/dist/src/entities/model/entity.model.interface.js +2 -0
- package/dist/src/entities/model/project.entity.model.d.ts +2 -0
- package/dist/src/entities/model/project.entity.model.js +6 -0
- package/dist/src/entities/model/state.entity.model.js +1 -1
- package/dist/src/entities/model/vendor_invoice_payment.entity.model.d.ts +61 -0
- package/dist/src/entities/model/vendor_invoice_payment.entity.model.js +206 -0
- package/dist/src/index.js +17 -7
- package/dist/src/utils/helper.fn.util.d.ts +2 -2
- package/dist/src/utils/models/date-code.model.util.d.ts +4 -0
- package/dist/src/utils/models/date-code.model.util.js +13 -0
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
# law-common
|
|
1
|
+
# law-common
|
package/dist/src/api/index.d.ts
CHANGED
|
@@ -97,3 +97,5 @@ export * from "./interface/client_quote_rate.update.dto.interface";
|
|
|
97
97
|
export * from "./interface/project-revenue-split.create.dto";
|
|
98
98
|
export * from "./interface/entity_history.create.dto.interface";
|
|
99
99
|
export * from "./interface/entity_history.update.dto.interface";
|
|
100
|
+
export * from "./interface/vendor_invoice_payment.create.dto.interface";
|
|
101
|
+
export * from "./interface/vendor_invoice_payment.update.dto.interface";
|
package/dist/src/api/index.js
CHANGED
|
@@ -117,3 +117,5 @@ __exportStar(require("./interface/client_quote_rate.update.dto.interface"), expo
|
|
|
117
117
|
__exportStar(require("./interface/project-revenue-split.create.dto"), exports);
|
|
118
118
|
__exportStar(require("./interface/entity_history.create.dto.interface"), exports);
|
|
119
119
|
__exportStar(require("./interface/entity_history.update.dto.interface"), exports);
|
|
120
|
+
__exportStar(require("./interface/vendor_invoice_payment.create.dto.interface"), exports);
|
|
121
|
+
__exportStar(require("./interface/vendor_invoice_payment.update.dto.interface"), exports);
|
|
@@ -8,8 +8,11 @@ export interface IStateActionDataDto {
|
|
|
8
8
|
remark?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare enum StateActionEnum {
|
|
11
|
-
|
|
12
|
-
EDIT = "edit",
|
|
11
|
+
UPDATE = "update",
|
|
13
12
|
DELETE = "delete",
|
|
14
|
-
CREATE = "create"
|
|
13
|
+
CREATE = "create",
|
|
14
|
+
APPROVE = "approve",
|
|
15
|
+
REJECT = "reject",
|
|
16
|
+
RECALL = "recall",
|
|
17
|
+
DEACTIVATE = "deactivate"
|
|
15
18
|
}
|
|
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StateActionEnum = void 0;
|
|
4
4
|
var StateActionEnum;
|
|
5
5
|
(function (StateActionEnum) {
|
|
6
|
-
|
|
7
|
-
StateActionEnum["
|
|
6
|
+
// VIEW = "view",
|
|
7
|
+
StateActionEnum["UPDATE"] = "update";
|
|
8
8
|
StateActionEnum["DELETE"] = "delete";
|
|
9
9
|
StateActionEnum["CREATE"] = "create";
|
|
10
|
+
StateActionEnum["APPROVE"] = "approve";
|
|
11
|
+
StateActionEnum["REJECT"] = "reject";
|
|
12
|
+
StateActionEnum["RECALL"] = "recall";
|
|
13
|
+
StateActionEnum["DEACTIVATE"] = "deactivate";
|
|
10
14
|
})(StateActionEnum || (exports.StateActionEnum = StateActionEnum = {}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IEntityCreateDto } from "../../entities";
|
|
2
|
+
import { IVendorInvoicePaymentEntity } from "../../entities/interface/vendor_invoice_payment.entity.interface";
|
|
3
|
+
export type IVendorInvoicePaymentCreateExclude = "status";
|
|
4
|
+
export interface IVendorInvoicePaymentCreateDto extends Omit<IEntityCreateDto<IVendorInvoicePaymentEntity>, IVendorInvoicePaymentCreateExclude> {
|
|
5
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DeepPartialButRequired } from "./api.utils.interface";
|
|
2
|
+
import { IVendorInvoicePaymentCreateDto } from "./vendor_invoice_payment.create.dto.interface";
|
|
3
|
+
export type IVendorInvoicePaymentUpdateDto = DeepPartialButRequired<IVendorInvoicePaymentCreateDto, never> & {
|
|
4
|
+
actionData: IVendorInvoicePaymentActionDataDto;
|
|
5
|
+
};
|
|
6
|
+
export interface IVendorInvoicePaymentActionDataDto {
|
|
7
|
+
action: VendorInvoicePaymentActionEnum;
|
|
8
|
+
remark?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare enum VendorInvoicePaymentActionEnum {
|
|
11
|
+
UPDATE = "update",
|
|
12
|
+
DELETE = "delete",
|
|
13
|
+
CREATE = "create",
|
|
14
|
+
APPROVE = "approve",
|
|
15
|
+
REJECT = "reject",
|
|
16
|
+
RECALL = "recall",
|
|
17
|
+
DEACTIVATE = "deactivate"
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VendorInvoicePaymentActionEnum = void 0;
|
|
4
|
+
var VendorInvoicePaymentActionEnum;
|
|
5
|
+
(function (VendorInvoicePaymentActionEnum) {
|
|
6
|
+
VendorInvoicePaymentActionEnum["UPDATE"] = "update";
|
|
7
|
+
VendorInvoicePaymentActionEnum["DELETE"] = "delete";
|
|
8
|
+
VendorInvoicePaymentActionEnum["CREATE"] = "create";
|
|
9
|
+
VendorInvoicePaymentActionEnum["APPROVE"] = "approve";
|
|
10
|
+
VendorInvoicePaymentActionEnum["REJECT"] = "reject";
|
|
11
|
+
VendorInvoicePaymentActionEnum["RECALL"] = "recall";
|
|
12
|
+
VendorInvoicePaymentActionEnum["DEACTIVATE"] = "deactivate";
|
|
13
|
+
})(VendorInvoicePaymentActionEnum || (exports.VendorInvoicePaymentActionEnum = VendorInvoicePaymentActionEnum = {}));
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { CronJobNames } from "./cron-jobs-name.enum";
|
|
2
2
|
export declare enum ConfigurationKeyEnum {
|
|
3
|
-
PENDING_APPROVAL_TIMESHEET_REMINDER = "pendingApprovalTimesheetReminder"
|
|
3
|
+
PENDING_APPROVAL_TIMESHEET_REMINDER = "pendingApprovalTimesheetReminder",
|
|
4
|
+
TIMESHEET_VIEW_RANGE = "timesheetViewRange",
|
|
5
|
+
TIMESHEET_VIEW_THRESHOLD = "timesheetViewThreshold",
|
|
6
|
+
TIMESHEET_THRESHOLD = "timesheetThreshold",
|
|
7
|
+
TIMESHEET_ENTER_THRESHOLD = "timesheetEnterThreshold",
|
|
8
|
+
ORGANIZATION_BILLING_OVERDUE_THRESHOLD = "organization_billing_overdue_threshold",
|
|
9
|
+
PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET = "projectEntityUsageNotificationSentPercentageReset"
|
|
4
10
|
}
|
|
5
11
|
export declare namespace ConfigurationKeyEnum {
|
|
6
12
|
function IsCronJobConfigurationKey(key: ConfigurationKeyEnum): boolean;
|
|
7
|
-
function getCronJobName(configurationKey: ConfigurationKeyEnum): CronJobNames;
|
|
13
|
+
function getCronJobName(configurationKey: ConfigurationKeyEnum): CronJobNames | undefined;
|
|
8
14
|
}
|
|
@@ -5,6 +5,12 @@ const cron_jobs_name_enum_1 = require("./cron-jobs-name.enum");
|
|
|
5
5
|
var ConfigurationKeyEnum;
|
|
6
6
|
(function (ConfigurationKeyEnum) {
|
|
7
7
|
ConfigurationKeyEnum["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pendingApprovalTimesheetReminder";
|
|
8
|
+
ConfigurationKeyEnum["TIMESHEET_VIEW_RANGE"] = "timesheetViewRange";
|
|
9
|
+
ConfigurationKeyEnum["TIMESHEET_VIEW_THRESHOLD"] = "timesheetViewThreshold";
|
|
10
|
+
ConfigurationKeyEnum["TIMESHEET_THRESHOLD"] = "timesheetThreshold";
|
|
11
|
+
ConfigurationKeyEnum["TIMESHEET_ENTER_THRESHOLD"] = "timesheetEnterThreshold";
|
|
12
|
+
ConfigurationKeyEnum["ORGANIZATION_BILLING_OVERDUE_THRESHOLD"] = "organization_billing_overdue_threshold";
|
|
13
|
+
ConfigurationKeyEnum["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "projectEntityUsageNotificationSentPercentageReset";
|
|
8
14
|
})(ConfigurationKeyEnum || (exports.ConfigurationKeyEnum = ConfigurationKeyEnum = {}));
|
|
9
15
|
(function (ConfigurationKeyEnum) {
|
|
10
16
|
function IsCronJobConfigurationKey(key) {
|
|
@@ -16,6 +22,7 @@ var ConfigurationKeyEnum;
|
|
|
16
22
|
function getCronJobName(configurationKey) {
|
|
17
23
|
const cronJobConfigurationKeyMapping = {
|
|
18
24
|
[ConfigurationKeyEnum.PENDING_APPROVAL_TIMESHEET_REMINDER]: cron_jobs_name_enum_1.CronJobNames.PENDING_APPROVAL_TIMESHEET_REMINDER,
|
|
25
|
+
[ConfigurationKeyEnum.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET]: cron_jobs_name_enum_1.CronJobNames.PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET,
|
|
19
26
|
};
|
|
20
27
|
return cronJobConfigurationKeyMapping[configurationKey];
|
|
21
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare enum CronJobNames {
|
|
2
|
-
PENDING_APPROVAL_TIMESHEET_REMINDER = "pending_approval_timesheet_reminder"
|
|
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
4
|
}
|
|
@@ -4,4 +4,5 @@ exports.CronJobNames = void 0;
|
|
|
4
4
|
var CronJobNames;
|
|
5
5
|
(function (CronJobNames) {
|
|
6
6
|
CronJobNames["PENDING_APPROVAL_TIMESHEET_REMINDER"] = "pending_approval_timesheet_reminder";
|
|
7
|
+
CronJobNames["PROJECT_ENTITY_USAGE_NOTIFICATION_SENT_PERCENTAGE_RESET"] = "project_entity_usage_notification_sent_percentage_reset";
|
|
7
8
|
})(CronJobNames || (exports.CronJobNames = CronJobNames = {}));
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export declare enum StateStatusEnum {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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"
|
|
5
12
|
}
|
|
@@ -3,7 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StateStatusEnum = void 0;
|
|
4
4
|
var StateStatusEnum;
|
|
5
5
|
(function (StateStatusEnum) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
StateStatusEnum["
|
|
6
|
+
// NO_ROW = "NO_ROW",
|
|
7
|
+
// ACTIVE = "ACTIVE",
|
|
8
|
+
StateStatusEnum["DEACTIVATED"] = "DEACTIVATED";
|
|
9
|
+
// INACTIVE = "INACTIVE",
|
|
10
|
+
StateStatusEnum["CREATED"] = "CREATED";
|
|
11
|
+
StateStatusEnum["UPDATED"] = "UPDATED";
|
|
12
|
+
StateStatusEnum["DELETED"] = "DELETED";
|
|
13
|
+
StateStatusEnum["APPROVED"] = "APPROVED";
|
|
14
|
+
StateStatusEnum["REJECTED"] = "REJECTED";
|
|
15
|
+
StateStatusEnum["CREATE_APPROVAL_PENDING"] = "CREATE_APPROVAL_PENDING";
|
|
16
|
+
StateStatusEnum["UPDATE_APPROVAL_PENDING"] = "UPDATE_APPROVAL_PENDING";
|
|
17
|
+
StateStatusEnum["DELETE_APPROVAL_PENDING"] = "DELETE_APPROVAL_PENDING";
|
|
18
|
+
StateStatusEnum["RESOLVED_REJECTED"] = "RESOLVED_REJECTED";
|
|
9
19
|
})(StateStatusEnum || (exports.StateStatusEnum = StateStatusEnum = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VendorInvoicePaymentModeEnum = void 0;
|
|
4
|
+
var VendorInvoicePaymentModeEnum;
|
|
5
|
+
(function (VendorInvoicePaymentModeEnum) {
|
|
6
|
+
VendorInvoicePaymentModeEnum["CASH"] = "CASH";
|
|
7
|
+
VendorInvoicePaymentModeEnum["NEFT"] = "NEFT";
|
|
8
|
+
VendorInvoicePaymentModeEnum["RTGS"] = "RTGS";
|
|
9
|
+
VendorInvoicePaymentModeEnum["UPI"] = "UPI";
|
|
10
|
+
VendorInvoicePaymentModeEnum["CHEQUE"] = "CHEQUE";
|
|
11
|
+
})(VendorInvoicePaymentModeEnum || (exports.VendorInvoicePaymentModeEnum = VendorInvoicePaymentModeEnum = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum VendorInvoicePaymentStatusEnum {
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VendorInvoicePaymentStatusEnum = void 0;
|
|
4
|
+
var VendorInvoicePaymentStatusEnum;
|
|
5
|
+
(function (VendorInvoicePaymentStatusEnum) {
|
|
6
|
+
VendorInvoicePaymentStatusEnum["DEACTIVATED"] = "DEACTIVATED";
|
|
7
|
+
VendorInvoicePaymentStatusEnum["CREATED"] = "CREATED";
|
|
8
|
+
VendorInvoicePaymentStatusEnum["UPDATED"] = "UPDATED";
|
|
9
|
+
VendorInvoicePaymentStatusEnum["DELETED"] = "DELETED";
|
|
10
|
+
VendorInvoicePaymentStatusEnum["APPROVED"] = "APPROVED";
|
|
11
|
+
VendorInvoicePaymentStatusEnum["REJECTED"] = "REJECTED";
|
|
12
|
+
VendorInvoicePaymentStatusEnum["CREATE_APPROVAL_PENDING"] = "CREATE_APPROVAL_PENDING";
|
|
13
|
+
VendorInvoicePaymentStatusEnum["UPDATE_APPROVAL_PENDING"] = "UPDATE_APPROVAL_PENDING";
|
|
14
|
+
VendorInvoicePaymentStatusEnum["DELETE_APPROVAL_PENDING"] = "DELETE_APPROVAL_PENDING";
|
|
15
|
+
VendorInvoicePaymentStatusEnum["RESOLVED_REJECTED"] = "RESOLVED_REJECTED";
|
|
16
|
+
})(VendorInvoicePaymentStatusEnum || (exports.VendorInvoicePaymentStatusEnum = VendorInvoicePaymentStatusEnum = {}));
|
|
@@ -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 statuses: 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]["statuses"]; }[Act][number] = { [key in A]: AM[key]["statuses"]; }[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]["statuses"]; }[Act][number] = { [key in A]: AM[key]["statuses"]; }[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 nextStatus Fixed target status, or a function `(ctx) => status`
|
|
103
|
+
* for context-driven transitions.
|
|
104
|
+
* @param action The action this config is for (used to look up
|
|
105
|
+
* default permissions from `actionMap`).
|
|
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
|
+
}
|