rez_core 1.0.89 → 1.0.95
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/main.js +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +8 -1
- package/dist/module/filter/controller/filter.controller.js +16 -2
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/repository/saved-filter.repository.d.ts +5 -0
- package/dist/module/filter/repository/saved-filter.repository.js +16 -1
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +5 -0
- package/dist/module/filter/service/saved-filter.service.js +3 -0
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +2 -1
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.js +5 -1
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.d.ts +1 -1
- package/dist/module/meta/service/media-data.service.js +1 -1
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +10 -2
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/user/service/role.service.js +1 -1
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/controller/filter.controller.ts +21 -2
- package/src/module/filter/repository/saved-filter.repository.ts +36 -11
- package/src/module/filter/service/saved-filter.service.ts +11 -9
- package/src/module/listmaster/service/list-master.service.ts +28 -17
- package/src/module/meta/service/entity-table.service.ts +5 -1
- package/src/module/meta/service/media-data.service.ts +1 -1
- package/src/module/module/repository/menu.repository.ts +11 -5
- package/src/module/user/service/role.service.ts +1 -1
package/package.json
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Post,
|
|
4
|
+
Body,
|
|
5
|
+
Query,
|
|
6
|
+
ParseIntPipe,
|
|
7
|
+
Get,
|
|
8
|
+
Param,
|
|
9
|
+
Inject,
|
|
10
|
+
} from '@nestjs/common';
|
|
2
11
|
import { FilterService } from '../service/filter.service';
|
|
12
|
+
import { SavedFilterService } from '../service/saved-filter.service';
|
|
3
13
|
|
|
4
14
|
@Controller('filter')
|
|
5
15
|
export class FilterController {
|
|
6
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly filterService: FilterService,
|
|
18
|
+
@Inject('SavedFilterService')
|
|
19
|
+
private readonly savedFilterService: SavedFilterService,
|
|
20
|
+
) {}
|
|
7
21
|
|
|
8
22
|
@Post()
|
|
9
23
|
async applyFilter(
|
|
@@ -31,4 +45,9 @@ export class FilterController {
|
|
|
31
45
|
size,
|
|
32
46
|
});
|
|
33
47
|
}
|
|
48
|
+
|
|
49
|
+
@Get(':id')
|
|
50
|
+
async getFilterById(@Param('id') id: string) {
|
|
51
|
+
return this.savedFilterService.getFilterById(Number(id));
|
|
52
|
+
}
|
|
34
53
|
}
|
|
@@ -50,22 +50,24 @@ export class SavedFilterRepositoryService {
|
|
|
50
50
|
async updateCode(id: number, code: string): Promise<void> {
|
|
51
51
|
await this.savedFilterMasterRepo.update(id, { code });
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
async getDefaultFilterByEntityType(
|
|
53
|
+
|
|
54
|
+
async getDefaultFilterByEntityType(
|
|
55
|
+
entityType: string,
|
|
56
|
+
): Promise<{ label: string; value: number } | null> {
|
|
55
57
|
const filter = await this.savedFilterMasterRepo.findOne({
|
|
56
58
|
where: {
|
|
57
59
|
mapped_entity_type: entityType,
|
|
58
60
|
is_default: true,
|
|
59
61
|
},
|
|
60
62
|
});
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
return filter ? { label: filter.name, value: filter.id } : null;
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
|
|
65
67
|
async getSavedFiltersByUserIdAndEntityType(
|
|
66
68
|
userId: number,
|
|
67
|
-
entityType: string
|
|
68
|
-
){
|
|
69
|
+
entityType: string,
|
|
70
|
+
) {
|
|
69
71
|
const filters = await this.savedFilterMasterRepo.find({
|
|
70
72
|
where: {
|
|
71
73
|
user_id: userId,
|
|
@@ -75,13 +77,36 @@ export class SavedFilterRepositoryService {
|
|
|
75
77
|
modified_date: 'DESC',
|
|
76
78
|
},
|
|
77
79
|
});
|
|
78
|
-
|
|
79
|
-
return filters.map(filter => ({
|
|
80
|
+
|
|
81
|
+
return filters.map((filter) => ({
|
|
80
82
|
label: filter.name,
|
|
81
83
|
value: filter.id,
|
|
82
84
|
}));
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
|
|
87
|
+
async getFilterById(
|
|
88
|
+
id: number,
|
|
89
|
+
): Promise<
|
|
90
|
+
{
|
|
91
|
+
filter_attribute: string;
|
|
92
|
+
filter_operator: string;
|
|
93
|
+
filter_value: string;
|
|
94
|
+
}[]
|
|
95
|
+
> {
|
|
96
|
+
const saveFilterMasterData = await this.savedFilterMasterRepo.findOne({
|
|
97
|
+
where: { id },
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
if (!saveFilterMasterData) return [];
|
|
101
|
+
|
|
102
|
+
const filterDetails = await this.savedFilterDetailRepo.find({
|
|
103
|
+
where: { mapped_filter_code: saveFilterMasterData.code },
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return filterDetails.map((detail) => ({
|
|
107
|
+
filter_attribute: detail.filter_attribute,
|
|
108
|
+
filter_operator: detail.filter_operator,
|
|
109
|
+
filter_value: detail.filter_value,
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
87
112
|
}
|
|
@@ -18,27 +18,27 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
18
18
|
loggedInUser: UserData | null,
|
|
19
19
|
): Promise<BaseEntity> {
|
|
20
20
|
const master = entityData as SavedFilterMaster;
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
const exists = await this.savedFilterRepo.isFilterNameExists(
|
|
23
23
|
master.name,
|
|
24
24
|
master.organization_id,
|
|
25
25
|
master.enterprise_id,
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
if (exists) {
|
|
29
29
|
throw new BadRequestException('Saved filter name already exists.');
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
// Save the master record without code
|
|
33
33
|
const savedMaster = await super.createEntity(master, loggedInUser);
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
// Generate the code like SFM00001 using the saved ID
|
|
36
36
|
const code = `SFM${savedMaster.id.toString().padStart(5, '0')}`;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// Update the code
|
|
39
39
|
savedMaster.code = code;
|
|
40
40
|
await this.savedFilterRepo.updateCode(savedMaster.id, code);
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
// Save filter details using generated code
|
|
43
43
|
const details = (entityData as any).filterDetails ?? [];
|
|
44
44
|
if (details.length) {
|
|
@@ -46,10 +46,10 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
46
46
|
...detail,
|
|
47
47
|
mapped_filter_code: savedMaster.code,
|
|
48
48
|
}));
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
await this.savedFilterRepo.saveDetails(prepared);
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
return savedMaster;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -99,5 +99,7 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
99
99
|
return this.savedFilterRepo.getDetailsByCode(code);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
async getFilterById(id: number) {
|
|
103
|
+
return this.savedFilterRepo.getFilterById(id);
|
|
104
|
+
}
|
|
103
105
|
}
|
|
@@ -13,7 +13,7 @@ import { EntityManager } from 'typeorm';
|
|
|
13
13
|
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
14
14
|
|
|
15
15
|
@Injectable()
|
|
16
|
-
export class ListMasterService
|
|
16
|
+
export class ListMasterService {
|
|
17
17
|
constructor(
|
|
18
18
|
private readonly entityManager: EntityManager,
|
|
19
19
|
private readonly entityMasterService: EntityMasterService,
|
|
@@ -21,8 +21,7 @@ export class ListMasterService {
|
|
|
21
21
|
private readonly listItemsRepo: ListMasterItemsRepository,
|
|
22
22
|
private readonly apiRegistryService: ApiRegistryService,
|
|
23
23
|
private readonly httpService: HttpService,
|
|
24
|
-
) {
|
|
25
|
-
}
|
|
24
|
+
) {}
|
|
26
25
|
|
|
27
26
|
async getDropdownOptions(type: string, params: Record<string, string>) {
|
|
28
27
|
const config = await this.listMasterRepo.findByType(type);
|
|
@@ -31,7 +30,7 @@ export class ListMasterService {
|
|
|
31
30
|
|
|
32
31
|
switch (config.source) {
|
|
33
32
|
case 'entity':
|
|
34
|
-
return this.fetchFromEntity(type,params);
|
|
33
|
+
return this.fetchFromEntity(type, params);
|
|
35
34
|
|
|
36
35
|
case 'master':
|
|
37
36
|
return this.listItemsRepo.findItemsByType(type);
|
|
@@ -44,7 +43,10 @@ export class ListMasterService {
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
private async fetchFromEntity(
|
|
46
|
+
private async fetchFromEntity(
|
|
47
|
+
sourceList: string,
|
|
48
|
+
params: Record<string, any>,
|
|
49
|
+
) {
|
|
48
50
|
let result: { label: string; value: number }[] = [];
|
|
49
51
|
const argsObjectList: any[] = [];
|
|
50
52
|
if (sourceList) {
|
|
@@ -58,11 +60,10 @@ export class ListMasterService {
|
|
|
58
60
|
argsObjectList.push(params[paramsKey]);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
|
|
62
63
|
let results = await this.entityManager.query(query, argsObjectList);
|
|
63
|
-
results.forEach(r => {
|
|
64
|
-
result.push({ label: r['name'], value: r['id']});
|
|
65
|
-
})
|
|
64
|
+
results.forEach((r) => {
|
|
65
|
+
result.push({ label: r['name'], value: r['id'] });
|
|
66
|
+
});
|
|
66
67
|
}
|
|
67
68
|
return result;
|
|
68
69
|
}
|
|
@@ -75,7 +76,11 @@ export class ListMasterService {
|
|
|
75
76
|
if (!apiRegistry) return [];
|
|
76
77
|
|
|
77
78
|
const url = `${apiRegistry.base_url}${apiRegistry.endpoint.replace(/{{(.*?)}}/g, (_, key) => params?.[key.trim()] || '')}`;
|
|
78
|
-
|
|
79
|
+
console.log(url);
|
|
80
|
+
const payload = this.injectDynamicParams(
|
|
81
|
+
apiRegistry.request_payload_schema,
|
|
82
|
+
params,
|
|
83
|
+
);
|
|
79
84
|
|
|
80
85
|
const response = await firstValueFrom(
|
|
81
86
|
this.httpService.request({
|
|
@@ -86,7 +91,10 @@ export class ListMasterService {
|
|
|
86
91
|
}),
|
|
87
92
|
);
|
|
88
93
|
|
|
89
|
-
const data = this.extractByPath(
|
|
94
|
+
const data = this.extractByPath(
|
|
95
|
+
response.data,
|
|
96
|
+
apiRegistry.response_data_path,
|
|
97
|
+
);
|
|
90
98
|
|
|
91
99
|
if (!Array.isArray(data)) {
|
|
92
100
|
return [{ label: data, value: data }];
|
|
@@ -100,13 +108,18 @@ export class ListMasterService {
|
|
|
100
108
|
label: item[apiRegistry?.label],
|
|
101
109
|
value: item[apiRegistry?.value],
|
|
102
110
|
}));
|
|
103
|
-
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
private injectDynamicParams(
|
|
107
|
-
|
|
113
|
+
private injectDynamicParams(
|
|
114
|
+
payload: any,
|
|
115
|
+
params?: Record<string, string>,
|
|
116
|
+
): any {
|
|
117
|
+
if (params) {
|
|
108
118
|
const stringified = JSON.stringify(payload);
|
|
109
|
-
const replaced = stringified.replace(
|
|
119
|
+
const replaced = stringified.replace(
|
|
120
|
+
/{{(.*?)}}/g,
|
|
121
|
+
(_, key) => params[key.trim()] || '',
|
|
122
|
+
);
|
|
110
123
|
return JSON.parse(replaced);
|
|
111
124
|
}
|
|
112
125
|
}
|
|
@@ -126,6 +139,4 @@ export class ListMasterService {
|
|
|
126
139
|
return acc[key];
|
|
127
140
|
}, obj);
|
|
128
141
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
142
|
}
|
|
@@ -62,7 +62,11 @@ export class EntityTableService {
|
|
|
62
62
|
entityTable.entity_type,
|
|
63
63
|
);
|
|
64
64
|
entityTableDto.operation_list = {
|
|
65
|
-
"text": await this.listMasterService.getDropdownOptions("OPT",{})
|
|
65
|
+
"text": await this.listMasterService.getDropdownOptions("OPT",{}),
|
|
66
|
+
"number": await this.listMasterService.getDropdownOptions("OPN",{}),
|
|
67
|
+
"date": await this.listMasterService.getDropdownOptions("OPD",{}),
|
|
68
|
+
"select": await this.listMasterService.getDropdownOptions("OPS",{}),
|
|
69
|
+
"multiselect": await this.listMasterService.getDropdownOptions("OPM",{})
|
|
66
70
|
// Add any other operations you want to include
|
|
67
71
|
};
|
|
68
72
|
entityTableDto.default_filter= await this.savedFilterRepoService.getDefaultFilterByEntityType(entityTable.list_type);
|
|
@@ -124,7 +124,7 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
124
124
|
Key: mediaData.media_url,
|
|
125
125
|
Expires: 60 * 5, // URL valid for 5 mins
|
|
126
126
|
});
|
|
127
|
-
return {signedUrl,
|
|
127
|
+
return {signedUrl,fileName: mediaData.file_name,id:mediaData.id};
|
|
128
128
|
} catch (error) {
|
|
129
129
|
console.error('Error generating signed URL for media:', error);
|
|
130
130
|
throw new Error('Failed to generate signed URL');
|
|
@@ -55,12 +55,18 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
55
55
|
return modules.map((module) => module.module_code);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
* Get menu items based on accessible modules.
|
|
60
|
-
*/
|
|
61
58
|
async getMenuItems(moduleCodes: string[]): Promise<MenuData[]> {
|
|
62
|
-
|
|
59
|
+
const menuItems = await this.createQueryBuilder('menu')
|
|
60
|
+
.leftJoin('cr_module', 'module', 'menu.module_code = module.module_code')
|
|
63
61
|
.where('menu.module_code IN (:...moduleCodes)', { moduleCodes })
|
|
64
|
-
.
|
|
62
|
+
.select([
|
|
63
|
+
'menu.*',
|
|
64
|
+
'module.component_name AS component',
|
|
65
|
+
'module.title AS title',
|
|
66
|
+
'module.entity_type AS entity_type',
|
|
67
|
+
])
|
|
68
|
+
.getRawMany();
|
|
69
|
+
|
|
70
|
+
return menuItems;
|
|
65
71
|
}
|
|
66
72
|
}
|
|
@@ -98,7 +98,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
if (
|
|
101
|
-
await this.roleRepository.isRoleNameExists(entityData.name, {excludeRoleId:entityData.id})
|
|
101
|
+
await this.roleRepository.isRoleNameExists(entityData.name, {excludeRoleId:entityData.id,organization_id:loggedInUser?.organization_id})
|
|
102
102
|
) {
|
|
103
103
|
throw new BadRequestException('Role name already exists.');
|
|
104
104
|
}
|