rez_core 2.1.16 → 2.1.17
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/filter/repository/saved-filter.repository.d.ts +1 -1
- package/dist/module/filter/repository/saved-filter.repository.js +6 -5
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +1 -1
- package/dist/module/filter/service/saved-filter.service.js +13 -2
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.js +0 -1
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.js +4 -5
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/section-master.service.js +0 -1
- package/dist/module/meta/service/section-master.service.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +9 -8
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/user/controller/login.controller.js +0 -4
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/encryptUtil.service.js +1 -1
- package/package.json +1 -1
- package/src/module/filter/repository/saved-filter.repository.ts +12 -10
- package/src/module/filter/service/saved-filter.service.ts +14 -12
- package/src/module/layout_preference/service/layout_preference.service.ts +0 -2
- package/src/module/meta/controller/entity.controller.ts +4 -14
- package/src/module/meta/service/entity-service-impl.service.ts +1 -1
- package/src/module/meta/service/section-master.service.ts +0 -1
- package/src/module/module/repository/menu.repository.ts +38 -32
- package/src/module/user/controller/login.controller.ts +0 -10
- package/src/utils/service/encryptUtil.service.ts +1 -1
|
@@ -41,7 +41,7 @@ let EncryptUtilService = class EncryptUtilService {
|
|
|
41
41
|
return decrypted;
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
|
-
throw new common_1.InternalServerErrorException('
|
|
44
|
+
throw new common_1.InternalServerErrorException('Decryption process failed');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
static encryptCBC(data, Datakey, Dataiv) {
|
package/package.json
CHANGED
|
@@ -13,19 +13,21 @@ export class SavedFilterRepositoryService {
|
|
|
13
13
|
private readonly savedFilterDetailRepo: Repository<SavedFilterDetail>,
|
|
14
14
|
) {}
|
|
15
15
|
|
|
16
|
-
async isFilterNameExists(
|
|
17
|
-
name
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
async isFilterNameExists({
|
|
17
|
+
name,
|
|
18
|
+
organization_id,
|
|
19
|
+
id,
|
|
20
|
+
level_type,
|
|
21
|
+
level_id,
|
|
22
|
+
}: any): Promise<boolean> {
|
|
22
23
|
const where: any = {
|
|
23
24
|
name,
|
|
24
|
-
organization_id:
|
|
25
|
-
|
|
25
|
+
organization_id: organization_id,
|
|
26
|
+
level_type: level_type,
|
|
27
|
+
level_id: level_id,
|
|
26
28
|
};
|
|
27
|
-
if (
|
|
28
|
-
where.id = Not(
|
|
29
|
+
if (id) {
|
|
30
|
+
where.id = Not(id);
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
const existing = await this.savedFilterMasterRepo.findOne({ where });
|
|
@@ -15,15 +15,17 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
15
15
|
|
|
16
16
|
async createEntity(
|
|
17
17
|
entityData: any,
|
|
18
|
-
loggedInUser: UserData
|
|
18
|
+
loggedInUser: UserData,
|
|
19
19
|
): Promise<BaseEntity> {
|
|
20
20
|
const master = entityData as SavedFilterMaster;
|
|
21
21
|
|
|
22
|
-
const exists = await this.savedFilterRepo.isFilterNameExists(
|
|
23
|
-
master.name,
|
|
24
|
-
|
|
25
|
-
master.
|
|
26
|
-
|
|
22
|
+
const exists = await this.savedFilterRepo.isFilterNameExists({
|
|
23
|
+
name: master.name,
|
|
24
|
+
organization_id: loggedInUser.organization_id,
|
|
25
|
+
id: master.id,
|
|
26
|
+
level_type: loggedInUser?.level_type,
|
|
27
|
+
level_id: loggedInUser?.level_id,
|
|
28
|
+
});
|
|
27
29
|
|
|
28
30
|
if (exists) {
|
|
29
31
|
throw new BadRequestException('Saved filter name already exists.');
|
|
@@ -68,12 +70,12 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
68
70
|
throw new BadRequestException('Saved filter not found.');
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
const nameExists = await this.savedFilterRepo.isFilterNameExists(
|
|
72
|
-
master.name,
|
|
73
|
-
master.organization_id,
|
|
74
|
-
master.enterprise_id,
|
|
75
|
-
master.id,
|
|
76
|
-
);
|
|
73
|
+
const nameExists = await this.savedFilterRepo.isFilterNameExists({
|
|
74
|
+
name: master.name,
|
|
75
|
+
organization_id: master.organization_id,
|
|
76
|
+
enterprise_id: master.enterprise_id,
|
|
77
|
+
id: master.id, // Include ID to check for updates
|
|
78
|
+
});
|
|
77
79
|
|
|
78
80
|
if (nameExists) {
|
|
79
81
|
throw new BadRequestException('Saved filter name already exists.');
|
|
@@ -22,8 +22,6 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
22
22
|
throw new Error('User ID is required to create layout preference.');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
console.log('userId', userId);
|
|
26
|
-
|
|
27
25
|
const existingLayoutPreference =
|
|
28
26
|
await this.layoutPreferenceRepository.findByEntityUserId(
|
|
29
27
|
mapped_entity_type,
|
|
@@ -60,7 +60,6 @@ export class EntityController {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
@Post('create')
|
|
63
|
-
// @Roles('USR', 'VIEW')
|
|
64
63
|
async create(
|
|
65
64
|
@Body() entityData: BaseEntity,
|
|
66
65
|
@Query('entity_type') entityType: string,
|
|
@@ -68,18 +67,9 @@ export class EntityController {
|
|
|
68
67
|
@Req() req: Request & { user: any },
|
|
69
68
|
) {
|
|
70
69
|
try {
|
|
71
|
-
let requestedUser = req.user.userData;
|
|
72
|
-
let appcode = requestedUser.appcode;
|
|
73
|
-
// let loggedInUser = await this.entityService.getEntityData(
|
|
74
|
-
// ENTITYTYPE_USER,
|
|
75
|
-
// requestedUser.userId,
|
|
76
|
-
// );
|
|
77
70
|
let loggedInUser = req.user.userData;
|
|
71
|
+
let appcode = req.user.userData.appcode;
|
|
78
72
|
if (!entityType) {
|
|
79
|
-
// throw new BadRequestException(
|
|
80
|
-
// 'Query parameter "entity_type" is required',
|
|
81
|
-
// );
|
|
82
|
-
|
|
83
73
|
return res.status(HttpStatus.BAD_REQUEST).json({
|
|
84
74
|
success: false,
|
|
85
75
|
error: 'Query parameter "entity_type" is required',
|
|
@@ -96,7 +86,7 @@ export class EntityController {
|
|
|
96
86
|
if (!entityService) {
|
|
97
87
|
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
98
88
|
success: false,
|
|
99
|
-
error: `No service found for
|
|
89
|
+
error: `No service found for Entity Type ${entityType}`,
|
|
100
90
|
});
|
|
101
91
|
}
|
|
102
92
|
const createdEntity = await entityService.createEntity(
|
|
@@ -106,7 +96,7 @@ export class EntityController {
|
|
|
106
96
|
appcode,
|
|
107
97
|
);
|
|
108
98
|
|
|
109
|
-
if (!createdEntity
|
|
99
|
+
if (!createdEntity) {
|
|
110
100
|
return res.status(HttpStatus.BAD_REQUEST).json({
|
|
111
101
|
success: false,
|
|
112
102
|
error: createdEntity?.error || 'Entity creation failed',
|
|
@@ -115,7 +105,7 @@ export class EntityController {
|
|
|
115
105
|
|
|
116
106
|
return res.status(HttpStatus.OK).json({
|
|
117
107
|
success: true,
|
|
118
|
-
data: createdEntity
|
|
108
|
+
data: createdEntity,
|
|
119
109
|
});
|
|
120
110
|
} catch (error) {
|
|
121
111
|
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
@@ -52,7 +52,6 @@ export class SectionMasterService extends EntityServiceImpl {
|
|
|
52
52
|
|
|
53
53
|
if (layoutJson?.form?.children && Array.isArray(layoutJson.form.children)) {
|
|
54
54
|
const firstChild = layoutJson.form.children[0];
|
|
55
|
-
console.log('First Child:', firstChild);
|
|
56
55
|
|
|
57
56
|
if (firstChild.type === 'wizard' && Array.isArray(firstChild.steps)) {
|
|
58
57
|
console.log('Wizard Steps:', firstChild.steps);
|
|
@@ -8,8 +8,9 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|
|
8
8
|
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class MenuRepository extends Repository<MenuData> {
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
11
|
+
constructor(
|
|
12
|
+
private readonly dataSource: DataSource,
|
|
13
|
+
@InjectRepository(MenuData) private readonly menuData: Repository<MenuData>,
|
|
13
14
|
) {
|
|
14
15
|
super(MenuData, dataSource.createEntityManager());
|
|
15
16
|
}
|
|
@@ -27,7 +28,10 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
27
28
|
return roles.map((r) => r.urm_role_id);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
async getAccessibleModules(
|
|
31
|
+
async getAccessibleModules(
|
|
32
|
+
roleIds: number[],
|
|
33
|
+
appCode: string,
|
|
34
|
+
): Promise<string[]> {
|
|
31
35
|
const roleCodes = await this.dataSource
|
|
32
36
|
.getRepository(Role)
|
|
33
37
|
.createQueryBuilder('role')
|
|
@@ -35,11 +39,9 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
35
39
|
.where('role.id IN (:...roleIds)', { roleIds })
|
|
36
40
|
.getMany();
|
|
37
41
|
|
|
38
|
-
console.log(roleCodes,"ROLE CODES")
|
|
39
|
-
|
|
40
42
|
const codes = roleCodes.map((role) => role.code);
|
|
41
43
|
if (codes.length === 0) return [];
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
const modules = await this.dataSource
|
|
44
46
|
.getRepository(ModuleAccess)
|
|
45
47
|
.createQueryBuilder('moduleAccess')
|
|
@@ -49,16 +51,17 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
49
51
|
.andWhere('LOWER(moduleAccess.appcode) = LOWER(:appCode)', { appCode })
|
|
50
52
|
.getMany();
|
|
51
53
|
|
|
52
|
-
console.log(modules,"MODULES")
|
|
53
|
-
|
|
54
54
|
return Array.from(new Set(modules.map((module) => module.module_code)));
|
|
55
55
|
}
|
|
56
|
-
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
58
|
* ✅ FIXED: Use this.createQueryBuilder() instead of this.menuData.createQueryBuilder()
|
|
60
59
|
*/
|
|
61
|
-
async getMenuItems(
|
|
60
|
+
async getMenuItems(
|
|
61
|
+
moduleCodes: string[],
|
|
62
|
+
appcode: string,
|
|
63
|
+
levelType: string,
|
|
64
|
+
) {
|
|
62
65
|
return await this.menuData
|
|
63
66
|
.createQueryBuilder('menu')
|
|
64
67
|
.leftJoin(
|
|
@@ -68,7 +71,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
68
71
|
menu.module_code = module.module_code
|
|
69
72
|
AND LOWER(menu.appcode) = LOWER(module.appcode)
|
|
70
73
|
AND menu.level_type = module.level_type
|
|
71
|
-
|
|
74
|
+
`,
|
|
72
75
|
)
|
|
73
76
|
.where('menu.module_code IN (:...moduleCodes)', { moduleCodes })
|
|
74
77
|
.andWhere('LOWER(menu.appcode) = LOWER(:appcode)', { appcode })
|
|
@@ -83,8 +86,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
83
86
|
])
|
|
84
87
|
.getRawMany();
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
|
|
88
90
|
async resolveUserRoles(
|
|
89
91
|
userId: number,
|
|
90
92
|
appcode: string,
|
|
@@ -92,9 +94,10 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
92
94
|
levelId: number,
|
|
93
95
|
): Promise<number[]> {
|
|
94
96
|
const repo = this.dataSource.getRepository(UserRoleMapping);
|
|
95
|
-
|
|
97
|
+
|
|
96
98
|
// 1. Try exact level match
|
|
97
|
-
let roles = await repo
|
|
99
|
+
let roles = await repo
|
|
100
|
+
.createQueryBuilder('urm')
|
|
98
101
|
.innerJoin('cr_role', 'role', 'role.id = urm.role_id')
|
|
99
102
|
.select('urm.role_id')
|
|
100
103
|
.where('urm.user_id = :userId', { userId })
|
|
@@ -102,23 +105,26 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
102
105
|
.andWhere('urm.level_id = :levelId', { levelId })
|
|
103
106
|
.andWhere('role.appcode = :appcode', { appcode })
|
|
104
107
|
.getRawMany();
|
|
105
|
-
|
|
106
|
-
if (roles.length) return roles.map(r => r.urm_role_id);
|
|
107
|
-
|
|
108
|
+
|
|
109
|
+
if (roles.length) return roles.map((r) => r.urm_role_id);
|
|
110
|
+
|
|
108
111
|
// 2. If SCH fallback → BRN → ORG
|
|
109
112
|
if (levelType === 'SCH') {
|
|
110
|
-
const [sch] = await this.dataSource.query(
|
|
113
|
+
const [sch] = await this.dataSource.query(
|
|
114
|
+
`
|
|
111
115
|
SELECT s.brand_id, s.organization_id
|
|
112
116
|
FROM cr_school s
|
|
113
117
|
WHERE s.id = ?
|
|
114
|
-
`,
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
`,
|
|
119
|
+
[levelId],
|
|
120
|
+
);
|
|
121
|
+
|
|
117
122
|
const brandId = sch?.brand_id;
|
|
118
123
|
const orgId = sch?.organization_id;
|
|
119
|
-
|
|
124
|
+
|
|
120
125
|
if (brandId) {
|
|
121
|
-
roles = await repo
|
|
126
|
+
roles = await repo
|
|
127
|
+
.createQueryBuilder('urm')
|
|
122
128
|
.innerJoin('cr_role', 'role', 'role.id = urm.role_id')
|
|
123
129
|
.select('urm.role_id')
|
|
124
130
|
.where('urm.user_id = :userId', { userId })
|
|
@@ -126,12 +132,13 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
126
132
|
.andWhere('urm.level_id = :levelId', { levelId: brandId })
|
|
127
133
|
.andWhere('role.appcode = :appcode', { appcode })
|
|
128
134
|
.getRawMany();
|
|
129
|
-
|
|
130
|
-
if (roles.length) return roles.map(r => r.urm_role_id);
|
|
135
|
+
|
|
136
|
+
if (roles.length) return roles.map((r) => r.urm_role_id);
|
|
131
137
|
}
|
|
132
|
-
|
|
138
|
+
|
|
133
139
|
if (orgId) {
|
|
134
|
-
roles = await repo
|
|
140
|
+
roles = await repo
|
|
141
|
+
.createQueryBuilder('urm')
|
|
135
142
|
.innerJoin('cr_role', 'role', 'role.id = urm.role_id')
|
|
136
143
|
.select('urm.role_id')
|
|
137
144
|
.where('urm.user_id = :userId', { userId })
|
|
@@ -139,12 +146,11 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
139
146
|
.andWhere('urm.level_id = :levelId', { levelId: orgId })
|
|
140
147
|
.andWhere('role.appcode = :appcode', { appcode })
|
|
141
148
|
.getRawMany();
|
|
142
|
-
|
|
143
|
-
if (roles.length) return roles.map(r => r.urm_role_id);
|
|
149
|
+
|
|
150
|
+
if (roles.length) return roles.map((r) => r.urm_role_id);
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
|
-
|
|
153
|
+
|
|
147
154
|
return [];
|
|
148
155
|
}
|
|
149
|
-
|
|
150
156
|
}
|
|
@@ -71,11 +71,8 @@ export class LoginController {
|
|
|
71
71
|
const currentUser = req.user.userData;
|
|
72
72
|
const currentAppcode = currentUser.appcode;
|
|
73
73
|
|
|
74
|
-
console.log(currentUser, 'DEBUG USER', data);
|
|
75
|
-
|
|
76
74
|
// If appcode is changing, validate the new level_id/level_type
|
|
77
75
|
if (data.appcode !== currentAppcode) {
|
|
78
|
-
console.log('inside if', data.appcode, currentAppcode);
|
|
79
76
|
const isValidAccess = await this.userSessionService.checkIfUserHasMapping(
|
|
80
77
|
currentUser.id,
|
|
81
78
|
data.appcode,
|
|
@@ -83,8 +80,6 @@ export class LoginController {
|
|
|
83
80
|
data.level_id,
|
|
84
81
|
);
|
|
85
82
|
|
|
86
|
-
console.log('isValidAccess', isValidAccess);
|
|
87
|
-
|
|
88
83
|
if (!isValidAccess) {
|
|
89
84
|
// If not valid, fetch the default one
|
|
90
85
|
const userMapping =
|
|
@@ -102,11 +97,6 @@ export class LoginController {
|
|
|
102
97
|
data.level_type = userMapping.level_type;
|
|
103
98
|
data.level_id = userMapping.level_id;
|
|
104
99
|
}
|
|
105
|
-
console.log(
|
|
106
|
-
data.level_type,
|
|
107
|
-
data.level_id,
|
|
108
|
-
'data.level_type, data.level_id',
|
|
109
|
-
);
|
|
110
100
|
}
|
|
111
101
|
|
|
112
102
|
return await this.userSessionService.switchCurrentLevelService(
|
|
@@ -32,7 +32,7 @@ export class EncryptUtilService {
|
|
|
32
32
|
let decrypted = decipher.update(data, 'utf8') + decipher.final('utf8');
|
|
33
33
|
return decrypted;
|
|
34
34
|
} catch (error) {
|
|
35
|
-
throw new InternalServerErrorException('
|
|
35
|
+
throw new InternalServerErrorException('Decryption process failed');
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|