rez_core 3.1.33 → 3.1.36
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/core.module.js +2 -5
- package/dist/core.module.js.map +1 -1
- package/dist/module/filter/repository/saved-filter.repository.js +1 -1
- package/dist/module/mapper/service/mapper.service.js +1 -1
- package/dist/module/mapper/service/mapper.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +48 -34
- 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/core.module.ts +2 -5
- package/src/module/filter/repository/saved-filter.repository.ts +1 -1
- package/src/module/mapper/service/mapper.service.ts +1 -1
- package/src/module/workflow-automation/service/workflow-automation.service.ts +76 -53
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { LeadModule } from './module/lead/lead.module';
|
|
|
15
15
|
import { LayoutPreferenceModule } from './module/layout_preference/layout_preference.module';
|
|
16
16
|
import { WorkflowModule } from './module/workflow/workflow.module';
|
|
17
17
|
import { WorkflowAutomationModule } from './module/workflow-automation/workflow-automation.module';
|
|
18
|
-
import { MapperModule } from './module/mapper/mapper.module';
|
|
19
18
|
|
|
20
19
|
@Global()
|
|
21
20
|
@Module({})
|
|
@@ -37,8 +36,7 @@ export class CoreModule {
|
|
|
37
36
|
LeadModule,
|
|
38
37
|
LayoutPreferenceModule,
|
|
39
38
|
WorkflowModule,
|
|
40
|
-
WorkflowAutomationModule
|
|
41
|
-
MapperModule
|
|
39
|
+
WorkflowAutomationModule
|
|
42
40
|
];
|
|
43
41
|
|
|
44
42
|
const exportsArray = [
|
|
@@ -53,8 +51,7 @@ export class CoreModule {
|
|
|
53
51
|
LeadModule,
|
|
54
52
|
LayoutPreferenceModule,
|
|
55
53
|
WorkflowModule,
|
|
56
|
-
WorkflowAutomationModule
|
|
57
|
-
MapperModule
|
|
54
|
+
WorkflowAutomationModule
|
|
58
55
|
];
|
|
59
56
|
|
|
60
57
|
if (isSso) {
|
|
@@ -39,7 +39,7 @@ export class SavedFilterRepositoryService {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async getDetailsByCode(code: string) {
|
|
42
|
-
console.log(
|
|
42
|
+
console.log('IN GET DETAILS BY CODE', code);
|
|
43
43
|
let data = await this.savedFilterDetailRepo.find({
|
|
44
44
|
where: { mapped_filter_code: code },
|
|
45
45
|
});
|
|
@@ -79,54 +79,67 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
79
79
|
this.logger.debug(`Workflow updated (id=${workflow.id})`);
|
|
80
80
|
|
|
81
81
|
// 2. EVENT FILTER
|
|
82
|
-
if (event?.
|
|
82
|
+
if (event?.triggerType) {
|
|
83
83
|
this.logger.log(`Processing EVENT filter for workflow ${workflow.id}`);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (workflow.condition_filter_code) {
|
|
95
|
-
this.logger.debug(
|
|
96
|
-
`Existing event filter found: ${workflow.condition_filter_code}`,
|
|
97
|
-
);
|
|
98
|
-
const existing = await this.savedFilterService.getEntityDataByCode(
|
|
99
|
-
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
100
|
-
workflow.condition_filter_code,
|
|
101
|
-
loggedInUser,
|
|
102
|
-
);
|
|
85
|
+
if (event.triggerType === 'on_event') {
|
|
86
|
+
const eventFilterMaster = {
|
|
87
|
+
entity_type: 'SFM',
|
|
88
|
+
name: `Event_Filter_${workflow.id}`,
|
|
89
|
+
filterDetails: event?.eventFilterJson ?? [],
|
|
90
|
+
filter_scope: 'RULE',
|
|
91
|
+
organization_id: loggedInUser.organization_id,
|
|
92
|
+
enterprise_id: loggedInUser.enterprise_id,
|
|
93
|
+
};
|
|
103
94
|
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
if (workflow.condition_filter_code) {
|
|
96
|
+
this.logger.debug(
|
|
97
|
+
`Existing event filter found: ${workflow.condition_filter_code}`,
|
|
98
|
+
);
|
|
99
|
+
const existing = await this.savedFilterService.getEntityDataByCode(
|
|
100
|
+
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
101
|
+
workflow.condition_filter_code,
|
|
108
102
|
loggedInUser,
|
|
109
103
|
);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
|
|
105
|
+
if (existing) {
|
|
106
|
+
eventFilterMaster['id'] = existing.id;
|
|
107
|
+
const updatedEvent = await this.savedFilterService.updateEntity(
|
|
108
|
+
eventFilterMaster as any,
|
|
109
|
+
loggedInUser,
|
|
110
|
+
);
|
|
111
|
+
workflow.condition_filter_code = updatedEvent.code;
|
|
112
|
+
this.logger.log(
|
|
113
|
+
`Updated existing event filter: ${updatedEvent.code}`,
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
const savedEvent = await this.savedFilterService.createEntity(
|
|
118
|
+
eventFilterMaster,
|
|
119
|
+
loggedInUser,
|
|
113
120
|
);
|
|
121
|
+
workflow.condition_filter_code = savedEvent.code;
|
|
122
|
+
this.logger.log(`Created new event filter: ${savedEvent.code}`);
|
|
114
123
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
|
|
125
|
+
workflow.trigger_event = event?.event ?? null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (event.triggerType === 'on_schedule') {
|
|
129
|
+
// just store JSON directly into schedule column
|
|
130
|
+
workflow.schedule = event?.scheduleJson ?? null;
|
|
131
|
+
this.logger.log(
|
|
132
|
+
`Stored schedule JSON for workflow ${workflow.id}: ${JSON.stringify(
|
|
133
|
+
workflow.schedule,
|
|
134
|
+
)}`,
|
|
119
135
|
);
|
|
120
|
-
workflow.condition_filter_code = savedEvent.code;
|
|
121
|
-
this.logger.log(`Created new event filter: ${savedEvent.code}`);
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
workflow.trigger_type = event
|
|
125
|
-
workflow.trigger_event = event?.event ?? null;
|
|
138
|
+
workflow.trigger_type = event.triggerType;
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
// 3. CRITERIA FILTER
|
|
129
|
-
if (filter
|
|
142
|
+
if (filter) {
|
|
130
143
|
this.logger.log(`Processing CRITERIA filter for workflow ${workflow.id}`);
|
|
131
144
|
|
|
132
145
|
// const criteriaFilterMaster = {
|
|
@@ -168,7 +181,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
168
181
|
// this.logger.log(`Created new criteria filter: ${savedCriteria.code}`);
|
|
169
182
|
// }
|
|
170
183
|
|
|
171
|
-
workflow.criteria_filter_code =
|
|
184
|
+
workflow.criteria_filter_code = filter.filter_code ?? null;
|
|
172
185
|
}
|
|
173
186
|
|
|
174
187
|
// 4. ACTIONS
|
|
@@ -260,29 +273,39 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
260
273
|
|
|
261
274
|
// 2. EVENT FILTER
|
|
262
275
|
let event: any = null;
|
|
263
|
-
if (workflowAutomation.condition_filter_code) {
|
|
264
|
-
const eventFilterMaster: any =
|
|
265
|
-
await this.savedFilterService.getEntityDataByCode(
|
|
266
|
-
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
267
|
-
workflowAutomation.condition_filter_code,
|
|
268
|
-
loggedInUser,
|
|
269
|
-
);
|
|
270
276
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
await this.savedFilterService.
|
|
275
|
-
|
|
277
|
+
if (workflowAutomation.trigger_type === 'on_event') {
|
|
278
|
+
if (workflowAutomation.condition_filter_code) {
|
|
279
|
+
const eventFilterMaster: any =
|
|
280
|
+
await this.savedFilterService.getEntityDataByCode(
|
|
281
|
+
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
282
|
+
workflowAutomation.condition_filter_code,
|
|
283
|
+
loggedInUser,
|
|
276
284
|
);
|
|
277
285
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
if (eventFilterMaster) {
|
|
287
|
+
// 🔑 fetch filter details using mapped_filter_code
|
|
288
|
+
const eventFilterDetails =
|
|
289
|
+
await this.savedFilterService.getDetailsByCode(
|
|
290
|
+
eventFilterMaster.code,
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
event = {
|
|
294
|
+
eventFilterJson: eventFilterDetails ?? [],
|
|
295
|
+
triggerType: workflowAutomation.trigger_type,
|
|
296
|
+
event: workflowAutomation.trigger_event,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
283
299
|
}
|
|
284
300
|
}
|
|
285
301
|
|
|
302
|
+
if (workflowAutomation.trigger_type === 'on_schedule') {
|
|
303
|
+
event = {
|
|
304
|
+
triggerType: workflowAutomation.trigger_type,
|
|
305
|
+
scheduleJson: workflowAutomation.schedule, // direct from DB
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
286
309
|
// 3. CRITERIA FILTER
|
|
287
310
|
let filter: any = null;
|
|
288
311
|
if (workflowAutomation.criteria_filter_code) {
|