@memberjunction/actions-bizapps-social 2.112.0 → 2.113.1

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 (204) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +13 -0
  3. package/dist/base/base-social.action.d.ts.map +1 -1
  4. package/dist/base/base-social.action.js +24 -18
  5. package/dist/base/base-social.action.js.map +1 -1
  6. package/dist/providers/buffer/buffer-base.action.d.ts.map +1 -1
  7. package/dist/providers/buffer/buffer-base.action.js +34 -35
  8. package/dist/providers/buffer/buffer-base.action.js.map +1 -1
  9. package/dist/providers/facebook/actions/boost-post.action.d.ts.map +1 -1
  10. package/dist/providers/facebook/actions/boost-post.action.js +33 -33
  11. package/dist/providers/facebook/actions/boost-post.action.js.map +1 -1
  12. package/dist/providers/facebook/actions/create-album.action.d.ts.map +1 -1
  13. package/dist/providers/facebook/actions/create-album.action.js +36 -34
  14. package/dist/providers/facebook/actions/create-album.action.js.map +1 -1
  15. package/dist/providers/facebook/actions/create-post.action.d.ts.map +1 -1
  16. package/dist/providers/facebook/actions/create-post.action.js +20 -20
  17. package/dist/providers/facebook/actions/create-post.action.js.map +1 -1
  18. package/dist/providers/facebook/actions/get-page-insights.action.d.ts.map +1 -1
  19. package/dist/providers/facebook/actions/get-page-insights.action.js +27 -25
  20. package/dist/providers/facebook/actions/get-page-insights.action.js.map +1 -1
  21. package/dist/providers/facebook/actions/get-page-posts.action.d.ts.map +1 -1
  22. package/dist/providers/facebook/actions/get-page-posts.action.js +23 -19
  23. package/dist/providers/facebook/actions/get-page-posts.action.js.map +1 -1
  24. package/dist/providers/facebook/actions/get-post-insights.action.d.ts.map +1 -1
  25. package/dist/providers/facebook/actions/get-post-insights.action.js +32 -28
  26. package/dist/providers/facebook/actions/get-post-insights.action.js.map +1 -1
  27. package/dist/providers/facebook/actions/respond-to-comments.action.d.ts.map +1 -1
  28. package/dist/providers/facebook/actions/respond-to-comments.action.js +44 -42
  29. package/dist/providers/facebook/actions/respond-to-comments.action.js.map +1 -1
  30. package/dist/providers/facebook/actions/schedule-post.action.d.ts.map +1 -1
  31. package/dist/providers/facebook/actions/schedule-post.action.js +29 -29
  32. package/dist/providers/facebook/actions/schedule-post.action.js.map +1 -1
  33. package/dist/providers/facebook/actions/search-posts.action.d.ts.map +1 -1
  34. package/dist/providers/facebook/actions/search-posts.action.js +39 -37
  35. package/dist/providers/facebook/actions/search-posts.action.js.map +1 -1
  36. package/dist/providers/facebook/facebook-base.action.d.ts.map +1 -1
  37. package/dist/providers/facebook/facebook-base.action.js +59 -44
  38. package/dist/providers/facebook/facebook-base.action.js.map +1 -1
  39. package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.d.ts.map +1 -1
  40. package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js +31 -33
  41. package/dist/providers/hootsuite/actions/bulk-schedule-posts.action.js.map +1 -1
  42. package/dist/providers/hootsuite/actions/create-scheduled-post.action.d.ts.map +1 -1
  43. package/dist/providers/hootsuite/actions/create-scheduled-post.action.js +32 -28
  44. package/dist/providers/hootsuite/actions/create-scheduled-post.action.js.map +1 -1
  45. package/dist/providers/hootsuite/actions/delete-scheduled-post.action.d.ts.map +1 -1
  46. package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js +19 -19
  47. package/dist/providers/hootsuite/actions/delete-scheduled-post.action.js.map +1 -1
  48. package/dist/providers/hootsuite/actions/get-analytics.action.d.ts.map +1 -1
  49. package/dist/providers/hootsuite/actions/get-analytics.action.js +26 -24
  50. package/dist/providers/hootsuite/actions/get-analytics.action.js.map +1 -1
  51. package/dist/providers/hootsuite/actions/get-scheduled-posts.action.d.ts.map +1 -1
  52. package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js +22 -22
  53. package/dist/providers/hootsuite/actions/get-scheduled-posts.action.js.map +1 -1
  54. package/dist/providers/hootsuite/actions/get-social-profiles.action.d.ts.map +1 -1
  55. package/dist/providers/hootsuite/actions/get-social-profiles.action.js +34 -32
  56. package/dist/providers/hootsuite/actions/get-social-profiles.action.js.map +1 -1
  57. package/dist/providers/hootsuite/actions/search-posts.action.d.ts.map +1 -1
  58. package/dist/providers/hootsuite/actions/search-posts.action.js +52 -43
  59. package/dist/providers/hootsuite/actions/search-posts.action.js.map +1 -1
  60. package/dist/providers/hootsuite/actions/update-scheduled-post.action.d.ts.map +1 -1
  61. package/dist/providers/hootsuite/actions/update-scheduled-post.action.js +28 -30
  62. package/dist/providers/hootsuite/actions/update-scheduled-post.action.js.map +1 -1
  63. package/dist/providers/hootsuite/hootsuite-base.action.d.ts.map +1 -1
  64. package/dist/providers/hootsuite/hootsuite-base.action.js +20 -18
  65. package/dist/providers/hootsuite/hootsuite-base.action.js.map +1 -1
  66. package/dist/providers/instagram/actions/create-post.action.d.ts.map +1 -1
  67. package/dist/providers/instagram/actions/create-post.action.js +26 -27
  68. package/dist/providers/instagram/actions/create-post.action.js.map +1 -1
  69. package/dist/providers/instagram/actions/create-story.action.d.ts.map +1 -1
  70. package/dist/providers/instagram/actions/create-story.action.js +35 -35
  71. package/dist/providers/instagram/actions/create-story.action.js.map +1 -1
  72. package/dist/providers/instagram/actions/get-account-insights.action.d.ts.map +1 -1
  73. package/dist/providers/instagram/actions/get-account-insights.action.js +59 -38
  74. package/dist/providers/instagram/actions/get-account-insights.action.js.map +1 -1
  75. package/dist/providers/instagram/actions/get-business-posts.action.d.ts.map +1 -1
  76. package/dist/providers/instagram/actions/get-business-posts.action.js +29 -29
  77. package/dist/providers/instagram/actions/get-business-posts.action.js.map +1 -1
  78. package/dist/providers/instagram/actions/get-comments.action.d.ts.map +1 -1
  79. package/dist/providers/instagram/actions/get-comments.action.js +36 -36
  80. package/dist/providers/instagram/actions/get-comments.action.js.map +1 -1
  81. package/dist/providers/instagram/actions/get-post-insights.action.d.ts.map +1 -1
  82. package/dist/providers/instagram/actions/get-post-insights.action.js +25 -23
  83. package/dist/providers/instagram/actions/get-post-insights.action.js.map +1 -1
  84. package/dist/providers/instagram/actions/schedule-post.action.d.ts.map +1 -1
  85. package/dist/providers/instagram/actions/schedule-post.action.js +25 -25
  86. package/dist/providers/instagram/actions/schedule-post.action.js.map +1 -1
  87. package/dist/providers/instagram/actions/search-posts.action.d.ts.map +1 -1
  88. package/dist/providers/instagram/actions/search-posts.action.js +60 -56
  89. package/dist/providers/instagram/actions/search-posts.action.js.map +1 -1
  90. package/dist/providers/instagram/instagram-base.action.d.ts.map +1 -1
  91. package/dist/providers/instagram/instagram-base.action.js +27 -25
  92. package/dist/providers/instagram/instagram-base.action.js.map +1 -1
  93. package/dist/providers/linkedin/actions/create-article.action.d.ts.map +1 -1
  94. package/dist/providers/linkedin/actions/create-article.action.js +45 -55
  95. package/dist/providers/linkedin/actions/create-article.action.js.map +1 -1
  96. package/dist/providers/linkedin/actions/create-post.action.d.ts.map +1 -1
  97. package/dist/providers/linkedin/actions/create-post.action.js +29 -31
  98. package/dist/providers/linkedin/actions/create-post.action.js.map +1 -1
  99. package/dist/providers/linkedin/actions/get-followers.action.d.ts.map +1 -1
  100. package/dist/providers/linkedin/actions/get-followers.action.js +28 -28
  101. package/dist/providers/linkedin/actions/get-followers.action.js.map +1 -1
  102. package/dist/providers/linkedin/actions/get-organization-posts.action.d.ts.map +1 -1
  103. package/dist/providers/linkedin/actions/get-organization-posts.action.js +20 -20
  104. package/dist/providers/linkedin/actions/get-organization-posts.action.js.map +1 -1
  105. package/dist/providers/linkedin/actions/get-personal-posts.action.d.ts.map +1 -1
  106. package/dist/providers/linkedin/actions/get-personal-posts.action.js +19 -19
  107. package/dist/providers/linkedin/actions/get-personal-posts.action.js.map +1 -1
  108. package/dist/providers/linkedin/actions/get-post-analytics.action.d.ts.map +1 -1
  109. package/dist/providers/linkedin/actions/get-post-analytics.action.js +23 -25
  110. package/dist/providers/linkedin/actions/get-post-analytics.action.js.map +1 -1
  111. package/dist/providers/linkedin/actions/schedule-post.action.d.ts.map +1 -1
  112. package/dist/providers/linkedin/actions/schedule-post.action.js +30 -32
  113. package/dist/providers/linkedin/actions/schedule-post.action.js.map +1 -1
  114. package/dist/providers/linkedin/actions/search-posts.action.d.ts.map +1 -1
  115. package/dist/providers/linkedin/actions/search-posts.action.js +30 -28
  116. package/dist/providers/linkedin/actions/search-posts.action.js.map +1 -1
  117. package/dist/providers/linkedin/linkedin-base.action.d.ts.map +1 -1
  118. package/dist/providers/linkedin/linkedin-base.action.js +38 -33
  119. package/dist/providers/linkedin/linkedin-base.action.js.map +1 -1
  120. package/dist/providers/tiktok/tiktok-base.action.d.ts.map +1 -1
  121. package/dist/providers/tiktok/tiktok-base.action.js +26 -25
  122. package/dist/providers/tiktok/tiktok-base.action.js.map +1 -1
  123. package/dist/providers/twitter/actions/create-thread.action.d.ts.map +1 -1
  124. package/dist/providers/twitter/actions/create-thread.action.js +29 -25
  125. package/dist/providers/twitter/actions/create-thread.action.js.map +1 -1
  126. package/dist/providers/twitter/actions/create-tweet.action.d.ts.map +1 -1
  127. package/dist/providers/twitter/actions/create-tweet.action.js +23 -23
  128. package/dist/providers/twitter/actions/create-tweet.action.js.map +1 -1
  129. package/dist/providers/twitter/actions/delete-tweet.action.d.ts.map +1 -1
  130. package/dist/providers/twitter/actions/delete-tweet.action.js +19 -19
  131. package/dist/providers/twitter/actions/delete-tweet.action.js.map +1 -1
  132. package/dist/providers/twitter/actions/get-analytics.action.d.ts.map +1 -1
  133. package/dist/providers/twitter/actions/get-analytics.action.js +47 -40
  134. package/dist/providers/twitter/actions/get-analytics.action.js.map +1 -1
  135. package/dist/providers/twitter/actions/get-mentions.action.d.ts.map +1 -1
  136. package/dist/providers/twitter/actions/get-mentions.action.js +31 -30
  137. package/dist/providers/twitter/actions/get-mentions.action.js.map +1 -1
  138. package/dist/providers/twitter/actions/get-timeline.action.d.ts.map +1 -1
  139. package/dist/providers/twitter/actions/get-timeline.action.js +29 -29
  140. package/dist/providers/twitter/actions/get-timeline.action.js.map +1 -1
  141. package/dist/providers/twitter/actions/schedule-tweet.action.d.ts.map +1 -1
  142. package/dist/providers/twitter/actions/schedule-tweet.action.js +26 -26
  143. package/dist/providers/twitter/actions/schedule-tweet.action.js.map +1 -1
  144. package/dist/providers/twitter/actions/search-tweets.action.d.ts.map +1 -1
  145. package/dist/providers/twitter/actions/search-tweets.action.js +58 -56
  146. package/dist/providers/twitter/actions/search-tweets.action.js.map +1 -1
  147. package/dist/providers/twitter/twitter-base.action.d.ts.map +1 -1
  148. package/dist/providers/twitter/twitter-base.action.js +68 -58
  149. package/dist/providers/twitter/twitter-base.action.js.map +1 -1
  150. package/dist/providers/youtube/youtube-base.action.d.ts +1 -1
  151. package/dist/providers/youtube/youtube-base.action.d.ts.map +1 -1
  152. package/dist/providers/youtube/youtube-base.action.js +25 -22
  153. package/dist/providers/youtube/youtube-base.action.js.map +1 -1
  154. package/package.json +6 -5
  155. package/src/base/base-social.action.ts +224 -217
  156. package/src/providers/buffer/buffer-base.action.ts +441 -435
  157. package/src/providers/facebook/actions/boost-post.action.ts +386 -350
  158. package/src/providers/facebook/actions/create-album.action.ts +307 -291
  159. package/src/providers/facebook/actions/create-post.action.ts +227 -224
  160. package/src/providers/facebook/actions/get-page-insights.action.ts +403 -383
  161. package/src/providers/facebook/actions/get-page-posts.action.ts +225 -214
  162. package/src/providers/facebook/actions/get-post-insights.action.ts +316 -300
  163. package/src/providers/facebook/actions/respond-to-comments.action.ts +336 -319
  164. package/src/providers/facebook/actions/schedule-post.action.ts +292 -289
  165. package/src/providers/facebook/actions/search-posts.action.ts +413 -399
  166. package/src/providers/facebook/facebook-base.action.ts +670 -653
  167. package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
  168. package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +189 -184
  169. package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +161 -160
  170. package/src/providers/hootsuite/actions/get-analytics.action.ts +254 -249
  171. package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +207 -206
  172. package/src/providers/hootsuite/actions/get-social-profiles.action.ts +205 -206
  173. package/src/providers/hootsuite/actions/search-posts.action.ts +369 -351
  174. package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +209 -211
  175. package/src/providers/hootsuite/hootsuite-base.action.ts +307 -301
  176. package/src/providers/instagram/actions/create-post.action.ts +296 -276
  177. package/src/providers/instagram/actions/create-story.action.ts +394 -378
  178. package/src/providers/instagram/actions/get-account-insights.action.ts +420 -384
  179. package/src/providers/instagram/actions/get-business-posts.action.ts +242 -233
  180. package/src/providers/instagram/actions/get-comments.action.ts +377 -365
  181. package/src/providers/instagram/actions/get-post-insights.action.ts +273 -265
  182. package/src/providers/instagram/actions/schedule-post.action.ts +235 -233
  183. package/src/providers/instagram/actions/search-posts.action.ts +538 -512
  184. package/src/providers/instagram/instagram-base.action.ts +393 -368
  185. package/src/providers/linkedin/actions/create-article.action.ts +266 -275
  186. package/src/providers/linkedin/actions/create-post.action.ts +177 -179
  187. package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
  188. package/src/providers/linkedin/actions/get-organization-posts.action.ts +147 -146
  189. package/src/providers/linkedin/actions/get-personal-posts.action.ts +139 -138
  190. package/src/providers/linkedin/actions/get-post-analytics.action.ts +189 -190
  191. package/src/providers/linkedin/actions/schedule-post.action.ts +189 -191
  192. package/src/providers/linkedin/actions/search-posts.action.ts +283 -275
  193. package/src/providers/linkedin/linkedin-base.action.ts +421 -407
  194. package/src/providers/tiktok/tiktok-base.action.ts +320 -305
  195. package/src/providers/twitter/actions/create-thread.action.ts +207 -203
  196. package/src/providers/twitter/actions/create-tweet.action.ts +188 -187
  197. package/src/providers/twitter/actions/delete-tweet.action.ts +129 -128
  198. package/src/providers/twitter/actions/get-analytics.action.ts +411 -402
  199. package/src/providers/twitter/actions/get-mentions.action.ts +219 -218
  200. package/src/providers/twitter/actions/get-timeline.action.ts +233 -232
  201. package/src/providers/twitter/actions/schedule-tweet.action.ts +222 -221
  202. package/src/providers/twitter/actions/search-tweets.action.ts +543 -540
  203. package/src/providers/twitter/twitter-base.action.ts +560 -541
  204. package/src/providers/youtube/youtube-base.action.ts +333 -320
