@postrun/js 1.2.0 → 2.0.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
@@ -811,11 +811,12 @@ var zErrorCode = z__namespace.enum([
811
811
  "account_not_available",
812
812
  "connection_reauth_required",
813
813
  "connection_not_pending",
814
- "connection_in_use",
815
814
  "not_implemented",
816
815
  "connection_discovery_failed",
817
816
  "media_processing",
818
817
  "not_publishable",
818
+ "invalid_connection",
819
+ "invalid_media",
819
820
  "profile_scope_invalid",
820
821
  "media_unprobeable",
821
822
  "media_too_large",
@@ -856,6 +857,7 @@ var zErrorCode = z__namespace.enum([
856
857
  "media_failed",
857
858
  "media_unsupported",
858
859
  "media_kind_mismatch",
860
+ "variant_unparseable",
859
861
  "publishing_unavailable",
860
862
  "x_duplicate_content",
861
863
  "x_not_authorized",
@@ -885,7 +887,8 @@ var zErrorCode = z__namespace.enum([
885
887
  "tiktok_not_authorized",
886
888
  "tiktok_rate_limited",
887
889
  "tiktok_publish_failed",
888
- "connection_platform_mismatch"
890
+ "connection_platform_mismatch",
891
+ "connection_removed"
889
892
  ]);
890
893
  z__namespace.object({
891
894
  limit: z__namespace.int().gte(1).lte(100).optional().default(20),
@@ -1927,7 +1930,7 @@ z__namespace.object({
1927
1930
  variants: z__namespace.array(z__namespace.object({
1928
1931
  id: z__namespace.string(),
1929
1932
  object: z__namespace.literal("post_variant"),
1930
- connection_id: z__namespace.string(),
1933
+ connection_id: z__namespace.string().nullable(),
1931
1934
  platform: z__namespace.enum([
1932
1935
  "x",
1933
1936
  "linkedin",
@@ -2206,7 +2209,7 @@ z__namespace.object({
2206
2209
  variants: z__namespace.array(z__namespace.object({
2207
2210
  id: z__namespace.string(),
2208
2211
  object: z__namespace.literal("post_variant"),
2209
- connection_id: z__namespace.string(),
2212
+ connection_id: z__namespace.string().nullable(),
2210
2213
  platform: z__namespace.enum([
2211
2214
  "x",
2212
2215
  "linkedin",
@@ -2288,7 +2291,7 @@ z__namespace.object({
2288
2291
  variants: z__namespace.array(z__namespace.object({
2289
2292
  id: z__namespace.string(),
2290
2293
  object: z__namespace.literal("post_variant"),
2291
- connection_id: z__namespace.string(),
2294
+ connection_id: z__namespace.string().nullable(),
2292
2295
  platform: z__namespace.enum([
2293
2296
  "x",
2294
2297
  "linkedin",
@@ -2564,7 +2567,7 @@ z__namespace.object({
2564
2567
  variants: z__namespace.array(z__namespace.object({
2565
2568
  id: z__namespace.string(),
2566
2569
  object: z__namespace.literal("post_variant"),
2567
- connection_id: z__namespace.string(),
2570
+ connection_id: z__namespace.string().nullable(),
2568
2571
  platform: z__namespace.enum([
2569
2572
  "x",
2570
2573
  "linkedin",
@@ -2611,6 +2614,301 @@ z__namespace.object({
2611
2614
  dry_run: z__namespace.boolean(),
2612
2615
  executed: z__namespace.boolean()
2613
2616
  });
2617
+ z__namespace.object({
2618
+ profile_id: z__namespace.string(),
2619
+ variants: z__namespace.array(z__namespace.union([
2620
+ z__namespace.object({
2621
+ platform: z__namespace.literal("x"),
2622
+ post_type: z__namespace.enum([
2623
+ "text",
2624
+ "single_image",
2625
+ "multi_image",
2626
+ "video"
2627
+ ]),
2628
+ connection_id: z__namespace.string(),
2629
+ body: z__namespace.string().optional(),
2630
+ media: z__namespace.array(z__namespace.object({
2631
+ media_id: z__namespace.string(),
2632
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2633
+ alt_text_override: z__namespace.string().nullish()
2634
+ })).optional().default([]),
2635
+ settings: z__namespace.object({
2636
+ reply_settings: z__namespace.enum([
2637
+ "everyone",
2638
+ "following",
2639
+ "mentionedUsers",
2640
+ "subscribers",
2641
+ "verified"
2642
+ ]).optional(),
2643
+ quote_tweet_id: z__namespace.string().regex(/^[0-9]{1,19}$/).optional(),
2644
+ poll: z__namespace.object({
2645
+ options: z__namespace.array(z__namespace.string().min(1).max(25)).min(2).max(4),
2646
+ duration_minutes: z__namespace.int().gte(5).lte(10080),
2647
+ reply_settings: z__namespace.enum([
2648
+ "following",
2649
+ "mentionedUsers",
2650
+ "subscribers",
2651
+ "verified"
2652
+ ]).optional()
2653
+ }).optional(),
2654
+ reply: z__namespace.object({
2655
+ in_reply_to_tweet_id: z__namespace.string().regex(/^[0-9]{1,19}$/),
2656
+ exclude_reply_user_ids: z__namespace.array(z__namespace.string().regex(/^[0-9]{1,19}$/)).optional(),
2657
+ auto_populate_reply_metadata: z__namespace.boolean().optional()
2658
+ }).optional(),
2659
+ community_id: z__namespace.string().regex(/^[0-9]{1,19}$/).optional(),
2660
+ for_super_followers_only: z__namespace.boolean().optional(),
2661
+ geo: z__namespace.object({
2662
+ place_id: z__namespace.string()
2663
+ }).optional(),
2664
+ card_uri: z__namespace.string().optional(),
2665
+ media_tagged_user_ids: z__namespace.array(z__namespace.string().regex(/^[0-9]{1,19}$/)).max(10).optional()
2666
+ }).optional().default({})
2667
+ }),
2668
+ z__namespace.object({
2669
+ platform: z__namespace.literal("linkedin"),
2670
+ post_type: z__namespace.enum([
2671
+ "text",
2672
+ "single_image",
2673
+ "multi_image",
2674
+ "video"
2675
+ ]),
2676
+ connection_id: z__namespace.string(),
2677
+ body: z__namespace.string().optional(),
2678
+ media: z__namespace.array(z__namespace.object({
2679
+ media_id: z__namespace.string(),
2680
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2681
+ alt_text_override: z__namespace.string().nullish()
2682
+ })).optional().default([]),
2683
+ settings: z__namespace.object({
2684
+ visibility: z__namespace.enum(["PUBLIC", "CONNECTIONS"]),
2685
+ content_kind: z__namespace.enum([
2686
+ "text",
2687
+ "single_image",
2688
+ "video",
2689
+ "multi_image",
2690
+ "document",
2691
+ "article",
2692
+ "poll"
2693
+ ]),
2694
+ article: z__namespace.object({
2695
+ source: z__namespace.url(),
2696
+ title: z__namespace.string().max(400).optional(),
2697
+ description: z__namespace.string().max(4086).optional(),
2698
+ thumbnail_media_id: z__namespace.string().optional()
2699
+ }).optional(),
2700
+ poll: z__namespace.object({
2701
+ question: z__namespace.string().min(1).max(140),
2702
+ options: z__namespace.array(z__namespace.string().min(1).max(30)).min(2).max(4),
2703
+ duration: z__namespace.enum([
2704
+ "ONE_DAY",
2705
+ "THREE_DAYS",
2706
+ "SEVEN_DAYS",
2707
+ "FOURTEEN_DAYS"
2708
+ ])
2709
+ }).optional(),
2710
+ document: z__namespace.object({
2711
+ title: z__namespace.string().min(1).max(400)
2712
+ }).optional(),
2713
+ disable_reshare: z__namespace.boolean().optional(),
2714
+ mentions: z__namespace.array(z__namespace.object({
2715
+ type: z__namespace.enum(["person", "organization"]),
2716
+ name: z__namespace.string().min(1),
2717
+ urn: z__namespace.string().regex(/^urn:li:(person|organization):/)
2718
+ })).optional()
2719
+ })
2720
+ }),
2721
+ z__namespace.object({
2722
+ platform: z__namespace.literal("instagram"),
2723
+ post_type: z__namespace.enum([
2724
+ "single_image",
2725
+ "carousel",
2726
+ "reel"
2727
+ ]),
2728
+ connection_id: z__namespace.string(),
2729
+ body: z__namespace.string().optional(),
2730
+ media: z__namespace.array(z__namespace.object({
2731
+ media_id: z__namespace.string(),
2732
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2733
+ alt_text_override: z__namespace.string().nullish()
2734
+ })).optional().default([]),
2735
+ settings: z__namespace.object({
2736
+ media_type: z__namespace.enum([
2737
+ "IMAGE",
2738
+ "CAROUSEL",
2739
+ "REELS"
2740
+ ]).optional(),
2741
+ location_id: z__namespace.string().optional(),
2742
+ user_tags: z__namespace.array(z__namespace.object({
2743
+ username: z__namespace.string().min(1),
2744
+ x: z__namespace.number().gte(0).lte(1),
2745
+ y: z__namespace.number().gte(0).lte(1)
2746
+ })).optional(),
2747
+ collaborators: z__namespace.array(z__namespace.string().min(1)).max(3).optional(),
2748
+ share_to_feed: z__namespace.boolean().optional(),
2749
+ thumb_offset: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2750
+ cover_url: z__namespace.url().optional(),
2751
+ audio_name: z__namespace.string().optional()
2752
+ })
2753
+ }),
2754
+ z__namespace.object({
2755
+ platform: z__namespace.literal("facebook_page"),
2756
+ post_type: z__namespace.enum([
2757
+ "text",
2758
+ "single_image",
2759
+ "multi_image",
2760
+ "reel"
2761
+ ]),
2762
+ connection_id: z__namespace.string(),
2763
+ body: z__namespace.string().optional(),
2764
+ media: z__namespace.array(z__namespace.object({
2765
+ media_id: z__namespace.string(),
2766
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2767
+ alt_text_override: z__namespace.string().nullish()
2768
+ })).optional().default([]),
2769
+ settings: z__namespace.object({
2770
+ link: z__namespace.url().optional()
2771
+ }).optional().default({})
2772
+ }),
2773
+ z__namespace.object({
2774
+ platform: z__namespace.literal("tiktok"),
2775
+ post_type: z__namespace.enum([
2776
+ "video",
2777
+ "single_image",
2778
+ "carousel"
2779
+ ]),
2780
+ connection_id: z__namespace.string(),
2781
+ body: z__namespace.string().optional(),
2782
+ media: z__namespace.array(z__namespace.object({
2783
+ media_id: z__namespace.string(),
2784
+ crop_box: z__namespace.record(z__namespace.string(), z__namespace.unknown()).nullish(),
2785
+ alt_text_override: z__namespace.string().nullish()
2786
+ })).optional().default([]),
2787
+ settings: z__namespace.object({
2788
+ privacy_level: z__namespace.enum([
2789
+ "PUBLIC_TO_EVERYONE",
2790
+ "MUTUAL_FOLLOW_FRIENDS",
2791
+ "FOLLOWER_OF_CREATOR",
2792
+ "SELF_ONLY"
2793
+ ]).optional(),
2794
+ disable_comment: z__namespace.boolean().optional(),
2795
+ disable_duet: z__namespace.boolean().optional(),
2796
+ disable_stitch: z__namespace.boolean().optional(),
2797
+ video_cover_timestamp_ms: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2798
+ photo_cover_index: z__namespace.int().gte(0).lte(9007199254740991).optional(),
2799
+ auto_add_music: z__namespace.boolean().optional(),
2800
+ brand_content_toggle: z__namespace.boolean().optional(),
2801
+ brand_organic_toggle: z__namespace.boolean().optional(),
2802
+ is_aigc: z__namespace.boolean().optional()
2803
+ }).optional().default({})
2804
+ })
2805
+ ])).min(1)
2806
+ });
2807
+ z__namespace.object({
2808
+ object: z__namespace.literal("validation"),
2809
+ publishable: z__namespace.boolean(),
2810
+ issues: z__namespace.array(z__namespace.object({
2811
+ code: z__namespace.enum([
2812
+ "unauthorized",
2813
+ "forbidden",
2814
+ "not_found",
2815
+ "conflict",
2816
+ "validation_failed",
2817
+ "rate_limited",
2818
+ "internal_error",
2819
+ "idempotency_key_invalid",
2820
+ "idempotency_key_reused",
2821
+ "idempotency_request_in_progress",
2822
+ "account_not_available",
2823
+ "connection_reauth_required",
2824
+ "connection_not_pending",
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
+ "variant_unparseable",
2872
+ "publishing_unavailable",
2873
+ "x_duplicate_content",
2874
+ "x_not_authorized",
2875
+ "x_rate_limited",
2876
+ "x_publish_failed",
2877
+ "x_media_upload_failed",
2878
+ "linkedin_duplicate_content",
2879
+ "linkedin_auth_expired",
2880
+ "linkedin_permission_denied",
2881
+ "linkedin_media_processing",
2882
+ "linkedin_media_upload_failed",
2883
+ "linkedin_publish_failed",
2884
+ "instagram_media_processing",
2885
+ "instagram_container_expired",
2886
+ "instagram_container_failed",
2887
+ "instagram_rate_limited",
2888
+ "instagram_not_authorized",
2889
+ "instagram_publish_failed",
2890
+ "facebook_reel_processing",
2891
+ "facebook_reel_failed",
2892
+ "facebook_rate_limited",
2893
+ "facebook_not_authorized",
2894
+ "facebook_publish_failed",
2895
+ "tiktok_privacy_not_allowed",
2896
+ "tiktok_duration_exceeds_max",
2897
+ "tiktok_media_processing",
2898
+ "tiktok_not_authorized",
2899
+ "tiktok_rate_limited",
2900
+ "tiktok_publish_failed",
2901
+ "connection_platform_mismatch",
2902
+ "connection_removed"
2903
+ ]),
2904
+ message: z__namespace.string(),
2905
+ hint: z__namespace.string().optional(),
2906
+ allowed: z__namespace.array(z__namespace.string()).optional(),
2907
+ got: z__namespace.string().optional(),
2908
+ variant_index: z__namespace.int().gte(-9007199254740991).lte(9007199254740991),
2909
+ path: z__namespace.array(z__namespace.union([z__namespace.string(), z__namespace.number()]))
2910
+ }))
2911
+ });
2614
2912
  z__namespace.object({
2615
2913
  connection_id: z__namespace.string()
2616
2914
  });
@@ -4704,6 +5002,23 @@ var postsUpdate = (options) => (options.client ?? client).patch({
4704
5002
  ...options.headers
4705
5003
  }
4706
5004
  });
5005
+ var postsValidate = (options) => (options.client ?? client).post({
5006
+ security: [{
5007
+ key: "secretKey",
5008
+ scheme: "bearer",
5009
+ type: "http"
5010
+ }, {
5011
+ key: "frontendToken",
5012
+ scheme: "bearer",
5013
+ type: "http"
5014
+ }],
5015
+ url: "/posts/validate",
5016
+ ...options,
5017
+ headers: {
5018
+ "Content-Type": "application/json",
5019
+ ...options.headers
5020
+ }
5021
+ });
4707
5022
  var metaAccount = (options) => (options.client ?? client).get({
4708
5023
  security: [{
4709
5024
  key: "secretKey",
@@ -5592,29 +5907,15 @@ function countKinds(media) {
5592
5907
  }
5593
5908
  return { images, videos, documents };
5594
5909
  }
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) {
5910
+ function deriveSinglePlacement(media, videoType) {
5601
5911
  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;
5912
+ if (videos >= 1) return videoType;
5611
5913
  return images >= 2 ? "multi_image" : "single_image";
5612
5914
  }
5613
5915
  var xHandler = {
5614
5916
  derivePostType: (media) => {
5615
5917
  if (media.length === 0) return "text";
5616
- rejectDocuments(media, "X");
5617
- return deriveSinglePlacement(media, "X", "video");
5918
+ return deriveSinglePlacement(media, "video");
5618
5919
  },
5619
5920
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5620
5921
  platform: "x",
@@ -5629,12 +5930,9 @@ var linkedInHandler = {
5629
5930
  derivePostType: (media) => {
5630
5931
  if (media.length === 0) return "text";
5631
5932
  if (countKinds(media).documents > 0) {
5632
- if (media.length > 1) {
5633
- throw new ComposeError("A LinkedIn document post takes a single document.");
5634
- }
5635
5933
  return "single_image";
5636
5934
  }
5637
- return deriveSinglePlacement(media, "LinkedIn", "video");
5935
+ return deriveSinglePlacement(media, "video");
5638
5936
  },
5639
5937
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5640
5938
  platform: "linkedin",
@@ -5648,8 +5946,7 @@ var linkedInHandler = {
5648
5946
  var facebookHandler = {
5649
5947
  derivePostType: (media) => {
5650
5948
  if (media.length === 0) return "text";
5651
- rejectDocuments(media, "Facebook");
5652
- return deriveSinglePlacement(media, "Facebook", "reel");
5949
+ return deriveSinglePlacement(media, "reel");
5653
5950
  },
5654
5951
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
5655
5952
  platform: "facebook_page",
@@ -5662,10 +5959,6 @@ var facebookHandler = {
5662
5959
  };
5663
5960
  var instagramHandler = {
5664
5961
  derivePostType: (media) => {
5665
- if (media.length === 0) {
5666
- throw new ComposeError("Instagram requires at least one media item.");
5667
- }
5668
- rejectDocuments(media, "Instagram");
5669
5962
  if (media.length >= 2) return "carousel";
5670
5963
  return countKinds(media).videos === 1 ? "reel" : "single_image";
5671
5964
  },
@@ -5680,20 +5973,8 @@ var instagramHandler = {
5680
5973
  };
5681
5974
  var tiktokHandler = {
5682
5975
  derivePostType: (media) => {
5683
- if (media.length === 0) {
5684
- throw new ComposeError("TikTok requires at least one media item.");
5685
- }
5686
- rejectDocuments(media, "TikTok");
5687
5976
  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";
5977
+ if (videos >= 1) return "video";
5697
5978
  return images >= 2 ? "carousel" : "single_image";
5698
5979
  },
5699
5980
  buildVariant: ({ settings, postType, connectionId, body, media }) => ({
@@ -5872,6 +6153,7 @@ exports.postsDelete = postsDelete;
5872
6153
  exports.postsGet = postsGet;
5873
6154
  exports.postsList = postsList;
5874
6155
  exports.postsUpdate = postsUpdate;
6156
+ exports.postsValidate = postsValidate;
5875
6157
  exports.profilesCreate = profilesCreate;
5876
6158
  exports.profilesDelete = profilesDelete;
5877
6159
  exports.profilesGet = profilesGet;