blitzreels 0.1.31 → 0.1.32

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.
@@ -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",
@@ -499,6 +749,12 @@ export function createPublishingCommandOperation({ helpers, }) {
499
749
  intervalMs: helpers.getNumberFlag({ flags, name: "interval-ms" }),
500
750
  timeoutMs: helpers.getNumberFlag({ flags, name: "timeout-ms" }),
501
751
  });
752
+ const scheduledFor = readScheduledFor({ flags, helpers });
753
+ if (videoPath)
754
+ await assertPublishingAccessBeforeUpload({
755
+ context,
756
+ needs: "schedule",
757
+ });
502
758
  const resolvedMediaAssetId = videoPath
503
759
  ? (await helpers.uploadLocalMediaFile({
504
760
  context,
@@ -538,10 +794,7 @@ export function createPublishingCommandOperation({ helpers, }) {
538
794
  flags,
539
795
  name: "contains-synthetic-media",
540
796
  }),
541
- scheduledFor: helpers.requireStringFlag({
542
- flags,
543
- name: "scheduled-for",
544
- }),
797
+ scheduledFor,
545
798
  timezone: helpers.getStringFlag({ flags, name: "timezone" }),
546
799
  includeAffiliateCta: helpers.getBooleanFlag({
547
800
  flags,
@@ -590,6 +843,12 @@ export function createPublishingCommandOperation({ helpers, }) {
590
843
  throw new Error("TikTok direct posting requires an explicit --privacy-level.");
591
844
  }
592
845
  const mediaAssetIds = [];
846
+ const scheduledFor = readScheduledFor({ flags, helpers });
847
+ if (imagePaths.length > 0)
848
+ await assertPublishingAccessBeforeUpload({
849
+ context,
850
+ needs: "schedule",
851
+ });
593
852
  for (const filePath of imagePaths) {
594
853
  const uploaded = await helpers.uploadLocalMediaFile({
595
854
  context,
@@ -614,10 +873,7 @@ export function createPublishingCommandOperation({ helpers, }) {
614
873
  name: "connection-id",
615
874
  }),
616
875
  caption: readCaption({ flags, helpers }),
617
- scheduledFor: helpers.requireStringFlag({
618
- flags,
619
- name: "scheduled-for",
620
- }),
876
+ scheduledFor,
621
877
  timezone: helpers.getStringFlag({ flags, name: "timezone" }),
622
878
  publishMode,
623
879
  privacyLevel,
@@ -695,9 +951,9 @@ export function createPublishingCommandOperation({ helpers, }) {
695
951
  flags: context.args.flags,
696
952
  name: "project-id",
697
953
  });
698
- const scheduledFor = helpers.requireStringFlag({
954
+ const scheduledFor = readScheduledFor({
699
955
  flags: context.args.flags,
700
- name: "scheduled-for",
956
+ helpers,
701
957
  });
702
958
  const result = await context.client.publishing.scheduleInstagram({
703
959
  idempotencyKey: helpers.getStringFlag({
@@ -760,250 +1016,17 @@ export function createPublishingCommandOperation({ helpers, }) {
760
1016
  }
761
1017
  return false;
762
1018
  },
763
- buildDryRun: ({ context, spec }) => {
764
- if (posts.matches({ command: context.args.command }))
765
- return posts.buildDryRun({ context, spec });
1019
+ buildDryRun: async ({ context, spec }) => {
1020
+ const preview = await buildLocalDryRun({ context, spec });
766
1021
  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
- });
1022
+ const publishes = action === "schedule" ||
1023
+ (resource === "posts" &&
1024
+ ["create", "replace"].includes(action ?? "")) ||
1025
+ (resource === "targets" &&
1026
+ ["retry", "reschedule"].includes(action ?? ""));
1027
+ return preview && publishes
1028
+ ? withPublishingAccessNote({ preview })
1029
+ : preview;
1007
1030
  },
1008
1031
  };
1009
1032
  }