blitzreels 0.1.31 → 0.1.33

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.
Files changed (41) hide show
  1. package/README.md +16 -4
  2. package/dist/agent-context.js +9 -0
  3. package/dist/agent-context.js.map +1 -1
  4. package/dist/command-registry.d.ts.map +1 -1
  5. package/dist/command-registry.js +2 -0
  6. package/dist/command-registry.js.map +1 -1
  7. package/dist/commands/analytics.d.ts +10 -0
  8. package/dist/commands/analytics.d.ts.map +1 -0
  9. package/dist/commands/analytics.js +214 -0
  10. package/dist/commands/analytics.js.map +1 -0
  11. package/dist/commands/auth.d.ts.map +1 -1
  12. package/dist/commands/auth.js +5 -0
  13. package/dist/commands/auth.js.map +1 -1
  14. package/dist/commands/faceless.d.ts +3 -0
  15. package/dist/commands/faceless.d.ts.map +1 -1
  16. package/dist/commands/faceless.js +522 -7
  17. package/dist/commands/faceless.js.map +1 -1
  18. package/dist/commands/generation-review.d.ts +1 -1
  19. package/dist/commands/generation-review.d.ts.map +1 -1
  20. package/dist/commands/generation-review.js +5 -0
  21. package/dist/commands/generation-review.js.map +1 -1
  22. package/dist/commands/generation.d.ts.map +1 -1
  23. package/dist/commands/generation.js +13 -3
  24. package/dist/commands/generation.js.map +1 -1
  25. package/dist/commands/publishing-access-preflight.d.ts +16 -0
  26. package/dist/commands/publishing-access-preflight.d.ts.map +1 -0
  27. package/dist/commands/publishing-access-preflight.js +31 -0
  28. package/dist/commands/publishing-access-preflight.js.map +1 -0
  29. package/dist/commands/publishing-posts.d.ts.map +1 -1
  30. package/dist/commands/publishing-posts.js +62 -13
  31. package/dist/commands/publishing-posts.js.map +1 -1
  32. package/dist/commands/publishing-schedule-time.d.ts +11 -0
  33. package/dist/commands/publishing-schedule-time.d.ts.map +1 -0
  34. package/dist/commands/publishing-schedule-time.js +81 -0
  35. package/dist/commands/publishing-schedule-time.js.map +1 -0
  36. package/dist/commands/publishing.d.ts.map +1 -1
  37. package/dist/commands/publishing.js +289 -263
  38. package/dist/commands/publishing.js.map +1 -1
  39. package/dist/index.js +12 -0
  40. package/dist/index.js.map +1 -1
  41. package/package.json +2 -2
@@ -3,14 +3,16 @@ import { resolve } from "node:path";
3
3
  import { CliUsageError } from "../cli-errors.js";
4
4
  import { assertSafeTextFlag } from "../cli-safe-input.js";
5
5
  import { commandSpec } from "../command-metadata.js";
6
+ import { assertPublishingAccessBeforeUpload, withPublishingAccessNote, } from "./publishing-access-preflight.js";
6
7
  import { resolvePublishingWaitOptions, waitForPublishingVideo, } from "./publishing-media.js";
7
8
  import { createPublishingPostsOperation, PUBLISHING_POST_COMMAND_SPECS, printPost, } from "./publishing-posts.js";
