@postrun/js 2.25.0 → 3.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
@@ -859,7 +859,6 @@ var zErrorCode = z__namespace.enum([
859
859
  "content_missing",
860
860
  "content_conflict",
861
861
  "content_incomplete",
862
- "content_kind_mismatch",
863
862
  "media_type_mismatch",
864
863
  "tag_limit_exceeded",
865
864
  "reel_field_on_non_reel",
@@ -1156,7 +1155,7 @@ var zPostPlatform = z__namespace.enum([
1156
1155
  "instagram",
1157
1156
  "tiktok"
1158
1157
  ]);
1159
- z__namespace.enum([
1158
+ var zPostType = z__namespace.enum([
1160
1159
  "text",
1161
1160
  "single_image",
1162
1161
  "multi_image",
@@ -1219,12 +1218,6 @@ var zTikTokPrivacyLevel = z__namespace.enum([
1219
1218
  var zPostVariant = z__namespace.union([
1220
1219
  z__namespace.object({
1221
1220
  platform: z__namespace.literal("x"),
1222
- post_type: z__namespace.enum([
1223
- "text",
1224
- "single_image",
1225
- "multi_image",
1226
- "video"
1227
- ]),
1228
1221
  settings: z__namespace.object({
1229
1222
  reply_settings: z__namespace.enum([
1230
1223
  "everyone",
@@ -1259,6 +1252,7 @@ var zPostVariant = z__namespace.union([
1259
1252
  }),
1260
1253
  id: z__namespace.string(),
1261
1254
  object: z__namespace.literal("post_variant"),
1255
+ post_type: zPostType.nullable(),
1262
1256
  connection_id: z__namespace.string().nullable(),
1263
1257
  body: z__namespace.string().nullable(),
1264
1258
  status: zPostVariantStatus,
@@ -1325,7 +1319,6 @@ var zPostVariant = z__namespace.union([
1325
1319
  "content_missing",
1326
1320
  "content_conflict",
1327
1321
  "content_incomplete",
1328
- "content_kind_mismatch",
1329
1322
  "media_type_mismatch",
1330
1323
  "tag_limit_exceeded",
1331
1324
  "reel_field_on_non_reel",
@@ -1409,23 +1402,8 @@ var zPostVariant = z__namespace.union([
1409
1402
  }),
1410
1403
  z__namespace.object({
1411
1404
  platform: z__namespace.literal("linkedin"),
1412
- post_type: z__namespace.enum([
1413
- "text",
1414
- "single_image",
1415
- "multi_image",
1416
- "video"
1417
- ]),
1418
1405
  settings: z__namespace.object({
1419
1406
  visibility: z__namespace.enum(["PUBLIC", "CONNECTIONS"]),
1420
- content_kind: z__namespace.enum([
1421
- "text",
1422
- "single_image",
1423
- "video",
1424
- "multi_image",
1425
- "document",
1426
- "article",
1427
- "poll"
1428
- ]),
1429
1407
  article: z__namespace.object({
1430
1408
  source: z__namespace.url(),
1431
1409
  title: z__namespace.string().max(400).optional(),
@@ -1454,6 +1432,7 @@ var zPostVariant = z__namespace.union([
1454
1432
  }),
1455
1433
  id: z__namespace.string(),
1456
1434
  object: z__namespace.literal("post_variant"),
1435
+ post_type: zPostType.nullable(),
1457
1436
  connection_id: z__namespace.string().nullable(),
1458
1437
  body: z__namespace.string().nullable(),
1459
1438
  status: zPostVariantStatus,
@@ -1520,7 +1499,6 @@ var zPostVariant = z__namespace.union([
1520
1499
  "content_missing",
1521
1500
  "content_conflict",
1522
1501
  "content_incomplete",
1523
- "content_kind_mismatch",
1524
1502
  "media_type_mismatch",
1525
1503
  "tag_limit_exceeded",
1526
1504
  "reel_field_on_non_reel",
@@ -1600,21 +1578,25 @@ var zPostVariant = z__namespace.union([
1600
1578
  position: z__namespace.int().gte(-9007199254740991).lte(9007199254740991),
1601
1579
  alt_text_override: z__namespace.string().nullable(),
1602
1580
  media: zMedia
1603
- }))
1604
- }),
1605
- z__namespace.object({
1606
- platform: z__namespace.literal("facebook_page"),
1607
- post_type: z__namespace.enum([
1581
+ })),
1582
+ content_kind: z__namespace.enum([
1608
1583
  "text",
1609
1584
  "single_image",
1585
+ "video",
1610
1586
  "multi_image",
1611
- "reel"
1612
- ]),
1587
+ "document",
1588
+ "article",
1589
+ "poll"
1590
+ ]).nullable()
1591
+ }),
1592
+ z__namespace.object({
1593
+ platform: z__namespace.literal("facebook_page"),
1613
1594
  settings: z__namespace.object({
1614
1595
  link: z__namespace.url().optional()
1615
1596
  }),
1616
1597
  id: z__namespace.string(),
1617
1598
  object: z__namespace.literal("post_variant"),
1599
+ post_type: zPostType.nullable(),
1618
1600
  connection_id: z__namespace.string().nullable(),
1619
1601
  body: z__namespace.string().nullable(),
1620
1602
  status: zPostVariantStatus,
@@ -1681,7 +1663,6 @@ var zPostVariant = z__namespace.union([
1681
1663
  "content_missing",
1682
1664
  "content_conflict",
1683
1665
  "content_incomplete",
1684
- "content_kind_mismatch",
1685
1666
  "media_type_mismatch",
1686
1667
  "tag_limit_exceeded",
1687
1668
  "reel_field_on_non_reel",
@@ -1765,17 +1746,7 @@ var zPostVariant = z__namespace.union([
1765
1746
  }),
1766
1747
  z__namespace.object({
1767
1748
  platform: z__namespace.literal("instagram"),
1768
- post_type: z__namespace.enum([
1769
- "single_image",
1770
- "carousel",
1771
- "reel"
1772
- ]),
1773
1749
  settings: z__namespace.object({
1774
- media_type: z__namespace.enum([
1775
- "IMAGE",
1776
- "CAROUSEL",
1777
- "REELS"
1778
- ]).optional(),
1779
1750
  location_id: z__namespace.string().optional(),
1780
1751
  user_tags: z__namespace.array(z__namespace.object({
1781
1752
  username: z__namespace.string().min(1),
@@ -1790,6 +1761,7 @@ var zPostVariant = z__namespace.union([
1790
1761
  }),
1791
1762
  id: z__namespace.string(),
1792
1763
  object: z__namespace.literal("post_variant"),
1764
+ post_type: zPostType.nullable(),
1793
1765
  connection_id: z__namespace.string().nullable(),
1794
1766
  body: z__namespace.string().nullable(),
1795
1767
  status: zPostVariantStatus,
@@ -1856,7 +1828,6 @@ var zPostVariant = z__namespace.union([
1856
1828
  "content_missing",
1857
1829
  "content_conflict",
1858
1830
  "content_incomplete",
1859
- "content_kind_mismatch",
1860
1831
  "media_type_mismatch",
1861
1832
  "tag_limit_exceeded",
1862
1833
  "reel_field_on_non_reel",
@@ -1936,15 +1907,15 @@ var zPostVariant = z__namespace.union([
1936
1907
  position: z__namespace.int().gte(-9007199254740991).lte(9007199254740991),
1937
1908
  alt_text_override: z__namespace.string().nullable(),
1938
1909
  media: zMedia
1939
- }))
1910
+ })),
1911
+ media_type: z__namespace.enum([
1912
+ "IMAGE",
1913
+ "CAROUSEL",
1914
+ "REELS"
1915
+ ]).nullable()
1940
1916
  }),
1941
1917
  z__namespace.object({
1942
1918
  platform: z__namespace.literal("tiktok"),
1943
- post_type: z__namespace.enum([
1944
- "video",
1945
- "single_image",
1946
- "carousel"
1947
- ]),
1948
1919
  settings: z__namespace.object({
1949
1920
  privacy_level: zTikTokPrivacyLevel.optional(),
1950
1921
  disable_comment: z__namespace.boolean().optional(),
@@ -1959,6 +1930,7 @@ var zPostVariant = z__namespace.union([
1959
1930
  }),
1960
1931
  id: z__namespace.string(),
1961
1932
  object: z__namespace.literal("post_variant"),
1933
+ post_type: zPostType.nullable(),
1962
1934
  connection_id: z__namespace.string().nullable(),
1963
1935
  body: z__namespace.string().nullable(),
1964
1936
  status: zPostVariantStatus,
@@ -2025,7 +1997,6 @@ var zPostVariant = z__namespace.union([
2025
1997
  "content_missing",
2026
1998
  "content_conflict",
2027
1999
  "content_incomplete",
2028
- "content_kind_mismatch",
2029
2000
  "media_type_mismatch",
2030
2001
  "tag_limit_exceeded",
2031
2002
  "reel_field_on_non_reel",
@@ -2150,12 +2121,6 @@ z__namespace.object({
2150
2121
  var zPostVariantInput = z__namespace.union([
2151
2122
  z__namespace.object({
2152
2123
  platform: z__namespace.literal("x"),
2153
- post_type: z__namespace.enum([
2154
- "text",
2155
- "single_image",
2156
- "multi_image",
2157
- "video"
2158
- ]),
2159
2124
  settings: z__namespace.object({
2160
2125
  reply_settings: z__namespace.enum([
2161
2126
  "everyone",
@@ -2197,23 +2162,8 @@ var zPostVariantInput = z__namespace.union([
2197
2162
  }),
2198
2163
  z__namespace.object({
2199
2164
  platform: z__namespace.literal("linkedin"),
2200
- post_type: z__namespace.enum([
2201
- "text",
2202
- "single_image",
2203
- "multi_image",
2204
- "video"
2205
- ]),
2206
2165
  settings: z__namespace.object({
2207
2166
  visibility: z__namespace.enum(["PUBLIC", "CONNECTIONS"]),
2208
- content_kind: z__namespace.enum([
2209
- "text",
2210
- "single_image",
2211
- "video",
2212
- "multi_image",
2213
- "document",
2214
- "article",
2215
- "poll"
2216
- ]),
2217
2167
  article: z__namespace.object({
2218
2168
  source: z__namespace.url(),
2219
2169
  title: z__namespace.string().max(400).optional(),
@@ -2249,17 +2199,7 @@ var zPostVariantInput = z__namespace.union([
2249
2199
  }),
2250
2200
  z__namespace.object({
2251
2201
  platform: z__namespace.literal("instagram"),
2252
- post_type: z__namespace.enum([
2253
- "single_image",
2254
- "carousel",
2255
- "reel"
2256
- ]),
2257
2202
  settings: z__namespace.object({
2258
- media_type: z__namespace.enum([
2259
- "IMAGE",
2260
- "CAROUSEL",
2261
- "REELS"
2262
- ]).optional(),
2263
2203
  location_id: z__namespace.string().optional(),
2264
2204
  user_tags: z__namespace.array(z__namespace.object({
2265
2205
  username: z__namespace.string().min(1),
@@ -2281,12 +2221,6 @@ var zPostVariantInput = z__namespace.union([
2281
2221
  }),
2282
2222
  z__namespace.object({
2283
2223
  platform: z__namespace.literal("facebook_page"),
2284
- post_type: z__namespace.enum([
2285
- "text",
2286
- "single_image",
2287
- "multi_image",
2288
- "reel"
2289
- ]),
2290
2224
  settings: z__namespace.object({
2291
2225
  link: z__namespace.url().optional()
2292
2226
  }).optional().default({}),
@@ -2299,11 +2233,6 @@ var zPostVariantInput = z__namespace.union([
2299
2233
  }),
2300
2234
  z__namespace.object({
2301
2235
  platform: z__namespace.literal("tiktok"),
2302
- post_type: z__namespace.enum([
2303
- "video",
2304
- "single_image",
2305
- "carousel"
2306
- ]),
2307
2236
  settings: z__namespace.object({
2308
2237
  privacy_level: zTikTokPrivacyLevel.optional(),
2309
2238
  disable_comment: z__namespace.boolean().optional(),
@@ -2331,7 +2260,7 @@ z__namespace.object({
2331
2260
  "schedule",
2332
2261
  "draft"
2333
2262
  ]).optional().default("draft"),
2334
- schedule_at: z__namespace.iso.datetime().optional(),
2263
+ schedule_at: z__namespace.iso.datetime({ offset: true }).optional(),
2335
2264
  external_id: z__namespace.string().min(1).max(255).optional(),
2336
2265
  metadata: z__namespace.record(z__namespace.string(), z__namespace.union([
2337
2266
  z__namespace.string().max(500),
@@ -2998,7 +2927,7 @@ var zGoogleAdsConversionUserIdentifier = z__namespace.object({
2998
2927
  }).optional()
2999
2928
  });
3000
2929
  var zGoogleAdsConversionEvent = z__namespace.object({
3001
- event_timestamp: z__namespace.iso.datetime(),
2930
+ event_timestamp: z__namespace.iso.datetime({ offset: true }),
3002
2931
  event_source: z__namespace.enum([
3003
2932
  "WEB",
3004
2933
  "APP",
@@ -3081,7 +3010,6 @@ var zGoogleAdsConversionStatusReason = z__namespace.object({
3081
3010
  "content_missing",
3082
3011
  "content_conflict",
3083
3012
  "content_incomplete",
3084
- "content_kind_mismatch",
3085
3013
  "media_type_mismatch",
3086
3014
  "tag_limit_exceeded",
3087
3015
  "reel_field_on_non_reel",
@@ -3578,9 +3506,9 @@ z__namespace.object({
3578
3506
  z__namespace.number(),
3579
3507
  z__namespace.boolean()
3580
3508
  ])).optional(),
3581
- scheduled_after: z__namespace.iso.datetime().optional(),
3582
- scheduled_before: z__namespace.iso.datetime().optional(),
3583
- updated_after: z__namespace.iso.datetime().optional(),
3509
+ scheduled_after: z__namespace.iso.datetime({ offset: true }).optional(),
3510
+ scheduled_before: z__namespace.iso.datetime({ offset: true }).optional(),
3511
+ updated_after: z__namespace.iso.datetime({ offset: true }).optional(),
3584
3512
  status: z__namespace.array(zPostStatus).optional()
3585
3513
  });
3586
3514
  z__namespace.object({
@@ -3638,7 +3566,7 @@ z__namespace.object({
3638
3566
  "schedule",
3639
3567
  "draft"
3640
3568
  ]).optional(),
3641
- schedule_at: z__namespace.iso.datetime().nullish(),
3569
+ schedule_at: z__namespace.iso.datetime({ offset: true }).nullish(),
3642
3570
  external_id: z__namespace.string().min(1).max(255).nullish(),
3643
3571
  metadata: z__namespace.record(z__namespace.string(), z__namespace.union([
3644
3572
  z__namespace.string().max(500),
@@ -3747,7 +3675,6 @@ z__namespace.object({
3747
3675
  "content_missing",
3748
3676
  "content_conflict",
3749
3677
  "content_incomplete",
3750
- "content_kind_mismatch",
3751
3678
  "media_type_mismatch",
3752
3679
  "tag_limit_exceeded",
3753
3680
  "reel_field_on_non_reel",
@@ -5308,8 +5235,8 @@ z__namespace.object({
5308
5235
  "scheduler"
5309
5236
  ]).optional(),
5310
5237
  action: z__namespace.string().min(1).optional(),
5311
- created_after: z__namespace.iso.datetime().optional(),
5312
- created_before: z__namespace.iso.datetime().optional()
5238
+ created_after: z__namespace.iso.datetime({ offset: true }).optional(),
5239
+ created_before: z__namespace.iso.datetime({ offset: true }).optional()
5313
5240
  });
5314
5241
  z__namespace.object({
5315
5242
  object: z__namespace.literal("list"),
@@ -5399,7 +5326,6 @@ z__namespace.object({
5399
5326
  "content_missing",
5400
5327
  "content_conflict",
5401
5328
  "content_incomplete",
5402
- "content_kind_mismatch",
5403
5329
  "media_type_mismatch",
5404
5330
  "tag_limit_exceeded",
5405
5331
  "reel_field_on_non_reel",
@@ -5559,7 +5485,6 @@ z__namespace.object({
5559
5485
  "content_missing",
5560
5486
  "content_conflict",
5561
5487
  "content_incomplete",
5562
- "content_kind_mismatch",
5563
5488
  "media_type_mismatch",
5564
5489
  "tag_limit_exceeded",
5565
5490
  "reel_field_on_non_reel",
@@ -5740,7 +5665,6 @@ z__namespace.object({
5740
5665
  "content_missing",
5741
5666
  "content_conflict",
5742
5667
  "content_incomplete",
5743
- "content_kind_mismatch",
5744
5668
  "media_type_mismatch",
5745
5669
  "tag_limit_exceeded",
5746
5670
  "reel_field_on_non_reel",
@@ -5900,7 +5824,6 @@ z__namespace.object({
5900
5824
  "content_missing",
5901
5825
  "content_conflict",
5902
5826
  "content_incomplete",
5903
- "content_kind_mismatch",
5904
5827
  "media_type_mismatch",
5905
5828
  "tag_limit_exceeded",
5906
5829
  "reel_field_on_non_reel",
@@ -7975,30 +7898,9 @@ var ComposeError = class extends Error {
7975
7898
  this.name = "ComposeError";
7976
7899
  }
7977
7900
  };
7978
- function countKinds(media) {
7979
- let images = 0;
7980
- let videos = 0;
7981
- let documents = 0;
7982
- for (const item of media) {
7983
- if (item.kind === "video") videos += 1;
7984
- else if (item.kind === "document") documents += 1;
7985
- else images += 1;
7986
- }
7987
- return { images, videos, documents };
7988
- }
7989
- function deriveSinglePlacement(media, videoType) {
7990
- const { images, videos } = countKinds(media);
7991
- if (videos >= 1) return videoType;
7992
- return images >= 2 ? "multi_image" : "single_image";
7993
- }
7994
7901
  var xHandler = {
7995
- derivePostType: (media) => {
7996
- if (media.length === 0) return "text";
7997
- return deriveSinglePlacement(media, "video");
7998
- },
7999
- buildVariant: ({ settings, postType, connectionId, body, media }) => ({
7902
+ buildVariant: ({ settings, connectionId, body, media }) => ({
8000
7903
  platform: "x",
8001
- post_type: postType,
8002
7904
  connection_id: connectionId,
8003
7905
  body,
8004
7906
  media: [...media],
@@ -8006,16 +7908,8 @@ var xHandler = {
8006
7908
  })
8007
7909
  };
8008
7910
  var linkedInHandler = {
8009
- derivePostType: (media) => {
8010
- if (media.length === 0) return "text";
8011
- if (countKinds(media).documents > 0) {
8012
- return "single_image";
8013
- }
8014
- return deriveSinglePlacement(media, "video");
8015
- },
8016
- buildVariant: ({ settings, postType, connectionId, body, media }) => ({
7911
+ buildVariant: ({ settings, connectionId, body, media }) => ({
8017
7912
  platform: "linkedin",
8018
- post_type: postType,
8019
7913
  connection_id: connectionId,
8020
7914
  body,
8021
7915
  media: [...media],
@@ -8023,13 +7917,8 @@ var linkedInHandler = {
8023
7917
  })
8024
7918
  };
8025
7919
  var facebookHandler = {
8026
- derivePostType: (media) => {
8027
- if (media.length === 0) return "text";
8028
- return deriveSinglePlacement(media, "reel");
8029
- },
8030
- buildVariant: ({ settings, postType, connectionId, body, media }) => ({
7920
+ buildVariant: ({ settings, connectionId, body, media }) => ({
8031
7921
  platform: "facebook_page",
8032
- post_type: postType,
8033
7922
  connection_id: connectionId,
8034
7923
  body,
8035
7924
  media: [...media],
@@ -8037,13 +7926,8 @@ var facebookHandler = {
8037
7926
  })
8038
7927
  };
8039
7928
  var instagramHandler = {
8040
- derivePostType: (media) => {
8041
- if (media.length >= 2) return "carousel";
8042
- return countKinds(media).videos === 1 ? "reel" : "single_image";
8043
- },
8044
- buildVariant: ({ settings, postType, connectionId, body, media }) => ({
7929
+ buildVariant: ({ settings, connectionId, body, media }) => ({
8045
7930
  platform: "instagram",
8046
- post_type: postType,
8047
7931
  connection_id: connectionId,
8048
7932
  body,
8049
7933
  media: [...media],
@@ -8051,14 +7935,8 @@ var instagramHandler = {
8051
7935
  })
8052
7936
  };
8053
7937
  var tiktokHandler = {
8054
- derivePostType: (media) => {
8055
- const { images, videos } = countKinds(media);
8056
- if (videos >= 1) return "video";
8057
- return images >= 2 ? "carousel" : "single_image";
8058
- },
8059
- buildVariant: ({ settings, postType, connectionId, body, media }) => ({
7938
+ buildVariant: ({ settings, connectionId, body, media }) => ({
8060
7939
  platform: "tiktok",
8061
- post_type: postType,
8062
7940
  connection_id: connectionId,
8063
7941
  body,
8064
7942
  media: [...media],
@@ -8090,7 +7968,6 @@ function buildChannel(handler, platform, config, content, connections) {
8090
7968
  const media = config.media ?? content.media ?? [];
8091
7969
  return handler.buildVariant({
8092
7970
  settings: config.settings,
8093
- postType: config.postType ?? handler.derivePostType(media),
8094
7971
  connectionId: resolveConnectionId(platform, config.connectionId, connections),
8095
7972
  body: config.body ?? content.body,
8096
7973
  media: media.map((item) => ({ media_id: item.id }))