rez_core 3.1.98 → 3.1.100

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": "3.1.98",
3
+ "version": "3.1.100",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -5,14 +5,13 @@ import { MapperRepository } from '../repository/mapper.repository';
5
5
  import { FieldMapperRepository } from '../repository/field-mapper.repository';
6
6
  import { FieldLovsRepository } from '../repository/field-lovs.repository';
7
7
 
8
-
9
8
  @Injectable()
10
9
  export class MapperService extends EntityServiceImpl {
11
-
12
- constructor(private readonly dataSource: DataSource,
13
- private mapperRepository: MapperRepository,
14
- private fieldMapperRepository: FieldMapperRepository,
15
- private fieldLovsRepository: FieldLovsRepository,
10
+ constructor(
11
+ private readonly dataSource: DataSource,
12
+ private mapperRepository: MapperRepository,
13
+ private fieldMapperRepository: FieldMapperRepository,
14
+ private fieldLovsRepository: FieldLovsRepository,
16
15
  ) {
17
16
  super();
18
17
  }
@@ -21,24 +20,42 @@ export class MapperService extends EntityServiceImpl {
21
20
  if (!mappedEntityType) return [];
22
21
 
23
22
  const mappers = await this.dataSource.query(
24
- `SELECT id, name, code
23
+ `SELECT id, name, code, status
25
24
  FROM cr_mapper
26
25
  WHERE mapped_entity_type = ?`,
27
26
  [mappedEntityType],
28
27
  );
29
28
 
29
+ const distinctStatuses = [
30
+ ...new Set(mappers.map((m) => m.status).filter((s) => s !== null)),
31
+ ];
32
+
33
+ // get all statuses in one query
34
+ const statusMap = new Map();
35
+ if (distinctStatuses.length > 0) {
36
+ const statuses = await this.dataSource.query(
37
+ `SELECT id, name FROM cr_list_master_items WHERE id IN (?)`,
38
+ [distinctStatuses],
39
+ );
40
+ statuses.forEach((status) => {
41
+ statusMap.set(status.id, status.name);
42
+ });
43
+ }
44
+
45
+ // map status names to mappers
46
+
30
47
  return mappers.map((m) => ({
31
48
  id: m.id,
32
49
  label: m.name,
33
50
  value: m.id,
34
51
  code: m.code,
35
- status: m.status,
52
+ status: statusMap.get(m.status) || null,
36
53
  }));
37
54
  }
38
55
 
39
56
  async deleteEntity(entityType: string, entityId: number, loggedInUser) {
40
-
41
- let fieldMappers = await this.fieldMapperRepository.findByMapperId(entityId);
57
+ let fieldMappers =
58
+ await this.fieldMapperRepository.findByMapperId(entityId);
42
59
 
43
60
  for (const fieldMapper of fieldMappers) {
44
61
  await this.fieldLovsRepository.deleteByMapperFieldId(fieldMapper.id);
@@ -53,4 +70,4 @@ export class MapperService extends EntityServiceImpl {
53
70
  message: `Mapper deleted successfully.`,
54
71
  };
55
72
  }
56
- }
73
+ }
@@ -187,8 +187,9 @@ export class EntityDynamicService {
187
187
  );
188
188
 
189
189
  await this.dataSource.query(
190
- `INSERT INTO cr_entity_relation_data (source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES (?, ?, ?, ?, ?)`,
190
+ `INSERT INTO cr_entity_relation_data (organization_id, source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES (?, ?, ?, ?, ?)`,
191
191
  [
192
+ organizationId,
192
193
  mainID,
193
194
  entityType,
194
195
  createdRelatedEntity.insertId,
@@ -155,7 +155,7 @@ export class WorkflowMetaService extends EntityServiceImpl {
155
155
  status: firstStage.status,
156
156
  current_user_id: loggedInUser.id,
157
157
  stage_action_mapping_id: firstStage.id,
158
- orgnization_id: loggedInUser.organization_id,
158
+ organization_id: loggedInUser.organization_id,
159
159
  stage_group_id: stageGroup.id,
160
160
  stage_id: firstStage.id,
161
161
  start_date: new Date(),