rez_core 2.1.138 → 2.1.140
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/dist/module/filter/controller/filter.controller.d.ts +1 -1
- package/dist/module/filter/controller/filter.controller.js +7 -4
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/dto/filter-request.dto.d.ts +1 -0
- package/dist/module/filter/service/filter.service.js +23 -2
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +11 -0
- package/dist/module/workflow/controller/comm-template.controller.js +44 -0
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage-group.controller.d.ts +10 -0
- package/dist/module/workflow/controller/stage-group.controller.js +43 -0
- package/dist/module/workflow/controller/stage-group.controller.js.map +1 -0
- package/dist/module/workflow/controller/stage.controller.d.ts +10 -0
- package/dist/module/workflow/controller/stage.controller.js +43 -0
- package/dist/module/workflow/controller/stage.controller.js.map +1 -0
- package/dist/module/workflow/controller/workflow.controller.d.ts +18 -9
- package/dist/module/workflow/controller/workflow.controller.js +25 -13
- package/dist/module/workflow/controller/workflow.controller.js.map +1 -1
- package/dist/module/workflow/entity/action.entity.d.ts +4 -1
- package/dist/module/workflow/entity/action.entity.js +20 -8
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage-group.entity.d.ts +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js +1 -1
- package/dist/module/workflow/entity/stage-group.entity.js.map +1 -1
- package/dist/module/workflow/entity/stage.entity.d.ts +1 -2
- package/dist/module/workflow/entity/stage.entity.js +1 -5
- package/dist/module/workflow/entity/stage.entity.js.map +1 -1
- package/dist/module/workflow/entity/workflow.entity.d.ts +3 -0
- package/dist/module/workflow/entity/workflow.entity.js +12 -0
- package/dist/module/workflow/entity/workflow.entity.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +7 -0
- package/dist/module/workflow/repository/comm-template.repository.js +39 -0
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage-group.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage-group.repository.js +50 -0
- package/dist/module/workflow/repository/stage-group.repository.js.map +1 -0
- package/dist/module/workflow/repository/stage.repository.d.ts +7 -0
- package/dist/module/workflow/repository/stage.repository.js +50 -0
- package/dist/module/workflow/repository/stage.repository.js.map +1 -0
- package/dist/module/workflow/repository/workflow.repository.d.ts +9 -1
- package/dist/module/workflow/repository/workflow.repository.js +38 -6
- package/dist/module/workflow/repository/workflow.repository.js.map +1 -1
- package/dist/module/workflow/service/action.service.d.ts +2 -0
- package/dist/module/workflow/service/action.service.js +39 -7
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +8 -2
- package/dist/module/workflow/service/comm-template.service.js +18 -3
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.d.ts +8 -0
- package/dist/module/workflow/service/stage-group.service.js +19 -1
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.d.ts +7 -5
- package/dist/module/workflow/service/stage.service.js +12 -18
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.d.ts +22 -3
- package/dist/module/workflow/service/workflow.service.js +65 -39
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +22 -2
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/controller/filter.controller.ts +10 -4
- package/src/module/filter/dto/filter-request.dto.ts +1 -0
- package/src/module/filter/service/filter.service.ts +34 -2
- package/src/module/workflow/controller/comm-template.controller.ts +31 -0
- package/src/module/workflow/controller/stage-group.controller.ts +33 -0
- package/src/module/workflow/controller/stage.controller.ts +33 -0
- package/src/module/workflow/controller/workflow.controller.ts +18 -11
- package/src/module/workflow/entity/action.entity.ts +10 -1
- package/src/module/workflow/entity/stage-group.entity.ts +1 -1
- package/src/module/workflow/entity/stage.entity.ts +1 -4
- package/src/module/workflow/entity/workflow.entity.ts +9 -0
- package/src/module/workflow/repository/comm-template.repository.ts +22 -0
- package/src/module/workflow/repository/stage-group.repository.ts +46 -0
- package/src/module/workflow/repository/stage.repository.ts +47 -0
- package/src/module/workflow/repository/workflow.repository.ts +40 -2
- package/src/module/workflow/service/action.service.ts +85 -14
- package/src/module/workflow/service/comm-template.service.ts +21 -2
- package/src/module/workflow/service/stage-group.service.ts +35 -2
- package/src/module/workflow/service/stage.service.ts +24 -33
- package/src/module/workflow/service/workflow.service.ts +100 -47
- package/src/module/workflow/workflow.module.ts +23 -2
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { StageGroupRepository } from '../repository/stage-group.repository';
|
|
4
|
+
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
5
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
3
6
|
|
|
4
7
|
@Injectable()
|
|
5
|
-
export class StageGroupService extends EntityServiceImpl {
|
|
8
|
+
export class StageGroupService extends EntityServiceImpl {
|
|
9
|
+
constructor(private readonly stageGroupRepository: StageGroupRepository) {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
async getAllStageGroup(
|
|
13
|
+
workflow_id: number,
|
|
14
|
+
level_id: string,
|
|
15
|
+
level_type: string,
|
|
16
|
+
) {
|
|
17
|
+
return await this.stageGroupRepository.getAllStageGroup(
|
|
18
|
+
workflow_id,
|
|
19
|
+
level_id,
|
|
20
|
+
level_type,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async updateEntity(
|
|
25
|
+
entityData: BaseEntity,
|
|
26
|
+
loggedInUser: UserData,
|
|
27
|
+
): Promise<any> {
|
|
28
|
+
return await super.updateEntity(entityData, loggedInUser);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async getEntityData(
|
|
32
|
+
entityType: string,
|
|
33
|
+
id: number,
|
|
34
|
+
loggedInUser?: UserData,
|
|
35
|
+
): Promise<BaseEntity | null> {
|
|
36
|
+
return await super.getEntityData(entityType, id, loggedInUser);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,47 +1,38 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
4
4
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
5
|
-
import {
|
|
5
|
+
import { StageRepository } from '../repository/stage.repository';
|
|
6
6
|
|
|
7
7
|
@Injectable()
|
|
8
8
|
export class StageService extends EntityServiceImpl {
|
|
9
|
-
constructor(private readonly
|
|
9
|
+
constructor(private readonly stageRepository: StageRepository) {
|
|
10
10
|
super();
|
|
11
11
|
}
|
|
12
|
+
async getAllStage(
|
|
13
|
+
stage_group_id: number,
|
|
14
|
+
level_id: string,
|
|
15
|
+
level_type: string,
|
|
16
|
+
) {
|
|
17
|
+
return await this.stageRepository.getAllStage(
|
|
18
|
+
stage_group_id,
|
|
19
|
+
level_id,
|
|
20
|
+
level_type,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
12
23
|
|
|
13
|
-
async
|
|
24
|
+
async updateEntity(
|
|
14
25
|
entityData: BaseEntity,
|
|
15
|
-
loggedInUser: UserData
|
|
16
|
-
manager?: EntityManager | null,
|
|
17
|
-
appcode?: string,
|
|
26
|
+
loggedInUser: UserData,
|
|
18
27
|
): Promise<any> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Step 1: Get the stage_group name using stage_group_id
|
|
22
|
-
let stageGroupName = '';
|
|
23
|
-
if (stageData.stage_group_id) {
|
|
24
|
-
const result = await this.dataSource.query(
|
|
25
|
-
`SELECT name FROM cr_wf_stage_group WHERE id = ?`,
|
|
26
|
-
[stageData.stage_group_id],
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (result.length > 0) {
|
|
30
|
-
stageGroupName = result[0].name;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (stageGroupName && stageData.name) {
|
|
35
|
-
stageData.full_name = `${stageGroupName}-${stageData.name}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const savedStage = await super.createEntity(
|
|
39
|
-
stageData,
|
|
40
|
-
loggedInUser,
|
|
41
|
-
manager,
|
|
42
|
-
appcode,
|
|
43
|
-
);
|
|
28
|
+
return await super.updateEntity(entityData, loggedInUser);
|
|
29
|
+
}
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
async getEntityData(
|
|
32
|
+
entityType: string,
|
|
33
|
+
id: number,
|
|
34
|
+
loggedInUser?: UserData,
|
|
35
|
+
): Promise<BaseEntity | null> {
|
|
36
|
+
return await super.getEntityData(entityType, id, loggedInUser);
|
|
46
37
|
}
|
|
47
38
|
}
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { DataSource, In } from 'typeorm';
|
|
4
|
+
import { WorkflowRepository } from '../repository/workflow.repository';
|
|
5
|
+
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
6
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
4
|
-
import {
|
|
7
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
8
|
+
import { STATUS_INACTIVE, WORKFLOW } from 'src/constant/global.constant';
|
|
9
|
+
import { Workflow } from '../entity/workflow.entity';
|
|
5
10
|
|
|
6
11
|
@Injectable()
|
|
7
12
|
export class WorkflowService extends EntityServiceImpl {
|
|
8
|
-
constructor(
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly dataSource: DataSource,
|
|
15
|
+
private readonly workflowRepository: WorkflowRepository,
|
|
16
|
+
@Inject('ListMasterService')
|
|
17
|
+
private readonly listMasterService: ListMasterService,
|
|
18
|
+
) {
|
|
9
19
|
super();
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
async
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
AND level_type = ?
|
|
22
|
-
`,
|
|
23
|
-
[entity_type, level_id, level_type],
|
|
22
|
+
async getAllWorkflows(
|
|
23
|
+
entity_type: string,
|
|
24
|
+
level_id: string,
|
|
25
|
+
level_type: string,
|
|
26
|
+
) {
|
|
27
|
+
return this.workflowRepository.getAllWorkflowsByFilters(
|
|
28
|
+
entity_type,
|
|
29
|
+
level_id,
|
|
30
|
+
level_type,
|
|
24
31
|
);
|
|
25
|
-
|
|
26
|
-
return workflows; // array of rows (each row is already in JSON format)
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
async getWorkflowById(id: number) {
|
|
@@ -34,45 +39,93 @@ export class WorkflowService extends EntityServiceImpl {
|
|
|
34
39
|
return result[0] || null;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
//update entity
|
|
43
|
+
async updateEntity(
|
|
44
|
+
entityData: BaseEntity,
|
|
45
|
+
loggedInUser: UserData,
|
|
46
|
+
): Promise<any> {
|
|
47
|
+
const resolveStatus = await this.listMasterService.getResolvedListCode(
|
|
48
|
+
STATUS_INACTIVE,
|
|
49
|
+
loggedInUser?.organization_id || 0,
|
|
43
50
|
);
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
throw new BadRequestException('Lead not found');
|
|
47
|
-
}
|
|
52
|
+
const workflowId = entityData.id;
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
// Handle INACTIVE status validation
|
|
55
|
+
if (entityData.status == resolveStatus.id) {
|
|
56
|
+
const existingWorkflow = (await this.getEntityData(
|
|
57
|
+
WORKFLOW,
|
|
58
|
+
workflowId,
|
|
59
|
+
loggedInUser,
|
|
60
|
+
)) as Workflow;
|
|
51
61
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
response.push({ label: 'Primary', value: data.phone_number });
|
|
62
|
+
if (!existingWorkflow) {
|
|
63
|
+
return { success: false, error: 'Workflow not found' };
|
|
55
64
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
|
|
66
|
+
if (existingWorkflow.is_default) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: 'Cannot inactivate because it is default.',
|
|
70
|
+
};
|
|
61
71
|
}
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
72
|
+
|
|
73
|
+
if (existingWorkflow.is_factory) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
error: 'Cannot inactivate because it is factory.',
|
|
77
|
+
};
|
|
65
78
|
}
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Handle is_default uniqueness logic
|
|
82
|
+
if ((entityData as Workflow).is_default == true) {
|
|
83
|
+
await this.dataSource
|
|
84
|
+
.createQueryBuilder()
|
|
85
|
+
.update(Workflow)
|
|
86
|
+
.set({ is_default: 0 })
|
|
87
|
+
.where('is_default = :isDefault', { isDefault: 1 })
|
|
88
|
+
.execute();
|
|
89
|
+
}
|
|
90
|
+
// Final update
|
|
91
|
+
return super.updateEntity(entityData, loggedInUser);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async deleteWorkflowById(id: number) {
|
|
95
|
+
return this.workflowRepository.deleteWorkflowById(id);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async updateSequence(body: any[], loggedInUser: any) {
|
|
99
|
+
if (!Array.isArray(body) || body.length === 0) {
|
|
100
|
+
throw new BadRequestException(
|
|
101
|
+
'Invalid input. Expected a non-empty array.',
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const results: {
|
|
106
|
+
id: any;
|
|
107
|
+
success: boolean;
|
|
108
|
+
result?: any;
|
|
109
|
+
error?: string;
|
|
110
|
+
}[] = [];
|
|
111
|
+
|
|
112
|
+
for (const item of body) {
|
|
113
|
+
if (!item.id || item.sequence === undefined) {
|
|
114
|
+
results.push({
|
|
115
|
+
id: item.id || null,
|
|
116
|
+
success: false,
|
|
117
|
+
error: 'Missing id or sequence',
|
|
118
|
+
});
|
|
119
|
+
continue;
|
|
68
120
|
}
|
|
69
|
-
|
|
70
|
-
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const result = await super.updateEntity(item, loggedInUser);
|
|
124
|
+
results.push({ id: item.id, success: true, result });
|
|
125
|
+
} catch (err) {
|
|
126
|
+
results.push({ id: item.id, success: false, error: err.message });
|
|
71
127
|
}
|
|
72
|
-
} else {
|
|
73
|
-
throw new BadRequestException('Invalid mode');
|
|
74
128
|
}
|
|
75
|
-
|
|
76
|
-
return response;
|
|
129
|
+
return { updated: results.filter((r) => r.success).length, results };
|
|
77
130
|
}
|
|
78
131
|
}
|
|
@@ -16,17 +16,26 @@ import { StageService } from './service/stage.service';
|
|
|
16
16
|
import { StageGroupService } from './service/stage-group.service';
|
|
17
17
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
18
18
|
import { EntityModule } from '../meta/entity.module';
|
|
19
|
-
import { Action } from './entity/action.entity';
|
|
20
19
|
import { WorkflowListMasterService } from './service/workflow-list-master.service';
|
|
21
20
|
import { WorkflowListMasterController } from './controller/workflow-list-master.controller';
|
|
22
21
|
import { ActionTemplateMappingController } from './controller/action-template-mapping.controller';
|
|
23
22
|
import { WorkflowController } from './controller/workflow.controller';
|
|
23
|
+
import { WorkflowRepository } from './repository/workflow.repository';
|
|
24
|
+
import { ListMasterService } from '../listmaster/service/list-master.service';
|
|
25
|
+
import { ListMasterModule } from '../listmaster/listmaster.module';
|
|
26
|
+
import { CommTemplateController } from './controller/comm-template.controller';
|
|
27
|
+
import { CommTemplateRepository } from './repository/comm-template.repository';
|
|
28
|
+
import { ActionEntity } from './entity/action.entity';
|
|
29
|
+
import { StageGroupRepository } from './repository/stage-group.repository';
|
|
30
|
+
import { StageGroupController } from './controller/stage-group.controller';
|
|
31
|
+
import { StageController } from './controller/stage.controller';
|
|
32
|
+
import { StageRepository } from './repository/stage.repository';
|
|
24
33
|
|
|
25
34
|
@Module({
|
|
26
35
|
imports: [
|
|
27
36
|
TypeOrmModule.forFeature([
|
|
28
37
|
Workflow,
|
|
29
|
-
|
|
38
|
+
ActionEntity,
|
|
30
39
|
ActionCategory,
|
|
31
40
|
Stage,
|
|
32
41
|
StageGroup,
|
|
@@ -35,6 +44,7 @@ import { WorkflowController } from './controller/workflow.controller';
|
|
|
35
44
|
StageActionMapping,
|
|
36
45
|
]),
|
|
37
46
|
EntityModule,
|
|
47
|
+
ListMasterModule,
|
|
38
48
|
],
|
|
39
49
|
providers: [
|
|
40
50
|
{ provide: 'ActionCategoryService', useClass: ActionCategoryService },
|
|
@@ -49,6 +59,11 @@ import { WorkflowController } from './controller/workflow.controller';
|
|
|
49
59
|
{ provide: 'WorkflowService', useClass: WorkflowService },
|
|
50
60
|
WorkflowListMasterService,
|
|
51
61
|
ActionTemplateMappingService,
|
|
62
|
+
WorkflowRepository,
|
|
63
|
+
CommTemplateService,
|
|
64
|
+
CommTemplateRepository,
|
|
65
|
+
StageGroupRepository,
|
|
66
|
+
StageRepository,
|
|
52
67
|
],
|
|
53
68
|
exports: [
|
|
54
69
|
'ActionCategoryService',
|
|
@@ -57,11 +72,17 @@ import { WorkflowController } from './controller/workflow.controller';
|
|
|
57
72
|
'ActionService',
|
|
58
73
|
'StageService',
|
|
59
74
|
'StageGroupService',
|
|
75
|
+
WorkflowRepository,
|
|
76
|
+
StageGroupRepository,
|
|
77
|
+
StageRepository,
|
|
60
78
|
],
|
|
61
79
|
controllers: [
|
|
62
80
|
WorkflowListMasterController,
|
|
63
81
|
ActionTemplateMappingController,
|
|
64
82
|
WorkflowController,
|
|
83
|
+
CommTemplateController,
|
|
84
|
+
StageGroupController,
|
|
85
|
+
StageController,
|
|
65
86
|
],
|
|
66
87
|
})
|
|
67
88
|
export class WorkflowModule {}
|