rez_core 2.1.63 → 2.1.65

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": "2.1.63",
3
+ "version": "2.1.65",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -11,4 +11,7 @@ export class LayoutPreference extends BaseEntity {
11
11
 
12
12
  @Column({ length: 50, nullable: true, type: 'varchar' })
13
13
  mapped_entity_type: string;
14
+
15
+ @Column({ nullable: true, type: 'json' })
16
+ navigation_tabs_json: any;
14
17
  }
@@ -32,6 +32,9 @@ export class ListMasterRepository {
32
32
  );
33
33
  }
34
34
 
35
+ // sort by created_at in descending order
36
+ qb.orderBy('item.created_date', 'DESC');
37
+
35
38
  return await qb.getMany();
36
39
  }
37
40
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BadRequestException,
2
3
  forwardRef,
3
4
  Inject,
4
5
  Injectable,
@@ -64,7 +65,9 @@ export class ListMasterItemService {
64
65
  const name = item.name?.trim();
65
66
  const code = item.code?.trim();
66
67
 
67
- if (!name) continue; // Skip invalid item
68
+ if (!name) {
69
+ throw new BadRequestException('Name is required and cannot be empty');
70
+ }
68
71
 
69
72
  let existingItem;
70
73
 
@@ -238,6 +238,18 @@ export class ListMasterService {
238
238
 
239
239
  // createEntity method
240
240
  async createEntity(entityData: any, loggedInUser: UserData): Promise<any> {
241
+ // Trim and validate name and code
242
+ const name = entityData.name?.trim();
243
+ const code = entityData.code?.trim();
244
+
245
+ if (!name || !code) {
246
+ throw new BadRequestException(
247
+ 'Name and Code are required and cannot be empty',
248
+ );
249
+ }
250
+
251
+ entityData.name = name;
252
+ entityData.code = code;
241
253
  entityData.is_factory = entityData.is_factory || 0;
242
254
  entityData.source = entityData.source || 'master';
243
255
  entityData.status = entityData.status || 'ACTIVE';
@@ -245,16 +257,27 @@ export class ListMasterService {
245
257
  entityData.sort_by = entityData.sort_by || 'asc';
246
258
  entityData.organization_id = loggedInUser.organization_id;
247
259
 
248
- // check if a list master with the same type already exists
249
- const existingListMaster = await this.listMasterRepo.findOneByCondition({
250
- name: entityData.name,
251
- code: entityData.code,
260
+ // Check for duplicate name
261
+ const nameExists = await this.listMasterRepo.findOneByCondition({
262
+ name,
263
+ organization_id: loggedInUser.organization_id,
264
+ });
265
+
266
+ if (nameExists) {
267
+ throw new BadRequestException(
268
+ 'A List Master with the same name already exists',
269
+ );
270
+ }
271
+
272
+ // Check for duplicate code
273
+ const codeExists = await this.listMasterRepo.findOneByCondition({
274
+ code,
252
275
  organization_id: loggedInUser.organization_id,
253
276
  });
254
277
 
255
- if (existingListMaster) {
278
+ if (codeExists) {
256
279
  throw new BadRequestException(
257
- 'List master with the same name already exists',
280
+ 'A List Master with the same code already exists',
258
281
  );
259
282
  }
260
283
 
@@ -1,3 +1,4 @@
1
+ import { get } from 'http';
1
2
  import { UserSession } from '../entity/user-session.entity';
2
3
  import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
3
4
  import { BadRequestException, Injectable } from '@nestjs/common';
@@ -7,6 +8,7 @@ import { ConfigService } from '@nestjs/config';
7
8
  import { UserRoleMappingService } from './user-role-mapping.service';
8
9
  import { DataSource } from 'typeorm';
9
10
  import { UserRoleMapping } from '../entity/user-role-mapping.entity';
11
+ import { UserData } from '../entity/user.entity';
10
12
 
11
13
  @Injectable()
12
14
  export class UserSessionService {
@@ -84,7 +86,19 @@ export class UserSessionService {
84
86
  appcode: data.appcode,
85
87
  };
86
88
 
87
- if (payload.organization_id === 1 && payload.level_type === 'ORG') {
89
+ let getUserDetails;
90
+
91
+ if (currentUser) {
92
+ // Check if user has any role mappings for the given appcode
93
+ getUserDetails = await this.dataSource.query(
94
+ `
95
+ SELECT * from cr_user where id = ?
96
+ `,
97
+ [currentUser.id],
98
+ );
99
+ }
100
+
101
+ if (getUserDetails.organization_id === 1 && payload.level_type === 'ORG') {
88
102
  payload.organization_id = payload.level_id;
89
103
  }
90
104