rez_core 3.1.34 → 3.1.35
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/mapper/controller/field-mapper.controller.d.ts +2 -1
- package/dist/module/mapper/controller/field-mapper.controller.js +17 -4
- package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -1
- package/dist/module/mapper/dto/field-mapper.dto.d.ts +1 -1
- package/dist/module/mapper/entity/field-mapper.entity.d.ts +3 -3
- package/dist/module/mapper/entity/field-mapper.entity.js +5 -5
- package/dist/module/mapper/entity/field-mapper.entity.js.map +1 -1
- package/dist/module/mapper/repository/field-mapper.repository.js +1 -1
- package/dist/module/mapper/repository/field-mapper.repository.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +1 -1
- package/dist/module/mapper/service/field-mapper.service.js +3 -3
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/mapper/service/mapper.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +50 -38
- 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/mapper/controller/field-mapper.controller.ts +10 -4
- package/src/module/mapper/dto/field-mapper.dto.ts +1 -1
- package/src/module/mapper/entity/field-mapper.entity.ts +5 -5
- package/src/module/mapper/repository/field-mapper.repository.ts +1 -1
- package/src/module/mapper/service/field-mapper.service.ts +4 -4
- package/src/module/mapper/service/mapper.service.ts +1 -1
- package/src/module/workflow-automation/service/workflow-automation.service.ts +80 -58
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Controller, Inject, Post, Query, Req, UseGuards } from '@nestjs/common';
|
|
1
|
+
import { Body, Controller, Inject, Post, Query, Req, UseGuards } from '@nestjs/common';
|
|
2
2
|
import { FieldMapperService } from '../service/field-mapper.service';
|
|
3
3
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
4
4
|
|
|
@@ -10,12 +10,18 @@ export class FieldMapperController {
|
|
|
10
10
|
@Post('resolve')
|
|
11
11
|
@UseGuards(JwtAuthGuard)
|
|
12
12
|
async resolve(@Req() req: any, @Query('integration_component') integration_component: string,
|
|
13
|
-
@Query('
|
|
14
|
-
@Query('
|
|
13
|
+
@Query('entity_type') entity_type: string,
|
|
14
|
+
@Query('entity_id') entity_id: number) {
|
|
15
15
|
const loggedInUser = req.user.userData;
|
|
16
|
-
return this.fieldMapperService.resolveData(integration_component,
|
|
16
|
+
return this.fieldMapperService.resolveData(integration_component, entity_type, entity_id, loggedInUser);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
@Post('bulk')
|
|
21
|
+
@UseGuards(JwtAuthGuard)
|
|
22
|
+
async createBulk(@Req() req: any, @Body() dtos: string) {
|
|
23
|
+
const loggedInUser = req.user.userData;
|
|
24
|
+
return this.fieldMapperService.createFieldMappers(dtos);
|
|
25
|
+
}
|
|
20
26
|
|
|
21
27
|
}
|
|
@@ -9,8 +9,8 @@ export class FieldMapper extends BaseEntity {
|
|
|
9
9
|
this.entity_type = 'FMAP';
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
@Column({ name: '
|
|
13
|
-
|
|
12
|
+
@Column({ name: 'mapper_id', type: 'varchar', length: 30 })
|
|
13
|
+
mapper_id: string;
|
|
14
14
|
|
|
15
15
|
@Column({ name: 'action', type: 'varchar', length: 30 })
|
|
16
16
|
action: string;
|
|
@@ -19,10 +19,10 @@ export class FieldMapper extends BaseEntity {
|
|
|
19
19
|
source_attribute: string;
|
|
20
20
|
|
|
21
21
|
@Column({ name: 'destination_attribute', type: 'varchar', length: 30 })
|
|
22
|
-
|
|
22
|
+
attribute_key: string;
|
|
23
23
|
|
|
24
24
|
@Column({ name: 'destination_entity_type', type: 'varchar', length: 30 })
|
|
25
|
-
|
|
25
|
+
mapper_entity_type: string;
|
|
26
26
|
|
|
27
27
|
@Column({ name: 'mapped_entity_type', type: 'varchar', length: 30, nullable: true })
|
|
28
28
|
mapped_entity_type: string;
|
|
@@ -30,7 +30,7 @@ export class FieldMapper extends BaseEntity {
|
|
|
30
30
|
@Column({ name: 'filter_code', type: 'varchar', length: 30, default: 'default', nullable: true })
|
|
31
31
|
filter_code: string;
|
|
32
32
|
|
|
33
|
-
@Column({ name: 'is_lov_present', type: 'tinyint' })
|
|
33
|
+
@Column({ name: 'is_lov_present', type: 'tinyint', nullable: true, default: 0 })
|
|
34
34
|
is_lov_present: number;
|
|
35
35
|
|
|
36
36
|
}
|
|
@@ -13,7 +13,7 @@ export class FieldMapperRepository {
|
|
|
13
13
|
|
|
14
14
|
async findByIntegrationComponentAndDestinationEntityType(integrationComponent: string, destinationEntityType: string) {
|
|
15
15
|
return await this.fieldMapperRepository.find({
|
|
16
|
-
where: {
|
|
16
|
+
where: { mapper_id: integrationComponent, mapped_entity_type: destinationEntityType },
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -43,7 +43,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
43
43
|
return super.updateEntity(dto, loggedInUser);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async createFieldMappers(dtos
|
|
46
|
+
async createFieldMappers(dtos) {
|
|
47
47
|
return await this.fieldMapperRepository.saveBulk(dtos);
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -65,7 +65,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
65
65
|
for (const field of fieldMappers) {
|
|
66
66
|
const entityType = field.mapped_entity_type
|
|
67
67
|
? field.mapped_entity_type
|
|
68
|
-
: field.
|
|
68
|
+
: field.mapper_entity_type;
|
|
69
69
|
const filterCode = field.filter_code || 'default';
|
|
70
70
|
|
|
71
71
|
if (!inMemory[entityType]) {
|
|
@@ -75,7 +75,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
75
75
|
// Case 1️⃣ direct mapping (no mapped_entity_type or equal)
|
|
76
76
|
if (
|
|
77
77
|
!inMemory[entityType][filterCode] &&
|
|
78
|
-
field.mapped_entity_type == field.
|
|
78
|
+
field.mapped_entity_type == field.mapper_entity_type
|
|
79
79
|
) {
|
|
80
80
|
inMemory[entityType][filterCode] = await super.getResolvedEntityData(
|
|
81
81
|
entityType,
|
|
@@ -140,7 +140,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
140
140
|
// Fetch mapped attribute values
|
|
141
141
|
const entityData = inMemory[entityType][filterCode];
|
|
142
142
|
if (entityData) {
|
|
143
|
-
let value = entityData[field.
|
|
143
|
+
let value = entityData[field.mapper_entity_type];
|
|
144
144
|
|
|
145
145
|
if (field.is_lov_present) {
|
|
146
146
|
if (field.action === 'LOOKUP') {
|
|
@@ -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,37 +273,46 @@ 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
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
filter_code: workflowAutomation.criteria_filter_code,
|
|
302
|
+
if (workflowAutomation.trigger_type === 'on_schedule') {
|
|
303
|
+
event = {
|
|
304
|
+
triggerType: workflowAutomation.trigger_type,
|
|
305
|
+
scheduleJson: workflowAutomation.schedule, // direct from DB
|
|
291
306
|
};
|
|
292
307
|
}
|
|
293
308
|
|
|
309
|
+
// 3. CRITERIA FILTER
|
|
310
|
+
let filter: any = null;
|
|
311
|
+
|
|
312
|
+
filter = {
|
|
313
|
+
filter_code: workflowAutomation.criteria_filter_code,
|
|
314
|
+
};
|
|
315
|
+
|
|
294
316
|
// 4. ACTIONS
|
|
295
317
|
const actions = await this.dataSource
|
|
296
318
|
.getRepository(WorkflowAutomationActionEntity)
|