@posty5/social-publisher-post 4.0.0 → 4.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @posty5/social-publisher-post
2
2
 
3
- Official Posty5 SDK for managing social media publishing posts. Publish videos to YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels with a unified, developer-friendly API.
3
+ Official Posty5 SDK for managing social media publishing posts. Prepare creator-owned videos for YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels with a unified, developer-friendly API.
4
4
 
5
5
  ---
6
6
 
@@ -11,7 +11,7 @@ Official Posty5 SDK for managing social media publishing posts. Publish videos t
11
11
  - 🔗 **Shorten URLs** - Create memorable, trackable short links
12
12
  - 📱 **Generate QR Codes** - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
13
13
  - 🌐 **Host HTML Pages** - Deploy static HTML pages with dynamic variables and form submission handling
14
- - 📢 **Automate Social Media** - Schedule and manage social media posts across multiple platforms
14
+ - 📢 **Social Publishing** - Prepare and manage creator-controlled social media posts across connected platforms
15
15
  - 📊 **Track Performance** - Monitor and analyze your digital marketing efforts
16
16
 
17
17
  Posty5 empowers businesses, marketers, and developers to streamline their online workflows—all from a unified control panel.
@@ -22,29 +22,29 @@ Posty5 empowers businesses, marketers, and developers to streamline their online
22
22
 
23
23
  ## 📦 About This Package
24
24
 
25
- `@posty5/social-publisher-post` is the **post management client** for the Posty5 Social Media Publisher. This package enables you to programmatically publish short-form videos to multiple social media platforms simultaneously from a single API call.
25
+ `@posty5/social-publisher-post` is the **post management client** for the Posty5 Social Media Publisher. Use it with videos you created or have the rights to publish. TikTok Direct Post requires the creator-controlled Posty5 review flow before submission.
26
26
 
27
27
  ### What are Social Publisher Posts?
28
28
 
29
- Posts represent video publishing jobs that distribute your content across YouTube Shorts, TikTok, Facebook Reels, and Instagram Reels. Each post handles the entire publishing workflow: video upload, platform-specific configuration, scheduling, and status tracking.
29
+ Posts represent video publishing jobs for connected YouTube, TikTok, Facebook, and Instagram accounts. Each post handles video upload, platform-specific configuration, scheduling, and status tracking.
30
30
 
31
31
  ### Key Capabilities
32
32
 
33
- - **Multi-Platform Publishing** - Publish to YouTube, TikTok, Facebook, and Instagram in one API call
34
- - **Flexible Video Sources** - Upload files, provide URLs, or repost from other platforms (auto-detected)
33
+ - **Multi-Platform Preparation** - Prepare posts for connected YouTube, TikTok, Facebook, and Instagram accounts
34
+ - **Authorized Video Sources** - Upload files or provide direct video file URLs for content you created or have rights to publish
35
35
  - **Smart Thumbnail Handling** - Upload files or provide URLs for thumbnail images
36
36
  - **Platform-Specific Configuration** - Customize titles, descriptions, captions, tags, and privacy settings per platform
37
37
  - **Schedule Publishing** - Publish immediately or schedule for optimal engagement times
38
- - **Repost Detection** - Automatically detect and repost from Facebook, TikTok, and YouTube Shorts URLs
38
+ - **TikTok Direct Post Review** - TikTok publishing requires manual privacy selection, disclosure options when needed, and explicit creator confirmation in Posty5
39
39
  - **Post Status Tracking** - Monitor publishing progress and platform-specific status
40
40
  - **Tag & Reference System** - Organize posts using custom tags and reference IDs
41
41
  - **Pagination & Filtering** - Search posts by workspace, status, tag, or reference ID
42
42
 
43
43
  ### Why Use This Package?
44
44
 
45
- - **Time Saving**: Publish to 4 platforms with a single API call instead of managing each separately
46
- - **Automated Workflow**: Integrate multi-platform publishing into your content pipeline
47
- - **Content Repurposing**: Automatically repost viral content from other platforms
45
+ - **Time Saving**: Prepare platform-specific settings from one integration while keeping TikTok publishing creator-controlled
46
+ - **Reviewed Workflow**: Integrate publishing status and configuration while preserving the Posty5 TikTok review and confirmation flow
47
+ - **Rights-Aware Publishing**: Use original videos or content you have permission to publish
48
48
  - **Consistent Branding**: Apply platform-optimized metadata while maintaining brand voice
