rez_core 2.2.154 → 2.2.156
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/app.module.js +2 -0
- package/dist/app.module.js.map +1 -1
- package/dist/constant/global.constant.d.ts +1 -1
- package/dist/constant/global.constant.js +1 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/auth/strategies/google.strategy.js +1 -1
- package/dist/module/auth/strategies/google.strategy.js.map +1 -1
- package/dist/module/communication/communication.module.d.ts +2 -0
- package/dist/module/communication/communication.module.js +69 -0
- package/dist/module/communication/communication.module.js.map +1 -0
- package/dist/module/communication/controller/communication.controller.d.ts +54 -0
- package/dist/module/communication/controller/communication.controller.js +148 -0
- package/dist/module/communication/controller/communication.controller.js.map +1 -0
- package/dist/module/communication/dto/create-config.dto.d.ts +91 -0
- package/dist/module/communication/dto/create-config.dto.js +243 -0
- package/dist/module/communication/dto/create-config.dto.js.map +1 -0
- package/dist/module/communication/entity/communication-config.entity.d.ts +44 -0
- package/dist/module/communication/entity/communication-config.entity.js +45 -0
- package/dist/module/communication/entity/communication-config.entity.js.map +1 -0
- package/dist/module/communication/entity/communication-hub.entity.d.ts +20 -0
- package/dist/module/communication/entity/communication-hub.entity.js +105 -0
- package/dist/module/communication/entity/communication-hub.entity.js.map +1 -0
- package/dist/module/communication/examples/usage.example.d.ts +11 -0
- package/dist/module/communication/examples/usage.example.js +89 -0
- package/dist/module/communication/examples/usage.example.js.map +1 -0
- package/dist/module/communication/factories/base.factory.d.ts +9 -0
- package/dist/module/communication/factories/base.factory.js +3 -0
- package/dist/module/communication/factories/base.factory.js.map +1 -0
- package/dist/module/communication/factories/communication.factory.d.ts +33 -0
- package/dist/module/communication/factories/communication.factory.js +104 -0
- package/dist/module/communication/factories/communication.factory.js.map +1 -0
- package/dist/module/communication/factories/email.factory.d.ts +19 -0
- package/dist/module/communication/factories/email.factory.js +61 -0
- package/dist/module/communication/factories/email.factory.js.map +1 -0
- package/dist/module/communication/factories/sms.factory.d.ts +15 -0
- package/dist/module/communication/factories/sms.factory.js +49 -0
- package/dist/module/communication/factories/sms.factory.js.map +1 -0
- package/dist/module/communication/factories/telephone.factory.d.ts +13 -0
- package/dist/module/communication/factories/telephone.factory.js +43 -0
- package/dist/module/communication/factories/telephone.factory.js.map +1 -0
- package/dist/module/communication/factories/whatsapp.factory.d.ts +13 -0
- package/dist/module/communication/factories/whatsapp.factory.js +43 -0
- package/dist/module/communication/factories/whatsapp.factory.js.map +1 -0
- package/dist/module/communication/service/communication.service.d.ts +111 -0
- package/dist/module/communication/service/communication.service.js +726 -0
- package/dist/module/communication/service/communication.service.js.map +1 -0
- package/dist/module/communication/service/oauth.service.d.ts +18 -0
- package/dist/module/communication/service/oauth.service.js +185 -0
- package/dist/module/communication/service/oauth.service.js.map +1 -0
- package/dist/module/communication/strategies/communication.strategy.d.ts +17 -0
- package/dist/module/communication/strategies/communication.strategy.js +3 -0
- package/dist/module/communication/strategies/communication.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.d.ts +7 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.js +135 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js +49 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.js +44 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.js.map +1 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.js +61 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/gmail.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/gmail.strategy.js +71 -0
- package/dist/module/communication/strategies/gmail.strategy.js.map +1 -0
- package/dist/module/communication/strategies/knowlarity.strategy.d.ts +6 -0
- package/dist/module/communication/strategies/knowlarity.strategy.js +115 -0
- package/dist/module/communication/strategies/knowlarity.strategy.js.map +1 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.js +66 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/outlook.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/outlook.strategy.js +64 -0
- package/dist/module/communication/strategies/outlook.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js +44 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.js +44 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms.strategy.js +50 -0
- package/dist/module/communication/strategies/sms.strategy.js.map +1 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js +44 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js.map +1 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js +47 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js.map +1 -0
- package/dist/module/communication/strategies/whatsapp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/whatsapp.strategy.js +58 -0
- package/dist/module/communication/strategies/whatsapp.strategy.js.map +1 -0
- package/dist/module/meta/entity.module.js +2 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +4 -2
- package/dist/module/user/controller/login.controller.js +26 -4
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js +2 -2
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.js +1 -1
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/src/app.module.ts +2 -0
- package/src/constant/global.constant.ts +1 -1
- package/src/module/auth/strategies/google.strategy.ts +1 -1
- package/src/module/communication/communication.module.ts +77 -0
- package/src/module/communication/controller/communication.controller.ts +122 -0
- package/src/module/communication/dto/create-config.dto.ts +234 -0
- package/src/module/communication/entity/communication-config.entity.ts +80 -0
- package/src/module/communication/entity/communication-hub.entity.ts +77 -0
- package/src/module/communication/examples/usage.example.ts +169 -0
- package/src/module/communication/factories/base.factory.ts +7 -0
- package/src/module/communication/factories/communication.factory.ts +103 -0
- package/src/module/communication/factories/email.factory.ts +51 -0
- package/src/module/communication/factories/sms.factory.ts +41 -0
- package/src/module/communication/factories/telephone.factory.ts +34 -0
- package/src/module/communication/factories/whatsapp.factory.ts +34 -0
- package/src/module/communication/service/communication.service.ts +1118 -0
- package/src/module/communication/service/oauth.service.ts +203 -0
- package/src/module/communication/strategies/communication.strategy.ts +23 -0
- package/src/module/communication/strategies/email/gmail-api.strategy.ts +161 -0
- package/src/module/communication/strategies/email/gmail-smtp.strategy.ts +51 -0
- package/src/module/communication/strategies/email/outlook-api.strategy.ts +44 -0
- package/src/module/communication/strategies/gmail-smtp.strategy.ts +64 -0
- package/src/module/communication/strategies/gmail.strategy.ts +68 -0
- package/src/module/communication/strategies/knowlarity.strategy.ts +124 -0
- package/src/module/communication/strategies/outlook-smtp.strategy.ts +69 -0
- package/src/module/communication/strategies/outlook.strategy.ts +57 -0
- package/src/module/communication/strategies/sms/knowlarity.strategy.ts +44 -0
- package/src/module/communication/strategies/sms/twilio.strategy.ts +44 -0
- package/src/module/communication/strategies/sms.strategy.ts +44 -0
- package/src/module/communication/strategies/telephone/knowlarity-voice.strategy.ts +44 -0
- package/src/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.ts +49 -0
- package/src/module/communication/strategies/whatsapp.strategy.ts +53 -0
- package/src/module/meta/entity.module.ts +2 -1
- package/src/module/user/controller/login.controller.ts +34 -3
- package/src/module/workflow/service/populate-workflow.service.ts +3 -3
- package/src/module/workflow/service/stage.service.ts +1 -1
- package/src/resources/dev.properties.yaml +1 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { CommunicationStrategy, CommunicationResult } from './communication.strategy';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class KnowlarityStrategy implements CommunicationStrategy {
|
|
7
|
+
async sendMessage(to: string, message: string, config: any): Promise<CommunicationResult> {
|
|
8
|
+
try {
|
|
9
|
+
const {
|
|
10
|
+
apiKey,
|
|
11
|
+
apiSecret,
|
|
12
|
+
callerNumber,
|
|
13
|
+
baseUrl = 'https://kpi.knowlarity.com/Basic',
|
|
14
|
+
callType = 'voice',
|
|
15
|
+
language = 'en'
|
|
16
|
+
} = config;
|
|
17
|
+
|
|
18
|
+
if (callType === 'voice') {
|
|
19
|
+
const callData = {
|
|
20
|
+
k_number: callerNumber,
|
|
21
|
+
agent_number: to,
|
|
22
|
+
caller_id: callerNumber,
|
|
23
|
+
voice_message: config.voiceMessage || message,
|
|
24
|
+
language: language,
|
|
25
|
+
api_key: apiKey,
|
|
26
|
+
api_secret: apiSecret,
|
|
27
|
+
format: 'json'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const response = await axios.post(`${baseUrl}/start_call.php`, callData, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
33
|
+
},
|
|
34
|
+
transformRequest: [(data) => {
|
|
35
|
+
return Object.keys(data)
|
|
36
|
+
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)
|
|
37
|
+
.join('&');
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
success: response.data.status === 'success',
|
|
43
|
+
provider: 'knowlarity',
|
|
44
|
+
service: 'THIRD_PARTY',
|
|
45
|
+
messageId: response.data.call_id,
|
|
46
|
+
timestamp: new Date(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (callType === 'sms') {
|
|
51
|
+
const smsData = {
|
|
52
|
+
k_number: callerNumber,
|
|
53
|
+
agent_number: to,
|
|
54
|
+
sms_text: message,
|
|
55
|
+
api_key: apiKey,
|
|
56
|
+
api_secret: apiSecret,
|
|
57
|
+
format: 'json'
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const response = await axios.post(`${baseUrl}/send_sms.php`, smsData, {
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
63
|
+
},
|
|
64
|
+
transformRequest: [(data) => {
|
|
65
|
+
return Object.keys(data)
|
|
66
|
+
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)
|
|
67
|
+
.join('&');
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
success: response.data.status === 'success',
|
|
73
|
+
provider: 'knowlarity',
|
|
74
|
+
service: 'THIRD_PARTY',
|
|
75
|
+
messageId: response.data.message_id,
|
|
76
|
+
timestamp: new Date(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
throw new Error('Invalid call type. Must be "voice" or "sms"');
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
provider: 'knowlarity',
|
|
85
|
+
service: 'THIRD_PARTY',
|
|
86
|
+
error: error.message,
|
|
87
|
+
timestamp: new Date(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
validateConfig(config: any): boolean {
|
|
93
|
+
return !!(
|
|
94
|
+
config.apiKey &&
|
|
95
|
+
config.apiSecret &&
|
|
96
|
+
config.callerNumber &&
|
|
97
|
+
['voice', 'sms'].includes(config.callType)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getCallStatus(callId: string, config: any): Promise<any> {
|
|
102
|
+
const { apiKey, apiSecret, baseUrl = 'https://kpi.knowlarity.com/Basic' } = config;
|
|
103
|
+
|
|
104
|
+
const statusData = {
|
|
105
|
+
call_id: callId,
|
|
106
|
+
api_key: apiKey,
|
|
107
|
+
api_secret: apiSecret,
|
|
108
|
+
format: 'json'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const response = await axios.post(`${baseUrl}/call_details.php`, statusData, {
|
|
112
|
+
headers: {
|
|
113
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
114
|
+
},
|
|
115
|
+
transformRequest: [(data) => {
|
|
116
|
+
return Object.keys(data)
|
|
117
|
+
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)
|
|
118
|
+
.join('&');
|
|
119
|
+
}]
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return response.data;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import * as nodemailer from 'nodemailer';
|
|
3
|
+
import { CommunicationStrategy, CommunicationResult } from './communication.strategy';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class OutlookSMTPStrategy implements CommunicationStrategy {
|
|
7
|
+
async sendMessage(to: string, message: string, config: any): Promise<CommunicationResult> {
|
|
8
|
+
try {
|
|
9
|
+
const {
|
|
10
|
+
email,
|
|
11
|
+
password,
|
|
12
|
+
subject = 'Notification',
|
|
13
|
+
html,
|
|
14
|
+
attachments,
|
|
15
|
+
cc,
|
|
16
|
+
bcc
|
|
17
|
+
} = config;
|
|
18
|
+
|
|
19
|
+
const transporter = nodemailer.createTransport({
|
|
20
|
+
host: 'smtp-mail.outlook.com',
|
|
21
|
+
port: 587,
|
|
22
|
+
secure: false,
|
|
23
|
+
auth: {
|
|
24
|
+
user: email,
|
|
25
|
+
pass: password,
|
|
26
|
+
},
|
|
27
|
+
tls: {
|
|
28
|
+
ciphers: 'SSLv3',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const mailOptions = {
|
|
33
|
+
from: email,
|
|
34
|
+
to: Array.isArray(to) ? to.join(',') : to,
|
|
35
|
+
cc: cc ? (Array.isArray(cc) ? cc.join(',') : cc) : undefined,
|
|
36
|
+
bcc: bcc ? (Array.isArray(bcc) ? bcc.join(',') : bcc) : undefined,
|
|
37
|
+
subject,
|
|
38
|
+
text: message,
|
|
39
|
+
html: html || message,
|
|
40
|
+
attachments: attachments || [],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const result = await transporter.sendMail(mailOptions);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
provider: 'outlook',
|
|
48
|
+
service: 'SMTP',
|
|
49
|
+
messageId: result.messageId,
|
|
50
|
+
timestamp: new Date(),
|
|
51
|
+
};
|
|
52
|
+
} catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
provider: 'outlook',
|
|
56
|
+
service: 'SMTP',
|
|
57
|
+
error: error.message,
|
|
58
|
+
timestamp: new Date(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
validateConfig(config: any): boolean {
|
|
64
|
+
return !!(
|
|
65
|
+
config.email &&
|
|
66
|
+
config.password
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
|
+
import { CommunicationStrategy, CommunicationResult } from './communication.strategy';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class OutlookStrategy implements CommunicationStrategy {
|
|
7
|
+
async sendMessage(to: string, message: string, config: any): Promise<CommunicationResult> {
|
|
8
|
+
try {
|
|
9
|
+
const { accessToken } = config;
|
|
10
|
+
|
|
11
|
+
const graphClient = Client.init({
|
|
12
|
+
authProvider: {
|
|
13
|
+
getAccessToken: async () => accessToken,
|
|
14
|
+
} as any,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const subject = config.subject || 'Notification';
|
|
18
|
+
const mail = {
|
|
19
|
+
message: {
|
|
20
|
+
subject,
|
|
21
|
+
body: {
|
|
22
|
+
contentType: config.html ? 'HTML' : 'Text',
|
|
23
|
+
content: config.html || message,
|
|
24
|
+
},
|
|
25
|
+
toRecipients: [
|
|
26
|
+
{
|
|
27
|
+
emailAddress: {
|
|
28
|
+
address: to,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
await graphClient.api('/me/sendMail').post(mail);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
provider: 'outlook',
|
|
40
|
+
service: 'API',
|
|
41
|
+
timestamp: new Date(),
|
|
42
|
+
};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
provider: 'outlook',
|
|
47
|
+
service: 'API',
|
|
48
|
+
error: error.message,
|
|
49
|
+
timestamp: new Date(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
validateConfig(config: any): boolean {
|
|
55
|
+
return !!(config.accessToken);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
CommunicationStrategy,
|
|
4
|
+
CommunicationResult,
|
|
5
|
+
} from '../communication.strategy';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class KnowlarityStrategy implements CommunicationStrategy {
|
|
9
|
+
async sendMessage(
|
|
10
|
+
to: string,
|
|
11
|
+
message: string,
|
|
12
|
+
config: any,
|
|
13
|
+
): Promise<CommunicationResult> {
|
|
14
|
+
try {
|
|
15
|
+
if (!this.validateConfig(config)) {
|
|
16
|
+
throw new Error('Invalid Knowlarity configuration');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Knowlarity API implementation would go here
|
|
20
|
+
// This is a placeholder for actual Knowlarity integration
|
|
21
|
+
console.log('Sending SMS via Knowlarity to:', to);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
messageId: `knowlarity-${Date.now()}`,
|
|
26
|
+
provider: 'knowlarity',
|
|
27
|
+
service: 'THIRD_PARTY',
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
provider: 'knowlarity',
|
|
34
|
+
service: 'THIRD_PARTY',
|
|
35
|
+
error: error.message,
|
|
36
|
+
timestamp: new Date(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
validateConfig(config: any): boolean {
|
|
42
|
+
return config && config.apiKey && config.senderId;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
CommunicationStrategy,
|
|
4
|
+
CommunicationResult,
|
|
5
|
+
} from '../communication.strategy';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class TwilioStrategy implements CommunicationStrategy {
|
|
9
|
+
async sendMessage(
|
|
10
|
+
to: string,
|
|
11
|
+
message: string,
|
|
12
|
+
config: any,
|
|
13
|
+
): Promise<CommunicationResult> {
|
|
14
|
+
try {
|
|
15
|
+
if (!this.validateConfig(config)) {
|
|
16
|
+
throw new Error('Invalid Twilio configuration');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Twilio SDK implementation would go here
|
|
20
|
+
// This is a placeholder for actual Twilio integration
|
|
21
|
+
console.log('Sending SMS via Twilio to:', to);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
messageId: `twilio-${Date.now()}`,
|
|
26
|
+
provider: 'twilio',
|
|
27
|
+
service: 'THIRD_PARTY',
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
provider: 'twilio',
|
|
34
|
+
service: 'THIRD_PARTY',
|
|
35
|
+
error: error.message,
|
|
36
|
+
timestamp: new Date(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
validateConfig(config: any): boolean {
|
|
42
|
+
return config && config.accountSid && config.authToken && config.fromNumber;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { Twilio } from 'twilio';
|
|
3
|
+
import { CommunicationStrategy, CommunicationResult } from './communication.strategy';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class SmsStrategy implements CommunicationStrategy {
|
|
7
|
+
async sendMessage(to: string, message: string, config: any): Promise<CommunicationResult> {
|
|
8
|
+
try {
|
|
9
|
+
const { accountSid, authToken, fromNumber } = config;
|
|
10
|
+
|
|
11
|
+
const client = new Twilio(accountSid, authToken);
|
|
12
|
+
|
|
13
|
+
const result = await client.messages.create({
|
|
14
|
+
body: message,
|
|
15
|
+
from: fromNumber,
|
|
16
|
+
to: to,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
success: true,
|
|
21
|
+
provider: 'twilio',
|
|
22
|
+
service: 'THIRD_PARTY',
|
|
23
|
+
messageId: result.sid,
|
|
24
|
+
timestamp: new Date(),
|
|
25
|
+
};
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
provider: 'twilio',
|
|
30
|
+
service: 'THIRD_PARTY',
|
|
31
|
+
error: error.message,
|
|
32
|
+
timestamp: new Date(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
validateConfig(config: any): boolean {
|
|
38
|
+
return !!(
|
|
39
|
+
config.accountSid &&
|
|
40
|
+
config.authToken &&
|
|
41
|
+
config.fromNumber
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
CommunicationStrategy,
|
|
4
|
+
CommunicationResult,
|
|
5
|
+
} from '../communication.strategy';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class KnowlarityVoiceStrategy implements CommunicationStrategy {
|
|
9
|
+
async sendMessage(
|
|
10
|
+
to: string,
|
|
11
|
+
message: string,
|
|
12
|
+
config: any,
|
|
13
|
+
): Promise<CommunicationResult> {
|
|
14
|
+
try {
|
|
15
|
+
if (!this.validateConfig(config)) {
|
|
16
|
+
throw new Error('Invalid Knowlarity Voice configuration');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Knowlarity Voice API implementation would go here
|
|
20
|
+
// This is a placeholder for actual voice call integration
|
|
21
|
+
console.log('Initiating voice call via Knowlarity to:', to);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
messageId: `knowlarity-voice-${Date.now()}`,
|
|
26
|
+
provider: 'knowlarity',
|
|
27
|
+
service: 'THIRD_PARTY',
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
provider: 'knowlarity',
|
|
34
|
+
service: 'THIRD_PARTY',
|
|
35
|
+
error: error.message,
|
|
36
|
+
timestamp: new Date(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
validateConfig(config: any): boolean {
|
|
42
|
+
return config && config.apiKey && config.callerId && config.voiceUrl;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
CommunicationStrategy,
|
|
4
|
+
CommunicationResult,
|
|
5
|
+
} from '../communication.strategy';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class WhatsAppCloudStrategy implements CommunicationStrategy {
|
|
9
|
+
async sendMessage(
|
|
10
|
+
to: string,
|
|
11
|
+
message: string,
|
|
12
|
+
config: any,
|
|
13
|
+
): Promise<CommunicationResult> {
|
|
14
|
+
try {
|
|
15
|
+
if (!this.validateConfig(config)) {
|
|
16
|
+
throw new Error('Invalid WhatsApp Cloud API configuration');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// WhatsApp Cloud API implementation would go here
|
|
20
|
+
// This is a placeholder for actual WhatsApp integration
|
|
21
|
+
console.log('Sending WhatsApp message via Cloud API to:', to);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
messageId: `whatsapp-${Date.now()}`,
|
|
26
|
+
provider: 'whatsapp',
|
|
27
|
+
service: 'API',
|
|
28
|
+
timestamp: new Date(),
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
provider: 'whatsapp',
|
|
34
|
+
service: 'API',
|
|
35
|
+
error: error.message,
|
|
36
|
+
timestamp: new Date(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
validateConfig(config: any): boolean {
|
|
42
|
+
return (
|
|
43
|
+
config &&
|
|
44
|
+
config.accessToken &&
|
|
45
|
+
config.phoneNumberId &&
|
|
46
|
+
config.businessAccountId
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { CommunicationStrategy, CommunicationResult } from './communication.strategy';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class WhatsAppStrategy implements CommunicationStrategy {
|
|
7
|
+
async sendMessage(to: string, message: string, config: any): Promise<CommunicationResult> {
|
|
8
|
+
try {
|
|
9
|
+
const { accessToken, phoneNumberId, apiVersion = 'v17.0' } = config;
|
|
10
|
+
|
|
11
|
+
const url = `https://graph.facebook.com/${apiVersion}/${phoneNumberId}/messages`;
|
|
12
|
+
|
|
13
|
+
const payload = {
|
|
14
|
+
messaging_product: 'whatsapp',
|
|
15
|
+
to: to,
|
|
16
|
+
type: 'text',
|
|
17
|
+
text: {
|
|
18
|
+
body: message,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const response = await axios.post(url, payload, {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${accessToken}`,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
success: true,
|
|
31
|
+
provider: 'whatsapp',
|
|
32
|
+
service: 'API',
|
|
33
|
+
messageId: response.data.messages[0].id,
|
|
34
|
+
timestamp: new Date(),
|
|
35
|
+
};
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
provider: 'whatsapp',
|
|
40
|
+
service: 'API',
|
|
41
|
+
error: error.message,
|
|
42
|
+
timestamp: new Date(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
validateConfig(config: any): boolean {
|
|
48
|
+
return !!(
|
|
49
|
+
config.accessToken &&
|
|
50
|
+
config.phoneNumberId
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -80,7 +80,7 @@ import { CommonService } from './service/common.service';
|
|
|
80
80
|
EntityMasterService,
|
|
81
81
|
EntityServiceImpl,
|
|
82
82
|
EntityDynamicService,
|
|
83
|
-
CommonService,
|
|
83
|
+
{ provide: 'CommonService', useClass: CommonService },
|
|
84
84
|
AttributeMasterRepository,
|
|
85
85
|
PreferenceService,
|
|
86
86
|
PreferenceRepository,
|
|
@@ -132,6 +132,7 @@ import { CommonService } from './service/common.service';
|
|
|
132
132
|
MasterService,
|
|
133
133
|
ResolverService,
|
|
134
134
|
EntityDynamicService,
|
|
135
|
+
'CommonService',
|
|
135
136
|
],
|
|
136
137
|
controllers: [
|
|
137
138
|
EntityController,
|
|
@@ -15,6 +15,7 @@ import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
|
15
15
|
import { Request, Response } from 'express';
|
|
16
16
|
import { UserSessionService } from '../service/user-session.service';
|
|
17
17
|
import { ConfigService } from '@nestjs/config';
|
|
18
|
+
import { CommunicationService } from '../../communication/service/communication.service';
|
|
18
19
|
|
|
19
20
|
@Controller('auth')
|
|
20
21
|
export class LoginController {
|
|
@@ -22,6 +23,7 @@ export class LoginController {
|
|
|
22
23
|
private loginService: LoginService,
|
|
23
24
|
private userSessionService: UserSessionService,
|
|
24
25
|
private configService: ConfigService,
|
|
26
|
+
private communicationService: CommunicationService,
|
|
25
27
|
) {}
|
|
26
28
|
|
|
27
29
|
@Post('login')
|
|
@@ -42,7 +44,7 @@ export class LoginController {
|
|
|
42
44
|
@Req() request: Request & { user: any },
|
|
43
45
|
@Res() response: Response,
|
|
44
46
|
) {
|
|
45
|
-
|
|
47
|
+
const requestUser: any = request.user.userData;
|
|
46
48
|
response
|
|
47
49
|
.status(HttpStatus.OK)
|
|
48
50
|
.json(await this.loginService.logout(requestUser.sessionToken));
|
|
@@ -58,9 +60,38 @@ export class LoginController {
|
|
|
58
60
|
@Get('google/callback')
|
|
59
61
|
@UseGuards(GoogleAuthGuard)
|
|
60
62
|
async googleAuthRedirect(@Req() req: any, @Res() res: Response) {
|
|
61
|
-
|
|
63
|
+
const { email, name, accessToken: googleAccessToken, refreshToken: googleRefreshToken } = req.user;
|
|
64
|
+
const { state } = req.query;
|
|
62
65
|
|
|
63
|
-
//
|
|
66
|
+
// Check if this is a Gmail configuration request
|
|
67
|
+
if (state && typeof state === 'string' && state.startsWith('gmail_config:')) {
|
|
68
|
+
try {
|
|
69
|
+
// Extract the actual state from the prefixed state
|
|
70
|
+
const actualState = state.replace('gmail_config:', '');
|
|
71
|
+
|
|
72
|
+
// Forward to communication service for Gmail config handling using already exchanged tokens
|
|
73
|
+
const result = await this.communicationService.handleGmailTokensCallback(
|
|
74
|
+
email,
|
|
75
|
+
googleAccessToken,
|
|
76
|
+
googleRefreshToken,
|
|
77
|
+
actualState
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return res.status(200).json({
|
|
81
|
+
success: true,
|
|
82
|
+
message: 'Gmail configuration saved successfully',
|
|
83
|
+
hubId: result.hubId,
|
|
84
|
+
configId: result.configId,
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return res.status(500).json({
|
|
88
|
+
success: false,
|
|
89
|
+
error: error.message,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Original login flow
|
|
64
95
|
const data = await this.loginService.loginWithGoogle(email, name);
|
|
65
96
|
|
|
66
97
|
if (!('accessToken' in data) || !data.accessToken)
|
|
@@ -36,7 +36,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
36
36
|
// service: 'stageGroupService',
|
|
37
37
|
// },
|
|
38
38
|
// { table: 'cr_wf_stage', entityType: 'WFS', service: 'stageService' },
|
|
39
|
-
// { table: 'cr_wf_action', entityType: '
|
|
39
|
+
// { table: 'cr_wf_action', entityType: 'WFAC', service: 'actionService' },
|
|
40
40
|
// ];
|
|
41
41
|
|
|
42
42
|
// const getAllFactoryData = async (table: { table: string }) => {
|
|
@@ -136,7 +136,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
136
136
|
service: 'stageGroupService',
|
|
137
137
|
},
|
|
138
138
|
{ table: 'cr_wf_stage', entityType: 'WFS', service: 'stageService' },
|
|
139
|
-
{ table: 'cr_wf_action', entityType: '
|
|
139
|
+
{ table: 'cr_wf_action', entityType: 'WFAC', service: 'actionService' },
|
|
140
140
|
];
|
|
141
141
|
|
|
142
142
|
// Fetch all base data
|
|
@@ -308,7 +308,7 @@ export class PopulateWorkflowService extends EntityServiceImpl {
|
|
|
308
308
|
organization_id,
|
|
309
309
|
action_requirement: matchedNewMandatory?.id ?? null,
|
|
310
310
|
level_id: organization_id,
|
|
311
|
-
entity_type: '
|
|
311
|
+
entity_type: 'WFAC',
|
|
312
312
|
form: formActionCategory.length > 0 ? formViewMaster[0]?.id : null,
|
|
313
313
|
status: statusValue,
|
|
314
314
|
},
|
|
@@ -10,6 +10,7 @@ SECRET_KEY: '1hard_to_guess_secret7890a'
|
|
|
10
10
|
CLIENT_ID: '819281384645-2tnuvm80sul1n2ahqa4eg6kjd19pnbu9.apps.googleusercontent.com'
|
|
11
11
|
CLIENT_SECRET: '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'
|
|
12
12
|
CALLBACK_URL: 'http://localhost:5001/auth/google/callback'
|
|
13
|
+
BASE_URL: 'http://localhost:5001'
|
|
13
14
|
OTP_EXPIRY: '10'
|
|
14
15
|
OTP_LENGTH: '6'
|
|
15
16
|
VERIFY_OTP: 'false'
|