post-upload 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +525 -2
- package/dist/cli.js +297 -0
- package/dist/index.d.mts +660 -0
- package/dist/index.d.ts +660 -0
- package/dist/index.js +1034 -0
- package/dist/index.mjs +984 -0
- package/package.json +96 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
interface PostUploadConfig {
|
|
2
|
+
/** Your Post-Upload API key (Dashboard → API Keys). */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** API base URL. Default: https://api.post-upload.com */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Request timeout in milliseconds. Default: 120000 (120 s). */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
/** Custom fetch implementation (defaults to the global `fetch`, Node >= 18). */
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
/** Extra headers sent with every request. */
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
/** First retry delay (ms) for chunked-upload steps; doubles per attempt unless the server sends Retry-After. Default 1000. */
|
|
13
|
+
retryBaseDelayMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/** @deprecated Use {@link PostUploadConfig}. */
|
|
16
|
+
type IndReelForgeConfig = PostUploadConfig;
|
|
17
|
+
/** @deprecated Use {@link PostUploadConfig}. */
|
|
18
|
+
type InReelForgeConfig = PostUploadConfig;
|
|
19
|
+
type Platform = 'instagram' | 'youtube' | 'tiktok' | 'facebook' | 'x' | 'linkedin' | 'threads' | 'pinterest' | 'reddit' | 'bluesky' | 'google_business' | 'discord' | 'telegram' | 'slack' | 'mastodon' | 'wordpress' | 'devto' | 'hashnode' | 'lemmy' | 'nostr' | 'whop' | 'listmonk' | (string & {});
|
|
20
|
+
/** Every platform key known to this SDK version. */
|
|
21
|
+
declare const PLATFORMS: readonly ["instagram", "youtube", "tiktok", "facebook", "x", "linkedin", "threads", "pinterest", "reddit", "bluesky", "google_business", "discord", "telegram", "slack", "mastodon", "wordpress", "devto", "hashnode", "lemmy", "nostr", "whop", "listmonk"];
|
|
22
|
+
/** Credential fields for platforms that connect with credentials instead of OAuth. */
|
|
23
|
+
interface PlatformCredentials {
|
|
24
|
+
/** Channel webhook URL (Server Settings → Integrations → Webhooks). */
|
|
25
|
+
discord: {
|
|
26
|
+
webhook_url: string;
|
|
27
|
+
};
|
|
28
|
+
/** Bot token from @BotFather; chat_id is a public channel `@username` or a numeric chat id. */
|
|
29
|
+
telegram: {
|
|
30
|
+
bot_token: string;
|
|
31
|
+
chat_id: string;
|
|
32
|
+
};
|
|
33
|
+
/** Incoming webhook URL. Slack can't verify it without posting, so a bad URL only fails on the first post. */
|
|
34
|
+
slack: {
|
|
35
|
+
webhook_url: string;
|
|
36
|
+
};
|
|
37
|
+
/** Instance URL (e.g. https://mastodon.social) and an access token with write:statuses + write:media. */
|
|
38
|
+
mastodon: {
|
|
39
|
+
instance_url: string;
|
|
40
|
+
access_token: string;
|
|
41
|
+
};
|
|
42
|
+
/** Self-hosted site URL, a user who can publish, and an application password. */
|
|
43
|
+
wordpress: {
|
|
44
|
+
site_url: string;
|
|
45
|
+
username: string;
|
|
46
|
+
app_password: string;
|
|
47
|
+
};
|
|
48
|
+
/** DEV / Forem API key; `base_url` only for a Forem site other than dev.to. */
|
|
49
|
+
devto: {
|
|
50
|
+
api_key: string;
|
|
51
|
+
base_url?: string;
|
|
52
|
+
};
|
|
53
|
+
/** Personal access token and the publication ID (Hashnode Pro publications only). */
|
|
54
|
+
hashnode: {
|
|
55
|
+
access_token: string;
|
|
56
|
+
publication_id: string;
|
|
57
|
+
};
|
|
58
|
+
/** Instance, account and community (`name` or `name@instance`); `totp` only if 2FA is on (used once, not stored). */
|
|
59
|
+
lemmy: {
|
|
60
|
+
instance_url: string;
|
|
61
|
+
username: string;
|
|
62
|
+
password: string;
|
|
63
|
+
community: string;
|
|
64
|
+
totp?: string;
|
|
65
|
+
};
|
|
66
|
+
/** Private key (`nsec1…` or 64-char hex); optional comma-separated wss:// relays and a Blossom media server. */
|
|
67
|
+
nostr: {
|
|
68
|
+
nsec: string;
|
|
69
|
+
relays?: string;
|
|
70
|
+
blossom_server?: string;
|
|
71
|
+
};
|
|
72
|
+
/** API key plus either a forum `experience_id` (exp_…) or a chat `channel_id` (not both). */
|
|
73
|
+
whop: {
|
|
74
|
+
api_key: string;
|
|
75
|
+
experience_id?: string;
|
|
76
|
+
channel_id?: string;
|
|
77
|
+
};
|
|
78
|
+
/** Listmonk URL, an API user + token, and the numeric list IDs (comma-separated) each campaign is sent to. */
|
|
79
|
+
listmonk: {
|
|
80
|
+
base_url: string;
|
|
81
|
+
api_user: string;
|
|
82
|
+
api_token: string;
|
|
83
|
+
list_ids: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
type CredentialPlatform = keyof PlatformCredentials;
|
|
87
|
+
/** Platforms connected via `connectWithCredentials()`, with their required fields. */
|
|
88
|
+
declare const CREDENTIAL_PLATFORMS: {
|
|
89
|
+
readonly [P in CredentialPlatform]: ReadonlyArray<keyof PlatformCredentials[P]>;
|
|
90
|
+
};
|
|
91
|
+
interface ConnectCredentialsResponse {
|
|
92
|
+
success: boolean;
|
|
93
|
+
message: string;
|
|
94
|
+
/** Account / channel name the credentials resolved to. */
|
|
95
|
+
platform_username: string;
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}
|
|
98
|
+
/** Value accepted for a platform-specific form field. */
|
|
99
|
+
type PlatformOptionValue = string | number | boolean | string[] | Record<string, unknown> | null | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Platform-specific fields, sent verbatim as form fields (snake_case API names),
|
|
102
|
+
* e.g. `{ privacy_level: 'PUBLIC_TO_EVERYONE', pinterest_board_id: '123', gbp_cta_type: 'LEARN_MORE' }`.
|
|
103
|
+
* Arrays are sent as repeated fields, booleans as "true"/"false", objects as JSON.
|
|
104
|
+
*/
|
|
105
|
+
type PlatformOptions = Record<string, PlatformOptionValue>;
|
|
106
|
+
interface UploadOptions {
|
|
107
|
+
/** Profile name (managed user). */
|
|
108
|
+
user: string;
|
|
109
|
+
/** Platforms to publish to. */
|
|
110
|
+
platforms: Platform[];
|
|
111
|
+
/** Post title / caption. */
|
|
112
|
+
title?: string;
|
|
113
|
+
/** Long description (YouTube, LinkedIn, Facebook, Pinterest, ...). */
|
|
114
|
+
description?: string;
|
|
115
|
+
/** First comment (Instagram, Facebook, YouTube, X, Threads, ...). */
|
|
116
|
+
firstComment?: string;
|
|
117
|
+
/** Schedule for later: ISO-8601 datetime. */
|
|
118
|
+
schedule?: string;
|
|
119
|
+
/** IANA timezone used with `schedule` (e.g. "America/New_York"). */
|
|
120
|
+
timezone?: string;
|
|
121
|
+
/** Add the post to the profile's next free queue slot. */
|
|
122
|
+
addToQueue?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* `false` = synchronous mode: the server waits (up to ~50 s) for the publish
|
|
125
|
+
* result and returns `{ sync: true, data: { status, platforms, platform_post_ids } }`.
|
|
126
|
+
* Default (omitted / `true`) returns immediately and publishes in the background.
|
|
127
|
+
*/
|
|
128
|
+
asyncUpload?: boolean;
|
|
129
|
+
/** Your own correlation id; look the upload up later with `getRequestStatus()`. */
|
|
130
|
+
requestId?: string;
|
|
131
|
+
/** Sent as the `Idempotency-Key` header: retries with the same key never double-post. */
|
|
132
|
+
idempotencyKey?: string;
|
|
133
|
+
/** Any platform-specific fields (see {@link PlatformOptions}). */
|
|
134
|
+
platformOptions?: PlatformOptions;
|
|
135
|
+
instagramTitle?: string;
|
|
136
|
+
youtubeTitle?: string;
|
|
137
|
+
youtubeDescription?: string;
|
|
138
|
+
youtubeTags?: string[];
|
|
139
|
+
youtubePrivacy?: 'public' | 'private' | 'unlisted';
|
|
140
|
+
}
|
|
141
|
+
/** Progress of a chunked upload, reported after each part. */
|
|
142
|
+
interface UploadProgress {
|
|
143
|
+
/** Bytes confirmed by the server so far. */
|
|
144
|
+
uploadedBytes: number;
|
|
145
|
+
/** Total file size in bytes. */
|
|
146
|
+
totalBytes: number;
|
|
147
|
+
/** Number of parts uploaded so far (1-based count). */
|
|
148
|
+
part: number;
|
|
149
|
+
/** Total number of parts. */
|
|
150
|
+
totalParts: number;
|
|
151
|
+
}
|
|
152
|
+
/** What can be sent as a video: a local path, a Buffer / Uint8Array, or a readable stream. */
|
|
153
|
+
type VideoSource = string | Uint8Array | NodeJS.ReadableStream | AsyncIterable<Uint8Array>;
|
|
154
|
+
interface ChunkedUploadOptions {
|
|
155
|
+
/** File name sent to the server (its extension decides the type). Default: the path's basename, or "video.mp4". */
|
|
156
|
+
filename?: string;
|
|
157
|
+
/** MIME type. Default: guessed from the file name (video/mp4 when unknown). */
|
|
158
|
+
mimeType?: string;
|
|
159
|
+
/** Size in bytes. Required for streams; read from disk / the buffer otherwise. */
|
|
160
|
+
size?: number;
|
|
161
|
+
/** Called after each part is uploaded. */
|
|
162
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
163
|
+
/** Attempts per part (and per init/complete call) on 429 / 5xx / network errors. Default 5. */
|
|
164
|
+
maxRetries?: number;
|
|
165
|
+
}
|
|
166
|
+
interface UploadVideoOptions extends UploadOptions {
|
|
167
|
+
/** Path to a local video file. */
|
|
168
|
+
videoPath?: string;
|
|
169
|
+
/** Video bytes (Buffer / Uint8Array) or a readable stream (requires `size` for chunked uploads). */
|
|
170
|
+
video?: Uint8Array | NodeJS.ReadableStream | AsyncIterable<Uint8Array>;
|
|
171
|
+
/** Public http(s) URL of a video (up to 500 MB); the server downloads it. */
|
|
172
|
+
videoUrl?: string;
|
|
173
|
+
/** A file already sent with the chunked upload endpoints (`uploadLargeFile` / `completeUploadSession`). */
|
|
174
|
+
stagedFileId?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Send the file in parts through the chunked upload endpoints (up to 500 MB).
|
|
177
|
+
* Default `'auto'`: chunked when the file is larger than {@link CHUNKED_THRESHOLD_BYTES} (95 MiB),
|
|
178
|
+
* which is required above ~100 MB. `true` always, `false` never.
|
|
179
|
+
*/
|
|
180
|
+
chunked?: boolean | 'auto';
|
|
181
|
+
/** File name for a Buffer / stream `video` (default "video.mp4"). */
|
|
182
|
+
filename?: string;
|
|
183
|
+
/** MIME type for the file (default: guessed from the name). */
|
|
184
|
+
mimeType?: string;
|
|
185
|
+
/** Size in bytes of a stream `video` (needed for a chunked upload of a stream). */
|
|
186
|
+
size?: number;
|
|
187
|
+
/** Progress of a chunked upload (called after each part). */
|
|
188
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
189
|
+
/** Attempts per part on 429 / 5xx / network errors during a chunked upload. Default 5. */
|
|
190
|
+
maxRetries?: number;
|
|
191
|
+
}
|
|
192
|
+
/** Files above this size are sent with the chunked upload endpoints by default (Cloudflare caps a request at 100 MB). */
|
|
193
|
+
declare const CHUNKED_THRESHOLD_BYTES: number;
|
|
194
|
+
/** Largest video the API accepts (chunked upload or `videoUrl`). */
|
|
195
|
+
declare const MAX_VIDEO_BYTES: number;
|
|
196
|
+
interface CreateUploadSessionOptions {
|
|
197
|
+
filename: string;
|
|
198
|
+
/** File size in bytes. */
|
|
199
|
+
size: number;
|
|
200
|
+
/** e.g. "video/mp4". */
|
|
201
|
+
mime_type?: string;
|
|
202
|
+
}
|
|
203
|
+
interface UploadSession {
|
|
204
|
+
success?: boolean;
|
|
205
|
+
upload_session_id: string;
|
|
206
|
+
/** Every part except the last must be exactly this many bytes. */
|
|
207
|
+
chunk_size: number;
|
|
208
|
+
total_chunks: number;
|
|
209
|
+
expires_at: string;
|
|
210
|
+
[key: string]: any;
|
|
211
|
+
}
|
|
212
|
+
interface UploadSessionStatus {
|
|
213
|
+
success?: boolean;
|
|
214
|
+
upload_session_id?: string;
|
|
215
|
+
status?: string;
|
|
216
|
+
/** Indexes already received (to resume). */
|
|
217
|
+
received_chunks?: number[];
|
|
218
|
+
total_chunks?: number;
|
|
219
|
+
chunk_size?: number;
|
|
220
|
+
staged_file_id?: string;
|
|
221
|
+
expires_at?: string;
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
}
|
|
224
|
+
interface CompleteUploadSessionResponse {
|
|
225
|
+
success?: boolean;
|
|
226
|
+
/** Pass to `uploadVideo({ stagedFileId })` / `POST /api/upload staged_file_id`. Usable once. */
|
|
227
|
+
staged_file_id: string;
|
|
228
|
+
expires_at?: string;
|
|
229
|
+
message?: string;
|
|
230
|
+
[key: string]: any;
|
|
231
|
+
}
|
|
232
|
+
interface UploadPhotoOptions extends UploadOptions {
|
|
233
|
+
/** Paths to local photo files (max 10 in total with `photoUrls`). */
|
|
234
|
+
photoPaths?: string[];
|
|
235
|
+
/** Public http(s) URLs of photos (max 10 in total with `photoPaths`). */
|
|
236
|
+
photoUrls?: string[];
|
|
237
|
+
}
|
|
238
|
+
interface UploadTextOptions extends UploadOptions {
|
|
239
|
+
/** Text content. Either `text` or `title` is required. */
|
|
240
|
+
text?: string;
|
|
241
|
+
}
|
|
242
|
+
interface UploadDocumentOptions {
|
|
243
|
+
/** Profile name (managed user). Document posts go to LinkedIn. */
|
|
244
|
+
user: string;
|
|
245
|
+
/** Path to a PDF, PPT, PPTX, DOC or DOCX file (max 100 MB). */
|
|
246
|
+
documentPath: string;
|
|
247
|
+
title?: string;
|
|
248
|
+
description?: string;
|
|
249
|
+
firstComment?: string;
|
|
250
|
+
/** LinkedIn visibility, e.g. "PUBLIC" or "CONNECTIONS". */
|
|
251
|
+
visibility?: string;
|
|
252
|
+
/** Post as a LinkedIn company page instead of the personal profile. */
|
|
253
|
+
targetLinkedinPageId?: string;
|
|
254
|
+
schedule?: string;
|
|
255
|
+
timezone?: string;
|
|
256
|
+
requestId?: string;
|
|
257
|
+
idempotencyKey?: string;
|
|
258
|
+
platformOptions?: PlatformOptions;
|
|
259
|
+
}
|
|
260
|
+
interface UploadWarning {
|
|
261
|
+
/** e.g. `upload_limit`, `ffmpeg_limit`, `platform_rate_limit`, `platform_skipped`. */
|
|
262
|
+
type: string;
|
|
263
|
+
level?: string;
|
|
264
|
+
platform?: string;
|
|
265
|
+
error_code?: string;
|
|
266
|
+
message: string;
|
|
267
|
+
[key: string]: any;
|
|
268
|
+
}
|
|
269
|
+
/** A platform the file was too large for: stored as failed, never sent, no quota used. */
|
|
270
|
+
interface SkippedPlatform {
|
|
271
|
+
platform: Platform;
|
|
272
|
+
/** `FILE_TOO_LARGE_FOR_PLATFORM`. */
|
|
273
|
+
error_code: string;
|
|
274
|
+
message: string;
|
|
275
|
+
file_size_mb?: number;
|
|
276
|
+
max_size_mb?: number;
|
|
277
|
+
[key: string]: any;
|
|
278
|
+
}
|
|
279
|
+
interface UploadResponse {
|
|
280
|
+
success?: boolean;
|
|
281
|
+
/** Present on some responses (e.g. idempotent replays). */
|
|
282
|
+
status?: string;
|
|
283
|
+
message: string;
|
|
284
|
+
request_id?: string;
|
|
285
|
+
/** `true` when `asyncUpload: false` and the publish finished within the wait window. */
|
|
286
|
+
sync?: boolean;
|
|
287
|
+
data: {
|
|
288
|
+
upload_id: string;
|
|
289
|
+
platforms: Record<string, unknown> | string[];
|
|
290
|
+
status?: string;
|
|
291
|
+
platform_post_ids?: Record<string, string> | null;
|
|
292
|
+
/** With skipped platforms: JSON string `{"platform_errors": {…}}`. */
|
|
293
|
+
error_message?: string | null;
|
|
294
|
+
scheduled_date?: string;
|
|
295
|
+
/** Platforms the file was too large for (the others still publish). */
|
|
296
|
+
skipped_platforms?: SkippedPlatform[];
|
|
297
|
+
[key: string]: any;
|
|
298
|
+
};
|
|
299
|
+
warnings?: UploadWarning[];
|
|
300
|
+
[key: string]: any;
|
|
301
|
+
}
|
|
302
|
+
type UploadStatus = 'queued' | 'processing' | 'scheduled' | 'completed' | 'partial' | 'failed' | 'cancelled';
|
|
303
|
+
interface UploadStatusResponse {
|
|
304
|
+
upload_id: string;
|
|
305
|
+
request_id?: string | null;
|
|
306
|
+
status: UploadStatus | string;
|
|
307
|
+
upload_type: string;
|
|
308
|
+
platforms: Record<string, unknown> | null;
|
|
309
|
+
platform_post_ids: Record<string, string> | null;
|
|
310
|
+
created_at: string;
|
|
311
|
+
completed_at: string | null;
|
|
312
|
+
scheduled_at?: string | null;
|
|
313
|
+
error_message: string | null;
|
|
314
|
+
}
|
|
315
|
+
interface UploadRecord {
|
|
316
|
+
id: string;
|
|
317
|
+
title: string | null;
|
|
318
|
+
description: string | null;
|
|
319
|
+
upload_type: string;
|
|
320
|
+
platforms: string[];
|
|
321
|
+
platform_statuses: Record<string, unknown> | null;
|
|
322
|
+
platform_post_ids: Record<string, string> | null;
|
|
323
|
+
platform_post_urls: Record<string, string> | null;
|
|
324
|
+
status: UploadStatus | string;
|
|
325
|
+
scheduled_at: string | null;
|
|
326
|
+
created_at: string;
|
|
327
|
+
completed_at: string | null;
|
|
328
|
+
error_message: string | null;
|
|
329
|
+
[key: string]: any;
|
|
330
|
+
}
|
|
331
|
+
interface ListUploadsOptions {
|
|
332
|
+
/** Page size (1-100, default 20). */
|
|
333
|
+
limit?: number;
|
|
334
|
+
/** Page number (1-based). */
|
|
335
|
+
page?: number;
|
|
336
|
+
status?: UploadStatus;
|
|
337
|
+
}
|
|
338
|
+
interface ListUploadsResponse {
|
|
339
|
+
uploads: UploadRecord[];
|
|
340
|
+
pagination: {
|
|
341
|
+
page: number;
|
|
342
|
+
limit: number;
|
|
343
|
+
total: number;
|
|
344
|
+
pages: number;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
interface Me {
|
|
348
|
+
id: number | string;
|
|
349
|
+
email: string;
|
|
350
|
+
role: string;
|
|
351
|
+
plan: string;
|
|
352
|
+
uploads_this_month: number | null;
|
|
353
|
+
month_reset_at: string | null;
|
|
354
|
+
api_key_id?: number | string;
|
|
355
|
+
[key: string]: any;
|
|
356
|
+
}
|
|
357
|
+
interface Profile {
|
|
358
|
+
id: number;
|
|
359
|
+
name: string;
|
|
360
|
+
platforms: Record<string, boolean>;
|
|
361
|
+
created_at: string;
|
|
362
|
+
[key: string]: any;
|
|
363
|
+
}
|
|
364
|
+
interface ProfilesResponse {
|
|
365
|
+
profiles: Profile[];
|
|
366
|
+
usage: {
|
|
367
|
+
current: number;
|
|
368
|
+
limit: number;
|
|
369
|
+
};
|
|
370
|
+
[key: string]: any;
|
|
371
|
+
}
|
|
372
|
+
interface ScheduledPost {
|
|
373
|
+
id: string;
|
|
374
|
+
title: string | null;
|
|
375
|
+
description: string | null;
|
|
376
|
+
upload_type: string;
|
|
377
|
+
platforms: string[];
|
|
378
|
+
platform_statuses: Record<string, unknown> | null;
|
|
379
|
+
scheduled_at: string;
|
|
380
|
+
timezone: string | null;
|
|
381
|
+
created_at: string;
|
|
382
|
+
}
|
|
383
|
+
interface UpdateScheduledPostOptions {
|
|
384
|
+
/** New ISO-8601 datetime (or a zoneless wall-clock time combined with `timezone`). */
|
|
385
|
+
scheduledDate?: string;
|
|
386
|
+
timezone?: string;
|
|
387
|
+
title?: string;
|
|
388
|
+
caption?: string;
|
|
389
|
+
}
|
|
390
|
+
interface QueueSlot {
|
|
391
|
+
/** "HH:MM" (24h). */
|
|
392
|
+
time?: string;
|
|
393
|
+
[key: string]: any;
|
|
394
|
+
}
|
|
395
|
+
interface UpdateQueueSettingsOptions {
|
|
396
|
+
/** Profile name the queue belongs to. */
|
|
397
|
+
profile: string;
|
|
398
|
+
/** Posting times, e.g. ["09:00", "13:00"] or slot objects. */
|
|
399
|
+
slots?: Array<string | QueueSlot>;
|
|
400
|
+
/** 0 = Sunday … 6 = Saturday. */
|
|
401
|
+
daysOfWeek?: number[];
|
|
402
|
+
timezone?: string;
|
|
403
|
+
maxPostsPerSlot?: number;
|
|
404
|
+
}
|
|
405
|
+
interface TotalImpressionsOptions {
|
|
406
|
+
platform?: string;
|
|
407
|
+
period?: string;
|
|
408
|
+
startDate?: string;
|
|
409
|
+
endDate?: string;
|
|
410
|
+
}
|
|
411
|
+
interface AnalyticsOverview {
|
|
412
|
+
total_views: string;
|
|
413
|
+
total_uploads: string;
|
|
414
|
+
engagement_rate: string;
|
|
415
|
+
followers_gained: string;
|
|
416
|
+
views_trend?: string;
|
|
417
|
+
uploads_trend?: string;
|
|
418
|
+
[key: string]: any;
|
|
419
|
+
}
|
|
420
|
+
interface Plan {
|
|
421
|
+
name: string;
|
|
422
|
+
slug: string;
|
|
423
|
+
price_monthly: string;
|
|
424
|
+
price_annual: string;
|
|
425
|
+
features: string[];
|
|
426
|
+
[key: string]: any;
|
|
427
|
+
}
|
|
428
|
+
/** Generic JSON object returned by endpoints without a dedicated type. */
|
|
429
|
+
type JsonObject = Record<string, any>;
|
|
430
|
+
|
|
431
|
+
declare const DEFAULT_BASE_URL = "https://api.post-upload.com";
|
|
432
|
+
/**
|
|
433
|
+
* Official Node.js client for the Post-Upload Social Media API.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* const client = new PostUpload(process.env.POST_UPLOAD_API_KEY!);
|
|
437
|
+
* await client.uploadVideo('./clip.mp4', { user: 'my-profile', platforms: ['tiktok'] });
|
|
438
|
+
*/
|
|
439
|
+
declare class PostUpload {
|
|
440
|
+
private apiKey;
|
|
441
|
+
private baseUrl;
|
|
442
|
+
private timeout;
|
|
443
|
+
private fetchImpl;
|
|
444
|
+
private extraHeaders;
|
|
445
|
+
private retryBaseDelayMs;
|
|
446
|
+
/**
|
|
447
|
+
* @param config Options object, or just the API key (`new PostUpload('key')`,
|
|
448
|
+
* optionally followed by the other options).
|
|
449
|
+
*/
|
|
450
|
+
constructor(config: PostUploadConfig | string, options?: Omit<PostUploadConfig, 'apiKey'>);
|
|
451
|
+
private request;
|
|
452
|
+
private buildForm;
|
|
453
|
+
private idemHeaders;
|
|
454
|
+
/**
|
|
455
|
+
* Upload a video: a local file (`videoPath`, or a path as the first argument), a Buffer or
|
|
456
|
+
* stream (`video`), a public URL (`videoUrl`, up to 500 MB, downloaded by the server) or a
|
|
457
|
+
* file already sent in parts (`stagedFileId`).
|
|
458
|
+
*
|
|
459
|
+
* Files larger than {@link CHUNKED_THRESHOLD_BYTES} (95 MiB) are sent automatically with the
|
|
460
|
+
* chunked upload endpoints (up to 500 MB); force or disable that with `chunked`.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* await client.uploadVideo('./video.mp4', { user: 'my-profile', platforms: ['youtube'], title: 'Hi' });
|
|
464
|
+
*/
|
|
465
|
+
uploadVideo(options: UploadVideoOptions): Promise<UploadResponse>;
|
|
466
|
+
uploadVideo(source: VideoSource, options: Omit<UploadVideoOptions, 'videoPath' | 'video' | 'videoUrl' | 'stagedFileId'>): Promise<UploadResponse>;
|
|
467
|
+
private shouldChunk;
|
|
468
|
+
/**
|
|
469
|
+
* Start a chunked upload session (`POST /api/upload/chunked/init`). Send every part with
|
|
470
|
+
* {@link uploadPart}, then call {@link completeUploadSession}. Most callers want
|
|
471
|
+
* {@link uploadLargeFile} or `uploadVideo`, which do all of this.
|
|
472
|
+
*/
|
|
473
|
+
createUploadSession(options: CreateUploadSessionOptions): Promise<UploadSession>;
|
|
474
|
+
/**
|
|
475
|
+
* Send one part (`PUT /api/upload/chunked/:id/:index`). Every part must be exactly the
|
|
476
|
+
* session's `chunk_size` bytes except the last. Single attempt; re-sending an index replaces it.
|
|
477
|
+
*/
|
|
478
|
+
uploadPart(sessionId: string, index: number, bytes: Uint8Array): Promise<JsonObject>;
|
|
479
|
+
/** Assemble the parts (`POST /api/upload/chunked/:id/complete`); returns the `staged_file_id`. */
|
|
480
|
+
completeUploadSession(sessionId: string): Promise<CompleteUploadSessionResponse>;
|
|
481
|
+
/** Parts received so far (`GET /api/upload/chunked/:id`), to resume an interrupted upload. */
|
|
482
|
+
getUploadSession(sessionId: string): Promise<UploadSessionStatus>;
|
|
483
|
+
/** Cancel a chunked upload and delete its parts (`DELETE /api/upload/chunked/:id`). */
|
|
484
|
+
abortUploadSession(sessionId: string): Promise<JsonObject>;
|
|
485
|
+
/**
|
|
486
|
+
* Send a large video with the chunked upload endpoints: init → parts (sequential, retried on
|
|
487
|
+
* 429 / 5xx / network errors) → complete. Resolves with the `staged_file_id` to post with
|
|
488
|
+
* `uploadVideo({ stagedFileId })` (usable once, within 6 hours). The session is cancelled if a
|
|
489
|
+
* step fails for good.
|
|
490
|
+
*
|
|
491
|
+
* `source` is a file path, a Buffer / Uint8Array, or a readable stream. Files are read part by
|
|
492
|
+
* part; a stream with `size` is read part by part, and a stream without `size` is first written
|
|
493
|
+
* to a temporary file (deleted afterwards).
|
|
494
|
+
*/
|
|
495
|
+
uploadLargeFile(source: VideoSource, options?: ChunkedUploadOptions): Promise<CompleteUploadSessionResponse>;
|
|
496
|
+
/** Retry `fn` on network errors, timeouts, 429 and 5xx (honouring Retry-After), up to `attempts` tries. */
|
|
497
|
+
private withRetry;
|
|
498
|
+
/** Upload photos / a carousel (local files via `photoPaths` and/or public URLs via `photoUrls`; max 10). */
|
|
499
|
+
uploadPhotos(options: UploadPhotoOptions): Promise<UploadResponse>;
|
|
500
|
+
/** Publish a text-only post (`text` or `title`). */
|
|
501
|
+
uploadText(options: UploadTextOptions): Promise<UploadResponse>;
|
|
502
|
+
/** Publish a LinkedIn document post (PDF, PPT, PPTX, DOC, DOCX). */
|
|
503
|
+
uploadDocument(options: UploadDocumentOptions): Promise<UploadResponse>;
|
|
504
|
+
/** Current account: plan, monthly usage, API key id. */
|
|
505
|
+
getMe(): Promise<Me>;
|
|
506
|
+
/** Status of one upload (per-platform results, post ids, errors). */
|
|
507
|
+
getUploadStatus(uploadId: string): Promise<UploadStatusResponse>;
|
|
508
|
+
/** Look an upload up by your own `requestId` (or by upload id). */
|
|
509
|
+
getRequestStatus(requestId: string): Promise<UploadStatusResponse>;
|
|
510
|
+
/** Paginated upload history. */
|
|
511
|
+
listUploads(options?: ListUploadsOptions): Promise<ListUploadsResponse>;
|
|
512
|
+
/** A single upload record. */
|
|
513
|
+
getUpload(uploadId: string): Promise<UploadRecord>;
|
|
514
|
+
/** Delete an upload record (and its stored media). Not allowed while processing. */
|
|
515
|
+
deleteUpload(uploadId: string): Promise<JsonObject>;
|
|
516
|
+
/** Retry a failed upload. */
|
|
517
|
+
retryUpload(uploadId: string): Promise<JsonObject>;
|
|
518
|
+
/** Per-platform daily posting limits and current usage. */
|
|
519
|
+
getPlatformLimits(): Promise<JsonObject>;
|
|
520
|
+
/** List all profiles. */
|
|
521
|
+
getProfiles(): Promise<ProfilesResponse>;
|
|
522
|
+
/** Create a new profile. */
|
|
523
|
+
createProfile(name: string): Promise<{
|
|
524
|
+
profile: Profile;
|
|
525
|
+
} & JsonObject>;
|
|
526
|
+
/** Delete a profile. */
|
|
527
|
+
deleteProfile(name: string): Promise<{
|
|
528
|
+
message: string;
|
|
529
|
+
} & JsonObject>;
|
|
530
|
+
/**
|
|
531
|
+
* Connect a platform that uses credentials instead of OAuth (Discord, Telegram,
|
|
532
|
+
* Slack, Mastodon, WordPress, Dev.to, Hashnode, Lemmy, Nostr, Whop, Listmonk). The server verifies them live before saving;
|
|
533
|
+
* connecting again replaces the stored credentials.
|
|
534
|
+
*
|
|
535
|
+
* Errors: 400 with `code` MISSING_FIELD / FIELD_TOO_LONG / INVALID_CREDENTIALS
|
|
536
|
+
* (`err.body.details.field` names the field), 404 unknown profile, 502 platform unreachable.
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* await client.connectWithCredentials('my-brand', 'mastodon', {
|
|
540
|
+
* instance_url: 'https://mastodon.social', access_token: '...',
|
|
541
|
+
* });
|
|
542
|
+
*/
|
|
543
|
+
connectWithCredentials<P extends CredentialPlatform | (string & {})>(profile: string, platform: P, credentials: P extends CredentialPlatform ? PlatformCredentials[P] : Record<string, string>): Promise<ConnectCredentialsResponse>;
|
|
544
|
+
/** All scheduled (not yet published) posts. */
|
|
545
|
+
getScheduledPosts(): Promise<{
|
|
546
|
+
scheduled_posts: ScheduledPost[];
|
|
547
|
+
}>;
|
|
548
|
+
/** Reschedule or edit a scheduled post. */
|
|
549
|
+
updateScheduledPost(jobId: string, options: UpdateScheduledPostOptions): Promise<JsonObject>;
|
|
550
|
+
/** Cancel a scheduled post. */
|
|
551
|
+
cancelScheduledPost(jobId: string): Promise<JsonObject>;
|
|
552
|
+
/** Queue settings (time slots, days, timezone) for a profile. */
|
|
553
|
+
getQueueSettings(profile: string): Promise<JsonObject>;
|
|
554
|
+
/** Create or update a profile's queue settings. */
|
|
555
|
+
updateQueueSettings(options: UpdateQueueSettingsOptions): Promise<JsonObject>;
|
|
556
|
+
/** Upcoming queue slots for a profile. */
|
|
557
|
+
getQueuePreview(profile: string, count?: number): Promise<JsonObject>;
|
|
558
|
+
/** The next free queue slot for a profile. */
|
|
559
|
+
getNextQueueSlot(profile: string): Promise<JsonObject>;
|
|
560
|
+
/** Facebook pages available to the profile (use the id as `facebook_page_id`). */
|
|
561
|
+
getFacebookPages(profile: string): Promise<JsonObject>;
|
|
562
|
+
/** LinkedIn company pages (use the id as `target_linkedin_page_id`). */
|
|
563
|
+
getLinkedInPages(profile: string): Promise<JsonObject>;
|
|
564
|
+
/** Pinterest boards (use the id as `pinterest_board_id`). */
|
|
565
|
+
getPinterestBoards(profile: string): Promise<JsonObject>;
|
|
566
|
+
/** Google Business Profile locations (use the id as `gbp_location_id`). */
|
|
567
|
+
getGoogleBusinessLocations(profile: string): Promise<JsonObject>;
|
|
568
|
+
/** Account analytics overview (e.g. range "7d", "30d", "90d"). */
|
|
569
|
+
getAnalytics(range?: string): Promise<AnalyticsOverview>;
|
|
570
|
+
/** Live follower / engagement stats pulled from the platforms for a profile. */
|
|
571
|
+
getLiveAnalytics(profile: string, platforms?: string[]): Promise<JsonObject>;
|
|
572
|
+
/** Per-post analytics for an upload (optionally a single platform). */
|
|
573
|
+
getPostAnalytics(uploadId: string, platform?: string): Promise<JsonObject>;
|
|
574
|
+
/** Total impressions for a profile. */
|
|
575
|
+
getTotalImpressions(profile: string, options?: TotalImpressionsOptions): Promise<JsonObject>;
|
|
576
|
+
/** FFmpeg processing minutes used / remaining this month. */
|
|
577
|
+
getFfmpegUsage(): Promise<JsonObject>;
|
|
578
|
+
/** Recent FFmpeg jobs (latest 50). */
|
|
579
|
+
listFfmpegJobs(): Promise<{
|
|
580
|
+
jobs: JsonObject[];
|
|
581
|
+
}>;
|
|
582
|
+
/** A single FFmpeg job. */
|
|
583
|
+
getFfmpegJob(jobId: string): Promise<JsonObject>;
|
|
584
|
+
/** List available plans. */
|
|
585
|
+
getPlans(): Promise<{
|
|
586
|
+
plans: Plan[];
|
|
587
|
+
} & JsonObject>;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* @deprecated Use {@link PostUpload}. Alias kept from the `indreelforge` package
|
|
591
|
+
* (the same class, so `instanceof` keeps working).
|
|
592
|
+
*/
|
|
593
|
+
declare const IndReelForge: typeof PostUpload;
|
|
594
|
+
/** @deprecated Use {@link PostUpload}. */
|
|
595
|
+
type IndReelForge = PostUpload;
|
|
596
|
+
/**
|
|
597
|
+
* @deprecated Use {@link PostUpload}. Alias kept for 1.0.x code.
|
|
598
|
+
*/
|
|
599
|
+
declare const InReelForge: typeof PostUpload;
|
|
600
|
+
/** @deprecated Use {@link PostUpload}. */
|
|
601
|
+
type InReelForge = PostUpload;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Error thrown for any non-2xx response from the Post-Upload API, and for
|
|
605
|
+
* network failures / timeouts (status 0 / 408).
|
|
606
|
+
*/
|
|
607
|
+
declare class PostUploadError extends Error {
|
|
608
|
+
/** HTTP status code (0 for network errors, 408 for client-side timeouts). */
|
|
609
|
+
readonly status: number;
|
|
610
|
+
/** Machine-readable error code from the API (`error_code` / `code`), if any. */
|
|
611
|
+
readonly code: string | null;
|
|
612
|
+
/** Parsed response body (JSON object or raw text), if any. */
|
|
613
|
+
readonly body: unknown;
|
|
614
|
+
/** Seconds from the response's `Retry-After` header (e.g. on 429), if any. */
|
|
615
|
+
retryAfter: number | null;
|
|
616
|
+
constructor(message: string, status: number, code?: string | null, body?: unknown);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* @deprecated Use {@link PostUploadError}. Alias kept from the `indreelforge`
|
|
620
|
+
* package; `err instanceof IndReelForgeError` keeps working.
|
|
621
|
+
*/
|
|
622
|
+
declare const IndReelForgeError: typeof PostUploadError;
|
|
623
|
+
/** @deprecated Use {@link PostUploadError}. */
|
|
624
|
+
type IndReelForgeError = PostUploadError;
|
|
625
|
+
/**
|
|
626
|
+
* @deprecated Use {@link PostUploadError}. Alias kept for 1.0.x code;
|
|
627
|
+
* `err instanceof InReelForgeError` keeps working.
|
|
628
|
+
*/
|
|
629
|
+
declare const InReelForgeError: typeof PostUploadError;
|
|
630
|
+
/** @deprecated Use {@link PostUploadError}. */
|
|
631
|
+
type InReelForgeError = PostUploadError;
|
|
632
|
+
|
|
633
|
+
/** SDK version. Kept in sync with package.json (enforced by the test suite). */
|
|
634
|
+
declare const VERSION = "1.2.0";
|
|
635
|
+
|
|
636
|
+
declare const DEFAULT_MCP_URL = "https://api.post-upload.com/mcp";
|
|
637
|
+
interface McpBridgeOptions {
|
|
638
|
+
/** Post-Upload API key (sent as `Authorization: ApiKey <key>`). */
|
|
639
|
+
apiKey: string;
|
|
640
|
+
/** MCP endpoint. Default: https://api.post-upload.com/mcp */
|
|
641
|
+
url?: string;
|
|
642
|
+
/** Source of newline-delimited JSON-RPC (default: process.stdin). */
|
|
643
|
+
input?: NodeJS.ReadableStream;
|
|
644
|
+
/** Sink for JSON-RPC responses, one per line (default: process.stdout). */
|
|
645
|
+
output?: NodeJS.WritableStream;
|
|
646
|
+
/** Diagnostics sink (default: writes to stderr). */
|
|
647
|
+
log?: (message: string) => void;
|
|
648
|
+
/** Custom fetch implementation (default: global fetch). */
|
|
649
|
+
fetch?: typeof fetch;
|
|
650
|
+
/** Per-request timeout in ms (default 300000). */
|
|
651
|
+
timeoutMs?: number;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Run the bridge until `input` ends and every in-flight request has been
|
|
655
|
+
* answered. Requests are forwarded concurrently, except that messages arriving
|
|
656
|
+
* while an `initialize` is in flight wait for it (so they carry the session id).
|
|
657
|
+
*/
|
|
658
|
+
declare function runMcpBridge(options: McpBridgeOptions): Promise<void>;
|
|
659
|
+
|
|
660
|
+
export { type AnalyticsOverview, CHUNKED_THRESHOLD_BYTES, CREDENTIAL_PLATFORMS, type ChunkedUploadOptions, type CompleteUploadSessionResponse, type ConnectCredentialsResponse, type CreateUploadSessionOptions, type CredentialPlatform, DEFAULT_BASE_URL, DEFAULT_MCP_URL, InReelForge, type InReelForgeConfig, InReelForgeError, IndReelForge, type IndReelForgeConfig, IndReelForgeError, type JsonObject, type ListUploadsOptions, type ListUploadsResponse, MAX_VIDEO_BYTES, type McpBridgeOptions, type Me, PLATFORMS, type Plan, type Platform, type PlatformCredentials, type PlatformOptionValue, type PlatformOptions, PostUpload, type PostUploadConfig, PostUploadError, type Profile, type ProfilesResponse, type QueueSlot, type ScheduledPost, type SkippedPlatform, type TotalImpressionsOptions, type UpdateQueueSettingsOptions, type UpdateScheduledPostOptions, type UploadDocumentOptions, type UploadOptions, type UploadPhotoOptions, type UploadProgress, type UploadRecord, type UploadResponse, type UploadSession, type UploadSessionStatus, type UploadStatus, type UploadStatusResponse, type UploadTextOptions, type UploadVideoOptions, type UploadWarning, VERSION, type VideoSource, PostUpload as default, runMcpBridge };
|