rez_core 1.0.53 → 1.0.55

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": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -125,7 +125,7 @@ export class MediaDataService extends EntityServiceImpl {
125
125
  Key: mediaData.media_url,
126
126
  Expires: 60 * 5, // URL valid for 5 mins
127
127
  });
128
- return {signedUrl,fileName: mediaData.file_name};
128
+ return {signedUrl,fileName: mediaData.file_name,id:mediaData.id};
129
129
  } catch (error) {
130
130
  console.error('Error generating signed URL for media:', error);
131
131
  throw new Error('Failed to generate signed URL');
@@ -176,17 +176,24 @@ export class ModuleAccessRepository {
176
176
  throw new BadRequestException('Role name already exists.');
177
177
  }
178
178
 
179
- const code = this.clockIDGenService.idGenerator('ROL');
179
+ // 1. Create the role without the code (code will be updated after ID is generated)
180
180
  const newRole = this.roleRepo.create({
181
181
  name,
182
- code,
183
182
  description,
184
183
  status: status || 'ACTIVE',
185
184
  created_by: loggedInUser.id,
186
185
  created_date: new Date(),
187
186
  });
188
187
 
189
- const savedRole = await this.roleRepo.save(newRole);
188
+ // 2. Save the role to get the generated ID
189
+ const savedRole = await this.roleRepo.save(newRole); // ID is now available
190
+
191
+ // 3. Generate the code using the saved ID
192
+ const generatedCode = `ROL${savedRole.id}`;
193
+
194
+ // 4. Update the role with the generated code
195
+ savedRole.code = generatedCode;
196
+ await this.roleRepo.save(savedRole); // Update only the code
190
197
 
191
198
  if (copyFromRoleId) {
192
199
  const sourceRole = await this.roleRepo.findOne({
@@ -200,7 +207,7 @@ export class ModuleAccessRepository {
200
207
  });
201
208
  const clonedPermissions = sourcePermissions.map((perm) =>
202
209
  this.moduleAccessRepo.create({
203
- role_code: code,
210
+ role_code: generatedCode,
204
211
  module_code: perm.module_code,
205
212
  action_type: perm.action_type,
206
213
  access_flag: perm.access_flag,
@@ -303,4 +310,4 @@ export class ModuleAccessRepository {
303
310
  const existingRole = await query.getOne();
304
311
  return !!existingRole;
305
312
  }
306
- }
313
+ }