@posty5/social-publisher-post 4.1.0 → 5.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 +273 -15
- package/dist/index.d.mts +833 -54
- package/dist/index.d.ts +833 -54
- package/dist/index.js +1552 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1544 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { IPaginationResponse, HttpClient, IPaginationParams } from '@posty5/core';
|
|
2
2
|
export { HttpClient, IHttpClientConfig, IPosty5Config, uploadToR2 } from '@posty5/core';
|
|
3
3
|
|
|
4
|
-
type SocialPublisherPostStatusType = "pending" | "processing" | "processingInPlatform" | "failedByPlatform" | "done" | "error" | "canceled" | "needsMaintenance" | "invalidVideoURL" | "invalidPostVideoURL" | "retrying";
|
|
5
|
-
|
|
4
|
+
type SocialPublisherPostStatusType = "pending" | "processing" | "processingInPlatform" | "failedByPlatform" | "done" | "error" | "canceled" | "needsMaintenance" | "invalidVideoURL" | "invalidPostVideoURL" | "retrying" | "removing" | "removed" | "removeFailed";
|
|
5
|
+
/**
|
|
6
|
+
* Content type of a post.
|
|
7
|
+
*
|
|
8
|
+
* `longVideo` was added in 4.2.0; `image` and `text` were always returned by
|
|
9
|
+
* the API but missing from this union. Code that switches on this field must
|
|
10
|
+
* handle values it does not recognise — the set grows as the platform does.
|
|
11
|
+
*/
|
|
12
|
+
type SocialPublisherPostType = "shortVideo" | "longVideo" | "image" | "text";
|
|
6
13
|
type SocialPublisherPostAccountType = "youtube" | "facebook" | "instagram" | "tiktok";
|
|
7
14
|
type SocialPublisherPostScheduleType = "now" | "schedule";
|
|
8
15
|
type SocialPublisherPostSourceType = "video-file" | "video-url";
|
|
@@ -20,6 +27,96 @@ type SocialPublisherAccountPlatformType = "youtube" | "facebook" | "tiktok";
|
|
|
20
27
|
type SocialPublisherAccountAccountType = "facebook" | "instagram" | "youtube" | "tiktok";
|
|
21
28
|
type SocialPublisherAccountStatusType = "active" | "inactive" | "authenticationExpired";
|
|
22
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
|
+
|
|
23
120
|
interface IYouTubeConfig {
|
|
24
121
|
title: string;
|
|
25
122
|
description: string;
|
|
@@ -72,7 +169,10 @@ interface IImageMediaRequest {
|
|
|
72
169
|
}
|
|
73
170
|
/**
|
|
74
171
|
* Image-post create request (workspace target).
|
|
75
|
-
* Image posts cost **
|
|
172
|
+
* Image posts cost **50 credits**, and each comment that actually posts is a
|
|
173
|
+
* further **25**. Both numbers come from the API's plan data
|
|
174
|
+
* (`socialMediaPublisher.imagePost` and `socialMediaPublisher.commentOnPost`);
|
|
175
|
+
* the "5 credits + 1" this line used to carry was wrong on both halves.
|
|
76
176
|
* YouTube community posts are always reported as `notSupported`.
|
|
77
177
|
*/
|
|
78
178
|
interface ICreateImagePostToWorkspaceRequest {
|
|
@@ -89,7 +189,24 @@ interface ICreateImagePostToWorkspaceRequest {
|
|
|
89
189
|
facebook?: IFacebookPageConfig;
|
|
90
190
|
instagram?: IInstagramConfig;
|
|
91
191
|
schedule?: IScheduleConfig;
|
|
192
|
+
/**
|
|
193
|
+
* A single post-publish comment.
|
|
194
|
+
*
|
|
195
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
196
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
197
|
+
* so send one or the other.
|
|
198
|
+
*/
|
|
92
199
|
comment?: ICommentRequest;
|
|
200
|
+
/**
|
|
201
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
202
|
+
* post.
|
|
203
|
+
*
|
|
204
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
205
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
206
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
207
|
+
* dropped before it is charged.
|
|
208
|
+
*/
|
|
209
|
+
comments?: ICommentRequest[];
|
|
93
210
|
tag?: string;
|
|
94
211
|
refId?: string;
|
|
95
212
|
}
|
|
@@ -107,21 +224,80 @@ interface ICreateImagePostToAccountRequest {
|
|
|
107
224
|
facebook?: IFacebookPageConfig;
|
|
108
225
|
instagram?: IInstagramConfig;
|
|
109
226
|
schedule?: IScheduleConfig;
|
|
227
|
+
/**
|
|
228
|
+
* A single post-publish comment.
|
|
229
|
+
*
|
|
230
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
231
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
232
|
+
* so send one or the other.
|
|
233
|
+
*/
|
|
110
234
|
comment?: ICommentRequest;
|
|
235
|
+
/**
|
|
236
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
237
|
+
* post.
|
|
238
|
+
*
|
|
239
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
240
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
241
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
242
|
+
* dropped before it is charged.
|
|
243
|
+
*/
|
|
244
|
+
comments?: ICommentRequest[];
|
|
111
245
|
tag?: string;
|
|
112
246
|
refId?: string;
|
|
113
247
|
}
|
|
248
|
+
/** At most this many comments may ride on one post. Enforced server-side. */
|
|
249
|
+
declare const MAX_POST_COMMENTS = 5;
|
|
250
|
+
/** Longest a comment may be. */
|
|
251
|
+
declare const MAX_COMMENT_LENGTH = 2200;
|
|
252
|
+
/** Longest a comment may wait after the post before it is published. */
|
|
253
|
+
declare const MAX_COMMENT_DELAY_MINUTES: number;
|
|
114
254
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
255
|
+
* One post-publish comment.
|
|
256
|
+
*
|
|
257
|
+
* Posted under each enabled platform post once the post itself is live, either
|
|
258
|
+
* immediately or after a delay.
|
|
259
|
+
*
|
|
260
|
+
* **Pricing: 25 credits per comment**, charged per comment that actually posts —
|
|
261
|
+
* not per post, and not "+1". Earlier versions of this file documented "+1
|
|
262
|
+
* credit", which was never the price: the API charges
|
|
263
|
+
* `socialMediaPublisher.commentOnPost`, which its plan data prices at 25. A
|
|
264
|
+
* comment aimed at no enabled platform is dropped before it is charged.
|
|
265
|
+
*
|
|
266
|
+
* **TikTok is not supported** and never will be through this API: TikTok exposes
|
|
267
|
+
* no public comment-posting endpoint. A comment aimed at it reports
|
|
268
|
+
* `notSupported` rather than failing.
|
|
117
269
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
270
|
+
* **An image is Facebook only.** Instagram's and YouTube's comment endpoints are
|
|
271
|
+
* text-only, so an image bound for either is dropped with a reason rather than
|
|
272
|
+
* failing the comment.
|
|
121
273
|
*/
|
|
122
274
|
interface ICommentRequest {
|
|
123
|
-
/** Comment text (1..
|
|
275
|
+
/** Comment text (1..{@link MAX_COMMENT_LENGTH} characters). Required. */
|
|
124
276
|
text: string;
|
|
277
|
+
/**
|
|
278
|
+
* How long to wait after the post is published, in minutes.
|
|
279
|
+
*
|
|
280
|
+
* `0` or omitted posts it as soon as the post is live. Maximum
|
|
281
|
+
* {@link MAX_COMMENT_DELAY_MINUTES} (24 hours) — the API refuses more.
|
|
282
|
+
*/
|
|
283
|
+
delayMinutes?: number;
|
|
284
|
+
/**
|
|
285
|
+
* A publicly reachable image to attach. **Facebook only** (see above).
|
|
286
|
+
*
|
|
287
|
+
* Use this OR {@link imageStorageKey}, not both. A URL costs us no storage and
|
|
288
|
+
* is available on every plan; uploading is plan-gated.
|
|
289
|
+
*/
|
|
290
|
+
imageUrl?: string;
|
|
291
|
+
/**
|
|
292
|
+
* The storage key of an image uploaded through the account's
|
|
293
|
+
* `default-comments/upload-urls` endpoint.
|
|
294
|
+
*
|
|
295
|
+
* Prefer {@link imageUrl} unless you have uploaded the bytes yourself: the key
|
|
296
|
+
* is what tells the API the object is OURS, which is what its cleanup path
|
|
297
|
+
* uses when the post or the comment is deleted. Sending a public URL in this
|
|
298
|
+
* field makes the image read as external and it will never be cleaned up.
|
|
299
|
+
*/
|
|
300
|
+
imageStorageKey?: string;
|
|
125
301
|
/** Post the comment on Facebook (default: true). */
|
|
126
302
|
postToFacebook?: boolean;
|
|
127
303
|
/** Post the comment on Instagram (default: true). */
|
|
@@ -143,11 +319,23 @@ interface ICreateSocialPublisherPostRequest {
|
|
|
143
319
|
thumbURL?: string;
|
|
144
320
|
schedule?: IScheduleConfig;
|
|
145
321
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
322
|
+
* A single post-publish comment.
|
|
323
|
+
*
|
|
324
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
325
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
326
|
+
* so send one or the other.
|
|
149
327
|
*/
|
|
150
328
|
comment?: ICommentRequest;
|
|
329
|
+
/**
|
|
330
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
331
|
+
* post.
|
|
332
|
+
*
|
|
333
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
334
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
335
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
336
|
+
* dropped before it is charged.
|
|
337
|
+
*/
|
|
338
|
+
comments?: ICommentRequest[];
|
|
151
339
|
/**
|
|
152
340
|
* Tag (optional)
|
|
153
341
|
* Use this field to filter posts by tag.
|
|
@@ -173,11 +361,23 @@ interface ICreateSocialPublisherAccountPostRequest {
|
|
|
173
361
|
thumbURL?: string;
|
|
174
362
|
schedule?: IScheduleConfig;
|
|
175
363
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
364
|
+
* A single post-publish comment.
|
|
365
|
+
*
|
|
366
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
367
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
368
|
+
* so send one or the other.
|
|
179
369
|
*/
|
|
180
370
|
comment?: ICommentRequest;
|
|
371
|
+
/**
|
|
372
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
373
|
+
* post.
|
|
374
|
+
*
|
|
375
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
376
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
377
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
378
|
+
* dropped before it is charged.
|
|
379
|
+
*/
|
|
380
|
+
comments?: ICommentRequest[];
|
|
181
381
|
/**
|
|
182
382
|
* Tag (optional)
|
|
183
383
|
* Use this field to filter posts by tag.
|
|
@@ -200,8 +400,24 @@ interface IPostSetting {
|
|
|
200
400
|
instagram?: IInstagramConfig;
|
|
201
401
|
schedule?: IScheduleConfig;
|
|
202
402
|
source: SocialPublisherPostSourceType;
|
|
203
|
-
/**
|
|
403
|
+
/**
|
|
404
|
+
* A single post-publish comment.
|
|
405
|
+
*
|
|
406
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
407
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
408
|
+
* so send one or the other.
|
|
409
|
+
*/
|
|
204
410
|
comment?: ICommentRequest;
|
|
411
|
+
/**
|
|
412
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
413
|
+
* post.
|
|
414
|
+
*
|
|
415
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
416
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
417
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
418
|
+
* dropped before it is charged.
|
|
419
|
+
*/
|
|
420
|
+
comments?: ICommentRequest[];
|
|
205
421
|
/** Optional caller-supplied tag, persisted on the created post for filtering. */
|
|
206
422
|
tag?: string;
|
|
207
423
|
/** Optional caller-supplied reference ID, persisted on the created post for filtering. */
|
|
@@ -216,8 +432,24 @@ interface IAccountPostSetting {
|
|
|
216
432
|
instagram?: IInstagramConfig;
|
|
217
433
|
schedule?: IScheduleConfig;
|
|
218
434
|
source: SocialPublisherPostSourceType;
|
|
219
|
-
/**
|
|
435
|
+
/**
|
|
436
|
+
* A single post-publish comment.
|
|
437
|
+
*
|
|
438
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
439
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
440
|
+
* so send one or the other.
|
|
441
|
+
*/
|
|
220
442
|
comment?: ICommentRequest;
|
|
443
|
+
/**
|
|
444
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
445
|
+
* post.
|
|
446
|
+
*
|
|
447
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
448
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
449
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
450
|
+
* dropped before it is charged.
|
|
451
|
+
*/
|
|
452
|
+
comments?: ICommentRequest[];
|
|
221
453
|
/** Optional caller-supplied tag, persisted on the created post for filtering. */
|
|
222
454
|
tag?: string;
|
|
223
455
|
/** Optional caller-supplied reference ID, persisted on the created post for filtering. */
|
|
@@ -226,6 +458,13 @@ interface IAccountPostSetting {
|
|
|
226
458
|
interface IGenerateUploadUrlsRequest {
|
|
227
459
|
thumbFileType?: string;
|
|
228
460
|
videoFileType?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Post type these uploads are for. Sending `"longVideo"` makes the server
|
|
463
|
+
* check plan gating and affordability now, before you spend an hour
|
|
464
|
+
* uploading something that cannot be published. The duration-accurate
|
|
465
|
+
* charge still happens when the post is created.
|
|
466
|
+
*/
|
|
467
|
+
postType?: SocialPublisherPostType;
|
|
229
468
|
}
|
|
230
469
|
/**
|
|
231
470
|
* Simplified options for the unified publish() method
|
|
@@ -287,10 +526,23 @@ interface IPublishOptions {
|
|
|
287
526
|
*/
|
|
288
527
|
refId?: string;
|
|
289
528
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
529
|
+
* A single post-publish comment.
|
|
530
|
+
*
|
|
531
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
532
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
533
|
+
* so send one or the other.
|
|
292
534
|
*/
|
|
293
535
|
comment?: ICommentRequest;
|
|
536
|
+
/**
|
|
537
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
538
|
+
* post.
|
|
539
|
+
*
|
|
540
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
541
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
542
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
543
|
+
* dropped before it is charged.
|
|
544
|
+
*/
|
|
545
|
+
comments?: ICommentRequest[];
|
|
294
546
|
}
|
|
295
547
|
/**
|
|
296
548
|
* Options for publishing to an account
|
|
@@ -351,10 +603,23 @@ interface IPublishToAccountOptions {
|
|
|
351
603
|
*/
|
|
352
604
|
refId?: string;
|
|
353
605
|
/**
|
|
354
|
-
*
|
|
355
|
-
*
|
|
606
|
+
* A single post-publish comment.
|
|
607
|
+
*
|
|
608
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
609
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
610
|
+
* so send one or the other.
|
|
356
611
|
*/
|
|
357
612
|
comment?: ICommentRequest;
|
|
613
|
+
/**
|
|
614
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
615
|
+
* post.
|
|
616
|
+
*
|
|
617
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
618
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
619
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
620
|
+
* dropped before it is charged.
|
|
621
|
+
*/
|
|
622
|
+
comments?: ICommentRequest[];
|
|
358
623
|
}
|
|
359
624
|
/**
|
|
360
625
|
* Base interface for quick publish options
|
|
@@ -407,10 +672,23 @@ interface IQuickPublishBaseOptions {
|
|
|
407
672
|
*/
|
|
408
673
|
refId?: string;
|
|
409
674
|
/**
|
|
410
|
-
*
|
|
411
|
-
*
|
|
675
|
+
* A single post-publish comment.
|
|
676
|
+
*
|
|
677
|
+
* @deprecated Use {@link comments} instead. Kept for one major version so
|
|
678
|
+
* existing callers keep compiling; the API refuses a request carrying BOTH,
|
|
679
|
+
* so send one or the other.
|
|
412
680
|
*/
|
|
413
681
|
comment?: ICommentRequest;
|
|
682
|
+
/**
|
|
683
|
+
* Up to {@link MAX_POST_COMMENTS} post-publish comments, in the order they
|
|
684
|
+
* post.
|
|
685
|
+
*
|
|
686
|
+
* Each carries its own delay, its own optional image and its own per-platform
|
|
687
|
+
* flags — see {@link ICommentRequest}. **25 credits each**, charged per
|
|
688
|
+
* comment that actually posts; a comment aimed at no enabled platform is
|
|
689
|
+
* dropped before it is charged.
|
|
690
|
+
*/
|
|
691
|
+
comments?: ICommentRequest[];
|
|
414
692
|
}
|
|
415
693
|
/**
|
|
416
694
|
* Quick publish options for YouTube only
|
|
@@ -572,41 +850,161 @@ interface IListParams {
|
|
|
572
850
|
"instagram.postInfo.isAllow"?: boolean;
|
|
573
851
|
"tiktok.postInfo.isAllow"?: boolean;
|
|
574
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* Longest video the API accepts for a `longVideo` post: 60 minutes.
|
|
855
|
+
* Exported so callers can check a file before starting an upload, but the
|
|
856
|
+
* server measures the real duration and is the only authority on it.
|
|
857
|
+
*/
|
|
858
|
+
declare const LONG_VIDEO_MAX_DURATION_SECONDS = 3600;
|
|
859
|
+
/** One charge unit covers each started 5 minutes of video. */
|
|
860
|
+
declare const LONG_VIDEO_CREDIT_UNIT_SECONDS = 300;
|
|
861
|
+
/**
|
|
862
|
+
* Options for {@link SocialPublisherPostClient.publishLongVideoToWorkspace}.
|
|
863
|
+
*
|
|
864
|
+
* Identical to {@link IPublishOptions} apart from `onProgress` — a 60-minute
|
|
865
|
+
* upload is long enough that a caller needs to report it — and the absence of
|
|
866
|
+
* any duration field. The duration is measured server-side from the file, and
|
|
867
|
+
* the price is derived from that measurement, so a client-supplied duration
|
|
868
|
+
* would be a client-supplied price.
|
|
869
|
+
*/
|
|
870
|
+
interface ILongVideoUploadControls {
|
|
871
|
+
/**
|
|
872
|
+
* Called once the upload exists on the server, with its URL.
|
|
873
|
+
*
|
|
874
|
+
* Persist this if you want to resume the same transfer after a crash or a
|
|
875
|
+
* page reload: the ticket expires in minutes, but an upload that already
|
|
876
|
+
* exists resumes by its own URL and is unaffected. Pass it back as
|
|
877
|
+
* `resumeFrom`.
|
|
878
|
+
*/
|
|
879
|
+
onUploadUrl?: (uploadUrl: string) => void;
|
|
880
|
+
/**
|
|
881
|
+
* Resume a previous attempt instead of starting a new upload. Use the URL
|
|
882
|
+
* handed to `onUploadUrl` on the earlier run.
|
|
883
|
+
*/
|
|
884
|
+
resumeFrom?: string;
|
|
885
|
+
/**
|
|
886
|
+
* Abort the transfer. What has already been uploaded stays on the server and
|
|
887
|
+
* can be resumed with `resumeFrom`; no post is created, so nothing is
|
|
888
|
+
* charged.
|
|
889
|
+
*/
|
|
890
|
+
signal?: AbortSignal;
|
|
891
|
+
/**
|
|
892
|
+
* Discard the partial upload when `signal` fires, instead of leaving it
|
|
893
|
+
* resumable.
|
|
894
|
+
*
|
|
895
|
+
* Off by default: in most interfaces "pause" and "cancel" are the same
|
|
896
|
+
* button, and a user who paused a 40-minute video does not expect to start
|
|
897
|
+
* over. Set it where the abort really is final — a closed wizard, a replaced
|
|
898
|
+
* file — so the server stops holding megabytes nobody will claim.
|
|
899
|
+
*
|
|
900
|
+
* Best-effort. A failed termination is not reported, because the server
|
|
901
|
+
* expires abandoned uploads after 24 hours regardless.
|
|
902
|
+
*/
|
|
903
|
+
terminateOnAbort?: boolean;
|
|
904
|
+
}
|
|
905
|
+
interface IPublishLongVideoOptions extends IPublishOptions, ILongVideoUploadControls {
|
|
906
|
+
/**
|
|
907
|
+
* Called as the upload proceeds, with a percentage.
|
|
908
|
+
*
|
|
909
|
+
* Resumable transfers report per chunk — 8MiB of an hour-long file at a time
|
|
910
|
+
* — so this moves continuously. It falls back to 0 then 100 only on a server
|
|
911
|
+
* without the resumable service, where the single signed PUT would need
|
|
912
|
+
* `XMLHttpRequest` to report anything in between.
|
|
913
|
+
*/
|
|
914
|
+
onProgress?: (progress: number) => void;
|
|
915
|
+
}
|
|
916
|
+
/** Account-targeted counterpart of {@link IPublishLongVideoOptions}. */
|
|
917
|
+
interface IPublishLongVideoToAccountOptions extends IPublishToAccountOptions, ILongVideoUploadControls {
|
|
918
|
+
/** See the note on {@link IPublishLongVideoOptions.onProgress}. */
|
|
919
|
+
onProgress?: (progress: number) => void;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Re-schedule (or edit) a post that has not published yet.
|
|
923
|
+
*
|
|
924
|
+
* Only posts still pending with a future publish time accept this; anything
|
|
925
|
+
* that has started publishing is refused by the server.
|
|
926
|
+
*/
|
|
927
|
+
interface IReschedulePostRequest {
|
|
928
|
+
/** New publish moment. Pass a `Date`, or `"now"` to publish immediately. */
|
|
929
|
+
schedule: "now" | Date;
|
|
930
|
+
/** Optionally replace the caption at the same time. */
|
|
931
|
+
caption?: string;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** What creating a text or story post answers. */
|
|
935
|
+
interface ICreatePostResult {
|
|
936
|
+
/** The created post's id — `getStatus(_id)` follows it. */
|
|
937
|
+
_id: string;
|
|
938
|
+
/** Connected platforms dropped from the post, with why (e.g. X below the Pro plan). */
|
|
939
|
+
refusedTargets?: {
|
|
940
|
+
platform: string;
|
|
941
|
+
reason: string;
|
|
942
|
+
}[];
|
|
943
|
+
/** Platforms whose text was built from the shared caption and cut to fit (X). */
|
|
944
|
+
truncatedTargets?: string[];
|
|
945
|
+
/** Connected platforms that cannot take this post type. */
|
|
946
|
+
skippedPlatforms?: string[];
|
|
947
|
+
}
|
|
575
948
|
|
|
576
949
|
interface IUploadConfig {
|
|
577
950
|
url: string;
|
|
578
951
|
fields: Record<string, string>;
|
|
579
952
|
}
|
|
953
|
+
/**
|
|
954
|
+
* One upload destination the API authorized.
|
|
955
|
+
*
|
|
956
|
+
* The same slot is offered two ways. `uploadFileURL` is a signed R2 PUT — one
|
|
957
|
+
* request, no resume. The `tus*` fields describe the same destination as a
|
|
958
|
+
* resumable transfer. Both land the file at `fileURL`, so nothing downstream
|
|
959
|
+
* cares which was used.
|
|
960
|
+
*
|
|
961
|
+
* The resumable fields are optional on purpose: an API not deployed with the
|
|
962
|
+
* resumable service omits them, and clients fall back to the signed PUT.
|
|
963
|
+
*/
|
|
964
|
+
interface IUploadTarget {
|
|
965
|
+
/** Public URL of the finished object. Known before the upload starts. */
|
|
966
|
+
fileURL: string | undefined;
|
|
967
|
+
/** Signed URL for a single PUT. */
|
|
968
|
+
uploadFileURL: string | undefined;
|
|
969
|
+
/** Object key inside the bucket. */
|
|
970
|
+
bucketFilePath: string | undefined;
|
|
971
|
+
/**
|
|
972
|
+
* Absolute tus endpoint for this same destination, when resumable uploads
|
|
973
|
+
* are configured.
|
|
974
|
+
*/
|
|
975
|
+
tusEndpoint?: string;
|
|
976
|
+
/**
|
|
977
|
+
* Signed capability naming this exact destination, sent as the tus
|
|
978
|
+
* `Upload-Metadata` key `ticket`. Short-lived, and never to be logged or
|
|
979
|
+
* persisted.
|
|
980
|
+
*/
|
|
981
|
+
ticket?: string;
|
|
982
|
+
/** When the ticket stops being accepted for creating an upload. */
|
|
983
|
+
ticketExpiresAt?: string;
|
|
984
|
+
/** Maximum accepted size in bytes, so a client can fail fast. */
|
|
985
|
+
maxSize?: number;
|
|
986
|
+
}
|
|
580
987
|
interface IGenerateUploadUrlsResponse {
|
|
581
988
|
postId: string;
|
|
582
|
-
thumb:
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Upload URL to upload file to Cloud Bucket (Signed URL)
|
|
603
|
-
*/
|
|
604
|
-
uploadFileURL: string | undefined;
|
|
605
|
-
/**
|
|
606
|
-
* Path in Cloud Bucket
|
|
607
|
-
*/
|
|
608
|
-
bucketFilePath: string | undefined;
|
|
609
|
-
};
|
|
989
|
+
thumb: IUploadTarget;
|
|
990
|
+
video: IUploadTarget;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Per-platform outcome of a {@link SocialPublisherPostClient.removePost} call.
|
|
994
|
+
* `notSupported` marks platforms (Instagram, TikTok) whose API can't delete a
|
|
995
|
+
* published post; `skipped` marks platforms that had nothing to delete.
|
|
996
|
+
*/
|
|
997
|
+
interface IRemovePostPlatformResult {
|
|
998
|
+
success: boolean;
|
|
999
|
+
notSupported?: boolean;
|
|
1000
|
+
skipped?: boolean;
|
|
1001
|
+
error?: string;
|
|
1002
|
+
}
|
|
1003
|
+
interface IRemovePostResponse {
|
|
1004
|
+
_id: string;
|
|
1005
|
+
/** The post's new version */
|
|
1006
|
+
__v: number;
|
|
1007
|
+
results: Partial<Record<"youtube" | "facebook" | "instagram" | "tiktok", IRemovePostPlatformResult>>;
|
|
610
1008
|
}
|
|
611
1009
|
interface ISocialPublisherPostStatusLog {
|
|
612
1010
|
status: SocialPublisherPostStatusType;
|
|
@@ -646,7 +1044,11 @@ interface IImageDTO {
|
|
|
646
1044
|
}
|
|
647
1045
|
/**
|
|
648
1046
|
* Per-platform comment status block returned on the post status response.
|
|
649
|
-
* Present only when the post was created with a
|
|
1047
|
+
* Present only when the post was created with a comment payload.
|
|
1048
|
+
*
|
|
1049
|
+
* With a LIST of comments this describes the first one; the whole list, one
|
|
1050
|
+
* entry per comment, is {@link ICommentStatusDTO}[] on `comments`. The singular
|
|
1051
|
+
* block is kept so a caller written against one comment keeps reading.
|
|
650
1052
|
*
|
|
651
1053
|
* TikTok always returns `currentStatus = "notSupported"`.
|
|
652
1054
|
*/
|
|
@@ -666,11 +1068,32 @@ interface ICommentInfoDTO {
|
|
|
666
1068
|
/** Grouped history of status transitions for this platform comment. */
|
|
667
1069
|
statusHistoryGrouped?: IBaseStatusHistoryGroupedDay<CommentStatusType>[];
|
|
668
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* One comment's status on one platform.
|
|
1073
|
+
*
|
|
1074
|
+
* `order` is the position it posts in, which is also the position it was sent
|
|
1075
|
+
* in — the API takes the order from the array rather than from a field on the
|
|
1076
|
+
* comment, so two comments cannot claim the same slot.
|
|
1077
|
+
*/
|
|
1078
|
+
interface ICommentStatusDTO extends ICommentInfoDTO {
|
|
1079
|
+
/** Position in the list, from 0. Also the order it posts in. */
|
|
1080
|
+
order: number;
|
|
1081
|
+
/** The text as it was sent, so a status row is readable without the request. */
|
|
1082
|
+
text?: string;
|
|
1083
|
+
/** Minutes waited after the post went live. `0` means immediately. */
|
|
1084
|
+
delayMinutes?: number;
|
|
1085
|
+
/** The image attached, if any. Facebook only; dropped elsewhere with a reason. */
|
|
1086
|
+
imageUrl?: string;
|
|
1087
|
+
/** Set when this comment was copied from the account's saved defaults. */
|
|
1088
|
+
defaultCommentId?: string;
|
|
1089
|
+
}
|
|
669
1090
|
interface ISocialPublisherPostPlatform {
|
|
670
1091
|
postInfo: ISocialPublisherPostInfo;
|
|
671
1092
|
}
|
|
672
1093
|
interface ISocialPublisherPostResponse {
|
|
673
1094
|
_id: string;
|
|
1095
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1096
|
+
__v: number;
|
|
674
1097
|
numbering: string;
|
|
675
1098
|
caption: string;
|
|
676
1099
|
createdAt: Date;
|
|
@@ -699,11 +1122,24 @@ interface ISocialPublisherPostResponse {
|
|
|
699
1122
|
};
|
|
700
1123
|
refId: string;
|
|
701
1124
|
tag: string;
|
|
1125
|
+
type?: "shortVideo" | "longVideo" | "image" | string;
|
|
1126
|
+
source?: SocialPublisherPostSourceType | string;
|
|
1127
|
+
sourceURLs?: {
|
|
1128
|
+
thumbURL?: string;
|
|
1129
|
+
videoURL?: string;
|
|
1130
|
+
postURL?: string;
|
|
1131
|
+
imageURL?: string;
|
|
1132
|
+
};
|
|
1133
|
+
image?: {
|
|
1134
|
+
externalUrl?: string;
|
|
1135
|
+
};
|
|
702
1136
|
}
|
|
703
1137
|
interface ISocialPublisherPostStatusResponse {
|
|
704
1138
|
_id: string;
|
|
1139
|
+
/** Document version: pass it to versioned writes (`update`, `delete`, ...). */
|
|
1140
|
+
__v: number;
|
|
705
1141
|
numbering: string;
|
|
706
|
-
type: "shortVideo" | "image";
|
|
1142
|
+
type: "shortVideo" | "longVideo" | "image";
|
|
707
1143
|
source: SocialPublisherPostSourceType;
|
|
708
1144
|
sourceURLs: {
|
|
709
1145
|
/**
|
|
@@ -721,6 +1157,8 @@ interface ISocialPublisherPostStatusResponse {
|
|
|
721
1157
|
};
|
|
722
1158
|
/** Image-post metadata — only present when `type === "image"`. */
|
|
723
1159
|
image?: IImageDTO;
|
|
1160
|
+
/** Long-video metadata — only present when `type === "longVideo"`. */
|
|
1161
|
+
video?: IVideoDTO;
|
|
724
1162
|
currentStatus: SocialPublisherPostStatusType;
|
|
725
1163
|
currentError: string;
|
|
726
1164
|
currentStatusChangedAt: string;
|
|
@@ -737,6 +1175,10 @@ interface ISocialPublisherPostStatusResponse {
|
|
|
737
1175
|
scheduledAt: Date;
|
|
738
1176
|
executedAt: Date;
|
|
739
1177
|
};
|
|
1178
|
+
/** Custom reference id supplied when the post was created. */
|
|
1179
|
+
refId?: string;
|
|
1180
|
+
/** Custom tag supplied when the post was created. */
|
|
1181
|
+
tag?: string;
|
|
740
1182
|
}
|
|
741
1183
|
interface ISocialPublisherWorkspace {
|
|
742
1184
|
_id: string;
|
|
@@ -776,12 +1218,22 @@ interface ISocialPublisherPostTikTokPostDetails extends ISocialPublisherPostAcco
|
|
|
776
1218
|
privacy_level: string;
|
|
777
1219
|
/** Per-platform comment status — TikTok always reports `notSupported`. */
|
|
778
1220
|
commentInfo?: ICommentInfoDTO;
|
|
1221
|
+
/** One entry per comment, every one of them `notSupported` on TikTok. */
|
|
1222
|
+
comments?: ICommentStatusDTO[];
|
|
779
1223
|
}
|
|
780
1224
|
interface ISocialPublisherPostFacebookPagePostDetails extends ISocialPublisherPostAccount {
|
|
781
1225
|
description: string;
|
|
782
1226
|
title: string;
|
|
783
1227
|
/** Per-platform comment status (only present when a comment was requested). */
|
|
784
1228
|
commentInfo?: ICommentInfoDTO;
|
|
1229
|
+
/**
|
|
1230
|
+
* One entry per comment on this platform, in posting order.
|
|
1231
|
+
*
|
|
1232
|
+
* Present when the post was created with `comments[]`. `commentInfo` above
|
|
1233
|
+
* mirrors the first entry, so a caller written before the list existed keeps
|
|
1234
|
+
* working.
|
|
1235
|
+
*/
|
|
1236
|
+
comments?: ICommentStatusDTO[];
|
|
785
1237
|
}
|
|
786
1238
|
interface ISocialPublisherPostInstagramPostDetails extends ISocialPublisherPostAccount {
|
|
787
1239
|
description: string;
|
|
@@ -789,6 +1241,14 @@ interface ISocialPublisherPostInstagramPostDetails extends ISocialPublisherPostA
|
|
|
789
1241
|
is_published_to_both_feed_and_story: boolean;
|
|
790
1242
|
/** Per-platform comment status (only present when a comment was requested). */
|
|
791
1243
|
commentInfo?: ICommentInfoDTO;
|
|
1244
|
+
/**
|
|
1245
|
+
* One entry per comment on this platform, in posting order.
|
|
1246
|
+
*
|
|
1247
|
+
* Present when the post was created with `comments[]`. `commentInfo` above
|
|
1248
|
+
* mirrors the first entry, so a caller written before the list existed keeps
|
|
1249
|
+
* working.
|
|
1250
|
+
*/
|
|
1251
|
+
comments?: ICommentStatusDTO[];
|
|
792
1252
|
}
|
|
793
1253
|
interface ISocialPublisherPostYouTubePostDetails extends ISocialPublisherPostAccount {
|
|
794
1254
|
title: string;
|
|
@@ -802,6 +1262,14 @@ interface ISocialPublisherPostYouTubePostDetails extends ISocialPublisherPostAcc
|
|
|
802
1262
|
localizations: any;
|
|
803
1263
|
/** Per-platform comment status (only present when a comment was requested). */
|
|
804
1264
|
commentInfo?: ICommentInfoDTO;
|
|
1265
|
+
/**
|
|
1266
|
+
* One entry per comment on this platform, in posting order.
|
|
1267
|
+
*
|
|
1268
|
+
* Present when the post was created with `comments[]`. `commentInfo` above
|
|
1269
|
+
* mirrors the first entry, so a caller written before the list existed keeps
|
|
1270
|
+
* working.
|
|
1271
|
+
*/
|
|
1272
|
+
comments?: ICommentStatusDTO[];
|
|
805
1273
|
}
|
|
806
1274
|
interface ISocialPublisherPostNextPreviousResponse {
|
|
807
1275
|
nextId?: string;
|
|
@@ -819,6 +1287,89 @@ interface IBaseStatusHistoryGroupedItem<StatusType> {
|
|
|
819
1287
|
time: Date;
|
|
820
1288
|
status: StatusType;
|
|
821
1289
|
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Long-video metadata carried on a post. Present only when the post's `type`
|
|
1292
|
+
* is `longVideo`.
|
|
1293
|
+
*/
|
|
1294
|
+
interface IVideoDTO {
|
|
1295
|
+
/** Duration measured server-side, in seconds. */
|
|
1296
|
+
durationSeconds: number;
|
|
1297
|
+
/** Charge units billed — one per started 5 minutes. */
|
|
1298
|
+
creditUnits?: number;
|
|
1299
|
+
container?: string;
|
|
1300
|
+
videoCodec?: string;
|
|
1301
|
+
audioCodec?: string;
|
|
1302
|
+
width?: number;
|
|
1303
|
+
height?: number;
|
|
1304
|
+
sizeBytes?: number;
|
|
1305
|
+
}
|
|
1306
|
+
/** What one platform would do with a video of a given length. */
|
|
1307
|
+
interface ILongVideoPlatformVerdict {
|
|
1308
|
+
platform: "youtube" | "facebook" | "instagram" | "tiktok";
|
|
1309
|
+
accepted: boolean;
|
|
1310
|
+
/** The limit that applied, in seconds, when one did. */
|
|
1311
|
+
limitSeconds?: number;
|
|
1312
|
+
/** Why the platform refused. Present only when `accepted` is false. */
|
|
1313
|
+
reason?: string;
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Result of {@link SocialPublisherPostClient.getLongVideoQuote} — what the
|
|
1317
|
+
* post will cost, before committing to it.
|
|
1318
|
+
*/
|
|
1319
|
+
interface ILongVideoQuoteResponse {
|
|
1320
|
+
/** Duration measured server-side, in seconds, rounded up. */
|
|
1321
|
+
durationSeconds: number;
|
|
1322
|
+
/** The ceiling the API enforces (3600). */
|
|
1323
|
+
maxDurationSeconds: number;
|
|
1324
|
+
/** False when the video is over the ceiling; `reason` then says by how much. */
|
|
1325
|
+
withinLimit: boolean;
|
|
1326
|
+
/** Charge units — one per started 5 minutes. Zero when over the limit. */
|
|
1327
|
+
units: number;
|
|
1328
|
+
/** This plan's cost per unit (50 by default). */
|
|
1329
|
+
creditsPerUnit: number;
|
|
1330
|
+
/** Total credits the post will cost. */
|
|
1331
|
+
credits: number;
|
|
1332
|
+
/** True when the plan does not include long video posting. */
|
|
1333
|
+
isGated: boolean;
|
|
1334
|
+
container?: string;
|
|
1335
|
+
videoCodec?: string;
|
|
1336
|
+
width?: number;
|
|
1337
|
+
height?: number;
|
|
1338
|
+
/** What each platform would do with a video this long. */
|
|
1339
|
+
platforms: ILongVideoPlatformVerdict[];
|
|
1340
|
+
/** Present only when `withinLimit` is false. */
|
|
1341
|
+
reason?: string;
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* A connected platform dropped from a workspace post because the video is too
|
|
1345
|
+
* long for it. The rest of the post still publishes.
|
|
1346
|
+
*/
|
|
1347
|
+
interface ILongVideoRefusedTarget {
|
|
1348
|
+
platform: "youtube" | "facebook" | "instagram" | "tiktok";
|
|
1349
|
+
/** Names that platform's limit and this video's length. */
|
|
1350
|
+
reason: string;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Result of publishing a long video. Unlike the short-video helpers, which
|
|
1354
|
+
* return just an id, this carries what was measured and what was charged —
|
|
1355
|
+
* and which targets, if any, were dropped for exceeding their own limit.
|
|
1356
|
+
*/
|
|
1357
|
+
interface IPublishLongVideoResult {
|
|
1358
|
+
/** Created post ID. */
|
|
1359
|
+
_id: string;
|
|
1360
|
+
/** Duration measured server-side, in seconds. */
|
|
1361
|
+
durationSeconds: number;
|
|
1362
|
+
/** Charge units billed. */
|
|
1363
|
+
creditUnits: number;
|
|
1364
|
+
/** Credits actually charged. */
|
|
1365
|
+
credits: number;
|
|
1366
|
+
/**
|
|
1367
|
+
* Targets dropped because the video exceeded their duration limit. Empty
|
|
1368
|
+
* when every connected account accepted it. Always empty for account-targeted
|
|
1369
|
+
* posts, which are refused outright rather than partially published.
|
|
1370
|
+
*/
|
|
1371
|
+
refusedTargets: ILongVideoRefusedTarget[];
|
|
1372
|
+
}
|
|
822
1373
|
|
|
823
1374
|
/**
|
|
824
1375
|
* Social Publisher Post Client
|
|
@@ -849,6 +1400,28 @@ declare class SocialPublisherPostClient {
|
|
|
849
1400
|
* @param data - File information
|
|
850
1401
|
*/
|
|
851
1402
|
private generateUploadUrls;
|
|
1403
|
+
/**
|
|
1404
|
+
* Remove (delete) a post's published media directly from the connected
|
|
1405
|
+
* platform pages. Runs synchronously on the server — the media is deleted
|
|
1406
|
+
* from the platform immediately, not via a background job.
|
|
1407
|
+
*
|
|
1408
|
+
* Cost: 50 credits, charged ONLY when the removal succeeds (at least one
|
|
1409
|
+
* platform cleared and no delete-capable platform failed). Instagram and
|
|
1410
|
+
* TikTok expose no delete API, so a post published only to those platforms
|
|
1411
|
+
* cannot be removed programmatically and no credits are charged.
|
|
1412
|
+
*
|
|
1413
|
+
* @param id - Post ID
|
|
1414
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1415
|
+
* @returns Per-platform removal results, `__v` set to the post's new version
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* ```ts
|
|
1419
|
+
* const post = await client.getStatus("post_123");
|
|
1420
|
+
* const { results } = await client.removePost("post_123", post.__v);
|
|
1421
|
+
* // results.youtube?.success === true
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
removePost(id: string, version: number): Promise<IRemovePostResponse>;
|
|
852
1425
|
/**
|
|
853
1426
|
* Get next and previous post IDs
|
|
854
1427
|
* @param id - Current Post ID
|
|
@@ -901,6 +1474,22 @@ declare class SocialPublisherPostClient {
|
|
|
901
1474
|
* platforms in the request are ignored.
|
|
902
1475
|
*/
|
|
903
1476
|
createImagePostToAccount(data: ICreateImagePostToAccountRequest, id?: string): Promise<string>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Publish a text-only post to every text-capable account in a workspace
|
|
1479
|
+
* (Facebook, Threads, X). Platforms that cannot take text are reported in
|
|
1480
|
+
* `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
|
|
1481
|
+
*/
|
|
1482
|
+
createTextPostToWorkspace(data: ICreateTextPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1483
|
+
/** Publish a text-only post to one account. */
|
|
1484
|
+
createTextPostToAccount(data: ICreateTextPostToAccountRequest): Promise<ICreatePostResult>;
|
|
1485
|
+
/**
|
|
1486
|
+
* Publish a story to every story-capable account in a workspace. Media by URL
|
|
1487
|
+
* only in this release: `image: { source: "image-url", externalUrl }`, or
|
|
1488
|
+
* `source: "video-url"` with `videoURL`.
|
|
1489
|
+
*/
|
|
1490
|
+
createStoryPostToWorkspace(data: ICreateStoryPostToWorkspaceRequest): Promise<ICreatePostResult>;
|
|
1491
|
+
/** Publish a story to one account. Media by URL only, as for the workspace form. */
|
|
1492
|
+
createStoryPostToAccount(data: ICreateStoryPostToAccountRequest): Promise<ICreatePostResult>;
|
|
904
1493
|
/**
|
|
905
1494
|
* Handle thumbnail upload - accepts either File or URL string
|
|
906
1495
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -981,6 +1570,117 @@ declare class SocialPublisherPostClient {
|
|
|
981
1570
|
* @deprecated Use publishShortVideoToWorkspace instead
|
|
982
1571
|
*/
|
|
983
1572
|
publishShortVideo(options: IPublishOptions): Promise<string>;
|
|
1573
|
+
/**
|
|
1574
|
+
* Price a long video before publishing it. Neither creates nor charges
|
|
1575
|
+
* anything.
|
|
1576
|
+
*
|
|
1577
|
+
* The server reads the video, measures its duration, and returns the exact
|
|
1578
|
+
* cost plus what each platform would do with a video that long. Show this
|
|
1579
|
+
* before the user commits — the units come from the same function the create
|
|
1580
|
+
* call charges with, so the quote and the bill cannot disagree.
|
|
1581
|
+
*
|
|
1582
|
+
* @param videoURL - URL of an uploaded or externally hosted video
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```ts
|
|
1586
|
+
* const quote = await client.getLongVideoQuote(fileURL);
|
|
1587
|
+
* if (!quote.withinLimit) throw new Error(quote.reason);
|
|
1588
|
+
* console.log(`${quote.durationSeconds}s costs ${quote.credits} credits`);
|
|
1589
|
+
* const blocked = quote.platforms.filter((p) => !p.accepted);
|
|
1590
|
+
* ```
|
|
1591
|
+
*/
|
|
1592
|
+
getLongVideoQuote(videoURL: string): Promise<ILongVideoQuoteResponse>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Publish a video of up to 60 minutes to every account connected to a
|
|
1595
|
+
* workspace.
|
|
1596
|
+
*
|
|
1597
|
+
* Handles the whole sequence for an uploaded file: request an upload
|
|
1598
|
+
* destination, push the bytes, then create the post. Pass a URL instead of a
|
|
1599
|
+
* `File` to publish something already hosted elsewhere.
|
|
1600
|
+
*
|
|
1601
|
+
* Cost is duration-based — 50 credits per started 5 minutes — so a 12-minute
|
|
1602
|
+
* video costs 150. Call {@link getLongVideoQuote} first if you need to show
|
|
1603
|
+
* the price. The duration is measured server-side; there is no duration
|
|
1604
|
+
* option here because a client-supplied one would be a client-supplied price.
|
|
1605
|
+
*
|
|
1606
|
+
* Platforms differ on what they accept: a 40-minute video publishes to
|
|
1607
|
+
* YouTube and Facebook but is refused by Instagram, whose Reels cap at 15
|
|
1608
|
+
* minutes. Those targets come back in `refusedTargets` — the post still
|
|
1609
|
+
* publishes to the rest.
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* const result = await client.publishLongVideoToWorkspace({
|
|
1614
|
+
* workspaceId: "ws_123",
|
|
1615
|
+
* video: recordingFile,
|
|
1616
|
+
* youtube: { title: "Full session", description: "...", tags: ["workshop"] },
|
|
1617
|
+
* onProgress: (p) => console.log(`${p}%`),
|
|
1618
|
+
* });
|
|
1619
|
+
* console.log(`Charged ${result.credits} credits for ${result.durationSeconds}s`);
|
|
1620
|
+
* for (const t of result.refusedTargets) console.warn(t.reason);
|
|
1621
|
+
* ```
|
|
1622
|
+
*/
|
|
1623
|
+
publishLongVideoToWorkspace(options: IPublishLongVideoOptions): Promise<IPublishLongVideoResult>;
|
|
1624
|
+
/**
|
|
1625
|
+
* Publish a video of up to 60 minutes to a single connected account.
|
|
1626
|
+
*
|
|
1627
|
+
* With one target there is no partial success: if that platform will not take
|
|
1628
|
+
* a video this long, the whole call is refused and nothing is charged. See
|
|
1629
|
+
* {@link publishLongVideoToWorkspace} for the cost model.
|
|
1630
|
+
*/
|
|
1631
|
+
publishLongVideoToAccount(options: IPublishLongVideoToAccountOptions): Promise<IPublishLongVideoResult>;
|
|
1632
|
+
/**
|
|
1633
|
+
* Re-schedule a post that has not published yet, or send it out now.
|
|
1634
|
+
*
|
|
1635
|
+
* Free — this costs no credits. Only posts still pending with a future
|
|
1636
|
+
* publish time are eligible; anything that has started publishing is refused
|
|
1637
|
+
* by the server with a reason.
|
|
1638
|
+
*
|
|
1639
|
+
* @example
|
|
1640
|
+
* ```ts
|
|
1641
|
+
* const post = await client.getStatus("post_123");
|
|
1642
|
+
* const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
|
|
1643
|
+
* await client.reschedulePost("post_123", { schedule: "now" }, __v);
|
|
1644
|
+
* ```
|
|
1645
|
+
*
|
|
1646
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1647
|
+
* @returns `{ _id, __v }`, `__v` being the new version
|
|
1648
|
+
*/
|
|
1649
|
+
reschedulePost(id: string, data: IReschedulePostRequest, version: number): Promise<{
|
|
1650
|
+
_id: string;
|
|
1651
|
+
__v: number;
|
|
1652
|
+
}>;
|
|
1653
|
+
/**
|
|
1654
|
+
* Delete a post that has not published yet, releasing its uploaded media in
|
|
1655
|
+
* the same request.
|
|
1656
|
+
*
|
|
1657
|
+
* Free, and nothing is refunded — nothing was charged for a post that never
|
|
1658
|
+
* went out. A post that HAS published is refused; use {@link removePost} to
|
|
1659
|
+
* take down media that is already live.
|
|
1660
|
+
*
|
|
1661
|
+
* @example
|
|
1662
|
+
* ```ts
|
|
1663
|
+
* await client.deletePost("post_123", post.__v);
|
|
1664
|
+
* ```
|
|
1665
|
+
*
|
|
1666
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
1667
|
+
*/
|
|
1668
|
+
deletePost(id: string, version: number): Promise<void>;
|
|
1669
|
+
/**
|
|
1670
|
+
* Upload a long video and return the URL to publish from.
|
|
1671
|
+
*
|
|
1672
|
+
* Declares `postType: "longVideo"` so the server refuses now — on plan gating
|
|
1673
|
+
* or an empty balance — rather than after an hour of transfer.
|
|
1674
|
+
*/
|
|
1675
|
+
private uploadLongVideo;
|
|
1676
|
+
/** Translate the friendly `"now" | Date` form into the wire shape. */
|
|
1677
|
+
private buildSchedule;
|
|
1678
|
+
/**
|
|
1679
|
+
* Guarantee the shape callers destructure. An older server that does not yet
|
|
1680
|
+
* return the duration fields would otherwise hand back `undefined` where the
|
|
1681
|
+
* types promise numbers.
|
|
1682
|
+
*/
|
|
1683
|
+
private normaliseLongVideoResult;
|
|
984
1684
|
/**
|
|
985
1685
|
* Auto-detect video source type.
|
|
986
1686
|
*
|
|
@@ -990,4 +1690,83 @@ declare class SocialPublisherPostClient {
|
|
|
990
1690
|
private detectVideoSource;
|
|
991
1691
|
}
|
|
992
1692
|
|
|
993
|
-
|
|
1693
|
+
/**
|
|
1694
|
+
* Resumable uploads (tus 1.0.0) for large media.
|
|
1695
|
+
*
|
|
1696
|
+
* A signed PUT is all-or-nothing: a dropped connection at 90% of an hour-long
|
|
1697
|
+
* video starts again from zero. The API offers the same destination as a
|
|
1698
|
+
* resumable transfer, and this is the client for it.
|
|
1699
|
+
*
|
|
1700
|
+
* The protocol subset needed here is small — create, patch, head — so it is
|
|
1701
|
+
* implemented directly rather than by pulling `tus-js-client` into a published
|
|
1702
|
+
* SDK's dependency tree. What is deliberately NOT implemented is fingerprint
|
|
1703
|
+
* storage: resuming across page loads needs somewhere to persist the upload
|
|
1704
|
+
* URL, which is the caller's decision, not a library's. Pass `uploadUrl` back
|
|
1705
|
+
* in to resume an earlier attempt yourself.
|
|
1706
|
+
*/
|
|
1707
|
+
|
|
1708
|
+
/**
|
|
1709
|
+
* 8MiB matches the server's multipart part size, so one PATCH becomes one R2
|
|
1710
|
+
* part with no server-side re-buffering. It also caps how much progress a
|
|
1711
|
+
* dropped connection can cost.
|
|
1712
|
+
*/
|
|
1713
|
+
declare const DEFAULT_CHUNK_SIZE: number;
|
|
1714
|
+
interface IResumableUploadOptions {
|
|
1715
|
+
/** Called with 0-100 as the transfer proceeds. */
|
|
1716
|
+
onProgress?: (progress: number) => void;
|
|
1717
|
+
/**
|
|
1718
|
+
* Called once the upload exists on the server, with its URL. Persist this to
|
|
1719
|
+
* resume the same transfer later — the ticket expires, but an upload that
|
|
1720
|
+
* already exists resumes by its own URL and is unaffected.
|
|
1721
|
+
*/
|
|
1722
|
+
onUploadUrl?: (uploadUrl: string) => void;
|
|
1723
|
+
/** Resume a previous attempt instead of creating a new upload. */
|
|
1724
|
+
uploadUrl?: string;
|
|
1725
|
+
/** Bytes per PATCH. Defaults to the server's 8MiB part size. */
|
|
1726
|
+
chunkSize?: number;
|
|
1727
|
+
/** Abort the transfer. A partially uploaded file can be resumed later. */
|
|
1728
|
+
signal?: AbortSignal;
|
|
1729
|
+
/**
|
|
1730
|
+
* Tell the server to discard the partial upload when `signal` fires.
|
|
1731
|
+
*
|
|
1732
|
+
* Off by default, and deliberately so: the reason abort leaves the bytes in
|
|
1733
|
+
* place is that "cancel" and "pause" are the same gesture in most UIs, and a
|
|
1734
|
+
* user who paused a 40-minute video does not expect to start over. Turn this
|
|
1735
|
+
* on where the abort really is final — a wizard the user closed, a file they
|
|
1736
|
+
* replaced — so the server stops holding megabytes nobody will claim.
|
|
1737
|
+
*
|
|
1738
|
+
* Best-effort: a failed termination is swallowed, because the caller is
|
|
1739
|
+
* already being handed an AbortError and the server expires the upload on its
|
|
1740
|
+
* own after 24h regardless.
|
|
1741
|
+
*/
|
|
1742
|
+
terminateOnAbort?: boolean;
|
|
1743
|
+
/** Content type stamped on the request when the blob does not carry one. */
|
|
1744
|
+
fallbackType?: string;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Whether this target can be uploaded resumably. A server without the resumable
|
|
1748
|
+
* service configured simply omits these fields, and callers fall back.
|
|
1749
|
+
*/
|
|
1750
|
+
declare function supportsResumableUpload(target: IUploadTarget): boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* Discard an upload the server is still holding (tus Termination extension).
|
|
1753
|
+
*
|
|
1754
|
+
* Exported because the decision is the caller's: an upload URL persisted from
|
|
1755
|
+
* `onUploadUrl` outlives the transfer that created it, and only the caller knows
|
|
1756
|
+
* whether the user means to come back to it. Without this the bytes sit on the
|
|
1757
|
+
* server until its 24h expiry sweep.
|
|
1758
|
+
*
|
|
1759
|
+
* Resolves `true` when the server confirms, `false` when it refuses or is
|
|
1760
|
+
* unreachable — never throws, since nothing useful can be done about a failed
|
|
1761
|
+
* cleanup of something that expires on its own.
|
|
1762
|
+
*/
|
|
1763
|
+
declare function terminateUpload(uploadUrl: string): Promise<boolean>;
|
|
1764
|
+
/**
|
|
1765
|
+
* Upload a file resumably, returning the public URL it lands at.
|
|
1766
|
+
*
|
|
1767
|
+
* `target.fileURL` came back with the ticket, so the final URL is known up
|
|
1768
|
+
* front and there is no completion body to parse.
|
|
1769
|
+
*/
|
|
1770
|
+
declare function uploadResumable(target: IUploadTarget, file: Blob, options?: IResumableUploadOptions): Promise<string>;
|
|
1771
|
+
|
|
1772
|
+
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 };
|