rez_core 4.0.83 → 4.0.85

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": "4.0.83",
3
+ "version": "4.0.85",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -93,6 +93,8 @@ export class FieldMapperService extends EntityServiceImpl {
93
93
  userData: UserData,
94
94
  inputJson?: Record<string, any>,
95
95
  mappedEntities?: Record<string, any>,
96
+ overwrite?: boolean,
97
+ entity_data?: any
96
98
  ) {
97
99
  // Fetch field mappings for this mapper
98
100
  const fieldMappers =
@@ -129,65 +131,69 @@ export class FieldMapperService extends EntityServiceImpl {
129
131
  userData,
130
132
  );
131
133
  } else {
132
- const relations = await this.datasource.query(
133
- `SELECT target_entity_id
134
- FROM frm_entity_relation_data
135
- WHERE source_entity_type = ?
136
- AND source_entity_id = ?
137
- AND target_entity_type = ?`,
138
- [parent_type, parent_id, field.mapped_entity_type],
139
- );
134
+ if (overwrite && entity_data && entity_data[field.mapped_entity_type]) {
135
+ inMemory[entityType][filterCode] = entity_data;
136
+ } else {
137
+ const relations = await this.datasource.query(
138
+ `SELECT target_entity_id
139
+ FROM frm_entity_relation_data
140
+ WHERE source_entity_type = ?
141
+ AND source_entity_id = ?
142
+ AND target_entity_type = ?`,
143
+ [parent_type, parent_id, field.mapped_entity_type],
144
+ );
140
145
 
141
- const targetEntityIds = relations.map((r) => r.target_entity_id);
146
+ const targetEntityIds = relations.map((r) => r.target_entity_id);
142
147
 
143
- this.loggingService.log(
144
- 'package',
145
- 'fieldMapperService',
146
- 'targetEntityIds',
147
- targetEntityIds,
148
- );
148
+ this.loggingService.log(
149
+ 'package',
150
+ 'fieldMapperService',
151
+ 'targetEntityIds',
152
+ targetEntityIds,
153
+ );
149
154
 
150
- if (targetEntityIds.length > 0) {
151
- if (filterCode && filterCode !== 'default') {
152
- let filterResponse =
153
- await this.filterService.applyFilterWrapper({
154
- entity_type: entityType,
155
- savedFilterCode: filterCode,
156
- quickFilter: [
157
- {
158
- filter_attribute: 'id',
159
- filter_operator: 'equal',
160
- filter_value: targetEntityIds,
161
- filter_entity_type: entityType,
162
- },
163
- ],
164
- attributeFilter: [],
165
- loggedInUser: userData,
166
- queryParams: {},
167
- });
168
-
169
- this.loggingService.log(
170
- 'package',
171
- 'fieldMapperService',
172
- 'filterResponse',
173
- `${filterResponse}`,
174
- );
175
-
176
- inMemory[entityType][filterCode] =
177
- filterResponse?.data?.entity_list[0];
178
- } else {
179
- let firstId = targetEntityIds[0];
180
- if (mappedEntities && mappedEntities[entityType])
181
- firstId = mappedEntities[entityType];
182
- inMemory[entityType][filterCode] =
183
- await super.getResolvedEntityData(
184
- entityType,
185
- firstId,
186
- userData,
155
+ if (targetEntityIds.length > 0) {
156
+ if (filterCode && filterCode !== 'default') {
157
+ let filterResponse =
158
+ await this.filterService.applyFilterWrapper({
159
+ entity_type: entityType,
160
+ savedFilterCode: filterCode,
161
+ quickFilter: [
162
+ {
163
+ filter_attribute: 'id',
164
+ filter_operator: 'equal',
165
+ filter_value: targetEntityIds,
166
+ filter_entity_type: entityType,
167
+ },
168
+ ],
169
+ attributeFilter: [],
170
+ loggedInUser: userData,
171
+ queryParams: {},
172
+ });
173
+
174
+ this.loggingService.log(
175
+ 'package',
176
+ 'fieldMapperService',
177
+ 'filterResponse',
178
+ `${filterResponse}`,
187
179
  );
180
+
181
+ inMemory[entityType][filterCode] =
182
+ filterResponse?.data?.entity_list[0];
183
+ } else {
184
+ let firstId = targetEntityIds[0];
185
+ if (mappedEntities && mappedEntities[entityType])
186
+ firstId = mappedEntities[entityType];
187
+ inMemory[entityType][filterCode] =
188
+ await super.getResolvedEntityData(
189
+ entityType,
190
+ firstId,
191
+ userData,
192
+ );
193
+ }
194
+ } else {
195
+ inMemory[entityType][filterCode] = null;
188
196
  }
189
- } else {
190
- inMemory[entityType][filterCode] = null;
191
197
  }
192
198
  }
193
199
  }
@@ -35,7 +35,9 @@ export class CommTemplateController {
35
35
 
36
36
  @Post('/resolve-message')
37
37
  @HttpCode(HttpStatus.OK)
38
- async resolveMessage(@Body() payload: any) {
39
- return await this.commTemplateService.getResolvedTemplateMsg(payload);
38
+ async resolveMessage(@Body() payload: any,
39
+ @Req() req: Request & { user: any },) {
40
+ const loggedInUser = req.user.userData;
41
+ return await this.commTemplateService.getResolvedTemplateMsg(payload, loggedInUser);
40
42
  }
41
43
  }
@@ -125,7 +125,7 @@ export class CommTemplateService extends EntityServiceImpl {
125
125
  return response;
126
126
  }
127
127
 
128
- async getResolvedTemplateMsg(payload: any) {
128
+ async getResolvedTemplateMsg(payload: any, loggedInUser: UserData) {
129
129
  let commTemplate = await this.commTemplateRepository.findByCodeAndLevelIdAndLevelTypeAndAppCode(
130
130
  payload.template_code,
131
131
  payload.level_id,
@@ -134,7 +134,7 @@ export class CommTemplateService extends EntityServiceImpl {
134
134
  );
135
135
 
136
136
  let variables;
137
- if (commTemplate && ! commTemplate.template_id) {
137
+ if (commTemplate && !commTemplate.template_id) {
138
138
 
139
139
  if (commTemplate.mapper_id) {
140
140
  variables = await this.fieldMapperService.resolveData(
@@ -142,7 +142,11 @@ export class CommTemplateService extends EntityServiceImpl {
142
142
  'LOOKUP',
143
143
  payload.entity_type,
144
144
  payload.entity_id,
145
- {} as any,
145
+ loggedInUser,
146
+ undefined,
147
+ undefined,
148
+ payload.overwrite || false,
149
+ payload.entity_data || null,
146
150
  );
147
151
  }
148
152
 
@@ -170,7 +174,7 @@ export class CommTemplateService extends EntityServiceImpl {
170
174
  };
171
175
  }
172
176
  } else {
173
- throw new BadRequestException("Editing is disabled for external templates");
177
+ throw new BadRequestException('Editing is disabled for external templates');
174
178
  }
175
179
  }
176
180
  }