@meltwater/conversations-api-services 1.0.26 → 1.0.28

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.
@@ -19,8 +19,6 @@ exports.unlike = unlike;
19
19
  var _superagent = _interopRequireDefault(require("superagent"));
20
20
  var _externalIdHelpers = require("../../lib/externalId.helpers.js");
21
21
  var _loggerHelpers = require("../../lib/logger.helpers.js");
22
- var _httpError = require("../../errors/http-error.js");
23
- var _engageError = require("../../errors/engage-error.js");
24
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
23
  const FACEBOOK_URL = 'https://graph.facebook.com';
26
24
  async function shareCount(token, externalId, logger) {
@@ -306,7 +304,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
306
304
  (0, _loggerHelpers.loggerError)(logger, `Failed to call facebook api`, err);
307
305
  }
308
306
  if (response.status) {
309
- throw new _httpError.EngageHttpError(response.status, response.statusText, response.body, response.headers);
307
+ throw new Error(response.statusText);
310
308
  }
311
309
  throw err;
312
310
  }
@@ -314,7 +312,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
314
312
  logger.error(logger, `Failed to call facebook api`, {
315
313
  responseBody: JSON.stringify(response.body)
316
314
  });
317
- throw new _engageError.EngageError(response.status, `Failed to call facebook api ${response.body}`);
315
+ throw new Error(`Failed to call facebook api ${response.body}`);
318
316
  }
319
317
  return response;
320
318
  }
@@ -3,102 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
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
- exports.InstagramNative = void 0;
57
- Object.defineProperty(exports, "InstagramVideoClient", {
58
- enumerable: true,
59
- get: function () {
60
- return _InstagramVideoClient.InstagramVideoClient;
61
- }
62
- });
63
- Object.defineProperty(exports, "LinkedInApiClient", {
64
- enumerable: true,
65
- get: function () {
66
- return _linkedInApiClient.LinkedInApiClient;
67
- }
68
- });
69
- exports.LinkedinNative = exports.LinkedInHelpers = void 0;
70
- Object.defineProperty(exports, "MasfClient", {
71
- enumerable: true,
72
- get: function () {
73
- return _masfClient.MasfClient;
74
- }
75
- });
76
- Object.defineProperty(exports, "TikTokApiClient", {
77
- enumerable: true,
78
- get: function () {
79
- return _tiktokApiClient.TikTokApiClient;
80
- }
81
- });
82
- exports.TwitterNative = exports.TiktokNative = void 0;
83
- Object.defineProperty(exports, "WarpZoneApiClient", {
84
- enumerable: true,
85
- get: function () {
86
- return _WarpZoneApiClient.WarpZoneApiClient;
87
- }
88
- });
89
- exports.YoutubeNative = void 0;
90
- Object.defineProperty(exports, "assetManagerTvmRepository", {
91
- enumerable: true,
92
- get: function () {
93
- return _assetManagerTvmClient.assetManagerTvmRepository;
94
- }
95
- });
96
- Object.defineProperty(exports, "awsS3Client", {
97
- enumerable: true,
98
- get: function () {
99
- return _amazonS.awsS3Client;
100
- }
101
- });
6
+ exports.default = void 0;
102
7
  var _amazonS = require("./http/amazonS3.js");
103
8
  var _assetManagerTvmClient = require("./http/asset-manager-tvm.client.js");
104
9
  var _companiesApiClient = require("./http/companiesApi.client.js");
@@ -118,25 +23,44 @@ var messageHelpers = _interopRequireWildcard(require("../lib/message.helpers.js"
118
23
  var applicationTagFunctions = _interopRequireWildcard(require("../lib/applicationTags.helpers.js"));
119
24
  var hiddenHelpers = _interopRequireWildcard(require("../lib/hidden.helpers.js"));
120
25
  var FacebookNative = _interopRequireWildcard(require("./http/facebook.native.js"));
121
- exports.FacebookNative = FacebookNative;
122
26
  var TiktokNative = _interopRequireWildcard(require("./http/tiktok.native.js"));
123
- exports.TiktokNative = TiktokNative;
124
27
  var YoutubeNative = _interopRequireWildcard(require("./http/youtube.native.js"));
125
- exports.YoutubeNative = YoutubeNative;
126
28
  var LinkedinNative = _interopRequireWildcard(require("./http/linkedin.native.js"));
127
- exports.LinkedinNative = LinkedinNative;
128
29
  var TwitterNative = _interopRequireWildcard(require("./http/twitter.native.js"));
129
- exports.TwitterNative = TwitterNative;
130
30
  var InstagramNative = _interopRequireWildcard(require("./http/instagram.native.js"));
131
- exports.InstagramNative = InstagramNative;
132
31
  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); }
133
32
  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; }
