@meltwater/conversations-api-services 1.3.2 → 1.4.0

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.
Files changed (28) hide show
  1. package/.github/workflows/release.yml +4 -6
  2. package/CLAUDE.md +70 -0
  3. package/dist/cjs/data-access/http/facebook.native.js +122 -106
  4. package/dist/cjs/data-access/http/instagram.native.js +92 -49
  5. package/dist/cjs/data-access/http/linkedin.native.js +135 -56
  6. package/dist/cjs/data-access/http/threads.native.js +53 -18
  7. package/dist/cjs/data-access/http/tiktok.native.js +18 -12
  8. package/dist/cjs/data-access/http/twitter.native.js +142 -40
  9. package/dist/cjs/data-access/http/youtube.native.js +19 -13
  10. package/dist/esm/data-access/http/facebook.native.js +123 -107
  11. package/dist/esm/data-access/http/instagram.native.js +93 -50
  12. package/dist/esm/data-access/http/linkedin.native.js +136 -57
  13. package/dist/esm/data-access/http/threads.native.js +54 -19
  14. package/dist/esm/data-access/http/tiktok.native.js +19 -13
  15. package/dist/esm/data-access/http/twitter.native.js +143 -41
  16. package/dist/esm/data-access/http/youtube.native.js +20 -14
  17. package/package.json +1 -3
  18. package/src/data-access/http/README.md +50 -0
  19. package/src/data-access/http/facebook.native.js +122 -144
  20. package/src/data-access/http/instagram.native.js +113 -93
  21. package/src/data-access/http/linkedin.native.js +144 -83
  22. package/src/data-access/http/threads.native.js +58 -27
  23. package/src/data-access/http/tiktok.native.js +19 -39
  24. package/src/data-access/http/twitter.native.js +145 -65
  25. package/src/data-access/http/youtube.native.js +21 -40
  26. package/dist/cjs/lib/hiddenComment.helper.js +0 -119
  27. package/dist/esm/lib/hiddenComment.helper.js +0 -112
  28. package/src/lib/hiddenComment.helper.js +0 -107
