rez_core 2.1.27 → 2.1.29

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.27",
3
+ "version": "2.1.29",
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) {
@@ -13,6 +13,8 @@ import {
13
13
  UseGuards,
14
14
  Inject,
15
15
  Request,
16
+ InternalServerErrorException,
17
+ NotFoundException,
16
18
  } from '@nestjs/common';
17
19
  import { EntityServiceImpl } from '../service/entity-service-impl.service';
18
20
  import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
@@ -63,56 +65,36 @@ export class EntityController {
63
65
  async create(
64
66
  @Body() entityData: BaseEntity,
65
67
  @Query('entity_type') entityType: string,
66
- @Res() res: Response,
67
68
  @Req() req: Request & { user: any },
68
69
  ) {
69
- try {
70
- let loggedInUser = req.user.userData;
71
- let appcode = req.user.userData.appcode;
72
- if (!entityType) {
73
- return res.status(HttpStatus.BAD_REQUEST).json({
74
- success: false,
75
- error: 'Query parameter "entity_type" is required',
76
- });
77
- }
78
- const entityMaster =
79
- await this.entityMasterService.getEntityData(entityType);
70
+ let loggedInUser = req.user.userData;
71
+ let appcode = req.user.userData.appcode;
80
72
 
81
- const entityService =
82
- await this.reflectionHelper.getBean<EntityServiceImpl>(
83
- entityMaster.entity_service,
84
- );
85
-
86
- if (!entityService) {
87
- return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
88
- success: false,
89
- error: `No service found for Entity Type ${entityType}`,
90
- });
91
- }
92
- const createdEntity = await entityService.createEntity(
93
- entityData,
94
- loggedInUser as UserData,
95
- null,
96
- appcode,
73
+ if (!entityType) {
74
+ throw new BadRequestException(
75
+ `Query parameter "entity_type" is required`,
97
76
  );
77
+ }
98
78
 
99
- if (!createdEntity) {
100
- return res.status(HttpStatus.BAD_REQUEST).json({
101
- success: false,
102
- error: createdEntity?.error || 'Entity creation failed',
103
- });
104
- }
79
+ const entityMaster =
80
+ await this.entityMasterService.getEntityData(entityType);
81
+ const entityService =
82
+ await this.reflectionHelper.getBean<EntityServiceImpl>(
83
+ entityMaster.entity_service,
84
+ );
105
85
 
106
- return res.status(HttpStatus.OK).json({
107
- success: true,
108
- data: createdEntity,
109
- });
110
- } catch (error) {
111
- return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
112
- success: false,
113
- error: error.message || 'Internal server error',
114
- });
86
+ if (!entityService) {
87
+ throw new InternalServerErrorException(
88
+ `No service found for Entity Type ${entityType}`,
89
+ );
115
90
  }
91
+
92
+ return entityService.createEntity(
93
+ entityData,
94
+ loggedInUser as UserData,
95
+ null,
96
+ appcode,
97
+ );
116
98
  }
117
99
 
118
100
  @Post('update/:id')
@@ -120,68 +102,44 @@ export class EntityController {
120
102
  @Param('id') id: number,
121
103
  @Body() entityData: BaseEntity,
122
104
  @Query('entity_type') entityType: string,
123
- @Res() response: Response,
124
105
  @Req() req: Request & { user: any },
125
106
  ) {
126
- try {
127
- let loggedInUser = req.user.userData;
128
- // let loggedInUser = await this.entityService.getEntityData(
129
- // ENTITYTYPE_USER,
130
- // requestedUser.userId,
131
- // );
132
- if (!entityType) {
133
- return response.status(HttpStatus.BAD_REQUEST).json({
134
- success: false,
135
- error: 'Query parameter "entity_type" is required',
136
- });
137
- }
107
+ const loggedInUser = req.user.userData;
138
108
 
139
- const entityMaster =
140
- await this.entityMasterService.getEntityData(entityType);
141
-
142
- const entityService =
143
- await this.reflectionHelper.getBean<EntityServiceImpl>(
144
- entityMaster.entity_service,
145
- );
146
-
147
- if (!entityService) {
148
- return response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
149
- success: false,
150
- error: `No service found for entity_type "${entityType}"`,
151
- });
152
- }
109
+ if (!entityType) {
110
+ throw new BadRequestException(
111
+ 'Query parameter "entity_type" is required',
112
+ );
113
+ }
153
114
 
154
- let existingEntity = await entityService.getEntityData(entityType, id);
155
- if (!existingEntity) {
156
- return response.status(HttpStatus.NOT_FOUND).json({
157
- success: false,
158
- error: `No entity found for id "${id}"`,
159
- });
160
- }
161
- // let mergeEntity = JsonUtil.merge(existingEntity, entityData);
115
+ const entityMaster =
116
+ await this.entityMasterService.getEntityData(entityType);
162
117
 
163
- const updatedEntity = await entityService.updateEntity(
164
- entityData,
165
- loggedInUser as UserData,
118
+ const entityService =
119
+ await this.reflectionHelper.getBean<EntityServiceImpl>(
120
+ entityMaster.entity_service,
166
121
  );
167
122
 
168
- if (!updatedEntity) {
169
- return response.status(HttpStatus.BAD_REQUEST).json({
170
- success: false,
171
- error: updatedEntity?.error || 'Entity creation failed',
172
- });
173
- }
123
+ if (!entityService) {
124
+ throw new InternalServerErrorException(
125
+ `No service found for entity_type "${entityType}"`,
126
+ );
127
+ }
174
128
 
175
- return response.status(HttpStatus.OK).json({
176
- success: true,
177
- data: updatedEntity.data,
178
- });
179
- } catch (error) {
180
- return response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
181
- success: false,
182
- error: error.message || 'Internal server error',
183
- });
129
+ const existingEntity = await entityService.getEntityData(entityType, id);
130
+ if (!existingEntity) {
131
+ throw new NotFoundException(`No entity found for id "${id}"`);
184
132
  }
133
+
134
+ const updatedEntity = await entityService.updateEntity(
135
+ entityData,
136
+ loggedInUser as UserData,
137
+ );
138
+
139
+ return {
140
+ success: true,
141
+ data: updatedEntity.data,
142
+ };
185
143
  }
186
144
 
187
145
  @Post('getFilteredDataWithTabs/:entity_type')