@meltwater/conversations-api-services 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/data-access/http/assetManager.client.js +42 -0
- package/dist/cjs/data-access/http/twitter.native.js +3 -2
- package/dist/cjs/data-access/index.js +2 -0
- package/dist/esm/data-access/http/assetManager.client.js +35 -0
- package/dist/esm/data-access/http/twitter.native.js +3 -2
- package/dist/esm/data-access/index.js +2 -0
- package/package.json +1 -1
- package/src/data-access/http/assetManager.client.js +45 -0
- package/src/data-access/http/twitter.native.js +2 -1
- package/src/data-access/index.js +2 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getURL = getURL;
|
|
7
|
+
var _loggerHelpers = require("../../lib/logger.helpers.js");
|
|
8
|
+
var _configuration = _interopRequireDefault(require("../../lib/configuration.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const superagent = require('superagent');
|
|
11
|
+
const gatewayURL = _configuration.default.get('ASSETMANAGER_GATEWAY_URL');
|
|
12
|
+
async function getURL(jwt, assetId, logger) {
|
|
13
|
+
try {
|
|
14
|
+
const response = await superagent.post(`${gatewayURL}`).set('apollographql-client-name', 'phoenix-conversations').set('Authorization', jwt).send({
|
|
15
|
+
query: `
|
|
16
|
+
query getAssetUrlForPublishing(
|
|
17
|
+
$filter: AssetFilterInput
|
|
18
|
+
) {
|
|
19
|
+
assets(filter: $filter) {
|
|
20
|
+
edges {
|
|
21
|
+
node {
|
|
22
|
+
url
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
operationName: 'getAssetUrlForPublishing',
|
|
29
|
+
variables: {
|
|
30
|
+
filter: {
|
|
31
|
+
ids: [assetId],
|
|
32
|
+
uploadPath: ['ASSET_MANAGER', 'ENGAGE_CONVERSATIONS']
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return response.body;
|
|
37
|
+
} catch (exception) {
|
|
38
|
+
// How would you prefer to handle this
|
|
39
|
+
(0, _loggerHelpers.loggerError)(logger, 'Error getting asset url', exception);
|
|
40
|
+
throw exception;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -370,7 +370,8 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
370
370
|
uri,
|
|
371
371
|
payload,
|
|
372
372
|
attachUrlPrefix: false,
|
|
373
|
-
convertPayloadToUri: false
|
|
373
|
+
convertPayloadToUri: false,
|
|
374
|
+
logger
|
|
374
375
|
});
|
|
375
376
|
}
|
|
376
377
|
(0, _loggerHelpers.loggerInfo)(logger, `finished fetching twitterAPI nativeResponse `, {
|
|
@@ -389,7 +390,7 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
389
390
|
});
|
|
390
391
|
return response;
|
|
391
392
|
} catch (err) {
|
|
392
|
-
(0, _loggerHelpers.loggerError)(`Twitter publish exception details`, err);
|
|
393
|
+
(0, _loggerHelpers.loggerError)(logger, `Twitter publish exception details`, err);
|
|
393
394
|
throw err;
|
|
394
395
|
}
|
|
395
396
|
}
|
|
@@ -28,6 +28,7 @@ var YoutubeNative = _interopRequireWildcard(require("./http/youtube.native.js"))
|
|
|
28
28
|
var LinkedinNative = _interopRequireWildcard(require("./http/linkedin.native.js"));
|
|
29
29
|
var TwitterNative = _interopRequireWildcard(require("./http/twitter.native.js"));
|
|
30
30
|
var InstagramNative = _interopRequireWildcard(require("./http/instagram.native.js"));
|
|
31
|
+
var AssetManagerClient = _interopRequireWildcard(require("./http/assetManager.client.js"));
|
|
31
32
|
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); }
|
|
32
33
|
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; }
|
|
33
34
|
const DocumentHelperFunctions = {
|
|
@@ -47,6 +48,7 @@ var _default = exports.default = {
|
|
|
47
48
|
YoutubeNative,
|
|
48
49
|
LinkedinNative,
|
|
49
50
|
TwitterNative,
|
|
51
|
+
AssetManagerClient,
|
|
50
52
|
awsS3Client: _amazonS.awsS3Client,
|
|
51
53
|
assetManagerTvmRepository: _assetManagerTvmClient.assetManagerTvmRepository,
|
|
52
54
|
CompanyApiClient: _companiesApiClient.CompanyApiClient,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { loggerError } from '../../lib/logger.helpers.js';
|
|
2
|
+
const superagent = require('superagent');
|
|
3
|
+
import configuration from '../../lib/configuration.js';
|
|
4
|
+
const gatewayURL = configuration.get('ASSETMANAGER_GATEWAY_URL');
|
|
5
|
+
export async function getURL(jwt, assetId, logger) {
|
|
6
|
+
try {
|
|
7
|
+
const response = await superagent.post(`${gatewayURL}`).set('apollographql-client-name', 'phoenix-conversations').set('Authorization', jwt).send({
|
|
8
|
+
query: `
|
|
9
|
+
query getAssetUrlForPublishing(
|
|
10
|
+
$filter: AssetFilterInput
|
|
11
|
+
) {
|
|
12
|
+
assets(filter: $filter) {
|
|
13
|
+
edges {
|
|
14
|
+
node {
|
|
15
|
+
url
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
operationName: 'getAssetUrlForPublishing',
|
|
22
|
+
variables: {
|
|
23
|
+
filter: {
|
|
24
|
+
ids: [assetId],
|
|
25
|
+
uploadPath: ['ASSET_MANAGER', 'ENGAGE_CONVERSATIONS']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return response.body;
|
|
30
|
+
} catch (exception) {
|
|
31
|
+
// How would you prefer to handle this
|
|
32
|
+
loggerError(logger, 'Error getting asset url', exception);
|
|
33
|
+
throw exception;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -347,7 +347,8 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
347
347
|
uri,
|
|
348
348
|
payload,
|
|
349
349
|
attachUrlPrefix: false,
|
|
350
|
-
convertPayloadToUri: false
|
|
350
|
+
convertPayloadToUri: false,
|
|
351
|
+
logger
|
|
351
352
|
});
|
|
352
353
|
}
|
|
353
354
|
loggerInfo(logger, `finished fetching twitterAPI nativeResponse `, {
|
|
@@ -366,7 +367,7 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
366
367
|
});
|
|
367
368
|
return response;
|
|
368
369
|
} catch (err) {
|
|
369
|
-
loggerError(`Twitter publish exception details`, err);
|
|
370
|
+
loggerError(logger, `Twitter publish exception details`, err);
|
|
370
371
|
throw err;
|
|
371
372
|
}
|
|
372
373
|
}
|
|
@@ -22,6 +22,7 @@ import * as YoutubeNative from './http/youtube.native.js';
|
|
|
22
22
|
import * as LinkedinNative from './http/linkedin.native.js';
|
|
23
23
|
import * as TwitterNative from './http/twitter.native.js';
|
|
24
24
|
import * as InstagramNative from './http/instagram.native.js';
|
|
25
|
+
import * as AssetManagerClient from './http/assetManager.client.js';
|
|
25
26
|
const DocumentHelperFunctions = {
|
|
26
27
|
...messageHelpers,
|
|
27
28
|
...applicationTagFunctions,
|
|
@@ -39,6 +40,7 @@ export default {
|
|
|
39
40
|
YoutubeNative,
|
|
40
41
|
LinkedinNative,
|
|
41
42
|
TwitterNative,
|
|
43
|
+
AssetManagerClient,
|
|
42
44
|
awsS3Client,
|
|
43
45
|
assetManagerTvmRepository,
|
|
44
46
|
CompanyApiClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meltwater/conversations-api-services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"description": "Repository to contain all conversations api services shared across our services",
|
|
5
5
|
"main": "dist/cjs/data-access/index.js",
|
|
6
6
|
"module": "dist/esm/data-access/index.js",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { loggerError } from '../../lib/logger.helpers.js';
|
|
2
|
+
const superagent = require('superagent');
|
|
3
|
+
import configuration from '../../lib/configuration.js';
|
|
4
|
+
const gatewayURL = configuration.get(
|
|
5
|
+
'ASSETMANAGER_GATEWAY_URL'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export async function getURL(jwt, assetId, logger) {
|
|
9
|
+
try {
|
|
10
|
+
const response = await superagent
|
|
11
|
+
.post(`${gatewayURL}`)
|
|
12
|
+
.set('apollographql-client-name', 'phoenix-conversations')
|
|
13
|
+
.set('Authorization', jwt)
|
|
14
|
+
.send({
|
|
15
|
+
query: `
|
|
16
|
+
query getAssetUrlForPublishing(
|
|
17
|
+
$filter: AssetFilterInput
|
|
18
|
+
) {
|
|
19
|
+
assets(filter: $filter) {
|
|
20
|
+
edges {
|
|
21
|
+
node {
|
|
22
|
+
url
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
operationName: 'getAssetUrlForPublishing',
|
|
29
|
+
variables: {
|
|
30
|
+
filter: {
|
|
31
|
+
ids: [assetId],
|
|
32
|
+
uploadPath: [
|
|
33
|
+
'ASSET_MANAGER',
|
|
34
|
+
'ENGAGE_CONVERSATIONS',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return response.body;
|
|
40
|
+
} catch (exception) {
|
|
41
|
+
// How would you prefer to handle this
|
|
42
|
+
loggerError(logger,'Error getting asset url', exception);
|
|
43
|
+
throw exception;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -407,6 +407,7 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
407
407
|
payload,
|
|
408
408
|
attachUrlPrefix: false,
|
|
409
409
|
convertPayloadToUri: false,
|
|
410
|
+
logger
|
|
410
411
|
});
|
|
411
412
|
}
|
|
412
413
|
|
|
@@ -435,7 +436,7 @@ async function publishTweet(token, payload, query, isDirectMessage, logger) {
|
|
|
435
436
|
});
|
|
436
437
|
return response;
|
|
437
438
|
} catch (err) {
|
|
438
|
-
loggerError(
|
|
439
|
+
loggerError(logger,
|
|
439
440
|
`Twitter publish exception details`,
|
|
440
441
|
err
|
|
441
442
|
);
|
package/src/data-access/index.js
CHANGED
|
@@ -27,6 +27,7 @@ import * as YoutubeNative from './http/youtube.native.js';
|
|
|
27
27
|
import * as LinkedinNative from './http/linkedin.native.js';
|
|
28
28
|
import * as TwitterNative from './http/twitter.native.js';
|
|
29
29
|
import * as InstagramNative from './http/instagram.native.js';
|
|
30
|
+
import * as AssetManagerClient from './http/assetManager.client.js';
|
|
30
31
|
|
|
31
32
|
const DocumentHelperFunctions = {
|
|
32
33
|
...messageHelpers,
|
|
@@ -46,6 +47,7 @@ export default {
|
|
|
46
47
|
YoutubeNative,
|
|
47
48
|
LinkedinNative,
|
|
48
49
|
TwitterNative,
|
|
50
|
+
AssetManagerClient,
|
|
49
51
|
awsS3Client,
|
|
50
52
|
assetManagerTvmRepository,
|
|
51
53
|
CompanyApiClient,
|