rez_core 4.0.104 → 4.0.106
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/layout_preference/controller/layout_preference.controller.d.ts +4 -1
- package/dist/module/layout_preference/service/layout_preference.service.d.ts +4 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +11 -8
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/listmaster/controller/list-master.controller.d.ts +2 -1
- package/dist/module/listmaster/controller/list-master.controller.js +20 -2
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +4 -1
- package/dist/module/listmaster/service/list-master.service.js +59 -2
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/repository/attribute-master.repository.d.ts +1 -0
- package/dist/module/meta/repository/attribute-master.repository.js +7 -0
- package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +1 -0
- package/dist/module/meta/service/attribute-master.service.js +3 -0
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/layout_preference/service/layout_preference.service.ts +15 -16
- package/src/module/listmaster/controller/list-master.controller.ts +24 -1
- package/src/module/listmaster/service/list-master.service.ts +102 -0
- package/src/module/meta/repository/attribute-master.repository.ts +8 -0
- package/src/module/meta/service/attribute-master.service.ts +10 -1
- package/src/resources/dev.properties.yaml +1 -1
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -80,7 +80,7 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
80
80
|
column: string,
|
|
81
81
|
sort_by: string,
|
|
82
82
|
loggedInUser: UserData,
|
|
83
|
-
): Promise<string[]> {
|
|
83
|
+
): Promise<{ label: string; value: string }[]> {
|
|
84
84
|
try {
|
|
85
85
|
const getTableMeta =
|
|
86
86
|
await this.entityTableService.findByEntityTypeAndListTypeAndDisplayType(
|
|
@@ -135,7 +135,8 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
135
135
|
const resolvedValue =
|
|
136
136
|
resolvedEntityList[index]?.[column] || row.column_value;
|
|
137
137
|
return {
|
|
138
|
-
resolvedValue,
|
|
138
|
+
label: resolvedValue, // Human-readable label
|
|
139
|
+
value: row.column_value, // Original DB value
|
|
139
140
|
count: Number(row.count),
|
|
140
141
|
};
|
|
141
142
|
});
|
|
@@ -143,14 +144,10 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
143
144
|
// Sort based on sort_by parameter
|
|
144
145
|
switch (sort_by) {
|
|
145
146
|
case 'asc':
|
|
146
|
-
resolvedWithCounts.sort((a, b) =>
|
|
147
|
-
a.resolvedValue.localeCompare(b.resolvedValue),
|
|
148
|
-
);
|
|
147
|
+
resolvedWithCounts.sort((a, b) => a.label.localeCompare(b.label));
|
|
149
148
|
break;
|
|
150
149
|
case 'dsc':
|
|
151
|
-
resolvedWithCounts.sort((a, b) =>
|
|
152
|
-
b.resolvedValue.localeCompare(a.resolvedValue),
|
|
153
|
-
);
|
|
150
|
+
resolvedWithCounts.sort((a, b) => b.label.localeCompare(a.label));
|
|
154
151
|
break;
|
|
155
152
|
case 'count_asc':
|
|
156
153
|
resolvedWithCounts.sort((a, b) => a.count - b.count);
|
|
@@ -162,16 +159,18 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
162
159
|
break;
|
|
163
160
|
}
|
|
164
161
|
|
|
165
|
-
//
|
|
162
|
+
// Clean and return only label/value pairs
|
|
166
163
|
return resolvedWithCounts
|
|
167
|
-
.map((item) => item.resolvedValue)
|
|
168
164
|
.filter(
|
|
169
|
-
(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
165
|
+
(item) =>
|
|
166
|
+
item.label !== null &&
|
|
167
|
+
item.label !== undefined &&
|
|
168
|
+
item.label.toString().trim() !== '',
|
|
169
|
+
)
|
|
170
|
+
.map((item) => ({
|
|
171
|
+
label: item.label,
|
|
172
|
+
value: item.value,
|
|
173
|
+
}));
|
|
175
174
|
} catch (error) {
|
|
176
175
|
this.logger.error(`getColumnValue ERROR: ${error.message}`, error.stack);
|
|
177
176
|
return [];
|
|
@@ -29,7 +29,7 @@ export class ListMasterController {
|
|
|
29
29
|
@Post('/getDropdownData/:type')
|
|
30
30
|
@UseGuards(JwtAuthGuard)
|
|
31
31
|
@HttpCode(HttpStatus.OK)
|
|
32
|
-
async
|
|
32
|
+
async getDropdownDataO(
|
|
33
33
|
@Param('type') type: string,
|
|
34
34
|
@Query() queryParams: Record<string, string>,
|
|
35
35
|
@Request() req,
|
|
@@ -184,4 +184,27 @@ export class ListMasterController {
|
|
|
184
184
|
): Promise<string> {
|
|
185
185
|
return await this.listMasterItemService.deleteListMasterItem(type, code);
|
|
186
186
|
}
|
|
187
|
+
|
|
188
|
+
@Post('/getDropdownData')
|
|
189
|
+
@UseGuards(JwtAuthGuard)
|
|
190
|
+
@HttpCode(HttpStatus.OK)
|
|
191
|
+
async getDropdownData(
|
|
192
|
+
@Query('entity_type') entity_type: string,
|
|
193
|
+
@Query('attribute_key') attribute_key: string,
|
|
194
|
+
@Body() body: Record<string, string>,
|
|
195
|
+
@Request() req,
|
|
196
|
+
) {
|
|
197
|
+
|
|
198
|
+
const loggedInUser = req.user.userData;
|
|
199
|
+
const authHeader = req.headers.authorization || '';
|
|
200
|
+
const token = authHeader.replace('Bearer ', '').trim();
|
|
201
|
+
|
|
202
|
+
return await this.service.getDropDownData(
|
|
203
|
+
entity_type,
|
|
204
|
+
attribute_key,
|
|
205
|
+
token,
|
|
206
|
+
loggedInUser,
|
|
207
|
+
body
|
|
208
|
+
);
|
|
209
|
+
}
|
|
187
210
|
}
|
|
@@ -20,6 +20,7 @@ import { ListMasterEngine } from './list-master-engine';
|
|
|
20
20
|
import { Action } from '../../workflow-automation/interface/action.interface';
|
|
21
21
|
import axios from 'axios';
|
|
22
22
|
import { ConfigService } from '@nestjs/config';
|
|
23
|
+
import { AttributeMasterService } from '../../meta/service/attribute-master.service';
|
|
23
24
|
|
|
24
25
|
@Injectable()
|
|
25
26
|
export class ListMasterService {
|
|
@@ -35,6 +36,7 @@ export class ListMasterService {
|
|
|
35
36
|
private readonly httpService: HttpService,
|
|
36
37
|
private readonly listMasterEngine: ListMasterEngine,
|
|
37
38
|
private readonly configService: ConfigService,
|
|
39
|
+
private readonly attributeMasterService: AttributeMasterService,
|
|
38
40
|
) {}
|
|
39
41
|
|
|
40
42
|
private readonly skipLevelFilterEntities = ['BRN', 'USR', 'UPR', 'BRNP'];
|
|
@@ -437,4 +439,104 @@ export class ListMasterService {
|
|
|
437
439
|
): Promise<any[]> {
|
|
438
440
|
return await this.listMasterRepo.findAllItems(organizationId, search);
|
|
439
441
|
}
|
|
442
|
+
|
|
443
|
+
async getDropDownData(entity_type: string,
|
|
444
|
+
attribute_key: string,
|
|
445
|
+
token: string,
|
|
446
|
+
loggedInUser: UserData,
|
|
447
|
+
body: Record<string, string>
|
|
448
|
+
) {
|
|
449
|
+
let entityMaster = await this.entityMasterService.getEntityData(entity_type, loggedInUser);
|
|
450
|
+
let appCode = entityMaster.appcode;
|
|
451
|
+
|
|
452
|
+
const { inactiveIds, ...params } = body;
|
|
453
|
+
|
|
454
|
+
const inactiveIdsArray = inactiveIds
|
|
455
|
+
? inactiveIds.split(',').map((id) => parseInt(id, 10))
|
|
456
|
+
: [];
|
|
457
|
+
|
|
458
|
+
const currentAppCode = this.configService.get<string>('appcode');
|
|
459
|
+
|
|
460
|
+
if (currentAppCode === appCode || !currentAppCode) {
|
|
461
|
+
const entityAttribute = await this.attributeMasterService.findByMappedEntityTypeAndAttributeKey(
|
|
462
|
+
entity_type,
|
|
463
|
+
attribute_key,
|
|
464
|
+
loggedInUser
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
if (entityAttribute && entityAttribute.data_source_type) {
|
|
468
|
+
const listMaster = await this.listMasterRepo.findByType(
|
|
469
|
+
entityAttribute.datasource_list,
|
|
470
|
+
loggedInUser?.organization_id,
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
if (!listMaster) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
switch (listMaster.source) {
|
|
478
|
+
case 'entity':
|
|
479
|
+
return this.fetchFromEntity(
|
|
480
|
+
listMaster.type,
|
|
481
|
+
params,
|
|
482
|
+
inactiveIdsArray,
|
|
483
|
+
loggedInUser,
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
case 'master':
|
|
487
|
+
return this.listItemsRepo.findItemsByType(
|
|
488
|
+
listMaster.type,
|
|
489
|
+
listMaster.sort_by,
|
|
490
|
+
inactiveIdsArray,
|
|
491
|
+
loggedInUser.organization_id,
|
|
492
|
+
params,
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
case 'operator':
|
|
496
|
+
return this.listItemsRepo.findOperatorsByType(
|
|
497
|
+
listMaster?.type,
|
|
498
|
+
loggedInUser?.organization_id,
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
case 'custom':
|
|
502
|
+
// If you want Axios call here too:
|
|
503
|
+
try {
|
|
504
|
+
const response = await axios.get(
|
|
505
|
+
`https://external-source.com/${listMaster.custom_source_id}`,
|
|
506
|
+
{ params },
|
|
507
|
+
);
|
|
508
|
+
return response.data;
|
|
509
|
+
} catch (error) {
|
|
510
|
+
console.error('⚠️ Custom source fetch failed:', error.message);
|
|
511
|
+
throw new BadRequestException('Failed to fetch custom source');
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
default:
|
|
515
|
+
throw new BadRequestException(`Unknown source: ${listMaster.source}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
const baseUrl = this.configService.get<string>(appCode);
|
|
520
|
+
|
|
521
|
+
if (!baseUrl) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const response = await axios.post(
|
|
526
|
+
`${baseUrl}/list-master/getDropdownData`,
|
|
527
|
+
{
|
|
528
|
+
headers: {
|
|
529
|
+
Authorization: `Bearer ${token}`,
|
|
530
|
+
},
|
|
531
|
+
params: {
|
|
532
|
+
entity_type: entity_type,
|
|
533
|
+
attribute_key: attribute_key,
|
|
534
|
+
},
|
|
535
|
+
body: body
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
return response.data;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
440
542
|
}
|
|
@@ -107,4 +107,12 @@ export class AttributeMasterRepository {
|
|
|
107
107
|
const alterQuery = `ALTER TABLE \`${tableName}\` ADD COLUMN \`${columnName}\` ${columnType} NULL`;
|
|
108
108
|
await this.dataSource.query(alterQuery);
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
async findByMappedEntityTypeAndAttributeKeyAndOrganizationId(mapped_entity_type: string, attribute_key: string, organization_id: number) {
|
|
112
|
+
return await this.attributeMasterRepository.findOne({
|
|
113
|
+
where: {
|
|
114
|
+
mapped_entity_type, attribute_key, organization_id
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
}
|
|
110
118
|
}
|
|
@@ -7,7 +7,8 @@ import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
|
7
7
|
export class AttributeMasterService {
|
|
8
8
|
constructor(
|
|
9
9
|
private readonly attributeMasterRepository: AttributeMasterRepository,
|
|
10
|
-
) {
|
|
10
|
+
) {
|
|
11
|
+
}
|
|
11
12
|
|
|
12
13
|
async findAttributesByMappedEntityType(
|
|
13
14
|
entity_type: string,
|
|
@@ -114,4 +115,12 @@ export class AttributeMasterService {
|
|
|
114
115
|
loggedInUser,
|
|
115
116
|
);
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
async findByMappedEntityTypeAndAttributeKey(mapped_entity_type: string, attribute_key: string, loggedInUser: UserData) {
|
|
120
|
+
return await this.attributeMasterRepository.findByMappedEntityTypeAndAttributeKeyAndOrganizationId(
|
|
121
|
+
mapped_entity_type,
|
|
122
|
+
attribute_key,
|
|
123
|
+
loggedInUser.organization_id
|
|
124
|
+
);
|
|
125
|
+
}
|
|
117
126
|
}
|