rez_core 3.1.124 → 3.1.126

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.124",
3
+ "version": "3.1.126",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -56,6 +56,7 @@ export class PopulateMetaService {
56
56
  'cr_entity_master',
57
57
  'cr_attribute_master',
58
58
  'cr_view_master',
59
+ 'cr_entity_relation',
59
60
  ];
60
61
  const entityTypeToNewIdMap = new Map<string, number>();
61
62
 
@@ -74,7 +75,19 @@ export class PopulateMetaService {
74
75
 
75
76
  let transformedData;
76
77
 
77
- if (table === 'cr_attribute_master') {
78
+ if (table === 'cr_entity_master') {
79
+ transformedData = factoryData.map(
80
+ ({ id, created_date, modified_date, ...rest }) => ({
81
+ ...rest,
82
+ organization_id,
83
+ level_type: 'ORG',
84
+ level_id: organization_id,
85
+ is_workflow: rest.is_workflow == 1 ? true : false,
86
+ status: status,
87
+ }),
88
+ );
89
+ }
90
+ else if (table === 'cr_attribute_master') {
78
91
  transformedData = factoryData.map(
79
92
  ({ id, created_date, modified_date, ...rest }) => ({
80
93
  ...rest,
@@ -83,6 +96,7 @@ export class PopulateMetaService {
83
96
  level_id: organization_id,
84
97
  is_unique: rest.is_unique == 1 ? true : false,
85
98
  required: rest.required == 1 ? true : false,
99
+ is_hidden: rest.is_hidden == 1 ? true : false,
86
100
  status: status,
87
101
  }),
88
102
  );
@@ -6,6 +6,7 @@ import {
6
6
  HttpStatus,
7
7
  Inject,
8
8
  Post,
9
+ Query,
9
10
  Req,
10
11
  UseGuards,
11
12
  } from '@nestjs/common';
@@ -24,11 +25,13 @@ export class StageController {
24
25
  async getAllStage(
25
26
  @Req() req: Request & { user: any },
26
27
  @Body() body: { stage_group_id: number },
28
+ @Query() query: { show_previous: boolean },
27
29
  ) {
28
30
  const { organization_id } = req.user.userData;
29
31
  return this.stageGroupService.getAllStage(
30
- body.stage_group_id,
32
+ body,
31
33
  organization_id,
34
+ query.show_previous,
32
35
  );
33
36
  }
34
37
 
@@ -115,4 +115,58 @@ export class StageRepository {
115
115
 
116
116
  return rows;
117
117
  }
118
+
119
+ async getAllStageGroupAndStageByStageMovement(
120
+ stage_group_id: number,
121
+ organization_id: number,
122
+ ) {
123
+ // 1. Find the current stage group
124
+ const currentStageGroup = await this.dataSource.manager.findOne<any>(
125
+ 'cr_wf_stage_group',
126
+ { where: { id: stage_group_id, organization_id } },
127
+ );
128
+
129
+ if (!currentStageGroup) {
130
+ return [];
131
+ }
132
+
133
+ // 2. Get all stage groups in the same workflow with sequence <= current
134
+ const stageGroups = await this.dataSource.manager.find<any>(
135
+ 'cr_wf_stage_group',
136
+ {
137
+ where: {
138
+ workflow_id: currentStageGroup.workflow_id,
139
+ organization_id,
140
+ },
141
+ order: { sequence: 'ASC' },
142
+ },
143
+ );
144
+
145
+ // Filter only groups with sequence <= current
146
+ const eligibleGroups = stageGroups.filter(
147
+ (g) => g.sequence <= currentStageGroup.sequence,
148
+ );
149
+
150
+ const flatResults: any[] = [];
151
+
152
+ // 3. For each eligible group, fetch its stages
153
+ for (const group of eligibleGroups) {
154
+ const stages = await this.stageRepository.find({
155
+ where: { stage_group_id: group.id, organization_id },
156
+ order: { sequence: 'ASC' },
157
+ });
158
+
159
+ if (!stages || stages.length === 0) continue;
160
+
161
+ // 4. Flatten into result with full_name
162
+ for (const stage of stages) {
163
+ flatResults.push({
164
+ ...stage,
165
+ full_name: `${group.name} - ${stage.name}`,
166
+ });
167
+ }
168
+ }
169
+
170
+ return flatResults;
171
+ }
118
172
  }
@@ -3,6 +3,7 @@ import {
3
3
  BadRequestException,
4
4
  Inject,
5
5
  Injectable,
6
+ Logger,
6
7
  NotFoundException,
7
8
  } from '@nestjs/common';
8
9
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
@@ -16,6 +17,8 @@ import { StageMovementData } from '../entity/stage-movement-data.entity';
16
17
 
17
18
  @Injectable()
18
19
  export class StageService extends EntityServiceImpl {
20
+ private readonly logger = new Logger(StageService.name);
21
+
19
22
  constructor(
20
23
  private readonly stageRepository: StageRepository,
21
24
  private readonly stageGroupRepository: StageGroupRepository,
@@ -28,29 +31,47 @@ export class StageService extends EntityServiceImpl {
28
31
  super();
29
32
  }
30
33
 
31
- async getAllStage(stage_group_id: number, organization_id: number) {
32
- const allStages = await this.stageRepository.getAllStage(
33
- stage_group_id,
34
- organization_id,
35
- );
34
+ async getAllStage(
35
+ payload: {
36
+ stage_group_id: number;
37
+ },
38
+ organization_id: number,
39
+ show_previous: boolean,
40
+ ) {
41
+ if (!show_previous) {
42
+ const allStages = await this.stageRepository.getAllStage(
43
+ payload.stage_group_id,
44
+ organization_id,
45
+ );
46
+
47
+ const statusListMaster = await this.dataSource.query(
48
+ `SELECT id, name
49
+ FROM cr_list_master_items
50
+ WHERE listtype = 'STS' AND organization_id = ?`,
51
+ [organization_id],
52
+ );
53
+
54
+ // Build a lookup map: id → name
55
+ const statusMap = new Map(
56
+ statusListMaster.map((s) => [String(s.id), s.name]),
57
+ );
58
+
59
+ for (const stage of allStages) {
60
+ stage.status = statusMap.get(String(stage.status)) as any;
61
+ }
36
62
 
37
- const statusListMaster = await this.dataSource.query(
38
- `SELECT id, name
39
- FROM cr_list_master_items
40
- WHERE listtype = 'STS' AND organization_id = ?`,
41
- [organization_id],
42
- );
63
+ return allStages;
64
+ }
43
65
 
44
- // Build a lookup map: id → name
45
- const statusMap = new Map(
46
- statusListMaster.map((s) => [String(s.id), s.name]),
47
- );
66
+ const allStageWithStageGroup =
67
+ await this.stageRepository.getAllStageGroupAndStageByStageMovement(
68
+ payload.stage_group_id,
69
+ organization_id,
70
+ );
48
71
 
49
- for (const stage of allStages) {
50
- stage.status = statusMap.get(String(stage.status)) as any;
51
- }
72
+ this.logger.debug('allStageWithStageGroup', allStageWithStageGroup);
52
73
 
53
- return allStages;
74
+ return allStageWithStageGroup;
54
75
  }
55
76
 
56
77
  async updateEntity(
@@ -119,7 +140,7 @@ export class StageService extends EntityServiceImpl {
119
140
  allStages.push(...stages);
120
141
  } catch (err) {
121
142
  if (err instanceof NotFoundException) {
122
- console.warn(`No stages for group ID ${groupId}`);
143
+ this.logger.warn(`No stages for group ID ${groupId}`);
123
144
  continue;
124
145
  }
125
146
  throw err;
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint"
4
- ]
5
- }