@app-connect/core 1.7.10 → 1.7.11
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/connector/developerPortal.js +43 -0
- package/connector/proxy/index.js +10 -3
- package/connector/registry.js +8 -6
- package/handlers/admin.js +44 -21
- package/handlers/auth.js +89 -67
- package/handlers/calldown.js +10 -4
- package/handlers/contact.js +4 -104
- package/handlers/disposition.js +4 -142
- package/handlers/log.js +172 -257
- package/handlers/user.js +19 -6
- package/index.js +213 -47
- package/lib/analytics.js +3 -1
- package/lib/authSession.js +68 -0
- package/lib/callLogComposer.js +498 -420
- package/lib/errorHandler.js +206 -0
- package/lib/jwt.js +2 -0
- package/lib/logger.js +190 -0
- package/lib/oauth.js +21 -10
- package/lib/ringcentral.js +2 -10
- package/lib/sharedSMSComposer.js +471 -0
- package/mcp/SupportedPlatforms.md +12 -0
- package/mcp/lib/validator.js +91 -0
- package/mcp/mcpHandler.js +166 -0
- package/mcp/tools/checkAuthStatus.js +90 -0
- package/mcp/tools/collectAuthInfo.js +86 -0
- package/mcp/tools/createCallLog.js +299 -0
- package/mcp/tools/createMessageLog.js +283 -0
- package/mcp/tools/doAuth.js +185 -0
- package/mcp/tools/findContactByName.js +87 -0
- package/mcp/tools/findContactByPhone.js +96 -0
- package/mcp/tools/getCallLog.js +98 -0
- package/mcp/tools/getHelp.js +39 -0
- package/mcp/tools/getPublicConnectors.js +46 -0
- package/mcp/tools/index.js +58 -0
- package/mcp/tools/logout.js +63 -0
- package/mcp/tools/rcGetCallLogs.js +73 -0
- package/mcp/tools/setConnector.js +64 -0
- package/mcp/tools/updateCallLog.js +122 -0
- package/models/cacheModel.js +3 -0
- package/package.json +71 -70
- package/releaseNotes.json +12 -0
- package/test/handlers/log.test.js +6 -2
- package/test/lib/logger.test.js +206 -0
- package/test/lib/sharedSMSComposer.test.js +1084 -0
- package/test/mcp/tools/collectAuthInfo.test.js +192 -0
- package/test/mcp/tools/createCallLog.test.js +412 -0
- package/test/mcp/tools/createMessageLog.test.js +580 -0
- package/test/mcp/tools/doAuth.test.js +363 -0
- package/test/mcp/tools/findContactByName.test.js +263 -0
- package/test/mcp/tools/findContactByPhone.test.js +284 -0
- package/test/mcp/tools/getCallLog.test.js +286 -0
- package/test/mcp/tools/getPublicConnectors.test.js +128 -0
- package/test/mcp/tools/logout.test.js +169 -0
- package/test/mcp/tools/setConnector.test.js +177 -0
- package/test/mcp/tools/updateCallLog.test.js +346 -0
package/handlers/disposition.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
// const Op = require('sequelize').Op;
|
|
2
1
|
const { CallLogModel } = require('../models/callLogModel');
|
|
3
|
-
// const { MessageLogModel } = require('../models/messageLogModel');
|
|
4
2
|
const { UserModel } = require('../models/userModel');
|
|
5
3
|
const oauth = require('../lib/oauth');
|
|
6
|
-
// const userCore = require('../handlers/user');
|
|
7
|
-
const errorMessage = require('../lib/generalErrorMessage');
|
|
8
4
|
const connectorRegistry = require('../connector/registry');
|
|
9
5
|
const { Connector } = require('../models/dynamo/connectorSchema');
|
|
6
|
+
const { handleApiError } = require('../lib/errorHandler');
|
|
10
7
|
|
|
11
|
-
async function upsertCallDisposition({ platform, userId, sessionId, dispositions
|
|
8
|
+
async function upsertCallDisposition({ platform, userId, sessionId, dispositions }) {
|
|
12
9
|
try {
|
|
13
10
|
const log = await CallLogModel.findOne({
|
|
14
11
|
where: {
|
|
@@ -65,143 +62,8 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
|
|
|
65
62
|
return { successful: !!logId, logId, returnMessage, extraDataTracking };
|
|
66
63
|
}
|
|
67
64
|
catch (e) {
|
|
68
|
-
|
|
69
|
-
if (e.response?.status === 429) {
|
|
70
|
-
return {
|
|
71
|
-
successful: false,
|
|
72
|
-
returnMessage: errorMessage.rateLimitErrorMessage({ platform })
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
else if (e.response?.status >= 400 && e.response?.status < 410) {
|
|
76
|
-
return {
|
|
77
|
-
successful: false,
|
|
78
|
-
returnMessage: errorMessage.authorizationErrorMessage({ platform }),
|
|
79
|
-
extraDataTracking: {
|
|
80
|
-
statusCode: e.response?.status,
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
successful: false,
|
|
86
|
-
returnMessage:
|
|
87
|
-
{
|
|
88
|
-
message: `Error dispositioning call log`,
|
|
89
|
-
messageType: 'warning',
|
|
90
|
-
details: [
|
|
91
|
-
{
|
|
92
|
-
title: 'Details',
|
|
93
|
-
items: [
|
|
94
|
-
{
|
|
95
|
-
id: '1',
|
|
96
|
-
type: 'text',
|
|
97
|
-
text: `Please check if your account has permission to UPDATE logs.`
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
],
|
|
102
|
-
ttl: 5000
|
|
103
|
-
}
|
|
104
|
-
};
|
|
65
|
+
return handleApiError(e, platform, 'upsertCallDisposition', { userId, sessionId, dispositions });
|
|
105
66
|
}
|
|
106
67
|
}
|
|
107
68
|
|
|
108
|
-
|
|
109
|
-
// try {
|
|
110
|
-
// const existingSameDateMessageLog = await MessageLogModel.findOne({
|
|
111
|
-
// where: {
|
|
112
|
-
// conversationLogId
|
|
113
|
-
// }
|
|
114
|
-
// });
|
|
115
|
-
// if (!existingSameDateMessageLog) {
|
|
116
|
-
// return {
|
|
117
|
-
// successful: false,
|
|
118
|
-
// returnMessage: {
|
|
119
|
-
// message: `Cannot find log`,
|
|
120
|
-
// messageType: 'warning',
|
|
121
|
-
// ttl: 3000
|
|
122
|
-
// }
|
|
123
|
-
// }
|
|
124
|
-
// }
|
|
125
|
-
// let user = await UserModel.findByPk(userId);
|
|
126
|
-
// if (!user) {
|
|
127
|
-
// return {
|
|
128
|
-
// successful: false,
|
|
129
|
-
// returnMessage: {
|
|
130
|
-
// message: `Cannot find user`,
|
|
131
|
-
// messageType: 'warning',
|
|
132
|
-
// ttl: 3000
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// const proxyId = user.platformAdditionalInfo?.proxyId;
|
|
137
|
-
// let proxyConfig = null;
|
|
138
|
-
// if (proxyId) {
|
|
139
|
-
// proxyConfig = await Connector.getProxyConfig(proxyId);
|
|
140
|
-
// }
|
|
141
|
-
// const platformModule = connectorRegistry.getConnector(platform);
|
|
142
|
-
// const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
|
|
143
|
-
// let authHeader = '';
|
|
144
|
-
// switch (authType) {
|
|
145
|
-
// case 'oauth':
|
|
146
|
-
// const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
|
|
147
|
-
// user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
|
|
148
|
-
// authHeader = `Bearer ${user.accessToken}`;
|
|
149
|
-
// break;
|
|
150
|
-
// case 'apiKey':
|
|
151
|
-
// const basicAuth = platformModule.getBasicAuth({ apiKey: user.accessToken });
|
|
152
|
-
// authHeader = `Basic ${basicAuth}`;
|
|
153
|
-
// break;
|
|
154
|
-
// }
|
|
155
|
-
// const { logId, returnMessage, extraDataTracking } = await platformModule.upsertMessageDisposition({
|
|
156
|
-
// user,
|
|
157
|
-
// existingMessageLog: existingSameDateMessageLog,
|
|
158
|
-
// authHeader,
|
|
159
|
-
// dispositions,
|
|
160
|
-
// proxyConfig
|
|
161
|
-
// });
|
|
162
|
-
// return { successful: !!logId, logId, returnMessage, extraDataTracking };
|
|
163
|
-
// }
|
|
164
|
-
// catch (e) {
|
|
165
|
-
// console.error(`platform: ${platform} \n${e.stack} \n${JSON.stringify(e.response?.data)}`);
|
|
166
|
-
// if (e.response?.status === 429) {
|
|
167
|
-
// return {
|
|
168
|
-
// successful: false,
|
|
169
|
-
// returnMessage: errorMessage.rateLimitErrorMessage({ platform })
|
|
170
|
-
// };
|
|
171
|
-
// }
|
|
172
|
-
// else if (e.response?.status >= 400 && e.response?.status < 410) {
|
|
173
|
-
// return {
|
|
174
|
-
// successful: false,
|
|
175
|
-
// returnMessage: errorMessage.authorizationErrorMessage({ platform }),
|
|
176
|
-
// extraDataTracking: {
|
|
177
|
-
// statusCode: e.response?.status,
|
|
178
|
-
// }
|
|
179
|
-
// };
|
|
180
|
-
// }
|
|
181
|
-
// return {
|
|
182
|
-
// successful: false,
|
|
183
|
-
// returnMessage:
|
|
184
|
-
// {
|
|
185
|
-
// message: `Error dispositioning message log`,
|
|
186
|
-
// messageType: 'warning',
|
|
187
|
-
// details: [
|
|
188
|
-
// {
|
|
189
|
-
// title: 'Details',
|
|
190
|
-
// items: [
|
|
191
|
-
// {
|
|
192
|
-
// id: '1',
|
|
193
|
-
// type: 'text',
|
|
194
|
-
// text: `Please check if your account has correct permissions.`
|
|
195
|
-
// }
|
|
196
|
-
// ]
|
|
197
|
-
// }
|
|
198
|
-
// ],
|
|
199
|
-
// ttl: 5000
|
|
200
|
-
// }
|
|
201
|
-
// };
|
|
202
|
-
// }
|
|
203
|
-
// }
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
exports.upsertCallDisposition = upsertCallDisposition;
|
|
207
|
-
// exports.upsertMessageDisposition = upsertMessageDisposition;
|
|
69
|
+
exports.upsertCallDisposition = upsertCallDisposition;
|