@memberjunction/actions-bizapps-social 2.112.0 → 2.113.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +24 -18
- package/dist/base/base-social.action.js.map +1 -1
- package/dist/providers/buffer/buffer-base.action.d.ts.map +1 -1
- package/dist/providers/buffer/buffer-base.action.js +34 -35
- package/dist/providers/buffer/buffer-base.action.js.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/boost-post.action.js +33 -33
- package/dist/providers/facebook/actions/boost-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-album.action.js +36 -34
- package/dist/providers/facebook/actions/create-album.action.js.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/create-post.action.js +20 -20
- package/dist/providers/facebook/actions/create-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-insights.action.js +27 -25
- package/dist/providers/facebook/actions/get-page-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-page-posts.action.js +23 -19
- package/dist/providers/facebook/actions/get-page-posts.action.js.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/get-post-insights.action.js +32 -28
- package/dist/providers/facebook/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/respond-to-comments.action.js +44 -42
- package/dist/providers/facebook/actions/respond-to-comments.action.js.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/schedule-post.action.js +29 -29
- package/dist/providers/facebook/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/facebook/actions/search-posts.action.js +39 -37
- package/dist/providers/facebook/actions/search-posts.action.js.map +1 -1
- package/dist/providers/facebook/facebook-base.action.d.ts.map +1 -1
- package/dist/providers/facebook/facebook-base.action.js +59 -44
- package/dist/providers/facebook/facebook-base.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js +31 -33
- package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js +32 -28
- package/dist/providers/hootsuite/actions/create-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js +19 -19
- package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-analytics.action.js +26 -24
- package/dist/providers/hootsuite/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js +22 -22
- package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js +34 -32
- package/dist/providers/hootsuite/actions/get-social-profiles.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/search-posts.action.js +52 -43
- package/dist/providers/hootsuite/actions/search-posts.action.js.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js +28 -30
- package/dist/providers/hootsuite/actions/update-scheduled-post.action.js.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.d.ts.map +1 -1
- package/dist/providers/hootsuite/hootsuite-base.action.js +20 -18
- package/dist/providers/hootsuite/hootsuite-base.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-post.action.js +26 -27
- package/dist/providers/instagram/actions/create-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/create-story.action.js +35 -35
- package/dist/providers/instagram/actions/create-story.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-account-insights.action.js +59 -38
- package/dist/providers/instagram/actions/get-account-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-business-posts.action.js +29 -29
- package/dist/providers/instagram/actions/get-business-posts.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-comments.action.js +36 -36
- package/dist/providers/instagram/actions/get-comments.action.js.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/get-post-insights.action.js +25 -23
- package/dist/providers/instagram/actions/get-post-insights.action.js.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/schedule-post.action.js +25 -25
- package/dist/providers/instagram/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/instagram/actions/search-posts.action.js +60 -56
- package/dist/providers/instagram/actions/search-posts.action.js.map +1 -1
- package/dist/providers/instagram/instagram-base.action.d.ts.map +1 -1
- package/dist/providers/instagram/instagram-base.action.js +27 -25
- package/dist/providers/instagram/instagram-base.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-article.action.js +45 -55
- package/dist/providers/linkedin/actions/create-article.action.js.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/create-post.action.js +29 -31
- package/dist/providers/linkedin/actions/create-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-followers.action.js +28 -28
- package/dist/providers/linkedin/actions/get-followers.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-organization-posts.action.js +20 -20
- package/dist/providers/linkedin/actions/get-organization-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-personal-posts.action.js +19 -19
- package/dist/providers/linkedin/actions/get-personal-posts.action.js.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/get-post-analytics.action.js +23 -25
- package/dist/providers/linkedin/actions/get-post-analytics.action.js.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/schedule-post.action.js +30 -32
- package/dist/providers/linkedin/actions/schedule-post.action.js.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.d.ts.map +1 -1
- package/dist/providers/linkedin/actions/search-posts.action.js +30 -28
- package/dist/providers/linkedin/actions/search-posts.action.js.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.d.ts.map +1 -1
- package/dist/providers/linkedin/linkedin-base.action.js +38 -33
- package/dist/providers/linkedin/linkedin-base.action.js.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.d.ts.map +1 -1
- package/dist/providers/tiktok/tiktok-base.action.js +26 -25
- package/dist/providers/tiktok/tiktok-base.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-thread.action.js +29 -25
- package/dist/providers/twitter/actions/create-thread.action.js.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/create-tweet.action.js +23 -23
- package/dist/providers/twitter/actions/create-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/delete-tweet.action.js +19 -19
- package/dist/providers/twitter/actions/delete-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-analytics.action.js +47 -40
- package/dist/providers/twitter/actions/get-analytics.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-mentions.action.js +31 -30
- package/dist/providers/twitter/actions/get-mentions.action.js.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/get-timeline.action.js +29 -29
- package/dist/providers/twitter/actions/get-timeline.action.js.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/schedule-tweet.action.js +26 -26
- package/dist/providers/twitter/actions/schedule-tweet.action.js.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.d.ts.map +1 -1
- package/dist/providers/twitter/actions/search-tweets.action.js +58 -56
- package/dist/providers/twitter/actions/search-tweets.action.js.map +1 -1
- package/dist/providers/twitter/twitter-base.action.d.ts.map +1 -1
- package/dist/providers/twitter/twitter-base.action.js +68 -58
- package/dist/providers/twitter/twitter-base.action.js.map +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts +1 -1
- package/dist/providers/youtube/youtube-base.action.d.ts.map +1 -1
- package/dist/providers/youtube/youtube-base.action.js +25 -22
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +6 -5
- package/src/base/base-social.action.ts +224 -217
- package/src/providers/buffer/buffer-base.action.ts +441 -435
- package/src/providers/facebook/actions/boost-post.action.ts +386 -350
- package/src/providers/facebook/actions/create-album.action.ts +307 -291
- package/src/providers/facebook/actions/create-post.action.ts +227 -224
- package/src/providers/facebook/actions/get-page-insights.action.ts +403 -383
- package/src/providers/facebook/actions/get-page-posts.action.ts +225 -214
- package/src/providers/facebook/actions/get-post-insights.action.ts +316 -300
- package/src/providers/facebook/actions/respond-to-comments.action.ts +336 -319
- package/src/providers/facebook/actions/schedule-post.action.ts +292 -289
- package/src/providers/facebook/actions/search-posts.action.ts +413 -399
- package/src/providers/facebook/facebook-base.action.ts +670 -653
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +189 -184
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +161 -160
- package/src/providers/hootsuite/actions/get-analytics.action.ts +254 -249
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +207 -206
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +205 -206
- package/src/providers/hootsuite/actions/search-posts.action.ts +369 -351
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +209 -211
- package/src/providers/hootsuite/hootsuite-base.action.ts +307 -301
- package/src/providers/instagram/actions/create-post.action.ts +296 -276
- package/src/providers/instagram/actions/create-story.action.ts +394 -378
- package/src/providers/instagram/actions/get-account-insights.action.ts +420 -384
- package/src/providers/instagram/actions/get-business-posts.action.ts +242 -233
- package/src/providers/instagram/actions/get-comments.action.ts +377 -365
- package/src/providers/instagram/actions/get-post-insights.action.ts +273 -265
- package/src/providers/instagram/actions/schedule-post.action.ts +235 -233
- package/src/providers/instagram/actions/search-posts.action.ts +538 -512
- package/src/providers/instagram/instagram-base.action.ts +393 -368
- package/src/providers/linkedin/actions/create-article.action.ts +266 -275
- package/src/providers/linkedin/actions/create-post.action.ts +177 -179
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +147 -146
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +139 -138
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +189 -190
- package/src/providers/linkedin/actions/schedule-post.action.ts +189 -191
- package/src/providers/linkedin/actions/search-posts.action.ts +283 -275
- package/src/providers/linkedin/linkedin-base.action.ts +421 -407
- package/src/providers/tiktok/tiktok-base.action.ts +320 -305
- package/src/providers/twitter/actions/create-thread.action.ts +207 -203
- package/src/providers/twitter/actions/create-tweet.action.ts +188 -187
- package/src/providers/twitter/actions/delete-tweet.action.ts +129 -128
- package/src/providers/twitter/actions/get-analytics.action.ts +411 -402
- package/src/providers/twitter/actions/get-mentions.action.ts +219 -218
- package/src/providers/twitter/actions/get-timeline.action.ts +233 -232
- package/src/providers/twitter/actions/schedule-tweet.action.ts +222 -221
- package/src/providers/twitter/actions/search-tweets.action.ts +543 -540
- package/src/providers/twitter/twitter-base.action.ts +560 -541
- package/src/providers/youtube/youtube-base.action.ts +333 -320
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { TwitterBaseAction, Tweet } from '../twitter-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/core';
|
|
5
5
|
import { SocialPost } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,239 +10,240 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'TwitterGetTimelineAction')
|
|
12
12
|
export class TwitterGetTimelineAction extends TwitterBaseAction {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Get timeline tweets from Twitter
|
|
15
|
+
*/
|
|
16
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
17
|
+
const { Params, ContextUser } = params;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Initialize OAuth
|
|
21
|
+
const companyIntegrationId = this.getParamValue(Params, 'CompanyIntegrationID');
|
|
22
|
+
if (!await this.initializeOAuth(companyIntegrationId)) {
|
|
23
|
+
throw new Error('Failed to initialize OAuth connection');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Extract parameters
|
|
27
|
+
const timelineType = this.getParamValue(Params, 'TimelineType') || 'home'; // 'home' or 'user'
|
|
28
|
+
const userId = this.getParamValue(Params, 'UserID');
|
|
29
|
+
const username = this.getParamValue(Params, 'Username');
|
|
30
|
+
const maxResults = this.getParamValue(Params, 'MaxResults') || 100;
|
|
31
|
+
const excludeReplies = this.getParamValue(Params, 'ExcludeReplies') === true;
|
|
32
|
+
const excludeRetweets = this.getParamValue(Params, 'ExcludeRetweets') === true;
|
|
33
|
+
const startTime = this.getParamValue(Params, 'StartTime');
|
|
34
|
+
const endTime = this.getParamValue(Params, 'EndTime');
|
|
35
|
+
const sinceId = this.getParamValue(Params, 'SinceID');
|
|
36
|
+
const untilId = this.getParamValue(Params, 'UntilID');
|
|
37
|
+
|
|
38
|
+
let tweets: Tweet[] = [];
|
|
39
|
+
let endpoint: string;
|
|
40
|
+
const queryParams: Record<string, any> = {
|
|
41
|
+
'tweet.fields': 'id,text,created_at,author_id,conversation_id,public_metrics,attachments,entities,referenced_tweets',
|
|
42
|
+
'user.fields': 'id,name,username,profile_image_url,description,created_at,verified',
|
|
43
|
+
'media.fields': 'url,preview_image_url,type,width,height',
|
|
44
|
+
'expansions': 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id',
|
|
45
|
+
'max_results': Math.min(maxResults, 100) // API limit per request
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (timelineType === 'home') {
|
|
49
|
+
// Get home timeline (requires user context)
|
|
50
|
+
const currentUser = await this.getCurrentUser();
|
|
51
|
+
endpoint = `/users/${currentUser.id}/timelines/reverse_chronological`;
|
|
52
|
+
|
|
53
|
+
// Home timeline specific parameters
|
|
54
|
+
if (excludeReplies) {
|
|
55
|
+
queryParams['exclude'] = queryParams['exclude'] ? `${queryParams['exclude']},replies` : 'replies';
|
|
56
|
+
}
|
|
57
|
+
if (excludeRetweets) {
|
|
58
|
+
queryParams['exclude'] = queryParams['exclude'] ? `${queryParams['exclude']},retweets` : 'retweets';
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
// Get user timeline
|
|
62
|
+
let targetUserId: string;
|
|
63
|
+
|
|
64
|
+
if (userId) {
|
|
65
|
+
targetUserId = userId;
|
|
66
|
+
} else if (username) {
|
|
67
|
+
// Look up user by username
|
|
68
|
+
const userResponse = await this.axiosInstance.get(`/users/by/username/${username}`, {
|
|
69
|
+
params: { 'user.fields': 'id' }
|
|
70
|
+
});
|
|
71
|
+
targetUserId = userResponse.data.data.id;
|
|
72
|
+
} else {
|
|
73
|
+
// Default to authenticated user
|
|
74
|
+
const currentUser = await this.getCurrentUser();
|
|
75
|
+
targetUserId = currentUser.id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
endpoint = `/users/${targetUserId}/tweets`;
|
|
79
|
+
|
|
80
|
+
// User timeline specific parameters
|
|
81
|
+
if (excludeReplies) {
|
|
82
|
+
queryParams['exclude'] = queryParams['exclude'] ? `${queryParams['exclude']},replies` : 'replies';
|
|
83
|
+
}
|
|
84
|
+
if (excludeRetweets) {
|
|
85
|
+
queryParams['exclude'] = queryParams['exclude'] ? `${queryParams['exclude']},retweets` : 'retweets';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Add time-based filters if provided
|
|
90
|
+
if (startTime) {
|
|
91
|
+
queryParams['start_time'] = this.formatTwitterDate(startTime);
|
|
92
|
+
}
|
|
93
|
+
if (endTime) {
|
|
94
|
+
queryParams['end_time'] = this.formatTwitterDate(endTime);
|
|
95
|
+
}
|
|
96
|
+
if (sinceId) {
|
|
97
|
+
queryParams['since_id'] = sinceId;
|
|
98
|
+
}
|
|
99
|
+
if (untilId) {
|
|
100
|
+
queryParams['until_id'] = untilId;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Get paginated tweets
|
|
104
|
+
LogStatus(`Getting ${timelineType} timeline tweets...`);
|
|
105
|
+
tweets = await this.getPaginatedTweets(endpoint, queryParams, maxResults);
|
|
106
|
+
|
|
107
|
+
// Convert to normalized format
|
|
108
|
+
const normalizedPosts: SocialPost[] = tweets.map(tweet => this.normalizePost(tweet));
|
|
109
|
+
|
|
110
|
+
// Calculate summary statistics
|
|
111
|
+
const stats = {
|
|
112
|
+
totalTweets: normalizedPosts.length,
|
|
113
|
+
totalLikes: 0,
|
|
114
|
+
totalRetweets: 0,
|
|
115
|
+
totalReplies: 0,
|
|
116
|
+
totalImpressions: 0
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
normalizedPosts.forEach(post => {
|
|
120
|
+
if (post.analytics) {
|
|
121
|
+
stats.totalLikes += post.analytics.likes;
|
|
122
|
+
stats.totalRetweets += post.analytics.shares;
|
|
123
|
+
stats.totalReplies += post.analytics.comments;
|
|
124
|
+
stats.totalImpressions += post.analytics.impressions;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Update output parameters
|
|
129
|
+
const outputParams = [...Params];
|
|
130
|
+
const postsParam = outputParams.find(p => p.Name === 'Posts');
|
|
131
|
+
if (postsParam) postsParam.Value = normalizedPosts;
|
|
132
|
+
const tweetsParam = outputParams.find(p => p.Name === 'Tweets');
|
|
133
|
+
if (tweetsParam) tweetsParam.Value = tweets;
|
|
134
|
+
const statsParam = outputParams.find(p => p.Name === 'Statistics');
|
|
135
|
+
if (statsParam) statsParam.Value = stats;
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
Success: true,
|
|
139
|
+
ResultCode: 'SUCCESS',
|
|
140
|
+
Message: `Successfully retrieved ${normalizedPosts.length} tweets from ${timelineType} timeline`,
|
|
141
|
+
Params: outputParams
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
} catch (error) {
|
|
145
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
Success: false,
|
|
149
|
+
ResultCode: this.getErrorCode(error),
|
|
150
|
+
Message: `Failed to get timeline: ${errorMessage}`,
|
|
151
|
+
Params
|
|
152
|
+
};
|
|
56
153
|
}
|
|
57
|
-
|
|
58
|
-
queryParams['exclude'] = queryParams['exclude'] ? `${queryParams['exclude']},retweets` : 'retweets';
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
// Get user timeline
|
|
62
|
-
let targetUserId: string;
|
|
63
|
-
|
|
64
|
-
if (userId) {
|
|
65
|
-
targetUserId = userId;
|
|
66
|
-
} else if (username) {
|
|
67
|
-
// Look up user by username
|
|
68
|
-
const userResponse = await this.axiosInstance.get(`/users/by/username/${username}`, {
|
|
69
|
-
params: { 'user.fields': 'id' },
|
|
70
|
-
});
|
|
71
|
-
targetUserId = userResponse.data.data.id;
|
|
72
|
-
} else {
|
|
73
|
-
// Default to authenticated user
|
|
74
|
-
const currentUser = await this.getCurrentUser();
|
|
75
|
-
targetUserId = currentUser.id;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
endpoint = `/users/${targetUserId}/tweets`;
|
|
154
|
+
}
|
|
79
155
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Get error code based on error type
|
|
158
|
+
*/
|
|
159
|
+
private getErrorCode(error: any): string {
|
|
160
|
+
if (error instanceof Error) {
|
|
161
|
+
if (error.message.includes('Rate Limit')) return 'RATE_LIMIT';
|
|
162
|
+
if (error.message.includes('Unauthorized')) return 'INVALID_TOKEN';
|
|
163
|
+
if (error.message.includes('Not Found')) return 'USER_NOT_FOUND';
|
|
164
|
+
if (error.message.includes('Forbidden')) return 'INSUFFICIENT_PERMISSIONS';
|
|
86
165
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
166
|
+
return 'ERROR';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Define the parameters this action expects
|
|
171
|
+
*/
|
|
172
|
+
public get Params(): ActionParam[] {
|
|
173
|
+
return [
|
|
174
|
+
...this.commonSocialParams,
|
|
175
|
+
{
|
|
176
|
+
Name: 'TimelineType',
|
|
177
|
+
Type: 'Input',
|
|
178
|
+
Value: 'home' // 'home' or 'user'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
Name: 'UserID',
|
|
182
|
+
Type: 'Input',
|
|
183
|
+
Value: null
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
Name: 'Username',
|
|
187
|
+
Type: 'Input',
|
|
188
|
+
Value: null
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
Name: 'MaxResults',
|
|
192
|
+
Type: 'Input',
|
|
193
|
+
Value: 100
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
Name: 'ExcludeReplies',
|
|
197
|
+
Type: 'Input',
|
|
198
|
+
Value: false
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
Name: 'ExcludeRetweets',
|
|
202
|
+
Type: 'Input',
|
|
203
|
+
Value: false
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
Name: 'StartTime',
|
|
207
|
+
Type: 'Input',
|
|
208
|
+
Value: null
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
Name: 'EndTime',
|
|
212
|
+
Type: 'Input',
|
|
213
|
+
Value: null
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
Name: 'SinceID',
|
|
217
|
+
Type: 'Input',
|
|
218
|
+
Value: null
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
Name: 'UntilID',
|
|
222
|
+
Type: 'Input',
|
|
223
|
+
Value: null
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
Name: 'Posts',
|
|
227
|
+
Type: 'Output',
|
|
228
|
+
Value: null
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
Name: 'Tweets',
|
|
232
|
+
Type: 'Output',
|
|
233
|
+
Value: null
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
Name: 'Statistics',
|
|
237
|
+
Type: 'Output',
|
|
238
|
+
Value: null
|
|
239
|
+
}
|
|
240
|
+
];
|
|
152
241
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (error instanceof Error) {
|
|
160
|
-
if (error.message.includes('Rate Limit')) return 'RATE_LIMIT';
|
|
161
|
-
if (error.message.includes('Unauthorized')) return 'INVALID_TOKEN';
|
|
162
|
-
if (error.message.includes('Not Found')) return 'USER_NOT_FOUND';
|
|
163
|
-
if (error.message.includes('Forbidden')) return 'INSUFFICIENT_PERMISSIONS';
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Get action description
|
|
245
|
+
*/
|
|
246
|
+
public get Description(): string {
|
|
247
|
+
return 'Gets timeline tweets from Twitter/X including home timeline or a specific user\'s timeline with filtering options';
|
|
164
248
|
}
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Define the parameters this action expects
|
|
170
|
-
*/
|
|
171
|
-
public get Params(): ActionParam[] {
|
|
172
|
-
return [
|
|
173
|
-
...this.commonSocialParams,
|
|
174
|
-
{
|
|
175
|
-
Name: 'TimelineType',
|
|
176
|
-
Type: 'Input',
|
|
177
|
-
Value: 'home', // 'home' or 'user'
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
Name: 'UserID',
|
|
181
|
-
Type: 'Input',
|
|
182
|
-
Value: null,
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
Name: 'Username',
|
|
186
|
-
Type: 'Input',
|
|
187
|
-
Value: null,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
Name: 'MaxResults',
|
|
191
|
-
Type: 'Input',
|
|
192
|
-
Value: 100,
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
Name: 'ExcludeReplies',
|
|
196
|
-
Type: 'Input',
|
|
197
|
-
Value: false,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
Name: 'ExcludeRetweets',
|
|
201
|
-
Type: 'Input',
|
|
202
|
-
Value: false,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
Name: 'StartTime',
|
|
206
|
-
Type: 'Input',
|
|
207
|
-
Value: null,
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
Name: 'EndTime',
|
|
211
|
-
Type: 'Input',
|
|
212
|
-
Value: null,
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
Name: 'SinceID',
|
|
216
|
-
Type: 'Input',
|
|
217
|
-
Value: null,
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
Name: 'UntilID',
|
|
221
|
-
Type: 'Input',
|
|
222
|
-
Value: null,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
Name: 'Posts',
|
|
226
|
-
Type: 'Output',
|
|
227
|
-
Value: null,
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
Name: 'Tweets',
|
|
231
|
-
Type: 'Output',
|
|
232
|
-
Value: null,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
Name: 'Statistics',
|
|
236
|
-
Type: 'Output',
|
|
237
|
-
Value: null,
|
|
238
|
-
},
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Get action description
|
|
244
|
-
*/
|
|
245
|
-
public get Description(): string {
|
|
246
|
-
return "Gets timeline tweets from Twitter/X including home timeline or a specific user's timeline with filtering options";
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
+
}
|