rez_core 5.0.131 → 5.0.134

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.131",
3
+ "version": "5.0.134",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -13,9 +13,9 @@ export class BullConfigService implements SharedBullConfigurationFactory {
13
13
  createSharedConfiguration(): BullModuleOptions {
14
14
  return {
15
15
  redis: {
16
- host: this.configService.get<string>('REDIS_HOST', 'localhost'),
16
+ host: this.configService.get<string>('REDIS_HOST', '43.205.35.45'),
17
17
  port: this.configService.get<number>('REDIS_PORT', 6379),
18
- password: this.configService.get<string>('REDIS_PASSWORD'),
18
+ password: this.configService.get<string>('REDIS_PASSWORD','Rezolut123'),
19
19
  db: this.configService.get<number>('REDIS_DB', 0),
20
20
  // Enable offline queue to handle Redis disconnections
21
21
  enableOfflineQueue: true,
@@ -31,4 +31,7 @@ export class AppMaster extends BaseEntity {
31
31
 
32
32
  @Column({ name: 'version', type: 'varchar', nullable: true })
33
33
  version: string;
34
+
35
+ @Column({ name: 'show_in_ui', type: 'boolean', nullable: true })
36
+ show_in_ui: string;
34
37
  }
@@ -71,18 +71,18 @@ export class EntityDynamicService {
71
71
  // -------------------------------------------------------
72
72
  // AUTO-CODE GENERATION (POSTGRES SAFE)
73
73
  // -------------------------------------------------------
74
- if (!entityData.code && entityData.entity_type) {
74
+ const entityMaster = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.organization_id)
75
+
76
+ if (!entityData.code && entityData.entity_type && entityMaster) {
75
77
  // Extract integer suffix
76
- const result = await this.entityManager.query(
77
- `
78
- SELECT MAX(id) AS max_seq_no
79
- FROM ${tableName}
80
- WHERE entity_type = $1
81
- `,
82
- [entityData.entity_type],
83
- );
78
+ const repo = this.reflectionHelper.getRepoService(entityMaster.entity_data_class);
79
+
80
+ const result = await repo
81
+ .createQueryBuilder()
82
+ .select('MAX(id)', 'seq_no')
83
+ .getRawOne();
84
84
 
85
- let maxSeq = Number(result?.[0]?.max_seq_no) || 0;
85
+ let maxSeq = Number(result?.max_seq_no) || 0;
86
86
  maxSeq++;
87
87
  entityData.code = `${entityData.entity_type}${maxSeq}`;
88
88
  }
@@ -19,10 +19,10 @@ export class UserSessionService {
19
19
  private readonly clockIDGenService: ClockIDGenService,
20
20
  private configService: ConfigService,
21
21
  @InjectRepository(UserData)
22
- private readonly userDataRepository:Repository<UserData>,
22
+ private readonly userDataRepository: Repository<UserData>,
23
23
  @InjectRepository(UserRoleMapping)
24
- private readonly userRoleMappingRepository:Repository<UserRoleMapping>,
25
- private readonly reflectionHelper: ReflectionHelper
24
+ private readonly userRoleMappingRepository: Repository<UserRoleMapping>,
25
+ private readonly reflectionHelper: ReflectionHelper,
26
26
  ) {}
27
27
  async createSession(user, appcode?: string, accessInfo?: any) {
28
28
  const sessionToken = this.clockIDGenService.idGenerator('SES');
@@ -98,8 +98,8 @@ export class UserSessionService {
98
98
  getUserDetails = await this.userDataRepository.findOne({
99
99
  where: {
100
100
  id: currentUser.id,
101
- }
102
- })
101
+ },
102
+ });
103
103
  }
104
104
 
105
105
  if (getUserDetails?.organization_id == 1 && payload.level_type == 'ORG') {
@@ -122,56 +122,82 @@ export class UserSessionService {
122
122
  }
123
123
 
124
124
  async checkIfUserHasMapping(
125
- userId: number,
126
- appcode: string,
127
- levelType: string,
128
- levelId: string,
129
- ): Promise<boolean> {
130
-
131
- const count = await this.userRoleMappingRepository
132
- .createQueryBuilder("urm")
133
- .where("urm.user_id = :userId", { userId })
134
- .andWhere("urm.appcode = :appcode", { appcode })
135
- .andWhere("urm.level_type = :levelType", { levelType })
136
- .andWhere("urm.level_id = :levelId", { levelId })
137
- .getCount();
138
-
139
- return count > 0;
140
- }
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
+
141
154
 
142
155
  async getUserRoleMappingForApp(userId: number, appcode: string) {
143
- const mapping = await this.userRoleMappingRepository
144
- .createQueryBuilder('sso_user_role_mapping')
145
- .where('sso_user_role_mapping.user_id = :userId', { userId })
146
- .andWhere('sso_user_role_mapping.appcode = :appcode', { appcode })
147
- .getOne();
148
-
149
- // If not found or is already ORG/SCH, return directly
150
- if (!mapping || mapping.level_type !== 'BRN') {
151
- return mapping;
152
- }
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
+ }
153
180
 
154
- //DONE
155
- // If BRN, resolve first SCH under this brand
156
- const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
157
- const schools = await schoolRepo.findOne({
158
- where: {
159
- brand_id: mapping.level_id
160
- },
161
- order: {
162
- id: "ASC"
163
- }
164
- });
181
+ // Resolve SCH under BRN
182
+ const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
165
183
 
166
- if (schools) {
167
- return {
168
- ...mapping,
169
- level_type: 'SCH',
170
- level_id: schools.id,
171
- };
172
- }
184
+ const school = await schoolRepo.findOne({
185
+ where: {
186
+ brand_id: mapping.level_id,
187
+ },
188
+ order: { id: 'ASC' },
189
+ });
173
190
 
174
- // No SCH found under BRN
175
- return null;
191
+ if (school) {
192
+ return {
193
+ ...mapping,
194
+ level_type: 'SCH',
195
+ level_id: school.id,
196
+ };
176
197
  }
198
+
199
+ // If no SCH found
200
+ return null;
201
+ }
202
+
177
203
  }
@@ -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>