rez_core 2.1.140 → 2.1.142

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.
Files changed (28) hide show
  1. package/dist/module/workflow/controller/stage.controller.d.ts +3 -0
  2. package/dist/module/workflow/controller/stage.controller.js +13 -0
  3. package/dist/module/workflow/controller/stage.controller.js.map +1 -1
  4. package/dist/module/workflow/entity/workflow.entity.d.ts +0 -1
  5. package/dist/module/workflow/entity/workflow.entity.js +0 -4
  6. package/dist/module/workflow/entity/workflow.entity.js.map +1 -1
  7. package/dist/module/workflow/service/action.service.d.ts +1 -0
  8. package/dist/module/workflow/service/action.service.js +7 -0
  9. package/dist/module/workflow/service/action.service.js.map +1 -1
  10. package/dist/module/workflow/service/stage-group.service.d.ts +4 -1
  11. package/dist/module/workflow/service/stage-group.service.js +19 -2
  12. package/dist/module/workflow/service/stage-group.service.js.map +1 -1
  13. package/dist/module/workflow/service/stage.service.d.ts +9 -1
  14. package/dist/module/workflow/service/stage.service.js +52 -2
  15. package/dist/module/workflow/service/stage.service.js.map +1 -1
  16. package/dist/module/workflow/service/workflow.service.d.ts +6 -1
  17. package/dist/module/workflow/service/workflow.service.js +19 -2
  18. package/dist/module/workflow/service/workflow.service.js.map +1 -1
  19. package/dist/tsconfig.build.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/src/module/workflow/controller/stage.controller.ts +17 -0
  22. package/src/module/workflow/entity/workflow.entity.ts +0 -3
  23. package/src/module/workflow/repository/stage-group.repository.ts +1 -1
  24. package/src/module/workflow/repository/stage.repository.ts +1 -1
  25. package/src/module/workflow/service/action.service.ts +21 -0
  26. package/src/module/workflow/service/stage-group.service.ts +32 -1
  27. package/src/module/workflow/service/stage.service.ts +87 -2
  28. package/src/module/workflow/service/workflow.service.ts +36 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.140",
3
+ "version": "2.1.142",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -2,6 +2,8 @@ import {
2
2
  Body,
3
3
  Controller,
4
4
  Get,
5
+ HttpCode,
6
+ HttpStatus,
5
7
  Inject,
6
8
  Post,
7
9
  Req,
@@ -9,6 +11,7 @@ import {
9
11
  } from '@nestjs/common';
10
12
  import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
11
13
  import { StageService } from '../service/stage.service';
14
+ import { level } from 'winston';
12
15
 
13
16
  @Controller('/stage')
14
17
  @UseGuards(JwtAuthGuard)
@@ -30,4 +33,18 @@ export class StageController {
30
33
  level_type,
31
34
  );
32
35
  }
36
+
37
+ @Post('/getStagesWithGroupName')
38
+ @HttpCode(HttpStatus.OK)
39
+ async getStagesWithGroupName(
40
+ @Body('workflow_id') workflow_id: number,
41
+ @Req() req: Request & { user: any },
42
+ ) {
43
+ const { level_id, level_type } = req.user.userData;
44
+ return this.stageGroupService.getStagesWithGroupName(
45
+ workflow_id,
46
+ level_id,
47
+ level_type,
48
+ );
49
+ }
33
50
  }
@@ -17,7 +17,4 @@ export class Workflow extends BaseEntity {
17
17
 
18
18
  @Column({ type: 'boolean', nullable: true })
19
19
  is_factory: boolean;
20
-
21
- @Column({ type: 'int', nullable: true })
22
- sequence: number;
23
20
  }
@@ -31,7 +31,7 @@ export class StageGroupRepository {
31
31
  level_type,
32
32
  },
33
33
  order: {
34
- sequence: 'ASC', // or 'DESC' if you want reverse order
34
+ sequence: 'ASC',
35
35
  },
36
36
  });
37
37
 
@@ -32,7 +32,7 @@ export class StageRepository {
32
32
  level_type,
33
33
  },
34
34
  order: {
35
- sequence: 'ASC', // or 'DESC' if you want reverse order
35
+ sequence: 'ASC',
36
36
  },
37
37
  });
38
38
 
@@ -148,4 +148,25 @@ export class ActionService extends EntityServiceImpl {
148
148
 
149
149
  return action; // Return the action entity instead of actionData
150
150
  }
