rez_core 5.0.15 → 5.0.17

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": "5.0.15",
3
+ "version": "5.0.17",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -597,10 +597,10 @@ export class EntityDynamicService {
597
597
  );
598
598
 
599
599
  const columns = validAttributes
600
- .map((attr) => `${attr.attribute_key}`)
600
+ .map((attr) => `t.${attr.attribute_key}`)
601
601
  .join(', ');
602
602
  const selectQuery = `SELECT ${columns}
603
- FROM ${tableName}
603
+ FROM ${tableName} t
604
604
  WHERE id = $1`;
605
605
 
606
606
  const result = await this.dataSource.query(selectQuery, [id]);
@@ -1,10 +1,12 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { EntityServiceImpl } from './entity-service-impl.service';
3
3
  import { DataSource } from 'typeorm';
4
+ import { EntityMasterRepository } from '../repository/entity-master.repository';
4
5
 
5
6
  @Injectable()
6
7
  export class EntityRelationService extends EntityServiceImpl {
7
- constructor(private readonly dataSource: DataSource) {
8
+ constructor(private readonly dataSource: DataSource,
9
+ private entityMasterRepo: EntityMasterRepository) {
8
10
  super();
9
11
  }
10
12
 
@@ -21,16 +23,11 @@ export class EntityRelationService extends EntityServiceImpl {
21
23
  );
22
24
 
23
25
  if (includeSelf) {
24
- const [entity] = await this.dataSource.query(
25
- `SELECT name as label
26
- FROM frm_entity_master
27
- WHERE mapped_entity_type = $1 AND organization_id = $2`,
28
- [entityType, loggedInUser.organization_id],
29
- );
26
+ const entity = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.organization_id);
30
27
 
31
28
  if (entity) {
32
29
  relations.unshift({
33
- label: entity.label,
30
+ label: entity.name,
34
31
  value: entityType,
35
32
  id: null, // or some special marker
36
33
  });
@@ -4,6 +4,7 @@ import { UserData } from '../../user/entity/user.entity';
4
4
  import * as moment from 'moment';
5
5
  import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
6
6
  import { ModuleRef } from '@nestjs/core';
7
+ import { AttributeMasterRepository } from '../repository/attribute-master.repository';
7
8
 
8
9
  @Injectable()
9
10
  export class ResolverService {
@@ -14,6 +15,7 @@ export class ResolverService {
14
15
  @Inject('ListMasterService')
15
16
  private readonly listMasterService: ListMasterService,
16
17
  private readonly moduleRef: ModuleRef,
18
+ private readonly attributeMasterRepo: AttributeMasterRepository
17
19
  ) {}
18
20
 
19
21
  private async getMediaDataService() {
@@ -31,10 +33,7 @@ export class ResolverService {
31
33
  entityData: any,
32
34
  entityType: string,
33
35
  ): Promise<any> {
34
- const attributeItems = await this.dataSource.query(
35
- `SELECT * FROM frm_entity_attribute WHERE mapped_entity_type = $1 AND organization_id = $2`,
36
- [entityType, loggedInUser.organization_id],
37
- );
36
+ const attributeItems = await this.attributeMasterRepo.findAttributesByMappedEntityType(entityType, loggedInUser.organization_id);
38
37
 
39
38
  const resolvedEntityData = { ...entityData };
40
39
 
@@ -13,6 +13,8 @@ import * as moment from 'moment';
13
13
  import { MediaDataService } from 'src/module/meta/service/media-data.service';
14
14
  import axios from 'axios';
15
15
  import { ConfigService } from '@nestjs/config';
16
+ import { ListMasterData } from 'src/module/listmaster/entity/list-master.entity';
17
+ import { StageGroup } from '../entity/stage-group.entity';
16
18
 
17
19
  @Injectable()
18
20
  export class StageGroupService extends EntityServiceImpl {
@@ -27,6 +29,10 @@ export class StageGroupService extends EntityServiceImpl {
27
29
  private readonly stageMovementRepo: Repository<StageMovementData>,
28
30
  private readonly mediaDataService: MediaDataService,
29
31
  private readonly configService: ConfigService,
32
+ @InjectRepository(ListMasterData)
33
+ private readonly listMasterRepo: Repository<ListMasterData>,
34
+ @InjectRepository(StageGroup)
35
+ private readonly stageGroupRepo: Repository<StageGroup>,
30
36
  ) {
31
37
  super();
32
38
  }
@@ -78,38 +84,53 @@ export class StageGroupService extends EntityServiceImpl {
78
84
 
79
85
  // if (!workflowLevelMapping) return null;
80
86
 
81
- let stage_movement_data: StageMovementData[] = [];
82
- stage_movement_data = await this.stageMovementRepo.find({
87
+ let stageMovement = await this.stageMovementRepo.find({
83
88
  where: {
84
89
  mapped_entity_type: 'LEAD',
85
90
  mapped_entity_id: lead_id,
86
91
  },
87
92
  });
88
93
 
89
- let stage_group_data = await this.stageMovementRepo.query(
90
- `SELECT * FROM frm_wf_stage_group WHERE id = $1`,
91
- [stage_movement_data[0].stage_group_id],
92
- );
94
+ if (!stageMovement || stageMovement.length === 0) {
95
+ return [];
96
+ }
97
+
98
+ console.log('stageMovementttegst', stageMovement);
99
+
100
+ const stageGroupData = await this.stageGroupRepo.findOne({
101
+ where: {
102
+ id: stageMovement[0].stage_group_id,
103
+ },
104
+ });
105
+
106
+ if (!stageGroupData) {
107
+ return [];
108
+ }
93
109
 
94
110
  // 3) Lead status (parameterized)
95
111
  let leadStatus: string | null = null;
96
- const leadData = await this.dataSource.query(
97
- `SELECT lead_status FROM crm_lead WHERE id = $1`,
98
- [lead_id],
99
- );
100
- if (leadData.length > 0 && leadData[0].lead_status != null) {
101
- const leadStatusResolved = await this.dataSource.query(
102
- `SELECT name FROM frm_list_master_items WHERE id = $1 AND organization_id = $2`,
103
- [leadData[0].lead_status, loggedInUser.organization_id],
104
- );
105
- if (leadStatusResolved.length > 0) {
106
- leadStatus = leadStatusResolved[0].name;
112
+
113
+ const leadData = await this.getEntityData('LEAD', lead_id, loggedInUser);
114
+ console.log('leadData', leadData);
115
+ const leadRecord = Array.isArray(leadData) ? leadData[0] : null;
116
+
117
+ if (leadRecord && leadRecord.lead_status != null) {
118
+ const leadStatusItem = await this.listMasterRepo.findOne({
119
+ where: {
120
+ id: leadRecord.lead_status,
121
+ organization_id: loggedInUser.organization_id,
122
+ },
123
+ select: ['name'],
124
+ });
125
+ if (leadStatusItem) {
126
+ leadStatus = leadStatusItem.name;
107
127
  }
108
128
  }
129
+
109
130
  // 4. Fetch stage groups & hierarchy
110
131
  const stageGroupAndStageHierarchy =
111
132
  (await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
112
- stage_group_data[0].workflow_id,
133
+ stageGroupData[0].workflow_id,
113
134
  loggedInUser,
114
135
  lead_id,
115
136
  )) as Array<{
@@ -63,6 +63,7 @@ import { ActivityLogController } from './controller/activity-log.controller';
63
63
  import { NotificationModule } from '../notification/notification.module';
64
64
  import { MapperModule } from '../mapper/mapper.module';
65
65
  import { WorkflowAutomationModule } from '../workflow-automation/workflow-automation.module';
66
+ import { ListMasterData } from '../listmaster/entity/list-master.entity';
66
67
 
67
68
  @Module({
68
69
  imports: [
@@ -83,9 +84,10 @@ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automa
83
84
  ActionDataEntity,
84
85
  ActionResourcesMapping,
85
86
  ActivityLog,
87
+ ListMasterData,
86
88
  ]),
87
- EntityModule,
88
89
  ListMasterModule,
90
+ EntityModule,
89
91
  NotificationModule,
90
92
  MapperModule,
91
93
  WorkflowAutomationModule,