rez_core 3.1.90 → 3.1.92
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/service/filter.service.js +34 -71
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/mapper/controller/field-mapper.controller.d.ts +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +1 -1
- package/dist/module/mapper/service/field-mapper.service.js +2 -2
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +1 -3
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +12 -16
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +123 -338
- package/src/module/mapper/service/field-mapper.service.ts +2 -2
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +25 -62
|
@@ -92,7 +92,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
92
92
|
const fieldMappers =
|
|
93
93
|
await this.fieldMapperRepository.findByMapperId(mapper_id);
|
|
94
94
|
|
|
95
|
-
const result
|
|
95
|
+
const result = new Map<string, any>();
|
|
96
96
|
const inMemory: Record<string, Record<string, any>> = {}; // cache for entity lookups
|
|
97
97
|
|
|
98
98
|
for (const field of fieldMappers) {
|
|
@@ -179,7 +179,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// Add to result
|
|
182
|
-
result
|
|
182
|
+
result.set(field.source_attribute, value);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -4,7 +4,6 @@ import { WorkflowAutomationService } from './workflow-automation.service';
|
|
|
4
4
|
import { FilterEvaluatorService } from '../../filter/service/filter-evaluator.service';
|
|
5
5
|
import { Action } from '../interface/action.interface';
|
|
6
6
|
import { DataSource } from 'typeorm';
|
|
7
|
-
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
8
7
|
|
|
9
8
|
@Injectable()
|
|
10
9
|
export class WorkflowAutomationEngineService {
|
|
@@ -15,16 +14,12 @@ export class WorkflowAutomationEngineService {
|
|
|
15
14
|
private readonly wfService: WorkflowAutomationService,
|
|
16
15
|
private readonly filterEvaluator: FilterEvaluatorService,
|
|
17
16
|
private readonly dataSource: DataSource,
|
|
18
|
-
@Inject() protected readonly loggingService: LoggingService,
|
|
19
17
|
) {}
|
|
20
18
|
|
|
21
19
|
registerAction(actionName: string, actionInstance: Action) {
|
|
22
20
|
this.actions.set(actionName, actionInstance);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'WorkflowAutomationEngine',
|
|
26
|
-
'registerAction',
|
|
27
|
-
`Registered action ${actionName}`,
|
|
21
|
+
console.log(
|
|
22
|
+
`⚙️ [WorkflowAutomationEngine] Registered action: ${actionName}`,
|
|
28
23
|
);
|
|
29
24
|
}
|
|
30
25
|
|
|
@@ -39,12 +34,9 @@ export class WorkflowAutomationEngineService {
|
|
|
39
34
|
user: any,
|
|
40
35
|
preUpdateStates?: Record<number, boolean> | null,
|
|
41
36
|
) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'handleEntityEvent',
|
|
46
|
-
`Handling entity event: ${eventType} for entityType: ${entityType}`,
|
|
47
|
-
[newEntity?.id, preUpdateStates],
|
|
37
|
+
console.log(
|
|
38
|
+
`🟢 [WorkflowAutomationEngine] Handling entity event: ${eventType} for entityType: ${entityType}`,
|
|
39
|
+
{ entityId: newEntity?.id, preUpdateStates },
|
|
48
40
|
);
|
|
49
41
|
|
|
50
42
|
const workflows = await this.wfService.getActiveRules(
|
|
@@ -76,22 +68,17 @@ export class WorkflowAutomationEngineService {
|
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
// 🔍 Log Step 1 result
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'WorkflowAutomationEngine',
|
|
82
|
-
'handleEntityEvent',
|
|
83
|
-
`Step 1 - Trigger matched`,
|
|
84
|
-
[wf.id, triggerMatched],
|
|
71
|
+
console.log(
|
|
72
|
+
`🧩 [WorkflowAutomationEngine] Step 1 - Trigger matched for WF ${wf.id}: ${triggerMatched}`,
|
|
85
73
|
);
|
|
86
74
|
|
|
87
75
|
if (!triggerMatched) continue;
|
|
88
76
|
|
|
89
77
|
// Step 2️⃣ Final criteria evaluation
|
|
90
|
-
|
|
91
78
|
const entityIdToUse =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
wf.mapped_entity_type === wf.applicable_entity_type
|
|
80
|
+
? newEntity.id
|
|
81
|
+
: newEntity.parent_id;
|
|
95
82
|
|
|
96
83
|
const criteriaMatched = await this.filterEvaluator.evaluateCriteria(
|
|
97
84
|
wf.mapped_entity_type,
|
|
@@ -101,12 +88,8 @@ export class WorkflowAutomationEngineService {
|
|
|
101
88
|
);
|
|
102
89
|
|
|
103
90
|
// 🔍 Log Step 2 result
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'WorkflowAutomationEngine',
|
|
107
|
-
'handleEntityEvent',
|
|
108
|
-
`Step 2 - Criteria matched`,
|
|
109
|
-
[wf.id, criteriaMatched],
|
|
91
|
+
console.log(
|
|
92
|
+
`⚖️ [WorkflowAutomationEngine] Step 2 - Criteria matched for WF ${wf.id}: ${criteriaMatched}`,
|
|
110
93
|
);
|
|
111
94
|
|
|
112
95
|
if (!criteriaMatched) continue;
|
|
@@ -127,11 +110,8 @@ export class WorkflowAutomationEngineService {
|
|
|
127
110
|
);
|
|
128
111
|
|
|
129
112
|
if (!actions.length) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
'WorkflowAutomationEngine',
|
|
133
|
-
'executeActions',
|
|
134
|
-
`No actions found for workflow ${workflow_automation_id}`,
|
|
113
|
+
console.warn(
|
|
114
|
+
`⚠️ [WorkflowAutomationEngine] No actions found for workflow ${workflow_automation_id}`,
|
|
135
115
|
);
|
|
136
116
|
return;
|
|
137
117
|
}
|
|
@@ -145,11 +125,8 @@ export class WorkflowAutomationEngineService {
|
|
|
145
125
|
);
|
|
146
126
|
|
|
147
127
|
if (!category?.action_decorator) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'WorkflowAutomationEngine',
|
|
151
|
-
'executeActions',
|
|
152
|
-
`No action_decorator found for category_id=${action.action_category_id}`,
|
|
128
|
+
console.warn(
|
|
129
|
+
`⚠️ [WorkflowAutomationEngine] No action_decorator found for category_id=${action.action_category_id}`,
|
|
153
130
|
);
|
|
154
131
|
continue;
|
|
155
132
|
}
|
|
@@ -160,21 +137,14 @@ export class WorkflowAutomationEngineService {
|
|
|
160
137
|
const impl = this.actions.get(decorator);
|
|
161
138
|
|
|
162
139
|
if (!impl) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
'WorkflowAutomationEngine',
|
|
166
|
-
'executeActions',
|
|
167
|
-
`No implementation found for action: ${decorator}`,
|
|
140
|
+
console.warn(
|
|
141
|
+
`⚠️ [WorkflowAutomationEngine] No implementation found for action: ${decorator}`,
|
|
168
142
|
);
|
|
169
143
|
continue;
|
|
170
144
|
}
|
|
171
145
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'WorkflowAutomationEngine',
|
|
175
|
-
'executeActions',
|
|
176
|
-
`Executing action ${decorator} for entity ${entity.id}`,
|
|
177
|
-
[workflow_automation_id],
|
|
146
|
+
console.log(
|
|
147
|
+
`🚀 [WorkflowAutomationEngine] Executing action "${decorator}" for entity ${entity.id} (WF ${workflow_automation_id})`,
|
|
178
148
|
);
|
|
179
149
|
|
|
180
150
|
// 4️ Execute action with required context
|
|
@@ -184,20 +154,13 @@ export class WorkflowAutomationEngineService {
|
|
|
184
154
|
config: action.payload, // from cr_wf_action table
|
|
185
155
|
});
|
|
186
156
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
'WorkflowAutomationEngine',
|
|
190
|
-
'executeActions',
|
|
191
|
-
`Action ${decorator} executed successfully`,
|
|
192
|
-
[workflow_automation_id],
|
|
157
|
+
console.log(
|
|
158
|
+
`✅ [WorkflowAutomationEngine] Action "${decorator}" executed successfully (WF ${workflow_automation_id})`,
|
|
193
159
|
);
|
|
194
160
|
} catch (err) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
'executeActions',
|
|
199
|
-
`Error executing action (category_id=${action.action_category_id})`,
|
|
200
|
-
[err],
|
|
161
|
+
console.error(
|
|
162
|
+
`❌ [WorkflowAutomationEngine] Error executing action (category_id=${action.action_category_id}):`,
|
|
163
|
+
err,
|
|
201
164
|
);
|
|
202
165
|
}
|
|
203
166
|
}
|