@posty5/social-publisher-post 3.0.0 → 4.0.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/README.md +986 -957
- package/dist/index.d.mts +232 -52
- package/dist/index.d.ts +232 -52
- package/dist/index.js +58 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +61 -61
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,16 @@ type SocialPublisherPostType = "shortVideo";
|
|
|
5
5
|
type SocialPublisherPostAccountType = "youtube" | "facebook" | "instagram" | "tiktok";
|
|
6
6
|
type SocialPublisherPostScheduleType = "now" | "schedule";
|
|
7
7
|
type SocialPublisherPostSourceType = "video-file" | "video-url" | "facebook-video" | "youtube-video" | "tiktok-video";
|
|
8
|
+
/**
|
|
9
|
+
* Status of the optional post-publish comment, reported per-platform.
|
|
10
|
+
* - `pending`: queued, waiting for the parent post to be published
|
|
11
|
+
* - `processing`: comment request is in flight
|
|
12
|
+
* - `done`: comment posted successfully
|
|
13
|
+
* - `error`: comment failed (see `currentError`)
|
|
14
|
+
* - `skipped`: caller opted out for this platform (e.g. postToFacebook=false)
|
|
15
|
+
* - `notSupported`: platform does not allow programmatic comments (TikTok)
|
|
16
|
+
*/
|
|
17
|
+
type CommentStatusType = "pending" | "processing" | "done" | "error" | "skipped" | "notSupported";
|
|
8
18
|
type SocialPublisherAccountPlatformType = "youtube" | "facebook" | "tiktok";
|
|
9
19
|
type SocialPublisherAccountAccountType = "facebook" | "instagram" | "youtube" | "tiktok";
|
|
10
20
|
type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
|
|
@@ -39,14 +49,91 @@ interface IScheduleConfig {
|
|
|
39
49
|
type: SocialPublisherPostScheduleType;
|
|
40
50
|
scheduledAt?: Date;
|
|
41
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Image-post source — uploaded to our bucket or fetched from a public URL.
|
|
54
|
+
*/
|
|
55
|
+
type ImageSourceType = "image-file" | "image-url";
|
|
56
|
+
/**
|
|
57
|
+
* Image-post media block. One of `bucketKey` (uploaded) or `externalUrl`
|
|
58
|
+
* (image-url) must be provided, matching the `source` discriminator.
|
|
59
|
+
*/
|
|
60
|
+
interface IImageMediaRequest {
|
|
61
|
+
source: ImageSourceType;
|
|
62
|
+
/** Bucket file URL returned by `generate-upload-urls` (when source = image-file). */
|
|
63
|
+
bucketKey?: string;
|
|
64
|
+
/** Direct public image URL (when source = image-url). */
|
|
65
|
+
externalUrl?: string;
|
|
66
|
+
/** Optional metadata — server uses for soft validation. */
|
|
67
|
+
width?: number;
|
|
68
|
+
height?: number;
|
|
69
|
+
/** e.g. "image/jpeg", "image/png", "image/webp". */
|
|
70
|
+
mimeType?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Image-post create request (workspace target).
|
|
74
|
+
* Image posts cost **5 credits** + 1 for an optional auto-comment.
|
|
75
|
+
* YouTube community posts are always reported as `notSupported`.
|
|
76
|
+
*/
|
|
77
|
+
interface ICreateImagePostToWorkspaceRequest {
|
|
78
|
+
/** Workspace ID. */
|
|
79
|
+
workspaceId: string;
|
|
80
|
+
image: IImageMediaRequest;
|
|
81
|
+
/** Shared caption used as the default per-platform description if no
|
|
82
|
+
* platform-specific block is supplied. 1..8000 chars. */
|
|
83
|
+
caption: string;
|
|
84
|
+
/** Marks the caption as AI-enhanced; surfaces on the status page. */
|
|
85
|
+
aiEnhanced?: boolean;
|
|
86
|
+
youtube?: IYouTubeConfig;
|
|
87
|
+
tiktok?: ITikTokConfig;
|
|
88
|
+
facebook?: IFacebookPageConfig;
|
|
89
|
+
instagram?: IInstagramConfig;
|
|
90
|
+
schedule?: IScheduleConfig;
|
|
91
|
+
comment?: ICommentRequest;
|
|
92
|
+
tag?: string;
|
|
93
|
+
refId?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Image-post create request (single-account target).
|
|
97
|
+
*/
|
|
98
|
+
interface ICreateImagePostToAccountRequest {
|
|
99
|
+
/** Account ID. */
|
|
100
|
+
accountId: string;
|
|
101
|
+
image: IImageMediaRequest;
|
|
102
|
+
caption: string;
|
|
103
|
+
aiEnhanced?: boolean;
|
|
104
|
+
youtube?: IYouTubeConfig;
|
|
105
|
+
tiktok?: ITikTokConfig;
|
|
106
|
+
facebook?: IFacebookPageConfig;
|
|
107
|
+
instagram?: IInstagramConfig;
|
|
108
|
+
schedule?: IScheduleConfig;
|
|
109
|
+
comment?: ICommentRequest;
|
|
110
|
+
tag?: string;
|
|
111
|
+
refId?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Optional post-publish comment.
|
|
115
|
+
* Adds a comment under each platform post once it is published.
|
|
116
|
+
*
|
|
117
|
+
* Pricing: +1 credit on top of the video charge (Pro plan).
|
|
118
|
+
* TikTok comments are not supported by the platform and will always
|
|
119
|
+
* be reported as `notSupported` in the status response.
|
|
120
|
+
*/
|
|
121
|
+
interface ICommentRequest {
|
|
122
|
+
/** Comment text (1..2200 characters). */
|
|
123
|
+
text: string;
|
|
124
|
+
/** Post the comment on Facebook (default: true). */
|
|
125
|
+
postToFacebook?: boolean;
|
|
126
|
+
/** Post the comment on Instagram (default: true). */
|
|
127
|
+
postToInstagram?: boolean;
|
|
128
|
+
/** Post the comment on YouTube (default: true). */
|
|
129
|
+
postToYoutube?: boolean;
|
|
130
|
+
/** Post the comment on TikTok (default: false — not supported by TikTok). */
|
|
131
|
+
postToTiktok?: boolean;
|
|
132
|
+
}
|
|
42
133
|
interface ICreateSocialPublisherPostRequest {
|
|
43
134
|
/** Workspace ID */
|
|
44
135
|
workspaceId: string;
|
|
45
136
|
source: SocialPublisherPostSourceType;
|
|
46
|
-
isAllowYouTube: boolean;
|
|
47
|
-
isAllowTiktok: boolean;
|
|
48
|
-
isAllowFacebookPage: boolean;
|
|
49
|
-
isAllowInstagram: boolean;
|
|
50
137
|
youtube?: IYouTubeConfig;
|
|
51
138
|
tiktok?: ITikTokConfig;
|
|
52
139
|
facebook?: IFacebookPageConfig;
|
|
@@ -55,6 +142,12 @@ interface ICreateSocialPublisherPostRequest {
|
|
|
55
142
|
thumbURL?: string;
|
|
56
143
|
postURL?: string;
|
|
57
144
|
schedule?: IScheduleConfig;
|
|
145
|
+
/**
|
|
146
|
+
* Optional post-publish comment (Pro plan, +1 credit).
|
|
147
|
+
* Once the video is published, a comment is added under each enabled
|
|
148
|
+
* platform post. TikTok is not supported.
|
|
149
|
+
*/
|
|
150
|
+
comment?: ICommentRequest;
|
|
58
151
|
/**
|
|
59
152
|
* Tag (optional)
|
|
60
153
|
* Use this field to filter posts by tag.
|
|
@@ -72,10 +165,6 @@ interface ICreateSocialPublisherAccountPostRequest {
|
|
|
72
165
|
/** Account ID */
|
|
73
166
|
accountId: string;
|
|
74
167
|
source: SocialPublisherPostSourceType;
|
|
75
|
-
isAllowYouTube: boolean;
|
|
76
|
-
isAllowTiktok: boolean;
|
|
77
|
-
isAllowFacebookPage: boolean;
|
|
78
|
-
isAllowInstagram: boolean;
|
|
79
168
|
youtube?: IYouTubeConfig;
|
|
80
169
|
tiktok?: ITikTokConfig;
|
|
81
170
|
facebook?: IFacebookPageConfig;
|
|
@@ -84,6 +173,12 @@ interface ICreateSocialPublisherAccountPostRequest {
|
|
|
84
173
|
thumbURL?: string;
|
|
85
174
|
postURL?: string;
|
|
86
175
|
schedule?: IScheduleConfig;
|
|
176
|
+
/**
|
|
177
|
+
* Optional post-publish comment (Pro plan, +1 credit).
|
|
178
|
+
* Once the video is published, a comment is added under each enabled
|
|
179
|
+
* platform post. TikTok is not supported.
|
|
180
|
+
*/
|
|
181
|
+
comment?: ICommentRequest;
|
|
87
182
|
/**
|
|
88
183
|
* Tag (optional)
|
|
89
184
|
* Use this field to filter posts by tag.
|
|
@@ -100,30 +195,34 @@ interface ICreateSocialPublisherAccountPostRequest {
|
|
|
100
195
|
interface IPostSetting {
|
|
101
196
|
/** Workspace ID */
|
|
102
197
|
workspaceId: string;
|
|
103
|
-
isAllowYouTube: boolean;
|
|
104
|
-
isAllowTiktok: boolean;
|
|
105
|
-
isAllowFacebookPage: boolean;
|
|
106
|
-
isAllowInstagram: boolean;
|
|
107
198
|
youtube?: IYouTubeConfig;
|
|
108
199
|
tiktok?: ITikTokConfig;
|
|
109
200
|
facebook?: IFacebookPageConfig;
|
|
110
201
|
instagram?: IInstagramConfig;
|
|
111
202
|
schedule?: IScheduleConfig;
|
|
112
203
|
source: SocialPublisherPostSourceType;
|
|
204
|
+
/** Optional post-publish comment (Pro plan, +1 credit). TikTok is not supported. */
|
|
205
|
+
comment?: ICommentRequest;
|
|
206
|
+
/** Optional caller-supplied tag, persisted on the created post for filtering. */
|
|
207
|
+
tag?: string;
|
|
208
|
+
/** Optional caller-supplied reference ID, persisted on the created post for filtering. */
|
|
209
|
+
refId?: string;
|
|
113
210
|
}
|
|
114
211
|
interface IAccountPostSetting {
|
|
115
212
|
/** Account ID */
|
|
116
213
|
accountId: string;
|
|
117
|
-
isAllowYouTube: boolean;
|
|
118
|
-
isAllowTiktok: boolean;
|
|
119
|
-
isAllowFacebookPage: boolean;
|
|
120
|
-
isAllowInstagram: boolean;
|
|
121
214
|
youtube?: IYouTubeConfig;
|
|
122
215
|
tiktok?: ITikTokConfig;
|
|
123
216
|
facebook?: IFacebookPageConfig;
|
|
124
217
|
instagram?: IInstagramConfig;
|
|
125
218
|
schedule?: IScheduleConfig;
|
|
126
219
|
source: SocialPublisherPostSourceType;
|
|
220
|
+
/** Optional post-publish comment (Pro plan, +1 credit). TikTok is not supported. */
|
|
221
|
+
comment?: ICommentRequest;
|
|
222
|
+
/** Optional caller-supplied tag, persisted on the created post for filtering. */
|
|
223
|
+
tag?: string;
|
|
224
|
+
/** Optional caller-supplied reference ID, persisted on the created post for filtering. */
|
|
225
|
+
refId?: string;
|
|
127
226
|
}
|
|
128
227
|
interface IGenerateUploadUrlsRequest {
|
|
129
228
|
thumbFileType?: string;
|
|
@@ -156,28 +255,23 @@ interface IPublishOptions {
|
|
|
156
255
|
*/
|
|
157
256
|
thumbnail?: File | string;
|
|
158
257
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*/
|
|
162
|
-
platforms: Array<"youtube" | "tiktok" | "facebook" | "instagram">;
|
|
163
|
-
/**
|
|
164
|
-
* YouTube-specific configuration
|
|
165
|
-
* Required if 'youtube' is in platforms array
|
|
258
|
+
* YouTube-specific configuration.
|
|
259
|
+
* Required if the workspace has a YouTube account connected.
|
|
166
260
|
*/
|
|
167
261
|
youtube?: IYouTubeConfig;
|
|
168
262
|
/**
|
|
169
|
-
* TikTok-specific configuration
|
|
170
|
-
* Required if
|
|
263
|
+
* TikTok-specific configuration.
|
|
264
|
+
* Required if the workspace has a TikTok account connected.
|
|
171
265
|
*/
|
|
172
266
|
tiktok?: ITikTokConfig;
|
|
173
267
|
/**
|
|
174
|
-
* Facebook Page-specific configuration
|
|
175
|
-
* Required if
|
|
268
|
+
* Facebook Page-specific configuration.
|
|
269
|
+
* Required if the workspace has a Facebook Page connected.
|
|
176
270
|
*/
|
|
177
271
|
facebook?: IFacebookPageConfig;
|
|
178
272
|
/**
|
|
179
|
-
* Instagram-specific configuration
|
|
180
|
-
* Required if
|
|
273
|
+
* Instagram-specific configuration.
|
|
274
|
+
* Required if the workspace has an Instagram account connected.
|
|
181
275
|
*/
|
|
182
276
|
instagram?: IInstagramConfig;
|
|
183
277
|
/**
|
|
@@ -194,6 +288,11 @@ interface IPublishOptions {
|
|
|
194
288
|
* Optional reference ID for external systems
|
|
195
289
|
*/
|
|
196
290
|
refId?: string;
|
|
291
|
+
/**
|
|
292
|
+
* Optional post-publish comment (Pro plan, +1 credit).
|
|
293
|
+
* TikTok comments are not supported.
|
|
294
|
+
*/
|
|
295
|
+
comment?: ICommentRequest;
|
|
197
296
|
}
|
|
198
297
|
/**
|
|
199
298
|
* Options for publishing to an account
|
|
@@ -221,28 +320,23 @@ interface IPublishToAccountOptions {
|
|
|
221
320
|
*/
|
|
222
321
|
thumbnail?: File | string;
|
|
223
322
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*/
|
|
227
|
-
platforms: Array<"youtube" | "tiktok" | "facebook" | "instagram">;
|
|
228
|
-
/**
|
|
229
|
-
* YouTube-specific configuration
|
|
230
|
-
* Required if 'youtube' is in platforms array
|
|
323
|
+
* YouTube-specific configuration.
|
|
324
|
+
* Required if the workspace has a YouTube account connected.
|
|
231
325
|
*/
|
|
232
326
|
youtube?: IYouTubeConfig;
|
|
233
327
|
/**
|
|
234
|
-
* TikTok-specific configuration
|
|
235
|
-
* Required if
|
|
328
|
+
* TikTok-specific configuration.
|
|
329
|
+
* Required if the workspace has a TikTok account connected.
|
|
236
330
|
*/
|
|
237
331
|
tiktok?: ITikTokConfig;
|
|
238
332
|
/**
|
|
239
|
-
* Facebook Page-specific configuration
|
|
240
|
-
* Required if
|
|
333
|
+
* Facebook Page-specific configuration.
|
|
334
|
+
* Required if the workspace has a Facebook Page connected.
|
|
241
335
|
*/
|
|
242
336
|
facebook?: IFacebookPageConfig;
|
|
243
337
|
/**
|
|
244
|
-
* Instagram-specific configuration
|
|
245
|
-
* Required if
|
|
338
|
+
* Instagram-specific configuration.
|
|
339
|
+
* Required if the workspace has an Instagram account connected.
|
|
246
340
|
*/
|
|
247
341
|
instagram?: IInstagramConfig;
|
|
248
342
|
/**
|
|
@@ -259,6 +353,11 @@ interface IPublishToAccountOptions {
|
|
|
259
353
|
* Optional reference ID for external systems
|
|
260
354
|
*/
|
|
261
355
|
refId?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Optional post-publish comment (Pro plan, +1 credit).
|
|
358
|
+
* TikTok comments are not supported.
|
|
359
|
+
*/
|
|
360
|
+
comment?: ICommentRequest;
|
|
262
361
|
}
|
|
263
362
|
/**
|
|
264
363
|
* Base interface for quick publish options
|
|
@@ -310,6 +409,11 @@ interface IQuickPublishBaseOptions {
|
|
|
310
409
|
* @example 'external-id-123', 'crm-campaign-456'
|
|
311
410
|
*/
|
|
312
411
|
refId?: string;
|
|
412
|
+
/**
|
|
413
|
+
* Optional post-publish comment (Pro plan, +1 credit).
|
|
414
|
+
* TikTok comments are not supported.
|
|
415
|
+
*/
|
|
416
|
+
comment?: ICommentRequest;
|
|
313
417
|
}
|
|
314
418
|
/**
|
|
315
419
|
* Quick publish options for YouTube only
|
|
@@ -527,6 +631,44 @@ interface ISocialPublisherPostInfo {
|
|
|
527
631
|
}[];
|
|
528
632
|
socialPublisherAccountId: string | any;
|
|
529
633
|
}
|
|
634
|
+
/**
|
|
635
|
+
* Image-post metadata on the post status response.
|
|
636
|
+
* Only present when `type === "image"`.
|
|
637
|
+
*/
|
|
638
|
+
interface IImageDTO {
|
|
639
|
+
source: "image-file" | "image-url";
|
|
640
|
+
bucketKey?: string;
|
|
641
|
+
externalUrl?: string;
|
|
642
|
+
width?: number;
|
|
643
|
+
height?: number;
|
|
644
|
+
mimeType?: string;
|
|
645
|
+
/** True when the caption was AI-enhanced before publish. */
|
|
646
|
+
aiEnhanced?: boolean;
|
|
647
|
+
/** Set after the bucket cleanup job runs (uploaded files only). */
|
|
648
|
+
deletedFromBucketAt?: Date;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Per-platform comment status block returned on the post status response.
|
|
652
|
+
* Present only when the post was created with a `comment` payload.
|
|
653
|
+
*
|
|
654
|
+
* TikTok always returns `currentStatus = "notSupported"`.
|
|
655
|
+
*/
|
|
656
|
+
interface ICommentInfoDTO {
|
|
657
|
+
/** Whether the caller opted in for this platform (mirrors the request flag). */
|
|
658
|
+
isAllow?: boolean;
|
|
659
|
+
/** Current per-platform comment status. */
|
|
660
|
+
currentStatus?: CommentStatusType;
|
|
661
|
+
/** Last error message (when `currentStatus === "error"`). */
|
|
662
|
+
currentError?: string;
|
|
663
|
+
/** ID of the comment on the platform (when posted). */
|
|
664
|
+
externalCommentId?: string;
|
|
665
|
+
/** Public URL of the comment on the platform (when posted). */
|
|
666
|
+
commentURL?: string;
|
|
667
|
+
/** Timestamp the comment was successfully posted. */
|
|
668
|
+
postedAt?: Date;
|
|
669
|
+
/** Grouped history of status transitions for this platform comment. */
|
|
670
|
+
statusHistoryGrouped?: IBaseStatusHistoryGroupedDay<CommentStatusType>[];
|
|
671
|
+
}
|
|
530
672
|
interface ISocialPublisherPostPlatform {
|
|
531
673
|
postInfo: ISocialPublisherPostInfo;
|
|
532
674
|
}
|
|
@@ -564,7 +706,7 @@ interface ISocialPublisherPostResponse {
|
|
|
564
706
|
interface ISocialPublisherPostStatusResponse {
|
|
565
707
|
_id: string;
|
|
566
708
|
numbering: string;
|
|
567
|
-
type: "shortVideo";
|
|
709
|
+
type: "shortVideo" | "image";
|
|
568
710
|
source: SocialPublisherPostSourceType;
|
|
569
711
|
sourceURLs: {
|
|
570
712
|
/**
|
|
@@ -575,11 +717,17 @@ interface ISocialPublisherPostStatusResponse {
|
|
|
575
717
|
* Video URL, can be null if didn't upload any video or passed URL
|
|
576
718
|
*/
|
|
577
719
|
videoURL?: string;
|
|
720
|
+
/**
|
|
721
|
+
* Image URL (image-post type). Returned for posts of `type: "image"`.
|
|
722
|
+
*/
|
|
723
|
+
imageURL?: string;
|
|
578
724
|
/**
|
|
579
725
|
* Post URL, can be null if didn't upload any post or passed URL for platforms like facebook, tiktok, youtube
|
|
580
726
|
*/
|
|
581
727
|
postURL?: string;
|
|
582
728
|
};
|
|
729
|
+
/** Image-post metadata — only present when `type === "image"`. */
|
|
730
|
+
image?: IImageDTO;
|
|
583
731
|
currentStatus: SocialPublisherPostStatusType;
|
|
584
732
|
currentError: string;
|
|
585
733
|
currentStatusChangedAt: string;
|
|
@@ -633,15 +781,21 @@ interface ISocialPublisherPostTikTokPostDetails extends ISocialPublisherPostAcco
|
|
|
633
781
|
disable_stitch: boolean;
|
|
634
782
|
disable_comment: boolean;
|
|
635
783
|
privacy_level: string;
|
|
784
|
+
/** Per-platform comment status — TikTok always reports `notSupported`. */
|
|
785
|
+
commentInfo?: ICommentInfoDTO;
|
|
636
786
|
}
|
|
637
787
|
interface ISocialPublisherPostFacebookPagePostDetails extends ISocialPublisherPostAccount {
|
|
638
788
|
description: string;
|
|
639
789
|
title: string;
|
|
790
|
+
/** Per-platform comment status (only present when a comment was requested). */
|
|
791
|
+
commentInfo?: ICommentInfoDTO;
|
|
640
792
|
}
|
|
641
793
|
interface ISocialPublisherPostInstagramPostDetails extends ISocialPublisherPostAccount {
|
|
642
794
|
description: string;
|
|
643
795
|
share_to_feed: boolean;
|
|
644
796
|
is_published_to_both_feed_and_story: boolean;
|
|
797
|
+
/** Per-platform comment status (only present when a comment was requested). */
|
|
798
|
+
commentInfo?: ICommentInfoDTO;
|
|
645
799
|
}
|
|
646
800
|
interface ISocialPublisherPostYouTubePostDetails extends ISocialPublisherPostAccount {
|
|
647
801
|
title: string;
|
|
@@ -653,6 +807,8 @@ interface ISocialPublisherPostYouTubePostDetails extends ISocialPublisherPostAcc
|
|
|
653
807
|
categoryId: string;
|
|
654
808
|
localizationLanguages: string[];
|
|
655
809
|
localizations: any;
|
|
810
|
+
/** Per-platform comment status (only present when a comment was requested). */
|
|
811
|
+
commentInfo?: ICommentInfoDTO;
|
|
656
812
|
}
|
|
657
813
|
interface ISocialPublisherPostNextPreviousResponse {
|
|
658
814
|
nextId?: string;
|
|
@@ -729,6 +885,29 @@ declare class SocialPublisherPostClient {
|
|
|
729
885
|
* @param id - Optional ID for updating/retrying?
|
|
730
886
|
*/
|
|
731
887
|
private createToAccountByURL;
|
|
888
|
+
/**
|
|
889
|
+
* Create an image post targeting a workspace. The image is published to
|
|
890
|
+
* every account connected to the workspace (Facebook / Instagram / TikTok
|
|
891
|
+
* photo). YouTube community posts are always reported as `notSupported`
|
|
892
|
+
* on the status response — the YouTube Data API doesn't expose them to
|
|
893
|
+
* third-party apps. Cost: 5 credits + 1 if `comment` is provided.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* const postId = await client.createImagePostToWorkspace({
|
|
898
|
+
* workspaceId: "ws_123",
|
|
899
|
+
* image: { source: "image-url", externalUrl: "https://cdn.example.com/launch.jpg" },
|
|
900
|
+
* caption: "We shipped!",
|
|
901
|
+
* });
|
|
902
|
+
* ```
|
|
903
|
+
*/
|
|
904
|
+
createImagePostToWorkspace(data: ICreateImagePostToWorkspaceRequest, id?: string): Promise<string>;
|
|
905
|
+
/**
|
|
906
|
+
* Create an image post targeting a single account. The server derives the
|
|
907
|
+
* target platform from `account.platform`; image config blocks for other
|
|
908
|
+
* platforms in the request are ignored.
|
|
909
|
+
*/
|
|
910
|
+
createImagePostToAccount(data: ICreateImagePostToAccountRequest, id?: string): Promise<string>;
|
|
732
911
|
/**
|
|
733
912
|
* Handle thumbnail upload - accepts either File or URL string
|
|
734
913
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -778,14 +957,17 @@ declare class SocialPublisherPostClient {
|
|
|
778
957
|
* @param options - Simplified publishing options
|
|
779
958
|
* @returns Created post response
|
|
780
959
|
*
|
|
960
|
+
* The workspace's connected accounts (set up via the Posty5 dashboard)
|
|
961
|
+
* determine which platforms this post lands on — supply a config block
|
|
962
|
+
* for each connected platform.
|
|
963
|
+
*
|
|
781
964
|
* @example
|
|
782
965
|
* ```typescript
|
|
783
|
-
* //
|
|
784
|
-
* await client.
|
|
966
|
+
* // Workspace has a YouTube account connected → just supply youtube config
|
|
967
|
+
* await client.publishShortVideoToWorkspace({
|
|
785
968
|
* workspaceId: 'workspace-123',
|
|
786
969
|
* video: videoFile,
|
|
787
970
|
* thumbnail: thumbFile,
|
|
788
|
-
* platforms: ['youtube'],
|
|
789
971
|
* youtube: {
|
|
790
972
|
* title: 'My Video',
|
|
791
973
|
* description: 'Description',
|
|
@@ -793,21 +975,19 @@ declare class SocialPublisherPostClient {
|
|
|
793
975
|
* }
|
|
794
976
|
* });
|
|
795
977
|
*
|
|
796
|
-
* //
|
|
797
|
-
* await client.
|
|
978
|
+
* // Workspace has YouTube + TikTok connected → supply both configs
|
|
979
|
+
* await client.publishShortVideoToWorkspace({
|
|
798
980
|
* workspaceId: 'workspace-123',
|
|
799
981
|
* video: 'https://example.com/video.mp4',
|
|
800
982
|
* thumbnail: 'https://example.com/thumb.jpg',
|
|
801
|
-
* platforms: ['youtube', 'tiktok'],
|
|
802
983
|
* youtube: { title: 'Video', description: 'Desc', tags: [] },
|
|
803
984
|
* tiktok: { caption: 'Caption', privacy_level: 'public', disable_duet: false, disable_stitch: false, disable_comment: false }
|
|
804
985
|
* });
|
|
805
986
|
*
|
|
806
987
|
* // Repost from Facebook (auto-detected)
|
|
807
|
-
* await client.
|
|
988
|
+
* await client.publishShortVideoToWorkspace({
|
|
808
989
|
* workspaceId: 'workspace-123',
|
|
809
990
|
* video: 'https://facebook.com/video/12345',
|
|
810
|
-
* platforms: ['youtube'],
|
|
811
991
|
* youtube: { title: 'Reposted', description: 'From FB', tags: [] }
|
|
812
992
|
* });
|
|
813
993
|
* ```
|
|
@@ -832,4 +1012,4 @@ declare class SocialPublisherPostClient {
|
|
|
832
1012
|
private detectVideoSource;
|
|
833
1013
|
}
|
|
834
1014
|
|
|
835
|
-
export { type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICreateSocialPublisherAccountPostRequest, type ICreateSocialPublisherPostRequest, type IDefaultSettingsResponse, type IFacebookPageConfig, type IGenerateUploadUrlsRequest, type IGenerateUploadUrlsResponse, type IInstagramConfig, type IListParams, type IPostSetting, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IScheduleConfig, type ISearchSocialPublisherPostResponse, type ISocialPublisherAccount, type ISocialPublisherPostAccount, type ISocialPublisherPostFacebookPagePostDetails, type ISocialPublisherPostInfo, type ISocialPublisherPostInstagramPostDetails, type ISocialPublisherPostNextPreviousResponse, type ISocialPublisherPostPlatform, type ISocialPublisherPostResponse, type ISocialPublisherPostStatusLog, type ISocialPublisherPostStatusResponse, type ISocialPublisherPostTikTokPostDetails, type ISocialPublisherPostYouTubePostDetails, type ISocialPublisherWorkspace, type ITikTokConfig, type IUploadConfig, type IYouTubeConfig, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType };
|
|
1015
|
+
export { type CommentStatusType, type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICommentInfoDTO, type ICommentRequest, type ICreateImagePostToAccountRequest, type ICreateImagePostToWorkspaceRequest, type ICreateSocialPublisherAccountPostRequest, type ICreateSocialPublisherPostRequest, type IDefaultSettingsResponse, type IFacebookPageConfig, type IGenerateUploadUrlsRequest, type IGenerateUploadUrlsResponse, type IImageDTO, type IImageMediaRequest, type IInstagramConfig, type IListParams, type IPostSetting, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IScheduleConfig, type ISearchSocialPublisherPostResponse, type ISocialPublisherAccount, type ISocialPublisherPostAccount, type ISocialPublisherPostFacebookPagePostDetails, type ISocialPublisherPostInfo, type ISocialPublisherPostInstagramPostDetails, type ISocialPublisherPostNextPreviousResponse, type ISocialPublisherPostPlatform, type ISocialPublisherPostResponse, type ISocialPublisherPostStatusLog, type ISocialPublisherPostStatusResponse, type ISocialPublisherPostTikTokPostDetails, type ISocialPublisherPostYouTubePostDetails, type ISocialPublisherWorkspace, type ITikTokConfig, type IUploadConfig, type IYouTubeConfig, type ImageSourceType, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType };
|
package/dist/index.js
CHANGED
|
@@ -107,6 +107,43 @@ var SocialPublisherPostClient = class {
|
|
|
107
107
|
});
|
|
108
108
|
return response.result?._id;
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Create an image post targeting a workspace. The image is published to
|
|
112
|
+
* every account connected to the workspace (Facebook / Instagram / TikTok
|
|
113
|
+
* photo). YouTube community posts are always reported as `notSupported`
|
|
114
|
+
* on the status response — the YouTube Data API doesn't expose them to
|
|
115
|
+
* third-party apps. Cost: 5 credits + 1 if `comment` is provided.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* const postId = await client.createImagePostToWorkspace({
|
|
120
|
+
* workspaceId: "ws_123",
|
|
121
|
+
* image: { source: "image-url", externalUrl: "https://cdn.example.com/launch.jpg" },
|
|
122
|
+
* caption: "We shipped!",
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
async createImagePostToWorkspace(data, id) {
|
|
127
|
+
const url = id ? `${this.basePath}/image/workspace/${id}` : `${this.basePath}/image/workspace`;
|
|
128
|
+
const response = await this.http.post(url, {
|
|
129
|
+
...data,
|
|
130
|
+
createdFrom: "npmPackage"
|
|
131
|
+
});
|
|
132
|
+
return response.result?._id;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Create an image post targeting a single account. The server derives the
|
|
136
|
+
* target platform from `account.platform`; image config blocks for other
|
|
137
|
+
* platforms in the request are ignored.
|
|
138
|
+
*/
|
|
139
|
+
async createImagePostToAccount(data, id) {
|
|
140
|
+
const url = id ? `${this.basePath}/image/account/${id}` : `${this.basePath}/image/account`;
|
|
141
|
+
const response = await this.http.post(url, {
|
|
142
|
+
...data,
|
|
143
|
+
createdFrom: "npmPackage"
|
|
144
|
+
});
|
|
145
|
+
return response.result?._id;
|
|
146
|
+
}
|
|
110
147
|
/**
|
|
111
148
|
* Handle thumbnail upload - accepts either File or URL string
|
|
112
149
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -262,14 +299,17 @@ var SocialPublisherPostClient = class {
|
|
|
262
299
|
* @param options - Simplified publishing options
|
|
263
300
|
* @returns Created post response
|
|
264
301
|
*
|
|
302
|
+
* The workspace's connected accounts (set up via the Posty5 dashboard)
|
|
303
|
+
* determine which platforms this post lands on — supply a config block
|
|
304
|
+
* for each connected platform.
|
|
305
|
+
*
|
|
265
306
|
* @example
|
|
266
307
|
* ```typescript
|
|
267
|
-
* //
|
|
268
|
-
* await client.
|
|
308
|
+
* // Workspace has a YouTube account connected → just supply youtube config
|
|
309
|
+
* await client.publishShortVideoToWorkspace({
|
|
269
310
|
* workspaceId: 'workspace-123',
|
|
270
311
|
* video: videoFile,
|
|
271
312
|
* thumbnail: thumbFile,
|
|
272
|
-
* platforms: ['youtube'],
|
|
273
313
|
* youtube: {
|
|
274
314
|
* title: 'My Video',
|
|
275
315
|
* description: 'Description',
|
|
@@ -277,21 +317,19 @@ var SocialPublisherPostClient = class {
|
|
|
277
317
|
* }
|
|
278
318
|
* });
|
|
279
319
|
*
|
|
280
|
-
* //
|
|
281
|
-
* await client.
|
|
320
|
+
* // Workspace has YouTube + TikTok connected → supply both configs
|
|
321
|
+
* await client.publishShortVideoToWorkspace({
|
|
282
322
|
* workspaceId: 'workspace-123',
|
|
283
323
|
* video: 'https://example.com/video.mp4',
|
|
284
324
|
* thumbnail: 'https://example.com/thumb.jpg',
|
|
285
|
-
* platforms: ['youtube', 'tiktok'],
|
|
286
325
|
* youtube: { title: 'Video', description: 'Desc', tags: [] },
|
|
287
326
|
* tiktok: { caption: 'Caption', privacy_level: 'public', disable_duet: false, disable_stitch: false, disable_comment: false }
|
|
288
327
|
* });
|
|
289
328
|
*
|
|
290
329
|
* // Repost from Facebook (auto-detected)
|
|
291
|
-
* await client.
|
|
330
|
+
* await client.publishShortVideoToWorkspace({
|
|
292
331
|
* workspaceId: 'workspace-123',
|
|
293
332
|
* video: 'https://facebook.com/video/12345',
|
|
294
|
-
* platforms: ['youtube'],
|
|
295
333
|
* youtube: { title: 'Reposted', description: 'From FB', tags: [] }
|
|
296
334
|
* });
|
|
297
335
|
* ```
|
|
@@ -303,27 +341,11 @@ var SocialPublisherPostClient = class {
|
|
|
303
341
|
if (!options.video) {
|
|
304
342
|
throw new Error("video is required");
|
|
305
343
|
}
|
|
306
|
-
if (!options.
|
|
307
|
-
throw new Error("
|
|
308
|
-
}
|
|
309
|
-
if (options.platforms.includes("youtube") && !options.youtube) {
|
|
310
|
-
throw new Error("YouTube configuration is required when publishing to YouTube");
|
|
311
|
-
}
|
|
312
|
-
if (options.platforms.includes("tiktok") && !options.tiktok) {
|
|
313
|
-
throw new Error("TikTok configuration is required when publishing to TikTok");
|
|
314
|
-
}
|
|
315
|
-
if (options.platforms.includes("facebook") && !options.facebook) {
|
|
316
|
-
throw new Error("Facebook configuration is required when publishing to Facebook");
|
|
317
|
-
}
|
|
318
|
-
if (options.platforms.includes("instagram") && !options.instagram) {
|
|
319
|
-
throw new Error("Instagram configuration is required when publishing to Instagram");
|
|
344
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
345
|
+
throw new Error("Provide at least one platform configuration (youtube / tiktok / facebook / instagram)");
|
|
320
346
|
}
|
|
321
347
|
const settings = {
|
|
322
348
|
workspaceId: options.workspaceId,
|
|
323
|
-
isAllowYouTube: options.platforms.includes("youtube"),
|
|
324
|
-
isAllowTiktok: options.platforms.includes("tiktok"),
|
|
325
|
-
isAllowFacebookPage: options.platforms.includes("facebook"),
|
|
326
|
-
isAllowInstagram: options.platforms.includes("instagram"),
|
|
327
349
|
youtube: options.youtube,
|
|
328
350
|
tiktok: options.tiktok,
|
|
329
351
|
facebook: options.facebook,
|
|
@@ -332,7 +354,10 @@ var SocialPublisherPostClient = class {
|
|
|
332
354
|
type: options.schedule === "now" ? "now" : "schedule",
|
|
333
355
|
scheduledAt: options.schedule instanceof Date ? options.schedule : void 0
|
|
334
356
|
} : void 0,
|
|
335
|
-
source: "video-file"
|
|
357
|
+
source: "video-file",
|
|
358
|
+
tag: options.tag,
|
|
359
|
+
refId: options.refId,
|
|
360
|
+
comment: options.comment
|
|
336
361
|
};
|
|
337
362
|
const source = this.detectVideoSource(options.video);
|
|
338
363
|
switch (source) {
|
|
@@ -362,28 +387,12 @@ var SocialPublisherPostClient = class {
|
|
|
362
387
|
if (!options.video) {
|
|
363
388
|
throw new Error("video is required");
|
|
364
389
|
}
|
|
365
|
-
if (!options.
|
|
366
|
-
throw new Error("
|
|
367
|
-
}
|
|
368
|
-
if (options.platforms.includes("youtube") && !options.youtube) {
|
|
369
|
-
throw new Error("YouTube configuration is required when publishing to YouTube");
|
|
370
|
-
}
|
|
371
|
-
if (options.platforms.includes("tiktok") && !options.tiktok) {
|
|
372
|
-
throw new Error("TikTok configuration is required when publishing to TikTok");
|
|
373
|
-
}
|
|
374
|
-
if (options.platforms.includes("facebook") && !options.facebook) {
|
|
375
|
-
throw new Error("Facebook configuration is required when publishing to Facebook");
|
|
376
|
-
}
|
|
377
|
-
if (options.platforms.includes("instagram") && !options.instagram) {
|
|
378
|
-
throw new Error("Instagram configuration is required when publishing to Instagram");
|
|
390
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
391
|
+
throw new Error("Provide the platform configuration matching the account (youtube / tiktok / facebook / instagram)");
|
|
379
392
|
}
|
|
380
393
|
const source = this.detectVideoSource(options.video);
|
|
381
394
|
const settings = {
|
|
382
395
|
accountId: options.accountId,
|
|
383
|
-
isAllowYouTube: options.platforms.includes("youtube"),
|
|
384
|
-
isAllowTiktok: options.platforms.includes("tiktok"),
|
|
385
|
-
isAllowFacebookPage: options.platforms.includes("facebook"),
|
|
386
|
-
isAllowInstagram: options.platforms.includes("instagram"),
|
|
387
396
|
youtube: options.youtube,
|
|
388
397
|
tiktok: options.tiktok,
|
|
389
398
|
facebook: options.facebook,
|
|
@@ -392,7 +401,10 @@ var SocialPublisherPostClient = class {
|
|
|
392
401
|
type: options.schedule === "now" ? "now" : "schedule",
|
|
393
402
|
scheduledAt: options.schedule instanceof Date ? options.schedule : void 0
|
|
394
403
|
} : void 0,
|
|
395
|
-
source: "video-file"
|
|
404
|
+
source: "video-file",
|
|
405
|
+
tag: options.tag,
|
|
406
|
+
refId: options.refId,
|
|
407
|
+
comment: options.comment
|
|
396
408
|
};
|
|
397
409
|
switch (source) {
|
|
398
410
|
case "file": {
|