rez_core 2.1.26 → 2.1.28

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.26",
3
+ "version": "2.1.28",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -25,6 +25,7 @@ export class FilterService {
25
25
  column: string | undefined,
26
26
  whereClauses: { query: string; params: Record<string, any> }[],
27
27
  ) {
28
+ console.log('GTETABCOUNTS', tableName, column, whereClauses);
28
29
  if (!column) return [];
29
30
 
30
31
  let whereSQL = '';
@@ -95,6 +96,8 @@ export class FilterService {
95
96
  'LIST',
96
97
  );
97
98
 
99
+ console.log(getTableMeta, 'GETTABLEMETA');
100
+
98
101
  if (!getTableMeta) {
99
102
  throw new BadRequestException(
100
103
  `Table meta not found for entity_type: ${entity_type}`,
@@ -107,6 +110,7 @@ export class FilterService {
107
110
  true,
108
111
  );
109
112
 
113
+ console.log(getTableColumnMeta, 'GETTABLECOLUMNMETA');
110
114
  // const attributeMeta =
111
115
  // await this.attributeMasterService.findAttributesByMappedEntityType(
112
116
  // entity_type,
@@ -119,6 +123,7 @@ export class FilterService {
119
123
  {} as Record<string, any>,
120
124
  );
121
125
 
126
+ console.log(attributeMetaMap, 'ATTRIBUTEMETAMAP');
122
127
  // Get and parse filters
123
128
  const savedFilters = await this.getSavedFilters(savedFilterCode);
124
129
  const baseFilters = [
@@ -128,7 +133,7 @@ export class FilterService {
128
133
  ];
129
134
 
130
135
  const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
131
-
136
+ console.log(baseWhere, 'BASEWHERE', level_type, level_id);
132
137
  if (level_type && level_id) {
133
138
  baseWhere.push({
134
139
  query: 'e.level_type = :level_type AND e.level_id = :level_id',
@@ -139,7 +144,9 @@ export class FilterService {
139
144
  });
140
145
  }
141
146
 
147
+ console.log('OUSTSIDE SKIP');
142
148
  if (this.skipLevelFilterEntities.includes(entity_type)) {
149
+ console.log('INSIDE SKIP');
143
150
  baseWhere.push({
144
151
  query: 'e.appcode = :appcode',
145
152
  params: { appcode },
@@ -153,12 +160,15 @@ export class FilterService {
153
160
  [user_id, entity_type],
154
161
  );
155
162
 
163
+ console.log('LAYOUTPREFERNECE', layoutPreference);
164
+
156
165
  // Extract layout preference
157
166
  const layout = layoutPreference?.[0]?.layout_json?.quick_tab || {};
158
167
  let showList = layout?.show_list?.map((val) => val.toLowerCase()) || [];
159
168
 
160
169
  let allTabs;
161
170
  if (layout.attribute) {
171
+ console.log('IN LAYOUT');
162
172
  allTabs = await this.gettab_value_counts(
163
173
  getTableMeta.data_source,
164
174
  layout.attribute,
@@ -210,6 +220,8 @@ export class FilterService {
210
220
  filteredTabs = allTabs;
211
221
  }
212
222
 
223
+ console.log(allTabs, 'ALLTABSE');
224
+
213
225
  const dataWhere = [...baseWhere];
214
226
 
215
227
  if (tabs?.columnName && tabs?.value) {
@@ -28,7 +28,7 @@ export class LoginService {
28
28
 
29
29
  async login(email: string, password: string) {
30
30
  const user = await this.userService.findByEmailId(email);
31
-
31
+
32
32
  if (!user) {
33
33
  return {
34
34
  success: false,
@@ -36,7 +36,7 @@ export class LoginService {
36
36
  type: 'email',
37
37
  };
38
38
  }
39
-
39
+
40
40
  if (user.status !== 'ACTIVE') {
41
41
  return {
42
42
  success: false,
@@ -44,13 +44,13 @@ export class LoginService {
44
44
  type: 'email',
45
45
  };
46
46
  }
47
-
47
+
48
48
  const encryptedPassword = EncryptUtilService.encryptGCM(
49
49
  password,
50
50
  this.masterKey,
51
51
  this.masterIv,
52
52
  );
53
-
53
+
54
54
  if (encryptedPassword !== user.password) {
55
55
  return {
56
56
  success: false,
@@ -58,64 +58,67 @@ export class LoginService {
58
58
  type: 'password',
59
59
  };
60
60
  }
61
-
61
+
62
62
  let defaultAccess;
63
-
64
- if (!user.last_level_type && !user.last_level_id) {
65
- const roleMappings = await this.userRoleMappingRepository.find({
66
- where: {
67
- user_id: user.id,
68
- appcode: user.last_app_access,
69
- },
70
- });
71
-
72
- if (!roleMappings.length) {
73
- throw new BadRequestException(
74
- 'User does not have any access mapped for this app.',
75
- );
76
- }
77
-
78
- // ✅ Pick default access based on priority
79
- const priority = { org: 1, sch: 2, brn: 3 };
80
- defaultAccess = roleMappings.sort(
81
- (a, b) => priority[a.level_type] - priority[b.level_type],
82
- )[0];
83
-
84
- if ((defaultAccess.level_type, defaultAccess.level_id)) {
85
- await this.userService.setLastLevelTypeAndId(
86
- user.id,
87
- defaultAccess.level_type,
88
- defaultAccess.level_id,
89
- );
90
- }
91
- } else {
92
- defaultAccess = {
93
- level_type: user.last_level_type,
94
- level_id: user.last_level_id,
95
- };
96
- }
97
-
98
- //appcode
99
-
100
63
  let appcode = user.last_app_access;
101
-
64
+
102
65
  if (!appcode) {
103
66
  appcode = 'ADM';
104
67
  await this.userService.setDefaultLastAccess(user.id, appcode);
105
68
  }
106
-
69
+
70
+ // ✅ Always fetch role mappings for the user + app
71
+ const roleMappings = await this.userRoleMappingRepository.find({
72
+ where: {
73
+ user_id: user.id,
74
+ appcode,
75
+ },
76
+ });
77
+
78
+ if (!roleMappings.length) {
79
+ throw new BadRequestException(
80
+ 'User does not have any access mapped for this app.',
81
+ );
82
+ }
83
+
84
+ // 🔍 If user.last_level_type & level_id exist, validate them against URM
85
+ const validURM = roleMappings.find(
86
+ (r) =>
87
+ r.level_type === user.last_level_type &&
88
+ r.level_id === user.last_level_id,
89
+ );
90
+
91
+ if (user.last_level_type && user.last_level_id && validURM) {
92
+ defaultAccess = {
93
+ level_type: user.last_level_type,
94
+ level_id: user.last_level_id,
95
+ };
96
+ } else {
97
+ // ❌ Fallback: Pick default based on priority
98
+ const priority = { org: 1, sch: 2, brn: 3 };
99
+ defaultAccess = roleMappings.sort(
100
+ (a, b) => priority[a.level_type] - priority[b.level_type],
101
+ )[0];
102
+
103
+ await this.userService.setLastLevelTypeAndId(
104
+ user.id,
105
+ defaultAccess.level_type,
106
+ defaultAccess.level_id,
107
+ );
108
+ }
109
+
107
110
  const token = await this.userSessionService.createSession(user, appcode, {
108
111
  level_type: defaultAccess.level_type,
109
112
  level_id: defaultAccess.level_id,
110
113
  });
111
-
114
+
112
115
  if (user.is_firstlogin === 1) {
113
116
  user.invitation_status = 'ACCEPTED';
114
117
  user.is_firstlogin = 0;
115
118
  const { password, ...userWithoutPassword } = user;
116
119
  await this.userService.updateEntity(userWithoutPassword, user);
117
120
  }
118
-
121
+
119
122
  return {
120
123
  success: true,
121
124
  accessToken: token,
@@ -124,6 +127,7 @@ export class LoginService {
124
127
  level_id: defaultAccess.level_id,
125
128
  };
126
129
  }
130
+
127
131
 
128
132
  async loginWithGoogle(email: string, name) {
129
133
  let user = await this.userService.findByEmailId(email);