rez_core 5.0.135 → 5.0.136

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.135",
3
+ "version": "5.0.136",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -71,6 +71,7 @@ export class UserSessionService {
71
71
  await this.userSessionRepository.saveSession(userSession);
72
72
  }
73
73
 
74
+
74
75
  async switchCurrentLevelService(
75
76
  currentUser: any,
76
77
  data: any,
@@ -122,82 +123,78 @@ export class UserSessionService {
122
123
  }
123
124
 
124
125
  async checkIfUserHasMapping(
125
- userId: number,
126
- appcode: string,
127
- levelType: string,
128
- levelId: string,
129
- ): Promise<boolean> {
130
- // Get repositories dynamically via reflectionHelper
131
- const userRoleMappingRepo =
132
- this.reflectionHelper.getRepoService('UserRoleMapping');
133
- const appMasterRepo =
134
- this.reflectionHelper.getRepoService('AppMaster');
135
-
136
- // Use QueryBuilder with proper aliases
137
- const count = await userRoleMappingRepo
138
- .createQueryBuilder('urm')
139
- .innerJoin(
140
- appMasterRepo.metadata.tableName,
141
- 'app',
142
- 'app.appcode = urm.appcode',
143
- )
144
- .where('urm.user_id = :userId', { userId })
145
- .andWhere('urm.appcode = :appcode', { appcode })
146
- .andWhere('urm.level_type = :levelType', { levelType })
147
- .andWhere('urm.level_id = :levelId', { levelId })
148
- .andWhere('app.show_in_ui = true')
149
- .getCount();
150
-
151
- return count > 0;
152
- }
153
-
126
+ userId: number,
127
+ appcode: string,
128
+ levelType: string,
129
+ levelId: string,
130
+ ): Promise<boolean> {
131
+ // Get repositories dynamically via reflectionHelper
132
+ const userRoleMappingRepo =
133
+ this.reflectionHelper.getRepoService('UserRoleMapping');
134
+ const appMasterRepo = this.reflectionHelper.getRepoService('AppMaster');
135
+
136
+ // Use QueryBuilder with proper aliases
137
+ const count = await userRoleMappingRepo
138
+ .createQueryBuilder('urm')
139
+ .innerJoin(
140
+ appMasterRepo.metadata.tableName,
141
+ 'app',
142
+ 'app.appcode = urm.appcode',
143
+ )
144
+ .where('urm.user_id = :userId', { userId })
145
+ .andWhere('urm.appcode = :appcode', { appcode })
146
+ .andWhere('urm.level_type = :levelType', { levelType })
147
+ .andWhere('urm.level_id = :levelId', { levelId })
148
+ .andWhere('app.show_in_ui = true')
149
+ .getCount();
150
+
151
+ return count > 0;
152
+ }
154
153
 
155
154
  async getUserRoleMappingForApp(userId: number, appcode: string) {
156
- // Get repos dynamically
157
- const userRoleMappingRepo =
158
- this.reflectionHelper.getRepoService('UserRoleMapping');
159
-
160
- const appMasterRepo =
161
- this.reflectionHelper.getRepoService('AppMaster');
162
-
163
- // Build dynamic join using metadata
164
- const mapping = await userRoleMappingRepo
165
- .createQueryBuilder('urm')
166
- .innerJoin(
167
- appMasterRepo.metadata.tableName,
168
- 'app',
169
- 'app.appcode = urm.appcode',
170
- )
171
- .where('urm.user_id = :userId', { userId })
172
- .andWhere('urm.appcode = :appcode', { appcode })
173
- .andWhere('app.show_in_ui = true')
174
- .getOne();
175
-
176
- // If not found or level_type is not BRN → return
177
- if (!mapping || mapping.level_type !== 'BRN') {
178
- return mapping;
179
- }
155
+ const userRoleMappingRepo =
156
+ this.reflectionHelper.getRepoService('UserRoleMapping');
157
+ const appMasterRepo = this.reflectionHelper.getRepoService('AppMaster');
158
+
159
+ const mapping = await userRoleMappingRepo
160
+ .createQueryBuilder('urm')
161
+ .innerJoin(
162
+ appMasterRepo.metadata.tableName,
163
+ 'app',
164
+ 'app.appcode = urm.appcode',
165
+ )
166
+ .where('urm.user_id = :userId', { userId })
167
+ .andWhere('urm.appcode = :appcode', { appcode })
168
+ .andWhere('app.show_in_ui = true')
169
+ .getOne();
170
+
171
+ if (!mapping) {
172
+ throw new BadRequestException(
173
+ `User does not have visible access to app ${appcode}`,
174
+ );
175
+ }
180
176
 
181
- // Resolve SCH under BRN
182
- const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
177
+ if (mapping.level_type !== 'BRN') {
178
+ return mapping;
179
+ }
183
180
 
184
- const school = await schoolRepo.findOne({
185
- where: {
186
- brand_id: mapping.level_id,
187
- },
188
- order: { id: 'ASC' },
189
- });
181
+ // Resolve SCH under brand
182
+ const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
183
+ const school = await schoolRepo.findOne({
184
+ where: { brand_id: mapping.level_id },
185
+ order: { id: 'ASC' },
186
+ });
187
+
188
+ if (!school) {
189
+ throw new BadRequestException(
190
+ `No schools found under brand ${mapping.level_id}`,
191
+ );
192
+ }
190
193
 
191
- if (school) {
192
194
  return {
193
195
  ...mapping,
194
196
  level_type: 'SCH',
195
197
  level_id: school.id,
196
198
  };
197
199
  }
198
-
199
- // If no SCH found
200
- return null;
201
- }
202
-
203
200
  }
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </component>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myConfigurationMode" value="AUTOMATIC" />
5
- </component>
6
- </project>