@@ -1,7 +1,7 @@
1
1
  import { RegisterClass } from '@memberjunction/global';
2
2
  import { InstagramBaseAction } from '../instagram-base.action';
3
3
  import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
- import { LogError } from '@memberjunction/global';
4
+ import { LogError } from '@memberjunction/core';
5
5
  import { SocialPost } from '../../../base/base-social.action';
6
6
  import { BaseAction } from '@memberjunction/actions';
7
7
 
@@ -11,263 +11,272 @@ import { BaseAction } from '@memberjunction/actions';
11
11
  */
12
12
  @RegisterClass(BaseAction, 'Instagram - Get Business Posts')
13
13
  export class InstagramGetBusinessPostsAction extends InstagramBaseAction {
14
- protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
15
- try {
16
- const companyIntegrationId = this.getParamValue(params.Params, 'CompanyIntegrationID');
17
- const limit = this.getParamValue(params.Params, 'Limit') || 25;
18
- const mediaType = this.getParamValue(params.Params, 'MediaType');
19
- const includeMetrics = this.getParamValue(params.Params, 'IncludeMetrics') !== false;
20
- const afterCursor = this.getParamValue(params.Params, 'AfterCursor');
21
- const startDate = this.getParamValue(params.Params, 'StartDate');
22
- const endDate = this.getParamValue(params.Params, 'EndDate');
14
+
15
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
16
+ try {
17
+ const companyIntegrationId = this.getParamValue(params.Params, 'CompanyIntegrationID');
18
+ const limit = this.getParamValue(params.Params, 'Limit') || 25;
19
+ const mediaType = this.getParamValue(params.Params, 'MediaType');
20
+ const includeMetrics = this.getParamValue(params.Params, 'IncludeMetrics') !== false;
21
+ const afterCursor = this.getParamValue(params.Params, 'AfterCursor');
22
+ const startDate = this.getParamValue(params.Params, 'StartDate');
23
+ const endDate = this.getParamValue(params.Params, 'EndDate');
23
24
 
24
- // Initialize OAuth
25
- if (!(await this.initializeOAuth(companyIntegrationId))) {
26
- return {
27
- Success: false,
28
- Message: 'Failed to initialize Instagram authentication',
29
- ResultCode: 'AUTH_FAILED',
30
- };
31
- }
25
+ // Initialize OAuth
26
+ if (!await this.initializeOAuth(companyIntegrationId)) {
27
+ return {
28
+ Success: false,
29
+ Message: 'Failed to initialize Instagram authentication',
30
+ ResultCode: 'AUTH_FAILED'
31
+ };
32
+ }
32
33
 
33
- // Build fields parameter
34
- let fields = 'id,caption,media_type,media_url,thumbnail_url,permalink,timestamp';
35
- if (includeMetrics) {
36
- fields += ',like_count,comments_count,impressions,reach,saved,video_views';
37
- }
34
+ // Build fields parameter
35
+ let fields = 'id,caption,media_type,media_url,thumbnail_url,permalink,timestamp';
36
+ if (includeMetrics) {
37
+ fields += ',like_count,comments_count,impressions,reach,saved,video_views';
38
+ }
38
39
 
39
- // Build query parameters
40
- const queryParams: any = {
41
- fields,
42
- access_token: this.getAccessToken(),
43
- limit: Math.min(limit, 100), // Instagram max is 100 per request
44
- };
40
+ // Build query parameters
41
+ const queryParams: any = {
42
+ fields,
43
+ access_token: this.getAccessToken(),
44
+ limit: Math.min(limit, 100) // Instagram max is 100 per request
45
+ };
45
46
 
46
- if (afterCursor) {
47
- queryParams.after = afterCursor;
48
- }
47
+ if (afterCursor) {
48
+ queryParams.after = afterCursor;
49
+ }
49
50
 
50
- // Add date filtering if provided
51
- if (startDate) {
52
- queryParams.since = Math.floor(new Date(startDate).getTime() / 1000);
53
- }
54
- if (endDate) {
55
- queryParams.until = Math.floor(new Date(endDate).getTime() / 1000);
56
- }
51
+ // Add date filtering if provided
52
+ if (startDate) {
53
+ queryParams.since = Math.floor(new Date(startDate).getTime() / 1000);
54
+ }
55
+ if (endDate) {
56
+ queryParams.until = Math.floor(new Date(endDate).getTime() / 1000);
57
+ }
57
58
 
58
- // Fetch posts
59
- const response = await this.makeInstagramRequest<{
60
- data: any[];
61
- paging?: {
62
- cursors: {
63
- before: string;
64
- after: string;
65
- };
66
- next?: string;
67
- previous?: string;
68
- };
69
- }>(`${this.instagramBusinessAccountId}/media`, 'GET', null, queryParams);
59
+ // Fetch posts
60
+ const response = await this.makeInstagramRequest<{
61
+ data: any[];
62
+ paging?: {
63
+ cursors: {
64
+ before: string;
65
+ after: string;
66
+ };
67
+ next?: string;
68
+ previous?: string;
69
+ };
70
+ }>(
71
+ `${this.instagramBusinessAccountId}/media`,
72
+ 'GET',
73
+ null,
74
+ queryParams
75
+ );
70
76
 
71
- // Filter by media type if specified
72
- let posts = response.data || [];
73
- if (mediaType) {
74
- posts = posts.filter((post) => post.media_type === mediaType);
75
- }
77
+ // Filter by media type if specified
78
+ let posts = response.data || [];
79
+ if (mediaType) {
80
+ posts = posts.filter(post => post.media_type === mediaType);
81
+ }
76
82
 
77
- // Transform to common format
78
- const normalizedPosts: SocialPost[] = posts.map((post) => this.normalizePost(post));
83
+ // Transform to common format
84
+ const normalizedPosts: SocialPost[] = posts.map(post => this.normalizePost(post));
79
85
 
80
- // Get additional insights if requested and available
81
- if (includeMetrics && posts.length > 0) {
82
- await this.enrichPostsWithInsights(normalizedPosts);
83
- }
86
+ // Get additional insights if requested and available
87
+ if (includeMetrics && posts.length > 0) {
88
+ await this.enrichPostsWithInsights(normalizedPosts);
89
+ }
84
90
 
85
- // Store result in output params
86
- const outputParams = [...params.Params];
87
- outputParams.push({
88
- Name: 'ResultData',
89
- Type: 'Output',
90
- Value: JSON.stringify({
91
- posts: normalizedPosts,
92
- paging: {
93
- hasNext: !!response.paging?.next,
94
- hasPrevious: !!response.paging?.previous,
95
- afterCursor: response.paging?.cursors?.after,
96
- beforeCursor: response.paging?.cursors?.before,
97
- },
98
- summary: {
99
- totalPosts: normalizedPosts.length,
100
- mediaTypes: this.summarizeMediaTypes(posts),
101
- dateRange: this.getDateRange(normalizedPosts),
102
- },
103
- }),
104
- });
91
+ // Store result in output params
92
+ const outputParams = [...params.Params];
93
+ outputParams.push({
94
+ Name: 'ResultData',
95
+ Type: 'Output',
96
+ Value: JSON.stringify({
97
+ posts: normalizedPosts,
98
+ paging: {
99
+ hasNext: !!response.paging?.next,
100
+ hasPrevious: !!response.paging?.previous,
101
+ afterCursor: response.paging?.cursors?.after,
102
+ beforeCursor: response.paging?.cursors?.before
103
+ },
104
+ summary: {
105
+ totalPosts: normalizedPosts.length,
106
+ mediaTypes: this.summarizeMediaTypes(posts),
107
+ dateRange: this.getDateRange(normalizedPosts)
108
+ }
109
+ })
110
+ });
105
111
 
106
- return {
107
- Success: true,
108
- Message: `Retrieved ${normalizedPosts.length} Instagram posts`,
109
- ResultCode: 'SUCCESS',
110
- Params: outputParams,
111
- };
112
- } catch (error: any) {
113
- LogError('Failed to retrieve Instagram business posts', error);
112
+ return {
113
+ Success: true,
114
+ Message: `Retrieved ${normalizedPosts.length} Instagram posts`,
115
+ ResultCode: 'SUCCESS',
116
+ Params: outputParams
117
+ };
114
118
 
115
- if (error.code === 'RATE_LIMIT') {
116
- return {
117
- Success: false,
118
- Message: 'Instagram API rate limit exceeded. Please try again later.',
119
- ResultCode: 'RATE_LIMIT',
120
- };
121
- }
119
+ } catch (error: any) {
120
+ LogError('Failed to retrieve Instagram business posts', error);
121
+
122
+ if (error.code === 'RATE_LIMIT') {
123
+ return {
124
+ Success: false,
125
+ Message: 'Instagram API rate limit exceeded. Please try again later.',
126
+ ResultCode: 'RATE_LIMIT'
127
+ };
128
+ }
122
129
 
123
- if (error.code === 'INSUFFICIENT_PERMISSIONS') {
124
- return {
125
- Success: false,
126
- Message: 'Insufficient permissions to access Instagram business posts',
127
- ResultCode: 'INSUFFICIENT_PERMISSIONS',
128
- };
129
- }
130
+ if (error.code === 'INSUFFICIENT_PERMISSIONS') {
131
+ return {
132
+ Success: false,
133
+ Message: 'Insufficient permissions to access Instagram business posts',
134
+ ResultCode: 'INSUFFICIENT_PERMISSIONS'
135
+ };
136
+ }
130
137
 
131
- return {
132
- Success: false,
133
- Message: `Failed to retrieve Instagram posts: ${error.message}`,
134
- ResultCode: 'ERROR',
135
- };
138
+ return {
139
+ Success: false,
140
+ Message: `Failed to retrieve Instagram posts: ${error.message}`,
141
+ ResultCode: 'ERROR'
142
+ };
143
+ }
136
144
  }
137
- }
138
145
 