9
+ import { resolveScheduledFor } from "./publishing-schedule-time.js";
8
10
  export const PUBLISHING_COMMAND_SPECS = [
9
11
  ...PUBLISHING_POST_COMMAND_SPECS,
10
12
  ...["x", "linkedin", "threads"].map((platform) => commandSpec({
11
13
  command: ["publishing", platform, "schedule"],
12
14
  discovery: "detail",
13
- usage: `blitzreels publishing ${platform} schedule --connection-id ID --caption TEXT --scheduled-for ISO --idempotency-key KEY [--project-id ID --export-id ID] [--timezone TZ] [--dry-run] [--json]`,
15
+ usage: `blitzreels publishing ${platform} schedule --connection-id ID --caption TEXT (--scheduled-for TIME | --in 10m) --idempotency-key KEY [--project-id ID --export-id ID] [--timezone TZ] [--dry-run] [--json]`,
14
16
  description: platform === "x"
15
17
  ? "Schedule an X text post using verified free API access."
16
18
  : `Schedule a ${platform} text post or completed media export.`,
@@ -20,7 +22,8 @@ export const PUBLISHING_COMMAND_SPECS = [
20
22
  "caption-file",
21
23
  "project-id",
22
24
  "export-id",
23
- { name: "scheduled-for", required: true },
25
+ "scheduled-for",
26
+ "in",
24
27
  "timezone",
25
28
  { name: "idempotency-key", required: true },
26
29
  ],
@@ -43,8 +46,10 @@ export const PUBLISHING_COMMAND_SPECS = [
43
46
  command: ["publishing", "video", "schedule"],
44
47
  discovery: "detail",
45
48
  usage: "blitzreels publishing video schedule (--video PATH | --media-asset-id ID) " +
46
- "--targets PLATFORM[:CONNECTION_ID][,...] --scheduled-for ISO [--caption TEXT|--caption-file PATH] " +
49
+ "--targets PLATFORM[:CONNECTION_ID][,...] (--scheduled-for TIME | --in 10m) [--caption TEXT|--caption-file PATH] " +
47
50
  "[--title TEXT] [--timezone TZ] [--contains-synthetic-media] " +
51
+ "[--youtube-privacy-status public|unlisted|private (default public)] [--youtube-made-for-kids (default false)] " +
52
+ "[--instagram-trial-reel] [--instagram-share-to-feed] " +
48
53
  "[--tiktok-publish-mode direct_post|draft] " +
49
54
  "[--tiktok-privacy-level PUBLIC_TO_EVERYONE|FOLLOWER_OF_CREATOR|MUTUAL_FOLLOW_FRIENDS|SELF_ONLY] " +
50
55
  "[--tiktok-consent-accepted] [--interval-ms 3000] [--timeout-ms 600000] [--dry-run] [--json]",
@@ -59,7 +64,8 @@ export const PUBLISHING_COMMAND_SPECS = [
59
64
  "caption-file",
60
65
  "title",
61
66
  { name: "contains-synthetic-media", type: "boolean" },
62
- { name: "scheduled-for", required: true },
67
+ "scheduled-for",
68
+ "in",
63
69
  "timezone",
64
70
  {
65
71
  name: "youtube-privacy-status",
@@ -104,7 +110,7 @@ export const PUBLISHING_COMMAND_SPECS = [
104
110
  command: ["publishing", "tiktok", "schedule"],
105
111
  discovery: "detail",
106
112
  usage: "blitzreels publishing tiktok schedule [--project-id ID] [--export-id ID] [--images PATHS] " +
107
- "[--project-name NAME] [--connection-id ID] [--caption TEXT|--caption-file PATH] --scheduled-for ISO " +
113
+ "[--project-name NAME] [--connection-id ID] [--caption TEXT|--caption-file PATH] (--scheduled-for TIME | --in 10m) " +
108
114
  "[--timezone TZ] [--publish-mode direct_post|draft] [--privacy-level SELF_ONLY] " +
109
115
  "[--photo-cover-index 0] [--auto-add-music] [--consent-accepted] [--dry-run] [--json]",
110
116
  description: "Schedule a TikTok video or slideshow from a BlitzReels export, or upload ordered local JPEG/WebP images first.",
@@ -117,7 +123,8 @@ export const PUBLISHING_COMMAND_SPECS = [
117
123
  "connection-id",
118
124
  "caption",
119
125
  "caption-file",
120
- { name: "scheduled-for", required: true },
126
+ "scheduled-for",
127
+ "in",
121
128
  "timezone",
122
129
  { name: "publish-mode", enum: ["direct_post", "draft"] },
123
130
  {
@@ -150,7 +157,7 @@ export const PUBLISHING_COMMAND_SPECS = [
150
157
  discovery: "detail",
151
158
  usage: "blitzreels publishing instagram schedule --project-id ID " +
152
159
  "[--export-id ID] [--connection-id ID] [--caption TEXT|--caption-file PATH] " +
153
- "--scheduled-for ISO [--timezone TZ] [--trial-reel] " +
160
+ "(--scheduled-for TIME | --in 10m) [--timezone TZ] [--trial-reel] " +
154
161
  "[--trial-graduation-strategy MANUAL|SS_PERFORMANCE] [--share-to-feed] " +
155
162
  "[--include-affiliate-cta] [--affiliate-tracking-url URL] " +
156
163
  "[--affiliate-cta-text TEXT] [--dry-run] [--json]",
@@ -162,7 +169,8 @@ export const PUBLISHING_COMMAND_SPECS = [
162
169
  "connection-id",
163
170
  "caption",
164
171
  "caption-file",
165
- { name: "scheduled-for", required: true },
172
+ "scheduled-for",
173
+ "in",
166
174
  "timezone",
167
175
  { name: "trial-reel", type: "boolean" },
168
176
  {
@@ -426,7 +434,7 @@ function networkOptions({ flags, helpers, platform, }) {
426
434
  exportId,
427
435
  caption,
428
436
  connectionId: helpers.requireStringFlag({ flags, name: "connection-id" }),
429
- scheduledFor: helpers.requireStringFlag({ flags, name: "scheduled-for" }),
437
+ scheduledFor: readScheduledFor({ flags: flags, helpers }),
430
438
  timezone: helpers.getStringFlag({ flags, name: "timezone" }) ?? "UTC",
431
439
  idempotencyKey: helpers.requireStringFlag({
432
440
  flags,
@@ -434,8 +442,250 @@ function networkOptions({ flags, helpers, platform, }) {
434
442
  }),
435
443
  };
436
444
  }
445
+ function readScheduledFor({ flags, helpers, }) {
446
+ return resolveScheduledFor({
447
+ scheduledFor: helpers.getStringFlag({ flags, name: "scheduled-for" }),
448
+ scheduleIn: helpers.getStringFlag({ flags, name: "in" }),
449
+ timezone: helpers.getStringFlag({ flags, name: "timezone" }),
450
+ now: new Date(),
451
+ });
452
+ }
437
453
  export function createPublishingCommandOperation({ helpers, }) {
438
454
  const posts = createPublishingPostsOperation(helpers);
455
+ const buildLocalDryRun = ({ context, spec, }) => {
456
+ if (posts.matches({ command: context.args.command }))
457
+ return posts.buildDryRun({ context, spec });
458
+ const [, resource, action] = context.args.command;
459
+ if (["x", "linkedin", "threads"].includes(resource ?? "") &&
460
+ action === "schedule") {
461
+ const input = networkOptions({
462
+ flags: context.args.flags,
463
+ helpers,
464
+ platform: resource,
465
+ });
466
+ return helpers.dryRunRequest({
467
+ spec,
468
+ method: "POST",
469
+ path: "/publishing/network/schedule",
470
+ body: {
471
+ platform: input.platform,
472
+ connection_id: input.connectionId,
473
+ project_id: input.projectId,
474
+ export_id: input.exportId,
475
+ caption: input.caption,
476
+ scheduled_for: input.scheduledFor,
477
+ timezone: input.timezone,
478
+ },
479
+ followUpRequests: undefined,
480
+ notes: [
481
+ "The live request sends the supplied Idempotency-Key.",
482
+ "Read the receipt with publishing posts get --post-id ID.",
483
+ ],
484
+ });
485
+ }
486
+ if (context.args.command[1] === "video" &&
487
+ context.args.command[2] === "schedule") {
488
+ const flags = context.args.flags;
489
+ const { videoPath, mediaAssetId } = resolveUploadedVideoSourceFlags({
490
+ flags,
491
+ helpers,
492
+ });
493
+ const targets = buildUploadedVideoTargets({ flags, helpers });
494
+ const waitOptions = resolvePublishingWaitOptions({
495
+ intervalMs: helpers.getNumberFlag({ flags, name: "interval-ms" }),
496
+ timeoutMs: helpers.getNumberFlag({ flags, name: "timeout-ms" }),
497
+ });
498
+ return helpers.dryRunRequest({
499
+ spec,
500
+ method: "POST",
501
+ path: "/publishing/video/schedule",
502
+ body: {
503
+ media_asset_id: videoPath ? `<uploaded:${videoPath}>` : mediaAssetId,
504
+ project_name: helpers.getStringFlag({
505
+ flags,
506
+ name: "project-name",
507
+ }),
508
+ caption: readCaption({ flags, helpers }),
509
+ contains_synthetic_media: helpers.getBooleanFlag({
510
+ flags,
511
+ name: "contains-synthetic-media",
512
+ }),
513
+ scheduled_for: readScheduledFor({ flags: flags, helpers }),
514
+ timezone: helpers.getStringFlag({ flags, name: "timezone" }),
515
+ include_affiliate_cta: helpers.getBooleanFlag({
516
+ flags,
517
+ name: "include-affiliate-cta",
518
+ }),
519
+ affiliate_tracking_url: helpers.getStringFlag({
520
+ flags,
521
+ name: "affiliate-tracking-url",
522
+ }),
523
+ affiliate_cta_text: helpers.getStringFlag({
524
+ flags,
525
+ name: "affiliate-cta-text",
526
+ }),
527
+ targets: targets.map((target) => mapUploadedVideoTargetRequest({ target })),
528
+ },
529
+ followUpRequests: undefined,
530
+ notes: videoPath
531
+ ? [
532
+ `The live command uploads the local video and waits up to ${waitOptions.timeoutMs} ms for duration and dimensions before scheduling.`,
533
+ "Dry-run does not read or upload the local file.",
534
+ ]
535
+ : [
536
+ `The live command waits up to ${waitOptions.timeoutMs} ms for the selected video's duration and dimensions before scheduling.`,
537
+ ],
538
+ });
539
+ }
540
+ if (context.args.command[1] === "tiktok" &&
541
+ context.args.command[2] === "schedule") {
542
+ const flags = context.args.flags;
543
+ const { projectId, imagePaths } = resolveTikTokSourceFlags({
544
+ flags,
545
+ helpers,
546
+ });
547
+ return helpers.dryRunRequest({
548
+ spec,
549
+ method: "POST",
550
+ path: "/publishing/tiktok/schedule",
551
+ body: {
552
+ project_id: projectId,
553
+ export_id: helpers.getStringFlag({ flags, name: "export-id" }),
554
+ media_asset_ids: imagePaths.length > 0
555
+ ? imagePaths.map((path) => `<uploaded:${path}>`)
556
+ : undefined,
557
+ project_name: helpers.getStringFlag({
558
+ flags,
559
+ name: "project-name",
560
+ }),
561
+ connection_id: helpers.getStringFlag({
562
+ flags,
563
+ name: "connection-id",
564
+ }),
565
+ caption: readCaption({ flags, helpers }),
566
+ scheduled_for: readScheduledFor({ flags: flags, helpers }),
567
+ timezone: helpers.getStringFlag({ flags, name: "timezone" }),
568
+ publish_mode: helpers.getStringFlag({
569
+ flags,
570
+ name: "publish-mode",
571
+ }),
572
+ privacy_level: readTikTokPrivacyLevel({ flags, helpers }),
573
+ allow_comment: helpers.getBooleanFlag({
574
+ flags,
575
+ name: "allow-comment",
576
+ }),
577
+ allow_duet: helpers.getBooleanFlag({
578
+ flags,
579
+ name: "allow-duet",
580
+ }),
581
+ allow_stitch: helpers.getBooleanFlag({
582
+ flags,
583
+ name: "allow-stitch",
584
+ }),
585
+ cover_timestamp_ms: helpers.getNumberFlag({
586
+ flags,
587
+ name: "cover-timestamp-ms",
588
+ }),
589
+ photo_cover_index: helpers.getNumberFlag({
590
+ flags,
591
+ name: "photo-cover-index",
592
+ }),
593
+ auto_add_music: helpers.getBooleanFlag({
594
+ flags,
595
+ name: "auto-add-music",
596
+ }),
597
+ commercial_content_enabled: helpers.getBooleanFlag({
598
+ flags,
599
+ name: "commercial-content",
600
+ }),
601
+ brand_organic: helpers.getBooleanFlag({
602
+ flags,
603
+ name: "brand-organic",
604
+ }),
605
+ branded_content: helpers.getBooleanFlag({
606
+ flags,
607
+ name: "branded-content",
608
+ }),
609
+ is_ai_generated: helpers.getBooleanFlag({
610
+ flags,
611
+ name: "ai-generated",
612
+ }),
613
+ consent_accepted: helpers.getBooleanFlag({
614
+ flags,
615
+ name: "consent-accepted",
616
+ }),
617
+ },
618
+ followUpRequests: undefined,
619
+ notes: imagePaths.length > 0
620
+ ? [
621
+ `The live command uploads ${imagePaths.length} local image${imagePaths.length === 1 ? "" : "s"} in this order before scheduling.`,
622
+ "Dry-run does not read or upload local files.",
623
+ ]
624
+ : ["The existing completed project export is scheduled."],
625
+ });
626
+ }
627
+ if (context.args.command[1] !== "instagram" ||
628
+ context.args.command[2] !== "schedule") {
629
+ return undefined;
630
+ }
631
+ const projectId = helpers.requireStringFlag({
632
+ flags: context.args.flags,
633
+ name: "project-id",
634
+ });
635
+ return helpers.dryRunRequest({
636
+ spec,
637
+ method: "POST",
638
+ path: `/projects/${encodeURIComponent(projectId)}/publishing/instagram`,
639
+ body: {
640
+ export_id: helpers.getStringFlag({
641
+ flags: context.args.flags,
642
+ name: "export-id",
643
+ }),
644
+ connection_id: helpers.getStringFlag({
645
+ flags: context.args.flags,
646
+ name: "connection-id",
647
+ }),
648
+ caption: readCaption({
649
+ flags: context.args.flags,
650
+ helpers,
651
+ }),
652
+ scheduled_for: readScheduledFor({ flags: context.args.flags, helpers }),
653
+ timezone: helpers.getStringFlag({
654
+ flags: context.args.flags,
655
+ name: "timezone",
656
+ }),
657
+ trial_reel: helpers.getBooleanFlag({
658
+ flags: context.args.flags,
659
+ name: "trial-reel",
660
+ }),
661
+ trial_graduation_strategy: helpers.getStringFlag({
662
+ flags: context.args.flags,
663
+ name: "trial-graduation-strategy",
664
+ }),
665
+ share_to_feed: helpers.getBooleanFlag({
666
+ flags: context.args.flags,
667
+ name: "share-to-feed",
668
+ }),
669
+ include_affiliate_cta: helpers.getBooleanFlag({
670
+ flags: context.args.flags,
671
+ name: "include-affiliate-cta",
672
+ }),
673
+ affiliate_tracking_url: helpers.getStringFlag({
674
+ flags: context.args.flags,
675
+ name: "affiliate-tracking-url",
676
+ }),
677
+ affiliate_cta_text: helpers.getStringFlag({
678
+ flags: context.args.flags,
679
+ name: "affiliate-cta-text",
680
+ }),
681
+ },
682
+ followUpRequests: undefined,
683
+ notes: [
684
+ "Requires an active Instagram account connected in the BlitzReels UI.",
685
+ "include_affiliate_cta appends Try BlitzReels for free + Affonso tracking URL.",
686
+ ],
687
+ });
688
+ };
439
689
  return {
440
690
  name: "publishing",
441
691
  matches: ({ command }) => command[0] === "publishing",
@@ -479,9 +729,12 @@ export function createPublishingCommandOperation({ helpers, }) {
479
729
  value: result,
480
730
  human: [
481
731
  `Connections: ${result.count}`,
732
+ result.account_limit
733
+ ? `Posting: ${result.account_limit.posting}${result.account_limit.limit === null ? "" : ` of ${result.account_limit.limit}`} accounts · max ${result.account_limit.max_targets_per_post} per post`
734
+ : "",
482
735
  ...result.connections.map((connection) => {
483
736
  const connectionId = connection.id ?? connection.connection_id;
484
- return `${connectionId} ${connection.platform} ${connection.username ?? connection.display_name ?? connection.external_account_id} ${connection.status}`;
737
+ return `${connectionId} ${connection.platform} ${connection.username ?? connection.display_name ?? connection.external_account_id} ${connection.publishing_blocked_reason ? "not posting (account limit)" : connection.status}`;
485
738
  }),
486
739
  ],
487
740
  fields: undefined,
@@ -499,6 +752,12 @@ export function createPublishingCommandOperation({ helpers, }) {
499
752
  intervalMs: helpers.getNumberFlag({ flags, name: "interval-ms" }),
500
753
  timeoutMs: helpers.getNumberFlag({ flags, name: "timeout-ms" }),
501
754
  });
755
+ const scheduledFor = readScheduledFor({ flags, helpers });
756
+ if (videoPath)
757
+ await assertPublishingAccessBeforeUpload({
758
+ context,
759
+ needs: "schedule",
760
+ });
502
761
  const resolvedMediaAssetId = videoPath
503
762
  ? (await helpers.uploadLocalMediaFile({
504
763
  context,
@@ -538,10 +797,7 @@ export function createPublishingCommandOperation({ helpers, }) {
538
797
  flags,
539
798
  name: "contains-synthetic-media",
540
799
  }),
541
- scheduledFor: helpers.requireStringFlag({
542
- flags,
543
- name: "scheduled-for",
544
- }),
800
+ scheduledFor,
545
801
  timezone: helpers.getStringFlag({ flags, name: "timezone" }),
546
802
  includeAffiliateCta: helpers.getBooleanFlag({
547
803
  flags,
@@ -590,6 +846,12 @@ export function createPublishingCommandOperation({ helpers, }) {
590
846
  throw new Error("TikTok direct posting requires an explicit --privacy-level.");
591
847
  }
592
848
  const mediaAssetIds = [];
849
+ const scheduledFor = readScheduledFor({ flags, helpers });
850
+ if (imagePaths.length > 0)
851
+ await assertPublishingAccessBeforeUpload({
852
+ context,
853
+ needs: "schedule",
854
+ });
593
855
  for (const filePath of imagePaths) {
594
856
  const uploaded = await helpers.uploadLocalMediaFile({
595
857
  context,
@@ -614,10 +876,7 @@ export function createPublishingCommandOperation({ helpers, }) {
614
876
  name: "connection-id",
615
877
  }),
616
878
  caption: readCaption({ flags, helpers }),
617
- scheduledFor: helpers.requireStringFlag({
618
- flags,
619
- name: "scheduled-for",
620
- }),
879
+ scheduledFor,
621
880
  timezone: helpers.getStringFlag({ flags, name: "timezone" }),
622
881
  publishMode,
623
882
  privacyLevel,
@@ -695,9 +954,9 @@ export function createPublishingCommandOperation({ helpers, }) {
695
954
  flags: context.args.flags,
696
955
  name: "project-id",
697
956
  });
698
- const scheduledFor = helpers.requireStringFlag({
957
+ const scheduledFor = readScheduledFor({
699
958
  flags: context.args.flags,
700
- name: "scheduled-for",
959
+ helpers,
701
960
  });
702
961
  const result = await context.client.publishing.scheduleInstagram({
703
962
  idempotencyKey: helpers.getStringFlag({
@@ -760,250 +1019,17 @@ export function createPublishingCommandOperation({ helpers, }) {
760
1019
  }
761
1020
  return false;
762
1021
  },
763
- buildDryRun: ({ context, spec }) => {
764
- if (posts.matches({ command: context.args.command }))
765
- return posts.buildDryRun({ context, spec });
1022
+ buildDryRun: async ({ context, spec }) => {
1023
+ const preview = await buildLocalDryRun({ context, spec });
766
1024
  const [, resource, action] = context.args.command;
767
- if (["x", "linkedin", "threads"].includes(resource ?? "") &&
768
- action === "schedule") {
769
- const input = networkOptions({
770
- flags: context.args.flags,
771
- helpers,
772
- platform: resource,
773
- });
774
- return helpers.dryRunRequest({
775
- spec,
776
- method: "POST",
777
- path: "/publishing/network/schedule",
778
- body: {
779
- platform: input.platform,
780
- connection_id: input.connectionId,
781
- project_id: input.projectId,
782
- export_id: input.exportId,
783
- caption: input.caption,
784
- scheduled_for: input.scheduledFor,
785
- timezone: input.timezone,
786
- },
787
- followUpRequests: undefined,
788
- notes: [
789
- "The live request sends the supplied Idempotency-Key.",
790
- "Read the receipt with publishing posts get --post-id ID.",
791
- ],
792
- });
793
- }
794
- if (context.args.command[1] === "video" &&
795
- context.args.command[2] === "schedule") {
796
- const flags = context.args.flags;
797
- const { videoPath, mediaAssetId } = resolveUploadedVideoSourceFlags({
798
- flags,
799
- helpers,
800
- });
801
- const targets = buildUploadedVideoTargets({ flags, helpers });
802
- const waitOptions = resolvePublishingWaitOptions({
803
- intervalMs: helpers.getNumberFlag({ flags, name: "interval-ms" }),
804
- timeoutMs: helpers.getNumberFlag({ flags, name: "timeout-ms" }),
805
- });
806
- return helpers.dryRunRequest({
807
- spec,
808
- method: "POST",
809
- path: "/publishing/video/schedule",
810
- body: {
811
- media_asset_id: videoPath
812
- ? `<uploaded:${videoPath}>`
813
- : mediaAssetId,
814
- project_name: helpers.getStringFlag({
815
- flags,
816
- name: "project-name",
817
- }),
818
- caption: readCaption({ flags, helpers }),
819
- contains_synthetic_media: helpers.getBooleanFlag({
820
- flags,
821
- name: "contains-synthetic-media",
822
- }),
823
- scheduled_for: helpers.requireStringFlag({
824
- flags,
825
- name: "scheduled-for",
826
- }),
827
- timezone: helpers.getStringFlag({ flags, name: "timezone" }),
828
- include_affiliate_cta: helpers.getBooleanFlag({
829
- flags,
830
- name: "include-affiliate-cta",
831
- }),
832
- affiliate_tracking_url: helpers.getStringFlag({
833
- flags,
834
- name: "affiliate-tracking-url",
835
- }),
836
- affiliate_cta_text: helpers.getStringFlag({
837
- flags,
838
- name: "affiliate-cta-text",
839
- }),
840
- targets: targets.map((target) => mapUploadedVideoTargetRequest({ target })),
841
- },
842
- followUpRequests: undefined,
843
- notes: videoPath
844
- ? [
845
- `The live command uploads the local video and waits up to ${waitOptions.timeoutMs} ms for duration and dimensions before scheduling.`,
846
- "Dry-run does not read or upload the local file.",
847
- ]
848
- : [
849
- `The live command waits up to ${waitOptions.timeoutMs} ms for the selected video's duration and dimensions before scheduling.`,
850
- ],
851
- });
852
- }
853
- if (context.args.command[1] === "tiktok" &&
854
- context.args.command[2] === "schedule") {
855
- const flags = context.args.flags;
856
- const { projectId, imagePaths } = resolveTikTokSourceFlags({
857
- flags,
858
- helpers,
859
- });
860
- return helpers.dryRunRequest({
861
- spec,
862
- method: "POST",
863
- path: "/publishing/tiktok/schedule",
864
- body: {
865
- project_id: projectId,
866
- export_id: helpers.getStringFlag({ flags, name: "export-id" }),
867
- media_asset_ids: imagePaths.length > 0
868
- ? imagePaths.map((path) => `<uploaded:${path}>`)
869
- : undefined,
870
- project_name: helpers.getStringFlag({
871
- flags,
872
- name: "project-name",
873
- }),
874
- connection_id: helpers.getStringFlag({
875
- flags,
876
- name: "connection-id",
877
- }),
878
- caption: readCaption({ flags, helpers }),
879
- scheduled_for: helpers.requireStringFlag({
880
- flags,
881
- name: "scheduled-for",
882
- }),
883
- timezone: helpers.getStringFlag({ flags, name: "timezone" }),
884
- publish_mode: helpers.getStringFlag({
885
- flags,
886
- name: "publish-mode",
887
- }),
888
- privacy_level: readTikTokPrivacyLevel({ flags, helpers }),
889
- allow_comment: helpers.getBooleanFlag({
890
- flags,
891
- name: "allow-comment",
892
- }),
893
- allow_duet: helpers.getBooleanFlag({
894
- flags,
895
- name: "allow-duet",
896
- }),
897
- allow_stitch: helpers.getBooleanFlag({
898
- flags,
899
- name: "allow-stitch",
900
- }),
901
- cover_timestamp_ms: helpers.getNumberFlag({
902
- flags,
903
- name: "cover-timestamp-ms",
904
- }),
905
- photo_cover_index: helpers.getNumberFlag({
906
- flags,
907
- name: "photo-cover-index",
908
- }),
909
- auto_add_music: helpers.getBooleanFlag({
910
- flags,
911
- name: "auto-add-music",
912
- }),
913
- commercial_content_enabled: helpers.getBooleanFlag({
914
- flags,
915
- name: "commercial-content",
916
- }),
917
- brand_organic: helpers.getBooleanFlag({
918
- flags,
919
- name: "brand-organic",
920
- }),
921
- branded_content: helpers.getBooleanFlag({
922
- flags,
923
- name: "branded-content",
924
- }),
925
- is_ai_generated: helpers.getBooleanFlag({
926
- flags,
927
- name: "ai-generated",
928
- }),
929
- consent_accepted: helpers.getBooleanFlag({
930
- flags,
931
- name: "consent-accepted",
932
- }),
933
- },
934
- followUpRequests: undefined,
935
- notes: imagePaths.length > 0
936
- ? [
937
- `The live command uploads ${imagePaths.length} local image${imagePaths.length === 1 ? "" : "s"} in this order before scheduling.`,
938
- "Dry-run does not read or upload local files.",
939
- ]
940
- : ["The existing completed project export is scheduled."],
941
- });
942
- }
943
- if (context.args.command[1] !== "instagram" ||
944
- context.args.command[2] !== "schedule") {
945
- return undefined;
946
- }
947
- const projectId = helpers.requireStringFlag({
948
- flags: context.args.flags,
949
- name: "project-id",
950
- });
951
- return helpers.dryRunRequest({
952
- spec,
953
- method: "POST",
954
- path: `/projects/${encodeURIComponent(projectId)}/publishing/instagram`,
955
- body: {
956
- export_id: helpers.getStringFlag({
957
- flags: context.args.flags,
958
- name: "export-id",
959
- }),
960
- connection_id: helpers.getStringFlag({
961
- flags: context.args.flags,
962
- name: "connection-id",
963
- }),
964
- caption: readCaption({
965
- flags: context.args.flags,
966
- helpers,
967
- }),
968
- scheduled_for: helpers.requireStringFlag({
969
- flags: context.args.flags,
970
- name: "scheduled-for",
971
- }),
972
- timezone: helpers.getStringFlag({
973
- flags: context.args.flags,
974
- name: "timezone",
975
- }),
976
- trial_reel: helpers.getBooleanFlag({
977
- flags: context.args.flags,
978
- name: "trial-reel",
979
- }),
980
- trial_graduation_strategy: helpers.getStringFlag({
981
- flags: context.args.flags,
982
- name: "trial-graduation-strategy",
983
- }),
984
- share_to_feed: helpers.getBooleanFlag({
985
- flags: context.args.flags,
986
- name: "share-to-feed",
987
- }),
988
- include_affiliate_cta: helpers.getBooleanFlag({
989
- flags: context.args.flags,
990
- name: "include-affiliate-cta",
991
- }),
992
- affiliate_tracking_url: helpers.getStringFlag({
993
- flags: context.args.flags,
994
- name: "affiliate-tracking-url",
995
- }),
996
- affiliate_cta_text: helpers.getStringFlag({
997
- flags: context.args.flags,
998
- name: "affiliate-cta-text",
999
- }),
1000
- },
1001
- followUpRequests: undefined,
1002
- notes: [
1003
- "Requires an active Instagram account connected in the BlitzReels UI.",
1004
- "include_affiliate_cta appends Try BlitzReels for free + Affonso tracking URL.",
1005
- ],
1006
- });
1025
+ const publishes = action === "schedule" ||
1026
+ (resource === "posts" &&
1027
+ ["create", "replace"].includes(action ?? "")) ||
1028
+ (resource === "targets" &&
1029
+ ["retry", "reschedule"].includes(action ?? ""));
1030
+ return preview && publishes
1031
+ ? withPublishingAccessNote({ preview })
1032
+ : preview;
1007
1033
  },
1008
1034
  };
1009
1035
  }