rez_core 4.0.293 → 4.0.295
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/entity_json.module.js +6 -1
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +1 -1
- 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 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.js +28 -46
- 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/entity_json.module.ts +7 -2
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +4 -1
- package/src/module/linked_attributes/service/linked_attributes.service.ts +37 -64
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -9,9 +9,14 @@ import { EntityJson } from './entity/entityJson.entity';
|
|
|
9
9
|
import { EntityJSONRepository } from './service/entityJson.repository';
|
|
10
10
|
|
|
11
11
|
@Module({
|
|
12
|
-
imports: [
|
|
12
|
+
imports: [
|
|
13
|
+
EntityModule,
|
|
14
|
+
TypeOrmModule.forFeature([EntityJson]),
|
|
15
|
+
FilterModule,
|
|
16
|
+
UtilsModule,
|
|
17
|
+
],
|
|
13
18
|
controllers: [EntityJSONController],
|
|
14
|
-
providers: [EntityJSONService,EntityJSONRepository],
|
|
19
|
+
providers: [EntityJSONService, EntityJSONRepository],
|
|
15
20
|
exports: [],
|
|
16
21
|
})
|
|
17
22
|
export class EntityJSONModule {}
|
|
@@ -29,6 +29,9 @@ export class LinkedAttributesController {
|
|
|
29
29
|
@UseGuards(JwtAuthGuard)
|
|
30
30
|
async upsertLinkedAttributes(@Req() req: any, @Body() payload: any) {
|
|
31
31
|
const loggedInUser = req.user?.userData;
|
|
32
|
-
return this.linkedAttributesService.
|
|
32
|
+
return this.linkedAttributesService.upsertLinkedAttributes(
|
|
33
|
+
payload,
|
|
34
|
+
loggedInUser,
|
|
35
|
+
);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -15,7 +15,7 @@ export class LinkedAttributesService extends EntityServiceImpl {
|
|
|
15
15
|
payload.attribute_key = payload.field_name
|
|
16
16
|
.trim()
|
|
17
17
|
.toLowerCase()
|
|
18
|
-
.replace(/\s+/g, '_');
|
|
18
|
+
.replace(/\s+/g, '_');
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Pass to base class create method
|
|
@@ -32,71 +32,44 @@ export class LinkedAttributesService extends EntityServiceImpl {
|
|
|
32
32
|
.getMany();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async
|
|
35
|
+
async upsertLinkedAttributes(payloadList: any[], loggedInUser: any) {
|
|
36
36
|
const orgId = loggedInUser.organization_id;
|
|
37
|
-
const output: any[] = [];
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
}
|
|
38
|
+
// Step 1: Delete all existing rows for this organization
|
|
39
|
+
await this.dataSource
|
|
40
|
+
.createQueryBuilder()
|
|
41
|
+
.delete()
|
|
42
|
+
.from(LinkedAttributes)
|
|
43
|
+
.where('organization_id = :orgId', { orgId })
|
|
44
|
+
.execute();
|
|
45
|
+
|
|
46
|
+
// Step 2: Normalize & prepare payloads
|
|
47
|
+
const newPayloads = payloadList.map((item) => ({
|
|
48
|
+
...item,
|
|
49
|
+
organization_id: orgId,
|
|
50
|
+
attribute_key: item.attribute_key
|
|
51
|
+
? item.attribute_key.trim().toLowerCase().replace(/\s+/g, '_')
|
|
52
|
+
: item.field_name.trim().toLowerCase().replace(/\s+/g, '_'),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
// Step 3: Bulk Insert
|
|
56
|
+
const insertResult = await this.dataSource
|
|
57
|
+
.createQueryBuilder()
|
|
58
|
+
.insert()
|
|
59
|
+
.into(LinkedAttributes)
|
|
60
|
+
.values(newPayloads)
|
|
61
|
+
.execute();
|
|
62
|
+
|
|
63
|
+
// Step 4: Return inserted list
|
|
64
|
+
const ids = insertResult.identifiers.map((i) => i.id);
|
|
65
|
+
|
|
66
|
+
const newlyCreated = await this.dataSource
|
|
67
|
+
.getRepository(LinkedAttributes)
|
|
68
|
+
.createQueryBuilder('la')
|
|
69
|
+
.where('la.id IN (:...ids)', { ids })
|
|
70
|
+
.andWhere('la.organization_id = :orgId', { orgId })
|
|
71
|
+
.getMany();
|
|
99
72
|
|
|
100
|
-
return
|
|
73
|
+
return newlyCreated;
|
|
101
74
|
}
|
|
102
75
|
}
|