139
- /**
140
- * Enrich posts with additional insights data
141
- */
142
- private async enrichPostsWithInsights(posts: SocialPost[]): Promise<void> {
143
- // Instagram allows batch insights requests
144
- const postIds = posts.map((p) => p.id);
145
- const batchSize = 50; // Instagram's batch limit
146
+ /**
147
+ * Enrich posts with additional insights data
148
+ */
149
+ private async enrichPostsWithInsights(posts: SocialPost[]): Promise<void> {
150
+ // Instagram allows batch insights requests
151
+ const postIds = posts.map(p => p.id);
152
+ const batchSize = 50; // Instagram's batch limit
146
153
 
147
- for (let i = 0; i < postIds.length; i += batchSize) {
148
- const batch = postIds.slice(i, i + batchSize);
154
+ for (let i = 0; i < postIds.length; i += batchSize) {
155
+ const batch = postIds.slice(i, i + batchSize);
156
+
157
+ try {
158
+ // Get insights for this batch
159
+ const metrics = ['impressions', 'reach', 'engagement', 'saved', 'video_views'];
160
+ const insightsPromises = batch.map(postId =>
161
+ this.getInsights(postId, metrics, 'lifetime')
162
+ );
149
163
 
150
- try {
151
- // Get insights for this batch
152
- const metrics = ['impressions', 'reach', 'engagement', 'saved', 'video_views'];
153
- const insightsPromises = batch.map((postId) => this.getInsights(postId, metrics, 'lifetime'));
164
+ const insightsResults = await Promise.allSettled(insightsPromises);
154
165
 
155
- const insightsResults = await Promise.allSettled(insightsPromises);
156
-
157
- // Map insights back to posts
158
- insightsResults.forEach((result, index) => {
159
- if (result.status === 'fulfilled' && result.value) {
160
- const postIndex = i + index;
161
- const post = posts[postIndex];
166
+ // Map insights back to posts
167
+ insightsResults.forEach((result, index) => {
168
+ if (result.status === 'fulfilled' && result.value) {
169
+ const postIndex = i + index;
170
+ const post = posts[postIndex];
171
+
172
+ // Parse insights data
173
+ result.value.forEach((metric: any) => {
174
+ const value = metric.values?.[0]?.value || 0;
175
+
176
+ switch (metric.name) {
177
+ case 'impressions':
178
+ post.analytics!.impressions = value;
179
+ break;
180
+ case 'reach':
181
+ post.analytics!.reach = value;
182
+ break;
183
+ case 'engagement':
184
+ post.analytics!.engagements = value;
185
+ break;
186
+ case 'saved':
187
+ post.analytics!.saves = value;
188
+ break;
189
+ case 'video_views':
190
+ post.analytics!.videoViews = value;
191
+ break;
192
+ }
193
+ });
194
+ }
195
+ });
196
+ } catch (error) {
197
+ // Log but don't fail the whole operation
198
+ LogError(`Failed to get insights for batch starting at ${i}`, error);
199
+ }
200
+ }
201
+ }
162
202
 
163
- // Parse insights data
164
- result.value.forEach((metric: any) => {
165
- const value = metric.values?.[0]?.value || 0;
203
+ /**
204
+ * Summarize media types in the response
205
+ */
206
+ private summarizeMediaTypes(posts: any[]): Record<string, number> {
207
+ const summary: Record<string, number> = {
208
+ IMAGE: 0,
209
+ VIDEO: 0,
210
+ CAROUSEL_ALBUM: 0
211
+ };
166
212
 
167
- switch (metric.name) {
168
- case 'impressions':
169
- post.analytics!.impressions = value;
170
- break;
171
- case 'reach':
172
- post.analytics!.reach = value;
173
- break;
174
- case 'engagement':
175
- post.analytics!.engagements = value;
176
- break;
177
- case 'saved':
178
- post.analytics!.saves = value;
179
- break;
180
- case 'video_views':
181
- post.analytics!.videoViews = value;
182
- break;
183
- }
184
- });
185
- }
213
+ posts.forEach(post => {
214
+ if (summary[post.media_type] !== undefined) {
215
+ summary[post.media_type]++;
216
+ }
186
217
  });
187
- } catch (error) {
188
- // Log but don't fail the whole operation
189
- LogError(`Failed to get insights for batch starting at ${i}`, error);
190
- }
191
- }
192
- }
193
218
 
194
- /**
195
- * Summarize media types in the response
196
- */
197
- private summarizeMediaTypes(posts: any[]): Record<string, number> {
198
- const summary: Record<string, number> = {
199
- IMAGE: 0,
200
- VIDEO: 0,
201
- CAROUSEL_ALBUM: 0,
202
- };
203
-
204
- posts.forEach((post) => {
205
- if (summary[post.media_type] !== undefined) {
206
- summary[post.media_type]++;
207
- }
208
- });
219
+ return summary;
220
+ }
209
221
 
210
- return summary;
211
- }
222
+ /**
223
+ * Get date range of posts
224
+ */
225
+ private getDateRange(posts: SocialPost[]): { earliest: Date | null; latest: Date | null } {
226
+ if (posts.length === 0) {
227
+ return { earliest: null, latest: null };
228
+ }
212
229
 
213
- /**
214
- * Get date range of posts
215
- */
216
- private getDateRange(posts: SocialPost[]): { earliest: Date | null; latest: Date | null } {
217
- if (posts.length === 0) {
218
- return { earliest: null, latest: null };
230
+ const dates = posts.map(p => p.publishedAt.getTime());
231
+ return {
232
+ earliest: new Date(Math.min(...dates)),
233
+ latest: new Date(Math.max(...dates))
234
+ };
219
235
  }
220
236
 
221
- const dates = posts.map((p) => p.publishedAt.getTime());
222
- return {
223
- earliest: new Date(Math.min(...dates)),
224
- latest: new Date(Math.max(...dates)),
225
- };
226
- }
227
-
228
- /**
229
- * Define the parameters for this action
230
- */
231
- public get Params(): ActionParam[] {
232
- return [
233
- ...this.commonSocialParams,
234
- {
235
- Name: 'Limit',
236
- Type: 'Input',
237
- Value: 25,
238
- },
239
- {
240
- Name: 'MediaType',
241
- Type: 'Input',
242
- Value: null,
243
- },
244
- {
245
- Name: 'IncludeMetrics',
246
- Type: 'Input',
247
- Value: true,
248
- },
249
- {
250
- Name: 'AfterCursor',
251
- Type: 'Input',
252
- Value: null,
253
- },
254
- {
255
- Name: 'StartDate',
256
- Type: 'Input',
257
- Value: null,
258
- },
259
- {
260
- Name: 'EndDate',
261
- Type: 'Input',
262
- Value: null,
263
- },
264
- ];
265
- }
237
+ /**
238
+ * Define the parameters for this action
239
+ */
240
+ public get Params(): ActionParam[] {
241
+ return [
242
+ ...this.commonSocialParams,
243
+ {
244
+ Name: 'Limit',
245
+ Type: 'Input',
246
+ Value: 25
247
+ },
248
+ {
249
+ Name: 'MediaType',
250
+ Type: 'Input',
251
+ Value: null
252
+ },
253
+ {
254
+ Name: 'IncludeMetrics',
255
+ Type: 'Input',
256
+ Value: true
257
+ },
258
+ {
259
+ Name: 'AfterCursor',
260
+ Type: 'Input',
261
+ Value: null
262
+ },
263
+ {
264
+ Name: 'StartDate',
265
+ Type: 'Input',
266
+ Value: null
267
+ },
268
+ {
269
+ Name: 'EndDate',
270
+ Type: 'Input',
271
+ Value: null
272
+ }
273
+ ];
274
+ }
266
275
 
267
- /**
268
- * Get the description for this action
269
- */
270
- public get Description(): string {
271
- return 'Retrieves posts from an Instagram Business account with optional metrics and filtering.';
272
- }
273
- }
276
+ /**
277
+ * Get the description for this action
278
+ */
279
+ public get Description(): string {
280
+ return 'Retrieves posts from an Instagram Business account with optional metrics and filtering.';
281
+ }
282
+ }