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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "3.1.33",
3
+ "version": "3.1.36",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -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("IN GET DETAILS BY CODE", code);
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
  });
@@ -22,7 +22,7 @@ export class MapperService extends EntityServiceImpl{
22
22
 
23
23
  return mappers.map((m) => ({
24
24
  id: m.id,
25
- name: m.name,
25
+ label: m.name,
26
26
  value: m.id,
27
27
  code: m.code,
28
28
  }));
@@ -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?.eventFilterJson || event?.triggerType || event?.event) {
82
+ if (event?.triggerType) {
83
83
  this.logger.log(`Processing EVENT filter for workflow ${workflow.id}`);
84
84
 
85
- const eventFilterMaster = {
86
- entity_type: 'SFM',
87
- name: `Event_Filter_${workflow.id}`,
88
- filterDetails: event?.eventFilterJson ?? [],
89
- filter_scope: 'RULE',
90
- organization_id: loggedInUser.organization_id,
91
- enterprise_id: loggedInUser.enterprise_id,
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 (existing) {
105
- eventFilterMaster['id'] = existing.id;
106
- const updatedEvent = await this.savedFilterService.updateEntity(
107
- eventFilterMaster as any,
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
- workflow.condition_filter_code = updatedEvent.code;
111
- this.logger.log(
112
- `Updated existing event filter: ${updatedEvent.code}`,
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
- } else {
116
- const savedEvent = await this.savedFilterService.createEntity(
117
- eventFilterMaster,
118
- loggedInUser,
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?.triggerType ?? null;
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?.filter_code) {
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 = entityData.filter.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
- if (eventFilterMaster) {
272
- // 🔑 fetch filter details using mapped_filter_code
273
- const eventFilterDetails =
274
- await this.savedFilterService.getDetailsByCode(
275
- eventFilterMaster.code,
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
- event = {
279
- eventFilterJson: eventFilterDetails ?? [],
280
- triggerType: workflowAutomation.trigger_type,
281
- event: workflowAutomation.trigger_event,
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) {