@posterly/cli 0.1.5 → 0.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/bin/posterly.mjs +79 -9
- package/generated/platform-manifest.mjs +33 -26
- package/package.json +1 -1
package/bin/posterly.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { readFile, mkdir, writeFile, rm, chmod, rename } from 'node:fs/promises';
|
|
3
|
+
import { readFile, mkdir, writeFile, rm, chmod, rename, stat } from 'node:fs/promises';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import path from 'node:path';
|
|
@@ -58,7 +58,7 @@ const COMMANDS = [
|
|
|
58
58
|
'media:upload|signed-upload|upload-from-url',
|
|
59
59
|
'analytics:account|posts',
|
|
60
60
|
'gbp:reviews|review-link|audit|media|add-media|delete-media|suggest-reply|reply|delete-reply',
|
|
61
|
-
'ai:captions|image|video-options|video-function|generate-video|video-jobs|video-job',
|
|
61
|
+
'ai:captions|image|image-jobs|image-job|video-options|video-function|generate-video|video-jobs|video-job',
|
|
62
62
|
'activity:list',
|
|
63
63
|
'notifications:list',
|
|
64
64
|
'x:quota',
|
|
@@ -217,11 +217,7 @@ async function main() {
|
|
|
217
217
|
})), flags);
|
|
218
218
|
|
|
219
219
|
case 'media:signed-upload':
|
|
220
|
-
return print(await client.post('/media/signed-upload',
|
|
221
|
-
filename: required(flags.filename || positional[0], 'filename'),
|
|
222
|
-
content_type: required(flags.contentType, '--content-type'),
|
|
223
|
-
size: Number(required(flags.size, '--size')),
|
|
224
|
-
}), flags);
|
|
220
|
+
return print(await client.post('/media/signed-upload', await mediaSignedUploadPayload(flags, positional)), flags);
|
|
225
221
|
case 'media:upload-from-url':
|
|
226
222
|
return print(await client.post('/media/upload-from-url', {
|
|
227
223
|
url: required(flags.url || positional[0], 'url'),
|
|
@@ -330,8 +326,23 @@ async function main() {
|
|
|
330
326
|
|
|
331
327
|
case 'ai:captions':
|
|
332
328
|
return print(await client.post('/ai/generate-captions', await captionsPayloadFromFlags(flags)), flags);
|
|
333
|
-
case 'ai:image':
|
|
334
|
-
|
|
329
|
+
case 'ai:image': {
|
|
330
|
+
const queued = await client.post('/ai/generate-image', await imagePayloadFromFlags(flags, positional));
|
|
331
|
+
if (flagEnabled(flags.noWait)) {
|
|
332
|
+
return print(queued, flags);
|
|
333
|
+
}
|
|
334
|
+
if (!queued?.job_id) {
|
|
335
|
+
return print(queued, flags);
|
|
336
|
+
}
|
|
337
|
+
return print(await pollImageJob(client, queued.job_id), flags);
|
|
338
|
+
}
|
|
339
|
+
case 'ai:image-jobs':
|
|
340
|
+
return print(await client.get(withQuery('/ai/image-jobs', {
|
|
341
|
+
status: flags.status,
|
|
342
|
+
limit: flags.limit,
|
|
343
|
+
})), flags);
|
|
344
|
+
case 'ai:image-job':
|
|
345
|
+
return print(await client.get(`/ai/image-jobs/${required(positional[0] || flags.id, 'image job id')}`), flags);
|
|
335
346
|
|
|
336
347
|
case 'ai:video-options':
|
|
337
348
|
return print(await client.get('/ai/video-options'), flags);
|
|
@@ -885,6 +896,40 @@ async function mediaUploadPayload(flags, positional) {
|
|
|
885
896
|
};
|
|
886
897
|
}
|
|
887
898
|
|
|
899
|
+
// One file: `media:signed-upload launch.mp4 --content-type video/mp4 --size N`
|
|
900
|
+
// (unchanged). Several files, up to 20 in one call: pass local paths with no
|
|
901
|
+
// --content-type, `media:signed-upload a.jpg b.jpg c.mp4`, and the CLI reads
|
|
902
|
+
// each name, type and size from disk. `--files '[{"filename","content_type",
|
|
903
|
+
// "size"}]'` sends a batch you describe yourself.
|
|
904
|
+
async function mediaSignedUploadPayload(flags, positional) {
|
|
905
|
+
const workspace = flags.workspaceId ? { workspace_id: flags.workspaceId } : {};
|
|
906
|
+
if (flags.files !== undefined) {
|
|
907
|
+
const files = jsonFlag(flags.files);
|
|
908
|
+
if (!Array.isArray(files)) throw new Error('--files must be a JSON array of { filename, content_type, size }');
|
|
909
|
+
return { files, ...workspace };
|
|
910
|
+
}
|
|
911
|
+
if (flags.contentType === undefined && positional.length > 0) {
|
|
912
|
+
const files = [];
|
|
913
|
+
for (const filePath of positional) {
|
|
914
|
+
const info = await stat(filePath).catch(() => null);
|
|
915
|
+
if (!info || !info.isFile()) throw new Error(`Not a readable file: ${filePath}`);
|
|
916
|
+
files.push({
|
|
917
|
+
filename: path.basename(filePath),
|
|
918
|
+
content_type: guessContentType(filePath),
|
|
919
|
+
size: info.size,
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
if (files.length === 1) return { ...files[0], ...workspace };
|
|
923
|
+
return { files, ...workspace };
|
|
924
|
+
}
|
|
925
|
+
return {
|
|
926
|
+
filename: required(flags.filename || positional[0], 'filename'),
|
|
927
|
+
content_type: required(flags.contentType, '--content-type'),
|
|
928
|
+
size: Number(required(flags.size, '--size')),
|
|
929
|
+
...workspace,
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
|
|
888
933
|
async function captionsPayloadFromFlags(flags) {
|
|
889
934
|
if (flags.file) return readJson(required(flags.file, '--file'));
|
|
890
935
|
return clean({
|
|
@@ -912,12 +957,36 @@ async function imagePayloadFromFlags(flags, positional) {
|
|
|
912
957
|
prompt: required(flags.prompt || positional[0], '--prompt'),
|
|
913
958
|
aspect_ratio: flags.aspectRatio,
|
|
914
959
|
style: flags.style,
|
|
960
|
+
variations: flags.variations ? Number(flags.variations) : undefined,
|
|
961
|
+
provider: flags.provider,
|
|
962
|
+
model: flags.model,
|
|
963
|
+
resolution: flags.resolution,
|
|
964
|
+
quality: flags.quality,
|
|
965
|
+
thinking_level: flags.thinkingLevel,
|
|
966
|
+
reference_image_urls: csv(flags.referenceImageUrls || flags.referenceImages),
|
|
915
967
|
});
|
|
916
968
|
}
|
|
917
969
|
|
|
970
|
+
async function pollImageJob(client, jobId, options = {}) {
|
|
971
|
+
const timeoutMs = Number(options.timeoutMs || 8 * 60 * 1000);
|
|
972
|
+
const intervalMs = Number(options.intervalMs || 2000);
|
|
973
|
+
const started = Date.now();
|
|
974
|
+
while (Date.now() - started < timeoutMs) {
|
|
975
|
+
const data = await client.get(`/ai/image-jobs/${encodeURIComponent(jobId)}`);
|
|
976
|
+
const job = data.job || data;
|
|
977
|
+
if (job.status === 'completed') return job;
|
|
978
|
+
if (job.status === 'failed') {
|
|
979
|
+
throw new Error(job.error_message || 'Image job failed');
|
|
980
|
+
}
|
|
981
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
982
|
+
}
|
|
983
|
+
throw new Error(`Image job ${jobId} is still running. Poll with: posterly ai:image-job ${jobId}`);
|
|
984
|
+
}
|
|
985
|
+
|
|
918
986
|
async function videoPayloadFromFlags(flags) {
|
|
919
987
|
if (flags.file) return readJson(required(flags.file, '--file'));
|
|
920
988
|
return clean({
|
|
989
|
+
provider: flags.provider,
|
|
921
990
|
prompt: required(flags.prompt, '--prompt'),
|
|
922
991
|
negative_prompt: flags.negativePrompt,
|
|
923
992
|
aspect_ratio: flags.aspectRatio,
|
|
@@ -944,6 +1013,7 @@ async function videoFunctionPayloadFromFlags(flags, positional) {
|
|
|
944
1013
|
duration_seconds: flags.durationSeconds ? Number(flags.durationSeconds) : undefined,
|
|
945
1014
|
resolution: flags.resolution,
|
|
946
1015
|
output: flags.output,
|
|
1016
|
+
input_image_count: flags.inputImageCount ? Number(flags.inputImageCount) : undefined,
|
|
947
1017
|
prompt: flags.prompt,
|
|
948
1018
|
negative_prompt: flags.negativePrompt,
|
|
949
1019
|
aspect_ratio: flags.aspectRatio,
|
|
@@ -14,6 +14,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
14
14
|
"telegram",
|
|
15
15
|
"bluesky",
|
|
16
16
|
"discord",
|
|
17
|
+
"slack",
|
|
17
18
|
"mastodon",
|
|
18
19
|
"devto",
|
|
19
20
|
"hashnode",
|
|
@@ -23,7 +24,6 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
23
24
|
"plannedPlatformIds": [
|
|
24
25
|
"reddit",
|
|
25
26
|
"medium",
|
|
26
|
-
"slack",
|
|
27
27
|
"skool",
|
|
28
28
|
"whop"
|
|
29
29
|
],
|
|
@@ -40,6 +40,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
40
40
|
"telegram",
|
|
41
41
|
"bluesky",
|
|
42
42
|
"discord",
|
|
43
|
+
"slack",
|
|
43
44
|
"mastodon",
|
|
44
45
|
"devto",
|
|
45
46
|
"hashnode",
|
|
@@ -47,7 +48,6 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
47
48
|
"lemmy",
|
|
48
49
|
"reddit",
|
|
49
50
|
"medium",
|
|
50
|
-
"slack",
|
|
51
51
|
"skool",
|
|
52
52
|
"whop"
|
|
53
53
|
],
|
|
@@ -67,6 +67,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
67
67
|
"linkedin",
|
|
68
68
|
"mastodon",
|
|
69
69
|
"pinterest",
|
|
70
|
+
"slack",
|
|
70
71
|
"telegram",
|
|
71
72
|
"threads",
|
|
72
73
|
"tiktok",
|
|
@@ -141,6 +142,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
141
142
|
"analyticsPlatformIds": [
|
|
142
143
|
"instagram",
|
|
143
144
|
"facebook",
|
|
145
|
+
"twitter",
|
|
144
146
|
"linkedin",
|
|
145
147
|
"youtube",
|
|
146
148
|
"pinterest",
|
|
@@ -162,6 +164,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
162
164
|
"telegram",
|
|
163
165
|
"bluesky",
|
|
164
166
|
"discord",
|
|
167
|
+
"slack",
|
|
165
168
|
"mastodon",
|
|
166
169
|
"devto",
|
|
167
170
|
"hashnode",
|
|
@@ -169,7 +172,6 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
169
172
|
"lemmy",
|
|
170
173
|
"reddit",
|
|
171
174
|
"medium",
|
|
172
|
-
"slack",
|
|
173
175
|
"skool",
|
|
174
176
|
"whop"
|
|
175
177
|
],
|
|
@@ -314,7 +316,7 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
314
316
|
"carousel",
|
|
315
317
|
"x_thread"
|
|
316
318
|
],
|
|
317
|
-
"analyticsSupported":
|
|
319
|
+
"analyticsSupported": true,
|
|
318
320
|
"helpers": [
|
|
319
321
|
"x.quota"
|
|
320
322
|
]
|
|
@@ -435,6 +437,20 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
435
437
|
"analyticsSupported": false,
|
|
436
438
|
"helpers": []
|
|
437
439
|
},
|
|
440
|
+
{
|
|
441
|
+
"id": "slack",
|
|
442
|
+
"label": "Slack",
|
|
443
|
+
"status": "supported",
|
|
444
|
+
"aliases": [],
|
|
445
|
+
"postTypes": [
|
|
446
|
+
"text",
|
|
447
|
+
"image",
|
|
448
|
+
"video",
|
|
449
|
+
"carousel"
|
|
450
|
+
],
|
|
451
|
+
"analyticsSupported": false,
|
|
452
|
+
"helpers": []
|
|
453
|
+
},
|
|
438
454
|
{
|
|
439
455
|
"id": "mastodon",
|
|
440
456
|
"label": "Mastodon",
|
|
@@ -515,15 +531,6 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
515
531
|
"analyticsSupported": false,
|
|
516
532
|
"helpers": []
|
|
517
533
|
},
|
|
518
|
-
{
|
|
519
|
-
"id": "slack",
|
|
520
|
-
"label": "Slack",
|
|
521
|
-
"status": "planned",
|
|
522
|
-
"aliases": [],
|
|
523
|
-
"postTypes": [],
|
|
524
|
-
"analyticsSupported": false,
|
|
525
|
-
"helpers": []
|
|
526
|
-
},
|
|
527
534
|
{
|
|
528
535
|
"id": "skool",
|
|
529
536
|
"label": "Skool",
|
|
@@ -663,6 +670,13 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
663
670
|
"aliases": [],
|
|
664
671
|
"method": "manual_credentials"
|
|
665
672
|
},
|
|
673
|
+
{
|
|
674
|
+
"id": "slack",
|
|
675
|
+
"label": "Slack",
|
|
676
|
+
"status": "supported",
|
|
677
|
+
"aliases": [],
|
|
678
|
+
"method": "dashboard_oauth"
|
|
679
|
+
},
|
|
666
680
|
{
|
|
667
681
|
"id": "mastodon",
|
|
668
682
|
"label": "Mastodon",
|
|
@@ -712,13 +726,6 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
712
726
|
"aliases": [],
|
|
713
727
|
"method": "planned"
|
|
714
728
|
},
|
|
715
|
-
{
|
|
716
|
-
"id": "slack",
|
|
717
|
-
"label": "Slack",
|
|
718
|
-
"status": "planned",
|
|
719
|
-
"aliases": [],
|
|
720
|
-
"method": "planned"
|
|
721
|
-
},
|
|
722
729
|
{
|
|
723
730
|
"id": "skool",
|
|
724
731
|
"label": "Skool",
|
|
@@ -735,12 +742,12 @@ export const PLATFORM_MANIFEST = Object.freeze({
|
|
|
735
742
|
}
|
|
736
743
|
]
|
|
737
744
|
});
|
|
738
|
-
export const SUPPORTED_PLATFORM_IDS = Object.freeze(["instagram","facebook","tiktok","twitter","linkedin","youtube","pinterest","threads","google_business","telegram","bluesky","discord","mastodon","devto","hashnode","wordpress","lemmy"]);
|
|
739
|
-
export const PLANNED_PLATFORM_IDS = Object.freeze(["reddit","medium","
|
|
740
|
-
export const ALL_PLATFORM_IDS = Object.freeze(["instagram","facebook","tiktok","twitter","linkedin","youtube","pinterest","threads","google_business","telegram","bluesky","discord","mastodon","devto","hashnode","wordpress","lemmy","reddit","medium","
|
|
741
|
-
export const SUPPORTED_PLATFORM_INPUTS = Object.freeze(["bluesky","devto","discord","facebook","gmb","google-business","google_business","google_business_profile","hashnode","instagram","instagram-standalone","lemmy","linkedin","mastodon","pinterest","telegram","threads","tiktok","twitter","wordpress","x","youtube"]);
|
|
745
|
+
export const SUPPORTED_PLATFORM_IDS = Object.freeze(["instagram","facebook","tiktok","twitter","linkedin","youtube","pinterest","threads","google_business","telegram","bluesky","discord","slack","mastodon","devto","hashnode","wordpress","lemmy"]);
|
|
746
|
+
export const PLANNED_PLATFORM_IDS = Object.freeze(["reddit","medium","skool","whop"]);
|
|
747
|
+
export const ALL_PLATFORM_IDS = Object.freeze(["instagram","facebook","tiktok","twitter","linkedin","youtube","pinterest","threads","google_business","telegram","bluesky","discord","slack","mastodon","devto","hashnode","wordpress","lemmy","reddit","medium","skool","whop"]);
|
|
748
|
+
export const SUPPORTED_PLATFORM_INPUTS = Object.freeze(["bluesky","devto","discord","facebook","gmb","google-business","google_business","google_business_profile","hashnode","instagram","instagram-standalone","lemmy","linkedin","mastodon","pinterest","slack","telegram","threads","tiktok","twitter","wordpress","x","youtube"]);
|
|
742
749
|
export const ALL_PLATFORM_INPUTS = Object.freeze(["bluesky","devto","discord","facebook","gmb","google-business","google_business","google_business_profile","hashnode","instagram","instagram-standalone","lemmy","linkedin","mastodon","medium","pinterest","reddit","skool","slack","telegram","threads","tiktok","twitter","whop","wordpress","x","youtube"]);
|
|
743
750
|
export const PLATFORM_HELPER_NAMES = Object.freeze(["linkedin.recent_mentions","pinterest.boards","tiktok.creator_info","x.quota"]);
|
|
744
|
-
export const CONNECT_TARGET_IDS = Object.freeze(["instagram","meta","facebook","youtube","tiktok","linkedin","linkedin_page","threads","google_business","pinterest","twitter","telegram","bluesky","discord","mastodon","devto","hashnode","wordpress","lemmy","reddit","medium","
|
|
751
|
+
export const CONNECT_TARGET_IDS = Object.freeze(["instagram","meta","facebook","youtube","tiktok","linkedin","linkedin_page","threads","google_business","pinterest","twitter","telegram","bluesky","discord","slack","mastodon","devto","hashnode","wordpress","lemmy","reddit","medium","skool","whop"]);
|
|
745
752
|
export const CONNECT_INPUTS = Object.freeze(["bluesky","devto","discord","facebook","facebook_instagram","facebook_pages","gmb","google-business","google_business","google_business_profile","hashnode","instagram","instagram-standalone","instagram_direct","lemmy","linkedin","linkedin-company","linkedin-page","linkedin_company","linkedin_page","linkedin_personal","mastodon","medium","meta","meta_business","pinterest","reddit","skool","slack","telegram","threads","tiktok","twitter","whop","wordpress","x","x_twitter","youtube"]);
|
|
746
|
-
export const ANALYTICS_PLATFORM_IDS = Object.freeze(["instagram","facebook","linkedin","youtube","pinterest","threads","google_business"]);
|
|
753
|
+
export const ANALYTICS_PLATFORM_IDS = Object.freeze(["instagram","facebook","twitter","linkedin","youtube","pinterest","threads","google_business"]);
|