@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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -6
- package/dist/base/base-social.action.d.ts.map +1 -1
- package/dist/base/base-social.action.js +18 -24
- 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 +35 -34
- 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 +34 -36
- 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 +25 -27
- 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 +19 -23
- 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 +28 -32
- 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 +42 -44
- 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 +37 -39
- 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 +44 -59
- 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 +33 -31
- 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 +28 -32
- 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 +24 -26
- 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 +32 -34
- 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 +43 -52
- 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 +30 -28
- 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 +18 -20
- 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 +27 -26
- 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 +38 -59
- 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 +23 -25
- 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 +56 -60
- 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 +25 -27
- 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 +55 -45
- 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 +31 -29
- 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 +25 -23
- 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 +32 -30
- 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 +28 -30
- 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 +33 -38
- 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 +25 -26
- 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 +25 -29
- 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 +40 -47
- 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 +30 -31
- 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 +56 -58
- 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 +58 -68
- 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 +22 -25
- package/dist/providers/youtube/youtube-base.action.js.map +1 -1
- package/package.json +5 -6
- package/src/base/base-social.action.ts +217 -224
- package/src/providers/buffer/buffer-base.action.ts +435 -441
- package/src/providers/facebook/actions/boost-post.action.ts +350 -386
- package/src/providers/facebook/actions/create-album.action.ts +291 -307
- package/src/providers/facebook/actions/create-post.action.ts +224 -227
- package/src/providers/facebook/actions/get-page-insights.action.ts +383 -403
- package/src/providers/facebook/actions/get-page-posts.action.ts +214 -225
- package/src/providers/facebook/actions/get-post-insights.action.ts +300 -316
- package/src/providers/facebook/actions/respond-to-comments.action.ts +319 -336
- package/src/providers/facebook/actions/schedule-post.action.ts +289 -292
- package/src/providers/facebook/actions/search-posts.action.ts +399 -413
- package/src/providers/facebook/facebook-base.action.ts +653 -670
- package/src/providers/hootsuite/actions/bulk-schedule-posts.action.ts +257 -257
- package/src/providers/hootsuite/actions/create-scheduled-post.action.ts +184 -189
- package/src/providers/hootsuite/actions/delete-scheduled-post.action.ts +160 -161
- package/src/providers/hootsuite/actions/get-analytics.action.ts +249 -254
- package/src/providers/hootsuite/actions/get-scheduled-posts.action.ts +206 -207
- package/src/providers/hootsuite/actions/get-social-profiles.action.ts +206 -205
- package/src/providers/hootsuite/actions/search-posts.action.ts +351 -369
- package/src/providers/hootsuite/actions/update-scheduled-post.action.ts +211 -209
- package/src/providers/hootsuite/hootsuite-base.action.ts +301 -307
- package/src/providers/instagram/actions/create-post.action.ts +276 -296
- package/src/providers/instagram/actions/create-story.action.ts +378 -394
- package/src/providers/instagram/actions/get-account-insights.action.ts +384 -420
- package/src/providers/instagram/actions/get-business-posts.action.ts +233 -242
- package/src/providers/instagram/actions/get-comments.action.ts +365 -377
- package/src/providers/instagram/actions/get-post-insights.action.ts +265 -273
- package/src/providers/instagram/actions/schedule-post.action.ts +233 -235
- package/src/providers/instagram/actions/search-posts.action.ts +512 -538
- package/src/providers/instagram/instagram-base.action.ts +368 -393
- package/src/providers/linkedin/actions/create-article.action.ts +275 -266
- package/src/providers/linkedin/actions/create-post.action.ts +179 -177
- package/src/providers/linkedin/actions/get-followers.action.ts +211 -211
- package/src/providers/linkedin/actions/get-organization-posts.action.ts +146 -147
- package/src/providers/linkedin/actions/get-personal-posts.action.ts +138 -139
- package/src/providers/linkedin/actions/get-post-analytics.action.ts +190 -189
- package/src/providers/linkedin/actions/schedule-post.action.ts +191 -189
- package/src/providers/linkedin/actions/search-posts.action.ts +275 -283
- package/src/providers/linkedin/linkedin-base.action.ts +407 -421
- package/src/providers/tiktok/tiktok-base.action.ts +305 -320
- package/src/providers/twitter/actions/create-thread.action.ts +203 -207
- package/src/providers/twitter/actions/create-tweet.action.ts +187 -188
- package/src/providers/twitter/actions/delete-tweet.action.ts +128 -129
- package/src/providers/twitter/actions/get-analytics.action.ts +402 -411
- package/src/providers/twitter/actions/get-mentions.action.ts +218 -219
- package/src/providers/twitter/actions/get-timeline.action.ts +232 -233
- package/src/providers/twitter/actions/schedule-tweet.action.ts +221 -222
- package/src/providers/twitter/actions/search-tweets.action.ts +540 -543
- package/src/providers/twitter/twitter-base.action.ts +541 -560
- package/src/providers/youtube/youtube-base.action.ts +320 -333
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RegisterClass } from '@memberjunction/global';
|
|
2
2
|
import { LinkedInBaseAction, LinkedInShareData } from '../linkedin-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
|
-
import { LogStatus, LogError } from '@memberjunction/
|
|
4
|
+
import { LogStatus, LogError } from '@memberjunction/global';
|
|
5
5
|
import { MediaFile } from '../../../base/base-social.action';
|
|
6
6
|
import { BaseAction } from '@memberjunction/actions';
|
|
7
7
|
|
|
@@ -10,182 +10,184 @@ import { BaseAction } from '@memberjunction/actions';
|
|
|
10
10
|
*/
|
|
11
11
|
@RegisterClass(BaseAction, 'LinkedInCreatePostAction')
|
|
12
12
|
export class LinkedInCreatePostAction extends LinkedInBaseAction {
|
|
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
|
-
} else {
|
|
54
|
-
// Personal post
|
|
55
|
-
authorUrn = await this.getCurrentUserUrn();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Upload media if provided
|
|
59
|
-
let mediaUrns: string[] = [];
|
|
60
|
-
if (mediaFiles && Array.isArray(mediaFiles)) {
|
|
61
|
-
LogStatus(`Uploading ${mediaFiles.length} media files...`);
|
|
62
|
-
mediaUrns = await this.uploadMedia(mediaFiles as MediaFile[]);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Build share data
|
|
66
|
-
const shareData: LinkedInShareData = {
|
|
67
|
-
author: authorUrn,
|
|
68
|
-
lifecycleState: 'PUBLISHED',
|
|
69
|
-
specificContent: {
|
|
70
|
-
'com.linkedin.ugc.ShareContent': {
|
|
71
|
-
shareCommentary: {
|
|
72
|
-
text: content
|
|
73
|
-
},
|
|
74
|
-
shareMediaCategory: mediaUrns.length > 0 ? 'IMAGE' : 'NONE',
|
|
75
|
-
media: mediaUrns.length > 0 ? mediaUrns.map(urn => ({
|
|
76
|
-
status: 'READY' as const,
|
|
77
|
-
media: urn
|
|
78
|
-
})) : undefined
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
visibility: {
|
|
82
|
-
'com.linkedin.ugc.MemberNetworkVisibility': visibility as any
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Add distribution settings if public
|
|
87
|
-
if (visibility === 'PUBLIC') {
|
|
88
|
-
shareData.distribution = {
|
|
89
|
-
linkedInDistributionTarget: {
|
|
90
|
-
visibleToGuest: visibleToGuest
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Create the post
|
|
96
|
-
LogStatus('Creating LinkedIn post...');
|
|
97
|
-
const postId = await this.createShare(shareData);
|
|
98
|
-
|
|
99
|
-
// Get the created post details
|
|
100
|
-
const shares = await this.getShares(authorUrn, 1);
|
|
101
|
-
const createdPost = shares.find(s => s.id === postId);
|
|
102
|
-
|
|
103
|
-
if (!createdPost) {
|
|
104
|
-
throw new Error('Failed to retrieve created post');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Normalize the created post
|
|
108
|
-
const normalizedPost = this.normalizePost(createdPost);
|
|
109
|
-
|
|
110
|
-
// Update output parameters
|
|
111
|
-
const outputParams = [...Params];
|
|
112
|
-
const postParam = outputParams.find(p => p.Name === 'CreatedPost');
|
|
113
|
-
if (postParam) postParam.Value = normalizedPost;
|
|
114
|
-
const postIdParam = outputParams.find(p => p.Name === 'PostID');
|
|
115
|
-
if (postIdParam) postIdParam.Value = postId;
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
Success: true,
|
|
119
|
-
ResultCode: 'SUCCESS',
|
|
120
|
-
Message: `Successfully created LinkedIn post (ID: ${postId})`,
|
|
121
|
-
Params: outputParams
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
} catch (error) {
|
|
125
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
Success: false,
|
|
129
|
-
ResultCode: 'ERROR',
|
|
130
|
-
Message: `Failed to create LinkedIn post: ${errorMessage}`,
|
|
131
|
-
Params
|
|
132
|
-
};
|
|
13
|
+
/**
|
|
14
|
+
* Create a post on LinkedIn (personal or organization)
|
|
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 content = this.getParamValue(Params, 'Content');
|
|
28
|
+
const authorType = this.getParamValue(Params, 'AuthorType') || 'personal'; // 'personal' or 'organization'
|
|
29
|
+
const organizationId = this.getParamValue(Params, 'OrganizationID');
|
|
30
|
+
const mediaFiles = this.getParamValue(Params, 'MediaFiles');
|
|
31
|
+
const visibility = this.getParamValue(Params, 'Visibility') || 'PUBLIC';
|
|
32
|
+
const visibleToGuest = this.getParamValue(Params, 'VisibleToGuest') !== false; // Default true
|
|
33
|
+
|
|
34
|
+
// Validate required parameters
|
|
35
|
+
if (!content) {
|
|
36
|
+
throw new Error('Content is required');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Determine author URN
|
|
40
|
+
let authorUrn: string;
|
|
41
|
+
if (authorType === 'organization') {
|
|
42
|
+
if (!organizationId) {
|
|
43
|
+
// Get first admin organization if not specified
|
|
44
|
+
const orgs = await this.getAdminOrganizations();
|
|
45
|
+
if (orgs.length === 0) {
|
|
46
|
+
throw new Error('No organizations found. Please specify OrganizationID.');
|
|
47
|
+
}
|
|
48
|
+
authorUrn = orgs[0].urn;
|
|
49
|
+
LogStatus(`Using organization: ${orgs[0].name}`);
|
|
50
|
+
} else {
|
|
51
|
+
authorUrn = `urn:li:organization:${organizationId}`;
|
|
133
52
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
Type: 'Input',
|
|
155
|
-
Value: null
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
Name: 'MediaFiles',
|
|
159
|
-
Type: 'Input',
|
|
160
|
-
Value: null
|
|
53
|
+
} else {
|
|
54
|
+
// Personal post
|
|
55
|
+
authorUrn = await this.getCurrentUserUrn();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Upload media if provided
|
|
59
|
+
let mediaUrns: string[] = [];
|
|
60
|
+
if (mediaFiles && Array.isArray(mediaFiles)) {
|
|
61
|
+
LogStatus(`Uploading ${mediaFiles.length} media files...`);
|
|
62
|
+
mediaUrns = await this.uploadMedia(mediaFiles as MediaFile[]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Build share data
|
|
66
|
+
const shareData: LinkedInShareData = {
|
|
67
|
+
author: authorUrn,
|
|
68
|
+
lifecycleState: 'PUBLISHED',
|
|
69
|
+
specificContent: {
|
|
70
|
+
'com.linkedin.ugc.ShareContent': {
|
|
71
|
+
shareCommentary: {
|
|
72
|
+
text: content,
|
|
161
73
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
74
|
+
shareMediaCategory: mediaUrns.length > 0 ? 'IMAGE' : 'NONE',
|
|
75
|
+
media:
|
|
76
|
+
mediaUrns.length > 0
|
|
77
|
+
? mediaUrns.map((urn) => ({
|
|
78
|
+
status: 'READY' as const,
|
|
79
|
+
media: urn,
|
|
80
|
+
}))
|
|
81
|
+
: undefined,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
visibility: {
|
|
85
|
+
'com.linkedin.ugc.MemberNetworkVisibility': visibility as any,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Add distribution settings if public
|
|
90
|
+
if (visibility === 'PUBLIC') {
|
|
91
|
+
shareData.distribution = {
|
|
92
|
+
linkedInDistributionTarget: {
|
|
93
|
+
visibleToGuest: visibleToGuest,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Create the post
|
|
99
|
+
LogStatus('Creating LinkedIn post...');
|
|
100
|
+
const postId = await this.createShare(shareData);
|
|
101
|
+
|
|
102
|
+
// Get the created post details
|
|
103
|
+
const shares = await this.getShares(authorUrn, 1);
|
|
104
|
+
const createdPost = shares.find((s) => s.id === postId);
|
|
105
|
+
|
|
106
|
+
if (!createdPost) {
|
|
107
|
+
throw new Error('Failed to retrieve created post');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Normalize the created post
|
|
111
|
+
const normalizedPost = this.normalizePost(createdPost);
|
|
112
|
+
|
|
113
|
+
// Update output parameters
|
|
114
|
+
const outputParams = [...Params];
|
|
115
|
+
const postParam = outputParams.find((p) => p.Name === 'CreatedPost');
|
|
116
|
+
if (postParam) postParam.Value = normalizedPost;
|
|
117
|
+
const postIdParam = outputParams.find((p) => p.Name === 'PostID');
|
|
118
|
+
if (postIdParam) postIdParam.Value = postId;
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
Success: true,
|
|
122
|
+
ResultCode: 'SUCCESS',
|
|
123
|
+
Message: `Successfully created LinkedIn post (ID: ${postId})`,
|
|
124
|
+
Params: outputParams,
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
Success: false,
|
|
131
|
+
ResultCode: 'ERROR',
|
|
132
|
+
Message: `Failed to create LinkedIn post: ${errorMessage}`,
|
|
133
|
+
Params,
|
|
134
|
+
};
|
|
190
135
|
}
|
|
191
|
-
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Define the parameters this action expects
|
|
140
|
+
*/
|
|
141
|
+
public get Params(): ActionParam[] {
|
|
142
|
+
return [
|
|
143
|
+
...this.commonSocialParams,
|
|
144
|
+
{
|
|
145
|
+
Name: 'Content',
|
|
146
|
+
Type: 'Input',
|
|
147
|
+
Value: null,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
Name: 'AuthorType',
|
|
151
|
+
Type: 'Input',
|
|
152
|
+
Value: 'personal', // 'personal' or 'organization'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
Name: 'OrganizationID',
|
|
156
|
+
Type: 'Input',
|
|
157
|
+
Value: null,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
Name: 'MediaFiles',
|
|
161
|
+
Type: 'Input',
|
|
162
|
+
Value: null,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
Name: 'Visibility',
|
|
166
|
+
Type: 'Input',
|
|
167
|
+
Value: 'PUBLIC', // 'PUBLIC', 'CONNECTIONS', 'LOGGED_IN', 'CONTAINER'
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
Name: 'VisibleToGuest',
|
|
171
|
+
Type: 'Input',
|
|
172
|
+
Value: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
Name: 'CreatedPost',
|
|
176
|
+
Type: 'Output',
|
|
177
|
+
Value: null,
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
Name: 'PostID',
|
|
181
|
+
Type: 'Output',
|
|
182
|
+
Value: null,
|
|
183
|
+
},
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get action description
|
|
189
|
+
*/
|
|
190
|
+
public get Description(): string {
|
|
191
|
+
return 'Creates a post on LinkedIn for personal profiles or organization pages with optional media attachments';
|
|
192
|
+
}
|
|
193
|
+
}
|