@@ -1,112 +0,0 @@
1
- import logger from '../lib/logger.js';
2
- import { IRClient } from '../data-access/http/ir.clien.jst';
3
- import XRunes from '@meltwater/xrunes';
4
- import xRunesCore from '@meltwater/xrunes-core';
5
- import { MeltwaterAttributes } from '../lib/logger.helpers.js';
6
- class HiddenCommentHelper {
7
- constructor(_ref) {
8
- let {
9
- company,
10
- user,
11
- traceId
12
- } = _ref;
13
- this.irClient = new IRClient({
14
- company,
15
- user,
16
- traceId
17
- });
18
- this.xRunes = new XRunes();
19
- this.xRunes.registerLibrary(xRunesCore);
20
- }
21
- shouldHandle(message) {
22
- return message.metaData.discussionType === 'qt';
23
- }
24
- async hideChildren(message, markHidden) {
25
- let {
26
- body: {
27
- publishDate: {
28
- date: publishDate
29
- } = {}
30
- } = {},
31
- metaData: {
32
- externalId,
33
- source: {
34
- socialOriginType
35
- } = {}
36
- } = {},
37
- systemData: {
38
- connectionsCredential: credentialId,
39
- policies: {
40
- storage: {
41
- privateTo: companyId
42
- } = {}
43
- } = {}
44
- } = {}
45
- } = message;
46
- let operation;
47
- let query = {
48
- type: 'x:match',
49
- matchQuery: {
50
- type: 'all',
51
- allQueries: [{
52
- type: 'x:dateRange',
53
- field: 'body.publishDate.date',
54
- from: publishDate
55
- }, {
56
- type: 'term',
57
- field: 'metaData.inReplyTo.externalId',
58
- value: externalId
59
- }]
60
- }
61
- };
62
- if (markHidden) {
63
- operation = 'addToSet';
64
- query.notMatchQuery = {
65
- type: 'term',
66
- field: 'metaData.applicationTags',
67
- value: 'parentHidden'
68
- };
69
- } else {
70
- operation = 'removeFromSet';
71
- query.matchQuery.allQueries.push({
72
- type: 'term',
73
- field: 'metaData.applicationTags',
74
- value: 'parentHidden'
75
- });
76
- }
77
- let runes = {
78
- query,
79
- transformers: [{
80
- type: 'idml',
81
- script: `action = "update" target = "revision" revisionGroup = "${companyId}" documentId = id operations = [{"operation": "${operation}", "value": ["parentHidden"], "fieldPath": "metaData.applicationTags"}]`
82
- }],
83
- overlayGroups: [companyId],
84
- fields: ['id'],
85
- outputConfiguration: {
86
- type: 's3',
87
- region: 'eu-west-1',
88
- roleArn: process.env.EXPORT_API_ROLE_ARN,
89
- externalId: process.env.EXPORT_API_EXTERNAL_ID,
90
- s3BucketName: process.env.EXPORT_API_S3_BUCKET,
91
- s3KeyPrefix: process.env.EXPORT_API_S3_PREFIX,
92
- // the property is optional, the trailing / isn't
93
- batchSize: 1000 // the property is optional, must be >= 100 and <= 20000. Default is 20000
94
- },
95
- metaData: {
96
- companyId
97
- }
98
- };
99
- runes.query = await this.xRunes.render(runes.query);
100
- logger.debug(`export api query: ${JSON.stringify(runes.query)}`, {
101
- [MeltwaterAttributes.COMPANYID]: companyId,
102
- [MeltwaterAttributes.CREDENTIALID]: credentialId
103
- });
104
- let results = await this.irClient.export(runes);
105
- logger.debug(`export api result: ${JSON.stringify(results)}`, {
106
- [MeltwaterAttributes.COMPANYID]: companyId,
107
- [MeltwaterAttributes.CREDENTIALID]: credentialId
108
- });
109
- return results;
110
- }
111
- }
112
- export default HiddenCommentHelper;
@@ -1,107 +0,0 @@
1
- import logger from '../lib/logger.js';
2
- import { IRClient } from '../data-access/http/ir.clien.jst';
3
- import XRunes from '@meltwater/xrunes';
4
- import xRunesCore from '@meltwater/xrunes-core';
5
- import { MeltwaterAttributes } from '../lib/logger.helpers.js';
6
-
7
- class HiddenCommentHelper {
8
- constructor({ company, user, traceId }) {
9
- this.irClient = new IRClient({ company, user, traceId });
10
-
11
- this.xRunes = new XRunes();
12
- this.xRunes.registerLibrary(xRunesCore);
13
- }
14
-
15
- shouldHandle(message) {
16
- return message.metaData.discussionType === 'qt';
17
- }
18
-
19
- async hideChildren(message, markHidden) {
20
- let {
21
- body: { publishDate: { date: publishDate } = {} } = {},
22
- metaData: { externalId, source: { socialOriginType } = {} } = {},
23
- systemData: {
24
- connectionsCredential: credentialId,
25
- policies: { storage: { privateTo: companyId } = {} } = {},
26
- } = {},
27
- } = message;
28
-
29
- let operation;
30
- let query = {
31
- type: 'x:match',
32
- matchQuery: {
33
- type: 'all',
34
- allQueries: [
35
- {
36
- type: 'x:dateRange',
37
- field: 'body.publishDate.date',
38
- from: publishDate,
39
- },
40
- {
41
- type: 'term',
42
- field: 'metaData.inReplyTo.externalId',
43
- value: externalId,
44
- },
45
- ],
46
- },
47
- };
48
-
49
- if (markHidden) {
50
- operation = 'addToSet';
51
- query.notMatchQuery = {
52
- type: 'term',
53
- field: 'metaData.applicationTags',
54
- value: 'parentHidden',
55
- };
56
- } else {
57
- operation = 'removeFromSet';
58
- query.matchQuery.allQueries.push({
59
- type: 'term',
60
- field: 'metaData.applicationTags',
61
- value: 'parentHidden',
62
- });
63
- }
64
-
65
- let runes = {
66
- query,
67
- transformers: [
68
- {
69
- type: 'idml',
70
- script: `action = "update" target = "revision" revisionGroup = "${companyId}" documentId = id operations = [{"operation": "${operation}", "value": ["parentHidden"], "fieldPath": "metaData.applicationTags"}]`,
71
- },
72
- ],
73
- overlayGroups: [companyId],
74
- fields: ['id'],
75
- outputConfiguration: {
76
- type: 's3',
77
- region: 'eu-west-1',
78
- roleArn: process.env.EXPORT_API_ROLE_ARN,
79
- externalId: process.env.EXPORT_API_EXTERNAL_ID,
80
- s3BucketName: process.env.EXPORT_API_S3_BUCKET,
81
- s3KeyPrefix: process.env.EXPORT_API_S3_PREFIX, // the property is optional, the trailing / isn't
82
- batchSize: 1000, // the property is optional, must be >= 100 and <= 20000. Default is 20000
83
- },
84
- metaData: {
85
- companyId,
86
- },
87
- };
88
-
89
- runes.query = await this.xRunes.render(runes.query);
90
-
91
- logger.debug(`export api query: ${JSON.stringify(runes.query)}`, {
92
- [MeltwaterAttributes.COMPANYID]: companyId,
93
- [MeltwaterAttributes.CREDENTIALID]: credentialId,
94
- });
95
-
96
- let results = await this.irClient.export(runes);
97
-
98
- logger.debug(`export api result: ${JSON.stringify(results)}`, {
99
- [MeltwaterAttributes.COMPANYID]: companyId,
100
- [MeltwaterAttributes.CREDENTIALID]: credentialId,
101
- });
102
-
103
- return results;
104
- }
105
- }
106
-
107
- export default HiddenCommentHelper;