@postrun/js 1.2.0 → 1.3.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/dist/index.cjs CHANGED
@@ -816,6 +816,8 @@ var zErrorCode = z__namespace.enum([
816
816
  "connection_discovery_failed",
817
817
  "media_processing",
818
818
  "not_publishable",
819
+ "invalid_connection",
820
+ "invalid_media",
819
821
  "profile_scope_invalid",
820
822
  "media_unprobeable",
821
823
  "media_too_large",
@@ -2611,6 +2613,300 @@ z__namespace.object({
2611
2613
  dry_run: z__namespace.boolean(),
2612
2614
  executed: z__namespace.boolean()
2613
2615
  });
2616
+ z__namespace.object({
2617
+ profile_id: z__namespace.string(),
2618
+ variants: z__namespace.array(z__namespace.union([
2619
+ z__namespace.object({
2620
+ platform: z__namespace.literal("x"),
2621
+ post_type: z__namespace.enum([
2622
+ "text",
2623
+ "single_image",
2624
+ "multi_image",
2625
+ "video"
2626
+ ]),
2627
+ connection_id: z__namespace.string(),
2628
+ body: z__namespace.string().optional(),
2629
+ media: z__namespace.array(z__namespace.object({
2630
+ media_id: z__namespace.string(),
2631
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2632
+ alt_text_override: z__namespace.string().nullish()
2633
+ })).optional().default([]),
2634
+ settings: z__namespace.object({
2635
+ reply_settings: z__namespace.enum([
2636
+ "everyone",
2637
+ "following",
2638
+ "mentionedUsers",
2639
+ "subscribers",
2640
+ "verified"
2641
+ ]).optional(),
2642
+ quote_tweet_id: z__namespace.string().regex(/^[0-9]{1,19}$/).optional(),
2643
+ poll: z__namespace.object({
2644
+ options: z__namespace.array(z__namespace.string().min(1).max(25)).min(2).max(4),
2645
+ duration_minutes: z__namespace.int().gte(5).lte(10080),
2646
+ reply_settings: z__namespace.enum([
2647
+ "following",
2648
+ "mentionedUsers",
2649
+ "subscribers",
2650
+ "verified"
2651
+ ]).optional()
2652
+ }).optional(),
2653
+ reply: z__namespace.object({
2654
+ in_reply_to_tweet_id: z__namespace.string().regex(/^[0-9]{1,19}$/),
2655
+ exclude_reply_user_ids: z__namespace.array(z__namespace.string().regex(/^[0-9]{1,19}$/)).optional(),
2656
+ auto_populate_reply_metadata: z__namespace.boolean().optional()
2657
+ }).optional(),
2658
+ community_id: z__namespace.string().regex(/^[0-9]{1,19}$/).optional(),
2659
+ for_super_followers_only: z__namespace.boolean().optional(),
2660
+ geo: z__namespace.object({
2661
+ place_id: z__namespace.string()
2662
+ }).optional(),
2663
+ card_uri: z__namespace.string().optional(),
2664
+ media_tagged_user_ids: z__namespace.array(z__namespace.string().regex(/^[0-9]{1,19}$/)).max(10).optional()
2665
+ }).optional().default({})
2666
+ }),
2667
+ z__namespace.object({
2668
+ platform: z__namespace.literal("linkedin"),
2669
+ post_type: z__namespace.enum([
2670
+ "text",
2671
+ "single_image",
2672
+ "multi_image",
2673
+ "video"
2674
+ ]),
2675
+ connection_id: z__namespace.string(),
2676
+ body: z__namespace.string().optional(),
2677
+ media: z__namespace.array(z__namespace.object({
2678
+ media_id: z__namespace.string(),
2679
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2680
+ alt_text_override: z__namespace.string().nullish()
2681
+ })).optional().default([]),
2682
+ settings: z__namespace.object({
2683
+ visibility: z__namespace.enum(["PUBLIC", "CONNECTIONS"]),
2684
+ content_kind: z__namespace.enum([
2685
+ "text",
2686
+ "single_image",
2687
+ "video",
2688
+ "multi_image",
2689
+ "document",
2690
+ "article",
2691
+ "poll"
2692
+ ]),
2693
+ article: z__namespace.object({
2694
+ source: z__namespace.url(),
2695
+ title: z__namespace.string().max(400).optional(),
2696
+ description: z__namespace.string().max(4086).optional(),
2697
+ thumbnail_media_id: z__namespace.string().optional()
2698
+ }).optional(),
2699
+ poll: z__namespace.object({
2700
+ question: z__namespace.string().min(1).max(140),
2701
+ options: z__namespace.array(z__namespace.string().min(1).max(30)).min(2).max(4),
2702
+ duration: z__namespace.enum([
2703
+ "ONE_DAY",
2704
+ "THREE_DAYS",
2705
+ "SEVEN_DAYS",
2706
+ "FOURTEEN_DAYS"
2707
+ ])
2708
+ }).optional(),
2709
+ document: z__namespace.object({
2710
+ title: z__namespace.string().min(1).max(400)
2711
+ }).optional(),
2712
+ disable_reshare: z__namespace.boolean().optional(),
2713
+ mentions: z__namespace.array(z__namespace.object({
2714
+ type: z__namespace.enum(["person", "organization"]),
2715
+ name: z__namespace.string().min(1),
2716
+ urn: z__namespace.string().regex(/^urn:li:(person|organization):/)
2717
+ })).optional()
2718
+ })
2719
+ }),
2720
+ z__namespace.object({
2721
+ platform: z__namespace.literal("instagram"),
2722
+ post_type: z__namespace.enum([
2723
+ "single_image",
2724
+ "carousel",
2725
+ "reel"
2726
+ ]),
2727
+ connection_id: z__namespace.string(),
2728
+ body: z__namespace.string().optional(),
2729
+ media: z__namespace.array(z__namespace.object({
2730
+ media_id: z__namespace.string(),
2731
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2732
+ alt_text_override: z__namespace.string().nullish()
2733
+ })).optional().default([]),
2734
+ settings: z__namespace.object({
2735
+ media_type: z__namespace.enum([
2736
+ "IMAGE",
2737
+ "CAROUSEL",
2738
+ "REELS"
2739
+ ]).optional(),
2740
+ location_id: z__namespace.string().optional(),
2741
+ user_tags: z__namespace.array(z__namespace.object({
2742
+ username: z__namespace.string().min(1),
2743
+ x: z__namespace.number().gte(0).lte(1),
2744
+ y: z__namespace.number().gte(0).lte(1)
2745
+ })).optional(),
2746
+ collaborators: z__namespace.array(z__namespace.string().min(1)).max(3).optional(),
2747
+ share_to_feed: z__namespace.boolean().optional(),
2748
+ thumb_offset: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2749
+ cover_url: z__namespace.url().optional(),
2750
+ audio_name: z__namespace.string().optional()
2751
+ })
2752
+ }),
2753
+ z__namespace.object({
2754
+ platform: z__namespace.literal("facebook_page"),
2755
+ post_type: z__namespace.enum([
2756
+ "text",
2757
+ "single_image",
2758
+ "multi_image",
2759
+ "reel"
2760
+ ]),
2761
+ connection_id: z__namespace.string(),
2762
+ body: z__namespace.string().optional(),
2763
+ media: z__namespace.array(z__namespace.object({
2764
+ media_id: z__namespace.string(),
2765
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2766
+ alt_text_override: z__namespace.string().nullish()
2767
+ })).optional().default([]),
2768
+ settings: z__namespace.object({
2769
+ link: z__namespace.url().optional()
2770
+ }).optional().default({})
2771
+ }),
2772
+ z__namespace.object({
2773
+ platform: z__namespace.literal("tiktok"),
2774
+ post_type: z__namespace.enum([
2775
+ "video",
2776
+ "single_image",
2777
+ "carousel"
2778
+ ]),
2779
+ connection_id: z__namespace.string(),
2780
+ body: z__namespace.string().optional(),
2781
+ media: z__namespace.array(z__namespace.object({
2782
+ media_id: z__namespace.string(),
2783
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2784
+ alt_text_override: z__namespace.string().nullish()
2785
+ })).optional().default([]),
2786
+ settings: z__namespace.object({
2787
+ privacy_level: z__namespace.enum([
2788
+ "PUBLIC_TO_EVERYONE",
2789
+ "MUTUAL_FOLLOW_FRIENDS",
2790
+ "FOLLOWER_OF_CREATOR",
2791
+ "SELF_ONLY"
2792
+ ]).optional(),
2793
+ disable_comment: z__namespace.boolean().optional(),
2794
+ disable_duet: z__namespace.boolean().optional(),
2795
+ disable_stitch: z__namespace.boolean().optional(),
2796
+ video_cover_timestamp_ms: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2797
+ photo_cover_index: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2798
+ auto_add_music: z__namespace.boolean().optional(),
2799
+ brand_content_toggle: z__namespace.boolean().optional(),
2800
+ brand_organic_toggle: z__namespace.boolean().optional(),
2801
+ is_aigc: z__namespace.boolean().optional()
2802
+ }).optional().default({})
2803
+ })
2804
+ ])).min(1)
2805
+ });
2806
+ z__namespace.object({
2807
+ object: z__namespace.literal("validation"),
2808
+ publishable: z__namespace.boolean(),
2809
+ issues: z__namespace.array(z__namespace.object({
2810
+ code: z__namespace.enum([
2811
+ "unauthorized",
2812
+ "forbidden",
2813
+ "not_found",
2814
+ "conflict",
2815
+ "validation_failed",
2816
+ "rate_limited",
2817
+ "internal_error",
2818
+ "idempotency_key_invalid",
2819
+ "idempotency_key_reused",
2820
+ "idempotency_request_in_progress",
2821
+ "account_not_available",
2822
+ "connection_reauth_required",
2823
+ "connection_not_pending",
2824
+ "connection_in_use",
2825
+ "not_implemented",
2826
+ "connection_discovery_failed",
2827
+ "media_processing",
2828
+ "not_publishable",
2829
+ "invalid_connection",
2830
+ "invalid_media",
2831
+ "profile_scope_invalid",
2832
+ "media_unprobeable",
2833
+ "media_too_large",
2834
+ "media_aspect_ratio_unsupported",
2835
+ "media_resolution_too_low",
2836
+ "media_gif_unsupported",
2837
+ "media_format_recompressed",
2838
+ "media_resolution_downscaled",
2839
+ "video_container_unsupported",
2840
+ "video_codec_unsupported",
2841
+ "video_audio_codec_unsupported",
2842
+ "video_too_large",
2843
+ "video_too_small",
2844
+ "video_dimensions_unsupported",
2845
+ "video_dimensions_too_large",
2846
+ "video_fps_unsupported",
2847
+ "video_fps_too_low",
2848
+ "video_aspect_unsupported",
2849
+ "video_duration_too_short",
2850
+ "video_duration_exceeds_max",
2851
+ "video_transform_failed",
2852
+ "media_fetch_failed",
2853
+ "document_format_unsupported",
2854
+ "document_too_large",
2855
+ "document_too_many_pages",
2856
+ "media_format_indeterminate",
2857
+ "media_count_invalid",
2858
+ "body_too_long",
2859
+ "content_missing",
2860
+ "content_conflict",
2861
+ "content_incomplete",
2862
+ "content_kind_mismatch",
2863
+ "media_type_mismatch",
2864
+ "tag_limit_exceeded",
2865
+ "reel_field_on_non_reel",
2866
+ "field_placement_invalid",
2867
+ "media_not_ready",
2868
+ "media_failed",
2869
+ "media_unsupported",
2870
+ "media_kind_mismatch",
2871
+ "publishing_unavailable",
2872
+ "x_duplicate_content",
2873
+ "x_not_authorized",
2874
+ "x_rate_limited",
2875
+ "x_publish_failed",
2876
+ "x_media_upload_failed",
2877
+ "linkedin_duplicate_content",
2878
+ "linkedin_auth_expired",
2879
+ "linkedin_permission_denied",
2880
+ "linkedin_media_processing",
2881
+ "linkedin_media_upload_failed",
2882
+ "linkedin_publish_failed",
2883
+ "instagram_media_processing",
2884
+ "instagram_container_expired",
2885
+ "instagram_container_failed",
2886
+ "instagram_rate_limited",
2887
+ "instagram_not_authorized",
2888
+ "instagram_publish_failed",
2889
+ "facebook_reel_processing",
2890
+ "facebook_reel_failed",
2891
+ "facebook_rate_limited",
2892
+ "facebook_not_authorized",
2893
+ "facebook_publish_failed",
2894
+ "tiktok_privacy_not_allowed",
2895
+ "tiktok_duration_exceeds_max",
2896
+ "tiktok_media_processing",
2897
+ "tiktok_not_authorized",
2898
+ "tiktok_rate_limited",
2899
+ "tiktok_publish_failed",
2900
+ "connection_platform_mismatch"
2901
+ ]),
2902
+ message: z__namespace.string(),
2903
+ hint: z__namespace.string().optional(),
2904
+ allowed: z__namespace.array(z__namespace.string()).optional(),
2905
+ got: z__namespace.string().optional(),
2906
+ variant_index: z__namespace.int().gte(-9007199254740991).lte(9007199254740991),
2907
+ path: z__namespace.array(z__namespace.union([z__namespace.string(), z__namespace.number()]))
2908
+ }))
2909
+ });
2614
2910
  z__namespace.object({
2615
2911
  connection_id: z__namespace.string()
2616
2912
  });
@@ -4704,6 +5000,23 @@ var postsUpdate = (options) => (options.client ?? client).patch({
4704
5000
  ...options.headers
4705
5001
  }
4706
5002
  });
5003
+ var postsValidate = (options) => (options.client ?? client).post({
5004
+ security: [{
5005
+ key: "secretKey",
5006
+ scheme: "bearer",
5007
+ type: "http"
5008
+ }, {
5009
+ key: "frontendToken",
5010
+ scheme: "bearer",
5011
+ type: "http"
5012
+ }],
5013
+ url: "/posts/validate",
5014
+ ...options,
5015
+ headers: {
5016
+ "Content-Type": "application/json",
5017
+ ...options.headers
5018
+ }
5019
+ });
4707
5020
  var metaAccount = (options) => (options.client ?? client).get({
4708
5021
  security: [{
4709
5022
  key: "secretKey",
@@ -5592,29 +5905,15 @@ function countKinds(media) {
5592
5905
  }
5593
5906
  return { images, videos, documents };
5594
5907
  }
5595
- function rejectDocuments(media, platform) {
5596
- if (countKinds(media).documents > 0) {
5597
- throw new ComposeError(`${platform} does not support document uploads.`);
5598
- }
5599
- }
5600
- function deriveSinglePlacement(media, platform, videoType) {
5908
+ function deriveSinglePlacement(media, videoType) {
5601
5909
  const { images, videos } = countKinds(media);
5602
- if (images > 0 && videos > 0) {
5603
- throw new ComposeError(
5604
- `${platform} can't combine images and video in one post \u2014 split them into separate posts.`
5605
- );
5606
- }
5607
- if (videos > 1) {
5608
- throw new ComposeError(`${platform} allows at most one video per post.`);
5609
- }
5610
- if (videos === 1) return videoType;
5910
+ if (videos >= 1) return videoType;
5611
5911
  return images >= 2 ? "multi_image" : "single_image";
5612
5912
  }
5613
5913
  var xHandler = {
5614
5914
  derivePostType: (media) => {
5615
5915
  if (media.length === 0) return "text";
5616
- rejectDocuments(media, "X");
5617
- return deriveSinglePlacement(media, "X", "video");
5916
+ return deriveSinglePlacement(media, "video");
5618
5917
  },
5619
5918
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5620
5919
  platform: "x",
@@ -5629,12 +5928,9 @@ var linkedInHandler = {
5629
5928
  derivePostType: (media) => {
5630
5929
  if (media.length === 0) return "text";
5631
5930
  if (countKinds(media).documents > 0) {
5632
- if (media.length > 1) {
5633
- throw new ComposeError("A LinkedIn document post takes a single document.");
5634
- }
5635
5931
  return "single_image";
5636
5932
  }
5637
- return deriveSinglePlacement(media, "LinkedIn", "video");
5933
+ return deriveSinglePlacement(media, "video");
5638
5934
  },
5639
5935
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5640
5936
  platform: "linkedin",
@@ -5648,8 +5944,7 @@ var linkedInHandler = {
5648
5944
  var facebookHandler = {
5649
5945
  derivePostType: (media) => {
5650
5946
  if (media.length === 0) return "text";
5651
- rejectDocuments(media, "Facebook");
5652
- return deriveSinglePlacement(media, "Facebook", "reel");
5947
+ return deriveSinglePlacement(media, "reel");
5653
5948
  },
5654
5949
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5655
5950
  platform: "facebook_page",
@@ -5662,10 +5957,6 @@ var facebookHandler = {
5662
5957
  };
5663
5958
  var instagramHandler = {
5664
5959
  derivePostType: (media) => {
5665
- if (media.length === 0) {
5666
- throw new ComposeError("Instagram requires at least one media item.");
5667
- }
5668
- rejectDocuments(media, "Instagram");
5669
5960
  if (media.length >= 2) return "carousel";
5670
5961
  return countKinds(media).videos === 1 ? "reel" : "single_image";
5671
5962
  },
@@ -5680,20 +5971,8 @@ var instagramHandler = {
5680
5971
  };
5681
5972
  var tiktokHandler = {
5682
5973
  derivePostType: (media) => {
5683
- if (media.length === 0) {
5684
- throw new ComposeError("TikTok requires at least one media item.");
5685
- }
5686
- rejectDocuments(media, "TikTok");
5687
5974
  const { images, videos } = countKinds(media);
5688
- if (images > 0 && videos > 0) {
5689
- throw new ComposeError(
5690
- "TikTok can't combine images and video in one post \u2014 split them into separate posts."
5691
- );
5692
- }
5693
- if (videos > 1) {
5694
- throw new ComposeError("TikTok allows at most one video per post.");
5695
- }
5696
- if (videos === 1) return "video";
5975
+ if (videos >= 1) return "video";
5697
5976
  return images >= 2 ? "carousel" : "single_image";
5698
5977
  },
5699
5978
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
@@ -5872,6 +6151,7 @@ exports.postsDelete = postsDelete;
5872
6151
  exports.postsGet = postsGet;
5873
6152
  exports.postsList = postsList;
5874
6153
  exports.postsUpdate = postsUpdate;
6154
+ exports.postsValidate = postsValidate;
5875
6155
  exports.profilesCreate = profilesCreate;
5876
6156
  exports.profilesDelete = profilesDelete;
5877
6157
  exports.profilesGet = profilesGet;