151
+
152
+ async deleteEntity(
153
+ entityType: string,
154
+ id: number,
155
+ loggedInUser: UserData,
156
+ ): Promise<any> {
157
+ await this.dataSource.query(
158
+ `DELETE FROM cr_wf_action_template_mapping WHERE stg_act_mapping_id IN (SELECT
159
+ id FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type = 'STGM')`,
160
+ [id],
161
+ );
162
+
163
+ await this.dataSource.query(
164
+ `DELETE FROM cr_wf_stage_action_mapping WHERE action_id = ? AND entity_type ='STGM'`,
165
+ [id],
166
+ );
167
+
168
+ const deleteAction = await super.deleteEntity(entityType, id, loggedInUser);
169
+
170
+ return deleteAction;
171
+ }
151
172
  }
@@ -3,10 +3,15 @@ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.s
3
3
  import { StageGroupRepository } from '../repository/stage-group.repository';
4
4
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
5
5
  import { UserData } from 'src/module/user/entity/user.entity';
6
+ import { StageService } from './stage.service';
6
7
 
7
8
  @Injectable()
8
9
  export class StageGroupService extends EntityServiceImpl {
9
- constructor(private readonly stageGroupRepository: StageGroupRepository) {
10
+ constructor(
11
+ private readonly stageGroupRepository: StageGroupRepository,
12
+ @Inject('StageService')
13
+ private readonly stageService: StageService,
14
+ ) {
10
15
  super();
11
16
  }
12
17
  async getAllStageGroup(
@@ -35,4 +40,30 @@ export class StageGroupService extends EntityServiceImpl {
35
40
  ): Promise<BaseEntity | null> {
36
41
  return await super.getEntityData(entityType, id, loggedInUser);
37
42
  }
43
+
44
+ async deleteEntity(
45
+ entityType: string,
46
+ id: number,
47
+ loggedInUser: UserData,
48
+ ): Promise<any> {
49
+ const getAllStage = await this.stageService.getAllStage(
50
+ id,
51
+ loggedInUser.level_id,
52
+ loggedInUser.level_type,
53
+ );
54
+
55
+ if (getAllStage.length > 0) {
56
+ for (const stage of getAllStage) {
57
+ await this.stageService.deleteEntity('STG', stage.id, loggedInUser);
58
+ }
59
+ }
60
+
61
+ const deleteStageGroup = await super.deleteEntity(
62
+ entityType,
63
+ id,
64
+ loggedInUser,
65
+ );
66
+
67
+ return deleteStageGroup;
68
+ }
38
69
  }
@@ -1,12 +1,26 @@
1
- import { Injectable } from '@nestjs/common';
1
+ import { ActionService } from './action.service';
2
+ import {
3
+ BadRequestException,
4
+ Inject,
5
+ Injectable,
6
+ NotFoundException,
7
+ } from '@nestjs/common';
2
8
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
9
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
4
10
  import { UserData } from 'src/module/user/entity/user.entity';
5
11
  import { StageRepository } from '../repository/stage.repository';
12
+ import { DataSource } from 'typeorm';
13
+ import { StageGroupRepository } from '../repository/stage-group.repository';
6
14
 
7
15
  @Injectable()
8
16
  export class StageService extends EntityServiceImpl {
9
- constructor(private readonly stageRepository: StageRepository) {
17
+ constructor(
18
+ private readonly stageRepository: StageRepository,
19
+ private readonly stageGroupRepository: StageGroupRepository,
20
+ private readonly dataSource: DataSource,
21
+ @Inject('ActionService')
22
+ private readonly actionService: ActionService,
23
+ ) {
10
24
  super();
11
25
  }
12
26
  async getAllStage(
@@ -35,4 +49,75 @@ export class StageService extends EntityServiceImpl {
35
49
  ): Promise<BaseEntity | null> {
36
50
  return await super.getEntityData(entityType, id, loggedInUser);
37
51
  }
52
+
53
+ async deleteEntity(
54
+ entityType: string,
55
+ id: number,
56
+ loggedInUser: UserData,
57
+ ): Promise<any> {
58
+ const getAllStageAction = await this.dataSource.query(
59
+ `SELECT action_id FROM cr_wf_stage_action_mapping WHERE stage_id = ? AND entity_type = 'STGM'`,
60
+ [id],
61
+ );
62
+
63
+ if (getAllStageAction.length > 0) {
64
+ for (const action of getAllStageAction) {
65
+ await this.actionService.deleteEntity(
66
+ 'ACTN',
67
+ action.action_id,
68
+ loggedInUser,
69
+ );
70
+ }
71
+ }
72
+
73
+ const deleteStage = await super.deleteEntity(entityType, id, loggedInUser);
74
+
75
+ return deleteStage;
76
+ }
77
+
78
+ async getStagesWithGroupName(
79
+ workflow_id: number,
80
+ level_id: string,
81
+ level_type: string,
82
+ ) {
83
+ if (!workflow_id) {
84
+ throw new BadRequestException('workflow_id is required');
85
+ }
86
+
87
+ const stageGroups = await this.stageGroupRepository.getAllStageGroup(
88
+ workflow_id,
89
+ level_id,
90
+ level_type,
91
+ );
92
+
93
+ const stageGroupIds = stageGroups.map((group) => group.id);
94
+ const groupNameMap = new Map<number, string>(
95
+ stageGroups.map((group) => [Number(group.id), group.name]),
96
+ );
97
+
98
+ // Get all stages for all stageGroups
99
+ const allStages: any = [];
100
+ for (const groupId of stageGroupIds) {
101
+ try {
102
+ const stages = await this.stageRepository.getAllStage(
103
+ groupId,
104
+ level_id,
105
+ level_type,
106
+ );
107
+ allStages.push(...stages);
108
+ } catch (err) {
109
+ if (err instanceof NotFoundException) {
110
+ console.warn(`No stages for group ID ${groupId}`);
111
+ continue;
112
+ }
113
+ throw err;
114
+ }
115
+ }
116
+
117
+ const result = allStages.map((stage) => ({
118
+ stage_id: stage.id,
119
+ full_name: `${groupNameMap.get(stage.stage_group_id)} - ${stage.name}`,
120
+ }));
121
+ return result;
122
+ }
38
123
  }
@@ -8,6 +8,9 @@ import { ListMasterService } from 'src/module/listmaster/service/list-master.ser
8
8
  import { STATUS_INACTIVE, WORKFLOW } from 'src/constant/global.constant';
9
9
  import { Workflow } from '../entity/workflow.entity';
10
10
 
11
+ import { StageGroupRepository } from '../repository/stage-group.repository';
12
+ import { StageGroupService } from './stage-group.service';
13
+
11
14
  @Injectable()
12
15
  export class WorkflowService extends EntityServiceImpl {
13
16
  constructor(
@@ -15,6 +18,9 @@ export class WorkflowService extends EntityServiceImpl {
15
18
  private readonly workflowRepository: WorkflowRepository,
16
19
  @Inject('ListMasterService')
17
20
  private readonly listMasterService: ListMasterService,
21
+ @Inject('StageGroupService')
22
+ private readonly stateGroupService: StageGroupService,
23
+ private readonly stageGroupRepository: StageGroupRepository,
18
24
  ) {
19
25
  super();
20
26
  }
@@ -95,6 +101,36 @@ export class WorkflowService extends EntityServiceImpl {
95
101
  return this.workflowRepository.deleteWorkflowById(id);
96
102
  }
97
103
 
104
+ async deleteEntity(
105
+ entityType: string,
106
+ id: number,
107
+ loggedInUser: UserData,
108
+ ): Promise<any> {
109
+ const getAllStage = await this.stageGroupRepository.getAllStageGroup(
110
+ id,
111
+ loggedInUser.level_id,
112
+ loggedInUser.level_type,
113
+ );
114
+
115
+ if (getAllStage.length > 0) {
116
+ for (const stage of getAllStage) {
117
+ await this.stateGroupService.deleteEntity(
118
+ 'STGP',
119
+ stage.id,
120
+ loggedInUser,
121
+ );
122
+ }
123
+ }
124
+
125
+ const deleteWorkflow = await super.deleteEntity(
126
+ entityType,
127
+ id,
128
+ loggedInUser,
129
+ );
130
+
131
+ return deleteWorkflow;
132
+ }
133
+
98
134
  async updateSequence(body: any[], loggedInUser: any) {
99
135
  if (!Array.isArray(body) || body.length === 0) {
100
136
  throw new BadRequestException(