@memberjunction/actions-bizapps-social 2.111.0 → 2.112.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 (204) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +6 -6
  3. package/dist/base/base-social.action.d.ts.map +1 -1
  4. package/dist/base/base-social.action.js +18 -24
  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 +35 -34
  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 +34 -36
  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 +25 -27
  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 +19 -23
  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 +28 -32
  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 +42 -44
  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 +37 -39
  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 +44 -59
  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 +33 -31
  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 +28 -32
  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 +24 -26
  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 +32 -34
  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 +43 -52
  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 +30 -28
  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 +18 -20
  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 +27 -26
  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 +38 -59
  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 +23 -25
  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 +56 -60
  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 +25 -27
  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 +55 -45
  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 +31 -29
  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 +25 -23
  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 +32 -30
  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 +28 -30
  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 +33 -38
  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 +25 -26
  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 +25 -29
  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 +40 -47
  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 +30 -31
  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 +56 -58
  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 +58 -68
  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 +22 -25
  153. package/dist/providers/youtube/youtube-base.action.js.map +1 -1
  154. package/package.json +5 -6
  155. package/src/base/base-social.action.ts +217 -224
  156. package/src/providers/buffer/buffer-base.action.ts +435 -441
  157. package/src/providers/facebook/actions/boost-post.action.ts +350 -386
  158. package/src/providers/facebook/actions/create-album.action.ts +291 -307
  159. package/src/providers/facebook/actions/create-post.action.ts +224 -227
  160. package/src/providers/facebook/actions/get-page-insights.action.ts +383 -403
  161. package/src/providers/facebook/actions/get-page-posts.action.ts +214 -225
  162. package/src/providers/facebook/actions/get-post-insights.action.ts +300 -316
  163. package/src/providers/facebook/actions/respond-to-comments.action.ts +319 -336
  164. package/src/providers/facebook/actions/schedule-post.action.ts +289 -292
  165. package/src/providers/facebook/actions/search-posts.action.ts +399 -413
  166. package/src/providers/facebook/facebook-base.action.ts +653 -670
  167. package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
  168. package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +184 -189
  169. package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +160 -161
  170. package/src/providers/hootsuite/actions/get-analytics.action.ts +249 -254
  171. package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +206 -207
  172. package/src/providers/hootsuite/actions/get-social-profiles.action.ts +206 -205
  173. package/src/providers/hootsuite/actions/search-posts.action.ts +351 -369
  174. package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +211 -209
  175. package/src/providers/hootsuite/hootsuite-base.action.ts +301 -307
  176. package/src/providers/instagram/actions/create-post.action.ts +276 -296
  177. package/src/providers/instagram/actions/create-story.action.ts +378 -394
  178. package/src/providers/instagram/actions/get-account-insights.action.ts +384 -420
  179. package/src/providers/instagram/actions/get-business-posts.action.ts +233 -242
  180. package/src/providers/instagram/actions/get-comments.action.ts +365 -377
  181. package/src/providers/instagram/actions/get-post-insights.action.ts +265 -273
  182. package/src/providers/instagram/actions/schedule-post.action.ts +233 -235
  183. package/src/providers/instagram/actions/search-posts.action.ts +512 -538
  184. package/src/providers/instagram/instagram-base.action.ts +368 -393
  185. package/src/providers/linkedin/actions/create-article.action.ts +275 -266
  186. package/src/providers/linkedin/actions/create-post.action.ts +179 -177
  187. package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
  188. package/src/providers/linkedin/actions/get-organization-posts.action.ts +146 -147
  189. package/src/providers/linkedin/actions/get-personal-posts.action.ts +138 -139
  190. package/src/providers/linkedin/actions/get-post-analytics.action.ts +190 -189
  191. package/src/providers/linkedin/actions/schedule-post.action.ts +191 -189
  192. package/src/providers/linkedin/actions/search-posts.action.ts +275 -283
  193. package/src/providers/linkedin/linkedin-base.action.ts +407 -421
  194. package/src/providers/tiktok/tiktok-base.action.ts +305 -320
  195. package/src/providers/twitter/actions/create-thread.action.ts +203 -207
  196. package/src/providers/twitter/actions/create-tweet.action.ts +187 -188
  197. package/src/providers/twitter/actions/delete-tweet.action.ts +128 -129
  198. package/src/providers/twitter/actions/get-analytics.action.ts +402 -411
  199. package/src/providers/twitter/actions/get-mentions.action.ts +218 -219
  200. package/src/providers/twitter/actions/get-timeline.action.ts +232 -233
  201. package/src/providers/twitter/actions/schedule-tweet.action.ts +221 -222
  202. package/src/providers/twitter/actions/search-tweets.action.ts +540 -543
  203. package/src/providers/twitter/twitter-base.action.ts +541 -560
  204. package/src/providers/youtube/youtube-base.action.ts +320 -333
