rez_core 4.0.222 → 4.0.225
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/.idea/250218_nodejs_core.iml +12 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/module/entity_json/service/entity_json.service.js +5 -7
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +1 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +13 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +1 -0
- package/dist/module/linked_attributes/service/linked_attributes.service.js +48 -0
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/entity_json/service/entity_json.service.ts +21 -28
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +16 -1
- package/src/module/linked_attributes/service/linked_attributes.service.ts +68 -0
package/package.json
CHANGED
|
@@ -103,7 +103,6 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
103
103
|
'attr.id',
|
|
104
104
|
'attr.name',
|
|
105
105
|
'attr.attribute_key',
|
|
106
|
-
'fla.saved_filter_code',
|
|
107
106
|
])
|
|
108
107
|
.where('attr.organization_id = :orgId', { orgId })
|
|
109
108
|
.getRawMany();
|
|
@@ -212,33 +211,27 @@ export class EntityJSONService extends EntityServiceImpl {
|
|
|
212
211
|
}
|
|
213
212
|
|
|
214
213
|
// 5. Merge linked attributes using saved filters
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// Use attrMap if flat_json_key exists
|
|
237
|
-
const flatKey = attrMap[childAttributeKey] || childAttributeKey;
|
|
238
|
-
flatJson[flatKey] = value;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
214
|
+
for (const linkAttr of safeAttributes.linkedAttributes) {
|
|
215
|
+
if (!linkAttr.applicable_entity_type || !linkAttr.applicable_attribute_key) continue;
|
|
216
|
+
|
|
217
|
+
const mappingValue = mainData?.[linkAttr.parent_attribute_key || ''] ?? null;
|
|
218
|
+
const value = await this.applyLinkedFilterUsingSavedFilter(
|
|
219
|
+
linkAttr.applicable_entity_type,
|
|
220
|
+
linkAttr.saved_filter_code,
|
|
221
|
+
linkAttr.applicable_attribute_key,
|
|
222
|
+
mappingValue,
|
|
223
|
+
linkAttr.target_attribute_key || linkAttr.applicable_attribute_key,
|
|
224
|
+
loggedInUser,
|
|
225
|
+
entityId,
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (value !== null && value !== undefined) {
|
|
229
|
+
const flatKey = attrMap[linkAttr.target_attribute_key || linkAttr.applicable_attribute_key]
|
|
230
|
+
|| (linkAttr.target_attribute_key || linkAttr.applicable_attribute_key);
|
|
231
|
+
flatJson[flatKey] = value;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
242
235
|
// 6. Save JSON
|
|
243
236
|
await this.dataSource.query(
|
|
244
237
|
`INSERT INTO frm_entity_json (entity_type, entity_id, json_data, created_by)
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
Get,
|
|
5
|
+
Inject,
|
|
6
|
+
Post,
|
|
7
|
+
Req,
|
|
8
|
+
UseGuards,
|
|
9
|
+
} from '@nestjs/common';
|
|
2
10
|
import { LinkedAttributesService } from '../service/linked_attributes.service';
|
|
3
11
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
12
|
|
|
@@ -16,4 +24,11 @@ export class LinkedAttributesController {
|
|
|
16
24
|
|
|
17
25
|
return this.linkedAttributesService.getAllLinkedAttributes(loggedInUser);
|
|
18
26
|
}
|
|
27
|
+
|
|
28
|
+
@Post('upsert')
|
|
29
|
+
@UseGuards(JwtAuthGuard)
|
|
30
|
+
async upsertLinkedAttributes(@Req() req: any, @Body() payload: any) {
|
|
31
|
+
const loggedInUser = req.user?.userData;
|
|
32
|
+
return this.linkedAttributesService.upsert(payload, loggedInUser);
|
|
33
|
+
}
|
|
19
34
|
}
|
|
@@ -31,4 +31,72 @@ export class LinkedAttributesService extends EntityServiceImpl {
|
|
|
31
31
|
.where('fla.organization_id = :orgId', { orgId })
|
|
32
32
|
.getMany();
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
async upsert(payloadList: any[], loggedInUser: any) {
|
|
36
|
+
const orgId = loggedInUser.organization_id;
|
|
37
|
+
const output: any[] = [];
|
|
38
|
+
|
|
39
|
+
for (const payload of payloadList) {
|
|
40
|
+
payload.organization_id = orgId;
|
|
41
|
+
|
|
42
|
+
// ------------------------------------
|
|
43
|
+
// UPDATE CASE
|
|
44
|
+
// ------------------------------------
|
|
45
|
+
if (payload.id) {
|
|
46
|
+
const existing = await this.dataSource
|
|
47
|
+
.getRepository(LinkedAttributes)
|
|
48
|
+
.createQueryBuilder('la')
|
|
49
|
+
.where('la.id = :id', { id: payload.id })
|
|
50
|
+
.andWhere('la.organization_id = :orgId', { orgId })
|
|
51
|
+
.getOne();
|
|
52
|
+
|
|
53
|
+
if (!existing) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await this.dataSource
|
|
58
|
+
.createQueryBuilder()
|
|
59
|
+
.update(LinkedAttributes)
|
|
60
|
+
.set(payload)
|
|
61
|
+
.where('id = :id', { id: payload.id })
|
|
62
|
+
.andWhere('organization_id = :orgId', { orgId })
|
|
63
|
+
.execute();
|
|
64
|
+
|
|
65
|
+
// fetch updated object
|
|
66
|
+
const updated = await this.dataSource
|
|
67
|
+
.getRepository(LinkedAttributes)
|
|
68
|
+
.createQueryBuilder('la')
|
|
69
|
+
.where('la.id = :id', { id: payload.id })
|
|
70
|
+
.andWhere('la.organization_id = :orgId', { orgId })
|
|
71
|
+
.getOne();
|
|
72
|
+
|
|
73
|
+
output.push(updated);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ------------------------------------
|
|
78
|
+
// CREATE CASE
|
|
79
|
+
// ------------------------------------
|
|
80
|
+
const insertResult = await this.dataSource
|
|
81
|
+
.createQueryBuilder()
|
|
82
|
+
.insert()
|
|
83
|
+
.into(LinkedAttributes)
|
|
84
|
+
.values(payload)
|
|
85
|
+
.execute();
|
|
86
|
+
|
|
87
|
+
const newId = insertResult.identifiers[0].id;
|
|
88
|
+
|
|
89
|
+
// fetch the created object
|
|
90
|
+
const created = await this.dataSource
|
|
91
|
+
.getRepository(LinkedAttributes)
|
|
92
|
+
.createQueryBuilder('la')
|
|
93
|
+
.where('la.id = :id', { id: newId })
|
|
94
|
+
.andWhere('la.organization_id = :orgId', { orgId })
|
|
95
|
+
.getOne();
|
|
96
|
+
|
|
97
|
+
output.push(created);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return output;
|
|
101
|
+
}
|
|
34
102
|
}
|