@app-connect/core 1.7.0-beta.4 → 1.7.0-beta.6
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/README.md +77 -77
- package/{adapter → connector}/registry.js +66 -66
- package/handlers/admin.js +4 -4
- package/handlers/auth.js +5 -5
- package/handlers/contact.js +4 -4
- package/handlers/disposition.js +3 -3
- package/handlers/log.js +8 -8
- package/handlers/user.js +2 -2
- package/index.js +36 -36
- package/lib/analytics.js +3 -3
- package/lib/callLogComposer.js +2 -21
- package/lib/oauth.js +2 -2
- package/models/adminConfigModel.js +1 -0
- package/package.json +1 -1
- package/test/adapter/registry.test.js +109 -109
- package/test/handlers/auth.test.js +21 -21
- package/test/setup.js +9 -9
- /package/{adapter → connector}/mock.js +0 -0
package/handlers/disposition.js
CHANGED
|
@@ -5,7 +5,7 @@ const { UserModel } = require('../models/userModel');
|
|
|
5
5
|
const oauth = require('../lib/oauth');
|
|
6
6
|
// const userCore = require('../handlers/user');
|
|
7
7
|
const errorMessage = require('../lib/generalErrorMessage');
|
|
8
|
-
const
|
|
8
|
+
const connectorRegistry = require('../connector/registry');
|
|
9
9
|
|
|
10
10
|
async function upsertCallDisposition({ platform, userId, sessionId, dispositions, additionalSubmission, userSettings }) {
|
|
11
11
|
try {
|
|
@@ -35,7 +35,7 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const platformModule =
|
|
38
|
+
const platformModule = connectorRegistry.getConnector(platform);
|
|
39
39
|
const authType = platformModule.getAuthType();
|
|
40
40
|
let authHeader = '';
|
|
41
41
|
switch (authType) {
|
|
@@ -126,7 +126,7 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
|
|
|
126
126
|
// }
|
|
127
127
|
// }
|
|
128
128
|
// }
|
|
129
|
-
// const platformModule =
|
|
129
|
+
// const platformModule = connectorRegistry.getConnector(platform);
|
|
130
130
|
// const authType = platformModule.getAuthType();
|
|
131
131
|
// let authHeader = '';
|
|
132
132
|
// switch (authType) {
|
package/handlers/log.js
CHANGED
|
@@ -4,8 +4,8 @@ const { MessageLogModel } = require('../models/messageLogModel');
|
|
|
4
4
|
const { UserModel } = require('../models/userModel');
|
|
5
5
|
const oauth = require('../lib/oauth');
|
|
6
6
|
const errorMessage = require('../lib/generalErrorMessage');
|
|
7
|
-
const { composeCallLog
|
|
8
|
-
const
|
|
7
|
+
const { composeCallLog } = require('../lib/callLogComposer');
|
|
8
|
+
const connectorRegistry = require('../connector/registry');
|
|
9
9
|
const { LOG_DETAILS_FORMAT_TYPE } = require('../lib/constants');
|
|
10
10
|
const { NoteCache } = require('../models/dynamo/noteCacheSchema');
|
|
11
11
|
const moment = require('moment');
|
|
@@ -39,7 +39,7 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const platformModule =
|
|
42
|
+
const platformModule = connectorRegistry.getConnector(platform);
|
|
43
43
|
const callLog = incomingData.logInfo;
|
|
44
44
|
const additionalSubmission = incomingData.additionalSubmission;
|
|
45
45
|
let note = incomingData.note;
|
|
@@ -84,7 +84,7 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
// Compose call log details centrally
|
|
87
|
-
const logFormat = getLogFormatType(platform);
|
|
87
|
+
const logFormat = platformModule.platformModule ? platformModule.getLogFormatType(platform) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
88
88
|
let composedLogDetails = '';
|
|
89
89
|
if (logFormat === LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT || logFormat === LOG_DETAILS_FORMAT_TYPE.HTML || logFormat === LOG_DETAILS_FORMAT_TYPE.MARKDOWN) {
|
|
90
90
|
composedLogDetails = await composeCallLog({
|
|
@@ -189,7 +189,7 @@ async function getCallLog({ userId, sessionIds, platform, requireDetails }) {
|
|
|
189
189
|
sessionIdsArray = sessionIdsArray.slice(0, 5);
|
|
190
190
|
}
|
|
191
191
|
if (requireDetails) {
|
|
192
|
-
const platformModule =
|
|
192
|
+
const platformModule = connectorRegistry.getConnector(platform);
|
|
193
193
|
const authType = platformModule.getAuthType();
|
|
194
194
|
let authHeader = '';
|
|
195
195
|
switch (authType) {
|
|
@@ -303,7 +303,7 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
303
303
|
}
|
|
304
304
|
});
|
|
305
305
|
if (existingCallLog) {
|
|
306
|
-
const platformModule =
|
|
306
|
+
const platformModule = connectorRegistry.getConnector(platform);
|
|
307
307
|
let user = await UserModel.findByPk(userId);
|
|
308
308
|
if (!user || !user.accessToken) {
|
|
309
309
|
return { successful: false, message: `Contact not found` };
|
|
@@ -324,7 +324,7 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
324
324
|
|
|
325
325
|
// Fetch existing call log details once to avoid duplicate API calls
|
|
326
326
|
let existingCallLogDetails = null; // Compose updated call log details centrally
|
|
327
|
-
const logFormat = getLogFormatType(platform);
|
|
327
|
+
const logFormat = platformModule.platformModule ? platformModule.getLogFormatType(platform) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
328
328
|
let composedLogDetails = '';
|
|
329
329
|
if (logFormat === LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT || logFormat === LOG_DETAILS_FORMAT_TYPE.HTML || logFormat === LOG_DETAILS_FORMAT_TYPE.MARKDOWN) {
|
|
330
330
|
let existingBody = '';
|
|
@@ -455,7 +455,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
const platformModule =
|
|
458
|
+
const platformModule = connectorRegistry.getConnector(platform);
|
|
459
459
|
const contactNumber = incomingData.logInfo.correspondents[0].phoneNumber;
|
|
460
460
|
const additionalSubmission = incomingData.additionalSubmission;
|
|
461
461
|
let user = await UserModel.findByPk(userId);
|
package/handlers/user.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
2
|
const { AdminConfigModel } = require('../models/adminConfigModel');
|
|
3
3
|
const { getHashValue } = require('../lib/util');
|
|
4
|
-
const
|
|
4
|
+
const connectorRegistry = require('../connector/registry');
|
|
5
5
|
|
|
6
6
|
async function getUserSettingsByAdmin({ rcAccessToken, rcAccountId }) {
|
|
7
7
|
let hashedRcAccountId = null;
|
|
@@ -73,7 +73,7 @@ async function updateUserSettings({ user, userSettings, platformName }) {
|
|
|
73
73
|
for (const k of keys) {
|
|
74
74
|
updatedSettings[k] = userSettings[k];
|
|
75
75
|
}
|
|
76
|
-
const platformModule =
|
|
76
|
+
const platformModule = connectorRegistry.getConnector(platformName);
|
|
77
77
|
if (platformModule.onUpdateUserSettings) {
|
|
78
78
|
const { successful, returnMessage } = await platformModule.onUpdateUserSettings({ user, userSettings, updatedSettings });
|
|
79
79
|
if (successful) {
|
package/index.js
CHANGED
|
@@ -17,11 +17,11 @@ const authCore = require('./handlers/auth');
|
|
|
17
17
|
const adminCore = require('./handlers/admin');
|
|
18
18
|
const userCore = require('./handlers/user');
|
|
19
19
|
const dispositionCore = require('./handlers/disposition');
|
|
20
|
-
const mock = require('./
|
|
20
|
+
const mock = require('./connector/mock');
|
|
21
21
|
const releaseNotes = require('./releaseNotes.json');
|
|
22
22
|
const analytics = require('./lib/analytics');
|
|
23
23
|
const util = require('./lib/util');
|
|
24
|
-
const
|
|
24
|
+
const connectorRegistry = require('./connector/registry');
|
|
25
25
|
const calldown = require('./handlers/calldown');
|
|
26
26
|
|
|
27
27
|
let packageJson = null;
|
|
@@ -75,13 +75,13 @@ function createCoreRouter() {
|
|
|
75
75
|
// Move all app.get, app.post, etc. to router.get, router.post, etc.
|
|
76
76
|
router.get('/releaseNotes', async function (req, res) {
|
|
77
77
|
const globalReleaseNotes = releaseNotes;
|
|
78
|
-
const
|
|
78
|
+
const connectorReleaseNotes = connectorRegistry.getReleaseNotes();
|
|
79
79
|
const mergedReleaseNotes = {};
|
|
80
|
-
const versions = Object.keys(
|
|
80
|
+
const versions = Object.keys(connectorReleaseNotes);
|
|
81
81
|
for (const version of versions) {
|
|
82
82
|
mergedReleaseNotes[version] = {
|
|
83
83
|
global: globalReleaseNotes[version]?.global ?? {},
|
|
84
|
-
...
|
|
84
|
+
...connectorReleaseNotes[version] ?? {}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
res.json(mergedReleaseNotes);
|
|
@@ -91,7 +91,7 @@ function createCoreRouter() {
|
|
|
91
91
|
router.get('/crmManifest', (req, res) => {
|
|
92
92
|
try {
|
|
93
93
|
const platformName = req.query.platformName || 'default';
|
|
94
|
-
const crmManifest =
|
|
94
|
+
const crmManifest = connectorRegistry.getManifest(platformName);
|
|
95
95
|
if (crmManifest) {
|
|
96
96
|
// Override app server url for local development
|
|
97
97
|
if (process.env.OVERRIDE_APP_SERVER) {
|
|
@@ -164,7 +164,7 @@ function createCoreRouter() {
|
|
|
164
164
|
analytics.track({
|
|
165
165
|
eventName: 'Check license status',
|
|
166
166
|
interfaceName: 'checkLicenseStatus',
|
|
167
|
-
|
|
167
|
+
connectorName: platformName,
|
|
168
168
|
accountId: hashedAccountId,
|
|
169
169
|
extensionId: hashedExtensionId,
|
|
170
170
|
success,
|
|
@@ -219,7 +219,7 @@ function createCoreRouter() {
|
|
|
219
219
|
analytics.track({
|
|
220
220
|
eventName: 'Auth validation',
|
|
221
221
|
interfaceName: 'authValidation',
|
|
222
|
-
|
|
222
|
+
connectorName: platformName,
|
|
223
223
|
accountId: hashedAccountId,
|
|
224
224
|
extensionId: hashedExtensionId,
|
|
225
225
|
success,
|
|
@@ -238,7 +238,7 @@ function createCoreRouter() {
|
|
|
238
238
|
|
|
239
239
|
// Obsolete
|
|
240
240
|
router.get('/serverVersionInfo', (req, res) => {
|
|
241
|
-
const defaultCrmManifest =
|
|
241
|
+
const defaultCrmManifest = connectorRegistry.getManifest('default');
|
|
242
242
|
res.send({ version: defaultCrmManifest?.version ?? 'unknown' });
|
|
243
243
|
});
|
|
244
244
|
|
|
@@ -302,7 +302,7 @@ function createCoreRouter() {
|
|
|
302
302
|
}
|
|
303
303
|
else {
|
|
304
304
|
res.status(200).send({
|
|
305
|
-
|
|
305
|
+
customConnector: null,
|
|
306
306
|
userSettings: {}
|
|
307
307
|
});
|
|
308
308
|
}
|
|
@@ -325,7 +325,7 @@ function createCoreRouter() {
|
|
|
325
325
|
analytics.track({
|
|
326
326
|
eventName: 'Get admin settings',
|
|
327
327
|
interfaceName: 'getAdminSettings',
|
|
328
|
-
|
|
328
|
+
connectorName: platformName,
|
|
329
329
|
accountId: hashedAccountId,
|
|
330
330
|
extensionId: hashedExtensionId,
|
|
331
331
|
success,
|
|
@@ -377,7 +377,7 @@ function createCoreRouter() {
|
|
|
377
377
|
analytics.track({
|
|
378
378
|
eventName: 'Get user mapping',
|
|
379
379
|
interfaceName: 'getUserMapping',
|
|
380
|
-
|
|
380
|
+
connectorName: platformName,
|
|
381
381
|
accountId: hashedAccountId,
|
|
382
382
|
extensionId: hashedExtensionId,
|
|
383
383
|
success,
|
|
@@ -423,7 +423,7 @@ function createCoreRouter() {
|
|
|
423
423
|
analytics.track({
|
|
424
424
|
eventName: 'Get server logging settings',
|
|
425
425
|
interfaceName: 'getServerLoggingSettings',
|
|
426
|
-
|
|
426
|
+
connectorName: platformName,
|
|
427
427
|
accountId: hashedAccountId,
|
|
428
428
|
extensionId: hashedExtensionId,
|
|
429
429
|
success,
|
|
@@ -474,7 +474,7 @@ function createCoreRouter() {
|
|
|
474
474
|
analytics.track({
|
|
475
475
|
eventName: 'Set server logging settings',
|
|
476
476
|
interfaceName: 'setServerLoggingSettings',
|
|
477
|
-
|
|
477
|
+
connectorName: platformName,
|
|
478
478
|
accountId: hashedAccountId,
|
|
479
479
|
extensionId: hashedExtensionId,
|
|
480
480
|
success,
|
|
@@ -539,7 +539,7 @@ function createCoreRouter() {
|
|
|
539
539
|
analytics.track({
|
|
540
540
|
eventName: 'Get user settings',
|
|
541
541
|
interfaceName: 'getUserSettings',
|
|
542
|
-
|
|
542
|
+
connectorName: platformName,
|
|
543
543
|
accountId: hashedAccountId,
|
|
544
544
|
extensionId: hashedExtensionId,
|
|
545
545
|
success,
|
|
@@ -584,7 +584,7 @@ function createCoreRouter() {
|
|
|
584
584
|
analytics.track({
|
|
585
585
|
eventName: 'Set user settings',
|
|
586
586
|
interfaceName: 'setUserSettings',
|
|
587
|
-
|
|
587
|
+
connectorName: platformName,
|
|
588
588
|
accountId: hashedAccountId,
|
|
589
589
|
extensionId: hashedExtensionId,
|
|
590
590
|
success,
|
|
@@ -671,7 +671,7 @@ function createCoreRouter() {
|
|
|
671
671
|
analytics.track({
|
|
672
672
|
eventName: 'OAuth Callback',
|
|
673
673
|
interfaceName: 'onOAuthCallback',
|
|
674
|
-
|
|
674
|
+
connectorName: platformName,
|
|
675
675
|
accountId: hashedAccountId,
|
|
676
676
|
extensionId: hashedExtensionId,
|
|
677
677
|
success,
|
|
@@ -722,7 +722,7 @@ function createCoreRouter() {
|
|
|
722
722
|
analytics.track({
|
|
723
723
|
eventName: 'API Key Login',
|
|
724
724
|
interfaceName: 'onApiKeyLogin',
|
|
725
|
-
|
|
725
|
+
connectorName: platformName,
|
|
726
726
|
accountId: hashedAccountId,
|
|
727
727
|
extensionId: hashedExtensionId,
|
|
728
728
|
success,
|
|
@@ -748,7 +748,7 @@ function createCoreRouter() {
|
|
|
748
748
|
res.status(400).send();
|
|
749
749
|
return;
|
|
750
750
|
}
|
|
751
|
-
const platformModule =
|
|
751
|
+
const platformModule = connectorRegistry.getConnector(unAuthData?.platform ?? 'Unknown');
|
|
752
752
|
const { returnMessage } = await platformModule.unAuthorize({ user: userToLogout });
|
|
753
753
|
res.status(200).send({ returnMessage });
|
|
754
754
|
success = true;
|
|
@@ -767,7 +767,7 @@ function createCoreRouter() {
|
|
|
767
767
|
analytics.track({
|
|
768
768
|
eventName: 'Unauthorize',
|
|
769
769
|
interfaceName: 'unAuthorize',
|
|
770
|
-
|
|
770
|
+
connectorName: platformName,
|
|
771
771
|
accountId: hashedAccountId,
|
|
772
772
|
extensionId: hashedExtensionId,
|
|
773
773
|
success,
|
|
@@ -832,7 +832,7 @@ function createCoreRouter() {
|
|
|
832
832
|
analytics.track({
|
|
833
833
|
eventName: 'Find contact',
|
|
834
834
|
interfaceName: 'findContact',
|
|
835
|
-
|
|
835
|
+
connectorName: platformName,
|
|
836
836
|
accountId: hashedAccountId,
|
|
837
837
|
extensionId: hashedExtensionId,
|
|
838
838
|
success,
|
|
@@ -885,7 +885,7 @@ function createCoreRouter() {
|
|
|
885
885
|
analytics.track({
|
|
886
886
|
eventName: 'Create contact',
|
|
887
887
|
interfaceName: 'createContact',
|
|
888
|
-
|
|
888
|
+
connectorName: platformName,
|
|
889
889
|
accountId: hashedAccountId,
|
|
890
890
|
extensionId: hashedExtensionId,
|
|
891
891
|
success,
|
|
@@ -932,7 +932,7 @@ function createCoreRouter() {
|
|
|
932
932
|
analytics.track({
|
|
933
933
|
eventName: 'Save note cache',
|
|
934
934
|
interfaceName: 'saveNoteCache',
|
|
935
|
-
|
|
935
|
+
connectorName: platformName,
|
|
936
936
|
accountId: hashedAccountId,
|
|
937
937
|
extensionId: hashedExtensionId,
|
|
938
938
|
success,
|
|
@@ -976,7 +976,7 @@ function createCoreRouter() {
|
|
|
976
976
|
analytics.track({
|
|
977
977
|
eventName: 'Get call log',
|
|
978
978
|
interfaceName: 'getCallLog',
|
|
979
|
-
|
|
979
|
+
connectorName: platformName,
|
|
980
980
|
accountId: hashedAccountId,
|
|
981
981
|
extensionId: hashedExtensionId,
|
|
982
982
|
success,
|
|
@@ -1028,7 +1028,7 @@ function createCoreRouter() {
|
|
|
1028
1028
|
analytics.track({
|
|
1029
1029
|
eventName: 'Create call log',
|
|
1030
1030
|
interfaceName: 'createCallLog',
|
|
1031
|
-
|
|
1031
|
+
connectorName: platformName,
|
|
1032
1032
|
accountId: hashedAccountId,
|
|
1033
1033
|
extensionId: hashedExtensionId,
|
|
1034
1034
|
success,
|
|
@@ -1080,7 +1080,7 @@ function createCoreRouter() {
|
|
|
1080
1080
|
analytics.track({
|
|
1081
1081
|
eventName: 'Update call log',
|
|
1082
1082
|
interfaceName: 'updateCallLog',
|
|
1083
|
-
|
|
1083
|
+
connectorName: platformName,
|
|
1084
1084
|
accountId: hashedAccountId,
|
|
1085
1085
|
extensionId: hashedExtensionId,
|
|
1086
1086
|
success,
|
|
@@ -1136,7 +1136,7 @@ function createCoreRouter() {
|
|
|
1136
1136
|
analytics.track({
|
|
1137
1137
|
eventName: 'Create call log',
|
|
1138
1138
|
interfaceName: 'createCallLog',
|
|
1139
|
-
|
|
1139
|
+
connectorName: platformName,
|
|
1140
1140
|
accountId: hashedAccountId,
|
|
1141
1141
|
extensionId: hashedExtensionId,
|
|
1142
1142
|
success,
|
|
@@ -1189,7 +1189,7 @@ function createCoreRouter() {
|
|
|
1189
1189
|
analytics.track({
|
|
1190
1190
|
eventName: 'Create message log',
|
|
1191
1191
|
interfaceName: 'createMessageLog',
|
|
1192
|
-
|
|
1192
|
+
connectorName: platformName,
|
|
1193
1193
|
accountId: hashedAccountId,
|
|
1194
1194
|
extensionId: hashedExtensionId,
|
|
1195
1195
|
success,
|
|
@@ -1230,7 +1230,7 @@ function createCoreRouter() {
|
|
|
1230
1230
|
analytics.track({
|
|
1231
1231
|
eventName: 'Schedule call down',
|
|
1232
1232
|
interfaceName: 'scheduleCallDown',
|
|
1233
|
-
|
|
1233
|
+
connectorName: platformName,
|
|
1234
1234
|
accountId: hashedAccountId,
|
|
1235
1235
|
extensionId: hashedExtensionId,
|
|
1236
1236
|
success,
|
|
@@ -1271,7 +1271,7 @@ function createCoreRouter() {
|
|
|
1271
1271
|
analytics.track({
|
|
1272
1272
|
eventName: 'Get call down list',
|
|
1273
1273
|
interfaceName: 'getCallDownList',
|
|
1274
|
-
|
|
1274
|
+
connectorName: platformName,
|
|
1275
1275
|
accountId: hashedAccountId,
|
|
1276
1276
|
extensionId: hashedExtensionId,
|
|
1277
1277
|
success,
|
|
@@ -1316,7 +1316,7 @@ function createCoreRouter() {
|
|
|
1316
1316
|
analytics.track({
|
|
1317
1317
|
eventName: 'Delete call down item',
|
|
1318
1318
|
interfaceName: 'deleteCallDownItem',
|
|
1319
|
-
|
|
1319
|
+
connectorName: platformName,
|
|
1320
1320
|
accountId: hashedAccountId,
|
|
1321
1321
|
extensionId: hashedExtensionId,
|
|
1322
1322
|
success,
|
|
@@ -1360,7 +1360,7 @@ function createCoreRouter() {
|
|
|
1360
1360
|
analytics.track({
|
|
1361
1361
|
eventName: 'Mark call down called',
|
|
1362
1362
|
interfaceName: 'markCallDownCalled',
|
|
1363
|
-
|
|
1363
|
+
connectorName: platformName,
|
|
1364
1364
|
accountId: hashedAccountId,
|
|
1365
1365
|
extensionId: hashedExtensionId,
|
|
1366
1366
|
success,
|
|
@@ -1405,7 +1405,7 @@ function createCoreRouter() {
|
|
|
1405
1405
|
analytics.track({
|
|
1406
1406
|
eventName: 'Contact Search by Name',
|
|
1407
1407
|
interfaceName: 'contactSearchByName',
|
|
1408
|
-
|
|
1408
|
+
connectorName: platformName,
|
|
1409
1409
|
accountId: hashedAccountId,
|
|
1410
1410
|
extensionId: hashedExtensionId,
|
|
1411
1411
|
success,
|
|
@@ -1449,7 +1449,7 @@ function createCoreRouter() {
|
|
|
1449
1449
|
analytics.track({
|
|
1450
1450
|
eventName: 'Get admin report',
|
|
1451
1451
|
interfaceName: 'getAdminReport',
|
|
1452
|
-
|
|
1452
|
+
connectorName: platformName,
|
|
1453
1453
|
accountId: hashedAccountId,
|
|
1454
1454
|
extensionId: hashedExtensionId,
|
|
1455
1455
|
success,
|
|
@@ -1490,7 +1490,7 @@ function createCoreRouter() {
|
|
|
1490
1490
|
analytics.track({
|
|
1491
1491
|
eventName: 'Get user report',
|
|
1492
1492
|
interfaceName: 'getUserReport',
|
|
1493
|
-
|
|
1493
|
+
connectorName: platformName,
|
|
1494
1494
|
accountId: hashedAccountId,
|
|
1495
1495
|
extensionId: hashedExtensionId,
|
|
1496
1496
|
success,
|
|
@@ -1625,4 +1625,4 @@ exports.createCoreRouter = createCoreRouter;
|
|
|
1625
1625
|
exports.createCoreMiddleware = createCoreMiddleware;
|
|
1626
1626
|
exports.createCoreApp = createCoreApp;
|
|
1627
1627
|
exports.initializeCore = initializeCore;
|
|
1628
|
-
exports.
|
|
1628
|
+
exports.connectorRegistry = connectorRegistry;
|
package/lib/analytics.js
CHANGED
|
@@ -19,7 +19,7 @@ exports.init = function init() {
|
|
|
19
19
|
mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
exports.track = function track({ eventName, interfaceName,
|
|
22
|
+
exports.track = function track({ eventName, interfaceName, connectorName, accountId, extensionId, success, requestDuration, userAgent, ip, author, eventAddedVia, extras = null }) {
|
|
23
23
|
if (!mixpanel || !extensionId) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -27,13 +27,13 @@ exports.track = function track({ eventName, interfaceName, adapterName, accountI
|
|
|
27
27
|
mixpanel.people.set_once(extensionId, {
|
|
28
28
|
version,
|
|
29
29
|
appName,
|
|
30
|
-
crmPlatform:
|
|
30
|
+
crmPlatform: connectorName
|
|
31
31
|
});
|
|
32
32
|
const ua = parser(userAgent);
|
|
33
33
|
mixpanel.track(eventName, {
|
|
34
34
|
distinct_id: extensionId,
|
|
35
35
|
interfaceName,
|
|
36
|
-
|
|
36
|
+
connectorName,
|
|
37
37
|
rcAccountId: accountId,
|
|
38
38
|
extensionId,
|
|
39
39
|
success,
|
package/lib/callLogComposer.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const moment = require('moment-timezone');
|
|
2
2
|
const { secondsToHoursMinutesSeconds } = require('./util');
|
|
3
|
-
const
|
|
3
|
+
const connectorRegistry = require('../connector/registry');
|
|
4
4
|
const { LOG_DETAILS_FORMAT_TYPE } = require('./constants');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Centralized call log composition module
|
|
8
|
-
* Supports both plain text and HTML formats used across different CRM
|
|
8
|
+
* Supports both plain text and HTML formats used across different CRM connectors
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -615,27 +615,8 @@ function upsertLegs({ body, legs, logFormat }) {
|
|
|
615
615
|
return result;
|
|
616
616
|
}
|
|
617
617
|
|
|
618
|
-
/**
|
|
619
|
-
* Helper function to determine format type for a CRM platform
|
|
620
|
-
* @param {string} platform - CRM platform name
|
|
621
|
-
* @returns {string} Format type
|
|
622
|
-
*/
|
|
623
|
-
function getLogFormatType(platform) {
|
|
624
|
-
if(process.env.LOG_FORMAT_PLAIN_TEXT_PLATFORMS.split(',').includes(platform)){
|
|
625
|
-
return LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
626
|
-
}
|
|
627
|
-
if(process.env.LOG_FORMAT_HTML_PLATFORMS.split(',').includes(platform)){
|
|
628
|
-
return LOG_DETAILS_FORMAT_TYPE.HTML;
|
|
629
|
-
}
|
|
630
|
-
if(process.env.LOG_FORMAT_MARKDOWN_PLATFORMS.split(',').includes(platform)){
|
|
631
|
-
return LOG_DETAILS_FORMAT_TYPE.MARKDOWN;
|
|
632
|
-
}
|
|
633
|
-
return LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
618
|
module.exports = {
|
|
637
619
|
composeCallLog,
|
|
638
|
-
getLogFormatType,
|
|
639
620
|
// Export individual upsert functions for backward compatibility
|
|
640
621
|
upsertCallAgentNote,
|
|
641
622
|
upsertCallSessionId,
|
package/lib/oauth.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const ClientOAuth2 = require('client-oauth2');
|
|
3
3
|
const moment = require('moment');
|
|
4
4
|
const { UserModel } = require('../models/userModel');
|
|
5
|
-
const
|
|
5
|
+
const connectorRegistry = require('../connector/registry');
|
|
6
6
|
const dynamoose = require('dynamoose');
|
|
7
7
|
|
|
8
8
|
// oauthApp strategy is default to 'code' which use credentials to get accessCode, then exchange for accessToken and refreshToken.
|
|
@@ -25,7 +25,7 @@ async function checkAndRefreshAccessToken(oauthApp, user, tokenLockTimeout = 20)
|
|
|
25
25
|
const expiryBuffer = 2; // 2 minutes
|
|
26
26
|
// Special case: Bullhorn
|
|
27
27
|
if (user.platform) {
|
|
28
|
-
const platformModule =
|
|
28
|
+
const platformModule = connectorRegistry.getConnector(user.platform);
|
|
29
29
|
if (platformModule.checkAndRefreshAccessToken) {
|
|
30
30
|
return platformModule.checkAndRefreshAccessToken(oauthApp, user, tokenLockTimeout);
|
|
31
31
|
}
|