@@ -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/core';
4
+ import { LogError } from '@memberjunction/global';
5
5
  import { SocialPost } from '../../../base/base-social.action';
6
6
  import { BaseAction } from '@memberjunction/actions';
7
7
 
@@ -11,272 +11,263 @@ import { BaseAction } from '@memberjunction/actions';
11
11
  */
12
12
  @RegisterClass(BaseAction, 'Instagram - Get Business Posts')
13
13
  export class InstagramGetBusinessPostsAction extends InstagramBaseAction {
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');
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');
24
23
 
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
- }
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
+ }
33
32
 
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
- }
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
+ }
39
38
 
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
- };
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
+ };
46
45
 
47
- if (afterCursor) {
48
- queryParams.after = afterCursor;
49
- }
46
+ if (afterCursor) {
47
+ queryParams.after = afterCursor;
48
+ }
50
49
 
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
- }
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
+ }
58
57
 
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
- );
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);
76
70
 
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
- }
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
+ }
82
76
 
83
- // Transform to common format
84
- const normalizedPosts: SocialPost[] = posts.map(post => this.normalizePost(post));
77
+ // Transform to common format
78
+ const normalizedPosts: SocialPost[] = posts.map((post) => this.normalizePost(post));
85
79
 
86
- // Get additional insights if requested and available
87
- if (includeMetrics && posts.length > 0) {
88
- await this.enrichPostsWithInsights(normalizedPosts);
89
- }
80
+ // Get additional insights if requested and available
81
+ if (includeMetrics && posts.length > 0) {
82
+ await this.enrichPostsWithInsights(normalizedPosts);
83
+ }
90
84
 
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
- });
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
+ });
111
105
 
112
- return {
113
- Success: true,
114
- Message: `Retrieved ${normalizedPosts.length} Instagram posts`,
115
- ResultCode: 'SUCCESS',
116
- Params: outputParams
117
- };
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);
118
114
 
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
- }
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
+ }
129
122
 
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
- }
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
+ }
137
130
 
138
- return {
139
- Success: false,
140
- Message: `Failed to retrieve Instagram posts: ${error.message}`,
141
- ResultCode: 'ERROR'
142
- };
143
- }
131
+ return {
132
+ Success: false,
133
+ Message: `Failed to retrieve Instagram posts: ${error.message}`,
134
+ ResultCode: 'ERROR',
135
+ };
144
136
  }
137
+ }
145
138
 
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
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
153
146
 
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
- );
147
+ for (let i = 0; i < postIds.length; i += batchSize) {
148
+ const batch = postIds.slice(i, i + batchSize);
163
149
 
164
- const insightsResults = await Promise.allSettled(insightsPromises);
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'));
165
154
 
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
- }
155
+ const insightsResults = await Promise.allSettled(insightsPromises);
202
156
 
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
- };
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];
212
162
 
213
- posts.forEach(post => {
214
- if (summary[post.media_type] !== undefined) {
215
- summary[post.media_type]++;
216
- }
217
- });
163
+ // Parse insights data
164
+ result.value.forEach((metric: any) => {
165
+ const value = metric.values?.[0]?.value || 0;
218
166
 
219
- return summary;
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
+ }
186
+ });
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
+ }
220
191
  }
192
+ }
221
193
 
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
- }
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
+ };
229
203
 
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
- };
235
- }
204
+ posts.forEach((post) => {
205
+ if (summary[post.media_type] !== undefined) {
206
+ summary[post.media_type]++;
207
+ }
208
+ });
236
209
 
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
- }
210
+ return summary;
211
+ }
275
212
 
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.';
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 };
281
219
  }
282
- }
220
+
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
+ }
266
+
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
+ }