rez_core 2.2.247 → 2.2.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/filter/filter.module.js +7 -2
- package/dist/module/filter/filter.module.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +5 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +46 -2
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/filter.module.ts +7 -3
- package/src/module/workflow-automation/service/workflow-automation.service.ts +69 -1
package/package.json
CHANGED
|
@@ -13,15 +13,19 @@ import { FilterEvaluatorService } from './service/filter-evaluator.service';
|
|
|
13
13
|
imports: [
|
|
14
14
|
TypeOrmModule.forFeature([SavedFilterDetail, SavedFilterMaster]),
|
|
15
15
|
forwardRef(() => EntityModule),
|
|
16
|
-
|
|
17
16
|
],
|
|
18
17
|
controllers: [FilterController],
|
|
19
18
|
providers: [
|
|
20
19
|
{ provide: 'SavedFilterService', useClass: SavedFilterService },
|
|
21
20
|
SavedFilterRepositoryService,
|
|
22
21
|
FilterService,
|
|
23
|
-
FilterEvaluatorService
|
|
22
|
+
FilterEvaluatorService,
|
|
23
|
+
],
|
|
24
|
+
exports: [
|
|
25
|
+
'SavedFilterService',
|
|
26
|
+
SavedFilterRepositoryService,
|
|
27
|
+
FilterService,
|
|
28
|
+
FilterEvaluatorService,
|
|
24
29
|
],
|
|
25
|
-
exports: ['SavedFilterService', SavedFilterRepositoryService, FilterService,FilterEvaluatorService],
|
|
26
30
|
})
|
|
27
31
|
export class FilterModule {}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { Repository } from 'typeorm';
|
|
4
4
|
import { WorkflowAutomation } from '../entity/workflow-automation.entity';
|
|
5
5
|
import { WorkflowAutomationActionEntity } from '../entity/workflow-automation-action.entity';
|
|
6
6
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
7
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
8
|
+
import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
|
|
7
9
|
|
|
8
10
|
@Injectable()
|
|
9
11
|
export class WorkflowAutomationService extends EntityServiceImpl {
|
|
@@ -12,6 +14,8 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
12
14
|
private readonly wfRepo: Repository<WorkflowAutomation>,
|
|
13
15
|
@InjectRepository(WorkflowAutomationActionEntity)
|
|
14
16
|
private readonly actionRepo: Repository<WorkflowAutomationActionEntity>,
|
|
17
|
+
@Inject('SavedFilterService')
|
|
18
|
+
private readonly savedFilterService: SavedFilterService,
|
|
15
19
|
) {
|
|
16
20
|
super();
|
|
17
21
|
}
|
|
@@ -58,4 +62,68 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
58
62
|
where: { workflow_automation_id },
|
|
59
63
|
});
|
|
60
64
|
}
|
|
65
|
+
|
|
66
|
+
async updateEntity(entityData: any, loggedInUser: UserData) {
|
|
67
|
+
// 1. Extract "core" workflow fields
|
|
68
|
+
const { event, criteria, action, ...workflowData } = entityData;
|
|
69
|
+
|
|
70
|
+
// 2. Update only valid workflow columns
|
|
71
|
+
let workflow = await super.updateEntity(workflowData, loggedInUser);
|
|
72
|
+
|
|
73
|
+
// 3. EVENT
|
|
74
|
+
if (event?.eventFilterJson || event?.triggerType || event?.event) {
|
|
75
|
+
const eventFilterMaster = {
|
|
76
|
+
entity_type: 'SFM',
|
|
77
|
+
name: `Event_Filter_${workflow.id}`,
|
|
78
|
+
filterDetails: event?.eventFilterJson ?? [],
|
|
79
|
+
filter_scope: 'RULE',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const savedEvent = await this.savedFilterService.createEntity(
|
|
83
|
+
eventFilterMaster,
|
|
84
|
+
loggedInUser,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
workflow.trigger_type = event?.triggerType ?? null;
|
|
88
|
+
workflow.trigger_event = event?.event ?? null;
|
|
89
|
+
workflow.condition_filter_code = savedEvent.code;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 4. CRITERIA
|
|
93
|
+
if (criteria?.criteriaFilterJson?.length) {
|
|
94
|
+
const criteriaFilterMaster = {
|
|
95
|
+
entity_type: 'SFM',
|
|
96
|
+
name: `Criteria_Filter_${workflow.id}`,
|
|
97
|
+
filterDetails: criteria?.criteriaFilterJson ?? [],
|
|
98
|
+
filter_scope: 'RULE',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const savedCriteria = await this.savedFilterService.createEntity(
|
|
102
|
+
criteriaFilterMaster,
|
|
103
|
+
loggedInUser,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
workflow.criteria_filter_code = savedCriteria.code;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 5. ACTIONS
|
|
110
|
+
if (Array.isArray(action) && action.length) {
|
|
111
|
+
for (const a of action) {
|
|
112
|
+
if (!a?.actionCategory) continue; // skip invalid
|
|
113
|
+
|
|
114
|
+
const actionEntity = new WorkflowAutomationActionEntity();
|
|
115
|
+
actionEntity.entity_type = 'WFAA';
|
|
116
|
+
actionEntity.workflow_automation_id = workflow.id;
|
|
117
|
+
actionEntity.entity_method = a.actionCategory;
|
|
118
|
+
actionEntity.payload = a.actionPayload ?? {};
|
|
119
|
+
|
|
120
|
+
await super.createEntity(actionEntity, loggedInUser);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 6. Save workflow with updated trigger/criteria codes
|
|
125
|
+
workflow = await super.updateEntity(workflow, loggedInUser);
|
|
126
|
+
|
|
127
|
+
return workflow;
|
|
128
|
+
}
|
|
61
129
|
}
|