rez_core 4.0.292 → 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/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/module/listmaster/service/list-master.service.js +13 -2
- package/dist/module/listmaster/service/list-master.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/src/module/listmaster/service/list-master.service.ts +41 -18
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
|
}
|
|
@@ -87,6 +87,20 @@ export class ListMasterService {
|
|
|
87
87
|
config.appcode != loggedInUser?.appcode &&
|
|
88
88
|
!publicCall
|
|
89
89
|
) {
|
|
90
|
+
const client = this.factory.getClient(config.appcode);
|
|
91
|
+
|
|
92
|
+
if (!client) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const res = await firstValueFrom(
|
|
97
|
+
client.send('listmaster.getDropdownData', {
|
|
98
|
+
type,
|
|
99
|
+
loggedInUser,
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
console.log(res, '-------------------');
|
|
90
104
|
// Call internal API for appcode mismatch
|
|
91
105
|
try {
|
|
92
106
|
const baseUrl = this.configService.get<string>('REDIRECT_BE_URL');
|
|
@@ -443,12 +457,16 @@ export class ListMasterService {
|
|
|
443
457
|
return await this.listMasterRepo.findAllItems(organizationId, search);
|
|
444
458
|
}
|
|
445
459
|
|
|
446
|
-
async getDropDownData(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
460
|
+
async getDropDownData(
|
|
461
|
+
entity_type: string,
|
|
462
|
+
attribute_key: string,
|
|
463
|
+
loggedInUser: UserData,
|
|
464
|
+
body: Record<string, string>,
|
|
465
|
+
) {
|
|
466
|
+
let entityMaster = await this.entityMasterService.getEntityData(
|
|
467
|
+
entity_type,
|
|
468
|
+
loggedInUser,
|
|
469
|
+
);
|
|
452
470
|
let appCode = entityMaster.appcode;
|
|
453
471
|
|
|
454
472
|
const { inactiveIds, ...params } = body;
|
|
@@ -460,11 +478,12 @@ export class ListMasterService {
|
|
|
460
478
|
const currentAppCode = this.configService.get<string>('appcode');
|
|
461
479
|
|
|
462
480
|
if (currentAppCode === appCode || !currentAppCode) {
|
|
463
|
-
const entityAttribute =
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
481
|
+
const entityAttribute =
|
|
482
|
+
await this.attributeMasterService.findByMappedEntityTypeAndAttributeKey(
|
|
483
|
+
entity_type,
|
|
484
|
+
attribute_key,
|
|
485
|
+
loggedInUser,
|
|
486
|
+
);
|
|
468
487
|
|
|
469
488
|
if (entityAttribute && entityAttribute.data_source_type) {
|
|
470
489
|
const listMaster = await this.listMasterRepo.findByType(
|
|
@@ -514,7 +533,9 @@ export class ListMasterService {
|
|
|
514
533
|
}
|
|
515
534
|
|
|
516
535
|
default:
|
|
517
|
-
throw new BadRequestException(
|
|
536
|
+
throw new BadRequestException(
|
|
537
|
+
`Unknown source: ${listMaster.source}`,
|
|
538
|
+
);
|
|
518
539
|
}
|
|
519
540
|
}
|
|
520
541
|
} else {
|
|
@@ -524,12 +545,14 @@ export class ListMasterService {
|
|
|
524
545
|
return;
|
|
525
546
|
}
|
|
526
547
|
|
|
527
|
-
return client
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
548
|
+
return client
|
|
549
|
+
.send('getDropdownData', {
|
|
550
|
+
entity_type,
|
|
551
|
+
attribute_key,
|
|
552
|
+
loggedInUser,
|
|
553
|
+
body,
|
|
554
|
+
})
|
|
555
|
+
.toPromise();
|
|
533
556
|
}
|
|
534
557
|
}
|
|
535
558
|
}
|