rez_core 4.0.140 → 4.0.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.
- package/dist/module/enterprise/repository/school.repository.js +1 -1
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/filter/repository/saved-filter.repository.js +1 -1
- package/dist/module/filter/service/filter-evaluator.service.js +1 -1
- package/dist/module/filter/service/filter-evaluator.service.js.map +1 -1
- package/dist/module/filter/service/filter.service.js +1 -1
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/integration/service/wrapper.service.js +10 -9
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master-item.service.js +1 -1
- package/dist/module/listmaster/service/list-master-item.service.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.js +3 -3
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/mapper/service/mapper.service.js +2 -2
- package/dist/module/mapper/service/mapper.service.js.map +1 -1
- package/dist/module/meta/repository/attribute-master.repository.js +2 -2
- package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
- package/dist/module/meta/repository/entity-master.repository.js +1 -1
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +19 -19
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.js +2 -2
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-relation.service.js +6 -6
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.js +9 -9
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.js +14 -14
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/notification/service/notification.service.js +1 -1
- package/dist/module/user/service/login.service.js +1 -1
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.js +3 -3
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.js +4 -4
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
- package/dist/module/workflow/repository/action.repository.js +2 -2
- package/dist/module/workflow/repository/action.repository.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.js +4 -4
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/repository/form-master.repository.js +1 -1
- package/dist/module/workflow/repository/form-master.repository.js.map +1 -1
- package/dist/module/workflow/repository/stage-group.repository.js +4 -4
- package/dist/module/workflow/repository/stage-movement.repository.js +4 -4
- package/dist/module/workflow/repository/stage-movement.repository.js.map +1 -1
- package/dist/module/workflow/service/action-template-mapping.service.js +7 -7
- package/dist/module/workflow/service/action.service.js +7 -7
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.js +2 -2
- package/dist/module/workflow/service/populate-workflow.service.js +8 -8
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.js +4 -4
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.js +2 -2
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +6 -6
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-list-master.service.js +3 -3
- package/dist/module/workflow/service/workflow-list-master.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +22 -22
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.js +4 -4
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/reflection-helper.service.js +1 -1
- package/dist/utils/service/reflection-helper.service.js.map +1 -1
- package/package.json +1 -1
- package/src/module/enterprise/repository/school.repository.ts +1 -1
- package/src/module/filter/repository/saved-filter.repository.ts +1 -1
- package/src/module/filter/service/filter-evaluator.service.ts +1 -1
- package/src/module/filter/service/filter.service.ts +1 -1
- package/src/module/integration/service/wrapper.service.ts +10 -9
- package/src/module/listmaster/service/list-master-item.service.ts +1 -1
- package/src/module/mapper/service/field-mapper.service.ts +3 -3
- package/src/module/mapper/service/mapper.service.ts +2 -2
- package/src/module/meta/repository/attribute-master.repository.ts +2 -2
- package/src/module/meta/repository/entity-master.repository.ts +1 -1
- package/src/module/meta/service/entity-dynamic.service.ts +19 -19
- package/src/module/meta/service/entity-master.service.ts +2 -2
- package/src/module/meta/service/entity-relation.service.ts +6 -6
- package/src/module/meta/service/media-data.service.ts +9 -9
- package/src/module/meta/service/resolver.service.ts +14 -14
- package/src/module/notification/service/notification.service.ts +1 -1
- package/src/module/user/service/login.service.ts +1 -1
- package/src/module/user/service/user-session.service.ts +3 -3
- package/src/module/workflow/repository/action-data.repository.ts +4 -4
- package/src/module/workflow/repository/action.repository.ts +2 -2
- package/src/module/workflow/repository/comm-template.repository.ts +4 -4
- package/src/module/workflow/repository/form-master.repository.ts +1 -1
- package/src/module/workflow/repository/stage-group.repository.ts +4 -4
- package/src/module/workflow/repository/stage-movement.repository.ts +4 -4
- package/src/module/workflow/service/action-template-mapping.service.ts +7 -7
- package/src/module/workflow/service/action.service.ts +7 -7
- package/src/module/workflow/service/entity-modification.service.ts +2 -2
- package/src/module/workflow/service/populate-workflow.service.ts +8 -8
- package/src/module/workflow/service/stage-group.service.ts +4 -4
- package/src/module/workflow/service/stage.service.ts +2 -2
- package/src/module/workflow/service/task.service.ts +6 -6
- package/src/module/workflow/service/workflow-list-master.service.ts +3 -3
- package/src/module/workflow/service/workflow-meta.service.ts +22 -22
- package/src/module/workflow/service/workflow.service.ts +4 -4
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +1 -1
- package/src/utils/service/reflection-helper.service.ts +1 -1
|
@@ -40,7 +40,7 @@ export class ActionDataRepository extends EntityServiceImpl {
|
|
|
40
40
|
if (action.length > 0) {
|
|
41
41
|
for (const act of action) {
|
|
42
42
|
const is_mandatory = await this.dataSource.query(
|
|
43
|
-
`SELECT code FROM frm_list_master_items WHERE id =
|
|
43
|
+
`SELECT code FROM frm_list_master_items WHERE id = $1 and organization_id = $2 LIMIT 1;`,
|
|
44
44
|
[act.action_requirement, loggedInUser.organization_id],
|
|
45
45
|
);
|
|
46
46
|
const isFirst = act.sequence == minSequence;
|
|
@@ -100,13 +100,13 @@ export class ActionDataRepository extends EntityServiceImpl {
|
|
|
100
100
|
// THEN INSERT SDFM IN RELATION TASK TABLE
|
|
101
101
|
|
|
102
102
|
let relationData = await this.dataSource.query(
|
|
103
|
-
`SELECT * FROM frm_entity_relation WHERE source_entity_type =
|
|
103
|
+
`SELECT * FROM frm_entity_relation WHERE source_entity_type = $1 AND target_entity_type = $2`,
|
|
104
104
|
[createdEntity.mapped_entity_type, createdEntity.entity_type],
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
if (relationData) {
|
|
108
108
|
await this.dataSource.query(
|
|
109
|
-
`INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES (
|
|
109
|
+
`INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES ($1, $2, $3, $4, $5,$6)`,
|
|
110
110
|
[
|
|
111
111
|
loggedInUser.organization_id,
|
|
112
112
|
createdEntity.mapped_entity_id,
|
|
@@ -256,7 +256,7 @@ export class ActionDataRepository extends EntityServiceImpl {
|
|
|
256
256
|
|
|
257
257
|
// Reset status (optional: set to something like 'pending' if needed)
|
|
258
258
|
const pendingListMasterItemId = await this.dataSource.query(
|
|
259
|
-
`SELECT id FROM frm_list_master_items WHERE code = 'in_progress' AND organization_id =
|
|
259
|
+
`SELECT id FROM frm_list_master_items WHERE code = 'in_progress' AND organization_id = $1 AND listtype = 'TKST' LIMIT 1;`,
|
|
260
260
|
[organization_id],
|
|
261
261
|
);
|
|
262
262
|
task.status = pendingListMasterItemId[0]?.id ?? task.status;
|
|
@@ -65,7 +65,7 @@ export class ActionRepository {
|
|
|
65
65
|
`
|
|
66
66
|
SELECT id, action_id
|
|
67
67
|
FROM frm_wf_stage_action_mapping
|
|
68
|
-
WHERE stage_id =
|
|
68
|
+
WHERE stage_id = $1
|
|
69
69
|
`,
|
|
70
70
|
[stage_id],
|
|
71
71
|
);
|
|
@@ -221,7 +221,7 @@ export class ActionRepository {
|
|
|
221
221
|
) {
|
|
222
222
|
// Step 1: Get all action mappings for the stage
|
|
223
223
|
const stageActions = await this.dataSource.query(
|
|
224
|
-
`SELECT id, action_id FROM frm_wf_stage_action_mapping WHERE stage_id =
|
|
224
|
+
`SELECT id, action_id FROM frm_wf_stage_action_mapping WHERE stage_id = $1`,
|
|
225
225
|
[stage_id],
|
|
226
226
|
);
|
|
227
227
|
|
|
@@ -30,7 +30,7 @@ export class CommTemplateRepository {
|
|
|
30
30
|
const [actionResult] = await this.dataSource.query(
|
|
31
31
|
`SELECT is_template
|
|
32
32
|
FROM frm_wf_action
|
|
33
|
-
WHERE id =
|
|
33
|
+
WHERE id = $1 AND organization_id = $2
|
|
34
34
|
LIMIT 1`,
|
|
35
35
|
[action_id, organization_id],
|
|
36
36
|
);
|
|
@@ -43,9 +43,9 @@ export class CommTemplateRepository {
|
|
|
43
43
|
|
|
44
44
|
await this.dataSource.query(
|
|
45
45
|
`UPDATE frm_wf_comm_template
|
|
46
|
-
SET is_template =
|
|
47
|
-
WHERE mapped_entity_type =
|
|
48
|
-
AND organization_id =
|
|
46
|
+
SET is_template = $1
|
|
47
|
+
WHERE mapped_entity_type = $2
|
|
48
|
+
AND organization_id = $3 AND level_id = $4 AND level_type=$5`,
|
|
49
49
|
[is_template, entity_type, organization_id, level_id, level_type],
|
|
50
50
|
);
|
|
51
51
|
}
|
|
@@ -21,7 +21,7 @@ export class FormMasterRepository {
|
|
|
21
21
|
const forms = await this.dataSource.query(
|
|
22
22
|
`SELECT fm.id as fm_id, fm.name as fm_form_name
|
|
23
23
|
FROM frm_entity_view fm
|
|
24
|
-
WHERE fm.organization_id =
|
|
24
|
+
WHERE fm.organization_id = $1 AND fm.mapped_entity_type = $2`,
|
|
25
25
|
[organization_id, source_entity_type],
|
|
26
26
|
);
|
|
27
27
|
|
|
@@ -87,7 +87,7 @@ export class StageGroupRepository {
|
|
|
87
87
|
frm_wf_stage.*
|
|
88
88
|
FROM frm_wf_stage
|
|
89
89
|
WHERE frm_wf_stage.stage_group_id IN (${stageGroupIds.map(() => '?').join(',')})
|
|
90
|
-
AND frm_wf_stage.organization_id =
|
|
90
|
+
AND frm_wf_stage.organization_id = $2
|
|
91
91
|
ORDER BY frm_wf_stage.sequence ASC
|
|
92
92
|
`,
|
|
93
93
|
[...stageGroupIds, loggedInUser.organization_id],
|
|
@@ -100,7 +100,7 @@ export class StageGroupRepository {
|
|
|
100
100
|
`
|
|
101
101
|
SELECT stage_id, COUNT(*) AS task_count
|
|
102
102
|
FROM frm_wf_task_data
|
|
103
|
-
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND is_system=0 AND mapped_entity_id =
|
|
103
|
+
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND is_system=0 AND mapped_entity_id = $2
|
|
104
104
|
GROUP BY stage_id
|
|
105
105
|
`,
|
|
106
106
|
[...stageIds, lead_id],
|
|
@@ -111,7 +111,7 @@ export class StageGroupRepository {
|
|
|
111
111
|
`
|
|
112
112
|
SELECT stage_id, COUNT(*) AS meeting_count
|
|
113
113
|
FROM crm_lead_meeting
|
|
114
|
-
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND mapped_entity_id =
|
|
114
|
+
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND mapped_entity_id = $2
|
|
115
115
|
GROUP BY stage_id
|
|
116
116
|
`,
|
|
117
117
|
[...stageIds, lead_id],
|
|
@@ -122,7 +122,7 @@ export class StageGroupRepository {
|
|
|
122
122
|
`
|
|
123
123
|
SELECT stage_id, COUNT(*) AS send_comm_count
|
|
124
124
|
FROM crm_lead_communication
|
|
125
|
-
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND mapped_entity_id =
|
|
125
|
+
WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND mapped_entity_id = $2
|
|
126
126
|
AND type IN ('SEND', 'LOG')
|
|
127
127
|
GROUP BY stage_id
|
|
128
128
|
`,
|
|
@@ -191,7 +191,7 @@ export class StageMovementRepository {
|
|
|
191
191
|
FROM frm_wf_action a
|
|
192
192
|
LEFT JOIN frm_wf_stage_action_mapping m ON a.id = m.action_id
|
|
193
193
|
LEFT JOIN frm_wf_action_category ac ON a.action_category = ac.id
|
|
194
|
-
WHERE m.stage_id =
|
|
194
|
+
WHERE m.stage_id = $1
|
|
195
195
|
`,
|
|
196
196
|
[stageId],
|
|
197
197
|
);
|
|
@@ -203,7 +203,7 @@ export class StageMovementRepository {
|
|
|
203
203
|
`
|
|
204
204
|
SELECT arm.form_id
|
|
205
205
|
FROM frm_wf_action_resources_mapping arm
|
|
206
|
-
WHERE arm.stg_act_mapping_id =
|
|
206
|
+
WHERE arm.stg_act_mapping_id = $1 and form_id IS NOT NULL
|
|
207
207
|
LIMIT 1
|
|
208
208
|
`,
|
|
209
209
|
[item.mapping_id],
|
|
@@ -222,7 +222,7 @@ export class StageMovementRepository {
|
|
|
222
222
|
if (action.length > 0) {
|
|
223
223
|
for (const act of action) {
|
|
224
224
|
await this.dataSource.query(
|
|
225
|
-
`INSERT INTO frm_wf_action_data (stage_id, user_id, action_id) VALUES (
|
|
225
|
+
`INSERT INTO frm_wf_action_data (stage_id, user_id, action_id) VALUES ($1, $2, $3)`,
|
|
226
226
|
[act.stage_id, loggedInUser.id, act.id],
|
|
227
227
|
);
|
|
228
228
|
}
|
|
@@ -235,7 +235,7 @@ export class StageMovementRepository {
|
|
|
235
235
|
if (actionData.length > 0) {
|
|
236
236
|
for (const action of actionData) {
|
|
237
237
|
await this.dataSource.query(
|
|
238
|
-
`INSERT INTO frm_wf_task_data (action_id, user_id) VALUES (
|
|
238
|
+
`INSERT INTO frm_wf_task_data (action_id, user_id) VALUES ($1, $2)`,
|
|
239
239
|
[action.id, loggedInUser.id],
|
|
240
240
|
);
|
|
241
241
|
}
|
|
@@ -20,7 +20,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
20
20
|
stageAction = await this.dataSource.query(
|
|
21
21
|
`
|
|
22
22
|
SELECT id FROM frm_wf_stage_action_mapping
|
|
23
|
-
WHERE action_id =
|
|
23
|
+
WHERE action_id = $1
|
|
24
24
|
`,
|
|
25
25
|
[action_id],
|
|
26
26
|
);
|
|
@@ -34,8 +34,8 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
34
34
|
`
|
|
35
35
|
SELECT id
|
|
36
36
|
FROM frm_list_master_items
|
|
37
|
-
WHERE organization_id =
|
|
38
|
-
AND listtype = "MOD" AND code =
|
|
37
|
+
WHERE organization_id = $1
|
|
38
|
+
AND listtype = "MOD" AND code = $2
|
|
39
39
|
`,
|
|
40
40
|
[loggedInUser.organization_id, 'email'],
|
|
41
41
|
);
|
|
@@ -46,7 +46,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
46
46
|
`
|
|
47
47
|
SELECT code as value, name as label , id
|
|
48
48
|
FROM frm_wf_comm_template
|
|
49
|
-
WHERE mode =
|
|
49
|
+
WHERE mode = $1 AND organization_id = $2 AND level_type = $3 AND level_id = $4 AND status IN (SELECT id FROM frm_list_master_items WHERE code = "STATUS_ACTIVE" AND organization_id = $5)
|
|
50
50
|
`,
|
|
51
51
|
[
|
|
52
52
|
modeId,
|
|
@@ -67,7 +67,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
67
67
|
const getModeFromAction = await this.dataSource.query(
|
|
68
68
|
`
|
|
69
69
|
SELECT mode FROM frm_wf_action
|
|
70
|
-
WHERE id =
|
|
70
|
+
WHERE id = $1
|
|
71
71
|
`,
|
|
72
72
|
[action_id],
|
|
73
73
|
);
|
|
@@ -77,7 +77,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
77
77
|
const templates = await this.dataSource.query(
|
|
78
78
|
`
|
|
79
79
|
SELECT template_code FROM frm_wf_action_resources_mapping
|
|
80
|
-
WHERE stg_act_mapping_id =
|
|
80
|
+
WHERE stg_act_mapping_id = $1
|
|
81
81
|
`,
|
|
82
82
|
[stgActMappingId],
|
|
83
83
|
);
|
|
@@ -89,7 +89,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
89
89
|
`
|
|
90
90
|
SELECT code as value, name as label , id
|
|
91
91
|
FROM frm_wf_comm_template
|
|
92
|
-
WHERE code IN (
|
|
92
|
+
WHERE code IN ($1) AND mode = $2 AND organization_id = $3 AND level_type = $4 AND level_id = $5 AND status IN (SELECT id FROM frm_list_master_items WHERE code = "STATUS_ACTIVE" AND organization_id = $6)
|
|
93
93
|
`,
|
|
94
94
|
[
|
|
95
95
|
templateCodes,
|
|
@@ -32,7 +32,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
32
32
|
WHERE stg_act_mapping_id IN (
|
|
33
33
|
SELECT id
|
|
34
34
|
FROM frm_wf_stage_action_mapping
|
|
35
|
-
WHERE action_id =
|
|
35
|
+
WHERE action_id = $1 AND entity_type = 'WFSA'
|
|
36
36
|
)`,
|
|
37
37
|
[actionData.id],
|
|
38
38
|
);
|
|
@@ -101,7 +101,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
await this.dataSource.query(
|
|
104
|
-
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id =
|
|
104
|
+
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id = $1 AND type = 'form'`,
|
|
105
105
|
[stageActionMappingData.id],
|
|
106
106
|
);
|
|
107
107
|
|
|
@@ -141,7 +141,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
const stageMapID = await this.dataSource.query(
|
|
144
|
-
`SELECT id FROM frm_wf_stage_action_mapping WHERE action_id =
|
|
144
|
+
`SELECT id FROM frm_wf_stage_action_mapping WHERE action_id = $1 AND entity_type = 'WFSA'`,
|
|
145
145
|
[action.id],
|
|
146
146
|
);
|
|
147
147
|
|
|
@@ -177,7 +177,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
177
177
|
|
|
178
178
|
// delete existing template mappings for this action
|
|
179
179
|
await this.dataSource.query(
|
|
180
|
-
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id =
|
|
180
|
+
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id = $1 AND type = 'template'`,
|
|
181
181
|
[stageActionMappingData.id],
|
|
182
182
|
);
|
|
183
183
|
|
|
@@ -200,7 +200,7 @@ export class ActionService extends EntityServiceImpl {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
await this.dataSource.query(
|
|
203
|
-
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id =
|
|
203
|
+
`DELETE FROM frm_wf_action_resources_mapping WHERE stg_act_mapping_id = $1 AND type = 'form'`,
|
|
204
204
|
[stageActionMappingData.id],
|
|
205
205
|
);
|
|
206
206
|
|
|
@@ -224,12 +224,12 @@ export class ActionService extends EntityServiceImpl {
|
|
|
224
224
|
): Promise<any> {
|
|
225
225
|
await this.dataSource.query(
|
|
226
226
|
`DELETE FROM frm_wf_action_template_mapping WHERE stg_act_mapping_id IN (SELECT
|
|
227
|
-
id FROM frm_wf_stage_action_mapping WHERE action_id =
|
|
227
|
+
id FROM frm_wf_stage_action_mapping WHERE action_id = $1 AND entity_type = 'WFSA')`,
|
|
228
228
|
[id],
|
|
229
229
|
);
|
|
230
230
|
|
|
231
231
|
await this.dataSource.query(
|
|
232
|
-
`DELETE FROM frm_wf_stage_action_mapping WHERE action_id =
|
|
232
|
+
`DELETE FROM frm_wf_stage_action_mapping WHERE action_id = $1 AND entity_type ='WFSA'`,
|
|
233
233
|
[id],
|
|
234
234
|
);
|
|
235
235
|
|
|
@@ -28,7 +28,7 @@ export class EntityModificationService extends EntityServiceImpl {
|
|
|
28
28
|
`
|
|
29
29
|
SELECT db_table_name
|
|
30
30
|
FROM frm_entity_master
|
|
31
|
-
WHERE mapped_entity_type =
|
|
31
|
+
WHERE mapped_entity_type = $1 AND organization_id = $2
|
|
32
32
|
`,
|
|
33
33
|
[mapped_entity_type, organization_id],
|
|
34
34
|
);
|
|
@@ -44,7 +44,7 @@ export class EntityModificationService extends EntityServiceImpl {
|
|
|
44
44
|
// Step 2: Get the row from the target table using mapped_entity_id
|
|
45
45
|
const [entityRow] = await this.dataSource.query(
|
|
46
46
|
`
|
|
47
|
-
SELECT * FROM ${tableName} WHERE id =
|
|
47
|
+
SELECT * FROM ${tableName} WHERE id = $1
|
|
48
48
|
`,
|
|
49
49
|
[mapped_entity_id],
|
|
50
50
|
);
|
|
@@ -82,7 +82,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
82
82
|
|
|
83
83
|
async populateWorkflowData(organization_id: number, loggedInUser: UserData) {
|
|
84
84
|
let statusRow = await this.dataSource.query(
|
|
85
|
-
`SELECT * FROM frm_list_master_items WHERE code='STATUS_ACTIVE' AND organization_id =
|
|
85
|
+
`SELECT * FROM frm_list_master_items WHERE code='STATUS_ACTIVE' AND organization_id = $1`,
|
|
86
86
|
[organization_id],
|
|
87
87
|
);
|
|
88
88
|
|
|
@@ -157,7 +157,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
157
157
|
|
|
158
158
|
// adding new entry for workflow level mapping
|
|
159
159
|
await this.dataSource.query(
|
|
160
|
-
`INSERT INTO frm_wf_level_mapping (workflow_id, mapped_level_id, mapped_level_type) VALUES (
|
|
160
|
+
`INSERT INTO frm_wf_level_mapping (workflow_id, mapped_level_id, mapped_level_type) VALUES ($1, $2, $3)`,
|
|
161
161
|
[newWf.id, organization_id, 'ORG'],
|
|
162
162
|
);
|
|
163
163
|
|
|
@@ -213,7 +213,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
213
213
|
// step 4 save new action
|
|
214
214
|
|
|
215
215
|
const stageIds = await this.dataSource.query(
|
|
216
|
-
`SELECT action_id FROM frm_wf_stage_action_mapping WHERE stage_id =
|
|
216
|
+
`SELECT action_id FROM frm_wf_stage_action_mapping WHERE stage_id = $1`,
|
|
217
217
|
[id],
|
|
218
218
|
);
|
|
219
219
|
|
|
@@ -222,7 +222,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
222
222
|
let actions = [];
|
|
223
223
|
if (actionIds.length > 0) {
|
|
224
224
|
actions = await this.dataSource.query(
|
|
225
|
-
`SELECT * FROM frm_wf_action WHERE id IN (
|
|
225
|
+
`SELECT * FROM frm_wf_action WHERE id IN ($1)`,
|
|
226
226
|
[actionIds],
|
|
227
227
|
);
|
|
228
228
|
} else {
|
|
@@ -242,13 +242,13 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
242
242
|
|
|
243
243
|
// Step 1: Get the code of the old is_mandatory field
|
|
244
244
|
const [oldIsMandatory] = await this.dataSource.query(
|
|
245
|
-
`SELECT code FROM frm_list_master_items WHERE id =
|
|
245
|
+
`SELECT code FROM frm_list_master_items WHERE id = $1`,
|
|
246
246
|
[rest.action_requirement],
|
|
247
247
|
);
|
|
248
248
|
|
|
249
249
|
// Step 2: Get all new 'ACRQ' list master items for the organization
|
|
250
250
|
const newIsMandatoryList = await this.dataSource.query(
|
|
251
|
-
`SELECT id, code FROM frm_list_master_items WHERE organization_id =
|
|
251
|
+
`SELECT id, code FROM frm_list_master_items WHERE organization_id = $1 AND listtype = 'ACRQ'`,
|
|
252
252
|
[organization_id],
|
|
253
253
|
);
|
|
254
254
|
|
|
@@ -267,13 +267,13 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
267
267
|
console.log(`Matched new mandatory item:`, matchedNewMandatory);
|
|
268
268
|
|
|
269
269
|
const formActionCategory = await this.dataSource.query(
|
|
270
|
-
`SELECT id FROM frm_wf_action_category WHERE id =
|
|
270
|
+
`SELECT id FROM frm_wf_action_category WHERE id = $1 and is_form = 1`,
|
|
271
271
|
[row.action_category],
|
|
272
272
|
);
|
|
273
273
|
|
|
274
274
|
//get view master form
|
|
275
275
|
const formViewMaster = await this.dataSource.query(
|
|
276
|
-
`SELECT id FROM frm_entity_view WHERE code = "LEAD_FORM" and organization_id =
|
|
276
|
+
`SELECT id FROM frm_entity_view WHERE code = "LEAD_FORM" and organization_id = $1`,
|
|
277
277
|
[organization_id],
|
|
278
278
|
);
|
|
279
279
|
|
|
@@ -38,7 +38,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
38
38
|
const statusListMaster = await this.dataSource.query(
|
|
39
39
|
`SELECT id, name
|
|
40
40
|
FROM frm_list_master_items
|
|
41
|
-
WHERE listtype = 'STS' AND organization_id =
|
|
41
|
+
WHERE listtype = 'STS' AND organization_id = $1`,
|
|
42
42
|
[organization_id],
|
|
43
43
|
);
|
|
44
44
|
|
|
@@ -94,12 +94,12 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
94
94
|
// 3) Lead status (parameterized)
|
|
95
95
|
let leadStatus: string | null = null;
|
|
96
96
|
const leadData = await this.dataSource.query(
|
|
97
|
-
`SELECT lead_status FROM crm_lead WHERE id =
|
|
97
|
+
`SELECT lead_status FROM crm_lead WHERE id = $1`,
|
|
98
98
|
[lead_id],
|
|
99
99
|
);
|
|
100
100
|
if (leadData.length > 0 && leadData[0].lead_status != null) {
|
|
101
101
|
const leadStatusResolved = await this.dataSource.query(
|
|
102
|
-
`SELECT name FROM frm_list_master_items WHERE id =
|
|
102
|
+
`SELECT name FROM frm_list_master_items WHERE id = $1 AND organization_id = $2`,
|
|
103
103
|
[leadData[0].lead_status, loggedInUser.organization_id],
|
|
104
104
|
);
|
|
105
105
|
if (leadStatusResolved.length > 0) {
|
|
@@ -298,7 +298,7 @@ export class StageGroupService extends EntityServiceImpl {
|
|
|
298
298
|
loggedInUser: UserData,
|
|
299
299
|
): Promise<any> {
|
|
300
300
|
const getAllStage = await this.dataSource.query(
|
|
301
|
-
`SELECT id FROM frm_wf_stage WHERE stage_group_id =
|
|
301
|
+
`SELECT id FROM frm_wf_stage WHERE stage_group_id = $1 AND level_id = $2 AND level_type = $3`,
|
|
302
302
|
[id, loggedInUser.level_id, loggedInUser.level_type],
|
|
303
303
|
);
|
|
304
304
|
|
|
@@ -48,7 +48,7 @@ export class StageService extends EntityServiceImpl {
|
|
|
48
48
|
const statusListMaster = await this.dataSource.query(
|
|
49
49
|
`SELECT id, name
|
|
50
50
|
FROM frm_list_master_items
|
|
51
|
-
WHERE listtype = 'STS' AND organization_id =
|
|
51
|
+
WHERE listtype = 'STS' AND organization_id = $1`,
|
|
52
52
|
[organization_id],
|
|
53
53
|
);
|
|
54
54
|
|
|
@@ -133,7 +133,7 @@ export class StageService extends EntityServiceImpl {
|
|
|
133
133
|
loggedInUser: UserData,
|
|
134
134
|
): Promise<any> {
|
|
135
135
|
const getAllStageAction = await this.dataSource.query(
|
|
136
|
-
`SELECT action_id FROM frm_wf_stage_action_mapping WHERE stage_id =
|
|
136
|
+
`SELECT action_id FROM frm_wf_stage_action_mapping WHERE stage_id = $1 AND entity_type = 'WFSA'`,
|
|
137
137
|
[id],
|
|
138
138
|
);
|
|
139
139
|
|
|
@@ -37,7 +37,7 @@ export class TaskService extends EntityServiceImpl {
|
|
|
37
37
|
const stageRow = await this.dataSource.query(
|
|
38
38
|
`SELECT stage_id
|
|
39
39
|
FROM frm_wf_stage_movement_data
|
|
40
|
-
WHERE mapped_entity_id =
|
|
40
|
+
WHERE mapped_entity_id = $1
|
|
41
41
|
AND is_current = 'Y'
|
|
42
42
|
LIMIT 1`,
|
|
43
43
|
[entity.id],
|
|
@@ -121,13 +121,13 @@ export class TaskService extends EntityServiceImpl {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
let relationData = await this.dataSource.query(
|
|
124
|
-
`SELECT * FROM frm_entity_relation WHERE source_entity_type =
|
|
124
|
+
`SELECT * FROM frm_entity_relation WHERE source_entity_type = $1 AND target_entity_type = $2`,
|
|
125
125
|
[createdEntity.mapped_entity_type, createdEntity.entity_type],
|
|
126
126
|
);
|
|
127
127
|
|
|
128
128
|
if (relationData) {
|
|
129
129
|
await this.dataSource.query(
|
|
130
|
-
`INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES (
|
|
130
|
+
`INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type, target_entity_id, target_entity_type, relation_type) VALUES ($1, $2, $3, $4, $5 , $6)`,
|
|
131
131
|
[
|
|
132
132
|
loggedInUser.organization_id,
|
|
133
133
|
createdEntity.mapped_entity_id,
|
|
@@ -150,8 +150,8 @@ export class TaskService extends EntityServiceImpl {
|
|
|
150
150
|
const taskStatusQuery = `
|
|
151
151
|
SELECT name
|
|
152
152
|
FROM frm_list_master_items
|
|
153
|
-
WHERE id =
|
|
154
|
-
AND organization_id =
|
|
153
|
+
WHERE id = $1
|
|
154
|
+
AND organization_id = $2
|
|
155
155
|
AND listtype = 'TKST'
|
|
156
156
|
LIMIT 1;
|
|
157
157
|
`;
|
|
@@ -539,7 +539,7 @@ export class TaskService extends EntityServiceImpl {
|
|
|
539
539
|
if (!entity || !entity.mapped_entity_id || !entity.reason_code) return null;
|
|
540
540
|
|
|
541
541
|
const [reason] = await this.dataSource.query(
|
|
542
|
-
`SELECT name FROM frm_list_master_items WHERE id =
|
|
542
|
+
`SELECT name FROM frm_list_master_items WHERE id = $1 AND organization_id = $2`,
|
|
543
543
|
[entity.reason_code, loggedInUser.organization_id],
|
|
544
544
|
);
|
|
545
545
|
|
|
@@ -19,7 +19,7 @@ export class WorkflowListMasterService extends EntityServiceImpl {
|
|
|
19
19
|
FROM frm_wf_stage_action_mapping sam
|
|
20
20
|
JOIN frm_wf_action a ON sam.action_id = a.id
|
|
21
21
|
JOIN frm_wf_action_category ac ON a.action_category = ac.id
|
|
22
|
-
WHERE sam.stage_id =
|
|
22
|
+
WHERE sam.stage_id = $1
|
|
23
23
|
`,
|
|
24
24
|
[stageId],
|
|
25
25
|
);
|
|
@@ -36,7 +36,7 @@ export class WorkflowListMasterService extends EntityServiceImpl {
|
|
|
36
36
|
|
|
37
37
|
async getStagesByGroup(stageGroupId: number): Promise<any[]> {
|
|
38
38
|
const results = await this.dataSource.query(
|
|
39
|
-
`SELECT id, full_name FROM frm_wf_stage WHERE stage_group_id =
|
|
39
|
+
`SELECT id, full_name FROM frm_wf_stage WHERE stage_group_id = $1`,
|
|
40
40
|
[stageGroupId],
|
|
41
41
|
);
|
|
42
42
|
return results;
|
|
@@ -50,7 +50,7 @@ export class WorkflowListMasterService extends EntityServiceImpl {
|
|
|
50
50
|
SELECT id, name
|
|
51
51
|
FROM frm_list_master_items
|
|
52
52
|
WHERE listtype = 'MOD'
|
|
53
|
-
AND organization_id =
|
|
53
|
+
AND organization_id = $1
|
|
54
54
|
`,
|
|
55
55
|
[organization_id],
|
|
56
56
|
);
|
|
@@ -400,8 +400,8 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
400
400
|
const unassignedListMasterItemData = await this.dataSource.query(
|
|
401
401
|
`SELECT name, id
|
|
402
402
|
FROM frm_list_master_items
|
|
403
|
-
WHERE listtype = "LEST" AND organization_id =
|
|
404
|
-
AND value IN (
|
|
403
|
+
WHERE listtype = "LEST" AND organization_id = $1
|
|
404
|
+
AND value IN ($2, $3)`,
|
|
405
405
|
[loggedInUser.organization_id, 'unassigned', 'active'],
|
|
406
406
|
);
|
|
407
407
|
|
|
@@ -429,19 +429,19 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
429
429
|
);
|
|
430
430
|
|
|
431
431
|
await this.dataSource.query(
|
|
432
|
-
`UPDATE frm_wf_action_data SET user_id
|
|
433
|
-
WHERE mapped_entity_id
|
|
434
|
-
AND mapped_entity_type =
|
|
435
|
-
AND stage_id =
|
|
432
|
+
`UPDATE frm_wf_action_data SET user_id =$1
|
|
433
|
+
WHERE mapped_entity_id=$2
|
|
434
|
+
AND mapped_entity_type = $3
|
|
435
|
+
AND stage_id = $4
|
|
436
436
|
AND (is_current = 'Y' OR is_current IS NULL)
|
|
437
437
|
`,
|
|
438
438
|
[lead_owner, lead_id, entity_type, stage_id],
|
|
439
439
|
);
|
|
440
440
|
|
|
441
441
|
await this.dataSource.query(
|
|
442
|
-
`UPDATE crm_lead_meeting SET user_id
|
|
443
|
-
WHERE stage_id =
|
|
444
|
-
AND mapped_entity_id =
|
|
442
|
+
`UPDATE crm_lead_meeting SET user_id=$1
|
|
443
|
+
WHERE stage_id = $2
|
|
444
|
+
AND mapped_entity_id = $3
|
|
445
445
|
AND mapped_entity_type = "LEAD"
|
|
446
446
|
AND (status='scheduled' OR status='rescheduled')
|
|
447
447
|
`,
|
|
@@ -450,16 +450,16 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
450
450
|
|
|
451
451
|
const taskRows = await this.dataSource.query(
|
|
452
452
|
`SELECT id,status FROM frm_wf_task_data
|
|
453
|
-
WHERE mapped_entity_id =
|
|
454
|
-
AND mapped_entity_type =
|
|
455
|
-
AND stage_id =
|
|
453
|
+
WHERE mapped_entity_id = $1
|
|
454
|
+
AND mapped_entity_type = $2
|
|
455
|
+
AND stage_id = $3`,
|
|
456
456
|
[lead_id, entity_type, stage_id],
|
|
457
457
|
);
|
|
458
458
|
|
|
459
459
|
for (const task of taskRows) {
|
|
460
460
|
const statusRows = await this.dataSource.query(
|
|
461
461
|
`SELECT value FROM frm_list_master_items
|
|
462
|
-
WHERE id =
|
|
462
|
+
WHERE id = $1 AND organization_id = $2`,
|
|
463
463
|
[task.status, loggedInUser.organization_id],
|
|
464
464
|
);
|
|
465
465
|
|
|
@@ -469,14 +469,14 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
469
469
|
statusName === 'todo'
|
|
470
470
|
) {
|
|
471
471
|
await this.dataSource.query(
|
|
472
|
-
`UPDATE frm_wf_task_data SET user_id =
|
|
472
|
+
`UPDATE frm_wf_task_data SET user_id = $1, task_owner = $2 WHERE id = $3`,
|
|
473
473
|
[lead_owner, lead_owner, task.id],
|
|
474
474
|
);
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
const leadOwnerName = await this.dataSource.query(
|
|
479
|
-
`SELECT name FROM sso_user WHERE id =
|
|
479
|
+
`SELECT name FROM sso_user WHERE id = $1`,
|
|
480
480
|
[entityData?.lead_owner],
|
|
481
481
|
);
|
|
482
482
|
|
|
@@ -567,9 +567,9 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
567
567
|
`
|
|
568
568
|
SELECT lead_owner
|
|
569
569
|
FROM crm_lead
|
|
570
|
-
WHERE organization_id =
|
|
571
|
-
AND level_id =
|
|
572
|
-
AND level_type =
|
|
570
|
+
WHERE organization_id = $1
|
|
571
|
+
AND level_id = $2
|
|
572
|
+
AND level_type = $3
|
|
573
573
|
AND lead_owner IN (${placeholders})
|
|
574
574
|
ORDER BY created_date DESC
|
|
575
575
|
LIMIT 1
|
|
@@ -588,10 +588,10 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
588
588
|
await this.dataSource.query(
|
|
589
589
|
`
|
|
590
590
|
UPDATE crm_lead
|
|
591
|
-
SET lead_owner =
|
|
592
|
-
WHERE organization_id =
|
|
593
|
-
AND level_id =
|
|
594
|
-
AND level_type =
|
|
591
|
+
SET lead_owner = $1
|
|
592
|
+
WHERE organization_id = $2
|
|
593
|
+
AND level_id = $3
|
|
594
|
+
AND level_type = $4
|
|
595
595
|
AND lead_owner IS NULL
|
|
596
596
|
ORDER BY created_date ASC
|
|
597
597
|
LIMIT 1
|
|
@@ -40,7 +40,7 @@ export class WorkflowService extends EntityServiceImpl {
|
|
|
40
40
|
|
|
41
41
|
async getWorkflowById(id: number) {
|
|
42
42
|
const result = await this.dataSource.query(
|
|
43
|
-
`SELECT * FROM frm_wf_master WHERE id =
|
|
43
|
+
`SELECT * FROM frm_wf_master WHERE id = $1`,
|
|
44
44
|
[id],
|
|
45
45
|
);
|
|
46
46
|
return result[0] || null;
|
|
@@ -108,8 +108,8 @@ export class WorkflowService extends EntityServiceImpl {
|
|
|
108
108
|
// Update frm_wf_level_mapping to point to the new workflow
|
|
109
109
|
await this.dataSource.query(
|
|
110
110
|
`UPDATE frm_wf_level_mapping
|
|
111
|
-
SET workflow_id =
|
|
112
|
-
WHERE mapped_level_id =
|
|
111
|
+
SET workflow_id = $1
|
|
112
|
+
WHERE mapped_level_id = $2 AND mapped_level_type = $3`,
|
|
113
113
|
[workflowId, level_id, level_type],
|
|
114
114
|
);
|
|
115
115
|
}
|
|
@@ -146,7 +146,7 @@ export class WorkflowService extends EntityServiceImpl {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
const getAllStageGroup = await this.dataSource.query(
|
|
149
|
-
`SELECT id FROM frm_wf_stage_group WHERE workflow_id =
|
|
149
|
+
`SELECT id FROM frm_wf_stage_group WHERE workflow_id = $1 AND level_id = $2 AND level_type = $3`,
|
|
150
150
|
[id, loggedInUser.level_id, loggedInUser.level_type],
|
|
151
151
|
);
|
|
152
152
|
|
|
@@ -166,7 +166,7 @@ export class WorkflowAutomationEngineService {
|
|
|
166
166
|
try {
|
|
167
167
|
// 2 Resolve action_decorator using action_category_id
|
|
168
168
|
const [category] = await this.dataSource.query(
|
|
169
|
-
`SELECT action_decorator FROM frm_wf_action_category WHERE id =
|
|
169
|
+
`SELECT action_decorator FROM frm_wf_action_category WHERE id = $1`,
|
|
170
170
|
[action.action_category_id],
|
|
171
171
|
);
|
|
172
172
|
|
|
@@ -55,7 +55,7 @@ export class ReflectionHelper {
|
|
|
55
55
|
async getEntityData(id: number, tableName: string) {
|
|
56
56
|
const entityList = await this.dataSource.query(`SELECT *
|
|
57
57
|
FROM ${tableName}
|
|
58
|
-
WHERE id =
|
|
58
|
+
WHERE id = $1`, [id]);
|
|
59
59
|
|
|
60
60
|
return entityList.length > 0 ? entityList[0] : null;
|
|
61
61
|
}
|