49
49
  - **Progress Tracking**: Monitor post status and handle errors programmatically
50
50
 
@@ -110,13 +110,13 @@ console.log("YouTube:", status.youtube?.postInfo.currentStatus);
110
110
 
111
111
  ### publishShortVideo()
112
112
 
113
- Publish a short video to one or more social media platforms. This is the main method for creating publishing posts. It automatically detects video source type (File upload, URL, or platform-specific repost URL) and handles all upload logic.
113
+ Publish a short video to one or more connected social media accounts. Use file uploads or direct video file URLs for content you created or have the rights to publish. TikTok Direct Post must go through the Posty5 creator review and confirmation flow.
114
114
 
115
115
  **Parameters:**
116
116
 
117
117
  - `options` (IPublishOptions): Publishing configuration
118
118
  - `workspaceId` (string, required): Workspace ID containing connected social accounts
119
- - `video` (File | string, required): Video source - File object, direct URL, or platform URL (Facebook/TikTok/YouTube)
119
+ - `video` (File | string, required): Video source - File object or direct video file URL only.
120
120
  - `thumbnail` (File | string, optional): Thumbnail image - File object or URL string
121
121
  - `youtube` (IYouTubeConfig, optional): YouTube configuration — **required** if the workspace has a YouTube account connected
122
122
  - `tiktok` (ITikTokConfig, optional): TikTok configuration — **required** if the workspace has a TikTok account connected