134
- const DocumentHelperFunctions = exports.DocumentHelperFunctions = {
33
+ const DocumentHelperFunctions = {
135
34
  ...messageHelpers,
136
35
  ...applicationTagFunctions,
137
36
  ...hiddenHelpers
138
37
  };
139
- const LinkedInHelpers = exports.LinkedInHelpers = {
38
+ const LinkedInHelpers = {
140
39
  getOrganization: _linkedInApiClient.getOrganization,
141
40
  getProfile: _linkedInApiClient.getProfile
41
+ };
42
+ var _default = exports.default = {
43
+ InstagramNative,
44
+ FacebookNative,
45
+ TiktokNative,
46
+ YoutubeNative,
47
+ LinkedinNative,
48
+ TwitterNative,
49
+ awsS3Client: _amazonS.awsS3Client,
50
+ assetManagerTvmRepository: _assetManagerTvmClient.assetManagerTvmRepository,
51
+ CompanyApiClient: _companiesApiClient.CompanyApiClient,
52
+ CredentialsApiClient: _credentialsApiClient.CredentialsApiClient,
53
+ EntitlementsApiClient: _entitlementsApiClient.EntitlementsApiClient,
54
+ FacebookApiClient: _facebookApiClient.FacebookApiClient,
55
+ FeatureToggleClient: _featureToggleApiClient.FeatureToggleClient,
56
+ IdentityServicesClient: _identityServicesClient.IdentityServicesClient,
57
+ InstagramApiClient: _instagramApiClient.InstagramApiClient,
58
+ InstagramVideoClient: _InstagramVideoClient.InstagramVideoClient,
59
+ IRClient: _irClient.IRClient,
60
+ LinkedInApiClient: _linkedInApiClient.LinkedInApiClient,
61
+ TikTokApiClient: _tiktokApiClient.TikTokApiClient,
62
+ MasfClient: _masfClient.MasfClient,
63
+ WarpZoneApiClient: _WarpZoneApiClient.WarpZoneApiClient,
64
+ DocumentHelperFunctions,
65
+ LinkedInHelpers
142
66
  };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1,8 +1,6 @@
1
1
  import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
3
  import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
4
- import { EngageHttpError } from '../../errors/http-error.js';
5
- import { EngageError } from '../../errors/engage-error.js';
6
4
  const FACEBOOK_URL = 'https://graph.facebook.com';
7
5
  export async function shareCount(token, externalId, logger) {
8
6
  try {
@@ -287,7 +285,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
287
285
  loggerError(logger, `Failed to call facebook api`, err);
288
286
  }
289
287
  if (response.status) {
290
- throw new EngageHttpError(response.status, response.statusText, response.body, response.headers);
288
+ throw new Error(response.statusText);
291
289
  }
292
290
  throw err;
293
291
  }
@@ -295,7 +293,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
295
293
  logger.error(logger, `Failed to call facebook api`, {
296
294
  responseBody: JSON.stringify(response.body)
297
295
  });
298
- throw new EngageError(response.status, `Failed to call facebook api ${response.body}`);
296
+ throw new Error(`Failed to call facebook api ${response.body}`);
299
297
  }
300
298
  return response;
301
299
  }
@@ -31,4 +31,28 @@ const LinkedInHelpers = {
31
31
  getOrganization,
32
32
  getProfile
33
33
  };
