rez_core 2.2.246 → 2.2.248
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/filter/service/filter.service.js +8 -3
- package/dist/module/filter/service/filter.service.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 +44 -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/filter/service/filter.service.ts +9 -3
- package/src/module/workflow-automation/service/workflow-automation.service.ts +67 -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 {}
|
|
@@ -139,10 +139,16 @@ export class FilterService {
|
|
|
139
139
|
console.log("IN FILTER SERVICE",savedFilterCode);
|
|
140
140
|
const savedFilters = await this.getSavedFilters(savedFilterCode);
|
|
141
141
|
console.log("SAVED FILTERS", savedFilters);
|
|
142
|
+
const savedFiltersNormalized = savedFilters.map(f => ({
|
|
143
|
+
filter_attribute: f.filter_attribute,
|
|
144
|
+
filter_operator: f.filter_operator,
|
|
145
|
+
filter_value: f.filter_value
|
|
146
|
+
}));
|
|
147
|
+
|
|
142
148
|
const baseFilters = [
|
|
143
|
-
...(quickFilter || []).filter(
|
|
144
|
-
...
|
|
145
|
-
...(attributeFilter || []).filter(
|
|
149
|
+
...(quickFilter || []).filter(f => f.filter_value != null && f.filter_value !== ''),
|
|
150
|
+
...savedFiltersNormalized.filter(f => f.filter_value != null && f.filter_value !== ''),
|
|
151
|
+
...(attributeFilter || []).filter(f => f.filter_value != null && f.filter_value !== ''),
|
|
146
152
|
];
|
|
147
153
|
|
|
148
154
|
// Build where clauses
|
|
@@ -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,66 @@ 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) {
|
|
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;
|
|
88
|
+
workflow.trigger_event = event.event;
|
|
89
|
+
workflow.condition_filter_code = savedEvent.code;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 4. CRITERIA
|
|
93
|
+
if (criteria) {
|
|
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 (action?.length) {
|
|
111
|
+
for (const a of action) {
|
|
112
|
+
const actionEntity = new WorkflowAutomationActionEntity();
|
|
113
|
+
actionEntity.entity_type = 'WFAA';
|
|
114
|
+
actionEntity.workflow_automation_id = workflow.id;
|
|
115
|
+
actionEntity.entity_method = a.actionCategory;
|
|
116
|
+
actionEntity.payload = a.actionPayload;
|
|
117
|
+
|
|
118
|
+
await super.createEntity(actionEntity, loggedInUser);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 6. Save workflow with updated trigger/criteria codes
|
|
123
|
+
workflow = await super.updateEntity(workflow, loggedInUser);
|
|
124
|
+
|
|
125
|
+
return workflow;
|
|
126
|
+
}
|
|
61
127
|
}
|