@@ -190,34 +190,68 @@ const postId = await client.publishShortVideo({
190
190
  console.log("Published to YouTube and TikTok:", postId);
191
191
  ```
192
192
 
193
- **Example - Auto-Comment After Publish (Pro plan, +1 credit):**
193
+ **Example - Comments After Publish (25 credits each):**
194
194
 
195
195
  ```typescript
196
- // Publish a video and queue a comment for each platform.
197
- // TikTok comments are not supported — the platform will always
198
- // report `commentInfo.currentStatus === "notSupported"`.
196
+ // Publish a video and queue up to five comments under each platform post.
197
+ // TikTok is never one of them: it exposes no public comment-posting endpoint,
198
+ // so a comment aimed at it reports `notSupported` rather than failing.
199
199
  const postId = await client.publishShortVideo({
200
200
  workspaceId: "workspace-123",
201
201
  video: videoFile,
202
202
  youtube: { title: "Launch day", description: "We shipped!", tags: ["launch"] },
203
203
  facebook: { description: "We shipped!" },
204
204
  instagram: { description: "We shipped! 🚀" },
205
- comment: {
206
- text: "Drop your favourite feature below 👇",
207
- postToFacebook: true,
208
- postToInstagram: true,
209
- postToYoutube: true,
210
- // postToTiktok defaults to false — TikTok does not support API comments
211
- },
205
+ // Up to five, in the order they post. 25 credits each, charged per comment
206
+ // that actually posts.
207
+ comments: [
208
+ {
209
+ text: "Drop your favourite feature below",
210
+ postToFacebook: true,
211
+ postToInstagram: true,
212
+ postToYoutube: true,
213
+ // postToTiktok defaults to false - TikTok exposes no comment API
214
+ },
215
+ {
216
+ // An hour later, to catch the second wave.
217
+ text: "Still reading? The changelog is in the description.",
218
+ delayMinutes: 60,
219
+ },
220
+ {
221
+ // An image is Facebook only; Instagram and YouTube comments are
222
+ // text-only, so it is dropped there with a reason rather than failing.
223
+ text: "Here is the before and after.",
224
+ imageUrl: "https://cdn.example.com/before-after.jpg",
225
+ postToFacebook: true,
226
+ postToInstagram: false,
227
+ postToYoutube: false,
228
+ },
229
+ ],
212
230
  });
213
231
 
214
- // Later, poll status to see how each comment landed:
232
+ // Later, poll status to see how each comment landed.
215
233
  const status = await client.getStatus(postId);
216
- console.log("YouTube comment:", status.youtube?.commentInfo?.currentStatus);
217
- console.log("Facebook comment URL:", status.facebook?.commentInfo?.commentURL);
218
- console.log("TikTok comment:", status.tiktok?.commentInfo?.currentStatus); // "notSupported"
234
+
235
+ // One entry per comment, in posting order.
236
+ for (const comment of status.facebook?.comments ?? []) {
237
+ console.log(`#${comment.order}`, comment.currentStatus, comment.commentURL);
238
+ }
239
+
240
+ // TikTok reports every comment as notSupported - that is the permanent answer,
241
+ // not a failure.
242
+ console.log("TikTok:", status.tiktok?.comments?.[0]?.currentStatus); // "notSupported"
219
243
  ```
220
244
 
245
+ > **Migrating from `comment`.** The singular field still compiles and is
246
+ > deprecated for one major version. Send one or the other - the API refuses a
247
+ > request carrying both. The singular `commentInfo` on each platform's status
248
+ > also stays, mirroring the first entry of `comments`.
249
+
250
+ > **Pricing.** 25 credits per comment that actually posts, from the API's
251
+ > `socialMediaPublisher.commentOnPost`. Earlier releases of this README said
252
+ > "+1 credit", which was never the price. A comment aimed at no enabled platform
253
+ > is dropped before it is charged.
254
+
221
255
  **Example - Multi-Platform Publishing:**
222
256
 
223
257
  ```typescript
@@ -259,32 +293,25 @@ const postId = await client.publishShortVideo({
259
293
  console.log("Published to all platforms:", postId);
260
294
  ```
261
295
 
262
- **Example - Repost from TikTok:**
296
+ > **TikTok Direct Post note:** This SDK supports file uploads and direct video file URLs only. TikTok publishing in Posty5 is creator-controlled: the connected account owner reviews the video, confirms the TikTok nickname, edits caption text, manually selects privacy and interaction settings, completes disclosure options when required, and explicitly confirms publishing before submission.
297
+
298
+ **Example - Scheduled Publishing:**
263
299
 
264
300
  ```typescript
265
- // Automatically detect and repost from TikTok
301
+ // Schedule video for future publication
302
+ const publishDate = new Date("2024-12-25T12:00:00Z"); // Christmas at noon
303
+
266
304
  const postId = await client.publishShortVideo({
267
305
  workspaceId: "workspace-123",
268
- video: "https://www.tiktok.com/@username/video/1234567890", // TikTok URL
306
+ video: videoFile,
307
+ schedule: publishDate, // Schedule for specific date/time
269
308
  youtube: {
270
- title: "Viral TikTok Repost",
271
- description: "Sharing this viral moment from TikTok",
272
- tags: ["tiktok", "viral", "repost"],
309
+ title: "Merry Christmas! 🎄",
310
+ description: "Holiday greetings from our team",
311
+ tags: ["christmas", "holiday", "greetings"],
273
312
  },
274
- });
275
-
276
- console.log("Reposted from TikTok to YouTube:", postId);
277
- ```
278
-
279
- **Example - Repost from YouTube Shorts:**
280
-
281
- ```typescript
282
- // Repost YouTube Shorts to TikTok
283
- const postId = await client.publishShortVideo({
284
- workspaceId: "workspace-123",
285
- video: "https://www.youtube.com/shorts/abc123", // YouTube Shorts URL
286
313
  tiktok: {
287
- caption: "Check out this YouTube Short! #YouTubeShorts",
314
+ caption: "Merry Christmas everyone! 🎅🎄 #Christmas",
288
315
  privacy_level: "public",
289
316
  disable_duet: false,
290
317
  disable_stitch: false,
@@ -292,60 +319,191 @@ const postId = await client.publishShortVideo({
292
319
  },
293
320
  });
294
321
 
295
- console.log("Reposted from YouTube to TikTok:", postId);
322
+ console.log("Scheduled for", publishDate, "- Post ID:", postId);
296
323
  ```
297
324
 
298
- **Example - Repost from Facebook:**
325
+ ### publishLongVideoToWorkspace()
326
+
327
+ Publish a video of up to **60 minutes** to every account connected to a workspace.
328
+
329
+ The SDK handles the whole sequence for an uploaded file — reserve an upload
330
+ destination, push the bytes, create the post. Pass a URL string instead of a
331
+ `File` to publish something already hosted elsewhere.
299
332
 
300
333
  ```typescript
301
- // Repost Facebook video to other platforms
302
- const postId = await client.publishShortVideo({
303
- workspaceId: "workspace-123",
304
- video: "https://www.facebook.com/reel/1234567890", // Facebook Reel URL
334
+ const result = await client.publishLongVideoToWorkspace({
335
+ workspaceId: "workspace_123",
336
+ video: recordingFile, // File, or a direct https:// URL
305
337
  youtube: {
306
- title: "Facebook Viral Moment",
307
- description: "Reposting this viral moment from Facebook",
308
- tags: ["facebook", "viral", "repost"],
309
- },
310
- tiktok: {
311
- caption: "Viral moment from Facebook! #Viral",
312
- privacy_level: "public",
313
- disable_duet: false,
314
- disable_stitch: false,
315
- disable_comment: false,
338
+ title: "Full workshop recording",
339
+ description: "The complete two-part session.",
340
+ tags: ["workshop", "long-form"],
341
+ privacyStatus: "public",
316
342
  },
343
+ facebook: { title: "Full workshop recording", description: "The complete session." },
344
+ onProgress: (percent) => console.log(`Upload ${percent}%`),
317
345
  });
318
346
 
319
- console.log("Reposted from Facebook:", postId);
347
+ console.log(result.durationSeconds); // 2400 — measured by the server
348
+ console.log(result.credits); // 400 — 8 units x 50
320
349
  ```
321
350
 
322
- **Example - Scheduled Publishing:**
351
+ #### Cost
352
+
353
+ Long video is priced by **duration**: 50 credits for every *started* 5 minutes.
354
+
355
+ | Video length | Units | Credits |
356
+ | --- | --- | --- |
357
+ | 4m 30s | 1 | 50 |
358
+ | 12m | 3 | 150 |
359
+ | 15m | 3 | 150 |
360
+ | 15m 01s | 4 | 200 |
361
+ | 60m | 12 | 600 |
362
+
363
+ There is no `duration` option, and one would be ignored — the server measures
364
+ the video itself, because a client-supplied duration would be a
365
+ client-supplied price.
366
+
367
+ Requires the `socialMediaPublisher.longVideoPost` plan feature.
368
+
369
+ #### Quote before you publish
323
370
 
324
371
  ```typescript
325
- // Schedule video for future publication
326
- const publishDate = new Date("2024-12-25T12:00:00Z"); // Christmas at noon
372
+ const quote = await client.getLongVideoQuote(videoURL);
327
373
 
328
- const postId = await client.publishShortVideo({
329
- workspaceId: "workspace-123",
330
- video: videoFile,
331
- schedule: publishDate, // Schedule for specific date/time
332
- youtube: {
333
- title: "Merry Christmas! 🎄",
334
- description: "Holiday greetings from our team",
335
- tags: ["christmas", "holiday", "greetings"],
336
- },
337
- tiktok: {
338
- caption: "Merry Christmas everyone! 🎅🎄 #Christmas",
339
- privacy_level: "public",
340
- disable_duet: false,
341
- disable_stitch: false,
342
- disable_comment: false,
343
- },
374
+ if (!quote.withinLimit) throw new Error(quote.reason); // over 60 minutes
375
+ console.log(`${quote.durationSeconds}s costs ${quote.credits} credits`);
376
+
377
+ // Which targets can actually take a video this long?
378
+ for (const p of quote.platforms.filter((p) => !p.accepted)) {
379
+ console.warn(`${p.platform}: ${p.reason}`);
380
+ }
381
+ ```
382
+
383
+ #### Interrupted uploads resume
384
+
385
+ Long video uploads resumably: the file goes up in 8MiB chunks, so a dropped
386
+ connection costs one chunk rather than the hour of footage before it. Keep the
387
+ upload URL and you can continue the same transfer later — even after a page
388
+ reload.
389
+
390
+ ```typescript
391
+ let resumeFrom = localStorage.getItem("upload-url") ?? undefined;
392
+
393
+ await client.publishLongVideoToWorkspace({
394
+ workspaceId: "workspace_123",
395
+ video: recordingFile,
396
+ youtube: { title: "Full recording", description: "...", tags: [] },
397
+ resumeFrom,
398
+ onUploadUrl: (url) => localStorage.setItem("upload-url", url),
399
+ signal: controller.signal, // aborting keeps what was uploaded
344
400
  });
401
+ ```
345
402
 
346
- console.log("Scheduled for", publishDate, "- Post ID:", postId);
403
+ The SDK falls back to a single signed PUT when the server does not offer the
404
+ resumable service, so this needs no configuration on your side.
405
+
406
+ #### Cancelling for good
407
+
408
+ Aborting leaves the uploaded bytes on the server, because in most interfaces
409
+ "pause" and "cancel" are the same button and a user who paused a 40-minute video
410
+ does not expect to start over. Where the abort really is final — a wizard the
411
+ user closed, a file they swapped out — say so, and the server stops holding
412
+ megabytes nobody will claim:
413
+
414
+ ```typescript
415
+ await client.publishLongVideoToWorkspace({
416
+ // ...
417
+ signal: controller.signal,
418
+ terminateOnAbort: true,
419
+ });
420
+ ```
421
+
422
+ For an upload URL you persisted earlier and have decided not to resume, discard
423
+ it directly. It never throws — a cleanup that fails is not worth an error, since
424
+ the server expires abandoned uploads after 24 hours anyway:
425
+
426
+ ```typescript
427
+ import { terminateUpload } from "@posty5/social-publisher-post";
428
+
429
+ const discarded = await terminateUpload(savedUploadUrl);
430
+ localStorage.removeItem("upload-url");
431
+ ```
432
+
433
+ #### What counts as a video
434
+
435
+ Both long-video helpers take a **browser `File` or `Blob`**, or a URL to a video
436
+ already hosted somewhere reachable. They do **not** accept a Node `ReadStream` or
437
+ a filesystem path — the same boundary the short-video helpers have always had.
438
+
439
+ From Node, read the file and hand over a `Blob`:
440
+
441
+ ```typescript
442
+ import { readFile } from "node:fs/promises";
443
+
444
+ const bytes = await readFile("./recording.mp4");
445
+ const video = new File([bytes], "recording.mp4", { type: "video/mp4" });
347
446
  ```
348
447
 
448
+ That buffers the whole file in memory, which is the reason the streaming variant
449
+ does not exist yet rather than an oversight. For anything large from a server,
450
+ prefer uploading to your own storage first and publishing by URL.
451
+
452
+ #### Platforms disagree about "long"
453
+
454
+ A 40-minute video is a fine YouTube post and an impossible Instagram one —
455
+ Reels stop at 15 minutes. Rather than fail the whole post, a workspace publish
456
+ goes out to the targets that accept it and tells you which it dropped:
457
+
458
+ ```typescript
459
+ for (const target of result.refusedTargets) {
460
+ console.warn(`${target.platform} skipped: ${target.reason}`);
461
+ }
462
+ ```
463
+
464
+ Limits are checked when the post is created, never mid-upload. TikTok's cap is
465
+ per-creator and read from the connected account.
466
+
467
+ ---
468
+
469
+ ### publishLongVideoToAccount()
470
+
471
+ The same, targeting one connected account. With a single target there is no
472
+ partial success: if that platform will not take a video this long, the call is
473
+ refused and nothing is charged.
474
+
475
+ ```typescript
476
+ const result = await client.publishLongVideoToAccount({
477
+ accountId: "account_456",
478
+ video: recordingFile,
479
+ youtube: { title: "Episode 14", description: "The full episode.", tags: ["podcast"] },
480
+ schedule: new Date("2026-09-15T10:00:00Z"),
481
+ });
482
+ ```
483
+
484
+ ---
485
+
486
+ ### reschedulePost()
487
+
488
+ Move a post that has not published yet to a different time, or send it out now.
489
+ Free — this costs no credits.
490
+
491
+ ```typescript
492
+ // Move it
493
+ await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") });
494
+
495
+ // Or publish it immediately
496
+ await client.reschedulePost("post_123", { schedule: "now" });
497
+
498
+ // Optionally replace the caption at the same time
499
+ await client.reschedulePost("post_123", { schedule: "now", caption: "Updated caption" });
500
+ ```
501
+
502
+ Only posts still pending with a future publish time are eligible. Anything that
503
+ has already started publishing is refused by the server with a reason.
504
+
505
+ ---
506
+
349
507
  ---
350
508
 
351
509
  ### list()
@@ -862,7 +1020,7 @@ import {
862
1020
 
863
1021
  // Status types
864
1022
  SocialPublisherPostStatusType, // 'pending' | 'processing' | 'done' | 'error' | ...
865
- SocialPublisherPostSourceType, // 'video-file' | 'video-url' | 'facebook-video' | ...
1023
+ SocialPublisherPostSourceType, // 'video-file' | 'video-url'
866
1024
  SocialPublisherAccountStatusType, // 'active' | 'inactive' | 'authenticationExpired'
867
1025
  } from "@posty5/social-publisher-post";
868
1026
  ```