rez_core 3.1.89 → 3.1.92
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/service/filter.service.js +34 -71
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js +1 -2
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js.map +1 -1
- package/dist/module/mapper/controller/field-mapper.controller.d.ts +1 -1
- package/dist/module/mapper/controller/field-mapper.controller.js +7 -5
- package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -1
- package/dist/module/mapper/repository/field-mapper.repository.js +1 -0
- package/dist/module/mapper/repository/field-mapper.repository.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +1 -1
- package/dist/module/mapper/service/field-mapper.service.js +2 -2
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/meta/controller/media.controller.js +1 -1
- package/dist/module/meta/controller/media.controller.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +6 -2
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.js +1 -1
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +1 -3
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +12 -16
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +123 -338
- package/src/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.ts +8 -9
- package/src/module/mapper/controller/field-mapper.controller.ts +4 -1
- package/src/module/mapper/repository/field-mapper.repository.ts +1 -0
- package/src/module/mapper/service/field-mapper.service.ts +2 -2
- package/src/module/meta/controller/media.controller.ts +2 -1
- package/src/module/meta/service/entity-dynamic.service.ts +6 -2
- package/src/module/meta/service/media-data.service.ts +1 -1
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +25 -62
|
@@ -32,7 +32,7 @@ interface TubelightApiResponse {
|
|
|
32
32
|
export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
33
33
|
private readonly logger = new Logger(TubelightWhatsAppStrategy.name);
|
|
34
34
|
private readonly defaultBaseUrl =
|
|
35
|
-
|
|
35
|
+
'https://portal.tubelightcommunications.com/whatsapp/api/v1';
|
|
36
36
|
|
|
37
37
|
async sendMessage(
|
|
38
38
|
to: string,
|
|
@@ -86,8 +86,8 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
86
86
|
} else {
|
|
87
87
|
throw new Error(
|
|
88
88
|
response.data?.error ||
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
response.data?.message ||
|
|
90
|
+
'Invalid response from Tubelight API',
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
} catch (error) {
|
|
@@ -160,7 +160,7 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
160
160
|
const basePayload = {
|
|
161
161
|
cust_uuid: config.custUuid || randomUUID(),
|
|
162
162
|
to: [this.formatPhoneNumber(to)],
|
|
163
|
-
|
|
163
|
+
};
|
|
164
164
|
|
|
165
165
|
// If templateId exists, send template message
|
|
166
166
|
if (config.templateId || config.templateName) {
|
|
@@ -286,8 +286,7 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
286
286
|
throw new Error('Authentication failed');
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
const
|
|
290
|
-
const url = `${baseUrl}/retreive/template`;
|
|
289
|
+
const url = `${this.defaultBaseUrl}/retreive/template`;
|
|
291
290
|
|
|
292
291
|
const response = await axios.post(
|
|
293
292
|
url,
|
|
@@ -305,9 +304,9 @@ export class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
|
305
304
|
// Format the response with templateName as both label and value
|
|
306
305
|
const formattedTemplates = Array.isArray(templates)
|
|
307
306
|
? templates.map((template: any) => ({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
307
|
+
label: template.templateName,
|
|
308
|
+
value: template.templateName,
|
|
309
|
+
}))
|
|
311
310
|
: [];
|
|
312
311
|
|
|
313
312
|
return {
|
|
@@ -27,16 +27,19 @@ export class FieldMapperController {
|
|
|
27
27
|
async resolve(
|
|
28
28
|
@Req() req: any,
|
|
29
29
|
@Query('integration_component') integration_component: number,
|
|
30
|
+
@Query('action') action: 'LOOKUP' | 'LOAD',
|
|
30
31
|
@Query('entity_type') entity_type: string,
|
|
31
32
|
@Query('entity_id') entity_id: number,
|
|
33
|
+
@Body() inputJson,
|
|
32
34
|
) {
|
|
33
35
|
const loggedInUser = req.user.userData;
|
|
34
36
|
return this.fieldMapperService.resolveData(
|
|
35
37
|
integration_component,
|
|
36
|
-
|
|
38
|
+
action,
|
|
37
39
|
entity_type,
|
|
38
40
|
entity_id,
|
|
39
41
|
loggedInUser,
|
|
42
|
+
inputJson,
|
|
40
43
|
);
|
|
41
44
|
}
|
|
42
45
|
|
|
@@ -92,7 +92,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
92
92
|
const fieldMappers =
|
|
93
93
|
await this.fieldMapperRepository.findByMapperId(mapper_id);
|
|
94
94
|
|
|
95
|
-
const result
|
|
95
|
+
const result = new Map<string, any>();
|
|
96
96
|
const inMemory: Record<string, Record<string, any>> = {}; // cache for entity lookups
|
|
97
97
|
|
|
98
98
|
for (const field of fieldMappers) {
|
|
@@ -179,7 +179,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// Add to result
|
|
182
|
-
result
|
|
182
|
+
result.set(field.source_attribute, value);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
HttpStatus,
|
|
6
6
|
Param,
|
|
7
7
|
Post,
|
|
8
|
+
Query,
|
|
8
9
|
Req,
|
|
9
10
|
Res,
|
|
10
11
|
UseGuards,
|
|
@@ -57,7 +58,7 @@ export class MediaController {
|
|
|
57
58
|
@Param('id') id: number,
|
|
58
59
|
@Res() res: Response,
|
|
59
60
|
@Req() req: Request & { user: any },
|
|
60
|
-
@
|
|
61
|
+
@Query('expiresIn') expiresIn?: number,
|
|
61
62
|
) {
|
|
62
63
|
const loggedInUser = req.user.userData;
|
|
63
64
|
try {
|
|
@@ -612,10 +612,14 @@ export class EntityDynamicService {
|
|
|
612
612
|
}[]
|
|
613
613
|
> {
|
|
614
614
|
const result = await this.dataSource.query(
|
|
615
|
-
`SELECT attribute_key,
|
|
615
|
+
`SELECT attribute_key,
|
|
616
|
+
MAX(db_datatype) AS db_datatype,
|
|
617
|
+
MAX(element_type) AS element_type,
|
|
618
|
+
MAX(is_hidden) AS is_hidden
|
|
616
619
|
FROM cr_attribute_master
|
|
617
620
|
WHERE mapped_entity_type = ? AND organization_id = ?
|
|
618
|
-
and (is_hidden IS NULL OR is_hidden = 0) -- Exclude hidden attributes
|
|
621
|
+
and (is_hidden IS NULL OR is_hidden = 0) -- Exclude hidden attributes
|
|
622
|
+
GROUP BY attribute_key`,
|
|
619
623
|
[entityType, organizationId],
|
|
620
624
|
);
|
|
621
625
|
|
|
@@ -129,7 +129,7 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
129
129
|
const signedUrl = await this.s3.getSignedUrlPromise('getObject', {
|
|
130
130
|
Bucket: this.bucketName,
|
|
131
131
|
Key: mediaData.media_url,
|
|
132
|
-
Expires: expiresIn || 60 * 5, // URL valid for 5 mins or custom time
|
|
132
|
+
Expires: Number(expiresIn) || 60 * 5, // URL valid for 5 mins or custom time
|
|
133
133
|
});
|
|
134
134
|
return { signedUrl, fileName: mediaData.file_name, id: mediaData.id };
|
|
135
135
|
} catch (error) {
|
|
@@ -4,7 +4,6 @@ import { WorkflowAutomationService } from './workflow-automation.service';
|
|
|
4
4
|
import { FilterEvaluatorService } from '../../filter/service/filter-evaluator.service';
|
|
5
5
|
import { Action } from '../interface/action.interface';
|
|
6
6
|
import { DataSource } from 'typeorm';
|
|
7
|
-
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
8
7
|
|
|
9
8
|
@Injectable()
|
|
10
9
|
export class WorkflowAutomationEngineService {
|
|
@@ -15,16 +14,12 @@ export class WorkflowAutomationEngineService {
|
|
|
15
14
|
private readonly wfService: WorkflowAutomationService,
|
|
16
15
|
private readonly filterEvaluator: FilterEvaluatorService,
|
|
17
16
|
private readonly dataSource: DataSource,
|
|
18
|
-
@Inject() protected readonly loggingService: LoggingService,
|
|
19
17
|
) {}
|
|
20
18
|
|
|
21
19
|
registerAction(actionName: string, actionInstance: Action) {
|
|
22
20
|
this.actions.set(actionName, actionInstance);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'WorkflowAutomationEngine',
|
|
26
|
-
'registerAction',
|
|
27
|
-
`Registered action ${actionName}`,
|
|
21
|
+
console.log(
|
|
22
|
+
`⚙️ [WorkflowAutomationEngine] Registered action: ${actionName}`,
|
|
28
23
|
);
|
|
29
24
|
}
|
|
30
25
|
|
|
@@ -39,12 +34,9 @@ export class WorkflowAutomationEngineService {
|
|
|
39
34
|
user: any,
|
|
40
35
|
preUpdateStates?: Record<number, boolean> | null,
|
|
41
36
|
) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'handleEntityEvent',
|
|
46
|
-
`Handling entity event: ${eventType} for entityType: ${entityType}`,
|
|
47
|
-
[newEntity?.id, preUpdateStates],
|
|
37
|
+
console.log(
|
|
38
|
+
`🟢 [WorkflowAutomationEngine] Handling entity event: ${eventType} for entityType: ${entityType}`,
|
|
39
|
+
{ entityId: newEntity?.id, preUpdateStates },
|
|
48
40
|
);
|
|
49
41
|
|
|
50
42
|
const workflows = await this.wfService.getActiveRules(
|
|
@@ -76,22 +68,17 @@ export class WorkflowAutomationEngineService {
|
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
// 🔍 Log Step 1 result
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'WorkflowAutomationEngine',
|
|
82
|
-
'handleEntityEvent',
|
|
83
|
-
`Step 1 - Trigger matched`,
|
|
84
|
-
[wf.id, triggerMatched],
|
|
71
|
+
console.log(
|
|
72
|
+
`🧩 [WorkflowAutomationEngine] Step 1 - Trigger matched for WF ${wf.id}: ${triggerMatched}`,
|
|
85
73
|
);
|
|
86
74
|
|
|
87
75
|
if (!triggerMatched) continue;
|
|
88
76
|
|
|
89
77
|
// Step 2️⃣ Final criteria evaluation
|
|
90
|
-
|
|
91
78
|
const entityIdToUse =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
79
|
+
wf.mapped_entity_type === wf.applicable_entity_type
|
|
80
|
+
? newEntity.id
|
|
81
|
+
: newEntity.parent_id;
|
|
95
82
|
|
|
96
83
|
const criteriaMatched = await this.filterEvaluator.evaluateCriteria(
|
|
97
84
|
wf.mapped_entity_type,
|
|
@@ -101,12 +88,8 @@ export class WorkflowAutomationEngineService {
|
|
|
101
88
|
);
|
|
102
89
|
|
|
103
90
|
// 🔍 Log Step 2 result
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'WorkflowAutomationEngine',
|
|
107
|
-
'handleEntityEvent',
|
|
108
|
-
`Step 2 - Criteria matched`,
|
|
109
|
-
[wf.id, criteriaMatched],
|
|
91
|
+
console.log(
|
|
92
|
+
`⚖️ [WorkflowAutomationEngine] Step 2 - Criteria matched for WF ${wf.id}: ${criteriaMatched}`,
|
|
110
93
|
);
|
|
111
94
|
|
|
112
95
|
if (!criteriaMatched) continue;
|
|
@@ -127,11 +110,8 @@ export class WorkflowAutomationEngineService {
|
|
|
127
110
|
);
|
|
128
111
|
|
|
129
112
|
if (!actions.length) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
'WorkflowAutomationEngine',
|
|
133
|
-
'executeActions',
|
|
134
|
-
`No actions found for workflow ${workflow_automation_id}`,
|
|
113
|
+
console.warn(
|
|
114
|
+
`⚠️ [WorkflowAutomationEngine] No actions found for workflow ${workflow_automation_id}`,
|
|
135
115
|
);
|
|
136
116
|
return;
|
|
137
117
|
}
|
|
@@ -145,11 +125,8 @@ export class WorkflowAutomationEngineService {
|
|
|
145
125
|
);
|
|
146
126
|
|
|
147
127
|
if (!category?.action_decorator) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'WorkflowAutomationEngine',
|
|
151
|
-
'executeActions',
|
|
152
|
-
`No action_decorator found for category_id=${action.action_category_id}`,
|
|
128
|
+
console.warn(
|
|
129
|
+
`⚠️ [WorkflowAutomationEngine] No action_decorator found for category_id=${action.action_category_id}`,
|
|
153
130
|
);
|
|
154
131
|
continue;
|
|
155
132
|
}
|
|
@@ -160,21 +137,14 @@ export class WorkflowAutomationEngineService {
|
|
|
160
137
|
const impl = this.actions.get(decorator);
|
|
161
138
|
|
|
162
139
|
if (!impl) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
'WorkflowAutomationEngine',
|
|
166
|
-
'executeActions',
|
|
167
|
-
`No implementation found for action: ${decorator}`,
|
|
140
|
+
console.warn(
|
|
141
|
+
`⚠️ [WorkflowAutomationEngine] No implementation found for action: ${decorator}`,
|
|
168
142
|
);
|
|
169
143
|
continue;
|
|
170
144
|
}
|
|
171
145
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'WorkflowAutomationEngine',
|
|
175
|
-
'executeActions',
|
|
176
|
-
`Executing action ${decorator} for entity ${entity.id}`,
|
|
177
|
-
[workflow_automation_id],
|
|
146
|
+
console.log(
|
|
147
|
+
`🚀 [WorkflowAutomationEngine] Executing action "${decorator}" for entity ${entity.id} (WF ${workflow_automation_id})`,
|
|
178
148
|
);
|
|
179
149
|
|
|
180
150
|
// 4️ Execute action with required context
|
|
@@ -184,20 +154,13 @@ export class WorkflowAutomationEngineService {
|
|
|
184
154
|
config: action.payload, // from cr_wf_action table
|
|
185
155
|
});
|
|
186
156
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
'WorkflowAutomationEngine',
|
|
190
|
-
'executeActions',
|
|
191
|
-
`Action ${decorator} executed successfully`,
|
|
192
|
-
[workflow_automation_id],
|
|
157
|
+
console.log(
|
|
158
|
+
`✅ [WorkflowAutomationEngine] Action "${decorator}" executed successfully (WF ${workflow_automation_id})`,
|
|
193
159
|
);
|
|
194
160
|
} catch (err) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
'executeActions',
|
|
199
|
-
`Error executing action (category_id=${action.action_category_id})`,
|
|
200
|
-
[err],
|
|
161
|
+
console.error(
|
|
162
|
+
`❌ [WorkflowAutomationEngine] Error executing action (category_id=${action.action_category_id}):`,
|
|
163
|
+
err,
|
|
201
164
|
);
|
|
202
165
|
}
|
|
203
166
|
}
|