@pubnio/sdk 0.2.13 → 0.4.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/solid.js CHANGED
@@ -139,6 +139,7 @@ __export(exports_sdk_gen, {
139
139
  postsRetry: () => postsRetry,
140
140
  postsUpdate: () => postsUpdate,
141
141
  postsValidate: () => postsValidate,
142
+ postsValidateBody: () => postsValidateBody,
142
143
  profileDeactivate: () => profileDeactivate,
143
144
  profileGet: () => profileGet,
144
145
  profileUpdate: () => profileUpdate,
@@ -355,6 +356,8 @@ var IssueCode = Schema6.Literals([
355
356
  "tiktok_upload_required",
356
357
  "tiktok_too_many_mentions",
357
358
  "queue_and_time_conflict",
359
+ "queue_not_found",
360
+ "queue_unavailable",
358
361
  "invalid_field",
359
362
  "account_ambiguous",
360
363
  "unsupported_placement",
@@ -365,8 +368,9 @@ var IssueCode = Schema6.Literals([
365
368
  var PostIssue = Schema6.Struct({
366
369
  code: IssueCode,
367
370
  path: Schema6.Array(Schema6.Union([Schema6.String, Schema6.Int])),
368
- message: Schema6.String
369
- });
371
+ message: Schema6.String,
372
+ candidates: Schema6.optionalKey(Schema6.Array(Schema6.Struct({ accountId: AccountId, name: Schema6.String })))
373
+ }).annotate({ identifier: "PostIssue" });
370
374
  var schemaIssueFormatter = SchemaIssue.makeFormatterStandardSchemaV1();
371
375
 
372
376
  // ../protocol/src/provider.ts
@@ -468,18 +472,22 @@ var PublishPlacement = Schema8.Literals([
468
472
  var ScheduleOverride = Schema8.Union([ScheduledAt, Schema8.Null]);
469
473
  var DestinationSelection = Schema8.Struct({
470
474
  accountId: AccountId,
471
- placement: PublishPlacement,
475
+ placement: Schema8.optionalKey(PublishPlacement).annotate({
476
+ description: "Omit to select the draft's only destination for this account."
477
+ }),
472
478
  scheduledAt: Schema8.optionalKey(ScheduleOverride),
473
479
  queueId: Schema8.optionalKey(uuid2)
474
480
  }).annotate({ identifier: "DestinationSelection" });
475
481
  var PublishInput = Schema8.Struct({
476
- expectedRevision: PublishRevision,
482
+ expectedRevision: Schema8.optionalKey(PublishRevision).annotate({
483
+ description: "Publish only if the draft is still at this revision. Omit to publish the saved draft as it is."
484
+ }),
477
485
  scheduledAt: Schema8.optionalKey(ScheduledAt),
478
- accountIds: Schema8.optionalKey(Schema8.Array(AccountId).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
486
+ accounts: Schema8.optionalKey(Schema8.Array(AccountId).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
479
487
  description: "Select every draft placement for these accounts. Use targets for exact selection instead."
480
488
  })),
481
489
  targets: Schema8.optionalKey(Schema8.Array(DestinationSelection).check(Schema8.isMinLength(1), Schema8.isMaxLength(50)).annotate({
482
- description: "Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."
490
+ description: "Select exact draft destinations and optionally override each schedule. Omit accounts when using targets."
483
491
  }))
484
492
  });
485
493
  var PostRef = Schema8.Struct({ postId: PostId });
@@ -583,7 +591,10 @@ var DeliveryIssue = Schema8.Literals([
583
591
  "tiktok_settings_not_allowed",
584
592
  "tiktok_processing_failed",
585
593
  "submission_uncertain",
586
- "confirmation_unavailable"
594
+ "confirmation_unavailable",
595
+ "billing_inactive",
596
+ "spend_cap_reached",
597
+ "insufficient_credit"
587
598
  ]);
588
599
  var FirstCommentStatus = Schema8.Literals([
589
600
  "pending",
@@ -682,6 +693,7 @@ var BillingSubscriptionStatus = Schema9.Literals([
682
693
  var UsageMeter = Schema9.Literals([
683
694
  "confirmed_publish",
684
695
  "x_passthrough",
696
+ "x_read",
685
697
  "managed_ad",
686
698
  "inbox_reply",
687
699
  "automation_run"
@@ -698,10 +710,15 @@ var BillingPlan = Schema9.Struct({
698
710
  monthlyPrice: Schema9.NullOr(Money),
699
711
  annualPrice: Schema9.NullOr(Money),
700
712
  meters: Schema9.Array(BillingPlanMeter),
713
+ xReads: Schema9.Boolean,
714
+ includedXReadMicros: Schema9.NullOr(Schema9.Int),
701
715
  seatsLimit: Schema9.NullOr(Schema9.Int),
702
716
  analyticsRetentionDays: Schema9.Int,
703
717
  whiteLabelOAuth: Schema9.Boolean,
704
- ssoSaml: Schema9.Boolean
718
+ ssoSaml: Schema9.Boolean,
719
+ priorityQueue: Schema9.Boolean,
720
+ adsInsights: Schema9.Boolean,
721
+ adsWrite: Schema9.Boolean
705
722
  }).annotate({ identifier: "BillingPlan" });
706
723
  var BillingPlanList = Schema9.Struct({
707
724
  data: Schema9.Array(BillingPlan)
@@ -737,6 +754,8 @@ var WorkspaceBilling = Schema9.Struct({
737
754
  creditBalance: Money,
738
755
  spendControls: BillingSpendControls,
739
756
  currentPeriod: Schema9.Struct({
757
+ start: Schema9.String,
758
+ end: Schema9.String,
740
759
  meters: Schema9.Array(BillingMeterUsage),
741
760
  totalVariableSpendMicros: Schema9.Int,
742
761
  seatsUsed: Schema9.Int,
@@ -1878,7 +1897,51 @@ var ApiLimits = Schema15.Struct({
1878
1897
  media: MediaLimits,
1879
1898
  rateLimits: RateLimits
1880
1899
  }).annotate({ identifier: "ApiLimits" });
1900
+ var pollOptionCount = { minOptions: 2, maxOptions: 4 };
1901
+ var xPollLimits = {
1902
+ ...pollOptionCount,
1903
+ optionCharacters: 25,
1904
+ minDurationMinutes: 5,
1905
+ maxDurationMinutes: 10080
1906
+ };
1907
+ var linkedinPollLimits = {
1908
+ ...pollOptionCount,
1909
+ questionCharacters: 140,
1910
+ optionCharacters: 30,
1911
+ durations: ["ONE_DAY", "THREE_DAYS", "SEVEN_DAYS", "FOURTEEN_DAYS"]
1912
+ };
1913
+ var xReplySettings = [
1914
+ "following",
1915
+ "mentionedUsers",
1916
+ "subscribers",
1917
+ "verified"
1918
+ ];
1919
+ var xMediaTagLimit = 10;
1920
+ var pollOptionLimits = {
1921
+ minOptions: Schema15.Int,
1922
+ maxOptions: Schema15.Int,
1923
+ optionCharacters: Schema15.Int
1924
+ };
1925
+ var FeedSettingsCapability = Schema15.Struct({
1926
+ poll: Schema15.Union([
1927
+ Schema15.Struct({
1928
+ ...pollOptionLimits,
1929
+ minDurationMinutes: Schema15.Int,
1930
+ maxDurationMinutes: Schema15.Int
1931
+ }),
1932
+ Schema15.Struct({
1933
+ ...pollOptionLimits,
1934
+ questionCharacters: Schema15.Int,
1935
+ durations: Schema15.Array(Schema15.Literals(linkedinPollLimits.durations))
1936
+ })
1937
+ ]),
1938
+ replySettings: Schema15.optionalKey(Schema15.Array(Schema15.Literals(xReplySettings))),
1939
+ maxMediaTags: Schema15.optionalKey(Schema15.Int),
1940
+ placeId: Schema15.optionalKey(Schema15.Boolean),
1941
+ quotePostId: Schema15.optionalKey(Schema15.Boolean)
1942
+ });
1881
1943
  var PlacementCapability = Schema15.Struct({
1944
+ settings: Schema15.optionalKey(FeedSettingsCapability),
1882
1945
  placement: PublishPlacement,
1883
1946
  default: Schema15.Boolean,
1884
1947
  mediaTypes: Schema15.Array(MediaType),
@@ -2249,9 +2312,14 @@ var InstagramAudioSearch = Schema17.Struct({
2249
2312
  import { Schema as Schema28 } from "effect";
2250
2313
 
2251
2314
  // ../protocol/src/publishing.ts
2252
- import { Schema as Schema18 } from "effect";
2315
+ import { Effect, Schema as Schema18 } from "effect";
2253
2316
  var postTextLimit = 128000;
2254
2317
  var threadPostTextLimit = 1250;
2318
+ var blueskyPostMaxBytes = 3000;
2319
+ var graphemeSegmenter = new Intl.Segmenter(undefined, {
2320
+ granularity: "grapheme"
2321
+ });
2322
+ var utf8 = new TextEncoder;
2255
2323
  var redditTitleMaxLength = 300;
2256
2324
  var threadsTextLimit = 500;
2257
2325
  var xArticleTitleMaxLength = 100;
@@ -2359,12 +2427,34 @@ var InstagramStorySettings = Schema18.Struct({
2359
2427
  muteAudio: Schema18.optionalKey(Schema18.Boolean),
2360
2428
  userTags: instagramTags
2361
2429
  }).annotate({ identifier: "InstagramStorySettings" });
2430
+ var blueskyPostText = Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(blueskyPostMaxBytes));
2362
2431
  var BlueskyFeedSettings = Schema18.Struct({
2363
- firstComment: Schema18.optionalKey(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(300))),
2364
- thread: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(300))).check(Schema18.isMaxLength(24))),
2432
+ firstComment: Schema18.optionalKey(blueskyPostText),
2433
+ thread: Schema18.optionalKey(Schema18.Array(blueskyPostText).check(Schema18.isMaxLength(24))),
2365
2434
  altText: Schema18.optionalKey(Schema18.String.check(Schema18.isMaxLength(1000)))
2366
2435
  }).annotate({ identifier: "BlueskyFeedSettings" });
2436
+ var nonblank = Schema18.makeFilter((value) => value.trim().length > 0 || "Supply a nonblank string.", { toJsonSchema: () => ({ pattern: "\\S" }) });
2437
+ function pollText(maximum) {
2438
+ return Schema18.String.check(Schema18.isBetweenCodePoints(1, maximum, {
2439
+ expected: `between 1 and ${maximum} characters`
2440
+ }), nonblank);
2441
+ }
2442
+ function pollOptions({
2443
+ minOptions,
2444
+ maxOptions,
2445
+ optionCharacters
2446
+ }) {
2447
+ return Schema18.Array(pollText(optionCharacters)).check(Schema18.isMinLength(minOptions), Schema18.isMaxLength(maxOptions));
2448
+ }
2449
+ var LinkedInPoll = Schema18.Struct({
2450
+ question: pollText(linkedinPollLimits.questionCharacters),
2451
+ options: pollOptions(linkedinPollLimits),
2452
+ duration: Schema18.Literals(linkedinPollLimits.durations)
2453
+ }).annotate({
2454
+ description: "Organic LinkedIn poll. Include post text and omit media, altText, and documentTitle."
2455
+ });
2367
2456
  var LinkedInFeedSettings = Schema18.Struct({
2457
+ poll: Schema18.optionalKey(LinkedInPoll),
2368
2458
  firstComment: Schema18.optionalKey(text),
2369
2459
  thread: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(threadPostTextLimit))).check(Schema18.isMaxLength(24))),
2370
2460
  visibility: Schema18.optionalKey(Schema18.Literals(["PUBLIC", "CONNECTIONS"])),
@@ -2401,6 +2491,7 @@ var YouTubeVideoSettings = Schema18.Struct({
2401
2491
  title: Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(100)),
2402
2492
  description: Schema18.optionalKey(Schema18.String.check(Schema18.isMaxLength(5000))),
2403
2493
  privacyStatus: Schema18.Literals(["public", "unlisted", "private"]),
2494
+ firstComment: Schema18.optionalKey(text),
2404
2495
  tags: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMaxLength(100))).check(Schema18.isMaxLength(30))),
2405
2496
  categoryId: Schema18.optionalKey(Schema18.String.check(Schema18.isPattern(/^\d{1,3}$/))),
2406
2497
  madeForKids: Schema18.optionalKey(Schema18.Boolean),
@@ -2415,14 +2506,66 @@ var XArticleDraftSettings = Schema18.Struct({
2415
2506
  title: Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(xArticleTitleMaxLength)),
2416
2507
  content: Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(xArticleContentMaxLength))
2417
2508
  }).annotate({ identifier: "XArticleDraftSettings" });
2509
+ var XPoll = Schema18.Struct({
2510
+ options: pollOptions(xPollLimits),
2511
+ durationMinutes: Schema18.Number.check(Schema18.isInt({ expected: "an integer number of minutes" }), Schema18.isBetween({
2512
+ minimum: xPollLimits.minDurationMinutes,
2513
+ maximum: xPollLimits.maxDurationMinutes
2514
+ }, {
2515
+ expected: `between ${xPollLimits.minDurationMinutes} and ${xPollLimits.maxDurationMinutes} minutes`
2516
+ }))
2517
+ }).annotate({
2518
+ description: "X poll on the root post. Include post text and omit attachments."
2519
+ });
2520
+ var xPostOptionId = Schema18.String.check(Schema18.isPattern(/^[0-9]{1,19}$/, {
2521
+ expected: "an X ID string of 1 to 19 digits"
2522
+ }));
2418
2523
  var XFeedSettings = Schema18.Struct({
2524
+ poll: Schema18.optionalKey(XPoll),
2525
+ replySettings: Schema18.optionalKey(Schema18.Literals(xReplySettings).annotate({
2526
+ description: "Who may reply to the root X post. Omit for the provider default."
2527
+ })),
2528
+ quotePostId: Schema18.optionalKey(xPostOptionId.annotate({
2529
+ description: "Native quotes require an X Enterprise app. With PubNio's current app, omit this field and put the X post URL in the text."
2530
+ })),
2531
+ mediaTaggedUserIds: Schema18.optionalKey(Schema18.Array(xPostOptionId).check(Schema18.isMaxLength(xMediaTagLimit)).annotate({
2532
+ description: "X user ID strings to tag on root post photos (JPEG, PNG, or WebP)."
2533
+ })),
2534
+ placeId: Schema18.optionalKey(Schema18.String.check(Schema18.isTrimmed({
2535
+ expected: "an X Place ID without surrounding whitespace"
2536
+ }), nonblank).annotate({
2537
+ description: "Opaque X Place ID such as geo.place_id from a post lookup."
2538
+ })),
2419
2539
  firstComment: Schema18.optionalKey(text),
2420
- thread: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(280))).check(Schema18.isMaxLength(24))),
2540
+ thread: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(threadPostTextLimit))).check(Schema18.isMaxLength(24))),
2421
2541
  article: Schema18.optionalKey(XArticleDraftSettings)
2422
2542
  }).annotate({ identifier: "XFeedSettings" });
2423
- var GoogleBusinessFeedSettings = Schema18.Struct({}).annotate({
2424
- identifier: "GoogleBusinessFeedSettings"
2425
- });
2543
+ var googleBusinessLocalTimeFormat = "Use a valid location-local date and time in YYYY-MM-DDTHH:MM format.";
2544
+ var googleBusinessLocalTime = Schema18.String.check(Schema18.isPattern(/^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):[0-5][0-9]$/, {
2545
+ message: googleBusinessLocalTimeFormat
2546
+ }), Schema18.makeFilter((value) => {
2547
+ const year = Number(value.slice(0, 4));
2548
+ const date = new Date(`${value}:00Z`);
2549
+ return year > 0 && date.getUTCMonth() + 1 === Number(value.slice(5, 7)) && date.getUTCDate() === Number(value.slice(8, 10)) || googleBusinessLocalTimeFormat;
2550
+ })).annotate({ description: googleBusinessLocalTimeFormat });
2551
+ var googleBusinessNonblank = Schema18.String.check(Schema18.isPattern(/\S/, {
2552
+ message: "Enter a string with non-whitespace content."
2553
+ }));
2554
+ var googleBusinessLink = MediaUrl.annotate({
2555
+ description: "Use an HTTPS URL of at most 2,048 characters without embedded credentials.",
2556
+ message: "Use an HTTPS URL of at most 2,048 characters without embedded credentials."
2557
+ });
2558
+ var GoogleBusinessFeedSettings = Schema18.Struct({
2559
+ topicType: Schema18.optionalKey(Schema18.Literals(["standard", "event", "offer"])),
2560
+ title: Schema18.optionalKey(googleBusinessNonblank),
2561
+ startsAt: Schema18.optionalKey(googleBusinessLocalTime),
2562
+ endsAt: Schema18.optionalKey(googleBusinessLocalTime),
2563
+ couponCode: Schema18.optionalKey(googleBusinessNonblank),
2564
+ redeemUrl: Schema18.optionalKey(googleBusinessLink),
2565
+ terms: Schema18.optionalKey(googleBusinessNonblank),
2566
+ callToAction: Schema18.optionalKey(Schema18.Literals(["book", "order", "shop", "learn_more", "sign_up", "call"])),
2567
+ callToActionUrl: Schema18.optionalKey(googleBusinessLink)
2568
+ }).annotate({ identifier: "GoogleBusinessFeedSettings" });
2426
2569
  var ThreadsFeedSettings = Schema18.Struct({
2427
2570
  firstComment: Schema18.optionalKey(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(threadsTextLimit))),
2428
2571
  thread: Schema18.optionalKey(Schema18.Array(Schema18.String.check(Schema18.isMinLength(1), Schema18.isMaxLength(threadsTextLimit))).check(Schema18.isMaxLength(24)))
@@ -2601,6 +2744,41 @@ var providerSettings = Schema18.Union([
2601
2744
  TikTokFeedSettings,
2602
2745
  GoogleBusinessFeedSettings
2603
2746
  ]);
2747
+ function settingsShapeErrors(issue, depth = 0) {
2748
+ switch (issue._tag) {
2749
+ case "Composite":
2750
+ return issue.issues.reduce((count, child) => count + settingsShapeErrors(child, depth), 0);
2751
+ case "AnyOf":
2752
+ return issue.issues.length === 0 ? 0 : Math.min(...issue.issues.map((child) => settingsShapeErrors(child, depth)));
2753
+ case "Pointer":
2754
+ return settingsShapeErrors(issue.issue, depth + issue.path.length);
2755
+ case "UnexpectedKey":
2756
+ return depth === 1 ? 3 : 2;
2757
+ case "MissingKey":
2758
+ return depth === 1 ? 4 : 1;
2759
+ default:
2760
+ return 0;
2761
+ }
2762
+ }
2763
+ var createTargetSettings = providerSettings.pipe(Schema18.catchDecoding((issue) => {
2764
+ if (issue._tag !== "AnyOf")
2765
+ return Effect.fail(issue);
2766
+ const [first, ...others] = issue.issues;
2767
+ if (!first)
2768
+ return Effect.fail(issue);
2769
+ let closest = first;
2770
+ let fewest = settingsShapeErrors(first);
2771
+ for (const candidate of others) {
2772
+ if (fewest === 0)
2773
+ break;
2774
+ const errors = settingsShapeErrors(candidate);
2775
+ if (errors < fewest) {
2776
+ closest = candidate;
2777
+ fewest = errors;
2778
+ }
2779
+ }
2780
+ return Effect.fail(closest);
2781
+ }));
2604
2782
  var CreatePostTarget = Schema18.Struct({
2605
2783
  accountId: AccountId,
2606
2784
  provider: Schema18.optionalKey(Provider),
@@ -2612,29 +2790,26 @@ var CreatePostTarget = Schema18.Struct({
2612
2790
  queueId: Schema18.optionalKey(Schema18.String.check(Schema18.isUUID()).annotate({
2613
2791
  description: "Assign this destination to its connected account's schedule queue."
2614
2792
  })),
2615
- settings: Schema18.optionalKey(providerSettings)
2793
+ settings: Schema18.optionalKey(createTargetSettings)
2616
2794
  }).annotate({ identifier: "CreatePostTarget" });
2617
2795
  var postText = Schema18.Trim.check(Schema18.isMaxLength(postTextLimit)).pipe(Schema18.annotateEncoded({
2618
2796
  description: `At most ${postTextLimit} characters after trimming.`
2619
2797
  }));
2620
2798
  var postTargets = Schema18.Array(PublishTarget).check(Schema18.isMaxLength(50));
2621
- var postContent = {
2799
+ var PostContent = Schema18.Struct({
2622
2800
  text: Schema18.optionalKey(postText),
2623
2801
  targets: Schema18.optionalKey(postTargets),
2624
- media: Schema18.optionalKey(MediaInputs)
2625
- };
2626
- var PostContent = Schema18.Struct(postContent).annotate({
2627
- identifier: "PostContent"
2628
- });
2629
- var PostPreflight = Schema18.Struct({
2630
- ...postContent,
2802
+ media: Schema18.optionalKey(MediaInputs),
2631
2803
  scheduledAt: Schema18.optionalKey(ScheduledAt)
2632
- }).annotate({ identifier: "PostPreflight" });
2633
- var CreatePost = Schema18.Struct({
2634
- text: Schema18.optionalKey(postText),
2804
+ }).annotate({ identifier: "PostContent" });
2805
+ var destinationSelectors = {
2635
2806
  platforms: Schema18.optionalKey(Schema18.Array(Provider).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2636
2807
  accounts: Schema18.optionalKey(Schema18.Array(AccountId).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2637
- targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit))),
2808
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMinLength(1), Schema18.isMaxLength(publishTargetLimit)))
2809
+ };
2810
+ var CreatePost = Schema18.Struct({
2811
+ text: Schema18.optionalKey(postText),
2812
+ ...destinationSelectors,
2638
2813
  media: Schema18.optionalKey(MediaInputs),
2639
2814
  scheduledAt: Schema18.optionalKey(ScheduledAt),
2640
2815
  publishNow: Schema18.optionalKey(Schema18.Boolean),
@@ -2642,12 +2817,18 @@ var CreatePost = Schema18.Struct({
2642
2817
  description: "Save the post as a draft without submitting it. Defaults to false."
2643
2818
  })
2644
2819
  }).annotate({ identifier: "CreatePost" }).annotate({
2645
- description: "Send exactly one selector for a direct post: platforms resolves the single ready account per provider, accounts selects exact account IDs, and targets selects exact destinations. Provider and placement are derived when omitted. publishNow defaults to true when scheduledAt is absent. Set isDraft to true to save a draft without submitting; drafts accept text, media, and targets."
2820
+ description: "Send one selector: platforms, accounts, or targets. scheduledAt is the default time; targets[].scheduledAt overrides it per destination. isDraft saves the same body without submitting."
2646
2821
  });
2647
2822
  var UpdatePost = Schema18.Struct({
2648
- ...postContent,
2823
+ text: Schema18.optionalKey(postText),
2824
+ media: Schema18.optionalKey(MediaInputs),
2825
+ scheduledAt: Schema18.optionalKey(ScheduleOverride),
2826
+ ...destinationSelectors,
2827
+ targets: Schema18.optionalKey(Schema18.Array(CreatePostTarget).check(Schema18.isMaxLength(publishTargetLimit))),
2649
2828
  expectedRevision: Schema18.optionalKey(revision)
2650
- }).annotate({ identifier: "UpdatePost" });
2829
+ }).annotate({ identifier: "UpdatePost" }).annotate({
2830
+ description: "Edit a draft with the same fields as create. scheduledAt sets the default time; null clears it. One selector (platforms, accounts, or targets) replaces the saved targets; an empty targets array removes them."
2831
+ });
2651
2832
  var Post = Schema18.Struct({
2652
2833
  postId: PostId,
2653
2834
  isDraft: Schema18.Boolean,
@@ -2655,6 +2836,9 @@ var Post = Schema18.Struct({
2655
2836
  text: postText,
2656
2837
  media: MediaInputs,
2657
2838
  targets: postTargets,
2839
+ scheduledAt: Schema18.NullOr(ScheduledAt).annotate({
2840
+ description: "The default time for targets without their own scheduledAt. null publishes them when submitted."
2841
+ }),
2658
2842
  deliveries: Schema18.Array(DeliveryStatus),
2659
2843
  status: PostState,
2660
2844
  createdAt: Schema18.String,
@@ -3304,6 +3488,31 @@ var InboxReviewList = Schema21.Struct({
3304
3488
  var InboxUnreadCount = Schema21.Struct({
3305
3489
  unreadCount: Schema21.Int
3306
3490
  }).annotate({ identifier: "InboxUnreadCount" });
3491
+ var InboxUnavailableReason = Schema21.Literals([
3492
+ "provider_subscription_limit",
3493
+ "missing_scopes",
3494
+ "webhook_invalid",
3495
+ "subscription_pending",
3496
+ "plan_required",
3497
+ "insufficient_credit",
3498
+ "spend_cap_reached"
3499
+ ]);
3500
+ var InboxUnavailableState = Schema21.Struct({
3501
+ reason: InboxUnavailableReason,
3502
+ action: Schema21.Literals([
3503
+ "contact_pubnio",
3504
+ "reconnect_account",
3505
+ "wait_for_repair",
3506
+ "upgrade_plan",
3507
+ "add_credit",
3508
+ "raise_spend_cap"
3509
+ ])
3510
+ });
3511
+ var InboxDeliveryGap = Schema21.Struct({
3512
+ from: Schema21.String,
3513
+ to: Schema21.String,
3514
+ action: Schema21.Literal("review_on_x")
3515
+ });
3307
3516
  var InboxChannelCapability = Schema21.Struct({
3308
3517
  resource: InboxResource,
3309
3518
  supported: Schema21.Boolean,
@@ -3316,7 +3525,8 @@ var InboxChannelCapability = Schema21.Struct({
3316
3525
  syncMode: InboxSyncMode,
3317
3526
  backfillDays: Schema21.Int,
3318
3527
  missingScopes: Schema21.Array(Schema21.String),
3319
- missingTasks: Schema21.Array(Schema21.String)
3528
+ missingTasks: Schema21.Array(Schema21.String),
3529
+ unavailable: Schema21.NullOr(InboxUnavailableState)
3320
3530
  }).annotate({ identifier: "InboxChannelCapability" });
3321
3531
  var InboxAccountCapabilities = Schema21.Struct({
3322
3532
  accountId: AccountId,
@@ -3331,6 +3541,7 @@ var InboxAccountCapabilities = Schema21.Struct({
3331
3541
  mentions: InboxChannelCapability,
3332
3542
  replyWindow: InboxReplyWindow,
3333
3543
  lastSyncError: Schema21.NullOr(Schema21.String),
3544
+ deliveryGap: Schema21.NullOr(InboxDeliveryGap),
3334
3545
  checkedAt: Schema21.String
3335
3546
  }).annotate({ identifier: "InboxAccountCapabilities" });
3336
3547
  var InboxCapabilities = Schema21.Struct({
@@ -4243,7 +4454,8 @@ var WorkspaceEventType = Schema26.Literals([
4243
4454
  "billing.credit.topped_up",
4244
4455
  "billing.credit.low",
4245
4456
  "billing.spend_cap.reached",
4246
- "billing.invoice.payment_failed"
4457
+ "billing.invoice.payment_failed",
4458
+ "billing.subscription.duplicate_refunded"
4247
4459
  ]);
4248
4460
  var WorkspaceEventEnvelope = Schema26.Struct({
4249
4461
  id: Schema26.String.check(Schema26.isUUID()),
@@ -4824,6 +5036,15 @@ var WebhookEvent = Schema27.Union([
4824
5036
  hostedInvoiceUrl: Schema27.NullOr(Schema27.String)
4825
5037
  })
4826
5038
  }),
5039
+ Schema27.Struct({
5040
+ ...envelope,
5041
+ type: Schema27.Literal("billing.subscription.duplicate_refunded"),
5042
+ data: Schema27.Struct({
5043
+ subscriptionId: Schema27.String,
5044
+ amountRefundedMinor: Schema27.Int,
5045
+ currency: Schema27.String
5046
+ })
5047
+ }),
4827
5048
  Schema27.Struct({
4828
5049
  ...envelope,
4829
5050
  type: Schema27.Literal("webhook.test"),
@@ -5007,6 +5228,27 @@ class SeatLimitReached extends HttpApiError.Problem()("SeatLimitReached", {
5007
5228
  }) {
5008
5229
  }
5009
5230
 
5231
+ class PlanRequired extends HttpApiError.Problem()("PlanRequired", {
5232
+ type: "urn:pubnio:problem:plan-required",
5233
+ status: 402,
5234
+ title: "Plan upgrade required"
5235
+ }, {
5236
+ code: Schema28.Literal("plan_required"),
5237
+ entitlement: Schema28.Literals([
5238
+ "adsInsights",
5239
+ "adsWrite",
5240
+ "analyticsHistory"
5241
+ ]),
5242
+ currentPlan: BillingPlanId,
5243
+ minimumPlan: BillingPlanId,
5244
+ fundingUrl: Schema28.String,
5245
+ canManageBilling: Schema28.Boolean,
5246
+ nextAction: Schema28.String,
5247
+ param: Schema28.optionalKey(Schema28.String),
5248
+ earliestDate: Schema28.optionalKey(Schema28.String)
5249
+ }) {
5250
+ }
5251
+
5010
5252
  class AlreadyMember extends HttpApiError.Problem()("AlreadyMember", {
5011
5253
  type: "urn:pubnio:problem:already-member",
5012
5254
  status: 409,
@@ -5196,6 +5438,17 @@ class DestinationAlreadySubmitted extends HttpApiError.Problem()("DestinationAlr
5196
5438
  }) {
5197
5439
  }
5198
5440
 
5441
+ class PostSubmitted extends HttpApiError.Problem()("PostSubmitted", {
5442
+ type: "urn:pubnio:problem:post-submitted",
5443
+ status: 409,
5444
+ title: "Post already submitted"
5445
+ }, {
5446
+ code: Schema28.Literal("post_submitted"),
5447
+ targetIds: Schema28.Array(TargetId),
5448
+ nextAction: Schema28.String
5449
+ }) {
5450
+ }
5451
+
5199
5452
  class DeliveryNotRetryable extends HttpApiError.Problem()("DeliveryNotRetryable", {
5200
5453
  type: "urn:pubnio:problem:delivery-not-retryable",
5201
5454
  status: 409,
@@ -5478,7 +5731,15 @@ class InboxUnsupportedContent extends HttpApiError.Problem()("InboxUnsupportedCo
5478
5731
  capability: ProductCapability
5479
5732
  }) {
5480
5733
  }
5734
+
5735
+ class InboxUnavailable extends HttpApiError.Problem()("InboxUnavailable", {
5736
+ type: "urn:pubnio:problem:inbox-unavailable",
5737
+ status: 409,
5738
+ title: "Inbox unavailable"
5739
+ }, InboxUnavailableState.fields) {
5740
+ }
5481
5741
  var InboxProblems = [
5742
+ InboxUnavailable,
5482
5743
  InboxReplyWindowClosed,
5483
5744
  InboxTargetChanged,
5484
5745
  InboxSyncInProgress,
@@ -5693,6 +5954,7 @@ var PublishProblems = [
5693
5954
  AttemptChanged,
5694
5955
  IdempotencyConflict,
5695
5956
  DestinationAlreadySubmitted,
5957
+ PostSubmitted,
5696
5958
  DeliveryNotRetryable,
5697
5959
  DeliveryNotReconcilable,
5698
5960
  DeliveryScheduleLocked,
@@ -5719,7 +5981,8 @@ var AdsProblems = [
5719
5981
  AdKillSwitchActive,
5720
5982
  AdOperationNotRetryable,
5721
5983
  AdProviderRejected,
5722
- InvalidAdRequest
5984
+ InvalidAdRequest,
5985
+ PlanRequired
5723
5986
  ];
5724
5987
  var SchedulingProblems = [
5725
5988
  QueueNotFound,
@@ -6150,7 +6413,7 @@ import { ProblemDetails } from "effect/http";
6150
6413
  // package.json
6151
6414
  var package_default = {
6152
6415
  name: "@pubnio/sdk",
6153
- version: "0.2.13",
6416
+ version: "0.4.0",
6154
6417
  description: "JavaScript and TypeScript client for the PubNio API",
6155
6418
  type: "module",
6156
6419
  exports: {
@@ -7817,6 +8080,15 @@ var postsCreate = (options) => (options.client ?? client).post({
7817
8080
  ...options.headers
7818
8081
  }
7819
8082
  });
8083
+ var postsValidateBody = (options) => (options.client ?? client).post({
8084
+ security: [{ scheme: "bearer", type: "http" }],
8085
+ url: "/api/v1/posts/validate",
8086
+ ...options,
8087
+ headers: {
8088
+ "Content-Type": "application/json",
8089
+ ...options.headers
8090
+ }
8091
+ });
7820
8092
  var postsDelete = (options) => (options.client ?? client).delete({
7821
8093
  security: [{ scheme: "bearer", type: "http" }],
7822
8094
  url: "/api/v1/posts/{postId}",
@@ -8669,7 +8941,7 @@ function createPubNioClient({
8669
8941
  return withIdempotencyKey(idempotencyKey, async () => {
8670
8942
  const body = post;
8671
8943
  if (post.isDraft) {
8672
- return decode(Post, postsCreate({
8944
+ return decode(PostCreated, postsCreate({
8673
8945
  client,
8674
8946
  query: { workspaceId },
8675
8947
  headers: { "idempotency-key": idempotencyKey },
@@ -9354,7 +9626,16 @@ function createPubNioClient({
9354
9626
  query: { workspaceId },
9355
9627
  ...transport()
9356
9628
  })),
9357
- publish: (postId, input) => {
9629
+ validateBody: (input) => {
9630
+ const body = input;
9631
+ return decode(PostValidation, postsValidateBody({
9632
+ client,
9633
+ query: { workspaceId },
9634
+ body,
9635
+ ...transport()
9636
+ }));
9637
+ },
9638
+ publish: (postId, input = {}) => {
9358
9639
  const { idempotencyKey = crypto.randomUUID(), ...publish } = input;
9359
9640
  return withIdempotencyKey(idempotencyKey, async () => {
9360
9641
  const accepted = await decode(PublishAccepted, postsPublish({
@@ -9365,7 +9646,7 @@ function createPubNioClient({
9365
9646
  body: {
9366
9647
  expectedRevision: publish.expectedRevision,
9367
9648
  scheduledAt: publish.scheduledAt,
9368
- accountIds: publish.accountIds && [...publish.accountIds],
9649
+ accounts: publish.accounts && [...publish.accounts],
9369
9650
  targets: publish.targets && [...publish.targets]
9370
9651
  },
9371
9652
  ...transport()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubnio/sdk",
3
- "version": "0.2.13",
3
+ "version": "0.4.0",
4
4
  "description": "JavaScript and TypeScript client for the PubNio API",
5
5
  "homepage": "https://pubnio.com",
6
6
  "keywords": [