@posty5/social-publisher-post 4.2.0 β 5.1.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 +47 -0
- package/dist/index.d.mts +160 -9
- package/dist/index.d.ts +160 -9
- package/dist/index.js +1074 -259
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1075 -260
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -106,6 +106,33 @@ console.log("YouTube:", status.youtube?.postInfo.currentStatus);
|
|
|
106
106
|
|
|
107
107
|
---
|
|
108
108
|
|
|
109
|
+
## π Versioned writes (5.0.0)
|
|
110
|
+
|
|
111
|
+
Every write to an existing document carries the version you read, so two
|
|
112
|
+
people (or two scripts) can never silently overwrite each other.
|
|
113
|
+
|
|
114
|
+
- **Where `__v` comes from:** every entity this SDK returns (`get`, `list`,
|
|
115
|
+
and every write) has `__v`. Keep the `__v` a write returns for your next write.
|
|
116
|
+
- **A stale version** throws `ConflictError` (409). It carries
|
|
117
|
+
`currentVersion`, the document's version now.
|
|
118
|
+
- **Merging deliberately:** reload, re-apply your change, and resend with the
|
|
119
|
+
fresh version (`currentVersion`). There is no "overwrite anyway" flag;
|
|
120
|
+
resending blindly is exactly the lost update this prevents.
|
|
121
|
+
- Versioned writes are never retried automatically.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { ConflictError } from "@posty5/core";
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const post = await client.getStatus(id);
|
|
128
|
+
await client.reschedulePost(id, { schedule: 'now' }, post.__v);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof ConflictError) {
|
|
131
|
+
// error.currentVersion: reload, merge, and resend with the fresh __v
|
|
132
|
+
} else throw error;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
109
136
|
## Γ°ΕΈβΕ‘ API Reference & Examples
|
|
110
137
|
|
|
111
138
|
### publishShortVideo()
|
|
@@ -517,6 +544,8 @@ Search and retrieve publishing posts with pagination and filtering options.
|
|
|
517
544
|
- `currentStatus` (string, optional): Filter by post status ('pending', 'processing', 'done', 'error', etc.)
|
|
518
545
|
- `tag` (string, optional): Filter by custom tag
|
|
519
546
|
- `refId` (string, optional): Filter by reference ID
|
|
547
|
+
- `fromDate` / `toDate` (string, optional): Created-at window, `YYYY-MM-DD`.
|
|
548
|
+
Applied only when both are sent (one alone filters nothing), in whole UTC days.
|
|
520
549
|
- `pagination` (IPaginationParams, optional): Pagination settings
|
|
521
550
|
- `page` (number): Page number (default: 1)
|
|
522
551
|
- `pageSize` (number): Items per page (default: 10)
|
|
@@ -631,6 +660,9 @@ const specificPost = await client.list(
|
|
|
631
660
|
if (specificPost.items.length > 0) {
|
|
632
661
|
console.log("Found post:", specificPost.items[0].caption);
|
|
633
662
|
}
|
|
663
|
+
|
|
664
|
+
// Posts created in a date window (both bounds, YYYY-MM-DD, whole UTC days)
|
|
665
|
+
const lastWeekPosts = await client.list({ fromDate: "2026-10-01", toDate: "2026-10-07" });
|
|
634
666
|
```
|
|
635
667
|
|
|
636
668
|
---
|
|
@@ -1126,6 +1158,21 @@ We're here to help you succeed with Posty5!
|
|
|
1126
1158
|
|
|
1127
1159
|
---
|
|
1128
1160
|
|
|
1161
|
+
## π Text posts and stories (4.6.0)
|
|
1162
|
+
|
|
1163
|
+
```ts
|
|
1164
|
+
await posts.createTextPostToWorkspace({ workspaceId, caption: "Launching today!", threads: { topic_tag: "launch" } });
|
|
1165
|
+
await posts.createTextPostToAccount({ accountId, caption: "Hello X", twitter: { reply_settings: "following" } });
|
|
1166
|
+
|
|
1167
|
+
await posts.createStoryPostToWorkspace({ workspaceId, kind: "image", image: { source: "image-url", externalUrl } });
|
|
1168
|
+
await posts.createStoryPostToAccount({ accountId, platform: "instagram", kind: "video", source: "video-url", videoURL });
|
|
1169
|
+
```
|
|
1170
|
+
|
|
1171
|
+
Each answers `{ _id, refusedTargets?, truncatedTargets?, skippedPlatforms? }`.
|
|
1172
|
+
Story media is by URL in this release.
|
|
1173
|
+
|
|
1174
|
+
---
|
|
1175
|
+
|
|
1129
1176
|
## Γ°ΕΈββ License
|
|
1130
1177
|
|
|
1131
1178
|
MIT License - see [LICENSE](./LICENSE) file for details.
|
package/dist/index.d.mts
CHANGED
|
@@ -27,6 +27,96 @@ type SocialPublisherAccountPlatformType = "youtube" | "facebook" | "tiktok";
|
|
|
27
27
|
type SocialPublisherAccountAccountType = "facebook" | "instagram" | "youtube" | "tiktok";
|
|
28
28
|
type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
|
|
29
29
|
|
|
30
|
+
/** Facebook's override for a text post. Without it the shared caption is used. */
|
|
31
|
+
interface IFacebookTextConfig {
|
|
32
|
+
/** The status text. */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Kept for other surfaces; Facebook ignores it. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** An http(s) link Facebook previews. Posty5 never requests it. */
|
|
37
|
+
link?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Threads' override for a text post β at most 500 characters. */
|
|
40
|
+
interface IThreadsTextConfig {
|
|
41
|
+
text?: string;
|
|
42
|
+
reply_control?: "everyone" | "accounts_you_follow" | "mentioned_only" | "parent_post_author_only" | "followers_only";
|
|
43
|
+
/** The ONE topic Threads links (letters, digits, `_`). */
|
|
44
|
+
topic_tag?: string;
|
|
45
|
+
/** An http(s) link shown as a preview card. */
|
|
46
|
+
link?: string;
|
|
47
|
+
}
|
|
48
|
+
/** X's settings for a text post (requires the Pro plan or higher on the API side). */
|
|
49
|
+
interface ITwitterTextConfig {
|
|
50
|
+
/** At most 280 weighted characters. */
|
|
51
|
+
text?: string;
|
|
52
|
+
reply_settings?: "everyone" | "mentionedUsers" | "following";
|
|
53
|
+
/** 2β4 options of up to 25 characters; 5β10080 minutes. Not with `quote_tweet_id`. */
|
|
54
|
+
poll?: {
|
|
55
|
+
options: string[];
|
|
56
|
+
duration_minutes?: number;
|
|
57
|
+
};
|
|
58
|
+
quote_tweet_id?: string;
|
|
59
|
+
}
|
|
60
|
+
/** UTM parameters added to tracked links. */
|
|
61
|
+
interface IPostUtmConfig {
|
|
62
|
+
medium?: string;
|
|
63
|
+
campaign?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Fields every text post takes, whichever target. */
|
|
66
|
+
interface ICreateTextPostBase {
|
|
67
|
+
/** The post's text. */
|
|
68
|
+
caption: string;
|
|
69
|
+
facebook?: IFacebookTextConfig;
|
|
70
|
+
threads?: IThreadsTextConfig;
|
|
71
|
+
twitter?: ITwitterTextConfig;
|
|
72
|
+
schedule?: IScheduleConfig;
|
|
73
|
+
comments?: ICommentRequest[];
|
|
74
|
+
/** Saved hashtag groups merged into the caption (at most 5). */
|
|
75
|
+
hashtagGroupIds?: string[];
|
|
76
|
+
/** At most 30. */
|
|
77
|
+
hashtags?: string[];
|
|
78
|
+
/** Turn links in the caption into tracked short links. */
|
|
79
|
+
trackLinks?: boolean;
|
|
80
|
+
utm?: IPostUtmConfig;
|
|
81
|
+
refId?: string;
|
|
82
|
+
tag?: string;
|
|
83
|
+
}
|
|
84
|
+
/** A text post to every text-capable account in a workspace. */
|
|
85
|
+
interface ICreateTextPostToWorkspaceRequest extends ICreateTextPostBase {
|
|
86
|
+
workspaceId: string;
|
|
87
|
+
}
|
|
88
|
+
/** A text post to one account. */
|
|
89
|
+
interface ICreateTextPostToAccountRequest extends ICreateTextPostBase {
|
|
90
|
+
accountId: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A story. Media by URL only in this SDK release: an image as
|
|
94
|
+
* `image: { source: "image-url", externalUrl }`, a video as
|
|
95
|
+
* `source: "video-url"` + `videoURL`.
|
|
96
|
+
*/
|
|
97
|
+
interface ICreateStoryPostBase {
|
|
98
|
+
kind: "image" | "video";
|
|
99
|
+
/** For `kind: "image"`. */
|
|
100
|
+
image?: IImageMediaRequest;
|
|
101
|
+
/** For `kind: "video"`. */
|
|
102
|
+
source?: "video-url";
|
|
103
|
+
/** For `kind: "video"`: a direct, public video URL. */
|
|
104
|
+
videoURL?: string;
|
|
105
|
+
schedule?: IScheduleConfig;
|
|
106
|
+
refId?: string;
|
|
107
|
+
tag?: string;
|
|
108
|
+
}
|
|
109
|
+
/** A story to every story-capable account in a workspace. */
|
|
110
|
+
interface ICreateStoryPostToWorkspaceRequest extends ICreateStoryPostBase {
|
|
111
|
+
workspaceId: string;
|
|
112
|
+
}
|
|
113
|
+
/** A story to one account. */
|
|
114
|
+
interface ICreateStoryPostToAccountRequest extends ICreateStoryPostBase {
|
|
115
|
+
accountId: string;
|
|
116
|
+
/** The account's platform β required by the API for a story to one account. */
|
|
117
|
+
platform: "youtube" | "tiktok" | "facebook" | "instagram" | "threads" | "twitter";
|
|
118
|
+
}
|
|
119
|
+
|
|
30
120
|
interface IYouTubeConfig {
|
|
31
121
|
title: string;
|
|
32
122
|
description: string;
|
|
@@ -759,6 +849,19 @@ interface IListParams {
|
|
|
759
849
|
"facebook.postInfo.isAllow"?: boolean;
|
|
760
850
|
"instagram.postInfo.isAllow"?: boolean;
|
|
761
851
|
"tiktok.postInfo.isAllow"?: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Created on or after this day, `YYYY-MM-DD`. Applied only together with
|
|
854
|
+
* `toDate` (and vice versa): the API ignores a lone bound, and this SDK
|
|
855
|
+
* does not check the pair. Matched on the creation date, in whole UTC days
|
|
856
|
+
* (the API rounds `fromDate` to the start of its UTC day).
|
|
857
|
+
*/
|
|
858
|
+
fromDate?: string;
|
|
859
|
+
/**
|
|
860
|
+
* Created on or before this day, `YYYY-MM-DD`. Applied only together with
|
|
861
|
+
* `fromDate` (and vice versa); the API rounds `toDate` to the end of its
|
|
862
|
+
* UTC day.
|
|
863
|
+
*/
|
|
864
|
+
toDate?: string;
|
|
762
865
|
}
|
|
763
866
|
/**
|
|
764
867
|
* Longest video the API accepts for a `longVideo` post: 60 minutes.
|
|
@@ -841,6 +944,21 @@ interface IReschedulePostRequest {
|
|
|
841
944
|
caption?: string;
|
|
842
945
|
}
|
|
843
946
|
|
|
947
|
+
/** What creating a text or story post answers. */
|
|
948
|
+
interface ICreatePostResult {
|
|
949
|
+
/** The created post's id β `getStatus(_id)` follows it. */
|
|
950
|
+
_id: string;
|
|
951
|
+
/** Connected platforms dropped from the post, with why (e.g. X below the Pro plan). */
|
|
952
|
+
refusedTargets?: {
|
|
953
|
+
platform: string;
|
|
954
|
+
reason: string;
|
|
955
|
+
}[];
|
|
956
|
+
/** Platforms whose text was built from the shared caption and cut to fit (X). */
|
|
957
|
+
truncatedTargets?: string[];
|
|
958
|
+
/** Connected platforms that cannot take this post type. */
|
|
959
|
+
skippedPlatforms?: string[];
|
|
960
|
+
}
|
|
961
|
+
|
|
844
962
|
interface IUploadConfig {
|
|
845
963
|
url: string;
|
|
846
964
|
fields: Record<string, string>;
|
|
@@ -897,6 +1015,8 @@ interface IRemovePostPlatformResult {
|
|
|
897
1015
|
}
|
|
898
1016
|
interface IRemovePostResponse {
|
|
899
1017
|
_id: string;
|
|
1018
|
+
/** The post's new version */
|
|
1019
|
+
__v: number;
|
|
900
1020
|
results: Partial<Record<"youtube" | "facebook" | "instagram" | "tiktok", IRemovePostPlatformResult>>;
|
|
901
1021
|
}
|
|
902
1022
|
interface ISocialPublisherPostStatusLog {
|
|
@@ -985,6 +1105,8 @@ interface ISocialPublisherPostPlatform {
|
|
|
985
1105
|
}
|
|
986
1106
|
interface ISocialPublisherPostResponse {
|
|
987
1107
|
_id: string;
|
|
1108
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1109
|
+
__v: number;
|
|
988
1110
|
numbering: string;
|
|
989
1111
|
caption: string;
|
|
990
1112
|
createdAt: Date;
|
|
@@ -1027,6 +1149,8 @@ interface ISocialPublisherPostResponse {
|
|
|
1027
1149
|
}
|
|
1028
1150
|
interface ISocialPublisherPostStatusResponse {
|
|
1029
1151
|
_id: string;
|
|
1152
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1153
|
+
__v: number;
|
|
1030
1154
|
numbering: string;
|
|
1031
1155
|
type: "shortVideo" | "longVideo" | "image";
|
|
1032
1156
|
source: SocialPublisherPostSourceType;
|
|
@@ -1300,15 +1424,17 @@ declare class SocialPublisherPostClient {
|
|
|
1300
1424
|
* cannot be removed programmatically and no credits are charged.
|
|
1301
1425
|
*
|
|
1302
1426
|
* @param id - Post ID
|
|
1303
|
-
* @
|
|
1427
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1428
|
+
* @returns Per-platform removal results, `__v` set to the post's new version
|
|
1304
1429
|
*
|
|
1305
1430
|
* @example
|
|
1306
1431
|
* ```ts
|
|
1307
|
-
* const
|
|
1432
|
+
* const post = await client.getStatus("post_123");
|
|
1433
|
+
* const { results } = await client.removePost("post_123", post.__v);
|
|
1308
1434
|
* // results.youtube?.success === true
|
|
1309
1435
|
* ```
|
|
1310
1436
|
*/
|
|
1311
|
-
removePost(id: string): Promise<IRemovePostResponse>;
|
|
1437
|
+
removePost(id: string, version: number): Promise<IRemovePostResponse>;
|
|
1312
1438
|
/**
|
|
1313
1439
|
* Get next and previous post IDs
|
|
1314
1440
|
* @param id - Current Post ID
|
|
@@ -1361,6 +1487,22 @@ declare class SocialPublisherPostClient {
|
|
|
1361
1487
|
* platforms in the request are ignored.
|
|
1362
1488
|
*/
|
|
1363
1489
|
createImagePostToAccount(data: ICreateImagePostToAccountRequest, id?: string): Promise<string>;
|
|
1490
|
+
/**
|
|
1491
|
+
* Publish a text-only post to every text-capable account in a workspace
|
|
1492
|
+
* (Facebook, Threads, X). Platforms that cannot take text are reported in
|
|
1493
|
+
* `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
|
|
1494
|
+
*/
|
|
1495
|
+
createTextPostToWorkspace(data: ICreateTextPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1496
|
+
/** Publish a text-only post to one account. */
|
|
1497
|
+
createTextPostToAccount(data: ICreateTextPostToAccountRequest): Promise<ICreatePostResult>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Publish a story to every story-capable account in a workspace. Media by URL
|
|
1500
|
+
* only in this release: `image: { source: "image-url", externalUrl }`, or
|
|
1501
|
+
* `source: "video-url"` with `videoURL`.
|
|
1502
|
+
*/
|
|
1503
|
+
createStoryPostToWorkspace(data: ICreateStoryPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1504
|
+
/** Publish a story to one account. Media by URL only, as for the workspace form. */
|
|
1505
|
+
createStoryPostToAccount(data: ICreateStoryPostToAccountRequest): Promise<ICreatePostResult>;
|
|
1364
1506
|
/**
|
|
1365
1507
|
* Handle thumbnail upload - accepts either File or URL string
|
|
1366
1508
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -1509,11 +1651,18 @@ declare class SocialPublisherPostClient {
|
|
|
1509
1651
|
*
|
|
1510
1652
|
* @example
|
|
1511
1653
|
* ```ts
|
|
1512
|
-
* await client.
|
|
1513
|
-
* await client.reschedulePost("post_123", { schedule: "
|
|
1654
|
+
* const post = await client.getStatus("post_123");
|
|
1655
|
+
* const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
|
|
1656
|
+
* await client.reschedulePost("post_123", { schedule: "now" }, __v);
|
|
1514
1657
|
* ```
|
|
1658
|
+
*
|
|
1659
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1660
|
+
* @returns `{ _id, __v }`, `__v` being the new version
|
|
1515
1661
|
*/
|
|
1516
|
-
reschedulePost(id: string, data: IReschedulePostRequest): Promise<
|
|
1662
|
+
reschedulePost(id: string, data: IReschedulePostRequest, version: number): Promise<{
|
|
1663
|
+
_id: string;
|
|
1664
|
+
__v: number;
|
|
1665
|
+
}>;
|
|
1517
1666
|
/**
|
|
1518
1667
|
* Delete a post that has not published yet, releasing its uploaded media in
|
|
1519
1668
|
* the same request.
|
|
@@ -1524,10 +1673,12 @@ declare class SocialPublisherPostClient {
|
|
|
1524
1673
|
*
|
|
1525
1674
|
* @example
|
|
1526
1675
|
* ```ts
|
|
1527
|
-
* await client.deletePost("post_123");
|
|
1676
|
+
* await client.deletePost("post_123", post.__v);
|
|
1528
1677
|
* ```
|
|
1678
|
+
*
|
|
1679
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1529
1680
|
*/
|
|
1530
|
-
deletePost(id: string): Promise<void>;
|
|
1681
|
+
deletePost(id: string, version: number): Promise<void>;
|
|
1531
1682
|
/**
|
|
1532
1683
|
* Upload a long video and return the URL to publish from.
|
|
1533
1684
|
*
|
|
@@ -1631,4 +1782,4 @@ declare function terminateUpload(uploadUrl: string): Promise<boolean>;
|
|
|
1631
1782
|
*/
|
|
1632
1783
|
declare function uploadResumable(target: IUploadTarget, file: Blob, options?: IResumableUploadOptions): Promise<string>;
|
|
1633
1784
|
|
|
1634
|
-
export { type CommentStatusType, DEFAULT_CHUNK_SIZE, type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICommentInfoDTO, type ICommentRequest, type ICommentStatusDTO, 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 ILongVideoPlatformVerdict, type ILongVideoQuoteResponse, type ILongVideoRefusedTarget, type ILongVideoUploadControls, type IPostSetting, type IPublishLongVideoOptions, type IPublishLongVideoResult, type IPublishLongVideoToAccountOptions, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IRemovePostPlatformResult, type IRemovePostResponse, type IReschedulePostRequest, type IResumableUploadOptions, 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 IUploadTarget, type IVideoDTO, type IYouTubeConfig, type ImageSourceType, LONG_VIDEO_CREDIT_UNIT_SECONDS, LONG_VIDEO_MAX_DURATION_SECONDS, MAX_COMMENT_DELAY_MINUTES, MAX_COMMENT_LENGTH, MAX_POST_COMMENTS, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType, supportsResumableUpload, terminateUpload, uploadResumable };
|
|
1785
|
+
export { type CommentStatusType, DEFAULT_CHUNK_SIZE, type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICommentInfoDTO, type ICommentRequest, type ICommentStatusDTO, type ICreateImagePostToAccountRequest, type ICreateImagePostToWorkspaceRequest, type ICreatePostResult, type ICreateSocialPublisherAccountPostRequest, type ICreateSocialPublisherPostRequest, type ICreateStoryPostBase, type ICreateStoryPostToAccountRequest, type ICreateStoryPostToWorkspaceRequest, type ICreateTextPostBase, type ICreateTextPostToAccountRequest, type ICreateTextPostToWorkspaceRequest, type IDefaultSettingsResponse, type IFacebookPageConfig, type IFacebookTextConfig, type IGenerateUploadUrlsRequest, type IGenerateUploadUrlsResponse, type IImageDTO, type IImageMediaRequest, type IInstagramConfig, type IListParams, type ILongVideoPlatformVerdict, type ILongVideoQuoteResponse, type ILongVideoRefusedTarget, type ILongVideoUploadControls, type IPostSetting, type IPostUtmConfig, type IPublishLongVideoOptions, type IPublishLongVideoResult, type IPublishLongVideoToAccountOptions, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IRemovePostPlatformResult, type IRemovePostResponse, type IReschedulePostRequest, type IResumableUploadOptions, 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 IThreadsTextConfig, type ITikTokConfig, type ITwitterTextConfig, type IUploadConfig, type IUploadTarget, type IVideoDTO, type IYouTubeConfig, type ImageSourceType, LONG_VIDEO_CREDIT_UNIT_SECONDS, LONG_VIDEO_MAX_DURATION_SECONDS, MAX_COMMENT_DELAY_MINUTES, MAX_COMMENT_LENGTH, MAX_POST_COMMENTS, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType, supportsResumableUpload, terminateUpload, uploadResumable };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,96 @@ type SocialPublisherAccountPlatformType = "youtube" | "facebook" | "tiktok";
|
|
|
27
27
|
type SocialPublisherAccountAccountType = "facebook" | "instagram" | "youtube" | "tiktok";
|
|
28
28
|
type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
|
|
29
29
|
|
|
30
|
+
/** Facebook's override for a text post. Without it the shared caption is used. */
|
|
31
|
+
interface IFacebookTextConfig {
|
|
32
|
+
/** The status text. */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Kept for other surfaces; Facebook ignores it. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** An http(s) link Facebook previews. Posty5 never requests it. */
|
|
37
|
+
link?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Threads' override for a text post β at most 500 characters. */
|
|
40
|
+
interface IThreadsTextConfig {
|
|
41
|
+
text?: string;
|
|
42
|
+
reply_control?: "everyone" | "accounts_you_follow" | "mentioned_only" | "parent_post_author_only" | "followers_only";
|
|
43
|
+
/** The ONE topic Threads links (letters, digits, `_`). */
|
|
44
|
+
topic_tag?: string;
|
|
45
|
+
/** An http(s) link shown as a preview card. */
|
|
46
|
+
link?: string;
|
|
47
|
+
}
|
|
48
|
+
/** X's settings for a text post (requires the Pro plan or higher on the API side). */
|
|
49
|
+
interface ITwitterTextConfig {
|
|
50
|
+
/** At most 280 weighted characters. */
|
|
51
|
+
text?: string;
|
|
52
|
+
reply_settings?: "everyone" | "mentionedUsers" | "following";
|
|
53
|
+
/** 2β4 options of up to 25 characters; 5β10080 minutes. Not with `quote_tweet_id`. */
|
|
54
|
+
poll?: {
|
|
55
|
+
options: string[];
|
|
56
|
+
duration_minutes?: number;
|
|
57
|
+
};
|
|
58
|
+
quote_tweet_id?: string;
|
|
59
|
+
}
|
|
60
|
+
/** UTM parameters added to tracked links. */
|
|
61
|
+
interface IPostUtmConfig {
|
|
62
|
+
medium?: string;
|
|
63
|
+
campaign?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Fields every text post takes, whichever target. */
|
|
66
|
+
interface ICreateTextPostBase {
|
|
67
|
+
/** The post's text. */
|
|
68
|
+
caption: string;
|
|
69
|
+
facebook?: IFacebookTextConfig;
|
|
70
|
+
threads?: IThreadsTextConfig;
|
|
71
|
+
twitter?: ITwitterTextConfig;
|
|
72
|
+
schedule?: IScheduleConfig;
|
|
73
|
+
comments?: ICommentRequest[];
|
|
74
|
+
/** Saved hashtag groups merged into the caption (at most 5). */
|
|
75
|
+
hashtagGroupIds?: string[];
|
|
76
|
+
/** At most 30. */
|
|
77
|
+
hashtags?: string[];
|
|
78
|
+
/** Turn links in the caption into tracked short links. */
|
|
79
|
+
trackLinks?: boolean;
|
|
80
|
+
utm?: IPostUtmConfig;
|
|
81
|
+
refId?: string;
|
|
82
|
+
tag?: string;
|
|
83
|
+
}
|
|
84
|
+
/** A text post to every text-capable account in a workspace. */
|
|
85
|
+
interface ICreateTextPostToWorkspaceRequest extends ICreateTextPostBase {
|
|
86
|
+
workspaceId: string;
|
|
87
|
+
}
|
|
88
|
+
/** A text post to one account. */
|
|
89
|
+
interface ICreateTextPostToAccountRequest extends ICreateTextPostBase {
|
|
90
|
+
accountId: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A story. Media by URL only in this SDK release: an image as
|
|
94
|
+
* `image: { source: "image-url", externalUrl }`, a video as
|
|
95
|
+
* `source: "video-url"` + `videoURL`.
|
|
96
|
+
*/
|
|
97
|
+
interface ICreateStoryPostBase {
|
|
98
|
+
kind: "image" | "video";
|
|
99
|
+
/** For `kind: "image"`. */
|
|
100
|
+
image?: IImageMediaRequest;
|
|
101
|
+
/** For `kind: "video"`. */
|
|
102
|
+
source?: "video-url";
|
|
103
|
+
/** For `kind: "video"`: a direct, public video URL. */
|
|
104
|
+
videoURL?: string;
|
|
105
|
+
schedule?: IScheduleConfig;
|
|
106
|
+
refId?: string;
|
|
107
|
+
tag?: string;
|
|
108
|
+
}
|
|
109
|
+
/** A story to every story-capable account in a workspace. */
|
|
110
|
+
interface ICreateStoryPostToWorkspaceRequest extends ICreateStoryPostBase {
|
|
111
|
+
workspaceId: string;
|
|
112
|
+
}
|
|
113
|
+
/** A story to one account. */
|
|
114
|
+
interface ICreateStoryPostToAccountRequest extends ICreateStoryPostBase {
|
|
115
|
+
accountId: string;
|
|
116
|
+
/** The account's platform β required by the API for a story to one account. */
|
|
117
|
+
platform: "youtube" | "tiktok" | "facebook" | "instagram" | "threads" | "twitter";
|
|
118
|
+
}
|
|
119
|
+
|
|
30
120
|
interface IYouTubeConfig {
|
|
31
121
|
title: string;
|
|
32
122
|
description: string;
|
|
@@ -759,6 +849,19 @@ interface IListParams {
|
|
|
759
849
|
"facebook.postInfo.isAllow"?: boolean;
|
|
760
850
|
"instagram.postInfo.isAllow"?: boolean;
|
|
761
851
|
"tiktok.postInfo.isAllow"?: boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Created on or after this day, `YYYY-MM-DD`. Applied only together with
|
|
854
|
+
* `toDate` (and vice versa): the API ignores a lone bound, and this SDK
|
|
855
|
+
* does not check the pair. Matched on the creation date, in whole UTC days
|
|
856
|
+
* (the API rounds `fromDate` to the start of its UTC day).
|
|
857
|
+
*/
|
|
858
|
+
fromDate?: string;
|
|
859
|
+
/**
|
|
860
|
+
* Created on or before this day, `YYYY-MM-DD`. Applied only together with
|
|
861
|
+
* `fromDate` (and vice versa); the API rounds `toDate` to the end of its
|
|
862
|
+
* UTC day.
|
|
863
|
+
*/
|
|
864
|
+
toDate?: string;
|
|
762
865
|
}
|
|
763
866
|
/**
|
|
764
867
|
* Longest video the API accepts for a `longVideo` post: 60 minutes.
|
|
@@ -841,6 +944,21 @@ interface IReschedulePostRequest {
|
|
|
841
944
|
caption?: string;
|
|
842
945
|
}
|
|
843
946
|
|
|
947
|
+
/** What creating a text or story post answers. */
|
|
948
|
+
interface ICreatePostResult {
|
|
949
|
+
/** The created post's id β `getStatus(_id)` follows it. */
|
|
950
|
+
_id: string;
|
|
951
|
+
/** Connected platforms dropped from the post, with why (e.g. X below the Pro plan). */
|
|
952
|
+
refusedTargets?: {
|
|
953
|
+
platform: string;
|
|
954
|
+
reason: string;
|
|
955
|
+
}[];
|
|
956
|
+
/** Platforms whose text was built from the shared caption and cut to fit (X). */
|
|
957
|
+
truncatedTargets?: string[];
|
|
958
|
+
/** Connected platforms that cannot take this post type. */
|
|
959
|
+
skippedPlatforms?: string[];
|
|
960
|
+
}
|
|
961
|
+
|
|
844
962
|
interface IUploadConfig {
|
|
845
963
|
url: string;
|
|
846
964
|
fields: Record<string, string>;
|
|
@@ -897,6 +1015,8 @@ interface IRemovePostPlatformResult {
|
|
|
897
1015
|
}
|
|
898
1016
|
interface IRemovePostResponse {
|
|
899
1017
|
_id: string;
|
|
1018
|
+
/** The post's new version */
|
|
1019
|
+
__v: number;
|
|
900
1020
|
results: Partial<Record<"youtube" | "facebook" | "instagram" | "tiktok", IRemovePostPlatformResult>>;
|
|
901
1021
|
}
|
|
902
1022
|
interface ISocialPublisherPostStatusLog {
|
|
@@ -985,6 +1105,8 @@ interface ISocialPublisherPostPlatform {
|
|
|
985
1105
|
}
|
|
986
1106
|
interface ISocialPublisherPostResponse {
|
|
987
1107
|
_id: string;
|
|
1108
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1109
|
+
__v: number;
|
|
988
1110
|
numbering: string;
|
|
989
1111
|
caption: string;
|
|
990
1112
|
createdAt: Date;
|
|
@@ -1027,6 +1149,8 @@ interface ISocialPublisherPostResponse {
|
|
|
1027
1149
|
}
|
|
1028
1150
|
interface ISocialPublisherPostStatusResponse {
|
|
1029
1151
|
_id: string;
|
|
1152
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1153
|
+
__v: number;
|
|
1030
1154
|
numbering: string;
|
|
1031
1155
|
type: "shortVideo" | "longVideo" | "image";
|
|
1032
1156
|
source: SocialPublisherPostSourceType;
|
|
@@ -1300,15 +1424,17 @@ declare class SocialPublisherPostClient {
|
|
|
1300
1424
|
* cannot be removed programmatically and no credits are charged.
|
|
1301
1425
|
*
|
|
1302
1426
|
* @param id - Post ID
|
|
1303
|
-
* @
|
|
1427
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1428
|
+
* @returns Per-platform removal results, `__v` set to the post's new version
|
|
1304
1429
|
*
|
|
1305
1430
|
* @example
|
|
1306
1431
|
* ```ts
|
|
1307
|
-
* const
|
|
1432
|
+
* const post = await client.getStatus("post_123");
|
|
1433
|
+
* const { results } = await client.removePost("post_123", post.__v);
|
|
1308
1434
|
* // results.youtube?.success === true
|
|
1309
1435
|
* ```
|
|
1310
1436
|
*/
|
|
1311
|
-
removePost(id: string): Promise<IRemovePostResponse>;
|
|
1437
|
+
removePost(id: string, version: number): Promise<IRemovePostResponse>;
|
|
1312
1438
|
/**
|
|
1313
1439
|
* Get next and previous post IDs
|
|
1314
1440
|
* @param id - Current Post ID
|
|
@@ -1361,6 +1487,22 @@ declare class SocialPublisherPostClient {
|
|
|
1361
1487
|
* platforms in the request are ignored.
|
|
1362
1488
|
*/
|
|
1363
1489
|
createImagePostToAccount(data: ICreateImagePostToAccountRequest, id?: string): Promise<string>;
|
|
1490
|
+
/**
|
|
1491
|
+
* Publish a text-only post to every text-capable account in a workspace
|
|
1492
|
+
* (Facebook, Threads, X). Platforms that cannot take text are reported in
|
|
1493
|
+
* `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
|
|
1494
|
+
*/
|
|
1495
|
+
createTextPostToWorkspace(data: ICreateTextPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1496
|
+
/** Publish a text-only post to one account. */
|
|
1497
|
+
createTextPostToAccount(data: ICreateTextPostToAccountRequest): Promise<ICreatePostResult>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Publish a story to every story-capable account in a workspace. Media by URL
|
|
1500
|
+
* only in this release: `image: { source: "image-url", externalUrl }`, or
|
|
1501
|
+
* `source: "video-url"` with `videoURL`.
|
|
1502
|
+
*/
|
|
1503
|
+
createStoryPostToWorkspace(data: ICreateStoryPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1504
|
+
/** Publish a story to one account. Media by URL only, as for the workspace form. */
|
|
1505
|
+
createStoryPostToAccount(data: ICreateStoryPostToAccountRequest): Promise<ICreatePostResult>;
|
|
1364
1506
|
/**
|
|
1365
1507
|
* Handle thumbnail upload - accepts either File or URL string
|
|
1366
1508
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -1509,11 +1651,18 @@ declare class SocialPublisherPostClient {
|
|
|
1509
1651
|
*
|
|
1510
1652
|
* @example
|
|
1511
1653
|
* ```ts
|
|
1512
|
-
* await client.
|
|
1513
|
-
* await client.reschedulePost("post_123", { schedule: "
|
|
1654
|
+
* const post = await client.getStatus("post_123");
|
|
1655
|
+
* const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
|
|
1656
|
+
* await client.reschedulePost("post_123", { schedule: "now" }, __v);
|
|
1514
1657
|
* ```
|
|
1658
|
+
*
|
|
1659
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1660
|
+
* @returns `{ _id, __v }`, `__v` being the new version
|
|
1515
1661
|
*/
|
|
1516
|
-
reschedulePost(id: string, data: IReschedulePostRequest): Promise<
|
|
1662
|
+
reschedulePost(id: string, data: IReschedulePostRequest, version: number): Promise<{
|
|
1663
|
+
_id: string;
|
|
1664
|
+
__v: number;
|
|
1665
|
+
}>;
|
|
1517
1666
|
/**
|
|
1518
1667
|
* Delete a post that has not published yet, releasing its uploaded media in
|
|
1519
1668
|
* the same request.
|
|
@@ -1524,10 +1673,12 @@ declare class SocialPublisherPostClient {
|
|
|
1524
1673
|
*
|
|
1525
1674
|
* @example
|
|
1526
1675
|
* ```ts
|
|
1527
|
-
* await client.deletePost("post_123");
|
|
1676
|
+
* await client.deletePost("post_123", post.__v);
|
|
1528
1677
|
* ```
|
|
1678
|
+
*
|
|
1679
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1529
1680
|
*/
|
|
1530
|
-
deletePost(id: string): Promise<void>;
|
|
1681
|
+
deletePost(id: string, version: number): Promise<void>;
|
|
1531
1682
|
/**
|
|
1532
1683
|
* Upload a long video and return the URL to publish from.
|
|
1533
1684
|
*
|
|
@@ -1631,4 +1782,4 @@ declare function terminateUpload(uploadUrl: string): Promise<boolean>;
|
|
|
1631
1782
|
*/
|
|
1632
1783
|
declare function uploadResumable(target: IUploadTarget, file: Blob, options?: IResumableUploadOptions): Promise<string>;
|
|
1633
1784
|
|
|
1634
|
-
export { type CommentStatusType, DEFAULT_CHUNK_SIZE, type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICommentInfoDTO, type ICommentRequest, type ICommentStatusDTO, 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 ILongVideoPlatformVerdict, type ILongVideoQuoteResponse, type ILongVideoRefusedTarget, type ILongVideoUploadControls, type IPostSetting, type IPublishLongVideoOptions, type IPublishLongVideoResult, type IPublishLongVideoToAccountOptions, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IRemovePostPlatformResult, type IRemovePostResponse, type IReschedulePostRequest, type IResumableUploadOptions, 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 IUploadTarget, type IVideoDTO, type IYouTubeConfig, type ImageSourceType, LONG_VIDEO_CREDIT_UNIT_SECONDS, LONG_VIDEO_MAX_DURATION_SECONDS, MAX_COMMENT_DELAY_MINUTES, MAX_COMMENT_LENGTH, MAX_POST_COMMENTS, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType, supportsResumableUpload, terminateUpload, uploadResumable };
|
|
1785
|
+
export { type CommentStatusType, DEFAULT_CHUNK_SIZE, type IAccountPostSetting, type IBaseStatusHistoryGroupedDay, type IBaseStatusHistoryGroupedItem, type ICommentInfoDTO, type ICommentRequest, type ICommentStatusDTO, type ICreateImagePostToAccountRequest, type ICreateImagePostToWorkspaceRequest, type ICreatePostResult, type ICreateSocialPublisherAccountPostRequest, type ICreateSocialPublisherPostRequest, type ICreateStoryPostBase, type ICreateStoryPostToAccountRequest, type ICreateStoryPostToWorkspaceRequest, type ICreateTextPostBase, type ICreateTextPostToAccountRequest, type ICreateTextPostToWorkspaceRequest, type IDefaultSettingsResponse, type IFacebookPageConfig, type IFacebookTextConfig, type IGenerateUploadUrlsRequest, type IGenerateUploadUrlsResponse, type IImageDTO, type IImageMediaRequest, type IInstagramConfig, type IListParams, type ILongVideoPlatformVerdict, type ILongVideoQuoteResponse, type ILongVideoRefusedTarget, type ILongVideoUploadControls, type IPostSetting, type IPostUtmConfig, type IPublishLongVideoOptions, type IPublishLongVideoResult, type IPublishLongVideoToAccountOptions, type IPublishOptions, type IPublishToAccountOptions, type IQuickPublishAllOptions, type IQuickPublishBaseOptions, type IQuickPublishFacebookOptions, type IQuickPublishInstagramOptions, type IQuickPublishTikTokOptions, type IQuickPublishYouTubeOptions, type IRemovePostPlatformResult, type IRemovePostResponse, type IReschedulePostRequest, type IResumableUploadOptions, 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 IThreadsTextConfig, type ITikTokConfig, type ITwitterTextConfig, type IUploadConfig, type IUploadTarget, type IVideoDTO, type IYouTubeConfig, type ImageSourceType, LONG_VIDEO_CREDIT_UNIT_SECONDS, LONG_VIDEO_MAX_DURATION_SECONDS, MAX_COMMENT_DELAY_MINUTES, MAX_COMMENT_LENGTH, MAX_POST_COMMENTS, type SocialPublisherAccountAccountType, type SocialPublisherAccountPlatformType, type SocialPublisherAccountStatusType, type SocialPublisherPostAccountType, SocialPublisherPostClient, type SocialPublisherPostScheduleType, type SocialPublisherPostSourceType, type SocialPublisherPostStatusType, type SocialPublisherPostType, supportsResumableUpload, terminateUpload, uploadResumable };
|