rez_core 2.2.155 → 2.2.157
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/enterprise/entity/organization.entity.d.ts +1 -0
- package/dist/module/enterprise/entity/organization.entity.js +4 -0
- package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
- package/dist/module/enterprise/repository/organization.repository.d.ts +1 -0
- package/dist/module/enterprise/repository/organization.repository.js +5 -0
- package/dist/module/enterprise/repository/organization.repository.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +0 -1
- package/dist/module/master/service/master.service.js +20 -24
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/controller/entity-master.controller.d.ts +8 -0
- package/dist/module/meta/controller/entity-master.controller.js +44 -0
- package/dist/module/meta/controller/entity-master.controller.js.map +1 -0
- package/dist/module/meta/entity.module.js +6 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/entity-master.repository.d.ts +8 -0
- package/dist/module/meta/repository/entity-master.repository.js +36 -0
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -0
- package/dist/module/meta/service/entity-master.service.d.ts +4 -1
- package/dist/module/meta/service/entity-master.service.js +8 -2
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +1 -0
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +1 -0
- package/dist/module/notification/service/otp.service.js +2 -2
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +4 -2
- package/dist/module/user/controller/login.controller.js +28 -6
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +1 -1
- package/dist/module/user/service/login.service.js +15 -6
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/user.module.js +2 -0
- package/dist/module/user/user.module.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/enterprise/entity/organization.entity.ts +3 -0
- package/src/module/enterprise/repository/organization.repository.ts +6 -0
- package/src/module/master/service/master.service.ts +29 -24
- package/src/module/meta/controller/entity-master.controller.ts +28 -0
- package/src/module/meta/entity.module.ts +6 -1
- package/src/module/meta/repository/entity-master.repository.ts +17 -0
- package/src/module/meta/service/entity-master.service.ts +7 -0
- package/src/module/notification/controller/otp.controller.ts +1 -1
- package/src/module/notification/service/otp.service.ts +3 -3
- package/src/module/user/controller/login.controller.ts +36 -5
- package/src/module/user/service/login.service.ts +48 -23
- package/src/module/user/user.module.ts +2 -0
- 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
|
+
}
|
|
@@ -15,4 +15,10 @@ export class OrganizationRepository {
|
|
|
15
15
|
where: { id },
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
async findOrganizationBySubdomain(subdomain: string): Promise<OrganizationData | null> {
|
|
20
|
+
return await this.organizationRepository.findOne({
|
|
21
|
+
where: { subdomain },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
18
24
|
}
|
|
@@ -21,51 +21,56 @@ export class MasterService {
|
|
|
21
21
|
protected readonly entityValidationService: EntityValidationService,
|
|
22
22
|
) {}
|
|
23
23
|
|
|
24
|
-
private readonly metaSheets = [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
];
|
|
24
|
+
// private readonly metaSheets = [
|
|
25
|
+
// 'cr_entity_master',
|
|
26
|
+
// 'cr_attribute_master',
|
|
27
|
+
// 'cr_list_master',
|
|
28
|
+
// 'cr_list_master_items',
|
|
29
|
+
// 'cr_entity_table',
|
|
30
|
+
// 'cr_entity_table_column',
|
|
31
|
+
// 'cr_view_master',
|
|
32
|
+
// ];
|
|
33
33
|
private readonly sequence = [
|
|
34
34
|
{
|
|
35
35
|
table: 'cr_entity_master',
|
|
36
|
-
unique_fields: ['
|
|
36
|
+
unique_fields: ['id', 'organization_id'],
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
table: 'cr_attribute_master',
|
|
40
|
-
unique_fields: ['mapped_entity_type', 'attribute_key'],
|
|
40
|
+
unique_fields: ['mapped_entity_type', 'attribute_key', 'organization_id'],
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
table: 'cr_list_master',
|
|
44
|
-
unique_fields: ['type'],
|
|
44
|
+
unique_fields: ['type', 'organization_id'],
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
table: 'cr_list_master_items',
|
|
48
|
-
unique_fields: ['listtype', 'code'],
|
|
48
|
+
unique_fields: ['listtype', 'code', 'organization_id'],
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
table: 'cr_entity_table',
|
|
52
|
-
unique_fields: ['list_type', 'mapped_entity_type'],
|
|
52
|
+
unique_fields: ['list_type', 'mapped_entity_type', 'organization_id'],
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
table: 'cr_entity_table_column',
|
|
56
|
-
unique_fields: [
|
|
56
|
+
unique_fields: [
|
|
57
|
+
'parent_id',
|
|
58
|
+
'parent_type',
|
|
59
|
+
'attribute_key',
|
|
60
|
+
'organization_id',
|
|
61
|
+
],
|
|
57
62
|
},
|
|
58
63
|
{
|
|
59
64
|
table: 'cr_view_master',
|
|
60
|
-
unique_fields: ['mapped_entity_type'],
|
|
65
|
+
unique_fields: ['mapped_entity_type', 'organization_id'],
|
|
61
66
|
},
|
|
62
67
|
{
|
|
63
68
|
table: 'cr_user',
|
|
64
|
-
unique_fields: ['
|
|
69
|
+
unique_fields: ['organization_id'],
|
|
65
70
|
},
|
|
66
71
|
{
|
|
67
72
|
table: 'cr_header_items',
|
|
68
|
-
unique_fields: ['code', 'section_id'],
|
|
73
|
+
unique_fields: ['code', 'section_id', 'organization_id'],
|
|
69
74
|
},
|
|
70
75
|
{
|
|
71
76
|
table: 'cr_module_access',
|
|
@@ -73,27 +78,27 @@ export class MasterService {
|
|
|
73
78
|
},
|
|
74
79
|
{
|
|
75
80
|
table: 'cr_module_action',
|
|
76
|
-
unique_fields: ['module_code', 'action_type'],
|
|
81
|
+
unique_fields: ['module_code', 'action_type', 'organization_id'],
|
|
77
82
|
},
|
|
78
83
|
{
|
|
79
84
|
table: 'cr_menu',
|
|
80
|
-
unique_fields: ['module_code'],
|
|
85
|
+
unique_fields: ['module_code', 'organization_id'],
|
|
81
86
|
},
|
|
82
87
|
{
|
|
83
88
|
table: 'cr_module',
|
|
84
|
-
unique_fields: ['module_code'],
|
|
89
|
+
unique_fields: ['module_code', 'organization_id'],
|
|
85
90
|
},
|
|
86
91
|
{
|
|
87
92
|
table: 'cr_role',
|
|
88
|
-
unique_fields: ['code'],
|
|
93
|
+
unique_fields: ['code', 'organization_id'],
|
|
89
94
|
},
|
|
90
95
|
{
|
|
91
96
|
table: 'cr_header_sections',
|
|
92
|
-
unique_fields: ['section_name'],
|
|
97
|
+
unique_fields: ['section_name', 'organization_id'],
|
|
93
98
|
},
|
|
94
99
|
{
|
|
95
100
|
table: 'cr_user_role_mapping',
|
|
96
|
-
unique_fields: ['user_id', 'role_id'],
|
|
101
|
+
unique_fields: ['user_id', 'role_id', 'organization_id'],
|
|
97
102
|
},
|
|
98
103
|
{
|
|
99
104
|
table: 'cr_organization',
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller,
|
|
3
|
+
Post,
|
|
4
|
+
Body,
|
|
5
|
+
Param,
|
|
6
|
+
Req,
|
|
7
|
+
UseGuards,
|
|
8
|
+
Get,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
11
|
+
import { EntityMasterService } from '../service/entity-master.service';
|
|
12
|
+
import { HttpCode } from '@nestjs/common';
|
|
13
|
+
import { HttpStatus } from '@nestjs/common';
|
|
14
|
+
|
|
15
|
+
@Controller('entity-master')
|
|
16
|
+
@UseGuards(JwtAuthGuard)
|
|
17
|
+
export class EntityMasterController {
|
|
18
|
+
constructor(private readonly entityMasterService: EntityMasterService) {}
|
|
19
|
+
|
|
20
|
+
@Get('getById/:id')
|
|
21
|
+
@HttpCode(HttpStatus.OK)
|
|
22
|
+
async getEntityById(
|
|
23
|
+
@Param('id') id: number,
|
|
24
|
+
@Req() req: Request & { user: any },
|
|
25
|
+
) {
|
|
26
|
+
return await this.entityMasterService.getEntityById(id);
|
|
27
|
+
}
|
|
28
|
+
}
|