rez_core 3.1.30 → 3.1.32
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 +5 -2
- package/dist/core.module.js.map +1 -1
- package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -1
- package/dist/module/mapper/controller/mapper.controller.d.ts +6 -0
- package/dist/module/mapper/controller/mapper.controller.js +39 -0
- package/dist/module/mapper/controller/mapper.controller.js.map +1 -0
- package/dist/module/mapper/entity/field-mapper.entity.js +1 -1
- package/dist/module/mapper/entity/field-mapper.entity.js.map +1 -1
- package/dist/module/mapper/mapper.module.js +2 -1
- package/dist/module/mapper/mapper.module.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +5 -1
- package/dist/module/mapper/service/field-mapper.service.js +56 -8
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/mapper/service/mapper.service.d.ts +4 -0
- package/dist/module/mapper/service/mapper.service.js +23 -1
- package/dist/module/mapper/service/mapper.service.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.service.d.ts +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core.module.ts +5 -2
- package/src/module/mapper/controller/field-mapper.controller.ts +2 -0
- package/src/module/mapper/controller/mapper.controller.ts +12 -0
- package/src/module/mapper/entity/field-mapper.entity.ts +1 -1
- package/src/module/mapper/mapper.module.ts +2 -1
- package/src/module/mapper/service/field-mapper.service.ts +92 -11
- package/src/module/mapper/service/mapper.service.ts +23 -0
- package/src/module/workflow-automation/entity/workflow-automation.entity.ts +3 -0
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -15,6 +15,7 @@ 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';
|
|
18
19
|
|
|
19
20
|
@Global()
|
|
20
21
|
@Module({})
|
|
@@ -36,7 +37,8 @@ export class CoreModule {
|
|
|
36
37
|
LeadModule,
|
|
37
38
|
LayoutPreferenceModule,
|
|
38
39
|
WorkflowModule,
|
|
39
|
-
WorkflowAutomationModule
|
|
40
|
+
WorkflowAutomationModule,
|
|
41
|
+
MapperModule
|
|
40
42
|
];
|
|
41
43
|
|
|
42
44
|
const exportsArray = [
|
|
@@ -51,7 +53,8 @@ export class CoreModule {
|
|
|
51
53
|
LeadModule,
|
|
52
54
|
LayoutPreferenceModule,
|
|
53
55
|
WorkflowModule,
|
|
54
|
-
WorkflowAutomationModule
|
|
56
|
+
WorkflowAutomationModule,
|
|
57
|
+
MapperModule
|
|
55
58
|
];
|
|
56
59
|
|
|
57
60
|
if (isSso) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Controller, Get, Inject, Query } from '@nestjs/common';
|
|
2
|
+
import { MapperService } from '../service/mapper.service';
|
|
3
|
+
|
|
4
|
+
@Controller('mapper')
|
|
5
|
+
export class MapperController {
|
|
6
|
+
constructor(@Inject('MapperService') private readonly mapperService: MapperService) {}
|
|
7
|
+
|
|
8
|
+
@Get('')
|
|
9
|
+
async getByMappedEntityType(@Query('mapped_entity_type') mappedEntityType: string) {
|
|
10
|
+
return this.mapperService.getByMappedEntityType(mappedEntityType);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -27,7 +27,7 @@ export class FieldMapper extends BaseEntity {
|
|
|
27
27
|
@Column({ name: 'mapped_entity_type', type: 'varchar', length: 30, nullable: true })
|
|
28
28
|
mapped_entity_type: string;
|
|
29
29
|
|
|
30
|
-
@Column({ name: 'filter_code', type: 'varchar', length: 30, default: 'default' })
|
|
30
|
+
@Column({ name: 'filter_code', type: 'varchar', length: 30, default: 'default', nullable: true })
|
|
31
31
|
filter_code: string;
|
|
32
32
|
|
|
33
33
|
@Column({ name: 'is_lov_present', type: 'tinyint' })
|
|
@@ -10,6 +10,7 @@ import { FieldLovMapper } from './entity/field-lovs.entity';
|
|
|
10
10
|
import { FieldLovsRepository } from './repository/field-lovs.repository';
|
|
11
11
|
import { MapperService } from './service/mapper.service';
|
|
12
12
|
import { Mapper } from './entity/mapper.entity';
|
|
13
|
+
import { MapperController } from './controller/mapper.controller';
|
|
13
14
|
|
|
14
15
|
@Module({
|
|
15
16
|
imports: [
|
|
@@ -23,7 +24,7 @@ import { Mapper } from './entity/mapper.entity';
|
|
|
23
24
|
FieldMapperRepository,
|
|
24
25
|
FieldLovsRepository,
|
|
25
26
|
],
|
|
26
|
-
controllers: [FieldMapperController],
|
|
27
|
+
controllers: [FieldMapperController,MapperController],
|
|
27
28
|
})
|
|
28
29
|
export class MapperModule {
|
|
29
30
|
}
|
|
@@ -5,20 +5,28 @@ import { EntityServiceImpl } from '../../meta/service/entity-service-impl.servic
|
|
|
5
5
|
import { UserData } from '../../user/entity/user.entity';
|
|
6
6
|
import { SavedFilterService } from '../../filter/service/saved-filter.service';
|
|
7
7
|
import { FieldLovsRepository } from '../repository/field-lovs.repository';
|
|
8
|
+
import { DataSource } from 'typeorm';
|
|
9
|
+
import { FilterService } from 'src/module/filter/service/filter.service';
|
|
8
10
|
|
|
9
11
|
@Injectable()
|
|
10
12
|
export class FieldMapperService extends EntityServiceImpl {
|
|
11
13
|
constructor(
|
|
12
14
|
private readonly fieldMapperRepository: FieldMapperRepository,
|
|
13
|
-
@Inject('SavedFilterService')
|
|
15
|
+
@Inject('SavedFilterService')
|
|
16
|
+
private readonly savedFilterService: SavedFilterService,
|
|
14
17
|
private readonly fieldLovsRepository: FieldLovsRepository,
|
|
18
|
+
private readonly datasource: DataSource,
|
|
19
|
+
private readonly filterService: FilterService,
|
|
15
20
|
) {
|
|
16
21
|
super();
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
async createEntity(dto: FieldMapperDto, loggedInUser: UserData) {
|
|
20
25
|
if (dto.filter_json) {
|
|
21
|
-
const savedFilter = await this.savedFilterService.createEntity(
|
|
26
|
+
const savedFilter = await this.savedFilterService.createEntity(
|
|
27
|
+
dto.filter_json,
|
|
28
|
+
loggedInUser,
|
|
29
|
+
);
|
|
22
30
|
dto.filter_code = savedFilter.code;
|
|
23
31
|
}
|
|
24
32
|
return super.createEntity(dto, loggedInUser);
|
|
@@ -26,7 +34,10 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
26
34
|
|
|
27
35
|
async updateEntity(dto: FieldMapperDto, loggedInUser: UserData) {
|
|
28
36
|
if (dto.filter_json) {
|
|
29
|
-
const savedFilter = await this.savedFilterService.createEntity(
|
|
37
|
+
const savedFilter = await this.savedFilterService.createEntity(
|
|
38
|
+
dto.filter_json,
|
|
39
|
+
loggedInUser,
|
|
40
|
+
);
|
|
30
41
|
dto.filter_code = savedFilter.code;
|
|
31
42
|
}
|
|
32
43
|
return super.updateEntity(dto, loggedInUser);
|
|
@@ -47,37 +58,106 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
47
58
|
integration_component,
|
|
48
59
|
parent_type,
|
|
49
60
|
);
|
|
50
|
-
const result: Record<string, any> = {};
|
|
51
61
|
|
|
62
|
+
const result: Record<string, any> = {};
|
|
52
63
|
const inMemory: Record<string, Record<string, any>> = {};
|
|
53
64
|
|
|
54
65
|
for (const field of fieldMappers) {
|
|
55
|
-
const entityType = field.mapped_entity_type
|
|
66
|
+
const entityType = field.mapped_entity_type
|
|
67
|
+
? field.mapped_entity_type
|
|
68
|
+
: field.destination_entity_type;
|
|
56
69
|
const filterCode = field.filter_code || 'default';
|
|
70
|
+
|
|
57
71
|
if (!inMemory[entityType]) {
|
|
58
72
|
inMemory[entityType] = {};
|
|
59
73
|
}
|
|
60
|
-
|
|
74
|
+
|
|
75
|
+
// Case 1️⃣ direct mapping (no mapped_entity_type or equal)
|
|
76
|
+
if (
|
|
77
|
+
!inMemory[entityType][filterCode] &&
|
|
78
|
+
field.mapped_entity_type == field.destination_entity_type
|
|
79
|
+
) {
|
|
61
80
|
inMemory[entityType][filterCode] = await super.getResolvedEntityData(
|
|
62
81
|
entityType,
|
|
63
82
|
parent_id,
|
|
64
83
|
userData,
|
|
65
84
|
);
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
85
|
+
|
|
86
|
+
// Case 2️⃣ mapped_entity_type
|
|
87
|
+
} else if (
|
|
88
|
+
field.mapped_entity_type &&
|
|
89
|
+
!inMemory[entityType][filterCode]
|
|
90
|
+
) {
|
|
91
|
+
// Step 1: get related target entity ids
|
|
92
|
+
const relations = await this.datasource.query(
|
|
93
|
+
`SELECT target_entity_id
|
|
94
|
+
FROM cr_entity_relation_data
|
|
95
|
+
WHERE source_entity_type = ?
|
|
96
|
+
AND source_entity_id = ?
|
|
97
|
+
AND target_entity_type = ?
|
|
98
|
+
AND organization_id = ?`,
|
|
99
|
+
[
|
|
100
|
+
parent_type,
|
|
101
|
+
parent_id,
|
|
102
|
+
field.mapped_entity_type,
|
|
103
|
+
userData.organization_id,
|
|
104
|
+
],
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const targetEntityIds = relations.map((r) => r.target_entity_id);
|
|
108
|
+
|
|
109
|
+
if (targetEntityIds.length > 0) {
|
|
110
|
+
if (filterCode && filterCode !== 'default') {
|
|
111
|
+
// Step 2a: filtered fetch with IN clause using applyFilterWrapper
|
|
112
|
+
inMemory[entityType][filterCode] = inMemory[entityType][
|
|
113
|
+
filterCode
|
|
114
|
+
] = await this.filterService.applyFilterWrapper({
|
|
115
|
+
entity_type: entityType,
|
|
116
|
+
savedFilterCode: filterCode,
|
|
117
|
+
quickFilter: [
|
|
118
|
+
{
|
|
119
|
+
filter_attribute: 'id',
|
|
120
|
+
filter_operator: 'equal',
|
|
121
|
+
filter_value: targetEntityIds,
|
|
122
|
+
filter_entity_type: entityType,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
attributeFilter: [],
|
|
126
|
+
loggedInUser: userData,
|
|
127
|
+
queryParams: {},
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
// Step 2b: no filter → just pick first related entity
|
|
131
|
+
const firstId = targetEntityIds[0];
|
|
132
|
+
inMemory[entityType][filterCode] =
|
|
133
|
+
await super.getResolvedEntityData(entityType, firstId, userData);
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
inMemory[entityType][filterCode] = null;
|
|
137
|
+
}
|
|
69
138
|
}
|
|
139
|
+
|
|
140
|
+
// Fetch mapped attribute values
|
|
70
141
|
const entityData = inMemory[entityType][filterCode];
|
|
71
142
|
if (entityData) {
|
|
72
143
|
let value = entityData[field.destination_attribute];
|
|
144
|
+
|
|
73
145
|
if (field.is_lov_present) {
|
|
74
146
|
if (field.action === 'LOOKUP') {
|
|
75
|
-
|
|
147
|
+
const fieldLovMapper =
|
|
148
|
+
await this.fieldLovsRepository.findByMapperFieldIdAndDestinationAttributeValue(
|
|
149
|
+
field.id,
|
|
150
|
+
value,
|
|
151
|
+
);
|
|
76
152
|
if (fieldLovMapper) {
|
|
77
153
|
value = fieldLovMapper.source_attribute_value;
|
|
78
154
|
}
|
|
79
155
|
} else {
|
|
80
|
-
|
|
156
|
+
const fieldLovMapper =
|
|
157
|
+
await this.fieldLovsRepository.findByMapperFieldIdAndSourceAttributeValue(
|
|
158
|
+
field.id,
|
|
159
|
+
value,
|
|
160
|
+
);
|
|
81
161
|
if (fieldLovMapper) {
|
|
82
162
|
value = fieldLovMapper.destination_attribute_value;
|
|
83
163
|
}
|
|
@@ -86,6 +166,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
86
166
|
result[field.source_attribute] = value;
|
|
87
167
|
}
|
|
88
168
|
}
|
|
169
|
+
|
|
89
170
|
return result;
|
|
90
171
|
}
|
|
91
172
|
}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
2
|
import { EntityServiceImpl } from "src/module/meta/service/entity-service-impl.service";
|
|
3
|
+
import { DataSource } from "typeorm";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class MapperService extends EntityServiceImpl{
|
|
7
8
|
|
|
9
|
+
constructor(private readonly dataSource: DataSource) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getByMappedEntityType(mappedEntityType: string) {
|
|
14
|
+
if (!mappedEntityType) return [];
|
|
15
|
+
|
|
16
|
+
const mappers = await this.dataSource.query(
|
|
17
|
+
`SELECT id, name, code
|
|
18
|
+
FROM cr_mapper
|
|
19
|
+
WHERE mapped_entity_type = ?`,
|
|
20
|
+
[mappedEntityType],
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return mappers.map((m) => ({
|
|
24
|
+
id: m.id,
|
|
25
|
+
name: m.name,
|
|
26
|
+
value: m.id,
|
|
27
|
+
code: m.code,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
8
31
|
}
|