34
- export { InstagramNative, FacebookNative, TiktokNative, YoutubeNative, LinkedinNative, TwitterNative, awsS3Client, assetManagerTvmRepository, CompanyApiClient, CredentialsApiClient, EntitlementsApiClient, FacebookApiClient, FeatureToggleClient, IdentityServicesClient, InstagramApiClient, InstagramVideoClient, IRClient, LinkedInApiClient, TikTokApiClient, MasfClient, WarpZoneApiClient, DocumentHelperFunctions, LinkedInHelpers };
34
+ export default {
35
+ InstagramNative,
36
+ FacebookNative,
37
+ TiktokNative,
38
+ YoutubeNative,
39
+ LinkedinNative,
40
+ TwitterNative,
41
+ awsS3Client,
42
+ assetManagerTvmRepository,
43
+ CompanyApiClient,
44
+ CredentialsApiClient,
45
+ EntitlementsApiClient,
46
+ FacebookApiClient,
47
+ FeatureToggleClient,
48
+ IdentityServicesClient,
49
+ InstagramApiClient,
50
+ InstagramVideoClient,
51
+ IRClient,
52
+ LinkedInApiClient,
53
+ TikTokApiClient,
54
+ MasfClient,
55
+ WarpZoneApiClient,
56
+ DocumentHelperFunctions,
57
+ LinkedInHelpers
58
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
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",
7
7
  "exports": {
8
- "require": "./dist/cjs/data-access/index.js",
9
- "import": "./dist/esm/data-access/index.js"
8
+ ".": {
9
+ "require": "./dist/cjs/data-access/index.js",
10
+ "import": "./dist/esm/data-access/index.js"
11
+ }
10
12
  },
11
13
  "directories": {
12
14
  "doc": "docs"
@@ -16,7 +18,8 @@
16
18
  "test": "echo \"Error: no test specified\" && exit 1",
17
19
  "build:cjs": "BABEL_ENV=cjs babel src --out-dir dist/cjs",
18
20
  "build:esm": "BABEL_ENV=esm babel src --out-dir dist/esm",
19
- "build": "npm run build:cjs && npm run build:esm"
21
+ "build": "npm run build:cjs && npm run build:esm && npm run postbuild",
22
+ "postbuild": "node scripts/create-package-json.js"
20
23
  },
21
24
  "repository": {
22
25
  "type": "git",
@@ -0,0 +1,22 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const esmDir = path.join(__dirname, '../dist/esm');
5
+ const cjsDir = path.join(__dirname, '../dist/cjs');
6
+
7
+ // Function to write package.json
8
+ function writePackageJson(dir, content) {
9
+ const packageJsonPath = path.join(dir, 'package.json');
10
+ fs.writeFileSync(packageJsonPath, JSON.stringify(content, null, 2), 'utf8');
11
+ console.log(`Created package.json in ${dir}`);
12
+ }
13
+
14
+ // Create package.json for ESM
15
+ writePackageJson(esmDir, {
16
+ type: 'module',
17
+ });
18
+
19
+ // Create package.json for CJS (optional)
20
+ writePackageJson(cjsDir, {
21
+ type: 'commonjs',
22
+ });
@@ -1,8 +1,6 @@
1
1
  import superagent from 'superagent';
2
2
  import { removePrefix } from '../../lib/externalId.helpers.js';
3
3
  import { loggerDebug, loggerError, loggerInfo } from '../../lib/logger.helpers.js';
4
- import { EngageHttpError } from '../../errors/http-error.js';
5
- import { EngageError } from '../../errors/engage-error.js';
6
4
 
7
5
  const FACEBOOK_URL = 'https://graph.facebook.com';
8
6
 
@@ -477,7 +475,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
477
475
  );
478
476
  }
479
477
  if(response.status){
480
- throw new EngageHttpError(response.status, response.statusText, response.body, response.headers);
478
+ throw new Error(response.statusText);
481
479
  }
482
480
  throw err;
483
481
  }
@@ -487,8 +485,7 @@ async function postApi(apiUrl, accessToken, payload, logger) {
487
485
  `Failed to call facebook api`,
488
486
  { responseBody: JSON.stringify(response.body) }
489
487
  );
490
- throw new EngageError(
491
- response.status,
488
+ throw new Error(
492
489
  `Failed to call facebook api ${response.body}`
493
490
  );
494
491
  }
@@ -33,7 +33,7 @@ const LinkedInHelpers = {
33
33
  getProfile,
34
34
  }
35
35
 
36
- export {
36
+ export default {
37
37
  InstagramNative,
38
38
  FacebookNative,
39
39
  TiktokNative,
@@ -1,16 +0,0 @@
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;
@@ -1,23 +0,0 @@
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;
@@ -1,9 +0,0 @@
1
- export class EngageError extends Error {
2
- code;
3
- constructor(code, message) {
4
- super(message);
5
- Object.setPrototypeOf(this, new.target.prototype);
6
- this.name = this.constructor.name;
7
- this.code = code;
8
- }
9
- }
@@ -1,16 +0,0 @@
1
- import { EngageError } from "./engage-error";
2
- export class EngageHttpError extends EngageError {
3
- status;
4
- statusText;
5
- response;
6
- headers;
7
- constructor(status, statusText, response, headers) {
8
- super(`HTTP ${status}: ${statusText}`, statusText);
9
- Object.setPrototypeOf(this, new.target.prototype);
10
- this.name = this.constructor.name;
11
- this.status = status;
12
- this.statusText = statusText;
13
- this.response = response;
14
- this.headers = headers;
15
- }
16
- }
@@ -1,11 +0,0 @@
1
- export class EngageError extends Error {
2
- code;
3
-
4
- constructor(code, message) {
5
- super(message);
6
- Object.setPrototypeOf(this, new.target.prototype);
7
-
8
- this.name = this.constructor.name;
9
- this.code = code;
10
- }
11
- }
@@ -1,19 +0,0 @@
1
- import { EngageError } from "./engage-error";
2
-
3
- export class EngageHttpError extends EngageError {
4
- status;
5
- statusText;
6
- response;
7
- headers;
8
-
9
- constructor(status, statusText, response, headers) {
10
- super(`HTTP ${status}: ${statusText}`, statusText);
11
- Object.setPrototypeOf(this, new.target.prototype);
12
-
13
- this.name = this.constructor.name;
14
- this.status = status;
15
- this.statusText = statusText;
16
- this.response = response;
17
- this.headers = headers;
18
- }
19
- }
File without changes