@posty5/social-publisher-post 2.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 ADDED
@@ -0,0 +1,957 @@
1
+ # @posty5/social-publisher-post
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.
4
+
5
+ ---
6
+
7
+ ## 🌟 What is Posty5?
8
+
9
+ **Posty5** is a comprehensive suite of free online tools designed to enhance your digital marketing and social media presence. With over 4+ powerful tools and counting, Posty5 provides everything you need to:
10
+
11
+ - πŸ”— **Shorten URLs** - Create memorable, trackable short links
12
+ - πŸ“± **Generate QR Codes** - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
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
15
+ - πŸ“Š **Track Performance** - Monitor and analyze your digital marketing efforts
16
+
17
+ Posty5 empowers businesses, marketers, and developers to streamline their online workflowsβ€”all from a unified control panel.
18
+
19
+ **Learn more:** [https://posty5.com](https://posty5.com)
20
+
21
+ ---
22
+
23
+ ## πŸ“¦ About This Package
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.
26
+
27
+ ### What are Social Publisher Posts?
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.
30
+
31
+ ### Key Capabilities
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)
35
+ - **Smart Thumbnail Handling** - Upload files or provide URLs for thumbnail images
36
+ - **Platform-Specific Configuration** - Customize titles, descriptions, captions, tags, and privacy settings per platform
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
39
+ - **Post Status Tracking** - Monitor publishing progress and platform-specific status
40
+ - **Tag & Reference System** - Organize posts using custom tags and reference IDs
41
+ - **Pagination & Filtering** - Search posts by workspace, status, tag, or reference ID
42
+
43
+ ### Why Use This Package?
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
48
+ - **Consistent Branding**: Apply platform-optimized metadata while maintaining brand voice
49
+ - **Progress Tracking**: Monitor post status and handle errors programmatically
50
+
51
+ ### Supported Platforms
52
+
53
+ | Platform | Content Type | Custom Thumbnails | Max File Size |
54
+ | --------- | ------------ | ----------------- | ------------- |
55
+ | YouTube | Shorts | βœ… Yes | 2 GB |
56
+ | TikTok | Videos | ❌ No | 2 GB |
57
+ | Facebook | Reels | ❌ No | 2 GB |
58
+ | Instagram | Reels | ❌ No | 2 GB |
59
+
60
+ ---
61
+
62
+ ## πŸ“₯ Installation
63
+
64
+ Install via npm:
65
+
66
+ ```bash
67
+ npm install @posty5/social-publisher-post @posty5/core
68
+ ```
69
+
70
+ ---
71
+
72
+ ## πŸš€ Quick Start
73
+
74
+ ```typescript
75
+ import { HttpClient } from "@posty5/core";
76
+ import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
77
+
78
+ // Initialize the HTTP client with your API key
79
+ const httpClient = new HttpClient({
80
+ apiKey: "your-api-key", // Get from studio.posty5.com/account/settings?tab=APIKeys
81
+ debug: true, // Optional: Enable debug logging
82
+ });
83
+
84
+ // Create post client
85
+ const client = new SocialPublisherPostClient(httpClient);
86
+
87
+ // Publish video to YouTube Shorts
88
+ const postId = await client.publishShortVideo({
89
+ workspaceId: "workspace-123", // Your workspace ID
90
+ video: videoFile, // File object or URL string
91
+ thumbnail: thumbFile, // Optional: File or URL
92
+ platforms: ["youtube"], // Target platforms
93
+ youtube: {
94
+ title: "My First YouTube Short",
95
+ description: "Published using Posty5 SDK",
96
+ tags: ["shorts", "video", "tutorial"],
97
+ },
98
+ });
99
+
100
+ console.log("Post created:", postId);
101
+
102
+ // Check post status
103
+ const status = await client.getStatus(postId);
104
+ console.log("Publishing status:", status.currentStatus);
105
+ console.log("YouTube:", status.youtube?.postInfo.currentStatus);
106
+ ```
107
+
108
+ ---
109
+
110
+ ## πŸ“š API Reference & Examples
111
+
112
+ ### publishShortVideo()
113
+
114
+ 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.
115
+
116
+ **Parameters:**
117
+
118
+ - `options` (IPublishOptions): Publishing configuration
119
+ - `workspaceId` (string, required): Workspace ID containing connected social accounts
120
+ - `video` (File | string, required): Video source - File object, direct URL, or platform URL (Facebook/TikTok/YouTube)
121
+ - `thumbnail` (File | string, optional): Thumbnail image - File object or URL string
122
+ - `platforms` (Array<'youtube' | 'tiktok' | 'facebook' | 'instagram'>, required): Target platforms
123
+ - `youtube` (IYouTubeConfig, optional): YouTube configuration - required if 'youtube' in platforms
124
+ - `tiktok` (ITikTokConfig, optional): TikTok configuration - required if 'tiktok' in platforms
125
+ - `facebook` (IFacebookPageConfig, optional): Facebook configuration - required if 'facebook' in platforms
126
+ - `instagram` (IInstagramConfig, optional): Instagram configuration - required if 'instagram' in platforms
127
+ - `schedule` ('now' | Date, optional): Publish immediately (default) or schedule for specific date/time
128
+ - `tag` (string, optional): Custom tag for filtering
129
+ - `refId` (string, optional): Your internal reference ID
130
+
131
+ **Returns:** `Promise<string>` - Created post ID
132
+
133
+ **Example - Upload Video File:**
134
+
135
+ ```typescript
136
+ import * as fs from "fs";
137
+
138
+ // Read video and thumbnail files
139
+ const videoFile = fs.readFileSync("./video.mp4");
140
+ const thumbFile = fs.readFileSync("./thumbnail.jpg");
141
+
142
+ // Create File objects
143
+ const video = new File([videoFile], "video.mp4", { type: "video/mp4" });
144
+ const thumbnail = new File([thumbFile], "thumb.jpg", { type: "image/jpeg" });
145
+
146
+ // Publish to YouTube only
147
+ const postId = await client.publishShortVideo({
148
+ workspaceId: "workspace-123",
149
+ video: video,
150
+ thumbnail: thumbnail,
151
+ platforms: ["youtube"],
152
+ youtube: {
153
+ title: "Product Launch Video",
154
+ description: "Introducing our new product line for 2024",
155
+ tags: ["product", "launch", "2024"],
156
+ madeForKids: false,
157
+ },
158
+ tag: "product-launch", // Custom tag for filtering
159
+ refId: "PROD-LAUNCH-001", // Your internal reference
160
+ });
161
+
162
+ console.log("Published to YouTube:", postId);
163
+ ```
164
+
165
+ **Example - Video URL with Thumbnail URL:**
166
+
167
+ ```typescript
168
+ // Publish using URLs (no file upload needed)
169
+ const postId = await client.publishShortVideo({
170
+ workspaceId: "workspace-123",
171
+ video: "https://cdn.example.com/videos/promo.mp4", // Direct video URL
172
+ thumbnail: "https://cdn.example.com/images/thumb.jpg", // Direct thumbnail URL
173
+ platforms: ["youtube", "tiktok"],
174
+ youtube: {
175
+ title: "Summer Sale Announcement",
176
+ description: "Check out our summer collection",
177
+ tags: ["sale", "summer", "fashion"],
178
+ },
179
+ tiktok: {
180
+ caption: "Summer sale is here! πŸ”₯ #SummerSale #Fashion",
181
+ privacy_level: "public",
182
+ disable_duet: false,
183
+ disable_stitch: false,
184
+ disable_comment: false,
185
+ },
186
+ });
187
+
188
+ console.log("Published to YouTube and TikTok:", postId);
189
+ ```
190
+
191
+ **Example - Multi-Platform Publishing:**
192
+
193
+ ```typescript
194
+ // Publish to all 4 platforms simultaneously
195
+ const postId = await client.publishShortVideo({
196
+ workspaceId: "workspace-123",
197
+ video: videoFile,
198
+ thumbnail: thumbFile,
199
+ platforms: ["youtube", "tiktok", "facebook", "instagram"],
200
+
201
+ // YouTube configuration
202
+ youtube: {
203
+ title: "How to Use Our Product",
204
+ description: "Step-by-step tutorial for beginners",
205
+ tags: ["tutorial", "howto", "guide"],
206
+ },
207
+
208
+ // TikTok configuration
209
+ tiktok: {
210
+ caption: "Easy tutorial! Try it yourself 🎯 #Tutorial #LearnTikTok",
211
+ privacy_level: "public",
212
+ disable_duet: false,
213
+ disable_stitch: false,
214
+ disable_comment: false,
215
+ },
216
+
217
+ // Facebook configuration
218
+ facebook: {
219
+ title: "Product Tutorial",
220
+ description: "Learn how to use our product in under 60 seconds",
221
+ },
222
+
223
+ // Instagram configuration
224
+ instagram: {
225
+ description: "Quick product tutorial πŸ“± #ProductTutorial",
226
+ share_to_feed: true,
227
+ },
228
+ });
229
+
230
+ console.log("Published to all platforms:", postId);
231
+ ```
232
+
233
+ **Example - Repost from TikTok:**
234
+
235
+ ```typescript
236
+ // Automatically detect and repost from TikTok
237
+ const postId = await client.publishShortVideo({
238
+ workspaceId: "workspace-123",
239
+ video: "https://www.tiktok.com/@username/video/1234567890", // TikTok URL
240
+ platforms: ["youtube"], // Repost to YouTube
241
+ youtube: {
242
+ title: "Viral TikTok Repost",
243
+ description: "Sharing this viral moment from TikTok",
244
+ tags: ["tiktok", "viral", "repost"],
245
+ },
246
+ });
247
+
248
+ console.log("Reposted from TikTok to YouTube:", postId);
249
+ ```
250
+
251
+ **Example - Repost from YouTube Shorts:**
252
+
253
+ ```typescript
254
+ // Repost YouTube Shorts to TikTok
255
+ const postId = await client.publishShortVideo({
256
+ workspaceId: "workspace-123",
257
+ video: "https://www.youtube.com/shorts/abc123", // YouTube Shorts URL
258
+ platforms: ["tiktok"],
259
+ tiktok: {
260
+ caption: "Check out this YouTube Short! #YouTubeShorts",
261
+ privacy_level: "public",
262
+ disable_duet: false,
263
+ disable_stitch: false,
264
+ disable_comment: false,
265
+ },
266
+ });
267
+
268
+ console.log("Reposted from YouTube to TikTok:", postId);
269
+ ```
270
+
271
+ **Example - Repost from Facebook:**
272
+
273
+ ```typescript
274
+ // Repost Facebook video to other platforms
275
+ const postId = await client.publishShortVideo({
276
+ workspaceId: "workspace-123",
277
+ video: "https://www.facebook.com/reel/1234567890", // Facebook Reel URL
278
+ platforms: ["youtube", "tiktok"],
279
+ youtube: {
280
+ title: "Facebook Viral Moment",
281
+ description: "Reposting this viral moment from Facebook",
282
+ tags: ["facebook", "viral", "repost"],
283
+ },
284
+ tiktok: {
285
+ caption: "Viral moment from Facebook! #Viral",
286
+ privacy_level: "public",
287
+ disable_duet: false,
288
+ disable_stitch: false,
289
+ disable_comment: false,
290
+ },
291
+ });
292
+
293
+ console.log("Reposted from Facebook:", postId);
294
+ ```
295
+
296
+ **Example - Scheduled Publishing:**
297
+
298
+ ```typescript
299
+ // Schedule video for future publication
300
+ const publishDate = new Date("2024-12-25T12:00:00Z"); // Christmas at noon
301
+
302
+ const postId = await client.publishShortVideo({
303
+ workspaceId: "workspace-123",
304
+ video: videoFile,
305
+ platforms: ["youtube", "tiktok"],
306
+ schedule: publishDate, // Schedule for specific date/time
307
+ youtube: {
308
+ title: "Merry Christmas! πŸŽ„",
309
+ description: "Holiday greetings from our team",
310
+ tags: ["christmas", "holiday", "greetings"],
311
+ },
312
+ tiktok: {
313
+ caption: "Merry Christmas everyone! πŸŽ…πŸŽ„ #Christmas",
314
+ privacy_level: "public",
315
+ disable_duet: false,
316
+ disable_stitch: false,
317
+ disable_comment: false,
318
+ },
319
+ });
320
+
321
+ console.log("Scheduled for", publishDate, "- Post ID:", postId);
322
+ ```
323
+
324
+ ---
325
+
326
+ ### list()
327
+
328
+ Search and retrieve publishing posts with pagination and filtering options.
329
+
330
+ **Parameters:**
331
+
332
+ - `params` (IListParams, optional): Search and filter options
333
+ - `workspaceId` (string, optional): Filter by workspace ID
334
+ - `currentStatus` (string, optional): Filter by post status ('pending', 'processing', 'done', 'error', etc.)
335
+ - `tag` (string, optional): Filter by custom tag
336
+ - `refId` (string, optional): Filter by reference ID
337
+ - `pagination` (IPaginationParams, optional): Pagination settings
338
+ - `page` (number): Page number (default: 1)
339
+ - `pageSize` (number): Items per page (default: 10)
340
+
341
+ **Returns:** `Promise<ISearchSocialPublisherPostResponse>` - Paginated post list
342
+
343
+ **Response Structure:**
344
+
345
+ ```typescript
346
+ {
347
+ items: Array<{
348
+ _id: string; // Post ID
349
+ numbering: string; // Post number (e.g., "T-12345")
350
+ caption: string; // Post caption/title
351
+ createdAt: Date; // Creation timestamp
352
+ currentStatus: string; // Overall post status
353
+ isAllowYoutube: boolean; // YouTube enabled
354
+ isAllowFacebookPage: boolean; // Facebook enabled
355
+ isAllowInstagram: boolean; // Instagram enabled
356
+ isAllowTiktok: boolean; // TikTok enabled
357
+ workspaceName: string; // Workspace name
358
+ scheduleType: "schedule" | "now"; // Schedule type
359
+ scheduleScheduledAt: Date | null; // Scheduled date
360
+ scheduleExecutedAt: Date | null; // Execution date
361
+ refId: string; // Reference ID
362
+ tag: string; // Custom tag
363
+ apiKeyName: string; // API key name
364
+ }>;
365
+ pagination: {
366
+ page: number; // Current page
367
+ pageSize: number; // Items per page
368
+ totalCount: number; // Total posts
369
+ totalPages: number; // Total pages
370
+ }
371
+ }
372
+ ```
373
+
374
+ **Example:**
375
+
376
+ ```typescript
377
+ // Get all posts with pagination
378
+ const posts = await client.list(
379
+ {},
380
+ {
381
+ page: 1,
382
+ pageSize: 20,
383
+ },
384
+ );
385
+
386
+ console.log(`Total posts: ${posts.pagination.totalCount}`);
387
+ console.log(`Showing page ${posts.pagination.page} of ${posts.pagination.totalPages}`);
388
+
389
+ // Display posts
390
+ posts.items.forEach((post) => {
391
+ console.log(`${post.numbering}: ${post.caption}`);
392
+ console.log(` Status: ${post.currentStatus}`);
393
+ console.log(
394
+ ` Platforms: ${[post.isAllowYoutube && "YouTube", post.isAllowTiktok && "TikTok", post.isAllowFacebookPage && "Facebook", post.isAllowInstagram && "Instagram"].filter(Boolean).join(", ")}`,
395
+ );
396
+ });
397
+
398
+ // Filter by workspace
399
+ const workspacePosts = await client.list(
400
+ {
401
+ workspaceId: "workspace-123",
402
+ },
403
+ {
404
+ page: 1,
405
+ pageSize: 50,
406
+ },
407
+ );
408
+
409
+ console.log(`Workspace has ${workspacePosts.items.length} posts`);
410
+
411
+ // Filter by status
412
+ const pendingPosts = await client.list(
413
+ {
414
+ currentStatus: "pending",
415
+ },
416
+ {
417
+ page: 1,
418
+ pageSize: 10,
419
+ },
420
+ );
421
+
422
+ console.log(`Pending posts: ${pendingPosts.pagination.totalCount}`);
423
+
424
+ // Filter by tag
425
+ const campaignPosts = await client.list(
426
+ {
427
+ tag: "summer-campaign",
428
+ },
429
+ {
430
+ page: 1,
431
+ pageSize: 100,
432
+ },
433
+ );
434
+
435
+ console.log(`Campaign posts: ${campaignPosts.items.length}`);
436
+
437
+ // Filter by reference ID
438
+ const specificPost = await client.list(
439
+ {
440
+ refId: "PROD-001",
441
+ },
442
+ {
443
+ page: 1,
444
+ pageSize: 1,
445
+ },
446
+ );
447
+
448
+ if (specificPost.items.length > 0) {
449
+ console.log("Found post:", specificPost.items[0].caption);
450
+ }
451
+ ```
452
+
453
+ ---
454
+
455
+ ### getStatus()
456
+
457
+ Retrieve detailed status information for a specific publishing post, including platform-specific progress and post URLs.
458
+
459
+ **Parameters:**
460
+
461
+ - `id` (string): Post ID
462
+
463
+ **Returns:** `Promise<ISocialPublisherPostStatusResponse>` - Detailed post status
464
+
465
+ **Response Structure:**
466
+
467
+ ```typescript
468
+ {
469
+ _id: string; // Post ID
470
+ numbering: string; // Post number
471
+ caption: string; // Post caption
472
+ currentStatus: string; // Overall status
473
+ createdAt: Date; // Creation time
474
+ startedAt: Date; // Start time
475
+
476
+ // Platform-specific details
477
+ youtube?: {
478
+ tags: string[];
479
+ postInfo: {
480
+ isAllow: boolean; // Platform enabled
481
+ currentStatus: string; // Platform status
482
+ videoURL: string; // Published video URL
483
+ socialPublisherAccount: { // Account details
484
+ name: string;
485
+ thumbnail: string;
486
+ platformAccountId: string;
487
+ };
488
+ };
489
+ };
490
+
491
+ tiktok?: { /* Similar structure */ };
492
+ facebook?: { /* Similar structure */ };
493
+ instagram?: { /* Similar structure */ };
494
+
495
+ // Workspace info
496
+ workspace: {
497
+ _id: string;
498
+ name: string;
499
+ description: string;
500
+ };
501
+
502
+ // Schedule info
503
+ schedule: {
504
+ type: 'schedule' | 'now';
505
+ scheduledAt: Date;
506
+ executedAt: Date;
507
+ };
508
+ }
509
+ ```
510
+
511
+ **Example:**
512
+
513
+ ```typescript
514
+ // Get post status
515
+ const status = await client.getStatus("post-id-here");
516
+
517
+ console.log("Post:", status.numbering);
518
+ console.log("Overall Status:", status.currentStatus);
519
+ console.log("Created:", status.createdAt);
520
+
521
+ // Check YouTube status
522
+ if (status.youtube) {
523
+ console.log("\nYouTube:");
524
+ console.log(" Status:", status.youtube.postInfo.currentStatus);
525
+ console.log(" Channel:", status.youtube.postInfo.socialPublisherAccount.name);
526
+
527
+ if (status.youtube.postInfo.videoURL) {
528
+ console.log(" Video URL:", status.youtube.postInfo.videoURL);
529
+ }
530
+ }
531
+
532
+ // Check TikTok status
533
+ if (status.tiktok) {
534
+ console.log("\nTikTok:");
535
+ console.log(" Status:", status.tiktok.postInfo.currentStatus);
536
+ console.log(" Account:", status.tiktok.postInfo.socialPublisherAccount.name);
537
+
538
+ if (status.tiktok.postInfo.videoURL) {
539
+ console.log(" Video URL:", status.tiktok.postInfo.videoURL);
540
+ }
541
+ }
542
+
543
+ // Check Facebook status
544
+ if (status.facebook) {
545
+ console.log("\nFacebook:");
546
+ console.log(" Status:", status.facebook.postInfo.currentStatus);
547
+ console.log(" Page:", status.facebook.postInfo.socialPublisherAccount.name);
548
+ }
549
+
550
+ // Check Instagram status
551
+ if (status.instagram) {
552
+ console.log("\nInstagram:");
553
+ console.log(" Status:", status.instagram.postInfo.currentStatus);
554
+ console.log(" Account:", status.instagram.postInfo.socialPublisherAccount.name);
555
+ }
556
+
557
+ // Handle errors
558
+ if (status.currentStatus === "error") {
559
+ console.error("Post failed!");
560
+
561
+ // Check which platforms failed
562
+ const failures = [];
563
+ if (status.youtube?.postInfo.currentStatus === "error") failures.push("YouTube");
564
+ if (status.tiktok?.postInfo.currentStatus === "error") failures.push("TikTok");
565
+ if (status.facebook?.postInfo.currentStatus === "error") failures.push("Facebook");
566
+ if (status.instagram?.postInfo.currentStatus === "error") failures.push("Instagram");
567
+
568
+ console.error("Failed platforms:", failures.join(", "));
569
+ }
570
+
571
+ // Monitor post progress
572
+ async function waitForCompletion(postId: string, maxWaitMs = 300000) {
573
+ const startTime = Date.now();
574
+
575
+ while (Date.now() - startTime < maxWaitMs) {
576
+ const status = await client.getStatus(postId);
577
+
578
+ console.log(`Status: ${status.currentStatus}`);
579
+
580
+ if (status.currentStatus === "done") {
581
+ console.log("βœ“ Publishing complete!");
582
+ return status;
583
+ }
584
+
585
+ if (status.currentStatus === "error") {
586
+ throw new Error("Publishing failed");
587
+ }
588
+
589
+ // Wait 5 seconds before checking again
590
+ await new Promise((resolve) => setTimeout(resolve, 5000));
591
+ }
592
+
593
+ throw new Error("Timeout waiting for post completion");
594
+ }
595
+
596
+ const finalStatus = await waitForCompletion("post-id");
597
+ console.log("All platforms published successfully");
598
+ ```
599
+
600
+ ---
601
+
602
+ ### getDefaultSettings()
603
+
604
+ Retrieve default configuration settings for social media publishing, including platform limits and default values.
605
+
606
+ **Parameters:** None
607
+
608
+ **Returns:** `Promise<IDefaultSettingsResponse>` - Default settings configuration
609
+
610
+ **Example:**
611
+
612
+ ```typescript
613
+ // Get default settings
614
+ const settings = await client.getDefaultSettings();
615
+
616
+ console.log("Default Settings:", settings);
617
+
618
+ // Use defaults in your application
619
+ console.log("Max video size:", client.maxVideoUploadSizeBytes, "bytes");
620
+ console.log("Max thumbnail size:", client.maxImageUploadSizeBytes, "bytes");
621
+ ```
622
+
623
+ ---
624
+
625
+ ### getNextAndPrevious()
626
+
627
+ Get the IDs of the next and previous posts for navigation purposes.
628
+
629
+ **Parameters:**
630
+
631
+ - `id` (string): Current post ID
632
+
633
+ **Returns:** `Promise<ISocialPublisherPostNextPreviousResponse>` - Next and previous post IDs
634
+
635
+ **Response Structure:**
636
+
637
+ ```typescript
638
+ {
639
+ nextId?: string; // Next post ID (if exists)
640
+ previousId?: string; // Previous post ID (if exists)
641
+ }
642
+ ```
643
+
644
+ **Example:**
645
+
646
+ ```typescript
647
+ // Get navigation IDs
648
+ const navigation = await client.getNextAndPrevious("current-post-id");
649
+
650
+ if (navigation.nextId) {
651
+ console.log("Next post:", navigation.nextId);
652
+
653
+ // Navigate to next post
654
+ const nextPost = await client.getStatus(navigation.nextId);
655
+ console.log("Next post caption:", nextPost.caption);
656
+ }
657
+
658
+ if (navigation.previousId) {
659
+ console.log("Previous post:", navigation.previousId);
660
+
661
+ // Navigate to previous post
662
+ const prevPost = await client.getStatus(navigation.previousId);
663
+ console.log("Previous post caption:", prevPost.caption);
664
+ }
665
+
666
+ // Build post navigation
667
+ async function navigateForward(startPostId: string, count: number) {
668
+ const posts = [];
669
+ let currentId = startPostId;
670
+
671
+ for (let i = 0; i < count; i++) {
672
+ const status = await client.getStatus(currentId);
673
+ posts.push(status);
674
+
675
+ const nav = await client.getNextAndPrevious(currentId);
676
+ if (!nav.nextId) break;
677
+
678
+ currentId = nav.nextId;
679
+ }
680
+
681
+ return posts;
682
+ }
683
+
684
+ const next5Posts = await navigateForward("post-id", 5);
685
+ console.log(`Retrieved ${next5Posts.length} posts`);
686
+ ```
687
+
688
+ ---
689
+
690
+ ## πŸ”„ Complete Workflow Example
691
+
692
+ ```typescript
693
+ import { HttpClient } from "@posty5/core";
694
+ import { SocialPublisherPostClient } from "@posty5/social-publisher-post";
695
+ import * as fs from "fs";
696
+
697
+ // Initialize client
698
+ const httpClient = new HttpClient({
699
+ apiKey: process.env.POSTY5_API_KEY!,
700
+ debug: false,
701
+ });
702
+
703
+ const client = new SocialPublisherPostClient(httpClient);
704
+
705
+ async function publishVideoWorkflow() {
706
+ try {
707
+ // 1. Prepare video and thumbnail
708
+ console.log("Preparing media files...");
709
+ const videoBuffer = fs.readFileSync("./content/video.mp4");
710
+ const thumbBuffer = fs.readFileSync("./content/thumbnail.jpg");
711
+
712
+ const video = new File([videoBuffer], "video.mp4", { type: "video/mp4" });
713
+ const thumbnail = new File([thumbBuffer], "thumb.jpg", { type: "image/jpeg" });
714
+
715
+ // 2. Publish to multiple platforms
716
+ console.log("Publishing video...");
717
+ const postId = await client.publishShortVideo({
718
+ workspaceId: "workspace-123",
719
+ video: video,
720
+ thumbnail: thumbnail,
721
+ platforms: ["youtube", "tiktok"],
722
+ youtube: {
723
+ title: "Product Demo 2024",
724
+ description: "Check out our latest product features",
725
+ tags: ["product", "demo", "2024"],
726
+ },
727
+ tiktok: {
728
+ caption: "New product alert! πŸš€ #Product #Tech",
729
+ privacy_level: "public",
730
+ disable_duet: false,
731
+ disable_stitch: false,
732
+ disable_comment: false,
733
+ },
734
+ tag: "product-demo",
735
+ refId: "DEMO-2024-001",
736
+ });
737
+
738
+ console.log("βœ“ Post created:", postId);
739
+
740
+ // 3. Monitor publishing progress
741
+ console.log("\nMonitoring progress...");
742
+ let attempts = 0;
743
+ const maxAttempts = 60; // 5 minutes (5 second intervals)
744
+
745
+ while (attempts < maxAttempts) {
746
+ const status = await client.getStatus(postId);
747
+
748
+ console.log(` Status: ${status.currentStatus}`);
749
+
750
+ // Check individual platforms
751
+ if (status.youtube) {
752
+ console.log(` YouTube: ${status.youtube.postInfo.currentStatus}`);
753
+ }
754
+ if (status.tiktok) {
755
+ console.log(` TikTok: ${status.tiktok.postInfo.currentStatus}`);
756
+ }
757
+
758
+ // Check if completed
759
+ if (status.currentStatus === "done") {
760
+ console.log("\nβœ“ Publishing complete!");
761
+
762
+ // Get video URLs
763
+ if (status.youtube?.postInfo.videoURL) {
764
+ console.log(" YouTube URL:", status.youtube.postInfo.videoURL);
765
+ }
766
+ if (status.tiktok?.postInfo.videoURL) {
767
+ console.log(" TikTok URL:", status.tiktok.postInfo.videoURL);
768
+ }
769
+
770
+ return status;
771
+ }
772
+
773
+ // Check for errors
774
+ if (status.currentStatus === "error") {
775
+ console.error("\nβœ— Publishing failed");
776
+ throw new Error("Post failed");
777
+ }
778
+
779
+ // Wait before checking again
780
+ await new Promise((resolve) => setTimeout(resolve, 5000));
781
+ attempts++;
782
+ }
783
+
784
+ throw new Error("Timeout: Post did not complete within 5 minutes");
785
+ } catch (error) {
786
+ console.error("Error:", error.message);
787
+ throw error;
788
+ }
789
+ }
790
+
791
+ // Run the workflow
792
+ publishVideoWorkflow()
793
+ .then(() => console.log("\nWorkflow completed successfully"))
794
+ .catch((err) => console.error("\nWorkflow failed:", err));
795
+ ```
796
+
797
+ ---
798
+
799
+ ## πŸ“˜ TypeScript Support
800
+
801
+ Full TypeScript support with exported interfaces:
802
+
803
+ ```typescript
804
+ import {
805
+ // Client
806
+ SocialPublisherPostClient,
807
+
808
+ // Publishing options
809
+ IPublishOptions,
810
+
811
+ // Platform configurations
812
+ IYouTubeConfig,
813
+ ITikTokConfig,
814
+ IFacebookPageConfig,
815
+ IInstagramConfig,
816
+
817
+ // Schedule configuration
818
+ IScheduleConfig,
819
+
820
+ // Search parameters
821
+ IListParams,
822
+
823
+ // Response interfaces
824
+ ISocialPublisherPostStatusResponse,
825
+ ISearchSocialPublisherPostResponse,
826
+ ISocialPublisherPostNextPreviousResponse,
827
+ IDefaultSettingsResponse,
828
+
829
+ // Response types
830
+ ISocialPublisherPostResponse,
831
+ ISocialPublisherWorkspace,
832
+ ISocialPublisherAccount,
833
+
834
+ // Status types
835
+ SocialPublisherPostStatusType, // 'pending' | 'processing' | 'done' | 'error' | ...
836
+ SocialPublisherPostSourceType, // 'video-file' | 'video-url' | 'facebook-video' | ...
837
+ SocialPublisherAccountStatusType, // 'active' | 'inactive' | 'authenticationExpired'
838
+ } from "@posty5/social-publisher-post";
839
+ ```
840
+
841
+ ### Platform Configuration Types
842
+
843
+ **YouTube Configuration:**
844
+
845
+ ```typescript
846
+ interface IYouTubeConfig {
847
+ title: string; // Video title (required)
848
+ description: string; // Video description (required)
849
+ tags: string[]; // Video tags (required)
850
+ madeForKids?: boolean; // Mark as made for kids (optional)
851
+ defaultLanguage?: string; // Default language code (optional)
852
+ defaultAudioLanguage?: string; // Audio language code (optional)
853
+ categoryId?: string; // YouTube category ID (optional)
854
+ localizationLanguages?: string[]; // Localization languages (optional)
855
+ }
856
+ ```
857
+
858
+ **TikTok Configuration:**
859
+
860
+ ```typescript
861
+ interface ITikTokConfig {
862
+ caption: string; // Video caption (required)
863
+ privacy_level: string; // 'public' | 'SELF_ONLY' | 'MUTUAL_FOLLOW_FRIENDS' (required)
864
+ disable_duet: boolean; // Disable duet feature (required)
865
+ disable_stitch: boolean; // Disable stitch feature (required)
866
+ disable_comment: boolean; // Disable comments (required)
867
+ }
868
+ ```
869
+
870
+ **Facebook Configuration:**
871
+
872
+ ```typescript
873
+ interface IFacebookPageConfig {
874
+ description: string; // Post description (required)
875
+ title?: string; // Post title (optional)
876
+ }
877
+ ```
878
+
879
+ **Instagram Configuration:**
880
+
881
+ ```typescript
882
+ interface IInstagramConfig {
883
+ description: string; // Post description (required)
884
+ share_to_feed?: boolean; // Share to feed (optional)
885
+ is_published_to_both_feed_and_story?: boolean; // Publish to both (optional)
886
+ }
887
+ ```
888
+
889
+ ---
890
+
891
+ ## πŸ“¦ Related Packages
892
+
893
+ This SDK ecosystem contains the following tool packages:
894
+
895
+ | Package | Description | Version | GitHub | NPM |
896
+ | --- | --- | --- | --- | --- |
897
+ | @posty5/short-link | URL shortener client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-short-link) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/short-link) |
898
+ | @posty5/qr-code | QR code generator client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-qr-code) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/qr-code) |
899
+ | @posty5/html-hosting | HTML hosting client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/html-hosting) |
900
+ | @posty5/html-hosting-variables | HTML hosting variables client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-variables) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/html-hosting-variables) |
901
+ | @posty5/html-hosting-form-submission | Form submission client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-html-hosting-form-submission) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/html-hosting-form-submission) |
902
+ | @posty5/social-publisher-workspace | Social publisher workspace client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-workspace) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/social-publisher-workspace) |
903
+ | @posty5/social-publisher-post | Social publisher post client | 1.0.2 | [πŸ“– Docs](https://github.com/Posty5/npm-sdk/tree/main/posty5-social-publisher-post) | [πŸ“¦ NPM](https://www.npmjs.com/package/@posty5/social-publisher-post) |
904
+
905
+ ---
906
+
907
+ ## πŸ’» Node.js Compatibility
908
+
909
+ - **Node.js**: >= 16.0.0
910
+ - **Module Systems**: ESM and CommonJS
911
+ - **TypeScript**: Full type definitions included
912
+
913
+ ---
914
+
915
+ ## πŸ†˜ Support
916
+
917
+ We're here to help you succeed with Posty5!
918
+
919
+ ### Get Help
920
+
921
+ - **Documentation**: [https://guide.posty5.com](https://guide.posty5.com)
922
+ - **Contact Us**: [https://posty5.com/contact-us](https://posty5.com/contact-us)
923
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/Posty5/npm-sdk/issues)
924
+ - **API Status**: Check API status and uptime at [https://status.posty5.com](https://status.posty5.com)
925
+
926
+ ### Common Issues
927
+
928
+ 1. **Authentication Errors**
929
+ - Ensure your API key is valid and active
930
+ - Get your API key from [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
931
+
932
+ 2. **Network Errors**
933
+ - Check your internet connection
934
+ - Verify firewall settings allow connections to `api.posty5.com`
935
+
936
+ 3. **Rate Limiting**
937
+ - The SDK includes automatic retry logic
938
+ - Check your API plan limits in the dashboard
939
+
940
+ ---
941
+
942
+ ## πŸ“„ License
943
+
944
+ MIT License - see [LICENSE](./LICENSE) file for details.
945
+
946
+ ---
947
+
948
+ ## πŸ”— Useful Links
949
+
950
+ - **Website**: [https://posty5.com](https://posty5.com)
951
+ - **Dashboard**: [studio.posty5.com/account/settings?tab=APIKeys](studio.posty5.com/account/settings?tab=APIKeys)
952
+ - **API Documentation**: [https://docs.posty5.com](https://docs.posty5.com)
953
+ - **GitHub**: [https://github.com/Posty5/npm-sdk](https://github.com/Posty5/npm-sdk)
954
+
955
+ ---
956
+
957
+ Made with ❀️ by the Posty5 team