@meltwater/conversations-api-services 1.0.19 → 1.0.20
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/.github/workflows/release.yml +2 -0
- package/babel.config.js +18 -0
- package/dist/cjs/data-access/http/InstagramVideoClient.js +42 -0
- package/dist/cjs/data-access/http/WarpZoneApi.client.js +32 -0
- package/dist/cjs/data-access/http/amazonS3.js +44 -0
- package/dist/cjs/data-access/http/asset-manager-tvm.client.js +35 -0
- package/dist/cjs/data-access/http/companiesApi.client.js +38 -0
- package/dist/cjs/data-access/http/credentialsApi.client.js +102 -0
- package/dist/cjs/data-access/http/entitlementsApi.client.js +40 -0
- package/dist/cjs/data-access/http/facebook.native.js +344 -0
- package/dist/cjs/data-access/http/facebookApi.client.js +631 -0
- package/dist/cjs/data-access/http/featureToggleApi.client.js +31 -0
- package/dist/cjs/data-access/http/identityServices.client.js +97 -0
- package/dist/cjs/data-access/http/instagramApi.client.js +428 -0
- package/dist/cjs/data-access/http/ir.client.js +242 -0
- package/dist/cjs/data-access/http/linkedInApi.client.js +491 -0
- package/dist/cjs/data-access/http/masf.client.js +101 -0
- package/dist/cjs/data-access/http/tiktokApi.client.js +441 -0
- package/dist/cjs/data-access/index.js +129 -0
- package/dist/cjs/errors/engage-error.js +16 -0
- package/dist/cjs/errors/http-error.js +23 -0
- package/dist/cjs/lib/applicationTags.helpers.js +30 -0
- package/dist/cjs/lib/configuration.js +14 -0
- package/dist/cjs/lib/document-action-events.js +12 -0
- package/dist/cjs/lib/externalId.helpers.js +19 -0
- package/dist/cjs/lib/hidden.helpers.js +13 -0
- package/dist/cjs/lib/hiddenComment.helper.js +119 -0
- package/dist/cjs/lib/logger.helpers.js +68 -0
- package/dist/cjs/lib/logger.js +23 -0
- package/dist/cjs/lib/message.helpers.js +58 -0
- package/dist/cjs/lib/metrics.helper.js +97 -0
- package/dist/esm/data-access/http/InstagramVideoClient.js +34 -0
- package/dist/esm/data-access/http/WarpZoneApi.client.js +24 -0
- package/dist/esm/data-access/http/amazonS3.js +37 -0
- package/dist/esm/data-access/http/asset-manager-tvm.client.js +28 -0
- package/dist/esm/data-access/http/companiesApi.client.js +30 -0
- package/dist/esm/data-access/http/credentialsApi.client.js +92 -0
- package/dist/esm/data-access/http/entitlementsApi.client.js +32 -0
- package/dist/esm/data-access/http/facebook.native.js +325 -0
- package/dist/esm/data-access/http/facebookApi.client.js +621 -0
- package/dist/esm/data-access/http/featureToggleApi.client.js +23 -0
- package/dist/esm/data-access/http/identityServices.client.js +89 -0
- package/dist/esm/data-access/http/instagramApi.client.js +420 -0
- package/dist/esm/data-access/http/ir.client.js +234 -0
- package/dist/esm/data-access/http/linkedInApi.client.js +481 -0
- package/dist/esm/data-access/http/masf.client.js +93 -0
- package/dist/esm/data-access/http/tiktokApi.client.js +433 -0
- package/dist/esm/data-access/index.js +29 -0
- package/dist/esm/errors/engage-error.js +9 -0
- package/dist/esm/errors/http-error.js +16 -0
- package/dist/esm/lib/applicationTags.helpers.js +22 -0
- package/dist/esm/lib/configuration.js +8 -0
- package/dist/esm/lib/document-action-events.js +6 -0
- package/dist/esm/lib/externalId.helpers.js +12 -0
- package/dist/esm/lib/hidden.helpers.js +6 -0
- package/dist/esm/lib/hiddenComment.helper.js +112 -0
- package/dist/esm/lib/logger.helpers.js +60 -0
- package/dist/esm/lib/logger.js +16 -0
- package/dist/esm/lib/message.helpers.js +52 -0
- package/dist/esm/lib/metrics.helper.js +90 -0
- package/package.json +14 -4
- package/src/data-access/http/facebook.native.js +542 -0
- package/src/data-access/index.js +2 -0
- package/src/errors/engage-error.js +11 -0
- package/src/errors/http-error.js +19 -0
- package/src/lib/logger.helpers.js +15 -0
- package/src/lib/message.helpers.js +7 -1
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TikTokApiClient = void 0;
|
|
7
|
+
var _superagent = _interopRequireDefault(require("superagent"));
|
|
8
|
+
var _configuration = _interopRequireDefault(require("../../lib/configuration.js"));
|
|
9
|
+
var _logger = _interopRequireDefault(require("../../lib/logger.js"));
|
|
10
|
+
var _externalIdHelpers = require("../../lib/externalId.helpers.js");
|
|
11
|
+
var _credentialsApiClient = require("../http/credentialsApi.client.js");
|
|
12
|
+
var _loggerHelpers = require("../../lib/logger.helpers.js");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
class TikTokApiClient {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.tiktokURL = _configuration.default.get('TIKTOK_API_URL');
|
|
17
|
+
this.credentialsAPI = new _credentialsApiClient.CredentialsApiClient();
|
|
18
|
+
}
|
|
19
|
+
async getAuthorization(document) {
|
|
20
|
+
const {
|
|
21
|
+
documentId,
|
|
22
|
+
systemData: {
|
|
23
|
+
connectionsCredential: credentialId,
|
|
24
|
+
policies: {
|
|
25
|
+
storage: {
|
|
26
|
+
privateTo: companyId
|
|
27
|
+
} = {}
|
|
28
|
+
} = {}
|
|
29
|
+
} = {}
|
|
30
|
+
} = document;
|
|
31
|
+
try {
|
|
32
|
+
const credential = await this.credentialsAPI.getToken(credentialId, companyId);
|
|
33
|
+
return `${credential.token}`;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
_logger.default.error(`${documentId} - error getting tiktok token - ${error.code}`, error, {
|
|
36
|
+
[_loggerHelpers.MeltwaterAttributes.DOCUMENTID]: documentId,
|
|
37
|
+
[_loggerHelpers.MeltwaterAttributes.COMPANYID]: companyId,
|
|
38
|
+
[_loggerHelpers.MeltwaterAttributes.CREDENTIALID]: credentialId
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async sendPost(_ref) {
|
|
43
|
+
let {
|
|
44
|
+
paramString = '',
|
|
45
|
+
headers = {},
|
|
46
|
+
document,
|
|
47
|
+
postData = undefined
|
|
48
|
+
} = _ref;
|
|
49
|
+
let response = {};
|
|
50
|
+
try {
|
|
51
|
+
response = await _superagent.default.post(this.tiktokURL + paramString).set('Accept', 'application/json').set('Content-Type', 'application/json').set('Access-Token', await this.getAuthorization(document)).send(postData);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
let errorText = '';
|
|
54
|
+
if (err && err.response && err.response.body && err.response.body.error) {
|
|
55
|
+
errorText = `Failed to call tiktok api for paramString ${paramString}: ${err.response.body.error.message}`;
|
|
56
|
+
_logger.default.error(errorText);
|
|
57
|
+
} else {
|
|
58
|
+
errorText = `Failed to call tiktok api for paramString ${paramString}`;
|
|
59
|
+
_logger.default.error(errorText, err);
|
|
60
|
+
}
|
|
61
|
+
throw new Error(errorText);
|
|
62
|
+
}
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// assumes batch calls are using the same credential
|
|
67
|
+
async sendRequest(_ref2) {
|
|
68
|
+
let {
|
|
69
|
+
paramString = '',
|
|
70
|
+
headers = {},
|
|
71
|
+
document
|
|
72
|
+
} = _ref2;
|
|
73
|
+
let response = {};
|
|
74
|
+
try {
|
|
75
|
+
response = await _superagent.default.get(this.tiktokURL + paramString).set('Accept', 'application/json').set('Content-Type', 'application/json').set('Access-Token', await this.getAuthorization(document)).send();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
let errorText = '';
|
|
78
|
+
if (err && err.response && err.response.body && err.response.body.error) {
|
|
79
|
+
errorText = `Failed to call tiktok api for paramString ${paramString}: ${err.response.body.error.message}`;
|
|
80
|
+
_logger.default.error(errorText);
|
|
81
|
+
} else {
|
|
82
|
+
errorText = `Failed to call tiktok api for paramString ${paramString}`;
|
|
83
|
+
_logger.default.error(errorText, err);
|
|
84
|
+
}
|
|
85
|
+
throw new Error(errorText);
|
|
86
|
+
}
|
|
87
|
+
if (response.status !== 200) {
|
|
88
|
+
_logger.default.error(`Failed to call tiktok api for documentId ${document.documentId}`, response.body, {
|
|
89
|
+
[_loggerHelpers.MeltwaterAttributes.DOCUMENTID]: document.documentId
|
|
90
|
+
});
|
|
91
|
+
let error = new Error(`Failed to call tiktok api for documentId ${document.documentId}`);
|
|
92
|
+
error.code = response.status;
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
return response.body;
|
|
96
|
+
}
|
|
97
|
+
async getChannelInfoForDocuments(documents) {
|
|
98
|
+
const channelInfo = await this.getStatsForDocuments(documents, 'metaData.authors.0.authorInfo.externalId', {
|
|
99
|
+
og: ['video/list/']
|
|
100
|
+
});
|
|
101
|
+
return channelInfo;
|
|
102
|
+
}
|
|
103
|
+
async getStatsForDocuments(documents) {
|
|
104
|
+
let externalIdFrom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'metaData.externalId';
|
|
105
|
+
let paramsByType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
106
|
+
og: ['video/list/']
|
|
107
|
+
};
|
|
108
|
+
// for batching separate og and comment/reply requests per credential
|
|
109
|
+
const documentsByTypeAndCredentials = documents.reduce((retObj, document, index) => {
|
|
110
|
+
const paramArray = paramsByType[document.metaData.discussionType];
|
|
111
|
+
if (paramArray) {
|
|
112
|
+
paramArray.forEach(paramString => {
|
|
113
|
+
let discussionTypeBucket = retObj[`${paramString}${document.systemData.connectionsCredential}`];
|
|
114
|
+
if (!discussionTypeBucket) {
|
|
115
|
+
discussionTypeBucket = {
|
|
116
|
+
paramString,
|
|
117
|
+
document,
|
|
118
|
+
externalIds: [],
|
|
119
|
+
externalIdToDocumentIndex: {}
|
|
120
|
+
};
|
|
121
|
+
retObj[`${paramString}${document.systemData.connectionsCredential}`] = discussionTypeBucket;
|
|
122
|
+
}
|
|
123
|
+
const externalIdTrimmed = (0, _externalIdHelpers.removePrefix)(
|
|
124
|
+
// javascript weirdness to get around '.' notation
|
|
125
|
+
externalIdFrom.split('.').reduce((a, b) => a[b], document));
|
|
126
|
+
discussionTypeBucket.externalIds.push(externalIdTrimmed);
|
|
127
|
+
discussionTypeBucket.externalIdToDocumentIndex[externalIdTrimmed] = index;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return retObj;
|
|
131
|
+
}, {});
|
|
132
|
+
const sortedResults = Array(documents.length).fill();
|
|
133
|
+
await Promise.all(Object.values(documentsByTypeAndCredentials).map(async documentsByTypeAndCredential => {
|
|
134
|
+
if (documentsByTypeAndCredential.externalIds.length) {
|
|
135
|
+
const {
|
|
136
|
+
metaData: {
|
|
137
|
+
inReplyTo: {
|
|
138
|
+
profileId: business_id
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} = documentsByTypeAndCredential.document;
|
|
142
|
+
const trimmedBusinessId = (0, _externalIdHelpers.removePrefix)(business_id);
|
|
143
|
+
const requestResult = await this.sendRequest({
|
|
144
|
+
paramString: `${documentsByTypeAndCredential.paramString}?business_id=${trimmedBusinessId}&fields=["item_id","create_time","thumbnail_url","share_url","embed_url","caption","video_views","likes","comments","shares"]&filters=${JSON.stringify({
|
|
145
|
+
video_ids: documentsByTypeAndCredential.externalIds
|
|
146
|
+
})}`,
|
|
147
|
+
document: documentsByTypeAndCredential.document
|
|
148
|
+
});
|
|
149
|
+
requestResult.data.videos.forEach(_ref3 => {
|
|
150
|
+
let {
|
|
151
|
+
item_id,
|
|
152
|
+
create_time,
|
|
153
|
+
thumbnail_url,
|
|
154
|
+
share_url,
|
|
155
|
+
embed_url,
|
|
156
|
+
caption,
|
|
157
|
+
video_views,
|
|
158
|
+
likes,
|
|
159
|
+
comments,
|
|
160
|
+
shares,
|
|
161
|
+
...args
|
|
162
|
+
} = _ref3;
|
|
163
|
+
const documentIndex = documentsByTypeAndCredential.externalIdToDocumentIndex[item_id];
|
|
164
|
+
sortedResults[documentIndex] = {
|
|
165
|
+
...sortedResults[documentIndex],
|
|
166
|
+
item_id,
|
|
167
|
+
create_time,
|
|
168
|
+
thumbnail_url,
|
|
169
|
+
externalId: documents[documentIndex].metaData.externalId,
|
|
170
|
+
share_url,
|
|
171
|
+
embed_url,
|
|
172
|
+
caption,
|
|
173
|
+
video_views,
|
|
174
|
+
likes,
|
|
175
|
+
comments,
|
|
176
|
+
shares
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
return sortedResults;
|
|
182
|
+
}
|
|
183
|
+
async publish(message, videoId, markMessageAsCompleteDocumentId) {
|
|
184
|
+
const {
|
|
185
|
+
metaData: {
|
|
186
|
+
discussionType
|
|
187
|
+
}
|
|
188
|
+
} = message;
|
|
189
|
+
let publishedMessage;
|
|
190
|
+
switch (discussionType) {
|
|
191
|
+
case 'qt':
|
|
192
|
+
publishedMessage = await this.insertComment(message);
|
|
193
|
+
break;
|
|
194
|
+
case 're':
|
|
195
|
+
publishedMessage = await this.insertReply(videoId, message, markMessageAsCompleteDocumentId);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
return publishedMessage;
|
|
199
|
+
}
|
|
200
|
+
async insertComment(document) {
|
|
201
|
+
const {
|
|
202
|
+
body: {
|
|
203
|
+
content: {
|
|
204
|
+
text: text
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
metaData: {
|
|
208
|
+
source: {
|
|
209
|
+
id: business_id
|
|
210
|
+
},
|
|
211
|
+
inReplyTo: {
|
|
212
|
+
id: video_id
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} = document;
|
|
216
|
+
const {
|
|
217
|
+
body: publishedMessage
|
|
218
|
+
} = (await this.sendPost({
|
|
219
|
+
paramString: 'comment/create/',
|
|
220
|
+
postData: {
|
|
221
|
+
business_id,
|
|
222
|
+
video_id,
|
|
223
|
+
text
|
|
224
|
+
},
|
|
225
|
+
document
|
|
226
|
+
})) || {};
|
|
227
|
+
return publishedMessage;
|
|
228
|
+
}
|
|
229
|
+
async insertReply(videoId, document, markMessageAsCompleteDocumentId) {
|
|
230
|
+
const {
|
|
231
|
+
body: {
|
|
232
|
+
content: {
|
|
233
|
+
text: text
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
metaData: {
|
|
237
|
+
inReplyTo: {
|
|
238
|
+
id: comment_id,
|
|
239
|
+
profileId: business_id
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} = document;
|
|
243
|
+
const {
|
|
244
|
+
body: publishedMessage
|
|
245
|
+
} = (await this.sendPost({
|
|
246
|
+
paramString: 'comment/reply/create/',
|
|
247
|
+
postData: {
|
|
248
|
+
business_id: document.metaData.source.id,
|
|
249
|
+
comment_id: markMessageAsCompleteDocumentId || comment_id,
|
|
250
|
+
video_id: (0, _externalIdHelpers.removePrefix)(videoId),
|
|
251
|
+
text
|
|
252
|
+
},
|
|
253
|
+
document
|
|
254
|
+
})) || {};
|
|
255
|
+
return publishedMessage;
|
|
256
|
+
}
|
|
257
|
+
async toggleLike(document) {
|
|
258
|
+
const {
|
|
259
|
+
enrichments: {
|
|
260
|
+
socialScores: {
|
|
261
|
+
tt_liked_by_user: likedByUser
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} = document;
|
|
265
|
+
try {
|
|
266
|
+
let likeResponse = await (!likedByUser ? this.like(document) : this.unlike(document));
|
|
267
|
+
return likeResponse;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
_logger.default.error(`${document} - error recieved - ${error.code}`, error);
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async toggleHide(document) {
|
|
274
|
+
let parentDoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
275
|
+
const {
|
|
276
|
+
documentId,
|
|
277
|
+
appData: {
|
|
278
|
+
hidden: hiddenOnNative
|
|
279
|
+
}
|
|
280
|
+
} = document;
|
|
281
|
+
let response;
|
|
282
|
+
try {
|
|
283
|
+
if (hiddenOnNative) {
|
|
284
|
+
response = await this.hide(document, parentDoc);
|
|
285
|
+
} else {
|
|
286
|
+
response = await this.unhide(document, parentDoc);
|
|
287
|
+
}
|
|
288
|
+
_logger.default.info(`Native Tiktok API Hide Response for documentId ${documentId}`, {
|
|
289
|
+
status: response.status,
|
|
290
|
+
ok: response.ok,
|
|
291
|
+
[_loggerHelpers.MeltwaterAttributes.DOCUMENTID]: documentId
|
|
292
|
+
});
|
|
293
|
+
if (response.message === 'OK') {
|
|
294
|
+
return response;
|
|
295
|
+
}
|
|
296
|
+
} catch (error) {
|
|
297
|
+
_logger.default.error(`${documentId} - error recieved - ${error.code}`, error, {
|
|
298
|
+
[_loggerHelpers.MeltwaterAttributes.DOCUMENTID]: documentId
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async like(document) {
|
|
303
|
+
const {
|
|
304
|
+
metaData: {
|
|
305
|
+
externalId: comment_id,
|
|
306
|
+
source: {
|
|
307
|
+
id: sourceId
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
} = document;
|
|
311
|
+
const {
|
|
312
|
+
body: publishedMessage
|
|
313
|
+
} = (await this.sendPost({
|
|
314
|
+
paramString: 'comment/like/',
|
|
315
|
+
postData: {
|
|
316
|
+
business_id: (0, _externalIdHelpers.removePrefix)(sourceId),
|
|
317
|
+
comment_id: (0, _externalIdHelpers.removePrefix)(comment_id),
|
|
318
|
+
action: 'LIKE'
|
|
319
|
+
},
|
|
320
|
+
document
|
|
321
|
+
})) || {};
|
|
322
|
+
return publishedMessage;
|
|
323
|
+
}
|
|
324
|
+
async unlike(document) {
|
|
325
|
+
const {
|
|
326
|
+
metaData: {
|
|
327
|
+
inReplyTo: {
|
|
328
|
+
id: comment_id
|
|
329
|
+
},
|
|
330
|
+
source: {
|
|
331
|
+
id: sourceId
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
} = document;
|
|
335
|
+
const {
|
|
336
|
+
body: publishedMessage
|
|
337
|
+
} = (await this.sendPost({
|
|
338
|
+
paramString: 'comment/like/',
|
|
339
|
+
postData: {
|
|
340
|
+
business_id: (0, _externalIdHelpers.removePrefix)(sourceId),
|
|
341
|
+
comment_id: (0, _externalIdHelpers.removePrefix)(comment_id),
|
|
342
|
+
action: 'unlike'
|
|
343
|
+
},
|
|
344
|
+
document
|
|
345
|
+
})) || {};
|
|
346
|
+
return publishedMessage;
|
|
347
|
+
}
|
|
348
|
+
async hide(document) {
|
|
349
|
+
let parentDoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
350
|
+
const {
|
|
351
|
+
metaData: {
|
|
352
|
+
externalId: comment_id,
|
|
353
|
+
source: {
|
|
354
|
+
id: sourceId
|
|
355
|
+
},
|
|
356
|
+
discussionType
|
|
357
|
+
}
|
|
358
|
+
} = document;
|
|
359
|
+
|
|
360
|
+
//very small chance we get externalid instead of id
|
|
361
|
+
const video_id = discussionType === 're' ? parentDoc?.metaData?.inReplyTo?.id || parentDoc?.metaData?.inReplyTo?.externalId : document?.metaData?.inReplyTo?.id || document?.metaData?.inReplyTo?.externalId;
|
|
362
|
+
const {
|
|
363
|
+
body: publishedMessage
|
|
364
|
+
} = (await this.sendPost({
|
|
365
|
+
paramString: 'comment/hide/',
|
|
366
|
+
postData: {
|
|
367
|
+
business_id: (0, _externalIdHelpers.removePrefix)(sourceId),
|
|
368
|
+
comment_id: (0, _externalIdHelpers.removePrefix)(comment_id),
|
|
369
|
+
video_id: (0, _externalIdHelpers.removePrefix)(video_id),
|
|
370
|
+
action: 'HIDE'
|
|
371
|
+
},
|
|
372
|
+
document
|
|
373
|
+
})) || {};
|
|
374
|
+
return publishedMessage;
|
|
375
|
+
}
|
|
376
|
+
async unhide(document) {
|
|
377
|
+
let parentDoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
378
|
+
const {
|
|
379
|
+
metaData: {
|
|
380
|
+
externalId: comment_id,
|
|
381
|
+
source: {
|
|
382
|
+
id: sourceId
|
|
383
|
+
},
|
|
384
|
+
discussionType
|
|
385
|
+
}
|
|
386
|
+
} = document;
|
|
387
|
+
const video_id = discussionType === 're' ? parentDoc?.metaData?.inReplyTo?.id : document?.metaData?.inReplyTo?.id;
|
|
388
|
+
const {
|
|
389
|
+
body: publishedMessage
|
|
390
|
+
} = (await this.sendPost({
|
|
391
|
+
paramString: 'comment/hide/',
|
|
392
|
+
postData: {
|
|
393
|
+
business_id: (0, _externalIdHelpers.removePrefix)(sourceId),
|
|
394
|
+
comment_id: (0, _externalIdHelpers.removePrefix)(comment_id),
|
|
395
|
+
video_id: (0, _externalIdHelpers.removePrefix)(video_id),
|
|
396
|
+
action: 'UNHIDE'
|
|
397
|
+
},
|
|
398
|
+
document
|
|
399
|
+
})) || {};
|
|
400
|
+
return publishedMessage;
|
|
401
|
+
}
|
|
402
|
+
async deleteComment(document) {
|
|
403
|
+
const {
|
|
404
|
+
metaData: {
|
|
405
|
+
inReplyTo: {
|
|
406
|
+
id: comment_id,
|
|
407
|
+
profileId: business_id
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} = document;
|
|
411
|
+
const {
|
|
412
|
+
body: publishedMessage
|
|
413
|
+
} = (await this.sendPost({
|
|
414
|
+
paramString: 'comment/delete/',
|
|
415
|
+
postData: {
|
|
416
|
+
business_id,
|
|
417
|
+
comment_id
|
|
418
|
+
},
|
|
419
|
+
document
|
|
420
|
+
})) || {};
|
|
421
|
+
return publishedMessage;
|
|
422
|
+
}
|
|
423
|
+
async getProfile(business_id, document) {
|
|
424
|
+
const fields = '["username", "display_name", "profile_image"]';
|
|
425
|
+
const profile = (await this.sendRequest({
|
|
426
|
+
paramString: `get/?business_id=${business_id}&fields=${fields}`,
|
|
427
|
+
document
|
|
428
|
+
})) || {};
|
|
429
|
+
return profile;
|
|
430
|
+
}
|
|
431
|
+
async getPostData(business_id, video_id, document) {
|
|
432
|
+
const fields = '["item_id", "thumbnail_url", "create_time", "username", "display_name", "profile_image"]';
|
|
433
|
+
const video_ids = `["${video_id}"]`;
|
|
434
|
+
const profile = (await this.sendRequest({
|
|
435
|
+
paramString: `video/list?business_id=${business_id}&fields=${fields}&filters={"video_ids":${video_ids}}`,
|
|
436
|
+
document
|
|
437
|
+
})) || {};
|
|
438
|
+
return profile;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
exports.TikTokApiClient = TikTokApiClient;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CompanyApiClient", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _companiesApiClient.CompanyApiClient;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "CredentialsApiClient", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _credentialsApiClient.CredentialsApiClient;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.DocumentHelperFunctions = void 0;
|
|
19
|
+
Object.defineProperty(exports, "EntitlementsApiClient", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _entitlementsApiClient.EntitlementsApiClient;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "FacebookApiClient", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _facebookApiClient.FacebookApiClient;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
exports.FacebookNative = void 0;
|
|
32
|
+
Object.defineProperty(exports, "FeatureToggleClient", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _featureToggleApiClient.FeatureToggleClient;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "IRClient", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _irClient.IRClient;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "IdentityServicesClient", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _identityServicesClient.IdentityServicesClient;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "InstagramApiClient", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return _instagramApiClient.InstagramApiClient;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "InstagramVideoClient", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return _InstagramVideoClient.InstagramVideoClient;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "LinkedInApiClient", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return _linkedInApiClient.LinkedInApiClient;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
exports.LinkedInHelpers = void 0;
|
|
69
|
+
Object.defineProperty(exports, "MasfClient", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return _masfClient.MasfClient;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "TikTokApiClient", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return _tiktokApiClient.TikTokApiClient;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "WarpZoneApiClient", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return _WarpZoneApiClient.WarpZoneApiClient;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "assetManagerTvmRepository", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _assetManagerTvmClient.assetManagerTvmRepository;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "awsS3Client", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return _amazonS.awsS3Client;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
var _amazonS = require("./http/amazonS3.js");
|
|
100
|
+
var _assetManagerTvmClient = require("./http/asset-manager-tvm.client.js");
|
|
101
|
+
var _companiesApiClient = require("./http/companiesApi.client.js");
|
|
102
|
+
var _credentialsApiClient = require("./http/credentialsApi.client.js");
|
|
103
|
+
var _entitlementsApiClient = require("./http/entitlementsApi.client.js");
|
|
104
|
+
var _facebookApiClient = require("./http/facebookApi.client.js");
|
|
105
|
+
var _featureToggleApiClient = require("./http/featureToggleApi.client.js");
|
|
106
|
+
var _identityServicesClient = require("./http/identityServices.client.js");
|
|
107
|
+
var _instagramApiClient = require("./http/instagramApi.client.js");
|
|
108
|
+
var _InstagramVideoClient = require("./http/InstagramVideoClient.js");
|
|
109
|
+
var _irClient = require("./http/ir.client.js");
|
|
110
|
+
var _linkedInApiClient = require("./http/linkedInApi.client.js");
|
|
111
|
+
var _tiktokApiClient = require("./http/tiktokApi.client.js");
|
|
112
|
+
var _masfClient = require("./http/masf.client.js");
|
|
113
|
+
var _WarpZoneApiClient = require("./http/WarpZoneApi.client.js");
|
|
114
|
+
var messageHelpers = _interopRequireWildcard(require("../lib/message.helpers.js"));
|
|
115
|
+
var applicationTagFunctions = _interopRequireWildcard(require("../lib/applicationTags.helpers.js"));
|
|
116
|
+
var hiddenHelpers = _interopRequireWildcard(require("../lib/hidden.helpers.js"));
|
|
117
|
+
var FacebookNative = _interopRequireWildcard(require("./http/facebook.native.js"));
|
|
118
|
+
exports.FacebookNative = FacebookNative;
|
|
119
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
120
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
121
|
+
const DocumentHelperFunctions = exports.DocumentHelperFunctions = {
|
|
122
|
+
...messageHelpers,
|
|
123
|
+
...applicationTagFunctions,
|
|
124
|
+
...hiddenHelpers
|
|
125
|
+
};
|
|
126
|
+
const LinkedInHelpers = exports.LinkedInHelpers = {
|
|
127
|
+
getOrganization: _linkedInApiClient.getOrganization,
|
|
128
|
+
getProfile: _linkedInApiClient.getProfile
|
|
129
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EngageError = void 0;
|
|
7
|
+
class EngageError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
this.name = this.constructor.name;
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.EngageError = EngageError;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EngageHttpError = void 0;
|
|
7
|
+
var _engageError = require("./engage-error");
|
|
8
|
+
class EngageHttpError extends _engageError.EngageError {
|
|
9
|
+
status;
|
|
10
|
+
statusText;
|
|
11
|
+
response;
|
|
12
|
+
headers;
|
|
13
|
+
constructor(status, statusText, response, headers) {
|
|
14
|
+
super(`HTTP ${status}: ${statusText}`, statusText);
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
this.name = this.constructor.name;
|
|
17
|
+
this.status = status;
|
|
18
|
+
this.statusText = statusText;
|
|
19
|
+
this.response = response;
|
|
20
|
+
this.headers = headers;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.EngageHttpError = EngageHttpError;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkApplicationTagsForUserLikes = checkApplicationTagsForUserLikes;
|
|
7
|
+
exports.getCredentialIdFromApplicationTags = getCredentialIdFromApplicationTags;
|
|
8
|
+
exports.parseApplicationTags = parseApplicationTags;
|
|
9
|
+
function parseApplicationTags(tags) {
|
|
10
|
+
const parsedTags = {};
|
|
11
|
+
if (!tags) {
|
|
12
|
+
return parsedTags;
|
|
13
|
+
}
|
|
14
|
+
tags.map(tag => {
|
|
15
|
+
const [key, value] = tag.split('=');
|
|
16
|
+
parsedTags[key] = value;
|
|
17
|
+
});
|
|
18
|
+
return parsedTags;
|
|
19
|
+
}
|
|
20
|
+
function checkApplicationTagsForUserLikes(applicationTags) {
|
|
21
|
+
const appTags = parseApplicationTags(applicationTags);
|
|
22
|
+
if (appTags.userLikes === 'true') {
|
|
23
|
+
return true;
|
|
24
|
+
} else {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function getCredentialIdFromApplicationTags(applicationTags) {
|
|
29
|
+
return applicationTags.find(appTag => appTag.startsWith('connectionsCredential=') || appTag.startsWith('connectionscredential='))?.substring(22);
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
get: varName => {
|
|
9
|
+
const value = process.env[varName];
|
|
10
|
+
if (value === 'true') return true;
|
|
11
|
+
if (value === 'false') return false;
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
MARK_AS_TODO: 'MARK_AS_TODO',
|
|
9
|
+
MARK_AS_COMPLETE: 'MARK_AS_COMPLETE',
|
|
10
|
+
USER_STARTED_RESPONDING: 'USER_STARTED_RESPONDING',
|
|
11
|
+
USER_STOPPED_RESPONDING: 'USER_STOPPED_RESPONDING'
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removePrefix = removePrefix;
|
|
7
|
+
exports.twitterPrefixCheck = twitterPrefixCheck;
|
|
8
|
+
function removePrefix(document) {
|
|
9
|
+
return document && document.replace(/id\:[a-zA-Z]+\.com:/g, '');
|
|
10
|
+
}
|
|
11
|
+
function twitterPrefixCheck(socialOriginType, value) {
|
|
12
|
+
let result = value;
|
|
13
|
+
if (socialOriginType === 'twitter') {
|
|
14
|
+
if (!value.includes('id:twitter.com:')) {
|
|
15
|
+
result = 'id:twitter.com:' + value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|