rez_core 3.1.56 → 3.1.58
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 +1 -0
- package/dist/module/mapper/controller/field-mapper.controller.js +10 -0
- package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -1
- package/dist/module/mapper/dto/field-mapper.dto.d.ts +3 -4
- package/dist/module/mapper/dto/field-mapper.dto.js.map +1 -1
- package/dist/module/mapper/repository/field-lovs.repository.d.ts +1 -0
- package/dist/module/mapper/repository/field-lovs.repository.js +5 -0
- package/dist/module/mapper/repository/field-lovs.repository.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +2 -3
- package/dist/module/mapper/service/field-mapper.service.js +11 -14
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/workflow/entity/action-category.entity.d.ts +1 -0
- package/dist/module/workflow/entity/action-category.entity.js +4 -0
- package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.d.ts +1 -2
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js +1 -5
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation.entity.d.ts +1 -0
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js +4 -0
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +3 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +31 -8
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +2 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +3 -1
- 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 +5 -0
- package/src/module/mapper/dto/field-mapper.dto.ts +3 -4
- package/src/module/mapper/repository/field-lovs.repository.ts +6 -0
- package/src/module/mapper/service/field-mapper.service.ts +13 -13
- package/src/module/workflow/entity/action-category.entity.ts +3 -0
- package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +1 -4
- package/src/module/workflow-automation/entity/workflow-automation.entity.ts +3 -0
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +46 -11
- package/src/module/workflow-automation/service/workflow-automation.service.ts +3 -0
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -48,4 +48,9 @@ export class FieldMapperController {
|
|
|
48
48
|
async getFieldsByMapper(@Param('mapperId') mapperId: number) {
|
|
49
49
|
return this.fieldMapperService.getMapperFields(mapperId);
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
@Get('getLovs/:mapperFieldId')
|
|
53
|
+
async getLovsByMapperField(@Param('mapperFieldId') mapperFieldId: number) {
|
|
54
|
+
return this.fieldMapperService.getFieldLovs(mapperFieldId);
|
|
55
|
+
}
|
|
51
56
|
}
|
|
@@ -2,14 +2,13 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
|
2
2
|
import { FieldLovMapper } from '../entity/field-lovs.entity';
|
|
3
3
|
|
|
4
4
|
export class FieldMapperDto extends BaseEntity {
|
|
5
|
-
mapper_id: string;
|
|
6
5
|
action: string;
|
|
6
|
+
mapper_id: number;
|
|
7
7
|
source_attribute: string;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
attribute_key: string;
|
|
9
|
+
mapper_entity_type: string;
|
|
10
10
|
mapped_entity_type: string;
|
|
11
11
|
filter_code?: string;
|
|
12
|
-
filter_json?: any;
|
|
13
12
|
field_lovs?: FieldLovMapper[];
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -23,4 +23,10 @@ export class FieldLovsRepository {
|
|
|
23
23
|
where: { mapper_field_id, destination_attribute_value },
|
|
24
24
|
})
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
async findByMapperFieldId(mapper_field_id: number) {
|
|
28
|
+
return await this.fieldLovMapperRepository.find({
|
|
29
|
+
where: { mapper_field_id },
|
|
30
|
+
})
|
|
31
|
+
}
|
|
26
32
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { FieldMapperRepository } from '../repository/field-mapper.repository';
|
|
3
3
|
import { FieldMapperDto } from '../dto/field-mapper.dto';
|
|
4
4
|
import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
|
|
5
5
|
import { UserData } from '../../user/entity/user.entity';
|
|
6
|
-
import { SavedFilterService } from '../../filter/service/saved-filter.service';
|
|
7
6
|
import { FieldLovsRepository } from '../repository/field-lovs.repository';
|
|
8
7
|
import { DataSource } from 'typeorm';
|
|
9
8
|
import { FilterService } from 'src/module/filter/service/filter.service';
|
|
@@ -13,8 +12,6 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
|
13
12
|
export class FieldMapperService extends EntityServiceImpl {
|
|
14
13
|
constructor(
|
|
15
14
|
private readonly fieldMapperRepository: FieldMapperRepository,
|
|
16
|
-
@Inject('SavedFilterService')
|
|
17
|
-
private readonly savedFilterService: SavedFilterService,
|
|
18
15
|
private readonly fieldLovsRepository: FieldLovsRepository,
|
|
19
16
|
private readonly datasource: DataSource,
|
|
20
17
|
private readonly filterService: FilterService,
|
|
@@ -23,20 +20,19 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
async createEntity(dto: FieldMapperDto, loggedInUser: UserData) {
|
|
23
|
+
let savedEntity = await super.createEntity(dto, loggedInUser);
|
|
24
|
+
|
|
26
25
|
if (dto.field_lovs) {
|
|
26
|
+
for (const lov of dto.field_lovs) {
|
|
27
|
+
lov.mapper_field_id = savedEntity.id;
|
|
28
|
+
lov.entity_type = 'FLOV';
|
|
29
|
+
}
|
|
27
30
|
await this.fieldLovsRepository.saveBulk(dto.field_lovs);
|
|
28
31
|
}
|
|
29
|
-
return
|
|
32
|
+
return savedEntity;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
async updateEntity(dto: FieldMapperDto, loggedInUser: UserData) {
|
|
33
|
-
if (dto.filter_json) {
|
|
34
|
-
const savedFilter = await this.savedFilterService.createEntity(
|
|
35
|
-
dto.filter_json,
|
|
36
|
-
loggedInUser,
|
|
37
|
-
);
|
|
38
|
-
dto.filter_code = savedFilter.code;
|
|
39
|
-
}
|
|
40
36
|
return super.updateEntity(dto, loggedInUser);
|
|
41
37
|
}
|
|
42
38
|
|
|
@@ -62,6 +58,10 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
62
58
|
return await this.fieldMapperRepository.findByMapperId(mapperId);
|
|
63
59
|
}
|
|
64
60
|
|
|
61
|
+
async getFieldLovs(mapperFieldId: number) {
|
|
62
|
+
return await this.fieldLovsRepository.findByMapperFieldId(mapperFieldId);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
65
|
async resolveData(
|
|
66
66
|
mapper_id: number,
|
|
67
67
|
parent_type: string,
|
|
@@ -88,7 +88,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
88
88
|
|
|
89
89
|
// Case 1️⃣ direct mapping (no mapped_entity_type or equal)
|
|
90
90
|
if (
|
|
91
|
-
!inMemory[entityType][filterCode]
|
|
91
|
+
!inMemory[entityType][filterCode] ||
|
|
92
92
|
field.mapped_entity_type == field.mapper_entity_type
|
|
93
93
|
) {
|
|
94
94
|
inMemory[entityType][filterCode] = await super.getResolvedEntityData(
|
|
@@ -16,10 +16,7 @@ export class WorkflowAutomationActionEntity extends BaseEntity {
|
|
|
16
16
|
action_category_id: number;
|
|
17
17
|
|
|
18
18
|
@Column({ type: 'json', nullable: true })
|
|
19
|
-
payload:
|
|
20
|
-
|
|
21
|
-
@Column({ type: 'varchar', nullable: true })
|
|
22
|
-
action_decorator: string;
|
|
19
|
+
payload: string;
|
|
23
20
|
|
|
24
21
|
@Column({ type: 'varchar', nullable: true })
|
|
25
22
|
entity_method: string;
|
|
@@ -27,6 +27,9 @@ export class WorkflowAutomation extends BaseEntity {
|
|
|
27
27
|
@Column({ type: 'varchar', nullable: true })
|
|
28
28
|
trigger_type: string;
|
|
29
29
|
|
|
30
|
+
@Column({ type: 'varchar', nullable: true })
|
|
31
|
+
applicable_entity_type: string;
|
|
32
|
+
|
|
30
33
|
@Column({ type: 'json', nullable: true })
|
|
31
34
|
schedule: string;
|
|
32
35
|
}
|
|
@@ -3,6 +3,7 @@ import { Injectable, Inject } from '@nestjs/common';
|
|
|
3
3
|
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
|
+
import { DataSource } from 'typeorm';
|
|
6
7
|
|
|
7
8
|
@Injectable()
|
|
8
9
|
export class WorkflowAutomationEngineService {
|
|
@@ -12,6 +13,7 @@ export class WorkflowAutomationEngineService {
|
|
|
12
13
|
@Inject('WorkflowAutomationService')
|
|
13
14
|
private readonly wfService: WorkflowAutomationService,
|
|
14
15
|
private readonly filterEvaluator: FilterEvaluatorService,
|
|
16
|
+
private readonly dataSource: DataSource,
|
|
15
17
|
) {}
|
|
16
18
|
|
|
17
19
|
registerAction(actionName: string, actionInstance: Action) {
|
|
@@ -90,24 +92,57 @@ export class WorkflowAutomationEngineService {
|
|
|
90
92
|
entity: any,
|
|
91
93
|
user: any,
|
|
92
94
|
) {
|
|
93
|
-
//
|
|
95
|
+
// 1️ Get actions from workflow automation
|
|
94
96
|
const actions = await this.wfService.getActionsForRule(
|
|
95
97
|
workflow_automation_id,
|
|
96
98
|
);
|
|
97
99
|
|
|
100
|
+
if (!actions.length) {
|
|
101
|
+
console.log(`No actions found for workflow ${workflow_automation_id}`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
98
105
|
for (const action of actions) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
try {
|
|
107
|
+
// 2 Resolve action_decorator using action_category_id
|
|
108
|
+
const [category] = await this.dataSource.query(
|
|
109
|
+
`SELECT action_decorator FROM cr_wf_action_category WHERE id = ?`,
|
|
110
|
+
[action.action_category_id],
|
|
103
111
|
);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
112
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
if (!category?.action_decorator) {
|
|
114
|
+
console.warn(
|
|
115
|
+
`No action_decorator found for category_id=${action.action_category_id}`,
|
|
116
|
+
);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const decorator = String(category.action_decorator);
|
|
121
|
+
|
|
122
|
+
// 3️ Get implementation from the registered action map
|
|
123
|
+
const impl = this.actions.get(decorator);
|
|
124
|
+
|
|
125
|
+
if (!impl) {
|
|
126
|
+
console.warn(` No implementation found for action: ${decorator}`);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
console.log(`Executing action ${decorator} for entity ${entity.id}`);
|
|
131
|
+
|
|
132
|
+
// 4️ Execute action with required context
|
|
133
|
+
await impl.execute({
|
|
134
|
+
entity,
|
|
135
|
+
user,
|
|
136
|
+
config: action.payload, // from cr_wf_action table
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log(`Action ${decorator} executed successfully`);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.error(
|
|
142
|
+
`Error executing action (category_id=${action.action_category_id}):`,
|
|
143
|
+
err,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
111
146
|
}
|
|
112
147
|
}
|
|
113
148
|
}
|
|
@@ -7,6 +7,7 @@ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.s
|
|
|
7
7
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
8
8
|
import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
|
|
9
9
|
import { ENTITYTYPE_SAVEDFILTERMASTER } from 'src/constant/global.constant';
|
|
10
|
+
import { app } from 'firebase-admin';
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
12
13
|
export class WorkflowAutomationService extends EntityServiceImpl {
|
|
@@ -90,6 +91,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
90
91
|
filter_scope: 'RULE',
|
|
91
92
|
organization_id: loggedInUser.organization_id,
|
|
92
93
|
enterprise_id: loggedInUser.enterprise_id,
|
|
94
|
+
applicable_entity_type: workflow.applicable_entity_type,
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
if (workflow.condition_filter_code) {
|
|
@@ -128,6 +130,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
128
130
|
if (event.triggerType === 'on_schedule') {
|
|
129
131
|
// just store JSON directly into schedule column
|
|
130
132
|
workflow.schedule = event?.scheduleJson ?? null;
|
|
133
|
+
workflow.applicable_entity_type= workflow.applicable_entity_type,
|
|
131
134
|
this.logger.log(
|
|
132
135
|
`Stored schedule JSON for workflow ${workflow.id}: ${JSON.stringify(
|
|
133
136
|
workflow.schedule,
|