@meltwater/conversations-api-services 1.0.19 → 1.0.21
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/tiktok.native.js +162 -0
- package/dist/cjs/data-access/http/tiktokApi.client.js +441 -0
- package/dist/cjs/data-access/index.js +132 -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/tiktok.native.js +146 -0
- package/dist/esm/data-access/http/tiktokApi.client.js +433 -0
- package/dist/esm/data-access/index.js +30 -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/http/tiktok.native.js +248 -0
- package/src/data-access/index.js +4 -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,132 @@
|
|
|
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
|
+
exports.TiktokNative = void 0;
|
|
82
|
+
Object.defineProperty(exports, "WarpZoneApiClient", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return _WarpZoneApiClient.WarpZoneApiClient;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "assetManagerTvmRepository", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return _assetManagerTvmClient.assetManagerTvmRepository;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "awsS3Client", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return _amazonS.awsS3Client;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
var _amazonS = require("./http/amazonS3.js");
|
|
101
|
+
var _assetManagerTvmClient = require("./http/asset-manager-tvm.client.js");
|
|
102
|
+
var _companiesApiClient = require("./http/companiesApi.client.js");
|
|
103
|
+
var _credentialsApiClient = require("./http/credentialsApi.client.js");
|
|
104
|
+
var _entitlementsApiClient = require("./http/entitlementsApi.client.js");
|
|
105
|
+
var _facebookApiClient = require("./http/facebookApi.client.js");
|
|
106
|
+
var _featureToggleApiClient = require("./http/featureToggleApi.client.js");
|
|
107
|
+
var _identityServicesClient = require("./http/identityServices.client.js");
|
|
108
|
+
var _instagramApiClient = require("./http/instagramApi.client.js");
|
|
109
|
+
var _InstagramVideoClient = require("./http/InstagramVideoClient.js");
|
|
110
|
+
var _irClient = require("./http/ir.client.js");
|
|
111
|
+
var _linkedInApiClient = require("./http/linkedInApi.client.js");
|
|
112
|
+
var _tiktokApiClient = require("./http/tiktokApi.client.js");
|
|
113
|
+
var _masfClient = require("./http/masf.client.js");
|
|
114
|
+
var _WarpZoneApiClient = require("./http/WarpZoneApi.client.js");
|
|
115
|
+
var messageHelpers = _interopRequireWildcard(require("../lib/message.helpers.js"));
|
|
116
|
+
var applicationTagFunctions = _interopRequireWildcard(require("../lib/applicationTags.helpers.js"));
|
|
117
|
+
var hiddenHelpers = _interopRequireWildcard(require("../lib/hidden.helpers.js"));
|
|
118
|
+
var FacebookNative = _interopRequireWildcard(require("./http/facebook.native.js"));
|
|
119
|
+
exports.FacebookNative = FacebookNative;
|
|
120
|
+
var TiktokNative = _interopRequireWildcard(require("./http/tiktok.native.js"));
|
|
121
|
+
exports.TiktokNative = TiktokNative;
|
|
122
|
+
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); }
|
|
123
|
+
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; }
|
|
124
|
+
const DocumentHelperFunctions = exports.DocumentHelperFunctions = {
|
|
125
|
+
...messageHelpers,
|
|
126
|
+
...applicationTagFunctions,
|
|
127
|
+
...hiddenHelpers
|
|
128
|
+
};
|
|
129
|
+
const LinkedInHelpers = exports.LinkedInHelpers = {
|
|
130
|
+
getOrganization: _linkedInApiClient.getOrganization,
|
|
131
|
+
getProfile: _linkedInApiClient.getProfile
|
|
132
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isThisHiddenEligible = isThisHiddenEligible;
|
|
7
|
+
exports.socialTypesThatCanBeHidden = socialTypesThatCanBeHidden;
|
|
8
|
+
function socialTypesThatCanBeHidden() {
|
|
9
|
+
return ['instagram', 'facebook', 'tiktok'];
|
|
10
|
+
}
|
|
11
|
+
function isThisHiddenEligible(document) {
|
|
12
|
+
return socialTypesThatCanBeHidden().includes(document.metaData.source.socialOriginType);
|
|
13
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _logger = _interopRequireDefault(require("../lib/logger.js"));
|
|
8
|
+
var _irClien = require("../data-access/http/ir.clien.jst");
|
|
9
|
+
var _xrunes = _interopRequireDefault(require("@meltwater/xrunes"));
|
|
10
|
+
var _xrunesCore = _interopRequireDefault(require("@meltwater/xrunes-core"));
|
|
11
|
+
var _loggerHelpers = require("../lib/logger.helpers.js");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
class HiddenCommentHelper {
|
|
14
|
+
constructor(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
company,
|
|
17
|
+
user,
|
|
18
|
+
traceId
|
|
19
|
+
} = _ref;
|
|
20
|
+
this.irClient = new _irClien.IRClient({
|
|
21
|
+
company,
|
|
22
|
+
user,
|
|
23
|
+
traceId
|
|
24
|
+
});
|
|
25
|
+
this.xRunes = new _xrunes.default();
|
|
26
|
+
this.xRunes.registerLibrary(_xrunesCore.default);
|
|
27
|
+
}
|
|
28
|
+
shouldHandle(message) {
|
|
29
|
+
return message.metaData.discussionType === 'qt';
|
|
30
|
+
}
|
|
31
|
+
async hideChildren(message, markHidden) {
|
|
32
|
+
let {
|
|
33
|
+
body: {
|
|
34
|
+
publishDate: {
|
|
35
|
+
date: publishDate
|
|
36
|
+
} = {}
|
|
37
|
+
} = {},
|
|
38
|
+
metaData: {
|
|
39
|
+
externalId,
|
|
40
|
+
source: {
|
|
41
|
+
socialOriginType
|
|
42
|
+
} = {}
|
|
43
|
+
} = {},
|
|
44
|
+
systemData: {
|
|
45
|
+
connectionsCredential: credentialId,
|
|
46
|
+
policies: {
|
|
47
|
+
storage: {
|
|
48
|
+
privateTo: companyId
|
|
49
|
+
} = {}
|
|
50
|
+
} = {}
|
|
51
|
+
} = {}
|
|
52
|
+
} = message;
|
|
53
|
+
let operation;
|
|
54
|
+
let query = {
|
|
55
|
+
type: 'x:match',
|
|
56
|
+
matchQuery: {
|
|
57
|
+
type: 'all',
|
|
58
|
+
allQueries: [{
|
|
59
|
+
type: 'x:dateRange',
|
|
60
|
+
field: 'body.publishDate.date',
|
|
61
|
+
from: publishDate
|
|
62
|
+
}, {
|
|
63
|
+
type: 'term',
|
|
64
|
+
field: 'metaData.inReplyTo.externalId',
|
|
65
|
+
value: externalId
|
|
66
|
+
}]
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
if (markHidden) {
|
|
70
|
+
operation = 'addToSet';
|
|
71
|
+
query.notMatchQuery = {
|
|
72
|
+
type: 'term',
|
|
73
|
+
field: 'metaData.applicationTags',
|
|
74
|
+
value: 'parentHidden'
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
operation = 'removeFromSet';
|
|
78
|
+
query.matchQuery.allQueries.push({
|
|
79
|
+
type: 'term',
|
|
80
|
+
field: 'metaData.applicationTags',
|
|
81
|
+
value: 'parentHidden'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
let runes = {
|
|
85
|
+
query,
|
|
86
|
+
transformers: [{
|
|
87
|
+
type: 'idml',
|
|
88
|
+
script: `action = "update" target = "revision" revisionGroup = "${companyId}" documentId = id operations = [{"operation": "${operation}", "value": ["parentHidden"], "fieldPath": "metaData.applicationTags"}]`
|
|
89
|
+
}],
|
|
90
|
+
overlayGroups: [companyId],
|
|
91
|
+
fields: ['id'],
|
|
92
|
+
outputConfiguration: {
|
|
93
|
+
type: 's3',
|
|
94
|
+
region: 'eu-west-1',
|
|
95
|
+
roleArn: process.env.EXPORT_API_ROLE_ARN,
|
|
96
|
+
externalId: process.env.EXPORT_API_EXTERNAL_ID,
|
|
97
|
+
s3BucketName: process.env.EXPORT_API_S3_BUCKET,
|
|
98
|
+
s3KeyPrefix: process.env.EXPORT_API_S3_PREFIX,
|
|
99
|
+
// the property is optional, the trailing / isn't
|
|
100
|
+
batchSize: 1000 // the property is optional, must be >= 100 and <= 20000. Default is 20000
|
|
101
|
+
},
|
|
102
|
+
metaData: {
|
|
103
|
+
companyId
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
runes.query = await this.xRunes.render(runes.query);
|
|
107
|
+
_logger.default.debug(`export api query: ${JSON.stringify(runes.query)}`, {
|
|
108
|
+
[_loggerHelpers.MeltwaterAttributes.COMPANYID]: companyId,
|
|
109
|
+
[_loggerHelpers.MeltwaterAttributes.CREDENTIALID]: credentialId
|
|
110
|
+
});
|
|
111
|
+
let results = await this.irClient.export(runes);
|
|
112
|
+
_logger.default.debug(`export api result: ${JSON.stringify(results)}`, {
|
|
113
|
+
[_loggerHelpers.MeltwaterAttributes.COMPANYID]: companyId,
|
|
114
|
+
[_loggerHelpers.MeltwaterAttributes.CREDENTIALID]: credentialId
|
|
115
|
+
});
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
var _default = exports.default = HiddenCommentHelper;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MeltwaterAttributes = void 0;
|
|
7
|
+
exports.loggerDebug = loggerDebug;
|
|
8
|
+
exports.loggerError = loggerError;
|
|
9
|
+
exports.loggerInfo = loggerInfo;
|
|
10
|
+
const MeltwaterAttributes = exports.MeltwaterAttributes = {
|
|
11
|
+
COMPANYID: 'meltwater.company.id',
|
|
12
|
+
// Unique identifier of a company as it applies to meltwater search
|
|
13
|
+
DOCUMENTID: 'meltwater.document.id',
|
|
14
|
+
// Unique identifier of a document indexed into search
|
|
15
|
+
DOCUMENTLANG: 'meltwater.document.lang',
|
|
16
|
+
// Two-letter country code (lower-case) of the original document
|
|
17
|
+
DOCUMENTEXTERNALID: 'meltwater.document.external_id',
|
|
18
|
+
// The external ID of the document
|
|
19
|
+
REQUESTFORMAT: 'meltwater.document.request_format',
|
|
20
|
+
// The document format requested (“gyda”/”quiddity”)
|
|
21
|
+
DOCUMENTIDS: 'meltwater.document_ids',
|
|
22
|
+
// A list of document Ids
|
|
23
|
+
SEARCHIDS: 'meltwater.search_ids',
|
|
24
|
+
// List of IDs of saved searches.
|
|
25
|
+
AUTHORLISTIDS: 'meltwater.authorlist_ids',
|
|
26
|
+
// List of IDs of author lists.
|
|
27
|
+
TAGNAMES: 'meltwater.tag_names',
|
|
28
|
+
// List of tag names
|
|
29
|
+
SEARCHID: 'meltwater.search.id',
|
|
30
|
+
// ID for a saved search
|
|
31
|
+
CREDENTIALID: 'meltwater.social.credential_id',
|
|
32
|
+
// Identifier for Owned and Paid Social Connections.
|
|
33
|
+
CREDENTIALIDS: 'meltwater.social.credential_ids',
|
|
34
|
+
// List of Credential IDs
|
|
35
|
+
SOCIALEXTERNALID: 'meltwater.social.external_id',
|
|
36
|
+
// External ID for Owned and Paid Social Connections.
|
|
37
|
+
ASSETID: 'meltwater.asset.id',
|
|
38
|
+
// Asset ID in the asset library
|
|
39
|
+
ASSETIDS: 'meltwater.asset.ids',
|
|
40
|
+
// List of Asset IDs
|
|
41
|
+
WORKSPACEID: 'meltwater.workspace.id',
|
|
42
|
+
// Workspace ID
|
|
43
|
+
PRODUCTTYPE: 'meltwater.product_type',
|
|
44
|
+
// The name of the product for the search request
|
|
45
|
+
CLIENTNAME: 'meltwater.client_name',
|
|
46
|
+
// The “client_name” identifier used for API calls
|
|
47
|
+
ORIGINALCLIENTNAME: 'meltwater.original_client_name',
|
|
48
|
+
// The originating “client_name” identifier used for API calls
|
|
49
|
+
AUTHKEYID: 'meltwater.auth.kid',
|
|
50
|
+
// The JWT Key ID for the request.
|
|
51
|
+
AUTHEXP: 'meltwater.auth.exp',
|
|
52
|
+
// The expiration of the auth credentials.
|
|
53
|
+
AUTHPERMISSIONS: 'meltwater.auth.permissions',
|
|
54
|
+
// List of auth permermissions.
|
|
55
|
+
USERID: 'user.id' // ID of the user
|
|
56
|
+
};
|
|
57
|
+
function loggerDebug(logger, message) {
|
|
58
|
+
let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
59
|
+
if (logger) logger.debug(message, meta);
|
|
60
|
+
}
|
|
61
|
+
function loggerInfo(logger, message) {
|
|
62
|
+
let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
63
|
+
if (logger) logger.info(message, meta);
|
|
64
|
+
}
|
|
65
|
+
function loggerError(logger, message) {
|
|
66
|
+
let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
67
|
+
if (logger) logger.error(message, meta);
|
|
68
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _winston = _interopRequireDefault(require("winston"));
|
|
8
|
+
var _ecsWinstonFormat = require("@elastic/ecs-winston-format");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const format = (0, _ecsWinstonFormat.ecsFormat)({
|
|
11
|
+
serviceName: process.env.NODE_ENV ? `conversations-api-services-${process.env.NODE_ENV}` : 'conversations-api-services',
|
|
12
|
+
serviceVersion: process.env.npm_package_version,
|
|
13
|
+
serviceEnvironment: process.env.NODE_ENV
|
|
14
|
+
});
|
|
15
|
+
const logger = _winston.default.createLogger({
|
|
16
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
17
|
+
format,
|
|
18
|
+
defaultMeta: {},
|
|
19
|
+
transports: [new _winston.default.transports.Console({
|
|
20
|
+
format
|
|
21
|
+
})]
|
|
22
|
+
});
|
|
23
|
+
var _default = exports.default = logger;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMention = isMention;
|
|
7
|
+
function isMention(_ref, credential) {
|
|
8
|
+
let {
|
|
9
|
+
appData: {
|
|
10
|
+
isMention = false
|
|
11
|
+
} = {},
|
|
12
|
+
body: {
|
|
13
|
+
mentions = []
|
|
14
|
+
} = {},
|
|
15
|
+
metaData: {
|
|
16
|
+
authors: [{
|
|
17
|
+
authorInfo: {
|
|
18
|
+
externalId: authorExternalId,
|
|
19
|
+
handle: authorHandle
|
|
20
|
+
} = {}
|
|
21
|
+
} = {}] = [{}],
|
|
22
|
+
inReplyTo: {
|
|
23
|
+
author: {
|
|
24
|
+
externalId: inReplyToExternalId,
|
|
25
|
+
handle: inReplyToHandle
|
|
26
|
+
} = {}
|
|
27
|
+
} = {},
|
|
28
|
+
discussionType = '',
|
|
29
|
+
source: {
|
|
30
|
+
socialOriginType
|
|
31
|
+
} = {}
|
|
32
|
+
} = {},
|
|
33
|
+
providerSpecific
|
|
34
|
+
} = _ref;
|
|
35
|
+
if (socialOriginType == 'twitter' && discussionType != 'og') {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
// if inReplyToExternalId is the same as the credential's social_account_id, then it's not a mention
|
|
39
|
+
if (inReplyToExternalId && credential.social_account_id && inReplyToExternalId === credential.social_account_id || inReplyToHandle === credential.username) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (authorExternalId && credential.social_account_id && authorExternalId === credential.social_account_id || authorHandle?.length && (authorHandle.toLowerCase() === credential.username?.toLowerCase || authorHandle.toLowerCase() === credential.handle?.toLowerCase())) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
let retIsMention = (['og', 're', 'qt'].includes(discussionType) || discussionType === 'dm' && socialOriginType === 'instagram') && (mentions?.length && mentions.some(mention => mention.toLowerCase() === credential.pageName?.toLowerCase() || mention.toLowerCase() === credential.target_page_name?.toLowerCase() || mention.toLowerCase() === credential.userName?.toLowerCase() || mention.toLowerCase() === credential.username?.toLowerCase()) || isMention && socialOriginType === 'facebook');
|
|
46
|
+
if (providerSpecific) {
|
|
47
|
+
let hasMention = providerSpecific.some(_ref2 => {
|
|
48
|
+
let {
|
|
49
|
+
facebookPostType
|
|
50
|
+
} = _ref2;
|
|
51
|
+
return facebookPostType === 'mention';
|
|
52
|
+
});
|
|
53
|
+
if (hasMention) {
|
|
54
|
+
retIsMention = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return retIsMention;
|
|
58
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.metricN = exports.Metrics = void 0;
|
|
7
|
+
var _promClient = _interopRequireDefault(require("prom-client"));
|
|
8
|
+
var _logger = _interopRequireDefault(require("./logger.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const podMetricsByName = new Map();
|
|
11
|
+
const metricNames = ['irGetByDocumentId', 'irRatelimited', 'irSearch'];
|
|
12
|
+
|
|
13
|
+
// todo: make this a dynamic process
|
|
14
|
+
const irGetByDocumentIdHistogram = new _promClient.default.Histogram({
|
|
15
|
+
name: 'irGetByDocumentId_Avg_Reponse_Time',
|
|
16
|
+
help: 'metric_help',
|
|
17
|
+
buckets: _promClient.default.linearBuckets(0, 200, 40)
|
|
18
|
+
});
|
|
19
|
+
const irGetByDocumentIdCountHistogram = new _promClient.default.Histogram({
|
|
20
|
+
name: 'irGetByDocumentId_Count',
|
|
21
|
+
help: 'metric_help',
|
|
22
|
+
buckets: _promClient.default.linearBuckets(0, 1, 40)
|
|
23
|
+
});
|
|
24
|
+
metricNames.forEach(metricName => {
|
|
25
|
+
podMetricsByName.set(metricName, new _promClient.default.Counter({
|
|
26
|
+
name: metricName,
|
|
27
|
+
help: `${metricName}_help`
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
class Metrics {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.requestMetricsByName = new Map();
|
|
33
|
+
metricNames.forEach(metricName => {
|
|
34
|
+
this.requestMetricsByName.set(metricName, []);
|
|
35
|
+
});
|
|
36
|
+
this.getMetrics = metricName => {
|
|
37
|
+
return {
|
|
38
|
+
podMetrics: podMetricsByName.get(metricName),
|
|
39
|
+
requestMetrics: this.requestMetricsByName.get(metricName)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
count(metricName) {
|
|
44
|
+
const {
|
|
45
|
+
podMetrics,
|
|
46
|
+
requestMetrics
|
|
47
|
+
} = this.getMetrics(metricName);
|
|
48
|
+
if (podMetrics) {
|
|
49
|
+
podMetrics.inc();
|
|
50
|
+
} else {
|
|
51
|
+
_logger.default.error(`No pod level metric exists for ${metricName}`);
|
|
52
|
+
}
|
|
53
|
+
const metricObject = {
|
|
54
|
+
type: 'count',
|
|
55
|
+
timestamp: Date.now()
|
|
56
|
+
};
|
|
57
|
+
if (requestMetrics) {
|
|
58
|
+
requestMetrics.push(metricObject);
|
|
59
|
+
}
|
|
60
|
+
return metricObject;
|
|
61
|
+
}
|
|
62
|
+
finishOperation(metricName, metricObject) {
|
|
63
|
+
const {
|
|
64
|
+
requestMetrics
|
|
65
|
+
} = this.getMetrics(metricName);
|
|
66
|
+
if (requestMetrics) {
|
|
67
|
+
const matchingMetric = requestMetrics.find(requestMetricExiting => requestMetricExiting.timestamp === metricObject.timestamp);
|
|
68
|
+
matchingMetric.duration = Date.now() - matchingMetric.timestamp;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async somethingCompleted() {
|
|
72
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'IR.getByDocumentId';
|
|
73
|
+
let start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
74
|
+
} // duration math
|
|
75
|
+
async finishRequest() {
|
|
76
|
+
const {
|
|
77
|
+
requestMetrics
|
|
78
|
+
} = this.getMetrics('irGetByDocumentId');
|
|
79
|
+
let arrHasDuration = requestMetrics.filter(metric => metric.duration);
|
|
80
|
+
if (arrHasDuration.length) {
|
|
81
|
+
let avgDuration = arrHasDuration.reduce((avg, metric) => avg + metric.duration, 0) / arrHasDuration.length;
|
|
82
|
+
irGetByDocumentIdHistogram.observe(avgDuration);
|
|
83
|
+
}
|
|
84
|
+
if (requestMetrics.length > 0) {
|
|
85
|
+
irGetByDocumentIdCountHistogram.observe(requestMetrics.length);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.Metrics = Metrics;
|
|
90
|
+
function createEnum(values) {
|
|
91
|
+
const enumObject = {};
|
|
92
|
+
for (const val of values) {
|
|
93
|
+
enumObject[val] = val;
|
|
94
|
+
}
|
|
95
|
+
return Object.freeze(enumObject);
|
|
96
|
+
}
|
|
97
|
+
const metricN = exports.metricN = createEnum(metricNames);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import superagent from 'superagent';
|
|
2
|
+
import configuration from '../../lib/configuration.js';
|
|
3
|
+
import logger from '../../lib/logger.js';
|
|
4
|
+
export class InstagramVideoClient {
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @param {string} url
|
|
8
|
+
* @returns {Promise<object>}
|
|
9
|
+
*/
|
|
10
|
+
_getDownloadLink = async url => {
|
|
11
|
+
const apiUrl = configuration.get('UGC_MEDIA_API_URL');
|
|
12
|
+
const apiToken = configuration.get('UGC_MEDIA_API_TOKEN');
|
|
13
|
+
try {
|
|
14
|
+
const response = await superagent.get(`${apiUrl}/instagram/video/`).set('x-api-token', apiToken).query({
|
|
15
|
+
url
|
|
16
|
+
});
|
|
17
|
+
return response.body?.data;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
logger.error(`Could not retrieve video link from ${url}`, {
|
|
20
|
+
error
|
|
21
|
+
});
|
|
22
|
+
throw new Error('Could not retrieve video link');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {string} url
|
|
29
|
+
* @returns {Promise<object>}
|
|
30
|
+
*/
|
|
31
|
+
getVideoLink = async url => {
|
|
32
|
+
return await this._getDownloadLink(url);
|
|
33
|
+
};
|
|
34
|
+
}
|