rez_core 5.0.246 → 5.0.248

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.246",
3
+ "version": "5.0.248",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -17,6 +17,8 @@ import { ActionCategory } from '../entity/action-category.entity';
17
17
  import { StageGroup } from '../entity/stage-group.entity';
18
18
  import { ActionDataEntity } from '../entity/action-data.entity';
19
19
  import { TaskDataEntity } from '../entity/task-data.entity';
20
+ import { IMicroserviceClients } from 'src/module/microservice-client/service/microservice-clients';
21
+ import { firstValueFrom } from 'rxjs';
20
22
 
21
23
  @Injectable()
22
24
  export class WorkflowMetaService extends EntityServiceImpl {
@@ -41,6 +43,8 @@ export class WorkflowMetaService extends EntityServiceImpl {
41
43
  private readonly actionDataEntityRepository: Repository<ActionDataEntity>,
42
44
  @InjectRepository(TaskDataEntity)
43
45
  private readonly taskDataEntityRepository: Repository<TaskDataEntity>,
46
+ @Inject('MICROSERVICE_CLIENT_FACTORY')
47
+ private readonly factory: IMicroserviceClients,
44
48
  ) {
45
49
  super();
46
50
  }
@@ -549,32 +553,25 @@ export class WorkflowMetaService extends EntityServiceImpl {
549
553
  mapped_entity_type: string,
550
554
  stage_id: number,
551
555
  actions: any[],
552
- ): Promise<number> {
556
+ ): Promise<number | null> {
553
557
  const { organization_id, level_id, level_type } = loggedInUser;
554
558
 
555
559
  let owners = [] as any;
556
560
 
557
- try {
558
- const baseUrl = this.configService.get<string>('REDIRECT_BE_URL');
559
-
560
- // Prepare query params
561
- const queryParams = new URLSearchParams({
562
- loggedInUser: JSON.stringify(loggedInUser),
563
- }).toString();
564
-
565
- const { level_id } = loggedInUser;
561
+ const client = this.factory.getClient('SSO');
566
562
 
567
- const url = `${baseUrl}/users/public/lead-owners/?entity_type=USR&${queryParams}`;
568
-
569
- const response = await axios.get(url);
570
-
571
- owners = response.data;
572
-
573
- // The API response is likely a JSON object, not an array
574
- } catch (error) {
575
- console.error('Internal Entity API call failed:', error.message);
563
+ if (!client) {
564
+ return null;
576
565
  }
577
566
 
567
+ owners = await firstValueFrom(
568
+ client.send('user.leadOwnerDropdown', {
569
+ organization_id,
570
+ level_id,
571
+ level_type,
572
+ }),
573
+ );
574
+
578
575
  if (!owners?.length)
579
576
  console.log('No eligible owners found for lead assignment.');
580
577
  const userIds = owners?.map((o) => Number(o.id)); // normalize to numbers
@@ -594,7 +591,7 @@ export class WorkflowMetaService extends EntityServiceImpl {
594
591
  .limit(1)
595
592
  .getRawOne();
596
593
 
597
- const lastAssigned = lastRow.length ? Number(lastRow[0].lead_owner) : null;
594
+ const lastAssigned = lastRow ? Number(lastRow.lead_owner) : null;
598
595
 
599
596
  // 3) Compute next user in round-robin
600
597
  const lastIdx = lastAssigned != null ? userIds.indexOf(lastAssigned) : -1;