rez_core 2.1.25 → 2.1.27

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.25",
3
+ "version": "2.1.27",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -153,16 +153,25 @@ export class FilterService {
153
153
  [user_id, entity_type],
154
154
  );
155
155
 
156
- const allTabs = await this.gettab_value_counts(
157
- getTableMeta.data_source,
158
- tabs?.columnName,
159
- baseWhere,
160
- );
161
-
162
156
  // Extract layout preference
163
157
  const layout = layoutPreference?.[0]?.layout_json?.quick_tab || {};
164
158
  let showList = layout?.show_list?.map((val) => val.toLowerCase()) || [];
165
159
 
160
+ let allTabs;
161
+ if (layout.attribute) {
162
+ allTabs = await this.gettab_value_counts(
163
+ getTableMeta.data_source,
164
+ layout.attribute,
165
+ baseWhere,
166
+ );
167
+ } else {
168
+ allTabs = await this.gettab_value_counts(
169
+ getTableMeta.data_source,
170
+ tabs?.columnName,
171
+ baseWhere,
172
+ );
173
+ }
174
+
166
175
  let filteredTabs;
167
176
 
168
177
  if (showList?.length > 0) {
@@ -201,20 +210,42 @@ export class FilterService {
201
210
  filteredTabs = allTabs;
202
211
  }
203
212
 
204
- // Add tab.value filter only if present
205
213
  const dataWhere = [...baseWhere];
214
+
206
215
  if (tabs?.columnName && tabs?.value) {
207
216
  const tabAttrMeta = attributeMetaMap[tabs.columnName];
208
- const tabCondition = this.buildCondition(
209
- {
210
- filter_attribute: tabs.columnName,
211
- filter_operator: 'equal',
212
- filter_value: tabs.value,
213
- },
214
- tabAttrMeta,
215
- );
216
- if (tabCondition) {
217
- if (tabs.value.toLowerCase() !== 'all') dataWhere.push(tabCondition);
217
+ const tabValue = tabs.value.toLowerCase();
218
+
219
+ if (tabValue === 'others') {
220
+ const valuesToExclude = showList.filter((v) => v !== 'all');
221
+ if (valuesToExclude.length > 0) {
222
+ valuesToExclude.forEach((value) => {
223
+ const tabCondition = this.buildCondition(
224
+ {
225
+ filter_attribute: tabs.columnName,
226
+ filter_operator: 'not_equal',
227
+ filter_value: value,
228
+ },
229
+ tabAttrMeta,
230
+ );
231
+ if (tabCondition) {
232
+ dataWhere.push(tabCondition);
233
+ }
234
+ });
235
+ }
236
+ } else if (tabValue !== 'all') {
237
+ // Normal case: filter by equality
238
+ const tabCondition = this.buildCondition(
239
+ {
240
+ filter_attribute: tabs.columnName,
241
+ filter_operator: 'equal',
242
+ filter_value: tabs.value,
243
+ },
244
+ tabAttrMeta,
245
+ );
246
+ if (tabCondition) {
247
+ dataWhere.push(tabCondition);
248
+ }
218
249
  }
219
250
  }
220
251
 
@@ -15,6 +15,8 @@ export class LayoutPreferenceService extends EntityServiceImpl {
15
15
  }
16
16
 
17
17
  async createEntity(entityData: BaseEntity, loggedInUser: UserData | null) {
18
+ console.log('lap api called', entityData);
19
+
18
20
  const { mapped_entity_type } = entityData as any;
19
21
  const userId = loggedInUser?.id;
20
22
 
@@ -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);